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
cityware/city-format
src/Stringy.php
Stringy.slugify
public function slugify($replacement = '-') { $stringy = self::create($this->str, $this->encoding); $stringy->str = preg_replace("/[^a-zA-Z\d $replacement]/u", '', $stringy->toAscii()); $stringy->str = $stringy->collapseWhitespace()->str; $stringy->str = str_replace(' ', $replacement, strtolower($stringy->str)); return $stringy; }
php
public function slugify($replacement = '-') { $stringy = self::create($this->str, $this->encoding); $stringy->str = preg_replace("/[^a-zA-Z\d $replacement]/u", '', $stringy->toAscii()); $stringy->str = $stringy->collapseWhitespace()->str; $stringy->str = str_replace(' ', $replacement, strtolower($stringy->str)); return $stringy; }
Converts the string into an URL slug. This includes replacing non-ASCII characters with their closest ASCII equivalents, removing non-alphanumeric and non-ASCII characters, and replacing whitespace with $replacement. The replacement defaults to a single dash, and the string is also converted to lowercase. @param string $replacement The string used to replace whitespace @return Stringy Object whose $str has been converted to an URL slug
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L597-L605
cityware/city-format
src/Stringy.php
Stringy.contains
public function contains($needle, $caseSensitive = true) { if ($caseSensitive) return (mb_strpos($this->str, $needle, 0, $this->encoding) !== false); else return (mb_stripos($this->str, $needle, 0, $this->encoding) !== false); }
php
public function contains($needle, $caseSensitive = true) { if ($caseSensitive) return (mb_strpos($this->str, $needle, 0, $this->encoding) !== false); else return (mb_stripos($this->str, $needle, 0, $this->encoding) !== false); }
Returns true if the string contains $needle, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false. @param string $needle Substring to look for @param bool $caseSensitive Whether or not to enforce case-sensitivity @return bool Whether or not $str contains $needle
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L616-L621
cityware/city-format
src/Stringy.php
Stringy.surround
public function surround($substring) { $stringy = self::create($this->str, $this->encoding); $stringy->str = implode('', array($substring, $stringy->str, $substring)); return $stringy; }
php
public function surround($substring) { $stringy = self::create($this->str, $this->encoding); $stringy->str = implode('', array($substring, $stringy->str, $substring)); return $stringy; }
Surrounds $str with the given substring. @param string $substring The substring to add to both sides @return Stringy Object whose $str had the substring prepended and appended
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L629-L634
cityware/city-format
src/Stringy.php
Stringy.truncate
public function truncate($length, $substring = '') { $stringy = self::create($this->str, $this->encoding); if ($length >= $stringy->length()) return $stringy; // Need to further trim the string so we can append the substring $substringLength = mb_strlen($substring, $stringy->encoding); $length = $length - $substringLength; $truncated = mb_substr($stringy->str, 0, $length, $stringy->encoding); $stringy->str = $truncated . $substring; return $stringy; }
php
public function truncate($length, $substring = '') { $stringy = self::create($this->str, $this->encoding); if ($length >= $stringy->length()) return $stringy; // Need to further trim the string so we can append the substring $substringLength = mb_strlen($substring, $stringy->encoding); $length = $length - $substringLength; $truncated = mb_substr($stringy->str, 0, $length, $stringy->encoding); $stringy->str = $truncated . $substring; return $stringy; }
Truncates the string to a given length. If $substring is provided, and truncating occurs, the string is further truncated so that the substring may be appended without exceeding the desired length. @param int $length Desired length of the truncated string @param string $substring The substring to append if it can fit @return Stringy Object with the resulting $str after truncating
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L665-L678
cityware/city-format
src/Stringy.php
Stringy.reverse
public function reverse() { $strLength = $this->length(); $reversed = ''; // Loop from last index of string to first for ($i = $strLength - 1; $i >= 0; $i--) { $reversed .= mb_substr($this->str, $i, 1, $this->encoding); } return self::create($reversed, $this->encoding); }
php
public function reverse() { $strLength = $this->length(); $reversed = ''; // Loop from last index of string to first for ($i = $strLength - 1; $i >= 0; $i--) { $reversed .= mb_substr($this->str, $i, 1, $this->encoding); } return self::create($reversed, $this->encoding); }
Returns a reversed string. A multibyte version of strrev(). @return Stringy Object with a reversed $str
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L718-L728
cityware/city-format
src/Stringy.php
Stringy.substr
public function substr($start, $length = null) { $stringy = self::create($this->str, $this->encoding); if ($length === null) { $stringy->str = mb_substr($stringy->str, $start, $stringy->length() - $start, $this->encoding); } else { $stringy->str = mb_substr($stringy->str, $start, $length, $stringy->encoding); } return $stringy; }
php
public function substr($start, $length = null) { $stringy = self::create($this->str, $this->encoding); if ($length === null) { $stringy->str = mb_substr($stringy->str, $start, $stringy->length() - $start, $this->encoding); } else { $stringy->str = mb_substr($stringy->str, $start, $length, $stringy->encoding); } return $stringy; }
Returns the substring beginning at $start with the specified $length. It differs from the mb_substr() function in that providing a $length of null will return the rest of the string, rather than an empty string. @param int $start Position of the first character to use @param int $length Maximum number of characters used @return Stringy Object with its $str being the substring
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L868-L878
cityware/city-format
src/Stringy.php
Stringy.first
public function first($n) { $stringy = self::create($this->str, $this->encoding); if ($n < 0) { $stringy->str = ''; } else { return $stringy->substr(0, $n); } return $stringy; }
php
public function first($n) { $stringy = self::create($this->str, $this->encoding); if ($n < 0) { $stringy->str = ''; } else { return $stringy->substr(0, $n); } return $stringy; }
Returns the first $n characters of the string. @param int $n Number of characters to retrieve from the start @return Stringy Object with its $str being the first $n chars
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L896-L906
cityware/city-format
src/Stringy.php
Stringy.ensureLeft
public function ensureLeft($substring) { $stringy = self::create($this->str, $this->encoding); if (!$stringy->startsWith($substring)) $stringy->str = $substring . $stringy->str; return $stringy; }
php
public function ensureLeft($substring) { $stringy = self::create($this->str, $this->encoding); if (!$stringy->startsWith($substring)) $stringy->str = $substring . $stringy->str; return $stringy; }
Ensures that the string begins with $substring. If it doesn't, it's prepended. @param string $substring The substring to add if not present @return Stringy Object with its $str prefixed by the $substring
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L933-L940
cityware/city-format
src/Stringy.php
Stringy.ensureRight
public function ensureRight($substring) { $stringy = self::create($this->str, $this->encoding); if (!$stringy->endsWith($substring)) $stringy->str .= $substring; return $stringy; }
php
public function ensureRight($substring) { $stringy = self::create($this->str, $this->encoding); if (!$stringy->endsWith($substring)) $stringy->str .= $substring; return $stringy; }
Ensures that the string begins with $substring. If it doesn't, it's appended. @param string $substring The substring to add if not present @return Stringy Object with its $str suffixed by the $substring
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L949-L956
cityware/city-format
src/Stringy.php
Stringy.matchesPattern
private function matchesPattern($pattern) { $regexEncoding = mb_regex_encoding(); mb_regex_encoding($this->encoding); $match = mb_ereg_match($pattern, $this->str); mb_regex_encoding($regexEncoding); return $match; }
php
private function matchesPattern($pattern) { $regexEncoding = mb_regex_encoding(); mb_regex_encoding($this->encoding); $match = mb_ereg_match($pattern, $this->str); mb_regex_encoding($regexEncoding); return $match; }
Returns true if $str matches the supplied pattern, false otherwise. @param string $pattern Regex pattern to match against @return bool Whether or not $str matches the pattern
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L1000-L1008
cityware/city-format
src/Stringy.php
Stringy.isJson
public function isJson() { if (!$this->endsWith('}') && !$this->endsWith(']')) { return false; } return !is_null(json_decode($this->str)); }
php
public function isJson() { if (!$this->endsWith('}') && !$this->endsWith(']')) { return false; } return !is_null(json_decode($this->str)); }
Returns true if the string is JSON, false otherwise. @return bool Whether or not $str is JSON
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L1052-L1058
cityware/city-format
src/Stringy.php
Stringy.replace
public function replace($search, $replacement) { $regexEncoding = mb_regex_encoding(); mb_regex_encoding($this->encoding); // Don't want the args being parsed as regex $search = preg_quote($search); $replacement = preg_quote($replacement); $str = mb_ereg_replace($search, $replacement, $this->str); mb_regex_encoding($regexEncoding); return self::create($str, $this->encoding); }
php
public function replace($search, $replacement) { $regexEncoding = mb_regex_encoding(); mb_regex_encoding($this->encoding); // Don't want the args being parsed as regex $search = preg_quote($search); $replacement = preg_quote($replacement); $str = mb_ereg_replace($search, $replacement, $this->str); mb_regex_encoding($regexEncoding); return self::create($str, $this->encoding); }
Replaces all occurrences of $search in $str by $replacement. @param string $search The needle to search for @param string $replacement The string to replace with @return Stringy Object with the resulting $str after the replacements
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L1114-L1126
cityware/city-format
src/Stringy.php
Stringy.regexReplace
public function regexReplace($pattern, $replacement, $options = 'msr') { $regexEncoding = mb_regex_encoding(); mb_regex_encoding($this->encoding); $str = mb_ereg_replace($pattern, $replacement, $this->str, $options); mb_regex_encoding($regexEncoding); return self::create($str, $this->encoding); }
php
public function regexReplace($pattern, $replacement, $options = 'msr') { $regexEncoding = mb_regex_encoding(); mb_regex_encoding($this->encoding); $str = mb_ereg_replace($pattern, $replacement, $this->str, $options); mb_regex_encoding($regexEncoding); return self::create($str, $this->encoding); }
Replaces all occurrences of $pattern in $str by $replacement. An alias for mb_ereg_replace(). Note that the 'i' option with multibyte patterns in mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support in the bundled version of Oniguruma in PHP 5.3. @param string $pattern The regular expression pattern @param string $replacement The string to replace with @param string $options Matching conditions to be used @return Stringy Object with the resulting $str after the replacements
https://github.com/cityware/city-format/blob/1e292670639a950ecf561b545462427512950c74/src/Stringy.php#L1139-L1147
hal-platform/hal-core
src/Entity/User/UserPermission.php
UserPermission.withType
public function withType(string $type): self { $this->type = UserPermissionEnum::ensureValid($type); return $this; }
php
public function withType(string $type): self { $this->type = UserPermissionEnum::ensureValid($type); return $this; }
@param string $type @return self
https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Entity/User/UserPermission.php#L75-L79
dankempster/axstrad-filesystem
Scanner/BaseIteratorScanner.php
BaseIteratorScanner.setFileClassname
public function setFileClassname($classname = null) { if ($classname === null) { $this->fileClass = null; } elseif ( ! class_exists($classname)) { throw ClassDoesNotExistException::create($classname); } else { $this->fileClass = (string) $classname; } return $this; }
php
public function setFileClassname($classname = null) { if ($classname === null) { $this->fileClass = null; } elseif ( ! class_exists($classname)) { throw ClassDoesNotExistException::create($classname); } else { $this->fileClass = (string) $classname; } return $this; }
Set file classname If set, an instance of the class will be created for each file during iteration. It is that object that will be added to the FileBag. @param null|string $classname The classname of the File objects to create @return self @see getFileClassname @throws ClassDoesNotExistException If $classname does not exist.
https://github.com/dankempster/axstrad-filesystem/blob/f47e52fcf093dc64cf54bc5702100ea881d0b010/Scanner/BaseIteratorScanner.php#L65-L77
jtallant/skimpy-engine
cache/doctrine-proxy/__CG__SkimpyCMSTerm.php
Term.getId
public function getId() { if ($this->__isInitialized__ === false) { return (int) parent::getId(); } $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', []); return parent::getId(); }
php
public function getId() { if ($this->__isInitialized__ === false) { return (int) parent::getId(); } $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', []); return parent::getId(); }
{@inheritDoc}
https://github.com/jtallant/skimpy-engine/blob/2fce5bc16f8745e54fd66a1c291fcea47fc1b4b2/cache/doctrine-proxy/__CG__SkimpyCMSTerm.php#L190-L200
jtallant/skimpy-engine
cache/doctrine-proxy/__CG__SkimpyCMSTerm.php
Term.addContentItem
public function addContentItem(\Skimpy\CMS\ContentItem $item) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'addContentItem', [$item]); return parent::addContentItem($item); }
php
public function addContentItem(\Skimpy\CMS\ContentItem $item) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'addContentItem', [$item]); return parent::addContentItem($item); }
{@inheritDoc}
https://github.com/jtallant/skimpy-engine/blob/2fce5bc16f8745e54fd66a1c291fcea47fc1b4b2/cache/doctrine-proxy/__CG__SkimpyCMSTerm.php#L271-L277
Phpillip/phpillip
src/EventListener/LastModifiedListener.php
LastModifiedListener.onKernelReponse
public function onKernelReponse(FilterResponseEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); $route = $this->routes->get($request->attributes->get('_route')); if ($route && $route->hasContent() && !$response->headers->has('Last-Modified')) { $this->setLastModifiedHeader($route, $request, $response); } }
php
public function onKernelReponse(FilterResponseEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); $route = $this->routes->get($request->attributes->get('_route')); if ($route && $route->hasContent() && !$response->headers->has('Last-Modified')) { $this->setLastModifiedHeader($route, $request, $response); } }
Handler Kernel Response events @param FilterResponseEvent $event
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/EventListener/LastModifiedListener.php#L51-L60
Phpillip/phpillip
src/EventListener/LastModifiedListener.php
LastModifiedListener.setLastModifiedHeader
protected function setLastModifiedHeader(Route $route, Request $request, Response $response) { $content = $route->getContent(); if ($route->isList()) { $dates = array_map(function (array $content) { return $content['lastModified']; }, $request->attributes->get($content . 's')); rsort($dates); $lastModified = $dates[0]; } else { $lastModified = $request->attributes->get($content)['lastModified']; } $response->headers->set('Last-Modified', $lastModified); }
php
protected function setLastModifiedHeader(Route $route, Request $request, Response $response) { $content = $route->getContent(); if ($route->isList()) { $dates = array_map(function (array $content) { return $content['lastModified']; }, $request->attributes->get($content . 's')); rsort($dates); $lastModified = $dates[0]; } else { $lastModified = $request->attributes->get($content)['lastModified']; } $response->headers->set('Last-Modified', $lastModified); }
Populate content for the request @param Route $route @param Request $request @param Response $response
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/EventListener/LastModifiedListener.php#L69-L86
phpalchemy/phpalchemy
Alchemy/Kernel/Event/ControllerEvent.php
ControllerEvent.setController
public function setController($controller) { // controller must be a callable if (!is_callable($controller)) { throw new \LogicException(sprintf( 'The controller must be a callable (%s given).', gettype($controller) )); } $this->controller = $controller; }
php
public function setController($controller) { // controller must be a callable if (!is_callable($controller)) { throw new \LogicException(sprintf( 'The controller must be a callable (%s given).', gettype($controller) )); } $this->controller = $controller; }
Sets a controller @param callable $controller
https://github.com/phpalchemy/phpalchemy/blob/5b7e9b13acfda38c61b2da2639e8a56f298dc32e/Alchemy/Kernel/Event/ControllerEvent.php#L38-L49
gluephp/glue
src/Http/Request.php
Request.get
public function get($key = null, $fallback = null) { return $key ? $this->request->query->get($key, $fallback) : $this->request->query; }
php
public function get($key = null, $fallback = null) { return $key ? $this->request->query->get($key, $fallback) : $this->request->query; }
Get a query value from the $_GET super global @param string $key @param mixed $fallback @return mixed
https://github.com/gluephp/glue/blob/d54e0905dfe74d1c114c04f33fa89a60e2651562/src/Http/Request.php#L29-L34
gluephp/glue
src/Http/Request.php
Request.post
public function post($key = null, $fallback = null) { return $key ? $this->request->request->get($key, $fallback) : $this->request->request; }
php
public function post($key = null, $fallback = null) { return $key ? $this->request->request->get($key, $fallback) : $this->request->request; }
Get a parameter value from the $_POST super global @param string $key @param mixed $fallback @return mixed
https://github.com/gluephp/glue/blob/d54e0905dfe74d1c114c04f33fa89a60e2651562/src/Http/Request.php#L44-L49
gluephp/glue
src/Http/Request.php
Request.cookies
public function cookies($key = null, $fallback = null) { return $key ? $this->request->cookies->get($key, $fallback) : $this->request->cookies; }
php
public function cookies($key = null, $fallback = null) { return $key ? $this->request->cookies->get($key, $fallback) : $this->request->cookies; }
Get a cookie value from the $_COOKIE super global @param string $key @param mixed $fallback @return mixed
https://github.com/gluephp/glue/blob/d54e0905dfe74d1c114c04f33fa89a60e2651562/src/Http/Request.php#L59-L64
gluephp/glue
src/Http/Request.php
Request.files
public function files($key = null, $fallback = null) { return $key ? $this->request->files->get($key, $fallback) : $this->request->files; }
php
public function files($key = null, $fallback = null) { return $key ? $this->request->files->get($key, $fallback) : $this->request->files; }
Get a file value from the $_FILES super global @param string $key @param mixed $fallback @return mixed
https://github.com/gluephp/glue/blob/d54e0905dfe74d1c114c04f33fa89a60e2651562/src/Http/Request.php#L74-L79
gluephp/glue
src/Http/Request.php
Request.server
public function server($key = null, $fallback = null) { return $key ? $this->request->server->get($key, $fallback) : $this->request->server; }
php
public function server($key = null, $fallback = null) { return $key ? $this->request->server->get($key, $fallback) : $this->request->server; }
Get a server value from the $_SERVER super global @param string $key @param mixed $fallback @return mixed
https://github.com/gluephp/glue/blob/d54e0905dfe74d1c114c04f33fa89a60e2651562/src/Http/Request.php#L89-L94
gluephp/glue
src/Http/Request.php
Request.headers
public function headers($key = null, $fallback = null) { return $key ? $this->request->headers->get($key, $fallback) : $this->request->headers; }
php
public function headers($key = null, $fallback = null) { return $key ? $this->request->headers->get($key, $fallback) : $this->request->headers; }
Get a request header value @param string $key @param mixed $fallback @return mixed
https://github.com/gluephp/glue/blob/d54e0905dfe74d1c114c04f33fa89a60e2651562/src/Http/Request.php#L104-L109
antaresproject/translations
src/Http/Presenter/TranslationPresenter.php
TranslationPresenter.table
public function table($id, $current, $languages, array $list) { app('antares.asset')->container('antares/foundation::application')->add('webpack_brand_settings', '/webpack/view_brand_settings.js', ['app_cache']) ->add('webpack_forms_advanced', '/webpack/forms_advanced.js', ['webpack_brand_settings']) ->add('translations_requirements', '/webpack/translations_requirements.js', ['webpack_forms_advanced']); publish('translations', ['js/translations.js']); return $this->translations->render('antares/translations::admin.translation.index', compact('dataTable', 'languages', 'current', 'list', 'id')); }
php
public function table($id, $current, $languages, array $list) { app('antares.asset')->container('antares/foundation::application')->add('webpack_brand_settings', '/webpack/view_brand_settings.js', ['app_cache']) ->add('webpack_forms_advanced', '/webpack/forms_advanced.js', ['webpack_brand_settings']) ->add('translations_requirements', '/webpack/translations_requirements.js', ['webpack_forms_advanced']); publish('translations', ['js/translations.js']); return $this->translations->render('antares/translations::admin.translation.index', compact('dataTable', 'languages', 'current', 'list', 'id')); }
Table View Generator @param mixed $id @param mixed $current @param array $languages @param array $list @return \Illuminate\View\View
https://github.com/antaresproject/translations/blob/63097aeb97f18c5aeeef7dcf15f0c67959951685/src/Http/Presenter/TranslationPresenter.php#L55-L62
schpill/thin
src/Dependency.php
Dependency.has
public function has($itemName) { return Arrays::exists($itemName, $this->_store) && isset($this->_store[$itemName]['lookupType']); }
php
public function has($itemName) { return Arrays::exists($itemName, $this->_store) && isset($this->_store[$itemName]['lookupType']); }
Test if an item is registered in this container with the given name. @see register() @param string $itemName @return boolean
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L66-L69
schpill/thin
src/Dependency.php
Dependency.lookup
public function lookup($itemName) { if (!$this->has($itemName)) { throw new Exception( 'Cannot lookup dependency "' . $itemName . '" since it is not registered.' ); } switch ($this->_store[$itemName]['lookupType']) { case self::TYPE_ALIAS: return $this->_createAlias($itemName); case self::TYPE_VALUE: return $this->_getValue($itemName); case self::TYPE_INSTANCE: return $this->_createNewInstance($itemName); case self::TYPE_SHARED: return $this->_createSharedInstance($itemName); } }
php
public function lookup($itemName) { if (!$this->has($itemName)) { throw new Exception( 'Cannot lookup dependency "' . $itemName . '" since it is not registered.' ); } switch ($this->_store[$itemName]['lookupType']) { case self::TYPE_ALIAS: return $this->_createAlias($itemName); case self::TYPE_VALUE: return $this->_getValue($itemName); case self::TYPE_INSTANCE: return $this->_createNewInstance($itemName); case self::TYPE_SHARED: return $this->_createSharedInstance($itemName); } }
Lookup the item with the given $itemName. @see register() @param string $itemName @return mixed @throws DependencyException If the dependency is not found
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L82-L100
schpill/thin
src/Dependency.php
Dependency.createDependenciesFor
public function createDependenciesFor($itemName) { $args = array(); if (isset($this->_store[$itemName]['args'])) { $args = $this->_resolveArgs($this->_store[$itemName]['args']); } return $args; }
php
public function createDependenciesFor($itemName) { $args = array(); if (isset($this->_store[$itemName]['args'])) { $args = $this->_resolveArgs($this->_store[$itemName]['args']); } return $args; }
Create an array of arguments passed to the constructor of $itemName. @param string $itemName @return array
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L109-L117
schpill/thin
src/Dependency.php
Dependency.register
public function register($itemName) { $this->_store[$itemName] = array(); $this->_endPoint =& $this->_store[$itemName]; return $this; }
php
public function register($itemName) { $this->_store[$itemName] = array(); $this->_endPoint =& $this->_store[$itemName]; return $this; }
Register a new dependency with $itemName. This method returns the current Dependency instance because it requires the use of the fluid interface to set the specific details for the dependency. @see asNewInstanceOf(), asSharedInstanceOf(), asValue() @param string $itemName @return Dependency
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L131-L137
schpill/thin
src/Dependency.php
Dependency.asValue
public function asValue($value) { $endPoint =& $this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_VALUE; $endPoint['value'] = $value; return $this; }
php
public function asValue($value) { $endPoint =& $this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_VALUE; $endPoint['value'] = $value; return $this; }
Specify the previously registered item as a literal value. {@link register()} must be called before this will work. @param mixed $value @return Dependency
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L148-L155
schpill/thin
src/Dependency.php
Dependency.asAliasOf
public function asAliasOf($lookup) { $endPoint =& $this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_ALIAS; $endPoint['ref'] = $lookup; return $this; }
php
public function asAliasOf($lookup) { $endPoint =& $this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_ALIAS; $endPoint['ref'] = $lookup; return $this; }
Specify the previously registered item as an alias of another item. @param string $lookup @return Dependency
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L164-L171
schpill/thin
src/Dependency.php
Dependency.asNewInstanceOf
public function asNewInstanceOf($className) { $endPoint =& $this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_INSTANCE; $endPoint['className'] = $className; return $this; }
php
public function asNewInstanceOf($className) { $endPoint =& $this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_INSTANCE; $endPoint['className'] = $className; return $this; }
Specify the previously registered item as a new instance of $className. {@link register()} must be called before this will work. Any arguments can be set with {@link withDependencies()}, {@link addConstructorValue()} or {@link addConstructorLookup()}. @see withDependencies(), addConstructorValue(), addConstructorLookup() @param string $className @return Dependency
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L186-L193
schpill/thin
src/Dependency.php
Dependency.asSharedInstanceOf
public function asSharedInstanceOf($className) { $endPoint =& $this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_SHARED; $endPoint['className'] = $className; return $this; }
php
public function asSharedInstanceOf($className) { $endPoint =& $this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_SHARED; $endPoint['className'] = $className; return $this; }
Specify the previously registered item as a shared instance of $className. {@link register()} must be called before this will work. @param string $className @return Dependency
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L204-L211
schpill/thin
src/Dependency.php
Dependency.withDependencies
public function withDependencies(array $lookups) { $endPoint =& $this->_getEndPoint(); $endPoint['args'] = array(); foreach ($lookups as $lookup) { $this->addConstructorLookup($lookup); } return $this; }
php
public function withDependencies(array $lookups) { $endPoint =& $this->_getEndPoint(); $endPoint['args'] = array(); foreach ($lookups as $lookup) { $this->addConstructorLookup($lookup); } return $this; }
Specify a list of injected dependencies for the previously registered item. This method takes an array of lookup names. @see addConstructorValue(), addConstructorLookup() @param array $lookups @return Dependency
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L224-L233
schpill/thin
src/Dependency.php
Dependency.addConstructorValue
public function addConstructorValue($value) { $endPoint =& $this->_getEndPoint(); if (!isset($endPoint['args'])) { $endPoint['args'] = array(); } $endPoint['args'][] = array( 'type' => 'value', 'item' => $value ); return $this; }
php
public function addConstructorValue($value) { $endPoint =& $this->_getEndPoint(); if (!isset($endPoint['args'])) { $endPoint['args'] = array(); } $endPoint['args'][] = array( 'type' => 'value', 'item' => $value ); return $this; }
Specify a literal (non looked up) value for the constructor of the previously registered item. @see withDependencies(), addConstructorLookup() @param mixed $value @return Dependency
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L245-L259
schpill/thin
src/Dependency.php
Dependency.addConstructorLookup
public function addConstructorLookup($lookup) { $endPoint =& $this->_getEndPoint(); if (!isset($this->_endPoint['args'])) { $endPoint['args'] = array(); } $endPoint['args'][] = array( 'type' => 'lookup', 'item' => $lookup ); return $this; }
php
public function addConstructorLookup($lookup) { $endPoint =& $this->_getEndPoint(); if (!isset($this->_endPoint['args'])) { $endPoint['args'] = array(); } $endPoint['args'][] = array( 'type' => 'lookup', 'item' => $lookup ); return $this; }
Specify a dependency lookup for the constructor of the previously registered item. @see withDependencies(), addConstructorValue() @param string $lookup @return Dependency
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L271-L283
schpill/thin
src/Dependency.php
Dependency._createNewInstance
private function _createNewInstance($itemName) { $reflector = new \ReflectionClass($this->_store[$itemName]['className']); if ($reflector->getConstructor()) { return $reflector->newInstanceArgs( $this->createDependenciesFor($itemName) ); } else { return $reflector->newInstance(); } }
php
private function _createNewInstance($itemName) { $reflector = new \ReflectionClass($this->_store[$itemName]['className']); if ($reflector->getConstructor()) { return $reflector->newInstanceArgs( $this->createDependenciesFor($itemName) ); } else { return $reflector->newInstance(); } }
Create a fresh instance of $itemName
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L300-L310
schpill/thin
src/Dependency.php
Dependency._createSharedInstance
private function _createSharedInstance($itemName) { if (!isset($this->_store[$itemName]['instance'])) { $this->_store[$itemName]['instance'] = $this->_createNewInstance($itemName); } return $this->_store[$itemName]['instance']; }
php
private function _createSharedInstance($itemName) { if (!isset($this->_store[$itemName]['instance'])) { $this->_store[$itemName]['instance'] = $this->_createNewInstance($itemName); } return $this->_store[$itemName]['instance']; }
Create and register a shared instance of $itemName
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L313-L320
schpill/thin
src/Dependency.php
Dependency._resolveArgs
private function _resolveArgs(array $args) { $resolved = array(); foreach ($args as $argDefinition) { switch ($argDefinition['type']) { case 'lookup': $resolved[] = $this->_lookupRecursive($argDefinition['item']); break; case 'value': $resolved[] = $argDefinition['item']; break; } } return $resolved; }
php
private function _resolveArgs(array $args) { $resolved = array(); foreach ($args as $argDefinition) { switch ($argDefinition['type']) { case 'lookup': $resolved[] = $this->_lookupRecursive($argDefinition['item']); break; case 'value': $resolved[] = $argDefinition['item']; break; } } return $resolved; }
Get an argument list with dependencies resolved
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L335-L350
schpill/thin
src/Dependency.php
Dependency._lookupRecursive
private function _lookupRecursive($item) { if (Arrays::is($item)) { $collection = array(); foreach ($item as $k => $v) { $collection[$k] = $this->_lookupRecursive($v); } return $collection; } else { return $this->lookup($item); } }
php
private function _lookupRecursive($item) { if (Arrays::is($item)) { $collection = array(); foreach ($item as $k => $v) { $collection[$k] = $this->_lookupRecursive($v); } return $collection; } else { return $this->lookup($item); } }
Resolve a single dependency with an collections
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Dependency.php#L353-L364
selikhovleonid/nadir
src/core/CtrlWrapper.php
CtrlWrapper.callActon
private function callActon($sName, array $aArgs) { if (empty($aArgs)) { $this->ctrl->{$sName}(); } else { $oMethod = new \ReflectionMethod($this->ctrl, $sName); $oMethod->invokeArgs($this->ctrl, $aArgs); } }
php
private function callActon($sName, array $aArgs) { if (empty($aArgs)) { $this->ctrl->{$sName}(); } else { $oMethod = new \ReflectionMethod($this->ctrl, $sName); $oMethod->invokeArgs($this->ctrl, $aArgs); } }
It calls the controller action with passage the parameters if necessary. @param string $sName The action name of target controller. @param array $aArgs The action parameters.
https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/CtrlWrapper.php#L30-L38
selikhovleonid/nadir
src/core/CtrlWrapper.php
CtrlWrapper.processAuth
protected function processAuth($sName, array $aArgs) { if (class_exists('\extensions\core\Auth')) { $oAuth = new \extensions\core\Auth($this->ctrl->getRequest()); $oAuth->run(); if ($oAuth->isValid()) { $this->callActon($sName, $aArgs); } else { $oAuth->onFail(); } } else { $this->callActon($sName, $aArgs); } }
php
protected function processAuth($sName, array $aArgs) { if (class_exists('\extensions\core\Auth')) { $oAuth = new \extensions\core\Auth($this->ctrl->getRequest()); $oAuth->run(); if ($oAuth->isValid()) { $this->callActon($sName, $aArgs); } else { $oAuth->onFail(); } } else { $this->callActon($sName, $aArgs); } }
The method calls user's auth checking, on successful complition of which it invokes the target controller and the onFail method of Auth class in other case. @param string $sName The action name. @param mixed[] $aArgs The action parameters.
https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/CtrlWrapper.php#L47-L60
Synapse-Cmf/synapse-cmf
src/Synapse/Cmf/Bundle/Form/Type/Media/FormatType.php
FormatType.configureOptions
public function configureOptions(OptionsResolver $resolver) { $resolver->setRequired('format'); $resolver->setAllowedTypes('format', FormatInterface::class); $resolver->setDefaults(array( 'cascade_validation' => false, 'data_class' => FormatAction::class, )); }
php
public function configureOptions(OptionsResolver $resolver) { $resolver->setRequired('format'); $resolver->setAllowedTypes('format', FormatInterface::class); $resolver->setDefaults(array( 'cascade_validation' => false, 'data_class' => FormatAction::class, )); }
{@inheritdoc}
https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Bundle/Form/Type/Media/FormatType.php#L39-L48
Synapse-Cmf/synapse-cmf
src/Synapse/Cmf/Bundle/Form/Type/Media/FormatType.php
FormatType.buildForm
public function buildForm(FormBuilderInterface $builder, array $options) { $this->format = $options['format']; $builder ->addModelTransformer($this) ->add('options', FormatOptionsType::class, array()) ; }
php
public function buildForm(FormBuilderInterface $builder, array $options) { $this->format = $options['format']; $builder ->addModelTransformer($this) ->add('options', FormatOptionsType::class, array()) ; }
Options form prototype definition. @see FormInterface::buildForm()
https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Bundle/Form/Type/Media/FormatType.php#L73-L81
deweller/php-cliopts
src/CLIOpts/Values/ArgumentValues.php
ArgumentValues.getValidator
public function getValidator() { if (!isset($this->validator)) { $this->validator = new ArgsValidator($this->arguments_spec, $this->parsed_args); } return $this->validator; }
php
public function getValidator() { if (!isset($this->validator)) { $this->validator = new ArgsValidator($this->arguments_spec, $this->parsed_args); } return $this->validator; }
get the validator for these values @return ArgsValidator the validator
https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Values/ArgumentValues.php#L80-L85
deweller/php-cliopts
src/CLIOpts/Values/ArgumentValues.php
ArgumentValues.offsetGet
public function offsetGet($key) { $resolved_key = $this->arguments_spec->normalizeOptionName($key); if ($resolved_key === null) { if (isset($this->merged_arg_values[$key])) { return parent::offsetGet($key); } } if (isset($this->merged_arg_values[$resolved_key])) { return parent::offsetGet($resolved_key); } return null; }
php
public function offsetGet($key) { $resolved_key = $this->arguments_spec->normalizeOptionName($key); if ($resolved_key === null) { if (isset($this->merged_arg_values[$key])) { return parent::offsetGet($key); } } if (isset($this->merged_arg_values[$resolved_key])) { return parent::offsetGet($resolved_key); } return null; }
returns the argument or option value @param string $key argument name or long option name @return string argument or option value
https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Values/ArgumentValues.php#L96-L110
deweller/php-cliopts
src/CLIOpts/Values/ArgumentValues.php
ArgumentValues.offsetExists
public function offsetExists($key) { $resolved_key = $this->arguments_spec->normalizeOptionName($key); if ($resolved_key === null) { return isset($this->merged_arg_values[$key]); } return isset($this->merged_arg_values[$resolved_key]); }
php
public function offsetExists($key) { $resolved_key = $this->arguments_spec->normalizeOptionName($key); if ($resolved_key === null) { return isset($this->merged_arg_values[$key]); } return isset($this->merged_arg_values[$resolved_key]); }
returns true if the argument or option value exists @param string $key argument name or long option name @return bool true if the argument or option value exists
https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Values/ArgumentValues.php#L120-L127
deweller/php-cliopts
src/CLIOpts/Values/ArgumentValues.php
ArgumentValues.extractAllLongOpts
protected function extractAllLongOpts(ArgumentsSpec $arguments_spec, $parsed_args) { $long_opts = array(); foreach ($parsed_args['options'] as $option_name => $value) { if ($long_option_name = $arguments_spec->normalizeOptionName($option_name)) { $long_opts[$long_option_name] = $value; } } return $long_opts; }
php
protected function extractAllLongOpts(ArgumentsSpec $arguments_spec, $parsed_args) { $long_opts = array(); foreach ($parsed_args['options'] as $option_name => $value) { if ($long_option_name = $arguments_spec->normalizeOptionName($option_name)) { $long_opts[$long_option_name] = $value; } } return $long_opts; }
builds argument values by long option name @param ArgumentsSpec $arguments_spec The arguments specification @param array $parsed_args data parsed by the ArgumentsParser @return array argument values by long option name
https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Values/ArgumentValues.php#L152-L162
prhost/composer-vendor-merge
src/ComposerMergeVendor.php
ComposerMergeVendor.addVendor
public function addVendor($vendorPath) { $dir = $vendorPath . '/composer'; if (file_exists($file = $dir . '/autoload_namespaces.php')) { $map = require $file; foreach ($map as $namespace => $path) { if (isset($this->namespacePool[$namespace])) continue; $this->loader->set($namespace, $path); $this->namespacePool[$namespace] = true; } } if (file_exists($file = $dir . '/autoload_psr4.php')) { $map = require $file; foreach ($map as $namespace => $path) { if (isset($this->psr4Pool[$namespace])) continue; $this->loader->setPsr4($namespace, $path); $this->psr4Pool[$namespace] = true; } } if (file_exists($file = $dir . '/autoload_classmap.php')) { $classMap = require $file; if ($classMap) { $classMapDiff = array_diff_key($classMap, $this->classMapPool); $this->loader->addClassMap($classMapDiff); $this->classMapPool += array_fill_keys(array_keys($classMapDiff), true); } } if (file_exists($file = $dir . '/autoload_files.php')) { $includeFiles = require $file; foreach ($includeFiles as $includeFile) { $relativeFile = $this->stripVendorDir($includeFile, $vendorPath); if (isset($this->includeFilesPool[$relativeFile])) continue; require $includeFile; $this->includeFilesPool[$relativeFile] = true; } } }
php
public function addVendor($vendorPath) { $dir = $vendorPath . '/composer'; if (file_exists($file = $dir . '/autoload_namespaces.php')) { $map = require $file; foreach ($map as $namespace => $path) { if (isset($this->namespacePool[$namespace])) continue; $this->loader->set($namespace, $path); $this->namespacePool[$namespace] = true; } } if (file_exists($file = $dir . '/autoload_psr4.php')) { $map = require $file; foreach ($map as $namespace => $path) { if (isset($this->psr4Pool[$namespace])) continue; $this->loader->setPsr4($namespace, $path); $this->psr4Pool[$namespace] = true; } } if (file_exists($file = $dir . '/autoload_classmap.php')) { $classMap = require $file; if ($classMap) { $classMapDiff = array_diff_key($classMap, $this->classMapPool); $this->loader->addClassMap($classMapDiff); $this->classMapPool += array_fill_keys(array_keys($classMapDiff), true); } } if (file_exists($file = $dir . '/autoload_files.php')) { $includeFiles = require $file; foreach ($includeFiles as $includeFile) { $relativeFile = $this->stripVendorDir($includeFile, $vendorPath); if (isset($this->includeFilesPool[$relativeFile])) continue; require $includeFile; $this->includeFilesPool[$relativeFile] = true; } } }
Similar function to including vendor/autoload.php. @param string $vendorPath Absoulte path to the vendor directory. @return void
https://github.com/prhost/composer-vendor-merge/blob/747ce16e28b8dfe6714014a5890f1bb8aba97657/src/ComposerMergeVendor.php#L50-L86
helori/laravel-admin
src/Notifications/AdminResetPassword.php
AdminResetPassword.toMail
public function toMail() { return (new MailMessage) ->subject(config('app.name').' : Ré-initialisation de votre mot de passe') ->line([ 'Vous recevez cet email car nous avons reçu une demande de ré-initialisation de mot de passe pour votre compte.', 'Cliquez sur ce bouton pour ré-initialiser votre mot de passe :', ]) ->action('Ré-initialiser le mot de passe', route('admin-password-reset', ['token' => $this->token])) ->line('Si vous n\'avez pas demandé à ré-initialiser votre mot de passe, alors vous n\'avez rien à faire.'); }
php
public function toMail() { return (new MailMessage) ->subject(config('app.name').' : Ré-initialisation de votre mot de passe') ->line([ 'Vous recevez cet email car nous avons reçu une demande de ré-initialisation de mot de passe pour votre compte.', 'Cliquez sur ce bouton pour ré-initialiser votre mot de passe :', ]) ->action('Ré-initialiser le mot de passe', route('admin-password-reset', ['token' => $this->token])) ->line('Si vous n\'avez pas demandé à ré-initialiser votre mot de passe, alors vous n\'avez rien à faire.'); }
Build the mail representation of the notification. @return \Illuminate\Notifications\Messages\MailMessage
https://github.com/helori/laravel-admin/blob/169bc37c3126bc6a3a2f3df6a8d7a43ddab53dec/src/Notifications/AdminResetPassword.php#L45-L55
nilportugues/php-todo-finder
src/TodoFinder/Command/FinderCommand.php
FinderCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $path = $input->getArgument(self::COMMAND_NAME); $realPath = realpath($path); $configFile = $input->getOption('config'); $finder = new FileParser($configFile); if (file_exists($configFile)) { $this->scanFiles($path, $finder); if (!empty($this->errors)) { $output->writeln("<info>To-do expressions were found:</info>\n"); foreach ($this->errors as $file => $lines) { foreach ($lines as $line) { $output->writeln( sprintf( "<comment> - .%s:</comment> %s", str_replace($realPath, '', $file), $line ) ); } } if (count($this->flatten($this->errors)) > $finder->getTotalAllowed()) { throw new \Exception('To-do statements are piling up! Isn\'t it time to address this issue?'); } } return $output->writeln("<info>\nCongratulations! To-do statements are under control.\n</info>"); } throw new ConfigFileException($configFile); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $path = $input->getArgument(self::COMMAND_NAME); $realPath = realpath($path); $configFile = $input->getOption('config'); $finder = new FileParser($configFile); if (file_exists($configFile)) { $this->scanFiles($path, $finder); if (!empty($this->errors)) { $output->writeln("<info>To-do expressions were found:</info>\n"); foreach ($this->errors as $file => $lines) { foreach ($lines as $line) { $output->writeln( sprintf( "<comment> - .%s:</comment> %s", str_replace($realPath, '', $file), $line ) ); } } if (count($this->flatten($this->errors)) > $finder->getTotalAllowed()) { throw new \Exception('To-do statements are piling up! Isn\'t it time to address this issue?'); } } return $output->writeln("<info>\nCongratulations! To-do statements are under control.\n</info>"); } throw new ConfigFileException($configFile); }
@param InputInterface $input @param OutputInterface $output @return int|null @throws Exceptions\ConfigFileException @throws \Exception
https://github.com/nilportugues/php-todo-finder/blob/eea3e63714633744e6e576bf0ca4b8e1d7c20be5/src/TodoFinder/Command/FinderCommand.php#L55-L89
znframework/package-helpers
Logger.php
Logger.notice
public static function notice(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
php
public static function notice(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
Notice log @param string $message @param string $time @return bool
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Logger.php#L24-L27
znframework/package-helpers
Logger.php
Logger.emergency
public static function emergency(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
php
public static function emergency(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
Emergency log @param string $message @param string $time @return bool
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Logger.php#L37-L40
znframework/package-helpers
Logger.php
Logger.alert
public static function alert(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
php
public static function alert(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
Alert log @param string $message @param string $time @return bool
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Logger.php#L50-L53
znframework/package-helpers
Logger.php
Logger.error
public static function error(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
php
public static function error(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
Error log @param string $message @param string $time @return bool
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Logger.php#L63-L66
znframework/package-helpers
Logger.php
Logger.warning
public static function warning(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
php
public static function warning(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
Warning log @param string $message @param string $time @return bool
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Logger.php#L76-L79
znframework/package-helpers
Logger.php
Logger.critical
public static function critical(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
php
public static function critical(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
Critical log @param string $message @param string $time @return bool
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Logger.php#L89-L92
znframework/package-helpers
Logger.php
Logger.info
public static function info(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
php
public static function info(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
Info log @param string $message @param string $time @return bool
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Logger.php#L102-L105
znframework/package-helpers
Logger.php
Logger.debug
public static function debug(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
php
public static function debug(String $message, String $time = NULL) { return self::report(__FUNCTION__, $message, NULL, $time); }
Debug log @param string $message @param string $time @return bool
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Logger.php#L115-L118
znframework/package-helpers
Logger.php
Logger.report
public static function report(String $subject, String $message, String $destination = NULL, String $time = NULL) : Bool { return Helper::report($subject, $message, $destination, $time); }
php
public static function report(String $subject, String $message, String $destination = NULL, String $time = NULL) : Bool { return Helper::report($subject, $message, $destination, $time); }
Report log @param string $subject @param string $message @param string $destination @param string $time @return bool
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Logger.php#L130-L133
aaronadal/twig-list-loop
src/Twig/ListTokenParser.php
ListTokenParser.parse
public function parse(Twig_Token $token) { $parser = $this->parser; $stream = $parser->getStream(); // Parse for loop $targets = $parser->getExpressionParser()->parseAssignmentExpression(); $stream->expect(Twig_Token::OPERATOR_TYPE, 'in'); $sequence = $parser->getExpressionParser()->parseExpression(); // Parse if expression $if = null; if($stream->nextIf(Twig_Token::NAME_TYPE, 'if')) { $if = $parser->getExpressionParser()->parseExpression(); } // Parse listing template $stream->expect(Twig_Token::NAME_TYPE, 'using'); $template = $this->parser->getExpressionParser()->parseExpression(); // Parse additional args $args = null; if($stream->nextIf(Twig_Token::NAME_TYPE, 'with')) { $args = $parser->getExpressionParser()->parseExpression(); } $stream->expect(Twig_Token::BLOCK_END_TYPE); // Subparse body $body = $parser->subparse(array($this, 'decideListBodyEnd')); // Subparse else $else = null; if($stream->next()->getValue() == 'else') { $stream->expect(Twig_Token::BLOCK_END_TYPE); $else = $parser->subparse(array($this, 'decideListElseEnd'), true); } $stream->expect(Twig_Token::BLOCK_END_TYPE); // Parse for loop variable names if(count($targets) > 1) { $keyTarget = $targets->getNode(0); $keyTarget = new Twig_Node_Expression_AssignName( $keyTarget->getAttribute('name'), $keyTarget->getTemplateLine() ); $valueTarget = $targets->getNode(1); $valueTarget = new Twig_Node_Expression_AssignName( $valueTarget->getAttribute('name'), $valueTarget->getTemplateLine() ); } else { $keyTarget = new Twig_Node_Expression_AssignName('_key', $token->getLine()); $valueTarget = $targets->getNode(0); $valueTarget = new Twig_Node_Expression_AssignName( $valueTarget->getAttribute('name'), $valueTarget->getTemplateLine() ); } // Create loop node $listTarget = new Twig_Node_Expression_AssignName('list', $token->getLine()); $listLoop = $this->createForLoop($keyTarget, $valueTarget, $listTarget, $sequence, $if, $body, $token->getLine(), self::TAG); // Return list node return new ListNode($template, $listTarget, $listLoop, $args, $else, $token->getLine(), self::TAG); }
php
public function parse(Twig_Token $token) { $parser = $this->parser; $stream = $parser->getStream(); // Parse for loop $targets = $parser->getExpressionParser()->parseAssignmentExpression(); $stream->expect(Twig_Token::OPERATOR_TYPE, 'in'); $sequence = $parser->getExpressionParser()->parseExpression(); // Parse if expression $if = null; if($stream->nextIf(Twig_Token::NAME_TYPE, 'if')) { $if = $parser->getExpressionParser()->parseExpression(); } // Parse listing template $stream->expect(Twig_Token::NAME_TYPE, 'using'); $template = $this->parser->getExpressionParser()->parseExpression(); // Parse additional args $args = null; if($stream->nextIf(Twig_Token::NAME_TYPE, 'with')) { $args = $parser->getExpressionParser()->parseExpression(); } $stream->expect(Twig_Token::BLOCK_END_TYPE); // Subparse body $body = $parser->subparse(array($this, 'decideListBodyEnd')); // Subparse else $else = null; if($stream->next()->getValue() == 'else') { $stream->expect(Twig_Token::BLOCK_END_TYPE); $else = $parser->subparse(array($this, 'decideListElseEnd'), true); } $stream->expect(Twig_Token::BLOCK_END_TYPE); // Parse for loop variable names if(count($targets) > 1) { $keyTarget = $targets->getNode(0); $keyTarget = new Twig_Node_Expression_AssignName( $keyTarget->getAttribute('name'), $keyTarget->getTemplateLine() ); $valueTarget = $targets->getNode(1); $valueTarget = new Twig_Node_Expression_AssignName( $valueTarget->getAttribute('name'), $valueTarget->getTemplateLine() ); } else { $keyTarget = new Twig_Node_Expression_AssignName('_key', $token->getLine()); $valueTarget = $targets->getNode(0); $valueTarget = new Twig_Node_Expression_AssignName( $valueTarget->getAttribute('name'), $valueTarget->getTemplateLine() ); } // Create loop node $listTarget = new Twig_Node_Expression_AssignName('list', $token->getLine()); $listLoop = $this->createForLoop($keyTarget, $valueTarget, $listTarget, $sequence, $if, $body, $token->getLine(), self::TAG); // Return list node return new ListNode($template, $listTarget, $listLoop, $args, $else, $token->getLine(), self::TAG); }
{@inheritdoc}
https://github.com/aaronadal/twig-list-loop/blob/266d650bab1673e08a2b71df3fd1f285feccc8a9/src/Twig/ListTokenParser.php#L22-L91
104corp/php-cache
src/ArrayCache.php
ArrayCache.set
public function set($key, $value, $ttl = null) { Helper::checkStringType($key); $this->data[$key] = [ 'value' => $value, 'expireAt' => Helper::normalizeExpireAt($ttl) ]; return true; }
php
public function set($key, $value, $ttl = null) { Helper::checkStringType($key); $this->data[$key] = [ 'value' => $value, 'expireAt' => Helper::normalizeExpireAt($ttl) ]; return true; }
{@inheritdoc}
https://github.com/104corp/php-cache/blob/35305201af260b9e9234d772ec1b1870a3332efb/src/ArrayCache.php#L36-L46
104corp/php-cache
src/ArrayCache.php
ArrayCache.setMultiple
public function setMultiple($values, $ttl = null) { Helper::checkTraversableType($values); foreach ($values as $key => $value) { $this->set($key, $value, $ttl); } return true; }
php
public function setMultiple($values, $ttl = null) { Helper::checkTraversableType($values); foreach ($values as $key => $value) { $this->set($key, $value, $ttl); } return true; }
{@inheritdoc}
https://github.com/104corp/php-cache/blob/35305201af260b9e9234d772ec1b1870a3332efb/src/ArrayCache.php#L88-L97
104corp/php-cache
src/ArrayCache.php
ArrayCache.deleteMultiple
public function deleteMultiple($keys) { Helper::checkTraversableType($keys); foreach ($keys as $key) { $this->delete($key); } return true; }
php
public function deleteMultiple($keys) { Helper::checkTraversableType($keys); foreach ($keys as $key) { $this->delete($key); } return true; }
{@inheritdoc}
https://github.com/104corp/php-cache/blob/35305201af260b9e9234d772ec1b1870a3332efb/src/ArrayCache.php#L102-L111
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Config/Registry.php
Radial_Core_Model_Config_Registry._getStoreConfigValue
protected function _getStoreConfigValue($configKey, $store, $asFlag) { foreach ($this->_configModels as $configModel) { if ($configModel->hasKey($configKey)) { $configMethod = $asFlag ? 'getStoreConfigFlag' : 'getStoreConfig'; return Mage::$configMethod($configModel->getPathForKey($configKey), $store); } } throw Mage::exception('Mage_Core', "Configuration path specified by '$configKey' was not found."); }
php
protected function _getStoreConfigValue($configKey, $store, $asFlag) { foreach ($this->_configModels as $configModel) { if ($configModel->hasKey($configKey)) { $configMethod = $asFlag ? 'getStoreConfigFlag' : 'getStoreConfig'; return Mage::$configMethod($configModel->getPathForKey($configKey), $store); } } throw Mage::exception('Mage_Core', "Configuration path specified by '$configKey' was not found."); }
Search through registered config models for one that knows about the key and get the actual config path from it for the lookup. @param string $configKey @param null|string|bool|int|Mage_Core_Model_Store $store @param bool $asFlag @throws Mage_Core_Exception if the config path is not found. @return string|bool
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Config/Registry.php#L77-L86
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Config/Registry.php
Radial_Core_Model_Config_Registry.getConfigFlag
public function getConfigFlag($configKey, $store = null) { // if a value is given store, use it, even if it is null/false/empty string/whatever $store = count(func_get_args()) > 1 ? $store : $this->getStore(); return $this->_getStoreConfigValue($configKey, $store, true); }
php
public function getConfigFlag($configKey, $store = null) { // if a value is given store, use it, even if it is null/false/empty string/whatever $store = count(func_get_args()) > 1 ? $store : $this->getStore(); return $this->_getStoreConfigValue($configKey, $store, true); }
Get the configuration value represented by the given configKey @param string $configKey @param null|string|bool|int|Mage_Core_Model_Store $store @return string
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Config/Registry.php#L94-L99
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Config/Registry.php
Radial_Core_Model_Config_Registry.getConfig
public function getConfig($configKey, $store = null) { // if a value is given store, use it, even if it is null/false/empty string/whatever $store = count(func_get_args()) > 1 ? $store : $this->getStore(); return $this->_getStoreConfigValue($configKey, $store, false); }
php
public function getConfig($configKey, $store = null) { // if a value is given store, use it, even if it is null/false/empty string/whatever $store = count(func_get_args()) > 1 ? $store : $this->getStore(); return $this->_getStoreConfigValue($configKey, $store, false); }
Get the configuration flag value represented by the given configKey @param string $configKey @param null|string|bool|int|Mage_Core_Model_Store $store @return bool
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Config/Registry.php#L107-L112
xervice/redis
src/Xervice/Redis/Communication/Plugin/RedisSessionHandler.php
RedisSessionHandler.doRead
protected function doRead($sessionId): string { try { $this->sessionDataProvider = $this->getFacade()->get($this->prefix . $sessionId); } catch (RedisException $exception) { $this->sessionDataProvider->setData(''); } return $this->sessionDataProvider->getData(); }
php
protected function doRead($sessionId): string { try { $this->sessionDataProvider = $this->getFacade()->get($this->prefix . $sessionId); } catch (RedisException $exception) { $this->sessionDataProvider->setData(''); } return $this->sessionDataProvider->getData(); }
@param string $sessionId @return string
https://github.com/xervice/redis/blob/c773553c825b1d035cb68da3e1496a81cd68e1f1/src/Xervice/Redis/Communication/Plugin/RedisSessionHandler.php#L50-L59
xervice/redis
src/Xervice/Redis/Communication/Plugin/RedisSessionHandler.php
RedisSessionHandler.doWrite
protected function doWrite($sessionId, $data): bool { $this->sessionDataProvider->setData($data); $this->getFacade()->setEx($this->prefix . $sessionId, $this->sessionDataProvider, 'ex', $this->ttl); return true; }
php
protected function doWrite($sessionId, $data): bool { $this->sessionDataProvider->setData($data); $this->getFacade()->setEx($this->prefix . $sessionId, $this->sessionDataProvider, 'ex', $this->ttl); return true; }
@param string $sessionId @param string $data @return bool
https://github.com/xervice/redis/blob/c773553c825b1d035cb68da3e1496a81cd68e1f1/src/Xervice/Redis/Communication/Plugin/RedisSessionHandler.php#L67-L73
xervice/redis
src/Xervice/Redis/Communication/Plugin/RedisSessionHandler.php
RedisSessionHandler.doDestroy
protected function doDestroy($sessionId): bool { $this->getFacade()->delete($this->prefix . $sessionId); return true; }
php
protected function doDestroy($sessionId): bool { $this->getFacade()->delete($this->prefix . $sessionId); return true; }
@param string $sessionId @return bool
https://github.com/xervice/redis/blob/c773553c825b1d035cb68da3e1496a81cd68e1f1/src/Xervice/Redis/Communication/Plugin/RedisSessionHandler.php#L80-L85
xervice/redis
src/Xervice/Redis/Communication/Plugin/RedisSessionHandler.php
RedisSessionHandler.updateTimestamp
public function updateTimestamp($session_id, $session_data): bool { $this->getFacade()->expire($this->prefix . $session_id, $this->ttl); return true; }
php
public function updateTimestamp($session_id, $session_data): bool { $this->getFacade()->expire($this->prefix . $session_id, $this->ttl); return true; }
@param string $session_id @param string $session_data @return bool
https://github.com/xervice/redis/blob/c773553c825b1d035cb68da3e1496a81cd68e1f1/src/Xervice/Redis/Communication/Plugin/RedisSessionHandler.php#L111-L116
Phpillip/phpillip
src/Console/Command/BuildCommand.php
BuildCommand.initialize
protected function initialize(InputInterface $input, OutputInterface $output) { $this->app = $this->getApplication()->getKernel(); $this->logger = new Logger($output); $destination = $input->getArgument('destination') ?: $this->app['root'] . $this->app['dst_path']; $this->builder = new Builder($this->app, $destination); if (!$input->getOption('no-sitemap')) { $this->sitemap = new Sitemap(); $this->app['dispatcher']->addSubscriber(new SitemapListener($this->app['routes'], $this->sitemap)); } if ($host = $input->getArgument('host')) { $this->app['url_generator']->getContext()->setHost($host); } }
php
protected function initialize(InputInterface $input, OutputInterface $output) { $this->app = $this->getApplication()->getKernel(); $this->logger = new Logger($output); $destination = $input->getArgument('destination') ?: $this->app['root'] . $this->app['dst_path']; $this->builder = new Builder($this->app, $destination); if (!$input->getOption('no-sitemap')) { $this->sitemap = new Sitemap(); $this->app['dispatcher']->addSubscriber(new SitemapListener($this->app['routes'], $this->sitemap)); } if ($host = $input->getArgument('host')) { $this->app['url_generator']->getContext()->setHost($host); } }
{@inheritdoc}
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L88-L105
Phpillip/phpillip
src/Console/Command/BuildCommand.php
BuildCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $this->logger->log('[ Clearing destination folder ]'); $this->builder->clear(); $this->logger->log(sprintf('[ Building <info>%s</info> routes ]', $this->app['routes']->count())); foreach ($this->app['routes'] as $name => $route) { $this->dump($route, $name); } if ($this->sitemap) { $this->logger->log(sprintf('[ Building sitemap with <comment>%s</comment> urls. ]', count($this->sitemap))); $this->buildSitemap($this->sitemap); } if (!$input->getOption('no-expose') && $this->getApplication()->has('phpillip:expose')) { $arguments = [ 'command' => 'phpillip:expose', 'destination' => $input->getArgument('destination'), ]; $this->getApplication()->get('phpillip:expose')->run(new ArrayInput($arguments), $output); } }
php
protected function execute(InputInterface $input, OutputInterface $output) { $this->logger->log('[ Clearing destination folder ]'); $this->builder->clear(); $this->logger->log(sprintf('[ Building <info>%s</info> routes ]', $this->app['routes']->count())); foreach ($this->app['routes'] as $name => $route) { $this->dump($route, $name); } if ($this->sitemap) { $this->logger->log(sprintf('[ Building sitemap with <comment>%s</comment> urls. ]', count($this->sitemap))); $this->buildSitemap($this->sitemap); } if (!$input->getOption('no-expose') && $this->getApplication()->has('phpillip:expose')) { $arguments = [ 'command' => 'phpillip:expose', 'destination' => $input->getArgument('destination'), ]; $this->getApplication()->get('phpillip:expose')->run(new ArrayInput($arguments), $output); } }
{@inheritdoc}
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L110-L134
Phpillip/phpillip
src/Console/Command/BuildCommand.php
BuildCommand.dump
protected function dump(Route $route, $name) { if (!$route->isVisible()) { return; } if (!in_array('GET', $route->getMethods())) { throw new Exception(sprintf('Only GET mehtod supported, "%s" given.', $name)); } if ($route->hasContent()) { if ($route->isList()) { if ($route->isPaginated()) { $this->buildPaginatedRoute($route, $name); } else { $this->buildListRoute($route, $name); } } else { $this->buildContentRoute($route, $name); } } else { $this->logger->log(sprintf('Building route <comment>%s</comment>', $name)); $this->builder->build($route, $name); } }
php
protected function dump(Route $route, $name) { if (!$route->isVisible()) { return; } if (!in_array('GET', $route->getMethods())) { throw new Exception(sprintf('Only GET mehtod supported, "%s" given.', $name)); } if ($route->hasContent()) { if ($route->isList()) { if ($route->isPaginated()) { $this->buildPaginatedRoute($route, $name); } else { $this->buildListRoute($route, $name); } } else { $this->buildContentRoute($route, $name); } } else { $this->logger->log(sprintf('Building route <comment>%s</comment>', $name)); $this->builder->build($route, $name); } }
Dump route content to destination file @param Route $route @param string $name
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L142-L166
Phpillip/phpillip
src/Console/Command/BuildCommand.php
BuildCommand.buildPaginatedRoute
protected function buildPaginatedRoute(Route $route, $name) { $contentType = $route->getContent(); $contents = $this->app['content_repository']->listContents($contentType); $paginator = new Paginator($contents, $route->getPerPage()); $this->logger->log(sprintf( 'Building route <comment>%s</comment> for <info>%s</info> pages', $name, $paginator->count() )); $this->logger->getProgress($paginator->count()); $this->logger->start(); foreach ($paginator as $index => $contents) { $this->builder->build($route, $name, ['page' => $index + 1]); $this->logger->advance(); } $this->logger->finish(); }
php
protected function buildPaginatedRoute(Route $route, $name) { $contentType = $route->getContent(); $contents = $this->app['content_repository']->listContents($contentType); $paginator = new Paginator($contents, $route->getPerPage()); $this->logger->log(sprintf( 'Building route <comment>%s</comment> for <info>%s</info> pages', $name, $paginator->count() )); $this->logger->getProgress($paginator->count()); $this->logger->start(); foreach ($paginator as $index => $contents) { $this->builder->build($route, $name, ['page' => $index + 1]); $this->logger->advance(); } $this->logger->finish(); }
Build paginated route @param Route $route @param string $name
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L174-L194
Phpillip/phpillip
src/Console/Command/BuildCommand.php
BuildCommand.buildListRoute
protected function buildListRoute(Route $route, $name) { $contentType = $route->getContent(); $contents = $this->app['content_repository']->listContents($contentType); $this->logger->log(sprintf( 'Building route <comment>%s</comment> with <info>%s</info> <comment>%s(s)</comment>', $name, count($contents), $contentType )); $this->builder->build($route, $name); }
php
protected function buildListRoute(Route $route, $name) { $contentType = $route->getContent(); $contents = $this->app['content_repository']->listContents($contentType); $this->logger->log(sprintf( 'Building route <comment>%s</comment> with <info>%s</info> <comment>%s(s)</comment>', $name, count($contents), $contentType )); $this->builder->build($route, $name); }
Build list route @param Route $route @param string $name
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L202-L214
Phpillip/phpillip
src/Console/Command/BuildCommand.php
BuildCommand.buildContentRoute
protected function buildContentRoute(Route $route, $name) { $contentType = $route->getContent(); $contents = $this->app['content_repository']->listContents($contentType); $this->logger->log(sprintf( 'Building route <comment>%s</comment> for <info>%s</info> <comment>%s(s)</comment>', $name, count($contents), $route->getContent() )); $this->logger->getProgress(count($contents)); $this->logger->start(); foreach ($contents as $content) { $this->builder->build($route, $name, [$contentType => $content]); $this->logger->advance(); } $this->logger->finish(); }
php
protected function buildContentRoute(Route $route, $name) { $contentType = $route->getContent(); $contents = $this->app['content_repository']->listContents($contentType); $this->logger->log(sprintf( 'Building route <comment>%s</comment> for <info>%s</info> <comment>%s(s)</comment>', $name, count($contents), $route->getContent() )); $this->logger->getProgress(count($contents)); $this->logger->start(); foreach ($contents as $content) { $this->builder->build($route, $name, [$contentType => $content]); $this->logger->advance(); } $this->logger->finish(); }
Build content route @param Route $route @param string $name
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L222-L242
Phpillip/phpillip
src/Console/Command/BuildCommand.php
BuildCommand.buildSitemap
protected function buildSitemap(Sitemap $sitemap) { $content = $this->app['twig']->render('@phpillip/sitemap.xml.twig', ['sitemap' => $sitemap]); $this->builder->write('/', $content, 'xml', 'sitemap'); }
php
protected function buildSitemap(Sitemap $sitemap) { $content = $this->app['twig']->render('@phpillip/sitemap.xml.twig', ['sitemap' => $sitemap]); $this->builder->write('/', $content, 'xml', 'sitemap'); }
Build sitemap xml file from Sitemap @param Sitemap $sitemap
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Command/BuildCommand.php#L249-L253
open-orchestra/open-orchestra-display-bundle
DisplayBundle/BBcode/InternalLinkDefinition.php
InternalLinkDefinition.generateHtml
protected function generateHtml(BBcodeElementNodeInterface $el, $preview = false) { $children = $el->getChildren(); $option = $el->getAttribute(); if ($preview) { return $this->templating->render( 'OpenOrchestraDisplayBundle::BBcode/link.html.twig', array( 'href' => '#', 'options' => html_entity_decode($option['link']), 'text' => $children[0]->getAsBBCode(), ) ); } $parameters = json_decode(html_entity_decode($option['link']), true); $uri = '#'; try { $linkName = $this->nodeManager->getRouteDocumentName($parameters); try { $routeCompileParameters = array(); if (array_key_exists('wildcard', $parameters)) { foreach ($parameters['wildcard'] as $name => $value) { $routeCompileParameters[$name] = urlencode($value); } } $uri = $this->urlGenerator->generate($linkName, $routeCompileParameters, UrlGeneratorInterface::ABSOLUTE_PATH).(array_key_exists('query', $parameters) ? $parameters['query'] : ''); } catch(RouteNotFoundException $e) { } } catch (NodeNotFoundException $e) { } return $this->templating->render( 'OpenOrchestraDisplayBundle::BBcode/link.html.twig', array( 'href' => $uri, 'options' => '', 'text' => $children[0]->getAsBBCode(), ) ); }
php
protected function generateHtml(BBcodeElementNodeInterface $el, $preview = false) { $children = $el->getChildren(); $option = $el->getAttribute(); if ($preview) { return $this->templating->render( 'OpenOrchestraDisplayBundle::BBcode/link.html.twig', array( 'href' => '#', 'options' => html_entity_decode($option['link']), 'text' => $children[0]->getAsBBCode(), ) ); } $parameters = json_decode(html_entity_decode($option['link']), true); $uri = '#'; try { $linkName = $this->nodeManager->getRouteDocumentName($parameters); try { $routeCompileParameters = array(); if (array_key_exists('wildcard', $parameters)) { foreach ($parameters['wildcard'] as $name => $value) { $routeCompileParameters[$name] = urlencode($value); } } $uri = $this->urlGenerator->generate($linkName, $routeCompileParameters, UrlGeneratorInterface::ABSOLUTE_PATH).(array_key_exists('query', $parameters) ? $parameters['query'] : ''); } catch(RouteNotFoundException $e) { } } catch (NodeNotFoundException $e) { } return $this->templating->render( 'OpenOrchestraDisplayBundle::BBcode/link.html.twig', array( 'href' => $uri, 'options' => '', 'text' => $children[0]->getAsBBCode(), ) ); }
@param BBcodeElementNodeInterface $el @param bool $preview @return string
https://github.com/open-orchestra/open-orchestra-display-bundle/blob/0e59e8686dac2d8408b57b63b975b4e5a1aa9472/DisplayBundle/BBcode/InternalLinkDefinition.php#L71-L110
Boolive/Core
functions/F.php
F.parse
static function parse($text, $vars=[], $tpl_left = '{', $tpl_right = '}', $filter = FILTER_SANITIZE_SPECIAL_CHARS) { if ($filter) $vars = filter_var_array($vars, $filter); // По циклу проходимся по всем переменным заменяя значения в {} на значения в массиве if (is_array($vars)){ foreach ($vars as $key => $value){ if (is_scalar($value)) $text = str_replace($tpl_left.$key.$tpl_right, $value, $text); } } return $text; }
php
static function parse($text, $vars=[], $tpl_left = '{', $tpl_right = '}', $filter = FILTER_SANITIZE_SPECIAL_CHARS) { if ($filter) $vars = filter_var_array($vars, $filter); // По циклу проходимся по всем переменным заменяя значения в {} на значения в массиве if (is_array($vars)){ foreach ($vars as $key => $value){ if (is_scalar($value)) $text = str_replace($tpl_left.$key.$tpl_right, $value, $text); } } return $text; }
Парсер. Вставка в шаблон значений @param string $text Шаблон текста @param array $vars Массив значений для вставки в шаблон @param string $tpl_left @param string $tpl_right @param int $filter @return string Подготовленный текст
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L24-L34
Boolive/Core
functions/F.php
F.arrayMergeRecursive
static function arrayMergeRecursive() { $params = func_get_args(); $return = array_shift($params); foreach ($params as $array){ foreach ($array as $key => $value){ if (isset($return[$key]) && is_array($value) && is_array($return[$key])){ $return[$key] = self::arrayMergeRecursive($return[$key], $value); }else{ $return[$key] = $value; } } } return $return; }
php
static function arrayMergeRecursive() { $params = func_get_args(); $return = array_shift($params); foreach ($params as $array){ foreach ($array as $key => $value){ if (isset($return[$key]) && is_array($value) && is_array($return[$key])){ $return[$key] = self::arrayMergeRecursive($return[$key], $value); }else{ $return[$key] = $value; } } } return $return; }
Рекурсивное объединение массива с учетом числовых ключей @param array @return array
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L41-L55
Boolive/Core
functions/F.php
F.explode
static function explode($delim, $str, $lim = 1) { if ($lim > -2) return explode($delim, $str, abs($lim)); $lim = -$lim; $out = explode($delim, $str); if ($lim >= sizeof($out)) return $out; $out = array_chunk($out, sizeof($out) - $lim + 1); return array_merge(array(implode($delim, $out[0])), $out[1]); }
php
static function explode($delim, $str, $lim = 1) { if ($lim > -2) return explode($delim, $str, abs($lim)); $lim = -$lim; $out = explode($delim, $str); if ($lim >= sizeof($out)) return $out; $out = array_chunk($out, sizeof($out) - $lim + 1); return array_merge(array(implode($delim, $out[0])), $out[1]); }
Разрезание строки на одномерный массив по разделительной строке. Если $lim отрицателен, то разрезание происходит с конца строки @param string$delim Разделительная строка @param string$str Строка, которую нужно разрезать @param int $lim Максимальное количество частей @return array
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L65-L73
Boolive/Core
functions/F.php
F.splitRight
static function splitRight($delim, $str, $single = false) { if ($single){ $delim_length = mb_strlen($delim); $pos = false; $tmp_str = $str; if ($delim_length && mb_strlen($str) >= $delim_length){ do{ $pos = mb_strrpos($tmp_str, $delim); $repeated = false; // Не повторяется ли символ далее. Проверяем, так как нужно найти одиночный фрагмент while ($pos!==false && ($next = mb_strrpos($tmp_str = mb_substr($tmp_str, 0, $pos+$delim_length-1), $delim)) >= $pos-$delim_length && $next!==false){ $pos = $next; $repeated = true; } if ($repeated){ $pos = false; } }while ($repeated && $tmp_str); } }else{ $pos = mb_strrpos($str, $delim); } if ($pos === false) return array(null, $str ); return array(mb_substr($str, 0, $pos), mb_substr($str, $pos+mb_strlen($delim))); }
php
static function splitRight($delim, $str, $single = false) { if ($single){ $delim_length = mb_strlen($delim); $pos = false; $tmp_str = $str; if ($delim_length && mb_strlen($str) >= $delim_length){ do{ $pos = mb_strrpos($tmp_str, $delim); $repeated = false; // Не повторяется ли символ далее. Проверяем, так как нужно найти одиночный фрагмент while ($pos!==false && ($next = mb_strrpos($tmp_str = mb_substr($tmp_str, 0, $pos+$delim_length-1), $delim)) >= $pos-$delim_length && $next!==false){ $pos = $next; $repeated = true; } if ($repeated){ $pos = false; } }while ($repeated && $tmp_str); } }else{ $pos = mb_strrpos($str, $delim); } if ($pos === false) return array(null, $str ); return array(mb_substr($str, 0, $pos), mb_substr($str, $pos+mb_strlen($delim))); }
Разделение строки на две части используя строку-разделитель Поиск разделителя выполняется с конца @param string $delim Разделитель @param string $str Строка, которая делится @param bool $single Если в строке встречаются подряд идущие символы-разделители, то не считать их разделителями. @return array Массив строк. Если разделитель не найден, то первая строка = null, вторая = $str
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L83-L108
Boolive/Core
functions/F.php
F.implodeRecursive
static function implodeRecursive($glue, $pieces) { $items = []; foreach ($pieces as $item){ if (is_array($item)){ $items[] = self::implodeRecursive($glue, $item); }else{ $items[] = $item; } } return implode($glue, $items); }
php
static function implodeRecursive($glue, $pieces) { $items = []; foreach ($pieces as $item){ if (is_array($item)){ $items[] = self::implodeRecursive($glue, $item); }else{ $items[] = $item; } } return implode($glue, $items); }
Объединение элементов массива в строку Работает с многомерныыми массивами @param string $glue Соединительная строка @param array $pieces Массив @return string
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L117-L128
Boolive/Core
functions/F.php
F.isArrayMatch
static function isArrayMatch($source, $mask) { if (!is_array($source) || !is_array($mask)){ return false; } foreach ($mask as $key => $value){ if (!isset($source[$key])){ return false; }else if (is_array($value)){ if (is_array($source[$key])){ return self::isArrayMatch($value, $source[$key]); }else{ return false; } }else if ($source[$key] != $value){ return false; } } return true; }
php
static function isArrayMatch($source, $mask) { if (!is_array($source) || !is_array($mask)){ return false; } foreach ($mask as $key => $value){ if (!isset($source[$key])){ return false; }else if (is_array($value)){ if (is_array($source[$key])){ return self::isArrayMatch($value, $source[$key]); }else{ return false; } }else if ($source[$key] != $value){ return false; } } return true; }
Проверка совпадения массивов Если элементы массива $mask имеются в $source и их значения равны, то массивы совпадают, при этом в массиве $source могут содержаться элементы, которых нет в $mask @param array $source Проверяемый массив @param array $mask Массив-маска @return bool
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L138-L159
Boolive/Core
functions/F.php
F.ord
static function ord($chr) { $ord0 = ord($chr); if ($ord0 >= 0 && $ord0 <= 127){ return $ord0; } if (!isset($chr{1})){ trigger_error('Short sequence - at least 2 bytes expected, only 1 seen'); return FALSE; } $ord1 = ord($chr{1}); if ($ord0 >= 192 && $ord0 <= 223){ return ( $ord0 - 192 ) * 64 + ( $ord1 - 128 ); } if (!isset($chr{2})){ trigger_error('Short sequence - at least 3 bytes expected, only 2 seen'); return FALSE; } $ord2 = ord($chr{2}); if ($ord0 >= 224 && $ord0 <= 239){ return ($ord0 - 224) * 4096 + ($ord1 - 128) * 64 + ($ord2 - 128); } if (!isset($chr{3})){ trigger_error('Short sequence - at least 4 bytes expected, only 3 seen'); return FALSE; } $ord3 = ord($chr{3}); if ($ord0 >= 240 && $ord0 <= 247){ return ($ord0 - 240) * 262144 + ($ord1 - 128) * 4096 + ($ord2 - 128) * 64 + ($ord3 - 128); } if (!isset($chr{4})){ trigger_error('Short sequence - at least 5 bytes expected, only 4 seen'); return FALSE; } $ord4 = ord($chr{4}); if ($ord0 >= 248 && $ord0 <= 251){ return ($ord0 - 248) * 16777216 + ($ord1 - 128) * 262144 + ($ord2 - 128) * 4096 + ($ord3 - 128) * 64 + ($ord4 - 128); } if (!isset($chr{5})){ trigger_error('Short sequence - at least 6 bytes expected, only 5 seen'); return FALSE; } if ($ord0 >= 252 && $ord0 <= 253){ return ($ord0 - 252) * 1073741824 + ($ord1 - 128) * 16777216 + ($ord2 - 128) * 262144 + ($ord3 - 128) * 4096 + ($ord4 - 128) * 64 + (ord($chr{5}) - 128); } if ($ord0 >= 254 && $ord0 <= 255){ trigger_error('Invalid UTF-8 with surrogate ordinal '.$ord0); return FALSE; } return null; }
php
static function ord($chr) { $ord0 = ord($chr); if ($ord0 >= 0 && $ord0 <= 127){ return $ord0; } if (!isset($chr{1})){ trigger_error('Short sequence - at least 2 bytes expected, only 1 seen'); return FALSE; } $ord1 = ord($chr{1}); if ($ord0 >= 192 && $ord0 <= 223){ return ( $ord0 - 192 ) * 64 + ( $ord1 - 128 ); } if (!isset($chr{2})){ trigger_error('Short sequence - at least 3 bytes expected, only 2 seen'); return FALSE; } $ord2 = ord($chr{2}); if ($ord0 >= 224 && $ord0 <= 239){ return ($ord0 - 224) * 4096 + ($ord1 - 128) * 64 + ($ord2 - 128); } if (!isset($chr{3})){ trigger_error('Short sequence - at least 4 bytes expected, only 3 seen'); return FALSE; } $ord3 = ord($chr{3}); if ($ord0 >= 240 && $ord0 <= 247){ return ($ord0 - 240) * 262144 + ($ord1 - 128) * 4096 + ($ord2 - 128) * 64 + ($ord3 - 128); } if (!isset($chr{4})){ trigger_error('Short sequence - at least 5 bytes expected, only 4 seen'); return FALSE; } $ord4 = ord($chr{4}); if ($ord0 >= 248 && $ord0 <= 251){ return ($ord0 - 248) * 16777216 + ($ord1 - 128) * 262144 + ($ord2 - 128) * 4096 + ($ord3 - 128) * 64 + ($ord4 - 128); } if (!isset($chr{5})){ trigger_error('Short sequence - at least 6 bytes expected, only 5 seen'); return FALSE; } if ($ord0 >= 252 && $ord0 <= 253){ return ($ord0 - 252) * 1073741824 + ($ord1 - 128) * 16777216 + ($ord2 - 128) * 262144 + ($ord3 - 128) * 4096 + ($ord4 - 128) * 64 + (ord($chr{5}) - 128); } if ($ord0 >= 254 && $ord0 <= 255){ trigger_error('Invalid UTF-8 with surrogate ordinal '.$ord0); return FALSE; } return null; }
Код символа в UTF-8 строке @param string $chr символ @return int
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L167-L217
Boolive/Core
functions/F.php
F.translit
static function translit($string) { if (!isset(self::$translit_table)){ self::$translit_table = array( 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Ж' => 'ZH', 'З' => 'Z', 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', 'Ш' => 'SH', 'Щ' => 'CSH', 'Ь' => '', 'Ы' => 'Y', 'Ъ' => '', 'Э' => 'E', 'Ю' => 'YU', 'Я' => 'YA', 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'csh', 'ь' => '', 'ы' => 'y', 'ъ' => '', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', ); } return @iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', str_replace(array_keys(self::$translit_table), array_values(self::$translit_table), $string)); }
php
static function translit($string) { if (!isset(self::$translit_table)){ self::$translit_table = array( 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Ж' => 'ZH', 'З' => 'Z', 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', 'Ш' => 'SH', 'Щ' => 'CSH', 'Ь' => '', 'Ы' => 'Y', 'Ъ' => '', 'Э' => 'E', 'Ю' => 'YU', 'Я' => 'YA', 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'csh', 'ь' => '', 'ы' => 'y', 'ъ' => '', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', ); } return @iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', str_replace(array_keys(self::$translit_table), array_values(self::$translit_table), $string)); }
Транслит с русского в английский @param $string @return string
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L224-L245
Boolive/Core
functions/F.php
F.special_unicode_to_utf8
static function special_unicode_to_utf8($str) { $str = preg_replace('#\\\/#', '/', $str); return preg_replace_callback("/\\\u([[:xdigit:]]{4})/i", function($matches){ $ewchar = $matches[1]; $binwchar = hexdec($ewchar); $wchar = chr(($binwchar >> 8) & 0xFF) . chr(($binwchar) & 0xFF); return iconv("unicodebig", "utf-8", $wchar); }, $str); }
php
static function special_unicode_to_utf8($str) { $str = preg_replace('#\\\/#', '/', $str); return preg_replace_callback("/\\\u([[:xdigit:]]{4})/i", function($matches){ $ewchar = $matches[1]; $binwchar = hexdec($ewchar); $wchar = chr(($binwchar >> 8) & 0xFF) . chr(($binwchar) & 0xFF); return iconv("unicodebig", "utf-8", $wchar); }, $str); }
Декодирование unicode-заменители в символы @param $str @return mixed
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L262-L271
Boolive/Core
functions/F.php
F.toJSON
static function toJSON($value, $format = true) { if (version_compare(PHP_VERSION, '5.4.0') >= 0) { $f = JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE; if ($format) $f = $f|JSON_PRETTY_PRINT; return json_encode($value, $f); }else{ return F::special_unicode_to_utf8(json_encode($value)); } }
php
static function toJSON($value, $format = true) { if (version_compare(PHP_VERSION, '5.4.0') >= 0) { $f = JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE; if ($format) $f = $f|JSON_PRETTY_PRINT; return json_encode($value, $f); }else{ return F::special_unicode_to_utf8(json_encode($value)); } }
Ковертирование в строку JSON формата @param mixed $value @param bool $format @return mixed|string
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L279-L288
Boolive/Core
functions/F.php
F.arrayToCode
static function arrayToCode(array $arrray, array $syntax, $indent = ' ', &$indentLevel = 1) { $result = ""; $ia_accos = F::isAssoc($arrray); foreach ($arrray as $key => $value){ $result .= str_repeat($indent, $indentLevel); $result .= $ia_accos ? ((is_int($key) ? $key : "'" . addslashes($key) . "'") . ' => ') : ''; if (is_array($value)){ if ($value === []) { $result .= $syntax['open'] . $syntax['close'] . ",\n"; }else{ $indentLevel++; $result .= $syntax['open'] . "\n" . self::arrayToCode($value, $syntax, $indent, $indentLevel) . str_repeat($indent, --$indentLevel) . $syntax['close'] . ",\n"; } }else if (is_object($value) || is_string($value)){ $result .= var_export($value, true) . ",\n"; }else if (is_bool($value)){ $result .= ($value ? 'true' : 'false') . ",\n"; }else if ($value === null){ $result .= "null,\n"; }else{ $result .= $value . ",\n"; } } return $result; }
php
static function arrayToCode(array $arrray, array $syntax, $indent = ' ', &$indentLevel = 1) { $result = ""; $ia_accos = F::isAssoc($arrray); foreach ($arrray as $key => $value){ $result .= str_repeat($indent, $indentLevel); $result .= $ia_accos ? ((is_int($key) ? $key : "'" . addslashes($key) . "'") . ' => ') : ''; if (is_array($value)){ if ($value === []) { $result .= $syntax['open'] . $syntax['close'] . ",\n"; }else{ $indentLevel++; $result .= $syntax['open'] . "\n" . self::arrayToCode($value, $syntax, $indent, $indentLevel) . str_repeat($indent, --$indentLevel) . $syntax['close'] . ",\n"; } }else if (is_object($value) || is_string($value)){ $result .= var_export($value, true) . ",\n"; }else if (is_bool($value)){ $result .= ($value ? 'true' : 'false') . ",\n"; }else if ($value === null){ $result .= "null,\n"; }else{ $result .= $value . ",\n"; } } return $result; }
Рекрсивное преобразование массива в строку кода на php @param array $arrray @param array $syntax @param int $indentLevel @param string $indent @return string
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/functions/F.php#L379-L409
xqddd/Exceptions
src/InvalidArgumentException.php
InvalidArgumentException.setMessage
protected function setMessage() { $this->message = sprintf($this->message, $this->argumentName, $this->expected, $this->actual); }
php
protected function setMessage() { $this->message = sprintf($this->message, $this->argumentName, $this->expected, $this->actual); }
Set the additional parameters in the message
https://github.com/xqddd/Exceptions/blob/2ffdaa8e62d2ade8e599ed0cf01e5b1e2771fa7b/src/InvalidArgumentException.php#L107-L110
keeko/framework
src/security/AuthManager.php
AuthManager.authCookie
private function authCookie(Request $request) { if ($request->cookies->has(self::COOKIE_TOKEN_NAME)) { $token = $request->cookies->get(self::COOKIE_TOKEN_NAME); return $this->authToken($token); } return null; }
php
private function authCookie(Request $request) { if ($request->cookies->has(self::COOKIE_TOKEN_NAME)) { $token = $request->cookies->get(self::COOKIE_TOKEN_NAME); return $this->authToken($token); } return null; }
Authenticates a user by a token in a cookie @param Request $request @return Session|null
https://github.com/keeko/framework/blob/a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac/src/security/AuthManager.php#L71-L77
keeko/framework
src/security/AuthManager.php
AuthManager.authHeader
private function authHeader(Request $request) { if ($request->headers->has('authorization')) { $auth = $request->headers->get('authorization'); if (!empty($auth)) { list(, $token) = explode(' ', $auth); if (empty($token)) { return null; } return $this->authToken($token); } } return null; }
php
private function authHeader(Request $request) { if ($request->headers->has('authorization')) { $auth = $request->headers->get('authorization'); if (!empty($auth)) { list(, $token) = explode(' ', $auth); if (empty($token)) { return null; } return $this->authToken($token); } } return null; }
Authenticates a user by an authorization header @param Request $request @return Session|null
https://github.com/keeko/framework/blob/a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac/src/security/AuthManager.php#L85-L97
keeko/framework
src/security/AuthManager.php
AuthManager.authBasic
private function authBasic(Request $request) { $user = $this->findUser($request->getUser()); if ($user !== null && $this->verifyUser($user, $request->getPassword())) { $session = $this->findSession($user); if ($session === null) { $session = $this->createSession($user); } $this->authenticated = true; return $session; } return null; }
php
private function authBasic(Request $request) { $user = $this->findUser($request->getUser()); if ($user !== null && $this->verifyUser($user, $request->getPassword())) { $session = $this->findSession($user); if ($session === null) { $session = $this->createSession($user); } $this->authenticated = true; return $session; } return null; }
Authenticates a user by basic authentication @param Request $request @return Session|null
https://github.com/keeko/framework/blob/a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac/src/security/AuthManager.php#L115-L127
keeko/framework
src/security/AuthManager.php
AuthManager.login
public function login($login, $password) { $user = $this->findUser($login); if ($user) { $this->user = $user; $this->recognized = true; if ($this->verifyUser($user, $password)) { $this->authenticated = true; $session = $this->findSession($user); if ($session === null) { $session = $this->createSession($user); } $this->session = $session; return true; } } return false; }
php
public function login($login, $password) { $user = $this->findUser($login); if ($user) { $this->user = $user; $this->recognized = true; if ($this->verifyUser($user, $password)) { $this->authenticated = true; $session = $this->findSession($user); if ($session === null) { $session = $this->createSession($user); } $this->session = $session; return true; } } return false; }
TODO: Probably not the best location/method-name and response (throw an exception?) @param string $login @param string $password @return boolean
https://github.com/keeko/framework/blob/a2c5d76a4ab7bd658e81d88fb3c98eee115c06ac/src/security/AuthManager.php#L136-L157
liufee/cms-core
backend/components/AdminLog.php
AdminLog.delete
public static function delete($event) { $desc = '<br>'; foreach ($event->sender->getAttributes() as $name => $value) { $desc .= $event->sender->getAttributeLabel($name) . '(' . $name . ') => ' . $value . ',<br>'; } $desc = substr($desc, 0, -5); $model = new AdminLogModel(); $class = $event->sender->className(); $id_des = ''; if (isset($event->sender->id)) { $id_des = '{{%ID%}} ' . $event->sender->id; } $model->description = '{{%ADMIN_USER%}} [ ' . yii::$app->getUser()->getIdentity()->username . ' ] {{%BY%}} ' . $class . ' [ ' . $class::tableName() . ' ] ' . " {{%DELETED%}} {$id_des} {{%RECORD%}}: " . $desc; $model->route = Yii::$app->controller->id . '/' . Yii::$app->controller->action->id; $model->user_id = yii::$app->getUser()->id; $model->save(); }
php
public static function delete($event) { $desc = '<br>'; foreach ($event->sender->getAttributes() as $name => $value) { $desc .= $event->sender->getAttributeLabel($name) . '(' . $name . ') => ' . $value . ',<br>'; } $desc = substr($desc, 0, -5); $model = new AdminLogModel(); $class = $event->sender->className(); $id_des = ''; if (isset($event->sender->id)) { $id_des = '{{%ID%}} ' . $event->sender->id; } $model->description = '{{%ADMIN_USER%}} [ ' . yii::$app->getUser()->getIdentity()->username . ' ] {{%BY%}} ' . $class . ' [ ' . $class::tableName() . ' ] ' . " {{%DELETED%}} {$id_des} {{%RECORD%}}: " . $desc; $model->route = Yii::$app->controller->id . '/' . Yii::$app->controller->action->id; $model->user_id = yii::$app->getUser()->id; $model->save(); }
数据库删除保存日志 @param $event
https://github.com/liufee/cms-core/blob/440ee229e3b722d6088c57926d612b5f891b370d/backend/components/AdminLog.php#L76-L93
valu-digital/valuso
src/ValuSo/Queue/Job/ServiceJob.php
ServiceJob.setup
public function setup(CommandInterface $command, $identity) { if (!$identity) { throw new RuntimeException( 'Unable to initialize Job: identity is not available'); } $this->setContent([ 'context' => $command->getContext(), 'service' => $command->getName(), 'operation' => $command->getOperation(), 'params' => $command->getParams()->getArrayCopy(), 'identity' => $identity ]); }
php
public function setup(CommandInterface $command, $identity) { if (!$identity) { throw new RuntimeException( 'Unable to initialize Job: identity is not available'); } $this->setContent([ 'context' => $command->getContext(), 'service' => $command->getName(), 'operation' => $command->getOperation(), 'params' => $command->getParams()->getArrayCopy(), 'identity' => $identity ]); }
Setup ServiceJob @param CommandInterface $command @param ArrayAccess $identity @throws RuntimeException
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Queue/Job/ServiceJob.php#L28-L42
valu-digital/valuso
src/ValuSo/Queue/Job/ServiceJob.php
ServiceJob.execute
public function execute() { $command = $this->getCommand(); $broker = $this->getServiceBroker(); if (!$command->getIdentity()) { throw new RuntimeException( 'Unable to execute Job: identity is not available'); } $broker->dispatch($command); }
php
public function execute() { $command = $this->getCommand(); $broker = $this->getServiceBroker(); if (!$command->getIdentity()) { throw new RuntimeException( 'Unable to execute Job: identity is not available'); } $broker->dispatch($command); }
Execute job @throws RuntimeException
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Queue/Job/ServiceJob.php#L49-L60