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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
223,000
|
awakenweb/livedocx
|
src/Templates/Local.php
|
Local.setName
|
public function setName($template_name , $path = null)
{
parent::setName($template_name);
$this->directory = $path;
}
|
php
|
public function setName($template_name , $path = null)
{
parent::setName($template_name);
$this->directory = $path;
}
|
[
"public",
"function",
"setName",
"(",
"$",
"template_name",
",",
"$",
"path",
"=",
"null",
")",
"{",
"parent",
"::",
"setName",
"(",
"$",
"template_name",
")",
";",
"$",
"this",
"->",
"directory",
"=",
"$",
"path",
";",
"}"
] |
Set the name of the template and its path
@param string $template_name
@param string $path
|
[
"Set",
"the",
"name",
"of",
"the",
"template",
"and",
"its",
"path"
] |
e83abb0df1c122ed1fed67d799fd3643ca134a59
|
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Local.php#L53-L57
|
223,001
|
awakenweb/livedocx
|
src/Templates/Local.php
|
Local.setAsActive
|
public function setAsActive()
{
try {
$templatecontent = $this->getBase64Contents();
$format = $this->getFormat();
} catch ( FileExistException $ex ) {
throw new FileExistException('Template file does not exist or is not readable' , $ex);
}
try {
$this->getSoapClient()->SetLocalTemplate([
'template' => $templatecontent ,
'format' => $format
]);
$this->isActive = true;
return $this;
} catch ( SoapException $ex ) {
throw new ActiveException('Error while setting the local template as the active template' , $ex);
}
}
|
php
|
public function setAsActive()
{
try {
$templatecontent = $this->getBase64Contents();
$format = $this->getFormat();
} catch ( FileExistException $ex ) {
throw new FileExistException('Template file does not exist or is not readable' , $ex);
}
try {
$this->getSoapClient()->SetLocalTemplate([
'template' => $templatecontent ,
'format' => $format
]);
$this->isActive = true;
return $this;
} catch ( SoapException $ex ) {
throw new ActiveException('Error while setting the local template as the active template' , $ex);
}
}
|
[
"public",
"function",
"setAsActive",
"(",
")",
"{",
"try",
"{",
"$",
"templatecontent",
"=",
"$",
"this",
"->",
"getBase64Contents",
"(",
")",
";",
"$",
"format",
"=",
"$",
"this",
"->",
"getFormat",
"(",
")",
";",
"}",
"catch",
"(",
"FileExistException",
"$",
"ex",
")",
"{",
"throw",
"new",
"FileExistException",
"(",
"'Template file does not exist or is not readable'",
",",
"$",
"ex",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"getSoapClient",
"(",
")",
"->",
"SetLocalTemplate",
"(",
"[",
"'template'",
"=>",
"$",
"templatecontent",
",",
"'format'",
"=>",
"$",
"format",
"]",
")",
";",
"$",
"this",
"->",
"isActive",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}",
"catch",
"(",
"SoapException",
"$",
"ex",
")",
"{",
"throw",
"new",
"ActiveException",
"(",
"'Error while setting the local template as the active template'",
",",
"$",
"ex",
")",
";",
"}",
"}"
] |
Set the local template as active and upload it to be used when generating the final
document
@return Local
@throws FileExistException
@throws ActiveException
|
[
"Set",
"the",
"local",
"template",
"as",
"active",
"and",
"upload",
"it",
"to",
"be",
"used",
"when",
"generating",
"the",
"final",
"document"
] |
e83abb0df1c122ed1fed67d799fd3643ca134a59
|
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Local.php#L68-L88
|
223,002
|
awakenweb/livedocx
|
src/Templates/Local.php
|
Local.upload
|
public function upload()
{
try {
$templatecontent = $this->getBase64Contents();
$filename = basename($this->getName());
} catch ( FileExistException $ex ) {
throw new FileExistException('Template file does not exist or is not readable' , $ex);
}
try {
$this->getSoapClient()->UploadTemplate([
'template' => $templatecontent ,
'filename' => $filename ,
]);
$remoteTemplate = new Remote($this->getSoapClient());
$remoteTemplate->setName($this->getName());
return $remoteTemplate;
} catch ( SoapException $ex ) {
throw new UploadException('Error while uploading the template' , $ex);
}
}
|
php
|
public function upload()
{
try {
$templatecontent = $this->getBase64Contents();
$filename = basename($this->getName());
} catch ( FileExistException $ex ) {
throw new FileExistException('Template file does not exist or is not readable' , $ex);
}
try {
$this->getSoapClient()->UploadTemplate([
'template' => $templatecontent ,
'filename' => $filename ,
]);
$remoteTemplate = new Remote($this->getSoapClient());
$remoteTemplate->setName($this->getName());
return $remoteTemplate;
} catch ( SoapException $ex ) {
throw new UploadException('Error while uploading the template' , $ex);
}
}
|
[
"public",
"function",
"upload",
"(",
")",
"{",
"try",
"{",
"$",
"templatecontent",
"=",
"$",
"this",
"->",
"getBase64Contents",
"(",
")",
";",
"$",
"filename",
"=",
"basename",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"FileExistException",
"$",
"ex",
")",
"{",
"throw",
"new",
"FileExistException",
"(",
"'Template file does not exist or is not readable'",
",",
"$",
"ex",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"getSoapClient",
"(",
")",
"->",
"UploadTemplate",
"(",
"[",
"'template'",
"=>",
"$",
"templatecontent",
",",
"'filename'",
"=>",
"$",
"filename",
",",
"]",
")",
";",
"$",
"remoteTemplate",
"=",
"new",
"Remote",
"(",
"$",
"this",
"->",
"getSoapClient",
"(",
")",
")",
";",
"$",
"remoteTemplate",
"->",
"setName",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"return",
"$",
"remoteTemplate",
";",
"}",
"catch",
"(",
"SoapException",
"$",
"ex",
")",
"{",
"throw",
"new",
"UploadException",
"(",
"'Error while uploading the template'",
",",
"$",
"ex",
")",
";",
"}",
"}"
] |
Upload the local template to Livedocx service and return a new instance of corresponding
remote template
@return Remote
@throws FileExistException
@throws UploadException
|
[
"Upload",
"the",
"local",
"template",
"to",
"Livedocx",
"service",
"and",
"return",
"a",
"new",
"instance",
"of",
"corresponding",
"remote",
"template"
] |
e83abb0df1c122ed1fed67d799fd3643ca134a59
|
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Local.php#L99-L121
|
223,003
|
awakenweb/livedocx
|
src/Templates/Local.php
|
Local.getContents
|
public function getContents()
{
try {
$fileObj = new SplFileObject($this->getName(true) , 'r');
} catch ( RuntimeException $ex ) {
throw new FileExistException('The provided file is not readable' , $ex);
}
return file_get_contents($fileObj->getPathname());
}
|
php
|
public function getContents()
{
try {
$fileObj = new SplFileObject($this->getName(true) , 'r');
} catch ( RuntimeException $ex ) {
throw new FileExistException('The provided file is not readable' , $ex);
}
return file_get_contents($fileObj->getPathname());
}
|
[
"public",
"function",
"getContents",
"(",
")",
"{",
"try",
"{",
"$",
"fileObj",
"=",
"new",
"SplFileObject",
"(",
"$",
"this",
"->",
"getName",
"(",
"true",
")",
",",
"'r'",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"ex",
")",
"{",
"throw",
"new",
"FileExistException",
"(",
"'The provided file is not readable'",
",",
"$",
"ex",
")",
";",
"}",
"return",
"file_get_contents",
"(",
"$",
"fileObj",
"->",
"getPathname",
"(",
")",
")",
";",
"}"
] |
Return the contents of the whole template file
@return string
@throws FileExistException
|
[
"Return",
"the",
"contents",
"of",
"the",
"whole",
"template",
"file"
] |
e83abb0df1c122ed1fed67d799fd3643ca134a59
|
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Local.php#L148-L157
|
223,004
|
awakenweb/livedocx
|
src/Templates/Local.php
|
Local.getFormat
|
public function getFormat()
{
try {
$fileObj = new SplFileObject($this->getName(true) , 'r');
} catch ( RuntimeException $ex ) {
throw new FileExistException('The provided file is not readable' , $ex);
}
return $fileObj->getExtension();
}
|
php
|
public function getFormat()
{
try {
$fileObj = new SplFileObject($this->getName(true) , 'r');
} catch ( RuntimeException $ex ) {
throw new FileExistException('The provided file is not readable' , $ex);
}
return $fileObj->getExtension();
}
|
[
"public",
"function",
"getFormat",
"(",
")",
"{",
"try",
"{",
"$",
"fileObj",
"=",
"new",
"SplFileObject",
"(",
"$",
"this",
"->",
"getName",
"(",
"true",
")",
",",
"'r'",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"ex",
")",
"{",
"throw",
"new",
"FileExistException",
"(",
"'The provided file is not readable'",
",",
"$",
"ex",
")",
";",
"}",
"return",
"$",
"fileObj",
"->",
"getExtension",
"(",
")",
";",
"}"
] |
Return the format of the file
@return string
@throws FileExistException
|
[
"Return",
"the",
"format",
"of",
"the",
"file"
] |
e83abb0df1c122ed1fed67d799fd3643ca134a59
|
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Local.php#L166-L175
|
223,005
|
mongator/mongator
|
src/Mongator/Id/IdGeneratorContainer.php
|
IdGeneratorContainer.add
|
public static function add($name, $class)
{
if (static::has($name)) {
throw new \InvalidArgumentException(sprintf('The id generator "%s" already exists.', $name));
}
$r = new \ReflectionClass($class);
if (!$r->isSubclassOf('Mongator\Id\BaseIdGenerator')) {
throw new \InvalidArgumentException(sprintf('The class "%s" is not a subclass of Mongator\Id\BaseIdGenerator.', $class));
}
static::$map[$name] = $class;
}
|
php
|
public static function add($name, $class)
{
if (static::has($name)) {
throw new \InvalidArgumentException(sprintf('The id generator "%s" already exists.', $name));
}
$r = new \ReflectionClass($class);
if (!$r->isSubclassOf('Mongator\Id\BaseIdGenerator')) {
throw new \InvalidArgumentException(sprintf('The class "%s" is not a subclass of Mongator\Id\BaseIdGenerator.', $class));
}
static::$map[$name] = $class;
}
|
[
"public",
"static",
"function",
"add",
"(",
"$",
"name",
",",
"$",
"class",
")",
"{",
"if",
"(",
"static",
"::",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The id generator \"%s\" already exists.'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"r",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"$",
"r",
"->",
"isSubclassOf",
"(",
"'Mongator\\Id\\BaseIdGenerator'",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The class \"%s\" is not a subclass of Mongator\\Id\\BaseIdGenerator.'",
",",
"$",
"class",
")",
")",
";",
"}",
"static",
"::",
"$",
"map",
"[",
"$",
"name",
"]",
"=",
"$",
"class",
";",
"}"
] |
Add an id generator.
@param string $name The name.
@param string $class The class.
@throws \InvalidArgumentException If the id generator already exists.
@throws \InvalidArgumentException If the class is not a subclass of Mongator\Id\IdGenerator.
|
[
"Add",
"an",
"id",
"generator",
"."
] |
c29b94989677597a84dc5d3907224bf608967c26
|
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Id/IdGeneratorContainer.php#L50-L62
|
223,006
|
mongator/mongator
|
src/Mongator/Id/IdGeneratorContainer.php
|
IdGeneratorContainer.get
|
public static function get($name)
{
if (!isset(static::$idGenerators[$name])) {
if (!static::has($name)) {
throw new \InvalidArgumentException(sprintf('The id generator "%s" does not exists.', $name));
}
static::$idGenerators[$name] = new static::$map[$name];
}
return static::$idGenerators[$name];
}
|
php
|
public static function get($name)
{
if (!isset(static::$idGenerators[$name])) {
if (!static::has($name)) {
throw new \InvalidArgumentException(sprintf('The id generator "%s" does not exists.', $name));
}
static::$idGenerators[$name] = new static::$map[$name];
}
return static::$idGenerators[$name];
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"idGenerators",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The id generator \"%s\" does not exists.'",
",",
"$",
"name",
")",
")",
";",
"}",
"static",
"::",
"$",
"idGenerators",
"[",
"$",
"name",
"]",
"=",
"new",
"static",
"::",
"$",
"map",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"static",
"::",
"$",
"idGenerators",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns an id generator.
@param string $name The name.
@return \Mongator\Id\BaseIdGenerator The id generator.
@throws \InvalidArgumentException If the id generator does not exists.
|
[
"Returns",
"an",
"id",
"generator",
"."
] |
c29b94989677597a84dc5d3907224bf608967c26
|
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Id/IdGeneratorContainer.php#L73-L84
|
223,007
|
mongator/mongator
|
src/Mongator/Id/IdGeneratorContainer.php
|
IdGeneratorContainer.remove
|
public static function remove($name)
{
if (!static::has($name)) {
throw new \InvalidArgumentException(sprintf('The id generator "%s" does not exists.', $name));
}
unset(static::$map[$name], static::$idGenerators[$name]);
}
|
php
|
public static function remove($name)
{
if (!static::has($name)) {
throw new \InvalidArgumentException(sprintf('The id generator "%s" does not exists.', $name));
}
unset(static::$map[$name], static::$idGenerators[$name]);
}
|
[
"public",
"static",
"function",
"remove",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The id generator \"%s\" does not exists.'",
",",
"$",
"name",
")",
")",
";",
"}",
"unset",
"(",
"static",
"::",
"$",
"map",
"[",
"$",
"name",
"]",
",",
"static",
"::",
"$",
"idGenerators",
"[",
"$",
"name",
"]",
")",
";",
"}"
] |
Remove an id generator.
@param string $name The name.
@throws \InvalidArgumentException If the id generator does not exists.
|
[
"Remove",
"an",
"id",
"generator",
"."
] |
c29b94989677597a84dc5d3907224bf608967c26
|
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Id/IdGeneratorContainer.php#L93-L100
|
223,008
|
mongator/mongator
|
src/Mongator/Document/Document.php
|
Document.save
|
public function save(array $options = array())
{
if ($this->isNew()) {
$this->queryFields = array();
$batchInsertOptions = $options;
$updateOptions = array();
} else {
$batchInsertOptions = array();
$updateOptions = $options;
}
$this->getRepository()->save($this, $batchInsertOptions, $updateOptions);
return $this;
}
|
php
|
public function save(array $options = array())
{
if ($this->isNew()) {
$this->queryFields = array();
$batchInsertOptions = $options;
$updateOptions = array();
} else {
$batchInsertOptions = array();
$updateOptions = $options;
}
$this->getRepository()->save($this, $batchInsertOptions, $updateOptions);
return $this;
}
|
[
"public",
"function",
"save",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"this",
"->",
"queryFields",
"=",
"array",
"(",
")",
";",
"$",
"batchInsertOptions",
"=",
"$",
"options",
";",
"$",
"updateOptions",
"=",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"batchInsertOptions",
"=",
"array",
"(",
")",
";",
"$",
"updateOptions",
"=",
"$",
"options",
";",
"}",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"save",
"(",
"$",
"this",
",",
"$",
"batchInsertOptions",
",",
"$",
"updateOptions",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Save the document.
@param array $options The options for the batch insert or update operation, it depends on if the document is new or not (optional).
@return \Mongator\Document\Document The document (fluent interface).
@api
|
[
"Save",
"the",
"document",
"."
] |
c29b94989677597a84dc5d3907224bf608967c26
|
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Document/Document.php#L122-L136
|
223,009
|
mongator/mongator
|
src/Mongator/Document/Document.php
|
Document.setQueryFields
|
protected function setQueryFields(array $fields)
{
$this->queryFields = array();
foreach ($fields as $field => $included) {
if ($included) $this->queryFields[$field] = 1;
}
}
|
php
|
protected function setQueryFields(array $fields)
{
$this->queryFields = array();
foreach ($fields as $field => $included) {
if ($included) $this->queryFields[$field] = 1;
}
}
|
[
"protected",
"function",
"setQueryFields",
"(",
"array",
"$",
"fields",
")",
"{",
"$",
"this",
"->",
"queryFields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
"=>",
"$",
"included",
")",
"{",
"if",
"(",
"$",
"included",
")",
"$",
"this",
"->",
"queryFields",
"[",
"$",
"field",
"]",
"=",
"1",
";",
"}",
"}"
] |
Set the fields that were included in the query used to populate the object.
@param array $fields an associative array($f1 => 1, $f2 => 1, ...)
|
[
"Set",
"the",
"fields",
"that",
"were",
"included",
"in",
"the",
"query",
"used",
"to",
"populate",
"the",
"object",
"."
] |
c29b94989677597a84dc5d3907224bf608967c26
|
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Document/Document.php#L238-L244
|
223,010
|
thephpleague/flysystem-phpcr
|
src/PhpcrAdapter.php
|
PhpcrAdapter.applyPathPrefix
|
public function applyPathPrefix($path)
{
$path = ltrim($path, '/');
if (strlen($path) === 0) {
return rtrim($this->getPathPrefix(), '/');
}
return $this->getPathPrefix() . $path;
}
|
php
|
public function applyPathPrefix($path)
{
$path = ltrim($path, '/');
if (strlen($path) === 0) {
return rtrim($this->getPathPrefix(), '/');
}
return $this->getPathPrefix() . $path;
}
|
[
"public",
"function",
"applyPathPrefix",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
"===",
"0",
")",
"{",
"return",
"rtrim",
"(",
"$",
"this",
"->",
"getPathPrefix",
"(",
")",
",",
"'/'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getPathPrefix",
"(",
")",
".",
"$",
"path",
";",
"}"
] |
Prefix a path.
@param string $path
@return string prefixed path
|
[
"Prefix",
"a",
"path",
"."
] |
60f51d1c67943fdb38f86eac0ff2d9dad9fe0b55
|
https://github.com/thephpleague/flysystem-phpcr/blob/60f51d1c67943fdb38f86eac0ff2d9dad9fe0b55/src/PhpcrAdapter.php#L77-L85
|
223,011
|
thephpleague/flysystem-phpcr
|
src/PhpcrAdapter.php
|
PhpcrAdapter.getFolderNode
|
private function getFolderNode($path, $create = false)
{
$location = $this->applyPathPrefix($path);
if (!$create && !$this->session->nodeExists($location)) {
// trigger the phpcr exception rather than trying to create parent nodes.
return $this->session->getNode($location);
}
$folders = array();
while (!$this->session->nodeExists($location)) {
$folders[] = PathHelper::getNodeName($location);
$location = PathHelper::getParentPath($location);
}
$node = $this->session->getNode($location);
while (null !== $folder = array_pop($folders)) {
$node = $node->addNode($folder, 'nt:folder');
}
if (!$node->isNodeType('nt:folder')) {
throw new \LogicException($path.' is not a folder but '.$node->getPrimaryNodeType()->getName());
}
if ($create) {
$this->session->save();
}
return $node;
}
|
php
|
private function getFolderNode($path, $create = false)
{
$location = $this->applyPathPrefix($path);
if (!$create && !$this->session->nodeExists($location)) {
// trigger the phpcr exception rather than trying to create parent nodes.
return $this->session->getNode($location);
}
$folders = array();
while (!$this->session->nodeExists($location)) {
$folders[] = PathHelper::getNodeName($location);
$location = PathHelper::getParentPath($location);
}
$node = $this->session->getNode($location);
while (null !== $folder = array_pop($folders)) {
$node = $node->addNode($folder, 'nt:folder');
}
if (!$node->isNodeType('nt:folder')) {
throw new \LogicException($path.' is not a folder but '.$node->getPrimaryNodeType()->getName());
}
if ($create) {
$this->session->save();
}
return $node;
}
|
[
"private",
"function",
"getFolderNode",
"(",
"$",
"path",
",",
"$",
"create",
"=",
"false",
")",
"{",
"$",
"location",
"=",
"$",
"this",
"->",
"applyPathPrefix",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"create",
"&&",
"!",
"$",
"this",
"->",
"session",
"->",
"nodeExists",
"(",
"$",
"location",
")",
")",
"{",
"// trigger the phpcr exception rather than trying to create parent nodes.",
"return",
"$",
"this",
"->",
"session",
"->",
"getNode",
"(",
"$",
"location",
")",
";",
"}",
"$",
"folders",
"=",
"array",
"(",
")",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"session",
"->",
"nodeExists",
"(",
"$",
"location",
")",
")",
"{",
"$",
"folders",
"[",
"]",
"=",
"PathHelper",
"::",
"getNodeName",
"(",
"$",
"location",
")",
";",
"$",
"location",
"=",
"PathHelper",
"::",
"getParentPath",
"(",
"$",
"location",
")",
";",
"}",
"$",
"node",
"=",
"$",
"this",
"->",
"session",
"->",
"getNode",
"(",
"$",
"location",
")",
";",
"while",
"(",
"null",
"!==",
"$",
"folder",
"=",
"array_pop",
"(",
"$",
"folders",
")",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"addNode",
"(",
"$",
"folder",
",",
"'nt:folder'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"node",
"->",
"isNodeType",
"(",
"'nt:folder'",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"$",
"path",
".",
"' is not a folder but '",
".",
"$",
"node",
"->",
"getPrimaryNodeType",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"create",
")",
"{",
"$",
"this",
"->",
"session",
"->",
"save",
"(",
")",
";",
"}",
"return",
"$",
"node",
";",
"}"
] |
Ensure the directory exists and try to create it if it does not exist.
@param string $path path relative to the $root.
@param boolean $create Whether to create the folder if not existing.
@return NodeInterface The node at $root/$path.
|
[
"Ensure",
"the",
"directory",
"exists",
"and",
"try",
"to",
"create",
"it",
"if",
"it",
"does",
"not",
"exist",
"."
] |
60f51d1c67943fdb38f86eac0ff2d9dad9fe0b55
|
https://github.com/thephpleague/flysystem-phpcr/blob/60f51d1c67943fdb38f86eac0ff2d9dad9fe0b55/src/PhpcrAdapter.php#L95-L122
|
223,012
|
mwr/magedeploy2
|
src/Robo/RoboFile.php
|
RoboFile.deploy
|
public function deploy(
$stage,
$branchOrTag,
$revision = '',
$opts = [
self::OPT_REINSTALL_PROJECT => false,
self::OPT_DROP_VENDOR => false,
self::OPT_DROP_DATABASE => false,
self::OPT_DEPLOYER_PARALLEL => false,
]
) {
$this->startTimer();
$this->deployMagentoSetup($branchOrTag, $revision, $opts);
$this->deployArtifactsGenerate();
$this->deployDeploy($stage, $branchOrTag, $opts);
$this->stopTimer();
$this->printRuntime(__FUNCTION__);
}
|
php
|
public function deploy(
$stage,
$branchOrTag,
$revision = '',
$opts = [
self::OPT_REINSTALL_PROJECT => false,
self::OPT_DROP_VENDOR => false,
self::OPT_DROP_DATABASE => false,
self::OPT_DEPLOYER_PARALLEL => false,
]
) {
$this->startTimer();
$this->deployMagentoSetup($branchOrTag, $revision, $opts);
$this->deployArtifactsGenerate();
$this->deployDeploy($stage, $branchOrTag, $opts);
$this->stopTimer();
$this->printRuntime(__FUNCTION__);
}
|
[
"public",
"function",
"deploy",
"(",
"$",
"stage",
",",
"$",
"branchOrTag",
",",
"$",
"revision",
"=",
"''",
",",
"$",
"opts",
"=",
"[",
"self",
"::",
"OPT_REINSTALL_PROJECT",
"=>",
"false",
",",
"self",
"::",
"OPT_DROP_VENDOR",
"=>",
"false",
",",
"self",
"::",
"OPT_DROP_DATABASE",
"=>",
"false",
",",
"self",
"::",
"OPT_DEPLOYER_PARALLEL",
"=>",
"false",
",",
"]",
")",
"{",
"$",
"this",
"->",
"startTimer",
"(",
")",
";",
"$",
"this",
"->",
"deployMagentoSetup",
"(",
"$",
"branchOrTag",
",",
"$",
"revision",
",",
"$",
"opts",
")",
";",
"$",
"this",
"->",
"deployArtifactsGenerate",
"(",
")",
";",
"$",
"this",
"->",
"deployDeploy",
"(",
"$",
"stage",
",",
"$",
"branchOrTag",
",",
"$",
"opts",
")",
";",
"$",
"this",
"->",
"stopTimer",
"(",
")",
";",
"$",
"this",
"->",
"printRuntime",
"(",
"__FUNCTION__",
")",
";",
"}"
] |
command to trigger deployment process completly
@param string $stage Environment to deploy to (by default: local/staging/production)
@param string $branchOrTag Branch or Tag to deploy
@param string $revision
@param array $opts
@option $reinstall-project Reinstall project by deleting env.php file and running setup:install
@option $drop-vendor Remove the vendor directory
@option $drop-database Drop the Database
@option $parallel Parallel deployment mode for deployer
|
[
"command",
"to",
"trigger",
"deployment",
"process",
"completly"
] |
8252f61ee4810f5aa2448090a51cb2d3916d6421
|
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboFile.php#L35-L56
|
223,013
|
mwr/magedeploy2
|
src/Robo/RoboFile.php
|
RoboFile.deployArtifactsGenerate
|
public function deployArtifactsGenerate()
{
$this->startTimer();
$this->printStageInfo('GENERATE ASSETS');
$this->printTaskInfo('SET PRODUCTION MODE');
$this->taskMagentoSetProductionMode()->run();
$this->printTaskInfo('MAGENTO SETUP DI COMPILE');
$this->taskMagentoSetupDiCompile()->run();
$this->printTaskInfo('COMPOSER DUMP AUTOLOAD');
$this->taskMagentoDumpAutoload()->run();
$this->printTaskInfo('MAGENTO SETUP STATIC CONTENT DEPLOY');
$this->taskMagentoSetupStaticContentDeploy()->run();
$this->printTaskInfo('GENERATE ARTIFACTS');
$this->taskArtifactCreatePackages()->run();
$this->stopTimer();
$this->printRuntime(__FUNCTION__);
}
|
php
|
public function deployArtifactsGenerate()
{
$this->startTimer();
$this->printStageInfo('GENERATE ASSETS');
$this->printTaskInfo('SET PRODUCTION MODE');
$this->taskMagentoSetProductionMode()->run();
$this->printTaskInfo('MAGENTO SETUP DI COMPILE');
$this->taskMagentoSetupDiCompile()->run();
$this->printTaskInfo('COMPOSER DUMP AUTOLOAD');
$this->taskMagentoDumpAutoload()->run();
$this->printTaskInfo('MAGENTO SETUP STATIC CONTENT DEPLOY');
$this->taskMagentoSetupStaticContentDeploy()->run();
$this->printTaskInfo('GENERATE ARTIFACTS');
$this->taskArtifactCreatePackages()->run();
$this->stopTimer();
$this->printRuntime(__FUNCTION__);
}
|
[
"public",
"function",
"deployArtifactsGenerate",
"(",
")",
"{",
"$",
"this",
"->",
"startTimer",
"(",
")",
";",
"$",
"this",
"->",
"printStageInfo",
"(",
"'GENERATE ASSETS'",
")",
";",
"$",
"this",
"->",
"printTaskInfo",
"(",
"'SET PRODUCTION MODE'",
")",
";",
"$",
"this",
"->",
"taskMagentoSetProductionMode",
"(",
")",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"printTaskInfo",
"(",
"'MAGENTO SETUP DI COMPILE'",
")",
";",
"$",
"this",
"->",
"taskMagentoSetupDiCompile",
"(",
")",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"printTaskInfo",
"(",
"'COMPOSER DUMP AUTOLOAD'",
")",
";",
"$",
"this",
"->",
"taskMagentoDumpAutoload",
"(",
")",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"printTaskInfo",
"(",
"'MAGENTO SETUP STATIC CONTENT DEPLOY'",
")",
";",
"$",
"this",
"->",
"taskMagentoSetupStaticContentDeploy",
"(",
")",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"printTaskInfo",
"(",
"'GENERATE ARTIFACTS'",
")",
";",
"$",
"this",
"->",
"taskArtifactCreatePackages",
"(",
")",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"stopTimer",
"(",
")",
";",
"$",
"this",
"->",
"printRuntime",
"(",
"__FUNCTION__",
")",
";",
"}"
] |
STAGE command that generates all artifacts for the deploy
|
[
"STAGE",
"command",
"that",
"generates",
"all",
"artifacts",
"for",
"the",
"deploy"
] |
8252f61ee4810f5aa2448090a51cb2d3916d6421
|
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboFile.php#L126-L149
|
223,014
|
mwr/magedeploy2
|
src/Robo/RoboFile.php
|
RoboFile.deployDeploy
|
public function deployDeploy(
$stage,
$branchOrTag,
$opts = [
self::OPT_DEPLOYER_PARALLEL => false,
]
) {
// use string parallel due as robo always submits this string for both triggers
$parallelMode = $opts['parallel'];
$this->startTimer();
$this->printStageInfo('DEPLOYER DEPLOY');
$task = $this->taskDeployerDeploy($stage, $branchOrTag);
if ($parallelMode === true) {
$task->parallel();
}
$task->run();
$this->stopTimer();
$this->printRuntime(__FUNCTION__);
}
|
php
|
public function deployDeploy(
$stage,
$branchOrTag,
$opts = [
self::OPT_DEPLOYER_PARALLEL => false,
]
) {
// use string parallel due as robo always submits this string for both triggers
$parallelMode = $opts['parallel'];
$this->startTimer();
$this->printStageInfo('DEPLOYER DEPLOY');
$task = $this->taskDeployerDeploy($stage, $branchOrTag);
if ($parallelMode === true) {
$task->parallel();
}
$task->run();
$this->stopTimer();
$this->printRuntime(__FUNCTION__);
}
|
[
"public",
"function",
"deployDeploy",
"(",
"$",
"stage",
",",
"$",
"branchOrTag",
",",
"$",
"opts",
"=",
"[",
"self",
"::",
"OPT_DEPLOYER_PARALLEL",
"=>",
"false",
",",
"]",
")",
"{",
"// use string parallel due as robo always submits this string for both triggers",
"$",
"parallelMode",
"=",
"$",
"opts",
"[",
"'parallel'",
"]",
";",
"$",
"this",
"->",
"startTimer",
"(",
")",
";",
"$",
"this",
"->",
"printStageInfo",
"(",
"'DEPLOYER DEPLOY'",
")",
";",
"$",
"task",
"=",
"$",
"this",
"->",
"taskDeployerDeploy",
"(",
"$",
"stage",
",",
"$",
"branchOrTag",
")",
";",
"if",
"(",
"$",
"parallelMode",
"===",
"true",
")",
"{",
"$",
"task",
"->",
"parallel",
"(",
")",
";",
"}",
"$",
"task",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"stopTimer",
"(",
")",
";",
"$",
"this",
"->",
"printRuntime",
"(",
"__FUNCTION__",
")",
";",
"}"
] |
STAGE command triggering release to server using deployer
@param string $stage Environment to deploy to (by default: local/staging/production)
@param string $branchOrTag Branch or Tag to deploy
@param array $opts
|
[
"STAGE",
"command",
"triggering",
"release",
"to",
"server",
"using",
"deployer"
] |
8252f61ee4810f5aa2448090a51cb2d3916d6421
|
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboFile.php#L158-L181
|
223,015
|
activecollab/activecollab-sdk
|
ActiveCollab/Client.php
|
Client.call
|
static function call($command, $additional_command_params = null, $post_params = null, $attachments = null) {
if(empty(self::$url) || empty(self::$key) || empty(self::$connector)) {
throw new WrapperNotInitialized();
} // if
// ---------------------------------------------------
// Prepare command URl
// ---------------------------------------------------
$data = is_array($additional_command_params) && count($additional_command_params) ? $additional_command_params : array();
$data['path_info'] = $command;
$data['auth_api_token'] = self::$key;
$data['format'] = 'json';
$command_url = self::$url . '?' . http_build_query($data);
// ---------------------------------------------------
// Prepare attachments
// ---------------------------------------------------
if(empty($attachments)) {
$file_params = null;
} else {
$file_params = array();
$counter = 1;
foreach($attachments as $attachment) {
if(is_readable($attachment)) {
$file_params['attachment_' . $counter++] = $attachment;
} else {
throw new FileNotReadable($attachment);
} // if
} // foreach
} // if
// ---------------------------------------------------
// Prepare POST variables
// ---------------------------------------------------
if(empty($post_params)) {
$post_params = array();
} else {
if(!isset($post_params['submitted']) || $post_params['submitted'] != 'submitted') {
$post_params['submitted'] = 'submitted';
} // if
foreach($post_params as $post_param => $post_param_value) {
if(is_array($post_param_value)) {
foreach($post_param_value as $k => $v) {
$post_params["{$post_param}[{$k}]"] = $v;
} // foreach
unset($post_params[$post_param]);
} // if
} // foreach
} // if
// ---------------------------------------------------
// Make the call and decode the result
// ---------------------------------------------------
if(empty($post_params) && empty($file_params)) {
$response = self::$connector->get($command_url);
} else {
$response = self::$connector->post($command_url, $post_params, $file_params);
} // if
return json_decode($response, true);
}
|
php
|
static function call($command, $additional_command_params = null, $post_params = null, $attachments = null) {
if(empty(self::$url) || empty(self::$key) || empty(self::$connector)) {
throw new WrapperNotInitialized();
} // if
// ---------------------------------------------------
// Prepare command URl
// ---------------------------------------------------
$data = is_array($additional_command_params) && count($additional_command_params) ? $additional_command_params : array();
$data['path_info'] = $command;
$data['auth_api_token'] = self::$key;
$data['format'] = 'json';
$command_url = self::$url . '?' . http_build_query($data);
// ---------------------------------------------------
// Prepare attachments
// ---------------------------------------------------
if(empty($attachments)) {
$file_params = null;
} else {
$file_params = array();
$counter = 1;
foreach($attachments as $attachment) {
if(is_readable($attachment)) {
$file_params['attachment_' . $counter++] = $attachment;
} else {
throw new FileNotReadable($attachment);
} // if
} // foreach
} // if
// ---------------------------------------------------
// Prepare POST variables
// ---------------------------------------------------
if(empty($post_params)) {
$post_params = array();
} else {
if(!isset($post_params['submitted']) || $post_params['submitted'] != 'submitted') {
$post_params['submitted'] = 'submitted';
} // if
foreach($post_params as $post_param => $post_param_value) {
if(is_array($post_param_value)) {
foreach($post_param_value as $k => $v) {
$post_params["{$post_param}[{$k}]"] = $v;
} // foreach
unset($post_params[$post_param]);
} // if
} // foreach
} // if
// ---------------------------------------------------
// Make the call and decode the result
// ---------------------------------------------------
if(empty($post_params) && empty($file_params)) {
$response = self::$connector->get($command_url);
} else {
$response = self::$connector->post($command_url, $post_params, $file_params);
} // if
return json_decode($response, true);
}
|
[
"static",
"function",
"call",
"(",
"$",
"command",
",",
"$",
"additional_command_params",
"=",
"null",
",",
"$",
"post_params",
"=",
"null",
",",
"$",
"attachments",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"url",
")",
"||",
"empty",
"(",
"self",
"::",
"$",
"key",
")",
"||",
"empty",
"(",
"self",
"::",
"$",
"connector",
")",
")",
"{",
"throw",
"new",
"WrapperNotInitialized",
"(",
")",
";",
"}",
"// if",
"// ---------------------------------------------------",
"// Prepare command URl",
"// ---------------------------------------------------",
"$",
"data",
"=",
"is_array",
"(",
"$",
"additional_command_params",
")",
"&&",
"count",
"(",
"$",
"additional_command_params",
")",
"?",
"$",
"additional_command_params",
":",
"array",
"(",
")",
";",
"$",
"data",
"[",
"'path_info'",
"]",
"=",
"$",
"command",
";",
"$",
"data",
"[",
"'auth_api_token'",
"]",
"=",
"self",
"::",
"$",
"key",
";",
"$",
"data",
"[",
"'format'",
"]",
"=",
"'json'",
";",
"$",
"command_url",
"=",
"self",
"::",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"data",
")",
";",
"// ---------------------------------------------------",
"// Prepare attachments",
"// ---------------------------------------------------",
"if",
"(",
"empty",
"(",
"$",
"attachments",
")",
")",
"{",
"$",
"file_params",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"file_params",
"=",
"array",
"(",
")",
";",
"$",
"counter",
"=",
"1",
";",
"foreach",
"(",
"$",
"attachments",
"as",
"$",
"attachment",
")",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"attachment",
")",
")",
"{",
"$",
"file_params",
"[",
"'attachment_'",
".",
"$",
"counter",
"++",
"]",
"=",
"$",
"attachment",
";",
"}",
"else",
"{",
"throw",
"new",
"FileNotReadable",
"(",
"$",
"attachment",
")",
";",
"}",
"// if",
"}",
"// foreach",
"}",
"// if",
"// ---------------------------------------------------",
"// Prepare POST variables",
"// ---------------------------------------------------",
"if",
"(",
"empty",
"(",
"$",
"post_params",
")",
")",
"{",
"$",
"post_params",
"=",
"array",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"post_params",
"[",
"'submitted'",
"]",
")",
"||",
"$",
"post_params",
"[",
"'submitted'",
"]",
"!=",
"'submitted'",
")",
"{",
"$",
"post_params",
"[",
"'submitted'",
"]",
"=",
"'submitted'",
";",
"}",
"// if",
"foreach",
"(",
"$",
"post_params",
"as",
"$",
"post_param",
"=>",
"$",
"post_param_value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"post_param_value",
")",
")",
"{",
"foreach",
"(",
"$",
"post_param_value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"post_params",
"[",
"\"{$post_param}[{$k}]\"",
"]",
"=",
"$",
"v",
";",
"}",
"// foreach",
"unset",
"(",
"$",
"post_params",
"[",
"$",
"post_param",
"]",
")",
";",
"}",
"// if",
"}",
"// foreach",
"}",
"// if",
"// ---------------------------------------------------",
"// Make the call and decode the result",
"// ---------------------------------------------------",
"if",
"(",
"empty",
"(",
"$",
"post_params",
")",
"&&",
"empty",
"(",
"$",
"file_params",
")",
")",
"{",
"$",
"response",
"=",
"self",
"::",
"$",
"connector",
"->",
"get",
"(",
"$",
"command_url",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"self",
"::",
"$",
"connector",
"->",
"post",
"(",
"$",
"command_url",
",",
"$",
"post_params",
",",
"$",
"file_params",
")",
";",
"}",
"// if",
"return",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"}"
] |
Prepare and execute API command
@param string $command
@param array $additional_command_params
@param array $post_params
@param array $attachments
@return mixed
@throws Exceptions\WrapperNotInitialized
@throws Exceptions\FileNotReadable
|
[
"Prepare",
"and",
"execute",
"API",
"command"
] |
26604ab5e07402c584998371969ebfcbf5ea358e
|
https://github.com/activecollab/activecollab-sdk/blob/26604ab5e07402c584998371969ebfcbf5ea358e/ActiveCollab/Client.php#L144-L213
|
223,016
|
riesenia/kendo
|
src/Kendo.php
|
Kendo.create
|
public static function create(string $name, string $bindTo = ''): Base
{
$fullName = __NAMESPACE__ . '\\Widget\\' . $name;
$widget = class_exists($fullName) ? new $fullName() : new Widget\Base('kendo' . $name);
if ($bindTo) {
$widget->bindTo($bindTo);
}
return $widget;
}
|
php
|
public static function create(string $name, string $bindTo = ''): Base
{
$fullName = __NAMESPACE__ . '\\Widget\\' . $name;
$widget = class_exists($fullName) ? new $fullName() : new Widget\Base('kendo' . $name);
if ($bindTo) {
$widget->bindTo($bindTo);
}
return $widget;
}
|
[
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"bindTo",
"=",
"''",
")",
":",
"Base",
"{",
"$",
"fullName",
"=",
"__NAMESPACE__",
".",
"'\\\\Widget\\\\'",
".",
"$",
"name",
";",
"$",
"widget",
"=",
"class_exists",
"(",
"$",
"fullName",
")",
"?",
"new",
"$",
"fullName",
"(",
")",
":",
"new",
"Widget",
"\\",
"Base",
"(",
"'kendo'",
".",
"$",
"name",
")",
";",
"if",
"(",
"$",
"bindTo",
")",
"{",
"$",
"widget",
"->",
"bindTo",
"(",
"$",
"bindTo",
")",
";",
"}",
"return",
"$",
"widget",
";",
"}"
] |
Create and return instance of requested Kendo widget.
@param string $name
@param string $bindTo
@return Base
|
[
"Create",
"and",
"return",
"instance",
"of",
"requested",
"Kendo",
"widget",
"."
] |
5e675c7c5d44c6228e4384091480a13fedfc3dde
|
https://github.com/riesenia/kendo/blob/5e675c7c5d44c6228e4384091480a13fedfc3dde/src/Kendo.php#L30-L40
|
223,017
|
riesenia/kendo
|
src/Kendo.php
|
Kendo.date
|
public static function date(string $value): ?JavascriptFunction
{
$timestamp = strtotime($value);
// wrong date format
if (!$timestamp) {
return null;
}
return new JavascriptFunction('kendo.parseDate("' . date('Y-m-d H:i:s', $timestamp) . '")');
}
|
php
|
public static function date(string $value): ?JavascriptFunction
{
$timestamp = strtotime($value);
// wrong date format
if (!$timestamp) {
return null;
}
return new JavascriptFunction('kendo.parseDate("' . date('Y-m-d H:i:s', $timestamp) . '")');
}
|
[
"public",
"static",
"function",
"date",
"(",
"string",
"$",
"value",
")",
":",
"?",
"JavascriptFunction",
"{",
"$",
"timestamp",
"=",
"strtotime",
"(",
"$",
"value",
")",
";",
"// wrong date format",
"if",
"(",
"!",
"$",
"timestamp",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"JavascriptFunction",
"(",
"'kendo.parseDate(\"'",
".",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"timestamp",
")",
".",
"'\")'",
")",
";",
"}"
] |
Create javascript date object.
@param string $value
@return JavascriptFunction|null
|
[
"Create",
"javascript",
"date",
"object",
"."
] |
5e675c7c5d44c6228e4384091480a13fedfc3dde
|
https://github.com/riesenia/kendo/blob/5e675c7c5d44c6228e4384091480a13fedfc3dde/src/Kendo.php#L61-L71
|
223,018
|
rpayonline/rpayonline-lite-php
|
lib/RpayLiteObject.php
|
RpayLiteObject.install
|
public function install($val, $opts = null)
{
$this->id = isset($val['id']) ? $val['id'] : null;
$this->opts = Util\Options::parse($opts);
foreach ($val as $k => $v) {
$this->values[$k] = Util\Util::arrayToObject($v);
}
}
|
php
|
public function install($val, $opts = null)
{
$this->id = isset($val['id']) ? $val['id'] : null;
$this->opts = Util\Options::parse($opts);
foreach ($val as $k => $v) {
$this->values[$k] = Util\Util::arrayToObject($v);
}
}
|
[
"public",
"function",
"install",
"(",
"$",
"val",
",",
"$",
"opts",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"isset",
"(",
"$",
"val",
"[",
"'id'",
"]",
")",
"?",
"$",
"val",
"[",
"'id'",
"]",
":",
"null",
";",
"$",
"this",
"->",
"opts",
"=",
"Util",
"\\",
"Options",
"::",
"parse",
"(",
"$",
"opts",
")",
";",
"foreach",
"(",
"$",
"val",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"k",
"]",
"=",
"Util",
"\\",
"Util",
"::",
"arrayToObject",
"(",
"$",
"v",
")",
";",
"}",
"}"
] |
Apply the contents of the given Object to this instance.
@param RpayLiteObject $val Original object.
@param array $opts Request header.
|
[
"Apply",
"the",
"contents",
"of",
"the",
"given",
"Object",
"to",
"this",
"instance",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/RpayLiteObject.php#L36-L43
|
223,019
|
rpayonline/rpayonline-lite-php
|
lib/RpayLiteObject.php
|
RpayLiteObject.constructFrom
|
public static function constructFrom($val, $opts = null)
{
$obj = new static(isset($val['id']) ? $val['id'] : null);
$obj->install($val, $opts);
return $obj;
}
|
php
|
public static function constructFrom($val, $opts = null)
{
$obj = new static(isset($val['id']) ? $val['id'] : null);
$obj->install($val, $opts);
return $obj;
}
|
[
"public",
"static",
"function",
"constructFrom",
"(",
"$",
"val",
",",
"$",
"opts",
"=",
"null",
")",
"{",
"$",
"obj",
"=",
"new",
"static",
"(",
"isset",
"(",
"$",
"val",
"[",
"'id'",
"]",
")",
"?",
"$",
"val",
"[",
"'id'",
"]",
":",
"null",
")",
";",
"$",
"obj",
"->",
"install",
"(",
"$",
"val",
",",
"$",
"opts",
")",
";",
"return",
"$",
"obj",
";",
"}"
] |
Create new instance from JSON string.
@param string $val JSON string
@param array $opts Request header.
@return RpayLiteObject
|
[
"Create",
"new",
"instance",
"from",
"JSON",
"string",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/RpayLiteObject.php#L51-L56
|
223,020
|
rpayonline/rpayonline-lite-php
|
lib/RpayLiteObject.php
|
RpayLiteObject.parseJson
|
public static function parseJson($jsonString)
{
$jsonObj = json_decode($jsonString, true);
$jsonCheck = json_last_error();
if ($jsonObj === null && $jsonCheck !== JSON_ERROR_NONE) {
$msg = "Invalid json string: $jsonString -- "
. "json_last_error() returns $jsonCheck";
throw new Error\ParseException($msg);
}
return self::constructFrom($jsonObj);
}
|
php
|
public static function parseJson($jsonString)
{
$jsonObj = json_decode($jsonString, true);
$jsonCheck = json_last_error();
if ($jsonObj === null && $jsonCheck !== JSON_ERROR_NONE) {
$msg = "Invalid json string: $jsonString -- "
. "json_last_error() returns $jsonCheck";
throw new Error\ParseException($msg);
}
return self::constructFrom($jsonObj);
}
|
[
"public",
"static",
"function",
"parseJson",
"(",
"$",
"jsonString",
")",
"{",
"$",
"jsonObj",
"=",
"json_decode",
"(",
"$",
"jsonString",
",",
"true",
")",
";",
"$",
"jsonCheck",
"=",
"json_last_error",
"(",
")",
";",
"if",
"(",
"$",
"jsonObj",
"===",
"null",
"&&",
"$",
"jsonCheck",
"!==",
"JSON_ERROR_NONE",
")",
"{",
"$",
"msg",
"=",
"\"Invalid json string: $jsonString -- \"",
".",
"\"json_last_error() returns $jsonCheck\"",
";",
"throw",
"new",
"Error",
"\\",
"ParseException",
"(",
"$",
"msg",
")",
";",
"}",
"return",
"self",
"::",
"constructFrom",
"(",
"$",
"jsonObj",
")",
";",
"}"
] |
Apply the contents of given JSON string to this instance.
@param string $jsonString JSON string
@return Event|RpayLiteObject
@throws Error\ParseException In case of JSON parse error.
|
[
"Apply",
"the",
"contents",
"of",
"given",
"JSON",
"string",
"to",
"this",
"instance",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/RpayLiteObject.php#L126-L136
|
223,021
|
DevGroup-ru/yii2-tag-dependency-helper
|
src/NamingHelper.php
|
NamingHelper.getObjectTag
|
public static function getObjectTag($class, $id)
{
if (is_object($class) && $class instanceof ActiveRecord) {
$class = $class->className();
} elseif (!is_string($class)) {
throw new InvalidParamException('Param $class must be a string or an object.');
}
return $class . '[ObjectTag:' . self::getCacheKeyById($id) . ']';
}
|
php
|
public static function getObjectTag($class, $id)
{
if (is_object($class) && $class instanceof ActiveRecord) {
$class = $class->className();
} elseif (!is_string($class)) {
throw new InvalidParamException('Param $class must be a string or an object.');
}
return $class . '[ObjectTag:' . self::getCacheKeyById($id) . ']';
}
|
[
"public",
"static",
"function",
"getObjectTag",
"(",
"$",
"class",
",",
"$",
"id",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"class",
")",
"&&",
"$",
"class",
"instanceof",
"ActiveRecord",
")",
"{",
"$",
"class",
"=",
"$",
"class",
"->",
"className",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"is_string",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"'Param $class must be a string or an object.'",
")",
";",
"}",
"return",
"$",
"class",
".",
"'[ObjectTag:'",
".",
"self",
"::",
"getCacheKeyById",
"(",
"$",
"id",
")",
".",
"']'",
";",
"}"
] |
Get object tag name.
@param string|ActiveRecord $class
@param mixed $id
@return string
@throws \yii\base\InvalidParamException
|
[
"Get",
"object",
"tag",
"name",
"."
] |
23e7d26df35fc9605aa674f03cd701f46909214a
|
https://github.com/DevGroup-ru/yii2-tag-dependency-helper/blob/23e7d26df35fc9605aa674f03cd701f46909214a/src/NamingHelper.php#L18-L26
|
223,022
|
DevGroup-ru/yii2-tag-dependency-helper
|
src/NamingHelper.php
|
NamingHelper.getCompositeTag
|
public static function getCompositeTag($class, $fields)
{
if (is_object($class) && $class instanceof ActiveRecord) {
$class = $class->className();
} elseif (!is_string($class)) {
throw new InvalidParamException('Param $class must be a string or an object.');
}
return $class .
'[CompositeTag(' .
self::getCacheKeyById($fields, true) .
'):(' .
self::getCacheKeyById($fields) .
')]';
}
|
php
|
public static function getCompositeTag($class, $fields)
{
if (is_object($class) && $class instanceof ActiveRecord) {
$class = $class->className();
} elseif (!is_string($class)) {
throw new InvalidParamException('Param $class must be a string or an object.');
}
return $class .
'[CompositeTag(' .
self::getCacheKeyById($fields, true) .
'):(' .
self::getCacheKeyById($fields) .
')]';
}
|
[
"public",
"static",
"function",
"getCompositeTag",
"(",
"$",
"class",
",",
"$",
"fields",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"class",
")",
"&&",
"$",
"class",
"instanceof",
"ActiveRecord",
")",
"{",
"$",
"class",
"=",
"$",
"class",
"->",
"className",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"is_string",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"'Param $class must be a string or an object.'",
")",
";",
"}",
"return",
"$",
"class",
".",
"'[CompositeTag('",
".",
"self",
"::",
"getCacheKeyById",
"(",
"$",
"fields",
",",
"true",
")",
".",
"'):('",
".",
"self",
"::",
"getCacheKeyById",
"(",
"$",
"fields",
")",
".",
"')]'",
";",
"}"
] |
Get composite tag name from model fields.
@param string|ActiveRecord $class
@param array $fields - ['field_model' => 'value']
@return string
@throws \yii\base\InvalidParamException
|
[
"Get",
"composite",
"tag",
"name",
"from",
"model",
"fields",
"."
] |
23e7d26df35fc9605aa674f03cd701f46909214a
|
https://github.com/DevGroup-ru/yii2-tag-dependency-helper/blob/23e7d26df35fc9605aa674f03cd701f46909214a/src/NamingHelper.php#L51-L65
|
223,023
|
DevGroup-ru/yii2-tag-dependency-helper
|
src/NamingHelper.php
|
NamingHelper.getCacheKeyById
|
public static function getCacheKeyById($id, $keys = false)
{
if (is_array($id)) {
ksort($id);
$id = ($keys) ? array_keys($id) : array_values($id);
return implode('|', $id);
}
return (string)$id;
}
|
php
|
public static function getCacheKeyById($id, $keys = false)
{
if (is_array($id)) {
ksort($id);
$id = ($keys) ? array_keys($id) : array_values($id);
return implode('|', $id);
}
return (string)$id;
}
|
[
"public",
"static",
"function",
"getCacheKeyById",
"(",
"$",
"id",
",",
"$",
"keys",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"id",
")",
")",
"{",
"ksort",
"(",
"$",
"id",
")",
";",
"$",
"id",
"=",
"(",
"$",
"keys",
")",
"?",
"array_keys",
"(",
"$",
"id",
")",
":",
"array_values",
"(",
"$",
"id",
")",
";",
"return",
"implode",
"(",
"'|'",
",",
"$",
"id",
")",
";",
"}",
"return",
"(",
"string",
")",
"$",
"id",
";",
"}"
] |
Return string for cache-key from varios primary key
@param mixed $id
@param bool $keys if true, will used keys array for build the cache key
@return string
|
[
"Return",
"string",
"for",
"cache",
"-",
"key",
"from",
"varios",
"primary",
"key"
] |
23e7d26df35fc9605aa674f03cd701f46909214a
|
https://github.com/DevGroup-ru/yii2-tag-dependency-helper/blob/23e7d26df35fc9605aa674f03cd701f46909214a/src/NamingHelper.php#L73-L83
|
223,024
|
symlex/doctrine-active-record
|
src/Dao/Factory.php
|
Factory.create
|
public function create(string $name)
{
$className = $this->getClassName($name);
$result = $this->createInstance($className);
return $result;
}
|
php
|
public function create(string $name)
{
$className = $this->getClassName($name);
$result = $this->createInstance($className);
return $result;
}
|
[
"public",
"function",
"create",
"(",
"string",
"$",
"name",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"getClassName",
"(",
"$",
"name",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"createInstance",
"(",
"$",
"className",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Returns a new DAO instance
@param string $name Class name without namespace prefix and postfix
@throws FactoryException
@return Dao|EntityDao
|
[
"Returns",
"a",
"new",
"DAO",
"instance"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Dao/Factory.php#L51-L58
|
223,025
|
core-system/bootstrap-form
|
src/BootstrapFormBuilder.php
|
BootstrapFormBuilder.openGroup
|
public function openGroup($name, $label = null, $options = array())
{
$options = $this->appendClassToOptions(Config::get('form-builder.group-class'), $options);
$this->groupStack[] = $name;
if ($this->hasErrors($name)) {
$options = $this->appendClassToOptions(Config::get('form-builder.error-class'), $options);
}
$label = $label ? $this->label($name, $label) : '';
return $this->toHtmlString('<div'.$this->html->attributes($options).'>'.$label);
}
|
php
|
public function openGroup($name, $label = null, $options = array())
{
$options = $this->appendClassToOptions(Config::get('form-builder.group-class'), $options);
$this->groupStack[] = $name;
if ($this->hasErrors($name)) {
$options = $this->appendClassToOptions(Config::get('form-builder.error-class'), $options);
}
$label = $label ? $this->label($name, $label) : '';
return $this->toHtmlString('<div'.$this->html->attributes($options).'>'.$label);
}
|
[
"public",
"function",
"openGroup",
"(",
"$",
"name",
",",
"$",
"label",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"appendClassToOptions",
"(",
"Config",
"::",
"get",
"(",
"'form-builder.group-class'",
")",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"groupStack",
"[",
"]",
"=",
"$",
"name",
";",
"if",
"(",
"$",
"this",
"->",
"hasErrors",
"(",
"$",
"name",
")",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"appendClassToOptions",
"(",
"Config",
"::",
"get",
"(",
"'form-builder.error-class'",
")",
",",
"$",
"options",
")",
";",
"}",
"$",
"label",
"=",
"$",
"label",
"?",
"$",
"this",
"->",
"label",
"(",
"$",
"name",
",",
"$",
"label",
")",
":",
"''",
";",
"return",
"$",
"this",
"->",
"toHtmlString",
"(",
"'<div'",
".",
"$",
"this",
"->",
"html",
"->",
"attributes",
"(",
"$",
"options",
")",
".",
"'>'",
".",
"$",
"label",
")",
";",
"}"
] |
Open a new form group
@param string $name
@param mixed $label
@param array $options
@return \Illuminate\Support\HtmlString
|
[
"Open",
"a",
"new",
"form",
"group"
] |
40820f63bb09ad61cbdb657a8077798e8aa54f54
|
https://github.com/core-system/bootstrap-form/blob/40820f63bb09ad61cbdb657a8077798e8aa54f54/src/BootstrapFormBuilder.php#L23-L36
|
223,026
|
core-system/bootstrap-form
|
src/BootstrapFormBuilder.php
|
BootstrapFormBuilder.select
|
public function select(
$name,
$list = [],
$selected = null,
array $selectAttributes = [],
array $optionsAttributes = [],
array $optgroupsAttributes = []
) {
$selectAttributes = $this->appendClassToOptions(Config::get('form-builder.control-class'), $selectAttributes);
return parent::select($name, $list, $selected, $selectAttributes, $optionsAttributes);
}
|
php
|
public function select(
$name,
$list = [],
$selected = null,
array $selectAttributes = [],
array $optionsAttributes = [],
array $optgroupsAttributes = []
) {
$selectAttributes = $this->appendClassToOptions(Config::get('form-builder.control-class'), $selectAttributes);
return parent::select($name, $list, $selected, $selectAttributes, $optionsAttributes);
}
|
[
"public",
"function",
"select",
"(",
"$",
"name",
",",
"$",
"list",
"=",
"[",
"]",
",",
"$",
"selected",
"=",
"null",
",",
"array",
"$",
"selectAttributes",
"=",
"[",
"]",
",",
"array",
"$",
"optionsAttributes",
"=",
"[",
"]",
",",
"array",
"$",
"optgroupsAttributes",
"=",
"[",
"]",
")",
"{",
"$",
"selectAttributes",
"=",
"$",
"this",
"->",
"appendClassToOptions",
"(",
"Config",
"::",
"get",
"(",
"'form-builder.control-class'",
")",
",",
"$",
"selectAttributes",
")",
";",
"return",
"parent",
"::",
"select",
"(",
"$",
"name",
",",
"$",
"list",
",",
"$",
"selected",
",",
"$",
"selectAttributes",
",",
"$",
"optionsAttributes",
")",
";",
"}"
] |
Create a select box
@param string $name
@param array $list
@param string $selected
@param array $selectAttributes
@param array $optionsAttributes
@return \Illuminate\Support\HtmlString
|
[
"Create",
"a",
"select",
"box"
] |
40820f63bb09ad61cbdb657a8077798e8aa54f54
|
https://github.com/core-system/bootstrap-form/blob/40820f63bb09ad61cbdb657a8077798e8aa54f54/src/BootstrapFormBuilder.php#L78-L89
|
223,027
|
core-system/bootstrap-form
|
src/BootstrapFormBuilder.php
|
BootstrapFormBuilder.plainSelect
|
public function plainSelect($name, $list = array(), $selected = null, array $selectAttributes = [], array $optionsAttributes = [])
{
return parent::select($name, $list, $selected, $selectAttributes, $optionsAttributes);
}
|
php
|
public function plainSelect($name, $list = array(), $selected = null, array $selectAttributes = [], array $optionsAttributes = [])
{
return parent::select($name, $list, $selected, $selectAttributes, $optionsAttributes);
}
|
[
"public",
"function",
"plainSelect",
"(",
"$",
"name",
",",
"$",
"list",
"=",
"array",
"(",
")",
",",
"$",
"selected",
"=",
"null",
",",
"array",
"$",
"selectAttributes",
"=",
"[",
"]",
",",
"array",
"$",
"optionsAttributes",
"=",
"[",
"]",
")",
"{",
"return",
"parent",
"::",
"select",
"(",
"$",
"name",
",",
"$",
"list",
",",
"$",
"selected",
",",
"$",
"selectAttributes",
",",
"$",
"optionsAttributes",
")",
";",
"}"
] |
Create a plain select box
@param string $name
@param array $list
@param string $selected
@param array $selectAttributes
@param array $optionsAttributes
@return \Illuminate\Support\HtmlString
|
[
"Create",
"a",
"plain",
"select",
"box"
] |
40820f63bb09ad61cbdb657a8077798e8aa54f54
|
https://github.com/core-system/bootstrap-form/blob/40820f63bb09ad61cbdb657a8077798e8aa54f54/src/BootstrapFormBuilder.php#L115-L118
|
223,028
|
core-system/bootstrap-form
|
src/BootstrapFormBuilder.php
|
BootstrapFormBuilder.hasErrors
|
private function hasErrors($name)
{
if (is_null($this->session) || !$this->session->has('errors')) {
return false;
}
// Get errors session
$errors = $this->getErrorsSession();
return $errors->has($this->transformKey($name));
}
|
php
|
private function hasErrors($name)
{
if (is_null($this->session) || !$this->session->has('errors')) {
return false;
}
// Get errors session
$errors = $this->getErrorsSession();
return $errors->has($this->transformKey($name));
}
|
[
"private",
"function",
"hasErrors",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"session",
")",
"||",
"!",
"$",
"this",
"->",
"session",
"->",
"has",
"(",
"'errors'",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Get errors session",
"$",
"errors",
"=",
"$",
"this",
"->",
"getErrorsSession",
"(",
")",
";",
"return",
"$",
"errors",
"->",
"has",
"(",
"$",
"this",
"->",
"transformKey",
"(",
"$",
"name",
")",
")",
";",
"}"
] |
Determine whether the form element with the given name has any validation errors
@param string $name
@return bool
|
[
"Determine",
"whether",
"the",
"form",
"element",
"with",
"the",
"given",
"name",
"has",
"any",
"validation",
"errors"
] |
40820f63bb09ad61cbdb657a8077798e8aa54f54
|
https://github.com/core-system/bootstrap-form/blob/40820f63bb09ad61cbdb657a8077798e8aa54f54/src/BootstrapFormBuilder.php#L281-L290
|
223,029
|
core-system/bootstrap-form
|
src/BootstrapFormBuilder.php
|
BootstrapFormBuilder.getFormattedErrors
|
private function getFormattedErrors($name)
{
if (!$this->hasErrors($name)) {
return '';
}
// Get errors session
$errors = $this->getErrorsSession();
return $errors->first($this->transformKey($name), '<p class="help-block">:message</p>');
}
|
php
|
private function getFormattedErrors($name)
{
if (!$this->hasErrors($name)) {
return '';
}
// Get errors session
$errors = $this->getErrorsSession();
return $errors->first($this->transformKey($name), '<p class="help-block">:message</p>');
}
|
[
"private",
"function",
"getFormattedErrors",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
"$",
"name",
")",
")",
"{",
"return",
"''",
";",
"}",
"// Get errors session",
"$",
"errors",
"=",
"$",
"this",
"->",
"getErrorsSession",
"(",
")",
";",
"return",
"$",
"errors",
"->",
"first",
"(",
"$",
"this",
"->",
"transformKey",
"(",
"$",
"name",
")",
",",
"'<p class=\"help-block\">:message</p>'",
")",
";",
"}"
] |
Get the formatted errors for the form element with the given name
@param string $name
@return string
|
[
"Get",
"the",
"formatted",
"errors",
"for",
"the",
"form",
"element",
"with",
"the",
"given",
"name"
] |
40820f63bb09ad61cbdb657a8077798e8aa54f54
|
https://github.com/core-system/bootstrap-form/blob/40820f63bb09ad61cbdb657a8077798e8aa54f54/src/BootstrapFormBuilder.php#L308-L317
|
223,030
|
index0h/yii2-log
|
src/base/TargetTrait.php
|
TargetTrait.addContextToMessages
|
protected function addContextToMessages()
{
$context = $this->getContextMessage();
if ($context === []) {
return;
}
foreach ($this->messages as &$message) {
$message[0] = ArrayHelper::merge($context, $this->parseText($message[0]));
}
}
|
php
|
protected function addContextToMessages()
{
$context = $this->getContextMessage();
if ($context === []) {
return;
}
foreach ($this->messages as &$message) {
$message[0] = ArrayHelper::merge($context, $this->parseText($message[0]));
}
}
|
[
"protected",
"function",
"addContextToMessages",
"(",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"getContextMessage",
"(",
")",
";",
"if",
"(",
"$",
"context",
"===",
"[",
"]",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"messages",
"as",
"&",
"$",
"message",
")",
"{",
"$",
"message",
"[",
"0",
"]",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"context",
",",
"$",
"this",
"->",
"parseText",
"(",
"$",
"message",
"[",
"0",
"]",
")",
")",
";",
"}",
"}"
] |
Updates all messages if there are context variables.
|
[
"Updates",
"all",
"messages",
"if",
"there",
"are",
"context",
"variables",
"."
] |
a470a913e953a190880ced04ddfa13fe2ecc4811
|
https://github.com/index0h/yii2-log/blob/a470a913e953a190880ced04ddfa13fe2ecc4811/src/base/TargetTrait.php#L70-L81
|
223,031
|
index0h/yii2-log
|
src/base/TargetTrait.php
|
TargetTrait.getContextMessage
|
protected function getContextMessage()
{
$context = $this->context;
if (($this->logUser === true) && ($user = \Yii::$app->get('user', false)) !== null) {
/** @var \yii\web\User $user */
$context['userId'] = $user->getId();
}
foreach ($this->logVars as $name) {
if (empty($GLOBALS[$name]) === false) {
$context[$name] = & $GLOBALS[$name];
}
}
return $context;
}
|
php
|
protected function getContextMessage()
{
$context = $this->context;
if (($this->logUser === true) && ($user = \Yii::$app->get('user', false)) !== null) {
/** @var \yii\web\User $user */
$context['userId'] = $user->getId();
}
foreach ($this->logVars as $name) {
if (empty($GLOBALS[$name]) === false) {
$context[$name] = & $GLOBALS[$name];
}
}
return $context;
}
|
[
"protected",
"function",
"getContextMessage",
"(",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"context",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"logUser",
"===",
"true",
")",
"&&",
"(",
"$",
"user",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"get",
"(",
"'user'",
",",
"false",
")",
")",
"!==",
"null",
")",
"{",
"/** @var \\yii\\web\\User $user */",
"$",
"context",
"[",
"'userId'",
"]",
"=",
"$",
"user",
"->",
"getId",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"logVars",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"GLOBALS",
"[",
"$",
"name",
"]",
")",
"===",
"false",
")",
"{",
"$",
"context",
"[",
"$",
"name",
"]",
"=",
"&",
"$",
"GLOBALS",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"$",
"context",
";",
"}"
] |
Generates the context information to be logged.
@return array
|
[
"Generates",
"the",
"context",
"information",
"to",
"be",
"logged",
"."
] |
a470a913e953a190880ced04ddfa13fe2ecc4811
|
https://github.com/index0h/yii2-log/blob/a470a913e953a190880ced04ddfa13fe2ecc4811/src/base/TargetTrait.php#L88-L104
|
223,032
|
index0h/yii2-log
|
src/base/TargetTrait.php
|
TargetTrait.prepareMessage
|
protected function prepareMessage($message)
{
list($text, $level, $category, $timestamp) = $message;
$level = Logger::getLevelName($level);
$timestamp = date('c', $timestamp);
$result = ArrayHelper::merge(
$this->parseText($text),
['level' => $level, 'category' => $category, '@timestamp' => $timestamp]
);
if (isset($message[4]) === true) {
$result['trace'] = $message[4];
}
return $result;
}
|
php
|
protected function prepareMessage($message)
{
list($text, $level, $category, $timestamp) = $message;
$level = Logger::getLevelName($level);
$timestamp = date('c', $timestamp);
$result = ArrayHelper::merge(
$this->parseText($text),
['level' => $level, 'category' => $category, '@timestamp' => $timestamp]
);
if (isset($message[4]) === true) {
$result['trace'] = $message[4];
}
return $result;
}
|
[
"protected",
"function",
"prepareMessage",
"(",
"$",
"message",
")",
"{",
"list",
"(",
"$",
"text",
",",
"$",
"level",
",",
"$",
"category",
",",
"$",
"timestamp",
")",
"=",
"$",
"message",
";",
"$",
"level",
"=",
"Logger",
"::",
"getLevelName",
"(",
"$",
"level",
")",
";",
"$",
"timestamp",
"=",
"date",
"(",
"'c'",
",",
"$",
"timestamp",
")",
";",
"$",
"result",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"this",
"->",
"parseText",
"(",
"$",
"text",
")",
",",
"[",
"'level'",
"=>",
"$",
"level",
",",
"'category'",
"=>",
"$",
"category",
",",
"'@timestamp'",
"=>",
"$",
"timestamp",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"message",
"[",
"4",
"]",
")",
"===",
"true",
")",
"{",
"$",
"result",
"[",
"'trace'",
"]",
"=",
"$",
"message",
"[",
"4",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Transform log message to assoc.
@param array $message The log message.
@return array
|
[
"Transform",
"log",
"message",
"to",
"assoc",
"."
] |
a470a913e953a190880ced04ddfa13fe2ecc4811
|
https://github.com/index0h/yii2-log/blob/a470a913e953a190880ced04ddfa13fe2ecc4811/src/base/TargetTrait.php#L135-L152
|
223,033
|
symlex/doctrine-active-record
|
src/Dao/Format.php
|
Format.fromSql
|
public static function fromSql(string $format, $data = null)
{
if ($data === null) {
return null;
}
switch ($format) {
case self::NONE:
return $data;
case self::DATE:
$result = DateTime::createFromFormat($format, $data);
$result->setTime(0, 0, 0);
return $result;
case self::TIMESTAMP:
case self::TIMETZ:
case self::TIMEUTZ:
case self::DATETIMETZ:
case self::DATETIMEUTZ:
// Format must match - no auto detection
return DateTime::createFromFormat($format, $data);
case self::TIME:
case self::TIMEU:
// Includes microseconds?
$timeFormat = (strlen($data) > 8) ? self::TIMEU : self::TIME;
return DateTime::createFromFormat($timeFormat, $data);
case self::DATETIME:
case self::DATETIMEU:
// Includes microseconds?
$dateTimeFormat = (strlen($data) > 19) ? self::DATETIMEU : self::DATETIME;
return DateTime::createFromFormat($dateTimeFormat, $data);
case self::INT:
return (integer)$data;
case self::BOOL:
return (bool)$data;
case self::FLOAT:
return floatval($data);
case self::STRING:
return (string)$data;
case self::ALPHANUMERIC:
return preg_replace('/[^a-zA-Z0-9_ ]/', '', $data);
case self::SERIALIZED:
return unserialize($data);
case self::JSON:
return json_decode($data, true);
case self::CSV:
return str_getcsv($data);
default:
throw new FormatException ('Unknown format: ' . $format);
}
}
|
php
|
public static function fromSql(string $format, $data = null)
{
if ($data === null) {
return null;
}
switch ($format) {
case self::NONE:
return $data;
case self::DATE:
$result = DateTime::createFromFormat($format, $data);
$result->setTime(0, 0, 0);
return $result;
case self::TIMESTAMP:
case self::TIMETZ:
case self::TIMEUTZ:
case self::DATETIMETZ:
case self::DATETIMEUTZ:
// Format must match - no auto detection
return DateTime::createFromFormat($format, $data);
case self::TIME:
case self::TIMEU:
// Includes microseconds?
$timeFormat = (strlen($data) > 8) ? self::TIMEU : self::TIME;
return DateTime::createFromFormat($timeFormat, $data);
case self::DATETIME:
case self::DATETIMEU:
// Includes microseconds?
$dateTimeFormat = (strlen($data) > 19) ? self::DATETIMEU : self::DATETIME;
return DateTime::createFromFormat($dateTimeFormat, $data);
case self::INT:
return (integer)$data;
case self::BOOL:
return (bool)$data;
case self::FLOAT:
return floatval($data);
case self::STRING:
return (string)$data;
case self::ALPHANUMERIC:
return preg_replace('/[^a-zA-Z0-9_ ]/', '', $data);
case self::SERIALIZED:
return unserialize($data);
case self::JSON:
return json_decode($data, true);
case self::CSV:
return str_getcsv($data);
default:
throw new FormatException ('Unknown format: ' . $format);
}
}
|
[
"public",
"static",
"function",
"fromSql",
"(",
"string",
"$",
"format",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"switch",
"(",
"$",
"format",
")",
"{",
"case",
"self",
"::",
"NONE",
":",
"return",
"$",
"data",
";",
"case",
"self",
"::",
"DATE",
":",
"$",
"result",
"=",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"format",
",",
"$",
"data",
")",
";",
"$",
"result",
"->",
"setTime",
"(",
"0",
",",
"0",
",",
"0",
")",
";",
"return",
"$",
"result",
";",
"case",
"self",
"::",
"TIMESTAMP",
":",
"case",
"self",
"::",
"TIMETZ",
":",
"case",
"self",
"::",
"TIMEUTZ",
":",
"case",
"self",
"::",
"DATETIMETZ",
":",
"case",
"self",
"::",
"DATETIMEUTZ",
":",
"// Format must match - no auto detection",
"return",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"format",
",",
"$",
"data",
")",
";",
"case",
"self",
"::",
"TIME",
":",
"case",
"self",
"::",
"TIMEU",
":",
"// Includes microseconds?",
"$",
"timeFormat",
"=",
"(",
"strlen",
"(",
"$",
"data",
")",
">",
"8",
")",
"?",
"self",
"::",
"TIMEU",
":",
"self",
"::",
"TIME",
";",
"return",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"timeFormat",
",",
"$",
"data",
")",
";",
"case",
"self",
"::",
"DATETIME",
":",
"case",
"self",
"::",
"DATETIMEU",
":",
"// Includes microseconds?",
"$",
"dateTimeFormat",
"=",
"(",
"strlen",
"(",
"$",
"data",
")",
">",
"19",
")",
"?",
"self",
"::",
"DATETIMEU",
":",
"self",
"::",
"DATETIME",
";",
"return",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"dateTimeFormat",
",",
"$",
"data",
")",
";",
"case",
"self",
"::",
"INT",
":",
"return",
"(",
"integer",
")",
"$",
"data",
";",
"case",
"self",
"::",
"BOOL",
":",
"return",
"(",
"bool",
")",
"$",
"data",
";",
"case",
"self",
"::",
"FLOAT",
":",
"return",
"floatval",
"(",
"$",
"data",
")",
";",
"case",
"self",
"::",
"STRING",
":",
"return",
"(",
"string",
")",
"$",
"data",
";",
"case",
"self",
"::",
"ALPHANUMERIC",
":",
"return",
"preg_replace",
"(",
"'/[^a-zA-Z0-9_ ]/'",
",",
"''",
",",
"$",
"data",
")",
";",
"case",
"self",
"::",
"SERIALIZED",
":",
"return",
"unserialize",
"(",
"$",
"data",
")",
";",
"case",
"self",
"::",
"JSON",
":",
"return",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
";",
"case",
"self",
"::",
"CSV",
":",
"return",
"str_getcsv",
"(",
"$",
"data",
")",
";",
"default",
":",
"throw",
"new",
"FormatException",
"(",
"'Unknown format: '",
".",
"$",
"format",
")",
";",
"}",
"}"
] |
Converts data from sql data source
@param string $format
@param mixed $data
@throws FormatException
@return mixed
|
[
"Converts",
"data",
"from",
"sql",
"data",
"source"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Dao/Format.php#L48-L97
|
223,034
|
symlex/doctrine-active-record
|
src/Dao/Format.php
|
Format.toSql
|
public static function toSql(string $format, $data = null)
{
if ($data === null) {
return null;
}
switch ($format) {
case self::NONE:
return $data;
case self::TIME:
case self::TIMEU:
case self::TIMETZ:
case self::TIMEUTZ:
case self::DATE:
case self::DATETIME:
case self::DATETIMEU:
case self::DATETIMETZ:
case self::DATETIMEUTZ:
case self::TIMESTAMP:
if (empty($data)) {
$result = null;
} elseif (!is_object($data)) {
$datetime = new DateTime($data);
$result = $datetime->format($format);
} elseif ($data instanceof DateTime) {
$result = $data->format($format);
} else {
throw new FormatException('Unknown datetime object: ' . get_class($data));
}
return $result;
case self::INT:
return (integer)$data;
case self::BOOL:
return (integer)$data;
case self::FLOAT:
if (strpos($data, ',') > strpos($data, '.')) {
$data = str_replace(array('.', ','), array('', '.'), $data);
} elseif(strpos($data, '.') > strpos($data, ',')) {
$data = str_replace(',', '', $data);
}
return floatval($data);
case self::STRING:
return (string)$data;
case self::ALPHANUMERIC:
return preg_replace('/[^a-zA-Z0-9_ ]/', '', $data);
case self::SERIALIZED:
return serialize($data);
case self::JSON:
return json_encode($data);
case self::CSV:
return implode(',', $data);
default:
throw new FormatException ('Unknown format: ' . $format);
}
}
|
php
|
public static function toSql(string $format, $data = null)
{
if ($data === null) {
return null;
}
switch ($format) {
case self::NONE:
return $data;
case self::TIME:
case self::TIMEU:
case self::TIMETZ:
case self::TIMEUTZ:
case self::DATE:
case self::DATETIME:
case self::DATETIMEU:
case self::DATETIMETZ:
case self::DATETIMEUTZ:
case self::TIMESTAMP:
if (empty($data)) {
$result = null;
} elseif (!is_object($data)) {
$datetime = new DateTime($data);
$result = $datetime->format($format);
} elseif ($data instanceof DateTime) {
$result = $data->format($format);
} else {
throw new FormatException('Unknown datetime object: ' . get_class($data));
}
return $result;
case self::INT:
return (integer)$data;
case self::BOOL:
return (integer)$data;
case self::FLOAT:
if (strpos($data, ',') > strpos($data, '.')) {
$data = str_replace(array('.', ','), array('', '.'), $data);
} elseif(strpos($data, '.') > strpos($data, ',')) {
$data = str_replace(',', '', $data);
}
return floatval($data);
case self::STRING:
return (string)$data;
case self::ALPHANUMERIC:
return preg_replace('/[^a-zA-Z0-9_ ]/', '', $data);
case self::SERIALIZED:
return serialize($data);
case self::JSON:
return json_encode($data);
case self::CSV:
return implode(',', $data);
default:
throw new FormatException ('Unknown format: ' . $format);
}
}
|
[
"public",
"static",
"function",
"toSql",
"(",
"string",
"$",
"format",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"switch",
"(",
"$",
"format",
")",
"{",
"case",
"self",
"::",
"NONE",
":",
"return",
"$",
"data",
";",
"case",
"self",
"::",
"TIME",
":",
"case",
"self",
"::",
"TIMEU",
":",
"case",
"self",
"::",
"TIMETZ",
":",
"case",
"self",
"::",
"TIMEUTZ",
":",
"case",
"self",
"::",
"DATE",
":",
"case",
"self",
"::",
"DATETIME",
":",
"case",
"self",
"::",
"DATETIMEU",
":",
"case",
"self",
"::",
"DATETIMETZ",
":",
"case",
"self",
"::",
"DATETIMEUTZ",
":",
"case",
"self",
"::",
"TIMESTAMP",
":",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"result",
"=",
"null",
";",
"}",
"elseif",
"(",
"!",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"$",
"datetime",
"=",
"new",
"DateTime",
"(",
"$",
"data",
")",
";",
"$",
"result",
"=",
"$",
"datetime",
"->",
"format",
"(",
"$",
"format",
")",
";",
"}",
"elseif",
"(",
"$",
"data",
"instanceof",
"DateTime",
")",
"{",
"$",
"result",
"=",
"$",
"data",
"->",
"format",
"(",
"$",
"format",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"FormatException",
"(",
"'Unknown datetime object: '",
".",
"get_class",
"(",
"$",
"data",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"case",
"self",
"::",
"INT",
":",
"return",
"(",
"integer",
")",
"$",
"data",
";",
"case",
"self",
"::",
"BOOL",
":",
"return",
"(",
"integer",
")",
"$",
"data",
";",
"case",
"self",
"::",
"FLOAT",
":",
"if",
"(",
"strpos",
"(",
"$",
"data",
",",
"','",
")",
">",
"strpos",
"(",
"$",
"data",
",",
"'.'",
")",
")",
"{",
"$",
"data",
"=",
"str_replace",
"(",
"array",
"(",
"'.'",
",",
"','",
")",
",",
"array",
"(",
"''",
",",
"'.'",
")",
",",
"$",
"data",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"data",
",",
"'.'",
")",
">",
"strpos",
"(",
"$",
"data",
",",
"','",
")",
")",
"{",
"$",
"data",
"=",
"str_replace",
"(",
"','",
",",
"''",
",",
"$",
"data",
")",
";",
"}",
"return",
"floatval",
"(",
"$",
"data",
")",
";",
"case",
"self",
"::",
"STRING",
":",
"return",
"(",
"string",
")",
"$",
"data",
";",
"case",
"self",
"::",
"ALPHANUMERIC",
":",
"return",
"preg_replace",
"(",
"'/[^a-zA-Z0-9_ ]/'",
",",
"''",
",",
"$",
"data",
")",
";",
"case",
"self",
"::",
"SERIALIZED",
":",
"return",
"serialize",
"(",
"$",
"data",
")",
";",
"case",
"self",
"::",
"JSON",
":",
"return",
"json_encode",
"(",
"$",
"data",
")",
";",
"case",
"self",
"::",
"CSV",
":",
"return",
"implode",
"(",
"','",
",",
"$",
"data",
")",
";",
"default",
":",
"throw",
"new",
"FormatException",
"(",
"'Unknown format: '",
".",
"$",
"format",
")",
";",
"}",
"}"
] |
Converts data to sql format
@param string $format
@param mixed $data
@throws FormatException
@return mixed
|
[
"Converts",
"data",
"to",
"sql",
"format"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Dao/Format.php#L107-L163
|
223,035
|
rpayonline/rpayonline-lite-php
|
lib/Charge.php
|
Charge.retrieve
|
public static function retrieve($id, $opts = null)
{
$list = self::all(array('id' => $id), $opts);
$ch = new Charge();
$ch->install($list->data[0]->values, $list->opts);
return $ch;
}
|
php
|
public static function retrieve($id, $opts = null)
{
$list = self::all(array('id' => $id), $opts);
$ch = new Charge();
$ch->install($list->data[0]->values, $list->opts);
return $ch;
}
|
[
"public",
"static",
"function",
"retrieve",
"(",
"$",
"id",
",",
"$",
"opts",
"=",
"null",
")",
"{",
"$",
"list",
"=",
"self",
"::",
"all",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
",",
"$",
"opts",
")",
";",
"$",
"ch",
"=",
"new",
"Charge",
"(",
")",
";",
"$",
"ch",
"->",
"install",
"(",
"$",
"list",
"->",
"data",
"[",
"0",
"]",
"->",
"values",
",",
"$",
"list",
"->",
"opts",
")",
";",
"return",
"$",
"ch",
";",
"}"
] |
Get Charge object which has specific charge id.
@param string $id charge id.
@param array $opts Request header.
@return Charge
|
[
"Get",
"Charge",
"object",
"which",
"has",
"specific",
"charge",
"id",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Charge.php#L37-L43
|
223,036
|
rpayonline/rpayonline-lite-php
|
lib/Charge.php
|
Charge.all
|
public static function all($params = array(), $opts = null)
{
$list = parent::all($params, $opts);
$chList = new ChargeCollection();
$chList->install($list->values, $list->opts);
return $chList;
}
|
php
|
public static function all($params = array(), $opts = null)
{
$list = parent::all($params, $opts);
$chList = new ChargeCollection();
$chList->install($list->values, $list->opts);
return $chList;
}
|
[
"public",
"static",
"function",
"all",
"(",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"opts",
"=",
"null",
")",
"{",
"$",
"list",
"=",
"parent",
"::",
"all",
"(",
"$",
"params",
",",
"$",
"opts",
")",
";",
"$",
"chList",
"=",
"new",
"ChargeCollection",
"(",
")",
";",
"$",
"chList",
"->",
"install",
"(",
"$",
"list",
"->",
"values",
",",
"$",
"list",
"->",
"opts",
")",
";",
"return",
"$",
"chList",
";",
"}"
] |
Get Charge list.
@param array $params Request parameters.
@param array $opts Request headers.
@return ChargeCollection
@link https://lite.checkout.rakuten.co.jp/manual/api#charge_list
|
[
"Get",
"Charge",
"list",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Charge.php#L52-L58
|
223,037
|
rpayonline/rpayonline-lite-php
|
lib/Charge.php
|
Charge.refund
|
public function refund($params, $opts = null)
{
$url = self::classUrl() . '/' . $this->instanceId() . "/refund";
list($resp, $usedOpts) = self::request(self::METHOD_POST, $url, $params, $opts);
$this->install($resp, $usedOpts);
return $this;
}
|
php
|
public function refund($params, $opts = null)
{
$url = self::classUrl() . '/' . $this->instanceId() . "/refund";
list($resp, $usedOpts) = self::request(self::METHOD_POST, $url, $params, $opts);
$this->install($resp, $usedOpts);
return $this;
}
|
[
"public",
"function",
"refund",
"(",
"$",
"params",
",",
"$",
"opts",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"classUrl",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"instanceId",
"(",
")",
".",
"\"/refund\"",
";",
"list",
"(",
"$",
"resp",
",",
"$",
"usedOpts",
")",
"=",
"self",
"::",
"request",
"(",
"self",
"::",
"METHOD_POST",
",",
"$",
"url",
",",
"$",
"params",
",",
"$",
"opts",
")",
";",
"$",
"this",
"->",
"install",
"(",
"$",
"resp",
",",
"$",
"usedOpts",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Refund order.
@param array $params Request parameters.
@param array $opts Request headers.
@return Charge $this
@link https://lite.checkout.rakuten.co.jp/manual/api#charge_refund
|
[
"Refund",
"order",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Charge.php#L67-L73
|
223,038
|
rpayonline/rpayonline-lite-php
|
lib/Charge.php
|
Charge.refresh
|
public function refresh()
{
$url = self::classUrl() . "?id=" . $this->instanceId();
list($resp, $usedOpts) = self::request(self::METHOD_GET, $url);
$body = isset($resp['data'][0]) ? $resp['data'][0] : null;
$this->install($body, $usedOpts);
return $this;
}
|
php
|
public function refresh()
{
$url = self::classUrl() . "?id=" . $this->instanceId();
list($resp, $usedOpts) = self::request(self::METHOD_GET, $url);
$body = isset($resp['data'][0]) ? $resp['data'][0] : null;
$this->install($body, $usedOpts);
return $this;
}
|
[
"public",
"function",
"refresh",
"(",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"classUrl",
"(",
")",
".",
"\"?id=\"",
".",
"$",
"this",
"->",
"instanceId",
"(",
")",
";",
"list",
"(",
"$",
"resp",
",",
"$",
"usedOpts",
")",
"=",
"self",
"::",
"request",
"(",
"self",
"::",
"METHOD_GET",
",",
"$",
"url",
")",
";",
"$",
"body",
"=",
"isset",
"(",
"$",
"resp",
"[",
"'data'",
"]",
"[",
"0",
"]",
")",
"?",
"$",
"resp",
"[",
"'data'",
"]",
"[",
"0",
"]",
":",
"null",
";",
"$",
"this",
"->",
"install",
"(",
"$",
"body",
",",
"$",
"usedOpts",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Update Charge object information to the latest.
@return Charge $this
|
[
"Update",
"Charge",
"object",
"information",
"to",
"the",
"latest",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Charge.php#L107-L114
|
223,039
|
riesenia/kendo
|
src/Widget/Base.php
|
Base.set
|
public function set($name, $value = null): self
{
if (!is_array($name)) {
$name = [$name => $value];
}
foreach ($name as $property => $value) {
$this->_data[$property] = $value;
}
return $this;
}
|
php
|
public function set($name, $value = null): self
{
if (!is_array($name)) {
$name = [$name => $value];
}
foreach ($name as $property => $value) {
$this->_data[$property] = $value;
}
return $this;
}
|
[
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"[",
"$",
"name",
"=>",
"$",
"value",
"]",
";",
"}",
"foreach",
"(",
"$",
"name",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"$",
"property",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Property setter.
@param array|string $name property name or array of properties
@param mixed $value property value
@return $this
|
[
"Property",
"setter",
"."
] |
5e675c7c5d44c6228e4384091480a13fedfc3dde
|
https://github.com/riesenia/kendo/blob/5e675c7c5d44c6228e4384091480a13fedfc3dde/src/Widget/Base.php#L85-L96
|
223,040
|
riesenia/kendo
|
src/Widget/Base.php
|
Base.add
|
public function add(string $name, ?string $key, $value): self
{
if (!isset($this->_data[$name])) {
$this->_data[$name] = [];
}
if ($key === null) {
$key = count($this->_data[$name]);
}
$this->_data[$name][$key] = $value;
return $this;
}
|
php
|
public function add(string $name, ?string $key, $value): self
{
if (!isset($this->_data[$name])) {
$this->_data[$name] = [];
}
if ($key === null) {
$key = count($this->_data[$name]);
}
$this->_data[$name][$key] = $value;
return $this;
}
|
[
"public",
"function",
"add",
"(",
"string",
"$",
"name",
",",
"?",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"self",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"$",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"$",
"key",
"=",
"count",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"name",
"]",
")",
";",
"}",
"$",
"this",
"->",
"_data",
"[",
"$",
"name",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Property setter adding to associative arrays.
@param string $name
@param string|null $key
@param mixed $value
@return $this
|
[
"Property",
"setter",
"adding",
"to",
"associative",
"arrays",
"."
] |
5e675c7c5d44c6228e4384091480a13fedfc3dde
|
https://github.com/riesenia/kendo/blob/5e675c7c5d44c6228e4384091480a13fedfc3dde/src/Widget/Base.php#L107-L120
|
223,041
|
riesenia/kendo
|
src/Widget/Base.php
|
Base.get
|
public function get(string $name)
{
if (!isset($this->_data[$name])) {
return null;
}
return $this->_data[$name];
}
|
php
|
public function get(string $name)
{
if (!isset($this->_data[$name])) {
return null;
}
return $this->_data[$name];
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_data",
"[",
"$",
"name",
"]",
";",
"}"
] |
Property getter.
@param string $name
@return mixed property value
|
[
"Property",
"getter",
"."
] |
5e675c7c5d44c6228e4384091480a13fedfc3dde
|
https://github.com/riesenia/kendo/blob/5e675c7c5d44c6228e4384091480a13fedfc3dde/src/Widget/Base.php#L129-L136
|
223,042
|
riesenia/kendo
|
src/Widget/Base.php
|
Base._encode
|
protected function _encode(): string
{
// json encode
$data = json_encode($this, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if ($data === false) {
throw new \Exception('Invalid data');
}
// replace markup by JavacriptFunction
$data = preg_replace_callback('/"::FUNCTION::(.*?)::FUNCTION::"/', function ($matches) {
return stripcslashes($matches[1]);
}, $data);
return $data;
}
|
php
|
protected function _encode(): string
{
// json encode
$data = json_encode($this, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if ($data === false) {
throw new \Exception('Invalid data');
}
// replace markup by JavacriptFunction
$data = preg_replace_callback('/"::FUNCTION::(.*?)::FUNCTION::"/', function ($matches) {
return stripcslashes($matches[1]);
}, $data);
return $data;
}
|
[
"protected",
"function",
"_encode",
"(",
")",
":",
"string",
"{",
"// json encode",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"this",
",",
"JSON_UNESCAPED_SLASHES",
"|",
"JSON_UNESCAPED_UNICODE",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Invalid data'",
")",
";",
"}",
"// replace markup by JavacriptFunction",
"$",
"data",
"=",
"preg_replace_callback",
"(",
"'/\"::FUNCTION::(.*?)::FUNCTION::\"/'",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"stripcslashes",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
",",
"$",
"data",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
Handle json_encode.
@return string
|
[
"Handle",
"json_encode",
"."
] |
5e675c7c5d44c6228e4384091480a13fedfc3dde
|
https://github.com/riesenia/kendo/blob/5e675c7c5d44c6228e4384091480a13fedfc3dde/src/Widget/Base.php#L153-L168
|
223,043
|
mwr/magedeploy2
|
src/Config/ConfigReader.php
|
ConfigReader.read
|
public function read($fallbackToDefault = false)
{
$configFile = Config::FILENAME;
if (!is_file($configFile)) {
if ($fallbackToDefault === false) {
return null;
}
$configFile = __DIR__ . '/magedeploy2.default.php';
}
$data = include $configFile;
$config = new Config($data);
return $config;
}
|
php
|
public function read($fallbackToDefault = false)
{
$configFile = Config::FILENAME;
if (!is_file($configFile)) {
if ($fallbackToDefault === false) {
return null;
}
$configFile = __DIR__ . '/magedeploy2.default.php';
}
$data = include $configFile;
$config = new Config($data);
return $config;
}
|
[
"public",
"function",
"read",
"(",
"$",
"fallbackToDefault",
"=",
"false",
")",
"{",
"$",
"configFile",
"=",
"Config",
"::",
"FILENAME",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"configFile",
")",
")",
"{",
"if",
"(",
"$",
"fallbackToDefault",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"$",
"configFile",
"=",
"__DIR__",
".",
"'/magedeploy2.default.php'",
";",
"}",
"$",
"data",
"=",
"include",
"$",
"configFile",
";",
"$",
"config",
"=",
"new",
"Config",
"(",
"$",
"data",
")",
";",
"return",
"$",
"config",
";",
"}"
] |
Read Config from file and initialize Config object
@return Config
|
[
"Read",
"Config",
"from",
"file",
"and",
"initialize",
"Config",
"object"
] |
8252f61ee4810f5aa2448090a51cb2d3916d6421
|
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Config/ConfigReader.php#L20-L37
|
223,044
|
rpayonline/rpayonline-lite-php
|
lib/ApiObject.php
|
ApiObject.interpretResponse
|
private static function interpretResponse($rstatus, $rheader, $rbody)
{
if ($rstatus < 200 || $rstatus >= 300) {
self::handleError($rstatus, $rheader, $rbody);
} elseif (empty($rbody)) {
throw new Error\Api('Invalid response from API', $rstatus, $rheader, $rbody);
}
$resp = json_decode($rbody, true);
return $resp;
}
|
php
|
private static function interpretResponse($rstatus, $rheader, $rbody)
{
if ($rstatus < 200 || $rstatus >= 300) {
self::handleError($rstatus, $rheader, $rbody);
} elseif (empty($rbody)) {
throw new Error\Api('Invalid response from API', $rstatus, $rheader, $rbody);
}
$resp = json_decode($rbody, true);
return $resp;
}
|
[
"private",
"static",
"function",
"interpretResponse",
"(",
"$",
"rstatus",
",",
"$",
"rheader",
",",
"$",
"rbody",
")",
"{",
"if",
"(",
"$",
"rstatus",
"<",
"200",
"||",
"$",
"rstatus",
">=",
"300",
")",
"{",
"self",
"::",
"handleError",
"(",
"$",
"rstatus",
",",
"$",
"rheader",
",",
"$",
"rbody",
")",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"rbody",
")",
")",
"{",
"throw",
"new",
"Error",
"\\",
"Api",
"(",
"'Invalid response from API'",
",",
"$",
"rstatus",
",",
"$",
"rheader",
",",
"$",
"rbody",
")",
";",
"}",
"$",
"resp",
"=",
"json_decode",
"(",
"$",
"rbody",
",",
"true",
")",
";",
"return",
"$",
"resp",
";",
"}"
] |
Check response information. If it is valid one, JSON array will be returned.
@param int $rstatus HTTP Status.
@param array $rheader Response header.
@param string $rbody String of Response body.
@return array JSON array created from response body.
@throws Error\Api
|
[
"Check",
"response",
"information",
".",
"If",
"it",
"is",
"valid",
"one",
"JSON",
"array",
"will",
"be",
"returned",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/ApiObject.php#L167-L176
|
223,045
|
rpayonline/rpayonline-lite-php
|
lib/ApiObject.php
|
ApiObject.all
|
protected static function all($params, $opts)
{
$url = self::classUrl();
list($resp, $usedOpts) = self::request(self::METHOD_GET, $url, $params, $opts);
$resp = Util\Util::arrayToObject($resp, $usedOpts);
// Check the class name of the result because all feature must get the instance of Collection class.
if (!is_a($resp, 'RpayLite\\Collection')) {
$class = get_class($resp);
$msg = "'RpayLite\\Collection' is expected but '$class' is returned.";
throw new Error\Api($msg);
}
return $resp;
}
|
php
|
protected static function all($params, $opts)
{
$url = self::classUrl();
list($resp, $usedOpts) = self::request(self::METHOD_GET, $url, $params, $opts);
$resp = Util\Util::arrayToObject($resp, $usedOpts);
// Check the class name of the result because all feature must get the instance of Collection class.
if (!is_a($resp, 'RpayLite\\Collection')) {
$class = get_class($resp);
$msg = "'RpayLite\\Collection' is expected but '$class' is returned.";
throw new Error\Api($msg);
}
return $resp;
}
|
[
"protected",
"static",
"function",
"all",
"(",
"$",
"params",
",",
"$",
"opts",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"classUrl",
"(",
")",
";",
"list",
"(",
"$",
"resp",
",",
"$",
"usedOpts",
")",
"=",
"self",
"::",
"request",
"(",
"self",
"::",
"METHOD_GET",
",",
"$",
"url",
",",
"$",
"params",
",",
"$",
"opts",
")",
";",
"$",
"resp",
"=",
"Util",
"\\",
"Util",
"::",
"arrayToObject",
"(",
"$",
"resp",
",",
"$",
"usedOpts",
")",
";",
"// Check the class name of the result because all feature must get the instance of Collection class.",
"if",
"(",
"!",
"is_a",
"(",
"$",
"resp",
",",
"'RpayLite\\\\Collection'",
")",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"resp",
")",
";",
"$",
"msg",
"=",
"\"'RpayLite\\\\Collection' is expected but '$class' is returned.\"",
";",
"throw",
"new",
"Error",
"\\",
"Api",
"(",
"$",
"msg",
")",
";",
"}",
"return",
"$",
"resp",
";",
"}"
] |
Call API that will return the list which has multiple objects.
@param array $params Reuqest parameter.
@param array $opts Request header.
@return Collection List of RpayLiteObject
@throws Error\Api
|
[
"Call",
"API",
"that",
"will",
"return",
"the",
"list",
"which",
"has",
"multiple",
"objects",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/ApiObject.php#L237-L249
|
223,046
|
deesoft/yii2-angular
|
NgView.php
|
NgView.parseBlockJs
|
public static function parseBlockJs($js)
{
$jsBlockPattern = '|^<script[^>]*>(?P<block_content>.+?)</script>$|is';
if (preg_match($jsBlockPattern, trim($js), $matches)) {
$js = trim($matches['block_content']);
}
return $js;
}
|
php
|
public static function parseBlockJs($js)
{
$jsBlockPattern = '|^<script[^>]*>(?P<block_content>.+?)</script>$|is';
if (preg_match($jsBlockPattern, trim($js), $matches)) {
$js = trim($matches['block_content']);
}
return $js;
}
|
[
"public",
"static",
"function",
"parseBlockJs",
"(",
"$",
"js",
")",
"{",
"$",
"jsBlockPattern",
"=",
"'|^<script[^>]*>(?P<block_content>.+?)</script>$|is'",
";",
"if",
"(",
"preg_match",
"(",
"$",
"jsBlockPattern",
",",
"trim",
"(",
"$",
"js",
")",
",",
"$",
"matches",
")",
")",
"{",
"$",
"js",
"=",
"trim",
"(",
"$",
"matches",
"[",
"'block_content'",
"]",
")",
";",
"}",
"return",
"$",
"js",
";",
"}"
] |
Only get script inner of `script` tag.
@param string $js
@return string
|
[
"Only",
"get",
"script",
"inner",
"of",
"script",
"tag",
"."
] |
47ae76f615ef72b892405910ce1b67b89304b22e
|
https://github.com/deesoft/yii2-angular/blob/47ae76f615ef72b892405910ce1b67b89304b22e/NgView.php#L346-L353
|
223,047
|
symlex/doctrine-active-record
|
src/Model/EntityModel.php
|
EntityModel.wrapAll
|
protected function wrapAll(array $result): array
{
$modelName = $this->getModelName();
foreach ($result as &$entity) {
$entity = $this->createModel($modelName, $entity);
}
return $result;
}
|
php
|
protected function wrapAll(array $result): array
{
$modelName = $this->getModelName();
foreach ($result as &$entity) {
$entity = $this->createModel($modelName, $entity);
}
return $result;
}
|
[
"protected",
"function",
"wrapAll",
"(",
"array",
"$",
"result",
")",
":",
"array",
"{",
"$",
"modelName",
"=",
"$",
"this",
"->",
"getModelName",
"(",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"&",
"$",
"entity",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"createModel",
"(",
"$",
"modelName",
",",
"$",
"entity",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Wraps all DAO result entities in model instances
@param array $result
@return array
|
[
"Wraps",
"all",
"DAO",
"result",
"entities",
"in",
"model",
"instances"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/EntityModel.php#L105-L114
|
223,048
|
symlex/doctrine-active-record
|
src/Model/EntityModel.php
|
EntityModel.searchOne
|
public function searchOne(array $cond = array())
{
$options = array(
'count' => 1,
'offset' => 0
);
$result = $this->search($cond, $options);
if ($result['total'] != 1) {
throw new NotFoundException($result['total'] . ' matching items found');
}
return $result->getFirstResult();
}
|
php
|
public function searchOne(array $cond = array())
{
$options = array(
'count' => 1,
'offset' => 0
);
$result = $this->search($cond, $options);
if ($result['total'] != 1) {
throw new NotFoundException($result['total'] . ' matching items found');
}
return $result->getFirstResult();
}
|
[
"public",
"function",
"searchOne",
"(",
"array",
"$",
"cond",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'count'",
"=>",
"1",
",",
"'offset'",
"=>",
"0",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"search",
"(",
"$",
"cond",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"result",
"[",
"'total'",
"]",
"!=",
"1",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"$",
"result",
"[",
"'total'",
"]",
".",
"' matching items found'",
")",
";",
"}",
"return",
"$",
"result",
"->",
"getFirstResult",
"(",
")",
";",
"}"
] |
Search a single record; throws an exception if 0 or more than one record are found
@param array $cond The search conditions as array
@throws NotFoundException
@return EntityModel
|
[
"Search",
"a",
"single",
"record",
";",
"throws",
"an",
"exception",
"if",
"0",
"or",
"more",
"than",
"one",
"record",
"are",
"found"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/EntityModel.php#L172-L186
|
223,049
|
symlex/doctrine-active-record
|
src/Model/EntityModel.php
|
EntityModel.searchIds
|
public function searchIds(array $cond, array $options = array()): SearchResult
{
$params = $options + array('cond' => $cond);
$params['ids_only'] = true;
$result = $this->getEntityDao()->search($params);
if (!$result instanceof SearchResult) {
throw new FindException('Data Access Object did not return a search result');
}
return $result;
}
|
php
|
public function searchIds(array $cond, array $options = array()): SearchResult
{
$params = $options + array('cond' => $cond);
$params['ids_only'] = true;
$result = $this->getEntityDao()->search($params);
if (!$result instanceof SearchResult) {
throw new FindException('Data Access Object did not return a search result');
}
return $result;
}
|
[
"public",
"function",
"searchIds",
"(",
"array",
"$",
"cond",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
":",
"SearchResult",
"{",
"$",
"params",
"=",
"$",
"options",
"+",
"array",
"(",
"'cond'",
"=>",
"$",
"cond",
")",
";",
"$",
"params",
"[",
"'ids_only'",
"]",
"=",
"true",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"getEntityDao",
"(",
")",
"->",
"search",
"(",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"result",
"instanceof",
"SearchResult",
")",
"{",
"throw",
"new",
"FindException",
"(",
"'Data Access Object did not return a search result'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns an array of matching primary keys for the given search condition
@param array $cond
@param array $options
@throws FindException
@return SearchResult
|
[
"Returns",
"an",
"array",
"of",
"matching",
"primary",
"keys",
"for",
"the",
"given",
"search",
"condition"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/EntityModel.php#L196-L209
|
223,050
|
symlex/doctrine-active-record
|
src/Model/EntityModel.php
|
EntityModel.batchEdit
|
public function batchEdit(array $ids, array $properties)
{
$this->getEntityDao()->beginTransaction();
try {
foreach ($ids as $id) {
/** @var EntityDao $dao */
$dao = $this->createDao();
$dao->find($id);
foreach ($properties as $key => $value) {
$dao->$key = $value;
}
$dao->update();
}
$this->getEntityDao()->commit();
} catch (Exception $e) {
$this->getEntityDao()->rollBack();
throw new UpdateException ('Batch edit was not successful: ' . $e->getMessage());
}
return $this;
}
|
php
|
public function batchEdit(array $ids, array $properties)
{
$this->getEntityDao()->beginTransaction();
try {
foreach ($ids as $id) {
/** @var EntityDao $dao */
$dao = $this->createDao();
$dao->find($id);
foreach ($properties as $key => $value) {
$dao->$key = $value;
}
$dao->update();
}
$this->getEntityDao()->commit();
} catch (Exception $e) {
$this->getEntityDao()->rollBack();
throw new UpdateException ('Batch edit was not successful: ' . $e->getMessage());
}
return $this;
}
|
[
"public",
"function",
"batchEdit",
"(",
"array",
"$",
"ids",
",",
"array",
"$",
"properties",
")",
"{",
"$",
"this",
"->",
"getEntityDao",
"(",
")",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"/** @var EntityDao $dao */",
"$",
"dao",
"=",
"$",
"this",
"->",
"createDao",
"(",
")",
";",
"$",
"dao",
"->",
"find",
"(",
"$",
"id",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"dao",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"$",
"dao",
"->",
"update",
"(",
")",
";",
"}",
"$",
"this",
"->",
"getEntityDao",
"(",
")",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"getEntityDao",
"(",
")",
"->",
"rollBack",
"(",
")",
";",
"throw",
"new",
"UpdateException",
"(",
"'Batch edit was not successful: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Update the data of multiple DAO instances
@param array $ids The IDs (primary keys) of the entities to be changed
@param array $properties The properties to be changed
@throws UpdateException
@return object this
|
[
"Update",
"the",
"data",
"of",
"multiple",
"DAO",
"instances"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/EntityModel.php#L295-L321
|
223,051
|
symlex/doctrine-active-record
|
src/Model/EntityModel.php
|
EntityModel.delete
|
public function delete()
{
if (!$this->hasId()) {
throw new DeleteException('ID not set - did you call find($id) before delete()?');
}
if (!$this->isDeletable()) {
throw new DeleteException('Permission denied: Entity can not be deleted');
}
$this->transactional(function () {
$this->forceDelete();
});
return $this;
}
|
php
|
public function delete()
{
if (!$this->hasId()) {
throw new DeleteException('ID not set - did you call find($id) before delete()?');
}
if (!$this->isDeletable()) {
throw new DeleteException('Permission denied: Entity can not be deleted');
}
$this->transactional(function () {
$this->forceDelete();
});
return $this;
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasId",
"(",
")",
")",
"{",
"throw",
"new",
"DeleteException",
"(",
"'ID not set - did you call find($id) before delete()?'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isDeletable",
"(",
")",
")",
"{",
"throw",
"new",
"DeleteException",
"(",
"'Permission denied: Entity can not be deleted'",
")",
";",
"}",
"$",
"this",
"->",
"transactional",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"forceDelete",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Permanently deletes the entity instance
@throws DeleteException
@throws \Doctrine\DBAL\DBALException
@return $this
|
[
"Permanently",
"deletes",
"the",
"entity",
"instance"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/EntityModel.php#L390-L405
|
223,052
|
symlex/doctrine-active-record
|
src/Model/EntityModel.php
|
EntityModel.update
|
public function update(array $values)
{
if (!$this->hasId()) {
throw new UpdateException('ID not set - did you call find($id) before update($values)?');
}
if (!$this->isUpdatable()) {
throw new UpdateException('Permission denied: Entity can not be updated');
}
$this->transactional(function () use ($values) {
$this->forceUpdate($values);
});
return $this;
}
|
php
|
public function update(array $values)
{
if (!$this->hasId()) {
throw new UpdateException('ID not set - did you call find($id) before update($values)?');
}
if (!$this->isUpdatable()) {
throw new UpdateException('Permission denied: Entity can not be updated');
}
$this->transactional(function () use ($values) {
$this->forceUpdate($values);
});
return $this;
}
|
[
"public",
"function",
"update",
"(",
"array",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasId",
"(",
")",
")",
"{",
"throw",
"new",
"UpdateException",
"(",
"'ID not set - did you call find($id) before update($values)?'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isUpdatable",
"(",
")",
")",
"{",
"throw",
"new",
"UpdateException",
"(",
"'Permission denied: Entity can not be updated'",
")",
";",
"}",
"$",
"this",
"->",
"transactional",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"values",
")",
"{",
"$",
"this",
"->",
"forceUpdate",
"(",
"$",
"values",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Updates the entity using the given values
@param array $values
@throws UpdateException
@throws \Doctrine\DBAL\DBALException
@return $this
|
[
"Updates",
"the",
"entity",
"using",
"the",
"given",
"values"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/EntityModel.php#L432-L447
|
223,053
|
symlex/doctrine-active-record
|
src/Model/EntityModel.php
|
EntityModel.forceUpdate
|
public function forceUpdate(array $values)
{
$dao = $this->getEntityDao();
$dao->setValues($values);
$dao->update();
return $this;
}
|
php
|
public function forceUpdate(array $values)
{
$dao = $this->getEntityDao();
$dao->setValues($values);
$dao->update();
return $this;
}
|
[
"public",
"function",
"forceUpdate",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"dao",
"=",
"$",
"this",
"->",
"getEntityDao",
"(",
")",
";",
"$",
"dao",
"->",
"setValues",
"(",
"$",
"values",
")",
";",
"$",
"dao",
"->",
"update",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Updates the entity without transaction & permission checks
@param array $values
@throws \Doctrine\DBAL\DBALException
@return $this
|
[
"Updates",
"the",
"entity",
"without",
"transaction",
"&",
"permission",
"checks"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/EntityModel.php#L456-L465
|
223,054
|
symlex/doctrine-active-record
|
src/Model/EntityModel.php
|
EntityModel.save
|
public function save(array $values)
{
if (!$this->isSavable()) {
throw new CreateException('Permission denied: Entity can not be saved');
}
$this->transactional(function () use ($values) {
$this->forceSave($values);
});
return $this;
}
|
php
|
public function save(array $values)
{
if (!$this->isSavable()) {
throw new CreateException('Permission denied: Entity can not be saved');
}
$this->transactional(function () use ($values) {
$this->forceSave($values);
});
return $this;
}
|
[
"public",
"function",
"save",
"(",
"array",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isSavable",
"(",
")",
")",
"{",
"throw",
"new",
"CreateException",
"(",
"'Permission denied: Entity can not be saved'",
")",
";",
"}",
"$",
"this",
"->",
"transactional",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"values",
")",
"{",
"$",
"this",
"->",
"forceSave",
"(",
"$",
"values",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Save a new entity using the given values
@param array $values
@throws CreateException
@throws \Doctrine\DBAL\DBALException
@return $this
|
[
"Save",
"a",
"new",
"entity",
"using",
"the",
"given",
"values"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/EntityModel.php#L475-L486
|
223,055
|
symlex/doctrine-active-record
|
src/Model/EntityModel.php
|
EntityModel.forceSave
|
public function forceSave(array $values)
{
$dao = $this->getEntityDao();
$dao->setValues($values);
$dao->save();
$dao->reload();
return $this;
}
|
php
|
public function forceSave(array $values)
{
$dao = $this->getEntityDao();
$dao->setValues($values);
$dao->save();
$dao->reload();
return $this;
}
|
[
"public",
"function",
"forceSave",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"dao",
"=",
"$",
"this",
"->",
"getEntityDao",
"(",
")",
";",
"$",
"dao",
"->",
"setValues",
"(",
"$",
"values",
")",
";",
"$",
"dao",
"->",
"save",
"(",
")",
";",
"$",
"dao",
"->",
"reload",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Creates the entity without transaction & permission checks
@param array $values
@throws \Doctrine\DBAL\DBALException
@return $this
|
[
"Creates",
"the",
"entity",
"without",
"transaction",
"&",
"permission",
"checks"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/EntityModel.php#L495-L506
|
223,056
|
alexandresalome/multisite-bundle
|
Branding/Branding.php
|
Branding.getHost
|
public function getHost($locale)
{
if (!isset($this->localesConfig[$locale]['host'])) {
return null;
}
return $this->localesConfig[$locale]['host'];
}
|
php
|
public function getHost($locale)
{
if (!isset($this->localesConfig[$locale]['host'])) {
return null;
}
return $this->localesConfig[$locale]['host'];
}
|
[
"public",
"function",
"getHost",
"(",
"$",
"locale",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"localesConfig",
"[",
"$",
"locale",
"]",
"[",
"'host'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"localesConfig",
"[",
"$",
"locale",
"]",
"[",
"'host'",
"]",
";",
"}"
] |
Returns host configured for a locale, or null if not found.
@param string $locale
@return string|null returns a hostname or null if not found.
|
[
"Returns",
"host",
"configured",
"for",
"a",
"locale",
"or",
"null",
"if",
"not",
"found",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/Branding/Branding.php#L66-L73
|
223,057
|
alexandresalome/multisite-bundle
|
Branding/Branding.php
|
Branding.prefixPath
|
public function prefixPath($locale, $path)
{
if (isset($this->localesConfig[$locale]['prefix'])) {
return $this->localesConfig[$locale]['prefix'].$path;
}
return $path;
}
|
php
|
public function prefixPath($locale, $path)
{
if (isset($this->localesConfig[$locale]['prefix'])) {
return $this->localesConfig[$locale]['prefix'].$path;
}
return $path;
}
|
[
"public",
"function",
"prefixPath",
"(",
"$",
"locale",
",",
"$",
"path",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"localesConfig",
"[",
"$",
"locale",
"]",
"[",
"'prefix'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"localesConfig",
"[",
"$",
"locale",
"]",
"[",
"'prefix'",
"]",
".",
"$",
"path",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Prefixes the path for a given locale, if a prefix is configured.
``prefixPath`` will return the path if no prefix is configured.
@param string $locale
@param string $path
@return string
|
[
"Prefixes",
"the",
"path",
"for",
"a",
"given",
"locale",
"if",
"a",
"prefix",
"is",
"configured",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/Branding/Branding.php#L85-L92
|
223,058
|
alexandresalome/multisite-bundle
|
Branding/Branding.php
|
Branding.getOption
|
public function getOption($locale, $name, $default = null)
{
return isset($this->localesConfig[$locale][$name]) ? $this->localesConfig[$locale][$name] : $default;
}
|
php
|
public function getOption($locale, $name, $default = null)
{
return isset($this->localesConfig[$locale][$name]) ? $this->localesConfig[$locale][$name] : $default;
}
|
[
"public",
"function",
"getOption",
"(",
"$",
"locale",
",",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"localesConfig",
"[",
"$",
"locale",
"]",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"localesConfig",
"[",
"$",
"locale",
"]",
"[",
"$",
"name",
"]",
":",
"$",
"default",
";",
"}"
] |
Returns value of an option.
@param string $locale
@param string $name
@param mixed $default
@return mixed
|
[
"Returns",
"value",
"of",
"an",
"option",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/Branding/Branding.php#L103-L106
|
223,059
|
emilio/php-router
|
src/Router/Route.php
|
Route.matches
|
public function matches($path)
{
if (preg_match($this->expr, $path, $this->matches) &&
in_array($_SERVER['REQUEST_METHOD'], $this->methods)) {
return true;
}
return false;
}
|
php
|
public function matches($path)
{
if (preg_match($this->expr, $path, $this->matches) &&
in_array($_SERVER['REQUEST_METHOD'], $this->methods)) {
return true;
}
return false;
}
|
[
"public",
"function",
"matches",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"this",
"->",
"expr",
",",
"$",
"path",
",",
"$",
"this",
"->",
"matches",
")",
"&&",
"in_array",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
",",
"$",
"this",
"->",
"methods",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
See if route matches with path
@param string $path
@return boolean
|
[
"See",
"if",
"route",
"matches",
"with",
"path"
] |
55ae2f3a6417a2327715402edb7b404001c5a04f
|
https://github.com/emilio/php-router/blob/55ae2f3a6417a2327715402edb7b404001c5a04f/src/Router/Route.php#L45-L53
|
223,060
|
DevGroup-ru/yii2-tag-dependency-helper
|
src/TagDependencyTrait.php
|
TagDependencyTrait.objectTag
|
public function objectTag($oldFields = [])
{
/** @var \yii\db\ActiveRecord $this */
$primaryKey = null;
if (count($this->primaryKey()) === 1)
{
$key = $this->primaryKey()[0];
$primaryKey = isset($oldFields[$key]) ? $oldFields[$key] : $this->$key;
} else {
$primaryKey = [];
foreach ($this->primaryKey() as $key)
{
$primaryKey[$key] = isset($oldFields[$key]) ? $oldFields[$key] : $this->$key;
}
}
return NamingHelper::getObjectTag($this->className(), $primaryKey);
}
|
php
|
public function objectTag($oldFields = [])
{
/** @var \yii\db\ActiveRecord $this */
$primaryKey = null;
if (count($this->primaryKey()) === 1)
{
$key = $this->primaryKey()[0];
$primaryKey = isset($oldFields[$key]) ? $oldFields[$key] : $this->$key;
} else {
$primaryKey = [];
foreach ($this->primaryKey() as $key)
{
$primaryKey[$key] = isset($oldFields[$key]) ? $oldFields[$key] : $this->$key;
}
}
return NamingHelper::getObjectTag($this->className(), $primaryKey);
}
|
[
"public",
"function",
"objectTag",
"(",
"$",
"oldFields",
"=",
"[",
"]",
")",
"{",
"/** @var \\yii\\db\\ActiveRecord $this */",
"$",
"primaryKey",
"=",
"null",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"primaryKey",
"(",
")",
")",
"===",
"1",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"primaryKey",
"(",
")",
"[",
"0",
"]",
";",
"$",
"primaryKey",
"=",
"isset",
"(",
"$",
"oldFields",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"oldFields",
"[",
"$",
"key",
"]",
":",
"$",
"this",
"->",
"$",
"key",
";",
"}",
"else",
"{",
"$",
"primaryKey",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"primaryKey",
"(",
")",
"as",
"$",
"key",
")",
"{",
"$",
"primaryKey",
"[",
"$",
"key",
"]",
"=",
"isset",
"(",
"$",
"oldFields",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"oldFields",
"[",
"$",
"key",
"]",
":",
"$",
"this",
"->",
"$",
"key",
";",
"}",
"}",
"return",
"NamingHelper",
"::",
"getObjectTag",
"(",
"$",
"this",
"->",
"className",
"(",
")",
",",
"$",
"primaryKey",
")",
";",
"}"
] |
Returns object tag name including it's id
@param array $oldFields Changed fields from Update Event
@return string tag name
|
[
"Returns",
"object",
"tag",
"name",
"including",
"it",
"s",
"id"
] |
23e7d26df35fc9605aa674f03cd701f46909214a
|
https://github.com/DevGroup-ru/yii2-tag-dependency-helper/blob/23e7d26df35fc9605aa674f03cd701f46909214a/src/TagDependencyTrait.php#L44-L60
|
223,061
|
DevGroup-ru/yii2-tag-dependency-helper
|
src/TagDependencyTrait.php
|
TagDependencyTrait.objectCompositeTag
|
public function objectCompositeTag($oldFields = [])
{
/** @var \yii\db\ActiveRecord|TagDependencyTrait $this */
$cacheFields = $this->cacheCompositeTagFields();
if(empty($cacheFields)) {
return [];
}
$cacheFields = (is_array($cacheFields) && !empty($cacheFields) && is_array($cacheFields[0])) ? $cacheFields : [$cacheFields];
$tags = [];
foreach ($cacheFields as $tagFields) {
$tag = [];
$changed = false;
foreach ($tagFields as $tagField) {
$tag[$tagField] = $this->$tagField;
$changed |= isset($oldFields[$tagField]);
}
$tags[] = NamingHelper::getCompositeTag($this->className(), $tag);
if ($changed) {
$tag = [];
foreach ($tagFields as $tagField) {
$tag[$tagField] = isset($oldFields[$tagField]) ? $oldFields[$tagField] : $this->$tagField;
}
$tags[] = NamingHelper::getCompositeTag($this->className(), $tag);
}
}
return $tags;
}
|
php
|
public function objectCompositeTag($oldFields = [])
{
/** @var \yii\db\ActiveRecord|TagDependencyTrait $this */
$cacheFields = $this->cacheCompositeTagFields();
if(empty($cacheFields)) {
return [];
}
$cacheFields = (is_array($cacheFields) && !empty($cacheFields) && is_array($cacheFields[0])) ? $cacheFields : [$cacheFields];
$tags = [];
foreach ($cacheFields as $tagFields) {
$tag = [];
$changed = false;
foreach ($tagFields as $tagField) {
$tag[$tagField] = $this->$tagField;
$changed |= isset($oldFields[$tagField]);
}
$tags[] = NamingHelper::getCompositeTag($this->className(), $tag);
if ($changed) {
$tag = [];
foreach ($tagFields as $tagField) {
$tag[$tagField] = isset($oldFields[$tagField]) ? $oldFields[$tagField] : $this->$tagField;
}
$tags[] = NamingHelper::getCompositeTag($this->className(), $tag);
}
}
return $tags;
}
|
[
"public",
"function",
"objectCompositeTag",
"(",
"$",
"oldFields",
"=",
"[",
"]",
")",
"{",
"/** @var \\yii\\db\\ActiveRecord|TagDependencyTrait $this */",
"$",
"cacheFields",
"=",
"$",
"this",
"->",
"cacheCompositeTagFields",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"cacheFields",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"cacheFields",
"=",
"(",
"is_array",
"(",
"$",
"cacheFields",
")",
"&&",
"!",
"empty",
"(",
"$",
"cacheFields",
")",
"&&",
"is_array",
"(",
"$",
"cacheFields",
"[",
"0",
"]",
")",
")",
"?",
"$",
"cacheFields",
":",
"[",
"$",
"cacheFields",
"]",
";",
"$",
"tags",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"cacheFields",
"as",
"$",
"tagFields",
")",
"{",
"$",
"tag",
"=",
"[",
"]",
";",
"$",
"changed",
"=",
"false",
";",
"foreach",
"(",
"$",
"tagFields",
"as",
"$",
"tagField",
")",
"{",
"$",
"tag",
"[",
"$",
"tagField",
"]",
"=",
"$",
"this",
"->",
"$",
"tagField",
";",
"$",
"changed",
"|=",
"isset",
"(",
"$",
"oldFields",
"[",
"$",
"tagField",
"]",
")",
";",
"}",
"$",
"tags",
"[",
"]",
"=",
"NamingHelper",
"::",
"getCompositeTag",
"(",
"$",
"this",
"->",
"className",
"(",
")",
",",
"$",
"tag",
")",
";",
"if",
"(",
"$",
"changed",
")",
"{",
"$",
"tag",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tagFields",
"as",
"$",
"tagField",
")",
"{",
"$",
"tag",
"[",
"$",
"tagField",
"]",
"=",
"isset",
"(",
"$",
"oldFields",
"[",
"$",
"tagField",
"]",
")",
"?",
"$",
"oldFields",
"[",
"$",
"tagField",
"]",
":",
"$",
"this",
"->",
"$",
"tagField",
";",
"}",
"$",
"tags",
"[",
"]",
"=",
"NamingHelper",
"::",
"getCompositeTag",
"(",
"$",
"this",
"->",
"className",
"(",
")",
",",
"$",
"tag",
")",
";",
"}",
"}",
"return",
"$",
"tags",
";",
"}"
] |
Returns composite tags name including fields
@param array $oldFields Changed fields from Update Event
@return array tag names
|
[
"Returns",
"composite",
"tags",
"name",
"including",
"fields"
] |
23e7d26df35fc9605aa674f03cd701f46909214a
|
https://github.com/DevGroup-ru/yii2-tag-dependency-helper/blob/23e7d26df35fc9605aa674f03cd701f46909214a/src/TagDependencyTrait.php#L67-L100
|
223,062
|
DevGroup-ru/yii2-tag-dependency-helper
|
src/TagDependencyTrait.php
|
TagDependencyTrait.invalidateTags
|
public function invalidateTags($event = null)
{
/** @var TagDependencyTrait $this */
$oldFields = $event !== null && $event->name === ActiveRecord::EVENT_AFTER_UPDATE ? $event->changedAttributes : [];
\yii\caching\TagDependency::invalidate(
$this->getTagDependencyCacheComponent(),
[
static::commonTag(),
$this->objectTag($oldFields)
]
);
if ($this->cacheCompositeTagFields()) {
\yii\caching\TagDependency::invalidate(
$this->getTagDependencyCacheComponent(),
$this->objectCompositeTag($oldFields)
);
}
return true;
}
|
php
|
public function invalidateTags($event = null)
{
/** @var TagDependencyTrait $this */
$oldFields = $event !== null && $event->name === ActiveRecord::EVENT_AFTER_UPDATE ? $event->changedAttributes : [];
\yii\caching\TagDependency::invalidate(
$this->getTagDependencyCacheComponent(),
[
static::commonTag(),
$this->objectTag($oldFields)
]
);
if ($this->cacheCompositeTagFields()) {
\yii\caching\TagDependency::invalidate(
$this->getTagDependencyCacheComponent(),
$this->objectCompositeTag($oldFields)
);
}
return true;
}
|
[
"public",
"function",
"invalidateTags",
"(",
"$",
"event",
"=",
"null",
")",
"{",
"/** @var TagDependencyTrait $this */",
"$",
"oldFields",
"=",
"$",
"event",
"!==",
"null",
"&&",
"$",
"event",
"->",
"name",
"===",
"ActiveRecord",
"::",
"EVENT_AFTER_UPDATE",
"?",
"$",
"event",
"->",
"changedAttributes",
":",
"[",
"]",
";",
"\\",
"yii",
"\\",
"caching",
"\\",
"TagDependency",
"::",
"invalidate",
"(",
"$",
"this",
"->",
"getTagDependencyCacheComponent",
"(",
")",
",",
"[",
"static",
"::",
"commonTag",
"(",
")",
",",
"$",
"this",
"->",
"objectTag",
"(",
"$",
"oldFields",
")",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cacheCompositeTagFields",
"(",
")",
")",
"{",
"\\",
"yii",
"\\",
"caching",
"\\",
"TagDependency",
"::",
"invalidate",
"(",
"$",
"this",
"->",
"getTagDependencyCacheComponent",
"(",
")",
",",
"$",
"this",
"->",
"objectCompositeTag",
"(",
"$",
"oldFields",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Invalidate model tags.
@param yii\db\AfterSaveEvent|null $event when called as an event handler.
@return bool
|
[
"Invalidate",
"model",
"tags",
"."
] |
23e7d26df35fc9605aa674f03cd701f46909214a
|
https://github.com/DevGroup-ru/yii2-tag-dependency-helper/blob/23e7d26df35fc9605aa674f03cd701f46909214a/src/TagDependencyTrait.php#L191-L211
|
223,063
|
rpayonline/rpayonline-lite-php
|
lib/Notification.php
|
Notification.retrieve
|
public static function retrieve($charge, $id, $opts = null)
{
$list = self::all(array('id' => $id), $opts);
$nt = new Notification();
$nt->install($list->data[0]->values, $list->opts);
return $nt;
}
|
php
|
public static function retrieve($charge, $id, $opts = null)
{
$list = self::all(array('id' => $id), $opts);
$nt = new Notification();
$nt->install($list->data[0]->values, $list->opts);
return $nt;
}
|
[
"public",
"static",
"function",
"retrieve",
"(",
"$",
"charge",
",",
"$",
"id",
",",
"$",
"opts",
"=",
"null",
")",
"{",
"$",
"list",
"=",
"self",
"::",
"all",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
",",
"$",
"opts",
")",
";",
"$",
"nt",
"=",
"new",
"Notification",
"(",
")",
";",
"$",
"nt",
"->",
"install",
"(",
"$",
"list",
"->",
"data",
"[",
"0",
"]",
"->",
"values",
",",
"$",
"list",
"->",
"opts",
")",
";",
"return",
"$",
"nt",
";",
"}"
] |
Get Notification object which has specific ID and Charge ID.
@param string $charge
@param string $id
@param array $opts
@return Notification
|
[
"Get",
"Notification",
"object",
"which",
"has",
"specific",
"ID",
"and",
"Charge",
"ID",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Notification.php#L28-L34
|
223,064
|
rpayonline/rpayonline-lite-php
|
lib/Notification.php
|
Notification.all
|
public static function all($params, $opts = null)
{
$list = parent::all($params, $opts);
$ntList = new NotificationCollection();
$ntList->install($list->values, $list->opts);
return $ntList;
}
|
php
|
public static function all($params, $opts = null)
{
$list = parent::all($params, $opts);
$ntList = new NotificationCollection();
$ntList->install($list->values, $list->opts);
return $ntList;
}
|
[
"public",
"static",
"function",
"all",
"(",
"$",
"params",
",",
"$",
"opts",
"=",
"null",
")",
"{",
"$",
"list",
"=",
"parent",
"::",
"all",
"(",
"$",
"params",
",",
"$",
"opts",
")",
";",
"$",
"ntList",
"=",
"new",
"NotificationCollection",
"(",
")",
";",
"$",
"ntList",
"->",
"install",
"(",
"$",
"list",
"->",
"values",
",",
"$",
"list",
"->",
"opts",
")",
";",
"return",
"$",
"ntList",
";",
"}"
] |
Get Notification list
@param array $params Request parameters.
@param array $opts Request headers.
@return NotificationCollection
@link https://lite.checkout.rakuten.co.jp/manual/api#notification_list
|
[
"Get",
"Notification",
"list"
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Notification.php#L43-L49
|
223,065
|
rpayonline/rpayonline-lite-php
|
lib/Notification.php
|
Notification.refresh
|
public function refresh()
{
list($resp, $usedOpts) = self::request(self::METHOD_GET, self::instanceUrl());
$body = isset($resp['data'][0]) ? $resp['data'][0] : null;
$this->install($body, $usedOpts);
return $this;
}
|
php
|
public function refresh()
{
list($resp, $usedOpts) = self::request(self::METHOD_GET, self::instanceUrl());
$body = isset($resp['data'][0]) ? $resp['data'][0] : null;
$this->install($body, $usedOpts);
return $this;
}
|
[
"public",
"function",
"refresh",
"(",
")",
"{",
"list",
"(",
"$",
"resp",
",",
"$",
"usedOpts",
")",
"=",
"self",
"::",
"request",
"(",
"self",
"::",
"METHOD_GET",
",",
"self",
"::",
"instanceUrl",
"(",
")",
")",
";",
"$",
"body",
"=",
"isset",
"(",
"$",
"resp",
"[",
"'data'",
"]",
"[",
"0",
"]",
")",
"?",
"$",
"resp",
"[",
"'data'",
"]",
"[",
"0",
"]",
":",
"null",
";",
"$",
"this",
"->",
"install",
"(",
"$",
"body",
",",
"$",
"usedOpts",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Update Notification object information to the latest.
@return Notification $this
|
[
"Update",
"Notification",
"object",
"information",
"to",
"the",
"latest",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Notification.php#L70-L76
|
223,066
|
symlex/doctrine-active-record
|
src/Dao/Dao.php
|
Dao.fetchSingleValue
|
protected function fetchSingleValue($statement, array $params = array(), array $types = array())
{
return $this->getDb()->fetchColumn($statement, $params, 0, $types);
}
|
php
|
protected function fetchSingleValue($statement, array $params = array(), array $types = array())
{
return $this->getDb()->fetchColumn($statement, $params, 0, $types);
}
|
[
"protected",
"function",
"fetchSingleValue",
"(",
"$",
"statement",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
",",
"array",
"$",
"types",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getDb",
"(",
")",
"->",
"fetchColumn",
"(",
"$",
"statement",
",",
"$",
"params",
",",
"0",
",",
"$",
"types",
")",
";",
"}"
] |
Returns value of the first column of the first row
@param string $statement The SQL query.
@param array $params The prepared statement params.
@param array $types The query parameter types.
@return mixed
@throws Exception
|
[
"Returns",
"value",
"of",
"the",
"first",
"column",
"of",
"the",
"first",
"row"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Dao/Dao.php#L254-L257
|
223,067
|
symlex/doctrine-active-record
|
src/Dao/Dao.php
|
Dao.fetchCol
|
protected function fetchCol($statement, array $params = array(), array $types = array()): array
{
$result = array();
$rows = $this->getDb()->fetchAll($statement, $params, $types);
foreach ($rows as $row) {
$result[] = current($row);
}
return $result;
}
|
php
|
protected function fetchCol($statement, array $params = array(), array $types = array()): array
{
$result = array();
$rows = $this->getDb()->fetchAll($statement, $params, $types);
foreach ($rows as $row) {
$result[] = current($row);
}
return $result;
}
|
[
"protected",
"function",
"fetchCol",
"(",
"$",
"statement",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
",",
"array",
"$",
"types",
"=",
"array",
"(",
")",
")",
":",
"array",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"rows",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
"->",
"fetchAll",
"(",
"$",
"statement",
",",
"$",
"params",
",",
"$",
"types",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"current",
"(",
"$",
"row",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns values of the first column as array
@param string $statement The SQL query.
@param array $params The prepared statement params.
@param array $types The query parameter types.
@return array
|
[
"Returns",
"values",
"of",
"the",
"first",
"column",
"as",
"array"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Dao/Dao.php#L267-L278
|
223,068
|
symlex/doctrine-active-record
|
src/Dao/Dao.php
|
Dao.describeTable
|
protected function describeTable(string $tableName): array
{
if (isset($this->_tableDescription[$tableName])) {
return $this->_tableDescription[$tableName];
}
$result = array();
$statement = 'DESCRIBE ' . $this->getDb()->quoteIdentifier($tableName);
$cols = $this->fetchAll($statement);
foreach ($cols as $col) {
$result[$col['Field']] = $col['Type'];
}
$this->_tableDescription[$tableName] = $result;
return $result;
}
|
php
|
protected function describeTable(string $tableName): array
{
if (isset($this->_tableDescription[$tableName])) {
return $this->_tableDescription[$tableName];
}
$result = array();
$statement = 'DESCRIBE ' . $this->getDb()->quoteIdentifier($tableName);
$cols = $this->fetchAll($statement);
foreach ($cols as $col) {
$result[$col['Field']] = $col['Type'];
}
$this->_tableDescription[$tableName] = $result;
return $result;
}
|
[
"protected",
"function",
"describeTable",
"(",
"string",
"$",
"tableName",
")",
":",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_tableDescription",
"[",
"$",
"tableName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_tableDescription",
"[",
"$",
"tableName",
"]",
";",
"}",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"statement",
"=",
"'DESCRIBE '",
".",
"$",
"this",
"->",
"getDb",
"(",
")",
"->",
"quoteIdentifier",
"(",
"$",
"tableName",
")",
";",
"$",
"cols",
"=",
"$",
"this",
"->",
"fetchAll",
"(",
"$",
"statement",
")",
";",
"foreach",
"(",
"$",
"cols",
"as",
"$",
"col",
")",
"{",
"$",
"result",
"[",
"$",
"col",
"[",
"'Field'",
"]",
"]",
"=",
"$",
"col",
"[",
"'Type'",
"]",
";",
"}",
"$",
"this",
"->",
"_tableDescription",
"[",
"$",
"tableName",
"]",
"=",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}"
] |
Returns column names and types as array
@param string $tableName
@return array
|
[
"Returns",
"column",
"names",
"and",
"types",
"as",
"array"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Dao/Dao.php#L286-L303
|
223,069
|
dan-da/coinparams
|
bindings/php/CoinParams.php
|
CoinParams.get_coin_network
|
static public function get_coin_network($symbol, $network, $silentfail=false) {
$data = self::get_coin($symbol, $silentfail);
$info = @$data[$network];
if( !$info && !$silentfail ) {
throw new \Exception("Network not found: $symbol/$network");
}
return $info;
}
|
php
|
static public function get_coin_network($symbol, $network, $silentfail=false) {
$data = self::get_coin($symbol, $silentfail);
$info = @$data[$network];
if( !$info && !$silentfail ) {
throw new \Exception("Network not found: $symbol/$network");
}
return $info;
}
|
[
"static",
"public",
"function",
"get_coin_network",
"(",
"$",
"symbol",
",",
"$",
"network",
",",
"$",
"silentfail",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"self",
"::",
"get_coin",
"(",
"$",
"symbol",
",",
"$",
"silentfail",
")",
";",
"$",
"info",
"=",
"@",
"$",
"data",
"[",
"$",
"network",
"]",
";",
"if",
"(",
"!",
"$",
"info",
"&&",
"!",
"$",
"silentfail",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Network not found: $symbol/$network\"",
")",
";",
"}",
"return",
"$",
"info",
";",
"}"
] |
returns information about coin+network
throws an exception if $symbol is not found,
unless $silentfail is true.
|
[
"returns",
"information",
"about",
"coin",
"+",
"network"
] |
c1f2be4ed7e416ecd088e775914de3b7456a2974
|
https://github.com/dan-da/coinparams/blob/c1f2be4ed7e416ecd088e775914de3b7456a2974/bindings/php/CoinParams.php#L30-L39
|
223,070
|
dan-da/coinparams
|
bindings/php/CoinParams.php
|
CoinParams.get_all_coins
|
static public function get_all_coins() {
static $data = null;
if( $data ) {
return $data;
}
$buf = self::get_raw_json();
$data = @json_decode($buf, true);
if( !$data ) {
throw new \Exception("Unable to parse json: " . json_last_error_msg());
}
return $data;
}
|
php
|
static public function get_all_coins() {
static $data = null;
if( $data ) {
return $data;
}
$buf = self::get_raw_json();
$data = @json_decode($buf, true);
if( !$data ) {
throw new \Exception("Unable to parse json: " . json_last_error_msg());
}
return $data;
}
|
[
"static",
"public",
"function",
"get_all_coins",
"(",
")",
"{",
"static",
"$",
"data",
"=",
"null",
";",
"if",
"(",
"$",
"data",
")",
"{",
"return",
"$",
"data",
";",
"}",
"$",
"buf",
"=",
"self",
"::",
"get_raw_json",
"(",
")",
";",
"$",
"data",
"=",
"@",
"json_decode",
"(",
"$",
"buf",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Unable to parse json: \"",
".",
"json_last_error_msg",
"(",
")",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
returns parsed json data for all coins
data is cached between calls after initial read.
|
[
"returns",
"parsed",
"json",
"data",
"for",
"all",
"coins"
] |
c1f2be4ed7e416ecd088e775914de3b7456a2974
|
https://github.com/dan-da/coinparams/blob/c1f2be4ed7e416ecd088e775914de3b7456a2974/bindings/php/CoinParams.php#L61-L72
|
223,071
|
alexandresalome/multisite-bundle
|
Router/MultisiteRouter.php
|
MultisiteRouter.sortRoutes
|
protected function sortRoutes(array $routes)
{
if (!$this->sortRoutes) {
return $routes;
}
// group by host is a good-enough strategy for most of the cases
$hosts = array();
foreach ($routes as $name => $route) {
$branding = $route->getDefault('_branding');
$locale = $route->getDefault('_locale');
$hosts[$branding.'__'.$locale][$name] = $route;
}
return call_user_func_array('array_merge', $hosts);
}
|
php
|
protected function sortRoutes(array $routes)
{
if (!$this->sortRoutes) {
return $routes;
}
// group by host is a good-enough strategy for most of the cases
$hosts = array();
foreach ($routes as $name => $route) {
$branding = $route->getDefault('_branding');
$locale = $route->getDefault('_locale');
$hosts[$branding.'__'.$locale][$name] = $route;
}
return call_user_func_array('array_merge', $hosts);
}
|
[
"protected",
"function",
"sortRoutes",
"(",
"array",
"$",
"routes",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sortRoutes",
")",
"{",
"return",
"$",
"routes",
";",
"}",
"// group by host is a good-enough strategy for most of the cases",
"$",
"hosts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"name",
"=>",
"$",
"route",
")",
"{",
"$",
"branding",
"=",
"$",
"route",
"->",
"getDefault",
"(",
"'_branding'",
")",
";",
"$",
"locale",
"=",
"$",
"route",
"->",
"getDefault",
"(",
"'_locale'",
")",
";",
"$",
"hosts",
"[",
"$",
"branding",
".",
"'__'",
".",
"$",
"locale",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"route",
";",
"}",
"return",
"call_user_func_array",
"(",
"'array_merge'",
",",
"$",
"hosts",
")",
";",
"}"
] |
Sort routes by domain.
@param Route[] $routes
@return Route[]
|
[
"Sort",
"routes",
"by",
"domain",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/Router/MultisiteRouter.php#L128-L143
|
223,072
|
alexandresalome/multisite-bundle
|
Router/MultisiteRouter.php
|
MultisiteRouter.setMatchContext
|
private function setMatchContext(array $match)
{
if (isset($match['_branding'])) {
$this->context->setParameter('_branding', $match['_branding']);
$this->siteContext->setCurrentBranding($this->siteContext->getBranding($match['_branding']));
}
if (isset($match['_locale'])) {
$this->context->setParameter('_locale', $match['_locale']);
$this->siteContext->setCurrentLocale($match['_locale']);
}
}
|
php
|
private function setMatchContext(array $match)
{
if (isset($match['_branding'])) {
$this->context->setParameter('_branding', $match['_branding']);
$this->siteContext->setCurrentBranding($this->siteContext->getBranding($match['_branding']));
}
if (isset($match['_locale'])) {
$this->context->setParameter('_locale', $match['_locale']);
$this->siteContext->setCurrentLocale($match['_locale']);
}
}
|
[
"private",
"function",
"setMatchContext",
"(",
"array",
"$",
"match",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"match",
"[",
"'_branding'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"setParameter",
"(",
"'_branding'",
",",
"$",
"match",
"[",
"'_branding'",
"]",
")",
";",
"$",
"this",
"->",
"siteContext",
"->",
"setCurrentBranding",
"(",
"$",
"this",
"->",
"siteContext",
"->",
"getBranding",
"(",
"$",
"match",
"[",
"'_branding'",
"]",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"match",
"[",
"'_locale'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"setParameter",
"(",
"'_locale'",
",",
"$",
"match",
"[",
"'_locale'",
"]",
")",
";",
"$",
"this",
"->",
"siteContext",
"->",
"setCurrentLocale",
"(",
"$",
"match",
"[",
"'_locale'",
"]",
")",
";",
"}",
"}"
] |
Changes router context and site context according to matched route.
@param array $match
|
[
"Changes",
"router",
"context",
"and",
"site",
"context",
"according",
"to",
"matched",
"route",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/Router/MultisiteRouter.php#L164-L177
|
223,073
|
krombox/oauth2-wordpress
|
src/Provider/WordPressResourceOwner.php
|
WordPressResourceOwner.getAvatarUrl
|
public function getAvatarUrl($size = 96)
{
$avatarUrls = $this->getValueByKey($this->response, 'avatar_urls');
return in_array($size, array('24','48','96')) ? $avatarUrls[$size] : null;
}
|
php
|
public function getAvatarUrl($size = 96)
{
$avatarUrls = $this->getValueByKey($this->response, 'avatar_urls');
return in_array($size, array('24','48','96')) ? $avatarUrls[$size] : null;
}
|
[
"public",
"function",
"getAvatarUrl",
"(",
"$",
"size",
"=",
"96",
")",
"{",
"$",
"avatarUrls",
"=",
"$",
"this",
"->",
"getValueByKey",
"(",
"$",
"this",
"->",
"response",
",",
"'avatar_urls'",
")",
";",
"return",
"in_array",
"(",
"$",
"size",
",",
"array",
"(",
"'24'",
",",
"'48'",
",",
"'96'",
")",
")",
"?",
"$",
"avatarUrls",
"[",
"$",
"size",
"]",
":",
"null",
";",
"}"
] |
Get resource owner avatar url
@return string|null
|
[
"Get",
"resource",
"owner",
"avatar",
"url"
] |
69e6e8d7f9f8c6e19b3f521b7d2f71dee9198095
|
https://github.com/krombox/oauth2-wordpress/blob/69e6e8d7f9f8c6e19b3f521b7d2f71dee9198095/src/Provider/WordPressResourceOwner.php#L75-L79
|
223,074
|
symlex/doctrine-active-record
|
src/Factory/FactoryAbstract.php
|
FactoryAbstract.getClassName
|
protected function getClassName($name) {
if (empty($name)) {
throw new $this->_factoryExceptionClassName ('$name must not be empty');
}
$result = $this->getFactoryNamespace() . '\\' . $name . $this->getFactoryPostfix();
if (!class_exists($result)) {
throw new $this->_factoryExceptionClassName ('Class "' . $result . '" does not exist');
}
return $result;
}
|
php
|
protected function getClassName($name) {
if (empty($name)) {
throw new $this->_factoryExceptionClassName ('$name must not be empty');
}
$result = $this->getFactoryNamespace() . '\\' . $name . $this->getFactoryPostfix();
if (!class_exists($result)) {
throw new $this->_factoryExceptionClassName ('Class "' . $result . '" does not exist');
}
return $result;
}
|
[
"protected",
"function",
"getClassName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"$",
"this",
"->",
"_factoryExceptionClassName",
"(",
"'$name must not be empty'",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"getFactoryNamespace",
"(",
")",
".",
"'\\\\'",
".",
"$",
"name",
".",
"$",
"this",
"->",
"getFactoryPostfix",
"(",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"result",
")",
")",
"{",
"throw",
"new",
"$",
"this",
"->",
"_factoryExceptionClassName",
"(",
"'Class \"'",
".",
"$",
"result",
".",
"'\" does not exist'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns complete class name
@param string $name
@return string
@throws FactoryException
|
[
"Returns",
"complete",
"class",
"name"
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Factory/FactoryAbstract.php#L87-L99
|
223,075
|
alexandresalome/multisite-bundle
|
Branding/SiteContext.php
|
SiteContext.getCurrentBranding
|
public function getCurrentBranding()
{
if (null === $this->currentBranding) {
return $this->getBranding($this->defaultBrandingName);
}
return $this->currentBranding;
}
|
php
|
public function getCurrentBranding()
{
if (null === $this->currentBranding) {
return $this->getBranding($this->defaultBrandingName);
}
return $this->currentBranding;
}
|
[
"public",
"function",
"getCurrentBranding",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"currentBranding",
")",
"{",
"return",
"$",
"this",
"->",
"getBranding",
"(",
"$",
"this",
"->",
"defaultBrandingName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"currentBranding",
";",
"}"
] |
Returns current branding.
@return Branding
|
[
"Returns",
"current",
"branding",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/Branding/SiteContext.php#L97-L104
|
223,076
|
alexandresalome/multisite-bundle
|
Branding/SiteContext.php
|
SiteContext.getBranding
|
public function getBranding($name)
{
foreach ($this->brandings as $branding) {
if ($branding->getName() === $name) {
return $branding;
}
}
$names = array_map(function ($branding) {
return $branding->getName();
}, $this->brandings);
throw new \InvalidArgumentException(sprintf('No branding named "%s". Available are: %s.', $name, implode(', ', $names)));
}
|
php
|
public function getBranding($name)
{
foreach ($this->brandings as $branding) {
if ($branding->getName() === $name) {
return $branding;
}
}
$names = array_map(function ($branding) {
return $branding->getName();
}, $this->brandings);
throw new \InvalidArgumentException(sprintf('No branding named "%s". Available are: %s.', $name, implode(', ', $names)));
}
|
[
"public",
"function",
"getBranding",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"brandings",
"as",
"$",
"branding",
")",
"{",
"if",
"(",
"$",
"branding",
"->",
"getName",
"(",
")",
"===",
"$",
"name",
")",
"{",
"return",
"$",
"branding",
";",
"}",
"}",
"$",
"names",
"=",
"array_map",
"(",
"function",
"(",
"$",
"branding",
")",
"{",
"return",
"$",
"branding",
"->",
"getName",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"brandings",
")",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'No branding named \"%s\". Available are: %s.'",
",",
"$",
"name",
",",
"implode",
"(",
"', '",
",",
"$",
"names",
")",
")",
")",
";",
"}"
] |
Returns a given branding.
@param string $name
@return Branding
|
[
"Returns",
"a",
"given",
"branding",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/Branding/SiteContext.php#L127-L140
|
223,077
|
alexandresalome/multisite-bundle
|
Branding/SiteContext.php
|
SiteContext.getBrandingsWithLocale
|
public function getBrandingsWithLocale($locale)
{
$result = array();
foreach ($this->brandings as $branding) {
if ($branding->hasLocale($locale)) {
$result[] = $branding;
}
}
return $result;
}
|
php
|
public function getBrandingsWithLocale($locale)
{
$result = array();
foreach ($this->brandings as $branding) {
if ($branding->hasLocale($locale)) {
$result[] = $branding;
}
}
return $result;
}
|
[
"public",
"function",
"getBrandingsWithLocale",
"(",
"$",
"locale",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"brandings",
"as",
"$",
"branding",
")",
"{",
"if",
"(",
"$",
"branding",
"->",
"hasLocale",
"(",
"$",
"locale",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"branding",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns brandings with a given locale.
@param string $locale
@return Branding[]
|
[
"Returns",
"brandings",
"with",
"a",
"given",
"locale",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/Branding/SiteContext.php#L149-L159
|
223,078
|
rpayonline/rpayonline-lite-php
|
lib/Util/Util.php
|
Util.isRpayLiteClassType
|
public static function isRpayLiteClassType($class, $type)
{
if (array_key_exists($class, self::$types)
&& in_array($type, self::$types[$class])) {
return true;
}
return false;
}
|
php
|
public static function isRpayLiteClassType($class, $type)
{
if (array_key_exists($class, self::$types)
&& in_array($type, self::$types[$class])) {
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"isRpayLiteClassType",
"(",
"$",
"class",
",",
"$",
"type",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"class",
",",
"self",
"::",
"$",
"types",
")",
"&&",
"in_array",
"(",
"$",
"type",
",",
"self",
"::",
"$",
"types",
"[",
"$",
"class",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Detect whether the given class and type are supported by this SDK.
@param string $class String included in the object "JSON" property.
@param string $type String included in the type "JSON" property.
@return bool
|
[
"Detect",
"whether",
"the",
"given",
"class",
"and",
"type",
"are",
"supported",
"by",
"this",
"SDK",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Util/Util.php#L53-L60
|
223,079
|
rpayonline/rpayonline-lite-php
|
lib/Util/Util.php
|
Util.arrayToObject
|
public static function arrayToObject($resp, $opts = null)
{
if (self::isIndexedArray($resp)) {
$objArray = array();
foreach ($resp as $val) {
array_push($objArray, self::arrayToObject($val, $opts));
}
return $objArray;
} elseif (is_array($resp)) {
if (isset($resp['object']) &&
# Event object may have object property as array, remove this case.
!is_array($resp['object']) &&
isset(self::$classes[$resp['object']])) {
$class = self::$classes[$resp['object']];
} else {
$class = 'RpayLite\\RpayLiteObject';
}
if (isset($resp['items'])) {
$resp['items'] = self::objectize('item', $resp['items']);
}
return $class::constructFrom($resp, $opts);
}
// In case of non-array object, return the value as is.
return $resp;
}
|
php
|
public static function arrayToObject($resp, $opts = null)
{
if (self::isIndexedArray($resp)) {
$objArray = array();
foreach ($resp as $val) {
array_push($objArray, self::arrayToObject($val, $opts));
}
return $objArray;
} elseif (is_array($resp)) {
if (isset($resp['object']) &&
# Event object may have object property as array, remove this case.
!is_array($resp['object']) &&
isset(self::$classes[$resp['object']])) {
$class = self::$classes[$resp['object']];
} else {
$class = 'RpayLite\\RpayLiteObject';
}
if (isset($resp['items'])) {
$resp['items'] = self::objectize('item', $resp['items']);
}
return $class::constructFrom($resp, $opts);
}
// In case of non-array object, return the value as is.
return $resp;
}
|
[
"public",
"static",
"function",
"arrayToObject",
"(",
"$",
"resp",
",",
"$",
"opts",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"isIndexedArray",
"(",
"$",
"resp",
")",
")",
"{",
"$",
"objArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"resp",
"as",
"$",
"val",
")",
"{",
"array_push",
"(",
"$",
"objArray",
",",
"self",
"::",
"arrayToObject",
"(",
"$",
"val",
",",
"$",
"opts",
")",
")",
";",
"}",
"return",
"$",
"objArray",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"resp",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"resp",
"[",
"'object'",
"]",
")",
"&&",
"# Event object may have object property as array, remove this case.",
"!",
"is_array",
"(",
"$",
"resp",
"[",
"'object'",
"]",
")",
"&&",
"isset",
"(",
"self",
"::",
"$",
"classes",
"[",
"$",
"resp",
"[",
"'object'",
"]",
"]",
")",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"$",
"classes",
"[",
"$",
"resp",
"[",
"'object'",
"]",
"]",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"'RpayLite\\\\RpayLiteObject'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"resp",
"[",
"'items'",
"]",
")",
")",
"{",
"$",
"resp",
"[",
"'items'",
"]",
"=",
"self",
"::",
"objectize",
"(",
"'item'",
",",
"$",
"resp",
"[",
"'items'",
"]",
")",
";",
"}",
"return",
"$",
"class",
"::",
"constructFrom",
"(",
"$",
"resp",
",",
"$",
"opts",
")",
";",
"}",
"// In case of non-array object, return the value as is.",
"return",
"$",
"resp",
";",
"}"
] |
Convert JSON array created by json_encode to any class instance which
is corresponding to the included "object" JSON property.
It returns the given value as is if the "object" does not exist.
@param mixed $resp
@param array $opts
@return RpayLiteObject|mixed RpayLiteObject or given value.
|
[
"Convert",
"JSON",
"array",
"created",
"by",
"json_encode",
"to",
"any",
"class",
"instance",
"which",
"is",
"corresponding",
"to",
"the",
"included",
"object",
"JSON",
"property",
".",
"It",
"returns",
"the",
"given",
"value",
"as",
"is",
"if",
"the",
"object",
"does",
"not",
"exist",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Util/Util.php#L70-L94
|
223,080
|
rpayonline/rpayonline-lite-php
|
lib/Util/Util.php
|
Util.objectToArray
|
public static function objectToArray($values)
{
$results = array();
foreach ($values as $key => $val) {
if ($val instanceof RpayLiteObject) {
$results[$key] = $val->__toArray(true);
} elseif (is_array($val)) {
$results[$key] = self::objectToArray($val);
} else {
$results[$key] = $val;
}
}
return $results;
}
|
php
|
public static function objectToArray($values)
{
$results = array();
foreach ($values as $key => $val) {
if ($val instanceof RpayLiteObject) {
$results[$key] = $val->__toArray(true);
} elseif (is_array($val)) {
$results[$key] = self::objectToArray($val);
} else {
$results[$key] = $val;
}
}
return $results;
}
|
[
"public",
"static",
"function",
"objectToArray",
"(",
"$",
"values",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"instanceof",
"RpayLiteObject",
")",
"{",
"$",
"results",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
"->",
"__toArray",
"(",
"true",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"$",
"results",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"objectToArray",
"(",
"$",
"val",
")",
";",
"}",
"else",
"{",
"$",
"results",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
] |
Convert RpayLiteObject to an array.
@param array $values RpayLiteObject object to convert.
@return array
|
[
"Convert",
"RpayLiteObject",
"to",
"an",
"array",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Util/Util.php#L101-L114
|
223,081
|
rpayonline/rpayonline-lite-php
|
lib/Util/Util.php
|
Util.objectize
|
public static function objectize($name, $elems)
{
$objectized = array();
foreach ($elems as $elem) {
$elem['object'] = $name;
array_push($objectized, $elem);
}
return $objectized;
}
|
php
|
public static function objectize($name, $elems)
{
$objectized = array();
foreach ($elems as $elem) {
$elem['object'] = $name;
array_push($objectized, $elem);
}
return $objectized;
}
|
[
"public",
"static",
"function",
"objectize",
"(",
"$",
"name",
",",
"$",
"elems",
")",
"{",
"$",
"objectized",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"elems",
"as",
"$",
"elem",
")",
"{",
"$",
"elem",
"[",
"'object'",
"]",
"=",
"$",
"name",
";",
"array_push",
"(",
"$",
"objectized",
",",
"$",
"elem",
")",
";",
"}",
"return",
"$",
"objectized",
";",
"}"
] |
Inject "object" property in to the given JSON object.
This feature is used for handling Item as the independent class.
Items is better to be class but it does not have "object" property.
@param string $name New value of object property.
@param array $elems Target JSON array.
@return array
|
[
"Inject",
"object",
"property",
"in",
"to",
"the",
"given",
"JSON",
"object",
".",
"This",
"feature",
"is",
"used",
"for",
"handling",
"Item",
"as",
"the",
"independent",
"class",
".",
"Items",
"is",
"better",
"to",
"be",
"class",
"but",
"it",
"does",
"not",
"have",
"object",
"property",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Util/Util.php#L124-L132
|
223,082
|
rpayonline/rpayonline-lite-php
|
lib/Util/Util.php
|
Util.isIndexedArray
|
public static function isIndexedArray($arr)
{
if (!is_array($arr)) {
return false;
}
if (array_values($arr) === $arr) {
return true;
}
return false;
}
|
php
|
public static function isIndexedArray($arr)
{
if (!is_array($arr)) {
return false;
}
if (array_values($arr) === $arr) {
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"isIndexedArray",
"(",
"$",
"arr",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"array_values",
"(",
"$",
"arr",
")",
"===",
"$",
"arr",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check whether the given array is associative or indexed.
@param array $arr
@return bool
|
[
"Check",
"whether",
"the",
"given",
"array",
"is",
"associative",
"or",
"indexed",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Util/Util.php#L139-L148
|
223,083
|
rpayonline/rpayonline-lite-php
|
lib/Util/Util.php
|
Util.parseClassType
|
private static function parseClassType($type)
{
$ct = explode('.', $type);
if (count($ct) != 2) {
return false;
}
$_class = $ct[0];
$_type = $ct[1];
if (self::isRpayLiteClassType($_class, $_type)) {
return $_type;
} else {
return false;
}
}
|
php
|
private static function parseClassType($type)
{
$ct = explode('.', $type);
if (count($ct) != 2) {
return false;
}
$_class = $ct[0];
$_type = $ct[1];
if (self::isRpayLiteClassType($_class, $_type)) {
return $_type;
} else {
return false;
}
}
|
[
"private",
"static",
"function",
"parseClassType",
"(",
"$",
"type",
")",
"{",
"$",
"ct",
"=",
"explode",
"(",
"'.'",
",",
"$",
"type",
")",
";",
"if",
"(",
"count",
"(",
"$",
"ct",
")",
"!=",
"2",
")",
"{",
"return",
"false",
";",
"}",
"$",
"_class",
"=",
"$",
"ct",
"[",
"0",
"]",
";",
"$",
"_type",
"=",
"$",
"ct",
"[",
"1",
"]",
";",
"if",
"(",
"self",
"::",
"isRpayLiteClassType",
"(",
"$",
"_class",
",",
"$",
"_type",
")",
")",
"{",
"return",
"$",
"_type",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Parse data for classType method.
@param string $type
@return bool
|
[
"Parse",
"data",
"for",
"classType",
"method",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Util/Util.php#L171-L184
|
223,084
|
activecollab/activecollab-sdk
|
ActiveCollab/Connectors/Snoopy.php
|
Snoopy.get
|
function get($url) {
$snoopy = $this->getSnoopyInstance();
$snoopy->fetch($url);
return $this->processSnoopyResponse($snoopy);
}
|
php
|
function get($url) {
$snoopy = $this->getSnoopyInstance();
$snoopy->fetch($url);
return $this->processSnoopyResponse($snoopy);
}
|
[
"function",
"get",
"(",
"$",
"url",
")",
"{",
"$",
"snoopy",
"=",
"$",
"this",
"->",
"getSnoopyInstance",
"(",
")",
";",
"$",
"snoopy",
"->",
"fetch",
"(",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"processSnoopyResponse",
"(",
"$",
"snoopy",
")",
";",
"}"
] |
GET data
readre
@param string $url
@return string
|
[
"GET",
"data",
"readre"
] |
26604ab5e07402c584998371969ebfcbf5ea358e
|
https://github.com/activecollab/activecollab-sdk/blob/26604ab5e07402c584998371969ebfcbf5ea358e/ActiveCollab/Connectors/Snoopy.php#L40-L44
|
223,085
|
activecollab/activecollab-sdk
|
ActiveCollab/Connectors/Snoopy.php
|
Snoopy.processSnoopyResponse
|
private function processSnoopyResponse(\Snoopy &$snoopy) {
if($snoopy->status != 200) {
throw new CallFailed($snoopy->status, $snoopy->results);
} else {
return $snoopy->results;
} // if
}
|
php
|
private function processSnoopyResponse(\Snoopy &$snoopy) {
if($snoopy->status != 200) {
throw new CallFailed($snoopy->status, $snoopy->results);
} else {
return $snoopy->results;
} // if
}
|
[
"private",
"function",
"processSnoopyResponse",
"(",
"\\",
"Snoopy",
"&",
"$",
"snoopy",
")",
"{",
"if",
"(",
"$",
"snoopy",
"->",
"status",
"!=",
"200",
")",
"{",
"throw",
"new",
"CallFailed",
"(",
"$",
"snoopy",
"->",
"status",
",",
"$",
"snoopy",
"->",
"results",
")",
";",
"}",
"else",
"{",
"return",
"$",
"snoopy",
"->",
"results",
";",
"}",
"// if",
"}"
] |
Process Snoopy response
@param \Snoopy $snoopy
@return string
@throws \ActiveCollab\Exceptions\CallFailed
|
[
"Process",
"Snoopy",
"response"
] |
26604ab5e07402c584998371969ebfcbf5ea358e
|
https://github.com/activecollab/activecollab-sdk/blob/26604ab5e07402c584998371969ebfcbf5ea358e/ActiveCollab/Connectors/Snoopy.php#L67-L73
|
223,086
|
activecollab/activecollab-sdk
|
ActiveCollab/Connectors/Snoopy.php
|
Snoopy.getSnoopyInstance
|
private function getSnoopyInstance() {
require_once $this->snoopy_class_path;
$snoopy = new \Snoopy();
$snoopy->agent = Client::getUserAgent();
return $snoopy;
}
|
php
|
private function getSnoopyInstance() {
require_once $this->snoopy_class_path;
$snoopy = new \Snoopy();
$snoopy->agent = Client::getUserAgent();
return $snoopy;
}
|
[
"private",
"function",
"getSnoopyInstance",
"(",
")",
"{",
"require_once",
"$",
"this",
"->",
"snoopy_class_path",
";",
"$",
"snoopy",
"=",
"new",
"\\",
"Snoopy",
"(",
")",
";",
"$",
"snoopy",
"->",
"agent",
"=",
"Client",
"::",
"getUserAgent",
"(",
")",
";",
"return",
"$",
"snoopy",
";",
"}"
] |
Return Snoopy instance
@return \Snoopy
|
[
"Return",
"Snoopy",
"instance"
] |
26604ab5e07402c584998371969ebfcbf5ea358e
|
https://github.com/activecollab/activecollab-sdk/blob/26604ab5e07402c584998371969ebfcbf5ea358e/ActiveCollab/Connectors/Snoopy.php#L80-L87
|
223,087
|
alexandresalome/multisite-bundle
|
Router/Loader/AnnotatedRouteControllerLoader.php
|
AnnotatedRouteControllerLoader.addMultisiteRoute
|
protected function addMultisiteRoute(RouteCollection $collection, $annot, $globals, \ReflectionClass $class, \ReflectionMethod $method)
{
$paths = $this->siteContext->normalizePaths($annot->getPaths());
foreach ($paths as $branding => $locales) {
foreach ($locales as $locale => $path) {
// this block of code is copied from Symfony\Component\Routing\Loader\AnnotationFileLoader
$name = $annot->getName();
if (null === $name) {
$name = $this->getDefaultRouteName($class, $method);
}
$name = MultisiteRouter::ROUTE_PREFIX.'_'.$branding.'_'.$locale.'__'.$name;
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
foreach ($method->getParameters() as $param) {
if (!isset($defaults[$param->getName()]) && $param->isOptional()) {
$defaults[$param->getName()] = $param->getDefaultValue();
}
}
// +2 lines
$defaults['_branding'] = $branding;
$defaults['_locale'] = $locale;
$requirements = array_replace($globals['requirements'], $annot->getRequirements());
$options = array_replace($globals['options'], $annot->getOptions());
$schemes = array_replace($globals['schemes'], $annot->getSchemes());
$methods = array_replace($globals['methods'], $annot->getMethods());
$host = $annot->getHost();
if (null === $host) {
$host = $globals['host'];
}
// +3 lines
if (!$host) {
$host = $this->siteContext->getBranding($branding)->getHost($locale);
}
$condition = $annot->getCondition();
if (null === $condition) {
$condition = $globals['condition'];
}
$route = new Route($globals['path'].$path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
$this->configureRoute($route, $class, $method, $annot);
$collection->add($name, $route);
}
}
// cache will refresh when file is modified
$collection->addResource(new FileResource($class->getFileName()));
return $collection;
}
|
php
|
protected function addMultisiteRoute(RouteCollection $collection, $annot, $globals, \ReflectionClass $class, \ReflectionMethod $method)
{
$paths = $this->siteContext->normalizePaths($annot->getPaths());
foreach ($paths as $branding => $locales) {
foreach ($locales as $locale => $path) {
// this block of code is copied from Symfony\Component\Routing\Loader\AnnotationFileLoader
$name = $annot->getName();
if (null === $name) {
$name = $this->getDefaultRouteName($class, $method);
}
$name = MultisiteRouter::ROUTE_PREFIX.'_'.$branding.'_'.$locale.'__'.$name;
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
foreach ($method->getParameters() as $param) {
if (!isset($defaults[$param->getName()]) && $param->isOptional()) {
$defaults[$param->getName()] = $param->getDefaultValue();
}
}
// +2 lines
$defaults['_branding'] = $branding;
$defaults['_locale'] = $locale;
$requirements = array_replace($globals['requirements'], $annot->getRequirements());
$options = array_replace($globals['options'], $annot->getOptions());
$schemes = array_replace($globals['schemes'], $annot->getSchemes());
$methods = array_replace($globals['methods'], $annot->getMethods());
$host = $annot->getHost();
if (null === $host) {
$host = $globals['host'];
}
// +3 lines
if (!$host) {
$host = $this->siteContext->getBranding($branding)->getHost($locale);
}
$condition = $annot->getCondition();
if (null === $condition) {
$condition = $globals['condition'];
}
$route = new Route($globals['path'].$path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
$this->configureRoute($route, $class, $method, $annot);
$collection->add($name, $route);
}
}
// cache will refresh when file is modified
$collection->addResource(new FileResource($class->getFileName()));
return $collection;
}
|
[
"protected",
"function",
"addMultisiteRoute",
"(",
"RouteCollection",
"$",
"collection",
",",
"$",
"annot",
",",
"$",
"globals",
",",
"\\",
"ReflectionClass",
"$",
"class",
",",
"\\",
"ReflectionMethod",
"$",
"method",
")",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"siteContext",
"->",
"normalizePaths",
"(",
"$",
"annot",
"->",
"getPaths",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"branding",
"=>",
"$",
"locales",
")",
"{",
"foreach",
"(",
"$",
"locales",
"as",
"$",
"locale",
"=>",
"$",
"path",
")",
"{",
"// this block of code is copied from Symfony\\Component\\Routing\\Loader\\AnnotationFileLoader",
"$",
"name",
"=",
"$",
"annot",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getDefaultRouteName",
"(",
"$",
"class",
",",
"$",
"method",
")",
";",
"}",
"$",
"name",
"=",
"MultisiteRouter",
"::",
"ROUTE_PREFIX",
".",
"'_'",
".",
"$",
"branding",
".",
"'_'",
".",
"$",
"locale",
".",
"'__'",
".",
"$",
"name",
";",
"$",
"defaults",
"=",
"array_replace",
"(",
"$",
"globals",
"[",
"'defaults'",
"]",
",",
"$",
"annot",
"->",
"getDefaults",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"method",
"->",
"getParameters",
"(",
")",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"defaults",
"[",
"$",
"param",
"->",
"getName",
"(",
")",
"]",
")",
"&&",
"$",
"param",
"->",
"isOptional",
"(",
")",
")",
"{",
"$",
"defaults",
"[",
"$",
"param",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"param",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"}",
"// +2 lines",
"$",
"defaults",
"[",
"'_branding'",
"]",
"=",
"$",
"branding",
";",
"$",
"defaults",
"[",
"'_locale'",
"]",
"=",
"$",
"locale",
";",
"$",
"requirements",
"=",
"array_replace",
"(",
"$",
"globals",
"[",
"'requirements'",
"]",
",",
"$",
"annot",
"->",
"getRequirements",
"(",
")",
")",
";",
"$",
"options",
"=",
"array_replace",
"(",
"$",
"globals",
"[",
"'options'",
"]",
",",
"$",
"annot",
"->",
"getOptions",
"(",
")",
")",
";",
"$",
"schemes",
"=",
"array_replace",
"(",
"$",
"globals",
"[",
"'schemes'",
"]",
",",
"$",
"annot",
"->",
"getSchemes",
"(",
")",
")",
";",
"$",
"methods",
"=",
"array_replace",
"(",
"$",
"globals",
"[",
"'methods'",
"]",
",",
"$",
"annot",
"->",
"getMethods",
"(",
")",
")",
";",
"$",
"host",
"=",
"$",
"annot",
"->",
"getHost",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"host",
")",
"{",
"$",
"host",
"=",
"$",
"globals",
"[",
"'host'",
"]",
";",
"}",
"// +3 lines",
"if",
"(",
"!",
"$",
"host",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"siteContext",
"->",
"getBranding",
"(",
"$",
"branding",
")",
"->",
"getHost",
"(",
"$",
"locale",
")",
";",
"}",
"$",
"condition",
"=",
"$",
"annot",
"->",
"getCondition",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"condition",
")",
"{",
"$",
"condition",
"=",
"$",
"globals",
"[",
"'condition'",
"]",
";",
"}",
"$",
"route",
"=",
"new",
"Route",
"(",
"$",
"globals",
"[",
"'path'",
"]",
".",
"$",
"path",
",",
"$",
"defaults",
",",
"$",
"requirements",
",",
"$",
"options",
",",
"$",
"host",
",",
"$",
"schemes",
",",
"$",
"methods",
",",
"$",
"condition",
")",
";",
"$",
"this",
"->",
"configureRoute",
"(",
"$",
"route",
",",
"$",
"class",
",",
"$",
"method",
",",
"$",
"annot",
")",
";",
"$",
"collection",
"->",
"add",
"(",
"$",
"name",
",",
"$",
"route",
")",
";",
"}",
"}",
"// cache will refresh when file is modified",
"$",
"collection",
"->",
"addResource",
"(",
"new",
"FileResource",
"(",
"$",
"class",
"->",
"getFileName",
"(",
")",
")",
")",
";",
"return",
"$",
"collection",
";",
"}"
] |
Specific method to add a multisite route to the collection.
Paths option should not be null.
|
[
"Specific",
"method",
"to",
"add",
"a",
"multisite",
"route",
"to",
"the",
"collection",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/Router/Loader/AnnotatedRouteControllerLoader.php#L59-L115
|
223,088
|
mwr/magedeploy2
|
src/Config/Config.php
|
Config.set
|
public function set($path, $value)
{
if (strpos($path, '/') === false) {
$this->data[$path] = $value;
return $this;
}
$pathKeys = explode('/', $path);
$key = array_pop($pathKeys);
$data = &$this->data;
foreach ($pathKeys as $pathKey) {
if (is_array($data) && array_key_exists($pathKey, $data)) {
$data = &$data[$pathKey];
} else {
continue;
}
}
$data[$key] = $value;
return $this;
}
|
php
|
public function set($path, $value)
{
if (strpos($path, '/') === false) {
$this->data[$path] = $value;
return $this;
}
$pathKeys = explode('/', $path);
$key = array_pop($pathKeys);
$data = &$this->data;
foreach ($pathKeys as $pathKey) {
if (is_array($data) && array_key_exists($pathKey, $data)) {
$data = &$data[$pathKey];
} else {
continue;
}
}
$data[$key] = $value;
return $this;
}
|
[
"public",
"function",
"set",
"(",
"$",
"path",
",",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'/'",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"path",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}",
"$",
"pathKeys",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"key",
"=",
"array_pop",
"(",
"$",
"pathKeys",
")",
";",
"$",
"data",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"foreach",
"(",
"$",
"pathKeys",
"as",
"$",
"pathKey",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"&&",
"array_key_exists",
"(",
"$",
"pathKey",
",",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"&",
"$",
"data",
"[",
"$",
"pathKey",
"]",
";",
"}",
"else",
"{",
"continue",
";",
"}",
"}",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Set a Config Value
@param string $path
@param mixed $value
@return $this
|
[
"Set",
"a",
"Config",
"Value"
] |
8252f61ee4810f5aa2448090a51cb2d3916d6421
|
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Config/Config.php#L83-L104
|
223,089
|
activecollab/activecollab-sdk
|
ActiveCollab/Connectors/Curl.php
|
Curl.&
|
private function &getHandle($url) {
$http = curl_init();
curl_setopt($http, CURLOPT_USERAGENT, Client::getUserAgent());
curl_setopt($http, CURLOPT_RETURNTRANSFER, true);
curl_setopt($http, CURLOPT_URL, $url);
return $http;
}
|
php
|
private function &getHandle($url) {
$http = curl_init();
curl_setopt($http, CURLOPT_USERAGENT, Client::getUserAgent());
curl_setopt($http, CURLOPT_RETURNTRANSFER, true);
curl_setopt($http, CURLOPT_URL, $url);
return $http;
}
|
[
"private",
"function",
"&",
"getHandle",
"(",
"$",
"url",
")",
"{",
"$",
"http",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"http",
",",
"CURLOPT_USERAGENT",
",",
"Client",
"::",
"getUserAgent",
"(",
")",
")",
";",
"curl_setopt",
"(",
"$",
"http",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"http",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"return",
"$",
"http",
";",
"}"
] |
Return curl resource
@param string $url
@return resource
|
[
"Return",
"curl",
"resource"
] |
26604ab5e07402c584998371969ebfcbf5ea358e
|
https://github.com/activecollab/activecollab-sdk/blob/26604ab5e07402c584998371969ebfcbf5ea358e/ActiveCollab/Connectors/Curl.php#L61-L69
|
223,090
|
activecollab/activecollab-sdk
|
ActiveCollab/Connectors/Curl.php
|
Curl.execute
|
private function execute(&$http) {
$result = curl_exec($http);
if($result === false) {
$error_code = curl_errno($http);
$error_message = curl_error($http);
curl_close($http);
throw new CallFailed($error_code, $result, $error_message);
} else {
$status = (integer) curl_getinfo($http, CURLINFO_HTTP_CODE);
curl_close($http);
switch($status) {
case 200:
return $result;
case 400:
case 401:
case 403:
case 404:
case 409:
case 500:
case 503:
if(is_string($result) && substr($result, 0, 1) === '{') {
throw new AppException($status, $result); // Known application exception
} // if
} // switch
throw new CallFailed($status, $result); // Unknown exception
} // if
}
|
php
|
private function execute(&$http) {
$result = curl_exec($http);
if($result === false) {
$error_code = curl_errno($http);
$error_message = curl_error($http);
curl_close($http);
throw new CallFailed($error_code, $result, $error_message);
} else {
$status = (integer) curl_getinfo($http, CURLINFO_HTTP_CODE);
curl_close($http);
switch($status) {
case 200:
return $result;
case 400:
case 401:
case 403:
case 404:
case 409:
case 500:
case 503:
if(is_string($result) && substr($result, 0, 1) === '{') {
throw new AppException($status, $result); // Known application exception
} // if
} // switch
throw new CallFailed($status, $result); // Unknown exception
} // if
}
|
[
"private",
"function",
"execute",
"(",
"&",
"$",
"http",
")",
"{",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"http",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"error_code",
"=",
"curl_errno",
"(",
"$",
"http",
")",
";",
"$",
"error_message",
"=",
"curl_error",
"(",
"$",
"http",
")",
";",
"curl_close",
"(",
"$",
"http",
")",
";",
"throw",
"new",
"CallFailed",
"(",
"$",
"error_code",
",",
"$",
"result",
",",
"$",
"error_message",
")",
";",
"}",
"else",
"{",
"$",
"status",
"=",
"(",
"integer",
")",
"curl_getinfo",
"(",
"$",
"http",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"curl_close",
"(",
"$",
"http",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"200",
":",
"return",
"$",
"result",
";",
"case",
"400",
":",
"case",
"401",
":",
"case",
"403",
":",
"case",
"404",
":",
"case",
"409",
":",
"case",
"500",
":",
"case",
"503",
":",
"if",
"(",
"is_string",
"(",
"$",
"result",
")",
"&&",
"substr",
"(",
"$",
"result",
",",
"0",
",",
"1",
")",
"===",
"'{'",
")",
"{",
"throw",
"new",
"AppException",
"(",
"$",
"status",
",",
"$",
"result",
")",
";",
"// Known application exception",
"}",
"// if",
"}",
"// switch",
"throw",
"new",
"CallFailed",
"(",
"$",
"status",
",",
"$",
"result",
")",
";",
"// Unknown exception",
"}",
"// if",
"}"
] |
Do the call
@param resource $http
@return string
@throws CallFailed
@throws AppException
|
[
"Do",
"the",
"call"
] |
26604ab5e07402c584998371969ebfcbf5ea358e
|
https://github.com/activecollab/activecollab-sdk/blob/26604ab5e07402c584998371969ebfcbf5ea358e/ActiveCollab/Connectors/Curl.php#L79-L111
|
223,091
|
symlex/doctrine-active-record
|
src/Search/SearchResult.php
|
SearchResult.getAllResultsAsArray
|
public function getAllResultsAsArray(): array
{
$result = array();
$entities = $this->getAllResults();
// Convert search results to array
foreach ($entities as $entity) {
if (is_object($entity) && method_exists($entity, 'getValues')) {
$result[] = $entity->getValues();
} else {
$result[] = (array)$entity;
}
}
return $result;
}
|
php
|
public function getAllResultsAsArray(): array
{
$result = array();
$entities = $this->getAllResults();
// Convert search results to array
foreach ($entities as $entity) {
if (is_object($entity) && method_exists($entity, 'getValues')) {
$result[] = $entity->getValues();
} else {
$result[] = (array)$entity;
}
}
return $result;
}
|
[
"public",
"function",
"getAllResultsAsArray",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"entities",
"=",
"$",
"this",
"->",
"getAllResults",
"(",
")",
";",
"// Convert search results to array",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"entity",
")",
"&&",
"method_exists",
"(",
"$",
"entity",
",",
"'getValues'",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"entity",
"->",
"getValues",
"(",
")",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"(",
"array",
")",
"$",
"entity",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns all results as nested array.
@return array
|
[
"Returns",
"all",
"results",
"as",
"nested",
"array",
"."
] |
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
|
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Search/SearchResult.php#L120-L136
|
223,092
|
rpayonline/rpayonline-lite-php
|
lib/Webhook.php
|
Webhook.constructEvent
|
public static function constructEvent($jsonString, $header, $expectedSignature = null)
{
self::verifySignature($header, $expectedSignature);
return Event::parseJson($jsonString);
}
|
php
|
public static function constructEvent($jsonString, $header, $expectedSignature = null)
{
self::verifySignature($header, $expectedSignature);
return Event::parseJson($jsonString);
}
|
[
"public",
"static",
"function",
"constructEvent",
"(",
"$",
"jsonString",
",",
"$",
"header",
",",
"$",
"expectedSignature",
"=",
"null",
")",
"{",
"self",
"::",
"verifySignature",
"(",
"$",
"header",
",",
"$",
"expectedSignature",
")",
";",
"return",
"Event",
"::",
"parseJson",
"(",
"$",
"jsonString",
")",
";",
"}"
] |
Create new Event object from given JSON string.
@param string $jsonString JSON string
@param string $header Signature included in the request header.
@param string $expectedSignature Expected signature.
@return Event
|
[
"Create",
"new",
"Event",
"object",
"from",
"given",
"JSON",
"string",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Webhook.php#L25-L29
|
223,093
|
rpayonline/rpayonline-lite-php
|
lib/Webhook.php
|
Webhook.verifySignature
|
private static function verifySignature($signature, $expectedSignature = null)
{
if (!isset($expectedSignature) && !isset(RpayLite::$webhookSignature)) {
throw new Error\SignatureVerification('Webhook Signature is not defined.');
}
$expected = $expectedSignature ? $expectedSignature : RpayLite::$webhookSignature;
if (!is_string($signature) || !is_string($expected)) {
throw new Error\SignatureVerification('Webhook Signature is not string.');
}
if ($signature !== $expected) {
throw new Error\SignatureVerification("Webhook Signature is invalid.");
}
return true;
}
|
php
|
private static function verifySignature($signature, $expectedSignature = null)
{
if (!isset($expectedSignature) && !isset(RpayLite::$webhookSignature)) {
throw new Error\SignatureVerification('Webhook Signature is not defined.');
}
$expected = $expectedSignature ? $expectedSignature : RpayLite::$webhookSignature;
if (!is_string($signature) || !is_string($expected)) {
throw new Error\SignatureVerification('Webhook Signature is not string.');
}
if ($signature !== $expected) {
throw new Error\SignatureVerification("Webhook Signature is invalid.");
}
return true;
}
|
[
"private",
"static",
"function",
"verifySignature",
"(",
"$",
"signature",
",",
"$",
"expectedSignature",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"expectedSignature",
")",
"&&",
"!",
"isset",
"(",
"RpayLite",
"::",
"$",
"webhookSignature",
")",
")",
"{",
"throw",
"new",
"Error",
"\\",
"SignatureVerification",
"(",
"'Webhook Signature is not defined.'",
")",
";",
"}",
"$",
"expected",
"=",
"$",
"expectedSignature",
"?",
"$",
"expectedSignature",
":",
"RpayLite",
"::",
"$",
"webhookSignature",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"signature",
")",
"||",
"!",
"is_string",
"(",
"$",
"expected",
")",
")",
"{",
"throw",
"new",
"Error",
"\\",
"SignatureVerification",
"(",
"'Webhook Signature is not string.'",
")",
";",
"}",
"if",
"(",
"$",
"signature",
"!==",
"$",
"expected",
")",
"{",
"throw",
"new",
"Error",
"\\",
"SignatureVerification",
"(",
"\"Webhook Signature is invalid.\"",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Validate signature.
@param string $signature Signature included in the request header.
@param string $expectedSignature Expected signature.
@return bool It returns true in case of same signature.
@throws Error\SignatureVerification Invalid signature or failed to validate.
|
[
"Validate",
"signature",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Webhook.php#L38-L51
|
223,094
|
alexandresalome/multisite-bundle
|
DependencyInjection/AlexMultisiteExtension.php
|
AlexMultisiteExtension.addBrandingDefinition
|
private function addBrandingDefinition(ContainerBuilder $container, array $options)
{
$brandings = array();
if (isset($options['_defaults'])) {
$globalOptions = $options['_defaults'];
unset($options['_defaults']);
} else {
$globalOptions = array();
}
foreach ($options as $name => $localeOptions) {
if (isset($localeOptions['_defaults'])) {
$brandingOptions = $localeOptions['_defaults'];
unset($localeOptions['_defaults']);
} else {
$brandingOptions = array();
}
$arg = array();
foreach ($localeOptions as $locale => $options) {
$arg[$locale] = array_merge($globalOptions, $brandingOptions, $options);
}
$brandings[] = new Definition(
'Alex\MultisiteBundle\Branding\Branding',
array($name, $arg)
);
}
$container->getDefinition('site_context')->replaceArgument(0, $brandings);
}
|
php
|
private function addBrandingDefinition(ContainerBuilder $container, array $options)
{
$brandings = array();
if (isset($options['_defaults'])) {
$globalOptions = $options['_defaults'];
unset($options['_defaults']);
} else {
$globalOptions = array();
}
foreach ($options as $name => $localeOptions) {
if (isset($localeOptions['_defaults'])) {
$brandingOptions = $localeOptions['_defaults'];
unset($localeOptions['_defaults']);
} else {
$brandingOptions = array();
}
$arg = array();
foreach ($localeOptions as $locale => $options) {
$arg[$locale] = array_merge($globalOptions, $brandingOptions, $options);
}
$brandings[] = new Definition(
'Alex\MultisiteBundle\Branding\Branding',
array($name, $arg)
);
}
$container->getDefinition('site_context')->replaceArgument(0, $brandings);
}
|
[
"private",
"function",
"addBrandingDefinition",
"(",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"options",
")",
"{",
"$",
"brandings",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'_defaults'",
"]",
")",
")",
"{",
"$",
"globalOptions",
"=",
"$",
"options",
"[",
"'_defaults'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'_defaults'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"globalOptions",
"=",
"array",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"options",
"as",
"$",
"name",
"=>",
"$",
"localeOptions",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"localeOptions",
"[",
"'_defaults'",
"]",
")",
")",
"{",
"$",
"brandingOptions",
"=",
"$",
"localeOptions",
"[",
"'_defaults'",
"]",
";",
"unset",
"(",
"$",
"localeOptions",
"[",
"'_defaults'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"brandingOptions",
"=",
"array",
"(",
")",
";",
"}",
"$",
"arg",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"localeOptions",
"as",
"$",
"locale",
"=>",
"$",
"options",
")",
"{",
"$",
"arg",
"[",
"$",
"locale",
"]",
"=",
"array_merge",
"(",
"$",
"globalOptions",
",",
"$",
"brandingOptions",
",",
"$",
"options",
")",
";",
"}",
"$",
"brandings",
"[",
"]",
"=",
"new",
"Definition",
"(",
"'Alex\\MultisiteBundle\\Branding\\Branding'",
",",
"array",
"(",
"$",
"name",
",",
"$",
"arg",
")",
")",
";",
"}",
"$",
"container",
"->",
"getDefinition",
"(",
"'site_context'",
")",
"->",
"replaceArgument",
"(",
"0",
",",
"$",
"brandings",
")",
";",
"}"
] |
Adds configured brandings to the site context service.
@param ContainerBuilder $container
@param array $options
|
[
"Adds",
"configured",
"brandings",
"to",
"the",
"site",
"context",
"service",
"."
] |
1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a
|
https://github.com/alexandresalome/multisite-bundle/blob/1e238e23d3f4c4b1ef11c4e859f78bcbcae1ee0a/DependencyInjection/AlexMultisiteExtension.php#L42-L73
|
223,095
|
rpayonline/rpayonline-lite-php
|
lib/Button.php
|
Button.deleteItem
|
public function deleteItem($id)
{
$updatedItems = $this->values['items'];
foreach ($updatedItems as $index => $item) {
if ($item['id'] == $id) {
unset($updatedItems[$index]);
}
}
$this->values['items'] = array_values($updatedItems);
}
|
php
|
public function deleteItem($id)
{
$updatedItems = $this->values['items'];
foreach ($updatedItems as $index => $item) {
if ($item['id'] == $id) {
unset($updatedItems[$index]);
}
}
$this->values['items'] = array_values($updatedItems);
}
|
[
"public",
"function",
"deleteItem",
"(",
"$",
"id",
")",
"{",
"$",
"updatedItems",
"=",
"$",
"this",
"->",
"values",
"[",
"'items'",
"]",
";",
"foreach",
"(",
"$",
"updatedItems",
"as",
"$",
"index",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"'id'",
"]",
"==",
"$",
"id",
")",
"{",
"unset",
"(",
"$",
"updatedItems",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"values",
"[",
"'items'",
"]",
"=",
"array_values",
"(",
"$",
"updatedItems",
")",
";",
"}"
] |
Remove a item having specific ID.
@param string $id
|
[
"Remove",
"a",
"item",
"having",
"specific",
"ID",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Button.php#L73-L82
|
223,096
|
rpayonline/rpayonline-lite-php
|
lib/Button.php
|
Button.toHtml
|
public function toHtml($sig = true)
{
$html = '<script';
$html = $html . ' src="' . self::BUTTON_SRC . '"';
$html = $html . ' class="' . self::BUTTON_CLASS . '"';
if (isset($this->values['key'])) {
$html = $html . ' data-key="' . $this->values['key'] . '"';
}
if (isset($this->values['image'])) {
$html = $html . ' data-image="' . $this->values['image'] . '"';
}
if (isset($this->values['callback'])) {
$html = $html . ' data-callback="' . $this->values['callback'] . '"';
}
if (isset($this->values['cart_id'])) {
$html = $html . ' data-cart-id="' . $this->values['cart_id'] . '"';
}
if (!isset($this->values['items']) || count($this->values['items']) < 1) {
throw new Error\InvalidButton('Item is required.');
}
foreach ($this->values['items'] as $index => $item) {
$index++;
$html = $html . ' data-item-id-' . $index . '="' . $item['id'] . '"';
$html = $html . ' data-item-name-' . $index . '="' . $item['name'] . '"';
$html = $html . ' data-item-unit-price-' . $index . '="' . $item['unit_price'] . '"';
$html = $html . ' data-item-quantity-' . $index . '="' . $item['quantity'] . '"';
}
if ($sig) {
$html = $html . ' data-sig="' . $this->signature() . '"';
}
$html = $html . '>';
$html = $html . '</script>';
return $html;
}
|
php
|
public function toHtml($sig = true)
{
$html = '<script';
$html = $html . ' src="' . self::BUTTON_SRC . '"';
$html = $html . ' class="' . self::BUTTON_CLASS . '"';
if (isset($this->values['key'])) {
$html = $html . ' data-key="' . $this->values['key'] . '"';
}
if (isset($this->values['image'])) {
$html = $html . ' data-image="' . $this->values['image'] . '"';
}
if (isset($this->values['callback'])) {
$html = $html . ' data-callback="' . $this->values['callback'] . '"';
}
if (isset($this->values['cart_id'])) {
$html = $html . ' data-cart-id="' . $this->values['cart_id'] . '"';
}
if (!isset($this->values['items']) || count($this->values['items']) < 1) {
throw new Error\InvalidButton('Item is required.');
}
foreach ($this->values['items'] as $index => $item) {
$index++;
$html = $html . ' data-item-id-' . $index . '="' . $item['id'] . '"';
$html = $html . ' data-item-name-' . $index . '="' . $item['name'] . '"';
$html = $html . ' data-item-unit-price-' . $index . '="' . $item['unit_price'] . '"';
$html = $html . ' data-item-quantity-' . $index . '="' . $item['quantity'] . '"';
}
if ($sig) {
$html = $html . ' data-sig="' . $this->signature() . '"';
}
$html = $html . '>';
$html = $html . '</script>';
return $html;
}
|
[
"public",
"function",
"toHtml",
"(",
"$",
"sig",
"=",
"true",
")",
"{",
"$",
"html",
"=",
"'<script'",
";",
"$",
"html",
"=",
"$",
"html",
".",
"' src=\"'",
".",
"self",
"::",
"BUTTON_SRC",
".",
"'\"'",
";",
"$",
"html",
"=",
"$",
"html",
".",
"' class=\"'",
".",
"self",
"::",
"BUTTON_CLASS",
".",
"'\"'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"'key'",
"]",
")",
")",
"{",
"$",
"html",
"=",
"$",
"html",
".",
"' data-key=\"'",
".",
"$",
"this",
"->",
"values",
"[",
"'key'",
"]",
".",
"'\"'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"'image'",
"]",
")",
")",
"{",
"$",
"html",
"=",
"$",
"html",
".",
"' data-image=\"'",
".",
"$",
"this",
"->",
"values",
"[",
"'image'",
"]",
".",
"'\"'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"'callback'",
"]",
")",
")",
"{",
"$",
"html",
"=",
"$",
"html",
".",
"' data-callback=\"'",
".",
"$",
"this",
"->",
"values",
"[",
"'callback'",
"]",
".",
"'\"'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"'cart_id'",
"]",
")",
")",
"{",
"$",
"html",
"=",
"$",
"html",
".",
"' data-cart-id=\"'",
".",
"$",
"this",
"->",
"values",
"[",
"'cart_id'",
"]",
".",
"'\"'",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"'items'",
"]",
")",
"||",
"count",
"(",
"$",
"this",
"->",
"values",
"[",
"'items'",
"]",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"Error",
"\\",
"InvalidButton",
"(",
"'Item is required.'",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"values",
"[",
"'items'",
"]",
"as",
"$",
"index",
"=>",
"$",
"item",
")",
"{",
"$",
"index",
"++",
";",
"$",
"html",
"=",
"$",
"html",
".",
"' data-item-id-'",
".",
"$",
"index",
".",
"'=\"'",
".",
"$",
"item",
"[",
"'id'",
"]",
".",
"'\"'",
";",
"$",
"html",
"=",
"$",
"html",
".",
"' data-item-name-'",
".",
"$",
"index",
".",
"'=\"'",
".",
"$",
"item",
"[",
"'name'",
"]",
".",
"'\"'",
";",
"$",
"html",
"=",
"$",
"html",
".",
"' data-item-unit-price-'",
".",
"$",
"index",
".",
"'=\"'",
".",
"$",
"item",
"[",
"'unit_price'",
"]",
".",
"'\"'",
";",
"$",
"html",
"=",
"$",
"html",
".",
"' data-item-quantity-'",
".",
"$",
"index",
".",
"'=\"'",
".",
"$",
"item",
"[",
"'quantity'",
"]",
".",
"'\"'",
";",
"}",
"if",
"(",
"$",
"sig",
")",
"{",
"$",
"html",
"=",
"$",
"html",
".",
"' data-sig=\"'",
".",
"$",
"this",
"->",
"signature",
"(",
")",
".",
"'\"'",
";",
"}",
"$",
"html",
"=",
"$",
"html",
".",
"'>'",
";",
"$",
"html",
"=",
"$",
"html",
".",
"'</script>'",
";",
"return",
"$",
"html",
";",
"}"
] |
Generate HTML of payment button from registered information.
@param bool $sig True if data-sig is also generated (Default is true).
@return string <script> tag.
@throws Error\InvalidButton
|
[
"Generate",
"HTML",
"of",
"payment",
"button",
"from",
"registered",
"information",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Button.php#L90-L123
|
223,097
|
rpayonline/rpayonline-lite-php
|
lib/Button.php
|
Button.signature
|
private function signature()
{
if (isset($this->apiKey)) {
$apiKey = $this->apiKey;
} else {
$apiKey = \RpayLite\RpayLite::$apiKey;
}
$array_payload = array();
array_push($array_payload, $this['key']);
foreach ($this['items'] as $item) {
array_push($array_payload, $item['id']);
array_push($array_payload, $item['name']);
array_push($array_payload, $item['unit_price']);
array_push($array_payload, $item['quantity']);
}
if (isset($this['cart_id'])) {
array_push($array_payload, $this['cart_id']);
} else {
array_push($array_payload, "");
}
$payload = join(";", $array_payload) . ";";
return hash_hmac("SHA1", $payload, $apiKey);
}
|
php
|
private function signature()
{
if (isset($this->apiKey)) {
$apiKey = $this->apiKey;
} else {
$apiKey = \RpayLite\RpayLite::$apiKey;
}
$array_payload = array();
array_push($array_payload, $this['key']);
foreach ($this['items'] as $item) {
array_push($array_payload, $item['id']);
array_push($array_payload, $item['name']);
array_push($array_payload, $item['unit_price']);
array_push($array_payload, $item['quantity']);
}
if (isset($this['cart_id'])) {
array_push($array_payload, $this['cart_id']);
} else {
array_push($array_payload, "");
}
$payload = join(";", $array_payload) . ";";
return hash_hmac("SHA1", $payload, $apiKey);
}
|
[
"private",
"function",
"signature",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"apiKey",
")",
")",
"{",
"$",
"apiKey",
"=",
"$",
"this",
"->",
"apiKey",
";",
"}",
"else",
"{",
"$",
"apiKey",
"=",
"\\",
"RpayLite",
"\\",
"RpayLite",
"::",
"$",
"apiKey",
";",
"}",
"$",
"array_payload",
"=",
"array",
"(",
")",
";",
"array_push",
"(",
"$",
"array_payload",
",",
"$",
"this",
"[",
"'key'",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"[",
"'items'",
"]",
"as",
"$",
"item",
")",
"{",
"array_push",
"(",
"$",
"array_payload",
",",
"$",
"item",
"[",
"'id'",
"]",
")",
";",
"array_push",
"(",
"$",
"array_payload",
",",
"$",
"item",
"[",
"'name'",
"]",
")",
";",
"array_push",
"(",
"$",
"array_payload",
",",
"$",
"item",
"[",
"'unit_price'",
"]",
")",
";",
"array_push",
"(",
"$",
"array_payload",
",",
"$",
"item",
"[",
"'quantity'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"'cart_id'",
"]",
")",
")",
"{",
"array_push",
"(",
"$",
"array_payload",
",",
"$",
"this",
"[",
"'cart_id'",
"]",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"array_payload",
",",
"\"\"",
")",
";",
"}",
"$",
"payload",
"=",
"join",
"(",
"\";\"",
",",
"$",
"array_payload",
")",
".",
"\";\"",
";",
"return",
"hash_hmac",
"(",
"\"SHA1\"",
",",
"$",
"payload",
",",
"$",
"apiKey",
")",
";",
"}"
] |
Generate data-sig from registered information.
@return string data-sig string.
|
[
"Generate",
"data",
"-",
"sig",
"from",
"registered",
"information",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Button.php#L129-L151
|
223,098
|
rpayonline/rpayonline-lite-php
|
lib/RpayLite.php
|
RpayLite.isLive
|
public static function isLive()
{
if (preg_match("/^(live_private_|test_private_)/", self::$apiKey)) {
return true;
} elseif (preg_match("/^sandbox_private_/", self::$apiKey)) {
return false;
} else {
throw new Error\InvalidApiKey('Set correct secret key.');
}
}
|
php
|
public static function isLive()
{
if (preg_match("/^(live_private_|test_private_)/", self::$apiKey)) {
return true;
} elseif (preg_match("/^sandbox_private_/", self::$apiKey)) {
return false;
} else {
throw new Error\InvalidApiKey('Set correct secret key.');
}
}
|
[
"public",
"static",
"function",
"isLive",
"(",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/^(live_private_|test_private_)/\"",
",",
"self",
"::",
"$",
"apiKey",
")",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"\"/^sandbox_private_/\"",
",",
"self",
"::",
"$",
"apiKey",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"\\",
"InvalidApiKey",
"(",
"'Set correct secret key.'",
")",
";",
"}",
"}"
] |
Check whether target environment is live or sandbox.
Detected by the prefix of the Secret key.
@return bool Live:true, Sandbox:false
@throws Error\InvalidApiKey
|
[
"Check",
"whether",
"target",
"environment",
"is",
"live",
"or",
"sandbox",
".",
"Detected",
"by",
"the",
"prefix",
"of",
"the",
"Secret",
"key",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/RpayLite.php#L64-L73
|
223,099
|
rpayonline/rpayonline-lite-php
|
lib/Util/Options.php
|
Options.merge
|
public function merge($opts)
{
$primary_opts = self::parse($opts);
if ($primary_opts->apiKey === null) {
$primary_opts->apiKey = $this->apiKey;
}
$primary_opts->headers = array_merge($this->headers, $primary_opts->headers);
return $primary_opts;
}
|
php
|
public function merge($opts)
{
$primary_opts = self::parse($opts);
if ($primary_opts->apiKey === null) {
$primary_opts->apiKey = $this->apiKey;
}
$primary_opts->headers = array_merge($this->headers, $primary_opts->headers);
return $primary_opts;
}
|
[
"public",
"function",
"merge",
"(",
"$",
"opts",
")",
"{",
"$",
"primary_opts",
"=",
"self",
"::",
"parse",
"(",
"$",
"opts",
")",
";",
"if",
"(",
"$",
"primary_opts",
"->",
"apiKey",
"===",
"null",
")",
"{",
"$",
"primary_opts",
"->",
"apiKey",
"=",
"$",
"this",
"->",
"apiKey",
";",
"}",
"$",
"primary_opts",
"->",
"headers",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"primary_opts",
"->",
"headers",
")",
";",
"return",
"$",
"primary_opts",
";",
"}"
] |
Unify given options with this instance has.
@param array $opts Array of request header key/values.
@return Options Unified Options object.
|
[
"Unify",
"given",
"options",
"with",
"this",
"instance",
"has",
"."
] |
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
|
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Util/Options.php#L43-L51
|
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.