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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
225,400
|
interserver/myadmin-plugin-installer
|
src/Plugin.php
|
Plugin.setPermissions
|
public static function setPermissions(Event $event)
{
if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
$event->getIO()->write('<info>No permissions setup is required on Windows.</info>');
return;
}
$event->getIO()->write('Setting up permissions.');
/* try {
self::setPermissionsSetfacl($event);
return;
} catch (\Exception $setfaclException) {
$event->getIO()->write(sprintf('<error>%s</error>', $setfaclException->getMessage()));
$event->getIO()->write('<info>Trying chmod...</info>');
}*/
try {
self::setPermissionsChmod($event);
return;
} catch (\Exception $chmodException) {
$event->getIO()->write(sprintf('<error>%s</error>', $chmodException->getMessage()));
}
}
|
php
|
public static function setPermissions(Event $event)
{
if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
$event->getIO()->write('<info>No permissions setup is required on Windows.</info>');
return;
}
$event->getIO()->write('Setting up permissions.');
/* try {
self::setPermissionsSetfacl($event);
return;
} catch (\Exception $setfaclException) {
$event->getIO()->write(sprintf('<error>%s</error>', $setfaclException->getMessage()));
$event->getIO()->write('<info>Trying chmod...</info>');
}*/
try {
self::setPermissionsChmod($event);
return;
} catch (\Exception $chmodException) {
$event->getIO()->write(sprintf('<error>%s</error>', $chmodException->getMessage()));
}
}
|
[
"public",
"static",
"function",
"setPermissions",
"(",
"Event",
"$",
"event",
")",
"{",
"if",
"(",
"'WIN'",
"===",
"strtoupper",
"(",
"substr",
"(",
"PHP_OS",
",",
"0",
",",
"3",
")",
")",
")",
"{",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"'<info>No permissions setup is required on Windows.</info>'",
")",
";",
"return",
";",
"}",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"'Setting up permissions.'",
")",
";",
"/*\t\ttry {\n\t\t\t\t\tself::setPermissionsSetfacl($event);\n\t\t\t\t\treturn;\n\t\t\t\t} catch (\\Exception $setfaclException) {\n\t\t\t\t\t$event->getIO()->write(sprintf('<error>%s</error>', $setfaclException->getMessage()));\n\t\t\t\t\t$event->getIO()->write('<info>Trying chmod...</info>');\n\t\t\t\t}*/",
"try",
"{",
"self",
"::",
"setPermissionsChmod",
"(",
"$",
"event",
")",
";",
"return",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"chmodException",
")",
"{",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"sprintf",
"(",
"'<error>%s</error>'",
",",
"$",
"chmodException",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"}"
] |
An event that triggers setting writable permissions on any directories specified in the writable-dirs composer extra options
@param Event $event
@return void
|
[
"An",
"event",
"that",
"triggers",
"setting",
"writable",
"permissions",
"on",
"any",
"directories",
"specified",
"in",
"the",
"writable",
"-",
"dirs",
"composer",
"extra",
"options"
] |
128efde0b61f5623b094cbb399e66ab4aa0dba3f
|
https://github.com/interserver/myadmin-plugin-installer/blob/128efde0b61f5623b094cbb399e66ab4aa0dba3f/src/Plugin.php#L125-L145
|
225,401
|
interserver/myadmin-plugin-installer
|
src/Plugin.php
|
Plugin.getWritableDirs
|
public static function getWritableDirs(Event $event)
{
$configuration = $event->getComposer()->getPackage()->getExtra();
if (!isset($configuration['writable-dirs'])) {
throw new \Exception('The writable-dirs must be specified in composer arbitrary extra data.');
}
if (!is_array($configuration['writable-dirs'])) {
throw new \Exception('The writable-dirs must be an array.');
}
return $configuration['writable-dirs'];
}
|
php
|
public static function getWritableDirs(Event $event)
{
$configuration = $event->getComposer()->getPackage()->getExtra();
if (!isset($configuration['writable-dirs'])) {
throw new \Exception('The writable-dirs must be specified in composer arbitrary extra data.');
}
if (!is_array($configuration['writable-dirs'])) {
throw new \Exception('The writable-dirs must be an array.');
}
return $configuration['writable-dirs'];
}
|
[
"public",
"static",
"function",
"getWritableDirs",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"configuration",
"=",
"$",
"event",
"->",
"getComposer",
"(",
")",
"->",
"getPackage",
"(",
")",
"->",
"getExtra",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"configuration",
"[",
"'writable-dirs'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The writable-dirs must be specified in composer arbitrary extra data.'",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"configuration",
"[",
"'writable-dirs'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The writable-dirs must be an array.'",
")",
";",
"}",
"return",
"$",
"configuration",
"[",
"'writable-dirs'",
"]",
";",
"}"
] |
returns a list of writeable directories specified in the writeable-dirs composer extra options
@param Event $event
@return array an array of directory paths
|
[
"returns",
"a",
"list",
"of",
"writeable",
"directories",
"specified",
"in",
"the",
"writeable",
"-",
"dirs",
"composer",
"extra",
"options"
] |
128efde0b61f5623b094cbb399e66ab4aa0dba3f
|
https://github.com/interserver/myadmin-plugin-installer/blob/128efde0b61f5623b094cbb399e66ab4aa0dba3f/src/Plugin.php#L153-L163
|
225,402
|
interserver/myadmin-plugin-installer
|
src/Plugin.php
|
Plugin.setPermissionsSetfacl
|
public static function setPermissionsSetfacl(Event $event)
{
$http_user = self::getHttpdUser($event);
foreach (self::getWritableDirs($event) as $path) {
self::SetfaclPermissionsSetter($event, $http_user, $path);
}
foreach (self::getWritableFiles($event) as $path) {
self::ChmodPermissionsSetter($event, $http_user, $path, 'file');
}
}
|
php
|
public static function setPermissionsSetfacl(Event $event)
{
$http_user = self::getHttpdUser($event);
foreach (self::getWritableDirs($event) as $path) {
self::SetfaclPermissionsSetter($event, $http_user, $path);
}
foreach (self::getWritableFiles($event) as $path) {
self::ChmodPermissionsSetter($event, $http_user, $path, 'file');
}
}
|
[
"public",
"static",
"function",
"setPermissionsSetfacl",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"http_user",
"=",
"self",
"::",
"getHttpdUser",
"(",
"$",
"event",
")",
";",
"foreach",
"(",
"self",
"::",
"getWritableDirs",
"(",
"$",
"event",
")",
"as",
"$",
"path",
")",
"{",
"self",
"::",
"SetfaclPermissionsSetter",
"(",
"$",
"event",
",",
"$",
"http_user",
",",
"$",
"path",
")",
";",
"}",
"foreach",
"(",
"self",
"::",
"getWritableFiles",
"(",
"$",
"event",
")",
"as",
"$",
"path",
")",
"{",
"self",
"::",
"ChmodPermissionsSetter",
"(",
"$",
"event",
",",
"$",
"http_user",
",",
"$",
"path",
",",
"'file'",
")",
";",
"}",
"}"
] |
Sets Writrable Directory permissions for any directories listed in the writeable-dirs option using setfacl
@param Event $event
|
[
"Sets",
"Writrable",
"Directory",
"permissions",
"for",
"any",
"directories",
"listed",
"in",
"the",
"writeable",
"-",
"dirs",
"option",
"using",
"setfacl"
] |
128efde0b61f5623b094cbb399e66ab4aa0dba3f
|
https://github.com/interserver/myadmin-plugin-installer/blob/128efde0b61f5623b094cbb399e66ab4aa0dba3f/src/Plugin.php#L188-L197
|
225,403
|
interserver/myadmin-plugin-installer
|
src/Plugin.php
|
Plugin.setPermissionsChmod
|
public static function setPermissionsChmod(Event $event)
{
$http_user = self::getHttpdUser($event);
foreach (self::getWritableDirs($event) as $path) {
self::ChmodPermissionsSetter($event, $http_user, $path, 'dir');
}
foreach (self::getWritableFiles($event) as $path) {
self::ChmodPermissionsSetter($event, $http_user, $path, 'file');
}
}
|
php
|
public static function setPermissionsChmod(Event $event)
{
$http_user = self::getHttpdUser($event);
foreach (self::getWritableDirs($event) as $path) {
self::ChmodPermissionsSetter($event, $http_user, $path, 'dir');
}
foreach (self::getWritableFiles($event) as $path) {
self::ChmodPermissionsSetter($event, $http_user, $path, 'file');
}
}
|
[
"public",
"static",
"function",
"setPermissionsChmod",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"http_user",
"=",
"self",
"::",
"getHttpdUser",
"(",
"$",
"event",
")",
";",
"foreach",
"(",
"self",
"::",
"getWritableDirs",
"(",
"$",
"event",
")",
"as",
"$",
"path",
")",
"{",
"self",
"::",
"ChmodPermissionsSetter",
"(",
"$",
"event",
",",
"$",
"http_user",
",",
"$",
"path",
",",
"'dir'",
")",
";",
"}",
"foreach",
"(",
"self",
"::",
"getWritableFiles",
"(",
"$",
"event",
")",
"as",
"$",
"path",
")",
"{",
"self",
"::",
"ChmodPermissionsSetter",
"(",
"$",
"event",
",",
"$",
"http_user",
",",
"$",
"path",
",",
"'file'",
")",
";",
"}",
"}"
] |
Sets Writrable Directory permissions for any directories listed in the writeable-dirs option using chmod
@param Event $event
|
[
"Sets",
"Writrable",
"Directory",
"permissions",
"for",
"any",
"directories",
"listed",
"in",
"the",
"writeable",
"-",
"dirs",
"option",
"using",
"chmod"
] |
128efde0b61f5623b094cbb399e66ab4aa0dba3f
|
https://github.com/interserver/myadmin-plugin-installer/blob/128efde0b61f5623b094cbb399e66ab4aa0dba3f/src/Plugin.php#L204-L213
|
225,404
|
interserver/myadmin-plugin-installer
|
src/Plugin.php
|
Plugin.getHttpdUser
|
public static function getHttpdUser(Event $event)
{
$ps = self::runProcess($event, 'ps aux');
preg_match_all('/^.*([a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx)$/m', $ps, $matches);
foreach ($matches[0] as $match) {
$user = substr($match, 0, strpos($match, ' '));
if ($user != 'root') {
return $user;
}
}
}
|
php
|
public static function getHttpdUser(Event $event)
{
$ps = self::runProcess($event, 'ps aux');
preg_match_all('/^.*([a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx)$/m', $ps, $matches);
foreach ($matches[0] as $match) {
$user = substr($match, 0, strpos($match, ' '));
if ($user != 'root') {
return $user;
}
}
}
|
[
"public",
"static",
"function",
"getHttpdUser",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"ps",
"=",
"self",
"::",
"runProcess",
"(",
"$",
"event",
",",
"'ps aux'",
")",
";",
"preg_match_all",
"(",
"'/^.*([a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx)$/m'",
",",
"$",
"ps",
",",
"$",
"matches",
")",
";",
"foreach",
"(",
"$",
"matches",
"[",
"0",
"]",
"as",
"$",
"match",
")",
"{",
"$",
"user",
"=",
"substr",
"(",
"$",
"match",
",",
"0",
",",
"strpos",
"(",
"$",
"match",
",",
"' '",
")",
")",
";",
"if",
"(",
"$",
"user",
"!=",
"'root'",
")",
"{",
"return",
"$",
"user",
";",
"}",
"}",
"}"
] |
returns the user the webserver is running as
@param Event $event
@return string the webserver username
|
[
"returns",
"the",
"user",
"the",
"webserver",
"is",
"running",
"as"
] |
128efde0b61f5623b094cbb399e66ab4aa0dba3f
|
https://github.com/interserver/myadmin-plugin-installer/blob/128efde0b61f5623b094cbb399e66ab4aa0dba3f/src/Plugin.php#L221-L231
|
225,405
|
interserver/myadmin-plugin-installer
|
src/Plugin.php
|
Plugin.EnsureDirExists
|
public static function EnsureDirExists(Event $event, $path)
{
if (!is_dir($path)) {
mkdir($path, 0777, true);
if (!is_dir($path)) {
throw new \Exception('Path Not Found: '.$path);
}
if ($event->getIO()->isVerbose() === true) {
$event->getIO()->write(sprintf('Created Directory <info>%s</info>', $path));
}
}
}
|
php
|
public static function EnsureDirExists(Event $event, $path)
{
if (!is_dir($path)) {
mkdir($path, 0777, true);
if (!is_dir($path)) {
throw new \Exception('Path Not Found: '.$path);
}
if ($event->getIO()->isVerbose() === true) {
$event->getIO()->write(sprintf('Created Directory <info>%s</info>', $path));
}
}
}
|
[
"public",
"static",
"function",
"EnsureDirExists",
"(",
"Event",
"$",
"event",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"mkdir",
"(",
"$",
"path",
",",
"0777",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Path Not Found: '",
".",
"$",
"path",
")",
";",
"}",
"if",
"(",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"isVerbose",
"(",
")",
"===",
"true",
")",
"{",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"sprintf",
"(",
"'Created Directory <info>%s</info>'",
",",
"$",
"path",
")",
")",
";",
"}",
"}",
"}"
] |
checks if the given directory exists and if not tries to create it.
@param Event $event
@param string $path the directory
@throws \Exception
|
[
"checks",
"if",
"the",
"given",
"directory",
"exists",
"and",
"if",
"not",
"tries",
"to",
"create",
"it",
"."
] |
128efde0b61f5623b094cbb399e66ab4aa0dba3f
|
https://github.com/interserver/myadmin-plugin-installer/blob/128efde0b61f5623b094cbb399e66ab4aa0dba3f/src/Plugin.php#L275-L286
|
225,406
|
interserver/myadmin-plugin-installer
|
src/Plugin.php
|
Plugin.EnsureFileExists
|
public static function EnsureFileExists(Event $event, $path)
{
if (!is_dir(dirname($path))) {
mkdir(dirname($path), 0777, true);
touch($path);
if (!file_exists($path)) {
throw new \Exception('File Not Found: '.$path);
}
if ($event->getIO()->isVerbose() === true) {
$event->getIO()->write(sprintf('Created File <info>%s</info>', $path));
}
}
}
|
php
|
public static function EnsureFileExists(Event $event, $path)
{
if (!is_dir(dirname($path))) {
mkdir(dirname($path), 0777, true);
touch($path);
if (!file_exists($path)) {
throw new \Exception('File Not Found: '.$path);
}
if ($event->getIO()->isVerbose() === true) {
$event->getIO()->write(sprintf('Created File <info>%s</info>', $path));
}
}
}
|
[
"public",
"static",
"function",
"EnsureFileExists",
"(",
"Event",
"$",
"event",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"path",
")",
",",
"0777",
",",
"true",
")",
";",
"touch",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'File Not Found: '",
".",
"$",
"path",
")",
";",
"}",
"if",
"(",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"isVerbose",
"(",
")",
"===",
"true",
")",
"{",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"sprintf",
"(",
"'Created File <info>%s</info>'",
",",
"$",
"path",
")",
")",
";",
"}",
"}",
"}"
] |
checks if the given file exists and if not tries to create it.
@param Event $event
@param string $path the directory
@throws \Exception
|
[
"checks",
"if",
"the",
"given",
"file",
"exists",
"and",
"if",
"not",
"tries",
"to",
"create",
"it",
"."
] |
128efde0b61f5623b094cbb399e66ab4aa0dba3f
|
https://github.com/interserver/myadmin-plugin-installer/blob/128efde0b61f5623b094cbb399e66ab4aa0dba3f/src/Plugin.php#L295-L307
|
225,407
|
interserver/myadmin-plugin-installer
|
src/Plugin.php
|
Plugin.runProcess
|
public static function runProcess(Event $event, $commandline)
{
if ($event->getIO()->isVerbose() === true) {
$event->getIO()->write(sprintf('Running <info>%s</info>', $commandline));
}
exec($commandline, $output, $return);
if ($return != 0) {
throw new \Exception('Returned Error Code '.$return);
}
return implode(PHP_EOL, $output);
}
|
php
|
public static function runProcess(Event $event, $commandline)
{
if ($event->getIO()->isVerbose() === true) {
$event->getIO()->write(sprintf('Running <info>%s</info>', $commandline));
}
exec($commandline, $output, $return);
if ($return != 0) {
throw new \Exception('Returned Error Code '.$return);
}
return implode(PHP_EOL, $output);
}
|
[
"public",
"static",
"function",
"runProcess",
"(",
"Event",
"$",
"event",
",",
"$",
"commandline",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"isVerbose",
"(",
")",
"===",
"true",
")",
"{",
"$",
"event",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"sprintf",
"(",
"'Running <info>%s</info>'",
",",
"$",
"commandline",
")",
")",
";",
"}",
"exec",
"(",
"$",
"commandline",
",",
"$",
"output",
",",
"$",
"return",
")",
";",
"if",
"(",
"$",
"return",
"!=",
"0",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Returned Error Code '",
".",
"$",
"return",
")",
";",
"}",
"return",
"implode",
"(",
"PHP_EOL",
",",
"$",
"output",
")",
";",
"}"
] |
runs a command process returning the output and checking return code
@param Event $event
@param string $commandline the command line to run
@return string the output
@throws \Exception
|
[
"runs",
"a",
"command",
"process",
"returning",
"the",
"output",
"and",
"checking",
"return",
"code"
] |
128efde0b61f5623b094cbb399e66ab4aa0dba3f
|
https://github.com/interserver/myadmin-plugin-installer/blob/128efde0b61f5623b094cbb399e66ab4aa0dba3f/src/Plugin.php#L317-L327
|
225,408
|
cmsgears/module-forms
|
common/models/resources/FormSubmitField.php
|
FormSubmitField.findByFormSubmitId
|
public static function findByFormSubmitId( $formSubmitId ) {
$frmSubmitTable = FormTables::getTableName( FormTables::TABLE_FORM_SUBMIT );
$query = static::find()->joinWith( 'formSubmit' )->where( "$frmSubmitTable.id=:id", [ ':id' => $formSubmitId ] );
return $query->all();
}
|
php
|
public static function findByFormSubmitId( $formSubmitId ) {
$frmSubmitTable = FormTables::getTableName( FormTables::TABLE_FORM_SUBMIT );
$query = static::find()->joinWith( 'formSubmit' )->where( "$frmSubmitTable.id=:id", [ ':id' => $formSubmitId ] );
return $query->all();
}
|
[
"public",
"static",
"function",
"findByFormSubmitId",
"(",
"$",
"formSubmitId",
")",
"{",
"$",
"frmSubmitTable",
"=",
"FormTables",
"::",
"getTableName",
"(",
"FormTables",
"::",
"TABLE_FORM_SUBMIT",
")",
";",
"$",
"query",
"=",
"static",
"::",
"find",
"(",
")",
"->",
"joinWith",
"(",
"'formSubmit'",
")",
"->",
"where",
"(",
"\"$frmSubmitTable.id=:id\"",
",",
"[",
"':id'",
"=>",
"$",
"formSubmitId",
"]",
")",
";",
"return",
"$",
"query",
"->",
"all",
"(",
")",
";",
"}"
] |
Find and return the form submit fields associated with given form submit id.
@param integer $formSubmitId
@return FormSubmitField[]
|
[
"Find",
"and",
"return",
"the",
"form",
"submit",
"fields",
"associated",
"with",
"given",
"form",
"submit",
"id",
"."
] |
84cbb26e8ecb945410bb2604b84440d5ed841308
|
https://github.com/cmsgears/module-forms/blob/84cbb26e8ecb945410bb2604b84440d5ed841308/common/models/resources/FormSubmitField.php#L165-L172
|
225,409
|
cmsgears/module-forms
|
common/models/resources/FormSubmitField.php
|
FormSubmitField.findByName
|
public static function findByName( $formSubmitId, $name ) {
$frmSubmitTable = FormTables::getTableName( FormTables::TABLE_FORM_SUBMIT );
$frmSubmitFieldTable = FormTables::getTableName( FormTables::TABLE_FORM_SUBMIT_FIELD );
$query = static::find()->joinWith( 'formSubmit' )->where( "$frmSubmitTable.id=:id AND $frmSubmitFieldTable.name=:name", [ ':id' => $formSubmitId, ':name' => $name ] );
return $query->one();
}
|
php
|
public static function findByName( $formSubmitId, $name ) {
$frmSubmitTable = FormTables::getTableName( FormTables::TABLE_FORM_SUBMIT );
$frmSubmitFieldTable = FormTables::getTableName( FormTables::TABLE_FORM_SUBMIT_FIELD );
$query = static::find()->joinWith( 'formSubmit' )->where( "$frmSubmitTable.id=:id AND $frmSubmitFieldTable.name=:name", [ ':id' => $formSubmitId, ':name' => $name ] );
return $query->one();
}
|
[
"public",
"static",
"function",
"findByName",
"(",
"$",
"formSubmitId",
",",
"$",
"name",
")",
"{",
"$",
"frmSubmitTable",
"=",
"FormTables",
"::",
"getTableName",
"(",
"FormTables",
"::",
"TABLE_FORM_SUBMIT",
")",
";",
"$",
"frmSubmitFieldTable",
"=",
"FormTables",
"::",
"getTableName",
"(",
"FormTables",
"::",
"TABLE_FORM_SUBMIT_FIELD",
")",
";",
"$",
"query",
"=",
"static",
"::",
"find",
"(",
")",
"->",
"joinWith",
"(",
"'formSubmit'",
")",
"->",
"where",
"(",
"\"$frmSubmitTable.id=:id AND $frmSubmitFieldTable.name=:name\"",
",",
"[",
"':id'",
"=>",
"$",
"formSubmitId",
",",
"':name'",
"=>",
"$",
"name",
"]",
")",
";",
"return",
"$",
"query",
"->",
"one",
"(",
")",
";",
"}"
] |
Find and return the form submit field associated with given form submit id and name.
@param integer $formSubmitId
@param string $name
@return FormSubmitField
|
[
"Find",
"and",
"return",
"the",
"form",
"submit",
"field",
"associated",
"with",
"given",
"form",
"submit",
"id",
"and",
"name",
"."
] |
84cbb26e8ecb945410bb2604b84440d5ed841308
|
https://github.com/cmsgears/module-forms/blob/84cbb26e8ecb945410bb2604b84440d5ed841308/common/models/resources/FormSubmitField.php#L181-L189
|
225,410
|
Finesse/MiniDB
|
src/Parts/RawHelpersTrait.php
|
RawHelpersTrait.addTablePrefix
|
public function addTablePrefix(string $table): string
{
return ($this->tablePrefixer ?? $this->database->getTablePrefixer())->addTablePrefix($table);
}
|
php
|
public function addTablePrefix(string $table): string
{
return ($this->tablePrefixer ?? $this->database->getTablePrefixer())->addTablePrefix($table);
}
|
[
"public",
"function",
"addTablePrefix",
"(",
"string",
"$",
"table",
")",
":",
"string",
"{",
"return",
"(",
"$",
"this",
"->",
"tablePrefixer",
"??",
"$",
"this",
"->",
"database",
"->",
"getTablePrefixer",
"(",
")",
")",
"->",
"addTablePrefix",
"(",
"$",
"table",
")",
";",
"}"
] |
Adds the table prefix to a table name.
@param string $table Table name without quotes
@return string Table name with prefix
|
[
"Adds",
"the",
"table",
"prefix",
"to",
"a",
"table",
"name",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/RawHelpersTrait.php#L37-L40
|
225,411
|
Finesse/MiniDB
|
src/Parts/RawHelpersTrait.php
|
RawHelpersTrait.addTablePrefixToColumn
|
public function addTablePrefixToColumn(string $column): string
{
return ($this->tablePrefixer ?? $this->database->getTablePrefixer())->addTablePrefixToColumn($column);
}
|
php
|
public function addTablePrefixToColumn(string $column): string
{
return ($this->tablePrefixer ?? $this->database->getTablePrefixer())->addTablePrefixToColumn($column);
}
|
[
"public",
"function",
"addTablePrefixToColumn",
"(",
"string",
"$",
"column",
")",
":",
"string",
"{",
"return",
"(",
"$",
"this",
"->",
"tablePrefixer",
"??",
"$",
"this",
"->",
"database",
"->",
"getTablePrefixer",
"(",
")",
")",
"->",
"addTablePrefixToColumn",
"(",
"$",
"column",
")",
";",
"}"
] |
Adds the table prefix to a column name which may contain table name or alias.
@param string $column Column name without quotes
@return string Column name with prefixed table name
|
[
"Adds",
"the",
"table",
"prefix",
"to",
"a",
"column",
"name",
"which",
"may",
"contain",
"table",
"name",
"or",
"alias",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/RawHelpersTrait.php#L48-L51
|
225,412
|
Finesse/MiniDB
|
src/Parts/RawHelpersTrait.php
|
RawHelpersTrait.escapeLikeWildcards
|
public function escapeLikeWildcards(string $string): string
{
return ($this->grammar ?? $this->database->getGrammar())->escapeLikeWildcards($string);
}
|
php
|
public function escapeLikeWildcards(string $string): string
{
return ($this->grammar ?? $this->database->getGrammar())->escapeLikeWildcards($string);
}
|
[
"public",
"function",
"escapeLikeWildcards",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"return",
"(",
"$",
"this",
"->",
"grammar",
"??",
"$",
"this",
"->",
"database",
"->",
"getGrammar",
"(",
")",
")",
"->",
"escapeLikeWildcards",
"(",
"$",
"string",
")",
";",
"}"
] |
Escapes the LIKE operator special characters. Doesn't escape general string wildcard characters because it is
another job.
@param string $string
@return string
|
[
"Escapes",
"the",
"LIKE",
"operator",
"special",
"characters",
".",
"Doesn",
"t",
"escape",
"general",
"string",
"wildcard",
"characters",
"because",
"it",
"is",
"another",
"job",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/RawHelpersTrait.php#L84-L87
|
225,413
|
bytic/Common
|
src/Records/Traits/PersistentCurrent.php
|
PersistentCurrent.getCurrent
|
public function getCurrent()
{
if ($this->current === null) {
$this->current = false;
$item = $this->getFromSession();
if (!$item) {
$item = $this->getFromCookie();
}
if ($item && $this->checkAccessCurrent($item)) {
$this->beforeSetCurrent($item);
$this->setAndSaveCurrent($item);
} else {
$this->setCurrent($this->getCurrentDefault());
}
}
return $this->current;
}
|
php
|
public function getCurrent()
{
if ($this->current === null) {
$this->current = false;
$item = $this->getFromSession();
if (!$item) {
$item = $this->getFromCookie();
}
if ($item && $this->checkAccessCurrent($item)) {
$this->beforeSetCurrent($item);
$this->setAndSaveCurrent($item);
} else {
$this->setCurrent($this->getCurrentDefault());
}
}
return $this->current;
}
|
[
"public",
"function",
"getCurrent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"current",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"current",
"=",
"false",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"getFromSession",
"(",
")",
";",
"if",
"(",
"!",
"$",
"item",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"getFromCookie",
"(",
")",
";",
"}",
"if",
"(",
"$",
"item",
"&&",
"$",
"this",
"->",
"checkAccessCurrent",
"(",
"$",
"item",
")",
")",
"{",
"$",
"this",
"->",
"beforeSetCurrent",
"(",
"$",
"item",
")",
";",
"$",
"this",
"->",
"setAndSaveCurrent",
"(",
"$",
"item",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setCurrent",
"(",
"$",
"this",
"->",
"getCurrentDefault",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"current",
";",
"}"
] |
Get current Persisted record
@return Record
|
[
"Get",
"current",
"Persisted",
"record"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/PersistentCurrent.php#L30-L49
|
225,414
|
bytic/Common
|
src/Records/Traits/PersistentCurrent.php
|
PersistentCurrent.getFromSession
|
public function getFromSession()
{
$sessionInfo = $this->getCurrentSessionData();
if (is_array($sessionInfo)) {
if (isset($sessionInfo['id']) && !empty($sessionInfo['id'])) {
$recordId = intval($sessionInfo['id']);
return $this->findOne($recordId);
}
}
return false;
}
|
php
|
public function getFromSession()
{
$sessionInfo = $this->getCurrentSessionData();
if (is_array($sessionInfo)) {
if (isset($sessionInfo['id']) && !empty($sessionInfo['id'])) {
$recordId = intval($sessionInfo['id']);
return $this->findOne($recordId);
}
}
return false;
}
|
[
"public",
"function",
"getFromSession",
"(",
")",
"{",
"$",
"sessionInfo",
"=",
"$",
"this",
"->",
"getCurrentSessionData",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"sessionInfo",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"sessionInfo",
"[",
"'id'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"sessionInfo",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"recordId",
"=",
"intval",
"(",
"$",
"sessionInfo",
"[",
"'id'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"findOne",
"(",
"$",
"recordId",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get persisted Record from Session
@return bool|Record
|
[
"Get",
"persisted",
"Record",
"from",
"Session"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/PersistentCurrent.php#L70-L83
|
225,415
|
bytic/Common
|
src/Records/Traits/PersistentCurrent.php
|
PersistentCurrent.getCurrentSessionData
|
public function getCurrentSessionData()
{
$varName = $this->getCurrentVarName();
return isset($_SESSION[$varName]) ? $_SESSION[$varName] : null;
}
|
php
|
public function getCurrentSessionData()
{
$varName = $this->getCurrentVarName();
return isset($_SESSION[$varName]) ? $_SESSION[$varName] : null;
}
|
[
"public",
"function",
"getCurrentSessionData",
"(",
")",
"{",
"$",
"varName",
"=",
"$",
"this",
"->",
"getCurrentVarName",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"varName",
"]",
")",
"?",
"$",
"_SESSION",
"[",
"$",
"varName",
"]",
":",
"null",
";",
"}"
] |
Get session data for persistent record from session
@return []|null
|
[
"Get",
"session",
"data",
"for",
"persistent",
"record",
"from",
"session"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/PersistentCurrent.php#L90-L95
|
225,416
|
bytic/Common
|
src/Records/Traits/PersistentCurrent.php
|
PersistentCurrent.setAndSaveCurrent
|
public function setAndSaveCurrent($item = false)
{
$this->setCurrent($item);
$this->savePersistCurrent($item);
return $this;
}
|
php
|
public function setAndSaveCurrent($item = false)
{
$this->setCurrent($item);
$this->savePersistCurrent($item);
return $this;
}
|
[
"public",
"function",
"setAndSaveCurrent",
"(",
"$",
"item",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setCurrent",
"(",
"$",
"item",
")",
";",
"$",
"this",
"->",
"savePersistCurrent",
"(",
"$",
"item",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set and save persisted model
@param Record|boolean $item
@return $this
|
[
"Set",
"and",
"save",
"persisted",
"model"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/PersistentCurrent.php#L126-L132
|
225,417
|
bytic/Common
|
src/Records/Traits/PersistentCurrent.php
|
PersistentCurrent.savePersistCurrentCookie
|
public function savePersistCurrentCookie($item)
{
$varName = $this->getCurrentVarName();
CookieJar::instance()->newCookie()
->setName($varName)
->setValue($item->id)
->save();
}
|
php
|
public function savePersistCurrentCookie($item)
{
$varName = $this->getCurrentVarName();
CookieJar::instance()->newCookie()
->setName($varName)
->setValue($item->id)
->save();
}
|
[
"public",
"function",
"savePersistCurrentCookie",
"(",
"$",
"item",
")",
"{",
"$",
"varName",
"=",
"$",
"this",
"->",
"getCurrentVarName",
"(",
")",
";",
"CookieJar",
"::",
"instance",
"(",
")",
"->",
"newCookie",
"(",
")",
"->",
"setName",
"(",
"$",
"varName",
")",
"->",
"setValue",
"(",
"$",
"item",
"->",
"id",
")",
"->",
"save",
"(",
")",
";",
"}"
] |
Save record in Cookie
@param Record|boolean $item Record to save in cookie
@return void
|
[
"Save",
"record",
"in",
"Cookie"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/PersistentCurrent.php#L221-L228
|
225,418
|
bytic/Common
|
src/Records/Traits/PersistentCurrent.php
|
PersistentCurrent.getFromCookie
|
public function getFromCookie()
{
$varName = $this->getCurrentVarName();
if (isset($_COOKIE[$varName])) {
$recordId = $_COOKIE[$varName];
$item = $this->findOne(intval($recordId));
if ($item) {
return $item;
}
}
return false;
}
|
php
|
public function getFromCookie()
{
$varName = $this->getCurrentVarName();
if (isset($_COOKIE[$varName])) {
$recordId = $_COOKIE[$varName];
$item = $this->findOne(intval($recordId));
if ($item) {
return $item;
}
}
return false;
}
|
[
"public",
"function",
"getFromCookie",
"(",
")",
"{",
"$",
"varName",
"=",
"$",
"this",
"->",
"getCurrentVarName",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"varName",
"]",
")",
")",
"{",
"$",
"recordId",
"=",
"$",
"_COOKIE",
"[",
"$",
"varName",
"]",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"findOne",
"(",
"intval",
"(",
"$",
"recordId",
")",
")",
";",
"if",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get persistent record from Cookie
@return bool|Record
|
[
"Get",
"persistent",
"record",
"from",
"Cookie"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/PersistentCurrent.php#L235-L248
|
225,419
|
SetBased/php-abc-form
|
src/Validator/ProxyValidator.php
|
ProxyValidator.validate
|
public function validate(Control $control): bool
{
return ($this->data===null) ? ($this->callable)($control) : ($this->callable)($control, $this->data);
}
|
php
|
public function validate(Control $control): bool
{
return ($this->data===null) ? ($this->callable)($control) : ($this->callable)($control, $this->data);
}
|
[
"public",
"function",
"validate",
"(",
"Control",
"$",
"control",
")",
":",
"bool",
"{",
"return",
"(",
"$",
"this",
"->",
"data",
"===",
"null",
")",
"?",
"(",
"$",
"this",
"->",
"callable",
")",
"(",
"$",
"control",
")",
":",
"(",
"$",
"this",
"->",
"callable",
")",
"(",
"$",
"control",
",",
"$",
"this",
"->",
"data",
")",
";",
"}"
] |
Returns true if the value of the form control meets the conditions of this validator. Returns false otherwise.
@param Control $control The form control.
@return bool
@since 1.0.0
@api
|
[
"Returns",
"true",
"if",
"the",
"value",
"of",
"the",
"form",
"control",
"meets",
"the",
"conditions",
"of",
"this",
"validator",
".",
"Returns",
"false",
"otherwise",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Validator/ProxyValidator.php#L55-L58
|
225,420
|
cmsgears/module-notify
|
common/components/EventManager.php
|
EventManager.triggerActivity
|
public function triggerActivity( $slug, $data, $config = [] ) {
// Return in case activity logging is disabled at system level.
if( !Yii::$app->core->isActivities() ) {
return false;
}
// Generate Message
$template = $this->templateService->getBySlugType( $slug, NotifyGlobal::TYPE_ACTIVITY );
// Do nothing if template not found or disabled
if( empty( $template ) || !$template->isActive() ) {
return;
}
$message = Yii::$app->templateManager->renderMessage( $template, $data, $config );
// Trigger Activity
$templateConfig = $template->getDataMeta( CoreGlobal::DATA_CONFIG );
$model = $data[ 'model' ];
$gridData = [];
$gridData[ 'content' ] = isset( $templateConfig->storeContent ) && $model->hasAttribute( 'content' ) ? $model->content : null;
$gridData[ 'data' ] = isset( $templateConfig->storeData ) && $model->hasAttribute( 'data' ) ? $model->data : null;
$gridData[ 'cache' ] = isset( $templateConfig->storeCache ) && $model->hasAttribute( 'cache' ) ? $model->cache : null;
$activity = $this->activityService->getModelObject();
$activity->userId = $config[ 'userId' ];
$activity->parentId = isset( $config[ 'parentId' ] ) ? $config[ 'parentId' ] : null;
$activity->parentType = isset( $config[ 'parentType' ] ) ? $config[ 'parentType' ] : null;
$activity->admin = isset( $config[ 'admin' ] ) ? $config[ 'admin' ] : false;
$activity->consumed = false;
$activity->trash = false;
$activity->content = $message;
$activity->gridCache = json_encode( $gridData );
$activity->gridCacheValid = true;
$activity->gridCachedAt = DateUtil::getDateTime();
$activity->type = "log";
if( isset( $config[ 'title' ] ) ) {
$activity->title = $config[ 'title' ];
}
else {
$activity->title = $template->name;
}
// Create Activity
$this->activityService->create( $activity, $config );
$user = Yii::$app->user->getIdentity();
$user->lastActivityAt = DateUtil::getDateTime();
$user->update();
}
|
php
|
public function triggerActivity( $slug, $data, $config = [] ) {
// Return in case activity logging is disabled at system level.
if( !Yii::$app->core->isActivities() ) {
return false;
}
// Generate Message
$template = $this->templateService->getBySlugType( $slug, NotifyGlobal::TYPE_ACTIVITY );
// Do nothing if template not found or disabled
if( empty( $template ) || !$template->isActive() ) {
return;
}
$message = Yii::$app->templateManager->renderMessage( $template, $data, $config );
// Trigger Activity
$templateConfig = $template->getDataMeta( CoreGlobal::DATA_CONFIG );
$model = $data[ 'model' ];
$gridData = [];
$gridData[ 'content' ] = isset( $templateConfig->storeContent ) && $model->hasAttribute( 'content' ) ? $model->content : null;
$gridData[ 'data' ] = isset( $templateConfig->storeData ) && $model->hasAttribute( 'data' ) ? $model->data : null;
$gridData[ 'cache' ] = isset( $templateConfig->storeCache ) && $model->hasAttribute( 'cache' ) ? $model->cache : null;
$activity = $this->activityService->getModelObject();
$activity->userId = $config[ 'userId' ];
$activity->parentId = isset( $config[ 'parentId' ] ) ? $config[ 'parentId' ] : null;
$activity->parentType = isset( $config[ 'parentType' ] ) ? $config[ 'parentType' ] : null;
$activity->admin = isset( $config[ 'admin' ] ) ? $config[ 'admin' ] : false;
$activity->consumed = false;
$activity->trash = false;
$activity->content = $message;
$activity->gridCache = json_encode( $gridData );
$activity->gridCacheValid = true;
$activity->gridCachedAt = DateUtil::getDateTime();
$activity->type = "log";
if( isset( $config[ 'title' ] ) ) {
$activity->title = $config[ 'title' ];
}
else {
$activity->title = $template->name;
}
// Create Activity
$this->activityService->create( $activity, $config );
$user = Yii::$app->user->getIdentity();
$user->lastActivityAt = DateUtil::getDateTime();
$user->update();
}
|
[
"public",
"function",
"triggerActivity",
"(",
"$",
"slug",
",",
"$",
"data",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"// Return in case activity logging is disabled at system level.",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
"core",
"->",
"isActivities",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Generate Message",
"$",
"template",
"=",
"$",
"this",
"->",
"templateService",
"->",
"getBySlugType",
"(",
"$",
"slug",
",",
"NotifyGlobal",
"::",
"TYPE_ACTIVITY",
")",
";",
"// Do nothing if template not found or disabled",
"if",
"(",
"empty",
"(",
"$",
"template",
")",
"||",
"!",
"$",
"template",
"->",
"isActive",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"message",
"=",
"Yii",
"::",
"$",
"app",
"->",
"templateManager",
"->",
"renderMessage",
"(",
"$",
"template",
",",
"$",
"data",
",",
"$",
"config",
")",
";",
"// Trigger Activity",
"$",
"templateConfig",
"=",
"$",
"template",
"->",
"getDataMeta",
"(",
"CoreGlobal",
"::",
"DATA_CONFIG",
")",
";",
"$",
"model",
"=",
"$",
"data",
"[",
"'model'",
"]",
";",
"$",
"gridData",
"=",
"[",
"]",
";",
"$",
"gridData",
"[",
"'content'",
"]",
"=",
"isset",
"(",
"$",
"templateConfig",
"->",
"storeContent",
")",
"&&",
"$",
"model",
"->",
"hasAttribute",
"(",
"'content'",
")",
"?",
"$",
"model",
"->",
"content",
":",
"null",
";",
"$",
"gridData",
"[",
"'data'",
"]",
"=",
"isset",
"(",
"$",
"templateConfig",
"->",
"storeData",
")",
"&&",
"$",
"model",
"->",
"hasAttribute",
"(",
"'data'",
")",
"?",
"$",
"model",
"->",
"data",
":",
"null",
";",
"$",
"gridData",
"[",
"'cache'",
"]",
"=",
"isset",
"(",
"$",
"templateConfig",
"->",
"storeCache",
")",
"&&",
"$",
"model",
"->",
"hasAttribute",
"(",
"'cache'",
")",
"?",
"$",
"model",
"->",
"cache",
":",
"null",
";",
"$",
"activity",
"=",
"$",
"this",
"->",
"activityService",
"->",
"getModelObject",
"(",
")",
";",
"$",
"activity",
"->",
"userId",
"=",
"$",
"config",
"[",
"'userId'",
"]",
";",
"$",
"activity",
"->",
"parentId",
"=",
"isset",
"(",
"$",
"config",
"[",
"'parentId'",
"]",
")",
"?",
"$",
"config",
"[",
"'parentId'",
"]",
":",
"null",
";",
"$",
"activity",
"->",
"parentType",
"=",
"isset",
"(",
"$",
"config",
"[",
"'parentType'",
"]",
")",
"?",
"$",
"config",
"[",
"'parentType'",
"]",
":",
"null",
";",
"$",
"activity",
"->",
"admin",
"=",
"isset",
"(",
"$",
"config",
"[",
"'admin'",
"]",
")",
"?",
"$",
"config",
"[",
"'admin'",
"]",
":",
"false",
";",
"$",
"activity",
"->",
"consumed",
"=",
"false",
";",
"$",
"activity",
"->",
"trash",
"=",
"false",
";",
"$",
"activity",
"->",
"content",
"=",
"$",
"message",
";",
"$",
"activity",
"->",
"gridCache",
"=",
"json_encode",
"(",
"$",
"gridData",
")",
";",
"$",
"activity",
"->",
"gridCacheValid",
"=",
"true",
";",
"$",
"activity",
"->",
"gridCachedAt",
"=",
"DateUtil",
"::",
"getDateTime",
"(",
")",
";",
"$",
"activity",
"->",
"type",
"=",
"\"log\"",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'title'",
"]",
")",
")",
"{",
"$",
"activity",
"->",
"title",
"=",
"$",
"config",
"[",
"'title'",
"]",
";",
"}",
"else",
"{",
"$",
"activity",
"->",
"title",
"=",
"$",
"template",
"->",
"name",
";",
"}",
"// Create Activity",
"$",
"this",
"->",
"activityService",
"->",
"create",
"(",
"$",
"activity",
",",
"$",
"config",
")",
";",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"getIdentity",
"(",
")",
";",
"$",
"user",
"->",
"lastActivityAt",
"=",
"DateUtil",
"::",
"getDateTime",
"(",
")",
";",
"$",
"user",
"->",
"update",
"(",
")",
";",
"}"
] |
Trigger Activity using given template, message and config
@param string $slug
@param array $data
@param array $config
@return boolean
|
[
"Trigger",
"Activity",
"using",
"given",
"template",
"message",
"and",
"config"
] |
2cca001d47dc4615c49cc704f0a3f8b0baf03cf6
|
https://github.com/cmsgears/module-notify/blob/2cca001d47dc4615c49cc704f0a3f8b0baf03cf6/common/components/EventManager.php#L414-L479
|
225,421
|
hiqdev/hipanel-hiart
|
src/Connection.php
|
Connection.getResponseError
|
public function getResponseError(ResponseInterface $response)
{
if ($this->isError($response)) {
$error = $this->getError($response);
if (in_array($error, ['invalid_token', 'not_allowed_ip'], true)) {
$this->app->user->logout();
$this->app->response->refresh()->send();
$this->app->end();
}
return $error ?: 'unknown api error';
}
if ($response->getRequest()->getQuery()->action === 'search') {
$this->fixResponse($response);
}
return false;
}
|
php
|
public function getResponseError(ResponseInterface $response)
{
if ($this->isError($response)) {
$error = $this->getError($response);
if (in_array($error, ['invalid_token', 'not_allowed_ip'], true)) {
$this->app->user->logout();
$this->app->response->refresh()->send();
$this->app->end();
}
return $error ?: 'unknown api error';
}
if ($response->getRequest()->getQuery()->action === 'search') {
$this->fixResponse($response);
}
return false;
}
|
[
"public",
"function",
"getResponseError",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isError",
"(",
"$",
"response",
")",
")",
"{",
"$",
"error",
"=",
"$",
"this",
"->",
"getError",
"(",
"$",
"response",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"error",
",",
"[",
"'invalid_token'",
",",
"'not_allowed_ip'",
"]",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"user",
"->",
"logout",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"response",
"->",
"refresh",
"(",
")",
"->",
"send",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"end",
"(",
")",
";",
"}",
"return",
"$",
"error",
"?",
":",
"'unknown api error'",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getRequest",
"(",
")",
"->",
"getQuery",
"(",
")",
"->",
"action",
"===",
"'search'",
")",
"{",
"$",
"this",
"->",
"fixResponse",
"(",
"$",
"response",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Calls fixResponse.
@param ResponseInterface $response
@return string|false error text or false
|
[
"Calls",
"fixResponse",
"."
] |
68e9cbc5a36813ca1127e5148735d416582c9d59
|
https://github.com/hiqdev/hipanel-hiart/blob/68e9cbc5a36813ca1127e5148735d416582c9d59/src/Connection.php#L65-L83
|
225,422
|
MatyCZ/LemoTracy
|
src/Options/TracyOptions.php
|
TracyOptions.setLogDirectory
|
public function setLogDirectory(?string $path): self
{
if (null !== $path) {
if (!is_dir($path)) {
throw new InvalidArgumentException(sprintf(
"Tracy log path '%s' does`t exists",
$path
));
}
$path = realpath($path);
}
$this->logDirectory = $path;
return $this;
}
|
php
|
public function setLogDirectory(?string $path): self
{
if (null !== $path) {
if (!is_dir($path)) {
throw new InvalidArgumentException(sprintf(
"Tracy log path '%s' does`t exists",
$path
));
}
$path = realpath($path);
}
$this->logDirectory = $path;
return $this;
}
|
[
"public",
"function",
"setLogDirectory",
"(",
"?",
"string",
"$",
"path",
")",
":",
"self",
"{",
"if",
"(",
"null",
"!==",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"Tracy log path '%s' does`t exists\"",
",",
"$",
"path",
")",
")",
";",
"}",
"$",
"path",
"=",
"realpath",
"(",
"$",
"path",
")",
";",
"}",
"$",
"this",
"->",
"logDirectory",
"=",
"$",
"path",
";",
"return",
"$",
"this",
";",
"}"
] |
Path to log directory
@param string $path
@throws InvalidArgumentException
@return self
|
[
"Path",
"to",
"log",
"directory"
] |
873a3690886cfb5727edea6ef2371504b825d479
|
https://github.com/MatyCZ/LemoTracy/blob/873a3690886cfb5727edea6ef2371504b825d479/src/Options/TracyOptions.php#L99-L114
|
225,423
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setLiveUpdateURL
|
public function setLiveUpdateURL($liveUpdateURL = 'https://secure.epayment.ro/order/lu.php')
{
if (!is_string($liveUpdateURL)) { //invalid data type
return false;
}
if (empty($liveUpdateURL)) { //empty string
return false;
}
$this->liveUpdateURL = $liveUpdateURL; //everything is ok
return true;
}
|
php
|
public function setLiveUpdateURL($liveUpdateURL = 'https://secure.epayment.ro/order/lu.php')
{
if (!is_string($liveUpdateURL)) { //invalid data type
return false;
}
if (empty($liveUpdateURL)) { //empty string
return false;
}
$this->liveUpdateURL = $liveUpdateURL; //everything is ok
return true;
}
|
[
"public",
"function",
"setLiveUpdateURL",
"(",
"$",
"liveUpdateURL",
"=",
"'https://secure.epayment.ro/order/lu.php'",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"liveUpdateURL",
")",
")",
"{",
"//invalid data type",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"liveUpdateURL",
")",
")",
"{",
"//empty string",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"liveUpdateURL",
"=",
"$",
"liveUpdateURL",
";",
"//everything is ok",
"return",
"true",
";",
"}"
] |
setLiveUpdateURL class method
Set up live update URL address
@access public
@param $liveUpdateURL - live update url address
@return boolean
|
[
"setLiveUpdateURL",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L268-L280
|
225,424
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setLanguage
|
public function setLanguage($language = 'ro')
{
$language = trim(strtolower($language));
switch ($language) {
case 'ro':
$this->language = 'ro';
break;
case 'en':
default:
$this->language = 'en';
}
return true;
}
|
php
|
public function setLanguage($language = 'ro')
{
$language = trim(strtolower($language));
switch ($language) {
case 'ro':
$this->language = 'ro';
break;
case 'en':
default:
$this->language = 'en';
}
return true;
}
|
[
"public",
"function",
"setLanguage",
"(",
"$",
"language",
"=",
"'ro'",
")",
"{",
"$",
"language",
"=",
"trim",
"(",
"strtolower",
"(",
"$",
"language",
")",
")",
";",
"switch",
"(",
"$",
"language",
")",
"{",
"case",
"'ro'",
":",
"$",
"this",
"->",
"language",
"=",
"'ro'",
";",
"break",
";",
"case",
"'en'",
":",
"default",
":",
"$",
"this",
"->",
"language",
"=",
"'en'",
";",
"}",
"return",
"true",
";",
"}"
] |
setLanguage class method
Sets the order language
@access public
@param $language - string
@return boolean
|
[
"setLanguage",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L320-L333
|
225,425
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setSecretKey
|
public function setSecretKey($secretKey)
{
if (!is_string($secretKey)) {
$this->secretKeyError = 'invalid type';
return false;
}
if (empty($secretKey)) {
$this->secretKeyError = 'empty string';
return false;
}
if (strlen($secretKey) > 64) {
$this->secretKeyError = 'secret key is length is too big';
return false;
}
if (preg_match("/ /i", $secretKey)) {
$this->secretKeyError = 'invalid format; white spaces not allowed';
return false;
}
$this->secretKey = $secretKey;
return true;
}
|
php
|
public function setSecretKey($secretKey)
{
if (!is_string($secretKey)) {
$this->secretKeyError = 'invalid type';
return false;
}
if (empty($secretKey)) {
$this->secretKeyError = 'empty string';
return false;
}
if (strlen($secretKey) > 64) {
$this->secretKeyError = 'secret key is length is too big';
return false;
}
if (preg_match("/ /i", $secretKey)) {
$this->secretKeyError = 'invalid format; white spaces not allowed';
return false;
}
$this->secretKey = $secretKey;
return true;
}
|
[
"public",
"function",
"setSecretKey",
"(",
"$",
"secretKey",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"secretKey",
")",
")",
"{",
"$",
"this",
"->",
"secretKeyError",
"=",
"'invalid type'",
";",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"secretKey",
")",
")",
"{",
"$",
"this",
"->",
"secretKeyError",
"=",
"'empty string'",
";",
"return",
"false",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"secretKey",
")",
">",
"64",
")",
"{",
"$",
"this",
"->",
"secretKeyError",
"=",
"'secret key is length is too big'",
";",
"return",
"false",
";",
"}",
"if",
"(",
"preg_match",
"(",
"\"/ /i\"",
",",
"$",
"secretKey",
")",
")",
"{",
"$",
"this",
"->",
"secretKeyError",
"=",
"'invalid format; white spaces not allowed'",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"secretKey",
"=",
"$",
"secretKey",
";",
"return",
"true",
";",
"}"
] |
setSecretKey class method
Sets the secret key used for HASH signature
@access public
@param $secretKey - string
@return boolean
|
[
"setSecretKey",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L344-L373
|
225,426
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderDate
|
public function setOrderDate($orderDate = '')
{
if (strtotime($orderDate) === -1) {
$this->orderDate = null;
return false;
}
$dateFormatPattern = "^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))^";
if (!preg_match($dateFormatPattern, $orderDate)) {
$this->orderDate = null;
return false;
}
if (strtotime($orderDate) > strtotime(date("Y-m-d H:i:s"))) {
$this->orderDate = null;
return false;
}
$this->orderDate = $orderDate;
return true;
}
|
php
|
public function setOrderDate($orderDate = '')
{
if (strtotime($orderDate) === -1) {
$this->orderDate = null;
return false;
}
$dateFormatPattern = "^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))^";
if (!preg_match($dateFormatPattern, $orderDate)) {
$this->orderDate = null;
return false;
}
if (strtotime($orderDate) > strtotime(date("Y-m-d H:i:s"))) {
$this->orderDate = null;
return false;
}
$this->orderDate = $orderDate;
return true;
}
|
[
"public",
"function",
"setOrderDate",
"(",
"$",
"orderDate",
"=",
"''",
")",
"{",
"if",
"(",
"strtotime",
"(",
"$",
"orderDate",
")",
"===",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"orderDate",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"dateFormatPattern",
"=",
"\"^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))^\"",
";",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"dateFormatPattern",
",",
"$",
"orderDate",
")",
")",
"{",
"$",
"this",
"->",
"orderDate",
"=",
"null",
";",
"return",
"false",
";",
"}",
"if",
"(",
"strtotime",
"(",
"$",
"orderDate",
")",
">",
"strtotime",
"(",
"date",
"(",
"\"Y-m-d H:i:s\"",
")",
")",
")",
"{",
"$",
"this",
"->",
"orderDate",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderDate",
"=",
"$",
"orderDate",
";",
"return",
"true",
";",
"}"
] |
setOrderDate class method
@access public
@param $orderDate string
@return boolean
|
[
"setOrderDate",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L430-L455
|
225,427
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderPName
|
public function setOrderPName($orderPName)
{
if (!is_array($orderPName)) {
$this->orderPName = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPName)) {
if (strlen($orderPName[$index]) > 155) {
$isValid = false;
} else {
$isValid = true;
}
$index++;
}
if (!$isValid) {
$this->orderPName = null;
return false;
}
$this->orderPName = $orderPName;
return true;
}
|
php
|
public function setOrderPName($orderPName)
{
if (!is_array($orderPName)) {
$this->orderPName = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPName)) {
if (strlen($orderPName[$index]) > 155) {
$isValid = false;
} else {
$isValid = true;
}
$index++;
}
if (!$isValid) {
$this->orderPName = null;
return false;
}
$this->orderPName = $orderPName;
return true;
}
|
[
"public",
"function",
"setOrderPName",
"(",
"$",
"orderPName",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"orderPName",
")",
")",
"{",
"$",
"this",
"->",
"orderPName",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"isValid",
"=",
"true",
";",
"$",
"index",
"=",
"0",
";",
"while",
"(",
"$",
"isValid",
"&&",
"$",
"index",
"<",
"count",
"(",
"$",
"orderPName",
")",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"orderPName",
"[",
"$",
"index",
"]",
")",
">",
"155",
")",
"{",
"$",
"isValid",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"isValid",
"=",
"true",
";",
"}",
"$",
"index",
"++",
";",
"}",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"$",
"this",
"->",
"orderPName",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderPName",
"=",
"$",
"orderPName",
";",
"return",
"true",
";",
"}"
] |
setOrderPName class method
Sets shopping cart product names
@access public
@param $orderPName array
@return boolean
|
[
"setOrderPName",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L466-L491
|
225,428
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderPGroup
|
public function setOrderPGroup($orderPGroup)
{
if (!is_array($orderPGroup)) {
$this->orderPGroup = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPGroup)) {
if (strlen($orderPGroup[$index]) > 155) {
$isValid = false;
} else {
$isValid = true;
}
$index++;
}
if (!$isValid) {
$this->orderPGroup = null;
return false;
}
$this->orderPGroup = $orderPGroup;
return true;
}
|
php
|
public function setOrderPGroup($orderPGroup)
{
if (!is_array($orderPGroup)) {
$this->orderPGroup = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPGroup)) {
if (strlen($orderPGroup[$index]) > 155) {
$isValid = false;
} else {
$isValid = true;
}
$index++;
}
if (!$isValid) {
$this->orderPGroup = null;
return false;
}
$this->orderPGroup = $orderPGroup;
return true;
}
|
[
"public",
"function",
"setOrderPGroup",
"(",
"$",
"orderPGroup",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"orderPGroup",
")",
")",
"{",
"$",
"this",
"->",
"orderPGroup",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"isValid",
"=",
"true",
";",
"$",
"index",
"=",
"0",
";",
"while",
"(",
"$",
"isValid",
"&&",
"$",
"index",
"<",
"count",
"(",
"$",
"orderPGroup",
")",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"orderPGroup",
"[",
"$",
"index",
"]",
")",
">",
"155",
")",
"{",
"$",
"isValid",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"isValid",
"=",
"true",
";",
"}",
"$",
"index",
"++",
";",
"}",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"$",
"this",
"->",
"orderPGroup",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderPGroup",
"=",
"$",
"orderPGroup",
";",
"return",
"true",
";",
"}"
] |
setOrderPGroup class method
Sets products groups
@access public
@param $orderPGroup array
@return boolean
|
[
"setOrderPGroup",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L502-L527
|
225,429
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderPType
|
public function setOrderPType($orderPType)
{
if (!is_array($orderPType)) {
$this->orderPType = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPType)) {
if (!in_array($orderPType[$index], array('GROSS', 'NET'))) {
$isValid = false;
} else {
$isValid = true;
}
$index++;
}
if (!$isValid) {
$this->orderPType = null;
return false;
}
$this->orderPType = $orderPType;
return true;
}
|
php
|
public function setOrderPType($orderPType)
{
if (!is_array($orderPType)) {
$this->orderPType = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPType)) {
if (!in_array($orderPType[$index], array('GROSS', 'NET'))) {
$isValid = false;
} else {
$isValid = true;
}
$index++;
}
if (!$isValid) {
$this->orderPType = null;
return false;
}
$this->orderPType = $orderPType;
return true;
}
|
[
"public",
"function",
"setOrderPType",
"(",
"$",
"orderPType",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"orderPType",
")",
")",
"{",
"$",
"this",
"->",
"orderPType",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"isValid",
"=",
"true",
";",
"$",
"index",
"=",
"0",
";",
"while",
"(",
"$",
"isValid",
"&&",
"$",
"index",
"<",
"count",
"(",
"$",
"orderPType",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"orderPType",
"[",
"$",
"index",
"]",
",",
"array",
"(",
"'GROSS'",
",",
"'NET'",
")",
")",
")",
"{",
"$",
"isValid",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"isValid",
"=",
"true",
";",
"}",
"$",
"index",
"++",
";",
"}",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"$",
"this",
"->",
"orderPType",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderPType",
"=",
"$",
"orderPType",
";",
"return",
"true",
";",
"}"
] |
setOrderPType class method
Sets products price types
@access public
@param $orderPType array
@return boolean
|
[
"setOrderPType",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L538-L563
|
225,430
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderPCode
|
public function setOrderPCode($orderPCode)
{
if (!is_array($orderPCode)) {
$this->orderPCode = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPCode)) {
if (strlen($orderPCode[$index]) > 20) {
$isValid = false;
} else {
$isValid = true;
}
$index++;
}
if (!$isValid) {
$this->orderPCode = null;
return false;
}
$this->orderPCode = $orderPCode;
return true;
}
|
php
|
public function setOrderPCode($orderPCode)
{
if (!is_array($orderPCode)) {
$this->orderPCode = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPCode)) {
if (strlen($orderPCode[$index]) > 20) {
$isValid = false;
} else {
$isValid = true;
}
$index++;
}
if (!$isValid) {
$this->orderPCode = null;
return false;
}
$this->orderPCode = $orderPCode;
return true;
}
|
[
"public",
"function",
"setOrderPCode",
"(",
"$",
"orderPCode",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"orderPCode",
")",
")",
"{",
"$",
"this",
"->",
"orderPCode",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"isValid",
"=",
"true",
";",
"$",
"index",
"=",
"0",
";",
"while",
"(",
"$",
"isValid",
"&&",
"$",
"index",
"<",
"count",
"(",
"$",
"orderPCode",
")",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"orderPCode",
"[",
"$",
"index",
"]",
")",
">",
"20",
")",
"{",
"$",
"isValid",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"isValid",
"=",
"true",
";",
"}",
"$",
"index",
"++",
";",
"}",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"$",
"this",
"->",
"orderPCode",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderPCode",
"=",
"$",
"orderPCode",
";",
"return",
"true",
";",
"}"
] |
setOrderPCode class method
Sets shopping cart product codes
@access public
@param $orderPCode array
@return boolean
|
[
"setOrderPCode",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L574-L599
|
225,431
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderPInfo
|
public function setOrderPInfo($orderPInfo)
{
if (!is_array($orderPInfo)) {
$this->orderPInfo = null;
return false;
}
$this->orderPInfo = $orderPInfo;
return true;
}
|
php
|
public function setOrderPInfo($orderPInfo)
{
if (!is_array($orderPInfo)) {
$this->orderPInfo = null;
return false;
}
$this->orderPInfo = $orderPInfo;
return true;
}
|
[
"public",
"function",
"setOrderPInfo",
"(",
"$",
"orderPInfo",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"orderPInfo",
")",
")",
"{",
"$",
"this",
"->",
"orderPInfo",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderPInfo",
"=",
"$",
"orderPInfo",
";",
"return",
"true",
";",
"}"
] |
setOrderPInfo class method
Sets additional information for the products in the shopping cart
@access public
@param $orderPInfo array
@return boolean
|
[
"setOrderPInfo",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L610-L620
|
225,432
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderPrice
|
public function setOrderPrice($orderPrice)
{
if (!is_array($orderPrice)) {
$this->orderPrice = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPrice)) {
if (is_numeric($orderPrice[$index]) && $orderPrice[$index] > 0) {
$isValid = true;
} else {
$isValid = false;
}
$index++;
}
if (!$isValid) {
$this->orderPrice = null;
return false;
}
$this->orderPrice = $orderPrice;
return true;
}
|
php
|
public function setOrderPrice($orderPrice)
{
if (!is_array($orderPrice)) {
$this->orderPrice = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderPrice)) {
if (is_numeric($orderPrice[$index]) && $orderPrice[$index] > 0) {
$isValid = true;
} else {
$isValid = false;
}
$index++;
}
if (!$isValid) {
$this->orderPrice = null;
return false;
}
$this->orderPrice = $orderPrice;
return true;
}
|
[
"public",
"function",
"setOrderPrice",
"(",
"$",
"orderPrice",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"orderPrice",
")",
")",
"{",
"$",
"this",
"->",
"orderPrice",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"isValid",
"=",
"true",
";",
"$",
"index",
"=",
"0",
";",
"while",
"(",
"$",
"isValid",
"&&",
"$",
"index",
"<",
"count",
"(",
"$",
"orderPrice",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"orderPrice",
"[",
"$",
"index",
"]",
")",
"&&",
"$",
"orderPrice",
"[",
"$",
"index",
"]",
">",
"0",
")",
"{",
"$",
"isValid",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"isValid",
"=",
"false",
";",
"}",
"$",
"index",
"++",
";",
"}",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"$",
"this",
"->",
"orderPrice",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderPrice",
"=",
"$",
"orderPrice",
";",
"return",
"true",
";",
"}"
] |
setOrderPrice class method
Sets product prices
@access public
@param $orderPrice array
@return boolean
|
[
"setOrderPrice",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L631-L656
|
225,433
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderQTY
|
public function setOrderQTY($orderQty)
{
if (!is_array($orderQty)) {
$this->orderQty = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderQty)) {
if (is_numeric($orderQty[$index]) && $orderQty[$index] > 0) {
$isValid = true;
} else {
$isValid = false;
}
$index++;
}
if (!$isValid) {
$this->orderQty = null;
return false;
}
$this->orderQty = $orderQty;
return true;
}
|
php
|
public function setOrderQTY($orderQty)
{
if (!is_array($orderQty)) {
$this->orderQty = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderQty)) {
if (is_numeric($orderQty[$index]) && $orderQty[$index] > 0) {
$isValid = true;
} else {
$isValid = false;
}
$index++;
}
if (!$isValid) {
$this->orderQty = null;
return false;
}
$this->orderQty = $orderQty;
return true;
}
|
[
"public",
"function",
"setOrderQTY",
"(",
"$",
"orderQty",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"orderQty",
")",
")",
"{",
"$",
"this",
"->",
"orderQty",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"isValid",
"=",
"true",
";",
"$",
"index",
"=",
"0",
";",
"while",
"(",
"$",
"isValid",
"&&",
"$",
"index",
"<",
"count",
"(",
"$",
"orderQty",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"orderQty",
"[",
"$",
"index",
"]",
")",
"&&",
"$",
"orderQty",
"[",
"$",
"index",
"]",
">",
"0",
")",
"{",
"$",
"isValid",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"isValid",
"=",
"false",
";",
"}",
"$",
"index",
"++",
";",
"}",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"$",
"this",
"->",
"orderQty",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderQty",
"=",
"$",
"orderQty",
";",
"return",
"true",
";",
"}"
] |
setOrderQTY class method
Sets quantities for each product in the shopping cart
@access public
@param $orderQty array
@return boolean
|
[
"setOrderQTY",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L666-L691
|
225,434
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderVAT
|
public function setOrderVAT($orderVAT)
{
if (!is_array($orderVAT)) {
$this->orderVAT = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderVAT)) {
if (is_numeric($orderVAT[$index]) && $orderVAT[$index] >= 0 && $orderVAT[$index] < 100) {
$isValid = true;
} else {
$isValid = false;
}
$index++;
}
if (!$isValid) {
$this->orderVAT = null;
return false;
}
$this->orderVAT = $orderVAT;
return true;
}
|
php
|
public function setOrderVAT($orderVAT)
{
if (!is_array($orderVAT)) {
$this->orderVAT = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderVAT)) {
if (is_numeric($orderVAT[$index]) && $orderVAT[$index] >= 0 && $orderVAT[$index] < 100) {
$isValid = true;
} else {
$isValid = false;
}
$index++;
}
if (!$isValid) {
$this->orderVAT = null;
return false;
}
$this->orderVAT = $orderVAT;
return true;
}
|
[
"public",
"function",
"setOrderVAT",
"(",
"$",
"orderVAT",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"orderVAT",
")",
")",
"{",
"$",
"this",
"->",
"orderVAT",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"isValid",
"=",
"true",
";",
"$",
"index",
"=",
"0",
";",
"while",
"(",
"$",
"isValid",
"&&",
"$",
"index",
"<",
"count",
"(",
"$",
"orderVAT",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"orderVAT",
"[",
"$",
"index",
"]",
")",
"&&",
"$",
"orderVAT",
"[",
"$",
"index",
"]",
">=",
"0",
"&&",
"$",
"orderVAT",
"[",
"$",
"index",
"]",
"<",
"100",
")",
"{",
"$",
"isValid",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"isValid",
"=",
"false",
";",
"}",
"$",
"index",
"++",
";",
"}",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"$",
"this",
"->",
"orderVAT",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderVAT",
"=",
"$",
"orderVAT",
";",
"return",
"true",
";",
"}"
] |
setOrderVAT class method
Sets VAT for each product in the shopping cart
@access public
@param $orderVAT array
@return boolean
|
[
"setOrderVAT",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L701-L726
|
225,435
|
bytic/Common
|
src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php
|
LiveUpdate.setOrderVer
|
public function setOrderVer($orderVer)
{
if (!is_array($orderVer)) {
$this->orderVer = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderVer)) {
if (settype($orderVer[$index], "string")) {
if (strlen($orderVer[$index]) < 51) {
$isValid = true;
} else {
$isValid = false;
}
} else {
$isValid = false;
}
$index++;
}
if (!$isValid) {
$this->orderVer = null;
return false;
}
$this->orderVer = $orderVer;
return true;
}
|
php
|
public function setOrderVer($orderVer)
{
if (!is_array($orderVer)) {
$this->orderVer = null;
return false;
}
$isValid = true;
$index = 0;
while ($isValid && $index < count($orderVer)) {
if (settype($orderVer[$index], "string")) {
if (strlen($orderVer[$index]) < 51) {
$isValid = true;
} else {
$isValid = false;
}
} else {
$isValid = false;
}
$index++;
}
if (!$isValid) {
$this->orderVer = null;
return false;
}
$this->orderVer = $orderVer;
return true;
}
|
[
"public",
"function",
"setOrderVer",
"(",
"$",
"orderVer",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"orderVer",
")",
")",
"{",
"$",
"this",
"->",
"orderVer",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"isValid",
"=",
"true",
";",
"$",
"index",
"=",
"0",
";",
"while",
"(",
"$",
"isValid",
"&&",
"$",
"index",
"<",
"count",
"(",
"$",
"orderVer",
")",
")",
"{",
"if",
"(",
"settype",
"(",
"$",
"orderVer",
"[",
"$",
"index",
"]",
",",
"\"string\"",
")",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"orderVer",
"[",
"$",
"index",
"]",
")",
"<",
"51",
")",
"{",
"$",
"isValid",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"isValid",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"isValid",
"=",
"false",
";",
"}",
"$",
"index",
"++",
";",
"}",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"$",
"this",
"->",
"orderVer",
"=",
"null",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"orderVer",
"=",
"$",
"orderVer",
";",
"return",
"true",
";",
"}"
] |
setOrderVer class method
Sets products versions
@access public
@param $orderVer array
@return boolean
|
[
"setOrderVer",
"class",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Payments/Gateways/Providers/Payu/Api/LiveUpdate.php#L737-L766
|
225,436
|
froq/froq-event
|
src/Events.php
|
Events.setStack
|
public function setStack(array $stack): void
{
// reset
$this->stack = [];
foreach ($stack as $event) {
if (!$event instanceof Event) {
throw new EventException('Stack elements must be instanceof froq\event\Event object');
}
$this->stack[$this->normalizeName($event->getName())] = $event;
}
}
|
php
|
public function setStack(array $stack): void
{
// reset
$this->stack = [];
foreach ($stack as $event) {
if (!$event instanceof Event) {
throw new EventException('Stack elements must be instanceof froq\event\Event object');
}
$this->stack[$this->normalizeName($event->getName())] = $event;
}
}
|
[
"public",
"function",
"setStack",
"(",
"array",
"$",
"stack",
")",
":",
"void",
"{",
"// reset",
"$",
"this",
"->",
"stack",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"stack",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"event",
"instanceof",
"Event",
")",
"{",
"throw",
"new",
"EventException",
"(",
"'Stack elements must be instanceof froq\\event\\Event object'",
")",
";",
"}",
"$",
"this",
"->",
"stack",
"[",
"$",
"this",
"->",
"normalizeName",
"(",
"$",
"event",
"->",
"getName",
"(",
")",
")",
"]",
"=",
"$",
"event",
";",
"}",
"}"
] |
Set stack.
@param array $stack
@return void
@throws froq\eventException
|
[
"Set",
"stack",
"."
] |
f7a9afd3bbafd55a5974702fe455375e60daeefe
|
https://github.com/froq/froq-event/blob/f7a9afd3bbafd55a5974702fe455375e60daeefe/src/Events.php#L59-L71
|
225,437
|
SetBased/php-abc-form
|
src/Validator/EmailValidator.php
|
EmailValidator.validate
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
// An empty value is valid.
if ($value==='' || $value===null || $value===false)
{
return true;
}
// Objects and arrays are not valid email addresses.
if (!is_scalar($value))
{
return false;
}
// Filter valid email address from the value.
$email = filter_var($value, FILTER_VALIDATE_EMAIL);
// If the actual value and the filtered value are not equal the value is not a valid email address.
if ($email!==$value)
{
return false;
}
// Test if the domain does exists.
$domain = substr(strstr($value, '@'), 1);
if ($domain===false || $domain==='')
{
return false;
}
// The domain must have a MX or A record.
if (!(checkdnsrr($domain.'.', 'MX') || checkdnsrr($domain.'.', 'A')))
{
return false;
}
return true;
}
|
php
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
// An empty value is valid.
if ($value==='' || $value===null || $value===false)
{
return true;
}
// Objects and arrays are not valid email addresses.
if (!is_scalar($value))
{
return false;
}
// Filter valid email address from the value.
$email = filter_var($value, FILTER_VALIDATE_EMAIL);
// If the actual value and the filtered value are not equal the value is not a valid email address.
if ($email!==$value)
{
return false;
}
// Test if the domain does exists.
$domain = substr(strstr($value, '@'), 1);
if ($domain===false || $domain==='')
{
return false;
}
// The domain must have a MX or A record.
if (!(checkdnsrr($domain.'.', 'MX') || checkdnsrr($domain.'.', 'A')))
{
return false;
}
return true;
}
|
[
"public",
"function",
"validate",
"(",
"Control",
"$",
"control",
")",
":",
"bool",
"{",
"$",
"value",
"=",
"$",
"control",
"->",
"getSubmittedValue",
"(",
")",
";",
"// An empty value is valid.",
"if",
"(",
"$",
"value",
"===",
"''",
"||",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"true",
";",
"}",
"// Objects and arrays are not valid email addresses.",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Filter valid email address from the value.",
"$",
"email",
"=",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_EMAIL",
")",
";",
"// If the actual value and the filtered value are not equal the value is not a valid email address.",
"if",
"(",
"$",
"email",
"!==",
"$",
"value",
")",
"{",
"return",
"false",
";",
"}",
"// Test if the domain does exists.",
"$",
"domain",
"=",
"substr",
"(",
"strstr",
"(",
"$",
"value",
",",
"'@'",
")",
",",
"1",
")",
";",
"if",
"(",
"$",
"domain",
"===",
"false",
"||",
"$",
"domain",
"===",
"''",
")",
"{",
"return",
"false",
";",
"}",
"// The domain must have a MX or A record.",
"if",
"(",
"!",
"(",
"checkdnsrr",
"(",
"$",
"domain",
".",
"'.'",
",",
"'MX'",
")",
"||",
"checkdnsrr",
"(",
"$",
"domain",
".",
"'.'",
",",
"'A'",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Returns true if the value of the form control is a valid email address. Otherwise returns false.
Note:
* Empty values are considered valid.
* This validator will test if the domain exists.
@param Control $control The form control.
@return bool
@since 1.0.0
@api
|
[
"Returns",
"true",
"if",
"the",
"value",
"of",
"the",
"form",
"control",
"is",
"a",
"valid",
"email",
"address",
".",
"Otherwise",
"returns",
"false",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Validator/EmailValidator.php#L28-L67
|
225,438
|
stubbles/stubbles-input
|
src/main/php/Param.php
|
Param.isEmpty
|
public function isEmpty()
{
return $this->isNull()
|| (is_array($this->value) && count($this->value) === 0)
|| $this->length() === 0;
}
|
php
|
public function isEmpty()
{
return $this->isNull()
|| (is_array($this->value) && count($this->value) === 0)
|| $this->length() === 0;
}
|
[
"public",
"function",
"isEmpty",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"isNull",
"(",
")",
"||",
"(",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"value",
")",
"===",
"0",
")",
"||",
"$",
"this",
"->",
"length",
"(",
")",
"===",
"0",
";",
"}"
] |
checks if parameter is empty
Parameter is empty if its value is null or an empty string.
@return bool
|
[
"checks",
"if",
"parameter",
"is",
"empty"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/Param.php#L90-L95
|
225,439
|
stubbles/stubbles-input
|
src/main/php/Param.php
|
Param.length
|
public function length()
{
if ($this->isNull() || (is_string($this->value) && strlen($this->value) === 0)) {
return 0;
}
if (is_string($this->value)) {
return strlen($this->value);
}
return strlen(current($this->value));
}
|
php
|
public function length()
{
if ($this->isNull() || (is_string($this->value) && strlen($this->value) === 0)) {
return 0;
}
if (is_string($this->value)) {
return strlen($this->value);
}
return strlen(current($this->value));
}
|
[
"public",
"function",
"length",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNull",
"(",
")",
"||",
"(",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"strlen",
"(",
"$",
"this",
"->",
"value",
")",
"===",
"0",
")",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"return",
"strlen",
"(",
"$",
"this",
"->",
"value",
")",
";",
"}",
"return",
"strlen",
"(",
"current",
"(",
"$",
"this",
"->",
"value",
")",
")",
";",
"}"
] |
returns length of value
@return int
|
[
"returns",
"length",
"of",
"value"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/Param.php#L102-L113
|
225,440
|
stubbles/stubbles-input
|
src/main/php/Param.php
|
Param.addError
|
public function addError($error, array $details = [])
{
$error = ParamError::fromData($error, $details);
$this->errors[$error->id()] = $error;
return $error;
}
|
php
|
public function addError($error, array $details = [])
{
$error = ParamError::fromData($error, $details);
$this->errors[$error->id()] = $error;
return $error;
}
|
[
"public",
"function",
"addError",
"(",
"$",
"error",
",",
"array",
"$",
"details",
"=",
"[",
"]",
")",
"{",
"$",
"error",
"=",
"ParamError",
"::",
"fromData",
"(",
"$",
"error",
",",
"$",
"details",
")",
";",
"$",
"this",
"->",
"errors",
"[",
"$",
"error",
"->",
"id",
"(",
")",
"]",
"=",
"$",
"error",
";",
"return",
"$",
"error",
";",
"}"
] |
adds error with given id
@param \stubbles\input\errors\ParamError|string $error id of error or an instance of ParamError
@param array $details details of what caused the error
@return \stubbles\input\errors\ParamError
|
[
"adds",
"error",
"with",
"given",
"id"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/Param.php#L122-L127
|
225,441
|
stubbles/stubbles-input
|
src/main/php/ParamRequest.php
|
ParamRequest.readParam
|
public function readParam(string $paramName): ValueReader
{
return new ValueReader(
$this->params->errors(),
$paramName,
$this->params->value($paramName)
);
}
|
php
|
public function readParam(string $paramName): ValueReader
{
return new ValueReader(
$this->params->errors(),
$paramName,
$this->params->value($paramName)
);
}
|
[
"public",
"function",
"readParam",
"(",
"string",
"$",
"paramName",
")",
":",
"ValueReader",
"{",
"return",
"new",
"ValueReader",
"(",
"$",
"this",
"->",
"params",
"->",
"errors",
"(",
")",
",",
"$",
"paramName",
",",
"$",
"this",
"->",
"params",
"->",
"value",
"(",
"$",
"paramName",
")",
")",
";",
"}"
] |
returns request value from params for filtering or validation
@param string $paramName name of parameter
@return \stubbles\input\ValueReader
@since 1.3.0
|
[
"returns",
"request",
"value",
"from",
"params",
"for",
"filtering",
"or",
"validation"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ParamRequest.php#L87-L94
|
225,442
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/rolling/RollingFile.php
|
RollingFile.rollOver
|
private function rollOver() {
// If maxBackups <= 0, then there is no file renaming to be done.
if($this->maxBackupIndex > 0) {
// Delete the oldest file, to keep Windows happy.
$file = $this->file . '.' . $this->maxBackupIndex;
if (file_exists($file) && !unlink($file)) {
throw new \n2n\log4php\LoggerException("Unable to delete oldest backup file from [$file].");
}
// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
$this->renameArchievedLogs($this->file);
// Backup the active file
$this->moveToBackup($this->file);
}
// Truncate the active file
\n2n\io\IoUtils::ftruncate($this->fp, 0);
rewind($this->fp);
}
|
php
|
private function rollOver() {
// If maxBackups <= 0, then there is no file renaming to be done.
if($this->maxBackupIndex > 0) {
// Delete the oldest file, to keep Windows happy.
$file = $this->file . '.' . $this->maxBackupIndex;
if (file_exists($file) && !unlink($file)) {
throw new \n2n\log4php\LoggerException("Unable to delete oldest backup file from [$file].");
}
// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
$this->renameArchievedLogs($this->file);
// Backup the active file
$this->moveToBackup($this->file);
}
// Truncate the active file
\n2n\io\IoUtils::ftruncate($this->fp, 0);
rewind($this->fp);
}
|
[
"private",
"function",
"rollOver",
"(",
")",
"{",
"// If maxBackups <= 0, then there is no file renaming to be done.\r",
"if",
"(",
"$",
"this",
"->",
"maxBackupIndex",
">",
"0",
")",
"{",
"// Delete the oldest file, to keep Windows happy.\r",
"$",
"file",
"=",
"$",
"this",
"->",
"file",
".",
"'.'",
".",
"$",
"this",
"->",
"maxBackupIndex",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"!",
"unlink",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"Unable to delete oldest backup file from [$file].\"",
")",
";",
"}",
"// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}\r",
"$",
"this",
"->",
"renameArchievedLogs",
"(",
"$",
"this",
"->",
"file",
")",
";",
"// Backup the active file\r",
"$",
"this",
"->",
"moveToBackup",
"(",
"$",
"this",
"->",
"file",
")",
";",
"}",
"// Truncate the active file\r",
"\\",
"n2n",
"\\",
"io",
"\\",
"IoUtils",
"::",
"ftruncate",
"(",
"$",
"this",
"->",
"fp",
",",
"0",
")",
";",
"rewind",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"}"
] |
Implements the usual roll over behaviour.
If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
Rollover must be called while the file is locked so that it is safe for concurrent access.
@throws \n2n\log4php\LoggerException If any part of the rollover procedure fails.
|
[
"Implements",
"the",
"usual",
"roll",
"over",
"behaviour",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/rolling/RollingFile.php#L119-L139
|
225,443
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/rolling/RollingFile.php
|
RollingFile.write
|
protected function write($string) {
// Lazy file open
if(!isset($this->fp)) {
if ($this->openFile() === false) {
return; // Do not write if file open failed.
}
}
// Lock the file while writing and possible rolling over
if(\n2n\io\IoUtils::flock($this->fp, LOCK_EX)) {
// Write to locked file
if(\n2n\io\IoUtils::fwrite($this->fp, $string) === false) {
$this->warn("Failed writing to file. Closing appender.");
$this->closed = true;
}
// Stats cache must be cleared, otherwise \n2n\io\IoUtils::filesize() returns cached results
// If supported (PHP 5.3+), clear only the state cache for the target file
if ($this->clearConditional) {
clearstatcache(true, $this->file);
} else {
clearstatcache();
}
// Rollover if needed
if (\n2n\io\IoUtils::filesize($this->file) > $this->maxFileSize) {
try {
$this->rollOver();
} catch (\n2n\log4php\LoggerException $ex) {
$this->warn("Rollover failed: " . $ex->getMessage() . " Closing appender.");
$this->closed = true;
}
}
\n2n\io\IoUtils::flock($this->fp, LOCK_UN);
} else {
$this->warn("Failed locking file for writing. Closing appender.");
$this->closed = true;
}
}
|
php
|
protected function write($string) {
// Lazy file open
if(!isset($this->fp)) {
if ($this->openFile() === false) {
return; // Do not write if file open failed.
}
}
// Lock the file while writing and possible rolling over
if(\n2n\io\IoUtils::flock($this->fp, LOCK_EX)) {
// Write to locked file
if(\n2n\io\IoUtils::fwrite($this->fp, $string) === false) {
$this->warn("Failed writing to file. Closing appender.");
$this->closed = true;
}
// Stats cache must be cleared, otherwise \n2n\io\IoUtils::filesize() returns cached results
// If supported (PHP 5.3+), clear only the state cache for the target file
if ($this->clearConditional) {
clearstatcache(true, $this->file);
} else {
clearstatcache();
}
// Rollover if needed
if (\n2n\io\IoUtils::filesize($this->file) > $this->maxFileSize) {
try {
$this->rollOver();
} catch (\n2n\log4php\LoggerException $ex) {
$this->warn("Rollover failed: " . $ex->getMessage() . " Closing appender.");
$this->closed = true;
}
}
\n2n\io\IoUtils::flock($this->fp, LOCK_UN);
} else {
$this->warn("Failed locking file for writing. Closing appender.");
$this->closed = true;
}
}
|
[
"protected",
"function",
"write",
"(",
"$",
"string",
")",
"{",
"// Lazy file open\r",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"openFile",
"(",
")",
"===",
"false",
")",
"{",
"return",
";",
"// Do not write if file open failed.\r",
"}",
"}",
"// Lock the file while writing and possible rolling over\r",
"if",
"(",
"\\",
"n2n",
"\\",
"io",
"\\",
"IoUtils",
"::",
"flock",
"(",
"$",
"this",
"->",
"fp",
",",
"LOCK_EX",
")",
")",
"{",
"// Write to locked file\r",
"if",
"(",
"\\",
"n2n",
"\\",
"io",
"\\",
"IoUtils",
"::",
"fwrite",
"(",
"$",
"this",
"->",
"fp",
",",
"$",
"string",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Failed writing to file. Closing appender.\"",
")",
";",
"$",
"this",
"->",
"closed",
"=",
"true",
";",
"}",
"// Stats cache must be cleared, otherwise \\n2n\\io\\IoUtils::filesize() returns cached results\r",
"// If supported (PHP 5.3+), clear only the state cache for the target file\r",
"if",
"(",
"$",
"this",
"->",
"clearConditional",
")",
"{",
"clearstatcache",
"(",
"true",
",",
"$",
"this",
"->",
"file",
")",
";",
"}",
"else",
"{",
"clearstatcache",
"(",
")",
";",
"}",
"// Rollover if needed\r",
"if",
"(",
"\\",
"n2n",
"\\",
"io",
"\\",
"IoUtils",
"::",
"filesize",
"(",
"$",
"this",
"->",
"file",
")",
">",
"$",
"this",
"->",
"maxFileSize",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"rollOver",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Rollover failed: \"",
".",
"$",
"ex",
"->",
"getMessage",
"(",
")",
".",
"\" Closing appender.\"",
")",
";",
"$",
"this",
"->",
"closed",
"=",
"true",
";",
"}",
"}",
"\\",
"n2n",
"\\",
"io",
"\\",
"IoUtils",
"::",
"flock",
"(",
"$",
"this",
"->",
"fp",
",",
"LOCK_UN",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Failed locking file for writing. Closing appender.\"",
")",
";",
"$",
"this",
"->",
"closed",
"=",
"true",
";",
"}",
"}"
] |
Writes a string to the target file. Opens file if not already open.
@param string $string Data to write.
|
[
"Writes",
"a",
"string",
"to",
"the",
"target",
"file",
".",
"Opens",
"file",
"if",
"not",
"already",
"open",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/rolling/RollingFile.php#L198-L238
|
225,444
|
ricardopedias/report-collection
|
src/Libs/Writer.php
|
Writer.createFromStyler
|
public static function createFromStyler(Styler $styler) : Writer
{
$classname = \get_called_class(); // para permitir abstração
$instance = new $classname;
$instance->styler = $styler;
$instance->reader = $styler->getReader();
return $instance;
}
|
php
|
public static function createFromStyler(Styler $styler) : Writer
{
$classname = \get_called_class(); // para permitir abstração
$instance = new $classname;
$instance->styler = $styler;
$instance->reader = $styler->getReader();
return $instance;
}
|
[
"public",
"static",
"function",
"createFromStyler",
"(",
"Styler",
"$",
"styler",
")",
":",
"Writer",
"{",
"$",
"classname",
"=",
"\\",
"get_called_class",
"(",
")",
";",
"// para permitir abstração",
"$",
"instance",
"=",
"new",
"$",
"classname",
";",
"$",
"instance",
"->",
"styler",
"=",
"$",
"styler",
";",
"$",
"instance",
"->",
"reader",
"=",
"$",
"styler",
"->",
"getReader",
"(",
")",
";",
"return",
"$",
"instance",
";",
"}"
] |
Importa os dados a partir do Styler
@param ReportCollection\Libs\Styler $styler
@return ReportCollection\Libs\Writer
|
[
"Importa",
"os",
"dados",
"a",
"partir",
"do",
"Styler"
] |
8536e2c48f83fa12b5cea20737d50da20945b71d
|
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/Writer.php#L81-L89
|
225,445
|
ricardopedias/report-collection
|
src/Libs/Writer.php
|
Writer.getStyler
|
public function getStyler() : Styler
{
if ($this->styler == null) {
$this->styler = Styler::createFromReader($this->getReader());
}
return $this->styler;
}
|
php
|
public function getStyler() : Styler
{
if ($this->styler == null) {
$this->styler = Styler::createFromReader($this->getReader());
}
return $this->styler;
}
|
[
"public",
"function",
"getStyler",
"(",
")",
":",
"Styler",
"{",
"if",
"(",
"$",
"this",
"->",
"styler",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"styler",
"=",
"Styler",
"::",
"createFromReader",
"(",
"$",
"this",
"->",
"getReader",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"styler",
";",
"}"
] |
Devolve a instancia do Styler.
@return ReportCollection\Libs\Styler
|
[
"Devolve",
"a",
"instancia",
"do",
"Styler",
"."
] |
8536e2c48f83fa12b5cea20737d50da20945b71d
|
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/Writer.php#L104-L111
|
225,446
|
cmsgears/plugin-social-meta
|
components/SocialMeta.php
|
SocialMeta.getMetaTags
|
public static function getMetaTags( $params, $config = [] ) {
if( empty( $params[ 'model' ] ) ) {
return;
}
$config[ 'model' ] = $params[ 'model' ];
$config[ 'summary' ] = $params[ 'summary' ];
$config[ 'homePage' ] = isset( $params[ 'homePage' ] ) ? $params[ 'homePage' ] : 'home';
$meta = new SocialMeta( $config );
return $meta->generatePageMetaTags();
}
|
php
|
public static function getMetaTags( $params, $config = [] ) {
if( empty( $params[ 'model' ] ) ) {
return;
}
$config[ 'model' ] = $params[ 'model' ];
$config[ 'summary' ] = $params[ 'summary' ];
$config[ 'homePage' ] = isset( $params[ 'homePage' ] ) ? $params[ 'homePage' ] : 'home';
$meta = new SocialMeta( $config );
return $meta->generatePageMetaTags();
}
|
[
"public",
"static",
"function",
"getMetaTags",
"(",
"$",
"params",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"'model'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"config",
"[",
"'model'",
"]",
"=",
"$",
"params",
"[",
"'model'",
"]",
";",
"$",
"config",
"[",
"'summary'",
"]",
"=",
"$",
"params",
"[",
"'summary'",
"]",
";",
"$",
"config",
"[",
"'homePage'",
"]",
"=",
"isset",
"(",
"$",
"params",
"[",
"'homePage'",
"]",
")",
"?",
"$",
"params",
"[",
"'homePage'",
"]",
":",
"'home'",
";",
"$",
"meta",
"=",
"new",
"SocialMeta",
"(",
"$",
"config",
")",
";",
"return",
"$",
"meta",
"->",
"generatePageMetaTags",
"(",
")",
";",
"}"
] |
Helper to generate tags
|
[
"Helper",
"to",
"generate",
"tags"
] |
b4adae379ce9f1537d2678b241c1d2639ef022ba
|
https://github.com/cmsgears/plugin-social-meta/blob/b4adae379ce9f1537d2678b241c1d2639ef022ba/components/SocialMeta.php#L50-L64
|
225,447
|
cmsgears/plugin-social-meta
|
components/SocialMeta.php
|
SocialMeta.generateTwitterCard
|
private function generateTwitterCard( $banner, $metaContent ) {
$properties = TwitterMetaProperties::getInstance();
if( $properties->isActive() ) {
$card = $properties->getCard();
$site = $properties->getSite();
$creator = $properties->getCreator();
$model = $this->model;
$summary = filter_var( $this->summary, FILTER_SANITIZE_STRING );
// Configure Card, Site and Creator
if( isset( $card ) ) {
$metaContent[ 'tcard' ] = "<meta name=\"twitter:card\" content=\"summary_large_image\" />";
if( !empty( $site ) ) {
$metaContent[ 'tsite' ] = "<meta name=\"twitter:site\" content=\"$site\" />";
}
if( !empty( $creator ) ) {
$metaContent[ 'tcreator' ] = "<meta name=\"twitter:creator\" content=\"$creator\" />";
}
}
$defaultBanner = SiteProperties::getInstance()->getDefaultBanner();
// TODO: Add support for player and app cards generated by Twitter
switch( $card ) {
case 'summary': {
if( empty( $metaContent[ 'otitle' ] ) ) {
$metaContent[ 'otitle' ] = "<meta name=\"twitter:title\" content=\"$model->displayName\" />";
}
if( empty( $metaContent[ 'odesc' ] ) ) {
$metaContent[ 'tdesc' ] = "<meta name=\"twitter:description\" content=\"$summary\" />";
}
if( empty( $metaContent[ 'oimage' ] ) && ( isset( $banner ) || isset( $defaultBanner ) ) ) {
$imageUrl = isset( $banner ) ? $banner->getMediumUrl() : Yii::getAlias( '@webroot' ) . "/images/$defaultBanner";
$metaContent[ 'timage' ] = "<meta name=\"twitter:image\" content=\"$imageUrl\" />";
}
if( isset( $banner ) && !empty( $banner->altText ) ) {
$metaContent[ 'timagealt' ] = "<meta name=\"twitter:image:alt\" content=\"$banner->altText\" />";
}
break;
}
case 'summary_large_image': {
if( empty( $metaContent[ 'otitle' ] ) ) {
$metaContent[ 'otitle' ] = "<meta name=\"twitter:title\" content=\"$model->displayName\" />";
}
if( empty( $metaContent[ 'odesc' ] ) ) {
$metaContent[ 'tdesc' ] = "<meta name=\"twitter:description\" content=\"$summary\" />";
}
if( empty( $metaContent[ 'oimage' ] ) && ( isset( $banner ) || isset( $defaultBanner ) ) ) {
$imageUrl = isset( $banner ) ? $banner->getFileUrl() : Yii::getAlias( '@webroot' ) . "/images/$defaultBanner";
$metaContent[ 'timage' ] = "<meta name=\"twitter:image\" content=\"$imageUrl\" />";
}
if( isset( $banner ) && !empty( $banner->altText ) ) {
$metaContent[ 'timagealt' ] = "<meta name=\"twitter:image:alt\" content=\"$banner->altText\" />";
}
break;
}
case 'app': {
break;
}
case 'player': {
break;
}
}
}
return $metaContent;
}
|
php
|
private function generateTwitterCard( $banner, $metaContent ) {
$properties = TwitterMetaProperties::getInstance();
if( $properties->isActive() ) {
$card = $properties->getCard();
$site = $properties->getSite();
$creator = $properties->getCreator();
$model = $this->model;
$summary = filter_var( $this->summary, FILTER_SANITIZE_STRING );
// Configure Card, Site and Creator
if( isset( $card ) ) {
$metaContent[ 'tcard' ] = "<meta name=\"twitter:card\" content=\"summary_large_image\" />";
if( !empty( $site ) ) {
$metaContent[ 'tsite' ] = "<meta name=\"twitter:site\" content=\"$site\" />";
}
if( !empty( $creator ) ) {
$metaContent[ 'tcreator' ] = "<meta name=\"twitter:creator\" content=\"$creator\" />";
}
}
$defaultBanner = SiteProperties::getInstance()->getDefaultBanner();
// TODO: Add support for player and app cards generated by Twitter
switch( $card ) {
case 'summary': {
if( empty( $metaContent[ 'otitle' ] ) ) {
$metaContent[ 'otitle' ] = "<meta name=\"twitter:title\" content=\"$model->displayName\" />";
}
if( empty( $metaContent[ 'odesc' ] ) ) {
$metaContent[ 'tdesc' ] = "<meta name=\"twitter:description\" content=\"$summary\" />";
}
if( empty( $metaContent[ 'oimage' ] ) && ( isset( $banner ) || isset( $defaultBanner ) ) ) {
$imageUrl = isset( $banner ) ? $banner->getMediumUrl() : Yii::getAlias( '@webroot' ) . "/images/$defaultBanner";
$metaContent[ 'timage' ] = "<meta name=\"twitter:image\" content=\"$imageUrl\" />";
}
if( isset( $banner ) && !empty( $banner->altText ) ) {
$metaContent[ 'timagealt' ] = "<meta name=\"twitter:image:alt\" content=\"$banner->altText\" />";
}
break;
}
case 'summary_large_image': {
if( empty( $metaContent[ 'otitle' ] ) ) {
$metaContent[ 'otitle' ] = "<meta name=\"twitter:title\" content=\"$model->displayName\" />";
}
if( empty( $metaContent[ 'odesc' ] ) ) {
$metaContent[ 'tdesc' ] = "<meta name=\"twitter:description\" content=\"$summary\" />";
}
if( empty( $metaContent[ 'oimage' ] ) && ( isset( $banner ) || isset( $defaultBanner ) ) ) {
$imageUrl = isset( $banner ) ? $banner->getFileUrl() : Yii::getAlias( '@webroot' ) . "/images/$defaultBanner";
$metaContent[ 'timage' ] = "<meta name=\"twitter:image\" content=\"$imageUrl\" />";
}
if( isset( $banner ) && !empty( $banner->altText ) ) {
$metaContent[ 'timagealt' ] = "<meta name=\"twitter:image:alt\" content=\"$banner->altText\" />";
}
break;
}
case 'app': {
break;
}
case 'player': {
break;
}
}
}
return $metaContent;
}
|
[
"private",
"function",
"generateTwitterCard",
"(",
"$",
"banner",
",",
"$",
"metaContent",
")",
"{",
"$",
"properties",
"=",
"TwitterMetaProperties",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"properties",
"->",
"isActive",
"(",
")",
")",
"{",
"$",
"card",
"=",
"$",
"properties",
"->",
"getCard",
"(",
")",
";",
"$",
"site",
"=",
"$",
"properties",
"->",
"getSite",
"(",
")",
";",
"$",
"creator",
"=",
"$",
"properties",
"->",
"getCreator",
"(",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
";",
"$",
"summary",
"=",
"filter_var",
"(",
"$",
"this",
"->",
"summary",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"// Configure Card, Site and Creator",
"if",
"(",
"isset",
"(",
"$",
"card",
")",
")",
"{",
"$",
"metaContent",
"[",
"'tcard'",
"]",
"=",
"\"<meta name=\\\"twitter:card\\\" content=\\\"summary_large_image\\\" />\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"site",
")",
")",
"{",
"$",
"metaContent",
"[",
"'tsite'",
"]",
"=",
"\"<meta name=\\\"twitter:site\\\" content=\\\"$site\\\" />\"",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"creator",
")",
")",
"{",
"$",
"metaContent",
"[",
"'tcreator'",
"]",
"=",
"\"<meta name=\\\"twitter:creator\\\" content=\\\"$creator\\\" />\"",
";",
"}",
"}",
"$",
"defaultBanner",
"=",
"SiteProperties",
"::",
"getInstance",
"(",
")",
"->",
"getDefaultBanner",
"(",
")",
";",
"// TODO: Add support for player and app cards generated by Twitter",
"switch",
"(",
"$",
"card",
")",
"{",
"case",
"'summary'",
":",
"{",
"if",
"(",
"empty",
"(",
"$",
"metaContent",
"[",
"'otitle'",
"]",
")",
")",
"{",
"$",
"metaContent",
"[",
"'otitle'",
"]",
"=",
"\"<meta name=\\\"twitter:title\\\" content=\\\"$model->displayName\\\" />\"",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"metaContent",
"[",
"'odesc'",
"]",
")",
")",
"{",
"$",
"metaContent",
"[",
"'tdesc'",
"]",
"=",
"\"<meta name=\\\"twitter:description\\\" content=\\\"$summary\\\" />\"",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"metaContent",
"[",
"'oimage'",
"]",
")",
"&&",
"(",
"isset",
"(",
"$",
"banner",
")",
"||",
"isset",
"(",
"$",
"defaultBanner",
")",
")",
")",
"{",
"$",
"imageUrl",
"=",
"isset",
"(",
"$",
"banner",
")",
"?",
"$",
"banner",
"->",
"getMediumUrl",
"(",
")",
":",
"Yii",
"::",
"getAlias",
"(",
"'@webroot'",
")",
".",
"\"/images/$defaultBanner\"",
";",
"$",
"metaContent",
"[",
"'timage'",
"]",
"=",
"\"<meta name=\\\"twitter:image\\\" content=\\\"$imageUrl\\\" />\"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"banner",
")",
"&&",
"!",
"empty",
"(",
"$",
"banner",
"->",
"altText",
")",
")",
"{",
"$",
"metaContent",
"[",
"'timagealt'",
"]",
"=",
"\"<meta name=\\\"twitter:image:alt\\\" content=\\\"$banner->altText\\\" />\"",
";",
"}",
"break",
";",
"}",
"case",
"'summary_large_image'",
":",
"{",
"if",
"(",
"empty",
"(",
"$",
"metaContent",
"[",
"'otitle'",
"]",
")",
")",
"{",
"$",
"metaContent",
"[",
"'otitle'",
"]",
"=",
"\"<meta name=\\\"twitter:title\\\" content=\\\"$model->displayName\\\" />\"",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"metaContent",
"[",
"'odesc'",
"]",
")",
")",
"{",
"$",
"metaContent",
"[",
"'tdesc'",
"]",
"=",
"\"<meta name=\\\"twitter:description\\\" content=\\\"$summary\\\" />\"",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"metaContent",
"[",
"'oimage'",
"]",
")",
"&&",
"(",
"isset",
"(",
"$",
"banner",
")",
"||",
"isset",
"(",
"$",
"defaultBanner",
")",
")",
")",
"{",
"$",
"imageUrl",
"=",
"isset",
"(",
"$",
"banner",
")",
"?",
"$",
"banner",
"->",
"getFileUrl",
"(",
")",
":",
"Yii",
"::",
"getAlias",
"(",
"'@webroot'",
")",
".",
"\"/images/$defaultBanner\"",
";",
"$",
"metaContent",
"[",
"'timage'",
"]",
"=",
"\"<meta name=\\\"twitter:image\\\" content=\\\"$imageUrl\\\" />\"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"banner",
")",
"&&",
"!",
"empty",
"(",
"$",
"banner",
"->",
"altText",
")",
")",
"{",
"$",
"metaContent",
"[",
"'timagealt'",
"]",
"=",
"\"<meta name=\\\"twitter:image:alt\\\" content=\\\"$banner->altText\\\" />\"",
";",
"}",
"break",
";",
"}",
"case",
"'app'",
":",
"{",
"break",
";",
"}",
"case",
"'player'",
":",
"{",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"metaContent",
";",
"}"
] |
Generate and return appropriate Twitter Card.
@param string $banner
@param array $metaContent
@return array
|
[
"Generate",
"and",
"return",
"appropriate",
"Twitter",
"Card",
"."
] |
b4adae379ce9f1537d2678b241c1d2639ef022ba
|
https://github.com/cmsgears/plugin-social-meta/blob/b4adae379ce9f1537d2678b241c1d2639ef022ba/components/SocialMeta.php#L185-L283
|
225,448
|
sopinetchat/SopinetChatBundle
|
Service/Consumer/SendMessagePackageConsumer.php
|
SendMessagePackageConsumer.execute
|
public function execute(AMQPMessage $msg)
{
$logger = $this->container->get("logger");
$jsonBody = json_decode($msg->body);
if ($jsonBody == null){
$logger->error("JSON NULL");
return false;
}
$messagePackageId = json_decode($msg->body)->messagePackageId;
$logger->error('tGuardado correctamente 1: ' . $messagePackageId);
/** @var EntityManager $em */
$em = $this->container->get('doctrine.orm.default_entity_manager');
/** @var MessageHelper $messageHelper */
$messageHelper = $this->container->get('sopinet_chatbundle_messagehelper');
$reMessagePackage = $em->getRepository('SopinetChatBundle:MessagePackage');
/** @var MessagePackage $messagePackage */
$messagePackage = $reMessagePackage->findOneById($messagePackageId);
if ($messagePackage == null) return false;
if ($messagePackage->getMessage() == null) return false;;
$logger->error('Guardado correctamente 2: ' . $messagePackageId);
// TODO: This part should be same that <SEARCH_DUPLICATE>
if ($messagePackage->getToDevice()->getDeviceType() == Device::TYPE_ANDROID) {
$messagePackage->setProcessed(true); // Yes, processed
} elseif (
$messagePackage->getToDevice()->getDeviceType() == Device::TYPE_IOS ||
$messagePackage->getToDevice()->getDeviceType() == Device::TYPE_VIRTUALNONE
) {
$messagePackage->setProcessed(false); // Not processed
}
$em->persist($messagePackage);
$em->flush();
$response = $messageHelper->sendRealMessageToDevice($messagePackage->getMessage(), $messagePackage->getToDevice(), $messagePackage->getToUser(), $this->request, true);
if ($response) {
$messagePackage->setStatus(MessagePackage::STATUS_OK);
if ($messagePackage->getMessage()->getMySenderEmailHas($this->container)) {
$messageHelper->sendMessageToEmail($messagePackage->getMessage(), $messagePackage->getToUser());
}
} else {
$messagePackage->setStatus(MessagePackage::STATUS_KO);
}
$em->persist($messagePackage);
$em->flush();
// TODO: End <SEARCH_DUPLICATE>
return true;
}
|
php
|
public function execute(AMQPMessage $msg)
{
$logger = $this->container->get("logger");
$jsonBody = json_decode($msg->body);
if ($jsonBody == null){
$logger->error("JSON NULL");
return false;
}
$messagePackageId = json_decode($msg->body)->messagePackageId;
$logger->error('tGuardado correctamente 1: ' . $messagePackageId);
/** @var EntityManager $em */
$em = $this->container->get('doctrine.orm.default_entity_manager');
/** @var MessageHelper $messageHelper */
$messageHelper = $this->container->get('sopinet_chatbundle_messagehelper');
$reMessagePackage = $em->getRepository('SopinetChatBundle:MessagePackage');
/** @var MessagePackage $messagePackage */
$messagePackage = $reMessagePackage->findOneById($messagePackageId);
if ($messagePackage == null) return false;
if ($messagePackage->getMessage() == null) return false;;
$logger->error('Guardado correctamente 2: ' . $messagePackageId);
// TODO: This part should be same that <SEARCH_DUPLICATE>
if ($messagePackage->getToDevice()->getDeviceType() == Device::TYPE_ANDROID) {
$messagePackage->setProcessed(true); // Yes, processed
} elseif (
$messagePackage->getToDevice()->getDeviceType() == Device::TYPE_IOS ||
$messagePackage->getToDevice()->getDeviceType() == Device::TYPE_VIRTUALNONE
) {
$messagePackage->setProcessed(false); // Not processed
}
$em->persist($messagePackage);
$em->flush();
$response = $messageHelper->sendRealMessageToDevice($messagePackage->getMessage(), $messagePackage->getToDevice(), $messagePackage->getToUser(), $this->request, true);
if ($response) {
$messagePackage->setStatus(MessagePackage::STATUS_OK);
if ($messagePackage->getMessage()->getMySenderEmailHas($this->container)) {
$messageHelper->sendMessageToEmail($messagePackage->getMessage(), $messagePackage->getToUser());
}
} else {
$messagePackage->setStatus(MessagePackage::STATUS_KO);
}
$em->persist($messagePackage);
$em->flush();
// TODO: End <SEARCH_DUPLICATE>
return true;
}
|
[
"public",
"function",
"execute",
"(",
"AMQPMessage",
"$",
"msg",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"\"logger\"",
")",
";",
"$",
"jsonBody",
"=",
"json_decode",
"(",
"$",
"msg",
"->",
"body",
")",
";",
"if",
"(",
"$",
"jsonBody",
"==",
"null",
")",
"{",
"$",
"logger",
"->",
"error",
"(",
"\"JSON NULL\"",
")",
";",
"return",
"false",
";",
"}",
"$",
"messagePackageId",
"=",
"json_decode",
"(",
"$",
"msg",
"->",
"body",
")",
"->",
"messagePackageId",
";",
"$",
"logger",
"->",
"error",
"(",
"'tGuardado correctamente 1: '",
".",
"$",
"messagePackageId",
")",
";",
"/** @var EntityManager $em */",
"$",
"em",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine.orm.default_entity_manager'",
")",
";",
"/** @var MessageHelper $messageHelper */",
"$",
"messageHelper",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'sopinet_chatbundle_messagehelper'",
")",
";",
"$",
"reMessagePackage",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'SopinetChatBundle:MessagePackage'",
")",
";",
"/** @var MessagePackage $messagePackage */",
"$",
"messagePackage",
"=",
"$",
"reMessagePackage",
"->",
"findOneById",
"(",
"$",
"messagePackageId",
")",
";",
"if",
"(",
"$",
"messagePackage",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"$",
"messagePackage",
"->",
"getMessage",
"(",
")",
"==",
"null",
")",
"return",
"false",
";",
";",
"$",
"logger",
"->",
"error",
"(",
"'Guardado correctamente 2: '",
".",
"$",
"messagePackageId",
")",
";",
"// TODO: This part should be same that <SEARCH_DUPLICATE>",
"if",
"(",
"$",
"messagePackage",
"->",
"getToDevice",
"(",
")",
"->",
"getDeviceType",
"(",
")",
"==",
"Device",
"::",
"TYPE_ANDROID",
")",
"{",
"$",
"messagePackage",
"->",
"setProcessed",
"(",
"true",
")",
";",
"// Yes, processed",
"}",
"elseif",
"(",
"$",
"messagePackage",
"->",
"getToDevice",
"(",
")",
"->",
"getDeviceType",
"(",
")",
"==",
"Device",
"::",
"TYPE_IOS",
"||",
"$",
"messagePackage",
"->",
"getToDevice",
"(",
")",
"->",
"getDeviceType",
"(",
")",
"==",
"Device",
"::",
"TYPE_VIRTUALNONE",
")",
"{",
"$",
"messagePackage",
"->",
"setProcessed",
"(",
"false",
")",
";",
"// Not processed",
"}",
"$",
"em",
"->",
"persist",
"(",
"$",
"messagePackage",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"response",
"=",
"$",
"messageHelper",
"->",
"sendRealMessageToDevice",
"(",
"$",
"messagePackage",
"->",
"getMessage",
"(",
")",
",",
"$",
"messagePackage",
"->",
"getToDevice",
"(",
")",
",",
"$",
"messagePackage",
"->",
"getToUser",
"(",
")",
",",
"$",
"this",
"->",
"request",
",",
"true",
")",
";",
"if",
"(",
"$",
"response",
")",
"{",
"$",
"messagePackage",
"->",
"setStatus",
"(",
"MessagePackage",
"::",
"STATUS_OK",
")",
";",
"if",
"(",
"$",
"messagePackage",
"->",
"getMessage",
"(",
")",
"->",
"getMySenderEmailHas",
"(",
"$",
"this",
"->",
"container",
")",
")",
"{",
"$",
"messageHelper",
"->",
"sendMessageToEmail",
"(",
"$",
"messagePackage",
"->",
"getMessage",
"(",
")",
",",
"$",
"messagePackage",
"->",
"getToUser",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"messagePackage",
"->",
"setStatus",
"(",
"MessagePackage",
"::",
"STATUS_KO",
")",
";",
"}",
"$",
"em",
"->",
"persist",
"(",
"$",
"messagePackage",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"// TODO: End <SEARCH_DUPLICATE>",
"return",
"true",
";",
"}"
] |
Process the message
@param AMQPMessage $msg
|
[
"Process",
"the",
"message"
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/Consumer/SendMessagePackageConsumer.php#L36-L90
|
225,449
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configuration/adapter/AdapterINI.php
|
AdapterINI.load
|
private function load($url) {
if (!file_exists($url)) {
throw new \n2n\log4php\LoggerException("File [$url] does not exist.");
}
$properties = \n2n\io\IoUtils::parseIniFile($url, true);
if ($properties === false) {
$error = error_get_last();
throw new \n2n\log4php\LoggerException("Error parsing configuration file: {$error['message']}");
}
return $properties;
}
|
php
|
private function load($url) {
if (!file_exists($url)) {
throw new \n2n\log4php\LoggerException("File [$url] does not exist.");
}
$properties = \n2n\io\IoUtils::parseIniFile($url, true);
if ($properties === false) {
$error = error_get_last();
throw new \n2n\log4php\LoggerException("Error parsing configuration file: {$error['message']}");
}
return $properties;
}
|
[
"private",
"function",
"load",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"url",
")",
")",
"{",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"File [$url] does not exist.\"",
")",
";",
"}",
"$",
"properties",
"=",
"\\",
"n2n",
"\\",
"io",
"\\",
"IoUtils",
"::",
"parseIniFile",
"(",
"$",
"url",
",",
"true",
")",
";",
"if",
"(",
"$",
"properties",
"===",
"false",
")",
"{",
"$",
"error",
"=",
"error_get_last",
"(",
")",
";",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"Error parsing configuration file: {$error['message']}\"",
")",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] |
Loads and parses the INI configuration file.
@param string $url Path to the config file.
@throws \n2n\log4php\LoggerException
|
[
"Loads",
"and",
"parses",
"the",
"INI",
"configuration",
"file",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configuration/adapter/AdapterINI.php#L66-L78
|
225,450
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configuration/adapter/AdapterINI.php
|
AdapterINI.parseAppender
|
private function parseAppender($key, $value) {
// Remove the appender prefix from key
$subKey = substr($key, strlen(self::APPENDER_PREFIX));
// Divide the string by dots
$parts = explode('.', $subKey);
$count = count($parts);
// The first part is always the appender name
$name = trim($parts[0]);
// Only one part - this line defines the appender class
if ($count == 1) {
$this->config['appenders'][$name]['class'] = $value;
return;
}
// Two parts - either a parameter, a threshold or layout class
else if ($count == 2) {
if ($parts[1] == 'layout') {
$this->config['appenders'][$name]['layout']['class'] = $value;
return;
} else if ($parts[1] == 'threshold') {
$this->config['appenders'][$name]['threshold'] = $value;
return;
} else {
$this->config['appenders'][$name]['params'][$parts[1]] = $value;
return;
}
}
// Three parts - this can only be a layout parameter
else if ($count == 3) {
if ($parts[1] == 'layout') {
$this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value;
return;
}
}
throw new \n2n\log4php\LoggerException("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping.");
}
|
php
|
private function parseAppender($key, $value) {
// Remove the appender prefix from key
$subKey = substr($key, strlen(self::APPENDER_PREFIX));
// Divide the string by dots
$parts = explode('.', $subKey);
$count = count($parts);
// The first part is always the appender name
$name = trim($parts[0]);
// Only one part - this line defines the appender class
if ($count == 1) {
$this->config['appenders'][$name]['class'] = $value;
return;
}
// Two parts - either a parameter, a threshold or layout class
else if ($count == 2) {
if ($parts[1] == 'layout') {
$this->config['appenders'][$name]['layout']['class'] = $value;
return;
} else if ($parts[1] == 'threshold') {
$this->config['appenders'][$name]['threshold'] = $value;
return;
} else {
$this->config['appenders'][$name]['params'][$parts[1]] = $value;
return;
}
}
// Three parts - this can only be a layout parameter
else if ($count == 3) {
if ($parts[1] == 'layout') {
$this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value;
return;
}
}
throw new \n2n\log4php\LoggerException("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping.");
}
|
[
"private",
"function",
"parseAppender",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"// Remove the appender prefix from key\r",
"$",
"subKey",
"=",
"substr",
"(",
"$",
"key",
",",
"strlen",
"(",
"self",
"::",
"APPENDER_PREFIX",
")",
")",
";",
"// Divide the string by dots\r",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"subKey",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"// The first part is always the appender name\r",
"$",
"name",
"=",
"trim",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"// Only one part - this line defines the appender class \r",
"if",
"(",
"$",
"count",
"==",
"1",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'appenders'",
"]",
"[",
"$",
"name",
"]",
"[",
"'class'",
"]",
"=",
"$",
"value",
";",
"return",
";",
"}",
"// Two parts - either a parameter, a threshold or layout class\r",
"else",
"if",
"(",
"$",
"count",
"==",
"2",
")",
"{",
"if",
"(",
"$",
"parts",
"[",
"1",
"]",
"==",
"'layout'",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'appenders'",
"]",
"[",
"$",
"name",
"]",
"[",
"'layout'",
"]",
"[",
"'class'",
"]",
"=",
"$",
"value",
";",
"return",
";",
"}",
"else",
"if",
"(",
"$",
"parts",
"[",
"1",
"]",
"==",
"'threshold'",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'appenders'",
"]",
"[",
"$",
"name",
"]",
"[",
"'threshold'",
"]",
"=",
"$",
"value",
";",
"return",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"config",
"[",
"'appenders'",
"]",
"[",
"$",
"name",
"]",
"[",
"'params'",
"]",
"[",
"$",
"parts",
"[",
"1",
"]",
"]",
"=",
"$",
"value",
";",
"return",
";",
"}",
"}",
"// Three parts - this can only be a layout parameter\r",
"else",
"if",
"(",
"$",
"count",
"==",
"3",
")",
"{",
"if",
"(",
"$",
"parts",
"[",
"1",
"]",
"==",
"'layout'",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'appenders'",
"]",
"[",
"$",
"name",
"]",
"[",
"'layout'",
"]",
"[",
"'params'",
"]",
"[",
"$",
"parts",
"[",
"2",
"]",
"]",
"=",
"$",
"value",
";",
"return",
";",
"}",
"}",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"log4php: Don't know how to parse the following line: \\\"$key = $value\\\". Skipping.\"",
")",
";",
"}"
] |
Parses an configuration line pertaining to an appender.
Parses the following patterns:
Appender class:
<pre>
log4php.appender.<name> = <class>
</pre>
Appender parameter:
<pre>
log4php.appender.<name>.<param> = <value>
</pre>
Appender threshold:
<pre>
log4php.appender.<name>.threshold = <level>
</pre>
Appender layout:
<pre>
log4php.appender.<name>.layout = <layoutClass>
</pre>
Layout parameter:
<pre>
log4php.appender.<name>.layout.<param> = <value>
</pre>
For example, a full appender config might look like:
<pre>
log4php.appender.myAppender = LoggerAppenderConsole
log4php.appender.myAppender.threshold = info
log4php.appender.myAppender.target = stdout
log4php.appender.myAppender.layout = LoggerLayoutPattern
log4php.appender.myAppender.layout.conversionPattern = "%d %c: %m%n"
</pre>
After parsing all these options, the following configuration can be
found under $this->config['appenders']['myAppender']:
<pre>
array(
'class' => LoggerAppenderConsole,
'threshold' => info,
'params' => array(
'target' => 'stdout'
),
'layout' => array(
'class' => 'LoggerAppenderConsole',
'params' => array(
'conversionPattern' => '%d %c: %m%n'
)
)
)
</pre>
@param string $key
@param string $value
|
[
"Parses",
"an",
"configuration",
"line",
"pertaining",
"to",
"an",
"appender",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configuration/adapter/AdapterINI.php#L230-L272
|
225,451
|
DrNixx/yii2-onix
|
src/system/DateTimeHelper.php
|
DateTimeHelper.nowSql
|
final public static function nowSql()
{
try {
$date = new \DateTimeImmutable(null, self::tzUtc());
return $date->format('Y-m-d H:i:s');
} catch (\Exception $e) {
return null;
}
}
|
php
|
final public static function nowSql()
{
try {
$date = new \DateTimeImmutable(null, self::tzUtc());
return $date->format('Y-m-d H:i:s');
} catch (\Exception $e) {
return null;
}
}
|
[
"final",
"public",
"static",
"function",
"nowSql",
"(",
")",
"{",
"try",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTimeImmutable",
"(",
"null",
",",
"self",
"::",
"tzUtc",
"(",
")",
")",
";",
"return",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Current date in SQL format
@return string
|
[
"Current",
"date",
"in",
"SQL",
"format"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/system/DateTimeHelper.php#L80-L90
|
225,452
|
DrNixx/yii2-onix
|
src/system/DateTimeHelper.php
|
DateTimeHelper.asSql
|
final public static function asSql($date)
{
if (!empty($date)) {
if ($date instanceof \DateTimeInterface) {
return $date->format('Y-m-d H:i:sO');
} else {
return self::asDateTime($date)->format('Y-m-d H:i:sO');
}
} else {
return null;
}
}
|
php
|
final public static function asSql($date)
{
if (!empty($date)) {
if ($date instanceof \DateTimeInterface) {
return $date->format('Y-m-d H:i:sO');
} else {
return self::asDateTime($date)->format('Y-m-d H:i:sO');
}
} else {
return null;
}
}
|
[
"final",
"public",
"static",
"function",
"asSql",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"date",
")",
")",
"{",
"if",
"(",
"$",
"date",
"instanceof",
"\\",
"DateTimeInterface",
")",
"{",
"return",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H:i:sO'",
")",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"asDateTime",
"(",
"$",
"date",
")",
"->",
"format",
"(",
"'Y-m-d H:i:sO'",
")",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Date in SQL format
@param \DateTimeInterface|string $date
@return string|null
@throws \Exception
|
[
"Date",
"in",
"SQL",
"format"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/system/DateTimeHelper.php#L136-L147
|
225,453
|
DrNixx/yii2-onix
|
src/system/DateTimeHelper.php
|
DateTimeHelper.dateSqlUtcToIsoOffset
|
final public static function dateSqlUtcToIsoOffset($date, $default = null)
{
if (!empty($date)) {
$date = self::asDateTime($date);
$date->setTimezone(self::tzUtc());
return $date->format("Y-m-d\TH:i:sP");
} else {
return $default;
}
}
|
php
|
final public static function dateSqlUtcToIsoOffset($date, $default = null)
{
if (!empty($date)) {
$date = self::asDateTime($date);
$date->setTimezone(self::tzUtc());
return $date->format("Y-m-d\TH:i:sP");
} else {
return $default;
}
}
|
[
"final",
"public",
"static",
"function",
"dateSqlUtcToIsoOffset",
"(",
"$",
"date",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"date",
")",
")",
"{",
"$",
"date",
"=",
"self",
"::",
"asDateTime",
"(",
"$",
"date",
")",
";",
"$",
"date",
"->",
"setTimezone",
"(",
"self",
"::",
"tzUtc",
"(",
")",
")",
";",
"return",
"$",
"date",
"->",
"format",
"(",
"\"Y-m-d\\TH:i:sP\"",
")",
";",
"}",
"else",
"{",
"return",
"$",
"default",
";",
"}",
"}"
] |
Convert ISO offset datetime to SQL string
@param string $date Datetime i.e. 2011-12-03 10:15:30
@param null $default
@return null|string
@throws \Exception
|
[
"Convert",
"ISO",
"offset",
"datetime",
"to",
"SQL",
"string"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/system/DateTimeHelper.php#L562-L571
|
225,454
|
stubbles/stubbles-input
|
src/main/php/filter/range/AbstractRange.php
|
AbstractRange.contains
|
public function contains($value): bool
{
if (null === $value) {
return false;
}
if ($this->belowMinBorder($value)) {
return false;
}
return !$this->aboveMaxBorder($value);
}
|
php
|
public function contains($value): bool
{
if (null === $value) {
return false;
}
if ($this->belowMinBorder($value)) {
return false;
}
return !$this->aboveMaxBorder($value);
}
|
[
"public",
"function",
"contains",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"belowMinBorder",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"$",
"this",
"->",
"aboveMaxBorder",
"(",
"$",
"value",
")",
";",
"}"
] |
checks if range contains given value
@param mixed $value
@return bool
|
[
"checks",
"if",
"range",
"contains",
"given",
"value"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/filter/range/AbstractRange.php#L25-L36
|
225,455
|
stubbles/stubbles-input
|
src/main/php/filter/range/AbstractRange.php
|
AbstractRange.errorsOf
|
public function errorsOf($value): array
{
if ($this->belowMinBorder($value)) {
return $this->minBorderViolation();
}
if ($this->aboveMaxBorder($value)) {
return $this->maxBorderViolation();
}
return [];
}
|
php
|
public function errorsOf($value): array
{
if ($this->belowMinBorder($value)) {
return $this->minBorderViolation();
}
if ($this->aboveMaxBorder($value)) {
return $this->maxBorderViolation();
}
return [];
}
|
[
"public",
"function",
"errorsOf",
"(",
"$",
"value",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"belowMinBorder",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"minBorderViolation",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"aboveMaxBorder",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"maxBorderViolation",
"(",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
returns list of errors when range does not contain given value
@param mixed $value
@return array
|
[
"returns",
"list",
"of",
"errors",
"when",
"range",
"does",
"not",
"contain",
"given",
"value"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/filter/range/AbstractRange.php#L44-L55
|
225,456
|
czogori/Dami
|
src/Dami/Migration/MigrationFiles.php
|
MigrationFiles.get
|
public function get($version = null, $up = true)
{
$currentVersion = $this->schemaTable->getCurrentVersion();
if (null !== $version && false === $up && (int) $version > (int) $currentVersion) {
return null;
}
$files = $this->getFiles($up);
if (!$this->fileVersionExists($version, $this->getFiles($up))) {
return null;
}
$migrationFiles = array();
foreach ($files as $file) {
$filenameParser = new FileNameParser($file->getFileName());
$isMigrated = in_array($filenameParser->getVersion(), $this->schemaTable->getVersions());
$migrationFile = new MigrationFile($filenameParser->getMigrationName(), $file->getRealpath(),
$filenameParser->getVersion(), $filenameParser->getMigrationClassName(), $isMigrated);
if (false === $this->statusIntention) {
if ($up && $isMigrated || !$up && !$isMigrated) {
continue;
}
if ($version == $migrationFile->getVersion()) {
$migrationFiles[] = $migrationFile;
break;
}
}
$migrationFiles[] = $migrationFile;
}
return $migrationFiles;
}
|
php
|
public function get($version = null, $up = true)
{
$currentVersion = $this->schemaTable->getCurrentVersion();
if (null !== $version && false === $up && (int) $version > (int) $currentVersion) {
return null;
}
$files = $this->getFiles($up);
if (!$this->fileVersionExists($version, $this->getFiles($up))) {
return null;
}
$migrationFiles = array();
foreach ($files as $file) {
$filenameParser = new FileNameParser($file->getFileName());
$isMigrated = in_array($filenameParser->getVersion(), $this->schemaTable->getVersions());
$migrationFile = new MigrationFile($filenameParser->getMigrationName(), $file->getRealpath(),
$filenameParser->getVersion(), $filenameParser->getMigrationClassName(), $isMigrated);
if (false === $this->statusIntention) {
if ($up && $isMigrated || !$up && !$isMigrated) {
continue;
}
if ($version == $migrationFile->getVersion()) {
$migrationFiles[] = $migrationFile;
break;
}
}
$migrationFiles[] = $migrationFile;
}
return $migrationFiles;
}
|
[
"public",
"function",
"get",
"(",
"$",
"version",
"=",
"null",
",",
"$",
"up",
"=",
"true",
")",
"{",
"$",
"currentVersion",
"=",
"$",
"this",
"->",
"schemaTable",
"->",
"getCurrentVersion",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"version",
"&&",
"false",
"===",
"$",
"up",
"&&",
"(",
"int",
")",
"$",
"version",
">",
"(",
"int",
")",
"$",
"currentVersion",
")",
"{",
"return",
"null",
";",
"}",
"$",
"files",
"=",
"$",
"this",
"->",
"getFiles",
"(",
"$",
"up",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"fileVersionExists",
"(",
"$",
"version",
",",
"$",
"this",
"->",
"getFiles",
"(",
"$",
"up",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"migrationFiles",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"filenameParser",
"=",
"new",
"FileNameParser",
"(",
"$",
"file",
"->",
"getFileName",
"(",
")",
")",
";",
"$",
"isMigrated",
"=",
"in_array",
"(",
"$",
"filenameParser",
"->",
"getVersion",
"(",
")",
",",
"$",
"this",
"->",
"schemaTable",
"->",
"getVersions",
"(",
")",
")",
";",
"$",
"migrationFile",
"=",
"new",
"MigrationFile",
"(",
"$",
"filenameParser",
"->",
"getMigrationName",
"(",
")",
",",
"$",
"file",
"->",
"getRealpath",
"(",
")",
",",
"$",
"filenameParser",
"->",
"getVersion",
"(",
")",
",",
"$",
"filenameParser",
"->",
"getMigrationClassName",
"(",
")",
",",
"$",
"isMigrated",
")",
";",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"statusIntention",
")",
"{",
"if",
"(",
"$",
"up",
"&&",
"$",
"isMigrated",
"||",
"!",
"$",
"up",
"&&",
"!",
"$",
"isMigrated",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"version",
"==",
"$",
"migrationFile",
"->",
"getVersion",
"(",
")",
")",
"{",
"$",
"migrationFiles",
"[",
"]",
"=",
"$",
"migrationFile",
";",
"break",
";",
"}",
"}",
"$",
"migrationFiles",
"[",
"]",
"=",
"$",
"migrationFile",
";",
"}",
"return",
"$",
"migrationFiles",
";",
"}"
] |
Gets migration files.
@param string $version Version of migration.
@return MigrationFile[]
|
[
"Gets",
"migration",
"files",
"."
] |
19612e643f8bea76706cc667c3f2c12a42d4cd19
|
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/MigrationFiles.php#L30-L63
|
225,457
|
DrNixx/yii2-onix
|
src/widgets/WidgetTrait.php
|
WidgetTrait.initDestroyJs
|
protected function initDestroyJs()
{
if (isset($this->pluginDestroyJs)) {
return;
}
if (empty($this->pluginName)) {
$this->pluginDestroyJs = '';
return;
}
$id = "jQuery('#" . $this->options['id'] . "')";
$plugin = $this->pluginName;
$this->pluginDestroyJs = "if ({$id}.data('{$this->pluginName}')) { {$id}.{$plugin}('destroy'); }";
}
|
php
|
protected function initDestroyJs()
{
if (isset($this->pluginDestroyJs)) {
return;
}
if (empty($this->pluginName)) {
$this->pluginDestroyJs = '';
return;
}
$id = "jQuery('#" . $this->options['id'] . "')";
$plugin = $this->pluginName;
$this->pluginDestroyJs = "if ({$id}.data('{$this->pluginName}')) { {$id}.{$plugin}('destroy'); }";
}
|
[
"protected",
"function",
"initDestroyJs",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"pluginDestroyJs",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"pluginName",
")",
")",
"{",
"$",
"this",
"->",
"pluginDestroyJs",
"=",
"''",
";",
"return",
";",
"}",
"$",
"id",
"=",
"\"jQuery('#\"",
".",
"$",
"this",
"->",
"options",
"[",
"'id'",
"]",
".",
"\"')\"",
";",
"$",
"plugin",
"=",
"$",
"this",
"->",
"pluginName",
";",
"$",
"this",
"->",
"pluginDestroyJs",
"=",
"\"if ({$id}.data('{$this->pluginName}')) { {$id}.{$plugin}('destroy'); }\"",
";",
"}"
] |
Generates the `pluginDestroyJs` script if it is not set.
|
[
"Generates",
"the",
"pluginDestroyJs",
"script",
"if",
"it",
"is",
"not",
"set",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/WidgetTrait.php#L38-L52
|
225,458
|
DrNixx/yii2-onix
|
src/widgets/WidgetTrait.php
|
WidgetTrait.addAsset
|
protected function addAsset($view, $file, $type, $class)
{
if ($type == 'css' || $type == 'js') {
$asset = $view->getAssetManager();
$bundle = $asset->bundles[$class];
if ($type == 'css') {
$bundle->css[] = $file;
} else {
$bundle->js[] = $file;
}
$asset->bundles[$class] = $bundle;
$view->setAssetManager($asset);
}
}
|
php
|
protected function addAsset($view, $file, $type, $class)
{
if ($type == 'css' || $type == 'js') {
$asset = $view->getAssetManager();
$bundle = $asset->bundles[$class];
if ($type == 'css') {
$bundle->css[] = $file;
} else {
$bundle->js[] = $file;
}
$asset->bundles[$class] = $bundle;
$view->setAssetManager($asset);
}
}
|
[
"protected",
"function",
"addAsset",
"(",
"$",
"view",
",",
"$",
"file",
",",
"$",
"type",
",",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'css'",
"||",
"$",
"type",
"==",
"'js'",
")",
"{",
"$",
"asset",
"=",
"$",
"view",
"->",
"getAssetManager",
"(",
")",
";",
"$",
"bundle",
"=",
"$",
"asset",
"->",
"bundles",
"[",
"$",
"class",
"]",
";",
"if",
"(",
"$",
"type",
"==",
"'css'",
")",
"{",
"$",
"bundle",
"->",
"css",
"[",
"]",
"=",
"$",
"file",
";",
"}",
"else",
"{",
"$",
"bundle",
"->",
"js",
"[",
"]",
"=",
"$",
"file",
";",
"}",
"$",
"asset",
"->",
"bundles",
"[",
"$",
"class",
"]",
"=",
"$",
"bundle",
";",
"$",
"view",
"->",
"setAssetManager",
"(",
"$",
"asset",
")",
";",
"}",
"}"
] |
Adds an asset to the view.
@param View $view the View object
@param string $file the asset file name
@param string $type the asset file type (css or js)
@param string $class the class name of the AssetBundle
|
[
"Adds",
"an",
"asset",
"to",
"the",
"view",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/WidgetTrait.php#L61-L75
|
225,459
|
DrNixx/yii2-onix
|
src/widgets/WidgetTrait.php
|
WidgetTrait.registerPluginOptions
|
protected function registerPluginOptions($name)
{
$this->hashPluginOptions($name);
$encOptions = empty($this->_encOptions) ? '{}' : $this->_encOptions;
$this->registerWidgetJs("window.{$this->_hashVar} = {$encOptions};\n", $this->hashVarLoadPosition);
}
|
php
|
protected function registerPluginOptions($name)
{
$this->hashPluginOptions($name);
$encOptions = empty($this->_encOptions) ? '{}' : $this->_encOptions;
$this->registerWidgetJs("window.{$this->_hashVar} = {$encOptions};\n", $this->hashVarLoadPosition);
}
|
[
"protected",
"function",
"registerPluginOptions",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"hashPluginOptions",
"(",
"$",
"name",
")",
";",
"$",
"encOptions",
"=",
"empty",
"(",
"$",
"this",
"->",
"_encOptions",
")",
"?",
"'{}'",
":",
"$",
"this",
"->",
"_encOptions",
";",
"$",
"this",
"->",
"registerWidgetJs",
"(",
"\"window.{$this->_hashVar} = {$encOptions};\\n\"",
",",
"$",
"this",
"->",
"hashVarLoadPosition",
")",
";",
"}"
] |
Registers plugin options by storing within a uniquely generated javascript variable.
@param string $name the plugin name
|
[
"Registers",
"plugin",
"options",
"by",
"storing",
"within",
"a",
"uniquely",
"generated",
"javascript",
"variable",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/WidgetTrait.php#L96-L101
|
225,460
|
DrNixx/yii2-onix
|
src/widgets/WidgetTrait.php
|
WidgetTrait.getPluginScript
|
protected function getPluginScript($name, $element = null, $callback = null, $callbackCon = null)
{
$id = $element ? $element : "jQuery('#" . $this->options['id'] . "')";
$script = '';
if ($this->pluginOptions !== false) {
$this->registerPluginOptions($name);
$script = "{$id}.{$name}({$this->_hashVar})";
if ($callbackCon != null) {
$script = "{$id}.{$name}({$this->_hashVar}, {$callbackCon})";
}
if ($callback != null) {
$script = "jQuery.when({$script}).done({$callback})";
}
$script .= ";\n";
}
$script = $this->pluginDestroyJs . "\n" . $script;
if (!empty($this->pluginEvents)) {
foreach ($this->pluginEvents as $event => $handler) {
$function = $handler instanceof JsExpression ? $handler : new JsExpression($handler);
$script .= "{$id}.on('{$event}', {$function});\n";
}
}
return $script;
}
|
php
|
protected function getPluginScript($name, $element = null, $callback = null, $callbackCon = null)
{
$id = $element ? $element : "jQuery('#" . $this->options['id'] . "')";
$script = '';
if ($this->pluginOptions !== false) {
$this->registerPluginOptions($name);
$script = "{$id}.{$name}({$this->_hashVar})";
if ($callbackCon != null) {
$script = "{$id}.{$name}({$this->_hashVar}, {$callbackCon})";
}
if ($callback != null) {
$script = "jQuery.when({$script}).done({$callback})";
}
$script .= ";\n";
}
$script = $this->pluginDestroyJs . "\n" . $script;
if (!empty($this->pluginEvents)) {
foreach ($this->pluginEvents as $event => $handler) {
$function = $handler instanceof JsExpression ? $handler : new JsExpression($handler);
$script .= "{$id}.on('{$event}', {$function});\n";
}
}
return $script;
}
|
[
"protected",
"function",
"getPluginScript",
"(",
"$",
"name",
",",
"$",
"element",
"=",
"null",
",",
"$",
"callback",
"=",
"null",
",",
"$",
"callbackCon",
"=",
"null",
")",
"{",
"$",
"id",
"=",
"$",
"element",
"?",
"$",
"element",
":",
"\"jQuery('#\"",
".",
"$",
"this",
"->",
"options",
"[",
"'id'",
"]",
".",
"\"')\"",
";",
"$",
"script",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"pluginOptions",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"registerPluginOptions",
"(",
"$",
"name",
")",
";",
"$",
"script",
"=",
"\"{$id}.{$name}({$this->_hashVar})\"",
";",
"if",
"(",
"$",
"callbackCon",
"!=",
"null",
")",
"{",
"$",
"script",
"=",
"\"{$id}.{$name}({$this->_hashVar}, {$callbackCon})\"",
";",
"}",
"if",
"(",
"$",
"callback",
"!=",
"null",
")",
"{",
"$",
"script",
"=",
"\"jQuery.when({$script}).done({$callback})\"",
";",
"}",
"$",
"script",
".=",
"\";\\n\"",
";",
"}",
"$",
"script",
"=",
"$",
"this",
"->",
"pluginDestroyJs",
".",
"\"\\n\"",
".",
"$",
"script",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"pluginEvents",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"pluginEvents",
"as",
"$",
"event",
"=>",
"$",
"handler",
")",
"{",
"$",
"function",
"=",
"$",
"handler",
"instanceof",
"JsExpression",
"?",
"$",
"handler",
":",
"new",
"JsExpression",
"(",
"$",
"handler",
")",
";",
"$",
"script",
".=",
"\"{$id}.on('{$event}', {$function});\\n\"",
";",
"}",
"}",
"return",
"$",
"script",
";",
"}"
] |
Returns the plugin registration script.
@param string $name the name of the plugin
@param string $element the plugin target element
@param string $callback the javascript callback function to be called after plugin loads
@param string $callbackCon the javascript callback function to be passed to the plugin constructor
@return string the generated plugin script
|
[
"Returns",
"the",
"plugin",
"registration",
"script",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/WidgetTrait.php#L112-L139
|
225,461
|
DrNixx/yii2-onix
|
src/widgets/WidgetTrait.php
|
WidgetTrait.registerWidgetJs
|
public function registerWidgetJs($js, $pos = View::POS_READY, $key = null)
{
if (empty($js)) {
return;
}
$view = $this->getView();
// WidgetAsset::register($view);
$view->registerJs($js, $pos, $key);
if (!empty($this->pjaxContainerId) && ($pos === View::POS_LOAD || $pos === View::POS_READY)) {
$pjax = 'jQuery("#' . $this->pjaxContainerId . '")';
$evComplete = 'pjax:complete.' . hash('crc32', $js);
$script = "setTimeout(function(){ {$js} }, 100);";
$view->registerJs("{$pjax}.off('{$evComplete}').on('{$evComplete}',function(){ {$script} });");
// hack fix for browser back and forward buttons
if ($this->enablePopStateFix) {
$view->registerJs("window.addEventListener('popstate',function(){window.location.reload();});");
}
}
}
|
php
|
public function registerWidgetJs($js, $pos = View::POS_READY, $key = null)
{
if (empty($js)) {
return;
}
$view = $this->getView();
// WidgetAsset::register($view);
$view->registerJs($js, $pos, $key);
if (!empty($this->pjaxContainerId) && ($pos === View::POS_LOAD || $pos === View::POS_READY)) {
$pjax = 'jQuery("#' . $this->pjaxContainerId . '")';
$evComplete = 'pjax:complete.' . hash('crc32', $js);
$script = "setTimeout(function(){ {$js} }, 100);";
$view->registerJs("{$pjax}.off('{$evComplete}').on('{$evComplete}',function(){ {$script} });");
// hack fix for browser back and forward buttons
if ($this->enablePopStateFix) {
$view->registerJs("window.addEventListener('popstate',function(){window.location.reload();});");
}
}
}
|
[
"public",
"function",
"registerWidgetJs",
"(",
"$",
"js",
",",
"$",
"pos",
"=",
"View",
"::",
"POS_READY",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"js",
")",
")",
"{",
"return",
";",
"}",
"$",
"view",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
";",
"// WidgetAsset::register($view);",
"$",
"view",
"->",
"registerJs",
"(",
"$",
"js",
",",
"$",
"pos",
",",
"$",
"key",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"pjaxContainerId",
")",
"&&",
"(",
"$",
"pos",
"===",
"View",
"::",
"POS_LOAD",
"||",
"$",
"pos",
"===",
"View",
"::",
"POS_READY",
")",
")",
"{",
"$",
"pjax",
"=",
"'jQuery(\"#'",
".",
"$",
"this",
"->",
"pjaxContainerId",
".",
"'\")'",
";",
"$",
"evComplete",
"=",
"'pjax:complete.'",
".",
"hash",
"(",
"'crc32'",
",",
"$",
"js",
")",
";",
"$",
"script",
"=",
"\"setTimeout(function(){ {$js} }, 100);\"",
";",
"$",
"view",
"->",
"registerJs",
"(",
"\"{$pjax}.off('{$evComplete}').on('{$evComplete}',function(){ {$script} });\"",
")",
";",
"// hack fix for browser back and forward buttons",
"if",
"(",
"$",
"this",
"->",
"enablePopStateFix",
")",
"{",
"$",
"view",
"->",
"registerJs",
"(",
"\"window.addEventListener('popstate',function(){window.location.reload();});\"",
")",
";",
"}",
"}",
"}"
] |
Registers a JS code block for the widget.
@param string $js the JS code block to be registered
@param integer $pos the position at which the JS script tag should be inserted in a page. The possible values
are:
- [[View::POS_HEAD]]: in the head section
- [[View::POS_BEGIN]]: at the beginning of the body section
- [[View::POS_END]]: at the end of the body section
- [[View::POS_LOAD]]: enclosed within jQuery(window).load(). Note that by using this position, the method will
automatically register the jQuery js file.
- [[View::POS_READY]]: enclosed within jQuery(document).ready(). This is the default value. Note that by using
this position, the method will automatically register the jQuery js file.
@param string $key the key that identifies the JS code block. If null, it will use `$js` as the key. If two JS
code blocks are registered with the same key, the latter will overwrite the former.
|
[
"Registers",
"a",
"JS",
"code",
"block",
"for",
"the",
"widget",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/WidgetTrait.php#L170-L191
|
225,462
|
UCSLabs/Referenceable
|
ReferenceGeneratorProvider.php
|
ReferenceGeneratorProvider.find
|
public function find(ReferenceableInterface $referenceable) {
foreach( $this->generators->all() as $generator ) {
if( $generator->canHandle($referenceable) ) {
return $generator;
}
}
return null;
}
|
php
|
public function find(ReferenceableInterface $referenceable) {
foreach( $this->generators->all() as $generator ) {
if( $generator->canHandle($referenceable) ) {
return $generator;
}
}
return null;
}
|
[
"public",
"function",
"find",
"(",
"ReferenceableInterface",
"$",
"referenceable",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"generators",
"->",
"all",
"(",
")",
"as",
"$",
"generator",
")",
"{",
"if",
"(",
"$",
"generator",
"->",
"canHandle",
"(",
"$",
"referenceable",
")",
")",
"{",
"return",
"$",
"generator",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the generator with the highest priority that can be applied to the
given entity
@param mixed $referenceable the object on which the generator should be
applied
@return null|ReferenceGeneratorInterface
|
[
"Get",
"the",
"generator",
"with",
"the",
"highest",
"priority",
"that",
"can",
"be",
"applied",
"to",
"the",
"given",
"entity"
] |
72cef440197898605237805293109be1e4a79d67
|
https://github.com/UCSLabs/Referenceable/blob/72cef440197898605237805293109be1e4a79d67/ReferenceGeneratorProvider.php#L64-L72
|
225,463
|
UCSLabs/Referenceable
|
ReferenceGeneratorProvider.php
|
ReferenceGeneratorProvider.findAll
|
public function findAll(ReferenceableInterface $referenceable) {
$generators = new ReferenceGeneratorCollection();
foreach( $this->generators->all() as $generator ) {
if( $generator->canHandle($referenceable) ) {
$generators->add($generator);
}
}
return $generators;
}
|
php
|
public function findAll(ReferenceableInterface $referenceable) {
$generators = new ReferenceGeneratorCollection();
foreach( $this->generators->all() as $generator ) {
if( $generator->canHandle($referenceable) ) {
$generators->add($generator);
}
}
return $generators;
}
|
[
"public",
"function",
"findAll",
"(",
"ReferenceableInterface",
"$",
"referenceable",
")",
"{",
"$",
"generators",
"=",
"new",
"ReferenceGeneratorCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"generators",
"->",
"all",
"(",
")",
"as",
"$",
"generator",
")",
"{",
"if",
"(",
"$",
"generator",
"->",
"canHandle",
"(",
"$",
"referenceable",
")",
")",
"{",
"$",
"generators",
"->",
"add",
"(",
"$",
"generator",
")",
";",
"}",
"}",
"return",
"$",
"generators",
";",
"}"
] |
Get all generators for the given entity
@param mixed $referenceable the object on which the generator should be
applied
@return null|ReferenceGeneratorInterface
|
[
"Get",
"all",
"generators",
"for",
"the",
"given",
"entity"
] |
72cef440197898605237805293109be1e4a79d67
|
https://github.com/UCSLabs/Referenceable/blob/72cef440197898605237805293109be1e4a79d67/ReferenceGeneratorProvider.php#L100-L110
|
225,464
|
sopinetchat/SopinetChatBundle
|
Service/MessageHelper.php
|
MessageHelper.sendMessage
|
public function sendMessage(Message $message) {
if ($this->isDisabled()) {
return false;
}
$users = $message->getMyDestionationUsers($this->container);
$sentCount = 0;
foreach($users as $user) {
//if($user->getId() != $message->getFromUser()->getId()){
$sentCount += $this->sendMessageToUser($message, $user);
//}
}
return $sentCount;
}
|
php
|
public function sendMessage(Message $message) {
if ($this->isDisabled()) {
return false;
}
$users = $message->getMyDestionationUsers($this->container);
$sentCount = 0;
foreach($users as $user) {
//if($user->getId() != $message->getFromUser()->getId()){
$sentCount += $this->sendMessageToUser($message, $user);
//}
}
return $sentCount;
}
|
[
"public",
"function",
"sendMessage",
"(",
"Message",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDisabled",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"users",
"=",
"$",
"message",
"->",
"getMyDestionationUsers",
"(",
"$",
"this",
"->",
"container",
")",
";",
"$",
"sentCount",
"=",
"0",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"//if($user->getId() != $message->getFromUser()->getId()){",
"$",
"sentCount",
"+=",
"$",
"this",
"->",
"sendMessageToUser",
"(",
"$",
"message",
",",
"$",
"user",
")",
";",
"//}",
"}",
"return",
"$",
"sentCount",
";",
"}"
] |
Manda un mensaje a los usuarios que el tipo de Mensaje indique
@param Message $message
@return integer: -1 si hay error, 0 si no hay dispositivos a los que mandar, y más de 0 indicando el número de mensajes enviados
|
[
"Manda",
"un",
"mensaje",
"a",
"los",
"usuarios",
"que",
"el",
"tipo",
"de",
"Mensaje",
"indique"
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/MessageHelper.php#L100-L113
|
225,465
|
sopinetchat/SopinetChatBundle
|
Service/MessageHelper.php
|
MessageHelper.sendRealMessageToDevice
|
public function sendRealMessageToDevice(Message $message, Device $device, $user = null, Request $request = null)
{
if ($this->isDisabled()) {
return false;
}
$em = $this->container->get('doctrine')->getManager();
$config = $this->container->getParameter('sopinet_chat.config');
$messageData = $message->getMyMessageObject($this->container, $request);
$text = $message->__toString();
$messageArray = array();
$vars = get_object_vars($messageData);
foreach($vars as $key => $value) {
$messageArray[$key] = $value;
}
if ($message->getChat() != null) {
$em = $this->container->get('doctrine.orm.default_entity_manager');
/** @var ChatRepository $repositoryChat */
$repositoryChat = $em->getRepository('SopinetChatBundle:Chat');
$repositoryChat->enabledChat($message->getChat());
$chatData = $message->getChat()->getMyAddMessageObject($this->container);
$varsChat = get_object_vars($chatData);
foreach($varsChat as $key => $value) {
$messageArray[$key] = $value;
}
}
if ($user != null) {
$messageArray['toUserId'] = $user->getId();
//Calculamos el numero de mensajes pendientes que tiene
// Get MessagePackage
$reMessagePackage = $em->getRepository("SopinetChatBundle:MessagePackage");
$messagesPackage = $reMessagePackage->findBy(array(
'toUser' => $user->getId(),
'toDevice' => $device->getDeviceId(),
'processed' => false
));
//Añadimos uno para que cuente el actual mensaje
$messageArray['badge'] = count($messagesPackage) + 1;
}else{
$messageArray['badge'] = 0;
}
if ($device->getDeviceType() == Device::TYPE_ANDROID && $config['enabledAndroid']) {
return $this->sendGCMessage($messageArray, $text, $device->getDeviceGCMId());
} elseif ($device->getDeviceType() == Device::TYPE_IOS && $config['enabledIOS']) {
return $this->sendAPNMessage($messageArray, $text, $device->getDeviceId(), $message->getMyIOSContentAvailable(), $message->getMyIOSNotificationFields());
} elseif ($device->getDeviceType() == Device::TYPE_WEB && $config['enabledWeb']) {
return $this->sendWebMessage($messageArray, $text, $device->getDeviceId());
} elseif ($device->getDeviceType() == Device::TYPE_VIRTUALNONE) {
// Do Nothing, but return true, so, state = 1, it is "sent" (in virtualnone: saved)
return true;
}
}
|
php
|
public function sendRealMessageToDevice(Message $message, Device $device, $user = null, Request $request = null)
{
if ($this->isDisabled()) {
return false;
}
$em = $this->container->get('doctrine')->getManager();
$config = $this->container->getParameter('sopinet_chat.config');
$messageData = $message->getMyMessageObject($this->container, $request);
$text = $message->__toString();
$messageArray = array();
$vars = get_object_vars($messageData);
foreach($vars as $key => $value) {
$messageArray[$key] = $value;
}
if ($message->getChat() != null) {
$em = $this->container->get('doctrine.orm.default_entity_manager');
/** @var ChatRepository $repositoryChat */
$repositoryChat = $em->getRepository('SopinetChatBundle:Chat');
$repositoryChat->enabledChat($message->getChat());
$chatData = $message->getChat()->getMyAddMessageObject($this->container);
$varsChat = get_object_vars($chatData);
foreach($varsChat as $key => $value) {
$messageArray[$key] = $value;
}
}
if ($user != null) {
$messageArray['toUserId'] = $user->getId();
//Calculamos el numero de mensajes pendientes que tiene
// Get MessagePackage
$reMessagePackage = $em->getRepository("SopinetChatBundle:MessagePackage");
$messagesPackage = $reMessagePackage->findBy(array(
'toUser' => $user->getId(),
'toDevice' => $device->getDeviceId(),
'processed' => false
));
//Añadimos uno para que cuente el actual mensaje
$messageArray['badge'] = count($messagesPackage) + 1;
}else{
$messageArray['badge'] = 0;
}
if ($device->getDeviceType() == Device::TYPE_ANDROID && $config['enabledAndroid']) {
return $this->sendGCMessage($messageArray, $text, $device->getDeviceGCMId());
} elseif ($device->getDeviceType() == Device::TYPE_IOS && $config['enabledIOS']) {
return $this->sendAPNMessage($messageArray, $text, $device->getDeviceId(), $message->getMyIOSContentAvailable(), $message->getMyIOSNotificationFields());
} elseif ($device->getDeviceType() == Device::TYPE_WEB && $config['enabledWeb']) {
return $this->sendWebMessage($messageArray, $text, $device->getDeviceId());
} elseif ($device->getDeviceType() == Device::TYPE_VIRTUALNONE) {
// Do Nothing, but return true, so, state = 1, it is "sent" (in virtualnone: saved)
return true;
}
}
|
[
"public",
"function",
"sendRealMessageToDevice",
"(",
"Message",
"$",
"message",
",",
"Device",
"$",
"device",
",",
"$",
"user",
"=",
"null",
",",
"Request",
"$",
"request",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDisabled",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"em",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine'",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'sopinet_chat.config'",
")",
";",
"$",
"messageData",
"=",
"$",
"message",
"->",
"getMyMessageObject",
"(",
"$",
"this",
"->",
"container",
",",
"$",
"request",
")",
";",
"$",
"text",
"=",
"$",
"message",
"->",
"__toString",
"(",
")",
";",
"$",
"messageArray",
"=",
"array",
"(",
")",
";",
"$",
"vars",
"=",
"get_object_vars",
"(",
"$",
"messageData",
")",
";",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"messageArray",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"message",
"->",
"getChat",
"(",
")",
"!=",
"null",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine.orm.default_entity_manager'",
")",
";",
"/** @var ChatRepository $repositoryChat */",
"$",
"repositoryChat",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'SopinetChatBundle:Chat'",
")",
";",
"$",
"repositoryChat",
"->",
"enabledChat",
"(",
"$",
"message",
"->",
"getChat",
"(",
")",
")",
";",
"$",
"chatData",
"=",
"$",
"message",
"->",
"getChat",
"(",
")",
"->",
"getMyAddMessageObject",
"(",
"$",
"this",
"->",
"container",
")",
";",
"$",
"varsChat",
"=",
"get_object_vars",
"(",
"$",
"chatData",
")",
";",
"foreach",
"(",
"$",
"varsChat",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"messageArray",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"if",
"(",
"$",
"user",
"!=",
"null",
")",
"{",
"$",
"messageArray",
"[",
"'toUserId'",
"]",
"=",
"$",
"user",
"->",
"getId",
"(",
")",
";",
"//Calculamos el numero de mensajes pendientes que tiene",
"// Get MessagePackage",
"$",
"reMessagePackage",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"\"SopinetChatBundle:MessagePackage\"",
")",
";",
"$",
"messagesPackage",
"=",
"$",
"reMessagePackage",
"->",
"findBy",
"(",
"array",
"(",
"'toUser'",
"=>",
"$",
"user",
"->",
"getId",
"(",
")",
",",
"'toDevice'",
"=>",
"$",
"device",
"->",
"getDeviceId",
"(",
")",
",",
"'processed'",
"=>",
"false",
")",
")",
";",
"//Añadimos uno para que cuente el actual mensaje",
"$",
"messageArray",
"[",
"'badge'",
"]",
"=",
"count",
"(",
"$",
"messagesPackage",
")",
"+",
"1",
";",
"}",
"else",
"{",
"$",
"messageArray",
"[",
"'badge'",
"]",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"device",
"->",
"getDeviceType",
"(",
")",
"==",
"Device",
"::",
"TYPE_ANDROID",
"&&",
"$",
"config",
"[",
"'enabledAndroid'",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"sendGCMessage",
"(",
"$",
"messageArray",
",",
"$",
"text",
",",
"$",
"device",
"->",
"getDeviceGCMId",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"device",
"->",
"getDeviceType",
"(",
")",
"==",
"Device",
"::",
"TYPE_IOS",
"&&",
"$",
"config",
"[",
"'enabledIOS'",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"sendAPNMessage",
"(",
"$",
"messageArray",
",",
"$",
"text",
",",
"$",
"device",
"->",
"getDeviceId",
"(",
")",
",",
"$",
"message",
"->",
"getMyIOSContentAvailable",
"(",
")",
",",
"$",
"message",
"->",
"getMyIOSNotificationFields",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"device",
"->",
"getDeviceType",
"(",
")",
"==",
"Device",
"::",
"TYPE_WEB",
"&&",
"$",
"config",
"[",
"'enabledWeb'",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"sendWebMessage",
"(",
"$",
"messageArray",
",",
"$",
"text",
",",
"$",
"device",
"->",
"getDeviceId",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"device",
"->",
"getDeviceType",
"(",
")",
"==",
"Device",
"::",
"TYPE_VIRTUALNONE",
")",
"{",
"// Do Nothing, but return true, so, state = 1, it is \"sent\" (in virtualnone: saved)",
"return",
"true",
";",
"}",
"}"
] |
Send message to User and device
It functions transform to Real message data array
@param Object $msg
@param String $to
|
[
"Send",
"message",
"to",
"User",
"and",
"device",
"It",
"functions",
"transform",
"to",
"Real",
"message",
"data",
"array"
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/MessageHelper.php#L208-L273
|
225,466
|
sopinetchat/SopinetChatBundle
|
Service/MessageHelper.php
|
MessageHelper.sendGCMessage
|
private function sendGCMessage($mes, $text, $to)
{
$message=new AndroidMessage();
$message->setMessage($text);
$message->setData($mes);
$message->setDeviceIdentifier($to);
$message->setGCM(true);
// $logger = $this->container->get('logger');
// $logger->emerg(implode(',', $message->getData()));
try {
$response = $this->container->get('rms_push_notifications')->send($message);
} catch (InvalidMessageTypeException $e) {
throw $e;
}
return $response;
}
|
php
|
private function sendGCMessage($mes, $text, $to)
{
$message=new AndroidMessage();
$message->setMessage($text);
$message->setData($mes);
$message->setDeviceIdentifier($to);
$message->setGCM(true);
// $logger = $this->container->get('logger');
// $logger->emerg(implode(',', $message->getData()));
try {
$response = $this->container->get('rms_push_notifications')->send($message);
} catch (InvalidMessageTypeException $e) {
throw $e;
}
return $response;
}
|
[
"private",
"function",
"sendGCMessage",
"(",
"$",
"mes",
",",
"$",
"text",
",",
"$",
"to",
")",
"{",
"$",
"message",
"=",
"new",
"AndroidMessage",
"(",
")",
";",
"$",
"message",
"->",
"setMessage",
"(",
"$",
"text",
")",
";",
"$",
"message",
"->",
"setData",
"(",
"$",
"mes",
")",
";",
"$",
"message",
"->",
"setDeviceIdentifier",
"(",
"$",
"to",
")",
";",
"$",
"message",
"->",
"setGCM",
"(",
"true",
")",
";",
"// $logger = $this->container->get('logger');",
"// $logger->emerg(implode(',', $message->getData()));",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'rms_push_notifications'",
")",
"->",
"send",
"(",
"$",
"message",
")",
";",
"}",
"catch",
"(",
"InvalidMessageTypeException",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Funcion que envia un mensaje con el servicio GCM de Google
@param Array $mes
@param DeviceId $to
|
[
"Funcion",
"que",
"envia",
"un",
"mensaje",
"con",
"el",
"servicio",
"GCM",
"de",
"Google"
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/MessageHelper.php#L304-L320
|
225,467
|
sopinetchat/SopinetChatBundle
|
Service/MessageHelper.php
|
MessageHelper.sendMessageToEmail
|
public function sendMessageToEmail(Message $message, $user) {
if (is_object($user)) {
$toEmail = $user->getEmail();
} else {
$toEmail = $user;
}
if ($this->container->hasParameter('mailer_email')) {
$mailer_email = $this->container->getParameter('mailer_email');
} else if ($this->container->hasParameter('mailer_user')) {
$mailer_email = $this->container->getParameter('mailer_user');
} else {
$mailer_email = "define@youremail.com";
}
$emailMessage = \Swift_Message::newInstance()
->setSubject($message->getMySenderEmailSubject($this->container, $user))
->setFrom($mailer_email)
->setTo($toEmail)
->setBody(
$message->getMySenderEmailBody($this->container, $user),
'text/html'
)
;
$senderAttach = $message->getMySenderEmailAttach($this->container, $user);
if ($senderAttach != null) {
if (is_array($senderAttach)) {
foreach($senderAttach as $attach) {
$emailMessage->attach(\Swift_Attachment::fromPath($attach));
}
} else {
$emailMessage->attach(\Swift_Attachment::fromPath($senderAttach));
}
}
$this->container->get('mailer')->send($emailMessage);
return true;
}
|
php
|
public function sendMessageToEmail(Message $message, $user) {
if (is_object($user)) {
$toEmail = $user->getEmail();
} else {
$toEmail = $user;
}
if ($this->container->hasParameter('mailer_email')) {
$mailer_email = $this->container->getParameter('mailer_email');
} else if ($this->container->hasParameter('mailer_user')) {
$mailer_email = $this->container->getParameter('mailer_user');
} else {
$mailer_email = "define@youremail.com";
}
$emailMessage = \Swift_Message::newInstance()
->setSubject($message->getMySenderEmailSubject($this->container, $user))
->setFrom($mailer_email)
->setTo($toEmail)
->setBody(
$message->getMySenderEmailBody($this->container, $user),
'text/html'
)
;
$senderAttach = $message->getMySenderEmailAttach($this->container, $user);
if ($senderAttach != null) {
if (is_array($senderAttach)) {
foreach($senderAttach as $attach) {
$emailMessage->attach(\Swift_Attachment::fromPath($attach));
}
} else {
$emailMessage->attach(\Swift_Attachment::fromPath($senderAttach));
}
}
$this->container->get('mailer')->send($emailMessage);
return true;
}
|
[
"public",
"function",
"sendMessageToEmail",
"(",
"Message",
"$",
"message",
",",
"$",
"user",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"user",
")",
")",
"{",
"$",
"toEmail",
"=",
"$",
"user",
"->",
"getEmail",
"(",
")",
";",
"}",
"else",
"{",
"$",
"toEmail",
"=",
"$",
"user",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"hasParameter",
"(",
"'mailer_email'",
")",
")",
"{",
"$",
"mailer_email",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'mailer_email'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"hasParameter",
"(",
"'mailer_user'",
")",
")",
"{",
"$",
"mailer_email",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'mailer_user'",
")",
";",
"}",
"else",
"{",
"$",
"mailer_email",
"=",
"\"define@youremail.com\"",
";",
"}",
"$",
"emailMessage",
"=",
"\\",
"Swift_Message",
"::",
"newInstance",
"(",
")",
"->",
"setSubject",
"(",
"$",
"message",
"->",
"getMySenderEmailSubject",
"(",
"$",
"this",
"->",
"container",
",",
"$",
"user",
")",
")",
"->",
"setFrom",
"(",
"$",
"mailer_email",
")",
"->",
"setTo",
"(",
"$",
"toEmail",
")",
"->",
"setBody",
"(",
"$",
"message",
"->",
"getMySenderEmailBody",
"(",
"$",
"this",
"->",
"container",
",",
"$",
"user",
")",
",",
"'text/html'",
")",
";",
"$",
"senderAttach",
"=",
"$",
"message",
"->",
"getMySenderEmailAttach",
"(",
"$",
"this",
"->",
"container",
",",
"$",
"user",
")",
";",
"if",
"(",
"$",
"senderAttach",
"!=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"senderAttach",
")",
")",
"{",
"foreach",
"(",
"$",
"senderAttach",
"as",
"$",
"attach",
")",
"{",
"$",
"emailMessage",
"->",
"attach",
"(",
"\\",
"Swift_Attachment",
"::",
"fromPath",
"(",
"$",
"attach",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"emailMessage",
"->",
"attach",
"(",
"\\",
"Swift_Attachment",
"::",
"fromPath",
"(",
"$",
"senderAttach",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mailer'",
")",
"->",
"send",
"(",
"$",
"emailMessage",
")",
";",
"return",
"true",
";",
"}"
] |
Send a message to Email
@return bool
|
[
"Send",
"a",
"message",
"to",
"Email"
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/MessageHelper.php#L388-L426
|
225,468
|
yawik/behat
|
src/CoreContext.php
|
CoreContext.iSubmitTheFormWithId
|
public function iSubmitTheFormWithId($arg)
{
$node = $this->minkContext->getSession()->getPage()->find('css', $arg);
if ($node) {
$this->minkContext->getSession()->executeScript("jQuery('$arg').submit();");
} else {
throw new \Exception('Element not found');
}
}
|
php
|
public function iSubmitTheFormWithId($arg)
{
$node = $this->minkContext->getSession()->getPage()->find('css', $arg);
if ($node) {
$this->minkContext->getSession()->executeScript("jQuery('$arg').submit();");
} else {
throw new \Exception('Element not found');
}
}
|
[
"public",
"function",
"iSubmitTheFormWithId",
"(",
"$",
"arg",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"minkContext",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"find",
"(",
"'css'",
",",
"$",
"arg",
")",
";",
"if",
"(",
"$",
"node",
")",
"{",
"$",
"this",
"->",
"minkContext",
"->",
"getSession",
"(",
")",
"->",
"executeScript",
"(",
"\"jQuery('$arg').submit();\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Element not found'",
")",
";",
"}",
"}"
] |
Some forms do not have a Submit button just pass the ID
@Given /^I submit the form with id "([^"]*)"$/
|
[
"Some",
"forms",
"do",
"not",
"have",
"a",
"Submit",
"button",
"just",
"pass",
"the",
"ID"
] |
9e776b8aa8a069da13e35d717f7bb35c2f96b277
|
https://github.com/yawik/behat/blob/9e776b8aa8a069da13e35d717f7bb35c2f96b277/src/CoreContext.php#L143-L151
|
225,469
|
yawik/behat
|
src/CoreContext.php
|
CoreContext.iClickOnTheText
|
public function iClickOnTheText($text)
{
$session = $this->getSession();
$element = $session->getPage()->find(
'xpath',
$session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]')
);
if (null === $element) {
$element = $session->getPage()->find(
'named',
array('id',$text)
);
}
if (null === $element) {
throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
}
$element->click();
}
|
php
|
public function iClickOnTheText($text)
{
$session = $this->getSession();
$element = $session->getPage()->find(
'xpath',
$session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]')
);
if (null === $element) {
$element = $session->getPage()->find(
'named',
array('id',$text)
);
}
if (null === $element) {
throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
}
$element->click();
}
|
[
"public",
"function",
"iClickOnTheText",
"(",
"$",
"text",
")",
"{",
"$",
"session",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"$",
"element",
"=",
"$",
"session",
"->",
"getPage",
"(",
")",
"->",
"find",
"(",
"'xpath'",
",",
"$",
"session",
"->",
"getSelectorsHandler",
"(",
")",
"->",
"selectorToXpath",
"(",
"'xpath'",
",",
"'*//*[text()=\"'",
".",
"$",
"text",
".",
"'\"]'",
")",
")",
";",
"if",
"(",
"null",
"===",
"$",
"element",
")",
"{",
"$",
"element",
"=",
"$",
"session",
"->",
"getPage",
"(",
")",
"->",
"find",
"(",
"'named'",
",",
"array",
"(",
"'id'",
",",
"$",
"text",
")",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"element",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Cannot find text: \"%s\"'",
",",
"$",
"text",
")",
")",
";",
"}",
"$",
"element",
"->",
"click",
"(",
")",
";",
"}"
] |
Click some text
@When /^I click on the text "([^"]*)"$/
|
[
"Click",
"some",
"text"
] |
9e776b8aa8a069da13e35d717f7bb35c2f96b277
|
https://github.com/yawik/behat/blob/9e776b8aa8a069da13e35d717f7bb35c2f96b277/src/CoreContext.php#L285-L303
|
225,470
|
railken/amethyst-listener
|
src/Managers/ListenerManager.php
|
ListenerManager.getAvailableEventClasses
|
public function getAvailableEventClasses()
{
/** @var \Railken\Amethyst\Repositories\ListenerRepository */
$repository = $this->getRepository();
return $repository->newQuery()->get()->map(function ($v) {
return $v->event_class;
})->toArray();
}
|
php
|
public function getAvailableEventClasses()
{
/** @var \Railken\Amethyst\Repositories\ListenerRepository */
$repository = $this->getRepository();
return $repository->newQuery()->get()->map(function ($v) {
return $v->event_class;
})->toArray();
}
|
[
"public",
"function",
"getAvailableEventClasses",
"(",
")",
"{",
"/** @var \\Railken\\Amethyst\\Repositories\\ListenerRepository */",
"$",
"repository",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"return",
"$",
"repository",
"->",
"newQuery",
"(",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"$",
"v",
"->",
"event_class",
";",
"}",
")",
"->",
"toArray",
"(",
")",
";",
"}"
] |
Retrieve all events_class available.
@return array
|
[
"Retrieve",
"all",
"events_class",
"available",
"."
] |
e815710b199ee445c7cea9f4a8af03593cb1e878
|
https://github.com/railken/amethyst-listener/blob/e815710b199ee445c7cea9f4a8af03593cb1e878/src/Managers/ListenerManager.php#L22-L30
|
225,471
|
bytic/Common
|
src/Controllers/Traits/HasRecordPaginator.php
|
HasRecordPaginator.prepareRecordPaginator
|
public function prepareRecordPaginator()
{
$page = $this->getRequest()->get('page', 1);
$this->getRecordPaginator()->setPage(intval($page));
$this->getRecordPaginator()->setItemsPerPage(50);
}
|
php
|
public function prepareRecordPaginator()
{
$page = $this->getRequest()->get('page', 1);
$this->getRecordPaginator()->setPage(intval($page));
$this->getRecordPaginator()->setItemsPerPage(50);
}
|
[
"public",
"function",
"prepareRecordPaginator",
"(",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"get",
"(",
"'page'",
",",
"1",
")",
";",
"$",
"this",
"->",
"getRecordPaginator",
"(",
")",
"->",
"setPage",
"(",
"intval",
"(",
"$",
"page",
")",
")",
";",
"$",
"this",
"->",
"getRecordPaginator",
"(",
")",
"->",
"setItemsPerPage",
"(",
"50",
")",
";",
"}"
] |
Prepare Record Paginator Object
@return void
|
[
"Prepare",
"Record",
"Paginator",
"Object"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Controllers/Traits/HasRecordPaginator.php#L79-L84
|
225,472
|
n2n/n2n-log4php
|
src/app/n2n/log4php/layout/LayoutPattern.php
|
LayoutPattern.activateOptions
|
public function activateOptions() {
if (!isset($this->pattern)) {
throw new \n2n\log4php\LoggerException("Mandatory parameter 'conversionPattern' is not set.");
}
$parser = new \n2n\log4php\pattern\PatternParser($this->pattern, $this->converterMap);
$this->head = $parser->parse();
}
|
php
|
public function activateOptions() {
if (!isset($this->pattern)) {
throw new \n2n\log4php\LoggerException("Mandatory parameter 'conversionPattern' is not set.");
}
$parser = new \n2n\log4php\pattern\PatternParser($this->pattern, $this->converterMap);
$this->head = $parser->parse();
}
|
[
"public",
"function",
"activateOptions",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"pattern",
")",
")",
"{",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"Mandatory parameter 'conversionPattern' is not set.\"",
")",
";",
"}",
"$",
"parser",
"=",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"pattern",
"\\",
"PatternParser",
"(",
"$",
"this",
"->",
"pattern",
",",
"$",
"this",
"->",
"converterMap",
")",
";",
"$",
"this",
"->",
"head",
"=",
"$",
"parser",
"->",
"parse",
"(",
")",
";",
"}"
] |
Processes the conversion pattern and creates a corresponding chain of
pattern converters which will be used to format logging events.
|
[
"Processes",
"the",
"conversion",
"pattern",
"and",
"creates",
"a",
"corresponding",
"chain",
"of",
"pattern",
"converters",
"which",
"will",
"be",
"used",
"to",
"format",
"logging",
"events",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/layout/LayoutPattern.php#L148-L155
|
225,473
|
n2n/n2n-log4php
|
src/app/n2n/log4php/layout/LayoutPattern.php
|
LayoutPattern.format
|
public function format(\n2n\log4php\logging\LoggingEvent $event) {
$sbuf = '';
$converter = $this->head;
while ($converter !== null) {
$converter->format($sbuf, $event);
$converter = $converter->next;
}
return $sbuf;
}
|
php
|
public function format(\n2n\log4php\logging\LoggingEvent $event) {
$sbuf = '';
$converter = $this->head;
while ($converter !== null) {
$converter->format($sbuf, $event);
$converter = $converter->next;
}
return $sbuf;
}
|
[
"public",
"function",
"format",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"logging",
"\\",
"LoggingEvent",
"$",
"event",
")",
"{",
"$",
"sbuf",
"=",
"''",
";",
"$",
"converter",
"=",
"$",
"this",
"->",
"head",
";",
"while",
"(",
"$",
"converter",
"!==",
"null",
")",
"{",
"$",
"converter",
"->",
"format",
"(",
"$",
"sbuf",
",",
"$",
"event",
")",
";",
"$",
"converter",
"=",
"$",
"converter",
"->",
"next",
";",
"}",
"return",
"$",
"sbuf",
";",
"}"
] |
Produces a formatted string as specified by the conversion pattern.
@param \n2n\log4php\logging\LoggingEvent $event
@return string
|
[
"Produces",
"a",
"formatted",
"string",
"as",
"specified",
"by",
"the",
"conversion",
"pattern",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/layout/LayoutPattern.php#L163-L171
|
225,474
|
SetBased/php-helper-code-store
|
src/CodeStore.php
|
CodeStore.append
|
public function append($line, bool $trim = true): void
{
switch (true)
{
case is_string($line):
$this->appendLine($line, $trim);
break;
case is_array($line):
$this->appendLines($line, $trim);
break;
case is_null($line):
// Nothing to do.
break;
default:
throw new \InvalidArgumentException('Not a string nor an array.');
}
}
|
php
|
public function append($line, bool $trim = true): void
{
switch (true)
{
case is_string($line):
$this->appendLine($line, $trim);
break;
case is_array($line):
$this->appendLines($line, $trim);
break;
case is_null($line):
// Nothing to do.
break;
default:
throw new \InvalidArgumentException('Not a string nor an array.');
}
}
|
[
"public",
"function",
"append",
"(",
"$",
"line",
",",
"bool",
"$",
"trim",
"=",
"true",
")",
":",
"void",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_string",
"(",
"$",
"line",
")",
":",
"$",
"this",
"->",
"appendLine",
"(",
"$",
"line",
",",
"$",
"trim",
")",
";",
"break",
";",
"case",
"is_array",
"(",
"$",
"line",
")",
":",
"$",
"this",
"->",
"appendLines",
"(",
"$",
"line",
",",
"$",
"trim",
")",
";",
"break",
";",
"case",
"is_null",
"(",
"$",
"line",
")",
":",
"// Nothing to do.",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Not a string nor an array.'",
")",
";",
"}",
"}"
] |
Appends a line or lines of code.
@param null|string|string[] $line The line or lines of code to be appended. Null values will be ignored.
@param bool $trim If true the line or lines of code will be trimmed before appending.
@throws \InvalidArgumentException
@since 1.0.0
@api
|
[
"Appends",
"a",
"line",
"or",
"lines",
"of",
"code",
"."
] |
42d248b757ffdf7f3d660cadf5b27040f5785b4a
|
https://github.com/SetBased/php-helper-code-store/blob/42d248b757ffdf7f3d660cadf5b27040f5785b4a/src/CodeStore.php#L112-L131
|
225,475
|
SetBased/php-helper-code-store
|
src/CodeStore.php
|
CodeStore.appendToLastLine
|
public function appendToLastLine(string $part): void
{
$this->lines[count($this->lines) - 1] .= $part;
}
|
php
|
public function appendToLastLine(string $part): void
{
$this->lines[count($this->lines) - 1] .= $part;
}
|
[
"public",
"function",
"appendToLastLine",
"(",
"string",
"$",
"part",
")",
":",
"void",
"{",
"$",
"this",
"->",
"lines",
"[",
"count",
"(",
"$",
"this",
"->",
"lines",
")",
"-",
"1",
"]",
".=",
"$",
"part",
";",
"}"
] |
Appends a part of code to the last line of code.
@param string $part The part of code to be to the last line.
@since 1.0.0
@api
|
[
"Appends",
"a",
"part",
"of",
"code",
"to",
"the",
"last",
"line",
"of",
"code",
"."
] |
42d248b757ffdf7f3d660cadf5b27040f5785b4a
|
https://github.com/SetBased/php-helper-code-store/blob/42d248b757ffdf7f3d660cadf5b27040f5785b4a/src/CodeStore.php#L154-L157
|
225,476
|
SetBased/php-helper-code-store
|
src/CodeStore.php
|
CodeStore.getCode
|
public function getCode(): string
{
$lines = [];
$indentLevel = 0;
foreach ($this->lines as $line)
{
$mode = $this->indentationMode($line);
// Increment or decrement indentation level.
if ($mode & self::C_INDENT_INCREMENT_BEFORE)
{
$indentLevel++;
}
if ($mode & self::C_INDENT_DECREMENT_BEFORE)
{
$indentLevel = max(0, $indentLevel - 1);
}
if ($mode & self::C_INDENT_DECREMENT_BEFORE_DOUBLE)
{
$indentLevel = max(0, $indentLevel - 2);
}
// If the line is a separator shorten the separator.
if ($this->separator!==null && $line==$this->separator)
{
$line = $this->shortenSeparator($this->width - $this->indentation * $indentLevel);
}
// Append the line with indentation.
$lines[] = $this->addIndentation($line, $indentLevel);
// Increment or decrement indentation level.
if ($mode & self::C_INDENT_INCREMENT_AFTER)
{
$indentLevel++;
}
if ($mode & self::C_INDENT_DECREMENT_AFTER)
{
$indentLevel = max(0, $indentLevel - 1);
}
}
if (empty($lines))
{
return '';
}
return implode(PHP_EOL, $lines).PHP_EOL;
}
|
php
|
public function getCode(): string
{
$lines = [];
$indentLevel = 0;
foreach ($this->lines as $line)
{
$mode = $this->indentationMode($line);
// Increment or decrement indentation level.
if ($mode & self::C_INDENT_INCREMENT_BEFORE)
{
$indentLevel++;
}
if ($mode & self::C_INDENT_DECREMENT_BEFORE)
{
$indentLevel = max(0, $indentLevel - 1);
}
if ($mode & self::C_INDENT_DECREMENT_BEFORE_DOUBLE)
{
$indentLevel = max(0, $indentLevel - 2);
}
// If the line is a separator shorten the separator.
if ($this->separator!==null && $line==$this->separator)
{
$line = $this->shortenSeparator($this->width - $this->indentation * $indentLevel);
}
// Append the line with indentation.
$lines[] = $this->addIndentation($line, $indentLevel);
// Increment or decrement indentation level.
if ($mode & self::C_INDENT_INCREMENT_AFTER)
{
$indentLevel++;
}
if ($mode & self::C_INDENT_DECREMENT_AFTER)
{
$indentLevel = max(0, $indentLevel - 1);
}
}
if (empty($lines))
{
return '';
}
return implode(PHP_EOL, $lines).PHP_EOL;
}
|
[
"public",
"function",
"getCode",
"(",
")",
":",
"string",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"indentLevel",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"mode",
"=",
"$",
"this",
"->",
"indentationMode",
"(",
"$",
"line",
")",
";",
"// Increment or decrement indentation level.",
"if",
"(",
"$",
"mode",
"&",
"self",
"::",
"C_INDENT_INCREMENT_BEFORE",
")",
"{",
"$",
"indentLevel",
"++",
";",
"}",
"if",
"(",
"$",
"mode",
"&",
"self",
"::",
"C_INDENT_DECREMENT_BEFORE",
")",
"{",
"$",
"indentLevel",
"=",
"max",
"(",
"0",
",",
"$",
"indentLevel",
"-",
"1",
")",
";",
"}",
"if",
"(",
"$",
"mode",
"&",
"self",
"::",
"C_INDENT_DECREMENT_BEFORE_DOUBLE",
")",
"{",
"$",
"indentLevel",
"=",
"max",
"(",
"0",
",",
"$",
"indentLevel",
"-",
"2",
")",
";",
"}",
"// If the line is a separator shorten the separator.",
"if",
"(",
"$",
"this",
"->",
"separator",
"!==",
"null",
"&&",
"$",
"line",
"==",
"$",
"this",
"->",
"separator",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"shortenSeparator",
"(",
"$",
"this",
"->",
"width",
"-",
"$",
"this",
"->",
"indentation",
"*",
"$",
"indentLevel",
")",
";",
"}",
"// Append the line with indentation.",
"$",
"lines",
"[",
"]",
"=",
"$",
"this",
"->",
"addIndentation",
"(",
"$",
"line",
",",
"$",
"indentLevel",
")",
";",
"// Increment or decrement indentation level.",
"if",
"(",
"$",
"mode",
"&",
"self",
"::",
"C_INDENT_INCREMENT_AFTER",
")",
"{",
"$",
"indentLevel",
"++",
";",
"}",
"if",
"(",
"$",
"mode",
"&",
"self",
"::",
"C_INDENT_DECREMENT_AFTER",
")",
"{",
"$",
"indentLevel",
"=",
"max",
"(",
"0",
",",
"$",
"indentLevel",
"-",
"1",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"lines",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"implode",
"(",
"PHP_EOL",
",",
"$",
"lines",
")",
".",
"PHP_EOL",
";",
"}"
] |
Returns the generated code properly indented as a single string.
@return string
@since 1.0.0
@api
|
[
"Returns",
"the",
"generated",
"code",
"properly",
"indented",
"as",
"a",
"single",
"string",
"."
] |
42d248b757ffdf7f3d660cadf5b27040f5785b4a
|
https://github.com/SetBased/php-helper-code-store/blob/42d248b757ffdf7f3d660cadf5b27040f5785b4a/src/CodeStore.php#L180-L229
|
225,477
|
SetBased/php-helper-code-store
|
src/CodeStore.php
|
CodeStore.addIndentation
|
private function addIndentation(string $line, int $indentLevel): string
{
return ($line==='') ? '' : str_repeat(' ', $this->indentation * $indentLevel).$line;
}
|
php
|
private function addIndentation(string $line, int $indentLevel): string
{
return ($line==='') ? '' : str_repeat(' ', $this->indentation * $indentLevel).$line;
}
|
[
"private",
"function",
"addIndentation",
"(",
"string",
"$",
"line",
",",
"int",
"$",
"indentLevel",
")",
":",
"string",
"{",
"return",
"(",
"$",
"line",
"===",
"''",
")",
"?",
"''",
":",
"str_repeat",
"(",
"' '",
",",
"$",
"this",
"->",
"indentation",
"*",
"$",
"indentLevel",
")",
".",
"$",
"line",
";",
"}"
] |
Returns a line of code with the proper amount of indentationMode.
@param string $line The line of code.
@param int $indentLevel The indentation level.
@return string The indented line of code.
|
[
"Returns",
"a",
"line",
"of",
"code",
"with",
"the",
"proper",
"amount",
"of",
"indentationMode",
"."
] |
42d248b757ffdf7f3d660cadf5b27040f5785b4a
|
https://github.com/SetBased/php-helper-code-store/blob/42d248b757ffdf7f3d660cadf5b27040f5785b4a/src/CodeStore.php#L307-L310
|
225,478
|
SetBased/php-helper-code-store
|
src/CodeStore.php
|
CodeStore.appendLine
|
private function appendLine(?string $line, bool $trim): void
{
if ($line===null) return;
if ($trim) $line = trim($line);
$this->lines[] = $line;
}
|
php
|
private function appendLine(?string $line, bool $trim): void
{
if ($line===null) return;
if ($trim) $line = trim($line);
$this->lines[] = $line;
}
|
[
"private",
"function",
"appendLine",
"(",
"?",
"string",
"$",
"line",
",",
"bool",
"$",
"trim",
")",
":",
"void",
"{",
"if",
"(",
"$",
"line",
"===",
"null",
")",
"return",
";",
"if",
"(",
"$",
"trim",
")",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"$",
"this",
"->",
"lines",
"[",
"]",
"=",
"$",
"line",
";",
"}"
] |
Appends a line of code this this code.
@param null|string $line The line of code to append. If null the line will be ignored.
@param bool $trim If true the line of code will be trimmed before appending.
|
[
"Appends",
"a",
"line",
"of",
"code",
"this",
"this",
"code",
"."
] |
42d248b757ffdf7f3d660cadf5b27040f5785b4a
|
https://github.com/SetBased/php-helper-code-store/blob/42d248b757ffdf7f3d660cadf5b27040f5785b4a/src/CodeStore.php#L319-L326
|
225,479
|
SetBased/php-helper-code-store
|
src/CodeStore.php
|
CodeStore.appendLines
|
private function appendLines(array $lines, bool $trim): void
{
foreach ($lines as $line)
{
$this->appendLine($line, $trim);
}
}
|
php
|
private function appendLines(array $lines, bool $trim): void
{
foreach ($lines as $line)
{
$this->appendLine($line, $trim);
}
}
|
[
"private",
"function",
"appendLines",
"(",
"array",
"$",
"lines",
",",
"bool",
"$",
"trim",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"appendLine",
"(",
"$",
"line",
",",
"$",
"trim",
")",
";",
"}",
"}"
] |
Appends an array with lines of code this this code.
@param string[] $lines The lines of code to append.
@param bool $trim If true the lines of code will be trimmed before appending.
|
[
"Appends",
"an",
"array",
"with",
"lines",
"of",
"code",
"this",
"this",
"code",
"."
] |
42d248b757ffdf7f3d660cadf5b27040f5785b4a
|
https://github.com/SetBased/php-helper-code-store/blob/42d248b757ffdf7f3d660cadf5b27040f5785b4a/src/CodeStore.php#L335-L341
|
225,480
|
SetBased/php-abc-table-overview
|
src/OverviewTable.php
|
OverviewTable.addColumn
|
public function addColumn(TableColumn $column): void
{
// Add the column to our array of columns.
$this->columns[$this->columnIndex] = $column;
$column->onAddColumn($this, $this->columnIndex);
// Increase the index for the next added column.
$this->columnIndex += $column->getColSpan();
}
|
php
|
public function addColumn(TableColumn $column): void
{
// Add the column to our array of columns.
$this->columns[$this->columnIndex] = $column;
$column->onAddColumn($this, $this->columnIndex);
// Increase the index for the next added column.
$this->columnIndex += $column->getColSpan();
}
|
[
"public",
"function",
"addColumn",
"(",
"TableColumn",
"$",
"column",
")",
":",
"void",
"{",
"// Add the column to our array of columns.",
"$",
"this",
"->",
"columns",
"[",
"$",
"this",
"->",
"columnIndex",
"]",
"=",
"$",
"column",
";",
"$",
"column",
"->",
"onAddColumn",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"columnIndex",
")",
";",
"// Increase the index for the next added column.",
"$",
"this",
"->",
"columnIndex",
"+=",
"$",
"column",
"->",
"getColSpan",
"(",
")",
";",
"}"
] |
Adds a column to this table.
@param TableColumn $column The column to be added to this table.
|
[
"Adds",
"a",
"column",
"to",
"this",
"table",
"."
] |
1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a
|
https://github.com/SetBased/php-abc-table-overview/blob/1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a/src/OverviewTable.php#L73-L82
|
225,481
|
SetBased/php-abc-table-overview
|
src/OverviewTable.php
|
OverviewTable.getHtmlTable
|
public function getHtmlTable(array $rows): string
{
$this->prepare();
$ret = $this->getHtmlPrefix();
$ret .= Html::generateTag('table', $this->attributes);
// Generate HTML code for the column classes.
$ret .= '<colgroup>';
foreach ($this->columns as $column)
{
// If required disable sorting of this column.
if (!$this->sortable) $column->notSortable();
// Generate column element.
$ret .= $column->getHtmlCol();
}
$ret .= '</colgroup>';
// Generate HTML code for the table header.
$ret .= Html::generateTag('thead', ['class' => static::$class]);
$ret .= $this->getHtmlHeader();
$ret .= '</thead>';
// Generate HTML code for the table body.
$ret .= Html::generateTag('tbody', ['class' => static::$class]);
$ret .= $this->getHtmlBody($rows);
$ret .= '</tbody>';
$ret .= '</table>';
$ret .= $this->getHtmlPostfix();
$this->generateResponsiveCss();
return $ret;
}
|
php
|
public function getHtmlTable(array $rows): string
{
$this->prepare();
$ret = $this->getHtmlPrefix();
$ret .= Html::generateTag('table', $this->attributes);
// Generate HTML code for the column classes.
$ret .= '<colgroup>';
foreach ($this->columns as $column)
{
// If required disable sorting of this column.
if (!$this->sortable) $column->notSortable();
// Generate column element.
$ret .= $column->getHtmlCol();
}
$ret .= '</colgroup>';
// Generate HTML code for the table header.
$ret .= Html::generateTag('thead', ['class' => static::$class]);
$ret .= $this->getHtmlHeader();
$ret .= '</thead>';
// Generate HTML code for the table body.
$ret .= Html::generateTag('tbody', ['class' => static::$class]);
$ret .= $this->getHtmlBody($rows);
$ret .= '</tbody>';
$ret .= '</table>';
$ret .= $this->getHtmlPostfix();
$this->generateResponsiveCss();
return $ret;
}
|
[
"public",
"function",
"getHtmlTable",
"(",
"array",
"$",
"rows",
")",
":",
"string",
"{",
"$",
"this",
"->",
"prepare",
"(",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"getHtmlPrefix",
"(",
")",
";",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'table'",
",",
"$",
"this",
"->",
"attributes",
")",
";",
"// Generate HTML code for the column classes.",
"$",
"ret",
".=",
"'<colgroup>'",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"// If required disable sorting of this column.",
"if",
"(",
"!",
"$",
"this",
"->",
"sortable",
")",
"$",
"column",
"->",
"notSortable",
"(",
")",
";",
"// Generate column element.",
"$",
"ret",
".=",
"$",
"column",
"->",
"getHtmlCol",
"(",
")",
";",
"}",
"$",
"ret",
".=",
"'</colgroup>'",
";",
"// Generate HTML code for the table header.",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'thead'",
",",
"[",
"'class'",
"=>",
"static",
"::",
"$",
"class",
"]",
")",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"getHtmlHeader",
"(",
")",
";",
"$",
"ret",
".=",
"'</thead>'",
";",
"// Generate HTML code for the table body.",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'tbody'",
",",
"[",
"'class'",
"=>",
"static",
"::",
"$",
"class",
"]",
")",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"getHtmlBody",
"(",
"$",
"rows",
")",
";",
"$",
"ret",
".=",
"'</tbody>'",
";",
"$",
"ret",
".=",
"'</table>'",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"getHtmlPostfix",
"(",
")",
";",
"$",
"this",
"->",
"generateResponsiveCss",
"(",
")",
";",
"return",
"$",
"ret",
";",
"}"
] |
Returns the HTML code of this table
@param array[] $rows The data shown in the table.
@return string
|
[
"Returns",
"the",
"HTML",
"code",
"of",
"this",
"table"
] |
1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a
|
https://github.com/SetBased/php-abc-table-overview/blob/1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a/src/OverviewTable.php#L119-L156
|
225,482
|
SetBased/php-abc-table-overview
|
src/OverviewTable.php
|
OverviewTable.getHtmlBody
|
protected function getHtmlBody(array $rows): string
{
$ret = '';
$i = 0;
foreach ($rows as $row)
{
$class = static::$class;
if ($class!==null) $class .= ' ';
$class .= ($i % 2==0) ? 'even' : 'odd';
$ret .= Html::generateTag('tr', ['class' => $class]);
foreach ($this->columns as $column)
{
$ret .= $column->getHtmlCell($row);
}
$ret .= '</tr>';
$i++;
}
return $ret;
}
|
php
|
protected function getHtmlBody(array $rows): string
{
$ret = '';
$i = 0;
foreach ($rows as $row)
{
$class = static::$class;
if ($class!==null) $class .= ' ';
$class .= ($i % 2==0) ? 'even' : 'odd';
$ret .= Html::generateTag('tr', ['class' => $class]);
foreach ($this->columns as $column)
{
$ret .= $column->getHtmlCell($row);
}
$ret .= '</tr>';
$i++;
}
return $ret;
}
|
[
"protected",
"function",
"getHtmlBody",
"(",
"array",
"$",
"rows",
")",
":",
"string",
"{",
"$",
"ret",
"=",
"''",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"class",
"=",
"static",
"::",
"$",
"class",
";",
"if",
"(",
"$",
"class",
"!==",
"null",
")",
"$",
"class",
".=",
"' '",
";",
"$",
"class",
".=",
"(",
"$",
"i",
"%",
"2",
"==",
"0",
")",
"?",
"'even'",
":",
"'odd'",
";",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'tr'",
",",
"[",
"'class'",
"=>",
"$",
"class",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"ret",
".=",
"$",
"column",
"->",
"getHtmlCell",
"(",
"$",
"row",
")",
";",
"}",
"$",
"ret",
".=",
"'</tr>'",
";",
"$",
"i",
"++",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Returns the inner HTML code of the body for this table holding the rows as data.
@param array[] $rows The data of the rows.
@return string
|
[
"Returns",
"the",
"inner",
"HTML",
"code",
"of",
"the",
"body",
"for",
"this",
"table",
"holding",
"the",
"rows",
"as",
"data",
"."
] |
1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a
|
https://github.com/SetBased/php-abc-table-overview/blob/1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a/src/OverviewTable.php#L201-L221
|
225,483
|
SetBased/php-abc-table-overview
|
src/OverviewTable.php
|
OverviewTable.getHtmlHeader
|
protected function getHtmlHeader(): string
{
$ret = '';
if ($this->title)
{
$mode = 1;
$colspan = 0;
$ret .= '<tr class="title">';
foreach ($this->columns as $column)
{
$empty = $column->hasEmptyHeader();
if ($mode==1)
{
if ($empty)
{
$ret .= '<th class="empty"></th>';
}
else
{
$mode = 2;
}
}
if ($mode==2)
{
if ($empty)
{
$mode = 3;
}
else
{
$colspan++;
}
}
if ($mode==3)
{
if ($colspan==1) $colspan = null;
$ret .= Html::generateElement('th', ['colspan' => $colspan], $this->title);
$mode = 4;
}
if ($mode==4)
{
$ret .= '<th class="empty"></th>';
}
}
if ($mode==2)
{
if ($colspan==1) $colspan = null;
$ret .= Html::generateElement('th', ['colspan' => $colspan], $this->title);
}
$ret .= '</tr>';
}
$ret .= Html::generateTag('tr', ['class' => [self::$class, 'header']]);
foreach ($this->columns as $column)
{
$ret .= $column->getHtmlColumnHeader();
}
$ret .= '</tr>';
if ($this->filter)
{
$ret .= Html::generateTag('tr', ['class' => [self::$class, 'filter']]);
foreach ($this->columns as $column)
{
$ret .= $column->getHtmlColumnFilter();
}
$ret .= '</tr>';
}
return $ret;
}
|
php
|
protected function getHtmlHeader(): string
{
$ret = '';
if ($this->title)
{
$mode = 1;
$colspan = 0;
$ret .= '<tr class="title">';
foreach ($this->columns as $column)
{
$empty = $column->hasEmptyHeader();
if ($mode==1)
{
if ($empty)
{
$ret .= '<th class="empty"></th>';
}
else
{
$mode = 2;
}
}
if ($mode==2)
{
if ($empty)
{
$mode = 3;
}
else
{
$colspan++;
}
}
if ($mode==3)
{
if ($colspan==1) $colspan = null;
$ret .= Html::generateElement('th', ['colspan' => $colspan], $this->title);
$mode = 4;
}
if ($mode==4)
{
$ret .= '<th class="empty"></th>';
}
}
if ($mode==2)
{
if ($colspan==1) $colspan = null;
$ret .= Html::generateElement('th', ['colspan' => $colspan], $this->title);
}
$ret .= '</tr>';
}
$ret .= Html::generateTag('tr', ['class' => [self::$class, 'header']]);
foreach ($this->columns as $column)
{
$ret .= $column->getHtmlColumnHeader();
}
$ret .= '</tr>';
if ($this->filter)
{
$ret .= Html::generateTag('tr', ['class' => [self::$class, 'filter']]);
foreach ($this->columns as $column)
{
$ret .= $column->getHtmlColumnFilter();
}
$ret .= '</tr>';
}
return $ret;
}
|
[
"protected",
"function",
"getHtmlHeader",
"(",
")",
":",
"string",
"{",
"$",
"ret",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"title",
")",
"{",
"$",
"mode",
"=",
"1",
";",
"$",
"colspan",
"=",
"0",
";",
"$",
"ret",
".=",
"'<tr class=\"title\">'",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"empty",
"=",
"$",
"column",
"->",
"hasEmptyHeader",
"(",
")",
";",
"if",
"(",
"$",
"mode",
"==",
"1",
")",
"{",
"if",
"(",
"$",
"empty",
")",
"{",
"$",
"ret",
".=",
"'<th class=\"empty\"></th>'",
";",
"}",
"else",
"{",
"$",
"mode",
"=",
"2",
";",
"}",
"}",
"if",
"(",
"$",
"mode",
"==",
"2",
")",
"{",
"if",
"(",
"$",
"empty",
")",
"{",
"$",
"mode",
"=",
"3",
";",
"}",
"else",
"{",
"$",
"colspan",
"++",
";",
"}",
"}",
"if",
"(",
"$",
"mode",
"==",
"3",
")",
"{",
"if",
"(",
"$",
"colspan",
"==",
"1",
")",
"$",
"colspan",
"=",
"null",
";",
"$",
"ret",
".=",
"Html",
"::",
"generateElement",
"(",
"'th'",
",",
"[",
"'colspan'",
"=>",
"$",
"colspan",
"]",
",",
"$",
"this",
"->",
"title",
")",
";",
"$",
"mode",
"=",
"4",
";",
"}",
"if",
"(",
"$",
"mode",
"==",
"4",
")",
"{",
"$",
"ret",
".=",
"'<th class=\"empty\"></th>'",
";",
"}",
"}",
"if",
"(",
"$",
"mode",
"==",
"2",
")",
"{",
"if",
"(",
"$",
"colspan",
"==",
"1",
")",
"$",
"colspan",
"=",
"null",
";",
"$",
"ret",
".=",
"Html",
"::",
"generateElement",
"(",
"'th'",
",",
"[",
"'colspan'",
"=>",
"$",
"colspan",
"]",
",",
"$",
"this",
"->",
"title",
")",
";",
"}",
"$",
"ret",
".=",
"'</tr>'",
";",
"}",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'tr'",
",",
"[",
"'class'",
"=>",
"[",
"self",
"::",
"$",
"class",
",",
"'header'",
"]",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"ret",
".=",
"$",
"column",
"->",
"getHtmlColumnHeader",
"(",
")",
";",
"}",
"$",
"ret",
".=",
"'</tr>'",
";",
"if",
"(",
"$",
"this",
"->",
"filter",
")",
"{",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'tr'",
",",
"[",
"'class'",
"=>",
"[",
"self",
"::",
"$",
"class",
",",
"'filter'",
"]",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"ret",
".=",
"$",
"column",
"->",
"getHtmlColumnFilter",
"(",
")",
";",
"}",
"$",
"ret",
".=",
"'</tr>'",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Returns the inner HTML code of the header for this table.
@return string
|
[
"Returns",
"the",
"inner",
"HTML",
"code",
"of",
"the",
"header",
"for",
"this",
"table",
"."
] |
1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a
|
https://github.com/SetBased/php-abc-table-overview/blob/1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a/src/OverviewTable.php#L229-L307
|
225,484
|
SetBased/php-abc-table-overview
|
src/OverviewTable.php
|
OverviewTable.prepare
|
private function prepare(): void
{
$this->addClass(static::$class);
if (static::$responsiveMediaQuery!==null && $this->getAttribute('id')===null)
{
$this->setAttrId(Html::getAutoId());
}
}
|
php
|
private function prepare(): void
{
$this->addClass(static::$class);
if (static::$responsiveMediaQuery!==null && $this->getAttribute('id')===null)
{
$this->setAttrId(Html::getAutoId());
}
}
|
[
"private",
"function",
"prepare",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"addClass",
"(",
"static",
"::",
"$",
"class",
")",
";",
"if",
"(",
"static",
"::",
"$",
"responsiveMediaQuery",
"!==",
"null",
"&&",
"$",
"this",
"->",
"getAttribute",
"(",
"'id'",
")",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setAttrId",
"(",
"Html",
"::",
"getAutoId",
"(",
")",
")",
";",
"}",
"}"
] |
Prepares this table for generation HTML code.
|
[
"Prepares",
"this",
"table",
"for",
"generation",
"HTML",
"code",
"."
] |
1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a
|
https://github.com/SetBased/php-abc-table-overview/blob/1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a/src/OverviewTable.php#L358-L366
|
225,485
|
stubbles/stubbles-input
|
src/main/php/broker/param/CustomDatespanParamBroker.php
|
CustomDatespanParamBroker.getDate
|
private function getDate(Request $request, Annotation $annotation, $type)
{
$nameMethod = 'get' . $type . 'Name';
return $this->readValue(
$request,
$annotation->$nameMethod(),
$annotation->isRequired(),
$this->parseDate($annotation, 'default' . $type)
)
->asDate(new DateRange(
$this->parseDate($annotation, "min{$type}Date"),
$this->parseDate($annotation, "max{$type}Date")
)
);
}
|
php
|
private function getDate(Request $request, Annotation $annotation, $type)
{
$nameMethod = 'get' . $type . 'Name';
return $this->readValue(
$request,
$annotation->$nameMethod(),
$annotation->isRequired(),
$this->parseDate($annotation, 'default' . $type)
)
->asDate(new DateRange(
$this->parseDate($annotation, "min{$type}Date"),
$this->parseDate($annotation, "max{$type}Date")
)
);
}
|
[
"private",
"function",
"getDate",
"(",
"Request",
"$",
"request",
",",
"Annotation",
"$",
"annotation",
",",
"$",
"type",
")",
"{",
"$",
"nameMethod",
"=",
"'get'",
".",
"$",
"type",
".",
"'Name'",
";",
"return",
"$",
"this",
"->",
"readValue",
"(",
"$",
"request",
",",
"$",
"annotation",
"->",
"$",
"nameMethod",
"(",
")",
",",
"$",
"annotation",
"->",
"isRequired",
"(",
")",
",",
"$",
"this",
"->",
"parseDate",
"(",
"$",
"annotation",
",",
"'default'",
".",
"$",
"type",
")",
")",
"->",
"asDate",
"(",
"new",
"DateRange",
"(",
"$",
"this",
"->",
"parseDate",
"(",
"$",
"annotation",
",",
"\"min{$type}Date\"",
")",
",",
"$",
"this",
"->",
"parseDate",
"(",
"$",
"annotation",
",",
"\"max{$type}Date\"",
")",
")",
")",
";",
"}"
] |
retrieves start date
@param \stubbles\input\Request $request
@param \stubbles\reflect\annotation\Annotation $annotation
@param string $type
@return \stubbles\date\Date
|
[
"retrieves",
"start",
"date"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/param/CustomDatespanParamBroker.php#L62-L76
|
225,486
|
stubbles/stubbles-input
|
src/main/php/broker/param/CustomDatespanParamBroker.php
|
CustomDatespanParamBroker.parseDate
|
private function parseDate(Annotation $annotation, string $field)
{
if ($annotation->hasValueByName($field)) {
return new Date($annotation->getValueByName($field));
}
return null;
}
|
php
|
private function parseDate(Annotation $annotation, string $field)
{
if ($annotation->hasValueByName($field)) {
return new Date($annotation->getValueByName($field));
}
return null;
}
|
[
"private",
"function",
"parseDate",
"(",
"Annotation",
"$",
"annotation",
",",
"string",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"annotation",
"->",
"hasValueByName",
"(",
"$",
"field",
")",
")",
"{",
"return",
"new",
"Date",
"(",
"$",
"annotation",
"->",
"getValueByName",
"(",
"$",
"field",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
reads default value from annotation
@param \stubbles\reflect\annotation\Annotation $annotation
@param string $field
@return \stubbles\date\Date
|
[
"reads",
"default",
"value",
"from",
"annotation"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/param/CustomDatespanParamBroker.php#L109-L116
|
225,487
|
SetBased/php-abc-table-detail
|
src/DetailTable.php
|
DetailTable.getHtmlRowHeader
|
protected static function getHtmlRowHeader($header): string
{
$html = '<th>';
$html .= (is_int($header)) ? Abc::$babel->getWord($header) : $header;
$html .= '</th>';
return $html;
}
|
php
|
protected static function getHtmlRowHeader($header): string
{
$html = '<th>';
$html .= (is_int($header)) ? Abc::$babel->getWord($header) : $header;
$html .= '</th>';
return $html;
}
|
[
"protected",
"static",
"function",
"getHtmlRowHeader",
"(",
"$",
"header",
")",
":",
"string",
"{",
"$",
"html",
"=",
"'<th>'",
";",
"$",
"html",
".=",
"(",
"is_int",
"(",
"$",
"header",
")",
")",
"?",
"Abc",
"::",
"$",
"babel",
"->",
"getWord",
"(",
"$",
"header",
")",
":",
"$",
"header",
";",
"$",
"html",
".=",
"'</th>'",
";",
"return",
"$",
"html",
";",
"}"
] |
Returns the HTML code for the header of the row.
@param string|int|null $header The header text of this table row. We distinguish 3 cases:
<ul>
<li>string: the value is the header text of this table row,
<li>int: the value is a word ID to be resolved to a text using Babel,
<li>null: this table row has an empty header.
</ul>
Note: 14 is a word ID and '14' is a header text.
@return string
|
[
"Returns",
"the",
"HTML",
"code",
"for",
"the",
"header",
"of",
"the",
"row",
"."
] |
1f786174ccb10800f9c07bfd497b0ab35940a8ea
|
https://github.com/SetBased/php-abc-table-detail/blob/1f786174ccb10800f9c07bfd497b0ab35940a8ea/src/DetailTable.php#L44-L51
|
225,488
|
SetBased/php-abc-table-detail
|
src/DetailTable.php
|
DetailTable.getHtmlTable
|
public function getHtmlTable(): string
{
$this->addClass(static::$class);
$ret = $this->getHtmlPrefix();
$ret .= Html::generateTag('table', $this->attributes);
$childAttributes = ['class' => static::$class];
// Generate HTML code for the table header.
$ret .= Html::generateTag('thead', $childAttributes);
$ret .= $this->getHtmlHeader();
$ret .= '</thead>';
// Generate HTML code for the table body.
$ret .= Html::generateTag('tbody', $childAttributes);
$ret .= $this->rows;
$ret .= '</tbody>';
// Generate HTML code for the table header.
$ret .= Html::generateTag('tfoot', $childAttributes);
$ret .= $this->getHtmlFooter();
$ret .= '</tfoot>';
$ret .= '</table>';
$ret .= $this->getHtmlPostfix();
return $ret;
}
|
php
|
public function getHtmlTable(): string
{
$this->addClass(static::$class);
$ret = $this->getHtmlPrefix();
$ret .= Html::generateTag('table', $this->attributes);
$childAttributes = ['class' => static::$class];
// Generate HTML code for the table header.
$ret .= Html::generateTag('thead', $childAttributes);
$ret .= $this->getHtmlHeader();
$ret .= '</thead>';
// Generate HTML code for the table body.
$ret .= Html::generateTag('tbody', $childAttributes);
$ret .= $this->rows;
$ret .= '</tbody>';
// Generate HTML code for the table header.
$ret .= Html::generateTag('tfoot', $childAttributes);
$ret .= $this->getHtmlFooter();
$ret .= '</tfoot>';
$ret .= '</table>';
$ret .= $this->getHtmlPostfix();
return $ret;
}
|
[
"public",
"function",
"getHtmlTable",
"(",
")",
":",
"string",
"{",
"$",
"this",
"->",
"addClass",
"(",
"static",
"::",
"$",
"class",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"getHtmlPrefix",
"(",
")",
";",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'table'",
",",
"$",
"this",
"->",
"attributes",
")",
";",
"$",
"childAttributes",
"=",
"[",
"'class'",
"=>",
"static",
"::",
"$",
"class",
"]",
";",
"// Generate HTML code for the table header.",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'thead'",
",",
"$",
"childAttributes",
")",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"getHtmlHeader",
"(",
")",
";",
"$",
"ret",
".=",
"'</thead>'",
";",
"// Generate HTML code for the table body.",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'tbody'",
",",
"$",
"childAttributes",
")",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"rows",
";",
"$",
"ret",
".=",
"'</tbody>'",
";",
"// Generate HTML code for the table header.",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'tfoot'",
",",
"$",
"childAttributes",
")",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"getHtmlFooter",
"(",
")",
";",
"$",
"ret",
".=",
"'</tfoot>'",
";",
"$",
"ret",
".=",
"'</table>'",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"getHtmlPostfix",
"(",
")",
";",
"return",
"$",
"ret",
";",
"}"
] |
Returns the HTML code of this table.
@return string
|
[
"Returns",
"the",
"HTML",
"code",
"of",
"this",
"table",
"."
] |
1f786174ccb10800f9c07bfd497b0ab35940a8ea
|
https://github.com/SetBased/php-abc-table-detail/blob/1f786174ccb10800f9c07bfd497b0ab35940a8ea/src/DetailTable.php#L94-L124
|
225,489
|
railken/amethyst-data-builder
|
src/Models/DataBuilder.php
|
DataBuilder.newInstanceQuery
|
public function newInstanceQuery(array $data, array $selectable = ['*']): Builder
{
$tm = new TextGenerator();
$r = $this->newInstanceData();
$query = $r->newQuery();
if (!empty($this->filter)) {
$filter = new Filter($r->getTableName(), $selectable);
$filter->build($query, $tm->generateAndRender($this->filter, $data));
}
$this->autoJoin($r, $query);
return $query;
}
|
php
|
public function newInstanceQuery(array $data, array $selectable = ['*']): Builder
{
$tm = new TextGenerator();
$r = $this->newInstanceData();
$query = $r->newQuery();
if (!empty($this->filter)) {
$filter = new Filter($r->getTableName(), $selectable);
$filter->build($query, $tm->generateAndRender($this->filter, $data));
}
$this->autoJoin($r, $query);
return $query;
}
|
[
"public",
"function",
"newInstanceQuery",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"selectable",
"=",
"[",
"'*'",
"]",
")",
":",
"Builder",
"{",
"$",
"tm",
"=",
"new",
"TextGenerator",
"(",
")",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"newInstanceData",
"(",
")",
";",
"$",
"query",
"=",
"$",
"r",
"->",
"newQuery",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"filter",
")",
")",
"{",
"$",
"filter",
"=",
"new",
"Filter",
"(",
"$",
"r",
"->",
"getTableName",
"(",
")",
",",
"$",
"selectable",
")",
";",
"$",
"filter",
"->",
"build",
"(",
"$",
"query",
",",
"$",
"tm",
"->",
"generateAndRender",
"(",
"$",
"this",
"->",
"filter",
",",
"$",
"data",
")",
")",
";",
"}",
"$",
"this",
"->",
"autoJoin",
"(",
"$",
"r",
",",
"$",
"query",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
New query instance.
@param array $data
@param array $selectable
@return \Illuminate\Database\Eloquent\Builder
|
[
"New",
"query",
"instance",
"."
] |
55334227b6b7f14cf755b02e7cd36a11db00f454
|
https://github.com/railken/amethyst-data-builder/blob/55334227b6b7f14cf755b02e7cd36a11db00f454/src/Models/DataBuilder.php#L49-L64
|
225,490
|
railken/amethyst-data-builder
|
src/Models/DataBuilder.php
|
DataBuilder.newInstanceData
|
public function newInstanceData()
{
$className = $this->class_name;
$arguments = (array) Yaml::parse(strval($this->class_arguments));
return new $className(...$arguments);
}
|
php
|
public function newInstanceData()
{
$className = $this->class_name;
$arguments = (array) Yaml::parse(strval($this->class_arguments));
return new $className(...$arguments);
}
|
[
"public",
"function",
"newInstanceData",
"(",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"class_name",
";",
"$",
"arguments",
"=",
"(",
"array",
")",
"Yaml",
"::",
"parse",
"(",
"strval",
"(",
"$",
"this",
"->",
"class_arguments",
")",
")",
";",
"return",
"new",
"$",
"className",
"(",
"...",
"$",
"arguments",
")",
";",
"}"
] |
New instance data builder custom.
@return \Railken\Amethyst\Contracts\DataBuilderContract
|
[
"New",
"instance",
"data",
"builder",
"custom",
"."
] |
55334227b6b7f14cf755b02e7cd36a11db00f454
|
https://github.com/railken/amethyst-data-builder/blob/55334227b6b7f14cf755b02e7cd36a11db00f454/src/Models/DataBuilder.php#L122-L129
|
225,491
|
aircury/collection
|
CollectionDiff.php
|
CollectionDiff.apply
|
public function apply(
ComparableCollectionInterface $sourceCollection,
bool $keepOriginalOrder = false
): ComparableCollectionInterface {
$collectionClass = get_class($sourceCollection);
$source = $sourceCollection->toArray();
$array = [];
foreach ($this->changes as $key => [$action, $item]) {
if (self::SOURCE === $action) {
if ($item !== $key) {
$array[$key] = $sourceCollection[$item];
}
} elseif (self::ADDED === $action) {
$array[$key] = $item;
} elseif (self::REMOVED === $action) {
unset($array[$key]);
} else {
$array[$key] = $item;
}
}
if ($keepOriginalOrder) {
$array = array_merge($this->changes, $source);
}
return new $collectionClass($array);
}
|
php
|
public function apply(
ComparableCollectionInterface $sourceCollection,
bool $keepOriginalOrder = false
): ComparableCollectionInterface {
$collectionClass = get_class($sourceCollection);
$source = $sourceCollection->toArray();
$array = [];
foreach ($this->changes as $key => [$action, $item]) {
if (self::SOURCE === $action) {
if ($item !== $key) {
$array[$key] = $sourceCollection[$item];
}
} elseif (self::ADDED === $action) {
$array[$key] = $item;
} elseif (self::REMOVED === $action) {
unset($array[$key]);
} else {
$array[$key] = $item;
}
}
if ($keepOriginalOrder) {
$array = array_merge($this->changes, $source);
}
return new $collectionClass($array);
}
|
[
"public",
"function",
"apply",
"(",
"ComparableCollectionInterface",
"$",
"sourceCollection",
",",
"bool",
"$",
"keepOriginalOrder",
"=",
"false",
")",
":",
"ComparableCollectionInterface",
"{",
"$",
"collectionClass",
"=",
"get_class",
"(",
"$",
"sourceCollection",
")",
";",
"$",
"source",
"=",
"$",
"sourceCollection",
"->",
"toArray",
"(",
")",
";",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"changes",
"as",
"$",
"key",
"=>",
"[",
"$",
"action",
",",
"$",
"item",
"]",
")",
"{",
"if",
"(",
"self",
"::",
"SOURCE",
"===",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"item",
"!==",
"$",
"key",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"sourceCollection",
"[",
"$",
"item",
"]",
";",
"}",
"}",
"elseif",
"(",
"self",
"::",
"ADDED",
"===",
"$",
"action",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"elseif",
"(",
"self",
"::",
"REMOVED",
"===",
"$",
"action",
")",
"{",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"if",
"(",
"$",
"keepOriginalOrder",
")",
"{",
"$",
"array",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"changes",
",",
"$",
"source",
")",
";",
"}",
"return",
"new",
"$",
"collectionClass",
"(",
"$",
"array",
")",
";",
"}"
] |
Applies this Diff over the collection provided and returns a new one with it applied
|
[
"Applies",
"this",
"Diff",
"over",
"the",
"collection",
"provided",
"and",
"returns",
"a",
"new",
"one",
"with",
"it",
"applied"
] |
8b7ec30a5939733c435653724e3ba02c5eed730c
|
https://github.com/aircury/collection/blob/8b7ec30a5939733c435653724e3ba02c5eed730c/CollectionDiff.php#L135-L162
|
225,492
|
froq/froq-service
|
src/ServiceFactory.php
|
ServiceFactory.toServiceMethod
|
public static final function toServiceMethod(string $serviceMethod): string
{
// foo-bar => FooBar
$serviceMethod = ucfirst($serviceMethod);
if (strpos($serviceMethod, '-')) {
$serviceMethod = preg_replace_callback('~-([a-z])~i', function($match) {
return ucfirst($match[1]);
}, $serviceMethod);
}
// foo-bar => doFooBar
return sprintf('%s%s', Service::METHOD_NAME_PREFIX, $serviceMethod);
}
|
php
|
public static final function toServiceMethod(string $serviceMethod): string
{
// foo-bar => FooBar
$serviceMethod = ucfirst($serviceMethod);
if (strpos($serviceMethod, '-')) {
$serviceMethod = preg_replace_callback('~-([a-z])~i', function($match) {
return ucfirst($match[1]);
}, $serviceMethod);
}
// foo-bar => doFooBar
return sprintf('%s%s', Service::METHOD_NAME_PREFIX, $serviceMethod);
}
|
[
"public",
"static",
"final",
"function",
"toServiceMethod",
"(",
"string",
"$",
"serviceMethod",
")",
":",
"string",
"{",
"// foo-bar => FooBar",
"$",
"serviceMethod",
"=",
"ucfirst",
"(",
"$",
"serviceMethod",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"serviceMethod",
",",
"'-'",
")",
")",
"{",
"$",
"serviceMethod",
"=",
"preg_replace_callback",
"(",
"'~-([a-z])~i'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"return",
"ucfirst",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
",",
"$",
"serviceMethod",
")",
";",
"}",
"// foo-bar => doFooBar",
"return",
"sprintf",
"(",
"'%s%s'",
",",
"Service",
"::",
"METHOD_NAME_PREFIX",
",",
"$",
"serviceMethod",
")",
";",
"}"
] |
To service method.
@param string $serviceMethod
@return string
|
[
"To",
"service",
"method",
"."
] |
c8fb2009100b27b6a0bd1ff8f8d81e102faadebc
|
https://github.com/froq/froq-service/blob/c8fb2009100b27b6a0bd1ff8f8d81e102faadebc/src/ServiceFactory.php#L252-L264
|
225,493
|
froq/froq-service
|
src/ServiceFactory.php
|
ServiceFactory.isServiceExists
|
private static final function isServiceExists(string $serviceFile, string $serviceClass): bool
{
if (!file_exists($serviceFile)) {
return false;
}
return class_exists($serviceClass, true);
}
|
php
|
private static final function isServiceExists(string $serviceFile, string $serviceClass): bool
{
if (!file_exists($serviceFile)) {
return false;
}
return class_exists($serviceClass, true);
}
|
[
"private",
"static",
"final",
"function",
"isServiceExists",
"(",
"string",
"$",
"serviceFile",
",",
"string",
"$",
"serviceClass",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"serviceFile",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"class_exists",
"(",
"$",
"serviceClass",
",",
"true",
")",
";",
"}"
] |
Is service exists.
@param string $serviceFile
@param string $serviceClass
@return bool
|
[
"Is",
"service",
"exists",
"."
] |
c8fb2009100b27b6a0bd1ff8f8d81e102faadebc
|
https://github.com/froq/froq-service/blob/c8fb2009100b27b6a0bd1ff8f8d81e102faadebc/src/ServiceFactory.php#L272-L279
|
225,494
|
froq/froq-service
|
src/ServiceFactory.php
|
ServiceFactory.isServiceMethodExists
|
private static final function isServiceMethodExists(?Service $service, string $serviceMethod): bool
{
return $service && method_exists($service, $serviceMethod);
}
|
php
|
private static final function isServiceMethodExists(?Service $service, string $serviceMethod): bool
{
return $service && method_exists($service, $serviceMethod);
}
|
[
"private",
"static",
"final",
"function",
"isServiceMethodExists",
"(",
"?",
"Service",
"$",
"service",
",",
"string",
"$",
"serviceMethod",
")",
":",
"bool",
"{",
"return",
"$",
"service",
"&&",
"method_exists",
"(",
"$",
"service",
",",
"$",
"serviceMethod",
")",
";",
"}"
] |
Is service method exists.
@param froq\service\Service $service
@param string $serviceMethod
@return bool
|
[
"Is",
"service",
"method",
"exists",
"."
] |
c8fb2009100b27b6a0bd1ff8f8d81e102faadebc
|
https://github.com/froq/froq-service/blob/c8fb2009100b27b6a0bd1ff8f8d81e102faadebc/src/ServiceFactory.php#L287-L290
|
225,495
|
SetBased/php-abc-table-detail
|
src/TableRow/EmailTableRow.php
|
EmailTableRow.addRow
|
public static function addRow(DetailTable $table, $header, ?string $value): void
{
if ($value!==null && $value!=='')
{
$a = Html::generateElement('a', ['href' => 'mailto:'.$value], $value);
$table->addRow($header, ['class' => 'email'], $a, true);
}
else
{
$table->addRow($header);
}
}
|
php
|
public static function addRow(DetailTable $table, $header, ?string $value): void
{
if ($value!==null && $value!=='')
{
$a = Html::generateElement('a', ['href' => 'mailto:'.$value], $value);
$table->addRow($header, ['class' => 'email'], $a, true);
}
else
{
$table->addRow($header);
}
}
|
[
"public",
"static",
"function",
"addRow",
"(",
"DetailTable",
"$",
"table",
",",
"$",
"header",
",",
"?",
"string",
"$",
"value",
")",
":",
"void",
"{",
"if",
"(",
"$",
"value",
"!==",
"null",
"&&",
"$",
"value",
"!==",
"''",
")",
"{",
"$",
"a",
"=",
"Html",
"::",
"generateElement",
"(",
"'a'",
",",
"[",
"'href'",
"=>",
"'mailto:'",
".",
"$",
"value",
"]",
",",
"$",
"value",
")",
";",
"$",
"table",
"->",
"addRow",
"(",
"$",
"header",
",",
"[",
"'class'",
"=>",
"'email'",
"]",
",",
"$",
"a",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"table",
"->",
"addRow",
"(",
"$",
"header",
")",
";",
"}",
"}"
] |
Adds a row with a email address to a detail table.
@param DetailTable $table The detail table.
@param string|int|null $header The header text of this table row.
@param string|null $value The email address.
|
[
"Adds",
"a",
"row",
"with",
"a",
"email",
"address",
"to",
"a",
"detail",
"table",
"."
] |
1f786174ccb10800f9c07bfd497b0ab35940a8ea
|
https://github.com/SetBased/php-abc-table-detail/blob/1f786174ccb10800f9c07bfd497b0ab35940a8ea/src/TableRow/EmailTableRow.php#L21-L33
|
225,496
|
cmsgears/module-cms
|
common/components/Cms.php
|
Cms.registerPageMap
|
public function registerPageMap() {
$this->pageMap[ CmsGlobal::TYPE_PAGE ] = Page::class;
$this->pageMap[ CmsGlobal::TYPE_ARTICLE ] = Article::class;
$this->pageMap[ CmsGlobal::TYPE_POST ] = Post::class;
}
|
php
|
public function registerPageMap() {
$this->pageMap[ CmsGlobal::TYPE_PAGE ] = Page::class;
$this->pageMap[ CmsGlobal::TYPE_ARTICLE ] = Article::class;
$this->pageMap[ CmsGlobal::TYPE_POST ] = Post::class;
}
|
[
"public",
"function",
"registerPageMap",
"(",
")",
"{",
"$",
"this",
"->",
"pageMap",
"[",
"CmsGlobal",
"::",
"TYPE_PAGE",
"]",
"=",
"Page",
"::",
"class",
";",
"$",
"this",
"->",
"pageMap",
"[",
"CmsGlobal",
"::",
"TYPE_ARTICLE",
"]",
"=",
"Article",
"::",
"class",
";",
"$",
"this",
"->",
"pageMap",
"[",
"CmsGlobal",
"::",
"TYPE_POST",
"]",
"=",
"Post",
"::",
"class",
";",
"}"
] |
Register page map
|
[
"Register",
"page",
"map"
] |
ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8
|
https://github.com/cmsgears/module-cms/blob/ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8/common/components/Cms.php#L57-L62
|
225,497
|
FlxPeters/sfDependencyInjectionPlugin
|
config/sfDependencyInjectionPluginConfiguration.class.php
|
sfDependencyInjectionPluginConfiguration.initializeServiceContainer
|
private function initializeServiceContainer()
{
$this->containerManager = new ServiceContainerManager($this->dispatcher, $this->getLogger());
$class = $this->getContainerClass();
$container = $this->containerManager->initializeServiceContainer($class);
$this->dispatcher->notify(new sfEvent($container, 'service_container.loaded'));
}
|
php
|
private function initializeServiceContainer()
{
$this->containerManager = new ServiceContainerManager($this->dispatcher, $this->getLogger());
$class = $this->getContainerClass();
$container = $this->containerManager->initializeServiceContainer($class);
$this->dispatcher->notify(new sfEvent($container, 'service_container.loaded'));
}
|
[
"private",
"function",
"initializeServiceContainer",
"(",
")",
"{",
"$",
"this",
"->",
"containerManager",
"=",
"new",
"ServiceContainerManager",
"(",
"$",
"this",
"->",
"dispatcher",
",",
"$",
"this",
"->",
"getLogger",
"(",
")",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getContainerClass",
"(",
")",
";",
"$",
"container",
"=",
"$",
"this",
"->",
"containerManager",
"->",
"initializeServiceContainer",
"(",
"$",
"class",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"notify",
"(",
"new",
"sfEvent",
"(",
"$",
"container",
",",
"'service_container.loaded'",
")",
")",
";",
"}"
] |
Build a new Container or return a existing from cache
|
[
"Build",
"a",
"new",
"Container",
"or",
"return",
"a",
"existing",
"from",
"cache"
] |
d8aced7015011b5d18d297460ccd82f39df6f709
|
https://github.com/FlxPeters/sfDependencyInjectionPlugin/blob/d8aced7015011b5d18d297460ccd82f39df6f709/config/sfDependencyInjectionPluginConfiguration.class.php#L41-L48
|
225,498
|
FlxPeters/sfDependencyInjectionPlugin
|
config/sfDependencyInjectionPluginConfiguration.class.php
|
sfDependencyInjectionPluginConfiguration.listenToMethodNotFound
|
public function listenToMethodNotFound($event)
{
if ('getServiceContainer' == $event['method']) {
$event->setReturnValue($this->containerManager->getServiceContainer());
return true;
}
if ('getContainerBuilder' == $event['method']) {
$event->setReturnValue($this->containerManager->getContainerBuilder());
return true;
}
if ('getService' == $event['method']) {
$event->setReturnValue($this->containerManager->getServiceContainer()->get($event['arguments'][0]));
return true;
}
return false;
}
|
php
|
public function listenToMethodNotFound($event)
{
if ('getServiceContainer' == $event['method']) {
$event->setReturnValue($this->containerManager->getServiceContainer());
return true;
}
if ('getContainerBuilder' == $event['method']) {
$event->setReturnValue($this->containerManager->getContainerBuilder());
return true;
}
if ('getService' == $event['method']) {
$event->setReturnValue($this->containerManager->getServiceContainer()->get($event['arguments'][0]));
return true;
}
return false;
}
|
[
"public",
"function",
"listenToMethodNotFound",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"'getServiceContainer'",
"==",
"$",
"event",
"[",
"'method'",
"]",
")",
"{",
"$",
"event",
"->",
"setReturnValue",
"(",
"$",
"this",
"->",
"containerManager",
"->",
"getServiceContainer",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"'getContainerBuilder'",
"==",
"$",
"event",
"[",
"'method'",
"]",
")",
"{",
"$",
"event",
"->",
"setReturnValue",
"(",
"$",
"this",
"->",
"containerManager",
"->",
"getContainerBuilder",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"'getService'",
"==",
"$",
"event",
"[",
"'method'",
"]",
")",
"{",
"$",
"event",
"->",
"setReturnValue",
"(",
"$",
"this",
"->",
"containerManager",
"->",
"getServiceContainer",
"(",
")",
"->",
"get",
"(",
"$",
"event",
"[",
"'arguments'",
"]",
"[",
"0",
"]",
")",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Return the Container or a Service when calling a matching method
@param $event sfEvent
@return bool
|
[
"Return",
"the",
"Container",
"or",
"a",
"Service",
"when",
"calling",
"a",
"matching",
"method"
] |
d8aced7015011b5d18d297460ccd82f39df6f709
|
https://github.com/FlxPeters/sfDependencyInjectionPlugin/blob/d8aced7015011b5d18d297460ccd82f39df6f709/config/sfDependencyInjectionPluginConfiguration.class.php#L75-L93
|
225,499
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/BasicContext.php
|
BasicContext.closeModalDialog
|
public function closeModalDialog(ScenarioEvent $event) {
try{
// Only for failed tests on CMS page
if (4 === $event->getResult()) {
$cmsElement = $this->getSession()->getPage()->find('css', '.cms');
if($cmsElement) {
try {
// Navigate away triggered by reloading the page
$this->getSession()->reload();
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
} catch(\WebDriver\Exception $e) {
// no-op, alert might not be present
}
}
}
}catch(\WebDriver\Exception $e){
$this->logException($e);
}
}
|
php
|
public function closeModalDialog(ScenarioEvent $event) {
try{
// Only for failed tests on CMS page
if (4 === $event->getResult()) {
$cmsElement = $this->getSession()->getPage()->find('css', '.cms');
if($cmsElement) {
try {
// Navigate away triggered by reloading the page
$this->getSession()->reload();
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
} catch(\WebDriver\Exception $e) {
// no-op, alert might not be present
}
}
}
}catch(\WebDriver\Exception $e){
$this->logException($e);
}
}
|
[
"public",
"function",
"closeModalDialog",
"(",
"ScenarioEvent",
"$",
"event",
")",
"{",
"try",
"{",
"// Only for failed tests on CMS page",
"if",
"(",
"4",
"===",
"$",
"event",
"->",
"getResult",
"(",
")",
")",
"{",
"$",
"cmsElement",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"find",
"(",
"'css'",
",",
"'.cms'",
")",
";",
"if",
"(",
"$",
"cmsElement",
")",
"{",
"try",
"{",
"// Navigate away triggered by reloading the page",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"reload",
"(",
")",
";",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getDriver",
"(",
")",
"->",
"getWebDriverSession",
"(",
")",
"->",
"accept_alert",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"WebDriver",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// no-op, alert might not be present",
"}",
"}",
"}",
"}",
"catch",
"(",
"\\",
"WebDriver",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logException",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Close modal dialog if test scenario fails on CMS page
@AfterScenario
|
[
"Close",
"modal",
"dialog",
"if",
"test",
"scenario",
"fails",
"on",
"CMS",
"page"
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/BasicContext.php#L244-L262
|
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.