repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
brick/reflection
src/ReflectionTools.php
ReflectionTools.getParameterTypes
public function getParameterTypes(\ReflectionParameter $parameter) : array { $name = $parameter->getName(); $function = $parameter->getDeclaringFunction(); $types = $this->getFunctionParameterTypes($function); return isset($types[$name]) ? $types[$name] : []; }
php
public function getParameterTypes(\ReflectionParameter $parameter) : array { $name = $parameter->getName(); $function = $parameter->getDeclaringFunction(); $types = $this->getFunctionParameterTypes($function); return isset($types[$name]) ? $types[$name] : []; }
[ "public", "function", "getParameterTypes", "(", "\\", "ReflectionParameter", "$", "parameter", ")", ":", "array", "{", "$", "name", "=", "$", "parameter", "->", "getName", "(", ")", ";", "$", "function", "=", "$", "parameter", "->", "getDeclaringFunction", "...
Returns the types documented on a parameter. @param \ReflectionParameter $parameter @return array
[ "Returns", "the", "types", "documented", "on", "a", "parameter", "." ]
4c1736b1ef0d27cf651c5f08c61751b379697d0b
https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ReflectionTools.php#L228-L235
train
brick/reflection
src/ReflectionTools.php
ReflectionTools.getPropertyTypes
public function getPropertyTypes(\ReflectionProperty $property) : array { $docComment = $property->getDocComment(); if ($docComment === false) { return []; } if (preg_match('/@var\s+(\S+)/', $docComment, $matches) !== 1) { return []; } return explode('|', $matches[1]); }
php
public function getPropertyTypes(\ReflectionProperty $property) : array { $docComment = $property->getDocComment(); if ($docComment === false) { return []; } if (preg_match('/@var\s+(\S+)/', $docComment, $matches) !== 1) { return []; } return explode('|', $matches[1]); }
[ "public", "function", "getPropertyTypes", "(", "\\", "ReflectionProperty", "$", "property", ")", ":", "array", "{", "$", "docComment", "=", "$", "property", "->", "getDocComment", "(", ")", ";", "if", "(", "$", "docComment", "===", "false", ")", "{", "retu...
Returns the types documented on a property. @param \ReflectionProperty $property @return array
[ "Returns", "the", "types", "documented", "on", "a", "property", "." ]
4c1736b1ef0d27cf651c5f08c61751b379697d0b
https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ReflectionTools.php#L244-L257
train
brick/reflection
src/ReflectionTools.php
ReflectionTools.getPropertyClass
public function getPropertyClass(\ReflectionProperty $property) : ?string { $types = $this->getPropertyTypes($property); if (count($types) === 1) { $type = $types[0]; if ($type[0] === '\\') { return substr($type, 1); } } return null; }
php
public function getPropertyClass(\ReflectionProperty $property) : ?string { $types = $this->getPropertyTypes($property); if (count($types) === 1) { $type = $types[0]; if ($type[0] === '\\') { return substr($type, 1); } } return null; }
[ "public", "function", "getPropertyClass", "(", "\\", "ReflectionProperty", "$", "property", ")", ":", "?", "string", "{", "$", "types", "=", "$", "this", "->", "getPropertyTypes", "(", "$", "property", ")", ";", "if", "(", "count", "(", "$", "types", ")"...
Returns the fully qualified class name documented for the given property. @param \ReflectionProperty $property @return string|null The class name, or null if not available.
[ "Returns", "the", "fully", "qualified", "class", "name", "documented", "for", "the", "given", "property", "." ]
4c1736b1ef0d27cf651c5f08c61751b379697d0b
https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ReflectionTools.php#L266-L279
train
brick/reflection
src/ReflectionTools.php
ReflectionTools.exportFunction
public function exportFunction(\ReflectionFunctionAbstract $function, int $excludeModifiers = 0) : string { $result = ''; if ($function instanceof \ReflectionMethod) { $modifiers = $function->getModifiers(); $modifiers &= ~ $excludeModifiers; foreach (\Reflection::getModifierNames($modifiers) as $modifier) { $result .= $modifier . ' '; } } $result .= 'function ' . $function->getShortName(); $result .= '(' . $this->exportFunctionParameters($function) . ')'; if (null !== $returnType = $function->getReturnType()) { $result .= ' : '; if ($returnType->allowsNull()) { $result .= '?'; } if (! $returnType->isBuiltin()) { $result .= '\\'; } $result .= $returnType->getName(); } return $result; }
php
public function exportFunction(\ReflectionFunctionAbstract $function, int $excludeModifiers = 0) : string { $result = ''; if ($function instanceof \ReflectionMethod) { $modifiers = $function->getModifiers(); $modifiers &= ~ $excludeModifiers; foreach (\Reflection::getModifierNames($modifiers) as $modifier) { $result .= $modifier . ' '; } } $result .= 'function ' . $function->getShortName(); $result .= '(' . $this->exportFunctionParameters($function) . ')'; if (null !== $returnType = $function->getReturnType()) { $result .= ' : '; if ($returnType->allowsNull()) { $result .= '?'; } if (! $returnType->isBuiltin()) { $result .= '\\'; } $result .= $returnType->getName(); } return $result; }
[ "public", "function", "exportFunction", "(", "\\", "ReflectionFunctionAbstract", "$", "function", ",", "int", "$", "excludeModifiers", "=", "0", ")", ":", "string", "{", "$", "result", "=", "''", ";", "if", "(", "$", "function", "instanceof", "\\", "Reflecti...
Exports the function signature. @param \ReflectionFunctionAbstract $function The function to export. @param int $excludeModifiers An optional bitmask of modifiers to exclude. @return string
[ "Exports", "the", "function", "signature", "." ]
4c1736b1ef0d27cf651c5f08c61751b379697d0b
https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ReflectionTools.php#L309-L340
train
brick/reflection
src/ReflectionTools.php
ReflectionTools.cache
private function cache(string $method, $object, callable $callback) { $hash = spl_object_hash($object); if (! isset($this->cache[$method][$hash])) { $this->cache[$method][$hash] = $callback(); } return $this->cache[$method][$hash]; }
php
private function cache(string $method, $object, callable $callback) { $hash = spl_object_hash($object); if (! isset($this->cache[$method][$hash])) { $this->cache[$method][$hash] = $callback(); } return $this->cache[$method][$hash]; }
[ "private", "function", "cache", "(", "string", "$", "method", ",", "$", "object", ",", "callable", "$", "callback", ")", "{", "$", "hash", "=", "spl_object_hash", "(", "$", "object", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "cache",...
Caches the output of a worker function. @param string $method The name of the calling method. @param object $object The object to use as the cache key. @param callable $callback The callback that does the actual work. @return mixed The callback return value, potentially cached.
[ "Caches", "the", "output", "of", "a", "worker", "function", "." ]
4c1736b1ef0d27cf651c5f08c61751b379697d0b
https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ReflectionTools.php#L399-L408
train
yajra/cms-core
src/Entities/Widget.php
Widget.getAssignmentAttribute
public function getAssignmentAttribute() { if (! $this->exists) { return static::ALL_PAGES; } $count = $this->menuPivot()->count(); if ($count === 0) { return static::NO_PAGES; } elseif ($count > 1) { return static::SELECTED_PAGES; } elseif ($count === 1) { $pivot = $this->menuPivot()->first(); if ($pivot->menu_id > 0) { return static::SELECTED_PAGES; } } return static::ALL_PAGES; }
php
public function getAssignmentAttribute() { if (! $this->exists) { return static::ALL_PAGES; } $count = $this->menuPivot()->count(); if ($count === 0) { return static::NO_PAGES; } elseif ($count > 1) { return static::SELECTED_PAGES; } elseif ($count === 1) { $pivot = $this->menuPivot()->first(); if ($pivot->menu_id > 0) { return static::SELECTED_PAGES; } } return static::ALL_PAGES; }
[ "public", "function", "getAssignmentAttribute", "(", ")", "{", "if", "(", "!", "$", "this", "->", "exists", ")", "{", "return", "static", "::", "ALL_PAGES", ";", "}", "$", "count", "=", "$", "this", "->", "menuPivot", "(", ")", "->", "count", "(", ")...
Get menu assignment attribute. @return int
[ "Get", "menu", "assignment", "attribute", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Widget.php#L148-L167
train
yajra/cms-core
src/Entities/Widget.php
Widget.menuPivot
public function menuPivot() { return $this->getConnection()->table('widget_menu') ->where('widget_id', $this->id) ->orWhere(function ($query) { $query->where('menu_id', 0) ->where('widget_id', $this->id); }); }
php
public function menuPivot() { return $this->getConnection()->table('widget_menu') ->where('widget_id', $this->id) ->orWhere(function ($query) { $query->where('menu_id', 0) ->where('widget_id', $this->id); }); }
[ "public", "function", "menuPivot", "(", ")", "{", "return", "$", "this", "->", "getConnection", "(", ")", "->", "table", "(", "'widget_menu'", ")", "->", "where", "(", "'widget_id'", ",", "$", "this", "->", "id", ")", "->", "orWhere", "(", "function", ...
Get related menus. @return \Illuminate\Database\Eloquent\Builder
[ "Get", "related", "menus", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Widget.php#L174-L182
train
yajra/cms-core
src/Entities/Widget.php
Widget.syncMenuAssignment
public function syncMenuAssignment($menu, $assignment) { switch ($assignment) { case static::ALL_PAGES: $this->menus()->sync([static::ALL_PAGES]); break; case static::NO_PAGES: $this->menus()->detach(); break; case static::SELECTED_PAGES: $this->menus()->sync($menu); break; } return $this; }
php
public function syncMenuAssignment($menu, $assignment) { switch ($assignment) { case static::ALL_PAGES: $this->menus()->sync([static::ALL_PAGES]); break; case static::NO_PAGES: $this->menus()->detach(); break; case static::SELECTED_PAGES: $this->menus()->sync($menu); break; } return $this; }
[ "public", "function", "syncMenuAssignment", "(", "$", "menu", ",", "$", "assignment", ")", "{", "switch", "(", "$", "assignment", ")", "{", "case", "static", "::", "ALL_PAGES", ":", "$", "this", "->", "menus", "(", ")", "->", "sync", "(", "[", "static"...
Sync widget menu assignment. @param array $menu @param int $assignment @return $this
[ "Sync", "widget", "menu", "assignment", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Widget.php#L191-L206
train
yajra/cms-core
src/Repositories/Extension/EloquentRepository.php
EloquentRepository.install
public function install($type, array $attributes) { $extension = new Extension; $extension->type = $type; $extension->name = $attributes['name']; if (isset($attributes['parameters'])) { $extension->parameters = $attributes['parameters']; } $extension->manifest = json_encode($attributes); $extension->save(); return $extension; }
php
public function install($type, array $attributes) { $extension = new Extension; $extension->type = $type; $extension->name = $attributes['name']; if (isset($attributes['parameters'])) { $extension->parameters = $attributes['parameters']; } $extension->manifest = json_encode($attributes); $extension->save(); return $extension; }
[ "public", "function", "install", "(", "$", "type", ",", "array", "$", "attributes", ")", "{", "$", "extension", "=", "new", "Extension", ";", "$", "extension", "->", "type", "=", "$", "type", ";", "$", "extension", "->", "name", "=", "$", "attributes",...
Install an extension. @param string $type @param array $attributes @return \Yajra\CMS\Entities\Extension
[ "Install", "an", "extension", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Repositories/Extension/EloquentRepository.php#L22-L34
train
yajra/cms-core
src/Repositories/Extension/EloquentRepository.php
EloquentRepository.uninstall
public function uninstall($id) { $extension = $this->getModel()->query()->findOrFail($id); // TODO: remove extension files. $extension->delete(); }
php
public function uninstall($id) { $extension = $this->getModel()->query()->findOrFail($id); // TODO: remove extension files. $extension->delete(); }
[ "public", "function", "uninstall", "(", "$", "id", ")", "{", "$", "extension", "=", "$", "this", "->", "getModel", "(", ")", "->", "query", "(", ")", "->", "findOrFail", "(", "$", "id", ")", ";", "// TODO: remove extension files.", "$", "extension", "->"...
Uninstall extension. @param int $id @throws \Exception
[ "Uninstall", "extension", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Repositories/Extension/EloquentRepository.php#L42-L47
train
yajra/cms-core
src/Repositories/Extension/EloquentRepository.php
EloquentRepository.registerManifest
public function registerManifest($path) { if (! File::exists($path)) { throw new \Exception('Extension manifest file does not exist! Path: ' . $path); } $manifest = File::get($path); $manifest = json_decode($manifest, true); $this->register($manifest); }
php
public function registerManifest($path) { if (! File::exists($path)) { throw new \Exception('Extension manifest file does not exist! Path: ' . $path); } $manifest = File::get($path); $manifest = json_decode($manifest, true); $this->register($manifest); }
[ "public", "function", "registerManifest", "(", "$", "path", ")", "{", "if", "(", "!", "File", "::", "exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Extension manifest file does not exist! Path: '", ".", "$", "path", ")", ...
Register an extension using manifest config file. @param string $path @throws \Exception @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
[ "Register", "an", "extension", "using", "manifest", "config", "file", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Repositories/Extension/EloquentRepository.php#L97-L106
train
eviweb/fuelphp-phpcs
Standards/FuelPHP/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
FuelPHP_Sniffs_WhiteSpace_ControlStructureSpacingSniff.isNextTokenAnException
protected function isNextTokenAnException($tokens, $ptr) { return in_array($tokens[($ptr + 1)]['code'], $this->exceptions) && $tokens[($ptr + 1)]['column'] - $tokens[($ptr)]['column'] == 1; }
php
protected function isNextTokenAnException($tokens, $ptr) { return in_array($tokens[($ptr + 1)]['code'], $this->exceptions) && $tokens[($ptr + 1)]['column'] - $tokens[($ptr)]['column'] == 1; }
[ "protected", "function", "isNextTokenAnException", "(", "$", "tokens", ",", "$", "ptr", ")", "{", "return", "in_array", "(", "$", "tokens", "[", "(", "$", "ptr", "+", "1", ")", "]", "[", "'code'", "]", ",", "$", "this", "->", "exceptions", ")", "&&",...
check whether the next token of the current one is an exception @param array $tokens list of tokens @param integer $ptr current token index @return boolean returns true if the next token is an exception or false
[ "check", "whether", "the", "next", "token", "of", "the", "current", "one", "is", "an", "exception" ]
6042b3ad72e4b1250e5bc05aa9c22bf6b641d1be
https://github.com/eviweb/fuelphp-phpcs/blob/6042b3ad72e4b1250e5bc05aa9c22bf6b641d1be/Standards/FuelPHP/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php#L227-L231
train
umbrellaTech/ya-boleto-php
src/Bancos/BancoBrasil/Convenio.php
Convenio.ajustarNossoNumero
public function ajustarNossoNumero(ArrayObject $data) { $carteira = $this->carteira; switch (strlen($this->convenio)) { case 6: if (!$carteira instanceof Carteira21) { $data['NossoNumero'] = $this->convenio . $data['NossoNumero']; } break; case 4: case 7: $data['NossoNumero'] = $this->convenio . $data['NossoNumero']; break; default: throw new \LogicException('O codigo do convenio precisa ter 4, 6 ou 7 digitos!'); } return $data; }
php
public function ajustarNossoNumero(ArrayObject $data) { $carteira = $this->carteira; switch (strlen($this->convenio)) { case 6: if (!$carteira instanceof Carteira21) { $data['NossoNumero'] = $this->convenio . $data['NossoNumero']; } break; case 4: case 7: $data['NossoNumero'] = $this->convenio . $data['NossoNumero']; break; default: throw new \LogicException('O codigo do convenio precisa ter 4, 6 ou 7 digitos!'); } return $data; }
[ "public", "function", "ajustarNossoNumero", "(", "ArrayObject", "$", "data", ")", "{", "$", "carteira", "=", "$", "this", "->", "carteira", ";", "switch", "(", "strlen", "(", "$", "this", "->", "convenio", ")", ")", "{", "case", "6", ":", "if", "(", ...
Ajusta o Nosso Numero antes de seta-lo no objeto Convenio. @param ArrayObject $data @return ArrayObject
[ "Ajusta", "o", "Nosso", "Numero", "antes", "de", "seta", "-", "lo", "no", "objeto", "Convenio", "." ]
3d2e0f2db63e380eaa6db66d1103294705197118
https://github.com/umbrellaTech/ya-boleto-php/blob/3d2e0f2db63e380eaa6db66d1103294705197118/src/Bancos/BancoBrasil/Convenio.php#L88-L107
train
neos/redirecthandler
Classes/RedirectService.php
RedirectService.buildResponseIfApplicable
public function buildResponseIfApplicable(Request $httpRequest) { try { $redirect = $this->redirectStorage->getOneBySourceUriPathAndHost($httpRequest->getRelativePath(), $httpRequest->getBaseUri()->getHost()); if ($redirect === null) { return null; } if (isset($this->featureSwitch['hitCounter']) && $this->featureSwitch['hitCounter'] === true) { $this->redirectStorage->incrementHitCount($redirect); } return $this->buildResponse($httpRequest, $redirect); } catch (\Exception $exception) { // Throw exception if it's a \Neos\RedirectHandler\Exception (used for custom exception handling) if ($exception instanceof Exception) { throw $exception; } // skip triggering the redirect if there was an error accessing the database (wrong credentials, ...) return null; } }
php
public function buildResponseIfApplicable(Request $httpRequest) { try { $redirect = $this->redirectStorage->getOneBySourceUriPathAndHost($httpRequest->getRelativePath(), $httpRequest->getBaseUri()->getHost()); if ($redirect === null) { return null; } if (isset($this->featureSwitch['hitCounter']) && $this->featureSwitch['hitCounter'] === true) { $this->redirectStorage->incrementHitCount($redirect); } return $this->buildResponse($httpRequest, $redirect); } catch (\Exception $exception) { // Throw exception if it's a \Neos\RedirectHandler\Exception (used for custom exception handling) if ($exception instanceof Exception) { throw $exception; } // skip triggering the redirect if there was an error accessing the database (wrong credentials, ...) return null; } }
[ "public", "function", "buildResponseIfApplicable", "(", "Request", "$", "httpRequest", ")", "{", "try", "{", "$", "redirect", "=", "$", "this", "->", "redirectStorage", "->", "getOneBySourceUriPathAndHost", "(", "$", "httpRequest", "->", "getRelativePath", "(", ")...
Searches for a matching redirect for the given HTTP response @param Request $httpRequest @return Response|null @api
[ "Searches", "for", "a", "matching", "redirect", "for", "the", "given", "HTTP", "response" ]
351effbe2d184e82cc1dc65a5e409d092ba56194
https://github.com/neos/redirecthandler/blob/351effbe2d184e82cc1dc65a5e409d092ba56194/Classes/RedirectService.php#L56-L75
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.setServer
public function setServer($host, $port = 0) { assert(is_string($host)); if ($host[0] == '/') { $this->_path = 'unix://'.$host; return; } if (substr($host, 0, 7) == 'unix://') { $this->_path = $host; return; } $this->_host = $host; if (is_int($port)) { if ($port) { $this->_port = $port; } } $this->_path = ''; return $this; }
php
public function setServer($host, $port = 0) { assert(is_string($host)); if ($host[0] == '/') { $this->_path = 'unix://'.$host; return; } if (substr($host, 0, 7) == 'unix://') { $this->_path = $host; return; } $this->_host = $host; if (is_int($port)) { if ($port) { $this->_port = $port; } } $this->_path = ''; return $this; }
[ "public", "function", "setServer", "(", "$", "host", ",", "$", "port", "=", "0", ")", "{", "assert", "(", "is_string", "(", "$", "host", ")", ")", ";", "if", "(", "$", "host", "[", "0", "]", "==", "'/'", ")", "{", "$", "this", "->", "_path", ...
Sets the searchd host name and port. @param $host @param int $port @return SphinxClient
[ "Sets", "the", "searchd", "host", "name", "and", "port", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L253-L276
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.setLimits
public function setLimits($offset, $limit, $max = 0, $cutoff = 0) { assert(is_int($offset)); assert(is_int($limit)); assert(is_int($max)); assert(is_int($cutoff)); assert($offset >= 0); assert($limit > 0); assert($max >= 0); assert($cutoff >= 0); $this->_offset = $offset; $this->_limit = $limit; if ($max > 0) { $this->_maxmatches = $max; } if ($cutoff > 0) { $this->_cutoff = $cutoff; } return $this; }
php
public function setLimits($offset, $limit, $max = 0, $cutoff = 0) { assert(is_int($offset)); assert(is_int($limit)); assert(is_int($max)); assert(is_int($cutoff)); assert($offset >= 0); assert($limit > 0); assert($max >= 0); assert($cutoff >= 0); $this->_offset = $offset; $this->_limit = $limit; if ($max > 0) { $this->_maxmatches = $max; } if ($cutoff > 0) { $this->_cutoff = $cutoff; } return $this; }
[ "public", "function", "setLimits", "(", "$", "offset", ",", "$", "limit", ",", "$", "max", "=", "0", ",", "$", "cutoff", "=", "0", ")", "{", "assert", "(", "is_int", "(", "$", "offset", ")", ")", ";", "assert", "(", "is_int", "(", "$", "limit", ...
Sets an offset and count into result set, and optionally set max-matches and cutoff limits. @param $offset @param $limit @param int $max @param int $cutoff @return SphinxClient
[ "Sets", "an", "offset", "and", "count", "into", "result", "set", "and", "optionally", "set", "max", "-", "matches", "and", "cutoff", "limits", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L304-L325
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.setMaxQueryTime
public function setMaxQueryTime($max) { assert(is_int($max)); assert($max >= 0); $this->_maxquerytime = $max; return $this; }
php
public function setMaxQueryTime($max) { assert(is_int($max)); assert($max >= 0); $this->_maxquerytime = $max; return $this; }
[ "public", "function", "setMaxQueryTime", "(", "$", "max", ")", "{", "assert", "(", "is_int", "(", "$", "max", ")", ")", ";", "assert", "(", "$", "max", ">=", "0", ")", ";", "$", "this", "->", "_maxquerytime", "=", "$", "max", ";", "return", "$", ...
Set maximum query time, in milliseconds, per-index.Integer, 0 means "do not limit". @param $max @return SphinxClient
[ "Set", "maximum", "query", "time", "in", "milliseconds", "per", "-", "index", ".", "Integer", "0", "means", "do", "not", "limit", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L334-L341
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.setMatchMode
public function setMatchMode($mode) { assert($mode == SPH_MATCH_ALL || $mode == SPH_MATCH_ANY || $mode == SPH_MATCH_PHRASE || $mode == SPH_MATCH_BOOLEAN || $mode == SPH_MATCH_EXTENDED || $mode == SPH_MATCH_FULLSCAN || $mode == SPH_MATCH_EXTENDED2); $this->_mode = $mode; return $this; }
php
public function setMatchMode($mode) { assert($mode == SPH_MATCH_ALL || $mode == SPH_MATCH_ANY || $mode == SPH_MATCH_PHRASE || $mode == SPH_MATCH_BOOLEAN || $mode == SPH_MATCH_EXTENDED || $mode == SPH_MATCH_FULLSCAN || $mode == SPH_MATCH_EXTENDED2); $this->_mode = $mode; return $this; }
[ "public", "function", "setMatchMode", "(", "$", "mode", ")", "{", "assert", "(", "$", "mode", "==", "SPH_MATCH_ALL", "||", "$", "mode", "==", "SPH_MATCH_ANY", "||", "$", "mode", "==", "SPH_MATCH_PHRASE", "||", "$", "mode", "==", "SPH_MATCH_BOOLEAN", "||", ...
Sets a matching mode. @param $mode @return SphinxClient
[ "Sets", "a", "matching", "mode", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L350-L362
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.setRankingMode
public function setRankingMode($ranker, $rankexpr = '') { assert($ranker === 0 || $ranker >= 1 && $ranker < SPH_RANK_TOTAL); assert(is_string($rankexpr)); $this->_ranker = $ranker; $this->_rankexpr = $rankexpr; return $this; }
php
public function setRankingMode($ranker, $rankexpr = '') { assert($ranker === 0 || $ranker >= 1 && $ranker < SPH_RANK_TOTAL); assert(is_string($rankexpr)); $this->_ranker = $ranker; $this->_rankexpr = $rankexpr; return $this; }
[ "public", "function", "setRankingMode", "(", "$", "ranker", ",", "$", "rankexpr", "=", "''", ")", "{", "assert", "(", "$", "ranker", "===", "0", "||", "$", "ranker", ">=", "1", "&&", "$", "ranker", "<", "SPH_RANK_TOTAL", ")", ";", "assert", "(", "is_...
Sets ranking mode. @param $ranker @param string $rankexpr @return SphinxClient
[ "Sets", "ranking", "mode", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L372-L380
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.setIndexWeights
public function setIndexWeights(array $weights) { assert(is_array($weights)); foreach ($weights as $index => $weight) { assert(is_string($index)); assert(is_int($weight)); } $this->_indexweights = $weights; return $this; }
php
public function setIndexWeights(array $weights) { assert(is_array($weights)); foreach ($weights as $index => $weight) { assert(is_string($index)); assert(is_int($weight)); } $this->_indexweights = $weights; return $this; }
[ "public", "function", "setIndexWeights", "(", "array", "$", "weights", ")", "{", "assert", "(", "is_array", "(", "$", "weights", ")", ")", ";", "foreach", "(", "$", "weights", "as", "$", "index", "=>", "$", "weight", ")", "{", "assert", "(", "is_string...
Bind per-index weights by name. @param array $weights @return SphinxClient
[ "Bind", "per", "-", "index", "weights", "by", "name", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L450-L460
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.setRetries
public function setRetries($count, $delay = 0) { assert(is_int($count) && $count >= 0); assert(is_int($delay) && $delay >= 0); $this->_retrycount = $count; $this->_retrydelay = $delay; return $this; }
php
public function setRetries($count, $delay = 0) { assert(is_int($count) && $count >= 0); assert(is_int($delay) && $delay >= 0); $this->_retrycount = $count; $this->_retrydelay = $delay; return $this; }
[ "public", "function", "setRetries", "(", "$", "count", ",", "$", "delay", "=", "0", ")", "{", "assert", "(", "is_int", "(", "$", "count", ")", "&&", "$", "count", ">=", "0", ")", ";", "assert", "(", "is_int", "(", "$", "delay", ")", "&&", "$", ...
Sets distributed retries count and delay values. @param $count @param int $delay @return SphinxClient
[ "Sets", "distributed", "retries", "count", "and", "delay", "values", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L623-L631
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.query
public function query($query, $index = '*', $comment = '') { assert(empty($this->_reqs)); $this->AddQuery($query, $index, $comment); $results = $this->RunQueries(); $this->_reqs = array(); // just in case it failed too early if (!is_array($results)) { return false; } // probably network error; error message should be already filled $this->_error = $results[0]['error']; $this->_warning = $results[0]['warning']; if ($results[0]['status'] == SEARCHD_ERROR) { return false; } else { return $results[0]; } }
php
public function query($query, $index = '*', $comment = '') { assert(empty($this->_reqs)); $this->AddQuery($query, $index, $comment); $results = $this->RunQueries(); $this->_reqs = array(); // just in case it failed too early if (!is_array($results)) { return false; } // probably network error; error message should be already filled $this->_error = $results[0]['error']; $this->_warning = $results[0]['warning']; if ($results[0]['status'] == SEARCHD_ERROR) { return false; } else { return $results[0]; } }
[ "public", "function", "query", "(", "$", "query", ",", "$", "index", "=", "'*'", ",", "$", "comment", "=", "''", ")", "{", "assert", "(", "empty", "(", "$", "this", "->", "_reqs", ")", ")", ";", "$", "this", "->", "AddQuery", "(", "$", "query", ...
Connects to searchd server, run given search query through given indexes, and returns the search results. @param $query @param string $index @param string $comment @return bool
[ "Connects", "to", "searchd", "server", "run", "given", "search", "query", "through", "given", "indexes", "and", "returns", "the", "search", "results", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L734-L753
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.runQueries
public function runQueries() { if (empty($this->_reqs)) { $this->_error = 'no queries defined, issue AddQuery() first'; return false; } // mbstring workaround $this->_MBPush(); if (!($fp = $this->_Connect())) { $this->_MBPop(); return false; } // send query, get response $nreqs = count($this->_reqs); $req = implode('', $this->_reqs); $len = 8 + strlen($req); $req = pack('nnNNN', SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs).$req; // add header if (!($this->_Send($fp, $req, $len + 8)) || !($response = $this->_GetResponse($fp, VER_COMMAND_SEARCH)) ) { $this->_MBPop(); return false; } // query sent ok; we can reset reqs now $this->_reqs = array(); // parse and return response return $this->_ParseSearchResponse($response, $nreqs); }
php
public function runQueries() { if (empty($this->_reqs)) { $this->_error = 'no queries defined, issue AddQuery() first'; return false; } // mbstring workaround $this->_MBPush(); if (!($fp = $this->_Connect())) { $this->_MBPop(); return false; } // send query, get response $nreqs = count($this->_reqs); $req = implode('', $this->_reqs); $len = 8 + strlen($req); $req = pack('nnNNN', SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs).$req; // add header if (!($this->_Send($fp, $req, $len + 8)) || !($response = $this->_GetResponse($fp, VER_COMMAND_SEARCH)) ) { $this->_MBPop(); return false; } // query sent ok; we can reset reqs now $this->_reqs = array(); // parse and return response return $this->_ParseSearchResponse($response, $nreqs); }
[ "public", "function", "runQueries", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_reqs", ")", ")", "{", "$", "this", "->", "_error", "=", "'no queries defined, issue AddQuery() first'", ";", "return", "false", ";", "}", "// mbstring workaround",...
Connects to searchd, runs queries in batch, and returns an array of result sets. @return array|bool
[ "Connects", "to", "searchd", "runs", "queries", "in", "batch", "and", "returns", "an", "array", "of", "result", "sets", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L889-L925
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.open
public function open() { if ($this->_socket !== false) { $this->_error = 'already connected'; return false; } if (!$fp = $this->_Connect()) { return false; } // command, command version = 0, body length = 4, body = 1 $req = pack('nnNN', SEARCHD_COMMAND_PERSIST, 0, 4, 1); if (!$this->_Send($fp, $req, 12)) { return false; } $this->_socket = $fp; return true; }
php
public function open() { if ($this->_socket !== false) { $this->_error = 'already connected'; return false; } if (!$fp = $this->_Connect()) { return false; } // command, command version = 0, body length = 4, body = 1 $req = pack('nnNN', SEARCHD_COMMAND_PERSIST, 0, 4, 1); if (!$this->_Send($fp, $req, 12)) { return false; } $this->_socket = $fp; return true; }
[ "public", "function", "open", "(", ")", "{", "if", "(", "$", "this", "->", "_socket", "!==", "false", ")", "{", "$", "this", "->", "_error", "=", "'already connected'", ";", "return", "false", ";", "}", "if", "(", "!", "$", "fp", "=", "$", "this", ...
Opens the connection to searchd. @return bool
[ "Opens", "the", "connection", "to", "searchd", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L1313-L1333
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.close
public function close() { if ($this->_socket === false) { $this->_error = 'not connected'; return false; } fclose($this->_socket); $this->_socket = false; return true; }
php
public function close() { if ($this->_socket === false) { $this->_error = 'not connected'; return false; } fclose($this->_socket); $this->_socket = false; return true; }
[ "public", "function", "close", "(", ")", "{", "if", "(", "$", "this", "->", "_socket", "===", "false", ")", "{", "$", "this", "->", "_error", "=", "'not connected'", ";", "return", "false", ";", "}", "fclose", "(", "$", "this", "->", "_socket", ")", ...
Closes the connection to searchd. @return bool
[ "Closes", "the", "connection", "to", "searchd", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L1340-L1352
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.status
public function status() { $this->_MBPush(); if (!($fp = $this->_Connect())) { $this->_MBPop(); return false; } $req = pack('nnNN', SEARCHD_COMMAND_STATUS, VER_COMMAND_STATUS, 4, 1); // len=4, body=1 if (!($this->_Send($fp, $req, 12)) || !($response = $this->_GetResponse($fp, VER_COMMAND_STATUS)) ) { $this->_MBPop(); return false; } substr($response, 4); // just ignore length, error handling, etc $p = 0; list($rows, $cols) = array_values(unpack('N*N*', substr($response, $p, 8))); $p += 8; $res = array(); for ($i = 0; $i < $rows; ++$i) { for ($j = 0; $j < $cols; ++$j) { list(, $len) = unpack('N*', substr($response, $p, 4)); $p += 4; $res[$i][] = substr($response, $p, $len); $p += $len; } } $this->_MBPop(); return $res; }
php
public function status() { $this->_MBPush(); if (!($fp = $this->_Connect())) { $this->_MBPop(); return false; } $req = pack('nnNN', SEARCHD_COMMAND_STATUS, VER_COMMAND_STATUS, 4, 1); // len=4, body=1 if (!($this->_Send($fp, $req, 12)) || !($response = $this->_GetResponse($fp, VER_COMMAND_STATUS)) ) { $this->_MBPop(); return false; } substr($response, 4); // just ignore length, error handling, etc $p = 0; list($rows, $cols) = array_values(unpack('N*N*', substr($response, $p, 8))); $p += 8; $res = array(); for ($i = 0; $i < $rows; ++$i) { for ($j = 0; $j < $cols; ++$j) { list(, $len) = unpack('N*', substr($response, $p, 4)); $p += 4; $res[$i][] = substr($response, $p, $len); $p += $len; } } $this->_MBPop(); return $res; }
[ "public", "function", "status", "(", ")", "{", "$", "this", "->", "_MBPush", "(", ")", ";", "if", "(", "!", "(", "$", "fp", "=", "$", "this", "->", "_Connect", "(", ")", ")", ")", "{", "$", "this", "->", "_MBPop", "(", ")", ";", "return", "fa...
Checks the searchd status. @return array|bool
[ "Checks", "the", "searchd", "status", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L1359-L1395
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.removeFilter
public function removeFilter($attribute) { assert(is_string($attribute)); foreach ($this->_filters as $key => $filter) { if ($filter['attr'] == $attribute) { unset($this->_filters[$key]); return $this; } } return $this; }
php
public function removeFilter($attribute) { assert(is_string($attribute)); foreach ($this->_filters as $key => $filter) { if ($filter['attr'] == $attribute) { unset($this->_filters[$key]); return $this; } } return $this; }
[ "public", "function", "removeFilter", "(", "$", "attribute", ")", "{", "assert", "(", "is_string", "(", "$", "attribute", ")", ")", ";", "foreach", "(", "$", "this", "->", "_filters", "as", "$", "key", "=>", "$", "filter", ")", "{", "if", "(", "$", ...
Removes a previously set filter. @author: Nil Portugués Calderó @param $attribute @return SphinxClient
[ "Removes", "a", "previously", "set", "filter", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L1439-L1451
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient._Connect
protected function _Connect() { if ($this->_socket !== false) { // we are in persistent connection mode, so we have a socket // however, need to check whether it's still alive if (!@feof($this->_socket)) { return $this->_socket; } // force reopen $this->_socket = false; } $errno = 0; $errstr = ''; $this->_connerror = false; if ($this->_path) { $host = $this->_path; $port = 0; } else { $host = $this->_host; $port = $this->_port; } if ($this->_timeout <= 0) { $fp = @fsockopen($host, $port, $errno, $errstr); } else { $fp = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); } if (!$fp) { if ($this->_path) { $location = $this->_path; } else { $location = "{$this->_host}:{$this->_port}"; } $errstr = trim($errstr); $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; $this->_connerror = true; return false; } // send my version // this is a subtle part. we must do it before (!) reading back from searchd. // because otherwise under some conditions (reported on FreeBSD for instance) // TCP stack could throttle write-write-read pattern because of Nagle. if (!$this->_Send($fp, pack('N', 1), 4)) { fclose($fp); $this->_error = 'failed to send client protocol version'; return false; } // check version list(, $v) = unpack('N*', fread($fp, 4)); $v = (int) $v; if ($v < 1) { fclose($fp); $this->_error = "expected searchd protocol version 1+, got version '$v'"; return false; } return $fp; }
php
protected function _Connect() { if ($this->_socket !== false) { // we are in persistent connection mode, so we have a socket // however, need to check whether it's still alive if (!@feof($this->_socket)) { return $this->_socket; } // force reopen $this->_socket = false; } $errno = 0; $errstr = ''; $this->_connerror = false; if ($this->_path) { $host = $this->_path; $port = 0; } else { $host = $this->_host; $port = $this->_port; } if ($this->_timeout <= 0) { $fp = @fsockopen($host, $port, $errno, $errstr); } else { $fp = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); } if (!$fp) { if ($this->_path) { $location = $this->_path; } else { $location = "{$this->_host}:{$this->_port}"; } $errstr = trim($errstr); $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; $this->_connerror = true; return false; } // send my version // this is a subtle part. we must do it before (!) reading back from searchd. // because otherwise under some conditions (reported on FreeBSD for instance) // TCP stack could throttle write-write-read pattern because of Nagle. if (!$this->_Send($fp, pack('N', 1), 4)) { fclose($fp); $this->_error = 'failed to send client protocol version'; return false; } // check version list(, $v) = unpack('N*', fread($fp, 4)); $v = (int) $v; if ($v < 1) { fclose($fp); $this->_error = "expected searchd protocol version 1+, got version '$v'"; return false; } return $fp; }
[ "protected", "function", "_Connect", "(", ")", "{", "if", "(", "$", "this", "->", "_socket", "!==", "false", ")", "{", "// we are in persistent connection mode, so we have a socket", "// however, need to check whether it's still alive", "if", "(", "!", "@", "feof", "(",...
Connect to searchd server. @return bool|resource
[ "Connect", "to", "searchd", "server", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L1499-L1566
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient._GetResponse
protected function _GetResponse($fp, $client_ver) { $status = ''; $response = ''; $len = 0; $ver = ''; $header = fread($fp, 8); if (strlen($header) == 8) { list($status, $ver, $len) = array_values(unpack('n2a/Nb', $header)); $left = $len; while ($left > 0 && !feof($fp)) { $chunk = fread($fp, min(8192, $left)); if ($chunk) { $response .= $chunk; $left -= strlen($chunk); } } } if ($this->_socket === false) { fclose($fp); } // check response $read = strlen($response); if (!$response || $read != $len) { $this->_error = $len ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)" : 'received zero-sized searchd response'; return false; } // check status if ($status == SEARCHD_WARNING) { list($temp, $wlen) = unpack('N*', substr($response, 0, 4)); unset($temp); $this->_warning = substr($response, 4, $wlen); return substr($response, 4 + $wlen); } if ($status == SEARCHD_ERROR) { $this->_error = 'searchd error: '.substr($response, 4); return false; } if ($status == SEARCHD_RETRY) { $this->_error = 'temporary searchd error: '.substr($response, 4); return false; } if ($status != SEARCHD_OK) { $this->_error = "unknown status code '$status'"; return false; } // check version if ($ver < $client_ver) { $this->_warning = sprintf("searchd command v.%d.%d older than client's v.%d.%d, some options might not work", $ver >> 8, $ver & 0xff, $client_ver >> 8, $client_ver & 0xff); } return $response; }
php
protected function _GetResponse($fp, $client_ver) { $status = ''; $response = ''; $len = 0; $ver = ''; $header = fread($fp, 8); if (strlen($header) == 8) { list($status, $ver, $len) = array_values(unpack('n2a/Nb', $header)); $left = $len; while ($left > 0 && !feof($fp)) { $chunk = fread($fp, min(8192, $left)); if ($chunk) { $response .= $chunk; $left -= strlen($chunk); } } } if ($this->_socket === false) { fclose($fp); } // check response $read = strlen($response); if (!$response || $read != $len) { $this->_error = $len ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)" : 'received zero-sized searchd response'; return false; } // check status if ($status == SEARCHD_WARNING) { list($temp, $wlen) = unpack('N*', substr($response, 0, 4)); unset($temp); $this->_warning = substr($response, 4, $wlen); return substr($response, 4 + $wlen); } if ($status == SEARCHD_ERROR) { $this->_error = 'searchd error: '.substr($response, 4); return false; } if ($status == SEARCHD_RETRY) { $this->_error = 'temporary searchd error: '.substr($response, 4); return false; } if ($status != SEARCHD_OK) { $this->_error = "unknown status code '$status'"; return false; } // check version if ($ver < $client_ver) { $this->_warning = sprintf("searchd command v.%d.%d older than client's v.%d.%d, some options might not work", $ver >> 8, $ver & 0xff, $client_ver >> 8, $client_ver & 0xff); } return $response; }
[ "protected", "function", "_GetResponse", "(", "$", "fp", ",", "$", "client_ver", ")", "{", "$", "status", "=", "''", ";", "$", "response", "=", "''", ";", "$", "len", "=", "0", ";", "$", "ver", "=", "''", ";", "$", "header", "=", "fread", "(", ...
Get and check response packet from searchd server. @param $fp @param $client_ver @return bool|string
[ "Get", "and", "check", "response", "packet", "from", "searchd", "server", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L1576-L1640
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.sphPackI64
protected function sphPackI64($v) { assert(is_numeric($v)); // x64 if (PHP_INT_SIZE >= 8) { $v = (int) $v; return pack('NN', $v >> 32, $v & 0xFFFFFFFF); } // x32, int if (is_int($v)) { return pack('NN', $v < 0 ? -1 : 0, $v); } // x32, bcmath if (function_exists('bcmul')) { if (bccomp($v, 0) == -1) { $v = bcadd('18446744073709551616', $v); } $h = bcdiv($v, '4294967296', 0); $l = bcmod($v, '4294967296'); return pack('NN', (float) $h, (float) $l); // conversion to float is intentional; int would lose 31st bit } // x32, no-bcmath $p = max(0, strlen($v) - 13); $lo = abs((float) substr($v, $p)); $hi = abs((float) substr($v, 0, $p)); $m = $lo + $hi * 1316134912.0; // (10 ^ 13) % (1 << 32) = 1316134912 $q = floor($m / 4294967296.0); $l = $m - ($q * 4294967296.0); $h = $hi * 2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328 if ($v < 0) { if ($l == 0) { $h = 4294967296.0 - $h; } else { $h = 4294967295.0 - $h; $l = 4294967296.0 - $l; } } return pack('NN', $h, $l); }
php
protected function sphPackI64($v) { assert(is_numeric($v)); // x64 if (PHP_INT_SIZE >= 8) { $v = (int) $v; return pack('NN', $v >> 32, $v & 0xFFFFFFFF); } // x32, int if (is_int($v)) { return pack('NN', $v < 0 ? -1 : 0, $v); } // x32, bcmath if (function_exists('bcmul')) { if (bccomp($v, 0) == -1) { $v = bcadd('18446744073709551616', $v); } $h = bcdiv($v, '4294967296', 0); $l = bcmod($v, '4294967296'); return pack('NN', (float) $h, (float) $l); // conversion to float is intentional; int would lose 31st bit } // x32, no-bcmath $p = max(0, strlen($v) - 13); $lo = abs((float) substr($v, $p)); $hi = abs((float) substr($v, 0, $p)); $m = $lo + $hi * 1316134912.0; // (10 ^ 13) % (1 << 32) = 1316134912 $q = floor($m / 4294967296.0); $l = $m - ($q * 4294967296.0); $h = $hi * 2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328 if ($v < 0) { if ($l == 0) { $h = 4294967296.0 - $h; } else { $h = 4294967295.0 - $h; $l = 4294967296.0 - $l; } } return pack('NN', $h, $l); }
[ "protected", "function", "sphPackI64", "(", "$", "v", ")", "{", "assert", "(", "is_numeric", "(", "$", "v", ")", ")", ";", "// x64", "if", "(", "PHP_INT_SIZE", ">=", "8", ")", "{", "$", "v", "=", "(", "int", ")", "$", "v", ";", "return", "pack", ...
Pack 64-bit signed. @param $v @return string
[ "Pack", "64", "-", "bit", "signed", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L1861-L1908
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.sphPackU64
protected function sphPackU64($v) { assert(is_numeric($v)); // x64 if (PHP_INT_SIZE >= 8) { assert($v >= 0); // x64, int if (is_int($v)) { return pack('NN', $v >> 32, $v & 0xFFFFFFFF); } // x64, bcmath if (function_exists('bcmul')) { $h = bcdiv($v, 4294967296, 0); $l = bcmod($v, 4294967296); return pack('NN', $h, $l); } // x64, no-bcmath $p = max(0, strlen($v) - 13); $lo = (int) substr($v, $p); $hi = (int) substr($v, 0, $p); $m = $lo + $hi * 1316134912; $l = $m % 4294967296; $h = $hi * 2328 + (int) ($m / 4294967296); return pack('NN', $h, $l); } // x32, int if (is_int($v)) { return pack('NN', 0, $v); } // x32, bcmath if (function_exists('bcmul')) { $h = bcdiv($v, '4294967296', 0); $l = bcmod($v, '4294967296'); return pack('NN', (float) $h, (float) $l); // conversion to float is intentional; int would lose 31st bit } // x32, no-bcmath $p = max(0, strlen($v) - 13); $lo = (float) substr($v, $p); $hi = (float) substr($v, 0, $p); $m = $lo + $hi * 1316134912.0; $q = floor($m / 4294967296.0); $l = $m - ($q * 4294967296.0); $h = $hi * 2328.0 + $q; return pack('NN', $h, $l); }
php
protected function sphPackU64($v) { assert(is_numeric($v)); // x64 if (PHP_INT_SIZE >= 8) { assert($v >= 0); // x64, int if (is_int($v)) { return pack('NN', $v >> 32, $v & 0xFFFFFFFF); } // x64, bcmath if (function_exists('bcmul')) { $h = bcdiv($v, 4294967296, 0); $l = bcmod($v, 4294967296); return pack('NN', $h, $l); } // x64, no-bcmath $p = max(0, strlen($v) - 13); $lo = (int) substr($v, $p); $hi = (int) substr($v, 0, $p); $m = $lo + $hi * 1316134912; $l = $m % 4294967296; $h = $hi * 2328 + (int) ($m / 4294967296); return pack('NN', $h, $l); } // x32, int if (is_int($v)) { return pack('NN', 0, $v); } // x32, bcmath if (function_exists('bcmul')) { $h = bcdiv($v, '4294967296', 0); $l = bcmod($v, '4294967296'); return pack('NN', (float) $h, (float) $l); // conversion to float is intentional; int would lose 31st bit } // x32, no-bcmath $p = max(0, strlen($v) - 13); $lo = (float) substr($v, $p); $hi = (float) substr($v, 0, $p); $m = $lo + $hi * 1316134912.0; $q = floor($m / 4294967296.0); $l = $m - ($q * 4294967296.0); $h = $hi * 2328.0 + $q; return pack('NN', $h, $l); }
[ "protected", "function", "sphPackU64", "(", "$", "v", ")", "{", "assert", "(", "is_numeric", "(", "$", "v", ")", ")", ";", "// x64", "if", "(", "PHP_INT_SIZE", ">=", "8", ")", "{", "assert", "(", "$", "v", ">=", "0", ")", ";", "// x64, int", "if", ...
Packs 64-bit unsigned. @param $v @return string
[ "Packs", "64", "-", "bit", "unsigned", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L1917-L1974
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.sphUnpackU64
protected function sphUnpackU64($v) { list($hi, $lo) = array_values(unpack('N*N*', $v)); if (PHP_INT_SIZE >= 8) { if ($hi < 0) { $hi += (1 << 32); } // because php 5.2.2 to 5.2.5 is totally fucked up again if ($lo < 0) { $lo += (1 << 32); } // x64, int if ($hi <= 2147483647) { return ($hi << 32) + $lo; } // x64, bcmath if (function_exists('bcmul')) { return bcadd($lo, bcmul($hi, '4294967296')); } // x64, no-bcmath $C = 100000; $h = ((int) ($hi / $C) << 32) + (int) ($lo / $C); $l = (($hi % $C) << 32) + ($lo % $C); if ($l > $C) { $h += (int) ($l / $C); $l = $l % $C; } if ($h == 0) { return $l; } return sprintf('%d%05d', $h, $l); } // x32, int if ($hi == 0) { if ($lo > 0) { return $lo; } return sprintf('%u', $lo); } $hi = sprintf('%u', $hi); $lo = sprintf('%u', $lo); // x32, bcmath if (function_exists('bcmul')) { return bcadd($lo, bcmul($hi, '4294967296')); } // x32, no-bcmath $hi = (float) $hi; $lo = (float) $lo; $q = floor($hi / 10000000.0); $r = $hi - $q * 10000000.0; $m = $lo + $r * 4967296.0; $mq = floor($m / 10000000.0); $l = $m - $mq * 10000000.0; $h = $q * 4294967296.0 + $r * 429.0 + $mq; $h = sprintf('%.0f', $h); $l = sprintf('%07.0f', $l); if ($h == '0') { return sprintf('%.0f', (float) $l); } return $h.$l; }
php
protected function sphUnpackU64($v) { list($hi, $lo) = array_values(unpack('N*N*', $v)); if (PHP_INT_SIZE >= 8) { if ($hi < 0) { $hi += (1 << 32); } // because php 5.2.2 to 5.2.5 is totally fucked up again if ($lo < 0) { $lo += (1 << 32); } // x64, int if ($hi <= 2147483647) { return ($hi << 32) + $lo; } // x64, bcmath if (function_exists('bcmul')) { return bcadd($lo, bcmul($hi, '4294967296')); } // x64, no-bcmath $C = 100000; $h = ((int) ($hi / $C) << 32) + (int) ($lo / $C); $l = (($hi % $C) << 32) + ($lo % $C); if ($l > $C) { $h += (int) ($l / $C); $l = $l % $C; } if ($h == 0) { return $l; } return sprintf('%d%05d', $h, $l); } // x32, int if ($hi == 0) { if ($lo > 0) { return $lo; } return sprintf('%u', $lo); } $hi = sprintf('%u', $hi); $lo = sprintf('%u', $lo); // x32, bcmath if (function_exists('bcmul')) { return bcadd($lo, bcmul($hi, '4294967296')); } // x32, no-bcmath $hi = (float) $hi; $lo = (float) $lo; $q = floor($hi / 10000000.0); $r = $hi - $q * 10000000.0; $m = $lo + $r * 4967296.0; $mq = floor($m / 10000000.0); $l = $m - $mq * 10000000.0; $h = $q * 4294967296.0 + $r * 429.0 + $mq; $h = sprintf('%.0f', $h); $l = sprintf('%07.0f', $l); if ($h == '0') { return sprintf('%.0f', (float) $l); } return $h.$l; }
[ "protected", "function", "sphUnpackU64", "(", "$", "v", ")", "{", "list", "(", "$", "hi", ",", "$", "lo", ")", "=", "array_values", "(", "unpack", "(", "'N*N*'", ",", "$", "v", ")", ")", ";", "if", "(", "PHP_INT_SIZE", ">=", "8", ")", "{", "if", ...
Unpacks 64-bit unsigned. @param $v @return int|string
[ "Unpacks", "64", "-", "bit", "unsigned", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L1983-L2056
train
nilportugues/php-sphinx-search
src/NilPortugues/Sphinx/SphinxClient.php
SphinxClient.sphUnpackI64
protected function sphUnpackI64($v) { list($hi, $lo) = array_values(unpack('N*N*', $v)); // x64 if (PHP_INT_SIZE >= 8) { if ($hi < 0) { $hi += (1 << 32); } // because php 5.2.2 to 5.2.5 is totally fucked up again if ($lo < 0) { $lo += (1 << 32); } return ($hi << 32) + $lo; } // x32, int if ($hi == 0) { if ($lo > 0) { return $lo; } return sprintf('%u', $lo); } // x32, int elseif ($hi == -1) { if ($lo < 0) { return $lo; } return sprintf('%.0f', $lo - 4294967296.0); } $neg = ''; $c = 0; if ($hi < 0) { $hi = ~$hi; $lo = ~$lo; $c = 1; $neg = '-'; } $hi = sprintf('%u', $hi); $lo = sprintf('%u', $lo); // x32, bcmath if (function_exists('bcmul')) { return $neg.bcadd(bcadd($lo, bcmul($hi, '4294967296')), $c); } // x32, no-bcmath $hi = (float) $hi; $lo = (float) $lo; $q = floor($hi / 10000000.0); $r = $hi - $q * 10000000.0; $m = $lo + $r * 4967296.0; $mq = floor($m / 10000000.0); $l = $m - $mq * 10000000.0 + $c; $h = $q * 4294967296.0 + $r * 429.0 + $mq; if ($l == 10000000) { $l = 0; $h += 1; } $h = sprintf('%.0f', $h); $l = sprintf('%07.0f', $l); if ($h == '0') { return $neg.sprintf('%.0f', (float) $l); } return $neg.$h.$l; }
php
protected function sphUnpackI64($v) { list($hi, $lo) = array_values(unpack('N*N*', $v)); // x64 if (PHP_INT_SIZE >= 8) { if ($hi < 0) { $hi += (1 << 32); } // because php 5.2.2 to 5.2.5 is totally fucked up again if ($lo < 0) { $lo += (1 << 32); } return ($hi << 32) + $lo; } // x32, int if ($hi == 0) { if ($lo > 0) { return $lo; } return sprintf('%u', $lo); } // x32, int elseif ($hi == -1) { if ($lo < 0) { return $lo; } return sprintf('%.0f', $lo - 4294967296.0); } $neg = ''; $c = 0; if ($hi < 0) { $hi = ~$hi; $lo = ~$lo; $c = 1; $neg = '-'; } $hi = sprintf('%u', $hi); $lo = sprintf('%u', $lo); // x32, bcmath if (function_exists('bcmul')) { return $neg.bcadd(bcadd($lo, bcmul($hi, '4294967296')), $c); } // x32, no-bcmath $hi = (float) $hi; $lo = (float) $lo; $q = floor($hi / 10000000.0); $r = $hi - $q * 10000000.0; $m = $lo + $r * 4967296.0; $mq = floor($m / 10000000.0); $l = $m - $mq * 10000000.0 + $c; $h = $q * 4294967296.0 + $r * 429.0 + $mq; if ($l == 10000000) { $l = 0; $h += 1; } $h = sprintf('%.0f', $h); $l = sprintf('%07.0f', $l); if ($h == '0') { return $neg.sprintf('%.0f', (float) $l); } return $neg.$h.$l; }
[ "protected", "function", "sphUnpackI64", "(", "$", "v", ")", "{", "list", "(", "$", "hi", ",", "$", "lo", ")", "=", "array_values", "(", "unpack", "(", "'N*N*'", ",", "$", "v", ")", ")", ";", "// x64", "if", "(", "PHP_INT_SIZE", ">=", "8", ")", "...
Unpacks 64-bit signed. @param $v @return int|string
[ "Unpacks", "64", "-", "bit", "signed", "." ]
7381e8439fc03577d9f980247cca949b44d5f5cb
https://github.com/nilportugues/php-sphinx-search/blob/7381e8439fc03577d9f980247cca949b44d5f5cb/src/NilPortugues/Sphinx/SphinxClient.php#L2065-L2136
train
PendalF89/yii2-blog
controllers/CategoryController.php
CategoryController.actionTree
public function actionTree() { $models = Category::find()->orderBy('position DESC, title')->all(); $model = new Category(); return $this->render('tree', [ 'model' => $model, 'models' => $models, ]); }
php
public function actionTree() { $models = Category::find()->orderBy('position DESC, title')->all(); $model = new Category(); return $this->render('tree', [ 'model' => $model, 'models' => $models, ]); }
[ "public", "function", "actionTree", "(", ")", "{", "$", "models", "=", "Category", "::", "find", "(", ")", "->", "orderBy", "(", "'position DESC, title'", ")", "->", "all", "(", ")", ";", "$", "model", "=", "new", "Category", "(", ")", ";", "return", ...
Displays categories as tree. @return mixed
[ "Displays", "categories", "as", "tree", "." ]
1e60195c952b0fb85f0925abe1c2f2e9094e86fa
https://github.com/PendalF89/yii2-blog/blob/1e60195c952b0fb85f0925abe1c2f2e9094e86fa/controllers/CategoryController.php#L97-L105
train
yajra/cms-core
src/Http/Controllers/ThemesController.php
ThemesController.store
public function store(Request $request) { $this->validate($request, [ 'theme' => 'required', ]); /** @var Configuration $config */ $config = Configuration::query()->firstOrCreate(['key' => 'theme.frontend']); $config->value = $request->get('theme'); $config->save(); flash()->success(trans('cms::theme.success', ['theme' => $request->get('theme')])); return back(); }
php
public function store(Request $request) { $this->validate($request, [ 'theme' => 'required', ]); /** @var Configuration $config */ $config = Configuration::query()->firstOrCreate(['key' => 'theme.frontend']); $config->value = $request->get('theme'); $config->save(); flash()->success(trans('cms::theme.success', ['theme' => $request->get('theme')])); return back(); }
[ "public", "function", "store", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'theme'", "=>", "'required'", ",", "]", ")", ";", "/** @var Configuration $config */", "$", "config", "=", "Configuration"...
Store new default theme. @param \Illuminate\Http\Request $request @return \Illuminate\Http\RedirectResponse
[ "Store", "new", "default", "theme", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ThemesController.php#L45-L59
train
yajra/cms-core
src/DataTables/CategoriesDataTable.php
CategoriesDataTable.dataTable
public function dataTable() { return (new EloquentDataTable($this->query())) ->editColumn('lft', '<i class="fa fa-dot-circle-o"></i>') ->addColumn('action', function (Category $category) { return view('administrator.categories.datatables.action', $category->toArray()); }) ->editColumn('authenticated', function (Category $category) { return view('administrator.categories.datatables.authenticated', $category->toArray()); }) ->addColumn('pub', function (Category $category) { return '<span class="badge bg-green">' . $category->countPublished() . '</span>'; }) ->addColumn('unpub', function (Category $category) { return '<span class="badge bg-yellow">' . $category->countUnpublished() . '</span>'; }) ->editColumn('hits', function (Category $category) { return '<span class="badge bg-blue">' . $category->hits . '</span>'; }) ->editColumn('title', function (Category $category) { return view('administrator.categories.datatables.title', compact('category')); }) ->editColumn('created_at', function (Category $category) { return $category->created_at->format('Y-m-d'); }) ->rawColumns(['lft', 'published', 'authenticated', 'hits', 'title', 'action', 'pub', 'unpub']); }
php
public function dataTable() { return (new EloquentDataTable($this->query())) ->editColumn('lft', '<i class="fa fa-dot-circle-o"></i>') ->addColumn('action', function (Category $category) { return view('administrator.categories.datatables.action', $category->toArray()); }) ->editColumn('authenticated', function (Category $category) { return view('administrator.categories.datatables.authenticated', $category->toArray()); }) ->addColumn('pub', function (Category $category) { return '<span class="badge bg-green">' . $category->countPublished() . '</span>'; }) ->addColumn('unpub', function (Category $category) { return '<span class="badge bg-yellow">' . $category->countUnpublished() . '</span>'; }) ->editColumn('hits', function (Category $category) { return '<span class="badge bg-blue">' . $category->hits . '</span>'; }) ->editColumn('title', function (Category $category) { return view('administrator.categories.datatables.title', compact('category')); }) ->editColumn('created_at', function (Category $category) { return $category->created_at->format('Y-m-d'); }) ->rawColumns(['lft', 'published', 'authenticated', 'hits', 'title', 'action', 'pub', 'unpub']); }
[ "public", "function", "dataTable", "(", ")", "{", "return", "(", "new", "EloquentDataTable", "(", "$", "this", "->", "query", "(", ")", ")", ")", "->", "editColumn", "(", "'lft'", ",", "'<i class=\"fa fa-dot-circle-o\"></i>'", ")", "->", "addColumn", "(", "'...
Build DataTable class. @return \Yajra\DataTables\DataTableAbstract
[ "Build", "DataTable", "class", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/DataTables/CategoriesDataTable.php#L16-L42
train
PendalF89/yii2-blog
models/Category.php
Category.getPublishedPosts
public function getPublishedPosts() { return PostSearch::find() ->joinWith('category') ->where(['publish_status' => Post::STATUS_PUBLISHED, 'blog_category.id' => $this->id]) ->all(); }
php
public function getPublishedPosts() { return PostSearch::find() ->joinWith('category') ->where(['publish_status' => Post::STATUS_PUBLISHED, 'blog_category.id' => $this->id]) ->all(); }
[ "public", "function", "getPublishedPosts", "(", ")", "{", "return", "PostSearch", "::", "find", "(", ")", "->", "joinWith", "(", "'category'", ")", "->", "where", "(", "[", "'publish_status'", "=>", "Post", "::", "STATUS_PUBLISHED", ",", "'blog_category.id'", ...
Get published posts @return array|\yii\db\ActiveRecord[]
[ "Get", "published", "posts" ]
1e60195c952b0fb85f0925abe1c2f2e9094e86fa
https://github.com/PendalF89/yii2-blog/blob/1e60195c952b0fb85f0925abe1c2f2e9094e86fa/models/Category.php#L67-L73
train
madewithlove/phpunit-snapshots
src/SnapshotAssertions.php
SnapshotAssertions.assertEqualsSnapshot
protected function assertEqualsSnapshot($expected, $identifier = null, $message = null) { SnapshotsManager::setSuite($this); $snapshot = SnapshotsManager::upsertSnapshotContents($identifier, $expected); $this->assertEquals($snapshot, $expected, $message); }
php
protected function assertEqualsSnapshot($expected, $identifier = null, $message = null) { SnapshotsManager::setSuite($this); $snapshot = SnapshotsManager::upsertSnapshotContents($identifier, $expected); $this->assertEquals($snapshot, $expected, $message); }
[ "protected", "function", "assertEqualsSnapshot", "(", "$", "expected", ",", "$", "identifier", "=", "null", ",", "$", "message", "=", "null", ")", "{", "SnapshotsManager", "::", "setSuite", "(", "$", "this", ")", ";", "$", "snapshot", "=", "SnapshotsManager"...
Asserts that a given output matches a registered snapshot or update the latter if it doesn't exist yet. Passing an --update flag to PHPUnit will force updating all snapshots @param mixed $expected @param string|null $identifier An additional identifier to append to the snapshot ID @param string|null $message A message to throw in case of error
[ "Asserts", "that", "a", "given", "output", "matches", "a", "registered", "snapshot", "or", "update", "the", "latter", "if", "it", "doesn", "t", "exist", "yet", "." ]
a7924d66b25955ed036cea97aaa50f35c022dfca
https://github.com/madewithlove/phpunit-snapshots/blob/a7924d66b25955ed036cea97aaa50f35c022dfca/src/SnapshotAssertions.php#L18-L24
train
bipbop/bipbop-php
src/Client/Table.php
Table.generatePush
public function generatePush(Array $parameters, $label, $pushCallback, $pushClass = "\BIPBOP\Client\Push") { $reflection = new \ReflectionClass($pushClass); $query = sprintf("SELECT FROM '%s'.'%s'", $this->database->name(), $this->domNode->getAttribute("name")); $instance = $reflection->newInstance($this->ws); $this->validateParameters($parameters); /* @var $instance \BIPBOP\Push */ return $instance->create($label, $pushCallback, $query, $parameters); }
php
public function generatePush(Array $parameters, $label, $pushCallback, $pushClass = "\BIPBOP\Client\Push") { $reflection = new \ReflectionClass($pushClass); $query = sprintf("SELECT FROM '%s'.'%s'", $this->database->name(), $this->domNode->getAttribute("name")); $instance = $reflection->newInstance($this->ws); $this->validateParameters($parameters); /* @var $instance \BIPBOP\Push */ return $instance->create($label, $pushCallback, $query, $parameters); }
[ "public", "function", "generatePush", "(", "Array", "$", "parameters", ",", "$", "label", ",", "$", "pushCallback", ",", "$", "pushClass", "=", "\"\\BIPBOP\\Client\\Push\"", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "pushClass...
Cria um PUSH @param array $parameters @param string $label @param string $pushCallback URL de retorno do documento @param string $pushClass Endereço da classe que cuida do PUSH @return \DOMDocument
[ "Cria", "um", "PUSH" ]
c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb
https://github.com/bipbop/bipbop-php/blob/c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb/src/Client/Table.php#L61-L68
train
yajra/cms-core
src/Entities/Category.php
Category.recomputeSlug
protected function recomputeSlug() { $slug = $this->computeSlug(); $this->getConnection()->table($this->getTable()) ->where($this->getKeyName(), $this->id) ->update(['slug' => $slug]); $this->articles()->get()->each->touch(); }
php
protected function recomputeSlug() { $slug = $this->computeSlug(); $this->getConnection()->table($this->getTable()) ->where($this->getKeyName(), $this->id) ->update(['slug' => $slug]); $this->articles()->get()->each->touch(); }
[ "protected", "function", "recomputeSlug", "(", ")", "{", "$", "slug", "=", "$", "this", "->", "computeSlug", "(", ")", ";", "$", "this", "->", "getConnection", "(", ")", "->", "table", "(", "$", "this", "->", "getTable", "(", ")", ")", "->", "where",...
Recompute category slug and all articles.
[ "Recompute", "category", "slug", "and", "all", "articles", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Category.php#L92-L100
train
yajra/cms-core
src/Entities/Category.php
Category.getUrl
public function getUrl($layout = null) { $layout = $layout ? '?layout=' . $layout : ''; return url($this->slug) . $layout; }
php
public function getUrl($layout = null) { $layout = $layout ? '?layout=' . $layout : ''; return url($this->slug) . $layout; }
[ "public", "function", "getUrl", "(", "$", "layout", "=", "null", ")", "{", "$", "layout", "=", "$", "layout", "?", "'?layout='", ".", "$", "layout", ":", "''", ";", "return", "url", "(", "$", "this", "->", "slug", ")", ".", "$", "layout", ";", "}...
Get url from implementing class. @param mixed $layout @return string
[ "Get", "url", "from", "implementing", "class", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Category.php#L195-L200
train
jeremykenedy/slack
src/Attachment.php
Attachment.addAction
public function addAction($action) { if ($action instanceof AttachmentAction) { $this->actions[] = $action; return $this; } elseif (is_array($action)) { $this->actions[] = new AttachmentAction($action); return $this; } throw new InvalidArgumentException('The attachment action must be an instance of jeremykenedy\Slack\AttachmentAction or a keyed array'); }
php
public function addAction($action) { if ($action instanceof AttachmentAction) { $this->actions[] = $action; return $this; } elseif (is_array($action)) { $this->actions[] = new AttachmentAction($action); return $this; } throw new InvalidArgumentException('The attachment action must be an instance of jeremykenedy\Slack\AttachmentAction or a keyed array'); }
[ "public", "function", "addAction", "(", "$", "action", ")", "{", "if", "(", "$", "action", "instanceof", "AttachmentAction", ")", "{", "$", "this", "->", "actions", "[", "]", "=", "$", "action", ";", "return", "$", "this", ";", "}", "elseif", "(", "i...
Add an action to the attachment. @param mixed $action @return $this
[ "Add", "an", "action", "to", "the", "attachment", "." ]
f60a3265fe9ef5ea9e4992f7782bc6b9fb9d42e2
https://github.com/jeremykenedy/slack/blob/f60a3265fe9ef5ea9e4992f7782bc6b9fb9d42e2/src/Attachment.php#L659-L672
train
yajra/cms-core
src/Entities/Article.php
Article.boot
protected static function boot() { parent::boot(); static::saving(function (Article $article) { $article->slug = $article->computeSlug(); }); }
php
protected static function boot() { parent::boot(); static::saving(function (Article $article) { $article->slug = $article->computeSlug(); }); }
[ "protected", "static", "function", "boot", "(", ")", "{", "parent", "::", "boot", "(", ")", ";", "static", "::", "saving", "(", "function", "(", "Article", "$", "article", ")", "{", "$", "article", "->", "slug", "=", "$", "article", "->", "computeSlug"...
Boot model.
[ "Boot", "model", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Article.php#L137-L144
train
yajra/cms-core
src/Entities/Article.php
Article.computeSlug
public function computeSlug() { if ($this->is_page) { return $this->alias; } if (! $this->exists) { $category = Category::query()->findOrFail($this->category_id); } else { $category = $this->category; } return $category->slug . '/' . $this->alias; }
php
public function computeSlug() { if ($this->is_page) { return $this->alias; } if (! $this->exists) { $category = Category::query()->findOrFail($this->category_id); } else { $category = $this->category; } return $category->slug . '/' . $this->alias; }
[ "public", "function", "computeSlug", "(", ")", "{", "if", "(", "$", "this", "->", "is_page", ")", "{", "return", "$", "this", "->", "alias", ";", "}", "if", "(", "!", "$", "this", "->", "exists", ")", "{", "$", "category", "=", "Category", "::", ...
Compute article slug. @return string
[ "Compute", "article", "slug", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Article.php#L151-L164
train
yajra/cms-core
src/Entities/Article.php
Article.getRouteName
public function getRouteName() { if ($this->is_page) { return $this->alias; } return str_replace('category-', '', $this->category->getRouteName() . '.' . $this->alias); }
php
public function getRouteName() { if ($this->is_page) { return $this->alias; } return str_replace('category-', '', $this->category->getRouteName() . '.' . $this->alias); }
[ "public", "function", "getRouteName", "(", ")", "{", "if", "(", "$", "this", "->", "is_page", ")", "{", "return", "$", "this", "->", "alias", ";", "}", "return", "str_replace", "(", "'category-'", ",", "''", ",", "$", "this", "->", "category", "->", ...
Get article's route name. @return string
[ "Get", "article", "s", "route", "name", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Article.php#L221-L228
train
yajra/cms-core
src/Entities/Article.php
Article.visited
public function visited() { $this->hits++; $this->newQuery() ->toBase() ->where($this->getKeyName(), $this->getKey()) ->increment('hits'); return $this; }
php
public function visited() { $this->hits++; $this->newQuery() ->toBase() ->where($this->getKeyName(), $this->getKey()) ->increment('hits'); return $this; }
[ "public", "function", "visited", "(", ")", "{", "$", "this", "->", "hits", "++", ";", "$", "this", "->", "newQuery", "(", ")", "->", "toBase", "(", ")", "->", "where", "(", "$", "this", "->", "getKeyName", "(", ")", ",", "$", "this", "->", "getKe...
Update article hits without updating the timestamp. @return $this
[ "Update", "article", "hits", "without", "updating", "the", "timestamp", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Article.php#L304-L314
train
yajra/cms-core
src/Entities/Article.php
Article.getTemplate
public function getTemplate() { $view = 'articles' . str_replace('//', '.', $this->slug); if (view()->exists($view)) { return $view; } return $this->hasTemplate() ? $this->blade_template : 'article.show'; }
php
public function getTemplate() { $view = 'articles' . str_replace('//', '.', $this->slug); if (view()->exists($view)) { return $view; } return $this->hasTemplate() ? $this->blade_template : 'article.show'; }
[ "public", "function", "getTemplate", "(", ")", "{", "$", "view", "=", "'articles'", ".", "str_replace", "(", "'//'", ",", "'.'", ",", "$", "this", "->", "slug", ")", ";", "if", "(", "view", "(", ")", "->", "exists", "(", "$", "view", ")", ")", "{...
Get article's template. @return mixed|string
[ "Get", "article", "s", "template", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Article.php#L321-L329
train
yajra/cms-core
src/Console/WidgetMakeCommand.php
WidgetMakeCommand.createJsonConfig
protected function createJsonConfig($name) { if ($this->files->exists($path = $this->getJsonPath())) { $this->error('Widget json config already exists!'); return; } $stub = $this->files->get($this->getJsonStubPath()); $stub = $this->replaceNamespace($stub, $name)->replaceClass($stub, $name); $stub = $this->replaceFQCN($stub, $name); $stub = $this->replaceView($stub); $this->files->put($path, $stub); $this->info('Json config created successfully.'); }
php
protected function createJsonConfig($name) { if ($this->files->exists($path = $this->getJsonPath())) { $this->error('Widget json config already exists!'); return; } $stub = $this->files->get($this->getJsonStubPath()); $stub = $this->replaceNamespace($stub, $name)->replaceClass($stub, $name); $stub = $this->replaceFQCN($stub, $name); $stub = $this->replaceView($stub); $this->files->put($path, $stub); $this->info('Json config created successfully.'); }
[ "protected", "function", "createJsonConfig", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "path", "=", "$", "this", "->", "getJsonPath", "(", ")", ")", ")", "{", "$", "this", "->", "error", "(", "'Wid...
Create json config file for widget details. @param string $name @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
[ "Create", "json", "config", "file", "for", "widget", "details", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Console/WidgetMakeCommand.php#L44-L60
train
yajra/cms-core
src/Console/WidgetMakeCommand.php
WidgetMakeCommand.getJsonStubPath
protected function getJsonStubPath() { $stubPath = $this->laravel->make('config')->get('laravel-widgets.widget_json_stub'); return $this->laravel->basePath() . '/' . $stubPath; }
php
protected function getJsonStubPath() { $stubPath = $this->laravel->make('config')->get('laravel-widgets.widget_json_stub'); return $this->laravel->basePath() . '/' . $stubPath; }
[ "protected", "function", "getJsonStubPath", "(", ")", "{", "$", "stubPath", "=", "$", "this", "->", "laravel", "->", "make", "(", "'config'", ")", "->", "get", "(", "'laravel-widgets.widget_json_stub'", ")", ";", "return", "$", "this", "->", "laravel", "->",...
Get json stub path. @return string
[ "Get", "json", "stub", "path", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Console/WidgetMakeCommand.php#L77-L82
train
yajra/cms-core
src/Console/WidgetMakeCommand.php
WidgetMakeCommand.createView
protected function createView() { if ($this->files->exists($path = $this->getViewPath())) { $this->error('View already exists!'); return; } $this->makeDirectory($path); $view = $this->files->get($this->getViewStub('view')); $this->files->put($path, $view); $form = $this->files->get($this->getViewStub('form')); $this->files->put($this->getViewPath('_form'), $form); $this->info('Views successfully created.'); }
php
protected function createView() { if ($this->files->exists($path = $this->getViewPath())) { $this->error('View already exists!'); return; } $this->makeDirectory($path); $view = $this->files->get($this->getViewStub('view')); $this->files->put($path, $view); $form = $this->files->get($this->getViewStub('form')); $this->files->put($this->getViewPath('_form'), $form); $this->info('Views successfully created.'); }
[ "protected", "function", "createView", "(", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "path", "=", "$", "this", "->", "getViewPath", "(", ")", ")", ")", "{", "$", "this", "->", "error", "(", "'View already exists!'", ...
Create a new view file for the widget. return void
[ "Create", "a", "new", "view", "file", "for", "the", "widget", ".", "return", "void" ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Console/WidgetMakeCommand.php#L102-L118
train
yajra/cms-core
src/Console/WidgetMakeCommand.php
WidgetMakeCommand.getViewStub
public function getViewStub($key) { $stubPath = $this->laravel->make('config')->get('laravel-widgets.widget_' . $key . '_stub'); return $this->laravel->basePath() . '/' . $stubPath; }
php
public function getViewStub($key) { $stubPath = $this->laravel->make('config')->get('laravel-widgets.widget_' . $key . '_stub'); return $this->laravel->basePath() . '/' . $stubPath; }
[ "public", "function", "getViewStub", "(", "$", "key", ")", "{", "$", "stubPath", "=", "$", "this", "->", "laravel", "->", "make", "(", "'config'", ")", "->", "get", "(", "'laravel-widgets.widget_'", ".", "$", "key", ".", "'_stub'", ")", ";", "return", ...
Get widget stub by key. @param string $key @return string
[ "Get", "widget", "stub", "by", "key", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Console/WidgetMakeCommand.php#L137-L142
train
bipbop/bipbop-php
src/Client/WebService.php
WebService.post
public function post($query, Array $parameters = [], $autoParser = true) { curl_setopt_array($this->resource, [ CURLOPT_POSTFIELDS => array_merge($parameters, [ self::PARAMETER_QUERY => $query, self::PARAMETER_APIKEY => $this->apiKey ]) ]); $dom = new \DOMDocument; $ret = curl_exec($this->resource); if (!$autoParser) return $ret; $dom->loadXML($ret); static::assert($dom); return $dom; }
php
public function post($query, Array $parameters = [], $autoParser = true) { curl_setopt_array($this->resource, [ CURLOPT_POSTFIELDS => array_merge($parameters, [ self::PARAMETER_QUERY => $query, self::PARAMETER_APIKEY => $this->apiKey ]) ]); $dom = new \DOMDocument; $ret = curl_exec($this->resource); if (!$autoParser) return $ret; $dom->loadXML($ret); static::assert($dom); return $dom; }
[ "public", "function", "post", "(", "$", "query", ",", "Array", "$", "parameters", "=", "[", "]", ",", "$", "autoParser", "=", "true", ")", "{", "curl_setopt_array", "(", "$", "this", "->", "resource", ",", "[", "CURLOPT_POSTFIELDS", "=>", "array_merge", ...
Realiza a chamada ao WS da BIPBOP @param string $query Query da BIPBOP @param array $parameters @return \DOMDocument
[ "Realiza", "a", "chamada", "ao", "WS", "da", "BIPBOP" ]
c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb
https://github.com/bipbop/bipbop-php/blob/c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb/src/Client/WebService.php#L45-L59
train
bipbop/bipbop-php
src/Client/WebService.php
WebService.assert
public static function assert(\DOMDocument $dom) { $queryNode = (new \DOMXPath($dom))->query("/BPQL/header/exception"); if ($queryNode->length) { $nodeException = $queryNode->item(0); $source = $nodeException->getAttribute("source"); $code = $nodeException->getAttribute("code"); $id = $nodeException->getAttribute("id"); $pushable = ($nodeException->getAttribute("pushable") ?: $nodeException->getAttribute("push")) === "true"; $message = $nodeException->nodeValue; $e = new Exception(sprintf("[%s:%s/%s] %s", $code, $source, $id, $message, $pushable), $code); $e->setAttributes($code, $source, $id, $message, $pushable); throw $e; } }
php
public static function assert(\DOMDocument $dom) { $queryNode = (new \DOMXPath($dom))->query("/BPQL/header/exception"); if ($queryNode->length) { $nodeException = $queryNode->item(0); $source = $nodeException->getAttribute("source"); $code = $nodeException->getAttribute("code"); $id = $nodeException->getAttribute("id"); $pushable = ($nodeException->getAttribute("pushable") ?: $nodeException->getAttribute("push")) === "true"; $message = $nodeException->nodeValue; $e = new Exception(sprintf("[%s:%s/%s] %s", $code, $source, $id, $message, $pushable), $code); $e->setAttributes($code, $source, $id, $message, $pushable); throw $e; } }
[ "public", "static", "function", "assert", "(", "\\", "DOMDocument", "$", "dom", ")", "{", "$", "queryNode", "=", "(", "new", "\\", "DOMXPath", "(", "$", "dom", ")", ")", "->", "query", "(", "\"/BPQL/header/exception\"", ")", ";", "if", "(", "$", "query...
Realiza um assertion do documento @param \DOMDocument $dom
[ "Realiza", "um", "assertion", "do", "documento" ]
c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb
https://github.com/bipbop/bipbop-php/blob/c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb/src/Client/WebService.php#L65-L79
train
yajra/cms-core
src/Http/Controllers/MediaController.php
MediaController.browse
public function browse(Request $request, $filter = null) { $this->template = 'layouts.component'; $this->filter = $filter; return $this->index($request); }
php
public function browse(Request $request, $filter = null) { $this->template = 'layouts.component'; $this->filter = $filter; return $this->index($request); }
[ "public", "function", "browse", "(", "Request", "$", "request", ",", "$", "filter", "=", "null", ")", "{", "$", "this", "->", "template", "=", "'layouts.component'", ";", "$", "this", "->", "filter", "=", "$", "filter", ";", "return", "$", "this", "->"...
Display media browser from CKEditor. @param \Illuminate\Http\Request $request @param string|null $filter @return \Illuminate\Http\Response
[ "Display", "media", "browser", "from", "CKEditor", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/MediaController.php#L66-L72
train
yajra/cms-core
src/Http/Controllers/MediaController.php
MediaController.folderIsNotAccessible
protected function folderIsNotAccessible(Request $request) { if (isset($request['folder']) && empty($request->get('folder'))) { return true; } return ! Storage::exists($this->currentDir) && $request->has('folder') || $request->get('folder') === 'public'; }
php
protected function folderIsNotAccessible(Request $request) { if (isset($request['folder']) && empty($request->get('folder'))) { return true; } return ! Storage::exists($this->currentDir) && $request->has('folder') || $request->get('folder') === 'public'; }
[ "protected", "function", "folderIsNotAccessible", "(", "Request", "$", "request", ")", "{", "if", "(", "isset", "(", "$", "request", "[", "'folder'", "]", ")", "&&", "empty", "(", "$", "request", "->", "get", "(", "'folder'", ")", ")", ")", "{", "retur...
Check if current folder and folder being requested is accessible. @param \Illuminate\Http\Request $request @return bool
[ "Check", "if", "current", "folder", "and", "folder", "being", "requested", "is", "accessible", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/MediaController.php#L124-L131
train
yajra/cms-core
src/Http/Controllers/MediaController.php
MediaController.scanFiles
protected function scanFiles($current_directory) { $files = collect(Storage::files($current_directory)); $files = $files->filter(function ($file) { $ext = File::extension($file); if ($this->filter === 'images') { return in_array($ext, $this->config->get('media.images_ext')); } elseif ($this->filter === 'files') { return in_array($ext, $this->config->get('media.files_ext')); } return true; }); return $files; }
php
protected function scanFiles($current_directory) { $files = collect(Storage::files($current_directory)); $files = $files->filter(function ($file) { $ext = File::extension($file); if ($this->filter === 'images') { return in_array($ext, $this->config->get('media.images_ext')); } elseif ($this->filter === 'files') { return in_array($ext, $this->config->get('media.files_ext')); } return true; }); return $files; }
[ "protected", "function", "scanFiles", "(", "$", "current_directory", ")", "{", "$", "files", "=", "collect", "(", "Storage", "::", "files", "(", "$", "current_directory", ")", ")", ";", "$", "files", "=", "$", "files", "->", "filter", "(", "function", "(...
Scan files of the given directory. @param $current_directory @return \Illuminate\Support\Collection
[ "Scan", "files", "of", "the", "given", "directory", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/MediaController.php#L212-L228
train
yajra/cms-core
src/Http/Controllers/MediaController.php
MediaController.buildThumbnails
protected function buildThumbnails($files) { $thumbnails = []; foreach ($files as $file) { if (file_can_have_thumbnail($file)) { $thumbnails[$file] = (string) $this->image ->make(Storage::get($file)) ->resize(20, 20)->encode('data-url'); } } return $thumbnails; }
php
protected function buildThumbnails($files) { $thumbnails = []; foreach ($files as $file) { if (file_can_have_thumbnail($file)) { $thumbnails[$file] = (string) $this->image ->make(Storage::get($file)) ->resize(20, 20)->encode('data-url'); } } return $thumbnails; }
[ "protected", "function", "buildThumbnails", "(", "$", "files", ")", "{", "$", "thumbnails", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "file_can_have_thumbnail", "(", "$", "file", ")", ")", "{", "$", "th...
Build thumbnails for each files that is image type. @param \Illuminate\Support\Collection $files @return array
[ "Build", "thumbnails", "for", "each", "files", "that", "is", "image", "type", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/MediaController.php#L236-L249
train
yajra/cms-core
src/Http/Controllers/MediaController.php
MediaController.buildDirectory
protected function buildDirectory($directories, $parent) { $directories = $directories->map(function ($dir) use ($parent) { $dir = str_replace($parent . '/', '', $dir); return $dir; }); $html = '<ul>'; $directories->each(function ($dir) use (&$html, $parent) { $subParent = $parent . '/' . $dir; $url = request()->url() . '?folder=' . $dir; $dir = str_replace('public/', 'storage/', $dir); $html .= "<li>"; $html .= "<a href='{$url}'>{$dir}</a>"; if ($child = $this->scanDirectory($subParent)) { $html .= $this->buildDirectory($child, $subParent); } $html .= "</li>"; }); $html .= '</ul>'; return $html; }
php
protected function buildDirectory($directories, $parent) { $directories = $directories->map(function ($dir) use ($parent) { $dir = str_replace($parent . '/', '', $dir); return $dir; }); $html = '<ul>'; $directories->each(function ($dir) use (&$html, $parent) { $subParent = $parent . '/' . $dir; $url = request()->url() . '?folder=' . $dir; $dir = str_replace('public/', 'storage/', $dir); $html .= "<li>"; $html .= "<a href='{$url}'>{$dir}</a>"; if ($child = $this->scanDirectory($subParent)) { $html .= $this->buildDirectory($child, $subParent); } $html .= "</li>"; }); $html .= '</ul>'; return $html; }
[ "protected", "function", "buildDirectory", "(", "$", "directories", ",", "$", "parent", ")", "{", "$", "directories", "=", "$", "directories", "->", "map", "(", "function", "(", "$", "dir", ")", "use", "(", "$", "parent", ")", "{", "$", "dir", "=", "...
Build the directory lists. @param \Illuminate\Support\Collection $directories @param string $parent @return string
[ "Build", "the", "directory", "lists", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/MediaController.php#L269-L293
train
yajra/cms-core
src/Http/Controllers/MediaController.php
MediaController.deleteDirectory
protected function deleteDirectory(Request $request) { try { $dir = $request->input('s'); Storage::deleteDirectory($dir); return $this->notifySuccess($dir . ' successfully deleted!'); } catch (\ErrorException $e) { return $this->notifyError($e->getMessage()); } }
php
protected function deleteDirectory(Request $request) { try { $dir = $request->input('s'); Storage::deleteDirectory($dir); return $this->notifySuccess($dir . ' successfully deleted!'); } catch (\ErrorException $e) { return $this->notifyError($e->getMessage()); } }
[ "protected", "function", "deleteDirectory", "(", "Request", "$", "request", ")", "{", "try", "{", "$", "dir", "=", "$", "request", "->", "input", "(", "'s'", ")", ";", "Storage", "::", "deleteDirectory", "(", "$", "dir", ")", ";", "return", "$", "this"...
Delete a single directory from request. @param \Illuminate\Http\Request $request @return \Illuminate\Http\JsonResponse
[ "Delete", "a", "single", "directory", "from", "request", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/MediaController.php#L410-L420
train
yajra/cms-core
src/Http/Controllers/MediaController.php
MediaController.deleteFile
protected function deleteFile(Request $request) { try { $file = $request->input('s'); Storage::delete($file); return $this->notifySuccess($file . ' successfully deleted!'); } catch (\ErrorException $e) { return $this->notifyError($e->getMessage()); } }
php
protected function deleteFile(Request $request) { try { $file = $request->input('s'); Storage::delete($file); return $this->notifySuccess($file . ' successfully deleted!'); } catch (\ErrorException $e) { return $this->notifyError($e->getMessage()); } }
[ "protected", "function", "deleteFile", "(", "Request", "$", "request", ")", "{", "try", "{", "$", "file", "=", "$", "request", "->", "input", "(", "'s'", ")", ";", "Storage", "::", "delete", "(", "$", "file", ")", ";", "return", "$", "this", "->", ...
Delete a single file from request. @param \Illuminate\Http\Request $request @return \Illuminate\Http\JsonResponse
[ "Delete", "a", "single", "file", "from", "request", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/MediaController.php#L428-L438
train
yajra/cms-core
src/Http/Controllers/ExtensionsController.php
ExtensionsController.destroy
public function destroy($id) { $extension = $this->repository->findOrFail($id); if ($extension->protected) { return $this->notifyError(trans('cms::extension.protected')); } if ($this->repository->uninstall($id)) { flash()->success(trans('cms::extension.deleted', compact('id'))); } else { flash()->error(trans('cms::extension.error', compact('id'))); } return back(); }
php
public function destroy($id) { $extension = $this->repository->findOrFail($id); if ($extension->protected) { return $this->notifyError(trans('cms::extension.protected')); } if ($this->repository->uninstall($id)) { flash()->success(trans('cms::extension.deleted', compact('id'))); } else { flash()->error(trans('cms::extension.error', compact('id'))); } return back(); }
[ "public", "function", "destroy", "(", "$", "id", ")", "{", "$", "extension", "=", "$", "this", "->", "repository", "->", "findOrFail", "(", "$", "id", ")", ";", "if", "(", "$", "extension", "->", "protected", ")", "{", "return", "$", "this", "->", ...
Uninstall an extension. @param string $id @return \Illuminate\Http\RedirectResponse
[ "Uninstall", "an", "extension", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ExtensionsController.php#L55-L69
train
nathanmac/Responder
src/Responder.php
Responder.payload
public function payload($payload, $format = '', $container = 'data') { $class = $this->getFormatClass($format); return $this->generate($payload, new $class, $container); }
php
public function payload($payload, $format = '', $container = 'data') { $class = $this->getFormatClass($format); return $this->generate($payload, new $class, $container); }
[ "public", "function", "payload", "(", "$", "payload", ",", "$", "format", "=", "''", ",", "$", "container", "=", "'data'", ")", "{", "$", "class", "=", "$", "this", "->", "getFormatClass", "(", "$", "format", ")", ";", "return", "$", "this", "->", ...
Format the payload array, autodetect format. Override the format by providing a content type. @param string $format @param string $container @return array
[ "Format", "the", "payload", "array", "autodetect", "format", ".", "Override", "the", "format", "by", "providing", "a", "content", "type", "." ]
10bf8d6208771a19180feaa3241d5a626048561d
https://github.com/nathanmac/Responder/blob/10bf8d6208771a19180feaa3241d5a626048561d/src/Responder.php#L67-L71
train
nathanmac/Responder
src/Responder.php
Responder.registerFormat
public function registerFormat($format, $class) { if ( ! class_exists($class)) { throw new \InvalidArgumentException("Responder formatter class {$class} not found."); } if ( ! is_a($class, 'Nathanmac\Utilities\Responder\Formats\FormatInterface', true)) { throw new \InvalidArgumentException('Responder formatters must implement the Nathanmac\Utilities\Responder\Formats\FormatInterface interface.'); } $this->supported_formats[$format] = $class; return $this; }
php
public function registerFormat($format, $class) { if ( ! class_exists($class)) { throw new \InvalidArgumentException("Responder formatter class {$class} not found."); } if ( ! is_a($class, 'Nathanmac\Utilities\Responder\Formats\FormatInterface', true)) { throw new \InvalidArgumentException('Responder formatters must implement the Nathanmac\Utilities\Responder\Formats\FormatInterface interface.'); } $this->supported_formats[$format] = $class; return $this; }
[ "public", "function", "registerFormat", "(", "$", "format", ",", "$", "class", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Responder formatter class {$class} not found.\"", ...
Register Format Class. @param $format @param $class @throws InvalidArgumentException @return self
[ "Register", "Format", "Class", "." ]
10bf8d6208771a19180feaa3241d5a626048561d
https://github.com/nathanmac/Responder/blob/10bf8d6208771a19180feaa3241d5a626048561d/src/Responder.php#L131-L143
train
neos/redirecthandler
Classes/RedirectComponent.php
RedirectComponent.handle
public function handle(ComponentContext $componentContext) { $routingMatchResults = $componentContext->getParameter(RoutingComponent::class, 'matchResults'); if ($routingMatchResults !== NULL) { return; } $httpRequest = $componentContext->getHttpRequest(); $response = $this->redirectService->buildResponseIfApplicable($httpRequest); if ($response !== null) { $componentContext->replaceHttpResponse($response); $componentContext->setParameter(ComponentChain::class, 'cancel', true); } }
php
public function handle(ComponentContext $componentContext) { $routingMatchResults = $componentContext->getParameter(RoutingComponent::class, 'matchResults'); if ($routingMatchResults !== NULL) { return; } $httpRequest = $componentContext->getHttpRequest(); $response = $this->redirectService->buildResponseIfApplicable($httpRequest); if ($response !== null) { $componentContext->replaceHttpResponse($response); $componentContext->setParameter(ComponentChain::class, 'cancel', true); } }
[ "public", "function", "handle", "(", "ComponentContext", "$", "componentContext", ")", "{", "$", "routingMatchResults", "=", "$", "componentContext", "->", "getParameter", "(", "RoutingComponent", "::", "class", ",", "'matchResults'", ")", ";", "if", "(", "$", "...
Check if the current request match a redirect @param ComponentContext $componentContext @return void
[ "Check", "if", "the", "current", "request", "match", "a", "redirect" ]
351effbe2d184e82cc1dc65a5e409d092ba56194
https://github.com/neos/redirecthandler/blob/351effbe2d184e82cc1dc65a5e409d092ba56194/Classes/RedirectComponent.php#L45-L57
train
yajra/cms-core
src/Entities/Menu.php
Menu.category
public function category() { $category = $this->param('category_id', 0); $categoryId = explode(':', $category)[0]; return Category::query()->findOrNew($categoryId); }
php
public function category() { $category = $this->param('category_id', 0); $categoryId = explode(':', $category)[0]; return Category::query()->findOrNew($categoryId); }
[ "public", "function", "category", "(", ")", "{", "$", "category", "=", "$", "this", "->", "param", "(", "'category_id'", ",", "0", ")", ";", "$", "categoryId", "=", "explode", "(", "':'", ",", "$", "category", ")", "[", "0", "]", ";", "return", "Ca...
Get related category. @return \Illuminate\Database\Eloquent\Model|\Yajra\CMS\Entities\Article
[ "Get", "related", "category", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Menu.php#L112-L118
train
yajra/cms-core
src/Entities/Menu.php
Menu.hasWidget
public function hasWidget($widget) { if ($widget instanceof Model) { $widget = $widget->id; } return $this->widgets()->where('widget_id', $widget)->exists(); }
php
public function hasWidget($widget) { if ($widget instanceof Model) { $widget = $widget->id; } return $this->widgets()->where('widget_id', $widget)->exists(); }
[ "public", "function", "hasWidget", "(", "$", "widget", ")", "{", "if", "(", "$", "widget", "instanceof", "Model", ")", "{", "$", "widget", "=", "$", "widget", "->", "id", ";", "}", "return", "$", "this", "->", "widgets", "(", ")", "->", "where", "(...
Check if the menu has the given widget. @param mixed $widget @return bool
[ "Check", "if", "the", "menu", "has", "the", "given", "widget", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Menu.php#L173-L180
train
yajra/cms-core
src/Presenters/WidgetPresenter.php
WidgetPresenter.template
public function template() { return $this->entity->template === 'custom' ? $this->entity->custom_template : $this->entity->template; }
php
public function template() { return $this->entity->template === 'custom' ? $this->entity->custom_template : $this->entity->template; }
[ "public", "function", "template", "(", ")", "{", "return", "$", "this", "->", "entity", "->", "template", "===", "'custom'", "?", "$", "this", "->", "entity", "->", "custom_template", ":", "$", "this", "->", "entity", "->", "template", ";", "}" ]
Get widget's view template. @return string
[ "Get", "widget", "s", "view", "template", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/WidgetPresenter.php#L14-L17
train
yajra/cms-core
src/Presenters/WidgetPresenter.php
WidgetPresenter.class
public function class() { /** @var \Yajra\CMS\Repositories\Extension\Repository $repository */ $repository = app('extensions'); $extension = $repository->findOrFail($this->entity->extension_id); return $extension->param('class'); }
php
public function class() { /** @var \Yajra\CMS\Repositories\Extension\Repository $repository */ $repository = app('extensions'); $extension = $repository->findOrFail($this->entity->extension_id); return $extension->param('class'); }
[ "public", "function", "class", "(", ")", "{", "/** @var \\Yajra\\CMS\\Repositories\\Extension\\Repository $repository */", "$", "repository", "=", "app", "(", "'extensions'", ")", ";", "$", "extension", "=", "$", "repository", "->", "findOrFail", "(", "$", "this", "...
Get widget type FQCN. @return string @throws \Exception
[ "Get", "widget", "type", "FQCN", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/WidgetPresenter.php#L25-L32
train
yajra/cms-core
src/Http/Controllers/PermissionsController.php
PermissionsController.create
public function create() { $permission = new Permission; $permission->resource = 'System'; $roles = Role::all(); return view('administrator.permissions.create', compact('permission', 'roles')); }
php
public function create() { $permission = new Permission; $permission->resource = 'System'; $roles = Role::all(); return view('administrator.permissions.create', compact('permission', 'roles')); }
[ "public", "function", "create", "(", ")", "{", "$", "permission", "=", "new", "Permission", ";", "$", "permission", "->", "resource", "=", "'System'", ";", "$", "roles", "=", "Role", "::", "all", "(", ")", ";", "return", "view", "(", "'administrator.perm...
Show permission form. @return \Illuminate\View\View
[ "Show", "permission", "form", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/PermissionsController.php#L55-L62
train
yajra/cms-core
src/Http/Controllers/PermissionsController.php
PermissionsController.store
public function store() { $this->validate($this->request, [ 'name' => 'required', 'resource' => 'required|alpha_num', 'slug' => 'required|unique:permissions,slug', ]); $permission = Permission::create($this->request->all()); $permission->syncRoles($this->request->get('roles', [])); return redirect()->route('administrator.permissions.index'); }
php
public function store() { $this->validate($this->request, [ 'name' => 'required', 'resource' => 'required|alpha_num', 'slug' => 'required|unique:permissions,slug', ]); $permission = Permission::create($this->request->all()); $permission->syncRoles($this->request->get('roles', [])); return redirect()->route('administrator.permissions.index'); }
[ "public", "function", "store", "(", ")", "{", "$", "this", "->", "validate", "(", "$", "this", "->", "request", ",", "[", "'name'", "=>", "'required'", ",", "'resource'", "=>", "'required|alpha_num'", ",", "'slug'", "=>", "'required|unique:permissions,slug'", ...
Store a newly created permission. @return \Illuminate\Http\RedirectResponse
[ "Store", "a", "newly", "created", "permission", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/PermissionsController.php#L69-L81
train
yajra/cms-core
src/Http/Controllers/PermissionsController.php
PermissionsController.storeResource
public function storeResource() { $this->validate($this->request, [ 'resource' => 'required|alpha_num', ]); $permissions = Permission::createResource($this->request->resource); foreach ($permissions as $permission) { $permission->syncRoles($this->request->get('roles', [])); } return redirect()->route('administrator.permissions.index'); }
php
public function storeResource() { $this->validate($this->request, [ 'resource' => 'required|alpha_num', ]); $permissions = Permission::createResource($this->request->resource); foreach ($permissions as $permission) { $permission->syncRoles($this->request->get('roles', [])); } return redirect()->route('administrator.permissions.index'); }
[ "public", "function", "storeResource", "(", ")", "{", "$", "this", "->", "validate", "(", "$", "this", "->", "request", ",", "[", "'resource'", "=>", "'required|alpha_num'", ",", "]", ")", ";", "$", "permissions", "=", "Permission", "::", "createResource", ...
Store permission resource. @return \Illuminate\Http\RedirectResponse
[ "Store", "permission", "resource", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/PermissionsController.php#L101-L113
train
yajra/cms-core
src/Http/Controllers/PermissionsController.php
PermissionsController.update
public function update(Permission $permission) { $this->validate($this->request, [ 'name' => 'required', 'resource' => 'required|alpha_num', 'slug' => 'required|unique:permissions,slug,' . $permission->id, ]); $permission->name = $this->request->get('name'); $permission->resource = $this->request->get('resource'); if (! $permission->system) { $permission->slug = $this->request->get('slug'); } $permission->save(); $permission->syncRoles($this->request->get('roles', [])); return redirect()->route('administrator.permissions.index'); }
php
public function update(Permission $permission) { $this->validate($this->request, [ 'name' => 'required', 'resource' => 'required|alpha_num', 'slug' => 'required|unique:permissions,slug,' . $permission->id, ]); $permission->name = $this->request->get('name'); $permission->resource = $this->request->get('resource'); if (! $permission->system) { $permission->slug = $this->request->get('slug'); } $permission->save(); $permission->syncRoles($this->request->get('roles', [])); return redirect()->route('administrator.permissions.index'); }
[ "public", "function", "update", "(", "Permission", "$", "permission", ")", "{", "$", "this", "->", "validate", "(", "$", "this", "->", "request", ",", "[", "'name'", "=>", "'required'", ",", "'resource'", "=>", "'required|alpha_num'", ",", "'slug'", "=>", ...
Update selected permission. @param \Yajra\Acl\Models\Permission $permission @return \Illuminate\Http\RedirectResponse
[ "Update", "selected", "permission", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/PermissionsController.php#L134-L152
train
yajra/cms-core
src/Http/Controllers/PermissionsController.php
PermissionsController.destroy
public function destroy(Permission $permission) { if (! $permission->system) { try { $permission->delete(); return $this->notifySuccess('Permission successfully deleted!'); } catch (QueryException $e) { return $this->notifyError($e->getMessage()); } } return $this->notifyError('System permission is protected and cannot be deleted!'); }
php
public function destroy(Permission $permission) { if (! $permission->system) { try { $permission->delete(); return $this->notifySuccess('Permission successfully deleted!'); } catch (QueryException $e) { return $this->notifyError($e->getMessage()); } } return $this->notifyError('System permission is protected and cannot be deleted!'); }
[ "public", "function", "destroy", "(", "Permission", "$", "permission", ")", "{", "if", "(", "!", "$", "permission", "->", "system", ")", "{", "try", "{", "$", "permission", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "notifySuccess", "(...
Remove selected permission. @param \Yajra\Acl\Models\Permission $permission @return \Illuminate\Http\RedirectResponse
[ "Remove", "selected", "permission", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/PermissionsController.php#L160-L173
train
umbrellaTech/ya-boleto-php
src/Type/Number.php
Number.fatorVencimento
public static function fatorVencimento(\DateTime $data) { $dataBase = new \DateTime("1997-10-07"); return (int)$data->diff($dataBase, true)->format('%r%a'); }
php
public static function fatorVencimento(\DateTime $data) { $dataBase = new \DateTime("1997-10-07"); return (int)$data->diff($dataBase, true)->format('%r%a'); }
[ "public", "static", "function", "fatorVencimento", "(", "\\", "DateTime", "$", "data", ")", "{", "$", "dataBase", "=", "new", "\\", "DateTime", "(", "\"1997-10-07\"", ")", ";", "return", "(", "int", ")", "$", "data", "->", "diff", "(", "$", "dataBase", ...
Calcula o fator vencimento. @param \DateTime $data @return integer
[ "Calcula", "o", "fator", "vencimento", "." ]
3d2e0f2db63e380eaa6db66d1103294705197118
https://github.com/umbrellaTech/ya-boleto-php/blob/3d2e0f2db63e380eaa6db66d1103294705197118/src/Type/Number.php#L151-L156
train
yajra/cms-core
src/Http/Controllers/UsersController.php
UsersController.index
public function index(UsersDataTable $dataTable) { $roles = $this->role->pluck('name', 'id'); return $dataTable->render('administrator.users.index', compact('roles')); }
php
public function index(UsersDataTable $dataTable) { $roles = $this->role->pluck('name', 'id'); return $dataTable->render('administrator.users.index', compact('roles')); }
[ "public", "function", "index", "(", "UsersDataTable", "$", "dataTable", ")", "{", "$", "roles", "=", "$", "this", "->", "role", "->", "pluck", "(", "'name'", ",", "'id'", ")", ";", "return", "$", "dataTable", "->", "render", "(", "'administrator.users.inde...
Display list of users. @param \Yajra\CMS\DataTables\UsersDataTable $dataTable @return \Illuminate\Http\JsonResponse|\Illuminate\View\View
[ "Display", "list", "of", "users", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UsersController.php#L61-L66
train
yajra/cms-core
src/Http/Controllers/UsersController.php
UsersController.create
public function create() { $roles = $this->getAllowedRoles(); $selectedRoles = $this->request->old('roles'); $user = new User([ 'blocked' => 0, 'confirmed' => 1, ]); return view('administrator.users.create', compact('user', 'roles', 'selectedRoles')); }
php
public function create() { $roles = $this->getAllowedRoles(); $selectedRoles = $this->request->old('roles'); $user = new User([ 'blocked' => 0, 'confirmed' => 1, ]); return view('administrator.users.create', compact('user', 'roles', 'selectedRoles')); }
[ "public", "function", "create", "(", ")", "{", "$", "roles", "=", "$", "this", "->", "getAllowedRoles", "(", ")", ";", "$", "selectedRoles", "=", "$", "this", "->", "request", "->", "old", "(", "'roles'", ")", ";", "$", "user", "=", "new", "User", ...
Show user form. @return \Illuminate\View\View
[ "Show", "user", "form", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UsersController.php#L73-L84
train
yajra/cms-core
src/Http/Controllers/UsersController.php
UsersController.getAllowedRoles
protected function getAllowedRoles() { if ($this->request->user('administrator')->isRole('super-administrator')) { $roles = $this->role->newQuery()->get(); } else { $roles = $this->role->newQuery()->where('slug', '!=', 'super-administrator')->get(); } return $roles->pluck('name', 'id'); }
php
protected function getAllowedRoles() { if ($this->request->user('administrator')->isRole('super-administrator')) { $roles = $this->role->newQuery()->get(); } else { $roles = $this->role->newQuery()->where('slug', '!=', 'super-administrator')->get(); } return $roles->pluck('name', 'id'); }
[ "protected", "function", "getAllowedRoles", "(", ")", "{", "if", "(", "$", "this", "->", "request", "->", "user", "(", "'administrator'", ")", "->", "isRole", "(", "'super-administrator'", ")", ")", "{", "$", "roles", "=", "$", "this", "->", "role", "->"...
Get allowed roles for the current user. @return mixed
[ "Get", "allowed", "roles", "for", "the", "current", "user", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UsersController.php#L91-L100
train
yajra/cms-core
src/Http/Controllers/UsersController.php
UsersController.store
public function store(StoreUserValidator $request) { $user = new User($request->all()); $user->password = bcrypt($request->get('password')); $user->is_activated = $request->get('is_activated', false); $user->is_blocked = $request->get('is_blocked', false); $user->is_admin = $request->get('is_admin', false); $user->save(); $user->syncRoles($request->get('roles')); event(new UserWasCreated($user)); flash()->success('User ' . $user->first_name . 'successfully created!'); return redirect()->route('administrator.users.index'); }
php
public function store(StoreUserValidator $request) { $user = new User($request->all()); $user->password = bcrypt($request->get('password')); $user->is_activated = $request->get('is_activated', false); $user->is_blocked = $request->get('is_blocked', false); $user->is_admin = $request->get('is_admin', false); $user->save(); $user->syncRoles($request->get('roles')); event(new UserWasCreated($user)); flash()->success('User ' . $user->first_name . 'successfully created!'); return redirect()->route('administrator.users.index'); }
[ "public", "function", "store", "(", "StoreUserValidator", "$", "request", ")", "{", "$", "user", "=", "new", "User", "(", "$", "request", "->", "all", "(", ")", ")", ";", "$", "user", "->", "password", "=", "bcrypt", "(", "$", "request", "->", "get",...
Store a newly created user. @param \Yajra\CMS\Contracts\Validators\StoreUserValidator $request @return \Illuminate\Http\RedirectResponse
[ "Store", "a", "newly", "created", "user", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UsersController.php#L108-L123
train
yajra/cms-core
src/Http/Controllers/UsersController.php
UsersController.edit
public function edit(User $user) { $roles = $this->getAllowedRoles(); $selectedRoles = $user->roles()->pluck('roles.id'); return view('administrator.users.edit', compact('user', 'roles', 'selectedRoles')); }
php
public function edit(User $user) { $roles = $this->getAllowedRoles(); $selectedRoles = $user->roles()->pluck('roles.id'); return view('administrator.users.edit', compact('user', 'roles', 'selectedRoles')); }
[ "public", "function", "edit", "(", "User", "$", "user", ")", "{", "$", "roles", "=", "$", "this", "->", "getAllowedRoles", "(", ")", ";", "$", "selectedRoles", "=", "$", "user", "->", "roles", "(", ")", "->", "pluck", "(", "'roles.id'", ")", ";", "...
Show and edit selected user. @param \App\User $user @return \Illuminate\View\View
[ "Show", "and", "edit", "selected", "user", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UsersController.php#L131-L137
train
yajra/cms-core
src/Http/Controllers/UsersController.php
UsersController.destroy
public function destroy(User $user, $force = false) { if ($user->id <> auth('administrator')->id()) { try { if ($force) { $user->forceDelete(); } else { $user->delete(); } return $this->notifySuccess('User successfully deleted!'); } catch (QueryException $e) { return $this->notifyError($e->getMessage()); } } return $this->notifyError('You cannot delete your own record!'); }
php
public function destroy(User $user, $force = false) { if ($user->id <> auth('administrator')->id()) { try { if ($force) { $user->forceDelete(); } else { $user->delete(); } return $this->notifySuccess('User successfully deleted!'); } catch (QueryException $e) { return $this->notifyError($e->getMessage()); } } return $this->notifyError('You cannot delete your own record!'); }
[ "public", "function", "destroy", "(", "User", "$", "user", ",", "$", "force", "=", "false", ")", "{", "if", "(", "$", "user", "->", "id", "<>", "auth", "(", "'administrator'", ")", "->", "id", "(", ")", ")", "{", "try", "{", "if", "(", "$", "fo...
Remove selected user. @param \App\User $user @param bool|false $force @return \Illuminate\Http\JsonResponse @throws \Exception
[ "Remove", "selected", "user", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UsersController.php#L225-L242
train
yajra/cms-core
src/Http/Controllers/UsersController.php
UsersController.ban
public function ban(User $user) { $user->is_blocked = ! $user->is_blocked; $user->save(); if ($user->is_blocked) { return $this->notifySuccess('User ' . $user->name . ' blocked!'); } else { return $this->notifySuccess('User ' . $user->name . ' un-blocked!'); } }
php
public function ban(User $user) { $user->is_blocked = ! $user->is_blocked; $user->save(); if ($user->is_blocked) { return $this->notifySuccess('User ' . $user->name . ' blocked!'); } else { return $this->notifySuccess('User ' . $user->name . ' un-blocked!'); } }
[ "public", "function", "ban", "(", "User", "$", "user", ")", "{", "$", "user", "->", "is_blocked", "=", "!", "$", "user", "->", "is_blocked", ";", "$", "user", "->", "save", "(", ")", ";", "if", "(", "$", "user", "->", "is_blocked", ")", "{", "ret...
Toggle ban status of a user. @param \App\User $user @return \Illuminate\Http\JsonResponse
[ "Toggle", "ban", "status", "of", "a", "user", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UsersController.php#L262-L272
train
yajra/cms-core
src/Http/Controllers/UsersController.php
UsersController.activate
public function activate(User $user) { $user->is_activated = ! $user->is_activated; $user->save(); if ($user->is_activated) { return $this->notifySuccess('User ' . $user->name . ' activated!'); } else { return $this->notifySuccess('User ' . $user->name . ' deactivated!'); } }
php
public function activate(User $user) { $user->is_activated = ! $user->is_activated; $user->save(); if ($user->is_activated) { return $this->notifySuccess('User ' . $user->name . ' activated!'); } else { return $this->notifySuccess('User ' . $user->name . ' deactivated!'); } }
[ "public", "function", "activate", "(", "User", "$", "user", ")", "{", "$", "user", "->", "is_activated", "=", "!", "$", "user", "->", "is_activated", ";", "$", "user", "->", "save", "(", ")", ";", "if", "(", "$", "user", "->", "is_activated", ")", ...
Toggle user activation status. @param \App\User $user @return \Illuminate\Http\JsonResponse
[ "Toggle", "user", "activation", "status", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UsersController.php#L280-L290
train
bringyourownideas/silverstripe-composer-security-checker
src/Extensions/SiteSummaryExtension.php
SiteSummaryExtension.updateAlerts
public function updateAlerts(&$alerts) { $securityWarnings = $this->owner->sourceRecords()->filter('SecurityAlerts.ID:GreaterThan', 0); if ($securityWarnings->exists()) { $alerts['SecurityAlerts'] = $securityWarnings->renderWith('SecurityAlertSummary'); } }
php
public function updateAlerts(&$alerts) { $securityWarnings = $this->owner->sourceRecords()->filter('SecurityAlerts.ID:GreaterThan', 0); if ($securityWarnings->exists()) { $alerts['SecurityAlerts'] = $securityWarnings->renderWith('SecurityAlertSummary'); } }
[ "public", "function", "updateAlerts", "(", "&", "$", "alerts", ")", "{", "$", "securityWarnings", "=", "$", "this", "->", "owner", "->", "sourceRecords", "(", ")", "->", "filter", "(", "'SecurityAlerts.ID:GreaterThan'", ",", "0", ")", ";", "if", "(", "$", ...
Update the Package's screen bound summary info with little badges to indicate security alerts are present for this package @param array $alerts a list of alerts to display
[ "Update", "the", "Package", "s", "screen", "bound", "summary", "info", "with", "little", "badges", "to", "indicate", "security", "alerts", "are", "present", "for", "this", "package" ]
e8e18929752c0ca7fb51c7f52d1858c3ab3e5ee6
https://github.com/bringyourownideas/silverstripe-composer-security-checker/blob/e8e18929752c0ca7fb51c7f52d1858c3ab3e5ee6/src/Extensions/SiteSummaryExtension.php#L33-L40
train
yajra/cms-core
src/Http/Controllers/SearchController.php
SearchController.show
public function show() { $keyword = request('q'); $articles = []; $limit = abs(request('limit', config('site.limit', 10))); $max_limit = config('site.max_limit', 100); if ($limit > $max_limit) { $limit = $max_limit; } if ($keyword) { $articles = $this->engine->search($keyword, $limit); $articles->appends('q', $keyword); $articles->appends('limit', $limit); } return view('search.show', compact('articles', 'keyword')); }
php
public function show() { $keyword = request('q'); $articles = []; $limit = abs(request('limit', config('site.limit', 10))); $max_limit = config('site.max_limit', 100); if ($limit > $max_limit) { $limit = $max_limit; } if ($keyword) { $articles = $this->engine->search($keyword, $limit); $articles->appends('q', $keyword); $articles->appends('limit', $limit); } return view('search.show', compact('articles', 'keyword')); }
[ "public", "function", "show", "(", ")", "{", "$", "keyword", "=", "request", "(", "'q'", ")", ";", "$", "articles", "=", "[", "]", ";", "$", "limit", "=", "abs", "(", "request", "(", "'limit'", ",", "config", "(", "'site.limit'", ",", "10", ")", ...
Display search results. @param string $keyword @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "Display", "search", "results", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/SearchController.php#L31-L49
train
yajra/cms-core
src/Http/Controllers/WidgetsController.php
WidgetsController.create
public function create(Widget $widget) { $widget->extension_id = old('extension_id', Extension::WIDGET_WYSIWYG); $widget->template = old('template', 'widgets.wysiwyg.raw'); $widget->published = old('published', true); return view('administrator.widgets.create', compact('widget')); }
php
public function create(Widget $widget) { $widget->extension_id = old('extension_id', Extension::WIDGET_WYSIWYG); $widget->template = old('template', 'widgets.wysiwyg.raw'); $widget->published = old('published', true); return view('administrator.widgets.create', compact('widget')); }
[ "public", "function", "create", "(", "Widget", "$", "widget", ")", "{", "$", "widget", "->", "extension_id", "=", "old", "(", "'extension_id'", ",", "Extension", "::", "WIDGET_WYSIWYG", ")", ";", "$", "widget", "->", "template", "=", "old", "(", "'template...
Show widget form. @param \Yajra\CMS\Entities\Widget $widget @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "Show", "widget", "form", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/WidgetsController.php#L55-L62
train
yajra/cms-core
src/Http/Controllers/WidgetsController.php
WidgetsController.store
public function store(WidgetFormRequest $request) { $widget = new Widget; $widget->fill($request->all()); $widget->published = $request->get('published', false); $widget->authenticated = $request->get('authenticated', false); $widget->show_title = $request->get('show_title', false); $widget->save(); $widget->syncPermissions($request->get('permissions', [])); $widget->syncMenuAssignment($request->get('menu', []), $request->get('assignment', Widget::ALL_PAGES)); flash()->success(trans('cms::widget.store.success')); return redirect()->route('administrator.widgets.index'); }
php
public function store(WidgetFormRequest $request) { $widget = new Widget; $widget->fill($request->all()); $widget->published = $request->get('published', false); $widget->authenticated = $request->get('authenticated', false); $widget->show_title = $request->get('show_title', false); $widget->save(); $widget->syncPermissions($request->get('permissions', [])); $widget->syncMenuAssignment($request->get('menu', []), $request->get('assignment', Widget::ALL_PAGES)); flash()->success(trans('cms::widget.store.success')); return redirect()->route('administrator.widgets.index'); }
[ "public", "function", "store", "(", "WidgetFormRequest", "$", "request", ")", "{", "$", "widget", "=", "new", "Widget", ";", "$", "widget", "->", "fill", "(", "$", "request", "->", "all", "(", ")", ")", ";", "$", "widget", "->", "published", "=", "$"...
Store a newly created widget. @param \Yajra\CMS\Http\Requests\WidgetFormRequest $request @return \Illuminate\Http\RedirectResponse
[ "Store", "a", "newly", "created", "widget", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/WidgetsController.php#L70-L85
train
yajra/cms-core
src/Http/Controllers/WidgetsController.php
WidgetsController.edit
public function edit(Widget $widget) { $widget->type = old('type', $widget->type); $widget->template = old('template', $widget->template); return view('administrator.widgets.edit', compact('widget')); }
php
public function edit(Widget $widget) { $widget->type = old('type', $widget->type); $widget->template = old('template', $widget->template); return view('administrator.widgets.edit', compact('widget')); }
[ "public", "function", "edit", "(", "Widget", "$", "widget", ")", "{", "$", "widget", "->", "type", "=", "old", "(", "'type'", ",", "$", "widget", "->", "type", ")", ";", "$", "widget", "->", "template", "=", "old", "(", "'template'", ",", "$", "wid...
Show and edit selected widget. @param \Yajra\CMS\Entities\Widget $widget @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
[ "Show", "and", "edit", "selected", "widget", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/WidgetsController.php#L93-L99
train
yajra/cms-core
src/Http/Controllers/WidgetsController.php
WidgetsController.templates
public function templates($type) { $data = []; $extension = $this->repository->findOrFail($type); foreach ($extension->param('templates') as $template) { $data[] = ['key' => $template['path'], 'value' => $template['description']]; } return response()->json([ 'template' => $data[0]['key'], 'selected' => $type, 'data' => $data, ], 200); }
php
public function templates($type) { $data = []; $extension = $this->repository->findOrFail($type); foreach ($extension->param('templates') as $template) { $data[] = ['key' => $template['path'], 'value' => $template['description']]; } return response()->json([ 'template' => $data[0]['key'], 'selected' => $type, 'data' => $data, ], 200); }
[ "public", "function", "templates", "(", "$", "type", ")", "{", "$", "data", "=", "[", "]", ";", "$", "extension", "=", "$", "this", "->", "repository", "->", "findOrFail", "(", "$", "type", ")", ";", "foreach", "(", "$", "extension", "->", "param", ...
Get all widget types. @param string $type @return string
[ "Get", "all", "widget", "types", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/WidgetsController.php#L161-L174
train
yajra/cms-core
src/Http/Controllers/WidgetsController.php
WidgetsController.parameters
public function parameters($id, $widget) { $widget = Widget::withoutGlobalScope('menu_assignment')->findOrNew($widget); $extension = $this->repository->findOrFail($id); $formView = $extension->param('form'); if (view()->exists($formView)) { return view($formView, compact('widget')); } return view('widgets.partials.none'); }
php
public function parameters($id, $widget) { $widget = Widget::withoutGlobalScope('menu_assignment')->findOrNew($widget); $extension = $this->repository->findOrFail($id); $formView = $extension->param('form'); if (view()->exists($formView)) { return view($formView, compact('widget')); } return view('widgets.partials.none'); }
[ "public", "function", "parameters", "(", "$", "id", ",", "$", "widget", ")", "{", "$", "widget", "=", "Widget", "::", "withoutGlobalScope", "(", "'menu_assignment'", ")", "->", "findOrNew", "(", "$", "widget", ")", ";", "$", "extension", "=", "$", "this"...
Get widget custom parameter form if any. @param int $id @param int $widget @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
[ "Get", "widget", "custom", "parameter", "form", "if", "any", "." ]
50e6a03a6b3c5dd0884509d151825dfa51d7e406
https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/WidgetsController.php#L183-L194
train
siphoc/PdfBundle
Converter/CssToHTML.php
CssToHTML.createStylesheetPaths
public function createStylesheetPaths(array $stylesheets) { $sheets = array(); foreach ($stylesheets as $key => $sheet) { if (!$this->isExternalStylesheet($sheet)) { // assetic version removal $sheet = str_replace(strrchr($sheet, 'css?'), 'css', $sheet); $sheet = $this->getBasePath() . $sheet; } $sheets[] = $sheet; } return $sheets; }
php
public function createStylesheetPaths(array $stylesheets) { $sheets = array(); foreach ($stylesheets as $key => $sheet) { if (!$this->isExternalStylesheet($sheet)) { // assetic version removal $sheet = str_replace(strrchr($sheet, 'css?'), 'css', $sheet); $sheet = $this->getBasePath() . $sheet; } $sheets[] = $sheet; } return $sheets; }
[ "public", "function", "createStylesheetPaths", "(", "array", "$", "stylesheets", ")", "{", "$", "sheets", "=", "array", "(", ")", ";", "foreach", "(", "$", "stylesheets", "as", "$", "key", "=>", "$", "sheet", ")", "{", "if", "(", "!", "$", "this", "-...
Check if a stylesheet is a local stylesheet or an external stylesheet. If it is a local stylesheet, prepend our basepath to the link so we can properly fetch the data to insert. @param array $stylesheets @return array
[ "Check", "if", "a", "stylesheet", "is", "a", "local", "stylesheet", "or", "an", "external", "stylesheet", ".", "If", "it", "is", "a", "local", "stylesheet", "prepend", "our", "basepath", "to", "the", "link", "so", "we", "can", "properly", "fetch", "the", ...
89fcc6974158069a4e97b9a8cba2587b9c9b8ce0
https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Converter/CssToHTML.php#L75-L90
train
siphoc/PdfBundle
Converter/CssToHTML.php
CssToHTML.getStylesheetContent
private function getStylesheetContent($path) { if ($this->isExternalStylesheet($path)) { $cssData = $this->getRequestHandler()->getContent($path); } else { if (file_exists($path)) { $cssData = file_get_contents($path); } else { return; } } $cssData = $this->replaceLocalUrlTags($cssData); return "<style type=\"text/css\">\n" . $cssData . '</style>'; }
php
private function getStylesheetContent($path) { if ($this->isExternalStylesheet($path)) { $cssData = $this->getRequestHandler()->getContent($path); } else { if (file_exists($path)) { $cssData = file_get_contents($path); } else { return; } } $cssData = $this->replaceLocalUrlTags($cssData); return "<style type=\"text/css\">\n" . $cssData . '</style>'; }
[ "private", "function", "getStylesheetContent", "(", "$", "path", ")", "{", "if", "(", "$", "this", "->", "isExternalStylesheet", "(", "$", "path", ")", ")", "{", "$", "cssData", "=", "$", "this", "->", "getRequestHandler", "(", ")", "->", "getContent", "...
Retrieve the contents from a CSS file. @param string $path @return string
[ "Retrieve", "the", "contents", "from", "a", "CSS", "file", "." ]
89fcc6974158069a4e97b9a8cba2587b9c9b8ce0
https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Converter/CssToHTML.php#L108-L123
train
nattreid/cms
src/Control/presenters/SignPresenter.php
SignPresenter.actionForgottenPassword
public function actionForgottenPassword(): void { $session = $this->getSession('cms/forgottenPassword'); if ($session->count >= self::MAX_TRY) { $this->flashNotifier->warning('cms.user.restorePasswordDisabledForHour'); $this->redirect(":{$this->module}:Sign:in"); } }
php
public function actionForgottenPassword(): void { $session = $this->getSession('cms/forgottenPassword'); if ($session->count >= self::MAX_TRY) { $this->flashNotifier->warning('cms.user.restorePasswordDisabledForHour'); $this->redirect(":{$this->module}:Sign:in"); } }
[ "public", "function", "actionForgottenPassword", "(", ")", ":", "void", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", "'cms/forgottenPassword'", ")", ";", "if", "(", "$", "session", "->", "count", ">=", "self", "::", "MAX_TRY", ")", "{", ...
Obnoveni hesla je mozno jen trikrat do hodiny @throws AbortException
[ "Obnoveni", "hesla", "je", "mozno", "jen", "trikrat", "do", "hodiny" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/SignPresenter.php#L101-L108
train
nattreid/cms
src/Control/presenters/SignPresenter.php
SignPresenter.signInFormSucceeded
public function signInFormSucceeded(Form $form, ArrayHash $values) { try { $this->user->login($values->username, $values->password); if ($values->remember) { $this->user->setExpiration('+ ' . $this->sessionExpiration, false); } else { $this->user->setExpiration('+ ' . $this->loginExpiration, true); } $this->restoreRequest($this->backlink); $this->redirect(":{$this->module}:Homepage:"); } catch (AuthenticationException $e) { if ($e->getCode() == IAuthenticator::NOT_APPROVED) { $form->addError('cms.user.accountDeactivated'); } else { $form->addError('cms.user.incorrectUsernameOrPassword'); } } }
php
public function signInFormSucceeded(Form $form, ArrayHash $values) { try { $this->user->login($values->username, $values->password); if ($values->remember) { $this->user->setExpiration('+ ' . $this->sessionExpiration, false); } else { $this->user->setExpiration('+ ' . $this->loginExpiration, true); } $this->restoreRequest($this->backlink); $this->redirect(":{$this->module}:Homepage:"); } catch (AuthenticationException $e) { if ($e->getCode() == IAuthenticator::NOT_APPROVED) { $form->addError('cms.user.accountDeactivated'); } else { $form->addError('cms.user.incorrectUsernameOrPassword'); } } }
[ "public", "function", "signInFormSucceeded", "(", "Form", "$", "form", ",", "ArrayHash", "$", "values", ")", "{", "try", "{", "$", "this", "->", "user", "->", "login", "(", "$", "values", "->", "username", ",", "$", "values", "->", "password", ")", ";"...
Zpracovani prihlasovaciho formulare @param Form $form @param ArrayHash $values @throws AbortException
[ "Zpracovani", "prihlasovaciho", "formulare" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/SignPresenter.php#L158-L176
train
nattreid/cms
src/Control/presenters/SignPresenter.php
SignPresenter.createComponentForgottenPasswordForm
protected function createComponentForgottenPasswordForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addText('usernameOrEmail', 'cms.user.usernameOrEmail') ->setRequired(); $form->addSubmit('send', 'form.send'); $form->addLink('back', 'form.back', $this->link('in')); $form->onSuccess[] = [$this, 'forgottenPasswordFormSucceeded']; return $form; }
php
protected function createComponentForgottenPasswordForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addText('usernameOrEmail', 'cms.user.usernameOrEmail') ->setRequired(); $form->addSubmit('send', 'form.send'); $form->addLink('back', 'form.back', $this->link('in')); $form->onSuccess[] = [$this, 'forgottenPasswordFormSucceeded']; return $form; }
[ "protected", "function", "createComponentForgottenPasswordForm", "(", ")", ":", "Form", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", ")", ";", "$", "form", "->", "addProtection", "(", ")", ";", "$", "form", "->", "addText",...
Formular pro zapomenute heslo @return Form @throws \Nette\Application\UI\InvalidLinkException
[ "Formular", "pro", "zapomenute", "heslo" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/SignPresenter.php#L183-L198
train
nattreid/cms
src/Control/presenters/SignPresenter.php
SignPresenter.forgottenPasswordFormSucceeded
public function forgottenPasswordFormSucceeded(Form $form, ArrayHash $values): void { $value = $values->usernameOrEmail; $user = $this->orm->users->getByUsername($value); if (!$user) { $user = $this->orm->users->getByEmail($value); if (!$user) { $form->addError('cms.user.incorrectUsernameOrEmail'); $session = $this->getSession('cms/forgottenPassword'); if (isset($session->count)) { $session->count++; } else { $session->setExpiration('1 hours'); $session->count = 1; } $this->actionForgottenPassword(); return; } } $hash = $this->hasher->hash(Random::generate()); $session = $this->getSession('cms/restorePassword'); $session->setExpiration('1 hours'); $session->$hash = $user->email; $this->mailer->sendRestorePassword($user->email, $hash); $this->flashNotifier->info('cms.user.mailToRestorePasswordSent'); $this->redirect(":{$this->module}:Sign:in"); }
php
public function forgottenPasswordFormSucceeded(Form $form, ArrayHash $values): void { $value = $values->usernameOrEmail; $user = $this->orm->users->getByUsername($value); if (!$user) { $user = $this->orm->users->getByEmail($value); if (!$user) { $form->addError('cms.user.incorrectUsernameOrEmail'); $session = $this->getSession('cms/forgottenPassword'); if (isset($session->count)) { $session->count++; } else { $session->setExpiration('1 hours'); $session->count = 1; } $this->actionForgottenPassword(); return; } } $hash = $this->hasher->hash(Random::generate()); $session = $this->getSession('cms/restorePassword'); $session->setExpiration('1 hours'); $session->$hash = $user->email; $this->mailer->sendRestorePassword($user->email, $hash); $this->flashNotifier->info('cms.user.mailToRestorePasswordSent'); $this->redirect(":{$this->module}:Sign:in"); }
[ "public", "function", "forgottenPasswordFormSucceeded", "(", "Form", "$", "form", ",", "ArrayHash", "$", "values", ")", ":", "void", "{", "$", "value", "=", "$", "values", "->", "usernameOrEmail", ";", "$", "user", "=", "$", "this", "->", "orm", "->", "u...
Zpracovani formulare pro zapomenute heslo @param Form $form @param ArrayHash $values @throws AbortException @throws \Nette\Application\UI\InvalidLinkException
[ "Zpracovani", "formulare", "pro", "zapomenute", "heslo" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/SignPresenter.php#L207-L236
train
nattreid/cms
src/Control/presenters/SignPresenter.php
SignPresenter.createComponentRestorePasswordForm
protected function createComponentRestorePasswordForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addHidden('hash'); $form->addPassword('password', 'cms.user.newPassword') ->setRequired() ->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength); $form->addPassword('passwordVerify', 'cms.user.passwordVerify') ->setRequired() ->addRule(Form::EQUAL, null, $form['password']); $form->addSubmit('restore', 'form.save'); $form->onSuccess[] = [$this, 'restorePasswordFormSucceeded']; return $form; }
php
protected function createComponentRestorePasswordForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addHidden('hash'); $form->addPassword('password', 'cms.user.newPassword') ->setRequired() ->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength); $form->addPassword('passwordVerify', 'cms.user.passwordVerify') ->setRequired() ->addRule(Form::EQUAL, null, $form['password']); $form->addSubmit('restore', 'form.save'); $form->onSuccess[] = [$this, 'restorePasswordFormSucceeded']; return $form; }
[ "protected", "function", "createComponentRestorePasswordForm", "(", ")", ":", "Form", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", ")", ";", "$", "form", "->", "addProtection", "(", ")", ";", "$", "form", "->", "addHidden",...
Formular pro obnoveni hesla @return Form
[ "Formular", "pro", "obnoveni", "hesla" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/SignPresenter.php#L242-L261
train
nattreid/cms
src/Control/presenters/SignPresenter.php
SignPresenter.restorePasswordFormSucceeded
public function restorePasswordFormSucceeded(Form $form, ArrayHash $values): void { $session = $this->getSession('cms/restorePassword'); $email = $session->{$values->hash}; $session->remove(); $user = $this->orm->users->getByEmail($email); if ($user) { $user->setPassword($values->password); $this->orm->persistAndFlush($user); $this->flashNotifier->success('cms.user.passwordChanged'); } else { $this->flashNotifier->error('cms.permissions.accessDenied'); } $this->redirect(":{$this->module}:Sign:in"); }
php
public function restorePasswordFormSucceeded(Form $form, ArrayHash $values): void { $session = $this->getSession('cms/restorePassword'); $email = $session->{$values->hash}; $session->remove(); $user = $this->orm->users->getByEmail($email); if ($user) { $user->setPassword($values->password); $this->orm->persistAndFlush($user); $this->flashNotifier->success('cms.user.passwordChanged'); } else { $this->flashNotifier->error('cms.permissions.accessDenied'); } $this->redirect(":{$this->module}:Sign:in"); }
[ "public", "function", "restorePasswordFormSucceeded", "(", "Form", "$", "form", ",", "ArrayHash", "$", "values", ")", ":", "void", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", "'cms/restorePassword'", ")", ";", "$", "email", "=", "$", "s...
Zpracovani formulare pro obnoveni hesla @param Form $form @param ArrayHash $values @throws AuthenticationException @throws AbortException
[ "Zpracovani", "formulare", "pro", "obnoveni", "hesla" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/SignPresenter.php#L270-L285
train
nattreid/cms
src/Control/presenters/SignPresenter.php
SignPresenter.createComponentRegisterAdministratorForm
protected function createComponentRegisterAdministratorForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addText('username', 'cms.user.username') ->setRequired(); $form->addText('firstName', 'cms.user.firstName'); $form->addText('surname', 'cms.user.surname'); $form->addText('email', 'cms.user.email') ->setRequired() ->addRule(Form::EMAIL); $form->addPassword('password', 'cms.user.newPassword') ->setRequired() ->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength); $form->addPassword('passwordVerify', 'cms.user.passwordVerify') ->setRequired() ->addRule(Form::EQUAL, null, $form['password']); $form->addSubmit('create', 'form.save'); $form->onSuccess[] = [$this, 'registerAdministratorFormSucceeded']; return $form; }
php
protected function createComponentRegisterAdministratorForm(): Form { $form = $this->formFactory->create(); $form->addProtection(); $form->addText('username', 'cms.user.username') ->setRequired(); $form->addText('firstName', 'cms.user.firstName'); $form->addText('surname', 'cms.user.surname'); $form->addText('email', 'cms.user.email') ->setRequired() ->addRule(Form::EMAIL); $form->addPassword('password', 'cms.user.newPassword') ->setRequired() ->addRule(Form::MIN_LENGTH, null, $this->minPasswordLength); $form->addPassword('passwordVerify', 'cms.user.passwordVerify') ->setRequired() ->addRule(Form::EQUAL, null, $form['password']); $form->addSubmit('create', 'form.save'); $form->onSuccess[] = [$this, 'registerAdministratorFormSucceeded']; return $form; }
[ "protected", "function", "createComponentRegisterAdministratorForm", "(", ")", ":", "Form", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", ")", ";", "$", "form", "->", "addProtection", "(", ")", ";", "$", "form", "->", "addTe...
Formular pro prvniho uzivatele @return Form
[ "Formular", "pro", "prvniho", "uzivatele" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/SignPresenter.php#L291-L316
train
nattreid/cms
src/Control/presenters/SignPresenter.php
SignPresenter.registerAdministratorFormSucceeded
public function registerAdministratorFormSucceeded(Form $form, ArrayHash $values): void { $password = $values->password; $role = $this->orm->aclRoles->getByName(AclRolesMapper::SUPERADMIN); $user = new User; $user->firstName = $values->firstName; $user->surname = $values->surname; $user->email = $values->email; $user->username = $values->username; $user->setPassword($password); $user->roles->add($role); $this->orm->persistAndFlush($user); $this->user->setExpiration('+ ' . $this->loginExpiration, true); $this->user->login($values->username, $password); $this->flashNotifier->success('cms.user.dataSaved'); $this->redirect(":{$this->module}:Homepage:"); }
php
public function registerAdministratorFormSucceeded(Form $form, ArrayHash $values): void { $password = $values->password; $role = $this->orm->aclRoles->getByName(AclRolesMapper::SUPERADMIN); $user = new User; $user->firstName = $values->firstName; $user->surname = $values->surname; $user->email = $values->email; $user->username = $values->username; $user->setPassword($password); $user->roles->add($role); $this->orm->persistAndFlush($user); $this->user->setExpiration('+ ' . $this->loginExpiration, true); $this->user->login($values->username, $password); $this->flashNotifier->success('cms.user.dataSaved'); $this->redirect(":{$this->module}:Homepage:"); }
[ "public", "function", "registerAdministratorFormSucceeded", "(", "Form", "$", "form", ",", "ArrayHash", "$", "values", ")", ":", "void", "{", "$", "password", "=", "$", "values", "->", "password", ";", "$", "role", "=", "$", "this", "->", "orm", "->", "a...
Zpracovani formulare pro prvniho uzivatele @param Form $form @param ArrayHash $values @throws AuthenticationException @throws AbortException
[ "Zpracovani", "formulare", "pro", "prvniho", "uzivatele" ]
28eae564c6a8cdaf01d32ff5a1dffba58232f9c1
https://github.com/nattreid/cms/blob/28eae564c6a8cdaf01d32ff5a1dffba58232f9c1/src/Control/presenters/SignPresenter.php#L325-L347
train
thelia/core
lib/Thelia/Action/Message.php
Message.create
public function create(MessageCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $message = new MessageModel(); $message ->setDispatcher($dispatcher) ->setName($event->getMessageName()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) ->setSecured($event->getSecured()) ->save() ; $event->setMessage($message); }
php
public function create(MessageCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $message = new MessageModel(); $message ->setDispatcher($dispatcher) ->setName($event->getMessageName()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) ->setSecured($event->getSecured()) ->save() ; $event->setMessage($message); }
[ "public", "function", "create", "(", "MessageCreateEvent", "$", "event", ",", "$", "eventName", ",", "EventDispatcherInterface", "$", "dispatcher", ")", "{", "$", "message", "=", "new", "MessageModel", "(", ")", ";", "$", "message", "->", "setDispatcher", "(",...
Create a new messageuration entry @param \Thelia\Core\Event\Message\MessageCreateEvent $event @param $eventName @param EventDispatcherInterface $dispatcher
[ "Create", "a", "new", "messageuration", "entry" ]
38fbe7d5046bad6c0af9ea7c686b4655e8d84e67
https://github.com/thelia/core/blob/38fbe7d5046bad6c0af9ea7c686b4655e8d84e67/lib/Thelia/Action/Message.php#L33-L49
train