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
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
17,300
shinjin/freezer
src/LazyProxy.php
LazyProxy.__isset
public function __isset($name) { if ($this->thawedObject === null) { if ($name === $this->storage->getFreezer()->getIdProperty()) { return true; } } return isset($this->replaceProxy(2)->{$name}); }
php
public function __isset($name) { if ($this->thawedObject === null) { if ($name === $this->storage->getFreezer()->getIdProperty()) { return true; } } return isset($this->replaceProxy(2)->{$name}); }
[ "public", "function", "__isset", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "thawedObject", "===", "null", ")", "{", "if", "(", "$", "name", "===", "$", "this", "->", "storage", "->", "getFreezer", "(", ")", "->", "getIdProperty", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "isset", "(", "$", "this", "->", "replaceProxy", "(", "2", ")", "->", "{", "$", "name", "}", ")", ";", "}" ]
Delegates the property isset check to the real object and tries to replace the lazy proxy object with it. @param string $name @return mixed
[ "Delegates", "the", "property", "isset", "check", "to", "the", "real", "object", "and", "tries", "to", "replace", "the", "lazy", "proxy", "object", "with", "it", "." ]
f5955fb5476fa8ac456e27c0edafaae331d02cd3
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/LazyProxy.php#L119-L128
17,301
shinjin/freezer
src/LazyProxy.php
LazyProxy.replaceProxy
protected function replaceProxy($offset) { $object = $this->getObject(); /** * 0: LazyProxy::replaceProxy() * 1: LazyProxy::__get($name) / LazyProxy::__set($name, $value) * 2: Frame that accesses $name * 1: LazyProxy::__call($method, $arguments) * 2: LazyProxy::$method() * 3: Frame that invokes $method */ $trace = debug_backtrace(); if (isset($trace[$offset]['object'])) { $reflector = new \ReflectionObject($trace[$offset]['object']); foreach ($reflector->getProperties() as $property) { $property->setAccessible(true); if ($property->getValue($trace[$offset]['object']) === $this) { $property->setValue($trace[$offset]['object'], $object); break; } } } return $object; }
php
protected function replaceProxy($offset) { $object = $this->getObject(); /** * 0: LazyProxy::replaceProxy() * 1: LazyProxy::__get($name) / LazyProxy::__set($name, $value) * 2: Frame that accesses $name * 1: LazyProxy::__call($method, $arguments) * 2: LazyProxy::$method() * 3: Frame that invokes $method */ $trace = debug_backtrace(); if (isset($trace[$offset]['object'])) { $reflector = new \ReflectionObject($trace[$offset]['object']); foreach ($reflector->getProperties() as $property) { $property->setAccessible(true); if ($property->getValue($trace[$offset]['object']) === $this) { $property->setValue($trace[$offset]['object'], $object); break; } } } return $object; }
[ "protected", "function", "replaceProxy", "(", "$", "offset", ")", "{", "$", "object", "=", "$", "this", "->", "getObject", "(", ")", ";", "/**\n * 0: LazyProxy::replaceProxy()\n * 1: LazyProxy::__get($name) / LazyProxy::__set($name, $value)\n * 2: Frame that accesses $name\n * 1: LazyProxy::__call($method, $arguments)\n * 2: LazyProxy::$method()\n * 3: Frame that invokes $method\n */", "$", "trace", "=", "debug_backtrace", "(", ")", ";", "if", "(", "isset", "(", "$", "trace", "[", "$", "offset", "]", "[", "'object'", "]", ")", ")", "{", "$", "reflector", "=", "new", "\\", "ReflectionObject", "(", "$", "trace", "[", "$", "offset", "]", "[", "'object'", "]", ")", ";", "foreach", "(", "$", "reflector", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "if", "(", "$", "property", "->", "getValue", "(", "$", "trace", "[", "$", "offset", "]", "[", "'object'", "]", ")", "===", "$", "this", ")", "{", "$", "property", "->", "setValue", "(", "$", "trace", "[", "$", "offset", "]", "[", "'object'", "]", ",", "$", "object", ")", ";", "break", ";", "}", "}", "}", "return", "$", "object", ";", "}" ]
Tries to replace the lazy proxy object with the real object. @param integer $offset @return object
[ "Tries", "to", "replace", "the", "lazy", "proxy", "object", "with", "the", "real", "object", "." ]
f5955fb5476fa8ac456e27c0edafaae331d02cd3
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/LazyProxy.php#L136-L164
17,302
dburkart/scurvy
expression.php
Expression.newVar
public function newVar($str) { $str = trim($str); // Try to make it a variable if (preg_match('/^[a-zA-Z0-9\'_][a-zA-Z0-9\'_-]*$/', $str)) return new Atom(EXPR_VAR, $str); else { return false; } }
php
public function newVar($str) { $str = trim($str); // Try to make it a variable if (preg_match('/^[a-zA-Z0-9\'_][a-zA-Z0-9\'_-]*$/', $str)) return new Atom(EXPR_VAR, $str); else { return false; } }
[ "public", "function", "newVar", "(", "$", "str", ")", "{", "$", "str", "=", "trim", "(", "$", "str", ")", ";", "// Try to make it a variable", "if", "(", "preg_match", "(", "'/^[a-zA-Z0-9\\'_][a-zA-Z0-9\\'_-]*$/'", ",", "$", "str", ")", ")", "return", "new", "Atom", "(", "EXPR_VAR", ",", "$", "str", ")", ";", "else", "{", "return", "false", ";", "}", "}" ]
Creates a new variable atom, subsequent to validating that the string is correct for a variable @param str the name of the variable @return the newly created atom
[ "Creates", "a", "new", "variable", "atom", "subsequent", "to", "validating", "that", "the", "string", "is", "correct", "for", "a", "variable" ]
990a7c4f0517298de304438cf9cd95a303a231fb
https://github.com/dburkart/scurvy/blob/990a7c4f0517298de304438cf9cd95a303a231fb/expression.php#L343-L352
17,303
fubhy/graphql-php
src/Executor/Executor.php
Executor.buildExecutionContext
protected static function buildExecutionContext(Schema $schema, $root, Document $ast, $operationName = NULL, array $args = NULL, &$errors) { $operations = []; $fragments = []; foreach ($ast->get('definitions') as $statement) { switch ($statement::KIND) { case Node::KIND_OPERATION_DEFINITION: $operations[$statement->get('name') ? $statement->get('name')->get('value') : ''] = $statement; break; case Node::KIND_FRAGMENT_DEFINITION: $fragments[$statement->get('name')->get('value')] = $statement; break; } } if (!$operationName && count($operations) !== 1) { throw new \Exception('Must provide operation name if query contains multiple operations'); } $name = $operationName ?: key($operations); if (!isset($operations[$name])) { throw new \Exception('Unknown operation name: ' . $name); } $operation = $operations[$name]; $variables = Values::getVariableValues($schema, $operation->get('variableDefinitions') ?: [], $args ?: []); $context = new ExecutionContext($schema, $fragments, $root, $operation, $variables, $errors); return $context; }
php
protected static function buildExecutionContext(Schema $schema, $root, Document $ast, $operationName = NULL, array $args = NULL, &$errors) { $operations = []; $fragments = []; foreach ($ast->get('definitions') as $statement) { switch ($statement::KIND) { case Node::KIND_OPERATION_DEFINITION: $operations[$statement->get('name') ? $statement->get('name')->get('value') : ''] = $statement; break; case Node::KIND_FRAGMENT_DEFINITION: $fragments[$statement->get('name')->get('value')] = $statement; break; } } if (!$operationName && count($operations) !== 1) { throw new \Exception('Must provide operation name if query contains multiple operations'); } $name = $operationName ?: key($operations); if (!isset($operations[$name])) { throw new \Exception('Unknown operation name: ' . $name); } $operation = $operations[$name]; $variables = Values::getVariableValues($schema, $operation->get('variableDefinitions') ?: [], $args ?: []); $context = new ExecutionContext($schema, $fragments, $root, $operation, $variables, $errors); return $context; }
[ "protected", "static", "function", "buildExecutionContext", "(", "Schema", "$", "schema", ",", "$", "root", ",", "Document", "$", "ast", ",", "$", "operationName", "=", "NULL", ",", "array", "$", "args", "=", "NULL", ",", "&", "$", "errors", ")", "{", "$", "operations", "=", "[", "]", ";", "$", "fragments", "=", "[", "]", ";", "foreach", "(", "$", "ast", "->", "get", "(", "'definitions'", ")", "as", "$", "statement", ")", "{", "switch", "(", "$", "statement", "::", "KIND", ")", "{", "case", "Node", "::", "KIND_OPERATION_DEFINITION", ":", "$", "operations", "[", "$", "statement", "->", "get", "(", "'name'", ")", "?", "$", "statement", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ":", "''", "]", "=", "$", "statement", ";", "break", ";", "case", "Node", "::", "KIND_FRAGMENT_DEFINITION", ":", "$", "fragments", "[", "$", "statement", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", "]", "=", "$", "statement", ";", "break", ";", "}", "}", "if", "(", "!", "$", "operationName", "&&", "count", "(", "$", "operations", ")", "!==", "1", ")", "{", "throw", "new", "\\", "Exception", "(", "'Must provide operation name if query contains multiple operations'", ")", ";", "}", "$", "name", "=", "$", "operationName", "?", ":", "key", "(", "$", "operations", ")", ";", "if", "(", "!", "isset", "(", "$", "operations", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unknown operation name: '", ".", "$", "name", ")", ";", "}", "$", "operation", "=", "$", "operations", "[", "$", "name", "]", ";", "$", "variables", "=", "Values", "::", "getVariableValues", "(", "$", "schema", ",", "$", "operation", "->", "get", "(", "'variableDefinitions'", ")", "?", ":", "[", "]", ",", "$", "args", "?", ":", "[", "]", ")", ";", "$", "context", "=", "new", "ExecutionContext", "(", "$", "schema", ",", "$", "fragments", ",", "$", "root", ",", "$", "operation", ",", "$", "variables", ",", "$", "errors", ")", ";", "return", "$", "context", ";", "}" ]
Constructs a ExecutionContext object from the arguments passed to execute, which we will pass throughout the other execution methods. @param Schema $schema @param $root @param Document $ast @param string|null $operationName @param array $args @param $errors @return ExecutionContext @throws \Exception
[ "Constructs", "a", "ExecutionContext", "object", "from", "the", "arguments", "passed", "to", "execute", "which", "we", "will", "pass", "throughout", "the", "other", "execution", "methods", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L94-L125
17,304
fubhy/graphql-php
src/Executor/Executor.php
Executor.executeOperation
protected static function executeOperation(ExecutionContext $context, $root, OperationDefinition $operation) { $type = self::getOperationRootType($context->schema, $operation); $fields = self::collectFields($context, $type, $operation->get('selectionSet'), new \ArrayObject(), new \ArrayObject()); if ($operation->get('operation') === 'mutation') { return self::executeFieldsSerially($context, $type, $root, $fields->getArrayCopy()); } return self::executeFields($context, $type, $root, $fields); }
php
protected static function executeOperation(ExecutionContext $context, $root, OperationDefinition $operation) { $type = self::getOperationRootType($context->schema, $operation); $fields = self::collectFields($context, $type, $operation->get('selectionSet'), new \ArrayObject(), new \ArrayObject()); if ($operation->get('operation') === 'mutation') { return self::executeFieldsSerially($context, $type, $root, $fields->getArrayCopy()); } return self::executeFields($context, $type, $root, $fields); }
[ "protected", "static", "function", "executeOperation", "(", "ExecutionContext", "$", "context", ",", "$", "root", ",", "OperationDefinition", "$", "operation", ")", "{", "$", "type", "=", "self", "::", "getOperationRootType", "(", "$", "context", "->", "schema", ",", "$", "operation", ")", ";", "$", "fields", "=", "self", "::", "collectFields", "(", "$", "context", ",", "$", "type", ",", "$", "operation", "->", "get", "(", "'selectionSet'", ")", ",", "new", "\\", "ArrayObject", "(", ")", ",", "new", "\\", "ArrayObject", "(", ")", ")", ";", "if", "(", "$", "operation", "->", "get", "(", "'operation'", ")", "===", "'mutation'", ")", "{", "return", "self", "::", "executeFieldsSerially", "(", "$", "context", ",", "$", "type", ",", "$", "root", ",", "$", "fields", "->", "getArrayCopy", "(", ")", ")", ";", "}", "return", "self", "::", "executeFields", "(", "$", "context", ",", "$", "type", ",", "$", "root", ",", "$", "fields", ")", ";", "}" ]
Implements the "Evaluating operations" section of the spec.
[ "Implements", "the", "Evaluating", "operations", "section", "of", "the", "spec", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L130-L139
17,305
fubhy/graphql-php
src/Executor/Executor.php
Executor.getOperationRootType
protected static function getOperationRootType(Schema $schema, OperationDefinition $operation) { switch ($operation->get('operation')) { case 'query': return $schema->getQueryType(); case 'mutation': $mutationType = $schema->getMutationType(); if (!$mutationType) { throw new \Exception('Schema is not configured for mutations.'); } return $mutationType; } throw new \Exception('Can only execute queries and mutations.'); }
php
protected static function getOperationRootType(Schema $schema, OperationDefinition $operation) { switch ($operation->get('operation')) { case 'query': return $schema->getQueryType(); case 'mutation': $mutationType = $schema->getMutationType(); if (!$mutationType) { throw new \Exception('Schema is not configured for mutations.'); } return $mutationType; } throw new \Exception('Can only execute queries and mutations.'); }
[ "protected", "static", "function", "getOperationRootType", "(", "Schema", "$", "schema", ",", "OperationDefinition", "$", "operation", ")", "{", "switch", "(", "$", "operation", "->", "get", "(", "'operation'", ")", ")", "{", "case", "'query'", ":", "return", "$", "schema", "->", "getQueryType", "(", ")", ";", "case", "'mutation'", ":", "$", "mutationType", "=", "$", "schema", "->", "getMutationType", "(", ")", ";", "if", "(", "!", "$", "mutationType", ")", "{", "throw", "new", "\\", "Exception", "(", "'Schema is not configured for mutations.'", ")", ";", "}", "return", "$", "mutationType", ";", "}", "throw", "new", "\\", "Exception", "(", "'Can only execute queries and mutations.'", ")", ";", "}" ]
Extracts the root type of the operation from the schema. @param Schema $schema @param OperationDefinition $operation @return ObjectType @throws \Exception
[ "Extracts", "the", "root", "type", "of", "the", "operation", "from", "the", "schema", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L152-L167
17,306
fubhy/graphql-php
src/Executor/Executor.php
Executor.executeFieldsSerially
protected static function executeFieldsSerially(ExecutionContext $context, ObjectType $parent, $source, $fields) { $results = []; foreach ($fields as $response => $asts) { $result = self::resolveField($context, $parent, $source, $asts); if ($result !== self::$UNDEFINED) { // Undefined means that field is not defined in schema. $results[$response] = $result; } } return $results; }
php
protected static function executeFieldsSerially(ExecutionContext $context, ObjectType $parent, $source, $fields) { $results = []; foreach ($fields as $response => $asts) { $result = self::resolveField($context, $parent, $source, $asts); if ($result !== self::$UNDEFINED) { // Undefined means that field is not defined in schema. $results[$response] = $result; } } return $results; }
[ "protected", "static", "function", "executeFieldsSerially", "(", "ExecutionContext", "$", "context", ",", "ObjectType", "$", "parent", ",", "$", "source", ",", "$", "fields", ")", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "response", "=>", "$", "asts", ")", "{", "$", "result", "=", "self", "::", "resolveField", "(", "$", "context", ",", "$", "parent", ",", "$", "source", ",", "$", "asts", ")", ";", "if", "(", "$", "result", "!==", "self", "::", "$", "UNDEFINED", ")", "{", "// Undefined means that field is not defined in schema.", "$", "results", "[", "$", "response", "]", "=", "$", "result", ";", "}", "}", "return", "$", "results", ";", "}" ]
Implements the "Evaluating selection sets" section of the spec for "write" mode.
[ "Implements", "the", "Evaluating", "selection", "sets", "section", "of", "the", "spec", "for", "write", "mode", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L172-L185
17,307
fubhy/graphql-php
src/Executor/Executor.php
Executor.executeFields
protected static function executeFields(ExecutionContext $context, ObjectType $parent, $source, $fields) { return self::executeFieldsSerially($context, $parent, $source, $fields); }
php
protected static function executeFields(ExecutionContext $context, ObjectType $parent, $source, $fields) { return self::executeFieldsSerially($context, $parent, $source, $fields); }
[ "protected", "static", "function", "executeFields", "(", "ExecutionContext", "$", "context", ",", "ObjectType", "$", "parent", ",", "$", "source", ",", "$", "fields", ")", "{", "return", "self", "::", "executeFieldsSerially", "(", "$", "context", ",", "$", "parent", ",", "$", "source", ",", "$", "fields", ")", ";", "}" ]
Implements the "Evaluating selection sets" section of the spec for "read" mode. @param ExecutionContext $context @param ObjectType $parent @param $source @param $fields @return array
[ "Implements", "the", "Evaluating", "selection", "sets", "section", "of", "the", "spec", "for", "read", "mode", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L197-L200
17,308
fubhy/graphql-php
src/Executor/Executor.php
Executor.collectFields
protected static function collectFields(ExecutionContext $context, ObjectType $type, SelectionSet $set, $fields, $visited) { $count = count($set->get('selections')); for ($i = 0; $i < $count; $i++) { $selection = $set->get('selections')[$i]; switch ($selection::KIND) { case Node::KIND_FIELD: if (!self::shouldIncludeNode($context, $selection->get('directives'))) { continue; } $name = self::getFieldEntryKey($selection); if (!isset($fields[$name])) { $fields[$name] = new \ArrayObject(); } $fields[$name][] = $selection; break; case Node::KIND_INLINE_FRAGMENT: if (!self::shouldIncludeNode($context, $selection->get('directives')) || !self::doesFragmentConditionMatch($context, $selection, $type)) { continue; } self::collectFields( $context, $type, $selection->get('selectionSet'), $fields, $visited ); break; case Node::KIND_FRAGMENT_SPREAD: $fragName = $selection->get('name')->get('value'); if (!empty($visited[$fragName]) || !self::shouldIncludeNode($context, $selection->get('directives'))) { continue; } $visited[$fragName] = TRUE; $fragment = isset($context->fragments[$fragName]) ? $context->fragments[$fragName] : NULL; if (!$fragment || !self::shouldIncludeNode($context, $fragment->get('directives')) || !self::doesFragmentConditionMatch($context, $fragment, $type)) { continue; } self::collectFields($context, $type, $fragment->get('selectionSet'), $fields, $visited); break; } } return $fields; }
php
protected static function collectFields(ExecutionContext $context, ObjectType $type, SelectionSet $set, $fields, $visited) { $count = count($set->get('selections')); for ($i = 0; $i < $count; $i++) { $selection = $set->get('selections')[$i]; switch ($selection::KIND) { case Node::KIND_FIELD: if (!self::shouldIncludeNode($context, $selection->get('directives'))) { continue; } $name = self::getFieldEntryKey($selection); if (!isset($fields[$name])) { $fields[$name] = new \ArrayObject(); } $fields[$name][] = $selection; break; case Node::KIND_INLINE_FRAGMENT: if (!self::shouldIncludeNode($context, $selection->get('directives')) || !self::doesFragmentConditionMatch($context, $selection, $type)) { continue; } self::collectFields( $context, $type, $selection->get('selectionSet'), $fields, $visited ); break; case Node::KIND_FRAGMENT_SPREAD: $fragName = $selection->get('name')->get('value'); if (!empty($visited[$fragName]) || !self::shouldIncludeNode($context, $selection->get('directives'))) { continue; } $visited[$fragName] = TRUE; $fragment = isset($context->fragments[$fragName]) ? $context->fragments[$fragName] : NULL; if (!$fragment || !self::shouldIncludeNode($context, $fragment->get('directives')) || !self::doesFragmentConditionMatch($context, $fragment, $type)) { continue; } self::collectFields($context, $type, $fragment->get('selectionSet'), $fields, $visited); break; } } return $fields; }
[ "protected", "static", "function", "collectFields", "(", "ExecutionContext", "$", "context", ",", "ObjectType", "$", "type", ",", "SelectionSet", "$", "set", ",", "$", "fields", ",", "$", "visited", ")", "{", "$", "count", "=", "count", "(", "$", "set", "->", "get", "(", "'selections'", ")", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "selection", "=", "$", "set", "->", "get", "(", "'selections'", ")", "[", "$", "i", "]", ";", "switch", "(", "$", "selection", "::", "KIND", ")", "{", "case", "Node", "::", "KIND_FIELD", ":", "if", "(", "!", "self", "::", "shouldIncludeNode", "(", "$", "context", ",", "$", "selection", "->", "get", "(", "'directives'", ")", ")", ")", "{", "continue", ";", "}", "$", "name", "=", "self", "::", "getFieldEntryKey", "(", "$", "selection", ")", ";", "if", "(", "!", "isset", "(", "$", "fields", "[", "$", "name", "]", ")", ")", "{", "$", "fields", "[", "$", "name", "]", "=", "new", "\\", "ArrayObject", "(", ")", ";", "}", "$", "fields", "[", "$", "name", "]", "[", "]", "=", "$", "selection", ";", "break", ";", "case", "Node", "::", "KIND_INLINE_FRAGMENT", ":", "if", "(", "!", "self", "::", "shouldIncludeNode", "(", "$", "context", ",", "$", "selection", "->", "get", "(", "'directives'", ")", ")", "||", "!", "self", "::", "doesFragmentConditionMatch", "(", "$", "context", ",", "$", "selection", ",", "$", "type", ")", ")", "{", "continue", ";", "}", "self", "::", "collectFields", "(", "$", "context", ",", "$", "type", ",", "$", "selection", "->", "get", "(", "'selectionSet'", ")", ",", "$", "fields", ",", "$", "visited", ")", ";", "break", ";", "case", "Node", "::", "KIND_FRAGMENT_SPREAD", ":", "$", "fragName", "=", "$", "selection", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ";", "if", "(", "!", "empty", "(", "$", "visited", "[", "$", "fragName", "]", ")", "||", "!", "self", "::", "shouldIncludeNode", "(", "$", "context", ",", "$", "selection", "->", "get", "(", "'directives'", ")", ")", ")", "{", "continue", ";", "}", "$", "visited", "[", "$", "fragName", "]", "=", "TRUE", ";", "$", "fragment", "=", "isset", "(", "$", "context", "->", "fragments", "[", "$", "fragName", "]", ")", "?", "$", "context", "->", "fragments", "[", "$", "fragName", "]", ":", "NULL", ";", "if", "(", "!", "$", "fragment", "||", "!", "self", "::", "shouldIncludeNode", "(", "$", "context", ",", "$", "fragment", "->", "get", "(", "'directives'", ")", ")", "||", "!", "self", "::", "doesFragmentConditionMatch", "(", "$", "context", ",", "$", "fragment", ",", "$", "type", ")", ")", "{", "continue", ";", "}", "self", "::", "collectFields", "(", "$", "context", ",", "$", "type", ",", "$", "fragment", "->", "get", "(", "'selectionSet'", ")", ",", "$", "fields", ",", "$", "visited", ")", ";", "break", ";", "}", "}", "return", "$", "fields", ";", "}" ]
Given a selectionSet, adds all of the fields in that selection to the passed in map of fields, and returns it at the end. @param ExecutionContext $context @param ObjectType $type @param SelectionSet $set @param $fields @param $visited @return \ArrayObject
[ "Given", "a", "selectionSet", "adds", "all", "of", "the", "fields", "in", "that", "selection", "to", "the", "passed", "in", "map", "of", "fields", "and", "returns", "it", "at", "the", "end", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L214-L267
17,309
fubhy/graphql-php
src/Executor/Executor.php
Executor.shouldIncludeNode
protected static function shouldIncludeNode(ExecutionContext $exeContext, $directives) { $skip = Directive::skipDirective(); $include = Directive::includeDirective(); foreach ($directives as $directive) { if ($directive->get('name')->get('value') === $skip->getName()) { $values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables); return empty($values['if']); } if ($directive->get('name')->get('value') === $include->getName()) { $values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables); return !empty($values['if']); } } return TRUE; }
php
protected static function shouldIncludeNode(ExecutionContext $exeContext, $directives) { $skip = Directive::skipDirective(); $include = Directive::includeDirective(); foreach ($directives as $directive) { if ($directive->get('name')->get('value') === $skip->getName()) { $values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables); return empty($values['if']); } if ($directive->get('name')->get('value') === $include->getName()) { $values = Values::getArgumentValues($skip->getArguments(), $directive->get('arguments'), $exeContext->variables); return !empty($values['if']); } } return TRUE; }
[ "protected", "static", "function", "shouldIncludeNode", "(", "ExecutionContext", "$", "exeContext", ",", "$", "directives", ")", "{", "$", "skip", "=", "Directive", "::", "skipDirective", "(", ")", ";", "$", "include", "=", "Directive", "::", "includeDirective", "(", ")", ";", "foreach", "(", "$", "directives", "as", "$", "directive", ")", "{", "if", "(", "$", "directive", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", "===", "$", "skip", "->", "getName", "(", ")", ")", "{", "$", "values", "=", "Values", "::", "getArgumentValues", "(", "$", "skip", "->", "getArguments", "(", ")", ",", "$", "directive", "->", "get", "(", "'arguments'", ")", ",", "$", "exeContext", "->", "variables", ")", ";", "return", "empty", "(", "$", "values", "[", "'if'", "]", ")", ";", "}", "if", "(", "$", "directive", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", "===", "$", "include", "->", "getName", "(", ")", ")", "{", "$", "values", "=", "Values", "::", "getArgumentValues", "(", "$", "skip", "->", "getArguments", "(", ")", ",", "$", "directive", "->", "get", "(", "'arguments'", ")", ",", "$", "exeContext", "->", "variables", ")", ";", "return", "!", "empty", "(", "$", "values", "[", "'if'", "]", ")", ";", "}", "}", "return", "TRUE", ";", "}" ]
Determines if a field should be included based on @if and @unless directives.
[ "Determines", "if", "a", "field", "should", "be", "included", "based", "on" ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L272-L290
17,310
fubhy/graphql-php
src/Executor/Executor.php
Executor.doesFragmentConditionMatch
protected static function doesFragmentConditionMatch(ExecutionContext $context, $fragment, ObjectType $type) { $typeCondition = $fragment->get('typeCondition'); if (!$typeCondition) { return TRUE; } $conditionalType = TypeInfo::typeFromAST($context->schema, $typeCondition); if ($conditionalType->getName() === $type->getName()) { return TRUE; } if ($conditionalType instanceof InterfaceType || $conditionalType instanceof UnionType) { return $conditionalType->isPossibleType($type); } return FALSE; }
php
protected static function doesFragmentConditionMatch(ExecutionContext $context, $fragment, ObjectType $type) { $typeCondition = $fragment->get('typeCondition'); if (!$typeCondition) { return TRUE; } $conditionalType = TypeInfo::typeFromAST($context->schema, $typeCondition); if ($conditionalType->getName() === $type->getName()) { return TRUE; } if ($conditionalType instanceof InterfaceType || $conditionalType instanceof UnionType) { return $conditionalType->isPossibleType($type); } return FALSE; }
[ "protected", "static", "function", "doesFragmentConditionMatch", "(", "ExecutionContext", "$", "context", ",", "$", "fragment", ",", "ObjectType", "$", "type", ")", "{", "$", "typeCondition", "=", "$", "fragment", "->", "get", "(", "'typeCondition'", ")", ";", "if", "(", "!", "$", "typeCondition", ")", "{", "return", "TRUE", ";", "}", "$", "conditionalType", "=", "TypeInfo", "::", "typeFromAST", "(", "$", "context", "->", "schema", ",", "$", "typeCondition", ")", ";", "if", "(", "$", "conditionalType", "->", "getName", "(", ")", "===", "$", "type", "->", "getName", "(", ")", ")", "{", "return", "TRUE", ";", "}", "if", "(", "$", "conditionalType", "instanceof", "InterfaceType", "||", "$", "conditionalType", "instanceof", "UnionType", ")", "{", "return", "$", "conditionalType", "->", "isPossibleType", "(", "$", "type", ")", ";", "}", "return", "FALSE", ";", "}" ]
Determines if a fragment is applicable to the given type. @param ExecutionContext $context @param $fragment @param ObjectType $type @return bool
[ "Determines", "if", "a", "fragment", "is", "applicable", "to", "the", "given", "type", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L301-L318
17,311
fubhy/graphql-php
src/Executor/Executor.php
Executor.getFieldEntryKey
protected static function getFieldEntryKey(Field $node) { return $node->get('alias') ? $node->get('alias')->get('value') : $node->get('name')->get('value'); }
php
protected static function getFieldEntryKey(Field $node) { return $node->get('alias') ? $node->get('alias')->get('value') : $node->get('name')->get('value'); }
[ "protected", "static", "function", "getFieldEntryKey", "(", "Field", "$", "node", ")", "{", "return", "$", "node", "->", "get", "(", "'alias'", ")", "?", "$", "node", "->", "get", "(", "'alias'", ")", "->", "get", "(", "'value'", ")", ":", "$", "node", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ";", "}" ]
Implements the logic to compute the key of a given field's entry @param Field $node @return string
[ "Implements", "the", "logic", "to", "compute", "the", "key", "of", "a", "given", "field", "s", "entry" ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L327-L330
17,312
fubhy/graphql-php
src/Executor/Executor.php
Executor.resolveField
protected static function resolveField(ExecutionContext $context, ObjectType $parent, $source, $asts) { $definition = self::getFieldDefinition($context->schema, $parent, $asts[0]); if (!$definition) { return self::$UNDEFINED; } // If the field type is non-nullable, then it is resolved without any // protection from errors. if ($definition->getType() instanceof NonNullModifier) { return self::resolveFieldOrError($context, $parent, $source, $asts, $definition); } // Otherwise, error protection is applied, logging the error and // resolving a null value for this field if one is encountered. try { $result = self::resolveFieldOrError($context, $parent, $source, $asts, $definition); return $result; } catch (\Exception $error) { $context->errors[] = $error; return NULL; } }
php
protected static function resolveField(ExecutionContext $context, ObjectType $parent, $source, $asts) { $definition = self::getFieldDefinition($context->schema, $parent, $asts[0]); if (!$definition) { return self::$UNDEFINED; } // If the field type is non-nullable, then it is resolved without any // protection from errors. if ($definition->getType() instanceof NonNullModifier) { return self::resolveFieldOrError($context, $parent, $source, $asts, $definition); } // Otherwise, error protection is applied, logging the error and // resolving a null value for this field if one is encountered. try { $result = self::resolveFieldOrError($context, $parent, $source, $asts, $definition); return $result; } catch (\Exception $error) { $context->errors[] = $error; return NULL; } }
[ "protected", "static", "function", "resolveField", "(", "ExecutionContext", "$", "context", ",", "ObjectType", "$", "parent", ",", "$", "source", ",", "$", "asts", ")", "{", "$", "definition", "=", "self", "::", "getFieldDefinition", "(", "$", "context", "->", "schema", ",", "$", "parent", ",", "$", "asts", "[", "0", "]", ")", ";", "if", "(", "!", "$", "definition", ")", "{", "return", "self", "::", "$", "UNDEFINED", ";", "}", "// If the field type is non-nullable, then it is resolved without any", "// protection from errors.", "if", "(", "$", "definition", "->", "getType", "(", ")", "instanceof", "NonNullModifier", ")", "{", "return", "self", "::", "resolveFieldOrError", "(", "$", "context", ",", "$", "parent", ",", "$", "source", ",", "$", "asts", ",", "$", "definition", ")", ";", "}", "// Otherwise, error protection is applied, logging the error and", "// resolving a null value for this field if one is encountered.", "try", "{", "$", "result", "=", "self", "::", "resolveFieldOrError", "(", "$", "context", ",", "$", "parent", ",", "$", "source", ",", "$", "asts", ",", "$", "definition", ")", ";", "return", "$", "result", ";", "}", "catch", "(", "\\", "Exception", "$", "error", ")", "{", "$", "context", "->", "errors", "[", "]", "=", "$", "error", ";", "return", "NULL", ";", "}", "}" ]
A wrapper function for resolving the field, that catches the error and adds it to the context's global if the error is not rethrowable. @param ExecutionContext $context @param ObjectType $parent @param $source @param $asts @return array|mixed|null|string @throws \Exception
[ "A", "wrapper", "function", "for", "resolving", "the", "field", "that", "catches", "the", "error", "and", "adds", "it", "to", "the", "context", "s", "global", "if", "the", "error", "is", "not", "rethrowable", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L345-L367
17,313
fubhy/graphql-php
src/Executor/Executor.php
Executor.resolveFieldOrError
protected static function resolveFieldOrError(ExecutionContext $context, ObjectType $parent, $source, $asts, FieldDefinition $definition) { $ast = $asts[0]; $type = $definition->getType(); $resolver = $definition->getResolveCallback() ?: [__CLASS__, 'defaultResolveFn']; $data = $definition->getResolveData(); $args = Values::getArgumentValues($definition->getArguments(), $ast->get('arguments'), $context->variables); try { // @todo Change the resolver function syntax to use a value object. $result = call_user_func($resolver, $source, $args, $context->root, $ast, $type, $parent, $context->schema, $data); } catch (\Exception $error) { throw $error; } return self::completeField($context, $type, $asts, $result); }
php
protected static function resolveFieldOrError(ExecutionContext $context, ObjectType $parent, $source, $asts, FieldDefinition $definition) { $ast = $asts[0]; $type = $definition->getType(); $resolver = $definition->getResolveCallback() ?: [__CLASS__, 'defaultResolveFn']; $data = $definition->getResolveData(); $args = Values::getArgumentValues($definition->getArguments(), $ast->get('arguments'), $context->variables); try { // @todo Change the resolver function syntax to use a value object. $result = call_user_func($resolver, $source, $args, $context->root, $ast, $type, $parent, $context->schema, $data); } catch (\Exception $error) { throw $error; } return self::completeField($context, $type, $asts, $result); }
[ "protected", "static", "function", "resolveFieldOrError", "(", "ExecutionContext", "$", "context", ",", "ObjectType", "$", "parent", ",", "$", "source", ",", "$", "asts", ",", "FieldDefinition", "$", "definition", ")", "{", "$", "ast", "=", "$", "asts", "[", "0", "]", ";", "$", "type", "=", "$", "definition", "->", "getType", "(", ")", ";", "$", "resolver", "=", "$", "definition", "->", "getResolveCallback", "(", ")", "?", ":", "[", "__CLASS__", ",", "'defaultResolveFn'", "]", ";", "$", "data", "=", "$", "definition", "->", "getResolveData", "(", ")", ";", "$", "args", "=", "Values", "::", "getArgumentValues", "(", "$", "definition", "->", "getArguments", "(", ")", ",", "$", "ast", "->", "get", "(", "'arguments'", ")", ",", "$", "context", "->", "variables", ")", ";", "try", "{", "// @todo Change the resolver function syntax to use a value object.", "$", "result", "=", "call_user_func", "(", "$", "resolver", ",", "$", "source", ",", "$", "args", ",", "$", "context", "->", "root", ",", "$", "ast", ",", "$", "type", ",", "$", "parent", ",", "$", "context", "->", "schema", ",", "$", "data", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "error", ")", "{", "throw", "$", "error", ";", "}", "return", "self", "::", "completeField", "(", "$", "context", ",", "$", "type", ",", "$", "asts", ",", "$", "result", ")", ";", "}" ]
Resolves the field on the given source object. In particular, this figures out the object that the field returns using the resolve function, then calls completeField to coerce scalars or execute the sub selection set for objects. @param ExecutionContext $context @param ObjectType $parent @param $source @param $asts @param FieldDefinition $definition @return array|mixed|null|string @throws \Exception
[ "Resolves", "the", "field", "on", "the", "given", "source", "object", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L386-L402
17,314
fubhy/graphql-php
src/Executor/Executor.php
Executor.defaultResolveFn
public static function defaultResolveFn($source, $args, $root, $ast) { $property = NULL; $key = $ast->get('name')->get('value'); if ((is_array($source) || $source instanceof \ArrayAccess) && isset($source[$key])) { $property = $source[$key]; } else if (is_object($source) && property_exists($source, $key)) { if ($key !== 'ofType') { $property = $source->{$key}; } } return is_callable($property) ? call_user_func($property, $source) : $property; }
php
public static function defaultResolveFn($source, $args, $root, $ast) { $property = NULL; $key = $ast->get('name')->get('value'); if ((is_array($source) || $source instanceof \ArrayAccess) && isset($source[$key])) { $property = $source[$key]; } else if (is_object($source) && property_exists($source, $key)) { if ($key !== 'ofType') { $property = $source->{$key}; } } return is_callable($property) ? call_user_func($property, $source) : $property; }
[ "public", "static", "function", "defaultResolveFn", "(", "$", "source", ",", "$", "args", ",", "$", "root", ",", "$", "ast", ")", "{", "$", "property", "=", "NULL", ";", "$", "key", "=", "$", "ast", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ";", "if", "(", "(", "is_array", "(", "$", "source", ")", "||", "$", "source", "instanceof", "\\", "ArrayAccess", ")", "&&", "isset", "(", "$", "source", "[", "$", "key", "]", ")", ")", "{", "$", "property", "=", "$", "source", "[", "$", "key", "]", ";", "}", "else", "if", "(", "is_object", "(", "$", "source", ")", "&&", "property_exists", "(", "$", "source", ",", "$", "key", ")", ")", "{", "if", "(", "$", "key", "!==", "'ofType'", ")", "{", "$", "property", "=", "$", "source", "->", "{", "$", "key", "}", ";", "}", "}", "return", "is_callable", "(", "$", "property", ")", "?", "call_user_func", "(", "$", "property", ",", "$", "source", ")", ":", "$", "property", ";", "}" ]
If a resolve function is not given, then a default resolve behavior is used which takes the property of the source object of the same name as the field and returns it as the result, or if it's a function, returns the result of calling that function. @param $source @param $args @param $root @param $ast @return mixed|null
[ "If", "a", "resolve", "function", "is", "not", "given", "then", "a", "default", "resolve", "behavior", "is", "used", "which", "takes", "the", "property", "of", "the", "source", "object", "of", "the", "same", "name", "as", "the", "field", "and", "returns", "it", "as", "the", "result", "or", "if", "it", "s", "a", "function", "returns", "the", "result", "of", "calling", "that", "function", "." ]
c1de2233c731ca29e5c5db4c43f3b9db36478c83
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Executor.php#L511-L526
17,315
jinexus-framework/jinexus-mvc
src/View/AbstractView.php
AbstractView.htmlEncode
public function htmlEncode($data) { switch (gettype($data)) { case 'array': foreach ($data as $key => $value) { $data[$key] = $this->htmlEncode($value); } break; case 'object': $data = clone $data; foreach ($data as $key => $value) { $data->$key = $this->htmlEncode($value); } break; case 'string': default: $data = htmlentities($data, ENT_QUOTES, 'UTF-8'); break; } return $data; }
php
public function htmlEncode($data) { switch (gettype($data)) { case 'array': foreach ($data as $key => $value) { $data[$key] = $this->htmlEncode($value); } break; case 'object': $data = clone $data; foreach ($data as $key => $value) { $data->$key = $this->htmlEncode($value); } break; case 'string': default: $data = htmlentities($data, ENT_QUOTES, 'UTF-8'); break; } return $data; }
[ "public", "function", "htmlEncode", "(", "$", "data", ")", "{", "switch", "(", "gettype", "(", "$", "data", ")", ")", "{", "case", "'array'", ":", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "htmlEncode", "(", "$", "value", ")", ";", "}", "break", ";", "case", "'object'", ":", "$", "data", "=", "clone", "$", "data", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data", "->", "$", "key", "=", "$", "this", "->", "htmlEncode", "(", "$", "value", ")", ";", "}", "break", ";", "case", "'string'", ":", "default", ":", "$", "data", "=", "htmlentities", "(", "$", "data", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ";", "break", ";", "}", "return", "$", "data", ";", "}" ]
Recursively make a value safe for HTML @param mixed $data @return mixed
[ "Recursively", "make", "a", "value", "safe", "for", "HTML" ]
63937fecea4bc927b1ac9669fee5cf50278d28d3
https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L152-L177
17,316
jinexus-framework/jinexus-mvc
src/View/AbstractView.php
AbstractView.htmlDecode
public function htmlDecode($data) { switch (gettype($data)) { case 'array': foreach ($data as $key => $value) { $data[$key] = $this->htmlDecode($value); } break; case 'object': $data = clone $data; foreach ($data as $key => $value) { $data->$key = $this->htmlDecode($value); } break; case 'string': default: $data = html_entity_decode($data, ENT_QUOTES, 'UTF-8'); break; } return $data; }
php
public function htmlDecode($data) { switch (gettype($data)) { case 'array': foreach ($data as $key => $value) { $data[$key] = $this->htmlDecode($value); } break; case 'object': $data = clone $data; foreach ($data as $key => $value) { $data->$key = $this->htmlDecode($value); } break; case 'string': default: $data = html_entity_decode($data, ENT_QUOTES, 'UTF-8'); break; } return $data; }
[ "public", "function", "htmlDecode", "(", "$", "data", ")", "{", "switch", "(", "gettype", "(", "$", "data", ")", ")", "{", "case", "'array'", ":", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "htmlDecode", "(", "$", "value", ")", ";", "}", "break", ";", "case", "'object'", ":", "$", "data", "=", "clone", "$", "data", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data", "->", "$", "key", "=", "$", "this", "->", "htmlDecode", "(", "$", "value", ")", ";", "}", "break", ";", "case", "'string'", ":", "default", ":", "$", "data", "=", "html_entity_decode", "(", "$", "data", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ";", "break", ";", "}", "return", "$", "data", ";", "}" ]
Recursively decode an HTML encoded value @param mixed $data @return mixed
[ "Recursively", "decode", "an", "HTML", "encoded", "value" ]
63937fecea4bc927b1ac9669fee5cf50278d28d3
https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L185-L210
17,317
jinexus-framework/jinexus-mvc
src/View/AbstractView.php
AbstractView.get
public function get($variable, $htmlEncode = true) { $value = null; if ( isset($this->variables[$variable]) ) { $value = $this->variables[$variable][$htmlEncode ? 'safe' : 'unsafe']; } return $value; }
php
public function get($variable, $htmlEncode = true) { $value = null; if ( isset($this->variables[$variable]) ) { $value = $this->variables[$variable][$htmlEncode ? 'safe' : 'unsafe']; } return $value; }
[ "public", "function", "get", "(", "$", "variable", ",", "$", "htmlEncode", "=", "true", ")", "{", "$", "value", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "variables", "[", "$", "variable", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "variables", "[", "$", "variable", "]", "[", "$", "htmlEncode", "?", "'safe'", ":", "'unsafe'", "]", ";", "}", "return", "$", "value", ";", "}" ]
Get a view variable @param string $variable @param bool $htmlEncode @return mixed|null
[ "Get", "a", "view", "variable" ]
63937fecea4bc927b1ac9669fee5cf50278d28d3
https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L219-L228
17,318
jinexus-framework/jinexus-mvc
src/View/AbstractView.php
AbstractView.set
public function set($variable, $value = null) { $this->variables[$variable] = array( 'safe' => $this->htmlEncode($value), 'unsafe' => $value ); return $this; }
php
public function set($variable, $value = null) { $this->variables[$variable] = array( 'safe' => $this->htmlEncode($value), 'unsafe' => $value ); return $this; }
[ "public", "function", "set", "(", "$", "variable", ",", "$", "value", "=", "null", ")", "{", "$", "this", "->", "variables", "[", "$", "variable", "]", "=", "array", "(", "'safe'", "=>", "$", "this", "->", "htmlEncode", "(", "$", "value", ")", ",", "'unsafe'", "=>", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Set a view variable @param string $variable @param mixed $value @return \JiNexus\Mvc\View\ViewInterface
[ "Set", "a", "view", "variable" ]
63937fecea4bc927b1ac9669fee5cf50278d28d3
https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L247-L255
17,319
jinexus-framework/jinexus-mvc
src/View/AbstractView.php
AbstractView.setVariables
public function setVariables($variables = []) { foreach ($variables as $variable => $value) { $this->set($variable, $value); } }
php
public function setVariables($variables = []) { foreach ($variables as $variable => $value) { $this->set($variable, $value); } }
[ "public", "function", "setVariables", "(", "$", "variables", "=", "[", "]", ")", "{", "foreach", "(", "$", "variables", "as", "$", "variable", "=>", "$", "value", ")", "{", "$", "this", "->", "set", "(", "$", "variable", ",", "$", "value", ")", ";", "}", "}" ]
Set all variables @param array $variables
[ "Set", "all", "variables" ]
63937fecea4bc927b1ac9669fee5cf50278d28d3
https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L262-L267
17,320
jinexus-framework/jinexus-mvc
src/View/AbstractView.php
AbstractView.render
public function render($file = '') { $viewManager = $this->config->get('view_manager'); if ($viewManager['template_path_stack']) { $file = $viewManager['template_path_stack'] . '/' . $file; } $fileInfo = pathinfo($file); if (! isset($fileInfo['extension']) || $fileInfo['extension'] != 'phtml') { $file = $file . '.phtml'; } if (is_file($file)) { if (! headers_sent()) { header('X-Generator: JiNexus Framework'); } ob_start(); include $file; ob_end_flush(); } else { throw new Exception('View not found'); } }
php
public function render($file = '') { $viewManager = $this->config->get('view_manager'); if ($viewManager['template_path_stack']) { $file = $viewManager['template_path_stack'] . '/' . $file; } $fileInfo = pathinfo($file); if (! isset($fileInfo['extension']) || $fileInfo['extension'] != 'phtml') { $file = $file . '.phtml'; } if (is_file($file)) { if (! headers_sent()) { header('X-Generator: JiNexus Framework'); } ob_start(); include $file; ob_end_flush(); } else { throw new Exception('View not found'); } }
[ "public", "function", "render", "(", "$", "file", "=", "''", ")", "{", "$", "viewManager", "=", "$", "this", "->", "config", "->", "get", "(", "'view_manager'", ")", ";", "if", "(", "$", "viewManager", "[", "'template_path_stack'", "]", ")", "{", "$", "file", "=", "$", "viewManager", "[", "'template_path_stack'", "]", ".", "'/'", ".", "$", "file", ";", "}", "$", "fileInfo", "=", "pathinfo", "(", "$", "file", ")", ";", "if", "(", "!", "isset", "(", "$", "fileInfo", "[", "'extension'", "]", ")", "||", "$", "fileInfo", "[", "'extension'", "]", "!=", "'phtml'", ")", "{", "$", "file", "=", "$", "file", ".", "'.phtml'", ";", "}", "if", "(", "is_file", "(", "$", "file", ")", ")", "{", "if", "(", "!", "headers_sent", "(", ")", ")", "{", "header", "(", "'X-Generator: JiNexus Framework'", ")", ";", "}", "ob_start", "(", ")", ";", "include", "$", "file", ";", "ob_end_flush", "(", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'View not found'", ")", ";", "}", "}" ]
Render a file @param string $file @throws Exception
[ "Render", "a", "file" ]
63937fecea4bc927b1ac9669fee5cf50278d28d3
https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/View/AbstractView.php#L275-L299
17,321
controlabs/routify
src/Routify/RouteGroup.php
RouteGroup.path
public function path() { $clean = function($v) { return str_replace('/', '', $v); }; return join( '/', array_map($clean, $this->groups) ); }
php
public function path() { $clean = function($v) { return str_replace('/', '', $v); }; return join( '/', array_map($clean, $this->groups) ); }
[ "public", "function", "path", "(", ")", "{", "$", "clean", "=", "function", "(", "$", "v", ")", "{", "return", "str_replace", "(", "'/'", ",", "''", ",", "$", "v", ")", ";", "}", ";", "return", "join", "(", "'/'", ",", "array_map", "(", "$", "clean", ",", "$", "this", "->", "groups", ")", ")", ";", "}" ]
Returns a complete path @return string
[ "Returns", "a", "complete", "path" ]
a4e92000fc61ddc7f297984ef9924b6d9df508a4
https://github.com/controlabs/routify/blob/a4e92000fc61ddc7f297984ef9924b6d9df508a4/src/Routify/RouteGroup.php#L41-L51
17,322
webforge-labs/psc-cms
lib/Psc/DependencyManager.php
DependencyManager.unregister
public function unregister($alias) { // unregister unset($this->files[$alias]); // aus queued entfernen $key = array_search($alias, $this->enqueued); if ($key !== FALSE) { unset($this->enqueued[$key]); } return $this; }
php
public function unregister($alias) { // unregister unset($this->files[$alias]); // aus queued entfernen $key = array_search($alias, $this->enqueued); if ($key !== FALSE) { unset($this->enqueued[$key]); } return $this; }
[ "public", "function", "unregister", "(", "$", "alias", ")", "{", "// unregister", "unset", "(", "$", "this", "->", "files", "[", "$", "alias", "]", ")", ";", "// aus queued entfernen", "$", "key", "=", "array_search", "(", "$", "alias", ",", "$", "this", "->", "enqueued", ")", ";", "if", "(", "$", "key", "!==", "FALSE", ")", "{", "unset", "(", "$", "this", "->", "enqueued", "[", "$", "key", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Entfernt eine registrierte Datei @param string $alias wie bei register() angegeben
[ "Entfernt", "eine", "registrierte", "Datei" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DependencyManager.php#L108-L118
17,323
ClanCats/Core
src/bundles/UI/Form.php
Form.start
public static function start( $key, $attr = array() ) { $attributes = array(); // force the form role $attributes['role'] = 'form'; if ( !is_null( $key ) ) { static::$id_prefix = $attributes['id'] = static::form_id( 'form', $key ); } $attributes = array_merge( $attributes, $attr ); return '<form'.HTML::attr( $attributes ).'>'; }
php
public static function start( $key, $attr = array() ) { $attributes = array(); // force the form role $attributes['role'] = 'form'; if ( !is_null( $key ) ) { static::$id_prefix = $attributes['id'] = static::form_id( 'form', $key ); } $attributes = array_merge( $attributes, $attr ); return '<form'.HTML::attr( $attributes ).'>'; }
[ "public", "static", "function", "start", "(", "$", "key", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "// force the form role", "$", "attributes", "[", "'role'", "]", "=", "'form'", ";", "if", "(", "!", "is_null", "(", "$", "key", ")", ")", "{", "static", "::", "$", "id_prefix", "=", "$", "attributes", "[", "'id'", "]", "=", "static", "::", "form_id", "(", "'form'", ",", "$", "key", ")", ";", "}", "$", "attributes", "=", "array_merge", "(", "$", "attributes", ",", "$", "attr", ")", ";", "return", "'<form'", ".", "HTML", "::", "attr", "(", "$", "attributes", ")", ".", "'>'", ";", "}" ]
Open a new form This will set the current form to this one @param string $key @param array $attr @return string
[ "Open", "a", "new", "form", "This", "will", "set", "the", "current", "form", "to", "this", "one" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L64-L79
17,324
ClanCats/Core
src/bundles/UI/Form.php
Form.capture
public static function capture( $callback = null, $key = null, $attr = null ) { // we got some dynamics in the parameters here so in case // of this shift stuff if ( is_callable( $attr ) && !is_callable( $callback ) ) { $new_attr = $key; $key = $callback; $callback = $attr; $attr = $new_attr; } $form = new static; if ( is_null( $callback ) ) { throw new Exception( 'Cannot use capture without a callback or string given.' ); } // fix no array given if ( !is_array( $attr ) ) { $attr = array(); } return static::start( $key, $attr ).\CCStr::capture( $callback, array( $form ) ).static::end(); }
php
public static function capture( $callback = null, $key = null, $attr = null ) { // we got some dynamics in the parameters here so in case // of this shift stuff if ( is_callable( $attr ) && !is_callable( $callback ) ) { $new_attr = $key; $key = $callback; $callback = $attr; $attr = $new_attr; } $form = new static; if ( is_null( $callback ) ) { throw new Exception( 'Cannot use capture without a callback or string given.' ); } // fix no array given if ( !is_array( $attr ) ) { $attr = array(); } return static::start( $key, $attr ).\CCStr::capture( $callback, array( $form ) ).static::end(); }
[ "public", "static", "function", "capture", "(", "$", "callback", "=", "null", ",", "$", "key", "=", "null", ",", "$", "attr", "=", "null", ")", "{", "// we got some dynamics in the parameters here so in case", "// of this shift stuff", "if", "(", "is_callable", "(", "$", "attr", ")", "&&", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "new_attr", "=", "$", "key", ";", "$", "key", "=", "$", "callback", ";", "$", "callback", "=", "$", "attr", ";", "$", "attr", "=", "$", "new_attr", ";", "}", "$", "form", "=", "new", "static", ";", "if", "(", "is_null", "(", "$", "callback", ")", ")", "{", "throw", "new", "Exception", "(", "'Cannot use capture without a callback or string given.'", ")", ";", "}", "// fix no array given", "if", "(", "!", "is_array", "(", "$", "attr", ")", ")", "{", "$", "attr", "=", "array", "(", ")", ";", "}", "return", "static", "::", "start", "(", "$", "key", ",", "$", "attr", ")", ".", "\\", "CCStr", "::", "capture", "(", "$", "callback", ",", "array", "(", "$", "form", ")", ")", ".", "static", "::", "end", "(", ")", ";", "}" ]
Create a new from instance @param callback $callback @param string $key The form key used for identification. @param array $attr The form dom attributes. @return UI\Form
[ "Create", "a", "new", "from", "instance" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L101-L127
17,325
ClanCats/Core
src/bundles/UI/Form.php
Form.build_id
public static function build_id( $type, $name ) { if ( !is_null( static::$id_prefix ) ) { return static::$id_prefix.'-'.static::form_id( $type, $name ); } return static::form_id( $type, $name ); }
php
public static function build_id( $type, $name ) { if ( !is_null( static::$id_prefix ) ) { return static::$id_prefix.'-'.static::form_id( $type, $name ); } return static::form_id( $type, $name ); }
[ "public", "static", "function", "build_id", "(", "$", "type", ",", "$", "name", ")", "{", "if", "(", "!", "is_null", "(", "static", "::", "$", "id_prefix", ")", ")", "{", "return", "static", "::", "$", "id_prefix", ".", "'-'", ".", "static", "::", "form_id", "(", "$", "type", ",", "$", "name", ")", ";", "}", "return", "static", "::", "form_id", "(", "$", "type", ",", "$", "name", ")", ";", "}" ]
Format an id by configartion with the current form prefix @param string $type element, form etc.. @param strgin $name @return string
[ "Format", "an", "id", "by", "configartion", "with", "the", "current", "form", "prefix" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L148-L155
17,326
ClanCats/Core
src/bundles/UI/Form.php
Form.make_input
public static function make_input( $id, $key, $value = null, $type = 'text', $attr = array() ) { $element = HTML::tag( 'input', array_merge( array( 'id' => $id, 'name' => $key, 'type' => $type ), $attr )); if ( !is_null( $value ) ) { $element->value( _e( $value ) ); } if ( !static::$builder_enabled ) { return $element; } return Builder::handle( 'form_input', $element ); }
php
public static function make_input( $id, $key, $value = null, $type = 'text', $attr = array() ) { $element = HTML::tag( 'input', array_merge( array( 'id' => $id, 'name' => $key, 'type' => $type ), $attr )); if ( !is_null( $value ) ) { $element->value( _e( $value ) ); } if ( !static::$builder_enabled ) { return $element; } return Builder::handle( 'form_input', $element ); }
[ "public", "static", "function", "make_input", "(", "$", "id", ",", "$", "key", ",", "$", "value", "=", "null", ",", "$", "type", "=", "'text'", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "element", "=", "HTML", "::", "tag", "(", "'input'", ",", "array_merge", "(", "array", "(", "'id'", "=>", "$", "id", ",", "'name'", "=>", "$", "key", ",", "'type'", "=>", "$", "type", ")", ",", "$", "attr", ")", ")", ";", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "element", "->", "value", "(", "_e", "(", "$", "value", ")", ")", ";", "}", "if", "(", "!", "static", "::", "$", "builder_enabled", ")", "{", "return", "$", "element", ";", "}", "return", "Builder", "::", "handle", "(", "'form_input'", ",", "$", "element", ")", ";", "}" ]
make an input @param string $id The id that has been generated for us. @param string $key This is the name @param string $type @param array $attr
[ "make", "an", "input" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L204-L223
17,327
ClanCats/Core
src/bundles/UI/Form.php
Form.make_label
public static function make_label( $id, $key, $text = null, $attr = array() ) { if ( is_null( $text ) ) { $text = $key; } $element = HTML::tag( 'label', $text, array_merge( array( 'id' => $id, 'for' => static::build_id( 'input', $key ) ), $attr )); if ( !static::$builder_enabled ) { return $element; } return Builder::handle( 'form_label', $element ); }
php
public static function make_label( $id, $key, $text = null, $attr = array() ) { if ( is_null( $text ) ) { $text = $key; } $element = HTML::tag( 'label', $text, array_merge( array( 'id' => $id, 'for' => static::build_id( 'input', $key ) ), $attr )); if ( !static::$builder_enabled ) { return $element; } return Builder::handle( 'form_label', $element ); }
[ "public", "static", "function", "make_label", "(", "$", "id", ",", "$", "key", ",", "$", "text", "=", "null", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "if", "(", "is_null", "(", "$", "text", ")", ")", "{", "$", "text", "=", "$", "key", ";", "}", "$", "element", "=", "HTML", "::", "tag", "(", "'label'", ",", "$", "text", ",", "array_merge", "(", "array", "(", "'id'", "=>", "$", "id", ",", "'for'", "=>", "static", "::", "build_id", "(", "'input'", ",", "$", "key", ")", ")", ",", "$", "attr", ")", ")", ";", "if", "(", "!", "static", "::", "$", "builder_enabled", ")", "{", "return", "$", "element", ";", "}", "return", "Builder", "::", "handle", "(", "'form_label'", ",", "$", "element", ")", ";", "}" ]
make a label @param string $id The id that has been generated for us. @param string $key This is the name @param string $text @param array $attr
[ "make", "a", "label" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L233-L251
17,328
ClanCats/Core
src/bundles/UI/Form.php
Form.make_checkbox
public static function make_checkbox( $id, $key, $text = '', $active = false, $attr = array() ) { $element = HTML::tag( 'input', array_merge( array( 'id' => $id, 'name' => $key, 'type' => 'checkbox' ), $attr )); $element->checked( (bool) $active ); $element = HTML::tag( 'label', $element->render().' '.$text ); if ( !static::$builder_enabled ) { return $element; } return Builder::handle( 'form_checkbox', $element ); }
php
public static function make_checkbox( $id, $key, $text = '', $active = false, $attr = array() ) { $element = HTML::tag( 'input', array_merge( array( 'id' => $id, 'name' => $key, 'type' => 'checkbox' ), $attr )); $element->checked( (bool) $active ); $element = HTML::tag( 'label', $element->render().' '.$text ); if ( !static::$builder_enabled ) { return $element; } return Builder::handle( 'form_checkbox', $element ); }
[ "public", "static", "function", "make_checkbox", "(", "$", "id", ",", "$", "key", ",", "$", "text", "=", "''", ",", "$", "active", "=", "false", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "element", "=", "HTML", "::", "tag", "(", "'input'", ",", "array_merge", "(", "array", "(", "'id'", "=>", "$", "id", ",", "'name'", "=>", "$", "key", ",", "'type'", "=>", "'checkbox'", ")", ",", "$", "attr", ")", ")", ";", "$", "element", "->", "checked", "(", "(", "bool", ")", "$", "active", ")", ";", "$", "element", "=", "HTML", "::", "tag", "(", "'label'", ",", "$", "element", "->", "render", "(", ")", ".", "' '", ".", "$", "text", ")", ";", "if", "(", "!", "static", "::", "$", "builder_enabled", ")", "{", "return", "$", "element", ";", "}", "return", "Builder", "::", "handle", "(", "'form_checkbox'", ",", "$", "element", ")", ";", "}" ]
make a checkbox @param string $id The id that has been generated for us. @param string $key This is the name @param string $text @param bool $active Is the checkbox cheked @param array $attr @return string
[ "make", "a", "checkbox" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L263-L281
17,329
ClanCats/Core
src/bundles/UI/Form.php
Form.make_select
public static function make_select( $id, $name, array $options, $selected = array(), $size = 1 ) { if ( !is_array( $selected ) ) { $selected = array( $selected ); } $buffer = ""; foreach( $options as $key => $option ) { if ( ! ( $option instanceof HTML ) ) { $option = HTML::tag( 'option', $option ) ->value( $key ); } if ( in_array( $key, $selected ) ) { $option->selected( true ); } $buffer .= $option->render(); } $element = HTML::tag( 'select', $buffer, array( 'id' => $id, 'name' => $name, 'size' => $size, ) ); if ( !static::$builder_enabled ) { return $element; } return Builder::handle( 'form_select', $element ); }
php
public static function make_select( $id, $name, array $options, $selected = array(), $size = 1 ) { if ( !is_array( $selected ) ) { $selected = array( $selected ); } $buffer = ""; foreach( $options as $key => $option ) { if ( ! ( $option instanceof HTML ) ) { $option = HTML::tag( 'option', $option ) ->value( $key ); } if ( in_array( $key, $selected ) ) { $option->selected( true ); } $buffer .= $option->render(); } $element = HTML::tag( 'select', $buffer, array( 'id' => $id, 'name' => $name, 'size' => $size, ) ); if ( !static::$builder_enabled ) { return $element; } return Builder::handle( 'form_select', $element ); }
[ "public", "static", "function", "make_select", "(", "$", "id", ",", "$", "name", ",", "array", "$", "options", ",", "$", "selected", "=", "array", "(", ")", ",", "$", "size", "=", "1", ")", "{", "if", "(", "!", "is_array", "(", "$", "selected", ")", ")", "{", "$", "selected", "=", "array", "(", "$", "selected", ")", ";", "}", "$", "buffer", "=", "\"\"", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "option", ")", "{", "if", "(", "!", "(", "$", "option", "instanceof", "HTML", ")", ")", "{", "$", "option", "=", "HTML", "::", "tag", "(", "'option'", ",", "$", "option", ")", "->", "value", "(", "$", "key", ")", ";", "}", "if", "(", "in_array", "(", "$", "key", ",", "$", "selected", ")", ")", "{", "$", "option", "->", "selected", "(", "true", ")", ";", "}", "$", "buffer", ".=", "$", "option", "->", "render", "(", ")", ";", "}", "$", "element", "=", "HTML", "::", "tag", "(", "'select'", ",", "$", "buffer", ",", "array", "(", "'id'", "=>", "$", "id", ",", "'name'", "=>", "$", "name", ",", "'size'", "=>", "$", "size", ",", ")", ")", ";", "if", "(", "!", "static", "::", "$", "builder_enabled", ")", "{", "return", "$", "element", ";", "}", "return", "Builder", "::", "handle", "(", "'form_select'", ",", "$", "element", ")", ";", "}" ]
generate an select Form::select( 'gender', array( 'F', 'M' ), 0 ); Form::select( 'gender', array( '1' => 'A', '2' => 'B' ), array( 1,2 ), 2 ); @param string $id The id that has been generated for us. @param string $name This is the name @param array $options @param array $selected @param int $size @return string
[ "generate", "an", "select" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Form.php#L334-L371
17,330
neos/doctools
Classes/Command/ReferenceCommandController.php
ReferenceCommandController.renderCollectionCommand
public function renderCollectionCommand($collection) { if (!isset($this->settings['collections'][$collection])) { $this->outputLine('Collection "%s" is not configured', [$collection]); $this->quit(1); } if (!isset($this->settings['collections'][$collection]['references'])) { $this->outputLine('Collection "%s" does not have any references', [$collection]); $this->quit(1); } $references = $this->settings['collections'][$collection]['references']; $this->renderReferences($references); }
php
public function renderCollectionCommand($collection) { if (!isset($this->settings['collections'][$collection])) { $this->outputLine('Collection "%s" is not configured', [$collection]); $this->quit(1); } if (!isset($this->settings['collections'][$collection]['references'])) { $this->outputLine('Collection "%s" does not have any references', [$collection]); $this->quit(1); } $references = $this->settings['collections'][$collection]['references']; $this->renderReferences($references); }
[ "public", "function", "renderCollectionCommand", "(", "$", "collection", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "settings", "[", "'collections'", "]", "[", "$", "collection", "]", ")", ")", "{", "$", "this", "->", "outputLine", "(", "'Collection \"%s\" is not configured'", ",", "[", "$", "collection", "]", ")", ";", "$", "this", "->", "quit", "(", "1", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "settings", "[", "'collections'", "]", "[", "$", "collection", "]", "[", "'references'", "]", ")", ")", "{", "$", "this", "->", "outputLine", "(", "'Collection \"%s\" does not have any references'", ",", "[", "$", "collection", "]", ")", ";", "$", "this", "->", "quit", "(", "1", ")", ";", "}", "$", "references", "=", "$", "this", "->", "settings", "[", "'collections'", "]", "[", "$", "collection", "]", "[", "'references'", "]", ";", "$", "this", "->", "renderReferences", "(", "$", "references", ")", ";", "}" ]
Renders a configured collection of reference documentation from source code. @param string $collection to render (typically the name of a package). @return void @throws \Neos\Flow\Mvc\Exception\StopActionException @throws \Neos\FluidAdaptor\Exception @throws \Neos\Flow\Reflection\Exception\ClassLoadingForReflectionFailedException
[ "Renders", "a", "configured", "collection", "of", "reference", "documentation", "from", "source", "code", "." ]
726981245a8d59319ee594a582f80a30256df98b
https://github.com/neos/doctools/blob/726981245a8d59319ee594a582f80a30256df98b/Classes/Command/ReferenceCommandController.php#L71-L83
17,331
neos/doctools
Classes/Command/ReferenceCommandController.php
ReferenceCommandController.renderReference
protected function renderReference($reference) { if (!isset($this->settings['references'][$reference])) { $this->outputLine('Reference "%s" is not configured', [$reference]); $this->quit(1); } $referenceConfiguration = $this->settings['references'][$reference]; $affectedClassNames = $this->getAffectedClassNames($referenceConfiguration['affectedClasses']); $parserClassName = $referenceConfiguration['parser']['implementationClassName']; $parserOptions = isset($referenceConfiguration['parser']['options']) ? $referenceConfiguration['parser']['options'] : []; /** @var $classParser \Neos\DocTools\Domain\Service\AbstractClassParser */ $classParser = new $parserClassName($parserOptions); $classReferences = []; foreach ($affectedClassNames as $className) { $classReferences[$className] = $classParser->parse($className); } usort($classReferences, function (ClassReference $a, ClassReference $b) { if ($a->getTitle() == $b->getTitle()) { return 0; } return ($a->getTitle() < $b->getTitle()) ? -1 : 1; }); $standaloneView = new \Neos\FluidAdaptor\View\StandaloneView(); $templatePathAndFilename = isset($referenceConfiguration['templatePathAndFilename']) ? $referenceConfiguration['templatePathAndFilename'] : 'resource://Neos.DocTools/Private/Templates/ClassReferenceTemplate.txt'; $standaloneView->setTemplatePathAndFilename($templatePathAndFilename); $standaloneView->assign('title', isset($referenceConfiguration['title']) ? $referenceConfiguration['title'] : $reference); $standaloneView->assign('classReferences', $classReferences); file_put_contents($referenceConfiguration['savePathAndFilename'], $standaloneView->render()); $this->outputLine('DONE.'); }
php
protected function renderReference($reference) { if (!isset($this->settings['references'][$reference])) { $this->outputLine('Reference "%s" is not configured', [$reference]); $this->quit(1); } $referenceConfiguration = $this->settings['references'][$reference]; $affectedClassNames = $this->getAffectedClassNames($referenceConfiguration['affectedClasses']); $parserClassName = $referenceConfiguration['parser']['implementationClassName']; $parserOptions = isset($referenceConfiguration['parser']['options']) ? $referenceConfiguration['parser']['options'] : []; /** @var $classParser \Neos\DocTools\Domain\Service\AbstractClassParser */ $classParser = new $parserClassName($parserOptions); $classReferences = []; foreach ($affectedClassNames as $className) { $classReferences[$className] = $classParser->parse($className); } usort($classReferences, function (ClassReference $a, ClassReference $b) { if ($a->getTitle() == $b->getTitle()) { return 0; } return ($a->getTitle() < $b->getTitle()) ? -1 : 1; }); $standaloneView = new \Neos\FluidAdaptor\View\StandaloneView(); $templatePathAndFilename = isset($referenceConfiguration['templatePathAndFilename']) ? $referenceConfiguration['templatePathAndFilename'] : 'resource://Neos.DocTools/Private/Templates/ClassReferenceTemplate.txt'; $standaloneView->setTemplatePathAndFilename($templatePathAndFilename); $standaloneView->assign('title', isset($referenceConfiguration['title']) ? $referenceConfiguration['title'] : $reference); $standaloneView->assign('classReferences', $classReferences); file_put_contents($referenceConfiguration['savePathAndFilename'], $standaloneView->render()); $this->outputLine('DONE.'); }
[ "protected", "function", "renderReference", "(", "$", "reference", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "settings", "[", "'references'", "]", "[", "$", "reference", "]", ")", ")", "{", "$", "this", "->", "outputLine", "(", "'Reference \"%s\" is not configured'", ",", "[", "$", "reference", "]", ")", ";", "$", "this", "->", "quit", "(", "1", ")", ";", "}", "$", "referenceConfiguration", "=", "$", "this", "->", "settings", "[", "'references'", "]", "[", "$", "reference", "]", ";", "$", "affectedClassNames", "=", "$", "this", "->", "getAffectedClassNames", "(", "$", "referenceConfiguration", "[", "'affectedClasses'", "]", ")", ";", "$", "parserClassName", "=", "$", "referenceConfiguration", "[", "'parser'", "]", "[", "'implementationClassName'", "]", ";", "$", "parserOptions", "=", "isset", "(", "$", "referenceConfiguration", "[", "'parser'", "]", "[", "'options'", "]", ")", "?", "$", "referenceConfiguration", "[", "'parser'", "]", "[", "'options'", "]", ":", "[", "]", ";", "/** @var $classParser \\Neos\\DocTools\\Domain\\Service\\AbstractClassParser */", "$", "classParser", "=", "new", "$", "parserClassName", "(", "$", "parserOptions", ")", ";", "$", "classReferences", "=", "[", "]", ";", "foreach", "(", "$", "affectedClassNames", "as", "$", "className", ")", "{", "$", "classReferences", "[", "$", "className", "]", "=", "$", "classParser", "->", "parse", "(", "$", "className", ")", ";", "}", "usort", "(", "$", "classReferences", ",", "function", "(", "ClassReference", "$", "a", ",", "ClassReference", "$", "b", ")", "{", "if", "(", "$", "a", "->", "getTitle", "(", ")", "==", "$", "b", "->", "getTitle", "(", ")", ")", "{", "return", "0", ";", "}", "return", "(", "$", "a", "->", "getTitle", "(", ")", "<", "$", "b", "->", "getTitle", "(", ")", ")", "?", "-", "1", ":", "1", ";", "}", ")", ";", "$", "standaloneView", "=", "new", "\\", "Neos", "\\", "FluidAdaptor", "\\", "View", "\\", "StandaloneView", "(", ")", ";", "$", "templatePathAndFilename", "=", "isset", "(", "$", "referenceConfiguration", "[", "'templatePathAndFilename'", "]", ")", "?", "$", "referenceConfiguration", "[", "'templatePathAndFilename'", "]", ":", "'resource://Neos.DocTools/Private/Templates/ClassReferenceTemplate.txt'", ";", "$", "standaloneView", "->", "setTemplatePathAndFilename", "(", "$", "templatePathAndFilename", ")", ";", "$", "standaloneView", "->", "assign", "(", "'title'", ",", "isset", "(", "$", "referenceConfiguration", "[", "'title'", "]", ")", "?", "$", "referenceConfiguration", "[", "'title'", "]", ":", "$", "reference", ")", ";", "$", "standaloneView", "->", "assign", "(", "'classReferences'", ",", "$", "classReferences", ")", ";", "file_put_contents", "(", "$", "referenceConfiguration", "[", "'savePathAndFilename'", "]", ",", "$", "standaloneView", "->", "render", "(", ")", ")", ";", "$", "this", "->", "outputLine", "(", "'DONE.'", ")", ";", "}" ]
Render a reference to reStructuredText. @param string $reference @return void @throws \Neos\Flow\Mvc\Exception\StopActionException @throws \Neos\FluidAdaptor\Exception @throws \Neos\Flow\Reflection\Exception\ClassLoadingForReflectionFailedException
[ "Render", "a", "reference", "to", "reStructuredText", "." ]
726981245a8d59319ee594a582f80a30256df98b
https://github.com/neos/doctools/blob/726981245a8d59319ee594a582f80a30256df98b/Classes/Command/ReferenceCommandController.php#L111-L141
17,332
accgit/single-web
src/Single/Single.php
Single.flashMessage
public function flashMessage($message) { $sessions = $this->getSessions()->getSessionSection('flash.message'); $sessions->message = $message; $sessions->setExpiration('5 second'); return $sessions->message; }
php
public function flashMessage($message) { $sessions = $this->getSessions()->getSessionSection('flash.message'); $sessions->message = $message; $sessions->setExpiration('5 second'); return $sessions->message; }
[ "public", "function", "flashMessage", "(", "$", "message", ")", "{", "$", "sessions", "=", "$", "this", "->", "getSessions", "(", ")", "->", "getSessionSection", "(", "'flash.message'", ")", ";", "$", "sessions", "->", "message", "=", "$", "message", ";", "$", "sessions", "->", "setExpiration", "(", "'5 second'", ")", ";", "return", "$", "sessions", "->", "message", ";", "}" ]
Create flash message. @param string $message @return string
[ "Create", "flash", "message", "." ]
5d0dce3313df9e22ab60749bcf01f1753de8c143
https://github.com/accgit/single-web/blob/5d0dce3313df9e22ab60749bcf01f1753de8c143/src/Single/Single.php#L49-L55
17,333
kattsoftware/phassets
src/Phassets/Factory.php
Factory.buildLogger
public function buildLogger($class, Configurator $configurator) { if (!class_exists($class) || !is_subclass_of($class, Logger::class)) { $class = "\\Phassets\\Loggers\\$class"; } if (class_exists($class) && is_subclass_of($class, Logger::class)) { return new $class($configurator); } return false; }
php
public function buildLogger($class, Configurator $configurator) { if (!class_exists($class) || !is_subclass_of($class, Logger::class)) { $class = "\\Phassets\\Loggers\\$class"; } if (class_exists($class) && is_subclass_of($class, Logger::class)) { return new $class($configurator); } return false; }
[ "public", "function", "buildLogger", "(", "$", "class", ",", "Configurator", "$", "configurator", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", "||", "!", "is_subclass_of", "(", "$", "class", ",", "Logger", "::", "class", ")", ")", "{", "$", "class", "=", "\"\\\\Phassets\\\\Loggers\\\\$class\"", ";", "}", "if", "(", "class_exists", "(", "$", "class", ")", "&&", "is_subclass_of", "(", "$", "class", ",", "Logger", "::", "class", ")", ")", "{", "return", "new", "$", "class", "(", "$", "configurator", ")", ";", "}", "return", "false", ";", "}" ]
Creates a Logger instance. @param string $class Fully qualified class name of a Logger class @param Configurator $configurator Currently used Configurator of Phassets @return bool|Logger Created instance of the provided Logger; false on failure
[ "Creates", "a", "Logger", "instance", "." ]
cc982cf1941eb5776287d64f027218bd4835ed2b
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L50-L61
17,334
kattsoftware/phassets
src/Phassets/Factory.php
Factory.buildCacheAdapter
public function buildCacheAdapter($class, Configurator $configurator) { if (!class_exists($class) || !is_subclass_of($class, CacheAdapter::class)) { $class = "\\Phassets\\CacheAdapters\\$class"; } if (class_exists($class) && is_subclass_of($class, CacheAdapter::class)) { return new $class($configurator); } return false; }
php
public function buildCacheAdapter($class, Configurator $configurator) { if (!class_exists($class) || !is_subclass_of($class, CacheAdapter::class)) { $class = "\\Phassets\\CacheAdapters\\$class"; } if (class_exists($class) && is_subclass_of($class, CacheAdapter::class)) { return new $class($configurator); } return false; }
[ "public", "function", "buildCacheAdapter", "(", "$", "class", ",", "Configurator", "$", "configurator", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", "||", "!", "is_subclass_of", "(", "$", "class", ",", "CacheAdapter", "::", "class", ")", ")", "{", "$", "class", "=", "\"\\\\Phassets\\\\CacheAdapters\\\\$class\"", ";", "}", "if", "(", "class_exists", "(", "$", "class", ")", "&&", "is_subclass_of", "(", "$", "class", ",", "CacheAdapter", "::", "class", ")", ")", "{", "return", "new", "$", "class", "(", "$", "configurator", ")", ";", "}", "return", "false", ";", "}" ]
Creates a CacheAdapter instance. @param string $class Fully qualified class name of a CacheAdapter class @param Configurator $configurator Currently used Configurator of Phassets @return bool|CacheAdapter Created instance of the provided CacheAdapter; false on failure
[ "Creates", "a", "CacheAdapter", "instance", "." ]
cc982cf1941eb5776287d64f027218bd4835ed2b
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L71-L82
17,335
kattsoftware/phassets
src/Phassets/Factory.php
Factory.buildDeployer
public function buildDeployer($class, Configurator $configurator, CacheAdapter $cacheAdapter) { if (!class_exists($class) || !is_subclass_of($class, Deployer::class)) { $class = "\\Phassets\\Deployers\\$class"; } if (class_exists($class) && is_subclass_of($class, Deployer::class)) { return new $class($configurator, $cacheAdapter); } return false; }
php
public function buildDeployer($class, Configurator $configurator, CacheAdapter $cacheAdapter) { if (!class_exists($class) || !is_subclass_of($class, Deployer::class)) { $class = "\\Phassets\\Deployers\\$class"; } if (class_exists($class) && is_subclass_of($class, Deployer::class)) { return new $class($configurator, $cacheAdapter); } return false; }
[ "public", "function", "buildDeployer", "(", "$", "class", ",", "Configurator", "$", "configurator", ",", "CacheAdapter", "$", "cacheAdapter", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", "||", "!", "is_subclass_of", "(", "$", "class", ",", "Deployer", "::", "class", ")", ")", "{", "$", "class", "=", "\"\\\\Phassets\\\\Deployers\\\\$class\"", ";", "}", "if", "(", "class_exists", "(", "$", "class", ")", "&&", "is_subclass_of", "(", "$", "class", ",", "Deployer", "::", "class", ")", ")", "{", "return", "new", "$", "class", "(", "$", "configurator", ",", "$", "cacheAdapter", ")", ";", "}", "return", "false", ";", "}" ]
Creates a Deployer instance. @param string $class Fully qualified class name of a Deployer class @param Configurator $configurator Currently used Configurator of Phassets @param CacheAdapter $cacheAdapter Currently used CacheAdapter of Phassets @return Deployer|bool Created instance of the provided Deployer; false on failure
[ "Creates", "a", "Deployer", "instance", "." ]
cc982cf1941eb5776287d64f027218bd4835ed2b
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L104-L115
17,336
kattsoftware/phassets
src/Phassets/Factory.php
Factory.buildFilter
public function buildFilter($class, Configurator $configurator) { if (!class_exists($class) || !is_subclass_of($class, Filter::class)) { $class = "\\Phassets\\Filters\\$class"; } if (class_exists($class) && is_subclass_of($class, Filter::class)) { return new $class($configurator); } return false; }
php
public function buildFilter($class, Configurator $configurator) { if (!class_exists($class) || !is_subclass_of($class, Filter::class)) { $class = "\\Phassets\\Filters\\$class"; } if (class_exists($class) && is_subclass_of($class, Filter::class)) { return new $class($configurator); } return false; }
[ "public", "function", "buildFilter", "(", "$", "class", ",", "Configurator", "$", "configurator", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", "||", "!", "is_subclass_of", "(", "$", "class", ",", "Filter", "::", "class", ")", ")", "{", "$", "class", "=", "\"\\\\Phassets\\\\Filters\\\\$class\"", ";", "}", "if", "(", "class_exists", "(", "$", "class", ")", "&&", "is_subclass_of", "(", "$", "class", ",", "Filter", "::", "class", ")", ")", "{", "return", "new", "$", "class", "(", "$", "configurator", ")", ";", "}", "return", "false", ";", "}" ]
Creates a Filter instance. @param string $class Fully qualified class name of a Filter class @param Configurator $configurator Currently used Configurator of Phassets @return Filter|bool Created instance of the provided Filter; false on failure
[ "Creates", "a", "Filter", "instance", "." ]
cc982cf1941eb5776287d64f027218bd4835ed2b
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L125-L136
17,337
kattsoftware/phassets
src/Phassets/Factory.php
Factory.buildAssetsMerger
public function buildAssetsMerger($class, Configurator $configurator) { if (!class_exists($class) || !is_subclass_of($class, AssetsMerger::class)) { $class = "\\Phassets\\AssetsMergers\\$class"; } if (class_exists($class) && is_subclass_of($class, AssetsMerger::class)) { return new $class($configurator); } return false; }
php
public function buildAssetsMerger($class, Configurator $configurator) { if (!class_exists($class) || !is_subclass_of($class, AssetsMerger::class)) { $class = "\\Phassets\\AssetsMergers\\$class"; } if (class_exists($class) && is_subclass_of($class, AssetsMerger::class)) { return new $class($configurator); } return false; }
[ "public", "function", "buildAssetsMerger", "(", "$", "class", ",", "Configurator", "$", "configurator", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", "||", "!", "is_subclass_of", "(", "$", "class", ",", "AssetsMerger", "::", "class", ")", ")", "{", "$", "class", "=", "\"\\\\Phassets\\\\AssetsMergers\\\\$class\"", ";", "}", "if", "(", "class_exists", "(", "$", "class", ")", "&&", "is_subclass_of", "(", "$", "class", ",", "AssetsMerger", "::", "class", ")", ")", "{", "return", "new", "$", "class", "(", "$", "configurator", ")", ";", "}", "return", "false", ";", "}" ]
Creates an AssetsMerger instance. @param string $class Fully qualified class name of a AssetsMerger class @param Configurator $configurator Currently used Configurator of Phassets @return bool|AssetsMerger Created instance of the provided AssetsMerger; false on failure
[ "Creates", "an", "AssetsMerger", "instance", "." ]
cc982cf1941eb5776287d64f027218bd4835ed2b
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Factory.php#L166-L177
17,338
digitalkaoz/versioneye-php
src/Output/Products.php
Products.show
public function show(OutputInterface $output, array $response) { $this->printList($output, ['Name', 'Description', 'Source', 'Archive', 'Key', 'Type', 'License', 'Version', 'Group', 'Updated At'], ['name', 'description', 'links', 'archives', 'prod_key', 'prod_type', 'license_info', 'version', 'group_id', 'updated_at'], $response, function ($heading, $value) { if ('Source' === $heading) { if (!empty($value)) { return array_pop($value)['link']; } } if ('Archive' === $heading) { return array_pop($value)['link']; } return $value; } ); $this->printTable($output, ['Name', 'Current', 'Requested'], ['name', 'parsed_version', 'version'], $response['dependencies'] ); }
php
public function show(OutputInterface $output, array $response) { $this->printList($output, ['Name', 'Description', 'Source', 'Archive', 'Key', 'Type', 'License', 'Version', 'Group', 'Updated At'], ['name', 'description', 'links', 'archives', 'prod_key', 'prod_type', 'license_info', 'version', 'group_id', 'updated_at'], $response, function ($heading, $value) { if ('Source' === $heading) { if (!empty($value)) { return array_pop($value)['link']; } } if ('Archive' === $heading) { return array_pop($value)['link']; } return $value; } ); $this->printTable($output, ['Name', 'Current', 'Requested'], ['name', 'parsed_version', 'version'], $response['dependencies'] ); }
[ "public", "function", "show", "(", "OutputInterface", "$", "output", ",", "array", "$", "response", ")", "{", "$", "this", "->", "printList", "(", "$", "output", ",", "[", "'Name'", ",", "'Description'", ",", "'Source'", ",", "'Archive'", ",", "'Key'", ",", "'Type'", ",", "'License'", ",", "'Version'", ",", "'Group'", ",", "'Updated At'", "]", ",", "[", "'name'", ",", "'description'", ",", "'links'", ",", "'archives'", ",", "'prod_key'", ",", "'prod_type'", ",", "'license_info'", ",", "'version'", ",", "'group_id'", ",", "'updated_at'", "]", ",", "$", "response", ",", "function", "(", "$", "heading", ",", "$", "value", ")", "{", "if", "(", "'Source'", "===", "$", "heading", ")", "{", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "return", "array_pop", "(", "$", "value", ")", "[", "'link'", "]", ";", "}", "}", "if", "(", "'Archive'", "===", "$", "heading", ")", "{", "return", "array_pop", "(", "$", "value", ")", "[", "'link'", "]", ";", "}", "return", "$", "value", ";", "}", ")", ";", "$", "this", "->", "printTable", "(", "$", "output", ",", "[", "'Name'", ",", "'Current'", ",", "'Requested'", "]", ",", "[", "'name'", ",", "'parsed_version'", ",", "'version'", "]", ",", "$", "response", "[", "'dependencies'", "]", ")", ";", "}" ]
output for the show API. @param OutputInterface $output @param array $response
[ "output", "for", "the", "show", "API", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Products.php#L42-L68
17,339
digitalkaoz/versioneye-php
src/Output/Products.php
Products.versions
public function versions(OutputInterface $output, array $response) { $this->printList($output, ['Name', 'Language', 'Key', 'Type', 'Version'], ['name', 'language', 'prod_key', 'prod_type', 'version'], $response ); $this->printTable($output, ['Version', 'Released At'], ['version', 'released_at'], $response['versions'], function ($key, $value) { if ('released_at' !== $key) { return $value; } return date('Y-m-d H:i:s', strtotime($value)); } ); }
php
public function versions(OutputInterface $output, array $response) { $this->printList($output, ['Name', 'Language', 'Key', 'Type', 'Version'], ['name', 'language', 'prod_key', 'prod_type', 'version'], $response ); $this->printTable($output, ['Version', 'Released At'], ['version', 'released_at'], $response['versions'], function ($key, $value) { if ('released_at' !== $key) { return $value; } return date('Y-m-d H:i:s', strtotime($value)); } ); }
[ "public", "function", "versions", "(", "OutputInterface", "$", "output", ",", "array", "$", "response", ")", "{", "$", "this", "->", "printList", "(", "$", "output", ",", "[", "'Name'", ",", "'Language'", ",", "'Key'", ",", "'Type'", ",", "'Version'", "]", ",", "[", "'name'", ",", "'language'", ",", "'prod_key'", ",", "'prod_type'", ",", "'version'", "]", ",", "$", "response", ")", ";", "$", "this", "->", "printTable", "(", "$", "output", ",", "[", "'Version'", ",", "'Released At'", "]", ",", "[", "'version'", ",", "'released_at'", "]", ",", "$", "response", "[", "'versions'", "]", ",", "function", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "'released_at'", "!==", "$", "key", ")", "{", "return", "$", "value", ";", "}", "return", "date", "(", "'Y-m-d H:i:s'", ",", "strtotime", "(", "$", "value", ")", ")", ";", "}", ")", ";", "}" ]
output for the versions API. @param OutputInterface $output @param array $response
[ "output", "for", "the", "versions", "API", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Products.php#L109-L129
17,340
CakeCMS/Core
src/View/Helper/LessHelper.php
LessHelper.process
public function process($source, $force = true) { list ($webRoot, $source) = $this->_findWebRoot($source); $lessFile = FS::clean($webRoot . Configure::read('App.lessBaseUrl') . $source, '/'); $this->_setForce($force); $less = new Less($this->_config); if (!FS::isFile($lessFile)) { return null; } list($source, $isExpired) = $less->compile($lessFile); if ($isExpired) { $cacheId = FS::firstLine($source); $comment = '/* resource:' . str_replace(FS::clean(ROOT, '/'), '', $lessFile) . ' */' . PHP_EOL; $fileHead = implode('', [$cacheId, Str::low($comment)]); $css = $this->_normalizeContent($source, $fileHead); $this->_write($source, $css); } $source = str_replace(FS::clean(APP_ROOT . '/' . Configure::read('App.webroot'), '/'), '', $source); return $source; }
php
public function process($source, $force = true) { list ($webRoot, $source) = $this->_findWebRoot($source); $lessFile = FS::clean($webRoot . Configure::read('App.lessBaseUrl') . $source, '/'); $this->_setForce($force); $less = new Less($this->_config); if (!FS::isFile($lessFile)) { return null; } list($source, $isExpired) = $less->compile($lessFile); if ($isExpired) { $cacheId = FS::firstLine($source); $comment = '/* resource:' . str_replace(FS::clean(ROOT, '/'), '', $lessFile) . ' */' . PHP_EOL; $fileHead = implode('', [$cacheId, Str::low($comment)]); $css = $this->_normalizeContent($source, $fileHead); $this->_write($source, $css); } $source = str_replace(FS::clean(APP_ROOT . '/' . Configure::read('App.webroot'), '/'), '', $source); return $source; }
[ "public", "function", "process", "(", "$", "source", ",", "$", "force", "=", "true", ")", "{", "list", "(", "$", "webRoot", ",", "$", "source", ")", "=", "$", "this", "->", "_findWebRoot", "(", "$", "source", ")", ";", "$", "lessFile", "=", "FS", "::", "clean", "(", "$", "webRoot", ".", "Configure", "::", "read", "(", "'App.lessBaseUrl'", ")", ".", "$", "source", ",", "'/'", ")", ";", "$", "this", "->", "_setForce", "(", "$", "force", ")", ";", "$", "less", "=", "new", "Less", "(", "$", "this", "->", "_config", ")", ";", "if", "(", "!", "FS", "::", "isFile", "(", "$", "lessFile", ")", ")", "{", "return", "null", ";", "}", "list", "(", "$", "source", ",", "$", "isExpired", ")", "=", "$", "less", "->", "compile", "(", "$", "lessFile", ")", ";", "if", "(", "$", "isExpired", ")", "{", "$", "cacheId", "=", "FS", "::", "firstLine", "(", "$", "source", ")", ";", "$", "comment", "=", "'/* resource:'", ".", "str_replace", "(", "FS", "::", "clean", "(", "ROOT", ",", "'/'", ")", ",", "''", ",", "$", "lessFile", ")", ".", "' */'", ".", "PHP_EOL", ";", "$", "fileHead", "=", "implode", "(", "''", ",", "[", "$", "cacheId", ",", "Str", "::", "low", "(", "$", "comment", ")", "]", ")", ";", "$", "css", "=", "$", "this", "->", "_normalizeContent", "(", "$", "source", ",", "$", "fileHead", ")", ";", "$", "this", "->", "_write", "(", "$", "source", ",", "$", "css", ")", ";", "}", "$", "source", "=", "str_replace", "(", "FS", "::", "clean", "(", "APP_ROOT", ".", "'/'", ".", "Configure", "::", "read", "(", "'App.webroot'", ")", ",", "'/'", ")", ",", "''", ",", "$", "source", ")", ";", "return", "$", "source", ";", "}" ]
Process less file. @param string $source @param bool $force @return string|null @throws \JBZoo\Less\Exception
[ "Process", "less", "file", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L73-L99
17,341
CakeCMS/Core
src/View/Helper/LessHelper.php
LessHelper._compress
protected function _compress($code, $cacheId) { $code = (string) $code; // remove comments $code = preg_replace('#/\*[^*]*\*+([^/][^*]*\*+)*/#ius', '', $code); $code = str_replace( ["\r\n", "\r", "\n", "\t", ' ', ' ', ' {', '{ ', ' }', '; ', ';;', ';;;', ';;;;', ';}'], ['', '', '', '', '', '', '{', '{', '}', ';', ';', ';', ';', '}'], $code ); // remove tabs, spaces, newlines, etc. // remove spaces after and before colons $code = preg_replace('#([a-z\-])(:\s*|\s*:\s*|\s*:)#ius', '$1:', $code); // spaces before "!important" $code = preg_replace('#(\s*\!important)#ius', '!important', $code); $code = Str::trim($code); return implode('', [$cacheId, $code]); }
php
protected function _compress($code, $cacheId) { $code = (string) $code; // remove comments $code = preg_replace('#/\*[^*]*\*+([^/][^*]*\*+)*/#ius', '', $code); $code = str_replace( ["\r\n", "\r", "\n", "\t", ' ', ' ', ' {', '{ ', ' }', '; ', ';;', ';;;', ';;;;', ';}'], ['', '', '', '', '', '', '{', '{', '}', ';', ';', ';', ';', '}'], $code ); // remove tabs, spaces, newlines, etc. // remove spaces after and before colons $code = preg_replace('#([a-z\-])(:\s*|\s*:\s*|\s*:)#ius', '$1:', $code); // spaces before "!important" $code = preg_replace('#(\s*\!important)#ius', '!important', $code); $code = Str::trim($code); return implode('', [$cacheId, $code]); }
[ "protected", "function", "_compress", "(", "$", "code", ",", "$", "cacheId", ")", "{", "$", "code", "=", "(", "string", ")", "$", "code", ";", "// remove comments", "$", "code", "=", "preg_replace", "(", "'#/\\*[^*]*\\*+([^/][^*]*\\*+)*/#ius'", ",", "''", ",", "$", "code", ")", ";", "$", "code", "=", "str_replace", "(", "[", "\"\\r\\n\"", ",", "\"\\r\"", ",", "\"\\n\"", ",", "\"\\t\"", ",", "' '", ",", "' '", ",", "' {'", ",", "'{ '", ",", "' }'", ",", "'; '", ",", "';;'", ",", "';;;'", ",", "';;;;'", ",", "';}'", "]", ",", "[", "''", ",", "''", ",", "''", ",", "''", ",", "''", ",", "''", ",", "'{'", ",", "'{'", ",", "'}'", ",", "';'", ",", "';'", ",", "';'", ",", "';'", ",", "'}'", "]", ",", "$", "code", ")", ";", "// remove tabs, spaces, newlines, etc.", "// remove spaces after and before colons", "$", "code", "=", "preg_replace", "(", "'#([a-z\\-])(:\\s*|\\s*:\\s*|\\s*:)#ius'", ",", "'$1:'", ",", "$", "code", ")", ";", "// spaces before \"!important\"", "$", "code", "=", "preg_replace", "(", "'#(\\s*\\!important)#ius'", ",", "'!important'", ",", "$", "code", ")", ";", "$", "code", "=", "Str", "::", "trim", "(", "$", "code", ")", ";", "return", "implode", "(", "''", ",", "[", "$", "cacheId", ",", "$", "code", "]", ")", ";", "}" ]
CSS compressing. @param string $code @param string $cacheId @return string
[ "CSS", "compressing", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L108-L129
17,342
CakeCMS/Core
src/View/Helper/LessHelper.php
LessHelper._findWebRoot
protected function _findWebRoot($source) { $webRootDir = Configure::read('App.webroot'); $webRoot = APP_ROOT . DS . $webRootDir . DS; list ($plugin, $source) = $this->_View->pluginSplit($source); if ($plugin !== null && Plugin::loaded($plugin)) { $webRoot = Plugin::path($plugin) . $webRootDir . DS; } return [FS::clean($webRoot, '/'), $source]; }
php
protected function _findWebRoot($source) { $webRootDir = Configure::read('App.webroot'); $webRoot = APP_ROOT . DS . $webRootDir . DS; list ($plugin, $source) = $this->_View->pluginSplit($source); if ($plugin !== null && Plugin::loaded($plugin)) { $webRoot = Plugin::path($plugin) . $webRootDir . DS; } return [FS::clean($webRoot, '/'), $source]; }
[ "protected", "function", "_findWebRoot", "(", "$", "source", ")", "{", "$", "webRootDir", "=", "Configure", "::", "read", "(", "'App.webroot'", ")", ";", "$", "webRoot", "=", "APP_ROOT", ".", "DS", ".", "$", "webRootDir", ".", "DS", ";", "list", "(", "$", "plugin", ",", "$", "source", ")", "=", "$", "this", "->", "_View", "->", "pluginSplit", "(", "$", "source", ")", ";", "if", "(", "$", "plugin", "!==", "null", "&&", "Plugin", "::", "loaded", "(", "$", "plugin", ")", ")", "{", "$", "webRoot", "=", "Plugin", "::", "path", "(", "$", "plugin", ")", ".", "$", "webRootDir", ".", "DS", ";", "}", "return", "[", "FS", "::", "clean", "(", "$", "webRoot", ",", "'/'", ")", ",", "$", "source", "]", ";", "}" ]
Find source webroot dir. @param string $source @return array
[ "Find", "source", "webroot", "dir", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L137-L148
17,343
CakeCMS/Core
src/View/Helper/LessHelper.php
LessHelper._getPlgAssetUrl
protected function _getPlgAssetUrl($path) { $isPlugin = false; $plgPaths = Configure::read('App.paths.plugins'); foreach ($plgPaths as $plgPath) { $plgPath = ltrim(FS::clean($plgPath, '/'), '/'); if (preg_match('(' . quotemeta($plgPath) . ')', $path)) { $path = str_replace($plgPath, '', $path); return [true, $path]; } } foreach (Configure::read('plugins') as $name => $plgPath) { $plgPath = FS::clean($plgPath, '/'); if (preg_match('(' . quotemeta($plgPath) . ')', $path)) { $path = Str::low($name) . '/' . str_replace($plgPath, '', $path); return [true, $path]; } } return [$isPlugin, $path]; }
php
protected function _getPlgAssetUrl($path) { $isPlugin = false; $plgPaths = Configure::read('App.paths.plugins'); foreach ($plgPaths as $plgPath) { $plgPath = ltrim(FS::clean($plgPath, '/'), '/'); if (preg_match('(' . quotemeta($plgPath) . ')', $path)) { $path = str_replace($plgPath, '', $path); return [true, $path]; } } foreach (Configure::read('plugins') as $name => $plgPath) { $plgPath = FS::clean($plgPath, '/'); if (preg_match('(' . quotemeta($plgPath) . ')', $path)) { $path = Str::low($name) . '/' . str_replace($plgPath, '', $path); return [true, $path]; } } return [$isPlugin, $path]; }
[ "protected", "function", "_getPlgAssetUrl", "(", "$", "path", ")", "{", "$", "isPlugin", "=", "false", ";", "$", "plgPaths", "=", "Configure", "::", "read", "(", "'App.paths.plugins'", ")", ";", "foreach", "(", "$", "plgPaths", "as", "$", "plgPath", ")", "{", "$", "plgPath", "=", "ltrim", "(", "FS", "::", "clean", "(", "$", "plgPath", ",", "'/'", ")", ",", "'/'", ")", ";", "if", "(", "preg_match", "(", "'('", ".", "quotemeta", "(", "$", "plgPath", ")", ".", "')'", ",", "$", "path", ")", ")", "{", "$", "path", "=", "str_replace", "(", "$", "plgPath", ",", "''", ",", "$", "path", ")", ";", "return", "[", "true", ",", "$", "path", "]", ";", "}", "}", "foreach", "(", "Configure", "::", "read", "(", "'plugins'", ")", "as", "$", "name", "=>", "$", "plgPath", ")", "{", "$", "plgPath", "=", "FS", "::", "clean", "(", "$", "plgPath", ",", "'/'", ")", ";", "if", "(", "preg_match", "(", "'('", ".", "quotemeta", "(", "$", "plgPath", ")", ".", "')'", ",", "$", "path", ")", ")", "{", "$", "path", "=", "Str", "::", "low", "(", "$", "name", ")", ".", "'/'", ".", "str_replace", "(", "$", "plgPath", ",", "''", ",", "$", "path", ")", ";", "return", "[", "true", ",", "$", "path", "]", ";", "}", "}", "return", "[", "$", "isPlugin", ",", "$", "path", "]", ";", "}" ]
Get plugin asset url. @param string $path @return array
[ "Get", "plugin", "asset", "url", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L167-L188
17,344
CakeCMS/Core
src/View/Helper/LessHelper.php
LessHelper._normalizeContent
protected function _normalizeContent($path, $fileHead) { $css = file_get_contents($path); if (!$this->_configRead('debug')) { $css = $this->_compress($css, $fileHead); } else { list ($first, $second) = explode(PHP_EOL, $css, 2); if (preg_match('(\/* cacheid:)', $first)) { $css = $second; } $css = implode('', [$fileHead, $css]); } return $this->_replaceUrl($css); }
php
protected function _normalizeContent($path, $fileHead) { $css = file_get_contents($path); if (!$this->_configRead('debug')) { $css = $this->_compress($css, $fileHead); } else { list ($first, $second) = explode(PHP_EOL, $css, 2); if (preg_match('(\/* cacheid:)', $first)) { $css = $second; } $css = implode('', [$fileHead, $css]); } return $this->_replaceUrl($css); }
[ "protected", "function", "_normalizeContent", "(", "$", "path", ",", "$", "fileHead", ")", "{", "$", "css", "=", "file_get_contents", "(", "$", "path", ")", ";", "if", "(", "!", "$", "this", "->", "_configRead", "(", "'debug'", ")", ")", "{", "$", "css", "=", "$", "this", "->", "_compress", "(", "$", "css", ",", "$", "fileHead", ")", ";", "}", "else", "{", "list", "(", "$", "first", ",", "$", "second", ")", "=", "explode", "(", "PHP_EOL", ",", "$", "css", ",", "2", ")", ";", "if", "(", "preg_match", "(", "'(\\/* cacheid:)'", ",", "$", "first", ")", ")", "{", "$", "css", "=", "$", "second", ";", "}", "$", "css", "=", "implode", "(", "''", ",", "[", "$", "fileHead", ",", "$", "css", "]", ")", ";", "}", "return", "$", "this", "->", "_replaceUrl", "(", "$", "css", ")", ";", "}" ]
Normalize style file. @param string $path @param string $fileHead @return mixed
[ "Normalize", "style", "file", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L197-L212
17,345
CakeCMS/Core
src/View/Helper/LessHelper.php
LessHelper._normalizePlgAssetUrl
protected function _normalizePlgAssetUrl($path) { $details = explode('/', $path, 3); $pluginName = Inflector::camelize(trim($details[0], '/')); if (Plugin::loaded($pluginName)) { unset($details[0]); $source = $pluginName . '.' . ltrim(implode('/', $details), '/'); return $this->_getAssetUrl($source); } return $this->_getAssetUrl($path); }
php
protected function _normalizePlgAssetUrl($path) { $details = explode('/', $path, 3); $pluginName = Inflector::camelize(trim($details[0], '/')); if (Plugin::loaded($pluginName)) { unset($details[0]); $source = $pluginName . '.' . ltrim(implode('/', $details), '/'); return $this->_getAssetUrl($source); } return $this->_getAssetUrl($path); }
[ "protected", "function", "_normalizePlgAssetUrl", "(", "$", "path", ")", "{", "$", "details", "=", "explode", "(", "'/'", ",", "$", "path", ",", "3", ")", ";", "$", "pluginName", "=", "Inflector", "::", "camelize", "(", "trim", "(", "$", "details", "[", "0", "]", ",", "'/'", ")", ")", ";", "if", "(", "Plugin", "::", "loaded", "(", "$", "pluginName", ")", ")", "{", "unset", "(", "$", "details", "[", "0", "]", ")", ";", "$", "source", "=", "$", "pluginName", ".", "'.'", ".", "ltrim", "(", "implode", "(", "'/'", ",", "$", "details", ")", ",", "'/'", ")", ";", "return", "$", "this", "->", "_getAssetUrl", "(", "$", "source", ")", ";", "}", "return", "$", "this", "->", "_getAssetUrl", "(", "$", "path", ")", ";", "}" ]
Normalize plugin asset url. @param string $path @return string
[ "Normalize", "plugin", "asset", "url", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L220-L232
17,346
CakeCMS/Core
src/View/Helper/LessHelper.php
LessHelper._replaceUrlCallback
protected function _replaceUrlCallback(array $match) { $assetPath = str_replace(Router::fullBaseUrl(), '', $match[2]); $assetPath = trim(FS::clean($assetPath, '/'), '/'); $appDir = trim(FS::clean(APP_ROOT, '/'), '/'); list ($isPlugin, $assetPath) = $this->_getPlgAssetUrl($assetPath); if (!$isPlugin) { $assetPath = str_replace($appDir, '', $assetPath); } $assetPath = str_replace(Configure::read('App.webroot'), '', $assetPath); $assetPath = FS::clean($assetPath, '/'); if ($isPlugin) { return $this->_normalizePlgAssetUrl($assetPath); } return $this->_getAssetUrl($assetPath); }
php
protected function _replaceUrlCallback(array $match) { $assetPath = str_replace(Router::fullBaseUrl(), '', $match[2]); $assetPath = trim(FS::clean($assetPath, '/'), '/'); $appDir = trim(FS::clean(APP_ROOT, '/'), '/'); list ($isPlugin, $assetPath) = $this->_getPlgAssetUrl($assetPath); if (!$isPlugin) { $assetPath = str_replace($appDir, '', $assetPath); } $assetPath = str_replace(Configure::read('App.webroot'), '', $assetPath); $assetPath = FS::clean($assetPath, '/'); if ($isPlugin) { return $this->_normalizePlgAssetUrl($assetPath); } return $this->_getAssetUrl($assetPath); }
[ "protected", "function", "_replaceUrlCallback", "(", "array", "$", "match", ")", "{", "$", "assetPath", "=", "str_replace", "(", "Router", "::", "fullBaseUrl", "(", ")", ",", "''", ",", "$", "match", "[", "2", "]", ")", ";", "$", "assetPath", "=", "trim", "(", "FS", "::", "clean", "(", "$", "assetPath", ",", "'/'", ")", ",", "'/'", ")", ";", "$", "appDir", "=", "trim", "(", "FS", "::", "clean", "(", "APP_ROOT", ",", "'/'", ")", ",", "'/'", ")", ";", "list", "(", "$", "isPlugin", ",", "$", "assetPath", ")", "=", "$", "this", "->", "_getPlgAssetUrl", "(", "$", "assetPath", ")", ";", "if", "(", "!", "$", "isPlugin", ")", "{", "$", "assetPath", "=", "str_replace", "(", "$", "appDir", ",", "''", ",", "$", "assetPath", ")", ";", "}", "$", "assetPath", "=", "str_replace", "(", "Configure", "::", "read", "(", "'App.webroot'", ")", ",", "''", ",", "$", "assetPath", ")", ";", "$", "assetPath", "=", "FS", "::", "clean", "(", "$", "assetPath", ",", "'/'", ")", ";", "if", "(", "$", "isPlugin", ")", "{", "return", "$", "this", "->", "_normalizePlgAssetUrl", "(", "$", "assetPath", ")", ";", "}", "return", "$", "this", "->", "_getAssetUrl", "(", "$", "assetPath", ")", ";", "}" ]
Replace url callback. @param array $match @return string
[ "Replace", "url", "callback", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L252-L272
17,347
CakeCMS/Core
src/View/Helper/LessHelper.php
LessHelper._write
protected function _write($path, $content) { $File = new File($path); $File->write($content); $File->exists(); }
php
protected function _write($path, $content) { $File = new File($path); $File->write($content); $File->exists(); }
[ "protected", "function", "_write", "(", "$", "path", ",", "$", "content", ")", "{", "$", "File", "=", "new", "File", "(", "$", "path", ")", ";", "$", "File", "->", "write", "(", "$", "content", ")", ";", "$", "File", "->", "exists", "(", ")", ";", "}" ]
Write content in to the file. @param string $path @param string $content @return void
[ "Write", "content", "in", "to", "the", "file", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/LessHelper.php#L294-L299
17,348
inc2734/wp-share-buttons
src/App/Contract/Shortcode/Button.php
Button._get_requester
protected function _get_requester() { $this_class = get_class( $this ); $this_class = explode( '\\', $this_class ); $this_class = array_pop( $this_class ); $requester_class = '\Inc2734\WP_Share_Buttons\App\Model\Requester\\' . $this_class; if ( ! class_exists( $requester_class ) ) { return; } return $requester_class; }
php
protected function _get_requester() { $this_class = get_class( $this ); $this_class = explode( '\\', $this_class ); $this_class = array_pop( $this_class ); $requester_class = '\Inc2734\WP_Share_Buttons\App\Model\Requester\\' . $this_class; if ( ! class_exists( $requester_class ) ) { return; } return $requester_class; }
[ "protected", "function", "_get_requester", "(", ")", "{", "$", "this_class", "=", "get_class", "(", "$", "this", ")", ";", "$", "this_class", "=", "explode", "(", "'\\\\'", ",", "$", "this_class", ")", ";", "$", "this_class", "=", "array_pop", "(", "$", "this_class", ")", ";", "$", "requester_class", "=", "'\\Inc2734\\WP_Share_Buttons\\App\\Model\\Requester\\\\'", ".", "$", "this_class", ";", "if", "(", "!", "class_exists", "(", "$", "requester_class", ")", ")", "{", "return", ";", "}", "return", "$", "requester_class", ";", "}" ]
Return Requester class name @return string
[ "Return", "Requester", "class", "name" ]
cd032893ca083a343f5871e855cce68f4ede3a17
https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Contract/Shortcode/Button.php#L43-L54
17,349
factorio-item-browser/export-data
src/Registry/AbstractRegistry.php
AbstractRegistry.saveContent
protected function saveContent(string $hash, string $content): void { $this->adapter->save($this->namespace, $hash, $content); $this->cache[$hash] = $content; }
php
protected function saveContent(string $hash, string $content): void { $this->adapter->save($this->namespace, $hash, $content); $this->cache[$hash] = $content; }
[ "protected", "function", "saveContent", "(", "string", "$", "hash", ",", "string", "$", "content", ")", ":", "void", "{", "$", "this", "->", "adapter", "->", "save", "(", "$", "this", "->", "namespace", ",", "$", "hash", ",", "$", "content", ")", ";", "$", "this", "->", "cache", "[", "$", "hash", "]", "=", "$", "content", ";", "}" ]
Saves the specified content into the registry. @param string $hash @param string $content
[ "Saves", "the", "specified", "content", "into", "the", "registry", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/AbstractRegistry.php#L51-L55
17,350
factorio-item-browser/export-data
src/Registry/AbstractRegistry.php
AbstractRegistry.loadContent
protected function loadContent(string $hash): ?string { if (!array_key_exists($hash, $this->cache)) { $content = $this->adapter->load($this->namespace, $hash); $this->cache[$hash] = is_string($content) ? $content : null; } return $this->cache[$hash]; }
php
protected function loadContent(string $hash): ?string { if (!array_key_exists($hash, $this->cache)) { $content = $this->adapter->load($this->namespace, $hash); $this->cache[$hash] = is_string($content) ? $content : null; } return $this->cache[$hash]; }
[ "protected", "function", "loadContent", "(", "string", "$", "hash", ")", ":", "?", "string", "{", "if", "(", "!", "array_key_exists", "(", "$", "hash", ",", "$", "this", "->", "cache", ")", ")", "{", "$", "content", "=", "$", "this", "->", "adapter", "->", "load", "(", "$", "this", "->", "namespace", ",", "$", "hash", ")", ";", "$", "this", "->", "cache", "[", "$", "hash", "]", "=", "is_string", "(", "$", "content", ")", "?", "$", "content", ":", "null", ";", "}", "return", "$", "this", "->", "cache", "[", "$", "hash", "]", ";", "}" ]
Loads the content with the specified hash from the registry. @param string $hash @return string|null
[ "Loads", "the", "content", "with", "the", "specified", "hash", "from", "the", "registry", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/AbstractRegistry.php#L62-L69
17,351
factorio-item-browser/export-data
src/Registry/AbstractRegistry.php
AbstractRegistry.deleteContent
protected function deleteContent(string $hash): void { $this->adapter->delete($this->namespace, $hash); unset($this->cache[$hash]); }
php
protected function deleteContent(string $hash): void { $this->adapter->delete($this->namespace, $hash); unset($this->cache[$hash]); }
[ "protected", "function", "deleteContent", "(", "string", "$", "hash", ")", ":", "void", "{", "$", "this", "->", "adapter", "->", "delete", "(", "$", "this", "->", "namespace", ",", "$", "hash", ")", ";", "unset", "(", "$", "this", "->", "cache", "[", "$", "hash", "]", ")", ";", "}" ]
Deletes the content with the specified hash from the registry. @param string $hash
[ "Deletes", "the", "content", "with", "the", "specified", "hash", "from", "the", "registry", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/AbstractRegistry.php#L75-L79
17,352
factorio-item-browser/export-data
src/Registry/AbstractRegistry.php
AbstractRegistry.decodeContent
protected function decodeContent(string $content): array { $result = json_decode($content, true); return is_array($result) ? $result : []; }
php
protected function decodeContent(string $content): array { $result = json_decode($content, true); return is_array($result) ? $result : []; }
[ "protected", "function", "decodeContent", "(", "string", "$", "content", ")", ":", "array", "{", "$", "result", "=", "json_decode", "(", "$", "content", ",", "true", ")", ";", "return", "is_array", "(", "$", "result", ")", "?", "$", "result", ":", "[", "]", ";", "}" ]
Decodes the specified JSON content. @param string $content @return array
[ "Decodes", "the", "specified", "JSON", "content", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/AbstractRegistry.php#L96-L100
17,353
Ocramius/OcraDiCompiler
src/OcraDiCompiler/Definition/ClassListCompilerDefinition.php
ClassListCompilerDefinition.addClassToProcess
public function addClassToProcess($className) { if (!class_exists($className)) { return false; } $this->classesToProcess[(string) $className] = true; return true; }
php
public function addClassToProcess($className) { if (!class_exists($className)) { return false; } $this->classesToProcess[(string) $className] = true; return true; }
[ "public", "function", "addClassToProcess", "(", "$", "className", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "classesToProcess", "[", "(", "string", ")", "$", "className", "]", "=", "true", ";", "return", "true", ";", "}" ]
Adds a class to the list of classes to be processed @param string $className @return bool true if the class was added, false if the class does not exist
[ "Adds", "a", "class", "to", "the", "list", "of", "classes", "to", "be", "processed" ]
667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a
https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Definition/ClassListCompilerDefinition.php#L54-L62
17,354
amostajo/wordpress-plugin-core
src/psr4/Log.php
Log.instance
public static function instance() { if ( ! isset( self::$logger ) ) { self::$logger = new Logger( self::$path ); } return self::$logger; }
php
public static function instance() { if ( ! isset( self::$logger ) ) { self::$logger = new Logger( self::$path ); } return self::$logger; }
[ "public", "static", "function", "instance", "(", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "logger", ")", ")", "{", "self", "::", "$", "logger", "=", "new", "Logger", "(", "self", "::", "$", "path", ")", ";", "}", "return", "self", "::", "$", "logger", ";", "}" ]
Returns Logger instance. @since 1.0 @return mixed.
[ "Returns", "Logger", "instance", "." ]
63aba30b07057df540c3af4dc50b92bd5501d6fd
https://github.com/amostajo/wordpress-plugin-core/blob/63aba30b07057df540c3af4dc50b92bd5501d6fd/src/psr4/Log.php#L65-L71
17,355
xinix-technology/norm
src/Norm/Controller/NormController.php
NormController.getCriteria
public function getCriteria() { $gets = $this->request->get(); if (empty($this->routeData)) { $criteria = array(); } else { $criteria = $this->routeData; } foreach ($gets as $key => $value) { if ($key[0] !== '!') { $criteria[$key] = $value; } } $criteria = array_merge($criteria,$this->getOr()); return $criteria; }
php
public function getCriteria() { $gets = $this->request->get(); if (empty($this->routeData)) { $criteria = array(); } else { $criteria = $this->routeData; } foreach ($gets as $key => $value) { if ($key[0] !== '!') { $criteria[$key] = $value; } } $criteria = array_merge($criteria,$this->getOr()); return $criteria; }
[ "public", "function", "getCriteria", "(", ")", "{", "$", "gets", "=", "$", "this", "->", "request", "->", "get", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "routeData", ")", ")", "{", "$", "criteria", "=", "array", "(", ")", ";", "}", "else", "{", "$", "criteria", "=", "$", "this", "->", "routeData", ";", "}", "foreach", "(", "$", "gets", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "[", "0", "]", "!==", "'!'", ")", "{", "$", "criteria", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "$", "criteria", "=", "array_merge", "(", "$", "criteria", ",", "$", "this", "->", "getOr", "(", ")", ")", ";", "return", "$", "criteria", ";", "}" ]
Get criteria of current request @return array
[ "Get", "criteria", "of", "current", "request" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L63-L82
17,356
xinix-technology/norm
src/Norm/Controller/NormController.php
NormController.create
public function create() { $entry = $this->collection->newInstance()->set($this->getCriteria()); $this->data['entry'] = $entry; if ($this->request->isPost()) { try { $result = $entry->set($this->request->getBody())->save(); h('notification.info', $this->clazz.' created.'); h('controller.create.success', array( 'model' => $entry )); } catch (Stop $e) { throw $e; } catch (Exception $e) { // no more set notification.error since notificationmiddleware will // write this later // h('notification.error', $e); h('controller.create.error', array( 'model' => $entry, 'error' => $e, )); // rethrow error to make sure notificationmiddleware know what todo throw $e; } } }
php
public function create() { $entry = $this->collection->newInstance()->set($this->getCriteria()); $this->data['entry'] = $entry; if ($this->request->isPost()) { try { $result = $entry->set($this->request->getBody())->save(); h('notification.info', $this->clazz.' created.'); h('controller.create.success', array( 'model' => $entry )); } catch (Stop $e) { throw $e; } catch (Exception $e) { // no more set notification.error since notificationmiddleware will // write this later // h('notification.error', $e); h('controller.create.error', array( 'model' => $entry, 'error' => $e, )); // rethrow error to make sure notificationmiddleware know what todo throw $e; } } }
[ "public", "function", "create", "(", ")", "{", "$", "entry", "=", "$", "this", "->", "collection", "->", "newInstance", "(", ")", "->", "set", "(", "$", "this", "->", "getCriteria", "(", ")", ")", ";", "$", "this", "->", "data", "[", "'entry'", "]", "=", "$", "entry", ";", "if", "(", "$", "this", "->", "request", "->", "isPost", "(", ")", ")", "{", "try", "{", "$", "result", "=", "$", "entry", "->", "set", "(", "$", "this", "->", "request", "->", "getBody", "(", ")", ")", "->", "save", "(", ")", ";", "h", "(", "'notification.info'", ",", "$", "this", "->", "clazz", ".", "' created.'", ")", ";", "h", "(", "'controller.create.success'", ",", "array", "(", "'model'", "=>", "$", "entry", ")", ")", ";", "}", "catch", "(", "Stop", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "// no more set notification.error since notificationmiddleware will", "// write this later", "// h('notification.error', $e);", "h", "(", "'controller.create.error'", ",", "array", "(", "'model'", "=>", "$", "entry", ",", "'error'", "=>", "$", "e", ",", ")", ")", ";", "// rethrow error to make sure notificationmiddleware know what todo", "throw", "$", "e", ";", "}", "}", "}" ]
Handle creation of new document. @return void
[ "Handle", "creation", "of", "new", "document", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L189-L221
17,357
xinix-technology/norm
src/Norm/Controller/NormController.php
NormController.schema
public function schema($schema = null) { if (func_num_args() === 0) { return $this->collection->schema(); } return $this->collection->schema($schema); }
php
public function schema($schema = null) { if (func_num_args() === 0) { return $this->collection->schema(); } return $this->collection->schema($schema); }
[ "public", "function", "schema", "(", "$", "schema", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "===", "0", ")", "{", "return", "$", "this", "->", "collection", "->", "schema", "(", ")", ";", "}", "return", "$", "this", "->", "collection", "->", "schema", "(", "$", "schema", ")", ";", "}" ]
Get schema of collection @param string|null $schema @return mixed
[ "Get", "schema", "of", "collection" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L368-L375
17,358
xinix-technology/norm
src/Norm/Controller/NormController.php
NormController.routeModel
public function routeModel($key) { if (! isset($this->routeModels[$key])) { $Clazz = Inflector::classify($key); $collection = Norm::factory($this->schema($key)->get('foreign')); $this->routeModels[$key] = $collection->findOne($this->routeData($key)); } return $this->routeModels[$key]; }
php
public function routeModel($key) { if (! isset($this->routeModels[$key])) { $Clazz = Inflector::classify($key); $collection = Norm::factory($this->schema($key)->get('foreign')); $this->routeModels[$key] = $collection->findOne($this->routeData($key)); } return $this->routeModels[$key]; }
[ "public", "function", "routeModel", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "routeModels", "[", "$", "key", "]", ")", ")", "{", "$", "Clazz", "=", "Inflector", "::", "classify", "(", "$", "key", ")", ";", "$", "collection", "=", "Norm", "::", "factory", "(", "$", "this", "->", "schema", "(", "$", "key", ")", "->", "get", "(", "'foreign'", ")", ")", ";", "$", "this", "->", "routeModels", "[", "$", "key", "]", "=", "$", "collection", "->", "findOne", "(", "$", "this", "->", "routeData", "(", "$", "key", ")", ")", ";", "}", "return", "$", "this", "->", "routeModels", "[", "$", "key", "]", ";", "}" ]
Register a route model. @param string $key @return mixed
[ "Register", "a", "route", "model", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Controller/NormController.php#L396-L407
17,359
SachaMorard/phalcon-console
Library/Phalcon/Script.php
Script.dispatch
public function dispatch(Command $command) { // If beforeCommand fails abort if ($this->_eventsManager->fire('command:beforeCommand', $command) === false) { return false; } // If run the commands fails abort too if ($command->run($command->getParameters()) === false) { return false; } $this->_eventsManager->fire('command:afterCommand', $command); return true; }
php
public function dispatch(Command $command) { // If beforeCommand fails abort if ($this->_eventsManager->fire('command:beforeCommand', $command) === false) { return false; } // If run the commands fails abort too if ($command->run($command->getParameters()) === false) { return false; } $this->_eventsManager->fire('command:afterCommand', $command); return true; }
[ "public", "function", "dispatch", "(", "Command", "$", "command", ")", "{", "// If beforeCommand fails abort", "if", "(", "$", "this", "->", "_eventsManager", "->", "fire", "(", "'command:beforeCommand'", ",", "$", "command", ")", "===", "false", ")", "{", "return", "false", ";", "}", "// If run the commands fails abort too", "if", "(", "$", "command", "->", "run", "(", "$", "command", "->", "getParameters", "(", ")", ")", "===", "false", ")", "{", "return", "false", ";", "}", "$", "this", "->", "_eventsManager", "->", "fire", "(", "'command:afterCommand'", ",", "$", "command", ")", ";", "return", "true", ";", "}" ]
Dispatch the Command @param Command $command @return bool
[ "Dispatch", "the", "Command" ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Script.php#L108-L123
17,360
SachaMorard/phalcon-console
Library/Phalcon/Script.php
Script.run
public function run() { if (!isset($_SERVER['argv'][1])) { $_SERVER['argv'][1] = 'commands'; } $input = $_SERVER['argv'][1]; // Force `commands` command if (in_array(strtolower(trim($input)), ['-h', '--help', 'help'], true)) { $input = $_SERVER['argv'][1] = 'commands'; } if (in_array(strtolower(trim($input)), ['--version', '-v', '--info'], true)) { $input = $_SERVER['argv'][1] = 'info'; } // Try to dispatch the command foreach ($this->_commands as $command) { if ($command->hasIdentifier($input)) { return $this->dispatch($command); } } // Check for alternatives $available = []; foreach ($this->_commands as $command) { $providedCommands = $command->getCommands(); foreach ($providedCommands as $alias) { $soundex = soundex($alias); if (!isset($available[$soundex])) { $available[$soundex] = []; } $available[$soundex][] = $alias; } } // Show exception with/without alternatives $soundex = soundex($input); $message = sprintf('%s is not a recognized command.', $input); if (isset($available[$soundex])) { throw new ScriptException(sprintf('%s Did you mean: %s?', $message, join(' or ', $available[$soundex]))); } throw new ScriptException($message); }
php
public function run() { if (!isset($_SERVER['argv'][1])) { $_SERVER['argv'][1] = 'commands'; } $input = $_SERVER['argv'][1]; // Force `commands` command if (in_array(strtolower(trim($input)), ['-h', '--help', 'help'], true)) { $input = $_SERVER['argv'][1] = 'commands'; } if (in_array(strtolower(trim($input)), ['--version', '-v', '--info'], true)) { $input = $_SERVER['argv'][1] = 'info'; } // Try to dispatch the command foreach ($this->_commands as $command) { if ($command->hasIdentifier($input)) { return $this->dispatch($command); } } // Check for alternatives $available = []; foreach ($this->_commands as $command) { $providedCommands = $command->getCommands(); foreach ($providedCommands as $alias) { $soundex = soundex($alias); if (!isset($available[$soundex])) { $available[$soundex] = []; } $available[$soundex][] = $alias; } } // Show exception with/without alternatives $soundex = soundex($input); $message = sprintf('%s is not a recognized command.', $input); if (isset($available[$soundex])) { throw new ScriptException(sprintf('%s Did you mean: %s?', $message, join(' or ', $available[$soundex]))); } throw new ScriptException($message); }
[ "public", "function", "run", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "_SERVER", "[", "'argv'", "]", "[", "1", "]", ")", ")", "{", "$", "_SERVER", "[", "'argv'", "]", "[", "1", "]", "=", "'commands'", ";", "}", "$", "input", "=", "$", "_SERVER", "[", "'argv'", "]", "[", "1", "]", ";", "// Force `commands` command", "if", "(", "in_array", "(", "strtolower", "(", "trim", "(", "$", "input", ")", ")", ",", "[", "'-h'", ",", "'--help'", ",", "'help'", "]", ",", "true", ")", ")", "{", "$", "input", "=", "$", "_SERVER", "[", "'argv'", "]", "[", "1", "]", "=", "'commands'", ";", "}", "if", "(", "in_array", "(", "strtolower", "(", "trim", "(", "$", "input", ")", ")", ",", "[", "'--version'", ",", "'-v'", ",", "'--info'", "]", ",", "true", ")", ")", "{", "$", "input", "=", "$", "_SERVER", "[", "'argv'", "]", "[", "1", "]", "=", "'info'", ";", "}", "// Try to dispatch the command", "foreach", "(", "$", "this", "->", "_commands", "as", "$", "command", ")", "{", "if", "(", "$", "command", "->", "hasIdentifier", "(", "$", "input", ")", ")", "{", "return", "$", "this", "->", "dispatch", "(", "$", "command", ")", ";", "}", "}", "// Check for alternatives", "$", "available", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_commands", "as", "$", "command", ")", "{", "$", "providedCommands", "=", "$", "command", "->", "getCommands", "(", ")", ";", "foreach", "(", "$", "providedCommands", "as", "$", "alias", ")", "{", "$", "soundex", "=", "soundex", "(", "$", "alias", ")", ";", "if", "(", "!", "isset", "(", "$", "available", "[", "$", "soundex", "]", ")", ")", "{", "$", "available", "[", "$", "soundex", "]", "=", "[", "]", ";", "}", "$", "available", "[", "$", "soundex", "]", "[", "]", "=", "$", "alias", ";", "}", "}", "// Show exception with/without alternatives", "$", "soundex", "=", "soundex", "(", "$", "input", ")", ";", "$", "message", "=", "sprintf", "(", "'%s is not a recognized command.'", ",", "$", "input", ")", ";", "if", "(", "isset", "(", "$", "available", "[", "$", "soundex", "]", ")", ")", "{", "throw", "new", "ScriptException", "(", "sprintf", "(", "'%s Did you mean: %s?'", ",", "$", "message", ",", "join", "(", "' or '", ",", "$", "available", "[", "$", "soundex", "]", ")", ")", ")", ";", "}", "throw", "new", "ScriptException", "(", "$", "message", ")", ";", "}" ]
Run the scripts @throws ScriptException
[ "Run", "the", "scripts" ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Script.php#L130-L177
17,361
ClanCats/Core
src/bundles/Database/DB.php
DB.fetch
public static function fetch( $query, $params = array(), $handler = null, $arguments = array( 'obj' ) ) { return Handler::create( $handler )->fetch( $query, $params, $arguments ); }
php
public static function fetch( $query, $params = array(), $handler = null, $arguments = array( 'obj' ) ) { return Handler::create( $handler )->fetch( $query, $params, $arguments ); }
[ "public", "static", "function", "fetch", "(", "$", "query", ",", "$", "params", "=", "array", "(", ")", ",", "$", "handler", "=", "null", ",", "$", "arguments", "=", "array", "(", "'obj'", ")", ")", "{", "return", "Handler", "::", "create", "(", "$", "handler", ")", "->", "fetch", "(", "$", "query", ",", "$", "params", ",", "$", "arguments", ")", ";", "}" ]
Fetch data from an sql query Returns always an array of results @param string $query @param array $params @return array
[ "Fetch", "data", "from", "an", "sql", "query", "Returns", "always", "an", "array", "of", "results" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L86-L89
17,362
ClanCats/Core
src/bundles/Database/DB.php
DB.run
public static function run( $query, $params = array(), $handler = null ) { return Handler::create( $handler )->run( $query, $params ); }
php
public static function run( $query, $params = array(), $handler = null ) { return Handler::create( $handler )->run( $query, $params ); }
[ "public", "static", "function", "run", "(", "$", "query", ",", "$", "params", "=", "array", "(", ")", ",", "$", "handler", "=", "null", ")", "{", "return", "Handler", "::", "create", "(", "$", "handler", ")", "->", "run", "(", "$", "query", ",", "$", "params", ")", ";", "}" ]
Run an sql statement will return the number of affected rows @param string $query @param array $params @return mixed
[ "Run", "an", "sql", "statement", "will", "return", "the", "number", "of", "affected", "rows" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L98-L101
17,363
ClanCats/Core
src/bundles/Database/DB.php
DB.model
public static function model( $model, $handler = null ) { $model_data = call_user_func( $model.'::_model' ); return Query::select( $model_data['table'], null, $model_data['handler'] ) ->fetch_handler( $model.'::_fetch_handler' ); }
php
public static function model( $model, $handler = null ) { $model_data = call_user_func( $model.'::_model' ); return Query::select( $model_data['table'], null, $model_data['handler'] ) ->fetch_handler( $model.'::_fetch_handler' ); }
[ "public", "static", "function", "model", "(", "$", "model", ",", "$", "handler", "=", "null", ")", "{", "$", "model_data", "=", "call_user_func", "(", "$", "model", ".", "'::_model'", ")", ";", "return", "Query", "::", "select", "(", "$", "model_data", "[", "'table'", "]", ",", "null", ",", "$", "model_data", "[", "'handler'", "]", ")", "->", "fetch_handler", "(", "$", "model", ".", "'::_fetch_handler'", ")", ";", "}" ]
Create a select query with an model assignment @param string $table @param array $fields @return mixed
[ "Create", "a", "select", "query", "with", "an", "model", "assignment" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L122-L127
17,364
ClanCats/Core
src/bundles/Database/DB.php
DB.last
public static function last( $table, $key = null, $handler = null ) { return Query::select( $table )->last( $key, $handler ); }
php
public static function last( $table, $key = null, $handler = null ) { return Query::select( $table )->last( $key, $handler ); }
[ "public", "static", "function", "last", "(", "$", "table", ",", "$", "key", "=", "null", ",", "$", "handler", "=", "null", ")", "{", "return", "Query", "::", "select", "(", "$", "table", ")", "->", "last", "(", "$", "key", ",", "$", "handler", ")", ";", "}" ]
Get the last result by key @param string $table @param string $key @param string $handler @return mixed
[ "Get", "the", "last", "result", "by", "key" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L164-L167
17,365
ClanCats/Core
src/bundles/Database/DB.php
DB.insert
public static function insert( $table, $values = array(), $handler = null ) { return Query::insert( $table, $values, $handler ); }
php
public static function insert( $table, $values = array(), $handler = null ) { return Query::insert( $table, $values, $handler ); }
[ "public", "static", "function", "insert", "(", "$", "table", ",", "$", "values", "=", "array", "(", ")", ",", "$", "handler", "=", "null", ")", "{", "return", "Query", "::", "insert", "(", "$", "table", ",", "$", "values", ",", "$", "handler", ")", ";", "}" ]
Create an insert query object @param string $table @param array $data @return mixed
[ "Create", "an", "insert", "query", "object" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/DB.php#L188-L191
17,366
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/CustomerController.php
CustomerController.modalInfoAction
public function modalInfoAction($id) { /** @var Customer $oCustomer */ $oCustomer = CustomerQuery::create()->findOneById($id); return $this->render('SlashworksAppBundle:Customer:modal_info.html.twig', array( 'customer' => $oCustomer )); }
php
public function modalInfoAction($id) { /** @var Customer $oCustomer */ $oCustomer = CustomerQuery::create()->findOneById($id); return $this->render('SlashworksAppBundle:Customer:modal_info.html.twig', array( 'customer' => $oCustomer )); }
[ "public", "function", "modalInfoAction", "(", "$", "id", ")", "{", "/** @var Customer $oCustomer */", "$", "oCustomer", "=", "CustomerQuery", "::", "create", "(", ")", "->", "findOneById", "(", "$", "id", ")", ";", "return", "$", "this", "->", "render", "(", "'SlashworksAppBundle:Customer:modal_info.html.twig'", ",", "array", "(", "'customer'", "=>", "$", "oCustomer", ")", ")", ";", "}" ]
Modal info window for customerinformations @param int $id @return \Symfony\Component\HttpFoundation\Response
[ "Modal", "info", "window", "for", "customerinformations" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/CustomerController.php#L109-L119
17,367
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/CustomerController.php
CustomerController.newAction
public function newAction() { $oCustomer = new Customer(); $form = $this->createCreateForm($oCustomer); return $this->render('SlashworksAppBundle:Customer:new.html.twig', array( 'entity' => $oCustomer, 'form' => $form->createView(), )); }
php
public function newAction() { $oCustomer = new Customer(); $form = $this->createCreateForm($oCustomer); return $this->render('SlashworksAppBundle:Customer:new.html.twig', array( 'entity' => $oCustomer, 'form' => $form->createView(), )); }
[ "public", "function", "newAction", "(", ")", "{", "$", "oCustomer", "=", "new", "Customer", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "oCustomer", ")", ";", "return", "$", "this", "->", "render", "(", "'SlashworksAppBundle:Customer:new.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "oCustomer", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Displays a form to create a new Customer entity. @return \Symfony\Component\HttpFoundation\Response
[ "Displays", "a", "form", "to", "create", "a", "new", "Customer", "entity", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/CustomerController.php#L127-L137
17,368
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/CustomerController.php
CustomerController.editAction
public function editAction($id) { /** @var Customer $oCustomer */ $oCustomer = CustomerQuery::create()->findOneById($id); if (count($oCustomer) === 0) { throw $this->createNotFoundException('Unable to find Customer entity.'); } $oEditForm = $this->createEditForm($oCustomer); $oDeleteForm = $this->createDeleteForm($id); return $this->render('SlashworksAppBundle:Customer:edit.html.twig', array( 'entity' => $oCustomer, 'edit_form' => $oEditForm->createView(), 'delete_form' => $oDeleteForm->createView(), )); }
php
public function editAction($id) { /** @var Customer $oCustomer */ $oCustomer = CustomerQuery::create()->findOneById($id); if (count($oCustomer) === 0) { throw $this->createNotFoundException('Unable to find Customer entity.'); } $oEditForm = $this->createEditForm($oCustomer); $oDeleteForm = $this->createDeleteForm($id); return $this->render('SlashworksAppBundle:Customer:edit.html.twig', array( 'entity' => $oCustomer, 'edit_form' => $oEditForm->createView(), 'delete_form' => $oDeleteForm->createView(), )); }
[ "public", "function", "editAction", "(", "$", "id", ")", "{", "/** @var Customer $oCustomer */", "$", "oCustomer", "=", "CustomerQuery", "::", "create", "(", ")", "->", "findOneById", "(", "$", "id", ")", ";", "if", "(", "count", "(", "$", "oCustomer", ")", "===", "0", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Customer entity.'", ")", ";", "}", "$", "oEditForm", "=", "$", "this", "->", "createEditForm", "(", "$", "oCustomer", ")", ";", "$", "oDeleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "id", ")", ";", "return", "$", "this", "->", "render", "(", "'SlashworksAppBundle:Customer:edit.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "oCustomer", ",", "'edit_form'", "=>", "$", "oEditForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "oDeleteForm", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Displays a form to edit an existing Customer entity. @param int $id @return \Symfony\Component\HttpFoundation\Response
[ "Displays", "a", "form", "to", "edit", "an", "existing", "Customer", "entity", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/CustomerController.php#L147-L165
17,369
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/CustomerController.php
CustomerController.updateAction
public function updateAction(Request $request, $id) { /** @var Customer $oCustomer */ $oCustomer = CustomerQuery::create()->findOneById($id); if (count($oCustomer) === 0) { throw $this->createNotFoundException('Unable to find Customer entity.'); } $deleteForm = $this->createDeleteForm($id); $editForm = $this->createEditForm($oCustomer); $editForm->handleRequest($request); if ($editForm->isValid()) { $sLogoPath = $this->_handleLogoUpload($request, $oCustomer); $oCustomer->setLogo($sLogoPath); $oCustomer->save(); return $this->redirect($this->generateUrl('backend_system_customer')); } return $this->render('SlashworksAppBundle:Customer:edit.html.twig', array( 'entity' => $oCustomer, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), )); }
php
public function updateAction(Request $request, $id) { /** @var Customer $oCustomer */ $oCustomer = CustomerQuery::create()->findOneById($id); if (count($oCustomer) === 0) { throw $this->createNotFoundException('Unable to find Customer entity.'); } $deleteForm = $this->createDeleteForm($id); $editForm = $this->createEditForm($oCustomer); $editForm->handleRequest($request); if ($editForm->isValid()) { $sLogoPath = $this->_handleLogoUpload($request, $oCustomer); $oCustomer->setLogo($sLogoPath); $oCustomer->save(); return $this->redirect($this->generateUrl('backend_system_customer')); } return $this->render('SlashworksAppBundle:Customer:edit.html.twig', array( 'entity' => $oCustomer, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), )); }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "/** @var Customer $oCustomer */", "$", "oCustomer", "=", "CustomerQuery", "::", "create", "(", ")", "->", "findOneById", "(", "$", "id", ")", ";", "if", "(", "count", "(", "$", "oCustomer", ")", "===", "0", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Customer entity.'", ")", ";", "}", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "id", ")", ";", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "oCustomer", ")", ";", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "sLogoPath", "=", "$", "this", "->", "_handleLogoUpload", "(", "$", "request", ",", "$", "oCustomer", ")", ";", "$", "oCustomer", "->", "setLogo", "(", "$", "sLogoPath", ")", ";", "$", "oCustomer", "->", "save", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'backend_system_customer'", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'SlashworksAppBundle:Customer:edit.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "oCustomer", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Update existing customer @param \Symfony\Component\HttpFoundation\Request $request @param int $id @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
[ "Update", "existing", "customer" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/CustomerController.php#L176-L207
17,370
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/CustomerController.php
CustomerController._handleLogoUpload
private function _handleLogoUpload(Request &$request, Customer &$oCustomer) { $sLogoPath = ""; /** @var FileBag $t */ $oFiles = $request->files; $aFiles = $oFiles->get("slashworks_appbundle_customer"); $sUploadPath = __DIR__ . "/../../../../web/files/customers"; if (isset($aFiles['logo'])) { if (!empty($aFiles['logo'])) { /** @var UploadedFile $oUploadedFile */ $oUploadedFile = $aFiles['logo']; $sUniqId = sha1(uniqid(mt_rand(), true)); $sFileName = $sUniqId . '.' . $oUploadedFile->guessExtension(); $oUploadedFile->move($sUploadPath, $sFileName); $sLogoPath = $sFileName; } } return $sLogoPath; }
php
private function _handleLogoUpload(Request &$request, Customer &$oCustomer) { $sLogoPath = ""; /** @var FileBag $t */ $oFiles = $request->files; $aFiles = $oFiles->get("slashworks_appbundle_customer"); $sUploadPath = __DIR__ . "/../../../../web/files/customers"; if (isset($aFiles['logo'])) { if (!empty($aFiles['logo'])) { /** @var UploadedFile $oUploadedFile */ $oUploadedFile = $aFiles['logo']; $sUniqId = sha1(uniqid(mt_rand(), true)); $sFileName = $sUniqId . '.' . $oUploadedFile->guessExtension(); $oUploadedFile->move($sUploadPath, $sFileName); $sLogoPath = $sFileName; } } return $sLogoPath; }
[ "private", "function", "_handleLogoUpload", "(", "Request", "&", "$", "request", ",", "Customer", "&", "$", "oCustomer", ")", "{", "$", "sLogoPath", "=", "\"\"", ";", "/** @var FileBag $t */", "$", "oFiles", "=", "$", "request", "->", "files", ";", "$", "aFiles", "=", "$", "oFiles", "->", "get", "(", "\"slashworks_appbundle_customer\"", ")", ";", "$", "sUploadPath", "=", "__DIR__", ".", "\"/../../../../web/files/customers\"", ";", "if", "(", "isset", "(", "$", "aFiles", "[", "'logo'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "aFiles", "[", "'logo'", "]", ")", ")", "{", "/** @var UploadedFile $oUploadedFile */", "$", "oUploadedFile", "=", "$", "aFiles", "[", "'logo'", "]", ";", "$", "sUniqId", "=", "sha1", "(", "uniqid", "(", "mt_rand", "(", ")", ",", "true", ")", ")", ";", "$", "sFileName", "=", "$", "sUniqId", ".", "'.'", ".", "$", "oUploadedFile", "->", "guessExtension", "(", ")", ";", "$", "oUploadedFile", "->", "move", "(", "$", "sUploadPath", ",", "$", "sFileName", ")", ";", "$", "sLogoPath", "=", "$", "sFileName", ";", "}", "}", "return", "$", "sLogoPath", ";", "}" ]
Handle Logo uplaod @param \Symfony\Component\HttpFoundation\Request $request @param \Slashworks\AppBundle\Model\Customer $oCustomer @return string
[ "Handle", "Logo", "uplaod" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/CustomerController.php#L242-L267
17,371
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/CustomerController.php
CustomerController.createCreateForm
private function createCreateForm(Customer $oCustomer) { $form = $this->createForm(new CustomerType(array("language" => $this->get('request')->getLocale())), $oCustomer, array( 'action' => $this->generateUrl('backend_system_customer_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
private function createCreateForm(Customer $oCustomer) { $form = $this->createForm(new CustomerType(array("language" => $this->get('request')->getLocale())), $oCustomer, array( 'action' => $this->generateUrl('backend_system_customer_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
[ "private", "function", "createCreateForm", "(", "Customer", "$", "oCustomer", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "CustomerType", "(", "array", "(", "\"language\"", "=>", "$", "this", "->", "get", "(", "'request'", ")", "->", "getLocale", "(", ")", ")", ")", ",", "$", "oCustomer", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'backend_system_customer_create'", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Create'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to create a Customer entity. @param Customer $oCustomer The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "Customer", "entity", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/CustomerController.php#L277-L288
17,372
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/CustomerController.php
CustomerController.createEditForm
private function createEditForm(Customer $oCustomer) { $oForm = $this->createForm(new CustomerType(array("language" => $this->get('request')->getLocale())), $oCustomer, array( 'action' => $this->generateUrl('backend_system_customer_update', array('id' => $oCustomer->getId())), 'method' => 'PUT', )); $oForm->add('submit', 'submit', array('label' => 'Update')); return $oForm; }
php
private function createEditForm(Customer $oCustomer) { $oForm = $this->createForm(new CustomerType(array("language" => $this->get('request')->getLocale())), $oCustomer, array( 'action' => $this->generateUrl('backend_system_customer_update', array('id' => $oCustomer->getId())), 'method' => 'PUT', )); $oForm->add('submit', 'submit', array('label' => 'Update')); return $oForm; }
[ "private", "function", "createEditForm", "(", "Customer", "$", "oCustomer", ")", "{", "$", "oForm", "=", "$", "this", "->", "createForm", "(", "new", "CustomerType", "(", "array", "(", "\"language\"", "=>", "$", "this", "->", "get", "(", "'request'", ")", "->", "getLocale", "(", ")", ")", ")", ",", "$", "oCustomer", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'backend_system_customer_update'", ",", "array", "(", "'id'", "=>", "$", "oCustomer", "->", "getId", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "oForm", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Update'", ")", ")", ";", "return", "$", "oForm", ";", "}" ]
Create form for editing customer @param \Slashworks\AppBundle\Model\Customer $oCustomer @return \Symfony\Component\Form\Form
[ "Create", "form", "for", "editing", "customer" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/CustomerController.php#L298-L309
17,373
mremi/Flowdock
src/Mremi/Flowdock/Api/Push/Push.php
Push.sendMessage
protected function sendMessage(BaseMessageInterface $message, $baseUrl, array $options = array()) { $client = $this->createClient(sprintf('%s/%s', $baseUrl, $this->flowApiToken)); $response = $client->post(null, array_merge( $options, [ 'headers' => ['Content-Type' => 'application/json'], 'json' => $message->getData() ] )); $message->setResponse($response); return !$message->hasResponseErrors(); }
php
protected function sendMessage(BaseMessageInterface $message, $baseUrl, array $options = array()) { $client = $this->createClient(sprintf('%s/%s', $baseUrl, $this->flowApiToken)); $response = $client->post(null, array_merge( $options, [ 'headers' => ['Content-Type' => 'application/json'], 'json' => $message->getData() ] )); $message->setResponse($response); return !$message->hasResponseErrors(); }
[ "protected", "function", "sendMessage", "(", "BaseMessageInterface", "$", "message", ",", "$", "baseUrl", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "client", "=", "$", "this", "->", "createClient", "(", "sprintf", "(", "'%s/%s'", ",", "$", "baseUrl", ",", "$", "this", "->", "flowApiToken", ")", ")", ";", "$", "response", "=", "$", "client", "->", "post", "(", "null", ",", "array_merge", "(", "$", "options", ",", "[", "'headers'", "=>", "[", "'Content-Type'", "=>", "'application/json'", "]", ",", "'json'", "=>", "$", "message", "->", "getData", "(", ")", "]", ")", ")", ";", "$", "message", "->", "setResponse", "(", "$", "response", ")", ";", "return", "!", "$", "message", "->", "hasResponseErrors", "(", ")", ";", "}" ]
Sends a message to a flow @param BaseMessageInterface $message A message instance to send @param string $baseUrl A base URL @param array $options An array of options used by request @return boolean
[ "Sends", "a", "message", "to", "a", "flow" ]
287bfdcef17529055f803f2316e3ad31826e79eb
https://github.com/mremi/Flowdock/blob/287bfdcef17529055f803f2316e3ad31826e79eb/src/Mremi/Flowdock/Api/Push/Push.php#L66-L80
17,374
alanpich/slender
src/Core/ConfigFinder/ConfigFinder.php
ConfigFinder.findFiles
public function findFiles() { $search = (new Finder())->files(); // Add in paths foreach ($this->paths as $path) { if (is_readable($path)) { $search->in($path); } } // Add in names foreach ($this->files as $pattern) { $search->name($pattern); } $array = array(); foreach ($search as $f) { $array[] = $f->getRealPath(); } return $array; }
php
public function findFiles() { $search = (new Finder())->files(); // Add in paths foreach ($this->paths as $path) { if (is_readable($path)) { $search->in($path); } } // Add in names foreach ($this->files as $pattern) { $search->name($pattern); } $array = array(); foreach ($search as $f) { $array[] = $f->getRealPath(); } return $array; }
[ "public", "function", "findFiles", "(", ")", "{", "$", "search", "=", "(", "new", "Finder", "(", ")", ")", "->", "files", "(", ")", ";", "// Add in paths", "foreach", "(", "$", "this", "->", "paths", "as", "$", "path", ")", "{", "if", "(", "is_readable", "(", "$", "path", ")", ")", "{", "$", "search", "->", "in", "(", "$", "path", ")", ";", "}", "}", "// Add in names", "foreach", "(", "$", "this", "->", "files", "as", "$", "pattern", ")", "{", "$", "search", "->", "name", "(", "$", "pattern", ")", ";", "}", "$", "array", "=", "array", "(", ")", ";", "foreach", "(", "$", "search", "as", "$", "f", ")", "{", "$", "array", "[", "]", "=", "$", "f", "->", "getRealPath", "(", ")", ";", "}", "return", "$", "array", ";", "}" ]
Return an array of file paths to config files @return array of string paths
[ "Return", "an", "array", "of", "file", "paths", "to", "config", "files" ]
247f5c08af20cda95b116eb5d9f6f623d61e8a8a
https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/ConfigFinder/ConfigFinder.php#L54-L75
17,375
vi-kon/laravel-auth
src/ViKon/Auth/Model/User.php
User.hasRole
public function hasRole($role) { if (!$this->roles->where('token', $role)->isEmpty()) { return true; } foreach ($this->groups as $group) { if (!$group->roles->where('token', $role)->isEmpty()) { return true; } } return false; }
php
public function hasRole($role) { if (!$this->roles->where('token', $role)->isEmpty()) { return true; } foreach ($this->groups as $group) { if (!$group->roles->where('token', $role)->isEmpty()) { return true; } } return false; }
[ "public", "function", "hasRole", "(", "$", "role", ")", "{", "if", "(", "!", "$", "this", "->", "roles", "->", "where", "(", "'token'", ",", "$", "role", ")", "->", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "->", "groups", "as", "$", "group", ")", "{", "if", "(", "!", "$", "group", "->", "roles", "->", "where", "(", "'token'", ",", "$", "role", ")", "->", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if user has given role @param string $role @return bool
[ "Check", "if", "user", "has", "given", "role" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/Model/User.php#L167-L180
17,376
vi-kon/laravel-auth
src/ViKon/Auth/Model/User.php
User.hasPermission
public function hasPermission($permission) { if (!$this->permissions->where('token', $permission)->isEmpty()) { return true; } foreach ($this->groups as $group) { foreach ($group->roles as $role) { if (!$role->permissions->where('token', $permission)->isEmpty()) { return true; } } } foreach ($this->roles as $role) { if (!$role->permissions->where('token', $permission)->isEmpty()) { return true; } } return false; }
php
public function hasPermission($permission) { if (!$this->permissions->where('token', $permission)->isEmpty()) { return true; } foreach ($this->groups as $group) { foreach ($group->roles as $role) { if (!$role->permissions->where('token', $permission)->isEmpty()) { return true; } } } foreach ($this->roles as $role) { if (!$role->permissions->where('token', $permission)->isEmpty()) { return true; } } return false; }
[ "public", "function", "hasPermission", "(", "$", "permission", ")", "{", "if", "(", "!", "$", "this", "->", "permissions", "->", "where", "(", "'token'", ",", "$", "permission", ")", "->", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "->", "groups", "as", "$", "group", ")", "{", "foreach", "(", "$", "group", "->", "roles", "as", "$", "role", ")", "{", "if", "(", "!", "$", "role", "->", "permissions", "->", "where", "(", "'token'", ",", "$", "permission", ")", "->", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "}", "}", "foreach", "(", "$", "this", "->", "roles", "as", "$", "role", ")", "{", "if", "(", "!", "$", "role", "->", "permissions", "->", "where", "(", "'token'", ",", "$", "permission", ")", "->", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if user has given permission @param string $permission @return bool
[ "Check", "if", "user", "has", "given", "permission" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/Model/User.php#L189-L210
17,377
jenwachter/html-form
src/Elements/Parents/Field.php
Field.extractArgs
public function extractArgs($args) { foreach ($args as $k => $v) { if (property_exists($this, $k)) { $this->$k = $v; } else { throw new \InvalidArgumentException("{$k} is not a valid option."); } } }
php
public function extractArgs($args) { foreach ($args as $k => $v) { if (property_exists($this, $k)) { $this->$k = $v; } else { throw new \InvalidArgumentException("{$k} is not a valid option."); } } }
[ "public", "function", "extractArgs", "(", "$", "args", ")", "{", "foreach", "(", "$", "args", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "k", ")", ")", "{", "$", "this", "->", "$", "k", "=", "$", "v", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"{$k} is not a valid option.\"", ")", ";", "}", "}", "}" ]
Loops through a given array and it the key exists as a property on this object, it is assigned. @param array $args Associative array @return self
[ "Loops", "through", "a", "given", "array", "and", "it", "the", "key", "exists", "as", "a", "property", "on", "this", "object", "it", "is", "assigned", "." ]
eaece87d474f7da5c25679548fb8f1608a94303c
https://github.com/jenwachter/html-form/blob/eaece87d474f7da5c25679548fb8f1608a94303c/src/Elements/Parents/Field.php#L125-L134
17,378
jenwachter/html-form
src/Elements/Parents/Field.php
Field.getDisplayValue
public function getDisplayValue($formid = null) { if ($formid && isset($_SESSION[$formid][$this->name])) { $value = $_SESSION[$formid][$this->name]; } else if (isset($_POST[$this->name])) { $value = $_POST[$this->name]; } else { $value = $this->defaultValue; } return $this->cleanValue($value); }
php
public function getDisplayValue($formid = null) { if ($formid && isset($_SESSION[$formid][$this->name])) { $value = $_SESSION[$formid][$this->name]; } else if (isset($_POST[$this->name])) { $value = $_POST[$this->name]; } else { $value = $this->defaultValue; } return $this->cleanValue($value); }
[ "public", "function", "getDisplayValue", "(", "$", "formid", "=", "null", ")", "{", "if", "(", "$", "formid", "&&", "isset", "(", "$", "_SESSION", "[", "$", "formid", "]", "[", "$", "this", "->", "name", "]", ")", ")", "{", "$", "value", "=", "$", "_SESSION", "[", "$", "formid", "]", "[", "$", "this", "->", "name", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "_POST", "[", "$", "this", "->", "name", "]", ")", ")", "{", "$", "value", "=", "$", "_POST", "[", "$", "this", "->", "name", "]", ";", "}", "else", "{", "$", "value", "=", "$", "this", "->", "defaultValue", ";", "}", "return", "$", "this", "->", "cleanValue", "(", "$", "value", ")", ";", "}" ]
Get the value to display in the form field. Either the value in the session, post data, the default value, or nothing. @param string Form ID @return [type] [description]
[ "Get", "the", "value", "to", "display", "in", "the", "form", "field", ".", "Either", "the", "value", "in", "the", "session", "post", "data", "the", "default", "value", "or", "nothing", "." ]
eaece87d474f7da5c25679548fb8f1608a94303c
https://github.com/jenwachter/html-form/blob/eaece87d474f7da5c25679548fb8f1608a94303c/src/Elements/Parents/Field.php#L165-L176
17,379
jenwachter/html-form
src/Elements/Parents/Field.php
Field.cleanValue
protected function cleanValue($value) { if (is_array($value)) { return array_map(function ($v) { return $this->cleanValue($v); }, $value); } else { return stripslashes($value); } }
php
protected function cleanValue($value) { if (is_array($value)) { return array_map(function ($v) { return $this->cleanValue($v); }, $value); } else { return stripslashes($value); } }
[ "protected", "function", "cleanValue", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "array_map", "(", "function", "(", "$", "v", ")", "{", "return", "$", "this", "->", "cleanValue", "(", "$", "v", ")", ";", "}", ",", "$", "value", ")", ";", "}", "else", "{", "return", "stripslashes", "(", "$", "value", ")", ";", "}", "}" ]
Clean a value up for repopulation in a form field @param mixed $value String or array @return mixed
[ "Clean", "a", "value", "up", "for", "repopulation", "in", "a", "form", "field" ]
eaece87d474f7da5c25679548fb8f1608a94303c
https://github.com/jenwachter/html-form/blob/eaece87d474f7da5c25679548fb8f1608a94303c/src/Elements/Parents/Field.php#L183-L192
17,380
jenwachter/html-form
src/Elements/Parents/Field.php
Field.validate
public function validate() { $this->errors = array(); $value = $this->getRawValue(); if ($this->required) { $passed = $this->validateRequired($value); // don't do anymore validation until it passes the required validation if (!$passed) return $this->errors; // validate by field type $this->validateType($value); // validate by pattern, if defined $this->validatePattern($value); // validate by maxlength, if defined $this->validateMaxLength($value); // hook for users? } return $this->errors; }
php
public function validate() { $this->errors = array(); $value = $this->getRawValue(); if ($this->required) { $passed = $this->validateRequired($value); // don't do anymore validation until it passes the required validation if (!$passed) return $this->errors; // validate by field type $this->validateType($value); // validate by pattern, if defined $this->validatePattern($value); // validate by maxlength, if defined $this->validateMaxLength($value); // hook for users? } return $this->errors; }
[ "public", "function", "validate", "(", ")", "{", "$", "this", "->", "errors", "=", "array", "(", ")", ";", "$", "value", "=", "$", "this", "->", "getRawValue", "(", ")", ";", "if", "(", "$", "this", "->", "required", ")", "{", "$", "passed", "=", "$", "this", "->", "validateRequired", "(", "$", "value", ")", ";", "// don't do anymore validation until it passes the required validation", "if", "(", "!", "$", "passed", ")", "return", "$", "this", "->", "errors", ";", "// validate by field type", "$", "this", "->", "validateType", "(", "$", "value", ")", ";", "// validate by pattern, if defined", "$", "this", "->", "validatePattern", "(", "$", "value", ")", ";", "// validate by maxlength, if defined", "$", "this", "->", "validateMaxLength", "(", "$", "value", ")", ";", "// hook for users?", "}", "return", "$", "this", "->", "errors", ";", "}" ]
Validate a field @return boolean TRUE is valid; FALSE if invalid
[ "Validate", "a", "field" ]
eaece87d474f7da5c25679548fb8f1608a94303c
https://github.com/jenwachter/html-form/blob/eaece87d474f7da5c25679548fb8f1608a94303c/src/Elements/Parents/Field.php#L198-L224
17,381
jenwachter/html-form
src/Elements/Parents/Field.php
Field.validateMaxLength
public function validateMaxLength($value) { if (!isset($this->attr["maxlength"])) return true; $maxlength = trim($this->attr["maxlength"]); $length = strlen($value); if ($length > $maxlength) { $this->errors[] = "\"{$this->label}\" contains {$length} characters, but it is limited to {$maxlength} characters. Please shorten the length."; return false; } return true; }
php
public function validateMaxLength($value) { if (!isset($this->attr["maxlength"])) return true; $maxlength = trim($this->attr["maxlength"]); $length = strlen($value); if ($length > $maxlength) { $this->errors[] = "\"{$this->label}\" contains {$length} characters, but it is limited to {$maxlength} characters. Please shorten the length."; return false; } return true; }
[ "public", "function", "validateMaxLength", "(", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "attr", "[", "\"maxlength\"", "]", ")", ")", "return", "true", ";", "$", "maxlength", "=", "trim", "(", "$", "this", "->", "attr", "[", "\"maxlength\"", "]", ")", ";", "$", "length", "=", "strlen", "(", "$", "value", ")", ";", "if", "(", "$", "length", ">", "$", "maxlength", ")", "{", "$", "this", "->", "errors", "[", "]", "=", "\"\\\"{$this->label}\\\" contains {$length} characters, but it is limited to {$maxlength} characters. Please shorten the length.\"", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validates the maximum length of a form element. @param string $value Current value of form field @return boolean
[ "Validates", "the", "maximum", "length", "of", "a", "form", "element", "." ]
eaece87d474f7da5c25679548fb8f1608a94303c
https://github.com/jenwachter/html-form/blob/eaece87d474f7da5c25679548fb8f1608a94303c/src/Elements/Parents/Field.php#L248-L261
17,382
jenwachter/html-form
src/Elements/Parents/Field.php
Field.validatePattern
public function validatePattern($value) { if (!isset($this->attr["pattern"])) return true; $pattern = trim($this->attr["pattern"], "/"); if (!preg_match("/{$pattern}/", $value)) { $this->errors[] = "\"{$this->label}\" must match the specified pattern."; return false; } return true; }
php
public function validatePattern($value) { if (!isset($this->attr["pattern"])) return true; $pattern = trim($this->attr["pattern"], "/"); if (!preg_match("/{$pattern}/", $value)) { $this->errors[] = "\"{$this->label}\" must match the specified pattern."; return false; } return true; }
[ "public", "function", "validatePattern", "(", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "attr", "[", "\"pattern\"", "]", ")", ")", "return", "true", ";", "$", "pattern", "=", "trim", "(", "$", "this", "->", "attr", "[", "\"pattern\"", "]", ",", "\"/\"", ")", ";", "if", "(", "!", "preg_match", "(", "\"/{$pattern}/\"", ",", "$", "value", ")", ")", "{", "$", "this", "->", "errors", "[", "]", "=", "\"\\\"{$this->label}\\\" must match the specified pattern.\"", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validates a form element with a pattern attribute. @param string $label Form element label @param string $value Current value of form field @param string $element Form element object @return boolean TRUE if passed validation; FALSE if failed validation
[ "Validates", "a", "form", "element", "with", "a", "pattern", "attribute", "." ]
eaece87d474f7da5c25679548fb8f1608a94303c
https://github.com/jenwachter/html-form/blob/eaece87d474f7da5c25679548fb8f1608a94303c/src/Elements/Parents/Field.php#L282-L294
17,383
Double-Opt-in/php-client-api
src/Client/Commands/ActionsCommand.php
ActionsCommand.uri
public function uri(CryptographyEngine $cryptographyEngine) { $uri = parent::uri($cryptographyEngine); $params = array( 'hash' => $cryptographyEngine->hash($this->email), ); if (null !== $this->action) $params['action'] = $this->action; if (null !== $this->scope) $params['scope'] = $this->scope; $query = http_build_query($params); return $uri . (empty($query) ? '' : '?' . $query); }
php
public function uri(CryptographyEngine $cryptographyEngine) { $uri = parent::uri($cryptographyEngine); $params = array( 'hash' => $cryptographyEngine->hash($this->email), ); if (null !== $this->action) $params['action'] = $this->action; if (null !== $this->scope) $params['scope'] = $this->scope; $query = http_build_query($params); return $uri . (empty($query) ? '' : '?' . $query); }
[ "public", "function", "uri", "(", "CryptographyEngine", "$", "cryptographyEngine", ")", "{", "$", "uri", "=", "parent", "::", "uri", "(", "$", "cryptographyEngine", ")", ";", "$", "params", "=", "array", "(", "'hash'", "=>", "$", "cryptographyEngine", "->", "hash", "(", "$", "this", "->", "email", ")", ",", ")", ";", "if", "(", "null", "!==", "$", "this", "->", "action", ")", "$", "params", "[", "'action'", "]", "=", "$", "this", "->", "action", ";", "if", "(", "null", "!==", "$", "this", "->", "scope", ")", "$", "params", "[", "'scope'", "]", "=", "$", "this", "->", "scope", ";", "$", "query", "=", "http_build_query", "(", "$", "params", ")", ";", "return", "$", "uri", ".", "(", "empty", "(", "$", "query", ")", "?", "''", ":", "'?'", ".", "$", "query", ")", ";", "}" ]
returns query parameter hash: email will be hashed before requesting the server action: optional action will be transmitted in plain text scope: optional scope will be transmitted in plain text @param CryptographyEngine $cryptographyEngine @return string
[ "returns", "query", "parameter" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/ActionsCommand.php#L74-L91
17,384
Double-Opt-in/php-client-api
src/Client/Commands/ActionsCommand.php
ActionsCommand.response
public function response(Response $response, CryptographyEngine $cryptographyEngine) { $decryptedResponse = new DecryptedCommandResponse($response); $decryptedResponse->assignCryptographyEngine($cryptographyEngine, $this->email); return $decryptedResponse; }
php
public function response(Response $response, CryptographyEngine $cryptographyEngine) { $decryptedResponse = new DecryptedCommandResponse($response); $decryptedResponse->assignCryptographyEngine($cryptographyEngine, $this->email); return $decryptedResponse; }
[ "public", "function", "response", "(", "Response", "$", "response", ",", "CryptographyEngine", "$", "cryptographyEngine", ")", "{", "$", "decryptedResponse", "=", "new", "DecryptedCommandResponse", "(", "$", "response", ")", ";", "$", "decryptedResponse", "->", "assignCryptographyEngine", "(", "$", "cryptographyEngine", ",", "$", "this", "->", "email", ")", ";", "return", "$", "decryptedResponse", ";", "}" ]
creates a response from http response @param Response $response @param CryptographyEngine $cryptographyEngine @return DecryptedCommandResponse
[ "creates", "a", "response", "from", "http", "response" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/ActionsCommand.php#L113-L120
17,385
userfriendly/SocialUserBundle
Controller/ProfileController.php
ProfileController.usernameAvailableAction
public function usernameAvailableAction( Request $request ) { $response = array( 'cssClass' => 'success', 'text' => 'username is available', ); $user = $this->get( 'userfriendly_social_user.oauth_user_provider' ) ->findOneByUsernameSlug( $request->get( 'username_slug' )); $currentUser = $this->get( 'security.context' )->getToken()->getUser(); if ( $currentUser->getId() != $user->getId() && !$this->get( 'security.context' )->isGranted( 'ROLE_ADMIN' )) { throw new NotFoundHttpException(); } $requestedUsername = $request->get( 'username' ); $canonicalUsername = $this->get( 'fos_user.util.username_canonicalizer' )->canonicalize( $requestedUsername ); if ( $requestedUsername != $user->getUsername() ) { $users = $repo->findByUsernameCanonical( $canonicalUsername ); if ( count( $users ) > 0 ) { $response['cssClass'] = 'error'; $response['text'] = 'username not available'; } } return new Response( json_encode( $response )); }
php
public function usernameAvailableAction( Request $request ) { $response = array( 'cssClass' => 'success', 'text' => 'username is available', ); $user = $this->get( 'userfriendly_social_user.oauth_user_provider' ) ->findOneByUsernameSlug( $request->get( 'username_slug' )); $currentUser = $this->get( 'security.context' )->getToken()->getUser(); if ( $currentUser->getId() != $user->getId() && !$this->get( 'security.context' )->isGranted( 'ROLE_ADMIN' )) { throw new NotFoundHttpException(); } $requestedUsername = $request->get( 'username' ); $canonicalUsername = $this->get( 'fos_user.util.username_canonicalizer' )->canonicalize( $requestedUsername ); if ( $requestedUsername != $user->getUsername() ) { $users = $repo->findByUsernameCanonical( $canonicalUsername ); if ( count( $users ) > 0 ) { $response['cssClass'] = 'error'; $response['text'] = 'username not available'; } } return new Response( json_encode( $response )); }
[ "public", "function", "usernameAvailableAction", "(", "Request", "$", "request", ")", "{", "$", "response", "=", "array", "(", "'cssClass'", "=>", "'success'", ",", "'text'", "=>", "'username is available'", ",", ")", ";", "$", "user", "=", "$", "this", "->", "get", "(", "'userfriendly_social_user.oauth_user_provider'", ")", "->", "findOneByUsernameSlug", "(", "$", "request", "->", "get", "(", "'username_slug'", ")", ")", ";", "$", "currentUser", "=", "$", "this", "->", "get", "(", "'security.context'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "$", "currentUser", "->", "getId", "(", ")", "!=", "$", "user", "->", "getId", "(", ")", "&&", "!", "$", "this", "->", "get", "(", "'security.context'", ")", "->", "isGranted", "(", "'ROLE_ADMIN'", ")", ")", "{", "throw", "new", "NotFoundHttpException", "(", ")", ";", "}", "$", "requestedUsername", "=", "$", "request", "->", "get", "(", "'username'", ")", ";", "$", "canonicalUsername", "=", "$", "this", "->", "get", "(", "'fos_user.util.username_canonicalizer'", ")", "->", "canonicalize", "(", "$", "requestedUsername", ")", ";", "if", "(", "$", "requestedUsername", "!=", "$", "user", "->", "getUsername", "(", ")", ")", "{", "$", "users", "=", "$", "repo", "->", "findByUsernameCanonical", "(", "$", "canonicalUsername", ")", ";", "if", "(", "count", "(", "$", "users", ")", ">", "0", ")", "{", "$", "response", "[", "'cssClass'", "]", "=", "'error'", ";", "$", "response", "[", "'text'", "]", "=", "'username not available'", ";", "}", "}", "return", "new", "Response", "(", "json_encode", "(", "$", "response", ")", ")", ";", "}" ]
AJAX action for checking username availability @param \Symfony\Component\HttpFoundation\Request $request @return \Symfony\Component\HttpFoundation\Response
[ "AJAX", "action", "for", "checking", "username", "availability" ]
1dfcf76af2bc639901c471e6f28b04d73fb65452
https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/Controller/ProfileController.php#L131-L156
17,386
userfriendly/SocialUserBundle
Controller/ProfileController.php
ProfileController.showAndEdit
private function showAndEdit( Request $request, $action ) { $user = $this->get( 'userfriendly_social_user.oauth_user_provider' ) ->findOneByUsernameSlug( $request->get( 'username_slug' )); if ( $user ) { $currentUser = $this->get( 'security.context' )->getToken()->getUser(); if ( self::SHOW == $action || $currentUser->getId() == $user->getId() || $this->get( 'security.context' )->isGranted( 'ROLE_ADMIN' ) ) { return $this->render( 'UserfriendlySocialUserBundle:Profile:' . $action . '.html.twig', array( 'user' => $user, )); } throw new AccessDeniedException(); } throw new NotFoundHttpException(); }
php
private function showAndEdit( Request $request, $action ) { $user = $this->get( 'userfriendly_social_user.oauth_user_provider' ) ->findOneByUsernameSlug( $request->get( 'username_slug' )); if ( $user ) { $currentUser = $this->get( 'security.context' )->getToken()->getUser(); if ( self::SHOW == $action || $currentUser->getId() == $user->getId() || $this->get( 'security.context' )->isGranted( 'ROLE_ADMIN' ) ) { return $this->render( 'UserfriendlySocialUserBundle:Profile:' . $action . '.html.twig', array( 'user' => $user, )); } throw new AccessDeniedException(); } throw new NotFoundHttpException(); }
[ "private", "function", "showAndEdit", "(", "Request", "$", "request", ",", "$", "action", ")", "{", "$", "user", "=", "$", "this", "->", "get", "(", "'userfriendly_social_user.oauth_user_provider'", ")", "->", "findOneByUsernameSlug", "(", "$", "request", "->", "get", "(", "'username_slug'", ")", ")", ";", "if", "(", "$", "user", ")", "{", "$", "currentUser", "=", "$", "this", "->", "get", "(", "'security.context'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "self", "::", "SHOW", "==", "$", "action", "||", "$", "currentUser", "->", "getId", "(", ")", "==", "$", "user", "->", "getId", "(", ")", "||", "$", "this", "->", "get", "(", "'security.context'", ")", "->", "isGranted", "(", "'ROLE_ADMIN'", ")", ")", "{", "return", "$", "this", "->", "render", "(", "'UserfriendlySocialUserBundle:Profile:'", ".", "$", "action", ".", "'.html.twig'", ",", "array", "(", "'user'", "=>", "$", "user", ",", ")", ")", ";", "}", "throw", "new", "AccessDeniedException", "(", ")", ";", "}", "throw", "new", "NotFoundHttpException", "(", ")", ";", "}" ]
Private methods for use in this Controller's public methods
[ "Private", "methods", "for", "use", "in", "this", "Controller", "s", "public", "methods" ]
1dfcf76af2bc639901c471e6f28b04d73fb65452
https://github.com/userfriendly/SocialUserBundle/blob/1dfcf76af2bc639901c471e6f28b04d73fb65452/Controller/ProfileController.php#L162-L182
17,387
FuriosoJack/LaraException
src/Controllers/BasicController.php
BasicController.laraException
public function laraException(Request $request) { $storage = Storage::disk('local'); $fileName = base64_decode(urldecode($request->get('errors'))); if(!$storage->exists($fileName)){ $info = null; }else{ $info = $storage->get($fileName); } $view = self::VIEW_DEFAULT; // $info = $request->cookie('lara_exception_code'); $errors =[]; if(is_null($info)){ $errors = [ 'details' => '', 'message' => 'LaraException', 'debugCode' => '0', 'errors' => [], 'routeBack' => '' ]; }else{ //$urlEncode = \Crypt::decrypt($info); //\Cookie::forget('lara_exception_code'); ///$urlEncode = urldecode($info); $storage->delete($fileName); $data = json_decode(base64_decode($info),true); $errors = $data['errors']; $view = $data['view']; } return view($view,$errors); }
php
public function laraException(Request $request) { $storage = Storage::disk('local'); $fileName = base64_decode(urldecode($request->get('errors'))); if(!$storage->exists($fileName)){ $info = null; }else{ $info = $storage->get($fileName); } $view = self::VIEW_DEFAULT; // $info = $request->cookie('lara_exception_code'); $errors =[]; if(is_null($info)){ $errors = [ 'details' => '', 'message' => 'LaraException', 'debugCode' => '0', 'errors' => [], 'routeBack' => '' ]; }else{ //$urlEncode = \Crypt::decrypt($info); //\Cookie::forget('lara_exception_code'); ///$urlEncode = urldecode($info); $storage->delete($fileName); $data = json_decode(base64_decode($info),true); $errors = $data['errors']; $view = $data['view']; } return view($view,$errors); }
[ "public", "function", "laraException", "(", "Request", "$", "request", ")", "{", "$", "storage", "=", "Storage", "::", "disk", "(", "'local'", ")", ";", "$", "fileName", "=", "base64_decode", "(", "urldecode", "(", "$", "request", "->", "get", "(", "'errors'", ")", ")", ")", ";", "if", "(", "!", "$", "storage", "->", "exists", "(", "$", "fileName", ")", ")", "{", "$", "info", "=", "null", ";", "}", "else", "{", "$", "info", "=", "$", "storage", "->", "get", "(", "$", "fileName", ")", ";", "}", "$", "view", "=", "self", "::", "VIEW_DEFAULT", ";", "// $info = $request->cookie('lara_exception_code');", "$", "errors", "=", "[", "]", ";", "if", "(", "is_null", "(", "$", "info", ")", ")", "{", "$", "errors", "=", "[", "'details'", "=>", "''", ",", "'message'", "=>", "'LaraException'", ",", "'debugCode'", "=>", "'0'", ",", "'errors'", "=>", "[", "]", ",", "'routeBack'", "=>", "''", "]", ";", "}", "else", "{", "//$urlEncode = \\Crypt::decrypt($info);", "//\\Cookie::forget('lara_exception_code');", "///$urlEncode = urldecode($info);", "$", "storage", "->", "delete", "(", "$", "fileName", ")", ";", "$", "data", "=", "json_decode", "(", "base64_decode", "(", "$", "info", ")", ",", "true", ")", ";", "$", "errors", "=", "$", "data", "[", "'errors'", "]", ";", "$", "view", "=", "$", "data", "[", "'view'", "]", ";", "}", "return", "view", "(", "$", "view", ",", "$", "errors", ")", ";", "}" ]
Controlador encargado de validar que debe retornar si la vista o el response JSON @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
[ "Controlador", "encargado", "de", "validar", "que", "debe", "retornar", "si", "la", "vista", "o", "el", "response", "JSON" ]
b30ec2ed3331d99fca4d0ae47c8710a522bd0c19
https://github.com/FuriosoJack/LaraException/blob/b30ec2ed3331d99fca4d0ae47c8710a522bd0c19/src/Controllers/BasicController.php#L31-L67
17,388
CakeCMS/Core
src/ORM/Behavior/CachedBehavior.php
CachedBehavior.initialize
public function initialize(array $config) { $config = Hash::merge($this->_defaultConfig, $config); $this->setConfig($config); }
php
public function initialize(array $config) { $config = Hash::merge($this->_defaultConfig, $config); $this->setConfig($config); }
[ "public", "function", "initialize", "(", "array", "$", "config", ")", "{", "$", "config", "=", "Hash", "::", "merge", "(", "$", "this", "->", "_defaultConfig", ",", "$", "config", ")", ";", "$", "this", "->", "setConfig", "(", "$", "config", ")", ";", "}" ]
Initialize hook. @param array $config The config for this behavior. @return void
[ "Initialize", "hook", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/ORM/Behavior/CachedBehavior.php#L49-L53
17,389
CakeCMS/Core
src/ORM/Behavior/CachedBehavior.php
CachedBehavior._clearCacheGroup
protected function _clearCacheGroup() { $cacheGroups = (array) $this->getConfig('groups'); foreach ($cacheGroups as $group) { Cache::clearGroup($group, $this->getConfig('config')); } }
php
protected function _clearCacheGroup() { $cacheGroups = (array) $this->getConfig('groups'); foreach ($cacheGroups as $group) { Cache::clearGroup($group, $this->getConfig('config')); } }
[ "protected", "function", "_clearCacheGroup", "(", ")", "{", "$", "cacheGroups", "=", "(", "array", ")", "$", "this", "->", "getConfig", "(", "'groups'", ")", ";", "foreach", "(", "$", "cacheGroups", "as", "$", "group", ")", "{", "Cache", "::", "clearGroup", "(", "$", "group", ",", "$", "this", "->", "getConfig", "(", "'config'", ")", ")", ";", "}", "}" ]
Clear cache group. @return void
[ "Clear", "cache", "group", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/ORM/Behavior/CachedBehavior.php#L86-L92
17,390
Kylob/Bootstrap
src/Common.php
Common.lister
public function lister($tag, array $list) { $html = ''; $class = ''; if ($space = strpos($tag, ' ')) { $class = trim(substr($tag, $space)); $tag = substr($tag, 0, $space); } foreach ($list as $key => $value) { if ($tag == 'dl') { $html .= '<dt>'.$key.'</dt>'; $html .= '<dd>'.(is_array($value) ? implode('</dd><dd>', $value) : $value).'</dd>'; } else { $html .= '<li>'.(is_array($value) ? $key.$this->lister($tag, $value) : $value).'</li>'; } } return $this->page->tag($tag, array('class' => $class), $html); }
php
public function lister($tag, array $list) { $html = ''; $class = ''; if ($space = strpos($tag, ' ')) { $class = trim(substr($tag, $space)); $tag = substr($tag, 0, $space); } foreach ($list as $key => $value) { if ($tag == 'dl') { $html .= '<dt>'.$key.'</dt>'; $html .= '<dd>'.(is_array($value) ? implode('</dd><dd>', $value) : $value).'</dd>'; } else { $html .= '<li>'.(is_array($value) ? $key.$this->lister($tag, $value) : $value).'</li>'; } } return $this->page->tag($tag, array('class' => $class), $html); }
[ "public", "function", "lister", "(", "$", "tag", ",", "array", "$", "list", ")", "{", "$", "html", "=", "''", ";", "$", "class", "=", "''", ";", "if", "(", "$", "space", "=", "strpos", "(", "$", "tag", ",", "' '", ")", ")", "{", "$", "class", "=", "trim", "(", "substr", "(", "$", "tag", ",", "$", "space", ")", ")", ";", "$", "tag", "=", "substr", "(", "$", "tag", ",", "0", ",", "$", "space", ")", ";", "}", "foreach", "(", "$", "list", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "tag", "==", "'dl'", ")", "{", "$", "html", ".=", "'<dt>'", ".", "$", "key", ".", "'</dt>'", ";", "$", "html", ".=", "'<dd>'", ".", "(", "is_array", "(", "$", "value", ")", "?", "implode", "(", "'</dd><dd>'", ",", "$", "value", ")", ":", "$", "value", ")", ".", "'</dd>'", ";", "}", "else", "{", "$", "html", ".=", "'<li>'", ".", "(", "is_array", "(", "$", "value", ")", "?", "$", "key", ".", "$", "this", "->", "lister", "(", "$", "tag", ",", "$", "value", ")", ":", "$", "value", ")", ".", "'</li>'", ";", "}", "}", "return", "$", "this", "->", "page", "->", "tag", "(", "$", "tag", ",", "array", "(", "'class'", "=>", "$", "class", ")", ",", "$", "html", ")", ";", "}" ]
This assists you in making Ordered, Unordered, and Definition lists. It is especially useful when you are nesting lists within lists. Your code almost looks exactly like you would expect to see it on the big screen. It would have been nice if we could have named this method 'list', but someone has taken that already. @param string $tag Either an '**ol**' (Ordered list), '**ul**' (Unordered list), or a '**dl**' (Definition list). You can add any other classes you like (or not), but the special ones that Bootstrap has blessed us with are: - '**list-inline**' - For an unordered list to be displayed horizontally. - '**list-unstyled**' - For an unordered list to be unbulleted. - '**dl-horizontal**' - For a definition to be displayed beside it's title rather than below. @param array $list For Ordered and Unordered lists this is an ``array($li, $li, ...)``, and to nest another list just make the ``$li`` another array. For Definition Lists this is an ``array($title => $definition, ...)``. If you have multiple ``$definition``'s, then just make ``$title`` an array of them. @return string @example ```php echo $bp->lister('ol', array( 'Coffee', 'Tea' => array( 'Black tea', 'Green tea', ), 'Milk', )); echo $bp->lister('ul list-inline', array( 'Coffee', 'Tea', 'Milk', )); echo $bp->lister('dl dl-horizontal', array( 'Coffee' => array( 'Black hot drink', 'Caffeinated beverage', ), 'Milk' => 'White cold drink', )); ```
[ "This", "assists", "you", "in", "making", "Ordered", "Unordered", "and", "Definition", "lists", ".", "It", "is", "especially", "useful", "when", "you", "are", "nesting", "lists", "within", "lists", ".", "Your", "code", "almost", "looks", "exactly", "like", "you", "would", "expect", "to", "see", "it", "on", "the", "big", "screen", ".", "It", "would", "have", "been", "nice", "if", "we", "could", "have", "named", "this", "method", "list", "but", "someone", "has", "taken", "that", "already", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L172-L190
17,391
Kylob/Bootstrap
src/Common.php
Common.search
public function search($url, array $form = array()) { $html = ''; $form = array_merge(array( 'name' => 'search', 'role' => 'search', 'class' => 'form-horizontal', 'placeholder' => 'Search', 'button' => $this->icon('search'), 'size' => '', ), $form); $form['method'] = 'get'; $form['action'] = $url; $input = array('class' => 'form-control', 'placeholder' => $form['placeholder']); $button = $form['button']; $size = $form['size']; unset($form['placeholder'], $form['button'], $form['size']); $form = new BPForm($form); $form->validator->set($form->header['name'], 'required'); if (!empty($button)) { if (strpos($button, '<button') === false) { $button = '<button type="submit" class="btn btn-default" title="Search">'.$button.'</button>'; } $html .= '<div class="'.$this->prefixClasses('input-group', array('sm', 'md', 'lg'), $size).'">'; $html .= $form->text($form->header['name'], $input); $html .= '<div class="input-group-btn">'.$button.'</div>'; $html .= '</div>'; } else { if (!empty($size) && in_array($size, array('sm', 'md', 'lg'))) { $input['class'] .= " input-{$size}"; } $html .= $form->text($form->header['name'], $input); } return $form->header().$html.$form->close(); }
php
public function search($url, array $form = array()) { $html = ''; $form = array_merge(array( 'name' => 'search', 'role' => 'search', 'class' => 'form-horizontal', 'placeholder' => 'Search', 'button' => $this->icon('search'), 'size' => '', ), $form); $form['method'] = 'get'; $form['action'] = $url; $input = array('class' => 'form-control', 'placeholder' => $form['placeholder']); $button = $form['button']; $size = $form['size']; unset($form['placeholder'], $form['button'], $form['size']); $form = new BPForm($form); $form->validator->set($form->header['name'], 'required'); if (!empty($button)) { if (strpos($button, '<button') === false) { $button = '<button type="submit" class="btn btn-default" title="Search">'.$button.'</button>'; } $html .= '<div class="'.$this->prefixClasses('input-group', array('sm', 'md', 'lg'), $size).'">'; $html .= $form->text($form->header['name'], $input); $html .= '<div class="input-group-btn">'.$button.'</div>'; $html .= '</div>'; } else { if (!empty($size) && in_array($size, array('sm', 'md', 'lg'))) { $input['class'] .= " input-{$size}"; } $html .= $form->text($form->header['name'], $input); } return $form->header().$html.$form->close(); }
[ "public", "function", "search", "(", "$", "url", ",", "array", "$", "form", "=", "array", "(", ")", ")", "{", "$", "html", "=", "''", ";", "$", "form", "=", "array_merge", "(", "array", "(", "'name'", "=>", "'search'", ",", "'role'", "=>", "'search'", ",", "'class'", "=>", "'form-horizontal'", ",", "'placeholder'", "=>", "'Search'", ",", "'button'", "=>", "$", "this", "->", "icon", "(", "'search'", ")", ",", "'size'", "=>", "''", ",", ")", ",", "$", "form", ")", ";", "$", "form", "[", "'method'", "]", "=", "'get'", ";", "$", "form", "[", "'action'", "]", "=", "$", "url", ";", "$", "input", "=", "array", "(", "'class'", "=>", "'form-control'", ",", "'placeholder'", "=>", "$", "form", "[", "'placeholder'", "]", ")", ";", "$", "button", "=", "$", "form", "[", "'button'", "]", ";", "$", "size", "=", "$", "form", "[", "'size'", "]", ";", "unset", "(", "$", "form", "[", "'placeholder'", "]", ",", "$", "form", "[", "'button'", "]", ",", "$", "form", "[", "'size'", "]", ")", ";", "$", "form", "=", "new", "BPForm", "(", "$", "form", ")", ";", "$", "form", "->", "validator", "->", "set", "(", "$", "form", "->", "header", "[", "'name'", "]", ",", "'required'", ")", ";", "if", "(", "!", "empty", "(", "$", "button", ")", ")", "{", "if", "(", "strpos", "(", "$", "button", ",", "'<button'", ")", "===", "false", ")", "{", "$", "button", "=", "'<button type=\"submit\" class=\"btn btn-default\" title=\"Search\">'", ".", "$", "button", ".", "'</button>'", ";", "}", "$", "html", ".=", "'<div class=\"'", ".", "$", "this", "->", "prefixClasses", "(", "'input-group'", ",", "array", "(", "'sm'", ",", "'md'", ",", "'lg'", ")", ",", "$", "size", ")", ".", "'\">'", ";", "$", "html", ".=", "$", "form", "->", "text", "(", "$", "form", "->", "header", "[", "'name'", "]", ",", "$", "input", ")", ";", "$", "html", ".=", "'<div class=\"input-group-btn\">'", ".", "$", "button", ".", "'</div>'", ";", "$", "html", ".=", "'</div>'", ";", "}", "else", "{", "if", "(", "!", "empty", "(", "$", "size", ")", "&&", "in_array", "(", "$", "size", ",", "array", "(", "'sm'", ",", "'md'", ",", "'lg'", ")", ")", ")", "{", "$", "input", "[", "'class'", "]", ".=", "\" input-{$size}\"", ";", "}", "$", "html", ".=", "$", "form", "->", "text", "(", "$", "form", "->", "header", "[", "'name'", "]", ",", "$", "input", ")", ";", "}", "return", "$", "form", "->", "header", "(", ")", ".", "$", "html", ".", "$", "form", "->", "close", "(", ")", ";", "}" ]
This will assist you in creating a search bar for your site. @param string $url This is the url that you would like the search term to be sent to @param array $form To customize the form, you can submit an array with any of the following keys: - '**name**' - The name of the input field. The default is '**search**'. - '**placeholder**' - Subtle text to indicate what sort of field it is. The default is '**Search**'. - '**button**' - The button itself with tags and all, or just a name. The default is ``$bp->icon('search')``. - If you don't want a button at all then just give this an empty value. - '**class**' - Any special class(es) to give the ``<form>`` tag. The default is '**form-horizontal**'. - '**size**' - Either '**sm**', '**md**' (the default), or '**lg**'. @return string @example ```php echo $bp->search('http://example.com'); ```
[ "This", "will", "assist", "you", "in", "creating", "a", "search", "bar", "for", "your", "site", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L213-L248
17,392
Kylob/Bootstrap
src/Common.php
Common.icon
public function icon($symbol, $prefix = 'glyphicon', $tag = 'i') { $base = $prefix; $classes = explode(' ', $symbol); $prefix = array($classes[0]); // ie. only prefix the first class $params = ''; if ($space = strpos($tag, ' ')) { $params = ' '.trim(substr($tag, $space)); $tag = substr($tag, 0, $space); } if ($base == 'glyphicon') { $tag = 'span'; } return $this->addClass("<{$tag}{$params}></{$tag}>", array( $tag => $this->prefixClasses($base, $prefix, $classes), )); }
php
public function icon($symbol, $prefix = 'glyphicon', $tag = 'i') { $base = $prefix; $classes = explode(' ', $symbol); $prefix = array($classes[0]); // ie. only prefix the first class $params = ''; if ($space = strpos($tag, ' ')) { $params = ' '.trim(substr($tag, $space)); $tag = substr($tag, 0, $space); } if ($base == 'glyphicon') { $tag = 'span'; } return $this->addClass("<{$tag}{$params}></{$tag}>", array( $tag => $this->prefixClasses($base, $prefix, $classes), )); }
[ "public", "function", "icon", "(", "$", "symbol", ",", "$", "prefix", "=", "'glyphicon'", ",", "$", "tag", "=", "'i'", ")", "{", "$", "base", "=", "$", "prefix", ";", "$", "classes", "=", "explode", "(", "' '", ",", "$", "symbol", ")", ";", "$", "prefix", "=", "array", "(", "$", "classes", "[", "0", "]", ")", ";", "// ie. only prefix the first class", "$", "params", "=", "''", ";", "if", "(", "$", "space", "=", "strpos", "(", "$", "tag", ",", "' '", ")", ")", "{", "$", "params", "=", "' '", ".", "trim", "(", "substr", "(", "$", "tag", ",", "$", "space", ")", ")", ";", "$", "tag", "=", "substr", "(", "$", "tag", ",", "0", ",", "$", "space", ")", ";", "}", "if", "(", "$", "base", "==", "'glyphicon'", ")", "{", "$", "tag", "=", "'span'", ";", "}", "return", "$", "this", "->", "addClass", "(", "\"<{$tag}{$params}></{$tag}>\"", ",", "array", "(", "$", "tag", "=>", "$", "this", "->", "prefixClasses", "(", "$", "base", ",", "$", "prefix", ",", "$", "classes", ")", ",", ")", ")", ";", "}" ]
Create an icon without the verbosity. @param string $symbol The icon you would like to display without the base and icon class prefix. @param string $prefix The base and icon class prefix. The default is a Bootstrap icon, but this can be used with any icon font by simply entering their prefix value here. @param string $tag The tag to use for displaying your font. Everyone uses the ``<i>`` tag, so that is the default. If ``$prefix == 'glyphicon'`` (the default for Bootstrap) then we will use a span element. Why? I don't know, but since v.2 that seems to be what they prefer to use now. If you want to style an icon further then you can do so here. eg. ``'i style="font-size:16px;"'``. @return string @example ```php echo $bp->icon('asterisk'); ```
[ "Create", "an", "icon", "without", "the", "verbosity", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L309-L326
17,393
Kylob/Bootstrap
src/Common.php
Common.button
public function button($class, $name, array $options = array()) { $attributes = array('type' => 'button'); foreach ($options as $key => $value) { if (!in_array($key, array('dropdown', 'dropup', 'active', 'disabled', 'pull'))) { $attributes[$key] = $value; } } $attributes['class'] = $this->prefixClasses('btn', array('block', 'xs', 'sm', 'lg', 'default', 'primary', 'success', 'info', 'warning', 'danger', 'link'), $class); if (isset($options['dropdown']) || isset($options['dropup'])) { $html = ''; unset($attributes['href']); $class = (isset($options['dropup'])) ? 'btn-group dropup' : 'btn-group'; $links = (isset($options['dropup'])) ? $options['dropup'] : $options['dropdown']; $html .= '<div class="'.$class.'">'; list($dropdown, $id) = $this->dropdown($links, $options); if (is_array($name) && isset($name['split'])) { $html .= $this->page->tag('button', $attributes, $name['split']); $attributes['id'] = $id; $attributes['class'] .= ' dropdown-toggle'; $attributes['data-toggle'] = 'dropdown'; $attributes['aria-haspopup'] = 'true'; $attributes['aria-expanded'] = 'false'; $html .= $this->page->tag('button', $attributes, '<span class="caret"></span>', '<span class="sr-only">Toggle Dropdown</span>'); } else { $attributes['id'] = $id; $attributes['class'] .= ' dropdown-toggle'; $attributes['data-toggle'] = 'dropdown'; $attributes['aria-haspopup'] = 'true'; $attributes['aria-expanded'] = 'false'; $html .= $this->page->tag('button', $attributes, $name, '<span class="caret"></span>'); } $html .= $dropdown; $html .= '</div>'; return $html; } elseif (isset($options['href'])) { unset($attributes['type']); return $this->page->tag('a', $attributes, $name); } else { return $this->page->tag('button', $attributes, $name); } }
php
public function button($class, $name, array $options = array()) { $attributes = array('type' => 'button'); foreach ($options as $key => $value) { if (!in_array($key, array('dropdown', 'dropup', 'active', 'disabled', 'pull'))) { $attributes[$key] = $value; } } $attributes['class'] = $this->prefixClasses('btn', array('block', 'xs', 'sm', 'lg', 'default', 'primary', 'success', 'info', 'warning', 'danger', 'link'), $class); if (isset($options['dropdown']) || isset($options['dropup'])) { $html = ''; unset($attributes['href']); $class = (isset($options['dropup'])) ? 'btn-group dropup' : 'btn-group'; $links = (isset($options['dropup'])) ? $options['dropup'] : $options['dropdown']; $html .= '<div class="'.$class.'">'; list($dropdown, $id) = $this->dropdown($links, $options); if (is_array($name) && isset($name['split'])) { $html .= $this->page->tag('button', $attributes, $name['split']); $attributes['id'] = $id; $attributes['class'] .= ' dropdown-toggle'; $attributes['data-toggle'] = 'dropdown'; $attributes['aria-haspopup'] = 'true'; $attributes['aria-expanded'] = 'false'; $html .= $this->page->tag('button', $attributes, '<span class="caret"></span>', '<span class="sr-only">Toggle Dropdown</span>'); } else { $attributes['id'] = $id; $attributes['class'] .= ' dropdown-toggle'; $attributes['data-toggle'] = 'dropdown'; $attributes['aria-haspopup'] = 'true'; $attributes['aria-expanded'] = 'false'; $html .= $this->page->tag('button', $attributes, $name, '<span class="caret"></span>'); } $html .= $dropdown; $html .= '</div>'; return $html; } elseif (isset($options['href'])) { unset($attributes['type']); return $this->page->tag('a', $attributes, $name); } else { return $this->page->tag('button', $attributes, $name); } }
[ "public", "function", "button", "(", "$", "class", ",", "$", "name", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "attributes", "=", "array", "(", "'type'", "=>", "'button'", ")", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "array", "(", "'dropdown'", ",", "'dropup'", ",", "'active'", ",", "'disabled'", ",", "'pull'", ")", ")", ")", "{", "$", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "$", "attributes", "[", "'class'", "]", "=", "$", "this", "->", "prefixClasses", "(", "'btn'", ",", "array", "(", "'block'", ",", "'xs'", ",", "'sm'", ",", "'lg'", ",", "'default'", ",", "'primary'", ",", "'success'", ",", "'info'", ",", "'warning'", ",", "'danger'", ",", "'link'", ")", ",", "$", "class", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'dropdown'", "]", ")", "||", "isset", "(", "$", "options", "[", "'dropup'", "]", ")", ")", "{", "$", "html", "=", "''", ";", "unset", "(", "$", "attributes", "[", "'href'", "]", ")", ";", "$", "class", "=", "(", "isset", "(", "$", "options", "[", "'dropup'", "]", ")", ")", "?", "'btn-group dropup'", ":", "'btn-group'", ";", "$", "links", "=", "(", "isset", "(", "$", "options", "[", "'dropup'", "]", ")", ")", "?", "$", "options", "[", "'dropup'", "]", ":", "$", "options", "[", "'dropdown'", "]", ";", "$", "html", ".=", "'<div class=\"'", ".", "$", "class", ".", "'\">'", ";", "list", "(", "$", "dropdown", ",", "$", "id", ")", "=", "$", "this", "->", "dropdown", "(", "$", "links", ",", "$", "options", ")", ";", "if", "(", "is_array", "(", "$", "name", ")", "&&", "isset", "(", "$", "name", "[", "'split'", "]", ")", ")", "{", "$", "html", ".=", "$", "this", "->", "page", "->", "tag", "(", "'button'", ",", "$", "attributes", ",", "$", "name", "[", "'split'", "]", ")", ";", "$", "attributes", "[", "'id'", "]", "=", "$", "id", ";", "$", "attributes", "[", "'class'", "]", ".=", "' dropdown-toggle'", ";", "$", "attributes", "[", "'data-toggle'", "]", "=", "'dropdown'", ";", "$", "attributes", "[", "'aria-haspopup'", "]", "=", "'true'", ";", "$", "attributes", "[", "'aria-expanded'", "]", "=", "'false'", ";", "$", "html", ".=", "$", "this", "->", "page", "->", "tag", "(", "'button'", ",", "$", "attributes", ",", "'<span class=\"caret\"></span>'", ",", "'<span class=\"sr-only\">Toggle Dropdown</span>'", ")", ";", "}", "else", "{", "$", "attributes", "[", "'id'", "]", "=", "$", "id", ";", "$", "attributes", "[", "'class'", "]", ".=", "' dropdown-toggle'", ";", "$", "attributes", "[", "'data-toggle'", "]", "=", "'dropdown'", ";", "$", "attributes", "[", "'aria-haspopup'", "]", "=", "'true'", ";", "$", "attributes", "[", "'aria-expanded'", "]", "=", "'false'", ";", "$", "html", ".=", "$", "this", "->", "page", "->", "tag", "(", "'button'", ",", "$", "attributes", ",", "$", "name", ",", "'<span class=\"caret\"></span>'", ")", ";", "}", "$", "html", ".=", "$", "dropdown", ";", "$", "html", ".=", "'</div>'", ";", "return", "$", "html", ";", "}", "elseif", "(", "isset", "(", "$", "options", "[", "'href'", "]", ")", ")", "{", "unset", "(", "$", "attributes", "[", "'type'", "]", ")", ";", "return", "$", "this", "->", "page", "->", "tag", "(", "'a'", ",", "$", "attributes", ",", "$", "name", ")", ";", "}", "else", "{", "return", "$", "this", "->", "page", "->", "tag", "(", "'button'", ",", "$", "attributes", ",", "$", "name", ")", ";", "}", "}" ]
A button by itself is easy enough, but when you start including dropdowns and groups your markup can get ugly quick. Follow the examples. We'll start simple and go from there. @param string $class The classes: '**xs**', '**sm**', '**lg**', '**block**', '**default**', '**primary**', '**success**', '**info**', '**warning**', '**danger**', and '**link**' will all be prefixed with '**btn-...**', and we include the '**btn**' class too. Notice how we left out the '**btn-group**' option? Don't worry about that one. Feel free to add any more that you like such as '**disabled**'. @param string $name The text of your button. You may also include badges, labels, icons, etc, but leave the caret up to us. If you are including a dropdown menu and you would like to split the button from the menu, then you can make this an ``array('split' => $name)``. @param array $options These are all of the attributes that you would like to include in the ``<button>`` tag, except if you include an '**href**' key then it will be an ``<a>`` tag. Other potential options include: '**id**', '**style**', '**title**', '**type**', '**data-...**', etc, but the ones we take notice of and do special things with are: - '**dropdown**' => This is an ``array($name => $link, ...)`` of names and their associated links. - If the **$name** is numeric (ie. not specified) then the **$link** will be a header (if it is not empty), or a divider if it is. - '**dropup**' => The same as dropdown, only the caret and menu goes up instead of down. - '**active**' => This is to specify a **$link** that will receive the "**active**" class. You can set this value to either the **$name** or the **$link** of your dropdown menu, or an **integer** (starting from 1). If you just want it to select the current page then you can specify '**url**' which will match the current url and path, or '**urlquery**' which will match the current url, path, and query string. - '**disabled**' => This is to specify a link that will receive the "disabled" class. You can set this value to either the **$name** or the **$link** of your dropdown menu. - '**pull**' => Either '**left**' (default) or '**right**'. Where you would like the dropdown to be positioned, relative to the parent. @return string @example ```php echo $bp->button('primary', 'Primary'); echo $bp->button('lg success', 'Link', array('href'=>'#')); echo $bp->button('default', 'Dropdown', array( 'dropdown' => array( 'Header', 'Action' => '#', 'Another action' => '#', 'Active link' => '#', '', 'Separated link' => '#', 'Disabled link' => '#', ), 'active' => 'Active link', 'disabled' => 'Disabled link', )); ```
[ "A", "button", "by", "itself", "is", "easy", "enough", "but", "when", "you", "start", "including", "dropdowns", "and", "groups", "your", "markup", "can", "get", "ugly", "quick", ".", "Follow", "the", "examples", ".", "We", "ll", "start", "simple", "and", "go", "from", "there", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L366-L409
17,394
Kylob/Bootstrap
src/Common.php
Common.group
public function group($class, array $buttons, $form = '') { $attributes = array('class' => $this->prefixClasses('btn-group', array('xs', 'sm', 'lg', 'justified', 'vertical'), $class)); if ($form == 'checkbox' || $form == 'radio') { $attributes['data-toggle'] = 'buttons-'.$form; } if (strpos($class, 'justified') !== false) { $buttons = '<div class="btn-group" role="group">'.implode('</div><div class="btn-group" role="group">', $buttons).'</div>'; } else { $buttons = implode('', $buttons); } $attributes['role'] = 'group'; return $this->page->tag('div', $attributes, $buttons); }
php
public function group($class, array $buttons, $form = '') { $attributes = array('class' => $this->prefixClasses('btn-group', array('xs', 'sm', 'lg', 'justified', 'vertical'), $class)); if ($form == 'checkbox' || $form == 'radio') { $attributes['data-toggle'] = 'buttons-'.$form; } if (strpos($class, 'justified') !== false) { $buttons = '<div class="btn-group" role="group">'.implode('</div><div class="btn-group" role="group">', $buttons).'</div>'; } else { $buttons = implode('', $buttons); } $attributes['role'] = 'group'; return $this->page->tag('div', $attributes, $buttons); }
[ "public", "function", "group", "(", "$", "class", ",", "array", "$", "buttons", ",", "$", "form", "=", "''", ")", "{", "$", "attributes", "=", "array", "(", "'class'", "=>", "$", "this", "->", "prefixClasses", "(", "'btn-group'", ",", "array", "(", "'xs'", ",", "'sm'", ",", "'lg'", ",", "'justified'", ",", "'vertical'", ")", ",", "$", "class", ")", ")", ";", "if", "(", "$", "form", "==", "'checkbox'", "||", "$", "form", "==", "'radio'", ")", "{", "$", "attributes", "[", "'data-toggle'", "]", "=", "'buttons-'", ".", "$", "form", ";", "}", "if", "(", "strpos", "(", "$", "class", ",", "'justified'", ")", "!==", "false", ")", "{", "$", "buttons", "=", "'<div class=\"btn-group\" role=\"group\">'", ".", "implode", "(", "'</div><div class=\"btn-group\" role=\"group\">'", ",", "$", "buttons", ")", ".", "'</div>'", ";", "}", "else", "{", "$", "buttons", "=", "implode", "(", "''", ",", "$", "buttons", ")", ";", "}", "$", "attributes", "[", "'role'", "]", "=", "'group'", ";", "return", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "$", "attributes", ",", "$", "buttons", ")", ";", "}" ]
Group your buttons together. @param string $class The classes: '**xs**', '**sm**', '**lg**', '**justified**', and '**vertical**' will all be prefixed with '**btn-group-...**', and we include the '**btn-group**' class too. When you size a group up, then don't size the individual buttons. @param array $buttons An ``array($bp->button(), ...)`` of buttons. @param string $form This can be either '**checkbox**' or '**radio**' and your button group will act accordingly. @return string @example ```php echo $bp->group('', array( $bp->button('default', 'Left'), $bp->button('default', 'Middle'), $bp->button('default', array('split'=>'Right'), array( 'dropdown' => array( 'Works' => '#', 'Here' => '#', 'Too' => '#', ), 'pull' => 'right', )), )); ```
[ "Group", "your", "buttons", "together", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L437-L451
17,395
Kylob/Bootstrap
src/Common.php
Common.tabs
public function tabs(array $links, array $options = array()) { $class = 'nav nav-tabs'; if (isset($options['align'])) { switch ($options['align']) { case 'justified': $class .= ' nav-justified'; break; case 'left': case 'right': $class .= ' pull-'.$options['align']; break; } } return $this->page->tag('ul', array('class' => $class), $this->links('li', $links, $options)); }
php
public function tabs(array $links, array $options = array()) { $class = 'nav nav-tabs'; if (isset($options['align'])) { switch ($options['align']) { case 'justified': $class .= ' nav-justified'; break; case 'left': case 'right': $class .= ' pull-'.$options['align']; break; } } return $this->page->tag('ul', array('class' => $class), $this->links('li', $links, $options)); }
[ "public", "function", "tabs", "(", "array", "$", "links", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "class", "=", "'nav nav-tabs'", ";", "if", "(", "isset", "(", "$", "options", "[", "'align'", "]", ")", ")", "{", "switch", "(", "$", "options", "[", "'align'", "]", ")", "{", "case", "'justified'", ":", "$", "class", ".=", "' nav-justified'", ";", "break", ";", "case", "'left'", ":", "case", "'right'", ":", "$", "class", ".=", "' pull-'", ".", "$", "options", "[", "'align'", "]", ";", "break", ";", "}", "}", "return", "$", "this", "->", "page", "->", "tag", "(", "'ul'", ",", "array", "(", "'class'", "=>", "$", "class", ")", ",", "$", "this", "->", "links", "(", "'li'", ",", "$", "links", ",", "$", "options", ")", ")", ";", "}" ]
Creates a Bootstrap tabs nav menu. @param array $links An ``array($name => $href, ...)`` of links. If **$href** is an array unto itself, then it will be turned into a dropdown menu with the same header and divider rules applied as with ``$bp->buttons()``. @param array $options The available options are: - '**active**' => **$name**, **$href**, '**url**', '**urlquery**', or an **integer** (starting from 1). - '**disabled**' => **$name**, **$href**, or an **integer** (starting from 1). - '**align**' => - '**justified**' - So the tabs will horizontally extend the full width. - '**left**' (default) or '**right**' - The direction you would like to pull them towards. @return string @example ```php echo $bp->tabs(array( 'Nav' => '#', 'Tabs' => '#', 'Justified' => '#', ), array( 'align' => 'justified', 'active' => 1, )); ```
[ "Creates", "a", "Bootstrap", "tabs", "nav", "menu", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L586-L602
17,396
Kylob/Bootstrap
src/Common.php
Common.pills
public function pills(array $links, array $options = array()) { $class = 'nav nav-pills'; if (isset($options['align'])) { switch ($options['align']) { case 'justified': $class .= ' nav-justified'; break; case 'vertical': case 'stacked': $class .= ' nav-stacked'; break; case 'left': case 'right': $class .= ' pull-'.$options['align']; break; } } return $this->page->tag('ul', array('class' => $class), $this->links('li', $links, $options)); }
php
public function pills(array $links, array $options = array()) { $class = 'nav nav-pills'; if (isset($options['align'])) { switch ($options['align']) { case 'justified': $class .= ' nav-justified'; break; case 'vertical': case 'stacked': $class .= ' nav-stacked'; break; case 'left': case 'right': $class .= ' pull-'.$options['align']; break; } } return $this->page->tag('ul', array('class' => $class), $this->links('li', $links, $options)); }
[ "public", "function", "pills", "(", "array", "$", "links", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "class", "=", "'nav nav-pills'", ";", "if", "(", "isset", "(", "$", "options", "[", "'align'", "]", ")", ")", "{", "switch", "(", "$", "options", "[", "'align'", "]", ")", "{", "case", "'justified'", ":", "$", "class", ".=", "' nav-justified'", ";", "break", ";", "case", "'vertical'", ":", "case", "'stacked'", ":", "$", "class", ".=", "' nav-stacked'", ";", "break", ";", "case", "'left'", ":", "case", "'right'", ":", "$", "class", ".=", "' pull-'", ".", "$", "options", "[", "'align'", "]", ";", "break", ";", "}", "}", "return", "$", "this", "->", "page", "->", "tag", "(", "'ul'", ",", "array", "(", "'class'", "=>", "$", "class", ")", ",", "$", "this", "->", "links", "(", "'li'", ",", "$", "links", ",", "$", "options", ")", ")", ";", "}" ]
Creates a Bootstrap pills nav menu. @param array $links An ``array($name => $href, ...)`` of links. If **$href** is an array unto itself, then it will be turned into a dropdown menu with the same header and divider rules applied as with ``$bp->buttons()``. @param array $options The available options are: - '**active**' => **$name**, **$href**, '**url**', '**urlquery**', or an **integer** (starting from 1). - '**disabled**' => **$name**, **$href** or an **integer** (starting from 1). - '**align**' => - '**justified**' - The pills will horizontally extend the full width. - '**vertical**' or '**stacked**' - Each pill will be stacked on top of the other. - '**left**' (default) or '**right**' - The direction you would like to pull them towards. @return string @example ```php echo $bp->pills(array( 'Home ' . $bp->badge(42) => '#', 'Profile' . $bp->badge(0) => '#', 'Messages' . $bp->badge(3) => array( 'New! ' . $bp->badge(1) => '#', 'Read ' => '#', 'Trashed ' => '#', '', 'Spam ' . $bp->badge(2) => '#', ), ), array( 'active' => 'Home', )); ```
[ "Creates", "a", "Bootstrap", "pills", "nav", "menu", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L637-L657
17,397
Kylob/Bootstrap
src/Common.php
Common.breadcrumbs
public function breadcrumbs(array $links) { if (empty($links)) { return ''; } foreach ($links as $name => $href) { if (is_array($href)) { list($dropdown, $id) = $this->dropdown($href); $link = $this->page->tag('a', array('href' => '#', 'data-toggle' => 'dropdown', 'id' => $id), $name, '<b class="caret"></b>'); $links[$name] = '<li class="dropdown">'.$link.$dropdown.'</li>'; } else { $links[$name] = '<li><a href="'.$href.'">'.$name.'</a></li>'; } if ($name === 0) { $name = $href; // this should only happen to the last breadcrumb } } array_pop($links); return '<ul class="breadcrumb">'.implode(' ', $links).' <li class="active">'.$name.'</li></ul>'; }
php
public function breadcrumbs(array $links) { if (empty($links)) { return ''; } foreach ($links as $name => $href) { if (is_array($href)) { list($dropdown, $id) = $this->dropdown($href); $link = $this->page->tag('a', array('href' => '#', 'data-toggle' => 'dropdown', 'id' => $id), $name, '<b class="caret"></b>'); $links[$name] = '<li class="dropdown">'.$link.$dropdown.'</li>'; } else { $links[$name] = '<li><a href="'.$href.'">'.$name.'</a></li>'; } if ($name === 0) { $name = $href; // this should only happen to the last breadcrumb } } array_pop($links); return '<ul class="breadcrumb">'.implode(' ', $links).' <li class="active">'.$name.'</li></ul>'; }
[ "public", "function", "breadcrumbs", "(", "array", "$", "links", ")", "{", "if", "(", "empty", "(", "$", "links", ")", ")", "{", "return", "''", ";", "}", "foreach", "(", "$", "links", "as", "$", "name", "=>", "$", "href", ")", "{", "if", "(", "is_array", "(", "$", "href", ")", ")", "{", "list", "(", "$", "dropdown", ",", "$", "id", ")", "=", "$", "this", "->", "dropdown", "(", "$", "href", ")", ";", "$", "link", "=", "$", "this", "->", "page", "->", "tag", "(", "'a'", ",", "array", "(", "'href'", "=>", "'#'", ",", "'data-toggle'", "=>", "'dropdown'", ",", "'id'", "=>", "$", "id", ")", ",", "$", "name", ",", "'<b class=\"caret\"></b>'", ")", ";", "$", "links", "[", "$", "name", "]", "=", "'<li class=\"dropdown\">'", ".", "$", "link", ".", "$", "dropdown", ".", "'</li>'", ";", "}", "else", "{", "$", "links", "[", "$", "name", "]", "=", "'<li><a href=\"'", ".", "$", "href", ".", "'\">'", ".", "$", "name", ".", "'</a></li>'", ";", "}", "if", "(", "$", "name", "===", "0", ")", "{", "$", "name", "=", "$", "href", ";", "// this should only happen to the last breadcrumb", "}", "}", "array_pop", "(", "$", "links", ")", ";", "return", "'<ul class=\"breadcrumb\">'", ".", "implode", "(", "' '", ",", "$", "links", ")", ".", "' <li class=\"active\">'", ".", "$", "name", ".", "'</li></ul>'", ";", "}" ]
Creates a Bootstrap styled breadcrumb trail. The last link is automatically activated. @param array $links An ``array($name => $href)`` of links to display. The **$href** may also be another ``array($name => $href)`` of dropdown links. @return string @example ```php $bp->breadcrumbs(array( 'Home' => '#', 'Library' => '#', 'Data' => '#', )); ```
[ "Creates", "a", "Bootstrap", "styled", "breadcrumb", "trail", ".", "The", "last", "link", "is", "automatically", "activated", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L676-L696
17,398
Kylob/Bootstrap
src/Common.php
Common.alert
public function alert($type, $alert, $dismissable = true) { $html = ''; $class = 'alert alert-'.$type; if ($dismissable) { $class .= ' alert-dismissable'; } $html .= '<div class="'.$class.'" role="alert">'; if ($dismissable) { $html .= '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button>'; } $html .= $this->addClass($alert, array('h([1-6]){1}' => 'alert-heading', 'a' => 'alert-link')); $html .= '</div>'; return $html; }
php
public function alert($type, $alert, $dismissable = true) { $html = ''; $class = 'alert alert-'.$type; if ($dismissable) { $class .= ' alert-dismissable'; } $html .= '<div class="'.$class.'" role="alert">'; if ($dismissable) { $html .= '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button>'; } $html .= $this->addClass($alert, array('h([1-6]){1}' => 'alert-heading', 'a' => 'alert-link')); $html .= '</div>'; return $html; }
[ "public", "function", "alert", "(", "$", "type", ",", "$", "alert", ",", "$", "dismissable", "=", "true", ")", "{", "$", "html", "=", "''", ";", "$", "class", "=", "'alert alert-'", ".", "$", "type", ";", "if", "(", "$", "dismissable", ")", "{", "$", "class", ".=", "' alert-dismissable'", ";", "}", "$", "html", ".=", "'<div class=\"'", ".", "$", "class", ".", "'\" role=\"alert\">'", ";", "if", "(", "$", "dismissable", ")", "{", "$", "html", ".=", "'<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span></button>'", ";", "}", "$", "html", ".=", "$", "this", "->", "addClass", "(", "$", "alert", ",", "array", "(", "'h([1-6]){1}'", "=>", "'alert-heading'", ",", "'a'", "=>", "'alert-link'", ")", ")", ";", "$", "html", ".=", "'</div>'", ";", "return", "$", "html", ";", "}" ]
Creates Bootstrap alert messages. @param string $type Either '**success**', '**info**', '**warning**', or '**danger**'. @param string $alert The status message. All ``<h1-6>`` headers and ``<a>`` links will be classed appropriately. @param bool $dismissable If you set this to false, then the alert will not be dismissable. @return string @example ```php echo $bp->alert('info', '<h3>Heads up!</h3> This alert needs your attention, but it\'s not <a href="#">super important</a>.'); echo $bp->alert('danger', '<h3>Oh snap!</h3> Change a few things up and <a href="#">try submitting again</a>.', false); ```
[ "Creates", "Bootstrap", "alert", "messages", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L757-L772
17,399
Kylob/Bootstrap
src/Common.php
Common.progress
public function progress($percent, $class = '', $display = false) { $html = ''; $classes = (array) $class; foreach ((array) $percent as $key => $progress) { $class = (isset($classes[$key])) ? $classes[$key] : ''; $class = $this->prefixClasses('progress-bar', array('success', 'info', 'warning', 'danger', 'striped'), $class); $html .= $this->page->tag('div', array( 'class' => $class, 'style' => 'width:'.$progress.'%;', 'role' => 'progressbar', 'aria-valuenow' => $progress, 'aria-valuemin' => 0, 'aria-valuemax' => 100, ), $display !== false ? $progress.'%' : '<span class="sr-only">'.$progress.'% Complete</span>'); } return '<div class="progress">'.$html.'</div>'; }
php
public function progress($percent, $class = '', $display = false) { $html = ''; $classes = (array) $class; foreach ((array) $percent as $key => $progress) { $class = (isset($classes[$key])) ? $classes[$key] : ''; $class = $this->prefixClasses('progress-bar', array('success', 'info', 'warning', 'danger', 'striped'), $class); $html .= $this->page->tag('div', array( 'class' => $class, 'style' => 'width:'.$progress.'%;', 'role' => 'progressbar', 'aria-valuenow' => $progress, 'aria-valuemin' => 0, 'aria-valuemax' => 100, ), $display !== false ? $progress.'%' : '<span class="sr-only">'.$progress.'% Complete</span>'); } return '<div class="progress">'.$html.'</div>'; }
[ "public", "function", "progress", "(", "$", "percent", ",", "$", "class", "=", "''", ",", "$", "display", "=", "false", ")", "{", "$", "html", "=", "''", ";", "$", "classes", "=", "(", "array", ")", "$", "class", ";", "foreach", "(", "(", "array", ")", "$", "percent", "as", "$", "key", "=>", "$", "progress", ")", "{", "$", "class", "=", "(", "isset", "(", "$", "classes", "[", "$", "key", "]", ")", ")", "?", "$", "classes", "[", "$", "key", "]", ":", "''", ";", "$", "class", "=", "$", "this", "->", "prefixClasses", "(", "'progress-bar'", ",", "array", "(", "'success'", ",", "'info'", ",", "'warning'", ",", "'danger'", ",", "'striped'", ")", ",", "$", "class", ")", ";", "$", "html", ".=", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "$", "class", ",", "'style'", "=>", "'width:'", ".", "$", "progress", ".", "'%;'", ",", "'role'", "=>", "'progressbar'", ",", "'aria-valuenow'", "=>", "$", "progress", ",", "'aria-valuemin'", "=>", "0", ",", "'aria-valuemax'", "=>", "100", ",", ")", ",", "$", "display", "!==", "false", "?", "$", "progress", ".", "'%'", ":", "'<span class=\"sr-only\">'", ".", "$", "progress", ".", "'% Complete</span>'", ")", ";", "}", "return", "'<div class=\"progress\">'", ".", "$", "html", ".", "'</div>'", ";", "}" ]
Creates every flavor of progress bar that Bootstrap has to offer. @param int $percent The amount of progress from 0 to 100. In order to stack multiple values then turn this into an array. @param string $class You can include one of the four contextual classes: '**success**', '**info**', '**warning**' or '**danger**'. Also '**striped**' and '**active**' if you like the looks of those. These will all be properly prefixed with '**progress-...**'. If you are stacking multiple bars, then turn this into an array and make sure your classes correspond with your percentages. @param mixed $display If anything but false, then the percentage will be displayed in the progress bar. @return string @example ```php echo $bp->progress(60, 'info', 'display'); echo $bp->progress(array(25, 25, 25, 25), array('', 'warning', 'success', 'danger striped')); ```
[ "Creates", "every", "flavor", "of", "progress", "bar", "that", "Bootstrap", "has", "to", "offer", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L791-L809