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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
231,500
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.density
|
public function density($density)
{
$command = new Command\Stored\DensityCommand($density);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function density($density)
{
$command = new Command\Stored\DensityCommand($density);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"density",
"(",
"$",
"density",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Stored",
"\\",
"DensityCommand",
"(",
"$",
"density",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to select the print density.
@param int $density
@return \Epl\CommandHelper
|
[
"Use",
"this",
"command",
"to",
"select",
"the",
"print",
"density",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L139-L144
|
231,501
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.disableTopOfFormBackup
|
public function disableTopOfFormBackup()
{
$command = new Command\Stored\DisableTopOfFormBackupCommand();
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function disableTopOfFormBackup()
{
$command = new Command\Stored\DisableTopOfFormBackupCommand();
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"disableTopOfFormBackup",
"(",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Stored",
"\\",
"DisableTopOfFormBackupCommand",
"(",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
his command disable the Top Of Form Backup feature when printing multiple labels.
At power up, Top OF From Backup will be enabled.
@return CommandHelper
|
[
"his",
"command",
"disable",
"the",
"Top",
"Of",
"Form",
"Backup",
"feature",
"when",
"printing",
"multiple",
"labels",
".",
"At",
"power",
"up",
"Top",
"OF",
"From",
"Backup",
"will",
"be",
"enabled",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L166-L171
|
231,502
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.disableTopOfFormBackupAllCases
|
public function disableTopOfFormBackupAllCases()
{
$command = new Command\Stored\DisableTopOfFormBackupAllCasesCommand();
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function disableTopOfFormBackupAllCases()
{
$command = new Command\Stored\DisableTopOfFormBackupAllCasesCommand();
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"disableTopOfFormBackupAllCases",
"(",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Stored",
"\\",
"DisableTopOfFormBackupAllCasesCommand",
"(",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
This command disables the Top Of Form Backup feature for all operations.
@return CommandHelper
|
[
"This",
"command",
"disables",
"the",
"Top",
"Of",
"Form",
"Backup",
"feature",
"for",
"all",
"operations",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L177-L182
|
231,503
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.lineDrawExclusiveOR
|
public function lineDrawExclusiveOR($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength)
{
$command = new Command\Image\LineDrawExclusiveORCommand($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function lineDrawExclusiveOR($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength)
{
$command = new Command\Image\LineDrawExclusiveORCommand($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"lineDrawExclusiveOR",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"horizontalLength",
",",
"$",
"verticalLength",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Image",
"\\",
"LineDrawExclusiveORCommand",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"horizontalLength",
",",
"$",
"verticalLength",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to draw lines with an "Exclusive OR" function.
@param int $horizontalStartPosition
@param int $verticalStartPosition
@param int $horizontalLength
@param int $verticalLength
@return \Epl\CommandHelper
|
[
"Use",
"this",
"command",
"to",
"draw",
"lines",
"with",
"an",
"Exclusive",
"OR",
"function",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L205-L210
|
231,504
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.lineDrawBlack
|
public function lineDrawBlack($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength)
{
$command = new Command\Image\LineDrawBlackCommand($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function lineDrawBlack($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength)
{
$command = new Command\Image\LineDrawBlackCommand($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"lineDrawBlack",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"horizontalLength",
",",
"$",
"verticalLength",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Image",
"\\",
"LineDrawBlackCommand",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"horizontalLength",
",",
"$",
"verticalLength",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to draw black lines, overwriting previous information.
@param int $horizontalStartPosition
@param int $verticalStartPosition
@param int $horizontalLength
@param int $verticalLength
@return \Epl\CommandHelper
|
[
"Use",
"this",
"command",
"to",
"draw",
"black",
"lines",
"overwriting",
"previous",
"information",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L220-L225
|
231,505
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.lineDrawDiagonal
|
public function lineDrawDiagonal($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength, $verticalEndPosition)
{
$command = new Command\Image\LineDrawDiagonalCommand($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength, $verticalEndPosition);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function lineDrawDiagonal($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength, $verticalEndPosition)
{
$command = new Command\Image\LineDrawDiagonalCommand($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength, $verticalEndPosition);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"lineDrawDiagonal",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"horizontalLength",
",",
"$",
"verticalLength",
",",
"$",
"verticalEndPosition",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Image",
"\\",
"LineDrawDiagonalCommand",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"horizontalLength",
",",
"$",
"verticalLength",
",",
"$",
"verticalEndPosition",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to draw diagonal black lines, overwriting previous information.
@param int $horizontalStartPosition
@param int $verticalStartPosition
@param int $horizontalLength
@param int $verticalLength
@param int $verticalEndPosition
@return \Epl\CommandHelper
|
[
"Use",
"this",
"command",
"to",
"draw",
"diagonal",
"black",
"lines",
"overwriting",
"previous",
"information",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L236-L241
|
231,506
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.lineDrawWhite
|
public function lineDrawWhite($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength)
{
$command = new Command\Image\LineDrawWhiteCommand($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function lineDrawWhite($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength)
{
$command = new Command\Image\LineDrawWhiteCommand($horizontalStartPosition, $verticalStartPosition, $horizontalLength, $verticalLength);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"lineDrawWhite",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"horizontalLength",
",",
"$",
"verticalLength",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Image",
"\\",
"LineDrawWhiteCommand",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"horizontalLength",
",",
"$",
"verticalLength",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to draw white lines, effectively erasing previous information.
@param int $horizontalStartPosition
@param int $verticalStartPosition
@param int $horizontalLength
@param int $verticalLength
@return \Epl\CommandHelper
|
[
"Use",
"this",
"command",
"to",
"draw",
"white",
"lines",
"effectively",
"erasing",
"previous",
"information",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L253-L258
|
231,507
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.clearImageBuffer
|
public function clearImageBuffer()
{
$command = new Command\Image\ClearImageBufferCommand();
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function clearImageBuffer()
{
$command = new Command\Image\ClearImageBufferCommand();
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"clearImageBuffer",
"(",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Image",
"\\",
"ClearImageBufferCommand",
"(",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command clears the image buffer prior to building a new label image
@return CommandHelper
|
[
"Use",
"this",
"command",
"clears",
"the",
"image",
"buffer",
"prior",
"to",
"building",
"a",
"new",
"label",
"image"
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L264-L269
|
231,508
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.hardwareOption
|
public function hardwareOption($option, $additionalOption = null)
{
$command = new Command\Stored\HardwareOptionCommand($option, $additionalOption);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function hardwareOption($option, $additionalOption = null)
{
$command = new Command\Stored\HardwareOptionCommand($option, $additionalOption);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"hardwareOption",
"(",
"$",
"option",
",",
"$",
"additionalOption",
"=",
"null",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Stored",
"\\",
"HardwareOptionCommand",
"(",
"$",
"option",
",",
"$",
"additionalOption",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to select various printer options
@param string $option
@param null $additionalOption
@throws \Epl\ExceptionCommand
@return \Epl\CommandHelper
|
[
"Use",
"this",
"command",
"to",
"select",
"various",
"printer",
"options"
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L278-L283
|
231,509
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.printLabel
|
public function printLabel($numberOfLabels, $numberOfCopies = null)
{
$command = new Command\PrintCommand($numberOfLabels, $numberOfCopies);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function printLabel($numberOfLabels, $numberOfCopies = null)
{
$command = new Command\PrintCommand($numberOfLabels, $numberOfCopies);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"printLabel",
"(",
"$",
"numberOfLabels",
",",
"$",
"numberOfCopies",
"=",
"null",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"PrintCommand",
"(",
"$",
"numberOfLabels",
",",
"$",
"numberOfCopies",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to print the contents of the image buffer
@param int $numberOfLabels
@param null|int $numberOfCopies
@throws \Epl\ExceptionCommand
@return CommandHelper
|
[
"Use",
"this",
"command",
"to",
"print",
"the",
"contents",
"of",
"the",
"image",
"buffer"
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L292-L297
|
231,510
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.setFormWidth
|
public function setFormWidth($width)
{
$command = new Command\Stored\SetFormWidthCommand($width);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function setFormWidth($width)
{
$command = new Command\Stored\SetFormWidthCommand($width);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"setFormWidth",
"(",
"$",
"width",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Stored",
"\\",
"SetFormWidthCommand",
"(",
"$",
"width",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to set the width of the printable area of teh media in dots.
@param int $width
@return CommandHelper
|
[
"Use",
"this",
"command",
"to",
"set",
"the",
"width",
"of",
"the",
"printable",
"area",
"of",
"teh",
"media",
"in",
"dots",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L318-L323
|
231,511
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.speed
|
public function speed($speed)
{
$command = new Command\Stored\SpeedCommand($speed);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function speed($speed)
{
$command = new Command\Stored\SpeedCommand($speed);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"speed",
"(",
"$",
"speed",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Stored",
"\\",
"SpeedCommand",
"(",
"$",
"speed",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to select the print speed.
@param int $speed
@return CommandHelper
|
[
"Use",
"this",
"command",
"to",
"select",
"the",
"print",
"speed",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L345-L350
|
231,512
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.boxDraw
|
public function boxDraw($horizontalStartPosition, $verticalStartPosition, $lineThickness,
$horizontalEndPosition, $verticalEndPosition)
{
$command = new Command\Image\BoxDrawCommand($horizontalStartPosition, $verticalStartPosition, $lineThickness,
$horizontalEndPosition, $verticalEndPosition);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function boxDraw($horizontalStartPosition, $verticalStartPosition, $lineThickness,
$horizontalEndPosition, $verticalEndPosition)
{
$command = new Command\Image\BoxDrawCommand($horizontalStartPosition, $verticalStartPosition, $lineThickness,
$horizontalEndPosition, $verticalEndPosition);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"boxDraw",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"lineThickness",
",",
"$",
"horizontalEndPosition",
",",
"$",
"verticalEndPosition",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Image",
"\\",
"BoxDrawCommand",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"lineThickness",
",",
"$",
"horizontalEndPosition",
",",
"$",
"verticalEndPosition",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Use this command to draw a box shape.
@param int $horizontalStartPosition
@param int $verticalStartPosition
@param int $lineThickness
@param int $horizontalEndPosition
@param int $verticalEndPosition
@return CommandHelper
|
[
"Use",
"this",
"command",
"to",
"draw",
"a",
"box",
"shape",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L361-L368
|
231,513
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.graphicWrite
|
public function graphicWrite(
$horizontalStartPosition,
$verticalStartPosition,
$width,
$height,
$data
) {
$command = new Command\Image\GraphicWriteCommand(
$horizontalStartPosition,
$verticalStartPosition,
$width,
$height,
$data
);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function graphicWrite(
$horizontalStartPosition,
$verticalStartPosition,
$width,
$height,
$data
) {
$command = new Command\Image\GraphicWriteCommand(
$horizontalStartPosition,
$verticalStartPosition,
$width,
$height,
$data
);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"graphicWrite",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"data",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Image",
"\\",
"GraphicWriteCommand",
"(",
"$",
"horizontalStartPosition",
",",
"$",
"verticalStartPosition",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Loads binary graphic data directly into the Image Buffer memory for immediate printing.
@param integer $horizontalStartPosition
@param integer $verticalStartPosition
@param integer $width
@param integer $height
@param string $data
@return CommandHelper
|
[
"Loads",
"binary",
"graphic",
"data",
"directly",
"into",
"the",
"Image",
"Buffer",
"memory",
"for",
"immediate",
"printing",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L381-L399
|
231,514
|
opensoft/epl
|
src/Epl/CommandHelper.php
|
CommandHelper.commentLine
|
public function commentLine($commentData)
{
$command = new Command\Form\CommentLineCommand($commentData);
$this->getComposite()->addCommand($command);
return $this;
}
|
php
|
public function commentLine($commentData)
{
$command = new Command\Form\CommentLineCommand($commentData);
$this->getComposite()->addCommand($command);
return $this;
}
|
[
"public",
"function",
"commentLine",
"(",
"$",
"commentData",
")",
"{",
"$",
"command",
"=",
"new",
"Command",
"\\",
"Form",
"\\",
"CommentLineCommand",
"(",
"$",
"commentData",
")",
";",
"$",
"this",
"->",
"getComposite",
"(",
")",
"->",
"addCommand",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
This command signals the printer to ignore the following data.
@param string $commentData
@return CommandHelper
|
[
"This",
"command",
"signals",
"the",
"printer",
"to",
"ignore",
"the",
"following",
"data",
"."
] |
61a1152ed3e292d5bd3ec2758076d605bada0623
|
https://github.com/opensoft/epl/blob/61a1152ed3e292d5bd3ec2758076d605bada0623/src/Epl/CommandHelper.php#L406-L411
|
231,515
|
juliushaertl/phpdoc-to-rst
|
src/Builder/PhpDomainBuilder.php
|
PhpDomainBuilder.getNamespace
|
public static function getNamespace(Element $element) {
return substr($element->getFqsen(), 0, strlen($element->getFqsen())-strlen('\\'. $element->getName()));
//return str_replace('\\' . $element->getName(), '', $element->getFqsen());
}
|
php
|
public static function getNamespace(Element $element) {
return substr($element->getFqsen(), 0, strlen($element->getFqsen())-strlen('\\'. $element->getName()));
//return str_replace('\\' . $element->getName(), '', $element->getFqsen());
}
|
[
"public",
"static",
"function",
"getNamespace",
"(",
"Element",
"$",
"element",
")",
"{",
"return",
"substr",
"(",
"$",
"element",
"->",
"getFqsen",
"(",
")",
",",
"0",
",",
"strlen",
"(",
"$",
"element",
"->",
"getFqsen",
"(",
")",
")",
"-",
"strlen",
"(",
"'\\\\'",
".",
"$",
"element",
"->",
"getName",
"(",
")",
")",
")",
";",
"//return str_replace('\\\\' . $element->getName(), '', $element->getFqsen());",
"}"
] |
Strip element name from Fqsen to return the namespace only
@param Element $element
@return mixed
|
[
"Strip",
"element",
"name",
"from",
"Fqsen",
"to",
"return",
"the",
"namespace",
"only"
] |
9a695417d1f3bb709f60cd5c519e46f1ad08c843
|
https://github.com/juliushaertl/phpdoc-to-rst/blob/9a695417d1f3bb709f60cd5c519e46f1ad08c843/src/Builder/PhpDomainBuilder.php#L72-L75
|
231,516
|
praxisnetau/silverware
|
src/Components/PageComponent.php
|
PageComponent.getCurrentPageAttributes
|
public function getCurrentPageAttributes()
{
// Create Attributes Array:
$attributes = [];
// Define Attributes Array:
if ($id = $this->getCurrentPageClassID()) {
$attributes['id'] = $id;
}
if ($class = $this->getCurrentPageAncestry()) {
$attributes['class'] = $class;
}
// Extend Attributes Array:
$this->extend('updateCurrentPageAttributes', $attributes);
// Answer Attributes Array:
return $attributes;
}
|
php
|
public function getCurrentPageAttributes()
{
// Create Attributes Array:
$attributes = [];
// Define Attributes Array:
if ($id = $this->getCurrentPageClassID()) {
$attributes['id'] = $id;
}
if ($class = $this->getCurrentPageAncestry()) {
$attributes['class'] = $class;
}
// Extend Attributes Array:
$this->extend('updateCurrentPageAttributes', $attributes);
// Answer Attributes Array:
return $attributes;
}
|
[
"public",
"function",
"getCurrentPageAttributes",
"(",
")",
"{",
"// Create Attributes Array:",
"$",
"attributes",
"=",
"[",
"]",
";",
"// Define Attributes Array:",
"if",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"getCurrentPageClassID",
"(",
")",
")",
"{",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"}",
"if",
"(",
"$",
"class",
"=",
"$",
"this",
"->",
"getCurrentPageAncestry",
"(",
")",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"$",
"class",
";",
"}",
"// Extend Attributes Array:",
"$",
"this",
"->",
"extend",
"(",
"'updateCurrentPageAttributes'",
",",
"$",
"attributes",
")",
";",
"// Answer Attributes Array:",
"return",
"$",
"attributes",
";",
"}"
] |
Answers the attributes for the current page as an array.
@return array
|
[
"Answers",
"the",
"attributes",
"for",
"the",
"current",
"page",
"as",
"an",
"array",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/PageComponent.php#L187-L210
|
231,517
|
praxisnetau/silverware
|
src/Grid/Column.php
|
Column.getSpanViewports
|
public function getSpanViewports()
{
if ($this->hasColumnSpans()) {
foreach ($this->ColumnSpans() as $span) {
if ($span->isActive()) {
return $span->getSpanViewports();
}
}
}
return $this->owner->dbObject('Span');
}
|
php
|
public function getSpanViewports()
{
if ($this->hasColumnSpans()) {
foreach ($this->ColumnSpans() as $span) {
if ($span->isActive()) {
return $span->getSpanViewports();
}
}
}
return $this->owner->dbObject('Span');
}
|
[
"public",
"function",
"getSpanViewports",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasColumnSpans",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"ColumnSpans",
"(",
")",
"as",
"$",
"span",
")",
"{",
"if",
"(",
"$",
"span",
"->",
"isActive",
"(",
")",
")",
"{",
"return",
"$",
"span",
"->",
"getSpanViewports",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"owner",
"->",
"dbObject",
"(",
"'Span'",
")",
";",
"}"
] |
Answers the span viewports field defined for the column.
@return DBViewports
|
[
"Answers",
"the",
"span",
"viewports",
"field",
"defined",
"for",
"the",
"column",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/Column.php#L301-L316
|
231,518
|
praxisnetau/silverware
|
src/Extensions/Model/DetailFieldsExtension.php
|
DetailFieldsExtension.getDetailFields
|
public function getDetailFields()
{
// Create Details List:
$details = ArrayList::create();
// Define Details List:
foreach ($this->owner->getDetailFieldsConfig() as $name => $spec) {
if ($spec) {
if (!is_array($spec)) {
$spec = ['text' => $spec];
}
foreach ($spec as $item => $value) {
$args = [];
if (is_array($value)) {
$args = $value;
$value = array_shift($args);
}
$spec[$item] = $this->owner->processDetailFieldValue($value, $args);
}
$text = isset($spec['text']) ? $spec['text'] : null;
if ($text) {
if (isset($spec['show']) && !$this->owner->{$spec['show']}) {
continue;
}
$details->push(
ArrayData::create([
'Name' => isset($spec['name']) ? $spec['name'] : $name,
'Icon' => isset($spec['icon']) ? $spec['icon'] : null,
'Text' => $text
])
);
}
}
}
// Answer Details List:
return $details;
}
|
php
|
public function getDetailFields()
{
// Create Details List:
$details = ArrayList::create();
// Define Details List:
foreach ($this->owner->getDetailFieldsConfig() as $name => $spec) {
if ($spec) {
if (!is_array($spec)) {
$spec = ['text' => $spec];
}
foreach ($spec as $item => $value) {
$args = [];
if (is_array($value)) {
$args = $value;
$value = array_shift($args);
}
$spec[$item] = $this->owner->processDetailFieldValue($value, $args);
}
$text = isset($spec['text']) ? $spec['text'] : null;
if ($text) {
if (isset($spec['show']) && !$this->owner->{$spec['show']}) {
continue;
}
$details->push(
ArrayData::create([
'Name' => isset($spec['name']) ? $spec['name'] : $name,
'Icon' => isset($spec['icon']) ? $spec['icon'] : null,
'Text' => $text
])
);
}
}
}
// Answer Details List:
return $details;
}
|
[
"public",
"function",
"getDetailFields",
"(",
")",
"{",
"// Create Details List:",
"$",
"details",
"=",
"ArrayList",
"::",
"create",
"(",
")",
";",
"// Define Details List:",
"foreach",
"(",
"$",
"this",
"->",
"owner",
"->",
"getDetailFieldsConfig",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"spec",
")",
"{",
"if",
"(",
"$",
"spec",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"spec",
")",
")",
"{",
"$",
"spec",
"=",
"[",
"'text'",
"=>",
"$",
"spec",
"]",
";",
"}",
"foreach",
"(",
"$",
"spec",
"as",
"$",
"item",
"=>",
"$",
"value",
")",
"{",
"$",
"args",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"args",
"=",
"$",
"value",
";",
"$",
"value",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"}",
"$",
"spec",
"[",
"$",
"item",
"]",
"=",
"$",
"this",
"->",
"owner",
"->",
"processDetailFieldValue",
"(",
"$",
"value",
",",
"$",
"args",
")",
";",
"}",
"$",
"text",
"=",
"isset",
"(",
"$",
"spec",
"[",
"'text'",
"]",
")",
"?",
"$",
"spec",
"[",
"'text'",
"]",
":",
"null",
";",
"if",
"(",
"$",
"text",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"spec",
"[",
"'show'",
"]",
")",
"&&",
"!",
"$",
"this",
"->",
"owner",
"->",
"{",
"$",
"spec",
"[",
"'show'",
"]",
"}",
")",
"{",
"continue",
";",
"}",
"$",
"details",
"->",
"push",
"(",
"ArrayData",
"::",
"create",
"(",
"[",
"'Name'",
"=>",
"isset",
"(",
"$",
"spec",
"[",
"'name'",
"]",
")",
"?",
"$",
"spec",
"[",
"'name'",
"]",
":",
"$",
"name",
",",
"'Icon'",
"=>",
"isset",
"(",
"$",
"spec",
"[",
"'icon'",
"]",
")",
"?",
"$",
"spec",
"[",
"'icon'",
"]",
":",
"null",
",",
"'Text'",
"=>",
"$",
"text",
"]",
")",
")",
";",
"}",
"}",
"}",
"// Answer Details List:",
"return",
"$",
"details",
";",
"}"
] |
Answers an array list object containing the detail fields for the template.
@return ArrayList
|
[
"Answers",
"an",
"array",
"list",
"object",
"containing",
"the",
"detail",
"fields",
"for",
"the",
"template",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/DetailFieldsExtension.php#L98-L152
|
231,519
|
praxisnetau/silverware
|
src/Extensions/Model/DetailFieldsExtension.php
|
DetailFieldsExtension.getDetailFieldsConfig
|
public function getDetailFieldsConfig()
{
$config = $this->owner->getDefaultDetailFieldsConfig();
if (is_array($this->owner->config()->detail_fields)) {
foreach ($this->owner->config()->detail_fields as $name => $spec) {
if (!$spec) {
unset($config[$name]);
}
}
$config = array_merge_recursive($config, $this->owner->config()->detail_fields);
}
return $config;
}
|
php
|
public function getDetailFieldsConfig()
{
$config = $this->owner->getDefaultDetailFieldsConfig();
if (is_array($this->owner->config()->detail_fields)) {
foreach ($this->owner->config()->detail_fields as $name => $spec) {
if (!$spec) {
unset($config[$name]);
}
}
$config = array_merge_recursive($config, $this->owner->config()->detail_fields);
}
return $config;
}
|
[
"public",
"function",
"getDetailFieldsConfig",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"owner",
"->",
"getDefaultDetailFieldsConfig",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"detail_fields",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"detail_fields",
"as",
"$",
"name",
"=>",
"$",
"spec",
")",
"{",
"if",
"(",
"!",
"$",
"spec",
")",
"{",
"unset",
"(",
"$",
"config",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}",
"$",
"config",
"=",
"array_merge_recursive",
"(",
"$",
"config",
",",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"detail_fields",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Answers the detail fields config for the extended object.
@return array
|
[
"Answers",
"the",
"detail",
"fields",
"config",
"for",
"the",
"extended",
"object",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/DetailFieldsExtension.php#L169-L188
|
231,520
|
praxisnetau/silverware
|
src/Extensions/Model/DetailFieldsExtension.php
|
DetailFieldsExtension.getDefaultDetailFieldsConfig
|
public function getDefaultDetailFieldsConfig()
{
if (is_array($this->owner->config()->default_detail_fields)) {
return $this->owner->config()->default_detail_fields;
}
return [];
}
|
php
|
public function getDefaultDetailFieldsConfig()
{
if (is_array($this->owner->config()->default_detail_fields)) {
return $this->owner->config()->default_detail_fields;
}
return [];
}
|
[
"public",
"function",
"getDefaultDetailFieldsConfig",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"default_detail_fields",
")",
")",
"{",
"return",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"default_detail_fields",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
Answers the default detail fields config for the extended object.
@return array
|
[
"Answers",
"the",
"default",
"detail",
"fields",
"config",
"for",
"the",
"extended",
"object",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/DetailFieldsExtension.php#L195-L202
|
231,521
|
praxisnetau/silverware
|
src/Extensions/Model/DetailFieldsExtension.php
|
DetailFieldsExtension.getDetailFieldsHeadingTag
|
public function getDetailFieldsHeadingTag()
{
$tag = $this->owner->config()->detail_fields_heading_level;
return $tag ? $tag : Config::inst()->get(static::class, 'default_detail_fields_heading_level');
}
|
php
|
public function getDetailFieldsHeadingTag()
{
$tag = $this->owner->config()->detail_fields_heading_level;
return $tag ? $tag : Config::inst()->get(static::class, 'default_detail_fields_heading_level');
}
|
[
"public",
"function",
"getDetailFieldsHeadingTag",
"(",
")",
"{",
"$",
"tag",
"=",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"detail_fields_heading_level",
";",
"return",
"$",
"tag",
"?",
"$",
"tag",
":",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"static",
"::",
"class",
",",
"'default_detail_fields_heading_level'",
")",
";",
"}"
] |
Answers the heading tag for the detail fields section.
@return string
|
[
"Answers",
"the",
"heading",
"tag",
"for",
"the",
"detail",
"fields",
"section",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/DetailFieldsExtension.php#L209-L214
|
231,522
|
praxisnetau/silverware
|
src/Extensions/Model/DetailFieldsExtension.php
|
DetailFieldsExtension.getDetailFieldHeadingTag
|
public function getDetailFieldHeadingTag()
{
$tag = $this->owner->config()->detail_field_heading_level;
return $tag ? $tag : Config::inst()->get(static::class, 'default_detail_field_heading_level');
}
|
php
|
public function getDetailFieldHeadingTag()
{
$tag = $this->owner->config()->detail_field_heading_level;
return $tag ? $tag : Config::inst()->get(static::class, 'default_detail_field_heading_level');
}
|
[
"public",
"function",
"getDetailFieldHeadingTag",
"(",
")",
"{",
"$",
"tag",
"=",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"detail_field_heading_level",
";",
"return",
"$",
"tag",
"?",
"$",
"tag",
":",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"static",
"::",
"class",
",",
"'default_detail_field_heading_level'",
")",
";",
"}"
] |
Answers the heading tag for an individual detail field.
@return string
|
[
"Answers",
"the",
"heading",
"tag",
"for",
"an",
"individual",
"detail",
"field",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/DetailFieldsExtension.php#L221-L226
|
231,523
|
praxisnetau/silverware
|
src/Extensions/Model/DetailFieldsExtension.php
|
DetailFieldsExtension.getDetailFieldsClassNames
|
public function getDetailFieldsClassNames()
{
$classes = ['detail-fields'];
$classes[] = $this->owner->DetailFieldsInline ? 'inline' : 'block';
if ($this->owner->DetailFieldsHideIcons) {
$classes[] = 'hide-icons';
}
if ($this->owner->DetailFieldsHideNames) {
$classes[] = 'hide-names';
}
if ($this->owner->DetailFieldsHideHeader) {
$classes[] = 'hide-header';
}
$this->owner->extend('updateDetailFieldsClassNames', $classes);
return $classes;
}
|
php
|
public function getDetailFieldsClassNames()
{
$classes = ['detail-fields'];
$classes[] = $this->owner->DetailFieldsInline ? 'inline' : 'block';
if ($this->owner->DetailFieldsHideIcons) {
$classes[] = 'hide-icons';
}
if ($this->owner->DetailFieldsHideNames) {
$classes[] = 'hide-names';
}
if ($this->owner->DetailFieldsHideHeader) {
$classes[] = 'hide-header';
}
$this->owner->extend('updateDetailFieldsClassNames', $classes);
return $classes;
}
|
[
"public",
"function",
"getDetailFieldsClassNames",
"(",
")",
"{",
"$",
"classes",
"=",
"[",
"'detail-fields'",
"]",
";",
"$",
"classes",
"[",
"]",
"=",
"$",
"this",
"->",
"owner",
"->",
"DetailFieldsInline",
"?",
"'inline'",
":",
"'block'",
";",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"DetailFieldsHideIcons",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'hide-icons'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"DetailFieldsHideNames",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'hide-names'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"DetailFieldsHideHeader",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'hide-header'",
";",
"}",
"$",
"this",
"->",
"owner",
"->",
"extend",
"(",
"'updateDetailFieldsClassNames'",
",",
"$",
"classes",
")",
";",
"return",
"$",
"classes",
";",
"}"
] |
Answers an array of class names for the detail fields wrapper.
@return array
|
[
"Answers",
"an",
"array",
"of",
"class",
"names",
"for",
"the",
"detail",
"fields",
"wrapper",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/DetailFieldsExtension.php#L323-L344
|
231,524
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.isImageShown
|
public function isImageShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Image', $isFirst, $isMiddle, $isLast);
}
|
php
|
public function isImageShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Image', $isFirst, $isMiddle, $isLast);
}
|
[
"public",
"function",
"isImageShown",
"(",
"$",
"isFirst",
"=",
"false",
",",
"$",
"isMiddle",
"=",
"false",
",",
"$",
"isLast",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"isShown",
"(",
"'Image'",
",",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
";",
"}"
] |
Answers true if the image is to be shown for the current list item.
@param boolean $isFirst Item is first in the list.
@param boolean $isMiddle Item is in the middle of the list.
@param boolean $isLast Item is last in the list.
@return boolean
|
[
"Answers",
"true",
"if",
"the",
"image",
"is",
"to",
"be",
"shown",
"for",
"the",
"current",
"list",
"item",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L498-L501
|
231,525
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.isHeaderShown
|
public function isHeaderShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Header', $isFirst, $isMiddle, $isLast);
}
|
php
|
public function isHeaderShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Header', $isFirst, $isMiddle, $isLast);
}
|
[
"public",
"function",
"isHeaderShown",
"(",
"$",
"isFirst",
"=",
"false",
",",
"$",
"isMiddle",
"=",
"false",
",",
"$",
"isLast",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"isShown",
"(",
"'Header'",
",",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
";",
"}"
] |
Answers true if the header is to be shown for the current list item.
@param boolean $isFirst Item is first in the list.
@param boolean $isMiddle Item is in the middle of the list.
@param boolean $isLast Item is last in the list.
@return boolean
|
[
"Answers",
"true",
"if",
"the",
"header",
"is",
"to",
"be",
"shown",
"for",
"the",
"current",
"list",
"item",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L512-L515
|
231,526
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.isDetailsShown
|
public function isDetailsShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Details', $isFirst, $isMiddle, $isLast);
}
|
php
|
public function isDetailsShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Details', $isFirst, $isMiddle, $isLast);
}
|
[
"public",
"function",
"isDetailsShown",
"(",
"$",
"isFirst",
"=",
"false",
",",
"$",
"isMiddle",
"=",
"false",
",",
"$",
"isLast",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"isShown",
"(",
"'Details'",
",",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
";",
"}"
] |
Answers true if the details are to be shown for the current list item.
@param boolean $isFirst Item is first in the list.
@param boolean $isMiddle Item is in the middle of the list.
@param boolean $isLast Item is last in the list.
@return boolean
|
[
"Answers",
"true",
"if",
"the",
"details",
"are",
"to",
"be",
"shown",
"for",
"the",
"current",
"list",
"item",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L526-L529
|
231,527
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.isSummaryShown
|
public function isSummaryShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Summary', $isFirst, $isMiddle, $isLast);
}
|
php
|
public function isSummaryShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Summary', $isFirst, $isMiddle, $isLast);
}
|
[
"public",
"function",
"isSummaryShown",
"(",
"$",
"isFirst",
"=",
"false",
",",
"$",
"isMiddle",
"=",
"false",
",",
"$",
"isLast",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"isShown",
"(",
"'Summary'",
",",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
";",
"}"
] |
Answers true if the summary is to be shown for the current list item.
@param boolean $isFirst Item is first in the list.
@param boolean $isMiddle Item is in the middle of the list.
@param boolean $isLast Item is last in the list.
@return boolean
|
[
"Answers",
"true",
"if",
"the",
"summary",
"is",
"to",
"be",
"shown",
"for",
"the",
"current",
"list",
"item",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L540-L543
|
231,528
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.isContentShown
|
public function isContentShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Content', $isFirst, $isMiddle, $isLast);
}
|
php
|
public function isContentShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Content', $isFirst, $isMiddle, $isLast);
}
|
[
"public",
"function",
"isContentShown",
"(",
"$",
"isFirst",
"=",
"false",
",",
"$",
"isMiddle",
"=",
"false",
",",
"$",
"isLast",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"isShown",
"(",
"'Content'",
",",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
";",
"}"
] |
Answers true if the content is to be shown for the current list item.
@param boolean $isFirst Item is first in the list.
@param boolean $isMiddle Item is in the middle of the list.
@param boolean $isLast Item is last in the list.
@return boolean
|
[
"Answers",
"true",
"if",
"the",
"content",
"is",
"to",
"be",
"shown",
"for",
"the",
"current",
"list",
"item",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L554-L557
|
231,529
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.isContentEmpty
|
public function isContentEmpty($isFirst = false, $isMiddle = false, $isLast = false)
{
return !(
$this->isHeaderShown($isFirst, $isMiddle, $isLast) ||
$this->isDetailsShown($isFirst, $isMiddle, $isLast) ||
$this->isSummaryShown($isFirst, $isMiddle, $isLast) ||
$this->isContentShown($isFirst, $isMiddle, $isLast) ||
$this->isFooterShown($isFirst, $isMiddle, $isLast)
);
}
|
php
|
public function isContentEmpty($isFirst = false, $isMiddle = false, $isLast = false)
{
return !(
$this->isHeaderShown($isFirst, $isMiddle, $isLast) ||
$this->isDetailsShown($isFirst, $isMiddle, $isLast) ||
$this->isSummaryShown($isFirst, $isMiddle, $isLast) ||
$this->isContentShown($isFirst, $isMiddle, $isLast) ||
$this->isFooterShown($isFirst, $isMiddle, $isLast)
);
}
|
[
"public",
"function",
"isContentEmpty",
"(",
"$",
"isFirst",
"=",
"false",
",",
"$",
"isMiddle",
"=",
"false",
",",
"$",
"isLast",
"=",
"false",
")",
"{",
"return",
"!",
"(",
"$",
"this",
"->",
"isHeaderShown",
"(",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
"||",
"$",
"this",
"->",
"isDetailsShown",
"(",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
"||",
"$",
"this",
"->",
"isSummaryShown",
"(",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
"||",
"$",
"this",
"->",
"isContentShown",
"(",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
"||",
"$",
"this",
"->",
"isFooterShown",
"(",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
")",
";",
"}"
] |
Answers true if the content section is empty for the current list item.
@param boolean $isFirst Item is first in the list.
@param boolean $isMiddle Item is in the middle of the list.
@param boolean $isLast Item is last in the list.
@return boolean
|
[
"Answers",
"true",
"if",
"the",
"content",
"section",
"is",
"empty",
"for",
"the",
"current",
"list",
"item",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L568-L577
|
231,530
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.isFooterShown
|
public function isFooterShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Footer', $isFirst, $isMiddle, $isLast);
}
|
php
|
public function isFooterShown($isFirst = false, $isMiddle = false, $isLast = false)
{
return $this->isShown('Footer', $isFirst, $isMiddle, $isLast);
}
|
[
"public",
"function",
"isFooterShown",
"(",
"$",
"isFirst",
"=",
"false",
",",
"$",
"isMiddle",
"=",
"false",
",",
"$",
"isLast",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"isShown",
"(",
"'Footer'",
",",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
";",
"}"
] |
Answers true if the footer is to be shown for the current list item.
@param boolean $isFirst Item is first in the list.
@param boolean $isMiddle Item is in the middle of the list.
@param boolean $isLast Item is last in the list.
@return boolean
|
[
"Answers",
"true",
"if",
"the",
"footer",
"is",
"to",
"be",
"shown",
"for",
"the",
"current",
"list",
"item",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L588-L591
|
231,531
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.getShowOptions
|
public function getShowOptions()
{
return [
self::SHOW_NONE => _t(__CLASS__ . '.NONE', 'None'),
self::SHOW_FIRST => _t(__CLASS__ . '.FIRST', 'First'),
self::SHOW_LAST => _t(__CLASS__ . '.LAST', 'Last'),
self::SHOW_ALL => _t(__CLASS__ . '.ALL', 'All')
];
}
|
php
|
public function getShowOptions()
{
return [
self::SHOW_NONE => _t(__CLASS__ . '.NONE', 'None'),
self::SHOW_FIRST => _t(__CLASS__ . '.FIRST', 'First'),
self::SHOW_LAST => _t(__CLASS__ . '.LAST', 'Last'),
self::SHOW_ALL => _t(__CLASS__ . '.ALL', 'All')
];
}
|
[
"public",
"function",
"getShowOptions",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"SHOW_NONE",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.NONE'",
",",
"'None'",
")",
",",
"self",
"::",
"SHOW_FIRST",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.FIRST'",
",",
"'First'",
")",
",",
"self",
"::",
"SHOW_LAST",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.LAST'",
",",
"'Last'",
")",
",",
"self",
"::",
"SHOW_ALL",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.ALL'",
",",
"'All'",
")",
"]",
";",
"}"
] |
Answers an array of options for the show fields.
@return array
|
[
"Answers",
"an",
"array",
"of",
"options",
"for",
"the",
"show",
"fields",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L650-L658
|
231,532
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.getImageAlignOptions
|
public function getImageAlignOptions()
{
return [
self::IMAGE_ALIGN_LEFT => _t(__CLASS__ . '.LEFT', 'Left'),
self::IMAGE_ALIGN_RIGHT => _t(__CLASS__ . '.LEFT', 'Right'),
self::IMAGE_ALIGN_STAGGER => _t(__CLASS__ . '.LEFT', 'Stagger')
];
}
|
php
|
public function getImageAlignOptions()
{
return [
self::IMAGE_ALIGN_LEFT => _t(__CLASS__ . '.LEFT', 'Left'),
self::IMAGE_ALIGN_RIGHT => _t(__CLASS__ . '.LEFT', 'Right'),
self::IMAGE_ALIGN_STAGGER => _t(__CLASS__ . '.LEFT', 'Stagger')
];
}
|
[
"public",
"function",
"getImageAlignOptions",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"IMAGE_ALIGN_LEFT",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.LEFT'",
",",
"'Left'",
")",
",",
"self",
"::",
"IMAGE_ALIGN_RIGHT",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.LEFT'",
",",
"'Right'",
")",
",",
"self",
"::",
"IMAGE_ALIGN_STAGGER",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.LEFT'",
",",
"'Stagger'",
")",
"]",
";",
"}"
] |
Answers an array of options for the image align field.
@return array
|
[
"Answers",
"an",
"array",
"of",
"options",
"for",
"the",
"image",
"align",
"field",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L665-L672
|
231,533
|
praxisnetau/silverware
|
src/Components/BaseListComponent.php
|
BaseListComponent.isShown
|
protected function isShown($name, $isFirst, $isMiddle, $isLast)
{
if (!$this->{"Show{$name}"} || $this->{"Show{$name}"} == self::SHOW_NONE) {
return false;
}
return (
($this->{"Show{$name}"} == self::SHOW_FIRST && $isFirst) ||
($this->{"Show{$name}"} == self::SHOW_LAST && $isLast) ||
($this->{"Show{$name}"} == self::SHOW_ALL)
);
}
|
php
|
protected function isShown($name, $isFirst, $isMiddle, $isLast)
{
if (!$this->{"Show{$name}"} || $this->{"Show{$name}"} == self::SHOW_NONE) {
return false;
}
return (
($this->{"Show{$name}"} == self::SHOW_FIRST && $isFirst) ||
($this->{"Show{$name}"} == self::SHOW_LAST && $isLast) ||
($this->{"Show{$name}"} == self::SHOW_ALL)
);
}
|
[
"protected",
"function",
"isShown",
"(",
"$",
"name",
",",
"$",
"isFirst",
",",
"$",
"isMiddle",
",",
"$",
"isLast",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"{",
"\"Show{$name}\"",
"}",
"||",
"$",
"this",
"->",
"{",
"\"Show{$name}\"",
"}",
"==",
"self",
"::",
"SHOW_NONE",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"(",
"$",
"this",
"->",
"{",
"\"Show{$name}\"",
"}",
"==",
"self",
"::",
"SHOW_FIRST",
"&&",
"$",
"isFirst",
")",
"||",
"(",
"$",
"this",
"->",
"{",
"\"Show{$name}\"",
"}",
"==",
"self",
"::",
"SHOW_LAST",
"&&",
"$",
"isLast",
")",
"||",
"(",
"$",
"this",
"->",
"{",
"\"Show{$name}\"",
"}",
"==",
"self",
"::",
"SHOW_ALL",
")",
")",
";",
"}"
] |
Answers true if the part with the given name is shown.
@param string $name Name of part.
@param boolean $isFirst Item is first in the list.
@param boolean $isMiddle Item is in the middle of the list.
@param boolean $isLast Item is last in the list.
@return boolean
|
[
"Answers",
"true",
"if",
"the",
"part",
"with",
"the",
"given",
"name",
"is",
"shown",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/BaseListComponent.php#L711-L722
|
231,534
|
kamilZ/B2Backblaze
|
src/B2Backblaze/B2Response.php
|
B2Response.getHeaders
|
public function getHeaders()
{
$headers = $this->response->getHeaders();
$result = array();
if(!is_array($headers)) {
return $result;
}
foreach ($headers as $part) {
$middle=explode(": ",$part,2);
if(count($middle) == 2){
$result[trim($middle[0])] = trim($middle[1]);
}
}
return $result;
}
|
php
|
public function getHeaders()
{
$headers = $this->response->getHeaders();
$result = array();
if(!is_array($headers)) {
return $result;
}
foreach ($headers as $part) {
$middle=explode(": ",$part,2);
if(count($middle) == 2){
$result[trim($middle[0])] = trim($middle[1]);
}
}
return $result;
}
|
[
"public",
"function",
"getHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"response",
"->",
"getHeaders",
"(",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"headers",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"part",
")",
"{",
"$",
"middle",
"=",
"explode",
"(",
"\": \"",
",",
"$",
"part",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"middle",
")",
"==",
"2",
")",
"{",
"$",
"result",
"[",
"trim",
"(",
"$",
"middle",
"[",
"0",
"]",
")",
"]",
"=",
"trim",
"(",
"$",
"middle",
"[",
"1",
"]",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns the response headers.
@return array|null
|
[
"Returns",
"the",
"response",
"headers",
"."
] |
64d25e60849f7bcb957a070af3231694da118f55
|
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Response.php#L84-L98
|
231,535
|
kamilZ/B2Backblaze
|
src/B2Backblaze/B2Response.php
|
B2Response.isOk
|
public function isOk($errorCheck = true)
{
return $this->response->isOk() && ($errorCheck ? (!array_key_exists('code', $this->data)) : true);
}
|
php
|
public function isOk($errorCheck = true)
{
return $this->response->isOk() && ($errorCheck ? (!array_key_exists('code', $this->data)) : true);
}
|
[
"public",
"function",
"isOk",
"(",
"$",
"errorCheck",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"response",
"->",
"isOk",
"(",
")",
"&&",
"(",
"$",
"errorCheck",
"?",
"(",
"!",
"array_key_exists",
"(",
"'code'",
",",
"$",
"this",
"->",
"data",
")",
")",
":",
"true",
")",
";",
"}"
] |
Returns true if the response status code is 200.
@param bool $errorCheck
@return bool
|
[
"Returns",
"true",
"if",
"the",
"response",
"status",
"code",
"is",
"200",
"."
] |
64d25e60849f7bcb957a070af3231694da118f55
|
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Response.php#L107-L110
|
231,536
|
crisu83/yii-sentry
|
components/SentryErrorHandler.php
|
SentryErrorHandler.onShutdown
|
public function onShutdown()
{
$error = error_get_last();
if ($error !== null) {
$errors = array(
E_ERROR,
E_PARSE,
E_CORE_ERROR,
E_CORE_WARNING,
E_COMPILE_ERROR,
E_COMPILE_WARNING,
E_STRICT
);
if (in_array($error['type'], $errors)) {
$this->getSentryClient()->captureException(
$this->createErrorException($error['message'], $error['type'], $error['file'], $error['line'])
);
}
}
}
|
php
|
public function onShutdown()
{
$error = error_get_last();
if ($error !== null) {
$errors = array(
E_ERROR,
E_PARSE,
E_CORE_ERROR,
E_CORE_WARNING,
E_COMPILE_ERROR,
E_COMPILE_WARNING,
E_STRICT
);
if (in_array($error['type'], $errors)) {
$this->getSentryClient()->captureException(
$this->createErrorException($error['message'], $error['type'], $error['file'], $error['line'])
);
}
}
}
|
[
"public",
"function",
"onShutdown",
"(",
")",
"{",
"$",
"error",
"=",
"error_get_last",
"(",
")",
";",
"if",
"(",
"$",
"error",
"!==",
"null",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
"E_ERROR",
",",
"E_PARSE",
",",
"E_CORE_ERROR",
",",
"E_CORE_WARNING",
",",
"E_COMPILE_ERROR",
",",
"E_COMPILE_WARNING",
",",
"E_STRICT",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"error",
"[",
"'type'",
"]",
",",
"$",
"errors",
")",
")",
"{",
"$",
"this",
"->",
"getSentryClient",
"(",
")",
"->",
"captureException",
"(",
"$",
"this",
"->",
"createErrorException",
"(",
"$",
"error",
"[",
"'message'",
"]",
",",
"$",
"error",
"[",
"'type'",
"]",
",",
"$",
"error",
"[",
"'file'",
"]",
",",
"$",
"error",
"[",
"'line'",
"]",
")",
")",
";",
"}",
"}",
"}"
] |
Invoked on shutdown to attempt to capture any unhandled errors.
|
[
"Invoked",
"on",
"shutdown",
"to",
"attempt",
"to",
"capture",
"any",
"unhandled",
"errors",
"."
] |
beacc88e06a0eb32903e4eae63cc6cddea901524
|
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryErrorHandler.php#L32-L51
|
231,537
|
crisu83/yii-sentry
|
components/SentryErrorHandler.php
|
SentryErrorHandler.createErrorException
|
protected function createErrorException($message, $code, $file, $line)
{
return new ErrorException($message, $code, 0/* will be resolved */, $file, $line);
}
|
php
|
protected function createErrorException($message, $code, $file, $line)
{
return new ErrorException($message, $code, 0/* will be resolved */, $file, $line);
}
|
[
"protected",
"function",
"createErrorException",
"(",
"$",
"message",
",",
"$",
"code",
",",
"$",
"file",
",",
"$",
"line",
")",
"{",
"return",
"new",
"ErrorException",
"(",
"$",
"message",
",",
"$",
"code",
",",
"0",
"/* will be resolved */",
",",
"$",
"file",
",",
"$",
"line",
")",
";",
"}"
] |
Creates an error exception.
@param string $message error message.
@param int $code error code.
@param string $file file in which the error occurred.
@param int $line line number on which the error occurred.
@return ErrorException exception instance.
|
[
"Creates",
"an",
"error",
"exception",
"."
] |
beacc88e06a0eb32903e4eae63cc6cddea901524
|
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryErrorHandler.php#L85-L88
|
231,538
|
crisu83/yii-sentry
|
components/SentryErrorHandler.php
|
SentryErrorHandler.getSentryClient
|
public function getSentryClient()
{
if (!Yii::app()->hasComponent($this->sentryClientID)) {
throw new CException(sprintf('SentryErrorHandler.componentID "%s" is invalid.', $this->sentryClientID));
}
return Yii::app()->getComponent($this->sentryClientID);
}
|
php
|
public function getSentryClient()
{
if (!Yii::app()->hasComponent($this->sentryClientID)) {
throw new CException(sprintf('SentryErrorHandler.componentID "%s" is invalid.', $this->sentryClientID));
}
return Yii::app()->getComponent($this->sentryClientID);
}
|
[
"public",
"function",
"getSentryClient",
"(",
")",
"{",
"if",
"(",
"!",
"Yii",
"::",
"app",
"(",
")",
"->",
"hasComponent",
"(",
"$",
"this",
"->",
"sentryClientID",
")",
")",
"{",
"throw",
"new",
"CException",
"(",
"sprintf",
"(",
"'SentryErrorHandler.componentID \"%s\" is invalid.'",
",",
"$",
"this",
"->",
"sentryClientID",
")",
")",
";",
"}",
"return",
"Yii",
"::",
"app",
"(",
")",
"->",
"getComponent",
"(",
"$",
"this",
"->",
"sentryClientID",
")",
";",
"}"
] |
Returns the Sentry client component.
@return SentryClient client instance.
@throws CException if the component id is invalid.
|
[
"Returns",
"the",
"Sentry",
"client",
"component",
"."
] |
beacc88e06a0eb32903e4eae63cc6cddea901524
|
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryErrorHandler.php#L95-L101
|
231,539
|
i-am-tom/schemer
|
src/Result.php
|
Result.fatal
|
public static function fatal(string $error) : Result
{
$result = new self([$error]);
$result->fatal = true;
return $result;
}
|
php
|
public static function fatal(string $error) : Result
{
$result = new self([$error]);
$result->fatal = true;
return $result;
}
|
[
"public",
"static",
"function",
"fatal",
"(",
"string",
"$",
"error",
")",
":",
"Result",
"{",
"$",
"result",
"=",
"new",
"self",
"(",
"[",
"$",
"error",
"]",
")",
";",
"$",
"result",
"->",
"fatal",
"=",
"true",
";",
"return",
"$",
"result",
";",
"}"
] |
Return a failure, stop checking this branch.
@param string $error
@return Schemer\Result
|
[
"Return",
"a",
"failure",
"stop",
"checking",
"this",
"branch",
"."
] |
aa4ff458eae636ca61ada07d05859e27d3b4584d
|
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Result.php#L81-L87
|
231,540
|
praxisnetau/silverware
|
src/Extensions/Style/ButtonStyle.php
|
ButtonStyle.getButtonTypeStyle
|
public function getButtonTypeStyle()
{
$type = $this->owner->ButtonTypeOrDefault;
if ($this->owner->ButtonStyleOrDefault == self::STYLE_OUTLINE) {
return sprintf('outline-%s', $type);
}
return $type;
}
|
php
|
public function getButtonTypeStyle()
{
$type = $this->owner->ButtonTypeOrDefault;
if ($this->owner->ButtonStyleOrDefault == self::STYLE_OUTLINE) {
return sprintf('outline-%s', $type);
}
return $type;
}
|
[
"public",
"function",
"getButtonTypeStyle",
"(",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"owner",
"->",
"ButtonTypeOrDefault",
";",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"ButtonStyleOrDefault",
"==",
"self",
"::",
"STYLE_OUTLINE",
")",
"{",
"return",
"sprintf",
"(",
"'outline-%s'",
",",
"$",
"type",
")",
";",
"}",
"return",
"$",
"type",
";",
"}"
] |
Answers the type style for the button.
@return string
|
[
"Answers",
"the",
"type",
"style",
"for",
"the",
"button",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/ButtonStyle.php#L163-L172
|
231,541
|
praxisnetau/silverware
|
src/Extensions/Style/ButtonStyle.php
|
ButtonStyle.getButtonSizeOrDefault
|
public function getButtonSizeOrDefault()
{
if ($this->owner->ButtonSize) {
return $this->owner->ButtonSize;
}
return Config::inst()->get(static::class, 'default_button_size');
}
|
php
|
public function getButtonSizeOrDefault()
{
if ($this->owner->ButtonSize) {
return $this->owner->ButtonSize;
}
return Config::inst()->get(static::class, 'default_button_size');
}
|
[
"public",
"function",
"getButtonSizeOrDefault",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"ButtonSize",
")",
"{",
"return",
"$",
"this",
"->",
"owner",
"->",
"ButtonSize",
";",
"}",
"return",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"static",
"::",
"class",
",",
"'default_button_size'",
")",
";",
"}"
] |
Answers the defined button size or the default size.
@return string
|
[
"Answers",
"the",
"defined",
"button",
"size",
"or",
"the",
"default",
"size",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/ButtonStyle.php#L179-L186
|
231,542
|
praxisnetau/silverware
|
src/Extensions/Style/ButtonStyle.php
|
ButtonStyle.getButtonStyleOrDefault
|
public function getButtonStyleOrDefault()
{
if ($this->owner->ButtonStyle) {
return $this->owner->ButtonStyle;
}
return Config::inst()->get(static::class, 'default_button_style');
}
|
php
|
public function getButtonStyleOrDefault()
{
if ($this->owner->ButtonStyle) {
return $this->owner->ButtonStyle;
}
return Config::inst()->get(static::class, 'default_button_style');
}
|
[
"public",
"function",
"getButtonStyleOrDefault",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"ButtonStyle",
")",
"{",
"return",
"$",
"this",
"->",
"owner",
"->",
"ButtonStyle",
";",
"}",
"return",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"static",
"::",
"class",
",",
"'default_button_style'",
")",
";",
"}"
] |
Answers the defined button style or the default style.
@return string
|
[
"Answers",
"the",
"defined",
"button",
"style",
"or",
"the",
"default",
"style",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/ButtonStyle.php#L193-L200
|
231,543
|
praxisnetau/silverware
|
src/Extensions/Style/ButtonStyle.php
|
ButtonStyle.getButtonTypeOrDefault
|
public function getButtonTypeOrDefault()
{
if ($this->owner->ButtonType) {
return $this->owner->ButtonType;
}
return Config::inst()->get(static::class, 'default_button_type');
}
|
php
|
public function getButtonTypeOrDefault()
{
if ($this->owner->ButtonType) {
return $this->owner->ButtonType;
}
return Config::inst()->get(static::class, 'default_button_type');
}
|
[
"public",
"function",
"getButtonTypeOrDefault",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"ButtonType",
")",
"{",
"return",
"$",
"this",
"->",
"owner",
"->",
"ButtonType",
";",
"}",
"return",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"static",
"::",
"class",
",",
"'default_button_type'",
")",
";",
"}"
] |
Answers the defined button type or the default type.
@return string
|
[
"Answers",
"the",
"defined",
"button",
"type",
"or",
"the",
"default",
"type",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/ButtonStyle.php#L207-L214
|
231,544
|
praxisnetau/silverware
|
src/Extensions/Style/ButtonStyle.php
|
ButtonStyle.getButtonSizeOptions
|
public function getButtonSizeOptions()
{
return [
self::SIZE_SMALL => _t(__CLASS__ . '.SMALL', 'Small'),
self::SIZE_MEDIUM => _t(__CLASS__ . '.MEDIUM', 'Medium'),
self::SIZE_LARGE => _t(__CLASS__ . '.LARGE', 'Large')
];
}
|
php
|
public function getButtonSizeOptions()
{
return [
self::SIZE_SMALL => _t(__CLASS__ . '.SMALL', 'Small'),
self::SIZE_MEDIUM => _t(__CLASS__ . '.MEDIUM', 'Medium'),
self::SIZE_LARGE => _t(__CLASS__ . '.LARGE', 'Large')
];
}
|
[
"public",
"function",
"getButtonSizeOptions",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"SIZE_SMALL",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.SMALL'",
",",
"'Small'",
")",
",",
"self",
"::",
"SIZE_MEDIUM",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.MEDIUM'",
",",
"'Medium'",
")",
",",
"self",
"::",
"SIZE_LARGE",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.LARGE'",
",",
"'Large'",
")",
"]",
";",
"}"
] |
Answers an array of options for the button size field.
@return array
|
[
"Answers",
"an",
"array",
"of",
"options",
"for",
"the",
"button",
"size",
"field",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/ButtonStyle.php#L259-L266
|
231,545
|
Josantonius/PHP-Database
|
src/Provider/PDOprovider.php
|
PDOprovider.statements
|
public function statements($query, $statements)
{
try {
$query = $this->conn->prepare($query);
foreach ($statements as $key => $value) {
$param = $statements[$key][0];
$value = $statements[$key][1];
$ifExists = (isset($statements[$key][2]));
$dataType = $ifExists ? $statements[$key][2] : false;
switch ($dataType) {
case 'bool':
$query->bindValue($param, $value, \PDO::PARAM_BOOL);
continue;
case 'null':
$query->bindValue($param, $value, \PDO::PARAM_NULL);
continue;
case 'int':
$query->bindValue($param, $value, \PDO::PARAM_INT);
continue;
case 'str':
$query->bindValue($param, $value, \PDO::PARAM_STR);
continue;
}
$query->bindValue($param, $value);
}
$query->execute();
return $query;
} catch (\PDOException $e) {
$this->error = $e->getMessage();
return null;
}
}
|
php
|
public function statements($query, $statements)
{
try {
$query = $this->conn->prepare($query);
foreach ($statements as $key => $value) {
$param = $statements[$key][0];
$value = $statements[$key][1];
$ifExists = (isset($statements[$key][2]));
$dataType = $ifExists ? $statements[$key][2] : false;
switch ($dataType) {
case 'bool':
$query->bindValue($param, $value, \PDO::PARAM_BOOL);
continue;
case 'null':
$query->bindValue($param, $value, \PDO::PARAM_NULL);
continue;
case 'int':
$query->bindValue($param, $value, \PDO::PARAM_INT);
continue;
case 'str':
$query->bindValue($param, $value, \PDO::PARAM_STR);
continue;
}
$query->bindValue($param, $value);
}
$query->execute();
return $query;
} catch (\PDOException $e) {
$this->error = $e->getMessage();
return null;
}
}
|
[
"public",
"function",
"statements",
"(",
"$",
"query",
",",
"$",
"statements",
")",
"{",
"try",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"conn",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"foreach",
"(",
"$",
"statements",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"param",
"=",
"$",
"statements",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"$",
"statements",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
";",
"$",
"ifExists",
"=",
"(",
"isset",
"(",
"$",
"statements",
"[",
"$",
"key",
"]",
"[",
"2",
"]",
")",
")",
";",
"$",
"dataType",
"=",
"$",
"ifExists",
"?",
"$",
"statements",
"[",
"$",
"key",
"]",
"[",
"2",
"]",
":",
"false",
";",
"switch",
"(",
"$",
"dataType",
")",
"{",
"case",
"'bool'",
":",
"$",
"query",
"->",
"bindValue",
"(",
"$",
"param",
",",
"$",
"value",
",",
"\\",
"PDO",
"::",
"PARAM_BOOL",
")",
";",
"continue",
";",
"case",
"'null'",
":",
"$",
"query",
"->",
"bindValue",
"(",
"$",
"param",
",",
"$",
"value",
",",
"\\",
"PDO",
"::",
"PARAM_NULL",
")",
";",
"continue",
";",
"case",
"'int'",
":",
"$",
"query",
"->",
"bindValue",
"(",
"$",
"param",
",",
"$",
"value",
",",
"\\",
"PDO",
"::",
"PARAM_INT",
")",
";",
"continue",
";",
"case",
"'str'",
":",
"$",
"query",
"->",
"bindValue",
"(",
"$",
"param",
",",
"$",
"value",
",",
"\\",
"PDO",
"::",
"PARAM_STR",
")",
";",
"continue",
";",
"}",
"$",
"query",
"->",
"bindValue",
"(",
"$",
"param",
",",
"$",
"value",
")",
";",
"}",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"query",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Execute prepared queries.
@param string $query → query
@param array $statements → array with prepared parameters
@return object|null → returns the object with the connection or null
|
[
"Execute",
"prepared",
"queries",
"."
] |
8f68e1d49bde6071fed92f8d162a86bb78867975
|
https://github.com/Josantonius/PHP-Database/blob/8f68e1d49bde6071fed92f8d162a86bb78867975/src/Provider/PDOprovider.php#L96-L133
|
231,546
|
Josantonius/PHP-Database
|
src/Provider/PDOprovider.php
|
PDOprovider.select
|
public function select($columns, $from, $where, $order, $limit, $statements)
{
$query = 'SELECT ';
$query .= (is_array($columns)) ? implode(', ', $columns) : $columns;
$query .= ' FROM `' . $from . '` ';
$query .= (! is_null($where)) ? ' WHERE ' : '';
$query .= (is_string($where)) ? $where . ' ' : '';
if (is_array($where)) {
foreach ($where as $clause) {
$query .= $clause . ' AND ';
}
$query = rtrim(trim($query), 'AND');
}
$query .= (! is_null($order)) ? ' ORDER BY ' : '';
$query .= (is_string($order)) ? $order . ' ' : '';
if (is_array($order)) {
foreach ($order as $value) {
$query .= $value . ', ';
}
$query = rtrim(trim($query), ',');
}
$query .= (! is_null($limit)) ? ' LIMIT ' : '';
$query .= (is_int($limit)) ? $limit . ' ' : '';
if (! is_null($statements) && is_array($statements)) {
return $this->statements(trim($query), $statements);
}
return $this->query(trim($query), 'SELECT');
}
|
php
|
public function select($columns, $from, $where, $order, $limit, $statements)
{
$query = 'SELECT ';
$query .= (is_array($columns)) ? implode(', ', $columns) : $columns;
$query .= ' FROM `' . $from . '` ';
$query .= (! is_null($where)) ? ' WHERE ' : '';
$query .= (is_string($where)) ? $where . ' ' : '';
if (is_array($where)) {
foreach ($where as $clause) {
$query .= $clause . ' AND ';
}
$query = rtrim(trim($query), 'AND');
}
$query .= (! is_null($order)) ? ' ORDER BY ' : '';
$query .= (is_string($order)) ? $order . ' ' : '';
if (is_array($order)) {
foreach ($order as $value) {
$query .= $value . ', ';
}
$query = rtrim(trim($query), ',');
}
$query .= (! is_null($limit)) ? ' LIMIT ' : '';
$query .= (is_int($limit)) ? $limit . ' ' : '';
if (! is_null($statements) && is_array($statements)) {
return $this->statements(trim($query), $statements);
}
return $this->query(trim($query), 'SELECT');
}
|
[
"public",
"function",
"select",
"(",
"$",
"columns",
",",
"$",
"from",
",",
"$",
"where",
",",
"$",
"order",
",",
"$",
"limit",
",",
"$",
"statements",
")",
"{",
"$",
"query",
"=",
"'SELECT '",
";",
"$",
"query",
".=",
"(",
"is_array",
"(",
"$",
"columns",
")",
")",
"?",
"implode",
"(",
"', '",
",",
"$",
"columns",
")",
":",
"$",
"columns",
";",
"$",
"query",
".=",
"' FROM `'",
".",
"$",
"from",
".",
"'` '",
";",
"$",
"query",
".=",
"(",
"!",
"is_null",
"(",
"$",
"where",
")",
")",
"?",
"' WHERE '",
":",
"''",
";",
"$",
"query",
".=",
"(",
"is_string",
"(",
"$",
"where",
")",
")",
"?",
"$",
"where",
".",
"' '",
":",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"where",
")",
")",
"{",
"foreach",
"(",
"$",
"where",
"as",
"$",
"clause",
")",
"{",
"$",
"query",
".=",
"$",
"clause",
".",
"' AND '",
";",
"}",
"$",
"query",
"=",
"rtrim",
"(",
"trim",
"(",
"$",
"query",
")",
",",
"'AND'",
")",
";",
"}",
"$",
"query",
".=",
"(",
"!",
"is_null",
"(",
"$",
"order",
")",
")",
"?",
"' ORDER BY '",
":",
"''",
";",
"$",
"query",
".=",
"(",
"is_string",
"(",
"$",
"order",
")",
")",
"?",
"$",
"order",
".",
"' '",
":",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"order",
")",
")",
"{",
"foreach",
"(",
"$",
"order",
"as",
"$",
"value",
")",
"{",
"$",
"query",
".=",
"$",
"value",
".",
"', '",
";",
"}",
"$",
"query",
"=",
"rtrim",
"(",
"trim",
"(",
"$",
"query",
")",
",",
"','",
")",
";",
"}",
"$",
"query",
".=",
"(",
"!",
"is_null",
"(",
"$",
"limit",
")",
")",
"?",
"' LIMIT '",
":",
"''",
";",
"$",
"query",
".=",
"(",
"is_int",
"(",
"$",
"limit",
")",
")",
"?",
"$",
"limit",
".",
"' '",
":",
"''",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"statements",
")",
"&&",
"is_array",
"(",
"$",
"statements",
")",
")",
"{",
"return",
"$",
"this",
"->",
"statements",
"(",
"trim",
"(",
"$",
"query",
")",
",",
"$",
"statements",
")",
";",
"}",
"return",
"$",
"this",
"->",
"query",
"(",
"trim",
"(",
"$",
"query",
")",
",",
"'SELECT'",
")",
";",
"}"
] |
Selec statement.
@param mixed $columns → column/s name
@param string $from → table name
@param mixed $where → where clauses
@param mixed $order → query sort parameters
@param int $limit → query limiting parameters
@param array $statements → array with prepared parameters
@return object → query response
|
[
"Selec",
"statement",
"."
] |
8f68e1d49bde6071fed92f8d162a86bb78867975
|
https://github.com/Josantonius/PHP-Database/blob/8f68e1d49bde6071fed92f8d162a86bb78867975/src/Provider/PDOprovider.php#L209-L242
|
231,547
|
sop/crypto-encoding
|
lib/CryptoEncoding/PEMBundle.php
|
PEMBundle.fromString
|
public static function fromString(string $str): self
{
if (!preg_match_all(PEM::PEM_REGEX, $str, $matches, PREG_SET_ORDER)) {
throw new \UnexpectedValueException("No PEM blocks.");
}
$pems = array_map(
function ($match) {
$payload = preg_replace('/\s+/', "", $match[2]);
$data = base64_decode($payload, true);
if (false === $data) {
throw new \UnexpectedValueException(
"Failed to decode PEM data.");
}
return new PEM($match[1], $data);
}, $matches);
return new self(...$pems);
}
|
php
|
public static function fromString(string $str): self
{
if (!preg_match_all(PEM::PEM_REGEX, $str, $matches, PREG_SET_ORDER)) {
throw new \UnexpectedValueException("No PEM blocks.");
}
$pems = array_map(
function ($match) {
$payload = preg_replace('/\s+/', "", $match[2]);
$data = base64_decode($payload, true);
if (false === $data) {
throw new \UnexpectedValueException(
"Failed to decode PEM data.");
}
return new PEM($match[1], $data);
}, $matches);
return new self(...$pems);
}
|
[
"public",
"static",
"function",
"fromString",
"(",
"string",
"$",
"str",
")",
":",
"self",
"{",
"if",
"(",
"!",
"preg_match_all",
"(",
"PEM",
"::",
"PEM_REGEX",
",",
"$",
"str",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"No PEM blocks.\"",
")",
";",
"}",
"$",
"pems",
"=",
"array_map",
"(",
"function",
"(",
"$",
"match",
")",
"{",
"$",
"payload",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"\"\"",
",",
"$",
"match",
"[",
"2",
"]",
")",
";",
"$",
"data",
"=",
"base64_decode",
"(",
"$",
"payload",
",",
"true",
")",
";",
"if",
"(",
"false",
"===",
"$",
"data",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Failed to decode PEM data.\"",
")",
";",
"}",
"return",
"new",
"PEM",
"(",
"$",
"match",
"[",
"1",
"]",
",",
"$",
"data",
")",
";",
"}",
",",
"$",
"matches",
")",
";",
"return",
"new",
"self",
"(",
"...",
"$",
"pems",
")",
";",
"}"
] |
Initialize from a string.
@param string $str
@throws \UnexpectedValueException
@return self
|
[
"Initialize",
"from",
"a",
"string",
"."
] |
b5958cc213d3092cb9fa7be179adf760a8fde1f6
|
https://github.com/sop/crypto-encoding/blob/b5958cc213d3092cb9fa7be179adf760a8fde1f6/lib/CryptoEncoding/PEMBundle.php#L38-L54
|
231,548
|
sop/crypto-encoding
|
lib/CryptoEncoding/PEMBundle.php
|
PEMBundle.fromFile
|
public static function fromFile($filename): self
{
if (!is_readable($filename) ||
false === ($str = file_get_contents($filename))) {
throw new \RuntimeException("Failed to read $filename.");
}
return self::fromString($str);
}
|
php
|
public static function fromFile($filename): self
{
if (!is_readable($filename) ||
false === ($str = file_get_contents($filename))) {
throw new \RuntimeException("Failed to read $filename.");
}
return self::fromString($str);
}
|
[
"public",
"static",
"function",
"fromFile",
"(",
"$",
"filename",
")",
":",
"self",
"{",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"filename",
")",
"||",
"false",
"===",
"(",
"$",
"str",
"=",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Failed to read $filename.\"",
")",
";",
"}",
"return",
"self",
"::",
"fromString",
"(",
"$",
"str",
")",
";",
"}"
] |
Initialize from a file.
@param string $filename
@throws \RuntimeException If file reading fails
@return self
|
[
"Initialize",
"from",
"a",
"file",
"."
] |
b5958cc213d3092cb9fa7be179adf760a8fde1f6
|
https://github.com/sop/crypto-encoding/blob/b5958cc213d3092cb9fa7be179adf760a8fde1f6/lib/CryptoEncoding/PEMBundle.php#L63-L70
|
231,549
|
sop/crypto-encoding
|
lib/CryptoEncoding/PEMBundle.php
|
PEMBundle.withPEMs
|
public function withPEMs(PEM ...$pems): self
{
$obj = clone $this;
$obj->_pems = array_merge($obj->_pems, $pems);
return $obj;
}
|
php
|
public function withPEMs(PEM ...$pems): self
{
$obj = clone $this;
$obj->_pems = array_merge($obj->_pems, $pems);
return $obj;
}
|
[
"public",
"function",
"withPEMs",
"(",
"PEM",
"...",
"$",
"pems",
")",
":",
"self",
"{",
"$",
"obj",
"=",
"clone",
"$",
"this",
";",
"$",
"obj",
"->",
"_pems",
"=",
"array_merge",
"(",
"$",
"obj",
"->",
"_pems",
",",
"$",
"pems",
")",
";",
"return",
"$",
"obj",
";",
"}"
] |
Get self with PEM objects appended.
@param PEM ...$pems
@return self
|
[
"Get",
"self",
"with",
"PEM",
"objects",
"appended",
"."
] |
b5958cc213d3092cb9fa7be179adf760a8fde1f6
|
https://github.com/sop/crypto-encoding/blob/b5958cc213d3092cb9fa7be179adf760a8fde1f6/lib/CryptoEncoding/PEMBundle.php#L78-L83
|
231,550
|
sop/crypto-encoding
|
lib/CryptoEncoding/PEMBundle.php
|
PEMBundle.string
|
public function string(): string
{
return implode("\n",
array_map(
function (PEM $pem) {
return $pem->string();
}, $this->_pems));
}
|
php
|
public function string(): string
{
return implode("\n",
array_map(
function (PEM $pem) {
return $pem->string();
}, $this->_pems));
}
|
[
"public",
"function",
"string",
"(",
")",
":",
"string",
"{",
"return",
"implode",
"(",
"\"\\n\"",
",",
"array_map",
"(",
"function",
"(",
"PEM",
"$",
"pem",
")",
"{",
"return",
"$",
"pem",
"->",
"string",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"_pems",
")",
")",
";",
"}"
] |
Encode bundle to a string of contiguous PEM blocks.
@return string
|
[
"Encode",
"bundle",
"to",
"a",
"string",
"of",
"contiguous",
"PEM",
"blocks",
"."
] |
b5958cc213d3092cb9fa7be179adf760a8fde1f6
|
https://github.com/sop/crypto-encoding/blob/b5958cc213d3092cb9fa7be179adf760a8fde1f6/lib/CryptoEncoding/PEMBundle.php#L135-L142
|
231,551
|
sjdaws/vocal
|
examples/with-angular/database/seeds/UserSeeder.php
|
UserSeeder.seedUser
|
private function seedUser()
{
User::truncate();
UserAddress::truncate();
Input::replace(array(
'username' => 'Test',
'email' => 'test@test.com',
'addresses' => array(
array(
'address' => '123 Fake Street',
'city' => 'Faketon'
),
array(
'address' => '10 Test Street',
'city' => 'Testville'
)
)
));
$user = new User;
$user->saveRecursive();
}
|
php
|
private function seedUser()
{
User::truncate();
UserAddress::truncate();
Input::replace(array(
'username' => 'Test',
'email' => 'test@test.com',
'addresses' => array(
array(
'address' => '123 Fake Street',
'city' => 'Faketon'
),
array(
'address' => '10 Test Street',
'city' => 'Testville'
)
)
));
$user = new User;
$user->saveRecursive();
}
|
[
"private",
"function",
"seedUser",
"(",
")",
"{",
"User",
"::",
"truncate",
"(",
")",
";",
"UserAddress",
"::",
"truncate",
"(",
")",
";",
"Input",
"::",
"replace",
"(",
"array",
"(",
"'username'",
"=>",
"'Test'",
",",
"'email'",
"=>",
"'test@test.com'",
",",
"'addresses'",
"=>",
"array",
"(",
"array",
"(",
"'address'",
"=>",
"'123 Fake Street'",
",",
"'city'",
"=>",
"'Faketon'",
")",
",",
"array",
"(",
"'address'",
"=>",
"'10 Test Street'",
",",
"'city'",
"=>",
"'Testville'",
")",
")",
")",
")",
";",
"$",
"user",
"=",
"new",
"User",
";",
"$",
"user",
"->",
"saveRecursive",
"(",
")",
";",
"}"
] |
Add products to the database
@return void
|
[
"Add",
"products",
"to",
"the",
"database"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/examples/with-angular/database/seeds/UserSeeder.php#L20-L42
|
231,552
|
praxisnetau/silverware
|
src/Forms/DimensionsField.php
|
DimensionsField.setForm
|
public function setForm($form)
{
foreach ($this->fields as $field) {
$field->setForm($form);
}
return parent::setForm($form);
}
|
php
|
public function setForm($form)
{
foreach ($this->fields as $field) {
$field->setForm($form);
}
return parent::setForm($form);
}
|
[
"public",
"function",
"setForm",
"(",
"$",
"form",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"setForm",
"(",
"$",
"form",
")",
";",
"}",
"return",
"parent",
"::",
"setForm",
"(",
"$",
"form",
")",
";",
"}"
] |
Defines the form for the receiver and dimension fields.
@param Form $form
@return $this
|
[
"Defines",
"the",
"form",
"for",
"the",
"receiver",
"and",
"dimension",
"fields",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/DimensionsField.php#L122-L129
|
231,553
|
praxisnetau/silverware
|
src/Forms/DimensionsField.php
|
DimensionsField.performReadonlyTransformation
|
public function performReadonlyTransformation()
{
$clone = clone $this;
foreach ($clone->fields as $dim => $field) {
$clone->fields[$dim] = $field->performReadonlyTransformation();
}
$clone->setReadonly(true);
return $clone;
}
|
php
|
public function performReadonlyTransformation()
{
$clone = clone $this;
foreach ($clone->fields as $dim => $field) {
$clone->fields[$dim] = $field->performReadonlyTransformation();
}
$clone->setReadonly(true);
return $clone;
}
|
[
"public",
"function",
"performReadonlyTransformation",
"(",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"foreach",
"(",
"$",
"clone",
"->",
"fields",
"as",
"$",
"dim",
"=>",
"$",
"field",
")",
"{",
"$",
"clone",
"->",
"fields",
"[",
"$",
"dim",
"]",
"=",
"$",
"field",
"->",
"performReadonlyTransformation",
"(",
")",
";",
"}",
"$",
"clone",
"->",
"setReadonly",
"(",
"true",
")",
";",
"return",
"$",
"clone",
";",
"}"
] |
Returns a read-only version of the receiver.
@return DimensionsField
|
[
"Returns",
"a",
"read",
"-",
"only",
"version",
"of",
"the",
"receiver",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/DimensionsField.php#L261-L272
|
231,554
|
praxisnetau/silverware
|
src/Forms/DimensionsField.php
|
DimensionsField.setDimensionLabel
|
public function setDimensionLabel($dim, $label)
{
$this->labels[$dim] = $label;
$this->updateDimensionFields();
return $this;
}
|
php
|
public function setDimensionLabel($dim, $label)
{
$this->labels[$dim] = $label;
$this->updateDimensionFields();
return $this;
}
|
[
"public",
"function",
"setDimensionLabel",
"(",
"$",
"dim",
",",
"$",
"label",
")",
"{",
"$",
"this",
"->",
"labels",
"[",
"$",
"dim",
"]",
"=",
"$",
"label",
";",
"$",
"this",
"->",
"updateDimensionFields",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Defines the label for the specified dimension.
@param string $dim
@param string $label
@return $this
|
[
"Defines",
"the",
"label",
"for",
"the",
"specified",
"dimension",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/DimensionsField.php#L282-L289
|
231,555
|
praxisnetau/silverware
|
src/Forms/DimensionsField.php
|
DimensionsField.getDimensionValues
|
public function getDimensionValues()
{
$values = [];
foreach ($this->fields as $dim => $field) {
$values[$dim] = is_numeric($field->dataValue()) ? (int) $field->dataValue() : null;
}
return $values;
}
|
php
|
public function getDimensionValues()
{
$values = [];
foreach ($this->fields as $dim => $field) {
$values[$dim] = is_numeric($field->dataValue()) ? (int) $field->dataValue() : null;
}
return $values;
}
|
[
"public",
"function",
"getDimensionValues",
"(",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"dim",
"=>",
"$",
"field",
")",
"{",
"$",
"values",
"[",
"$",
"dim",
"]",
"=",
"is_numeric",
"(",
"$",
"field",
"->",
"dataValue",
"(",
")",
")",
"?",
"(",
"int",
")",
"$",
"field",
"->",
"dataValue",
"(",
")",
":",
"null",
";",
"}",
"return",
"$",
"values",
";",
"}"
] |
Answers an array containing the values of the dimension fields.
@return array
|
[
"Answers",
"an",
"array",
"containing",
"the",
"values",
"of",
"the",
"dimension",
"fields",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/DimensionsField.php#L312-L321
|
231,556
|
praxisnetau/silverware
|
src/Forms/DimensionsField.php
|
DimensionsField.getFields
|
public function getFields()
{
$fields = FieldList::create($this->fields);
foreach ($fields as $field) {
$fields->insertAfter(
$field->getName(),
LiteralField::create(
sprintf('%s_ByLiteral', $field->getName()),
'<div class="by"><span class="icon"></span></div>'
)
);
}
return $fields;
}
|
php
|
public function getFields()
{
$fields = FieldList::create($this->fields);
foreach ($fields as $field) {
$fields->insertAfter(
$field->getName(),
LiteralField::create(
sprintf('%s_ByLiteral', $field->getName()),
'<div class="by"><span class="icon"></span></div>'
)
);
}
return $fields;
}
|
[
"public",
"function",
"getFields",
"(",
")",
"{",
"$",
"fields",
"=",
"FieldList",
"::",
"create",
"(",
"$",
"this",
"->",
"fields",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"fields",
"->",
"insertAfter",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
",",
"LiteralField",
"::",
"create",
"(",
"sprintf",
"(",
"'%s_ByLiteral'",
",",
"$",
"field",
"->",
"getName",
"(",
")",
")",
",",
"'<div class=\"by\"><span class=\"icon\"></span></div>'",
")",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
] |
Answers the dimension fields for the field holder.
@return FieldList
|
[
"Answers",
"the",
"dimension",
"fields",
"for",
"the",
"field",
"holder",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/DimensionsField.php#L328-L345
|
231,557
|
praxisnetau/silverware
|
src/Forms/DimensionsField.php
|
DimensionsField.FieldHolder
|
public function FieldHolder($properties = [])
{
return FieldGroup::create(
$this->Title(),
$this->Fields
)->addExtraClass('dimensions')->FieldHolder($properties);
}
|
php
|
public function FieldHolder($properties = [])
{
return FieldGroup::create(
$this->Title(),
$this->Fields
)->addExtraClass('dimensions')->FieldHolder($properties);
}
|
[
"public",
"function",
"FieldHolder",
"(",
"$",
"properties",
"=",
"[",
"]",
")",
"{",
"return",
"FieldGroup",
"::",
"create",
"(",
"$",
"this",
"->",
"Title",
"(",
")",
",",
"$",
"this",
"->",
"Fields",
")",
"->",
"addExtraClass",
"(",
"'dimensions'",
")",
"->",
"FieldHolder",
"(",
"$",
"properties",
")",
";",
"}"
] |
Renders the field holder for the receiver.
@param array $properties
@return DBHTMLText
|
[
"Renders",
"the",
"field",
"holder",
"for",
"the",
"receiver",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/DimensionsField.php#L354-L360
|
231,558
|
praxisnetau/silverware
|
src/Forms/DimensionsField.php
|
DimensionsField.buildDimensionField
|
protected function buildDimensionField($dim)
{
$field = TextField::create(
sprintf('%s[%s]', $this->getName(), $dim),
$this->getDimensionLabel($dim)
);
return $field;
}
|
php
|
protected function buildDimensionField($dim)
{
$field = TextField::create(
sprintf('%s[%s]', $this->getName(), $dim),
$this->getDimensionLabel($dim)
);
return $field;
}
|
[
"protected",
"function",
"buildDimensionField",
"(",
"$",
"dim",
")",
"{",
"$",
"field",
"=",
"TextField",
"::",
"create",
"(",
"sprintf",
"(",
"'%s[%s]'",
",",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"dim",
")",
",",
"$",
"this",
"->",
"getDimensionLabel",
"(",
"$",
"dim",
")",
")",
";",
"return",
"$",
"field",
";",
"}"
] |
Builds and answers a form field for the specified dimension.
@param string $dim
@return FormField
|
[
"Builds",
"and",
"answers",
"a",
"form",
"field",
"for",
"the",
"specified",
"dimension",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/DimensionsField.php#L369-L377
|
231,559
|
praxisnetau/silverware
|
src/Forms/DimensionsField.php
|
DimensionsField.updateDimensionFields
|
protected function updateDimensionFields()
{
foreach ($this->fields as $dim => $field) {
// Update Title / Placeholders:
if ($this->usePlaceholders) {
$field->setTitle(null)->setAttribute('placeholder', $this->getDimensionLabel($dim));
} else {
$field->setTitle($this->getDimensionLabel($dim))->setAttribute('placeholder', null);
}
// Update Disabled Flags:
$field->setDisabled($this->disabled);
// Update Readonly Flags:
$field->setReadonly($this->readonly);
}
}
|
php
|
protected function updateDimensionFields()
{
foreach ($this->fields as $dim => $field) {
// Update Title / Placeholders:
if ($this->usePlaceholders) {
$field->setTitle(null)->setAttribute('placeholder', $this->getDimensionLabel($dim));
} else {
$field->setTitle($this->getDimensionLabel($dim))->setAttribute('placeholder', null);
}
// Update Disabled Flags:
$field->setDisabled($this->disabled);
// Update Readonly Flags:
$field->setReadonly($this->readonly);
}
}
|
[
"protected",
"function",
"updateDimensionFields",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"dim",
"=>",
"$",
"field",
")",
"{",
"// Update Title / Placeholders:",
"if",
"(",
"$",
"this",
"->",
"usePlaceholders",
")",
"{",
"$",
"field",
"->",
"setTitle",
"(",
"null",
")",
"->",
"setAttribute",
"(",
"'placeholder'",
",",
"$",
"this",
"->",
"getDimensionLabel",
"(",
"$",
"dim",
")",
")",
";",
"}",
"else",
"{",
"$",
"field",
"->",
"setTitle",
"(",
"$",
"this",
"->",
"getDimensionLabel",
"(",
"$",
"dim",
")",
")",
"->",
"setAttribute",
"(",
"'placeholder'",
",",
"null",
")",
";",
"}",
"// Update Disabled Flags:",
"$",
"field",
"->",
"setDisabled",
"(",
"$",
"this",
"->",
"disabled",
")",
";",
"// Update Readonly Flags:",
"$",
"field",
"->",
"setReadonly",
"(",
"$",
"this",
"->",
"readonly",
")",
";",
"}",
"}"
] |
Updates the dimension fields after a state change.
@return void
|
[
"Updates",
"the",
"dimension",
"fields",
"after",
"a",
"state",
"change",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/DimensionsField.php#L384-L405
|
231,560
|
EcomDev/cache-key
|
src/ConverterChain.php
|
ConverterChain.convert
|
public function convert($data)
{
foreach ($this->chain as $converter) {
$result = $converter->convert($data);
if ($result !== false) {
return $result;
}
}
return false;
}
|
php
|
public function convert($data)
{
foreach ($this->chain as $converter) {
$result = $converter->convert($data);
if ($result !== false) {
return $result;
}
}
return false;
}
|
[
"public",
"function",
"convert",
"(",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"chain",
"as",
"$",
"converter",
")",
"{",
"$",
"result",
"=",
"$",
"converter",
"->",
"convert",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"result",
"!==",
"false",
")",
"{",
"return",
"$",
"result",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Converts incoming data into string
Walks over all converters,
if some of them gives a match, then
@param mixed $data
@return string|bool
|
[
"Converts",
"incoming",
"data",
"into",
"string"
] |
5f90f5a013100ec57d7f3a842f48222ba8a4ccf9
|
https://github.com/EcomDev/cache-key/blob/5f90f5a013100ec57d7f3a842f48222ba8a4ccf9/src/ConverterChain.php#L41-L51
|
231,561
|
digiaonline/paytrail-php
|
src/Object/Product.php
|
Product.toArray
|
public function toArray()
{
return array(
'title' => $this->title,
'code' => $this->code,
'amount' => $this->amount,
'price' => $this->price,
'vat' => $this->vat,
'discount' => $this->discount,
'type' => $this->type,
);
}
|
php
|
public function toArray()
{
return array(
'title' => $this->title,
'code' => $this->code,
'amount' => $this->amount,
'price' => $this->price,
'vat' => $this->vat,
'discount' => $this->discount,
'type' => $this->type,
);
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"'title'",
"=>",
"$",
"this",
"->",
"title",
",",
"'code'",
"=>",
"$",
"this",
"->",
"code",
",",
"'amount'",
"=>",
"$",
"this",
"->",
"amount",
",",
"'price'",
"=>",
"$",
"this",
"->",
"price",
",",
"'vat'",
"=>",
"$",
"this",
"->",
"vat",
",",
"'discount'",
"=>",
"$",
"this",
"->",
"discount",
",",
"'type'",
"=>",
"$",
"this",
"->",
"type",
",",
")",
";",
"}"
] |
Convert Product object to array.
@return array
|
[
"Convert",
"Product",
"object",
"to",
"array",
"."
] |
a49c5e6742c42907fe329ff9b070fe7b21add74a
|
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Object/Product.php#L98-L109
|
231,562
|
i-am-tom/schemer
|
src/Formatter/FormatterAbstract.php
|
FormatterAbstract.pipe
|
protected function pipe(callable $transformation) : FormatterAbstract
{
$that = clone $this; // Immutability!
array_push($that->transformations, $transformation);
return $that;
}
|
php
|
protected function pipe(callable $transformation) : FormatterAbstract
{
$that = clone $this; // Immutability!
array_push($that->transformations, $transformation);
return $that;
}
|
[
"protected",
"function",
"pipe",
"(",
"callable",
"$",
"transformation",
")",
":",
"FormatterAbstract",
"{",
"$",
"that",
"=",
"clone",
"$",
"this",
";",
"// Immutability!",
"array_push",
"(",
"$",
"that",
"->",
"transformations",
",",
"$",
"transformation",
")",
";",
"return",
"$",
"that",
";",
"}"
] |
Add another step to the formatter.
@param callable $transformation
@return Schemer\Formatter\FormatterAbstract
|
[
"Add",
"another",
"step",
"to",
"the",
"formatter",
"."
] |
aa4ff458eae636ca61ada07d05859e27d3b4584d
|
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/FormatterAbstract.php#L49-L55
|
231,563
|
i-am-tom/schemer
|
src/Formatter/FormatterAbstract.php
|
FormatterAbstract.format
|
public function format($value)
{
return array_reduce(
$this->transformations,
function ($x, callable $f) {
return $f($x);
},
$value ?: $this->default
);
}
|
php
|
public function format($value)
{
return array_reduce(
$this->transformations,
function ($x, callable $f) {
return $f($x);
},
$value ?: $this->default
);
}
|
[
"public",
"function",
"format",
"(",
"$",
"value",
")",
"{",
"return",
"array_reduce",
"(",
"$",
"this",
"->",
"transformations",
",",
"function",
"(",
"$",
"x",
",",
"callable",
"$",
"f",
")",
"{",
"return",
"$",
"f",
"(",
"$",
"x",
")",
";",
"}",
",",
"$",
"value",
"?",
":",
"$",
"this",
"->",
"default",
")",
";",
"}"
] |
Execute the formatter on a given value.
@param mixed $value
@return mixed
|
[
"Execute",
"the",
"formatter",
"on",
"a",
"given",
"value",
"."
] |
aa4ff458eae636ca61ada07d05859e27d3b4584d
|
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/FormatterAbstract.php#L62-L71
|
231,564
|
wallstreetio/ontraport
|
src/Ontraport.php
|
Ontraport.object
|
public function object($object)
{
// We will check for a custom object, which allows developers to create
// objects using their own customized object Closure to create it.
// Otherwise, we'll check to see if an object exists by default.
if (array_key_exists($object, $this->extensions)) {
return $this->extensions[$object]($this);
}
$object = is_numeric($object) ? $object : $this->objects->find($object);
return new OntraportObject($this, $object);
}
|
php
|
public function object($object)
{
// We will check for a custom object, which allows developers to create
// objects using their own customized object Closure to create it.
// Otherwise, we'll check to see if an object exists by default.
if (array_key_exists($object, $this->extensions)) {
return $this->extensions[$object]($this);
}
$object = is_numeric($object) ? $object : $this->objects->find($object);
return new OntraportObject($this, $object);
}
|
[
"public",
"function",
"object",
"(",
"$",
"object",
")",
"{",
"// We will check for a custom object, which allows developers to create",
"// objects using their own customized object Closure to create it.",
"// Otherwise, we'll check to see if an object exists by default.",
"if",
"(",
"array_key_exists",
"(",
"$",
"object",
",",
"$",
"this",
"->",
"extensions",
")",
")",
"{",
"return",
"$",
"this",
"->",
"extensions",
"[",
"$",
"object",
"]",
"(",
"$",
"this",
")",
";",
"}",
"$",
"object",
"=",
"is_numeric",
"(",
"$",
"object",
")",
"?",
"$",
"object",
":",
"$",
"this",
"->",
"objects",
"->",
"find",
"(",
"$",
"object",
")",
";",
"return",
"new",
"OntraportObject",
"(",
"$",
"this",
",",
"$",
"object",
")",
";",
"}"
] |
Retrieve an Ontraport object.
@param mixed $object
@return mixed
|
[
"Retrieve",
"an",
"Ontraport",
"object",
"."
] |
55467fd63637083f76e497897af4aee13fc2c8b1
|
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Ontraport.php#L180-L193
|
231,565
|
wallstreetio/ontraport
|
src/Ontraport.php
|
Ontraport.extend
|
public function extend($name, $value)
{
if (is_callable($value)) {
$this->extensions[$name] = $value;
} else {
$this->extensions[$name] = function ($ontraport) use ($value) {
return new $value($ontraport);
};
}
return $this;
}
|
php
|
public function extend($name, $value)
{
if (is_callable($value)) {
$this->extensions[$name] = $value;
} else {
$this->extensions[$name] = function ($ontraport) use ($value) {
return new $value($ontraport);
};
}
return $this;
}
|
[
"public",
"function",
"extend",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"extensions",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"extensions",
"[",
"$",
"name",
"]",
"=",
"function",
"(",
"$",
"ontraport",
")",
"use",
"(",
"$",
"value",
")",
"{",
"return",
"new",
"$",
"value",
"(",
"$",
"ontraport",
")",
";",
"}",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Extend an Ontraport object.
@param string $name
@param mixed $value
@return $this
|
[
"Extend",
"an",
"Ontraport",
"object",
"."
] |
55467fd63637083f76e497897af4aee13fc2c8b1
|
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Ontraport.php#L202-L213
|
231,566
|
praxisnetau/silverware
|
src/Extensions/Config/PageTypeConfig.php
|
PageTypeConfig.getTemplateForClass
|
public function getTemplateForClass($class)
{
foreach (ClassTools::singleton()->getReverseAncestry($class) as $name) {
if ($type = PageType::findByClass($name)) {
if ($type->hasPageTemplate()) {
return $type->getPageTemplate();
}
}
if ($name == SiteTree::class) {
break;
}
}
}
|
php
|
public function getTemplateForClass($class)
{
foreach (ClassTools::singleton()->getReverseAncestry($class) as $name) {
if ($type = PageType::findByClass($name)) {
if ($type->hasPageTemplate()) {
return $type->getPageTemplate();
}
}
if ($name == SiteTree::class) {
break;
}
}
}
|
[
"public",
"function",
"getTemplateForClass",
"(",
"$",
"class",
")",
"{",
"foreach",
"(",
"ClassTools",
"::",
"singleton",
"(",
")",
"->",
"getReverseAncestry",
"(",
"$",
"class",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"type",
"=",
"PageType",
"::",
"findByClass",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"$",
"type",
"->",
"hasPageTemplate",
"(",
")",
")",
"{",
"return",
"$",
"type",
"->",
"getPageTemplate",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"name",
"==",
"SiteTree",
"::",
"class",
")",
"{",
"break",
";",
"}",
"}",
"}"
] |
Answers the template for the given page class.
@param string $class
@return Template
|
[
"Answers",
"the",
"template",
"for",
"the",
"given",
"page",
"class",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Config/PageTypeConfig.php#L131-L148
|
231,567
|
praxisnetau/silverware
|
src/Extensions/Config/PageTypeConfig.php
|
PageTypeConfig.getLayoutForClass
|
public function getLayoutForClass($class)
{
foreach (ClassTools::singleton()->getReverseAncestry($class) as $name) {
if ($type = PageType::findByClass($name)) {
if ($type->hasPageLayout()) {
return $type->getPageLayout();
}
}
if ($name == SiteTree::class) {
break;
}
}
}
|
php
|
public function getLayoutForClass($class)
{
foreach (ClassTools::singleton()->getReverseAncestry($class) as $name) {
if ($type = PageType::findByClass($name)) {
if ($type->hasPageLayout()) {
return $type->getPageLayout();
}
}
if ($name == SiteTree::class) {
break;
}
}
}
|
[
"public",
"function",
"getLayoutForClass",
"(",
"$",
"class",
")",
"{",
"foreach",
"(",
"ClassTools",
"::",
"singleton",
"(",
")",
"->",
"getReverseAncestry",
"(",
"$",
"class",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"type",
"=",
"PageType",
"::",
"findByClass",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"$",
"type",
"->",
"hasPageLayout",
"(",
")",
")",
"{",
"return",
"$",
"type",
"->",
"getPageLayout",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"name",
"==",
"SiteTree",
"::",
"class",
")",
"{",
"break",
";",
"}",
"}",
"}"
] |
Answers the layout for the given page class.
@param string $class
@return Layout
|
[
"Answers",
"the",
"layout",
"for",
"the",
"given",
"page",
"class",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Config/PageTypeConfig.php#L157-L174
|
231,568
|
praxisnetau/silverware
|
src/Components/AreaComponent.php
|
AreaComponent.getEnabledChildren
|
public function getEnabledChildren()
{
if ($page = $this->getCurrentPage(Page::class)) {
if (($panel = $page->getPanelForArea($this)) && $panel->isEnabled()) {
return $panel->getEnabledChildren();
}
}
return ArrayList::create();
}
|
php
|
public function getEnabledChildren()
{
if ($page = $this->getCurrentPage(Page::class)) {
if (($panel = $page->getPanelForArea($this)) && $panel->isEnabled()) {
return $panel->getEnabledChildren();
}
}
return ArrayList::create();
}
|
[
"public",
"function",
"getEnabledChildren",
"(",
")",
"{",
"if",
"(",
"$",
"page",
"=",
"$",
"this",
"->",
"getCurrentPage",
"(",
"Page",
"::",
"class",
")",
")",
"{",
"if",
"(",
"(",
"$",
"panel",
"=",
"$",
"page",
"->",
"getPanelForArea",
"(",
"$",
"this",
")",
")",
"&&",
"$",
"panel",
"->",
"isEnabled",
"(",
")",
")",
"{",
"return",
"$",
"panel",
"->",
"getEnabledChildren",
"(",
")",
";",
"}",
"}",
"return",
"ArrayList",
"::",
"create",
"(",
")",
";",
"}"
] |
Answers a list of the enabled children within the area and panel for the current page.
@return ArrayList
|
[
"Answers",
"a",
"list",
"of",
"the",
"enabled",
"children",
"within",
"the",
"area",
"and",
"panel",
"for",
"the",
"current",
"page",
"."
] |
2fa731c7f0737b350e0cbc676e93ac5beb430792
|
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/AreaComponent.php#L150-L161
|
231,569
|
ziadoz/silex-capsule
|
src/CapsuleServiceProvider.php
|
CapsuleServiceProvider.register
|
public function register(PimpleContainer $app)
{
$app['capsule.connection_defaults'] = [
'driver' => 'mysql',
'host' => 'localhost',
'database' => null,
'username' => 'root',
'password' => null,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => null,
'logging' => false,
];
$app['capsule.global'] = true;
$app['capsule.eloquent'] = true;
$app['capsule.container'] = function() {
return new Container;
};
$app['capsule.dispatcher'] = function() use($app) {
return new Dispatcher($app['capsule.container']);
};
$app['capsule'] = function($app) {
$capsule = new Capsule($app['capsule.container']);
$capsule->setEventDispatcher($app['capsule.dispatcher']);
if ($app['capsule.global']) {
$capsule->setAsGlobal();
}
if ($app['capsule.eloquent']) {
$capsule->bootEloquent();
}
if (! isset($app['capsule.connections'])) {
$app['capsule.connections'] = [
'default' => (isset($app['capsule.connection']) ? $app['capsule.connection'] : []),
];
}
foreach ($app['capsule.connections'] as $connection => $options) {
$options = array_replace($app['capsule.connection_defaults'], $options);
$logging = $options['logging'];
unset($options['logging']);
$capsule->addConnection($options, $connection);
if ($logging) {
$capsule->connection($connection)->enableQueryLog();
} else {
$capsule->connection($connection)->disableQueryLog();
}
}
return $capsule;
};
}
|
php
|
public function register(PimpleContainer $app)
{
$app['capsule.connection_defaults'] = [
'driver' => 'mysql',
'host' => 'localhost',
'database' => null,
'username' => 'root',
'password' => null,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => null,
'logging' => false,
];
$app['capsule.global'] = true;
$app['capsule.eloquent'] = true;
$app['capsule.container'] = function() {
return new Container;
};
$app['capsule.dispatcher'] = function() use($app) {
return new Dispatcher($app['capsule.container']);
};
$app['capsule'] = function($app) {
$capsule = new Capsule($app['capsule.container']);
$capsule->setEventDispatcher($app['capsule.dispatcher']);
if ($app['capsule.global']) {
$capsule->setAsGlobal();
}
if ($app['capsule.eloquent']) {
$capsule->bootEloquent();
}
if (! isset($app['capsule.connections'])) {
$app['capsule.connections'] = [
'default' => (isset($app['capsule.connection']) ? $app['capsule.connection'] : []),
];
}
foreach ($app['capsule.connections'] as $connection => $options) {
$options = array_replace($app['capsule.connection_defaults'], $options);
$logging = $options['logging'];
unset($options['logging']);
$capsule->addConnection($options, $connection);
if ($logging) {
$capsule->connection($connection)->enableQueryLog();
} else {
$capsule->connection($connection)->disableQueryLog();
}
}
return $capsule;
};
}
|
[
"public",
"function",
"register",
"(",
"PimpleContainer",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'capsule.connection_defaults'",
"]",
"=",
"[",
"'driver'",
"=>",
"'mysql'",
",",
"'host'",
"=>",
"'localhost'",
",",
"'database'",
"=>",
"null",
",",
"'username'",
"=>",
"'root'",
",",
"'password'",
"=>",
"null",
",",
"'charset'",
"=>",
"'utf8'",
",",
"'collation'",
"=>",
"'utf8_unicode_ci'",
",",
"'prefix'",
"=>",
"null",
",",
"'logging'",
"=>",
"false",
",",
"]",
";",
"$",
"app",
"[",
"'capsule.global'",
"]",
"=",
"true",
";",
"$",
"app",
"[",
"'capsule.eloquent'",
"]",
"=",
"true",
";",
"$",
"app",
"[",
"'capsule.container'",
"]",
"=",
"function",
"(",
")",
"{",
"return",
"new",
"Container",
";",
"}",
";",
"$",
"app",
"[",
"'capsule.dispatcher'",
"]",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Dispatcher",
"(",
"$",
"app",
"[",
"'capsule.container'",
"]",
")",
";",
"}",
";",
"$",
"app",
"[",
"'capsule'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"capsule",
"=",
"new",
"Capsule",
"(",
"$",
"app",
"[",
"'capsule.container'",
"]",
")",
";",
"$",
"capsule",
"->",
"setEventDispatcher",
"(",
"$",
"app",
"[",
"'capsule.dispatcher'",
"]",
")",
";",
"if",
"(",
"$",
"app",
"[",
"'capsule.global'",
"]",
")",
"{",
"$",
"capsule",
"->",
"setAsGlobal",
"(",
")",
";",
"}",
"if",
"(",
"$",
"app",
"[",
"'capsule.eloquent'",
"]",
")",
"{",
"$",
"capsule",
"->",
"bootEloquent",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"app",
"[",
"'capsule.connections'",
"]",
")",
")",
"{",
"$",
"app",
"[",
"'capsule.connections'",
"]",
"=",
"[",
"'default'",
"=>",
"(",
"isset",
"(",
"$",
"app",
"[",
"'capsule.connection'",
"]",
")",
"?",
"$",
"app",
"[",
"'capsule.connection'",
"]",
":",
"[",
"]",
")",
",",
"]",
";",
"}",
"foreach",
"(",
"$",
"app",
"[",
"'capsule.connections'",
"]",
"as",
"$",
"connection",
"=>",
"$",
"options",
")",
"{",
"$",
"options",
"=",
"array_replace",
"(",
"$",
"app",
"[",
"'capsule.connection_defaults'",
"]",
",",
"$",
"options",
")",
";",
"$",
"logging",
"=",
"$",
"options",
"[",
"'logging'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'logging'",
"]",
")",
";",
"$",
"capsule",
"->",
"addConnection",
"(",
"$",
"options",
",",
"$",
"connection",
")",
";",
"if",
"(",
"$",
"logging",
")",
"{",
"$",
"capsule",
"->",
"connection",
"(",
"$",
"connection",
")",
"->",
"enableQueryLog",
"(",
")",
";",
"}",
"else",
"{",
"$",
"capsule",
"->",
"connection",
"(",
"$",
"connection",
")",
"->",
"disableQueryLog",
"(",
")",
";",
"}",
"}",
"return",
"$",
"capsule",
";",
"}",
";",
"}"
] |
Register the Capsule service.
@param \Pimple\Container $app
@return void
|
[
"Register",
"the",
"Capsule",
"service",
"."
] |
82ad765e14b75a7ffffbcbdd1962601ab6c4b413
|
https://github.com/ziadoz/silex-capsule/blob/82ad765e14b75a7ffffbcbdd1962601ab6c4b413/src/CapsuleServiceProvider.php#L21-L80
|
231,570
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.addObservableEvent
|
private static function addObservableEvent($method, $event)
{
if (method_exists(get_called_class(), $method))
{
self::registerModelEvent($event, function($model) use ($method)
{
return $model->{$method}($model);
});
// Keep track of events
self::$observableEvents[] = $event;
}
}
|
php
|
private static function addObservableEvent($method, $event)
{
if (method_exists(get_called_class(), $method))
{
self::registerModelEvent($event, function($model) use ($method)
{
return $model->{$method}($model);
});
// Keep track of events
self::$observableEvents[] = $event;
}
}
|
[
"private",
"static",
"function",
"addObservableEvent",
"(",
"$",
"method",
",",
"$",
"event",
")",
"{",
"if",
"(",
"method_exists",
"(",
"get_called_class",
"(",
")",
",",
"$",
"method",
")",
")",
"{",
"self",
"::",
"registerModelEvent",
"(",
"$",
"event",
",",
"function",
"(",
"$",
"model",
")",
"use",
"(",
"$",
"method",
")",
"{",
"return",
"$",
"model",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"model",
")",
";",
"}",
")",
";",
"// Keep track of events",
"self",
"::",
"$",
"observableEvents",
"[",
"]",
"=",
"$",
"event",
";",
"}",
"}"
] |
Add a callback for an event if it exists
@param string $method
@param string $event
@return null
|
[
"Add",
"a",
"callback",
"for",
"an",
"event",
"if",
"it",
"exists"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L145-L157
|
231,571
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.addEventCallbacks
|
private static function addEventCallbacks(array $events = [])
{
$hooks = ['before' => 'ing', 'after' => 'ed'];
foreach ($events as $event)
{
foreach ($hooks as $hook => $suffix)
{
$method = $hook . ucfirst($event) . 'e';
$callback = $event . $suffix;
self::addObservableEvent($method, $callback);
}
}
}
|
php
|
private static function addEventCallbacks(array $events = [])
{
$hooks = ['before' => 'ing', 'after' => 'ed'];
foreach ($events as $event)
{
foreach ($hooks as $hook => $suffix)
{
$method = $hook . ucfirst($event) . 'e';
$callback = $event . $suffix;
self::addObservableEvent($method, $callback);
}
}
}
|
[
"private",
"static",
"function",
"addEventCallbacks",
"(",
"array",
"$",
"events",
"=",
"[",
"]",
")",
"{",
"$",
"hooks",
"=",
"[",
"'before'",
"=>",
"'ing'",
",",
"'after'",
"=>",
"'ed'",
"]",
";",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"foreach",
"(",
"$",
"hooks",
"as",
"$",
"hook",
"=>",
"$",
"suffix",
")",
"{",
"$",
"method",
"=",
"$",
"hook",
".",
"ucfirst",
"(",
"$",
"event",
")",
".",
"'e'",
";",
"$",
"callback",
"=",
"$",
"event",
".",
"$",
"suffix",
";",
"self",
"::",
"addObservableEvent",
"(",
"$",
"method",
",",
"$",
"callback",
")",
";",
"}",
"}",
"}"
] |
Attach callback before and after a set of events
@param array $events
@return null
|
[
"Attach",
"callback",
"before",
"and",
"after",
"a",
"set",
"of",
"events"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L165-L179
|
231,572
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.create
|
public static function create(array $data = [], array $rules = [], array $messages = [])
{
$model = new static;
$model->saveRecursive($data, $rules, $messages);
return $model;
}
|
php
|
public static function create(array $data = [], array $rules = [], array $messages = [])
{
$model = new static;
$model->saveRecursive($data, $rules, $messages);
return $model;
}
|
[
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"rules",
"=",
"[",
"]",
",",
"array",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"$",
"model",
"=",
"new",
"static",
";",
"$",
"model",
"->",
"saveRecursive",
"(",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
")",
";",
"return",
"$",
"model",
";",
"}"
] |
Create a record in one go
@param array $data
@param array $rules
@param array $messages
@return Vocal
|
[
"Create",
"a",
"record",
"in",
"one",
"go"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L203-L209
|
231,573
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.extractErrors
|
private function extractErrors($error)
{
$messages = [];
foreach ($error as $key => $errors)
{
// If error is a MessageBag, extract errors
if ($errors instanceof MessageBag) return $this->extractErrors($errors->toArray());
// If we have an array of errors preserve key
if (is_array($errors))
{
$messages[$key] = $this->extractErrors($errors);
continue;
}
// We must be down to a single error, just return it
return $errors;
}
return $messages;
}
|
php
|
private function extractErrors($error)
{
$messages = [];
foreach ($error as $key => $errors)
{
// If error is a MessageBag, extract errors
if ($errors instanceof MessageBag) return $this->extractErrors($errors->toArray());
// If we have an array of errors preserve key
if (is_array($errors))
{
$messages[$key] = $this->extractErrors($errors);
continue;
}
// We must be down to a single error, just return it
return $errors;
}
return $messages;
}
|
[
"private",
"function",
"extractErrors",
"(",
"$",
"error",
")",
"{",
"$",
"messages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"error",
"as",
"$",
"key",
"=>",
"$",
"errors",
")",
"{",
"// If error is a MessageBag, extract errors",
"if",
"(",
"$",
"errors",
"instanceof",
"MessageBag",
")",
"return",
"$",
"this",
"->",
"extractErrors",
"(",
"$",
"errors",
"->",
"toArray",
"(",
")",
")",
";",
"// If we have an array of errors preserve key",
"if",
"(",
"is_array",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"messages",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"extractErrors",
"(",
"$",
"errors",
")",
";",
"continue",
";",
"}",
"// We must be down to a single error, just return it",
"return",
"$",
"errors",
";",
"}",
"return",
"$",
"messages",
";",
"}"
] |
Recursively extract error messages
@param array $error
@return array
|
[
"Recursively",
"extract",
"error",
"messages"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L217-L238
|
231,574
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.fillModel
|
private function fillModel()
{
// If we've already filled this model don't fill it again
if ($this->hydrated) return true;
// Fire hydrating event
if ($this->fireModelEvent('hydrating') === false) return false;
// Fill from data and record we've filled it
$this->fill($this->dataset);
$this->hydrated = true;
// Remove any fields from the model which can't be submitted, such as objects and arrays
// - This will prevent errors with bound objects being saved twice
$this->removeInvalidAttributes();
$this->fireModelEvent('hydrated', false);
return true;
}
|
php
|
private function fillModel()
{
// If we've already filled this model don't fill it again
if ($this->hydrated) return true;
// Fire hydrating event
if ($this->fireModelEvent('hydrating') === false) return false;
// Fill from data and record we've filled it
$this->fill($this->dataset);
$this->hydrated = true;
// Remove any fields from the model which can't be submitted, such as objects and arrays
// - This will prevent errors with bound objects being saved twice
$this->removeInvalidAttributes();
$this->fireModelEvent('hydrated', false);
return true;
}
|
[
"private",
"function",
"fillModel",
"(",
")",
"{",
"// If we've already filled this model don't fill it again",
"if",
"(",
"$",
"this",
"->",
"hydrated",
")",
"return",
"true",
";",
"// Fire hydrating event",
"if",
"(",
"$",
"this",
"->",
"fireModelEvent",
"(",
"'hydrating'",
")",
"===",
"false",
")",
"return",
"false",
";",
"// Fill from data and record we've filled it",
"$",
"this",
"->",
"fill",
"(",
"$",
"this",
"->",
"dataset",
")",
";",
"$",
"this",
"->",
"hydrated",
"=",
"true",
";",
"// Remove any fields from the model which can't be submitted, such as objects and arrays",
"// - This will prevent errors with bound objects being saved twice",
"$",
"this",
"->",
"removeInvalidAttributes",
"(",
")",
";",
"$",
"this",
"->",
"fireModelEvent",
"(",
"'hydrated'",
",",
"false",
")",
";",
"return",
"true",
";",
"}"
] |
Fill a model from input or an array
@return bool
|
[
"Fill",
"a",
"model",
"from",
"input",
"or",
"an",
"array"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L245-L264
|
231,575
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.filterRelationshipByConditions
|
private function filterRelationshipByConditions($model, $conditions)
{
// Test for false and return the opposite
return ( !
(isset($conditions['only']) && ! in_array($model, $conditions['only'])) ||
(isset($conditions['except']) && in_array($model, $conditions['except']))
);
}
|
php
|
private function filterRelationshipByConditions($model, $conditions)
{
// Test for false and return the opposite
return ( !
(isset($conditions['only']) && ! in_array($model, $conditions['only'])) ||
(isset($conditions['except']) && in_array($model, $conditions['except']))
);
}
|
[
"private",
"function",
"filterRelationshipByConditions",
"(",
"$",
"model",
",",
"$",
"conditions",
")",
"{",
"// Test for false and return the opposite",
"return",
"(",
"!",
"(",
"isset",
"(",
"$",
"conditions",
"[",
"'only'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"$",
"model",
",",
"$",
"conditions",
"[",
"'only'",
"]",
")",
")",
"||",
"(",
"isset",
"(",
"$",
"conditions",
"[",
"'except'",
"]",
")",
"&&",
"in_array",
"(",
"$",
"model",
",",
"$",
"conditions",
"[",
"'except'",
"]",
")",
")",
")",
";",
"}"
] |
Test 'only' and 'except' lists for excluding relationships
@param string $model
@param array $conditions
@return bool
|
[
"Test",
"only",
"and",
"except",
"lists",
"for",
"excluding",
"relationships"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L273-L280
|
231,576
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.findOrCreateRecord
|
private function findOrCreateRecord($key = null)
{
if ($key)
{
$record = ($this->usesSoftDeletes()) ? $this->withTrashed()->find($key) : $this->find($key);
// Only return a record if we found one, otherwise we will end up sending a new record back below
if ($record) return $record;
}
return new $this;
}
|
php
|
private function findOrCreateRecord($key = null)
{
if ($key)
{
$record = ($this->usesSoftDeletes()) ? $this->withTrashed()->find($key) : $this->find($key);
// Only return a record if we found one, otherwise we will end up sending a new record back below
if ($record) return $record;
}
return new $this;
}
|
[
"private",
"function",
"findOrCreateRecord",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
")",
"{",
"$",
"record",
"=",
"(",
"$",
"this",
"->",
"usesSoftDeletes",
"(",
")",
")",
"?",
"$",
"this",
"->",
"withTrashed",
"(",
")",
"->",
"find",
"(",
"$",
"key",
")",
":",
"$",
"this",
"->",
"find",
"(",
"$",
"key",
")",
";",
"// Only return a record if we found one, otherwise we will end up sending a new record back below",
"if",
"(",
"$",
"record",
")",
"return",
"$",
"record",
";",
"}",
"return",
"new",
"$",
"this",
";",
"}"
] |
Find or create a record if it doesn't exist
@param integer|string $key
@return Vocal
|
[
"Find",
"or",
"create",
"a",
"record",
"if",
"it",
"doesn",
"t",
"exist"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L288-L299
|
231,577
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.forceSave
|
public function forceSave(array $data = [], $recursive = false)
{
return ($recursive) ? $this->recurse('save', $data) : $this->saveRecord($data);
}
|
php
|
public function forceSave(array $data = [], $recursive = false)
{
return ($recursive) ? $this->recurse('save', $data) : $this->saveRecord($data);
}
|
[
"public",
"function",
"forceSave",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"return",
"(",
"$",
"recursive",
")",
"?",
"$",
"this",
"->",
"recurse",
"(",
"'save'",
",",
"$",
"data",
")",
":",
"$",
"this",
"->",
"saveRecord",
"(",
"$",
"data",
")",
";",
"}"
] |
Save a record regardless of whether it's valid or not
@param array $data
@return bool
|
[
"Save",
"a",
"record",
"regardless",
"of",
"whether",
"it",
"s",
"valid",
"or",
"not"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L321-L324
|
231,578
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.getErrors
|
public function getErrors($filter = null)
{
// Create an array to hold errors
$messages = [];
// If we have no errors, abort
if ( ! $this->errors->count()) return $messages;
foreach ($this->errors->toArray() as $key => $error)
{
$messages[$key] = $this->extractErrors($error);
}
// Return a specific set of messages if asked
return array_get($messages, $filter);
}
|
php
|
public function getErrors($filter = null)
{
// Create an array to hold errors
$messages = [];
// If we have no errors, abort
if ( ! $this->errors->count()) return $messages;
foreach ($this->errors->toArray() as $key => $error)
{
$messages[$key] = $this->extractErrors($error);
}
// Return a specific set of messages if asked
return array_get($messages, $filter);
}
|
[
"public",
"function",
"getErrors",
"(",
"$",
"filter",
"=",
"null",
")",
"{",
"// Create an array to hold errors",
"$",
"messages",
"=",
"[",
"]",
";",
"// If we have no errors, abort",
"if",
"(",
"!",
"$",
"this",
"->",
"errors",
"->",
"count",
"(",
")",
")",
"return",
"$",
"messages",
";",
"foreach",
"(",
"$",
"this",
"->",
"errors",
"->",
"toArray",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"error",
")",
"{",
"$",
"messages",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"extractErrors",
"(",
"$",
"error",
")",
";",
"}",
"// Return a specific set of messages if asked",
"return",
"array_get",
"(",
"$",
"messages",
",",
"$",
"filter",
")",
";",
"}"
] |
Return the errors as an array
@param string $filter
@return array
|
[
"Return",
"the",
"errors",
"as",
"an",
"array"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L355-L370
|
231,579
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.getParameters
|
private function getParameters($type, $index = null)
{
// If the type is invalid, return an empty array
if ( ! in_array($type, ['dataset', 'messageset', 'ruleset'])) return [];
return array_get($this->{$type}, $index, []);
}
|
php
|
private function getParameters($type, $index = null)
{
// If the type is invalid, return an empty array
if ( ! in_array($type, ['dataset', 'messageset', 'ruleset'])) return [];
return array_get($this->{$type}, $index, []);
}
|
[
"private",
"function",
"getParameters",
"(",
"$",
"type",
",",
"$",
"index",
"=",
"null",
")",
"{",
"// If the type is invalid, return an empty array",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"[",
"'dataset'",
",",
"'messageset'",
",",
"'ruleset'",
"]",
")",
")",
"return",
"[",
"]",
";",
"return",
"array_get",
"(",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
",",
"$",
"index",
",",
"[",
"]",
")",
";",
"}"
] |
Get relationship data, rules or messages
@param string $type
@param integer|string $index
@return array
|
[
"Get",
"relationship",
"data",
"rules",
"or",
"messages"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L439-L445
|
231,580
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.getRelationships
|
private function getRelationships()
{
$relationships = [];
// Loop through input, and check whether any key is a valid relationship
foreach ($this->dataset as $model => $value)
{
// Skip anything which isn't a valid relationship
if ( ! $this->isRelationship($model, $this->conditions)) continue;
// Capture relationship and it's type
$relationships[$model] = $this->getRelationshipType(Str::camel($model));
}
return $relationships;
}
|
php
|
private function getRelationships()
{
$relationships = [];
// Loop through input, and check whether any key is a valid relationship
foreach ($this->dataset as $model => $value)
{
// Skip anything which isn't a valid relationship
if ( ! $this->isRelationship($model, $this->conditions)) continue;
// Capture relationship and it's type
$relationships[$model] = $this->getRelationshipType(Str::camel($model));
}
return $relationships;
}
|
[
"private",
"function",
"getRelationships",
"(",
")",
"{",
"$",
"relationships",
"=",
"[",
"]",
";",
"// Loop through input, and check whether any key is a valid relationship",
"foreach",
"(",
"$",
"this",
"->",
"dataset",
"as",
"$",
"model",
"=>",
"$",
"value",
")",
"{",
"// Skip anything which isn't a valid relationship",
"if",
"(",
"!",
"$",
"this",
"->",
"isRelationship",
"(",
"$",
"model",
",",
"$",
"this",
"->",
"conditions",
")",
")",
"continue",
";",
"// Capture relationship and it's type",
"$",
"relationships",
"[",
"$",
"model",
"]",
"=",
"$",
"this",
"->",
"getRelationshipType",
"(",
"Str",
"::",
"camel",
"(",
"$",
"model",
")",
")",
";",
"}",
"return",
"$",
"relationships",
";",
"}"
] |
Get all relationships for a model
@return array
|
[
"Get",
"all",
"relationships",
"for",
"a",
"model"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L485-L500
|
231,581
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.getRelationshipType
|
private function getRelationshipType($model)
{
// Poke method to check the type of instance
$class = get_class($this->{$model}());
$reflection = new ReflectionClass($class);
return (in_array($reflection->getShortName(), ['BelongsTo', 'HasOne', 'MorphOne', 'MorphTo'])) ? 'one' : 'many';
}
|
php
|
private function getRelationshipType($model)
{
// Poke method to check the type of instance
$class = get_class($this->{$model}());
$reflection = new ReflectionClass($class);
return (in_array($reflection->getShortName(), ['BelongsTo', 'HasOne', 'MorphOne', 'MorphTo'])) ? 'one' : 'many';
}
|
[
"private",
"function",
"getRelationshipType",
"(",
"$",
"model",
")",
"{",
"// Poke method to check the type of instance",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
"->",
"{",
"$",
"model",
"}",
"(",
")",
")",
";",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"return",
"(",
"in_array",
"(",
"$",
"reflection",
"->",
"getShortName",
"(",
")",
",",
"[",
"'BelongsTo'",
",",
"'HasOne'",
",",
"'MorphOne'",
",",
"'MorphTo'",
"]",
")",
")",
"?",
"'one'",
":",
"'many'",
";",
"}"
] |
Determine if we're working with a one or many relationship
@param string $model
@return string
|
[
"Determine",
"if",
"we",
"re",
"working",
"with",
"a",
"one",
"or",
"many",
"relationship"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L508-L515
|
231,582
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.hashHashable
|
private function hashHashable()
{
$hasher = new BcryptHasher;
$filtered = array_filter($this->attributes);
foreach ($filtered as $key => $value)
{
if (in_array($key, $this->hashable) && $value != $this->getOriginal($key))
{
$this->attributes[$key] = $hasher->make($value);
}
}
}
|
php
|
private function hashHashable()
{
$hasher = new BcryptHasher;
$filtered = array_filter($this->attributes);
foreach ($filtered as $key => $value)
{
if (in_array($key, $this->hashable) && $value != $this->getOriginal($key))
{
$this->attributes[$key] = $hasher->make($value);
}
}
}
|
[
"private",
"function",
"hashHashable",
"(",
")",
"{",
"$",
"hasher",
"=",
"new",
"BcryptHasher",
";",
"$",
"filtered",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"attributes",
")",
";",
"foreach",
"(",
"$",
"filtered",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"hashable",
")",
"&&",
"$",
"value",
"!=",
"$",
"this",
"->",
"getOriginal",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
"=",
"$",
"hasher",
"->",
"make",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}"
] |
Hash any hashable attributes
@return null
|
[
"Hash",
"any",
"hashable",
"attributes"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L535-L547
|
231,583
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.isRelationship
|
private function isRelationship($model, $conditions)
{
/**
* A valid relationship must:
* - Be a method
* - Not appear in the 'except' list
* - Appear in the 'only' list (if used)
* - Extend Illuminate\Database\Eloquent\Relations\Relation
*/
return (
method_exists($this, $model) &&
$this->filterRelationshipByConditions($model, $conditions) &&
is_subclass_of($this->{Str::camel($model)}(), 'Illuminate\Database\Eloquent\Relations\Relation')
);
}
|
php
|
private function isRelationship($model, $conditions)
{
/**
* A valid relationship must:
* - Be a method
* - Not appear in the 'except' list
* - Appear in the 'only' list (if used)
* - Extend Illuminate\Database\Eloquent\Relations\Relation
*/
return (
method_exists($this, $model) &&
$this->filterRelationshipByConditions($model, $conditions) &&
is_subclass_of($this->{Str::camel($model)}(), 'Illuminate\Database\Eloquent\Relations\Relation')
);
}
|
[
"private",
"function",
"isRelationship",
"(",
"$",
"model",
",",
"$",
"conditions",
")",
"{",
"/**\n * A valid relationship must:\n * - Be a method\n * - Not appear in the 'except' list\n * - Appear in the 'only' list (if used)\n * - Extend Illuminate\\Database\\Eloquent\\Relations\\Relation\n */",
"return",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"model",
")",
"&&",
"$",
"this",
"->",
"filterRelationshipByConditions",
"(",
"$",
"model",
",",
"$",
"conditions",
")",
"&&",
"is_subclass_of",
"(",
"$",
"this",
"->",
"{",
"Str",
"::",
"camel",
"(",
"$",
"model",
")",
"}",
"(",
")",
",",
"'Illuminate\\Database\\Eloquent\\Relations\\Relation'",
")",
")",
";",
"}"
] |
Determine if a string is a relationship
@param string $model
@param array $conditions
@return bool
|
[
"Determine",
"if",
"a",
"string",
"is",
"a",
"relationship"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L590-L604
|
231,584
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.mergeArrayFromIndex
|
private function mergeArrayFromIndex(array $to, array $from, $index = 0)
{
$size = count($from);
if ($size > $index) for ($i = $index; $i < $size; ++$i) $to[] = $from[$i];
return $to;
}
|
php
|
private function mergeArrayFromIndex(array $to, array $from, $index = 0)
{
$size = count($from);
if ($size > $index) for ($i = $index; $i < $size; ++$i) $to[] = $from[$i];
return $to;
}
|
[
"private",
"function",
"mergeArrayFromIndex",
"(",
"array",
"$",
"to",
",",
"array",
"$",
"from",
",",
"$",
"index",
"=",
"0",
")",
"{",
"$",
"size",
"=",
"count",
"(",
"$",
"from",
")",
";",
"if",
"(",
"$",
"size",
">",
"$",
"index",
")",
"for",
"(",
"$",
"i",
"=",
"$",
"index",
";",
"$",
"i",
"<",
"$",
"size",
";",
"++",
"$",
"i",
")",
"$",
"to",
"[",
"]",
"=",
"$",
"from",
"[",
"$",
"i",
"]",
";",
"return",
"$",
"to",
";",
"}"
] |
Merge an array from an index point
@param array $to
@param array $from
@param integer $index
@return array
|
[
"Merge",
"an",
"array",
"from",
"an",
"index",
"point"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L614-L621
|
231,585
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.mergeErrors
|
private function mergeErrors(MessageBag $bag, MessageBag $errors, $index = null)
{
if ( ! $errors->count()) return $bag;
// Add or merge errors into bag
if ($index !== null) $bag->add($index, $errors);
else $bag->merge($errors);
return $bag;
}
|
php
|
private function mergeErrors(MessageBag $bag, MessageBag $errors, $index = null)
{
if ( ! $errors->count()) return $bag;
// Add or merge errors into bag
if ($index !== null) $bag->add($index, $errors);
else $bag->merge($errors);
return $bag;
}
|
[
"private",
"function",
"mergeErrors",
"(",
"MessageBag",
"$",
"bag",
",",
"MessageBag",
"$",
"errors",
",",
"$",
"index",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"errors",
"->",
"count",
"(",
")",
")",
"return",
"$",
"bag",
";",
"// Add or merge errors into bag",
"if",
"(",
"$",
"index",
"!==",
"null",
")",
"$",
"bag",
"->",
"add",
"(",
"$",
"index",
",",
"$",
"errors",
")",
";",
"else",
"$",
"bag",
"->",
"merge",
"(",
"$",
"errors",
")",
";",
"return",
"$",
"bag",
";",
"}"
] |
Merge two message bags together
@param \Illuminate\Support\MessageBag $bag
@param \Illuminate\Support\MessageBag $errors
@param integer $index
@return \Illuminate\Support\MessageBag
|
[
"Merge",
"two",
"message",
"bags",
"together"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L631-L640
|
231,586
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.parseRuleParameters
|
private function parseRuleParameters($field, $parameters)
{
// Make sure parameters is an array
$parameters = (strpos($parameters, ',') > 0) ? explode(',', $parameters) : [$parameters];
// Process each parameter
foreach ($parameters as $key => $parameter)
{
// Replace ~table and ~field if they exist
$parameter = str_ireplace(['~table', '~field'], [$this->getTable(), $field], $parameter);
// Replace with attribute
if (strpos($parameter, '~') !== false) $parameter = $this->{str_replace('~', '', $parameter)};
}
return $parameters;
}
|
php
|
private function parseRuleParameters($field, $parameters)
{
// Make sure parameters is an array
$parameters = (strpos($parameters, ',') > 0) ? explode(',', $parameters) : [$parameters];
// Process each parameter
foreach ($parameters as $key => $parameter)
{
// Replace ~table and ~field if they exist
$parameter = str_ireplace(['~table', '~field'], [$this->getTable(), $field], $parameter);
// Replace with attribute
if (strpos($parameter, '~') !== false) $parameter = $this->{str_replace('~', '', $parameter)};
}
return $parameters;
}
|
[
"private",
"function",
"parseRuleParameters",
"(",
"$",
"field",
",",
"$",
"parameters",
")",
"{",
"// Make sure parameters is an array",
"$",
"parameters",
"=",
"(",
"strpos",
"(",
"$",
"parameters",
",",
"','",
")",
">",
"0",
")",
"?",
"explode",
"(",
"','",
",",
"$",
"parameters",
")",
":",
"[",
"$",
"parameters",
"]",
";",
"// Process each parameter",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"parameter",
")",
"{",
"// Replace ~table and ~field if they exist",
"$",
"parameter",
"=",
"str_ireplace",
"(",
"[",
"'~table'",
",",
"'~field'",
"]",
",",
"[",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"$",
"field",
"]",
",",
"$",
"parameter",
")",
";",
"// Replace with attribute",
"if",
"(",
"strpos",
"(",
"$",
"parameter",
",",
"'~'",
")",
"!==",
"false",
")",
"$",
"parameter",
"=",
"$",
"this",
"->",
"{",
"str_replace",
"(",
"'~'",
",",
"''",
",",
"$",
"parameter",
")",
"}",
";",
"}",
"return",
"$",
"parameters",
";",
"}"
] |
Parse rule parameters
@param string $field
@param string|array $parameters
@return array
|
[
"Parse",
"rule",
"parameters"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L649-L665
|
231,587
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.parseUniqueRule
|
private function parseUniqueRule($field, array $parameters, $type)
{
// If we have a unique rule, make sure it's built correctly
if ($type != 'unique') return $parameters;
// The first item may be null, remove it if that's the case
$parameters = array_filter($parameters);
// Determine primary key
$primaryKey = (isset($this->primaryKey)) ? $this->primaryKey : 'id';
// Construct unique rule correctly
$rule = [
array_get($parameters, 0, $this->getTable()),
array_get($parameters, 1, $field),
array_get($parameters, 2, $this->{$primaryKey}),
array_get($parameters, 3, $primaryKey)
];
// Merge in any other parameters we have
return $this->mergeArrayFromIndex($rule, $parameters, 4);
}
|
php
|
private function parseUniqueRule($field, array $parameters, $type)
{
// If we have a unique rule, make sure it's built correctly
if ($type != 'unique') return $parameters;
// The first item may be null, remove it if that's the case
$parameters = array_filter($parameters);
// Determine primary key
$primaryKey = (isset($this->primaryKey)) ? $this->primaryKey : 'id';
// Construct unique rule correctly
$rule = [
array_get($parameters, 0, $this->getTable()),
array_get($parameters, 1, $field),
array_get($parameters, 2, $this->{$primaryKey}),
array_get($parameters, 3, $primaryKey)
];
// Merge in any other parameters we have
return $this->mergeArrayFromIndex($rule, $parameters, 4);
}
|
[
"private",
"function",
"parseUniqueRule",
"(",
"$",
"field",
",",
"array",
"$",
"parameters",
",",
"$",
"type",
")",
"{",
"// If we have a unique rule, make sure it's built correctly",
"if",
"(",
"$",
"type",
"!=",
"'unique'",
")",
"return",
"$",
"parameters",
";",
"// The first item may be null, remove it if that's the case",
"$",
"parameters",
"=",
"array_filter",
"(",
"$",
"parameters",
")",
";",
"// Determine primary key",
"$",
"primaryKey",
"=",
"(",
"isset",
"(",
"$",
"this",
"->",
"primaryKey",
")",
")",
"?",
"$",
"this",
"->",
"primaryKey",
":",
"'id'",
";",
"// Construct unique rule correctly",
"$",
"rule",
"=",
"[",
"array_get",
"(",
"$",
"parameters",
",",
"0",
",",
"$",
"this",
"->",
"getTable",
"(",
")",
")",
",",
"array_get",
"(",
"$",
"parameters",
",",
"1",
",",
"$",
"field",
")",
",",
"array_get",
"(",
"$",
"parameters",
",",
"2",
",",
"$",
"this",
"->",
"{",
"$",
"primaryKey",
"}",
")",
",",
"array_get",
"(",
"$",
"parameters",
",",
"3",
",",
"$",
"primaryKey",
")",
"]",
";",
"// Merge in any other parameters we have",
"return",
"$",
"this",
"->",
"mergeArrayFromIndex",
"(",
"$",
"rule",
",",
"$",
"parameters",
",",
"4",
")",
";",
"}"
] |
Parse a unique rule
@param string $field
@param array $parameters
@param string $type
@return array
|
[
"Parse",
"a",
"unique",
"rule"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L675-L696
|
231,588
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.prepareRecord
|
private function prepareRecord(array $data, array $rules, array $messages)
{
// Reset error bag
$this->errors = new MessageBag;
// Capture data
$this->setDataset($data);
$this->setRuleset($rules);
$this->setMessageset($messages);
// Fill model
$this->fillModel();
}
|
php
|
private function prepareRecord(array $data, array $rules, array $messages)
{
// Reset error bag
$this->errors = new MessageBag;
// Capture data
$this->setDataset($data);
$this->setRuleset($rules);
$this->setMessageset($messages);
// Fill model
$this->fillModel();
}
|
[
"private",
"function",
"prepareRecord",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"rules",
",",
"array",
"$",
"messages",
")",
"{",
"// Reset error bag",
"$",
"this",
"->",
"errors",
"=",
"new",
"MessageBag",
";",
"// Capture data",
"$",
"this",
"->",
"setDataset",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setRuleset",
"(",
"$",
"rules",
")",
";",
"$",
"this",
"->",
"setMessageset",
"(",
"$",
"messages",
")",
";",
"// Fill model",
"$",
"this",
"->",
"fillModel",
"(",
")",
";",
"}"
] |
Prepare a record for saving or validating
@param array $data
@param array $rules
@param array $messages
@return null
|
[
"Prepare",
"a",
"record",
"for",
"saving",
"or",
"validating"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L717-L729
|
231,589
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.processRuleset
|
private function processRuleset($field, array $set)
{
$rules = [];
foreach ($set as $rule)
{
// If this rule is an array skip it because it's going to be a relationship
if (is_array($rule)) continue;
list($type, $parameters) = $this->getRuleTypeAndParameters($rule);
$parameters = $this->parseRuleParameters($field, $parameters);
$parameters = $this->parseUniqueRule($field, $parameters, $type);
// Rebuild rule
$rules[] = $this->rebuildRule($type, $parameters);
}
return $rules;
}
|
php
|
private function processRuleset($field, array $set)
{
$rules = [];
foreach ($set as $rule)
{
// If this rule is an array skip it because it's going to be a relationship
if (is_array($rule)) continue;
list($type, $parameters) = $this->getRuleTypeAndParameters($rule);
$parameters = $this->parseRuleParameters($field, $parameters);
$parameters = $this->parseUniqueRule($field, $parameters, $type);
// Rebuild rule
$rules[] = $this->rebuildRule($type, $parameters);
}
return $rules;
}
|
[
"private",
"function",
"processRuleset",
"(",
"$",
"field",
",",
"array",
"$",
"set",
")",
"{",
"$",
"rules",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"set",
"as",
"$",
"rule",
")",
"{",
"// If this rule is an array skip it because it's going to be a relationship",
"if",
"(",
"is_array",
"(",
"$",
"rule",
")",
")",
"continue",
";",
"list",
"(",
"$",
"type",
",",
"$",
"parameters",
")",
"=",
"$",
"this",
"->",
"getRuleTypeAndParameters",
"(",
"$",
"rule",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"parseRuleParameters",
"(",
"$",
"field",
",",
"$",
"parameters",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"parseUniqueRule",
"(",
"$",
"field",
",",
"$",
"parameters",
",",
"$",
"type",
")",
";",
"// Rebuild rule",
"$",
"rules",
"[",
"]",
"=",
"$",
"this",
"->",
"rebuildRule",
"(",
"$",
"type",
",",
"$",
"parameters",
")",
";",
"}",
"return",
"$",
"rules",
";",
"}"
] |
Process rule set into rules
@param string $field
@param array $set
@return array
|
[
"Process",
"rule",
"set",
"into",
"rules"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L738-L756
|
231,590
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.rebuildRule
|
private function rebuildRule($type, $parameters)
{
// Rebuild rule
$rule = $type;
if (is_array($parameters) && count($parameters)) $rule .= ':' . implode(',', $parameters);
else $rule .= ':' . $parameters;
// Remove any trailing colons we have from rules without parameters
return trim($rule, ':');
}
|
php
|
private function rebuildRule($type, $parameters)
{
// Rebuild rule
$rule = $type;
if (is_array($parameters) && count($parameters)) $rule .= ':' . implode(',', $parameters);
else $rule .= ':' . $parameters;
// Remove any trailing colons we have from rules without parameters
return trim($rule, ':');
}
|
[
"private",
"function",
"rebuildRule",
"(",
"$",
"type",
",",
"$",
"parameters",
")",
"{",
"// Rebuild rule",
"$",
"rule",
"=",
"$",
"type",
";",
"if",
"(",
"is_array",
"(",
"$",
"parameters",
")",
"&&",
"count",
"(",
"$",
"parameters",
")",
")",
"$",
"rule",
".=",
"':'",
".",
"implode",
"(",
"','",
",",
"$",
"parameters",
")",
";",
"else",
"$",
"rule",
".=",
"':'",
".",
"$",
"parameters",
";",
"// Remove any trailing colons we have from rules without parameters",
"return",
"trim",
"(",
"$",
"rule",
",",
"':'",
")",
";",
"}"
] |
Rebuild a whole rule
@param string $type
@param string|array $parameters
@return string
|
[
"Rebuild",
"a",
"whole",
"rule"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L765-L775
|
231,591
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.recurse
|
private function recurse($method, array $data = [], array $rules = [], array $messages = [])
{
// Make sure method is valid
if ( ! in_array($method, ['save', 'validate'])) return false;
// Disable validation
$validateBeforeSave = $this->validateBeforeSave;
$this->validateBeforeSave = false;
// Perform action
$result = $this->{$method}($data, $rules, $messages);
// Check for relationships
$relationships = $this->getRelationships();
// Recurse into each relationship if we can
foreach ($relationships as $name => $type)
{
$subresult = $this->recurseRelationship($method, $name, $type);
// If a relationship fails, we fail
if ( ! $subresult) $result = false;
}
// Reset validation
$this->validateBeforeSave = $validateBeforeSave;
return $result;
}
|
php
|
private function recurse($method, array $data = [], array $rules = [], array $messages = [])
{
// Make sure method is valid
if ( ! in_array($method, ['save', 'validate'])) return false;
// Disable validation
$validateBeforeSave = $this->validateBeforeSave;
$this->validateBeforeSave = false;
// Perform action
$result = $this->{$method}($data, $rules, $messages);
// Check for relationships
$relationships = $this->getRelationships();
// Recurse into each relationship if we can
foreach ($relationships as $name => $type)
{
$subresult = $this->recurseRelationship($method, $name, $type);
// If a relationship fails, we fail
if ( ! $subresult) $result = false;
}
// Reset validation
$this->validateBeforeSave = $validateBeforeSave;
return $result;
}
|
[
"private",
"function",
"recurse",
"(",
"$",
"method",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"rules",
"=",
"[",
"]",
",",
"array",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"// Make sure method is valid",
"if",
"(",
"!",
"in_array",
"(",
"$",
"method",
",",
"[",
"'save'",
",",
"'validate'",
"]",
")",
")",
"return",
"false",
";",
"// Disable validation",
"$",
"validateBeforeSave",
"=",
"$",
"this",
"->",
"validateBeforeSave",
";",
"$",
"this",
"->",
"validateBeforeSave",
"=",
"false",
";",
"// Perform action",
"$",
"result",
"=",
"$",
"this",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
")",
";",
"// Check for relationships",
"$",
"relationships",
"=",
"$",
"this",
"->",
"getRelationships",
"(",
")",
";",
"// Recurse into each relationship if we can",
"foreach",
"(",
"$",
"relationships",
"as",
"$",
"name",
"=>",
"$",
"type",
")",
"{",
"$",
"subresult",
"=",
"$",
"this",
"->",
"recurseRelationship",
"(",
"$",
"method",
",",
"$",
"name",
",",
"$",
"type",
")",
";",
"// If a relationship fails, we fail",
"if",
"(",
"!",
"$",
"subresult",
")",
"$",
"result",
"=",
"false",
";",
"}",
"// Reset validation",
"$",
"this",
"->",
"validateBeforeSave",
"=",
"$",
"validateBeforeSave",
";",
"return",
"$",
"result",
";",
"}"
] |
Perform a recursive action
@param string $method
@param array $data
@param array $rules
@param array $messages
@return bool
|
[
"Perform",
"a",
"recursive",
"action"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L786-L814
|
231,592
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.recurseRelationship
|
private function recurseRelationship($method, $name, $type = 'one')
{
$dataset = $this->getParameters('dataset', $name);
// Assume by default this will pass
$result = true;
if ($type == 'one')
{
$result = $this->recurseRecord($method, $name, $dataset);
}
else
{
foreach ($dataset as $index => $data)
{
$subresult = $this->recurseRecord($method, $name, $data, $index);
// Relationship failures are failures
if ( ! $subresult) $result = false;
}
}
// A positive result and no errors mean action was successful
return ($result && $this->errors->count() === 0);
}
|
php
|
private function recurseRelationship($method, $name, $type = 'one')
{
$dataset = $this->getParameters('dataset', $name);
// Assume by default this will pass
$result = true;
if ($type == 'one')
{
$result = $this->recurseRecord($method, $name, $dataset);
}
else
{
foreach ($dataset as $index => $data)
{
$subresult = $this->recurseRecord($method, $name, $data, $index);
// Relationship failures are failures
if ( ! $subresult) $result = false;
}
}
// A positive result and no errors mean action was successful
return ($result && $this->errors->count() === 0);
}
|
[
"private",
"function",
"recurseRelationship",
"(",
"$",
"method",
",",
"$",
"name",
",",
"$",
"type",
"=",
"'one'",
")",
"{",
"$",
"dataset",
"=",
"$",
"this",
"->",
"getParameters",
"(",
"'dataset'",
",",
"$",
"name",
")",
";",
"// Assume by default this will pass",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"$",
"type",
"==",
"'one'",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"recurseRecord",
"(",
"$",
"method",
",",
"$",
"name",
",",
"$",
"dataset",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"dataset",
"as",
"$",
"index",
"=>",
"$",
"data",
")",
"{",
"$",
"subresult",
"=",
"$",
"this",
"->",
"recurseRecord",
"(",
"$",
"method",
",",
"$",
"name",
",",
"$",
"data",
",",
"$",
"index",
")",
";",
"// Relationship failures are failures",
"if",
"(",
"!",
"$",
"subresult",
")",
"$",
"result",
"=",
"false",
";",
"}",
"}",
"// A positive result and no errors mean action was successful",
"return",
"(",
"$",
"result",
"&&",
"$",
"this",
"->",
"errors",
"->",
"count",
"(",
")",
"===",
"0",
")",
";",
"}"
] |
Validate a one to many relationship
@param string $method
@param string $name
@param string $type
@return bool
|
[
"Validate",
"a",
"one",
"to",
"many",
"relationship"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L824-L848
|
231,593
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.recurseRecord
|
private function recurseRecord($method, $name, array $data, $index = null)
{
// Get model and determine primary key column
$class = Str::camel($name);
$model = $this->{$class}()->getModel();
$primaryKey = (isset($model->primaryKey)) ? $model->primaryKey : 'id';
$key = array_get($data, $primaryKey);
// Find record and perform action on it
$record = $model->findOrCreateRecord($key);
$result = $record->recurse($method, $data, $this->getParameters('ruleset', $name), $this->getParameters('messageset', $name));
// Capture errors
$this->errors = $this->mergeErrors($this->errors, $record->getErrorBag(), $index);
// Attach relationhip to record
if ($result) $this->setRelationship($record, $name, $class, $index);
// Record failure
return $result;
}
|
php
|
private function recurseRecord($method, $name, array $data, $index = null)
{
// Get model and determine primary key column
$class = Str::camel($name);
$model = $this->{$class}()->getModel();
$primaryKey = (isset($model->primaryKey)) ? $model->primaryKey : 'id';
$key = array_get($data, $primaryKey);
// Find record and perform action on it
$record = $model->findOrCreateRecord($key);
$result = $record->recurse($method, $data, $this->getParameters('ruleset', $name), $this->getParameters('messageset', $name));
// Capture errors
$this->errors = $this->mergeErrors($this->errors, $record->getErrorBag(), $index);
// Attach relationhip to record
if ($result) $this->setRelationship($record, $name, $class, $index);
// Record failure
return $result;
}
|
[
"private",
"function",
"recurseRecord",
"(",
"$",
"method",
",",
"$",
"name",
",",
"array",
"$",
"data",
",",
"$",
"index",
"=",
"null",
")",
"{",
"// Get model and determine primary key column",
"$",
"class",
"=",
"Str",
"::",
"camel",
"(",
"$",
"name",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"{",
"$",
"class",
"}",
"(",
")",
"->",
"getModel",
"(",
")",
";",
"$",
"primaryKey",
"=",
"(",
"isset",
"(",
"$",
"model",
"->",
"primaryKey",
")",
")",
"?",
"$",
"model",
"->",
"primaryKey",
":",
"'id'",
";",
"$",
"key",
"=",
"array_get",
"(",
"$",
"data",
",",
"$",
"primaryKey",
")",
";",
"// Find record and perform action on it",
"$",
"record",
"=",
"$",
"model",
"->",
"findOrCreateRecord",
"(",
"$",
"key",
")",
";",
"$",
"result",
"=",
"$",
"record",
"->",
"recurse",
"(",
"$",
"method",
",",
"$",
"data",
",",
"$",
"this",
"->",
"getParameters",
"(",
"'ruleset'",
",",
"$",
"name",
")",
",",
"$",
"this",
"->",
"getParameters",
"(",
"'messageset'",
",",
"$",
"name",
")",
")",
";",
"// Capture errors",
"$",
"this",
"->",
"errors",
"=",
"$",
"this",
"->",
"mergeErrors",
"(",
"$",
"this",
"->",
"errors",
",",
"$",
"record",
"->",
"getErrorBag",
"(",
")",
",",
"$",
"index",
")",
";",
"// Attach relationhip to record",
"if",
"(",
"$",
"result",
")",
"$",
"this",
"->",
"setRelationship",
"(",
"$",
"record",
",",
"$",
"name",
",",
"$",
"class",
",",
"$",
"index",
")",
";",
"// Record failure",
"return",
"$",
"result",
";",
"}"
] |
Save or validate a single recursive record
@param string $method
@param string $name
@param array $data
@param integer|string|null $index
@return bool
|
[
"Save",
"or",
"validate",
"a",
"single",
"recursive",
"record"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L859-L880
|
231,594
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.removeInvalidAttributes
|
private function removeInvalidAttributes()
{
foreach ($this->getAttributes() as $attribute => $data)
{
if ( ! is_null($data) && ! is_scalar($data)) unset($this->{$attribute});
}
}
|
php
|
private function removeInvalidAttributes()
{
foreach ($this->getAttributes() as $attribute => $data)
{
if ( ! is_null($data) && ! is_scalar($data)) unset($this->{$attribute});
}
}
|
[
"private",
"function",
"removeInvalidAttributes",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"attribute",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"data",
")",
"&&",
"!",
"is_scalar",
"(",
"$",
"data",
")",
")",
"unset",
"(",
"$",
"this",
"->",
"{",
"$",
"attribute",
"}",
")",
";",
"}",
"}"
] |
Remove any fields which can't be submitted to the database
@return void
|
[
"Remove",
"any",
"fields",
"which",
"can",
"t",
"be",
"submitted",
"to",
"the",
"database"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L887-L893
|
231,595
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.saveAndDelete
|
public function saveAndDelete(array $data = [], array $rules = [], array $messages = [])
{
$result = $this->save($data, $rules, $messages);
if ( ! $result) return false;
return $this->delete();
}
|
php
|
public function saveAndDelete(array $data = [], array $rules = [], array $messages = [])
{
$result = $this->save($data, $rules, $messages);
if ( ! $result) return false;
return $this->delete();
}
|
[
"public",
"function",
"saveAndDelete",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"rules",
"=",
"[",
"]",
",",
"array",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"save",
"(",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"return",
"false",
";",
"return",
"$",
"this",
"->",
"delete",
"(",
")",
";",
"}"
] |
Save a record, then delete it if the save was successful
@param array $data
@param array $rules
@param array $messages
@return bool|null
|
[
"Save",
"a",
"record",
"then",
"delete",
"it",
"if",
"the",
"save",
"was",
"successful"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L919-L926
|
231,596
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.saveRecord
|
private function saveRecord(array $data = [], array $rules = [], array $messages = [])
{
$this->prepareRecord($data, $rules, $messages);
// Hash any hashable attributes
$this->hashHashable();
// Hand off to Model
return parent::save();
}
|
php
|
private function saveRecord(array $data = [], array $rules = [], array $messages = [])
{
$this->prepareRecord($data, $rules, $messages);
// Hash any hashable attributes
$this->hashHashable();
// Hand off to Model
return parent::save();
}
|
[
"private",
"function",
"saveRecord",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"rules",
"=",
"[",
"]",
",",
"array",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"prepareRecord",
"(",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
")",
";",
"// Hash any hashable attributes",
"$",
"this",
"->",
"hashHashable",
"(",
")",
";",
"// Hand off to Model",
"return",
"parent",
"::",
"save",
"(",
")",
";",
"}"
] |
Save a single record
@param array $data
@param array $rules
@param array $messages
@return bool
|
[
"Save",
"a",
"single",
"record"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L936-L945
|
231,597
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.saveRecursive
|
public function saveRecursive(array $data = [], array $rules = [], array $messages = [])
{
// If we're validating, do the whole record first to head off any problems
if ($this->validateBeforeSave && ! $this->validateRecursive($data, $rules, $messages)) return false;
return $this->recurse('save', $data, $rules, $messages);
}
|
php
|
public function saveRecursive(array $data = [], array $rules = [], array $messages = [])
{
// If we're validating, do the whole record first to head off any problems
if ($this->validateBeforeSave && ! $this->validateRecursive($data, $rules, $messages)) return false;
return $this->recurse('save', $data, $rules, $messages);
}
|
[
"public",
"function",
"saveRecursive",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"rules",
"=",
"[",
"]",
",",
"array",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"// If we're validating, do the whole record first to head off any problems",
"if",
"(",
"$",
"this",
"->",
"validateBeforeSave",
"&&",
"!",
"$",
"this",
"->",
"validateRecursive",
"(",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
")",
")",
"return",
"false",
";",
"return",
"$",
"this",
"->",
"recurse",
"(",
"'save'",
",",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
")",
";",
"}"
] |
Recursively save a record
@param array $data
@param array $rules
@param array $messages
@return bool
|
[
"Recursively",
"save",
"a",
"record"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L955-L961
|
231,598
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.setDataset
|
private function setDataset(array $data = [])
{
// If we don't have any data, use input if we're allowed
if ( ! count($data) && $this->allowHydrationFromInput) $data = Input::all();
$this->dataset = $data;
}
|
php
|
private function setDataset(array $data = [])
{
// If we don't have any data, use input if we're allowed
if ( ! count($data) && $this->allowHydrationFromInput) $data = Input::all();
$this->dataset = $data;
}
|
[
"private",
"function",
"setDataset",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"// If we don't have any data, use input if we're allowed",
"if",
"(",
"!",
"count",
"(",
"$",
"data",
")",
"&&",
"$",
"this",
"->",
"allowHydrationFromInput",
")",
"$",
"data",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"this",
"->",
"dataset",
"=",
"$",
"data",
";",
"}"
] |
Set relationship data
@param array $data
@return null
|
[
"Set",
"relationship",
"data"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L991-L997
|
231,599
|
sjdaws/vocal
|
src/Sjdaws/Vocal/Vocal.php
|
Vocal.setMessageset
|
private function setMessageset(array $messages = [])
{
// Passed messages rule, but we will use model messages if nothing has been passed
$this->messageset = $this->selectMessages($messages);
// If we don't have any rules, don't do anything because an error will never occur
if ( ! count($this->rules)) return;
// Determine file for validation messages
$file = $this->languageFolder . '/' . str_replace('\\', '/', get_called_class()) . '.';
$this->messages = [];
// Process each rule
foreach($this->rules as $field => $set)
{
foreach ($set as $rule)
{
// Remove parameters if we have them
list($type,) = $this->getRuleTypeAndParameters($rule);
// Generate a key using language file dot notation e.g. 'username.required'
$key = implode('.', [$field, $type]);
// Try to find a suitable error message
$message = $this->getMessage($file, $key);
if ($message) $this->messages[$key] = $message;
}
}
}
|
php
|
private function setMessageset(array $messages = [])
{
// Passed messages rule, but we will use model messages if nothing has been passed
$this->messageset = $this->selectMessages($messages);
// If we don't have any rules, don't do anything because an error will never occur
if ( ! count($this->rules)) return;
// Determine file for validation messages
$file = $this->languageFolder . '/' . str_replace('\\', '/', get_called_class()) . '.';
$this->messages = [];
// Process each rule
foreach($this->rules as $field => $set)
{
foreach ($set as $rule)
{
// Remove parameters if we have them
list($type,) = $this->getRuleTypeAndParameters($rule);
// Generate a key using language file dot notation e.g. 'username.required'
$key = implode('.', [$field, $type]);
// Try to find a suitable error message
$message = $this->getMessage($file, $key);
if ($message) $this->messages[$key] = $message;
}
}
}
|
[
"private",
"function",
"setMessageset",
"(",
"array",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"// Passed messages rule, but we will use model messages if nothing has been passed",
"$",
"this",
"->",
"messageset",
"=",
"$",
"this",
"->",
"selectMessages",
"(",
"$",
"messages",
")",
";",
"// If we don't have any rules, don't do anything because an error will never occur",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"rules",
")",
")",
"return",
";",
"// Determine file for validation messages",
"$",
"file",
"=",
"$",
"this",
"->",
"languageFolder",
".",
"'/'",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"get_called_class",
"(",
")",
")",
".",
"'.'",
";",
"$",
"this",
"->",
"messages",
"=",
"[",
"]",
";",
"// Process each rule",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"field",
"=>",
"$",
"set",
")",
"{",
"foreach",
"(",
"$",
"set",
"as",
"$",
"rule",
")",
"{",
"// Remove parameters if we have them",
"list",
"(",
"$",
"type",
",",
")",
"=",
"$",
"this",
"->",
"getRuleTypeAndParameters",
"(",
"$",
"rule",
")",
";",
"// Generate a key using language file dot notation e.g. 'username.required'",
"$",
"key",
"=",
"implode",
"(",
"'.'",
",",
"[",
"$",
"field",
",",
"$",
"type",
"]",
")",
";",
"// Try to find a suitable error message",
"$",
"message",
"=",
"$",
"this",
"->",
"getMessage",
"(",
"$",
"file",
",",
"$",
"key",
")",
";",
"if",
"(",
"$",
"message",
")",
"$",
"this",
"->",
"messages",
"[",
"$",
"key",
"]",
"=",
"$",
"message",
";",
"}",
"}",
"}"
] |
Set relationship messages
@param array $messages
@return null
|
[
"Set",
"relationship",
"messages"
] |
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
|
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L1005-L1034
|
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.