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
lsv/rejseplan-php-api
src/Services/AbstractServiceCall.php
AbstractServiceCall.validateJson
protected function validateJson(ResponseInterface $response): array { try { return \GuzzleHttp\json_decode((string) $response->getBody(), true); } catch (\Exception $e) { return []; } }
php
protected function validateJson(ResponseInterface $response): array { try { return \GuzzleHttp\json_decode((string) $response->getBody(), true); } catch (\Exception $e) { return []; } }
[ "protected", "function", "validateJson", "(", "ResponseInterface", "$", "response", ")", ":", "array", "{", "try", "{", "return", "\\", "GuzzleHttp", "\\", "json_decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ",", "true", ")"...
Validate json. @param ResponseInterface $response @return array
[ "Validate", "json", "." ]
f09add92e160f167a19ff2a290951d202d7ece67
https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/Services/AbstractServiceCall.php#L80-L87
train
webeweb/core-bundle
Manager/AbstractThemeManager.php
AbstractThemeManager.addGlobal
public function addGlobal() { foreach ($this->getIndex() as $k => $v) { if (null === $v) { continue; } $this->getTwigEnvironment()->addGlobal(str_replace("Interface", "", $k), $this->getProviders()[$v]); } }
php
public function addGlobal() { foreach ($this->getIndex() as $k => $v) { if (null === $v) { continue; } $this->getTwigEnvironment()->addGlobal(str_replace("Interface", "", $k), $this->getProviders()[$v]); } }
[ "public", "function", "addGlobal", "(", ")", "{", "foreach", "(", "$", "this", "->", "getIndex", "(", ")", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "null", "===", "$", "v", ")", "{", "continue", ";", "}", "$", "this", "->", "getTwig...
Add the global. @return void
[ "Add", "the", "global", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Manager/AbstractThemeManager.php#L54-L61
train
webeweb/core-bundle
Manager/AbstractThemeManager.php
AbstractThemeManager.setProvider
protected function setProvider($name, ThemeProviderInterface $provider) { $k = ObjectHelper::getShortName($name); $v = $this->getIndex()[$k]; if (null !== $v) { $this->getProviders()[$v] = $provider; return $this; } $this->index[$k] = count($this->getProviders()); return $this->addProvider($provider); }
php
protected function setProvider($name, ThemeProviderInterface $provider) { $k = ObjectHelper::getShortName($name); $v = $this->getIndex()[$k]; if (null !== $v) { $this->getProviders()[$v] = $provider; return $this; } $this->index[$k] = count($this->getProviders()); return $this->addProvider($provider); }
[ "protected", "function", "setProvider", "(", "$", "name", ",", "ThemeProviderInterface", "$", "provider", ")", "{", "$", "k", "=", "ObjectHelper", "::", "getShortName", "(", "$", "name", ")", ";", "$", "v", "=", "$", "this", "->", "getIndex", "(", ")", ...
Set a provider. @param mixed $name The name. @param ThemeProviderInterface $provider The provider. @return ManagerInterface Returns this manager. @throws ReflectionException Throws a reflection exception if an error occurs.
[ "Set", "a", "provider", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Manager/AbstractThemeManager.php#L114-L123
train
dadajuice/zephyrus
src/Zephyrus/Utilities/Uploaders/UploadFile.php
UploadFile.getRealMimeType
private function getRealMimeType() { $info = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($info, $this->temporaryFilename); finfo_close($info); return $mime; }
php
private function getRealMimeType() { $info = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($info, $this->temporaryFilename); finfo_close($info); return $mime; }
[ "private", "function", "getRealMimeType", "(", ")", "{", "$", "info", "=", "finfo_open", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "mime", "=", "finfo_file", "(", "$", "info", ",", "$", "this", "->", "temporaryFilename", ")", ";", "finfo_close", "(", "$", ...
Obtain the concrete mime type of uploaded file based signature. This mime type should be used for security check instead of the one provided in the HTTP request which could be spoofed. @return string
[ "Obtain", "the", "concrete", "mime", "type", "of", "uploaded", "file", "based", "signature", ".", "This", "mime", "type", "should", "be", "used", "for", "security", "check", "instead", "of", "the", "one", "provided", "in", "the", "HTTP", "request", "which", ...
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Utilities/Uploaders/UploadFile.php#L145-L151
train
lsv/rejseplan-php-api
src/Services/Trip.php
Trip.setWalkingDistance
public function setWalkingDistance(int $originDistance = 2000, int $destinationDistance = 2000): self { $this->options['maxWalkingDistanceDep'] = $originDistance; $this->options['maxWalkingDistanceDest'] = $destinationDistance; return $this; }
php
public function setWalkingDistance(int $originDistance = 2000, int $destinationDistance = 2000): self { $this->options['maxWalkingDistanceDep'] = $originDistance; $this->options['maxWalkingDistanceDest'] = $destinationDistance; return $this; }
[ "public", "function", "setWalkingDistance", "(", "int", "$", "originDistance", "=", "2000", ",", "int", "$", "destinationDistance", "=", "2000", ")", ":", "self", "{", "$", "this", "->", "options", "[", "'maxWalkingDistanceDep'", "]", "=", "$", "originDistance...
Set walking distances in meters. @param int $originDistance Walking distance at origin, in meters, min 500, max 20.000 @param int $destinationDistance Walking distance at destination, in meters, min 500, max 20.000 @return $this
[ "Set", "walking", "distances", "in", "meters", "." ]
f09add92e160f167a19ff2a290951d202d7ece67
https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/Services/Trip.php#L118-L124
train
lsv/rejseplan-php-api
src/Services/Trip.php
Trip.getUrl
protected function getUrl(array $options): string { $urlOptions = []; $this->setOriginAndDestinationOption($urlOptions, $options); $this->setViaOption($urlOptions, $options); $this->setDateOption($urlOptions, $options); $urlOptions = array_merge($urlOptions, $options); return sprintf('trip?%s&format=json', http_build_query($urlOptions)); }
php
protected function getUrl(array $options): string { $urlOptions = []; $this->setOriginAndDestinationOption($urlOptions, $options); $this->setViaOption($urlOptions, $options); $this->setDateOption($urlOptions, $options); $urlOptions = array_merge($urlOptions, $options); return sprintf('trip?%s&format=json', http_build_query($urlOptions)); }
[ "protected", "function", "getUrl", "(", "array", "$", "options", ")", ":", "string", "{", "$", "urlOptions", "=", "[", "]", ";", "$", "this", "->", "setOriginAndDestinationOption", "(", "$", "urlOptions", ",", "$", "options", ")", ";", "$", "this", "->",...
Create the URL. @param array $options @return string
[ "Create", "the", "URL", "." ]
f09add92e160f167a19ff2a290951d202d7ece67
https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/Services/Trip.php#L188-L198
train
dadajuice/zephyrus
src/Zephyrus/Application/Callback.php
Callback.executeMethod
private function executeMethod(array $arguments) { if ($this->reflection->isStatic()) { return $this->reflection->invokeArgs(null, $arguments); } elseif (is_object($this->callback[0])) { return $this->reflection->invokeArgs($this->callback[0], $arguments); } $instance = new $this->callback[0](); return $this->reflection->invokeArgs($instance, $arguments); }
php
private function executeMethod(array $arguments) { if ($this->reflection->isStatic()) { return $this->reflection->invokeArgs(null, $arguments); } elseif (is_object($this->callback[0])) { return $this->reflection->invokeArgs($this->callback[0], $arguments); } $instance = new $this->callback[0](); return $this->reflection->invokeArgs($instance, $arguments); }
[ "private", "function", "executeMethod", "(", "array", "$", "arguments", ")", "{", "if", "(", "$", "this", "->", "reflection", "->", "isStatic", "(", ")", ")", "{", "return", "$", "this", "->", "reflection", "->", "invokeArgs", "(", "null", ",", "$", "a...
Execute the specified callback object method. Works with static calls or instance method. @param array $arguments @return mixed
[ "Execute", "the", "specified", "callback", "object", "method", ".", "Works", "with", "static", "calls", "or", "instance", "method", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Callback.php#L69-L78
train
laravelflare/flare
src/Flare/Admin/AdminManager.php
AdminManager.getAdminClasses
public function getAdminClasses() { $classCollection = []; if (!defined('static::ADMIN_KEY')) { return $classCollection; } $classCollection = $this->getSubAdminClasses(\Flare::config(static::ADMIN_KEY)); return $classCollection; }
php
public function getAdminClasses() { $classCollection = []; if (!defined('static::ADMIN_KEY')) { return $classCollection; } $classCollection = $this->getSubAdminClasses(\Flare::config(static::ADMIN_KEY)); return $classCollection; }
[ "public", "function", "getAdminClasses", "(", ")", "{", "$", "classCollection", "=", "[", "]", ";", "if", "(", "!", "defined", "(", "'static::ADMIN_KEY'", ")", ")", "{", "return", "$", "classCollection", ";", "}", "$", "classCollection", "=", "$", "this", ...
Gets Admin classes based on the current users permissions which have been set. If a Admin class has not had the Permissions provided, it will be displayed by default. @return
[ "Gets", "Admin", "classes", "based", "on", "the", "current", "users", "permissions", "which", "have", "been", "set", ".", "If", "a", "Admin", "class", "has", "not", "had", "the", "Permissions", "provided", "it", "will", "be", "displayed", "by", "default", ...
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/AdminManager.php#L54-L65
train
laravelflare/flare
src/Flare/Admin/AdminManager.php
AdminManager.registerSubRoutes
public function registerSubRoutes(array $classes) { foreach ($classes as $key => $class) { if (is_array($class)) { if ($this->usableClass($key)) { $this->registerAdminRoutes($key); } $this->registerSubRoutes($class); continue; } $this->registerAdminRoutes($class); } }
php
public function registerSubRoutes(array $classes) { foreach ($classes as $key => $class) { if (is_array($class)) { if ($this->usableClass($key)) { $this->registerAdminRoutes($key); } $this->registerSubRoutes($class); continue; } $this->registerAdminRoutes($class); } }
[ "public", "function", "registerSubRoutes", "(", "array", "$", "classes", ")", "{", "foreach", "(", "$", "classes", "as", "$", "key", "=>", "$", "class", ")", "{", "if", "(", "is_array", "(", "$", "class", ")", ")", "{", "if", "(", "$", "this", "->"...
Loops through an array of classes and registers their Route recursively. @param array $classes
[ "Loops", "through", "an", "array", "of", "classes", "and", "registers", "their", "Route", "recursively", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/AdminManager.php#L126-L139
train
dadajuice/zephyrus
src/Zephyrus/Security/Cryptography.php
Cryptography.randomHex
public static function randomHex(int $length = 128): string { $bytes = ceil($length / 2); $hex = bin2hex(self::randomBytes($bytes)); return $hex; }
php
public static function randomHex(int $length = 128): string { $bytes = ceil($length / 2); $hex = bin2hex(self::randomBytes($bytes)); return $hex; }
[ "public", "static", "function", "randomHex", "(", "int", "$", "length", "=", "128", ")", ":", "string", "{", "$", "bytes", "=", "ceil", "(", "$", "length", "/", "2", ")", ";", "$", "hex", "=", "bin2hex", "(", "self", "::", "randomBytes", "(", "$", ...
Returns a random hex of desired length. @param int $length @throws \Exception @return string
[ "Returns", "a", "random", "hex", "of", "desired", "length", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/Cryptography.php#L58-L63
train
dadajuice/zephyrus
src/Zephyrus/Security/Cryptography.php
Cryptography.randomInt
public static function randomInt(int $min, int $max): int { if ($max <= $min) { throw new \Exception('Minimum equal or greater than maximum!'); } if ($max < 0 || $min < 0) { throw new \Exception('Only positive integers supported for now!'); } $difference = $max - $min; for ($power = 8; pow(2, $power) < $difference; $power = $power * 2) { } $powerExp = $power / 8; do { $randDiff = hexdec(bin2hex(self::randomBytes($powerExp))); } while ($randDiff > $difference); return $min + $randDiff; }
php
public static function randomInt(int $min, int $max): int { if ($max <= $min) { throw new \Exception('Minimum equal or greater than maximum!'); } if ($max < 0 || $min < 0) { throw new \Exception('Only positive integers supported for now!'); } $difference = $max - $min; for ($power = 8; pow(2, $power) < $difference; $power = $power * 2) { } $powerExp = $power / 8; do { $randDiff = hexdec(bin2hex(self::randomBytes($powerExp))); } while ($randDiff > $difference); return $min + $randDiff; }
[ "public", "static", "function", "randomInt", "(", "int", "$", "min", ",", "int", "$", "max", ")", ":", "int", "{", "if", "(", "$", "max", "<=", "$", "min", ")", "{", "throw", "new", "\\", "Exception", "(", "'Minimum equal or greater than maximum!'", ")",...
Returns a random integer between the provided min and max using random bytes. Throws exception if min and max arguments have inconsistencies. @param int $min @param int $max @throws \Exception @return int
[ "Returns", "a", "random", "integer", "between", "the", "provided", "min", "and", "max", "using", "random", "bytes", ".", "Throws", "exception", "if", "min", "and", "max", "arguments", "have", "inconsistencies", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/Cryptography.php#L74-L91
train
dadajuice/zephyrus
src/Zephyrus/Security/Cryptography.php
Cryptography.encrypt
public static function encrypt(string $data, string $key): string { $method = Configuration::getSecurityConfiguration('encryption_algorithm'); $initializationVector = self::randomBytes(openssl_cipher_iv_length($method)); $cipher = openssl_encrypt($data, $method, $key, 0, $initializationVector); return base64_encode($initializationVector) . ':' . base64_encode($cipher); }
php
public static function encrypt(string $data, string $key): string { $method = Configuration::getSecurityConfiguration('encryption_algorithm'); $initializationVector = self::randomBytes(openssl_cipher_iv_length($method)); $cipher = openssl_encrypt($data, $method, $key, 0, $initializationVector); return base64_encode($initializationVector) . ':' . base64_encode($cipher); }
[ "public", "static", "function", "encrypt", "(", "string", "$", "data", ",", "string", "$", "key", ")", ":", "string", "{", "$", "method", "=", "Configuration", "::", "getSecurityConfiguration", "(", "'encryption_algorithm'", ")", ";", "$", "initializationVector"...
Encrypts the given data using the configured encryption algorithm and the provided key. Returns a concatenation of the generated IV and the cipher. Resulting cipher should only be decrypted using the decrypt method. @param string $data @param string $key @return string
[ "Encrypts", "the", "given", "data", "using", "the", "configured", "encryption", "algorithm", "and", "the", "provided", "key", ".", "Returns", "a", "concatenation", "of", "the", "generated", "IV", "and", "the", "cipher", ".", "Resulting", "cipher", "should", "o...
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/Cryptography.php#L142-L148
train
phptuts/StarterBundleForSymfony
src/Service/JWSTokenService.php
JWSTokenService.createAuthTokenModel
public function createAuthTokenModel(BaseUser $user) { $privateKey = openssl_pkey_get_private( file_get_contents($this->projectDir . '/var/jwt/private.pem'), $this->passPhrase ); $jws = new SimpleJWS([ 'alg' => self::ALG ]); $expirationDate = new \DateTime(); $expirationDate->modify('+' . $this->authTokenTTL . ' seconds'); $expirationTimestamp = $expirationDate->getTimestamp(); $jws->setPayload(array_merge([ self::USER_ID_KEY => $user->getId(), self::EXP_KEY => $expirationTimestamp, self::IAT_KEY => (new \DateTime())->getTimestamp() ], $user->getJWTPayload())); $jws->sign($privateKey); return new AuthTokenModel($jws->getTokenString(), $expirationTimestamp); }
php
public function createAuthTokenModel(BaseUser $user) { $privateKey = openssl_pkey_get_private( file_get_contents($this->projectDir . '/var/jwt/private.pem'), $this->passPhrase ); $jws = new SimpleJWS([ 'alg' => self::ALG ]); $expirationDate = new \DateTime(); $expirationDate->modify('+' . $this->authTokenTTL . ' seconds'); $expirationTimestamp = $expirationDate->getTimestamp(); $jws->setPayload(array_merge([ self::USER_ID_KEY => $user->getId(), self::EXP_KEY => $expirationTimestamp, self::IAT_KEY => (new \DateTime())->getTimestamp() ], $user->getJWTPayload())); $jws->sign($privateKey); return new AuthTokenModel($jws->getTokenString(), $expirationTimestamp); }
[ "public", "function", "createAuthTokenModel", "(", "BaseUser", "$", "user", ")", "{", "$", "privateKey", "=", "openssl_pkey_get_private", "(", "file_get_contents", "(", "$", "this", "->", "projectDir", ".", "'/var/jwt/private.pem'", ")", ",", "$", "this", "->", ...
Creates a jws token model @param BaseUser $user @return AuthTokenModel
[ "Creates", "a", "jws", "token", "model" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/JWSTokenService.php#L79-L103
train
phptuts/StarterBundleForSymfony
src/Service/JWSTokenService.php
JWSTokenService.isValid
public function isValid($token) { try { $publicKey = openssl_pkey_get_public(file_get_contents($this->projectDir . '/var/jwt/public.pem')); $jws = SimpleJWS::load($token); return $jws->verify($publicKey, self::ALG) && $this->isTokenNotExpired($token); } catch (\InvalidArgumentException $ex) { return false; } }
php
public function isValid($token) { try { $publicKey = openssl_pkey_get_public(file_get_contents($this->projectDir . '/var/jwt/public.pem')); $jws = SimpleJWS::load($token); return $jws->verify($publicKey, self::ALG) && $this->isTokenNotExpired($token); } catch (\InvalidArgumentException $ex) { return false; } }
[ "public", "function", "isValid", "(", "$", "token", ")", "{", "try", "{", "$", "publicKey", "=", "openssl_pkey_get_public", "(", "file_get_contents", "(", "$", "this", "->", "projectDir", ".", "'/var/jwt/public.pem'", ")", ")", ";", "$", "jws", "=", "SimpleJ...
Returns true if the token is valid @param string $token @return bool
[ "Returns", "true", "if", "the", "token", "is", "valid" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/JWSTokenService.php#L111-L122
train
phptuts/StarterBundleForSymfony
src/Service/JWSTokenService.php
JWSTokenService.getUser
public function getUser($token) { $payload = $this->getPayload($token); if (empty($payload[JWSTokenService::USER_ID_KEY])) { throw new ProgrammerException("No user_id in token payload", ProgrammerException::AUTH_TOKEN_NO_USER_ID); } $userId = $payload[JWSTokenService::USER_ID_KEY]; $user = $this->userService->findUserById($userId); if (empty($user)) { throw new ProgrammerException( "Unknown user id in token, " . $userId, ProgrammerException::AUTH_TOKEN_NO_USER_WITH_ID_FOUND ); } return $user; }
php
public function getUser($token) { $payload = $this->getPayload($token); if (empty($payload[JWSTokenService::USER_ID_KEY])) { throw new ProgrammerException("No user_id in token payload", ProgrammerException::AUTH_TOKEN_NO_USER_ID); } $userId = $payload[JWSTokenService::USER_ID_KEY]; $user = $this->userService->findUserById($userId); if (empty($user)) { throw new ProgrammerException( "Unknown user id in token, " . $userId, ProgrammerException::AUTH_TOKEN_NO_USER_WITH_ID_FOUND ); } return $user; }
[ "public", "function", "getUser", "(", "$", "token", ")", "{", "$", "payload", "=", "$", "this", "->", "getPayload", "(", "$", "token", ")", ";", "if", "(", "empty", "(", "$", "payload", "[", "JWSTokenService", "::", "USER_ID_KEY", "]", ")", ")", "{",...
Returns the user attached to the token @param string $token @return BaseUser @throws ProgrammerException
[ "Returns", "the", "user", "attached", "to", "the", "token" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/JWSTokenService.php#L132-L152
train
phptuts/StarterBundleForSymfony
src/Service/JWSTokenService.php
JWSTokenService.getPayload
public function getPayload($token) { try { $jws = SimpleJWS::load($token); return $jws->getPayload(); } catch (\InvalidArgumentException $ex) { throw new ProgrammerException('Unable to read jws token.', ProgrammerException::JWS_INVALID_TOKEN_FORMAT); } }
php
public function getPayload($token) { try { $jws = SimpleJWS::load($token); return $jws->getPayload(); } catch (\InvalidArgumentException $ex) { throw new ProgrammerException('Unable to read jws token.', ProgrammerException::JWS_INVALID_TOKEN_FORMAT); } }
[ "public", "function", "getPayload", "(", "$", "token", ")", "{", "try", "{", "$", "jws", "=", "SimpleJWS", "::", "load", "(", "$", "token", ")", ";", "return", "$", "jws", "->", "getPayload", "(", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentEx...
Gets the payload out of the token. @param $token @return array @throws ProgrammerException
[ "Gets", "the", "payload", "out", "of", "the", "token", "." ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/JWSTokenService.php#L161-L170
train
phptuts/StarterBundleForSymfony
src/Service/JWSTokenService.php
JWSTokenService.isTokenNotExpired
private function isTokenNotExpired($token) { $payload = $this->getPayload($token); return isset($payload[self::EXP_KEY]) && $payload[self::EXP_KEY] > (new \DateTime())->getTimestamp(); }
php
private function isTokenNotExpired($token) { $payload = $this->getPayload($token); return isset($payload[self::EXP_KEY]) && $payload[self::EXP_KEY] > (new \DateTime())->getTimestamp(); }
[ "private", "function", "isTokenNotExpired", "(", "$", "token", ")", "{", "$", "payload", "=", "$", "this", "->", "getPayload", "(", "$", "token", ")", ";", "return", "isset", "(", "$", "payload", "[", "self", "::", "EXP_KEY", "]", ")", "&&", "$", "pa...
Returns true if the token is not expired @param string $token @return bool
[ "Returns", "true", "if", "the", "token", "is", "not", "expired" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/JWSTokenService.php#L179-L184
train
proem/proem
lib/Proem/Util/Structure/PriorityQueue.php
PriorityQueue.insert
public function insert($data, $priority = 0) { $this->data[] = [ 'data' => $data, 'priority' => $priority, ]; $priority = array($priority, $this->max--); $this->getSplQueue()->insert($data, $priority); return $this; }
php
public function insert($data, $priority = 0) { $this->data[] = [ 'data' => $data, 'priority' => $priority, ]; $priority = array($priority, $this->max--); $this->getSplQueue()->insert($data, $priority); return $this; }
[ "public", "function", "insert", "(", "$", "data", ",", "$", "priority", "=", "0", ")", "{", "$", "this", "->", "data", "[", "]", "=", "[", "'data'", "=>", "$", "data", ",", "'priority'", "=>", "$", "priority", ",", "]", ";", "$", "priority", "=",...
Insert an item into the queue. @param mixed $data @param int $priority
[ "Insert", "an", "item", "into", "the", "queue", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Util/Structure/PriorityQueue.php#L86-L96
train
Mihai-P/yii2-core
components/Migration.php
Migration.getController
public function getController() { if(!empty($this->controller)) { return $this->controller; } else { preg_match('@(?:m[a-zA-Z0-9]{1,})_([a-zA-Z0-9]{1,})_(?:create)_([^/]+)_(?:table)@i', get_class($this), $matches); return $matches[2]; } }
php
public function getController() { if(!empty($this->controller)) { return $this->controller; } else { preg_match('@(?:m[a-zA-Z0-9]{1,})_([a-zA-Z0-9]{1,})_(?:create)_([^/]+)_(?:table)@i', get_class($this), $matches); return $matches[2]; } }
[ "public", "function", "getController", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "controller", ")", ")", "{", "return", "$", "this", "->", "controller", ";", "}", "else", "{", "preg_match", "(", "'@(?:m[a-zA-Z0-9]{1,})_([a-zA-Z0-9]{1,})...
Returns the name of the controller @return string the name of the controller
[ "Returns", "the", "name", "of", "the", "controller" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Migration.php#L37-L44
train
Mihai-P/yii2-core
components/Migration.php
Migration.createAuthItems
public function createAuthItems() { foreach($this->privileges as $privilege) { $this->insert('AuthItem', [ "name" => $privilege.'::'.$this->getController(), "type" => 0, "description" => $privilege.' '.$this->getController(), "bizrule" => null, "data" => 'a:2:{s:6:"module";s:'.strlen($this->menu).':"'.$this->menu.'";s:10:"controller";s:'.strlen($this->friendly($this->getController())).':"'.$this->friendly($this->getController()).'";}', ]); $this->insert('AuthItemChild', [ "parent" => 1, "child" => $privilege.'::'.$this->getController(), ]); } }
php
public function createAuthItems() { foreach($this->privileges as $privilege) { $this->insert('AuthItem', [ "name" => $privilege.'::'.$this->getController(), "type" => 0, "description" => $privilege.' '.$this->getController(), "bizrule" => null, "data" => 'a:2:{s:6:"module";s:'.strlen($this->menu).':"'.$this->menu.'";s:10:"controller";s:'.strlen($this->friendly($this->getController())).':"'.$this->friendly($this->getController()).'";}', ]); $this->insert('AuthItemChild', [ "parent" => 1, "child" => $privilege.'::'.$this->getController(), ]); } }
[ "public", "function", "createAuthItems", "(", ")", "{", "foreach", "(", "$", "this", "->", "privileges", "as", "$", "privilege", ")", "{", "$", "this", "->", "insert", "(", "'AuthItem'", ",", "[", "\"name\"", "=>", "$", "privilege", ".", "'::'", ".", "...
Creates the AuthItems for a controller @return null
[ "Creates", "the", "AuthItems", "for", "a", "controller" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Migration.php#L51-L65
train
Mihai-P/yii2-core
components/Migration.php
Migration.deleteAuthItems
public function deleteAuthItems() { foreach($this->privileges as $privilege) { $this->delete( 'AuthItem',"name = '".$privilege.'::'.$this->getController()."'" ); } }
php
public function deleteAuthItems() { foreach($this->privileges as $privilege) { $this->delete( 'AuthItem',"name = '".$privilege.'::'.$this->getController()."'" ); } }
[ "public", "function", "deleteAuthItems", "(", ")", "{", "foreach", "(", "$", "this", "->", "privileges", "as", "$", "privilege", ")", "{", "$", "this", "->", "delete", "(", "'AuthItem'", ",", "\"name = '\"", ".", "$", "privilege", ".", "'::'", ".", "$", ...
Deletes the AuthItems for the controller @return null
[ "Deletes", "the", "AuthItems", "for", "the", "controller" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Migration.php#L72-L78
train
Mihai-P/yii2-core
components/Migration.php
Migration.createAdminMenu
public function createAdminMenu() { $connection = \Yii::$app->db; $query = new Query; if(!$this->singleMenu) { $menu_name = $this->friendly($this->getController()); $menu = $query->from('AdminMenu') ->where('internal=:internal', [':internal'=>$this->menu]) ->one(); if(!$menu) { $query = new Query; // compose the query $last_main_menu = $query->from('AdminMenu') ->where('AdminMenu_id IS NULL') ->orderby('order DESC') ->one(); $this->insert('AdminMenu', [ "name" => $this->menu, "internal" => $this->menu, "url" => '', "ap" => 'read::'.$this->getController(), "order" => $last_main_menu ? $last_main_menu['order'] + 1 : 1 ]); $menu_id = $connection->getLastInsertID(); } else { $menu_id = $menu['id']; } } else { $menu_id = NULL; $menu_name = $this->menu; } $query = new Query; $last_menu = $query->from('AdminMenu') ->from('AdminMenu') ->where('AdminMenu_id=:AdminMenu_id', [':AdminMenu_id'=>$menu_id]) ->orderby('order DESC') ->one(); $this->insert('AdminMenu', [ "AdminMenu_id" => $menu_id, "name" => $menu_name, "internal" => $this->getController() . 'Controller', "url" => ($this->module ? '/' . $this->module : '' ) . '/'. strtolower(trim(preg_replace("([A-Z])", "-$0", $this->getController()), '-')).'/', "ap" => 'read::'.$this->getController(), "order" => $last_menu ? $last_menu['order'] + 1 : 1 ]); }
php
public function createAdminMenu() { $connection = \Yii::$app->db; $query = new Query; if(!$this->singleMenu) { $menu_name = $this->friendly($this->getController()); $menu = $query->from('AdminMenu') ->where('internal=:internal', [':internal'=>$this->menu]) ->one(); if(!$menu) { $query = new Query; // compose the query $last_main_menu = $query->from('AdminMenu') ->where('AdminMenu_id IS NULL') ->orderby('order DESC') ->one(); $this->insert('AdminMenu', [ "name" => $this->menu, "internal" => $this->menu, "url" => '', "ap" => 'read::'.$this->getController(), "order" => $last_main_menu ? $last_main_menu['order'] + 1 : 1 ]); $menu_id = $connection->getLastInsertID(); } else { $menu_id = $menu['id']; } } else { $menu_id = NULL; $menu_name = $this->menu; } $query = new Query; $last_menu = $query->from('AdminMenu') ->from('AdminMenu') ->where('AdminMenu_id=:AdminMenu_id', [':AdminMenu_id'=>$menu_id]) ->orderby('order DESC') ->one(); $this->insert('AdminMenu', [ "AdminMenu_id" => $menu_id, "name" => $menu_name, "internal" => $this->getController() . 'Controller', "url" => ($this->module ? '/' . $this->module : '' ) . '/'. strtolower(trim(preg_replace("([A-Z])", "-$0", $this->getController()), '-')).'/', "ap" => 'read::'.$this->getController(), "order" => $last_menu ? $last_menu['order'] + 1 : 1 ]); }
[ "public", "function", "createAdminMenu", "(", ")", "{", "$", "connection", "=", "\\", "Yii", "::", "$", "app", "->", "db", ";", "$", "query", "=", "new", "Query", ";", "if", "(", "!", "$", "this", "->", "singleMenu", ")", "{", "$", "menu_name", "="...
Inserts the AdminMenus for the controller @return null
[ "Inserts", "the", "AdminMenus", "for", "the", "controller" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Migration.php#L85-L133
train
laravelflare/flare
src/Flare/Admin/Models/Traits/ModelCreating.php
ModelCreating.create
public function create() { event(new BeforeCreate($this)); $this->beforeCreate(); $this->doCreate(); $this->afterCreate(); event(new AfterCreate($this)); }
php
public function create() { event(new BeforeCreate($this)); $this->beforeCreate(); $this->doCreate(); $this->afterCreate(); event(new AfterCreate($this)); }
[ "public", "function", "create", "(", ")", "{", "event", "(", "new", "BeforeCreate", "(", "$", "this", ")", ")", ";", "$", "this", "->", "beforeCreate", "(", ")", ";", "$", "this", "->", "doCreate", "(", ")", ";", "$", "this", "->", "afterCreate", "...
Create Action. Fires off beforeCreate(), doCreate() and afterCreate() @return
[ "Create", "Action", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelCreating.php#L28-L39
train
reliv/Rcm
core/src/Module.php
Module.onBootstrap
public function onBootstrap(MvcEvent $event) { $serviceManager = $event->getApplication()->getServiceManager(); $request = $serviceManager->get('request'); if ($request instanceof ConsoleRequest) { return; } //Add Domain Checker $eventWrapper = $serviceManager->get( \Rcm\EventListener\EventWrapper::class ); /** @var \Zend\EventManager\EventManager $eventManager */ $eventManager = $event->getApplication()->getEventManager(); // Check for redirects from the CMS $eventManager->attach( MvcEvent::EVENT_ROUTE, [$eventWrapper, 'routeEvent'], 10000 ); // Set the sites layout. $eventManager->attach( MvcEvent::EVENT_DISPATCH, [$eventWrapper, 'dispatchEvent'], 10000 ); // Set the custom http response checker $eventManager->attach( MvcEvent::EVENT_FINISH, [$eventWrapper, 'finishEvent'], 10000 ); $viewEventManager = $serviceManager->get('ViewManager') ->getView() ->getEventManager(); // Set the plugin response over-ride $viewEventManager->attach( ViewEvent::EVENT_RESPONSE, [$eventWrapper, 'viewResponseEvent'], -10000 ); // Use the configured session handler. // Should we really boot this for every request though? $serviceManager->get(\Rcm\Service\SessionManager::class)->start(); }
php
public function onBootstrap(MvcEvent $event) { $serviceManager = $event->getApplication()->getServiceManager(); $request = $serviceManager->get('request'); if ($request instanceof ConsoleRequest) { return; } //Add Domain Checker $eventWrapper = $serviceManager->get( \Rcm\EventListener\EventWrapper::class ); /** @var \Zend\EventManager\EventManager $eventManager */ $eventManager = $event->getApplication()->getEventManager(); // Check for redirects from the CMS $eventManager->attach( MvcEvent::EVENT_ROUTE, [$eventWrapper, 'routeEvent'], 10000 ); // Set the sites layout. $eventManager->attach( MvcEvent::EVENT_DISPATCH, [$eventWrapper, 'dispatchEvent'], 10000 ); // Set the custom http response checker $eventManager->attach( MvcEvent::EVENT_FINISH, [$eventWrapper, 'finishEvent'], 10000 ); $viewEventManager = $serviceManager->get('ViewManager') ->getView() ->getEventManager(); // Set the plugin response over-ride $viewEventManager->attach( ViewEvent::EVENT_RESPONSE, [$eventWrapper, 'viewResponseEvent'], -10000 ); // Use the configured session handler. // Should we really boot this for every request though? $serviceManager->get(\Rcm\Service\SessionManager::class)->start(); }
[ "public", "function", "onBootstrap", "(", "MvcEvent", "$", "event", ")", "{", "$", "serviceManager", "=", "$", "event", "->", "getApplication", "(", ")", "->", "getServiceManager", "(", ")", ";", "$", "request", "=", "$", "serviceManager", "->", "get", "("...
Bootstrap For RCM. @param MvcEvent $event Zend MVC Event @return void
[ "Bootstrap", "For", "RCM", "." ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Module.php#L32-L85
train
Mihai-P/yii2-core
components/Controller.php
Controller.getCompatibilityId
public function getCompatibilityId() { $controller = $this->getUniqueId(); if (strpos($controller, "/")) { $controller = substr($controller, strpos($controller, "/") + 1); } return str_replace(' ', '', ucwords(str_replace('-', ' ', $controller))); }
php
public function getCompatibilityId() { $controller = $this->getUniqueId(); if (strpos($controller, "/")) { $controller = substr($controller, strpos($controller, "/") + 1); } return str_replace(' ', '', ucwords(str_replace('-', ' ', $controller))); }
[ "public", "function", "getCompatibilityId", "(", ")", "{", "$", "controller", "=", "$", "this", "->", "getUniqueId", "(", ")", ";", "if", "(", "strpos", "(", "$", "controller", ",", "\"/\"", ")", ")", "{", "$", "controller", "=", "substr", "(", "$", ...
Gets the simple name for the current controller @return string
[ "Gets", "the", "simple", "name", "for", "the", "current", "controller" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Controller.php#L134-L141
train
Mihai-P/yii2-core
components/Controller.php
Controller.actionIndex
public function actionIndex() { $this->getSearchCriteria(); $this->layout = static::TABLE_LAYOUT; return $this->render('index', [ 'searchModel' => $this->searchModel, 'dataProvider' => $this->dataProvider, ]); }
php
public function actionIndex() { $this->getSearchCriteria(); $this->layout = static::TABLE_LAYOUT; return $this->render('index', [ 'searchModel' => $this->searchModel, 'dataProvider' => $this->dataProvider, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "this", "->", "getSearchCriteria", "(", ")", ";", "$", "this", "->", "layout", "=", "static", "::", "TABLE_LAYOUT", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'searchMod...
Lists all the models. @return mixed
[ "Lists", "all", "the", "models", "." ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Controller.php#L160-L168
train
Mihai-P/yii2-core
components/Controller.php
Controller.getSearchCriteria
public function getSearchCriteria() { /* setting the default pagination for the page */ if (!Yii::$app->session->get($this->MainModel . 'Pagination')) { Yii::$app->session->set($this->MainModel . 'Pagination', Yii::$app->getModule('core')->recordsPerPage); } $savedQueryParams = Yii::$app->session->get($this->MainModel . 'QueryParams'); if (count($savedQueryParams)) { $queryParams = $savedQueryParams; } else { $queryParams = [substr($this->MainModelSearch, strrpos($this->MainModelSearch, "\\") + 1) => $this->defaultQueryParams]; } /* use the same filters as before */ if (count(Yii::$app->request->queryParams)) { $queryParams = array_merge($queryParams, Yii::$app->request->queryParams); } if (isset($queryParams['page'])) { $_GET['page'] = $queryParams['page']; } if (Yii::$app->request->getIsPjax()) { $this->layout = false; } Yii::$app->session->set($this->MainModel . 'QueryParams', $queryParams); $this->searchModel = new $this->MainModelSearch; $this->dataProvider = $this->searchModel->search($queryParams); }
php
public function getSearchCriteria() { /* setting the default pagination for the page */ if (!Yii::$app->session->get($this->MainModel . 'Pagination')) { Yii::$app->session->set($this->MainModel . 'Pagination', Yii::$app->getModule('core')->recordsPerPage); } $savedQueryParams = Yii::$app->session->get($this->MainModel . 'QueryParams'); if (count($savedQueryParams)) { $queryParams = $savedQueryParams; } else { $queryParams = [substr($this->MainModelSearch, strrpos($this->MainModelSearch, "\\") + 1) => $this->defaultQueryParams]; } /* use the same filters as before */ if (count(Yii::$app->request->queryParams)) { $queryParams = array_merge($queryParams, Yii::$app->request->queryParams); } if (isset($queryParams['page'])) { $_GET['page'] = $queryParams['page']; } if (Yii::$app->request->getIsPjax()) { $this->layout = false; } Yii::$app->session->set($this->MainModel . 'QueryParams', $queryParams); $this->searchModel = new $this->MainModelSearch; $this->dataProvider = $this->searchModel->search($queryParams); }
[ "public", "function", "getSearchCriteria", "(", ")", "{", "/* setting the default pagination for the page */", "if", "(", "!", "Yii", "::", "$", "app", "->", "session", "->", "get", "(", "$", "this", "->", "MainModel", ".", "'Pagination'", ")", ")", "{", "Yii"...
creates the search criteria for the model @return null
[ "creates", "the", "search", "criteria", "for", "the", "model" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Controller.php#L174-L200
train
Mihai-P/yii2-core
components/Controller.php
Controller.actionPdf
public function actionPdf() { $this->getSearchCriteria(); $this->layout = static::BLANK_LAYOUT; $this->dataProvider->pagination = false; $content = $this->render('pdf', [ 'dataProvider' => $this->dataProvider, ]); if (isset($_GET['test'])) { return $content; } else { $mpdf = new \mPDF(); $mpdf->WriteHTML($content); Yii::$app->response->getHeaders()->set('Content-Type', 'application/pdf'); Yii::$app->response->getHeaders()->set('Content-Disposition', 'attachment; filename="' . $this->getCompatibilityId() . '.pdf"'); return $mpdf->Output($this->getCompatibilityId() . '.pdf', 'S'); } }
php
public function actionPdf() { $this->getSearchCriteria(); $this->layout = static::BLANK_LAYOUT; $this->dataProvider->pagination = false; $content = $this->render('pdf', [ 'dataProvider' => $this->dataProvider, ]); if (isset($_GET['test'])) { return $content; } else { $mpdf = new \mPDF(); $mpdf->WriteHTML($content); Yii::$app->response->getHeaders()->set('Content-Type', 'application/pdf'); Yii::$app->response->getHeaders()->set('Content-Disposition', 'attachment; filename="' . $this->getCompatibilityId() . '.pdf"'); return $mpdf->Output($this->getCompatibilityId() . '.pdf', 'S'); } }
[ "public", "function", "actionPdf", "(", ")", "{", "$", "this", "->", "getSearchCriteria", "(", ")", ";", "$", "this", "->", "layout", "=", "static", "::", "BLANK_LAYOUT", ";", "$", "this", "->", "dataProvider", "->", "pagination", "=", "false", ";", "$",...
Creates a PDF file with the current list of the models @return string
[ "Creates", "a", "PDF", "file", "with", "the", "current", "list", "of", "the", "models" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Controller.php#L206-L224
train
Mihai-P/yii2-core
components/Controller.php
Controller.actionPagination
public function actionPagination() { Yii::$app->session->set($this->MainModel . 'Pagination', Yii::$app->request->queryParams['records']); $this->redirect(['index']); }
php
public function actionPagination() { Yii::$app->session->set($this->MainModel . 'Pagination', Yii::$app->request->queryParams['records']); $this->redirect(['index']); }
[ "public", "function", "actionPagination", "(", ")", "{", "Yii", "::", "$", "app", "->", "session", "->", "set", "(", "$", "this", "->", "MainModel", ".", "'Pagination'", ",", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", "[", "'records'"...
Sets the pagination for the list @return mixed
[ "Sets", "the", "pagination", "for", "the", "list" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Controller.php#L230-L234
train
Mihai-P/yii2-core
components/Controller.php
Controller.actionCreate
public function actionCreate() { $this->layout = static::FORM_LAYOUT; $model = new $this->MainModel; if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->afterCreate($model); if ($this->hasView) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->redirect(['index']); } } else { return $this->render('create', [ 'model' => $model, ]); } }
php
public function actionCreate() { $this->layout = static::FORM_LAYOUT; $model = new $this->MainModel; if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->afterCreate($model); if ($this->hasView) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->redirect(['index']); } } else { return $this->render('create', [ 'model' => $model, ]); } }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "this", "->", "layout", "=", "static", "::", "FORM_LAYOUT", ";", "$", "model", "=", "new", "$", "this", "->", "MainModel", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", ...
Creates a new model. If creation is successful, the browser will be redirected to the 'view' or 'index' page. @return mixed
[ "Creates", "a", "new", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "or", "index", "page", "." ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Controller.php#L271-L288
train
Mihai-P/yii2-core
components/Controller.php
Controller.saveHistory
public function saveHistory($model, $historyField) { if (isset($model->{$historyField})) { $url_components = explode("\\", get_class($model)); $url_components[2] = trim(preg_replace("([A-Z])", " $0", $url_components[2]), " "); $history = new History; $history->name = $model->{$historyField}; $history->type = $url_components[2]; $history->url = Url::toRoute(['update', 'id' => $model->id]); $history->save(); } }
php
public function saveHistory($model, $historyField) { if (isset($model->{$historyField})) { $url_components = explode("\\", get_class($model)); $url_components[2] = trim(preg_replace("([A-Z])", " $0", $url_components[2]), " "); $history = new History; $history->name = $model->{$historyField}; $history->type = $url_components[2]; $history->url = Url::toRoute(['update', 'id' => $model->id]); $history->save(); } }
[ "public", "function", "saveHistory", "(", "$", "model", ",", "$", "historyField", ")", "{", "if", "(", "isset", "(", "$", "model", "->", "{", "$", "historyField", "}", ")", ")", "{", "$", "url_components", "=", "explode", "(", "\"\\\\\"", ",", "get_cla...
Saves the history for the model @param \yii\db\ActiveRecord $model @param string $historyField @return null
[ "Saves", "the", "history", "for", "the", "model" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Controller.php#L305-L317
train
Mihai-P/yii2-core
components/Controller.php
Controller.actionUpdate
public function actionUpdate($id) { $this->layout = static::FORM_LAYOUT; $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->afterUpdate($model); if ($this->hasView) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->redirect(['index']); } } else { return $this->render('update', [ 'model' => $model, ]); } }
php
public function actionUpdate($id) { $this->layout = static::FORM_LAYOUT; $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { $this->afterUpdate($model); if ($this->hasView) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->redirect(['index']); } } else { return $this->render('update', [ 'model' => $model, ]); } }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "this", "->", "layout", "=", "static", "::", "FORM_LAYOUT", ";", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "if", "(", "$", "model", "->", "load"...
Updates an existing model. If update is successful, the browser will be redirected to the 'view' or 'index' page. @param integer $id @return mixed
[ "Updates", "an", "existing", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "or", "index", "page", "." ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Controller.php#L325-L343
train
Mihai-P/yii2-core
components/Controller.php
Controller.allButtons
public function allButtons() { $buttons = []; if (\Yii::$app->user->checkAccess('read::' . $this->getCompatibilityId())) { $buttons['pdf'] = [ 'text' => 'Download PDF', 'url' => Url::toRoute(['pdf']), 'options' => [ 'target' => '_blank', ] ]; $buttons['csv'] = [ 'text' => 'Download CSV', 'url' => Url::toRoute(['csv']), 'options' => [ 'target' => '_blank', ] ]; } return $buttons; }
php
public function allButtons() { $buttons = []; if (\Yii::$app->user->checkAccess('read::' . $this->getCompatibilityId())) { $buttons['pdf'] = [ 'text' => 'Download PDF', 'url' => Url::toRoute(['pdf']), 'options' => [ 'target' => '_blank', ] ]; $buttons['csv'] = [ 'text' => 'Download CSV', 'url' => Url::toRoute(['csv']), 'options' => [ 'target' => '_blank', ] ]; } return $buttons; }
[ "public", "function", "allButtons", "(", ")", "{", "$", "buttons", "=", "[", "]", ";", "if", "(", "\\", "Yii", "::", "$", "app", "->", "user", "->", "checkAccess", "(", "'read::'", ".", "$", "this", "->", "getCompatibilityId", "(", ")", ")", ")", "...
Sets the buttons that can be performed on the entire result @return array
[ "Sets", "the", "buttons", "that", "can", "be", "performed", "on", "the", "entire", "result" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/Controller.php#L485-L505
train
reliv/Rcm
core/src/EventListener/DispatchListener.php
DispatchListener.setSiteLayout
public function setSiteLayout(MvcEvent $event) { /** @var \Zend\View\Model\ViewModel $viewModel */ $viewModel = $event->getViewModel(); /* Add on for non CMS pages */ $fakePage = new Page( Tracking::UNKNOWN_USER_ID, 'Fake page for non CMS pages in ' . get_class($this) ); $fakeRevision = new Revision( Tracking::UNKNOWN_USER_ID, 'Fake revision for non CMS pages in ' . get_class($this) ); $fakePage->setCurrentRevision($fakeRevision); $currentSite = $this->getCurrentSite(); $viewModel->setVariable('page', $fakePage); $viewModel->setVariable('site', $currentSite); $template = $this->getSiteLayoutTemplate(); $viewModel->setTemplate('layout/' . $template); return null; }
php
public function setSiteLayout(MvcEvent $event) { /** @var \Zend\View\Model\ViewModel $viewModel */ $viewModel = $event->getViewModel(); /* Add on for non CMS pages */ $fakePage = new Page( Tracking::UNKNOWN_USER_ID, 'Fake page for non CMS pages in ' . get_class($this) ); $fakeRevision = new Revision( Tracking::UNKNOWN_USER_ID, 'Fake revision for non CMS pages in ' . get_class($this) ); $fakePage->setCurrentRevision($fakeRevision); $currentSite = $this->getCurrentSite(); $viewModel->setVariable('page', $fakePage); $viewModel->setVariable('site', $currentSite); $template = $this->getSiteLayoutTemplate(); $viewModel->setTemplate('layout/' . $template); return null; }
[ "public", "function", "setSiteLayout", "(", "MvcEvent", "$", "event", ")", "{", "/** @var \\Zend\\View\\Model\\ViewModel $viewModel */", "$", "viewModel", "=", "$", "event", "->", "getViewModel", "(", ")", ";", "/* Add on for non CMS pages */", "$", "fakePage", "=", "...
Set Site Layout @param MvcEvent $event Zend MVC Event object @return null
[ "Set", "Site", "Layout" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/EventListener/DispatchListener.php#L91-L118
train
phptuts/StarterBundleForSymfony
src/Controller/UserController.php
UserController.getUserById
private function getUserById($id) { $user = $this->userService->findUserById($id); if (empty($user)) { throw $this->createNotFoundException('user not found'); } return $user; }
php
private function getUserById($id) { $user = $this->userService->findUserById($id); if (empty($user)) { throw $this->createNotFoundException('user not found'); } return $user; }
[ "private", "function", "getUserById", "(", "$", "id", ")", "{", "$", "user", "=", "$", "this", "->", "userService", "->", "findUserById", "(", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "user", ")", ")", "{", "throw", "$", "this", "->", "...
Gets the user by the user's id @param $id @return null|object|BaseUser
[ "Gets", "the", "user", "by", "the", "user", "s", "id" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Controller/UserController.php#L504-L513
train
outeredge/magento-base-module
Helper/Asset.php
Asset.getAsset
public function getAsset($asset) { if (!isset($this->assetCache[$asset])) { $this->assetCache[$asset] = $this->assetRepository->createAsset($asset); } return $this->assetCache[$asset]; }
php
public function getAsset($asset) { if (!isset($this->assetCache[$asset])) { $this->assetCache[$asset] = $this->assetRepository->createAsset($asset); } return $this->assetCache[$asset]; }
[ "public", "function", "getAsset", "(", "$", "asset", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "assetCache", "[", "$", "asset", "]", ")", ")", "{", "$", "this", "->", "assetCache", "[", "$", "asset", "]", "=", "$", "this", "->", ...
Return asset file object @param string $asset @return File
[ "Return", "asset", "file", "object" ]
6ec95147011f2ae4399d7be2998998889d4e1f75
https://github.com/outeredge/magento-base-module/blob/6ec95147011f2ae4399d7be2998998889d4e1f75/Helper/Asset.php#L40-L46
train
dadajuice/zephyrus
src/Zephyrus/Application/Formatter.php
Formatter.formatSeoUrl
public static function formatSeoUrl($name) { $url = mb_strtolower($name); $url = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $url); $url = preg_replace("/[^a-z0-9_\s-]/", "", $url); $url = preg_replace("/[\s-]+/", " ", $url); $url = trim($url); return preg_replace("/[\s_]/", "-", $url); }
php
public static function formatSeoUrl($name) { $url = mb_strtolower($name); $url = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $url); $url = preg_replace("/[^a-z0-9_\s-]/", "", $url); $url = preg_replace("/[\s-]+/", " ", $url); $url = trim($url); return preg_replace("/[\s_]/", "-", $url); }
[ "public", "static", "function", "formatSeoUrl", "(", "$", "name", ")", "{", "$", "url", "=", "mb_strtolower", "(", "$", "name", ")", ";", "$", "url", "=", "iconv", "(", "'UTF-8'", ",", "'ASCII//TRANSLIT//IGNORE'", ",", "$", "url", ")", ";", "$", "url",...
Returns a SEO compatible url based on the specified string. Be sure to check the LC_CTYPE locale setting if getting any question marks in result. Run locale -a on server to see full list of supported locales. @param string $name @return string
[ "Returns", "a", "SEO", "compatible", "url", "based", "on", "the", "specified", "string", ".", "Be", "sure", "to", "check", "the", "LC_CTYPE", "locale", "setting", "if", "getting", "any", "question", "marks", "in", "result", ".", "Run", "locale", "-", "a", ...
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Formatter.php#L81-L89
train
phptuts/StarterBundleForSymfony
src/Form/DataTransformer/UserEmailTransformer.php
UserEmailTransformer.transform
public function transform($user) { if (empty($user)) { $className = $this->userService->getUserClass(); return new $className(); } return $user; }
php
public function transform($user) { if (empty($user)) { $className = $this->userService->getUserClass(); return new $className(); } return $user; }
[ "public", "function", "transform", "(", "$", "user", ")", "{", "if", "(", "empty", "(", "$", "user", ")", ")", "{", "$", "className", "=", "$", "this", "->", "userService", "->", "getUserClass", "(", ")", ";", "return", "new", "$", "className", "(", ...
This always return null or the full object because we transforming the whole form with this transformer @param BaseUser $user @return string
[ "This", "always", "return", "null", "or", "the", "full", "object", "because", "we", "transforming", "the", "whole", "form", "with", "this", "transformer" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Form/DataTransformer/UserEmailTransformer.php#L34-L44
train
RogerWaters/react-thread-pool
src/EventLoop/ForkableExtEventLoop.php
ForkableExtEventLoop.subscribeStreamEvent
private function subscribeStreamEvent($stream, $flag) { $key = (int) $stream; if (isset($this->streamEvents[$key])) { $event = $this->streamEvents[$key]; $flags = ($this->streamFlags[$key] |= $flag); $event->del(); $event->set($this->eventBase, $stream, Event::PERSIST | $flags, $this->streamCallback); } else { $event = new Event($this->eventBase, $stream, Event::PERSIST | $flag, $this->streamCallback); $this->streamEvents[$key] = $event; $this->streamFlags[$key] = $flag; } $event->add(); }
php
private function subscribeStreamEvent($stream, $flag) { $key = (int) $stream; if (isset($this->streamEvents[$key])) { $event = $this->streamEvents[$key]; $flags = ($this->streamFlags[$key] |= $flag); $event->del(); $event->set($this->eventBase, $stream, Event::PERSIST | $flags, $this->streamCallback); } else { $event = new Event($this->eventBase, $stream, Event::PERSIST | $flag, $this->streamCallback); $this->streamEvents[$key] = $event; $this->streamFlags[$key] = $flag; } $event->add(); }
[ "private", "function", "subscribeStreamEvent", "(", "$", "stream", ",", "$", "flag", ")", "{", "$", "key", "=", "(", "int", ")", "$", "stream", ";", "if", "(", "isset", "(", "$", "this", "->", "streamEvents", "[", "$", "key", "]", ")", ")", "{", ...
Create a new ext-event Event object, or update the existing one. @param stream $stream @param integer $flag Event::READ or Event::WRITE
[ "Create", "a", "new", "ext", "-", "event", "Event", "object", "or", "update", "the", "existing", "one", "." ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/EventLoop/ForkableExtEventLoop.php#L255-L273
train
RogerWaters/react-thread-pool
src/EventLoop/ForkableExtEventLoop.php
ForkableExtEventLoop.unsubscribeStreamEvent
private function unsubscribeStreamEvent($stream, $flag) { $key = (int) $stream; $flags = $this->streamFlags[$key] &= ~$flag; if (0 === $flags) { $this->removeStream($stream); return; } $event = $this->streamEvents[$key]; $event->del(); $event->set($this->eventBase, $stream, Event::PERSIST | $flags, $this->streamCallback); $event->add(); }
php
private function unsubscribeStreamEvent($stream, $flag) { $key = (int) $stream; $flags = $this->streamFlags[$key] &= ~$flag; if (0 === $flags) { $this->removeStream($stream); return; } $event = $this->streamEvents[$key]; $event->del(); $event->set($this->eventBase, $stream, Event::PERSIST | $flags, $this->streamCallback); $event->add(); }
[ "private", "function", "unsubscribeStreamEvent", "(", "$", "stream", ",", "$", "flag", ")", "{", "$", "key", "=", "(", "int", ")", "$", "stream", ";", "$", "flags", "=", "$", "this", "->", "streamFlags", "[", "$", "key", "]", "&=", "~", "$", "flag"...
Update the ext-event Event object for this stream to stop listening to the given event type, or remove it entirely if it's no longer needed. @param stream $stream @param integer $flag Event::READ or Event::WRITE
[ "Update", "the", "ext", "-", "event", "Event", "object", "for", "this", "stream", "to", "stop", "listening", "to", "the", "given", "event", "type", "or", "remove", "it", "entirely", "if", "it", "s", "no", "longer", "needed", "." ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/EventLoop/ForkableExtEventLoop.php#L282-L299
train
webeweb/core-bundle
Icon/FontAwesome/FontAwesomeIconEnumerator.php
FontAwesomeIconEnumerator.enumFonts
public static function enumFonts() { return [ FontAwesomeIconInterface::FONT_AWESOME_FONT, FontAwesomeIconInterface::FONT_AWESOME_FONT_BOLD, FontAwesomeIconInterface::FONT_AWESOME_FONT_LIGHT, FontAwesomeIconInterface::FONT_AWESOME_FONT_REGULAR, FontAwesomeIconInterface::FONT_AWESOME_FONT_SOLID, ]; }
php
public static function enumFonts() { return [ FontAwesomeIconInterface::FONT_AWESOME_FONT, FontAwesomeIconInterface::FONT_AWESOME_FONT_BOLD, FontAwesomeIconInterface::FONT_AWESOME_FONT_LIGHT, FontAwesomeIconInterface::FONT_AWESOME_FONT_REGULAR, FontAwesomeIconInterface::FONT_AWESOME_FONT_SOLID, ]; }
[ "public", "static", "function", "enumFonts", "(", ")", "{", "return", "[", "FontAwesomeIconInterface", "::", "FONT_AWESOME_FONT", ",", "FontAwesomeIconInterface", "::", "FONT_AWESOME_FONT_BOLD", ",", "FontAwesomeIconInterface", "::", "FONT_AWESOME_FONT_LIGHT", ",", "FontAwe...
Enumerates the fonts. @return array Returns the fonts enumeration.
[ "Enumerates", "the", "fonts", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Icon/FontAwesome/FontAwesomeIconEnumerator.php#L39-L47
train
Mihai-P/yii2-core
components/ActiveRecord.php
ActiveRecord.deleteInternal
public function deleteInternal() { $result = false; if ($this->beforeDelete()) { // we do not check the return value of deleteAll() because it's possible // the record is already deleted in the database and thus the method will return 0 $condition = $this->getOldPrimaryKey(true); $lock = $this->optimisticLock(); if ($lock !== null) { $condition[$lock] = $this->$lock; } $this->status = self::STATUS_DELETED; $result = $this->save(false); if ($lock !== null && !$result) { throw new StaleObjectException('The object being deleted is outdated.'); } $this->setOldAttributes(null); $this->afterDelete(); } return $result; }
php
public function deleteInternal() { $result = false; if ($this->beforeDelete()) { // we do not check the return value of deleteAll() because it's possible // the record is already deleted in the database and thus the method will return 0 $condition = $this->getOldPrimaryKey(true); $lock = $this->optimisticLock(); if ($lock !== null) { $condition[$lock] = $this->$lock; } $this->status = self::STATUS_DELETED; $result = $this->save(false); if ($lock !== null && !$result) { throw new StaleObjectException('The object being deleted is outdated.'); } $this->setOldAttributes(null); $this->afterDelete(); } return $result; }
[ "public", "function", "deleteInternal", "(", ")", "{", "$", "result", "=", "false", ";", "if", "(", "$", "this", "->", "beforeDelete", "(", ")", ")", "{", "// we do not check the return value of deleteAll() because it's possible", "// the record is already deleted in the ...
Marks an ActiveRecord as deleted in the database. @return integer|boolean the number of rows deleted, or false if the deletion is unsuccessful for some reason. Note that it is possible the number of rows deleted is 0, even though the deletion execution is successful. @throws StaleObjectException
[ "Marks", "an", "ActiveRecord", "as", "deleted", "in", "the", "database", "." ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/ActiveRecord.php#L78-L99
train
russsiq/bixbite
app/Models/Mutators/CommentMutators.php
CommentMutators.getAuthorAttribute
public function getAuthorAttribute() { return (object) [ 'name' => is_int($this->user_id) ? $this->user->name : $this->name, 'profile' => is_int($this->user_id) ? $this->user->profile : $this->name, 'avatar' => is_int($this->user_id) ? $this->user->avatar : get_avatar($this->email), 'isOnline' => is_int($this->user_id) ? $this->user->isOnline() : false, ]; }
php
public function getAuthorAttribute() { return (object) [ 'name' => is_int($this->user_id) ? $this->user->name : $this->name, 'profile' => is_int($this->user_id) ? $this->user->profile : $this->name, 'avatar' => is_int($this->user_id) ? $this->user->avatar : get_avatar($this->email), 'isOnline' => is_int($this->user_id) ? $this->user->isOnline() : false, ]; }
[ "public", "function", "getAuthorAttribute", "(", ")", "{", "return", "(", "object", ")", "[", "'name'", "=>", "is_int", "(", "$", "this", "->", "user_id", ")", "?", "$", "this", "->", "user", "->", "name", ":", "$", "this", "->", "name", ",", "'profi...
Don't touch this. Need when comments added from ajax
[ "Don", "t", "touch", "this", ".", "Need", "when", "comments", "added", "from", "ajax" ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Mutators/CommentMutators.php#L28-L36
train
lsv/rejseplan-php-api
src/Services/NearbyStops.php
NearbyStops.setCoordinate
public function setCoordinate(Coordinate $coordinate): self { $this->options['coordX'] = $coordinate->getLatitude(); $this->options['coordY'] = $coordinate->getLongitude(); return $this; }
php
public function setCoordinate(Coordinate $coordinate): self { $this->options['coordX'] = $coordinate->getLatitude(); $this->options['coordY'] = $coordinate->getLongitude(); return $this; }
[ "public", "function", "setCoordinate", "(", "Coordinate", "$", "coordinate", ")", ":", "self", "{", "$", "this", "->", "options", "[", "'coordX'", "]", "=", "$", "coordinate", "->", "getLatitude", "(", ")", ";", "$", "this", "->", "options", "[", "'coord...
Set coordinate to get nearby stops. @param Coordinate $coordinate @return $this
[ "Set", "coordinate", "to", "get", "nearby", "stops", "." ]
f09add92e160f167a19ff2a290951d202d7ece67
https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/Services/NearbyStops.php#L23-L29
train
phptuts/StarterBundleForSymfony
src/Security/Guard/OAuth/OAuthGuard.php
OAuthGuard.onAuthenticationSuccess
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) { $user = $token->getUser(); $this->dispatcher->dispatch(self::OAUTH_LOGIN_SUCCESS, new UserEvent($user)); return $this->authResponseService->authenticateResponse($user, new Response($this->twig->render('@StarterKitStart/oauth-success.html.twig'))); }
php
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) { $user = $token->getUser(); $this->dispatcher->dispatch(self::OAUTH_LOGIN_SUCCESS, new UserEvent($user)); return $this->authResponseService->authenticateResponse($user, new Response($this->twig->render('@StarterKitStart/oauth-success.html.twig'))); }
[ "public", "function", "onAuthenticationSuccess", "(", "Request", "$", "request", ",", "TokenInterface", "$", "token", ",", "$", "providerKey", ")", "{", "$", "user", "=", "$", "token", "->", "getUser", "(", ")", ";", "$", "this", "->", "dispatcher", "->", ...
5a) Return an authorized response. The page rendered will redirect the user to the home page. We can't do the RedirectResponse. @param Request $request @param TokenInterface $token @param string $providerKey @return Response
[ "5a", ")", "Return", "an", "authorized", "response", "." ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/OAuth/OAuthGuard.php#L101-L109
train
phptuts/StarterBundleForSymfony
src/Security/Guard/OAuth/OAuthGuard.php
OAuthGuard.onAuthenticationFailure
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { $this->dispatcher->dispatch(self::OAUTH_LOGIN_FAILURE, new AuthFailedEvent($request, $exception)); return $this->removeAuthCookieFromResponse(new Response( $this->twig->render('@StarterKitStart/oauth-failure.html.twig', ['login_path' => $this->loginPath]) )); }
php
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { $this->dispatcher->dispatch(self::OAUTH_LOGIN_FAILURE, new AuthFailedEvent($request, $exception)); return $this->removeAuthCookieFromResponse(new Response( $this->twig->render('@StarterKitStart/oauth-failure.html.twig', ['login_path' => $this->loginPath]) )); }
[ "public", "function", "onAuthenticationFailure", "(", "Request", "$", "request", ",", "AuthenticationException", "$", "exception", ")", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "self", "::", "OAUTH_LOGIN_FAILURE", ",", "new", "AuthFailedEvent", ...
5a) Returns a 403. The page rendered will redirect the user to the login page. This happens when third party api fails. @param Request $request @param AuthenticationException $exception @return Response
[ "5a", ")", "Returns", "a", "403", "." ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/OAuth/OAuthGuard.php#L120-L127
train
phptuts/StarterBundleForSymfony
src/Security/Guard/OAuth/OAuthGuard.php
OAuthGuard.start
public function start(Request $request, AuthenticationException $authException = null) { return new Response( $this->twig->render('@StarterKitStart/oauth-start.html.twig', ['login_path' => $this->loginPath]) ); }
php
public function start(Request $request, AuthenticationException $authException = null) { return new Response( $this->twig->render('@StarterKitStart/oauth-start.html.twig', ['login_path' => $this->loginPath]) ); }
[ "public", "function", "start", "(", "Request", "$", "request", ",", "AuthenticationException", "$", "authException", "=", "null", ")", "{", "return", "new", "Response", "(", "$", "this", "->", "twig", "->", "render", "(", "'@StarterKitStart/oauth-start.html.twig'"...
This will be fired when the user clicks cancel on slack or third party site. This page will redirect the user back to the login path. @param Request $request @param AuthenticationException|null $authException @return Response
[ "This", "will", "be", "fired", "when", "the", "user", "clicks", "cancel", "on", "slack", "or", "third", "party", "site", ".", "This", "page", "will", "redirect", "the", "user", "back", "to", "the", "login", "path", "." ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/OAuth/OAuthGuard.php#L137-L142
train
Mihai-P/yii2-core
controllers/DefaultController.php
DefaultController.actionLogin
public function actionLogin() { $model = new LoginForm(); //make the captcha required if the unsuccessful attempts are more of thee if ($this->getLoginAttempts() >= $this->module->attemptsBeforeCaptcha) { $model->scenario = 'withCaptcha'; } if(Yii::$app->request->post()) { if($model->load($_POST) && $model->login()) { $this->setLoginAttempts(0); //if login is successful, reset the attempts return $this->goBack(); } else { //if login is not successful, increase the attempts $this->setLoginAttempts($this->getLoginAttempts() + 1); } } return $this->render('login', [ 'model' => $model, ]); }
php
public function actionLogin() { $model = new LoginForm(); //make the captcha required if the unsuccessful attempts are more of thee if ($this->getLoginAttempts() >= $this->module->attemptsBeforeCaptcha) { $model->scenario = 'withCaptcha'; } if(Yii::$app->request->post()) { if($model->load($_POST) && $model->login()) { $this->setLoginAttempts(0); //if login is successful, reset the attempts return $this->goBack(); } else { //if login is not successful, increase the attempts $this->setLoginAttempts($this->getLoginAttempts() + 1); } } return $this->render('login', [ 'model' => $model, ]); }
[ "public", "function", "actionLogin", "(", ")", "{", "$", "model", "=", "new", "LoginForm", "(", ")", ";", "//make the captcha required if the unsuccessful attempts are more of thee", "if", "(", "$", "this", "->", "getLoginAttempts", "(", ")", ">=", "$", "this", "-...
Shows the login form @return string|\yii\web\Response
[ "Shows", "the", "login", "form" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/controllers/DefaultController.php#L85-L106
train
reliv/Rcm
admin/src/Controller/PagePermissionsController.php
PagePermissionsController.pagePermissionsAction
public function pagePermissionsAction() { $view = new ViewModel(); //fixes rendering site's header and footer in the dialog $view->setTerminal(true); /** @var \Rcm\Entity\Site $currentSite */ $currentSite = $this->getServiceLocator()->get( \Rcm\Service\CurrentSite::class ); $currentSiteId = $currentSite->getSiteId(); $sourcePageName = $this->getEvent() ->getRouteMatch() ->getParam( 'rcmPageName', 'index' ); $pageType = $this->getEvent() ->getRouteMatch() ->getParam( 'rcmPageType', 'n' ); /** @var ResourceName $resourceName */ $resourceName = $this->getServiceLocator()->get( ResourceName::class ); $resourceId = $resourceName->get( ResourceName::RESOURCE_SITES, $currentSiteId, ResourceName::RESOURCE_PAGES, $pageType, $sourcePageName ); /** @var \RcmUser\Acl\Service\AclDataService $aclDataService */ $aclDataService = $this->getServiceLocator()->get( \RcmUser\Acl\Service\AclDataService::class ); //getting all set rules by resource Id $rules = $aclDataService->getRulesByResource($resourceId)->getData(); //getting list of all dynamically created roles $allRoles = $aclDataService->getNamespacedRoles()->getData(); $rolesHasRules = []; foreach ($rules as $setRuleFor) { //getting only the ones that are allow if ($setRuleFor->getRule() == 'allow') { $rolesHasRules[] = $setRuleFor->getRoleId(); } } $selectedRoles = []; foreach ($allRoles as $key => $role) { $roleId = $role->getRoleId(); if (in_array($roleId, $rolesHasRules)) { $selectedRoles[$roleId] = $role; } } $data = [ 'siteId' => $currentSiteId, 'pageType' => $pageType, 'pageName' => $sourcePageName, 'roles' => $allRoles, 'selectedRoles' => $selectedRoles, ]; $view->setVariable('data', $data); $view->setVariable( 'rcmPageName', $sourcePageName ); $view->setVariable( 'rcmPageType', $pageType ); return $view; }
php
public function pagePermissionsAction() { $view = new ViewModel(); //fixes rendering site's header and footer in the dialog $view->setTerminal(true); /** @var \Rcm\Entity\Site $currentSite */ $currentSite = $this->getServiceLocator()->get( \Rcm\Service\CurrentSite::class ); $currentSiteId = $currentSite->getSiteId(); $sourcePageName = $this->getEvent() ->getRouteMatch() ->getParam( 'rcmPageName', 'index' ); $pageType = $this->getEvent() ->getRouteMatch() ->getParam( 'rcmPageType', 'n' ); /** @var ResourceName $resourceName */ $resourceName = $this->getServiceLocator()->get( ResourceName::class ); $resourceId = $resourceName->get( ResourceName::RESOURCE_SITES, $currentSiteId, ResourceName::RESOURCE_PAGES, $pageType, $sourcePageName ); /** @var \RcmUser\Acl\Service\AclDataService $aclDataService */ $aclDataService = $this->getServiceLocator()->get( \RcmUser\Acl\Service\AclDataService::class ); //getting all set rules by resource Id $rules = $aclDataService->getRulesByResource($resourceId)->getData(); //getting list of all dynamically created roles $allRoles = $aclDataService->getNamespacedRoles()->getData(); $rolesHasRules = []; foreach ($rules as $setRuleFor) { //getting only the ones that are allow if ($setRuleFor->getRule() == 'allow') { $rolesHasRules[] = $setRuleFor->getRoleId(); } } $selectedRoles = []; foreach ($allRoles as $key => $role) { $roleId = $role->getRoleId(); if (in_array($roleId, $rolesHasRules)) { $selectedRoles[$roleId] = $role; } } $data = [ 'siteId' => $currentSiteId, 'pageType' => $pageType, 'pageName' => $sourcePageName, 'roles' => $allRoles, 'selectedRoles' => $selectedRoles, ]; $view->setVariable('data', $data); $view->setVariable( 'rcmPageName', $sourcePageName ); $view->setVariable( 'rcmPageType', $pageType ); return $view; }
[ "public", "function", "pagePermissionsAction", "(", ")", "{", "$", "view", "=", "new", "ViewModel", "(", ")", ";", "//fixes rendering site's header and footer in the dialog", "$", "view", "->", "setTerminal", "(", "true", ")", ";", "/** @var \\Rcm\\Entity\\Site $current...
Getting all Roles list and rules if role has one @return ViewModel
[ "Getting", "all", "Roles", "list", "and", "rules", "if", "role", "has", "one" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Controller/PagePermissionsController.php#L36-L126
train
phptuts/StarterBundleForSymfony
src/Entity/BaseUser.php
BaseUser.singleView
public function singleView() { return [ 'id' => $this->getId(), 'displayName' => $this->getDisplayName(), 'roles' => $this->getRoles(), 'email' => $this->getEmail(), 'bio' => $this->getBio() ]; }
php
public function singleView() { return [ 'id' => $this->getId(), 'displayName' => $this->getDisplayName(), 'roles' => $this->getRoles(), 'email' => $this->getEmail(), 'bio' => $this->getBio() ]; }
[ "public", "function", "singleView", "(", ")", "{", "return", "[", "'id'", "=>", "$", "this", "->", "getId", "(", ")", ",", "'displayName'", "=>", "$", "this", "->", "getDisplayName", "(", ")", ",", "'roles'", "=>", "$", "this", "->", "getRoles", "(", ...
Return an array of the view for displaying as a single item @return array
[ "Return", "an", "array", "of", "the", "view", "for", "displaying", "as", "a", "single", "item" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Entity/BaseUser.php#L480-L489
train
noodle69/EdgarEzUICronBundle
src/lib/Form/Factory/FormFactory.php
FormFactory.updateCron
public function updateCron( EdgarEzCron $data, ?string $name = null ): ?FormInterface { $name = $name ?: sprintf('update-cron-%s', $data->getAlias()); return $this->formFactory->createNamed( $name, CronType::class, $data, [ 'method' => Request::METHOD_POST, 'csrf_protection' => true, ] ); }
php
public function updateCron( EdgarEzCron $data, ?string $name = null ): ?FormInterface { $name = $name ?: sprintf('update-cron-%s', $data->getAlias()); return $this->formFactory->createNamed( $name, CronType::class, $data, [ 'method' => Request::METHOD_POST, 'csrf_protection' => true, ] ); }
[ "public", "function", "updateCron", "(", "EdgarEzCron", "$", "data", ",", "?", "string", "$", "name", "=", "null", ")", ":", "?", "FormInterface", "{", "$", "name", "=", "$", "name", "?", ":", "sprintf", "(", "'update-cron-%s'", ",", "$", "data", "->",...
Cron form interface. @param EdgarEzCron $data @param null|string $name @return null|FormInterface
[ "Cron", "form", "interface", "." ]
54f31e1cd13a9fddc0d67b0481333ed64849c70a
https://github.com/noodle69/EdgarEzUICronBundle/blob/54f31e1cd13a9fddc0d67b0481333ed64849c70a/src/lib/Form/Factory/FormFactory.php#L37-L52
train
GoIntegro/hateoas
Metadata/Resource/EntityMetadataMiner.php
EntityMetadataMiner.isLinkOnlyRelation
private static function isLinkOnlyRelation( \ReflectionClass $class, $name ) { $getterName = 'get' . Inflector::camelize($name); return !$class->hasMethod($getterName) || !Reflection::isMethodGetter($class->getMethod($getterName)); }
php
private static function isLinkOnlyRelation( \ReflectionClass $class, $name ) { $getterName = 'get' . Inflector::camelize($name); return !$class->hasMethod($getterName) || !Reflection::isMethodGetter($class->getMethod($getterName)); }
[ "private", "static", "function", "isLinkOnlyRelation", "(", "\\", "ReflectionClass", "$", "class", ",", "$", "name", ")", "{", "$", "getterName", "=", "'get'", ".", "Inflector", "::", "camelize", "(", "$", "name", ")", ";", "return", "!", "$", "class", "...
Para relaciones que no van en el campo "links" del resource object. @param \ReflectionClass $class @param string $name @return boolean @see http://jsonapi.org/format/#document-structure-url-templates
[ "Para", "relaciones", "que", "no", "van", "en", "el", "campo", "links", "del", "resource", "object", "." ]
4799794294079f8bd3839e76175134219f876105
https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/Metadata/Resource/EntityMetadataMiner.php#L155-L164
train
proem/proem
lib/Proem/Util/Loader/Autoloader.php
Autoloader.attachNamespace
public function attachNamespace($namespace, $paths) { if (isset($this->namespaces[$namespace])) { if (is_array($paths)) { $this->namespaces[$namespace] = array_merge($this->namespaces[$namespace], $paths); } else { $this->namespaces[$namespace][] = $paths; } } else { $this->namespaces[$namespace] = (array) $paths; } return $this; }
php
public function attachNamespace($namespace, $paths) { if (isset($this->namespaces[$namespace])) { if (is_array($paths)) { $this->namespaces[$namespace] = array_merge($this->namespaces[$namespace], $paths); } else { $this->namespaces[$namespace][] = $paths; } } else { $this->namespaces[$namespace] = (array) $paths; } return $this; }
[ "public", "function", "attachNamespace", "(", "$", "namespace", ",", "$", "paths", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "namespaces", "[", "$", "namespace", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "paths", ")", ")", "{...
Register a namespace. @param string $namespace The namespace @param array|string $paths The path to the namespace
[ "Register", "a", "namespace", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Util/Loader/Autoloader.php#L112-L125
train
proem/proem
lib/Proem/Util/Loader/Autoloader.php
Autoloader.attachPearPrefixes
public function attachPearPrefixes(array $classes) { foreach ($classes as $prefix => $paths) { $this->attachPearPrefix($prefix, $paths); } return $this; }
php
public function attachPearPrefixes(array $classes) { foreach ($classes as $prefix => $paths) { $this->attachPearPrefix($prefix, $paths); } return $this; }
[ "public", "function", "attachPearPrefixes", "(", "array", "$", "classes", ")", "{", "foreach", "(", "$", "classes", "as", "$", "prefix", "=>", "$", "paths", ")", "{", "$", "this", "->", "attachPearPrefix", "(", "$", "prefix", ",", "$", "paths", ")", ";...
Registers an array of classes using the Pear naming convention @param array $classes
[ "Registers", "an", "array", "of", "classes", "using", "the", "Pear", "naming", "convention" ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Util/Loader/Autoloader.php#L132-L138
train
mrclay/Props
src/Props/Container.php
Container.setValue
public function setValue($name, $value) { unset($this->factories[$name]); $this->cache[$name] = $value; }
php
public function setValue($name, $value) { unset($this->factories[$name]); $this->cache[$name] = $value; }
[ "public", "function", "setValue", "(", "$", "name", ",", "$", "value", ")", "{", "unset", "(", "$", "this", "->", "factories", "[", "$", "name", "]", ")", ";", "$", "this", "->", "cache", "[", "$", "name", "]", "=", "$", "value", ";", "}" ]
Set a value to be later returned as is. You only need to use this if you wish to store a Closure. @param string $name @param mixed $value @throws \InvalidArgumentException
[ "Set", "a", "value", "to", "be", "later", "returned", "as", "is", ".", "You", "only", "need", "to", "use", "this", "if", "you", "wish", "to", "store", "a", "Closure", "." ]
f3c0fc62b4fe528d237475a662e953834a87bdb0
https://github.com/mrclay/Props/blob/f3c0fc62b4fe528d237475a662e953834a87bdb0/src/Props/Container.php#L78-L82
train
mrclay/Props
src/Props/Container.php
Container.extend
public function extend($name, $extender) { if (!is_callable($extender, true)) { throw new FactoryUncallableException('$extender must appear callable'); } if (!array_key_exists($name, $this->factories)) { throw new NotFoundException("No factory available for: $name"); } $factory = $this->factories[$name]; $newFactory = function (Container $c) use ($extender, $factory) { return call_user_func($extender, call_user_func($factory, $c), $c); }; $this->setFactory($name, $newFactory); return $newFactory; }
php
public function extend($name, $extender) { if (!is_callable($extender, true)) { throw new FactoryUncallableException('$extender must appear callable'); } if (!array_key_exists($name, $this->factories)) { throw new NotFoundException("No factory available for: $name"); } $factory = $this->factories[$name]; $newFactory = function (Container $c) use ($extender, $factory) { return call_user_func($extender, call_user_func($factory, $c), $c); }; $this->setFactory($name, $newFactory); return $newFactory; }
[ "public", "function", "extend", "(", "$", "name", ",", "$", "extender", ")", "{", "if", "(", "!", "is_callable", "(", "$", "extender", ",", "true", ")", ")", "{", "throw", "new", "FactoryUncallableException", "(", "'$extender must appear callable'", ")", ";"...
Add a function that gets applied to the return value of an existing factory @note A cached value (from a previous property read) will thrown away. The next property read (and all new_NAME() calls) will call the original factory. @param string $name The name of the value @param callable $extender Function that is applied to extend the returned value @return \Closure @throws FactoryUncallableException|NotFoundException
[ "Add", "a", "function", "that", "gets", "applied", "to", "the", "return", "value", "of", "an", "existing", "factory" ]
f3c0fc62b4fe528d237475a662e953834a87bdb0
https://github.com/mrclay/Props/blob/f3c0fc62b4fe528d237475a662e953834a87bdb0/src/Props/Container.php#L182-L201
train
mrclay/Props
src/Props/Container.php
Container.getKeys
public function getKeys() { $keys = array_keys($this->cache) + array_keys($this->factories); return array_unique($keys); }
php
public function getKeys() { $keys = array_keys($this->cache) + array_keys($this->factories); return array_unique($keys); }
[ "public", "function", "getKeys", "(", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "this", "->", "cache", ")", "+", "array_keys", "(", "$", "this", "->", "factories", ")", ";", "return", "array_unique", "(", "$", "keys", ")", ";", "}" ]
Get all keys available @return string[]
[ "Get", "all", "keys", "available" ]
f3c0fc62b4fe528d237475a662e953834a87bdb0
https://github.com/mrclay/Props/blob/f3c0fc62b4fe528d237475a662e953834a87bdb0/src/Props/Container.php#L208-L212
train
andreas-glaser/php-helpers
src/JsonHelper.php
JsonHelper.isValid
public static function isValid($string) { if (is_int($string) || is_float($string)) { return true; } json_decode($string); return json_last_error() === JSON_ERROR_NONE; }
php
public static function isValid($string) { if (is_int($string) || is_float($string)) { return true; } json_decode($string); return json_last_error() === JSON_ERROR_NONE; }
[ "public", "static", "function", "isValid", "(", "$", "string", ")", "{", "if", "(", "is_int", "(", "$", "string", ")", "||", "is_float", "(", "$", "string", ")", ")", "{", "return", "true", ";", "}", "json_decode", "(", "$", "string", ")", ";", "re...
Validates JSON input. @param $string @return bool
[ "Validates", "JSON", "input", "." ]
84d8b98b72d01c262a5df0fb8545cb80a63afcc4
https://github.com/andreas-glaser/php-helpers/blob/84d8b98b72d01c262a5df0fb8545cb80a63afcc4/src/JsonHelper.php#L20-L29
train
laravelflare/flare
src/Flare/Providers/RouteServiceProvider.php
RouteServiceProvider.adminController
protected function adminController($route = null) { if ($route) { return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController@'.$route; } return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController'; }
php
protected function adminController($route = null) { if ($route) { return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController@'.$route; } return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController'; }
[ "protected", "function", "adminController", "(", "$", "route", "=", "null", ")", "{", "if", "(", "$", "route", ")", "{", "return", "$", "this", "->", "namespace", ".", "'\\\\'", ".", "$", "this", "->", "compatibilityVersion", ".", "'\\AdminController@'", "...
Return the Controller or Controller and Route if provided. @param string $route @return string
[ "Return", "the", "Controller", "or", "Controller", "and", "Route", "if", "provided", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Providers/RouteServiceProvider.php#L83-L90
train
Mihai-P/yii2-core
components/CsvAction.php
CsvAction.run
public function run() { $this->controller->getSearchCriteria(); $this->controller->dataProvider->pagination = false; $query = $this->controller->dataProvider->query; $config = new ExporterConfig(); $exporter = new Exporter($config); $result = $query->asArray()->all(); $fields = $this->fields; $values = array_map(function ($ar) use ($fields) { //$values = array_map(function () use ($fields) { $return = []; foreach($fields as $field) { $keyString = "['" . str_replace('.', "']['", $field) . "']"; eval("\$return[] = \$ar".$keyString.";"); } return $return; }, $result); if(isset($_GET['test'])) { return json_encode(array_merge([$this->fields], $values)); } else { $this->setHttpHeaders('csv', $this->controller->getCompatibilityId(), 'text/plain'); $exporter->export('php://output', array_merge([$this->fields], $values)); } }
php
public function run() { $this->controller->getSearchCriteria(); $this->controller->dataProvider->pagination = false; $query = $this->controller->dataProvider->query; $config = new ExporterConfig(); $exporter = new Exporter($config); $result = $query->asArray()->all(); $fields = $this->fields; $values = array_map(function ($ar) use ($fields) { //$values = array_map(function () use ($fields) { $return = []; foreach($fields as $field) { $keyString = "['" . str_replace('.', "']['", $field) . "']"; eval("\$return[] = \$ar".$keyString.";"); } return $return; }, $result); if(isset($_GET['test'])) { return json_encode(array_merge([$this->fields], $values)); } else { $this->setHttpHeaders('csv', $this->controller->getCompatibilityId(), 'text/plain'); $exporter->export('php://output', array_merge([$this->fields], $values)); } }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "controller", "->", "getSearchCriteria", "(", ")", ";", "$", "this", "->", "controller", "->", "dataProvider", "->", "pagination", "=", "false", ";", "$", "query", "=", "$", "this", "->", "...
Creates the pdf file for download
[ "Creates", "the", "pdf", "file", "for", "download" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/CsvAction.php#L50-L75
train
Mihai-P/yii2-core
components/CsvAction.php
CsvAction.setHttpHeaders
protected function setHttpHeaders($type, $name, $mime, $encoding = 'utf-8') { Yii::$app->response->format = Response::FORMAT_RAW; if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") == false) { header("Cache-Control: no-cache"); header("Pragma: no-cache"); } else { header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: public"); } header("Expires: Sat, 26 Jul 1979 05:00:00 GMT"); header("Content-Encoding: {$encoding}"); header("Content-Type: {$mime}; charset={$encoding}"); header("Content-Disposition: attachment; filename={$name}.{$type}"); header("Cache-Control: max-age=0"); }
php
protected function setHttpHeaders($type, $name, $mime, $encoding = 'utf-8') { Yii::$app->response->format = Response::FORMAT_RAW; if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") == false) { header("Cache-Control: no-cache"); header("Pragma: no-cache"); } else { header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: public"); } header("Expires: Sat, 26 Jul 1979 05:00:00 GMT"); header("Content-Encoding: {$encoding}"); header("Content-Type: {$mime}; charset={$encoding}"); header("Content-Disposition: attachment; filename={$name}.{$type}"); header("Cache-Control: max-age=0"); }
[ "protected", "function", "setHttpHeaders", "(", "$", "type", ",", "$", "name", ",", "$", "mime", ",", "$", "encoding", "=", "'utf-8'", ")", "{", "Yii", "::", "$", "app", "->", "response", "->", "format", "=", "Response", "::", "FORMAT_RAW", ";", "if", ...
Sets the HTTP headers needed by file download action.
[ "Sets", "the", "HTTP", "headers", "needed", "by", "file", "download", "action", "." ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/CsvAction.php#L81-L96
train
reliv/Rcm
core/src/Acl/ResourceProvider.php
ResourceProvider.getResource
public function getResource($resourceId) { if (isset($this->resources[$resourceId])) { return $this->resources[$resourceId]; } $dynamicResource = $this->dynamicResourceMapper($resourceId); if (!empty($dynamicResource)) { return $dynamicResource; } return null; }
php
public function getResource($resourceId) { if (isset($this->resources[$resourceId])) { return $this->resources[$resourceId]; } $dynamicResource = $this->dynamicResourceMapper($resourceId); if (!empty($dynamicResource)) { return $dynamicResource; } return null; }
[ "public", "function", "getResource", "(", "$", "resourceId", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "resources", "[", "$", "resourceId", "]", ")", ")", "{", "return", "$", "this", "->", "resources", "[", "$", "resourceId", "]", ";", "}...
getResource Return the requested resource Can be used to return resources dynamically at run-time @param string $resourceId resourceId @return array|null
[ "getResource", "Return", "the", "requested", "resource", "Can", "be", "used", "to", "return", "resources", "dynamically", "at", "run", "-", "time" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Acl/ResourceProvider.php#L95-L108
train
reliv/Rcm
core/src/Acl/ResourceProvider.php
ResourceProvider.dynamicResourceMapper
protected function dynamicResourceMapper($resourceId) { // Page Resource Mapper $resource = $this->pageResourceMapper($resourceId); if (!empty($resource)) { return $resource; } $resource = $this->siteResourceMapper($resourceId); if (!empty($resource)) { return $resource; } return null; }
php
protected function dynamicResourceMapper($resourceId) { // Page Resource Mapper $resource = $this->pageResourceMapper($resourceId); if (!empty($resource)) { return $resource; } $resource = $this->siteResourceMapper($resourceId); if (!empty($resource)) { return $resource; } return null; }
[ "protected", "function", "dynamicResourceMapper", "(", "$", "resourceId", ")", "{", "// Page Resource Mapper", "$", "resource", "=", "$", "this", "->", "pageResourceMapper", "(", "$", "resourceId", ")", ";", "if", "(", "!", "empty", "(", "$", "resource", ")", ...
Dynamic Resource Mapper for Get Resource @param string $resourceId Dynamic Resource ID to generate @return array|null
[ "Dynamic", "Resource", "Mapper", "for", "Get", "Resource" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Acl/ResourceProvider.php#L140-L156
train
reliv/Rcm
core/src/Acl/ResourceProvider.php
ResourceProvider.pageResourceMapper
protected function pageResourceMapper($resourceId) { if (!$this->resourceName->isPagesResourceId($resourceId)) { return null; } $resources = explode('.', $resourceId); if (empty($resources[1])) { return null; } $siteResourceId = $this->resourceName->get(self::RESOURCE_SITES, $resources[1]); $return = [ 'resourceId' => $resourceId, 'parentResourceId' => $siteResourceId, ]; if ($this->resourceName->isPageResourceId($resourceId)) { $pagesResourceId = $this->resourceName->get(self::RESOURCE_SITES, $resources[1], self::RESOURCE_PAGES); $return['parentResourceId'] = $pagesResourceId; } return array_merge( $this->resources[self::RESOURCE_PAGES], $return ); }
php
protected function pageResourceMapper($resourceId) { if (!$this->resourceName->isPagesResourceId($resourceId)) { return null; } $resources = explode('.', $resourceId); if (empty($resources[1])) { return null; } $siteResourceId = $this->resourceName->get(self::RESOURCE_SITES, $resources[1]); $return = [ 'resourceId' => $resourceId, 'parentResourceId' => $siteResourceId, ]; if ($this->resourceName->isPageResourceId($resourceId)) { $pagesResourceId = $this->resourceName->get(self::RESOURCE_SITES, $resources[1], self::RESOURCE_PAGES); $return['parentResourceId'] = $pagesResourceId; } return array_merge( $this->resources[self::RESOURCE_PAGES], $return ); }
[ "protected", "function", "pageResourceMapper", "(", "$", "resourceId", ")", "{", "if", "(", "!", "$", "this", "->", "resourceName", "->", "isPagesResourceId", "(", "$", "resourceId", ")", ")", "{", "return", "null", ";", "}", "$", "resources", "=", "explod...
Page Resource Mapper @param string $resourceId Resource Id to search @return array|null
[ "Page", "Resource", "Mapper" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Acl/ResourceProvider.php#L165-L193
train
reliv/Rcm
core/src/Acl/ResourceProvider.php
ResourceProvider.siteResourceMapper
protected function siteResourceMapper($resourceId) { if (!$this->resourceName->isSitesResourceId($resourceId)) { return null; } $sitesResourceId = $this->resourceName->get(self::RESOURCE_SITES); $return = [ 'resourceId' => $resourceId, 'parentResourceId' => $sitesResourceId, ]; return array_merge( $this->resources[self::RESOURCE_SITES], $return ); }
php
protected function siteResourceMapper($resourceId) { if (!$this->resourceName->isSitesResourceId($resourceId)) { return null; } $sitesResourceId = $this->resourceName->get(self::RESOURCE_SITES); $return = [ 'resourceId' => $resourceId, 'parentResourceId' => $sitesResourceId, ]; return array_merge( $this->resources[self::RESOURCE_SITES], $return ); }
[ "protected", "function", "siteResourceMapper", "(", "$", "resourceId", ")", "{", "if", "(", "!", "$", "this", "->", "resourceName", "->", "isSitesResourceId", "(", "$", "resourceId", ")", ")", "{", "return", "null", ";", "}", "$", "sitesResourceId", "=", "...
Site Resource Mapper @param string $resourceId Resource Id to search @return array|null
[ "Site", "Resource", "Mapper" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Acl/ResourceProvider.php#L202-L219
train
reliv/Rcm
core/src/Acl/ResourceProvider.php
ResourceProvider.getSiteResources
protected function getSiteResources(Site $site) { $primaryDomain = $site->getDomain(); if (empty($primaryDomain)) { // no resources if domain missing return array(); } $primaryDomainName = $primaryDomain->getDomainName(); $siteId = $site->getSiteId(); $sitesResourceId = $this->resourceName->get(self::RESOURCE_SITES); $siteResourceId = $this->resourceName->get(self::RESOURCE_SITES, $siteId); $return[$siteResourceId] = [ 'resourceId' => $siteResourceId, 'parentResourceId' => $sitesResourceId, 'name' => $primaryDomainName, 'description' => "Resource for site '{$primaryDomainName}'" ]; $return[$siteResourceId] = array_merge( $this->resources[$sitesResourceId], $return[$siteResourceId] ); $pagesResourceId = $this->resourceName->get(self::RESOURCE_SITES, $siteId, self::RESOURCE_PAGES); $return[$pagesResourceId] = [ 'resourceId' => $pagesResourceId, 'parentResourceId' => $siteResourceId, 'name' => $primaryDomainName . ' - pages', 'description' => "Resource for pages on site '{$primaryDomainName}'" ]; $return[$pagesResourceId] = array_merge( $this->resources[self::RESOURCE_PAGES], $return[$pagesResourceId] ); $pages = $site->getPages(); /** @var \Rcm\Entity\Page $page */ foreach ($pages as &$page) { $pageResources = $this->getPageResources($page, $site); $return = array_merge($pageResources, $return); } return $return; }
php
protected function getSiteResources(Site $site) { $primaryDomain = $site->getDomain(); if (empty($primaryDomain)) { // no resources if domain missing return array(); } $primaryDomainName = $primaryDomain->getDomainName(); $siteId = $site->getSiteId(); $sitesResourceId = $this->resourceName->get(self::RESOURCE_SITES); $siteResourceId = $this->resourceName->get(self::RESOURCE_SITES, $siteId); $return[$siteResourceId] = [ 'resourceId' => $siteResourceId, 'parentResourceId' => $sitesResourceId, 'name' => $primaryDomainName, 'description' => "Resource for site '{$primaryDomainName}'" ]; $return[$siteResourceId] = array_merge( $this->resources[$sitesResourceId], $return[$siteResourceId] ); $pagesResourceId = $this->resourceName->get(self::RESOURCE_SITES, $siteId, self::RESOURCE_PAGES); $return[$pagesResourceId] = [ 'resourceId' => $pagesResourceId, 'parentResourceId' => $siteResourceId, 'name' => $primaryDomainName . ' - pages', 'description' => "Resource for pages on site '{$primaryDomainName}'" ]; $return[$pagesResourceId] = array_merge( $this->resources[self::RESOURCE_PAGES], $return[$pagesResourceId] ); $pages = $site->getPages(); /** @var \Rcm\Entity\Page $page */ foreach ($pages as &$page) { $pageResources = $this->getPageResources($page, $site); $return = array_merge($pageResources, $return); } return $return; }
[ "protected", "function", "getSiteResources", "(", "Site", "$", "site", ")", "{", "$", "primaryDomain", "=", "$", "site", "->", "getDomain", "(", ")", ";", "if", "(", "empty", "(", "$", "primaryDomain", ")", ")", "{", "// no resources if domain missing", "ret...
Get all resources for a site @param Site $site Rcm Site Entity @return array
[ "Get", "all", "resources", "for", "a", "site" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Acl/ResourceProvider.php#L228-L278
train
reliv/Rcm
core/src/Acl/ResourceProvider.php
ResourceProvider.getPageResources
protected function getPageResources(Page $page, Site $site) { $primaryDomainName = $site->getDomain()->getDomainName(); $siteId = $site->getSiteId(); $pageName = $page->getName(); $pageType = $page->getPageType(); $pagesResourceId = $this->resourceName->get(self::RESOURCE_SITES, $siteId, self::RESOURCE_PAGES); $pageResourceId = $this->resourceName->get( self::RESOURCE_SITES, $siteId, self::RESOURCE_PAGES, $pageType, $pageName ); $return[$pageResourceId] = [ 'resourceId' => $pageResourceId, 'parentResourceId' => $pagesResourceId, 'name' => $primaryDomainName . ' - pages - ' . $pageName, 'description' => "Resource for page '{$pageName}'" . " of type '{$pageType}' on site '{$primaryDomainName}'" ]; $return[$pageResourceId] = array_merge( $this->resources[self::RESOURCE_PAGES], $return[$pageResourceId] ); return $return; }
php
protected function getPageResources(Page $page, Site $site) { $primaryDomainName = $site->getDomain()->getDomainName(); $siteId = $site->getSiteId(); $pageName = $page->getName(); $pageType = $page->getPageType(); $pagesResourceId = $this->resourceName->get(self::RESOURCE_SITES, $siteId, self::RESOURCE_PAGES); $pageResourceId = $this->resourceName->get( self::RESOURCE_SITES, $siteId, self::RESOURCE_PAGES, $pageType, $pageName ); $return[$pageResourceId] = [ 'resourceId' => $pageResourceId, 'parentResourceId' => $pagesResourceId, 'name' => $primaryDomainName . ' - pages - ' . $pageName, 'description' => "Resource for page '{$pageName}'" . " of type '{$pageType}' on site '{$primaryDomainName}'" ]; $return[$pageResourceId] = array_merge( $this->resources[self::RESOURCE_PAGES], $return[$pageResourceId] ); return $return; }
[ "protected", "function", "getPageResources", "(", "Page", "$", "page", ",", "Site", "$", "site", ")", "{", "$", "primaryDomainName", "=", "$", "site", "->", "getDomain", "(", ")", "->", "getDomainName", "(", ")", ";", "$", "siteId", "=", "$", "site", "...
Get all Page Resources @param Page $page Rcm Page Entity @param Site $site Rcm Site Entity @return mixed
[ "Get", "all", "Page", "Resources" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Acl/ResourceProvider.php#L288-L317
train
RogerWaters/react-thread-pool
src/EventLoop/ForkableLibEventLoop.php
ForkableLibEventLoop.subscribeStreamEvent
private function subscribeStreamEvent($stream, $flag) { $key = (int) $stream; if (isset($this->streamEvents[$key])) { $event = $this->streamEvents[$key]; $flags = $this->streamFlags[$key] |= $flag; event_del($event); event_set($event, $stream, EV_PERSIST | $flags, $this->streamCallback); } else { $event = event_new(); event_set($event, $stream, EV_PERSIST | $flag, $this->streamCallback); event_base_set($event, $this->eventBase); $this->streamEvents[$key] = $event; $this->streamFlags[$key] = $flag; } event_add($event); }
php
private function subscribeStreamEvent($stream, $flag) { $key = (int) $stream; if (isset($this->streamEvents[$key])) { $event = $this->streamEvents[$key]; $flags = $this->streamFlags[$key] |= $flag; event_del($event); event_set($event, $stream, EV_PERSIST | $flags, $this->streamCallback); } else { $event = event_new(); event_set($event, $stream, EV_PERSIST | $flag, $this->streamCallback); event_base_set($event, $this->eventBase); $this->streamEvents[$key] = $event; $this->streamFlags[$key] = $flag; } event_add($event); }
[ "private", "function", "subscribeStreamEvent", "(", "$", "stream", ",", "$", "flag", ")", "{", "$", "key", "=", "(", "int", ")", "$", "stream", ";", "if", "(", "isset", "(", "$", "this", "->", "streamEvents", "[", "$", "key", "]", ")", ")", "{", ...
Create a new ext-libevent event resource, or update the existing one. @param stream $stream @param integer $flag EV_READ or EV_WRITE
[ "Create", "a", "new", "ext", "-", "libevent", "event", "resource", "or", "update", "the", "existing", "one", "." ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/EventLoop/ForkableLibEventLoop.php#L253-L274
train
RogerWaters/react-thread-pool
src/EventLoop/ForkableLibEventLoop.php
ForkableLibEventLoop.unsubscribeStreamEvent
private function unsubscribeStreamEvent($stream, $flag) { $key = (int) $stream; $flags = $this->streamFlags[$key] &= ~$flag; if (0 === $flags) { $this->removeStream($stream); return; } $event = $this->streamEvents[$key]; event_del($event); event_set($event, $stream, EV_PERSIST | $flags, $this->streamCallback); event_add($event); }
php
private function unsubscribeStreamEvent($stream, $flag) { $key = (int) $stream; $flags = $this->streamFlags[$key] &= ~$flag; if (0 === $flags) { $this->removeStream($stream); return; } $event = $this->streamEvents[$key]; event_del($event); event_set($event, $stream, EV_PERSIST | $flags, $this->streamCallback); event_add($event); }
[ "private", "function", "unsubscribeStreamEvent", "(", "$", "stream", ",", "$", "flag", ")", "{", "$", "key", "=", "(", "int", ")", "$", "stream", ";", "$", "flags", "=", "$", "this", "->", "streamFlags", "[", "$", "key", "]", "&=", "~", "$", "flag"...
Update the ext-libevent event resource for this stream to stop listening to the given event type, or remove it entirely if it's no longer needed. @param stream $stream @param integer $flag EV_READ or EV_WRITE
[ "Update", "the", "ext", "-", "libevent", "event", "resource", "for", "this", "stream", "to", "stop", "listening", "to", "the", "given", "event", "type", "or", "remove", "it", "entirely", "if", "it", "s", "no", "longer", "needed", "." ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/EventLoop/ForkableLibEventLoop.php#L283-L300
train
RogerWaters/react-thread-pool
src/EventLoop/ForkableLibEventLoop.php
ForkableLibEventLoop.afterForkChild
public function afterForkChild() { //possible event base free? unset($this->eventBase); unset($this->nextTickQueue); unset($this->futureTickQueue); //bugfix lambda function destructed while executing -.- //unset($this->timerCallback); //unset($this->streamCallback); unset($this->timerEvents); unset($this->running); $this->streamEvents = array(); $this->streamFlags = array(); $this->readListeners = array(); $this->writeListeners = array(); //call constructor $this->__construct(); return $this; }
php
public function afterForkChild() { //possible event base free? unset($this->eventBase); unset($this->nextTickQueue); unset($this->futureTickQueue); //bugfix lambda function destructed while executing -.- //unset($this->timerCallback); //unset($this->streamCallback); unset($this->timerEvents); unset($this->running); $this->streamEvents = array(); $this->streamFlags = array(); $this->readListeners = array(); $this->writeListeners = array(); //call constructor $this->__construct(); return $this; }
[ "public", "function", "afterForkChild", "(", ")", "{", "//possible event base free?\r", "unset", "(", "$", "this", "->", "eventBase", ")", ";", "unset", "(", "$", "this", "->", "nextTickQueue", ")", ";", "unset", "(", "$", "this", "->", "futureTickQueue", ")...
called after each fork in child instance. should clean up ever resource bound to the parent process and should return an new stable instance or itself if reusable @return ForkableLoopInterface
[ "called", "after", "each", "fork", "in", "child", "instance", ".", "should", "clean", "up", "ever", "resource", "bound", "to", "the", "parent", "process", "and", "should", "return", "an", "new", "stable", "instance", "or", "itself", "if", "reusable" ]
cdbbe172f5953c84f6b412a7cea94e425ff065df
https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/EventLoop/ForkableLibEventLoop.php#L360-L378
train
russsiq/bixbite
app/Models/Relations/Categoryable.php
Categoryable.getCategoryAttribute
public function getCategoryAttribute() { if(is_null($category = $this->categories->last())) { $category = new \stdClass(); $category->title = 'No name'; $category->slug = 'none'; $category->alt_url = null; $category->template = null; } return $category; }
php
public function getCategoryAttribute() { if(is_null($category = $this->categories->last())) { $category = new \stdClass(); $category->title = 'No name'; $category->slug = 'none'; $category->alt_url = null; $category->template = null; } return $category; }
[ "public", "function", "getCategoryAttribute", "(", ")", "{", "if", "(", "is_null", "(", "$", "category", "=", "$", "this", "->", "categories", "->", "last", "(", ")", ")", ")", "{", "$", "category", "=", "new", "\\", "stdClass", "(", ")", ";", "$", ...
Get a attributes to first category @var array
[ "Get", "a", "attributes", "to", "first", "category" ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Relations/Categoryable.php#L26-L37
train
reliv/Rcm
admin/src/View/Helper/DisplayErrors.php
DisplayErrors.renderErrors
public function renderErrors($errors) { if (empty($errors)) { return null; } $message = ''; foreach ($errors as &$error) { foreach ($error as $errorCode => &$errorMsg) { $message .= $this->errorMapper($errorCode, $errorMsg); } } return $message; }
php
public function renderErrors($errors) { if (empty($errors)) { return null; } $message = ''; foreach ($errors as &$error) { foreach ($error as $errorCode => &$errorMsg) { $message .= $this->errorMapper($errorCode, $errorMsg); } } return $message; }
[ "public", "function", "renderErrors", "(", "$", "errors", ")", "{", "if", "(", "empty", "(", "$", "errors", ")", ")", "{", "return", "null", ";", "}", "$", "message", "=", "''", ";", "foreach", "(", "$", "errors", "as", "&", "$", "error", ")", "{...
Render errors in html @param array $errors Array of errors to display @return null|string
[ "Render", "errors", "in", "html" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/View/Helper/DisplayErrors.php#L41-L56
train
russsiq/bixbite
app/Http/Controllers/HomeController.php
HomeController.index
public function index() { pageinfo([ 'title' => setting('system.meta_title', 'BixBite'), 'description' => setting('system.meta_description', 'BixBite - Content Management System'), 'keywords' => setting('system.meta_keywords', 'BixBite CMS, BBCMS, CMS'), 'onHomePage' => true, ]); if (! setting('themes.home_page_personalized', false)) { return app('\BBCMS\Http\Controllers\ArticlesController')->index(); } return $this->makeResponse('index'); }
php
public function index() { pageinfo([ 'title' => setting('system.meta_title', 'BixBite'), 'description' => setting('system.meta_description', 'BixBite - Content Management System'), 'keywords' => setting('system.meta_keywords', 'BixBite CMS, BBCMS, CMS'), 'onHomePage' => true, ]); if (! setting('themes.home_page_personalized', false)) { return app('\BBCMS\Http\Controllers\ArticlesController')->index(); } return $this->makeResponse('index'); }
[ "public", "function", "index", "(", ")", "{", "pageinfo", "(", "[", "'title'", "=>", "setting", "(", "'system.meta_title'", ",", "'BixBite'", ")", ",", "'description'", "=>", "setting", "(", "'system.meta_description'", ",", "'BixBite - Content Management System'", ...
Show the application home page. @return \Illuminate\Http\Response
[ "Show", "the", "application", "home", "page", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Http/Controllers/HomeController.php#L21-L35
train
dadajuice/zephyrus
src/Zephyrus/Database/Database.php
Database.buildFromConfiguration
public static function buildFromConfiguration(): Database { if (!is_null(self::$sharedInstance)) { return self::$sharedInstance; } $config = Configuration::getDatabaseConfiguration(); $instance = self::initializeFromConfiguration($config); if ($config['shared'] ?? false) { self::$sharedInstance = $instance; } return $instance; }
php
public static function buildFromConfiguration(): Database { if (!is_null(self::$sharedInstance)) { return self::$sharedInstance; } $config = Configuration::getDatabaseConfiguration(); $instance = self::initializeFromConfiguration($config); if ($config['shared'] ?? false) { self::$sharedInstance = $instance; } return $instance; }
[ "public", "static", "function", "buildFromConfiguration", "(", ")", ":", "Database", "{", "if", "(", "!", "is_null", "(", "self", "::", "$", "sharedInstance", ")", ")", "{", "return", "self", "::", "$", "sharedInstance", ";", "}", "$", "config", "=", "Co...
Constructs a database instance from the defined configurations. @throws DatabaseException @return Database
[ "Constructs", "a", "database", "instance", "from", "the", "defined", "configurations", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Database/Database.php#L133-L144
train
webeweb/core-bundle
Navigation/NavigationTreeHelper.php
NavigationTreeHelper.activeNodes
protected static function activeNodes(Request $request, array $nodes = [], $level = 0) { $result = false; foreach ($nodes as $n) { if (false === ($n instanceof AbstractNavigationNode)) { continue; } if (true === self::nodeMatch($n, $request)) { $current = true; } else { $current = self::activeNodes($request, $n->getNodes(), $level + 1); } if (false === $current) { continue; } $n->setActive(true); $result = true; } return $result; }
php
protected static function activeNodes(Request $request, array $nodes = [], $level = 0) { $result = false; foreach ($nodes as $n) { if (false === ($n instanceof AbstractNavigationNode)) { continue; } if (true === self::nodeMatch($n, $request)) { $current = true; } else { $current = self::activeNodes($request, $n->getNodes(), $level + 1); } if (false === $current) { continue; } $n->setActive(true); $result = true; } return $result; }
[ "protected", "static", "function", "activeNodes", "(", "Request", "$", "request", ",", "array", "$", "nodes", "=", "[", "]", ",", "$", "level", "=", "0", ")", "{", "$", "result", "=", "false", ";", "foreach", "(", "$", "nodes", "as", "$", "n", ")",...
Actives the nodes. @param Request $request The request. @param array $nodes The nodes. @param int $level The node level. @return bool Returns true in case of success, false othewise.
[ "Actives", "the", "nodes", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Navigation/NavigationTreeHelper.php#L32-L58
train
webeweb/core-bundle
Navigation/NavigationTreeHelper.php
NavigationTreeHelper.activeTree
public static function activeTree(NavigationTree $tree, Request $request) { self::activeNodes($request, $tree->getNodes()); }
php
public static function activeTree(NavigationTree $tree, Request $request) { self::activeNodes($request, $tree->getNodes()); }
[ "public", "static", "function", "activeTree", "(", "NavigationTree", "$", "tree", ",", "Request", "$", "request", ")", "{", "self", "::", "activeNodes", "(", "$", "request", ",", "$", "tree", "->", "getNodes", "(", ")", ")", ";", "}" ]
Active the tree. @param NavigationTree $tree The tree. @param Request $request The request. @return void
[ "Active", "the", "tree", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Navigation/NavigationTreeHelper.php#L67-L69
train
webeweb/core-bundle
Navigation/NavigationTreeHelper.php
NavigationTreeHelper.getBreadcrumbs
public static function getBreadcrumbs(AbstractNavigationNode $node) { $breadcrumbs = []; if (true === ($node instanceof NavigationNode || $node instanceof BreadcrumbNode) && true === $node->getActive()) { $breadcrumbs[] = $node; } foreach ($node->getNodes() as $current) { if (false === ($current instanceof AbstractNavigationNode)) { continue; } $breadcrumbs = array_merge($breadcrumbs, self::getBreadcrumbs($current)); } return $breadcrumbs; }
php
public static function getBreadcrumbs(AbstractNavigationNode $node) { $breadcrumbs = []; if (true === ($node instanceof NavigationNode || $node instanceof BreadcrumbNode) && true === $node->getActive()) { $breadcrumbs[] = $node; } foreach ($node->getNodes() as $current) { if (false === ($current instanceof AbstractNavigationNode)) { continue; } $breadcrumbs = array_merge($breadcrumbs, self::getBreadcrumbs($current)); } return $breadcrumbs; }
[ "public", "static", "function", "getBreadcrumbs", "(", "AbstractNavigationNode", "$", "node", ")", "{", "$", "breadcrumbs", "=", "[", "]", ";", "if", "(", "true", "===", "(", "$", "node", "instanceof", "NavigationNode", "||", "$", "node", "instanceof", "Brea...
Get the breadcrumbs. @param AbstractNavigationNode $node The tree. @return AsbtractNavigationNode[] Returns the breadcrumbs.
[ "Get", "the", "breadcrumbs", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Navigation/NavigationTreeHelper.php#L77-L93
train
webeweb/core-bundle
Navigation/NavigationTreeHelper.php
NavigationTreeHelper.nodeMatch
protected static function nodeMatch(AbstractNavigationNode $node, Request $request) { $result = false; switch ($node->getMatcher()) { case NavigationInterface::NAVIGATION_MATCHER_REGEXP: $result = preg_match("/" . $node->getUri() . "/", $request->getUri()); break; case NavigationInterface::NAVIGATION_MATCHER_ROUTER: $result = $request->get("_route") === $node->getUri(); break; case NavigationInterface::NAVIGATION_MATCHER_URL: $result = $request->getUri() === $node->getUri() || $request->getRequestUri() === $node->getUri(); break; } return boolval($result); }
php
protected static function nodeMatch(AbstractNavigationNode $node, Request $request) { $result = false; switch ($node->getMatcher()) { case NavigationInterface::NAVIGATION_MATCHER_REGEXP: $result = preg_match("/" . $node->getUri() . "/", $request->getUri()); break; case NavigationInterface::NAVIGATION_MATCHER_ROUTER: $result = $request->get("_route") === $node->getUri(); break; case NavigationInterface::NAVIGATION_MATCHER_URL: $result = $request->getUri() === $node->getUri() || $request->getRequestUri() === $node->getUri(); break; } return boolval($result); }
[ "protected", "static", "function", "nodeMatch", "(", "AbstractNavigationNode", "$", "node", ",", "Request", "$", "request", ")", "{", "$", "result", "=", "false", ";", "switch", "(", "$", "node", "->", "getMatcher", "(", ")", ")", "{", "case", "NavigationI...
Determines if a node match an URL. @param AbstractNavigationNode $node The node. @param Request $request The request. @return bool Returns true in case of success, false otherwise.
[ "Determines", "if", "a", "node", "match", "an", "URL", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Navigation/NavigationTreeHelper.php#L102-L122
train
noodle69/EdgarEzUICronBundle
src/lib/Form/Type/CronType.php
CronType.buildForm
public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('expression', TextType::class, [ 'required' => true, 'constraints' => [new ExpressionConstraint()], ]) ->add('arguments', TextType::class, [ 'required' => false, 'constraints' => [new ArgumentsConstraint()], ]) ->add('priority', IntegerType::class, [ 'required' => true, ]) ->add('enabled', CheckboxType::class, [ 'required' => false, ]) ->add('update', SubmitType::class, [ 'label' => /** @Desc("Update") */ 'cron_update_form.update', ]); }
php
public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('expression', TextType::class, [ 'required' => true, 'constraints' => [new ExpressionConstraint()], ]) ->add('arguments', TextType::class, [ 'required' => false, 'constraints' => [new ArgumentsConstraint()], ]) ->add('priority', IntegerType::class, [ 'required' => true, ]) ->add('enabled', CheckboxType::class, [ 'required' => false, ]) ->add('update', SubmitType::class, [ 'label' => /** @Desc("Update") */ 'cron_update_form.update', ]); }
[ "public", "function", "buildForm", "(", "FormBuilderInterface", "$", "builder", ",", "array", "$", "options", ")", "{", "$", "builder", "->", "add", "(", "'expression'", ",", "TextType", "::", "class", ",", "[", "'required'", "=>", "true", ",", "'constraints...
Build cron form. @param FormBuilderInterface $builder @param array $options
[ "Build", "cron", "form", "." ]
54f31e1cd13a9fddc0d67b0481333ed64849c70a
https://github.com/noodle69/EdgarEzUICronBundle/blob/54f31e1cd13a9fddc0d67b0481333ed64849c70a/src/lib/Form/Type/CronType.php#L26-L47
train
andreas-glaser/php-helpers
src/Http/UrlHelper.php
UrlHelper.protocolHostPort
public static function protocolHostPort() { if (RequestHelper::isCli()) { return null; } $isHttps = RequestHelper::isHttps(); $protocol = 'http' . ($isHttps ? 's' : ''); $serverName = $_SERVER['SERVER_NAME']; $serverPort = (int)$_SERVER['SERVER_PORT']; $protocolHostPort = $protocol . '://'; if ((!$isHttps && $serverPort !== 80) || ($isHttps && $serverPort !== 443)) { $protocolHostPort .= $serverName . ':' . $serverPort; } else { $protocolHostPort .= $serverName; } return $protocolHostPort; }
php
public static function protocolHostPort() { if (RequestHelper::isCli()) { return null; } $isHttps = RequestHelper::isHttps(); $protocol = 'http' . ($isHttps ? 's' : ''); $serverName = $_SERVER['SERVER_NAME']; $serverPort = (int)$_SERVER['SERVER_PORT']; $protocolHostPort = $protocol . '://'; if ((!$isHttps && $serverPort !== 80) || ($isHttps && $serverPort !== 443)) { $protocolHostPort .= $serverName . ':' . $serverPort; } else { $protocolHostPort .= $serverName; } return $protocolHostPort; }
[ "public", "static", "function", "protocolHostPort", "(", ")", "{", "if", "(", "RequestHelper", "::", "isCli", "(", ")", ")", "{", "return", "null", ";", "}", "$", "isHttps", "=", "RequestHelper", "::", "isHttps", "(", ")", ";", "$", "protocol", "=", "'...
Returns string of protocol, server name and port of server-side configured values. e.g.: http://example.com http://example.com:8080 (if custom http port is used) https://example.com:444 (if custom https port is used) @return null|string
[ "Returns", "string", "of", "protocol", "server", "name", "and", "port", "of", "server", "-", "side", "configured", "values", "." ]
84d8b98b72d01c262a5df0fb8545cb80a63afcc4
https://github.com/andreas-glaser/php-helpers/blob/84d8b98b72d01c262a5df0fb8545cb80a63afcc4/src/Http/UrlHelper.php#L23-L43
train
andreas-glaser/php-helpers
src/Http/UrlHelper.php
UrlHelper.query
public static function query(array $parameters = null, bool $mergeGetVariables = true) { if ($mergeGetVariables) { if ($parameters === null) { $parameters = $_GET; } else { $parameters = array_replace_recursive($_GET, $parameters); } } if (empty($parameters)) { return null; } $query = http_build_query($parameters, '', '&'); return ($query === '') ? '' : ('?' . $query); }
php
public static function query(array $parameters = null, bool $mergeGetVariables = true) { if ($mergeGetVariables) { if ($parameters === null) { $parameters = $_GET; } else { $parameters = array_replace_recursive($_GET, $parameters); } } if (empty($parameters)) { return null; } $query = http_build_query($parameters, '', '&'); return ($query === '') ? '' : ('?' . $query); }
[ "public", "static", "function", "query", "(", "array", "$", "parameters", "=", "null", ",", "bool", "$", "mergeGetVariables", "=", "true", ")", "{", "if", "(", "$", "mergeGetVariables", ")", "{", "if", "(", "$", "parameters", "===", "null", ")", "{", "...
Builds query part of url. @param array $parameters @param bool $mergeGetVariables @return null|string
[ "Builds", "query", "part", "of", "url", "." ]
84d8b98b72d01c262a5df0fb8545cb80a63afcc4
https://github.com/andreas-glaser/php-helpers/blob/84d8b98b72d01c262a5df0fb8545cb80a63afcc4/src/Http/UrlHelper.php#L55-L72
train
russsiq/bixbite
app/Http/Controllers/BaseController.php
BaseController.makeResponse
protected function makeResponse(string $template, array $vars = []) { if (request()->ajax()) { return $this->jsonOutput($vars); } return $this->renderOutput($template, $vars); }
php
protected function makeResponse(string $template, array $vars = []) { if (request()->ajax()) { return $this->jsonOutput($vars); } return $this->renderOutput($template, $vars); }
[ "protected", "function", "makeResponse", "(", "string", "$", "template", ",", "array", "$", "vars", "=", "[", "]", ")", "{", "if", "(", "request", "(", ")", "->", "ajax", "(", ")", ")", "{", "return", "$", "this", "->", "jsonOutput", "(", "$", "var...
Make response description. @param string $template [description] @param array $vars [description] @return mixed
[ "Make", "response", "description", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Http/Controllers/BaseController.php#L21-L28
train
webeweb/core-bundle
Twig/Extension/Plugin/JQueryInputMaskTwigExtension.php
JQueryInputMaskTwigExtension.jQueryInputMaskPhoneNumberFunction
public function jQueryInputMaskPhoneNumberFunction(array $args = []) { $defaultMask = "99 99 99 99 99"; return $this->jQueryInputMask(ArrayHelper::get($args, "selector"), $defaultMask, $this->prepareOptions($args, $defaultMask), ArrayHelper::get($args, "scriptTag", false)); }
php
public function jQueryInputMaskPhoneNumberFunction(array $args = []) { $defaultMask = "99 99 99 99 99"; return $this->jQueryInputMask(ArrayHelper::get($args, "selector"), $defaultMask, $this->prepareOptions($args, $defaultMask), ArrayHelper::get($args, "scriptTag", false)); }
[ "public", "function", "jQueryInputMaskPhoneNumberFunction", "(", "array", "$", "args", "=", "[", "]", ")", "{", "$", "defaultMask", "=", "\"99 99 99 99 99\"", ";", "return", "$", "this", "->", "jQueryInputMask", "(", "ArrayHelper", "::", "get", "(", "$", "args...
Displays a jQuery input mask "Phone number". @param array $args The arguments. @return string Returns the jQuery input mask "Phone number".
[ "Displays", "a", "jQuery", "input", "mask", "Phone", "number", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/JQueryInputMaskTwigExtension.php#L65-L68
train
webeweb/core-bundle
Twig/Extension/Plugin/JQueryInputMaskTwigExtension.php
JQueryInputMaskTwigExtension.jQueryInputMaskTime12Function
public function jQueryInputMaskTime12Function(array $args = []) { $defaultMask = "hh:mm t"; return $this->jQueryInputMask(ArrayHelper::get($args, "selector"), $defaultMask, array_merge($this->prepareOptions($args, null), ["hourFormat" => "12", "placeholder" => "__:__ _m"]), ArrayHelper::get($args, "scriptTag", false)); }
php
public function jQueryInputMaskTime12Function(array $args = []) { $defaultMask = "hh:mm t"; return $this->jQueryInputMask(ArrayHelper::get($args, "selector"), $defaultMask, array_merge($this->prepareOptions($args, null), ["hourFormat" => "12", "placeholder" => "__:__ _m"]), ArrayHelper::get($args, "scriptTag", false)); }
[ "public", "function", "jQueryInputMaskTime12Function", "(", "array", "$", "args", "=", "[", "]", ")", "{", "$", "defaultMask", "=", "\"hh:mm t\"", ";", "return", "$", "this", "->", "jQueryInputMask", "(", "ArrayHelper", "::", "get", "(", "$", "args", ",", ...
Displays a jQuery input mask "Time 12 hour". @param array $args The arguments. @return string Returns the jQuery input mask "Time 12 hour".
[ "Displays", "a", "jQuery", "input", "mask", "Time", "12", "hour", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/JQueryInputMaskTwigExtension.php#L98-L101
train
reliv/Rcm
core/src/EventListener/EventWrapper.php
EventWrapper.viewResponseEvent
public function viewResponseEvent(ViewEvent $event) { /** @var \Rcm\EventListener\ViewEventListener $viewEventListener */ $viewEventListener = $this->serviceLocator->get(\Rcm\EventListener\ViewEventListener::class); $return = $viewEventListener->processRcmResponses($event); if (!empty($return)) { return $return; } return null; }
php
public function viewResponseEvent(ViewEvent $event) { /** @var \Rcm\EventListener\ViewEventListener $viewEventListener */ $viewEventListener = $this->serviceLocator->get(\Rcm\EventListener\ViewEventListener::class); $return = $viewEventListener->processRcmResponses($event); if (!empty($return)) { return $return; } return null; }
[ "public", "function", "viewResponseEvent", "(", "ViewEvent", "$", "event", ")", "{", "/** @var \\Rcm\\EventListener\\ViewEventListener $viewEventListener */", "$", "viewEventListener", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "\\", "Rcm", "\\", "Event...
View Response Event @param ViewEvent $event @return null
[ "View", "Response", "Event" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/EventListener/EventWrapper.php#L141-L154
train
Mihai-P/yii2-core
controllers/NoteController.php
NoteController.actionSave
public function actionSave() { $post = Yii::$app->request->post(); $id = $post['Note']['id']; if($id) { $model = Note::findOne($id); } else { $model = new Note; } Yii::$app->response->format = 'json'; if ($model->load(Yii::$app->request->post()) && $model->save()) { return ['success' => true]; } else { return ['success' => false, 'errors' => $model->getErrors()]; } }
php
public function actionSave() { $post = Yii::$app->request->post(); $id = $post['Note']['id']; if($id) { $model = Note::findOne($id); } else { $model = new Note; } Yii::$app->response->format = 'json'; if ($model->load(Yii::$app->request->post()) && $model->save()) { return ['success' => true]; } else { return ['success' => false, 'errors' => $model->getErrors()]; } }
[ "public", "function", "actionSave", "(", ")", "{", "$", "post", "=", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ";", "$", "id", "=", "$", "post", "[", "'Note'", "]", "[", "'id'", "]", ";", "if", "(", "$", "id", ")", "{"...
Saves a model. If creation is successful, the browser will be redirected to the 'view' or 'index' page. @return mixed
[ "Saves", "a", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "or", "index", "page", "." ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/controllers/NoteController.php#L38-L53
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.init_handlers
protected function init_handlers() { $keys = [ self::KEY_SCRIPTS, self::KEY_STYLES ]; foreach ( $keys as $key ) { if ( $this->hasConfigKey( $key ) ) { $this->add_handler( $key ); } } }
php
protected function init_handlers() { $keys = [ self::KEY_SCRIPTS, self::KEY_STYLES ]; foreach ( $keys as $key ) { if ( $this->hasConfigKey( $key ) ) { $this->add_handler( $key ); } } }
[ "protected", "function", "init_handlers", "(", ")", "{", "$", "keys", "=", "[", "self", "::", "KEY_SCRIPTS", ",", "self", "::", "KEY_STYLES", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "$", "this", "->", "hasConfigK...
Initialize the dependency handlers. @since 0.1.0
[ "Initialize", "the", "dependency", "handlers", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L98-L105
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.add_handler
protected function add_handler( $dependency ) { if ( $this->hasConfigKey( $dependency ) ) { $handler = $this->hasConfigKey( self::KEY_HANDLERS, $dependency ) ? $this->getConfigKey( self::KEY_HANDLERS, $dependency ) : $this->get_default_handler( $dependency ); if ( $handler ) { $this->handlers[ $dependency ] = new $handler; } } }
php
protected function add_handler( $dependency ) { if ( $this->hasConfigKey( $dependency ) ) { $handler = $this->hasConfigKey( self::KEY_HANDLERS, $dependency ) ? $this->getConfigKey( self::KEY_HANDLERS, $dependency ) : $this->get_default_handler( $dependency ); if ( $handler ) { $this->handlers[ $dependency ] = new $handler; } } }
[ "protected", "function", "add_handler", "(", "$", "dependency", ")", "{", "if", "(", "$", "this", "->", "hasConfigKey", "(", "$", "dependency", ")", ")", "{", "$", "handler", "=", "$", "this", "->", "hasConfigKey", "(", "self", "::", "KEY_HANDLERS", ",",...
Add a single dependency handler. @since 0.1.0 @param string $dependency The dependency type for which to add a handler.
[ "Add", "a", "single", "dependency", "handler", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L114-L123
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.get_default_handler
protected function get_default_handler( $dependency ) { switch ( $dependency ) { case self::KEY_STYLES: return self::DEFAULT_STYLE_HANDLER; case self::KEY_SCRIPTS: return self::DEFAULT_SCRIPT_HANDLER; default: return null; } }
php
protected function get_default_handler( $dependency ) { switch ( $dependency ) { case self::KEY_STYLES: return self::DEFAULT_STYLE_HANDLER; case self::KEY_SCRIPTS: return self::DEFAULT_SCRIPT_HANDLER; default: return null; } }
[ "protected", "function", "get_default_handler", "(", "$", "dependency", ")", "{", "switch", "(", "$", "dependency", ")", "{", "case", "self", "::", "KEY_STYLES", ":", "return", "self", "::", "DEFAULT_STYLE_HANDLER", ";", "case", "self", "::", "KEY_SCRIPTS", ":...
Get the default handler class for a given type of dependency. @since 0.1.0 @param string $dependency The dependency that needs a handler. @return string|null Class name of the handler. Null if none.
[ "Get", "the", "default", "handler", "class", "for", "a", "given", "type", "of", "dependency", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L133-L142
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.init_dependencies
protected function init_dependencies() { array_walk( $this->handlers, function ( $handler, $dependency_type ) { if ( $this->hasConfigKey( $dependency_type ) ) { $this->dependencies[ $dependency_type ] = $this->init_dependency_type( $dependency_type ); } } ); }
php
protected function init_dependencies() { array_walk( $this->handlers, function ( $handler, $dependency_type ) { if ( $this->hasConfigKey( $dependency_type ) ) { $this->dependencies[ $dependency_type ] = $this->init_dependency_type( $dependency_type ); } } ); }
[ "protected", "function", "init_dependencies", "(", ")", "{", "array_walk", "(", "$", "this", "->", "handlers", ",", "function", "(", "$", "handler", ",", "$", "dependency_type", ")", "{", "if", "(", "$", "this", "->", "hasConfigKey", "(", "$", "dependency_...
Initialize the actual dependencies. @since 0.1.0
[ "Initialize", "the", "actual", "dependencies", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L149-L156
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.init_dependency_type
protected function init_dependency_type( $type ) { $array = [ ]; $data = $this->getConfigKey( $type ); foreach ( $data as $dependency ) { $handle = array_key_exists( 'handle', $dependency ) ? $dependency['handle'] : ''; $array[ $handle ] = $dependency; } return $array; }
php
protected function init_dependency_type( $type ) { $array = [ ]; $data = $this->getConfigKey( $type ); foreach ( $data as $dependency ) { $handle = array_key_exists( 'handle', $dependency ) ? $dependency['handle'] : ''; $array[ $handle ] = $dependency; } return $array; }
[ "protected", "function", "init_dependency_type", "(", "$", "type", ")", "{", "$", "array", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "getConfigKey", "(", "$", "type", ")", ";", "foreach", "(", "$", "data", "as", "$", "dependency", ")",...
Initialize the dependencies of a given type. @since 0.2.2 @param string $type The type of dependency to initialize. @return array Array of dependency configurations.
[ "Initialize", "the", "dependencies", "of", "a", "given", "type", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L166-L175
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.register
public function register( $context = null ) { $context = $this->validate_context( $context ); array_walk( $this->dependencies, [ $this, 'register_dependency_type' ], $context ); }
php
public function register( $context = null ) { $context = $this->validate_context( $context ); array_walk( $this->dependencies, [ $this, 'register_dependency_type' ], $context ); }
[ "public", "function", "register", "(", "$", "context", "=", "null", ")", "{", "$", "context", "=", "$", "this", "->", "validate_context", "(", "$", "context", ")", ";", "array_walk", "(", "$", "this", "->", "dependencies", ",", "[", "$", "this", ",", ...
Register all dependencies. @since 0.1.0 @param mixed $context Optional. The context to pass to the dependencies.
[ "Register", "all", "dependencies", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L184-L188
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.enqueue
public function enqueue( $context = null ) { $context = $this->validate_context( $context ); array_walk( $this->dependencies, [ $this, 'enqueue_dependency_type' ], $context ); }
php
public function enqueue( $context = null ) { $context = $this->validate_context( $context ); array_walk( $this->dependencies, [ $this, 'enqueue_dependency_type' ], $context ); }
[ "public", "function", "enqueue", "(", "$", "context", "=", "null", ")", "{", "$", "context", "=", "$", "this", "->", "validate_context", "(", "$", "context", ")", ";", "array_walk", "(", "$", "this", "->", "dependencies", ",", "[", "$", "this", ",", ...
Enqueue all dependencies. @since 0.1.0 @param mixed $context Optional. The context to pass to the dependencies.
[ "Enqueue", "all", "dependencies", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L213-L218
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.enqueue_handle
public function enqueue_handle( $handle, $context = null, $fallback = false ) { if ( ! $this->enqueue_internal_handle( $handle, $context ) ) { return $this->enqueue_fallback_handle( $handle ); } return true; }
php
public function enqueue_handle( $handle, $context = null, $fallback = false ) { if ( ! $this->enqueue_internal_handle( $handle, $context ) ) { return $this->enqueue_fallback_handle( $handle ); } return true; }
[ "public", "function", "enqueue_handle", "(", "$", "handle", ",", "$", "context", "=", "null", ",", "$", "fallback", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "enqueue_internal_handle", "(", "$", "handle", ",", "$", "context", ")", ")",...
Enqueue a single dependency retrieved by its handle. @since 0.2.2 @param string $handle The dependency handle to enqueue. @param mixed $context Optional. The context to pass to the dependencies. @param bool $fallback Whether to fall back to dependencies registered outside of DependencyManager. Defaults to false. @return bool Returns whether the handle was found or not.
[ "Enqueue", "a", "single", "dependency", "retrieved", "by", "its", "handle", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L232-L237
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.enqueue_internal_handle
protected function enqueue_internal_handle( $handle, $context = null ) { list( $dependency_type, $dependency ) = $this->get_dependency_array( $handle ); $context['dependency_type'] = $dependency_type; if ( ! $dependency ) { return false; } $this->enqueue_dependency( $dependency, $handle, $context ); $this->maybe_localize( $dependency, $context ); $this->maybe_add_inline_script( $dependency, $context ); return true; }
php
protected function enqueue_internal_handle( $handle, $context = null ) { list( $dependency_type, $dependency ) = $this->get_dependency_array( $handle ); $context['dependency_type'] = $dependency_type; if ( ! $dependency ) { return false; } $this->enqueue_dependency( $dependency, $handle, $context ); $this->maybe_localize( $dependency, $context ); $this->maybe_add_inline_script( $dependency, $context ); return true; }
[ "protected", "function", "enqueue_internal_handle", "(", "$", "handle", ",", "$", "context", "=", "null", ")", "{", "list", "(", "$", "dependency_type", ",", "$", "dependency", ")", "=", "$", "this", "->", "get_dependency_array", "(", "$", "handle", ")", "...
Enqueue a single dependency from the internal dependencies, retrieved by its handle. @since 0.2.4 @param string $handle The dependency handle to enqueue. @param mixed $context Optional. The context to pass to the dependencies. @return bool Returns whether the handle was found or not.
[ "Enqueue", "a", "single", "dependency", "from", "the", "internal", "dependencies", "retrieved", "by", "its", "handle", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L250-L268
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.get_dependency_array
protected function get_dependency_array( $handle ) { foreach ( $this->dependencies as $type => $dependencies ) { if ( array_key_exists( $handle, $dependencies ) ) { return [ $type, $dependencies[ $handle ] ]; } } // Handle not found, return an empty array. return [ '', null ]; }
php
protected function get_dependency_array( $handle ) { foreach ( $this->dependencies as $type => $dependencies ) { if ( array_key_exists( $handle, $dependencies ) ) { return [ $type, $dependencies[ $handle ] ]; } } // Handle not found, return an empty array. return [ '', null ]; }
[ "protected", "function", "get_dependency_array", "(", "$", "handle", ")", "{", "foreach", "(", "$", "this", "->", "dependencies", "as", "$", "type", "=>", "$", "dependencies", ")", "{", "if", "(", "array_key_exists", "(", "$", "handle", ",", "$", "dependen...
Get the matching dependency for a given handle. @since 0.2.2 @param string $handle The dependency handle to search for. @return array Array containing the dependency key as well as the dependency array itself.
[ "Get", "the", "matching", "dependency", "for", "a", "given", "handle", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L279-L287
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.enqueue_dependency
protected function enqueue_dependency( $dependency, $dependency_key, $context = null ) { if ( ! $this->is_needed( $dependency, $context ) ) { return; } $handler = $this->handlers[ $context['dependency_type'] ]; $handler->enqueue( $dependency ); }
php
protected function enqueue_dependency( $dependency, $dependency_key, $context = null ) { if ( ! $this->is_needed( $dependency, $context ) ) { return; } $handler = $this->handlers[ $context['dependency_type'] ]; $handler->enqueue( $dependency ); }
[ "protected", "function", "enqueue_dependency", "(", "$", "dependency", ",", "$", "dependency_key", ",", "$", "context", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "is_needed", "(", "$", "dependency", ",", "$", "context", ")", ")", "{", "...
Enqueue a single dependency. @since 0.1.0 @param array $dependency Configuration data of the dependency. @param string $dependency_key Config key of the dependency. @param mixed $context Optional. Context to pass to the dependencies. Contains the type of the dependency at key 'dependency_type'.
[ "Enqueue", "a", "single", "dependency", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L301-L307
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.is_needed
protected function is_needed( $dependency, $context ) { $is_needed = array_key_exists( 'is_needed', $dependency ) ? $dependency['is_needed'] : null; if ( null === $is_needed ) { return true; } return is_callable( $is_needed ) && $is_needed( $context ); }
php
protected function is_needed( $dependency, $context ) { $is_needed = array_key_exists( 'is_needed', $dependency ) ? $dependency['is_needed'] : null; if ( null === $is_needed ) { return true; } return is_callable( $is_needed ) && $is_needed( $context ); }
[ "protected", "function", "is_needed", "(", "$", "dependency", ",", "$", "context", ")", "{", "$", "is_needed", "=", "array_key_exists", "(", "'is_needed'", ",", "$", "dependency", ")", "?", "$", "dependency", "[", "'is_needed'", "]", ":", "null", ";", "if"...
Check whether a specific dependency is needed. @since 0.1.0 @param array $dependency Configuration of the dependency to check. @param mixed $context Context to pass to the dependencies. Contains the type of the dependency at key 'dependency_type'. @return bool Whether it is needed or not.
[ "Check", "whether", "a", "specific", "dependency", "is", "needed", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L320-L330
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.maybe_localize
protected function maybe_localize( $dependency, $context ) { if ( ! array_key_exists( 'localize', $dependency ) ) { return; } $localize = $dependency['localize']; $data = $localize['data']; if ( is_callable( $data ) ) { $data = $data( $context ); } wp_localize_script( $dependency['handle'], $localize['name'], $data ); }
php
protected function maybe_localize( $dependency, $context ) { if ( ! array_key_exists( 'localize', $dependency ) ) { return; } $localize = $dependency['localize']; $data = $localize['data']; if ( is_callable( $data ) ) { $data = $data( $context ); } wp_localize_script( $dependency['handle'], $localize['name'], $data ); }
[ "protected", "function", "maybe_localize", "(", "$", "dependency", ",", "$", "context", ")", "{", "if", "(", "!", "array_key_exists", "(", "'localize'", ",", "$", "dependency", ")", ")", "{", "return", ";", "}", "$", "localize", "=", "$", "dependency", "...
Localize the script of a given dependency. @since 0.1.0 @param array $dependency The dependency to localize the script of. @param mixed $context Contextual data to pass to the callback. Contains the type of the dependency at key 'dependency_type'.
[ "Localize", "the", "script", "of", "a", "given", "dependency", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L342-L354
train
brightnucleus/dependencies
src/DependencyManager.php
DependencyManager.maybe_add_inline_script
protected function maybe_add_inline_script( $dependency, $context ) { if ( ! array_key_exists( 'add_inline', $dependency ) ) { return; } $inline_script = $dependency['add_inline']; if ( is_callable( $inline_script ) ) { $inline_script = $inline_script( $context ); } wp_add_inline_script( $dependency['handle'], $inline_script ); }
php
protected function maybe_add_inline_script( $dependency, $context ) { if ( ! array_key_exists( 'add_inline', $dependency ) ) { return; } $inline_script = $dependency['add_inline']; if ( is_callable( $inline_script ) ) { $inline_script = $inline_script( $context ); } wp_add_inline_script( $dependency['handle'], $inline_script ); }
[ "protected", "function", "maybe_add_inline_script", "(", "$", "dependency", ",", "$", "context", ")", "{", "if", "(", "!", "array_key_exists", "(", "'add_inline'", ",", "$", "dependency", ")", ")", "{", "return", ";", "}", "$", "inline_script", "=", "$", "...
Add an inline script snippet to a given dependency. @since 0.1.0 @param array $dependency The dependency to add the inline script to. @param mixed $context Contextual data to pass to the callback. Contains the type of the dependency at key 'dependency_type'.
[ "Add", "an", "inline", "script", "snippet", "to", "a", "given", "dependency", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/DependencyManager.php#L366-L378
train