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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cssjanus/php-cssjanus | src/CSSJanus.php | CSSJanus.buildPatterns | private static function buildPatterns() {
if (!is_null(self::$patterns['escape'])) {
// Patterns have already been built
return;
}
// @codingStandardsIgnoreStart Generic.Files.LineLength.TooLong
$patterns =& self::$patterns;
$patterns['escape'] = "(?:{$patterns['unicode']}|\\[^\r\n\f0-9a-f])";
$patterns['nmstart'] = "(?:[_a-z]|{$patterns['nonAscii']}|{$patterns['escape']})";
$patterns['nmchar'] = "(?:[_a-z0-9-]|{$patterns['nonAscii']}|{$patterns['escape']})";
$patterns['ident'] = "-?{$patterns['nmstart']}{$patterns['nmchar']}*";
$patterns['quantity'] = "{$patterns['num']}(?:\s*{$patterns['unit']}|{$patterns['ident']})?";
$patterns['possibly_negative_quantity'] = "((?:-?{$patterns['quantity']})|(?:inherit|auto))";
$patterns['color'] = "(#?{$patterns['nmchar']}+|(?:rgba?|hsla?)\([ \d.,%-]+\))";
$patterns['url_chars'] = "(?:{$patterns['url_special_chars']}|{$patterns['nonAscii']}|{$patterns['escape']})*";
$patterns['lookahead_not_open_brace'] = "(?!({$patterns['nmchar']}|\r?\n|\s|#|\:|\.|\,|\+|>|\(|\)|\[|\]|=|\*=|~=|\^=|'[^']*'])*?{)";
$patterns['lookahead_not_closing_paren'] = "(?!{$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
$patterns['lookahead_for_closing_paren'] = "(?={$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
$patterns['noflip_single'] = "/({$patterns['noflip_annotation']}{$patterns['lookahead_not_open_brace']}[^;}]+;?)/i";
$patterns['noflip_class'] = "/({$patterns['noflip_annotation']}{$patterns['chars_within_selector']}})/i";
$patterns['direction_ltr'] = "/({$patterns['direction']})ltr/i";
$patterns['direction_rtl'] = "/({$patterns['direction']})rtl/i";
$patterns['left'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
$patterns['right'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
$patterns['left_in_url'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_for_closing_paren']}/i";
$patterns['right_in_url'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_for_closing_paren']}/i";
$patterns['ltr_in_url'] = "/{$patterns['lookbehind_not_letter']}(ltr){$patterns['lookahead_for_closing_paren']}/i";
$patterns['rtl_in_url'] = "/{$patterns['lookbehind_not_letter']}(rtl){$patterns['lookahead_for_closing_paren']}/i";
$patterns['cursor_east'] = "/{$patterns['lookbehind_not_letter']}([ns]?)e-resize/";
$patterns['cursor_west'] = "/{$patterns['lookbehind_not_letter']}([ns]?)w-resize/";
$patterns['four_notation_quantity_props'] = "((?:margin|padding|border-width)\s*:\s*)";
$patterns['four_notation_quantity'] = "/{$patterns['four_notation_quantity_props']}{$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}{$patterns['suffix']}/i";
$patterns['four_notation_color'] = "/((?:-color|border-style)\s*:\s*){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}{$patterns['suffix']}/i";
// border-radius: <length or percentage>{1,4} [optional: / <length or percentage>{1,4} ]
$patterns['border_radius'] = '/(border-radius\s*:\s*)' . $patterns['possibly_negative_quantity']
. '(?:(?:\s+' . $patterns['possibly_negative_quantity'] . ')(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?)?'
. '(?:(?:(?:\s*\/\s*)' . $patterns['possibly_negative_quantity'] . ')(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?)?' . $patterns['suffix']
. '/i';
$patterns['box_shadow'] = "/(box-shadow\s*:\s*(?:inset\s*)?){$patterns['possibly_negative_quantity']}/i";
$patterns['text_shadow1'] = "/(text-shadow\s*:\s*){$patterns['possibly_negative_quantity']}(\s*){$patterns['color']}/i";
$patterns['text_shadow2'] = "/(text-shadow\s*:\s*){$patterns['color']}(\s*){$patterns['possibly_negative_quantity']}/i";
$patterns['text_shadow3'] = "/(text-shadow\s*:\s*){$patterns['possibly_negative_quantity']}/i";
$patterns['bg_horizontal_percentage'] = "/(background(?:-position)?\s*:\s*(?:[^:;}\s]+\s+)*?)({$patterns['quantity']})/i";
$patterns['bg_horizontal_percentage_x'] = "/(background-position-x\s*:\s*)(-?{$patterns['num']}%)/i";
$patterns['translate_x'] = "/(transform\s*:[^;]*)(translateX\s*\(\s*){$patterns['possibly_negative_quantity']}(\s*\))/i";
$patterns['translate'] = "/(transform\s*:[^;]*)(translate\s*\(\s*){$patterns['possibly_negative_quantity']}((?:\s*,\s*{$patterns['possibly_negative_quantity']}){0,2}\s*\))/i";
// @codingStandardsIgnoreEnd
} | php | private static function buildPatterns() {
if (!is_null(self::$patterns['escape'])) {
// Patterns have already been built
return;
}
// @codingStandardsIgnoreStart Generic.Files.LineLength.TooLong
$patterns =& self::$patterns;
$patterns['escape'] = "(?:{$patterns['unicode']}|\\[^\r\n\f0-9a-f])";
$patterns['nmstart'] = "(?:[_a-z]|{$patterns['nonAscii']}|{$patterns['escape']})";
$patterns['nmchar'] = "(?:[_a-z0-9-]|{$patterns['nonAscii']}|{$patterns['escape']})";
$patterns['ident'] = "-?{$patterns['nmstart']}{$patterns['nmchar']}*";
$patterns['quantity'] = "{$patterns['num']}(?:\s*{$patterns['unit']}|{$patterns['ident']})?";
$patterns['possibly_negative_quantity'] = "((?:-?{$patterns['quantity']})|(?:inherit|auto))";
$patterns['color'] = "(#?{$patterns['nmchar']}+|(?:rgba?|hsla?)\([ \d.,%-]+\))";
$patterns['url_chars'] = "(?:{$patterns['url_special_chars']}|{$patterns['nonAscii']}|{$patterns['escape']})*";
$patterns['lookahead_not_open_brace'] = "(?!({$patterns['nmchar']}|\r?\n|\s|#|\:|\.|\,|\+|>|\(|\)|\[|\]|=|\*=|~=|\^=|'[^']*'])*?{)";
$patterns['lookahead_not_closing_paren'] = "(?!{$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
$patterns['lookahead_for_closing_paren'] = "(?={$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
$patterns['noflip_single'] = "/({$patterns['noflip_annotation']}{$patterns['lookahead_not_open_brace']}[^;}]+;?)/i";
$patterns['noflip_class'] = "/({$patterns['noflip_annotation']}{$patterns['chars_within_selector']}})/i";
$patterns['direction_ltr'] = "/({$patterns['direction']})ltr/i";
$patterns['direction_rtl'] = "/({$patterns['direction']})rtl/i";
$patterns['left'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
$patterns['right'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
$patterns['left_in_url'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_for_closing_paren']}/i";
$patterns['right_in_url'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_for_closing_paren']}/i";
$patterns['ltr_in_url'] = "/{$patterns['lookbehind_not_letter']}(ltr){$patterns['lookahead_for_closing_paren']}/i";
$patterns['rtl_in_url'] = "/{$patterns['lookbehind_not_letter']}(rtl){$patterns['lookahead_for_closing_paren']}/i";
$patterns['cursor_east'] = "/{$patterns['lookbehind_not_letter']}([ns]?)e-resize/";
$patterns['cursor_west'] = "/{$patterns['lookbehind_not_letter']}([ns]?)w-resize/";
$patterns['four_notation_quantity_props'] = "((?:margin|padding|border-width)\s*:\s*)";
$patterns['four_notation_quantity'] = "/{$patterns['four_notation_quantity_props']}{$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}(\s+){$patterns['possibly_negative_quantity']}{$patterns['suffix']}/i";
$patterns['four_notation_color'] = "/((?:-color|border-style)\s*:\s*){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}{$patterns['suffix']}/i";
// border-radius: <length or percentage>{1,4} [optional: / <length or percentage>{1,4} ]
$patterns['border_radius'] = '/(border-radius\s*:\s*)' . $patterns['possibly_negative_quantity']
. '(?:(?:\s+' . $patterns['possibly_negative_quantity'] . ')(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?)?'
. '(?:(?:(?:\s*\/\s*)' . $patterns['possibly_negative_quantity'] . ')(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?(?:\s+' . $patterns['possibly_negative_quantity'] . ')?)?' . $patterns['suffix']
. '/i';
$patterns['box_shadow'] = "/(box-shadow\s*:\s*(?:inset\s*)?){$patterns['possibly_negative_quantity']}/i";
$patterns['text_shadow1'] = "/(text-shadow\s*:\s*){$patterns['possibly_negative_quantity']}(\s*){$patterns['color']}/i";
$patterns['text_shadow2'] = "/(text-shadow\s*:\s*){$patterns['color']}(\s*){$patterns['possibly_negative_quantity']}/i";
$patterns['text_shadow3'] = "/(text-shadow\s*:\s*){$patterns['possibly_negative_quantity']}/i";
$patterns['bg_horizontal_percentage'] = "/(background(?:-position)?\s*:\s*(?:[^:;}\s]+\s+)*?)({$patterns['quantity']})/i";
$patterns['bg_horizontal_percentage_x'] = "/(background-position-x\s*:\s*)(-?{$patterns['num']}%)/i";
$patterns['translate_x'] = "/(transform\s*:[^;]*)(translateX\s*\(\s*){$patterns['possibly_negative_quantity']}(\s*\))/i";
$patterns['translate'] = "/(transform\s*:[^;]*)(translate\s*\(\s*){$patterns['possibly_negative_quantity']}((?:\s*,\s*{$patterns['possibly_negative_quantity']}){0,2}\s*\))/i";
// @codingStandardsIgnoreEnd
} | [
"private",
"static",
"function",
"buildPatterns",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'escape'",
"]",
")",
")",
"{",
"// Patterns have already been built",
"return",
";",
"}",
"// @codingStandardsIgnoreStart Generic.... | Build patterns we can't define above because they depend on other patterns. | [
"Build",
"patterns",
"we",
"can",
"t",
"define",
"above",
"because",
"they",
"depend",
"on",
"other",
"patterns",
"."
] | 44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6 | https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L87-L135 | train |
cssjanus/php-cssjanus | src/CSSJanus.php | CSSJanus.transform | public static function transform($css, $options = array(), $transformEdgeInUrl = false) {
if (!is_array($options)) {
$options = array(
'transformDirInUrl' => (bool)$options,
'transformEdgeInUrl' => (bool)$transformEdgeInUrl,
);
}
// Defaults
$options += array(
'transformDirInUrl' => false,
'transformEdgeInUrl' => false,
);
// We wrap tokens in ` , not ~ like the original implementation does.
// This was done because ` is not a legal character in CSS and can only
// occur in URLs, where we escape it to %60 before inserting our tokens.
$css = str_replace('`', '%60', $css);
self::buildPatterns();
// Tokenize single line rules with /* @noflip */
$noFlipSingle = new CSSJanusTokenizer(self::$patterns['noflip_single'], '`NOFLIP_SINGLE`');
$css = $noFlipSingle->tokenize($css);
// Tokenize class rules with /* @noflip */
$noFlipClass = new CSSJanusTokenizer(self::$patterns['noflip_class'], '`NOFLIP_CLASS`');
$css = $noFlipClass->tokenize($css);
// Tokenize comments
$comments = new CSSJanusTokenizer(self::$patterns['comment'], '`C`');
$css = $comments->tokenize($css);
// LTR->RTL fixes start here
$css = self::fixDirection($css);
if ($options['transformDirInUrl']) {
$css = self::fixLtrRtlInURL($css);
}
if ($options['transformEdgeInUrl']) {
$css = self::fixLeftRightInURL($css);
}
$css = self::fixLeftAndRight($css);
$css = self::fixCursorProperties($css);
$css = self::fixFourPartNotation($css);
$css = self::fixBorderRadius($css);
$css = self::fixBackgroundPosition($css);
$css = self::fixShadows($css);
$css = self::fixTranslate($css);
// Detokenize stuff we tokenized before
$css = $comments->detokenize($css);
$css = $noFlipClass->detokenize($css);
$css = $noFlipSingle->detokenize($css);
return $css;
} | php | public static function transform($css, $options = array(), $transformEdgeInUrl = false) {
if (!is_array($options)) {
$options = array(
'transformDirInUrl' => (bool)$options,
'transformEdgeInUrl' => (bool)$transformEdgeInUrl,
);
}
// Defaults
$options += array(
'transformDirInUrl' => false,
'transformEdgeInUrl' => false,
);
// We wrap tokens in ` , not ~ like the original implementation does.
// This was done because ` is not a legal character in CSS and can only
// occur in URLs, where we escape it to %60 before inserting our tokens.
$css = str_replace('`', '%60', $css);
self::buildPatterns();
// Tokenize single line rules with /* @noflip */
$noFlipSingle = new CSSJanusTokenizer(self::$patterns['noflip_single'], '`NOFLIP_SINGLE`');
$css = $noFlipSingle->tokenize($css);
// Tokenize class rules with /* @noflip */
$noFlipClass = new CSSJanusTokenizer(self::$patterns['noflip_class'], '`NOFLIP_CLASS`');
$css = $noFlipClass->tokenize($css);
// Tokenize comments
$comments = new CSSJanusTokenizer(self::$patterns['comment'], '`C`');
$css = $comments->tokenize($css);
// LTR->RTL fixes start here
$css = self::fixDirection($css);
if ($options['transformDirInUrl']) {
$css = self::fixLtrRtlInURL($css);
}
if ($options['transformEdgeInUrl']) {
$css = self::fixLeftRightInURL($css);
}
$css = self::fixLeftAndRight($css);
$css = self::fixCursorProperties($css);
$css = self::fixFourPartNotation($css);
$css = self::fixBorderRadius($css);
$css = self::fixBackgroundPosition($css);
$css = self::fixShadows($css);
$css = self::fixTranslate($css);
// Detokenize stuff we tokenized before
$css = $comments->detokenize($css);
$css = $noFlipClass->detokenize($css);
$css = $noFlipSingle->detokenize($css);
return $css;
} | [
"public",
"static",
"function",
"transform",
"(",
"$",
"css",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"transformEdgeInUrl",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
... | Transform an LTR stylesheet to RTL
@param string $css Stylesheet to transform
@param array|bool $options Options array or value of transformDirInUrl option (back-compat)
@param bool $options['transformDirInUrl'] Transform directions in URLs (ltr/rtl). Default: false.
@param bool $options['transformEdgeInUrl'] Transform edges in URLs (left/right). Default: false.
@param bool $transformEdgeInUrl [optional] For back-compat
@return string Transformed stylesheet | [
"Transform",
"an",
"LTR",
"stylesheet",
"to",
"RTL"
] | 44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6 | https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L146-L202 | train |
cssjanus/php-cssjanus | src/CSSJanus.php | CSSJanus.fixLtrRtlInURL | private static function fixLtrRtlInURL($css) {
$css = preg_replace(self::$patterns['ltr_in_url'], self::$patterns['tmpToken'], $css);
$css = preg_replace(self::$patterns['rtl_in_url'], 'ltr', $css);
$css = str_replace(self::$patterns['tmpToken'], 'rtl', $css);
return $css;
} | php | private static function fixLtrRtlInURL($css) {
$css = preg_replace(self::$patterns['ltr_in_url'], self::$patterns['tmpToken'], $css);
$css = preg_replace(self::$patterns['rtl_in_url'], 'ltr', $css);
$css = str_replace(self::$patterns['tmpToken'], 'rtl', $css);
return $css;
} | [
"private",
"static",
"function",
"fixLtrRtlInURL",
"(",
"$",
"css",
")",
"{",
"$",
"css",
"=",
"preg_replace",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'ltr_in_url'",
"]",
",",
"self",
"::",
"$",
"patterns",
"[",
"'tmpToken'",
"]",
",",
"$",
"css",
")... | Replace 'ltr' with 'rtl' and vice versa in background URLs
@param $css string
@return string | [
"Replace",
"ltr",
"with",
"rtl",
"and",
"vice",
"versa",
"in",
"background",
"URLs"
] | 44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6 | https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L233-L239 | train |
cssjanus/php-cssjanus | src/CSSJanus.php | CSSJanus.fixLeftRightInURL | private static function fixLeftRightInURL($css) {
$css = preg_replace(self::$patterns['left_in_url'], self::$patterns['tmpToken'], $css);
$css = preg_replace(self::$patterns['right_in_url'], 'left', $css);
$css = str_replace(self::$patterns['tmpToken'], 'right', $css);
return $css;
} | php | private static function fixLeftRightInURL($css) {
$css = preg_replace(self::$patterns['left_in_url'], self::$patterns['tmpToken'], $css);
$css = preg_replace(self::$patterns['right_in_url'], 'left', $css);
$css = str_replace(self::$patterns['tmpToken'], 'right', $css);
return $css;
} | [
"private",
"static",
"function",
"fixLeftRightInURL",
"(",
"$",
"css",
")",
"{",
"$",
"css",
"=",
"preg_replace",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'left_in_url'",
"]",
",",
"self",
"::",
"$",
"patterns",
"[",
"'tmpToken'",
"]",
",",
"$",
"css",
... | Replace 'left' with 'right' and vice versa in background URLs
@param $css string
@return string | [
"Replace",
"left",
"with",
"right",
"and",
"vice",
"versa",
"in",
"background",
"URLs"
] | 44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6 | https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L246-L252 | train |
cssjanus/php-cssjanus | src/CSSJanus.php | CSSJanus.fixShadows | private static function fixShadows($css) {
$css = preg_replace_callback(self::$patterns['box_shadow'], function ($matches) {
return $matches[1] . self::flipSign($matches[2]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow1'], function ($matches) {
return $matches[1] . $matches[2] . $matches[3] . self::flipSign($matches[4]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow2'], function ($matches) {
return $matches[1] . $matches[2] . $matches[3] . self::flipSign($matches[4]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow3'], function ($matches) {
return $matches[1] . self::flipSign($matches[2]);
}, $css);
return $css;
} | php | private static function fixShadows($css) {
$css = preg_replace_callback(self::$patterns['box_shadow'], function ($matches) {
return $matches[1] . self::flipSign($matches[2]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow1'], function ($matches) {
return $matches[1] . $matches[2] . $matches[3] . self::flipSign($matches[4]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow2'], function ($matches) {
return $matches[1] . $matches[2] . $matches[3] . self::flipSign($matches[4]);
}, $css);
$css = preg_replace_callback(self::$patterns['text_shadow3'], function ($matches) {
return $matches[1] . self::flipSign($matches[2]);
}, $css);
return $css;
} | [
"private",
"static",
"function",
"fixShadows",
"(",
"$",
"css",
")",
"{",
"$",
"css",
"=",
"preg_replace_callback",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'box_shadow'",
"]",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"$",
"matches",
"[... | Negates horizontal offset in box-shadow and text-shadow rules.
@param $css string
@return string | [
"Negates",
"horizontal",
"offset",
"in",
"box",
"-",
"shadow",
"and",
"text",
"-",
"shadow",
"rules",
"."
] | 44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6 | https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L389-L407 | train |
cssjanus/php-cssjanus | src/CSSJanus.php | CSSJanus.fixBackgroundPosition | private static function fixBackgroundPosition($css) {
$replaced = preg_replace_callback(
self::$patterns['bg_horizontal_percentage'],
array('self', 'calculateNewBackgroundPosition'),
$css
);
if ($replaced !== null) {
// preg_replace_callback() sometimes returns null
$css = $replaced;
}
$replaced = preg_replace_callback(
self::$patterns['bg_horizontal_percentage_x'],
array('self', 'calculateNewBackgroundPosition'),
$css
);
if ($replaced !== null) {
$css = $replaced;
}
return $css;
} | php | private static function fixBackgroundPosition($css) {
$replaced = preg_replace_callback(
self::$patterns['bg_horizontal_percentage'],
array('self', 'calculateNewBackgroundPosition'),
$css
);
if ($replaced !== null) {
// preg_replace_callback() sometimes returns null
$css = $replaced;
}
$replaced = preg_replace_callback(
self::$patterns['bg_horizontal_percentage_x'],
array('self', 'calculateNewBackgroundPosition'),
$css
);
if ($replaced !== null) {
$css = $replaced;
}
return $css;
} | [
"private",
"static",
"function",
"fixBackgroundPosition",
"(",
"$",
"css",
")",
"{",
"$",
"replaced",
"=",
"preg_replace_callback",
"(",
"self",
"::",
"$",
"patterns",
"[",
"'bg_horizontal_percentage'",
"]",
",",
"array",
"(",
"'self'",
",",
"'calculateNewBackgrou... | Flip horizontal background percentages.
@param $css string
@return string | [
"Flip",
"horizontal",
"background",
"percentages",
"."
] | 44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6 | https://github.com/cssjanus/php-cssjanus/blob/44362c7c8aace5c52bd20d917b87e6c1d2d8c5c6/src/CSSJanus.php#L432-L452 | train |
nglasl/silverstripe-mediawesome | src/objects/MediaType.php | MediaType.validate | public function validate() {
$result = parent::validate();
// Confirm that the current type has been given a title and doesn't already exist.
if($result->isValid() && !$this->Title) {
$result->addError('"Title" required!');
}
else if($result->isValid() && MediaType::get_one(MediaType::class, array(
'ID != ?' => $this->ID,
'Title = ?' => $this->Title
))) {
$result->addError('Type already exists!');
}
// Allow extension customisation.
$this->extend('validateMediaType', $result);
return $result;
} | php | public function validate() {
$result = parent::validate();
// Confirm that the current type has been given a title and doesn't already exist.
if($result->isValid() && !$this->Title) {
$result->addError('"Title" required!');
}
else if($result->isValid() && MediaType::get_one(MediaType::class, array(
'ID != ?' => $this->ID,
'Title = ?' => $this->Title
))) {
$result->addError('Type already exists!');
}
// Allow extension customisation.
$this->extend('validateMediaType', $result);
return $result;
} | [
"public",
"function",
"validate",
"(",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"validate",
"(",
")",
";",
"// Confirm that the current type has been given a title and doesn't already exist.",
"if",
"(",
"$",
"result",
"->",
"isValid",
"(",
")",
"&&",
"!",
"$... | Confirm that the current type is valid. | [
"Confirm",
"that",
"the",
"current",
"type",
"is",
"valid",
"."
] | 0537ad9934f69a680cd20115269efed13e082abf | https://github.com/nglasl/silverstripe-mediawesome/blob/0537ad9934f69a680cd20115269efed13e082abf/src/objects/MediaType.php#L105-L125 | train |
dreamfactorysoftware/df-sqldb | src/Resources/StoredFunction.php | StoredFunction.describeFunctions | protected function describeFunctions($names, $refresh = false)
{
$names = static::validateAsArray(
$names,
',',
true,
'The request contains no valid function names or properties.'
);
$out = [];
foreach ($names as $name) {
$out[] = $this->describeFunction($name, $refresh);
}
return $out;
} | php | protected function describeFunctions($names, $refresh = false)
{
$names = static::validateAsArray(
$names,
',',
true,
'The request contains no valid function names or properties.'
);
$out = [];
foreach ($names as $name) {
$out[] = $this->describeFunction($name, $refresh);
}
return $out;
} | [
"protected",
"function",
"describeFunctions",
"(",
"$",
"names",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"$",
"names",
"=",
"static",
"::",
"validateAsArray",
"(",
"$",
"names",
",",
"','",
",",
"true",
",",
"'The request contains no valid function names or... | Get multiple functions and their properties
@param string | array $names Function names comma-delimited string or array
@param bool $refresh Force a refresh of the schema from the database
@return array
@throws \Exception | [
"Get",
"multiple",
"functions",
"and",
"their",
"properties"
] | f5b6c45fae068db5043419405299bfbc928fa90b | https://github.com/dreamfactorysoftware/df-sqldb/blob/f5b6c45fae068db5043419405299bfbc928fa90b/src/Resources/StoredFunction.php#L270-L285 | train |
dreamfactorysoftware/df-sqldb | src/Resources/StoredFunction.php | StoredFunction.describeFunction | protected function describeFunction($name, $refresh = false)
{
$name = (is_array($name) ? array_get($name, 'name') : $name);
if (empty($name)) {
throw new BadRequestException('Function name can not be empty.');
}
$this->checkPermission(Verbs::GET, $name);
try {
$function = $this->getFunction($name, $refresh);
$result = $function->toArray();
$result['access'] = $this->getPermissions($name);
return $result;
} catch (RestException $ex) {
throw $ex;
} catch (\Exception $ex) {
throw new InternalServerErrorException("Failed to query database schema.\n{$ex->getMessage()}");
}
} | php | protected function describeFunction($name, $refresh = false)
{
$name = (is_array($name) ? array_get($name, 'name') : $name);
if (empty($name)) {
throw new BadRequestException('Function name can not be empty.');
}
$this->checkPermission(Verbs::GET, $name);
try {
$function = $this->getFunction($name, $refresh);
$result = $function->toArray();
$result['access'] = $this->getPermissions($name);
return $result;
} catch (RestException $ex) {
throw $ex;
} catch (\Exception $ex) {
throw new InternalServerErrorException("Failed to query database schema.\n{$ex->getMessage()}");
}
} | [
"protected",
"function",
"describeFunction",
"(",
"$",
"name",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"(",
"is_array",
"(",
"$",
"name",
")",
"?",
"array_get",
"(",
"$",
"name",
",",
"'name'",
")",
":",
"$",
"name",
")",
";"... | Get any properties related to the function
@param string | array $name Function name or defining properties
@param bool $refresh Force a refresh of the schema from the database
@return array
@throws \Exception | [
"Get",
"any",
"properties",
"related",
"to",
"the",
"function"
] | f5b6c45fae068db5043419405299bfbc928fa90b | https://github.com/dreamfactorysoftware/df-sqldb/blob/f5b6c45fae068db5043419405299bfbc928fa90b/src/Resources/StoredFunction.php#L296-L316 | train |
rtconner/laravel-likeable | src/LikeCounter.php | LikeCounter.rebuild | public static function rebuild($modelClass)
{
if(empty($modelClass)) {
throw new \Exception('$modelClass cannot be empty/null. Maybe set the $morphClass variable on your model.');
}
$builder = Like::query()
->select(\DB::raw('count(*) as count, likeable_type, likeable_id'))
->where('likeable_type', $modelClass)
->groupBy('likeable_id');
$results = $builder->get();
$inserts = $results->toArray();
\DB::table((new static)->table)->insert($inserts);
} | php | public static function rebuild($modelClass)
{
if(empty($modelClass)) {
throw new \Exception('$modelClass cannot be empty/null. Maybe set the $morphClass variable on your model.');
}
$builder = Like::query()
->select(\DB::raw('count(*) as count, likeable_type, likeable_id'))
->where('likeable_type', $modelClass)
->groupBy('likeable_id');
$results = $builder->get();
$inserts = $results->toArray();
\DB::table((new static)->table)->insert($inserts);
} | [
"public",
"static",
"function",
"rebuild",
"(",
"$",
"modelClass",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"modelClass",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'$modelClass cannot be empty/null. Maybe set the $morphClass variable on your model.'",
")"... | Delete all counts of the given model, and recount them and insert new counts
@param string $model (should match Model::$morphClass) | [
"Delete",
"all",
"counts",
"of",
"the",
"given",
"model",
"and",
"recount",
"them",
"and",
"insert",
"new",
"counts"
] | d3b61686703a23a4aa61f593e55bc10b87f60621 | https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/LikeCounter.php#L23-L39 | train |
rtconner/laravel-likeable | src/Likeable.php | Likeable.like | public function like($userId=null)
{
if(is_null($userId)) {
$userId = $this->loggedInUserId();
}
if($userId) {
$like = $this->likes()
->where('user_id', '=', $userId)
->first();
if($like) return;
$like = new Like();
$like->user_id = $userId;
$this->likes()->save($like);
}
$this->incrementLikeCount();
} | php | public function like($userId=null)
{
if(is_null($userId)) {
$userId = $this->loggedInUserId();
}
if($userId) {
$like = $this->likes()
->where('user_id', '=', $userId)
->first();
if($like) return;
$like = new Like();
$like->user_id = $userId;
$this->likes()->save($like);
}
$this->incrementLikeCount();
} | [
"public",
"function",
"like",
"(",
"$",
"userId",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"userId",
")",
")",
"{",
"$",
"userId",
"=",
"$",
"this",
"->",
"loggedInUserId",
"(",
")",
";",
"}",
"if",
"(",
"$",
"userId",
")",
"{",
"... | Add a like for this record by the given user.
@param $userId mixed - If null will use currently logged in user. | [
"Add",
"a",
"like",
"for",
"this",
"record",
"by",
"the",
"given",
"user",
"."
] | d3b61686703a23a4aa61f593e55bc10b87f60621 | https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L69-L88 | train |
rtconner/laravel-likeable | src/Likeable.php | Likeable.liked | public function liked($userId=null)
{
if(is_null($userId)) {
$userId = $this->loggedInUserId();
}
return (bool) $this->likes()
->where('user_id', '=', $userId)
->count();
} | php | public function liked($userId=null)
{
if(is_null($userId)) {
$userId = $this->loggedInUserId();
}
return (bool) $this->likes()
->where('user_id', '=', $userId)
->count();
} | [
"public",
"function",
"liked",
"(",
"$",
"userId",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"userId",
")",
")",
"{",
"$",
"userId",
"=",
"$",
"this",
"->",
"loggedInUserId",
"(",
")",
";",
"}",
"return",
"(",
"bool",
")",
"$",
"this... | Has the currently logged in user already "liked" the current object
@param string $userId
@return boolean | [
"Has",
"the",
"currently",
"logged",
"in",
"user",
"already",
"liked",
"the",
"current",
"object"
] | d3b61686703a23a4aa61f593e55bc10b87f60621 | https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L119-L128 | train |
rtconner/laravel-likeable | src/Likeable.php | Likeable.incrementLikeCount | private function incrementLikeCount()
{
$counter = $this->likeCounter()->first();
if($counter) {
$counter->count++;
$counter->save();
} else {
$counter = new LikeCounter;
$counter->count = 1;
$this->likeCounter()->save($counter);
}
} | php | private function incrementLikeCount()
{
$counter = $this->likeCounter()->first();
if($counter) {
$counter->count++;
$counter->save();
} else {
$counter = new LikeCounter;
$counter->count = 1;
$this->likeCounter()->save($counter);
}
} | [
"private",
"function",
"incrementLikeCount",
"(",
")",
"{",
"$",
"counter",
"=",
"$",
"this",
"->",
"likeCounter",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"counter",
")",
"{",
"$",
"counter",
"->",
"count",
"++",
";",
"$",
"counter",
... | Private. Increment the total like count stored in the counter | [
"Private",
".",
"Increment",
"the",
"total",
"like",
"count",
"stored",
"in",
"the",
"counter"
] | d3b61686703a23a4aa61f593e55bc10b87f60621 | https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L133-L145 | train |
rtconner/laravel-likeable | src/Likeable.php | Likeable.decrementLikeCount | private function decrementLikeCount()
{
$counter = $this->likeCounter()->first();
if($counter) {
$counter->count--;
if($counter->count) {
$counter->save();
} else {
$counter->delete();
}
}
} | php | private function decrementLikeCount()
{
$counter = $this->likeCounter()->first();
if($counter) {
$counter->count--;
if($counter->count) {
$counter->save();
} else {
$counter->delete();
}
}
} | [
"private",
"function",
"decrementLikeCount",
"(",
")",
"{",
"$",
"counter",
"=",
"$",
"this",
"->",
"likeCounter",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"counter",
")",
"{",
"$",
"counter",
"->",
"count",
"--",
";",
"if",
"(",
"$"... | Private. Decrement the total like count stored in the counter | [
"Private",
".",
"Decrement",
"the",
"total",
"like",
"count",
"stored",
"in",
"the",
"counter"
] | d3b61686703a23a4aa61f593e55bc10b87f60621 | https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L150-L162 | train |
rtconner/laravel-likeable | src/Likeable.php | Likeable.removeLikes | public function removeLikes()
{
Like::where('likeable_type', $this->morphClass)->where('likeable_id', $this->id)->delete();
LikeCounter::where('likeable_type', $this->morphClass)->where('likeable_id', $this->id)->delete();
} | php | public function removeLikes()
{
Like::where('likeable_type', $this->morphClass)->where('likeable_id', $this->id)->delete();
LikeCounter::where('likeable_type', $this->morphClass)->where('likeable_id', $this->id)->delete();
} | [
"public",
"function",
"removeLikes",
"(",
")",
"{",
"Like",
"::",
"where",
"(",
"'likeable_type'",
",",
"$",
"this",
"->",
"morphClass",
")",
"->",
"where",
"(",
"'likeable_id'",
",",
"$",
"this",
"->",
"id",
")",
"->",
"delete",
"(",
")",
";",
"LikeCo... | Delete likes related to the current record | [
"Delete",
"likes",
"related",
"to",
"the",
"current",
"record"
] | d3b61686703a23a4aa61f593e55bc10b87f60621 | https://github.com/rtconner/laravel-likeable/blob/d3b61686703a23a4aa61f593e55bc10b87f60621/src/Likeable.php#L197-L202 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Managerarea/ManagersController.php | ManagersController.import | public function import(Manager $manager, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $manager,
'tabs' => 'managerarea.attributes.tabs',
'url' => route('managerarea.attributes.stash'),
'id' => "managerarea-attributes-{$manager->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
} | php | public function import(Manager $manager, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $manager,
'tabs' => 'managerarea.attributes.tabs',
'url' => route('managerarea.attributes.stash'),
'id' => "managerarea-attributes-{$manager->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
} | [
"public",
"function",
"import",
"(",
"Manager",
"$",
"manager",
",",
"ImportRecordsDataTable",
"$",
"importRecordsDataTable",
")",
"{",
"return",
"$",
"importRecordsDataTable",
"->",
"with",
"(",
"[",
"'resource'",
"=>",
"$",
"manager",
",",
"'tabs'",
"=>",
"'ma... | Import managers.
@param \Cortex\Auth\Models\Manager $manager
@param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable
@return \Illuminate\View\View | [
"Import",
"managers",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/ManagersController.php#L119-L127 | train |
laravie/codex | src/Support/Versioning.php | Versioning.proxyRequestViaVersion | protected function proxyRequestViaVersion(string $swapVersion, callable $callback): Response
{
$version = $this->version;
try {
$this->version = $swapVersion;
return \call_user_func($callback);
} finally {
$this->version = $version;
}
} | php | protected function proxyRequestViaVersion(string $swapVersion, callable $callback): Response
{
$version = $this->version;
try {
$this->version = $swapVersion;
return \call_user_func($callback);
} finally {
$this->version = $version;
}
} | [
"protected",
"function",
"proxyRequestViaVersion",
"(",
"string",
"$",
"swapVersion",
",",
"callable",
"$",
"callback",
")",
":",
"Response",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"version",
";",
"try",
"{",
"$",
"this",
"->",
"version",
"=",
"$",
... | Proxy route to response via other version.
@param string $swapVersion
@param callable $callback
@return \Laravie\Codex\Contracts\Response | [
"Proxy",
"route",
"to",
"response",
"via",
"other",
"version",
"."
] | 4d813bcbe20e7cf0b6c0cb98d3b077a070285709 | https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Support/Versioning.php#L27-L38 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Frontarea/PhoneVerificationController.php | PhoneVerificationController.send | public function send(PhoneVerificationSendRequest $request)
{
$user = $request->user($this->getGuard())
?? $request->attemptUser($this->getGuard())
?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $request->input('phone'))->first();
$user->sendPhoneVerificationNotification($request->get('method'), true);
return intend([
'url' => route('frontarea.verification.phone.verify', ['phone' => $user->phone]),
'with' => ['success' => trans('cortex/auth::messages.verification.phone.sent')],
]);
} | php | public function send(PhoneVerificationSendRequest $request)
{
$user = $request->user($this->getGuard())
?? $request->attemptUser($this->getGuard())
?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $request->input('phone'))->first();
$user->sendPhoneVerificationNotification($request->get('method'), true);
return intend([
'url' => route('frontarea.verification.phone.verify', ['phone' => $user->phone]),
'with' => ['success' => trans('cortex/auth::messages.verification.phone.sent')],
]);
} | [
"public",
"function",
"send",
"(",
"PhoneVerificationSendRequest",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"$",
"request",
"->",
"user",
"(",
"$",
"this",
"->",
"getGuard",
"(",
")",
")",
"??",
"$",
"request",
"->",
"attemptUser",
"(",
"$",
"this",
... | Process the phone verification request form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Frontarea\PhoneVerificationSendRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Process",
"the",
"phone",
"verification",
"request",
"form",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Frontarea/PhoneVerificationController.php#L37-L49 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Frontarea/PhoneVerificationController.php | PhoneVerificationController.process | public function process(PhoneVerificationProcessRequest $request)
{
// Guest trying to authenticate through TwoFactor
if (($attemptUser = $request->attemptUser($this->getGuard())) && $this->attemptTwoFactor($attemptUser, $request->get('token'))) {
auth()->guard($this->getGuard())->login($attemptUser, $request->session()->get('cortex.auth.twofactor.remember'));
$request->session()->forget('cortex.auth.twofactor'); // @TODO: Do we need to forget session, or it's already gone after login?
return intend([
'intended' => route('frontarea.home'),
'with' => ['success' => trans('cortex/auth::messages.auth.login')],
]);
}
// Logged in user OR A GUEST trying to verify phone
if (($user = $request->user($this->getGuard()) ?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $request->get('phone'))->first()) && $this->isValidTwoFactorPhone($user, $request->get('token'))) {
// Profile update
$user->fill([
'phone_verified_at' => now(),
])->forceSave();
return intend([
'url' => route('frontarea.account.settings'),
'with' => ['success' => trans('cortex/auth::messages.verification.phone.verified')],
]);
}
return intend([
'back' => true,
'withErrors' => ['token' => trans('cortex/auth::messages.verification.twofactor.invalid_token')],
]);
} | php | public function process(PhoneVerificationProcessRequest $request)
{
// Guest trying to authenticate through TwoFactor
if (($attemptUser = $request->attemptUser($this->getGuard())) && $this->attemptTwoFactor($attemptUser, $request->get('token'))) {
auth()->guard($this->getGuard())->login($attemptUser, $request->session()->get('cortex.auth.twofactor.remember'));
$request->session()->forget('cortex.auth.twofactor'); // @TODO: Do we need to forget session, or it's already gone after login?
return intend([
'intended' => route('frontarea.home'),
'with' => ['success' => trans('cortex/auth::messages.auth.login')],
]);
}
// Logged in user OR A GUEST trying to verify phone
if (($user = $request->user($this->getGuard()) ?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $request->get('phone'))->first()) && $this->isValidTwoFactorPhone($user, $request->get('token'))) {
// Profile update
$user->fill([
'phone_verified_at' => now(),
])->forceSave();
return intend([
'url' => route('frontarea.account.settings'),
'with' => ['success' => trans('cortex/auth::messages.verification.phone.verified')],
]);
}
return intend([
'back' => true,
'withErrors' => ['token' => trans('cortex/auth::messages.verification.twofactor.invalid_token')],
]);
} | [
"public",
"function",
"process",
"(",
"PhoneVerificationProcessRequest",
"$",
"request",
")",
"{",
"// Guest trying to authenticate through TwoFactor",
"if",
"(",
"(",
"$",
"attemptUser",
"=",
"$",
"request",
"->",
"attemptUser",
"(",
"$",
"this",
"->",
"getGuard",
... | Process the phone verification form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Frontarea\PhoneVerificationProcessRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Process",
"the",
"phone",
"verification",
"form",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Frontarea/PhoneVerificationController.php#L70-L100 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Tenantarea/AccountMediaController.php | AccountMediaController.destroy | public function destroy(Member $member, Media $media)
{
$member->media()->where($media->getKeyName(), $media->getKey())->first()->delete();
return intend([
'url' => route('frontarea.account.settings'),
'with' => [
'warning' => trans('cortex/foundation::messages.resource_deleted', [
'resource' => trans('cortex/foundation::common.media'),
'identifier' => $media->getRouteKey(),
]),
],
]);
} | php | public function destroy(Member $member, Media $media)
{
$member->media()->where($media->getKeyName(), $media->getKey())->first()->delete();
return intend([
'url' => route('frontarea.account.settings'),
'with' => [
'warning' => trans('cortex/foundation::messages.resource_deleted', [
'resource' => trans('cortex/foundation::common.media'),
'identifier' => $media->getRouteKey(),
]),
],
]);
} | [
"public",
"function",
"destroy",
"(",
"Member",
"$",
"member",
",",
"Media",
"$",
"media",
")",
"{",
"$",
"member",
"->",
"media",
"(",
")",
"->",
"where",
"(",
"$",
"media",
"->",
"getKeyName",
"(",
")",
",",
"$",
"media",
"->",
"getKey",
"(",
")"... | Destroy given member media.
@param \Cortex\Auth\Models\Member $member
@param \Spatie\MediaLibrary\Models\Media $media
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Destroy",
"given",
"member",
"media",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/AccountMediaController.php#L21-L34 | train |
laravie/codex | src/Client.php | Client.useVersion | public function useVersion(string $version)
{
if (! \array_key_exists($version, $this->supportedVersions)) {
throw new InvalidArgumentException("API version [{$version}] is not supported.");
}
$this->defaultVersion = $version;
return $this;
} | php | public function useVersion(string $version)
{
if (! \array_key_exists($version, $this->supportedVersions)) {
throw new InvalidArgumentException("API version [{$version}] is not supported.");
}
$this->defaultVersion = $version;
return $this;
} | [
"public",
"function",
"useVersion",
"(",
"string",
"$",
"version",
")",
"{",
"if",
"(",
"!",
"\\",
"array_key_exists",
"(",
"$",
"version",
",",
"$",
"this",
"->",
"supportedVersions",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"API ve... | Use different API version.
@param string $version
@throws \InvalidArgumentException
@return $this | [
"Use",
"different",
"API",
"version",
"."
] | 4d813bcbe20e7cf0b6c0cb98d3b077a070285709 | https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Client.php#L65-L74 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Tenantarea/EmailVerificationController.php | EmailVerificationController.send | public function send(EmailVerificationSendRequest $request)
{
$result = app('rinvex.auth.emailverification')
->broker($this->getEmailVerificationBroker())
->sendVerificationLink($request->only(['email']));
switch ($result) {
case EmailVerificationBrokerContract::LINK_SENT:
return intend([
'url' => route('tenantarea.home'),
'with' => ['success' => trans('cortex/auth::'.$result)],
]);
case EmailVerificationBrokerContract::INVALID_USER:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans('cortex/auth::'.$result)],
]);
}
} | php | public function send(EmailVerificationSendRequest $request)
{
$result = app('rinvex.auth.emailverification')
->broker($this->getEmailVerificationBroker())
->sendVerificationLink($request->only(['email']));
switch ($result) {
case EmailVerificationBrokerContract::LINK_SENT:
return intend([
'url' => route('tenantarea.home'),
'with' => ['success' => trans('cortex/auth::'.$result)],
]);
case EmailVerificationBrokerContract::INVALID_USER:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans('cortex/auth::'.$result)],
]);
}
} | [
"public",
"function",
"send",
"(",
"EmailVerificationSendRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"app",
"(",
"'rinvex.auth.emailverification'",
")",
"->",
"broker",
"(",
"$",
"this",
"->",
"getEmailVerificationBroker",
"(",
")",
")",
"->",
"sendV... | Process the email verification request form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Tenantarea\EmailVerificationSendRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Process",
"the",
"email",
"verification",
"request",
"form",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/EmailVerificationController.php#L34-L55 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Tenantarea/EmailVerificationController.php | EmailVerificationController.verify | public function verify(EmailVerificationProcessRequest $request)
{
$result = app('rinvex.auth.emailverification')
->broker($this->getEmailVerificationBroker())
->verify($request->only(['email', 'expiration', 'token']), function ($user) {
$user->fill([
'email_verified_at' => now(),
])->forceSave();
});
switch ($result) {
case EmailVerificationBrokerContract::EMAIL_VERIFIED:
return intend([
'url' => route('tenantarea.account.settings'),
'with' => ['success' => trans('cortex/auth::'.$result)],
]);
case EmailVerificationBrokerContract::INVALID_USER:
case EmailVerificationBrokerContract::INVALID_TOKEN:
case EmailVerificationBrokerContract::EXPIRED_TOKEN:
default:
return intend([
'url' => route('tenantarea.verification.email.request'),
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans('cortex/auth::'.$result)],
]);
}
} | php | public function verify(EmailVerificationProcessRequest $request)
{
$result = app('rinvex.auth.emailverification')
->broker($this->getEmailVerificationBroker())
->verify($request->only(['email', 'expiration', 'token']), function ($user) {
$user->fill([
'email_verified_at' => now(),
])->forceSave();
});
switch ($result) {
case EmailVerificationBrokerContract::EMAIL_VERIFIED:
return intend([
'url' => route('tenantarea.account.settings'),
'with' => ['success' => trans('cortex/auth::'.$result)],
]);
case EmailVerificationBrokerContract::INVALID_USER:
case EmailVerificationBrokerContract::INVALID_TOKEN:
case EmailVerificationBrokerContract::EXPIRED_TOKEN:
default:
return intend([
'url' => route('tenantarea.verification.email.request'),
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans('cortex/auth::'.$result)],
]);
}
} | [
"public",
"function",
"verify",
"(",
"EmailVerificationProcessRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"app",
"(",
"'rinvex.auth.emailverification'",
")",
"->",
"broker",
"(",
"$",
"this",
"->",
"getEmailVerificationBroker",
"(",
")",
")",
"->",
"... | Process the email verification.
@param \Cortex\Auth\B2B2C2\Http\Requests\Tenantarea\EmailVerificationProcessRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Process",
"the",
"email",
"verification",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/EmailVerificationController.php#L64-L91 | train |
contributte/cache | src/Storages/MemoryAdapterStorage.php | MemoryAdapterStorage.read | public function read($key)
{
// Get data from memory storage
$data = $this->memoryStorage->read($key);
if ($data !== null) {
return $data;
}
// Get data from cached storage and write them to memory storage
$data = $this->cachedStorage->read($key);
if ($data !== null) {
$this->memoryStorage->write($key, $data, []);
}
return $data;
} | php | public function read($key)
{
// Get data from memory storage
$data = $this->memoryStorage->read($key);
if ($data !== null) {
return $data;
}
// Get data from cached storage and write them to memory storage
$data = $this->cachedStorage->read($key);
if ($data !== null) {
$this->memoryStorage->write($key, $data, []);
}
return $data;
} | [
"public",
"function",
"read",
"(",
"$",
"key",
")",
"{",
"// Get data from memory storage",
"$",
"data",
"=",
"$",
"this",
"->",
"memoryStorage",
"->",
"read",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"null",
")",
"{",
"return",
"$",
... | Read from cache.
@param string $key
@return mixed|null
@phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint | [
"Read",
"from",
"cache",
"."
] | ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e | https://github.com/contributte/cache/blob/ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e/src/Storages/MemoryAdapterStorage.php#L30-L45 | train |
contributte/cache | src/Storages/MemoryAdapterStorage.php | MemoryAdapterStorage.write | public function write($key, $data, array $dependencies): void
{
$this->cachedStorage->write($key, $data, $dependencies);
$this->memoryStorage->write($key, $data, $dependencies);
} | php | public function write($key, $data, array $dependencies): void
{
$this->cachedStorage->write($key, $data, $dependencies);
$this->memoryStorage->write($key, $data, $dependencies);
} | [
"public",
"function",
"write",
"(",
"$",
"key",
",",
"$",
"data",
",",
"array",
"$",
"dependencies",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cachedStorage",
"->",
"write",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"dependencies",
")",
";",
"$... | Writes item into the cache.
@param string $key
@param mixed $data
@param mixed[] $dependencies
@phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint | [
"Writes",
"item",
"into",
"the",
"cache",
"."
] | ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e | https://github.com/contributte/cache/blob/ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e/src/Storages/MemoryAdapterStorage.php#L67-L71 | train |
contributte/cache | src/Storages/MemoryAdapterStorage.php | MemoryAdapterStorage.remove | public function remove($key): void
{
$this->cachedStorage->remove($key);
$this->memoryStorage->remove($key);
} | php | public function remove($key): void
{
$this->cachedStorage->remove($key);
$this->memoryStorage->remove($key);
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cachedStorage",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"memoryStorage",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"}"
] | Removes item from the cache.
@param string $key
@phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint | [
"Removes",
"item",
"from",
"the",
"cache",
"."
] | ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e | https://github.com/contributte/cache/blob/ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e/src/Storages/MemoryAdapterStorage.php#L79-L83 | train |
contributte/cache | src/Storages/MemoryAdapterStorage.php | MemoryAdapterStorage.clean | public function clean(array $conditions): void
{
$this->cachedStorage->clean($conditions);
$this->memoryStorage->clean($conditions);
} | php | public function clean(array $conditions): void
{
$this->cachedStorage->clean($conditions);
$this->memoryStorage->clean($conditions);
} | [
"public",
"function",
"clean",
"(",
"array",
"$",
"conditions",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cachedStorage",
"->",
"clean",
"(",
"$",
"conditions",
")",
";",
"$",
"this",
"->",
"memoryStorage",
"->",
"clean",
"(",
"$",
"conditions",
")",
... | Removes items from the cache by conditions.
@param mixed[] $conditions | [
"Removes",
"items",
"from",
"the",
"cache",
"by",
"conditions",
"."
] | ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e | https://github.com/contributte/cache/blob/ac4e8ee28cc23e21ac1e9aabef323d88f8beb15e/src/Storages/MemoryAdapterStorage.php#L90-L94 | train |
swoft-cloud/swoft-rpc-client | src/Service/ServiceProxy.php | ServiceProxy.getMethodsTemplate | private static function getMethodsTemplate(array $reflectionMethods): string
{
$template = "";
foreach ($reflectionMethods as $reflectionMethod) {
$methodName = $reflectionMethod->getName();
// not to overrided method
if ($reflectionMethod->isConstructor() || $reflectionMethod->isStatic() || strpos($methodName, '__') !== false) {
continue;
}
// the template of parameter
$template .= " public function $methodName (";
$template .= self::getParameterTemplate($reflectionMethod);
$template .= ' ) ';
// the template of return type
$reflectionMethodReturn = $reflectionMethod->getReturnType();
if ($reflectionMethodReturn !== null) {
$returnType = $reflectionMethodReturn->__toString();
$returnType = ($returnType == 'self') ? $reflectionMethod->getDeclaringClass()->getName() : $returnType;
$template .= " : $returnType";
}
// overrided method
$template
.= "{
\$params = func_get_args();
return \$this->call('{$methodName}', \$params);
}
";
}
return $template;
} | php | private static function getMethodsTemplate(array $reflectionMethods): string
{
$template = "";
foreach ($reflectionMethods as $reflectionMethod) {
$methodName = $reflectionMethod->getName();
// not to overrided method
if ($reflectionMethod->isConstructor() || $reflectionMethod->isStatic() || strpos($methodName, '__') !== false) {
continue;
}
// the template of parameter
$template .= " public function $methodName (";
$template .= self::getParameterTemplate($reflectionMethod);
$template .= ' ) ';
// the template of return type
$reflectionMethodReturn = $reflectionMethod->getReturnType();
if ($reflectionMethodReturn !== null) {
$returnType = $reflectionMethodReturn->__toString();
$returnType = ($returnType == 'self') ? $reflectionMethod->getDeclaringClass()->getName() : $returnType;
$template .= " : $returnType";
}
// overrided method
$template
.= "{
\$params = func_get_args();
return \$this->call('{$methodName}', \$params);
}
";
}
return $template;
} | [
"private",
"static",
"function",
"getMethodsTemplate",
"(",
"array",
"$",
"reflectionMethods",
")",
":",
"string",
"{",
"$",
"template",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"reflectionMethods",
"as",
"$",
"reflectionMethod",
")",
"{",
"$",
"methodName",
"="... | return template of method
@param \ReflectionMethod[] $reflectionMethods
@return string | [
"return",
"template",
"of",
"method"
] | f163834c9db7c1d45643347a49232152e42cd64a | https://github.com/swoft-cloud/swoft-rpc-client/blob/f163834c9db7c1d45643347a49232152e42cd64a/src/Service/ServiceProxy.php#L37-L71 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Tenantarea/SocialAuthenticationController.php | SocialAuthenticationController.createLocalUser | protected function createLocalUser(string $provider, array $attributes)
{
$localUser = app('cortex.auth.member');
$attributes['password'] = str_random();
$attributes['email_verified_at'] = now();
$attributes['is_active'] = ! config('cortex.auth.registration.moderated');
$localUser->fill($attributes)->save();
// Fire the register success event
event(new Registered($localUser));
$localUser->socialites()->create([
'provider' => $provider,
'provider_uid' => $attributes['id'],
]);
return $localUser;
} | php | protected function createLocalUser(string $provider, array $attributes)
{
$localUser = app('cortex.auth.member');
$attributes['password'] = str_random();
$attributes['email_verified_at'] = now();
$attributes['is_active'] = ! config('cortex.auth.registration.moderated');
$localUser->fill($attributes)->save();
// Fire the register success event
event(new Registered($localUser));
$localUser->socialites()->create([
'provider' => $provider,
'provider_uid' => $attributes['id'],
]);
return $localUser;
} | [
"protected",
"function",
"createLocalUser",
"(",
"string",
"$",
"provider",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"localUser",
"=",
"app",
"(",
"'cortex.auth.member'",
")",
";",
"$",
"attributes",
"[",
"'password'",
"]",
"=",
"str_random",
"(",
")"... | Create local user for the given provider.
@param string $provider
@param array $attributes
@return \Illuminate\Database\Eloquent\Model|null | [
"Create",
"local",
"user",
"for",
"the",
"given",
"provider",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/SocialAuthenticationController.php#L106-L125 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Managerarea/RolesController.php | RolesController.import | public function import(Role $role, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $role,
'tabs' => 'managerarea.roles.tabs',
'url' => route('managerarea.roles.stash'),
'id' => "managerarea-roles-{$role->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
} | php | public function import(Role $role, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $role,
'tabs' => 'managerarea.roles.tabs',
'url' => route('managerarea.roles.stash'),
'id' => "managerarea-roles-{$role->getRouteKey()}-import-table",
])->render('cortex/foundation::managerarea.pages.datatable-dropzone');
} | [
"public",
"function",
"import",
"(",
"Role",
"$",
"role",
",",
"ImportRecordsDataTable",
"$",
"importRecordsDataTable",
")",
"{",
"return",
"$",
"importRecordsDataTable",
"->",
"with",
"(",
"[",
"'resource'",
"=>",
"$",
"role",
",",
"'tabs'",
"=>",
"'managerarea... | Import roles.
@param \Cortex\Auth\Models\Role $role
@param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable
@return \Illuminate\View\View | [
"Import",
"roles",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/RolesController.php#L67-L75 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Managerarea/RolesController.php | RolesController.destroy | public function destroy(Role $role)
{
$role->delete();
return intend([
'url' => route('managerarea.roles.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.role'), 'identifier' => $role->title])],
]);
} | php | public function destroy(Role $role)
{
$role->delete();
return intend([
'url' => route('managerarea.roles.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.role'), 'identifier' => $role->title])],
]);
} | [
"public",
"function",
"destroy",
"(",
"Role",
"$",
"role",
")",
"{",
"$",
"role",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'managerarea.roles.index'",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
"=>",
"... | Destroy given role.
@param \Cortex\Auth\Models\Role $role
@throws \Exception
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Destroy",
"given",
"role",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/RolesController.php#L237-L245 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Tenantarea/PasswordResetController.php | PasswordResetController.send | public function send(PasswordResetSendRequest $request)
{
$result = app('auth.password')
->broker($this->getPasswordResetBroker())
->sendResetLink($request->only(['email']));
switch ($result) {
case PasswordResetBrokerContract::RESET_LINK_SENT:
return intend([
'url' => route('tenantarea.home'),
'with' => ['success' => trans($result)],
]);
case PasswordResetBrokerContract::INVALID_USER:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans($result)],
]);
}
} | php | public function send(PasswordResetSendRequest $request)
{
$result = app('auth.password')
->broker($this->getPasswordResetBroker())
->sendResetLink($request->only(['email']));
switch ($result) {
case PasswordResetBrokerContract::RESET_LINK_SENT:
return intend([
'url' => route('tenantarea.home'),
'with' => ['success' => trans($result)],
]);
case PasswordResetBrokerContract::INVALID_USER:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans($result)],
]);
}
} | [
"public",
"function",
"send",
"(",
"PasswordResetSendRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"app",
"(",
"'auth.password'",
")",
"->",
"broker",
"(",
"$",
"this",
"->",
"getPasswordResetBroker",
"(",
")",
")",
"->",
"sendResetLink",
"(",
"$",... | Process the password reset request form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Tenantarea\PasswordResetSendRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Process",
"the",
"password",
"reset",
"request",
"form",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/PasswordResetController.php#L35-L56 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Tenantarea/PasswordResetController.php | PasswordResetController.process | public function process(PasswordResetPostProcessRequest $request)
{
$result = app('auth.password')
->broker($this->getPasswordResetBroker())
->reset($request->only(['email', 'expiration', 'token', 'password', 'password_confirmation']), function ($user, $password) {
$user->fill([
'password' => $password,
'remember_token' => str_random(60),
])->forceSave();
});
switch ($result) {
case PasswordResetBrokerContract::PASSWORD_RESET:
return intend([
'url' => route('tenantarea.login'),
'with' => ['success' => trans($result)],
]);
case PasswordResetBrokerContract::INVALID_USER:
case PasswordResetBrokerContract::INVALID_TOKEN:
case PasswordResetBrokerContract::EXPIRED_TOKEN:
case PasswordResetBrokerContract::INVALID_PASSWORD:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans($result)],
]);
}
} | php | public function process(PasswordResetPostProcessRequest $request)
{
$result = app('auth.password')
->broker($this->getPasswordResetBroker())
->reset($request->only(['email', 'expiration', 'token', 'password', 'password_confirmation']), function ($user, $password) {
$user->fill([
'password' => $password,
'remember_token' => str_random(60),
])->forceSave();
});
switch ($result) {
case PasswordResetBrokerContract::PASSWORD_RESET:
return intend([
'url' => route('tenantarea.login'),
'with' => ['success' => trans($result)],
]);
case PasswordResetBrokerContract::INVALID_USER:
case PasswordResetBrokerContract::INVALID_TOKEN:
case PasswordResetBrokerContract::EXPIRED_TOKEN:
case PasswordResetBrokerContract::INVALID_PASSWORD:
default:
return intend([
'back' => true,
'withInput' => $request->only(['email']),
'withErrors' => ['email' => trans($result)],
]);
}
} | [
"public",
"function",
"process",
"(",
"PasswordResetPostProcessRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"app",
"(",
"'auth.password'",
")",
"->",
"broker",
"(",
"$",
"this",
"->",
"getPasswordResetBroker",
"(",
")",
")",
"->",
"reset",
"(",
"$... | Process the password reset form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Tenantarea\PasswordResetPostProcessRequest $request
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Process",
"the",
"password",
"reset",
"form",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Tenantarea/PasswordResetController.php#L79-L108 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Adminarea/MembersController.php | MembersController.import | public function import(Member $member, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $member,
'tabs' => 'adminarea.attributes.tabs',
'url' => route('adminarea.members.stash'),
'id' => "adminarea-attributes-{$member->getRouteKey()}-import-table",
])->render('cortex/foundation::adminarea.pages.datatable-dropzone');
} | php | public function import(Member $member, ImportRecordsDataTable $importRecordsDataTable)
{
return $importRecordsDataTable->with([
'resource' => $member,
'tabs' => 'adminarea.attributes.tabs',
'url' => route('adminarea.members.stash'),
'id' => "adminarea-attributes-{$member->getRouteKey()}-import-table",
])->render('cortex/foundation::adminarea.pages.datatable-dropzone');
} | [
"public",
"function",
"import",
"(",
"Member",
"$",
"member",
",",
"ImportRecordsDataTable",
"$",
"importRecordsDataTable",
")",
"{",
"return",
"$",
"importRecordsDataTable",
"->",
"with",
"(",
"[",
"'resource'",
"=>",
"$",
"member",
",",
"'tabs'",
"=>",
"'admin... | Import members.
@param \Cortex\Auth\Models\Member $member
@param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable
@return \Illuminate\View\View | [
"Import",
"members",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Adminarea/MembersController.php#L119-L127 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Managerarea/MembersController.php | MembersController.destroy | public function destroy(Member $member)
{
$member->delete();
return intend([
'url' => route('managerarea.members.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.member'), 'identifier' => $member->username])],
]);
} | php | public function destroy(Member $member)
{
$member->delete();
return intend([
'url' => route('managerarea.members.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.member'), 'identifier' => $member->username])],
]);
} | [
"public",
"function",
"destroy",
"(",
"Member",
"$",
"member",
")",
"{",
"$",
"member",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'managerarea.members.index'",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
"... | Destroy given member.
@param \Cortex\Auth\Models\Member $member
@throws \Exception
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Destroy",
"given",
"member",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/MembersController.php#L290-L298 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Managerarea/AccountTwoFactorController.php | AccountTwoFactorController.index | public function index(Request $request)
{
$twoFactor = $request->user($this->getGuard())->getTwoFactor();
return view('cortex/auth::managerarea.pages.account-twofactor', compact('twoFactor'));
} | php | public function index(Request $request)
{
$twoFactor = $request->user($this->getGuard())->getTwoFactor();
return view('cortex/auth::managerarea.pages.account-twofactor', compact('twoFactor'));
} | [
"public",
"function",
"index",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"twoFactor",
"=",
"$",
"request",
"->",
"user",
"(",
"$",
"this",
"->",
"getGuard",
"(",
")",
")",
"->",
"getTwoFactor",
"(",
")",
";",
"return",
"view",
"(",
"'cortex/auth::... | Show the account security form.
@param \Illuminate\Http\Request $request
@return \Illuminate\View\View | [
"Show",
"the",
"account",
"security",
"form",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Managerarea/AccountTwoFactorController.php#L23-L28 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Adminarea/ManagersMediaController.php | ManagersMediaController.destroy | public function destroy(Manager $manager, Media $media)
{
$manager->media()->where($media->getKeyName(), $media->getKey())->first()->delete();
return intend([
'url' => route('adminarea.managers.edit', ['manager' => $manager]),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])],
]);
} | php | public function destroy(Manager $manager, Media $media)
{
$manager->media()->where($media->getKeyName(), $media->getKey())->first()->delete();
return intend([
'url' => route('adminarea.managers.edit', ['manager' => $manager]),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])],
]);
} | [
"public",
"function",
"destroy",
"(",
"Manager",
"$",
"manager",
",",
"Media",
"$",
"media",
")",
"{",
"$",
"manager",
"->",
"media",
"(",
")",
"->",
"where",
"(",
"$",
"media",
"->",
"getKeyName",
"(",
")",
",",
"$",
"media",
"->",
"getKey",
"(",
... | Destroy given manager media.
@param \Cortex\Auth\Models\Manager $manager
@param \Spatie\MediaLibrary\Models\Media $media
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Destroy",
"given",
"manager",
"media",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Adminarea/ManagersMediaController.php#L46-L54 | train |
laravie/codex | src/Support/Responsable.php | Responsable.interactsWithResponse | protected function interactsWithResponse(Response $response): Response
{
if ($response instanceof Filterable && $this instanceof Filterable) {
$response->setFilterable($this->getFilterable());
}
if ($this->validateResponseAutomatically === true) {
$response->validate();
}
return $response;
} | php | protected function interactsWithResponse(Response $response): Response
{
if ($response instanceof Filterable && $this instanceof Filterable) {
$response->setFilterable($this->getFilterable());
}
if ($this->validateResponseAutomatically === true) {
$response->validate();
}
return $response;
} | [
"protected",
"function",
"interactsWithResponse",
"(",
"Response",
"$",
"response",
")",
":",
"Response",
"{",
"if",
"(",
"$",
"response",
"instanceof",
"Filterable",
"&&",
"$",
"this",
"instanceof",
"Filterable",
")",
"{",
"$",
"response",
"->",
"setFilterable"... | Interacts with Response.
@param \Laravie\Codex\Contracts\Response $response
@return \Laravie\Codex\Contracts\Response | [
"Interacts",
"with",
"Response",
"."
] | 4d813bcbe20e7cf0b6c0cb98d3b077a070285709 | https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Support/Responsable.php#L18-L29 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Adminarea/ManagersController.php | ManagersController.destroy | public function destroy(Manager $manager)
{
$manager->delete();
return intend([
'url' => route('adminarea.managers.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.manager'), 'identifier' => $manager->username])],
]);
} | php | public function destroy(Manager $manager)
{
$manager->delete();
return intend([
'url' => route('adminarea.managers.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.manager'), 'identifier' => $manager->username])],
]);
} | [
"public",
"function",
"destroy",
"(",
"Manager",
"$",
"manager",
")",
"{",
"$",
"manager",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'adminarea.managers.index'",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
... | Destroy given manager.
@param \Cortex\Auth\Models\Manager $manager
@throws \Exception
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Destroy",
"given",
"manager",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Adminarea/ManagersController.php#L294-L302 | train |
rinvex/cortex-auth-b2b2c2 | src/Http/Controllers/Frontarea/TenantRegistrationController.php | TenantRegistrationController.form | public function form(TenantRegistrationRequest $request)
{
$countries = collect(countries())->map(function ($country, $code) {
return [
'id' => $code,
'text' => $country['name'],
'emoji' => $country['emoji'],
];
})->values();
$languages = collect(languages())->pluck('name', 'iso_639_1');
return view('cortex/auth::frontarea.pages.tenant-registration', compact('countries', 'languages'));
} | php | public function form(TenantRegistrationRequest $request)
{
$countries = collect(countries())->map(function ($country, $code) {
return [
'id' => $code,
'text' => $country['name'],
'emoji' => $country['emoji'],
];
})->values();
$languages = collect(languages())->pluck('name', 'iso_639_1');
return view('cortex/auth::frontarea.pages.tenant-registration', compact('countries', 'languages'));
} | [
"public",
"function",
"form",
"(",
"TenantRegistrationRequest",
"$",
"request",
")",
"{",
"$",
"countries",
"=",
"collect",
"(",
"countries",
"(",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"country",
",",
"$",
"code",
")",
"{",
"return",
"[",
"... | Show the registration form.
@param \Cortex\Auth\B2B2C2\Http\Requests\Frontarea\TenantRegistrationRequest $request
@return \Illuminate\View\View | [
"Show",
"the",
"registration",
"form",
"."
] | 3152b5314f77910656ddaddfd1bf7aa8e2517905 | https://github.com/rinvex/cortex-auth-b2b2c2/blob/3152b5314f77910656ddaddfd1bf7aa8e2517905/src/Http/Controllers/Frontarea/TenantRegistrationController.php#L22-L34 | train |
laravie/codex | src/Concerns/Request/Multipart.php | Multipart.prepareMultipartRequestPayloads | final public function prepareMultipartRequestPayloads(array $headers = [], array $body = [], array $files = []): array
{
$multipart = (($headers['Content-Type'] ?? null) == 'multipart/form-data');
if (empty($files) && ! $multipart) {
return [$headers, $body];
}
$builder = new Builder(StreamFactoryDiscovery::find());
$this->addFilesToMultipartBuilder($builder, $files);
$this->addBodyToMultipartBuilder(
$builder, $this instanceof Filterable ? $this->filterRequest($body) : $body
);
$headers['Content-Type'] = 'multipart/form-data; boundary='.$builder->getBoundary();
return [$headers, $builder->build()];
} | php | final public function prepareMultipartRequestPayloads(array $headers = [], array $body = [], array $files = []): array
{
$multipart = (($headers['Content-Type'] ?? null) == 'multipart/form-data');
if (empty($files) && ! $multipart) {
return [$headers, $body];
}
$builder = new Builder(StreamFactoryDiscovery::find());
$this->addFilesToMultipartBuilder($builder, $files);
$this->addBodyToMultipartBuilder(
$builder, $this instanceof Filterable ? $this->filterRequest($body) : $body
);
$headers['Content-Type'] = 'multipart/form-data; boundary='.$builder->getBoundary();
return [$headers, $builder->build()];
} | [
"final",
"public",
"function",
"prepareMultipartRequestPayloads",
"(",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"array",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"files",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"multipart",
"=",
"(",
"(... | Prepare multipart request payloads.
@param array $headers
@param array $body
@param array $files
@return array | [
"Prepare",
"multipart",
"request",
"payloads",
"."
] | 4d813bcbe20e7cf0b6c0cb98d3b077a070285709 | https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Concerns/Request/Multipart.php#L56-L74 | train |
laravie/codex | src/Concerns/Request/Multipart.php | Multipart.addBodyToMultipartBuilder | final protected function addBodyToMultipartBuilder(Builder $builder, array $body, ?string $prefix = null): void
{
foreach ($body as $key => $value) {
$name = $key;
if (! \is_null($prefix)) {
$name = "{$prefix}[{$key}]";
}
if (\is_array($value)) {
$this->addBodyToMultipartBuilder($builder, $value, $name);
continue;
}
$builder->addResource($name, $value, ['Content-Type' => 'text/plain']);
}
} | php | final protected function addBodyToMultipartBuilder(Builder $builder, array $body, ?string $prefix = null): void
{
foreach ($body as $key => $value) {
$name = $key;
if (! \is_null($prefix)) {
$name = "{$prefix}[{$key}]";
}
if (\is_array($value)) {
$this->addBodyToMultipartBuilder($builder, $value, $name);
continue;
}
$builder->addResource($name, $value, ['Content-Type' => 'text/plain']);
}
} | [
"final",
"protected",
"function",
"addBodyToMultipartBuilder",
"(",
"Builder",
"$",
"builder",
",",
"array",
"$",
"body",
",",
"?",
"string",
"$",
"prefix",
"=",
"null",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"body",
"as",
"$",
"key",
"=>",
"$",
"... | Add body to multipart stream builder.
@param \Http\Message\MultipartStream\MultipartStreamBuilder $builder
@param array $body
@param string|null $prefix
@return void | [
"Add",
"body",
"to",
"multipart",
"stream",
"builder",
"."
] | 4d813bcbe20e7cf0b6c0cb98d3b077a070285709 | https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Concerns/Request/Multipart.php#L85-L101 | train |
laravie/codex | src/Concerns/Request/Multipart.php | Multipart.addFilesToMultipartBuilder | final protected function addFilesToMultipartBuilder(Builder $builder, array $files = []): void
{
foreach ($files as $key => $file) {
if (! \is_null($file)) {
$builder->addResource($key, fopen($file, 'r'));
}
}
} | php | final protected function addFilesToMultipartBuilder(Builder $builder, array $files = []): void
{
foreach ($files as $key => $file) {
if (! \is_null($file)) {
$builder->addResource($key, fopen($file, 'r'));
}
}
} | [
"final",
"protected",
"function",
"addFilesToMultipartBuilder",
"(",
"Builder",
"$",
"builder",
",",
"array",
"$",
"files",
"=",
"[",
"]",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
... | Add files to multipart stream builder.
@param \Http\Message\MultipartStream\MultipartStreamBuilder $builder
@param array $files
@return void | [
"Add",
"files",
"to",
"multipart",
"stream",
"builder",
"."
] | 4d813bcbe20e7cf0b6c0cb98d3b077a070285709 | https://github.com/laravie/codex/blob/4d813bcbe20e7cf0b6c0cb98d3b077a070285709/src/Concerns/Request/Multipart.php#L111-L118 | train |
byTestGear/laravel-accountable | src/Traits/Accountable.php | Accountable.updatedBy | public function updatedBy()
{
$relation = $this->belongsTo(
AccountableServiceProvider::userModel(),
config('accountable.column_names.updated_by')
);
return $this->userModelUsesSoftDeletes() ? $relation->withTrashed() : $relation;
} | php | public function updatedBy()
{
$relation = $this->belongsTo(
AccountableServiceProvider::userModel(),
config('accountable.column_names.updated_by')
);
return $this->userModelUsesSoftDeletes() ? $relation->withTrashed() : $relation;
} | [
"public",
"function",
"updatedBy",
"(",
")",
"{",
"$",
"relation",
"=",
"$",
"this",
"->",
"belongsTo",
"(",
"AccountableServiceProvider",
"::",
"userModel",
"(",
")",
",",
"config",
"(",
"'accountable.column_names.updated_by'",
")",
")",
";",
"return",
"$",
"... | Define the updated by relationship.
@return \Illuminate\Database\Eloquent\Relations\BelongsTo | [
"Define",
"the",
"updated",
"by",
"relationship",
"."
] | 17a4d45de255b0106c1e51ae8974dd83301b4aff | https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Traits/Accountable.php#L94-L102 | train |
byTestGear/laravel-accountable | src/Traits/Accountable.php | Accountable.scopeOnlyCreatedBy | public function scopeOnlyCreatedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.created_by'), $user->getKey());
} | php | public function scopeOnlyCreatedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.created_by'), $user->getKey());
} | [
"public",
"function",
"scopeOnlyCreatedBy",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"user",
")",
"{",
"return",
"$",
"query",
"->",
"where",
"(",
"config",
"(",
"'accountable.column_names.created_by'",
")",
",",
"$",
"user",
"->",
"getKey",
"(",
")"... | Scope a query to only include records created by a given user.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $user
@return \Illuminate\Database\Eloquent\Builder | [
"Scope",
"a",
"query",
"to",
"only",
"include",
"records",
"created",
"by",
"a",
"given",
"user",
"."
] | 17a4d45de255b0106c1e51ae8974dd83301b4aff | https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Traits/Accountable.php#L127-L130 | train |
byTestGear/laravel-accountable | src/Traits/Accountable.php | Accountable.scopeOnlyUpdatedBy | public function scopeOnlyUpdatedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.updated_by'), $user->getKey());
} | php | public function scopeOnlyUpdatedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.updated_by'), $user->getKey());
} | [
"public",
"function",
"scopeOnlyUpdatedBy",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"user",
")",
"{",
"return",
"$",
"query",
"->",
"where",
"(",
"config",
"(",
"'accountable.column_names.updated_by'",
")",
",",
"$",
"user",
"->",
"getKey",
"(",
")"... | Scope a query to only include records updated by a given user.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $user
@return \Illuminate\Database\Eloquent\Builder | [
"Scope",
"a",
"query",
"to",
"only",
"include",
"records",
"updated",
"by",
"a",
"given",
"user",
"."
] | 17a4d45de255b0106c1e51ae8974dd83301b4aff | https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Traits/Accountable.php#L152-L155 | train |
byTestGear/laravel-accountable | src/Traits/Accountable.php | Accountable.scopeOnlyDeletedBy | public function scopeOnlyDeletedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.deleted_by'), $user->getKey());
} | php | public function scopeOnlyDeletedBy(Builder $query, Model $user)
{
return $query->where(config('accountable.column_names.deleted_by'), $user->getKey());
} | [
"public",
"function",
"scopeOnlyDeletedBy",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"user",
")",
"{",
"return",
"$",
"query",
"->",
"where",
"(",
"config",
"(",
"'accountable.column_names.deleted_by'",
")",
",",
"$",
"user",
"->",
"getKey",
"(",
")"... | Scope a query to only include records deleted by a given user.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $user
@return \Illuminate\Database\Eloquent\Builder | [
"Scope",
"a",
"query",
"to",
"only",
"include",
"records",
"deleted",
"by",
"a",
"given",
"user",
"."
] | 17a4d45de255b0106c1e51ae8974dd83301b4aff | https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Traits/Accountable.php#L165-L168 | train |
byTestGear/laravel-accountable | src/AccountableServiceProvider.php | AccountableServiceProvider.userModel | public static function userModel()
{
$guard = self::authDriver();
return collect(config('auth.guards'))
->map(function ($guard) {
return config("auth.providers.{$guard['provider']}.model");
})->get($guard);
} | php | public static function userModel()
{
$guard = self::authDriver();
return collect(config('auth.guards'))
->map(function ($guard) {
return config("auth.providers.{$guard['provider']}.model");
})->get($guard);
} | [
"public",
"static",
"function",
"userModel",
"(",
")",
"{",
"$",
"guard",
"=",
"self",
"::",
"authDriver",
"(",
")",
";",
"return",
"collect",
"(",
"config",
"(",
"'auth.guards'",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"guard",
")",
"{",
"... | Returns the user model, based on the configured authentication driver.
@return string | [
"Returns",
"the",
"user",
"model",
"based",
"on",
"the",
"configured",
"authentication",
"driver",
"."
] | 17a4d45de255b0106c1e51ae8974dd83301b4aff | https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/AccountableServiceProvider.php#L52-L60 | train |
byTestGear/laravel-accountable | src/Observer/AccountableObserver.php | AccountableObserver.creating | public function creating($model)
{
if ($model->accountableEnabled()) {
$model->{$this->config['column_names']['created_by']} = $this->accountableUserId();
$model->{$this->config['column_names']['updated_by']} = $this->accountableUserId();
}
} | php | public function creating($model)
{
if ($model->accountableEnabled()) {
$model->{$this->config['column_names']['created_by']} = $this->accountableUserId();
$model->{$this->config['column_names']['updated_by']} = $this->accountableUserId();
}
} | [
"public",
"function",
"creating",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"accountableEnabled",
"(",
")",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"config",
"[",
"'column_names'",
"]",
"[",
"'created_by'",
"]",
"}",
"... | Store the user creating a record.
@param \Illuminate\Database\Eloquent\Model $model | [
"Store",
"the",
"user",
"creating",
"a",
"record",
"."
] | 17a4d45de255b0106c1e51ae8974dd83301b4aff | https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Observer/AccountableObserver.php#L38-L44 | train |
byTestGear/laravel-accountable | src/Observer/AccountableObserver.php | AccountableObserver.deleting | public function deleting($model)
{
if ($model->accountableEnabled() &&
collect(class_uses($model))->contains(SoftDeletes::class)) {
$model->{$this->config['column_names']['deleted_by']} = $this->accountableUserId();
$model->save();
}
} | php | public function deleting($model)
{
if ($model->accountableEnabled() &&
collect(class_uses($model))->contains(SoftDeletes::class)) {
$model->{$this->config['column_names']['deleted_by']} = $this->accountableUserId();
$model->save();
}
} | [
"public",
"function",
"deleting",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"accountableEnabled",
"(",
")",
"&&",
"collect",
"(",
"class_uses",
"(",
"$",
"model",
")",
")",
"->",
"contains",
"(",
"SoftDeletes",
"::",
"class",
")",
")"... | Store the user deleting a record.
@param \Illuminate\Database\Eloquent\Model $model | [
"Store",
"the",
"user",
"deleting",
"a",
"record",
"."
] | 17a4d45de255b0106c1e51ae8974dd83301b4aff | https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Observer/AccountableObserver.php#L63-L71 | train |
byTestGear/laravel-accountable | src/Accountable.php | Accountable.columns | public static function columns(Blueprint $table, $usesSoftDeletes = true)
{
self::addColumn($table, config('accountable.column_names.created_by'));
self::addColumn($table, config('accountable.column_names.updated_by'));
if ($usesSoftDeletes) {
self::addColumn($table, config('accountable.column_names.deleted_by'));
}
} | php | public static function columns(Blueprint $table, $usesSoftDeletes = true)
{
self::addColumn($table, config('accountable.column_names.created_by'));
self::addColumn($table, config('accountable.column_names.updated_by'));
if ($usesSoftDeletes) {
self::addColumn($table, config('accountable.column_names.deleted_by'));
}
} | [
"public",
"static",
"function",
"columns",
"(",
"Blueprint",
"$",
"table",
",",
"$",
"usesSoftDeletes",
"=",
"true",
")",
"{",
"self",
"::",
"addColumn",
"(",
"$",
"table",
",",
"config",
"(",
"'accountable.column_names.created_by'",
")",
")",
";",
"self",
"... | Add accountable.column_names to the table, including indexes.
@param \Illuminate\Database\Schema\Blueprint $table
@param bool $usesSoftDeletes | [
"Add",
"accountable",
".",
"column_names",
"to",
"the",
"table",
"including",
"indexes",
"."
] | 17a4d45de255b0106c1e51ae8974dd83301b4aff | https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Accountable.php#L15-L23 | train |
byTestGear/laravel-accountable | src/Accountable.php | Accountable.addColumn | public static function addColumn(Blueprint $table, string $name)
{
$table->unsignedInteger($name)->nullable();
$table->index($name);
} | php | public static function addColumn(Blueprint $table, string $name)
{
$table->unsignedInteger($name)->nullable();
$table->index($name);
} | [
"public",
"static",
"function",
"addColumn",
"(",
"Blueprint",
"$",
"table",
",",
"string",
"$",
"name",
")",
"{",
"$",
"table",
"->",
"unsignedInteger",
"(",
"$",
"name",
")",
"->",
"nullable",
"(",
")",
";",
"$",
"table",
"->",
"index",
"(",
"$",
"... | Add a single Accountable column to the table. Also creates an index.
@param \Illuminate\Database\Schema\Blueprint $table
@param string $name | [
"Add",
"a",
"single",
"Accountable",
"column",
"to",
"the",
"table",
".",
"Also",
"creates",
"an",
"index",
"."
] | 17a4d45de255b0106c1e51ae8974dd83301b4aff | https://github.com/byTestGear/laravel-accountable/blob/17a4d45de255b0106c1e51ae8974dd83301b4aff/src/Accountable.php#L31-L35 | train |
techdivision/import-product | src/Observers/UrlKeyObserver.php | UrlKeyObserver.makeUrlKeyUnique | protected function makeUrlKeyUnique($urlKey)
{
// initialize the entity type ID
$entityType = $this->getEntityType();
$entityTypeId = (integer) $entityType[MemberNames::ENTITY_TYPE_ID];
// initialize the store view ID, use the admin store view if no store view has
// been set, because the default url_key value has been set in admin store view
$storeId = $this->getSubject()->getRowStoreId(StoreViewCodes::ADMIN);
// initialize the counter
$counter = 0;
// initialize the counters
$matchingCounters = array();
$notMatchingCounters = array();
// pre-initialze the URL key to query for
$value = $urlKey;
do {
// try to load the attribute
$productVarcharAttribute = $this->getProductBunchProcessor()
->loadProductVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue(
MemberNames::URL_KEY,
$entityTypeId,
$storeId,
$value
);
// try to load the product's URL key
if ($productVarcharAttribute) {
// this IS the URL key of the passed entity
if ($this->isUrlKeyOf($productVarcharAttribute)) {
$matchingCounters[] = $counter;
} else {
$notMatchingCounters[] = $counter;
}
// prepare the next URL key to query for
$value = sprintf('%s-%d', $urlKey, ++$counter);
}
} while ($productVarcharAttribute);
// sort the array ascending according to the counter
asort($matchingCounters);
asort($notMatchingCounters);
// this IS the URL key of the passed entity => we've an UPDATE
if (sizeof($matchingCounters) > 0) {
// load highest counter
$counter = end($matchingCounters);
// if the counter is > 0, we've to append it to the new URL key
if ($counter > 0) {
$urlKey = sprintf('%s-%d', $urlKey, $counter);
}
} elseif (sizeof($notMatchingCounters) > 0) {
// create a new URL key by raising the counter
$newCounter = end($notMatchingCounters);
$urlKey = sprintf('%s-%d', $urlKey, ++$newCounter);
}
// return the passed URL key, if NOT
return $urlKey;
} | php | protected function makeUrlKeyUnique($urlKey)
{
// initialize the entity type ID
$entityType = $this->getEntityType();
$entityTypeId = (integer) $entityType[MemberNames::ENTITY_TYPE_ID];
// initialize the store view ID, use the admin store view if no store view has
// been set, because the default url_key value has been set in admin store view
$storeId = $this->getSubject()->getRowStoreId(StoreViewCodes::ADMIN);
// initialize the counter
$counter = 0;
// initialize the counters
$matchingCounters = array();
$notMatchingCounters = array();
// pre-initialze the URL key to query for
$value = $urlKey;
do {
// try to load the attribute
$productVarcharAttribute = $this->getProductBunchProcessor()
->loadProductVarcharAttributeByAttributeCodeAndEntityTypeIdAndStoreIdAndValue(
MemberNames::URL_KEY,
$entityTypeId,
$storeId,
$value
);
// try to load the product's URL key
if ($productVarcharAttribute) {
// this IS the URL key of the passed entity
if ($this->isUrlKeyOf($productVarcharAttribute)) {
$matchingCounters[] = $counter;
} else {
$notMatchingCounters[] = $counter;
}
// prepare the next URL key to query for
$value = sprintf('%s-%d', $urlKey, ++$counter);
}
} while ($productVarcharAttribute);
// sort the array ascending according to the counter
asort($matchingCounters);
asort($notMatchingCounters);
// this IS the URL key of the passed entity => we've an UPDATE
if (sizeof($matchingCounters) > 0) {
// load highest counter
$counter = end($matchingCounters);
// if the counter is > 0, we've to append it to the new URL key
if ($counter > 0) {
$urlKey = sprintf('%s-%d', $urlKey, $counter);
}
} elseif (sizeof($notMatchingCounters) > 0) {
// create a new URL key by raising the counter
$newCounter = end($notMatchingCounters);
$urlKey = sprintf('%s-%d', $urlKey, ++$newCounter);
}
// return the passed URL key, if NOT
return $urlKey;
} | [
"protected",
"function",
"makeUrlKeyUnique",
"(",
"$",
"urlKey",
")",
"{",
"// initialize the entity type ID",
"$",
"entityType",
"=",
"$",
"this",
"->",
"getEntityType",
"(",
")",
";",
"$",
"entityTypeId",
"=",
"(",
"integer",
")",
"$",
"entityType",
"[",
"Me... | Make's the passed URL key unique by adding the next number to the end.
@param string $urlKey The URL key to make unique
@return string The unique URL key | [
"Make",
"s",
"the",
"passed",
"URL",
"key",
"unique",
"by",
"adding",
"the",
"next",
"number",
"to",
"the",
"end",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Observers/UrlKeyObserver.php#L159-L224 | train |
techdivision/import-product | src/Repositories/ProductWebsiteRepository.php | ProductWebsiteRepository.findOneByProductIdAndWebsite | public function findOneByProductIdAndWebsite($productId, $websiteId)
{
// prepare the params
$params = array(
MemberNames::PRODUCT_ID => $productId,
MemberNames::WEBSITE_ID => $websiteId
);
// load and return the product with the passed product/website ID
$this->productWebsiteStmt->execute($params);
return $this->productWebsiteStmt->fetch(\PDO::FETCH_ASSOC);
} | php | public function findOneByProductIdAndWebsite($productId, $websiteId)
{
// prepare the params
$params = array(
MemberNames::PRODUCT_ID => $productId,
MemberNames::WEBSITE_ID => $websiteId
);
// load and return the product with the passed product/website ID
$this->productWebsiteStmt->execute($params);
return $this->productWebsiteStmt->fetch(\PDO::FETCH_ASSOC);
} | [
"public",
"function",
"findOneByProductIdAndWebsite",
"(",
"$",
"productId",
",",
"$",
"websiteId",
")",
"{",
"// prepare the params",
"$",
"params",
"=",
"array",
"(",
"MemberNames",
"::",
"PRODUCT_ID",
"=>",
"$",
"productId",
",",
"MemberNames",
"::",
"WEBSITE_I... | Load's and return's the product website relation with the passed product and website ID.
@param string $productId The product ID of the relation
@param string $websiteId The website ID of the relation
@return array The product website | [
"Load",
"s",
"and",
"return",
"s",
"the",
"product",
"website",
"relation",
"with",
"the",
"passed",
"product",
"and",
"website",
"ID",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Repositories/ProductWebsiteRepository.php#L67-L79 | train |
contributte/thepay-api | src/DataApi/Processors/Digester.php | Digester.processItem | protected function processItem($value): string
{
if (Utils::isList($value)) {
return $this->processList($value);
}
return $this->processHash($value);
} | php | protected function processItem($value): string
{
if (Utils::isList($value)) {
return $this->processList($value);
}
return $this->processHash($value);
} | [
"protected",
"function",
"processItem",
"(",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"Utils",
"::",
"isList",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"processList",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"... | Hashes, lists and booleans are treated specially. Other values are simply
converted to strings, strings are left untouched.
@param mixed $value | [
"Hashes",
"lists",
"and",
"booleans",
"are",
"treated",
"specially",
".",
"Other",
"values",
"are",
"simply",
"converted",
"to",
"strings",
"strings",
"are",
"left",
"untouched",
"."
] | 7e28eaf30ad1880533add93cf9e7296e61c09b8e | https://github.com/contributte/thepay-api/blob/7e28eaf30ad1880533add93cf9e7296e61c09b8e/src/DataApi/Processors/Digester.php#L69-L76 | train |
contributte/thepay-api | src/ReturnedPayment.php | ReturnedPayment.verifySignature | public function verifySignature(?string $signature = null): bool
{
// check merchantId and accountId from request
if (
$this->getRequestMerchantId() !== $this->getMerchantConfig()->merchantId
|| $this->getRequestAccountId() !== $this->getMerchantConfig()->accountId
) {
throw new InvalidSignatureException();
}
if ($signature === null) {
$signature = $this->signature;
}
// Compute the signature for specified arguments, and compare it to the specified signature.
$out = [];
$out[] = 'merchantId=' . $this->getRequestMerchantId();
$out[] = 'accountId=' . $this->getRequestAccountId();
foreach (array_merge(self::$REQUIRED_ARGS, self::$OPTIONAL_ARGS) as $property) {
if ($this->{$property} !== null) {
$value = $this->{$property};
if (in_array($property, self::$FLOAT_ARGS, true)) {
$value = number_format($value, 2, '.', '');
} elseif (in_array($property, self::$BOOL_ARGS, true)) {
$value = $value ? '1' : '0';
}
$out[] = sprintf('%s=%s', $property, $value);
}
}
$out[] = 'password=' . $this->getMerchantConfig()->password;
$sig = $this->hashFunction(implode('&', $out));
if ($sig === $signature) {
return true;
}
throw new InvalidSignatureException();
} | php | public function verifySignature(?string $signature = null): bool
{
// check merchantId and accountId from request
if (
$this->getRequestMerchantId() !== $this->getMerchantConfig()->merchantId
|| $this->getRequestAccountId() !== $this->getMerchantConfig()->accountId
) {
throw new InvalidSignatureException();
}
if ($signature === null) {
$signature = $this->signature;
}
// Compute the signature for specified arguments, and compare it to the specified signature.
$out = [];
$out[] = 'merchantId=' . $this->getRequestMerchantId();
$out[] = 'accountId=' . $this->getRequestAccountId();
foreach (array_merge(self::$REQUIRED_ARGS, self::$OPTIONAL_ARGS) as $property) {
if ($this->{$property} !== null) {
$value = $this->{$property};
if (in_array($property, self::$FLOAT_ARGS, true)) {
$value = number_format($value, 2, '.', '');
} elseif (in_array($property, self::$BOOL_ARGS, true)) {
$value = $value ? '1' : '0';
}
$out[] = sprintf('%s=%s', $property, $value);
}
}
$out[] = 'password=' . $this->getMerchantConfig()->password;
$sig = $this->hashFunction(implode('&', $out));
if ($sig === $signature) {
return true;
}
throw new InvalidSignatureException();
} | [
"public",
"function",
"verifySignature",
"(",
"?",
"string",
"$",
"signature",
"=",
"null",
")",
":",
"bool",
"{",
"// check merchantId and accountId from request",
"if",
"(",
"$",
"this",
"->",
"getRequestMerchantId",
"(",
")",
"!==",
"$",
"this",
"->",
"getMer... | Use this call to verify signature of the payment.
this method is called automatically.
@return true if signature is valid, otherwise throws
a Tp\TpInvalidSignatureException.
@throws InvalidSignatureException , when signature isinvalid. | [
"Use",
"this",
"call",
"to",
"verify",
"signature",
"of",
"the",
"payment",
".",
"this",
"method",
"is",
"called",
"automatically",
"."
] | 7e28eaf30ad1880533add93cf9e7296e61c09b8e | https://github.com/contributte/thepay-api/blob/7e28eaf30ad1880533add93cf9e7296e61c09b8e/src/ReturnedPayment.php#L219-L261 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowlogger.php | OxpsPaymorrowLogger.log | public function log( array $aInfo )
{
/** @var $oPmSettings OxpsPaymorrowSettings */
$oPmSettings = oxNew( 'OxpsPaymorrowSettings' );
return $oPmSettings->isLoggingEnabled()
? $this->_saveToFile( $this->_toConvertToString( $aInfo ) )
: false;
} | php | public function log( array $aInfo )
{
/** @var $oPmSettings OxpsPaymorrowSettings */
$oPmSettings = oxNew( 'OxpsPaymorrowSettings' );
return $oPmSettings->isLoggingEnabled()
? $this->_saveToFile( $this->_toConvertToString( $aInfo ) )
: false;
} | [
"public",
"function",
"log",
"(",
"array",
"$",
"aInfo",
")",
"{",
"/** @var $oPmSettings OxpsPaymorrowSettings */",
"$",
"oPmSettings",
"=",
"oxNew",
"(",
"'OxpsPaymorrowSettings'",
")",
";",
"return",
"$",
"oPmSettings",
"->",
"isLoggingEnabled",
"(",
")",
"?",
... | Method that writes the given info to the log.
@param array $aInfo
@return bool|string | [
"Method",
"that",
"writes",
"the",
"given",
"info",
"to",
"the",
"log",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L89-L97 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowlogger.php | OxpsPaymorrowLogger.logWithType | public function logWithType( array $aInfo, $sType = '' )
{
$this->setFileName( sprintf( "oxpspaymorrow_%s_data-%s_log.txt", $sType, date( 'Y-m-d' ) ) );
$this->log( $aInfo );
} | php | public function logWithType( array $aInfo, $sType = '' )
{
$this->setFileName( sprintf( "oxpspaymorrow_%s_data-%s_log.txt", $sType, date( 'Y-m-d' ) ) );
$this->log( $aInfo );
} | [
"public",
"function",
"logWithType",
"(",
"array",
"$",
"aInfo",
",",
"$",
"sType",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"setFileName",
"(",
"sprintf",
"(",
"\"oxpspaymorrow_%s_data-%s_log.txt\"",
",",
"$",
"sType",
",",
"date",
"(",
"'Y-m-d'",
")",
")"... | Logs Paymorrow to file with type and date appended.
@param array $aInfo
@param string $sType | [
"Logs",
"Paymorrow",
"to",
"file",
"with",
"type",
"and",
"date",
"appended",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L105-L109 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowlogger.php | OxpsPaymorrowLogger.getContents | public function getContents()
{
$sErrorLogPath = $this->getErrorLogPathWithName();
$sLog = '';
if ( is_file( $sErrorLogPath ) ) {
$fErrorLog = fopen( $sErrorLogPath, "r" );
while ( !feof( $fErrorLog ) ) {
$sLog .= trim( fgets( $fErrorLog, 4096 ) ) . PHP_EOL;
}
fclose( $fErrorLog );
}
return $sLog;
} | php | public function getContents()
{
$sErrorLogPath = $this->getErrorLogPathWithName();
$sLog = '';
if ( is_file( $sErrorLogPath ) ) {
$fErrorLog = fopen( $sErrorLogPath, "r" );
while ( !feof( $fErrorLog ) ) {
$sLog .= trim( fgets( $fErrorLog, 4096 ) ) . PHP_EOL;
}
fclose( $fErrorLog );
}
return $sLog;
} | [
"public",
"function",
"getContents",
"(",
")",
"{",
"$",
"sErrorLogPath",
"=",
"$",
"this",
"->",
"getErrorLogPathWithName",
"(",
")",
";",
"$",
"sLog",
"=",
"''",
";",
"if",
"(",
"is_file",
"(",
"$",
"sErrorLogPath",
")",
")",
"{",
"$",
"fErrorLog",
"... | Get error log file contents.
@return string | [
"Get",
"error",
"log",
"file",
"contents",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L116-L133 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowlogger.php | OxpsPaymorrowLogger.getAllContents | public function getAllContents()
{
$sLog = '';
$sFormat = "----------------------------------------------------------------------\n" .
"%s\n" .
"----------------------------------------------------------------------\n\n" .
"%s\n\n";
$sLogDirectoryPath = $this->getErrorLogPath();
$hDir = @opendir( $sLogDirectoryPath );
if ( !empty( $hDir ) ) {
while ( false !== ( $sFileName = readdir( $hDir ) ) ) {
$sLog .= $this->_getFormattedContents( $sLogDirectoryPath, $sFileName, $sFormat );
}
}
return $sLog;
} | php | public function getAllContents()
{
$sLog = '';
$sFormat = "----------------------------------------------------------------------\n" .
"%s\n" .
"----------------------------------------------------------------------\n\n" .
"%s\n\n";
$sLogDirectoryPath = $this->getErrorLogPath();
$hDir = @opendir( $sLogDirectoryPath );
if ( !empty( $hDir ) ) {
while ( false !== ( $sFileName = readdir( $hDir ) ) ) {
$sLog .= $this->_getFormattedContents( $sLogDirectoryPath, $sFileName, $sFormat );
}
}
return $sLog;
} | [
"public",
"function",
"getAllContents",
"(",
")",
"{",
"$",
"sLog",
"=",
"''",
";",
"$",
"sFormat",
"=",
"\"----------------------------------------------------------------------\\n\"",
".",
"\"%s\\n\"",
".",
"\"--------------------------------------------------------------------... | Get all error log files contents.
@return string | [
"Get",
"all",
"error",
"log",
"files",
"contents",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L140-L158 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowlogger.php | OxpsPaymorrowLogger.getErrorLogPath | public function getErrorLogPath()
{
$sLogPath = $this->_sErrorLogPath;
if ( !is_dir( $sLogPath ) ) {
mkdir( $sLogPath, 0777, true );
}
return $sLogPath;
} | php | public function getErrorLogPath()
{
$sLogPath = $this->_sErrorLogPath;
if ( !is_dir( $sLogPath ) ) {
mkdir( $sLogPath, 0777, true );
}
return $sLogPath;
} | [
"public",
"function",
"getErrorLogPath",
"(",
")",
"{",
"$",
"sLogPath",
"=",
"$",
"this",
"->",
"_sErrorLogPath",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"sLogPath",
")",
")",
"{",
"mkdir",
"(",
"$",
"sLogPath",
",",
"0777",
",",
"true",
")",
";",
... | Get error log directory full path.
Also creates missing log folders is needed.
@return bool|string | [
"Get",
"error",
"log",
"directory",
"full",
"path",
".",
"Also",
"creates",
"missing",
"log",
"folders",
"is",
"needed",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L166-L175 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowlogger.php | OxpsPaymorrowLogger._toConvertToString | protected function _toConvertToString( $aArray )
{
$sResult = date( "Y-m-d H:i:s", oxRegistry::get( "oxUtilsDate" )->getTime() ) . PHP_EOL;
$sResult .= str_repeat( '=', 60 ) . PHP_EOL;
foreach ( $aArray as $sKey => $sValue ) {
$sResult .= " $sKey: $sValue" . PHP_EOL;
}
$sResult .= str_repeat( '=', 60 ) . PHP_EOL . PHP_EOL;
return $sResult;
} | php | protected function _toConvertToString( $aArray )
{
$sResult = date( "Y-m-d H:i:s", oxRegistry::get( "oxUtilsDate" )->getTime() ) . PHP_EOL;
$sResult .= str_repeat( '=', 60 ) . PHP_EOL;
foreach ( $aArray as $sKey => $sValue ) {
$sResult .= " $sKey: $sValue" . PHP_EOL;
}
$sResult .= str_repeat( '=', 60 ) . PHP_EOL . PHP_EOL;
return $sResult;
} | [
"protected",
"function",
"_toConvertToString",
"(",
"$",
"aArray",
")",
"{",
"$",
"sResult",
"=",
"date",
"(",
"\"Y-m-d H:i:s\"",
",",
"oxRegistry",
"::",
"get",
"(",
"\"oxUtilsDate\"",
")",
"->",
"getTime",
"(",
")",
")",
".",
"PHP_EOL",
";",
"$",
"sResul... | Converts the data array to string and returns it.
@param $aArray array that needs to be converted
@return string | [
"Converts",
"the",
"data",
"array",
"to",
"string",
"and",
"returns",
"it",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L232-L244 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowlogger.php | OxpsPaymorrowLogger._getFormattedContents | protected function _getFormattedContents( $sLogDirectoryPath, $sFileName, $sFormat )
{
$sFilePath = $sLogDirectoryPath . '/' . $sFileName;
if ( in_array( $sFileName, array('.', '..', '.htaccess') ) or !is_file( $sFilePath ) ) {
return '';
}
$this->setFileName( $sFileName );
return sprintf( $sFormat, $sFileName, $this->getContents() );
} | php | protected function _getFormattedContents( $sLogDirectoryPath, $sFileName, $sFormat )
{
$sFilePath = $sLogDirectoryPath . '/' . $sFileName;
if ( in_array( $sFileName, array('.', '..', '.htaccess') ) or !is_file( $sFilePath ) ) {
return '';
}
$this->setFileName( $sFileName );
return sprintf( $sFormat, $sFileName, $this->getContents() );
} | [
"protected",
"function",
"_getFormattedContents",
"(",
"$",
"sLogDirectoryPath",
",",
"$",
"sFileName",
",",
"$",
"sFormat",
")",
"{",
"$",
"sFilePath",
"=",
"$",
"sLogDirectoryPath",
".",
"'/'",
".",
"$",
"sFileName",
";",
"if",
"(",
"in_array",
"(",
"$",
... | Get formatted log file content.
@param string $sLogDirectoryPath Log folder path.
@param string $sFileName Log file name.
@param string $sFormat Output format string.
@return string | [
"Get",
"formatted",
"log",
"file",
"content",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowlogger.php#L255-L266 | train |
moodev/php-weasel | lib/Weasel/Annotation/AnnotationReader.php | AnnotationReader.setLogger | public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
if (isset($logger)) {
$this->parser->setLogger($logger);
$this->nsParser->setLogger($logger);
}
} | php | public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
if (isset($logger)) {
$this->parser->setLogger($logger);
$this->nsParser->setLogger($logger);
}
} | [
"public",
"function",
"setLogger",
"(",
"LoggerInterface",
"$",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"=",
"$",
"logger",
";",
"if",
"(",
"isset",
"(",
"$",
"logger",
")",
")",
"{",
"$",
"this",
"->",
"parser",
"->",
"setLogger",
"(",
"$",... | Sets a logger instance on the mixed
@param LoggerInterface $logger
@return null | [
"Sets",
"a",
"logger",
"instance",
"on",
"the",
"mixed"
] | fecc7cc06cae719489cb4490f414ed6530e70831 | https://github.com/moodev/php-weasel/blob/fecc7cc06cae719489cb4490f414ed6530e70831/lib/Weasel/Annotation/AnnotationReader.php#L243-L250 | train |
techdivision/import-product | src/Services/ProductBunchProcessor.php | ProductBunchProcessor.loadEavAttributeOptionValueByAttributeCodeAndStoreIdAndValue | public function loadEavAttributeOptionValueByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value)
{
return $this->getEavAttributeOptionValueRepository()->findOneByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value);
} | php | public function loadEavAttributeOptionValueByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value)
{
return $this->getEavAttributeOptionValueRepository()->findOneByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value);
} | [
"public",
"function",
"loadEavAttributeOptionValueByAttributeCodeAndStoreIdAndValue",
"(",
"$",
"attributeCode",
",",
"$",
"storeId",
",",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"getEavAttributeOptionValueRepository",
"(",
")",
"->",
"findOneByAttributeCodeA... | Load's and return's the EAV attribute option value with the passed code, store ID and value.
@param string $attributeCode The code of the EAV attribute option to load
@param integer $storeId The store ID of the attribute option to load
@param string $value The value of the attribute option to load
@return array The EAV attribute option value
@deprecated Since 5.0.0
@see \TechDivision\Import\Services\EavAwareProcessorInterface::loadAttributeOptionValueByEntityTypeIdAndAttributeCodeAndStoreIdAndValue() | [
"Load",
"s",
"and",
"return",
"s",
"the",
"EAV",
"attribute",
"option",
"value",
"with",
"the",
"passed",
"code",
"store",
"ID",
"and",
"value",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Services/ProductBunchProcessor.php#L913-L916 | train |
techdivision/import-product | src/Services/ProductBunchProcessor.php | ProductBunchProcessor.persistProduct | public function persistProduct($product, $name = null)
{
// persist the new entity and return the ID
$id = $this->getProductAction()->persist($product, $name);
// add the product to the cache, register the SKU reference as well
$this->getProductRepository()->toCache($product[MemberNames::SKU], $product, array($product[MemberNames::SKU] => $id));
// return the ID of the persisted product
return $id;
} | php | public function persistProduct($product, $name = null)
{
// persist the new entity and return the ID
$id = $this->getProductAction()->persist($product, $name);
// add the product to the cache, register the SKU reference as well
$this->getProductRepository()->toCache($product[MemberNames::SKU], $product, array($product[MemberNames::SKU] => $id));
// return the ID of the persisted product
return $id;
} | [
"public",
"function",
"persistProduct",
"(",
"$",
"product",
",",
"$",
"name",
"=",
"null",
")",
"{",
"// persist the new entity and return the ID",
"$",
"id",
"=",
"$",
"this",
"->",
"getProductAction",
"(",
")",
"->",
"persist",
"(",
"$",
"product",
",",
"... | Persist's the passed product data and return's the ID.
@param array $product The product data to persist
@param string|null $name The name of the prepared statement that has to be executed
@return string The ID of the persisted entity | [
"Persist",
"s",
"the",
"passed",
"product",
"data",
"and",
"return",
"s",
"the",
"ID",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Services/ProductBunchProcessor.php#L1020-L1031 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowerrorhandler.php | OxpsPaymorrowErrorHandler.getErrorByCode | public function getErrorByCode( $iErrorCode )
{
return array_key_exists( $iErrorCode, $this->_aPublicErrors )
? $this->translateError( $this->_aPublicErrors[$iErrorCode] )
: $this->translateError( $this->_aPublicErrors[3000] ); // If exact error not exist throw general
} | php | public function getErrorByCode( $iErrorCode )
{
return array_key_exists( $iErrorCode, $this->_aPublicErrors )
? $this->translateError( $this->_aPublicErrors[$iErrorCode] )
: $this->translateError( $this->_aPublicErrors[3000] ); // If exact error not exist throw general
} | [
"public",
"function",
"getErrorByCode",
"(",
"$",
"iErrorCode",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"iErrorCode",
",",
"$",
"this",
"->",
"_aPublicErrors",
")",
"?",
"$",
"this",
"->",
"translateError",
"(",
"$",
"this",
"->",
"_aPublicErrors",
... | Get human readable error message by error code.
@param integer $iErrorCode
@return string | [
"Get",
"human",
"readable",
"error",
"message",
"by",
"error",
"code",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowerrorhandler.php#L58-L63 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowerrorhandler.php | OxpsPaymorrowErrorHandler.redirectWithError | public function redirectWithError( $iErrorCode, $sController = 'order' )
{
$sErrorMessage = $this->getErrorByCode( $iErrorCode );
// Set error
$oEx = oxNew( 'oxExceptionToDisplay' );
$oEx->setMessage( $sErrorMessage );
oxRegistry::get( "oxUtilsView" )->addErrorToDisplay( $oEx, false );
// Redirect (refresh page)
$sUrl = $this->getConfig()->getShopCurrentUrl() . "cl=" . $sController;
$sUrl = oxRegistry::get( "oxUtilsUrl" )->processUrl( $sUrl );
oxRegistry::getUtils()->redirect( $sUrl );
return;
} | php | public function redirectWithError( $iErrorCode, $sController = 'order' )
{
$sErrorMessage = $this->getErrorByCode( $iErrorCode );
// Set error
$oEx = oxNew( 'oxExceptionToDisplay' );
$oEx->setMessage( $sErrorMessage );
oxRegistry::get( "oxUtilsView" )->addErrorToDisplay( $oEx, false );
// Redirect (refresh page)
$sUrl = $this->getConfig()->getShopCurrentUrl() . "cl=" . $sController;
$sUrl = oxRegistry::get( "oxUtilsUrl" )->processUrl( $sUrl );
oxRegistry::getUtils()->redirect( $sUrl );
return;
} | [
"public",
"function",
"redirectWithError",
"(",
"$",
"iErrorCode",
",",
"$",
"sController",
"=",
"'order'",
")",
"{",
"$",
"sErrorMessage",
"=",
"$",
"this",
"->",
"getErrorByCode",
"(",
"$",
"iErrorCode",
")",
";",
"// Set error",
"$",
"oEx",
"=",
"oxNew",
... | Redirect user to given controller and shows an error.
In case of 'RELOAD_CONFIGURATION_REQUIRED' error, update module settings and redirect.
@codeCoverageIgnore
@param $iErrorCode
@param string $sController | [
"Redirect",
"user",
"to",
"given",
"controller",
"and",
"shows",
"an",
"error",
".",
"In",
"case",
"of",
"RELOAD_CONFIGURATION_REQUIRED",
"error",
"update",
"module",
"settings",
"and",
"redirect",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowerrorhandler.php#L74-L89 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowmodule.php | OxpsPaymorrowModule.cleanTmp | public static function cleanTmp( $sClearFolderPath = '' )
{
$sTempFolderPath = realpath(oxRegistry::getConfig()->getConfigParam( 'sCompileDir' ));
if ( !empty( $sClearFolderPath ) and
( strpos( $sClearFolderPath, $sTempFolderPath ) !== false ) and
is_dir( $sClearFolderPath )
) {
// User argument folder path to delete from
$sFolderPath = $sClearFolderPath;
} elseif ( empty( $sClearFolderPath ) ) {
// Use temp folder path from settings
$sFolderPath = $sTempFolderPath;
} else {
return false;
}
$hDir = opendir( $sFolderPath );
if ( !empty( $hDir ) ) {
while ( false !== ( $sFileName = readdir( $hDir ) ) ) {
$sFilePath = $sFolderPath . '/' . $sFileName;
if ( !in_array( $sFileName, array('.', '..', '.htaccess') ) and is_file( $sFilePath ) ) {
// Delete a file if it is allowed to delete
@unlink( $sFilePath );
} elseif ( $sFileName == 'smarty' and is_dir( $sFilePath ) ) {
// Recursive call to clean Smarty temp
self::cleanTmp( $sFilePath );
}
}
}
return true;
} | php | public static function cleanTmp( $sClearFolderPath = '' )
{
$sTempFolderPath = realpath(oxRegistry::getConfig()->getConfigParam( 'sCompileDir' ));
if ( !empty( $sClearFolderPath ) and
( strpos( $sClearFolderPath, $sTempFolderPath ) !== false ) and
is_dir( $sClearFolderPath )
) {
// User argument folder path to delete from
$sFolderPath = $sClearFolderPath;
} elseif ( empty( $sClearFolderPath ) ) {
// Use temp folder path from settings
$sFolderPath = $sTempFolderPath;
} else {
return false;
}
$hDir = opendir( $sFolderPath );
if ( !empty( $hDir ) ) {
while ( false !== ( $sFileName = readdir( $hDir ) ) ) {
$sFilePath = $sFolderPath . '/' . $sFileName;
if ( !in_array( $sFileName, array('.', '..', '.htaccess') ) and is_file( $sFilePath ) ) {
// Delete a file if it is allowed to delete
@unlink( $sFilePath );
} elseif ( $sFileName == 'smarty' and is_dir( $sFilePath ) ) {
// Recursive call to clean Smarty temp
self::cleanTmp( $sFilePath );
}
}
}
return true;
} | [
"public",
"static",
"function",
"cleanTmp",
"(",
"$",
"sClearFolderPath",
"=",
"''",
")",
"{",
"$",
"sTempFolderPath",
"=",
"realpath",
"(",
"oxRegistry",
"::",
"getConfig",
"(",
")",
"->",
"getConfigParam",
"(",
"'sCompileDir'",
")",
")",
";",
"if",
"(",
... | Clean temp folder content.
@param string $sClearFolderPath Sub-folder path to delete from. Should be a full, valid path inside temp folder.
@return boolean | [
"Clean",
"temp",
"folder",
"content",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowmodule.php#L121-L159 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowmodule.php | OxpsPaymorrowModule.translate | public function translate( $sCode, $blUseModulePrefix = true )
{
if ( $blUseModulePrefix ) {
$sCode = 'PAYMORROW_' . $sCode;
}
return oxRegistry::getLang()->translateString( $sCode, oxRegistry::getLang()->getBaseLanguage(), false );
} | php | public function translate( $sCode, $blUseModulePrefix = true )
{
if ( $blUseModulePrefix ) {
$sCode = 'PAYMORROW_' . $sCode;
}
return oxRegistry::getLang()->translateString( $sCode, oxRegistry::getLang()->getBaseLanguage(), false );
} | [
"public",
"function",
"translate",
"(",
"$",
"sCode",
",",
"$",
"blUseModulePrefix",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"blUseModulePrefix",
")",
"{",
"$",
"sCode",
"=",
"'PAYMORROW_'",
".",
"$",
"sCode",
";",
"}",
"return",
"oxRegistry",
"::",
"getL... | Get translated string bt the translation code.
@param string $sCode
@param boolean $blUseModulePrefix User module translations prefix or not.
@return string | [
"Get",
"translated",
"string",
"bt",
"the",
"translation",
"code",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowmodule.php#L182-L189 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowmodule.php | OxpsPaymorrowModule.getCmsContent | public function getCmsContent( $sIdentifier, $blNoHtml = true )
{
/** @var oxContent|oxI18n $oContent */
$oContent = oxNew( 'oxContent' );
$oContent->loadByIdent( trim( (string) $sIdentifier ) );
$sValue = (string) $oContent->oxcontents__oxcontent->getRawValue();
return ( empty( $blNoHtml ) ? $sValue : nl2br( strip_tags( $sValue ) ) );
} | php | public function getCmsContent( $sIdentifier, $blNoHtml = true )
{
/** @var oxContent|oxI18n $oContent */
$oContent = oxNew( 'oxContent' );
$oContent->loadByIdent( trim( (string) $sIdentifier ) );
$sValue = (string) $oContent->oxcontents__oxcontent->getRawValue();
return ( empty( $blNoHtml ) ? $sValue : nl2br( strip_tags( $sValue ) ) );
} | [
"public",
"function",
"getCmsContent",
"(",
"$",
"sIdentifier",
",",
"$",
"blNoHtml",
"=",
"true",
")",
"{",
"/** @var oxContent|oxI18n $oContent */",
"$",
"oContent",
"=",
"oxNew",
"(",
"'oxContent'",
")",
";",
"$",
"oContent",
"->",
"loadByIdent",
"(",
"trim",... | Get CMS snippet content by identified ID.
@param string $sIdentifier
@param bool $blNoHtml
@return string | [
"Get",
"CMS",
"snippet",
"content",
"by",
"identified",
"ID",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowmodule.php#L199-L208 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowmodule.php | OxpsPaymorrowModule.getSetting | public function getSetting( $sModuleSettingName, $blUseModulePrefix = true )
{
if ( $blUseModulePrefix ) {
$sModuleSettingName = 'paymorrow' . (string) $sModuleSettingName;
}
return oxRegistry::getConfig()->getConfigParam( (string) $sModuleSettingName );
} | php | public function getSetting( $sModuleSettingName, $blUseModulePrefix = true )
{
if ( $blUseModulePrefix ) {
$sModuleSettingName = 'paymorrow' . (string) $sModuleSettingName;
}
return oxRegistry::getConfig()->getConfigParam( (string) $sModuleSettingName );
} | [
"public",
"function",
"getSetting",
"(",
"$",
"sModuleSettingName",
",",
"$",
"blUseModulePrefix",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"blUseModulePrefix",
")",
"{",
"$",
"sModuleSettingName",
"=",
"'paymorrow'",
".",
"(",
"string",
")",
"$",
"sModuleSettin... | Get module setting value.
@param string $sModuleSettingName Module setting parameter name without module prefix.
@param boolean $blUseModulePrefix User module settings prefix or not.
@return mixed | [
"Get",
"module",
"setting",
"value",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowmodule.php#L218-L225 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowmodule.php | OxpsPaymorrowModule.updateSettings | public function updateSettings()
{
// Load the configuration from Paymorrow
/** @var OxpsPaymorrowRequestControllerProxy $oRequestControllerProxy */
$oRequestControllerProxy = oxNew( 'OxpsPaymorrowRequestControllerProxy' );
$aConfigurationResponse = $oRequestControllerProxy->getConfiguration();
/** @var OxpsPaymorrowResponseHandler $oResponseHandler */
$oResponseHandler = oxNew( 'OxpsPaymorrowResponseHandler' );
$aConfigurationData = $oResponseHandler->parseGetConfigurationResponse( $aConfigurationResponse );
$oConfig = oxRegistry::getConfig();
if ( oxRegistry::get( 'OxpsPaymorrowSettings' )->isSandboxMode() ) {
$aSettingsMap = array(
'api_endpoint' => 'paymorrowEndpointUrlTest',
'api_resource_handler' => 'paymorrowResourcePathTest',
'api_operation_mode' => 'paymorrowOperationModeTest',
);
} else {
$aSettingsMap = array(
'api_endpoint' => 'paymorrowEndpointUrlProd',
'api_resource_handler' => 'paymorrowResourcePath',
'api_operation_mode' => 'paymorrowOperationMode',
);
}
// Apply the configuration for module settings
foreach ( $aSettingsMap as $sPaymorrowKey => $sSettingsKey ) {
if ( !empty( $aConfigurationData[$sPaymorrowKey] ) ) {
$sValue = trim( (string) $aConfigurationData[$sPaymorrowKey] );
$oConfig->setConfigParam( $sSettingsKey, $sValue );
$oConfig->saveShopConfVar(
'str', $sSettingsKey, $sValue, null, sprintf( 'module:%s', $this->getId() )
);
}
}
// Reset resource cache
/** @var OxpsPaymorrowResourceCache $oResourceCache */
$oResourceCache = oxNew( 'OxpsPaymorrowResourceCache' );
$oResourceCache->cleanCache();
} | php | public function updateSettings()
{
// Load the configuration from Paymorrow
/** @var OxpsPaymorrowRequestControllerProxy $oRequestControllerProxy */
$oRequestControllerProxy = oxNew( 'OxpsPaymorrowRequestControllerProxy' );
$aConfigurationResponse = $oRequestControllerProxy->getConfiguration();
/** @var OxpsPaymorrowResponseHandler $oResponseHandler */
$oResponseHandler = oxNew( 'OxpsPaymorrowResponseHandler' );
$aConfigurationData = $oResponseHandler->parseGetConfigurationResponse( $aConfigurationResponse );
$oConfig = oxRegistry::getConfig();
if ( oxRegistry::get( 'OxpsPaymorrowSettings' )->isSandboxMode() ) {
$aSettingsMap = array(
'api_endpoint' => 'paymorrowEndpointUrlTest',
'api_resource_handler' => 'paymorrowResourcePathTest',
'api_operation_mode' => 'paymorrowOperationModeTest',
);
} else {
$aSettingsMap = array(
'api_endpoint' => 'paymorrowEndpointUrlProd',
'api_resource_handler' => 'paymorrowResourcePath',
'api_operation_mode' => 'paymorrowOperationMode',
);
}
// Apply the configuration for module settings
foreach ( $aSettingsMap as $sPaymorrowKey => $sSettingsKey ) {
if ( !empty( $aConfigurationData[$sPaymorrowKey] ) ) {
$sValue = trim( (string) $aConfigurationData[$sPaymorrowKey] );
$oConfig->setConfigParam( $sSettingsKey, $sValue );
$oConfig->saveShopConfVar(
'str', $sSettingsKey, $sValue, null, sprintf( 'module:%s', $this->getId() )
);
}
}
// Reset resource cache
/** @var OxpsPaymorrowResourceCache $oResourceCache */
$oResourceCache = oxNew( 'OxpsPaymorrowResourceCache' );
$oResourceCache->cleanCache();
} | [
"public",
"function",
"updateSettings",
"(",
")",
"{",
"// Load the configuration from Paymorrow",
"/** @var OxpsPaymorrowRequestControllerProxy $oRequestControllerProxy */",
"$",
"oRequestControllerProxy",
"=",
"oxNew",
"(",
"'OxpsPaymorrowRequestControllerProxy'",
")",
";",
"$",
... | Settings update event.
Fetches latest configuration data from Paymorrow and update relevant module settings with it. | [
"Settings",
"update",
"event",
".",
"Fetches",
"latest",
"configuration",
"data",
"from",
"Paymorrow",
"and",
"update",
"relevant",
"module",
"settings",
"with",
"it",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowmodule.php#L241-L285 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowmodule.php | OxpsPaymorrowModule.getPaymentTransactionId | public function getPaymentTransactionId($blOnlySessionKey = false)
{
$sTransactionIdKey = sprintf('pm_order_transaction_id%s', $this->getPaymentMethodName());
$sTransactionId = (string) oxRegistry::getSession()->getVariable($sTransactionIdKey);
return empty($blOnlySessionKey) ? $sTransactionId : $sTransactionIdKey;
} | php | public function getPaymentTransactionId($blOnlySessionKey = false)
{
$sTransactionIdKey = sprintf('pm_order_transaction_id%s', $this->getPaymentMethodName());
$sTransactionId = (string) oxRegistry::getSession()->getVariable($sTransactionIdKey);
return empty($blOnlySessionKey) ? $sTransactionId : $sTransactionIdKey;
} | [
"public",
"function",
"getPaymentTransactionId",
"(",
"$",
"blOnlySessionKey",
"=",
"false",
")",
"{",
"$",
"sTransactionIdKey",
"=",
"sprintf",
"(",
"'pm_order_transaction_id%s'",
",",
"$",
"this",
"->",
"getPaymentMethodName",
"(",
")",
")",
";",
"$",
"sTransact... | Check session for verified Paymorrow payment method ID and get order transaction ID for the method.
@param bool $blOnlySessionKey If true, only return a session ket of the transaction ID, otherwise - the ID
@return string | [
"Check",
"session",
"for",
"verified",
"Paymorrow",
"payment",
"method",
"ID",
"and",
"get",
"order",
"transaction",
"ID",
"for",
"the",
"method",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowmodule.php#L375-L381 | train |
OXID-eSales/paymorrow-module | controllers/oxpspaymorrowresource.php | OxpsPaymorrowResource._getResource | protected function _getResource( $sResourcePath, $blNoCache = false )
{
$aResponse = null;
if ( !$blNoCache ) {
/** @var OxpsPaymorrowResourceCache $oResourceCache */
$oResourceCache = oxNew( 'OxpsPaymorrowResourceCache' );
$aResponse = $oResourceCache->pop( $sResourcePath );
}
if ( empty( $aResponse ) ) {
/** @var OxpsOxid2Paymorrow $oOxidToPm */
$oOxidToPm = oxNew( 'OxpsOxid2Paymorrow' );
$aResponse = $oOxidToPm->getBuiltPaymorrowResourceProxy()->getResource( $sResourcePath );
if ( !$blNoCache ) {
$oResourceCache->push( $sResourcePath, $aResponse );
}
}
$this->_resourceResponse( $aResponse );
} | php | protected function _getResource( $sResourcePath, $blNoCache = false )
{
$aResponse = null;
if ( !$blNoCache ) {
/** @var OxpsPaymorrowResourceCache $oResourceCache */
$oResourceCache = oxNew( 'OxpsPaymorrowResourceCache' );
$aResponse = $oResourceCache->pop( $sResourcePath );
}
if ( empty( $aResponse ) ) {
/** @var OxpsOxid2Paymorrow $oOxidToPm */
$oOxidToPm = oxNew( 'OxpsOxid2Paymorrow' );
$aResponse = $oOxidToPm->getBuiltPaymorrowResourceProxy()->getResource( $sResourcePath );
if ( !$blNoCache ) {
$oResourceCache->push( $sResourcePath, $aResponse );
}
}
$this->_resourceResponse( $aResponse );
} | [
"protected",
"function",
"_getResource",
"(",
"$",
"sResourcePath",
",",
"$",
"blNoCache",
"=",
"false",
")",
"{",
"$",
"aResponse",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"blNoCache",
")",
"{",
"/** @var OxpsPaymorrowResourceCache $oResourceCache */",
"$",
"oRe... | Get a resource by path and output the resource content.
@param string $sResourcePath
@param bool $blNoCache forces not to cache resource | [
"Get",
"a",
"resource",
"by",
"path",
"and",
"output",
"the",
"resource",
"content",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/controllers/oxpspaymorrowresource.php#L96-L118 | train |
OXID-eSales/paymorrow-module | controllers/oxpspaymorrowresource.php | OxpsPaymorrowResource._resourceResponse | protected function _resourceResponse( array $aResponse )
{
if ( isset( $aResponse['contentType'] ) ) {
oxRegistry::getUtils()->setHeader( 'Content-Type: ' . $aResponse['contentType'] );
}
if ( isset( $aResponse['body'] ) ) {
print( $aResponse['body'] );
}
exit();
} | php | protected function _resourceResponse( array $aResponse )
{
if ( isset( $aResponse['contentType'] ) ) {
oxRegistry::getUtils()->setHeader( 'Content-Type: ' . $aResponse['contentType'] );
}
if ( isset( $aResponse['body'] ) ) {
print( $aResponse['body'] );
}
exit();
} | [
"protected",
"function",
"_resourceResponse",
"(",
"array",
"$",
"aResponse",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"aResponse",
"[",
"'contentType'",
"]",
")",
")",
"{",
"oxRegistry",
"::",
"getUtils",
"(",
")",
"->",
"setHeader",
"(",
"'Content-Type: '",... | Sent response headers, content and stop execution to prevent defaults.
@codeCoverageIgnore
@param array $aResponse | [
"Sent",
"response",
"headers",
"content",
"and",
"stop",
"execution",
"to",
"prevent",
"defaults",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/controllers/oxpspaymorrowresource.php#L127-L138 | train |
moodev/php-weasel | lib/Weasel/JsonMarshaller/JsonMapper.php | JsonMapper._registerBuiltInTypes | protected function _registerBuiltInTypes()
{
$this->registerJsonType("boolean", new Types\BoolType(), array("bool"));
$this->registerJsonType("float", new Types\FloatType());
$this->registerJsonType("integer", new Types\IntType(), array("int"));
$this->registerJsonType("string", new Types\StringType());
$this->registerJsonType("datetime", new Types\DateTimeType());
} | php | protected function _registerBuiltInTypes()
{
$this->registerJsonType("boolean", new Types\BoolType(), array("bool"));
$this->registerJsonType("float", new Types\FloatType());
$this->registerJsonType("integer", new Types\IntType(), array("int"));
$this->registerJsonType("string", new Types\StringType());
$this->registerJsonType("datetime", new Types\DateTimeType());
} | [
"protected",
"function",
"_registerBuiltInTypes",
"(",
")",
"{",
"$",
"this",
"->",
"registerJsonType",
"(",
"\"boolean\"",
",",
"new",
"Types",
"\\",
"BoolType",
"(",
")",
",",
"array",
"(",
"\"bool\"",
")",
")",
";",
"$",
"this",
"->",
"registerJsonType",
... | Setup the types we consider "built-in". | [
"Setup",
"the",
"types",
"we",
"consider",
"built",
"-",
"in",
"."
] | fecc7cc06cae719489cb4490f414ed6530e70831 | https://github.com/moodev/php-weasel/blob/fecc7cc06cae719489cb4490f414ed6530e70831/lib/Weasel/JsonMarshaller/JsonMapper.php#L80-L87 | train |
moodev/php-weasel | lib/Weasel/JsonMarshaller/JsonMapper.php | JsonMapper.writeString | public function writeString($data, $type = null)
{
if (!isset($type)) {
$type = $this->_guessType($data);
}
return $this->_encodeValue($data, $this->_parseTypeString($type));
} | php | public function writeString($data, $type = null)
{
if (!isset($type)) {
$type = $this->_guessType($data);
}
return $this->_encodeValue($data, $this->_parseTypeString($type));
} | [
"public",
"function",
"writeString",
"(",
"$",
"data",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"type",
")",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"_guessType",
"(",
"$",
"data",
")",
";",
"}",
"retur... | Serialize an data to a string of JSON.
@param mixed $data Data to serialize
@param string $type Type of the data being encoded. If not provided then this will be guessed.
Guessing only works with primitives and simple objects.
@return string The JSON | [
"Serialize",
"an",
"data",
"to",
"a",
"string",
"of",
"JSON",
"."
] | fecc7cc06cae719489cb4490f414ed6530e70831 | https://github.com/moodev/php-weasel/blob/fecc7cc06cae719489cb4490f414ed6530e70831/lib/Weasel/JsonMarshaller/JsonMapper.php#L156-L162 | train |
moodev/php-weasel | lib/Weasel/JsonMarshaller/JsonMapper.php | JsonMapper.registerJsonType | public function registerJsonType($name, $handler, $aliases = array())
{
$this->typeHandlers[$name] = $handler;
foreach ($aliases as $alias) {
$this->typeHandlers[$alias] = $handler;
}
} | php | public function registerJsonType($name, $handler, $aliases = array())
{
$this->typeHandlers[$name] = $handler;
foreach ($aliases as $alias) {
$this->typeHandlers[$alias] = $handler;
}
} | [
"public",
"function",
"registerJsonType",
"(",
"$",
"name",
",",
"$",
"handler",
",",
"$",
"aliases",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"typeHandlers",
"[",
"$",
"name",
"]",
"=",
"$",
"handler",
";",
"foreach",
"(",
"$",
"aliases"... | Register a custom type.
@param string $name
@param Types\JsonType $handler
@param string[] $aliases | [
"Register",
"a",
"custom",
"type",
"."
] | fecc7cc06cae719489cb4490f414ed6530e70831 | https://github.com/moodev/php-weasel/blob/fecc7cc06cae719489cb4490f414ed6530e70831/lib/Weasel/JsonMarshaller/JsonMapper.php#L673-L679 | train |
moodev/php-weasel | lib/Weasel/JsonMarshaller/JsonMapper.php | JsonMapper.registerType | public function registerType($name, $handler, $aliases = array())
{
trigger_error("Types are deprecated, use JsonTypes through registerJsonType.", E_USER_DEPRECATED);
$this->registerJsonType($name, new OldTypeWrapper($handler), $aliases);
} | php | public function registerType($name, $handler, $aliases = array())
{
trigger_error("Types are deprecated, use JsonTypes through registerJsonType.", E_USER_DEPRECATED);
$this->registerJsonType($name, new OldTypeWrapper($handler), $aliases);
} | [
"public",
"function",
"registerType",
"(",
"$",
"name",
",",
"$",
"handler",
",",
"$",
"aliases",
"=",
"array",
"(",
")",
")",
"{",
"trigger_error",
"(",
"\"Types are deprecated, use JsonTypes through registerJsonType.\"",
",",
"E_USER_DEPRECATED",
")",
";",
"$",
... | Register an old style custom type.
This is a compatibility handler and will be removed. Please use registerJsonType!
@Deprecated
@param string $name
@param Types\Type $handler
@param string[] $aliases | [
"Register",
"an",
"old",
"style",
"custom",
"type",
".",
"This",
"is",
"a",
"compatibility",
"handler",
"and",
"will",
"be",
"removed",
".",
"Please",
"use",
"registerJsonType!"
] | fecc7cc06cae719489cb4490f414ed6530e70831 | https://github.com/moodev/php-weasel/blob/fecc7cc06cae719489cb4490f414ed6530e70831/lib/Weasel/JsonMarshaller/JsonMapper.php#L689-L693 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.getTaxClassIdByTaxClassName | public function getTaxClassIdByTaxClassName($taxClassName)
{
// query whether or not, the requested tax class is available
if (isset($this->taxClasses[$taxClassName])) {
return (integer) $this->taxClasses[$taxClassName][MemberNames::CLASS_ID];
}
// throw an exception, if not
throw new \Exception(
$this->appendExceptionSuffix(
sprintf('Found invalid tax class name %s', $taxClassName)
)
);
} | php | public function getTaxClassIdByTaxClassName($taxClassName)
{
// query whether or not, the requested tax class is available
if (isset($this->taxClasses[$taxClassName])) {
return (integer) $this->taxClasses[$taxClassName][MemberNames::CLASS_ID];
}
// throw an exception, if not
throw new \Exception(
$this->appendExceptionSuffix(
sprintf('Found invalid tax class name %s', $taxClassName)
)
);
} | [
"public",
"function",
"getTaxClassIdByTaxClassName",
"(",
"$",
"taxClassName",
")",
"{",
"// query whether or not, the requested tax class is available",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"taxClasses",
"[",
"$",
"taxClassName",
"]",
")",
")",
"{",
"return",
... | Return's the tax class ID for the passed tax class name.
@param string $taxClassName The tax class name to return the ID for
@return integer The tax class ID
@throws \Exception Is thrown, if the tax class with the requested name is not available | [
"Return",
"s",
"the",
"tax",
"class",
"ID",
"for",
"the",
"passed",
"tax",
"class",
"name",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L436-L450 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.getRootCategory | public function getRootCategory()
{
// load the default store
$defaultStore = $this->getDefaultStore();
// load the actual store view code
$storeViewCode = $this->getStoreViewCode($defaultStore[MemberNames::CODE]);
// query weather or not we've a root category or not
if (isset($this->rootCategories[$storeViewCode])) {
return $this->rootCategories[$storeViewCode];
}
// throw an exception if the root category is NOT available
throw new \Exception(
$this->appendExceptionSuffix(
sprintf('Root category for %s is not available', $storeViewCode)
)
);
} | php | public function getRootCategory()
{
// load the default store
$defaultStore = $this->getDefaultStore();
// load the actual store view code
$storeViewCode = $this->getStoreViewCode($defaultStore[MemberNames::CODE]);
// query weather or not we've a root category or not
if (isset($this->rootCategories[$storeViewCode])) {
return $this->rootCategories[$storeViewCode];
}
// throw an exception if the root category is NOT available
throw new \Exception(
$this->appendExceptionSuffix(
sprintf('Root category for %s is not available', $storeViewCode)
)
);
} | [
"public",
"function",
"getRootCategory",
"(",
")",
"{",
"// load the default store",
"$",
"defaultStore",
"=",
"$",
"this",
"->",
"getDefaultStore",
"(",
")",
";",
"// load the actual store view code",
"$",
"storeViewCode",
"=",
"$",
"this",
"->",
"getStoreViewCode",
... | Return's the root category for the actual view store.
@return array The store's root category
@throws \Exception Is thrown if the root category for the passed store code is NOT available | [
"Return",
"s",
"the",
"root",
"category",
"for",
"the",
"actual",
"view",
"store",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L552-L572 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.getStoreViewCodesByWebsiteCode | public function getStoreViewCodesByWebsiteCode($websiteCode)
{
// query whether or not the website with the passed code exists
if (!isset($this->storeWebsites[$websiteCode])) {
// throw an exception if the website is NOT available
throw new \Exception(
$this->appendExceptionSuffix(
sprintf('Website with code "%s" is not available', $websiteCode)
)
);
}
// initialize the array for the store view codes
$storeViewCodes = array();
// load the website ID
$websiteId = (integer) $this->storeWebsites[$websiteCode][MemberNames::WEBSITE_ID];
// iterate over the available stores to find the one of the website
foreach ($this->stores as $storeCode => $store) {
if ((integer) $store[MemberNames::WEBSITE_ID] === $websiteId) {
$storeViewCodes[] = $storeCode;
}
}
// return the array with the matching store view codes
return $storeViewCodes;
} | php | public function getStoreViewCodesByWebsiteCode($websiteCode)
{
// query whether or not the website with the passed code exists
if (!isset($this->storeWebsites[$websiteCode])) {
// throw an exception if the website is NOT available
throw new \Exception(
$this->appendExceptionSuffix(
sprintf('Website with code "%s" is not available', $websiteCode)
)
);
}
// initialize the array for the store view codes
$storeViewCodes = array();
// load the website ID
$websiteId = (integer) $this->storeWebsites[$websiteCode][MemberNames::WEBSITE_ID];
// iterate over the available stores to find the one of the website
foreach ($this->stores as $storeCode => $store) {
if ((integer) $store[MemberNames::WEBSITE_ID] === $websiteId) {
$storeViewCodes[] = $storeCode;
}
}
// return the array with the matching store view codes
return $storeViewCodes;
} | [
"public",
"function",
"getStoreViewCodesByWebsiteCode",
"(",
"$",
"websiteCode",
")",
"{",
"// query whether or not the website with the passed code exists",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"storeWebsites",
"[",
"$",
"websiteCode",
"]",
")",
")",
"{",... | Returns an array with the codes of the store views related with the passed website code.
@param string $websiteCode The code of the website to return the store view codes for
@return array The array with the matching store view codes | [
"Returns",
"an",
"array",
"with",
"the",
"codes",
"of",
"the",
"store",
"views",
"related",
"with",
"the",
"passed",
"website",
"code",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L581-L609 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.getCleanUpColumns | public function getCleanUpColumns()
{
// load the colums that has to be cleaned-up
$cleanUpColumns = $this->getConfiguration()->getParam(ConfigurationKeys::CLEAN_UP_EMPTY_COLUMNS);
// query whether or not the image columns has to be cleaned-up also
if ($this->getConfiguration()->hasParam(ConfigurationKeys::CLEAN_UP_EMPTY_IMAGE_COLUMNS) &&
$this->getConfiguration()->hasParam(ConfigurationKeys::CLEAN_UP_EMPTY_IMAGE_COLUMNS, false)
) {
// if yes load the image column names
$imageTypes = array_keys($this->getImageTypes());
// and append them to the column names from the configuration
foreach ($imageTypes as $imageAttribute) {
$cleanUpColumns[] = $imageAttribute;
}
}
// return the array with the column names that has to be cleaned-up
return $cleanUpColumns;
} | php | public function getCleanUpColumns()
{
// load the colums that has to be cleaned-up
$cleanUpColumns = $this->getConfiguration()->getParam(ConfigurationKeys::CLEAN_UP_EMPTY_COLUMNS);
// query whether or not the image columns has to be cleaned-up also
if ($this->getConfiguration()->hasParam(ConfigurationKeys::CLEAN_UP_EMPTY_IMAGE_COLUMNS) &&
$this->getConfiguration()->hasParam(ConfigurationKeys::CLEAN_UP_EMPTY_IMAGE_COLUMNS, false)
) {
// if yes load the image column names
$imageTypes = array_keys($this->getImageTypes());
// and append them to the column names from the configuration
foreach ($imageTypes as $imageAttribute) {
$cleanUpColumns[] = $imageAttribute;
}
}
// return the array with the column names that has to be cleaned-up
return $cleanUpColumns;
} | [
"public",
"function",
"getCleanUpColumns",
"(",
")",
"{",
"// load the colums that has to be cleaned-up",
"$",
"cleanUpColumns",
"=",
"$",
"this",
"->",
"getConfiguration",
"(",
")",
"->",
"getParam",
"(",
"ConfigurationKeys",
"::",
"CLEAN_UP_EMPTY_COLUMNS",
")",
";",
... | Merge the columns from the configuration with all image type columns to define which
columns should be cleaned-up.
@return array The columns that has to be cleaned-up | [
"Merge",
"the",
"columns",
"from",
"the",
"configuration",
"with",
"all",
"image",
"type",
"columns",
"to",
"define",
"which",
"columns",
"should",
"be",
"cleaned",
"-",
"up",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L617-L638 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.mapLinkTypeCodeToLinkTypeId | public function mapLinkTypeCodeToLinkTypeId($linkTypeCode)
{
// query weather or not the link type code has been mapped
if (isset($this->linkTypes[$linkTypeCode])) {
return $this->linkTypes[$linkTypeCode][MemberNames::LINK_TYPE_ID];
}
// throw an exception if the link type code has not been mapped yet
throw new MapLinkTypeCodeToIdException(
$this->appendExceptionSuffix(
sprintf('Found not mapped link type code %s', $linkTypeCode)
)
);
} | php | public function mapLinkTypeCodeToLinkTypeId($linkTypeCode)
{
// query weather or not the link type code has been mapped
if (isset($this->linkTypes[$linkTypeCode])) {
return $this->linkTypes[$linkTypeCode][MemberNames::LINK_TYPE_ID];
}
// throw an exception if the link type code has not been mapped yet
throw new MapLinkTypeCodeToIdException(
$this->appendExceptionSuffix(
sprintf('Found not mapped link type code %s', $linkTypeCode)
)
);
} | [
"public",
"function",
"mapLinkTypeCodeToLinkTypeId",
"(",
"$",
"linkTypeCode",
")",
"{",
"// query weather or not the link type code has been mapped",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"linkTypes",
"[",
"$",
"linkTypeCode",
"]",
")",
")",
"{",
"return",
"$... | Return's the link type ID for the passed link type code.
@param string $linkTypeCode The link type code to return the link type ID for
@return integer The mapped link type ID
@throws \TechDivision\Import\Product\Exceptions\MapLinkTypeCodeToIdException Is thrown if the link type code is not mapped yet | [
"Return",
"s",
"the",
"link",
"type",
"ID",
"for",
"the",
"passed",
"link",
"type",
"code",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L690-L704 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.getProductLinkAttribute | public function getProductLinkAttribute($linkTypeId, $attributeCode)
{
// try to load the link attribute with the passed link type ID and attribute code
foreach ($this->linkAttributes as $linkAttribute) {
if ($linkAttribute[MemberNames::LINK_TYPE_ID] === $linkTypeId &&
$linkAttribute[MemberNames::PRODUCT_LINK_ATTRIBUTE_CODE] === $attributeCode
) {
// return the matching link attribute
return $linkAttribute;
}
}
} | php | public function getProductLinkAttribute($linkTypeId, $attributeCode)
{
// try to load the link attribute with the passed link type ID and attribute code
foreach ($this->linkAttributes as $linkAttribute) {
if ($linkAttribute[MemberNames::LINK_TYPE_ID] === $linkTypeId &&
$linkAttribute[MemberNames::PRODUCT_LINK_ATTRIBUTE_CODE] === $attributeCode
) {
// return the matching link attribute
return $linkAttribute;
}
}
} | [
"public",
"function",
"getProductLinkAttribute",
"(",
"$",
"linkTypeId",
",",
"$",
"attributeCode",
")",
"{",
"// try to load the link attribute with the passed link type ID and attribute code",
"foreach",
"(",
"$",
"this",
"->",
"linkAttributes",
"as",
"$",
"linkAttribute",
... | Return's the link attribute for the passed link type ID and attribute code.
@param integer $linkTypeId The link type
@param string $attributeCode The attribute code
@return array The link attribute | [
"Return",
"s",
"the",
"link",
"attribute",
"for",
"the",
"passed",
"link",
"type",
"ID",
"and",
"attribute",
"code",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L714-L726 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.getProductLinkAttributeByLinkTypeCodeAndAttributeCode | public function getProductLinkAttributeByLinkTypeCodeAndAttributeCode($linkTypeCode, $attributeCode)
{
// map the link type code => ID
$linkTypeId = $this->mapLinkTypeCodeToLinkTypeId($linkTypeCode);
// try to load the link attribute with the passed link type ID and attribute code
foreach ($this->linkAttributes as $linkAttribute) {
if ($linkAttribute[MemberNames::LINK_TYPE_ID] === $linkTypeId &&
$linkAttribute[MemberNames::PRODUCT_LINK_ATTRIBUTE_CODE] === $attributeCode
) {
// return the matching link attribute
return $linkAttribute;
}
}
} | php | public function getProductLinkAttributeByLinkTypeCodeAndAttributeCode($linkTypeCode, $attributeCode)
{
// map the link type code => ID
$linkTypeId = $this->mapLinkTypeCodeToLinkTypeId($linkTypeCode);
// try to load the link attribute with the passed link type ID and attribute code
foreach ($this->linkAttributes as $linkAttribute) {
if ($linkAttribute[MemberNames::LINK_TYPE_ID] === $linkTypeId &&
$linkAttribute[MemberNames::PRODUCT_LINK_ATTRIBUTE_CODE] === $attributeCode
) {
// return the matching link attribute
return $linkAttribute;
}
}
} | [
"public",
"function",
"getProductLinkAttributeByLinkTypeCodeAndAttributeCode",
"(",
"$",
"linkTypeCode",
",",
"$",
"attributeCode",
")",
"{",
"// map the link type code => ID",
"$",
"linkTypeId",
"=",
"$",
"this",
"->",
"mapLinkTypeCodeToLinkTypeId",
"(",
"$",
"linkTypeCode... | Return's the link attribute for the passed link type and attribute code.
@param string $linkTypeCode The link type code
@param string $attributeCode The attribute code
@return array The link attribute | [
"Return",
"s",
"the",
"link",
"attribute",
"for",
"the",
"passed",
"link",
"type",
"and",
"attribute",
"code",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L736-L751 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.getProductLinkAttributes | public function getProductLinkAttributes($linkTypeCode)
{
// map the link type code => ID
$linkTypeId = $this->mapLinkTypeCodeToLinkTypeId($linkTypeCode);
// initialize the array for the link attributes
$linkAttributes = array();
// try to load the link attribute with the passed link type ID and attribute code
foreach ($this->linkAttributes as $linkAttribute) {
if ($linkAttribute[MemberNames::LINK_TYPE_ID] === $linkTypeId) {
// return the matching link attribute
$linkAttributes[] = $linkAttribute;
}
}
// return the link attributes
return $linkAttributes;
} | php | public function getProductLinkAttributes($linkTypeCode)
{
// map the link type code => ID
$linkTypeId = $this->mapLinkTypeCodeToLinkTypeId($linkTypeCode);
// initialize the array for the link attributes
$linkAttributes = array();
// try to load the link attribute with the passed link type ID and attribute code
foreach ($this->linkAttributes as $linkAttribute) {
if ($linkAttribute[MemberNames::LINK_TYPE_ID] === $linkTypeId) {
// return the matching link attribute
$linkAttributes[] = $linkAttribute;
}
}
// return the link attributes
return $linkAttributes;
} | [
"public",
"function",
"getProductLinkAttributes",
"(",
"$",
"linkTypeCode",
")",
"{",
"// map the link type code => ID",
"$",
"linkTypeId",
"=",
"$",
"this",
"->",
"mapLinkTypeCodeToLinkTypeId",
"(",
"$",
"linkTypeCode",
")",
";",
"// initialize the array for the link attri... | Returns the product link attributes for the passed link type code.
@param string $linkTypeCode The link type code
@return array The product link types | [
"Returns",
"the",
"product",
"link",
"attributes",
"for",
"the",
"passed",
"link",
"type",
"code",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L760-L779 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.mapLinkTypeCodeToColumnName | public function mapLinkTypeCodeToColumnName($linkTypeCode)
{
// query whether or not the link type code has a mapping
if (isset($this->linkTypeCodeToColumnNameMapping[$linkTypeCode])) {
return $this->linkTypeCodeToColumnNameMapping[$linkTypeCode];
}
// return the passed link type code
return $linkTypeCode;
} | php | public function mapLinkTypeCodeToColumnName($linkTypeCode)
{
// query whether or not the link type code has a mapping
if (isset($this->linkTypeCodeToColumnNameMapping[$linkTypeCode])) {
return $this->linkTypeCodeToColumnNameMapping[$linkTypeCode];
}
// return the passed link type code
return $linkTypeCode;
} | [
"public",
"function",
"mapLinkTypeCodeToColumnName",
"(",
"$",
"linkTypeCode",
")",
"{",
"// query whether or not the link type code has a mapping",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"linkTypeCodeToColumnNameMapping",
"[",
"$",
"linkTypeCode",
"]",
")",
")",
"... | Maps the link type code to the apropriate column name.
@param string $linkTypeCode The link type code to map
@return string The mapped column name | [
"Maps",
"the",
"link",
"type",
"code",
"to",
"the",
"apropriate",
"column",
"name",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L788-L798 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.prepareLinkTypeMappings | public function prepareLinkTypeMappings()
{
// initialize the array with link type mappings
$linkTypeMappings = array();
// prepare the link type mappings
foreach ($this->getLinkTypes() as $linkType) {
// map the link type code to the column name, if necessary
$columnName = $this->mapLinkTypeCodeToColumnName($linkType[MemberNames::CODE]);
// create the header for the link type mapping
$linkTypeMappings[$linkType[MemberNames::CODE]][] = array (
$fullColumnName = sprintf('%s_skus', $columnName),
$this->getLinkTypeColumnCallback($fullColumnName)
);
// add the mappings for the columns that contains the values for the configured link type attributes
foreach ($this->getProductLinkAttributes($linkType[MemberNames::CODE]) as $linkAttribute) {
// initialize the full column name that uses the column name as prefix and the attribute code as suffix
$fullColumnName = sprintf('%s_%s', $columnName, $linkAttribute[MemberNames::PRODUCT_LINK_ATTRIBUTE_CODE]);
// load the callback that extracts the values from the columns
$callback = $this->getLinkTypeColumnCallback($fullColumnName);
// map the column name to the real column name
if (isset($this->linkTypeAttributeColumnToCallbackMapping[$fullColumnName])) {
list ($fullColumnName, ) = $this->linkTypeAttributeColumnToCallbackMapping[$fullColumnName];
}
// add the link type mapping for the column with the link type value
$linkTypeMappings[$linkType[MemberNames::CODE]][] = array(
$fullColumnName,
$callback,
$linkAttribute[MemberNames::PRODUCT_LINK_ATTRIBUTE_CODE]
);
}
}
// return the link type mappings
return $linkTypeMappings;
} | php | public function prepareLinkTypeMappings()
{
// initialize the array with link type mappings
$linkTypeMappings = array();
// prepare the link type mappings
foreach ($this->getLinkTypes() as $linkType) {
// map the link type code to the column name, if necessary
$columnName = $this->mapLinkTypeCodeToColumnName($linkType[MemberNames::CODE]);
// create the header for the link type mapping
$linkTypeMappings[$linkType[MemberNames::CODE]][] = array (
$fullColumnName = sprintf('%s_skus', $columnName),
$this->getLinkTypeColumnCallback($fullColumnName)
);
// add the mappings for the columns that contains the values for the configured link type attributes
foreach ($this->getProductLinkAttributes($linkType[MemberNames::CODE]) as $linkAttribute) {
// initialize the full column name that uses the column name as prefix and the attribute code as suffix
$fullColumnName = sprintf('%s_%s', $columnName, $linkAttribute[MemberNames::PRODUCT_LINK_ATTRIBUTE_CODE]);
// load the callback that extracts the values from the columns
$callback = $this->getLinkTypeColumnCallback($fullColumnName);
// map the column name to the real column name
if (isset($this->linkTypeAttributeColumnToCallbackMapping[$fullColumnName])) {
list ($fullColumnName, ) = $this->linkTypeAttributeColumnToCallbackMapping[$fullColumnName];
}
// add the link type mapping for the column with the link type value
$linkTypeMappings[$linkType[MemberNames::CODE]][] = array(
$fullColumnName,
$callback,
$linkAttribute[MemberNames::PRODUCT_LINK_ATTRIBUTE_CODE]
);
}
}
// return the link type mappings
return $linkTypeMappings;
} | [
"public",
"function",
"prepareLinkTypeMappings",
"(",
")",
"{",
"// initialize the array with link type mappings",
"$",
"linkTypeMappings",
"=",
"array",
"(",
")",
";",
"// prepare the link type mappings",
"foreach",
"(",
"$",
"this",
"->",
"getLinkTypes",
"(",
")",
"as... | Return's the link type code => colums mapping.
@return array The mapping with the link type codes => colums | [
"Return",
"s",
"the",
"link",
"type",
"code",
"=",
">",
"colums",
"mapping",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L805-L845 | train |
techdivision/import-product | src/Subjects/AbstractProductSubject.php | AbstractProductSubject.getLinkTypeColumnCallback | public function getLinkTypeColumnCallback($columnName)
{
// query whether or not a callback mapping is available
if (isset($this->linkTypeAttributeColumnToCallbackMapping[$columnName])) {
// load it from the array with the mappings
list (, $callbackName) = $this->linkTypeAttributeColumnToCallbackMapping[$columnName];
// prepare and return the callback
return array($this, $callbackName);
}
// return the default callback
return array($this, 'explode');
} | php | public function getLinkTypeColumnCallback($columnName)
{
// query whether or not a callback mapping is available
if (isset($this->linkTypeAttributeColumnToCallbackMapping[$columnName])) {
// load it from the array with the mappings
list (, $callbackName) = $this->linkTypeAttributeColumnToCallbackMapping[$columnName];
// prepare and return the callback
return array($this, $callbackName);
}
// return the default callback
return array($this, 'explode');
} | [
"public",
"function",
"getLinkTypeColumnCallback",
"(",
"$",
"columnName",
")",
"{",
"// query whether or not a callback mapping is available",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"linkTypeAttributeColumnToCallbackMapping",
"[",
"$",
"columnName",
"]",
")",
")",
... | Returns the callback method used to extract the value of the passed
column to create the link type attribute value with.
@param string $columnName The column name to create the callback for
@return callable The callback | [
"Returns",
"the",
"callback",
"method",
"used",
"to",
"extract",
"the",
"value",
"of",
"the",
"passed",
"column",
"to",
"create",
"the",
"link",
"type",
"attribute",
"value",
"with",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Subjects/AbstractProductSubject.php#L855-L868 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowsettings.php | OxpsPaymorrowSettings.getSettings | public function getSettings()
{
$aValidSettings = $this->getValidSettings();
$aSettings = array();
foreach ( $aValidSettings as $sSettingName ) {
$aSettings[$sSettingName] = $this->getSetting( $sSettingName );
}
return $aSettings;
} | php | public function getSettings()
{
$aValidSettings = $this->getValidSettings();
$aSettings = array();
foreach ( $aValidSettings as $sSettingName ) {
$aSettings[$sSettingName] = $this->getSetting( $sSettingName );
}
return $aSettings;
} | [
"public",
"function",
"getSettings",
"(",
")",
"{",
"$",
"aValidSettings",
"=",
"$",
"this",
"->",
"getValidSettings",
"(",
")",
";",
"$",
"aSettings",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"aValidSettings",
"as",
"$",
"sSettingName",
")",
"{... | Get Paymorrow settings from OXID DB oxConfig table.
@return array | [
"Get",
"Paymorrow",
"settings",
"from",
"OXID",
"DB",
"oxConfig",
"table",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowsettings.php#L241-L251 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowsettings.php | OxpsPaymorrowSettings.getSetting | public function getSetting( $sSettingName, $blUseModulePrefix = true )
{
return in_array( $sSettingName, $this->_aValidPaymorrowSettings )
? $this->_OxpsPaymorrowSettings_getSetting_parent( $sSettingName, true )
: null;
} | php | public function getSetting( $sSettingName, $blUseModulePrefix = true )
{
return in_array( $sSettingName, $this->_aValidPaymorrowSettings )
? $this->_OxpsPaymorrowSettings_getSetting_parent( $sSettingName, true )
: null;
} | [
"public",
"function",
"getSetting",
"(",
"$",
"sSettingName",
",",
"$",
"blUseModulePrefix",
"=",
"true",
")",
"{",
"return",
"in_array",
"(",
"$",
"sSettingName",
",",
"$",
"this",
"->",
"_aValidPaymorrowSettings",
")",
"?",
"$",
"this",
"->",
"_OxpsPaymorrow... | Get specific Paymorrow setting.
@param string $sSettingName
@param bool $sSettingName
@return mixed|null | [
"Get",
"specific",
"Paymorrow",
"setting",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowsettings.php#L261-L266 | train |
OXID-eSales/paymorrow-module | core/oxpspaymorrowsettings.php | OxpsPaymorrowSettings._getKey | protected function _getKey( $sKeyType )
{
$sSettingName = (string) $sKeyType;
$sSettingName .= 'Key';
if ( $this->isSandboxMode() ) {
$sSettingName .= 'Test';
}
$sEncodedKey = (string) $this->getSetting( $sSettingName );
return !empty( $sEncodedKey ) ? base64_decode( $sEncodedKey ) : '';
} | php | protected function _getKey( $sKeyType )
{
$sSettingName = (string) $sKeyType;
$sSettingName .= 'Key';
if ( $this->isSandboxMode() ) {
$sSettingName .= 'Test';
}
$sEncodedKey = (string) $this->getSetting( $sSettingName );
return !empty( $sEncodedKey ) ? base64_decode( $sEncodedKey ) : '';
} | [
"protected",
"function",
"_getKey",
"(",
"$",
"sKeyType",
")",
"{",
"$",
"sSettingName",
"=",
"(",
"string",
")",
"$",
"sKeyType",
";",
"$",
"sSettingName",
".=",
"'Key'",
";",
"if",
"(",
"$",
"this",
"->",
"isSandboxMode",
"(",
")",
")",
"{",
"$",
"... | Get public or private merchant key or public Paymorrow key setting value.
It verifies if it is Test or Live mode to return corresponding value.
Additionally a base64 decoding is performed.
@param string $sKeyType True for public key, false for private key.
@return mixed | [
"Get",
"public",
"or",
"private",
"merchant",
"key",
"or",
"public",
"Paymorrow",
"key",
"setting",
"value",
".",
"It",
"verifies",
"if",
"it",
"is",
"Test",
"or",
"Live",
"mode",
"to",
"return",
"corresponding",
"value",
".",
"Additionally",
"a",
"base64",
... | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/core/oxpspaymorrowsettings.php#L278-L290 | train |
techdivision/import-product | src/Repositories/CategoryProductRepository.php | CategoryProductRepository.findAllBySku | public function findAllBySku($sku)
{
// prepare the params
$params = array(MemberNames::SKU => $sku);
// initialize the array for the category product relations
$categoryProducts = array();
// load and return the product category relation for the passed product SKU
$this->categoryProductsBySkuStmt->execute($params);
// prepare the result by using the category ID as key
foreach ($this->categoryProductsBySkuStmt->fetchAll(\PDO::FETCH_ASSOC) as $categoryProduct) {
$categoryProducts[$categoryProduct[MemberNames::CATEGORY_ID]] = $categoryProduct;
}
// return the category product relations
return $categoryProducts;
} | php | public function findAllBySku($sku)
{
// prepare the params
$params = array(MemberNames::SKU => $sku);
// initialize the array for the category product relations
$categoryProducts = array();
// load and return the product category relation for the passed product SKU
$this->categoryProductsBySkuStmt->execute($params);
// prepare the result by using the category ID as key
foreach ($this->categoryProductsBySkuStmt->fetchAll(\PDO::FETCH_ASSOC) as $categoryProduct) {
$categoryProducts[$categoryProduct[MemberNames::CATEGORY_ID]] = $categoryProduct;
}
// return the category product relations
return $categoryProducts;
} | [
"public",
"function",
"findAllBySku",
"(",
"$",
"sku",
")",
"{",
"// prepare the params",
"$",
"params",
"=",
"array",
"(",
"MemberNames",
"::",
"SKU",
"=>",
"$",
"sku",
")",
";",
"// initialize the array for the category product relations",
"$",
"categoryProducts",
... | Return's the category product relations for the product with the passed SKU.
@param string $sku The product SKU to load the category relations for
@return array The category product relations for the product with the passed SKU | [
"Return",
"s",
"the",
"category",
"product",
"relations",
"for",
"the",
"product",
"with",
"the",
"passed",
"SKU",
"."
] | a596e0c4b0495c918139935a709815c739d61e95 | https://github.com/techdivision/import-product/blob/a596e0c4b0495c918139935a709815c739d61e95/src/Repositories/CategoryProductRepository.php#L97-L116 | train |
OXID-eSales/paymorrow-module | controllers/admin/oxpspaymorrowpaymentmap.php | OxpsPaymorrowPaymentMap.getPaymorrowEditValue | public function getPaymorrowEditValue()
{
$sOXID = $this->getPaymentObjectId();
if ( $sOXID != "-1" && isset( $sOXID ) ) {
/** @var oxPayment $oPayment */
$oPayment = oxNew( "oxPayment" );
$oPayment->loadInLang( $this->_iEditLang, $sOXID );
$oOtherLang = $oPayment->getAvailableInLangs();
if ( !isset( $oOtherLang[$this->_iEditLang] ) ) {
$oPayment->loadInLang( key( $oOtherLang ), $sOXID );
}
return $oPayment;
}
return null;
} | php | public function getPaymorrowEditValue()
{
$sOXID = $this->getPaymentObjectId();
if ( $sOXID != "-1" && isset( $sOXID ) ) {
/** @var oxPayment $oPayment */
$oPayment = oxNew( "oxPayment" );
$oPayment->loadInLang( $this->_iEditLang, $sOXID );
$oOtherLang = $oPayment->getAvailableInLangs();
if ( !isset( $oOtherLang[$this->_iEditLang] ) ) {
$oPayment->loadInLang( key( $oOtherLang ), $sOXID );
}
return $oPayment;
}
return null;
} | [
"public",
"function",
"getPaymorrowEditValue",
"(",
")",
"{",
"$",
"sOXID",
"=",
"$",
"this",
"->",
"getPaymentObjectId",
"(",
")",
";",
"if",
"(",
"$",
"sOXID",
"!=",
"\"-1\"",
"&&",
"isset",
"(",
"$",
"sOXID",
")",
")",
"{",
"/** @var oxPayment $oPayment... | Get current edited payment object.
@return null|oxPayment | [
"Get",
"current",
"edited",
"payment",
"object",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/controllers/admin/oxpspaymorrowpaymentmap.php#L77-L97 | train |
OXID-eSales/paymorrow-module | controllers/admin/oxpspaymorrowpaymentmap.php | OxpsPaymorrowPaymentMap.save | public function save()
{
$aParams = oxRegistry::getConfig()->getRequestParameter( "editval" );
$sOXID = $aParams['oxpayments__oxid'];
/** @var OxpsPaymorrowOxPayment|oxPayment $oxPayment */
$oxPayment = oxNew( 'oxpayment' );
$oxPayment->load( $sOXID );
$blPaymorrowActive = (int) $aParams['oxpayments__oxpspaymorrowactive'];
// Set duplicated payment fields values
$oxPayment = $this->_setDuplicatedFields( $oxPayment, $aParams );
$oxPayment->setPaymorrowActive( $blPaymorrowActive );
$iPaymorrowPaymentMapTo = (int) $aParams['oxpayments__oxpspaymorrowmap'];
if ( $oxPayment->setPaymorrowPaymentMap( $iPaymorrowPaymentMapTo ) ) {
$oxPayment->save();
}
} | php | public function save()
{
$aParams = oxRegistry::getConfig()->getRequestParameter( "editval" );
$sOXID = $aParams['oxpayments__oxid'];
/** @var OxpsPaymorrowOxPayment|oxPayment $oxPayment */
$oxPayment = oxNew( 'oxpayment' );
$oxPayment->load( $sOXID );
$blPaymorrowActive = (int) $aParams['oxpayments__oxpspaymorrowactive'];
// Set duplicated payment fields values
$oxPayment = $this->_setDuplicatedFields( $oxPayment, $aParams );
$oxPayment->setPaymorrowActive( $blPaymorrowActive );
$iPaymorrowPaymentMapTo = (int) $aParams['oxpayments__oxpspaymorrowmap'];
if ( $oxPayment->setPaymorrowPaymentMap( $iPaymorrowPaymentMapTo ) ) {
$oxPayment->save();
}
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"aParams",
"=",
"oxRegistry",
"::",
"getConfig",
"(",
")",
"->",
"getRequestParameter",
"(",
"\"editval\"",
")",
";",
"$",
"sOXID",
"=",
"$",
"aParams",
"[",
"'oxpayments__oxid'",
"]",
";",
"/** @var OxpsPaym... | Save Payment methods mapping to database
@return string|void | [
"Save",
"Payment",
"methods",
"mapping",
"to",
"database"
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/controllers/admin/oxpspaymorrowpaymentmap.php#L105-L127 | train |
OXID-eSales/paymorrow-module | controllers/admin/oxpspaymorrowpaymentmap.php | OxpsPaymorrowPaymentMap._setDuplicatedFields | protected function _setDuplicatedFields( $oPayment, $aParams )
{
$aDuplicatedFields = (array) $this->_aDuplicatedPaymentFields;
foreach ( $aDuplicatedFields as $sFieldName => $sType ) {
$sField = sprintf( '%s__%s', $oPayment->getCoreTableName(), $sFieldName );
if ( !isset( $aParams[$sField] ) and ( $sFieldName != 'oxchecked' ) ) {
continue;
}
$this->_setDuplicatedField( $oPayment, $sFieldName, $sType, $aParams, $sField );
}
return $oPayment;
} | php | protected function _setDuplicatedFields( $oPayment, $aParams )
{
$aDuplicatedFields = (array) $this->_aDuplicatedPaymentFields;
foreach ( $aDuplicatedFields as $sFieldName => $sType ) {
$sField = sprintf( '%s__%s', $oPayment->getCoreTableName(), $sFieldName );
if ( !isset( $aParams[$sField] ) and ( $sFieldName != 'oxchecked' ) ) {
continue;
}
$this->_setDuplicatedField( $oPayment, $sFieldName, $sType, $aParams, $sField );
}
return $oPayment;
} | [
"protected",
"function",
"_setDuplicatedFields",
"(",
"$",
"oPayment",
",",
"$",
"aParams",
")",
"{",
"$",
"aDuplicatedFields",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"_aDuplicatedPaymentFields",
";",
"foreach",
"(",
"$",
"aDuplicatedFields",
"as",
"$",
"s... | Set payment model duplicated fields values from array.
Makes sure, that field is in the array.
For amount type field validates if value is correct.
@param OxpsPaymorrowOxPayment|oxPayment $oPayment
@param array $aParams
@return OxpsPaymorrowOxPayment|oxPayment | [
"Set",
"payment",
"model",
"duplicated",
"fields",
"values",
"from",
"array",
".",
"Makes",
"sure",
"that",
"field",
"is",
"in",
"the",
"array",
".",
"For",
"amount",
"type",
"field",
"validates",
"if",
"value",
"is",
"correct",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/controllers/admin/oxpspaymorrowpaymentmap.php#L140-L155 | train |
OXID-eSales/paymorrow-module | controllers/admin/oxpspaymorrowpaymentmap.php | OxpsPaymorrowPaymentMap._setDuplicatedField | protected function _setDuplicatedField( $oPayment, $sFieldName, $sType, $aParams, $sField )
{
$mValue = $aParams[$sField];
settype( $mValue, $sType );
if ( ( $sFieldName == 'oxaddsumtype' ) and !in_array( $mValue, array('abs', '%') ) ) {
return false;
}
$oPayment->$sField = new oxField( $mValue );
return true;
} | php | protected function _setDuplicatedField( $oPayment, $sFieldName, $sType, $aParams, $sField )
{
$mValue = $aParams[$sField];
settype( $mValue, $sType );
if ( ( $sFieldName == 'oxaddsumtype' ) and !in_array( $mValue, array('abs', '%') ) ) {
return false;
}
$oPayment->$sField = new oxField( $mValue );
return true;
} | [
"protected",
"function",
"_setDuplicatedField",
"(",
"$",
"oPayment",
",",
"$",
"sFieldName",
",",
"$",
"sType",
",",
"$",
"aParams",
",",
"$",
"sField",
")",
"{",
"$",
"mValue",
"=",
"$",
"aParams",
"[",
"$",
"sField",
"]",
";",
"settype",
"(",
"$",
... | Check if field if valid and ok to set a value.
@param OxpsPaymorrowOxPayment|oxPayment $oPayment
@param string $sFieldName
@param string $sType
@param array $aParams
@param string $sField
@return bool | [
"Check",
"if",
"field",
"if",
"valid",
"and",
"ok",
"to",
"set",
"a",
"value",
"."
] | adb5d7f50c2fa5b566abd262161c483c42847b42 | https://github.com/OXID-eSales/paymorrow-module/blob/adb5d7f50c2fa5b566abd262161c483c42847b42/controllers/admin/oxpspaymorrowpaymentmap.php#L168-L180 | train |
hostnet/accessor-generator-plugin-lib | src/Reflection/ReflectionProperty.php | ReflectionProperty.setModifiers | private function setModifiers(?int $modifiers): void
{
// Default to private.
if ($modifiers === null) {
$this->modifiers = \ReflectionProperty::IS_PRIVATE;
return;
}
// Get the number of active visibility modifiers amount all modifies.
$active_visibility_modifiers =
((bool) ($modifiers & \ReflectionProperty::IS_PRIVATE)) +
((bool) ($modifiers & \ReflectionProperty::IS_PROTECTED)) +
((bool) ($modifiers & \ReflectionProperty::IS_PUBLIC));
// Not one and only one of private, protected and public is selected, throw exception.
if ($active_visibility_modifiers !== 1) {
throw new \DomainException(sprintf(
'$modifiers (%s) has not ONE of IS_PRIVATE, IS_PROTECTED or IS_PUBLIC set, but found %s.',
$modifiers,
$active_visibility_modifiers
));
}
$this->modifiers = $modifiers;
} | php | private function setModifiers(?int $modifiers): void
{
// Default to private.
if ($modifiers === null) {
$this->modifiers = \ReflectionProperty::IS_PRIVATE;
return;
}
// Get the number of active visibility modifiers amount all modifies.
$active_visibility_modifiers =
((bool) ($modifiers & \ReflectionProperty::IS_PRIVATE)) +
((bool) ($modifiers & \ReflectionProperty::IS_PROTECTED)) +
((bool) ($modifiers & \ReflectionProperty::IS_PUBLIC));
// Not one and only one of private, protected and public is selected, throw exception.
if ($active_visibility_modifiers !== 1) {
throw new \DomainException(sprintf(
'$modifiers (%s) has not ONE of IS_PRIVATE, IS_PROTECTED or IS_PUBLIC set, but found %s.',
$modifiers,
$active_visibility_modifiers
));
}
$this->modifiers = $modifiers;
} | [
"private",
"function",
"setModifiers",
"(",
"?",
"int",
"$",
"modifiers",
")",
":",
"void",
"{",
"// Default to private.",
"if",
"(",
"$",
"modifiers",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"modifiers",
"=",
"\\",
"ReflectionProperty",
"::",
"IS_PRIVAT... | Check modifiers for right type and to have at least a visibility bit
enabled. Also turns null into private visibility.
@throws \InvalidArgumentException
@throws \DomainException
@param int|null $modifiers | [
"Check",
"modifiers",
"for",
"right",
"type",
"and",
"to",
"have",
"at",
"least",
"a",
"visibility",
"bit",
"enabled",
".",
"Also",
"turns",
"null",
"into",
"private",
"visibility",
"."
] | 0ff78bed5dddb4bec9fd64500f822a28ce987f62 | https://github.com/hostnet/accessor-generator-plugin-lib/blob/0ff78bed5dddb4bec9fd64500f822a28ce987f62/src/Reflection/ReflectionProperty.php#L63-L88 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.