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
jonesiscoding/device
src/DetectByUserAgent.php
DetectByUserAgent.isOpera
private function isOpera() { $is = false; // The 'Opera/x.xx' stopped at 9.80, then the version went into the 'Version/x.x.x' format. if ( preg_match("/(Opera)\/9.80.*Version\/((\d+)\.(\d+)(?:\.(\d+))?)/", $this->ua, $matches) ) { $is = true; $version = $matches[ 2 ]; $major = $matches[ 3 ]; $minor = $matches[ 4 ]; } // Earlier versions had the version in 'Opera/x.xx' format. elseif ( preg_match( "/Opera (([0-9]+)\.?([0-9]*))/", $this->ua, $matches ) ) { $is = true; $version = $matches[ 1 ]; $major = $matches[ 2 ]; $minor = $matches[ 3 ]; } // Some versions of Opera Mobile look like this. Luckily it's got OPR in the string or we'd think it was Safari. elseif ( preg_match( "/(?:Mobile Safari).*(OPR)\/(\d+)\.(\d+)\.(\d+)/", $this->ua, $matches ) ) { $is = true; $version = $matches[ 2 ]; $major = $matches[ 3 ]; $minor = $matches[ 4 ]; } // Opera version 15 was a freak UA, looking like Chrome, but with OPR in the string. elseif ( preg_match( "/(?:Chrome).*(OPR)\/(\d+)\.(\d+)\.(\d+)/", $this->ua, $matches ) ) { $is = true; $version = $matches[ 2 ]; $major = $matches[ 3 ]; $minor = $matches[ 4 ]; } if ( $is && isset( $version, $major, $minor ) ) { $this->browser = "opera"; $this->version = $version; $this->major = $major; $this->minor = $minor; return true; } return false; }
php
private function isOpera() { $is = false; // The 'Opera/x.xx' stopped at 9.80, then the version went into the 'Version/x.x.x' format. if ( preg_match("/(Opera)\/9.80.*Version\/((\d+)\.(\d+)(?:\.(\d+))?)/", $this->ua, $matches) ) { $is = true; $version = $matches[ 2 ]; $major = $matches[ 3 ]; $minor = $matches[ 4 ]; } // Earlier versions had the version in 'Opera/x.xx' format. elseif ( preg_match( "/Opera (([0-9]+)\.?([0-9]*))/", $this->ua, $matches ) ) { $is = true; $version = $matches[ 1 ]; $major = $matches[ 2 ]; $minor = $matches[ 3 ]; } // Some versions of Opera Mobile look like this. Luckily it's got OPR in the string or we'd think it was Safari. elseif ( preg_match( "/(?:Mobile Safari).*(OPR)\/(\d+)\.(\d+)\.(\d+)/", $this->ua, $matches ) ) { $is = true; $version = $matches[ 2 ]; $major = $matches[ 3 ]; $minor = $matches[ 4 ]; } // Opera version 15 was a freak UA, looking like Chrome, but with OPR in the string. elseif ( preg_match( "/(?:Chrome).*(OPR)\/(\d+)\.(\d+)\.(\d+)/", $this->ua, $matches ) ) { $is = true; $version = $matches[ 2 ]; $major = $matches[ 3 ]; $minor = $matches[ 4 ]; } if ( $is && isset( $version, $major, $minor ) ) { $this->browser = "opera"; $this->version = $version; $this->major = $major; $this->minor = $minor; return true; } return false; }
[ "private", "function", "isOpera", "(", ")", "{", "$", "is", "=", "false", ";", "// The 'Opera/x.xx' stopped at 9.80, then the version went into the 'Version/x.x.x' format.", "if", "(", "preg_match", "(", "\"/(Opera)\\/9.80.*Version\\/((\\d+)\\.(\\d+)(?:\\.(\\d+))?)/\"", ",", "$", "this", "->", "ua", ",", "$", "matches", ")", ")", "{", "$", "is", "=", "true", ";", "$", "version", "=", "$", "matches", "[", "2", "]", ";", "$", "major", "=", "$", "matches", "[", "3", "]", ";", "$", "minor", "=", "$", "matches", "[", "4", "]", ";", "}", "// Earlier versions had the version in 'Opera/x.xx' format.", "elseif", "(", "preg_match", "(", "\"/Opera (([0-9]+)\\.?([0-9]*))/\"", ",", "$", "this", "->", "ua", ",", "$", "matches", ")", ")", "{", "$", "is", "=", "true", ";", "$", "version", "=", "$", "matches", "[", "1", "]", ";", "$", "major", "=", "$", "matches", "[", "2", "]", ";", "$", "minor", "=", "$", "matches", "[", "3", "]", ";", "}", "// Some versions of Opera Mobile look like this. Luckily it's got OPR in the string or we'd think it was Safari.", "elseif", "(", "preg_match", "(", "\"/(?:Mobile Safari).*(OPR)\\/(\\d+)\\.(\\d+)\\.(\\d+)/\"", ",", "$", "this", "->", "ua", ",", "$", "matches", ")", ")", "{", "$", "is", "=", "true", ";", "$", "version", "=", "$", "matches", "[", "2", "]", ";", "$", "major", "=", "$", "matches", "[", "3", "]", ";", "$", "minor", "=", "$", "matches", "[", "4", "]", ";", "}", "// Opera version 15 was a freak UA, looking like Chrome, but with OPR in the string.", "elseif", "(", "preg_match", "(", "\"/(?:Chrome).*(OPR)\\/(\\d+)\\.(\\d+)\\.(\\d+)/\"", ",", "$", "this", "->", "ua", ",", "$", "matches", ")", ")", "{", "$", "is", "=", "true", ";", "$", "version", "=", "$", "matches", "[", "2", "]", ";", "$", "major", "=", "$", "matches", "[", "3", "]", ";", "$", "minor", "=", "$", "matches", "[", "4", "]", ";", "}", "if", "(", "$", "is", "&&", "isset", "(", "$", "version", ",", "$", "major", ",", "$", "minor", ")", ")", "{", "$", "this", "->", "browser", "=", "\"opera\"", ";", "$", "this", "->", "version", "=", "$", "version", ";", "$", "this", "->", "major", "=", "$", "major", ";", "$", "this", "->", "minor", "=", "$", "minor", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determines if a browser is Opera by the user agent string. @return bool
[ "Determines", "if", "a", "browser", "is", "Opera", "by", "the", "user", "agent", "string", "." ]
d3c66f934bcaa8e5e0424cf684c995b1c80cee29
https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DetectByUserAgent.php#L422-L469
train
jonesiscoding/device
src/DetectByUserAgent.php
DetectByUserAgent.isOperaMobile
private function isOperaMobile() { $is = false; $android = false; $ios = false; $tablet = false; $phone = false; $touch = false; if ( $this->browser == 'opera' || $this->isOpera() ) { // This is definitely opera mobile, strangely, on Android if ( preg_match( "/(?:Mobile Safari).*(OPR)/", $this->ua ) ) { $is = true; $android = true; } // Ok, perhaps we can find these things in the UA giving us a clue. elseif ( preg_match( '/(mobi|mini)/i', $this->ua ) ) { $is = true; // Header set by Opera Mini only. No longer used, but older versions still have it. if ( isset( $_SERVER[ 'HTTP_X_OPERAMINI_PHONE_UA' ] ) ) { $phone = true; $tablet = false; $android = ( isset( $_SERVER[ 'Device-Stock-UA' ] ) && stripos( $_SERVER[ 'Device-Stock-UA' ], 'android' ) !== false ) ? true : false; $touch = ( $android || stripos( $_SERVER[ 'Device-Stock-UA' ], 'touch' ) !== false ) ? true : false; } // Header set by Opera Mini and Mobile with the original Device's User Agent. We can get some extra info from this. elseif ( isset( $_SERVER[ 'Device-Stock-UA' ] ) ) { $tablet = ( stripos( $_SERVER[ 'Device-Stock-UA' ], 'tablet' ) !== false ) ? true : false; $phone = ( !$tablet && ( stripos( $_SERVER[ 'Device-Stock-UA' ], 'phone' ) !== false ) ) ? true : false; $android = ( stripos( $_SERVER[ 'Device-Stock-UA' ], 'android' ) !== false ) ? true : false; $touch = ( $android || stripos( $_SERVER[ 'Device-Stock-UA' ], 'touch' ) !== false ) ? true : false; } // No extra info available, let's see what we can still find out. We'll assume it's a phone if it does say tablet. else { $tablet = ( stripos( $this->ua, 'tablet' ) !== false ) ? true : false; $phone = ( $tablet ) ? false : true; if ( $tablet || stripos( $this->ua, 'mini' ) === false ) { $touch = true; } } } } if ( $is ) { $this->mobile = true; $this->android = $android; $this->ios = $ios; $this->tablet = $tablet; $this->phone = $phone; $this->touch = $touch; } return $is; }
php
private function isOperaMobile() { $is = false; $android = false; $ios = false; $tablet = false; $phone = false; $touch = false; if ( $this->browser == 'opera' || $this->isOpera() ) { // This is definitely opera mobile, strangely, on Android if ( preg_match( "/(?:Mobile Safari).*(OPR)/", $this->ua ) ) { $is = true; $android = true; } // Ok, perhaps we can find these things in the UA giving us a clue. elseif ( preg_match( '/(mobi|mini)/i', $this->ua ) ) { $is = true; // Header set by Opera Mini only. No longer used, but older versions still have it. if ( isset( $_SERVER[ 'HTTP_X_OPERAMINI_PHONE_UA' ] ) ) { $phone = true; $tablet = false; $android = ( isset( $_SERVER[ 'Device-Stock-UA' ] ) && stripos( $_SERVER[ 'Device-Stock-UA' ], 'android' ) !== false ) ? true : false; $touch = ( $android || stripos( $_SERVER[ 'Device-Stock-UA' ], 'touch' ) !== false ) ? true : false; } // Header set by Opera Mini and Mobile with the original Device's User Agent. We can get some extra info from this. elseif ( isset( $_SERVER[ 'Device-Stock-UA' ] ) ) { $tablet = ( stripos( $_SERVER[ 'Device-Stock-UA' ], 'tablet' ) !== false ) ? true : false; $phone = ( !$tablet && ( stripos( $_SERVER[ 'Device-Stock-UA' ], 'phone' ) !== false ) ) ? true : false; $android = ( stripos( $_SERVER[ 'Device-Stock-UA' ], 'android' ) !== false ) ? true : false; $touch = ( $android || stripos( $_SERVER[ 'Device-Stock-UA' ], 'touch' ) !== false ) ? true : false; } // No extra info available, let's see what we can still find out. We'll assume it's a phone if it does say tablet. else { $tablet = ( stripos( $this->ua, 'tablet' ) !== false ) ? true : false; $phone = ( $tablet ) ? false : true; if ( $tablet || stripos( $this->ua, 'mini' ) === false ) { $touch = true; } } } } if ( $is ) { $this->mobile = true; $this->android = $android; $this->ios = $ios; $this->tablet = $tablet; $this->phone = $phone; $this->touch = $touch; } return $is; }
[ "private", "function", "isOperaMobile", "(", ")", "{", "$", "is", "=", "false", ";", "$", "android", "=", "false", ";", "$", "ios", "=", "false", ";", "$", "tablet", "=", "false", ";", "$", "phone", "=", "false", ";", "$", "touch", "=", "false", ";", "if", "(", "$", "this", "->", "browser", "==", "'opera'", "||", "$", "this", "->", "isOpera", "(", ")", ")", "{", "// This is definitely opera mobile, strangely, on Android", "if", "(", "preg_match", "(", "\"/(?:Mobile Safari).*(OPR)/\"", ",", "$", "this", "->", "ua", ")", ")", "{", "$", "is", "=", "true", ";", "$", "android", "=", "true", ";", "}", "// Ok, perhaps we can find these things in the UA giving us a clue.", "elseif", "(", "preg_match", "(", "'/(mobi|mini)/i'", ",", "$", "this", "->", "ua", ")", ")", "{", "$", "is", "=", "true", ";", "// Header set by Opera Mini only. No longer used, but older versions still have it.", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_X_OPERAMINI_PHONE_UA'", "]", ")", ")", "{", "$", "phone", "=", "true", ";", "$", "tablet", "=", "false", ";", "$", "android", "=", "(", "isset", "(", "$", "_SERVER", "[", "'Device-Stock-UA'", "]", ")", "&&", "stripos", "(", "$", "_SERVER", "[", "'Device-Stock-UA'", "]", ",", "'android'", ")", "!==", "false", ")", "?", "true", ":", "false", ";", "$", "touch", "=", "(", "$", "android", "||", "stripos", "(", "$", "_SERVER", "[", "'Device-Stock-UA'", "]", ",", "'touch'", ")", "!==", "false", ")", "?", "true", ":", "false", ";", "}", "// Header set by Opera Mini and Mobile with the original Device's User Agent. We can get some extra info from this.", "elseif", "(", "isset", "(", "$", "_SERVER", "[", "'Device-Stock-UA'", "]", ")", ")", "{", "$", "tablet", "=", "(", "stripos", "(", "$", "_SERVER", "[", "'Device-Stock-UA'", "]", ",", "'tablet'", ")", "!==", "false", ")", "?", "true", ":", "false", ";", "$", "phone", "=", "(", "!", "$", "tablet", "&&", "(", "stripos", "(", "$", "_SERVER", "[", "'Device-Stock-UA'", "]", ",", "'phone'", ")", "!==", "false", ")", ")", "?", "true", ":", "false", ";", "$", "android", "=", "(", "stripos", "(", "$", "_SERVER", "[", "'Device-Stock-UA'", "]", ",", "'android'", ")", "!==", "false", ")", "?", "true", ":", "false", ";", "$", "touch", "=", "(", "$", "android", "||", "stripos", "(", "$", "_SERVER", "[", "'Device-Stock-UA'", "]", ",", "'touch'", ")", "!==", "false", ")", "?", "true", ":", "false", ";", "}", "// No extra info available, let's see what we can still find out. We'll assume it's a phone if it does say tablet.", "else", "{", "$", "tablet", "=", "(", "stripos", "(", "$", "this", "->", "ua", ",", "'tablet'", ")", "!==", "false", ")", "?", "true", ":", "false", ";", "$", "phone", "=", "(", "$", "tablet", ")", "?", "false", ":", "true", ";", "if", "(", "$", "tablet", "||", "stripos", "(", "$", "this", "->", "ua", ",", "'mini'", ")", "===", "false", ")", "{", "$", "touch", "=", "true", ";", "}", "}", "}", "}", "if", "(", "$", "is", ")", "{", "$", "this", "->", "mobile", "=", "true", ";", "$", "this", "->", "android", "=", "$", "android", ";", "$", "this", "->", "ios", "=", "$", "ios", ";", "$", "this", "->", "tablet", "=", "$", "tablet", ";", "$", "this", "->", "phone", "=", "$", "phone", ";", "$", "this", "->", "touch", "=", "$", "touch", ";", "}", "return", "$", "is", ";", "}" ]
Determines if the browser is the mobile or mini version of opera by the user agent string. @return bool
[ "Determines", "if", "the", "browser", "is", "the", "mobile", "or", "mini", "version", "of", "opera", "by", "the", "user", "agent", "string", "." ]
d3c66f934bcaa8e5e0424cf684c995b1c80cee29
https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DetectByUserAgent.php#L519-L580
train
jonesiscoding/device
src/DetectByUserAgent.php
DetectByUserAgent.isChromeMobile
private function isChromeMobile() { $is = false; $android = false; $ios = false; $tablet = false; $phone = false; if ( $this->browser == 'chrome' || $this->isChrome() ) { // We aren't differentiating between Chrome and webview. It doesn't matter for our purposes. if ( stripos( $this->ua, 'android' ) !== false ) { $is = true; $android = true; $tablet = ( stripos( $this->ua, 'mobile' ) !== false ) ? false : true; $phone = ($tablet) ? false : true; } // Only says this on iOS. Where it's really Safari. Yuck. elseif ( strpos( $this->ua, 'CriOS' ) !== false ) { $is = true; $ios = true; $phone = preg_match("/(iPhone|iPod)/", $this->ua ); $tablet = (strpos($this->ua, 'iPad') !== false) ? true : false; } } if ( $is ) { $this->android = $android; $this->ios = $ios; $this->tablet = $tablet; $this->phone = $phone; $this->mobile = true; $this->touch = true; } return $is; }
php
private function isChromeMobile() { $is = false; $android = false; $ios = false; $tablet = false; $phone = false; if ( $this->browser == 'chrome' || $this->isChrome() ) { // We aren't differentiating between Chrome and webview. It doesn't matter for our purposes. if ( stripos( $this->ua, 'android' ) !== false ) { $is = true; $android = true; $tablet = ( stripos( $this->ua, 'mobile' ) !== false ) ? false : true; $phone = ($tablet) ? false : true; } // Only says this on iOS. Where it's really Safari. Yuck. elseif ( strpos( $this->ua, 'CriOS' ) !== false ) { $is = true; $ios = true; $phone = preg_match("/(iPhone|iPod)/", $this->ua ); $tablet = (strpos($this->ua, 'iPad') !== false) ? true : false; } } if ( $is ) { $this->android = $android; $this->ios = $ios; $this->tablet = $tablet; $this->phone = $phone; $this->mobile = true; $this->touch = true; } return $is; }
[ "private", "function", "isChromeMobile", "(", ")", "{", "$", "is", "=", "false", ";", "$", "android", "=", "false", ";", "$", "ios", "=", "false", ";", "$", "tablet", "=", "false", ";", "$", "phone", "=", "false", ";", "if", "(", "$", "this", "->", "browser", "==", "'chrome'", "||", "$", "this", "->", "isChrome", "(", ")", ")", "{", "// We aren't differentiating between Chrome and webview. It doesn't matter for our purposes.", "if", "(", "stripos", "(", "$", "this", "->", "ua", ",", "'android'", ")", "!==", "false", ")", "{", "$", "is", "=", "true", ";", "$", "android", "=", "true", ";", "$", "tablet", "=", "(", "stripos", "(", "$", "this", "->", "ua", ",", "'mobile'", ")", "!==", "false", ")", "?", "false", ":", "true", ";", "$", "phone", "=", "(", "$", "tablet", ")", "?", "false", ":", "true", ";", "}", "// Only says this on iOS. Where it's really Safari. Yuck.", "elseif", "(", "strpos", "(", "$", "this", "->", "ua", ",", "'CriOS'", ")", "!==", "false", ")", "{", "$", "is", "=", "true", ";", "$", "ios", "=", "true", ";", "$", "phone", "=", "preg_match", "(", "\"/(iPhone|iPod)/\"", ",", "$", "this", "->", "ua", ")", ";", "$", "tablet", "=", "(", "strpos", "(", "$", "this", "->", "ua", ",", "'iPad'", ")", "!==", "false", ")", "?", "true", ":", "false", ";", "}", "}", "if", "(", "$", "is", ")", "{", "$", "this", "->", "android", "=", "$", "android", ";", "$", "this", "->", "ios", "=", "$", "ios", ";", "$", "this", "->", "tablet", "=", "$", "tablet", ";", "$", "this", "->", "phone", "=", "$", "phone", ";", "$", "this", "->", "mobile", "=", "true", ";", "$", "this", "->", "touch", "=", "true", ";", "}", "return", "$", "is", ";", "}" ]
Determines if the browser is Chrome on a mobile device by the user agent string. @return bool
[ "Determines", "if", "the", "browser", "is", "Chrome", "on", "a", "mobile", "device", "by", "the", "user", "agent", "string", "." ]
d3c66f934bcaa8e5e0424cf684c995b1c80cee29
https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DetectByUserAgent.php#L587-L625
train
jonesiscoding/device
src/DetectByUserAgent.php
DetectByUserAgent.isSafariMobile
private function isSafariMobile() { $is = false; $tablet = false; $phone = false; if ( $this->browser == 'safari' || $this->isSafari() ) { // We aren't differentiating between Safari and Apps. It doesn't matter for our purposes. // We also don't care if it's an iPod or iPhone, it's the size we care about. if ( preg_match("/(iPhone|iPod|iPad)/", $this->ua, $matches ) ) { $is = true; $tablet = ( $matches[1] == 'iPad' ); $phone = ($matches[1] == 'iPhone' || $matches[1] == 'iPod'); } } if ( $is ) { $this->android = false; $this->ios = true; $this->tablet = $tablet; $this->phone = $phone; $this->mobile = true; $this->touch = true; } return $is; }
php
private function isSafariMobile() { $is = false; $tablet = false; $phone = false; if ( $this->browser == 'safari' || $this->isSafari() ) { // We aren't differentiating between Safari and Apps. It doesn't matter for our purposes. // We also don't care if it's an iPod or iPhone, it's the size we care about. if ( preg_match("/(iPhone|iPod|iPad)/", $this->ua, $matches ) ) { $is = true; $tablet = ( $matches[1] == 'iPad' ); $phone = ($matches[1] == 'iPhone' || $matches[1] == 'iPod'); } } if ( $is ) { $this->android = false; $this->ios = true; $this->tablet = $tablet; $this->phone = $phone; $this->mobile = true; $this->touch = true; } return $is; }
[ "private", "function", "isSafariMobile", "(", ")", "{", "$", "is", "=", "false", ";", "$", "tablet", "=", "false", ";", "$", "phone", "=", "false", ";", "if", "(", "$", "this", "->", "browser", "==", "'safari'", "||", "$", "this", "->", "isSafari", "(", ")", ")", "{", "// We aren't differentiating between Safari and Apps. It doesn't matter for our purposes.", "// We also don't care if it's an iPod or iPhone, it's the size we care about.", "if", "(", "preg_match", "(", "\"/(iPhone|iPod|iPad)/\"", ",", "$", "this", "->", "ua", ",", "$", "matches", ")", ")", "{", "$", "is", "=", "true", ";", "$", "tablet", "=", "(", "$", "matches", "[", "1", "]", "==", "'iPad'", ")", ";", "$", "phone", "=", "(", "$", "matches", "[", "1", "]", "==", "'iPhone'", "||", "$", "matches", "[", "1", "]", "==", "'iPod'", ")", ";", "}", "}", "if", "(", "$", "is", ")", "{", "$", "this", "->", "android", "=", "false", ";", "$", "this", "->", "ios", "=", "true", ";", "$", "this", "->", "tablet", "=", "$", "tablet", ";", "$", "this", "->", "phone", "=", "$", "phone", ";", "$", "this", "->", "mobile", "=", "true", ";", "$", "this", "->", "touch", "=", "true", ";", "}", "return", "$", "is", ";", "}" ]
Determines if the browser is Safari Mobile by the User Agent String. @return bool
[ "Determines", "if", "the", "browser", "is", "Safari", "Mobile", "by", "the", "User", "Agent", "String", "." ]
d3c66f934bcaa8e5e0424cf684c995b1c80cee29
https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DetectByUserAgent.php#L632-L660
train
jonesiscoding/device
src/DetectByUserAgent.php
DetectByUserAgent.isFirefoxMobile
private function isFirefoxMobile() { $is = false; $tablet = false; $phone = false; $android = false; $touch = true; if ( $this->browser == 'firefox' || $this->isFirefox() ) { if ( preg_match( "/(Mobile|Tablet|TV)/", $this->ua, $matches ) ) { $is = true; $tablet = ($matches[1] == 'Tablet' || $matches[1] == 'TV') ? true : false; $phone = ($matches[1] == 'Mobile') ? true : false; } elseif ( stripos( $this->ua, 'Android' ) !== false ) { // No way to determine phone/tablet $is = true; $android = true; } elseif ( stripos( $this->ua, 'Maemo' ) !== false ) { $is = true; // It's horizontal, which is probably more like a tablet, but it's only 800x480. $phone = true; $android = false; // Yes, the Maemo units have a touch screen, but it's resistive, and doesn't really function like we think // of touch in a current web environment. $touch = false; } elseif ( stripos( $this->ua, 'Fennec' ) !== false ) { // No way to determine phone/tablet OR OS $is = true; } } if ( $is ) { $this->android = $android; // No Firefox for iOS $this->ios = false; $this->tablet = $tablet; $this->phone = $phone; $this->mobile = true; $this->touch = $touch; } return $is; }
php
private function isFirefoxMobile() { $is = false; $tablet = false; $phone = false; $android = false; $touch = true; if ( $this->browser == 'firefox' || $this->isFirefox() ) { if ( preg_match( "/(Mobile|Tablet|TV)/", $this->ua, $matches ) ) { $is = true; $tablet = ($matches[1] == 'Tablet' || $matches[1] == 'TV') ? true : false; $phone = ($matches[1] == 'Mobile') ? true : false; } elseif ( stripos( $this->ua, 'Android' ) !== false ) { // No way to determine phone/tablet $is = true; $android = true; } elseif ( stripos( $this->ua, 'Maemo' ) !== false ) { $is = true; // It's horizontal, which is probably more like a tablet, but it's only 800x480. $phone = true; $android = false; // Yes, the Maemo units have a touch screen, but it's resistive, and doesn't really function like we think // of touch in a current web environment. $touch = false; } elseif ( stripos( $this->ua, 'Fennec' ) !== false ) { // No way to determine phone/tablet OR OS $is = true; } } if ( $is ) { $this->android = $android; // No Firefox for iOS $this->ios = false; $this->tablet = $tablet; $this->phone = $phone; $this->mobile = true; $this->touch = $touch; } return $is; }
[ "private", "function", "isFirefoxMobile", "(", ")", "{", "$", "is", "=", "false", ";", "$", "tablet", "=", "false", ";", "$", "phone", "=", "false", ";", "$", "android", "=", "false", ";", "$", "touch", "=", "true", ";", "if", "(", "$", "this", "->", "browser", "==", "'firefox'", "||", "$", "this", "->", "isFirefox", "(", ")", ")", "{", "if", "(", "preg_match", "(", "\"/(Mobile|Tablet|TV)/\"", ",", "$", "this", "->", "ua", ",", "$", "matches", ")", ")", "{", "$", "is", "=", "true", ";", "$", "tablet", "=", "(", "$", "matches", "[", "1", "]", "==", "'Tablet'", "||", "$", "matches", "[", "1", "]", "==", "'TV'", ")", "?", "true", ":", "false", ";", "$", "phone", "=", "(", "$", "matches", "[", "1", "]", "==", "'Mobile'", ")", "?", "true", ":", "false", ";", "}", "elseif", "(", "stripos", "(", "$", "this", "->", "ua", ",", "'Android'", ")", "!==", "false", ")", "{", "// No way to determine phone/tablet", "$", "is", "=", "true", ";", "$", "android", "=", "true", ";", "}", "elseif", "(", "stripos", "(", "$", "this", "->", "ua", ",", "'Maemo'", ")", "!==", "false", ")", "{", "$", "is", "=", "true", ";", "// It's horizontal, which is probably more like a tablet, but it's only 800x480.", "$", "phone", "=", "true", ";", "$", "android", "=", "false", ";", "// Yes, the Maemo units have a touch screen, but it's resistive, and doesn't really function like we think", "// of touch in a current web environment.", "$", "touch", "=", "false", ";", "}", "elseif", "(", "stripos", "(", "$", "this", "->", "ua", ",", "'Fennec'", ")", "!==", "false", ")", "{", "// No way to determine phone/tablet OR OS", "$", "is", "=", "true", ";", "}", "}", "if", "(", "$", "is", ")", "{", "$", "this", "->", "android", "=", "$", "android", ";", "// No Firefox for iOS", "$", "this", "->", "ios", "=", "false", ";", "$", "this", "->", "tablet", "=", "$", "tablet", ";", "$", "this", "->", "phone", "=", "$", "phone", ";", "$", "this", "->", "mobile", "=", "true", ";", "$", "this", "->", "touch", "=", "$", "touch", ";", "}", "return", "$", "is", ";", "}" ]
Determines if the browser is Firefox Mobile, by the User Agent string. @return bool
[ "Determines", "if", "the", "browser", "is", "Firefox", "Mobile", "by", "the", "User", "Agent", "string", "." ]
d3c66f934bcaa8e5e0424cf684c995b1c80cee29
https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DetectByUserAgent.php#L667-L717
train
pdyn/filesystem
fileuploader/UploadedFile.php
UploadedFile.save
public function save($savepath) { $result = move_uploaded_file($this->stored_filename, $savepath); if ($result === true) { $this->stored_filename = $savepath; return true; } else { return false; } }
php
public function save($savepath) { $result = move_uploaded_file($this->stored_filename, $savepath); if ($result === true) { $this->stored_filename = $savepath; return true; } else { return false; } }
[ "public", "function", "save", "(", "$", "savepath", ")", "{", "$", "result", "=", "move_uploaded_file", "(", "$", "this", "->", "stored_filename", ",", "$", "savepath", ")", ";", "if", "(", "$", "result", "===", "true", ")", "{", "$", "this", "->", "stored_filename", "=", "$", "savepath", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Save the uploaded file to a specific path. @param string $savepath A full path (incl. filename) to save the uploaded file as. @return bool Success/Failure.
[ "Save", "the", "uploaded", "file", "to", "a", "specific", "path", "." ]
e2f780eac166aa60071e601d600133b860ace594
https://github.com/pdyn/filesystem/blob/e2f780eac166aa60071e601d600133b860ace594/fileuploader/UploadedFile.php#L84-L92
train
t3v/t3v_core
Classes/ViewHelpers/SlugViewHelper.php
SlugViewHelper.createSlug
protected static function createSlug(string $input, array $rulesets = self::SLUG_RULESETS, string $separator = '-'): string { $slugify = new Slugify(['rulesets' => $rulesets, 'separator' => $separator]); $slug = $slugify->slugify($input); return $slug; }
php
protected static function createSlug(string $input, array $rulesets = self::SLUG_RULESETS, string $separator = '-'): string { $slugify = new Slugify(['rulesets' => $rulesets, 'separator' => $separator]); $slug = $slugify->slugify($input); return $slug; }
[ "protected", "static", "function", "createSlug", "(", "string", "$", "input", ",", "array", "$", "rulesets", "=", "self", "::", "SLUG_RULESETS", ",", "string", "$", "separator", "=", "'-'", ")", ":", "string", "{", "$", "slugify", "=", "new", "Slugify", "(", "[", "'rulesets'", "=>", "$", "rulesets", ",", "'separator'", "=>", "$", "separator", "]", ")", ";", "$", "slug", "=", "$", "slugify", "->", "slugify", "(", "$", "input", ")", ";", "return", "$", "slug", ";", "}" ]
Creates a slug from an input. @param string $input The input to create a slug from @param array $rulesets The optional rulesets, defaults to `SlugViewHelper::SLUG_RULESETS` @param string $separator The optional separator, defaults to `-` @return string The slug
[ "Creates", "a", "slug", "from", "an", "input", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/ViewHelpers/SlugViewHelper.php#L87-L92
train
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/Rest.php
Rest.createJsonApiAdapter
private function createJsonApiAdapter($configName, ContainerBuilder $container) { // Serializer $serializerName = Utility::getAliasedName('api.serializer'); $definition = new Definition( Utility::getLibraryClass('Api\JsonApiOrg\Serializer') ); $definition->setPublic(false); $container->setDefinition($serializerName, $definition); // Normalizer $normalizerName = Utility::getAliasedName('api.normalizer'); $definition = new Definition( Utility::getLibraryClass('Api\JsonApiOrg\Normalizer') ); $definition->setPublic(false); $container->setDefinition($normalizerName, $definition); // Adapter $definition = new Definition( Utility::getLibraryClass('Api\JsonApiOrg\Adapter'), [ new Reference($serializerName), new Reference($normalizerName), new Reference(Utility::getAliasedName('store')), new Reference($configName), ] ); $definition->setPublic(true); return $definition; }
php
private function createJsonApiAdapter($configName, ContainerBuilder $container) { // Serializer $serializerName = Utility::getAliasedName('api.serializer'); $definition = new Definition( Utility::getLibraryClass('Api\JsonApiOrg\Serializer') ); $definition->setPublic(false); $container->setDefinition($serializerName, $definition); // Normalizer $normalizerName = Utility::getAliasedName('api.normalizer'); $definition = new Definition( Utility::getLibraryClass('Api\JsonApiOrg\Normalizer') ); $definition->setPublic(false); $container->setDefinition($normalizerName, $definition); // Adapter $definition = new Definition( Utility::getLibraryClass('Api\JsonApiOrg\Adapter'), [ new Reference($serializerName), new Reference($normalizerName), new Reference(Utility::getAliasedName('store')), new Reference($configName), ] ); $definition->setPublic(true); return $definition; }
[ "private", "function", "createJsonApiAdapter", "(", "$", "configName", ",", "ContainerBuilder", "$", "container", ")", "{", "// Serializer", "$", "serializerName", "=", "Utility", "::", "getAliasedName", "(", "'api.serializer'", ")", ";", "$", "definition", "=", "new", "Definition", "(", "Utility", "::", "getLibraryClass", "(", "'Api\\JsonApiOrg\\Serializer'", ")", ")", ";", "$", "definition", "->", "setPublic", "(", "false", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "serializerName", ",", "$", "definition", ")", ";", "// Normalizer", "$", "normalizerName", "=", "Utility", "::", "getAliasedName", "(", "'api.normalizer'", ")", ";", "$", "definition", "=", "new", "Definition", "(", "Utility", "::", "getLibraryClass", "(", "'Api\\JsonApiOrg\\Normalizer'", ")", ")", ";", "$", "definition", "->", "setPublic", "(", "false", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "normalizerName", ",", "$", "definition", ")", ";", "// Adapter", "$", "definition", "=", "new", "Definition", "(", "Utility", "::", "getLibraryClass", "(", "'Api\\JsonApiOrg\\Adapter'", ")", ",", "[", "new", "Reference", "(", "$", "serializerName", ")", ",", "new", "Reference", "(", "$", "normalizerName", ")", ",", "new", "Reference", "(", "Utility", "::", "getAliasedName", "(", "'store'", ")", ")", ",", "new", "Reference", "(", "$", "configName", ")", ",", "]", ")", ";", "$", "definition", "->", "setPublic", "(", "true", ")", ";", "return", "$", "definition", ";", "}" ]
Creates the jsonapi.org Adapter service definition. @param string $configName @param ContainerBuilder $container @return Definition
[ "Creates", "the", "jsonapi", ".", "org", "Adapter", "service", "definition", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/Rest.php#L24-L54
train
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/Rest.php
Rest.loadAdapter
private function loadAdapter($adapterName, $configName, array $adapterConfig, ContainerBuilder $container) { if (isset($adapterConfig['service'])) { // Custom adapter service. $container->setAlias($adapterName, Utility::cleanServiceName($adapterConfig['service'])); return $this; } // Built-In Adapter switch ($adapterConfig['type']) { case 'jsonapiorg': $definition = $this->createJsonApiAdapter($configName, $container); break; default: throw new \RuntimeException(sprintf('The adapter type "%s" is currently not supported.', $adapterConfig['type'])); } $container->setDefinition($adapterName, $definition); return $this; }
php
private function loadAdapter($adapterName, $configName, array $adapterConfig, ContainerBuilder $container) { if (isset($adapterConfig['service'])) { // Custom adapter service. $container->setAlias($adapterName, Utility::cleanServiceName($adapterConfig['service'])); return $this; } // Built-In Adapter switch ($adapterConfig['type']) { case 'jsonapiorg': $definition = $this->createJsonApiAdapter($configName, $container); break; default: throw new \RuntimeException(sprintf('The adapter type "%s" is currently not supported.', $adapterConfig['type'])); } $container->setDefinition($adapterName, $definition); return $this; }
[ "private", "function", "loadAdapter", "(", "$", "adapterName", ",", "$", "configName", ",", "array", "$", "adapterConfig", ",", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "isset", "(", "$", "adapterConfig", "[", "'service'", "]", ")", ")", "{", "// Custom adapter service.", "$", "container", "->", "setAlias", "(", "$", "adapterName", ",", "Utility", "::", "cleanServiceName", "(", "$", "adapterConfig", "[", "'service'", "]", ")", ")", ";", "return", "$", "this", ";", "}", "// Built-In Adapter", "switch", "(", "$", "adapterConfig", "[", "'type'", "]", ")", "{", "case", "'jsonapiorg'", ":", "$", "definition", "=", "$", "this", "->", "createJsonApiAdapter", "(", "$", "configName", ",", "$", "container", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The adapter type \"%s\" is currently not supported.'", ",", "$", "adapterConfig", "[", "'type'", "]", ")", ")", ";", "}", "$", "container", "->", "setDefinition", "(", "$", "adapterName", ",", "$", "definition", ")", ";", "return", "$", "this", ";", "}" ]
Loads the Adapter service based on the adapter config. @param string $adapterName @param string $configName @param array $adapterConfig @param ContainerBuilder $container @return self
[ "Loads", "the", "Adapter", "service", "based", "on", "the", "adapter", "config", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/Rest.php#L79-L98
train
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/Rest.php
Rest.loadConfiguration
private function loadConfiguration($name, array $restConfig, ContainerBuilder $container) { $definition = new Definition( Utility::getLibraryClass('Rest\RestConfiguration'), [ new Reference(Utility::getAliasedName('util.validator')), ] ); $definition->setPublic(false); $endpoint = $restConfig['root_endpoint']; $definition->addMethodCall('setRootEndpoint', [$endpoint]); $container->setDefinition($name, $definition); $container->setParameter(Utility::getAliasedName('rest.root_endpoint'), $endpoint); return $this; }
php
private function loadConfiguration($name, array $restConfig, ContainerBuilder $container) { $definition = new Definition( Utility::getLibraryClass('Rest\RestConfiguration'), [ new Reference(Utility::getAliasedName('util.validator')), ] ); $definition->setPublic(false); $endpoint = $restConfig['root_endpoint']; $definition->addMethodCall('setRootEndpoint', [$endpoint]); $container->setDefinition($name, $definition); $container->setParameter(Utility::getAliasedName('rest.root_endpoint'), $endpoint); return $this; }
[ "private", "function", "loadConfiguration", "(", "$", "name", ",", "array", "$", "restConfig", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "definition", "=", "new", "Definition", "(", "Utility", "::", "getLibraryClass", "(", "'Rest\\RestConfiguration'", ")", ",", "[", "new", "Reference", "(", "Utility", "::", "getAliasedName", "(", "'util.validator'", ")", ")", ",", "]", ")", ";", "$", "definition", "->", "setPublic", "(", "false", ")", ";", "$", "endpoint", "=", "$", "restConfig", "[", "'root_endpoint'", "]", ";", "$", "definition", "->", "addMethodCall", "(", "'setRootEndpoint'", ",", "[", "$", "endpoint", "]", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "name", ",", "$", "definition", ")", ";", "$", "container", "->", "setParameter", "(", "Utility", "::", "getAliasedName", "(", "'rest.root_endpoint'", ")", ",", "$", "endpoint", ")", ";", "return", "$", "this", ";", "}" ]
Loads the Rest config service based on the config. @param string $name @param array $restConfig @param ContainerBuilder $container @return self
[ "Loads", "the", "Rest", "config", "service", "based", "on", "the", "config", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/Rest.php#L108-L124
train
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/Rest.php
Rest.loadKernel
private function loadKernel($adapterName, $configName, $debug, ContainerBuilder $container) { $definition = new Definition( Utility::getLibraryClass('Rest\RestKernel'), [ new Reference($adapterName), new Reference($configName), ] ); $definition->addMethodCall('enableDebug', [$debug]); $container->setDefinition(Utility::getAliasedName('rest.kernel'), $definition); }
php
private function loadKernel($adapterName, $configName, $debug, ContainerBuilder $container) { $definition = new Definition( Utility::getLibraryClass('Rest\RestKernel'), [ new Reference($adapterName), new Reference($configName), ] ); $definition->addMethodCall('enableDebug', [$debug]); $container->setDefinition(Utility::getAliasedName('rest.kernel'), $definition); }
[ "private", "function", "loadKernel", "(", "$", "adapterName", ",", "$", "configName", ",", "$", "debug", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "definition", "=", "new", "Definition", "(", "Utility", "::", "getLibraryClass", "(", "'Rest\\RestKernel'", ")", ",", "[", "new", "Reference", "(", "$", "adapterName", ")", ",", "new", "Reference", "(", "$", "configName", ")", ",", "]", ")", ";", "$", "definition", "->", "addMethodCall", "(", "'enableDebug'", ",", "[", "$", "debug", "]", ")", ";", "$", "container", "->", "setDefinition", "(", "Utility", "::", "getAliasedName", "(", "'rest.kernel'", ")", ",", "$", "definition", ")", ";", "}" ]
Loads the Rest Kernel service based on the config. @param string $adapterName @param string $configName @param bool $debug @param ContainerBuilder $container @return self
[ "Loads", "the", "Rest", "Kernel", "service", "based", "on", "the", "config", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/Rest.php#L135-L146
train
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/UnitOfWork.php
UnitOfWork.doRefresh
private function doRefresh($document, array &$visited) { $oid = spl_object_hash($document); if (isset($visited[$oid])) { return; // Prevent infinite recursion } $visited[$oid] = $document; // mark visited $class = $this->dm->getClassMetadata(get_class($document)); if (!$class->isEmbeddedDocument) { if ($this->getDocumentState($document) !== self::STATE_MANAGED) { throw new \InvalidArgumentException('Document is not MANAGED.'); } $identifier = $this->documentIdentifiers[$oid]; $this->getDocumentPersister($class->name)->refresh($identifier, $document); } $this->cascadeRefresh($document, $visited); }
php
private function doRefresh($document, array &$visited) { $oid = spl_object_hash($document); if (isset($visited[$oid])) { return; // Prevent infinite recursion } $visited[$oid] = $document; // mark visited $class = $this->dm->getClassMetadata(get_class($document)); if (!$class->isEmbeddedDocument) { if ($this->getDocumentState($document) !== self::STATE_MANAGED) { throw new \InvalidArgumentException('Document is not MANAGED.'); } $identifier = $this->documentIdentifiers[$oid]; $this->getDocumentPersister($class->name)->refresh($identifier, $document); } $this->cascadeRefresh($document, $visited); }
[ "private", "function", "doRefresh", "(", "$", "document", ",", "array", "&", "$", "visited", ")", "{", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "if", "(", "isset", "(", "$", "visited", "[", "$", "oid", "]", ")", ")", "{", "return", ";", "// Prevent infinite recursion", "}", "$", "visited", "[", "$", "oid", "]", "=", "$", "document", ";", "// mark visited", "$", "class", "=", "$", "this", "->", "dm", "->", "getClassMetadata", "(", "get_class", "(", "$", "document", ")", ")", ";", "if", "(", "!", "$", "class", "->", "isEmbeddedDocument", ")", "{", "if", "(", "$", "this", "->", "getDocumentState", "(", "$", "document", ")", "!==", "self", "::", "STATE_MANAGED", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Document is not MANAGED.'", ")", ";", "}", "$", "identifier", "=", "$", "this", "->", "documentIdentifiers", "[", "$", "oid", "]", ";", "$", "this", "->", "getDocumentPersister", "(", "$", "class", "->", "name", ")", "->", "refresh", "(", "$", "identifier", ",", "$", "document", ")", ";", "}", "$", "this", "->", "cascadeRefresh", "(", "$", "document", ",", "$", "visited", ")", ";", "}" ]
Executes a refresh operation on a document. @param object $document The document to refresh. @param array $visited The already visited documents during cascades. @return void @throws \InvalidArgumentException If the document is not MANAGED.
[ "Executes", "a", "refresh", "operation", "on", "a", "document", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/UnitOfWork.php#L1439-L1460
train
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/UnitOfWork.php
UnitOfWork.getAssociationPersister
public function getAssociationPersister() { if (!isset($this->associationPersister)) { $this->associationPersister = new Persister\AssociationPersister( $this->dm, $this ); } return $this->associationPersister; }
php
public function getAssociationPersister() { if (!isset($this->associationPersister)) { $this->associationPersister = new Persister\AssociationPersister( $this->dm, $this ); } return $this->associationPersister; }
[ "public", "function", "getAssociationPersister", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "associationPersister", ")", ")", "{", "$", "this", "->", "associationPersister", "=", "new", "Persister", "\\", "AssociationPersister", "(", "$", "this", "->", "dm", ",", "$", "this", ")", ";", "}", "return", "$", "this", "->", "associationPersister", ";", "}" ]
Get the association persister instance. @return Persister\AssociationPersister
[ "Get", "the", "association", "persister", "instance", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/UnitOfWork.php#L1687-L1697
train
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/UnitOfWork.php
UnitOfWork.getDocumentIdentifier
public function getDocumentIdentifier($document) { return isset($this->documentIdentifiers[spl_object_hash($document)]) ? $this->documentIdentifiers[spl_object_hash($document)] : null; }
php
public function getDocumentIdentifier($document) { return isset($this->documentIdentifiers[spl_object_hash($document)]) ? $this->documentIdentifiers[spl_object_hash($document)] : null; }
[ "public", "function", "getDocumentIdentifier", "(", "$", "document", ")", "{", "return", "isset", "(", "$", "this", "->", "documentIdentifiers", "[", "spl_object_hash", "(", "$", "document", ")", "]", ")", "?", "$", "this", "->", "documentIdentifiers", "[", "spl_object_hash", "(", "$", "document", ")", "]", ":", "null", ";", "}" ]
Gets the identifier of a document. @param object $document @return Identifier|null The identifier instance for the document
[ "Gets", "the", "identifier", "of", "a", "document", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/UnitOfWork.php#L1839-L1843
train
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/UnitOfWork.php
UnitOfWork.size
public function size() { $count = 0; foreach ($this->identityMap as $documentSet) { $count += count($documentSet); } return $count; }
php
public function size() { $count = 0; foreach ($this->identityMap as $documentSet) { $count += count($documentSet); } return $count; }
[ "public", "function", "size", "(", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "identityMap", "as", "$", "documentSet", ")", "{", "$", "count", "+=", "count", "(", "$", "documentSet", ")", ";", "}", "return", "$", "count", ";", "}" ]
Calculates the size of the UnitOfWork. The size of the UnitOfWork is the number of documents in the identity map. @return int
[ "Calculates", "the", "size", "of", "the", "UnitOfWork", ".", "The", "size", "of", "the", "UnitOfWork", "is", "the", "number", "of", "documents", "in", "the", "identity", "map", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/UnitOfWork.php#L3023-L3031
train
RocketPropelledTortoise/Core
src/Taxonomy/Repositories/TermHierarchyRepository.php
TermHierarchyRepository.supportsCommonTableExpressionQuery
protected function supportsCommonTableExpressionQuery() { $driver = DB::connection()->getDriverName(); if ($driver == 'mysql') { return true; } if ($driver == 'sqlite' && \SQLite3::version()['versionNumber'] >= 3008003) { return true; } return false; }
php
protected function supportsCommonTableExpressionQuery() { $driver = DB::connection()->getDriverName(); if ($driver == 'mysql') { return true; } if ($driver == 'sqlite' && \SQLite3::version()['versionNumber'] >= 3008003) { return true; } return false; }
[ "protected", "function", "supportsCommonTableExpressionQuery", "(", ")", "{", "$", "driver", "=", "DB", "::", "connection", "(", ")", "->", "getDriverName", "(", ")", ";", "if", "(", "$", "driver", "==", "'mysql'", ")", "{", "return", "true", ";", "}", "if", "(", "$", "driver", "==", "'sqlite'", "&&", "\\", "SQLite3", "::", "version", "(", ")", "[", "'versionNumber'", "]", ">=", "3008003", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Tests if the driver supports Common Table Expression. If it doesn't we'll fall back to a manually recursive query. @return bool
[ "Tests", "if", "the", "driver", "supports", "Common", "Table", "Expression", "." ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Repositories/TermHierarchyRepository.php#L72-L85
train
RocketPropelledTortoise/Core
src/Taxonomy/Repositories/TermHierarchyRepository.php
TermHierarchyRepository.getDescent
public function getDescent($id) { $key = $this->getCacheKey('descent', $id); if ($results = $this->cache->get($key)) { return $results; } $this->cache->add($key, $results = $this->getRecursiveRetriever()->getDescent($id), 2); return $results; }
php
public function getDescent($id) { $key = $this->getCacheKey('descent', $id); if ($results = $this->cache->get($key)) { return $results; } $this->cache->add($key, $results = $this->getRecursiveRetriever()->getDescent($id), 2); return $results; }
[ "public", "function", "getDescent", "(", "$", "id", ")", "{", "$", "key", "=", "$", "this", "->", "getCacheKey", "(", "'descent'", ",", "$", "id", ")", ";", "if", "(", "$", "results", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "key", ")", ")", "{", "return", "$", "results", ";", "}", "$", "this", "->", "cache", "->", "add", "(", "$", "key", ",", "$", "results", "=", "$", "this", "->", "getRecursiveRetriever", "(", ")", "->", "getDescent", "(", "$", "id", ")", ",", "2", ")", ";", "return", "$", "results", ";", "}" ]
Get all childs recursively. @param int $id The term's id @return \Illuminate\Support\Collection
[ "Get", "all", "childs", "recursively", "." ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Repositories/TermHierarchyRepository.php#L137-L147
train
RocketPropelledTortoise/Core
src/Taxonomy/Repositories/TermHierarchyRepository.php
TermHierarchyRepository.prepareVertices
protected function prepareVertices($data) { $vertices = []; foreach ($data as $content) { // identifiers must be strings or SplObjectStorage::contains fails // seems to impact only PHP 5.6 $content->term_id = "$content->term_id"; $content->parent_id = "$content->parent_id"; if (!array_key_exists($content->term_id, $vertices)) { $vertices[$content->term_id] = new Vertex($content->term_id); } if (!array_key_exists($content->parent_id, $vertices)) { $vertices[$content->parent_id] = new Vertex($content->parent_id); } } return $vertices; }
php
protected function prepareVertices($data) { $vertices = []; foreach ($data as $content) { // identifiers must be strings or SplObjectStorage::contains fails // seems to impact only PHP 5.6 $content->term_id = "$content->term_id"; $content->parent_id = "$content->parent_id"; if (!array_key_exists($content->term_id, $vertices)) { $vertices[$content->term_id] = new Vertex($content->term_id); } if (!array_key_exists($content->parent_id, $vertices)) { $vertices[$content->parent_id] = new Vertex($content->parent_id); } } return $vertices; }
[ "protected", "function", "prepareVertices", "(", "$", "data", ")", "{", "$", "vertices", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "content", ")", "{", "// identifiers must be strings or SplObjectStorage::contains fails", "// seems to impact only PHP 5.6", "$", "content", "->", "term_id", "=", "\"$content->term_id\"", ";", "$", "content", "->", "parent_id", "=", "\"$content->parent_id\"", ";", "if", "(", "!", "array_key_exists", "(", "$", "content", "->", "term_id", ",", "$", "vertices", ")", ")", "{", "$", "vertices", "[", "$", "content", "->", "term_id", "]", "=", "new", "Vertex", "(", "$", "content", "->", "term_id", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "content", "->", "parent_id", ",", "$", "vertices", ")", ")", "{", "$", "vertices", "[", "$", "content", "->", "parent_id", "]", "=", "new", "Vertex", "(", "$", "content", "->", "parent_id", ")", ";", "}", "}", "return", "$", "vertices", ";", "}" ]
Prepare the vertices to create the graph. @param \Illuminate\Support\Collection $data The list of vertices that were retrieved @return array<Vertex>
[ "Prepare", "the", "vertices", "to", "create", "the", "graph", "." ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Repositories/TermHierarchyRepository.php#L155-L174
train
RocketPropelledTortoise/Core
src/Taxonomy/Repositories/TermHierarchyRepository.php
TermHierarchyRepository.getAncestryGraph
public function getAncestryGraph($id) { $data = $this->getAncestry($id); if (count($data) == 0) { return [null, null]; } // Create Vertices $this->vertices = $this->prepareVertices($data); // Create Graph $graph = new DirectedGraph(); foreach ($this->vertices as $vertex) { $graph->add_vertex($vertex); } // Create Relations foreach ($data as $content) { $graph->create_edge($this->vertices[$content->parent_id], $this->vertices[$content->term_id]); } return [$this->vertices[$id], $graph]; }
php
public function getAncestryGraph($id) { $data = $this->getAncestry($id); if (count($data) == 0) { return [null, null]; } // Create Vertices $this->vertices = $this->prepareVertices($data); // Create Graph $graph = new DirectedGraph(); foreach ($this->vertices as $vertex) { $graph->add_vertex($vertex); } // Create Relations foreach ($data as $content) { $graph->create_edge($this->vertices[$content->parent_id], $this->vertices[$content->term_id]); } return [$this->vertices[$id], $graph]; }
[ "public", "function", "getAncestryGraph", "(", "$", "id", ")", "{", "$", "data", "=", "$", "this", "->", "getAncestry", "(", "$", "id", ")", ";", "if", "(", "count", "(", "$", "data", ")", "==", "0", ")", "{", "return", "[", "null", ",", "null", "]", ";", "}", "// Create Vertices", "$", "this", "->", "vertices", "=", "$", "this", "->", "prepareVertices", "(", "$", "data", ")", ";", "// Create Graph", "$", "graph", "=", "new", "DirectedGraph", "(", ")", ";", "foreach", "(", "$", "this", "->", "vertices", "as", "$", "vertex", ")", "{", "$", "graph", "->", "add_vertex", "(", "$", "vertex", ")", ";", "}", "// Create Relations", "foreach", "(", "$", "data", "as", "$", "content", ")", "{", "$", "graph", "->", "create_edge", "(", "$", "this", "->", "vertices", "[", "$", "content", "->", "parent_id", "]", ",", "$", "this", "->", "vertices", "[", "$", "content", "->", "term_id", "]", ")", ";", "}", "return", "[", "$", "this", "->", "vertices", "[", "$", "id", "]", ",", "$", "graph", "]", ";", "}" ]
Get all parents recursively @param int $id The term we want the ancestry from. @return array Vertex, DirectedGraph
[ "Get", "all", "parents", "recursively" ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Repositories/TermHierarchyRepository.php#L182-L205
train
sil-project/Contact
Model/Address.php
Address.setCity
public function setCity(City $city): void { $this->city = $city->getName(); $this->postCode = $city->getPostCode(); }
php
public function setCity(City $city): void { $this->city = $city->getName(); $this->postCode = $city->getPostCode(); }
[ "public", "function", "setCity", "(", "City", "$", "city", ")", ":", "void", "{", "$", "this", "->", "city", "=", "$", "city", "->", "getName", "(", ")", ";", "$", "this", "->", "postCode", "=", "$", "city", "->", "getPostCode", "(", ")", ";", "}" ]
Set the value of post code and city through a City instance. @param City $city
[ "Set", "the", "value", "of", "post", "code", "and", "city", "through", "a", "City", "instance", "." ]
ead863b5dc4ee7a6a2e3f0f181d1a0874b4969b9
https://github.com/sil-project/Contact/blob/ead863b5dc4ee7a6a2e3f0f181d1a0874b4969b9/Model/Address.php#L134-L138
train
mwyatt/core
src/AbstractMapper.php
AbstractMapper.getIterator
public function getIterator($models = [], $requestedClassPath = '') { $possiblePath = ''; if ($requestedClassPath) { $possiblePath = $this->iteratorFactory->getDefaultNamespaceAbs($requestedClassPath); if (!class_exists($possiblePath)) { throw new \Exception("Unable to find iterator '$possiblePath'"); } } else { try { $possiblePath = $this->iteratorFactory->getDefaultNamespaceAbs('Model\\' . $this->getRelativeClassName()); } catch (\Exception $e) { } } if (class_exists($possiblePath)) { $chosenPath = $possiblePath; } else { $chosenPath = '\\Mwyatt\\Core\\Iterator\\Model'; } rtrim($chosenPath, '\\'); return new $chosenPath($models); }
php
public function getIterator($models = [], $requestedClassPath = '') { $possiblePath = ''; if ($requestedClassPath) { $possiblePath = $this->iteratorFactory->getDefaultNamespaceAbs($requestedClassPath); if (!class_exists($possiblePath)) { throw new \Exception("Unable to find iterator '$possiblePath'"); } } else { try { $possiblePath = $this->iteratorFactory->getDefaultNamespaceAbs('Model\\' . $this->getRelativeClassName()); } catch (\Exception $e) { } } if (class_exists($possiblePath)) { $chosenPath = $possiblePath; } else { $chosenPath = '\\Mwyatt\\Core\\Iterator\\Model'; } rtrim($chosenPath, '\\'); return new $chosenPath($models); }
[ "public", "function", "getIterator", "(", "$", "models", "=", "[", "]", ",", "$", "requestedClassPath", "=", "''", ")", "{", "$", "possiblePath", "=", "''", ";", "if", "(", "$", "requestedClassPath", ")", "{", "$", "possiblePath", "=", "$", "this", "->", "iteratorFactory", "->", "getDefaultNamespaceAbs", "(", "$", "requestedClassPath", ")", ";", "if", "(", "!", "class_exists", "(", "$", "possiblePath", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Unable to find iterator '$possiblePath'\"", ")", ";", "}", "}", "else", "{", "try", "{", "$", "possiblePath", "=", "$", "this", "->", "iteratorFactory", "->", "getDefaultNamespaceAbs", "(", "'Model\\\\'", ".", "$", "this", "->", "getRelativeClassName", "(", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "}", "if", "(", "class_exists", "(", "$", "possiblePath", ")", ")", "{", "$", "chosenPath", "=", "$", "possiblePath", ";", "}", "else", "{", "$", "chosenPath", "=", "'\\\\Mwyatt\\\\Core\\\\Iterator\\\\Model'", ";", "}", "rtrim", "(", "$", "chosenPath", ",", "'\\\\'", ")", ";", "return", "new", "$", "chosenPath", "(", "$", "models", ")", ";", "}" ]
get the iterator specific to this class or a custom one if required
[ "get", "the", "iterator", "specific", "to", "this", "class", "or", "a", "custom", "one", "if", "required" ]
8ea9d67cc84fe6aff17a469c703d5492dbcd93ed
https://github.com/mwyatt/core/blob/8ea9d67cc84fe6aff17a469c703d5492dbcd93ed/src/AbstractMapper.php#L99-L120
train
mwyatt/core
src/AbstractMapper.php
AbstractMapper.getInsertGenericSql
public function getInsertGenericSql(array $cols) { $sql = ['insert into', "`{$this->getTableNameLazy()}`", '(']; $sqlCols = []; foreach ($cols as $col) { $sqlCols[] = "`$col`"; } $sql[] = implode(', ', $sqlCols); $sql[] = ') values ('; $sqlCols = []; foreach ($cols as $col) { $sqlCols[] = ":$col"; } $sql[] = implode(', ', $sqlCols); $sql[] = ')'; return implode(' ', $sql); }
php
public function getInsertGenericSql(array $cols) { $sql = ['insert into', "`{$this->getTableNameLazy()}`", '(']; $sqlCols = []; foreach ($cols as $col) { $sqlCols[] = "`$col`"; } $sql[] = implode(', ', $sqlCols); $sql[] = ') values ('; $sqlCols = []; foreach ($cols as $col) { $sqlCols[] = ":$col"; } $sql[] = implode(', ', $sqlCols); $sql[] = ')'; return implode(' ', $sql); }
[ "public", "function", "getInsertGenericSql", "(", "array", "$", "cols", ")", "{", "$", "sql", "=", "[", "'insert into'", ",", "\"`{$this->getTableNameLazy()}`\"", ",", "'('", "]", ";", "$", "sqlCols", "=", "[", "]", ";", "foreach", "(", "$", "cols", "as", "$", "col", ")", "{", "$", "sqlCols", "[", "]", "=", "\"`$col`\"", ";", "}", "$", "sql", "[", "]", "=", "implode", "(", "', '", ",", "$", "sqlCols", ")", ";", "$", "sql", "[", "]", "=", "') values ('", ";", "$", "sqlCols", "=", "[", "]", ";", "foreach", "(", "$", "cols", "as", "$", "col", ")", "{", "$", "sqlCols", "[", "]", "=", "\":$col\"", ";", "}", "$", "sql", "[", "]", "=", "implode", "(", "', '", ",", "$", "sqlCols", ")", ";", "$", "sql", "[", "]", "=", "')'", ";", "return", "implode", "(", "' '", ",", "$", "sql", ")", ";", "}" ]
builds insert statement using cols provided @param array $cols 'name', 'another' @return string built insert sql
[ "builds", "insert", "statement", "using", "cols", "provided" ]
8ea9d67cc84fe6aff17a469c703d5492dbcd93ed
https://github.com/mwyatt/core/blob/8ea9d67cc84fe6aff17a469c703d5492dbcd93ed/src/AbstractMapper.php#L167-L183
train
mwyatt/core
src/AbstractMapper.php
AbstractMapper.getUpdateGenericSql
public function getUpdateGenericSql(array $cols) { $sql = ['update', "`{$this->getTableNameLazy()}`", 'set']; $sqlCols = []; foreach ($cols as $col) { $sqlCols[] = "`$col` = :$col"; } $sql[] = implode(', ', $sqlCols); $sql[] = "where `id` = :id"; return implode(' ', $sql); }
php
public function getUpdateGenericSql(array $cols) { $sql = ['update', "`{$this->getTableNameLazy()}`", 'set']; $sqlCols = []; foreach ($cols as $col) { $sqlCols[] = "`$col` = :$col"; } $sql[] = implode(', ', $sqlCols); $sql[] = "where `id` = :id"; return implode(' ', $sql); }
[ "public", "function", "getUpdateGenericSql", "(", "array", "$", "cols", ")", "{", "$", "sql", "=", "[", "'update'", ",", "\"`{$this->getTableNameLazy()}`\"", ",", "'set'", "]", ";", "$", "sqlCols", "=", "[", "]", ";", "foreach", "(", "$", "cols", "as", "$", "col", ")", "{", "$", "sqlCols", "[", "]", "=", "\"`$col` = :$col\"", ";", "}", "$", "sql", "[", "]", "=", "implode", "(", "', '", ",", "$", "sqlCols", ")", ";", "$", "sql", "[", "]", "=", "\"where `id` = :id\"", ";", "return", "implode", "(", "' '", ",", "$", "sql", ")", ";", "}" ]
builds update statement using cols provided @param array $cols 'name', 'another' @return string built update sql
[ "builds", "update", "statement", "using", "cols", "provided" ]
8ea9d67cc84fe6aff17a469c703d5492dbcd93ed
https://github.com/mwyatt/core/blob/8ea9d67cc84fe6aff17a469c703d5492dbcd93ed/src/AbstractMapper.php#L191-L201
train
ColonelBlimp/NsanjaIndexing
src/Nsanja/Core/Indexing/IndexAbstract.php
IndexAbstract.scanDirectory
protected function scanDirectory(string $path, string $parentDir): array { $files = []; $rdi = new \RecursiveDirectoryIterator( $path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::CURRENT_AS_FILEINFO ); $rii = new \RecursiveIteratorIterator($rdi); $needle = Constants::DS.$parentDir.Constants::DS; $len = \strlen($needle); foreach ($rii as $fileInfo) { $path = $fileInfo->getPathname(); $pos = \strrpos($path, $needle); $files[] = \substr($path, $pos + $len); } return $files; }
php
protected function scanDirectory(string $path, string $parentDir): array { $files = []; $rdi = new \RecursiveDirectoryIterator( $path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::CURRENT_AS_FILEINFO ); $rii = new \RecursiveIteratorIterator($rdi); $needle = Constants::DS.$parentDir.Constants::DS; $len = \strlen($needle); foreach ($rii as $fileInfo) { $path = $fileInfo->getPathname(); $pos = \strrpos($path, $needle); $files[] = \substr($path, $pos + $len); } return $files; }
[ "protected", "function", "scanDirectory", "(", "string", "$", "path", ",", "string", "$", "parentDir", ")", ":", "array", "{", "$", "files", "=", "[", "]", ";", "$", "rdi", "=", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "path", ",", "\\", "FilesystemIterator", "::", "SKIP_DOTS", "|", "\\", "FilesystemIterator", "::", "KEY_AS_FILENAME", "|", "\\", "FilesystemIterator", "::", "CURRENT_AS_FILEINFO", ")", ";", "$", "rii", "=", "new", "\\", "RecursiveIteratorIterator", "(", "$", "rdi", ")", ";", "$", "needle", "=", "Constants", "::", "DS", ".", "$", "parentDir", ".", "Constants", "::", "DS", ";", "$", "len", "=", "\\", "strlen", "(", "$", "needle", ")", ";", "foreach", "(", "$", "rii", "as", "$", "fileInfo", ")", "{", "$", "path", "=", "$", "fileInfo", "->", "getPathname", "(", ")", ";", "$", "pos", "=", "\\", "strrpos", "(", "$", "path", ",", "$", "needle", ")", ";", "$", "files", "[", "]", "=", "\\", "substr", "(", "$", "path", ",", "$", "pos", "+", "$", "len", ")", ";", "}", "return", "$", "files", ";", "}" ]
Scans the given directory and its sub-directories returning a list of all the relative path to each file from the given marker. @param string $path @param string $rootMarker @return array
[ "Scans", "the", "given", "directory", "and", "its", "sub", "-", "directories", "returning", "a", "list", "of", "all", "the", "relative", "path", "to", "each", "file", "from", "the", "given", "marker", "." ]
aba860c702732954f41661b1da297b8b7a9c8073
https://github.com/ColonelBlimp/NsanjaIndexing/blob/aba860c702732954f41661b1da297b8b7a9c8073/src/Nsanja/Core/Indexing/IndexAbstract.php#L124-L146
train
ColonelBlimp/NsanjaIndexing
src/Nsanja/Core/Indexing/IndexAbstract.php
IndexAbstract.loadIndexFile
private function loadIndexFile(string $indexFilepath): array { $this->status = IndexInterface::STATUS_LOADED; return \unserialize(\file_get_contents($indexFilepath)); }
php
private function loadIndexFile(string $indexFilepath): array { $this->status = IndexInterface::STATUS_LOADED; return \unserialize(\file_get_contents($indexFilepath)); }
[ "private", "function", "loadIndexFile", "(", "string", "$", "indexFilepath", ")", ":", "array", "{", "$", "this", "->", "status", "=", "IndexInterface", "::", "STATUS_LOADED", ";", "return", "\\", "unserialize", "(", "\\", "file_get_contents", "(", "$", "indexFilepath", ")", ")", ";", "}" ]
Reads the file and unserializes it. @param string $indexFilepath @return array
[ "Reads", "the", "file", "and", "unserializes", "it", "." ]
aba860c702732954f41661b1da297b8b7a9c8073
https://github.com/ColonelBlimp/NsanjaIndexing/blob/aba860c702732954f41661b1da297b8b7a9c8073/src/Nsanja/Core/Indexing/IndexAbstract.php#L153-L157
train
SahilDude89ss/PyntaxFramework
src/Pyntax/Html/HtmlFactory.php
HtmlFactory.createTable
public function createTable(BeanInterface $bean, $findCondition = "") { if($this->_table_factory instanceof TableFactoryInterface) { return $this->_table_factory->generateTable($bean, $findCondition, true); } return false; }
php
public function createTable(BeanInterface $bean, $findCondition = "") { if($this->_table_factory instanceof TableFactoryInterface) { return $this->_table_factory->generateTable($bean, $findCondition, true); } return false; }
[ "public", "function", "createTable", "(", "BeanInterface", "$", "bean", ",", "$", "findCondition", "=", "\"\"", ")", "{", "if", "(", "$", "this", "->", "_table_factory", "instanceof", "TableFactoryInterface", ")", "{", "return", "$", "this", "->", "_table_factory", "->", "generateTable", "(", "$", "bean", ",", "$", "findCondition", ",", "true", ")", ";", "}", "return", "false", ";", "}" ]
This function generates the Table based on the Bean and the search condition that is passed. @param BeanInterface $bean @param string $findCondition @return bool|string
[ "This", "function", "generates", "the", "Table", "based", "on", "the", "Bean", "and", "the", "search", "condition", "that", "is", "passed", "." ]
045cca87d24eb2b6405734966c64344e00224c7b
https://github.com/SahilDude89ss/PyntaxFramework/blob/045cca87d24eb2b6405734966c64344e00224c7b/src/Pyntax/Html/HtmlFactory.php#L55-L61
train
Weissheiten/Weissheiten.Neos.NodeMigration
Classes/Weissheiten/Neos/NodeMigration/Migration/Filters/HasParentOfNodeType.php
HasParentOfNodeType.matches
public function matches(\Neos\ContentRepository\Domain\Model\NodeData $node) { $nodeIsMatchingNodeType = false; for($i=0; $i<$this->searchDepth;$i++){ $parentNode = $node->getParent(); if($parentNode!==null){ // This will break atm for NodeTypes that no longer exist - see /Packages/Application/Neos.ContentRepository/Classes/TYPO3/TYPO3CR/Migration/Filters/NodeType.php // version stated there is a "hack" though and does not allow for standard UnitTesting $nodeType = $parentNode->getNodeType(); if ($this->withSubTypes === true) { $nodeIsMatchingNodeType = $nodeType->isOfType($this->nodeTypeName); } else { if ($nodeType->getName() === $this->nodeTypeName) { $nodeIsMatchingNodeType = true; break; } } $node = $parentNode; } else{ break; } } return $nodeIsMatchingNodeType; }
php
public function matches(\Neos\ContentRepository\Domain\Model\NodeData $node) { $nodeIsMatchingNodeType = false; for($i=0; $i<$this->searchDepth;$i++){ $parentNode = $node->getParent(); if($parentNode!==null){ // This will break atm for NodeTypes that no longer exist - see /Packages/Application/Neos.ContentRepository/Classes/TYPO3/TYPO3CR/Migration/Filters/NodeType.php // version stated there is a "hack" though and does not allow for standard UnitTesting $nodeType = $parentNode->getNodeType(); if ($this->withSubTypes === true) { $nodeIsMatchingNodeType = $nodeType->isOfType($this->nodeTypeName); } else { if ($nodeType->getName() === $this->nodeTypeName) { $nodeIsMatchingNodeType = true; break; } } $node = $parentNode; } else{ break; } } return $nodeIsMatchingNodeType; }
[ "public", "function", "matches", "(", "\\", "Neos", "\\", "ContentRepository", "\\", "Domain", "\\", "Model", "\\", "NodeData", "$", "node", ")", "{", "$", "nodeIsMatchingNodeType", "=", "false", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "searchDepth", ";", "$", "i", "++", ")", "{", "$", "parentNode", "=", "$", "node", "->", "getParent", "(", ")", ";", "if", "(", "$", "parentNode", "!==", "null", ")", "{", "// This will break atm for NodeTypes that no longer exist - see /Packages/Application/Neos.ContentRepository/Classes/TYPO3/TYPO3CR/Migration/Filters/NodeType.php", "// version stated there is a \"hack\" though and does not allow for standard UnitTesting", "$", "nodeType", "=", "$", "parentNode", "->", "getNodeType", "(", ")", ";", "if", "(", "$", "this", "->", "withSubTypes", "===", "true", ")", "{", "$", "nodeIsMatchingNodeType", "=", "$", "nodeType", "->", "isOfType", "(", "$", "this", "->", "nodeTypeName", ")", ";", "}", "else", "{", "if", "(", "$", "nodeType", "->", "getName", "(", ")", "===", "$", "this", "->", "nodeTypeName", ")", "{", "$", "nodeIsMatchingNodeType", "=", "true", ";", "break", ";", "}", "}", "$", "node", "=", "$", "parentNode", ";", "}", "else", "{", "break", ";", "}", "}", "return", "$", "nodeIsMatchingNodeType", ";", "}" ]
Returns TRUE if the given node has a parent of a specific nodetype @param \Neos\ContentRepository\Domain\Model\NodeData $node @return boolean
[ "Returns", "TRUE", "if", "the", "given", "node", "has", "a", "parent", "of", "a", "specific", "nodetype" ]
6da82f1e3a8da85e9914f054756664010014cc66
https://github.com/Weissheiten/Weissheiten.Neos.NodeMigration/blob/6da82f1e3a8da85e9914f054756664010014cc66/Classes/Weissheiten/Neos/NodeMigration/Migration/Filters/HasParentOfNodeType.php#L82-L110
train
wb-crowdfusion/crowdfusion
system/core/classes/mvc/filters/AbstractFilterer.php
AbstractFilterer.handleFilter
public function handleFilter($filtererName, $method, $params, $locals, $globals) { $this->allowTemplateCode = false; $this->locals = $locals; $this->globals = $globals; $this->params = $params; //empty string given for method, use default method if(strlen($method) == 0 && $this->getDefaultMethod() != null) $methodResolved = $this->getDefaultMethod(); else if(strlen($method) > 0) $methodResolved = ActionUtils::parseMethod($method); else throw new Exception('No filter method specified and default method does not exist on class ['.get_class($this).']'); $this->currentMethod = $methodResolved; $this->currentFilter = $filtererName.(strlen($method)==0?'':'-'.$method); if(!method_exists($this, $methodResolved)) throw new Exception('Method ['.$methodResolved.'] does not exist on class ['.get_class($this).']'); $this->preFilter($params); $result = $this->$methodResolved($params); $this->postFilter($params, $result); return $result; }
php
public function handleFilter($filtererName, $method, $params, $locals, $globals) { $this->allowTemplateCode = false; $this->locals = $locals; $this->globals = $globals; $this->params = $params; //empty string given for method, use default method if(strlen($method) == 0 && $this->getDefaultMethod() != null) $methodResolved = $this->getDefaultMethod(); else if(strlen($method) > 0) $methodResolved = ActionUtils::parseMethod($method); else throw new Exception('No filter method specified and default method does not exist on class ['.get_class($this).']'); $this->currentMethod = $methodResolved; $this->currentFilter = $filtererName.(strlen($method)==0?'':'-'.$method); if(!method_exists($this, $methodResolved)) throw new Exception('Method ['.$methodResolved.'] does not exist on class ['.get_class($this).']'); $this->preFilter($params); $result = $this->$methodResolved($params); $this->postFilter($params, $result); return $result; }
[ "public", "function", "handleFilter", "(", "$", "filtererName", ",", "$", "method", ",", "$", "params", ",", "$", "locals", ",", "$", "globals", ")", "{", "$", "this", "->", "allowTemplateCode", "=", "false", ";", "$", "this", "->", "locals", "=", "$", "locals", ";", "$", "this", "->", "globals", "=", "$", "globals", ";", "$", "this", "->", "params", "=", "$", "params", ";", "//empty string given for method, use default method", "if", "(", "strlen", "(", "$", "method", ")", "==", "0", "&&", "$", "this", "->", "getDefaultMethod", "(", ")", "!=", "null", ")", "$", "methodResolved", "=", "$", "this", "->", "getDefaultMethod", "(", ")", ";", "else", "if", "(", "strlen", "(", "$", "method", ")", ">", "0", ")", "$", "methodResolved", "=", "ActionUtils", "::", "parseMethod", "(", "$", "method", ")", ";", "else", "throw", "new", "Exception", "(", "'No filter method specified and default method does not exist on class ['", ".", "get_class", "(", "$", "this", ")", ".", "']'", ")", ";", "$", "this", "->", "currentMethod", "=", "$", "methodResolved", ";", "$", "this", "->", "currentFilter", "=", "$", "filtererName", ".", "(", "strlen", "(", "$", "method", ")", "==", "0", "?", "''", ":", "'-'", ".", "$", "method", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "methodResolved", ")", ")", "throw", "new", "Exception", "(", "'Method ['", ".", "$", "methodResolved", ".", "'] does not exist on class ['", ".", "get_class", "(", "$", "this", ")", ".", "']'", ")", ";", "$", "this", "->", "preFilter", "(", "$", "params", ")", ";", "$", "result", "=", "$", "this", "->", "$", "methodResolved", "(", "$", "params", ")", ";", "$", "this", "->", "postFilter", "(", "$", "params", ",", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
This function is used to handle the call to the filterer method. It fires preHandle, the specified filterer method, then postHandle. It's this function that makes it required for all filterer classes to be a child of this class (unless they implement their own version of course.) @param string $filtererName Name of the filter namespace, typically the class name @param string $method The filterer method to run @param array $params An array of parameters for the filterer method @param array $locals An array of locals @param array $globals An array of globals @return string The result from the filterer method that will be inserted into the template.
[ "This", "function", "is", "used", "to", "handle", "the", "call", "to", "the", "filterer", "method", ".", "It", "fires", "preHandle", "the", "specified", "filterer", "method", "then", "postHandle", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/mvc/filters/AbstractFilterer.php#L206-L235
train
brightnucleus/options-store
src/OptionRepository/WordPressOptionRepository.php
WordPressOptionRepository.readOption
protected function readOption(string $key, $fallback = null) { $value = get_option($this->prefix . $key, $fallback ?? false); if (false === $value) { return $fallback; } return $value; }
php
protected function readOption(string $key, $fallback = null) { $value = get_option($this->prefix . $key, $fallback ?? false); if (false === $value) { return $fallback; } return $value; }
[ "protected", "function", "readOption", "(", "string", "$", "key", ",", "$", "fallback", "=", "null", ")", "{", "$", "value", "=", "get_option", "(", "$", "this", "->", "prefix", ".", "$", "key", ",", "$", "fallback", "??", "false", ")", ";", "if", "(", "false", "===", "$", "value", ")", "{", "return", "$", "fallback", ";", "}", "return", "$", "value", ";", "}" ]
Read a single option from the persistence mechanism. @since 0.1.0 @param string $key Key of the option to read. @param mixed $fallback Optional. Fallback value to use if the option was not found. @return mixed Value that was read.
[ "Read", "a", "single", "option", "from", "the", "persistence", "mechanism", "." ]
9a9ef2a160bbacd69fe3e9db0be8ed89e6905ef1
https://github.com/brightnucleus/options-store/blob/9a9ef2a160bbacd69fe3e9db0be8ed89e6905ef1/src/OptionRepository/WordPressOptionRepository.php#L62-L70
train
TeknooSoftware/east-foundation
src/symfony/EndPoint/EastEndPointTrait.php
EastEndPointTrait.redirect
public function redirect(ClientInterface $client, string $url, int $status = 302): EndPointInterface { $client->acceptResponse(new Response\RedirectResponse($url, $status)); return $this; }
php
public function redirect(ClientInterface $client, string $url, int $status = 302): EndPointInterface { $client->acceptResponse(new Response\RedirectResponse($url, $status)); return $this; }
[ "public", "function", "redirect", "(", "ClientInterface", "$", "client", ",", "string", "$", "url", ",", "int", "$", "status", "=", "302", ")", ":", "EndPointInterface", "{", "$", "client", "->", "acceptResponse", "(", "new", "Response", "\\", "RedirectResponse", "(", "$", "url", ",", "$", "status", ")", ")", ";", "return", "$", "this", ";", "}" ]
Returns a RedirectResponse to the given URL. @param ClientInterface $client @param string $url The URL to redirect to @param int $status The status code to use for the Response @return EndPointInterface
[ "Returns", "a", "RedirectResponse", "to", "the", "given", "URL", "." ]
45ca97c83ba08b973877a472c731f27ca1e82cdf
https://github.com/TeknooSoftware/east-foundation/blob/45ca97c83ba08b973877a472c731f27ca1e82cdf/src/symfony/EndPoint/EastEndPointTrait.php#L141-L146
train
pazuzu156/Gravatar
src/Pazuzu156/Gravatar/Avatar.php
Avatar.img
public function img($email = '', $alt = '', array $attr = []) { if (empty($email)) { $email = $this->_options['email']; } $img = '<img src="'.$this->src($email, $attr).'"'; if (!empty($alt)) { $img .= ' alt="'.$alt.'"'; } if (isset($attr['width'])) { $img .= ' width="'.$attr['width'].'"'; } if (isset($attr['height'])) { $img .= ' height="'.$attr['height'].'"'; } return $img.'>'; }
php
public function img($email = '', $alt = '', array $attr = []) { if (empty($email)) { $email = $this->_options['email']; } $img = '<img src="'.$this->src($email, $attr).'"'; if (!empty($alt)) { $img .= ' alt="'.$alt.'"'; } if (isset($attr['width'])) { $img .= ' width="'.$attr['width'].'"'; } if (isset($attr['height'])) { $img .= ' height="'.$attr['height'].'"'; } return $img.'>'; }
[ "public", "function", "img", "(", "$", "email", "=", "''", ",", "$", "alt", "=", "''", ",", "array", "$", "attr", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "email", ")", ")", "{", "$", "email", "=", "$", "this", "->", "_options", "[", "'email'", "]", ";", "}", "$", "img", "=", "'<img src=\"'", ".", "$", "this", "->", "src", "(", "$", "email", ",", "$", "attr", ")", ".", "'\"'", ";", "if", "(", "!", "empty", "(", "$", "alt", ")", ")", "{", "$", "img", ".=", "' alt=\"'", ".", "$", "alt", ".", "'\"'", ";", "}", "if", "(", "isset", "(", "$", "attr", "[", "'width'", "]", ")", ")", "{", "$", "img", ".=", "' width=\"'", ".", "$", "attr", "[", "'width'", "]", ".", "'\"'", ";", "}", "if", "(", "isset", "(", "$", "attr", "[", "'height'", "]", ")", ")", "{", "$", "img", ".=", "' height=\"'", ".", "$", "attr", "[", "'height'", "]", ".", "'\"'", ";", "}", "return", "$", "img", ".", "'>'", ";", "}" ]
Generates and returns the HTML image. @param string $email - The email to use @param string $alt - The alternative text for the image tag @param array $attr - Extra attributes to set for the image request @return string
[ "Generates", "and", "returns", "the", "HTML", "image", "." ]
7ec5c03f8ada81ec15034c671f2750456c89b6d5
https://github.com/pazuzu156/Gravatar/blob/7ec5c03f8ada81ec15034c671f2750456c89b6d5/src/Pazuzu156/Gravatar/Avatar.php#L128-L149
train
thomasez/BisonLabSakonninBundle
Controller/MessageController.php
MessageController.showAction
public function showAction(Request $request, $access, $id) { $em = $this->getDoctrineManager(); // Hack. The contextGetAction in CommonBundle is not as smart as it // looks. $message = null; if ($id instanceof Message) { $message = $id; } elseif (is_numeric($id)) { $message = $em->getRepository('BisonLabSakonninBundle:Message') ->find($id); } else { $message = $em->getRepository('BisonLabSakonninBundle:Message') ->findOneBy(array('message_id' => $id)); } if (!$message) { return $this->returnNotFound($request, 'Unable to find Message.'); } $this->denyAccessUnlessGranted('show', $message); // If it's shown to receiver, it's read. $sm = $this->container->get('sakonnin.messages'); $user = $this->getUser(); // Not sure I want to set READ automatically. But UNREAD/READ is not // archived, which the users should set themselves. if ($message->getTo() == $user->getId()) { $message->setState("READ"); $em = $this->getDoctrineManager(); $em->flush(); } if ($this->isRest($access)) { return $this->returnRestData($request, $messages, array('html' =>'BisonLabSakonninBundle:Message:_show.html.twig')); } return $this->render('BisonLabSakonninBundle:Message:show.html.twig', array('entity' => $message)); }
php
public function showAction(Request $request, $access, $id) { $em = $this->getDoctrineManager(); // Hack. The contextGetAction in CommonBundle is not as smart as it // looks. $message = null; if ($id instanceof Message) { $message = $id; } elseif (is_numeric($id)) { $message = $em->getRepository('BisonLabSakonninBundle:Message') ->find($id); } else { $message = $em->getRepository('BisonLabSakonninBundle:Message') ->findOneBy(array('message_id' => $id)); } if (!$message) { return $this->returnNotFound($request, 'Unable to find Message.'); } $this->denyAccessUnlessGranted('show', $message); // If it's shown to receiver, it's read. $sm = $this->container->get('sakonnin.messages'); $user = $this->getUser(); // Not sure I want to set READ automatically. But UNREAD/READ is not // archived, which the users should set themselves. if ($message->getTo() == $user->getId()) { $message->setState("READ"); $em = $this->getDoctrineManager(); $em->flush(); } if ($this->isRest($access)) { return $this->returnRestData($request, $messages, array('html' =>'BisonLabSakonninBundle:Message:_show.html.twig')); } return $this->render('BisonLabSakonninBundle:Message:show.html.twig', array('entity' => $message)); }
[ "public", "function", "showAction", "(", "Request", "$", "request", ",", "$", "access", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", ";", "// Hack. The contextGetAction in CommonBundle is not as smart as it", "// looks.", "$", "message", "=", "null", ";", "if", "(", "$", "id", "instanceof", "Message", ")", "{", "$", "message", "=", "$", "id", ";", "}", "elseif", "(", "is_numeric", "(", "$", "id", ")", ")", "{", "$", "message", "=", "$", "em", "->", "getRepository", "(", "'BisonLabSakonninBundle:Message'", ")", "->", "find", "(", "$", "id", ")", ";", "}", "else", "{", "$", "message", "=", "$", "em", "->", "getRepository", "(", "'BisonLabSakonninBundle:Message'", ")", "->", "findOneBy", "(", "array", "(", "'message_id'", "=>", "$", "id", ")", ")", ";", "}", "if", "(", "!", "$", "message", ")", "{", "return", "$", "this", "->", "returnNotFound", "(", "$", "request", ",", "'Unable to find Message.'", ")", ";", "}", "$", "this", "->", "denyAccessUnlessGranted", "(", "'show'", ",", "$", "message", ")", ";", "// If it's shown to receiver, it's read.", "$", "sm", "=", "$", "this", "->", "container", "->", "get", "(", "'sakonnin.messages'", ")", ";", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ";", "// Not sure I want to set READ automatically. But UNREAD/READ is not", "// archived, which the users should set themselves.", "if", "(", "$", "message", "->", "getTo", "(", ")", "==", "$", "user", "->", "getId", "(", ")", ")", "{", "$", "message", "->", "setState", "(", "\"READ\"", ")", ";", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "}", "if", "(", "$", "this", "->", "isRest", "(", "$", "access", ")", ")", "{", "return", "$", "this", "->", "returnRestData", "(", "$", "request", ",", "$", "messages", ",", "array", "(", "'html'", "=>", "'BisonLabSakonninBundle:Message:_show.html.twig'", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'BisonLabSakonninBundle:Message:show.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "message", ")", ")", ";", "}" ]
Finds and displays a Message entity. @Route("/{id}", name="message_show", methods={"GET"})
[ "Finds", "and", "displays", "a", "Message", "entity", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/MessageController.php#L135-L169
train
thomasez/BisonLabSakonninBundle
Controller/MessageController.php
MessageController.searchContextGetAction
public function searchContextGetAction(Request $request, $access, $system, $object_name, $external_id) { // Search/Index - basically same same. For now at least. /* But it has a very annoying drawback; * It more or less does not work. * The reason is simple: I have to be able to filter every entity on * granted or not. And I can do that on two ways: * * Not use contextGetAction from the CommonBundle and make my own here * and filter every single entity. * Rewrite contextGetAction to check every entity and filter. * Which means quite alot more calls and slower response. * Add a better is_granted to twig and filter there. * is_granted in twog only supports a role check, not the symfony * security voter, which is quite odd. Someone else should have felt * this need aswell. */ $this->denyAccessUnlessGranted('index', new Message()); $context_conf = $this->container->getParameter('app.contexts'); $conf = $context_conf['BisonLabSakonninBundle']['Message']; $conf['entity'] = "BisonLabSakonninBundle:Message"; // If it's REST, but HTML, we'll be returning HTML content, but not a // complete page. if ($this->isRest($access)) { $conf['show_template'] = "BisonLabSakonninBundle:Message:_show.html.twig"; $conf['list_template'] = "BisonLabSakonninBundle:Message:_index.html.twig"; } else { $conf['show_template'] = "BisonLabSakonninBundle:Message:show.html.twig"; $conf['list_template'] = "BisonLabSakonninBundle:Message:index.html.twig"; } return $this->contextGetAction( $request, $conf, $access, $system, $object_name, $external_id); }
php
public function searchContextGetAction(Request $request, $access, $system, $object_name, $external_id) { // Search/Index - basically same same. For now at least. /* But it has a very annoying drawback; * It more or less does not work. * The reason is simple: I have to be able to filter every entity on * granted or not. And I can do that on two ways: * * Not use contextGetAction from the CommonBundle and make my own here * and filter every single entity. * Rewrite contextGetAction to check every entity and filter. * Which means quite alot more calls and slower response. * Add a better is_granted to twig and filter there. * is_granted in twog only supports a role check, not the symfony * security voter, which is quite odd. Someone else should have felt * this need aswell. */ $this->denyAccessUnlessGranted('index', new Message()); $context_conf = $this->container->getParameter('app.contexts'); $conf = $context_conf['BisonLabSakonninBundle']['Message']; $conf['entity'] = "BisonLabSakonninBundle:Message"; // If it's REST, but HTML, we'll be returning HTML content, but not a // complete page. if ($this->isRest($access)) { $conf['show_template'] = "BisonLabSakonninBundle:Message:_show.html.twig"; $conf['list_template'] = "BisonLabSakonninBundle:Message:_index.html.twig"; } else { $conf['show_template'] = "BisonLabSakonninBundle:Message:show.html.twig"; $conf['list_template'] = "BisonLabSakonninBundle:Message:index.html.twig"; } return $this->contextGetAction( $request, $conf, $access, $system, $object_name, $external_id); }
[ "public", "function", "searchContextGetAction", "(", "Request", "$", "request", ",", "$", "access", ",", "$", "system", ",", "$", "object_name", ",", "$", "external_id", ")", "{", "// Search/Index - basically same same. For now at least.", "/* But it has a very annoying drawback;\n * It more or less does not work.\n * The reason is simple: I have to be able to filter every entity on\n * granted or not. And I can do that on two ways:\n *\n * Not use contextGetAction from the CommonBundle and make my own here\n * and filter every single entity.\n * Rewrite contextGetAction to check every entity and filter.\n * Which means quite alot more calls and slower response.\n * Add a better is_granted to twig and filter there.\n * is_granted in twog only supports a role check, not the symfony\n * security voter, which is quite odd. Someone else should have felt\n * this need aswell.\n */", "$", "this", "->", "denyAccessUnlessGranted", "(", "'index'", ",", "new", "Message", "(", ")", ")", ";", "$", "context_conf", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'app.contexts'", ")", ";", "$", "conf", "=", "$", "context_conf", "[", "'BisonLabSakonninBundle'", "]", "[", "'Message'", "]", ";", "$", "conf", "[", "'entity'", "]", "=", "\"BisonLabSakonninBundle:Message\"", ";", "// If it's REST, but HTML, we'll be returning HTML content, but not a", "// complete page.", "if", "(", "$", "this", "->", "isRest", "(", "$", "access", ")", ")", "{", "$", "conf", "[", "'show_template'", "]", "=", "\"BisonLabSakonninBundle:Message:_show.html.twig\"", ";", "$", "conf", "[", "'list_template'", "]", "=", "\"BisonLabSakonninBundle:Message:_index.html.twig\"", ";", "}", "else", "{", "$", "conf", "[", "'show_template'", "]", "=", "\"BisonLabSakonninBundle:Message:show.html.twig\"", ";", "$", "conf", "[", "'list_template'", "]", "=", "\"BisonLabSakonninBundle:Message:index.html.twig\"", ";", "}", "return", "$", "this", "->", "contextGetAction", "(", "$", "request", ",", "$", "conf", ",", "$", "access", ",", "$", "system", ",", "$", "object_name", ",", "$", "external_id", ")", ";", "}" ]
Lists all Messages with that context. @Route("/search_context/system/{system}/object_name/{object_name}/external_id/{external_id}", name="message_context_search", methods={"GET"})
[ "Lists", "all", "Messages", "with", "that", "context", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/MessageController.php#L241-L274
train
thomasez/BisonLabSakonninBundle
Controller/MessageController.php
MessageController.deleteAction
public function deleteAction(Request $request, $access, Message $message) { $this->denyAccessUnlessGranted('edit', $message); $form = $this->createDeleteForm($message); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrineManager(); $em->remove($message); $em->flush($message); } if ($this->isRest($access)) return new JsonResponse(array("status" => "DELETED"), Response::HTTP_OK); else return $this->redirect($request->headers->get('referer')); }
php
public function deleteAction(Request $request, $access, Message $message) { $this->denyAccessUnlessGranted('edit', $message); $form = $this->createDeleteForm($message); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrineManager(); $em->remove($message); $em->flush($message); } if ($this->isRest($access)) return new JsonResponse(array("status" => "DELETED"), Response::HTTP_OK); else return $this->redirect($request->headers->get('referer')); }
[ "public", "function", "deleteAction", "(", "Request", "$", "request", ",", "$", "access", ",", "Message", "$", "message", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'edit'", ",", "$", "message", ")", ";", "$", "form", "=", "$", "this", "->", "createDeleteForm", "(", "$", "message", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isSubmitted", "(", ")", "&&", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", ";", "$", "em", "->", "remove", "(", "$", "message", ")", ";", "$", "em", "->", "flush", "(", "$", "message", ")", ";", "}", "if", "(", "$", "this", "->", "isRest", "(", "$", "access", ")", ")", "return", "new", "JsonResponse", "(", "array", "(", "\"status\"", "=>", "\"DELETED\"", ")", ",", "Response", "::", "HTTP_OK", ")", ";", "else", "return", "$", "this", "->", "redirect", "(", "$", "request", "->", "headers", "->", "get", "(", "'referer'", ")", ")", ";", "}" ]
Deletes a message entity. @Route("/{id}", name="message_delete", methods={"DELETE"})
[ "Deletes", "a", "message", "entity", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/MessageController.php#L416-L432
train
thomasez/BisonLabSakonninBundle
Controller/MessageController.php
MessageController.checkUnreadAction
public function checkUnreadAction(Request $request, $access) { $em = $this->getDoctrineManager(); $sm = $this->container->get('sakonnin.messages'); $user = $this->getUser(); $repo = $em->getRepository('BisonLabSakonninBundle:Message'); $messages = $sm->getMessagesForLoggedIn(array('state' => 'UNREAD')); if ($messages) { return $this->returnRestData($request, array('amount' => count($messages))); } // return $this->returnRestData($request, false); return $this->returnRestData($request, array('amount' => 0)); }
php
public function checkUnreadAction(Request $request, $access) { $em = $this->getDoctrineManager(); $sm = $this->container->get('sakonnin.messages'); $user = $this->getUser(); $repo = $em->getRepository('BisonLabSakonninBundle:Message'); $messages = $sm->getMessagesForLoggedIn(array('state' => 'UNREAD')); if ($messages) { return $this->returnRestData($request, array('amount' => count($messages))); } // return $this->returnRestData($request, false); return $this->returnRestData($request, array('amount' => 0)); }
[ "public", "function", "checkUnreadAction", "(", "Request", "$", "request", ",", "$", "access", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", ";", "$", "sm", "=", "$", "this", "->", "container", "->", "get", "(", "'sakonnin.messages'", ")", ";", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ";", "$", "repo", "=", "$", "em", "->", "getRepository", "(", "'BisonLabSakonninBundle:Message'", ")", ";", "$", "messages", "=", "$", "sm", "->", "getMessagesForLoggedIn", "(", "array", "(", "'state'", "=>", "'UNREAD'", ")", ")", ";", "if", "(", "$", "messages", ")", "{", "return", "$", "this", "->", "returnRestData", "(", "$", "request", ",", "array", "(", "'amount'", "=>", "count", "(", "$", "messages", ")", ")", ")", ";", "}", "// return $this->returnRestData($request, false);", "return", "$", "this", "->", "returnRestData", "(", "$", "request", ",", "array", "(", "'amount'", "=>", "0", ")", ")", ";", "}" ]
Check for unread messages @Route("/check_unread/", name="check_unread", methods={"GET"})
[ "Check", "for", "unread", "messages" ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/MessageController.php#L439-L452
train
thomasez/BisonLabSakonninBundle
Controller/MessageController.php
MessageController.newAction
public function newAction(Request $request, $access) { $message = new Message(); if ($message_type = $request->get('message_type')) { $em = $this->getDoctrineManager(); $message->setMessageType( $em->getRepository('BisonLabSakonninBundle:MessageType') ->find($message_type) ); } $form = $this->createForm('BisonLab\SakonninBundle\Form\MessageType', $message); $form->handleRequest($request); // Should or should not use the service createmessage here? if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrineManager(); $message->setFromType('INTERNAL'); $em->persist($message); $em->flush($message); return $this->redirectToRoute('message_show', array('access' => $access, 'id' => $message->getId())); } return $this->render('BisonLabSakonninBundle:Message:new.html.twig', array('entity' => $message, 'form' => $form->createView())); }
php
public function newAction(Request $request, $access) { $message = new Message(); if ($message_type = $request->get('message_type')) { $em = $this->getDoctrineManager(); $message->setMessageType( $em->getRepository('BisonLabSakonninBundle:MessageType') ->find($message_type) ); } $form = $this->createForm('BisonLab\SakonninBundle\Form\MessageType', $message); $form->handleRequest($request); // Should or should not use the service createmessage here? if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrineManager(); $message->setFromType('INTERNAL'); $em->persist($message); $em->flush($message); return $this->redirectToRoute('message_show', array('access' => $access, 'id' => $message->getId())); } return $this->render('BisonLabSakonninBundle:Message:new.html.twig', array('entity' => $message, 'form' => $form->createView())); }
[ "public", "function", "newAction", "(", "Request", "$", "request", ",", "$", "access", ")", "{", "$", "message", "=", "new", "Message", "(", ")", ";", "if", "(", "$", "message_type", "=", "$", "request", "->", "get", "(", "'message_type'", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", ";", "$", "message", "->", "setMessageType", "(", "$", "em", "->", "getRepository", "(", "'BisonLabSakonninBundle:MessageType'", ")", "->", "find", "(", "$", "message_type", ")", ")", ";", "}", "$", "form", "=", "$", "this", "->", "createForm", "(", "'BisonLab\\SakonninBundle\\Form\\MessageType'", ",", "$", "message", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "// Should or should not use the service createmessage here?", "if", "(", "$", "form", "->", "isSubmitted", "(", ")", "&&", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrineManager", "(", ")", ";", "$", "message", "->", "setFromType", "(", "'INTERNAL'", ")", ";", "$", "em", "->", "persist", "(", "$", "message", ")", ";", "$", "em", "->", "flush", "(", "$", "message", ")", ";", "return", "$", "this", "->", "redirectToRoute", "(", "'message_show'", ",", "array", "(", "'access'", "=>", "$", "access", ",", "'id'", "=>", "$", "message", "->", "getId", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'BisonLabSakonninBundle:Message:new.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "message", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ")", ")", ";", "}" ]
Creates a new person entity. @Route("/new/", name="message_new", methods={"GET", "POST"})
[ "Creates", "a", "new", "person", "entity", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/MessageController.php#L459-L486
train
thomasez/BisonLabSakonninBundle
Controller/MessageController.php
MessageController.createDeleteForm
public function createDeleteForm(Message $message, $access = "ajax") { $form_name = "message_delete_" . $message->getId(); return $this->get('form.factory')->createNamedBuilder($form_name,FormType::class) ->setAction($this->generateUrl('message_delete', array( 'id' => $message->getId(), 'access' => $access))) ->setMethod('DELETE') ->getForm() ; }
php
public function createDeleteForm(Message $message, $access = "ajax") { $form_name = "message_delete_" . $message->getId(); return $this->get('form.factory')->createNamedBuilder($form_name,FormType::class) ->setAction($this->generateUrl('message_delete', array( 'id' => $message->getId(), 'access' => $access))) ->setMethod('DELETE') ->getForm() ; }
[ "public", "function", "createDeleteForm", "(", "Message", "$", "message", ",", "$", "access", "=", "\"ajax\"", ")", "{", "$", "form_name", "=", "\"message_delete_\"", ".", "$", "message", "->", "getId", "(", ")", ";", "return", "$", "this", "->", "get", "(", "'form.factory'", ")", "->", "createNamedBuilder", "(", "$", "form_name", ",", "FormType", "::", "class", ")", "->", "setAction", "(", "$", "this", "->", "generateUrl", "(", "'message_delete'", ",", "array", "(", "'id'", "=>", "$", "message", "->", "getId", "(", ")", ",", "'access'", "=>", "$", "access", ")", ")", ")", "->", "setMethod", "(", "'DELETE'", ")", "->", "getForm", "(", ")", ";", "}" ]
Creates a form to delete a message entity. @param Message $message The message entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "delete", "a", "message", "entity", "." ]
45ca7ce9874c4a2be7b503d7067b3d11d2b518cb
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Controller/MessageController.php#L529-L539
train
joegreen88/zf1-component-validate
src/Zend/Validate/Barcode/Royalmail.php
Zend_Validate_Barcode_Royalmail.checkChars
public function checkChars($value) { if ($value[0] == '(') { $value = substr($value, 1); if ($value[strlen($value) - 1] == ')') { $value = substr($value, 0, -1); } else { return false; } } return parent::checkChars($value); }
php
public function checkChars($value) { if ($value[0] == '(') { $value = substr($value, 1); if ($value[strlen($value) - 1] == ')') { $value = substr($value, 0, -1); } else { return false; } } return parent::checkChars($value); }
[ "public", "function", "checkChars", "(", "$", "value", ")", "{", "if", "(", "$", "value", "[", "0", "]", "==", "'('", ")", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "1", ")", ";", "if", "(", "$", "value", "[", "strlen", "(", "$", "value", ")", "-", "1", "]", "==", "')'", ")", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "0", ",", "-", "1", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}", "return", "parent", "::", "checkChars", "(", "$", "value", ")", ";", "}" ]
Allows start and stop tag within checked chars @param string $value The barcode to check for allowed characters @return boolean
[ "Allows", "start", "and", "stop", "tag", "within", "checked", "chars" ]
88d9ea016f73d48ff0ba7d06ecbbf28951fd279e
https://github.com/joegreen88/zf1-component-validate/blob/88d9ea016f73d48ff0ba7d06ecbbf28951fd279e/src/Zend/Validate/Barcode/Royalmail.php#L107-L120
train
phossa/phossa-di
src/Phossa/Di/Extension/ExtensibleTrait.php
ExtensibleTrait.getExtension
public function getExtension( /*# string */ $extensionName )/*# : ExtensionAbstract */ { if (!$this->hasExtension($extensionName)) { $this->addExtension(new $extensionName); } return $this->extensions[$extensionName]; }
php
public function getExtension( /*# string */ $extensionName )/*# : ExtensionAbstract */ { if (!$this->hasExtension($extensionName)) { $this->addExtension(new $extensionName); } return $this->extensions[$extensionName]; }
[ "public", "function", "getExtension", "(", "/*# string */", "$", "extensionName", ")", "/*# : ExtensionAbstract */", "{", "if", "(", "!", "$", "this", "->", "hasExtension", "(", "$", "extensionName", ")", ")", "{", "$", "this", "->", "addExtension", "(", "new", "$", "extensionName", ")", ";", "}", "return", "$", "this", "->", "extensions", "[", "$", "extensionName", "]", ";", "}" ]
Get the named extension, create one if not injected yet @param string $extensionName @return ExtensionAbstract @access public @internal
[ "Get", "the", "named", "extension", "create", "one", "if", "not", "injected", "yet" ]
bbe1e95b081068e2bc49c6cd465f38aab0374be5
https://github.com/phossa/phossa-di/blob/bbe1e95b081068e2bc49c6cd465f38aab0374be5/src/Phossa/Di/Extension/ExtensibleTrait.php#L131-L138
train
phossa/phossa-di
src/Phossa/Di/Extension/ExtensibleTrait.php
ExtensibleTrait.decorateService
protected function decorateService($service) { $extName = DecorateExtension::EXTENSION_CLASS; // decorate extension loaded if ($this->hasExtension($extName)) { /* @var $ext DecorateExtension */ $ext = $this->getExtension($extName); $ext->decorateService($service); } return $this; }
php
protected function decorateService($service) { $extName = DecorateExtension::EXTENSION_CLASS; // decorate extension loaded if ($this->hasExtension($extName)) { /* @var $ext DecorateExtension */ $ext = $this->getExtension($extName); $ext->decorateService($service); } return $this; }
[ "protected", "function", "decorateService", "(", "$", "service", ")", "{", "$", "extName", "=", "DecorateExtension", "::", "EXTENSION_CLASS", ";", "// decorate extension loaded", "if", "(", "$", "this", "->", "hasExtension", "(", "$", "extName", ")", ")", "{", "/* @var $ext DecorateExtension */", "$", "ext", "=", "$", "this", "->", "getExtension", "(", "$", "extName", ")", ";", "$", "ext", "->", "decorateService", "(", "$", "service", ")", ";", "}", "return", "$", "this", ";", "}" ]
Decorate the service object if DecorateExtension loaded @param object $service @return self @throws LogicException if something goes wrong @access protected
[ "Decorate", "the", "service", "object", "if", "DecorateExtension", "loaded" ]
bbe1e95b081068e2bc49c6cd465f38aab0374be5
https://github.com/phossa/phossa-di/blob/bbe1e95b081068e2bc49c6cd465f38aab0374be5/src/Phossa/Di/Extension/ExtensibleTrait.php#L182-L194
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/ClassUtility.php
ClassUtility.splitClassName
public static function splitClassName ( $className ) { $chunk = explode('\\', $className); $className = array_pop($chunk); $namespace = implode('\\', $chunk); $result = array($namespace, $className); return $result; }
php
public static function splitClassName ( $className ) { $chunk = explode('\\', $className); $className = array_pop($chunk); $namespace = implode('\\', $chunk); $result = array($namespace, $className); return $result; }
[ "public", "static", "function", "splitClassName", "(", "$", "className", ")", "{", "$", "chunk", "=", "explode", "(", "'\\\\'", ",", "$", "className", ")", ";", "$", "className", "=", "array_pop", "(", "$", "chunk", ")", ";", "$", "namespace", "=", "implode", "(", "'\\\\'", ",", "$", "chunk", ")", ";", "$", "result", "=", "array", "(", "$", "namespace", ",", "$", "className", ")", ";", "return", "$", "result", ";", "}" ]
Split class name @param string $className Class name with namespace @return string Namespace
[ "Split", "class", "name" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/ClassUtility.php#L25-L32
train
shgysk8zer0/core_api
traits/pdo.php
PDO.showTables
final public function showTables() { $q = $this->query('SHOW TABLES'); $q->execute(); return $q->fetchAll(self::FETCH_COLUMN); }
php
final public function showTables() { $q = $this->query('SHOW TABLES'); $q->execute(); return $q->fetchAll(self::FETCH_COLUMN); }
[ "final", "public", "function", "showTables", "(", ")", "{", "$", "q", "=", "$", "this", "->", "query", "(", "'SHOW TABLES'", ")", ";", "$", "q", "->", "execute", "(", ")", ";", "return", "$", "q", "->", "fetchAll", "(", "self", "::", "FETCH_COLUMN", ")", ";", "}" ]
Returns an array of available database tables @param void @return array
[ "Returns", "an", "array", "of", "available", "database", "tables" ]
9e9b8baf761af874b95256ad2462e55fbb2b2e58
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/pdo.php#L55-L60
train
shgysk8zer0/core_api
traits/pdo.php
PDO.describe
final public function describe($table) { $q = $this->query("DESCRIBE `{$table}`"); $q->execute(); return $q->fetchAll(self::FETCH_COLUMN); }
php
final public function describe($table) { $q = $this->query("DESCRIBE `{$table}`"); $q->execute(); return $q->fetchAll(self::FETCH_COLUMN); }
[ "final", "public", "function", "describe", "(", "$", "table", ")", "{", "$", "q", "=", "$", "this", "->", "query", "(", "\"DESCRIBE `{$table}`\"", ")", ";", "$", "q", "->", "execute", "(", ")", ";", "return", "$", "q", "->", "fetchAll", "(", "self", "::", "FETCH_COLUMN", ")", ";", "}" ]
Describe a table @param string $table Name of table to describe @return array [key => \stdClass]
[ "Describe", "a", "table" ]
9e9b8baf761af874b95256ad2462e55fbb2b2e58
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/pdo.php#L68-L73
train
hiqdev/hiam-mrdp
src/controllers/MrdpController.php
MrdpController.actionLogin
public function actionLogin(array $confirm_data, $goto) { $url = 'http://hiapi.ahnames.com/verifyConfirmation?' . http_build_query([ 'auth_ip' => Yii::$app->request->getUserIp(), 'what' => 'redirect_hipanel', 'confirm_data' => $confirm_data, ]); $res = Json::decode(file_get_contents($url)); if (!empty($res['login']) && empty($res['_error'])) { $user = $this->user->findIdentity($res['login']); } else { throw new ForbiddenHttpException('Bad confirmation', 0, new BadConfirmException($res)); } if (!$user) { Yii::$app->session->setFlash('error', Yii::t('hiam', 'Failed login.')); return $this->goHome(); } $this->user->login($user); return $this->redirect($goto); }
php
public function actionLogin(array $confirm_data, $goto) { $url = 'http://hiapi.ahnames.com/verifyConfirmation?' . http_build_query([ 'auth_ip' => Yii::$app->request->getUserIp(), 'what' => 'redirect_hipanel', 'confirm_data' => $confirm_data, ]); $res = Json::decode(file_get_contents($url)); if (!empty($res['login']) && empty($res['_error'])) { $user = $this->user->findIdentity($res['login']); } else { throw new ForbiddenHttpException('Bad confirmation', 0, new BadConfirmException($res)); } if (!$user) { Yii::$app->session->setFlash('error', Yii::t('hiam', 'Failed login.')); return $this->goHome(); } $this->user->login($user); return $this->redirect($goto); }
[ "public", "function", "actionLogin", "(", "array", "$", "confirm_data", ",", "$", "goto", ")", "{", "$", "url", "=", "'http://hiapi.ahnames.com/verifyConfirmation?'", ".", "http_build_query", "(", "[", "'auth_ip'", "=>", "Yii", "::", "$", "app", "->", "request", "->", "getUserIp", "(", ")", ",", "'what'", "=>", "'redirect_hipanel'", ",", "'confirm_data'", "=>", "$", "confirm_data", ",", "]", ")", ";", "$", "res", "=", "Json", "::", "decode", "(", "file_get_contents", "(", "$", "url", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "res", "[", "'login'", "]", ")", "&&", "empty", "(", "$", "res", "[", "'_error'", "]", ")", ")", "{", "$", "user", "=", "$", "this", "->", "user", "->", "findIdentity", "(", "$", "res", "[", "'login'", "]", ")", ";", "}", "else", "{", "throw", "new", "ForbiddenHttpException", "(", "'Bad confirmation'", ",", "0", ",", "new", "BadConfirmException", "(", "$", "res", ")", ")", ";", "}", "if", "(", "!", "$", "user", ")", "{", "Yii", "::", "$", "app", "->", "session", "->", "setFlash", "(", "'error'", ",", "Yii", "::", "t", "(", "'hiam'", ",", "'Failed login.'", ")", ")", ";", "return", "$", "this", "->", "goHome", "(", ")", ";", "}", "$", "this", "->", "user", "->", "login", "(", "$", "user", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "goto", ")", ";", "}" ]
Implements login from MRDP panel. @param $confirm_data confirmation data @param $goto url to go to on success @throws ForbiddenHttpException when login confirmation is broken
[ "Implements", "login", "from", "MRDP", "panel", "." ]
22227d86c80bd1d96370f88251e43d213ad73a3b
https://github.com/hiqdev/hiam-mrdp/blob/22227d86c80bd1d96370f88251e43d213ad73a3b/src/controllers/MrdpController.php#L29-L50
train
AdamB7586/menu-builder
src/Builder/Breadcrumb.php
Breadcrumb.setBreadcrumbElement
public function setBreadcrumbElement($element) { if(!empty(trim($element)) && is_string($element)) { $this->breadcrumbElement = trim($element); } return $this; }
php
public function setBreadcrumbElement($element) { if(!empty(trim($element)) && is_string($element)) { $this->breadcrumbElement = trim($element); } return $this; }
[ "public", "function", "setBreadcrumbElement", "(", "$", "element", ")", "{", "if", "(", "!", "empty", "(", "trim", "(", "$", "element", ")", ")", "&&", "is_string", "(", "$", "element", ")", ")", "{", "$", "this", "->", "breadcrumbElement", "=", "trim", "(", "$", "element", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the main element to give to list style breadcrumb menus @param string $element The main element you want to give to the breadcrumb @return $this
[ "Sets", "the", "main", "element", "to", "give", "to", "list", "style", "breadcrumb", "menus" ]
dbc192bca7d59475068c19d1a07a039e5f997ee4
https://github.com/AdamB7586/menu-builder/blob/dbc192bca7d59475068c19d1a07a039e5f997ee4/src/Builder/Breadcrumb.php#L63-L68
train
AdamB7586/menu-builder
src/Builder/Breadcrumb.php
Breadcrumb.setBreacrumbLinks
public function setBreacrumbLinks($links) { if(is_array($links) && !empty($links)) { $this->links = $links; } return $this; }
php
public function setBreacrumbLinks($links) { if(is_array($links) && !empty($links)) { $this->links = $links; } return $this; }
[ "public", "function", "setBreacrumbLinks", "(", "$", "links", ")", "{", "if", "(", "is_array", "(", "$", "links", ")", "&&", "!", "empty", "(", "$", "links", ")", ")", "{", "$", "this", "->", "links", "=", "$", "links", ";", "}", "return", "$", "this", ";", "}" ]
Sets the link to include in the breadcrumb element @param array $links This should be the breadcrumb links @return $this
[ "Sets", "the", "link", "to", "include", "in", "the", "breadcrumb", "element" ]
dbc192bca7d59475068c19d1a07a039e5f997ee4
https://github.com/AdamB7586/menu-builder/blob/dbc192bca7d59475068c19d1a07a039e5f997ee4/src/Builder/Breadcrumb.php#L86-L91
train
tonis-io-legacy/doctrine-orm
src/EntityManagerFactory.php
EntityManagerFactory.createConfiguration
private static function createConfiguration(array $config, ContainerInterface $container = null) { $cache = $config['cache']; if ($container && is_string($config['cache']) && $container->has($config['cache'])) { $cache = $container->get($config['cache']); } return Setup::createConfiguration($config['debug'], $config['proxy_dir'], $cache); }
php
private static function createConfiguration(array $config, ContainerInterface $container = null) { $cache = $config['cache']; if ($container && is_string($config['cache']) && $container->has($config['cache'])) { $cache = $container->get($config['cache']); } return Setup::createConfiguration($config['debug'], $config['proxy_dir'], $cache); }
[ "private", "static", "function", "createConfiguration", "(", "array", "$", "config", ",", "ContainerInterface", "$", "container", "=", "null", ")", "{", "$", "cache", "=", "$", "config", "[", "'cache'", "]", ";", "if", "(", "$", "container", "&&", "is_string", "(", "$", "config", "[", "'cache'", "]", ")", "&&", "$", "container", "->", "has", "(", "$", "config", "[", "'cache'", "]", ")", ")", "{", "$", "cache", "=", "$", "container", "->", "get", "(", "$", "config", "[", "'cache'", "]", ")", ";", "}", "return", "Setup", "::", "createConfiguration", "(", "$", "config", "[", "'debug'", "]", ",", "$", "config", "[", "'proxy_dir'", "]", ",", "$", "cache", ")", ";", "}" ]
Creates the ORM configuration. @param array $config @param ContainerInterface $container @return Configuration
[ "Creates", "the", "ORM", "configuration", "." ]
fed8de8a6304b8fdad88a425a16d6c2e6a9e27ed
https://github.com/tonis-io-legacy/doctrine-orm/blob/fed8de8a6304b8fdad88a425a16d6c2e6a9e27ed/src/EntityManagerFactory.php#L56-L65
train
pdyn/base
Exception.php
Exception.get_string_from_code
public function get_string_from_code($code) { $errors = [ self::ERR_GENERAL => 'General Error', self::ERR_BAD_REQUEST => 'Bad Request', self::ERR_UNAUTHORIZED => 'Unauthorized', self::ERR_FORBIDDEN => 'Forbidden', self::ERR_INTERNAL_ERROR => 'Internal Error', self::ERR_PRECONDITION_FAILED => 'Precondition Failed', self::ERR_RESOURCE_NOT_FOUND => 'Resource Not Found', self::ERR_INVALID_RESOURCE => 'Invalid Resource', self::ERR_NOT_IMPLEMENTED => 'Feature not implemented', self::ERR_DISABLED => 'Feature Disabled', self::ERR_NETWORKING_DISABLED => 'Networking is Disabled', ]; return (isset($errors[$code])) ? $errors[$code] : ''; }
php
public function get_string_from_code($code) { $errors = [ self::ERR_GENERAL => 'General Error', self::ERR_BAD_REQUEST => 'Bad Request', self::ERR_UNAUTHORIZED => 'Unauthorized', self::ERR_FORBIDDEN => 'Forbidden', self::ERR_INTERNAL_ERROR => 'Internal Error', self::ERR_PRECONDITION_FAILED => 'Precondition Failed', self::ERR_RESOURCE_NOT_FOUND => 'Resource Not Found', self::ERR_INVALID_RESOURCE => 'Invalid Resource', self::ERR_NOT_IMPLEMENTED => 'Feature not implemented', self::ERR_DISABLED => 'Feature Disabled', self::ERR_NETWORKING_DISABLED => 'Networking is Disabled', ]; return (isset($errors[$code])) ? $errors[$code] : ''; }
[ "public", "function", "get_string_from_code", "(", "$", "code", ")", "{", "$", "errors", "=", "[", "self", "::", "ERR_GENERAL", "=>", "'General Error'", ",", "self", "::", "ERR_BAD_REQUEST", "=>", "'Bad Request'", ",", "self", "::", "ERR_UNAUTHORIZED", "=>", "'Unauthorized'", ",", "self", "::", "ERR_FORBIDDEN", "=>", "'Forbidden'", ",", "self", "::", "ERR_INTERNAL_ERROR", "=>", "'Internal Error'", ",", "self", "::", "ERR_PRECONDITION_FAILED", "=>", "'Precondition Failed'", ",", "self", "::", "ERR_RESOURCE_NOT_FOUND", "=>", "'Resource Not Found'", ",", "self", "::", "ERR_INVALID_RESOURCE", "=>", "'Invalid Resource'", ",", "self", "::", "ERR_NOT_IMPLEMENTED", "=>", "'Feature not implemented'", ",", "self", "::", "ERR_DISABLED", "=>", "'Feature Disabled'", ",", "self", "::", "ERR_NETWORKING_DISABLED", "=>", "'Networking is Disabled'", ",", "]", ";", "return", "(", "isset", "(", "$", "errors", "[", "$", "code", "]", ")", ")", "?", "$", "errors", "[", "$", "code", "]", ":", "''", ";", "}" ]
Translate an error code into a human-readable string explaining the problem. @param int $code The error code. @return string The human-readable description.
[ "Translate", "an", "error", "code", "into", "a", "human", "-", "readable", "string", "explaining", "the", "problem", "." ]
0b93961693954a6b4e1c6df7e345e5cdf07f26ff
https://github.com/pdyn/base/blob/0b93961693954a6b4e1c6df7e345e5cdf07f26ff/Exception.php#L68-L84
train
eureka-framework/component-http
src/Http/Message/UploadedFile.php
UploadedFile.setClientFilename
private function setClientFilename($clientFilename) { if (preg_match('`[/\\]+`', $clientFilename) > 0) { throw new \InvalidArgumentException('Filename contain invalid character "\" or "/" in his name.'); } $this->clientFilename = (empty($clientFilename) ? null : (string) $clientFilename); return $this; }
php
private function setClientFilename($clientFilename) { if (preg_match('`[/\\]+`', $clientFilename) > 0) { throw new \InvalidArgumentException('Filename contain invalid character "\" or "/" in his name.'); } $this->clientFilename = (empty($clientFilename) ? null : (string) $clientFilename); return $this; }
[ "private", "function", "setClientFilename", "(", "$", "clientFilename", ")", "{", "if", "(", "preg_match", "(", "'`[/\\\\]+`'", ",", "$", "clientFilename", ")", ">", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Filename contain invalid character \"\\\" or \"/\" in his name.'", ")", ";", "}", "$", "this", "->", "clientFilename", "=", "(", "empty", "(", "$", "clientFilename", ")", "?", "null", ":", "(", "string", ")", "$", "clientFilename", ")", ";", "return", "$", "this", ";", "}" ]
Set client filename. @param string $clientFilename @return self @throws \InvalidArgumentException
[ "Set", "client", "filename", "." ]
698c3b73581a9703a9c932890c57e50f8774607a
https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Message/UploadedFile.php#L201-L210
train
eureka-framework/component-http
src/Http/Message/UploadedFile.php
UploadedFile.setSize
private function setSize($size = null) { if ($size !== null) { $size = (int) $size; if ($size < 0) { throw new \RuntimeException('File size cannot be a negative value ! (size: ' . $size . ')'); } } $this->size = $size; return $this; }
php
private function setSize($size = null) { if ($size !== null) { $size = (int) $size; if ($size < 0) { throw new \RuntimeException('File size cannot be a negative value ! (size: ' . $size . ')'); } } $this->size = $size; return $this; }
[ "private", "function", "setSize", "(", "$", "size", "=", "null", ")", "{", "if", "(", "$", "size", "!==", "null", ")", "{", "$", "size", "=", "(", "int", ")", "$", "size", ";", "if", "(", "$", "size", "<", "0", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'File size cannot be a negative value ! (size: '", ".", "$", "size", ".", "')'", ")", ";", "}", "}", "$", "this", "->", "size", "=", "$", "size", ";", "return", "$", "this", ";", "}" ]
Set file size @param int $size @return self
[ "Set", "file", "size" ]
698c3b73581a9703a9c932890c57e50f8774607a
https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Message/UploadedFile.php#L244-L257
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/model/ModelObject.php
ModelObject.getDefault
public function getDefault($key) { $schema = $this->getModelSchema(); if (array_key_exists('default', $schema[$key])) return $schema[$key]['default']; return null; }
php
public function getDefault($key) { $schema = $this->getModelSchema(); if (array_key_exists('default', $schema[$key])) return $schema[$key]['default']; return null; }
[ "public", "function", "getDefault", "(", "$", "key", ")", "{", "$", "schema", "=", "$", "this", "->", "getModelSchema", "(", ")", ";", "if", "(", "array_key_exists", "(", "'default'", ",", "$", "schema", "[", "$", "key", "]", ")", ")", "return", "$", "schema", "[", "$", "key", "]", "[", "'default'", "]", ";", "return", "null", ";", "}" ]
Returns the default value of the field. @param string $key The name of the field @return mixed or null if there is no default value
[ "Returns", "the", "default", "value", "of", "the", "field", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/model/ModelObject.php#L146-L154
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/model/ModelObject.php
ModelObject.getFieldTitle
public function getFieldTitle($key) { $schema = $this->getModelSchema(); if (array_key_exists('title', $schema[$key])) return $schema[$key]['title']; return $key; }
php
public function getFieldTitle($key) { $schema = $this->getModelSchema(); if (array_key_exists('title', $schema[$key])) return $schema[$key]['title']; return $key; }
[ "public", "function", "getFieldTitle", "(", "$", "key", ")", "{", "$", "schema", "=", "$", "this", "->", "getModelSchema", "(", ")", ";", "if", "(", "array_key_exists", "(", "'title'", ",", "$", "schema", "[", "$", "key", "]", ")", ")", "return", "$", "schema", "[", "$", "key", "]", "[", "'title'", "]", ";", "return", "$", "key", ";", "}" ]
Returns the field title. @param string $key The name of the field @return string or the field name if there is no title
[ "Returns", "the", "field", "title", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/model/ModelObject.php#L163-L171
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/model/ModelObject.php
ModelObject.getValidation
public function getValidation($field = null) { $validation = array(); $schema = $this->getModelSchema(); if ($field != null) $schema = array($field => $schema[$field]); foreach ( $schema as $key => $value ) { if (!isset($value['validation'])) throw new Exception('Validation missing for key: '.$field); $validation[$key] = $value['validation']; } if ($field != null) return $validation[$field]; return $validation; }
php
public function getValidation($field = null) { $validation = array(); $schema = $this->getModelSchema(); if ($field != null) $schema = array($field => $schema[$field]); foreach ( $schema as $key => $value ) { if (!isset($value['validation'])) throw new Exception('Validation missing for key: '.$field); $validation[$key] = $value['validation']; } if ($field != null) return $validation[$field]; return $validation; }
[ "public", "function", "getValidation", "(", "$", "field", "=", "null", ")", "{", "$", "validation", "=", "array", "(", ")", ";", "$", "schema", "=", "$", "this", "->", "getModelSchema", "(", ")", ";", "if", "(", "$", "field", "!=", "null", ")", "$", "schema", "=", "array", "(", "$", "field", "=>", "$", "schema", "[", "$", "field", "]", ")", ";", "foreach", "(", "$", "schema", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "value", "[", "'validation'", "]", ")", ")", "throw", "new", "Exception", "(", "'Validation missing for key: '", ".", "$", "field", ")", ";", "$", "validation", "[", "$", "key", "]", "=", "$", "value", "[", "'validation'", "]", ";", "}", "if", "(", "$", "field", "!=", "null", ")", "return", "$", "validation", "[", "$", "field", "]", ";", "return", "$", "validation", ";", "}" ]
Returns the model schema, which we'll use for validation @param string $field The field name @return array
[ "Returns", "the", "model", "schema", "which", "we", "ll", "use", "for", "validation" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/model/ModelObject.php#L180-L199
train
goncalomb/asbestos
src/classes/Html/Element.php
Element.append
public function append() { $args = func_get_args(); foreach ($args as $arg) { if ($arg instanceof Element) { if ($arg->_used) { continue; } $arg->_used = true; } $this->_html[] = $arg; } }
php
public function append() { $args = func_get_args(); foreach ($args as $arg) { if ($arg instanceof Element) { if ($arg->_used) { continue; } $arg->_used = true; } $this->_html[] = $arg; } }
[ "public", "function", "append", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "if", "(", "$", "arg", "instanceof", "Element", ")", "{", "if", "(", "$", "arg", "->", "_used", ")", "{", "continue", ";", "}", "$", "arg", "->", "_used", "=", "true", ";", "}", "$", "this", "->", "_html", "[", "]", "=", "$", "arg", ";", "}", "}" ]
Append content or other elements. @param mixed Things to be appended.
[ "Append", "content", "or", "other", "elements", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Html/Element.php#L79-L91
train
goncalomb/asbestos
src/classes/Html/Element.php
Element.outputOpeningTag
protected function outputOpeningTag() { echo '<', htmlspecialchars($this->_tag); foreach ($this->_attributes as $name => $value) { echo ' ', htmlspecialchars($name), '="', htmlspecialchars($value), '"'; } echo '>'; if ($this->_tag == 'html' || $this->_tag == 'head' || $this->_tag == 'body') { echo "\n"; } }
php
protected function outputOpeningTag() { echo '<', htmlspecialchars($this->_tag); foreach ($this->_attributes as $name => $value) { echo ' ', htmlspecialchars($name), '="', htmlspecialchars($value), '"'; } echo '>'; if ($this->_tag == 'html' || $this->_tag == 'head' || $this->_tag == 'body') { echo "\n"; } }
[ "protected", "function", "outputOpeningTag", "(", ")", "{", "echo", "'<'", ",", "htmlspecialchars", "(", "$", "this", "->", "_tag", ")", ";", "foreach", "(", "$", "this", "->", "_attributes", "as", "$", "name", "=>", "$", "value", ")", "{", "echo", "' '", ",", "htmlspecialchars", "(", "$", "name", ")", ",", "'=\"'", ",", "htmlspecialchars", "(", "$", "value", ")", ",", "'\"'", ";", "}", "echo", "'>'", ";", "if", "(", "$", "this", "->", "_tag", "==", "'html'", "||", "$", "this", "->", "_tag", "==", "'head'", "||", "$", "this", "->", "_tag", "==", "'body'", ")", "{", "echo", "\"\\n\"", ";", "}", "}" ]
Output opening HTML.
[ "Output", "opening", "HTML", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Html/Element.php#L104-L114
train
goncalomb/asbestos
src/classes/Html/Element.php
Element.outputContent
protected function outputContent() { foreach ($this->_html as $part) { if ($part instanceof Element) { $part->output(); } else { echo $part; } } }
php
protected function outputContent() { foreach ($this->_html as $part) { if ($part instanceof Element) { $part->output(); } else { echo $part; } } }
[ "protected", "function", "outputContent", "(", ")", "{", "foreach", "(", "$", "this", "->", "_html", "as", "$", "part", ")", "{", "if", "(", "$", "part", "instanceof", "Element", ")", "{", "$", "part", "->", "output", "(", ")", ";", "}", "else", "{", "echo", "$", "part", ";", "}", "}", "}" ]
Output inner HTML.
[ "Output", "inner", "HTML", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Html/Element.php#L119-L128
train
goncalomb/asbestos
src/classes/Html/Element.php
Element.outputClosingTag
protected function outputClosingTag() { echo '</', htmlspecialchars($this->_tag), '>'; if ($this->_tag == 'html' || $this->_tag == 'head' || $this->_tag == 'body') { echo "\n"; } }
php
protected function outputClosingTag() { echo '</', htmlspecialchars($this->_tag), '>'; if ($this->_tag == 'html' || $this->_tag == 'head' || $this->_tag == 'body') { echo "\n"; } }
[ "protected", "function", "outputClosingTag", "(", ")", "{", "echo", "'</'", ",", "htmlspecialchars", "(", "$", "this", "->", "_tag", ")", ",", "'>'", ";", "if", "(", "$", "this", "->", "_tag", "==", "'html'", "||", "$", "this", "->", "_tag", "==", "'head'", "||", "$", "this", "->", "_tag", "==", "'body'", ")", "{", "echo", "\"\\n\"", ";", "}", "}" ]
Output closing HTML.
[ "Output", "closing", "HTML", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Html/Element.php#L133-L139
train
shrink0r/php-schema
src/Property/ChoiceProperty.php
ChoiceProperty.validate
public function validate($value) { return in_array($value, $this->choices) ? Ok::unit() : Error::unit([ Error::INVALID_CHOICE ]); }
php
public function validate($value) { return in_array($value, $this->choices) ? Ok::unit() : Error::unit([ Error::INVALID_CHOICE ]); }
[ "public", "function", "validate", "(", "$", "value", ")", "{", "return", "in_array", "(", "$", "value", ",", "$", "this", "->", "choices", ")", "?", "Ok", "::", "unit", "(", ")", ":", "Error", "::", "unit", "(", "[", "Error", "::", "INVALID_CHOICE", "]", ")", ";", "}" ]
Tells if a given value is a valid choice according to the property's definition. @param mixed $value @return ResultInterface Returns Ok if the value is valid, otherwise an Error is returned.
[ "Tells", "if", "a", "given", "value", "is", "a", "valid", "choice", "according", "to", "the", "property", "s", "definition", "." ]
94293fe897af376dd9d05962e2c516079409dd29
https://github.com/shrink0r/php-schema/blob/94293fe897af376dd9d05962e2c516079409dd29/src/Property/ChoiceProperty.php#L39-L42
train
TodoMove/intercessor
src/TodoMove/Intercessor/Task.php
Task.tags
public function tags(Tags $tags = null) { if (is_null($tags)) { return $this->tags; } $this->tags = $tags; return $this; }
php
public function tags(Tags $tags = null) { if (is_null($tags)) { return $this->tags; } $this->tags = $tags; return $this; }
[ "public", "function", "tags", "(", "Tags", "$", "tags", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "tags", ")", ")", "{", "return", "$", "this", "->", "tags", ";", "}", "$", "this", "->", "tags", "=", "$", "tags", ";", "return", "$", "this", ";", "}" ]
This needs a tag collection. @param Tags|null $tags - pass to set, don't pass to get @return $this|Tags
[ "This", "needs", "a", "tag", "collection", "." ]
546f9cdaaeaa2db52f8ed33f4870db5526105e50
https://github.com/TodoMove/intercessor/blob/546f9cdaaeaa2db52f8ed33f4870db5526105e50/src/TodoMove/Intercessor/Task.php#L163-L172
train
ekyna/Resource
Persistence/PersistenceEventQueue.php
PersistenceEventQueue.getEventPriority
protected function getEventPriority($eventName) { $suffix = $this->getEventSuffix($eventName); if ($suffix === static::UPDATE) { return 9999; } elseif ($suffix === static::INSERT) { return 9998; } elseif ($suffix === static::DELETE) { return 9997; } return parent::getEventPriority($eventName); }
php
protected function getEventPriority($eventName) { $suffix = $this->getEventSuffix($eventName); if ($suffix === static::UPDATE) { return 9999; } elseif ($suffix === static::INSERT) { return 9998; } elseif ($suffix === static::DELETE) { return 9997; } return parent::getEventPriority($eventName); }
[ "protected", "function", "getEventPriority", "(", "$", "eventName", ")", "{", "$", "suffix", "=", "$", "this", "->", "getEventSuffix", "(", "$", "eventName", ")", ";", "if", "(", "$", "suffix", "===", "static", "::", "UPDATE", ")", "{", "return", "9999", ";", "}", "elseif", "(", "$", "suffix", "===", "static", "::", "INSERT", ")", "{", "return", "9998", ";", "}", "elseif", "(", "$", "suffix", "===", "static", "::", "DELETE", ")", "{", "return", "9997", ";", "}", "return", "parent", "::", "getEventPriority", "(", "$", "eventName", ")", ";", "}" ]
Returns the event priority. @param string $eventName @return int
[ "Returns", "the", "event", "priority", "." ]
96ee3d28e02bd9513705408e3bb7f88a76e52f56
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/Persistence/PersistenceEventQueue.php#L116-L129
train
shadowfax/zf2-asset-manager
src/AssetManager/Asset/Resolver/MimeResolver.php
MimeResolver.getMimeType
public static function getMimeType($filename) { $mime_types = static::getMimeTypes(); $extension = pathinfo($filename, PATHINFO_EXTENSION); $extension = strtolower($extension); if (array_key_exists($extension, $mime_types)) { return $mime_types[$extension]; } elseif (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME); $mimetype = finfo_file($finfo, $filename); finfo_close($finfo); return $mimetype; } return 'application/octet-stream'; }
php
public static function getMimeType($filename) { $mime_types = static::getMimeTypes(); $extension = pathinfo($filename, PATHINFO_EXTENSION); $extension = strtolower($extension); if (array_key_exists($extension, $mime_types)) { return $mime_types[$extension]; } elseif (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME); $mimetype = finfo_file($finfo, $filename); finfo_close($finfo); return $mimetype; } return 'application/octet-stream'; }
[ "public", "static", "function", "getMimeType", "(", "$", "filename", ")", "{", "$", "mime_types", "=", "static", "::", "getMimeTypes", "(", ")", ";", "$", "extension", "=", "pathinfo", "(", "$", "filename", ",", "PATHINFO_EXTENSION", ")", ";", "$", "extension", "=", "strtolower", "(", "$", "extension", ")", ";", "if", "(", "array_key_exists", "(", "$", "extension", ",", "$", "mime_types", ")", ")", "{", "return", "$", "mime_types", "[", "$", "extension", "]", ";", "}", "elseif", "(", "function_exists", "(", "'finfo_open'", ")", ")", "{", "$", "finfo", "=", "finfo_open", "(", "FILEINFO_MIME", ")", ";", "$", "mimetype", "=", "finfo_file", "(", "$", "finfo", ",", "$", "filename", ")", ";", "finfo_close", "(", "$", "finfo", ")", ";", "return", "$", "mimetype", ";", "}", "return", "'application/octet-stream'", ";", "}" ]
Get the mime-type of a file @param string $filename The path to the file @return string The mime type
[ "Get", "the", "mime", "-", "type", "of", "a", "file" ]
adbdc40417c6fddbba1a8c8b675e59ce1a25ad65
https://github.com/shadowfax/zf2-asset-manager/blob/adbdc40417c6fddbba1a8c8b675e59ce1a25ad65/src/AssetManager/Asset/Resolver/MimeResolver.php#L23-L39
train
ekyna/Sale
Tax/TaxesAmounts.php
TaxesAmounts.addTaxAmount
public function addTaxAmount(TaxAmount $taxAmount) { $this->total += $taxAmount->getAmount(); foreach ($this->taxes as $tax) { if ($tax->getTax() == $taxAmount->getTax()) { $tax->addAmount($taxAmount->getAmount()); return; } } $this->taxes[] = $taxAmount; }
php
public function addTaxAmount(TaxAmount $taxAmount) { $this->total += $taxAmount->getAmount(); foreach ($this->taxes as $tax) { if ($tax->getTax() == $taxAmount->getTax()) { $tax->addAmount($taxAmount->getAmount()); return; } } $this->taxes[] = $taxAmount; }
[ "public", "function", "addTaxAmount", "(", "TaxAmount", "$", "taxAmount", ")", "{", "$", "this", "->", "total", "+=", "$", "taxAmount", "->", "getAmount", "(", ")", ";", "foreach", "(", "$", "this", "->", "taxes", "as", "$", "tax", ")", "{", "if", "(", "$", "tax", "->", "getTax", "(", ")", "==", "$", "taxAmount", "->", "getTax", "(", ")", ")", "{", "$", "tax", "->", "addAmount", "(", "$", "taxAmount", "->", "getAmount", "(", ")", ")", ";", "return", ";", "}", "}", "$", "this", "->", "taxes", "[", "]", "=", "$", "taxAmount", ";", "}" ]
Adds a tax amount @param TaxAmount $taxAmount
[ "Adds", "a", "tax", "amount" ]
434093b658628e88b59a156e21239df0b1855e89
https://github.com/ekyna/Sale/blob/434093b658628e88b59a156e21239df0b1855e89/Tax/TaxesAmounts.php#L36-L48
train
koolkode/view-express
src/ExpressContext.php
ExpressContext.bind
public function bind(ViewModelInterface $model) { $this->scoped['@file'] = $model->getResource(); $this->scoped['@model'] = $this->model = $model; $this->scoped['@context'] = $this; $this->renderer->triggerContextBound($this); }
php
public function bind(ViewModelInterface $model) { $this->scoped['@file'] = $model->getResource(); $this->scoped['@model'] = $this->model = $model; $this->scoped['@context'] = $this; $this->renderer->triggerContextBound($this); }
[ "public", "function", "bind", "(", "ViewModelInterface", "$", "model", ")", "{", "$", "this", "->", "scoped", "[", "'@file'", "]", "=", "$", "model", "->", "getResource", "(", ")", ";", "$", "this", "->", "scoped", "[", "'@model'", "]", "=", "$", "this", "->", "model", "=", "$", "model", ";", "$", "this", "->", "scoped", "[", "'@context'", "]", "=", "$", "this", ";", "$", "this", "->", "renderer", "->", "triggerContextBound", "(", "$", "this", ")", ";", "}" ]
Bind this express context to the given view model triggering a context-bound event in the process. @param ViewModelInterface $model
[ "Bind", "this", "express", "context", "to", "the", "given", "view", "model", "triggering", "a", "context", "-", "bound", "event", "in", "the", "process", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/ExpressContext.php#L81-L88
train
koolkode/view-express
src/ExpressContext.php
ExpressContext.get
public function get($key) { if(array_key_exists($key, $this->scoped)) { return $this->scoped[$key]; } return $this->model->get($key, NULL); }
php
public function get($key) { if(array_key_exists($key, $this->scoped)) { return $this->scoped[$key]; } return $this->model->get($key, NULL); }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "scoped", ")", ")", "{", "return", "$", "this", "->", "scoped", "[", "$", "key", "]", ";", "}", "return", "$", "this", "->", "model", "->", "get", "(", "$", "key", ",", "NULL", ")", ";", "}" ]
Get the value of a scoped variable or fallback to the view model. @param string $key The name of the variable to be accessed. @return mixed The value of the requetsed variable.
[ "Get", "the", "value", "of", "a", "scoped", "variable", "or", "fallback", "to", "the", "view", "model", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/ExpressContext.php#L133-L141
train
koolkode/view-express
src/ExpressContext.php
ExpressContext.set
public function set($key, $value) { if(array_key_exists($key, $this->scoped)) { $val = $this->scoped[$key]; if($value === NULL) { unset($this->scoped[$key]); } else { $this->scoped[$key] = $value; } return $val; } if($value !== NULL) { $this->scoped[$key] = $value; } }
php
public function set($key, $value) { if(array_key_exists($key, $this->scoped)) { $val = $this->scoped[$key]; if($value === NULL) { unset($this->scoped[$key]); } else { $this->scoped[$key] = $value; } return $val; } if($value !== NULL) { $this->scoped[$key] = $value; } }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "scoped", ")", ")", "{", "$", "val", "=", "$", "this", "->", "scoped", "[", "$", "key", "]", ";", "if", "(", "$", "value", "===", "NULL", ")", "{", "unset", "(", "$", "this", "->", "scoped", "[", "$", "key", "]", ")", ";", "}", "else", "{", "$", "this", "->", "scoped", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "val", ";", "}", "if", "(", "$", "value", "!==", "NULL", ")", "{", "$", "this", "->", "scoped", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Set the given variable in the scope and return the previous value if present, setting a value of NULL will remove the value from the context. @param string $key The name of the scoped variable to be set. @param mixed $value The new value of the scoped variable or NULL to unset the variable. @return mixed The previous value of the scoped variable.
[ "Set", "the", "given", "variable", "in", "the", "scope", "and", "return", "the", "previous", "value", "if", "present", "setting", "a", "value", "of", "NULL", "will", "remove", "the", "value", "from", "the", "context", "." ]
a8ebe6f373b6bfe8b8818d6264535e8fe063a596
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/ExpressContext.php#L151-L173
train
kambalabs/KmbPuppetDb
src/KmbPuppetDb/Service/ReportStatistics.php
ReportStatistics.processStatistics
protected function processStatistics($query = null) { $this->skips = 0; $this->success = 0; $this->failures = 0; $this->noops = 0; $reports = $this->getReportService()->getAllForToday($query); foreach ($reports as $report) { /** @var Model\Report $report */ if ($report->getStatus() == Model\ReportInterface::SKIPPED) { $this->skips++; } elseif ($report->getStatus() == Model\ReportInterface::SUCCESS) { $this->success++; } elseif ($report->getStatus() == Model\ReportInterface::FAILURE) { $this->failures++; } elseif ($report->getStatus() == Model\ReportInterface::NOOP) { $this->noops++; } } }
php
protected function processStatistics($query = null) { $this->skips = 0; $this->success = 0; $this->failures = 0; $this->noops = 0; $reports = $this->getReportService()->getAllForToday($query); foreach ($reports as $report) { /** @var Model\Report $report */ if ($report->getStatus() == Model\ReportInterface::SKIPPED) { $this->skips++; } elseif ($report->getStatus() == Model\ReportInterface::SUCCESS) { $this->success++; } elseif ($report->getStatus() == Model\ReportInterface::FAILURE) { $this->failures++; } elseif ($report->getStatus() == Model\ReportInterface::NOOP) { $this->noops++; } } }
[ "protected", "function", "processStatistics", "(", "$", "query", "=", "null", ")", "{", "$", "this", "->", "skips", "=", "0", ";", "$", "this", "->", "success", "=", "0", ";", "$", "this", "->", "failures", "=", "0", ";", "$", "this", "->", "noops", "=", "0", ";", "$", "reports", "=", "$", "this", "->", "getReportService", "(", ")", "->", "getAllForToday", "(", "$", "query", ")", ";", "foreach", "(", "$", "reports", "as", "$", "report", ")", "{", "/** @var Model\\Report $report */", "if", "(", "$", "report", "->", "getStatus", "(", ")", "==", "Model", "\\", "ReportInterface", "::", "SKIPPED", ")", "{", "$", "this", "->", "skips", "++", ";", "}", "elseif", "(", "$", "report", "->", "getStatus", "(", ")", "==", "Model", "\\", "ReportInterface", "::", "SUCCESS", ")", "{", "$", "this", "->", "success", "++", ";", "}", "elseif", "(", "$", "report", "->", "getStatus", "(", ")", "==", "Model", "\\", "ReportInterface", "::", "FAILURE", ")", "{", "$", "this", "->", "failures", "++", ";", "}", "elseif", "(", "$", "report", "->", "getStatus", "(", ")", "==", "Model", "\\", "ReportInterface", "::", "NOOP", ")", "{", "$", "this", "->", "noops", "++", ";", "}", "}", "}" ]
Browse all reports and process all the statistics @param \KmbPuppetDb\Query\Query|array $query
[ "Browse", "all", "reports", "and", "process", "all", "the", "statistics" ]
df56a275cf00f4402cf121a2e99149168f1f8b2d
https://github.com/kambalabs/KmbPuppetDb/blob/df56a275cf00f4402cf121a2e99149168f1f8b2d/src/KmbPuppetDb/Service/ReportStatistics.php#L154-L173
train
DoSomething/mb-toolbox
src/MB_Toolbox_cURL.php
MB_Toolbox_cURL.curlGETauth
public function curlGETauth($curlUrl) { // Remove authentication until POST to /api/v1/auth/login is resolved if (!isset($this->auth)) { $this->authenticate(); } $results = $this->curlGET($curlUrl, true); $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: curlGETauth', 1); return $results; }
php
public function curlGETauth($curlUrl) { // Remove authentication until POST to /api/v1/auth/login is resolved if (!isset($this->auth)) { $this->authenticate(); } $results = $this->curlGET($curlUrl, true); $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: curlGETauth', 1); return $results; }
[ "public", "function", "curlGETauth", "(", "$", "curlUrl", ")", "{", "// Remove authentication until POST to /api/v1/auth/login is resolved", "if", "(", "!", "isset", "(", "$", "this", "->", "auth", ")", ")", "{", "$", "this", "->", "authenticate", "(", ")", ";", "}", "$", "results", "=", "$", "this", "->", "curlGET", "(", "$", "curlUrl", ",", "true", ")", ";", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: curlGETauth'", ",", "1", ")", ";", "return", "$", "results", ";", "}" ]
cURL GET with authentication @param string $curlUrl The URL to GET to. Include domain and path. @return object $result The results returned from the cURL call.
[ "cURL", "GET", "with", "authentication" ]
ceec5fc594bae137d1ab1f447344800343b62ac6
https://github.com/DoSomething/mb-toolbox/blob/ceec5fc594bae137d1ab1f447344800343b62ac6/src/MB_Toolbox_cURL.php#L139-L151
train
DoSomething/mb-toolbox
src/MB_Toolbox_cURL.php
MB_Toolbox_cURL.curlPOSTauth
public function curlPOSTauth($curlUrl, $post) { // Remove authentication until POST to /api/v1/auth/login is resolved if (!isset($this->auth)) { $this->authenticate(); } $results = $this->curlPOST($curlUrl, $post, true); $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: curlPOSTauth', 1); return $results; }
php
public function curlPOSTauth($curlUrl, $post) { // Remove authentication until POST to /api/v1/auth/login is resolved if (!isset($this->auth)) { $this->authenticate(); } $results = $this->curlPOST($curlUrl, $post, true); $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: curlPOSTauth', 1); return $results; }
[ "public", "function", "curlPOSTauth", "(", "$", "curlUrl", ",", "$", "post", ")", "{", "// Remove authentication until POST to /api/v1/auth/login is resolved", "if", "(", "!", "isset", "(", "$", "this", "->", "auth", ")", ")", "{", "$", "this", "->", "authenticate", "(", ")", ";", "}", "$", "results", "=", "$", "this", "->", "curlPOST", "(", "$", "curlUrl", ",", "$", "post", ",", "true", ")", ";", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: curlPOSTauth'", ",", "1", ")", ";", "return", "$", "results", ";", "}" ]
cURL POSTs with authentication @param string $curlUrl The URL to POST to. Include domain and path. @param array $post The values to POST. @return object $result The results returned from the cURL call.
[ "cURL", "POSTs", "with", "authentication" ]
ceec5fc594bae137d1ab1f447344800343b62ac6
https://github.com/DoSomething/mb-toolbox/blob/ceec5fc594bae137d1ab1f447344800343b62ac6/src/MB_Toolbox_cURL.php#L272-L285
train
DoSomething/mb-toolbox
src/MB_Toolbox_cURL.php
MB_Toolbox_cURL.curlDELETEauth
public function curlDELETEauth($curlUrl) { // Remove authentication until POST to /api/v1/auth/login is resolved if (!isset($this->auth)) { $this->authenticate(); } $results = $this->curlDELETE($curlUrl, true); $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: curlDELETEauth', 1); return $results; }
php
public function curlDELETEauth($curlUrl) { // Remove authentication until POST to /api/v1/auth/login is resolved if (!isset($this->auth)) { $this->authenticate(); } $results = $this->curlDELETE($curlUrl, true); $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: curlDELETEauth', 1); return $results; }
[ "public", "function", "curlDELETEauth", "(", "$", "curlUrl", ")", "{", "// Remove authentication until POST to /api/v1/auth/login is resolved", "if", "(", "!", "isset", "(", "$", "this", "->", "auth", ")", ")", "{", "$", "this", "->", "authenticate", "(", ")", ";", "}", "$", "results", "=", "$", "this", "->", "curlDELETE", "(", "$", "curlUrl", ",", "true", ")", ";", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: curlDELETEauth'", ",", "1", ")", ";", "return", "$", "results", ";", "}" ]
cURL DELETE with authentication @param string $curlUrl The URL to DELETE to. Include domain and path. @return object $result The results returned from the cURL call.
[ "cURL", "DELETE", "with", "authentication" ]
ceec5fc594bae137d1ab1f447344800343b62ac6
https://github.com/DoSomething/mb-toolbox/blob/ceec5fc594bae137d1ab1f447344800343b62ac6/src/MB_Toolbox_cURL.php#L330-L343
train
DoSomething/mb-toolbox
src/MB_Toolbox_cURL.php
MB_Toolbox_cURL.authenticate
private function authenticate() { $dsDrupalAPIConfig = $this->mbConfig->getProperty('ds_drupal_api_config'); if (!empty($dsDrupalAPIConfig['username']) && !empty($dsDrupalAPIConfig['password'])) { $post = [ 'username' => $dsDrupalAPIConfig['username'], 'password' => $dsDrupalAPIConfig['password'], ]; } else { trigger_error("MB_Toolbox->authenticate() : username and/or password not defined.", E_USER_ERROR); exit(0); } // https://www.dosomething.org/api/v1/auth/login $curlUrl = $this->buildcURL($dsDrupalAPIConfig); $curlUrl .= self::DRUPAL_API . '/auth/login'; $auth = $this->curlPOST($curlUrl, $post); if ($auth[1] == 200) { $auth = $auth[0]; } else { echo 'ERROR - Failed to get auth creds: ' . $curlUrl . ' with POST: ' . print_r($post, true), PHP_EOL; $auth = false; } $this->auth = $auth; $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: authenticate', 1); }
php
private function authenticate() { $dsDrupalAPIConfig = $this->mbConfig->getProperty('ds_drupal_api_config'); if (!empty($dsDrupalAPIConfig['username']) && !empty($dsDrupalAPIConfig['password'])) { $post = [ 'username' => $dsDrupalAPIConfig['username'], 'password' => $dsDrupalAPIConfig['password'], ]; } else { trigger_error("MB_Toolbox->authenticate() : username and/or password not defined.", E_USER_ERROR); exit(0); } // https://www.dosomething.org/api/v1/auth/login $curlUrl = $this->buildcURL($dsDrupalAPIConfig); $curlUrl .= self::DRUPAL_API . '/auth/login'; $auth = $this->curlPOST($curlUrl, $post); if ($auth[1] == 200) { $auth = $auth[0]; } else { echo 'ERROR - Failed to get auth creds: ' . $curlUrl . ' with POST: ' . print_r($post, true), PHP_EOL; $auth = false; } $this->auth = $auth; $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: authenticate', 1); }
[ "private", "function", "authenticate", "(", ")", "{", "$", "dsDrupalAPIConfig", "=", "$", "this", "->", "mbConfig", "->", "getProperty", "(", "'ds_drupal_api_config'", ")", ";", "if", "(", "!", "empty", "(", "$", "dsDrupalAPIConfig", "[", "'username'", "]", ")", "&&", "!", "empty", "(", "$", "dsDrupalAPIConfig", "[", "'password'", "]", ")", ")", "{", "$", "post", "=", "[", "'username'", "=>", "$", "dsDrupalAPIConfig", "[", "'username'", "]", ",", "'password'", "=>", "$", "dsDrupalAPIConfig", "[", "'password'", "]", ",", "]", ";", "}", "else", "{", "trigger_error", "(", "\"MB_Toolbox->authenticate() : username and/or password not defined.\"", ",", "E_USER_ERROR", ")", ";", "exit", "(", "0", ")", ";", "}", "// https://www.dosomething.org/api/v1/auth/login", "$", "curlUrl", "=", "$", "this", "->", "buildcURL", "(", "$", "dsDrupalAPIConfig", ")", ";", "$", "curlUrl", ".=", "self", "::", "DRUPAL_API", ".", "'/auth/login'", ";", "$", "auth", "=", "$", "this", "->", "curlPOST", "(", "$", "curlUrl", ",", "$", "post", ")", ";", "if", "(", "$", "auth", "[", "1", "]", "==", "200", ")", "{", "$", "auth", "=", "$", "auth", "[", "0", "]", ";", "}", "else", "{", "echo", "'ERROR - Failed to get auth creds: '", ".", "$", "curlUrl", ".", "' with POST: '", ".", "print_r", "(", "$", "post", ",", "true", ")", ",", "PHP_EOL", ";", "$", "auth", "=", "false", ";", "}", "$", "this", "->", "auth", "=", "$", "auth", ";", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: authenticate'", ",", "1", ")", ";", "}" ]
Authenticate for Drupal API access
[ "Authenticate", "for", "Drupal", "API", "access" ]
ceec5fc594bae137d1ab1f447344800343b62ac6
https://github.com/DoSomething/mb-toolbox/blob/ceec5fc594bae137d1ab1f447344800343b62ac6/src/MB_Toolbox_cURL.php#L348-L378
train
DoSomething/mb-toolbox
src/MB_Toolbox_cURL.php
MB_Toolbox_cURL.buildcURL
public function buildcURL($settings) { if (isset($settings['host'])) { $curlUrl = $settings['host']; $port = $settings['port']; if ($port > 0 && is_numeric($port)) { $curlUrl .= ':' . (int) $port; } $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: buildcURL', 1); return $curlUrl; } else { throw new Exception('buildcURL required host setting missing.'); } }
php
public function buildcURL($settings) { if (isset($settings['host'])) { $curlUrl = $settings['host']; $port = $settings['port']; if ($port > 0 && is_numeric($port)) { $curlUrl .= ':' . (int) $port; } $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: buildcURL', 1); return $curlUrl; } else { throw new Exception('buildcURL required host setting missing.'); } }
[ "public", "function", "buildcURL", "(", "$", "settings", ")", "{", "if", "(", "isset", "(", "$", "settings", "[", "'host'", "]", ")", ")", "{", "$", "curlUrl", "=", "$", "settings", "[", "'host'", "]", ";", "$", "port", "=", "$", "settings", "[", "'port'", "]", ";", "if", "(", "$", "port", ">", "0", "&&", "is_numeric", "(", "$", "port", ")", ")", "{", "$", "curlUrl", ".=", "':'", ".", "(", "int", ")", "$", "port", ";", "}", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: buildcURL'", ",", "1", ")", ";", "return", "$", "curlUrl", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'buildcURL required host setting missing.'", ")", ";", "}", "}" ]
buildURL - Common construction utility for URLs of API paths. @todo: Move to MB_Toolbox_cURL class. @param array $settings "host" and "port" setting @return null @throws Exception
[ "buildURL", "-", "Common", "construction", "utility", "for", "URLs", "of", "API", "paths", "." ]
ceec5fc594bae137d1ab1f447344800343b62ac6
https://github.com/DoSomething/mb-toolbox/blob/ceec5fc594bae137d1ab1f447344800343b62ac6/src/MB_Toolbox_cURL.php#L390-L404
train
DoSomething/mb-toolbox
src/MB_Toolbox_cURL.php
MB_Toolbox_cURL.isNorthstar
private function isNorthstar($northstarConfig, $curlUrl) { // Confirm each of the required config settings are available if (empty($northstarConfig['host'])) { $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar false', 1); return false; } if (empty($northstarConfig['id'])) { $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar false', 1); return false; } if (empty($northstarConfig['key'])) { $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar false', 1); return false; } // Validate cURL as being for Northstar if (strpos($curlUrl, $northstarConfig['host']) === false) { $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar false', 1); return false; } $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar true', 1); return true; }
php
private function isNorthstar($northstarConfig, $curlUrl) { // Confirm each of the required config settings are available if (empty($northstarConfig['host'])) { $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar false', 1); return false; } if (empty($northstarConfig['id'])) { $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar false', 1); return false; } if (empty($northstarConfig['key'])) { $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar false', 1); return false; } // Validate cURL as being for Northstar if (strpos($curlUrl, $northstarConfig['host']) === false) { $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar false', 1); return false; } $this->statHat->ezCount('MB_Toolbox: MB_Toolbox_cURL: isNorthstar true', 1); return true; }
[ "private", "function", "isNorthstar", "(", "$", "northstarConfig", ",", "$", "curlUrl", ")", "{", "// Confirm each of the required config settings are available", "if", "(", "empty", "(", "$", "northstarConfig", "[", "'host'", "]", ")", ")", "{", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: isNorthstar false'", ",", "1", ")", ";", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "northstarConfig", "[", "'id'", "]", ")", ")", "{", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: isNorthstar false'", ",", "1", ")", ";", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "northstarConfig", "[", "'key'", "]", ")", ")", "{", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: isNorthstar false'", ",", "1", ")", ";", "return", "false", ";", "}", "// Validate cURL as being for Northstar", "if", "(", "strpos", "(", "$", "curlUrl", ",", "$", "northstarConfig", "[", "'host'", "]", ")", "===", "false", ")", "{", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: isNorthstar false'", ",", "1", ")", ";", "return", "false", ";", "}", "$", "this", "->", "statHat", "->", "ezCount", "(", "'MB_Toolbox: MB_Toolbox_cURL: isNorthstar true'", ",", "1", ")", ";", "return", "true", ";", "}" ]
Test if the Northstar configuration settings are valid and the cURL is for Northstar. @param array $northstarConfig Configuration settings for connecting to Northstar API @param string $curlUrl A cURL path. @return boolean
[ "Test", "if", "the", "Northstar", "configuration", "settings", "are", "valid", "and", "the", "cURL", "is", "for", "Northstar", "." ]
ceec5fc594bae137d1ab1f447344800343b62ac6
https://github.com/DoSomething/mb-toolbox/blob/ceec5fc594bae137d1ab1f447344800343b62ac6/src/MB_Toolbox_cURL.php#L416-L441
train
ScaraMVC/Framework
src/Scara/Database/Migration.php
Migration.create
public function create($table, Closure $closure) { $blueprint = $this->createBlueprint($table, $closure); $blueprint->create(); }
php
public function create($table, Closure $closure) { $blueprint = $this->createBlueprint($table, $closure); $blueprint->create(); }
[ "public", "function", "create", "(", "$", "table", ",", "Closure", "$", "closure", ")", "{", "$", "blueprint", "=", "$", "this", "->", "createBlueprint", "(", "$", "table", ",", "$", "closure", ")", ";", "$", "blueprint", "->", "create", "(", ")", ";", "}" ]
Creates table from migration. @param string $table @param \Closure $closure @return void
[ "Creates", "table", "from", "migration", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Database/Migration.php#L20-L24
train
ScaraMVC/Framework
src/Scara/Database/Migration.php
Migration.update
public function update($table, Closure $closure) { $blueprint = $this->createBlueprint($table, $closure); $blueprint->update(); }
php
public function update($table, Closure $closure) { $blueprint = $this->createBlueprint($table, $closure); $blueprint->update(); }
[ "public", "function", "update", "(", "$", "table", ",", "Closure", "$", "closure", ")", "{", "$", "blueprint", "=", "$", "this", "->", "createBlueprint", "(", "$", "table", ",", "$", "closure", ")", ";", "$", "blueprint", "->", "update", "(", ")", ";", "}" ]
updates table from migration. @param string $table @param \Closure $closure @return void
[ "updates", "table", "from", "migration", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Database/Migration.php#L34-L38
train
ARCANESOFT/Auth
src/Seeds/Foundation/UserTableSeeder.php
UserTableSeeder.seedAdminUser
private function seedAdminUser() { tap(new User($this->getAdminUserAttributes()), function (User $admin) { $admin->save(); /** @var \Arcanesoft\Auth\Models\Role $adminRole */ $adminRole = Role::admin()->first(); $adminRole->attachUser($admin); }); }
php
private function seedAdminUser() { tap(new User($this->getAdminUserAttributes()), function (User $admin) { $admin->save(); /** @var \Arcanesoft\Auth\Models\Role $adminRole */ $adminRole = Role::admin()->first(); $adminRole->attachUser($admin); }); }
[ "private", "function", "seedAdminUser", "(", ")", "{", "tap", "(", "new", "User", "(", "$", "this", "->", "getAdminUserAttributes", "(", ")", ")", ",", "function", "(", "User", "$", "admin", ")", "{", "$", "admin", "->", "save", "(", ")", ";", "/** @var \\Arcanesoft\\Auth\\Models\\Role $adminRole */", "$", "adminRole", "=", "Role", "::", "admin", "(", ")", "->", "first", "(", ")", ";", "$", "adminRole", "->", "attachUser", "(", "$", "admin", ")", ";", "}", ")", ";", "}" ]
Seed the admin account.
[ "Seed", "the", "admin", "account", "." ]
b33ca82597a76b1e395071f71ae3e51f1ec67e62
https://github.com/ARCANESOFT/Auth/blob/b33ca82597a76b1e395071f71ae3e51f1ec67e62/src/Seeds/Foundation/UserTableSeeder.php#L37-L46
train
ARCANESOFT/Auth
src/Seeds/Foundation/UserTableSeeder.php
UserTableSeeder.getAdminUserAttributes
private function getAdminUserAttributes() { $attributes = [ 'username' => 'admin', 'first_name' => 'Super', 'last_name' => 'ADMIN', 'email' => env('ADMIN_EMAIL', '[email protected]'), 'password' => env('ADMIN_PASSWORD', 'password'), 'is_admin' => true, 'activated_at' => $now = now(), ]; if (UserConfirmator::isEnabled()) $attributes['confirmed_at'] = $now; return $attributes; }
php
private function getAdminUserAttributes() { $attributes = [ 'username' => 'admin', 'first_name' => 'Super', 'last_name' => 'ADMIN', 'email' => env('ADMIN_EMAIL', '[email protected]'), 'password' => env('ADMIN_PASSWORD', 'password'), 'is_admin' => true, 'activated_at' => $now = now(), ]; if (UserConfirmator::isEnabled()) $attributes['confirmed_at'] = $now; return $attributes; }
[ "private", "function", "getAdminUserAttributes", "(", ")", "{", "$", "attributes", "=", "[", "'username'", "=>", "'admin'", ",", "'first_name'", "=>", "'Super'", ",", "'last_name'", "=>", "'ADMIN'", ",", "'email'", "=>", "env", "(", "'ADMIN_EMAIL'", ",", "'[email protected]'", ")", ",", "'password'", "=>", "env", "(", "'ADMIN_PASSWORD'", ",", "'password'", ")", ",", "'is_admin'", "=>", "true", ",", "'activated_at'", "=>", "$", "now", "=", "now", "(", ")", ",", "]", ";", "if", "(", "UserConfirmator", "::", "isEnabled", "(", ")", ")", "$", "attributes", "[", "'confirmed_at'", "]", "=", "$", "now", ";", "return", "$", "attributes", ";", "}" ]
Get the admin user's attributes. @return array
[ "Get", "the", "admin", "user", "s", "attributes", "." ]
b33ca82597a76b1e395071f71ae3e51f1ec67e62
https://github.com/ARCANESOFT/Auth/blob/b33ca82597a76b1e395071f71ae3e51f1ec67e62/src/Seeds/Foundation/UserTableSeeder.php#L53-L69
train
Tree6bee/framework
src/Foundation/Application.php
Application.sendThroughPipeline
protected function sendThroughPipeline(array $middleware, \Closure $then) { if (count($middleware) > 0) { return (new Pipeline($this)) ->send($this) ->through($middleware) ->then($then); } return $then(); }
php
protected function sendThroughPipeline(array $middleware, \Closure $then) { if (count($middleware) > 0) { return (new Pipeline($this)) ->send($this) ->through($middleware) ->then($then); } return $then(); }
[ "protected", "function", "sendThroughPipeline", "(", "array", "$", "middleware", ",", "\\", "Closure", "$", "then", ")", "{", "if", "(", "count", "(", "$", "middleware", ")", ">", "0", ")", "{", "return", "(", "new", "Pipeline", "(", "$", "this", ")", ")", "->", "send", "(", "$", "this", ")", "->", "through", "(", "$", "middleware", ")", "->", "then", "(", "$", "then", ")", ";", "}", "return", "$", "then", "(", ")", ";", "}" ]
Send the request through the pipeline with the given callback. @param array $middleware @param \Closure $then @return mixed
[ "Send", "the", "request", "through", "the", "pipeline", "with", "the", "given", "callback", "." ]
3feac0b44666068d26cbed740d7a41590c03ab7b
https://github.com/Tree6bee/framework/blob/3feac0b44666068d26cbed740d7a41590c03ab7b/src/Foundation/Application.php#L124-L134
train
itcreator/custom-cmf
Module/System/src/Cmf/System/Request.php
Request.get
public function get($name, $type = self::TYPE_GET, $default = null) { return (isset($this->vars[$type]) && isset($this->vars[$type][$name])) ? $this->vars[$type][$name] : $default; }
php
public function get($name, $type = self::TYPE_GET, $default = null) { return (isset($this->vars[$type]) && isset($this->vars[$type][$name])) ? $this->vars[$type][$name] : $default; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "type", "=", "self", "::", "TYPE_GET", ",", "$", "default", "=", "null", ")", "{", "return", "(", "isset", "(", "$", "this", "->", "vars", "[", "$", "type", "]", ")", "&&", "isset", "(", "$", "this", "->", "vars", "[", "$", "type", "]", "[", "$", "name", "]", ")", ")", "?", "$", "this", "->", "vars", "[", "$", "type", "]", "[", "$", "name", "]", ":", "$", "default", ";", "}" ]
This method return request value @param string $name @param string $type @param null $default @return null|mixed
[ "This", "method", "return", "request", "value" ]
42fc0535dfa0f641856f06673f6ab596b2020c40
https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/System/src/Cmf/System/Request.php#L68-L71
train
nguyenanhung/requests
src/MyRequests.php
MyRequests.xmlRequest
public function xmlRequest($url = '', $data = '', $timeout = 60) { $this->debug->debug(__FUNCTION__, '/------------> ' . __FUNCTION__ . ' <------------\\'); $inputParams = [ 'url' => $url, 'data' => $data, 'timeout' => $timeout, ]; $this->debug->info(__FUNCTION__, 'input Params: ', $inputParams); $endpoint = trim($url); $this->debug->debug(__FUNCTION__, 'cURL Endpoint: ', $endpoint); if (!extension_loaded('curl')) { $this->debug->critical(__FUNCTION__, 'Server is not Support cURL, Please cURL. Library fallback user File Get Contents'); // Create Request use File Get Content $content = new GetContents(); $content->debugStatus = $this->debugStatus; $content->debugLoggerPath = $this->debugLoggerPath; $content->__construct(); $content->setURL($url); $content->setMethod('POST'); $content->setXML(TRUE); $content->setData($data); $content->sendRequest(); // Create Request $result = $content->response(); $getContent = $content->getContent(); $getError = $content->getError(); $this->debug->debug(__FUNCTION__, 'Get Content Result: ' . $getContent); $this->debug->debug(__FUNCTION__, 'Get Error Result: ' . $getError); } else { $this->setRequestIsXml(TRUE); $this->setTimeout($timeout); $result = $this->curlRequest($url, $data, 'POST'); } $this->debug->info(__FUNCTION__, 'Final Result from Request: ', $result); return $result; }
php
public function xmlRequest($url = '', $data = '', $timeout = 60) { $this->debug->debug(__FUNCTION__, '/------------> ' . __FUNCTION__ . ' <------------\\'); $inputParams = [ 'url' => $url, 'data' => $data, 'timeout' => $timeout, ]; $this->debug->info(__FUNCTION__, 'input Params: ', $inputParams); $endpoint = trim($url); $this->debug->debug(__FUNCTION__, 'cURL Endpoint: ', $endpoint); if (!extension_loaded('curl')) { $this->debug->critical(__FUNCTION__, 'Server is not Support cURL, Please cURL. Library fallback user File Get Contents'); // Create Request use File Get Content $content = new GetContents(); $content->debugStatus = $this->debugStatus; $content->debugLoggerPath = $this->debugLoggerPath; $content->__construct(); $content->setURL($url); $content->setMethod('POST'); $content->setXML(TRUE); $content->setData($data); $content->sendRequest(); // Create Request $result = $content->response(); $getContent = $content->getContent(); $getError = $content->getError(); $this->debug->debug(__FUNCTION__, 'Get Content Result: ' . $getContent); $this->debug->debug(__FUNCTION__, 'Get Error Result: ' . $getError); } else { $this->setRequestIsXml(TRUE); $this->setTimeout($timeout); $result = $this->curlRequest($url, $data, 'POST'); } $this->debug->info(__FUNCTION__, 'Final Result from Request: ', $result); return $result; }
[ "public", "function", "xmlRequest", "(", "$", "url", "=", "''", ",", "$", "data", "=", "''", ",", "$", "timeout", "=", "60", ")", "{", "$", "this", "->", "debug", "->", "debug", "(", "__FUNCTION__", ",", "'/------------> '", ".", "__FUNCTION__", ".", "' <------------\\\\'", ")", ";", "$", "inputParams", "=", "[", "'url'", "=>", "$", "url", ",", "'data'", "=>", "$", "data", ",", "'timeout'", "=>", "$", "timeout", ",", "]", ";", "$", "this", "->", "debug", "->", "info", "(", "__FUNCTION__", ",", "'input Params: '", ",", "$", "inputParams", ")", ";", "$", "endpoint", "=", "trim", "(", "$", "url", ")", ";", "$", "this", "->", "debug", "->", "debug", "(", "__FUNCTION__", ",", "'cURL Endpoint: '", ",", "$", "endpoint", ")", ";", "if", "(", "!", "extension_loaded", "(", "'curl'", ")", ")", "{", "$", "this", "->", "debug", "->", "critical", "(", "__FUNCTION__", ",", "'Server is not Support cURL, Please cURL. Library fallback user File Get Contents'", ")", ";", "// Create Request use File Get Content", "$", "content", "=", "new", "GetContents", "(", ")", ";", "$", "content", "->", "debugStatus", "=", "$", "this", "->", "debugStatus", ";", "$", "content", "->", "debugLoggerPath", "=", "$", "this", "->", "debugLoggerPath", ";", "$", "content", "->", "__construct", "(", ")", ";", "$", "content", "->", "setURL", "(", "$", "url", ")", ";", "$", "content", "->", "setMethod", "(", "'POST'", ")", ";", "$", "content", "->", "setXML", "(", "TRUE", ")", ";", "$", "content", "->", "setData", "(", "$", "data", ")", ";", "$", "content", "->", "sendRequest", "(", ")", ";", "// Create Request", "$", "result", "=", "$", "content", "->", "response", "(", ")", ";", "$", "getContent", "=", "$", "content", "->", "getContent", "(", ")", ";", "$", "getError", "=", "$", "content", "->", "getError", "(", ")", ";", "$", "this", "->", "debug", "->", "debug", "(", "__FUNCTION__", ",", "'Get Content Result: '", ".", "$", "getContent", ")", ";", "$", "this", "->", "debug", "->", "debug", "(", "__FUNCTION__", ",", "'Get Error Result: '", ".", "$", "getError", ")", ";", "}", "else", "{", "$", "this", "->", "setRequestIsXml", "(", "TRUE", ")", ";", "$", "this", "->", "setTimeout", "(", "$", "timeout", ")", ";", "$", "result", "=", "$", "this", "->", "curlRequest", "(", "$", "url", ",", "$", "data", ",", "'POST'", ")", ";", "}", "$", "this", "->", "debug", "->", "info", "(", "__FUNCTION__", ",", "'Final Result from Request: '", ",", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Function xmlRequest Send XML Request to Server @author: 713uk13m <[email protected]> @time : 10/7/18 07:11 @param string $url URL Endpoint to be Request @param string $data Data Content to be Request @param int $timeout Timeout Request @return array|null|string Response from Server
[ "Function", "xmlRequest", "Send", "XML", "Request", "to", "Server" ]
fae98614a256be6a3ff9bea34a273d182a3ae730
https://github.com/nguyenanhung/requests/blob/fae98614a256be6a3ff9bea34a273d182a3ae730/src/MyRequests.php#L986-L1023
train
ezra-obiwale/dSCore
src/Stdlib/Json.php
Json.decode
public function decode($assoc = false, $depth = 512, $options = 0) { return json_decode($this->content, $assoc, $depth, $options); }
php
public function decode($assoc = false, $depth = 512, $options = 0) { return json_decode($this->content, $assoc, $depth, $options); }
[ "public", "function", "decode", "(", "$", "assoc", "=", "false", ",", "$", "depth", "=", "512", ",", "$", "options", "=", "0", ")", "{", "return", "json_decode", "(", "$", "this", "->", "content", ",", "$", "assoc", ",", "$", "depth", ",", "$", "options", ")", ";", "}" ]
Decodes the given JSON string @see json_encode() @param bool $assoc [optional] <p> When <b>TRUE</b>, returned objects will be converted into associative arrays. </p> @param int $depth [optional] <p> User specified recursion depth. </p> @param int $options [optional] <p> Bitmask of JSON decode options. Currently only <b>JSON_BIGINT_AS_STRING</b> is supported (default is to cast large integers as floats) </p> @return mixed the value encoded in <i>json</i> in appropriate PHP type. Values true, false and null (case-insensitive) are returned as <b>TRUE</b>, <b>FALSE</b> and <b>NULL</b> respectively. <b>NULL</b> is returned if the <i>json</i> cannot be decoded or if the encoded data is deeper than the recursion limit.
[ "Decodes", "the", "given", "JSON", "string" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Stdlib/Json.php#L87-L89
train
CaliCastle/socialite
src/SocialiteManager.php
SocialiteManager.createBitbucketDriver
protected function createBitbucketDriver() { $config = $this->app['config']['services.bitbucket']; return new BitbucketProvider( $this->app['request'], new BitbucketServer($this->formatConfig($config)) ); }
php
protected function createBitbucketDriver() { $config = $this->app['config']['services.bitbucket']; return new BitbucketProvider( $this->app['request'], new BitbucketServer($this->formatConfig($config)) ); }
[ "protected", "function", "createBitbucketDriver", "(", ")", "{", "$", "config", "=", "$", "this", "->", "app", "[", "'config'", "]", "[", "'services.bitbucket'", "]", ";", "return", "new", "BitbucketProvider", "(", "$", "this", "->", "app", "[", "'request'", "]", ",", "new", "BitbucketServer", "(", "$", "this", "->", "formatConfig", "(", "$", "config", ")", ")", ")", ";", "}" ]
Create an instance of Bitbucket driver. @return One\AbstractProvider
[ "Create", "an", "instance", "of", "Bitbucket", "driver", "." ]
68acdf290c7e3afbc3db08b3a197230a3f6b0370
https://github.com/CaliCastle/socialite/blob/68acdf290c7e3afbc3db08b3a197230a3f6b0370/src/SocialiteManager.php#L255-L262
train
bandama-framework/bandama-framework
src/foundation/translation/Translator.php
Translator.addFile
public function addFile($file) { $baseName = basename($file, '.php'); $components = explode('.', $baseName); $language = $components[1]; $data = require($file); $this->add($data, $language); }
php
public function addFile($file) { $baseName = basename($file, '.php'); $components = explode('.', $baseName); $language = $components[1]; $data = require($file); $this->add($data, $language); }
[ "public", "function", "addFile", "(", "$", "file", ")", "{", "$", "baseName", "=", "basename", "(", "$", "file", ",", "'.php'", ")", ";", "$", "components", "=", "explode", "(", "'.'", ",", "$", "baseName", ")", ";", "$", "language", "=", "$", "components", "[", "1", "]", ";", "$", "data", "=", "require", "(", "$", "file", ")", ";", "$", "this", "->", "add", "(", "$", "data", ",", "$", "language", ")", ";", "}" ]
Add translation file content @param string $file @return void
[ "Add", "translation", "file", "content" ]
234ed703baf9e31268941c9d5f6d5e004cc53066
https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/foundation/translation/Translator.php#L76-L85
train
bandama-framework/bandama-framework
src/foundation/translation/Translator.php
Translator.add
private function add($data, $language) { $parts = explode('-', $language); // To manage language with region (fr-CI, en-US, etc.) foreach($data as $key => $translation) { if (count($parts) == 1) { $this->translations[$language][$key] = $translation; } elseif (count($parts) == 2) { $this->translations[$parts[0]][$parts[1]][$key] = $translation; } else { throw new TranslationException('Invalid language'); } } }
php
private function add($data, $language) { $parts = explode('-', $language); // To manage language with region (fr-CI, en-US, etc.) foreach($data as $key => $translation) { if (count($parts) == 1) { $this->translations[$language][$key] = $translation; } elseif (count($parts) == 2) { $this->translations[$parts[0]][$parts[1]][$key] = $translation; } else { throw new TranslationException('Invalid language'); } } }
[ "private", "function", "add", "(", "$", "data", ",", "$", "language", ")", "{", "$", "parts", "=", "explode", "(", "'-'", ",", "$", "language", ")", ";", "// To manage language with region (fr-CI, en-US, etc.)", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "translation", ")", "{", "if", "(", "count", "(", "$", "parts", ")", "==", "1", ")", "{", "$", "this", "->", "translations", "[", "$", "language", "]", "[", "$", "key", "]", "=", "$", "translation", ";", "}", "elseif", "(", "count", "(", "$", "parts", ")", "==", "2", ")", "{", "$", "this", "->", "translations", "[", "$", "parts", "[", "0", "]", "]", "[", "$", "parts", "[", "1", "]", "]", "[", "$", "key", "]", "=", "$", "translation", ";", "}", "else", "{", "throw", "new", "TranslationException", "(", "'Invalid language'", ")", ";", "}", "}", "}" ]
Add translation data for a language @param array $data @param string $language @return void
[ "Add", "translation", "data", "for", "a", "language" ]
234ed703baf9e31268941c9d5f6d5e004cc53066
https://github.com/bandama-framework/bandama-framework/blob/234ed703baf9e31268941c9d5f6d5e004cc53066/src/foundation/translation/Translator.php#L110-L121
train
OxfordInfoLabs/kinikit-core
src/Template/TemplateParser.php
TemplateParser.getParserByKey
public static function getParserByKey($key) { switch (strtolower($key)) { case "twig": return new TwigTemplateParser(); default: if (isset(self::$customParsers[$key])) return self::$customParsers[$key]; else return new MustacheTemplateParser(); } }
php
public static function getParserByKey($key) { switch (strtolower($key)) { case "twig": return new TwigTemplateParser(); default: if (isset(self::$customParsers[$key])) return self::$customParsers[$key]; else return new MustacheTemplateParser(); } }
[ "public", "static", "function", "getParserByKey", "(", "$", "key", ")", "{", "switch", "(", "strtolower", "(", "$", "key", ")", ")", "{", "case", "\"twig\"", ":", "return", "new", "TwigTemplateParser", "(", ")", ";", "default", ":", "if", "(", "isset", "(", "self", "::", "$", "customParsers", "[", "$", "key", "]", ")", ")", "return", "self", "::", "$", "customParsers", "[", "$", "key", "]", ";", "else", "return", "new", "MustacheTemplateParser", "(", ")", ";", "}", "}" ]
Get a view parser by key.
[ "Get", "a", "view", "parser", "by", "key", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Template/TemplateParser.php#L41-L51
train
covex-nn/JooS
src/JooS/Config/Adapter/Transaction.php
Adapter_Transaction.start
public static function start() { if (is_null(self::$_transaction)) { $object = self::$_transaction = new self(); $object->_stored = Config::getDataAdapter(); Config::setDataAdapter($object); $result = true; } else { $result = false; } return $result; }
php
public static function start() { if (is_null(self::$_transaction)) { $object = self::$_transaction = new self(); $object->_stored = Config::getDataAdapter(); Config::setDataAdapter($object); $result = true; } else { $result = false; } return $result; }
[ "public", "static", "function", "start", "(", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "_transaction", ")", ")", "{", "$", "object", "=", "self", "::", "$", "_transaction", "=", "new", "self", "(", ")", ";", "$", "object", "->", "_stored", "=", "Config", "::", "getDataAdapter", "(", ")", ";", "Config", "::", "setDataAdapter", "(", "$", "object", ")", ";", "$", "result", "=", "true", ";", "}", "else", "{", "$", "result", "=", "false", ";", "}", "return", "$", "result", ";", "}" ]
Start transaction and save current config adapter @return boolean
[ "Start", "transaction", "and", "save", "current", "config", "adapter" ]
8dfb94edccecaf307787d4091ba7f20a674b7792
https://github.com/covex-nn/JooS/blob/8dfb94edccecaf307787d4091ba7f20a674b7792/src/JooS/Config/Adapter/Transaction.php#L98-L112
train
covex-nn/JooS
src/JooS/Config/Adapter/Transaction.php
Adapter_Transaction._stop
private static function _stop() { $adapter = self::$_transaction->_stored; if (is_null($adapter)) { Config::clearDataAdapter(); } else { Config::setDataAdapter($adapter); } }
php
private static function _stop() { $adapter = self::$_transaction->_stored; if (is_null($adapter)) { Config::clearDataAdapter(); } else { Config::setDataAdapter($adapter); } }
[ "private", "static", "function", "_stop", "(", ")", "{", "$", "adapter", "=", "self", "::", "$", "_transaction", "->", "_stored", ";", "if", "(", "is_null", "(", "$", "adapter", ")", ")", "{", "Config", "::", "clearDataAdapter", "(", ")", ";", "}", "else", "{", "Config", "::", "setDataAdapter", "(", "$", "adapter", ")", ";", "}", "}" ]
Restore old data adapter @return null
[ "Restore", "old", "data", "adapter" ]
8dfb94edccecaf307787d4091ba7f20a674b7792
https://github.com/covex-nn/JooS/blob/8dfb94edccecaf307787d4091ba7f20a674b7792/src/JooS/Config/Adapter/Transaction.php#L181-L190
train
gplcart/cli
controllers/commands/Config.php
Config.cmdGetConfig
public function cmdGetConfig() { $result = $this->getListConfig(); $this->outputFormat($result); $this->outputFormatTableConfig($result); $this->output(); }
php
public function cmdGetConfig() { $result = $this->getListConfig(); $this->outputFormat($result); $this->outputFormatTableConfig($result); $this->output(); }
[ "public", "function", "cmdGetConfig", "(", ")", "{", "$", "result", "=", "$", "this", "->", "getListConfig", "(", ")", ";", "$", "this", "->", "outputFormat", "(", "$", "result", ")", ";", "$", "this", "->", "outputFormatTableConfig", "(", "$", "result", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "config-get" command
[ "Callback", "for", "config", "-", "get", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Config.php#L22-L28
train
gplcart/cli
controllers/commands/Config.php
Config.getListConfig
protected function getListConfig() { $name = $this->getParam(0); if (isset($name)) { $result = $this->config->get($name); if (!isset($result)) { $this->errorAndExit($this->text('Invalid argument')); } $list = array($name => $result); } else { $list = $this->config->get(); $this->limitArray($list); } $saved = $this->config->select(); $reindexed = array(); foreach ($list as $key => $value) { $reindexed[] = array( 'key' => $key, 'value' => $value, 'in_database' => isset($saved[$key]) ); } return $reindexed; }
php
protected function getListConfig() { $name = $this->getParam(0); if (isset($name)) { $result = $this->config->get($name); if (!isset($result)) { $this->errorAndExit($this->text('Invalid argument')); } $list = array($name => $result); } else { $list = $this->config->get(); $this->limitArray($list); } $saved = $this->config->select(); $reindexed = array(); foreach ($list as $key => $value) { $reindexed[] = array( 'key' => $key, 'value' => $value, 'in_database' => isset($saved[$key]) ); } return $reindexed; }
[ "protected", "function", "getListConfig", "(", ")", "{", "$", "name", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "if", "(", "isset", "(", "$", "name", ")", ")", "{", "$", "result", "=", "$", "this", "->", "config", "->", "get", "(", "$", "name", ")", ";", "if", "(", "!", "isset", "(", "$", "result", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "list", "=", "array", "(", "$", "name", "=>", "$", "result", ")", ";", "}", "else", "{", "$", "list", "=", "$", "this", "->", "config", "->", "get", "(", ")", ";", "$", "this", "->", "limitArray", "(", "$", "list", ")", ";", "}", "$", "saved", "=", "$", "this", "->", "config", "->", "select", "(", ")", ";", "$", "reindexed", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "reindexed", "[", "]", "=", "array", "(", "'key'", "=>", "$", "key", ",", "'value'", "=>", "$", "value", ",", "'in_database'", "=>", "isset", "(", "$", "saved", "[", "$", "key", "]", ")", ")", ";", "}", "return", "$", "reindexed", ";", "}" ]
Returns an array of configurations @return array
[ "Returns", "an", "array", "of", "configurations" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Config.php#L34-L61
train
gplcart/cli
controllers/commands/Config.php
Config.cmdDeleteConfig
public function cmdDeleteConfig() { $id = $this->getParam(0); if (!isset($id)) { $this->errorAndExit($this->text('Invalid argument')); } if (!$this->config->reset($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
php
public function cmdDeleteConfig() { $id = $this->getParam(0); if (!isset($id)) { $this->errorAndExit($this->text('Invalid argument')); } if (!$this->config->reset($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
[ "public", "function", "cmdDeleteConfig", "(", ")", "{", "$", "id", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "if", "(", "!", "isset", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "config", "->", "reset", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "config-delete" command
[ "Callback", "for", "config", "-", "delete", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Config.php#L66-L79
train
gplcart/cli
controllers/commands/Config.php
Config.cmdSetConfig
public function cmdSetConfig() { $key = $this->getParam(0); $value = $this->getParam(1); if (!isset($key) || !isset($value)) { $this->errorAndExit($this->text('Invalid command')); } if (!$this->config->set($key, $value)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
php
public function cmdSetConfig() { $key = $this->getParam(0); $value = $this->getParam(1); if (!isset($key) || !isset($value)) { $this->errorAndExit($this->text('Invalid command')); } if (!$this->config->set($key, $value)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
[ "public", "function", "cmdSetConfig", "(", ")", "{", "$", "key", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "$", "value", "=", "$", "this", "->", "getParam", "(", "1", ")", ";", "if", "(", "!", "isset", "(", "$", "key", ")", "||", "!", "isset", "(", "$", "value", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "config", "->", "set", "(", "$", "key", ",", "$", "value", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "config-set" command
[ "Callback", "for", "config", "-", "set", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Config.php#L84-L98
train
libreworks/caridea-dao
src/MongoDb.php
MongoDb.doExecute
protected function doExecute(\Closure $cb) { try { return $cb($this->manager, $this->collection); } catch (\Exception $e) { throw Exception\Translator\MongoDb::translate($e); } }
php
protected function doExecute(\Closure $cb) { try { return $cb($this->manager, $this->collection); } catch (\Exception $e) { throw Exception\Translator\MongoDb::translate($e); } }
[ "protected", "function", "doExecute", "(", "\\", "Closure", "$", "cb", ")", "{", "try", "{", "return", "$", "cb", "(", "$", "this", "->", "manager", ",", "$", "this", "->", "collection", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "Exception", "\\", "Translator", "\\", "MongoDb", "::", "translate", "(", "$", "e", ")", ";", "}", "}" ]
Executes something in the context of the collection. Exceptions are caught and translated. @param callable $cb The closure to execute, takes the entityManager and collection @return mixed Whatever the function returns, this method also returns @throws \Caridea\Dao\Exception If a database problem occurs @see \Caridea\Dao\Exception\Translator\MongoDb
[ "Executes", "something", "in", "the", "context", "of", "the", "collection", "." ]
22c2fc81f63050ad23f7b0c40e430ff026e1e767
https://github.com/libreworks/caridea-dao/blob/22c2fc81f63050ad23f7b0c40e430ff026e1e767/src/MongoDb.php#L69-L76
train
RetItaliaSpA/AuthenticationBundle
Entity/FunzioniUtente.php
FunzioniUtente.insertLog
public function insertLog($idObject="",$objJson="",$idFunzione="",$dettagli=""){ //Creo una nuova istanza di log $intranetLogApp = new IntranetLogApp(); $intranetLogApp->setDettagli($dettagli); if (!empty($idFunzione)) { $repository = $this->em->getRepository('retItaliaAuthenticationBundle:SaFunzione'); $saFunzione=$repository->find($idFunzione); if (!empty($saFunzione)) { $intranetLogApp->setIdFunzione($saFunzione); } } $intranetLogApp->setIdObject($idObject); $intranetLogApp->setObjJson($objJson); if (!empty($this->application_id)) { $repository = $this->em->getRepository('retItaliaAuthenticationBundle:SaApplicazione'); $saApplicazione=$repository->find($this->application_id); if (!empty($saApplicazione)) { $intranetLogApp->setIdApplicazione($saApplicazione); } } $intranetLogApp->setIdUtente($this->tokenStorage->getToken()->getUser()); $intranetLogApp->setDataLog(new \DateTime()); //Persisto l'oggetto $this->em->persist($intranetLogApp); //Flush di tutto $this->em->flush(); }
php
public function insertLog($idObject="",$objJson="",$idFunzione="",$dettagli=""){ //Creo una nuova istanza di log $intranetLogApp = new IntranetLogApp(); $intranetLogApp->setDettagli($dettagli); if (!empty($idFunzione)) { $repository = $this->em->getRepository('retItaliaAuthenticationBundle:SaFunzione'); $saFunzione=$repository->find($idFunzione); if (!empty($saFunzione)) { $intranetLogApp->setIdFunzione($saFunzione); } } $intranetLogApp->setIdObject($idObject); $intranetLogApp->setObjJson($objJson); if (!empty($this->application_id)) { $repository = $this->em->getRepository('retItaliaAuthenticationBundle:SaApplicazione'); $saApplicazione=$repository->find($this->application_id); if (!empty($saApplicazione)) { $intranetLogApp->setIdApplicazione($saApplicazione); } } $intranetLogApp->setIdUtente($this->tokenStorage->getToken()->getUser()); $intranetLogApp->setDataLog(new \DateTime()); //Persisto l'oggetto $this->em->persist($intranetLogApp); //Flush di tutto $this->em->flush(); }
[ "public", "function", "insertLog", "(", "$", "idObject", "=", "\"\"", ",", "$", "objJson", "=", "\"\"", ",", "$", "idFunzione", "=", "\"\"", ",", "$", "dettagli", "=", "\"\"", ")", "{", "//Creo una nuova istanza di log", "$", "intranetLogApp", "=", "new", "IntranetLogApp", "(", ")", ";", "$", "intranetLogApp", "->", "setDettagli", "(", "$", "dettagli", ")", ";", "if", "(", "!", "empty", "(", "$", "idFunzione", ")", ")", "{", "$", "repository", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'retItaliaAuthenticationBundle:SaFunzione'", ")", ";", "$", "saFunzione", "=", "$", "repository", "->", "find", "(", "$", "idFunzione", ")", ";", "if", "(", "!", "empty", "(", "$", "saFunzione", ")", ")", "{", "$", "intranetLogApp", "->", "setIdFunzione", "(", "$", "saFunzione", ")", ";", "}", "}", "$", "intranetLogApp", "->", "setIdObject", "(", "$", "idObject", ")", ";", "$", "intranetLogApp", "->", "setObjJson", "(", "$", "objJson", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "application_id", ")", ")", "{", "$", "repository", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'retItaliaAuthenticationBundle:SaApplicazione'", ")", ";", "$", "saApplicazione", "=", "$", "repository", "->", "find", "(", "$", "this", "->", "application_id", ")", ";", "if", "(", "!", "empty", "(", "$", "saApplicazione", ")", ")", "{", "$", "intranetLogApp", "->", "setIdApplicazione", "(", "$", "saApplicazione", ")", ";", "}", "}", "$", "intranetLogApp", "->", "setIdUtente", "(", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ")", ";", "$", "intranetLogApp", "->", "setDataLog", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "//Persisto l'oggetto", "$", "this", "->", "em", "->", "persist", "(", "$", "intranetLogApp", ")", ";", "//Flush di tutto", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}" ]
Questa funzione inserisce una nuova occorrenza nel file di log @param string $idObject @param string $objJson @param string $idFunzione @param string $dettagli @throws \Exception
[ "Questa", "funzione", "inserisce", "una", "nuova", "occorrenza", "nel", "file", "di", "log" ]
4c2b28d0d290a68ade9215f872c417749deea2cd
https://github.com/RetItaliaSpA/AuthenticationBundle/blob/4c2b28d0d290a68ade9215f872c417749deea2cd/Entity/FunzioniUtente.php#L163-L194
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Category.php
Category.initC2Ms
public function initC2Ms($overrideExisting = true) { if (null !== $this->collC2Ms && !$overrideExisting) { return; } $collectionClassName = C2MTableMap::getTableMap()->getCollectionClassName(); $this->collC2Ms = new $collectionClassName; $this->collC2Ms->setModel('\Attogram\SharedMedia\Orm\C2M'); }
php
public function initC2Ms($overrideExisting = true) { if (null !== $this->collC2Ms && !$overrideExisting) { return; } $collectionClassName = C2MTableMap::getTableMap()->getCollectionClassName(); $this->collC2Ms = new $collectionClassName; $this->collC2Ms->setModel('\Attogram\SharedMedia\Orm\C2M'); }
[ "public", "function", "initC2Ms", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collC2Ms", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "collectionClassName", "=", "C2MTableMap", "::", "getTableMap", "(", ")", "->", "getCollectionClassName", "(", ")", ";", "$", "this", "->", "collC2Ms", "=", "new", "$", "collectionClassName", ";", "$", "this", "->", "collC2Ms", "->", "setModel", "(", "'\\Attogram\\SharedMedia\\Orm\\C2M'", ")", ";", "}" ]
Initializes the collC2Ms collection. By default this just sets the collC2Ms collection to an empty array (like clearcollC2Ms()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collC2Ms", "collection", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2093-L2103
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Category.php
Category.countC2Ms
public function countC2Ms(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collC2MsPartial && !$this->isNew(); if (null === $this->collC2Ms || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collC2Ms) { return 0; } if ($partial && !$criteria) { return count($this->getC2Ms()); } $query = ChildC2MQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByCategory($this) ->count($con); } return count($this->collC2Ms); }
php
public function countC2Ms(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collC2MsPartial && !$this->isNew(); if (null === $this->collC2Ms || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collC2Ms) { return 0; } if ($partial && !$criteria) { return count($this->getC2Ms()); } $query = ChildC2MQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByCategory($this) ->count($con); } return count($this->collC2Ms); }
[ "public", "function", "countC2Ms", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collC2MsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collC2Ms", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collC2Ms", ")", "{", "return", "0", ";", "}", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getC2Ms", "(", ")", ")", ";", "}", "$", "query", "=", "ChildC2MQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByCategory", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "return", "count", "(", "$", "this", "->", "collC2Ms", ")", ";", "}" ]
Returns the number of related C2M objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related C2M objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "C2M", "objects", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2208-L2231
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Category.php
Category.addC2M
public function addC2M(ChildC2M $l) { if ($this->collC2Ms === null) { $this->initC2Ms(); $this->collC2MsPartial = true; } if (!$this->collC2Ms->contains($l)) { $this->doAddC2M($l); if ($this->c2MsScheduledForDeletion and $this->c2MsScheduledForDeletion->contains($l)) { $this->c2MsScheduledForDeletion->remove($this->c2MsScheduledForDeletion->search($l)); } } return $this; }
php
public function addC2M(ChildC2M $l) { if ($this->collC2Ms === null) { $this->initC2Ms(); $this->collC2MsPartial = true; } if (!$this->collC2Ms->contains($l)) { $this->doAddC2M($l); if ($this->c2MsScheduledForDeletion and $this->c2MsScheduledForDeletion->contains($l)) { $this->c2MsScheduledForDeletion->remove($this->c2MsScheduledForDeletion->search($l)); } } return $this; }
[ "public", "function", "addC2M", "(", "ChildC2M", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collC2Ms", "===", "null", ")", "{", "$", "this", "->", "initC2Ms", "(", ")", ";", "$", "this", "->", "collC2MsPartial", "=", "true", ";", "}", "if", "(", "!", "$", "this", "->", "collC2Ms", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "doAddC2M", "(", "$", "l", ")", ";", "if", "(", "$", "this", "->", "c2MsScheduledForDeletion", "and", "$", "this", "->", "c2MsScheduledForDeletion", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "c2MsScheduledForDeletion", "->", "remove", "(", "$", "this", "->", "c2MsScheduledForDeletion", "->", "search", "(", "$", "l", ")", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Method called to associate a ChildC2M object to this object through the ChildC2M foreign key attribute. @param ChildC2M $l ChildC2M @return $this|\Attogram\SharedMedia\Orm\Category The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildC2M", "object", "to", "this", "object", "through", "the", "ChildC2M", "foreign", "key", "attribute", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2240-L2256
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Category.php
Category.getC2MsJoinMedia
public function getC2MsJoinMedia(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildC2MQuery::create(null, $criteria); $query->joinWith('Media', $joinBehavior); return $this->getC2Ms($query, $con); }
php
public function getC2MsJoinMedia(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildC2MQuery::create(null, $criteria); $query->joinWith('Media', $joinBehavior); return $this->getC2Ms($query, $con); }
[ "public", "function", "getC2MsJoinMedia", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildC2MQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "$", "query", "->", "joinWith", "(", "'Media'", ",", "$", "joinBehavior", ")", ";", "return", "$", "this", "->", "getC2Ms", "(", "$", "query", ",", "$", "con", ")", ";", "}" ]
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this Category is new, it will return an empty collection; or if this Category has previously been saved, it will retrieve related C2Ms from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in Category. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildC2M[] List of ChildC2M objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "Category", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", "or", "if", "this", "Category", "has", "previously", "been", "saved", "it", "will", "retrieve", "related", "C2Ms", "from", "storage", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2304-L2310
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Category.php
Category.countC2Ps
public function countC2Ps(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collC2PsPartial && !$this->isNew(); if (null === $this->collC2Ps || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collC2Ps) { return 0; } if ($partial && !$criteria) { return count($this->getC2Ps()); } $query = ChildC2PQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByCategory($this) ->count($con); } return count($this->collC2Ps); }
php
public function countC2Ps(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collC2PsPartial && !$this->isNew(); if (null === $this->collC2Ps || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collC2Ps) { return 0; } if ($partial && !$criteria) { return count($this->getC2Ps()); } $query = ChildC2PQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByCategory($this) ->count($con); } return count($this->collC2Ps); }
[ "public", "function", "countC2Ps", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collC2PsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collC2Ps", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collC2Ps", ")", "{", "return", "0", ";", "}", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getC2Ps", "(", ")", ")", ";", "}", "$", "query", "=", "ChildC2PQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByCategory", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "return", "count", "(", "$", "this", "->", "collC2Ps", ")", ";", "}" ]
Returns the number of related C2P objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related C2P objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "C2P", "objects", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2461-L2484
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Category.php
Category.getC2PsJoinPage
public function getC2PsJoinPage(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildC2PQuery::create(null, $criteria); $query->joinWith('Page', $joinBehavior); return $this->getC2Ps($query, $con); }
php
public function getC2PsJoinPage(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildC2PQuery::create(null, $criteria); $query->joinWith('Page', $joinBehavior); return $this->getC2Ps($query, $con); }
[ "public", "function", "getC2PsJoinPage", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildC2PQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "$", "query", "->", "joinWith", "(", "'Page'", ",", "$", "joinBehavior", ")", ";", "return", "$", "this", "->", "getC2Ps", "(", "$", "query", ",", "$", "con", ")", ";", "}" ]
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this Category is new, it will return an empty collection; or if this Category has previously been saved, it will retrieve related C2Ps from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in Category. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildC2P[] List of ChildC2P objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "Category", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", "or", "if", "this", "Category", "has", "previously", "been", "saved", "it", "will", "retrieve", "related", "C2Ps", "from", "storage", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2557-L2563
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Category.php
Category.makeRoot
public function makeRoot() { if ($this->getLeftValue() || $this->getRightValue()) { throw new PropelException('Cannot turn an existing node into a root node.'); } $this->setLeftValue(1); $this->setRightValue(2); $this->setLevel(0); return $this; }
php
public function makeRoot() { if ($this->getLeftValue() || $this->getRightValue()) { throw new PropelException('Cannot turn an existing node into a root node.'); } $this->setLeftValue(1); $this->setRightValue(2); $this->setLevel(0); return $this; }
[ "public", "function", "makeRoot", "(", ")", "{", "if", "(", "$", "this", "->", "getLeftValue", "(", ")", "||", "$", "this", "->", "getRightValue", "(", ")", ")", "{", "throw", "new", "PropelException", "(", "'Cannot turn an existing node into a root node.'", ")", ";", "}", "$", "this", "->", "setLeftValue", "(", "1", ")", ";", "$", "this", "->", "setRightValue", "(", "2", ")", ";", "$", "this", "->", "setLevel", "(", "0", ")", ";", "return", "$", "this", ";", "}" ]
Creates the supplied node as the root node. @return $this|ChildCategory The current object (for fluent API support) @throws PropelException
[ "Creates", "the", "supplied", "node", "as", "the", "root", "node", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2742-L2753
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Category.php
Category.isDescendantOf
public function isDescendantOf(ChildCategory $parent) { return $this->isInTree() && $this->getLeftValue() > $parent->getLeftValue() && $this->getRightValue() < $parent->getRightValue(); }
php
public function isDescendantOf(ChildCategory $parent) { return $this->isInTree() && $this->getLeftValue() > $parent->getLeftValue() && $this->getRightValue() < $parent->getRightValue(); }
[ "public", "function", "isDescendantOf", "(", "ChildCategory", "$", "parent", ")", "{", "return", "$", "this", "->", "isInTree", "(", ")", "&&", "$", "this", "->", "getLeftValue", "(", ")", ">", "$", "parent", "->", "getLeftValue", "(", ")", "&&", "$", "this", "->", "getRightValue", "(", ")", "<", "$", "parent", "->", "getRightValue", "(", ")", ";", "}" ]
Tests if node is a descendant of another node @param ChildCategory $parent Propel node object @return bool
[ "Tests", "if", "node", "is", "a", "descendant", "of", "another", "node" ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2791-L2794
train