id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
230,200
Webiny/Framework
src/Webiny/Component/Cache/CacheStorage.php
CacheStorage.getDriver
public function getDriver() { // if driver status is false, we return the BlackHole driver if (!$this->getStatus()) { if (is_null(self::$nullDriver)) { self::$nullDriver = new Storage\BlackHole(); } return self::$nullDriver; } return $this->driver; }
php
public function getDriver() { // if driver status is false, we return the BlackHole driver if (!$this->getStatus()) { if (is_null(self::$nullDriver)) { self::$nullDriver = new Storage\BlackHole(); } return self::$nullDriver; } return $this->driver; }
[ "public", "function", "getDriver", "(", ")", "{", "// if driver status is false, we return the BlackHole driver", "if", "(", "!", "$", "this", "->", "getStatus", "(", ")", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "nullDriver", ")", ")", "{", "self", "::", "$", "nullDriver", "=", "new", "Storage", "\\", "BlackHole", "(", ")", ";", "}", "return", "self", "::", "$", "nullDriver", ";", "}", "return", "$", "this", "->", "driver", ";", "}" ]
Get driver instance. @return CacheStorageInterface
[ "Get", "driver", "instance", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Cache/CacheStorage.php#L62-L74
230,201
Webiny/Framework
src/Webiny/Component/Cache/CacheStorage.php
CacheStorage.increment
public function increment($key, $byValue = 1, $limitKeysCount = 0, $ttl = 259200) { return $this->getDriver()->increment($key, $byValue, $limitKeysCount, $ttl); }
php
public function increment($key, $byValue = 1, $limitKeysCount = 0, $ttl = 259200) { return $this->getDriver()->increment($key, $byValue, $limitKeysCount, $ttl); }
[ "public", "function", "increment", "(", "$", "key", ",", "$", "byValue", "=", "1", ",", "$", "limitKeysCount", "=", "0", ",", "$", "ttl", "=", "259200", ")", "{", "return", "$", "this", "->", "getDriver", "(", ")", "->", "increment", "(", "$", "key", ",", "$", "byValue", ",", "$", "limitKeysCount", ",", "$", "ttl", ")", ";", "}" ]
Increment value of the key. @param string $key Name of the cache key. @param mixed $byValue If stored value is an array: - If $by_value is a value in array, new element will be pushed to the end of array, - If $by_value is a key=>value array, new key=>value pair will be added (or updated). @param int $limitKeysCount Maximum count of elements (used only if stored value is array). @param int $ttl Set time to live for key. @return int|string|array New key value.
[ "Increment", "value", "of", "the", "key", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Cache/CacheStorage.php#L210-L213
230,202
naneau/semver
src/Naneau/SemVer/Version.php
Version.next
public function next($base = null) { // Ensure that $base is a Version. Parse it if we must, use ourself if // it is empty. if (empty($base)) { $base = $this; } else { if (is_string($base)) { $base = Parser::parse($base); } elseif (! $base instanceof Version) { throw new InvalidArgumentException("\$base must be of type Version"); } } // If the base is ahead of this Version then the next version will be // the base. if (Compare::greaterThan($base, $this)) { return $base->cleanCopy(); } $next = new Version; $next->setMajor($this->getMajor()); $next->setMinor($this->getMinor()); $next->setPatch($this->getPatch()); if ($base->hasPreRelease()) { if ($this->hasPreRelease()) { // We already know that $base is less than or equal to $this // and we won't be jumping to the next greek value. So it is // safe use $this prerelease and just increment the release // number. $pre = new PreRelease; $pre->setGreek($this->getPreRelease()->getGreek()); $pre->setReleaseNumber($this->getPreRelease()->getReleaseNumber() + 1); $next->setPreRelease($pre); } else { throw new InvalidArgumentException("This version has left prerelease without updating the base. Base should not be prerelease."); } } elseif ( ! $this->hasPreRelease()) { $next->setPatch($this->getPatch() + 1); } // The case of $this having a pre-release when $base does not means // that we are essentially just leaving pre-release. Nothing needs to // be done. return $next; }
php
public function next($base = null) { // Ensure that $base is a Version. Parse it if we must, use ourself if // it is empty. if (empty($base)) { $base = $this; } else { if (is_string($base)) { $base = Parser::parse($base); } elseif (! $base instanceof Version) { throw new InvalidArgumentException("\$base must be of type Version"); } } // If the base is ahead of this Version then the next version will be // the base. if (Compare::greaterThan($base, $this)) { return $base->cleanCopy(); } $next = new Version; $next->setMajor($this->getMajor()); $next->setMinor($this->getMinor()); $next->setPatch($this->getPatch()); if ($base->hasPreRelease()) { if ($this->hasPreRelease()) { // We already know that $base is less than or equal to $this // and we won't be jumping to the next greek value. So it is // safe use $this prerelease and just increment the release // number. $pre = new PreRelease; $pre->setGreek($this->getPreRelease()->getGreek()); $pre->setReleaseNumber($this->getPreRelease()->getReleaseNumber() + 1); $next->setPreRelease($pre); } else { throw new InvalidArgumentException("This version has left prerelease without updating the base. Base should not be prerelease."); } } elseif ( ! $this->hasPreRelease()) { $next->setPatch($this->getPatch() + 1); } // The case of $this having a pre-release when $base does not means // that we are essentially just leaving pre-release. Nothing needs to // be done. return $next; }
[ "public", "function", "next", "(", "$", "base", "=", "null", ")", "{", "// Ensure that $base is a Version. Parse it if we must, use ourself if", "// it is empty.", "if", "(", "empty", "(", "$", "base", ")", ")", "{", "$", "base", "=", "$", "this", ";", "}", "else", "{", "if", "(", "is_string", "(", "$", "base", ")", ")", "{", "$", "base", "=", "Parser", "::", "parse", "(", "$", "base", ")", ";", "}", "elseif", "(", "!", "$", "base", "instanceof", "Version", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"\\$base must be of type Version\"", ")", ";", "}", "}", "// If the base is ahead of this Version then the next version will be", "// the base.", "if", "(", "Compare", "::", "greaterThan", "(", "$", "base", ",", "$", "this", ")", ")", "{", "return", "$", "base", "->", "cleanCopy", "(", ")", ";", "}", "$", "next", "=", "new", "Version", ";", "$", "next", "->", "setMajor", "(", "$", "this", "->", "getMajor", "(", ")", ")", ";", "$", "next", "->", "setMinor", "(", "$", "this", "->", "getMinor", "(", ")", ")", ";", "$", "next", "->", "setPatch", "(", "$", "this", "->", "getPatch", "(", ")", ")", ";", "if", "(", "$", "base", "->", "hasPreRelease", "(", ")", ")", "{", "if", "(", "$", "this", "->", "hasPreRelease", "(", ")", ")", "{", "// We already know that $base is less than or equal to $this", "// and we won't be jumping to the next greek value. So it is", "// safe use $this prerelease and just increment the release", "// number.", "$", "pre", "=", "new", "PreRelease", ";", "$", "pre", "->", "setGreek", "(", "$", "this", "->", "getPreRelease", "(", ")", "->", "getGreek", "(", ")", ")", ";", "$", "pre", "->", "setReleaseNumber", "(", "$", "this", "->", "getPreRelease", "(", ")", "->", "getReleaseNumber", "(", ")", "+", "1", ")", ";", "$", "next", "->", "setPreRelease", "(", "$", "pre", ")", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "\"This version has left prerelease without updating the base. Base should not be prerelease.\"", ")", ";", "}", "}", "elseif", "(", "!", "$", "this", "->", "hasPreRelease", "(", ")", ")", "{", "$", "next", "->", "setPatch", "(", "$", "this", "->", "getPatch", "(", ")", "+", "1", ")", ";", "}", "// The case of $this having a pre-release when $base does not means", "// that we are essentially just leaving pre-release. Nothing needs to", "// be done.", "return", "$", "next", ";", "}" ]
Get the next logical version relative to the provided base version. If no base is supplied, base will be the same as the current version. @param Version|string|null $base @return Version @throws InvalidArgumentException
[ "Get", "the", "next", "logical", "version", "relative", "to", "the", "provided", "base", "version", ".", "If", "no", "base", "is", "supplied", "base", "will", "be", "the", "same", "as", "the", "current", "version", "." ]
c771ad1e6c89064c0a4fa714979639dc3649d6c8
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Version.php#L143-L195
230,203
naneau/semver
src/Naneau/SemVer/Version.php
Version.cleanCopy
public function cleanCopy() { $version = new Version; $version->setMajor($this->getMajor()); $version->setMinor($this->getMinor()); $version->setPatch($this->getPatch()); if ($this->hasPreRelease()) { $version->preRelease = clone($this->getPreRelease()); } return $version; }
php
public function cleanCopy() { $version = new Version; $version->setMajor($this->getMajor()); $version->setMinor($this->getMinor()); $version->setPatch($this->getPatch()); if ($this->hasPreRelease()) { $version->preRelease = clone($this->getPreRelease()); } return $version; }
[ "public", "function", "cleanCopy", "(", ")", "{", "$", "version", "=", "new", "Version", ";", "$", "version", "->", "setMajor", "(", "$", "this", "->", "getMajor", "(", ")", ")", ";", "$", "version", "->", "setMinor", "(", "$", "this", "->", "getMinor", "(", ")", ")", ";", "$", "version", "->", "setPatch", "(", "$", "this", "->", "getPatch", "(", ")", ")", ";", "if", "(", "$", "this", "->", "hasPreRelease", "(", ")", ")", "{", "$", "version", "->", "preRelease", "=", "clone", "(", "$", "this", "->", "getPreRelease", "(", ")", ")", ";", "}", "return", "$", "version", ";", "}" ]
Create a new Version that discards the entity information of build and originalVersionString @return Version
[ "Create", "a", "new", "Version", "that", "discards", "the", "entity", "information", "of", "build", "and", "originalVersionString" ]
c771ad1e6c89064c0a4fa714979639dc3649d6c8
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Version.php#L203-L216
230,204
Webiny/Framework
src/Webiny/Component/Cache/Storage/Memcache.php
Memcache.getInstance
public static function getInstance($host = '127.0.0.1', $port = 11211) { return \Webiny\Component\Cache\Bridge\Memcache::getInstance($host, $port); }
php
public static function getInstance($host = '127.0.0.1', $port = 11211) { return \Webiny\Component\Cache\Bridge\Memcache::getInstance($host, $port); }
[ "public", "static", "function", "getInstance", "(", "$", "host", "=", "'127.0.0.1'", ",", "$", "port", "=", "11211", ")", "{", "return", "\\", "Webiny", "\\", "Component", "\\", "Cache", "\\", "Bridge", "\\", "Memcache", "::", "getInstance", "(", "$", "host", ",", "$", "port", ")", ";", "}" ]
Get an instance of Memcache cache storage. @param string $host Host on which memcached is running. @param int $port Port on which memcached is running. @return CacheStorageInterface
[ "Get", "an", "instance", "of", "Memcache", "cache", "storage", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Cache/Storage/Memcache.php#L28-L31
230,205
decred/decred-php-api
src/Decred/Crypto/ExtendedKey.php
ExtendedKey.generateSeed
public static function generateSeed(NetworkInterface $network, $length = self::RECOMMENDED_SEED_BYTES) { // Per [BIP32], the seed must be in range [16, 64]. if (($length < static::MIN_SEED_BYTES) || ($length > static::MAX_SEED_BYTES)) { throw new \InvalidArgumentException( 'Invalid seed length. Length should be between 16 and 64 bytes (32 recommended).' ); } $seed = random_bytes($length); while (!static::verifySeed($seed, $network)) { // @codeCoverageIgnoreStart $seed = random_bytes($length); // @codeCoverageIgnoreEnd } return $seed; }
php
public static function generateSeed(NetworkInterface $network, $length = self::RECOMMENDED_SEED_BYTES) { // Per [BIP32], the seed must be in range [16, 64]. if (($length < static::MIN_SEED_BYTES) || ($length > static::MAX_SEED_BYTES)) { throw new \InvalidArgumentException( 'Invalid seed length. Length should be between 16 and 64 bytes (32 recommended).' ); } $seed = random_bytes($length); while (!static::verifySeed($seed, $network)) { // @codeCoverageIgnoreStart $seed = random_bytes($length); // @codeCoverageIgnoreEnd } return $seed; }
[ "public", "static", "function", "generateSeed", "(", "NetworkInterface", "$", "network", ",", "$", "length", "=", "self", "::", "RECOMMENDED_SEED_BYTES", ")", "{", "// Per [BIP32], the seed must be in range [16, 64].", "if", "(", "(", "$", "length", "<", "static", "::", "MIN_SEED_BYTES", ")", "||", "(", "$", "length", ">", "static", "::", "MAX_SEED_BYTES", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid seed length. Length should be between 16 and 64 bytes (32 recommended).'", ")", ";", "}", "$", "seed", "=", "random_bytes", "(", "$", "length", ")", ";", "while", "(", "!", "static", "::", "verifySeed", "(", "$", "seed", ",", "$", "network", ")", ")", "{", "// @codeCoverageIgnoreStart", "$", "seed", "=", "random_bytes", "(", "$", "length", ")", ";", "// @codeCoverageIgnoreEnd", "}", "return", "$", "seed", ";", "}" ]
Generate verified usable seed. @param NetworkInterface $network @param int $length @return mixed
[ "Generate", "verified", "usable", "seed", "." ]
dafea9ceac918c4c3cd9bc7c436009a95dfb1643
https://github.com/decred/decred-php-api/blob/dafea9ceac918c4c3cd9bc7c436009a95dfb1643/src/Decred/Crypto/ExtendedKey.php#L116-L134
230,206
decred/decred-php-api
src/Decred/Crypto/ExtendedKey.php
ExtendedKey.verifySeed
public static function verifySeed($seed, $network) { try { $master = static::newMaster($seed, $network); $coinType = $master->deriveCoinTypeKey(); $account0 = $coinType->deriveAccountKey(); $account0->neuter(); $account0->deriveInternalBranch(); $externalBranch = $account0->deriveExternalBranch(); $externalBranch0 = $externalBranch->privateChildKey(0); $externalBranch0->getAddress(); return $master; // @codeCoverageIgnoreStart } catch (\Exception $e) { return false; } // @codeCoverageIgnoreEnd }
php
public static function verifySeed($seed, $network) { try { $master = static::newMaster($seed, $network); $coinType = $master->deriveCoinTypeKey(); $account0 = $coinType->deriveAccountKey(); $account0->neuter(); $account0->deriveInternalBranch(); $externalBranch = $account0->deriveExternalBranch(); $externalBranch0 = $externalBranch->privateChildKey(0); $externalBranch0->getAddress(); return $master; // @codeCoverageIgnoreStart } catch (\Exception $e) { return false; } // @codeCoverageIgnoreEnd }
[ "public", "static", "function", "verifySeed", "(", "$", "seed", ",", "$", "network", ")", "{", "try", "{", "$", "master", "=", "static", "::", "newMaster", "(", "$", "seed", ",", "$", "network", ")", ";", "$", "coinType", "=", "$", "master", "->", "deriveCoinTypeKey", "(", ")", ";", "$", "account0", "=", "$", "coinType", "->", "deriveAccountKey", "(", ")", ";", "$", "account0", "->", "neuter", "(", ")", ";", "$", "account0", "->", "deriveInternalBranch", "(", ")", ";", "$", "externalBranch", "=", "$", "account0", "->", "deriveExternalBranch", "(", ")", ";", "$", "externalBranch0", "=", "$", "externalBranch", "->", "privateChildKey", "(", "0", ")", ";", "$", "externalBranch0", "->", "getAddress", "(", ")", ";", "return", "$", "master", ";", "// @codeCoverageIgnoreStart", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "// @codeCoverageIgnoreEnd", "}" ]
Verify that we can derive external branch 0 index address to check if seed is usable. @param string $seed @param NetworkInterface $network @return ExtendedKey|bool Master key or false
[ "Verify", "that", "we", "can", "derive", "external", "branch", "0", "index", "address", "to", "check", "if", "seed", "is", "usable", "." ]
dafea9ceac918c4c3cd9bc7c436009a95dfb1643
https://github.com/decred/decred-php-api/blob/dafea9ceac918c4c3cd9bc7c436009a95dfb1643/src/Decred/Crypto/ExtendedKey.php#L144-L161
230,207
decred/decred-php-api
src/Decred/Crypto/ExtendedKey.php
ExtendedKey.fromString
public static function fromString($key) { // version (4) || depth (1) || parent fingerprint (4) || // child num (4) || chain code (32) || key data (33) || checksum (4) $payload = DecredNetwork::extendedKeyBase58Decode($key); $network = NetworkFactory::fromExtendedKeyVersion(substr($payload, 0, 4)); $depth = intval(hexdec(substr($payload, 4, 1))); $parentFP = substr($payload, 5, 4); $childNum = intval(hexdec(substr($payload, 9, 4))); $chainCode = substr($payload, 13, 32); $key = substr($payload, 45, 33); $private = $payload[45] === "\x00"; return new ExtendedKey($key, $chainCode, $depth, $parentFP, $childNum, $network, $private); }
php
public static function fromString($key) { // version (4) || depth (1) || parent fingerprint (4) || // child num (4) || chain code (32) || key data (33) || checksum (4) $payload = DecredNetwork::extendedKeyBase58Decode($key); $network = NetworkFactory::fromExtendedKeyVersion(substr($payload, 0, 4)); $depth = intval(hexdec(substr($payload, 4, 1))); $parentFP = substr($payload, 5, 4); $childNum = intval(hexdec(substr($payload, 9, 4))); $chainCode = substr($payload, 13, 32); $key = substr($payload, 45, 33); $private = $payload[45] === "\x00"; return new ExtendedKey($key, $chainCode, $depth, $parentFP, $childNum, $network, $private); }
[ "public", "static", "function", "fromString", "(", "$", "key", ")", "{", "// version (4) || depth (1) || parent fingerprint (4) ||", "// child num (4) || chain code (32) || key data (33) || checksum (4)", "$", "payload", "=", "DecredNetwork", "::", "extendedKeyBase58Decode", "(", "$", "key", ")", ";", "$", "network", "=", "NetworkFactory", "::", "fromExtendedKeyVersion", "(", "substr", "(", "$", "payload", ",", "0", ",", "4", ")", ")", ";", "$", "depth", "=", "intval", "(", "hexdec", "(", "substr", "(", "$", "payload", ",", "4", ",", "1", ")", ")", ")", ";", "$", "parentFP", "=", "substr", "(", "$", "payload", ",", "5", ",", "4", ")", ";", "$", "childNum", "=", "intval", "(", "hexdec", "(", "substr", "(", "$", "payload", ",", "9", ",", "4", ")", ")", ")", ";", "$", "chainCode", "=", "substr", "(", "$", "payload", ",", "13", ",", "32", ")", ";", "$", "key", "=", "substr", "(", "$", "payload", ",", "45", ",", "33", ")", ";", "$", "private", "=", "$", "payload", "[", "45", "]", "===", "\"\\x00\"", ";", "return", "new", "ExtendedKey", "(", "$", "key", ",", "$", "chainCode", ",", "$", "depth", ",", "$", "parentFP", ",", "$", "childNum", ",", "$", "network", ",", "$", "private", ")", ";", "}" ]
Decode from base58 encoded string. @param string $key @return ExtendedKey
[ "Decode", "from", "base58", "encoded", "string", "." ]
dafea9ceac918c4c3cd9bc7c436009a95dfb1643
https://github.com/decred/decred-php-api/blob/dafea9ceac918c4c3cd9bc7c436009a95dfb1643/src/Decred/Crypto/ExtendedKey.php#L196-L210
230,208
decred/decred-php-api
src/Decred/Crypto/ExtendedKey.php
ExtendedKey.neuter
public function neuter() { if ($this->isPrivate()) { return new ExtendedKey( $this->publicKey(), $this->chainCode, $this->depth, $this->parentFP, $this->childNum, $this->network ); } return $this; }
php
public function neuter() { if ($this->isPrivate()) { return new ExtendedKey( $this->publicKey(), $this->chainCode, $this->depth, $this->parentFP, $this->childNum, $this->network ); } return $this; }
[ "public", "function", "neuter", "(", ")", "{", "if", "(", "$", "this", "->", "isPrivate", "(", ")", ")", "{", "return", "new", "ExtendedKey", "(", "$", "this", "->", "publicKey", "(", ")", ",", "$", "this", "->", "chainCode", ",", "$", "this", "->", "depth", ",", "$", "this", "->", "parentFP", ",", "$", "this", "->", "childNum", ",", "$", "this", "->", "network", ")", ";", "}", "return", "$", "this", ";", "}" ]
Get public extended key from private or verify it is public key.. @return ExtendedKey
[ "Get", "public", "extended", "key", "from", "private", "or", "verify", "it", "is", "public", "key", ".." ]
dafea9ceac918c4c3cd9bc7c436009a95dfb1643
https://github.com/decred/decred-php-api/blob/dafea9ceac918c4c3cd9bc7c436009a95dfb1643/src/Decred/Crypto/ExtendedKey.php#L432-L446
230,209
decred/decred-php-api
src/Decred/Crypto/ExtendedKey.php
ExtendedKey.deriveCoinTypeKey
public function deriveCoinTypeKey($coinType = self::DECRED_COIN_TYPE) { if ($coinType > self::MAX_COIN_TYPE) { throw new \InvalidArgumentException('Invalid coin type.'); } return $this->hardenedChildKey(static::BIP44_PURPOSE)->hardenedChildKey($coinType); }
php
public function deriveCoinTypeKey($coinType = self::DECRED_COIN_TYPE) { if ($coinType > self::MAX_COIN_TYPE) { throw new \InvalidArgumentException('Invalid coin type.'); } return $this->hardenedChildKey(static::BIP44_PURPOSE)->hardenedChildKey($coinType); }
[ "public", "function", "deriveCoinTypeKey", "(", "$", "coinType", "=", "self", "::", "DECRED_COIN_TYPE", ")", "{", "if", "(", "$", "coinType", ">", "self", "::", "MAX_COIN_TYPE", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid coin type.'", ")", ";", "}", "return", "$", "this", "->", "hardenedChildKey", "(", "static", "::", "BIP44_PURPOSE", ")", "->", "hardenedChildKey", "(", "$", "coinType", ")", ";", "}" ]
Derive BIP44 purpose and coin type. @param int $coinType @return ExtendedKey
[ "Derive", "BIP44", "purpose", "and", "coin", "type", "." ]
dafea9ceac918c4c3cd9bc7c436009a95dfb1643
https://github.com/decred/decred-php-api/blob/dafea9ceac918c4c3cd9bc7c436009a95dfb1643/src/Decred/Crypto/ExtendedKey.php#L478-L485
230,210
milesj/admin
Controller/LogsController.php
LogsController.index
public function index() { $this->paginate = array_merge(array( 'limit' => 25, 'contain' => array_keys($this->Model->belongsTo) ), $this->Model->admin['paginate']); $this->set('results', $this->paginate($this->Model)); }
php
public function index() { $this->paginate = array_merge(array( 'limit' => 25, 'contain' => array_keys($this->Model->belongsTo) ), $this->Model->admin['paginate']); $this->set('results', $this->paginate($this->Model)); }
[ "public", "function", "index", "(", ")", "{", "$", "this", "->", "paginate", "=", "array_merge", "(", "array", "(", "'limit'", "=>", "25", ",", "'contain'", "=>", "array_keys", "(", "$", "this", "->", "Model", "->", "belongsTo", ")", ")", ",", "$", "this", "->", "Model", "->", "admin", "[", "'paginate'", "]", ")", ";", "$", "this", "->", "set", "(", "'results'", ",", "$", "this", "->", "paginate", "(", "$", "this", "->", "Model", ")", ")", ";", "}" ]
Paginate the logs.
[ "Paginate", "the", "logs", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Controller/LogsController.php#L13-L20
230,211
milesj/admin
Controller/LogsController.php
LogsController.read
public function read($type = 'debug') { $path = TMP . 'logs/' . $type . '.log'; $logs = array(); $exceptions = array(); $message = null; if (!in_array($type, CakeLog::configured())) { throw new NotFoundException(__d('admin', '%s Log Not Found', Inflector::humanize($type))); } if (file_exists($path)) { if (filesize($path) > 2097152) { throw new BadRequestException(__d('admin', 'Can not read %s as it exceeds 2MB', basename($path))); } if ($file = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)) { $log = array(); foreach ($file as $line) { // Exception message if (preg_match('/^([0-9\-:\s]+)\s([a-z]+:)\s(?:\[([a-z]+)\])?\s?(.*?)$/i', $line, $matches)) { $exception = $matches[3]; // Save the previous log if ($log) { $key = md5($log['url'] . $log['message']); if (isset($logs[$key])) { $logs[$key]['count']++; } else { $logs[$key] = $log; } } // Start a new log $log = array( 'line' => $line, 'exception' => $exception, 'message' => $matches[4], 'stack' => array(), 'count' => 1, 'date' => $matches[1], 'url' => null ); if ($exception) { $exceptions[$exception][] = $matches[1]; } // Request URL } else if (preg_match('/^Request URL: (.*?)$/i', $line, $matches)) { $log['url'] = $matches[1]; // Stack trace } else if ($line[0] === '#') { $log['stack'][] = $line . PHP_EOL; } } } // Sort by count usort($logs, function($a, $b) { return $b['count'] - $a['count']; }); } $this->set('type', $type); $this->set('logs', $logs); $this->set('exceptions', $exceptions); }
php
public function read($type = 'debug') { $path = TMP . 'logs/' . $type . '.log'; $logs = array(); $exceptions = array(); $message = null; if (!in_array($type, CakeLog::configured())) { throw new NotFoundException(__d('admin', '%s Log Not Found', Inflector::humanize($type))); } if (file_exists($path)) { if (filesize($path) > 2097152) { throw new BadRequestException(__d('admin', 'Can not read %s as it exceeds 2MB', basename($path))); } if ($file = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)) { $log = array(); foreach ($file as $line) { // Exception message if (preg_match('/^([0-9\-:\s]+)\s([a-z]+:)\s(?:\[([a-z]+)\])?\s?(.*?)$/i', $line, $matches)) { $exception = $matches[3]; // Save the previous log if ($log) { $key = md5($log['url'] . $log['message']); if (isset($logs[$key])) { $logs[$key]['count']++; } else { $logs[$key] = $log; } } // Start a new log $log = array( 'line' => $line, 'exception' => $exception, 'message' => $matches[4], 'stack' => array(), 'count' => 1, 'date' => $matches[1], 'url' => null ); if ($exception) { $exceptions[$exception][] = $matches[1]; } // Request URL } else if (preg_match('/^Request URL: (.*?)$/i', $line, $matches)) { $log['url'] = $matches[1]; // Stack trace } else if ($line[0] === '#') { $log['stack'][] = $line . PHP_EOL; } } } // Sort by count usort($logs, function($a, $b) { return $b['count'] - $a['count']; }); } $this->set('type', $type); $this->set('logs', $logs); $this->set('exceptions', $exceptions); }
[ "public", "function", "read", "(", "$", "type", "=", "'debug'", ")", "{", "$", "path", "=", "TMP", ".", "'logs/'", ".", "$", "type", ".", "'.log'", ";", "$", "logs", "=", "array", "(", ")", ";", "$", "exceptions", "=", "array", "(", ")", ";", "$", "message", "=", "null", ";", "if", "(", "!", "in_array", "(", "$", "type", ",", "CakeLog", "::", "configured", "(", ")", ")", ")", "{", "throw", "new", "NotFoundException", "(", "__d", "(", "'admin'", ",", "'%s Log Not Found'", ",", "Inflector", "::", "humanize", "(", "$", "type", ")", ")", ")", ";", "}", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "filesize", "(", "$", "path", ")", ">", "2097152", ")", "{", "throw", "new", "BadRequestException", "(", "__d", "(", "'admin'", ",", "'Can not read %s as it exceeds 2MB'", ",", "basename", "(", "$", "path", ")", ")", ")", ";", "}", "if", "(", "$", "file", "=", "file", "(", "$", "path", ",", "FILE_IGNORE_NEW_LINES", "|", "FILE_SKIP_EMPTY_LINES", ")", ")", "{", "$", "log", "=", "array", "(", ")", ";", "foreach", "(", "$", "file", "as", "$", "line", ")", "{", "// Exception message", "if", "(", "preg_match", "(", "'/^([0-9\\-:\\s]+)\\s([a-z]+:)\\s(?:\\[([a-z]+)\\])?\\s?(.*?)$/i'", ",", "$", "line", ",", "$", "matches", ")", ")", "{", "$", "exception", "=", "$", "matches", "[", "3", "]", ";", "// Save the previous log", "if", "(", "$", "log", ")", "{", "$", "key", "=", "md5", "(", "$", "log", "[", "'url'", "]", ".", "$", "log", "[", "'message'", "]", ")", ";", "if", "(", "isset", "(", "$", "logs", "[", "$", "key", "]", ")", ")", "{", "$", "logs", "[", "$", "key", "]", "[", "'count'", "]", "++", ";", "}", "else", "{", "$", "logs", "[", "$", "key", "]", "=", "$", "log", ";", "}", "}", "// Start a new log", "$", "log", "=", "array", "(", "'line'", "=>", "$", "line", ",", "'exception'", "=>", "$", "exception", ",", "'message'", "=>", "$", "matches", "[", "4", "]", ",", "'stack'", "=>", "array", "(", ")", ",", "'count'", "=>", "1", ",", "'date'", "=>", "$", "matches", "[", "1", "]", ",", "'url'", "=>", "null", ")", ";", "if", "(", "$", "exception", ")", "{", "$", "exceptions", "[", "$", "exception", "]", "[", "]", "=", "$", "matches", "[", "1", "]", ";", "}", "// Request URL", "}", "else", "if", "(", "preg_match", "(", "'/^Request URL: (.*?)$/i'", ",", "$", "line", ",", "$", "matches", ")", ")", "{", "$", "log", "[", "'url'", "]", "=", "$", "matches", "[", "1", "]", ";", "// Stack trace", "}", "else", "if", "(", "$", "line", "[", "0", "]", "===", "'#'", ")", "{", "$", "log", "[", "'stack'", "]", "[", "]", "=", "$", "line", ".", "PHP_EOL", ";", "}", "}", "}", "// Sort by count", "usort", "(", "$", "logs", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "$", "b", "[", "'count'", "]", "-", "$", "a", "[", "'count'", "]", ";", "}", ")", ";", "}", "$", "this", "->", "set", "(", "'type'", ",", "$", "type", ")", ";", "$", "this", "->", "set", "(", "'logs'", ",", "$", "logs", ")", ";", "$", "this", "->", "set", "(", "'exceptions'", ",", "$", "exceptions", ")", ";", "}" ]
Parse and read syslogs. @param string $type @throws NotFoundException @throws BadRequestException
[ "Parse", "and", "read", "syslogs", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Controller/LogsController.php#L29-L97
230,212
PHP-DI/Kernel
src/Kernel.php
Kernel.createContainer
public function createContainer() : Container { $containerBuilder = new ContainerBuilder(); foreach ($this->modules as $module) { $this->loadModule($containerBuilder, $module); } if (!empty($this->config)) { $containerBuilder->addDefinitions($this->config); } $this->configureContainerBuilder($containerBuilder); return $containerBuilder->build(); }
php
public function createContainer() : Container { $containerBuilder = new ContainerBuilder(); foreach ($this->modules as $module) { $this->loadModule($containerBuilder, $module); } if (!empty($this->config)) { $containerBuilder->addDefinitions($this->config); } $this->configureContainerBuilder($containerBuilder); return $containerBuilder->build(); }
[ "public", "function", "createContainer", "(", ")", ":", "Container", "{", "$", "containerBuilder", "=", "new", "ContainerBuilder", "(", ")", ";", "foreach", "(", "$", "this", "->", "modules", "as", "$", "module", ")", "{", "$", "this", "->", "loadModule", "(", "$", "containerBuilder", ",", "$", "module", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "config", ")", ")", "{", "$", "containerBuilder", "->", "addDefinitions", "(", "$", "this", "->", "config", ")", ";", "}", "$", "this", "->", "configureContainerBuilder", "(", "$", "containerBuilder", ")", ";", "return", "$", "containerBuilder", "->", "build", "(", ")", ";", "}" ]
Configure and create a container using all configuration files found in included modules.
[ "Configure", "and", "create", "a", "container", "using", "all", "configuration", "files", "found", "in", "included", "modules", "." ]
1ba55842874608cd73cdeee874a0826530195ee8
https://github.com/PHP-DI/Kernel/blob/1ba55842874608cd73cdeee874a0826530195ee8/src/Kernel.php#L62-L77
230,213
ipalaus/buffer-php-sdk
src/Ipalaus/Buffer/Button.php
Button.create
public static function create($style, $tweet = null, $url = null, $username = null, $picture = null) { if ( ! in_array($style, static::$styles)) { throw new InvalidArgumentException("Button style [{$style}] not supported."); } $anchor = '<a href="http://bufferapp.com/add" class="buffer-add-button" data-count="' . $style . '"'; if ( ! is_null($tweet)) { $anchor .= ' data-text="' . htmlspecialchars($tweet) . '"'; } if ( ! is_null($url)) { $anchor .= ' data-url="' . urlencode($url) . '"'; } if ( ! is_null($username)) { $anchor .= ' data-via="' . htmlspecialchars($username) . '"'; } if ( ! is_null($picture)) { $anchor .= ' data-picture="' . urlencode($picture) . '"'; } $anchor .= '>Buffer</a>'; $script = '<script type="text/javascript" src="//static.bufferapp.com/js/button.js"></script>'; return $anchor.$script; }
php
public static function create($style, $tweet = null, $url = null, $username = null, $picture = null) { if ( ! in_array($style, static::$styles)) { throw new InvalidArgumentException("Button style [{$style}] not supported."); } $anchor = '<a href="http://bufferapp.com/add" class="buffer-add-button" data-count="' . $style . '"'; if ( ! is_null($tweet)) { $anchor .= ' data-text="' . htmlspecialchars($tweet) . '"'; } if ( ! is_null($url)) { $anchor .= ' data-url="' . urlencode($url) . '"'; } if ( ! is_null($username)) { $anchor .= ' data-via="' . htmlspecialchars($username) . '"'; } if ( ! is_null($picture)) { $anchor .= ' data-picture="' . urlencode($picture) . '"'; } $anchor .= '>Buffer</a>'; $script = '<script type="text/javascript" src="//static.bufferapp.com/js/button.js"></script>'; return $anchor.$script; }
[ "public", "static", "function", "create", "(", "$", "style", ",", "$", "tweet", "=", "null", ",", "$", "url", "=", "null", ",", "$", "username", "=", "null", ",", "$", "picture", "=", "null", ")", "{", "if", "(", "!", "in_array", "(", "$", "style", ",", "static", "::", "$", "styles", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Button style [{$style}] not supported.\"", ")", ";", "}", "$", "anchor", "=", "'<a href=\"http://bufferapp.com/add\" class=\"buffer-add-button\" data-count=\"'", ".", "$", "style", ".", "'\"'", ";", "if", "(", "!", "is_null", "(", "$", "tweet", ")", ")", "{", "$", "anchor", ".=", "' data-text=\"'", ".", "htmlspecialchars", "(", "$", "tweet", ")", ".", "'\"'", ";", "}", "if", "(", "!", "is_null", "(", "$", "url", ")", ")", "{", "$", "anchor", ".=", "' data-url=\"'", ".", "urlencode", "(", "$", "url", ")", ".", "'\"'", ";", "}", "if", "(", "!", "is_null", "(", "$", "username", ")", ")", "{", "$", "anchor", ".=", "' data-via=\"'", ".", "htmlspecialchars", "(", "$", "username", ")", ".", "'\"'", ";", "}", "if", "(", "!", "is_null", "(", "$", "picture", ")", ")", "{", "$", "anchor", ".=", "' data-picture=\"'", ".", "urlencode", "(", "$", "picture", ")", ".", "'\"'", ";", "}", "$", "anchor", ".=", "'>Buffer</a>'", ";", "$", "script", "=", "'<script type=\"text/javascript\" src=\"//static.bufferapp.com/js/button.js\"></script>'", ";", "return", "$", "anchor", ".", "$", "script", ";", "}" ]
Generates a Buffer Button to let people share your content on Twitter and Facebook seamlessly. They can share right away or at a better time using Buffer. @param string $style @param string $tweet @param string $url @param string $username @param string $picture @return string
[ "Generates", "a", "Buffer", "Button", "to", "let", "people", "share", "your", "content", "on", "Twitter", "and", "Facebook", "seamlessly", ".", "They", "can", "share", "right", "away", "or", "at", "a", "better", "time", "using", "Buffer", "." ]
f9314df3510f1dcdd6b3d5f618ce845c5f56bd5f
https://github.com/ipalaus/buffer-php-sdk/blob/f9314df3510f1dcdd6b3d5f618ce845c5f56bd5f/src/Ipalaus/Buffer/Button.php#L29-L58
230,214
Webiny/Framework
src/Webiny/Component/Security/Token/Storage/Stateless.php
Stateless.getTokenString
public function getTokenString() { if (!$this->tokenString) { $token = $this->httpRequest()->header('Authorization'); if (!$token) { $token = $this->httpRequest()->post('Authorization'); } return $token; } return $this->tokenString; }
php
public function getTokenString() { if (!$this->tokenString) { $token = $this->httpRequest()->header('Authorization'); if (!$token) { $token = $this->httpRequest()->post('Authorization'); } return $token; } return $this->tokenString; }
[ "public", "function", "getTokenString", "(", ")", "{", "if", "(", "!", "$", "this", "->", "tokenString", ")", "{", "$", "token", "=", "$", "this", "->", "httpRequest", "(", ")", "->", "header", "(", "'Authorization'", ")", ";", "if", "(", "!", "$", "token", ")", "{", "$", "token", "=", "$", "this", "->", "httpRequest", "(", ")", "->", "post", "(", "'Authorization'", ")", ";", "}", "return", "$", "token", ";", "}", "return", "$", "this", "->", "tokenString", ";", "}" ]
Get token string representation @return string
[ "Get", "token", "string", "representation" ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Security/Token/Storage/Stateless.php#L150-L162
230,215
Webiny/Framework
src/Webiny/Component/Security/Token/Storage/Stateless.php
Stateless.getTokenTtl
public function getTokenTtl() { $rememberMe = $this->tokenRememberMe; $ttl = 86400; // 1 day if ($rememberMe) { $ttl = is_numeric($rememberMe) ? intval($rememberMe) : 2592000; // 30 days } return $ttl; }
php
public function getTokenTtl() { $rememberMe = $this->tokenRememberMe; $ttl = 86400; // 1 day if ($rememberMe) { $ttl = is_numeric($rememberMe) ? intval($rememberMe) : 2592000; // 30 days } return $ttl; }
[ "public", "function", "getTokenTtl", "(", ")", "{", "$", "rememberMe", "=", "$", "this", "->", "tokenRememberMe", ";", "$", "ttl", "=", "86400", ";", "// 1 day", "if", "(", "$", "rememberMe", ")", "{", "$", "ttl", "=", "is_numeric", "(", "$", "rememberMe", ")", "?", "intval", "(", "$", "rememberMe", ")", ":", "2592000", ";", "// 30 days", "}", "return", "$", "ttl", ";", "}" ]
Get token TTL in seconds @return int
[ "Get", "token", "TTL", "in", "seconds" ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Security/Token/Storage/Stateless.php#L178-L187
230,216
Webiny/Framework
src/Webiny/Component/Mailer/Bridge/Sendgrid/Message.php
Message.addTo
public function addTo(Email $email) { $this->to[] = $email; $this->message->addTo($email->email, $email->name); return $this; }
php
public function addTo(Email $email) { $this->to[] = $email; $this->message->addTo($email->email, $email->name); return $this; }
[ "public", "function", "addTo", "(", "Email", "$", "email", ")", "{", "$", "this", "->", "to", "[", "]", "=", "$", "email", ";", "$", "this", "->", "message", "->", "addTo", "(", "$", "email", "->", "email", ",", "$", "email", "->", "name", ")", ";", "return", "$", "this", ";", "}" ]
Appends one more recipient to the list. @param Email $email @return $this
[ "Appends", "one", "more", "recipient", "to", "the", "list", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Mailer/Bridge/Sendgrid/Message.php#L160-L166
230,217
Webiny/Framework
src/Webiny/Component/Image/ImageLoader.php
ImageLoader.getLoader
private static function getLoader() { if (self::isNull(self::$loader)) { self::$loader = Loader::getImageLoader(Image::getConfig()); } return self::$loader; }
php
private static function getLoader() { if (self::isNull(self::$loader)) { self::$loader = Loader::getImageLoader(Image::getConfig()); } return self::$loader; }
[ "private", "static", "function", "getLoader", "(", ")", "{", "if", "(", "self", "::", "isNull", "(", "self", "::", "$", "loader", ")", ")", "{", "self", "::", "$", "loader", "=", "Loader", "::", "getImageLoader", "(", "Image", "::", "getConfig", "(", ")", ")", ";", "}", "return", "self", "::", "$", "loader", ";", "}" ]
Returns an instance of ImageLoaderInterface. @return null|ImageLoaderInterface
[ "Returns", "an", "instance", "of", "ImageLoaderInterface", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Image/ImageLoader.php#L39-L46
230,218
Webiny/Framework
src/Webiny/Component/Image/ImageLoader.php
ImageLoader.open
public static function open(File $image) { $img = self::getLoader()->open($image); $img->setDestination($image); // extract the format $format = self::str($image->getKey())->explode('.')->last()->caseLower()->val(); $img->setFormat($format); // fix image orientation (iPhone/Android issue) self::fixImageOrientation($image, $img); return $img; }
php
public static function open(File $image) { $img = self::getLoader()->open($image); $img->setDestination($image); // extract the format $format = self::str($image->getKey())->explode('.')->last()->caseLower()->val(); $img->setFormat($format); // fix image orientation (iPhone/Android issue) self::fixImageOrientation($image, $img); return $img; }
[ "public", "static", "function", "open", "(", "File", "$", "image", ")", "{", "$", "img", "=", "self", "::", "getLoader", "(", ")", "->", "open", "(", "$", "image", ")", ";", "$", "img", "->", "setDestination", "(", "$", "image", ")", ";", "// extract the format", "$", "format", "=", "self", "::", "str", "(", "$", "image", "->", "getKey", "(", ")", ")", "->", "explode", "(", "'.'", ")", "->", "last", "(", ")", "->", "caseLower", "(", ")", "->", "val", "(", ")", ";", "$", "img", "->", "setFormat", "(", "$", "format", ")", ";", "// fix image orientation (iPhone/Android issue)", "self", "::", "fixImageOrientation", "(", "$", "image", ",", "$", "img", ")", ";", "return", "$", "img", ";", "}" ]
Creates a new ImageInterface instance from the given image at the provided path. @param File $image Path to an image on the disk. @return ImageInterface
[ "Creates", "a", "new", "ImageInterface", "instance", "from", "the", "given", "image", "at", "the", "provided", "path", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Image/ImageLoader.php#L96-L109
230,219
Webiny/Framework
src/Webiny/Component/Image/ImageLoader.php
ImageLoader.fixImageOrientation
private static function fixImageOrientation(File $imageFile, ImageInterface $image) { $format = $image->getFormat(); // exif data is available only on jpeg and tiff // tiff is ignored, because smartphones don't produce tiff images if ($format == 'jpg' || $format == 'jpeg') { $exifData = exif_read_data($imageFile->getAbsolutePath(), 'IFDO'); if (isset($exifData['Orientation'])) { switch ($exifData['Orientation']) { case 3: $rotation = 180; break; case 6: $rotation = 90; break; case 8: $rotation = -90; break; default: $rotation = 0; break; } if($rotation!=0){ $image->rotate($rotation); } } } }
php
private static function fixImageOrientation(File $imageFile, ImageInterface $image) { $format = $image->getFormat(); // exif data is available only on jpeg and tiff // tiff is ignored, because smartphones don't produce tiff images if ($format == 'jpg' || $format == 'jpeg') { $exifData = exif_read_data($imageFile->getAbsolutePath(), 'IFDO'); if (isset($exifData['Orientation'])) { switch ($exifData['Orientation']) { case 3: $rotation = 180; break; case 6: $rotation = 90; break; case 8: $rotation = -90; break; default: $rotation = 0; break; } if($rotation!=0){ $image->rotate($rotation); } } } }
[ "private", "static", "function", "fixImageOrientation", "(", "File", "$", "imageFile", ",", "ImageInterface", "$", "image", ")", "{", "$", "format", "=", "$", "image", "->", "getFormat", "(", ")", ";", "// exif data is available only on jpeg and tiff", "// tiff is ignored, because smartphones don't produce tiff images", "if", "(", "$", "format", "==", "'jpg'", "||", "$", "format", "==", "'jpeg'", ")", "{", "$", "exifData", "=", "exif_read_data", "(", "$", "imageFile", "->", "getAbsolutePath", "(", ")", ",", "'IFDO'", ")", ";", "if", "(", "isset", "(", "$", "exifData", "[", "'Orientation'", "]", ")", ")", "{", "switch", "(", "$", "exifData", "[", "'Orientation'", "]", ")", "{", "case", "3", ":", "$", "rotation", "=", "180", ";", "break", ";", "case", "6", ":", "$", "rotation", "=", "90", ";", "break", ";", "case", "8", ":", "$", "rotation", "=", "-", "90", ";", "break", ";", "default", ":", "$", "rotation", "=", "0", ";", "break", ";", "}", "if", "(", "$", "rotation", "!=", "0", ")", "{", "$", "image", "->", "rotate", "(", "$", "rotation", ")", ";", "}", "}", "}", "}" ]
Android and Iphone images are sometimes rotated "incorrectly". This method fixes that. Method is called automatically on the `open` method. @param File $imageFile @param ImageInterface $image
[ "Android", "and", "Iphone", "images", "are", "sometimes", "rotated", "incorrectly", ".", "This", "method", "fixes", "that", ".", "Method", "is", "called", "automatically", "on", "the", "open", "method", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Image/ImageLoader.php#L119-L148
230,220
themsaid/katana-core
src/FileHandlers/BlogPostHandler.php
BlogPostHandler.getPostData
public function getPostData(SplFileInfo $file) { $this->file = $file; if ($this->file->getExtension() == 'md') { $postData = Markdown::parseWithYAML($this->file->getContents())[1]; } else { $view = $this->viewFactory->make(str_replace('.blade.php', '', $this->file->getRelativePathname())); $postData = []; $view->render(function ($view) use (&$postData) { $postData = $view->getFactory()->getSections(); }); } // Get only values with keys starting with post:: $postData = array_where($postData, function ($key) { return starts_with($key, 'post::'); }); // Remove 'post::' from $postData keys foreach ($postData as $key => $val) { $postData[str_replace('post::', '', $key)] = $val; unset($postData[$key]); } $postData['path'] = str_replace(KATANA_PUBLIC_DIR, '', $this->getDirectoryPrettyName()).'/'; return json_decode(json_encode($postData), false); }
php
public function getPostData(SplFileInfo $file) { $this->file = $file; if ($this->file->getExtension() == 'md') { $postData = Markdown::parseWithYAML($this->file->getContents())[1]; } else { $view = $this->viewFactory->make(str_replace('.blade.php', '', $this->file->getRelativePathname())); $postData = []; $view->render(function ($view) use (&$postData) { $postData = $view->getFactory()->getSections(); }); } // Get only values with keys starting with post:: $postData = array_where($postData, function ($key) { return starts_with($key, 'post::'); }); // Remove 'post::' from $postData keys foreach ($postData as $key => $val) { $postData[str_replace('post::', '', $key)] = $val; unset($postData[$key]); } $postData['path'] = str_replace(KATANA_PUBLIC_DIR, '', $this->getDirectoryPrettyName()).'/'; return json_decode(json_encode($postData), false); }
[ "public", "function", "getPostData", "(", "SplFileInfo", "$", "file", ")", "{", "$", "this", "->", "file", "=", "$", "file", ";", "if", "(", "$", "this", "->", "file", "->", "getExtension", "(", ")", "==", "'md'", ")", "{", "$", "postData", "=", "Markdown", "::", "parseWithYAML", "(", "$", "this", "->", "file", "->", "getContents", "(", ")", ")", "[", "1", "]", ";", "}", "else", "{", "$", "view", "=", "$", "this", "->", "viewFactory", "->", "make", "(", "str_replace", "(", "'.blade.php'", ",", "''", ",", "$", "this", "->", "file", "->", "getRelativePathname", "(", ")", ")", ")", ";", "$", "postData", "=", "[", "]", ";", "$", "view", "->", "render", "(", "function", "(", "$", "view", ")", "use", "(", "&", "$", "postData", ")", "{", "$", "postData", "=", "$", "view", "->", "getFactory", "(", ")", "->", "getSections", "(", ")", ";", "}", ")", ";", "}", "// Get only values with keys starting with post::", "$", "postData", "=", "array_where", "(", "$", "postData", ",", "function", "(", "$", "key", ")", "{", "return", "starts_with", "(", "$", "key", ",", "'post::'", ")", ";", "}", ")", ";", "// Remove 'post::' from $postData keys", "foreach", "(", "$", "postData", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "postData", "[", "str_replace", "(", "'post::'", ",", "''", ",", "$", "key", ")", "]", "=", "$", "val", ";", "unset", "(", "$", "postData", "[", "$", "key", "]", ")", ";", "}", "$", "postData", "[", "'path'", "]", "=", "str_replace", "(", "KATANA_PUBLIC_DIR", ",", "''", ",", "$", "this", "->", "getDirectoryPrettyName", "(", ")", ")", ".", "'/'", ";", "return", "json_decode", "(", "json_encode", "(", "$", "postData", ")", ",", "false", ")", ";", "}" ]
Get the blog post data. @param SplFileInfo $file @return \stdClass
[ "Get", "the", "blog", "post", "data", "." ]
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/FileHandlers/BlogPostHandler.php#L17-L48
230,221
themsaid/katana-core
src/FileHandlers/BlogPostHandler.php
BlogPostHandler.getDirectoryPrettyName
protected function getDirectoryPrettyName() { $pathName = $this->normalizePath($this->file->getPathname()); // If the post is inside a child directory of the _blog directory then // we deal with it like regular site files and generate a nested // directories based post path with exact file name. if ($this->isInsideBlogDirectory($pathName)) { return str_replace('/_blog/', '/', parent::getDirectoryPrettyName()); } $fileBaseName = $this->getFileName(); $fileRelativePath = $this->getBlogPostSlug($fileBaseName); return KATANA_PUBLIC_DIR."/$fileRelativePath"; }
php
protected function getDirectoryPrettyName() { $pathName = $this->normalizePath($this->file->getPathname()); // If the post is inside a child directory of the _blog directory then // we deal with it like regular site files and generate a nested // directories based post path with exact file name. if ($this->isInsideBlogDirectory($pathName)) { return str_replace('/_blog/', '/', parent::getDirectoryPrettyName()); } $fileBaseName = $this->getFileName(); $fileRelativePath = $this->getBlogPostSlug($fileBaseName); return KATANA_PUBLIC_DIR."/$fileRelativePath"; }
[ "protected", "function", "getDirectoryPrettyName", "(", ")", "{", "$", "pathName", "=", "$", "this", "->", "normalizePath", "(", "$", "this", "->", "file", "->", "getPathname", "(", ")", ")", ";", "// If the post is inside a child directory of the _blog directory then", "// we deal with it like regular site files and generate a nested", "// directories based post path with exact file name.", "if", "(", "$", "this", "->", "isInsideBlogDirectory", "(", "$", "pathName", ")", ")", "{", "return", "str_replace", "(", "'/_blog/'", ",", "'/'", ",", "parent", "::", "getDirectoryPrettyName", "(", ")", ")", ";", "}", "$", "fileBaseName", "=", "$", "this", "->", "getFileName", "(", ")", ";", "$", "fileRelativePath", "=", "$", "this", "->", "getBlogPostSlug", "(", "$", "fileBaseName", ")", ";", "return", "KATANA_PUBLIC_DIR", ".", "\"/$fileRelativePath\"", ";", "}" ]
Generate directory path to be used for pretty URLs. @return string
[ "Generate", "directory", "path", "to", "be", "used", "for", "pretty", "URLs", "." ]
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/FileHandlers/BlogPostHandler.php#L55-L71
230,222
Webiny/Framework
src/Webiny/Component/TemplateEngine/TemplateEngineLoader.php
TemplateEngineLoader.getInstance
static function getInstance($driver) { if (isset(self::$instances[$driver])) { return self::$instances[$driver]; } $driverConfig = TemplateEngine::getConfig()->get('Engines.' . $driver, false); if (!$driverConfig) { throw new TemplateEngineException('Unable to read driver configuration: TemplateEngine.Engines.' . $driver); } try { self::$instances[$driver] = TemplateEngineBridge::getInstance($driver, $driverConfig); return self::$instances[$driver]; } catch (\Exception $e) { throw $e; } }
php
static function getInstance($driver) { if (isset(self::$instances[$driver])) { return self::$instances[$driver]; } $driverConfig = TemplateEngine::getConfig()->get('Engines.' . $driver, false); if (!$driverConfig) { throw new TemplateEngineException('Unable to read driver configuration: TemplateEngine.Engines.' . $driver); } try { self::$instances[$driver] = TemplateEngineBridge::getInstance($driver, $driverConfig); return self::$instances[$driver]; } catch (\Exception $e) { throw $e; } }
[ "static", "function", "getInstance", "(", "$", "driver", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "instances", "[", "$", "driver", "]", ")", ")", "{", "return", "self", "::", "$", "instances", "[", "$", "driver", "]", ";", "}", "$", "driverConfig", "=", "TemplateEngine", "::", "getConfig", "(", ")", "->", "get", "(", "'Engines.'", ".", "$", "driver", ",", "false", ")", ";", "if", "(", "!", "$", "driverConfig", ")", "{", "throw", "new", "TemplateEngineException", "(", "'Unable to read driver configuration: TemplateEngine.Engines.'", ".", "$", "driver", ")", ";", "}", "try", "{", "self", "::", "$", "instances", "[", "$", "driver", "]", "=", "TemplateEngineBridge", "::", "getInstance", "(", "$", "driver", ",", "$", "driverConfig", ")", ";", "return", "self", "::", "$", "instances", "[", "$", "driver", "]", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Returns an instance of template engine driver. If the requested driver is already created, the same instance is returned. @param string $driver Name of the template engine driver. Must correspond to components.template_engine.engines.{$driver}. @return \Webiny\Component\TemplateEngine\Bridge\TemplateEngineInterface @throws TemplateEngineException @throws \Exception
[ "Returns", "an", "instance", "of", "template", "engine", "driver", ".", "If", "the", "requested", "driver", "is", "already", "created", "the", "same", "instance", "is", "returned", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/TemplateEngine/TemplateEngineLoader.php#L35-L54
230,223
Webiny/Framework
src/Webiny/Component/ServiceManager/Argument.php
Argument.value
public function value() { /** * If 'object' key exists - it's either a class or service **/ if ($this->isArray($this->value) && array_key_exists('Object', $this->value)) { $this->value = $this->arr($this->value); $objectArguments = $this->value->key('ObjectArguments', [], true); $this->value = $this->createValue($this->value->key('Object'), $this->parseArguments($objectArguments)); } else { $this->value = $this->createValue($this->value); } return $this->value; }
php
public function value() { /** * If 'object' key exists - it's either a class or service **/ if ($this->isArray($this->value) && array_key_exists('Object', $this->value)) { $this->value = $this->arr($this->value); $objectArguments = $this->value->key('ObjectArguments', [], true); $this->value = $this->createValue($this->value->key('Object'), $this->parseArguments($objectArguments)); } else { $this->value = $this->createValue($this->value); } return $this->value; }
[ "public", "function", "value", "(", ")", "{", "/**\n * If 'object' key exists - it's either a class or service\n **/", "if", "(", "$", "this", "->", "isArray", "(", "$", "this", "->", "value", ")", "&&", "array_key_exists", "(", "'Object'", ",", "$", "this", "->", "value", ")", ")", "{", "$", "this", "->", "value", "=", "$", "this", "->", "arr", "(", "$", "this", "->", "value", ")", ";", "$", "objectArguments", "=", "$", "this", "->", "value", "->", "key", "(", "'ObjectArguments'", ",", "[", "]", ",", "true", ")", ";", "$", "this", "->", "value", "=", "$", "this", "->", "createValue", "(", "$", "this", "->", "value", "->", "key", "(", "'Object'", ")", ",", "$", "this", "->", "parseArguments", "(", "$", "objectArguments", ")", ")", ";", "}", "else", "{", "$", "this", "->", "value", "=", "$", "this", "->", "createValue", "(", "$", "this", "->", "value", ")", ";", "}", "return", "$", "this", "->", "value", ";", "}" ]
Get real Argument value @return mixed
[ "Get", "real", "Argument", "value" ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/ServiceManager/Argument.php#L43-L57
230,224
Webiny/Framework
src/Webiny/Component/ServiceManager/Argument.php
Argument.createValue
private function createValue($object, $arguments = []) { if ($this->isInstanceOf($arguments, ConfigObject::class)) { $arguments = $arguments->toArray(); } if (!$this->isArray($arguments)) { throw new ServiceManagerException(ServiceManagerException::INVALID_SERVICE_ARGUMENTS_TYPE, [$object]); } if (!$this->isString($object)) { return $object; } $object = $this->str($object); if ($object->startsWith('@')) { return ServiceManager::getInstance()->getService($object->trimLeft('@')->val()); } else { $value = $object->val(); if (class_exists($value)) { $reflection = new \ReflectionClass($value); return $reflection->newInstanceArgs($arguments); } return $value; } }
php
private function createValue($object, $arguments = []) { if ($this->isInstanceOf($arguments, ConfigObject::class)) { $arguments = $arguments->toArray(); } if (!$this->isArray($arguments)) { throw new ServiceManagerException(ServiceManagerException::INVALID_SERVICE_ARGUMENTS_TYPE, [$object]); } if (!$this->isString($object)) { return $object; } $object = $this->str($object); if ($object->startsWith('@')) { return ServiceManager::getInstance()->getService($object->trimLeft('@')->val()); } else { $value = $object->val(); if (class_exists($value)) { $reflection = new \ReflectionClass($value); return $reflection->newInstanceArgs($arguments); } return $value; } }
[ "private", "function", "createValue", "(", "$", "object", ",", "$", "arguments", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isInstanceOf", "(", "$", "arguments", ",", "ConfigObject", "::", "class", ")", ")", "{", "$", "arguments", "=", "$", "arguments", "->", "toArray", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isArray", "(", "$", "arguments", ")", ")", "{", "throw", "new", "ServiceManagerException", "(", "ServiceManagerException", "::", "INVALID_SERVICE_ARGUMENTS_TYPE", ",", "[", "$", "object", "]", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isString", "(", "$", "object", ")", ")", "{", "return", "$", "object", ";", "}", "$", "object", "=", "$", "this", "->", "str", "(", "$", "object", ")", ";", "if", "(", "$", "object", "->", "startsWith", "(", "'@'", ")", ")", "{", "return", "ServiceManager", "::", "getInstance", "(", ")", "->", "getService", "(", "$", "object", "->", "trimLeft", "(", "'@'", ")", "->", "val", "(", ")", ")", ";", "}", "else", "{", "$", "value", "=", "$", "object", "->", "val", "(", ")", ";", "if", "(", "class_exists", "(", "$", "value", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "value", ")", ";", "return", "$", "reflection", "->", "newInstanceArgs", "(", "$", "arguments", ")", ";", "}", "return", "$", "value", ";", "}", "}" ]
Create proper argument value @param mixed $object @param array $arguments @throws ServiceManagerException @return mixed|object
[ "Create", "proper", "argument", "value" ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/ServiceManager/Argument.php#L80-L109
230,225
milesj/admin
Controller/ReportsController.php
ReportsController.index
public function index() { $this->paginate = array_merge(array( 'limit' => 25, 'order' => array('ItemReport.' . $this->Model->displayField => 'ASC'), 'contain' => array_keys($this->Model->belongsTo), 'conditions' => array('ItemReport.status' => ItemReport::PENDING) ), $this->Model->admin['paginate']); $this->AdminToolbar->setBelongsToData($this->Model); $this->request->data['ItemReport']['status'] = ItemReport::PENDING; // Filters if (!empty($this->request->params['named'])) { $this->paginate['conditions'] = $this->AdminToolbar->parseFilterConditions($this->Model, $this->request->params['named']); } $this->set('results', $this->paginate($this->Model)); }
php
public function index() { $this->paginate = array_merge(array( 'limit' => 25, 'order' => array('ItemReport.' . $this->Model->displayField => 'ASC'), 'contain' => array_keys($this->Model->belongsTo), 'conditions' => array('ItemReport.status' => ItemReport::PENDING) ), $this->Model->admin['paginate']); $this->AdminToolbar->setBelongsToData($this->Model); $this->request->data['ItemReport']['status'] = ItemReport::PENDING; // Filters if (!empty($this->request->params['named'])) { $this->paginate['conditions'] = $this->AdminToolbar->parseFilterConditions($this->Model, $this->request->params['named']); } $this->set('results', $this->paginate($this->Model)); }
[ "public", "function", "index", "(", ")", "{", "$", "this", "->", "paginate", "=", "array_merge", "(", "array", "(", "'limit'", "=>", "25", ",", "'order'", "=>", "array", "(", "'ItemReport.'", ".", "$", "this", "->", "Model", "->", "displayField", "=>", "'ASC'", ")", ",", "'contain'", "=>", "array_keys", "(", "$", "this", "->", "Model", "->", "belongsTo", ")", ",", "'conditions'", "=>", "array", "(", "'ItemReport.status'", "=>", "ItemReport", "::", "PENDING", ")", ")", ",", "$", "this", "->", "Model", "->", "admin", "[", "'paginate'", "]", ")", ";", "$", "this", "->", "AdminToolbar", "->", "setBelongsToData", "(", "$", "this", "->", "Model", ")", ";", "$", "this", "->", "request", "->", "data", "[", "'ItemReport'", "]", "[", "'status'", "]", "=", "ItemReport", "::", "PENDING", ";", "// Filters", "if", "(", "!", "empty", "(", "$", "this", "->", "request", "->", "params", "[", "'named'", "]", ")", ")", "{", "$", "this", "->", "paginate", "[", "'conditions'", "]", "=", "$", "this", "->", "AdminToolbar", "->", "parseFilterConditions", "(", "$", "this", "->", "Model", ",", "$", "this", "->", "request", "->", "params", "[", "'named'", "]", ")", ";", "}", "$", "this", "->", "set", "(", "'results'", ",", "$", "this", "->", "paginate", "(", "$", "this", "->", "Model", ")", ")", ";", "}" ]
Paginate the reports.
[ "Paginate", "the", "reports", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Controller/ReportsController.php#L16-L34
230,226
Webiny/Framework
src/Webiny/Component/Rest/Response/RateControl.php
RateControl.isWithinRateLimits
public static function isWithinRateLimits(RequestBag $requestBag, CallbackResult $cr) { // do we have rate control in place? if (!($rateControl = $requestBag->getApiConfig()->get('RateControl', false))) { return true; // if rate control is not set, user is within his limits } // check if we should ignore rate control for this particular method if (isset($requestBag->getMethodData()['rateControl']['ignore'])) { return true; } // verify that we have a Cache service set if (!($cache = $requestBag->getApiConfig()->get('Cache', false))) { throw new RestException('Rest Rate Control requires that you have a Cache service defined under the Rest configuration.' ); } // set the limit in response header $cr->attachDebugHeader('RateControl-Limit', $rateControl->Limit, true); // get current usage $cacheKey = md5('Webiny.Rest.RateLimit.' . self::httpRequest()->getClientIp()); $cacheData = self::cache($cache)->read($cacheKey); if (!$cacheData) { $cacheData = [ 'usage' => 0, 'penalty' => 0, 'ttl' => time() + (60 * $rateControl->Interval) ]; } else { $cacheData = self::unserialize($cacheData); // validate the ttl if (time() > $cacheData['ttl']) { $cacheData = [ 'usage' => 0, 'penalty' => 0, 'ttl' => time() + (60 * $rateControl->Interval) ]; } } // check if user is already in penalty if ($cacheData['penalty'] > time()) { // when in penalty the reset value, equals the penalty value $cr->attachDebugHeader('RateControl-Reset', ($cacheData['penalty'] - time()), true); // and the remaining equals 0 $cr->attachDebugHeader('RateControl-Remaining', 0, true); return false; } // check if rate is reached if ($cacheData['usage'] >= $rateControl->Limit) { // set penalty for reaching the limit $cr->attachDebugHeader('RateControl-Reset', (($rateControl->Penalty * 60) + time()), true); // and the remaining 0 $cr->attachDebugHeader('RateControl-Remaining', 0, true); return false; } // if limit not reached, increment the usage and save the data $cacheData['usage']++; $cr->attachDebugHeader('RateControl-Remaining', ($rateControl->Limit - $cacheData['usage']), true); $cr->attachDebugHeader('RateControl-Reset', $cacheData['ttl'], true); $cacheTtl = ($rateControl->Interval > $rateControl->Penalty) ? $rateControl->Interval : $rateControl->Penalty; self::cache($cache)->save($cacheKey, self::serialize($cacheData), ($cacheTtl * 60)); return true; }
php
public static function isWithinRateLimits(RequestBag $requestBag, CallbackResult $cr) { // do we have rate control in place? if (!($rateControl = $requestBag->getApiConfig()->get('RateControl', false))) { return true; // if rate control is not set, user is within his limits } // check if we should ignore rate control for this particular method if (isset($requestBag->getMethodData()['rateControl']['ignore'])) { return true; } // verify that we have a Cache service set if (!($cache = $requestBag->getApiConfig()->get('Cache', false))) { throw new RestException('Rest Rate Control requires that you have a Cache service defined under the Rest configuration.' ); } // set the limit in response header $cr->attachDebugHeader('RateControl-Limit', $rateControl->Limit, true); // get current usage $cacheKey = md5('Webiny.Rest.RateLimit.' . self::httpRequest()->getClientIp()); $cacheData = self::cache($cache)->read($cacheKey); if (!$cacheData) { $cacheData = [ 'usage' => 0, 'penalty' => 0, 'ttl' => time() + (60 * $rateControl->Interval) ]; } else { $cacheData = self::unserialize($cacheData); // validate the ttl if (time() > $cacheData['ttl']) { $cacheData = [ 'usage' => 0, 'penalty' => 0, 'ttl' => time() + (60 * $rateControl->Interval) ]; } } // check if user is already in penalty if ($cacheData['penalty'] > time()) { // when in penalty the reset value, equals the penalty value $cr->attachDebugHeader('RateControl-Reset', ($cacheData['penalty'] - time()), true); // and the remaining equals 0 $cr->attachDebugHeader('RateControl-Remaining', 0, true); return false; } // check if rate is reached if ($cacheData['usage'] >= $rateControl->Limit) { // set penalty for reaching the limit $cr->attachDebugHeader('RateControl-Reset', (($rateControl->Penalty * 60) + time()), true); // and the remaining 0 $cr->attachDebugHeader('RateControl-Remaining', 0, true); return false; } // if limit not reached, increment the usage and save the data $cacheData['usage']++; $cr->attachDebugHeader('RateControl-Remaining', ($rateControl->Limit - $cacheData['usage']), true); $cr->attachDebugHeader('RateControl-Reset', $cacheData['ttl'], true); $cacheTtl = ($rateControl->Interval > $rateControl->Penalty) ? $rateControl->Interval : $rateControl->Penalty; self::cache($cache)->save($cacheKey, self::serialize($cacheData), ($cacheTtl * 60)); return true; }
[ "public", "static", "function", "isWithinRateLimits", "(", "RequestBag", "$", "requestBag", ",", "CallbackResult", "$", "cr", ")", "{", "// do we have rate control in place?", "if", "(", "!", "(", "$", "rateControl", "=", "$", "requestBag", "->", "getApiConfig", "(", ")", "->", "get", "(", "'RateControl'", ",", "false", ")", ")", ")", "{", "return", "true", ";", "// if rate control is not set, user is within his limits", "}", "// check if we should ignore rate control for this particular method", "if", "(", "isset", "(", "$", "requestBag", "->", "getMethodData", "(", ")", "[", "'rateControl'", "]", "[", "'ignore'", "]", ")", ")", "{", "return", "true", ";", "}", "// verify that we have a Cache service set", "if", "(", "!", "(", "$", "cache", "=", "$", "requestBag", "->", "getApiConfig", "(", ")", "->", "get", "(", "'Cache'", ",", "false", ")", ")", ")", "{", "throw", "new", "RestException", "(", "'Rest Rate Control requires that you have a Cache service defined\n under the Rest configuration.'", ")", ";", "}", "// set the limit in response header", "$", "cr", "->", "attachDebugHeader", "(", "'RateControl-Limit'", ",", "$", "rateControl", "->", "Limit", ",", "true", ")", ";", "// get current usage", "$", "cacheKey", "=", "md5", "(", "'Webiny.Rest.RateLimit.'", ".", "self", "::", "httpRequest", "(", ")", "->", "getClientIp", "(", ")", ")", ";", "$", "cacheData", "=", "self", "::", "cache", "(", "$", "cache", ")", "->", "read", "(", "$", "cacheKey", ")", ";", "if", "(", "!", "$", "cacheData", ")", "{", "$", "cacheData", "=", "[", "'usage'", "=>", "0", ",", "'penalty'", "=>", "0", ",", "'ttl'", "=>", "time", "(", ")", "+", "(", "60", "*", "$", "rateControl", "->", "Interval", ")", "]", ";", "}", "else", "{", "$", "cacheData", "=", "self", "::", "unserialize", "(", "$", "cacheData", ")", ";", "// validate the ttl", "if", "(", "time", "(", ")", ">", "$", "cacheData", "[", "'ttl'", "]", ")", "{", "$", "cacheData", "=", "[", "'usage'", "=>", "0", ",", "'penalty'", "=>", "0", ",", "'ttl'", "=>", "time", "(", ")", "+", "(", "60", "*", "$", "rateControl", "->", "Interval", ")", "]", ";", "}", "}", "// check if user is already in penalty", "if", "(", "$", "cacheData", "[", "'penalty'", "]", ">", "time", "(", ")", ")", "{", "// when in penalty the reset value, equals the penalty value", "$", "cr", "->", "attachDebugHeader", "(", "'RateControl-Reset'", ",", "(", "$", "cacheData", "[", "'penalty'", "]", "-", "time", "(", ")", ")", ",", "true", ")", ";", "// and the remaining equals 0", "$", "cr", "->", "attachDebugHeader", "(", "'RateControl-Remaining'", ",", "0", ",", "true", ")", ";", "return", "false", ";", "}", "// check if rate is reached", "if", "(", "$", "cacheData", "[", "'usage'", "]", ">=", "$", "rateControl", "->", "Limit", ")", "{", "// set penalty for reaching the limit", "$", "cr", "->", "attachDebugHeader", "(", "'RateControl-Reset'", ",", "(", "(", "$", "rateControl", "->", "Penalty", "*", "60", ")", "+", "time", "(", ")", ")", ",", "true", ")", ";", "// and the remaining 0", "$", "cr", "->", "attachDebugHeader", "(", "'RateControl-Remaining'", ",", "0", ",", "true", ")", ";", "return", "false", ";", "}", "// if limit not reached, increment the usage and save the data", "$", "cacheData", "[", "'usage'", "]", "++", ";", "$", "cr", "->", "attachDebugHeader", "(", "'RateControl-Remaining'", ",", "(", "$", "rateControl", "->", "Limit", "-", "$", "cacheData", "[", "'usage'", "]", ")", ",", "true", ")", ";", "$", "cr", "->", "attachDebugHeader", "(", "'RateControl-Reset'", ",", "$", "cacheData", "[", "'ttl'", "]", ",", "true", ")", ";", "$", "cacheTtl", "=", "(", "$", "rateControl", "->", "Interval", ">", "$", "rateControl", "->", "Penalty", ")", "?", "$", "rateControl", "->", "Interval", ":", "$", "rateControl", "->", "Penalty", ";", "self", "::", "cache", "(", "$", "cache", ")", "->", "save", "(", "$", "cacheKey", ",", "self", "::", "serialize", "(", "$", "cacheData", ")", ",", "(", "$", "cacheTtl", "*", "60", ")", ")", ";", "return", "true", ";", "}" ]
Checks if user is within rate limits. @param RequestBag $requestBag @param CallbackResult $cr @return bool @throws \Webiny\Component\Rest\RestException
[ "Checks", "if", "user", "is", "within", "rate", "limits", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/Response/RateControl.php#L36-L112
230,227
decred/decred-php-api
src/Decred/Data/DataClient.php
DataClient.getAddressRaw
public function getAddressRaw($address, \DateTime $from = null) { $result = false; $response = $this->request(sprintf('/api/address/%s/raw', $address)); if ($response !== false && is_array($response)) { $result = []; foreach ($response as $data) { $transaction = new Transaction($data); if ($transaction->getOutAmount($address) !== false) { if ($from === null || $transaction->getTime() > $from) { $result[] = $transaction; } } } } return $result; }
php
public function getAddressRaw($address, \DateTime $from = null) { $result = false; $response = $this->request(sprintf('/api/address/%s/raw', $address)); if ($response !== false && is_array($response)) { $result = []; foreach ($response as $data) { $transaction = new Transaction($data); if ($transaction->getOutAmount($address) !== false) { if ($from === null || $transaction->getTime() > $from) { $result[] = $transaction; } } } } return $result; }
[ "public", "function", "getAddressRaw", "(", "$", "address", ",", "\\", "DateTime", "$", "from", "=", "null", ")", "{", "$", "result", "=", "false", ";", "$", "response", "=", "$", "this", "->", "request", "(", "sprintf", "(", "'/api/address/%s/raw'", ",", "$", "address", ")", ")", ";", "if", "(", "$", "response", "!==", "false", "&&", "is_array", "(", "$", "response", ")", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "response", "as", "$", "data", ")", "{", "$", "transaction", "=", "new", "Transaction", "(", "$", "data", ")", ";", "if", "(", "$", "transaction", "->", "getOutAmount", "(", "$", "address", ")", "!==", "false", ")", "{", "if", "(", "$", "from", "===", "null", "||", "$", "transaction", "->", "getTime", "(", ")", ">", "$", "from", ")", "{", "$", "result", "[", "]", "=", "$", "transaction", ";", "}", "}", "}", "}", "return", "$", "result", ";", "}" ]
Get address raw presentation. @param string $address Address @param \DateTime|null $from Filter older transactions @return array|bool|Transaction[]
[ "Get", "address", "raw", "presentation", "." ]
dafea9ceac918c4c3cd9bc7c436009a95dfb1643
https://github.com/decred/decred-php-api/blob/dafea9ceac918c4c3cd9bc7c436009a95dfb1643/src/Decred/Data/DataClient.php#L46-L66
230,228
Webiny/Framework
src/Webiny/Component/ClassLoader/Loaders/Pear.php
Pear.registerMap
public function registerMap($prefix, $library) { // check the structure of location if it contains metadata if (is_array($library)) { $path = $library['Path']; $this->rules[$prefix] = $library; } else { $path = $library; } $this->maps[$prefix] = $path; }
php
public function registerMap($prefix, $library) { // check the structure of location if it contains metadata if (is_array($library)) { $path = $library['Path']; $this->rules[$prefix] = $library; } else { $path = $library; } $this->maps[$prefix] = $path; }
[ "public", "function", "registerMap", "(", "$", "prefix", ",", "$", "library", ")", "{", "// check the structure of location if it contains metadata", "if", "(", "is_array", "(", "$", "library", ")", ")", "{", "$", "path", "=", "$", "library", "[", "'Path'", "]", ";", "$", "this", "->", "rules", "[", "$", "prefix", "]", "=", "$", "library", ";", "}", "else", "{", "$", "path", "=", "$", "library", ";", "}", "$", "this", "->", "maps", "[", "$", "prefix", "]", "=", "$", "path", ";", "}" ]
Register a map. @param string $prefix Map prefix or namespace. @param array|string $library Absolute path to the library or an array with path and additional options. @return void
[ "Register", "a", "map", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/ClassLoader/Loaders/Pear.php#L30-L41
230,229
milesj/admin
Model/FileUpload.php
FileUpload.beforeUpload
public function beforeUpload($options) { $data = $this->data[$this->alias]; // Remove transforms for non-image files if (!empty($data['path']['type']) && strpos($data['path']['type'], 'image') === false) { $options['transforms'] = array(); } // Overwrite transforms from UploadController::index() if (!empty($data['transforms'])) { $oldTransforms = $options['transforms']; $options['transforms'] = array(); foreach (array('path_thumb', 'path_large') as $field) { $newTransform = empty($oldTransforms[$field]) ? array() : $oldTransforms[$field]; // Only apply if checkbox is checked if (!empty($data['transforms'][$field]['transform'])) { $options['transforms'][$field] = array_merge($newTransform, $data['transforms'][$field]); } } } // Overwrite transport from UploadController::index() if (!empty($data['transport'])) { $options['transport'] = array(); if (!empty($data['transport']['class'])) { $options['transport'] = $data['transport']; } } return $options; }
php
public function beforeUpload($options) { $data = $this->data[$this->alias]; // Remove transforms for non-image files if (!empty($data['path']['type']) && strpos($data['path']['type'], 'image') === false) { $options['transforms'] = array(); } // Overwrite transforms from UploadController::index() if (!empty($data['transforms'])) { $oldTransforms = $options['transforms']; $options['transforms'] = array(); foreach (array('path_thumb', 'path_large') as $field) { $newTransform = empty($oldTransforms[$field]) ? array() : $oldTransforms[$field]; // Only apply if checkbox is checked if (!empty($data['transforms'][$field]['transform'])) { $options['transforms'][$field] = array_merge($newTransform, $data['transforms'][$field]); } } } // Overwrite transport from UploadController::index() if (!empty($data['transport'])) { $options['transport'] = array(); if (!empty($data['transport']['class'])) { $options['transport'] = $data['transport']; } } return $options; }
[ "public", "function", "beforeUpload", "(", "$", "options", ")", "{", "$", "data", "=", "$", "this", "->", "data", "[", "$", "this", "->", "alias", "]", ";", "// Remove transforms for non-image files", "if", "(", "!", "empty", "(", "$", "data", "[", "'path'", "]", "[", "'type'", "]", ")", "&&", "strpos", "(", "$", "data", "[", "'path'", "]", "[", "'type'", "]", ",", "'image'", ")", "===", "false", ")", "{", "$", "options", "[", "'transforms'", "]", "=", "array", "(", ")", ";", "}", "// Overwrite transforms from UploadController::index()", "if", "(", "!", "empty", "(", "$", "data", "[", "'transforms'", "]", ")", ")", "{", "$", "oldTransforms", "=", "$", "options", "[", "'transforms'", "]", ";", "$", "options", "[", "'transforms'", "]", "=", "array", "(", ")", ";", "foreach", "(", "array", "(", "'path_thumb'", ",", "'path_large'", ")", "as", "$", "field", ")", "{", "$", "newTransform", "=", "empty", "(", "$", "oldTransforms", "[", "$", "field", "]", ")", "?", "array", "(", ")", ":", "$", "oldTransforms", "[", "$", "field", "]", ";", "// Only apply if checkbox is checked", "if", "(", "!", "empty", "(", "$", "data", "[", "'transforms'", "]", "[", "$", "field", "]", "[", "'transform'", "]", ")", ")", "{", "$", "options", "[", "'transforms'", "]", "[", "$", "field", "]", "=", "array_merge", "(", "$", "newTransform", ",", "$", "data", "[", "'transforms'", "]", "[", "$", "field", "]", ")", ";", "}", "}", "}", "// Overwrite transport from UploadController::index()", "if", "(", "!", "empty", "(", "$", "data", "[", "'transport'", "]", ")", ")", "{", "$", "options", "[", "'transport'", "]", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "data", "[", "'transport'", "]", "[", "'class'", "]", ")", ")", "{", "$", "options", "[", "'transport'", "]", "=", "$", "data", "[", "'transport'", "]", ";", "}", "}", "return", "$", "options", ";", "}" ]
Remove transforms if file is not an image. @param array $options @return array
[ "Remove", "transforms", "if", "file", "is", "not", "an", "image", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Model/FileUpload.php#L124-L157
230,230
Webiny/Framework
src/Webiny/Component/OAuth2/Bridge/OAuth2.php
OAuth2.getInstance
static function getInstance($clientId, $clientSecret, $redirectUri, $certificateFile = '') { $driver = static::getLibrary(); try { $instance = new $driver($clientId, $clientSecret, $redirectUri); } catch (\Exception $e) { throw new Exception('Unable to create an instance of ' . $driver); } if (!self::isInstanceOf($instance, OAuth2Interface::class)) { throw new Exception(Exception::MSG_INVALID_ARG, ['driver', OAuth2Interface::class]); } if ($certificateFile != '') { $instance->setCertificate($certificateFile); } return $instance; }
php
static function getInstance($clientId, $clientSecret, $redirectUri, $certificateFile = '') { $driver = static::getLibrary(); try { $instance = new $driver($clientId, $clientSecret, $redirectUri); } catch (\Exception $e) { throw new Exception('Unable to create an instance of ' . $driver); } if (!self::isInstanceOf($instance, OAuth2Interface::class)) { throw new Exception(Exception::MSG_INVALID_ARG, ['driver', OAuth2Interface::class]); } if ($certificateFile != '') { $instance->setCertificate($certificateFile); } return $instance; }
[ "static", "function", "getInstance", "(", "$", "clientId", ",", "$", "clientSecret", ",", "$", "redirectUri", ",", "$", "certificateFile", "=", "''", ")", "{", "$", "driver", "=", "static", "::", "getLibrary", "(", ")", ";", "try", "{", "$", "instance", "=", "new", "$", "driver", "(", "$", "clientId", ",", "$", "clientSecret", ",", "$", "redirectUri", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "'Unable to create an instance of '", ".", "$", "driver", ")", ";", "}", "if", "(", "!", "self", "::", "isInstanceOf", "(", "$", "instance", ",", "OAuth2Interface", "::", "class", ")", ")", "{", "throw", "new", "Exception", "(", "Exception", "::", "MSG_INVALID_ARG", ",", "[", "'driver'", ",", "OAuth2Interface", "::", "class", "]", ")", ";", "}", "if", "(", "$", "certificateFile", "!=", "''", ")", "{", "$", "instance", "->", "setCertificate", "(", "$", "certificateFile", ")", ";", "}", "return", "$", "instance", ";", "}" ]
Create an instance of an OAuth2 driver. @param string $clientId Client id. @param string $clientSecret Client secret. @param string $redirectUri Target url where to redirect after authentication. @param string $certificateFile @throws Exception @return AbstractOAuth2
[ "Create", "an", "instance", "of", "an", "OAuth2", "driver", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/OAuth2/Bridge/OAuth2.php#L61-L80
230,231
markguinn/silverstripe-ajax
code/AjaxHttpResponse.php
AjaxHTTPResponse.triggerEvent
public function triggerEvent($eventName, $eventData=1) { if (!empty($eventName)) { $this->events[$eventName] = $eventData; } return $this; }
php
public function triggerEvent($eventName, $eventData=1) { if (!empty($eventName)) { $this->events[$eventName] = $eventData; } return $this; }
[ "public", "function", "triggerEvent", "(", "$", "eventName", ",", "$", "eventData", "=", "1", ")", "{", "if", "(", "!", "empty", "(", "$", "eventName", ")", ")", "{", "$", "this", "->", "events", "[", "$", "eventName", "]", "=", "$", "eventData", ";", "}", "return", "$", "this", ";", "}" ]
Queues up an event to be triggered on the client when the response is received. Events are not gauranteed to be triggered in order. Events are triggered AFTER regions are replaced. @param string $eventName @param mixed $eventData - must be json encodable @return $this
[ "Queues", "up", "an", "event", "to", "be", "triggered", "on", "the", "client", "when", "the", "response", "is", "received", ".", "Events", "are", "not", "gauranteed", "to", "be", "triggered", "in", "order", ".", "Events", "are", "triggered", "AFTER", "regions", "are", "replaced", "." ]
4fcfa4a70d80ff090e4664df064fe695f82f5497
https://github.com/markguinn/silverstripe-ajax/blob/4fcfa4a70d80ff090e4664df064fe695f82f5497/code/AjaxHttpResponse.php#L69-L76
230,232
addiks/phpsql
src/Addiks/PHPSQL/Column/ColumnDataFactory.php
ColumnDataFactory.createColumnData
public function createColumnData( $schemaId, $tableId, $columnId, ColumnSchema $columnSchema ) { assert(is_numeric($tableId)); $columnDataFilePath = sprintf( FilePathes::FILEPATH_COLUMN_DATA_FILE, $schemaId, $tableId, $columnId, 0 ); /* @var $columnDataFile FileInterface */ $columnDataFile = $this->filesystem->getFile($columnDataFilePath); /* @var $columnData ColumnData */ $columnData = new ColumnData($columnDataFile, $columnSchema); return $columnData; }
php
public function createColumnData( $schemaId, $tableId, $columnId, ColumnSchema $columnSchema ) { assert(is_numeric($tableId)); $columnDataFilePath = sprintf( FilePathes::FILEPATH_COLUMN_DATA_FILE, $schemaId, $tableId, $columnId, 0 ); /* @var $columnDataFile FileInterface */ $columnDataFile = $this->filesystem->getFile($columnDataFilePath); /* @var $columnData ColumnData */ $columnData = new ColumnData($columnDataFile, $columnSchema); return $columnData; }
[ "public", "function", "createColumnData", "(", "$", "schemaId", ",", "$", "tableId", ",", "$", "columnId", ",", "ColumnSchema", "$", "columnSchema", ")", "{", "assert", "(", "is_numeric", "(", "$", "tableId", ")", ")", ";", "$", "columnDataFilePath", "=", "sprintf", "(", "FilePathes", "::", "FILEPATH_COLUMN_DATA_FILE", ",", "$", "schemaId", ",", "$", "tableId", ",", "$", "columnId", ",", "0", ")", ";", "/* @var $columnDataFile FileInterface */", "$", "columnDataFile", "=", "$", "this", "->", "filesystem", "->", "getFile", "(", "$", "columnDataFilePath", ")", ";", "/* @var $columnData ColumnData */", "$", "columnData", "=", "new", "ColumnData", "(", "$", "columnDataFile", ",", "$", "columnSchema", ")", ";", "return", "$", "columnData", ";", "}" ]
Creates a new column-data-object. @param string $columnId @return ColumnData
[ "Creates", "a", "new", "column", "-", "data", "-", "object", "." ]
28dae64ffc2123f39f801a50ab53bfe29890cbd9
https://github.com/addiks/phpsql/blob/28dae64ffc2123f39f801a50ab53bfe29890cbd9/src/Addiks/PHPSQL/Column/ColumnDataFactory.php#L37-L60
230,233
addiks/phpsql
src/Addiks/PHPSQL/Iterators/CustomIterator.php
CustomIterator.current
public function current() { if (is_callable($this->currentCallback)) { $return = call_user_func($this->currentCallback, parent::current()); return $return; } else { return parent::current(); } }
php
public function current() { if (is_callable($this->currentCallback)) { $return = call_user_func($this->currentCallback, parent::current()); return $return; } else { return parent::current(); } }
[ "public", "function", "current", "(", ")", "{", "if", "(", "is_callable", "(", "$", "this", "->", "currentCallback", ")", ")", "{", "$", "return", "=", "call_user_func", "(", "$", "this", "->", "currentCallback", ",", "parent", "::", "current", "(", ")", ")", ";", "return", "$", "return", ";", "}", "else", "{", "return", "parent", "::", "current", "(", ")", ";", "}", "}" ]
gets current value @return mixed @see ArrayIterator::current()
[ "gets", "current", "value" ]
28dae64ffc2123f39f801a50ab53bfe29890cbd9
https://github.com/addiks/phpsql/blob/28dae64ffc2123f39f801a50ab53bfe29890cbd9/src/Addiks/PHPSQL/Iterators/CustomIterator.php#L154-L162
230,234
Webiny/Framework
src/Webiny/Component/Security/Authentication/Providers/OAuth2/OAuth2.php
OAuth2.triggerExit
private function triggerExit($msg) { switch ($this->exitTrigger) { case 'die': die($msg); break; case 'exception': throw new OAuth2Exception($msg); break; default: die($msg); break; } }
php
private function triggerExit($msg) { switch ($this->exitTrigger) { case 'die': die($msg); break; case 'exception': throw new OAuth2Exception($msg); break; default: die($msg); break; } }
[ "private", "function", "triggerExit", "(", "$", "msg", ")", "{", "switch", "(", "$", "this", "->", "exitTrigger", ")", "{", "case", "'die'", ":", "die", "(", "$", "msg", ")", ";", "break", ";", "case", "'exception'", ":", "throw", "new", "OAuth2Exception", "(", "$", "msg", ")", ";", "break", ";", "default", ":", "die", "(", "$", "msg", ")", ";", "break", ";", "}", "}" ]
Triggers the exit process from OAuth2 authentication process. @throws OAuth2Exception
[ "Triggers", "the", "exit", "process", "from", "OAuth2", "authentication", "process", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Security/Authentication/Providers/OAuth2/OAuth2.php#L211-L224
230,235
Webiny/Framework
src/Webiny/Component/Rest/RestTrait.php
RestTrait.restGetPage
protected static function restGetPage($default = 1) { $page = Request::getInstance()->query('_page', $default); if (!is_numeric($page) || $page < 1) { return $default; } return (int)$page; }
php
protected static function restGetPage($default = 1) { $page = Request::getInstance()->query('_page', $default); if (!is_numeric($page) || $page < 1) { return $default; } return (int)$page; }
[ "protected", "static", "function", "restGetPage", "(", "$", "default", "=", "1", ")", "{", "$", "page", "=", "Request", "::", "getInstance", "(", ")", "->", "query", "(", "'_page'", ",", "$", "default", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "page", ")", "||", "$", "page", "<", "1", ")", "{", "return", "$", "default", ";", "}", "return", "(", "int", ")", "$", "page", ";", "}" ]
Get the page number. @param int $default Default value to return if page parameter is not found or if it's not valid. @return int
[ "Get", "the", "page", "number", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/RestTrait.php#L27-L35
230,236
Webiny/Framework
src/Webiny/Component/Rest/RestTrait.php
RestTrait.restGetPerPage
protected static function restGetPerPage($default = 10) { $perPage = Request::getInstance()->query('_perPage', $default); if (!is_numeric($perPage) || $perPage < 1 || $perPage > 1000) { return $default; } return (int)$perPage; }
php
protected static function restGetPerPage($default = 10) { $perPage = Request::getInstance()->query('_perPage', $default); if (!is_numeric($perPage) || $perPage < 1 || $perPage > 1000) { return $default; } return (int)$perPage; }
[ "protected", "static", "function", "restGetPerPage", "(", "$", "default", "=", "10", ")", "{", "$", "perPage", "=", "Request", "::", "getInstance", "(", ")", "->", "query", "(", "'_perPage'", ",", "$", "default", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "perPage", ")", "||", "$", "perPage", "<", "1", "||", "$", "perPage", ">", "1000", ")", "{", "return", "$", "default", ";", "}", "return", "(", "int", ")", "$", "perPage", ";", "}" ]
Get the perPage value. @param int $default Default value to return if perPage parameter is not found or if it's not valid. @return int
[ "Get", "the", "perPage", "value", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/RestTrait.php#L44-L52
230,237
Webiny/Framework
src/Webiny/Component/Rest/RestTrait.php
RestTrait.restGetSortField
protected static function restGetSortField($default = false) { $sort = Request::getInstance()->query('_sort', false); if (!$sort) { return $default; } $sortDirection = substr($sort, 0, 1); if ($sortDirection == '+' || $sortDirection == '-') { return substr($sort, 1); } return $sort; }
php
protected static function restGetSortField($default = false) { $sort = Request::getInstance()->query('_sort', false); if (!$sort) { return $default; } $sortDirection = substr($sort, 0, 1); if ($sortDirection == '+' || $sortDirection == '-') { return substr($sort, 1); } return $sort; }
[ "protected", "static", "function", "restGetSortField", "(", "$", "default", "=", "false", ")", "{", "$", "sort", "=", "Request", "::", "getInstance", "(", ")", "->", "query", "(", "'_sort'", ",", "false", ")", ";", "if", "(", "!", "$", "sort", ")", "{", "return", "$", "default", ";", "}", "$", "sortDirection", "=", "substr", "(", "$", "sort", ",", "0", ",", "1", ")", ";", "if", "(", "$", "sortDirection", "==", "'+'", "||", "$", "sortDirection", "==", "'-'", ")", "{", "return", "substr", "(", "$", "sort", ",", "1", ")", ";", "}", "return", "$", "sort", ";", "}" ]
Get the sort value. @param string|bool $default Default value to return if sort parameter is not found. @return mixed|string
[ "Get", "the", "sort", "value", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/RestTrait.php#L61-L74
230,238
Webiny/Framework
src/Webiny/Component/Rest/RestTrait.php
RestTrait.restGetSortFields
protected static function restGetSortFields($default = []) { $sort = Request::getInstance()->query('_sort', false); if (!$sort) { return $default; } $sorters = []; $fields = explode(',', $sort); foreach ($fields as $sort) { $sortField = $sort; $sortDirection = 1; $sortDirectionSign = substr($sort, 0, 1); if ($sortDirectionSign == '+' || $sortDirectionSign == '-') { $sortField = substr($sort, 1); $sortDirection = $sortDirectionSign == '+' ? 1 : -1; } $sorters[$sortField] = $sortDirection; } return $sorters; }
php
protected static function restGetSortFields($default = []) { $sort = Request::getInstance()->query('_sort', false); if (!$sort) { return $default; } $sorters = []; $fields = explode(',', $sort); foreach ($fields as $sort) { $sortField = $sort; $sortDirection = 1; $sortDirectionSign = substr($sort, 0, 1); if ($sortDirectionSign == '+' || $sortDirectionSign == '-') { $sortField = substr($sort, 1); $sortDirection = $sortDirectionSign == '+' ? 1 : -1; } $sorters[$sortField] = $sortDirection; } return $sorters; }
[ "protected", "static", "function", "restGetSortFields", "(", "$", "default", "=", "[", "]", ")", "{", "$", "sort", "=", "Request", "::", "getInstance", "(", ")", "->", "query", "(", "'_sort'", ",", "false", ")", ";", "if", "(", "!", "$", "sort", ")", "{", "return", "$", "default", ";", "}", "$", "sorters", "=", "[", "]", ";", "$", "fields", "=", "explode", "(", "','", ",", "$", "sort", ")", ";", "foreach", "(", "$", "fields", "as", "$", "sort", ")", "{", "$", "sortField", "=", "$", "sort", ";", "$", "sortDirection", "=", "1", ";", "$", "sortDirectionSign", "=", "substr", "(", "$", "sort", ",", "0", ",", "1", ")", ";", "if", "(", "$", "sortDirectionSign", "==", "'+'", "||", "$", "sortDirectionSign", "==", "'-'", ")", "{", "$", "sortField", "=", "substr", "(", "$", "sort", ",", "1", ")", ";", "$", "sortDirection", "=", "$", "sortDirectionSign", "==", "'+'", "?", "1", ":", "-", "1", ";", "}", "$", "sorters", "[", "$", "sortField", "]", "=", "$", "sortDirection", ";", "}", "return", "$", "sorters", ";", "}" ]
Get the sort fields values @param string|bool $default Default value to return if sort parameter is not found. @return mixed|string
[ "Get", "the", "sort", "fields", "values" ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/RestTrait.php#L83-L106
230,239
Webiny/Framework
src/Webiny/Component/Rest/RestTrait.php
RestTrait.restGetSortDirection
protected static function restGetSortDirection($default = 1) { $sort = Request::getInstance()->query('_sort', false); if (!$sort) { return $default; } $sortDirection = substr($sort, 0, 1); if ($sortDirection == '+') { return 1; } if ($sortDirection == '-') { return -1; } return $default; }
php
protected static function restGetSortDirection($default = 1) { $sort = Request::getInstance()->query('_sort', false); if (!$sort) { return $default; } $sortDirection = substr($sort, 0, 1); if ($sortDirection == '+') { return 1; } if ($sortDirection == '-') { return -1; } return $default; }
[ "protected", "static", "function", "restGetSortDirection", "(", "$", "default", "=", "1", ")", "{", "$", "sort", "=", "Request", "::", "getInstance", "(", ")", "->", "query", "(", "'_sort'", ",", "false", ")", ";", "if", "(", "!", "$", "sort", ")", "{", "return", "$", "default", ";", "}", "$", "sortDirection", "=", "substr", "(", "$", "sort", ",", "0", ",", "1", ")", ";", "if", "(", "$", "sortDirection", "==", "'+'", ")", "{", "return", "1", ";", "}", "if", "(", "$", "sortDirection", "==", "'-'", ")", "{", "return", "-", "1", ";", "}", "return", "$", "default", ";", "}" ]
Get the sort direction. The result output is optimized for mongodb, meaning we return '1' for ascending and '-1' for descending. @param int $default Default value to return if sort parameter is not found or if it's not valid. @return int
[ "Get", "the", "sort", "direction", ".", "The", "result", "output", "is", "optimized", "for", "mongodb", "meaning", "we", "return", "1", "for", "ascending", "and", "-", "1", "for", "descending", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/RestTrait.php#L116-L133
230,240
Webiny/Framework
src/Webiny/Component/Rest/RestTrait.php
RestTrait.restGetFieldsDepth
protected static function restGetFieldsDepth($default = 1) { $depth = Request::getInstance()->query('_fieldsDepth', false); if (!$depth) { $fields = static::restGetFields(false); if (!$fields) { return $default; } // Determine the deepest key $depth = 1; foreach (explode(',', $fields) as $key) { $keyDepth = substr_count($key, '.'); if ($depth < $keyDepth) { $depth = $keyDepth; } } return $depth; } return $depth; }
php
protected static function restGetFieldsDepth($default = 1) { $depth = Request::getInstance()->query('_fieldsDepth', false); if (!$depth) { $fields = static::restGetFields(false); if (!$fields) { return $default; } // Determine the deepest key $depth = 1; foreach (explode(',', $fields) as $key) { $keyDepth = substr_count($key, '.'); if ($depth < $keyDepth) { $depth = $keyDepth; } } return $depth; } return $depth; }
[ "protected", "static", "function", "restGetFieldsDepth", "(", "$", "default", "=", "1", ")", "{", "$", "depth", "=", "Request", "::", "getInstance", "(", ")", "->", "query", "(", "'_fieldsDepth'", ",", "false", ")", ";", "if", "(", "!", "$", "depth", ")", "{", "$", "fields", "=", "static", "::", "restGetFields", "(", "false", ")", ";", "if", "(", "!", "$", "fields", ")", "{", "return", "$", "default", ";", "}", "// Determine the deepest key", "$", "depth", "=", "1", ";", "foreach", "(", "explode", "(", "','", ",", "$", "fields", ")", "as", "$", "key", ")", "{", "$", "keyDepth", "=", "substr_count", "(", "$", "key", ",", "'.'", ")", ";", "if", "(", "$", "depth", "<", "$", "keyDepth", ")", "{", "$", "depth", "=", "$", "keyDepth", ";", "}", "}", "return", "$", "depth", ";", "}", "return", "$", "depth", ";", "}" ]
Get the fields depth @param int Default value to return if fieldsDepth parameter is not found. @return int
[ "Get", "the", "fields", "depth" ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Rest/RestTrait.php#L154-L176
230,241
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/DateTimeObject/ManipulatorTrait.php
ManipulatorTrait.add
public function add($amount) { try { $interval = $this->parseDateInterval($amount); $this->getDateObject()->add($interval); } catch (\Exception $e) { throw new DateTimeObjectException($e->getMessage()); } return $this; }
php
public function add($amount) { try { $interval = $this->parseDateInterval($amount); $this->getDateObject()->add($interval); } catch (\Exception $e) { throw new DateTimeObjectException($e->getMessage()); } return $this; }
[ "public", "function", "add", "(", "$", "amount", ")", "{", "try", "{", "$", "interval", "=", "$", "this", "->", "parseDateInterval", "(", "$", "amount", ")", ";", "$", "this", "->", "getDateObject", "(", ")", "->", "add", "(", "$", "interval", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "DateTimeObjectException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds an amount of days, months, years, hours, minutes and seconds to a DateTimeObject. @param string $amount You can specify the amount in ISO8601 format (example: 'P14D' = 14 days; 'P1DT12H' = 1 day 12 hours), or as a date string (example: '1 day', '2 months', '3 year', '2 days + 10 minutes'). @return $this @throws DateTimeObjectException
[ "Adds", "an", "amount", "of", "days", "months", "years", "hours", "minutes", "and", "seconds", "to", "a", "DateTimeObject", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/DateTimeObject/ManipulatorTrait.php#L31-L42
230,242
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/DateTimeObject/ManipulatorTrait.php
ManipulatorTrait.setDate
public function setDate($year, $month, $day) { try { $this->getDateObject()->setDate($year, $month, $day); } catch (\Exception $e) { throw new DateTimeObjectException($e->getMessage()); } return $this; }
php
public function setDate($year, $month, $day) { try { $this->getDateObject()->setDate($year, $month, $day); } catch (\Exception $e) { throw new DateTimeObjectException($e->getMessage()); } return $this; }
[ "public", "function", "setDate", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", "{", "try", "{", "$", "this", "->", "getDateObject", "(", ")", "->", "setDate", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "DateTimeObjectException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the date on current object. @param int $year @param int $month @param int $day @throws DateTimeObjectException @return $this
[ "Set", "the", "date", "on", "current", "object", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/DateTimeObject/ManipulatorTrait.php#L54-L63
230,243
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/DateTimeObject/ManipulatorTrait.php
ManipulatorTrait.setTime
public function setTime($hour, $minute, $second = 0) { try { $this->getDateObject()->setTime($hour, $minute, $second); } catch (\Exception $e) { throw new DateTimeObjectException($e->getMessage()); } return $this; }
php
public function setTime($hour, $minute, $second = 0) { try { $this->getDateObject()->setTime($hour, $minute, $second); } catch (\Exception $e) { throw new DateTimeObjectException($e->getMessage()); } return $this; }
[ "public", "function", "setTime", "(", "$", "hour", ",", "$", "minute", ",", "$", "second", "=", "0", ")", "{", "try", "{", "$", "this", "->", "getDateObject", "(", ")", "->", "setTime", "(", "$", "hour", ",", "$", "minute", ",", "$", "second", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "DateTimeObjectException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the time on current object. @param int $hour @param int $minute @param int $second @throws DateTimeObjectException @return $this
[ "Set", "the", "time", "on", "current", "object", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/DateTimeObject/ManipulatorTrait.php#L75-L84
230,244
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/DateTimeObject/ManipulatorTrait.php
ManipulatorTrait.setTimestamp
public function setTimestamp($timestamp) { try { $this->getDateObject()->setTimestamp($timestamp); } catch (\Exception $e) { throw new DateTimeObjectException($e->getMessage()); } return $this; }
php
public function setTimestamp($timestamp) { try { $this->getDateObject()->setTimestamp($timestamp); } catch (\Exception $e) { throw new DateTimeObjectException($e->getMessage()); } return $this; }
[ "public", "function", "setTimestamp", "(", "$", "timestamp", ")", "{", "try", "{", "$", "this", "->", "getDateObject", "(", ")", "->", "setTimestamp", "(", "$", "timestamp", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "DateTimeObjectException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the timestamp on current object. @param int $timestamp UNIX timestamp. @throws DateTimeObjectException @return $this
[ "Set", "the", "timestamp", "on", "current", "object", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/DateTimeObject/ManipulatorTrait.php#L94-L103
230,245
naneau/semver
src/Naneau/SemVer/Parser/PreRelease.php
PreRelease.parse
public static function parse($string) { // Type X.Y.Z, can be parsed as Versionable if (substr_count($string, '.') === 2) { return VersionableParser::parse($string, 'Naneau\SemVer\Version\PreRelease'); } $preRelease = new PreReleaseVersion; $parts = explode('.', $string); // Sanity check if (count($parts) === 0) { return $preRelease; } // Set the greek name $preRelease->setGreek( $parts[0] ); // If there's another part it's a release number if (isset($parts[1])) { $preRelease->setReleaseNumber( (int) $parts[1] ); } return $preRelease; }
php
public static function parse($string) { // Type X.Y.Z, can be parsed as Versionable if (substr_count($string, '.') === 2) { return VersionableParser::parse($string, 'Naneau\SemVer\Version\PreRelease'); } $preRelease = new PreReleaseVersion; $parts = explode('.', $string); // Sanity check if (count($parts) === 0) { return $preRelease; } // Set the greek name $preRelease->setGreek( $parts[0] ); // If there's another part it's a release number if (isset($parts[1])) { $preRelease->setReleaseNumber( (int) $parts[1] ); } return $preRelease; }
[ "public", "static", "function", "parse", "(", "$", "string", ")", "{", "// Type X.Y.Z, can be parsed as Versionable", "if", "(", "substr_count", "(", "$", "string", ",", "'.'", ")", "===", "2", ")", "{", "return", "VersionableParser", "::", "parse", "(", "$", "string", ",", "'Naneau\\SemVer\\Version\\PreRelease'", ")", ";", "}", "$", "preRelease", "=", "new", "PreReleaseVersion", ";", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "string", ")", ";", "// Sanity check", "if", "(", "count", "(", "$", "parts", ")", "===", "0", ")", "{", "return", "$", "preRelease", ";", "}", "// Set the greek name", "$", "preRelease", "->", "setGreek", "(", "$", "parts", "[", "0", "]", ")", ";", "// If there's another part it's a release number", "if", "(", "isset", "(", "$", "parts", "[", "1", "]", ")", ")", "{", "$", "preRelease", "->", "setReleaseNumber", "(", "(", "int", ")", "$", "parts", "[", "1", "]", ")", ";", "}", "return", "$", "preRelease", ";", "}" ]
Parse pre release version string @param string @return PreReleaseVersion
[ "Parse", "pre", "release", "version", "string" ]
c771ad1e6c89064c0a4fa714979639dc3649d6c8
https://github.com/naneau/semver/blob/c771ad1e6c89064c0a4fa714979639dc3649d6c8/src/Naneau/SemVer/Parser/PreRelease.php#L34-L63
230,246
ZenMagick/ZenCart
includes/modules/payment/authorizenet_echeck.php
authorizenet_echeck.confirmation
function confirmation() { global $order; $confirmation = array('fields' => array(array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_NAME, 'field' => $_POST['authorizenet_echeck_bank_name']), array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_ROUTING_CODE, 'field' => $_POST['authorizenet_echeck_bank_aba_code']), array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_ACCOUNT_TYPE, 'field' => $_POST['authorizenet_echeck_bank_acct_type']), array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_ACCOUNT_NUM, 'field' => $_POST['authorizenet_echeck_bank_acct_num']), array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_AUTHORIZATION_TITLE, 'field' => sprintf(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_AUTHORIZATION_NOTICE, strtolower(zen_db_prepare_input($_POST['authorizenet_echeck_bank_acct_type'])), zen_date_short(date("Y-m-d")), $order->info['total'])) )); return $confirmation; }
php
function confirmation() { global $order; $confirmation = array('fields' => array(array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_NAME, 'field' => $_POST['authorizenet_echeck_bank_name']), array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_ROUTING_CODE, 'field' => $_POST['authorizenet_echeck_bank_aba_code']), array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_ACCOUNT_TYPE, 'field' => $_POST['authorizenet_echeck_bank_acct_type']), array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_ACCOUNT_NUM, 'field' => $_POST['authorizenet_echeck_bank_acct_num']), array('title' => MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_AUTHORIZATION_TITLE, 'field' => sprintf(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_AUTHORIZATION_NOTICE, strtolower(zen_db_prepare_input($_POST['authorizenet_echeck_bank_acct_type'])), zen_date_short(date("Y-m-d")), $order->info['total'])) )); return $confirmation; }
[ "function", "confirmation", "(", ")", "{", "global", "$", "order", ";", "$", "confirmation", "=", "array", "(", "'fields'", "=>", "array", "(", "array", "(", "'title'", "=>", "MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_NAME", ",", "'field'", "=>", "$", "_POST", "[", "'authorizenet_echeck_bank_name'", "]", ")", ",", "array", "(", "'title'", "=>", "MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_ROUTING_CODE", ",", "'field'", "=>", "$", "_POST", "[", "'authorizenet_echeck_bank_aba_code'", "]", ")", ",", "array", "(", "'title'", "=>", "MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_ACCOUNT_TYPE", ",", "'field'", "=>", "$", "_POST", "[", "'authorizenet_echeck_bank_acct_type'", "]", ")", ",", "array", "(", "'title'", "=>", "MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_BANK_ACCOUNT_NUM", ",", "'field'", "=>", "$", "_POST", "[", "'authorizenet_echeck_bank_acct_num'", "]", ")", ",", "array", "(", "'title'", "=>", "MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_AUTHORIZATION_TITLE", ",", "'field'", "=>", "sprintf", "(", "MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_AUTHORIZATION_NOTICE", ",", "strtolower", "(", "zen_db_prepare_input", "(", "$", "_POST", "[", "'authorizenet_echeck_bank_acct_type'", "]", ")", ")", ",", "zen_date_short", "(", "date", "(", "\"Y-m-d\"", ")", ")", ",", "$", "order", "->", "info", "[", "'total'", "]", ")", ")", ")", ")", ";", "return", "$", "confirmation", ";", "}" ]
Display Account Information on the Checkout Confirmation Page @return array
[ "Display", "Account", "Information", "on", "the", "Checkout", "Confirmation", "Page" ]
00438ebc0faee786489aab4a6d70fc0d0c1461c7
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/authorizenet_echeck.php#L255-L269
230,247
ZenMagick/ZenCart
includes/modules/payment/authorizenet_echeck.php
authorizenet_echeck.after_process
function after_process() { global $insert_id, $db; $sql = "insert into " . TABLE_ORDERS_STATUS_HISTORY . " (comments, orders_id, orders_status_id, date_added) values (:orderComments, :orderID, :orderStatus, now() )"; $sql = $db->bindVars($sql, ':orderComments', 'eCheck payment. AUTH: ' . $this->auth_code . '. TransID: ' . $this->transaction_id . '.', 'string'); $sql = $db->bindVars($sql, ':orderID', $insert_id, 'integer'); $sql = $db->bindVars($sql, ':orderStatus', $this->order_status, 'integer'); $db->Execute($sql); return false; }
php
function after_process() { global $insert_id, $db; $sql = "insert into " . TABLE_ORDERS_STATUS_HISTORY . " (comments, orders_id, orders_status_id, date_added) values (:orderComments, :orderID, :orderStatus, now() )"; $sql = $db->bindVars($sql, ':orderComments', 'eCheck payment. AUTH: ' . $this->auth_code . '. TransID: ' . $this->transaction_id . '.', 'string'); $sql = $db->bindVars($sql, ':orderID', $insert_id, 'integer'); $sql = $db->bindVars($sql, ':orderStatus', $this->order_status, 'integer'); $db->Execute($sql); return false; }
[ "function", "after_process", "(", ")", "{", "global", "$", "insert_id", ",", "$", "db", ";", "$", "sql", "=", "\"insert into \"", ".", "TABLE_ORDERS_STATUS_HISTORY", ".", "\" (comments, orders_id, orders_status_id, date_added) values (:orderComments, :orderID, :orderStatus, now() )\"", ";", "$", "sql", "=", "$", "db", "->", "bindVars", "(", "$", "sql", ",", "':orderComments'", ",", "'eCheck payment. AUTH: '", ".", "$", "this", "->", "auth_code", ".", "'. TransID: '", ".", "$", "this", "->", "transaction_id", ".", "'.'", ",", "'string'", ")", ";", "$", "sql", "=", "$", "db", "->", "bindVars", "(", "$", "sql", ",", "':orderID'", ",", "$", "insert_id", ",", "'integer'", ")", ";", "$", "sql", "=", "$", "db", "->", "bindVars", "(", "$", "sql", ",", "':orderStatus'", ",", "$", "this", "->", "order_status", ",", "'integer'", ")", ";", "$", "db", "->", "Execute", "(", "$", "sql", ")", ";", "return", "false", ";", "}" ]
Post-process activities. Updates the order-status history data with the auth code from the transaction. @return boolean
[ "Post", "-", "process", "activities", ".", "Updates", "the", "order", "-", "status", "history", "data", "with", "the", "auth", "code", "from", "the", "transaction", "." ]
00438ebc0faee786489aab4a6d70fc0d0c1461c7
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/authorizenet_echeck.php#L433-L441
230,248
Webiny/Framework
src/Webiny/Component/Security/Authentication/Providers/Http/Http.php
Http.getLoginObject
public function getLoginObject(ConfigObject $config) { if (!$this->httpSession()->get('username', false)) { $this->triggerLogin($config); } $username = $this->httpSession()->get('username', ''); $password = $this->httpSession()->get('password', ''); return new Login($username, $password, false); }
php
public function getLoginObject(ConfigObject $config) { if (!$this->httpSession()->get('username', false)) { $this->triggerLogin($config); } $username = $this->httpSession()->get('username', ''); $password = $this->httpSession()->get('password', ''); return new Login($username, $password, false); }
[ "public", "function", "getLoginObject", "(", "ConfigObject", "$", "config", ")", "{", "if", "(", "!", "$", "this", "->", "httpSession", "(", ")", "->", "get", "(", "'username'", ",", "false", ")", ")", "{", "$", "this", "->", "triggerLogin", "(", "$", "config", ")", ";", "}", "$", "username", "=", "$", "this", "->", "httpSession", "(", ")", "->", "get", "(", "'username'", ",", "''", ")", ";", "$", "password", "=", "$", "this", "->", "httpSession", "(", ")", "->", "get", "(", "'password'", ",", "''", ")", ";", "return", "new", "Login", "(", "$", "username", ",", "$", "password", ",", "false", ")", ";", "}" ]
This method is triggered on the login submit page where user credentials are submitted. On this page the provider should create a new Login object from those credentials, and return the object. This object will be then validated my user providers. @param ConfigObject $config Firewall config @return Login
[ "This", "method", "is", "triggered", "on", "the", "login", "submit", "page", "where", "user", "credentials", "are", "submitted", ".", "On", "this", "page", "the", "provider", "should", "create", "a", "new", "Login", "object", "from", "those", "credentials", "and", "return", "the", "object", ".", "This", "object", "will", "be", "then", "validated", "my", "user", "providers", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Security/Authentication/Providers/Http/Http.php#L55-L65
230,249
Webiny/Framework
src/Webiny/Component/Security/Authentication/Providers/Http/Http.php
Http.triggerLogin
public function triggerLogin($config) { $headers = [ 'WWW-Authenticate: Basic realm="' . $config->RealmName . '"', 'HTTP/1.0 401 Unauthorized' ]; foreach ($headers as $h) { header($h); } if ($this->httpSession()->get('login_retry') == 'true') { $this->httpSession()->delete('login_retry'); $this->triggerExit(); } // once we get the username and password, we store them into the session and redirect to login submit path if ($this->httpRequest()->server()->get(self::USERNAME, '') != '' && $this->httpSession()->get('logout', 'false' ) != 'true' ) { // php Basic HTTP auth $username = $this->httpRequest()->server()->get(self::USERNAME); $password = $this->httpRequest()->server()->get(self::PASSWORD); } else { $this->httpSession()->delete('logout'); $this->triggerExit(); } $this->httpSession()->save('username', $username); $this->httpSession()->save('password', $password); $this->httpRedirect($this->httpRequest()->getCurrentUrl()); }
php
public function triggerLogin($config) { $headers = [ 'WWW-Authenticate: Basic realm="' . $config->RealmName . '"', 'HTTP/1.0 401 Unauthorized' ]; foreach ($headers as $h) { header($h); } if ($this->httpSession()->get('login_retry') == 'true') { $this->httpSession()->delete('login_retry'); $this->triggerExit(); } // once we get the username and password, we store them into the session and redirect to login submit path if ($this->httpRequest()->server()->get(self::USERNAME, '') != '' && $this->httpSession()->get('logout', 'false' ) != 'true' ) { // php Basic HTTP auth $username = $this->httpRequest()->server()->get(self::USERNAME); $password = $this->httpRequest()->server()->get(self::PASSWORD); } else { $this->httpSession()->delete('logout'); $this->triggerExit(); } $this->httpSession()->save('username', $username); $this->httpSession()->save('password', $password); $this->httpRedirect($this->httpRequest()->getCurrentUrl()); }
[ "public", "function", "triggerLogin", "(", "$", "config", ")", "{", "$", "headers", "=", "[", "'WWW-Authenticate: Basic realm=\"'", ".", "$", "config", "->", "RealmName", ".", "'\"'", ",", "'HTTP/1.0 401 Unauthorized'", "]", ";", "foreach", "(", "$", "headers", "as", "$", "h", ")", "{", "header", "(", "$", "h", ")", ";", "}", "if", "(", "$", "this", "->", "httpSession", "(", ")", "->", "get", "(", "'login_retry'", ")", "==", "'true'", ")", "{", "$", "this", "->", "httpSession", "(", ")", "->", "delete", "(", "'login_retry'", ")", ";", "$", "this", "->", "triggerExit", "(", ")", ";", "}", "// once we get the username and password, we store them into the session and redirect to login submit path", "if", "(", "$", "this", "->", "httpRequest", "(", ")", "->", "server", "(", ")", "->", "get", "(", "self", "::", "USERNAME", ",", "''", ")", "!=", "''", "&&", "$", "this", "->", "httpSession", "(", ")", "->", "get", "(", "'logout'", ",", "'false'", ")", "!=", "'true'", ")", "{", "// php Basic HTTP auth", "$", "username", "=", "$", "this", "->", "httpRequest", "(", ")", "->", "server", "(", ")", "->", "get", "(", "self", "::", "USERNAME", ")", ";", "$", "password", "=", "$", "this", "->", "httpRequest", "(", ")", "->", "server", "(", ")", "->", "get", "(", "self", "::", "PASSWORD", ")", ";", "}", "else", "{", "$", "this", "->", "httpSession", "(", ")", "->", "delete", "(", "'logout'", ")", ";", "$", "this", "->", "triggerExit", "(", ")", ";", "}", "$", "this", "->", "httpSession", "(", ")", "->", "save", "(", "'username'", ",", "$", "username", ")", ";", "$", "this", "->", "httpSession", "(", ")", "->", "save", "(", "'password'", ",", "$", "password", ")", ";", "$", "this", "->", "httpRedirect", "(", "$", "this", "->", "httpRequest", "(", ")", "->", "getCurrentUrl", "(", ")", ")", ";", "}" ]
This method is triggered when the user opens the login page. On this page you must ask the user to provide you his credentials which should then be passed to the login submit page. @param ConfigObject $config Firewall config @return mixed
[ "This", "method", "is", "triggered", "when", "the", "user", "opens", "the", "login", "page", ".", "On", "this", "page", "you", "must", "ask", "the", "user", "to", "provide", "you", "his", "credentials", "which", "should", "then", "be", "passed", "to", "the", "login", "submit", "page", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Security/Authentication/Providers/Http/Http.php#L95-L127
230,250
Webiny/Framework
src/Webiny/Component/Security/Authentication/Providers/Http/Http.php
Http.invalidLoginProvidedCallback
public function invalidLoginProvidedCallback() { $this->httpSession()->delete('username'); $this->httpSession()->delete('password'); $this->httpSession()->save('login_retry', 'true'); }
php
public function invalidLoginProvidedCallback() { $this->httpSession()->delete('username'); $this->httpSession()->delete('password'); $this->httpSession()->save('login_retry', 'true'); }
[ "public", "function", "invalidLoginProvidedCallback", "(", ")", "{", "$", "this", "->", "httpSession", "(", ")", "->", "delete", "(", "'username'", ")", ";", "$", "this", "->", "httpSession", "(", ")", "->", "delete", "(", "'password'", ")", ";", "$", "this", "->", "httpSession", "(", ")", "->", "save", "(", "'login_retry'", ",", "'true'", ")", ";", "}" ]
This callback is triggered after we validate the given login data, and the data is not valid. Use this callback to clear the submit data from the previous request so that you don't get stuck in an infinitive loop between login and login submit page.
[ "This", "callback", "is", "triggered", "after", "we", "validate", "the", "given", "login", "data", "and", "the", "data", "is", "not", "valid", ".", "Use", "this", "callback", "to", "clear", "the", "submit", "data", "from", "the", "previous", "request", "so", "that", "you", "don", "t", "get", "stuck", "in", "an", "infinitive", "loop", "between", "login", "and", "login", "submit", "page", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Security/Authentication/Providers/Http/Http.php#L134-L139
230,251
Webiny/Framework
src/Webiny/Component/Security/Authentication/Providers/Http/Http.php
Http.triggerExit
private function triggerExit() { $msg = 'You are not authenticated'; switch ($this->exitTrigger) { case 'die': die($msg); break; case 'exception': throw new HttpException($msg); break; default: die($msg); break; } }
php
private function triggerExit() { $msg = 'You are not authenticated'; switch ($this->exitTrigger) { case 'die': die($msg); break; case 'exception': throw new HttpException($msg); break; default: die($msg); break; } }
[ "private", "function", "triggerExit", "(", ")", "{", "$", "msg", "=", "'You are not authenticated'", ";", "switch", "(", "$", "this", "->", "exitTrigger", ")", "{", "case", "'die'", ":", "die", "(", "$", "msg", ")", ";", "break", ";", "case", "'exception'", ":", "throw", "new", "HttpException", "(", "$", "msg", ")", ";", "break", ";", "default", ":", "die", "(", "$", "msg", ")", ";", "break", ";", "}", "}" ]
Triggers the exit process from Http authentication process. This method is used so we can mock the behaviour of this provider, for unit tests. @throws HttpException
[ "Triggers", "the", "exit", "process", "from", "Http", "authentication", "process", ".", "This", "method", "is", "used", "so", "we", "can", "mock", "the", "behaviour", "of", "this", "provider", "for", "unit", "tests", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Security/Authentication/Providers/Http/Http.php#L181-L196
230,252
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.key
public function key($key, $value = null, $setOnlyIfDoesntExist = false) { $key = StdObjectWrapper::toString($key); $array = $this->val(); if ($setOnlyIfDoesntExist && !$this->keyExists($key)) { $array[$key] = $value; $this->val($array); return $value; } else { if (!$setOnlyIfDoesntExist && !$this->isNull($value)) { $array[$key] = $value; $this->val($array); return $this; } } if (!isset($array[$key])) { return $value; } return $array[$key]; }
php
public function key($key, $value = null, $setOnlyIfDoesntExist = false) { $key = StdObjectWrapper::toString($key); $array = $this->val(); if ($setOnlyIfDoesntExist && !$this->keyExists($key)) { $array[$key] = $value; $this->val($array); return $value; } else { if (!$setOnlyIfDoesntExist && !$this->isNull($value)) { $array[$key] = $value; $this->val($array); return $this; } } if (!isset($array[$key])) { return $value; } return $array[$key]; }
[ "public", "function", "key", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "setOnlyIfDoesntExist", "=", "false", ")", "{", "$", "key", "=", "StdObjectWrapper", "::", "toString", "(", "$", "key", ")", ";", "$", "array", "=", "$", "this", "->", "val", "(", ")", ";", "if", "(", "$", "setOnlyIfDoesntExist", "&&", "!", "$", "this", "->", "keyExists", "(", "$", "key", ")", ")", "{", "$", "array", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "val", "(", "$", "array", ")", ";", "return", "$", "value", ";", "}", "else", "{", "if", "(", "!", "$", "setOnlyIfDoesntExist", "&&", "!", "$", "this", "->", "isNull", "(", "$", "value", ")", ")", "{", "$", "array", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "val", "(", "$", "array", ")", ";", "return", "$", "this", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "array", "[", "$", "key", "]", ")", ")", "{", "return", "$", "value", ";", "}", "return", "$", "array", "[", "$", "key", "]", ";", "}" ]
Get or update the given key inside current array. @param string|int|StringObject $key Array key @param null|mixed $value If set, the value under current $key will be updated and not returned. @param bool $setOnlyIfDoesntExist Set the $value only in case if the $key doesn't exist. @return $this|mixed|StringObject The value of the given key.
[ "Get", "or", "update", "the", "given", "key", "inside", "current", "array", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L32-L56
230,253
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.append
public function append($k, $v = null) { $array = $this->val(); if (!$this->isNull($v)) { $array[$k] = $v; } else { $array[] = $k; } $this->val($array); return $this; }
php
public function append($k, $v = null) { $array = $this->val(); if (!$this->isNull($v)) { $array[$k] = $v; } else { $array[] = $k; } $this->val($array); return $this; }
[ "public", "function", "append", "(", "$", "k", ",", "$", "v", "=", "null", ")", "{", "$", "array", "=", "$", "this", "->", "val", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isNull", "(", "$", "v", ")", ")", "{", "$", "array", "[", "$", "k", "]", "=", "$", "v", ";", "}", "else", "{", "$", "array", "[", "]", "=", "$", "k", ";", "}", "$", "this", "->", "val", "(", "$", "array", ")", ";", "return", "$", "this", ";", "}" ]
Inserts an element to the end of the array. If you set both params, that first param is the key, and second is the value, else first param is the value, and the second is ignored. @param mixed $k @param mixed $v @return $this
[ "Inserts", "an", "element", "to", "the", "end", "of", "the", "array", ".", "If", "you", "set", "both", "params", "that", "first", "param", "is", "the", "key", "and", "second", "is", "the", "value", "else", "first", "param", "is", "the", "value", "and", "the", "second", "is", "ignored", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L114-L127
230,254
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.prepend
public function prepend($k, $v = null) { $array = $this->val(); if (!$this->isNull($v)) { $array = array_reverse($array, true); $array[$k] = $v; $array = array_reverse($array, true); } else { array_unshift($array, $k); } $this->val($array); return $this; }
php
public function prepend($k, $v = null) { $array = $this->val(); if (!$this->isNull($v)) { $array = array_reverse($array, true); $array[$k] = $v; $array = array_reverse($array, true); } else { array_unshift($array, $k); } $this->val($array); return $this; }
[ "public", "function", "prepend", "(", "$", "k", ",", "$", "v", "=", "null", ")", "{", "$", "array", "=", "$", "this", "->", "val", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isNull", "(", "$", "v", ")", ")", "{", "$", "array", "=", "array_reverse", "(", "$", "array", ",", "true", ")", ";", "$", "array", "[", "$", "k", "]", "=", "$", "v", ";", "$", "array", "=", "array_reverse", "(", "$", "array", ",", "true", ")", ";", "}", "else", "{", "array_unshift", "(", "$", "array", ",", "$", "k", ")", ";", "}", "$", "this", "->", "val", "(", "$", "array", ")", ";", "return", "$", "this", ";", "}" ]
Inserts an element at the beginning of the array. If you set both params, that first param is the key, and second is the value, else first param is the value, and the second is ignored. @param mixed $k @param mixed $v @return $this
[ "Inserts", "an", "element", "at", "the", "beginning", "of", "the", "array", ".", "If", "you", "set", "both", "params", "that", "first", "param", "is", "the", "key", "and", "second", "is", "the", "value", "else", "first", "param", "is", "the", "value", "and", "the", "second", "is", "ignored", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L139-L154
230,255
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.removeLast
public function removeLast(&$assign = null) { $array = $this->val(); if (count(func_get_args()) > 0) { $assign = $this->last()->val(); } array_pop($array); $this->val($array); return $this; }
php
public function removeLast(&$assign = null) { $array = $this->val(); if (count(func_get_args()) > 0) { $assign = $this->last()->val(); } array_pop($array); $this->val($array); return $this; }
[ "public", "function", "removeLast", "(", "&", "$", "assign", "=", "null", ")", "{", "$", "array", "=", "$", "this", "->", "val", "(", ")", ";", "if", "(", "count", "(", "func_get_args", "(", ")", ")", ">", "0", ")", "{", "$", "assign", "=", "$", "this", "->", "last", "(", ")", "->", "val", "(", ")", ";", "}", "array_pop", "(", "$", "array", ")", ";", "$", "this", "->", "val", "(", "$", "array", ")", ";", "return", "$", "this", ";", "}" ]
Removes the last element from the array. @param null $assign Assign removed value to given parameter @return $this
[ "Removes", "the", "last", "element", "from", "the", "array", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L185-L197
230,256
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.chunk
public function chunk($size, $preserve_keys = false) { try { $chunk = array_chunk($this->val(), $size, $preserve_keys); } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } return new ArrayObject($chunk); }
php
public function chunk($size, $preserve_keys = false) { try { $chunk = array_chunk($this->val(), $size, $preserve_keys); } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } return new ArrayObject($chunk); }
[ "public", "function", "chunk", "(", "$", "size", ",", "$", "preserve_keys", "=", "false", ")", "{", "try", "{", "$", "chunk", "=", "array_chunk", "(", "$", "this", "->", "val", "(", ")", ",", "$", "size", ",", "$", "preserve_keys", ")", ";", "}", "catch", "(", "\\", "ErrorException", "$", "e", ")", "{", "throw", "new", "ArrayObjectException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "new", "ArrayObject", "(", "$", "chunk", ")", ";", "}" ]
Split an array into chunks. @param int $size Chunk size. @param bool $preserve_keys Do you want ot preserve keys. @return ArrayObject A new instance of ArrayObject containing a multidimensional numerically indexed array, starting with zero, with each dimension containing size elements. @throws ArrayObjectException
[ "Split", "an", "array", "into", "chunks", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L263-L272
230,257
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.changeKeyCase
public function changeKeyCase($case) { // validate case $case = new StringObject($case); $case->caseLower(); $realCase = ''; if ($case->equals('lower')) { $realCase = CASE_LOWER; } else { if ($case->equals('upper')) { $realCase = CASE_UPPER; } else { throw new ArrayObjectException(ArrayObjectException::MSG_PARAM_VALUE_OUT_OF_SCOPE, [ '$case', '"lower" or "upper"' ]); } } $this->val(array_change_key_case($this->val(), $realCase)); return $this; }
php
public function changeKeyCase($case) { // validate case $case = new StringObject($case); $case->caseLower(); $realCase = ''; if ($case->equals('lower')) { $realCase = CASE_LOWER; } else { if ($case->equals('upper')) { $realCase = CASE_UPPER; } else { throw new ArrayObjectException(ArrayObjectException::MSG_PARAM_VALUE_OUT_OF_SCOPE, [ '$case', '"lower" or "upper"' ]); } } $this->val(array_change_key_case($this->val(), $realCase)); return $this; }
[ "public", "function", "changeKeyCase", "(", "$", "case", ")", "{", "// validate case", "$", "case", "=", "new", "StringObject", "(", "$", "case", ")", ";", "$", "case", "->", "caseLower", "(", ")", ";", "$", "realCase", "=", "''", ";", "if", "(", "$", "case", "->", "equals", "(", "'lower'", ")", ")", "{", "$", "realCase", "=", "CASE_LOWER", ";", "}", "else", "{", "if", "(", "$", "case", "->", "equals", "(", "'upper'", ")", ")", "{", "$", "realCase", "=", "CASE_UPPER", ";", "}", "else", "{", "throw", "new", "ArrayObjectException", "(", "ArrayObjectException", "::", "MSG_PARAM_VALUE_OUT_OF_SCOPE", ",", "[", "'$case'", ",", "'\"lower\" or \"upper\"'", "]", ")", ";", "}", "}", "$", "this", "->", "val", "(", "array_change_key_case", "(", "$", "this", "->", "val", "(", ")", ",", "$", "realCase", ")", ")", ";", "return", "$", "this", ";", "}" ]
Change the case of all keys in current ArrayObject. @param string $case Case to which you want to covert array keys. Can be 'lower' or 'upper'. @return $this @throws ArrayObjectException
[ "Change", "the", "case", "of", "all", "keys", "in", "current", "ArrayObject", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L282-L304
230,258
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.filter
public function filter($callable = '') { if ($callable != '' && !$this->isCallable($callable)) { throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [ '$callable', 'a callable function or method' ]); } if ($callable == '') { // Filter all values equal to FALSE $this->val(array_filter($this->val())); } else { // Filter values using a callback $this->val(array_filter($this->val(), $callable)); } return $this; }
php
public function filter($callable = '') { if ($callable != '' && !$this->isCallable($callable)) { throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [ '$callable', 'a callable function or method' ]); } if ($callable == '') { // Filter all values equal to FALSE $this->val(array_filter($this->val())); } else { // Filter values using a callback $this->val(array_filter($this->val(), $callable)); } return $this; }
[ "public", "function", "filter", "(", "$", "callable", "=", "''", ")", "{", "if", "(", "$", "callable", "!=", "''", "&&", "!", "$", "this", "->", "isCallable", "(", "$", "callable", ")", ")", "{", "throw", "new", "ArrayObjectException", "(", "ArrayObjectException", "::", "MSG_INVALID_PARAM", ",", "[", "'$callable'", ",", "'a callable function or method'", "]", ")", ";", "}", "if", "(", "$", "callable", "==", "''", ")", "{", "// Filter all values equal to FALSE", "$", "this", "->", "val", "(", "array_filter", "(", "$", "this", "->", "val", "(", ")", ")", ")", ";", "}", "else", "{", "// Filter values using a callback", "$", "this", "->", "val", "(", "array_filter", "(", "$", "this", "->", "val", "(", ")", ",", "$", "callable", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Filter array values by using a callback function. @param string $callable @return $this @throws ArrayObjectException
[ "Filter", "array", "values", "by", "using", "a", "callback", "function", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L377-L395
230,259
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.sortKey
public function sortKey($direction = SORT_ASC, $sortFlag = SORT_REGULAR) { try { $arr = $this->val(); if ($direction == SORT_DESC) { krsort($arr, $sortFlag); } else { ksort($arr, $sortFlag); } } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } $this->val($arr); return $this; }
php
public function sortKey($direction = SORT_ASC, $sortFlag = SORT_REGULAR) { try { $arr = $this->val(); if ($direction == SORT_DESC) { krsort($arr, $sortFlag); } else { ksort($arr, $sortFlag); } } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } $this->val($arr); return $this; }
[ "public", "function", "sortKey", "(", "$", "direction", "=", "SORT_ASC", ",", "$", "sortFlag", "=", "SORT_REGULAR", ")", "{", "try", "{", "$", "arr", "=", "$", "this", "->", "val", "(", ")", ";", "if", "(", "$", "direction", "==", "SORT_DESC", ")", "{", "krsort", "(", "$", "arr", ",", "$", "sortFlag", ")", ";", "}", "else", "{", "ksort", "(", "$", "arr", ",", "$", "sortFlag", ")", ";", "}", "}", "catch", "(", "\\", "ErrorException", "$", "e", ")", "{", "throw", "new", "ArrayObjectException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "val", "(", "$", "arr", ")", ";", "return", "$", "this", ";", "}" ]
Sort the array by its key. This sort function take two flags. One defines the sort algorithm, and the other one, the sort direction. Default behavior equals to the standard asort function. @param int $direction In which direction you want to sort. You can use SORT_ASC or SORT_DESC. @param int $sortFlag Which sort algorithm. SORT_REGULAR | SORT_NUMERIC | SORT_STRING | SORT_LOCALE_STRING | SORT_NATURAL @return $this @throws ArrayObjectException
[ "Sort", "the", "array", "by", "its", "key", ".", "This", "sort", "function", "take", "two", "flags", ".", "One", "defines", "the", "sort", "algorithm", "and", "the", "other", "one", "the", "sort", "direction", ".", "Default", "behavior", "equals", "to", "the", "standard", "asort", "function", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L691-L707
230,260
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.pad
public function pad($size, $value) { try { $arr = array_pad($this->val(), $size, $value); } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } $this->val($arr); return $this; }
php
public function pad($size, $value) { try { $arr = array_pad($this->val(), $size, $value); } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } $this->val($arr); return $this; }
[ "public", "function", "pad", "(", "$", "size", ",", "$", "value", ")", "{", "try", "{", "$", "arr", "=", "array_pad", "(", "$", "this", "->", "val", "(", ")", ",", "$", "size", ",", "$", "value", ")", ";", "}", "catch", "(", "\\", "ErrorException", "$", "e", ")", "{", "throw", "new", "ArrayObjectException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "val", "(", "$", "arr", ")", ";", "return", "$", "this", ";", "}" ]
Pad array to the specified length with a value. @param int $size New size of the array @param mixed $value Value to pad if array is smaller than pad_size. @return $this @throws ArrayObjectException
[ "Pad", "array", "to", "the", "specified", "length", "with", "a", "value", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L771-L782
230,261
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.rand
public function rand($num = 1) { try { $arr = array_rand($this->val(), $num); } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } if (!$this->isArray($arr)) { $arr = [$arr]; } return new ArrayObject($arr); }
php
public function rand($num = 1) { try { $arr = array_rand($this->val(), $num); } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } if (!$this->isArray($arr)) { $arr = [$arr]; } return new ArrayObject($arr); }
[ "public", "function", "rand", "(", "$", "num", "=", "1", ")", "{", "try", "{", "$", "arr", "=", "array_rand", "(", "$", "this", "->", "val", "(", ")", ",", "$", "num", ")", ";", "}", "catch", "(", "\\", "ErrorException", "$", "e", ")", "{", "throw", "new", "ArrayObjectException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isArray", "(", "$", "arr", ")", ")", "{", "$", "arr", "=", "[", "$", "arr", "]", ";", "}", "return", "new", "ArrayObject", "(", "$", "arr", ")", ";", "}" ]
Returns random elements from current array. @param int $num How many object you want to return. @return ArrayObject @throws ArrayObjectException
[ "Returns", "random", "elements", "from", "current", "array", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L792-L805
230,262
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.slice
public function slice($offset, $length = null, $preserveKeys = true) { if (!$this->isNumber($offset)) { throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [ '$offset', 'integer' ]); } try { $arr = array_slice($this->val(), $offset, $length, $preserveKeys); } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } $this->val($arr); return $this; }
php
public function slice($offset, $length = null, $preserveKeys = true) { if (!$this->isNumber($offset)) { throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [ '$offset', 'integer' ]); } try { $arr = array_slice($this->val(), $offset, $length, $preserveKeys); } catch (\ErrorException $e) { throw new ArrayObjectException($e->getMessage()); } $this->val($arr); return $this; }
[ "public", "function", "slice", "(", "$", "offset", ",", "$", "length", "=", "null", ",", "$", "preserveKeys", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "isNumber", "(", "$", "offset", ")", ")", "{", "throw", "new", "ArrayObjectException", "(", "ArrayObjectException", "::", "MSG_INVALID_PARAM", ",", "[", "'$offset'", ",", "'integer'", "]", ")", ";", "}", "try", "{", "$", "arr", "=", "array_slice", "(", "$", "this", "->", "val", "(", ")", ",", "$", "offset", ",", "$", "length", ",", "$", "preserveKeys", ")", ";", "}", "catch", "(", "\\", "ErrorException", "$", "e", ")", "{", "throw", "new", "ArrayObjectException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "val", "(", "$", "arr", ")", ";", "return", "$", "this", ";", "}" ]
Slice a portion of current array and discard the remains. @param int $offset From where to start slicing. @param null|int $length How many elements to take. @param bool $preserveKeys Do you want to preserve the keys from the current array. Default is true. @return $this @throws ArrayObjectException
[ "Slice", "a", "portion", "of", "current", "array", "and", "discard", "the", "remains", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L874-L892
230,263
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.unique
public function unique($sortFlag = SORT_REGULAR) { $this->val(array_unique($this->val(), $sortFlag)); return $this; }
php
public function unique($sortFlag = SORT_REGULAR) { $this->val(array_unique($this->val(), $sortFlag)); return $this; }
[ "public", "function", "unique", "(", "$", "sortFlag", "=", "SORT_REGULAR", ")", "{", "$", "this", "->", "val", "(", "array_unique", "(", "$", "this", "->", "val", "(", ")", ",", "$", "sortFlag", ")", ")", ";", "return", "$", "this", ";", "}" ]
Remove duplicates from the array. @param int $sortFlag The optional parameter that may be used to modify the sorting behavior. Possible values are: SORT_STRING, SORT_NUMERIC, SORT_REGULAR and SORT_LOCALE_STRING @return $this
[ "Remove", "duplicates", "from", "the", "array", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L940-L945
230,264
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.diff
public function diff($array, $compareKeys = false) { if ($this->isInstanceOf($array, $this)) { $array = $array->val(); } else { if (!$this->isArray($array)) { throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [ '$array', 'array, ArrayObject' ]); } } if ($compareKeys) { $this->val(array_diff_assoc($this->val(), $array)); return $this; } else { $this->val(array_diff($this->val(), $array)); return $this; } }
php
public function diff($array, $compareKeys = false) { if ($this->isInstanceOf($array, $this)) { $array = $array->val(); } else { if (!$this->isArray($array)) { throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [ '$array', 'array, ArrayObject' ]); } } if ($compareKeys) { $this->val(array_diff_assoc($this->val(), $array)); return $this; } else { $this->val(array_diff($this->val(), $array)); return $this; } }
[ "public", "function", "diff", "(", "$", "array", ",", "$", "compareKeys", "=", "false", ")", "{", "if", "(", "$", "this", "->", "isInstanceOf", "(", "$", "array", ",", "$", "this", ")", ")", "{", "$", "array", "=", "$", "array", "->", "val", "(", ")", ";", "}", "else", "{", "if", "(", "!", "$", "this", "->", "isArray", "(", "$", "array", ")", ")", "{", "throw", "new", "ArrayObjectException", "(", "ArrayObjectException", "::", "MSG_INVALID_PARAM", ",", "[", "'$array'", ",", "'array, ArrayObject'", "]", ")", ";", "}", "}", "if", "(", "$", "compareKeys", ")", "{", "$", "this", "->", "val", "(", "array_diff_assoc", "(", "$", "this", "->", "val", "(", ")", ",", "$", "array", ")", ")", ";", "return", "$", "this", ";", "}", "else", "{", "$", "this", "->", "val", "(", "array_diff", "(", "$", "this", "->", "val", "(", ")", ",", "$", "array", ")", ")", ";", "return", "$", "this", ";", "}", "}" ]
Compare two arrays or ArrayObjects and returns an ArrayObject containing all the values from current ArrayObject that are not present in any of the other array. @param $array Array to which to compare @param bool $compareKeys Do you want to compare array keys also. Default is false. @return ArrayObject @throws ArrayObjectException
[ "Compare", "two", "arrays", "or", "ArrayObjects", "and", "returns", "an", "ArrayObject", "containing", "all", "the", "values", "from", "current", "ArrayObject", "that", "are", "not", "present", "in", "any", "of", "the", "other", "array", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L1005-L1027
230,265
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php
ManipulatorTrait.diffKeys
public function diffKeys($array) { if ($this->isInstanceOf($array, $this)) { $array = $array->val(); } else { if (!$this->isArray($array)) { throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [ '$array', 'array, ArrayObject' ]); } } $this->val(array_diff_key($this->val(), $array)); return $this; }
php
public function diffKeys($array) { if ($this->isInstanceOf($array, $this)) { $array = $array->val(); } else { if (!$this->isArray($array)) { throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [ '$array', 'array, ArrayObject' ]); } } $this->val(array_diff_key($this->val(), $array)); return $this; }
[ "public", "function", "diffKeys", "(", "$", "array", ")", "{", "if", "(", "$", "this", "->", "isInstanceOf", "(", "$", "array", ",", "$", "this", ")", ")", "{", "$", "array", "=", "$", "array", "->", "val", "(", ")", ";", "}", "else", "{", "if", "(", "!", "$", "this", "->", "isArray", "(", "$", "array", ")", ")", "{", "throw", "new", "ArrayObjectException", "(", "ArrayObjectException", "::", "MSG_INVALID_PARAM", ",", "[", "'$array'", ",", "'array, ArrayObject'", "]", ")", ";", "}", "}", "$", "this", "->", "val", "(", "array_diff_key", "(", "$", "this", "->", "val", "(", ")", ",", "$", "array", ")", ")", ";", "return", "$", "this", ";", "}" ]
Compare the keys from two arrays or ArrayObjects and returns an ArrayObject containing all the values from current ArrayObject whose keys are not present in any of the other arrays. @param $array Array to which to compare @return ArrayObject @throws ArrayObjectException
[ "Compare", "the", "keys", "from", "two", "arrays", "or", "ArrayObjects", "and", "returns", "an", "ArrayObject", "containing", "all", "the", "values", "from", "current", "ArrayObject", "whose", "keys", "are", "not", "present", "in", "any", "of", "the", "other", "arrays", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/ArrayObject/ManipulatorTrait.php#L1038-L1054
230,266
Webiny/Framework
src/Webiny/Component/Bootstrap/Router.php
Router.initializeRouter
public function initializeRouter($url = null) { // current url $currentUrl = is_null($url) ? $this->httpRequest()->getCurrentUrl() : $url; // init the router try { // try matching a custom route $result = $this->router()->match($currentUrl); if ($result) { // custom route matched // based on callback, route the request $callback = $result->getCallback(); // namespace $ns = Bootstrap::getInstance()->getEnvironment()->getApplicationConfig()->get('Namespace', false); // extract callback parts $callbackData = $this->str($callback['Class'])->trimLeft('\\')->trimLeft($ns)->explode('\\')->val(); if ($callbackData[1] == 'Modules' && $callbackData[3] == 'Controllers') { // custom route, but still an MVC application return $this->dispatchMvc($callbackData[2], $callbackData[4], $callback['Method'], $result->getParams()); } else { // custom route and custom callback (non MVC) return $this->dispatchCustom($callback['Class'], $callback['Method'], $result->getParams()); } } else { // fallback to the mvc router return $this->mvcRouter($this->httpRequest()->getCurrentUrl(true)->getPath()); } } catch (\Exception $e) { throw $e; } throw new BootstrapException('No router matched the request.'); }
php
public function initializeRouter($url = null) { // current url $currentUrl = is_null($url) ? $this->httpRequest()->getCurrentUrl() : $url; // init the router try { // try matching a custom route $result = $this->router()->match($currentUrl); if ($result) { // custom route matched // based on callback, route the request $callback = $result->getCallback(); // namespace $ns = Bootstrap::getInstance()->getEnvironment()->getApplicationConfig()->get('Namespace', false); // extract callback parts $callbackData = $this->str($callback['Class'])->trimLeft('\\')->trimLeft($ns)->explode('\\')->val(); if ($callbackData[1] == 'Modules' && $callbackData[3] == 'Controllers') { // custom route, but still an MVC application return $this->dispatchMvc($callbackData[2], $callbackData[4], $callback['Method'], $result->getParams()); } else { // custom route and custom callback (non MVC) return $this->dispatchCustom($callback['Class'], $callback['Method'], $result->getParams()); } } else { // fallback to the mvc router return $this->mvcRouter($this->httpRequest()->getCurrentUrl(true)->getPath()); } } catch (\Exception $e) { throw $e; } throw new BootstrapException('No router matched the request.'); }
[ "public", "function", "initializeRouter", "(", "$", "url", "=", "null", ")", "{", "// current url", "$", "currentUrl", "=", "is_null", "(", "$", "url", ")", "?", "$", "this", "->", "httpRequest", "(", ")", "->", "getCurrentUrl", "(", ")", ":", "$", "url", ";", "// init the router", "try", "{", "// try matching a custom route", "$", "result", "=", "$", "this", "->", "router", "(", ")", "->", "match", "(", "$", "currentUrl", ")", ";", "if", "(", "$", "result", ")", "{", "// custom route matched", "// based on callback, route the request", "$", "callback", "=", "$", "result", "->", "getCallback", "(", ")", ";", "// namespace", "$", "ns", "=", "Bootstrap", "::", "getInstance", "(", ")", "->", "getEnvironment", "(", ")", "->", "getApplicationConfig", "(", ")", "->", "get", "(", "'Namespace'", ",", "false", ")", ";", "// extract callback parts", "$", "callbackData", "=", "$", "this", "->", "str", "(", "$", "callback", "[", "'Class'", "]", ")", "->", "trimLeft", "(", "'\\\\'", ")", "->", "trimLeft", "(", "$", "ns", ")", "->", "explode", "(", "'\\\\'", ")", "->", "val", "(", ")", ";", "if", "(", "$", "callbackData", "[", "1", "]", "==", "'Modules'", "&&", "$", "callbackData", "[", "3", "]", "==", "'Controllers'", ")", "{", "// custom route, but still an MVC application", "return", "$", "this", "->", "dispatchMvc", "(", "$", "callbackData", "[", "2", "]", ",", "$", "callbackData", "[", "4", "]", ",", "$", "callback", "[", "'Method'", "]", ",", "$", "result", "->", "getParams", "(", ")", ")", ";", "}", "else", "{", "// custom route and custom callback (non MVC)", "return", "$", "this", "->", "dispatchCustom", "(", "$", "callback", "[", "'Class'", "]", ",", "$", "callback", "[", "'Method'", "]", ",", "$", "result", "->", "getParams", "(", ")", ")", ";", "}", "}", "else", "{", "// fallback to the mvc router", "return", "$", "this", "->", "mvcRouter", "(", "$", "this", "->", "httpRequest", "(", ")", "->", "getCurrentUrl", "(", "true", ")", "->", "getPath", "(", ")", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "throw", "new", "BootstrapException", "(", "'No router matched the request.'", ")", ";", "}" ]
This is the request entry point, once the Bootstrap has been initialized. The method initializes router and tries to call the callback assigned to the current url. Method is call automatically from the Bootstrap class. @param string $url Url to route. If not set, the current url is used. @throws \Exception @return Dispatcher
[ "This", "is", "the", "request", "entry", "point", "once", "the", "Bootstrap", "has", "been", "initialized", ".", "The", "method", "initializes", "router", "and", "tries", "to", "call", "the", "callback", "assigned", "to", "the", "current", "url", ".", "Method", "is", "call", "automatically", "from", "the", "Bootstrap", "class", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/Router.php#L36-L71
230,267
Webiny/Framework
src/Webiny/Component/Bootstrap/Router.php
Router.mvcRouter
public function mvcRouter($request) { // parse the request $request = $this->str($request)->trimLeft('/')->trimRight('/')->explode('/'); if ($request->count() < 2) { throw new BootstrapException('Unable to route this request.'); } // extract the url parts $module = $this->str($request[0]); $controller = $this->str($request[1]); $action = isset($request[2]) ? $this->str($request[2]) : $this->str('index'); $params = []; if ($request->count() >= 4) { $params = $request->slice(3, $request->count())->val(); } // check if we need to normalize the request parts if ($module->contains('-')) { $module = $module->replace('-', ' ')->caseWordUpper()->replace(' ', ''); } else { $module = $module->charFirstUpper(); } if ($controller->contains('-')) { $controller = $controller->replace('-', ' ')->caseWordUpper()->replace(' ', ''); } else { $controller = $controller->charFirstUpper(); } if ($action->contains('-')) { $action = $action->replace('-', ' ')->caseWordUpper()->replace(' ', ''); } // call the dispatcher return $this->dispatchMvc($module->val(), $controller->val(), $action->val(), $params); }
php
public function mvcRouter($request) { // parse the request $request = $this->str($request)->trimLeft('/')->trimRight('/')->explode('/'); if ($request->count() < 2) { throw new BootstrapException('Unable to route this request.'); } // extract the url parts $module = $this->str($request[0]); $controller = $this->str($request[1]); $action = isset($request[2]) ? $this->str($request[2]) : $this->str('index'); $params = []; if ($request->count() >= 4) { $params = $request->slice(3, $request->count())->val(); } // check if we need to normalize the request parts if ($module->contains('-')) { $module = $module->replace('-', ' ')->caseWordUpper()->replace(' ', ''); } else { $module = $module->charFirstUpper(); } if ($controller->contains('-')) { $controller = $controller->replace('-', ' ')->caseWordUpper()->replace(' ', ''); } else { $controller = $controller->charFirstUpper(); } if ($action->contains('-')) { $action = $action->replace('-', ' ')->caseWordUpper()->replace(' ', ''); } // call the dispatcher return $this->dispatchMvc($module->val(), $controller->val(), $action->val(), $params); }
[ "public", "function", "mvcRouter", "(", "$", "request", ")", "{", "// parse the request", "$", "request", "=", "$", "this", "->", "str", "(", "$", "request", ")", "->", "trimLeft", "(", "'/'", ")", "->", "trimRight", "(", "'/'", ")", "->", "explode", "(", "'/'", ")", ";", "if", "(", "$", "request", "->", "count", "(", ")", "<", "2", ")", "{", "throw", "new", "BootstrapException", "(", "'Unable to route this request.'", ")", ";", "}", "// extract the url parts", "$", "module", "=", "$", "this", "->", "str", "(", "$", "request", "[", "0", "]", ")", ";", "$", "controller", "=", "$", "this", "->", "str", "(", "$", "request", "[", "1", "]", ")", ";", "$", "action", "=", "isset", "(", "$", "request", "[", "2", "]", ")", "?", "$", "this", "->", "str", "(", "$", "request", "[", "2", "]", ")", ":", "$", "this", "->", "str", "(", "'index'", ")", ";", "$", "params", "=", "[", "]", ";", "if", "(", "$", "request", "->", "count", "(", ")", ">=", "4", ")", "{", "$", "params", "=", "$", "request", "->", "slice", "(", "3", ",", "$", "request", "->", "count", "(", ")", ")", "->", "val", "(", ")", ";", "}", "// check if we need to normalize the request parts", "if", "(", "$", "module", "->", "contains", "(", "'-'", ")", ")", "{", "$", "module", "=", "$", "module", "->", "replace", "(", "'-'", ",", "' '", ")", "->", "caseWordUpper", "(", ")", "->", "replace", "(", "' '", ",", "''", ")", ";", "}", "else", "{", "$", "module", "=", "$", "module", "->", "charFirstUpper", "(", ")", ";", "}", "if", "(", "$", "controller", "->", "contains", "(", "'-'", ")", ")", "{", "$", "controller", "=", "$", "controller", "->", "replace", "(", "'-'", ",", "' '", ")", "->", "caseWordUpper", "(", ")", "->", "replace", "(", "' '", ",", "''", ")", ";", "}", "else", "{", "$", "controller", "=", "$", "controller", "->", "charFirstUpper", "(", ")", ";", "}", "if", "(", "$", "action", "->", "contains", "(", "'-'", ")", ")", "{", "$", "action", "=", "$", "action", "->", "replace", "(", "'-'", ",", "' '", ")", "->", "caseWordUpper", "(", ")", "->", "replace", "(", "' '", ",", "''", ")", ";", "}", "// call the dispatcher", "return", "$", "this", "->", "dispatchMvc", "(", "$", "module", "->", "val", "(", ")", ",", "$", "controller", "->", "val", "(", ")", ",", "$", "action", "->", "val", "(", ")", ",", "$", "params", ")", ";", "}" ]
This is the optional router that routes the MVC requests. @param string $request Current url path. @return Dispatcher @throws BootstrapException @throws \Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObjectException @throws \Webiny\Component\StdLib\StdObject\StringObject\StringObjectException
[ "This", "is", "the", "optional", "router", "that", "routes", "the", "MVC", "requests", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/Router.php#L84-L118
230,268
Webiny/Framework
src/Webiny/Component/Bootstrap/Router.php
Router.dispatchMvc
private function dispatchMvc($module, $controller, $action, $params) { return Dispatcher::mvcDispatcher($module, $controller, $action, $params); }
php
private function dispatchMvc($module, $controller, $action, $params) { return Dispatcher::mvcDispatcher($module, $controller, $action, $params); }
[ "private", "function", "dispatchMvc", "(", "$", "module", ",", "$", "controller", ",", "$", "action", ",", "$", "params", ")", "{", "return", "Dispatcher", "::", "mvcDispatcher", "(", "$", "module", ",", "$", "controller", ",", "$", "action", ",", "$", "params", ")", ";", "}" ]
Issues the callback using the MVC dispatcher. @param string $module Module name. @param string $controller Controller name. @param string $action Action name. @param array $params Parameter list. @return Dispatcher
[ "Issues", "the", "callback", "using", "the", "MVC", "dispatcher", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/Router.php#L130-L133
230,269
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/StringObject/StringObject.php
StringObject.wordCount
public function wordCount($format = 0) { if ($format < 1) { return str_word_count($this->val(), $format); } else { return new ArrayObject(str_word_count($this->val(), $format)); } }
php
public function wordCount($format = 0) { if ($format < 1) { return str_word_count($this->val(), $format); } else { return new ArrayObject(str_word_count($this->val(), $format)); } }
[ "public", "function", "wordCount", "(", "$", "format", "=", "0", ")", "{", "if", "(", "$", "format", "<", "1", ")", "{", "return", "str_word_count", "(", "$", "this", "->", "val", "(", ")", ",", "$", "format", ")", ";", "}", "else", "{", "return", "new", "ArrayObject", "(", "str_word_count", "(", "$", "this", "->", "val", "(", ")", ",", "$", "format", ")", ")", ";", "}", "}" ]
Get the number of words in the string. @param int $format Specify the return format: 0 - return number of words 1 - return an ArrayObject containing all the words found inside the string 2 - returns an ArrayObject, where the key is the numeric position of the word inside the string and the value is the actual word itself @return mixed|ArrayObject An ArrayObject or integer, based on the wanted $format, with the stats about the words in the string.
[ "Get", "the", "number", "of", "words", "in", "the", "string", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/StringObject/StringObject.php#L87-L95
230,270
Webiny/Framework
src/Webiny/Component/StdLib/StdObject/StringObject/StringObject.php
StringObject.subStringCount
public function subStringCount($string, $offset = 0, $length = null) { if ($this->isNull($length)) { $length = $this->length(); } return substr_count($this->val(), $string, $offset, $length); }
php
public function subStringCount($string, $offset = 0, $length = null) { if ($this->isNull($length)) { $length = $this->length(); } return substr_count($this->val(), $string, $offset, $length); }
[ "public", "function", "subStringCount", "(", "$", "string", ",", "$", "offset", "=", "0", ",", "$", "length", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isNull", "(", "$", "length", ")", ")", "{", "$", "length", "=", "$", "this", "->", "length", "(", ")", ";", "}", "return", "substr_count", "(", "$", "this", "->", "val", "(", ")", ",", "$", "string", ",", "$", "offset", ",", "$", "length", ")", ";", "}" ]
Get number of string occurrences in current string. @param string $string String to search for @param null|int $offset The offset where to start counting @param null|int $length The maximum length after the specified offset to search for the substring. It outputs a warning if the offset plus the length is greater than the haystack length. @return int
[ "Get", "number", "of", "string", "occurrences", "in", "current", "string", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/StdObject/StringObject/StringObject.php#L117-L124
230,271
decred/decred-php-api
src/Decred/Crypto/Curve.php
Curve.ensureOnCurve
public static function ensureOnCurve($key) { $point = self::unserializePoint($key); if (!static::curve()->contains($point->getX(), $point->getY())) { throw new \InvalidArgumentException( 'Invalid key. Point is not on the curve.' ); } }
php
public static function ensureOnCurve($key) { $point = self::unserializePoint($key); if (!static::curve()->contains($point->getX(), $point->getY())) { throw new \InvalidArgumentException( 'Invalid key. Point is not on the curve.' ); } }
[ "public", "static", "function", "ensureOnCurve", "(", "$", "key", ")", "{", "$", "point", "=", "self", "::", "unserializePoint", "(", "$", "key", ")", ";", "if", "(", "!", "static", "::", "curve", "(", ")", "->", "contains", "(", "$", "point", "->", "getX", "(", ")", ",", "$", "point", "->", "getY", "(", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid key. Point is not on the curve.'", ")", ";", "}", "}" ]
Is key on the secp256k1 curve. @param string $key @return bool
[ "Is", "key", "on", "the", "secp256k1", "curve", "." ]
dafea9ceac918c4c3cd9bc7c436009a95dfb1643
https://github.com/decred/decred-php-api/blob/dafea9ceac918c4c3cd9bc7c436009a95dfb1643/src/Decred/Crypto/Curve.php#L101-L109
230,272
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.filterFields
public function filterFields(Model $model, $filter = array()) { if (empty($filter) || $filter === '*') { return $model->fields; } $fields = array(); foreach ($filter as $field) { list($table, $field) = pluginSplit($field); $fields[$field] = $model->fields[$field]; } return $fields; }
php
public function filterFields(Model $model, $filter = array()) { if (empty($filter) || $filter === '*') { return $model->fields; } $fields = array(); foreach ($filter as $field) { list($table, $field) = pluginSplit($field); $fields[$field] = $model->fields[$field]; } return $fields; }
[ "public", "function", "filterFields", "(", "Model", "$", "model", ",", "$", "filter", "=", "array", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "filter", ")", "||", "$", "filter", "===", "'*'", ")", "{", "return", "$", "model", "->", "fields", ";", "}", "$", "fields", "=", "array", "(", ")", ";", "foreach", "(", "$", "filter", "as", "$", "field", ")", "{", "list", "(", "$", "table", ",", "$", "field", ")", "=", "pluginSplit", "(", "$", "field", ")", ";", "$", "fields", "[", "$", "field", "]", "=", "$", "model", "->", "fields", "[", "$", "field", "]", ";", "}", "return", "$", "fields", ";", "}" ]
Filter down fields if the association has a whitelist. @param Model $model @param array $filter @return array|mixed
[ "Filter", "down", "fields", "if", "the", "association", "has", "a", "whitelist", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L26-L40
230,273
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.getBehaviorCallbacks
public function getBehaviorCallbacks(Model $model) { $callbacks = array(); $behaviors = Configure::read('Admin.behaviorCallbacks'); foreach ($behaviors as $behavior => $methods) { if (!$model->Behaviors->loaded($behavior)) { continue; } foreach ($methods as $method => $options) { if (is_string($options)) { $options = array('title' => $options, 'access' => 'update'); } else { $options = $options += array('access' => 'update'); } if ($this->hasAccess($model->qualifiedName, $options['access'])) { $callbacks[$method] = array( 'title' => __d('admin', $options['title'], $model->singularName), 'behavior' => Inflector::underscore($behavior), 'method' => $method ); } } } return $callbacks; }
php
public function getBehaviorCallbacks(Model $model) { $callbacks = array(); $behaviors = Configure::read('Admin.behaviorCallbacks'); foreach ($behaviors as $behavior => $methods) { if (!$model->Behaviors->loaded($behavior)) { continue; } foreach ($methods as $method => $options) { if (is_string($options)) { $options = array('title' => $options, 'access' => 'update'); } else { $options = $options += array('access' => 'update'); } if ($this->hasAccess($model->qualifiedName, $options['access'])) { $callbacks[$method] = array( 'title' => __d('admin', $options['title'], $model->singularName), 'behavior' => Inflector::underscore($behavior), 'method' => $method ); } } } return $callbacks; }
[ "public", "function", "getBehaviorCallbacks", "(", "Model", "$", "model", ")", "{", "$", "callbacks", "=", "array", "(", ")", ";", "$", "behaviors", "=", "Configure", "::", "read", "(", "'Admin.behaviorCallbacks'", ")", ";", "foreach", "(", "$", "behaviors", "as", "$", "behavior", "=>", "$", "methods", ")", "{", "if", "(", "!", "$", "model", "->", "Behaviors", "->", "loaded", "(", "$", "behavior", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "methods", "as", "$", "method", "=>", "$", "options", ")", "{", "if", "(", "is_string", "(", "$", "options", ")", ")", "{", "$", "options", "=", "array", "(", "'title'", "=>", "$", "options", ",", "'access'", "=>", "'update'", ")", ";", "}", "else", "{", "$", "options", "=", "$", "options", "+=", "array", "(", "'access'", "=>", "'update'", ")", ";", "}", "if", "(", "$", "this", "->", "hasAccess", "(", "$", "model", "->", "qualifiedName", ",", "$", "options", "[", "'access'", "]", ")", ")", "{", "$", "callbacks", "[", "$", "method", "]", "=", "array", "(", "'title'", "=>", "__d", "(", "'admin'", ",", "$", "options", "[", "'title'", "]", ",", "$", "model", "->", "singularName", ")", ",", "'behavior'", "=>", "Inflector", "::", "underscore", "(", "$", "behavior", ")", ",", "'method'", "=>", "$", "method", ")", ";", "}", "}", "}", "return", "$", "callbacks", ";", "}" ]
Return a list of valid callbacks for the model + behaviors and logged in user. @param Model $model @return array
[ "Return", "a", "list", "of", "valid", "callbacks", "for", "the", "model", "+", "behaviors", "and", "logged", "in", "user", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L48-L75
230,274
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.getDependencies
public function getDependencies(Model $model, $depth = 0) { $dependencies = array(); if ($depth >= 5) { return $dependencies; } foreach (array($model->hasOne, $model->hasMany, $model->hasAndBelongsToMany) as $assocGroup) { foreach ($assocGroup as $alias => $assoc) { // hasOne, hasMany if (isset($assoc['dependent']) && $assoc['dependent']) { $class = $assoc['className']; // hasAndBelongsToMany } else if (isset($assoc['joinTable'])) { $class = $assoc['with']; } else { continue; } $dependencies[] = array( 'alias' => $alias, 'model' => $class, 'dependencies' => $this->getDependencies($this->introspect($class), ($depth + 1)) ); } } return $dependencies; }
php
public function getDependencies(Model $model, $depth = 0) { $dependencies = array(); if ($depth >= 5) { return $dependencies; } foreach (array($model->hasOne, $model->hasMany, $model->hasAndBelongsToMany) as $assocGroup) { foreach ($assocGroup as $alias => $assoc) { // hasOne, hasMany if (isset($assoc['dependent']) && $assoc['dependent']) { $class = $assoc['className']; // hasAndBelongsToMany } else if (isset($assoc['joinTable'])) { $class = $assoc['with']; } else { continue; } $dependencies[] = array( 'alias' => $alias, 'model' => $class, 'dependencies' => $this->getDependencies($this->introspect($class), ($depth + 1)) ); } } return $dependencies; }
[ "public", "function", "getDependencies", "(", "Model", "$", "model", ",", "$", "depth", "=", "0", ")", "{", "$", "dependencies", "=", "array", "(", ")", ";", "if", "(", "$", "depth", ">=", "5", ")", "{", "return", "$", "dependencies", ";", "}", "foreach", "(", "array", "(", "$", "model", "->", "hasOne", ",", "$", "model", "->", "hasMany", ",", "$", "model", "->", "hasAndBelongsToMany", ")", "as", "$", "assocGroup", ")", "{", "foreach", "(", "$", "assocGroup", "as", "$", "alias", "=>", "$", "assoc", ")", "{", "// hasOne, hasMany", "if", "(", "isset", "(", "$", "assoc", "[", "'dependent'", "]", ")", "&&", "$", "assoc", "[", "'dependent'", "]", ")", "{", "$", "class", "=", "$", "assoc", "[", "'className'", "]", ";", "// hasAndBelongsToMany", "}", "else", "if", "(", "isset", "(", "$", "assoc", "[", "'joinTable'", "]", ")", ")", "{", "$", "class", "=", "$", "assoc", "[", "'with'", "]", ";", "}", "else", "{", "continue", ";", "}", "$", "dependencies", "[", "]", "=", "array", "(", "'alias'", "=>", "$", "alias", ",", "'model'", "=>", "$", "class", ",", "'dependencies'", "=>", "$", "this", "->", "getDependencies", "(", "$", "this", "->", "introspect", "(", "$", "class", ")", ",", "(", "$", "depth", "+", "1", ")", ")", ")", ";", "}", "}", "return", "$", "dependencies", ";", "}" ]
Generate a nested list of dependencies by looping and drilling down through all the model associations. @param Model $model @param int $depth @return array
[ "Generate", "a", "nested", "list", "of", "dependencies", "by", "looping", "and", "drilling", "down", "through", "all", "the", "model", "associations", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L84-L114
230,275
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.getDisplayField
public function getDisplayField(Model $model, $result) { $displayField = $result[$model->alias][$model->displayField]; if (!$displayField) { $displayField = $this->Html->tag('span', '(' . __d('admin', 'No Title') . ')', array( 'class' => 'text-warning' )); } return $displayField; }
php
public function getDisplayField(Model $model, $result) { $displayField = $result[$model->alias][$model->displayField]; if (!$displayField) { $displayField = $this->Html->tag('span', '(' . __d('admin', 'No Title') . ')', array( 'class' => 'text-warning' )); } return $displayField; }
[ "public", "function", "getDisplayField", "(", "Model", "$", "model", ",", "$", "result", ")", "{", "$", "displayField", "=", "$", "result", "[", "$", "model", "->", "alias", "]", "[", "$", "model", "->", "displayField", "]", ";", "if", "(", "!", "$", "displayField", ")", "{", "$", "displayField", "=", "$", "this", "->", "Html", "->", "tag", "(", "'span'", ",", "'('", ".", "__d", "(", "'admin'", ",", "'No Title'", ")", ".", "')'", ",", "array", "(", "'class'", "=>", "'text-warning'", ")", ")", ";", "}", "return", "$", "displayField", ";", "}" ]
Return the display field. If field does not exist, use the ID. @param Model $model @param array $result @return string
[ "Return", "the", "display", "field", ".", "If", "field", "does", "not", "exist", "use", "the", "ID", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L123-L133
230,276
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.getModelCallbacks
public function getModelCallbacks(Model $model, $scope = '*') { $callbacks = array(); $models = Configure::read('Admin.modelCallbacks'); if (isset($models[$model->qualifiedName])) { foreach ($models[$model->qualifiedName] as $method => $options) { if (is_string($options)) { $options = array('title' => $options, 'access' => 'update', 'scope' => '*'); } else { $options = $options += array('access' => 'update', 'scope' => '*'); } if ($options['scope'] !== $scope) { continue; } if ($this->hasAccess($model->qualifiedName, $options['access'])) { $callbacks[$method] = __d('admin', $options['title'], $model->singularName); } } } return $callbacks; }
php
public function getModelCallbacks(Model $model, $scope = '*') { $callbacks = array(); $models = Configure::read('Admin.modelCallbacks'); if (isset($models[$model->qualifiedName])) { foreach ($models[$model->qualifiedName] as $method => $options) { if (is_string($options)) { $options = array('title' => $options, 'access' => 'update', 'scope' => '*'); } else { $options = $options += array('access' => 'update', 'scope' => '*'); } if ($options['scope'] !== $scope) { continue; } if ($this->hasAccess($model->qualifiedName, $options['access'])) { $callbacks[$method] = __d('admin', $options['title'], $model->singularName); } } } return $callbacks; }
[ "public", "function", "getModelCallbacks", "(", "Model", "$", "model", ",", "$", "scope", "=", "'*'", ")", "{", "$", "callbacks", "=", "array", "(", ")", ";", "$", "models", "=", "Configure", "::", "read", "(", "'Admin.modelCallbacks'", ")", ";", "if", "(", "isset", "(", "$", "models", "[", "$", "model", "->", "qualifiedName", "]", ")", ")", "{", "foreach", "(", "$", "models", "[", "$", "model", "->", "qualifiedName", "]", "as", "$", "method", "=>", "$", "options", ")", "{", "if", "(", "is_string", "(", "$", "options", ")", ")", "{", "$", "options", "=", "array", "(", "'title'", "=>", "$", "options", ",", "'access'", "=>", "'update'", ",", "'scope'", "=>", "'*'", ")", ";", "}", "else", "{", "$", "options", "=", "$", "options", "+=", "array", "(", "'access'", "=>", "'update'", ",", "'scope'", "=>", "'*'", ")", ";", "}", "if", "(", "$", "options", "[", "'scope'", "]", "!==", "$", "scope", ")", "{", "continue", ";", "}", "if", "(", "$", "this", "->", "hasAccess", "(", "$", "model", "->", "qualifiedName", ",", "$", "options", "[", "'access'", "]", ")", ")", "{", "$", "callbacks", "[", "$", "method", "]", "=", "__d", "(", "'admin'", ",", "$", "options", "[", "'title'", "]", ",", "$", "model", "->", "singularName", ")", ";", "}", "}", "}", "return", "$", "callbacks", ";", "}" ]
Return a list of valid callbacks for the model and logged in user. @param Model $model @param string $scope @return array
[ "Return", "a", "list", "of", "valid", "callbacks", "for", "the", "model", "and", "logged", "in", "user", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L142-L165
230,277
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.getModelLinks
public function getModelLinks(Model $model) { $models = Configure::read('Admin.modelLinks'); if (isset($models[$model->qualifiedName])) { return $models[$model->qualifiedName]; } return array(); }
php
public function getModelLinks(Model $model) { $models = Configure::read('Admin.modelLinks'); if (isset($models[$model->qualifiedName])) { return $models[$model->qualifiedName]; } return array(); }
[ "public", "function", "getModelLinks", "(", "Model", "$", "model", ")", "{", "$", "models", "=", "Configure", "::", "read", "(", "'Admin.modelLinks'", ")", ";", "if", "(", "isset", "(", "$", "models", "[", "$", "model", "->", "qualifiedName", "]", ")", ")", "{", "return", "$", "models", "[", "$", "model", "->", "qualifiedName", "]", ";", "}", "return", "array", "(", ")", ";", "}" ]
Return a list of valid links for a record @param Model $model @return array
[ "Return", "a", "list", "of", "valid", "links", "for", "a", "record" ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L173-L181
230,278
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.getNavigation
public function getNavigation() { $plugins = Admin::getModels(); $navigation = array(); foreach ($plugins as $plugin) { $models = array(); foreach ($plugin['models'] as $model) { if ($model['installed']) { $models[Inflector::humanize($model['group'])][] = $model; } } $navigation[$plugin['title']] = $models; } return $navigation; }
php
public function getNavigation() { $plugins = Admin::getModels(); $navigation = array(); foreach ($plugins as $plugin) { $models = array(); foreach ($plugin['models'] as $model) { if ($model['installed']) { $models[Inflector::humanize($model['group'])][] = $model; } } $navigation[$plugin['title']] = $models; } return $navigation; }
[ "public", "function", "getNavigation", "(", ")", "{", "$", "plugins", "=", "Admin", "::", "getModels", "(", ")", ";", "$", "navigation", "=", "array", "(", ")", ";", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "$", "models", "=", "array", "(", ")", ";", "foreach", "(", "$", "plugin", "[", "'models'", "]", "as", "$", "model", ")", "{", "if", "(", "$", "model", "[", "'installed'", "]", ")", "{", "$", "models", "[", "Inflector", "::", "humanize", "(", "$", "model", "[", "'group'", "]", ")", "]", "[", "]", "=", "$", "model", ";", "}", "}", "$", "navigation", "[", "$", "plugin", "[", "'title'", "]", "]", "=", "$", "models", ";", "}", "return", "$", "navigation", ";", "}" ]
Return a list of models grouped by plugin, to use in the navigation menu. @return array
[ "Return", "a", "list", "of", "models", "grouped", "by", "plugin", "to", "use", "in", "the", "navigation", "menu", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L188-L205
230,279
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.getUserRoute
public function getUserRoute($route, array $user) { $route = Configure::read('User.routes.' . $route); if (!$route) { return null; } $route = (array) $route; foreach ($route as &$value) { if ($value === '{id}') { $value = $user['id']; } else if ($value === '{slug}' && isset($user['slug'])) { $value = $user['slug']; } else if ($value === '{username}') { $value = $user[Configure::read('User.fieldMap.username')]; } } return $this->url($route); }
php
public function getUserRoute($route, array $user) { $route = Configure::read('User.routes.' . $route); if (!$route) { return null; } $route = (array) $route; foreach ($route as &$value) { if ($value === '{id}') { $value = $user['id']; } else if ($value === '{slug}' && isset($user['slug'])) { $value = $user['slug']; } else if ($value === '{username}') { $value = $user[Configure::read('User.fieldMap.username')]; } } return $this->url($route); }
[ "public", "function", "getUserRoute", "(", "$", "route", ",", "array", "$", "user", ")", "{", "$", "route", "=", "Configure", "::", "read", "(", "'User.routes.'", ".", "$", "route", ")", ";", "if", "(", "!", "$", "route", ")", "{", "return", "null", ";", "}", "$", "route", "=", "(", "array", ")", "$", "route", ";", "foreach", "(", "$", "route", "as", "&", "$", "value", ")", "{", "if", "(", "$", "value", "===", "'{id}'", ")", "{", "$", "value", "=", "$", "user", "[", "'id'", "]", ";", "}", "else", "if", "(", "$", "value", "===", "'{slug}'", "&&", "isset", "(", "$", "user", "[", "'slug'", "]", ")", ")", "{", "$", "value", "=", "$", "user", "[", "'slug'", "]", ";", "}", "else", "if", "(", "$", "value", "===", "'{username}'", ")", "{", "$", "value", "=", "$", "user", "[", "Configure", "::", "read", "(", "'User.fieldMap.username'", ")", "]", ";", "}", "}", "return", "$", "this", "->", "url", "(", "$", "route", ")", ";", "}" ]
Return a parse user route. @param string $route @param array $user @return string
[ "Return", "a", "parse", "user", "route", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L214-L236
230,280
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.hasRole
public function hasRole($role) { $roles = (array) $this->Session->read('Acl.roles'); if (is_numeric($role)) { return isset($roles[$role]); } return in_array($role, $roles); }
php
public function hasRole($role) { $roles = (array) $this->Session->read('Acl.roles'); if (is_numeric($role)) { return isset($roles[$role]); } return in_array($role, $roles); }
[ "public", "function", "hasRole", "(", "$", "role", ")", "{", "$", "roles", "=", "(", "array", ")", "$", "this", "->", "Session", "->", "read", "(", "'Acl.roles'", ")", ";", "if", "(", "is_numeric", "(", "$", "role", ")", ")", "{", "return", "isset", "(", "$", "roles", "[", "$", "role", "]", ")", ";", "}", "return", "in_array", "(", "$", "role", ",", "$", "roles", ")", ";", "}" ]
Check to see if the user has a role. @param int|string $role @return bool
[ "Check", "to", "see", "if", "the", "user", "has", "a", "role", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L257-L265
230,281
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.loopDependencies
public function loopDependencies($list, &$exclude = array()) { if (!$list) { return null; } $output = ''; foreach ($list as $dependent) { if (in_array($dependent['model'], $exclude)) { continue; } $exclude[] = $dependent['model']; $output .= sprintf('<li>%s (%s) %s</li>', $dependent['model'], $dependent['alias'], $this->loopDependencies($dependent['dependencies'], $exclude)); } return $this->Html->tag('ul', $output); }
php
public function loopDependencies($list, &$exclude = array()) { if (!$list) { return null; } $output = ''; foreach ($list as $dependent) { if (in_array($dependent['model'], $exclude)) { continue; } $exclude[] = $dependent['model']; $output .= sprintf('<li>%s (%s) %s</li>', $dependent['model'], $dependent['alias'], $this->loopDependencies($dependent['dependencies'], $exclude)); } return $this->Html->tag('ul', $output); }
[ "public", "function", "loopDependencies", "(", "$", "list", ",", "&", "$", "exclude", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "list", ")", "{", "return", "null", ";", "}", "$", "output", "=", "''", ";", "foreach", "(", "$", "list", "as", "$", "dependent", ")", "{", "if", "(", "in_array", "(", "$", "dependent", "[", "'model'", "]", ",", "$", "exclude", ")", ")", "{", "continue", ";", "}", "$", "exclude", "[", "]", "=", "$", "dependent", "[", "'model'", "]", ";", "$", "output", ".=", "sprintf", "(", "'<li>%s (%s) %s</li>'", ",", "$", "dependent", "[", "'model'", "]", ",", "$", "dependent", "[", "'alias'", "]", ",", "$", "this", "->", "loopDependencies", "(", "$", "dependent", "[", "'dependencies'", "]", ",", "$", "exclude", ")", ")", ";", "}", "return", "$", "this", "->", "Html", "->", "tag", "(", "'ul'", ",", "$", "output", ")", ";", "}" ]
Generate a nested list of deletion model dependencies. @param array $list @param array $exclude @return string
[ "Generate", "a", "nested", "list", "of", "deletion", "model", "dependencies", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L302-L323
230,282
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.outputAssocName
public function outputAssocName($model, $alias, $className) { $output = $this->outputIconTitle($model, $alias); if ($className != $alias) { $output .= sprintf(' (%s)', $this->Html->tag('span', $className, array('class' => 'text-muted')) ); } return $output; }
php
public function outputAssocName($model, $alias, $className) { $output = $this->outputIconTitle($model, $alias); if ($className != $alias) { $output .= sprintf(' (%s)', $this->Html->tag('span', $className, array('class' => 'text-muted')) ); } return $output; }
[ "public", "function", "outputAssocName", "(", "$", "model", ",", "$", "alias", ",", "$", "className", ")", "{", "$", "output", "=", "$", "this", "->", "outputIconTitle", "(", "$", "model", ",", "$", "alias", ")", ";", "if", "(", "$", "className", "!=", "$", "alias", ")", "{", "$", "output", ".=", "sprintf", "(", "' (%s)'", ",", "$", "this", "->", "Html", "->", "tag", "(", "'span'", ",", "$", "className", ",", "array", "(", "'class'", "=>", "'text-muted'", ")", ")", ")", ";", "}", "return", "$", "output", ";", "}" ]
Output an association alias and class name. If both are equal, only display the alias. @param Model|array $model @param string $alias @param string $className @return string
[ "Output", "an", "association", "alias", "and", "class", "name", ".", "If", "both", "are", "equal", "only", "display", "the", "alias", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L360-L370
230,283
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.outputIconTitle
public function outputIconTitle($model, $title = null) { if ($model instanceof Model) { $model = $model->admin; } if (!$title && isset($model['title'])) { $title = $model['title']; } if ($model['iconClass']) { $title = $this->Html->tag('span', '&nbsp;', array( 'class' => 'model-icon fa ' . str_replace('icon-', 'fa-', $model['iconClass']) // FontAwesome 4.0 fix )) . ' ' . $title; } return $title; }
php
public function outputIconTitle($model, $title = null) { if ($model instanceof Model) { $model = $model->admin; } if (!$title && isset($model['title'])) { $title = $model['title']; } if ($model['iconClass']) { $title = $this->Html->tag('span', '&nbsp;', array( 'class' => 'model-icon fa ' . str_replace('icon-', 'fa-', $model['iconClass']) // FontAwesome 4.0 fix )) . ' ' . $title; } return $title; }
[ "public", "function", "outputIconTitle", "(", "$", "model", ",", "$", "title", "=", "null", ")", "{", "if", "(", "$", "model", "instanceof", "Model", ")", "{", "$", "model", "=", "$", "model", "->", "admin", ";", "}", "if", "(", "!", "$", "title", "&&", "isset", "(", "$", "model", "[", "'title'", "]", ")", ")", "{", "$", "title", "=", "$", "model", "[", "'title'", "]", ";", "}", "if", "(", "$", "model", "[", "'iconClass'", "]", ")", "{", "$", "title", "=", "$", "this", "->", "Html", "->", "tag", "(", "'span'", ",", "'&nbsp;'", ",", "array", "(", "'class'", "=>", "'model-icon fa '", ".", "str_replace", "(", "'icon-'", ",", "'fa-'", ",", "$", "model", "[", "'iconClass'", "]", ")", "// FontAwesome 4.0 fix", ")", ")", ".", "' '", ".", "$", "title", ";", "}", "return", "$", "title", ";", "}" ]
Output a model title and icon if applicable. @param Model|array $model @param string $title @return string
[ "Output", "a", "model", "title", "and", "icon", "if", "applicable", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L379-L395
230,284
milesj/admin
View/Helper/AdminHelper.php
AdminHelper.setBreadcrumbs
public function setBreadcrumbs(Model $model, $result, $action) { list($plugin, $alias) = pluginSplit($model->qualifiedName); $this->Breadcrumb->add($plugin, array('controller' => 'admin', 'action' => 'index', '#' => Inflector::underscore($plugin))); $this->Breadcrumb->add($model->pluralName, array('controller' => 'crud', 'action' => 'index', 'model' => $model->urlSlug)); switch ($action) { case 'create': $this->Breadcrumb->add(__d('admin', 'Add'), array('action' => 'create', 'model' => $model->urlSlug)); break; case 'read': case 'update': case 'delete': $id = $result[$model->alias][$model->primaryKey]; $displayField = $this->getDisplayField($model, $result); $this->Breadcrumb->add($displayField, array('action' => 'read', $id, 'model' => $model->urlSlug)); if ($action === 'update' || $action === 'delete') { $this->Breadcrumb->add(__d('admin', ($action === 'update') ? 'Update' : 'Delete'), array('action' => $action, $id, 'model' => $model->urlSlug)); } break; } }
php
public function setBreadcrumbs(Model $model, $result, $action) { list($plugin, $alias) = pluginSplit($model->qualifiedName); $this->Breadcrumb->add($plugin, array('controller' => 'admin', 'action' => 'index', '#' => Inflector::underscore($plugin))); $this->Breadcrumb->add($model->pluralName, array('controller' => 'crud', 'action' => 'index', 'model' => $model->urlSlug)); switch ($action) { case 'create': $this->Breadcrumb->add(__d('admin', 'Add'), array('action' => 'create', 'model' => $model->urlSlug)); break; case 'read': case 'update': case 'delete': $id = $result[$model->alias][$model->primaryKey]; $displayField = $this->getDisplayField($model, $result); $this->Breadcrumb->add($displayField, array('action' => 'read', $id, 'model' => $model->urlSlug)); if ($action === 'update' || $action === 'delete') { $this->Breadcrumb->add(__d('admin', ($action === 'update') ? 'Update' : 'Delete'), array('action' => $action, $id, 'model' => $model->urlSlug)); } break; } }
[ "public", "function", "setBreadcrumbs", "(", "Model", "$", "model", ",", "$", "result", ",", "$", "action", ")", "{", "list", "(", "$", "plugin", ",", "$", "alias", ")", "=", "pluginSplit", "(", "$", "model", "->", "qualifiedName", ")", ";", "$", "this", "->", "Breadcrumb", "->", "add", "(", "$", "plugin", ",", "array", "(", "'controller'", "=>", "'admin'", ",", "'action'", "=>", "'index'", ",", "'#'", "=>", "Inflector", "::", "underscore", "(", "$", "plugin", ")", ")", ")", ";", "$", "this", "->", "Breadcrumb", "->", "add", "(", "$", "model", "->", "pluralName", ",", "array", "(", "'controller'", "=>", "'crud'", ",", "'action'", "=>", "'index'", ",", "'model'", "=>", "$", "model", "->", "urlSlug", ")", ")", ";", "switch", "(", "$", "action", ")", "{", "case", "'create'", ":", "$", "this", "->", "Breadcrumb", "->", "add", "(", "__d", "(", "'admin'", ",", "'Add'", ")", ",", "array", "(", "'action'", "=>", "'create'", ",", "'model'", "=>", "$", "model", "->", "urlSlug", ")", ")", ";", "break", ";", "case", "'read'", ":", "case", "'update'", ":", "case", "'delete'", ":", "$", "id", "=", "$", "result", "[", "$", "model", "->", "alias", "]", "[", "$", "model", "->", "primaryKey", "]", ";", "$", "displayField", "=", "$", "this", "->", "getDisplayField", "(", "$", "model", ",", "$", "result", ")", ";", "$", "this", "->", "Breadcrumb", "->", "add", "(", "$", "displayField", ",", "array", "(", "'action'", "=>", "'read'", ",", "$", "id", ",", "'model'", "=>", "$", "model", "->", "urlSlug", ")", ")", ";", "if", "(", "$", "action", "===", "'update'", "||", "$", "action", "===", "'delete'", ")", "{", "$", "this", "->", "Breadcrumb", "->", "add", "(", "__d", "(", "'admin'", ",", "(", "$", "action", "===", "'update'", ")", "?", "'Update'", ":", "'Delete'", ")", ",", "array", "(", "'action'", "=>", "$", "action", ",", "$", "id", ",", "'model'", "=>", "$", "model", "->", "urlSlug", ")", ")", ";", "}", "break", ";", "}", "}" ]
Set the breadcrumbs for the respective model and action. @param Model $model @param array $result @param string $action
[ "Set", "the", "breadcrumbs", "for", "the", "respective", "model", "and", "action", "." ]
e5e93823d1eb4415f05a3191f653eb50c296d2c6
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/View/Helper/AdminHelper.php#L404-L427
230,285
Webiny/Framework
src/Webiny/Component/Image/ImageTrait.php
ImageTrait.image
public function image($image, $storage = 'local') { if ($image instanceof File) { return ImageLoader::load($image->getContents()); } else { if (!($storage instanceof Storage)) { $storage = ServiceManager::getInstance()->getService('Storage.' . $storage); } $file = new File($image, $storage); return ImageLoader::load($file->getContents()); } }
php
public function image($image, $storage = 'local') { if ($image instanceof File) { return ImageLoader::load($image->getContents()); } else { if (!($storage instanceof Storage)) { $storage = ServiceManager::getInstance()->getService('Storage.' . $storage); } $file = new File($image, $storage); return ImageLoader::load($file->getContents()); } }
[ "public", "function", "image", "(", "$", "image", ",", "$", "storage", "=", "'local'", ")", "{", "if", "(", "$", "image", "instanceof", "File", ")", "{", "return", "ImageLoader", "::", "load", "(", "$", "image", "->", "getContents", "(", ")", ")", ";", "}", "else", "{", "if", "(", "!", "(", "$", "storage", "instanceof", "Storage", ")", ")", "{", "$", "storage", "=", "ServiceManager", "::", "getInstance", "(", ")", "->", "getService", "(", "'Storage.'", ".", "$", "storage", ")", ";", "}", "$", "file", "=", "new", "File", "(", "$", "image", ",", "$", "storage", ")", ";", "return", "ImageLoader", "::", "load", "(", "$", "file", "->", "getContents", "(", ")", ")", ";", "}", "}" ]
Loads the image and returns an instance of Image class. @param string|File $image This can either be image file name that corresponds to File $key parameter, or it can be an instance of Webiny\Component\Storage\File\File. @param string|Storage $storage This can either be the name of the storage service or it can be an instance of Webiny\Component\Storage\Storage. NOTE: This parameter is not required if you pass the $image as instance of Webiny\Component\Storage\File\File. @return ImageInterface
[ "Loads", "the", "image", "and", "returns", "an", "instance", "of", "Image", "class", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Image/ImageTrait.php#L34-L47
230,286
Webiny/Framework
src/Webiny/Component/StdLib/ComponentTrait.php
ComponentTrait.getConfig
public static function getConfig() { if (!is_object(self::$componentConfig)) { $config = []; // check if we have default config if (isset(self::$defaultConfig)) { $config = self::$defaultConfig; } self::$componentConfig = new ConfigObject($config); } return self::$componentConfig; }
php
public static function getConfig() { if (!is_object(self::$componentConfig)) { $config = []; // check if we have default config if (isset(self::$defaultConfig)) { $config = self::$defaultConfig; } self::$componentConfig = new ConfigObject($config); } return self::$componentConfig; }
[ "public", "static", "function", "getConfig", "(", ")", "{", "if", "(", "!", "is_object", "(", "self", "::", "$", "componentConfig", ")", ")", "{", "$", "config", "=", "[", "]", ";", "// check if we have default config", "if", "(", "isset", "(", "self", "::", "$", "defaultConfig", ")", ")", "{", "$", "config", "=", "self", "::", "$", "defaultConfig", ";", "}", "self", "::", "$", "componentConfig", "=", "new", "ConfigObject", "(", "$", "config", ")", ";", "}", "return", "self", "::", "$", "componentConfig", ";", "}" ]
Returns the current component configuration. @return ConfigObject
[ "Returns", "the", "current", "component", "configuration", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/StdLib/ComponentTrait.php#L94-L107
230,287
Webiny/Framework
src/Webiny/Component/Bootstrap/Bootstrap.php
Bootstrap.runApplication
public function runApplication($appPath = '') { if ($appPath != '') { $rootPath = $appPath; } else { $rootPath = realpath(dirname(debug_backtrace()[0]['file']) . '/../'); } // save the root path $this->absolutePath = realpath($rootPath) . DIRECTORY_SEPARATOR; $this->initializeEnvironment($this->absolutePath); $this->initializeRouter(); }
php
public function runApplication($appPath = '') { if ($appPath != '') { $rootPath = $appPath; } else { $rootPath = realpath(dirname(debug_backtrace()[0]['file']) . '/../'); } // save the root path $this->absolutePath = realpath($rootPath) . DIRECTORY_SEPARATOR; $this->initializeEnvironment($this->absolutePath); $this->initializeRouter(); }
[ "public", "function", "runApplication", "(", "$", "appPath", "=", "''", ")", "{", "if", "(", "$", "appPath", "!=", "''", ")", "{", "$", "rootPath", "=", "$", "appPath", ";", "}", "else", "{", "$", "rootPath", "=", "realpath", "(", "dirname", "(", "debug_backtrace", "(", ")", "[", "0", "]", "[", "'file'", "]", ")", ".", "'/../'", ")", ";", "}", "// save the root path", "$", "this", "->", "absolutePath", "=", "realpath", "(", "$", "rootPath", ")", ".", "DIRECTORY_SEPARATOR", ";", "$", "this", "->", "initializeEnvironment", "(", "$", "this", "->", "absolutePath", ")", ";", "$", "this", "->", "initializeRouter", "(", ")", ";", "}" ]
Initializes the environment and the router. Router takes the process from there. @param string $appPath Path to the application root. @throws BootstrapException @throws \Exception
[ "Initializes", "the", "environment", "and", "the", "router", ".", "Router", "takes", "the", "process", "from", "there", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/Bootstrap.php#L46-L58
230,288
Webiny/Framework
src/Webiny/Component/Bootstrap/Bootstrap.php
Bootstrap.initializeEnvironment
public function initializeEnvironment($appPath) { try { // initialize the environment and its configurations $this->environment = Environment::getInstance(); $this->environment->initializeEnvironment($appPath); } catch (BootstrapException $e) { throw $e; } }
php
public function initializeEnvironment($appPath) { try { // initialize the environment and its configurations $this->environment = Environment::getInstance(); $this->environment->initializeEnvironment($appPath); } catch (BootstrapException $e) { throw $e; } }
[ "public", "function", "initializeEnvironment", "(", "$", "appPath", ")", "{", "try", "{", "// initialize the environment and its configurations", "$", "this", "->", "environment", "=", "Environment", "::", "getInstance", "(", ")", ";", "$", "this", "->", "environment", "->", "initializeEnvironment", "(", "$", "appPath", ")", ";", "}", "catch", "(", "BootstrapException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Initializes the application environment. @param string $appPath Path to the application root. @throws BootstrapException @throws \Exception
[ "Initializes", "the", "application", "environment", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/Bootstrap.php#L68-L77
230,289
Webiny/Framework
src/Webiny/Component/Bootstrap/Bootstrap.php
Bootstrap.initializeRouter
public function initializeRouter() { try { // initialize router $this->router = Router::getInstance(); // if a route is matched, a dispatcher instance is returned, and the callback is issued $this->router->initializeRouter()->issueCallback(); } catch (BootstrapException $e) { throw $e; } }
php
public function initializeRouter() { try { // initialize router $this->router = Router::getInstance(); // if a route is matched, a dispatcher instance is returned, and the callback is issued $this->router->initializeRouter()->issueCallback(); } catch (BootstrapException $e) { throw $e; } }
[ "public", "function", "initializeRouter", "(", ")", "{", "try", "{", "// initialize router", "$", "this", "->", "router", "=", "Router", "::", "getInstance", "(", ")", ";", "// if a route is matched, a dispatcher instance is returned, and the callback is issued", "$", "this", "->", "router", "->", "initializeRouter", "(", ")", "->", "issueCallback", "(", ")", ";", "}", "catch", "(", "BootstrapException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Initializes the router. @throws BootstrapException @throws \Exception
[ "Initializes", "the", "router", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/Bootstrap.php#L85-L96
230,290
Webiny/Framework
src/Webiny/Component/Mailer/Bridge/SwiftMailer/Transport.php
Transport.setDecorators
public function setDecorators(array $replacements) { $wrapper = $this->config->get('Decorators.Wrapper'); if ($wrapper) { foreach ($replacements as $email => $vars) { $decorators = []; foreach ($vars as $key => $value) { $key = $wrapper[0] . $key . $wrapper[1]; $decorators[$key] = $value; } $replacements[$email] = $decorators; } } $decoratorPlugin = new \Swift_Plugins_DecoratorPlugin($replacements); $this->mailer->registerPlugin($decoratorPlugin); return $this; }
php
public function setDecorators(array $replacements) { $wrapper = $this->config->get('Decorators.Wrapper'); if ($wrapper) { foreach ($replacements as $email => $vars) { $decorators = []; foreach ($vars as $key => $value) { $key = $wrapper[0] . $key . $wrapper[1]; $decorators[$key] = $value; } $replacements[$email] = $decorators; } } $decoratorPlugin = new \Swift_Plugins_DecoratorPlugin($replacements); $this->mailer->registerPlugin($decoratorPlugin); return $this; }
[ "public", "function", "setDecorators", "(", "array", "$", "replacements", ")", "{", "$", "wrapper", "=", "$", "this", "->", "config", "->", "get", "(", "'Decorators.Wrapper'", ")", ";", "if", "(", "$", "wrapper", ")", "{", "foreach", "(", "$", "replacements", "as", "$", "email", "=>", "$", "vars", ")", "{", "$", "decorators", "=", "[", "]", ";", "foreach", "(", "$", "vars", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "$", "wrapper", "[", "0", "]", ".", "$", "key", ".", "$", "wrapper", "[", "1", "]", ";", "$", "decorators", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "replacements", "[", "$", "email", "]", "=", "$", "decorators", ";", "}", "}", "$", "decoratorPlugin", "=", "new", "\\", "Swift_Plugins_DecoratorPlugin", "(", "$", "replacements", ")", ";", "$", "this", "->", "mailer", "->", "registerPlugin", "(", "$", "decoratorPlugin", ")", ";", "return", "$", "this", ";", "}" ]
Decorators are arrays that contain keys and values. The message body and subject will be scanned for the keys, and, where found, the key will be replaced with the value. @param array $replacements Array [email=> [key1=>value1, key2=>value2], email2=>[...]]. @return $this
[ "Decorators", "are", "arrays", "that", "contain", "keys", "and", "values", ".", "The", "message", "body", "and", "subject", "will", "be", "scanned", "for", "the", "keys", "and", "where", "found", "the", "key", "will", "be", "replaced", "with", "the", "value", "." ]
2ca7fb238999387e54a1eea8c5cb4735de9022a7
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Mailer/Bridge/SwiftMailer/Transport.php#L109-L127
230,291
deanblackborough/zf3-view-helpers
src/Bootstrap4Card.php
Bootstrap4Card.elementClasses
private function elementClasses(string $element) : string { if (in_array($element, $this->elements) === true) { $class = ''; if (count($this->classes[$element]) > 0) { $class = ' ' . implode(' ', $this->classes[$element]); } return $class; } else { return ''; } }
php
private function elementClasses(string $element) : string { if (in_array($element, $this->elements) === true) { $class = ''; if (count($this->classes[$element]) > 0) { $class = ' ' . implode(' ', $this->classes[$element]); } return $class; } else { return ''; } }
[ "private", "function", "elementClasses", "(", "string", "$", "element", ")", ":", "string", "{", "if", "(", "in_array", "(", "$", "element", ",", "$", "this", "->", "elements", ")", "===", "true", ")", "{", "$", "class", "=", "''", ";", "if", "(", "count", "(", "$", "this", "->", "classes", "[", "$", "element", "]", ")", ">", "0", ")", "{", "$", "class", "=", "' '", ".", "implode", "(", "' '", ",", "$", "this", "->", "classes", "[", "$", "element", "]", ")", ";", "}", "return", "$", "class", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Fetch the classes assigned to the given element @param string $element [card|body|header|footer] @return string
[ "Fetch", "the", "classes", "assigned", "to", "the", "given", "element" ]
db8bea4ca62709b2ac8c732aedbb2a5235223f23
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Card.php#L132-L145
230,292
deanblackborough/zf3-view-helpers
src/Bootstrap4Card.php
Bootstrap4Card.elementBodyClasses
private function elementBodyClasses(string $element) : string { if (in_array($element, $this->body_elements) === true) { $class = ''; if (count($this->body_classes[$element]) > 0) { if (array_key_exists($element, $this->body_classes_first) === false) { $class = ' ' . implode(' ', $this->body_classes[$element]); } else { $class = ''; foreach ($this->body_classes[$element] as $body_class) { if (array_key_exists($body_class, $this->body_classes_first[$element]) === false) { $class .= ' ' . $body_class; } else { if ($this->body_classes_first[$element][$body_class] === true) { $class .= ' ' . $body_class; $this->body_classes_first[$element][$body_class] = false; } } } } } return $class; } else { return ''; } }
php
private function elementBodyClasses(string $element) : string { if (in_array($element, $this->body_elements) === true) { $class = ''; if (count($this->body_classes[$element]) > 0) { if (array_key_exists($element, $this->body_classes_first) === false) { $class = ' ' . implode(' ', $this->body_classes[$element]); } else { $class = ''; foreach ($this->body_classes[$element] as $body_class) { if (array_key_exists($body_class, $this->body_classes_first[$element]) === false) { $class .= ' ' . $body_class; } else { if ($this->body_classes_first[$element][$body_class] === true) { $class .= ' ' . $body_class; $this->body_classes_first[$element][$body_class] = false; } } } } } return $class; } else { return ''; } }
[ "private", "function", "elementBodyClasses", "(", "string", "$", "element", ")", ":", "string", "{", "if", "(", "in_array", "(", "$", "element", ",", "$", "this", "->", "body_elements", ")", "===", "true", ")", "{", "$", "class", "=", "''", ";", "if", "(", "count", "(", "$", "this", "->", "body_classes", "[", "$", "element", "]", ")", ">", "0", ")", "{", "if", "(", "array_key_exists", "(", "$", "element", ",", "$", "this", "->", "body_classes_first", ")", "===", "false", ")", "{", "$", "class", "=", "' '", ".", "implode", "(", "' '", ",", "$", "this", "->", "body_classes", "[", "$", "element", "]", ")", ";", "}", "else", "{", "$", "class", "=", "''", ";", "foreach", "(", "$", "this", "->", "body_classes", "[", "$", "element", "]", "as", "$", "body_class", ")", "{", "if", "(", "array_key_exists", "(", "$", "body_class", ",", "$", "this", "->", "body_classes_first", "[", "$", "element", "]", ")", "===", "false", ")", "{", "$", "class", ".=", "' '", ".", "$", "body_class", ";", "}", "else", "{", "if", "(", "$", "this", "->", "body_classes_first", "[", "$", "element", "]", "[", "$", "body_class", "]", "===", "true", ")", "{", "$", "class", ".=", "' '", ".", "$", "body_class", ";", "$", "this", "->", "body_classes_first", "[", "$", "element", "]", "[", "$", "body_class", "]", "=", "false", ";", "}", "}", "}", "}", "}", "return", "$", "class", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Fetch the classes assigned to the given body element type @param string $element [title|subtitle|text|link] @return string
[ "Fetch", "the", "classes", "assigned", "to", "the", "given", "body", "element", "type" ]
db8bea4ca62709b2ac8c732aedbb2a5235223f23
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Card.php#L154-L181
230,293
deanblackborough/zf3-view-helpers
src/Bootstrap4Card.php
Bootstrap4Card.elementAttr
private function elementAttr(string $element) : string { if (in_array($element, $this->elements) === true) { $attr = ''; if (count($this->attr[$element]) > 0) { $attr = ' style="' . implode(' ', $this->attr[$element]) . '"'; } return $attr; } else { return ''; } }
php
private function elementAttr(string $element) : string { if (in_array($element, $this->elements) === true) { $attr = ''; if (count($this->attr[$element]) > 0) { $attr = ' style="' . implode(' ', $this->attr[$element]) . '"'; } return $attr; } else { return ''; } }
[ "private", "function", "elementAttr", "(", "string", "$", "element", ")", ":", "string", "{", "if", "(", "in_array", "(", "$", "element", ",", "$", "this", "->", "elements", ")", "===", "true", ")", "{", "$", "attr", "=", "''", ";", "if", "(", "count", "(", "$", "this", "->", "attr", "[", "$", "element", "]", ")", ">", "0", ")", "{", "$", "attr", "=", "' style=\"'", ".", "implode", "(", "' '", ",", "$", "this", "->", "attr", "[", "$", "element", "]", ")", ".", "'\"'", ";", "}", "return", "$", "attr", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Fetch the attributes assigned to the given element @param string $element [card|body|header|footer] @return string
[ "Fetch", "the", "attributes", "assigned", "to", "the", "given", "element" ]
db8bea4ca62709b2ac8c732aedbb2a5235223f23
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Card.php#L190-L203
230,294
deanblackborough/zf3-view-helpers
src/Bootstrap4Card.php
Bootstrap4Card.elementBodyAttr
private function elementBodyAttr(string $element) : string { if (in_array($element, $this->body_elements) === true) { $attr = ''; if (count($this->body_attr[$element]) > 0) { if (array_key_exists($element, $this->body_attr_first) === false) { $attr = ' style="' . implode(' ', $this->body_attr[$element]) . '"'; } else { $attr = ' style="'; foreach ($this->body_attr[$element] as $body_attr) { if (array_key_exists($body_attr, $this->body_attr_first[$element]) === false) { $attr .= ' ' . $body_attr . ';'; } else { if ($this->body_attr_first[$element][$body_attr] === true) { $attr .= ' ' . $body_attr . ';'; $this->body_attr_first[$element][$body_attr] = false; } } } $attr .= '"'; } } return $attr; } else { return ''; } }
php
private function elementBodyAttr(string $element) : string { if (in_array($element, $this->body_elements) === true) { $attr = ''; if (count($this->body_attr[$element]) > 0) { if (array_key_exists($element, $this->body_attr_first) === false) { $attr = ' style="' . implode(' ', $this->body_attr[$element]) . '"'; } else { $attr = ' style="'; foreach ($this->body_attr[$element] as $body_attr) { if (array_key_exists($body_attr, $this->body_attr_first[$element]) === false) { $attr .= ' ' . $body_attr . ';'; } else { if ($this->body_attr_first[$element][$body_attr] === true) { $attr .= ' ' . $body_attr . ';'; $this->body_attr_first[$element][$body_attr] = false; } } } $attr .= '"'; } } return $attr; } else { return ''; } }
[ "private", "function", "elementBodyAttr", "(", "string", "$", "element", ")", ":", "string", "{", "if", "(", "in_array", "(", "$", "element", ",", "$", "this", "->", "body_elements", ")", "===", "true", ")", "{", "$", "attr", "=", "''", ";", "if", "(", "count", "(", "$", "this", "->", "body_attr", "[", "$", "element", "]", ")", ">", "0", ")", "{", "if", "(", "array_key_exists", "(", "$", "element", ",", "$", "this", "->", "body_attr_first", ")", "===", "false", ")", "{", "$", "attr", "=", "' style=\"'", ".", "implode", "(", "' '", ",", "$", "this", "->", "body_attr", "[", "$", "element", "]", ")", ".", "'\"'", ";", "}", "else", "{", "$", "attr", "=", "' style=\"'", ";", "foreach", "(", "$", "this", "->", "body_attr", "[", "$", "element", "]", "as", "$", "body_attr", ")", "{", "if", "(", "array_key_exists", "(", "$", "body_attr", ",", "$", "this", "->", "body_attr_first", "[", "$", "element", "]", ")", "===", "false", ")", "{", "$", "attr", ".=", "' '", ".", "$", "body_attr", ".", "';'", ";", "}", "else", "{", "if", "(", "$", "this", "->", "body_attr_first", "[", "$", "element", "]", "[", "$", "body_attr", "]", "===", "true", ")", "{", "$", "attr", ".=", "' '", ".", "$", "body_attr", ".", "';'", ";", "$", "this", "->", "body_attr_first", "[", "$", "element", "]", "[", "$", "body_attr", "]", "=", "false", ";", "}", "}", "}", "$", "attr", ".=", "'\"'", ";", "}", "}", "return", "$", "attr", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Fetch the attributes assigned to the given body element type @param string $element [title|subtitle|text|link] @return string
[ "Fetch", "the", "attributes", "assigned", "to", "the", "given", "body", "element", "type" ]
db8bea4ca62709b2ac8c732aedbb2a5235223f23
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Card.php#L212-L240
230,295
deanblackborough/zf3-view-helpers
src/Bootstrap4Card.php
Bootstrap4Card.cardBody
private function cardBody() : string { if (count($this->body_sections) === 0) { if ($this->body !== null) { $body = $this->body; } else { $body = '<p>No card body content defined, no calls to setBody() or setBodyContent().</p>'; } } else { $body = $this->cardBodyHtml(); } return '<div class="card-body' . $this->elementClasses('body') . '"' . $this->elementAttr('body') . '>' . $body . '</div>'; }
php
private function cardBody() : string { if (count($this->body_sections) === 0) { if ($this->body !== null) { $body = $this->body; } else { $body = '<p>No card body content defined, no calls to setBody() or setBodyContent().</p>'; } } else { $body = $this->cardBodyHtml(); } return '<div class="card-body' . $this->elementClasses('body') . '"' . $this->elementAttr('body') . '>' . $body . '</div>'; }
[ "private", "function", "cardBody", "(", ")", ":", "string", "{", "if", "(", "count", "(", "$", "this", "->", "body_sections", ")", "===", "0", ")", "{", "if", "(", "$", "this", "->", "body", "!==", "null", ")", "{", "$", "body", "=", "$", "this", "->", "body", ";", "}", "else", "{", "$", "body", "=", "'<p>No card body content defined, no calls to setBody() or setBodyContent().</p>'", ";", "}", "}", "else", "{", "$", "body", "=", "$", "this", "->", "cardBodyHtml", "(", ")", ";", "}", "return", "'<div class=\"card-body'", ".", "$", "this", "->", "elementClasses", "(", "'body'", ")", ".", "'\"'", ".", "$", "this", "->", "elementAttr", "(", "'body'", ")", ".", "'>'", ".", "$", "body", ".", "'</div>'", ";", "}" ]
Generate the card body, checks to see if any section have been defined first, if not, check for a complete body @return string
[ "Generate", "the", "card", "body", "checks", "to", "see", "if", "any", "section", "have", "been", "defined", "first", "if", "not", "check", "for", "a", "complete", "body" ]
db8bea4ca62709b2ac8c732aedbb2a5235223f23
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Card.php#L248-L262
230,296
deanblackborough/zf3-view-helpers
src/Bootstrap4Card.php
Bootstrap4Card.cardBodyHtml
private function cardBodyHtml() : string { $html = ''; foreach ($this->body_sections as $section) { switch ($section['type']) { case 'title': $html .= '<' . $section['tag'] . ' class="card-title' . $this->elementBodyClasses('title') . '"' . $this->elementBodyAttr('title') . '>' . $section['content'] . '</' . $section['tag'] . '>'; break; case 'subtitle': $html .= '<' . $section['tag'] . ' class="card-subtitle' . $this->elementBodyClasses('subtitle') . '"' . $this->elementBodyAttr('subtitle') . '>' . $section['content'] . '</' . $section['tag'] . '>'; break; case 'text': $html .= '<p class="card-text' . $this->elementBodyClasses('text') . '"' . $this->elementBodyAttr('text') . '>' . $section['content'] . '</p>'; break; case 'link': $html .= '<a href="' . $section['uri'] . '" class="' . $this->elementBodyClasses('link') . '"' . $this->elementBodyAttr('link') . '>' . $section['content'] . '</a>'; break; default: // Do nothing break; } } return $html; }
php
private function cardBodyHtml() : string { $html = ''; foreach ($this->body_sections as $section) { switch ($section['type']) { case 'title': $html .= '<' . $section['tag'] . ' class="card-title' . $this->elementBodyClasses('title') . '"' . $this->elementBodyAttr('title') . '>' . $section['content'] . '</' . $section['tag'] . '>'; break; case 'subtitle': $html .= '<' . $section['tag'] . ' class="card-subtitle' . $this->elementBodyClasses('subtitle') . '"' . $this->elementBodyAttr('subtitle') . '>' . $section['content'] . '</' . $section['tag'] . '>'; break; case 'text': $html .= '<p class="card-text' . $this->elementBodyClasses('text') . '"' . $this->elementBodyAttr('text') . '>' . $section['content'] . '</p>'; break; case 'link': $html .= '<a href="' . $section['uri'] . '" class="' . $this->elementBodyClasses('link') . '"' . $this->elementBodyAttr('link') . '>' . $section['content'] . '</a>'; break; default: // Do nothing break; } } return $html; }
[ "private", "function", "cardBodyHtml", "(", ")", ":", "string", "{", "$", "html", "=", "''", ";", "foreach", "(", "$", "this", "->", "body_sections", "as", "$", "section", ")", "{", "switch", "(", "$", "section", "[", "'type'", "]", ")", "{", "case", "'title'", ":", "$", "html", ".=", "'<'", ".", "$", "section", "[", "'tag'", "]", ".", "' class=\"card-title'", ".", "$", "this", "->", "elementBodyClasses", "(", "'title'", ")", ".", "'\"'", ".", "$", "this", "->", "elementBodyAttr", "(", "'title'", ")", ".", "'>'", ".", "$", "section", "[", "'content'", "]", ".", "'</'", ".", "$", "section", "[", "'tag'", "]", ".", "'>'", ";", "break", ";", "case", "'subtitle'", ":", "$", "html", ".=", "'<'", ".", "$", "section", "[", "'tag'", "]", ".", "' class=\"card-subtitle'", ".", "$", "this", "->", "elementBodyClasses", "(", "'subtitle'", ")", ".", "'\"'", ".", "$", "this", "->", "elementBodyAttr", "(", "'subtitle'", ")", ".", "'>'", ".", "$", "section", "[", "'content'", "]", ".", "'</'", ".", "$", "section", "[", "'tag'", "]", ".", "'>'", ";", "break", ";", "case", "'text'", ":", "$", "html", ".=", "'<p class=\"card-text'", ".", "$", "this", "->", "elementBodyClasses", "(", "'text'", ")", ".", "'\"'", ".", "$", "this", "->", "elementBodyAttr", "(", "'text'", ")", ".", "'>'", ".", "$", "section", "[", "'content'", "]", ".", "'</p>'", ";", "break", ";", "case", "'link'", ":", "$", "html", ".=", "'<a href=\"'", ".", "$", "section", "[", "'uri'", "]", ".", "'\" class=\"'", ".", "$", "this", "->", "elementBodyClasses", "(", "'link'", ")", ".", "'\"'", ".", "$", "this", "->", "elementBodyAttr", "(", "'link'", ")", ".", "'>'", ".", "$", "section", "[", "'content'", "]", ".", "'</a>'", ";", "break", ";", "default", ":", "// Do nothing", "break", ";", "}", "}", "return", "$", "html", ";", "}" ]
Generate and return the body content HTML by looping through the set body sections @return string
[ "Generate", "and", "return", "the", "body", "content", "HTML", "by", "looping", "through", "the", "set", "body", "sections" ]
db8bea4ca62709b2ac8c732aedbb2a5235223f23
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Card.php#L269-L307
230,297
deanblackborough/zf3-view-helpers
src/Bootstrap4Card.php
Bootstrap4Card.cardHeader
private function cardHeader() : string { $html = ''; if ($this->header !== null) { $html .= '<div class="card-header' . $this->elementAttr('header') . '"' . $this->elementAttr('header') . '>' . $this->header . '</div>'; } return $html; }
php
private function cardHeader() : string { $html = ''; if ($this->header !== null) { $html .= '<div class="card-header' . $this->elementAttr('header') . '"' . $this->elementAttr('header') . '>' . $this->header . '</div>'; } return $html; }
[ "private", "function", "cardHeader", "(", ")", ":", "string", "{", "$", "html", "=", "''", ";", "if", "(", "$", "this", "->", "header", "!==", "null", ")", "{", "$", "html", ".=", "'<div class=\"card-header'", ".", "$", "this", "->", "elementAttr", "(", "'header'", ")", ".", "'\"'", ".", "$", "this", "->", "elementAttr", "(", "'header'", ")", ".", "'>'", ".", "$", "this", "->", "header", ".", "'</div>'", ";", "}", "return", "$", "html", ";", "}" ]
Generate the card header @return string
[ "Generate", "the", "card", "header" ]
db8bea4ca62709b2ac8c732aedbb2a5235223f23
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Card.php#L314-L324
230,298
deanblackborough/zf3-view-helpers
src/Bootstrap4Card.php
Bootstrap4Card.cardFooter
private function cardFooter() : string { $html = ''; if ($this->footer !== null) { $html .= '<div class="card-footer' . $this->elementAttr('footer') . '"' . $this->elementAttr('header') . '>' . $this->footer . '</div>'; } return $html; }
php
private function cardFooter() : string { $html = ''; if ($this->footer !== null) { $html .= '<div class="card-footer' . $this->elementAttr('footer') . '"' . $this->elementAttr('header') . '>' . $this->footer . '</div>'; } return $html; }
[ "private", "function", "cardFooter", "(", ")", ":", "string", "{", "$", "html", "=", "''", ";", "if", "(", "$", "this", "->", "footer", "!==", "null", ")", "{", "$", "html", ".=", "'<div class=\"card-footer'", ".", "$", "this", "->", "elementAttr", "(", "'footer'", ")", ".", "'\"'", ".", "$", "this", "->", "elementAttr", "(", "'header'", ")", ".", "'>'", ".", "$", "this", "->", "footer", ".", "'</div>'", ";", "}", "return", "$", "html", ";", "}" ]
Generate the card footer @return string
[ "Generate", "the", "card", "footer" ]
db8bea4ca62709b2ac8c732aedbb2a5235223f23
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Card.php#L331-L341
230,299
deanblackborough/zf3-view-helpers
src/Bootstrap4Card.php
Bootstrap4Card.addCustomClass
public function addCustomClass(string $class, string $element) : Bootstrap4Card { if (in_array($element, $this->elements) === true) { $this->classes[$element][] = $class; } return $this; }
php
public function addCustomClass(string $class, string $element) : Bootstrap4Card { if (in_array($element, $this->elements) === true) { $this->classes[$element][] = $class; } return $this; }
[ "public", "function", "addCustomClass", "(", "string", "$", "class", ",", "string", "$", "element", ")", ":", "Bootstrap4Card", "{", "if", "(", "in_array", "(", "$", "element", ",", "$", "this", "->", "elements", ")", "===", "true", ")", "{", "$", "this", "->", "classes", "[", "$", "element", "]", "[", "]", "=", "$", "class", ";", "}", "return", "$", "this", ";", "}" ]
Add a custom class to a card element Silently errors, if the element is invalid the attribute is not assigned to the classes array @param string $class Class to assign to element @param string $element Element to attach the class to [card|body|header|footer] @return Bootstrap4Card
[ "Add", "a", "custom", "class", "to", "a", "card", "element" ]
db8bea4ca62709b2ac8c732aedbb2a5235223f23
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Card.php#L369-L376