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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
7,600
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader.unregisterNamespace
public function unregisterNamespace($namespace) { if (is_string($namespace)) { $namespace = (array) $namespace; } elseif (!is_array($namespace)) { throw new Zend_Loader_Exception('Invalid namespace provided'); } foreach ($namespace as $ns) { if (isset($this->_namespaces[$ns])) { unset($this->_namespaces[$ns]); } } return $this; }
php
public function unregisterNamespace($namespace) { if (is_string($namespace)) { $namespace = (array) $namespace; } elseif (!is_array($namespace)) { throw new Zend_Loader_Exception('Invalid namespace provided'); } foreach ($namespace as $ns) { if (isset($this->_namespaces[$ns])) { unset($this->_namespaces[$ns]); } } return $this; }
[ "public", "function", "unregisterNamespace", "(", "$", "namespace", ")", "{", "if", "(", "is_string", "(", "$", "namespace", ")", ")", "{", "$", "namespace", "=", "(", "array", ")", "$", "namespace", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "namespace", ")", ")", "{", "throw", "new", "Zend_Loader_Exception", "(", "'Invalid namespace provided'", ")", ";", "}", "foreach", "(", "$", "namespace", "as", "$", "ns", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_namespaces", "[", "$", "ns", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "_namespaces", "[", "$", "ns", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Unload a registered autoload namespace @param string|array $namespace @return Zend_Loader_Autoloader
[ "Unload", "a", "registered", "autoload", "namespace" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L228-L242
7,601
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader.suppressNotFoundWarnings
public function suppressNotFoundWarnings($flag = null) { if (null === $flag) { return $this->_suppressNotFoundWarnings; } $this->_suppressNotFoundWarnings = (bool) $flag; return $this; }
php
public function suppressNotFoundWarnings($flag = null) { if (null === $flag) { return $this->_suppressNotFoundWarnings; } $this->_suppressNotFoundWarnings = (bool) $flag; return $this; }
[ "public", "function", "suppressNotFoundWarnings", "(", "$", "flag", "=", "null", ")", "{", "if", "(", "null", "===", "$", "flag", ")", "{", "return", "$", "this", "->", "_suppressNotFoundWarnings", ";", "}", "$", "this", "->", "_suppressNotFoundWarnings", "=", "(", "bool", ")", "$", "flag", ";", "return", "$", "this", ";", "}" ]
Get or set the value of the "suppress not found warnings" flag @param null|bool $flag @return bool|Zend_Loader_Autoloader Returns boolean if no argument is passed, object instance otherwise
[ "Get", "or", "set", "the", "value", "of", "the", "suppress", "not", "found", "warnings", "flag" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L286-L293
7,602
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader.getClassAutoloaders
public function getClassAutoloaders($class) { $namespace = false; $autoloaders = array(); // Add concrete namespaced autoloaders foreach (array_keys($this->_namespaceAutoloaders) as $ns) { if ('' == $ns) { continue; } if (0 === strpos($class, $ns)) { if ((false === $namespace) || (strlen($ns) > strlen($namespace))) { $namespace = $ns; $autoloaders = $this->getNamespaceAutoloaders($ns); } } } // Add internal namespaced autoloader foreach ($this->getRegisteredNamespaces() as $ns) { if (0 === strpos($class, $ns)) { $namespace = $ns; $autoloaders[] = $this->_internalAutoloader; break; } } // Add non-namespaced autoloaders $autoloadersNonNamespace = $this->getNamespaceAutoloaders(''); if (count($autoloadersNonNamespace)) { foreach ($autoloadersNonNamespace as $ns) { $autoloaders[] = $ns; } unset($autoloadersNonNamespace); } // Add fallback autoloader if (!$namespace && $this->isFallbackAutoloader()) { $autoloaders[] = $this->_internalAutoloader; } return $autoloaders; }
php
public function getClassAutoloaders($class) { $namespace = false; $autoloaders = array(); // Add concrete namespaced autoloaders foreach (array_keys($this->_namespaceAutoloaders) as $ns) { if ('' == $ns) { continue; } if (0 === strpos($class, $ns)) { if ((false === $namespace) || (strlen($ns) > strlen($namespace))) { $namespace = $ns; $autoloaders = $this->getNamespaceAutoloaders($ns); } } } // Add internal namespaced autoloader foreach ($this->getRegisteredNamespaces() as $ns) { if (0 === strpos($class, $ns)) { $namespace = $ns; $autoloaders[] = $this->_internalAutoloader; break; } } // Add non-namespaced autoloaders $autoloadersNonNamespace = $this->getNamespaceAutoloaders(''); if (count($autoloadersNonNamespace)) { foreach ($autoloadersNonNamespace as $ns) { $autoloaders[] = $ns; } unset($autoloadersNonNamespace); } // Add fallback autoloader if (!$namespace && $this->isFallbackAutoloader()) { $autoloaders[] = $this->_internalAutoloader; } return $autoloaders; }
[ "public", "function", "getClassAutoloaders", "(", "$", "class", ")", "{", "$", "namespace", "=", "false", ";", "$", "autoloaders", "=", "array", "(", ")", ";", "// Add concrete namespaced autoloaders", "foreach", "(", "array_keys", "(", "$", "this", "->", "_namespaceAutoloaders", ")", "as", "$", "ns", ")", "{", "if", "(", "''", "==", "$", "ns", ")", "{", "continue", ";", "}", "if", "(", "0", "===", "strpos", "(", "$", "class", ",", "$", "ns", ")", ")", "{", "if", "(", "(", "false", "===", "$", "namespace", ")", "||", "(", "strlen", "(", "$", "ns", ")", ">", "strlen", "(", "$", "namespace", ")", ")", ")", "{", "$", "namespace", "=", "$", "ns", ";", "$", "autoloaders", "=", "$", "this", "->", "getNamespaceAutoloaders", "(", "$", "ns", ")", ";", "}", "}", "}", "// Add internal namespaced autoloader", "foreach", "(", "$", "this", "->", "getRegisteredNamespaces", "(", ")", "as", "$", "ns", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "class", ",", "$", "ns", ")", ")", "{", "$", "namespace", "=", "$", "ns", ";", "$", "autoloaders", "[", "]", "=", "$", "this", "->", "_internalAutoloader", ";", "break", ";", "}", "}", "// Add non-namespaced autoloaders", "$", "autoloadersNonNamespace", "=", "$", "this", "->", "getNamespaceAutoloaders", "(", "''", ")", ";", "if", "(", "count", "(", "$", "autoloadersNonNamespace", ")", ")", "{", "foreach", "(", "$", "autoloadersNonNamespace", "as", "$", "ns", ")", "{", "$", "autoloaders", "[", "]", "=", "$", "ns", ";", "}", "unset", "(", "$", "autoloadersNonNamespace", ")", ";", "}", "// Add fallback autoloader", "if", "(", "!", "$", "namespace", "&&", "$", "this", "->", "isFallbackAutoloader", "(", ")", ")", "{", "$", "autoloaders", "[", "]", "=", "$", "this", "->", "_internalAutoloader", ";", "}", "return", "$", "autoloaders", ";", "}" ]
Get autoloaders to use when matching class Determines if the class matches a registered namespace, and, if so, returns only the autoloaders for that namespace. Otherwise, it returns all non-namespaced autoloaders. @param string $class @return array Array of autoloaders to use
[ "Get", "autoloaders", "to", "use", "when", "matching", "class" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L327-L369
7,603
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader.unshiftAutoloader
public function unshiftAutoloader($callback, $namespace = '') { $autoloaders = $this->getAutoloaders(); array_unshift($autoloaders, $callback); $this->setAutoloaders($autoloaders); $namespace = (array) $namespace; foreach ($namespace as $ns) { $autoloaders = $this->getNamespaceAutoloaders($ns); array_unshift($autoloaders, $callback); $this->_setNamespaceAutoloaders($autoloaders, $ns); } return $this; }
php
public function unshiftAutoloader($callback, $namespace = '') { $autoloaders = $this->getAutoloaders(); array_unshift($autoloaders, $callback); $this->setAutoloaders($autoloaders); $namespace = (array) $namespace; foreach ($namespace as $ns) { $autoloaders = $this->getNamespaceAutoloaders($ns); array_unshift($autoloaders, $callback); $this->_setNamespaceAutoloaders($autoloaders, $ns); } return $this; }
[ "public", "function", "unshiftAutoloader", "(", "$", "callback", ",", "$", "namespace", "=", "''", ")", "{", "$", "autoloaders", "=", "$", "this", "->", "getAutoloaders", "(", ")", ";", "array_unshift", "(", "$", "autoloaders", ",", "$", "callback", ")", ";", "$", "this", "->", "setAutoloaders", "(", "$", "autoloaders", ")", ";", "$", "namespace", "=", "(", "array", ")", "$", "namespace", ";", "foreach", "(", "$", "namespace", "as", "$", "ns", ")", "{", "$", "autoloaders", "=", "$", "this", "->", "getNamespaceAutoloaders", "(", "$", "ns", ")", ";", "array_unshift", "(", "$", "autoloaders", ",", "$", "callback", ")", ";", "$", "this", "->", "_setNamespaceAutoloaders", "(", "$", "autoloaders", ",", "$", "ns", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add an autoloader to the beginning of the stack @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation @param string|array $namespace Specific namespace(s) under which to register callback @return Zend_Loader_Autoloader
[ "Add", "an", "autoloader", "to", "the", "beginning", "of", "the", "stack" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L378-L392
7,604
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader.pushAutoloader
public function pushAutoloader($callback, $namespace = '') { $autoloaders = $this->getAutoloaders(); array_push($autoloaders, $callback); $this->setAutoloaders($autoloaders); $namespace = (array) $namespace; foreach ($namespace as $ns) { $autoloaders = $this->getNamespaceAutoloaders($ns); array_push($autoloaders, $callback); $this->_setNamespaceAutoloaders($autoloaders, $ns); } return $this; }
php
public function pushAutoloader($callback, $namespace = '') { $autoloaders = $this->getAutoloaders(); array_push($autoloaders, $callback); $this->setAutoloaders($autoloaders); $namespace = (array) $namespace; foreach ($namespace as $ns) { $autoloaders = $this->getNamespaceAutoloaders($ns); array_push($autoloaders, $callback); $this->_setNamespaceAutoloaders($autoloaders, $ns); } return $this; }
[ "public", "function", "pushAutoloader", "(", "$", "callback", ",", "$", "namespace", "=", "''", ")", "{", "$", "autoloaders", "=", "$", "this", "->", "getAutoloaders", "(", ")", ";", "array_push", "(", "$", "autoloaders", ",", "$", "callback", ")", ";", "$", "this", "->", "setAutoloaders", "(", "$", "autoloaders", ")", ";", "$", "namespace", "=", "(", "array", ")", "$", "namespace", ";", "foreach", "(", "$", "namespace", "as", "$", "ns", ")", "{", "$", "autoloaders", "=", "$", "this", "->", "getNamespaceAutoloaders", "(", "$", "ns", ")", ";", "array_push", "(", "$", "autoloaders", ",", "$", "callback", ")", ";", "$", "this", "->", "_setNamespaceAutoloaders", "(", "$", "autoloaders", ",", "$", "ns", ")", ";", "}", "return", "$", "this", ";", "}" ]
Append an autoloader to the autoloader stack @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation @param string|array $namespace Specific namespace(s) under which to register callback @return Zend_Loader_Autoloader
[ "Append", "an", "autoloader", "to", "the", "autoloader", "stack" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L401-L415
7,605
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader.removeAutoloader
public function removeAutoloader($callback, $namespace = null) { if (null === $namespace) { $autoloaders = $this->getAutoloaders(); if (false !== ($index = array_search($callback, $autoloaders, true))) { unset($autoloaders[$index]); $this->setAutoloaders($autoloaders); } foreach ($this->_namespaceAutoloaders as $ns => $autoloaders) { if (false !== ($index = array_search($callback, $autoloaders, true))) { unset($autoloaders[$index]); $this->_setNamespaceAutoloaders($autoloaders, $ns); } } } else { $namespace = (array) $namespace; foreach ($namespace as $ns) { $autoloaders = $this->getNamespaceAutoloaders($ns); if (false !== ($index = array_search($callback, $autoloaders, true))) { unset($autoloaders[$index]); $this->_setNamespaceAutoloaders($autoloaders, $ns); } } } return $this; }
php
public function removeAutoloader($callback, $namespace = null) { if (null === $namespace) { $autoloaders = $this->getAutoloaders(); if (false !== ($index = array_search($callback, $autoloaders, true))) { unset($autoloaders[$index]); $this->setAutoloaders($autoloaders); } foreach ($this->_namespaceAutoloaders as $ns => $autoloaders) { if (false !== ($index = array_search($callback, $autoloaders, true))) { unset($autoloaders[$index]); $this->_setNamespaceAutoloaders($autoloaders, $ns); } } } else { $namespace = (array) $namespace; foreach ($namespace as $ns) { $autoloaders = $this->getNamespaceAutoloaders($ns); if (false !== ($index = array_search($callback, $autoloaders, true))) { unset($autoloaders[$index]); $this->_setNamespaceAutoloaders($autoloaders, $ns); } } } return $this; }
[ "public", "function", "removeAutoloader", "(", "$", "callback", ",", "$", "namespace", "=", "null", ")", "{", "if", "(", "null", "===", "$", "namespace", ")", "{", "$", "autoloaders", "=", "$", "this", "->", "getAutoloaders", "(", ")", ";", "if", "(", "false", "!==", "(", "$", "index", "=", "array_search", "(", "$", "callback", ",", "$", "autoloaders", ",", "true", ")", ")", ")", "{", "unset", "(", "$", "autoloaders", "[", "$", "index", "]", ")", ";", "$", "this", "->", "setAutoloaders", "(", "$", "autoloaders", ")", ";", "}", "foreach", "(", "$", "this", "->", "_namespaceAutoloaders", "as", "$", "ns", "=>", "$", "autoloaders", ")", "{", "if", "(", "false", "!==", "(", "$", "index", "=", "array_search", "(", "$", "callback", ",", "$", "autoloaders", ",", "true", ")", ")", ")", "{", "unset", "(", "$", "autoloaders", "[", "$", "index", "]", ")", ";", "$", "this", "->", "_setNamespaceAutoloaders", "(", "$", "autoloaders", ",", "$", "ns", ")", ";", "}", "}", "}", "else", "{", "$", "namespace", "=", "(", "array", ")", "$", "namespace", ";", "foreach", "(", "$", "namespace", "as", "$", "ns", ")", "{", "$", "autoloaders", "=", "$", "this", "->", "getNamespaceAutoloaders", "(", "$", "ns", ")", ";", "if", "(", "false", "!==", "(", "$", "index", "=", "array_search", "(", "$", "callback", ",", "$", "autoloaders", ",", "true", ")", ")", ")", "{", "unset", "(", "$", "autoloaders", "[", "$", "index", "]", ")", ";", "$", "this", "->", "_setNamespaceAutoloaders", "(", "$", "autoloaders", ",", "$", "ns", ")", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Remove an autoloader from the autoloader stack @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation @param null|string|array $namespace Specific namespace(s) from which to remove autoloader @return Zend_Loader_Autoloader
[ "Remove", "an", "autoloader", "from", "the", "autoloader", "stack" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L424-L451
7,606
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader._autoload
protected function _autoload($class) { $callback = $this->getDefaultAutoloader(); try { if ($this->suppressNotFoundWarnings()) { @call_user_func($callback, $class); } else { call_user_func($callback, $class); } return $class; } catch (Zend_Exception $e) { return false; } }
php
protected function _autoload($class) { $callback = $this->getDefaultAutoloader(); try { if ($this->suppressNotFoundWarnings()) { @call_user_func($callback, $class); } else { call_user_func($callback, $class); } return $class; } catch (Zend_Exception $e) { return false; } }
[ "protected", "function", "_autoload", "(", "$", "class", ")", "{", "$", "callback", "=", "$", "this", "->", "getDefaultAutoloader", "(", ")", ";", "try", "{", "if", "(", "$", "this", "->", "suppressNotFoundWarnings", "(", ")", ")", "{", "@", "call_user_func", "(", "$", "callback", ",", "$", "class", ")", ";", "}", "else", "{", "call_user_func", "(", "$", "callback", ",", "$", "class", ")", ";", "}", "return", "$", "class", ";", "}", "catch", "(", "Zend_Exception", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Internal autoloader implementation @param string $class @return bool
[ "Internal", "autoloader", "implementation" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L472-L485
7,607
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader._getVersionPath
protected function _getVersionPath($path, $version) { $type = $this->_getVersionType($version); if ($type == 'latest') { $version = 'latest'; } $availableVersions = $this->_getAvailableVersions($path, $version); if (empty($availableVersions)) { throw new Zend_Loader_Exception('No valid ZF installations discovered'); } $matchedVersion = array_pop($availableVersions); return $matchedVersion; }
php
protected function _getVersionPath($path, $version) { $type = $this->_getVersionType($version); if ($type == 'latest') { $version = 'latest'; } $availableVersions = $this->_getAvailableVersions($path, $version); if (empty($availableVersions)) { throw new Zend_Loader_Exception('No valid ZF installations discovered'); } $matchedVersion = array_pop($availableVersions); return $matchedVersion; }
[ "protected", "function", "_getVersionPath", "(", "$", "path", ",", "$", "version", ")", "{", "$", "type", "=", "$", "this", "->", "_getVersionType", "(", "$", "version", ")", ";", "if", "(", "$", "type", "==", "'latest'", ")", "{", "$", "version", "=", "'latest'", ";", "}", "$", "availableVersions", "=", "$", "this", "->", "_getAvailableVersions", "(", "$", "path", ",", "$", "version", ")", ";", "if", "(", "empty", "(", "$", "availableVersions", ")", ")", "{", "throw", "new", "Zend_Loader_Exception", "(", "'No valid ZF installations discovered'", ")", ";", "}", "$", "matchedVersion", "=", "array_pop", "(", "$", "availableVersions", ")", ";", "return", "$", "matchedVersion", ";", "}" ]
Retrieve the filesystem path for the requested ZF version @param string $path @param string $version @return void
[ "Retrieve", "the", "filesystem", "path", "for", "the", "requested", "ZF", "version" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L508-L523
7,608
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader._getVersionType
protected function _getVersionType($version) { if (strtolower($version) == 'latest') { return 'latest'; } $parts = explode('.', $version); $count = count($parts); if (1 == $count) { return 'major'; } if (2 == $count) { return 'minor'; } if (3 < $count) { throw new Zend_Loader_Exception('Invalid version string provided'); } return 'specific'; }
php
protected function _getVersionType($version) { if (strtolower($version) == 'latest') { return 'latest'; } $parts = explode('.', $version); $count = count($parts); if (1 == $count) { return 'major'; } if (2 == $count) { return 'minor'; } if (3 < $count) { throw new Zend_Loader_Exception('Invalid version string provided'); } return 'specific'; }
[ "protected", "function", "_getVersionType", "(", "$", "version", ")", "{", "if", "(", "strtolower", "(", "$", "version", ")", "==", "'latest'", ")", "{", "return", "'latest'", ";", "}", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "version", ")", ";", "$", "count", "=", "count", "(", "$", "parts", ")", ";", "if", "(", "1", "==", "$", "count", ")", "{", "return", "'major'", ";", "}", "if", "(", "2", "==", "$", "count", ")", "{", "return", "'minor'", ";", "}", "if", "(", "3", "<", "$", "count", ")", "{", "throw", "new", "Zend_Loader_Exception", "(", "'Invalid version string provided'", ")", ";", "}", "return", "'specific'", ";", "}" ]
Retrieve the ZF version type @param string $version @return string "latest", "major", "minor", or "specific" @throws Zend_Loader_Exception if version string contains too many dots
[ "Retrieve", "the", "ZF", "version", "type" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L532-L550
7,609
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader._getAvailableVersions
protected function _getAvailableVersions($path, $version) { if (!is_dir($path)) { throw new Zend_Loader_Exception('Invalid ZF path provided'); } $path = rtrim($path, '/'); $path = rtrim($path, '\\'); $versionLen = strlen($version); $versions = array(); $dirs = glob("$path/*", GLOB_ONLYDIR); foreach ((array) $dirs as $dir) { $dirName = substr($dir, strlen($path) + 1); if (!preg_match('/^(?:ZendFramework-)?(\d+\.\d+\.\d+((a|b|pl|pr|p|rc)\d+)?)(?:-minimal)?$/i', $dirName, $matches)) { continue; } $matchedVersion = $matches[1]; if (('latest' == $version) || ((strlen($matchedVersion) >= $versionLen) && (0 === strpos($matchedVersion, $version))) ) { $versions[$matchedVersion] = $dir . '/library'; } } uksort($versions, 'version_compare'); return $versions; }
php
protected function _getAvailableVersions($path, $version) { if (!is_dir($path)) { throw new Zend_Loader_Exception('Invalid ZF path provided'); } $path = rtrim($path, '/'); $path = rtrim($path, '\\'); $versionLen = strlen($version); $versions = array(); $dirs = glob("$path/*", GLOB_ONLYDIR); foreach ((array) $dirs as $dir) { $dirName = substr($dir, strlen($path) + 1); if (!preg_match('/^(?:ZendFramework-)?(\d+\.\d+\.\d+((a|b|pl|pr|p|rc)\d+)?)(?:-minimal)?$/i', $dirName, $matches)) { continue; } $matchedVersion = $matches[1]; if (('latest' == $version) || ((strlen($matchedVersion) >= $versionLen) && (0 === strpos($matchedVersion, $version))) ) { $versions[$matchedVersion] = $dir . '/library'; } } uksort($versions, 'version_compare'); return $versions; }
[ "protected", "function", "_getAvailableVersions", "(", "$", "path", ",", "$", "version", ")", "{", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "throw", "new", "Zend_Loader_Exception", "(", "'Invalid ZF path provided'", ")", ";", "}", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'\\\\'", ")", ";", "$", "versionLen", "=", "strlen", "(", "$", "version", ")", ";", "$", "versions", "=", "array", "(", ")", ";", "$", "dirs", "=", "glob", "(", "\"$path/*\"", ",", "GLOB_ONLYDIR", ")", ";", "foreach", "(", "(", "array", ")", "$", "dirs", "as", "$", "dir", ")", "{", "$", "dirName", "=", "substr", "(", "$", "dir", ",", "strlen", "(", "$", "path", ")", "+", "1", ")", ";", "if", "(", "!", "preg_match", "(", "'/^(?:ZendFramework-)?(\\d+\\.\\d+\\.\\d+((a|b|pl|pr|p|rc)\\d+)?)(?:-minimal)?$/i'", ",", "$", "dirName", ",", "$", "matches", ")", ")", "{", "continue", ";", "}", "$", "matchedVersion", "=", "$", "matches", "[", "1", "]", ";", "if", "(", "(", "'latest'", "==", "$", "version", ")", "||", "(", "(", "strlen", "(", "$", "matchedVersion", ")", ">=", "$", "versionLen", ")", "&&", "(", "0", "===", "strpos", "(", "$", "matchedVersion", ",", "$", "version", ")", ")", ")", ")", "{", "$", "versions", "[", "$", "matchedVersion", "]", "=", "$", "dir", ".", "'/library'", ";", "}", "}", "uksort", "(", "$", "versions", ",", "'version_compare'", ")", ";", "return", "$", "versions", ";", "}" ]
Get available versions for the version type requested @param string $path @param string $version @return array
[ "Get", "available", "versions", "for", "the", "version", "type", "requested" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L559-L588
7,610
wollanup/php-api-rest
src/Entity/EntityFactory.php
EntityFactory.create
public function create( EntityFactoryConfig $config, ServerRequestInterface $request, ResponseInterface $response, callable $next ): ResponseInterface { $entityRequest = $config->createEntityRequest($request, $this->container); # make a new empty record $obj = $entityRequest->instantiateActiveRecord(); # Execute beforeCreate hook, which can alter record $entityRequest->beforeCreate($obj, $request); # Then, alter object with allowed properties if ($config->isHydrateEntityFromRequest()) { $requestParams = $request->getQueryParams(); $postParams = $request->getParsedBody(); if ($postParams) { $requestParams = array_merge($requestParams, (array)$postParams); } /** @noinspection PhpUndefinedMethodInspection */ $obj->fromArray($entityRequest->getAllowedDataFromRequest($requestParams, $request->getMethod())); } # Execute afterCreate hook, which can alter record $entityRequest->afterCreate($obj, $request); $request = $request->withAttribute($config->getParameterToInjectInto(), $obj); /** @var Response $response */ return $next($request, $response); }
php
public function create( EntityFactoryConfig $config, ServerRequestInterface $request, ResponseInterface $response, callable $next ): ResponseInterface { $entityRequest = $config->createEntityRequest($request, $this->container); # make a new empty record $obj = $entityRequest->instantiateActiveRecord(); # Execute beforeCreate hook, which can alter record $entityRequest->beforeCreate($obj, $request); # Then, alter object with allowed properties if ($config->isHydrateEntityFromRequest()) { $requestParams = $request->getQueryParams(); $postParams = $request->getParsedBody(); if ($postParams) { $requestParams = array_merge($requestParams, (array)$postParams); } /** @noinspection PhpUndefinedMethodInspection */ $obj->fromArray($entityRequest->getAllowedDataFromRequest($requestParams, $request->getMethod())); } # Execute afterCreate hook, which can alter record $entityRequest->afterCreate($obj, $request); $request = $request->withAttribute($config->getParameterToInjectInto(), $obj); /** @var Response $response */ return $next($request, $response); }
[ "public", "function", "create", "(", "EntityFactoryConfig", "$", "config", ",", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "callable", "$", "next", ")", ":", "ResponseInterface", "{", "$", "entityRequest", "=", "$", "config", "->", "createEntityRequest", "(", "$", "request", ",", "$", "this", "->", "container", ")", ";", "# make a new empty record", "$", "obj", "=", "$", "entityRequest", "->", "instantiateActiveRecord", "(", ")", ";", "# Execute beforeCreate hook, which can alter record", "$", "entityRequest", "->", "beforeCreate", "(", "$", "obj", ",", "$", "request", ")", ";", "# Then, alter object with allowed properties", "if", "(", "$", "config", "->", "isHydrateEntityFromRequest", "(", ")", ")", "{", "$", "requestParams", "=", "$", "request", "->", "getQueryParams", "(", ")", ";", "$", "postParams", "=", "$", "request", "->", "getParsedBody", "(", ")", ";", "if", "(", "$", "postParams", ")", "{", "$", "requestParams", "=", "array_merge", "(", "$", "requestParams", ",", "(", "array", ")", "$", "postParams", ")", ";", "}", "/** @noinspection PhpUndefinedMethodInspection */", "$", "obj", "->", "fromArray", "(", "$", "entityRequest", "->", "getAllowedDataFromRequest", "(", "$", "requestParams", ",", "$", "request", "->", "getMethod", "(", ")", ")", ")", ";", "}", "# Execute afterCreate hook, which can alter record", "$", "entityRequest", "->", "afterCreate", "(", "$", "obj", ",", "$", "request", ")", ";", "$", "request", "=", "$", "request", "->", "withAttribute", "(", "$", "config", "->", "getParameterToInjectInto", "(", ")", ",", "$", "obj", ")", ";", "/** @var Response $response */", "return", "$", "next", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
Create a new instance of activeRecord and add it to Request attributes @param EntityFactoryConfig $config @param ServerRequestInterface $request @param ResponseInterface $response @param callable $next @return ResponseInterface
[ "Create", "a", "new", "instance", "of", "activeRecord", "and", "add", "it", "to", "Request", "attributes" ]
185eac8a8412e5997d8e292ebd0e38787ae4b949
https://github.com/wollanup/php-api-rest/blob/185eac8a8412e5997d8e292ebd0e38787ae4b949/src/Entity/EntityFactory.php#L46-L78
7,611
wollanup/php-api-rest
src/Entity/EntityFactory.php
EntityFactory.fetch
public function fetch( EntityFactoryConfig $config, ServerRequestInterface $request, ResponseInterface $response, callable $next ): ResponseInterface { $entityRequest = $config->createEntityRequest($request, $this->container); # First, we try to determine PK in request path (most common case) if (isset($request->getAttribute('routeInfo')[2][$config->getRequestParameterName()])) { $entityRequest->setPrimaryKey($request->getAttribute('routeInfo')[2][$config->getRequestParameterName()]); } # Next, we create the query (ModelCriteria), based on Action class (which can alter the query) $query = $this->getQueryFromActiveRecordRequest($entityRequest); # Execute beforeFetch hook, which can enforce primary key $query = $entityRequest->beforeFetch($query, $request); # Now get the primary key in its final form $pk = $entityRequest->getPrimaryKey(); if (null === $pk) { $handler = $entityRequest->getContainer()->getEntityRequestErrorHandler(); return $handler->primaryKeyNotFound($entityRequest, $request, $response); } # Then, fetch object $obj = $query->findPk($pk); if ($obj === null) { $handler = $entityRequest->getContainer()->getEntityRequestErrorHandler(); return $handler->entityNotFound($entityRequest, $request, $response); } # Get request params if ($config->isHydrateEntityFromRequest()) { $params = $request->getQueryParams(); $postParams = $request->getParsedBody(); if ($postParams) { $params = array_merge($params, (array)$postParams); } # Then, alter object with allowed properties $obj->fromArray($entityRequest->getAllowedDataFromRequest($params, $request->getMethod())); } # Then, execute afterFetch hook, which can alter the object $entityRequest->afterFetch($obj, $request); $request = $request->withAttribute($config->getParameterToInjectInto(), $obj); return $next($request, $response); }
php
public function fetch( EntityFactoryConfig $config, ServerRequestInterface $request, ResponseInterface $response, callable $next ): ResponseInterface { $entityRequest = $config->createEntityRequest($request, $this->container); # First, we try to determine PK in request path (most common case) if (isset($request->getAttribute('routeInfo')[2][$config->getRequestParameterName()])) { $entityRequest->setPrimaryKey($request->getAttribute('routeInfo')[2][$config->getRequestParameterName()]); } # Next, we create the query (ModelCriteria), based on Action class (which can alter the query) $query = $this->getQueryFromActiveRecordRequest($entityRequest); # Execute beforeFetch hook, which can enforce primary key $query = $entityRequest->beforeFetch($query, $request); # Now get the primary key in its final form $pk = $entityRequest->getPrimaryKey(); if (null === $pk) { $handler = $entityRequest->getContainer()->getEntityRequestErrorHandler(); return $handler->primaryKeyNotFound($entityRequest, $request, $response); } # Then, fetch object $obj = $query->findPk($pk); if ($obj === null) { $handler = $entityRequest->getContainer()->getEntityRequestErrorHandler(); return $handler->entityNotFound($entityRequest, $request, $response); } # Get request params if ($config->isHydrateEntityFromRequest()) { $params = $request->getQueryParams(); $postParams = $request->getParsedBody(); if ($postParams) { $params = array_merge($params, (array)$postParams); } # Then, alter object with allowed properties $obj->fromArray($entityRequest->getAllowedDataFromRequest($params, $request->getMethod())); } # Then, execute afterFetch hook, which can alter the object $entityRequest->afterFetch($obj, $request); $request = $request->withAttribute($config->getParameterToInjectInto(), $obj); return $next($request, $response); }
[ "public", "function", "fetch", "(", "EntityFactoryConfig", "$", "config", ",", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "callable", "$", "next", ")", ":", "ResponseInterface", "{", "$", "entityRequest", "=", "$", "config", "->", "createEntityRequest", "(", "$", "request", ",", "$", "this", "->", "container", ")", ";", "# First, we try to determine PK in request path (most common case)", "if", "(", "isset", "(", "$", "request", "->", "getAttribute", "(", "'routeInfo'", ")", "[", "2", "]", "[", "$", "config", "->", "getRequestParameterName", "(", ")", "]", ")", ")", "{", "$", "entityRequest", "->", "setPrimaryKey", "(", "$", "request", "->", "getAttribute", "(", "'routeInfo'", ")", "[", "2", "]", "[", "$", "config", "->", "getRequestParameterName", "(", ")", "]", ")", ";", "}", "# Next, we create the query (ModelCriteria), based on Action class (which can alter the query)", "$", "query", "=", "$", "this", "->", "getQueryFromActiveRecordRequest", "(", "$", "entityRequest", ")", ";", "# Execute beforeFetch hook, which can enforce primary key", "$", "query", "=", "$", "entityRequest", "->", "beforeFetch", "(", "$", "query", ",", "$", "request", ")", ";", "# Now get the primary key in its final form", "$", "pk", "=", "$", "entityRequest", "->", "getPrimaryKey", "(", ")", ";", "if", "(", "null", "===", "$", "pk", ")", "{", "$", "handler", "=", "$", "entityRequest", "->", "getContainer", "(", ")", "->", "getEntityRequestErrorHandler", "(", ")", ";", "return", "$", "handler", "->", "primaryKeyNotFound", "(", "$", "entityRequest", ",", "$", "request", ",", "$", "response", ")", ";", "}", "# Then, fetch object", "$", "obj", "=", "$", "query", "->", "findPk", "(", "$", "pk", ")", ";", "if", "(", "$", "obj", "===", "null", ")", "{", "$", "handler", "=", "$", "entityRequest", "->", "getContainer", "(", ")", "->", "getEntityRequestErrorHandler", "(", ")", ";", "return", "$", "handler", "->", "entityNotFound", "(", "$", "entityRequest", ",", "$", "request", ",", "$", "response", ")", ";", "}", "# Get request params", "if", "(", "$", "config", "->", "isHydrateEntityFromRequest", "(", ")", ")", "{", "$", "params", "=", "$", "request", "->", "getQueryParams", "(", ")", ";", "$", "postParams", "=", "$", "request", "->", "getParsedBody", "(", ")", ";", "if", "(", "$", "postParams", ")", "{", "$", "params", "=", "array_merge", "(", "$", "params", ",", "(", "array", ")", "$", "postParams", ")", ";", "}", "# Then, alter object with allowed properties", "$", "obj", "->", "fromArray", "(", "$", "entityRequest", "->", "getAllowedDataFromRequest", "(", "$", "params", ",", "$", "request", "->", "getMethod", "(", ")", ")", ")", ";", "}", "# Then, execute afterFetch hook, which can alter the object", "$", "entityRequest", "->", "afterFetch", "(", "$", "obj", ",", "$", "request", ")", ";", "$", "request", "=", "$", "request", "->", "withAttribute", "(", "$", "config", "->", "getParameterToInjectInto", "(", ")", ",", "$", "obj", ")", ";", "return", "$", "next", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
Fetch an existing instance of activeRecord and add it to Request attributes @param EntityFactoryConfig $config @param ServerRequestInterface $request @param ResponseInterface $response @param callable $next @return ResponseInterface
[ "Fetch", "an", "existing", "instance", "of", "activeRecord", "and", "add", "it", "to", "Request", "attributes" ]
185eac8a8412e5997d8e292ebd0e38787ae4b949
https://github.com/wollanup/php-api-rest/blob/185eac8a8412e5997d8e292ebd0e38787ae4b949/src/Entity/EntityFactory.php#L90-L145
7,612
wollanup/php-api-rest
src/Entity/EntityFactory.php
EntityFactory.fetchCollection
public function fetchCollection( EntityRequestInterface $entityRequest, ServerRequestInterface $request, ResponseInterface $response, callable $next, $nameOfParameterToAdd = null ): ResponseInterface { $pks = []; if ($request->getMethod() === 'GET') { # GET : Try to find PKs in query $params = $request->getQueryParams(); if (array_key_exists('id', $params)) { $pks = $params['id']; } } else { # POST/PATCH : Try to find PKs in body if (is_array($request->getParsedBody())) { $finder = new PksFinder(['id']); $pks = $finder->find($request->getParsedBody()); } } # Next, we create the query (ModelCriteria), based on Action class (which can alter the query) $query = $this->getQueryFromActiveRecordRequest($entityRequest); if (empty($pks)) { $handler = $entityRequest->getContainer() ->getEntityRequestErrorHandler(); return $handler->primaryKeyNotFound($entityRequest, $request, $response); } # Then, fetch object $col = $query->findPks($pks); if ($col === null) { $handler = $entityRequest->getContainer() ->getEntityRequestErrorHandler(); return $handler->entityNotFound($entityRequest, $request, $response); } # Finally, build name of parameter to inject in action method, will be used later if ($nameOfParameterToAdd === null) { $nameOfParameterToAdd = $entityRequest->getNameOfParameterToAdd(true); } $request = $request->withAttribute($nameOfParameterToAdd, $col); return $next($request, $response); }
php
public function fetchCollection( EntityRequestInterface $entityRequest, ServerRequestInterface $request, ResponseInterface $response, callable $next, $nameOfParameterToAdd = null ): ResponseInterface { $pks = []; if ($request->getMethod() === 'GET') { # GET : Try to find PKs in query $params = $request->getQueryParams(); if (array_key_exists('id', $params)) { $pks = $params['id']; } } else { # POST/PATCH : Try to find PKs in body if (is_array($request->getParsedBody())) { $finder = new PksFinder(['id']); $pks = $finder->find($request->getParsedBody()); } } # Next, we create the query (ModelCriteria), based on Action class (which can alter the query) $query = $this->getQueryFromActiveRecordRequest($entityRequest); if (empty($pks)) { $handler = $entityRequest->getContainer() ->getEntityRequestErrorHandler(); return $handler->primaryKeyNotFound($entityRequest, $request, $response); } # Then, fetch object $col = $query->findPks($pks); if ($col === null) { $handler = $entityRequest->getContainer() ->getEntityRequestErrorHandler(); return $handler->entityNotFound($entityRequest, $request, $response); } # Finally, build name of parameter to inject in action method, will be used later if ($nameOfParameterToAdd === null) { $nameOfParameterToAdd = $entityRequest->getNameOfParameterToAdd(true); } $request = $request->withAttribute($nameOfParameterToAdd, $col); return $next($request, $response); }
[ "public", "function", "fetchCollection", "(", "EntityRequestInterface", "$", "entityRequest", ",", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "callable", "$", "next", ",", "$", "nameOfParameterToAdd", "=", "null", ")", ":", "ResponseInterface", "{", "$", "pks", "=", "[", "]", ";", "if", "(", "$", "request", "->", "getMethod", "(", ")", "===", "'GET'", ")", "{", "# GET : Try to find PKs in query", "$", "params", "=", "$", "request", "->", "getQueryParams", "(", ")", ";", "if", "(", "array_key_exists", "(", "'id'", ",", "$", "params", ")", ")", "{", "$", "pks", "=", "$", "params", "[", "'id'", "]", ";", "}", "}", "else", "{", "# POST/PATCH : Try to find PKs in body", "if", "(", "is_array", "(", "$", "request", "->", "getParsedBody", "(", ")", ")", ")", "{", "$", "finder", "=", "new", "PksFinder", "(", "[", "'id'", "]", ")", ";", "$", "pks", "=", "$", "finder", "->", "find", "(", "$", "request", "->", "getParsedBody", "(", ")", ")", ";", "}", "}", "# Next, we create the query (ModelCriteria), based on Action class (which can alter the query)", "$", "query", "=", "$", "this", "->", "getQueryFromActiveRecordRequest", "(", "$", "entityRequest", ")", ";", "if", "(", "empty", "(", "$", "pks", ")", ")", "{", "$", "handler", "=", "$", "entityRequest", "->", "getContainer", "(", ")", "->", "getEntityRequestErrorHandler", "(", ")", ";", "return", "$", "handler", "->", "primaryKeyNotFound", "(", "$", "entityRequest", ",", "$", "request", ",", "$", "response", ")", ";", "}", "# Then, fetch object", "$", "col", "=", "$", "query", "->", "findPks", "(", "$", "pks", ")", ";", "if", "(", "$", "col", "===", "null", ")", "{", "$", "handler", "=", "$", "entityRequest", "->", "getContainer", "(", ")", "->", "getEntityRequestErrorHandler", "(", ")", ";", "return", "$", "handler", "->", "entityNotFound", "(", "$", "entityRequest", ",", "$", "request", ",", "$", "response", ")", ";", "}", "# Finally, build name of parameter to inject in action method, will be used later", "if", "(", "$", "nameOfParameterToAdd", "===", "null", ")", "{", "$", "nameOfParameterToAdd", "=", "$", "entityRequest", "->", "getNameOfParameterToAdd", "(", "true", ")", ";", "}", "$", "request", "=", "$", "request", "->", "withAttribute", "(", "$", "nameOfParameterToAdd", ",", "$", "col", ")", ";", "return", "$", "next", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
Fetch an existing collection of activeRecords and add it to Request attributes @param EntityRequestInterface $entityRequest @param ServerRequestInterface $request @param ResponseInterface $response @param callable $next @param $nameOfParameterToAdd @return ResponseInterface @throws PropelException
[ "Fetch", "an", "existing", "collection", "of", "activeRecords", "and", "add", "it", "to", "Request", "attributes" ]
185eac8a8412e5997d8e292ebd0e38787ae4b949
https://github.com/wollanup/php-api-rest/blob/185eac8a8412e5997d8e292ebd0e38787ae4b949/src/Entity/EntityFactory.php#L159-L212
7,613
mszewcz/php-light-framework
src/Html/Form/Form.php
Form.addElement
public function addElement(Element $element): Element { if ($element instanceof FormStatus) { if ($this->hasStatus === true) { throw new InvalidArgumentException('Form can contain only one FormStatus element'); } $this->hasStatus = true; } return parent::addElement($element); }
php
public function addElement(Element $element): Element { if ($element instanceof FormStatus) { if ($this->hasStatus === true) { throw new InvalidArgumentException('Form can contain only one FormStatus element'); } $this->hasStatus = true; } return parent::addElement($element); }
[ "public", "function", "addElement", "(", "Element", "$", "element", ")", ":", "Element", "{", "if", "(", "$", "element", "instanceof", "FormStatus", ")", "{", "if", "(", "$", "this", "->", "hasStatus", "===", "true", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Form can contain only one FormStatus element'", ")", ";", "}", "$", "this", "->", "hasStatus", "=", "true", ";", "}", "return", "parent", "::", "addElement", "(", "$", "element", ")", ";", "}" ]
Adds element to composite. Throws InvalidArgumentException if more than one FormStatus element is added. @param Element $element @return Element
[ "Adds", "element", "to", "composite", ".", "Throws", "InvalidArgumentException", "if", "more", "than", "one", "FormStatus", "element", "is", "added", "." ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Form/Form.php#L65-L74
7,614
mszewcz/php-light-framework
src/Html/Form/Form.php
Form.generate
public function generate(): string { $elements = []; foreach ($this->hiddens as $hidden) { $elements[] = $hidden; } foreach ($this->elements as $element) { /** @noinspection PhpUndefinedMethodInspection */ $elements[] = $element->generate(); } return Tags::form($elements, $this->attributes); }
php
public function generate(): string { $elements = []; foreach ($this->hiddens as $hidden) { $elements[] = $hidden; } foreach ($this->elements as $element) { /** @noinspection PhpUndefinedMethodInspection */ $elements[] = $element->generate(); } return Tags::form($elements, $this->attributes); }
[ "public", "function", "generate", "(", ")", ":", "string", "{", "$", "elements", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "hiddens", "as", "$", "hidden", ")", "{", "$", "elements", "[", "]", "=", "$", "hidden", ";", "}", "foreach", "(", "$", "this", "->", "elements", "as", "$", "element", ")", "{", "/** @noinspection PhpUndefinedMethodInspection */", "$", "elements", "[", "]", "=", "$", "element", "->", "generate", "(", ")", ";", "}", "return", "Tags", "::", "form", "(", "$", "elements", ",", "$", "this", "->", "attributes", ")", ";", "}" ]
Generates from and returns it @return string
[ "Generates", "from", "and", "returns", "it" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Form/Form.php#L81-L92
7,615
zepi/turbo-base
Zepi/Web/General/Module.php
Module.getDataObjectBackend
protected function getDataObjectBackend($dataFileName) { $path = $this->framework->getRootDirectory() . '/data/' . $dataFileName; $objectBackend = new \Zepi\Turbo\Backend\FileObjectBackend($path); return $objectBackend; }
php
protected function getDataObjectBackend($dataFileName) { $path = $this->framework->getRootDirectory() . '/data/' . $dataFileName; $objectBackend = new \Zepi\Turbo\Backend\FileObjectBackend($path); return $objectBackend; }
[ "protected", "function", "getDataObjectBackend", "(", "$", "dataFileName", ")", "{", "$", "path", "=", "$", "this", "->", "framework", "->", "getRootDirectory", "(", ")", ".", "'/data/'", ".", "$", "dataFileName", ";", "$", "objectBackend", "=", "new", "\\", "Zepi", "\\", "Turbo", "\\", "Backend", "\\", "FileObjectBackend", "(", "$", "path", ")", ";", "return", "$", "objectBackend", ";", "}" ]
Returns a data object backend for the given file name @param string $dataFileName @return \Zepi\Turbo\Backend\FileObjectBackend
[ "Returns", "a", "data", "object", "backend", "for", "the", "given", "file", "name" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/Module.php#L151-L157
7,616
clusterpoint/php-client-api
response.class.php
CPS_Response.getRawDocuments
public function getRawDocuments($returnType) { if ($returnType == DOC_TYPE_ARRAY) { $res = array(); foreach ($this->_documents as $key => $value) { $res[$key] = CPS_Response::simpleXmlToArray($value); } return $res; } else if ($returnType == DOC_TYPE_STDCLASS) { $res = array(); foreach ($this->_documents as $key => $value) { $res[$key] = CPS_Response::simpleXmlToStdClass($value); } return $res; } return $this->_documents; }
php
public function getRawDocuments($returnType) { if ($returnType == DOC_TYPE_ARRAY) { $res = array(); foreach ($this->_documents as $key => $value) { $res[$key] = CPS_Response::simpleXmlToArray($value); } return $res; } else if ($returnType == DOC_TYPE_STDCLASS) { $res = array(); foreach ($this->_documents as $key => $value) { $res[$key] = CPS_Response::simpleXmlToStdClass($value); } return $res; } return $this->_documents; }
[ "public", "function", "getRawDocuments", "(", "$", "returnType", ")", "{", "if", "(", "$", "returnType", "==", "DOC_TYPE_ARRAY", ")", "{", "$", "res", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_documents", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "res", "[", "$", "key", "]", "=", "CPS_Response", "::", "simpleXmlToArray", "(", "$", "value", ")", ";", "}", "return", "$", "res", ";", "}", "else", "if", "(", "$", "returnType", "==", "DOC_TYPE_STDCLASS", ")", "{", "$", "res", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_documents", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "res", "[", "$", "key", "]", "=", "CPS_Response", "::", "simpleXmlToStdClass", "(", "$", "value", ")", ";", "}", "return", "$", "res", ";", "}", "return", "$", "this", "->", "_documents", ";", "}" ]
Returns the documents from the response @return array
[ "Returns", "the", "documents", "from", "the", "response" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/response.class.php#L289-L305
7,617
clusterpoint/php-client-api
response.class.php
CPS_Response.getRawAggregate
public function getRawAggregate($returnType) { if ($returnType == DOC_TYPE_ARRAY) { $res = array(); foreach ($this->_aggregate as $key => $value) { if ($value) { $tmp = CPS_Response::simpleXmlToArray($value); // multiple or one result - returned data format should be the same! if (isset($tmp['data'][0])) { // multiple results $res[$key] = $tmp['data']; } else { // one result $res[$key][] = $tmp['data']; } unset($tmp); } else { $res[$key] = array(); } } return $res; } else if ($returnType == DOC_TYPE_STDCLASS) { $res = array(); foreach ($this->_aggregate as $key => $value) { if ($value) { $tmp = CPS_Response::simpleXmlToStdClass($value); $res[$key] = $tmp->data; unset($tmp); } else { $res[$key] = new stdClass(); } } return $res; } return $this->_aggregate; }
php
public function getRawAggregate($returnType) { if ($returnType == DOC_TYPE_ARRAY) { $res = array(); foreach ($this->_aggregate as $key => $value) { if ($value) { $tmp = CPS_Response::simpleXmlToArray($value); // multiple or one result - returned data format should be the same! if (isset($tmp['data'][0])) { // multiple results $res[$key] = $tmp['data']; } else { // one result $res[$key][] = $tmp['data']; } unset($tmp); } else { $res[$key] = array(); } } return $res; } else if ($returnType == DOC_TYPE_STDCLASS) { $res = array(); foreach ($this->_aggregate as $key => $value) { if ($value) { $tmp = CPS_Response::simpleXmlToStdClass($value); $res[$key] = $tmp->data; unset($tmp); } else { $res[$key] = new stdClass(); } } return $res; } return $this->_aggregate; }
[ "public", "function", "getRawAggregate", "(", "$", "returnType", ")", "{", "if", "(", "$", "returnType", "==", "DOC_TYPE_ARRAY", ")", "{", "$", "res", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_aggregate", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "tmp", "=", "CPS_Response", "::", "simpleXmlToArray", "(", "$", "value", ")", ";", "// multiple or one result - returned data format should be the same!", "if", "(", "isset", "(", "$", "tmp", "[", "'data'", "]", "[", "0", "]", ")", ")", "{", "// multiple results", "$", "res", "[", "$", "key", "]", "=", "$", "tmp", "[", "'data'", "]", ";", "}", "else", "{", "// one result", "$", "res", "[", "$", "key", "]", "[", "]", "=", "$", "tmp", "[", "'data'", "]", ";", "}", "unset", "(", "$", "tmp", ")", ";", "}", "else", "{", "$", "res", "[", "$", "key", "]", "=", "array", "(", ")", ";", "}", "}", "return", "$", "res", ";", "}", "else", "if", "(", "$", "returnType", "==", "DOC_TYPE_STDCLASS", ")", "{", "$", "res", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_aggregate", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "tmp", "=", "CPS_Response", "::", "simpleXmlToStdClass", "(", "$", "value", ")", ";", "$", "res", "[", "$", "key", "]", "=", "$", "tmp", "->", "data", ";", "unset", "(", "$", "tmp", ")", ";", "}", "else", "{", "$", "res", "[", "$", "key", "]", "=", "new", "stdClass", "(", ")", ";", "}", "}", "return", "$", "res", ";", "}", "return", "$", "this", "->", "_aggregate", ";", "}" ]
Returns the aggregate data from the response @return array
[ "Returns", "the", "aggregate", "data", "from", "the", "response" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/response.class.php#L320-L355
7,618
clusterpoint/php-client-api
response.class.php
CPS_Response.getParam
public function getParam($name) { //if (in_array($name, self::$_textParamNames)) { if (in_array($name, $this->_textParamNames)) { return $this->_textParams[$name]; } else { throw new CPS_Exception(array(array('long_message' => 'Invalid response parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API'))); } }
php
public function getParam($name) { //if (in_array($name, self::$_textParamNames)) { if (in_array($name, $this->_textParamNames)) { return $this->_textParams[$name]; } else { throw new CPS_Exception(array(array('long_message' => 'Invalid response parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API'))); } }
[ "public", "function", "getParam", "(", "$", "name", ")", "{", "//if (in_array($name, self::$_textParamNames)) {", "if", "(", "in_array", "(", "$", "name", ",", "$", "this", "->", "_textParamNames", ")", ")", "{", "return", "$", "this", "->", "_textParams", "[", "$", "name", "]", ";", "}", "else", "{", "throw", "new", "CPS_Exception", "(", "array", "(", "array", "(", "'long_message'", "=>", "'Invalid response parameter'", ",", "'code'", "=>", "ERROR_CODE_INVALID_PARAMETER", ",", "'level'", "=>", "'REJECTED'", ",", "'source'", "=>", "'CPS_API'", ")", ")", ")", ";", "}", "}" ]
Returns a response parameter @param $name parameter name @return string
[ "Returns", "a", "response", "parameter" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/response.class.php#L380-L388
7,619
clusterpoint/php-client-api
response.class.php
CPS_Response.simpleXmlToArrayHelper
static function simpleXmlToArrayHelper(&$res, &$key, &$value, &$children) { if (isset($res[$key])) { if (is_string($res[$key]) || (is_array($res[$key]) && is_assoc($res[$key]))) { $res[$key] = array($res[$key]); } $res[$key][] = CPS_Response::simpleXmlToArray($value); } else { $res[$key] = CPS_Response::simpleXmlToArray($value); } $children = true; }
php
static function simpleXmlToArrayHelper(&$res, &$key, &$value, &$children) { if (isset($res[$key])) { if (is_string($res[$key]) || (is_array($res[$key]) && is_assoc($res[$key]))) { $res[$key] = array($res[$key]); } $res[$key][] = CPS_Response::simpleXmlToArray($value); } else { $res[$key] = CPS_Response::simpleXmlToArray($value); } $children = true; }
[ "static", "function", "simpleXmlToArrayHelper", "(", "&", "$", "res", ",", "&", "$", "key", ",", "&", "$", "value", ",", "&", "$", "children", ")", "{", "if", "(", "isset", "(", "$", "res", "[", "$", "key", "]", ")", ")", "{", "if", "(", "is_string", "(", "$", "res", "[", "$", "key", "]", ")", "||", "(", "is_array", "(", "$", "res", "[", "$", "key", "]", ")", "&&", "is_assoc", "(", "$", "res", "[", "$", "key", "]", ")", ")", ")", "{", "$", "res", "[", "$", "key", "]", "=", "array", "(", "$", "res", "[", "$", "key", "]", ")", ";", "}", "$", "res", "[", "$", "key", "]", "[", "]", "=", "CPS_Response", "::", "simpleXmlToArray", "(", "$", "value", ")", ";", "}", "else", "{", "$", "res", "[", "$", "key", "]", "=", "CPS_Response", "::", "simpleXmlToArray", "(", "$", "value", ")", ";", "}", "$", "children", "=", "true", ";", "}" ]
Helper function for conversions. Used internally.
[ "Helper", "function", "for", "conversions", ".", "Used", "internally", "." ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/response.class.php#L406-L417
7,620
clusterpoint/php-client-api
response.class.php
CPS_Response.simpleXmlToArray
static function simpleXmlToArray(SimpleXMLElement &$source) { $res = array(); $children = false; foreach ($source as $key => $value) { CPS_Response::simpleXmlToArrayHelper($res, $key, $value, $children); } if ($source) { foreach ($source->children('www.clusterpoint.com') as $key => $value) { $newkey = 'cps:' . $key; CPS_Response::simpleXmlToArrayHelper($res, $newkey, $value, $children); } } if (!$children) return (string)$source; return $res; }
php
static function simpleXmlToArray(SimpleXMLElement &$source) { $res = array(); $children = false; foreach ($source as $key => $value) { CPS_Response::simpleXmlToArrayHelper($res, $key, $value, $children); } if ($source) { foreach ($source->children('www.clusterpoint.com') as $key => $value) { $newkey = 'cps:' . $key; CPS_Response::simpleXmlToArrayHelper($res, $newkey, $value, $children); } } if (!$children) return (string)$source; return $res; }
[ "static", "function", "simpleXmlToArray", "(", "SimpleXMLElement", "&", "$", "source", ")", "{", "$", "res", "=", "array", "(", ")", ";", "$", "children", "=", "false", ";", "foreach", "(", "$", "source", "as", "$", "key", "=>", "$", "value", ")", "{", "CPS_Response", "::", "simpleXmlToArrayHelper", "(", "$", "res", ",", "$", "key", ",", "$", "value", ",", "$", "children", ")", ";", "}", "if", "(", "$", "source", ")", "{", "foreach", "(", "$", "source", "->", "children", "(", "'www.clusterpoint.com'", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "newkey", "=", "'cps:'", ".", "$", "key", ";", "CPS_Response", "::", "simpleXmlToArrayHelper", "(", "$", "res", ",", "$", "newkey", ",", "$", "value", ",", "$", "children", ")", ";", "}", "}", "if", "(", "!", "$", "children", ")", "return", "(", "string", ")", "$", "source", ";", "return", "$", "res", ";", "}" ]
Converts SimpleXMLElement to an array
[ "Converts", "SimpleXMLElement", "to", "an", "array" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/response.class.php#L422-L438
7,621
clusterpoint/php-client-api
response.class.php
CPS_Response.simpleXmlToStdClass
static function simpleXmlToStdClass(SimpleXMLElement &$source) { $res = new StdClass; $children = false; foreach ($source as $key => $value) { if (isset($res->$key)) { if (!is_array($res->$key)) { $res->$key = array($res->$key); } $ref = &$res->$key; $ref[] = CPS_Response::simpleXmlToStdClass($value); } else { $res->$key = CPS_Response::simpleXmlToStdClass($value); } $children = true; } if (!$children) return (string)$source; return $res; }
php
static function simpleXmlToStdClass(SimpleXMLElement &$source) { $res = new StdClass; $children = false; foreach ($source as $key => $value) { if (isset($res->$key)) { if (!is_array($res->$key)) { $res->$key = array($res->$key); } $ref = &$res->$key; $ref[] = CPS_Response::simpleXmlToStdClass($value); } else { $res->$key = CPS_Response::simpleXmlToStdClass($value); } $children = true; } if (!$children) return (string)$source; return $res; }
[ "static", "function", "simpleXmlToStdClass", "(", "SimpleXMLElement", "&", "$", "source", ")", "{", "$", "res", "=", "new", "StdClass", ";", "$", "children", "=", "false", ";", "foreach", "(", "$", "source", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "res", "->", "$", "key", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "res", "->", "$", "key", ")", ")", "{", "$", "res", "->", "$", "key", "=", "array", "(", "$", "res", "->", "$", "key", ")", ";", "}", "$", "ref", "=", "&", "$", "res", "->", "$", "key", ";", "$", "ref", "[", "]", "=", "CPS_Response", "::", "simpleXmlToStdClass", "(", "$", "value", ")", ";", "}", "else", "{", "$", "res", "->", "$", "key", "=", "CPS_Response", "::", "simpleXmlToStdClass", "(", "$", "value", ")", ";", "}", "$", "children", "=", "true", ";", "}", "if", "(", "!", "$", "children", ")", "return", "(", "string", ")", "$", "source", ";", "return", "$", "res", ";", "}" ]
Converts SimpleXMLElement to stdClass
[ "Converts", "SimpleXMLElement", "to", "stdClass" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/response.class.php#L443-L462
7,622
watoki/collections
src/watoki/collections/Liste.php
Liste.append
public function append($element) { $this->elements[] = $element; $this->fire(new ListCreateEvent($element, $this->count() - 1)); return $this; }
php
public function append($element) { $this->elements[] = $element; $this->fire(new ListCreateEvent($element, $this->count() - 1)); return $this; }
[ "public", "function", "append", "(", "$", "element", ")", "{", "$", "this", "->", "elements", "[", "]", "=", "$", "element", ";", "$", "this", "->", "fire", "(", "new", "ListCreateEvent", "(", "$", "element", ",", "$", "this", "->", "count", "(", ")", "-", "1", ")", ")", ";", "return", "$", "this", ";", "}" ]
Adds element to end of list. @param mixed $element @return static
[ "Adds", "element", "to", "end", "of", "list", "." ]
ff9c866020c7f2daff1b9bc24fe6d64e218af157
https://github.com/watoki/collections/blob/ff9c866020c7f2daff1b9bc24fe6d64e218af157/src/watoki/collections/Liste.php#L60-L64
7,623
watoki/collections
src/watoki/collections/Liste.php
Liste.unshift
public function unshift($element) { $this->insert($element, 0); $this->fire(new ListCreateEvent($element, 0)); return $this; }
php
public function unshift($element) { $this->insert($element, 0); $this->fire(new ListCreateEvent($element, 0)); return $this; }
[ "public", "function", "unshift", "(", "$", "element", ")", "{", "$", "this", "->", "insert", "(", "$", "element", ",", "0", ")", ";", "$", "this", "->", "fire", "(", "new", "ListCreateEvent", "(", "$", "element", ",", "0", ")", ")", ";", "return", "$", "this", ";", "}" ]
Inserts the given element to the beginning of the list. @param mixed $element @return static
[ "Inserts", "the", "given", "element", "to", "the", "beginning", "of", "the", "list", "." ]
ff9c866020c7f2daff1b9bc24fe6d64e218af157
https://github.com/watoki/collections/blob/ff9c866020c7f2daff1b9bc24fe6d64e218af157/src/watoki/collections/Liste.php#L83-L87
7,624
watoki/collections
src/watoki/collections/Liste.php
Liste.remove
public function remove($index) { $e = $this->elements[$index]; unset($this->elements[$index]); $this->clean(); $this->fire(new ListDeleteEvent($e, $index)); return $e; }
php
public function remove($index) { $e = $this->elements[$index]; unset($this->elements[$index]); $this->clean(); $this->fire(new ListDeleteEvent($e, $index)); return $e; }
[ "public", "function", "remove", "(", "$", "index", ")", "{", "$", "e", "=", "$", "this", "->", "elements", "[", "$", "index", "]", ";", "unset", "(", "$", "this", "->", "elements", "[", "$", "index", "]", ")", ";", "$", "this", "->", "clean", "(", ")", ";", "$", "this", "->", "fire", "(", "new", "ListDeleteEvent", "(", "$", "e", ",", "$", "index", ")", ")", ";", "return", "$", "e", ";", "}" ]
Removes and returns the element at given index from list. @param int $index @return mixed
[ "Removes", "and", "returns", "the", "element", "at", "given", "index", "from", "list", "." ]
ff9c866020c7f2daff1b9bc24fe6d64e218af157
https://github.com/watoki/collections/blob/ff9c866020c7f2daff1b9bc24fe6d64e218af157/src/watoki/collections/Liste.php#L123-L129
7,625
watoki/collections
src/watoki/collections/Liste.php
Liste.pop
public function pop() { $e = array_pop($this->elements); $this->fire(new ListDeleteEvent($e, $this->count())); return $e; }
php
public function pop() { $e = array_pop($this->elements); $this->fire(new ListDeleteEvent($e, $this->count())); return $e; }
[ "public", "function", "pop", "(", ")", "{", "$", "e", "=", "array_pop", "(", "$", "this", "->", "elements", ")", ";", "$", "this", "->", "fire", "(", "new", "ListDeleteEvent", "(", "$", "e", ",", "$", "this", "->", "count", "(", ")", ")", ")", ";", "return", "$", "e", ";", "}" ]
Removes and returns the last element of the list. @return mixed
[ "Removes", "and", "returns", "the", "last", "element", "of", "the", "list", "." ]
ff9c866020c7f2daff1b9bc24fe6d64e218af157
https://github.com/watoki/collections/blob/ff9c866020c7f2daff1b9bc24fe6d64e218af157/src/watoki/collections/Liste.php#L144-L148
7,626
watoki/collections
src/watoki/collections/Liste.php
Liste.shift
public function shift() { $e = array_shift($this->elements); $this->clean(); $this->fire(new ListDeleteEvent($e, 0)); return $e; }
php
public function shift() { $e = array_shift($this->elements); $this->clean(); $this->fire(new ListDeleteEvent($e, 0)); return $e; }
[ "public", "function", "shift", "(", ")", "{", "$", "e", "=", "array_shift", "(", "$", "this", "->", "elements", ")", ";", "$", "this", "->", "clean", "(", ")", ";", "$", "this", "->", "fire", "(", "new", "ListDeleteEvent", "(", "$", "e", ",", "0", ")", ")", ";", "return", "$", "e", ";", "}" ]
Removes and returns the first element of the list. @return mixed
[ "Removes", "and", "returns", "the", "first", "element", "of", "the", "list", "." ]
ff9c866020c7f2daff1b9bc24fe6d64e218af157
https://github.com/watoki/collections/blob/ff9c866020c7f2daff1b9bc24fe6d64e218af157/src/watoki/collections/Liste.php#L155-L160
7,627
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/image.php
Image.forge
public static function forge($config = array(), $filename = null) { !is_array($config) and $config = array(); $config = array_merge(\Config::get('image', array()), $config); $protocol = ucfirst( ! empty($config['driver']) ? $config['driver'] : 'gd'); $class = 'Image_'.$protocol; if ($protocol == 'Driver' || ! class_exists($class)) { throw new \FuelException('Driver '.$protocol.' is not a valid driver for image manipulation.'); } $return = new $class($config); if ($filename !== null) { $return->load($filename); } return $return; }
php
public static function forge($config = array(), $filename = null) { !is_array($config) and $config = array(); $config = array_merge(\Config::get('image', array()), $config); $protocol = ucfirst( ! empty($config['driver']) ? $config['driver'] : 'gd'); $class = 'Image_'.$protocol; if ($protocol == 'Driver' || ! class_exists($class)) { throw new \FuelException('Driver '.$protocol.' is not a valid driver for image manipulation.'); } $return = new $class($config); if ($filename !== null) { $return->load($filename); } return $return; }
[ "public", "static", "function", "forge", "(", "$", "config", "=", "array", "(", ")", ",", "$", "filename", "=", "null", ")", "{", "!", "is_array", "(", "$", "config", ")", "and", "$", "config", "=", "array", "(", ")", ";", "$", "config", "=", "array_merge", "(", "\\", "Config", "::", "get", "(", "'image'", ",", "array", "(", ")", ")", ",", "$", "config", ")", ";", "$", "protocol", "=", "ucfirst", "(", "!", "empty", "(", "$", "config", "[", "'driver'", "]", ")", "?", "$", "config", "[", "'driver'", "]", ":", "'gd'", ")", ";", "$", "class", "=", "'Image_'", ".", "$", "protocol", ";", "if", "(", "$", "protocol", "==", "'Driver'", "||", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "\\", "FuelException", "(", "'Driver '", ".", "$", "protocol", ".", "' is not a valid driver for image manipulation.'", ")", ";", "}", "$", "return", "=", "new", "$", "class", "(", "$", "config", ")", ";", "if", "(", "$", "filename", "!==", "null", ")", "{", "$", "return", "->", "load", "(", "$", "filename", ")", ";", "}", "return", "$", "return", ";", "}" ]
Creates a new instance of the image driver @param array $config @return Image_Driver
[ "Creates", "a", "new", "instance", "of", "the", "image", "driver" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image.php#L57-L75
7,628
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/image.php
Image.config
public static function config($index = array(), $value = null) { if (static::$_instance === null) { if ($value !== null) $index = array($index => $value); if (is_array($index)) static::$_config = array_merge(static::$_config, $index); static::instance(); return static::instance(); } else { return static::instance()->config($index, $value); } }
php
public static function config($index = array(), $value = null) { if (static::$_instance === null) { if ($value !== null) $index = array($index => $value); if (is_array($index)) static::$_config = array_merge(static::$_config, $index); static::instance(); return static::instance(); } else { return static::instance()->config($index, $value); } }
[ "public", "static", "function", "config", "(", "$", "index", "=", "array", "(", ")", ",", "$", "value", "=", "null", ")", "{", "if", "(", "static", "::", "$", "_instance", "===", "null", ")", "{", "if", "(", "$", "value", "!==", "null", ")", "$", "index", "=", "array", "(", "$", "index", "=>", "$", "value", ")", ";", "if", "(", "is_array", "(", "$", "index", ")", ")", "static", "::", "$", "_config", "=", "array_merge", "(", "static", "::", "$", "_config", ",", "$", "index", ")", ";", "static", "::", "instance", "(", ")", ";", "return", "static", "::", "instance", "(", ")", ";", "}", "else", "{", "return", "static", "::", "instance", "(", ")", "->", "config", "(", "$", "index", ",", "$", "value", ")", ";", "}", "}" ]
Used to set configuration options. Sending the config options through the static reference initalizes the instance. If you need to send a driver config through the static reference, make sure its the first one sent! If errors arise, create a new instance using forge(). @param array $config An array of configuration settings. @return Image_Driver
[ "Used", "to", "set", "configuration", "options", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image.php#L88-L101
7,629
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/image.php
Image.load
public static function load($filename, $return_data = false, $force_extension = false) { return static::instance()->load($filename, $return_data, $force_extension); }
php
public static function load($filename, $return_data = false, $force_extension = false) { return static::instance()->load($filename, $return_data, $force_extension); }
[ "public", "static", "function", "load", "(", "$", "filename", ",", "$", "return_data", "=", "false", ",", "$", "force_extension", "=", "false", ")", "{", "return", "static", "::", "instance", "(", ")", "->", "load", "(", "$", "filename", ",", "$", "return_data", ",", "$", "force_extension", ")", ";", "}" ]
Loads the image and checks if its compatable. @param string $filename The file to load @param string $return_data Decides if it should return the images data, or just "$this". @param mixed $force_extension Whether or not to force the image extension @return Image_Driver
[ "Loads", "the", "image", "and", "checks", "if", "its", "compatable", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image.php#L111-L114
7,630
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/image.php
Image.crop
public static function crop($x1, $y1, $x2, $y2) { return static::instance()->crop($x1, $y1, $x2, $y2); }
php
public static function crop($x1, $y1, $x2, $y2) { return static::instance()->crop($x1, $y1, $x2, $y2); }
[ "public", "static", "function", "crop", "(", "$", "x1", ",", "$", "y1", ",", "$", "x2", ",", "$", "y2", ")", "{", "return", "static", "::", "instance", "(", ")", "->", "crop", "(", "$", "x1", ",", "$", "y1", ",", "$", "x2", ",", "$", "y2", ")", ";", "}" ]
Crops the image using coordinates or percentages. Absolute integer or percentages accepted for all 4. @param integer $x1 X-Coordinate based from the top-left corner. @param integer $y1 Y-Coordinate based from the top-left corner. @param integer $x2 X-Coordinate based from the bottom-right corner. @param integer $y2 Y-Coordinate based from the bottom-right corner. @return Image_Driver
[ "Crops", "the", "image", "using", "coordinates", "or", "percentages", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image.php#L127-L130
7,631
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/image.php
Image.resize
public static function resize($width, $height, $keepar = true, $pad = false) { return static::instance()->resize($width, $height, $keepar, $pad); }
php
public static function resize($width, $height, $keepar = true, $pad = false) { return static::instance()->resize($width, $height, $keepar, $pad); }
[ "public", "static", "function", "resize", "(", "$", "width", ",", "$", "height", ",", "$", "keepar", "=", "true", ",", "$", "pad", "=", "false", ")", "{", "return", "static", "::", "instance", "(", ")", "->", "resize", "(", "$", "width", ",", "$", "height", ",", "$", "keepar", ",", "$", "pad", ")", ";", "}" ]
Resizes the image. If the width or height is null, it will resize retaining the original aspect ratio. @param integer $width The new width of the image. @param integer $height The new height of the image. @param boolean $keepar Defaults to true. If false, allows resizing without keeping AR. @param boolean $pad If set to true and $keepar is true, it will pad the image with the configured bgcolor @return Image_Driver
[ "Resizes", "the", "image", ".", "If", "the", "width", "or", "height", "is", "null", "it", "will", "resize", "retaining", "the", "original", "aspect", "ratio", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image.php#L141-L144
7,632
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/image.php
Image.rounded
public static function rounded($radius, $sides = null, $antialias = null) { return static::instance()->rounded($radius, $sides, $antialias); }
php
public static function rounded($radius, $sides = null, $antialias = null) { return static::instance()->rounded($radius, $sides, $antialias); }
[ "public", "static", "function", "rounded", "(", "$", "radius", ",", "$", "sides", "=", "null", ",", "$", "antialias", "=", "null", ")", "{", "return", "static", "::", "instance", "(", ")", "->", "rounded", "(", "$", "radius", ",", "$", "sides", ",", "$", "antialias", ")", ";", "}" ]
Adds rounded corners to the image. @param integer $radius @param integer $sides Accepts any combination of "tl tr bl br" seperated by spaces, or null for all sides @param integer $antialias Sets the antialias range. @return Image_Driver
[ "Adds", "rounded", "corners", "to", "the", "image", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image.php#L225-L228
7,633
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/image.php
Image.save_pa
public static function save_pa($prepend, $append = null, $permissions = null) { return static::instance()->save_pa($prepend, $append, $permissions); }
php
public static function save_pa($prepend, $append = null, $permissions = null) { return static::instance()->save_pa($prepend, $append, $permissions); }
[ "public", "static", "function", "save_pa", "(", "$", "prepend", ",", "$", "append", "=", "null", ",", "$", "permissions", "=", "null", ")", "{", "return", "static", "::", "instance", "(", ")", "->", "save_pa", "(", "$", "prepend", ",", "$", "append", ",", "$", "permissions", ")", ";", "}" ]
Saves the image, and optionally attempts to set permissions @param string $prepend The text to add to the beginning of the filename. @param string $append The text to add to the end of the filename. @param string $permissions Allows unix style permissions @return Image_Driver
[ "Saves", "the", "image", "and", "optionally", "attempts", "to", "set", "permissions" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image.php#L260-L263
7,634
znframework/package-image
GDFilter.php
GDFilter.apply
public static function apply($file, $filters) { if( ! empty($filters) ) { $gd = self::getSingletonGDClass(); $gd->canvas($file); foreach( $filters as $filter ) { $method = $filter[0]; $parameters = $filter[1] ?? []; $gd->$method(...(array) $parameters); } $gd->generate(MimeTypeFinder::get($file), $file); } }
php
public static function apply($file, $filters) { if( ! empty($filters) ) { $gd = self::getSingletonGDClass(); $gd->canvas($file); foreach( $filters as $filter ) { $method = $filter[0]; $parameters = $filter[1] ?? []; $gd->$method(...(array) $parameters); } $gd->generate(MimeTypeFinder::get($file), $file); } }
[ "public", "static", "function", "apply", "(", "$", "file", ",", "$", "filters", ")", "{", "if", "(", "!", "empty", "(", "$", "filters", ")", ")", "{", "$", "gd", "=", "self", "::", "getSingletonGDClass", "(", ")", ";", "$", "gd", "->", "canvas", "(", "$", "file", ")", ";", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "$", "method", "=", "$", "filter", "[", "0", "]", ";", "$", "parameters", "=", "$", "filter", "[", "1", "]", "??", "[", "]", ";", "$", "gd", "->", "$", "method", "(", "...", "(", "array", ")", "$", "parameters", ")", ";", "}", "$", "gd", "->", "generate", "(", "MimeTypeFinder", "::", "get", "(", "$", "file", ")", ",", "$", "file", ")", ";", "}", "}" ]
Applies the used filters belonging to the GD class. @param string $file @param array $filters
[ "Applies", "the", "used", "filters", "belonging", "to", "the", "GD", "class", "." ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/GDFilter.php#L22-L40
7,635
mindteam/phpci-symfony2-plugin
SymfonyCommands.php
SymfonyCommands.execute
public function execute() { $success = true; foreach ($this->commandList as $command) { if (!$this->runSingleCommand($command)) { $success = false; break; } } return $success; }
php
public function execute() { $success = true; foreach ($this->commandList as $command) { if (!$this->runSingleCommand($command)) { $success = false; break; } } return $success; }
[ "public", "function", "execute", "(", ")", "{", "$", "success", "=", "true", ";", "foreach", "(", "$", "this", "->", "commandList", "as", "$", "command", ")", "{", "if", "(", "!", "$", "this", "->", "runSingleCommand", "(", "$", "command", ")", ")", "{", "$", "success", "=", "false", ";", "break", ";", "}", "}", "return", "$", "success", ";", "}" ]
Executes Symfony2 commands @return boolean plugin work status
[ "Executes", "Symfony2", "commands" ]
cf469c3b845aa92ab7897e9c1ff2e64380bcc7b3
https://github.com/mindteam/phpci-symfony2-plugin/blob/cf469c3b845aa92ab7897e9c1ff2e64380bcc7b3/SymfonyCommands.php#L53-L63
7,636
mindteam/phpci-symfony2-plugin
SymfonyCommands.php
SymfonyCommands.runSingleCommand
public function runSingleCommand($command) { $cmd = 'php ' . $this->directory . 'app/console '; return $this->phpci->executeCommand($cmd . $command, $this->directory); }
php
public function runSingleCommand($command) { $cmd = 'php ' . $this->directory . 'app/console '; return $this->phpci->executeCommand($cmd . $command, $this->directory); }
[ "public", "function", "runSingleCommand", "(", "$", "command", ")", "{", "$", "cmd", "=", "'php '", ".", "$", "this", "->", "directory", ".", "'app/console '", ";", "return", "$", "this", "->", "phpci", "->", "executeCommand", "(", "$", "cmd", ".", "$", "command", ",", "$", "this", "->", "directory", ")", ";", "}" ]
Run one command @param string $command command for cymfony @return boolean
[ "Run", "one", "command" ]
cf469c3b845aa92ab7897e9c1ff2e64380bcc7b3
https://github.com/mindteam/phpci-symfony2-plugin/blob/cf469c3b845aa92ab7897e9c1ff2e64380bcc7b3/SymfonyCommands.php#L72-L77
7,637
JaredClemence/binn
src/builders/DecimalBuilder.php
DecimalBuilder.extractMantissa
public function extractMantissa($data) { $signAndExponent = $this->extractSignAndExponentFromData($data); $mask = ~$signAndExponent; $mantissa = $data & $mask; return $mantissa; }
php
public function extractMantissa($data) { $signAndExponent = $this->extractSignAndExponentFromData($data); $mask = ~$signAndExponent; $mantissa = $data & $mask; return $mantissa; }
[ "public", "function", "extractMantissa", "(", "$", "data", ")", "{", "$", "signAndExponent", "=", "$", "this", "->", "extractSignAndExponentFromData", "(", "$", "data", ")", ";", "$", "mask", "=", "~", "$", "signAndExponent", ";", "$", "mantissa", "=", "$", "data", "&", "$", "mask", ";", "return", "$", "mantissa", ";", "}" ]
Public for unit test
[ "Public", "for", "unit", "test" ]
838591e7a92c0f257c09a1df141d80737a20f7d9
https://github.com/JaredClemence/binn/blob/838591e7a92c0f257c09a1df141d80737a20f7d9/src/builders/DecimalBuilder.php#L129-L134
7,638
JaredClemence/binn
src/builders/DecimalBuilder.php
DecimalBuilder.makeFrontSideMask
public function makeFrontSideMask($maskLength, $byteLength) { $maskValue = 0; $bitLength = $byteLength * 8; $maskString = ""; $valueStore = 0; for ($i = 0; $i < $bitLength; $i++) { $maskValue <<= 1; if ($i < $maskLength) { $maskValue += 1; } $valueStore++; $binRep = BinaryStringAtom::createHumanReadableBinaryRepresentation($maskValue); if ($valueStore == 8) { $char = chr($maskValue); $maskString .= $char; $maskValue = 0; $valueStore = 0; } } return $maskString; }
php
public function makeFrontSideMask($maskLength, $byteLength) { $maskValue = 0; $bitLength = $byteLength * 8; $maskString = ""; $valueStore = 0; for ($i = 0; $i < $bitLength; $i++) { $maskValue <<= 1; if ($i < $maskLength) { $maskValue += 1; } $valueStore++; $binRep = BinaryStringAtom::createHumanReadableBinaryRepresentation($maskValue); if ($valueStore == 8) { $char = chr($maskValue); $maskString .= $char; $maskValue = 0; $valueStore = 0; } } return $maskString; }
[ "public", "function", "makeFrontSideMask", "(", "$", "maskLength", ",", "$", "byteLength", ")", "{", "$", "maskValue", "=", "0", ";", "$", "bitLength", "=", "$", "byteLength", "*", "8", ";", "$", "maskString", "=", "\"\"", ";", "$", "valueStore", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "bitLength", ";", "$", "i", "++", ")", "{", "$", "maskValue", "<<=", "1", ";", "if", "(", "$", "i", "<", "$", "maskLength", ")", "{", "$", "maskValue", "+=", "1", ";", "}", "$", "valueStore", "++", ";", "$", "binRep", "=", "BinaryStringAtom", "::", "createHumanReadableBinaryRepresentation", "(", "$", "maskValue", ")", ";", "if", "(", "$", "valueStore", "==", "8", ")", "{", "$", "char", "=", "chr", "(", "$", "maskValue", ")", ";", "$", "maskString", ".=", "$", "char", ";", "$", "maskValue", "=", "0", ";", "$", "valueStore", "=", "0", ";", "}", "}", "return", "$", "maskString", ";", "}" ]
This function makes a mask that has one's in the highest bit-values, and 0's in the lower bit-values. For example, when passed the parameters (3,1) it produces a binary string 0b11100000; Public function for testing. @param int $maskLength @param int $bitLength @return string
[ "This", "function", "makes", "a", "mask", "that", "has", "one", "s", "in", "the", "highest", "bit", "-", "values", "and", "0", "s", "in", "the", "lower", "bit", "-", "values", "." ]
838591e7a92c0f257c09a1df141d80737a20f7d9
https://github.com/JaredClemence/binn/blob/838591e7a92c0f257c09a1df141d80737a20f7d9/src/builders/DecimalBuilder.php#L165-L185
7,639
JaredClemence/binn
src/builders/DecimalBuilder.php
DecimalBuilder.convertBinaryFractionToDecimalFraction
public function convertBinaryFractionToDecimalFraction($mantissaByteString, $integerExponent) { $bits = $this->mantissaBitLength; $value = pow(2, $integerExponent); for ($i = 0; $i < $bits; $i++) { $curExponent = $integerExponent - 1 - $i; $bitPosition = $bits - $i - 1; $bitValue = $this->readBit($mantissaByteString, $bitPosition); $decValue = pow(2, $curExponent) * $bitValue; $value += $decValue; } return $value; }
php
public function convertBinaryFractionToDecimalFraction($mantissaByteString, $integerExponent) { $bits = $this->mantissaBitLength; $value = pow(2, $integerExponent); for ($i = 0; $i < $bits; $i++) { $curExponent = $integerExponent - 1 - $i; $bitPosition = $bits - $i - 1; $bitValue = $this->readBit($mantissaByteString, $bitPosition); $decValue = pow(2, $curExponent) * $bitValue; $value += $decValue; } return $value; }
[ "public", "function", "convertBinaryFractionToDecimalFraction", "(", "$", "mantissaByteString", ",", "$", "integerExponent", ")", "{", "$", "bits", "=", "$", "this", "->", "mantissaBitLength", ";", "$", "value", "=", "pow", "(", "2", ",", "$", "integerExponent", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "bits", ";", "$", "i", "++", ")", "{", "$", "curExponent", "=", "$", "integerExponent", "-", "1", "-", "$", "i", ";", "$", "bitPosition", "=", "$", "bits", "-", "$", "i", "-", "1", ";", "$", "bitValue", "=", "$", "this", "->", "readBit", "(", "$", "mantissaByteString", ",", "$", "bitPosition", ")", ";", "$", "decValue", "=", "pow", "(", "2", ",", "$", "curExponent", ")", "*", "$", "bitValue", ";", "$", "value", "+=", "$", "decValue", ";", "}", "return", "$", "value", ";", "}" ]
Pubic for unit testing only. @param type $mantissaByteString @param type $integerExponent
[ "Pubic", "for", "unit", "testing", "only", "." ]
838591e7a92c0f257c09a1df141d80737a20f7d9
https://github.com/JaredClemence/binn/blob/838591e7a92c0f257c09a1df141d80737a20f7d9/src/builders/DecimalBuilder.php#L200-L211
7,640
JaredClemence/binn
src/builders/DecimalBuilder.php
DecimalBuilder.readBit
public function readBit($byteString, $bitPosition) { $byteNumber = $this->findByteNumberForBitPosition($bitPosition); $bitPositionInByte = $bitPosition % 8; $pos = strlen($byteString) - 1 - $byteNumber; $targetByte = $byteString[$pos]; $mask = chr(1 << $bitPositionInByte); $filteredByte = $mask & $targetByte; $bitValue = 0; if (ord($filteredByte) > 0) { $bitValue = 1; } return $bitValue; }
php
public function readBit($byteString, $bitPosition) { $byteNumber = $this->findByteNumberForBitPosition($bitPosition); $bitPositionInByte = $bitPosition % 8; $pos = strlen($byteString) - 1 - $byteNumber; $targetByte = $byteString[$pos]; $mask = chr(1 << $bitPositionInByte); $filteredByte = $mask & $targetByte; $bitValue = 0; if (ord($filteredByte) > 0) { $bitValue = 1; } return $bitValue; }
[ "public", "function", "readBit", "(", "$", "byteString", ",", "$", "bitPosition", ")", "{", "$", "byteNumber", "=", "$", "this", "->", "findByteNumberForBitPosition", "(", "$", "bitPosition", ")", ";", "$", "bitPositionInByte", "=", "$", "bitPosition", "%", "8", ";", "$", "pos", "=", "strlen", "(", "$", "byteString", ")", "-", "1", "-", "$", "byteNumber", ";", "$", "targetByte", "=", "$", "byteString", "[", "$", "pos", "]", ";", "$", "mask", "=", "chr", "(", "1", "<<", "$", "bitPositionInByte", ")", ";", "$", "filteredByte", "=", "$", "mask", "&", "$", "targetByte", ";", "$", "bitValue", "=", "0", ";", "if", "(", "ord", "(", "$", "filteredByte", ")", ">", "0", ")", "{", "$", "bitValue", "=", "1", ";", "}", "return", "$", "bitValue", ";", "}" ]
Public for testing @param type $byteString @param type $bitPosition @return type
[ "Public", "for", "testing" ]
838591e7a92c0f257c09a1df141d80737a20f7d9
https://github.com/JaredClemence/binn/blob/838591e7a92c0f257c09a1df141d80737a20f7d9/src/builders/DecimalBuilder.php#L219-L231
7,641
jakecleary/ultrapress-library
src/Ultra/Helpers/Data.php
Data.spaceToCamelCase
public static function spaceToCamelCase($string, $type = '_', $first_char_caps = false) { if($first_char_caps === true) { $string[0] = strtoupper($string[0]); } $func = create_function('$c', 'return strtoupper($c[1]);'); return preg_replace_callback('/' . $type . '([a-z])/', $func, $string); }
php
public static function spaceToCamelCase($string, $type = '_', $first_char_caps = false) { if($first_char_caps === true) { $string[0] = strtoupper($string[0]); } $func = create_function('$c', 'return strtoupper($c[1]);'); return preg_replace_callback('/' . $type . '([a-z])/', $func, $string); }
[ "public", "static", "function", "spaceToCamelCase", "(", "$", "string", ",", "$", "type", "=", "'_'", ",", "$", "first_char_caps", "=", "false", ")", "{", "if", "(", "$", "first_char_caps", "===", "true", ")", "{", "$", "string", "[", "0", "]", "=", "strtoupper", "(", "$", "string", "[", "0", "]", ")", ";", "}", "$", "func", "=", "create_function", "(", "'$c'", ",", "'return strtoupper($c[1]);'", ")", ";", "return", "preg_replace_callback", "(", "'/'", ".", "$", "type", ".", "'([a-z])/'", ",", "$", "func", ",", "$", "string", ")", ";", "}" ]
Convert strings with an arbitrary deliminator into CamelCase. @param string $string The string to convert @param string $type The deliminator to replace @param bool $first_char_caps camelCase or CamelCase @return string The converted string
[ "Convert", "strings", "with", "an", "arbitrary", "deliminator", "into", "CamelCase", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Helpers/Data.php#L35-L45
7,642
dendevs/plpadaptability
src/NoKernel.php
NoKernel.get_config_value
public function get_config_value( $config_name, $default_value = false ) { $value = false; if( array_key_exists( $config_name, $this->_config ) ) { $value = $this->_config[$config_name]; } else if( ! $default_value ) { $value = $default_value; } return $value; }
php
public function get_config_value( $config_name, $default_value = false ) { $value = false; if( array_key_exists( $config_name, $this->_config ) ) { $value = $this->_config[$config_name]; } else if( ! $default_value ) { $value = $default_value; } return $value; }
[ "public", "function", "get_config_value", "(", "$", "config_name", ",", "$", "default_value", "=", "false", ")", "{", "$", "value", "=", "false", ";", "if", "(", "array_key_exists", "(", "$", "config_name", ",", "$", "this", "->", "_config", ")", ")", "{", "$", "value", "=", "$", "this", "->", "_config", "[", "$", "config_name", "]", ";", "}", "else", "if", "(", "!", "$", "default_value", ")", "{", "$", "value", "=", "$", "default_value", ";", "}", "return", "$", "value", ";", "}" ]
Recupere la valeur de l'option demander. Donne une valeur par default si non trouver et argument 2 exists @param string $config_name nom de l'option de Configuration a retrouver service.option_name.sous_option @param string $default_value false par defaut. @return false|mixed la valeur de l'option
[ "Recupere", "la", "valeur", "de", "l", "option", "demander", "." ]
9e1af2912c5b6ee7e409af487279d529e56ecbe1
https://github.com/dendevs/plpadaptability/blob/9e1af2912c5b6ee7e409af487279d529e56ecbe1/src/NoKernel.php#L48-L61
7,643
dendevs/plpadaptability
src/NoKernel.php
NoKernel.log
public function log( $service_name, $log_name, $level, $message, $context = array() ) { $ok = false; $tmp_log_path = $this->get_config_value( 'log_path' ); $log_path = ( $this->get_config_value( 'log_path' ) ) ? $this->get_config_value( 'log_path' ) . '/' . $service_name . '/' : sys_get_temp_dir() . '/' . $service_name . '/'; if( ! file_exists( $log_path ) ) { mkdir( $log_path, 0755 ); } $log_path .= $log_name . ".log"; // avoid big file $append = false; if( file_exists( $log_path ) && filesize( $log_path ) >= 1024 ) { // unlink( $log_path ); $append = FILE_APPEND; } // write $context_string = ( (bool) $context ) ? print_r( $context, true ) : ''; $formated_message = $level . ': ' . $message . ' ( ' . $context_string . ' )'; $ok = file_put_contents( $log_path, $formated_message, $append ); return ( $ok === false ) ? false : true; }
php
public function log( $service_name, $log_name, $level, $message, $context = array() ) { $ok = false; $tmp_log_path = $this->get_config_value( 'log_path' ); $log_path = ( $this->get_config_value( 'log_path' ) ) ? $this->get_config_value( 'log_path' ) . '/' . $service_name . '/' : sys_get_temp_dir() . '/' . $service_name . '/'; if( ! file_exists( $log_path ) ) { mkdir( $log_path, 0755 ); } $log_path .= $log_name . ".log"; // avoid big file $append = false; if( file_exists( $log_path ) && filesize( $log_path ) >= 1024 ) { // unlink( $log_path ); $append = FILE_APPEND; } // write $context_string = ( (bool) $context ) ? print_r( $context, true ) : ''; $formated_message = $level . ': ' . $message . ' ( ' . $context_string . ' )'; $ok = file_put_contents( $log_path, $formated_message, $append ); return ( $ok === false ) ? false : true; }
[ "public", "function", "log", "(", "$", "service_name", ",", "$", "log_name", ",", "$", "level", ",", "$", "message", ",", "$", "context", "=", "array", "(", ")", ")", "{", "$", "ok", "=", "false", ";", "$", "tmp_log_path", "=", "$", "this", "->", "get_config_value", "(", "'log_path'", ")", ";", "$", "log_path", "=", "(", "$", "this", "->", "get_config_value", "(", "'log_path'", ")", ")", "?", "$", "this", "->", "get_config_value", "(", "'log_path'", ")", ".", "'/'", ".", "$", "service_name", ".", "'/'", ":", "sys_get_temp_dir", "(", ")", ".", "'/'", ".", "$", "service_name", ".", "'/'", ";", "if", "(", "!", "file_exists", "(", "$", "log_path", ")", ")", "{", "mkdir", "(", "$", "log_path", ",", "0755", ")", ";", "}", "$", "log_path", ".=", "$", "log_name", ".", "\".log\"", ";", "// avoid big file", "$", "append", "=", "false", ";", "if", "(", "file_exists", "(", "$", "log_path", ")", "&&", "filesize", "(", "$", "log_path", ")", ">=", "1024", ")", "{", "// unlink( $log_path );", "$", "append", "=", "FILE_APPEND", ";", "}", "// write", "$", "context_string", "=", "(", "(", "bool", ")", "$", "context", ")", "?", "print_r", "(", "$", "context", ",", "true", ")", ":", "''", ";", "$", "formated_message", "=", "$", "level", ".", "': '", ".", "$", "message", ".", "' ( '", ".", "$", "context_string", ".", "' )'", ";", "$", "ok", "=", "file_put_contents", "(", "$", "log_path", ",", "$", "formated_message", ",", "$", "append", ")", ";", "return", "(", "$", "ok", "===", "false", ")", "?", "false", ":", "true", ";", "}" ]
Ecriture de log basique. Le logs est ecrit dans /tmp par defaut. Si la config log_path existe alors l'ecriture ce fait dans ce repertoire nom_plugin. @param string $log_name nom fichier ( sans ext ) @param string $level niveau du message ( info, debug, ... ) @param string $message message a logger @param array $context informations supplementaires @return bool true si ecriture ok
[ "Ecriture", "de", "log", "basique", "." ]
9e1af2912c5b6ee7e409af487279d529e56ecbe1
https://github.com/dendevs/plpadaptability/blob/9e1af2912c5b6ee7e409af487279d529e56ecbe1/src/NoKernel.php#L90-L118
7,644
bashilbers/domain
src/Eventing/When/ConventionBasedWhen.php
ConventionBasedWhen.when
protected function when(DomainEvent $event) { $method = 'when' . ClassToString::short($event); if (is_callable([$this, $method])) { $this->{$method}($event); } }
php
protected function when(DomainEvent $event) { $method = 'when' . ClassToString::short($event); if (is_callable([$this, $method])) { $this->{$method}($event); } }
[ "protected", "function", "when", "(", "DomainEvent", "$", "event", ")", "{", "$", "method", "=", "'when'", ".", "ClassToString", "::", "short", "(", "$", "event", ")", ";", "if", "(", "is_callable", "(", "[", "$", "this", ",", "$", "method", "]", ")", ")", "{", "$", "this", "->", "{", "$", "method", "}", "(", "$", "event", ")", ";", "}", "}" ]
Handle a single domain event @param DomainEvent $event @return void
[ "Handle", "a", "single", "domain", "event" ]
864736b8c409077706554b6ac4c574832678d316
https://github.com/bashilbers/domain/blob/864736b8c409077706554b6ac4c574832678d316/src/Eventing/When/ConventionBasedWhen.php#L20-L26
7,645
Dhii/di-abstract
src/ServiceCacheAwareTrait.php
ServiceCacheAwareTrait._setServiceCache
protected function _setServiceCache($serviceCache) { if ($serviceCache !== null && !($serviceCache instanceof ContainerInterface)) { throw $this->_createInvalidArgumentException($this->__('Invalid cache'), null, null, $serviceCache); } $this->serviceCache = $serviceCache; }
php
protected function _setServiceCache($serviceCache) { if ($serviceCache !== null && !($serviceCache instanceof ContainerInterface)) { throw $this->_createInvalidArgumentException($this->__('Invalid cache'), null, null, $serviceCache); } $this->serviceCache = $serviceCache; }
[ "protected", "function", "_setServiceCache", "(", "$", "serviceCache", ")", "{", "if", "(", "$", "serviceCache", "!==", "null", "&&", "!", "(", "$", "serviceCache", "instanceof", "ContainerInterface", ")", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Invalid cache'", ")", ",", "null", ",", "null", ",", "$", "serviceCache", ")", ";", "}", "$", "this", "->", "serviceCache", "=", "$", "serviceCache", ";", "}" ]
Assigns a service cache to this instance. @since [*next-version*] @param ContainerInterface|null $serviceCache The service cache.
[ "Assigns", "a", "service", "cache", "to", "this", "instance", "." ]
badfa20def27e5c6883f1c1078c98603b7bee319
https://github.com/Dhii/di-abstract/blob/badfa20def27e5c6883f1c1078c98603b7bee319/src/ServiceCacheAwareTrait.php#L45-L52
7,646
Palmabit-IT/authenticator
src/Palmabit/Authentication/Classes/SentryAuthenticator.php
SentryAuthenticator.hasGroup
public function hasGroup($name) { $group = App::make('group_repository')->findByName($name); $user = $this->getLoggedUser(); if (!$user) { return false; } return $user->inGroup($group); }
php
public function hasGroup($name) { $group = App::make('group_repository')->findByName($name); $user = $this->getLoggedUser(); if (!$user) { return false; } return $user->inGroup($group); }
[ "public", "function", "hasGroup", "(", "$", "name", ")", "{", "$", "group", "=", "App", "::", "make", "(", "'group_repository'", ")", "->", "findByName", "(", "$", "name", ")", ";", "$", "user", "=", "$", "this", "->", "getLoggedUser", "(", ")", ";", "if", "(", "!", "$", "user", ")", "{", "return", "false", ";", "}", "return", "$", "user", "->", "inGroup", "(", "$", "group", ")", ";", "}" ]
Check if the current user has the given group @param $name @return mixed
[ "Check", "if", "the", "current", "user", "has", "the", "given", "group" ]
986cfc7e666e0e1b0312e518d586ec61b08cdb42
https://github.com/Palmabit-IT/authenticator/blob/986cfc7e666e0e1b0312e518d586ec61b08cdb42/src/Palmabit/Authentication/Classes/SentryAuthenticator.php#L129-L137
7,647
devbr/tools
Cli/Key.php
Key.createKeys
private function createKeys() { //Create Can Keys shuffle(Devbr\Can::$base); shuffle(Devbr\Can::$extra_base); file_put_contents($this->configKeyPath.'can.key', implode(Devbr\Can::$base)."\n".implode(Devbr\Can::$extra_base)); $SSLcnf = []; $dn = []; //get configurations include $this->configKeyPath.'openssl.config.php'; // Generate a new private (and public) key pair $privkey = openssl_pkey_new($SSLcnf); // Generate a certificate signing request $csr = openssl_csr_new($dn, $privkey, $SSLcnf); // You will usually want to create a self-signed certificate at this // point until your CA fulfills your request. // This creates a self-signed cert that is valid for 365 days $sscert = openssl_csr_sign($csr, null, $privkey, 365, $SSLcnf); //CERTIFICADO openssl_csr_export_to_file($csr, $this->configKeyPath.'certificate.crt', false); //CERTIFICADO AUTO-ASSINADO openssl_x509_export_to_file($sscert, $this->configKeyPath.'self_signed_certificate.cer', false); //CHAVE PRIVADA (private.pem) openssl_pkey_export_to_file($privkey, $this->configKeyPath.'private.key', null, $SSLcnf); //CHAVE PÚBLICA (public.key) file_put_contents($this->configKeyPath.'public.key', openssl_pkey_get_details($privkey)['key']); }
php
private function createKeys() { //Create Can Keys shuffle(Devbr\Can::$base); shuffle(Devbr\Can::$extra_base); file_put_contents($this->configKeyPath.'can.key', implode(Devbr\Can::$base)."\n".implode(Devbr\Can::$extra_base)); $SSLcnf = []; $dn = []; //get configurations include $this->configKeyPath.'openssl.config.php'; // Generate a new private (and public) key pair $privkey = openssl_pkey_new($SSLcnf); // Generate a certificate signing request $csr = openssl_csr_new($dn, $privkey, $SSLcnf); // You will usually want to create a self-signed certificate at this // point until your CA fulfills your request. // This creates a self-signed cert that is valid for 365 days $sscert = openssl_csr_sign($csr, null, $privkey, 365, $SSLcnf); //CERTIFICADO openssl_csr_export_to_file($csr, $this->configKeyPath.'certificate.crt', false); //CERTIFICADO AUTO-ASSINADO openssl_x509_export_to_file($sscert, $this->configKeyPath.'self_signed_certificate.cer', false); //CHAVE PRIVADA (private.pem) openssl_pkey_export_to_file($privkey, $this->configKeyPath.'private.key', null, $SSLcnf); //CHAVE PÚBLICA (public.key) file_put_contents($this->configKeyPath.'public.key', openssl_pkey_get_details($privkey)['key']); }
[ "private", "function", "createKeys", "(", ")", "{", "//Create Can Keys", "shuffle", "(", "Devbr", "\\", "Can", "::", "$", "base", ")", ";", "shuffle", "(", "Devbr", "\\", "Can", "::", "$", "extra_base", ")", ";", "file_put_contents", "(", "$", "this", "->", "configKeyPath", ".", "'can.key'", ",", "implode", "(", "Devbr", "\\", "Can", "::", "$", "base", ")", ".", "\"\\n\"", ".", "implode", "(", "Devbr", "\\", "Can", "::", "$", "extra_base", ")", ")", ";", "$", "SSLcnf", "=", "[", "]", ";", "$", "dn", "=", "[", "]", ";", "//get configurations", "include", "$", "this", "->", "configKeyPath", ".", "'openssl.config.php'", ";", "// Generate a new private (and public) key pair", "$", "privkey", "=", "openssl_pkey_new", "(", "$", "SSLcnf", ")", ";", "// Generate a certificate signing request", "$", "csr", "=", "openssl_csr_new", "(", "$", "dn", ",", "$", "privkey", ",", "$", "SSLcnf", ")", ";", "// You will usually want to create a self-signed certificate at this", "// point until your CA fulfills your request.", "// This creates a self-signed cert that is valid for 365 days", "$", "sscert", "=", "openssl_csr_sign", "(", "$", "csr", ",", "null", ",", "$", "privkey", ",", "365", ",", "$", "SSLcnf", ")", ";", "//CERTIFICADO", "openssl_csr_export_to_file", "(", "$", "csr", ",", "$", "this", "->", "configKeyPath", ".", "'certificate.crt'", ",", "false", ")", ";", "//CERTIFICADO AUTO-ASSINADO", "openssl_x509_export_to_file", "(", "$", "sscert", ",", "$", "this", "->", "configKeyPath", ".", "'self_signed_certificate.cer'", ",", "false", ")", ";", "//CHAVE PRIVADA (private.pem)", "openssl_pkey_export_to_file", "(", "$", "privkey", ",", "$", "this", "->", "configKeyPath", ".", "'private.key'", ",", "null", ",", "$", "SSLcnf", ")", ";", "//CHAVE PÚBLICA (public.key)", "file_put_contents", "(", "$", "this", "->", "configKeyPath", ".", "'public.key'", ",", "openssl_pkey_get_details", "(", "$", "privkey", ")", "[", "'key'", "]", ")", ";", "}" ]
Create Can anda SSL keys @return void none
[ "Create", "Can", "anda", "SSL", "keys" ]
f23f35172143b4ab2f45db37274fcc94d32e20e8
https://github.com/devbr/tools/blob/f23f35172143b4ab2f45db37274fcc94d32e20e8/Cli/Key.php#L132-L167
7,648
bishopb/vanilla
library/core/class.request.php
Gdn_Request.Export
public function Export($Export) { switch ($Export) { case 'Environment': return $this->_Environment; case 'Arguments': return $this->_RequestArguments; case 'Parsed': return $this->_ParsedRequest; default: return NULL; } }
php
public function Export($Export) { switch ($Export) { case 'Environment': return $this->_Environment; case 'Arguments': return $this->_RequestArguments; case 'Parsed': return $this->_ParsedRequest; default: return NULL; } }
[ "public", "function", "Export", "(", "$", "Export", ")", "{", "switch", "(", "$", "Export", ")", "{", "case", "'Environment'", ":", "return", "$", "this", "->", "_Environment", ";", "case", "'Arguments'", ":", "return", "$", "this", "->", "_RequestArguments", ";", "case", "'Parsed'", ":", "return", "$", "this", "->", "_ParsedRequest", ";", "default", ":", "return", "NULL", ";", "}", "}" ]
This method allows requests to export their internal data. Mostly used in conjunction with FromImport() @param $Export Data group to export @return mixed
[ "This", "method", "allows", "requests", "to", "export", "their", "internal", "data", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L144-L151
7,649
bishopb/vanilla
library/core/class.request.php
Gdn_Request.FromEnvironment
public function FromEnvironment() { $this->WithURI() ->WithArgs(self::INPUT_GET, self::INPUT_POST, self::INPUT_SERVER, self::INPUT_FILES, self::INPUT_COOKIES); return $this; }
php
public function FromEnvironment() { $this->WithURI() ->WithArgs(self::INPUT_GET, self::INPUT_POST, self::INPUT_SERVER, self::INPUT_FILES, self::INPUT_COOKIES); return $this; }
[ "public", "function", "FromEnvironment", "(", ")", "{", "$", "this", "->", "WithURI", "(", ")", "->", "WithArgs", "(", "self", "::", "INPUT_GET", ",", "self", "::", "INPUT_POST", ",", "self", "::", "INPUT_SERVER", ",", "self", "::", "INPUT_FILES", ",", "self", "::", "INPUT_COOKIES", ")", ";", "return", "$", "this", ";", "}" ]
Chainable lazy Environment Bootstrap Convenience method allowing quick setup of the default request state... from the current environment. @flow chain @return Gdn_Request
[ "Chainable", "lazy", "Environment", "Bootstrap" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L174-L179
7,650
bishopb/vanilla
library/core/class.request.php
Gdn_Request.FromImport
public function FromImport($NewRequest) { // Import Environment $this->_Environment = $NewRequest->Export('Environment'); // Import Arguments $this->_RequestArguments = $NewRequest->Export('Arguments'); $this->_HaveParsedRequest = FALSE; $this->_Parsing = FALSE; return $this; }
php
public function FromImport($NewRequest) { // Import Environment $this->_Environment = $NewRequest->Export('Environment'); // Import Arguments $this->_RequestArguments = $NewRequest->Export('Arguments'); $this->_HaveParsedRequest = FALSE; $this->_Parsing = FALSE; return $this; }
[ "public", "function", "FromImport", "(", "$", "NewRequest", ")", "{", "// Import Environment", "$", "this", "->", "_Environment", "=", "$", "NewRequest", "->", "Export", "(", "'Environment'", ")", ";", "// Import Arguments", "$", "this", "->", "_RequestArguments", "=", "$", "NewRequest", "->", "Export", "(", "'Arguments'", ")", ";", "$", "this", "->", "_HaveParsedRequest", "=", "FALSE", ";", "$", "this", "->", "_Parsing", "=", "FALSE", ";", "return", "$", "this", ";", "}" ]
Chainable Request Importer This method allows one method to import the raw information of another request @param $NewRequest New Request from which to import environment and arguments. @flow chain @return Gdn_Request
[ "Chainable", "Request", "Importer" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L190-L199
7,651
bishopb/vanilla
library/core/class.request.php
Gdn_Request.Get
public function Get($Key = NULL, $Default = NULL) { if ($Key === NULL) return $this->GetRequestArguments (self::INPUT_GET); else return $this->GetValueFrom(self::INPUT_GET, $Key, $Default); }
php
public function Get($Key = NULL, $Default = NULL) { if ($Key === NULL) return $this->GetRequestArguments (self::INPUT_GET); else return $this->GetValueFrom(self::INPUT_GET, $Key, $Default); }
[ "public", "function", "Get", "(", "$", "Key", "=", "NULL", ",", "$", "Default", "=", "NULL", ")", "{", "if", "(", "$", "Key", "===", "NULL", ")", "return", "$", "this", "->", "GetRequestArguments", "(", "self", "::", "INPUT_GET", ")", ";", "else", "return", "$", "this", "->", "GetValueFrom", "(", "self", "::", "INPUT_GET", ",", "$", "Key", ",", "$", "Default", ")", ";", "}" ]
Get a value from the GET array or return the entire GET array. @param string|null $Key The key of the get item or null to return the entire get array. @param mixed $Default The value to return if the item isn't set. @return mixed
[ "Get", "a", "value", "from", "the", "GET", "array", "or", "return", "the", "entire", "GET", "array", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L208-L213
7,652
bishopb/vanilla
library/core/class.request.php
Gdn_Request.HostAndPort
public function HostAndPort() { $Host = $this->Host(); $Port = $this->Port(); if (!in_array($Port, array(80, 443))) return $Host.':'.$Port; else return $Host; }
php
public function HostAndPort() { $Host = $this->Host(); $Port = $this->Port(); if (!in_array($Port, array(80, 443))) return $Host.':'.$Port; else return $Host; }
[ "public", "function", "HostAndPort", "(", ")", "{", "$", "Host", "=", "$", "this", "->", "Host", "(", ")", ";", "$", "Port", "=", "$", "this", "->", "Port", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "Port", ",", "array", "(", "80", ",", "443", ")", ")", ")", "return", "$", "Host", ".", "':'", ".", "$", "Port", ";", "else", "return", "$", "Host", ";", "}" ]
Return the host and port together if the port isn't standard. @return string @since 2.1
[ "Return", "the", "host", "and", "port", "together", "if", "the", "port", "isn", "t", "standard", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L280-L287
7,653
bishopb/vanilla
library/core/class.request.php
Gdn_Request._ParseRequest
protected function _ParseRequest() { $this->_Parsing = TRUE; /** * Resolve final request to send to dispatcher */ $Path = $this->_EnvironmentElement('URI'); // Get the dispatch string from the URI if($Path !== FALSE) { $this->Path(trim($Path, '/')); } else { $Expression = '/^(?:\/?'.str_replace('/', '\/', $this->_EnvironmentElement('Folder')).')?(?:'.$this->_EnvironmentElement('Script').')?\/?(.*?)\/?(?:[#?].*)?$/i'; if (preg_match($Expression, $this->_EnvironmentElement('URI'), $Match)) $this->Path($Match[1]); else $this->Path(''); } /** * Resolve optional output modifying file extensions (rss, json, etc) */ $UrlParts = explode('/', $this->Path()); $Last = array_slice($UrlParts, -1, 1); $LastParam = array_pop($Last); $Match = array(); if (preg_match('/^(.+)\.([^.]{1,4})$/', $LastParam, $Match)) { $this->OutputFormat($Match[2]); $this->Filename($Match[0]); //$this->Path(implode('/',array_slice($UrlParts, 0, -1))); } /** * Resolve WebRoot */ // Attempt to get the webroot from the server $WebRoot = FALSE; if (!$WebRoot) { $WebRoot = explode('/', GetValue('PHP_SELF', $_SERVER, '')); // Look for index.php to figure out where the web root is. $Key = array_search('index.php', $WebRoot); if ($Key !== FALSE) { $WebRoot = implode('/', array_slice($WebRoot, 0, $Key)); } else { // Could not determine webroot. $WebRoot = ''; } } $ParsedWebRoot = trim($WebRoot,'/'); $this->WebRoot($ParsedWebRoot); /** * Resolve Domain */ $Domain = FALSE; if ($Domain === FALSE || $Domain == '') $Domain = $this->Host(); if ($Domain != '' && $Domain !== FALSE) { if (!stristr($Domain,'://')) $Domain = $this->Scheme().'://'.$Domain; $Domain = trim($Domain, '/'); } $this->Domain($Domain); $this->_Parsing = FALSE; $this->_HaveParsedRequest = TRUE; }
php
protected function _ParseRequest() { $this->_Parsing = TRUE; /** * Resolve final request to send to dispatcher */ $Path = $this->_EnvironmentElement('URI'); // Get the dispatch string from the URI if($Path !== FALSE) { $this->Path(trim($Path, '/')); } else { $Expression = '/^(?:\/?'.str_replace('/', '\/', $this->_EnvironmentElement('Folder')).')?(?:'.$this->_EnvironmentElement('Script').')?\/?(.*?)\/?(?:[#?].*)?$/i'; if (preg_match($Expression, $this->_EnvironmentElement('URI'), $Match)) $this->Path($Match[1]); else $this->Path(''); } /** * Resolve optional output modifying file extensions (rss, json, etc) */ $UrlParts = explode('/', $this->Path()); $Last = array_slice($UrlParts, -1, 1); $LastParam = array_pop($Last); $Match = array(); if (preg_match('/^(.+)\.([^.]{1,4})$/', $LastParam, $Match)) { $this->OutputFormat($Match[2]); $this->Filename($Match[0]); //$this->Path(implode('/',array_slice($UrlParts, 0, -1))); } /** * Resolve WebRoot */ // Attempt to get the webroot from the server $WebRoot = FALSE; if (!$WebRoot) { $WebRoot = explode('/', GetValue('PHP_SELF', $_SERVER, '')); // Look for index.php to figure out where the web root is. $Key = array_search('index.php', $WebRoot); if ($Key !== FALSE) { $WebRoot = implode('/', array_slice($WebRoot, 0, $Key)); } else { // Could not determine webroot. $WebRoot = ''; } } $ParsedWebRoot = trim($WebRoot,'/'); $this->WebRoot($ParsedWebRoot); /** * Resolve Domain */ $Domain = FALSE; if ($Domain === FALSE || $Domain == '') $Domain = $this->Host(); if ($Domain != '' && $Domain !== FALSE) { if (!stristr($Domain,'://')) $Domain = $this->Scheme().'://'.$Domain; $Domain = trim($Domain, '/'); } $this->Domain($Domain); $this->_Parsing = FALSE; $this->_HaveParsedRequest = TRUE; }
[ "protected", "function", "_ParseRequest", "(", ")", "{", "$", "this", "->", "_Parsing", "=", "TRUE", ";", "/**\n * Resolve final request to send to dispatcher\n */", "$", "Path", "=", "$", "this", "->", "_EnvironmentElement", "(", "'URI'", ")", ";", "// Get the dispatch string from the URI", "if", "(", "$", "Path", "!==", "FALSE", ")", "{", "$", "this", "->", "Path", "(", "trim", "(", "$", "Path", ",", "'/'", ")", ")", ";", "}", "else", "{", "$", "Expression", "=", "'/^(?:\\/?'", ".", "str_replace", "(", "'/'", ",", "'\\/'", ",", "$", "this", "->", "_EnvironmentElement", "(", "'Folder'", ")", ")", ".", "')?(?:'", ".", "$", "this", "->", "_EnvironmentElement", "(", "'Script'", ")", ".", "')?\\/?(.*?)\\/?(?:[#?].*)?$/i'", ";", "if", "(", "preg_match", "(", "$", "Expression", ",", "$", "this", "->", "_EnvironmentElement", "(", "'URI'", ")", ",", "$", "Match", ")", ")", "$", "this", "->", "Path", "(", "$", "Match", "[", "1", "]", ")", ";", "else", "$", "this", "->", "Path", "(", "''", ")", ";", "}", "/**\n * Resolve optional output modifying file extensions (rss, json, etc)\n */", "$", "UrlParts", "=", "explode", "(", "'/'", ",", "$", "this", "->", "Path", "(", ")", ")", ";", "$", "Last", "=", "array_slice", "(", "$", "UrlParts", ",", "-", "1", ",", "1", ")", ";", "$", "LastParam", "=", "array_pop", "(", "$", "Last", ")", ";", "$", "Match", "=", "array", "(", ")", ";", "if", "(", "preg_match", "(", "'/^(.+)\\.([^.]{1,4})$/'", ",", "$", "LastParam", ",", "$", "Match", ")", ")", "{", "$", "this", "->", "OutputFormat", "(", "$", "Match", "[", "2", "]", ")", ";", "$", "this", "->", "Filename", "(", "$", "Match", "[", "0", "]", ")", ";", "//$this->Path(implode('/',array_slice($UrlParts, 0, -1)));", "}", "/**\n * Resolve WebRoot\n */", "// Attempt to get the webroot from the server", "$", "WebRoot", "=", "FALSE", ";", "if", "(", "!", "$", "WebRoot", ")", "{", "$", "WebRoot", "=", "explode", "(", "'/'", ",", "GetValue", "(", "'PHP_SELF'", ",", "$", "_SERVER", ",", "''", ")", ")", ";", "// Look for index.php to figure out where the web root is.", "$", "Key", "=", "array_search", "(", "'index.php'", ",", "$", "WebRoot", ")", ";", "if", "(", "$", "Key", "!==", "FALSE", ")", "{", "$", "WebRoot", "=", "implode", "(", "'/'", ",", "array_slice", "(", "$", "WebRoot", ",", "0", ",", "$", "Key", ")", ")", ";", "}", "else", "{", "// Could not determine webroot.", "$", "WebRoot", "=", "''", ";", "}", "}", "$", "ParsedWebRoot", "=", "trim", "(", "$", "WebRoot", ",", "'/'", ")", ";", "$", "this", "->", "WebRoot", "(", "$", "ParsedWebRoot", ")", ";", "/**\n * Resolve Domain\n */", "$", "Domain", "=", "FALSE", ";", "if", "(", "$", "Domain", "===", "FALSE", "||", "$", "Domain", "==", "''", ")", "$", "Domain", "=", "$", "this", "->", "Host", "(", ")", ";", "if", "(", "$", "Domain", "!=", "''", "&&", "$", "Domain", "!==", "FALSE", ")", "{", "if", "(", "!", "stristr", "(", "$", "Domain", ",", "'://'", ")", ")", "$", "Domain", "=", "$", "this", "->", "Scheme", "(", ")", ".", "'://'", ".", "$", "Domain", ";", "$", "Domain", "=", "trim", "(", "$", "Domain", ",", "'/'", ")", ";", "}", "$", "this", "->", "Domain", "(", "$", "Domain", ")", ";", "$", "this", "->", "_Parsing", "=", "FALSE", ";", "$", "this", "->", "_HaveParsedRequest", "=", "TRUE", ";", "}" ]
Parse the Environment data into the ParsedRequest array. This method analyzes the Request environment and produces the ParsedRequest array which contains the Path and OutputFormat keys. These are used by the Dispatcher to decide which controller and method to invoke. @return void
[ "Parse", "the", "Environment", "data", "into", "the", "ParsedRequest", "array", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L487-L562
7,654
bishopb/vanilla
library/core/class.request.php
Gdn_Request.Post
public function Post($Key = NULL, $Default = NULL) { if ($Key === NULL) return $this->GetRequestArguments (self::INPUT_POST); else return $this->GetValueFrom(self::INPUT_POST, $Key, $Default); }
php
public function Post($Key = NULL, $Default = NULL) { if ($Key === NULL) return $this->GetRequestArguments (self::INPUT_POST); else return $this->GetValueFrom(self::INPUT_POST, $Key, $Default); }
[ "public", "function", "Post", "(", "$", "Key", "=", "NULL", ",", "$", "Default", "=", "NULL", ")", "{", "if", "(", "$", "Key", "===", "NULL", ")", "return", "$", "this", "->", "GetRequestArguments", "(", "self", "::", "INPUT_POST", ")", ";", "else", "return", "$", "this", "->", "GetValueFrom", "(", "self", "::", "INPUT_POST", ",", "$", "Key", ",", "$", "Default", ")", ";", "}" ]
Get a value from the post array or return the entire POST array. @param string|null $Key The key of the post item or null to return the entire array. @param mixed $Default The value to return if the item isn't set. @return mixed
[ "Get", "a", "value", "from", "the", "post", "array", "or", "return", "the", "entire", "POST", "array", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L667-L672
7,655
bishopb/vanilla
library/core/class.request.php
Gdn_Request.Merged
public function Merged($Key = NULL, $Default = NULL) { $Merged = array(); $QueryOrder = array( self::INPUT_CUSTOM, self::INPUT_GET, self::INPUT_POST, self::INPUT_FILES, self::INPUT_SERVER, self::INPUT_ENV, self::INPUT_COOKIES ); $NumDataTypes = sizeof($QueryOrder); for ($i=$NumDataTypes; $i > 0; $i--) { $DataType = $QueryOrder[$i-1]; if (!array_key_exists($DataType, $this->_RequestArguments)) continue; $Merged = array_merge($Merged, $this->_RequestArguments[$DataType]); } return (is_null($Key)) ? $Merged : GetValue($Key, $Merged, $Default); }
php
public function Merged($Key = NULL, $Default = NULL) { $Merged = array(); $QueryOrder = array( self::INPUT_CUSTOM, self::INPUT_GET, self::INPUT_POST, self::INPUT_FILES, self::INPUT_SERVER, self::INPUT_ENV, self::INPUT_COOKIES ); $NumDataTypes = sizeof($QueryOrder); for ($i=$NumDataTypes; $i > 0; $i--) { $DataType = $QueryOrder[$i-1]; if (!array_key_exists($DataType, $this->_RequestArguments)) continue; $Merged = array_merge($Merged, $this->_RequestArguments[$DataType]); } return (is_null($Key)) ? $Merged : GetValue($Key, $Merged, $Default); }
[ "public", "function", "Merged", "(", "$", "Key", "=", "NULL", ",", "$", "Default", "=", "NULL", ")", "{", "$", "Merged", "=", "array", "(", ")", ";", "$", "QueryOrder", "=", "array", "(", "self", "::", "INPUT_CUSTOM", ",", "self", "::", "INPUT_GET", ",", "self", "::", "INPUT_POST", ",", "self", "::", "INPUT_FILES", ",", "self", "::", "INPUT_SERVER", ",", "self", "::", "INPUT_ENV", ",", "self", "::", "INPUT_COOKIES", ")", ";", "$", "NumDataTypes", "=", "sizeof", "(", "$", "QueryOrder", ")", ";", "for", "(", "$", "i", "=", "$", "NumDataTypes", ";", "$", "i", ">", "0", ";", "$", "i", "--", ")", "{", "$", "DataType", "=", "$", "QueryOrder", "[", "$", "i", "-", "1", "]", ";", "if", "(", "!", "array_key_exists", "(", "$", "DataType", ",", "$", "this", "->", "_RequestArguments", ")", ")", "continue", ";", "$", "Merged", "=", "array_merge", "(", "$", "Merged", ",", "$", "this", "->", "_RequestArguments", "[", "$", "DataType", "]", ")", ";", "}", "return", "(", "is_null", "(", "$", "Key", ")", ")", "?", "$", "Merged", ":", "GetValue", "(", "$", "Key", ",", "$", "Merged", ",", "$", "Default", ")", ";", "}" ]
Get a value from the merged param array or return the entire merged array @param string|null $Key The key of the post item or null to return the entire array. @param mixed $Default The value to return if the item isn't set. @return mixed
[ "Get", "a", "value", "from", "the", "merged", "param", "array", "or", "return", "the", "entire", "merged", "array" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L694-L713
7,656
bishopb/vanilla
library/core/class.request.php
Gdn_Request._SetRequestArguments
protected function _SetRequestArguments($ParamsType, $ParamsData = NULL) { switch ($ParamsType) { case self::INPUT_GET: $ArgumentData = $_GET; break; case self::INPUT_POST: $ArgumentData = $_POST; break; case self::INPUT_SERVER: $ArgumentData = $_SERVER; break; case self::INPUT_FILES: $ArgumentData = $_FILES; break; case self::INPUT_ENV: $ArgumentData = $_ENV; break; case self::INPUT_COOKIES: $ArgumentData = $_COOKIE; break; case self::INPUT_CUSTOM: $ArgumentData = is_array($ParamsData) ? $ParamsData : array(); break; } $this->_RequestArguments[$ParamsType] = $ArgumentData; }
php
protected function _SetRequestArguments($ParamsType, $ParamsData = NULL) { switch ($ParamsType) { case self::INPUT_GET: $ArgumentData = $_GET; break; case self::INPUT_POST: $ArgumentData = $_POST; break; case self::INPUT_SERVER: $ArgumentData = $_SERVER; break; case self::INPUT_FILES: $ArgumentData = $_FILES; break; case self::INPUT_ENV: $ArgumentData = $_ENV; break; case self::INPUT_COOKIES: $ArgumentData = $_COOKIE; break; case self::INPUT_CUSTOM: $ArgumentData = is_array($ParamsData) ? $ParamsData : array(); break; } $this->_RequestArguments[$ParamsType] = $ArgumentData; }
[ "protected", "function", "_SetRequestArguments", "(", "$", "ParamsType", ",", "$", "ParamsData", "=", "NULL", ")", "{", "switch", "(", "$", "ParamsType", ")", "{", "case", "self", "::", "INPUT_GET", ":", "$", "ArgumentData", "=", "$", "_GET", ";", "break", ";", "case", "self", "::", "INPUT_POST", ":", "$", "ArgumentData", "=", "$", "_POST", ";", "break", ";", "case", "self", "::", "INPUT_SERVER", ":", "$", "ArgumentData", "=", "$", "_SERVER", ";", "break", ";", "case", "self", "::", "INPUT_FILES", ":", "$", "ArgumentData", "=", "$", "_FILES", ";", "break", ";", "case", "self", "::", "INPUT_ENV", ":", "$", "ArgumentData", "=", "$", "_ENV", ";", "break", ";", "case", "self", "::", "INPUT_COOKIES", ":", "$", "ArgumentData", "=", "$", "_COOKIE", ";", "break", ";", "case", "self", "::", "INPUT_CUSTOM", ":", "$", "ArgumentData", "=", "is_array", "(", "$", "ParamsData", ")", "?", "$", "ParamsData", ":", "array", "(", ")", ";", "break", ";", "}", "$", "this", "->", "_RequestArguments", "[", "$", "ParamsType", "]", "=", "$", "ArgumentData", ";", "}" ]
Attach an array of request arguments to the request. @param int $ParamsType type of data to import. One of the self::INPUT_* constants @param array $ParamsData optional data array to import if ParamsType is INPUT_CUSTOM @return void
[ "Attach", "an", "array", "of", "request", "arguments", "to", "the", "request", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L722-L754
7,657
bishopb/vanilla
library/core/class.request.php
Gdn_Request.WithArgs
public function WithArgs() { $ArgAliasList = func_get_args(); if (count($ArgAliasList)) foreach ($ArgAliasList as $ArgAlias) { $this->_SetRequestArguments(strtolower($ArgAlias)); } return $this; }
php
public function WithArgs() { $ArgAliasList = func_get_args(); if (count($ArgAliasList)) foreach ($ArgAliasList as $ArgAlias) { $this->_SetRequestArguments(strtolower($ArgAlias)); } return $this; }
[ "public", "function", "WithArgs", "(", ")", "{", "$", "ArgAliasList", "=", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "ArgAliasList", ")", ")", "foreach", "(", "$", "ArgAliasList", "as", "$", "ArgAlias", ")", "{", "$", "this", "->", "_SetRequestArguments", "(", "strtolower", "(", "$", "ArgAlias", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Chainable Superglobal arguments setter This method expects a variable number of parameters, each of which need to be a defined INPUT_* constant, and will interpret these as superglobal references. These constants each refer to a specific PHP superglobal and including them here causes their data to be imported into the request object. @param self::INPUT_* @flow chain @return Gdn_Request
[ "Chainable", "Superglobal", "arguments", "setter" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L922-L930
7,658
bishopb/vanilla
library/core/class.request.php
Gdn_Request.WithControllerMethod
public function WithControllerMethod($Controller, $Method = NULL, $Args = array()) { if (is_a($Controller, 'Gdn_Controller')) { // Convert object to string $Matches = array(); preg_match('/^(.*)Controller$/',get_class($Controller),$Matches); $Controller = $Matches[1]; } $Method = is_null($Method) ? 'index' : $Method; $Path = trim(implode('/',array_merge(array($Controller,$Method),$Args)),'/'); $this->_EnvironmentElement('URI', $Path); return $this; }
php
public function WithControllerMethod($Controller, $Method = NULL, $Args = array()) { if (is_a($Controller, 'Gdn_Controller')) { // Convert object to string $Matches = array(); preg_match('/^(.*)Controller$/',get_class($Controller),$Matches); $Controller = $Matches[1]; } $Method = is_null($Method) ? 'index' : $Method; $Path = trim(implode('/',array_merge(array($Controller,$Method),$Args)),'/'); $this->_EnvironmentElement('URI', $Path); return $this; }
[ "public", "function", "WithControllerMethod", "(", "$", "Controller", ",", "$", "Method", "=", "NULL", ",", "$", "Args", "=", "array", "(", ")", ")", "{", "if", "(", "is_a", "(", "$", "Controller", ",", "'Gdn_Controller'", ")", ")", "{", "// Convert object to string", "$", "Matches", "=", "array", "(", ")", ";", "preg_match", "(", "'/^(.*)Controller$/'", ",", "get_class", "(", "$", "Controller", ")", ",", "$", "Matches", ")", ";", "$", "Controller", "=", "$", "Matches", "[", "1", "]", ";", "}", "$", "Method", "=", "is_null", "(", "$", "Method", ")", "?", "'index'", ":", "$", "Method", ";", "$", "Path", "=", "trim", "(", "implode", "(", "'/'", ",", "array_merge", "(", "array", "(", "$", "Controller", ",", "$", "Method", ")", ",", "$", "Args", ")", ")", ",", "'/'", ")", ";", "$", "this", "->", "_EnvironmentElement", "(", "'URI'", ",", "$", "Path", ")", ";", "return", "$", "this", ";", "}" ]
Chainable URI Setter, source is a controller + method + args list @param $Controller Gdn_Controller Object or string controller name. @param $Method Optional name of the method to call. Omit or NULL for default (Index). @param $Args Optional argument list to forward to the method. Omit for none. @flow chain @return Gdn_Request
[ "Chainable", "URI", "Setter", "source", "is", "a", "controller", "+", "method", "+", "args", "list" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.request.php#L957-L969
7,659
mickrip/fwoot-core
src/Fw/Config.php
Config.load
static function load($filename) { if (isset(self::$stack[$filename])) return self::$stack[$filename]; $path = self::get("apppath") . "config" . DS . $filename; if (!file_exists($path)) throw new \Exception("Config file '$filename' not found'"); $config_data = include($path); self::set($filename, $config_data); return $config_data; }
php
static function load($filename) { if (isset(self::$stack[$filename])) return self::$stack[$filename]; $path = self::get("apppath") . "config" . DS . $filename; if (!file_exists($path)) throw new \Exception("Config file '$filename' not found'"); $config_data = include($path); self::set($filename, $config_data); return $config_data; }
[ "static", "function", "load", "(", "$", "filename", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "stack", "[", "$", "filename", "]", ")", ")", "return", "self", "::", "$", "stack", "[", "$", "filename", "]", ";", "$", "path", "=", "self", "::", "get", "(", "\"apppath\"", ")", ".", "\"config\"", ".", "DS", ".", "$", "filename", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "throw", "new", "\\", "Exception", "(", "\"Config file '$filename' not found'\"", ")", ";", "$", "config_data", "=", "include", "(", "$", "path", ")", ";", "self", "::", "set", "(", "$", "filename", ",", "$", "config_data", ")", ";", "return", "$", "config_data", ";", "}" ]
Loads a php file which returns an array of config data @param $filename @return mixed
[ "Loads", "a", "php", "file", "which", "returns", "an", "array", "of", "config", "data" ]
10fae2ee4b2c85454bc91067f0f9adeef64fdd4d
https://github.com/mickrip/fwoot-core/blob/10fae2ee4b2c85454bc91067f0f9adeef64fdd4d/src/Fw/Config.php#L29-L37
7,660
mszewcz/php-light-framework
src/Html/Form/FormStatus.php
FormStatus.generate
public function generate(): string { $status = Tags::NBSP; if ($this->statusData['status-type'] !== '' && $this->statusData['status-text'] !== '') { $status = [ Tags::div( $this->getConstant($this->statusData['status-text']), ['class' => $this->getConstant($this->statusData['status-type'])] ) ]; } return Tags::div($status, ['class' => 'status']); }
php
public function generate(): string { $status = Tags::NBSP; if ($this->statusData['status-type'] !== '' && $this->statusData['status-text'] !== '') { $status = [ Tags::div( $this->getConstant($this->statusData['status-text']), ['class' => $this->getConstant($this->statusData['status-type'])] ) ]; } return Tags::div($status, ['class' => 'status']); }
[ "public", "function", "generate", "(", ")", ":", "string", "{", "$", "status", "=", "Tags", "::", "NBSP", ";", "if", "(", "$", "this", "->", "statusData", "[", "'status-type'", "]", "!==", "''", "&&", "$", "this", "->", "statusData", "[", "'status-text'", "]", "!==", "''", ")", "{", "$", "status", "=", "[", "Tags", "::", "div", "(", "$", "this", "->", "getConstant", "(", "$", "this", "->", "statusData", "[", "'status-text'", "]", ")", ",", "[", "'class'", "=>", "$", "this", "->", "getConstant", "(", "$", "this", "->", "statusData", "[", "'status-type'", "]", ")", "]", ")", "]", ";", "}", "return", "Tags", "::", "div", "(", "$", "status", ",", "[", "'class'", "=>", "'status'", "]", ")", ";", "}" ]
Generates FormStatus and returns it @return string
[ "Generates", "FormStatus", "and", "returns", "it" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Form/FormStatus.php#L50-L62
7,661
popy-dev/popy-calendar
src/Parser/ResultMapper/StandardDateFragmented.php
StandardDateFragmented.determineWeekIndex
protected function determineWeekIndex(DateLexerResult $parts) { if (null === $w = $parts->get('W')) { return null; } return intval($w) - 1; }
php
protected function determineWeekIndex(DateLexerResult $parts) { if (null === $w = $parts->get('W')) { return null; } return intval($w) - 1; }
[ "protected", "function", "determineWeekIndex", "(", "DateLexerResult", "$", "parts", ")", "{", "if", "(", "null", "===", "$", "w", "=", "$", "parts", "->", "get", "(", "'W'", ")", ")", "{", "return", "null", ";", "}", "return", "intval", "(", "$", "w", ")", "-", "1", ";", "}" ]
Determine ISO week index from iso week number. @param DateLexerResult $parts @return integer|null
[ "Determine", "ISO", "week", "index", "from", "iso", "week", "number", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/Parser/ResultMapper/StandardDateFragmented.php#L112-L119
7,662
wb-crowdfusion/wb-lib
classes/filters/WbjsonFilterer.php
WbjsonFilterer.format
public function format() { $json = (string) $this->getParameter('value'); if (empty($json)) { return '""'; } $html = (boolean) $this->getParameter('html'); return JSONUtils::format($json, $html); }
php
public function format() { $json = (string) $this->getParameter('value'); if (empty($json)) { return '""'; } $html = (boolean) $this->getParameter('html'); return JSONUtils::format($json, $html); }
[ "public", "function", "format", "(", ")", "{", "$", "json", "=", "(", "string", ")", "$", "this", "->", "getParameter", "(", "'value'", ")", ";", "if", "(", "empty", "(", "$", "json", ")", ")", "{", "return", "'\"\"'", ";", "}", "$", "html", "=", "(", "boolean", ")", "$", "this", "->", "getParameter", "(", "'html'", ")", ";", "return", "JSONUtils", "::", "format", "(", "$", "json", ",", "$", "html", ")", ";", "}" ]
Indents a flat JSON string to make it more human-readable @return string
[ "Indents", "a", "flat", "JSON", "string", "to", "make", "it", "more", "human", "-", "readable" ]
972b0f1d4aa2fa538ee6c6b436ac84849a579326
https://github.com/wb-crowdfusion/wb-lib/blob/972b0f1d4aa2fa538ee6c6b436ac84849a579326/classes/filters/WbjsonFilterer.php#L10-L19
7,663
tacowordpress/util
src/Util/Color.php
Color.gauge
public static function gauge($val, $floor = 0) { $colors = self::getGaugeColors(); $key_size = 100 / count($colors); $key = floor($val / $key_size); return (array_key_exists((int) $key, $colors)) ? $colors[$key] : end($colors); }
php
public static function gauge($val, $floor = 0) { $colors = self::getGaugeColors(); $key_size = 100 / count($colors); $key = floor($val / $key_size); return (array_key_exists((int) $key, $colors)) ? $colors[$key] : end($colors); }
[ "public", "static", "function", "gauge", "(", "$", "val", ",", "$", "floor", "=", "0", ")", "{", "$", "colors", "=", "self", "::", "getGaugeColors", "(", ")", ";", "$", "key_size", "=", "100", "/", "count", "(", "$", "colors", ")", ";", "$", "key", "=", "floor", "(", "$", "val", "/", "$", "key_size", ")", ";", "return", "(", "array_key_exists", "(", "(", "int", ")", "$", "key", ",", "$", "colors", ")", ")", "?", "$", "colors", "[", "$", "key", "]", ":", "end", "(", "$", "colors", ")", ";", "}" ]
Turn a val to a color for a gauge @param $val Val from 0 to 100 @return string Hex
[ "Turn", "a", "val", "to", "a", "color", "for", "a", "gauge" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Color.php#L14-L20
7,664
tacowordpress/util
src/Util/Color.php
Color.hexToRgb
public static function hexToRgb($hex) { $hex = preg_replace('/[^a-zA-Z0-9]/', '', $hex); if (strlen($hex) === 3) { $hex = preg_replace('/([a-f0-9])/i', "$1$1", $hex); } return array_combine(array('r','g','b'), array_map('hexdec', str_split($hex, 2))); }
php
public static function hexToRgb($hex) { $hex = preg_replace('/[^a-zA-Z0-9]/', '', $hex); if (strlen($hex) === 3) { $hex = preg_replace('/([a-f0-9])/i', "$1$1", $hex); } return array_combine(array('r','g','b'), array_map('hexdec', str_split($hex, 2))); }
[ "public", "static", "function", "hexToRgb", "(", "$", "hex", ")", "{", "$", "hex", "=", "preg_replace", "(", "'/[^a-zA-Z0-9]/'", ",", "''", ",", "$", "hex", ")", ";", "if", "(", "strlen", "(", "$", "hex", ")", "===", "3", ")", "{", "$", "hex", "=", "preg_replace", "(", "'/([a-f0-9])/i'", ",", "\"$1$1\"", ",", "$", "hex", ")", ";", "}", "return", "array_combine", "(", "array", "(", "'r'", ",", "'g'", ",", "'b'", ")", ",", "array_map", "(", "'hexdec'", ",", "str_split", "(", "$", "hex", ",", "2", ")", ")", ")", ";", "}" ]
Convert hex to RGB values @param string $hex Hex (3 or 6 chars, with or without leading #) @return array RGB values with 'r', 'g', and 'b' keys
[ "Convert", "hex", "to", "RGB", "values" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Color.php#L61-L68
7,665
tacowordpress/util
src/Util/Color.php
Color.colorToHex
public static function colorToHex($color) { $colors = array( 'maroon' => '800000', 'red' => 'FF0000', 'orange' => 'FFA500', 'yellow' => 'FFFF00', 'olive' => '808000', 'purple' => '800080', 'fuchsia' => 'FF00FF', 'white' => 'FFFFFF', 'lime' => '00FF00', 'green' => '008000', 'navy' => '000080', 'blue' => '0000FF', 'aqua' => '00FFFF', 'teal' => '008080', 'black' => '000000', 'silver' => 'C0C0C0', 'gray' => '808080', ); if (array_key_exists($color, $colors)) { return $colors[$color]; } $color_pattern = '/rgb\((.*?)\)/'; preg_match($color_pattern, $color, $matches); if (is_array($matches) && count($matches) > 0) { $rgb = explode(',', $matches[1]); if (is_array($rgb) && count($rgb) === 3) { return self::RGBToHex($rgb[0], $rgb[1], $rgb[2]); } } return $color; }
php
public static function colorToHex($color) { $colors = array( 'maroon' => '800000', 'red' => 'FF0000', 'orange' => 'FFA500', 'yellow' => 'FFFF00', 'olive' => '808000', 'purple' => '800080', 'fuchsia' => 'FF00FF', 'white' => 'FFFFFF', 'lime' => '00FF00', 'green' => '008000', 'navy' => '000080', 'blue' => '0000FF', 'aqua' => '00FFFF', 'teal' => '008080', 'black' => '000000', 'silver' => 'C0C0C0', 'gray' => '808080', ); if (array_key_exists($color, $colors)) { return $colors[$color]; } $color_pattern = '/rgb\((.*?)\)/'; preg_match($color_pattern, $color, $matches); if (is_array($matches) && count($matches) > 0) { $rgb = explode(',', $matches[1]); if (is_array($rgb) && count($rgb) === 3) { return self::RGBToHex($rgb[0], $rgb[1], $rgb[2]); } } return $color; }
[ "public", "static", "function", "colorToHex", "(", "$", "color", ")", "{", "$", "colors", "=", "array", "(", "'maroon'", "=>", "'800000'", ",", "'red'", "=>", "'FF0000'", ",", "'orange'", "=>", "'FFA500'", ",", "'yellow'", "=>", "'FFFF00'", ",", "'olive'", "=>", "'808000'", ",", "'purple'", "=>", "'800080'", ",", "'fuchsia'", "=>", "'FF00FF'", ",", "'white'", "=>", "'FFFFFF'", ",", "'lime'", "=>", "'00FF00'", ",", "'green'", "=>", "'008000'", ",", "'navy'", "=>", "'000080'", ",", "'blue'", "=>", "'0000FF'", ",", "'aqua'", "=>", "'00FFFF'", ",", "'teal'", "=>", "'008080'", ",", "'black'", "=>", "'000000'", ",", "'silver'", "=>", "'C0C0C0'", ",", "'gray'", "=>", "'808080'", ",", ")", ";", "if", "(", "array_key_exists", "(", "$", "color", ",", "$", "colors", ")", ")", "{", "return", "$", "colors", "[", "$", "color", "]", ";", "}", "$", "color_pattern", "=", "'/rgb\\((.*?)\\)/'", ";", "preg_match", "(", "$", "color_pattern", ",", "$", "color", ",", "$", "matches", ")", ";", "if", "(", "is_array", "(", "$", "matches", ")", "&&", "count", "(", "$", "matches", ")", ">", "0", ")", "{", "$", "rgb", "=", "explode", "(", "','", ",", "$", "matches", "[", "1", "]", ")", ";", "if", "(", "is_array", "(", "$", "rgb", ")", "&&", "count", "(", "$", "rgb", ")", "===", "3", ")", "{", "return", "self", "::", "RGBToHex", "(", "$", "rgb", "[", "0", "]", ",", "$", "rgb", "[", "1", "]", ",", "$", "rgb", "[", "2", "]", ")", ";", "}", "}", "return", "$", "color", ";", "}" ]
Convert color name to hex @param string $color Color @return string
[ "Convert", "color", "name", "to", "hex" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Color.php#L76-L111
7,666
marando/phpSOFA
src/Marando/IAU/iauUt1tt.php
iauUt1tt.Ut1tt
public static function Ut1tt($ut11, $ut12, $dt, &$tt1, &$tt2) { $dtd; /* Result, safeguarding precision. */ $dtd = $dt / DAYSEC; if ($ut11 > $ut12) { $tt1 = $ut11; $tt2 = $ut12 + $dtd; } else { $tt1 = $ut11 + $dtd; $tt2 = $ut12; } /* Status (always OK). */ return 0; }
php
public static function Ut1tt($ut11, $ut12, $dt, &$tt1, &$tt2) { $dtd; /* Result, safeguarding precision. */ $dtd = $dt / DAYSEC; if ($ut11 > $ut12) { $tt1 = $ut11; $tt2 = $ut12 + $dtd; } else { $tt1 = $ut11 + $dtd; $tt2 = $ut12; } /* Status (always OK). */ return 0; }
[ "public", "static", "function", "Ut1tt", "(", "$", "ut11", ",", "$", "ut12", ",", "$", "dt", ",", "&", "$", "tt1", ",", "&", "$", "tt2", ")", "{", "$", "dtd", ";", "/* Result, safeguarding precision. */", "$", "dtd", "=", "$", "dt", "/", "DAYSEC", ";", "if", "(", "$", "ut11", ">", "$", "ut12", ")", "{", "$", "tt1", "=", "$", "ut11", ";", "$", "tt2", "=", "$", "ut12", "+", "$", "dtd", ";", "}", "else", "{", "$", "tt1", "=", "$", "ut11", "+", "$", "dtd", ";", "$", "tt2", "=", "$", "ut12", ";", "}", "/* Status (always OK). */", "return", "0", ";", "}" ]
- - - - - - - - - i a u U t 1 t t - - - - - - - - - Time scale transformation: Universal Time, UT1, to Terrestrial Time, TT. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: canonical. Given: ut11,ut12 double UT1 as a 2-part Julian Date dt double TT-UT1 in seconds Returned: tt1,tt2 double TT as a 2-part Julian Date Returned (function value): int status: 0 = OK Notes: 1) ut11+ut12 is Julian Date, apportioned in any convenient way between the two arguments, for example where ut11 is the Julian Day Number and ut12 is the fraction of a day. The returned tt1,tt2 follow suit. 2) The argument dt is classical Delta T. Reference: Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann (ed), University Science Books (1992) This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "U", "t", "1", "t", "t", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauUt1tt.php#L50-L66
7,667
dlabas/DlcCategory
src/DlcCategory/Mapper/Category.php
Category.getAllRootIds
public function getAllRootIds() { $entityClass = $this->getEntityClass(); $query = $this->getObjectManager()->createQuery('SELECT DISTINCT c.root FROM ' . $entityClass . ' c'); $result = $query->getResult(); $rootIds = array(); foreach ($result as $resultArray) { $rootIds[] = $resultArray['root']; } return $rootIds; }
php
public function getAllRootIds() { $entityClass = $this->getEntityClass(); $query = $this->getObjectManager()->createQuery('SELECT DISTINCT c.root FROM ' . $entityClass . ' c'); $result = $query->getResult(); $rootIds = array(); foreach ($result as $resultArray) { $rootIds[] = $resultArray['root']; } return $rootIds; }
[ "public", "function", "getAllRootIds", "(", ")", "{", "$", "entityClass", "=", "$", "this", "->", "getEntityClass", "(", ")", ";", "$", "query", "=", "$", "this", "->", "getObjectManager", "(", ")", "->", "createQuery", "(", "'SELECT DISTINCT c.root FROM '", ".", "$", "entityClass", ".", "' c'", ")", ";", "$", "result", "=", "$", "query", "->", "getResult", "(", ")", ";", "$", "rootIds", "=", "array", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "resultArray", ")", "{", "$", "rootIds", "[", "]", "=", "$", "resultArray", "[", "'root'", "]", ";", "}", "return", "$", "rootIds", ";", "}" ]
Returns a list of all root category ids @return array
[ "Returns", "a", "list", "of", "all", "root", "category", "ids" ]
cd4dbcae8c1c6a373f96fb0ad15ccebad383f256
https://github.com/dlabas/DlcCategory/blob/cd4dbcae8c1c6a373f96fb0ad15ccebad383f256/src/DlcCategory/Mapper/Category.php#L13-L26
7,668
dlabas/DlcCategory
src/DlcCategory/Mapper/Category.php
Category.findOneByName
public function findOneByName($name) { $entityClass = $this->getEntityClass(); return $this->getObjectManager() ->getRepository($entityClass) ->findOneByName($name); }
php
public function findOneByName($name) { $entityClass = $this->getEntityClass(); return $this->getObjectManager() ->getRepository($entityClass) ->findOneByName($name); }
[ "public", "function", "findOneByName", "(", "$", "name", ")", "{", "$", "entityClass", "=", "$", "this", "->", "getEntityClass", "(", ")", ";", "return", "$", "this", "->", "getObjectManager", "(", ")", "->", "getRepository", "(", "$", "entityClass", ")", "->", "findOneByName", "(", "$", "name", ")", ";", "}" ]
Find one category by it's name @param string $name
[ "Find", "one", "category", "by", "it", "s", "name" ]
cd4dbcae8c1c6a373f96fb0ad15ccebad383f256
https://github.com/dlabas/DlcCategory/blob/cd4dbcae8c1c6a373f96fb0ad15ccebad383f256/src/DlcCategory/Mapper/Category.php#L33-L40
7,669
dlabas/DlcCategory
src/DlcCategory/Mapper/Category.php
Category.findOneByTitle
public function findOneByTitle($title) { $entityClass = $this->getEntityClass(); return $this->getObjectManager() ->getRepository($entityClass) ->findOneByTitle($title); }
php
public function findOneByTitle($title) { $entityClass = $this->getEntityClass(); return $this->getObjectManager() ->getRepository($entityClass) ->findOneByTitle($title); }
[ "public", "function", "findOneByTitle", "(", "$", "title", ")", "{", "$", "entityClass", "=", "$", "this", "->", "getEntityClass", "(", ")", ";", "return", "$", "this", "->", "getObjectManager", "(", ")", "->", "getRepository", "(", "$", "entityClass", ")", "->", "findOneByTitle", "(", "$", "title", ")", ";", "}" ]
Find one category by it's title @param string $title
[ "Find", "one", "category", "by", "it", "s", "title" ]
cd4dbcae8c1c6a373f96fb0ad15ccebad383f256
https://github.com/dlabas/DlcCategory/blob/cd4dbcae8c1c6a373f96fb0ad15ccebad383f256/src/DlcCategory/Mapper/Category.php#L47-L54
7,670
vinala/kernel
src/Database/Drivers/MysqlDriver.php
MysqlDriver.connect
public static function connect($host = null, $database = null, $user = null, $password = null) { if (config('app.setup')) { self::$connection = new MysqlConnector($host, $database, $user, $password); self::$server = self::$connection->connector; } return self::$server; }
php
public static function connect($host = null, $database = null, $user = null, $password = null) { if (config('app.setup')) { self::$connection = new MysqlConnector($host, $database, $user, $password); self::$server = self::$connection->connector; } return self::$server; }
[ "public", "static", "function", "connect", "(", "$", "host", "=", "null", ",", "$", "database", "=", "null", ",", "$", "user", "=", "null", ",", "$", "password", "=", "null", ")", "{", "if", "(", "config", "(", "'app.setup'", ")", ")", "{", "self", "::", "$", "connection", "=", "new", "MysqlConnector", "(", "$", "host", ",", "$", "database", ",", "$", "user", ",", "$", "password", ")", ";", "self", "::", "$", "server", "=", "self", "::", "$", "connection", "->", "connector", ";", "}", "return", "self", "::", "$", "server", ";", "}" ]
Connect to Mysql database server. @param string, string, string, string @return PDO
[ "Connect", "to", "Mysql", "database", "server", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Drivers/MysqlDriver.php#L31-L39
7,671
vinala/kernel
src/Database/Drivers/MysqlDriver.php
MysqlDriver.getColmuns
public function getColmuns($table) { $table = self::table($table); $columns = []; // $data = Database::read("select COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '".Config::get('database.database')."' AND TABLE_NAME = '$table';"); // foreach ($data as $key => $value) { $columns[] = $value['COLUMN_NAME']; } // return $columns; }
php
public function getColmuns($table) { $table = self::table($table); $columns = []; // $data = Database::read("select COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '".Config::get('database.database')."' AND TABLE_NAME = '$table';"); // foreach ($data as $key => $value) { $columns[] = $value['COLUMN_NAME']; } // return $columns; }
[ "public", "function", "getColmuns", "(", "$", "table", ")", "{", "$", "table", "=", "self", "::", "table", "(", "$", "table", ")", ";", "$", "columns", "=", "[", "]", ";", "//", "$", "data", "=", "Database", "::", "read", "(", "\"select COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '\"", ".", "Config", "::", "get", "(", "'database.database'", ")", ".", "\"' AND TABLE_NAME = '$table';\"", ")", ";", "//", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "columns", "[", "]", "=", "$", "value", "[", "'COLUMN_NAME'", "]", ";", "}", "//", "return", "$", "columns", ";", "}" ]
Get columns of data table.
[ "Get", "columns", "of", "data", "table", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Drivers/MysqlDriver.php#L86-L98
7,672
vinala/kernel
src/Database/Drivers/MysqlDriver.php
MysqlDriver.getNormalColumn
public function getNormalColumn($table) { $all = self::getColmuns($table); $incs = self::getIncrement($table); // return Collection::except($incs, $all); }
php
public function getNormalColumn($table) { $all = self::getColmuns($table); $incs = self::getIncrement($table); // return Collection::except($incs, $all); }
[ "public", "function", "getNormalColumn", "(", "$", "table", ")", "{", "$", "all", "=", "self", "::", "getColmuns", "(", "$", "table", ")", ";", "$", "incs", "=", "self", "::", "getIncrement", "(", "$", "table", ")", ";", "//", "return", "Collection", "::", "except", "(", "$", "incs", ",", "$", "all", ")", ";", "}" ]
Get columns of data table without auto increment columns.
[ "Get", "columns", "of", "data", "table", "without", "auto", "increment", "columns", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Drivers/MysqlDriver.php#L120-L126
7,673
wearenolte/wp-endpoints-post
src/Post.php
Post.endpoint_callback
public function endpoint_callback( \WP_REST_Request $request ) { $params = $request->get_params(); $id = $params['id']; $slug = false === $params['slug'] ? false : trim( $params['slug'], '/' ); if ( false === $id && false === $slug ) { return new \WP_Error( self::INVALID_PARAMS, 'The request must have either an id or a slug', [ 'status' => 400 ] ); } $query_args = [ 'post_type' => 'any', 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ]; if ( false !== $id ) { $query_args['p'] = $id; } else { $query_args['name'] = $slug; } $query = new \WP_Query( apply_filters( $this->get_query_filter_name(), $query_args, $request ) ); if ( $query->have_posts() ) { $query->the_post(); $post = $query->post; $data = [ 'id' => $post->ID, 'slug' => $post->post_name, 'type' => Type::get( $post ), 'content' => Content::get( $post ), 'meta' => Meta\Post::get_all_post_meta( $post ), ]; wp_reset_postdata(); return $this->filter_data( $data, $post->ID ); } return new \WP_Error( self::NOT_FOUND, 'Nothing found for this query', [ 'status' => 404 ] ); }
php
public function endpoint_callback( \WP_REST_Request $request ) { $params = $request->get_params(); $id = $params['id']; $slug = false === $params['slug'] ? false : trim( $params['slug'], '/' ); if ( false === $id && false === $slug ) { return new \WP_Error( self::INVALID_PARAMS, 'The request must have either an id or a slug', [ 'status' => 400 ] ); } $query_args = [ 'post_type' => 'any', 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ]; if ( false !== $id ) { $query_args['p'] = $id; } else { $query_args['name'] = $slug; } $query = new \WP_Query( apply_filters( $this->get_query_filter_name(), $query_args, $request ) ); if ( $query->have_posts() ) { $query->the_post(); $post = $query->post; $data = [ 'id' => $post->ID, 'slug' => $post->post_name, 'type' => Type::get( $post ), 'content' => Content::get( $post ), 'meta' => Meta\Post::get_all_post_meta( $post ), ]; wp_reset_postdata(); return $this->filter_data( $data, $post->ID ); } return new \WP_Error( self::NOT_FOUND, 'Nothing found for this query', [ 'status' => 404 ] ); }
[ "public", "function", "endpoint_callback", "(", "\\", "WP_REST_Request", "$", "request", ")", "{", "$", "params", "=", "$", "request", "->", "get_params", "(", ")", ";", "$", "id", "=", "$", "params", "[", "'id'", "]", ";", "$", "slug", "=", "false", "===", "$", "params", "[", "'slug'", "]", "?", "false", ":", "trim", "(", "$", "params", "[", "'slug'", "]", ",", "'/'", ")", ";", "if", "(", "false", "===", "$", "id", "&&", "false", "===", "$", "slug", ")", "{", "return", "new", "\\", "WP_Error", "(", "self", "::", "INVALID_PARAMS", ",", "'The request must have either an id or a slug'", ",", "[", "'status'", "=>", "400", "]", ")", ";", "}", "$", "query_args", "=", "[", "'post_type'", "=>", "'any'", ",", "'no_found_rows'", "=>", "true", ",", "'update_post_meta_cache'", "=>", "false", ",", "'update_post_term_cache'", "=>", "false", ",", "]", ";", "if", "(", "false", "!==", "$", "id", ")", "{", "$", "query_args", "[", "'p'", "]", "=", "$", "id", ";", "}", "else", "{", "$", "query_args", "[", "'name'", "]", "=", "$", "slug", ";", "}", "$", "query", "=", "new", "\\", "WP_Query", "(", "apply_filters", "(", "$", "this", "->", "get_query_filter_name", "(", ")", ",", "$", "query_args", ",", "$", "request", ")", ")", ";", "if", "(", "$", "query", "->", "have_posts", "(", ")", ")", "{", "$", "query", "->", "the_post", "(", ")", ";", "$", "post", "=", "$", "query", "->", "post", ";", "$", "data", "=", "[", "'id'", "=>", "$", "post", "->", "ID", ",", "'slug'", "=>", "$", "post", "->", "post_name", ",", "'type'", "=>", "Type", "::", "get", "(", "$", "post", ")", ",", "'content'", "=>", "Content", "::", "get", "(", "$", "post", ")", ",", "'meta'", "=>", "Meta", "\\", "Post", "::", "get_all_post_meta", "(", "$", "post", ")", ",", "]", ";", "wp_reset_postdata", "(", ")", ";", "return", "$", "this", "->", "filter_data", "(", "$", "data", ",", "$", "post", "->", "ID", ")", ";", "}", "return", "new", "\\", "WP_Error", "(", "self", "::", "NOT_FOUND", ",", "'Nothing found for this query'", ",", "[", "'status'", "=>", "404", "]", ")", ";", "}" ]
Get the post. @param \WP_REST_Request $request The request. @return array|\WP_Error
[ "Get", "the", "post", "." ]
11f17af89a3164faade5bd05be714cc3ab6e3c08
https://github.com/wearenolte/wp-endpoints-post/blob/11f17af89a3164faade5bd05be714cc3ab6e3c08/src/Post.php#L34-L79
7,674
wearenolte/wp-endpoints-post
src/Post.php
Post.get_query_filter_name
private function get_query_filter_name() { $filter_format = trim( $this->filter_format( $this->endpoint ), '_' ); return sprintf( self::QUERY_FILTER, $filter_format ); }
php
private function get_query_filter_name() { $filter_format = trim( $this->filter_format( $this->endpoint ), '_' ); return sprintf( self::QUERY_FILTER, $filter_format ); }
[ "private", "function", "get_query_filter_name", "(", ")", "{", "$", "filter_format", "=", "trim", "(", "$", "this", "->", "filter_format", "(", "$", "this", "->", "endpoint", ")", ",", "'_'", ")", ";", "return", "sprintf", "(", "self", "::", "QUERY_FILTER", ",", "$", "filter_format", ")", ";", "}" ]
Makes sure there is no more _ between and after the filter_format @since 0.2.0 @return String
[ "Makes", "sure", "there", "is", "no", "more", "_", "between", "and", "after", "the", "filter_format" ]
11f17af89a3164faade5bd05be714cc3ab6e3c08
https://github.com/wearenolte/wp-endpoints-post/blob/11f17af89a3164faade5bd05be714cc3ab6e3c08/src/Post.php#L87-L90
7,675
wearenolte/wp-endpoints-post
src/Post.php
Post.endpoint_args
public function endpoint_args() { return [ 'id' => [ 'default' => false, 'validate_callback' => function ( $id ) { return false === $id || intval( $id ) > 0; }, ], 'slug' => [ 'default' => false, 'sanitize_callback' => function ( $slug, $request, $key ) { return false === $slug ? $slug : sanitize_text_field( $slug ); }, ], ]; }
php
public function endpoint_args() { return [ 'id' => [ 'default' => false, 'validate_callback' => function ( $id ) { return false === $id || intval( $id ) > 0; }, ], 'slug' => [ 'default' => false, 'sanitize_callback' => function ( $slug, $request, $key ) { return false === $slug ? $slug : sanitize_text_field( $slug ); }, ], ]; }
[ "public", "function", "endpoint_args", "(", ")", "{", "return", "[", "'id'", "=>", "[", "'default'", "=>", "false", ",", "'validate_callback'", "=>", "function", "(", "$", "id", ")", "{", "return", "false", "===", "$", "id", "||", "intval", "(", "$", "id", ")", ">", "0", ";", "}", ",", "]", ",", "'slug'", "=>", "[", "'default'", "=>", "false", ",", "'sanitize_callback'", "=>", "function", "(", "$", "slug", ",", "$", "request", ",", "$", "key", ")", "{", "return", "false", "===", "$", "slug", "?", "$", "slug", ":", "sanitize_text_field", "(", "$", "slug", ")", ";", "}", ",", "]", ",", "]", ";", "}" ]
Callback used for the endpoint @since 0.1.0
[ "Callback", "used", "for", "the", "endpoint" ]
11f17af89a3164faade5bd05be714cc3ab6e3c08
https://github.com/wearenolte/wp-endpoints-post/blob/11f17af89a3164faade5bd05be714cc3ab6e3c08/src/Post.php#L97-L112
7,676
Xety/Configurator
src/Configurator.php
Configurator.mergeConfig
public function mergeConfig(array $values, bool $invert = false): Configurator { $this->config = ($invert) ? array_merge($values, $this->config) : array_merge($this->config, $values); return $this; }
php
public function mergeConfig(array $values, bool $invert = false): Configurator { $this->config = ($invert) ? array_merge($values, $this->config) : array_merge($this->config, $values); return $this; }
[ "public", "function", "mergeConfig", "(", "array", "$", "values", ",", "bool", "$", "invert", "=", "false", ")", ":", "Configurator", "{", "$", "this", "->", "config", "=", "(", "$", "invert", ")", "?", "array_merge", "(", "$", "values", ",", "$", "this", "->", "config", ")", ":", "array_merge", "(", "$", "this", "->", "config", ",", "$", "values", ")", ";", "return", "$", "this", ";", "}" ]
Merge the values to the options array. @param array $values The values to merge in the config. @param bool $invert Invert the merge by merging the actual config into the values. @return \Xety\Configurator\Configurator
[ "Merge", "the", "values", "to", "the", "options", "array", "." ]
a7bb37a0f7d548df2491b6fd596c940cae81c94e
https://github.com/Xety/Configurator/blob/a7bb37a0f7d548df2491b6fd596c940cae81c94e/src/Configurator.php#L55-L60
7,677
Xety/Configurator
src/Configurator.php
Configurator.flushConfig
public function flushConfig(string ...$filter): Configurator { $filter = array_flip($filter); $this->config = array_diff_key($this->config, $filter); return $this; }
php
public function flushConfig(string ...$filter): Configurator { $filter = array_flip($filter); $this->config = array_diff_key($this->config, $filter); return $this; }
[ "public", "function", "flushConfig", "(", "string", "...", "$", "filter", ")", ":", "Configurator", "{", "$", "filter", "=", "array_flip", "(", "$", "filter", ")", ";", "$", "this", "->", "config", "=", "array_diff_key", "(", "$", "this", "->", "config", ",", "$", "filter", ")", ";", "return", "$", "this", ";", "}" ]
Flush a list of options from the config array. Usage: ```php $this->flush('key1', 'key2'); ``` @param string ...$filter All the options to remove from the config. @return \Xety\Configurator\Configurator
[ "Flush", "a", "list", "of", "options", "from", "the", "config", "array", "." ]
a7bb37a0f7d548df2491b6fd596c940cae81c94e
https://github.com/Xety/Configurator/blob/a7bb37a0f7d548df2491b6fd596c940cae81c94e/src/Configurator.php#L74-L80
7,678
Xety/Configurator
src/Configurator.php
Configurator.setOption
public function setOption(string $name, $value): Configurator { $this->validateName($name); $this->config[$name] = $value; return $this; }
php
public function setOption(string $name, $value): Configurator { $this->validateName($name); $this->config[$name] = $value; return $this; }
[ "public", "function", "setOption", "(", "string", "$", "name", ",", "$", "value", ")", ":", "Configurator", "{", "$", "this", "->", "validateName", "(", "$", "name", ")", ";", "$", "this", "->", "config", "[", "$", "name", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set a value to the given option. Usage: ```php $this->setOption('key', 'value'); $this->setOption('key', ['key2' => ['value2']]); ``` @param string $name The option name. @param mixed $value The option value. @return \Xety\Configurator\Configurator
[ "Set", "a", "value", "to", "the", "given", "option", "." ]
a7bb37a0f7d548df2491b6fd596c940cae81c94e
https://github.com/Xety/Configurator/blob/a7bb37a0f7d548df2491b6fd596c940cae81c94e/src/Configurator.php#L108-L114
7,679
Xety/Configurator
src/Configurator.php
Configurator.hasOption
public function hasOption(string $name): bool { $this->validateName($name); return array_key_exists($name, $this->config); }
php
public function hasOption(string $name): bool { $this->validateName($name); return array_key_exists($name, $this->config); }
[ "public", "function", "hasOption", "(", "string", "$", "name", ")", ":", "bool", "{", "$", "this", "->", "validateName", "(", "$", "name", ")", ";", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "config", ")", ";", "}" ]
Check if the option exist. @param string $name The option name to check. @return bool
[ "Check", "if", "the", "option", "exist", "." ]
a7bb37a0f7d548df2491b6fd596c940cae81c94e
https://github.com/Xety/Configurator/blob/a7bb37a0f7d548df2491b6fd596c940cae81c94e/src/Configurator.php#L146-L151
7,680
Xety/Configurator
src/Configurator.php
Configurator.consumeOption
public function consumeOption(string $name) { $this->validateName($name); if (!array_key_exists($name, $this->config)) { return null; } $value = $this->config[$name]; $this->flushOption($name); return $value; }
php
public function consumeOption(string $name) { $this->validateName($name); if (!array_key_exists($name, $this->config)) { return null; } $value = $this->config[$name]; $this->flushOption($name); return $value; }
[ "public", "function", "consumeOption", "(", "string", "$", "name", ")", "{", "$", "this", "->", "validateName", "(", "$", "name", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "config", ")", ")", "{", "return", "null", ";", "}", "$", "value", "=", "$", "this", "->", "config", "[", "$", "name", "]", ";", "$", "this", "->", "flushOption", "(", "$", "name", ")", ";", "return", "$", "value", ";", "}" ]
Read then flush an option. Exemple: Config: ```php $config = [ 'key1' => 'value1' ]; ``` Usage: ```php $result = $this->consumeOption('key1'); ``` Result: ```php echo $result; // value1 var_dump($config); // [] ``` @param string $name The name of the option to read then flush. @return mixed
[ "Read", "then", "flush", "an", "option", "." ]
a7bb37a0f7d548df2491b6fd596c940cae81c94e
https://github.com/Xety/Configurator/blob/a7bb37a0f7d548df2491b6fd596c940cae81c94e/src/Configurator.php#L178-L190
7,681
Xety/Configurator
src/Configurator.php
Configurator.pushOption
public function pushOption(string $name, array ...$args): Configurator { $this->validateName($name); if (empty($args)) { throw new InvalidArgumentNumberException(); } foreach ($args as $arg) { if (is_array($arg)) { foreach ($arg as $key => $value) { $this->config[$name][$key] = $value; } } } return $this; }
php
public function pushOption(string $name, array ...$args): Configurator { $this->validateName($name); if (empty($args)) { throw new InvalidArgumentNumberException(); } foreach ($args as $arg) { if (is_array($arg)) { foreach ($arg as $key => $value) { $this->config[$name][$key] = $value; } } } return $this; }
[ "public", "function", "pushOption", "(", "string", "$", "name", ",", "array", "...", "$", "args", ")", ":", "Configurator", "{", "$", "this", "->", "validateName", "(", "$", "name", ")", ";", "if", "(", "empty", "(", "$", "args", ")", ")", "{", "throw", "new", "InvalidArgumentNumberException", "(", ")", ";", "}", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "if", "(", "is_array", "(", "$", "arg", ")", ")", "{", "foreach", "(", "$", "arg", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "config", "[", "$", "name", "]", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Push the listed args to the named option. Usage: ```php $this->pushOption('key', ['key1' => 'value1'], ['key2' => ['value2' => 'value3']]); ``` Result: ```php 'key' => [ 'key1' => 'value1', 'key2' => [ value2 => value3 ] ] ``` @param string $name The name of the option. @param array ...$args A list of values to push into the option key. @throws \Xety\Configurator\Exceptions\InvalidArgumentNumberException When the args list is empty. @return \Xety\Configurator\Configurator
[ "Push", "the", "listed", "args", "to", "the", "named", "option", "." ]
a7bb37a0f7d548df2491b6fd596c940cae81c94e
https://github.com/Xety/Configurator/blob/a7bb37a0f7d548df2491b6fd596c940cae81c94e/src/Configurator.php#L217-L234
7,682
Xety/Configurator
src/Configurator.php
Configurator.flushOption
public function flushOption(string $name): Configurator { $this->validateName($name); if ($this->hasOption($name)) { unset($this->config[$name]); } return $this; }
php
public function flushOption(string $name): Configurator { $this->validateName($name); if ($this->hasOption($name)) { unset($this->config[$name]); } return $this; }
[ "public", "function", "flushOption", "(", "string", "$", "name", ")", ":", "Configurator", "{", "$", "this", "->", "validateName", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "hasOption", "(", "$", "name", ")", ")", "{", "unset", "(", "$", "this", "->", "config", "[", "$", "name", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Flush an option. @param string $name The name of the option to flush. @return \Xety\Configurator\Configurator
[ "Flush", "an", "option", "." ]
a7bb37a0f7d548df2491b6fd596c940cae81c94e
https://github.com/Xety/Configurator/blob/a7bb37a0f7d548df2491b6fd596c940cae81c94e/src/Configurator.php#L243-L252
7,683
CakeCMS/Extensions
src/Plugin.php
Plugin.getInstance
public static function getInstance($name) { if (!self::loaded($name)) { throw new MissingPluginException(['plugin' => $name]); } if (!Arr::key($name, self::$_pluginsList)) { $slug = Str::low($name); $table = TableRegistry::get('Extensions.Extensions'); $entity = $table ->find() ->where([ 'slug' => $slug, 'type' => EXT_TYPE_PLUGIN ]) ->first(); self::$_pluginsList[$name] = $entity; } return self::$_pluginsList[$name]; }
php
public static function getInstance($name) { if (!self::loaded($name)) { throw new MissingPluginException(['plugin' => $name]); } if (!Arr::key($name, self::$_pluginsList)) { $slug = Str::low($name); $table = TableRegistry::get('Extensions.Extensions'); $entity = $table ->find() ->where([ 'slug' => $slug, 'type' => EXT_TYPE_PLUGIN ]) ->first(); self::$_pluginsList[$name] = $entity; } return self::$_pluginsList[$name]; }
[ "public", "static", "function", "getInstance", "(", "$", "name", ")", "{", "if", "(", "!", "self", "::", "loaded", "(", "$", "name", ")", ")", "{", "throw", "new", "MissingPluginException", "(", "[", "'plugin'", "=>", "$", "name", "]", ")", ";", "}", "if", "(", "!", "Arr", "::", "key", "(", "$", "name", ",", "self", "::", "$", "_pluginsList", ")", ")", "{", "$", "slug", "=", "Str", "::", "low", "(", "$", "name", ")", ";", "$", "table", "=", "TableRegistry", "::", "get", "(", "'Extensions.Extensions'", ")", ";", "$", "entity", "=", "$", "table", "->", "find", "(", ")", "->", "where", "(", "[", "'slug'", "=>", "$", "slug", ",", "'type'", "=>", "EXT_TYPE_PLUGIN", "]", ")", "->", "first", "(", ")", ";", "self", "::", "$", "_pluginsList", "[", "$", "name", "]", "=", "$", "entity", ";", "}", "return", "self", "::", "$", "_pluginsList", "[", "$", "name", "]", ";", "}" ]
Get plugin extension instance. @param string $name Plugin name. @return Entity
[ "Get", "plugin", "extension", "instance", "." ]
5c719a8283ff2bc5499658f2ef3d6932d26c55e6
https://github.com/CakeCMS/Extensions/blob/5c719a8283ff2bc5499658f2ef3d6932d26c55e6/src/Plugin.php#L46-L68
7,684
znframework/package-services
CDN.php
CDN.get
public static function get(String $configName, String $name) : String { $config = Config::default('ZN\Services\CDNDefaultConfiguration') ::get('CDNLinks'); $configData = ! empty($config[$configName]) ? $config[$configName] : ''; if( empty($configData) ) { return false; } $data = array_change_key_case($configData); $name = strtolower($name); if( isset($data[$name]) ) { return $data[$name]; } else { return $data; } }
php
public static function get(String $configName, String $name) : String { $config = Config::default('ZN\Services\CDNDefaultConfiguration') ::get('CDNLinks'); $configData = ! empty($config[$configName]) ? $config[$configName] : ''; if( empty($configData) ) { return false; } $data = array_change_key_case($configData); $name = strtolower($name); if( isset($data[$name]) ) { return $data[$name]; } else { return $data; } }
[ "public", "static", "function", "get", "(", "String", "$", "configName", ",", "String", "$", "name", ")", ":", "String", "{", "$", "config", "=", "Config", "::", "default", "(", "'ZN\\Services\\CDNDefaultConfiguration'", ")", "::", "get", "(", "'CDNLinks'", ")", ";", "$", "configData", "=", "!", "empty", "(", "$", "config", "[", "$", "configName", "]", ")", "?", "$", "config", "[", "$", "configName", "]", ":", "''", ";", "if", "(", "empty", "(", "$", "configData", ")", ")", "{", "return", "false", ";", "}", "$", "data", "=", "array_change_key_case", "(", "$", "configData", ")", ";", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "$", "name", "]", ")", ")", "{", "return", "$", "data", "[", "$", "name", "]", ";", "}", "else", "{", "return", "$", "data", ";", "}", "}" ]
Get cdn data. @param string $configName @param string $name @return string
[ "Get", "cdn", "data", "." ]
d603667191e2e386cbc2119836c5bed9e3ade141
https://github.com/znframework/package-services/blob/d603667191e2e386cbc2119836c5bed9e3ade141/CDN.php#L88-L111
7,685
konservs/brilliant.framework
libraries/Config/BConfig.php
BConfig.getallfields
public function getallfields(){ $res=array(); foreach($this->categories as $cat){ foreach($cat->groups as $group){ foreach($group->fields as $fld){ $res[$fld->alias]=$fld; } } } return $res; }
php
public function getallfields(){ $res=array(); foreach($this->categories as $cat){ foreach($cat->groups as $group){ foreach($group->fields as $fld){ $res[$fld->alias]=$fld; } } } return $res; }
[ "public", "function", "getallfields", "(", ")", "{", "$", "res", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "categories", "as", "$", "cat", ")", "{", "foreach", "(", "$", "cat", "->", "groups", "as", "$", "group", ")", "{", "foreach", "(", "$", "group", "->", "fields", "as", "$", "fld", ")", "{", "$", "res", "[", "$", "fld", "->", "alias", "]", "=", "$", "fld", ";", "}", "}", "}", "return", "$", "res", ";", "}" ]
Get all fields objects @return array array of fields objects
[ "Get", "all", "fields", "objects" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Config/BConfig.php#L42-L52
7,686
konservs/brilliant.framework
libraries/Config/BConfig.php
BConfig.saveconfig
public function saveconfig(){ $fields=$this->getallfields(); foreach($fields as $k=>&$v){ $v->value=BRequest::getVar($k,$v->default); } $cfgfile='<?php'.PHP_EOL; foreach($fields as $fld){ $cfgfile.=$fld->getcfg(); } $fn_config=BROOTPATH.'config'.DIRECTORY_SEPARATOR.'config.php'; return file_put_contents($fn_config,$cfgfile); }
php
public function saveconfig(){ $fields=$this->getallfields(); foreach($fields as $k=>&$v){ $v->value=BRequest::getVar($k,$v->default); } $cfgfile='<?php'.PHP_EOL; foreach($fields as $fld){ $cfgfile.=$fld->getcfg(); } $fn_config=BROOTPATH.'config'.DIRECTORY_SEPARATOR.'config.php'; return file_put_contents($fn_config,$cfgfile); }
[ "public", "function", "saveconfig", "(", ")", "{", "$", "fields", "=", "$", "this", "->", "getallfields", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "k", "=>", "&", "$", "v", ")", "{", "$", "v", "->", "value", "=", "BRequest", "::", "getVar", "(", "$", "k", ",", "$", "v", "->", "default", ")", ";", "}", "$", "cfgfile", "=", "'<?php'", ".", "PHP_EOL", ";", "foreach", "(", "$", "fields", "as", "$", "fld", ")", "{", "$", "cfgfile", ".=", "$", "fld", "->", "getcfg", "(", ")", ";", "}", "$", "fn_config", "=", "BROOTPATH", ".", "'config'", ".", "DIRECTORY_SEPARATOR", ".", "'config.php'", ";", "return", "file_put_contents", "(", "$", "fn_config", ",", "$", "cfgfile", ")", ";", "}" ]
Save configuration file @return boolean result
[ "Save", "configuration", "file" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Config/BConfig.php#L71-L82
7,687
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.getDocumentCollection
public function getDocumentCollection($className) { $className = ltrim($className, '\\'); $metadata = $this->metadataFactory->getMetadataFor($className); $collectionName = $metadata->getCollection(); if ( ! $collectionName) { throw MongoDBException::documentNotMappedToCollection($className); } if ( ! isset($this->documentCollections[$className])) { $db = $this->getDocumentDatabase($className); $this->documentCollections[$className] = $metadata->isFile() ? $db->getGridFS($collectionName) : $db->selectCollection($collectionName); } $collection = $this->documentCollections[$className]; if ($metadata->slaveOkay !== null) { $collection->setSlaveOkay($metadata->slaveOkay); } return $this->documentCollections[$className]; }
php
public function getDocumentCollection($className) { $className = ltrim($className, '\\'); $metadata = $this->metadataFactory->getMetadataFor($className); $collectionName = $metadata->getCollection(); if ( ! $collectionName) { throw MongoDBException::documentNotMappedToCollection($className); } if ( ! isset($this->documentCollections[$className])) { $db = $this->getDocumentDatabase($className); $this->documentCollections[$className] = $metadata->isFile() ? $db->getGridFS($collectionName) : $db->selectCollection($collectionName); } $collection = $this->documentCollections[$className]; if ($metadata->slaveOkay !== null) { $collection->setSlaveOkay($metadata->slaveOkay); } return $this->documentCollections[$className]; }
[ "public", "function", "getDocumentCollection", "(", "$", "className", ")", "{", "$", "className", "=", "ltrim", "(", "$", "className", ",", "'\\\\'", ")", ";", "$", "metadata", "=", "$", "this", "->", "metadataFactory", "->", "getMetadataFor", "(", "$", "className", ")", ";", "$", "collectionName", "=", "$", "metadata", "->", "getCollection", "(", ")", ";", "if", "(", "!", "$", "collectionName", ")", "{", "throw", "MongoDBException", "::", "documentNotMappedToCollection", "(", "$", "className", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "documentCollections", "[", "$", "className", "]", ")", ")", "{", "$", "db", "=", "$", "this", "->", "getDocumentDatabase", "(", "$", "className", ")", ";", "$", "this", "->", "documentCollections", "[", "$", "className", "]", "=", "$", "metadata", "->", "isFile", "(", ")", "?", "$", "db", "->", "getGridFS", "(", "$", "collectionName", ")", ":", "$", "db", "->", "selectCollection", "(", "$", "collectionName", ")", ";", "}", "$", "collection", "=", "$", "this", "->", "documentCollections", "[", "$", "className", "]", ";", "if", "(", "$", "metadata", "->", "slaveOkay", "!==", "null", ")", "{", "$", "collection", "->", "setSlaveOkay", "(", "$", "metadata", "->", "slaveOkay", ")", ";", "}", "return", "$", "this", "->", "documentCollections", "[", "$", "className", "]", ";", "}" ]
Returns the MongoCollection instance for a class. @param string $className The class name. @throws MongoDBException When the $className param is not mapped to a collection @return \Doctrine\MongoDB\Collection
[ "Returns", "the", "MongoCollection", "instance", "for", "a", "class", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L329-L355
7,688
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.getRepository
public function getRepository($documentName) { $documentName = ltrim($documentName, '\\'); if (isset($this->repositories[$documentName])) { return $this->repositories[$documentName]; } $metadata = $this->getClassMetadata($documentName); $customRepositoryClassName = $metadata->customRepositoryClassName; if ($customRepositoryClassName !== null) { $repository = new $customRepositoryClassName($this, $this->unitOfWork, $metadata); } else { $repository = new DocumentRepository($this, $this->unitOfWork, $metadata); } $this->repositories[$documentName] = $repository; return $repository; }
php
public function getRepository($documentName) { $documentName = ltrim($documentName, '\\'); if (isset($this->repositories[$documentName])) { return $this->repositories[$documentName]; } $metadata = $this->getClassMetadata($documentName); $customRepositoryClassName = $metadata->customRepositoryClassName; if ($customRepositoryClassName !== null) { $repository = new $customRepositoryClassName($this, $this->unitOfWork, $metadata); } else { $repository = new DocumentRepository($this, $this->unitOfWork, $metadata); } $this->repositories[$documentName] = $repository; return $repository; }
[ "public", "function", "getRepository", "(", "$", "documentName", ")", "{", "$", "documentName", "=", "ltrim", "(", "$", "documentName", ",", "'\\\\'", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "repositories", "[", "$", "documentName", "]", ")", ")", "{", "return", "$", "this", "->", "repositories", "[", "$", "documentName", "]", ";", "}", "$", "metadata", "=", "$", "this", "->", "getClassMetadata", "(", "$", "documentName", ")", ";", "$", "customRepositoryClassName", "=", "$", "metadata", "->", "customRepositoryClassName", ";", "if", "(", "$", "customRepositoryClassName", "!==", "null", ")", "{", "$", "repository", "=", "new", "$", "customRepositoryClassName", "(", "$", "this", ",", "$", "this", "->", "unitOfWork", ",", "$", "metadata", ")", ";", "}", "else", "{", "$", "repository", "=", "new", "DocumentRepository", "(", "$", "this", ",", "$", "this", "->", "unitOfWork", ",", "$", "metadata", ")", ";", "}", "$", "this", "->", "repositories", "[", "$", "documentName", "]", "=", "$", "repository", ";", "return", "$", "repository", ";", "}" ]
Gets the repository for a document class. @param string $documentName The name of the Document. @return DocumentRepository The repository.
[ "Gets", "the", "repository", "for", "a", "document", "class", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L506-L526
7,689
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.flush
public function flush($document = null, array $options = array()) { if (null !== $document && ! is_object($document) && ! is_array($document)) { throw new \InvalidArgumentException(gettype($document)); } $this->errorIfClosed(); $this->unitOfWork->commit($document, $options); }
php
public function flush($document = null, array $options = array()) { if (null !== $document && ! is_object($document) && ! is_array($document)) { throw new \InvalidArgumentException(gettype($document)); } $this->errorIfClosed(); $this->unitOfWork->commit($document, $options); }
[ "public", "function", "flush", "(", "$", "document", "=", "null", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "null", "!==", "$", "document", "&&", "!", "is_object", "(", "$", "document", ")", "&&", "!", "is_array", "(", "$", "document", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "gettype", "(", "$", "document", ")", ")", ";", "}", "$", "this", "->", "errorIfClosed", "(", ")", ";", "$", "this", "->", "unitOfWork", "->", "commit", "(", "$", "document", ",", "$", "options", ")", ";", "}" ]
Flushes all changes to objects that have been queued up to now to the database. This effectively synchronizes the in-memory state of managed objects with the database. @param object $document @param array $options Array of options to be used with batchInsert(), update() and remove() @throws \InvalidArgumentException
[ "Flushes", "all", "changes", "to", "objects", "that", "have", "been", "queued", "up", "to", "now", "to", "the", "database", ".", "This", "effectively", "synchronizes", "the", "in", "-", "memory", "state", "of", "managed", "objects", "with", "the", "database", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L537-L544
7,690
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.getReference
public function getReference($documentName, $identifier) { /* @var $class \Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo */ $class = $this->metadataFactory->getMetadataFor(ltrim($documentName, '\\')); // Check identity map first, if its already in there just return it. if ($document = $this->unitOfWork->tryGetById($identifier, $class)) { return $document; } $document = $this->proxyFactory->getProxy($class->name, array($class->identifier => $identifier)); $this->unitOfWork->registerManaged($document, $identifier, array()); return $document; }
php
public function getReference($documentName, $identifier) { /* @var $class \Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo */ $class = $this->metadataFactory->getMetadataFor(ltrim($documentName, '\\')); // Check identity map first, if its already in there just return it. if ($document = $this->unitOfWork->tryGetById($identifier, $class)) { return $document; } $document = $this->proxyFactory->getProxy($class->name, array($class->identifier => $identifier)); $this->unitOfWork->registerManaged($document, $identifier, array()); return $document; }
[ "public", "function", "getReference", "(", "$", "documentName", ",", "$", "identifier", ")", "{", "/* @var $class \\Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadataInfo */", "$", "class", "=", "$", "this", "->", "metadataFactory", "->", "getMetadataFor", "(", "ltrim", "(", "$", "documentName", ",", "'\\\\'", ")", ")", ";", "// Check identity map first, if its already in there just return it.", "if", "(", "$", "document", "=", "$", "this", "->", "unitOfWork", "->", "tryGetById", "(", "$", "identifier", ",", "$", "class", ")", ")", "{", "return", "$", "document", ";", "}", "$", "document", "=", "$", "this", "->", "proxyFactory", "->", "getProxy", "(", "$", "class", "->", "name", ",", "array", "(", "$", "class", "->", "identifier", "=>", "$", "identifier", ")", ")", ";", "$", "this", "->", "unitOfWork", "->", "registerManaged", "(", "$", "document", ",", "$", "identifier", ",", "array", "(", ")", ")", ";", "return", "$", "document", ";", "}" ]
Gets a reference to the document identified by the given type and identifier without actually loading it. If partial objects are allowed, this method will return a partial object that only has its identifier populated. Otherwise a proxy is returned that automatically loads itself on first access. @param string $documentName @param string|object $identifier @return mixed|object The document reference.
[ "Gets", "a", "reference", "to", "the", "document", "identified", "by", "the", "given", "type", "and", "identifier", "without", "actually", "loading", "it", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L558-L572
7,691
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.createDBRef
public function createDBRef($document, array $referenceMapping = null) { if ( ! is_object($document)) { throw new \InvalidArgumentException('Cannot create a DBRef, the document is not an object'); } $class = $this->getClassMetadata(get_class($document)); $id = $this->unitOfWork->getDocumentIdentifier($document); if (!$id) { throw new \RuntimeException( sprintf('Cannot create a DBRef without an identifier. UnitOfWork::getDocumentIdentifier() did not return an identifier for class %s', $class->name) ); } if ( ! empty($referenceMapping['simple'])) { return $class->getDatabaseIdentifierValue($id); } $dbRef = array( '$ref' => $class->getCollection(), '$id' => $class->getDatabaseIdentifierValue($id), '$db' => $this->getDocumentDatabase($class->name)->getName(), ); /* If the class has a discriminator (field and value), use it. A child * class that is not defined in the discriminator map may only have a * discriminator field and no value, so default to the full class name. */ if (isset($class->discriminatorField)) { $dbRef[$class->discriminatorField] = isset($class->discriminatorValue) ? $class->discriminatorValue : $class->name; } /* Add a discriminator value if the referenced document is not mapped * explicitly to a targetDocument class. */ if ($referenceMapping !== null && ! isset($referenceMapping['targetDocument'])) { $discriminatorField = $referenceMapping['discriminatorField']; $discriminatorValue = isset($referenceMapping['discriminatorMap']) ? array_search($class->name, $referenceMapping['discriminatorMap']) : $class->name; /* If the discriminator value was not found in the map, use the full * class name. In the future, it may be preferable to throw an * exception here (perhaps based on some strictness option). * * @see PersistenceBuilder::prepareEmbeddedDocumentValue() */ if ($discriminatorValue === false) { $discriminatorValue = $class->name; } $dbRef[$discriminatorField] = $discriminatorValue; } return $dbRef; }
php
public function createDBRef($document, array $referenceMapping = null) { if ( ! is_object($document)) { throw new \InvalidArgumentException('Cannot create a DBRef, the document is not an object'); } $class = $this->getClassMetadata(get_class($document)); $id = $this->unitOfWork->getDocumentIdentifier($document); if (!$id) { throw new \RuntimeException( sprintf('Cannot create a DBRef without an identifier. UnitOfWork::getDocumentIdentifier() did not return an identifier for class %s', $class->name) ); } if ( ! empty($referenceMapping['simple'])) { return $class->getDatabaseIdentifierValue($id); } $dbRef = array( '$ref' => $class->getCollection(), '$id' => $class->getDatabaseIdentifierValue($id), '$db' => $this->getDocumentDatabase($class->name)->getName(), ); /* If the class has a discriminator (field and value), use it. A child * class that is not defined in the discriminator map may only have a * discriminator field and no value, so default to the full class name. */ if (isset($class->discriminatorField)) { $dbRef[$class->discriminatorField] = isset($class->discriminatorValue) ? $class->discriminatorValue : $class->name; } /* Add a discriminator value if the referenced document is not mapped * explicitly to a targetDocument class. */ if ($referenceMapping !== null && ! isset($referenceMapping['targetDocument'])) { $discriminatorField = $referenceMapping['discriminatorField']; $discriminatorValue = isset($referenceMapping['discriminatorMap']) ? array_search($class->name, $referenceMapping['discriminatorMap']) : $class->name; /* If the discriminator value was not found in the map, use the full * class name. In the future, it may be preferable to throw an * exception here (perhaps based on some strictness option). * * @see PersistenceBuilder::prepareEmbeddedDocumentValue() */ if ($discriminatorValue === false) { $discriminatorValue = $class->name; } $dbRef[$discriminatorField] = $discriminatorValue; } return $dbRef; }
[ "public", "function", "createDBRef", "(", "$", "document", ",", "array", "$", "referenceMapping", "=", "null", ")", "{", "if", "(", "!", "is_object", "(", "$", "document", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Cannot create a DBRef, the document is not an object'", ")", ";", "}", "$", "class", "=", "$", "this", "->", "getClassMetadata", "(", "get_class", "(", "$", "document", ")", ")", ";", "$", "id", "=", "$", "this", "->", "unitOfWork", "->", "getDocumentIdentifier", "(", "$", "document", ")", ";", "if", "(", "!", "$", "id", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Cannot create a DBRef without an identifier. UnitOfWork::getDocumentIdentifier() did not return an identifier for class %s'", ",", "$", "class", "->", "name", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "referenceMapping", "[", "'simple'", "]", ")", ")", "{", "return", "$", "class", "->", "getDatabaseIdentifierValue", "(", "$", "id", ")", ";", "}", "$", "dbRef", "=", "array", "(", "'$ref'", "=>", "$", "class", "->", "getCollection", "(", ")", ",", "'$id'", "=>", "$", "class", "->", "getDatabaseIdentifierValue", "(", "$", "id", ")", ",", "'$db'", "=>", "$", "this", "->", "getDocumentDatabase", "(", "$", "class", "->", "name", ")", "->", "getName", "(", ")", ",", ")", ";", "/* If the class has a discriminator (field and value), use it. A child\n * class that is not defined in the discriminator map may only have a\n * discriminator field and no value, so default to the full class name.\n */", "if", "(", "isset", "(", "$", "class", "->", "discriminatorField", ")", ")", "{", "$", "dbRef", "[", "$", "class", "->", "discriminatorField", "]", "=", "isset", "(", "$", "class", "->", "discriminatorValue", ")", "?", "$", "class", "->", "discriminatorValue", ":", "$", "class", "->", "name", ";", "}", "/* Add a discriminator value if the referenced document is not mapped\n * explicitly to a targetDocument class.\n */", "if", "(", "$", "referenceMapping", "!==", "null", "&&", "!", "isset", "(", "$", "referenceMapping", "[", "'targetDocument'", "]", ")", ")", "{", "$", "discriminatorField", "=", "$", "referenceMapping", "[", "'discriminatorField'", "]", ";", "$", "discriminatorValue", "=", "isset", "(", "$", "referenceMapping", "[", "'discriminatorMap'", "]", ")", "?", "array_search", "(", "$", "class", "->", "name", ",", "$", "referenceMapping", "[", "'discriminatorMap'", "]", ")", ":", "$", "class", "->", "name", ";", "/* If the discriminator value was not found in the map, use the full\n * class name. In the future, it may be preferable to throw an\n * exception here (perhaps based on some strictness option).\n *\n * @see PersistenceBuilder::prepareEmbeddedDocumentValue()\n */", "if", "(", "$", "discriminatorValue", "===", "false", ")", "{", "$", "discriminatorValue", "=", "$", "class", "->", "name", ";", "}", "$", "dbRef", "[", "$", "discriminatorField", "]", "=", "$", "discriminatorValue", ";", "}", "return", "$", "dbRef", ";", "}" ]
Returns a DBRef array for the supplied document. @param mixed $document A document object @param array $referenceMapping Mapping for the field that references the document @throws \InvalidArgumentException @return array A DBRef array
[ "Returns", "a", "DBRef", "array", "for", "the", "supplied", "document", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L684-L742
7,692
Laralum/PDF
src/Controllers/PDFController.php
PDFController.download
public function download(Request $request, $name = 'output') { $pdf = PDF::loadView('laralum_pdf::pdf', ['text' => $request->text]); return $pdf->download("$name.pdf"); }
php
public function download(Request $request, $name = 'output') { $pdf = PDF::loadView('laralum_pdf::pdf', ['text' => $request->text]); return $pdf->download("$name.pdf"); }
[ "public", "function", "download", "(", "Request", "$", "request", ",", "$", "name", "=", "'output'", ")", "{", "$", "pdf", "=", "PDF", "::", "loadView", "(", "'laralum_pdf::pdf'", ",", "[", "'text'", "=>", "$", "request", "->", "text", "]", ")", ";", "return", "$", "pdf", "->", "download", "(", "\"$name.pdf\"", ")", ";", "}" ]
Download the PDF. @param string $name @param \Illuminate\Http\Request $request @return \Illuminate\Http\Response
[ "Download", "the", "PDF", "." ]
b73d5a4b741ba8594820e9aab29ae56d7381766f
https://github.com/Laralum/PDF/blob/b73d5a4b741ba8594820e9aab29ae56d7381766f/src/Controllers/PDFController.php#L30-L35
7,693
Laralum/PDF
src/Controllers/PDFController.php
PDFController.show
public function show(Request $request) { $pdf = PDF::loadView('laralum_pdf::pdf', ['text' => $request->text]); return Response::make($pdf->download('output.pdf'), 200, ['content-type' => 'application/pdf']); }
php
public function show(Request $request) { $pdf = PDF::loadView('laralum_pdf::pdf', ['text' => $request->text]); return Response::make($pdf->download('output.pdf'), 200, ['content-type' => 'application/pdf']); }
[ "public", "function", "show", "(", "Request", "$", "request", ")", "{", "$", "pdf", "=", "PDF", "::", "loadView", "(", "'laralum_pdf::pdf'", ",", "[", "'text'", "=>", "$", "request", "->", "text", "]", ")", ";", "return", "Response", "::", "make", "(", "$", "pdf", "->", "download", "(", "'output.pdf'", ")", ",", "200", ",", "[", "'content-type'", "=>", "'application/pdf'", "]", ")", ";", "}" ]
Display the PDF. @param \Illuminate\Http\Request $request @return \Illuminate\Http\Response
[ "Display", "the", "PDF", "." ]
b73d5a4b741ba8594820e9aab29ae56d7381766f
https://github.com/Laralum/PDF/blob/b73d5a4b741ba8594820e9aab29ae56d7381766f/src/Controllers/PDFController.php#L44-L49
7,694
gossi/trixionary
src/model/Base/FunctionPhase.php
FunctionPhase.initRootSkills
public function initRootSkills($overrideExisting = true) { if (null !== $this->collRootSkills && !$overrideExisting) { return; } $this->collRootSkills = new ObjectCollection(); $this->collRootSkills->setModel('\gossi\trixionary\model\Skill'); }
php
public function initRootSkills($overrideExisting = true) { if (null !== $this->collRootSkills && !$overrideExisting) { return; } $this->collRootSkills = new ObjectCollection(); $this->collRootSkills->setModel('\gossi\trixionary\model\Skill'); }
[ "public", "function", "initRootSkills", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collRootSkills", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collRootSkills", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collRootSkills", "->", "setModel", "(", "'\\gossi\\trixionary\\model\\Skill'", ")", ";", "}" ]
Initializes the collRootSkills collection. By default this just sets the collRootSkills collection to an empty array (like clearcollRootSkills()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collRootSkills", "collection", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/FunctionPhase.php#L1379-L1386
7,695
gossi/trixionary
src/model/Base/FunctionPhase.php
FunctionPhase.getRootSkillsJoinSport
public function getRootSkillsJoinSport(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('Sport', $joinBehavior); return $this->getRootSkills($query, $con); }
php
public function getRootSkillsJoinSport(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('Sport', $joinBehavior); return $this->getRootSkills($query, $con); }
[ "public", "function", "getRootSkillsJoinSport", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildSkillQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "$", "query", "->", "joinWith", "(", "'Sport'", ",", "$", "joinBehavior", ")", ";", "return", "$", "this", "->", "getRootSkills", "(", "$", "query", ",", "$", "con", ")", ";", "}" ]
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this FunctionPhase is new, it will return an empty collection; or if this FunctionPhase has previously been saved, it will retrieve related RootSkills from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in FunctionPhase. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildSkill[] List of ChildSkill objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "FunctionPhase", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", "or", "if", "this", "FunctionPhase", "has", "previously", "been", "saved", "it", "will", "retrieve", "related", "RootSkills", "from", "storage", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/FunctionPhase.php#L1580-L1586
7,696
gossi/trixionary
src/model/Base/FunctionPhase.php
FunctionPhase.getSyncParent
public function getSyncParent($con = null) { $parent = $this->getParentOrCreate($con); $parent->setType($this->getType()); $parent->setSkillId($this->getSkillId()); $parent->setTitle($this->getTitle()); if ($this->getSkill() && $this->getSkill()->isNew()) { $parent->setSkill($this->getSkill()); } return $parent; }
php
public function getSyncParent($con = null) { $parent = $this->getParentOrCreate($con); $parent->setType($this->getType()); $parent->setSkillId($this->getSkillId()); $parent->setTitle($this->getTitle()); if ($this->getSkill() && $this->getSkill()->isNew()) { $parent->setSkill($this->getSkill()); } return $parent; }
[ "public", "function", "getSyncParent", "(", "$", "con", "=", "null", ")", "{", "$", "parent", "=", "$", "this", "->", "getParentOrCreate", "(", "$", "con", ")", ";", "$", "parent", "->", "setType", "(", "$", "this", "->", "getType", "(", ")", ")", ";", "$", "parent", "->", "setSkillId", "(", "$", "this", "->", "getSkillId", "(", ")", ")", ";", "$", "parent", "->", "setTitle", "(", "$", "this", "->", "getTitle", "(", ")", ")", ";", "if", "(", "$", "this", "->", "getSkill", "(", ")", "&&", "$", "this", "->", "getSkill", "(", ")", "->", "isNew", "(", ")", ")", "{", "$", "parent", "->", "setSkill", "(", "$", "this", "->", "getSkill", "(", ")", ")", ";", "}", "return", "$", "parent", ";", "}" ]
Create or Update the parent StructureNode object And return its primary key @return int The primary key of the parent object
[ "Create", "or", "Update", "the", "parent", "StructureNode", "object", "And", "return", "its", "primary", "key" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/FunctionPhase.php#L1906-L1917
7,697
synapsestudios/synapse-base
src/Synapse/Db/DbServiceProvider.php
DbServiceProvider.register
public function register(Application $app) { $app['db'] = $app->share(function ($app) { return new Adapter($app['config']->load('db')); }); $app['db.transaction'] = $app->share(function ($app) { return new Transaction($app['db']); }); $app->initializer( 'Synapse\\Db\\TransactionAwareInterface', function ($object, $app) { $object->setTransaction($app['db.transaction']); return $object; } ); $this->registerMapperInitializer($app); }
php
public function register(Application $app) { $app['db'] = $app->share(function ($app) { return new Adapter($app['config']->load('db')); }); $app['db.transaction'] = $app->share(function ($app) { return new Transaction($app['db']); }); $app->initializer( 'Synapse\\Db\\TransactionAwareInterface', function ($object, $app) { $object->setTransaction($app['db.transaction']); return $object; } ); $this->registerMapperInitializer($app); }
[ "public", "function", "register", "(", "Application", "$", "app", ")", "{", "$", "app", "[", "'db'", "]", "=", "$", "app", "->", "share", "(", "function", "(", "$", "app", ")", "{", "return", "new", "Adapter", "(", "$", "app", "[", "'config'", "]", "->", "load", "(", "'db'", ")", ")", ";", "}", ")", ";", "$", "app", "[", "'db.transaction'", "]", "=", "$", "app", "->", "share", "(", "function", "(", "$", "app", ")", "{", "return", "new", "Transaction", "(", "$", "app", "[", "'db'", "]", ")", ";", "}", ")", ";", "$", "app", "->", "initializer", "(", "'Synapse\\\\Db\\\\TransactionAwareInterface'", ",", "function", "(", "$", "object", ",", "$", "app", ")", "{", "$", "object", "->", "setTransaction", "(", "$", "app", "[", "'db.transaction'", "]", ")", ";", "return", "$", "object", ";", "}", ")", ";", "$", "this", "->", "registerMapperInitializer", "(", "$", "app", ")", ";", "}" ]
Register the database adapter @param Application $app Silex application
[ "Register", "the", "database", "adapter" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Db/DbServiceProvider.php#L22-L41
7,698
synapsestudios/synapse-base
src/Synapse/Db/DbServiceProvider.php
DbServiceProvider.registerMapperInitializer
protected function registerMapperInitializer(Application $app) { $initializer = function ($mapper, $app) { $mapper->setSqlFactory(new SqlFactory); }; $app->initializer('Synapse\Mapper\AbstractMapper', $initializer); }
php
protected function registerMapperInitializer(Application $app) { $initializer = function ($mapper, $app) { $mapper->setSqlFactory(new SqlFactory); }; $app->initializer('Synapse\Mapper\AbstractMapper', $initializer); }
[ "protected", "function", "registerMapperInitializer", "(", "Application", "$", "app", ")", "{", "$", "initializer", "=", "function", "(", "$", "mapper", ",", "$", "app", ")", "{", "$", "mapper", "->", "setSqlFactory", "(", "new", "SqlFactory", ")", ";", "}", ";", "$", "app", "->", "initializer", "(", "'Synapse\\Mapper\\AbstractMapper'", ",", "$", "initializer", ")", ";", "}" ]
Register an initializer that injects a SQL Factory into all AbstractMappers @param Application $app
[ "Register", "an", "initializer", "that", "injects", "a", "SQL", "Factory", "into", "all", "AbstractMappers" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Db/DbServiceProvider.php#L58-L65
7,699
zepi/turbo-base
Zepi/Web/AccessControl/src/FilterHandler/RegisterGroupAccessLevels.php
RegisterGroupAccessLevels.execute
public function execute(Framework $framework, RequestAbstract $request, Response $response, $value = null) { $accessLevels = $value; $dataRequest = new DataRequest(1, 0, 'name', 'ASC'); $groups = $this->groupManager->find($dataRequest); if ($groups === false) { return $accessLevels; } foreach ($groups as $group) { $accessLevels[] = new GroupAccessLevel( '\\Group\\' . $group->getUuid(), $this->translationManager->translate('Group', '\\Zepi\\Web\\AccessControl') . ' ' . $group->getName(), $this->translationManager->translate('Inherits all permissions from this group.', '\\Zepi\\Web\\AccessControl'), '\\Group' ); } return $accessLevels; }
php
public function execute(Framework $framework, RequestAbstract $request, Response $response, $value = null) { $accessLevels = $value; $dataRequest = new DataRequest(1, 0, 'name', 'ASC'); $groups = $this->groupManager->find($dataRequest); if ($groups === false) { return $accessLevels; } foreach ($groups as $group) { $accessLevels[] = new GroupAccessLevel( '\\Group\\' . $group->getUuid(), $this->translationManager->translate('Group', '\\Zepi\\Web\\AccessControl') . ' ' . $group->getName(), $this->translationManager->translate('Inherits all permissions from this group.', '\\Zepi\\Web\\AccessControl'), '\\Group' ); } return $accessLevels; }
[ "public", "function", "execute", "(", "Framework", "$", "framework", ",", "RequestAbstract", "$", "request", ",", "Response", "$", "response", ",", "$", "value", "=", "null", ")", "{", "$", "accessLevels", "=", "$", "value", ";", "$", "dataRequest", "=", "new", "DataRequest", "(", "1", ",", "0", ",", "'name'", ",", "'ASC'", ")", ";", "$", "groups", "=", "$", "this", "->", "groupManager", "->", "find", "(", "$", "dataRequest", ")", ";", "if", "(", "$", "groups", "===", "false", ")", "{", "return", "$", "accessLevels", ";", "}", "foreach", "(", "$", "groups", "as", "$", "group", ")", "{", "$", "accessLevels", "[", "]", "=", "new", "GroupAccessLevel", "(", "'\\\\Group\\\\'", ".", "$", "group", "->", "getUuid", "(", ")", ",", "$", "this", "->", "translationManager", "->", "translate", "(", "'Group'", ",", "'\\\\Zepi\\\\Web\\\\AccessControl'", ")", ".", "' '", ".", "$", "group", "->", "getName", "(", ")", ",", "$", "this", "->", "translationManager", "->", "translate", "(", "'Inherits all permissions from this group.'", ",", "'\\\\Zepi\\\\Web\\\\AccessControl'", ")", ",", "'\\\\Group'", ")", ";", "}", "return", "$", "accessLevels", ";", "}" ]
Registers the groups as access levels. @access public @param \Zepi\Turbo\Framework $framework @param \Zepi\Turbo\Request\RequestAbstract $request @param \Zepi\Turbo\Response\Response $response @param mixed $value @return mixed
[ "Registers", "the", "groups", "as", "access", "levels", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/FilterHandler/RegisterGroupAccessLevels.php#L99-L120