repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
itcreator/custom-cmf
Module/Data/src/Cmf/Data/Filter/StripTags.php
StripTags.filter
public function filter($value) { $valueCopy = (string)$value; // If comments are allowed, then replace them with unique identifiers if ($this->getCommentsAllowed()) { preg_match_all('/<\!--.*?--\s*>/s', (string)$valueCopy, $matches); $comments = array_unique($matches[0]); foreach ($comments as $k => $v) { $valueCopy = str_replace($v, self::UNIQUE_ID_PREFIX . $k, $valueCopy); } } // Initialize accumulator for filtered data $dataFiltered = ''; // Parse the input data iteratively as regular pre-tag text followed by a // tag; either may be empty strings preg_match_all('/([^<]*)(<?[^>]*>?)/', (string)$valueCopy, $matches); // Iterate over each set of matches foreach ($matches[1] as $index => $preTag) { // If the pre-tag text is non-empty, strip any ">" characters from it if (strlen($preTag)) { $preTag = str_replace('>', '', $preTag); } // If a tag exists in this match, then filter the tag $tag = $matches[2][$index]; if (strlen($tag)) { $tagFiltered = $this->_filterTag($tag); } else { $tagFiltered = ''; } // Add the filtered pre-tag text and filtered tag to the data buffer $dataFiltered .= $preTag . $tagFiltered; } // If comments are allowed, then replace the unique identifiers with the corresponding comments if ($this->getCommentsAllowed()) { foreach ($comments as $k => $v) { $dataFiltered = str_replace(self::UNIQUE_ID_PREFIX . $k, $v, $dataFiltered); } } // Return the filtered data return $dataFiltered; }
php
public function filter($value) { $valueCopy = (string)$value; // If comments are allowed, then replace them with unique identifiers if ($this->getCommentsAllowed()) { preg_match_all('/<\!--.*?--\s*>/s', (string)$valueCopy, $matches); $comments = array_unique($matches[0]); foreach ($comments as $k => $v) { $valueCopy = str_replace($v, self::UNIQUE_ID_PREFIX . $k, $valueCopy); } } // Initialize accumulator for filtered data $dataFiltered = ''; // Parse the input data iteratively as regular pre-tag text followed by a // tag; either may be empty strings preg_match_all('/([^<]*)(<?[^>]*>?)/', (string)$valueCopy, $matches); // Iterate over each set of matches foreach ($matches[1] as $index => $preTag) { // If the pre-tag text is non-empty, strip any ">" characters from it if (strlen($preTag)) { $preTag = str_replace('>', '', $preTag); } // If a tag exists in this match, then filter the tag $tag = $matches[2][$index]; if (strlen($tag)) { $tagFiltered = $this->_filterTag($tag); } else { $tagFiltered = ''; } // Add the filtered pre-tag text and filtered tag to the data buffer $dataFiltered .= $preTag . $tagFiltered; } // If comments are allowed, then replace the unique identifiers with the corresponding comments if ($this->getCommentsAllowed()) { foreach ($comments as $k => $v) { $dataFiltered = str_replace(self::UNIQUE_ID_PREFIX . $k, $v, $dataFiltered); } } // Return the filtered data return $dataFiltered; }
Defined by Zend_Filter_Interface @todo improve doc block descriptions @param string $value @return string
https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/Data/src/Cmf/Data/Filter/StripTags.php#L185-L229
itcreator/custom-cmf
Module/Data/src/Cmf/Data/Filter/StripTags.php
StripTags._filterTag
protected function _filterTag($tag) { // Parse the tag into: // 1. a starting delimiter (mandatory) // 2. a tag name (if available) // 3. a string of attributes (if available) // 4. an ending delimiter (if available) $isMatch = preg_match('~(</?)(\w*)((/(?!>)|[^/>])*)(/?>)~', $tag, $matches); // If the tag does not match, then strip the tag entirely if (!$isMatch) { return ''; } // Save the matches to more meaningfully named variables $tagStart = $matches[1]; $tagName = strtolower($matches[2]); $tagAttributes = $matches[3]; $tagEnd = $matches[5]; // If the tag is not an allowed tag, then remove the tag entirely if (!isset($this->_tagsAllowed[$tagName])) { return ''; } // Trim the attribute string of whitespace at the ends $tagAttributes = trim($tagAttributes); // If there are non-whitespace characters in the attribute string if (strlen($tagAttributes)) { // Parse iteratively for well-formed attributes preg_match_all('/(\w+)\s*=\s*(?:(")(.*?)"|(\')(.*?)\')/s', $tagAttributes, $matches); // Initialize valid attribute accumulator $tagAttributes = ''; // Iterate over each matched attribute foreach ($matches[1] as $index => $attributeName) { $attributeName = strtolower($attributeName); $attributeDelimiter = $matches[2][$index]; $attributeValue = $matches[3][$index]; // If the attribute is not allowed, then remove it entirely if (!array_key_exists($attributeName, $this->_tagsAllowed[$tagName]) && !array_key_exists($attributeName, $this->_attributesAllowed)) { continue; } // Add the attribute to the accumulator $tagAttributes .= " $attributeName=" . $attributeDelimiter . $attributeValue . $attributeDelimiter; } } // Reconstruct tags ending with "/>" as backwards-compatible XHTML tag if (strpos($tagEnd, '/') !== false) { $tagEnd = " $tagEnd"; } // Return the filtered tag return $tagStart . $tagName . $tagAttributes . $tagEnd; }
php
protected function _filterTag($tag) { // Parse the tag into: // 1. a starting delimiter (mandatory) // 2. a tag name (if available) // 3. a string of attributes (if available) // 4. an ending delimiter (if available) $isMatch = preg_match('~(</?)(\w*)((/(?!>)|[^/>])*)(/?>)~', $tag, $matches); // If the tag does not match, then strip the tag entirely if (!$isMatch) { return ''; } // Save the matches to more meaningfully named variables $tagStart = $matches[1]; $tagName = strtolower($matches[2]); $tagAttributes = $matches[3]; $tagEnd = $matches[5]; // If the tag is not an allowed tag, then remove the tag entirely if (!isset($this->_tagsAllowed[$tagName])) { return ''; } // Trim the attribute string of whitespace at the ends $tagAttributes = trim($tagAttributes); // If there are non-whitespace characters in the attribute string if (strlen($tagAttributes)) { // Parse iteratively for well-formed attributes preg_match_all('/(\w+)\s*=\s*(?:(")(.*?)"|(\')(.*?)\')/s', $tagAttributes, $matches); // Initialize valid attribute accumulator $tagAttributes = ''; // Iterate over each matched attribute foreach ($matches[1] as $index => $attributeName) { $attributeName = strtolower($attributeName); $attributeDelimiter = $matches[2][$index]; $attributeValue = $matches[3][$index]; // If the attribute is not allowed, then remove it entirely if (!array_key_exists($attributeName, $this->_tagsAllowed[$tagName]) && !array_key_exists($attributeName, $this->_attributesAllowed)) { continue; } // Add the attribute to the accumulator $tagAttributes .= " $attributeName=" . $attributeDelimiter . $attributeValue . $attributeDelimiter; } } // Reconstruct tags ending with "/>" as backwards-compatible XHTML tag if (strpos($tagEnd, '/') !== false) { $tagEnd = " $tagEnd"; } // Return the filtered tag return $tagStart . $tagName . $tagAttributes . $tagEnd; }
Filters a single tag against the current option settings @param string $tag @return string
https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/Data/src/Cmf/Data/Filter/StripTags.php#L237-L295
phpguard/listen
src/PhpGuard/Listen/Adapter/BasicAdapter.php
BasicAdapter.initialize
public function initialize(Listener $listener) { $this->listener = $listener; $this->topDirs = array_merge($this->topDirs,$listener->getPaths()); $this->tracker->initialize($listener); }
php
public function initialize(Listener $listener) { $this->listener = $listener; $this->topDirs = array_merge($this->topDirs,$listener->getPaths()); $this->tracker->initialize($listener); }
Initialize a listener @param Listener $listener @return void
https://github.com/phpguard/listen/blob/cd0cda150858d6d85deb025a72996873d2af3532/src/PhpGuard/Listen/Adapter/BasicAdapter.php#L46-L51
phpguard/listen
src/PhpGuard/Listen/Adapter/BasicAdapter.php
BasicAdapter.doCleanup
private function doCleanup($unchecked) { $tracker = $this->tracker; /* @var \PhpGuard\Listen\Resource\TrackedObject $tracked */ foreach($unchecked as $id=>$tracked){ $origin = $tracked->getResource(); if(!$origin->isExists()){ $tracker->addChangeSet($tracked,FilesystemEvent::DELETE); $tracker->remove($tracked); } unset($unchecked[$id]); } }
php
private function doCleanup($unchecked) { $tracker = $this->tracker; /* @var \PhpGuard\Listen\Resource\TrackedObject $tracked */ foreach($unchecked as $id=>$tracked){ $origin = $tracked->getResource(); if(!$origin->isExists()){ $tracker->addChangeSet($tracked,FilesystemEvent::DELETE); $tracker->remove($tracked); } unset($unchecked[$id]); } }
Track any undetected changes such as recursive directory delete
https://github.com/phpguard/listen/blob/cd0cda150858d6d85deb025a72996873d2af3532/src/PhpGuard/Listen/Adapter/BasicAdapter.php#L89-L101
metaclassing/PHP-Curler
src/Curler.php
Curler.curl_exec_utf8
public function curl_exec_utf8() { $data = curl_exec($this->curl); if (!is_string($data)) { return $data; } unset($charset); $content_type = curl_getinfo($this->curl, CURLINFO_CONTENT_TYPE); /* 1: HTTP Content-Type: header */ preg_match('@([\w/+]+)(;\s*charset=(\S+))?@i', $content_type, $matches); if (isset($matches[3])) { $charset = $matches[3]; } /* 2: <meta> element in the page */ if (!isset($charset)) { preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*charset=([^\s"]+))?@i', $data, $matches); if (isset($matches[3])) { $charset = $matches[3]; } } /* 3: <xml> element in the page */ if (!isset($charset)) { preg_match('@<\?xml.+encoding="([^\s"]+)@si', $data, $matches); if (isset($matches[1])) { $charset = $matches[1]; } } /* 4: PHP's heuristic detection */ if (!isset($charset)) { $encoding = mb_detect_encoding($data); if ($encoding) { $charset = $encoding; } } /* 5: Default for HTML */ if (!isset($charset)) { if (strstr($content_type, 'text/html') === 0) { $charset = 'ISO 8859-1'; } } /* Convert it if it is anything but UTF-8 */ /* You can change "UTF-8" to "UTF-8//IGNORE" to ignore conversion errors and still output something reasonable */ if (isset($charset) && strtoupper($charset) != 'UTF-8') { $data = iconv($charset, 'UTF-8', $data); } return $data; }
php
public function curl_exec_utf8() { $data = curl_exec($this->curl); if (!is_string($data)) { return $data; } unset($charset); $content_type = curl_getinfo($this->curl, CURLINFO_CONTENT_TYPE); /* 1: HTTP Content-Type: header */ preg_match('@([\w/+]+)(;\s*charset=(\S+))?@i', $content_type, $matches); if (isset($matches[3])) { $charset = $matches[3]; } /* 2: <meta> element in the page */ if (!isset($charset)) { preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*charset=([^\s"]+))?@i', $data, $matches); if (isset($matches[3])) { $charset = $matches[3]; } } /* 3: <xml> element in the page */ if (!isset($charset)) { preg_match('@<\?xml.+encoding="([^\s"]+)@si', $data, $matches); if (isset($matches[1])) { $charset = $matches[1]; } } /* 4: PHP's heuristic detection */ if (!isset($charset)) { $encoding = mb_detect_encoding($data); if ($encoding) { $charset = $encoding; } } /* 5: Default for HTML */ if (!isset($charset)) { if (strstr($content_type, 'text/html') === 0) { $charset = 'ISO 8859-1'; } } /* Convert it if it is anything but UTF-8 */ /* You can change "UTF-8" to "UTF-8//IGNORE" to ignore conversion errors and still output something reasonable */ if (isset($charset) && strtoupper($charset) != 'UTF-8') { $data = iconv($charset, 'UTF-8', $data); } return $data; }
The same as curl_exec except tries its best to convert the output to utf8 *
https://github.com/metaclassing/PHP-Curler/blob/6e658c141171d852c68754d452dbfb97b24638cc/src/Curler.php#L63-L118
shgysk8zer0/core_api
traits/http_auth.php
HTTP_Auth.authenticateBasic
final public function authenticateBasic($realm = null) { if (! ( array_key_exists('PHP_AUTH_USER', $_SERVER) and array_key_exists('PHP_AUTH_PW', $_SERVER)) and ! empty($_SERVER['PHP_AUTH_USER']) and ! empty($_SERER['PHP_AUTH_PW']) ) { $this->HTTPAuthenticate('Basic', array('realm' => $realm)); return false; } else { $this->HTTP_user = $_SERVER['PHP_AUTH_USER']; $this->HTTP_pass = $_SERVER['PHP_AUTH_PW']; return true; } }
php
final public function authenticateBasic($realm = null) { if (! ( array_key_exists('PHP_AUTH_USER', $_SERVER) and array_key_exists('PHP_AUTH_PW', $_SERVER)) and ! empty($_SERVER['PHP_AUTH_USER']) and ! empty($_SERER['PHP_AUTH_PW']) ) { $this->HTTPAuthenticate('Basic', array('realm' => $realm)); return false; } else { $this->HTTP_user = $_SERVER['PHP_AUTH_USER']; $this->HTTP_pass = $_SERVER['PHP_AUTH_PW']; return true; } }
Checks for credentials in HTTP headers for "Basic" authentication @param string $realm @return bool
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/http_auth.php#L48-L63
shgysk8zer0/core_api
traits/http_auth.php
HTTP_Auth.HTTPAuthenticate
final public function HTTPAuthenticate( $mode = 'Basic', array $params = array() ) { if (is_string($mode)) { $mode = ucwords(strtolower($mode)); } if (! (is_string($mode) and in_array($mode, array('Basic', 'Digest')))) { $mode = 'Basic'; } $params = array_filter($params, 'is_string'); $params = array_merge(array('realm' => $_SERVER['HTTP_HOST']), $params); header(sprintf( 'WWW-Authenticate: %s %s', $mode, join(', ', array_map( function($key, $val) { return $key . '="' . trim($val, '"') . '"'; }, array_keys($params), array_values($params) )) )); http_response_code(401); }
php
final public function HTTPAuthenticate( $mode = 'Basic', array $params = array() ) { if (is_string($mode)) { $mode = ucwords(strtolower($mode)); } if (! (is_string($mode) and in_array($mode, array('Basic', 'Digest')))) { $mode = 'Basic'; } $params = array_filter($params, 'is_string'); $params = array_merge(array('realm' => $_SERVER['HTTP_HOST']), $params); header(sprintf( 'WWW-Authenticate: %s %s', $mode, join(', ', array_map( function($key, $val) { return $key . '="' . trim($val, '"') . '"'; }, array_keys($params), array_values($params) )) )); http_response_code(401); }
Send headers requiring HTTP/WWW Authentication @param string $mode Basic or Digest @param array $params Additional components, such as "realm" @return void
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/http_auth.php#L72-L98
ThomasSquall/PHPMagicAnnotations
src/Reflection/ReflectionBase.php
ReflectionBase.hasAnnotation
public function hasAnnotation($name) { $result = false; if (!string_ends_with($name, 'Annotation')) $name .= 'Annotation'; foreach ($this->annotations as $annotation) { $class = get_class($annotation); if (string_starts_with($class, "\\") && !string_starts_with($name, "\\")) $name = "\\" . $name; elseif (!string_starts_with($class, "\\") && string_starts_with($name, "\\")) $name = substr($name, 1); if (string_ends_with($class, $name)) { $result = true; break; } } return $result; }
php
public function hasAnnotation($name) { $result = false; if (!string_ends_with($name, 'Annotation')) $name .= 'Annotation'; foreach ($this->annotations as $annotation) { $class = get_class($annotation); if (string_starts_with($class, "\\") && !string_starts_with($name, "\\")) $name = "\\" . $name; elseif (!string_starts_with($class, "\\") && string_starts_with($name, "\\")) $name = substr($name, 1); if (string_ends_with($class, $name)) { $result = true; break; } } return $result; }
Tells if the reflection object has the given annotation or not. @param string $name @return bool
https://github.com/ThomasSquall/PHPMagicAnnotations/blob/3a733fa6e1ca9ebdfdfb7250f67e7aceb6a4c001/src/Reflection/ReflectionBase.php#L20-L43
ThomasSquall/PHPMagicAnnotations
src/Reflection/ReflectionBase.php
ReflectionBase.getAnnotation
public function getAnnotation($name) { $result = null; if ($this->hasAnnotationAndReturn($name)) { if (!string_ends_with($name, 'Annotation')) $name .= 'Annotation'; $result = isset($this->annotations[$name]) ? $this->annotations[$name] : null; if ($result == null) { if (string_starts_with($name, '\\')) $name = substr($name, 1, strlen($name) - 1); else $name = '\\' . $name; $result = isset($this->annotations[$name]) ? $this->annotations[$name] : null; } $result = $this->evaluateAnnotation($result); } return $result; }
php
public function getAnnotation($name) { $result = null; if ($this->hasAnnotationAndReturn($name)) { if (!string_ends_with($name, 'Annotation')) $name .= 'Annotation'; $result = isset($this->annotations[$name]) ? $this->annotations[$name] : null; if ($result == null) { if (string_starts_with($name, '\\')) $name = substr($name, 1, strlen($name) - 1); else $name = '\\' . $name; $result = isset($this->annotations[$name]) ? $this->annotations[$name] : null; } $result = $this->evaluateAnnotation($result); } return $result; }
Returns the requested annotation. @param string $name @return Annotation|null
https://github.com/ThomasSquall/PHPMagicAnnotations/blob/3a733fa6e1ca9ebdfdfb7250f67e7aceb6a4c001/src/Reflection/ReflectionBase.php#L76-L100
native5/native5-sdk-client-php
src/Native5/Sessions/WebSessionManager.php
WebSessionManager.startSession
public function startSession($context=null, $useExisting=false) { $logger = $GLOBALS['logger']; $app = $GLOBALS['app']; // Strip '.' $appContext = rtrim($app->getConfiguration()->getApplicationContext(), '.'); if (empty($appContext)) { $appContext = "/"; } else { $appContext = "/".$appContext."/"; } if ($useExisting === true) { $sessionCookieName = $app->getConfiguration()->getApplicationContext()."-"."_n5_session"; $sessionCookieName = preg_replace("/\./", "_",$sessionCookieName); session_set_cookie_params(0, $appContext, null, false, true); session_name($sessionCookieName); session_start(); if (!$this->isActiveSession()) { self::resetActiveSession(); } $this->_session = new Session($_SESSION); if ($this->_session->getAttribute('category') !== null) { return; } } if (!isset($_SESSION[self::GLOBAL_PREFIX.'category'])) { // No session exists yet. if ($context === null) { $context = new WebContext($_REQUEST); } session_unset(); session_destroy(); $sessionCookieName = $app->getConfiguration()->getApplicationContext()."-"."_n5_session"; $sessionCookieName = preg_replace("/\./", "_",$sessionCookieName); session_set_cookie_params(0, $appContext, null, false, true); session_name($sessionCookieName); session_start(); session_regenerate_id(); $_SESSION = array(); $app = $GLOBALS['app']; if (!$app->getConfiguration()->isLocal()) { //$handler = new CachedSessionHandler(); //session_set_save_handler( //array($handler, 'open'), //array($handler, 'close'), //array($handler, 'read'), //array($handler, 'write'), //array($handler, 'destroy'), //array($handler, 'gc') //); } $_SESSION[self::GLOBAL_PREFIX.'category'] = $context->get('device'); $_SESSION[self::GLOBAL_PREFIX.'location'] = $context->get('location'); $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] = time(); }//end if $this->_session = new Session($_SESSION); }
php
public function startSession($context=null, $useExisting=false) { $logger = $GLOBALS['logger']; $app = $GLOBALS['app']; // Strip '.' $appContext = rtrim($app->getConfiguration()->getApplicationContext(), '.'); if (empty($appContext)) { $appContext = "/"; } else { $appContext = "/".$appContext."/"; } if ($useExisting === true) { $sessionCookieName = $app->getConfiguration()->getApplicationContext()."-"."_n5_session"; $sessionCookieName = preg_replace("/\./", "_",$sessionCookieName); session_set_cookie_params(0, $appContext, null, false, true); session_name($sessionCookieName); session_start(); if (!$this->isActiveSession()) { self::resetActiveSession(); } $this->_session = new Session($_SESSION); if ($this->_session->getAttribute('category') !== null) { return; } } if (!isset($_SESSION[self::GLOBAL_PREFIX.'category'])) { // No session exists yet. if ($context === null) { $context = new WebContext($_REQUEST); } session_unset(); session_destroy(); $sessionCookieName = $app->getConfiguration()->getApplicationContext()."-"."_n5_session"; $sessionCookieName = preg_replace("/\./", "_",$sessionCookieName); session_set_cookie_params(0, $appContext, null, false, true); session_name($sessionCookieName); session_start(); session_regenerate_id(); $_SESSION = array(); $app = $GLOBALS['app']; if (!$app->getConfiguration()->isLocal()) { //$handler = new CachedSessionHandler(); //session_set_save_handler( //array($handler, 'open'), //array($handler, 'close'), //array($handler, 'read'), //array($handler, 'write'), //array($handler, 'destroy'), //array($handler, 'gc') //); } $_SESSION[self::GLOBAL_PREFIX.'category'] = $context->get('device'); $_SESSION[self::GLOBAL_PREFIX.'location'] = $context->get('location'); $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] = time(); }//end if $this->_session = new Session($_SESSION); }
startSession @param mixed $context SessionContext @param mixed $useExisting Whether to use existing session. @access public @return void
https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Sessions/WebSessionManager.php#L58-L123
native5/native5-sdk-client-php
src/Native5/Sessions/WebSessionManager.php
WebSessionManager.isActiveSession
public function isActiveSession() { // Check if session timeout is defined in application settings $sessionConfig = $GLOBALS['app']->getConfiguration()->getRawConfiguration('session'); if (!empty($sessionConfig) && isset($sessionConfig['timeout']) && !empty($sessionConfig['timeout'])) { $sessionTimeout = $sessionConfig['timeout']; } else { $sessionTimeout = SESSION_TIMEOUT; } file_put_contents(getcwd().'/logs/session.log', print_r($_SESSION, 1)); if(isset($_SESSION[self::GLOBAL_PREFIX.'last_accessed']) && (time() - $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] > $sessionTimeout)) { return FALSE; } return TRUE; }
php
public function isActiveSession() { // Check if session timeout is defined in application settings $sessionConfig = $GLOBALS['app']->getConfiguration()->getRawConfiguration('session'); if (!empty($sessionConfig) && isset($sessionConfig['timeout']) && !empty($sessionConfig['timeout'])) { $sessionTimeout = $sessionConfig['timeout']; } else { $sessionTimeout = SESSION_TIMEOUT; } file_put_contents(getcwd().'/logs/session.log', print_r($_SESSION, 1)); if(isset($_SESSION[self::GLOBAL_PREFIX.'last_accessed']) && (time() - $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] > $sessionTimeout)) { return FALSE; } return TRUE; }
Checks if session is currently active. @access public @return boolean
https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Sessions/WebSessionManager.php#L175-L193
native5/native5-sdk-client-php
src/Native5/Sessions/WebSessionManager.php
WebSessionManager.resetActiveSession
public static function resetActiveSession() { // Strip '.' $appContext = rtrim($GLOBALS['app']->getConfiguration()->getApplicationContext(), '.'); if (empty($appContext)) { $appContext = "/"; } else { $appContext = "/".$appContext."/"; } $category = $_SESSION[self::GLOBAL_PREFIX.'category']; session_unset(); session_destroy(); $sessionCookieName = $GLOBALS['app']->getConfiguration()->getApplicationContext()."-"."_n5_session"; $sessionCookieName = preg_replace("/\./", "_",$sessionCookieName); session_set_cookie_params(0, $appContext, null, false, true); session_name($sessionCookieName); session_start(); session_regenerate_id(); $_SESSION = array(); $_SESSION[self::GLOBAL_PREFIX.'category'] = $category; $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] = time(); }
php
public static function resetActiveSession() { // Strip '.' $appContext = rtrim($GLOBALS['app']->getConfiguration()->getApplicationContext(), '.'); if (empty($appContext)) { $appContext = "/"; } else { $appContext = "/".$appContext."/"; } $category = $_SESSION[self::GLOBAL_PREFIX.'category']; session_unset(); session_destroy(); $sessionCookieName = $GLOBALS['app']->getConfiguration()->getApplicationContext()."-"."_n5_session"; $sessionCookieName = preg_replace("/\./", "_",$sessionCookieName); session_set_cookie_params(0, $appContext, null, false, true); session_name($sessionCookieName); session_start(); session_regenerate_id(); $_SESSION = array(); $_SESSION[self::GLOBAL_PREFIX.'category'] = $category; $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] = time(); }
Resets currently active session. @access public @return void
https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Sessions/WebSessionManager.php#L202-L225
native5/native5-sdk-client-php
src/Native5/Sessions/WebSessionManager.php
WebSessionManager.updateActiveSession
public static function updateActiveSession() { $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] = time(); // Update the session if session is authenticated and multiple logins is disabled $app = $GLOBALS['app']; if(\Native5\Identity\SecurityUtils::getSubject()->isAuthenticated() && $app->getConfiguration()->isPreventMultipleLogins()) { $sessionHash = $app->getSessionManager()->getActiveSession()->getAttribute('sessionHash'); $authenticator = new \Native5\Services\Identity\RemoteAuthenticationService(); $authenticator->onAccess($sessionHash); } }
php
public static function updateActiveSession() { $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] = time(); // Update the session if session is authenticated and multiple logins is disabled $app = $GLOBALS['app']; if(\Native5\Identity\SecurityUtils::getSubject()->isAuthenticated() && $app->getConfiguration()->isPreventMultipleLogins()) { $sessionHash = $app->getSessionManager()->getActiveSession()->getAttribute('sessionHash'); $authenticator = new \Native5\Services\Identity\RemoteAuthenticationService(); $authenticator->onAccess($sessionHash); } }
updateActiveSession @access public @return void
https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Sessions/WebSessionManager.php#L234-L245
MindyPHP/QueryBuilder
Database/Pgsql/Adapter.php
Adapter.sqlCheckIntegrity
public function sqlCheckIntegrity($check = true, $schema = '', $table = '') { if (empty($schema) && empty($table)) { return 'SET CONSTRAINTS ALL '.($check ? 'IMMEDIATE' : 'DEFERRED'); } return sprintf( 'ALTER TABLE %s.%s %s TRIGGER ALL', $this->getQuotedName($table), $this->getQuotedName($schema), $check ? 'ENABLE' : 'DISABLE' ); }
php
public function sqlCheckIntegrity($check = true, $schema = '', $table = '') { if (empty($schema) && empty($table)) { return 'SET CONSTRAINTS ALL '.($check ? 'IMMEDIATE' : 'DEFERRED'); } return sprintf( 'ALTER TABLE %s.%s %s TRIGGER ALL', $this->getQuotedName($table), $this->getQuotedName($schema), $check ? 'ENABLE' : 'DISABLE' ); }
Builds a SQL statement for enabling or disabling integrity check. @param bool $check whether to turn on or off the integrity check @param string $schema the schema of the tables @param string $table the table name @return string the SQL statement for checking integrity
https://github.com/MindyPHP/QueryBuilder/blob/fc486454786f3d38887dd7246802ea11e2954e54/Database/Pgsql/Adapter.php#L28-L40
Panigale/laravel5-Points
src/Models/PointRules.php
PointRules.create
public static function create(array $attributes = []) { if(!is_null(PointRules::where('name', $attributes['name'])->first())){ // if (static::getRules()->where('name', $attributes['name'])->first()) { throw PointRuleAlreadyExists::create($attributes['name']); } return static::query()->create($attributes); }
php
public static function create(array $attributes = []) { if(!is_null(PointRules::where('name', $attributes['name'])->first())){ // if (static::getRules()->where('name', $attributes['name'])->first()) { throw PointRuleAlreadyExists::create($attributes['name']); } return static::query()->create($attributes); }
建立點數規則 @param array $attributes @return mixed
https://github.com/Panigale/laravel5-Points/blob/6fb559d91694a336f5a11d8408348a85395b4ff3/src/Models/PointRules.php#L33-L41
Panigale/laravel5-Points
src/Models/PointRules.php
PointRules.findByName
public static function findByName(string $name) { $rules = static::getRules()->where('name' ,$name)->first(); if(!$rules){ throw PointRuleNotExist::create($name); } return $rules; }
php
public static function findByName(string $name) { $rules = static::getRules()->where('name' ,$name)->first(); if(!$rules){ throw PointRuleNotExist::create($name); } return $rules; }
依照點數名稱搜尋規則 @param string $name @return mixed
https://github.com/Panigale/laravel5-Points/blob/6fb559d91694a336f5a11d8408348a85395b4ff3/src/Models/PointRules.php#L59-L68
kduma-OSS/L5-permissions
PermissionsServiceProvider.php
PermissionsServiceProvider.register
public function register() { $this->mergeConfigFrom( __DIR__.'/Config/permissions.php', 'permissions' ); $this->app->singleton('permissions.templatehelper', function () { return new PermissionsTemplateHelper(); }); $this->app->singleton('permissions.adderhelper', function () { return new PermissionsAdderHelper(); }); }
php
public function register() { $this->mergeConfigFrom( __DIR__.'/Config/permissions.php', 'permissions' ); $this->app->singleton('permissions.templatehelper', function () { return new PermissionsTemplateHelper(); }); $this->app->singleton('permissions.adderhelper', function () { return new PermissionsAdderHelper(); }); }
Register the application services. @return void
https://github.com/kduma-OSS/L5-permissions/blob/0e11c1dc1dc083f972cef5a52ced664b7390b054/PermissionsServiceProvider.php#L32-L45
linpax/microphp-framework
src/web/Identity.php
Identity.addCookie
public function addCookie( $name, $value, $expire = 0, $path = '/', $domain = '', $secure = false, $httpOnly = true ) { return (new CookieInjector)->build()->set($name, $value, $expire, $path, $domain, $secure, $httpOnly); }
php
public function addCookie( $name, $value, $expire = 0, $path = '/', $domain = '', $secure = false, $httpOnly = true ) { return (new CookieInjector)->build()->set($name, $value, $expire, $path, $domain, $secure, $httpOnly); }
Add data into cookie @access public @param string $name cookie name @param mixed $value data value @param int $expire life time @param string $path path access cookie @param string $domain domain access cookie @param bool $secure use SSL? @param bool $httpOnly disable on JS? @return mixed @throws Exception
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/web/Identity.php#L89-L99
pryley/castor-framework
src/Forms/Fields/Base.php
Base.generateDescription
public function generateDescription( $paragraph = true ) { if( !isset( $this->args['desc'] ) || !$this->args['desc'] )return; $tag = ( !!$paragraph || $paragraph == 'p' ) ? 'p' : 'span'; return sprintf( '<%1$s class="description">%2$s</%1$s>', $tag, $this->args['desc'] ); }
php
public function generateDescription( $paragraph = true ) { if( !isset( $this->args['desc'] ) || !$this->args['desc'] )return; $tag = ( !!$paragraph || $paragraph == 'p' ) ? 'p' : 'span'; return sprintf( '<%1$s class="description">%2$s</%1$s>', $tag, $this->args['desc'] ); }
Generate the field description @param bool $paragraph @return null|string
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Fields/Base.php#L72-L79
pryley/castor-framework
src/Forms/Fields/Base.php
Base.implodeOptions
protected function implodeOptions( $method = 'select_option', $default = null ) { $this->args['default'] ?: $this->args['default'] = $default; $method = $this->camelCase( $method ); $method = method_exists( $this, $method ) ? $method : 'selectOption'; $i = 0; if( $method === 'singleInput' ) { if( !isset( $this->args['options'] ) || empty( $this->args['options'] ))return; // hack to make sure unset single checkbox values start at 1 instead of 0 if( key( $this->args['options'] ) === 0 ) { $options = ['1' => $this->args['options'][0]]; $this->args['options'] = $options; } return $this->singleInput(); } return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use ( &$i, $method ) { return $carry .= $this->$method( $key, $i++ ); }); }
php
protected function implodeOptions( $method = 'select_option', $default = null ) { $this->args['default'] ?: $this->args['default'] = $default; $method = $this->camelCase( $method ); $method = method_exists( $this, $method ) ? $method : 'selectOption'; $i = 0; if( $method === 'singleInput' ) { if( !isset( $this->args['options'] ) || empty( $this->args['options'] ))return; // hack to make sure unset single checkbox values start at 1 instead of 0 if( key( $this->args['options'] ) === 0 ) { $options = ['1' => $this->args['options'][0]]; $this->args['options'] = $options; } return $this->singleInput(); } return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use ( &$i, $method ) { return $carry .= $this->$method( $key, $i++ ); }); }
Implode multi-field items @return null|string
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Fields/Base.php#L133-L161
pryley/castor-framework
src/Forms/Fields/Base.php
Base.normalize
protected function normalize( array $defaults = [], $implode = false ) { $args = $this->mergeAttributesWith( $defaults ); $normalize = new Normalizer; return ( $this->element && method_exists( $normalize, $this->element )) ? $normalize->{$this->element}( $args, $implode ) : ( !!$implode ? '' : [] ); }
php
protected function normalize( array $defaults = [], $implode = false ) { $args = $this->mergeAttributesWith( $defaults ); $normalize = new Normalizer; return ( $this->element && method_exists( $normalize, $this->element )) ? $normalize->{$this->element}( $args, $implode ) : ( !!$implode ? '' : [] ); }
Normalize attributes for this specific field type @param bool|string $implode @return array|string
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Fields/Base.php#L170-L179
pryley/castor-framework
src/Forms/Fields/Base.php
Base.mergeAttributesWith
protected function mergeAttributesWith( array $defaults ) { // similar to array_merge except overwrite empty values foreach( $defaults as $key => $value ) { if( isset( $this->args[ $key ] ) && !empty( $this->args[ $key ] ))continue; $this->args[ $key ] = $value; } $attributes = $this->args['attributes']; // prioritize $attributes over $this->args, don't worry about duplicates return array_merge( $this->args, $attributes ); }
php
protected function mergeAttributesWith( array $defaults ) { // similar to array_merge except overwrite empty values foreach( $defaults as $key => $value ) { if( isset( $this->args[ $key ] ) && !empty( $this->args[ $key ] ))continue; $this->args[ $key ] = $value; } $attributes = $this->args['attributes']; // prioritize $attributes over $this->args, don't worry about duplicates return array_merge( $this->args, $attributes ); }
Merge and overwrite empty $this->args values with $defaults @return array
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Fields/Base.php#L186-L198
pryley/castor-framework
src/Forms/Fields/Base.php
Base.multiInput
protected function multiInput( $optionKey, $number, $type = 'radio' ) { $args = $this->multiInputArgs( $type, $optionKey, $number ); if( !$args )return; $attributes = ''; foreach( $args['attributes'] as $key => $val ) { $attributes .= sprintf( '%s="%s" ', $key, $val ); } return sprintf( '<li><label for="%s"><input %s%s/> %s</label></li>', $args['attributes']['id'], $attributes, checked( $args['value'], $args['attributes']['value'], false ), $args['label'] ); }
php
protected function multiInput( $optionKey, $number, $type = 'radio' ) { $args = $this->multiInputArgs( $type, $optionKey, $number ); if( !$args )return; $attributes = ''; foreach( $args['attributes'] as $key => $val ) { $attributes .= sprintf( '%s="%s" ', $key, $val ); } return sprintf( '<li><label for="%s"><input %s%s/> %s</label></li>', $args['attributes']['id'], $attributes, checked( $args['value'], $args['attributes']['value'], false ), $args['label'] ); }
Generate checkboxes and radios @param string $optionKey @param string $number @param string $type @return null|string
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Fields/Base.php#L209-L227
pryley/castor-framework
src/Forms/Fields/Base.php
Base.multiInputArgs
protected function multiInputArgs( $type, $optionName, $number ) { $defaults = [ 'class' => '', 'name' => '', 'type' => $type, 'value' => '', ]; $args = []; $value = $this->args['options'][ $optionName ]; if( is_array( $value )) { $args = $value; } if( is_string( $value )) { $label = $value; } isset( $args['name'] ) ?: $args['name'] = $optionName; isset( $args['value'] ) ?: $args['value'] = $optionName; $args = wp_parse_args( $args, $defaults ); if( !isset( $label ) || $args['name'] === '' )return; $args['id'] = $this->args['id'] . "-{$number}"; $args['name'] = $this->args['name'] . ( $type === 'checkbox' && $this->multi ? '[]' : '' ); $args = array_filter( $args, function( $value ) { return $value !== ''; }); if( is_array( $this->args['value'] )) { if( in_array( $args['value'], $this->args['value'] )) { $this->args['default'] = $args['value']; } } else if( $this->args['value'] ) { $this->args['default'] = $this->args['value']; } else if( $type == 'radio' && !$this->args['default'] ) { $this->args['default'] = 0; } return [ 'attributes' => $args, 'label' => $label, 'value' => $this->args['default'], ]; }
php
protected function multiInputArgs( $type, $optionName, $number ) { $defaults = [ 'class' => '', 'name' => '', 'type' => $type, 'value' => '', ]; $args = []; $value = $this->args['options'][ $optionName ]; if( is_array( $value )) { $args = $value; } if( is_string( $value )) { $label = $value; } isset( $args['name'] ) ?: $args['name'] = $optionName; isset( $args['value'] ) ?: $args['value'] = $optionName; $args = wp_parse_args( $args, $defaults ); if( !isset( $label ) || $args['name'] === '' )return; $args['id'] = $this->args['id'] . "-{$number}"; $args['name'] = $this->args['name'] . ( $type === 'checkbox' && $this->multi ? '[]' : '' ); $args = array_filter( $args, function( $value ) { return $value !== ''; }); if( is_array( $this->args['value'] )) { if( in_array( $args['value'], $this->args['value'] )) { $this->args['default'] = $args['value']; } } else if( $this->args['value'] ) { $this->args['default'] = $this->args['value']; } else if( $type == 'radio' && !$this->args['default'] ) { $this->args['default'] = 0; } return [ 'attributes' => $args, 'label' => $label, 'value' => $this->args['default'], ]; }
Build the checkbox/radio args @param string $type @param string $optionName @param string $number @return array|null
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Fields/Base.php#L238-L290
pryley/castor-framework
src/Forms/Fields/Base.php
Base.selectOption
protected function selectOption( $optionKey ) { return sprintf( '<option value="%s"%s>%s</option>', $optionKey, selected( $this->args['value'], $optionKey, false ), $this->args['options'][ $optionKey ] ); }
php
protected function selectOption( $optionKey ) { return sprintf( '<option value="%s"%s>%s</option>', $optionKey, selected( $this->args['value'], $optionKey, false ), $this->args['options'][ $optionKey ] ); }
Generate select options @param string $optionKey @return string
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Fields/Base.php#L312-L319
pryley/castor-framework
src/Forms/Fields/Base.php
Base.singleInput
protected function singleInput( $type = 'checkbox' ) { $optionKey = key( $this->args['options'] ); $args = $this->multiInputArgs( $type, $optionKey, 1 ); if( !$args )return; $atts = $this->normalize(); $atts = wp_parse_args( $args['attributes'], $atts ); $attributes = ''; foreach( $atts as $key => $val ) { $attributes .= sprintf( '%s="%s" ', $key, $val ); } return sprintf( '<label for="%s"><input %s%s/> %s</label>', $atts['id'], $attributes, checked( $args['value'], $atts['value'], false ), $args['label'] ); }
php
protected function singleInput( $type = 'checkbox' ) { $optionKey = key( $this->args['options'] ); $args = $this->multiInputArgs( $type, $optionKey, 1 ); if( !$args )return; $atts = $this->normalize(); $atts = wp_parse_args( $args['attributes'], $atts ); $attributes = ''; foreach( $atts as $key => $val ) { $attributes .= sprintf( '%s="%s" ', $key, $val ); } return sprintf( '<label for="%s"><input %s%s/> %s</label>', $atts['id'], $attributes, checked( $args['value'], $atts['value'], false ), $args['label'] ); }
Generate a single checkbox @param string $type @return null|string
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Forms/Fields/Base.php#L328-L351
erenmustafaozdal/laravel-modules-base
src/Controllers/DataTableTrait.php
DataTableTrait.getDatatables
public function getDatatables($query,array $addColumns = [],array $editColumns = [],array $removeColumns = []) { $this->dataTables = Datatables::of($query); // add new urls $addUrls = array_has($addColumns, 'addUrls') ? array_pull($addColumns, 'addUrls') : []; $this->dataTables->addColumn('urls', function($model) use($addUrls) { // if addUrls variable is empty return if ( ! $addUrls) { return false; } $urls = $this->getDefaultUrls($model); foreach($addUrls as $key => $value) { $urls[$key] = $this->getUrl($value, $model); } return $urls; }); // add, edit, remove columns $this->setColumns([ 'add' => $addColumns, 'edit' => $editColumns, 'remove' => $removeColumns ]); return $this->dataTables->addColumn('check_id', '{{ $id }}')->make(true); }
php
public function getDatatables($query,array $addColumns = [],array $editColumns = [],array $removeColumns = []) { $this->dataTables = Datatables::of($query); // add new urls $addUrls = array_has($addColumns, 'addUrls') ? array_pull($addColumns, 'addUrls') : []; $this->dataTables->addColumn('urls', function($model) use($addUrls) { // if addUrls variable is empty return if ( ! $addUrls) { return false; } $urls = $this->getDefaultUrls($model); foreach($addUrls as $key => $value) { $urls[$key] = $this->getUrl($value, $model); } return $urls; }); // add, edit, remove columns $this->setColumns([ 'add' => $addColumns, 'edit' => $editColumns, 'remove' => $removeColumns ]); return $this->dataTables->addColumn('check_id', '{{ $id }}')->make(true); }
get Datatables @param $query @param array $addColumns @param array $editColumns @param array $removeColumns @return \Yajra\Datatables\Datatables
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/DataTableTrait.php#L26-L48
erenmustafaozdal/laravel-modules-base
src/Controllers/DataTableTrait.php
DataTableTrait.setColumns
public function setColumns(array $columns) { // add columns foreach($columns['add'] as $key => $value) { $this->dataTables->addColumn($key, $value); } // edit columns foreach($columns['edit'] as $key => $value) { $this->dataTables->editColumn($key, $value); } // remove columns foreach($columns['remove'] as $value) { $this->dataTables->removeColumn($value); } }
php
public function setColumns(array $columns) { // add columns foreach($columns['add'] as $key => $value) { $this->dataTables->addColumn($key, $value); } // edit columns foreach($columns['edit'] as $key => $value) { $this->dataTables->editColumn($key, $value); } // remove columns foreach($columns['remove'] as $value) { $this->dataTables->removeColumn($value); } }
set data table columns @param array $columns [array('add' => ..., 'edit' => ...,'remove' => ...)] @return void
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/DataTableTrait.php#L56-L72
erenmustafaozdal/laravel-modules-base
src/Controllers/DataTableTrait.php
DataTableTrait.getUrl
private function getUrl($value, $model) { if(isset($value['id']) && $value['id']) { $routeParam = isset($value['model']) ? [ 'id' => $value['id'], $value['model'] => $model->id] : ['id' => $model->id]; return lmbRoute($value['route'], $routeParam); } return lmbRoute($value['route']); }
php
private function getUrl($value, $model) { if(isset($value['id']) && $value['id']) { $routeParam = isset($value['model']) ? [ 'id' => $value['id'], $value['model'] => $model->id] : ['id' => $model->id]; return lmbRoute($value['route'], $routeParam); } return lmbRoute($value['route']); }
get url @param array $value @param \Illuminate\Database\Eloquent\Model $model @return string
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/DataTableTrait.php#L81-L91
erenmustafaozdal/laravel-modules-base
src/Controllers/DataTableTrait.php
DataTableTrait.getDefaultUrls
private function getDefaultUrls($model) { $slug = getModelSlug($model); return [ 'details' => lmbRoute("api.{$slug}.detail", ['id' => $model->id]), 'fast_edit' => lmbRoute("api.{$slug}.fastEdit", ['id' => $model->id]), 'edit' => lmbRoute("api.{$slug}.update", ['id' => $model->id]), 'destroy' => lmbRoute("api.{$slug}.destroy", ['id' => $model->id]), 'show' => lmbRoute("admin.{$slug}.show", ['id' => $model->id]) ]; }
php
private function getDefaultUrls($model) { $slug = getModelSlug($model); return [ 'details' => lmbRoute("api.{$slug}.detail", ['id' => $model->id]), 'fast_edit' => lmbRoute("api.{$slug}.fastEdit", ['id' => $model->id]), 'edit' => lmbRoute("api.{$slug}.update", ['id' => $model->id]), 'destroy' => lmbRoute("api.{$slug}.destroy", ['id' => $model->id]), 'show' => lmbRoute("admin.{$slug}.show", ['id' => $model->id]) ]; }
get default urls for Datatables @param \Illuminate\Database\Eloquent\Model $model @return array
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Controllers/DataTableTrait.php#L99-L109
Eden-PHP/Block
Component/Pagination.php
Pagination.getVariables
public function getVariables() { $pages = ceil($this->total / $this->range); $page = floor($this->start / $this->range) + 1; $min = $page - $this->show; $max = $page + $this->show; if($min < 1) { $min = 1; } if($max > $pages) { $max = $pages; } return array( 'class' => $this->class, 'url' => $this->url, 'query' => $this->query, 'start' => $this->start, 'range' => $this->range, 'total' => $this->total, 'show' => $this->show, 'min' => $min, 'max' => $max, 'pages' => $pages, 'page' => $page); }
php
public function getVariables() { $pages = ceil($this->total / $this->range); $page = floor($this->start / $this->range) + 1; $min = $page - $this->show; $max = $page + $this->show; if($min < 1) { $min = 1; } if($max > $pages) { $max = $pages; } return array( 'class' => $this->class, 'url' => $this->url, 'query' => $this->query, 'start' => $this->start, 'range' => $this->range, 'total' => $this->total, 'show' => $this->show, 'min' => $min, 'max' => $max, 'pages' => $pages, 'page' => $page); }
Returns the template variables in key value format @param array data @return array
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Component/Pagination.php#L43-L71
Eden-PHP/Block
Component/Pagination.php
Pagination.setShow
public function setShow($show) { Argument::i()->test(1, 'int'); if($show < 1) { $show = 1; } $this->show = $show; return $this; }
php
public function setShow($show) { Argument::i()->test(1, 'int'); if($show < 1) { $show = 1; } $this->show = $show; return $this; }
Sets pages to show left and right of the current page @param int @return Eden\Block\Component\Pagination
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Component/Pagination.php#L146-L156
tonis-io-legacy/package
src/Subscriber/DefaultSubscriber.php
DefaultSubscriber.onLoad
public function onLoad(PackageEvent $event) { $manager = $event->getPackageManager(); $packages = $manager->getPackages(); foreach ($packages as $fqcn => $package) { $package = class_exists($fqcn) ? new $fqcn() : null; if (null === $package) { throw new PackageLoadFailedException($fqcn); } $packages[$fqcn] = $package; } }
php
public function onLoad(PackageEvent $event) { $manager = $event->getPackageManager(); $packages = $manager->getPackages(); foreach ($packages as $fqcn => $package) { $package = class_exists($fqcn) ? new $fqcn() : null; if (null === $package) { throw new PackageLoadFailedException($fqcn); } $packages[$fqcn] = $package; } }
{@inheritDoc}
https://github.com/tonis-io-legacy/package/blob/ecb7eb5778bfbdd2d0f367bdfa9281e098483341/src/Subscriber/DefaultSubscriber.php#L27-L40
tonis-io-legacy/package
src/Subscriber/DefaultSubscriber.php
DefaultSubscriber.onMerge
public function onMerge(PackageEvent $event) { $manager = $event->getPackageManager(); $config = []; foreach ($manager->getPackages() as $package) { if ($package instanceof ConfigProviderInterface) { $config = $manager->merge($config, $package->getConfig()); } } $pmConfig = $manager->getConfig(); if (null === $pmConfig['override_pattern']) { return $config; } $overrideFiles = glob($pmConfig['override_pattern'], $pmConfig['override_flags']); foreach ($overrideFiles as $file) { $config = $manager->merge($config, include $file); } return $config; }
php
public function onMerge(PackageEvent $event) { $manager = $event->getPackageManager(); $config = []; foreach ($manager->getPackages() as $package) { if ($package instanceof ConfigProviderInterface) { $config = $manager->merge($config, $package->getConfig()); } } $pmConfig = $manager->getConfig(); if (null === $pmConfig['override_pattern']) { return $config; } $overrideFiles = glob($pmConfig['override_pattern'], $pmConfig['override_flags']); foreach ($overrideFiles as $file) { $config = $manager->merge($config, include $file); } return $config; }
{@inheritDoc}
https://github.com/tonis-io-legacy/package/blob/ecb7eb5778bfbdd2d0f367bdfa9281e098483341/src/Subscriber/DefaultSubscriber.php#L45-L67
Wedeto/DB
src/Query/ConstantArray.php
ConstantArray.toSQL
public function toSQL(Parameters $params, bool $inner_clause) { if ($key = $this->getKey()) { try { $params->get($key); } catch (\OutOfRangeException $e) { // Not a valid key, replace $key = null; } } if (!$key) $key = $params->assign(null); // Rebind, to be sure $this->bind($params, $key, array($params->getDriver(), 'formatArray')); return ':' . $key; }
php
public function toSQL(Parameters $params, bool $inner_clause) { if ($key = $this->getKey()) { try { $params->get($key); } catch (\OutOfRangeException $e) { // Not a valid key, replace $key = null; } } if (!$key) $key = $params->assign(null); // Rebind, to be sure $this->bind($params, $key, array($params->getDriver(), 'formatArray')); return ':' . $key; }
Write a constant array clause as SQL query syntax @param Parameters $params The query parameters: tables and placeholder values @return string The generated SQL
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/ConstantArray.php#L63-L84
balintsera/evista-perform
src/Service.php
Service.transpileForm
public function transpileForm($markup) { $transpiledForm = new TranspiledForm($markup, $this->crawler, false, $this->uploadDir); // Return the result form object return $transpiledForm->getForm(); }
php
public function transpileForm($markup) { $transpiledForm = new TranspiledForm($markup, $this->crawler, false, $this->uploadDir); // Return the result form object return $transpiledForm->getForm(); }
Init transpilation @param $markup @return mixed
https://github.com/balintsera/evista-perform/blob/2b8723852ebe824ed721f30293e1e0d2c14f4b21/src/Service.php#L34-L40
PenoaksDev/Milky-Framework
src/Milky/Filesystem/Filesystem.php
Filesystem.moveDirectory
public function moveDirectory( $from, $to, $overwrite = false ) { if ( $overwrite && $this->isDirectory( $to ) ) { $this->deleteDirectory( $to ); $this->copyDirectory( $from, $to ); $this->deleteDirectory( $from ); return true; } return @rename( $from, $to ) === true; }
php
public function moveDirectory( $from, $to, $overwrite = false ) { if ( $overwrite && $this->isDirectory( $to ) ) { $this->deleteDirectory( $to ); $this->copyDirectory( $from, $to ); $this->deleteDirectory( $from ); return true; } return @rename( $from, $to ) === true; }
Move a directory. @param string $from @param string $to @param bool $overwrite @return bool
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Filesystem/Filesystem.php#L426-L440
thomasez/BisonLabSakonninBundle
Service/Templates.php
Templates.storeTemplate
public function storeTemplate(SakonninTemplate $template, array $options) { $em = $this->getDoctrineManager(); $em->persist($template); return $template; }
php
public function storeTemplate(SakonninTemplate $template, array $options) { $em = $this->getDoctrineManager(); $em->persist($template); return $template; }
/* Should I bother having this one? Not sure "Put everything in a service" is a fad any more. But the options is the key here. It's for futureproofing and reminding me why I have this. (Why you say? May be that I add contexts or some logging to it all.)
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Service/Templates.php#L43-L48
DarvinStudio/fileman
src/Darvin/Fileman/Manager/LocalManager.php
LocalManager.archiveFiles
public function archiveFiles(callable $callback) { $archiveFilenames = []; foreach ($this->getDirs() as $param => $dir) { $filename = $this->nameArchive($dir, 'local'); if (!$this->archiver->archive(sprintf('%sweb/%s', $this->getProjectPath(), $dir), $this->getProjectPath().$filename)) { continue; } $callback($filename); $archiveFilenames[$param] = $this->filesToRemove[] = $filename; } return $archiveFilenames; }
php
public function archiveFiles(callable $callback) { $archiveFilenames = []; foreach ($this->getDirs() as $param => $dir) { $filename = $this->nameArchive($dir, 'local'); if (!$this->archiver->archive(sprintf('%sweb/%s', $this->getProjectPath(), $dir), $this->getProjectPath().$filename)) { continue; } $callback($filename); $archiveFilenames[$param] = $this->filesToRemove[] = $filename; } return $archiveFilenames; }
@param callable $callback Success callback @return array
https://github.com/DarvinStudio/fileman/blob/940055874d2b094e082aabfa6ad7fc0fc17c8396/src/Darvin/Fileman/Manager/LocalManager.php#L60-L77
DarvinStudio/fileman
src/Darvin/Fileman/Manager/LocalManager.php
LocalManager.getConfigurationYaml
protected function getConfigurationYaml() { $pathname = $this->getProjectPath().'app/config/parameters.yml'; $yaml = @file_get_contents($pathname); if (false === $yaml) { throw new \RuntimeException(sprintf('Unable to read configuration file "%s".', $pathname)); } return $yaml; }
php
protected function getConfigurationYaml() { $pathname = $this->getProjectPath().'app/config/parameters.yml'; $yaml = @file_get_contents($pathname); if (false === $yaml) { throw new \RuntimeException(sprintf('Unable to read configuration file "%s".', $pathname)); } return $yaml; }
{@inheritdoc}
https://github.com/DarvinStudio/fileman/blob/940055874d2b094e082aabfa6ad7fc0fc17c8396/src/Darvin/Fileman/Manager/LocalManager.php#L103-L114
PenoaksDev/Milky-Framework
src/Milky/Http/Middleware/ShareSessionMessages.php
ShareSessionMessages.handle
public function handle($request, Closure $next) { // If the current session has an "errors" variable bound to it, we will share // its value with all view instances so the views can easily access errors // without having to bind. An empty bag is set when there aren't errors. $this->view->share( 'errors', $request->session()->get('errors') ?: new ViewErrorBag ); $this->view->share( 'messages', $request->session()->get('messages') ?: new ViewErrorBag ); // Putting the errors in the view for every view allows the developer to just // assume that some errors are always available, which is convenient since // they don't have to continually run checks for the presence of errors. return $next($request); }
php
public function handle($request, Closure $next) { // If the current session has an "errors" variable bound to it, we will share // its value with all view instances so the views can easily access errors // without having to bind. An empty bag is set when there aren't errors. $this->view->share( 'errors', $request->session()->get('errors') ?: new ViewErrorBag ); $this->view->share( 'messages', $request->session()->get('messages') ?: new ViewErrorBag ); // Putting the errors in the view for every view allows the developer to just // assume that some errors are always available, which is convenient since // they don't have to continually run checks for the presence of errors. return $next($request); }
Handle an incoming request. @param Request $request @param \Closure $next @return mixed
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Http/Middleware/ShareSessionMessages.php#L35-L53
sndsgd/form
src/form/field/FieldAbstract.php
FieldAbstract.getName
public function getName(array $keys = [], string $delimiter = "."): string { if (empty($keys)) { return $this->name; } $keys[] = $this->name; return implode($delimiter, $keys); }
php
public function getName(array $keys = [], string $delimiter = "."): string { if (empty($keys)) { return $this->name; } $keys[] = $this->name; return implode($delimiter, $keys); }
Get the name of the field @param array<string> $keys The nested names of parents @param string $delimiter A string to use when joining the name @return string
https://github.com/sndsgd/form/blob/56b5b9572a8942aea34c97c7c838b871e198e34f/src/form/field/FieldAbstract.php#L67-L75
sndsgd/form
src/form/field/FieldAbstract.php
FieldAbstract.getNestedName
public function getNestedName( string $delimiter = ".", string $name = "" ): string { $keys = array_filter([$this->name, $name], "strlen"); $parent = $this; while ($parent = $parent->getParent()) { $name = $parent->getName(); if ($name) { array_unshift($keys, $parent->getName()); } } return implode($delimiter, $keys); }
php
public function getNestedName( string $delimiter = ".", string $name = "" ): string { $keys = array_filter([$this->name, $name], "strlen"); $parent = $this; while ($parent = $parent->getParent()) { $name = $parent->getName(); if ($name) { array_unshift($keys, $parent->getName()); } } return implode($delimiter, $keys); }
Get a field's nested name @param string $delimiter @param string $name A name to append to the result @return string
https://github.com/sndsgd/form/blob/56b5b9572a8942aea34c97c7c838b871e198e34f/src/form/field/FieldAbstract.php#L84-L98
phpgears/identity
src/HashUuidIdentity.php
HashUuidIdentity.fromString
final public static function fromString(string $value) { try { $uuid = Uuid::fromString((new Hashids())->decodeHex($value)); } catch (InvalidUuidStringException $exception) { throw new InvalidIdentityException( \sprintf('Provided identity value "%s" is not a valid hashed UUID', $value), 0, $exception ); } if ($uuid->getVariant() !== Uuid::RFC_4122 || !\in_array($uuid->getVersion(), \range(1, 5), true)) { throw new InvalidIdentityException( \sprintf('Provided identity value "%s" is not a valid hashed UUID', $value) ); } return new static($value); }
php
final public static function fromString(string $value) { try { $uuid = Uuid::fromString((new Hashids())->decodeHex($value)); } catch (InvalidUuidStringException $exception) { throw new InvalidIdentityException( \sprintf('Provided identity value "%s" is not a valid hashed UUID', $value), 0, $exception ); } if ($uuid->getVariant() !== Uuid::RFC_4122 || !\in_array($uuid->getVersion(), \range(1, 5), true)) { throw new InvalidIdentityException( \sprintf('Provided identity value "%s" is not a valid hashed UUID', $value) ); } return new static($value); }
{@inheritdoc} @throws InvalidIdentityException
https://github.com/phpgears/identity/blob/1067571ad5b7a109cfe722f13d4a74ea4fd4d82c/src/HashUuidIdentity.php#L31-L50
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Model/MergeModel.php
MergeModel.getTableName
public function getTableName() { if(empty($this->trueTableName)) { $tableName = array(); $models = $this->modelList; foreach($models as $model){ $tableName[] = M($model)->getTableName().' '.$model; } $this->trueTableName = implode(',',$tableName); } return $this->trueTableName; }
php
public function getTableName() { if(empty($this->trueTableName)) { $tableName = array(); $models = $this->modelList; foreach($models as $model){ $tableName[] = M($model)->getTableName().' '.$model; } $this->trueTableName = implode(',',$tableName); } return $this->trueTableName; }
得到完整的数据表名 @access public @return string
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/MergeModel.php#L66-L76
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Model/MergeModel.php
MergeModel.add
public function add($data='',$options=array(),$replace=false){ if(empty($data)) { // 没有传递数据,获取当前数据对象的值 if(!empty($this->data)) { $data = $this->data; // 重置数据 $this->data = array(); }else{ $this->error = L('_DATA_TYPE_INVALID_'); return false; } } // 启动事务 $this->startTrans(); // 写入主表数据 $result = M($this->masterModel)->strict(false)->add($data); if($result){ // 写入外键数据 $data[$this->fk] = $result; $models = $this->modelList; array_shift($models); // 写入附表数据 foreach($models as $model){ $res = M($model)->strict(false)->add($data); if(!$res){ $this->rollback(); return false; } } // 提交事务 $this->commit(); }else{ $this->rollback(); return false; } return $result; }
php
public function add($data='',$options=array(),$replace=false){ if(empty($data)) { // 没有传递数据,获取当前数据对象的值 if(!empty($this->data)) { $data = $this->data; // 重置数据 $this->data = array(); }else{ $this->error = L('_DATA_TYPE_INVALID_'); return false; } } // 启动事务 $this->startTrans(); // 写入主表数据 $result = M($this->masterModel)->strict(false)->add($data); if($result){ // 写入外键数据 $data[$this->fk] = $result; $models = $this->modelList; array_shift($models); // 写入附表数据 foreach($models as $model){ $res = M($model)->strict(false)->add($data); if(!$res){ $this->rollback(); return false; } } // 提交事务 $this->commit(); }else{ $this->rollback(); return false; } return $result; }
新增聚合数据 @access public @param mixed $data 数据 @param array $options 表达式 @param boolean $replace 是否replace @return mixed
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/MergeModel.php#L93-L129
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Model/MergeModel.php
MergeModel._facade
protected function _facade($data) { // 检查数据字段合法性 if(!empty($this->fields)) { if(!empty($this->options['field'])) { $fields = $this->options['field']; unset($this->options['field']); if(is_string($fields)) { $fields = explode(',',$fields); } }else{ $fields = $this->fields; } foreach ($data as $key=>$val){ if(!in_array($key,$fields,true)){ unset($data[$key]); }elseif(array_key_exists($key,$this->mapFields)){ // 需要处理映射字段 $data[$this->mapFields[$key]] = $val; unset($data[$key]); } } } // 安全过滤 if(!empty($this->options['filter'])) { $data = array_map($this->options['filter'],$data); unset($this->options['filter']); } $this->_before_write($data); return $data; }
php
protected function _facade($data) { // 检查数据字段合法性 if(!empty($this->fields)) { if(!empty($this->options['field'])) { $fields = $this->options['field']; unset($this->options['field']); if(is_string($fields)) { $fields = explode(',',$fields); } }else{ $fields = $this->fields; } foreach ($data as $key=>$val){ if(!in_array($key,$fields,true)){ unset($data[$key]); }elseif(array_key_exists($key,$this->mapFields)){ // 需要处理映射字段 $data[$this->mapFields[$key]] = $val; unset($data[$key]); } } } // 安全过滤 if(!empty($this->options['filter'])) { $data = array_map($this->options['filter'],$data); unset($this->options['filter']); } $this->_before_write($data); return $data; }
对保存到数据库的数据进行处理 @access protected @param mixed $data 要操作的数据 @return boolean
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/MergeModel.php#L137-L168
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Model/MergeModel.php
MergeModel.save
public function save($data='',$options=array()){ // 根据主表的主键更新 if(empty($data)) { // 没有传递数据,获取当前数据对象的值 if(!empty($this->data)) { $data = $this->data; // 重置数据 $this->data = array(); }else{ $this->error = L('_DATA_TYPE_INVALID_'); return false; } } if(empty($data)){ // 没有数据则不执行 $this->error = L('_DATA_TYPE_INVALID_'); return false; } // 如果存在主键数据 则自动作为更新条件 $pk = $this->pk; if(isset($data[$pk])) { $where[$pk] = $data[$pk]; $options['where'] = $where; unset($data[$pk]); } $options['join'] = ''; $options = $this->_parseOptions($options); // 更新操作不使用JOIN $options['table'] = $this->getTableName(); if(is_array($options['where']) && isset($options['where'][$pk])){ $pkValue = $options['where'][$pk]; } if(false === $this->_before_update($data,$options)) { return false; } $result = $this->db->update($data,$options); if(false !== $result) { if(isset($pkValue)) $data[$pk] = $pkValue; $this->_after_update($data,$options); } return $result; }
php
public function save($data='',$options=array()){ // 根据主表的主键更新 if(empty($data)) { // 没有传递数据,获取当前数据对象的值 if(!empty($this->data)) { $data = $this->data; // 重置数据 $this->data = array(); }else{ $this->error = L('_DATA_TYPE_INVALID_'); return false; } } if(empty($data)){ // 没有数据则不执行 $this->error = L('_DATA_TYPE_INVALID_'); return false; } // 如果存在主键数据 则自动作为更新条件 $pk = $this->pk; if(isset($data[$pk])) { $where[$pk] = $data[$pk]; $options['where'] = $where; unset($data[$pk]); } $options['join'] = ''; $options = $this->_parseOptions($options); // 更新操作不使用JOIN $options['table'] = $this->getTableName(); if(is_array($options['where']) && isset($options['where'][$pk])){ $pkValue = $options['where'][$pk]; } if(false === $this->_before_update($data,$options)) { return false; } $result = $this->db->update($data,$options); if(false !== $result) { if(isset($pkValue)) $data[$pk] = $pkValue; $this->_after_update($data,$options); } return $result; }
保存聚合模型数据 @access public @param mixed $data 数据 @param array $options 表达式 @return boolean
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/MergeModel.php#L177-L219
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Model/MergeModel.php
MergeModel.checkOrder
protected function checkOrder($order='') { if(is_string($order) && !empty($order)) { $orders = explode(',',$order); $_order = array(); foreach ($orders as $order){ $array = explode(' ',trim($order)); $field = $array[0]; $sort = isset($array[1])?$array[1]:'ASC'; if(array_key_exists($field,$this->mapFields)){ // 需要处理映射字段 $field = $this->mapFields[$field]; } $_order[] = $field.' '.$sort; } $order = implode(',',$_order); } return $order; }
php
protected function checkOrder($order='') { if(is_string($order) && !empty($order)) { $orders = explode(',',$order); $_order = array(); foreach ($orders as $order){ $array = explode(' ',trim($order)); $field = $array[0]; $sort = isset($array[1])?$array[1]:'ASC'; if(array_key_exists($field,$this->mapFields)){ // 需要处理映射字段 $field = $this->mapFields[$field]; } $_order[] = $field.' '.$sort; } $order = implode(',',$_order); } return $order; }
检查Order表达式中的聚合字段 @access protected @param string $order 字段 @return string
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/MergeModel.php#L324-L341
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Model/MergeModel.php
MergeModel.checkGroup
protected function checkGroup($group='') { if(!empty($group)) { $groups = explode(',',$group); $_group = array(); foreach ($groups as $field){ // 解析成聚合字段 if(array_key_exists($field,$this->mapFields)){ // 需要处理映射字段 $field = $this->mapFields[$field]; } $_group[] = $field; } $group = implode(',',$_group); } return $group; }
php
protected function checkGroup($group='') { if(!empty($group)) { $groups = explode(',',$group); $_group = array(); foreach ($groups as $field){ // 解析成聚合字段 if(array_key_exists($field,$this->mapFields)){ // 需要处理映射字段 $field = $this->mapFields[$field]; } $_group[] = $field; } $group = implode(',',$_group); } return $group; }
检查Group表达式中的聚合字段 @access protected @param string $group 字段 @return string
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/MergeModel.php#L349-L364
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Model/MergeModel.php
MergeModel.checkFields
protected function checkFields($fields='') { if(empty($fields) || '*'==$fields ) { // 获取全部聚合字段 $fields = $this->fields; } if(!is_array($fields)) $fields = explode(',',$fields); // 解析成聚合字段 $array = array(); foreach ($fields as $field){ if(array_key_exists($field,$this->mapFields)){ // 需要处理映射字段 $array[] = $this->mapFields[$field].' AS '.$field; }else{ $array[] = $field; } } $fields = implode(',',$array); return $fields; }
php
protected function checkFields($fields='') { if(empty($fields) || '*'==$fields ) { // 获取全部聚合字段 $fields = $this->fields; } if(!is_array($fields)) $fields = explode(',',$fields); // 解析成聚合字段 $array = array(); foreach ($fields as $field){ if(array_key_exists($field,$this->mapFields)){ // 需要处理映射字段 $array[] = $this->mapFields[$field].' AS '.$field; }else{ $array[] = $field; } } $fields = implode(',',$array); return $fields; }
检查fields表达式中的聚合字段 @access protected @param string $fields 字段 @return string
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Model/MergeModel.php#L372-L392
StanBarrows/roles
src/Providers/RolesServiceProvider.php
RolesServiceProvider.boot
public function boot() { $this->app['router']->aliasMiddleware('role', RoleMiddleware::class); $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); Blade::directive('role', function ($role) { return "<?php if (auth()->check() && auth()->user()->hasRole({$role})): ?>"; }); Blade::directive('endrole', function ($role) { return "<?php endif; ?>"; }); $this->app->make('Illuminate\Database\Eloquent\Factory')->load(__DIR__ . '/../../database/factories'); }
php
public function boot() { $this->app['router']->aliasMiddleware('role', RoleMiddleware::class); $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); Blade::directive('role', function ($role) { return "<?php if (auth()->check() && auth()->user()->hasRole({$role})): ?>"; }); Blade::directive('endrole', function ($role) { return "<?php endif; ?>"; }); $this->app->make('Illuminate\Database\Eloquent\Factory')->load(__DIR__ . '/../../database/factories'); }
Bootstrap the application services. @return void
https://github.com/StanBarrows/roles/blob/112d823b4a2ce4731a88164deff264bff765214a/src/Providers/RolesServiceProvider.php#L16-L35
railken/lem
src/Attributes/ClassNameAttribute.php
ClassNameAttribute.valid
public function valid(EntityContract $entity, $value) { foreach ($this->getOptions() as $option) { if (class_exists($value) && is_subclass_of($value, $option)) { return true; } } return false; }
php
public function valid(EntityContract $entity, $value) { foreach ($this->getOptions() as $option) { if (class_exists($value) && is_subclass_of($value, $option)) { return true; } } return false; }
Is a value valid ? @param \Railken\Lem\Contracts\EntityContract $entity @param mixed $value @return bool
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/ClassNameAttribute.php#L36-L45
sokil/NotificationBundle
src/TransportProvider.php
TransportProvider.getTransport
public function getTransport($transportName) { if (empty($this->transport[$transportName])) { throw new InvalidArgumentException(sprintf('Transport %s not found', $transportName)); } return $this->transport[$transportName]; }
php
public function getTransport($transportName) { if (empty($this->transport[$transportName])) { throw new InvalidArgumentException(sprintf('Transport %s not found', $transportName)); } return $this->transport[$transportName]; }
Get transport by name @param $transportName @return TransportInterface @throws InvalidArgumentException
https://github.com/sokil/NotificationBundle/blob/bf8d793b6b5a13827b2db4f0b3c588cf6a03c66b/src/TransportProvider.php#L35-L42
fond-of/spryker-companies-rest-api
src/FondOfSpryker/Client/CompaniesRestApi/Zed/CompaniesRestApiStub.php
CompaniesRestApiStub.findCompanyByExternalReference
public function findCompanyByExternalReference( RestCompaniesRequestAttributesTransfer $restCompaniesRequestAttributesTransfer ): RestCompaniesResponseTransfer { /** @var \Generated\Shared\Transfer\RestCompaniesResponseTransfer $restCompaniesResponseTransfer */ $restCompaniesResponseTransfer = $this->zedRequestClient->call( '/companies-rest-api/gateway/find-company-by-external-reference', $restCompaniesRequestAttributesTransfer ); return $restCompaniesResponseTransfer; }
php
public function findCompanyByExternalReference( RestCompaniesRequestAttributesTransfer $restCompaniesRequestAttributesTransfer ): RestCompaniesResponseTransfer { /** @var \Generated\Shared\Transfer\RestCompaniesResponseTransfer $restCompaniesResponseTransfer */ $restCompaniesResponseTransfer = $this->zedRequestClient->call( '/companies-rest-api/gateway/find-company-by-external-reference', $restCompaniesRequestAttributesTransfer ); return $restCompaniesResponseTransfer; }
@param \Generated\Shared\Transfer\RestCompaniesRequestAttributesTransfer $restCompaniesRequestAttributesTransfer @return \Generated\Shared\Transfer\RestCompaniesResponseTransfer
https://github.com/fond-of/spryker-companies-rest-api/blob/0df688aa37cd6d18f90ac2af0a1cbc39357d94d7/src/FondOfSpryker/Client/CompaniesRestApi/Zed/CompaniesRestApiStub.php#L30-L40
fond-of/spryker-companies-rest-api
src/FondOfSpryker/Client/CompaniesRestApi/Zed/CompaniesRestApiStub.php
CompaniesRestApiStub.create
public function create(RestCompaniesRequestAttributesTransfer $restCompaniesRequestAttributesTransfer ): RestCompaniesResponseTransfer { /** @var \Generated\Shared\Transfer\RestCompaniesResponseTransfer $restCompaniesResponseTransfer */ $restCompaniesResponseTransfer = $this->zedRequestClient->call( '/companies-rest-api/gateway/create', $restCompaniesRequestAttributesTransfer ); return $restCompaniesResponseTransfer; }
php
public function create(RestCompaniesRequestAttributesTransfer $restCompaniesRequestAttributesTransfer ): RestCompaniesResponseTransfer { /** @var \Generated\Shared\Transfer\RestCompaniesResponseTransfer $restCompaniesResponseTransfer */ $restCompaniesResponseTransfer = $this->zedRequestClient->call( '/companies-rest-api/gateway/create', $restCompaniesRequestAttributesTransfer ); return $restCompaniesResponseTransfer; }
@param \Generated\Shared\Transfer\RestCompaniesRequestAttributesTransfer $restCompaniesRequestAttributesTransfer @return \Generated\Shared\Transfer\RestCompaniesResponseTransfer
https://github.com/fond-of/spryker-companies-rest-api/blob/0df688aa37cd6d18f90ac2af0a1cbc39357d94d7/src/FondOfSpryker/Client/CompaniesRestApi/Zed/CompaniesRestApiStub.php#L47-L57
fond-of/spryker-companies-rest-api
src/FondOfSpryker/Client/CompaniesRestApi/Zed/CompaniesRestApiStub.php
CompaniesRestApiStub.update
public function update(RestCompaniesRequestTransfer $restCompaniesRequestTransfer): RestCompaniesResponseTransfer { /** @var \Generated\Shared\Transfer\RestCompaniesResponseTransfer $restCompaniesResponseTransfer */ $restCompaniesResponseTransfer = $this->zedRequestClient->call( '/companies-rest-api/gateway/update', $restCompaniesRequestTransfer ); return $restCompaniesResponseTransfer; }
php
public function update(RestCompaniesRequestTransfer $restCompaniesRequestTransfer): RestCompaniesResponseTransfer { /** @var \Generated\Shared\Transfer\RestCompaniesResponseTransfer $restCompaniesResponseTransfer */ $restCompaniesResponseTransfer = $this->zedRequestClient->call( '/companies-rest-api/gateway/update', $restCompaniesRequestTransfer ); return $restCompaniesResponseTransfer; }
@param \Generated\Shared\Transfer\RestCompaniesRequestTransfer $restCompaniesRequestTransfer @return \Generated\Shared\Transfer\RestCompaniesResponseTransfer
https://github.com/fond-of/spryker-companies-rest-api/blob/0df688aa37cd6d18f90ac2af0a1cbc39357d94d7/src/FondOfSpryker/Client/CompaniesRestApi/Zed/CompaniesRestApiStub.php#L64-L73
MARCspec/php-marc-spec
src/Subfield.php
Subfield.jsonSerialize
public function jsonSerialize() { $_subfieldSpec['tag'] = $this->getTag(); $_subfieldSpec['indexStart'] = $this->getIndexStart(); $_subfieldSpec['indexEnd'] = $this->getIndexEnd(); if (($indexLength = $this->getIndexLength()) !== null) { $_subfieldSpec['indexLength'] = $indexLength; } if (($charStart = $this->getCharStart()) !== null) { $_subfieldSpec['charStart'] = $charStart; $_subfieldSpec['charEnd'] = $this->getCharEnd(); } if (($charLength = $this->getCharLength()) !== null) { $_subfieldSpec['charLength'] = $charLength; } if (($subSpecs = $this->getSubSpecs()) !== null) { $_subfieldSpec['subSpecs'] = []; foreach ($subSpecs as $key => $subSpec) { if (is_array($subSpec)) { foreach ($subSpec as $altSubSpec) { $_subfieldSpec['subSpecs'][$key][] = $altSubSpec->jsonSerialize(); } } else { $_subfieldSpec['subSpecs'][$key] = $subSpec->jsonSerialize(); } } } return $_subfieldSpec; }
php
public function jsonSerialize() { $_subfieldSpec['tag'] = $this->getTag(); $_subfieldSpec['indexStart'] = $this->getIndexStart(); $_subfieldSpec['indexEnd'] = $this->getIndexEnd(); if (($indexLength = $this->getIndexLength()) !== null) { $_subfieldSpec['indexLength'] = $indexLength; } if (($charStart = $this->getCharStart()) !== null) { $_subfieldSpec['charStart'] = $charStart; $_subfieldSpec['charEnd'] = $this->getCharEnd(); } if (($charLength = $this->getCharLength()) !== null) { $_subfieldSpec['charLength'] = $charLength; } if (($subSpecs = $this->getSubSpecs()) !== null) { $_subfieldSpec['subSpecs'] = []; foreach ($subSpecs as $key => $subSpec) { if (is_array($subSpec)) { foreach ($subSpec as $altSubSpec) { $_subfieldSpec['subSpecs'][$key][] = $altSubSpec->jsonSerialize(); } } else { $_subfieldSpec['subSpecs'][$key] = $subSpec->jsonSerialize(); } } } return $_subfieldSpec; }
{@inheritdoc}
https://github.com/MARCspec/php-marc-spec/blob/853d77ad3d510ce05c33535bfa3f1068dccdeef6/src/Subfield.php#L172-L207
MARCspec/php-marc-spec
src/Subfield.php
Subfield.getBaseSpec
public function getBaseSpec() { $subfieldSpec = '$'.$this->getTag(); $indexStart = $this->getIndexStart(); $indexEnd = $this->getIndexEnd(); if ($indexStart === 0 && $indexEnd === '#') { // use abbreviation } else { $subfieldSpec .= '['.$indexStart; if ($indexStart !== $indexEnd) { $subfieldSpec .= '-'.$indexEnd; } $subfieldSpec .= ']'; } if (($charStart = $this->getCharStart()) !== null) { $charEnd = $this->getCharEnd(); if ($charStart === 0 && $charEnd === '#') { // use abbreviation } else { $subfieldSpec .= '/'.$charStart; if ($charEnd !== $charStart) { $subfieldSpec .= '-'.$charEnd; } } } return $subfieldSpec; }
php
public function getBaseSpec() { $subfieldSpec = '$'.$this->getTag(); $indexStart = $this->getIndexStart(); $indexEnd = $this->getIndexEnd(); if ($indexStart === 0 && $indexEnd === '#') { // use abbreviation } else { $subfieldSpec .= '['.$indexStart; if ($indexStart !== $indexEnd) { $subfieldSpec .= '-'.$indexEnd; } $subfieldSpec .= ']'; } if (($charStart = $this->getCharStart()) !== null) { $charEnd = $this->getCharEnd(); if ($charStart === 0 && $charEnd === '#') { // use abbreviation } else { $subfieldSpec .= '/'.$charStart; if ($charEnd !== $charStart) { $subfieldSpec .= '-'.$charEnd; } } } return $subfieldSpec; }
{@inheritdoc}
https://github.com/MARCspec/php-marc-spec/blob/853d77ad3d510ce05c33535bfa3f1068dccdeef6/src/Subfield.php#L212-L241
MARCspec/php-marc-spec
src/Subfield.php
Subfield.offsetExists
public function offsetExists($offset) { switch ($offset) { case 'code': case 'tag': return isset($this->tag); break; case 'indexStart': return isset($this->indexStart); break; case 'indexEnd': return isset($this->indexEnd); break; case 'indexLength': return !is_null($this->getIndexLength()); break; case 'charStart': return isset($this->charStart); break; case 'charEnd': return isset($this->charEnd); break; case 'charLength': return !is_null($this->getCharLength()); break; case 'subSpecs': return (0 < count($this->subSpecs)) ? true : false; break; default: return false; } }
php
public function offsetExists($offset) { switch ($offset) { case 'code': case 'tag': return isset($this->tag); break; case 'indexStart': return isset($this->indexStart); break; case 'indexEnd': return isset($this->indexEnd); break; case 'indexLength': return !is_null($this->getIndexLength()); break; case 'charStart': return isset($this->charStart); break; case 'charEnd': return isset($this->charEnd); break; case 'charLength': return !is_null($this->getCharLength()); break; case 'subSpecs': return (0 < count($this->subSpecs)) ? true : false; break; default: return false; } }
Access object like an associative array. @api @param string $offset Key indexStart|indexEnd|charStart|charEnd|charLength|subSpecs
https://github.com/MARCspec/php-marc-spec/blob/853d77ad3d510ce05c33535bfa3f1068dccdeef6/src/Subfield.php#L273-L304
MARCspec/php-marc-spec
src/Subfield.php
Subfield.offsetGet
public function offsetGet($offset) { switch ($offset) { case 'tag': case 'code': return $this->getTag(); break; case 'indexStart': return $this->getIndexStart(); break; case 'indexEnd': return $this->getIndexEnd(); break; case 'indexLength': return $this->getIndexLength(); break; case 'charStart': return $this->getCharStart(); break; case 'charEnd': return $this->getCharEnd(); break; case 'charLength': return $this->getCharLength(); break; case 'subSpecs': return $this->getSubSpecs(); break; default: return; } }
php
public function offsetGet($offset) { switch ($offset) { case 'tag': case 'code': return $this->getTag(); break; case 'indexStart': return $this->getIndexStart(); break; case 'indexEnd': return $this->getIndexEnd(); break; case 'indexLength': return $this->getIndexLength(); break; case 'charStart': return $this->getCharStart(); break; case 'charEnd': return $this->getCharEnd(); break; case 'charLength': return $this->getCharLength(); break; case 'subSpecs': return $this->getSubSpecs(); break; default: return; } }
Access object like an associative array. @api @param string $offset Key indexStart|indexEnd|charStart|charEnd|charLength|subSpecs
https://github.com/MARCspec/php-marc-spec/blob/853d77ad3d510ce05c33535bfa3f1068dccdeef6/src/Subfield.php#L313-L343
tonis-io-legacy/tonis
src/Router/RouteMap.php
RouteMap.add
public function add($path, $handler) { $route = new Route($path, $handler); $this->routes[] = $route; $this->nameCache = []; $this->routeParser = new RouteParser; return $route; }
php
public function add($path, $handler) { $route = new Route($path, $handler); $this->routes[] = $route; $this->nameCache = []; $this->routeParser = new RouteParser; return $route; }
Adds a route to the map and resets the name cache. @param string $path @param callable $handler @return Route
https://github.com/tonis-io-legacy/tonis/blob/8371a277a94232433d882aaf37a85cd469daf501/src/Router/RouteMap.php#L25-L33
tonis-io-legacy/tonis
src/Router/RouteMap.php
RouteMap.get
public function get($name) { if (!$this->hasRoute($name)) { throw new Exception\MissingRoute($name); } return $this->nameCache[$name]; }
php
public function get($name) { if (!$this->hasRoute($name)) { throw new Exception\MissingRoute($name); } return $this->nameCache[$name]; }
Gets a route by name. @param string $name @return Route
https://github.com/tonis-io-legacy/tonis/blob/8371a277a94232433d882aaf37a85cd469daf501/src/Router/RouteMap.php#L79-L86
tonis-io-legacy/tonis
src/Router/RouteMap.php
RouteMap.buildNameCache
private function buildNameCache() { if (!empty($this->nameCache)) { return; } foreach ($this as $route) { if (!$route->name()) { continue; } $this->nameCache[$route->name()] = $route; } }
php
private function buildNameCache() { if (!empty($this->nameCache)) { return; } foreach ($this as $route) { if (!$route->name()) { continue; } $this->nameCache[$route->name()] = $route; } }
Iterates through routes and builds a name cache.
https://github.com/tonis-io-legacy/tonis/blob/8371a277a94232433d882aaf37a85cd469daf501/src/Router/RouteMap.php#L110-L121
PenoaksDev/Milky-Framework
src/Milky/Http/JsonResponse.php
JsonResponse.setData
public function setData($data = []) { if ($data instanceof Arrayable) { $this->data = json_encode($data->toArray(), $this->encodingOptions); } elseif ($data instanceof Jsonable) { $this->data = $data->toJson($this->encodingOptions); } elseif ($data instanceof JsonSerializable) { $this->data = json_encode($data->jsonSerialize(), $this->encodingOptions); } else { $this->data = json_encode($data, $this->encodingOptions); } if (JSON_ERROR_NONE !== json_last_error()) { throw new InvalidArgumentException(json_last_error_msg()); } return $this->update(); }
php
public function setData($data = []) { if ($data instanceof Arrayable) { $this->data = json_encode($data->toArray(), $this->encodingOptions); } elseif ($data instanceof Jsonable) { $this->data = $data->toJson($this->encodingOptions); } elseif ($data instanceof JsonSerializable) { $this->data = json_encode($data->jsonSerialize(), $this->encodingOptions); } else { $this->data = json_encode($data, $this->encodingOptions); } if (JSON_ERROR_NONE !== json_last_error()) { throw new InvalidArgumentException(json_last_error_msg()); } return $this->update(); }
{@inheritdoc}
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Http/JsonResponse.php#L43-L60
PenoaksDev/Milky-Framework
src/Milky/Http/JsonResponse.php
JsonResponse.setJsonOptions
public function setJsonOptions($options) { $this->encodingOptions = (int) $options; return $this->setData($this->getData()); }
php
public function setJsonOptions($options) { $this->encodingOptions = (int) $options; return $this->setData($this->getData()); }
Set the JSON encoding options. @param int $options @return mixed
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Http/JsonResponse.php#L86-L91
RhubarbPHP/Scaffold.BackgroundTasks
src/Task.php
Task.initiate
public static function initiate($settings) { // Create an entry in our database. $taskStatus = new BackgroundTaskStatus(); $taskStatus->TaskClass = get_called_class(); $taskStatus->TaskSettings = $settings; $taskStatus->save(); $task = new static(); $additionalArguments = $task->getShellArguments(); $additionalArgumentString = ""; foreach ($additionalArguments as $argument) { $additionalArgumentString .= escapeshellarg($argument); } if (BackgroundTasksModule::$debugServerName) { // This setting can be used to make command line tasks use a named configuration // in your IDE - this matches up to the PHP Server name in PhpStorm, found in // Settings -> Languages and Frameworks -> PHP -> Servers -> Name $command = 'PHP_IDE_CONFIG=' . escapeshellarg('serverName=' . BackgroundTasksModule::$debugServerName) . ' '; } else { $command = ''; } $runningRhubarbAppClass = escapeshellarg(get_class(Application::current())); $command .= "rhubarb_app=$runningRhubarbAppClass /usr/bin/env php " . realpath(VENDOR_DIR . "/rhubarbphp/rhubarb/platform/execute-cli.php") . " " . realpath(__DIR__ . "/Scripts/task-runner.php") . " " . escapeshellarg(get_called_class()) . " " . $taskStatus->BackgroundTaskStatusID . " " . $additionalArgumentString . " > /dev/null 2>&1 &"; Log::debug("Launching background task " . $taskStatus->UniqueIdentifier, "BACKGROUND", $command); exec($command); return $taskStatus; }
php
public static function initiate($settings) { // Create an entry in our database. $taskStatus = new BackgroundTaskStatus(); $taskStatus->TaskClass = get_called_class(); $taskStatus->TaskSettings = $settings; $taskStatus->save(); $task = new static(); $additionalArguments = $task->getShellArguments(); $additionalArgumentString = ""; foreach ($additionalArguments as $argument) { $additionalArgumentString .= escapeshellarg($argument); } if (BackgroundTasksModule::$debugServerName) { // This setting can be used to make command line tasks use a named configuration // in your IDE - this matches up to the PHP Server name in PhpStorm, found in // Settings -> Languages and Frameworks -> PHP -> Servers -> Name $command = 'PHP_IDE_CONFIG=' . escapeshellarg('serverName=' . BackgroundTasksModule::$debugServerName) . ' '; } else { $command = ''; } $runningRhubarbAppClass = escapeshellarg(get_class(Application::current())); $command .= "rhubarb_app=$runningRhubarbAppClass /usr/bin/env php " . realpath(VENDOR_DIR . "/rhubarbphp/rhubarb/platform/execute-cli.php") . " " . realpath(__DIR__ . "/Scripts/task-runner.php") . " " . escapeshellarg(get_called_class()) . " " . $taskStatus->BackgroundTaskStatusID . " " . $additionalArgumentString . " > /dev/null 2>&1 &"; Log::debug("Launching background task " . $taskStatus->UniqueIdentifier, "BACKGROUND", $command); exec($command); return $taskStatus; }
Initiates execution of the background task. @param array $settings Settings which will be passed to the execute method of the BackgroundTask (must be JSON serialisable) @return BackgroundTaskStatus The status object for this task.
https://github.com/RhubarbPHP/Scaffold.BackgroundTasks/blob/92a5feab27599288e8bf39deb522588115838904/src/Task.php#L71-L107
n2n/n2n-composer-skeleton-component-installer
src/n2n/composer/skeleton/component/ComponentInstaller.php
ComponentInstaller.update
public function update(\Composer\Repository\InstalledRepositoryInterface $repo, \Composer\Package\PackageInterface $initial, \Composer\Package\PackageInterface $target) { $this->moveBackResources($initial); parent::update($repo, $initial, $target); $this->removeResources($target); $this->installResources($target); }
php
public function update(\Composer\Repository\InstalledRepositoryInterface $repo, \Composer\Package\PackageInterface $initial, \Composer\Package\PackageInterface $target) { $this->moveBackResources($initial); parent::update($repo, $initial, $target); $this->removeResources($target); $this->installResources($target); }
{@inheritDoc} @see \Composer\Installer\InstallerInterface::update()
https://github.com/n2n/n2n-composer-skeleton-component-installer/blob/14166313bf28682d5cef8570cd0016b101ae608d/src/n2n/composer/skeleton/component/ComponentInstaller.php#L30-L39
n2n/n2n-composer-skeleton-component-installer
src/n2n/composer/skeleton/component/ComponentInstaller.php
ComponentInstaller.uninstall
public function uninstall(\Composer\Repository\InstalledRepositoryInterface $repo, \Composer\Package\PackageInterface $package) { $this->moveBackResources($package); parent::uninstall($repo, $package); }
php
public function uninstall(\Composer\Repository\InstalledRepositoryInterface $repo, \Composer\Package\PackageInterface $package) { $this->moveBackResources($package); parent::uninstall($repo, $package); }
{@inheritDoc} @see \Composer\Installer\InstallerInterface::uninstall()
https://github.com/n2n/n2n-composer-skeleton-component-installer/blob/14166313bf28682d5cef8570cd0016b101ae608d/src/n2n/composer/skeleton/component/ComponentInstaller.php#L45-L49
WyriHaximus/RatchetCommands
Lib/MessageQueue/Transports/TransportProxy.php
TransportProxy.instance
public static function instance() { if (empty(self::$_generalMessageQueueProxy)) { self::$_generalMessageQueueProxy = new TransportProxy(Configure::read('RatchetCommands.Queue.configuration')); } return self::$_generalMessageQueueProxy; }
php
public static function instance() { if (empty(self::$_generalMessageQueueProxy)) { self::$_generalMessageQueueProxy = new TransportProxy(Configure::read('RatchetCommands.Queue.configuration')); } return self::$_generalMessageQueueProxy; }
Singleton constructor @return TransportProxy
https://github.com/WyriHaximus/RatchetCommands/blob/ee03993862cadc109221c2a07794ea614986cbec/Lib/MessageQueue/Transports/TransportProxy.php#L44-L50
heiglandreas/OrgHeiglFileFinder
src/ClassMapList.php
ClassMapList.add
public function add(\SplFileInfo $file) { $content = new \Org_Heigl\FileFinder\Service\Tokenlist(file_get_contents($file->getPathname())); $classname = $content->getClassName(); if (! $classname) { return; } $class = $content->getNamespace(); $class[] = $classname; $key = str_replace('\\\\', '\\', '\\' . implode('\\', $class)); $this->list[$key] = realpath($file->getPathname()); }
php
public function add(\SplFileInfo $file) { $content = new \Org_Heigl\FileFinder\Service\Tokenlist(file_get_contents($file->getPathname())); $classname = $content->getClassName(); if (! $classname) { return; } $class = $content->getNamespace(); $class[] = $classname; $key = str_replace('\\\\', '\\', '\\' . implode('\\', $class)); $this->list[$key] = realpath($file->getPathname()); }
Add an SPL-File-Info to the filelist @param \SplFileInfo $file @return void
https://github.com/heiglandreas/OrgHeiglFileFinder/blob/189d15b95bec7dc186ef73681463c104831234d8/src/ClassMapList.php#L48-L62
ComPHPPuebla/restful-extensions
src/ComPHPPuebla/Slim/Middleware/CheckOptionsMiddleware.php
CheckOptionsMiddleware.call
public function call() { $params = $this->app->router()->getCurrentRoute()->getParams(); $options = $this->model->getOptionsList(); if (isset($params['id'])) { $options = $this->model->getOptions(); } if (in_array($this->app->request()->getMethod(), $options)) { $this->next->call(); return; } $this->app->response()->setStatus(405); // Method Not Allowed }
php
public function call() { $params = $this->app->router()->getCurrentRoute()->getParams(); $options = $this->model->getOptionsList(); if (isset($params['id'])) { $options = $this->model->getOptions(); } if (in_array($this->app->request()->getMethod(), $options)) { $this->next->call(); return; } $this->app->response()->setStatus(405); // Method Not Allowed }
Check if the current HTTP method is allowed for the resource being accesed @see \Slim\Middleware::call()
https://github.com/ComPHPPuebla/restful-extensions/blob/3dc5e554d7ebe1305eed4cd4ec71a6944316199c/src/ComPHPPuebla/Slim/Middleware/CheckOptionsMiddleware.php#L27-L43
Nicklas766/Comment
src/Comment/Modules/ActiveRecordModelExtender.php
ActiveRecordModelExtender.getMD
public function getMD($content) { $funcArr = ["yamlfrontmatter", "shortcode", "markdown", "titlefromheader"]; $textFilter = new textFilter(); return $textFilter->parse($content, $funcArr)->text; }
php
public function getMD($content) { $funcArr = ["yamlfrontmatter", "shortcode", "markdown", "titlefromheader"]; $textFilter = new textFilter(); return $textFilter->parse($content, $funcArr)->text; }
Return markdown based on string @param string $content unparsed markdown @return string as parsed markdown
https://github.com/Nicklas766/Comment/blob/1483eaf1ebb120b8bd6c2a1552c084b3a288ff25/src/Comment/Modules/ActiveRecordModelExtender.php#L42-L47
spryker/merchant-data-import
src/Spryker/Zed/MerchantDataImport/Business/Model/MerchantWriterStep.php
MerchantWriterStep.execute
public function execute(DataSetInterface $dataSet): void { $this->validateDataSet($dataSet); $merchantEntity = SpyMerchantQuery::create() ->filterByMerchantKey($dataSet[MerchantDataSetInterface::MERCHANT_KEY]) ->findOneOrCreate(); $merchantEntity ->setName($dataSet[MerchantDataSetInterface::NAME]) ->save(); }
php
public function execute(DataSetInterface $dataSet): void { $this->validateDataSet($dataSet); $merchantEntity = SpyMerchantQuery::create() ->filterByMerchantKey($dataSet[MerchantDataSetInterface::MERCHANT_KEY]) ->findOneOrCreate(); $merchantEntity ->setName($dataSet[MerchantDataSetInterface::NAME]) ->save(); }
@param \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface $dataSet @return void
https://github.com/spryker/merchant-data-import/blob/b3010824ca0765f890838d389e7c8e8a3e524b19/src/Spryker/Zed/MerchantDataImport/Business/Model/MerchantWriterStep.php#L23-L34
spryker/merchant-data-import
src/Spryker/Zed/MerchantDataImport/Business/Model/MerchantWriterStep.php
MerchantWriterStep.validateDataSet
protected function validateDataSet(DataSetInterface $dataSet): void { if (!$dataSet[MerchantDataSetInterface::MERCHANT_KEY]) { throw new InvalidDataException('"' . MerchantDataSetInterface::MERCHANT_KEY . '" is required.'); } if (!$dataSet[MerchantDataSetInterface::NAME]) { throw new InvalidDataException('"' . MerchantDataSetInterface::NAME . '" is required.'); } }
php
protected function validateDataSet(DataSetInterface $dataSet): void { if (!$dataSet[MerchantDataSetInterface::MERCHANT_KEY]) { throw new InvalidDataException('"' . MerchantDataSetInterface::MERCHANT_KEY . '" is required.'); } if (!$dataSet[MerchantDataSetInterface::NAME]) { throw new InvalidDataException('"' . MerchantDataSetInterface::NAME . '" is required.'); } }
@param \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface $dataSet @throws \Spryker\Zed\DataImport\Business\Exception\InvalidDataException @return void
https://github.com/spryker/merchant-data-import/blob/b3010824ca0765f890838d389e7c8e8a3e524b19/src/Spryker/Zed/MerchantDataImport/Business/Model/MerchantWriterStep.php#L43-L52
the-eater/odango.php
src/NyaaCollector.php
NyaaCollector.getFeed
protected function getFeed($query, $options) { $options = array_merge(['query' => $query], $options); $nyaa = $this->getNyaa(); $feed = $nyaa->getFeed($options); $matcher = $this->getMatcher(); return array_filter($feed, function ($item) use ($matcher, $query) { $title = $item->getMeta('title'); return $title !== null && $matcher($title, $query); }); }
php
protected function getFeed($query, $options) { $options = array_merge(['query' => $query], $options); $nyaa = $this->getNyaa(); $feed = $nyaa->getFeed($options); $matcher = $this->getMatcher(); return array_filter($feed, function ($item) use ($matcher, $query) { $title = $item->getMeta('title'); return $title !== null && $matcher($title, $query); }); }
Gets the torrent feed for given query and options @param string $query Query to search for in the nyaa feed @param array $options Options for the nyaa feed @return NyaaTorrent[]
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/NyaaCollector.php#L63-L75
the-eater/odango.php
src/NyaaCollector.php
NyaaCollector.filterDuplicates
public function filterDuplicates($torrents) { $arr = []; foreach ($torrents as $torrent) { $arr[$torrent->getTorrentId()] = $torrent; } return array_values($arr); }
php
public function filterDuplicates($torrents) { $arr = []; foreach ($torrents as $torrent) { $arr[$torrent->getTorrentId()] = $torrent; } return array_values($arr); }
Return list with unique torrents from given array @param NyaaTorrent[] The list to filter duplicates out @param NyaaTorrent[]
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/NyaaCollector.php#L83-L92
the-eater/odango.php
src/NyaaCollector.php
NyaaCollector.mapByHash
public function mapByHash($feed) { $torrents = []; foreach ($feed as $torrent) { $hash = $torrent->getSeriesHash(); if(!isset($torrents[$hash])) { $torrents[$hash] = new NyaaSet($hash); } $torrents[$hash]->add($torrent); } return $torrents; }
php
public function mapByHash($feed) { $torrents = []; foreach ($feed as $torrent) { $hash = $torrent->getSeriesHash(); if(!isset($torrents[$hash])) { $torrents[$hash] = new NyaaSet($hash); } $torrents[$hash]->add($torrent); } return $torrents; }
Maps the torrents by series hash and collects them in a NyaaSet @param NyaaTorrent[] list of torrents to be mapped @param NyaaSet[]
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/NyaaCollector.php#L100-L115
the-eater/odango.php
src/NyaaCollector.php
NyaaCollector.collectForUser
public function collectForUser($query, $users, $options = []) { $bigFeed = []; foreach ($users as $userId) { $userOptions = array_merge($options, ['user' => $userId]); $userFeed = $this->getFeed($query, $userOptions); $bigFeed = array_merge($bigFeed, $userFeed); } $bigFeed = $this->filterDuplicates($bigFeed); return $this->mapByHash($bigFeed); }
php
public function collectForUser($query, $users, $options = []) { $bigFeed = []; foreach ($users as $userId) { $userOptions = array_merge($options, ['user' => $userId]); $userFeed = $this->getFeed($query, $userOptions); $bigFeed = array_merge($bigFeed, $userFeed); } $bigFeed = $this->filterDuplicates($bigFeed); return $this->mapByHash($bigFeed); }
Searches for torrents per user @param string $query The query to search for @param int[] $users The users to search in @param array $options extra options for the nyaa feed @return NyaaSet[]
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/NyaaCollector.php#L125-L138
the-eater/odango.php
src/NyaaCollector.php
NyaaCollector.collectRecursive
public function collectRecursive($query, $options = []) { $feed = $this->getFeed($query, $options); $userIds = []; foreach ($feed as $torrent) { if (!isset($userIds[$torrent->getSeriesHash()])) { $userIds[$torrent->getSeriesHash()] = $torrent->getUserId(); } } $userIds = array_unique(array_values($userIds)); return $this->collectForUser($query, $userIds, $options); }
php
public function collectRecursive($query, $options = []) { $feed = $this->getFeed($query, $options); $userIds = []; foreach ($feed as $torrent) { if (!isset($userIds[$torrent->getSeriesHash()])) { $userIds[$torrent->getSeriesHash()] = $torrent->getUserId(); } } $userIds = array_unique(array_values($userIds)); return $this->collectForUser($query, $userIds, $options); }
Searches for torrent and searches for each found torrent in their user for more torrents, to create complete sets @param string $query The query to search for @param array $options Extra options for the nyaa feed @return NyaaSet[]
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/NyaaCollector.php#L147-L162
the-eater/odango.php
src/NyaaCollector.php
NyaaCollector.collect
public function collect($query, $options = []) { if (!$this->getNyaa()->canProvideAllData()) { return $this->collectRecursive($query, $options); } return $this->collectSingleFeed($query, $options); }
php
public function collect($query, $options = []) { if (!$this->getNyaa()->canProvideAllData()) { return $this->collectRecursive($query, $options); } return $this->collectSingleFeed($query, $options); }
Searches for torrents by query and returns sets created from it Collects recursively if backend doesn't provide all data @param string $query The query to search for @param array $options Extra options for the nyaa feed
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/NyaaCollector.php#L171-L179
the-eater/odango.php
src/NyaaCollector.php
NyaaCollector.collectSingleFeed
public function collectSingleFeed($query, $options = []) { $feed = $this->getFeed($query, $options); return $this->mapByHash($feed); }
php
public function collectSingleFeed($query, $options = []) { $feed = $this->getFeed($query, $options); return $this->mapByHash($feed); }
Searches for torrents by query and returns sets created from it, only fetches one feed. @param string $query @param array $options
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/NyaaCollector.php#L187-L192
praxigento/mobi_mod_downline
Block/Customer/Account/Reflink.php
Reflink.getDwnlCustomer
private function getDwnlCustomer() { if (is_null($this->cacheDwnlCust)) { $custId = $this->session->getCustomerId(); $this->cacheDwnlCust = $this->daoDwnlCust->getById($custId); } return $this->cacheDwnlCust; }
php
private function getDwnlCustomer() { if (is_null($this->cacheDwnlCust)) { $custId = $this->session->getCustomerId(); $this->cacheDwnlCust = $this->daoDwnlCust->getById($custId); } return $this->cacheDwnlCust; }
Cached data for current downline customer. @return \Praxigento\Downline\Repo\Data\Customer
https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Block/Customer/Account/Reflink.php#L44-L51
LIN3S/CMSKernel
src/LIN3S/CMSKernel/Infrastructure/Lin3sAdminBundle/Twig/TwigActionTranslationFilter.php
TwigActionTranslationFilter.actionTranslation
public function actionTranslation($options) { if (!is_array($options)) { return $this->translator->trans($options, [], 'CmsKernelAdminBridge'); } $resultOptions = []; foreach ($options as $optionKey => $option) { $option = null === json_decode($option, true) ? $option : json_decode($option, true); if (is_array($option)) { foreach ($option as $iterationKey => $iteration) { if (is_array($iteration)) { foreach ($iteration as $iKey => $i) { if (is_array($i)) { foreach ($i as $iiKey => $ii) { $resultOptions[$optionKey][$iterationKey][$iKey][$iiKey] = $this->translator->trans($ii, [], 'CmsKernelAdminBridge'); } } else { $resultOptions[$optionKey][$iterationKey][$iKey] = $this->translator->trans($i, [], 'CmsKernelAdminBridge'); } } } else { $resultOptions[$optionKey][$iterationKey] = $this->translator->trans($iteration, [], 'CmsKernelAdminBridge'); } } } else { $resultOptions[$optionKey] = $this->translator->trans($option, [], 'CmsKernelAdminBridge'); } } return $resultOptions; }
php
public function actionTranslation($options) { if (!is_array($options)) { return $this->translator->trans($options, [], 'CmsKernelAdminBridge'); } $resultOptions = []; foreach ($options as $optionKey => $option) { $option = null === json_decode($option, true) ? $option : json_decode($option, true); if (is_array($option)) { foreach ($option as $iterationKey => $iteration) { if (is_array($iteration)) { foreach ($iteration as $iKey => $i) { if (is_array($i)) { foreach ($i as $iiKey => $ii) { $resultOptions[$optionKey][$iterationKey][$iKey][$iiKey] = $this->translator->trans($ii, [], 'CmsKernelAdminBridge'); } } else { $resultOptions[$optionKey][$iterationKey][$iKey] = $this->translator->trans($i, [], 'CmsKernelAdminBridge'); } } } else { $resultOptions[$optionKey][$iterationKey] = $this->translator->trans($iteration, [], 'CmsKernelAdminBridge'); } } } else { $resultOptions[$optionKey] = $this->translator->trans($option, [], 'CmsKernelAdminBridge'); } } return $resultOptions; }
Callback of action translation Twig filter that returns resultant array. @param string $options The action options @return array|string
https://github.com/LIN3S/CMSKernel/blob/71b5fc1930cd60d6eac1a9816df34af4654f9a7e/src/LIN3S/CMSKernel/Infrastructure/Lin3sAdminBundle/Twig/TwigActionTranslationFilter.php#L57-L89
K-Phoen/rulerz-bridge
Form/SpecificationToBooleanTransformer.php
SpecificationToBooleanTransformer.reverseTransform
public function reverseTransform($boolean) { if (!$boolean) { return null; } $rClass = new \ReflectionClass($this->specificationClass); if ($rClass->getConstructor() && $rClass->getConstructor()->getNumberOfParameters() > 0) { return $rClass->newInstanceArgs($this->constructorArgs); } return $rClass->newInstance(); }
php
public function reverseTransform($boolean) { if (!$boolean) { return null; } $rClass = new \ReflectionClass($this->specificationClass); if ($rClass->getConstructor() && $rClass->getConstructor()->getNumberOfParameters() > 0) { return $rClass->newInstanceArgs($this->constructorArgs); } return $rClass->newInstance(); }
Transforms a value into a specification. @param bool $boolean @return \RulerZ\Spec\Specification|null
https://github.com/K-Phoen/rulerz-bridge/blob/fdad5856b669d59b5e4bda47c4e927a0485bf7a0/Form/SpecificationToBooleanTransformer.php#L48-L61
brainexe/core
src/Application/ControllerResolver.php
ControllerResolver.getController
public function getController(Request $request) { list($serviceId, $method) = $request->attributes->get('_controller'); $service = $this->controllers->get($serviceId); return [$service, $method]; }
php
public function getController(Request $request) { list($serviceId, $method) = $request->attributes->get('_controller'); $service = $this->controllers->get($serviceId); return [$service, $method]; }
{@inheritdoc}
https://github.com/brainexe/core/blob/9ef69c6f045306abd20e271572386970db9b3e54/src/Application/ControllerResolver.php#L31-L38
brainexe/core
src/Application/ControllerResolver.php
ControllerResolver.getArguments
public function getArguments(Request $request, $controller) { $arguments = [ $request ]; foreach ($request->attributes->all() as $attribute => $value) { if ($attribute[0] !== '_') { $arguments[] = $value; } } return $arguments; }
php
public function getArguments(Request $request, $controller) { $arguments = [ $request ]; foreach ($request->attributes->all() as $attribute => $value) { if ($attribute[0] !== '_') { $arguments[] = $value; } } return $arguments; }
{@inheritdoc}
https://github.com/brainexe/core/blob/9ef69c6f045306abd20e271572386970db9b3e54/src/Application/ControllerResolver.php#L43-L56
YiMAproject/yimaAdminor
src/yimaAdminor/Service/NavigationFactory.php
NavigationFactory.injectComponents
protected function injectComponents(array $pages, RouteMatch $routeMatch = null, Router $router = null) { foreach ($pages as &$page) { $isMVC = ( isset($page['action']) || isset($page['controller']) || isset($page['module']) || isset($page['route']) ); if ($isMVC) { // add default admin route name to navigation if (!isset($page['route'])) { $page['route'] = yimaAdminor\Module::ADMIN_ROUTE_NAME.'/default'; } // check mikonim agar dar route e "admin/default" boodim ... default apporach { // we need 'module' inside 'params' parameter key to use inside router, navigation .. $routeName = $page['route']; if (strstr($routeName,'/')) { $routeName = substr($routeName, 0, strpos($routeName,'/')); } if ($routeName == yimaAdminor\Module::ADMIN_ROUTE_NAME && ($page['route'] == yimaAdminor\Module::ADMIN_ROUTE_NAME.'/default' || $page['route'] == yimaAdminor\Module::ADMIN_ROUTE_NAME.'/default/query' ) ) { // we must put 'module' inside 'params' if (!isset($page['params']) || !is_array($page['params'])) { $page['params'] = array(); } $moduleKey = isset($page['module']) ? 'module' : ModuleRouteListener::MODULE_NAMESPACE; if (!isset($page[$moduleKey])) { throw new Exception\InvalidArgumentException('You are using default admin route and we can\'t not find "module" configuration key'); } $module = $page[$moduleKey]; $page['params'] = array_merge($page['params'], array('module' => $module)); } // } if (!isset($page['routeMatch']) && $routeMatch) { $page['routeMatch'] = $routeMatch; } if (!isset($page['router'])) { $page['router'] = $router; } } if (isset($page['pages'])) { $page['pages'] = $this->injectComponents($page['pages'], $routeMatch, $router); } } return $pages; }
php
protected function injectComponents(array $pages, RouteMatch $routeMatch = null, Router $router = null) { foreach ($pages as &$page) { $isMVC = ( isset($page['action']) || isset($page['controller']) || isset($page['module']) || isset($page['route']) ); if ($isMVC) { // add default admin route name to navigation if (!isset($page['route'])) { $page['route'] = yimaAdminor\Module::ADMIN_ROUTE_NAME.'/default'; } // check mikonim agar dar route e "admin/default" boodim ... default apporach { // we need 'module' inside 'params' parameter key to use inside router, navigation .. $routeName = $page['route']; if (strstr($routeName,'/')) { $routeName = substr($routeName, 0, strpos($routeName,'/')); } if ($routeName == yimaAdminor\Module::ADMIN_ROUTE_NAME && ($page['route'] == yimaAdminor\Module::ADMIN_ROUTE_NAME.'/default' || $page['route'] == yimaAdminor\Module::ADMIN_ROUTE_NAME.'/default/query' ) ) { // we must put 'module' inside 'params' if (!isset($page['params']) || !is_array($page['params'])) { $page['params'] = array(); } $moduleKey = isset($page['module']) ? 'module' : ModuleRouteListener::MODULE_NAMESPACE; if (!isset($page[$moduleKey])) { throw new Exception\InvalidArgumentException('You are using default admin route and we can\'t not find "module" configuration key'); } $module = $page[$moduleKey]; $page['params'] = array_merge($page['params'], array('module' => $module)); } // } if (!isset($page['routeMatch']) && $routeMatch) { $page['routeMatch'] = $routeMatch; } if (!isset($page['router'])) { $page['router'] = $router; } } if (isset($page['pages'])) { $page['pages'] = $this->injectComponents($page['pages'], $routeMatch, $router); } } return $pages; }
@param array $pages @param RouteMatch $routeMatch @param Router $router @return mixed
https://github.com/YiMAproject/yimaAdminor/blob/7a6c66e05aedaef8061c8998dfa44ac1ce9cc319/src/yimaAdminor/Service/NavigationFactory.php#L31-L87
schpill/thin
src/Request.php
Request.server
public static function server($key = null, $default = null) { return arrayGet(static::foundation()->server->all(), Inflector::upper($key), $default); }
php
public static function server($key = null, $default = null) { return arrayGet(static::foundation()->server->all(), Inflector::upper($key), $default); }
Get an item from the $_SERVER array. @param string $key @param mixed $default @return string
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Request.php#L83-L86
schpill/thin
src/Request.php
Request.detectEnv
public static function detectEnv(array $environments, $uri) { foreach ($environments as $environment => $patterns) { // Essentially we just want to loop through each environment pattern // and determine if the current URI matches the pattern and if so // we will simply return the environment for that URI pattern. foreach ($patterns as $pattern) { if (Inflector::is($pattern, $uri) or $pattern == gethostname()) { return $environment; } } } }
php
public static function detectEnv(array $environments, $uri) { foreach ($environments as $environment => $patterns) { // Essentially we just want to loop through each environment pattern // and determine if the current URI matches the pattern and if so // we will simply return the environment for that URI pattern. foreach ($patterns as $pattern) { if (Inflector::is($pattern, $uri) or $pattern == gethostname()) { return $environment; } } } }
Detect the current environment from an environment configuration. @param array $environments @param string $uri @return string|null
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Request.php#L231-L243
atelierspierrot/patterns
src/Patterns/Commons/Registry.php
Registry.setEntry
public function setEntry($var = null, $val = null, $section = false) { if (!empty($var)) { if ($section) { if (!isset($this->registry[$section])) { $this->registry[$section] = array(); } $this->registry[$section][$var] = $val; } else { $this->registry[$var] = $val; } } return $this; }
php
public function setEntry($var = null, $val = null, $section = false) { if (!empty($var)) { if ($section) { if (!isset($this->registry[$section])) { $this->registry[$section] = array(); } $this->registry[$section][$var] = $val; } else { $this->registry[$var] = $val; } } return $this; }
Set an entry in the instance registry @param null|string $var The variable name to set @param null|mixed $val The variable value to set @param false|string $section A section name in the registry (default is FALSE) @return self
https://github.com/atelierspierrot/patterns/blob/b7a8313e98bbfb6525e1672d0a726a1ead6f156e/src/Patterns/Commons/Registry.php#L102-L115
atelierspierrot/patterns
src/Patterns/Commons/Registry.php
Registry.getEntry
public function getEntry($var = null, $section = false, $default = null) { if (!empty($var)) { if (!empty($section) && isset($this->registry[$section]) && isset($this->registry[$section][$var])) { return $this->registry[$section][$var]; } elseif (isset($this->registry[$var])) { return $this->registry[$var]; } } return !is_null($default) ? $default : false; }
php
public function getEntry($var = null, $section = false, $default = null) { if (!empty($var)) { if (!empty($section) && isset($this->registry[$section]) && isset($this->registry[$section][$var])) { return $this->registry[$section][$var]; } elseif (isset($this->registry[$var])) { return $this->registry[$var]; } } return !is_null($default) ? $default : false; }
Get an entry from the instance registry @param string $var The variable name to get @param string $section A section name in the registry (default is FALSE) @param mixed $default The default value to return if it is not in registry (default is NULL) @return mixed The value found or $default
https://github.com/atelierspierrot/patterns/blob/b7a8313e98bbfb6525e1672d0a726a1ead6f156e/src/Patterns/Commons/Registry.php#L143-L153
atelierspierrot/patterns
src/Patterns/Commons/Registry.php
Registry.isEntry
public function isEntry($var = null, $section = false) { return ( !empty($var) and ( (!empty($section) && isset($this->registry[$section]) && isset($this->registry[$section][$var])) or isset($this->registry[$var]) ) ); }
php
public function isEntry($var = null, $section = false) { return ( !empty($var) and ( (!empty($section) && isset($this->registry[$section]) && isset($this->registry[$section][$var])) or isset($this->registry[$var]) ) ); }
Check if an entry exists in registry @param string $var The variable name to check @param string $section A section name in the registry (default is FALSE) @return bool
https://github.com/atelierspierrot/patterns/blob/b7a8313e98bbfb6525e1672d0a726a1ead6f156e/src/Patterns/Commons/Registry.php#L162-L170
atelierspierrot/patterns
src/Patterns/Commons/Registry.php
Registry.getKey
public function getKey($val = null, $var = null, $section = false) { if (!empty($val)) { if (!empty($var)) { foreach ($this->registry as $_sct=>$_data) { if ($ok=array_search($val, $_data) && $ok==$var) { return $_sct; } } } elseif (!empty($section) && isset($this->registry[$section])) { return array_search($val, $this->registry[$section]); } else { return array_search($val, $this->registry); } } }
php
public function getKey($val = null, $var = null, $section = false) { if (!empty($val)) { if (!empty($var)) { foreach ($this->registry as $_sct=>$_data) { if ($ok=array_search($val, $_data) && $ok==$var) { return $_sct; } } } elseif (!empty($section) && isset($this->registry[$section])) { return array_search($val, $this->registry[$section]); } else { return array_search($val, $this->registry); } } }
Search a key in registry @param mixed $val The variable value to find @param string $var The variable name to search in (in case of array) @param string $section A section name in the registry (default is FALSE) @return string|null The key found in the registry
https://github.com/atelierspierrot/patterns/blob/b7a8313e98bbfb6525e1672d0a726a1ead6f156e/src/Patterns/Commons/Registry.php#L180-L195
atelierspierrot/patterns
src/Patterns/Commons/Registry.php
Registry.dumpStack
public function dumpStack($index = null, $default = null) { if (array_key_exists($index, $this->registry_stacks)) { return $this->registry_stacks[$index]; } return $default; }
php
public function dumpStack($index = null, $default = null) { if (array_key_exists($index, $this->registry_stacks)) { return $this->registry_stacks[$index]; } return $default; }
Get a full stack from registry stacks @param string $index The stack index @param mixed $default The default value to return if it is not in registry (default is NULL) @return mixed The requested stack entry if so
https://github.com/atelierspierrot/patterns/blob/b7a8313e98bbfb6525e1672d0a726a1ead6f156e/src/Patterns/Commons/Registry.php#L208-L214
atelierspierrot/patterns
src/Patterns/Commons/Registry.php
Registry.saveStack
public function saveStack($index = null, $and_clean = false) { $this->registry_stacks[$index] = $this->registry; if ($and_clean===true) { $this->registry=array(); } return $this; }
php
public function saveStack($index = null, $and_clean = false) { $this->registry_stacks[$index] = $this->registry; if ($and_clean===true) { $this->registry=array(); } return $this; }
Save a stack of entries in registry @param string $index The stack index @param bool $and_clean Clean the actual registry after recorded the stack (default is FALSE) @return self
https://github.com/atelierspierrot/patterns/blob/b7a8313e98bbfb6525e1672d0a726a1ead6f156e/src/Patterns/Commons/Registry.php#L223-L230
atelierspierrot/patterns
src/Patterns/Commons/Registry.php
Registry.getStackEntry
public function getStackEntry($var = null, $section = false, $stack = null, $default = null) { if (!empty($var)) { if (!empty($stack) && $this->isStack($stack)) { $tmp_stack = $this->registry; $this->loadStack($stack); $val = $this->getEntry($var, $section, $default); $this->registry = $tmp_stack; return $val; } return $this->getEntry($var, $section, $default); } }
php
public function getStackEntry($var = null, $section = false, $stack = null, $default = null) { if (!empty($var)) { if (!empty($stack) && $this->isStack($stack)) { $tmp_stack = $this->registry; $this->loadStack($stack); $val = $this->getEntry($var, $section, $default); $this->registry = $tmp_stack; return $val; } return $this->getEntry($var, $section, $default); } }
Get a stack entry of the registry stacks @param string $var The variable name to search @param string $section A section name in the registry (default is FALSE) @param string $stack The stack name to search in @param mixed $default The default value to return if it is not in registry (default is NULL) @return mixed The value found or $default
https://github.com/atelierspierrot/patterns/blob/b7a8313e98bbfb6525e1672d0a726a1ead6f156e/src/Patterns/Commons/Registry.php#L264-L276
atelierspierrot/patterns
src/Patterns/Commons/Registry.php
Registry.getStackKey
public function getStackKey($val = null, $section = false, $stack = null, $default = null) { if (!empty($val)) { if (!empty($stack) && $this->isStack($stack)) { $tmp_stack = $this->registry; $this->loadStack($stack); $var = $this->getKey($val, $section, $default); $this->registry = $tmp_stack; return $var; } return $this->getKey($val, $section, $default); } }
php
public function getStackKey($val = null, $section = false, $stack = null, $default = null) { if (!empty($val)) { if (!empty($stack) && $this->isStack($stack)) { $tmp_stack = $this->registry; $this->loadStack($stack); $var = $this->getKey($val, $section, $default); $this->registry = $tmp_stack; return $var; } return $this->getKey($val, $section, $default); } }
Get the key of a stack entry of the registry stacks @param string $val The variable value to search @param string $section A section name in the registry (default is FALSE) @param string $stack The stack name to search in @param mixed $default The default value to return if it is not in registry (default is NULL) @return mixed The key found or $default
https://github.com/atelierspierrot/patterns/blob/b7a8313e98bbfb6525e1672d0a726a1ead6f156e/src/Patterns/Commons/Registry.php#L287-L299
courtney-miles/schnoop-schema
src/MySQL/Constraint/ForeignKey.php
ForeignKey.getReferenceColumnNames
public function getReferenceColumnNames() { $fkNames = []; foreach ($this->foreignKeyColumns as $foreignKeyColumn) { $fkNames[] = $foreignKeyColumn->getReferenceColumnName(); } return $fkNames; }
php
public function getReferenceColumnNames() { $fkNames = []; foreach ($this->foreignKeyColumns as $foreignKeyColumn) { $fkNames[] = $foreignKeyColumn->getReferenceColumnName(); } return $fkNames; }
{@inheritdoc}
https://github.com/courtney-miles/schnoop-schema/blob/f96e9922257860171ecdcdbb6b78182276e2f60d/src/MySQL/Constraint/ForeignKey.php#L109-L118
courtney-miles/schnoop-schema
src/MySQL/Constraint/ForeignKey.php
ForeignKey.hasReferenceColumnName
public function hasReferenceColumnName($columnName, $tableName = null) { if ($this->getReferenceTableName() !== $tableName) { return false; } foreach ($this->foreignKeyColumns as $foreignKeyColumn) { if ($foreignKeyColumn->getReferenceColumnName() == $columnName) { return true; } } return false; }
php
public function hasReferenceColumnName($columnName, $tableName = null) { if ($this->getReferenceTableName() !== $tableName) { return false; } foreach ($this->foreignKeyColumns as $foreignKeyColumn) { if ($foreignKeyColumn->getReferenceColumnName() == $columnName) { return true; } } return false; }
{@inheritdoc}
https://github.com/courtney-miles/schnoop-schema/blob/f96e9922257860171ecdcdbb6b78182276e2f60d/src/MySQL/Constraint/ForeignKey.php#L123-L136