id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
8,600
hgraca/php-helper
src/ClassHelper.php
ClassHelper.getReflectionProperty
public static function getReflectionProperty(ReflectionClass $class, string $propertyName): ReflectionProperty { try { return $class->getProperty($propertyName); } catch (ReflectionException $e) { $parentClass = $class->getParentClass(); if ($parentClass === false) { throw $e; } return self::getReflectionProperty($parentClass, $propertyName); } }
php
public static function getReflectionProperty(ReflectionClass $class, string $propertyName): ReflectionProperty { try { return $class->getProperty($propertyName); } catch (ReflectionException $e) { $parentClass = $class->getParentClass(); if ($parentClass === false) { throw $e; } return self::getReflectionProperty($parentClass, $propertyName); } }
[ "public", "static", "function", "getReflectionProperty", "(", "ReflectionClass", "$", "class", ",", "string", "$", "propertyName", ")", ":", "ReflectionProperty", "{", "try", "{", "return", "$", "class", "->", "getProperty", "(", "$", "propertyName", ")", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "$", "parentClass", "=", "$", "class", "->", "getParentClass", "(", ")", ";", "if", "(", "$", "parentClass", "===", "false", ")", "{", "throw", "$", "e", ";", "}", "return", "self", "::", "getReflectionProperty", "(", "$", "parentClass", ",", "$", "propertyName", ")", ";", "}", "}" ]
Gets the property from the current class, when not available will look on parent classes before failing @throws ReflectionException @return ReflectionProperty
[ "Gets", "the", "property", "from", "the", "current", "class", "when", "not", "available", "will", "look", "on", "parent", "classes", "before", "failing" ]
62b965b76d9116258142911ac7e154411df6009b
https://github.com/hgraca/php-helper/blob/62b965b76d9116258142911ac7e154411df6009b/src/ClassHelper.php#L117-L129
8,601
clacy-builders/calendar-php
src/Calendar.php
Calendar.setFirstWeekday
public function setFirstWeekday($firstWeekday = 0) { $this->firstWeekday = is_string($firstWeekday) ? self::firstWeekday($firstWeekday) : $firstWeekday; $this->buildWeekdays = true; return $this; }
php
public function setFirstWeekday($firstWeekday = 0) { $this->firstWeekday = is_string($firstWeekday) ? self::firstWeekday($firstWeekday) : $firstWeekday; $this->buildWeekdays = true; return $this; }
[ "public", "function", "setFirstWeekday", "(", "$", "firstWeekday", "=", "0", ")", "{", "$", "this", "->", "firstWeekday", "=", "is_string", "(", "$", "firstWeekday", ")", "?", "self", "::", "firstWeekday", "(", "$", "firstWeekday", ")", ":", "$", "firstWeekday", ";", "$", "this", "->", "buildWeekdays", "=", "true", ";", "return", "$", "this", ";", "}" ]
Sets the first day of the week in a calendar page view. @link http://unicode.org/repos/cldr/trunk/common/supplemental/supplementalData.xml @param int|string $firstWeekday 0 (for Monday) through 6 (for Sunday) or an ISO 3166 country code for example <code>BR</code> for Brazil, <code>SE</code> for Sweden. @return Calendar
[ "Sets", "the", "first", "day", "of", "the", "week", "in", "a", "calendar", "page", "view", "." ]
9e868c4fa37f6c81da0e7444a8e0da25cc6c9051
https://github.com/clacy-builders/calendar-php/blob/9e868c4fa37f6c81da0e7444a8e0da25cc6c9051/src/Calendar.php#L168-L175
8,602
imsamurai/array-object-advanced
Utility/ArrayObjectA.php
ArrayObjectA.map
public function map(callable $callback) { $that = clone $this; foreach ($that->getIterator() as $index => $item) { $that->offsetSet($index, $callback($item)); } return $that; }
php
public function map(callable $callback) { $that = clone $this; foreach ($that->getIterator() as $index => $item) { $that->offsetSet($index, $callback($item)); } return $that; }
[ "public", "function", "map", "(", "callable", "$", "callback", ")", "{", "$", "that", "=", "clone", "$", "this", ";", "foreach", "(", "$", "that", "->", "getIterator", "(", ")", "as", "$", "index", "=>", "$", "item", ")", "{", "$", "that", "->", "offsetSet", "(", "$", "index", ",", "$", "callback", "(", "$", "item", ")", ")", ";", "}", "return", "$", "that", ";", "}" ]
Apply callback to each element of array @param callable $callback @return \ArrayObjectA
[ "Apply", "callback", "to", "each", "element", "of", "array" ]
240dddf0c123be76f1e1cec08327f848a49f3f55
https://github.com/imsamurai/array-object-advanced/blob/240dddf0c123be76f1e1cec08327f848a49f3f55/Utility/ArrayObjectA.php#L36-L42
8,603
imsamurai/array-object-advanced
Utility/ArrayObjectA.php
ArrayObjectA.group
public function group(callable $callback) { $array = array(); foreach ($this->getIterator() as $index => $item) { $group = $callback($item); $array[$group][] = $item; } return new static($array); }
php
public function group(callable $callback) { $array = array(); foreach ($this->getIterator() as $index => $item) { $group = $callback($item); $array[$group][] = $item; } return new static($array); }
[ "public", "function", "group", "(", "callable", "$", "callback", ")", "{", "$", "array", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getIterator", "(", ")", "as", "$", "index", "=>", "$", "item", ")", "{", "$", "group", "=", "$", "callback", "(", "$", "item", ")", ";", "$", "array", "[", "$", "group", "]", "[", "]", "=", "$", "item", ";", "}", "return", "new", "static", "(", "$", "array", ")", ";", "}" ]
Group elements of array @param callable $callback @return \ArrayObjectA
[ "Group", "elements", "of", "array" ]
240dddf0c123be76f1e1cec08327f848a49f3f55
https://github.com/imsamurai/array-object-advanced/blob/240dddf0c123be76f1e1cec08327f848a49f3f55/Utility/ArrayObjectA.php#L73-L80
8,604
reflex-php/lockdown
src/Reflex/Lockdown/Roles/Eloquent/Role.php
Role.getPermission
public function getPermission($permission) { if ($permission instanceof PermissionInterface) { $permission = $permission->key; } return $this->permissions() ->key($permission) ->first(); }
php
public function getPermission($permission) { if ($permission instanceof PermissionInterface) { $permission = $permission->key; } return $this->permissions() ->key($permission) ->first(); }
[ "public", "function", "getPermission", "(", "$", "permission", ")", "{", "if", "(", "$", "permission", "instanceof", "PermissionInterface", ")", "{", "$", "permission", "=", "$", "permission", "->", "key", ";", "}", "return", "$", "this", "->", "permissions", "(", ")", "->", "key", "(", "$", "permission", ")", "->", "first", "(", ")", ";", "}" ]
Get the actual permission @param string $permission Permission name/key @return Model|Builder|null
[ "Get", "the", "actual", "permission" ]
2798e448608eef469f2924d75013deccfd6aca44
https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Roles/Eloquent/Role.php#L77-L86
8,605
reflex-php/lockdown
src/Reflex/Lockdown/Roles/Eloquent/Role.php
Role.give
public function give(PermissionInterface $permission, $level = 'allow') { $current = $this->getPermission($permission->key); if (isset($current)) { if ($current->level === $level) { return true; } $this->remove($permission); } $this->cache($permission->key, null); $this->permissions() ->attach($permission, compact('level')); return ! is_null($this->getPermission($permission)); }
php
public function give(PermissionInterface $permission, $level = 'allow') { $current = $this->getPermission($permission->key); if (isset($current)) { if ($current->level === $level) { return true; } $this->remove($permission); } $this->cache($permission->key, null); $this->permissions() ->attach($permission, compact('level')); return ! is_null($this->getPermission($permission)); }
[ "public", "function", "give", "(", "PermissionInterface", "$", "permission", ",", "$", "level", "=", "'allow'", ")", "{", "$", "current", "=", "$", "this", "->", "getPermission", "(", "$", "permission", "->", "key", ")", ";", "if", "(", "isset", "(", "$", "current", ")", ")", "{", "if", "(", "$", "current", "->", "level", "===", "$", "level", ")", "{", "return", "true", ";", "}", "$", "this", "->", "remove", "(", "$", "permission", ")", ";", "}", "$", "this", "->", "cache", "(", "$", "permission", "->", "key", ",", "null", ")", ";", "$", "this", "->", "permissions", "(", ")", "->", "attach", "(", "$", "permission", ",", "compact", "(", "'level'", ")", ")", ";", "return", "!", "is_null", "(", "$", "this", "->", "getPermission", "(", "$", "permission", ")", ")", ";", "}" ]
Give role a permission @param \Reflex\Lockdown\Permissions\PermissionInterface $permission Permission instance @param string $level Level @return boolean
[ "Give", "role", "a", "permission" ]
2798e448608eef469f2924d75013deccfd6aca44
https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Roles/Eloquent/Role.php#L96-L110
8,606
reflex-php/lockdown
src/Reflex/Lockdown/Roles/Eloquent/Role.php
Role.remove
public function remove(PermissionInterface $permission) { $this->cache($permission->key, null); if (! is_null($this->getPermission($permission))) { $this->permissions() ->detach($permission); } return true; }
php
public function remove(PermissionInterface $permission) { $this->cache($permission->key, null); if (! is_null($this->getPermission($permission))) { $this->permissions() ->detach($permission); } return true; }
[ "public", "function", "remove", "(", "PermissionInterface", "$", "permission", ")", "{", "$", "this", "->", "cache", "(", "$", "permission", "->", "key", ",", "null", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "getPermission", "(", "$", "permission", ")", ")", ")", "{", "$", "this", "->", "permissions", "(", ")", "->", "detach", "(", "$", "permission", ")", ";", "}", "return", "true", ";", "}" ]
Remove a permission from this role @param \Reflex\Lockdown\Permisssions\PermissionInterface $permission Permission instance @return boolean
[ "Remove", "a", "permission", "from", "this", "role" ]
2798e448608eef469f2924d75013deccfd6aca44
https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Roles/Eloquent/Role.php#L118-L128
8,607
titon/model
src/Titon/Model/Relation/ManyToMany.php
ManyToMany.deleteDependents
public function deleteDependents(Event $event, $ids, $count) { $pfk = $this->getPrimaryForeignKey(); $this->getJunctionRepository()->deleteMany(function(Query $query) use ($pfk, $ids) { $query->where($pfk, $ids); }); }
php
public function deleteDependents(Event $event, $ids, $count) { $pfk = $this->getPrimaryForeignKey(); $this->getJunctionRepository()->deleteMany(function(Query $query) use ($pfk, $ids) { $query->where($pfk, $ids); }); }
[ "public", "function", "deleteDependents", "(", "Event", "$", "event", ",", "$", "ids", ",", "$", "count", ")", "{", "$", "pfk", "=", "$", "this", "->", "getPrimaryForeignKey", "(", ")", ";", "$", "this", "->", "getJunctionRepository", "(", ")", "->", "deleteMany", "(", "function", "(", "Query", "$", "query", ")", "use", "(", "$", "pfk", ",", "$", "ids", ")", "{", "$", "query", "->", "where", "(", "$", "pfk", ",", "$", "ids", ")", ";", "}", ")", ";", "}" ]
Delete records found in the junction table, but do not delete records in the foreign table. {@inheritdoc}
[ "Delete", "records", "found", "in", "the", "junction", "table", "but", "do", "not", "delete", "records", "in", "the", "foreign", "table", "." ]
274e3810c2cfbb6818a388daaa462ff05de99cbd
https://github.com/titon/model/blob/274e3810c2cfbb6818a388daaa462ff05de99cbd/src/Titon/Model/Relation/ManyToMany.php#L50-L56
8,608
titon/model
src/Titon/Model/Relation/ManyToMany.php
ManyToMany.getJunctionRepository
public function getJunctionRepository() { if ($repo = $this->_junction) { return $repo; } $this->setJunctionRepository(new Repository($this->getJunction())); return $this->_junction; }
php
public function getJunctionRepository() { if ($repo = $this->_junction) { return $repo; } $this->setJunctionRepository(new Repository($this->getJunction())); return $this->_junction; }
[ "public", "function", "getJunctionRepository", "(", ")", "{", "if", "(", "$", "repo", "=", "$", "this", "->", "_junction", ")", "{", "return", "$", "repo", ";", "}", "$", "this", "->", "setJunctionRepository", "(", "new", "Repository", "(", "$", "this", "->", "getJunction", "(", ")", ")", ")", ";", "return", "$", "this", "->", "_junction", ";", "}" ]
Return the junction repository instance. @return \Titon\Db\Repository
[ "Return", "the", "junction", "repository", "instance", "." ]
274e3810c2cfbb6818a388daaa462ff05de99cbd
https://github.com/titon/model/blob/274e3810c2cfbb6818a388daaa462ff05de99cbd/src/Titon/Model/Relation/ManyToMany.php#L115-L123
8,609
titon/model
src/Titon/Model/Relation/ManyToMany.php
ManyToMany.setJunction
public function setJunction($table) { if (!is_array($table)) { $table = ['table' => $table]; } $this->setConfig('junction', $table); return $this; }
php
public function setJunction($table) { if (!is_array($table)) { $table = ['table' => $table]; } $this->setConfig('junction', $table); return $this; }
[ "public", "function", "setJunction", "(", "$", "table", ")", "{", "if", "(", "!", "is_array", "(", "$", "table", ")", ")", "{", "$", "table", "=", "[", "'table'", "=>", "$", "table", "]", ";", "}", "$", "this", "->", "setConfig", "(", "'junction'", ",", "$", "table", ")", ";", "return", "$", "this", ";", "}" ]
Set the junction table name. @param string|array $table @return $this
[ "Set", "the", "junction", "table", "name", "." ]
274e3810c2cfbb6818a388daaa462ff05de99cbd
https://github.com/titon/model/blob/274e3810c2cfbb6818a388daaa462ff05de99cbd/src/Titon/Model/Relation/ManyToMany.php#L272-L280
8,610
themichaelhall/bluemvc-fakes
src/FakeRequest.php
FakeRequest.parseHeaders
private static function parseHeaders(UrlInterface $url): HeaderCollectionInterface { $result = new HeaderCollection(); $result->set('Host', $url->getHostAndPort()); return $result; }
php
private static function parseHeaders(UrlInterface $url): HeaderCollectionInterface { $result = new HeaderCollection(); $result->set('Host', $url->getHostAndPort()); return $result; }
[ "private", "static", "function", "parseHeaders", "(", "UrlInterface", "$", "url", ")", ":", "HeaderCollectionInterface", "{", "$", "result", "=", "new", "HeaderCollection", "(", ")", ";", "$", "result", "->", "set", "(", "'Host'", ",", "$", "url", "->", "getHostAndPort", "(", ")", ")", ";", "return", "$", "result", ";", "}" ]
Parses a url into a header collection. @param UrlInterface $url The url. @return HeaderCollectionInterface The header collection.
[ "Parses", "a", "url", "into", "a", "header", "collection", "." ]
41641e1981a5ba26f804c231e0e19eb8e5e70084
https://github.com/themichaelhall/bluemvc-fakes/blob/41641e1981a5ba26f804c231e0e19eb8e5e70084/src/FakeRequest.php#L244-L250
8,611
themichaelhall/bluemvc-fakes
src/FakeRequest.php
FakeRequest.parseQueryParameters
private static function parseQueryParameters(?string $queryString): ParameterCollectionInterface { $parameters = new ParameterCollection(); if ($queryString === null) { return $parameters; } parse_str($queryString, $parametersArray); foreach ($parametersArray as $parameterName => $parameterValue) { $parameters->set($parameterName, is_array($parameterValue) ? $parameterValue[0] : $parameterValue); } return $parameters; }
php
private static function parseQueryParameters(?string $queryString): ParameterCollectionInterface { $parameters = new ParameterCollection(); if ($queryString === null) { return $parameters; } parse_str($queryString, $parametersArray); foreach ($parametersArray as $parameterName => $parameterValue) { $parameters->set($parameterName, is_array($parameterValue) ? $parameterValue[0] : $parameterValue); } return $parameters; }
[ "private", "static", "function", "parseQueryParameters", "(", "?", "string", "$", "queryString", ")", ":", "ParameterCollectionInterface", "{", "$", "parameters", "=", "new", "ParameterCollection", "(", ")", ";", "if", "(", "$", "queryString", "===", "null", ")", "{", "return", "$", "parameters", ";", "}", "parse_str", "(", "$", "queryString", ",", "$", "parametersArray", ")", ";", "foreach", "(", "$", "parametersArray", "as", "$", "parameterName", "=>", "$", "parameterValue", ")", "{", "$", "parameters", "->", "set", "(", "$", "parameterName", ",", "is_array", "(", "$", "parameterValue", ")", "?", "$", "parameterValue", "[", "0", "]", ":", "$", "parameterValue", ")", ";", "}", "return", "$", "parameters", ";", "}" ]
Parses a query string into a parameter collection. @param string|null $queryString The query string or null if no query string is set. @return ParameterCollectionInterface The parameter collection.
[ "Parses", "a", "query", "string", "into", "a", "parameter", "collection", "." ]
41641e1981a5ba26f804c231e0e19eb8e5e70084
https://github.com/themichaelhall/bluemvc-fakes/blob/41641e1981a5ba26f804c231e0e19eb8e5e70084/src/FakeRequest.php#L259-L273
8,612
TroRg/php-tokenlink
src/Token.php
Token.load
public static function load(string $token, array $config): Token { $fields = ['id', 'h', 'e']; $params = []; parse_str(self::base64url_decode($token), $params); foreach ($fields as $f) { if (!array_key_exists($f, $params)) { throw new \UnexpectedValueException('"'. $f .'" should exists in token attributes.'); } } $id = Identificator::load($params['id'], $config['idFields']); $token = new Token($id, $config); $token->setHash($params['h']); $token->setExpiration($params['e']); return $token; }
php
public static function load(string $token, array $config): Token { $fields = ['id', 'h', 'e']; $params = []; parse_str(self::base64url_decode($token), $params); foreach ($fields as $f) { if (!array_key_exists($f, $params)) { throw new \UnexpectedValueException('"'. $f .'" should exists in token attributes.'); } } $id = Identificator::load($params['id'], $config['idFields']); $token = new Token($id, $config); $token->setHash($params['h']); $token->setExpiration($params['e']); return $token; }
[ "public", "static", "function", "load", "(", "string", "$", "token", ",", "array", "$", "config", ")", ":", "Token", "{", "$", "fields", "=", "[", "'id'", ",", "'h'", ",", "'e'", "]", ";", "$", "params", "=", "[", "]", ";", "parse_str", "(", "self", "::", "base64url_decode", "(", "$", "token", ")", ",", "$", "params", ")", ";", "foreach", "(", "$", "fields", "as", "$", "f", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "f", ",", "$", "params", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'\"'", ".", "$", "f", ".", "'\" should exists in token attributes.'", ")", ";", "}", "}", "$", "id", "=", "Identificator", "::", "load", "(", "$", "params", "[", "'id'", "]", ",", "$", "config", "[", "'idFields'", "]", ")", ";", "$", "token", "=", "new", "Token", "(", "$", "id", ",", "$", "config", ")", ";", "$", "token", "->", "setHash", "(", "$", "params", "[", "'h'", "]", ")", ";", "$", "token", "->", "setExpiration", "(", "$", "params", "[", "'e'", "]", ")", ";", "return", "$", "token", ";", "}" ]
Create new token from string representation @param string $token raw base64 encoded token @param array $config configuration options like in constructor return Token
[ "Create", "new", "token", "from", "string", "representation" ]
91d5466954d4c53b58a910fef631ab8eaa91ade4
https://github.com/TroRg/php-tokenlink/blob/91d5466954d4c53b58a910fef631ab8eaa91ade4/src/Token.php#L54-L72
8,613
TroRg/php-tokenlink
src/Token.php
Token.generateHash
public function generateHash(): string { $h = sprintf('%s%s%s', (string)$this->getIdentificator(), $this->getExpiration(), $this->getSecret()); $h = md5($h, true); $h = self::base64url_encode($h); return $h; }
php
public function generateHash(): string { $h = sprintf('%s%s%s', (string)$this->getIdentificator(), $this->getExpiration(), $this->getSecret()); $h = md5($h, true); $h = self::base64url_encode($h); return $h; }
[ "public", "function", "generateHash", "(", ")", ":", "string", "{", "$", "h", "=", "sprintf", "(", "'%s%s%s'", ",", "(", "string", ")", "$", "this", "->", "getIdentificator", "(", ")", ",", "$", "this", "->", "getExpiration", "(", ")", ",", "$", "this", "->", "getSecret", "(", ")", ")", ";", "$", "h", "=", "md5", "(", "$", "h", ",", "true", ")", ";", "$", "h", "=", "self", "::", "base64url_encode", "(", "$", "h", ")", ";", "return", "$", "h", ";", "}" ]
Generate new hash for identificator @return string
[ "Generate", "new", "hash", "for", "identificator" ]
91d5466954d4c53b58a910fef631ab8eaa91ade4
https://github.com/TroRg/php-tokenlink/blob/91d5466954d4c53b58a910fef631ab8eaa91ade4/src/Token.php#L156-L162
8,614
TroRg/php-tokenlink
src/Token.php
Token.validate
public function validate() { if (time() > $this->getExpiration()) { throw new exceptions\TokenExpiredException('Token is expired.'); } if ($this->getHash() != $this->generateHash()) { throw new exceptions\InvalidHashException('Invalid token hash.'); } }
php
public function validate() { if (time() > $this->getExpiration()) { throw new exceptions\TokenExpiredException('Token is expired.'); } if ($this->getHash() != $this->generateHash()) { throw new exceptions\InvalidHashException('Invalid token hash.'); } }
[ "public", "function", "validate", "(", ")", "{", "if", "(", "time", "(", ")", ">", "$", "this", "->", "getExpiration", "(", ")", ")", "{", "throw", "new", "exceptions", "\\", "TokenExpiredException", "(", "'Token is expired.'", ")", ";", "}", "if", "(", "$", "this", "->", "getHash", "(", ")", "!=", "$", "this", "->", "generateHash", "(", ")", ")", "{", "throw", "new", "exceptions", "\\", "InvalidHashException", "(", "'Invalid token hash.'", ")", ";", "}", "}" ]
Validate token, usually used only when token is loaded from string representation.
[ "Validate", "token", "usually", "used", "only", "when", "token", "is", "loaded", "from", "string", "representation", "." ]
91d5466954d4c53b58a910fef631ab8eaa91ade4
https://github.com/TroRg/php-tokenlink/blob/91d5466954d4c53b58a910fef631ab8eaa91ade4/src/Token.php#L187-L195
8,615
magdev/php-assimp
src/Command/Verbs/Traits/ParameterTrait.php
ParameterTrait.setParameters
public function setParameters(array $params) { foreach ($params as $name => $value) { $this->getParameterContainer()->add($name, $value); } return $this; }
php
public function setParameters(array $params) { foreach ($params as $name => $value) { $this->getParameterContainer()->add($name, $value); } return $this; }
[ "public", "function", "setParameters", "(", "array", "$", "params", ")", "{", "foreach", "(", "$", "params", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "getParameterContainer", "(", ")", "->", "add", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set multiple parameters @param array $params @return \Assimp\Command\Verbs\ExportVerb @deprecated Use ParameterContainer methods
[ "Set", "multiple", "parameters" ]
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Verbs/Traits/ParameterTrait.php#L81-L87
8,616
magdev/php-assimp
src/Command/Verbs/Traits/ParameterTrait.php
ParameterTrait.getParameters
public function getParameters($asString = false) { if ($asString) { $str = (string) $this->getParameterContainer(); return $str; } return $this->getParameterContainer()->all(); }
php
public function getParameters($asString = false) { if ($asString) { $str = (string) $this->getParameterContainer(); return $str; } return $this->getParameterContainer()->all(); }
[ "public", "function", "getParameters", "(", "$", "asString", "=", "false", ")", "{", "if", "(", "$", "asString", ")", "{", "$", "str", "=", "(", "string", ")", "$", "this", "->", "getParameterContainer", "(", ")", ";", "return", "$", "str", ";", "}", "return", "$", "this", "->", "getParameterContainer", "(", ")", "->", "all", "(", ")", ";", "}" ]
Get all parameters @param boolean $asString @return \Assimp\Command\Verbs\Container\ParameterContainer @deprecated Use ParameterContainer methods
[ "Get", "all", "parameters" ]
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Verbs/Traits/ParameterTrait.php#L97-L104
8,617
magdev/php-assimp
src/Command/Verbs/Traits/ParameterTrait.php
ParameterTrait.removeParameter
public function removeParameter($name) { if ($this->hasParameter($name)) { $this->getParameterContainer()->remove($name); } return $this; }
php
public function removeParameter($name) { if ($this->hasParameter($name)) { $this->getParameterContainer()->remove($name); } return $this; }
[ "public", "function", "removeParameter", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "hasParameter", "(", "$", "name", ")", ")", "{", "$", "this", "->", "getParameterContainer", "(", ")", "->", "remove", "(", "$", "name", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove a parameter @param string $name @return \Assimp\Command\Verbs\ExportVerb @deprecated Use ParameterContainer methods
[ "Remove", "a", "parameter" ]
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Verbs/Traits/ParameterTrait.php#L155-L161
8,618
mszewcz/php-light-framework
src/Variables/Specific/Files.php
Files.addMimeInfo
private function addMimeInfo(): void { $finfoMimeType = new \finfo(FILEINFO_MIME_TYPE); $finfoMimeEncoding = new \finfo(FILEINFO_MIME_ENCODING); foreach ($this->variables as $file => $data) { foreach ($data as $varName => $varVal) { if (\is_array($varVal)) { $this->variables[$file][$varName]['encoding'] = ''; if (isset($this->variables[$file][$varName]['error']) && $this->variables[$file][$varName]['error'] === 0) { $finfoFile = $this->variables[$file][$varName]['tmp_name']; $this->variables[$file][$varName]['type'] = $finfoMimeType->file($finfoFile); $this->variables[$file][$varName]['encoding'] = $finfoMimeEncoding->file($finfoFile); } } if (!\is_array($varVal)) { $this->variables[$file]['encoding'] = ''; if (isset($this->variables[$file]['error']) && $this->variables[$file]['error'] === 0) { $finfoFile = $this->variables[$file]['tmp_name']; $this->variables[$file]['type'] = $finfoMimeType->file($finfoFile); $this->variables[$file]['encoding'] = $finfoMimeEncoding->file($finfoFile); } } } } }
php
private function addMimeInfo(): void { $finfoMimeType = new \finfo(FILEINFO_MIME_TYPE); $finfoMimeEncoding = new \finfo(FILEINFO_MIME_ENCODING); foreach ($this->variables as $file => $data) { foreach ($data as $varName => $varVal) { if (\is_array($varVal)) { $this->variables[$file][$varName]['encoding'] = ''; if (isset($this->variables[$file][$varName]['error']) && $this->variables[$file][$varName]['error'] === 0) { $finfoFile = $this->variables[$file][$varName]['tmp_name']; $this->variables[$file][$varName]['type'] = $finfoMimeType->file($finfoFile); $this->variables[$file][$varName]['encoding'] = $finfoMimeEncoding->file($finfoFile); } } if (!\is_array($varVal)) { $this->variables[$file]['encoding'] = ''; if (isset($this->variables[$file]['error']) && $this->variables[$file]['error'] === 0) { $finfoFile = $this->variables[$file]['tmp_name']; $this->variables[$file]['type'] = $finfoMimeType->file($finfoFile); $this->variables[$file]['encoding'] = $finfoMimeEncoding->file($finfoFile); } } } } }
[ "private", "function", "addMimeInfo", "(", ")", ":", "void", "{", "$", "finfoMimeType", "=", "new", "\\", "finfo", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "finfoMimeEncoding", "=", "new", "\\", "finfo", "(", "FILEINFO_MIME_ENCODING", ")", ";", "foreach", "(", "$", "this", "->", "variables", "as", "$", "file", "=>", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "varName", "=>", "$", "varVal", ")", "{", "if", "(", "\\", "is_array", "(", "$", "varVal", ")", ")", "{", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "$", "varName", "]", "[", "'encoding'", "]", "=", "''", ";", "if", "(", "isset", "(", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "$", "varName", "]", "[", "'error'", "]", ")", "&&", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "$", "varName", "]", "[", "'error'", "]", "===", "0", ")", "{", "$", "finfoFile", "=", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "$", "varName", "]", "[", "'tmp_name'", "]", ";", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "$", "varName", "]", "[", "'type'", "]", "=", "$", "finfoMimeType", "->", "file", "(", "$", "finfoFile", ")", ";", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "$", "varName", "]", "[", "'encoding'", "]", "=", "$", "finfoMimeEncoding", "->", "file", "(", "$", "finfoFile", ")", ";", "}", "}", "if", "(", "!", "\\", "is_array", "(", "$", "varVal", ")", ")", "{", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "'encoding'", "]", "=", "''", ";", "if", "(", "isset", "(", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "'error'", "]", ")", "&&", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "'error'", "]", "===", "0", ")", "{", "$", "finfoFile", "=", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "'tmp_name'", "]", ";", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "'type'", "]", "=", "$", "finfoMimeType", "->", "file", "(", "$", "finfoFile", ")", ";", "$", "this", "->", "variables", "[", "$", "file", "]", "[", "'encoding'", "]", "=", "$", "finfoMimeEncoding", "->", "file", "(", "$", "finfoFile", ")", ";", "}", "}", "}", "}", "}" ]
Adds MIME information to files
[ "Adds", "MIME", "information", "to", "files" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Variables/Specific/Files.php#L84-L113
8,619
mszewcz/php-light-framework
src/Variables/Specific/Files.php
Files.get
public function get(string $variableName = null, int $type = Variables::TYPE_ARRAY) { if ($variableName === null) { throw new BadMethodCallException('Variable name must be specified'); } if (isset($this->variables['MFVARS'][$variableName])) { return $this->variables['MFVARS'][$variableName]; } if (isset($this->variables[$variableName])) { return $this->variables[$variableName]; } return []; }
php
public function get(string $variableName = null, int $type = Variables::TYPE_ARRAY) { if ($variableName === null) { throw new BadMethodCallException('Variable name must be specified'); } if (isset($this->variables['MFVARS'][$variableName])) { return $this->variables['MFVARS'][$variableName]; } if (isset($this->variables[$variableName])) { return $this->variables[$variableName]; } return []; }
[ "public", "function", "get", "(", "string", "$", "variableName", "=", "null", ",", "int", "$", "type", "=", "Variables", "::", "TYPE_ARRAY", ")", "{", "if", "(", "$", "variableName", "===", "null", ")", "{", "throw", "new", "BadMethodCallException", "(", "'Variable name must be specified'", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "variables", "[", "'MFVARS'", "]", "[", "$", "variableName", "]", ")", ")", "{", "return", "$", "this", "->", "variables", "[", "'MFVARS'", "]", "[", "$", "variableName", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "variables", "[", "$", "variableName", "]", ")", ")", "{", "return", "$", "this", "->", "variables", "[", "$", "variableName", "]", ";", "}", "return", "[", "]", ";", "}" ]
Returns FILES variable's value. If variable doesn't exist method returns default value for specified type. @param string|null $variableName @param int $type @return array|mixed
[ "Returns", "FILES", "variable", "s", "value", ".", "If", "variable", "doesn", "t", "exist", "method", "returns", "default", "value", "for", "specified", "type", "." ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Variables/Specific/Files.php#L122-L134
8,620
pletfix/core
src/Services/PluginManager.php
PluginManager.publish
private function publish($register) { $this->publishConfig($register); $this->publishPublicFolder($register); $this->publishAssets($register); $this->publishCommands($register); $this->publishMigrations($register); $this->publishLanguages($register); $this->publishViews($register); $this->publishRoutes($register); $this->publishControllers($register); $this->publishMiddleware($register); $this->publishDrivers($register); $this->publishServices($register); $this->publishBootstraps($register); $this->enablePackage($register); }
php
private function publish($register) { $this->publishConfig($register); $this->publishPublicFolder($register); $this->publishAssets($register); $this->publishCommands($register); $this->publishMigrations($register); $this->publishLanguages($register); $this->publishViews($register); $this->publishRoutes($register); $this->publishControllers($register); $this->publishMiddleware($register); $this->publishDrivers($register); $this->publishServices($register); $this->publishBootstraps($register); $this->enablePackage($register); }
[ "private", "function", "publish", "(", "$", "register", ")", "{", "$", "this", "->", "publishConfig", "(", "$", "register", ")", ";", "$", "this", "->", "publishPublicFolder", "(", "$", "register", ")", ";", "$", "this", "->", "publishAssets", "(", "$", "register", ")", ";", "$", "this", "->", "publishCommands", "(", "$", "register", ")", ";", "$", "this", "->", "publishMigrations", "(", "$", "register", ")", ";", "$", "this", "->", "publishLanguages", "(", "$", "register", ")", ";", "$", "this", "->", "publishViews", "(", "$", "register", ")", ";", "$", "this", "->", "publishRoutes", "(", "$", "register", ")", ";", "$", "this", "->", "publishControllers", "(", "$", "register", ")", ";", "$", "this", "->", "publishMiddleware", "(", "$", "register", ")", ";", "$", "this", "->", "publishDrivers", "(", "$", "register", ")", ";", "$", "this", "->", "publishServices", "(", "$", "register", ")", ";", "$", "this", "->", "publishBootstraps", "(", "$", "register", ")", ";", "$", "this", "->", "enablePackage", "(", "$", "register", ")", ";", "}" ]
Register and unregister the plugin @param bool $register
[ "Register", "and", "unregister", "the", "plugin" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L164-L180
8,621
pletfix/core
src/Services/PluginManager.php
PluginManager.getNamespace
private function getNamespace($composerJson) { if (!file_exists($composerJson)) { throw new InvalidArgumentException('"' . $composerJson . '" not found.'); // @codeCoverageIgnore } $composer = json_decode(file_get_contents($composerJson), true); $autoload = isset($composer['autoload']['psr-4']) ? array_flip($composer['autoload']['psr-4']) : []; if (!isset($autoload['src/'])) { throw new InvalidArgumentException('psr-4 autoload directive for folder "src/" is missing in ' . $composerJson . '.'); } return $autoload['src/']; }
php
private function getNamespace($composerJson) { if (!file_exists($composerJson)) { throw new InvalidArgumentException('"' . $composerJson . '" not found.'); // @codeCoverageIgnore } $composer = json_decode(file_get_contents($composerJson), true); $autoload = isset($composer['autoload']['psr-4']) ? array_flip($composer['autoload']['psr-4']) : []; if (!isset($autoload['src/'])) { throw new InvalidArgumentException('psr-4 autoload directive for folder "src/" is missing in ' . $composerJson . '.'); } return $autoload['src/']; }
[ "private", "function", "getNamespace", "(", "$", "composerJson", ")", "{", "if", "(", "!", "file_exists", "(", "$", "composerJson", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"'", ".", "$", "composerJson", ".", "'\" not found.'", ")", ";", "// @codeCoverageIgnore", "}", "$", "composer", "=", "json_decode", "(", "file_get_contents", "(", "$", "composerJson", ")", ",", "true", ")", ";", "$", "autoload", "=", "isset", "(", "$", "composer", "[", "'autoload'", "]", "[", "'psr-4'", "]", ")", "?", "array_flip", "(", "$", "composer", "[", "'autoload'", "]", "[", "'psr-4'", "]", ")", ":", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "autoload", "[", "'src/'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'psr-4 autoload directive for folder \"src/\" is missing in '", ".", "$", "composerJson", ".", "'.'", ")", ";", "}", "return", "$", "autoload", "[", "'src/'", "]", ";", "}" ]
Read the namespace from composer.json @param string $composerJson full path of composer.json @return string
[ "Read", "the", "namespace", "from", "composer", ".", "json" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L188-L200
8,622
pletfix/core
src/Services/PluginManager.php
PluginManager.publishConfig
private function publishConfig($register) { $src = $this->path . '/config.php'; if (!file_exists($src)) { return; } $dest = config_path($this->plugin . '.php'); if (file_exists($dest)) { return; } if ($register) { copy($src, $dest); } }
php
private function publishConfig($register) { $src = $this->path . '/config.php'; if (!file_exists($src)) { return; } $dest = config_path($this->plugin . '.php'); if (file_exists($dest)) { return; } if ($register) { copy($src, $dest); } }
[ "private", "function", "publishConfig", "(", "$", "register", ")", "{", "$", "src", "=", "$", "this", "->", "path", ".", "'/config.php'", ";", "if", "(", "!", "file_exists", "(", "$", "src", ")", ")", "{", "return", ";", "}", "$", "dest", "=", "config_path", "(", "$", "this", "->", "plugin", ".", "'.php'", ")", ";", "if", "(", "file_exists", "(", "$", "dest", ")", ")", "{", "return", ";", "}", "if", "(", "$", "register", ")", "{", "copy", "(", "$", "src", ",", "$", "dest", ")", ";", "}", "}" ]
Copy the config, if not already done @param bool $register
[ "Copy", "the", "config", "if", "not", "already", "done" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L207-L222
8,623
pletfix/core
src/Services/PluginManager.php
PluginManager.publishPublicFolder
private function publishPublicFolder($register) { // read files $publicPath = $this->path . '/public'; if (!file_exists($publicPath)) { return; } $files = []; list_files($files, $publicPath); // copy files $publicPathLength = strlen($publicPath) + 1; foreach ($files as $file) { $destDir = public_path(substr(dirname($file), $publicPathLength)); if (!file_exists($destDir)) { if (!make_dir($destDir, 0755)) { throw new RuntimeException('Unable to create directory ' . $destDir); //@codeCoverageIgnore } } //@codeCoverageIgnore $dest = $destDir . DIRECTORY_SEPARATOR . basename($file); if ($register) { copy($file, $dest); } else { if (file_exists($dest)) { unlink($dest); } } } }
php
private function publishPublicFolder($register) { // read files $publicPath = $this->path . '/public'; if (!file_exists($publicPath)) { return; } $files = []; list_files($files, $publicPath); // copy files $publicPathLength = strlen($publicPath) + 1; foreach ($files as $file) { $destDir = public_path(substr(dirname($file), $publicPathLength)); if (!file_exists($destDir)) { if (!make_dir($destDir, 0755)) { throw new RuntimeException('Unable to create directory ' . $destDir); //@codeCoverageIgnore } } //@codeCoverageIgnore $dest = $destDir . DIRECTORY_SEPARATOR . basename($file); if ($register) { copy($file, $dest); } else { if (file_exists($dest)) { unlink($dest); } } } }
[ "private", "function", "publishPublicFolder", "(", "$", "register", ")", "{", "// read files", "$", "publicPath", "=", "$", "this", "->", "path", ".", "'/public'", ";", "if", "(", "!", "file_exists", "(", "$", "publicPath", ")", ")", "{", "return", ";", "}", "$", "files", "=", "[", "]", ";", "list_files", "(", "$", "files", ",", "$", "publicPath", ")", ";", "// copy files", "$", "publicPathLength", "=", "strlen", "(", "$", "publicPath", ")", "+", "1", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "destDir", "=", "public_path", "(", "substr", "(", "dirname", "(", "$", "file", ")", ",", "$", "publicPathLength", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "destDir", ")", ")", "{", "if", "(", "!", "make_dir", "(", "$", "destDir", ",", "0755", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Unable to create directory '", ".", "$", "destDir", ")", ";", "//@codeCoverageIgnore", "}", "}", "//@codeCoverageIgnore", "$", "dest", "=", "$", "destDir", ".", "DIRECTORY_SEPARATOR", ".", "basename", "(", "$", "file", ")", ";", "if", "(", "$", "register", ")", "{", "copy", "(", "$", "file", ",", "$", "dest", ")", ";", "}", "else", "{", "if", "(", "file_exists", "(", "$", "dest", ")", ")", "{", "unlink", "(", "$", "dest", ")", ";", "}", "}", "}", "}" ]
Copy the public folder @param bool $register
[ "Copy", "the", "public", "folder" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L229-L258
8,624
pletfix/core
src/Services/PluginManager.php
PluginManager.publishAssets
private function publishAssets($register) { $build = $this->path . '/assets/build.php'; if (!file_exists($build)) { return; } if (!$register) { DI::getInstance()->get('asset-manager')->remove(null, $this->plugin); } // update manifest $manifest = $this->getManifest('assets'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; if ($register) { // make absolute path to relative path $basePath = base_path(); $basePathLength = strlen($basePath); /** @noinspection PhpIncludeInspection */ $assets = include $build; foreach ($assets as $asset => $sources) { foreach ($sources as $i => $source) { if (substr($source, 0, $basePathLength) == $basePath) { $assets[$asset][$i] = substr($source, $basePathLength + 1); } } } // insert asset build information /** @noinspection PhpIncludeInspection */ $list[$this->plugin] = $assets; } else { // remove asset build information unset($list[$this->plugin]); } $this->saveArray($manifest, $list); if ($register) { DI::getInstance()->get('asset-manager')->publish(null, true, $this->plugin); } }
php
private function publishAssets($register) { $build = $this->path . '/assets/build.php'; if (!file_exists($build)) { return; } if (!$register) { DI::getInstance()->get('asset-manager')->remove(null, $this->plugin); } // update manifest $manifest = $this->getManifest('assets'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; if ($register) { // make absolute path to relative path $basePath = base_path(); $basePathLength = strlen($basePath); /** @noinspection PhpIncludeInspection */ $assets = include $build; foreach ($assets as $asset => $sources) { foreach ($sources as $i => $source) { if (substr($source, 0, $basePathLength) == $basePath) { $assets[$asset][$i] = substr($source, $basePathLength + 1); } } } // insert asset build information /** @noinspection PhpIncludeInspection */ $list[$this->plugin] = $assets; } else { // remove asset build information unset($list[$this->plugin]); } $this->saveArray($manifest, $list); if ($register) { DI::getInstance()->get('asset-manager')->publish(null, true, $this->plugin); } }
[ "private", "function", "publishAssets", "(", "$", "register", ")", "{", "$", "build", "=", "$", "this", "->", "path", ".", "'/assets/build.php'", ";", "if", "(", "!", "file_exists", "(", "$", "build", ")", ")", "{", "return", ";", "}", "if", "(", "!", "$", "register", ")", "{", "DI", "::", "getInstance", "(", ")", "->", "get", "(", "'asset-manager'", ")", "->", "remove", "(", "null", ",", "$", "this", "->", "plugin", ")", ";", "}", "// update manifest", "$", "manifest", "=", "$", "this", "->", "getManifest", "(", "'assets'", ")", ";", "/** @noinspection PhpIncludeInspection */", "$", "list", "=", "file_exists", "(", "$", "manifest", ")", "?", "include", "$", "manifest", ":", "[", "]", ";", "if", "(", "$", "register", ")", "{", "// make absolute path to relative path", "$", "basePath", "=", "base_path", "(", ")", ";", "$", "basePathLength", "=", "strlen", "(", "$", "basePath", ")", ";", "/** @noinspection PhpIncludeInspection */", "$", "assets", "=", "include", "$", "build", ";", "foreach", "(", "$", "assets", "as", "$", "asset", "=>", "$", "sources", ")", "{", "foreach", "(", "$", "sources", "as", "$", "i", "=>", "$", "source", ")", "{", "if", "(", "substr", "(", "$", "source", ",", "0", ",", "$", "basePathLength", ")", "==", "$", "basePath", ")", "{", "$", "assets", "[", "$", "asset", "]", "[", "$", "i", "]", "=", "substr", "(", "$", "source", ",", "$", "basePathLength", "+", "1", ")", ";", "}", "}", "}", "// insert asset build information", "/** @noinspection PhpIncludeInspection */", "$", "list", "[", "$", "this", "->", "plugin", "]", "=", "$", "assets", ";", "}", "else", "{", "// remove asset build information", "unset", "(", "$", "list", "[", "$", "this", "->", "plugin", "]", ")", ";", "}", "$", "this", "->", "saveArray", "(", "$", "manifest", ",", "$", "list", ")", ";", "if", "(", "$", "register", ")", "{", "DI", "::", "getInstance", "(", ")", "->", "get", "(", "'asset-manager'", ")", "->", "publish", "(", "null", ",", "true", ",", "$", "this", "->", "plugin", ")", ";", "}", "}" ]
Update manifest "assets.php" and run the Asset Manager to publish the assets. @param bool $register
[ "Update", "manifest", "assets", ".", "php", "and", "run", "the", "Asset", "Manager", "to", "publish", "the", "assets", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L265-L306
8,625
pletfix/core
src/Services/PluginManager.php
PluginManager.publishCommands
private function publishCommands($register) { // read all plugin commands from folder $commandPath = $this->path . '/src/Commands'; if (!file_exists($commandPath)) { return; } $classes = []; list_classes($classes, $commandPath, $this->namespace . 'Commands'); // read existing command list $manifest = $this->getManifest('commands'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; // merge plugin commands to the list (plugin overrides commands if exist) foreach ($classes as $class) { /** @var CommandContract $command */ $command = new $class; $name = $command->name(); if ($register) { $description = trim($command->description() ?: ''); $list[$name] = compact('class', 'name', 'description'); } else { unset($list[$name]); } } // save the new command list ksort($list); $this->saveArray($manifest, $list); }
php
private function publishCommands($register) { // read all plugin commands from folder $commandPath = $this->path . '/src/Commands'; if (!file_exists($commandPath)) { return; } $classes = []; list_classes($classes, $commandPath, $this->namespace . 'Commands'); // read existing command list $manifest = $this->getManifest('commands'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; // merge plugin commands to the list (plugin overrides commands if exist) foreach ($classes as $class) { /** @var CommandContract $command */ $command = new $class; $name = $command->name(); if ($register) { $description = trim($command->description() ?: ''); $list[$name] = compact('class', 'name', 'description'); } else { unset($list[$name]); } } // save the new command list ksort($list); $this->saveArray($manifest, $list); }
[ "private", "function", "publishCommands", "(", "$", "register", ")", "{", "// read all plugin commands from folder", "$", "commandPath", "=", "$", "this", "->", "path", ".", "'/src/Commands'", ";", "if", "(", "!", "file_exists", "(", "$", "commandPath", ")", ")", "{", "return", ";", "}", "$", "classes", "=", "[", "]", ";", "list_classes", "(", "$", "classes", ",", "$", "commandPath", ",", "$", "this", "->", "namespace", ".", "'Commands'", ")", ";", "// read existing command list", "$", "manifest", "=", "$", "this", "->", "getManifest", "(", "'commands'", ")", ";", "/** @noinspection PhpIncludeInspection */", "$", "list", "=", "file_exists", "(", "$", "manifest", ")", "?", "include", "$", "manifest", ":", "[", "]", ";", "// merge plugin commands to the list (plugin overrides commands if exist)", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "/** @var CommandContract $command */", "$", "command", "=", "new", "$", "class", ";", "$", "name", "=", "$", "command", "->", "name", "(", ")", ";", "if", "(", "$", "register", ")", "{", "$", "description", "=", "trim", "(", "$", "command", "->", "description", "(", ")", "?", ":", "''", ")", ";", "$", "list", "[", "$", "name", "]", "=", "compact", "(", "'class'", ",", "'name'", ",", "'description'", ")", ";", "}", "else", "{", "unset", "(", "$", "list", "[", "$", "name", "]", ")", ";", "}", "}", "// save the new command list", "ksort", "(", "$", "list", ")", ";", "$", "this", "->", "saveArray", "(", "$", "manifest", ",", "$", "list", ")", ";", "}" ]
Update manifest "commands.php" @param bool $register
[ "Update", "manifest", "commands", ".", "php" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L313-L345
8,626
pletfix/core
src/Services/PluginManager.php
PluginManager.publishMigrations
private function publishMigrations($register) { // read migrations from folder $migrationPath = $this->path . '/migrations'; if (!file_exists($migrationPath)) { return; } $files = []; list_files($files, $migrationPath, ['php']); // update manifest $manifest = $this->getManifest('migrations'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $basePathLength = strlen(base_path()) + 1; foreach ($files as $file) { $name = basename($file, '.php'); if ($register) { $list[$name] = substr($file, $basePathLength); } else { unset($list[$name]); } } $this->saveArray($manifest, $list); }
php
private function publishMigrations($register) { // read migrations from folder $migrationPath = $this->path . '/migrations'; if (!file_exists($migrationPath)) { return; } $files = []; list_files($files, $migrationPath, ['php']); // update manifest $manifest = $this->getManifest('migrations'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $basePathLength = strlen(base_path()) + 1; foreach ($files as $file) { $name = basename($file, '.php'); if ($register) { $list[$name] = substr($file, $basePathLength); } else { unset($list[$name]); } } $this->saveArray($manifest, $list); }
[ "private", "function", "publishMigrations", "(", "$", "register", ")", "{", "// read migrations from folder", "$", "migrationPath", "=", "$", "this", "->", "path", ".", "'/migrations'", ";", "if", "(", "!", "file_exists", "(", "$", "migrationPath", ")", ")", "{", "return", ";", "}", "$", "files", "=", "[", "]", ";", "list_files", "(", "$", "files", ",", "$", "migrationPath", ",", "[", "'php'", "]", ")", ";", "// update manifest", "$", "manifest", "=", "$", "this", "->", "getManifest", "(", "'migrations'", ")", ";", "/** @noinspection PhpIncludeInspection */", "$", "list", "=", "file_exists", "(", "$", "manifest", ")", "?", "include", "$", "manifest", ":", "[", "]", ";", "$", "basePathLength", "=", "strlen", "(", "base_path", "(", ")", ")", "+", "1", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "name", "=", "basename", "(", "$", "file", ",", "'.php'", ")", ";", "if", "(", "$", "register", ")", "{", "$", "list", "[", "$", "name", "]", "=", "substr", "(", "$", "file", ",", "$", "basePathLength", ")", ";", "}", "else", "{", "unset", "(", "$", "list", "[", "$", "name", "]", ")", ";", "}", "}", "$", "this", "->", "saveArray", "(", "$", "manifest", ",", "$", "list", ")", ";", "}" ]
Update manifest "migrations.php" @param bool $register
[ "Update", "manifest", "migrations", ".", "php" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L352-L377
8,627
pletfix/core
src/Services/PluginManager.php
PluginManager.publishLanguages
private function publishLanguages($register) { // read language files from folder $langPath = $this->path . '/lang'; if (!file_exists($langPath)) { return; } $files = []; list_files($files, $langPath, ['php'], false); // update manifest $manifest = $this->getManifest('languages'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $basePathLength = strlen(base_path()) + 1; foreach ($files as $file) { $locale = basename($file, '.php'); if ($register) { if (!isset($list[$locale])) { $list[$locale] = []; } $list[$locale][$this->plugin] = substr($file, $basePathLength); } else { if (isset($list[$locale])) { unset($list[$locale][$this->plugin]); if (empty($list[$locale])) { unset($list[$locale]); } } } } $this->saveArray($manifest, $list); }
php
private function publishLanguages($register) { // read language files from folder $langPath = $this->path . '/lang'; if (!file_exists($langPath)) { return; } $files = []; list_files($files, $langPath, ['php'], false); // update manifest $manifest = $this->getManifest('languages'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $basePathLength = strlen(base_path()) + 1; foreach ($files as $file) { $locale = basename($file, '.php'); if ($register) { if (!isset($list[$locale])) { $list[$locale] = []; } $list[$locale][$this->plugin] = substr($file, $basePathLength); } else { if (isset($list[$locale])) { unset($list[$locale][$this->plugin]); if (empty($list[$locale])) { unset($list[$locale]); } } } } $this->saveArray($manifest, $list); }
[ "private", "function", "publishLanguages", "(", "$", "register", ")", "{", "// read language files from folder", "$", "langPath", "=", "$", "this", "->", "path", ".", "'/lang'", ";", "if", "(", "!", "file_exists", "(", "$", "langPath", ")", ")", "{", "return", ";", "}", "$", "files", "=", "[", "]", ";", "list_files", "(", "$", "files", ",", "$", "langPath", ",", "[", "'php'", "]", ",", "false", ")", ";", "// update manifest", "$", "manifest", "=", "$", "this", "->", "getManifest", "(", "'languages'", ")", ";", "/** @noinspection PhpIncludeInspection */", "$", "list", "=", "file_exists", "(", "$", "manifest", ")", "?", "include", "$", "manifest", ":", "[", "]", ";", "$", "basePathLength", "=", "strlen", "(", "base_path", "(", ")", ")", "+", "1", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "locale", "=", "basename", "(", "$", "file", ",", "'.php'", ")", ";", "if", "(", "$", "register", ")", "{", "if", "(", "!", "isset", "(", "$", "list", "[", "$", "locale", "]", ")", ")", "{", "$", "list", "[", "$", "locale", "]", "=", "[", "]", ";", "}", "$", "list", "[", "$", "locale", "]", "[", "$", "this", "->", "plugin", "]", "=", "substr", "(", "$", "file", ",", "$", "basePathLength", ")", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "list", "[", "$", "locale", "]", ")", ")", "{", "unset", "(", "$", "list", "[", "$", "locale", "]", "[", "$", "this", "->", "plugin", "]", ")", ";", "if", "(", "empty", "(", "$", "list", "[", "$", "locale", "]", ")", ")", "{", "unset", "(", "$", "list", "[", "$", "locale", "]", ")", ";", "}", "}", "}", "}", "$", "this", "->", "saveArray", "(", "$", "manifest", ",", "$", "list", ")", ";", "}" ]
Update the language files. @param bool $register
[ "Update", "the", "language", "files", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L384-L417
8,628
pletfix/core
src/Services/PluginManager.php
PluginManager.publishViews
private function publishViews($register) { // read views from folder $visitPath = $this->path . '/views'; if (!file_exists($visitPath)) { return; } $files = []; list_files($files, $visitPath, ['php']); // update manifest $manifest = $this->getManifest('views'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $visitPathLength = strlen($visitPath) + 1; $basePathLength = strlen(base_path()) + 1; foreach ($files as $file) { if (substr($file, -10) == '.blade.php') { $name = $this->plugin . '.' . str_replace(DIRECTORY_SEPARATOR, '.', substr($file, $visitPathLength, -10)); if ($register) { $list[$name] = substr($file, $basePathLength); } else { unset($list[$name]); } } } $this->saveArray($manifest, $list); }
php
private function publishViews($register) { // read views from folder $visitPath = $this->path . '/views'; if (!file_exists($visitPath)) { return; } $files = []; list_files($files, $visitPath, ['php']); // update manifest $manifest = $this->getManifest('views'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $visitPathLength = strlen($visitPath) + 1; $basePathLength = strlen(base_path()) + 1; foreach ($files as $file) { if (substr($file, -10) == '.blade.php') { $name = $this->plugin . '.' . str_replace(DIRECTORY_SEPARATOR, '.', substr($file, $visitPathLength, -10)); if ($register) { $list[$name] = substr($file, $basePathLength); } else { unset($list[$name]); } } } $this->saveArray($manifest, $list); }
[ "private", "function", "publishViews", "(", "$", "register", ")", "{", "// read views from folder", "$", "visitPath", "=", "$", "this", "->", "path", ".", "'/views'", ";", "if", "(", "!", "file_exists", "(", "$", "visitPath", ")", ")", "{", "return", ";", "}", "$", "files", "=", "[", "]", ";", "list_files", "(", "$", "files", ",", "$", "visitPath", ",", "[", "'php'", "]", ")", ";", "// update manifest", "$", "manifest", "=", "$", "this", "->", "getManifest", "(", "'views'", ")", ";", "/** @noinspection PhpIncludeInspection */", "$", "list", "=", "file_exists", "(", "$", "manifest", ")", "?", "include", "$", "manifest", ":", "[", "]", ";", "$", "visitPathLength", "=", "strlen", "(", "$", "visitPath", ")", "+", "1", ";", "$", "basePathLength", "=", "strlen", "(", "base_path", "(", ")", ")", "+", "1", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "substr", "(", "$", "file", ",", "-", "10", ")", "==", "'.blade.php'", ")", "{", "$", "name", "=", "$", "this", "->", "plugin", ".", "'.'", ".", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'.'", ",", "substr", "(", "$", "file", ",", "$", "visitPathLength", ",", "-", "10", ")", ")", ";", "if", "(", "$", "register", ")", "{", "$", "list", "[", "$", "name", "]", "=", "substr", "(", "$", "file", ",", "$", "basePathLength", ")", ";", "}", "else", "{", "unset", "(", "$", "list", "[", "$", "name", "]", ")", ";", "}", "}", "}", "$", "this", "->", "saveArray", "(", "$", "manifest", ",", "$", "list", ")", ";", "}" ]
Update manifest "views.php" @param bool $register
[ "Update", "manifest", "views", ".", "php" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L424-L452
8,629
pletfix/core
src/Services/PluginManager.php
PluginManager.publishClasses
private function publishClasses($register, $subfolder) { // read middleware from folder $path = $this->path . '/src/' . $subfolder; if (!file_exists($path)) { return; } $classes = []; $ns = $this->namespace . $subfolder; list_classes($classes, $path, $ns); // update manifest $manifest = $this->getManifest(lcfirst($subfolder)); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $len = strlen($ns); foreach ($classes as $class) { if (strpos($class, '\\Contracts\\') !== false) { continue; // contracts } $name = substr($class, $len + 1); if ($register) { if (!isset($list[$name])) { $list[$name] = []; } if (($i = array_search($class, $list[$name])) === false) { $list[$name][] = $class; } } else { if (isset($list[$name]) && ($i = array_search($class, $list[$name])) !== false) { unset($list[$name][$i]); if (empty($list[$name])) { unset($list[$name]); } else { $list[$name] = array_values($list[$name]); } } } } $this->saveArray($manifest, $list); }
php
private function publishClasses($register, $subfolder) { // read middleware from folder $path = $this->path . '/src/' . $subfolder; if (!file_exists($path)) { return; } $classes = []; $ns = $this->namespace . $subfolder; list_classes($classes, $path, $ns); // update manifest $manifest = $this->getManifest(lcfirst($subfolder)); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $len = strlen($ns); foreach ($classes as $class) { if (strpos($class, '\\Contracts\\') !== false) { continue; // contracts } $name = substr($class, $len + 1); if ($register) { if (!isset($list[$name])) { $list[$name] = []; } if (($i = array_search($class, $list[$name])) === false) { $list[$name][] = $class; } } else { if (isset($list[$name]) && ($i = array_search($class, $list[$name])) !== false) { unset($list[$name][$i]); if (empty($list[$name])) { unset($list[$name]); } else { $list[$name] = array_values($list[$name]); } } } } $this->saveArray($manifest, $list); }
[ "private", "function", "publishClasses", "(", "$", "register", ",", "$", "subfolder", ")", "{", "// read middleware from folder", "$", "path", "=", "$", "this", "->", "path", ".", "'/src/'", ".", "$", "subfolder", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "return", ";", "}", "$", "classes", "=", "[", "]", ";", "$", "ns", "=", "$", "this", "->", "namespace", ".", "$", "subfolder", ";", "list_classes", "(", "$", "classes", ",", "$", "path", ",", "$", "ns", ")", ";", "// update manifest", "$", "manifest", "=", "$", "this", "->", "getManifest", "(", "lcfirst", "(", "$", "subfolder", ")", ")", ";", "/** @noinspection PhpIncludeInspection */", "$", "list", "=", "file_exists", "(", "$", "manifest", ")", "?", "include", "$", "manifest", ":", "[", "]", ";", "$", "len", "=", "strlen", "(", "$", "ns", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "if", "(", "strpos", "(", "$", "class", ",", "'\\\\Contracts\\\\'", ")", "!==", "false", ")", "{", "continue", ";", "// contracts", "}", "$", "name", "=", "substr", "(", "$", "class", ",", "$", "len", "+", "1", ")", ";", "if", "(", "$", "register", ")", "{", "if", "(", "!", "isset", "(", "$", "list", "[", "$", "name", "]", ")", ")", "{", "$", "list", "[", "$", "name", "]", "=", "[", "]", ";", "}", "if", "(", "(", "$", "i", "=", "array_search", "(", "$", "class", ",", "$", "list", "[", "$", "name", "]", ")", ")", "===", "false", ")", "{", "$", "list", "[", "$", "name", "]", "[", "]", "=", "$", "class", ";", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "list", "[", "$", "name", "]", ")", "&&", "(", "$", "i", "=", "array_search", "(", "$", "class", ",", "$", "list", "[", "$", "name", "]", ")", ")", "!==", "false", ")", "{", "unset", "(", "$", "list", "[", "$", "name", "]", "[", "$", "i", "]", ")", ";", "if", "(", "empty", "(", "$", "list", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "list", "[", "$", "name", "]", ")", ";", "}", "else", "{", "$", "list", "[", "$", "name", "]", "=", "array_values", "(", "$", "list", "[", "$", "name", "]", ")", ";", "}", "}", "}", "}", "$", "this", "->", "saveArray", "(", "$", "manifest", ",", "$", "list", ")", ";", "}" ]
Update manifest "classes.php" @param bool $register @param string $subfolder
[ "Update", "manifest", "classes", ".", "php" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L480-L525
8,630
pletfix/core
src/Services/PluginManager.php
PluginManager.publishDrivers
private function publishDrivers($register) { // read middleware from folder $path = $this->path . '/src/Drivers'; if (!file_exists($path)) { return; } $classes = []; $ns = $this->namespace . 'Drivers'; list_classes($classes, $path, $ns); // update manifest $manifest = $this->getManifest('drivers'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $len = strlen($ns); foreach ($classes as $class) { if (strpos($class, '\\Contracts\\') !== false) { continue; // contracts } $name = substr($class, $len + 1); if (($pos = strpos($name, '\\')) !== false) { $group = substr($name, 0, $pos); $name = substr($name, $pos + 1); } else { $group = ''; } if ($register) { if (!isset($list[$group])) { $list[$group] = []; } if (!isset($list[$group][$name])) { $list[$group][$name] = []; } if (($i = array_search($class, $list[$group][$name])) === false) { $list[$group][$name][] = $class; } } else { if (isset($list[$group][$name]) && ($i = array_search($class, $list[$group][$name])) !== false) { unset($list[$group][$name][$i]); if (empty($list[$group][$name])) { unset($list[$group][$name]); } else { $list[$group][$name] = array_values($list[$group][$name]); } if (empty($list[$group])) { unset($list[$group]); } } } } $this->saveArray($manifest, $list); }
php
private function publishDrivers($register) { // read middleware from folder $path = $this->path . '/src/Drivers'; if (!file_exists($path)) { return; } $classes = []; $ns = $this->namespace . 'Drivers'; list_classes($classes, $path, $ns); // update manifest $manifest = $this->getManifest('drivers'); /** @noinspection PhpIncludeInspection */ $list = file_exists($manifest) ? include $manifest : []; $len = strlen($ns); foreach ($classes as $class) { if (strpos($class, '\\Contracts\\') !== false) { continue; // contracts } $name = substr($class, $len + 1); if (($pos = strpos($name, '\\')) !== false) { $group = substr($name, 0, $pos); $name = substr($name, $pos + 1); } else { $group = ''; } if ($register) { if (!isset($list[$group])) { $list[$group] = []; } if (!isset($list[$group][$name])) { $list[$group][$name] = []; } if (($i = array_search($class, $list[$group][$name])) === false) { $list[$group][$name][] = $class; } } else { if (isset($list[$group][$name]) && ($i = array_search($class, $list[$group][$name])) !== false) { unset($list[$group][$name][$i]); if (empty($list[$group][$name])) { unset($list[$group][$name]); } else { $list[$group][$name] = array_values($list[$group][$name]); } if (empty($list[$group])) { unset($list[$group]); } } } } $this->saveArray($manifest, $list); }
[ "private", "function", "publishDrivers", "(", "$", "register", ")", "{", "// read middleware from folder", "$", "path", "=", "$", "this", "->", "path", ".", "'/src/Drivers'", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "return", ";", "}", "$", "classes", "=", "[", "]", ";", "$", "ns", "=", "$", "this", "->", "namespace", ".", "'Drivers'", ";", "list_classes", "(", "$", "classes", ",", "$", "path", ",", "$", "ns", ")", ";", "// update manifest", "$", "manifest", "=", "$", "this", "->", "getManifest", "(", "'drivers'", ")", ";", "/** @noinspection PhpIncludeInspection */", "$", "list", "=", "file_exists", "(", "$", "manifest", ")", "?", "include", "$", "manifest", ":", "[", "]", ";", "$", "len", "=", "strlen", "(", "$", "ns", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "if", "(", "strpos", "(", "$", "class", ",", "'\\\\Contracts\\\\'", ")", "!==", "false", ")", "{", "continue", ";", "// contracts", "}", "$", "name", "=", "substr", "(", "$", "class", ",", "$", "len", "+", "1", ")", ";", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "name", ",", "'\\\\'", ")", ")", "!==", "false", ")", "{", "$", "group", "=", "substr", "(", "$", "name", ",", "0", ",", "$", "pos", ")", ";", "$", "name", "=", "substr", "(", "$", "name", ",", "$", "pos", "+", "1", ")", ";", "}", "else", "{", "$", "group", "=", "''", ";", "}", "if", "(", "$", "register", ")", "{", "if", "(", "!", "isset", "(", "$", "list", "[", "$", "group", "]", ")", ")", "{", "$", "list", "[", "$", "group", "]", "=", "[", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", ")", ")", "{", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", "=", "[", "]", ";", "}", "if", "(", "(", "$", "i", "=", "array_search", "(", "$", "class", ",", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", ")", ")", "===", "false", ")", "{", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", "[", "]", "=", "$", "class", ";", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", ")", "&&", "(", "$", "i", "=", "array_search", "(", "$", "class", ",", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", ")", ")", "!==", "false", ")", "{", "unset", "(", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", "[", "$", "i", "]", ")", ";", "if", "(", "empty", "(", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", ")", ";", "}", "else", "{", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", "=", "array_values", "(", "$", "list", "[", "$", "group", "]", "[", "$", "name", "]", ")", ";", "}", "if", "(", "empty", "(", "$", "list", "[", "$", "group", "]", ")", ")", "{", "unset", "(", "$", "list", "[", "$", "group", "]", ")", ";", "}", "}", "}", "}", "$", "this", "->", "saveArray", "(", "$", "manifest", ",", "$", "list", ")", ";", "}" ]
Update manifest "drivers.php" @param bool $register
[ "Update", "manifest", "drivers", ".", "php" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L532-L591
8,631
pletfix/core
src/Services/PluginManager.php
PluginManager.publishRoutes
private function publishRoutes($register) { if ($register && (isset($this->options['no-routes']) && $this->options['no-routes'] == true)) { return; } if (!file_exists($this->path . '/boot/routes.php')) { return; } // Read enabled packages and add/remove the current plugin. $packages = $this->listPackages($register); // update manifest $dest = ''; foreach ($packages as $package => $path) { $file = base_path($path . '/boot/routes.php'); if (!file_exists($file)) { continue; } // get content $src = trim(file_get_contents($file)); // strip php tag if (substr($src, 0, 5) == '<?php') { $src = trim(substr($src, 5)); } if (substr($src, -2) == '?>') { $src = trim(substr($src, 0, -2)); } // strip the $router variable if exists $src = trim(preg_replace('/\\$router\\s*=\\s*\\\\?Core\\\\Application::router\\(\\);/', '', $src)); // strip "use Core\Services\Contracts\Router;" if exists $src = trim(preg_replace('/use Core\\\\Services\\\\Contracts\\\\Router;/', '', $src)); // append content to summery file if ($dest == '') { $dest = PHP_EOL . 'use Core\Services\Contracts\Router;' . PHP_EOL . PHP_EOL . '$router = \Core\Application::router();' . PHP_EOL; } $dest .= PHP_EOL . '///////////////////////////////////////////////////////////////////////////////' . PHP_EOL . '// ' . $package . PHP_EOL . PHP_EOL . $src . PHP_EOL; } $this->saveContent($this->getManifest('routes'), '<?php' . PHP_EOL . $dest); }
php
private function publishRoutes($register) { if ($register && (isset($this->options['no-routes']) && $this->options['no-routes'] == true)) { return; } if (!file_exists($this->path . '/boot/routes.php')) { return; } // Read enabled packages and add/remove the current plugin. $packages = $this->listPackages($register); // update manifest $dest = ''; foreach ($packages as $package => $path) { $file = base_path($path . '/boot/routes.php'); if (!file_exists($file)) { continue; } // get content $src = trim(file_get_contents($file)); // strip php tag if (substr($src, 0, 5) == '<?php') { $src = trim(substr($src, 5)); } if (substr($src, -2) == '?>') { $src = trim(substr($src, 0, -2)); } // strip the $router variable if exists $src = trim(preg_replace('/\\$router\\s*=\\s*\\\\?Core\\\\Application::router\\(\\);/', '', $src)); // strip "use Core\Services\Contracts\Router;" if exists $src = trim(preg_replace('/use Core\\\\Services\\\\Contracts\\\\Router;/', '', $src)); // append content to summery file if ($dest == '') { $dest = PHP_EOL . 'use Core\Services\Contracts\Router;' . PHP_EOL . PHP_EOL . '$router = \Core\Application::router();' . PHP_EOL; } $dest .= PHP_EOL . '///////////////////////////////////////////////////////////////////////////////' . PHP_EOL . '// ' . $package . PHP_EOL . PHP_EOL . $src . PHP_EOL; } $this->saveContent($this->getManifest('routes'), '<?php' . PHP_EOL . $dest); }
[ "private", "function", "publishRoutes", "(", "$", "register", ")", "{", "if", "(", "$", "register", "&&", "(", "isset", "(", "$", "this", "->", "options", "[", "'no-routes'", "]", ")", "&&", "$", "this", "->", "options", "[", "'no-routes'", "]", "==", "true", ")", ")", "{", "return", ";", "}", "if", "(", "!", "file_exists", "(", "$", "this", "->", "path", ".", "'/boot/routes.php'", ")", ")", "{", "return", ";", "}", "// Read enabled packages and add/remove the current plugin.", "$", "packages", "=", "$", "this", "->", "listPackages", "(", "$", "register", ")", ";", "// update manifest", "$", "dest", "=", "''", ";", "foreach", "(", "$", "packages", "as", "$", "package", "=>", "$", "path", ")", "{", "$", "file", "=", "base_path", "(", "$", "path", ".", "'/boot/routes.php'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "continue", ";", "}", "// get content", "$", "src", "=", "trim", "(", "file_get_contents", "(", "$", "file", ")", ")", ";", "// strip php tag", "if", "(", "substr", "(", "$", "src", ",", "0", ",", "5", ")", "==", "'<?php'", ")", "{", "$", "src", "=", "trim", "(", "substr", "(", "$", "src", ",", "5", ")", ")", ";", "}", "if", "(", "substr", "(", "$", "src", ",", "-", "2", ")", "==", "'?>'", ")", "{", "$", "src", "=", "trim", "(", "substr", "(", "$", "src", ",", "0", ",", "-", "2", ")", ")", ";", "}", "// strip the $router variable if exists", "$", "src", "=", "trim", "(", "preg_replace", "(", "'/\\\\$router\\\\s*=\\\\s*\\\\\\\\?Core\\\\\\\\Application::router\\\\(\\\\);/'", ",", "''", ",", "$", "src", ")", ")", ";", "// strip \"use Core\\Services\\Contracts\\Router;\" if exists", "$", "src", "=", "trim", "(", "preg_replace", "(", "'/use Core\\\\\\\\Services\\\\\\\\Contracts\\\\\\\\Router;/'", ",", "''", ",", "$", "src", ")", ")", ";", "// append content to summery file", "if", "(", "$", "dest", "==", "''", ")", "{", "$", "dest", "=", "PHP_EOL", ".", "'use Core\\Services\\Contracts\\Router;'", ".", "PHP_EOL", ".", "PHP_EOL", ".", "'$router = \\Core\\Application::router();'", ".", "PHP_EOL", ";", "}", "$", "dest", ".=", "PHP_EOL", ".", "'///////////////////////////////////////////////////////////////////////////////'", ".", "PHP_EOL", ".", "'// '", ".", "$", "package", ".", "PHP_EOL", ".", "PHP_EOL", ".", "$", "src", ".", "PHP_EOL", ";", "}", "$", "this", "->", "saveContent", "(", "$", "this", "->", "getManifest", "(", "'routes'", ")", ",", "'<?php'", ".", "PHP_EOL", ".", "$", "dest", ")", ";", "}" ]
Update manifest "routes.php" @param bool $register
[ "Update", "manifest", "routes", ".", "php" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L598-L653
8,632
pletfix/core
src/Services/PluginManager.php
PluginManager.publishServices
private function publishServices($register) { if (!file_exists($this->path . '/boot/services.php')) { return; } // Read enabled packages and add/remove the current plugin. $packages = $this->listPackages($register); // update manifest $dest = ''; foreach ($packages as $package => $path) { $file = base_path($path . '/boot/services.php'); if (!file_exists($file)) { continue; } // get content $src = trim(file_get_contents($file)); // strip php tag if (substr($src, 0, 5) == '<?php') { $src = trim(substr($src, 5)); } if (substr($src, -2) == '?>') { $src = trim(substr($src, 0, -2)); } // strip the $di variable if exists $src = trim(preg_replace('/\$di\s*=\s*\\\\Core\\\\Services\\\\DI::getInstance\(\);/', '', $src)); // append content to summery file if ($dest == '') { $dest = PHP_EOL . '$di = \Core\Services\DI::getInstance();' . PHP_EOL; } $dest .= PHP_EOL . '///////////////////////////////////////////////////////////////////////////////' . PHP_EOL . '// ' . $package . PHP_EOL . PHP_EOL . $src . PHP_EOL; } $this->saveContent($this->getManifest('services'), '<?php' . PHP_EOL . $dest); }
php
private function publishServices($register) { if (!file_exists($this->path . '/boot/services.php')) { return; } // Read enabled packages and add/remove the current plugin. $packages = $this->listPackages($register); // update manifest $dest = ''; foreach ($packages as $package => $path) { $file = base_path($path . '/boot/services.php'); if (!file_exists($file)) { continue; } // get content $src = trim(file_get_contents($file)); // strip php tag if (substr($src, 0, 5) == '<?php') { $src = trim(substr($src, 5)); } if (substr($src, -2) == '?>') { $src = trim(substr($src, 0, -2)); } // strip the $di variable if exists $src = trim(preg_replace('/\$di\s*=\s*\\\\Core\\\\Services\\\\DI::getInstance\(\);/', '', $src)); // append content to summery file if ($dest == '') { $dest = PHP_EOL . '$di = \Core\Services\DI::getInstance();' . PHP_EOL; } $dest .= PHP_EOL . '///////////////////////////////////////////////////////////////////////////////' . PHP_EOL . '// ' . $package . PHP_EOL . PHP_EOL . $src . PHP_EOL; } $this->saveContent($this->getManifest('services'), '<?php' . PHP_EOL . $dest); }
[ "private", "function", "publishServices", "(", "$", "register", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "path", ".", "'/boot/services.php'", ")", ")", "{", "return", ";", "}", "// Read enabled packages and add/remove the current plugin.", "$", "packages", "=", "$", "this", "->", "listPackages", "(", "$", "register", ")", ";", "// update manifest", "$", "dest", "=", "''", ";", "foreach", "(", "$", "packages", "as", "$", "package", "=>", "$", "path", ")", "{", "$", "file", "=", "base_path", "(", "$", "path", ".", "'/boot/services.php'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "continue", ";", "}", "// get content", "$", "src", "=", "trim", "(", "file_get_contents", "(", "$", "file", ")", ")", ";", "// strip php tag", "if", "(", "substr", "(", "$", "src", ",", "0", ",", "5", ")", "==", "'<?php'", ")", "{", "$", "src", "=", "trim", "(", "substr", "(", "$", "src", ",", "5", ")", ")", ";", "}", "if", "(", "substr", "(", "$", "src", ",", "-", "2", ")", "==", "'?>'", ")", "{", "$", "src", "=", "trim", "(", "substr", "(", "$", "src", ",", "0", ",", "-", "2", ")", ")", ";", "}", "// strip the $di variable if exists", "$", "src", "=", "trim", "(", "preg_replace", "(", "'/\\$di\\s*=\\s*\\\\\\\\Core\\\\\\\\Services\\\\\\\\DI::getInstance\\(\\);/'", ",", "''", ",", "$", "src", ")", ")", ";", "// append content to summery file", "if", "(", "$", "dest", "==", "''", ")", "{", "$", "dest", "=", "PHP_EOL", ".", "'$di = \\Core\\Services\\DI::getInstance();'", ".", "PHP_EOL", ";", "}", "$", "dest", ".=", "PHP_EOL", ".", "'///////////////////////////////////////////////////////////////////////////////'", ".", "PHP_EOL", ".", "'// '", ".", "$", "package", ".", "PHP_EOL", ".", "PHP_EOL", ".", "$", "src", ".", "PHP_EOL", ";", "}", "$", "this", "->", "saveContent", "(", "$", "this", "->", "getManifest", "(", "'services'", ")", ",", "'<?php'", ".", "PHP_EOL", ".", "$", "dest", ")", ";", "}" ]
Update manifest "services.php" @param bool $register
[ "Update", "manifest", "services", ".", "php" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L660-L705
8,633
pletfix/core
src/Services/PluginManager.php
PluginManager.publishBootstraps
private function publishBootstraps($register) { $classes = []; if (file_exists($this->path . '/src/Bootstraps')) { list_classes($classes, $this->path . '/src/Bootstraps', $this->namespace . 'Bootstraps'); } if (empty($classes)) { return; } // Read enabled packages and add/remove the current plugin. $packages = $this->listPackages($register); // update manifest $dest = ''; foreach ($packages as $package => $relativePath) { $path = base_path($relativePath); $classes = []; if (file_exists($path . '/src/Bootstraps')) { $namespace = $this->getNamespace($path . '/composer.json'); list_classes($classes, $path . '/src/Bootstraps', $namespace . 'Bootstraps'); } if (empty($classes)) { continue; } $dest .= PHP_EOL . '///////////////////////////////////////////////////////////////////////////////' . PHP_EOL . '// ' . $package . PHP_EOL . PHP_EOL; foreach ($classes as $class) { $dest .= '(new ' . $class . ')->boot();' . PHP_EOL; } } $this->saveContent($this->getManifest('bootstrap'), '<?php' . PHP_EOL . $dest); }
php
private function publishBootstraps($register) { $classes = []; if (file_exists($this->path . '/src/Bootstraps')) { list_classes($classes, $this->path . '/src/Bootstraps', $this->namespace . 'Bootstraps'); } if (empty($classes)) { return; } // Read enabled packages and add/remove the current plugin. $packages = $this->listPackages($register); // update manifest $dest = ''; foreach ($packages as $package => $relativePath) { $path = base_path($relativePath); $classes = []; if (file_exists($path . '/src/Bootstraps')) { $namespace = $this->getNamespace($path . '/composer.json'); list_classes($classes, $path . '/src/Bootstraps', $namespace . 'Bootstraps'); } if (empty($classes)) { continue; } $dest .= PHP_EOL . '///////////////////////////////////////////////////////////////////////////////' . PHP_EOL . '// ' . $package . PHP_EOL . PHP_EOL; foreach ($classes as $class) { $dest .= '(new ' . $class . ')->boot();' . PHP_EOL; } } $this->saveContent($this->getManifest('bootstrap'), '<?php' . PHP_EOL . $dest); }
[ "private", "function", "publishBootstraps", "(", "$", "register", ")", "{", "$", "classes", "=", "[", "]", ";", "if", "(", "file_exists", "(", "$", "this", "->", "path", ".", "'/src/Bootstraps'", ")", ")", "{", "list_classes", "(", "$", "classes", ",", "$", "this", "->", "path", ".", "'/src/Bootstraps'", ",", "$", "this", "->", "namespace", ".", "'Bootstraps'", ")", ";", "}", "if", "(", "empty", "(", "$", "classes", ")", ")", "{", "return", ";", "}", "// Read enabled packages and add/remove the current plugin.", "$", "packages", "=", "$", "this", "->", "listPackages", "(", "$", "register", ")", ";", "// update manifest", "$", "dest", "=", "''", ";", "foreach", "(", "$", "packages", "as", "$", "package", "=>", "$", "relativePath", ")", "{", "$", "path", "=", "base_path", "(", "$", "relativePath", ")", ";", "$", "classes", "=", "[", "]", ";", "if", "(", "file_exists", "(", "$", "path", ".", "'/src/Bootstraps'", ")", ")", "{", "$", "namespace", "=", "$", "this", "->", "getNamespace", "(", "$", "path", ".", "'/composer.json'", ")", ";", "list_classes", "(", "$", "classes", ",", "$", "path", ".", "'/src/Bootstraps'", ",", "$", "namespace", ".", "'Bootstraps'", ")", ";", "}", "if", "(", "empty", "(", "$", "classes", ")", ")", "{", "continue", ";", "}", "$", "dest", ".=", "PHP_EOL", ".", "'///////////////////////////////////////////////////////////////////////////////'", ".", "PHP_EOL", ".", "'// '", ".", "$", "package", ".", "PHP_EOL", ".", "PHP_EOL", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "$", "dest", ".=", "'(new '", ".", "$", "class", ".", "')->boot();'", ".", "PHP_EOL", ";", "}", "}", "$", "this", "->", "saveContent", "(", "$", "this", "->", "getManifest", "(", "'bootstrap'", ")", ",", "'<?php'", ".", "PHP_EOL", ".", "$", "dest", ")", ";", "}" ]
Update manifest "bootstraps.php". @param bool $register
[ "Update", "manifest", "bootstraps", ".", "php", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L712-L749
8,634
pletfix/core
src/Services/PluginManager.php
PluginManager.saveArray
private function saveArray($file, $array) { if (file_put_contents($file, '<?php return ' . var_export($array, true) . ';' . PHP_EOL, LOCK_EX) === false) { throw new RuntimeException('Plugin Manager is not able to save ' . $file . '.'); // @codeCoverageIgnore } }
php
private function saveArray($file, $array) { if (file_put_contents($file, '<?php return ' . var_export($array, true) . ';' . PHP_EOL, LOCK_EX) === false) { throw new RuntimeException('Plugin Manager is not able to save ' . $file . '.'); // @codeCoverageIgnore } }
[ "private", "function", "saveArray", "(", "$", "file", ",", "$", "array", ")", "{", "if", "(", "file_put_contents", "(", "$", "file", ",", "'<?php return '", ".", "var_export", "(", "$", "array", ",", "true", ")", ".", "';'", ".", "PHP_EOL", ",", "LOCK_EX", ")", "===", "false", ")", "{", "throw", "new", "RuntimeException", "(", "'Plugin Manager is not able to save '", ".", "$", "file", ".", "'.'", ")", ";", "// @codeCoverageIgnore", "}", "}" ]
Save array as an include file. @param string $file @param array $array
[ "Save", "array", "as", "an", "include", "file", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PluginManager.php#L829-L834
8,635
f1code/f1-wp-utils
src/Admin/AdminPageHelper.php
AdminPageHelper.registerOptionPage
public function registerOptionPage($pluginName = null) { add_action('admin_init', array(&$this, 'adminInit')); if ($this->multiSite) { add_action('network_admin_menu', array(&$this, 'networkAdminMenu')); add_action('update_wpmu_options', array(&$this, 'adminUpdateOptions')); } else { add_action('admin_menu', array(&$this, 'adminMenu')); } if ($pluginName) { add_filter("plugin_action_links_" . $pluginName, array(&$this, 'settingsLink')); } }
php
public function registerOptionPage($pluginName = null) { add_action('admin_init', array(&$this, 'adminInit')); if ($this->multiSite) { add_action('network_admin_menu', array(&$this, 'networkAdminMenu')); add_action('update_wpmu_options', array(&$this, 'adminUpdateOptions')); } else { add_action('admin_menu', array(&$this, 'adminMenu')); } if ($pluginName) { add_filter("plugin_action_links_" . $pluginName, array(&$this, 'settingsLink')); } }
[ "public", "function", "registerOptionPage", "(", "$", "pluginName", "=", "null", ")", "{", "add_action", "(", "'admin_init'", ",", "array", "(", "&", "$", "this", ",", "'adminInit'", ")", ")", ";", "if", "(", "$", "this", "->", "multiSite", ")", "{", "add_action", "(", "'network_admin_menu'", ",", "array", "(", "&", "$", "this", ",", "'networkAdminMenu'", ")", ")", ";", "add_action", "(", "'update_wpmu_options'", ",", "array", "(", "&", "$", "this", ",", "'adminUpdateOptions'", ")", ")", ";", "}", "else", "{", "add_action", "(", "'admin_menu'", ",", "array", "(", "&", "$", "this", ",", "'adminMenu'", ")", ")", ";", "}", "if", "(", "$", "pluginName", ")", "{", "add_filter", "(", "\"plugin_action_links_\"", ".", "$", "pluginName", ",", "array", "(", "&", "$", "this", ",", "'settingsLink'", ")", ")", ";", "}", "}" ]
Register WP hooks to render admin page. Should be called inside of WP_Loaded hook, but can be called either after or before adding the settings. @param string $pluginName - If specified, this will register a "settings" link for the plugin.
[ "Register", "WP", "hooks", "to", "render", "admin", "page", ".", "Should", "be", "called", "inside", "of", "WP_Loaded", "hook", "but", "can", "be", "called", "either", "after", "or", "before", "adding", "the", "settings", "." ]
cd299453b49cd537daf15ee2ee23582fd95922d7
https://github.com/f1code/f1-wp-utils/blob/cd299453b49cd537daf15ee2ee23582fd95922d7/src/Admin/AdminPageHelper.php#L46-L58
8,636
f1code/f1-wp-utils
src/Admin/AdminPageHelper.php
AdminPageHelper.addSetting
public function addSetting($name, $label, $renderer = null, $args = null, $default = null) { if (!$renderer) $renderer = array($this, 'createSettingsTextbox'); $this->settings[] = array('name' => $name, 'label' => $label, 'renderer' => $renderer, 'args' => $args, 'default' => $default); }
php
public function addSetting($name, $label, $renderer = null, $args = null, $default = null) { if (!$renderer) $renderer = array($this, 'createSettingsTextbox'); $this->settings[] = array('name' => $name, 'label' => $label, 'renderer' => $renderer, 'args' => $args, 'default' => $default); }
[ "public", "function", "addSetting", "(", "$", "name", ",", "$", "label", ",", "$", "renderer", "=", "null", ",", "$", "args", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "$", "renderer", ")", "$", "renderer", "=", "array", "(", "$", "this", ",", "'createSettingsTextbox'", ")", ";", "$", "this", "->", "settings", "[", "]", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'label'", "=>", "$", "label", ",", "'renderer'", "=>", "$", "renderer", ",", "'args'", "=>", "$", "args", ",", "'default'", "=>", "$", "default", ")", ";", "}" ]
Register a new setting @param string $name @param string $label @param callable $renderer @param array $args @param mixed $default - a default value for the setting
[ "Register", "a", "new", "setting" ]
cd299453b49cd537daf15ee2ee23582fd95922d7
https://github.com/f1code/f1-wp-utils/blob/cd299453b49cd537daf15ee2ee23582fd95922d7/src/Admin/AdminPageHelper.php#L82-L88
8,637
f1code/f1-wp-utils
src/Admin/AdminPageHelper.php
AdminPageHelper.adminUpdateOptions
public function adminUpdateOptions() { if (isset($_GET['settings']) && $_GET['settings'] == $this->settingsName) { $cleanPost = $_POST; if (function_exists('wp_magic_quotes')) { $cleanPost = array_map('stripslashes_deep', $cleanPost); } $options = $cleanPost[$this->settingsName]; $options = $this->onSanitizeOptions($options); update_site_option($this->settingsName, $options); wp_redirect(network_admin_url('settings.php?updated=true&page=' . $this->settingsName)); exit(); } }
php
public function adminUpdateOptions() { if (isset($_GET['settings']) && $_GET['settings'] == $this->settingsName) { $cleanPost = $_POST; if (function_exists('wp_magic_quotes')) { $cleanPost = array_map('stripslashes_deep', $cleanPost); } $options = $cleanPost[$this->settingsName]; $options = $this->onSanitizeOptions($options); update_site_option($this->settingsName, $options); wp_redirect(network_admin_url('settings.php?updated=true&page=' . $this->settingsName)); exit(); } }
[ "public", "function", "adminUpdateOptions", "(", ")", "{", "if", "(", "isset", "(", "$", "_GET", "[", "'settings'", "]", ")", "&&", "$", "_GET", "[", "'settings'", "]", "==", "$", "this", "->", "settingsName", ")", "{", "$", "cleanPost", "=", "$", "_POST", ";", "if", "(", "function_exists", "(", "'wp_magic_quotes'", ")", ")", "{", "$", "cleanPost", "=", "array_map", "(", "'stripslashes_deep'", ",", "$", "cleanPost", ")", ";", "}", "$", "options", "=", "$", "cleanPost", "[", "$", "this", "->", "settingsName", "]", ";", "$", "options", "=", "$", "this", "->", "onSanitizeOptions", "(", "$", "options", ")", ";", "update_site_option", "(", "$", "this", "->", "settingsName", ",", "$", "options", ")", ";", "wp_redirect", "(", "network_admin_url", "(", "'settings.php?updated=true&page='", ".", "$", "this", "->", "settingsName", ")", ")", ";", "exit", "(", ")", ";", "}", "}" ]
Used for network settings page
[ "Used", "for", "network", "settings", "page" ]
cd299453b49cd537daf15ee2ee23582fd95922d7
https://github.com/f1code/f1-wp-utils/blob/cd299453b49cd537daf15ee2ee23582fd95922d7/src/Admin/AdminPageHelper.php#L125-L138
8,638
f1code/f1-wp-utils
src/Admin/AdminPageHelper.php
AdminPageHelper.getOption
public function getOption($optionName = null) { if ($this->multiSite) { $options = get_site_option($this->settingsName); } else { $options = get_option($this->settingsName); } if (!$optionName) return $options; if (is_array($options) && isset($options[$optionName])) return $options[$optionName]; foreach ($this->settings as $setting) { if ($setting['name'] == $optionName) { if (!empty($setting['default'])) return $setting['default']; break; } } return null; }
php
public function getOption($optionName = null) { if ($this->multiSite) { $options = get_site_option($this->settingsName); } else { $options = get_option($this->settingsName); } if (!$optionName) return $options; if (is_array($options) && isset($options[$optionName])) return $options[$optionName]; foreach ($this->settings as $setting) { if ($setting['name'] == $optionName) { if (!empty($setting['default'])) return $setting['default']; break; } } return null; }
[ "public", "function", "getOption", "(", "$", "optionName", "=", "null", ")", "{", "if", "(", "$", "this", "->", "multiSite", ")", "{", "$", "options", "=", "get_site_option", "(", "$", "this", "->", "settingsName", ")", ";", "}", "else", "{", "$", "options", "=", "get_option", "(", "$", "this", "->", "settingsName", ")", ";", "}", "if", "(", "!", "$", "optionName", ")", "return", "$", "options", ";", "if", "(", "is_array", "(", "$", "options", ")", "&&", "isset", "(", "$", "options", "[", "$", "optionName", "]", ")", ")", "return", "$", "options", "[", "$", "optionName", "]", ";", "foreach", "(", "$", "this", "->", "settings", "as", "$", "setting", ")", "{", "if", "(", "$", "setting", "[", "'name'", "]", "==", "$", "optionName", ")", "{", "if", "(", "!", "empty", "(", "$", "setting", "[", "'default'", "]", ")", ")", "return", "$", "setting", "[", "'default'", "]", ";", "break", ";", "}", "}", "return", "null", ";", "}" ]
Retrieve option value. If the option is not set and a default was provided when adding the setting, it will be returned instead. @param string $optionName @return mixed
[ "Retrieve", "option", "value", ".", "If", "the", "option", "is", "not", "set", "and", "a", "default", "was", "provided", "when", "adding", "the", "setting", "it", "will", "be", "returned", "instead", "." ]
cd299453b49cd537daf15ee2ee23582fd95922d7
https://github.com/f1code/f1-wp-utils/blob/cd299453b49cd537daf15ee2ee23582fd95922d7/src/Admin/AdminPageHelper.php#L270-L290
8,639
mijohansen/php-gae-util
src/Util.php
Util.saveIncludedFiles
static function saveIncludedFiles($filename, $fromFile) { if (file_exists($filename)) { $all_included_files = json_decode(file_get_contents($filename), JSON_OBJECT_AS_ARRAY); } else { $all_included_files = array(); } foreach (get_included_files() as $includedFile) { if (!isset($all_included_files[$includedFile])) { $all_included_files[$includedFile] = array(); } if (!in_array($fromFile, $all_included_files[$includedFile])) { array_push($all_included_files[$includedFile], $fromFile); } } file_put_contents($filename, json_encode($all_included_files)); }
php
static function saveIncludedFiles($filename, $fromFile) { if (file_exists($filename)) { $all_included_files = json_decode(file_get_contents($filename), JSON_OBJECT_AS_ARRAY); } else { $all_included_files = array(); } foreach (get_included_files() as $includedFile) { if (!isset($all_included_files[$includedFile])) { $all_included_files[$includedFile] = array(); } if (!in_array($fromFile, $all_included_files[$includedFile])) { array_push($all_included_files[$includedFile], $fromFile); } } file_put_contents($filename, json_encode($all_included_files)); }
[ "static", "function", "saveIncludedFiles", "(", "$", "filename", ",", "$", "fromFile", ")", "{", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "all_included_files", "=", "json_decode", "(", "file_get_contents", "(", "$", "filename", ")", ",", "JSON_OBJECT_AS_ARRAY", ")", ";", "}", "else", "{", "$", "all_included_files", "=", "array", "(", ")", ";", "}", "foreach", "(", "get_included_files", "(", ")", "as", "$", "includedFile", ")", "{", "if", "(", "!", "isset", "(", "$", "all_included_files", "[", "$", "includedFile", "]", ")", ")", "{", "$", "all_included_files", "[", "$", "includedFile", "]", "=", "array", "(", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "fromFile", ",", "$", "all_included_files", "[", "$", "includedFile", "]", ")", ")", "{", "array_push", "(", "$", "all_included_files", "[", "$", "includedFile", "]", ",", "$", "fromFile", ")", ";", "}", "}", "file_put_contents", "(", "$", "filename", ",", "json_encode", "(", "$", "all_included_files", ")", ")", ";", "}" ]
Used to inspect shit @param string $filename
[ "Used", "to", "inspect", "shit" ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Util.php#L25-L40
8,640
xloit/xloit-bridge-zend-authentication
src/AuthenticationEvent.php
AuthenticationEvent.setIdentity
public function setIdentity($identity = null) { if (null === $identity) { $this->setResult(); } $this->setParam('identity', $identity); return $this; }
php
public function setIdentity($identity = null) { if (null === $identity) { $this->setResult(); } $this->setParam('identity', $identity); return $this; }
[ "public", "function", "setIdentity", "(", "$", "identity", "=", "null", ")", "{", "if", "(", "null", "===", "$", "identity", ")", "{", "$", "this", "->", "setResult", "(", ")", ";", "}", "$", "this", "->", "setParam", "(", "'identity'", ",", "$", "identity", ")", ";", "return", "$", "this", ";", "}" ]
Sets the identity. @param mixed $identity @return $this
[ "Sets", "the", "identity", "." ]
299c6ad8d5756c8db040b39a50ecfcc137c42b72
https://github.com/xloit/xloit-bridge-zend-authentication/blob/299c6ad8d5756c8db040b39a50ecfcc137c42b72/src/AuthenticationEvent.php#L75-L84
8,641
CableFramework/Caching
src/Components/Caching/CachingProvider.php
CachingProvider.boot
public function boot() { $this->getContainer() ->addProvider(ArraySerializerProvider::class) ->addProvider(JsonSerializerProvider::class) ->addProvider(CompressorProvider::class) ->addProvider(ArrayCacheDriver::class); }
php
public function boot() { $this->getContainer() ->addProvider(ArraySerializerProvider::class) ->addProvider(JsonSerializerProvider::class) ->addProvider(CompressorProvider::class) ->addProvider(ArrayCacheDriver::class); }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "addProvider", "(", "ArraySerializerProvider", "::", "class", ")", "->", "addProvider", "(", "JsonSerializerProvider", "::", "class", ")", "->", "addProvider", "(", "CompressorProvider", "::", "class", ")", "->", "addProvider", "(", "ArrayCacheDriver", "::", "class", ")", ";", "}" ]
register new providers or something @throws ProviderException @return mixed
[ "register", "new", "providers", "or", "something" ]
51d84c92c2c3985f0b36975b2fdbe1ba106dec4e
https://github.com/CableFramework/Caching/blob/51d84c92c2c3985f0b36975b2fdbe1ba106dec4e/src/Components/Caching/CachingProvider.php#L21-L28
8,642
livecms/core
src/Models/Traits/SearchableTrait.php
SearchableTrait.search
public static function search($query, $callback = null) { if (config('livecms.deepsearch', false)) { return static::LaravelSearch($query, $callback); } $instance = new static; if ($instance instanceof PostableModel) { $mandatoryField = 'title'; $selectFields = ['id', 'title', 'slug', 'published_at', 'status', 'author_id']; return $instance->select($selectFields)->where($mandatoryField, 'like', '%'.$query.'%'); } else { $mandatoryField = strtolower((new \ReflectionClass($instance))->getShortName()); if (in_array($mandatoryField, $instance->getFillable())) { return $instance->where($mandatoryField, 'like', '%'.$query.'%'); } } return $instance->where($instance->getKeyName(), null); }
php
public static function search($query, $callback = null) { if (config('livecms.deepsearch', false)) { return static::LaravelSearch($query, $callback); } $instance = new static; if ($instance instanceof PostableModel) { $mandatoryField = 'title'; $selectFields = ['id', 'title', 'slug', 'published_at', 'status', 'author_id']; return $instance->select($selectFields)->where($mandatoryField, 'like', '%'.$query.'%'); } else { $mandatoryField = strtolower((new \ReflectionClass($instance))->getShortName()); if (in_array($mandatoryField, $instance->getFillable())) { return $instance->where($mandatoryField, 'like', '%'.$query.'%'); } } return $instance->where($instance->getKeyName(), null); }
[ "public", "static", "function", "search", "(", "$", "query", ",", "$", "callback", "=", "null", ")", "{", "if", "(", "config", "(", "'livecms.deepsearch'", ",", "false", ")", ")", "{", "return", "static", "::", "LaravelSearch", "(", "$", "query", ",", "$", "callback", ")", ";", "}", "$", "instance", "=", "new", "static", ";", "if", "(", "$", "instance", "instanceof", "PostableModel", ")", "{", "$", "mandatoryField", "=", "'title'", ";", "$", "selectFields", "=", "[", "'id'", ",", "'title'", ",", "'slug'", ",", "'published_at'", ",", "'status'", ",", "'author_id'", "]", ";", "return", "$", "instance", "->", "select", "(", "$", "selectFields", ")", "->", "where", "(", "$", "mandatoryField", ",", "'like'", ",", "'%'", ".", "$", "query", ".", "'%'", ")", ";", "}", "else", "{", "$", "mandatoryField", "=", "strtolower", "(", "(", "new", "\\", "ReflectionClass", "(", "$", "instance", ")", ")", "->", "getShortName", "(", ")", ")", ";", "if", "(", "in_array", "(", "$", "mandatoryField", ",", "$", "instance", "->", "getFillable", "(", ")", ")", ")", "{", "return", "$", "instance", "->", "where", "(", "$", "mandatoryField", ",", "'like'", ",", "'%'", ".", "$", "query", ".", "'%'", ")", ";", "}", "}", "return", "$", "instance", "->", "where", "(", "$", "instance", "->", "getKeyName", "(", ")", ",", "null", ")", ";", "}" ]
Override Laravel Scout's search. @param string $query @param Closure $callback @return \Laravel\Scout\Builder
[ "Override", "Laravel", "Scout", "s", "search", "." ]
1df29cacb46752851d94021e3c6187e0f6827c4e
https://github.com/livecms/core/blob/1df29cacb46752851d94021e3c6187e0f6827c4e/src/Models/Traits/SearchableTrait.php#L21-L41
8,643
bookability/bookability-php
src/Bookability/Resources.php
Bookability_Resources.update
public function update($token, $_params = array()) { return $this->transform($this->master->put('resources/' . $token, $_params), true); }
php
public function update($token, $_params = array()) { return $this->transform($this->master->put('resources/' . $token, $_params), true); }
[ "public", "function", "update", "(", "$", "token", ",", "$", "_params", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "transform", "(", "$", "this", "->", "master", "->", "put", "(", "'resources/'", ".", "$", "token", ",", "$", "_params", ")", ",", "true", ")", ";", "}" ]
Update a single resource @return array
[ "Update", "a", "single", "resource" ]
be455327f2a965877d2b2a59edfe9ed71aed58aa
https://github.com/bookability/bookability-php/blob/be455327f2a965877d2b2a59edfe9ed71aed58aa/src/Bookability/Resources.php#L41-L44
8,644
dotkernel/dot-controller
src/AbstractController.php
AbstractController.getMethodFromAction
public static function getMethodFromAction(string $action): string { $method = str_replace(['.', '-', '_'], ' ', $action); $method = ucwords($method); $method = str_replace(' ', '', $method); $method = lcfirst($method); $method .= 'Action'; return $method; }
php
public static function getMethodFromAction(string $action): string { $method = str_replace(['.', '-', '_'], ' ', $action); $method = ucwords($method); $method = str_replace(' ', '', $method); $method = lcfirst($method); $method .= 'Action'; return $method; }
[ "public", "static", "function", "getMethodFromAction", "(", "string", "$", "action", ")", ":", "string", "{", "$", "method", "=", "str_replace", "(", "[", "'.'", ",", "'-'", ",", "'_'", "]", ",", "' '", ",", "$", "action", ")", ";", "$", "method", "=", "ucwords", "(", "$", "method", ")", ";", "$", "method", "=", "str_replace", "(", "' '", ",", "''", ",", "$", "method", ")", ";", "$", "method", "=", "lcfirst", "(", "$", "method", ")", ";", "$", "method", ".=", "'Action'", ";", "return", "$", "method", ";", "}" ]
Transform an "action" token into a method name @param string $action @return string
[ "Transform", "an", "action", "token", "into", "a", "method", "name" ]
5a67877c205554eb35895213287a95b504d65254
https://github.com/dotkernel/dot-controller/blob/5a67877c205554eb35895213287a95b504d65254/src/AbstractController.php#L53-L61
8,645
dotkernel/dot-controller
src/AbstractController.php
AbstractController.plugin
public function plugin(string $name, array $options = []): PluginInterface { return $this->getPluginManager()->get($name, $options); }
php
public function plugin(string $name, array $options = []): PluginInterface { return $this->getPluginManager()->get($name, $options); }
[ "public", "function", "plugin", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "PluginInterface", "{", "return", "$", "this", "->", "getPluginManager", "(", ")", "->", "get", "(", "$", "name", ",", "$", "options", ")", ";", "}" ]
Get plugin instance @param string $name Name of plugin to return @param array $options Options to pass to plugin constructor (if not already instantiated) @return PluginInterface|callable
[ "Get", "plugin", "instance" ]
5a67877c205554eb35895213287a95b504d65254
https://github.com/dotkernel/dot-controller/blob/5a67877c205554eb35895213287a95b504d65254/src/AbstractController.php#L115-L118
8,646
mooti/framework
src/Application/ApplicationRuntime.php
ApplicationRuntime.locateRootDirectory
public function locateRootDirectory() { $vendorDirectoryName = 'vendor'; $fileDirectory = __DIR__; $searchDirectories = [ __DIR__.'/..', __DIR__.'/../..', __DIR__.'/../../..', __DIR__.'/../../../..', __DIR__.'/../../../../..' ]; $fileSystem = $this->createNew(FileSystem::class); foreach ($searchDirectories as $searchDirectory) { if ($fileSystem->fileExists($searchDirectory . '/' . $vendorDirectoryName)) { return $fileSystem->getRealPath($searchDirectory); } } throw new FileSystemException('No application root directory found'); }
php
public function locateRootDirectory() { $vendorDirectoryName = 'vendor'; $fileDirectory = __DIR__; $searchDirectories = [ __DIR__.'/..', __DIR__.'/../..', __DIR__.'/../../..', __DIR__.'/../../../..', __DIR__.'/../../../../..' ]; $fileSystem = $this->createNew(FileSystem::class); foreach ($searchDirectories as $searchDirectory) { if ($fileSystem->fileExists($searchDirectory . '/' . $vendorDirectoryName)) { return $fileSystem->getRealPath($searchDirectory); } } throw new FileSystemException('No application root directory found'); }
[ "public", "function", "locateRootDirectory", "(", ")", "{", "$", "vendorDirectoryName", "=", "'vendor'", ";", "$", "fileDirectory", "=", "__DIR__", ";", "$", "searchDirectories", "=", "[", "__DIR__", ".", "'/..'", ",", "__DIR__", ".", "'/../..'", ",", "__DIR__", ".", "'/../../..'", ",", "__DIR__", ".", "'/../../../..'", ",", "__DIR__", ".", "'/../../../../..'", "]", ";", "$", "fileSystem", "=", "$", "this", "->", "createNew", "(", "FileSystem", "::", "class", ")", ";", "foreach", "(", "$", "searchDirectories", "as", "$", "searchDirectory", ")", "{", "if", "(", "$", "fileSystem", "->", "fileExists", "(", "$", "searchDirectory", ".", "'/'", ".", "$", "vendorDirectoryName", ")", ")", "{", "return", "$", "fileSystem", "->", "getRealPath", "(", "$", "searchDirectory", ")", ";", "}", "}", "throw", "new", "FileSystemException", "(", "'No application root directory found'", ")", ";", "}" ]
Attempts to find the root directory @return string The application root directory
[ "Attempts", "to", "find", "the", "root", "directory" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Application/ApplicationRuntime.php#L33-L53
8,647
mooti/framework
src/Application/ApplicationRuntime.php
ApplicationRuntime.getRootDirectory
public function getRootDirectory() { if(isset($this->rootDirectory) == false) { $this->rootDirectory = $this->locateRootDirectory(); } return $this->rootDirectory; }
php
public function getRootDirectory() { if(isset($this->rootDirectory) == false) { $this->rootDirectory = $this->locateRootDirectory(); } return $this->rootDirectory; }
[ "public", "function", "getRootDirectory", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "rootDirectory", ")", "==", "false", ")", "{", "$", "this", "->", "rootDirectory", "=", "$", "this", "->", "locateRootDirectory", "(", ")", ";", "}", "return", "$", "this", "->", "rootDirectory", ";", "}" ]
Get the root directory @return string The application root directory
[ "Get", "the", "root", "directory" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Application/ApplicationRuntime.php#L60-L66
8,648
emhar/SearchDoctrineBundle
Factory/AbstractCachedFactory.php
AbstractCachedFactory.get
protected function get($objectName, $datas = null) { if(isset($this->bag[$objectName])) { return $this->bag[$objectName]; } if($this->cacheDriver) { if(($cached = $this->cacheDriver->fetch($objectName . $this->cacheSalt)) !== false) { $this->bag[$objectName] = $cached; } else { $this->load($objectName, $datas); $this->cacheDriver->save( $objectName . $this->getCacheSalt(), $this->bag[$objectName] ); } } else { $this->load($objectName, $datas); } return $this->bag[$objectName]; }
php
protected function get($objectName, $datas = null) { if(isset($this->bag[$objectName])) { return $this->bag[$objectName]; } if($this->cacheDriver) { if(($cached = $this->cacheDriver->fetch($objectName . $this->cacheSalt)) !== false) { $this->bag[$objectName] = $cached; } else { $this->load($objectName, $datas); $this->cacheDriver->save( $objectName . $this->getCacheSalt(), $this->bag[$objectName] ); } } else { $this->load($objectName, $datas); } return $this->bag[$objectName]; }
[ "protected", "function", "get", "(", "$", "objectName", ",", "$", "datas", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "bag", "[", "$", "objectName", "]", ")", ")", "{", "return", "$", "this", "->", "bag", "[", "$", "objectName", "]", ";", "}", "if", "(", "$", "this", "->", "cacheDriver", ")", "{", "if", "(", "(", "$", "cached", "=", "$", "this", "->", "cacheDriver", "->", "fetch", "(", "$", "objectName", ".", "$", "this", "->", "cacheSalt", ")", ")", "!==", "false", ")", "{", "$", "this", "->", "bag", "[", "$", "objectName", "]", "=", "$", "cached", ";", "}", "else", "{", "$", "this", "->", "load", "(", "$", "objectName", ",", "$", "datas", ")", ";", "$", "this", "->", "cacheDriver", "->", "save", "(", "$", "objectName", ".", "$", "this", "->", "getCacheSalt", "(", ")", ",", "$", "this", "->", "bag", "[", "$", "objectName", "]", ")", ";", "}", "}", "else", "{", "$", "this", "->", "load", "(", "$", "objectName", ",", "$", "datas", ")", ";", "}", "return", "$", "this", "->", "bag", "[", "$", "objectName", "]", ";", "}" ]
Call this method to get the object @param string $objectName @param mixed $datas @return mixed
[ "Call", "this", "method", "to", "get", "the", "object" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Factory/AbstractCachedFactory.php#L72-L99
8,649
emhar/SearchDoctrineBundle
Factory/AbstractCachedFactory.php
AbstractCachedFactory.load
private function load($objectName, $datas) { if(!$this->initialized) { $this->initialize(); $this->initialized = true; } $this->bag[$objectName] = $this->doLoad(isset($datas) ? $datas : $objectName); }
php
private function load($objectName, $datas) { if(!$this->initialized) { $this->initialize(); $this->initialized = true; } $this->bag[$objectName] = $this->doLoad(isset($datas) ? $datas : $objectName); }
[ "private", "function", "load", "(", "$", "objectName", ",", "$", "datas", ")", "{", "if", "(", "!", "$", "this", "->", "initialized", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "$", "this", "->", "initialized", "=", "true", ";", "}", "$", "this", "->", "bag", "[", "$", "objectName", "]", "=", "$", "this", "->", "doLoad", "(", "isset", "(", "$", "datas", ")", "?", "$", "datas", ":", "$", "objectName", ")", ";", "}" ]
Initialise factory construct new object instance and store it in bag @param string $objectName @param mixed $datas
[ "Initialise", "factory", "construct", "new", "object", "instance", "and", "store", "it", "in", "bag" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Factory/AbstractCachedFactory.php#L108-L116
8,650
samurai-fw/samurai
src/Samurai/Component/FileSystem/File.php
File.appNameSpace
public function appNameSpace() { $app_dir = $this->appDir(); $root_dir = $this->rootDir(); $ns_path = substr($app_dir, strlen($root_dir) + 1); return str_replace(DS, '\\', $ns_path); }
php
public function appNameSpace() { $app_dir = $this->appDir(); $root_dir = $this->rootDir(); $ns_path = substr($app_dir, strlen($root_dir) + 1); return str_replace(DS, '\\', $ns_path); }
[ "public", "function", "appNameSpace", "(", ")", "{", "$", "app_dir", "=", "$", "this", "->", "appDir", "(", ")", ";", "$", "root_dir", "=", "$", "this", "->", "rootDir", "(", ")", ";", "$", "ns_path", "=", "substr", "(", "$", "app_dir", ",", "strlen", "(", "$", "root_dir", ")", "+", "1", ")", ";", "return", "str_replace", "(", "DS", ",", "'\\\\'", ",", "$", "ns_path", ")", ";", "}" ]
app namespace accessor. @access public @return string
[ "app", "namespace", "accessor", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/File.php#L161-L167
8,651
samurai-fw/samurai
src/Samurai/Component/FileSystem/File.php
File.absolutize
public function absolutize() { $new = []; $path = $this->path; if ($path[0] !== '/') $path = $this->cwd . DS . $this->path; $paths = explode(DS, $path); foreach ($paths as $p) { switch ($p) { case '.': break; case '..': array_pop($new); if (!$new) $new[] = ''; break; default: $new[] = $p; break; } } $this->path = join(DS, $new); }
php
public function absolutize() { $new = []; $path = $this->path; if ($path[0] !== '/') $path = $this->cwd . DS . $this->path; $paths = explode(DS, $path); foreach ($paths as $p) { switch ($p) { case '.': break; case '..': array_pop($new); if (!$new) $new[] = ''; break; default: $new[] = $p; break; } } $this->path = join(DS, $new); }
[ "public", "function", "absolutize", "(", ")", "{", "$", "new", "=", "[", "]", ";", "$", "path", "=", "$", "this", "->", "path", ";", "if", "(", "$", "path", "[", "0", "]", "!==", "'/'", ")", "$", "path", "=", "$", "this", "->", "cwd", ".", "DS", ".", "$", "this", "->", "path", ";", "$", "paths", "=", "explode", "(", "DS", ",", "$", "path", ")", ";", "foreach", "(", "$", "paths", "as", "$", "p", ")", "{", "switch", "(", "$", "p", ")", "{", "case", "'.'", ":", "break", ";", "case", "'..'", ":", "array_pop", "(", "$", "new", ")", ";", "if", "(", "!", "$", "new", ")", "$", "new", "[", "]", "=", "''", ";", "break", ";", "default", ":", "$", "new", "[", "]", "=", "$", "p", ";", "break", ";", "}", "}", "$", "this", "->", "path", "=", "join", "(", "DS", ",", "$", "new", ")", ";", "}" ]
relational path to absolute path. @access public
[ "relational", "path", "to", "absolute", "path", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/File.php#L243-L263
8,652
nilportugues/php-uuid
src/Uuid.php
Uuid.create
public static function create($namespace = null, $name = null) { if (null === $namespace) { return self::createNamespacelessUuid(); } return self::createNamespacedUuid($namespace, $name); }
php
public static function create($namespace = null, $name = null) { if (null === $namespace) { return self::createNamespacelessUuid(); } return self::createNamespacedUuid($namespace, $name); }
[ "public", "static", "function", "create", "(", "$", "namespace", "=", "null", ",", "$", "name", "=", "null", ")", "{", "if", "(", "null", "===", "$", "namespace", ")", "{", "return", "self", "::", "createNamespacelessUuid", "(", ")", ";", "}", "return", "self", "::", "createNamespacedUuid", "(", "$", "namespace", ",", "$", "name", ")", ";", "}" ]
Returns an Uuid identifier. @param string|null $namespace @param string|null $name @return string
[ "Returns", "an", "Uuid", "identifier", "." ]
5ac964774272b1d918fea3d9e528f49e2c3fc8ce
https://github.com/nilportugues/php-uuid/blob/5ac964774272b1d918fea3d9e528f49e2c3fc8ce/src/Uuid.php#L64-L71
8,653
nilportugues/php-uuid
src/Uuid.php
Uuid.generate
private static function generate($uuidKey, array $arguments) { $classAndMethod = \explode('::', self::$uuidMap[$uuidKey]); return \call_user_func_array($classAndMethod, $arguments); }
php
private static function generate($uuidKey, array $arguments) { $classAndMethod = \explode('::', self::$uuidMap[$uuidKey]); return \call_user_func_array($classAndMethod, $arguments); }
[ "private", "static", "function", "generate", "(", "$", "uuidKey", ",", "array", "$", "arguments", ")", "{", "$", "classAndMethod", "=", "\\", "explode", "(", "'::'", ",", "self", "::", "$", "uuidMap", "[", "$", "uuidKey", "]", ")", ";", "return", "\\", "call_user_func_array", "(", "$", "classAndMethod", ",", "$", "arguments", ")", ";", "}" ]
Call a Uuid generator and returns an Uuid identifier. @param string $uuidKey @param array $arguments @return string
[ "Call", "a", "Uuid", "generator", "and", "returns", "an", "Uuid", "identifier", "." ]
5ac964774272b1d918fea3d9e528f49e2c3fc8ce
https://github.com/nilportugues/php-uuid/blob/5ac964774272b1d918fea3d9e528f49e2c3fc8ce/src/Uuid.php#L91-L96
8,654
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.getEvent
protected function getEvent() { if (null === $this->event) { $this->event = $event = new EntityEvent; $event->setTarget($this); } return $this->event; }
php
protected function getEvent() { if (null === $this->event) { $this->event = $event = new EntityEvent; $event->setTarget($this); } return $this->event; }
[ "protected", "function", "getEvent", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "event", ")", "{", "$", "this", "->", "event", "=", "$", "event", "=", "new", "EntityEvent", ";", "$", "event", "->", "setTarget", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "event", ";", "}" ]
Get the pre initialized event object @return EntityEvent
[ "Get", "the", "pre", "initialized", "event", "object" ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L87-L96
8,655
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.setEventManager
public function setEventManager(EventManagerInterface $eventManager) { if ($this->eventManager === $eventManager || $eventManager === null) { return; } if ($this->eventManager !== null) { $this->detach($this->eventManager); } $this->eventManager = $eventManager; $this->eventManager->addIdentifiers([ 'EntityService', 'PolderKnowledge\EntityService\Service\EntityService', $this->getEntityServiceName(), trim($this->getEntityServiceName(), '\\'), ]); $this->attach($this->eventManager); }
php
public function setEventManager(EventManagerInterface $eventManager) { if ($this->eventManager === $eventManager || $eventManager === null) { return; } if ($this->eventManager !== null) { $this->detach($this->eventManager); } $this->eventManager = $eventManager; $this->eventManager->addIdentifiers([ 'EntityService', 'PolderKnowledge\EntityService\Service\EntityService', $this->getEntityServiceName(), trim($this->getEntityServiceName(), '\\'), ]); $this->attach($this->eventManager); }
[ "public", "function", "setEventManager", "(", "EventManagerInterface", "$", "eventManager", ")", "{", "if", "(", "$", "this", "->", "eventManager", "===", "$", "eventManager", "||", "$", "eventManager", "===", "null", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "eventManager", "!==", "null", ")", "{", "$", "this", "->", "detach", "(", "$", "this", "->", "eventManager", ")", ";", "}", "$", "this", "->", "eventManager", "=", "$", "eventManager", ";", "$", "this", "->", "eventManager", "->", "addIdentifiers", "(", "[", "'EntityService'", ",", "'PolderKnowledge\\EntityService\\Service\\EntityService'", ",", "$", "this", "->", "getEntityServiceName", "(", ")", ",", "trim", "(", "$", "this", "->", "getEntityServiceName", "(", ")", ",", "'\\\\'", ")", ",", "]", ")", ";", "$", "this", "->", "attach", "(", "$", "this", "->", "eventManager", ")", ";", "}" ]
Set the EventManager used by this service instance to handle its events. It will take care of disabling the old EventManager and will subscribe the internal listeners to the new EventManager @param EventManagerInterface $eventManager
[ "Set", "the", "EventManager", "used", "by", "this", "service", "instance", "to", "handle", "its", "events", ".", "It", "will", "take", "care", "of", "disabling", "the", "old", "EventManager", "and", "will", "subscribe", "the", "internal", "listeners", "to", "the", "new", "EventManager" ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L120-L139
8,656
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.delete
public function delete($entity) { if (!$this->isRepositoryDeletable()) { throw $this->createNotDeletableException(); } return $this->trigger(__FUNCTION__, [ 'entity' => $entity, ]); }
php
public function delete($entity) { if (!$this->isRepositoryDeletable()) { throw $this->createNotDeletableException(); } return $this->trigger(__FUNCTION__, [ 'entity' => $entity, ]); }
[ "public", "function", "delete", "(", "$", "entity", ")", "{", "if", "(", "!", "$", "this", "->", "isRepositoryDeletable", "(", ")", ")", "{", "throw", "$", "this", "->", "createNotDeletableException", "(", ")", ";", "}", "return", "$", "this", "->", "trigger", "(", "__FUNCTION__", ",", "[", "'entity'", "=>", "$", "entity", ",", "]", ")", ";", "}" ]
Deletes the given object from the repository @param object $entity The entity to delete. @return mixed @throws \Zend\EventManager\Exception\InvalidArgumentException @throws \PolderKnowledge\EntityService\Exception\RuntimeException
[ "Deletes", "the", "given", "object", "from", "the", "repository" ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L240-L249
8,657
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.deleteBy
public function deleteBy($criteria) { if (!$this->isRepositoryDeletable()) { throw $this->createNotDeletableException(); } return $this->trigger(__FUNCTION__, [ 'criteria' => $criteria, ]); }
php
public function deleteBy($criteria) { if (!$this->isRepositoryDeletable()) { throw $this->createNotDeletableException(); } return $this->trigger(__FUNCTION__, [ 'criteria' => $criteria, ]); }
[ "public", "function", "deleteBy", "(", "$", "criteria", ")", "{", "if", "(", "!", "$", "this", "->", "isRepositoryDeletable", "(", ")", ")", "{", "throw", "$", "this", "->", "createNotDeletableException", "(", ")", ";", "}", "return", "$", "this", "->", "trigger", "(", "__FUNCTION__", ",", "[", "'criteria'", "=>", "$", "criteria", ",", "]", ")", ";", "}" ]
Deletes all objects matching the criteria from the repository @param array|Criteria $criteria The criteria values to match on. @return mixed @throws \Zend\EventManager\Exception\InvalidArgumentException @throws \PolderKnowledge\EntityService\Exception\RuntimeException
[ "Deletes", "all", "objects", "matching", "the", "criteria", "from", "the", "repository" ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L259-L268
8,658
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.countBy
public function countBy($criteria) { if (!$this->isRepositoryReadable()) { throw $this->createNotReadableException(); } return $this->trigger(__FUNCTION__, [ 'criteria' => $criteria, ]); }
php
public function countBy($criteria) { if (!$this->isRepositoryReadable()) { throw $this->createNotReadableException(); } return $this->trigger(__FUNCTION__, [ 'criteria' => $criteria, ]); }
[ "public", "function", "countBy", "(", "$", "criteria", ")", "{", "if", "(", "!", "$", "this", "->", "isRepositoryReadable", "(", ")", ")", "{", "throw", "$", "this", "->", "createNotReadableException", "(", ")", ";", "}", "return", "$", "this", "->", "trigger", "(", "__FUNCTION__", ",", "[", "'criteria'", "=>", "$", "criteria", ",", "]", ")", ";", "}" ]
Count the objects matching the criteria respecting the order, limit and offset. @param array|Criteria $criteria The criteria values to match on. @return int @throws \Zend\EventManager\Exception\InvalidArgumentException @throws \PolderKnowledge\EntityService\Exception\RuntimeException
[ "Count", "the", "objects", "matching", "the", "criteria", "respecting", "the", "order", "limit", "and", "offset", "." ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L278-L287
8,659
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.findBy
public function findBy($criteria) { if (!$this->isRepositoryReadable()) { throw $this->createNotReadableException(); } return $this->trigger(__FUNCTION__, [ 'criteria' => $criteria, ]); }
php
public function findBy($criteria) { if (!$this->isRepositoryReadable()) { throw $this->createNotReadableException(); } return $this->trigger(__FUNCTION__, [ 'criteria' => $criteria, ]); }
[ "public", "function", "findBy", "(", "$", "criteria", ")", "{", "if", "(", "!", "$", "this", "->", "isRepositoryReadable", "(", ")", ")", "{", "throw", "$", "this", "->", "createNotReadableException", "(", ")", ";", "}", "return", "$", "this", "->", "trigger", "(", "__FUNCTION__", ",", "[", "'criteria'", "=>", "$", "criteria", ",", "]", ")", ";", "}" ]
Find one or more objects in the repository matching the criteria respecting the order, limit and offset @param array|Criteria $criteria The array with criteria to search on. @return array @throws \Zend\EventManager\Exception\InvalidArgumentException @throws \PolderKnowledge\EntityService\Exception\RuntimeException
[ "Find", "one", "or", "more", "objects", "in", "the", "repository", "matching", "the", "criteria", "respecting", "the", "order", "limit", "and", "offset" ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L332-L341
8,660
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.findOneBy
public function findOneBy($criteria) { if (!$this->isRepositoryReadable()) { throw $this->createNotReadableException(); } return $this->trigger(__FUNCTION__, [ 'criteria' => $criteria, ]); }
php
public function findOneBy($criteria) { if (!$this->isRepositoryReadable()) { throw $this->createNotReadableException(); } return $this->trigger(__FUNCTION__, [ 'criteria' => $criteria, ]); }
[ "public", "function", "findOneBy", "(", "$", "criteria", ")", "{", "if", "(", "!", "$", "this", "->", "isRepositoryReadable", "(", ")", ")", "{", "throw", "$", "this", "->", "createNotReadableException", "(", ")", ";", "}", "return", "$", "this", "->", "trigger", "(", "__FUNCTION__", ",", "[", "'criteria'", "=>", "$", "criteria", ",", "]", ")", ";", "}" ]
Find one object in the repository matching the criteria @param array|Criteria $criteria The criteria values to match on. @return object|null @throws \Zend\EventManager\Exception\InvalidArgumentException @throws \PolderKnowledge\EntityService\Exception\RuntimeException
[ "Find", "one", "object", "in", "the", "repository", "matching", "the", "criteria" ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L351-L360
8,661
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.persist
public function persist($entity) { if (!$this->isRepositoryWritable()) { throw $this->createNotWritableException(); } return $this->trigger(__FUNCTION__, [ 'entity' => $entity, ]); }
php
public function persist($entity) { if (!$this->isRepositoryWritable()) { throw $this->createNotWritableException(); } return $this->trigger(__FUNCTION__, [ 'entity' => $entity, ]); }
[ "public", "function", "persist", "(", "$", "entity", ")", "{", "if", "(", "!", "$", "this", "->", "isRepositoryWritable", "(", ")", ")", "{", "throw", "$", "this", "->", "createNotWritableException", "(", ")", ";", "}", "return", "$", "this", "->", "trigger", "(", "__FUNCTION__", ",", "[", "'entity'", "=>", "$", "entity", ",", "]", ")", ";", "}" ]
Persist the given entity @param object $entity @return mixed @throws \Zend\EventManager\Exception\InvalidArgumentException @throws RuntimeException
[ "Persist", "the", "given", "entity" ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L370-L379
8,662
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.multiPersist
public function multiPersist($entities) { if (!$this->isRepositoryWritable()) { throw $this->createNotWritableException(); } return $this->trigger(__FUNCTION__, [ 'entities' => $entities, ]); }
php
public function multiPersist($entities) { if (!$this->isRepositoryWritable()) { throw $this->createNotWritableException(); } return $this->trigger(__FUNCTION__, [ 'entities' => $entities, ]); }
[ "public", "function", "multiPersist", "(", "$", "entities", ")", "{", "if", "(", "!", "$", "this", "->", "isRepositoryWritable", "(", ")", ")", "{", "throw", "$", "this", "->", "createNotWritableException", "(", ")", ";", "}", "return", "$", "this", "->", "trigger", "(", "__FUNCTION__", ",", "[", "'entities'", "=>", "$", "entities", ",", "]", ")", ";", "}" ]
Persist the given object and flushes it to the storage device. @param array|Collection|Traversable $entities The entities to persist. @return mixed @throws RuntimeException
[ "Persist", "the", "given", "object", "and", "flushes", "it", "to", "the", "storage", "device", "." ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L388-L397
8,663
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.trigger
protected function trigger($name, array $params) { $event = clone $this->getEvent(); $event->setName($name); $event->setParams($params); $responseCollection = $this->getEventManager()->triggerEvent($event); if ($responseCollection->stopped() && $event->isError()) { throw new RuntimeException($event->getError(), $event->getErrorNr()); } return $event->getResult(); }
php
protected function trigger($name, array $params) { $event = clone $this->getEvent(); $event->setName($name); $event->setParams($params); $responseCollection = $this->getEventManager()->triggerEvent($event); if ($responseCollection->stopped() && $event->isError()) { throw new RuntimeException($event->getError(), $event->getErrorNr()); } return $event->getResult(); }
[ "protected", "function", "trigger", "(", "$", "name", ",", "array", "$", "params", ")", "{", "$", "event", "=", "clone", "$", "this", "->", "getEvent", "(", ")", ";", "$", "event", "->", "setName", "(", "$", "name", ")", ";", "$", "event", "->", "setParams", "(", "$", "params", ")", ";", "$", "responseCollection", "=", "$", "this", "->", "getEventManager", "(", ")", "->", "triggerEvent", "(", "$", "event", ")", ";", "if", "(", "$", "responseCollection", "->", "stopped", "(", ")", "&&", "$", "event", "->", "isError", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "$", "event", "->", "getError", "(", ")", ",", "$", "event", "->", "getErrorNr", "(", ")", ")", ";", "}", "return", "$", "event", "->", "getResult", "(", ")", ";", "}" ]
will prepare the event object and trigger the event using the internal EventManager @param string $name @param array $params @return mixed @throws \Zend\EventManager\Exception\InvalidArgumentException @throws \PolderKnowledge\EntityService\Exception\RuntimeException
[ "will", "prepare", "the", "event", "object", "and", "trigger", "the", "event", "using", "the", "internal", "EventManager" ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L408-L421
8,664
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.commitTransaction
public function commitTransaction() { if ($this->isTransactionEnabled() === false) { throw new ServiceException(sprintf( 'The repository for %s doesn\'t support Transactions', $this->getEntityServiceName() )); } $this->getRepository()->commitTransaction(); }
php
public function commitTransaction() { if ($this->isTransactionEnabled() === false) { throw new ServiceException(sprintf( 'The repository for %s doesn\'t support Transactions', $this->getEntityServiceName() )); } $this->getRepository()->commitTransaction(); }
[ "public", "function", "commitTransaction", "(", ")", "{", "if", "(", "$", "this", "->", "isTransactionEnabled", "(", ")", "===", "false", ")", "{", "throw", "new", "ServiceException", "(", "sprintf", "(", "'The repository for %s doesn\\'t support Transactions'", ",", "$", "this", "->", "getEntityServiceName", "(", ")", ")", ")", ";", "}", "$", "this", "->", "getRepository", "(", ")", "->", "commitTransaction", "(", ")", ";", "}" ]
Commits a started transaction. @throws ServiceException
[ "Commits", "a", "started", "transaction", "." ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L445-L455
8,665
polderknowledge/entityservice
src/AbstractEntityService.php
AbstractEntityService.rollbackTransaction
public function rollbackTransaction() { if ($this->isTransactionEnabled() === false) { throw new ServiceException(sprintf( 'The repository for %s doesn\'t support Transactions', $this->getEntityServiceName() )); } $this->getRepository()->rollbackTransaction(); }
php
public function rollbackTransaction() { if ($this->isTransactionEnabled() === false) { throw new ServiceException(sprintf( 'The repository for %s doesn\'t support Transactions', $this->getEntityServiceName() )); } $this->getRepository()->rollbackTransaction(); }
[ "public", "function", "rollbackTransaction", "(", ")", "{", "if", "(", "$", "this", "->", "isTransactionEnabled", "(", ")", "===", "false", ")", "{", "throw", "new", "ServiceException", "(", "sprintf", "(", "'The repository for %s doesn\\'t support Transactions'", ",", "$", "this", "->", "getEntityServiceName", "(", ")", ")", ")", ";", "}", "$", "this", "->", "getRepository", "(", ")", "->", "rollbackTransaction", "(", ")", ";", "}" ]
Rolls back a started transaction. @throws ServiceException
[ "Rolls", "back", "a", "started", "transaction", "." ]
f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15
https://github.com/polderknowledge/entityservice/blob/f48994b4ea33b1d3b56a24d255cbfb99c1eaaf15/src/AbstractEntityService.php#L462-L472
8,666
vinala/kernel
src/MVC/View/Libs/Views.php
Views.call
public function call($name, $data = null, $nest = null) { //Merge data if (!is_null($data)) { $this->data = array_merge($this->data, $data); } if (!$this->exists($name, $nest)) { throw new ViewNotFoundException($name); } else { $data = $this->exists($name, $nest); $this->path = $data['path']; $this->engine = $data['engine']; $this->nest = $nest; } $nameSegments = dot($name); $this->name = $this->setName($nameSegments); return $this; }
php
public function call($name, $data = null, $nest = null) { //Merge data if (!is_null($data)) { $this->data = array_merge($this->data, $data); } if (!$this->exists($name, $nest)) { throw new ViewNotFoundException($name); } else { $data = $this->exists($name, $nest); $this->path = $data['path']; $this->engine = $data['engine']; $this->nest = $nest; } $nameSegments = dot($name); $this->name = $this->setName($nameSegments); return $this; }
[ "public", "function", "call", "(", "$", "name", ",", "$", "data", "=", "null", ",", "$", "nest", "=", "null", ")", "{", "//Merge data", "if", "(", "!", "is_null", "(", "$", "data", ")", ")", "{", "$", "this", "->", "data", "=", "array_merge", "(", "$", "this", "->", "data", ",", "$", "data", ")", ";", "}", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "name", ",", "$", "nest", ")", ")", "{", "throw", "new", "ViewNotFoundException", "(", "$", "name", ")", ";", "}", "else", "{", "$", "data", "=", "$", "this", "->", "exists", "(", "$", "name", ",", "$", "nest", ")", ";", "$", "this", "->", "path", "=", "$", "data", "[", "'path'", "]", ";", "$", "this", "->", "engine", "=", "$", "data", "[", "'engine'", "]", ";", "$", "this", "->", "nest", "=", "$", "nest", ";", "}", "$", "nameSegments", "=", "dot", "(", "$", "name", ")", ";", "$", "this", "->", "name", "=", "$", "this", "->", "setName", "(", "$", "nameSegments", ")", ";", "return", "$", "this", ";", "}" ]
Call a view. @param string $name @param array $data @return Vinala\Kernel\MVC\Views
[ "Call", "a", "view", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/View/Libs/Views.php#L74-L97
8,667
vinala/kernel
src/MVC/View/Libs/Views.php
Views.exists
public function exists($name, $nest = null) { $file = str_replace('.', '/', $name); $extensions = [ '.php', '.atom.php', '.atom', '.tpl.php', ]; if (!is_null($nest)) { $nest = $nest.'resources/views/'; } elseif (!is_null($this->nest)) { $nest = $this->nest; } else { $nest = root().'resources/views/'; } $i = 0; foreach ($extensions as $extension) { $path = $nest.$file.$extension; if (file_exists($path)) { if ($i == 0) { $view = ['path' => $path, 'engine' => 'none']; } elseif ($i == 1 || $i == 2) { $view = ['path' => $path, 'engine' => 'atomium']; } elseif ($i == 3) { $view = ['path' => $path, 'engine' => 'smarty']; } return $view; } $i++; } return false; }
php
public function exists($name, $nest = null) { $file = str_replace('.', '/', $name); $extensions = [ '.php', '.atom.php', '.atom', '.tpl.php', ]; if (!is_null($nest)) { $nest = $nest.'resources/views/'; } elseif (!is_null($this->nest)) { $nest = $this->nest; } else { $nest = root().'resources/views/'; } $i = 0; foreach ($extensions as $extension) { $path = $nest.$file.$extension; if (file_exists($path)) { if ($i == 0) { $view = ['path' => $path, 'engine' => 'none']; } elseif ($i == 1 || $i == 2) { $view = ['path' => $path, 'engine' => 'atomium']; } elseif ($i == 3) { $view = ['path' => $path, 'engine' => 'smarty']; } return $view; } $i++; } return false; }
[ "public", "function", "exists", "(", "$", "name", ",", "$", "nest", "=", "null", ")", "{", "$", "file", "=", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "name", ")", ";", "$", "extensions", "=", "[", "'.php'", ",", "'.atom.php'", ",", "'.atom'", ",", "'.tpl.php'", ",", "]", ";", "if", "(", "!", "is_null", "(", "$", "nest", ")", ")", "{", "$", "nest", "=", "$", "nest", ".", "'resources/views/'", ";", "}", "elseif", "(", "!", "is_null", "(", "$", "this", "->", "nest", ")", ")", "{", "$", "nest", "=", "$", "this", "->", "nest", ";", "}", "else", "{", "$", "nest", "=", "root", "(", ")", ".", "'resources/views/'", ";", "}", "$", "i", "=", "0", ";", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "$", "path", "=", "$", "nest", ".", "$", "file", ".", "$", "extension", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "$", "i", "==", "0", ")", "{", "$", "view", "=", "[", "'path'", "=>", "$", "path", ",", "'engine'", "=>", "'none'", "]", ";", "}", "elseif", "(", "$", "i", "==", "1", "||", "$", "i", "==", "2", ")", "{", "$", "view", "=", "[", "'path'", "=>", "$", "path", ",", "'engine'", "=>", "'atomium'", "]", ";", "}", "elseif", "(", "$", "i", "==", "3", ")", "{", "$", "view", "=", "[", "'path'", "=>", "$", "path", ",", "'engine'", "=>", "'smarty'", "]", ";", "}", "return", "$", "view", ";", "}", "$", "i", "++", ";", "}", "return", "false", ";", "}" ]
Check if view exists. @param string $name @return array|false
[ "Check", "if", "view", "exists", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/View/Libs/Views.php#L118-L157
8,668
vinala/kernel
src/MVC/View/Libs/Views.php
Views.with
public function with($data, $value = null) { if (is_string($data)) { $this->data = array_merge($this->data, [$data => $value]); } elseif (is_array($data)) { $this->data = array_merge($this->data, $data); } return $this; }
php
public function with($data, $value = null) { if (is_string($data)) { $this->data = array_merge($this->data, [$data => $value]); } elseif (is_array($data)) { $this->data = array_merge($this->data, $data); } return $this; }
[ "public", "function", "with", "(", "$", "data", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "data", ")", ")", "{", "$", "this", "->", "data", "=", "array_merge", "(", "$", "this", "->", "data", ",", "[", "$", "data", "=>", "$", "value", "]", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "this", "->", "data", "=", "array_merge", "(", "$", "this", "->", "data", ",", "$", "data", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add variables to the view. @param array|string $data @param string $value @return Vinala\Kernel\MVC\views
[ "Add", "variables", "to", "the", "view", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/View/Libs/Views.php#L167-L176
8,669
vinala/kernel
src/MVC/View/Libs/Views.php
Views.show
public function show(self $_vinala_view = null) { if (is_null($_vinala_view)) { $_vinala_view = $this; } if ($_vinala_view->engine == 'atomium') { self::atomium($_vinala_view->path, $_vinala_view->data, $_vinala_view->nest); } elseif ($_vinala_view->engine == 'smarty') { Template::show($_vinala_view->path, $_vinala_view->data); } else { if (!is_null($_vinala_view->data)) { foreach ($_vinala_view->data as $_vinala_view_keys => $_vinala_view_values) { $$_vinala_view_keys = $_vinala_view_values; } } include $_vinala_view->path; } }
php
public function show(self $_vinala_view = null) { if (is_null($_vinala_view)) { $_vinala_view = $this; } if ($_vinala_view->engine == 'atomium') { self::atomium($_vinala_view->path, $_vinala_view->data, $_vinala_view->nest); } elseif ($_vinala_view->engine == 'smarty') { Template::show($_vinala_view->path, $_vinala_view->data); } else { if (!is_null($_vinala_view->data)) { foreach ($_vinala_view->data as $_vinala_view_keys => $_vinala_view_values) { $$_vinala_view_keys = $_vinala_view_values; } } include $_vinala_view->path; } }
[ "public", "function", "show", "(", "self", "$", "_vinala_view", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "_vinala_view", ")", ")", "{", "$", "_vinala_view", "=", "$", "this", ";", "}", "if", "(", "$", "_vinala_view", "->", "engine", "==", "'atomium'", ")", "{", "self", "::", "atomium", "(", "$", "_vinala_view", "->", "path", ",", "$", "_vinala_view", "->", "data", ",", "$", "_vinala_view", "->", "nest", ")", ";", "}", "elseif", "(", "$", "_vinala_view", "->", "engine", "==", "'smarty'", ")", "{", "Template", "::", "show", "(", "$", "_vinala_view", "->", "path", ",", "$", "_vinala_view", "->", "data", ")", ";", "}", "else", "{", "if", "(", "!", "is_null", "(", "$", "_vinala_view", "->", "data", ")", ")", "{", "foreach", "(", "$", "_vinala_view", "->", "data", "as", "$", "_vinala_view_keys", "=>", "$", "_vinala_view_values", ")", "{", "$", "$", "_vinala_view_keys", "=", "$", "_vinala_view_values", ";", "}", "}", "include", "$", "_vinala_view", "->", "path", ";", "}", "}" ]
Show the view. @return bool
[ "Show", "the", "view", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/View/Libs/Views.php#L183-L202
8,670
vinala/kernel
src/MVC/View/Libs/Views.php
Views.atomium
protected function atomium($file, $data, $nest = null) { $atomium = new Atomium($nest); return $atomium->show($file, $data); }
php
protected function atomium($file, $data, $nest = null) { $atomium = new Atomium($nest); return $atomium->show($file, $data); }
[ "protected", "function", "atomium", "(", "$", "file", ",", "$", "data", ",", "$", "nest", "=", "null", ")", "{", "$", "atomium", "=", "new", "Atomium", "(", "$", "nest", ")", ";", "return", "$", "atomium", "->", "show", "(", "$", "file", ",", "$", "data", ")", ";", "}" ]
Show atomium view. @param string $file @param array $data @return string
[ "Show", "atomium", "view", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/View/Libs/Views.php#L212-L217
8,671
marando/phpSOFA
src/Marando/IAU/iauTf2a.php
iauTf2a.Tf2a
public static function Tf2a($s, $ihour, $imin, $sec, &$rad) { /* Compute the interval. */ $rad = ( $s == '-' ? -1.0 : 1.0 ) * ( 60.0 * ( 60.0 * ( (double)abs($ihour) ) + ( (double)abs($imin) ) ) + abs($sec) ) * DS2R; /* Validate arguments and return status. */ if ($ihour < 0 || $ihour > 23) return 1; if ($imin < 0 || $imin > 59) return 2; if ($sec < 0.0 || $sec >= 60.0) return 3; return 0; }
php
public static function Tf2a($s, $ihour, $imin, $sec, &$rad) { /* Compute the interval. */ $rad = ( $s == '-' ? -1.0 : 1.0 ) * ( 60.0 * ( 60.0 * ( (double)abs($ihour) ) + ( (double)abs($imin) ) ) + abs($sec) ) * DS2R; /* Validate arguments and return status. */ if ($ihour < 0 || $ihour > 23) return 1; if ($imin < 0 || $imin > 59) return 2; if ($sec < 0.0 || $sec >= 60.0) return 3; return 0; }
[ "public", "static", "function", "Tf2a", "(", "$", "s", ",", "$", "ihour", ",", "$", "imin", ",", "$", "sec", ",", "&", "$", "rad", ")", "{", "/* Compute the interval. */", "$", "rad", "=", "(", "$", "s", "==", "'-'", "?", "-", "1.0", ":", "1.0", ")", "*", "(", "60.0", "*", "(", "60.0", "*", "(", "(", "double", ")", "abs", "(", "$", "ihour", ")", ")", "+", "(", "(", "double", ")", "abs", "(", "$", "imin", ")", ")", ")", "+", "abs", "(", "$", "sec", ")", ")", "*", "DS2R", ";", "/* Validate arguments and return status. */", "if", "(", "$", "ihour", "<", "0", "||", "$", "ihour", ">", "23", ")", "return", "1", ";", "if", "(", "$", "imin", "<", "0", "||", "$", "imin", ">", "59", ")", "return", "2", ";", "if", "(", "$", "sec", "<", "0.0", "||", "$", "sec", ">=", "60.0", ")", "return", "3", ";", "return", "0", ";", "}" ]
- - - - - - - - i a u T f 2 a - - - - - - - - Convert hours, minutes, seconds to radians. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: s char sign: '-' = negative, otherwise positive ihour int hours imin int minutes sec double seconds Returned: rad double angle in radians Returned (function value): int status: 0 = OK 1 = ihour outside range 0-23 2 = imin outside range 0-59 3 = sec outside range 0-59.999... Notes: 1) The result is computed even if any of the range checks fail. 2) Negative ihour, imin and/or sec produce a warning status, but the absolute value is used in the conversion. 3) If there are multiple errors, the status value reflects only the first, the smallest taking precedence. This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "T", "f", "2", "a", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauTf2a.php#L50-L65
8,672
prototypemvc/prototypemvc
Core/LazyLoad.php
LazyLoad.on
public static function on() { foreach(self::$classes as $k => $class) { if (!class_exists($class)) { if(class_exists('Prototypemvc\Core\\' . $class)) { class_alias('Prototypemvc\Core\\' . $class, $class); } else if(class_exists('Prototypemvc\Helpers\\' . $class)) { class_alias('Prototypemvc\Helpers\\' . $class, $class); } } } }
php
public static function on() { foreach(self::$classes as $k => $class) { if (!class_exists($class)) { if(class_exists('Prototypemvc\Core\\' . $class)) { class_alias('Prototypemvc\Core\\' . $class, $class); } else if(class_exists('Prototypemvc\Helpers\\' . $class)) { class_alias('Prototypemvc\Helpers\\' . $class, $class); } } } }
[ "public", "static", "function", "on", "(", ")", "{", "foreach", "(", "self", "::", "$", "classes", "as", "$", "k", "=>", "$", "class", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "if", "(", "class_exists", "(", "'Prototypemvc\\Core\\\\'", ".", "$", "class", ")", ")", "{", "class_alias", "(", "'Prototypemvc\\Core\\\\'", ".", "$", "class", ",", "$", "class", ")", ";", "}", "else", "if", "(", "class_exists", "(", "'Prototypemvc\\Helpers\\\\'", ".", "$", "class", ")", ")", "{", "class_alias", "(", "'Prototypemvc\\Helpers\\\\'", ".", "$", "class", ",", "$", "class", ")", ";", "}", "}", "}", "}" ]
Bypass namespaces. WARNING! Not recommended for use in a production environment because of poor performance. But fine in development for rapid prototyping. @example instead of Prototypemvc\Core\Text::methodX simply use Text::methodX
[ "Bypass", "namespaces", ".", "WARNING!", "Not", "recommended", "for", "use", "in", "a", "production", "environment", "because", "of", "poor", "performance", ".", "But", "fine", "in", "development", "for", "rapid", "prototyping", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/LazyLoad.php#L37-L48
8,673
uthando-cms/uthando-common
src/UthandoCommon/Stdlib/StringUtils.php
StringUtils.endsWith
public static function endsWith($string, $look) { return strrpos($string, $look) === strlen($string) - strlen($look); }
php
public static function endsWith($string, $look) { return strrpos($string, $look) === strlen($string) - strlen($look); }
[ "public", "static", "function", "endsWith", "(", "$", "string", ",", "$", "look", ")", "{", "return", "strrpos", "(", "$", "string", ",", "$", "look", ")", "===", "strlen", "(", "$", "string", ")", "-", "strlen", "(", "$", "look", ")", ";", "}" ]
Check to see if string starts with a string @param string $string @param string $look @return bool
[ "Check", "to", "see", "if", "string", "starts", "with", "a", "string" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Stdlib/StringUtils.php#L28-L31
8,674
johanderuijter/mailer
src/PartResolverRegistry.php
PartResolverRegistry.addResolver
public function addResolver(EmailPartResolver $resolver, $part): self { $this->resolvers[$part] = $resolver; return $this; }
php
public function addResolver(EmailPartResolver $resolver, $part): self { $this->resolvers[$part] = $resolver; return $this; }
[ "public", "function", "addResolver", "(", "EmailPartResolver", "$", "resolver", ",", "$", "part", ")", ":", "self", "{", "$", "this", "->", "resolvers", "[", "$", "part", "]", "=", "$", "resolver", ";", "return", "$", "this", ";", "}" ]
Add Resolver. @param EmailPartResolver $resolver @param string $part @return self
[ "Add", "Resolver", "." ]
5a0cbb7f8be91bb1fc7a4816964dddaff10ac25c
https://github.com/johanderuijter/mailer/blob/5a0cbb7f8be91bb1fc7a4816964dddaff10ac25c/src/PartResolverRegistry.php#L24-L29
8,675
johanderuijter/mailer
src/PartResolverRegistry.php
PartResolverRegistry.getResolverForPart
public function getResolverForPart(EmailPart $part): EmailPartResolver { $identifier = get_class($part); if (!array_key_exists($identifier, $this->resolvers)) { throw new InvalidArgumentException(sprintf( 'Resolver for the part "%s" does not exists. Please choose one of the following: %s', $identifier, implode(', ', array_keys($this->resolvers)) )); } return $this->resolvers[$identifier]; }
php
public function getResolverForPart(EmailPart $part): EmailPartResolver { $identifier = get_class($part); if (!array_key_exists($identifier, $this->resolvers)) { throw new InvalidArgumentException(sprintf( 'Resolver for the part "%s" does not exists. Please choose one of the following: %s', $identifier, implode(', ', array_keys($this->resolvers)) )); } return $this->resolvers[$identifier]; }
[ "public", "function", "getResolverForPart", "(", "EmailPart", "$", "part", ")", ":", "EmailPartResolver", "{", "$", "identifier", "=", "get_class", "(", "$", "part", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "identifier", ",", "$", "this", "->", "resolvers", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Resolver for the part \"%s\" does not exists. Please choose one of the following: %s'", ",", "$", "identifier", ",", "implode", "(", "', '", ",", "array_keys", "(", "$", "this", "->", "resolvers", ")", ")", ")", ")", ";", "}", "return", "$", "this", "->", "resolvers", "[", "$", "identifier", "]", ";", "}" ]
Get resolver for given email part. @param EmailPart $part @return EmailPartResolver
[ "Get", "resolver", "for", "given", "email", "part", "." ]
5a0cbb7f8be91bb1fc7a4816964dddaff10ac25c
https://github.com/johanderuijter/mailer/blob/5a0cbb7f8be91bb1fc7a4816964dddaff10ac25c/src/PartResolverRegistry.php#L38-L51
8,676
crisu83/yii-caviar
src/generators/Generator.php
Generator.renderHelp
public function renderHelp() { $this->renderHeader(); echo Line::begin('Usage:', Line::YELLOW)->nl(); echo Line::begin() ->indent(2) ->text($this->getUsage()) ->nl(2); // Options echo Line::begin('Options:', Line::YELLOW)->nl(); echo Line::begin() ->indent(2) ->text('--help', Line::MAGENTA) ->to(21) ->text('-h', Line::MAGENTA) ->text('Display this help message.') ->nl(1); $attributes = $this->attributeNames(); $help = $this->attributeHelp(); sort($attributes); foreach ($attributes as $name) { echo Line::begin() ->indent(2) ->text("--$name", Line::MAGENTA) ->to(24) ->text(isset($help[$name]) ? $help[$name] : '') ->nl(); } exit(0); }
php
public function renderHelp() { $this->renderHeader(); echo Line::begin('Usage:', Line::YELLOW)->nl(); echo Line::begin() ->indent(2) ->text($this->getUsage()) ->nl(2); // Options echo Line::begin('Options:', Line::YELLOW)->nl(); echo Line::begin() ->indent(2) ->text('--help', Line::MAGENTA) ->to(21) ->text('-h', Line::MAGENTA) ->text('Display this help message.') ->nl(1); $attributes = $this->attributeNames(); $help = $this->attributeHelp(); sort($attributes); foreach ($attributes as $name) { echo Line::begin() ->indent(2) ->text("--$name", Line::MAGENTA) ->to(24) ->text(isset($help[$name]) ? $help[$name] : '') ->nl(); } exit(0); }
[ "public", "function", "renderHelp", "(", ")", "{", "$", "this", "->", "renderHeader", "(", ")", ";", "echo", "Line", "::", "begin", "(", "'Usage:'", ",", "Line", "::", "YELLOW", ")", "->", "nl", "(", ")", ";", "echo", "Line", "::", "begin", "(", ")", "->", "indent", "(", "2", ")", "->", "text", "(", "$", "this", "->", "getUsage", "(", ")", ")", "->", "nl", "(", "2", ")", ";", "// Options", "echo", "Line", "::", "begin", "(", "'Options:'", ",", "Line", "::", "YELLOW", ")", "->", "nl", "(", ")", ";", "echo", "Line", "::", "begin", "(", ")", "->", "indent", "(", "2", ")", "->", "text", "(", "'--help'", ",", "Line", "::", "MAGENTA", ")", "->", "to", "(", "21", ")", "->", "text", "(", "'-h'", ",", "Line", "::", "MAGENTA", ")", "->", "text", "(", "'Display this help message.'", ")", "->", "nl", "(", "1", ")", ";", "$", "attributes", "=", "$", "this", "->", "attributeNames", "(", ")", ";", "$", "help", "=", "$", "this", "->", "attributeHelp", "(", ")", ";", "sort", "(", "$", "attributes", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "name", ")", "{", "echo", "Line", "::", "begin", "(", ")", "->", "indent", "(", "2", ")", "->", "text", "(", "\"--$name\"", ",", "Line", "::", "MAGENTA", ")", "->", "to", "(", "24", ")", "->", "text", "(", "isset", "(", "$", "help", "[", "$", "name", "]", ")", "?", "$", "help", "[", "$", "name", "]", ":", "''", ")", "->", "nl", "(", ")", ";", "}", "exit", "(", "0", ")", ";", "}" ]
Displays the help for this generator.
[ "Displays", "the", "help", "for", "this", "generator", "." ]
c85286b88e68558224e7f2ea7fff8f6975e46283
https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/Generator.php#L115-L150
8,677
crisu83/yii-caviar
src/generators/Generator.php
Generator.create
public static function create($name, array $config = array()) { if (!isset(self::$config->generators[$name])) { throw new Exception("Unknown generator '$name'."); } $generator = \Yii::createComponent(\CMap::mergeArray(self::$config->generators[$name], $config)); $generator->init(); foreach (self::$config->attributes as $attribute => $value) { if (property_exists($generator, $attribute)) { $generator->$attribute = $value; } } return $generator; }
php
public static function create($name, array $config = array()) { if (!isset(self::$config->generators[$name])) { throw new Exception("Unknown generator '$name'."); } $generator = \Yii::createComponent(\CMap::mergeArray(self::$config->generators[$name], $config)); $generator->init(); foreach (self::$config->attributes as $attribute => $value) { if (property_exists($generator, $attribute)) { $generator->$attribute = $value; } } return $generator; }
[ "public", "static", "function", "create", "(", "$", "name", ",", "array", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "config", "->", "generators", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "Exception", "(", "\"Unknown generator '$name'.\"", ")", ";", "}", "$", "generator", "=", "\\", "Yii", "::", "createComponent", "(", "\\", "CMap", "::", "mergeArray", "(", "self", "::", "$", "config", "->", "generators", "[", "$", "name", "]", ",", "$", "config", ")", ")", ";", "$", "generator", "->", "init", "(", ")", ";", "foreach", "(", "self", "::", "$", "config", "->", "attributes", "as", "$", "attribute", "=>", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "generator", ",", "$", "attribute", ")", ")", "{", "$", "generator", "->", "$", "attribute", "=", "$", "value", ";", "}", "}", "return", "$", "generator", ";", "}" ]
Creates a new generator. @param string $name name of the generator. @param array $config generator configuration. @return Generator the created generator. @throws Exception if the generator is not found.
[ "Creates", "a", "new", "generator", "." ]
c85286b88e68558224e7f2ea7fff8f6975e46283
https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/Generator.php#L213-L229
8,678
crisu83/yii-caviar
src/generators/Generator.php
Generator.run
public static function run($name, array $config = array()) { $generator = self::create($name, $config); if (!$generator->validate()) { $generator->renderErrors(); } return $generator->generate(); }
php
public static function run($name, array $config = array()) { $generator = self::create($name, $config); if (!$generator->validate()) { $generator->renderErrors(); } return $generator->generate(); }
[ "public", "static", "function", "run", "(", "$", "name", ",", "array", "$", "config", "=", "array", "(", ")", ")", "{", "$", "generator", "=", "self", "::", "create", "(", "$", "name", ",", "$", "config", ")", ";", "if", "(", "!", "$", "generator", "->", "validate", "(", ")", ")", "{", "$", "generator", "->", "renderErrors", "(", ")", ";", "}", "return", "$", "generator", "->", "generate", "(", ")", ";", "}" ]
Creates and runs a specific generator. @param string $name name of the generator. @param array $config generator configuration. @return File[] list of files to generate.
[ "Creates", "and", "runs", "a", "specific", "generator", "." ]
c85286b88e68558224e7f2ea7fff8f6975e46283
https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/generators/Generator.php#L248-L257
8,679
pletfix/core
src/Services/Router.php
Router.getPluginController
private function getPluginController($class) { if ($this->pluginControllers === null) { /** @noinspection PhpIncludeInspection */ $this->pluginControllers = file_exists($this->pluginManifestOfControllers) ? include $this->pluginManifestOfControllers : []; } return isset($this->pluginControllers[$class]) && count($this->pluginControllers[$class]) == 1 ? $this->pluginControllers[$class][0] : null; }
php
private function getPluginController($class) { if ($this->pluginControllers === null) { /** @noinspection PhpIncludeInspection */ $this->pluginControllers = file_exists($this->pluginManifestOfControllers) ? include $this->pluginManifestOfControllers : []; } return isset($this->pluginControllers[$class]) && count($this->pluginControllers[$class]) == 1 ? $this->pluginControllers[$class][0] : null; }
[ "private", "function", "getPluginController", "(", "$", "class", ")", "{", "if", "(", "$", "this", "->", "pluginControllers", "===", "null", ")", "{", "/** @noinspection PhpIncludeInspection */", "$", "this", "->", "pluginControllers", "=", "file_exists", "(", "$", "this", "->", "pluginManifestOfControllers", ")", "?", "include", "$", "this", "->", "pluginManifestOfControllers", ":", "[", "]", ";", "}", "return", "isset", "(", "$", "this", "->", "pluginControllers", "[", "$", "class", "]", ")", "&&", "count", "(", "$", "this", "->", "pluginControllers", "[", "$", "class", "]", ")", "==", "1", "?", "$", "this", "->", "pluginControllers", "[", "$", "class", "]", "[", "0", "]", ":", "null", ";", "}" ]
Get the full qualified class name of the plugin's controller. @param string $class @return null|string
[ "Get", "the", "full", "qualified", "class", "name", "of", "the", "plugin", "s", "controller", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Router.php#L114-L122
8,680
pletfix/core
src/Services/Router.php
Router.find
private function find(Contracts\Request $request) { $method = $request->method(); $path = $request->path(); foreach ($this->routes as $route) { if ($route->method == $method) { $pattern = $this->pattern($route); if (preg_match($pattern, $path)) { return $route; } } } return null; }
php
private function find(Contracts\Request $request) { $method = $request->method(); $path = $request->path(); foreach ($this->routes as $route) { if ($route->method == $method) { $pattern = $this->pattern($route); if (preg_match($pattern, $path)) { return $route; } } } return null; }
[ "private", "function", "find", "(", "Contracts", "\\", "Request", "$", "request", ")", "{", "$", "method", "=", "$", "request", "->", "method", "(", ")", ";", "$", "path", "=", "$", "request", "->", "path", "(", ")", ";", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "if", "(", "$", "route", "->", "method", "==", "$", "method", ")", "{", "$", "pattern", "=", "$", "this", "->", "pattern", "(", "$", "route", ")", ";", "if", "(", "preg_match", "(", "$", "pattern", ",", "$", "path", ")", ")", "{", "return", "$", "route", ";", "}", "}", "}", "return", "null", ";", "}" ]
Find the route matching the given request. @param Contracts\Request $request @return object|null
[ "Find", "the", "route", "matching", "the", "given", "request", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Router.php#L130-L144
8,681
pletfix/core
src/Services/Router.php
Router.getParameters
private function getParameters(Contracts\Request $request, $route) { $path = $request->path(); $pattern = $this->pattern($route); if (preg_match_all($pattern, $path, $matches, PREG_SET_ORDER) === false) { return []; // @codeCoverageIgnore } unset($matches[0][0]); $matches = array_values($matches[0]); return $matches; }
php
private function getParameters(Contracts\Request $request, $route) { $path = $request->path(); $pattern = $this->pattern($route); if (preg_match_all($pattern, $path, $matches, PREG_SET_ORDER) === false) { return []; // @codeCoverageIgnore } unset($matches[0][0]); $matches = array_values($matches[0]); return $matches; }
[ "private", "function", "getParameters", "(", "Contracts", "\\", "Request", "$", "request", ",", "$", "route", ")", "{", "$", "path", "=", "$", "request", "->", "path", "(", ")", ";", "$", "pattern", "=", "$", "this", "->", "pattern", "(", "$", "route", ")", ";", "if", "(", "preg_match_all", "(", "$", "pattern", ",", "$", "path", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", "===", "false", ")", "{", "return", "[", "]", ";", "// @codeCoverageIgnore", "}", "unset", "(", "$", "matches", "[", "0", "]", "[", "0", "]", ")", ";", "$", "matches", "=", "array_values", "(", "$", "matches", "[", "0", "]", ")", ";", "return", "$", "matches", ";", "}" ]
Get parameters of the request. @param Contracts\Request $request @param object $route @return array
[ "Get", "parameters", "of", "the", "request", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Router.php#L153-L165
8,682
dave-redfern/somnambulist-collection
src/Traits/Exportable.php
Exportable.toQueryString
public function toQueryString($separator = '&', $encoding = PHP_QUERY_RFC3986) { return http_build_query($this->toArray(), null, $separator, $encoding); }
php
public function toQueryString($separator = '&', $encoding = PHP_QUERY_RFC3986) { return http_build_query($this->toArray(), null, $separator, $encoding); }
[ "public", "function", "toQueryString", "(", "$", "separator", "=", "'&'", ",", "$", "encoding", "=", "PHP_QUERY_RFC3986", ")", "{", "return", "http_build_query", "(", "$", "this", "->", "toArray", "(", ")", ",", "null", ",", "$", "separator", ",", "$", "encoding", ")", ";", "}" ]
Returns a HTTP query string of the values Note: should only be used with elements that can be cast to scalars. @param string $separator @param int $encoding @return string
[ "Returns", "a", "HTTP", "query", "string", "of", "the", "values" ]
82cf33c333b00ff375c403fbc7f32e4b476ee0b1
https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Traits/Exportable.php#L64-L67
8,683
atorscho/menus
src/Item.php
Item.isActive
public function isActive(): bool { if ($this->isNested()) { return str_contains(url()->current(), $this->url); } return url($this->url) == url()->current(); }
php
public function isActive(): bool { if ($this->isNested()) { return str_contains(url()->current(), $this->url); } return url($this->url) == url()->current(); }
[ "public", "function", "isActive", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "isNested", "(", ")", ")", "{", "return", "str_contains", "(", "url", "(", ")", "->", "current", "(", ")", ",", "$", "this", "->", "url", ")", ";", "}", "return", "url", "(", "$", "this", "->", "url", ")", "==", "url", "(", ")", "->", "current", "(", ")", ";", "}" ]
Check if the current item is active.
[ "Check", "if", "the", "current", "item", "is", "active", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/Item.php#L91-L98
8,684
atorscho/menus
src/Item.php
Item.activeAttr
public function activeAttr(string $className = ''): string { if (! $className) { $className = config('menus.active_class_name'); } return $this->isActive() ? 'class="' . $className . '"' : ''; }
php
public function activeAttr(string $className = ''): string { if (! $className) { $className = config('menus.active_class_name'); } return $this->isActive() ? 'class="' . $className . '"' : ''; }
[ "public", "function", "activeAttr", "(", "string", "$", "className", "=", "''", ")", ":", "string", "{", "if", "(", "!", "$", "className", ")", "{", "$", "className", "=", "config", "(", "'menus.active_class_name'", ")", ";", "}", "return", "$", "this", "->", "isActive", "(", ")", "?", "'class=\"'", ".", "$", "className", ".", "'\"'", ":", "''", ";", "}" ]
Output active class attribute. e.g.: <li class="active">...</li>
[ "Output", "active", "class", "attribute", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/Item.php#L105-L112
8,685
atorscho/menus
src/Item.php
Item.activeClass
public function activeClass(string $className = ''): string { if (! $className) { $className = config('menus.active_class_name'); } return $this->isActive() ? $className : ''; }
php
public function activeClass(string $className = ''): string { if (! $className) { $className = config('menus.active_class_name'); } return $this->isActive() ? $className : ''; }
[ "public", "function", "activeClass", "(", "string", "$", "className", "=", "''", ")", ":", "string", "{", "if", "(", "!", "$", "className", ")", "{", "$", "className", "=", "config", "(", "'menus.active_class_name'", ")", ";", "}", "return", "$", "this", "->", "isActive", "(", ")", "?", "$", "className", ":", "''", ";", "}" ]
Return active class name.
[ "Return", "active", "class", "name", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/Item.php#L117-L124
8,686
nbostech/wavelabs-php-client-api
src/NBOS/http/Curl.php
Curl.execute
public function execute() { // Set two default options, and merge any extra ones in if ( ! isset($this->options[CURLOPT_TIMEOUT])) { $this->options[CURLOPT_TIMEOUT] = 30; } if ( ! isset($this->options[CURLOPT_RETURNTRANSFER])) { $this->options[CURLOPT_RETURNTRANSFER] = TRUE; } if ( ! isset($this->options[CURLOPT_FAILONERROR])) { $this->options[CURLOPT_FAILONERROR] = TRUE; } // Only set follow location if not running securely if ( ! ini_get('safe_mode') && ! ini_get('open_basedir')) { // Ok, follow location is not set already so lets set it to true if ( ! isset($this->options[CURLOPT_FOLLOWLOCATION])) { $this->options[CURLOPT_FOLLOWLOCATION] = TRUE; } } if ( ! empty($this->headers)) { $this->option(CURLOPT_HTTPHEADER, $this->headers); } $this->options(); curl_setopt($this->session, CURLINFO_HEADER_OUT, true); curl_setopt($this->session, CURLOPT_HEADER, 1); // Execute the request & and hide all output $this->response = curl_exec($this->session); if($this->response !== false){ $this->info = curl_getinfo($this->session); // Split header and body response //$header_size = curl_getinfo($this->session, CURLINFO_HEADER_SIZE); //$this->response_header = substr($this->response, 0, $header_size); //$this->response = substr($this->response, $header_size); list($this->response_header, $this->response) = explode("\r\n\r\n", $this->response); if(defined('CURL_DEBUG') && $this->log !== null){ $this->log->addInfo($this->url, [ "Request" => $this->info, "Response" => $this->response ]); } }else{ if(defined('CURL_DEBUG') && $this->log !== null){ $this->log->addError("Server not responding!", ["URL" => $this->url], ["message" => "test"]); } } // Request failed if ($this->response === FALSE) { $errno = curl_errno($this->session); $error = curl_error($this->session); curl_close($this->session); $this->set_defaults(); $this->error_code = $errno; $this->error_string = $error; return FALSE; } // Request successful else { curl_close($this->session); $this->last_response = $this->response; $this->last_response_header = $this->response_header; $this->last_info = $this->info; $this->set_defaults(); return $this->last_response; } }
php
public function execute() { // Set two default options, and merge any extra ones in if ( ! isset($this->options[CURLOPT_TIMEOUT])) { $this->options[CURLOPT_TIMEOUT] = 30; } if ( ! isset($this->options[CURLOPT_RETURNTRANSFER])) { $this->options[CURLOPT_RETURNTRANSFER] = TRUE; } if ( ! isset($this->options[CURLOPT_FAILONERROR])) { $this->options[CURLOPT_FAILONERROR] = TRUE; } // Only set follow location if not running securely if ( ! ini_get('safe_mode') && ! ini_get('open_basedir')) { // Ok, follow location is not set already so lets set it to true if ( ! isset($this->options[CURLOPT_FOLLOWLOCATION])) { $this->options[CURLOPT_FOLLOWLOCATION] = TRUE; } } if ( ! empty($this->headers)) { $this->option(CURLOPT_HTTPHEADER, $this->headers); } $this->options(); curl_setopt($this->session, CURLINFO_HEADER_OUT, true); curl_setopt($this->session, CURLOPT_HEADER, 1); // Execute the request & and hide all output $this->response = curl_exec($this->session); if($this->response !== false){ $this->info = curl_getinfo($this->session); // Split header and body response //$header_size = curl_getinfo($this->session, CURLINFO_HEADER_SIZE); //$this->response_header = substr($this->response, 0, $header_size); //$this->response = substr($this->response, $header_size); list($this->response_header, $this->response) = explode("\r\n\r\n", $this->response); if(defined('CURL_DEBUG') && $this->log !== null){ $this->log->addInfo($this->url, [ "Request" => $this->info, "Response" => $this->response ]); } }else{ if(defined('CURL_DEBUG') && $this->log !== null){ $this->log->addError("Server not responding!", ["URL" => $this->url], ["message" => "test"]); } } // Request failed if ($this->response === FALSE) { $errno = curl_errno($this->session); $error = curl_error($this->session); curl_close($this->session); $this->set_defaults(); $this->error_code = $errno; $this->error_string = $error; return FALSE; } // Request successful else { curl_close($this->session); $this->last_response = $this->response; $this->last_response_header = $this->response_header; $this->last_info = $this->info; $this->set_defaults(); return $this->last_response; } }
[ "public", "function", "execute", "(", ")", "{", "// Set two default options, and merge any extra ones in", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "CURLOPT_TIMEOUT", "]", ")", ")", "{", "$", "this", "->", "options", "[", "CURLOPT_TIMEOUT", "]", "=", "30", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "CURLOPT_RETURNTRANSFER", "]", ")", ")", "{", "$", "this", "->", "options", "[", "CURLOPT_RETURNTRANSFER", "]", "=", "TRUE", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "CURLOPT_FAILONERROR", "]", ")", ")", "{", "$", "this", "->", "options", "[", "CURLOPT_FAILONERROR", "]", "=", "TRUE", ";", "}", "// Only set follow location if not running securely", "if", "(", "!", "ini_get", "(", "'safe_mode'", ")", "&&", "!", "ini_get", "(", "'open_basedir'", ")", ")", "{", "// Ok, follow location is not set already so lets set it to true", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "CURLOPT_FOLLOWLOCATION", "]", ")", ")", "{", "$", "this", "->", "options", "[", "CURLOPT_FOLLOWLOCATION", "]", "=", "TRUE", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "headers", ")", ")", "{", "$", "this", "->", "option", "(", "CURLOPT_HTTPHEADER", ",", "$", "this", "->", "headers", ")", ";", "}", "$", "this", "->", "options", "(", ")", ";", "curl_setopt", "(", "$", "this", "->", "session", ",", "CURLINFO_HEADER_OUT", ",", "true", ")", ";", "curl_setopt", "(", "$", "this", "->", "session", ",", "CURLOPT_HEADER", ",", "1", ")", ";", "// Execute the request & and hide all output", "$", "this", "->", "response", "=", "curl_exec", "(", "$", "this", "->", "session", ")", ";", "if", "(", "$", "this", "->", "response", "!==", "false", ")", "{", "$", "this", "->", "info", "=", "curl_getinfo", "(", "$", "this", "->", "session", ")", ";", "// Split header and body response", "//$header_size = curl_getinfo($this->session, CURLINFO_HEADER_SIZE);", "//$this->response_header = substr($this->response, 0, $header_size);", "//$this->response = substr($this->response, $header_size);", "list", "(", "$", "this", "->", "response_header", ",", "$", "this", "->", "response", ")", "=", "explode", "(", "\"\\r\\n\\r\\n\"", ",", "$", "this", "->", "response", ")", ";", "if", "(", "defined", "(", "'CURL_DEBUG'", ")", "&&", "$", "this", "->", "log", "!==", "null", ")", "{", "$", "this", "->", "log", "->", "addInfo", "(", "$", "this", "->", "url", ",", "[", "\"Request\"", "=>", "$", "this", "->", "info", ",", "\"Response\"", "=>", "$", "this", "->", "response", "]", ")", ";", "}", "}", "else", "{", "if", "(", "defined", "(", "'CURL_DEBUG'", ")", "&&", "$", "this", "->", "log", "!==", "null", ")", "{", "$", "this", "->", "log", "->", "addError", "(", "\"Server not responding!\"", ",", "[", "\"URL\"", "=>", "$", "this", "->", "url", "]", ",", "[", "\"message\"", "=>", "\"test\"", "]", ")", ";", "}", "}", "// Request failed", "if", "(", "$", "this", "->", "response", "===", "FALSE", ")", "{", "$", "errno", "=", "curl_errno", "(", "$", "this", "->", "session", ")", ";", "$", "error", "=", "curl_error", "(", "$", "this", "->", "session", ")", ";", "curl_close", "(", "$", "this", "->", "session", ")", ";", "$", "this", "->", "set_defaults", "(", ")", ";", "$", "this", "->", "error_code", "=", "$", "errno", ";", "$", "this", "->", "error_string", "=", "$", "error", ";", "return", "FALSE", ";", "}", "// Request successful", "else", "{", "curl_close", "(", "$", "this", "->", "session", ")", ";", "$", "this", "->", "last_response", "=", "$", "this", "->", "response", ";", "$", "this", "->", "last_response_header", "=", "$", "this", "->", "response_header", ";", "$", "this", "->", "last_info", "=", "$", "this", "->", "info", ";", "$", "this", "->", "set_defaults", "(", ")", ";", "return", "$", "this", "->", "last_response", ";", "}", "}" ]
End a session and return the results
[ "End", "a", "session", "and", "return", "the", "results" ]
36b75f433df4c25fe61c02832706ba16cfa13203
https://github.com/nbostech/wavelabs-php-client-api/blob/36b75f433df4c25fe61c02832706ba16cfa13203/src/NBOS/http/Curl.php#L295-L376
8,687
fabsgc/framework
Core/Orm/Validation/Validation.php
Validation.check
public function check() { $this->_errors = []; /** @var $element \Gcs\Framework\Core\Orm\Validation\Element\Element */ foreach ($this->_elements as $element) { $element->check(); if ($element->valid() == false) { $this->_errors = array_merge($this->_errors, $element->errors()); } } }
php
public function check() { $this->_errors = []; /** @var $element \Gcs\Framework\Core\Orm\Validation\Element\Element */ foreach ($this->_elements as $element) { $element->check(); if ($element->valid() == false) { $this->_errors = array_merge($this->_errors, $element->errors()); } } }
[ "public", "function", "check", "(", ")", "{", "$", "this", "->", "_errors", "=", "[", "]", ";", "/** @var $element \\Gcs\\Framework\\Core\\Orm\\Validation\\Element\\Element */", "foreach", "(", "$", "this", "->", "_elements", "as", "$", "element", ")", "{", "$", "element", "->", "check", "(", ")", ";", "if", "(", "$", "element", "->", "valid", "(", ")", "==", "false", ")", "{", "$", "this", "->", "_errors", "=", "array_merge", "(", "$", "this", "->", "_errors", ",", "$", "element", "->", "errors", "(", ")", ")", ";", "}", "}", "}" ]
check a form request @access public @return void @since 3.0 @package Gcs\Framework\Core\Orm\Validation
[ "check", "a", "form", "request" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Validation.php#L63-L74
8,688
fabsgc/framework
Core/Orm/Validation/Validation.php
Validation.checkbox
public function checkbox($field, $label) { $checkbox = new Checkbox($this->_entity, $field, $label); array_push($this->_elements, $checkbox); return $checkbox; }
php
public function checkbox($field, $label) { $checkbox = new Checkbox($this->_entity, $field, $label); array_push($this->_elements, $checkbox); return $checkbox; }
[ "public", "function", "checkbox", "(", "$", "field", ",", "$", "label", ")", "{", "$", "checkbox", "=", "new", "Checkbox", "(", "$", "this", "->", "_entity", ",", "$", "field", ",", "$", "label", ")", ";", "array_push", "(", "$", "this", "->", "_elements", ",", "$", "checkbox", ")", ";", "return", "$", "checkbox", ";", "}" ]
add checkbox element @access public @param $field string @param $label string @return \Gcs\Framework\Core\Orm\Validation\Element\Checkbox @since 3.0 @package Gcs\Framework\Core\Orm\Validation
[ "add", "checkbox", "element" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Validation.php#L132-L137
8,689
fabsgc/framework
Core/Orm/Validation/Validation.php
Validation.select
public function select($field, $label) { $select = new Select($this->_entity, $field, $label); array_push($this->_elements, $select); return $select; }
php
public function select($field, $label) { $select = new Select($this->_entity, $field, $label); array_push($this->_elements, $select); return $select; }
[ "public", "function", "select", "(", "$", "field", ",", "$", "label", ")", "{", "$", "select", "=", "new", "Select", "(", "$", "this", "->", "_entity", ",", "$", "field", ",", "$", "label", ")", ";", "array_push", "(", "$", "this", "->", "_elements", ",", "$", "select", ")", ";", "return", "$", "select", ";", "}" ]
add select element @access public @param $field string @param $label string @return \Gcs\Framework\Core\Orm\Validation\Element\Select @since 3.0 @package Gcs\Framework\Core\Orm\Validation
[ "add", "select", "element" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Validation.php#L166-L171
8,690
fabsgc/framework
Core/Orm/Validation/Validation.php
Validation.file
public function file($field, $label) { $file = new File($this->_entity, $field, $label); array_push($this->_elements, $file); return $file; }
php
public function file($field, $label) { $file = new File($this->_entity, $field, $label); array_push($this->_elements, $file); return $file; }
[ "public", "function", "file", "(", "$", "field", ",", "$", "label", ")", "{", "$", "file", "=", "new", "File", "(", "$", "this", "->", "_entity", ",", "$", "field", ",", "$", "label", ")", ";", "array_push", "(", "$", "this", "->", "_elements", ",", "$", "file", ")", ";", "return", "$", "file", ";", "}" ]
add file element @access public @param $field string @param $label string @return \Gcs\Framework\Core\Orm\Validation\Element\File @since 3.0 @package Gcs\Framework\Core\Orm\Validation
[ "add", "file", "element" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Validation.php#L183-L188
8,691
phlexible/phlexible
src/Phlexible/Bundle/ElementBundle/Search/AbstractSearch.php
AbstractSearch.doSearch
protected function doSearch(array $rows, $title, $language = null) { if ($language === null) { $language = $this->defaultLanguage; } $results = []; foreach ($rows as $row) { $node = $this->treeManager->getByNodeId($row['id'])->get($row['id']); if (!$this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN') && !$this->authorizationChecker->isGranted('VIEW', $node)) { continue; } $element = $this->elementService->findElement($node->getTypeId()); $elementVersion = $this->elementService->findLatestElementVersion($element); $siteroot = $this->siterootManager->find($node->getTree()->getSiterootId()); $handlerData = array( 'handler' => 'element', 'parameters' => array( 'id' => $node->getId(), 'siteroot_id' => $node->getTree()->getSiterootId(), 'title' => $siteroot->getTitle($language), 'start_tid_path' => '/'.implode('/', $node->getTree()->getIdPath($node)), ), ); $createUserName = 'Unknown User'; try { $createUser = $this->userManager->find($elementVersion->getCreateUserId()); if ($createUser) { $createUserName = $createUser->getDisplayName(); } } catch (\Exception $e) { } $icon = $this->iconResolver->resolveTreeNode($node, $language); $results[] = new SearchResult( $node->getId(), $siteroot->getTitle($language).' :: '.$elementVersion->getBackendTitle($language).' ('.$language.', '.$node->getId().')', $createUserName, $elementVersion->getCreatedAt(), $icon, $title, $handlerData ); } return $results; }
php
protected function doSearch(array $rows, $title, $language = null) { if ($language === null) { $language = $this->defaultLanguage; } $results = []; foreach ($rows as $row) { $node = $this->treeManager->getByNodeId($row['id'])->get($row['id']); if (!$this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN') && !$this->authorizationChecker->isGranted('VIEW', $node)) { continue; } $element = $this->elementService->findElement($node->getTypeId()); $elementVersion = $this->elementService->findLatestElementVersion($element); $siteroot = $this->siterootManager->find($node->getTree()->getSiterootId()); $handlerData = array( 'handler' => 'element', 'parameters' => array( 'id' => $node->getId(), 'siteroot_id' => $node->getTree()->getSiterootId(), 'title' => $siteroot->getTitle($language), 'start_tid_path' => '/'.implode('/', $node->getTree()->getIdPath($node)), ), ); $createUserName = 'Unknown User'; try { $createUser = $this->userManager->find($elementVersion->getCreateUserId()); if ($createUser) { $createUserName = $createUser->getDisplayName(); } } catch (\Exception $e) { } $icon = $this->iconResolver->resolveTreeNode($node, $language); $results[] = new SearchResult( $node->getId(), $siteroot->getTitle($language).' :: '.$elementVersion->getBackendTitle($language).' ('.$language.', '.$node->getId().')', $createUserName, $elementVersion->getCreatedAt(), $icon, $title, $handlerData ); } return $results; }
[ "protected", "function", "doSearch", "(", "array", "$", "rows", ",", "$", "title", ",", "$", "language", "=", "null", ")", "{", "if", "(", "$", "language", "===", "null", ")", "{", "$", "language", "=", "$", "this", "->", "defaultLanguage", ";", "}", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "node", "=", "$", "this", "->", "treeManager", "->", "getByNodeId", "(", "$", "row", "[", "'id'", "]", ")", "->", "get", "(", "$", "row", "[", "'id'", "]", ")", ";", "if", "(", "!", "$", "this", "->", "authorizationChecker", "->", "isGranted", "(", "'ROLE_SUPER_ADMIN'", ")", "&&", "!", "$", "this", "->", "authorizationChecker", "->", "isGranted", "(", "'VIEW'", ",", "$", "node", ")", ")", "{", "continue", ";", "}", "$", "element", "=", "$", "this", "->", "elementService", "->", "findElement", "(", "$", "node", "->", "getTypeId", "(", ")", ")", ";", "$", "elementVersion", "=", "$", "this", "->", "elementService", "->", "findLatestElementVersion", "(", "$", "element", ")", ";", "$", "siteroot", "=", "$", "this", "->", "siterootManager", "->", "find", "(", "$", "node", "->", "getTree", "(", ")", "->", "getSiterootId", "(", ")", ")", ";", "$", "handlerData", "=", "array", "(", "'handler'", "=>", "'element'", ",", "'parameters'", "=>", "array", "(", "'id'", "=>", "$", "node", "->", "getId", "(", ")", ",", "'siteroot_id'", "=>", "$", "node", "->", "getTree", "(", ")", "->", "getSiterootId", "(", ")", ",", "'title'", "=>", "$", "siteroot", "->", "getTitle", "(", "$", "language", ")", ",", "'start_tid_path'", "=>", "'/'", ".", "implode", "(", "'/'", ",", "$", "node", "->", "getTree", "(", ")", "->", "getIdPath", "(", "$", "node", ")", ")", ",", ")", ",", ")", ";", "$", "createUserName", "=", "'Unknown User'", ";", "try", "{", "$", "createUser", "=", "$", "this", "->", "userManager", "->", "find", "(", "$", "elementVersion", "->", "getCreateUserId", "(", ")", ")", ";", "if", "(", "$", "createUser", ")", "{", "$", "createUserName", "=", "$", "createUser", "->", "getDisplayName", "(", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "$", "icon", "=", "$", "this", "->", "iconResolver", "->", "resolveTreeNode", "(", "$", "node", ",", "$", "language", ")", ";", "$", "results", "[", "]", "=", "new", "SearchResult", "(", "$", "node", "->", "getId", "(", ")", ",", "$", "siteroot", "->", "getTitle", "(", "$", "language", ")", ".", "' :: '", ".", "$", "elementVersion", "->", "getBackendTitle", "(", "$", "language", ")", ".", "' ('", ".", "$", "language", ".", "', '", ".", "$", "node", "->", "getId", "(", ")", ".", "')'", ",", "$", "createUserName", ",", "$", "elementVersion", "->", "getCreatedAt", "(", ")", ",", "$", "icon", ",", "$", "title", ",", "$", "handlerData", ")", ";", "}", "return", "$", "results", ";", "}" ]
Perform search. @param array $rows @param string $title @param string $language @return array
[ "Perform", "search", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementBundle/Search/AbstractSearch.php#L134-L185
8,692
sebardo/core
CoreBundle/Controller/ActorController.php
ActorController.newAction
public function newAction(Request $request) { $actorClass = $this->container->get('core_manager')->getActorClass(); $actor = new $actorClass(); $form = $this->createForm($this->get('core_manager')->getActorBundleName().'\Form\ActorType', $actor); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); //crypt password $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder(new BaseActor()); $encodePassword = $encoder->encodePassword($actor->getPassword(), $actor->getSalt()); $actor->setPassword($encodePassword); $role = $em->getRepository('CoreBundle:Role')->findOneByRole(Role::USER); $actor->addRole($role); $em->persist($actor); $em->flush(); $filesData = $request->files->get('actor'); if (isset($filesData['image']['file']) && $filesData['image']['file'] instanceof UploadedFile) { $this->get('core_manager')->uploadProfileImage($actor); } $this->get('session')->getFlashBag()->add('success', 'actor.created'); return $this->redirectToRoute('core_actor_show', array('id' => $actor->getId())); } return array( 'entity' => $actor, 'form' => $form->createView(), ); }
php
public function newAction(Request $request) { $actorClass = $this->container->get('core_manager')->getActorClass(); $actor = new $actorClass(); $form = $this->createForm($this->get('core_manager')->getActorBundleName().'\Form\ActorType', $actor); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); //crypt password $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder(new BaseActor()); $encodePassword = $encoder->encodePassword($actor->getPassword(), $actor->getSalt()); $actor->setPassword($encodePassword); $role = $em->getRepository('CoreBundle:Role')->findOneByRole(Role::USER); $actor->addRole($role); $em->persist($actor); $em->flush(); $filesData = $request->files->get('actor'); if (isset($filesData['image']['file']) && $filesData['image']['file'] instanceof UploadedFile) { $this->get('core_manager')->uploadProfileImage($actor); } $this->get('session')->getFlashBag()->add('success', 'actor.created'); return $this->redirectToRoute('core_actor_show', array('id' => $actor->getId())); } return array( 'entity' => $actor, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", "Request", "$", "request", ")", "{", "$", "actorClass", "=", "$", "this", "->", "container", "->", "get", "(", "'core_manager'", ")", "->", "getActorClass", "(", ")", ";", "$", "actor", "=", "new", "$", "actorClass", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "'core_manager'", ")", "->", "getActorBundleName", "(", ")", ".", "'\\Form\\ActorType'", ",", "$", "actor", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isSubmitted", "(", ")", "&&", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "//crypt password", "$", "factory", "=", "$", "this", "->", "get", "(", "'security.encoder_factory'", ")", ";", "$", "encoder", "=", "$", "factory", "->", "getEncoder", "(", "new", "BaseActor", "(", ")", ")", ";", "$", "encodePassword", "=", "$", "encoder", "->", "encodePassword", "(", "$", "actor", "->", "getPassword", "(", ")", ",", "$", "actor", "->", "getSalt", "(", ")", ")", ";", "$", "actor", "->", "setPassword", "(", "$", "encodePassword", ")", ";", "$", "role", "=", "$", "em", "->", "getRepository", "(", "'CoreBundle:Role'", ")", "->", "findOneByRole", "(", "Role", "::", "USER", ")", ";", "$", "actor", "->", "addRole", "(", "$", "role", ")", ";", "$", "em", "->", "persist", "(", "$", "actor", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "filesData", "=", "$", "request", "->", "files", "->", "get", "(", "'actor'", ")", ";", "if", "(", "isset", "(", "$", "filesData", "[", "'image'", "]", "[", "'file'", "]", ")", "&&", "$", "filesData", "[", "'image'", "]", "[", "'file'", "]", "instanceof", "UploadedFile", ")", "{", "$", "this", "->", "get", "(", "'core_manager'", ")", "->", "uploadProfileImage", "(", "$", "actor", ")", ";", "}", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'actor.created'", ")", ";", "return", "$", "this", "->", "redirectToRoute", "(", "'core_actor_show'", ",", "array", "(", "'id'", "=>", "$", "actor", "->", "getId", "(", ")", ")", ")", ";", "}", "return", "array", "(", "'entity'", "=>", "$", "actor", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Creates a new Actor entity. @Route("/admin/actor/new") @Method({"GET", "POST"}) @Template()
[ "Creates", "a", "new", "Actor", "entity", "." ]
d063334639dd717406c97ea4da9f4b260d0af4f4
https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Controller/ActorController.php#L72-L106
8,693
sebardo/core
CoreBundle/Controller/ActorController.php
ActorController.editAction
public function editAction(Request $request, Actor $actor) { $oldPassword = $actor->getPassword(); $deleteForm = $this->createDeleteForm($actor); $editForm = $this->createForm('CoreBundle\Form\ActorEditType', $actor); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $em = $this->getDoctrine()->getManager(); if($actor->getRemoveImage()){ $actor->setImage(null); } //crypt password $password = $editForm->getNormData()->getPassword(); if($password != ''){ $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder(new BaseActor()); $encodePassword = $encoder->encodePassword($password, $actor->getSalt()); $actor->setPassword($encodePassword); }else{ $actor->setPassword($oldPassword); } $em->persist($actor); $em->flush(); //image $filesData = $request->files->get('actor_edit'); if (isset($filesData['image']['file']) && $filesData['image']['file'] instanceof UploadedFile) { $this->get('core_manager')->uploadProfileImage($actor); } $this->get('session')->getFlashBag()->add('success', 'actor.edited'); return $this->redirectToRoute('core_actor_show', array('id' => $actor->getId())); } return array( 'entity' => $actor, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function editAction(Request $request, Actor $actor) { $oldPassword = $actor->getPassword(); $deleteForm = $this->createDeleteForm($actor); $editForm = $this->createForm('CoreBundle\Form\ActorEditType', $actor); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $em = $this->getDoctrine()->getManager(); if($actor->getRemoveImage()){ $actor->setImage(null); } //crypt password $password = $editForm->getNormData()->getPassword(); if($password != ''){ $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder(new BaseActor()); $encodePassword = $encoder->encodePassword($password, $actor->getSalt()); $actor->setPassword($encodePassword); }else{ $actor->setPassword($oldPassword); } $em->persist($actor); $em->flush(); //image $filesData = $request->files->get('actor_edit'); if (isset($filesData['image']['file']) && $filesData['image']['file'] instanceof UploadedFile) { $this->get('core_manager')->uploadProfileImage($actor); } $this->get('session')->getFlashBag()->add('success', 'actor.edited'); return $this->redirectToRoute('core_actor_show', array('id' => $actor->getId())); } return array( 'entity' => $actor, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "editAction", "(", "Request", "$", "request", ",", "Actor", "$", "actor", ")", "{", "$", "oldPassword", "=", "$", "actor", "->", "getPassword", "(", ")", ";", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "actor", ")", ";", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "'CoreBundle\\Form\\ActorEditType'", ",", "$", "actor", ")", ";", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isSubmitted", "(", ")", "&&", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "if", "(", "$", "actor", "->", "getRemoveImage", "(", ")", ")", "{", "$", "actor", "->", "setImage", "(", "null", ")", ";", "}", "//crypt password", "$", "password", "=", "$", "editForm", "->", "getNormData", "(", ")", "->", "getPassword", "(", ")", ";", "if", "(", "$", "password", "!=", "''", ")", "{", "$", "factory", "=", "$", "this", "->", "get", "(", "'security.encoder_factory'", ")", ";", "$", "encoder", "=", "$", "factory", "->", "getEncoder", "(", "new", "BaseActor", "(", ")", ")", ";", "$", "encodePassword", "=", "$", "encoder", "->", "encodePassword", "(", "$", "password", ",", "$", "actor", "->", "getSalt", "(", ")", ")", ";", "$", "actor", "->", "setPassword", "(", "$", "encodePassword", ")", ";", "}", "else", "{", "$", "actor", "->", "setPassword", "(", "$", "oldPassword", ")", ";", "}", "$", "em", "->", "persist", "(", "$", "actor", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "//image", "$", "filesData", "=", "$", "request", "->", "files", "->", "get", "(", "'actor_edit'", ")", ";", "if", "(", "isset", "(", "$", "filesData", "[", "'image'", "]", "[", "'file'", "]", ")", "&&", "$", "filesData", "[", "'image'", "]", "[", "'file'", "]", "instanceof", "UploadedFile", ")", "{", "$", "this", "->", "get", "(", "'core_manager'", ")", "->", "uploadProfileImage", "(", "$", "actor", ")", ";", "}", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'actor.edited'", ")", ";", "return", "$", "this", "->", "redirectToRoute", "(", "'core_actor_show'", ",", "array", "(", "'id'", "=>", "$", "actor", "->", "getId", "(", ")", ")", ")", ";", "}", "return", "array", "(", "'entity'", "=>", "$", "actor", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to edit an existing Actor entity. @Route("/admin/actor/{id}/edit") @Method({"GET", "POST"}) @Template()
[ "Displays", "a", "form", "to", "edit", "an", "existing", "Actor", "entity", "." ]
d063334639dd717406c97ea4da9f4b260d0af4f4
https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Controller/ActorController.php#L150-L194
8,694
JamesRezo/webhelper-parser
src/Parser/Descriptor.php
Descriptor.getServedUrls
public function getServedUrls($path) { $isServedAs = []; foreach ($this->paths as $exposedPath => $exposedDirectory) { $relative = $this->getRelative($path, $exposedDirectory); if (!is_null($relative)) { $isServedAs[] = $this->getHost().preg_replace(',/$,', '', $exposedPath).$relative; } } return $isServedAs; }
php
public function getServedUrls($path) { $isServedAs = []; foreach ($this->paths as $exposedPath => $exposedDirectory) { $relative = $this->getRelative($path, $exposedDirectory); if (!is_null($relative)) { $isServedAs[] = $this->getHost().preg_replace(',/$,', '', $exposedPath).$relative; } } return $isServedAs; }
[ "public", "function", "getServedUrls", "(", "$", "path", ")", "{", "$", "isServedAs", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "paths", "as", "$", "exposedPath", "=>", "$", "exposedDirectory", ")", "{", "$", "relative", "=", "$", "this", "->", "getRelative", "(", "$", "path", ",", "$", "exposedDirectory", ")", ";", "if", "(", "!", "is_null", "(", "$", "relative", ")", ")", "{", "$", "isServedAs", "[", "]", "=", "$", "this", "->", "getHost", "(", ")", ".", "preg_replace", "(", "',/$,'", ",", "''", ",", "$", "exposedPath", ")", ".", "$", "relative", ";", "}", "}", "return", "$", "isServedAs", ";", "}" ]
Gets the served urls. @param string $path The path @return array The served urls
[ "Gets", "the", "served", "urls", "." ]
0b39e7abe8f35afbeacdd6681fa9d0767888c646
https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Parser/Descriptor.php#L52-L64
8,695
JamesRezo/webhelper-parser
src/Parser/Descriptor.php
Descriptor.getExposedPath
public function getExposedPath($url) { $isExposedAs = ''; list($host, $path) = $this->getUriHostAndPath($url); if ($host == $this->host) { foreach ($this->paths as $exposedPath => $exposedDirectory) { $relative = $this->getRelative($path, $exposedPath); if (!is_null($relative)) { $isExposedAs = $exposedDirectory.$relative; break; } } } return $isExposedAs; }
php
public function getExposedPath($url) { $isExposedAs = ''; list($host, $path) = $this->getUriHostAndPath($url); if ($host == $this->host) { foreach ($this->paths as $exposedPath => $exposedDirectory) { $relative = $this->getRelative($path, $exposedPath); if (!is_null($relative)) { $isExposedAs = $exposedDirectory.$relative; break; } } } return $isExposedAs; }
[ "public", "function", "getExposedPath", "(", "$", "url", ")", "{", "$", "isExposedAs", "=", "''", ";", "list", "(", "$", "host", ",", "$", "path", ")", "=", "$", "this", "->", "getUriHostAndPath", "(", "$", "url", ")", ";", "if", "(", "$", "host", "==", "$", "this", "->", "host", ")", "{", "foreach", "(", "$", "this", "->", "paths", "as", "$", "exposedPath", "=>", "$", "exposedDirectory", ")", "{", "$", "relative", "=", "$", "this", "->", "getRelative", "(", "$", "path", ",", "$", "exposedPath", ")", ";", "if", "(", "!", "is_null", "(", "$", "relative", ")", ")", "{", "$", "isExposedAs", "=", "$", "exposedDirectory", ".", "$", "relative", ";", "break", ";", "}", "}", "}", "return", "$", "isExposedAs", ";", "}" ]
Gets the exposed path. @param string $url The url @return string The exposed path
[ "Gets", "the", "exposed", "path", "." ]
0b39e7abe8f35afbeacdd6681fa9d0767888c646
https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Parser/Descriptor.php#L73-L89
8,696
JamesRezo/webhelper-parser
src/Parser/Descriptor.php
Descriptor.getRelative
private function getRelative($path, $against) { $relative = null; if (preg_replace(',/$,', '', $path) == $against || Path::isBasePath($against, Path::getDirectory($path)) ) { $relative = Path::makeRelative($path, $against); $relative = $relative ? '/'.$relative : ''; } return $relative; }
php
private function getRelative($path, $against) { $relative = null; if (preg_replace(',/$,', '', $path) == $against || Path::isBasePath($against, Path::getDirectory($path)) ) { $relative = Path::makeRelative($path, $against); $relative = $relative ? '/'.$relative : ''; } return $relative; }
[ "private", "function", "getRelative", "(", "$", "path", ",", "$", "against", ")", "{", "$", "relative", "=", "null", ";", "if", "(", "preg_replace", "(", "',/$,'", ",", "''", ",", "$", "path", ")", "==", "$", "against", "||", "Path", "::", "isBasePath", "(", "$", "against", ",", "Path", "::", "getDirectory", "(", "$", "path", ")", ")", ")", "{", "$", "relative", "=", "Path", "::", "makeRelative", "(", "$", "path", ",", "$", "against", ")", ";", "$", "relative", "=", "$", "relative", "?", "'/'", ".", "$", "relative", ":", "''", ";", "}", "return", "$", "relative", ";", "}" ]
Gets the relative path if it matches against another path. @param string $path The path @param string $against The path to match against @return null|string The relative path
[ "Gets", "the", "relative", "path", "if", "it", "matches", "against", "another", "path", "." ]
0b39e7abe8f35afbeacdd6681fa9d0767888c646
https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Parser/Descriptor.php#L99-L111
8,697
JamesRezo/webhelper-parser
src/Parser/Descriptor.php
Descriptor.getUriHostAndPath
private function getUriHostAndPath($url) { try { $uri = HttpUri::createFromString($url); } catch (InvalidArgumentException $e) { return ['', '']; } $host = $uri->getHost(); $port = $uri->getPort(); if (!$port && $uri->getScheme() == 'https') { $port = 443; } if ($port) { $host .= ':'.strval($port); } $path = $uri->getPath(); if (!$path) { $path = '/'; } return [$host, $path]; }
php
private function getUriHostAndPath($url) { try { $uri = HttpUri::createFromString($url); } catch (InvalidArgumentException $e) { return ['', '']; } $host = $uri->getHost(); $port = $uri->getPort(); if (!$port && $uri->getScheme() == 'https') { $port = 443; } if ($port) { $host .= ':'.strval($port); } $path = $uri->getPath(); if (!$path) { $path = '/'; } return [$host, $path]; }
[ "private", "function", "getUriHostAndPath", "(", "$", "url", ")", "{", "try", "{", "$", "uri", "=", "HttpUri", "::", "createFromString", "(", "$", "url", ")", ";", "}", "catch", "(", "InvalidArgumentException", "$", "e", ")", "{", "return", "[", "''", ",", "''", "]", ";", "}", "$", "host", "=", "$", "uri", "->", "getHost", "(", ")", ";", "$", "port", "=", "$", "uri", "->", "getPort", "(", ")", ";", "if", "(", "!", "$", "port", "&&", "$", "uri", "->", "getScheme", "(", ")", "==", "'https'", ")", "{", "$", "port", "=", "443", ";", "}", "if", "(", "$", "port", ")", "{", "$", "host", ".=", "':'", ".", "strval", "(", "$", "port", ")", ";", "}", "$", "path", "=", "$", "uri", "->", "getPath", "(", ")", ";", "if", "(", "!", "$", "path", ")", "{", "$", "path", "=", "'/'", ";", "}", "return", "[", "$", "host", ",", "$", "path", "]", ";", "}" ]
Gets the uri host and path. @param string $url The url @return array The uri host and path
[ "Gets", "the", "uri", "host", "and", "path", "." ]
0b39e7abe8f35afbeacdd6681fa9d0767888c646
https://github.com/JamesRezo/webhelper-parser/blob/0b39e7abe8f35afbeacdd6681fa9d0767888c646/src/Parser/Descriptor.php#L138-L160
8,698
MINISTRYGmbH/morrow-core
src/Db.php
Db.connect
public function connect() { if (!$this->connected) { if ($this->config['host']{0} == '/') { $connector = $this->config['driver'].':unix_socket='.$this->config['host'].';dbname='.$this->config['db']; } else { $connector = $this->config['driver'].':host='.$this->config['host'].';dbname='.$this->config['db']; } // sqlite if ($this->config['driver'] == 'sqlite') { $connector = $this->config['driver'].':'.$this->config['file'].''; } parent::__construct($connector, $this->config['user'], $this->config['pass']); $this -> setAttribute(\PDO::ATTR_CASE, \PDO::CASE_NATURAL); // leave column names as returned by the database driver $this -> setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); // on errors we want to get \Exceptions // set encoding if (isset($this->config['encoding']) && $this->config['driver'] != 'sqlite') { parent::exec('SET NAMES '.$this->config['encoding']); } $this->connected = true; } }
php
public function connect() { if (!$this->connected) { if ($this->config['host']{0} == '/') { $connector = $this->config['driver'].':unix_socket='.$this->config['host'].';dbname='.$this->config['db']; } else { $connector = $this->config['driver'].':host='.$this->config['host'].';dbname='.$this->config['db']; } // sqlite if ($this->config['driver'] == 'sqlite') { $connector = $this->config['driver'].':'.$this->config['file'].''; } parent::__construct($connector, $this->config['user'], $this->config['pass']); $this -> setAttribute(\PDO::ATTR_CASE, \PDO::CASE_NATURAL); // leave column names as returned by the database driver $this -> setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); // on errors we want to get \Exceptions // set encoding if (isset($this->config['encoding']) && $this->config['driver'] != 'sqlite') { parent::exec('SET NAMES '.$this->config['encoding']); } $this->connected = true; } }
[ "public", "function", "connect", "(", ")", "{", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "if", "(", "$", "this", "->", "config", "[", "'host'", "]", "{", "0", "}", "==", "'/'", ")", "{", "$", "connector", "=", "$", "this", "->", "config", "[", "'driver'", "]", ".", "':unix_socket='", ".", "$", "this", "->", "config", "[", "'host'", "]", ".", "';dbname='", ".", "$", "this", "->", "config", "[", "'db'", "]", ";", "}", "else", "{", "$", "connector", "=", "$", "this", "->", "config", "[", "'driver'", "]", ".", "':host='", ".", "$", "this", "->", "config", "[", "'host'", "]", ".", "';dbname='", ".", "$", "this", "->", "config", "[", "'db'", "]", ";", "}", "// sqlite", "if", "(", "$", "this", "->", "config", "[", "'driver'", "]", "==", "'sqlite'", ")", "{", "$", "connector", "=", "$", "this", "->", "config", "[", "'driver'", "]", ".", "':'", ".", "$", "this", "->", "config", "[", "'file'", "]", ".", "''", ";", "}", "parent", "::", "__construct", "(", "$", "connector", ",", "$", "this", "->", "config", "[", "'user'", "]", ",", "$", "this", "->", "config", "[", "'pass'", "]", ")", ";", "$", "this", "->", "setAttribute", "(", "\\", "PDO", "::", "ATTR_CASE", ",", "\\", "PDO", "::", "CASE_NATURAL", ")", ";", "// leave column names as returned by the database driver", "$", "this", "->", "setAttribute", "(", "\\", "PDO", "::", "ATTR_ERRMODE", ",", "\\", "PDO", "::", "ERRMODE_EXCEPTION", ")", ";", "// on errors we want to get \\Exceptions", "// set encoding", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'encoding'", "]", ")", "&&", "$", "this", "->", "config", "[", "'driver'", "]", "!=", "'sqlite'", ")", "{", "parent", "::", "exec", "(", "'SET NAMES '", ".", "$", "this", "->", "config", "[", "'encoding'", "]", ")", ";", "}", "$", "this", "->", "connected", "=", "true", ";", "}", "}" ]
Connects to the Database. Because we added Lazy initialization to PDO you only have to call this method if you use PDOs own functions and you did not call any of our methods before. @return null
[ "Connects", "to", "the", "Database", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Db.php#L118-L143
8,699
MINISTRYGmbH/morrow-core
src/Db.php
Db.get
public function get($query, $token = null) { if (is_scalar($token)) $token = [$token]; // search for access keys $accesskey = null; $found = preg_match('=SELECT.+>([a-z_]+).+FROM=is', $query, $match); if ($found === 1) { $accesskey = $match[1]; $query = str_replace('>'.$accesskey, $accesskey, $query); } // do query $this->connect(); $sth = $this->prepare($query); $returner['SUCCESS'] = $sth->execute($token); $returner['RESULT'] = $sth->fetchAll(\PDO::FETCH_ASSOC); $returner['NUM_ROWS'] = count($returner['RESULT']); // if an access key was provided rearrange array if (!is_null($accesskey)) { $newreturner = []; foreach ($returner['RESULT'] as $row) { $newreturner[$row[$accesskey]] = $row; } $returner['RESULT'] = $newreturner; } return $returner; }
php
public function get($query, $token = null) { if (is_scalar($token)) $token = [$token]; // search for access keys $accesskey = null; $found = preg_match('=SELECT.+>([a-z_]+).+FROM=is', $query, $match); if ($found === 1) { $accesskey = $match[1]; $query = str_replace('>'.$accesskey, $accesskey, $query); } // do query $this->connect(); $sth = $this->prepare($query); $returner['SUCCESS'] = $sth->execute($token); $returner['RESULT'] = $sth->fetchAll(\PDO::FETCH_ASSOC); $returner['NUM_ROWS'] = count($returner['RESULT']); // if an access key was provided rearrange array if (!is_null($accesskey)) { $newreturner = []; foreach ($returner['RESULT'] as $row) { $newreturner[$row[$accesskey]] = $row; } $returner['RESULT'] = $newreturner; } return $returner; }
[ "public", "function", "get", "(", "$", "query", ",", "$", "token", "=", "null", ")", "{", "if", "(", "is_scalar", "(", "$", "token", ")", ")", "$", "token", "=", "[", "$", "token", "]", ";", "// search for access keys", "$", "accesskey", "=", "null", ";", "$", "found", "=", "preg_match", "(", "'=SELECT.+>([a-z_]+).+FROM=is'", ",", "$", "query", ",", "$", "match", ")", ";", "if", "(", "$", "found", "===", "1", ")", "{", "$", "accesskey", "=", "$", "match", "[", "1", "]", ";", "$", "query", "=", "str_replace", "(", "'>'", ".", "$", "accesskey", ",", "$", "accesskey", ",", "$", "query", ")", ";", "}", "// do query", "$", "this", "->", "connect", "(", ")", ";", "$", "sth", "=", "$", "this", "->", "prepare", "(", "$", "query", ")", ";", "$", "returner", "[", "'SUCCESS'", "]", "=", "$", "sth", "->", "execute", "(", "$", "token", ")", ";", "$", "returner", "[", "'RESULT'", "]", "=", "$", "sth", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "$", "returner", "[", "'NUM_ROWS'", "]", "=", "count", "(", "$", "returner", "[", "'RESULT'", "]", ")", ";", "// if an access key was provided rearrange array", "if", "(", "!", "is_null", "(", "$", "accesskey", ")", ")", "{", "$", "newreturner", "=", "[", "]", ";", "foreach", "(", "$", "returner", "[", "'RESULT'", "]", "as", "$", "row", ")", "{", "$", "newreturner", "[", "$", "row", "[", "$", "accesskey", "]", "]", "=", "$", "row", ";", "}", "$", "returner", "[", "'RESULT'", "]", "=", "$", "newreturner", ";", "}", "return", "$", "returner", ";", "}" ]
This method sends a query to the database and returns the result. @param string $query The SQL query to send. @param array $token An array with the prepared statement parameters (indexed or associative array, depends on the use of the prepared statement syntax) @return array Returns an array with the keys `SUCCESS` (true if the query could successfully sent to the db, otherwise false), `RESULT` (array The complete result set of the request) and `NUM_ROWS` (integer The count of returned results).
[ "This", "method", "sends", "a", "query", "to", "the", "database", "and", "returns", "the", "result", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Db.php#L152-L180