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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bishopb/vanilla | applications/dashboard/models/class.activitymodel.php | ActivityModel.NotificationPreference | public static function NotificationPreference($ActivityType, $Preferences, $Type = NULL) {
if (is_numeric($Preferences)) {
$User = Gdn::UserModel()->GetID($Preferences);
if (!$User)
return $Type == 'both' ? array(FALSE, FALSE) : FALSE;
$Preferences = GetValue('Preferences', $User);
}
if ($Type === NULL) {
$Result = self::NotificationPreference($ActivityType, $Preferences, 'Email')
|| self::NotificationPreference($ActivityType, $Preferences, 'Popup');
return $Result;
} elseif ($Type === 'both') {
$Result = array(
self::NotificationPreference($ActivityType, $Preferences, 'Popup'),
self::NotificationPreference($ActivityType, $Preferences, 'Email')
);
return $Result;
}
$ConfigPreference = C("Preferences.$Type.$ActivityType", '0');
if ((int)$ConfigPreference === 2)
$Preference = TRUE; // This preference is forced on.
if ($ConfigPreference !== FALSE)
$Preference = ArrayValue($Type.'.'.$ActivityType, $Preferences, $ConfigPreference);
else
$Preference = FALSE;
return $Preference;
} | php | public static function NotificationPreference($ActivityType, $Preferences, $Type = NULL) {
if (is_numeric($Preferences)) {
$User = Gdn::UserModel()->GetID($Preferences);
if (!$User)
return $Type == 'both' ? array(FALSE, FALSE) : FALSE;
$Preferences = GetValue('Preferences', $User);
}
if ($Type === NULL) {
$Result = self::NotificationPreference($ActivityType, $Preferences, 'Email')
|| self::NotificationPreference($ActivityType, $Preferences, 'Popup');
return $Result;
} elseif ($Type === 'both') {
$Result = array(
self::NotificationPreference($ActivityType, $Preferences, 'Popup'),
self::NotificationPreference($ActivityType, $Preferences, 'Email')
);
return $Result;
}
$ConfigPreference = C("Preferences.$Type.$ActivityType", '0');
if ((int)$ConfigPreference === 2)
$Preference = TRUE; // This preference is forced on.
if ($ConfigPreference !== FALSE)
$Preference = ArrayValue($Type.'.'.$ActivityType, $Preferences, $ConfigPreference);
else
$Preference = FALSE;
return $Preference;
} | [
"public",
"static",
"function",
"NotificationPreference",
"(",
"$",
"ActivityType",
",",
"$",
"Preferences",
",",
"$",
"Type",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"Preferences",
")",
")",
"{",
"$",
"User",
"=",
"Gdn",
"::",
"UserMod... | Get default notification preference for an activity type.
@since 2.0.0
@access public
@param string $ActivityType
@param array $Preferences
@param string $Type One of the following:
- Popup: Popup a notification.
- Email: Email the notification.
- NULL: True if either notification is true.
- both: Return an array of (Popup, Email).
@return bool | [
"Get",
"default",
"notification",
"preference",
"for",
"an",
"activity",
"type",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L659-L689 | train |
bishopb/vanilla | applications/dashboard/models/class.activitymodel.php | ActivityModel.SendNotification | public function SendNotification($ActivityID, $Story = '', $Force = FALSE) {
$Activity = $this->GetID($ActivityID);
if (!$Activity)
return;
$Activity = (object)$Activity;
$Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
// If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
$CommentActivity = $this->GetID($Activity->CommentActivityID);
$Activity->RegardingUserID = $CommentActivity->RegardingUserID;
$Activity->Route = '/activity/item/'.$Activity->CommentActivityID;
}
$User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT);
if ($User) {
if ($Force)
$Preference = $Force;
else {
$Preferences = $User->Preferences;
$Preference = ArrayValue('Email.'.$Activity->ActivityType, $Preferences, Gdn::Config('Preferences.Email.'.$Activity->ActivityType));
}
if ($Preference) {
$ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
$Email = new Gdn_Email();
$Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
$Email->To($User);
//$Email->From(Gdn::Config('Garden.SupportEmail'), Gdn::Config('Garden.SupportName'));
$Message = sprintf(
$Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"),
$ActivityHeadline,
ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route),
$Story
);
$Email->Message($Message);
$Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
$this->EventArguments = $Notification;
$this->FireEvent('BeforeSendNotification');
try {
// Only send if the user is not banned
if (!GetValue('Banned', $User))
$Email->Send();
$Emailed = self::SENT_OK;
} catch (phpmailerException $pex) {
if ($pex->getCode() == PHPMailer::STOP_CRITICAL)
$Emailed = self::SENT_FAIL;
else
$Emailed = self::SENT_ERROR;
} catch (Exception $ex) {
$Emailed = self::SENT_FAIL; // similar to http 5xx
}
try {
$this->SQL->Put('Activity', array('Emailed' => $Emailed), array('ActivityID' => $ActivityID));
} catch (Exception $Ex) {
}
}
}
} | php | public function SendNotification($ActivityID, $Story = '', $Force = FALSE) {
$Activity = $this->GetID($ActivityID);
if (!$Activity)
return;
$Activity = (object)$Activity;
$Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
// If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
$CommentActivity = $this->GetID($Activity->CommentActivityID);
$Activity->RegardingUserID = $CommentActivity->RegardingUserID;
$Activity->Route = '/activity/item/'.$Activity->CommentActivityID;
}
$User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT);
if ($User) {
if ($Force)
$Preference = $Force;
else {
$Preferences = $User->Preferences;
$Preference = ArrayValue('Email.'.$Activity->ActivityType, $Preferences, Gdn::Config('Preferences.Email.'.$Activity->ActivityType));
}
if ($Preference) {
$ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
$Email = new Gdn_Email();
$Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
$Email->To($User);
//$Email->From(Gdn::Config('Garden.SupportEmail'), Gdn::Config('Garden.SupportName'));
$Message = sprintf(
$Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"),
$ActivityHeadline,
ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route),
$Story
);
$Email->Message($Message);
$Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
$this->EventArguments = $Notification;
$this->FireEvent('BeforeSendNotification');
try {
// Only send if the user is not banned
if (!GetValue('Banned', $User))
$Email->Send();
$Emailed = self::SENT_OK;
} catch (phpmailerException $pex) {
if ($pex->getCode() == PHPMailer::STOP_CRITICAL)
$Emailed = self::SENT_FAIL;
else
$Emailed = self::SENT_ERROR;
} catch (Exception $ex) {
$Emailed = self::SENT_FAIL; // similar to http 5xx
}
try {
$this->SQL->Put('Activity', array('Emailed' => $Emailed), array('ActivityID' => $ActivityID));
} catch (Exception $Ex) {
}
}
}
} | [
"public",
"function",
"SendNotification",
"(",
"$",
"ActivityID",
",",
"$",
"Story",
"=",
"''",
",",
"$",
"Force",
"=",
"FALSE",
")",
"{",
"$",
"Activity",
"=",
"$",
"this",
"->",
"GetID",
"(",
"$",
"ActivityID",
")",
";",
"if",
"(",
"!",
"$",
"Act... | Send notification.
@since 2.0.17
@access public
@param int $ActivityID
@param array $Story
@param string $Force | [
"Send",
"notification",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L700-L762 | train |
bishopb/vanilla | applications/dashboard/models/class.activitymodel.php | ActivityModel.Comment | public function Comment($Comment) {
$Comment['InsertUserID'] = Gdn::Session()->UserID;
$Comment['DateInserted'] = Gdn_Format::ToDateTime();
$Comment['InsertIPAddress'] = Gdn::Request()->IpAddress();
$this->Validation->ApplyRule('ActivityID', 'Required');
$this->Validation->ApplyRule('Body', 'Required');
$this->Validation->ApplyRule('DateInserted', 'Required');
$this->Validation->ApplyRule('InsertUserID', 'Required');
$this->EventArguments['Comment'] = $Comment;
$this->FireEvent('BeforeSaveComment');
if ($this->Validate($Comment)) {
$Activity = $this->GetID($Comment['ActivityID'], DATASET_TYPE_ARRAY);
Gdn::Controller()->Json('Activity', $CommentActivityID);
$_ActivityID = $Comment['ActivityID'];
// Check to see if this is a shared activity/notification.
if ($CommentActivityID = GetValue('CommentActivityID', $Activity['Data'])) {
Gdn::Controller()->Json('CommentActivityID', $CommentActivityID);
$Comment['ActivityID'] = $CommentActivityID;
}
// Check for spam.
$Spam = SpamModel::IsSpam('ActivityComment', $Comment);
if ($Spam)
return SPAM;
// Check for approval
$ApprovalRequired = CheckRestriction('Vanilla.Approval.Require');
if ($ApprovalRequired && !GetValue('Verified', Gdn::Session()->User)) {
LogModel::Insert('Pending', 'ActivityComment', $Comment);
return UNAPPROVED;
}
$ID = $this->SQL->Insert('ActivityComment', $Comment);
if ($ID) {
// Check to see if this comment bumps the activity.
if ($Activity && GetValue('Bump', $Activity['Data'])) {
$this->SQL->Put('Activity', array('DateUpdated' => $Comment['DateInserted']), array('ActivityID' => $Activity['ActivityID']));
if ($_ActivityID != $Comment['ActivityID']) {
$this->SQL->Put('Activity', array('DateUpdated' => $Comment['DateInserted']), array('ActivityID' => $_ActivityID));
}
}
}
return $ID;
}
return FALSE;
} | php | public function Comment($Comment) {
$Comment['InsertUserID'] = Gdn::Session()->UserID;
$Comment['DateInserted'] = Gdn_Format::ToDateTime();
$Comment['InsertIPAddress'] = Gdn::Request()->IpAddress();
$this->Validation->ApplyRule('ActivityID', 'Required');
$this->Validation->ApplyRule('Body', 'Required');
$this->Validation->ApplyRule('DateInserted', 'Required');
$this->Validation->ApplyRule('InsertUserID', 'Required');
$this->EventArguments['Comment'] = $Comment;
$this->FireEvent('BeforeSaveComment');
if ($this->Validate($Comment)) {
$Activity = $this->GetID($Comment['ActivityID'], DATASET_TYPE_ARRAY);
Gdn::Controller()->Json('Activity', $CommentActivityID);
$_ActivityID = $Comment['ActivityID'];
// Check to see if this is a shared activity/notification.
if ($CommentActivityID = GetValue('CommentActivityID', $Activity['Data'])) {
Gdn::Controller()->Json('CommentActivityID', $CommentActivityID);
$Comment['ActivityID'] = $CommentActivityID;
}
// Check for spam.
$Spam = SpamModel::IsSpam('ActivityComment', $Comment);
if ($Spam)
return SPAM;
// Check for approval
$ApprovalRequired = CheckRestriction('Vanilla.Approval.Require');
if ($ApprovalRequired && !GetValue('Verified', Gdn::Session()->User)) {
LogModel::Insert('Pending', 'ActivityComment', $Comment);
return UNAPPROVED;
}
$ID = $this->SQL->Insert('ActivityComment', $Comment);
if ($ID) {
// Check to see if this comment bumps the activity.
if ($Activity && GetValue('Bump', $Activity['Data'])) {
$this->SQL->Put('Activity', array('DateUpdated' => $Comment['DateInserted']), array('ActivityID' => $Activity['ActivityID']));
if ($_ActivityID != $Comment['ActivityID']) {
$this->SQL->Put('Activity', array('DateUpdated' => $Comment['DateInserted']), array('ActivityID' => $_ActivityID));
}
}
}
return $ID;
}
return FALSE;
} | [
"public",
"function",
"Comment",
"(",
"$",
"Comment",
")",
"{",
"$",
"Comment",
"[",
"'InsertUserID'",
"]",
"=",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"UserID",
";",
"$",
"Comment",
"[",
"'DateInserted'",
"]",
"=",
"Gdn_Format",
"::",
"ToDateTime",
"("... | Save a comment on an activity.
@param array $Comment
@return int|bool
@since 2.1 | [
"Save",
"a",
"comment",
"on",
"an",
"activity",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L886-L937 | train |
bishopb/vanilla | applications/dashboard/models/class.activitymodel.php | ActivityModel.SendNotificationQueue | public function SendNotificationQueue() {
foreach ($this->_NotificationQueue as $UserID => $Notifications) {
if (is_array($Notifications)) {
// Only send out one notification per user.
$Notification = $Notifications[0];
$Email = $Notification['Email'];
if (is_object($Email)) {
$this->EventArguments = $Notification;
$this->FireEvent('BeforeSendNotification');
try {
// Only send if the user is not banned
$User = Gdn::UserModel()->GetID($UserID);
if (!GetValue('Banned', $User))
$Email->Send();
$Emailed = self::SENT_OK;
} catch (phpmailerException $pex) {
if ($pex->getCode() == PHPMailer::STOP_CRITICAL)
$Emailed = self::SENT_FAIL;
else
$Emailed = self::SENT_ERROR;
} catch(Exception $Ex) {
$Emailed = self::SENT_FAIL;
}
try {
$this->SQL->Put('Activity', array('Emailed' => $Emailed), array('ActivityID' => $Notification['ActivityID']));
} catch (Exception $Ex) {
}
}
}
}
// Clear out the queue
unset($this->_NotificationQueue);
$this->_NotificationQueue = array();
} | php | public function SendNotificationQueue() {
foreach ($this->_NotificationQueue as $UserID => $Notifications) {
if (is_array($Notifications)) {
// Only send out one notification per user.
$Notification = $Notifications[0];
$Email = $Notification['Email'];
if (is_object($Email)) {
$this->EventArguments = $Notification;
$this->FireEvent('BeforeSendNotification');
try {
// Only send if the user is not banned
$User = Gdn::UserModel()->GetID($UserID);
if (!GetValue('Banned', $User))
$Email->Send();
$Emailed = self::SENT_OK;
} catch (phpmailerException $pex) {
if ($pex->getCode() == PHPMailer::STOP_CRITICAL)
$Emailed = self::SENT_FAIL;
else
$Emailed = self::SENT_ERROR;
} catch(Exception $Ex) {
$Emailed = self::SENT_FAIL;
}
try {
$this->SQL->Put('Activity', array('Emailed' => $Emailed), array('ActivityID' => $Notification['ActivityID']));
} catch (Exception $Ex) {
}
}
}
}
// Clear out the queue
unset($this->_NotificationQueue);
$this->_NotificationQueue = array();
} | [
"public",
"function",
"SendNotificationQueue",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_NotificationQueue",
"as",
"$",
"UserID",
"=>",
"$",
"Notifications",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"Notifications",
")",
")",
"{",
"// Only send o... | Send all notifications in the queue.
@since 2.0.17
@access public | [
"Send",
"all",
"notifications",
"in",
"the",
"queue",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L945-L984 | train |
bishopb/vanilla | applications/dashboard/models/class.activitymodel.php | ActivityModel.QueueNotification | public function QueueNotification($ActivityID, $Story = '', $Position = 'last', $Force = FALSE) {
$Activity = $this->GetID($ActivityID);
if (!is_object($Activity))
return;
$Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
// If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
$CommentActivity = $this->GetID($Activity->CommentActivityID);
$Activity->RegardingUserID = $CommentActivity->RegardingUserID;
$Activity->Route = '/activity/item/'.$Activity->CommentActivityID;
}
$User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT); //$this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
if ($User) {
if ($Force)
$Preference = $Force;
else {
// $Preferences = Gdn_Format::Unserialize($User->Preferences);
$ConfigPreference = C('Preferences.Email.'.$Activity->ActivityType, '0');
if ($ConfigPreference !== FALSE)
$Preference = GetValue('Email.'.$Activity->ActivityType, $User->Preferences, $ConfigPreference);
else
$Preference = FALSE;
}
if ($Preference) {
$ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
$Email = new Gdn_Email();
$Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
$Email->To($User);
$Message = sprintf(
$Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"),
$ActivityHeadline,
ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route),
$Story
);
$Email->Message($Message);
if (!array_key_exists($User->UserID, $this->_NotificationQueue))
$this->_NotificationQueue[$User->UserID] = array();
$Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
if ($Position == 'first')
$this->_NotificationQueue[$User->UserID] = array_merge(array($Notification), $this->_NotificationQueue[$User->UserID]);
else
$this->_NotificationQueue[$User->UserID][] = $Notification;
}
}
} | php | public function QueueNotification($ActivityID, $Story = '', $Position = 'last', $Force = FALSE) {
$Activity = $this->GetID($ActivityID);
if (!is_object($Activity))
return;
$Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
// If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
$CommentActivity = $this->GetID($Activity->CommentActivityID);
$Activity->RegardingUserID = $CommentActivity->RegardingUserID;
$Activity->Route = '/activity/item/'.$Activity->CommentActivityID;
}
$User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT); //$this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
if ($User) {
if ($Force)
$Preference = $Force;
else {
// $Preferences = Gdn_Format::Unserialize($User->Preferences);
$ConfigPreference = C('Preferences.Email.'.$Activity->ActivityType, '0');
if ($ConfigPreference !== FALSE)
$Preference = GetValue('Email.'.$Activity->ActivityType, $User->Preferences, $ConfigPreference);
else
$Preference = FALSE;
}
if ($Preference) {
$ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
$Email = new Gdn_Email();
$Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
$Email->To($User);
$Message = sprintf(
$Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"),
$ActivityHeadline,
ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route),
$Story
);
$Email->Message($Message);
if (!array_key_exists($User->UserID, $this->_NotificationQueue))
$this->_NotificationQueue[$User->UserID] = array();
$Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
if ($Position == 'first')
$this->_NotificationQueue[$User->UserID] = array_merge(array($Notification), $this->_NotificationQueue[$User->UserID]);
else
$this->_NotificationQueue[$User->UserID][] = $Notification;
}
}
} | [
"public",
"function",
"QueueNotification",
"(",
"$",
"ActivityID",
",",
"$",
"Story",
"=",
"''",
",",
"$",
"Position",
"=",
"'last'",
",",
"$",
"Force",
"=",
"FALSE",
")",
"{",
"$",
"Activity",
"=",
"$",
"this",
"->",
"GetID",
"(",
"$",
"ActivityID",
... | Queue a notification for sending.
@since 2.0.17
@access public
@param int $ActivityID
@param string $Story
@param string $Position
@param bool $Force | [
"Queue",
"a",
"notification",
"for",
"sending",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L1014-L1062 | train |
bishopb/vanilla | applications/dashboard/models/class.activitymodel.php | ActivityModel.Queue | public function Queue($Data, $Preference = FALSE, $Options = array()) {
$this->_Touch($Data);
if (!isset($Data['NotifyUserID']) || !isset($Data['ActivityType']))
throw new Exception('Data missing NotifyUserID and/or ActivityType', 400);
if ($Data['ActivityUserID'] == $Data['NotifyUserID'] && !GetValue('Force', $Options))
return; // don't notify users of something they did.
$Notified = $Data['Notified'];
$Emailed = $Data['Emailed'];
if (isset(self::$Queue[$Data['NotifyUserID']][$Data['ActivityType']])) {
list($CurrentData, $CurrentOptions) = self::$Queue[$Data['NotifyUserID']][$Data['ActivityType']];
$Notified = $Notified ? $Notified : $CurrentData['Notified'];
$Emailed = $Emailed ? $Emailed : $CurrentData['Emailed'];
$Data = array_merge($CurrentData, $Data);
$Options = array_merge($CurrentOptions, $Options);
}
if ($Preference) {
list($Popup, $Email) = self::NotificationPreference($Preference, $Data['NotifyUserID'], 'both');
if (!$Popup && !$Email)
return; // don't queue if user doesn't want to be notified at all.
if ($Popup)
$Notified = self::SENT_PENDING;
if ($Email)
$Emailed = self::SENT_PENDING;
}
$Data['Notified'] = $Notified;
$Data['Emailed'] = $Emailed;
self::$Queue[$Data['NotifyUserID']][$Data['ActivityType']] = array($Data, $Options);
} | php | public function Queue($Data, $Preference = FALSE, $Options = array()) {
$this->_Touch($Data);
if (!isset($Data['NotifyUserID']) || !isset($Data['ActivityType']))
throw new Exception('Data missing NotifyUserID and/or ActivityType', 400);
if ($Data['ActivityUserID'] == $Data['NotifyUserID'] && !GetValue('Force', $Options))
return; // don't notify users of something they did.
$Notified = $Data['Notified'];
$Emailed = $Data['Emailed'];
if (isset(self::$Queue[$Data['NotifyUserID']][$Data['ActivityType']])) {
list($CurrentData, $CurrentOptions) = self::$Queue[$Data['NotifyUserID']][$Data['ActivityType']];
$Notified = $Notified ? $Notified : $CurrentData['Notified'];
$Emailed = $Emailed ? $Emailed : $CurrentData['Emailed'];
$Data = array_merge($CurrentData, $Data);
$Options = array_merge($CurrentOptions, $Options);
}
if ($Preference) {
list($Popup, $Email) = self::NotificationPreference($Preference, $Data['NotifyUserID'], 'both');
if (!$Popup && !$Email)
return; // don't queue if user doesn't want to be notified at all.
if ($Popup)
$Notified = self::SENT_PENDING;
if ($Email)
$Emailed = self::SENT_PENDING;
}
$Data['Notified'] = $Notified;
$Data['Emailed'] = $Emailed;
self::$Queue[$Data['NotifyUserID']][$Data['ActivityType']] = array($Data, $Options);
} | [
"public",
"function",
"Queue",
"(",
"$",
"Data",
",",
"$",
"Preference",
"=",
"FALSE",
",",
"$",
"Options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_Touch",
"(",
"$",
"Data",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"Data",
"[... | Queue an activity for saving later.
@param array $Data The data in the activity.
@param string|FALSE $Preference The name of the preference governing the activity.
@param array $Options Additional options for saving.
@return type | [
"Queue",
"an",
"activity",
"for",
"saving",
"later",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L1071-L1105 | train |
CakeCMS/Community | src/Model/Entity/User.php | User.getEditUrl | public function getEditUrl($backend = false)
{
$url = [
'action' => 'edit',
'controller' => 'Users',
'plugin' => 'Community'
];
if ($backend) {
$url['prefix'] = 'admin';
$url[] = $this->id;
}
return Router::url($url);
} | php | public function getEditUrl($backend = false)
{
$url = [
'action' => 'edit',
'controller' => 'Users',
'plugin' => 'Community'
];
if ($backend) {
$url['prefix'] = 'admin';
$url[] = $this->id;
}
return Router::url($url);
} | [
"public",
"function",
"getEditUrl",
"(",
"$",
"backend",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"[",
"'action'",
"=>",
"'edit'",
",",
"'controller'",
"=>",
"'Users'",
",",
"'plugin'",
"=>",
"'Community'",
"]",
";",
"if",
"(",
"$",
"backend",
")",
"{"... | Get current user edit profile url.
@param bool $backend Backend or frontend point.
@return string | [
"Get",
"current",
"user",
"edit",
"profile",
"url",
"."
] | cc2bdb596dd9617d42fd81f59e981024caa062e8 | https://github.com/CakeCMS/Community/blob/cc2bdb596dd9617d42fd81f59e981024caa062e8/src/Model/Entity/User.php#L65-L79 | train |
open-orchestra/open-orchestra-media-admin-bundle | MediaAdminBundle/Manager/SaveMediaManager.php | SaveMediaManager.getFileFromChunks | public function getFileFromChunks(UploadedFile $uploadedFile)
{
$filename = time() . '-' . $uploadedFile->getClientOriginalName();
$path = $this->tmpDir . DIRECTORY_SEPARATOR . $filename;
if (FlowBasic::save($path, $this->tmpDir)) {
return new UploadedFile($path, $uploadedFile->getClientOriginalName(), $uploadedFile->getClientMimeType());
}
return null;
} | php | public function getFileFromChunks(UploadedFile $uploadedFile)
{
$filename = time() . '-' . $uploadedFile->getClientOriginalName();
$path = $this->tmpDir . DIRECTORY_SEPARATOR . $filename;
if (FlowBasic::save($path, $this->tmpDir)) {
return new UploadedFile($path, $uploadedFile->getClientOriginalName(), $uploadedFile->getClientMimeType());
}
return null;
} | [
"public",
"function",
"getFileFromChunks",
"(",
"UploadedFile",
"$",
"uploadedFile",
")",
"{",
"$",
"filename",
"=",
"time",
"(",
")",
".",
"'-'",
".",
"$",
"uploadedFile",
"->",
"getClientOriginalName",
"(",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
... | Check if all chunks of a file being uploaded have been received
If yes, return the name of the reassembled temporary file
@param UploadedFile $uploadedFile
@return UploadedFile|null | [
"Check",
"if",
"all",
"chunks",
"of",
"a",
"file",
"being",
"uploaded",
"have",
"been",
"received",
"If",
"yes",
"return",
"the",
"name",
"of",
"the",
"reassembled",
"temporary",
"file"
] | 743fa00a6491b84d67221e215a806d8b210bf773 | https://github.com/open-orchestra/open-orchestra-media-admin-bundle/blob/743fa00a6491b84d67221e215a806d8b210bf773/MediaAdminBundle/Manager/SaveMediaManager.php#L67-L77 | train |
open-orchestra/open-orchestra-media-admin-bundle | MediaAdminBundle/Manager/SaveMediaManager.php | SaveMediaManager.initializeMediaFromUploadedFile | public function initializeMediaFromUploadedFile(UploadedFile $uploadedFile, $folderId, $siteId, $title = null)
{
/** @var MediaInterface $media */
$media = new $this->mediaClass();
$media->setSiteId($siteId);
$media->setFile($uploadedFile);
$media->setFilesystemName($uploadedFile->getFilename());
$media->setMediaFolder($this->folderRepository->find($folderId));
$media->setName($uploadedFile->getClientOriginalName());
$media->setMimeType($uploadedFile->getMimeType());
if (null === $title) {
$title = $uploadedFile->getFilename();
}
foreach ($this->frontLanguages as $language) {
$media->addTitle($language, $title);
}
return $media;
} | php | public function initializeMediaFromUploadedFile(UploadedFile $uploadedFile, $folderId, $siteId, $title = null)
{
/** @var MediaInterface $media */
$media = new $this->mediaClass();
$media->setSiteId($siteId);
$media->setFile($uploadedFile);
$media->setFilesystemName($uploadedFile->getFilename());
$media->setMediaFolder($this->folderRepository->find($folderId));
$media->setName($uploadedFile->getClientOriginalName());
$media->setMimeType($uploadedFile->getMimeType());
if (null === $title) {
$title = $uploadedFile->getFilename();
}
foreach ($this->frontLanguages as $language) {
$media->addTitle($language, $title);
}
return $media;
} | [
"public",
"function",
"initializeMediaFromUploadedFile",
"(",
"UploadedFile",
"$",
"uploadedFile",
",",
"$",
"folderId",
",",
"$",
"siteId",
",",
"$",
"title",
"=",
"null",
")",
"{",
"/** @var MediaInterface $media */",
"$",
"media",
"=",
"new",
"$",
"this",
"->... | initialize a media to fit an uploaded file
@param UploadedFile $uploadedFile
@param string $folderId
@param string $siteId
@param string|null $title
@return MediaInterface | [
"initialize",
"a",
"media",
"to",
"fit",
"an",
"uploaded",
"file"
] | 743fa00a6491b84d67221e215a806d8b210bf773 | https://github.com/open-orchestra/open-orchestra-media-admin-bundle/blob/743fa00a6491b84d67221e215a806d8b210bf773/MediaAdminBundle/Manager/SaveMediaManager.php#L89-L107 | train |
open-orchestra/open-orchestra-media-admin-bundle | MediaAdminBundle/Manager/SaveMediaManager.php | SaveMediaManager.saveMedia | public function saveMedia($media)
{
$file = $media->getFile();
$this->mediaStorageManager->uploadFile($file->getFilename(), $file->getRealPath(), false);
$this->objectManager->persist($media);
$this->objectManager->flush();
$event = new MediaEvent($media);
$this->dispatcher->dispatch(MediaEvents::MEDIA_ADD, $event);
} | php | public function saveMedia($media)
{
$file = $media->getFile();
$this->mediaStorageManager->uploadFile($file->getFilename(), $file->getRealPath(), false);
$this->objectManager->persist($media);
$this->objectManager->flush();
$event = new MediaEvent($media);
$this->dispatcher->dispatch(MediaEvents::MEDIA_ADD, $event);
} | [
"public",
"function",
"saveMedia",
"(",
"$",
"media",
")",
"{",
"$",
"file",
"=",
"$",
"media",
"->",
"getFile",
"(",
")",
";",
"$",
"this",
"->",
"mediaStorageManager",
"->",
"uploadFile",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
",",
"$",
"... | Save a media in database
@param MediaInterface $media | [
"Save",
"a",
"media",
"in",
"database"
] | 743fa00a6491b84d67221e215a806d8b210bf773 | https://github.com/open-orchestra/open-orchestra-media-admin-bundle/blob/743fa00a6491b84d67221e215a806d8b210bf773/MediaAdminBundle/Manager/SaveMediaManager.php#L114-L124 | train |
Puzzlout/FrameworkMvcLegacy | src/ViewModels/ErrorVm.php | ErrorVm.FillInstance | protected function FillInstance($errorId, $errorMessage, $exception) {
$this->errorId = $errorId;
$this->errorMessage = $errorMessage;
$this->exceptionObj = $exception;
} | php | protected function FillInstance($errorId, $errorMessage, $exception) {
$this->errorId = $errorId;
$this->errorMessage = $errorMessage;
$this->exceptionObj = $exception;
} | [
"protected",
"function",
"FillInstance",
"(",
"$",
"errorId",
",",
"$",
"errorMessage",
",",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"errorId",
"=",
"$",
"errorId",
";",
"$",
"this",
"->",
"errorMessage",
"=",
"$",
"errorMessage",
";",
"$",
"this"... | Sets the properties of the object
@param int $errorId
@param string $errorMessage
@param \Exception $exception | [
"Sets",
"the",
"properties",
"of",
"the",
"object"
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/ViewModels/ErrorVm.php#L69-L73 | train |
stefanotorresi/thorr-persistence | src/Entity/SluggableTrait.php | SluggableTrait.setSlug | public function setSlug($slug)
{
if ($slug !== null) {
$slug = (string) $slug;
}
$this->slug = $slug;
} | php | public function setSlug($slug)
{
if ($slug !== null) {
$slug = (string) $slug;
}
$this->slug = $slug;
} | [
"public",
"function",
"setSlug",
"(",
"$",
"slug",
")",
"{",
"if",
"(",
"$",
"slug",
"!==",
"null",
")",
"{",
"$",
"slug",
"=",
"(",
"string",
")",
"$",
"slug",
";",
"}",
"$",
"this",
"->",
"slug",
"=",
"$",
"slug",
";",
"}"
] | Setting to null should regenerate the slug
@param string|null $slug | [
"Setting",
"to",
"null",
"should",
"regenerate",
"the",
"slug"
] | c29e204e6a7b0db0cc11992c0ee2dc82b67e2fec | https://github.com/stefanotorresi/thorr-persistence/blob/c29e204e6a7b0db0cc11992c0ee2dc82b67e2fec/src/Entity/SluggableTrait.php#L30-L37 | train |
Archi-Strasbourg/archi-wiki | modules/archi/includes/archiAccueil.class.php | ArchiAccueil.getDernieresActualites | public function getDernieresActualites($params = array())
{
$sqlLimit = "";
if (isset($params['sqlLimit']) && $params['sqlLimit']!='') {
$sqlLimit = $params['sqlLimit'];
}
$sqlFields = "idActualite, titre, date, ".
"photoIllustration, texte, urlFichier";
if (isset($params['sqlFields']) && $params['sqlFields']!='') {
$sqlFields = $params['sqlFields'];
}
$sqlWhere = "";
if (isset($params['sqlWhere']) && $params['sqlWhere']!='') {
$sqlWhere = $params['sqlWhere'];
}
$req = "SELECT $sqlFields FROM actualites ".
"WHERE 1=1 $sqlWhere ORDER BY date DESC $sqlLimit";
$res = $this->connexionBdd->requete($req);
$i=0;
if (!isset($params['returnAsMysqlRes'])
|| $params['returnAsMysqlRes']!=true
) {
$retour = array();
while ($fetch = mysql_fetch_assoc($res)) {
$retour[$i] = $fetch;
$i++;
}
} else {
$retour = $res;
}
return $retour;
} | php | public function getDernieresActualites($params = array())
{
$sqlLimit = "";
if (isset($params['sqlLimit']) && $params['sqlLimit']!='') {
$sqlLimit = $params['sqlLimit'];
}
$sqlFields = "idActualite, titre, date, ".
"photoIllustration, texte, urlFichier";
if (isset($params['sqlFields']) && $params['sqlFields']!='') {
$sqlFields = $params['sqlFields'];
}
$sqlWhere = "";
if (isset($params['sqlWhere']) && $params['sqlWhere']!='') {
$sqlWhere = $params['sqlWhere'];
}
$req = "SELECT $sqlFields FROM actualites ".
"WHERE 1=1 $sqlWhere ORDER BY date DESC $sqlLimit";
$res = $this->connexionBdd->requete($req);
$i=0;
if (!isset($params['returnAsMysqlRes'])
|| $params['returnAsMysqlRes']!=true
) {
$retour = array();
while ($fetch = mysql_fetch_assoc($res)) {
$retour[$i] = $fetch;
$i++;
}
} else {
$retour = $res;
}
return $retour;
} | [
"public",
"function",
"getDernieresActualites",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"sqlLimit",
"=",
"\"\"",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'sqlLimit'",
"]",
")",
"&&",
"$",
"params",
"[",
"'sqlLimit'",
"]",
... | Renvoi les dernieres actualites pour la page d'accueil
sous forme de resultat mysql ou de tableau
@param array $params Paramètres
@return Resource | [
"Renvoi",
"les",
"dernieres",
"actualites",
"pour",
"la",
"page",
"d",
"accueil",
"sous",
"forme",
"de",
"resultat",
"mysql",
"ou",
"de",
"tableau"
] | b9fb39f43a78409890a7de96426c1f6c49d5c323 | https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAccueil.class.php#L1923-L1960 | train |
mainio/c5pkg_controller_extensions | src/Mainio/C5/ControllerExtensions/Controller/Extension/DoctrineEntitiesExtension.php | DoctrineEntitiesExtension.getEntityManager | public function getEntityManager()
{
if (isset($this->entityManager) && is_object($this->entityManager)) {
// 5.8 ->
return $this->entityManager;
}
$pkgID = $this->c->getPackageID();
if ($pkgID > 0) {
return Package::getByID($pkgID)->getEntityManager();
} else {
return ORM::entityManager('app');
}
} | php | public function getEntityManager()
{
if (isset($this->entityManager) && is_object($this->entityManager)) {
// 5.8 ->
return $this->entityManager;
}
$pkgID = $this->c->getPackageID();
if ($pkgID > 0) {
return Package::getByID($pkgID)->getEntityManager();
} else {
return ORM::entityManager('app');
}
} | [
"public",
"function",
"getEntityManager",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityManager",
")",
"&&",
"is_object",
"(",
"$",
"this",
"->",
"entityManager",
")",
")",
"{",
"// 5.8 ->",
"return",
"$",
"this",
"->",
"entityManager",... | Gets the controller specific entity manager. If the controller belongs
to a package, returns the package's entity manager. Otherwise returns
the application specific entity manager. | [
"Gets",
"the",
"controller",
"specific",
"entity",
"manager",
".",
"If",
"the",
"controller",
"belongs",
"to",
"a",
"package",
"returns",
"the",
"package",
"s",
"entity",
"manager",
".",
"Otherwise",
"returns",
"the",
"application",
"specific",
"entity",
"manage... | b3775bb6a79dcc91ce8b71be4bf5c9dd5fa66446 | https://github.com/mainio/c5pkg_controller_extensions/blob/b3775bb6a79dcc91ce8b71be4bf5c9dd5fa66446/src/Mainio/C5/ControllerExtensions/Controller/Extension/DoctrineEntitiesExtension.php#L20-L32 | train |
leedave/html | src/Html5.php | Html5.br | public static function br(int $amount = 1) : string
{
$output = "";
for ($i = 0; $i < $amount; $i++) {
$output .= self::tag("br");
}
return $output;
} | php | public static function br(int $amount = 1) : string
{
$output = "";
for ($i = 0; $i < $amount; $i++) {
$output .= self::tag("br");
}
return $output;
} | [
"public",
"static",
"function",
"br",
"(",
"int",
"$",
"amount",
"=",
"1",
")",
":",
"string",
"{",
"$",
"output",
"=",
"\"\"",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"amount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"out... | Create a BR Tag
@param int $amount Number of how many BR Tags
@return string HTML Code | [
"Create",
"a",
"BR",
"Tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L190-L197 | train |
leedave/html | src/Html5.php | Html5.button | public static function button(
string $label,
string $type = "submit",
string $onclick = null,
array $attributes = []
) : string
{
$buttonPreAttributes = [
"type" => $type,
];
if ($onclick) {
$buttonPreAttributes["onclick"] = $onclick;
}
$buttonAttributes = array_merge($buttonPreAttributes, $attributes);
return self::tag("button", $label, $buttonAttributes);
} | php | public static function button(
string $label,
string $type = "submit",
string $onclick = null,
array $attributes = []
) : string
{
$buttonPreAttributes = [
"type" => $type,
];
if ($onclick) {
$buttonPreAttributes["onclick"] = $onclick;
}
$buttonAttributes = array_merge($buttonPreAttributes, $attributes);
return self::tag("button", $label, $buttonAttributes);
} | [
"public",
"static",
"function",
"button",
"(",
"string",
"$",
"label",
",",
"string",
"$",
"type",
"=",
"\"submit\"",
",",
"string",
"$",
"onclick",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"buttonPreAt... | Create a Button Tag
@param string $label Button Content
@param string $type type attribute
@param string $onclick onclick attribute
@param array $attributes further attributes
@return string HTML Code | [
"Create",
"a",
"Button",
"Tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L207-L224 | train |
leedave/html | src/Html5.php | Html5.input | public static function input(
string $name,
string $type = "text",
string $value = null,
array $attributes = []
) : string
{
$preAttributesInput = [
"name" => $name,
"type" => $type,
];
if (!is_null($value)) {
$preAttributesInput["value"] = $value;
}
$attributesInput = array_merge($preAttributesInput, $attributes);
return self::tag("input", "", $attributesInput);
} | php | public static function input(
string $name,
string $type = "text",
string $value = null,
array $attributes = []
) : string
{
$preAttributesInput = [
"name" => $name,
"type" => $type,
];
if (!is_null($value)) {
$preAttributesInput["value"] = $value;
}
$attributesInput = array_merge($preAttributesInput, $attributes);
return self::tag("input", "", $attributesInput);
} | [
"public",
"static",
"function",
"input",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"type",
"=",
"\"text\"",
",",
"string",
"$",
"value",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"preAttributesInpu... | Create an input tag
@param string $name name attribute (always needed)
@param string $type type attribute (always needed)
@param string $value pre set value
@param array $attributes further attributes
@return string HTML Code | [
"Create",
"an",
"input",
"tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L770-L786 | train |
leedave/html | src/Html5.php | Html5.label | public static function label(
string $label,
string $for,
array $attributes = []
) : string
{
$preAttributesLabel = [
"for" => $for,
];
$attributesLabel = array_merge($preAttributesLabel, $attributes);
return self::tag("label", $label, $attributesLabel);
} | php | public static function label(
string $label,
string $for,
array $attributes = []
) : string
{
$preAttributesLabel = [
"for" => $for,
];
$attributesLabel = array_merge($preAttributesLabel, $attributes);
return self::tag("label", $label, $attributesLabel);
} | [
"public",
"static",
"function",
"label",
"(",
"string",
"$",
"label",
",",
"string",
"$",
"for",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"preAttributesLabel",
"=",
"[",
"\"for\"",
"=>",
"$",
"for",
",",
"]",
";",... | Creates label Tag
@param string $label content of tag
@param string $for for attribute (always needed)
@param array $attributes further attributes
@return string HTML Code | [
"Creates",
"label",
"Tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L824-L835 | train |
leedave/html | src/Html5.php | Html5.span | public static function span(
string $content = null,
array $attributes = []
) : string
{
return self::tag("span", $content, $attributes);
} | php | public static function span(
string $content = null,
array $attributes = []
) : string
{
return self::tag("span", $content, $attributes);
} | [
"public",
"static",
"function",
"span",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"span\"",
",",
"$",
"content",
",",
"$",
"attributes",
... | Create span tag
@param string $content content
@param array $attributes further attributes
@return HTML Code | [
"Create",
"span",
"tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1283-L1289 | train |
leedave/html | src/Html5.php | Html5.table | public static function table(
string $content = null,
array $attributes = []
) : string
{
return self::tag("table", $content, $attributes);
} | php | public static function table(
string $content = null,
array $attributes = []
) : string
{
return self::tag("table", $content, $attributes);
} | [
"public",
"static",
"function",
"table",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"table\"",
",",
"$",
"content",
",",
"$",
"attributes",
... | Create table tag
@param string $content content
@param array $attributes attributes
@return string HTML Code | [
"Create",
"table",
"tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1368-L1374 | train |
leedave/html | src/Html5.php | Html5.tbody | public static function tbody(
string $content = null,
array $attributes = []
) : string
{
return self::tag("tbody", $content, $attributes);
} | php | public static function tbody(
string $content = null,
array $attributes = []
) : string
{
return self::tag("tbody", $content, $attributes);
} | [
"public",
"static",
"function",
"tbody",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"tbody\"",
",",
"$",
"content",
",",
"$",
"attributes",
... | create tbody tag
@param string $content content
@param array $attributes further attributes
@return HTML Code | [
"create",
"tbody",
"tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1383-L1389 | train |
leedave/html | src/Html5.php | Html5.td | public static function td(
string $content = null,
array $attributes = []
) : string
{
return self::tag("td", $content, $attributes);
} | php | public static function td(
string $content = null,
array $attributes = []
) : string
{
return self::tag("td", $content, $attributes);
} | [
"public",
"static",
"function",
"td",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"td\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",... | create td tag
@param string $content content
@param array $attributes further attributes
@return HTML Code | [
"create",
"td",
"tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1398-L1404 | train |
leedave/html | src/Html5.php | Html5.th | public static function th(
string $content = null,
array $attributes = []
) : string
{
return self::tag("th", $content, $attributes);
} | php | public static function th(
string $content = null,
array $attributes = []
) : string
{
return self::tag("th", $content, $attributes);
} | [
"public",
"static",
"function",
"th",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"th\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",... | Create th tag
@param string $content content
@param array $attributes further attributes
@return HTML Code | [
"Create",
"th",
"tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1441-L1447 | train |
leedave/html | src/Html5.php | Html5.thead | public static function thead(
string $content = null,
array $attributes = []
) : string
{
return self::tag("thead", $content, $attributes);
} | php | public static function thead(
string $content = null,
array $attributes = []
) : string
{
return self::tag("thead", $content, $attributes);
} | [
"public",
"static",
"function",
"thead",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"thead\"",
",",
"$",
"content",
",",
"$",
"attributes",
... | Create thead tag
@param string $content content
@param array $attributes further attributes
@return HTML Code | [
"Create",
"thead",
"tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1456-L1462 | train |
leedave/html | src/Html5.php | Html5.tr | public static function tr(
string $content = null,
array $attributes = []
) : string
{
return self::tag("tr", $content, $attributes);
} | php | public static function tr(
string $content = null,
array $attributes = []
) : string
{
return self::tag("tr", $content, $attributes);
} | [
"public",
"static",
"function",
"tr",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"tr\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",... | Create tr tag
@param string $content content
@param array $attributes further attributes
@return HTML Code | [
"Create",
"tr",
"tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1497-L1503 | train |
leedave/html | src/Html5.php | Html5.ul | public static function ul(
string $content = null,
array $attributes = []
) : string
{
return self::tag("ul", $content, $attributes);
} | php | public static function ul(
string $content = null,
array $attributes = []
) : string
{
return self::tag("ul", $content, $attributes);
} | [
"public",
"static",
"function",
"ul",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"ul\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",... | Render unordered list tag
@param string $content
@param array $attributes
@return string | [
"Render",
"unordered",
"list",
"tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1539-L1545 | train |
leedave/html | src/Html5.php | Html5.ol | public static function ol(
string $content = null,
array $attributes = []
) : string
{
return self::tag("ol", $content, $attributes);
} | php | public static function ol(
string $content = null,
array $attributes = []
) : string
{
return self::tag("ol", $content, $attributes);
} | [
"public",
"static",
"function",
"ol",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"ol\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",... | Render Ordered List
@param string $content
@param array $attributes
@return string | [
"Render",
"Ordered",
"List"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1581-L1587 | train |
leedave/html | src/Html5.php | Html5.li | public static function li(
string $content = null,
array $attributes = []
) : string
{
return self::tag("li", $content, $attributes);
} | php | public static function li(
string $content = null,
array $attributes = []
) : string
{
return self::tag("li", $content, $attributes);
} | [
"public",
"static",
"function",
"li",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"li\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",... | Render List Item Tag
@param string $content
@param array $attributes
@return string | [
"Render",
"List",
"Item",
"Tag"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1595-L1601 | train |
leedave/html | src/Html5.php | Html5.renderTable | public static function renderTable(
array $head = [],
array $body = [],
array $attributes = []
) : string
{
$strHead = "";
$strBody = "";
foreach ($head as $thRow) {
$strHead .= self::renderTableHeaderRow($thRow);
}
if ($strHead != "") {
$strHead = self::thead($strHead);
}
foreach ($body as $tr) {
$strBody .= self::renderTableRow($tr);
}
if ($strBody != "") {
$strBody = self::tbody($strBody);
}
return self::tag("table", $strHead.$strBody, $attributes);
} | php | public static function renderTable(
array $head = [],
array $body = [],
array $attributes = []
) : string
{
$strHead = "";
$strBody = "";
foreach ($head as $thRow) {
$strHead .= self::renderTableHeaderRow($thRow);
}
if ($strHead != "") {
$strHead = self::thead($strHead);
}
foreach ($body as $tr) {
$strBody .= self::renderTableRow($tr);
}
if ($strBody != "") {
$strBody = self::tbody($strBody);
}
return self::tag("table", $strHead.$strBody, $attributes);
} | [
"public",
"static",
"function",
"renderTable",
"(",
"array",
"$",
"head",
"=",
"[",
"]",
",",
"array",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"strHead",
"=",
"\"\"",
";",
"$",
"st... | Put all elements together to form a standard table
@param array $head two dimensional rows and cells (no keys)
@param array $body two dimensional rows and cells (no keys)
@param array $attributes
@return string Compiled HTML Table | [
"Put",
"all",
"elements",
"together",
"to",
"form",
"a",
"standard",
"table"
] | f0780b37c34defbbd92d29f4e1a41ce875b4d300 | https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1656-L1680 | train |
AnonymPHP/Anonym-Library | src/Anonym/Application/RegisterProviders.php | RegisterProviders.register | public function register()
{
$app = $this->app;
foreach ($app->getProviders() as $provider) {
$provider = new $provider($app);
if (!$provider instanceof ServiceProvider) {
throw new ProviderException(sprintf('Your %s proiver must be a instance of ServiceProvider', get_class($provider)));
}
$provider->register();
$app = $provider->app();
}
} | php | public function register()
{
$app = $this->app;
foreach ($app->getProviders() as $provider) {
$provider = new $provider($app);
if (!$provider instanceof ServiceProvider) {
throw new ProviderException(sprintf('Your %s proiver must be a instance of ServiceProvider', get_class($provider)));
}
$provider->register();
$app = $provider->app();
}
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"foreach",
"(",
"$",
"app",
"->",
"getProviders",
"(",
")",
"as",
"$",
"provider",
")",
"{",
"$",
"provider",
"=",
"new",
"$",
"provider",
"(",
"$",
... | register the providers
@throws ProviderException | [
"register",
"the",
"providers"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Application/RegisterProviders.php#L43-L61 | train |
razielsd/webdriverlib | WebDriver/WebDriver/Driver.php | WebDriver_Driver.parseResponse | protected function parseResponse($rawResponse, $infoList, $command)
{
$httpStatusCode = isset($infoList['http_code']) ? $infoList['http_code'] : 0;
$messageList = [
"HTTP Response Status Code: {$httpStatusCode}",
WebDriver_Exception_Protocol::getCommandDescription($command)
];
switch ($httpStatusCode) {
case 0:
$message = $this->buildResponseErrorMessage("No response or broken.", $messageList);
throw new WebDriver_NoSeleniumException($message);
case WebDriver_Http::SUCCESS_OK:
$decodedJsonList = json_decode($rawResponse, true);
if ($decodedJsonList === null) {
$errorList = ["Can't decode response JSON:", json_last_error_msg()];
$message = $this->buildResponseErrorMessage($errorList, $messageList);
throw new WebDriver_Exception_Protocol($message);
}
if (isset($decodedJsonList['status']) &&
!WebDriver_Exception_FailedCommand::isOk($decodedJsonList['status'])) {
throw WebDriver_Exception_FailedCommand::factory(
$command,
$infoList,
$rawResponse,
$decodedJsonList
);
}
return $decodedJsonList;
default:
if (WebDriver_Http::isError($httpStatusCode)) {
throw WebDriver_Exception_Protocol::factory($command, $infoList, $rawResponse);
}
$errorMessage = "Unexpected HTTP status code: {$httpStatusCode}";
$message = $this->buildResponseErrorMessage($errorMessage, $messageList);
throw new WebDriver_Exception($message);
}
} | php | protected function parseResponse($rawResponse, $infoList, $command)
{
$httpStatusCode = isset($infoList['http_code']) ? $infoList['http_code'] : 0;
$messageList = [
"HTTP Response Status Code: {$httpStatusCode}",
WebDriver_Exception_Protocol::getCommandDescription($command)
];
switch ($httpStatusCode) {
case 0:
$message = $this->buildResponseErrorMessage("No response or broken.", $messageList);
throw new WebDriver_NoSeleniumException($message);
case WebDriver_Http::SUCCESS_OK:
$decodedJsonList = json_decode($rawResponse, true);
if ($decodedJsonList === null) {
$errorList = ["Can't decode response JSON:", json_last_error_msg()];
$message = $this->buildResponseErrorMessage($errorList, $messageList);
throw new WebDriver_Exception_Protocol($message);
}
if (isset($decodedJsonList['status']) &&
!WebDriver_Exception_FailedCommand::isOk($decodedJsonList['status'])) {
throw WebDriver_Exception_FailedCommand::factory(
$command,
$infoList,
$rawResponse,
$decodedJsonList
);
}
return $decodedJsonList;
default:
if (WebDriver_Http::isError($httpStatusCode)) {
throw WebDriver_Exception_Protocol::factory($command, $infoList, $rawResponse);
}
$errorMessage = "Unexpected HTTP status code: {$httpStatusCode}";
$message = $this->buildResponseErrorMessage($errorMessage, $messageList);
throw new WebDriver_Exception($message);
}
} | [
"protected",
"function",
"parseResponse",
"(",
"$",
"rawResponse",
",",
"$",
"infoList",
",",
"$",
"command",
")",
"{",
"$",
"httpStatusCode",
"=",
"isset",
"(",
"$",
"infoList",
"[",
"'http_code'",
"]",
")",
"?",
"$",
"infoList",
"[",
"'http_code'",
"]",
... | Returns parsed response.
@param string $rawResponse
@param array $infoList
@param WebDriver_Command $command
@throws WebDriver_Exception
@throws WebDriver_NoSeleniumException
@return array | [
"Returns",
"parsed",
"response",
"."
] | e498afc36a8cdeab5b6ca95016420557baf32f36 | https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Driver.php#L249-L285 | train |
ShortCirquit/LinkoScopeApi | ComLinkoScope.php | ComLinkoScope.updateFromPostCache | private function updateFromPostCache(Comment $comment, $c)
{
if ($comment->postId == null)
{
return;
}
if ($this->postCache == null || $this->postCache['ID'] != $comment->postId)
{
$this->postCache = $this->adminApi->getPost($comment->postId);
}
$comment->date = $this->getMetaKeyValue($this->postCache, "linkoscope_created_$comment->id") ?: $c['date'];
$comment->score =
$this->getMetaKeyValue($this->postCache, "linkoscope_score_$comment->id") ?: strtotime($c['date']);
} | php | private function updateFromPostCache(Comment $comment, $c)
{
if ($comment->postId == null)
{
return;
}
if ($this->postCache == null || $this->postCache['ID'] != $comment->postId)
{
$this->postCache = $this->adminApi->getPost($comment->postId);
}
$comment->date = $this->getMetaKeyValue($this->postCache, "linkoscope_created_$comment->id") ?: $c['date'];
$comment->score =
$this->getMetaKeyValue($this->postCache, "linkoscope_score_$comment->id") ?: strtotime($c['date']);
} | [
"private",
"function",
"updateFromPostCache",
"(",
"Comment",
"$",
"comment",
",",
"$",
"c",
")",
"{",
"if",
"(",
"$",
"comment",
"->",
"postId",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"postCache",
"==",
"null",
"||... | fetch associated post if it hasn't been fetched before, or if the incorrect post is cached. | [
"fetch",
"associated",
"post",
"if",
"it",
"hasn",
"t",
"been",
"fetched",
"before",
"or",
"if",
"the",
"incorrect",
"post",
"is",
"cached",
"."
] | a25f2233a67eeb916cddb6ff80ba3297e4597d13 | https://github.com/ShortCirquit/LinkoScopeApi/blob/a25f2233a67eeb916cddb6ff80ba3297e4597d13/ComLinkoScope.php#L342-L356 | train |
osflab/view | Helper/Tags/Link.php | Link.appendStylesheet | public function appendStylesheet($href, $media = null, array $attributes = [], $priority = false)
{
static $counter = 0;
$attributes['rel'] = 'stylesheet';
$attributes['href'] = $href;
//$attributes['type'] = 'text/css';
$media && $attributes['media'] = $media;
$this->links[$priority == 'high' ? $counter + 1000 : $counter] = Html::buildHtmlElement('link', $attributes);
$counter++;
return $this;
} | php | public function appendStylesheet($href, $media = null, array $attributes = [], $priority = false)
{
static $counter = 0;
$attributes['rel'] = 'stylesheet';
$attributes['href'] = $href;
//$attributes['type'] = 'text/css';
$media && $attributes['media'] = $media;
$this->links[$priority == 'high' ? $counter + 1000 : $counter] = Html::buildHtmlElement('link', $attributes);
$counter++;
return $this;
} | [
"public",
"function",
"appendStylesheet",
"(",
"$",
"href",
",",
"$",
"media",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"priority",
"=",
"false",
")",
"{",
"static",
"$",
"counter",
"=",
"0",
";",
"$",
"attributes",
"[",... | Link to a CSS stylesheet
@param string $href
@param string $media
@param array $attributes
@return \Osf\View\Helper\HeadLink | [
"Link",
"to",
"a",
"CSS",
"stylesheet"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Tags/Link.php#L34-L45 | train |
studyportals/SQL | src/MySQLResultSet.php | MySQLResultSet.next | public function next(){
if(next($this->_fetched) instanceof SQLResultRow){
return current($this->_fetched);
}
else{
try{
$mySQLResultRow = new MySQLResultRow($this->_result);
}
catch(SQLResultRowException $e){
return false;
}
// Clear fetch buffer in case of an unbuffered result-set
if(!$this->_buffered){
$this->_fetched = [];
}
$this->_fetched[] = $mySQLResultRow;
return $mySQLResultRow;
}
} | php | public function next(){
if(next($this->_fetched) instanceof SQLResultRow){
return current($this->_fetched);
}
else{
try{
$mySQLResultRow = new MySQLResultRow($this->_result);
}
catch(SQLResultRowException $e){
return false;
}
// Clear fetch buffer in case of an unbuffered result-set
if(!$this->_buffered){
$this->_fetched = [];
}
$this->_fetched[] = $mySQLResultRow;
return $mySQLResultRow;
}
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"next",
"(",
"$",
"this",
"->",
"_fetched",
")",
"instanceof",
"SQLResultRow",
")",
"{",
"return",
"current",
"(",
"$",
"this",
"->",
"_fetched",
")",
";",
"}",
"else",
"{",
"try",
"{",
"$",
"... | Read next result-row from the result-set.
@return SQLResultRow|false | [
"Read",
"next",
"result",
"-",
"row",
"from",
"the",
"result",
"-",
"set",
"."
] | 4f038ced9a3738c1d4ad562f93547812931d9ed4 | https://github.com/studyportals/SQL/blob/4f038ced9a3738c1d4ad562f93547812931d9ed4/src/MySQLResultSet.php#L61-L89 | train |
joegreen88/zf1-components-base | src/Zend/Loader.php | Zend_Loader.standardiseFile | public static function standardiseFile($file)
{
$fileName = ltrim($file, '\\');
$file = '';
$namespace = '';
if ($lastNsPos = strripos($fileName, '\\')) {
$namespace = substr($fileName, 0, $lastNsPos);
$fileName = substr($fileName, $lastNsPos + 1);
$file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$file .= str_replace('_', DIRECTORY_SEPARATOR, $fileName) . '.php';
return $file;
} | php | public static function standardiseFile($file)
{
$fileName = ltrim($file, '\\');
$file = '';
$namespace = '';
if ($lastNsPos = strripos($fileName, '\\')) {
$namespace = substr($fileName, 0, $lastNsPos);
$fileName = substr($fileName, $lastNsPos + 1);
$file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$file .= str_replace('_', DIRECTORY_SEPARATOR, $fileName) . '.php';
return $file;
} | [
"public",
"static",
"function",
"standardiseFile",
"(",
"$",
"file",
")",
"{",
"$",
"fileName",
"=",
"ltrim",
"(",
"$",
"file",
",",
"'\\\\'",
")",
";",
"$",
"file",
"=",
"''",
";",
"$",
"namespace",
"=",
"''",
";",
"if",
"(",
"$",
"lastNsPos",
"="... | Standardise the filename.
Convert the supplied filename into the namespace-aware standard,
based on the Framework Interop Group reference implementation:
http://groups.google.com/group/php-standards/web/psr-0-final-proposal
The filename must be formatted as "$file.php".
@param string $file - The file name to be loaded.
@return string | [
"Standardise",
"the",
"filename",
"."
] | d4591a2234c2db3094b54c08bcdc4303f7bf4819 | https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader.php#L338-L350 | train |
milkyway-multimedia/ss-zen-forms | src/Extensions/Form.php | Form.saveToSession | function saveToSession($data, $name = '') {
if(!$name) $name = $this->owner->FormName();
\Session::set("FormInfo.{$name}.data", $data);
} | php | function saveToSession($data, $name = '') {
if(!$name) $name = $this->owner->FormName();
\Session::set("FormInfo.{$name}.data", $data);
} | [
"function",
"saveToSession",
"(",
"$",
"data",
",",
"$",
"name",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"$",
"name",
"=",
"$",
"this",
"->",
"owner",
"->",
"FormName",
"(",
")",
";",
"\\",
"Session",
"::",
"set",
"(",
"\"FormInfo.... | save form data to session | [
"save",
"form",
"data",
"to",
"session"
] | 24098390d88fff016a6e6299fd2fda50f11be064 | https://github.com/milkyway-multimedia/ss-zen-forms/blob/24098390d88fff016a6e6299fd2fda50f11be064/src/Extensions/Form.php#L22-L26 | train |
milkyway-multimedia/ss-zen-forms | src/Extensions/Form.php | Form.loadFromSession | function loadFromSession($name = '') {
if(!$name) $name = $this->owner->FormName();
$formSession = \Session::get("FormInfo.{$name}.data");
if($formSession) $this->owner->loadDataFrom($formSession);
} | php | function loadFromSession($name = '') {
if(!$name) $name = $this->owner->FormName();
$formSession = \Session::get("FormInfo.{$name}.data");
if($formSession) $this->owner->loadDataFrom($formSession);
} | [
"function",
"loadFromSession",
"(",
"$",
"name",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"$",
"name",
"=",
"$",
"this",
"->",
"owner",
"->",
"FormName",
"(",
")",
";",
"$",
"formSession",
"=",
"\\",
"Session",
"::",
"get",
"(",
"\"... | load form data from session | [
"load",
"form",
"data",
"from",
"session"
] | 24098390d88fff016a6e6299fd2fda50f11be064 | https://github.com/milkyway-multimedia/ss-zen-forms/blob/24098390d88fff016a6e6299fd2fda50f11be064/src/Extensions/Form.php#L31-L36 | train |
milkyway-multimedia/ss-zen-forms | src/Extensions/Form.php | Form.clearSessionData | function clearSessionData($name = '', $clearErrors = true){
if(!$name) $name = $this->owner->FormName();
\Session::clear("FormInfo.{$name}.data");
if($clearErrors) \Session::clear("FormInfo.{$name}.errors");
} | php | function clearSessionData($name = '', $clearErrors = true){
if(!$name) $name = $this->owner->FormName();
\Session::clear("FormInfo.{$name}.data");
if($clearErrors) \Session::clear("FormInfo.{$name}.errors");
} | [
"function",
"clearSessionData",
"(",
"$",
"name",
"=",
"''",
",",
"$",
"clearErrors",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"$",
"name",
"=",
"$",
"this",
"->",
"owner",
"->",
"FormName",
"(",
")",
";",
"\\",
"Session",
"::",
"... | clear current form data session | [
"clear",
"current",
"form",
"data",
"session"
] | 24098390d88fff016a6e6299fd2fda50f11be064 | https://github.com/milkyway-multimedia/ss-zen-forms/blob/24098390d88fff016a6e6299fd2fda50f11be064/src/Extensions/Form.php#L41-L45 | train |
railsphp/framework | src/Rails/ActiveRecord/Base/Methods/ModelSchemaMethodsTrait.php | ModelSchemaMethodsTrait.tableName | public static function tableName()
{
if (static::TABLE_NAME) {
return static::TABLE_NAME;
} else {
$cn = str_replace('\\', '_', get_called_class());
$inf = self::services()->get('inflector');
$tableName = $inf->underscore($inf->pluralize($cn));
return static::tableNamePrefix() . $tableName . static::tableNameSuffix();
};
} | php | public static function tableName()
{
if (static::TABLE_NAME) {
return static::TABLE_NAME;
} else {
$cn = str_replace('\\', '_', get_called_class());
$inf = self::services()->get('inflector');
$tableName = $inf->underscore($inf->pluralize($cn));
return static::tableNamePrefix() . $tableName . static::tableNameSuffix();
};
} | [
"public",
"static",
"function",
"tableName",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"TABLE_NAME",
")",
"{",
"return",
"static",
"::",
"TABLE_NAME",
";",
"}",
"else",
"{",
"$",
"cn",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'_'",
",",
"get_called_class... | Returns the value of the TABLE_NAME constant if not empty,
otherwise it figures out the name of the table out of the
name of the model class.
@return string | [
"Returns",
"the",
"value",
"of",
"the",
"TABLE_NAME",
"constant",
"if",
"not",
"empty",
"otherwise",
"it",
"figures",
"out",
"the",
"name",
"of",
"the",
"table",
"out",
"of",
"the",
"name",
"of",
"the",
"model",
"class",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Base/Methods/ModelSchemaMethodsTrait.php#L34-L46 | train |
jfortunato/fortune | src/Configuration/Configuration.php | Configuration.resourceConfigurationFor | public function resourceConfigurationFor($resourceName)
{
foreach ($this->resourceConfigurations as $config) {
if ($config->getResource() === $resourceName) {
return $config;
}
}
return null;
} | php | public function resourceConfigurationFor($resourceName)
{
foreach ($this->resourceConfigurations as $config) {
if ($config->getResource() === $resourceName) {
return $config;
}
}
return null;
} | [
"public",
"function",
"resourceConfigurationFor",
"(",
"$",
"resourceName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"resourceConfigurations",
"as",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"->",
"getResource",
"(",
")",
"===",
"$",
"resourceNa... | Get ResourceConfiguration from resource name.
@param mixed $resourceName
@return ResourceConfiguration|null | [
"Get",
"ResourceConfiguration",
"from",
"resource",
"name",
"."
] | 3bbf66a85304070562e54a66c99145f58f32877e | https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Configuration/Configuration.php#L104-L113 | train |
PentagonalProject/SlimService | src/Sanitizer.php | Sanitizer.fixDirectorySeparator | public static function fixDirectorySeparator(string $path, $useCleanPrefix = false) : string
{
/**
* Trimming path string
*/
if (($path = trim($path)) == '') {
return $path;
}
$path = preg_replace('`(\/|\\\)+`', DIRECTORY_SEPARATOR, $path);
if ($useCleanPrefix) {
$path = DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR);
}
return $path;
} | php | public static function fixDirectorySeparator(string $path, $useCleanPrefix = false) : string
{
/**
* Trimming path string
*/
if (($path = trim($path)) == '') {
return $path;
}
$path = preg_replace('`(\/|\\\)+`', DIRECTORY_SEPARATOR, $path);
if ($useCleanPrefix) {
$path = DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR);
}
return $path;
} | [
"public",
"static",
"function",
"fixDirectorySeparator",
"(",
"string",
"$",
"path",
",",
"$",
"useCleanPrefix",
"=",
"false",
")",
":",
"string",
"{",
"/**\n * Trimming path string\n */",
"if",
"(",
"(",
"$",
"path",
"=",
"trim",
"(",
"$",
"path... | Fix Path Separator
@param string $path
@param bool $useCleanPrefix
@return string | [
"Fix",
"Path",
"Separator"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Sanitizer.php#L43-L58 | train |
PentagonalProject/SlimService | src/Sanitizer.php | Sanitizer.normalizePath | public static function normalizePath($path) : string
{
$path = self::fixDirectorySeparator($path);
$path = preg_replace('|(?<=.)/+|', DIRECTORY_SEPARATOR, $path);
if (':' === substr($path, 1, 1)) {
$path = ucfirst($path);
}
if (Validator::isAbsolutePath($path) && strpos($path, '.')) {
$explode = explode(DIRECTORY_SEPARATOR, $path);
$array = [];
foreach ($explode as $key => $value) {
if ('.' == $value) {
continue;
}
if ('..' == $value) {
array_pop($array);
} else {
$array[] = $value;
}
}
$path = implode(DIRECTORY_SEPARATOR, $array);
}
return $path;
} | php | public static function normalizePath($path) : string
{
$path = self::fixDirectorySeparator($path);
$path = preg_replace('|(?<=.)/+|', DIRECTORY_SEPARATOR, $path);
if (':' === substr($path, 1, 1)) {
$path = ucfirst($path);
}
if (Validator::isAbsolutePath($path) && strpos($path, '.')) {
$explode = explode(DIRECTORY_SEPARATOR, $path);
$array = [];
foreach ($explode as $key => $value) {
if ('.' == $value) {
continue;
}
if ('..' == $value) {
array_pop($array);
} else {
$array[] = $value;
}
}
$path = implode(DIRECTORY_SEPARATOR, $array);
}
return $path;
} | [
"public",
"static",
"function",
"normalizePath",
"(",
"$",
"path",
")",
":",
"string",
"{",
"$",
"path",
"=",
"self",
"::",
"fixDirectorySeparator",
"(",
"$",
"path",
")",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"'|(?<=.)/+|'",
",",
"DIRECTORY_SEPARATOR"... | Normalize a filesystem path.
@param string $path Path to normalize.
@return string Normalized path. | [
"Normalize",
"a",
"filesystem",
"path",
"."
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Sanitizer.php#L66-L92 | train |
PentagonalProject/SlimService | src/Sanitizer.php | Sanitizer.multiByteEntities | public static function multiByteEntities($mixed, $entity = false)
{
static $hasIconV;
static $limit;
if (!isset($hasIconV)) {
// safe resource check
$hasIconV = function_exists('iconv');
}
if (!isset($limit)) {
$limit = @ini_get('pcre.backtrack_limit');
$limit = ! is_numeric($limit) ? 4096 : abs($limit);
// minimum regex is 512 byte
$limit = $limit < 512 ? 512 : $limit;
// limit into 40 KB
$limit = $limit > 40960 ? 40960 : $limit;
}
if (! $hasIconV && ! $entity) {
return $mixed;
}
if (is_array($mixed)) {
foreach ($mixed as $key => $value) {
$mixed[$key] = self::multiByteEntities($value, $entity);
}
} elseif (is_object($mixed)) {
foreach (get_object_vars($mixed) as $key => $value) {
$mixed->{$key} = self::multiByteEntities($value, $entity);
}
} /**
* Work Safe with Parse @uses @var $limit Bit
* | 4KB data split for regex callback & safe memory usage
* that maybe fail on very long string
*/
elseif (strlen($mixed) > $limit) {
return implode('', self::multiByteEntities(str_split($mixed, $limit), $entity));
}
if ($entity) {
$mixed = htmlentities(html_entity_decode($mixed));
}
return $hasIconV
? (
preg_replace_callback(
'/[\x{80}-\x{10FFFF}]/u',
function ($match) {
$char = current($match);
$utf = iconv('UTF-8', 'UCS-4//IGNORE', $char);
return sprintf("&#x%s;", ltrim(strtolower(bin2hex($utf)), "0"));
},
$mixed
) ?:$mixed
) : $mixed;
} | php | public static function multiByteEntities($mixed, $entity = false)
{
static $hasIconV;
static $limit;
if (!isset($hasIconV)) {
// safe resource check
$hasIconV = function_exists('iconv');
}
if (!isset($limit)) {
$limit = @ini_get('pcre.backtrack_limit');
$limit = ! is_numeric($limit) ? 4096 : abs($limit);
// minimum regex is 512 byte
$limit = $limit < 512 ? 512 : $limit;
// limit into 40 KB
$limit = $limit > 40960 ? 40960 : $limit;
}
if (! $hasIconV && ! $entity) {
return $mixed;
}
if (is_array($mixed)) {
foreach ($mixed as $key => $value) {
$mixed[$key] = self::multiByteEntities($value, $entity);
}
} elseif (is_object($mixed)) {
foreach (get_object_vars($mixed) as $key => $value) {
$mixed->{$key} = self::multiByteEntities($value, $entity);
}
} /**
* Work Safe with Parse @uses @var $limit Bit
* | 4KB data split for regex callback & safe memory usage
* that maybe fail on very long string
*/
elseif (strlen($mixed) > $limit) {
return implode('', self::multiByteEntities(str_split($mixed, $limit), $entity));
}
if ($entity) {
$mixed = htmlentities(html_entity_decode($mixed));
}
return $hasIconV
? (
preg_replace_callback(
'/[\x{80}-\x{10FFFF}]/u',
function ($match) {
$char = current($match);
$utf = iconv('UTF-8', 'UCS-4//IGNORE', $char);
return sprintf("&#x%s;", ltrim(strtolower(bin2hex($utf)), "0"));
},
$mixed
) ?:$mixed
) : $mixed;
} | [
"public",
"static",
"function",
"multiByteEntities",
"(",
"$",
"mixed",
",",
"$",
"entity",
"=",
"false",
")",
"{",
"static",
"$",
"hasIconV",
";",
"static",
"$",
"limit",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"hasIconV",
")",
")",
"{",
"// safe reso... | Entities the Multi bytes deep string
@param mixed $mixed the string to detect multi bytes
@param bool $entity true if want to entity the output
@return mixed | [
"Entities",
"the",
"Multi",
"bytes",
"deep",
"string"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Sanitizer.php#L102-L157 | train |
PentagonalProject/SlimService | src/Sanitizer.php | Sanitizer.maybeUnSerialize | public static function maybeUnSerialize($original)
{
if (! is_string($original) || trim($original) == '') {
return $original;
}
/**
* Check if serialized
* check with trim
*/
if (self::isSerialized($original)) {
/**
* use trim if possible
* Serialized value could not start & end with white space
*/
return @unserialize(trim($original));
}
return $original;
} | php | public static function maybeUnSerialize($original)
{
if (! is_string($original) || trim($original) == '') {
return $original;
}
/**
* Check if serialized
* check with trim
*/
if (self::isSerialized($original)) {
/**
* use trim if possible
* Serialized value could not start & end with white space
*/
return @unserialize(trim($original));
}
return $original;
} | [
"public",
"static",
"function",
"maybeUnSerialize",
"(",
"$",
"original",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"original",
")",
"||",
"trim",
"(",
"$",
"original",
")",
"==",
"''",
")",
"{",
"return",
"$",
"original",
";",
"}",
"/**\n ... | Un-serialize value only if it was serialized.
@param string $original Maybe un-serialized original, if is needed.
@return mixed Un-serialized data can be any type. | [
"Un",
"-",
"serialize",
"value",
"only",
"if",
"it",
"was",
"serialized",
"."
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Sanitizer.php#L241-L260 | train |
gielfeldt/shutdownhandler | src/ShutdownHandler.php | ShutdownHandler.run | public function run()
{
if ($this->unRegister() && empty(static::$keys[$this->getKey()])) {
call_user_func_array($this->callback, $this->arguments);
}
} | php | public function run()
{
if ($this->unRegister() && empty(static::$keys[$this->getKey()])) {
call_user_func_array($this->callback, $this->arguments);
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"unRegister",
"(",
")",
"&&",
"empty",
"(",
"static",
"::",
"$",
"keys",
"[",
"$",
"this",
"->",
"getKey",
"(",
")",
"]",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"... | Run the shutdown handler. | [
"Run",
"the",
"shutdown",
"handler",
"."
] | a31bf9a93ce1fe77110a5374ac07cce77dda7bda | https://github.com/gielfeldt/shutdownhandler/blob/a31bf9a93ce1fe77110a5374ac07cce77dda7bda/src/ShutdownHandler.php#L99-L104 | train |
gielfeldt/shutdownhandler | src/ShutdownHandler.php | ShutdownHandler.unRegister | public function unRegister()
{
if (isset(static::$handlers[$this->handlerId])) {
if (!is_null($this->getKey())) {
static::$keys[$this->getKey()]--;
}
unset(static::$handlers[$this->handlerId]);
return true;
}
return false;
} | php | public function unRegister()
{
if (isset(static::$handlers[$this->handlerId])) {
if (!is_null($this->getKey())) {
static::$keys[$this->getKey()]--;
}
unset(static::$handlers[$this->handlerId]);
return true;
}
return false;
} | [
"public",
"function",
"unRegister",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"handlers",
"[",
"$",
"this",
"->",
"handlerId",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getKey",
"(",
")",
")",
")",... | Unregister handler.
@return boolean
true if handler was unregistered (i.e. not already unregistered). | [
"Unregister",
"handler",
"."
] | a31bf9a93ce1fe77110a5374ac07cce77dda7bda | https://github.com/gielfeldt/shutdownhandler/blob/a31bf9a93ce1fe77110a5374ac07cce77dda7bda/src/ShutdownHandler.php#L144-L154 | train |
gielfeldt/shutdownhandler | src/ShutdownHandler.php | ShutdownHandler.reRegister | public function reRegister($key = null)
{
// Set the key, and register the handler.
$this->setKey($key);
static::$handlers[$this->handlerId] = $this;
} | php | public function reRegister($key = null)
{
// Set the key, and register the handler.
$this->setKey($key);
static::$handlers[$this->handlerId] = $this;
} | [
"public",
"function",
"reRegister",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"// Set the key, and register the handler.",
"$",
"this",
"->",
"setKey",
"(",
"$",
"key",
")",
";",
"static",
"::",
"$",
"handlers",
"[",
"$",
"this",
"->",
"handlerId",
"]",
"=",... | Reregister handler.
@param string $key
(Optional) The key of the handler. | [
"Reregister",
"handler",
"."
] | a31bf9a93ce1fe77110a5374ac07cce77dda7bda | https://github.com/gielfeldt/shutdownhandler/blob/a31bf9a93ce1fe77110a5374ac07cce77dda7bda/src/ShutdownHandler.php#L183-L188 | train |
gielfeldt/shutdownhandler | src/ShutdownHandler.php | ShutdownHandler.setKey | protected function setKey($key)
{
// If a handler switches key, we need to decrement the counter for the old
// key, and increment the counter for the new key.
$this->removeKey();
// Set the new key, and increment the counter appropriately.
$this->key = $key;
if (isset($key)) {
static::$keys[$key] = isset(static::$keys[$key]) ? static::$keys[$key] + 1 : 1;
}
} | php | protected function setKey($key)
{
// If a handler switches key, we need to decrement the counter for the old
// key, and increment the counter for the new key.
$this->removeKey();
// Set the new key, and increment the counter appropriately.
$this->key = $key;
if (isset($key)) {
static::$keys[$key] = isset(static::$keys[$key]) ? static::$keys[$key] + 1 : 1;
}
} | [
"protected",
"function",
"setKey",
"(",
"$",
"key",
")",
"{",
"// If a handler switches key, we need to decrement the counter for the old",
"// key, and increment the counter for the new key.",
"$",
"this",
"->",
"removeKey",
"(",
")",
";",
"// Set the new key, and increment the co... | Set key for final nested destructor.
@param string $key
Name of key. | [
"Set",
"key",
"for",
"final",
"nested",
"destructor",
"."
] | a31bf9a93ce1fe77110a5374ac07cce77dda7bda | https://github.com/gielfeldt/shutdownhandler/blob/a31bf9a93ce1fe77110a5374ac07cce77dda7bda/src/ShutdownHandler.php#L222-L233 | train |
teeebor/decoy-framework | base/ErrorController.php | ErrorController._Bootstrap | public function _Bootstrap()
{
$this->forward()->setResponse(new HtmlResponse());
$this->forward()->getCurrentRoute()->setDefault(new Route(array('action'=>'_error')));
} | php | public function _Bootstrap()
{
$this->forward()->setResponse(new HtmlResponse());
$this->forward()->getCurrentRoute()->setDefault(new Route(array('action'=>'_error')));
} | [
"public",
"function",
"_Bootstrap",
"(",
")",
"{",
"$",
"this",
"->",
"forward",
"(",
")",
"->",
"setResponse",
"(",
"new",
"HtmlResponse",
"(",
")",
")",
";",
"$",
"this",
"->",
"forward",
"(",
")",
"->",
"getCurrentRoute",
"(",
")",
"->",
"setDefault... | Bootstrapping the class | [
"Bootstrapping",
"the",
"class"
] | 3881ae63a7d13088efda5afd3932c1af1fc18b23 | https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/base/ErrorController.php#L27-L31 | train |
teeebor/decoy-framework | base/ErrorController.php | ErrorController._error | public function _error(){
$model = new ViewModel('application/error');
$model->addVariable('error_type','error');
$model->addVariable('error',ErrorController::$errors);
return $model;
} | php | public function _error(){
$model = new ViewModel('application/error');
$model->addVariable('error_type','error');
$model->addVariable('error',ErrorController::$errors);
return $model;
} | [
"public",
"function",
"_error",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"ViewModel",
"(",
"'application/error'",
")",
";",
"$",
"model",
"->",
"addVariable",
"(",
"'error_type'",
",",
"'error'",
")",
";",
"$",
"model",
"->",
"addVariable",
"(",
"'error'",... | If there was an error, this method will display it | [
"If",
"there",
"was",
"an",
"error",
"this",
"method",
"will",
"display",
"it"
] | 3881ae63a7d13088efda5afd3932c1af1fc18b23 | https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/base/ErrorController.php#L35-L40 | train |
Opifer/ContentBundle | Controller/Api/ContentController.php | ContentController.idsAction | public function idsAction($ids)
{
$items = $this->get('opifer.content.content_manager')
->getRepository()
->findByIds($ids);
$contents = $this->get('jms_serializer')->serialize($items, 'json', SerializationContext::create()->setGroups(['list'])->enableMaxDepthChecks());
$data = [
'results' => json_decode($contents, true),
'total_results' => count($items)
];
return new JsonResponse($data);
} | php | public function idsAction($ids)
{
$items = $this->get('opifer.content.content_manager')
->getRepository()
->findByIds($ids);
$contents = $this->get('jms_serializer')->serialize($items, 'json', SerializationContext::create()->setGroups(['list'])->enableMaxDepthChecks());
$data = [
'results' => json_decode($contents, true),
'total_results' => count($items)
];
return new JsonResponse($data);
} | [
"public",
"function",
"idsAction",
"(",
"$",
"ids",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.content.content_manager'",
")",
"->",
"getRepository",
"(",
")",
"->",
"findByIds",
"(",
"$",
"ids",
")",
";",
"$",
"contents",
"=",
... | Get a content items by a list of ids
@param string $ids
@return JsonResponse | [
"Get",
"a",
"content",
"items",
"by",
"a",
"list",
"of",
"ids"
] | df44ef36b81a839ce87ea9a92f7728618111541f | https://github.com/Opifer/ContentBundle/blob/df44ef36b81a839ce87ea9a92f7728618111541f/Controller/Api/ContentController.php#L45-L59 | train |
Kylob/Sitemap | src/Component.php | Component.add | public static function add($category, $content, array $save = array())
{
$page = Page::html();
if ($page->url['format'] != 'html') {
return;
}
$page->filter('response', function ($page, $response) use ($category, $content, $save) {
if (empty($page->url['query'])) {
$sitemap = new Component();
$sitemap->upsert($category, array_merge(array(
'path' => $page->url['path'],
'title' => $page->title,
'description' => $page->description,
'keywords' => $page->keywords,
'image' => $page->image,
'content' => $content,
), $save));
unset($sitemap);
}
}, array('html', 200));
} | php | public static function add($category, $content, array $save = array())
{
$page = Page::html();
if ($page->url['format'] != 'html') {
return;
}
$page->filter('response', function ($page, $response) use ($category, $content, $save) {
if (empty($page->url['query'])) {
$sitemap = new Component();
$sitemap->upsert($category, array_merge(array(
'path' => $page->url['path'],
'title' => $page->title,
'description' => $page->description,
'keywords' => $page->keywords,
'image' => $page->image,
'content' => $content,
), $save));
unset($sitemap);
}
}, array('html', 200));
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"category",
",",
"$",
"content",
",",
"array",
"$",
"save",
"=",
"array",
"(",
")",
")",
"{",
"$",
"page",
"=",
"Page",
"::",
"html",
"(",
")",
";",
"if",
"(",
"$",
"page",
"->",
"url",
"[",
"'fo... | Include the current page in the sitemap if it is an HTML page, and has no query string. Made static to save you the hassle of opening and closing the database.
Use this method when you want to "set it, and forget it". When adding (and updating) **$content** dynamically, then some of your links may be a bit outdated as we can only update them when they are accessed. If this is unacceptable to you, then use the '**reset**', '**upsert**', and '**delete**' methods to keep everything up-to-date. Using the static add method would be equivalent to the following code:
```php
if (empty($page->url['query'])) {
$sitemap = new Sitemap();
$sitemap->upsert($category, array_merge(array(
'path' => $page->url['path'],
'title' => $page->title,
'description' => $page->description,
'keywords' => $page->keywords,
'image' => $page->image,
'content' => $content,
), $save));
unset($sitemap);
}
```
@param string $category To group related links.
@param string $content The main body of your page.
@param array $save Any additional information that you consider to be important, and would like to include with your search results.
@example
```php
Sitemap::add('pages', $html);
``` | [
"Include",
"the",
"current",
"page",
"in",
"the",
"sitemap",
"if",
"it",
"is",
"an",
"HTML",
"page",
"and",
"has",
"no",
"query",
"string",
".",
"Made",
"static",
"to",
"save",
"you",
"the",
"hassle",
"of",
"opening",
"and",
"closing",
"the",
"database",... | 19b31b6e8cc44497ac1101a00a32ec9711b86d43 | https://github.com/Kylob/Sitemap/blob/19b31b6e8cc44497ac1101a00a32ec9711b86d43/src/Component.php#L233-L253 | train |
Kylob/Sitemap | src/Component.php | Component.where | private function where($category, $and = '')
{
if (!empty($category)) {
$sql = array();
foreach ((array) $category as $like) {
$sql[] = "c.category LIKE '{$like}%'";
}
$category = 'AND '.implode(' OR ', $sql);
}
return trim('INNER JOIN sitemap AS m INNER JOIN categories AS c WHERE s.docid = m.docid AND m.category_id = c.id '.$category.' '.$and);
} | php | private function where($category, $and = '')
{
if (!empty($category)) {
$sql = array();
foreach ((array) $category as $like) {
$sql[] = "c.category LIKE '{$like}%'";
}
$category = 'AND '.implode(' OR ', $sql);
}
return trim('INNER JOIN sitemap AS m INNER JOIN categories AS c WHERE s.docid = m.docid AND m.category_id = c.id '.$category.' '.$and);
} | [
"private",
"function",
"where",
"(",
"$",
"category",
",",
"$",
"and",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"category",
")",
")",
"{",
"$",
"sql",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"category... | Adds the category and additional parameters to a query string.
@param string $category
@param string $and
@return string | [
"Adds",
"the",
"category",
"and",
"additional",
"parameters",
"to",
"a",
"query",
"string",
"."
] | 19b31b6e8cc44497ac1101a00a32ec9711b86d43 | https://github.com/Kylob/Sitemap/blob/19b31b6e8cc44497ac1101a00a32ec9711b86d43/src/Component.php#L461-L472 | train |
Kylob/Sitemap | src/Component.php | Component.id | private function id($category)
{
if (is_null($this->ids)) {
$this->ids = array();
$categories = $this->db->all('SELECT category, id FROM categories', '', 'assoc');
foreach ($categories as $row) {
$this->ids[$row['category']] = $row['id'];
}
}
if (!isset($this->ids[$category])) {
$parent = 0;
$previous = '';
foreach (explode('/', $category) as $path) {
if (!isset($this->ids[$previous.$path])) {
$this->ids[$previous.$path] = $this->exec('INSERT', 'categories', array($previous.$path, $parent));
}
$parent = $this->ids[$previous.$path];
$previous .= $path.'/';
}
}
return $this->ids[$category];
} | php | private function id($category)
{
if (is_null($this->ids)) {
$this->ids = array();
$categories = $this->db->all('SELECT category, id FROM categories', '', 'assoc');
foreach ($categories as $row) {
$this->ids[$row['category']] = $row['id'];
}
}
if (!isset($this->ids[$category])) {
$parent = 0;
$previous = '';
foreach (explode('/', $category) as $path) {
if (!isset($this->ids[$previous.$path])) {
$this->ids[$previous.$path] = $this->exec('INSERT', 'categories', array($previous.$path, $parent));
}
$parent = $this->ids[$previous.$path];
$previous .= $path.'/';
}
}
return $this->ids[$category];
} | [
"private",
"function",
"id",
"(",
"$",
"category",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"ids",
")",
")",
"{",
"$",
"this",
"->",
"ids",
"=",
"array",
"(",
")",
";",
"$",
"categories",
"=",
"$",
"this",
"->",
"db",
"->",
"all"... | Converts a category string into it's id.
@param string $category
@return int | [
"Converts",
"a",
"category",
"string",
"into",
"it",
"s",
"id",
"."
] | 19b31b6e8cc44497ac1101a00a32ec9711b86d43 | https://github.com/Kylob/Sitemap/blob/19b31b6e8cc44497ac1101a00a32ec9711b86d43/src/Component.php#L481-L503 | train |
subcosm-probe/primitives | src/Traits/Uri/MarshalTrait.php | MarshalTrait.marshalScheme | protected function marshalScheme($scheme): ? string
{
if ( null === $scheme ) {
return null;
}
if ( ! is_string($scheme) ) {
throw new UriException(
'Scheme must be a string'
);
}
return strtolower($scheme);
} | php | protected function marshalScheme($scheme): ? string
{
if ( null === $scheme ) {
return null;
}
if ( ! is_string($scheme) ) {
throw new UriException(
'Scheme must be a string'
);
}
return strtolower($scheme);
} | [
"protected",
"function",
"marshalScheme",
"(",
"$",
"scheme",
")",
":",
"?",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"scheme",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"scheme",
")",
")",
"{",
"throw",
"new... | marshals the scheme.
@param $scheme
@return null|string
@throws UriException | [
"marshals",
"the",
"scheme",
"."
] | 3b21293e88e9c08185237ff9ac707e4be6031776 | https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Uri/MarshalTrait.php#L28-L41 | train |
subcosm-probe/primitives | src/Traits/Uri/MarshalTrait.php | MarshalTrait.marshalPort | protected function marshalPort($port): ? int
{
if ( null === $port ) {
return null;
}
$port = (int) $port;
if ( 0 > $port || 65535 < $port ) {
throw new UriException(
sprintf('Invalid port: %s, value must be between 0 and 65535', $port)
);
}
return $port;
} | php | protected function marshalPort($port): ? int
{
if ( null === $port ) {
return null;
}
$port = (int) $port;
if ( 0 > $port || 65535 < $port ) {
throw new UriException(
sprintf('Invalid port: %s, value must be between 0 and 65535', $port)
);
}
return $port;
} | [
"protected",
"function",
"marshalPort",
"(",
"$",
"port",
")",
":",
"?",
"int",
"{",
"if",
"(",
"null",
"===",
"$",
"port",
")",
"{",
"return",
"null",
";",
"}",
"$",
"port",
"=",
"(",
"int",
")",
"$",
"port",
";",
"if",
"(",
"0",
">",
"$",
"... | marshals the port.
@param $port
@return int|null
@throws UriException | [
"marshals",
"the",
"port",
"."
] | 3b21293e88e9c08185237ff9ac707e4be6031776 | https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Uri/MarshalTrait.php#L68-L83 | train |
subcosm-probe/primitives | src/Traits/Uri/MarshalTrait.php | MarshalTrait.marshalPath | protected function marshalPath($path): string
{
if ( null === $path ) {
$path = '/';
}
if ( ! is_string($path) ) {
throw new UriException(
'Path must be a string or null'
);
}
return preg_replace_callback(
'/(?:[^'.self::$unreservedCharacters.self::$subDelimitedCharacters.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
function($match) {
return rawurlencode($match[0]);
},
$path
);
} | php | protected function marshalPath($path): string
{
if ( null === $path ) {
$path = '/';
}
if ( ! is_string($path) ) {
throw new UriException(
'Path must be a string or null'
);
}
return preg_replace_callback(
'/(?:[^'.self::$unreservedCharacters.self::$subDelimitedCharacters.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
function($match) {
return rawurlencode($match[0]);
},
$path
);
} | [
"protected",
"function",
"marshalPath",
"(",
"$",
"path",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"'/'",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
... | marshals the path.
@param $path
@return string
@throws UriException | [
"marshals",
"the",
"path",
"."
] | 3b21293e88e9c08185237ff9ac707e4be6031776 | https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Uri/MarshalTrait.php#L92-L111 | train |
subcosm-probe/primitives | src/Traits/Uri/MarshalTrait.php | MarshalTrait.marshalQueryAndFragment | protected function marshalQueryAndFragment($string): string
{
if ( ! is_string($string) ) {
throw new UriException(
'Query and Fragment must be a string or null'
);
}
return preg_replace_callback(
'/(?:[^'.self::$unreservedCharacters.self::$subDelimitedCharacters.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
function($match) {
return rawurlencode($match[0]);
},
$string
);
} | php | protected function marshalQueryAndFragment($string): string
{
if ( ! is_string($string) ) {
throw new UriException(
'Query and Fragment must be a string or null'
);
}
return preg_replace_callback(
'/(?:[^'.self::$unreservedCharacters.self::$subDelimitedCharacters.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
function($match) {
return rawurlencode($match[0]);
},
$string
);
} | [
"protected",
"function",
"marshalQueryAndFragment",
"(",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"throw",
"new",
"UriException",
"(",
"'Query and Fragment must be a string or null'",
")",
";",
"}",
... | marshals the query and fragment.
@param $string
@return string
@throws UriException | [
"marshals",
"the",
"query",
"and",
"fragment",
"."
] | 3b21293e88e9c08185237ff9ac707e4be6031776 | https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Uri/MarshalTrait.php#L120-L135 | train |
gorriecoe/silverstripe-dbstringextras | src/DBStringExtras.php | DBStringExtras.StrReplace | public function StrReplace($search = ' ', $replace = '')
{
$owner = $this->owner;
$owner->value = str_replace(
$search,
$replace,
$owner->value
);
return $owner;
} | php | public function StrReplace($search = ' ', $replace = '')
{
$owner = $this->owner;
$owner->value = str_replace(
$search,
$replace,
$owner->value
);
return $owner;
} | [
"public",
"function",
"StrReplace",
"(",
"$",
"search",
"=",
"' '",
",",
"$",
"replace",
"=",
"''",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"owner",
"->",
"value",
"=",
"str_replace",
"(",
"$",
"search",
",",
"$",
"replac... | Replace all occurrences of the search string with the replacement string.
@return string | [
"Replace",
"all",
"occurrences",
"of",
"the",
"search",
"string",
"with",
"the",
"replacement",
"string",
"."
] | e1a68adc6af95e8b887c1624c9144e10dc87b40c | https://github.com/gorriecoe/silverstripe-dbstringextras/blob/e1a68adc6af95e8b887c1624c9144e10dc87b40c/src/DBStringExtras.php#L31-L40 | train |
gorriecoe/silverstripe-dbstringextras | src/DBStringExtras.php | DBStringExtras.Nice | public function Nice()
{
$owner = $this->owner;
$value = preg_replace('/([a-z)([A-Z0-9]])/', '$1 $2', $owner->value);
$value = preg_replace('/([a-zA-Z])-([a-zA-Z0-9])/', '$1 $2', $value);
$value = str_replace('_', ' ', $value);
$owner->value = trim($value);
return $owner;
} | php | public function Nice()
{
$owner = $this->owner;
$value = preg_replace('/([a-z)([A-Z0-9]])/', '$1 $2', $owner->value);
$value = preg_replace('/([a-zA-Z])-([a-zA-Z0-9])/', '$1 $2', $value);
$value = str_replace('_', ' ', $value);
$owner->value = trim($value);
return $owner;
} | [
"public",
"function",
"Nice",
"(",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"'/([a-z)([A-Z0-9]])/'",
",",
"'$1 $2'",
",",
"$",
"owner",
"->",
"value",
")",
";",
"$",
"value",
"=",
"preg_repla... | Converts this camel case and hyphenated string to a space separated string.
@return string | [
"Converts",
"this",
"camel",
"case",
"and",
"hyphenated",
"string",
"to",
"a",
"space",
"separated",
"string",
"."
] | e1a68adc6af95e8b887c1624c9144e10dc87b40c | https://github.com/gorriecoe/silverstripe-dbstringextras/blob/e1a68adc6af95e8b887c1624c9144e10dc87b40c/src/DBStringExtras.php#L46-L54 | train |
gorriecoe/silverstripe-dbstringextras | src/DBStringExtras.php | DBStringExtras.Hyphenate | public function Hyphenate()
{
$value = preg_replace('/([A-Z])/', '-$1', $this->owner->value);
$value = trim($value);
return Convert::raw2url($value);
} | php | public function Hyphenate()
{
$value = preg_replace('/([A-Z])/', '-$1', $this->owner->value);
$value = trim($value);
return Convert::raw2url($value);
} | [
"public",
"function",
"Hyphenate",
"(",
")",
"{",
"$",
"value",
"=",
"preg_replace",
"(",
"'/([A-Z])/'",
",",
"'-$1'",
",",
"$",
"this",
"->",
"owner",
"->",
"value",
")",
";",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"return",
"Conver... | Converts this camel case string to a hyphenated, kebab or spinal case string. | [
"Converts",
"this",
"camel",
"case",
"string",
"to",
"a",
"hyphenated",
"kebab",
"or",
"spinal",
"case",
"string",
"."
] | e1a68adc6af95e8b887c1624c9144e10dc87b40c | https://github.com/gorriecoe/silverstripe-dbstringextras/blob/e1a68adc6af95e8b887c1624c9144e10dc87b40c/src/DBStringExtras.php#L59-L64 | train |
gorriecoe/silverstripe-dbstringextras | src/DBStringExtras.php | DBStringExtras.RemoveSpaces | public function RemoveSpaces()
{
$owner = $this->owner;
$owner->value = str_replace(
[' ', ' '],
'',
$owner->value
);
return $owner;
} | php | public function RemoveSpaces()
{
$owner = $this->owner;
$owner->value = str_replace(
[' ', ' '],
'',
$owner->value
);
return $owner;
} | [
"public",
"function",
"RemoveSpaces",
"(",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"owner",
"->",
"value",
"=",
"str_replace",
"(",
"[",
"' '",
",",
"' '",
"]",
",",
"''",
",",
"$",
"owner",
"->",
"value",
")",
";",
... | Removes spaces from this string.
@return string | [
"Removes",
"spaces",
"from",
"this",
"string",
"."
] | e1a68adc6af95e8b887c1624c9144e10dc87b40c | https://github.com/gorriecoe/silverstripe-dbstringextras/blob/e1a68adc6af95e8b887c1624c9144e10dc87b40c/src/DBStringExtras.php#L70-L79 | train |
razielsd/webdriverlib | WebDriver/WebDriver/Object/Timeout.php | WebDriver_Object_Timeout.implicitWait | public function implicitWait($timeout)
{
$timeoutNormalize = intval(ceil($timeout / 100));
if ($this->cache[self::WAIT_IMPLICIT] === $timeoutNormalize) {
return null;
}
$this->cache[self::WAIT_IMPLICIT] = $timeout;
$param = ['ms' => intval($timeout)];
$command = $this->driver->factoryCommand('timeouts/implicit_wait', WebDriver_Command::METHOD_POST, $param);
return $this->driver->curl($command)['value'];
} | php | public function implicitWait($timeout)
{
$timeoutNormalize = intval(ceil($timeout / 100));
if ($this->cache[self::WAIT_IMPLICIT] === $timeoutNormalize) {
return null;
}
$this->cache[self::WAIT_IMPLICIT] = $timeout;
$param = ['ms' => intval($timeout)];
$command = $this->driver->factoryCommand('timeouts/implicit_wait', WebDriver_Command::METHOD_POST, $param);
return $this->driver->curl($command)['value'];
} | [
"public",
"function",
"implicitWait",
"(",
"$",
"timeout",
")",
"{",
"$",
"timeoutNormalize",
"=",
"intval",
"(",
"ceil",
"(",
"$",
"timeout",
"/",
"100",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cache",
"[",
"self",
"::",
"WAIT_IMPLICIT",
"]",
... | Set the amount of time the driver should wait when searching for elements.
@param $timeout - The amount of time to wait, in milliseconds. This value has a lower bound of 0.
@return mixed | [
"Set",
"the",
"amount",
"of",
"time",
"the",
"driver",
"should",
"wait",
"when",
"searching",
"for",
"elements",
"."
] | e498afc36a8cdeab5b6ca95016420557baf32f36 | https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Object/Timeout.php#L42-L52 | train |
dlabas/DlcUseCase | src/DlcUseCase/Service/UseCase.php | UseCase.createUseCaseDiagramm | public function createUseCaseDiagramm()
{
$nodes = $this->findAll();
$diagrammService = $this->getDiagrammService();
return $diagrammService->createDiagrammFromNodes($nodes, UseCaseDiagramm::TYPE_USE_CASE);
} | php | public function createUseCaseDiagramm()
{
$nodes = $this->findAll();
$diagrammService = $this->getDiagrammService();
return $diagrammService->createDiagrammFromNodes($nodes, UseCaseDiagramm::TYPE_USE_CASE);
} | [
"public",
"function",
"createUseCaseDiagramm",
"(",
")",
"{",
"$",
"nodes",
"=",
"$",
"this",
"->",
"findAll",
"(",
")",
";",
"$",
"diagrammService",
"=",
"$",
"this",
"->",
"getDiagrammService",
"(",
")",
";",
"return",
"$",
"diagrammService",
"->",
"crea... | Creates an use case diagramm from all entities
@return UseCaseDiagramm | [
"Creates",
"an",
"use",
"case",
"diagramm",
"from",
"all",
"entities"
] | 6a15aa7628594c343c334dabf0253ce2ae5d7f0b | https://github.com/dlabas/DlcUseCase/blob/6a15aa7628594c343c334dabf0253ce2ae5d7f0b/src/DlcUseCase/Service/UseCase.php#L93-L100 | train |
dlabas/DlcUseCase | src/DlcUseCase/Service/UseCase.php | UseCase.createUseCaseDiagrammFor | public function createUseCaseDiagrammFor($entity)
{
if (is_int($entity)) {
$entity = $this->getById($entity);
} elseif (!$entity instanceof UseCaseEntity) {
throw new \InvalidArgumentException('Unkown entity data type "' . gettype($entity) . '"');
}
$diagrammService = $this->getDiagrammService();
return $diagrammService->createDiagrammFromNodes(array($entity), UseCaseDiagramm::TYPE_USE_CASE);
} | php | public function createUseCaseDiagrammFor($entity)
{
if (is_int($entity)) {
$entity = $this->getById($entity);
} elseif (!$entity instanceof UseCaseEntity) {
throw new \InvalidArgumentException('Unkown entity data type "' . gettype($entity) . '"');
}
$diagrammService = $this->getDiagrammService();
return $diagrammService->createDiagrammFromNodes(array($entity), UseCaseDiagramm::TYPE_USE_CASE);
} | [
"public",
"function",
"createUseCaseDiagrammFor",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"getById",
"(",
"$",
"entity",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"e... | Creates an use case diagramm from an single entity
@param int|\DlcUseCase\Entity\UseCase $entity
@return UseCaseDiagramm | [
"Creates",
"an",
"use",
"case",
"diagramm",
"from",
"an",
"single",
"entity"
] | 6a15aa7628594c343c334dabf0253ce2ae5d7f0b | https://github.com/dlabas/DlcUseCase/blob/6a15aa7628594c343c334dabf0253ce2ae5d7f0b/src/DlcUseCase/Service/UseCase.php#L108-L119 | train |
jayaregalinada/chikka | src/Sender.php | Sender.sendAsync | public function sendAsync($mobileNumber, $message, $messageId = null)
{
$this->requestForm = new SenderForm($mobileNumber, $message, $messageId);
return $this->client->requestAsync('POST', '', ['form_params' => $this->requestForm->get()]);
} | php | public function sendAsync($mobileNumber, $message, $messageId = null)
{
$this->requestForm = new SenderForm($mobileNumber, $message, $messageId);
return $this->client->requestAsync('POST', '', ['form_params' => $this->requestForm->get()]);
} | [
"public",
"function",
"sendAsync",
"(",
"$",
"mobileNumber",
",",
"$",
"message",
",",
"$",
"messageId",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"requestForm",
"=",
"new",
"SenderForm",
"(",
"$",
"mobileNumber",
",",
"$",
"message",
",",
"$",
"messageI... | Send a message and return a promise.
@param string $mobileNumber
@param string $message
@param string $messageId
@return \GuzzleHttp\Promise\Promise | [
"Send",
"a",
"message",
"and",
"return",
"a",
"promise",
"."
] | eefd52c6a7c0e22fe82cef00c52874865456dddf | https://github.com/jayaregalinada/chikka/blob/eefd52c6a7c0e22fe82cef00c52874865456dddf/src/Sender.php#L61-L66 | train |
jayaregalinada/chikka | src/Sender.php | Sender.send | public function send($mobileNumber, $message, $messageId = null)
{
return $this->sendAsync($mobileNumber, $message, $messageId)
->then(
function (ResponseInterface $response) {
return new SentResponse($response, $this->requestForm);
},
function ($exception) {
return $this->throwError($exception);
}
)->wait();
} | php | public function send($mobileNumber, $message, $messageId = null)
{
return $this->sendAsync($mobileNumber, $message, $messageId)
->then(
function (ResponseInterface $response) {
return new SentResponse($response, $this->requestForm);
},
function ($exception) {
return $this->throwError($exception);
}
)->wait();
} | [
"public",
"function",
"send",
"(",
"$",
"mobileNumber",
",",
"$",
"message",
",",
"$",
"messageId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"sendAsync",
"(",
"$",
"mobileNumber",
",",
"$",
"message",
",",
"$",
"messageId",
")",
"->",
"then"... | Send a message immediately.
@param string $mobileNumber
@param string $message
@param string $messageId
@throws inherits \Jag\Chikka\Exceptions\Exception
@return \Jag\Chikka\Responses\SentResponse | [
"Send",
"a",
"message",
"immediately",
"."
] | eefd52c6a7c0e22fe82cef00c52874865456dddf | https://github.com/jayaregalinada/chikka/blob/eefd52c6a7c0e22fe82cef00c52874865456dddf/src/Sender.php#L79-L90 | train |
vutran/wpmvc-core | src/Models/Post.php | Post.queryPosts | public static function queryPosts($args)
{
$query = new WP_Query($args);
// Set default return to false
$posts = false;
// Iterate and build the array of instances instances
if ($query->have_posts()) {
global $post;
// Create the array
$posts = array();
while ($query->have_posts()) {
$query->the_post();
$thePost = static::create($post);
array_push($posts, $thePost);
}
}
return $posts;
} | php | public static function queryPosts($args)
{
$query = new WP_Query($args);
// Set default return to false
$posts = false;
// Iterate and build the array of instances instances
if ($query->have_posts()) {
global $post;
// Create the array
$posts = array();
while ($query->have_posts()) {
$query->the_post();
$thePost = static::create($post);
array_push($posts, $thePost);
}
}
return $posts;
} | [
"public",
"static",
"function",
"queryPosts",
"(",
"$",
"args",
")",
"{",
"$",
"query",
"=",
"new",
"WP_Query",
"(",
"$",
"args",
")",
";",
"// Set default return to false",
"$",
"posts",
"=",
"false",
";",
"// Iterate and build the array of instances instances",
... | Query for posts and returns an array of the model
@access public
@static
@return array|bool | [
"Query",
"for",
"posts",
"and",
"returns",
"an",
"array",
"of",
"the",
"model"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L70-L87 | train |
vutran/wpmvc-core | src/Models/Post.php | Post.create | public static function create($post)
{
// If numeric, create the post
if (is_numeric($post)) {
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Post(%d)', $post);
$storedData = WP::getTransient($transientKey);
// If the transient doesn't yet exist, query for it!
if ($storedData === false) {
// Retrieve the post object
$post = WP::getPost(intval($post));
// Store the transient
WP::setTransient($transientKey, $post, static::$transientTimeout);
} else {
$post = $storedData;
}
} elseif (is_array($post)) {
// Convert array into object
$post = (object) $post;
}
return new static($post);
} | php | public static function create($post)
{
// If numeric, create the post
if (is_numeric($post)) {
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Post(%d)', $post);
$storedData = WP::getTransient($transientKey);
// If the transient doesn't yet exist, query for it!
if ($storedData === false) {
// Retrieve the post object
$post = WP::getPost(intval($post));
// Store the transient
WP::setTransient($transientKey, $post, static::$transientTimeout);
} else {
$post = $storedData;
}
} elseif (is_array($post)) {
// Convert array into object
$post = (object) $post;
}
return new static($post);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"post",
")",
"{",
"// If numeric, create the post",
"if",
"(",
"is_numeric",
"(",
"$",
"post",
")",
")",
"{",
"// Retrieve the transient",
"$",
"transientKey",
"=",
"sprintf",
"(",
"'WPMVC\\Models\\Post(%d)'",
",... | Creates a new instance by the post ID
@access public
@param array|int|WP_Post $postId
@return static | [
"Creates",
"a",
"new",
"instance",
"by",
"the",
"post",
"ID"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L109-L130 | train |
vutran/wpmvc-core | src/Models/Post.php | Post.loadMetaData | protected function loadMetaData()
{
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Post(%d)::loadMetaData', $this->id());
$metaData = WP::getTransient($transientKey);
// If it doesn't exist
if (!$metaData) {
$keys = WP::getPostCustom($this->id());
$metaData = array();
if ($keys && is_array($keys) && count($keys)) {
foreach ($keys as $key => $value) {
// If only 1 value, it's a string
if (is_array($value) && count($value) == 1) {
$metaData[$key] = $value[0];
} else {
$metaData[$key] = $value;
}
}
}
WP::setTransient($transientKey, $metaData, static::$transientTimeout);
}
$this->metaData = $metaData;
} | php | protected function loadMetaData()
{
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Post(%d)::loadMetaData', $this->id());
$metaData = WP::getTransient($transientKey);
// If it doesn't exist
if (!$metaData) {
$keys = WP::getPostCustom($this->id());
$metaData = array();
if ($keys && is_array($keys) && count($keys)) {
foreach ($keys as $key => $value) {
// If only 1 value, it's a string
if (is_array($value) && count($value) == 1) {
$metaData[$key] = $value[0];
} else {
$metaData[$key] = $value;
}
}
}
WP::setTransient($transientKey, $metaData, static::$transientTimeout);
}
$this->metaData = $metaData;
} | [
"protected",
"function",
"loadMetaData",
"(",
")",
"{",
"// Retrieve the transient",
"$",
"transientKey",
"=",
"sprintf",
"(",
"'WPMVC\\Models\\Post(%d)::loadMetaData'",
",",
"$",
"this",
"->",
"id",
"(",
")",
")",
";",
"$",
"metaData",
"=",
"WP",
"::",
"getTran... | Loads the post's meta data
@access protected
@return void | [
"Loads",
"the",
"post",
"s",
"meta",
"data"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L157-L179 | train |
vutran/wpmvc-core | src/Models/Post.php | Post.hasMeta | public function hasMeta($option)
{
return (isset($this->metaData[$option])) ? $this->metaData[$option] : false;
} | php | public function hasMeta($option)
{
return (isset($this->metaData[$option])) ? $this->metaData[$option] : false;
} | [
"public",
"function",
"hasMeta",
"(",
"$",
"option",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"metaData",
"[",
"$",
"option",
"]",
")",
")",
"?",
"$",
"this",
"->",
"metaData",
"[",
"$",
"option",
"]",
":",
"false",
";",
"}"
] | Checks if the post has a meta key
@access public
@return bool | [
"Checks",
"if",
"the",
"post",
"has",
"a",
"meta",
"key"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L210-L213 | train |
vutran/wpmvc-core | src/Models/Post.php | Post.content | public function content($moreLinkText = null, $stripTeaser = false)
{
global $post;
// Store current post into temp variable
$_p = $post;
$post = $this->post;
setup_postdata($post);
$content = get_the_content($moreLinkText, $stripTeaser);
// Apply filter
$content = WP::applyFilters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
// Restore the post
$post = $_p;
if ($_p) {
setup_postdata($post);
}
return $content;
} | php | public function content($moreLinkText = null, $stripTeaser = false)
{
global $post;
// Store current post into temp variable
$_p = $post;
$post = $this->post;
setup_postdata($post);
$content = get_the_content($moreLinkText, $stripTeaser);
// Apply filter
$content = WP::applyFilters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
// Restore the post
$post = $_p;
if ($_p) {
setup_postdata($post);
}
return $content;
} | [
"public",
"function",
"content",
"(",
"$",
"moreLinkText",
"=",
"null",
",",
"$",
"stripTeaser",
"=",
"false",
")",
"{",
"global",
"$",
"post",
";",
"// Store current post into temp variable",
"$",
"_p",
"=",
"$",
"post",
";",
"$",
"post",
"=",
"$",
"this"... | Retrieve the post's content
Note: Temporarily sets the global $post object to the event post and resets it
@access public
@link http://codex.wordpress.org/Function_Reference/get_the_title
@global WP_Post $post
@param string $moreLinkText (default: null)
@param string $stripTeaser boolean (default: false)
@return string | [
"Retrieve",
"the",
"post",
"s",
"content"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L290-L307 | train |
vutran/wpmvc-core | src/Models/Post.php | Post.excerpt | public function excerpt($wordCount = 20, $delimiter = '...')
{
global $post;
// Store current post into temp variable
$_p = $post;
$post = $this->post;
setup_postdata($post);
// Do the magic!
$limit = $wordCount + 1;
$full_excerpt = get_the_excerpt();
$full_excerpt_count = count(explode(' ', $full_excerpt)); /* Correct Word Count */
$new_excerpt = explode(' ', $full_excerpt, $limit);
if ($full_excerpt_count <= $wordCount) {
$delimiter = '';
} else {
array_pop($new_excerpt);
}
$new_excerpt = implode(' ', $new_excerpt) . $delimiter;
// Restore the post
$post = $_p;
if ($_p) {
setup_postdata($post);
}
return $new_excerpt;
} | php | public function excerpt($wordCount = 20, $delimiter = '...')
{
global $post;
// Store current post into temp variable
$_p = $post;
$post = $this->post;
setup_postdata($post);
// Do the magic!
$limit = $wordCount + 1;
$full_excerpt = get_the_excerpt();
$full_excerpt_count = count(explode(' ', $full_excerpt)); /* Correct Word Count */
$new_excerpt = explode(' ', $full_excerpt, $limit);
if ($full_excerpt_count <= $wordCount) {
$delimiter = '';
} else {
array_pop($new_excerpt);
}
$new_excerpt = implode(' ', $new_excerpt) . $delimiter;
// Restore the post
$post = $_p;
if ($_p) {
setup_postdata($post);
}
return $new_excerpt;
} | [
"public",
"function",
"excerpt",
"(",
"$",
"wordCount",
"=",
"20",
",",
"$",
"delimiter",
"=",
"'...'",
")",
"{",
"global",
"$",
"post",
";",
"// Store current post into temp variable",
"$",
"_p",
"=",
"$",
"post",
";",
"$",
"post",
"=",
"$",
"this",
"->... | Retrieve the post's excerpt
Note: Temporarily sets the global $post object to the event post and resets it
@access public
@link http://codex.wordpress.org/Function_Reference/get_the_excerpt
@global WP_Post $post
@param int $wordCount (default: 20)
@param string $delimiter (default: '...')
@return string | [
"Retrieve",
"the",
"post",
"s",
"excerpt"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L321-L345 | train |
vutran/wpmvc-core | src/Models/Post.php | Post.getTerms | public function getTerms($taxonomy)
{
// If terms isn't set
if (!$this->terms) {
// Retrieve the transient value
$transientKey = sprintf('WPMVC\Models\Post::getTerms(%s)', $this->id(), $taxonomy);
$terms = WP::getTransient($transientKey);
// If the terms isn't found in the cache
if (!$terms) {
// Query for the terms
$args = array(
'orderby' => 'name',
'order' => 'ASC'
);
// Retrieve and set the terms
$terms = wp_get_post_terms($this->id(), $taxonomy, $args);
// Store into the cache
WP::setTransient($transientKey, $terms, static::$transientTimeout);
}
// Set the terms
$this->terms[$taxonomy] = $terms;
}
return $this->terms[$taxonomy];
} | php | public function getTerms($taxonomy)
{
// If terms isn't set
if (!$this->terms) {
// Retrieve the transient value
$transientKey = sprintf('WPMVC\Models\Post::getTerms(%s)', $this->id(), $taxonomy);
$terms = WP::getTransient($transientKey);
// If the terms isn't found in the cache
if (!$terms) {
// Query for the terms
$args = array(
'orderby' => 'name',
'order' => 'ASC'
);
// Retrieve and set the terms
$terms = wp_get_post_terms($this->id(), $taxonomy, $args);
// Store into the cache
WP::setTransient($transientKey, $terms, static::$transientTimeout);
}
// Set the terms
$this->terms[$taxonomy] = $terms;
}
return $this->terms[$taxonomy];
} | [
"public",
"function",
"getTerms",
"(",
"$",
"taxonomy",
")",
"{",
"// If terms isn't set",
"if",
"(",
"!",
"$",
"this",
"->",
"terms",
")",
"{",
"// Retrieve the transient value",
"$",
"transientKey",
"=",
"sprintf",
"(",
"'WPMVC\\Models\\Post::getTerms(%s)'",
",",
... | Retrieves the taxonomy terms for the post
@access public
@return object | [
"Retrieves",
"the",
"taxonomy",
"terms",
"for",
"the",
"post"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L387-L410 | train |
vutran/wpmvc-core | src/Models/Post.php | Post.thumbnail | public function thumbnail($size = 'full')
{
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($this->id()), $size);
return isset($thumb[0]) ? $thumb[0] : '';
} | php | public function thumbnail($size = 'full')
{
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($this->id()), $size);
return isset($thumb[0]) ? $thumb[0] : '';
} | [
"public",
"function",
"thumbnail",
"(",
"$",
"size",
"=",
"'full'",
")",
"{",
"$",
"thumb",
"=",
"wp_get_attachment_image_src",
"(",
"get_post_thumbnail_id",
"(",
"$",
"this",
"->",
"id",
"(",
")",
")",
",",
"$",
"size",
")",
";",
"return",
"isset",
"(",... | Retrieve the post's thumbnail
@access public
@global object $post
@param string $size (default: "full")
@return string | [
"Retrieve",
"the",
"post",
"s",
"thumbnail"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L453-L457 | train |
vutran/wpmvc-core | src/Models/Post.php | Post.loadAdjacentPost | protected function loadAdjacentPost($direction = null)
{
$loadPrev = $loadNext = false;
switch ($direction) {
case 'prev':
$loadPrev = true;
break;
case 'next':
$loadNext = true;
break;
default:
$loadPrev = $loadNext = true;
break;
}
if ($loadPrev && !$this->prevPost) {
$this->prevPost = $this->getAdjacentPost('prev', $this->get('post_type'));
}
if ($loadNext && !$this->nextPost) {
$this->nextPost = $this->getAdjacentPost('next', $this->get('post_type'));
}
} | php | protected function loadAdjacentPost($direction = null)
{
$loadPrev = $loadNext = false;
switch ($direction) {
case 'prev':
$loadPrev = true;
break;
case 'next':
$loadNext = true;
break;
default:
$loadPrev = $loadNext = true;
break;
}
if ($loadPrev && !$this->prevPost) {
$this->prevPost = $this->getAdjacentPost('prev', $this->get('post_type'));
}
if ($loadNext && !$this->nextPost) {
$this->nextPost = $this->getAdjacentPost('next', $this->get('post_type'));
}
} | [
"protected",
"function",
"loadAdjacentPost",
"(",
"$",
"direction",
"=",
"null",
")",
"{",
"$",
"loadPrev",
"=",
"$",
"loadNext",
"=",
"false",
";",
"switch",
"(",
"$",
"direction",
")",
"{",
"case",
"'prev'",
":",
"$",
"loadPrev",
"=",
"true",
";",
"b... | Loads the adjacent posts
@access public
@param string $direction (default: null)
@return void | [
"Loads",
"the",
"adjacent",
"posts"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L561-L581 | train |
fabsgc/framework | Core/General/Resolver.php | Resolver.resolveStatic | protected static function resolveStatic($type, $data) {
$request = Request::instance();
$config = Config::instance();
if ($type == RESOLVE_ROUTE || $type == RESOLVE_LANG) {
if (preg_match('#^((\.)([a-zA-Z0-9_-]+)(\.)(.+))#', $data, $matches)) {
$src = $matches[3];
$data = preg_replace('#^(\.)(' . preg_quote($src) . ')(\.)#isU', '', $data);
}
else {
$src = $request->src;
}
return [$config->config[$type][$src], $data];
}
else {
if (preg_match('#^((\.)([^(\/)]+)([(\/)]*)(.*))#', $data, $matches)) {
$src = $matches[3];
$data = $matches[5];
}
else {
if ($request->src != '') {
$src = $request->src;
}
else {
$src = 'app';
}
}
if ($src == 'vendor') {
return VENDOR_PATH . $data;
}
else {
if (!isset($config->config[$type][$src])) {
throw new MissingConfigException('The section "' . $type . '/' . $src . '" does not exist in configuration');
}
}
return $config->config[$type][$src] . $data;
}
} | php | protected static function resolveStatic($type, $data) {
$request = Request::instance();
$config = Config::instance();
if ($type == RESOLVE_ROUTE || $type == RESOLVE_LANG) {
if (preg_match('#^((\.)([a-zA-Z0-9_-]+)(\.)(.+))#', $data, $matches)) {
$src = $matches[3];
$data = preg_replace('#^(\.)(' . preg_quote($src) . ')(\.)#isU', '', $data);
}
else {
$src = $request->src;
}
return [$config->config[$type][$src], $data];
}
else {
if (preg_match('#^((\.)([^(\/)]+)([(\/)]*)(.*))#', $data, $matches)) {
$src = $matches[3];
$data = $matches[5];
}
else {
if ($request->src != '') {
$src = $request->src;
}
else {
$src = 'app';
}
}
if ($src == 'vendor') {
return VENDOR_PATH . $data;
}
else {
if (!isset($config->config[$type][$src])) {
throw new MissingConfigException('The section "' . $type . '/' . $src . '" does not exist in configuration');
}
}
return $config->config[$type][$src] . $data;
}
} | [
"protected",
"static",
"function",
"resolveStatic",
"(",
"$",
"type",
",",
"$",
"data",
")",
"{",
"$",
"request",
"=",
"Request",
"::",
"instance",
"(",
")",
";",
"$",
"config",
"=",
"Config",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"type",
... | when you want to use a lang, route, image, template, this method is used to resolve the right path
the method use the instance of \Gcs\Framework\Core\Config\Config
@access public
@param $type string : type of the config
@param $data string : ".gcs.lang" ".gcs/template/" "template"
@throws MissingConfigException
@return mixed
@since 3.0
@package Gcs\Framework\Core\General | [
"when",
"you",
"want",
"to",
"use",
"a",
"lang",
"route",
"image",
"template",
"this",
"method",
"is",
"used",
"to",
"resolve",
"the",
"right",
"path",
"the",
"method",
"use",
"the",
"instance",
"of",
"\\",
"Gcs",
"\\",
"Framework",
"\\",
"Core",
"\\",
... | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/General/Resolver.php#L68-L108 | train |
phlexible/phlexible | src/Phlexible/Bundle/TeaserBundle/Controller/RenderController.php | RenderController.htmlAction | public function htmlAction(Request $request, $teaserId)
{
$requestStack = $this->get('request_stack');
$masterRequest = $requestStack->getMasterRequest();
if ($request->get('preview') || $request->get('_preview')) {
$request->attributes->set('_preview', true);
} elseif ($masterRequest !== $request && $masterRequest->attributes->get('_preview')) {
$request->attributes->set('_preview', true);
}
$teaser = $this->get('phlexible_teaser.teaser_service')->find($teaserId);
$request->attributes->set('contentDocument', $teaser);
$renderConfigurator = $this->get('phlexible_element_renderer.configurator');
$renderConfig = $renderConfigurator->configure($request);
if ($renderConfig->getResponse()) {
return $renderConfig->getResponse();
}
if ($request->get('template')) {
$renderConfig->set('template', $request->get('template', 'teaser'));
}
$data = $renderConfig->getVariables();
return $this->render($data['template'], (array) $data);
} | php | public function htmlAction(Request $request, $teaserId)
{
$requestStack = $this->get('request_stack');
$masterRequest = $requestStack->getMasterRequest();
if ($request->get('preview') || $request->get('_preview')) {
$request->attributes->set('_preview', true);
} elseif ($masterRequest !== $request && $masterRequest->attributes->get('_preview')) {
$request->attributes->set('_preview', true);
}
$teaser = $this->get('phlexible_teaser.teaser_service')->find($teaserId);
$request->attributes->set('contentDocument', $teaser);
$renderConfigurator = $this->get('phlexible_element_renderer.configurator');
$renderConfig = $renderConfigurator->configure($request);
if ($renderConfig->getResponse()) {
return $renderConfig->getResponse();
}
if ($request->get('template')) {
$renderConfig->set('template', $request->get('template', 'teaser'));
}
$data = $renderConfig->getVariables();
return $this->render($data['template'], (array) $data);
} | [
"public",
"function",
"htmlAction",
"(",
"Request",
"$",
"request",
",",
"$",
"teaserId",
")",
"{",
"$",
"requestStack",
"=",
"$",
"this",
"->",
"get",
"(",
"'request_stack'",
")",
";",
"$",
"masterRequest",
"=",
"$",
"requestStack",
"->",
"getMasterRequest"... | Render action.
@param Request $request
@param int $teaserId
@return Response
@Route("/{_locale}/{teaserId}", name="teaser_render") | [
"Render",
"action",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/TeaserBundle/Controller/RenderController.php#L36-L65 | train |
yani-/zip-factory | lib/ArchiverPclZip.php | ArchiverPclZip.addFromString | public function addFromString($localname , $contents)
{
return $this->pclZip->add(
array(
array(
PCLZIP_ATT_FILE_NAME => $localname,
PCLZIP_ATT_FILE_CONTENT => $contents,
)
)
);
} | php | public function addFromString($localname , $contents)
{
return $this->pclZip->add(
array(
array(
PCLZIP_ATT_FILE_NAME => $localname,
PCLZIP_ATT_FILE_CONTENT => $contents,
)
)
);
} | [
"public",
"function",
"addFromString",
"(",
"$",
"localname",
",",
"$",
"contents",
")",
"{",
"return",
"$",
"this",
"->",
"pclZip",
"->",
"add",
"(",
"array",
"(",
"array",
"(",
"PCLZIP_ATT_FILE_NAME",
"=>",
"$",
"localname",
",",
"PCLZIP_ATT_FILE_CONTENT",
... | Add a file to a ZIP archive using its contents
@param string $localname The name of the entry to create.
@param string $contents The contents to use to create the entry. It is used in a binary safe mode.
@return boolean | [
"Add",
"a",
"file",
"to",
"a",
"ZIP",
"archive",
"using",
"its",
"contents"
] | bbf202f9c183d5885aa5cce905fc50782eea10b9 | https://github.com/yani-/zip-factory/blob/bbf202f9c183d5885aa5cce905fc50782eea10b9/lib/ArchiverPclZip.php#L128-L138 | train |
tekton-php/support | src/Manifest/FileFormat.php | FileFormat.write | public function write(string $uri, $data)
{
// Create directory recursively if it doesn't exist
if ( ! file_exists(dirname($uri))) {
mkdir(dirname($uri), 0755, true);
}
// Write file to target directory
if ( ! file_put_contents($uri, $data)) {
throw new ErrorException("Failed to write output to file: ".$uri);
}
return true;
} | php | public function write(string $uri, $data)
{
// Create directory recursively if it doesn't exist
if ( ! file_exists(dirname($uri))) {
mkdir(dirname($uri), 0755, true);
}
// Write file to target directory
if ( ! file_put_contents($uri, $data)) {
throw new ErrorException("Failed to write output to file: ".$uri);
}
return true;
} | [
"public",
"function",
"write",
"(",
"string",
"$",
"uri",
",",
"$",
"data",
")",
"{",
"// Create directory recursively if it doesn't exist",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"uri",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"... | Write the data to the storage engine
@param string $uri The URI handle
@param mixed $data The data in whatever format encode outputted
@return boolean Whether it was a successful write or not | [
"Write",
"the",
"data",
"to",
"the",
"storage",
"engine"
] | 615b9f19ab66ebc2aa49aaccff12b1fc3b9266b5 | https://github.com/tekton-php/support/blob/615b9f19ab66ebc2aa49aaccff12b1fc3b9266b5/src/Manifest/FileFormat.php#L34-L47 | train |
easy-system/es-system | src/Components/Components.php | Components.register | public function register($class)
{
if ($this->initialized) {
throw new RuntimeException(
'The components have already been initialized.'
);
}
if (! class_exists($class)) {
throw new RuntimeException(sprintf(
'The component "%s" not exists.',
$class
));
}
$component = new $class();
if (! $component instanceof ComponentInterface) {
throw new InvalidArgumentException(sprintf(
'The component "%s" must implement "%s".',
$class,
ComponentInterface::CLASS
));
}
$this->container[$class] = $component;
return md5($class . $component->getVersion());
} | php | public function register($class)
{
if ($this->initialized) {
throw new RuntimeException(
'The components have already been initialized.'
);
}
if (! class_exists($class)) {
throw new RuntimeException(sprintf(
'The component "%s" not exists.',
$class
));
}
$component = new $class();
if (! $component instanceof ComponentInterface) {
throw new InvalidArgumentException(sprintf(
'The component "%s" must implement "%s".',
$class,
ComponentInterface::CLASS
));
}
$this->container[$class] = $component;
return md5($class . $component->getVersion());
} | [
"public",
"function",
"register",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'The components have already been initialized.'",
")",
";",
"}",
"if",
"(",
"!",
"class_exists",
"("... | Register the component.
@param string $class The class of component
@throws \InvalidArgumentException If the specified class not implements
the Es\Component\ComponentInterface
@throws \RuntimeException
- If If the components have already been initialized
- If the specified class of component does not exists
@return string The hash of component state | [
"Register",
"the",
"component",
"."
] | 750632b7a57f8c65d98c61cd0c29d2da3a9a04cc | https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/Components/Components.php#L51-L76 | train |
easy-system/es-system | src/Components/Components.php | Components.init | public function init(
ServicesInterface $services,
ListenersInterface $listeners,
EventsInterface $events,
ConfigInterface $config
) {
if ($this->initialized) {
throw new RuntimeException(
'The components have already been initialized.'
);
}
$this->initialized = true;
foreach ($this->container as $component) {
if (method_exists($component, 'getServicesConfig')) {
$services->add($component->getServicesConfig());
}
if (method_exists($component, 'getListenersConfig')) {
$listeners->add($component->getListenersConfig());
}
if (method_exists($component, 'getEventsConfig')) {
foreach ($component->getEventsConfig() as $item) {
call_user_func_array([$events, 'attach'], $item);
}
}
if (method_exists($component, 'getSystemConfig')) {
$config->merge($component->getSystemConfig());
}
}
} | php | public function init(
ServicesInterface $services,
ListenersInterface $listeners,
EventsInterface $events,
ConfigInterface $config
) {
if ($this->initialized) {
throw new RuntimeException(
'The components have already been initialized.'
);
}
$this->initialized = true;
foreach ($this->container as $component) {
if (method_exists($component, 'getServicesConfig')) {
$services->add($component->getServicesConfig());
}
if (method_exists($component, 'getListenersConfig')) {
$listeners->add($component->getListenersConfig());
}
if (method_exists($component, 'getEventsConfig')) {
foreach ($component->getEventsConfig() as $item) {
call_user_func_array([$events, 'attach'], $item);
}
}
if (method_exists($component, 'getSystemConfig')) {
$config->merge($component->getSystemConfig());
}
}
} | [
"public",
"function",
"init",
"(",
"ServicesInterface",
"$",
"services",
",",
"ListenersInterface",
"$",
"listeners",
",",
"EventsInterface",
"$",
"events",
",",
"ConfigInterface",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",... | Initializes components.
@param \Es\Services\ServicesInterface $services The services
@param \Es\Events\ListenersInterface $listeners The listeners
@param \Es\Events\EventsInterface $events The events
@param \Es\System\ConfigInterface $config The system configuration
@throws \RuntimeException If the components have already been initialized | [
"Initializes",
"components",
"."
] | 750632b7a57f8c65d98c61cd0c29d2da3a9a04cc | https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/Components/Components.php#L133-L162 | train |
ironedgesoftware/file-utils | src/File/Factory.php | Factory.createInstance | public function createInstance($file, $type = null, array $options = array())
{
if (!is_file($file) && $type === null) {
throw new \InvalidArgumentException(
'You must enter a $type if the file does not exist yet.'
);
}
$type = pathinfo($file, PATHINFO_EXTENSION);
switch ($type) {
case self::JSON_TYPE:
$file = new Json($file, $options);
break;
case self::YAML_TYPE:
$file = new Yaml($file, $options);
break;
default:
throw UnsupportedFileTypeException::create($type);
}
return $file;
} | php | public function createInstance($file, $type = null, array $options = array())
{
if (!is_file($file) && $type === null) {
throw new \InvalidArgumentException(
'You must enter a $type if the file does not exist yet.'
);
}
$type = pathinfo($file, PATHINFO_EXTENSION);
switch ($type) {
case self::JSON_TYPE:
$file = new Json($file, $options);
break;
case self::YAML_TYPE:
$file = new Yaml($file, $options);
break;
default:
throw UnsupportedFileTypeException::create($type);
}
return $file;
} | [
"public",
"function",
"createInstance",
"(",
"$",
"file",
",",
"$",
"type",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
"&&",
"$",
"type",
"===",
"null",
")",
"{",... | Creates an instance of a file.
@param string $file - File.
@param null|string $type - Type.
@param array $options - Options.
@throws UnsupportedFileTypeException - If the file type cannot be handled.
@return \IronEdge\Component\FileUtils\File\Base | [
"Creates",
"an",
"instance",
"of",
"a",
"file",
"."
] | d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb | https://github.com/ironedgesoftware/file-utils/blob/d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb/src/File/Factory.php#L36-L60 | train |
MarcusFulbright/represent | src/Represent/Factory/PaginationFactory.php | PaginationFactory.makePagerFromArray | protected function makePagerFromArray($data, $page = 1, $limit = 10)
{
$adapter = new ArrayAdapter($data);
$pager = new Pagerfanta($adapter);
$pager->setMaxPerPage($limit);
$pager->setCurrentPage($page);
return $pager;
} | php | protected function makePagerFromArray($data, $page = 1, $limit = 10)
{
$adapter = new ArrayAdapter($data);
$pager = new Pagerfanta($adapter);
$pager->setMaxPerPage($limit);
$pager->setCurrentPage($page);
return $pager;
} | [
"protected",
"function",
"makePagerFromArray",
"(",
"$",
"data",
",",
"$",
"page",
"=",
"1",
",",
"$",
"limit",
"=",
"10",
")",
"{",
"$",
"adapter",
"=",
"new",
"ArrayAdapter",
"(",
"$",
"data",
")",
";",
"$",
"pager",
"=",
"new",
"Pagerfanta",
"(",
... | Creates a pager from an array
@param $data
@param int $page
@param int $limit
@return Pagerfanta | [
"Creates",
"a",
"pager",
"from",
"an",
"array"
] | f7b624f473a3247a29f05c4a694d04bba4038e59 | https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Factory/PaginationFactory.php#L35-L43 | train |
MarcusFulbright/represent | src/Represent/Factory/PaginationFactory.php | PaginationFactory.paginate | public function paginate(array $data, $page, $limit , $url, $params = array())
{
$pager = $this->makePagerFromArray($data, $page, $limit);
return $this->factory->createCollectionFromPager($pager, $url, $params);
} | php | public function paginate(array $data, $page, $limit , $url, $params = array())
{
$pager = $this->makePagerFromArray($data, $page, $limit);
return $this->factory->createCollectionFromPager($pager, $url, $params);
} | [
"public",
"function",
"paginate",
"(",
"array",
"$",
"data",
",",
"$",
"page",
",",
"$",
"limit",
",",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"pager",
"=",
"$",
"this",
"->",
"makePagerFromArray",
"(",
"$",
"data",
... | Handles creating a pager and turning it into a collection representation
@param $data
@param $page
@param $limit
@param $url
@param array $params
@return PaginatedCollection | [
"Handles",
"creating",
"a",
"pager",
"and",
"turning",
"it",
"into",
"a",
"collection",
"representation"
] | f7b624f473a3247a29f05c4a694d04bba4038e59 | https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Factory/PaginationFactory.php#L55-L60 | train |
fabsgc/framework | Core/Lang/Langs.php | Langs.getLangClient | public function getLangClient() {
if (!array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) || !$_SERVER['HTTP_ACCEPT_LANGUAGE']) {
return Config::config()['user']['output']['lang'];
}
else {
$langcode = (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$langcode = (!empty($langcode)) ? explode(";", $langcode) : $langcode;
$langcode = (!empty($langcode['0'])) ? explode(",", $langcode['0']) : $langcode;
$langcode = (!empty($langcode['0'])) ? explode("-", $langcode['0']) : $langcode;
return $langcode['0'];
}
} | php | public function getLangClient() {
if (!array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) || !$_SERVER['HTTP_ACCEPT_LANGUAGE']) {
return Config::config()['user']['output']['lang'];
}
else {
$langcode = (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$langcode = (!empty($langcode)) ? explode(";", $langcode) : $langcode;
$langcode = (!empty($langcode['0'])) ? explode(",", $langcode['0']) : $langcode;
$langcode = (!empty($langcode['0'])) ? explode("-", $langcode['0']) : $langcode;
return $langcode['0'];
}
} | [
"public",
"function",
"getLangClient",
"(",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'HTTP_ACCEPT_LANGUAGE'",
",",
"$",
"_SERVER",
")",
"||",
"!",
"$",
"_SERVER",
"[",
"'HTTP_ACCEPT_LANGUAGE'",
"]",
")",
"{",
"return",
"Config",
"::",
"config",
"(... | get the client language
@access public
@return string
@since 3.0
@package Gcs\Framework\Core\Lang | [
"get",
"the",
"client",
"language"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Lang/Langs.php#L36-L48 | train |
cmdweb/cache | Cache/Cache.php | Cache.delete | public function delete($key){
$file = $this->generateFileLocation($key);
if(file_exists($file))
unlink($file);
} | php | public function delete($key){
$file = $this->generateFileLocation($key);
if(file_exists($file))
unlink($file);
} | [
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"generateFileLocation",
"(",
"$",
"key",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"unlink",
"(",
"$",
"file",
")",
";",
"}"
] | Limpa um cache | [
"Limpa",
"um",
"cache"
] | b1ca4249596bffe93d23b46ba298785d17fa1e10 | https://github.com/cmdweb/cache/blob/b1ca4249596bffe93d23b46ba298785d17fa1e10/Cache/Cache.php#L99-L104 | train |
cmdweb/cache | Cache/Cache.php | Cache.set | public function set($key, $content, $time = null) {
$time = strtotime(!is_null($time) ? $time : self::$time);
$content = serialize(array(
'expires' => $time,
'content' => $content));
return $this->createCacheFile($key, $content);
} | php | public function set($key, $content, $time = null) {
$time = strtotime(!is_null($time) ? $time : self::$time);
$content = serialize(array(
'expires' => $time,
'content' => $content));
return $this->createCacheFile($key, $content);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"content",
",",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"time",
"=",
"strtotime",
"(",
"!",
"is_null",
"(",
"$",
"time",
")",
"?",
"$",
"time",
":",
"self",
"::",
"$",
"time",
")",
";",
... | Salva um valor no cache
@uses Cache::createCacheFile() para criar o arquivo com o cache
@param string $key Uma chave para identificar o valor cacheado
@param mixed $content Conteúdo/variável a ser salvo(a) no cache
@param string $time Quanto tempo até o cache expirar (opcional)
@return boolean Se o cache foi salvo | [
"Salva",
"um",
"valor",
"no",
"cache"
] | b1ca4249596bffe93d23b46ba298785d17fa1e10 | https://github.com/cmdweb/cache/blob/b1ca4249596bffe93d23b46ba298785d17fa1e10/Cache/Cache.php#L117-L125 | train |
cmdweb/cache | Cache/Cache.php | Cache.get | public function get($key) {
$filename = $this->generateFileLocation($key);
if (file_exists($filename) && is_readable($filename)) {
$cache = unserialize(file_get_contents($filename));
if ($cache['expires'] > time()) {
return $cache['content'];
} else {
unlink($filename);
}
}
return null;
} | php | public function get($key) {
$filename = $this->generateFileLocation($key);
if (file_exists($filename) && is_readable($filename)) {
$cache = unserialize(file_get_contents($filename));
if ($cache['expires'] > time()) {
return $cache['content'];
} else {
unlink($filename);
}
}
return null;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"generateFileLocation",
"(",
"$",
"key",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
"&&",
"is_readable",
"(",
"$",
"filename",
")",
"... | Salva um valor do cache
@uses Cache::generateFileLocation() para gerar o local do arquivo de cache
@param string $key Uma chave para identificar o valor cacheado
@return mixed Se o cache foi encontrado retorna o seu valor, caso contrário retorna NULL | [
"Salva",
"um",
"valor",
"do",
"cache"
] | b1ca4249596bffe93d23b46ba298785d17fa1e10 | https://github.com/cmdweb/cache/blob/b1ca4249596bffe93d23b46ba298785d17fa1e10/Cache/Cache.php#L137-L148 | train |
pablodip/PablodipModuleBundle | Field/Guesser/FieldGuesserFactory.php | FieldGuesserFactory.addFieldGuessers | public function addFieldGuessers(array $fieldGuessers)
{
foreach ($fieldGuessers as $name => $fieldGuesser) {
$this->add($name, $fieldGuesser);
}
} | php | public function addFieldGuessers(array $fieldGuessers)
{
foreach ($fieldGuessers as $name => $fieldGuesser) {
$this->add($name, $fieldGuesser);
}
} | [
"public",
"function",
"addFieldGuessers",
"(",
"array",
"$",
"fieldGuessers",
")",
"{",
"foreach",
"(",
"$",
"fieldGuessers",
"as",
"$",
"name",
"=>",
"$",
"fieldGuesser",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"name",
",",
"$",
"fieldGuesser",
")... | Adds an array of field guessers.
@param array $fieldGuessers An array of field guessers. | [
"Adds",
"an",
"array",
"of",
"field",
"guessers",
"."
] | 6d26df909fa4c57b8b3337d58f8cbecd7781c6ef | https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Field/Guesser/FieldGuesserFactory.php#L50-L55 | train |
pablodip/PablodipModuleBundle | Field/Guesser/FieldGuesserFactory.php | FieldGuesserFactory.get | public function get($name)
{
if (!$this->has($name)) {
throw new \InvalidArgumentException(sprintf('The field guesser "%s" does not exist.', $name));
}
return $this->fieldGuessers[$name];
} | php | public function get($name)
{
if (!$this->has($name)) {
throw new \InvalidArgumentException(sprintf('The field guesser "%s" does not exist.', $name));
}
return $this->fieldGuessers[$name];
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The field guesser \"%s\" does not exist.'",
",",
"$... | Returns a field guesser by name.
@param string $name The name.
@return FieldGuesserInterface The field guesser.
@throws \InvalidArgumentException If the field guesser does not exist. | [
"Returns",
"a",
"field",
"guesser",
"by",
"name",
"."
] | 6d26df909fa4c57b8b3337d58f8cbecd7781c6ef | https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Field/Guesser/FieldGuesserFactory.php#L78-L85 | train |
dlapps/consul-php-envvar | src/Builder/ConsulEnvManagerBuilder.php | ConsulEnvManagerBuilder.build | public function build(): ConsulEnvManager
{
$kv = (new ServiceFactory([
'base_uri' => $this->consulServer
]))->get('kv');
$manager = new ConsulEnvManager(
$kv,
$this->overwriteEvenIfDefined
);
$this->clear();
return $manager;
} | php | public function build(): ConsulEnvManager
{
$kv = (new ServiceFactory([
'base_uri' => $this->consulServer
]))->get('kv');
$manager = new ConsulEnvManager(
$kv,
$this->overwriteEvenIfDefined
);
$this->clear();
return $manager;
} | [
"public",
"function",
"build",
"(",
")",
":",
"ConsulEnvManager",
"{",
"$",
"kv",
"=",
"(",
"new",
"ServiceFactory",
"(",
"[",
"'base_uri'",
"=>",
"$",
"this",
"->",
"consulServer",
"]",
")",
")",
"->",
"get",
"(",
"'kv'",
")",
";",
"$",
"manager",
"... | Build the manager with the properties that have been defined.
@return ConsulEnvManager | [
"Build",
"the",
"manager",
"with",
"the",
"properties",
"that",
"have",
"been",
"defined",
"."
] | e5da3a3e56536c1108c32c1148cda0b589ad7773 | https://github.com/dlapps/consul-php-envvar/blob/e5da3a3e56536c1108c32c1148cda0b589ad7773/src/Builder/ConsulEnvManagerBuilder.php#L33-L47 | train |
jmpantoja/planb-utils | src/Beautifier/Parser/ParserFactory.php | ParserFactory.factory | public static function factory(?Enviroment $environment = null): Parser
{
$environment = $environment ?? Enviroment::getFromSapi(PHP_SAPI);
return self::evaluate($environment)->isInstanceOf(Parser::class)->getValue();
} | php | public static function factory(?Enviroment $environment = null): Parser
{
$environment = $environment ?? Enviroment::getFromSapi(PHP_SAPI);
return self::evaluate($environment)->isInstanceOf(Parser::class)->getValue();
} | [
"public",
"static",
"function",
"factory",
"(",
"?",
"Enviroment",
"$",
"environment",
"=",
"null",
")",
":",
"Parser",
"{",
"$",
"environment",
"=",
"$",
"environment",
"??",
"Enviroment",
"::",
"getFromSapi",
"(",
"PHP_SAPI",
")",
";",
"return",
"self",
... | Devuelve el parser asociado a un nombre
@param null|\PlanB\Beautifier\Enviroment $environment
@return \PlanB\Beautifier\Parser\Parser | [
"Devuelve",
"el",
"parser",
"asociado",
"a",
"un",
"nombre"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/ParserFactory.php#L37-L42 | train |
jmpantoja/planb-utils | src/Beautifier/Parser/ParserFactory.php | ParserFactory.makeHtml | public function makeHtml(Enviroment $enviroment): ?Parser
{
if (!$enviroment->isHtml()) {
return null;
}
return Parser::make()
->addDecorator(PaddingDecorator::make())
->addDecorator(LineWidthDecorator::make())
->addDecorator(HtmlTagDecorator::make())
->addDecorator(MarginDecorator::make());
} | php | public function makeHtml(Enviroment $enviroment): ?Parser
{
if (!$enviroment->isHtml()) {
return null;
}
return Parser::make()
->addDecorator(PaddingDecorator::make())
->addDecorator(LineWidthDecorator::make())
->addDecorator(HtmlTagDecorator::make())
->addDecorator(MarginDecorator::make());
} | [
"public",
"function",
"makeHtml",
"(",
"Enviroment",
"$",
"enviroment",
")",
":",
"?",
"Parser",
"{",
"if",
"(",
"!",
"$",
"enviroment",
"->",
"isHtml",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"Parser",
"::",
"make",
"(",
")",
"->",... | Crea un objeto Html Parser
@param \PlanB\Beautifier\Enviroment $enviroment
@return null| \PlanB\Beautifier\Parser\Parser | [
"Crea",
"un",
"objeto",
"Html",
"Parser"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/ParserFactory.php#L62-L74 | train |
jmpantoja/planb-utils | src/Beautifier/Parser/ParserFactory.php | ParserFactory.makeConsole | public function makeConsole(Enviroment $enviroment): ?Parser
{
if (!$enviroment->isConsole()) {
return null;
}
return Parser::make()
->addDecorator(PaddingDecorator::make())
->addDecorator(LineWidthDecorator::make())
->addDecorator(ConsoleTagDecorator::make())
->addDecorator(MarginDecorator::make());
} | php | public function makeConsole(Enviroment $enviroment): ?Parser
{
if (!$enviroment->isConsole()) {
return null;
}
return Parser::make()
->addDecorator(PaddingDecorator::make())
->addDecorator(LineWidthDecorator::make())
->addDecorator(ConsoleTagDecorator::make())
->addDecorator(MarginDecorator::make());
} | [
"public",
"function",
"makeConsole",
"(",
"Enviroment",
"$",
"enviroment",
")",
":",
"?",
"Parser",
"{",
"if",
"(",
"!",
"$",
"enviroment",
"->",
"isConsole",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"Parser",
"::",
"make",
"(",
")",
... | Crea un objeto Console Parser
@param \PlanB\Beautifier\Enviroment $enviroment
@return null|\PlanB\Beautifier\Parser\Parser | [
"Crea",
"un",
"objeto",
"Console",
"Parser"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/ParserFactory.php#L83-L94 | train |
ExSituMarketing/EXS-LanderTrackingHouseBundle | Service/TrackingParameterExtracter.php | TrackingParameterExtracter.setup | public function setup(array $extracters)
{
foreach ($extracters as $extracter) {
if (
(false === ($extracter['reference'] instanceof TrackingParameterQueryExtracterInterface))
&& (false === ($extracter['reference'] instanceof TrackingParameterCookieExtracterInterface))
&& (false === ($extracter['reference'] instanceof TrackingParameterInitializerInterface))
) {
throw new InvalidConfigurationException(sprintf(
'Invalid tracking parameter extracter "%s".',
$extracter['name']
));
}
$this->extracters[$extracter['name']] = $extracter['reference'];
}
} | php | public function setup(array $extracters)
{
foreach ($extracters as $extracter) {
if (
(false === ($extracter['reference'] instanceof TrackingParameterQueryExtracterInterface))
&& (false === ($extracter['reference'] instanceof TrackingParameterCookieExtracterInterface))
&& (false === ($extracter['reference'] instanceof TrackingParameterInitializerInterface))
) {
throw new InvalidConfigurationException(sprintf(
'Invalid tracking parameter extracter "%s".',
$extracter['name']
));
}
$this->extracters[$extracter['name']] = $extracter['reference'];
}
} | [
"public",
"function",
"setup",
"(",
"array",
"$",
"extracters",
")",
"{",
"foreach",
"(",
"$",
"extracters",
"as",
"$",
"extracter",
")",
"{",
"if",
"(",
"(",
"false",
"===",
"(",
"$",
"extracter",
"[",
"'reference'",
"]",
"instanceof",
"TrackingParameterQ... | Set all formatters available.
@param array $extracters
@throws InvalidConfigurationException | [
"Set",
"all",
"formatters",
"available",
"."
] | 404ce51ec1ee0bf5e669eb1f4cd04746e244f61a | https://github.com/ExSituMarketing/EXS-LanderTrackingHouseBundle/blob/404ce51ec1ee0bf5e669eb1f4cd04746e244f61a/Service/TrackingParameterExtracter.php#L39-L55 | train |
ExSituMarketing/EXS-LanderTrackingHouseBundle | Service/TrackingParameterExtracter.php | TrackingParameterExtracter.extract | public function extract(Request $request)
{
$trackingParameters = new ParameterBag();
/** Get value from cookies. */
foreach ($this->extracters as $extracter) {
if ($extracter instanceof TrackingParameterCookieExtracterInterface) {
$trackingParameters->add($extracter->extractFromCookies($request->cookies));
}
}
/** Override cookies' value by query's value if set. */
foreach ($this->extracters as $extracter) {
if ($extracter instanceof TrackingParameterQueryExtracterInterface) {
$trackingParameters->add($extracter->extractFromQuery($request->query));
}
}
return $trackingParameters;
} | php | public function extract(Request $request)
{
$trackingParameters = new ParameterBag();
/** Get value from cookies. */
foreach ($this->extracters as $extracter) {
if ($extracter instanceof TrackingParameterCookieExtracterInterface) {
$trackingParameters->add($extracter->extractFromCookies($request->cookies));
}
}
/** Override cookies' value by query's value if set. */
foreach ($this->extracters as $extracter) {
if ($extracter instanceof TrackingParameterQueryExtracterInterface) {
$trackingParameters->add($extracter->extractFromQuery($request->query));
}
}
return $trackingParameters;
} | [
"public",
"function",
"extract",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"trackingParameters",
"=",
"new",
"ParameterBag",
"(",
")",
";",
"/** Get value from cookies. */",
"foreach",
"(",
"$",
"this",
"->",
"extracters",
"as",
"$",
"extracter",
")",
"{"... | Extract tracking parameters from query or from cookies.
@param Request $request
@return ParameterBag | [
"Extract",
"tracking",
"parameters",
"from",
"query",
"or",
"from",
"cookies",
"."
] | 404ce51ec1ee0bf5e669eb1f4cd04746e244f61a | https://github.com/ExSituMarketing/EXS-LanderTrackingHouseBundle/blob/404ce51ec1ee0bf5e669eb1f4cd04746e244f61a/Service/TrackingParameterExtracter.php#L64-L83 | train |
ruxon/framework | src/Sms/BaseSmsSms.class.php | BaseSmsSms.status | public function status($id)
{
$url = self::HOST . self::STATUS;
$params = $this->get_default_params();
$params['id'] = $id;
$result = $this->request($url, $params);
return $result;
} | php | public function status($id)
{
$url = self::HOST . self::STATUS;
$params = $this->get_default_params();
$params['id'] = $id;
$result = $this->request($url, $params);
return $result;
} | [
"public",
"function",
"status",
"(",
"$",
"id",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"HOST",
".",
"self",
"::",
"STATUS",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"get_default_params",
"(",
")",
";",
"$",
"params",
"[",
"'id'",
"]",
"=",
"... | Check message status
@param type $id
@return type | [
"Check",
"message",
"status"
] | d6c9a48df41c8564ee1b0455cd09fbe789e6b086 | https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L83-L92 | train |
ruxon/framework | src/Sms/BaseSmsSms.class.php | BaseSmsSms.balance | public function balance()
{
$url = self::HOST . self::BALANCE;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'balance' => $result[1]
);
} | php | public function balance()
{
$url = self::HOST . self::BALANCE;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'balance' => $result[1]
);
} | [
"public",
"function",
"balance",
"(",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"HOST",
".",
"self",
"::",
"BALANCE",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"get_default_params",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
... | Check user balance
@return array | [
"Check",
"user",
"balance"
] | d6c9a48df41c8564ee1b0455cd09fbe789e6b086 | https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L98-L110 | train |
ruxon/framework | src/Sms/BaseSmsSms.class.php | BaseSmsSms.limit | public function limit()
{
$url = self::HOST . self::LIMIT;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'total' => $result[1],
'current' => $result[2]
);
} | php | public function limit()
{
$url = self::HOST . self::LIMIT;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'total' => $result[1],
'current' => $result[2]
);
} | [
"public",
"function",
"limit",
"(",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"HOST",
".",
"self",
"::",
"LIMIT",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"get_default_params",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",... | Check day limit
@return array | [
"Check",
"day",
"limit"
] | d6c9a48df41c8564ee1b0455cd09fbe789e6b086 | https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L117-L130 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.