repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
moon-php/moon
src/AppFactory.php
AppFactory.response
private static function response(ContainerInterface $container): ResponseInterface { if (!$container->has(ResponseInterface::class)) { throw new InvalidArgumentException('Moon received an invalid response instance from the container'); } return $container->get(ResponseInterface::class); }
php
private static function response(ContainerInterface $container): ResponseInterface { if (!$container->has(ResponseInterface::class)) { throw new InvalidArgumentException('Moon received an invalid response instance from the container'); } return $container->get(ResponseInterface::class); }
[ "private", "static", "function", "response", "(", "ContainerInterface", "$", "container", ")", ":", "ResponseInterface", "{", "if", "(", "!", "$", "container", "->", "has", "(", "ResponseInterface", "::", "class", ")", ")", "{", "throw", "new", "InvalidArgumen...
Return an instance of the ResponseInterface. @throws ContainerExceptionInterface @throws InvalidArgumentException @throws NotFoundExceptionInterface
[ "Return", "an", "instance", "of", "the", "ResponseInterface", "." ]
25a6be494b829528f6181f544a21cda95d1226a2
https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/AppFactory.php#L72-L79
train
moon-php/moon
src/AppFactory.php
AppFactory.processor
private static function processor(ContainerInterface $container): ProcessorInterface { if (!$container->has(ProcessorInterface::class)) { return new WebProcessor($container); } return $container->get(ProcessorInterface::class); }
php
private static function processor(ContainerInterface $container): ProcessorInterface { if (!$container->has(ProcessorInterface::class)) { return new WebProcessor($container); } return $container->get(ProcessorInterface::class); }
[ "private", "static", "function", "processor", "(", "ContainerInterface", "$", "container", ")", ":", "ProcessorInterface", "{", "if", "(", "!", "$", "container", "->", "has", "(", "ProcessorInterface", "::", "class", ")", ")", "{", "return", "new", "WebProcess...
Return an instance of the ProcessorInterface. @throws ContainerExceptionInterface @throws NotFoundExceptionInterface
[ "Return", "an", "instance", "of", "the", "ProcessorInterface", "." ]
25a6be494b829528f6181f544a21cda95d1226a2
https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/AppFactory.php#L87-L94
train
moon-php/moon
src/AppFactory.php
AppFactory.errorHandler
private static function errorHandler(ContainerInterface $container): ErrorHandlerInterface { if (!$container->has(ErrorHandlerInterface::class)) { return new ErrorHandler(); } return $container->get(ErrorHandlerInterface::class); }
php
private static function errorHandler(ContainerInterface $container): ErrorHandlerInterface { if (!$container->has(ErrorHandlerInterface::class)) { return new ErrorHandler(); } return $container->get(ErrorHandlerInterface::class); }
[ "private", "static", "function", "errorHandler", "(", "ContainerInterface", "$", "container", ")", ":", "ErrorHandlerInterface", "{", "if", "(", "!", "$", "container", "->", "has", "(", "ErrorHandlerInterface", "::", "class", ")", ")", "{", "return", "new", "E...
Return an instance of the ErrorHandlerInterface. @throws ContainerExceptionInterface @throws NotFoundExceptionInterface
[ "Return", "an", "instance", "of", "the", "ErrorHandlerInterface", "." ]
25a6be494b829528f6181f544a21cda95d1226a2
https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/AppFactory.php#L102-L109
train
moon-php/moon
src/AppFactory.php
AppFactory.invalidRequestHandler
private static function invalidRequestHandler(ContainerInterface $container): InvalidRequestHandlerInterface { if (!$container->has(InvalidRequestHandlerInterface::class)) { return new InvalidRequestHandler(); } return $container->get(InvalidRequestHandlerInterface::class); }
php
private static function invalidRequestHandler(ContainerInterface $container): InvalidRequestHandlerInterface { if (!$container->has(InvalidRequestHandlerInterface::class)) { return new InvalidRequestHandler(); } return $container->get(InvalidRequestHandlerInterface::class); }
[ "private", "static", "function", "invalidRequestHandler", "(", "ContainerInterface", "$", "container", ")", ":", "InvalidRequestHandlerInterface", "{", "if", "(", "!", "$", "container", "->", "has", "(", "InvalidRequestHandlerInterface", "::", "class", ")", ")", "{"...
Return an instance of the NotFoundHandlerInterface. @throws ContainerExceptionInterface @throws NotFoundExceptionInterface
[ "Return", "an", "instance", "of", "the", "NotFoundHandlerInterface", "." ]
25a6be494b829528f6181f544a21cda95d1226a2
https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/AppFactory.php#L117-L124
train
moon-php/moon
src/AppFactory.php
AppFactory.matchableRequest
private static function matchableRequest(ContainerInterface $container): MatchableRequestInterface { if (!$container->has(MatchableRequestInterface::class)) { return new MatchableRequest($container->get(ServerRequestInterface::class)); } return $container->get(MatchableRequestInterface::class); }
php
private static function matchableRequest(ContainerInterface $container): MatchableRequestInterface { if (!$container->has(MatchableRequestInterface::class)) { return new MatchableRequest($container->get(ServerRequestInterface::class)); } return $container->get(MatchableRequestInterface::class); }
[ "private", "static", "function", "matchableRequest", "(", "ContainerInterface", "$", "container", ")", ":", "MatchableRequestInterface", "{", "if", "(", "!", "$", "container", "->", "has", "(", "MatchableRequestInterface", "::", "class", ")", ")", "{", "return", ...
Return an instance of the MatchableInterface. @throws ContainerExceptionInterface @throws NotFoundExceptionInterface
[ "Return", "an", "instance", "of", "the", "MatchableInterface", "." ]
25a6be494b829528f6181f544a21cda95d1226a2
https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/AppFactory.php#L132-L139
train
moon-php/moon
src/AppFactory.php
AppFactory.streamReadLength
private static function streamReadLength(ContainerInterface $container): ? int { return $container->has(self::STREAM_READ_LENGTH) ? $container->get(self::STREAM_READ_LENGTH) : null; }
php
private static function streamReadLength(ContainerInterface $container): ? int { return $container->has(self::STREAM_READ_LENGTH) ? $container->get(self::STREAM_READ_LENGTH) : null; }
[ "private", "static", "function", "streamReadLength", "(", "ContainerInterface", "$", "container", ")", ":", "?", "int", "{", "return", "$", "container", "->", "has", "(", "self", "::", "STREAM_READ_LENGTH", ")", "?", "$", "container", "->", "get", "(", "self...
Return the length for read the stream, if null is return all the body will be print. @throws ContainerExceptionInterface @throws NotFoundExceptionInterface
[ "Return", "the", "length", "for", "read", "the", "stream", "if", "null", "is", "return", "all", "the", "body", "will", "be", "print", "." ]
25a6be494b829528f6181f544a21cda95d1226a2
https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/AppFactory.php#L147-L150
train
lastzero/test-tools
src/Fixture/SelfInitializingFixtureTrait.php
SelfInitializingFixtureTrait.getFixtureFingerprintArguments
protected function getFixtureFingerprintArguments(array $arguments) { $fingerprintArguments = array(); foreach ($arguments as $arg) { if (is_object($arg) && method_exists($arg, '__toString')) { $fingerprintArg = (string)$arg; } else { $fingerprintArg = $arg; } $fingerprintArguments[] = $fingerprintArg; } return $fingerprintArguments; }
php
protected function getFixtureFingerprintArguments(array $arguments) { $fingerprintArguments = array(); foreach ($arguments as $arg) { if (is_object($arg) && method_exists($arg, '__toString')) { $fingerprintArg = (string)$arg; } else { $fingerprintArg = $arg; } $fingerprintArguments[] = $fingerprintArg; } return $fingerprintArguments; }
[ "protected", "function", "getFixtureFingerprintArguments", "(", "array", "$", "arguments", ")", "{", "$", "fingerprintArguments", "=", "array", "(", ")", ";", "foreach", "(", "$", "arguments", "as", "$", "arg", ")", "{", "if", "(", "is_object", "(", "$", "...
Can be overwritten by classes that use this trait @param array $arguments @return array
[ "Can", "be", "overwritten", "by", "classes", "that", "use", "this", "trait" ]
4f5f12e213060930e79c4e6cb9a48d422cd258ce
https://github.com/lastzero/test-tools/blob/4f5f12e213060930e79c4e6cb9a48d422cd258ce/src/Fixture/SelfInitializingFixtureTrait.php#L175-L190
train
eduvpn/vpn-lib-common
src/LdapClient.php
LdapClient.bind
public function bind($bindUser = null, $bindPass = null) { if (false === ldap_bind($this->ldapResource, $bindUser, $bindPass)) { throw new LdapClientException( sprintf( 'LDAP error: (%d) %s', ldap_errno($this->ldapResource), ldap_error($this->ldapResource) ) ); } }
php
public function bind($bindUser = null, $bindPass = null) { if (false === ldap_bind($this->ldapResource, $bindUser, $bindPass)) { throw new LdapClientException( sprintf( 'LDAP error: (%d) %s', ldap_errno($this->ldapResource), ldap_error($this->ldapResource) ) ); } }
[ "public", "function", "bind", "(", "$", "bindUser", "=", "null", ",", "$", "bindPass", "=", "null", ")", "{", "if", "(", "false", "===", "ldap_bind", "(", "$", "this", "->", "ldapResource", ",", "$", "bindUser", ",", "$", "bindPass", ")", ")", "{", ...
Bind to an LDAP server. @param string|null $bindUser you MUST use LdapClient::escapeDn on any user input used to contruct the DN! @param string|null $bindPass @return void
[ "Bind", "to", "an", "LDAP", "server", "." ]
8fe3982198765f9875bb4902076bd2a46a54d43f
https://github.com/eduvpn/vpn-lib-common/blob/8fe3982198765f9875bb4902076bd2a46a54d43f/src/LdapClient.php#L42-L53
train
softberg/quantum-core
src/Libraries/Session/Session.php
Session.getFlash
public function getFlash($key) { if ($this->has($key)) { $flashData = $_SESSION[$key]; $this->delete($key); return $flashData; } }
php
public function getFlash($key) { if ($this->has($key)) { $flashData = $_SESSION[$key]; $this->delete($key); return $flashData; } }
[ "public", "function", "getFlash", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "$", "flashData", "=", "$", "_SESSION", "[", "$", "key", "]", ";", "$", "this", "->", "delete", "(", "$", "key", ...
Gets flash values by given key @param string $key @return mixed
[ "Gets", "flash", "values", "by", "given", "key" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Session/Session.php#L91-L97
train
vegas-cmf/core
src/Bootstrap/LoaderInitializerTrait.php
LoaderInitializerTrait.initLoader
public function initLoader(Config $config) { $loader = new Loader(); $loader->registerDirs( [ $config->application->libraryDir, $config->application->pluginDir, $config->application->taskDir ] )->register(); }
php
public function initLoader(Config $config) { $loader = new Loader(); $loader->registerDirs( [ $config->application->libraryDir, $config->application->pluginDir, $config->application->taskDir ] )->register(); }
[ "public", "function", "initLoader", "(", "Config", "$", "config", ")", "{", "$", "loader", "=", "new", "Loader", "(", ")", ";", "$", "loader", "->", "registerDirs", "(", "[", "$", "config", "->", "application", "->", "libraryDir", ",", "$", "config", "...
Initializes loader Registers library and plugin directory
[ "Initializes", "loader", "Registers", "library", "and", "plugin", "directory" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Bootstrap/LoaderInitializerTrait.php#L25-L35
train
neos/party
Classes/Domain/Repository/PartyRepository.php
PartyRepository.findOneHavingAccount
public function findOneHavingAccount(Account $account) { $query = $this->createQuery(); return $query->matching($query->contains('accounts', $account))->execute()->getFirst(); }
php
public function findOneHavingAccount(Account $account) { $query = $this->createQuery(); return $query->matching($query->contains('accounts', $account))->execute()->getFirst(); }
[ "public", "function", "findOneHavingAccount", "(", "Account", "$", "account", ")", "{", "$", "query", "=", "$", "this", "->", "createQuery", "(", ")", ";", "return", "$", "query", "->", "matching", "(", "$", "query", "->", "contains", "(", "'accounts'", ...
Finds a Party instance, if any, which has the given Account attached. @param Account $account @return AbstractParty
[ "Finds", "a", "Party", "instance", "if", "any", "which", "has", "the", "given", "Account", "attached", "." ]
cf771039e8da24762c21640f8761d40d281c0cd0
https://github.com/neos/party/blob/cf771039e8da24762c21640f8761d40d281c0cd0/Classes/Domain/Repository/PartyRepository.php#L34-L39
train
jasny/db
src/FieldMap/ConfiguredFieldMap.php
ConfiguredFieldMap.apply
protected function apply(iterable $iterable): iterable { return Pipeline::with($iterable) ->mapKeys(function($_, $info) { $field = is_array($info) ? ($info['field'] ?? null) : $info; $newField = $this->map[$field] ?? ($this->dynamic ? $field : null); return isset($newField) && is_array($info) ? ['field' => $newField] + $info : $newField; }) ->filter(function($_, $info) { return $info !== null; }); }
php
protected function apply(iterable $iterable): iterable { return Pipeline::with($iterable) ->mapKeys(function($_, $info) { $field = is_array($info) ? ($info['field'] ?? null) : $info; $newField = $this->map[$field] ?? ($this->dynamic ? $field : null); return isset($newField) && is_array($info) ? ['field' => $newField] + $info : $newField; }) ->filter(function($_, $info) { return $info !== null; }); }
[ "protected", "function", "apply", "(", "iterable", "$", "iterable", ")", ":", "iterable", "{", "return", "Pipeline", "::", "with", "(", "$", "iterable", ")", "->", "mapKeys", "(", "function", "(", "$", "_", ",", "$", "info", ")", "{", "$", "field", "...
Apply mapping. @param iterable $iterable @return iterable
[ "Apply", "mapping", "." ]
efd57d9dd8f3f40235c4da8b39a81f03d5f79b25
https://github.com/jasny/db/blob/efd57d9dd8f3f40235c4da8b39a81f03d5f79b25/src/FieldMap/ConfiguredFieldMap.php#L75-L87
train
vegas-cmf/core
src/Mvc/Router.php
Router.addRoute
public function addRoute(array $routeArray) { $routeKeys = array_keys($routeArray); $routeValues = array_values($routeArray); $routeName = reset($routeKeys); $route = reset($routeValues); $this->routes[$routeName] = $route; return $this; }
php
public function addRoute(array $routeArray) { $routeKeys = array_keys($routeArray); $routeValues = array_values($routeArray); $routeName = reset($routeKeys); $route = reset($routeValues); $this->routes[$routeName] = $route; return $this; }
[ "public", "function", "addRoute", "(", "array", "$", "routeArray", ")", "{", "$", "routeKeys", "=", "array_keys", "(", "$", "routeArray", ")", ";", "$", "routeValues", "=", "array_values", "(", "$", "routeArray", ")", ";", "$", "routeName", "=", "reset", ...
Adds single route definition @param array $routeArray @return $this
[ "Adds", "single", "route", "definition" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Router.php#L107-L118
train
vegas-cmf/core
src/Mvc/Router.php
Router.addModuleRoutes
public function addModuleRoutes(array $module) { $routeArray = $this->getRouteArrayFromModulePath($module['path']); $this->addRoutes($routeArray); return $this; }
php
public function addModuleRoutes(array $module) { $routeArray = $this->getRouteArrayFromModulePath($module['path']); $this->addRoutes($routeArray); return $this; }
[ "public", "function", "addModuleRoutes", "(", "array", "$", "module", ")", "{", "$", "routeArray", "=", "$", "this", "->", "getRouteArrayFromModulePath", "(", "$", "module", "[", "'path'", "]", ")", ";", "$", "this", "->", "addRoutes", "(", "$", "routeArra...
Adds module routes from specified path @param array $module @return $this
[ "Adds", "module", "routes", "from", "specified", "path" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Router.php#L126-L132
train
vegas-cmf/core
src/Mvc/Router.php
Router.getRouteArrayFromModulePath
private function getRouteArrayFromModulePath($path) { $path = dirname($path).'/config/routes.php'; if (file_exists($path) && is_file($path)) { return require $path; } return array(); }
php
private function getRouteArrayFromModulePath($path) { $path = dirname($path).'/config/routes.php'; if (file_exists($path) && is_file($path)) { return require $path; } return array(); }
[ "private", "function", "getRouteArrayFromModulePath", "(", "$", "path", ")", "{", "$", "path", "=", "dirname", "(", "$", "path", ")", ".", "'/config/routes.php'", ";", "if", "(", "file_exists", "(", "$", "path", ")", "&&", "is_file", "(", "$", "path", ")...
Extracts routes from specified path @param $path @return array|mixed @internal
[ "Extracts", "routes", "from", "specified", "path" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Router.php#L141-L150
train
vegas-cmf/core
src/Mvc/Router.php
Router.groupRoutes
private function groupRoutes() { $routes = array(); foreach ($this->routeTypes as $type => $typeName) { $routes[$type] = array(); } foreach ($this->routes as $routePattern => $route) { if (!isset($route['type'])) { $route['type'] = Router::BASE_ROUTE; } $this->validateRouteType($route['type']); $routes[$route['type']][$routePattern] = $route; } $this->routes = $routes; }
php
private function groupRoutes() { $routes = array(); foreach ($this->routeTypes as $type => $typeName) { $routes[$type] = array(); } foreach ($this->routes as $routePattern => $route) { if (!isset($route['type'])) { $route['type'] = Router::BASE_ROUTE; } $this->validateRouteType($route['type']); $routes[$route['type']][$routePattern] = $route; } $this->routes = $routes; }
[ "private", "function", "groupRoutes", "(", ")", "{", "$", "routes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "routeTypes", "as", "$", "type", "=>", "$", "typeName", ")", "{", "$", "routes", "[", "$", "type", "]", "=", "array"...
Groups routes by types @internal
[ "Groups", "routes", "by", "types" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Router.php#L156-L173
train
vegas-cmf/core
src/Mvc/Router.php
Router.setup
public function setup() { $this->groupRoutes(); foreach ($this->routes as $type => $routes) { foreach ($routes as $name => $route) { $newRoute = new Route($name, $route); if (!$newRoute->hasParam('hostname')) { $newRoute->setParam('hostname', $this->resolveDefaultHostName()); } $routeType = $this->resolveRouteType($type); $routeType->add($this->getRouter(), $newRoute); } } }
php
public function setup() { $this->groupRoutes(); foreach ($this->routes as $type => $routes) { foreach ($routes as $name => $route) { $newRoute = new Route($name, $route); if (!$newRoute->hasParam('hostname')) { $newRoute->setParam('hostname', $this->resolveDefaultHostName()); } $routeType = $this->resolveRouteType($type); $routeType->add($this->getRouter(), $newRoute); } } }
[ "public", "function", "setup", "(", ")", "{", "$", "this", "->", "groupRoutes", "(", ")", ";", "foreach", "(", "$", "this", "->", "routes", "as", "$", "type", "=>", "$", "routes", ")", "{", "foreach", "(", "$", "routes", "as", "$", "name", "=>", ...
Setups router Adds rules to router
[ "Setups", "router", "Adds", "rules", "to", "router" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Router.php#L205-L220
train
vegas-cmf/core
src/Mvc/Router.php
Router.resolveRouteType
private function resolveRouteType($routeType) { $typeClassName = sprintf('%sRoute', ucfirst($routeType)); $classNamespace = __NAMESPACE__ . '\\Router\\Route\\' . $typeClassName; if (!array_key_exists($classNamespace, $this->resolvedTypes)) { $reflectionClass = new \ReflectionClass($classNamespace); $this->resolvedTypes[$classNamespace] = $reflectionClass->newInstance(); } return $this->resolvedTypes[$classNamespace]; }
php
private function resolveRouteType($routeType) { $typeClassName = sprintf('%sRoute', ucfirst($routeType)); $classNamespace = __NAMESPACE__ . '\\Router\\Route\\' . $typeClassName; if (!array_key_exists($classNamespace, $this->resolvedTypes)) { $reflectionClass = new \ReflectionClass($classNamespace); $this->resolvedTypes[$classNamespace] = $reflectionClass->newInstance(); } return $this->resolvedTypes[$classNamespace]; }
[ "private", "function", "resolveRouteType", "(", "$", "routeType", ")", "{", "$", "typeClassName", "=", "sprintf", "(", "'%sRoute'", ",", "ucfirst", "(", "$", "routeType", ")", ")", ";", "$", "classNamespace", "=", "__NAMESPACE__", ".", "'\\\\Router\\\\Route\\\\'...
Resolves route type @param $routeType @return \Vegas\Mvc\Router\RouteInterface @throws Router\Exception\InvalidRouteTypeException @internal
[ "Resolves", "route", "type" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Router.php#L254-L264
train
softberg/quantum-core
src/Libraries/Cookie/Cookie.php
Cookie.get
public static function get($key) { return self::has($key) ? self::decode($_COOKIE[$key]) : NULL; }
php
public static function get($key) { return self::has($key) ? self::decode($_COOKIE[$key]) : NULL; }
[ "public", "static", "function", "get", "(", "$", "key", ")", "{", "return", "self", "::", "has", "(", "$", "key", ")", "?", "self", "::", "decode", "(", "$", "_COOKIE", "[", "$", "key", "]", ")", ":", "NULL", ";", "}" ]
Gets data from cookie by given key @param string $key @return mixed
[ "Gets", "data", "from", "cookie", "by", "given", "key" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Cookie/Cookie.php#L35-L37
train
softberg/quantum-core
src/Libraries/Cookie/Cookie.php
Cookie.set
public static function set($key, $value = '', $time = 0, $path = '/', $domain = '', $secure = FALSE, $httponly = FALSE) { return setcookie($key, self::encode($value), time() + $time, $path, $domain, $secure, $httponly); }
php
public static function set($key, $value = '', $time = 0, $path = '/', $domain = '', $secure = FALSE, $httponly = FALSE) { return setcookie($key, self::encode($value), time() + $time, $path, $domain, $secure, $httponly); }
[ "public", "static", "function", "set", "(", "$", "key", ",", "$", "value", "=", "''", ",", "$", "time", "=", "0", ",", "$", "path", "=", "'/'", ",", "$", "domain", "=", "''", ",", "$", "secure", "=", "FALSE", ",", "$", "httponly", "=", "FALSE",...
Sets cookie data by given key @param string $key @param string $value @param integer $time @param string $path @param string $domain @param boolean $secure @param boolean $httponly @return bool
[ "Sets", "cookie", "data", "by", "given", "key" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Cookie/Cookie.php#L74-L76
train
softberg/quantum-core
src/Libraries/Cookie/Cookie.php
Cookie.delete
public static function delete($key, $path = '/') { if (self::has($key)) { setcookie($key, '', time() - 3600, $path); } }
php
public static function delete($key, $path = '/') { if (self::has($key)) { setcookie($key, '', time() - 3600, $path); } }
[ "public", "static", "function", "delete", "(", "$", "key", ",", "$", "path", "=", "'/'", ")", "{", "if", "(", "self", "::", "has", "(", "$", "key", ")", ")", "{", "setcookie", "(", "$", "key", ",", "''", ",", "time", "(", ")", "-", "3600", ",...
Delete cookie data by given key @param string $key @param string $path
[ "Delete", "cookie", "data", "by", "given", "key" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Cookie/Cookie.php#L84-L88
train
softberg/quantum-core
src/Libraries/Cookie/Cookie.php
Cookie.flush
public static function flush() { if (count($_COOKIE) > 0) { foreach ($_COOKIE as $key => $value) { self::delete($key, '/'); } } }
php
public static function flush() { if (count($_COOKIE) > 0) { foreach ($_COOKIE as $key => $value) { self::delete($key, '/'); } } }
[ "public", "static", "function", "flush", "(", ")", "{", "if", "(", "count", "(", "$", "_COOKIE", ")", ">", "0", ")", "{", "foreach", "(", "$", "_COOKIE", "as", "$", "key", "=>", "$", "value", ")", "{", "self", "::", "delete", "(", "$", "key", "...
Deletes whole cookie data
[ "Deletes", "whole", "cookie", "data" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Cookie/Cookie.php#L93-L99
train
moon-php/moon
src/App.php
App.run
public function run(MatchablePipelineCollectionInterface $pipelines): ResponseInterface { try { // If a pipeline match print the response and return if ($handledResponse = $this->handlePipeline($pipelines)) { return $handledResponse; } // If a route pattern matched but the http verbs was different, print a '405 response' // If no route pattern matched, print a '404 response' $statusCode = $this->matchableRequest->isPatternMatched() ? StatusCodeInterface::STATUS_METHOD_NOT_ALLOWED : StatusCodeInterface::STATUS_NOT_FOUND; return $this->invalidRequestHandler->__invoke($this->matchableRequest->request(), $this->response->withStatus($statusCode)); } catch (Throwable $e) { return $this->errorHandler->__invoke($e, $this->request, $this->response); } }
php
public function run(MatchablePipelineCollectionInterface $pipelines): ResponseInterface { try { // If a pipeline match print the response and return if ($handledResponse = $this->handlePipeline($pipelines)) { return $handledResponse; } // If a route pattern matched but the http verbs was different, print a '405 response' // If no route pattern matched, print a '404 response' $statusCode = $this->matchableRequest->isPatternMatched() ? StatusCodeInterface::STATUS_METHOD_NOT_ALLOWED : StatusCodeInterface::STATUS_NOT_FOUND; return $this->invalidRequestHandler->__invoke($this->matchableRequest->request(), $this->response->withStatus($statusCode)); } catch (Throwable $e) { return $this->errorHandler->__invoke($e, $this->request, $this->response); } }
[ "public", "function", "run", "(", "MatchablePipelineCollectionInterface", "$", "pipelines", ")", ":", "ResponseInterface", "{", "try", "{", "// If a pipeline match print the response and return", "if", "(", "$", "handledResponse", "=", "$", "this", "->", "handlePipeline",...
Run the web application, and print a Response. @throws RuntimeException
[ "Run", "the", "web", "application", "and", "print", "a", "Response", "." ]
25a6be494b829528f6181f544a21cda95d1226a2
https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/App.php#L76-L92
train
moon-php/moon
src/App.php
App.handlePipeline
private function handlePipeline(MatchablePipelineCollectionInterface $pipelines): ?ResponseInterface { /** @var MatchablePipelineInterface $pipeline */ foreach ($pipelines as $pipeline) { if ($pipeline->matchBy($this->matchableRequest)) { $stages = \array_merge($this->stages(), $pipeline->stages()); $pipelineResponse = $this->processor->processStages($stages, $this->matchableRequest->request()); if ($pipelineResponse instanceof ResponseInterface) { return $pipelineResponse; } $body = $this->response->getBody(); $body->write($pipelineResponse); return $this->response->withBody($body); } } return null; }
php
private function handlePipeline(MatchablePipelineCollectionInterface $pipelines): ?ResponseInterface { /** @var MatchablePipelineInterface $pipeline */ foreach ($pipelines as $pipeline) { if ($pipeline->matchBy($this->matchableRequest)) { $stages = \array_merge($this->stages(), $pipeline->stages()); $pipelineResponse = $this->processor->processStages($stages, $this->matchableRequest->request()); if ($pipelineResponse instanceof ResponseInterface) { return $pipelineResponse; } $body = $this->response->getBody(); $body->write($pipelineResponse); return $this->response->withBody($body); } } return null; }
[ "private", "function", "handlePipeline", "(", "MatchablePipelineCollectionInterface", "$", "pipelines", ")", ":", "?", "ResponseInterface", "{", "/** @var MatchablePipelineInterface $pipeline */", "foreach", "(", "$", "pipelines", "as", "$", "pipeline", ")", "{", "if", ...
Process the pipelines and return a ResponseInterface if one of this match. @throws UnprocessableStageException
[ "Process", "the", "pipelines", "and", "return", "a", "ResponseInterface", "if", "one", "of", "this", "match", "." ]
25a6be494b829528f6181f544a21cda95d1226a2
https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/App.php#L99-L119
train
moon-php/moon
src/App.php
App.sendResponse
public function sendResponse(ResponseInterface $response): void { // Send all the headers \http_response_code($response->getStatusCode()); foreach ($response->getHeaders() as $headerName => $headerValues) { /** @var string[] $headerValues */ foreach ($headerValues as $headerValue) { \header("$headerName: $headerValue", false); } } // Get the body, rewind it if possible $body = $response->getBody(); if ($body->isSeekable()) { $body->rewind(); } // If the body is not readable do not send any body to the client if (!$body->isReadable()) { return; } // Send the body (by chunk if specified in the container using streamReadLength value) if (null === $this->streamReadLength) { echo $body->__toString(); return; } while (!$body->eof()) { echo $body->read($this->streamReadLength); } }
php
public function sendResponse(ResponseInterface $response): void { // Send all the headers \http_response_code($response->getStatusCode()); foreach ($response->getHeaders() as $headerName => $headerValues) { /** @var string[] $headerValues */ foreach ($headerValues as $headerValue) { \header("$headerName: $headerValue", false); } } // Get the body, rewind it if possible $body = $response->getBody(); if ($body->isSeekable()) { $body->rewind(); } // If the body is not readable do not send any body to the client if (!$body->isReadable()) { return; } // Send the body (by chunk if specified in the container using streamReadLength value) if (null === $this->streamReadLength) { echo $body->__toString(); return; } while (!$body->eof()) { echo $body->read($this->streamReadLength); } }
[ "public", "function", "sendResponse", "(", "ResponseInterface", "$", "response", ")", ":", "void", "{", "// Send all the headers", "\\", "http_response_code", "(", "$", "response", "->", "getStatusCode", "(", ")", ")", ";", "foreach", "(", "$", "response", "->",...
Send headers and body to the client. @throws RuntimeException
[ "Send", "headers", "and", "body", "to", "the", "client", "." ]
25a6be494b829528f6181f544a21cda95d1226a2
https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/App.php#L126-L158
train
softberg/quantum-core
src/Mvc/Qt_Model.php
Qt_Model.fillObjectProps
public function fillObjectProps($arguments) { foreach ($arguments as $key => $value) { if (!in_array($key, $this->fillable)) { throw new \Exception(_message(ExceptionMessages::INAPPROPRIATE_PROPERTY, $key)); } $this->$key = $value; } }
php
public function fillObjectProps($arguments) { foreach ($arguments as $key => $value) { if (!in_array($key, $this->fillable)) { throw new \Exception(_message(ExceptionMessages::INAPPROPRIATE_PROPERTY, $key)); } $this->$key = $value; } }
[ "public", "function", "fillObjectProps", "(", "$", "arguments", ")", "{", "foreach", "(", "$", "arguments", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "this", "->", "fillable", ")", ")", "...
Fill Object Properties Fills the properties with values @param array $arguments @return void @throws \Exception When the property is not appropriate
[ "Fill", "Object", "Properties" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Mvc/Qt_Model.php#L103-L111
train
duncan3dc/php-helpers
src/Debug.php
Debug.output
public static function output($message, $data = null) { if (static::$mode == "html") { static::html($message, $data); } else { static::text($message, $data); } }
php
public static function output($message, $data = null) { if (static::$mode == "html") { static::html($message, $data); } else { static::text($message, $data); } }
[ "public", "static", "function", "output", "(", "$", "message", ",", "$", "data", "=", "null", ")", "{", "if", "(", "static", "::", "$", "mode", "==", "\"html\"", ")", "{", "static", "::", "html", "(", "$", "message", ",", "$", "data", ")", ";", "...
Output a message, in the current mode, if we are currently debugging @param string $message The message to output @param mixed $data Additional data to output @return void
[ "Output", "a", "message", "in", "the", "current", "mode", "if", "we", "are", "currently", "debugging" ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Debug.php#L77-L84
train
duncan3dc/php-helpers
src/Debug.php
Debug.indent
protected static function indent() { $char = (static::$mode == "html") ? "&nbsp;" : " "; for ($i = 0; $i < static::$indent; $i++) { for ($y = 0; $y < 4; $y++) { echo $char; } } }
php
protected static function indent() { $char = (static::$mode == "html") ? "&nbsp;" : " "; for ($i = 0; $i < static::$indent; $i++) { for ($y = 0; $y < 4; $y++) { echo $char; } } }
[ "protected", "static", "function", "indent", "(", ")", "{", "$", "char", "=", "(", "static", "::", "$", "mode", "==", "\"html\"", ")", "?", "\"&nbsp;\"", ":", "\" \"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "static", "::", "$", ...
Output some indentation based on the current level @return void
[ "Output", "some", "indentation", "based", "on", "the", "current", "level" ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Debug.php#L92-L101
train
duncan3dc/php-helpers
src/Debug.php
Debug.text
public static function text($message, $data = null) { if (!static::$on) { return; } echo "--------------------------------------------------------------------------------\n"; static::indent(); echo static::getTime() . " - " . $message . "\n"; if (is_array($data)) { print_r($data); } elseif ($data) { static::indent(); echo " " . $data . "\n"; } }
php
public static function text($message, $data = null) { if (!static::$on) { return; } echo "--------------------------------------------------------------------------------\n"; static::indent(); echo static::getTime() . " - " . $message . "\n"; if (is_array($data)) { print_r($data); } elseif ($data) { static::indent(); echo " " . $data . "\n"; } }
[ "public", "static", "function", "text", "(", "$", "message", ",", "$", "data", "=", "null", ")", "{", "if", "(", "!", "static", "::", "$", "on", ")", "{", "return", ";", "}", "echo", "\"----------------------------------------------------------------------------...
Output a message, in text mode, if we are currently debugging @param string $message The message to output @param mixed $data Additional data to output @return void
[ "Output", "a", "message", "in", "text", "mode", "if", "we", "are", "currently", "debugging" ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Debug.php#L112-L127
train
duncan3dc/php-helpers
src/Debug.php
Debug.html
public static function html($message, $data = null) { if (!static::$on) { return; } echo "<hr>"; echo "<i>"; static::indent(); echo "<b>" . static::getTime() . " - " . $message . "</b>"; if (is_array($data)) { Html::print_r($data); } elseif ($data) { static::indent(); echo "&nbsp;&nbsp;&nbsp;&nbsp;" . $data . "<br>"; } echo "</i>"; }
php
public static function html($message, $data = null) { if (!static::$on) { return; } echo "<hr>"; echo "<i>"; static::indent(); echo "<b>" . static::getTime() . " - " . $message . "</b>"; if (is_array($data)) { Html::print_r($data); } elseif ($data) { static::indent(); echo "&nbsp;&nbsp;&nbsp;&nbsp;" . $data . "<br>"; } echo "</i>"; }
[ "public", "static", "function", "html", "(", "$", "message", ",", "$", "data", "=", "null", ")", "{", "if", "(", "!", "static", "::", "$", "on", ")", "{", "return", ";", "}", "echo", "\"<hr>\"", ";", "echo", "\"<i>\"", ";", "static", "::", "indent"...
Output a message, in html mode, if we are currently debugging @param string $message The message to output @param mixed $data Additional data to output @return void
[ "Output", "a", "message", "in", "html", "mode", "if", "we", "are", "currently", "debugging" ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Debug.php#L138-L155
train
duncan3dc/php-helpers
src/Debug.php
Debug.call
public static function call($message, callable $func) { $time = microtime(true); static::output($message . " [START]"); static::$indent++; $func(); static::$indent--; static::output($message . " [END] (" . number_format(microtime(true) - $time, 3) . ")"); }
php
public static function call($message, callable $func) { $time = microtime(true); static::output($message . " [START]"); static::$indent++; $func(); static::$indent--; static::output($message . " [END] (" . number_format(microtime(true) - $time, 3) . ")"); }
[ "public", "static", "function", "call", "(", "$", "message", ",", "callable", "$", "func", ")", "{", "$", "time", "=", "microtime", "(", "true", ")", ";", "static", "::", "output", "(", "$", "message", ".", "\" [START]\"", ")", ";", "static", "::", "...
Output a start time, run a callable, then out the endtime @param string $message The message to output @param callable $func The function to execute @return void
[ "Output", "a", "start", "time", "run", "a", "callable", "then", "out", "the", "endtime" ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Debug.php#L166-L179
train
BenGorUser/User
src/BenGorUser/User/Domain/Model/UserToken.php
UserToken.isExpired
public function isExpired($lifetime) { $interval = $this->createdOn->diff(new \DateTimeImmutable()); return $interval->s >= (int) $lifetime; }
php
public function isExpired($lifetime) { $interval = $this->createdOn->diff(new \DateTimeImmutable()); return $interval->s >= (int) $lifetime; }
[ "public", "function", "isExpired", "(", "$", "lifetime", ")", "{", "$", "interval", "=", "$", "this", "->", "createdOn", "->", "diff", "(", "new", "\\", "DateTimeImmutable", "(", ")", ")", ";", "return", "$", "interval", "->", "s", ">=", "(", "int", ...
Checks if the token is expired comparing with the given lifetime. @param int $lifetime The lifetime of the token @return bool
[ "Checks", "if", "the", "token", "is", "expired", "comparing", "with", "the", "given", "lifetime", "." ]
734900f463042194502191e4fb3e4f588cb7bf6f
https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/UserToken.php#L90-L95
train
jasny/db
src/Result.php
Result.resolveMeta
protected function resolveMeta(): void { expect_type($this->meta, 'callable', \BadMethodCallException::class); $meta = i\function_call($this->meta); expect_type($meta, 'array', \UnexpectedValueException::class, "Failed to get meta: Expected %2\$s, got %1\$s"); $this->meta = $meta; }
php
protected function resolveMeta(): void { expect_type($this->meta, 'callable', \BadMethodCallException::class); $meta = i\function_call($this->meta); expect_type($meta, 'array', \UnexpectedValueException::class, "Failed to get meta: Expected %2\$s, got %1\$s"); $this->meta = $meta; }
[ "protected", "function", "resolveMeta", "(", ")", ":", "void", "{", "expect_type", "(", "$", "this", "->", "meta", ",", "'callable'", ",", "\\", "BadMethodCallException", "::", "class", ")", ";", "$", "meta", "=", "i", "\\", "function_call", "(", "$", "t...
Resolve metadata if it's still a Closure. @return void @throws \UnexpectedValueException if metadata closure didn't return a positive integer
[ "Resolve", "metadata", "if", "it", "s", "still", "a", "Closure", "." ]
efd57d9dd8f3f40235c4da8b39a81f03d5f79b25
https://github.com/jasny/db/blob/efd57d9dd8f3f40235c4da8b39a81f03d5f79b25/src/Result.php#L57-L65
train
Bartacus/BartacusBundle
EventSubscriber/LocaleSubscriber.php
LocaleSubscriber.getLocaleFromTypo3
private function getLocaleFromTypo3(Request $request): ?string { $locale = null; if ((bool) $language = $request->attributes->get('language')) { /* @var SiteLanguage $language */ [$locale] = \explode('.', $language->getLocale()); } elseif ((bool) $site = $request->attributes->get('site')) { /* @var Site $site */ [$locale] = \explode('.', $site->getDefaultLanguage()->getLocale()); } return $locale; }
php
private function getLocaleFromTypo3(Request $request): ?string { $locale = null; if ((bool) $language = $request->attributes->get('language')) { /* @var SiteLanguage $language */ [$locale] = \explode('.', $language->getLocale()); } elseif ((bool) $site = $request->attributes->get('site')) { /* @var Site $site */ [$locale] = \explode('.', $site->getDefaultLanguage()->getLocale()); } return $locale; }
[ "private", "function", "getLocaleFromTypo3", "(", "Request", "$", "request", ")", ":", "?", "string", "{", "$", "locale", "=", "null", ";", "if", "(", "(", "bool", ")", "$", "language", "=", "$", "request", "->", "attributes", "->", "get", "(", "'langu...
Tries to get the exact locale from TYPO3 if it can be found in the request.
[ "Tries", "to", "get", "the", "exact", "locale", "from", "TYPO3", "if", "it", "can", "be", "found", "in", "the", "request", "." ]
a24937be00e1a8f0b35f92db0c722907339b1ccb
https://github.com/Bartacus/BartacusBundle/blob/a24937be00e1a8f0b35f92db0c722907339b1ccb/EventSubscriber/LocaleSubscriber.php#L126-L139
train
Bartacus/BartacusBundle
EventSubscriber/LocaleSubscriber.php
LocaleSubscriber.getDenormalizedLocaleFromTypo3
private function getDenormalizedLocaleFromTypo3(Request $request): ?string { if ((bool) $language = $request->attributes->get('language')) { /* @var SiteLanguage $language */ return \trim($language->getBase()->getPath(), '/'); } if ((bool) $site = $request->attributes->get('site')) { /* @var Site $site */ return \trim($site->getDefaultLanguage()->getBase()->getPath(), '/'); } return null; }
php
private function getDenormalizedLocaleFromTypo3(Request $request): ?string { if ((bool) $language = $request->attributes->get('language')) { /* @var SiteLanguage $language */ return \trim($language->getBase()->getPath(), '/'); } if ((bool) $site = $request->attributes->get('site')) { /* @var Site $site */ return \trim($site->getDefaultLanguage()->getBase()->getPath(), '/'); } return null; }
[ "private", "function", "getDenormalizedLocaleFromTypo3", "(", "Request", "$", "request", ")", ":", "?", "string", "{", "if", "(", "(", "bool", ")", "$", "language", "=", "$", "request", "->", "attributes", "->", "get", "(", "'language'", ")", ")", "{", "...
Tries to get a denormalized locale for routing resolved from the base path. It is assumed here, that every site configuration has the locale as base path only.
[ "Tries", "to", "get", "a", "denormalized", "locale", "for", "routing", "resolved", "from", "the", "base", "path", "." ]
a24937be00e1a8f0b35f92db0c722907339b1ccb
https://github.com/Bartacus/BartacusBundle/blob/a24937be00e1a8f0b35f92db0c722907339b1ccb/EventSubscriber/LocaleSubscriber.php#L146-L159
train
Kolyunya/codeception-markup-validator
sources/Lib/MarkupValidator/W3CMarkupValidator.php
W3CMarkupValidator.getValidationData
private function getValidationData($markup) { $this->httpRequestParameters['body'] = $markup; $reponse = $this->httpClient->post( $this->configuration[self::ENDPOINT_CONFIG_KEY], $this->httpRequestParameters ); $responseData = $reponse->getBody()->getContents(); $validationData = json_decode($responseData, true); if ($validationData === null) { throw new Exception('Unable to parse W3C Markup Validation Service response.'); } return $validationData; }
php
private function getValidationData($markup) { $this->httpRequestParameters['body'] = $markup; $reponse = $this->httpClient->post( $this->configuration[self::ENDPOINT_CONFIG_KEY], $this->httpRequestParameters ); $responseData = $reponse->getBody()->getContents(); $validationData = json_decode($responseData, true); if ($validationData === null) { throw new Exception('Unable to parse W3C Markup Validation Service response.'); } return $validationData; }
[ "private", "function", "getValidationData", "(", "$", "markup", ")", "{", "$", "this", "->", "httpRequestParameters", "[", "'body'", "]", "=", "$", "markup", ";", "$", "reponse", "=", "$", "this", "->", "httpClient", "->", "post", "(", "$", "this", "->",...
Sends a validation request to a W3C Markup Validation Service and returns decoded validation data. @param string $markup Markup to get validation data for. @return array Validation data for provided markup.
[ "Sends", "a", "validation", "request", "to", "a", "W3C", "Markup", "Validation", "Service", "and", "returns", "decoded", "validation", "data", "." ]
89b5fa5e28602af7e7f2a8ee42686be697dd00a7
https://github.com/Kolyunya/codeception-markup-validator/blob/89b5fa5e28602af7e7f2a8ee42686be697dd00a7/sources/Lib/MarkupValidator/W3CMarkupValidator.php#L95-L110
train
Kolyunya/codeception-markup-validator
sources/Lib/MarkupValidator/W3CMarkupValidator.php
W3CMarkupValidator.getValidationMessages
private function getValidationMessages(array $validationData) { $messages = array(); $messagesData = $validationData['messages']; foreach ($messagesData as $messageData) { $message = new W3CMarkupValidatorMessage($messageData); $messages[] = $message; } return $messages; }
php
private function getValidationMessages(array $validationData) { $messages = array(); $messagesData = $validationData['messages']; foreach ($messagesData as $messageData) { $message = new W3CMarkupValidatorMessage($messageData); $messages[] = $message; } return $messages; }
[ "private", "function", "getValidationMessages", "(", "array", "$", "validationData", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "$", "messagesData", "=", "$", "validationData", "[", "'messages'", "]", ";", "foreach", "(", "$", "messagesData", "a...
Parses validation data and returns validation messages. @param array $validationData Validation data. @return MarkupValidatorMessageInterface[] Validation messages.
[ "Parses", "validation", "data", "and", "returns", "validation", "messages", "." ]
89b5fa5e28602af7e7f2a8ee42686be697dd00a7
https://github.com/Kolyunya/codeception-markup-validator/blob/89b5fa5e28602af7e7f2a8ee42686be697dd00a7/sources/Lib/MarkupValidator/W3CMarkupValidator.php#L118-L128
train
czim/laravel-cms-auth
src/Sentinel/Users/EloquentUser.php
EloquentUser.can
public function can($permission, $allowAny = false) { if ($allowAny) { return $this->hasAnyAccess( is_array($permission) ? $permission : [ $permission ] ); } return $this->hasAccess( is_array($permission) ? $permission : [ $permission ] ); }
php
public function can($permission, $allowAny = false) { if ($allowAny) { return $this->hasAnyAccess( is_array($permission) ? $permission : [ $permission ] ); } return $this->hasAccess( is_array($permission) ? $permission : [ $permission ] ); }
[ "public", "function", "can", "(", "$", "permission", ",", "$", "allowAny", "=", "false", ")", "{", "if", "(", "$", "allowAny", ")", "{", "return", "$", "this", "->", "hasAnyAccess", "(", "is_array", "(", "$", "permission", ")", "?", "$", "permission", ...
Returns whether the user has the given permission. @param string|string[] $permission @param bool $allowAny if true, allows if any is permitted @return bool
[ "Returns", "whether", "the", "user", "has", "the", "given", "permission", "." ]
dbd7fecc69e891f8befdd6039244037a42c4b10f
https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Sentinel/Users/EloquentUser.php#L135-L146
train
neos/party
Classes/Domain/Validator/PersonNameValidator.php
PersonNameValidator.isValid
public function isValid($value) { if ($value instanceof PersonName) { if (strlen(trim($value->getFullName())) === 0) { $this->addError('The person name cannot be empty.', 1268676765); } } }
php
public function isValid($value) { if ($value instanceof PersonName) { if (strlen(trim($value->getFullName())) === 0) { $this->addError('The person name cannot be empty.', 1268676765); } } }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "PersonName", ")", "{", "if", "(", "strlen", "(", "trim", "(", "$", "value", "->", "getFullName", "(", ")", ")", ")", "===", "0", ")", "{", "$", ...
Checks if the concatenated person name has at least one character. Any errors can be retrieved through the getErrors() method. @param mixed $value The value that should be validated @return void
[ "Checks", "if", "the", "concatenated", "person", "name", "has", "at", "least", "one", "character", "." ]
cf771039e8da24762c21640f8761d40d281c0cd0
https://github.com/neos/party/blob/cf771039e8da24762c21640f8761d40d281c0cd0/Classes/Domain/Validator/PersonNameValidator.php#L31-L38
train
vegas-cmf/core
src/Mvc/View/Engine/RegisterHelpersTrait.php
RegisterHelpersTrait.registerHelpers
public function registerHelpers() { foreach (glob($this->getHelpersDirectoryPath() . '*.php') as $file) { $helperName = pathinfo($file, PATHINFO_FILENAME); $this->registerHelper(lcfirst($helperName)); } }
php
public function registerHelpers() { foreach (glob($this->getHelpersDirectoryPath() . '*.php') as $file) { $helperName = pathinfo($file, PATHINFO_FILENAME); $this->registerHelper(lcfirst($helperName)); } }
[ "public", "function", "registerHelpers", "(", ")", "{", "foreach", "(", "glob", "(", "$", "this", "->", "getHelpersDirectoryPath", "(", ")", ".", "'*.php'", ")", "as", "$", "file", ")", "{", "$", "helperName", "=", "pathinfo", "(", "$", "file", ",", "P...
Registers view helpers
[ "Registers", "view", "helpers" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View/Engine/RegisterHelpersTrait.php#L37-L43
train
vegas-cmf/core
src/Bootstrap/EnvironmentInitializerTrait.php
EnvironmentInitializerTrait.initEnvironment
public function initEnvironment(Config $config) { if (isset($config->application) && isset($config->application->environment)) { $env = $config->application->environment; } else { $env = Constants::DEFAULT_ENV; } if (!defined('APPLICATION_ENV')) { define('APPLICATION_ENV', $env); } $this->getDI()->set('environment', function() use ($env) { return $env; }, true); }
php
public function initEnvironment(Config $config) { if (isset($config->application) && isset($config->application->environment)) { $env = $config->application->environment; } else { $env = Constants::DEFAULT_ENV; } if (!defined('APPLICATION_ENV')) { define('APPLICATION_ENV', $env); } $this->getDI()->set('environment', function() use ($env) { return $env; }, true); }
[ "public", "function", "initEnvironment", "(", "Config", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "->", "application", ")", "&&", "isset", "(", "$", "config", "->", "application", "->", "environment", ")", ")", "{", "$", "env", "...
Initializes application environment
[ "Initializes", "application", "environment" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Bootstrap/EnvironmentInitializerTrait.php#L18-L33
train
vegas-cmf/core
src/Mvc/Module/Loader.php
Loader.dump
public function dump($inputDirectory, $outputDirectory, $dumpVendorModules = true) { $modulesList = []; //extracts list of modules from module directory $directoryIterator = new \DirectoryIterator($inputDirectory); foreach ($directoryIterator as $moduleDir) { if ($moduleDir->isDot()) { continue; } $moduleSettingsFile = $moduleDir->getPathname() . DIRECTORY_SEPARATOR . self::MODULE_SETTINGS_FILE; if (!file_exists($moduleSettingsFile)) { continue; } $modulesList[$moduleDir->getBasename()] = [ 'className' => $moduleDir->getBasename() . '\\' . pathinfo(self::MODULE_SETTINGS_FILE, PATHINFO_FILENAME), 'path' => $moduleSettingsFile ]; } if ($dumpVendorModules) { $this->dumpModulesFromVendor($modulesList); } //saves generated array to php source file FileWriter::writeObject( $outputDirectory . self::MODULE_STATIC_FILE, $modulesList, true ); return $modulesList; }
php
public function dump($inputDirectory, $outputDirectory, $dumpVendorModules = true) { $modulesList = []; //extracts list of modules from module directory $directoryIterator = new \DirectoryIterator($inputDirectory); foreach ($directoryIterator as $moduleDir) { if ($moduleDir->isDot()) { continue; } $moduleSettingsFile = $moduleDir->getPathname() . DIRECTORY_SEPARATOR . self::MODULE_SETTINGS_FILE; if (!file_exists($moduleSettingsFile)) { continue; } $modulesList[$moduleDir->getBasename()] = [ 'className' => $moduleDir->getBasename() . '\\' . pathinfo(self::MODULE_SETTINGS_FILE, PATHINFO_FILENAME), 'path' => $moduleSettingsFile ]; } if ($dumpVendorModules) { $this->dumpModulesFromVendor($modulesList); } //saves generated array to php source file FileWriter::writeObject( $outputDirectory . self::MODULE_STATIC_FILE, $modulesList, true ); return $modulesList; }
[ "public", "function", "dump", "(", "$", "inputDirectory", ",", "$", "outputDirectory", ",", "$", "dumpVendorModules", "=", "true", ")", "{", "$", "modulesList", "=", "[", "]", ";", "//extracts list of modules from module directory", "$", "directoryIterator", "=", ...
Generates list of modules into source file @param string $inputDirectory @param string $outputDirectory @param bool $dumpVendorModules @return array
[ "Generates", "list", "of", "modules", "into", "source", "file" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Module/Loader.php#L58-L95
train
vegas-cmf/core
src/Mvc/Module/Loader.php
Loader.dumpModulesFromVendor
public function dumpModulesFromVendor(array &$modulesList) { if (!file_exists(APP_ROOT.'/composer.json')) { return $modulesList; } $fileContent = file_get_contents(APP_ROOT . DIRECTORY_SEPARATOR . 'composer.json'); $json = json_decode($fileContent, true); $vendorDir = realpath(APP_ROOT . ( isset($json['config']['vendor-dir']) ? DIRECTORY_SEPARATOR . $json['config']['vendor-dir'] : DIRECTORY_SEPARATOR.'vendor' ) ); foreach ($this->getModuleProviders() as $provider) { $providerDir = $vendorDir . DIRECTORY_SEPARATOR . $provider; $this->dumpSingleProviderModulesFromVendor($modulesList, $providerDir); } return $modulesList; }
php
public function dumpModulesFromVendor(array &$modulesList) { if (!file_exists(APP_ROOT.'/composer.json')) { return $modulesList; } $fileContent = file_get_contents(APP_ROOT . DIRECTORY_SEPARATOR . 'composer.json'); $json = json_decode($fileContent, true); $vendorDir = realpath(APP_ROOT . ( isset($json['config']['vendor-dir']) ? DIRECTORY_SEPARATOR . $json['config']['vendor-dir'] : DIRECTORY_SEPARATOR.'vendor' ) ); foreach ($this->getModuleProviders() as $provider) { $providerDir = $vendorDir . DIRECTORY_SEPARATOR . $provider; $this->dumpSingleProviderModulesFromVendor($modulesList, $providerDir); } return $modulesList; }
[ "public", "function", "dumpModulesFromVendor", "(", "array", "&", "$", "modulesList", ")", "{", "if", "(", "!", "file_exists", "(", "APP_ROOT", ".", "'/composer.json'", ")", ")", "{", "return", "$", "modulesList", ";", "}", "$", "fileContent", "=", "file_get...
Extract Vegas modules from composer vegas-cmf vendors. @param $modulesList @return mixed
[ "Extract", "Vegas", "modules", "from", "composer", "vegas", "-", "cmf", "vendors", "." ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Module/Loader.php#L103-L126
train
vegas-cmf/core
src/Mvc/Module/Loader.php
Loader.dumpSingleProviderModulesFromVendor
private function dumpSingleProviderModulesFromVendor(array &$modulesList, $providerDir) { $directoryIterator = new \DirectoryIterator($providerDir); foreach ($directoryIterator as $libDir) { if ($libDir->isDot()) { continue; } //creates path to Module.php file $moduleSettingsFile = implode(DIRECTORY_SEPARATOR, [ $providerDir, $libDir, 'module', self::MODULE_SETTINGS_FILE ]); if (!file_exists($moduleSettingsFile)) { continue; } $baseName = Text::camelize($libDir->getBasename()); if (!isset($modulesList[$baseName])) { $modulesList[$baseName] = [ 'className' => $baseName . '\\' . pathinfo(self::MODULE_SETTINGS_FILE, PATHINFO_FILENAME), 'path' => $moduleSettingsFile ]; } } }
php
private function dumpSingleProviderModulesFromVendor(array &$modulesList, $providerDir) { $directoryIterator = new \DirectoryIterator($providerDir); foreach ($directoryIterator as $libDir) { if ($libDir->isDot()) { continue; } //creates path to Module.php file $moduleSettingsFile = implode(DIRECTORY_SEPARATOR, [ $providerDir, $libDir, 'module', self::MODULE_SETTINGS_FILE ]); if (!file_exists($moduleSettingsFile)) { continue; } $baseName = Text::camelize($libDir->getBasename()); if (!isset($modulesList[$baseName])) { $modulesList[$baseName] = [ 'className' => $baseName . '\\' . pathinfo(self::MODULE_SETTINGS_FILE, PATHINFO_FILENAME), 'path' => $moduleSettingsFile ]; } } }
[ "private", "function", "dumpSingleProviderModulesFromVendor", "(", "array", "&", "$", "modulesList", ",", "$", "providerDir", ")", "{", "$", "directoryIterator", "=", "new", "\\", "DirectoryIterator", "(", "$", "providerDir", ")", ";", "foreach", "(", "$", "dire...
Extracts Vegas modules from specific provider in vendor directory. @param array $modulesList @param string $providerDir directory path for module provider (e.x. vegas-cmf)
[ "Extracts", "Vegas", "modules", "from", "specific", "provider", "in", "vendor", "directory", "." ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Module/Loader.php#L134-L160
train
vegas-cmf/core
src/Mvc/Module/Loader.php
Loader.getModuleProviders
private function getModuleProviders() { $defaultProviders = [ 'vegas-cmf' ]; $appConfig = $this->di->get('config')->application; if (!isset($appConfig->vendorModuleProvider)) { $providerNames = []; } else if (is_string($appConfig->vendorModuleProvider)) { $providerNames = [$appConfig->vendorModuleProvider]; } else { $providerNames = $appConfig->vendorModuleProvider->toArray(); } return array_unique(array_merge($defaultProviders, $providerNames)); }
php
private function getModuleProviders() { $defaultProviders = [ 'vegas-cmf' ]; $appConfig = $this->di->get('config')->application; if (!isset($appConfig->vendorModuleProvider)) { $providerNames = []; } else if (is_string($appConfig->vendorModuleProvider)) { $providerNames = [$appConfig->vendorModuleProvider]; } else { $providerNames = $appConfig->vendorModuleProvider->toArray(); } return array_unique(array_merge($defaultProviders, $providerNames)); }
[ "private", "function", "getModuleProviders", "(", ")", "{", "$", "defaultProviders", "=", "[", "'vegas-cmf'", "]", ";", "$", "appConfig", "=", "$", "this", "->", "di", "->", "get", "(", "'config'", ")", "->", "application", ";", "if", "(", "!", "isset", ...
Get available module providers - default is vegas-cmf. Additional providers can be placed under application->vendorModuleProvider key in config file. Value of the key can be either a string with name or an array with multiple names. @return array
[ "Get", "available", "module", "providers", "-", "default", "is", "vegas", "-", "cmf", ".", "Additional", "providers", "can", "be", "placed", "under", "application", "-", ">", "vendorModuleProvider", "key", "in", "config", "file", ".", "Value", "of", "the", "...
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Module/Loader.php#L169-L185
train
softberg/quantum-core
src/Libraries/Curl/Curl.php
Curl.getResponseHeaders
public function getResponseHeaders() { $requestHeaders = []; if ($this->headers instanceof \ArrayAccess) { while ($this->headers->valid()) { $requestHeaders[$this->headers->key()] = $this->headers->current(); $this->headers->next(); } } return $requestHeaders; }
php
public function getResponseHeaders() { $requestHeaders = []; if ($this->headers instanceof \ArrayAccess) { while ($this->headers->valid()) { $requestHeaders[$this->headers->key()] = $this->headers->current(); $this->headers->next(); } } return $requestHeaders; }
[ "public", "function", "getResponseHeaders", "(", ")", "{", "$", "requestHeaders", "=", "[", "]", ";", "if", "(", "$", "this", "->", "headers", "instanceof", "\\", "ArrayAccess", ")", "{", "while", "(", "$", "this", "->", "headers", "->", "valid", "(", ...
Get Response Headers Gets the response headers @return array
[ "Get", "Response", "Headers" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Curl/Curl.php#L137-L148
train
softberg/quantum-core
src/Libraries/Debugger/Debugger.php
Debugger.runDebuger
public static function runDebuger($view = null) { self::$debugbar = new Debugger(); self::$assets_url = base_url() . '/assets/DebugBar/Resources'; self::addQueries(); self::addMessages(); self::addRoute($view); self::$debugbarRenderer = self::$debugbar->getJavascriptRenderer()->setBaseUrl(self::$assets_url); return self::$debugbarRenderer; }
php
public static function runDebuger($view = null) { self::$debugbar = new Debugger(); self::$assets_url = base_url() . '/assets/DebugBar/Resources'; self::addQueries(); self::addMessages(); self::addRoute($view); self::$debugbarRenderer = self::$debugbar->getJavascriptRenderer()->setBaseUrl(self::$assets_url); return self::$debugbarRenderer; }
[ "public", "static", "function", "runDebuger", "(", "$", "view", "=", "null", ")", "{", "self", "::", "$", "debugbar", "=", "new", "Debugger", "(", ")", ";", "self", "::", "$", "assets_url", "=", "base_url", "(", ")", ".", "'/assets/DebugBar/Resources'", ...
Runs the debug bar @param string $view @return object
[ "Runs", "the", "debug", "bar" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Debugger/Debugger.php#L80-L90
train
softberg/quantum-core
src/Libraries/Debugger/Debugger.php
Debugger.addQueries
private static function addQueries() { self::$debugbar->addCollector(new MessagesCollector('queries')); self::$queries = ORM::get_query_log(); if (self::$queries) { foreach (self::$queries as $query) { self::$debugbar['queries']->info($query); } } }
php
private static function addQueries() { self::$debugbar->addCollector(new MessagesCollector('queries')); self::$queries = ORM::get_query_log(); if (self::$queries) { foreach (self::$queries as $query) { self::$debugbar['queries']->info($query); } } }
[ "private", "static", "function", "addQueries", "(", ")", "{", "self", "::", "$", "debugbar", "->", "addCollector", "(", "new", "MessagesCollector", "(", "'queries'", ")", ")", ";", "self", "::", "$", "queries", "=", "ORM", "::", "get_query_log", "(", ")", ...
Collects the queries @return void
[ "Collects", "the", "queries" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Debugger/Debugger.php#L97-L105
train
softberg/quantum-core
src/Libraries/Debugger/Debugger.php
Debugger.addRoute
private static function addRoute($view) { $uri = RouteController::$currentRoute['uri']; $method = RouteController::$currentRoute['method']; $module = RouteController::$currentRoute['module']; $current_controller = 'modules' . DS . $module . DS . RouteController::$currentRoute['controller']; $current_action = RouteController::$currentRoute['action']; $args = RouteController::$currentRoute['args']; $route = [ 'Route' => $uri, 'Method' => $method, 'Module' => $module, 'Controller' => $current_controller, 'Action' => $current_action, 'View' => '', 'Args' => $args, ]; if ($view) { $route['View'] = 'modules/' . RouteController::$currentRoute['module'] . '/Views/' . $view; } self::$debugbar->addCollector(new MessagesCollector('routes')); self::$debugbar['routes']->info($route); }
php
private static function addRoute($view) { $uri = RouteController::$currentRoute['uri']; $method = RouteController::$currentRoute['method']; $module = RouteController::$currentRoute['module']; $current_controller = 'modules' . DS . $module . DS . RouteController::$currentRoute['controller']; $current_action = RouteController::$currentRoute['action']; $args = RouteController::$currentRoute['args']; $route = [ 'Route' => $uri, 'Method' => $method, 'Module' => $module, 'Controller' => $current_controller, 'Action' => $current_action, 'View' => '', 'Args' => $args, ]; if ($view) { $route['View'] = 'modules/' . RouteController::$currentRoute['module'] . '/Views/' . $view; } self::$debugbar->addCollector(new MessagesCollector('routes')); self::$debugbar['routes']->info($route); }
[ "private", "static", "function", "addRoute", "(", "$", "view", ")", "{", "$", "uri", "=", "RouteController", "::", "$", "currentRoute", "[", "'uri'", "]", ";", "$", "method", "=", "RouteController", "::", "$", "currentRoute", "[", "'method'", "]", ";", "...
Collects the routes @return void
[ "Collects", "the", "routes" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Debugger/Debugger.php#L112-L136
train
softberg/quantum-core
src/Libraries/Debugger/Debugger.php
Debugger.addMessages
private static function addMessages() { $out_data = session()->get('output'); if ($out_data) { foreach ($out_data as $data) { self::$debugbar['messages']->debug($data); } session()->delete('output'); } }
php
private static function addMessages() { $out_data = session()->get('output'); if ($out_data) { foreach ($out_data as $data) { self::$debugbar['messages']->debug($data); } session()->delete('output'); } }
[ "private", "static", "function", "addMessages", "(", ")", "{", "$", "out_data", "=", "session", "(", ")", "->", "get", "(", "'output'", ")", ";", "if", "(", "$", "out_data", ")", "{", "foreach", "(", "$", "out_data", "as", "$", "data", ")", "{", "s...
Collects the messages @return void
[ "Collects", "the", "messages" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Debugger/Debugger.php#L143-L151
train
chimeraphp/foundation
src/ExecuteCommand.php
ExecuteCommand.execute
public function execute(Input $input): void { $this->bus->handle( $this->messageCreator->create($this->command, $input) ); }
php
public function execute(Input $input): void { $this->bus->handle( $this->messageCreator->create($this->command, $input) ); }
[ "public", "function", "execute", "(", "Input", "$", "input", ")", ":", "void", "{", "$", "this", "->", "bus", "->", "handle", "(", "$", "this", "->", "messageCreator", "->", "create", "(", "$", "this", "->", "command", ",", "$", "input", ")", ")", ...
Creates the command with given input and executes it @throws MessageCannotBeCreated
[ "Creates", "the", "command", "with", "given", "input", "and", "executes", "it" ]
80535a588057a7d924233696c9c06db1faba3fa3
https://github.com/chimeraphp/foundation/blob/80535a588057a7d924233696c9c06db1faba3fa3/src/ExecuteCommand.php#L40-L45
train
vegas-cmf/core
src/DI/Scaffolding.php
Scaffolding.processForm
private function processForm($values) { $form = $this->getForm($this->record); $form->bind($values, $this->record); if ($form->isValid()) { return $this->record->save(); } $this->form = $form; throw new InvalidFormException(); }
php
private function processForm($values) { $form = $this->getForm($this->record); $form->bind($values, $this->record); if ($form->isValid()) { return $this->record->save(); } $this->form = $form; throw new InvalidFormException(); }
[ "private", "function", "processForm", "(", "$", "values", ")", "{", "$", "form", "=", "$", "this", "->", "getForm", "(", "$", "this", "->", "record", ")", ";", "$", "form", "->", "bind", "(", "$", "values", ",", "$", "this", "->", "record", ")", ...
Processes form with provided values @param $values @return mixed @throws Scaffolding\Exception\InvalidFormException @internal
[ "Processes", "form", "with", "provided", "values" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/DI/Scaffolding.php#L195-L206
train
duncan3dc/php-helpers
src/Image.php
Image.resize
public static function resize($options = null) { $options = Helper::getOptions($options, [ "fromPath" => null, "toPath" => null, "width" => null, "height" => null, ]); if (!$fromPath = trim($options["fromPath"])) { throw new \Exception("No from path specified to read from"); } if (!$toPath = trim($options["toPath"])) { throw new \Exception("No to path specified to save to"); } $maxWidth = round($options["width"]); $maxHeight = round($options["height"]); list($width, $height, $format) = getimagesize($fromPath); if ($width < 1 || $height < 1) { copy($fromPath, $toPath); return; } if ($maxWidth < 1 && $maxHeight < 1) { copy($fromPath, $toPath); return; } if ($width < $maxWidth && $height < $maxHeight) { copy($fromPath, $toPath); return; } $newWidth = $width; $newHeight = $height; if ($maxHeight && $newHeight > $maxHeight) { $ratio = $newWidth / $newHeight; $newHeight = $maxHeight; $newWidth = $newHeight * $ratio; } if ($maxWidth && $newWidth > $maxWidth) { $ratio = $newHeight / $newWidth; $newWidth = $maxWidth; $newHeight = $newWidth * $ratio; } $image = static::create($fromPath, $format); $newImage = imagecreatetruecolor($newWidth, $newHeight); if ($format != IMAGETYPE_JPEG) { imagealphablending($newImage, false); imagesavealpha($newImage, true); $background = imagecolorallocatealpha($newImage, 255, 255, 255, 127); imagecolortransparent($newImage, $background); } imagecopyresampled($newImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); static::save($newImage, $toPath, $format); imagedestroy($image); imagedestroy($newImage); }
php
public static function resize($options = null) { $options = Helper::getOptions($options, [ "fromPath" => null, "toPath" => null, "width" => null, "height" => null, ]); if (!$fromPath = trim($options["fromPath"])) { throw new \Exception("No from path specified to read from"); } if (!$toPath = trim($options["toPath"])) { throw new \Exception("No to path specified to save to"); } $maxWidth = round($options["width"]); $maxHeight = round($options["height"]); list($width, $height, $format) = getimagesize($fromPath); if ($width < 1 || $height < 1) { copy($fromPath, $toPath); return; } if ($maxWidth < 1 && $maxHeight < 1) { copy($fromPath, $toPath); return; } if ($width < $maxWidth && $height < $maxHeight) { copy($fromPath, $toPath); return; } $newWidth = $width; $newHeight = $height; if ($maxHeight && $newHeight > $maxHeight) { $ratio = $newWidth / $newHeight; $newHeight = $maxHeight; $newWidth = $newHeight * $ratio; } if ($maxWidth && $newWidth > $maxWidth) { $ratio = $newHeight / $newWidth; $newWidth = $maxWidth; $newHeight = $newWidth * $ratio; } $image = static::create($fromPath, $format); $newImage = imagecreatetruecolor($newWidth, $newHeight); if ($format != IMAGETYPE_JPEG) { imagealphablending($newImage, false); imagesavealpha($newImage, true); $background = imagecolorallocatealpha($newImage, 255, 255, 255, 127); imagecolortransparent($newImage, $background); } imagecopyresampled($newImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); static::save($newImage, $toPath, $format); imagedestroy($image); imagedestroy($newImage); }
[ "public", "static", "function", "resize", "(", "$", "options", "=", "null", ")", "{", "$", "options", "=", "Helper", "::", "getOptions", "(", "$", "options", ",", "[", "\"fromPath\"", "=>", "null", ",", "\"toPath\"", "=>", "null", ",", "\"width\"", "=>",...
Resize an image, maintaining the same aspect ratio. If the image is already an appropriate size then it is just copied. $options: - string "fromPath" The path of the current image file - string "toPath" The path to save the resized image to - int "width" The maximum width that the image can be - int "height" The maximum height that the image can be @param array $options An array of options (see above) @return null
[ "Resize", "an", "image", "maintaining", "the", "same", "aspect", "ratio", ".", "If", "the", "image", "is", "already", "an", "appropriate", "size", "then", "it", "is", "just", "copied", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Image.php#L115-L180
train
duncan3dc/php-helpers
src/Image.php
Image.img
public static function img($options = null) { $options = Helper::getOptions($options, [ "path" => "images/img", "basename" => null, "filename" => null, "width" => null, "height" => null, ]); $path = $options["path"]; if ($path[0] == "/") { $fullpath = $path; } else { $fullpath = Env::path($path, Env::PATH_DOCUMENT_ROOT); } $filename = $options["filename"]; if ($basename = $options["basename"]) { $original = $fullpath . "/original/" . $basename; if (file_exists($original)) { if ($ext = static::getExtension($original)) { $filename = $basename . "." . $ext; copy($original, $fullpath . "/original/" . $filename); } } } if (!$filename) { throw new \Exception("No image filename provided to use"); } $original = $fullpath . "/original/" . $filename; if (!file_exists($original)) { throw new \Exception("Original image file does not exist (" . $original . ")"); } $w = $options["width"]; $h = $options["height"]; if (!$w && !$h) { return $path . "/original/" . $filename; } if ($w && $h) { $dir = "max" . $w . "x" . $h; } elseif ($w) { $dir = "width" . $w; } elseif ($h) { $dir = "height" . $h; } $fullpath .= "/" . $dir; $newfile = $fullpath . "/" . $filename; $newpath = $path . "/" . $dir . "/" . $filename; if (file_exists($newfile)) { return $newpath; } if (!is_dir($fullpath)) { mkdir($fullpath, 0777, true); } static::resize([ "fromPath" => $original, "toPath" => $newfile, "width" => $w, "height" => $h, ]); return $newpath; }
php
public static function img($options = null) { $options = Helper::getOptions($options, [ "path" => "images/img", "basename" => null, "filename" => null, "width" => null, "height" => null, ]); $path = $options["path"]; if ($path[0] == "/") { $fullpath = $path; } else { $fullpath = Env::path($path, Env::PATH_DOCUMENT_ROOT); } $filename = $options["filename"]; if ($basename = $options["basename"]) { $original = $fullpath . "/original/" . $basename; if (file_exists($original)) { if ($ext = static::getExtension($original)) { $filename = $basename . "." . $ext; copy($original, $fullpath . "/original/" . $filename); } } } if (!$filename) { throw new \Exception("No image filename provided to use"); } $original = $fullpath . "/original/" . $filename; if (!file_exists($original)) { throw new \Exception("Original image file does not exist (" . $original . ")"); } $w = $options["width"]; $h = $options["height"]; if (!$w && !$h) { return $path . "/original/" . $filename; } if ($w && $h) { $dir = "max" . $w . "x" . $h; } elseif ($w) { $dir = "width" . $w; } elseif ($h) { $dir = "height" . $h; } $fullpath .= "/" . $dir; $newfile = $fullpath . "/" . $filename; $newpath = $path . "/" . $dir . "/" . $filename; if (file_exists($newfile)) { return $newpath; } if (!is_dir($fullpath)) { mkdir($fullpath, 0777, true); } static::resize([ "fromPath" => $original, "toPath" => $newfile, "width" => $w, "height" => $h, ]); return $newpath; }
[ "public", "static", "function", "img", "(", "$", "options", "=", "null", ")", "{", "$", "options", "=", "Helper", "::", "getOptions", "(", "$", "options", ",", "[", "\"path\"", "=>", "\"images/img\"", ",", "\"basename\"", "=>", "null", ",", "\"filename\"",...
Automatically resize and create images on the fly. If the image already exists then it's path is just passed back. $options: - string "path" The path that the images reside in (default: "images/img") - string "basename" The filename, without extension, of the image, the extension will be automatically established and appended - string "filename" The filename, including extension, of the image. Either this or "basename" must be set - int "width" The maximum width that the image can be, if the image is wider it will be resized (maintaining the same aspect ratio) - int "height" The maximum height that the image can be, if the image is taller it will be resized (maintaining the same aspect ratio) @param array $options An array of options (see above) @return string
[ "Automatically", "resize", "and", "create", "images", "on", "the", "fly", ".", "If", "the", "image", "already", "exists", "then", "it", "s", "path", "is", "just", "passed", "back", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Image.php#L198-L270
train
duncan3dc/php-helpers
src/Image.php
Image.create
public static function create($path, $format) { switch ($format) { case IMAGETYPE_JPEG: $result = imagecreatefromjpeg($path); break; case IMAGETYPE_PNG: $result = imagecreatefrompng($path); break; case IMAGETYPE_GIF: $result = imagecreatefromgif($path); break; } if (!$result) { throw new \Exception("Failing to create image (" . $path . ")"); } return $result; }
php
public static function create($path, $format) { switch ($format) { case IMAGETYPE_JPEG: $result = imagecreatefromjpeg($path); break; case IMAGETYPE_PNG: $result = imagecreatefrompng($path); break; case IMAGETYPE_GIF: $result = imagecreatefromgif($path); break; } if (!$result) { throw new \Exception("Failing to create image (" . $path . ")"); } return $result; }
[ "public", "static", "function", "create", "(", "$", "path", ",", "$", "format", ")", "{", "switch", "(", "$", "format", ")", "{", "case", "IMAGETYPE_JPEG", ":", "$", "result", "=", "imagecreatefromjpeg", "(", "$", "path", ")", ";", "break", ";", "case"...
Create an image resource from an image on disk. @param string $path The path to load the image from @param int $format Image type constant (http://php.net/manual/en/image.constants.php) @return resource
[ "Create", "an", "image", "resource", "from", "an", "image", "on", "disk", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Image.php#L281-L300
train
duncan3dc/php-helpers
src/Image.php
Image.save
public static function save($image, $path, $format) { switch ($format) { case IMAGETYPE_JPEG: $result = imagejpeg($image, $path, 100); break; case IMAGETYPE_PNG: $result = imagepng($image, $path, 9); break; case IMAGETYPE_GIF: $result = imagegif($image, $path); break; } if (!$result) { throw new \Exception("Failed to save image (" . $path . ")"); } }
php
public static function save($image, $path, $format) { switch ($format) { case IMAGETYPE_JPEG: $result = imagejpeg($image, $path, 100); break; case IMAGETYPE_PNG: $result = imagepng($image, $path, 9); break; case IMAGETYPE_GIF: $result = imagegif($image, $path); break; } if (!$result) { throw new \Exception("Failed to save image (" . $path . ")"); } }
[ "public", "static", "function", "save", "(", "$", "image", ",", "$", "path", ",", "$", "format", ")", "{", "switch", "(", "$", "format", ")", "{", "case", "IMAGETYPE_JPEG", ":", "$", "result", "=", "imagejpeg", "(", "$", "image", ",", "$", "path", ...
Save an image resource to the disk. @param resource $image The image resource to save @param string $path The path to save the image too @param int $format Image type constant (http://php.net/manual/en/image.constants.php) @return void
[ "Save", "an", "image", "resource", "to", "the", "disk", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Image.php#L312-L329
train
duncan3dc/php-helpers
src/Image.php
Image.rotate
public static function rotate($path, $rotate = null) { if ($rotate === null) { $exif = exif_read_data($path); switch ($exif["Orientation"]) { case 3: $rotate = 180; break; case 6: $rotate = 90; break; case 8: $rotate = -90; break; } } if (!$rotate) { return; } $format = getimagesize($path)[2]; $image = static::create($path, $format); $rotate = imagerotate($image, $rotate * -1, 0); static::save($rotate, $path, $format); }
php
public static function rotate($path, $rotate = null) { if ($rotate === null) { $exif = exif_read_data($path); switch ($exif["Orientation"]) { case 3: $rotate = 180; break; case 6: $rotate = 90; break; case 8: $rotate = -90; break; } } if (!$rotate) { return; } $format = getimagesize($path)[2]; $image = static::create($path, $format); $rotate = imagerotate($image, $rotate * -1, 0); static::save($rotate, $path, $format); }
[ "public", "static", "function", "rotate", "(", "$", "path", ",", "$", "rotate", "=", "null", ")", "{", "if", "(", "$", "rotate", "===", "null", ")", "{", "$", "exif", "=", "exif_read_data", "(", "$", "path", ")", ";", "switch", "(", "$", "exif", ...
Rotate an image and save it. If no angle to rotate is passed then we attempt to read it from exif data. @param string $path The path of the image to work with, and overwrite @param int $rotate A specific rotation angle to apply (clockwise) @return void
[ "Rotate", "an", "image", "and", "save", "it", ".", "If", "no", "angle", "to", "rotate", "is", "passed", "then", "we", "attempt", "to", "read", "it", "from", "exif", "data", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Image.php#L341-L368
train
vegas-cmf/core
src/Mvc/View.php
View._engineRender
protected function _engineRender($engines, $viewPath, $silence, $mustClean, $cache) { $basePath = $this->_basePath; $notExists = true; if (is_object($cache)) { $renderLevel = intval($this->_renderLevel); $cacheLevel = intval($this->_cacheLevel); if ($renderLevel >= $cacheLevel) { if ($cache->isStarted() === false) { $viewOptions = $this->_options; if (is_array($viewOptions)) { if (isset($viewOptions['cache'])) { $cacheOptions = $viewOptions['cache']; if (is_array($cacheOptions)) { if (isset($cacheOptions['key'])) { $key = $cacheOptions['key']; } if (isset($cacheOptions['lifetime'])) { $lifeTime = $cacheOptions['lifetime']; } } if (!isset($key) || !$key) { $key = md5($viewPath); } if (!isset($lifeTime)) { $lifeTime = 0; } $cachedView = $cache->start($key, $lifeTime); if (!$cachedView) { $this->_content = $cachedView; return null; } } if (!$cache->isFresh()) { return null; } } } } } $viewParams = $this->_viewParams; $eventsManager = $this->_eventsManager; foreach ($engines as $extension => $engine) { $viewEnginePath = $basePath . $this->resolveFullViewPath($viewPath) . $extension; if (file_exists($viewEnginePath)) { if (is_object($eventsManager)) { $this->_activeRenderPath = $viewEnginePath; if ($eventsManager->fire("view:beforeRenderView", $this, $viewEnginePath) === false) { continue; } } $engine->render($viewEnginePath, $viewParams, $mustClean); $notExists = false; if (is_object($eventsManager)) { $eventsManager->fire("view:afterRenderView", $this); } break; } } if ($notExists) { if (is_object($eventsManager)) { $this->_activeRenderPath = $viewEnginePath; $eventsManager->fire("view:notFoundView", $this, $viewEnginePath); } if (!$silence) { throw new Exception(sprintf("View %s was not found in the views directory", $viewEnginePath)); } } }
php
protected function _engineRender($engines, $viewPath, $silence, $mustClean, $cache) { $basePath = $this->_basePath; $notExists = true; if (is_object($cache)) { $renderLevel = intval($this->_renderLevel); $cacheLevel = intval($this->_cacheLevel); if ($renderLevel >= $cacheLevel) { if ($cache->isStarted() === false) { $viewOptions = $this->_options; if (is_array($viewOptions)) { if (isset($viewOptions['cache'])) { $cacheOptions = $viewOptions['cache']; if (is_array($cacheOptions)) { if (isset($cacheOptions['key'])) { $key = $cacheOptions['key']; } if (isset($cacheOptions['lifetime'])) { $lifeTime = $cacheOptions['lifetime']; } } if (!isset($key) || !$key) { $key = md5($viewPath); } if (!isset($lifeTime)) { $lifeTime = 0; } $cachedView = $cache->start($key, $lifeTime); if (!$cachedView) { $this->_content = $cachedView; return null; } } if (!$cache->isFresh()) { return null; } } } } } $viewParams = $this->_viewParams; $eventsManager = $this->_eventsManager; foreach ($engines as $extension => $engine) { $viewEnginePath = $basePath . $this->resolveFullViewPath($viewPath) . $extension; if (file_exists($viewEnginePath)) { if (is_object($eventsManager)) { $this->_activeRenderPath = $viewEnginePath; if ($eventsManager->fire("view:beforeRenderView", $this, $viewEnginePath) === false) { continue; } } $engine->render($viewEnginePath, $viewParams, $mustClean); $notExists = false; if (is_object($eventsManager)) { $eventsManager->fire("view:afterRenderView", $this); } break; } } if ($notExists) { if (is_object($eventsManager)) { $this->_activeRenderPath = $viewEnginePath; $eventsManager->fire("view:notFoundView", $this, $viewEnginePath); } if (!$silence) { throw new Exception(sprintf("View %s was not found in the views directory", $viewEnginePath)); } } }
[ "protected", "function", "_engineRender", "(", "$", "engines", ",", "$", "viewPath", ",", "$", "silence", ",", "$", "mustClean", ",", "$", "cache", ")", "{", "$", "basePath", "=", "$", "this", "->", "_basePath", ";", "$", "notExists", "=", "true", ";",...
Checks whether view exists on registered extensions and render it @override @param array $engines @param string $viewPath @param boolean $silence @param boolean $mustClean @param \Phalcon\Cache\BackendInterface $cache @return null|void @throws Exception
[ "Checks", "whether", "view", "exists", "on", "registered", "extensions", "and", "render", "it" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View.php#L98-L175
train
vegas-cmf/core
src/Mvc/View.php
View.resolveFullViewPath
private function resolveFullViewPath($viewPath) { if (strlen($this->getPartialsDir()) > 0 && strpos($viewPath, $this->getPartialsDir()) === 0) { return $this->resolvePartialPath($viewPath); } if (strpos($viewPath, $this->getLayoutsDir()) === 0) { return $this->resolveLayoutPath($viewPath); } return $this->resolveViewPath($viewPath); }
php
private function resolveFullViewPath($viewPath) { if (strlen($this->getPartialsDir()) > 0 && strpos($viewPath, $this->getPartialsDir()) === 0) { return $this->resolvePartialPath($viewPath); } if (strpos($viewPath, $this->getLayoutsDir()) === 0) { return $this->resolveLayoutPath($viewPath); } return $this->resolveViewPath($viewPath); }
[ "private", "function", "resolveFullViewPath", "(", "$", "viewPath", ")", "{", "if", "(", "strlen", "(", "$", "this", "->", "getPartialsDir", "(", ")", ")", ">", "0", "&&", "strpos", "(", "$", "viewPath", ",", "$", "this", "->", "getPartialsDir", "(", "...
Resolves full path to view file @param $viewPath @return string
[ "Resolves", "full", "path", "to", "view", "file" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View.php#L183-L193
train
vegas-cmf/core
src/Mvc/View.php
View.resolveViewPath
private function resolveViewPath($viewPath) { $path = realpath($this->_viewsDir . dirname($viewPath)) . DIRECTORY_SEPARATOR . basename($viewPath); return $path; }
php
private function resolveViewPath($viewPath) { $path = realpath($this->_viewsDir . dirname($viewPath)) . DIRECTORY_SEPARATOR . basename($viewPath); return $path; }
[ "private", "function", "resolveViewPath", "(", "$", "viewPath", ")", "{", "$", "path", "=", "realpath", "(", "$", "this", "->", "_viewsDir", ".", "dirname", "(", "$", "viewPath", ")", ")", ".", "DIRECTORY_SEPARATOR", ".", "basename", "(", "$", "viewPath", ...
Resolves view path @param $viewPath @return string
[ "Resolves", "view", "path" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View.php#L201-L205
train
vegas-cmf/core
src/Mvc/View.php
View.resolvePartialPath
private function resolvePartialPath($viewPath) { $tempViewPath = str_replace($this->getPartialsDir(), '', $viewPath); if (strpos($tempViewPath, '../') === 0 || strpos($tempViewPath, '/../') === 0) { return $this->resolveRelativePath($tempViewPath); } else if (strpos($tempViewPath, './') === 0) { return $this->resolveLocalPath($tempViewPath); } else if (!in_array(dirname($tempViewPath), ['.','..']) && file_exists(dirname($tempViewPath))) { return $tempViewPath; } return $this->resolveGlobalPath($tempViewPath); }
php
private function resolvePartialPath($viewPath) { $tempViewPath = str_replace($this->getPartialsDir(), '', $viewPath); if (strpos($tempViewPath, '../') === 0 || strpos($tempViewPath, '/../') === 0) { return $this->resolveRelativePath($tempViewPath); } else if (strpos($tempViewPath, './') === 0) { return $this->resolveLocalPath($tempViewPath); } else if (!in_array(dirname($tempViewPath), ['.','..']) && file_exists(dirname($tempViewPath))) { return $tempViewPath; } return $this->resolveGlobalPath($tempViewPath); }
[ "private", "function", "resolvePartialPath", "(", "$", "viewPath", ")", "{", "$", "tempViewPath", "=", "str_replace", "(", "$", "this", "->", "getPartialsDir", "(", ")", ",", "''", ",", "$", "viewPath", ")", ";", "if", "(", "strpos", "(", "$", "tempViewP...
Resolves path to partial application->view->partialsDir option is optional When partialsDir is not set in configuration, then by default partialsDir is the same like current viewsDir Otherwise, when partialsDir is set to for example directory app/layouts/partials then partial function loads global partials from this directory <code> //remember about trailing slashes 'application' => array( ... 'view' => array( 'layout' => 'main', 'layoutsDir' => APP_ROOT . '/app/layouts/', 'partialsDir' => APP_ROOT . '/app/layouts/partials/', //[optional] ... ) ) ... </code> Usage: - Relative partial <code> {# somewhere in module view #} {{ partial('../../../layouts/partials/header/navigation') } # goes to APP_ROOT/app/layouts/partials/header/navigation.volt </code> <code> {# somewhere in module view eg. Test/views/index/index.volt #} {{ partial('./frontend/foo/partials/other.volt') } # goes to APP_ROOT/app/modules/Test/views/frontend/foo/partials/other.volt </code> - Global partial <code> {{ partial('header/navigation') }} # when partialsDir is set to APP_ROOT/app/layouts/partials # it goes to APP_ROOT/app/layouts/partials/header/navigation.volt # otherwise it is looking for view inside current viewsDir, so: APP_ROOT/app/modules/Test/views/header/navigation.volt </code> - Local partial in module Test, controller Index (app/modules/Test/views/index/) <code> {{ partial('./frontend/index/partials/content/heading') }} # goes to APP_ROOT/app/modules/Test/views/frontend/index/partials/content/heading.volt </code> - Absolute path <code> {{ partial(constant("APP_ROOT") ~ "/app/layouts/partials/header/navigation.volt") }} </code> @param $viewPath @return string
[ "Resolves", "path", "to", "partial" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View.php#L263-L277
train
vegas-cmf/core
src/Mvc/View.php
View.resolveLocalPath
private function resolveLocalPath($partialPath) { $partialDir = str_replace('./', '', dirname($partialPath)); $partialsDir = realpath(sprintf('%s%s', $this->_viewsDir, $partialDir )) . DIRECTORY_SEPARATOR; return $partialsDir . basename($partialPath); }
php
private function resolveLocalPath($partialPath) { $partialDir = str_replace('./', '', dirname($partialPath)); $partialsDir = realpath(sprintf('%s%s', $this->_viewsDir, $partialDir )) . DIRECTORY_SEPARATOR; return $partialsDir . basename($partialPath); }
[ "private", "function", "resolveLocalPath", "(", "$", "partialPath", ")", "{", "$", "partialDir", "=", "str_replace", "(", "'./'", ",", "''", ",", "dirname", "(", "$", "partialPath", ")", ")", ";", "$", "partialsDir", "=", "realpath", "(", "sprintf", "(", ...
Resolves path to local partials directory @param $partialPath @return string
[ "Resolves", "path", "to", "local", "partials", "directory" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View.php#L296-L305
train
vegas-cmf/core
src/Mvc/View.php
View.resolveRelativePath
private function resolveRelativePath($partialPath) { $partialsDirPath = realpath(sprintf('%s%s', $this->_viewsDir, dirname($partialPath) )) . DIRECTORY_SEPARATOR; return $partialsDirPath . basename($partialPath); }
php
private function resolveRelativePath($partialPath) { $partialsDirPath = realpath(sprintf('%s%s', $this->_viewsDir, dirname($partialPath) )) . DIRECTORY_SEPARATOR; return $partialsDirPath . basename($partialPath); }
[ "private", "function", "resolveRelativePath", "(", "$", "partialPath", ")", "{", "$", "partialsDirPath", "=", "realpath", "(", "sprintf", "(", "'%s%s'", ",", "$", "this", "->", "_viewsDir", ",", "dirname", "(", "$", "partialPath", ")", ")", ")", ".", "DIRE...
Resolves `realpath` from relative partial path @param $partialPath @return string
[ "Resolves", "realpath", "from", "relative", "partial", "path" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View.php#L325-L333
train
vegas-cmf/core
src/Mvc/View.php
View.render
public function render($controllerName, $actionName, $params = null) { if (empty($this->controllerViewPath)) { $this->setControllerViewPath($controllerName); } parent::render($this->controllerViewPath, $actionName, $params); }
php
public function render($controllerName, $actionName, $params = null) { if (empty($this->controllerViewPath)) { $this->setControllerViewPath($controllerName); } parent::render($this->controllerViewPath, $actionName, $params); }
[ "public", "function", "render", "(", "$", "controllerName", ",", "$", "actionName", ",", "$", "params", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "controllerViewPath", ")", ")", "{", "$", "this", "->", "setControllerViewPath", "(...
Renders view for controller action @override @param string $controllerName @param string $actionName @param null $params @return PhalconView|void
[ "Renders", "view", "for", "controller", "action" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View.php#L344-L349
train
vegas-cmf/core
src/Mvc/View.php
View.setControllerViewPath
public function setControllerViewPath($controllerName) { $this->controllerViewPath = str_replace('\\','/',strtolower($controllerName)); $this->controllerFullViewPath = $this->_viewsDir . $this->controllerViewPath; }
php
public function setControllerViewPath($controllerName) { $this->controllerViewPath = str_replace('\\','/',strtolower($controllerName)); $this->controllerFullViewPath = $this->_viewsDir . $this->controllerViewPath; }
[ "public", "function", "setControllerViewPath", "(", "$", "controllerName", ")", "{", "$", "this", "->", "controllerViewPath", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "strtolower", "(", "$", "controllerName", ")", ")", ";", "$", "this", "->", "con...
Prepares and sets path for controller view @param $controllerName @return mixed @internal
[ "Prepares", "and", "sets", "path", "for", "controller", "view" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View.php#L368-L372
train
dreamfactorysoftware/df-oauth
src/Components/DfOAuthTwoProvider.php
DfOAuthTwoProvider.getUserFromTokenResponse
public function getUserFromTokenResponse($response) { $user = $this->mapUserToObject($this->getUserByToken( $token = $this->parseAccessToken($response) )); $this->credentialsResponseBody = $response; if ($user instanceof User) { $user->setAccessTokenResponseBody($this->credentialsResponseBody); } return $user->setToken($token) ->setRefreshToken($this->parseRefreshToken($response)) ->setExpiresIn($this->parseExpiresIn($response)); }
php
public function getUserFromTokenResponse($response) { $user = $this->mapUserToObject($this->getUserByToken( $token = $this->parseAccessToken($response) )); $this->credentialsResponseBody = $response; if ($user instanceof User) { $user->setAccessTokenResponseBody($this->credentialsResponseBody); } return $user->setToken($token) ->setRefreshToken($this->parseRefreshToken($response)) ->setExpiresIn($this->parseExpiresIn($response)); }
[ "public", "function", "getUserFromTokenResponse", "(", "$", "response", ")", "{", "$", "user", "=", "$", "this", "->", "mapUserToObject", "(", "$", "this", "->", "getUserByToken", "(", "$", "token", "=", "$", "this", "->", "parseAccessToken", "(", "$", "re...
Retrieve user using token response. @param $response @return $this
[ "Retrieve", "user", "using", "token", "response", "." ]
2f82b3915ab59188fe6ba5b6f387291d1ac83f4d
https://github.com/dreamfactorysoftware/df-oauth/blob/2f82b3915ab59188fe6ba5b6f387291d1ac83f4d/src/Components/DfOAuthTwoProvider.php#L92-L107
train
softberg/quantum-core
src/Libraries/Database/Database.php
Database.getDbConfig
private function getDbConfig() { if (file_exists(MODULES_DIR . DS . $this->currentRoute['module'] . '/Config/database.php')) { $dbConfig = require_once MODULES_DIR . DS . $this->currentRoute['module'] . '/Config/database.php'; if (!empty($dbConfig) && is_array($dbConfig)) { return $dbConfig; } else { throw new \Exception(ExceptionMessages::INCORRECT_CONFIG); } } else { if (file_exists(BASE_DIR . '/config/database.php')) { $dbConfig = require_once BASE_DIR . '/config/database.php'; if (!empty($dbConfig) && is_array($dbConfig)) { return $dbConfig; } else { throw new \Exception(ExceptionMessages::INCORRECT_CONFIG); } } else { throw new \Exception(ExceptionMessages::DB_CONFIG_NOT_FOUND); } } }
php
private function getDbConfig() { if (file_exists(MODULES_DIR . DS . $this->currentRoute['module'] . '/Config/database.php')) { $dbConfig = require_once MODULES_DIR . DS . $this->currentRoute['module'] . '/Config/database.php'; if (!empty($dbConfig) && is_array($dbConfig)) { return $dbConfig; } else { throw new \Exception(ExceptionMessages::INCORRECT_CONFIG); } } else { if (file_exists(BASE_DIR . '/config/database.php')) { $dbConfig = require_once BASE_DIR . '/config/database.php'; if (!empty($dbConfig) && is_array($dbConfig)) { return $dbConfig; } else { throw new \Exception(ExceptionMessages::INCORRECT_CONFIG); } } else { throw new \Exception(ExceptionMessages::DB_CONFIG_NOT_FOUND); } } }
[ "private", "function", "getDbConfig", "(", ")", "{", "if", "(", "file_exists", "(", "MODULES_DIR", ".", "DS", ".", "$", "this", "->", "currentRoute", "[", "'module'", "]", ".", "'/Config/database.php'", ")", ")", "{", "$", "dbConfig", "=", "require_once", ...
Get DB Config Gets db configs from current config/database.php of module or from top config/database.php if in module it's not defined @return array @throws \Exception When config is not found or incorrect
[ "Get", "DB", "Config" ]
081d42a4ce4197ac8687d438c571914473ade9da
https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Database/Database.php#L116-L137
train
duncan3dc/php-helpers
src/Cache.php
Cache.getInstance
public static function getInstance($name) { if (!isset(static::$instances[$name])) { static::$instances[$name] = new CacheInstance(); } return static::$instances[$name]; }
php
public static function getInstance($name) { if (!isset(static::$instances[$name])) { static::$instances[$name] = new CacheInstance(); } return static::$instances[$name]; }
[ "public", "static", "function", "getInstance", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "instances", "[", "$", "name", "]", ")", ")", "{", "static", "::", "$", "instances", "[", "$", "name", "]", "=", "new", ...
Get a named instance of CacheInstance for segregating cache data. @param string $name The name of the instance to get @return CacheInstance
[ "Get", "a", "named", "instance", "of", "CacheInstance", "for", "segregating", "cache", "data", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Cache.php#L25-L31
train
Torann/laravel-moderate
src/Torann/Moderate/Moderator.php
Moderator.reloadBlacklist
public function reloadBlacklist() { $this->cache->flush($this->getCacheKey()); $this->blackListRegex = null; $this->loadBlacklist(); }
php
public function reloadBlacklist() { $this->cache->flush($this->getCacheKey()); $this->blackListRegex = null; $this->loadBlacklist(); }
[ "public", "function", "reloadBlacklist", "(", ")", "{", "$", "this", "->", "cache", "->", "flush", "(", "$", "this", "->", "getCacheKey", "(", ")", ")", ";", "$", "this", "->", "blackListRegex", "=", "null", ";", "$", "this", "->", "loadBlacklist", "("...
Reload blacklist data
[ "Reload", "blacklist", "data" ]
89b0a8eac5fdffae85f63b2ac844c49747547f3d
https://github.com/Torann/laravel-moderate/blob/89b0a8eac5fdffae85f63b2ac844c49747547f3d/src/Torann/Moderate/Moderator.php#L67-L74
train
Torann/laravel-moderate
src/Torann/Moderate/Moderator.php
Moderator.check
public function check($model) { $moderated = false; foreach ($model->getModerateList() as $id => $moderation) { $rules = explode('|', $moderation); foreach ($rules as $rule) { $action = explode(':', $rule); $options = isset($action[1]) ? $action[1] : null; $method = $action[0]; if ($this->$method($model->$id, $options)) { return $moderated = true; } } // No reason to keep going if ($moderated === true) { return $moderated; } } return $moderated; }
php
public function check($model) { $moderated = false; foreach ($model->getModerateList() as $id => $moderation) { $rules = explode('|', $moderation); foreach ($rules as $rule) { $action = explode(':', $rule); $options = isset($action[1]) ? $action[1] : null; $method = $action[0]; if ($this->$method($model->$id, $options)) { return $moderated = true; } } // No reason to keep going if ($moderated === true) { return $moderated; } } return $moderated; }
[ "public", "function", "check", "(", "$", "model", ")", "{", "$", "moderated", "=", "false", ";", "foreach", "(", "$", "model", "->", "getModerateList", "(", ")", "as", "$", "id", "=>", "$", "moderation", ")", "{", "$", "rules", "=", "explode", "(", ...
Check model using the moderate rules. @param object $model @return bool
[ "Check", "model", "using", "the", "moderate", "rules", "." ]
89b0a8eac5fdffae85f63b2ac844c49747547f3d
https://github.com/Torann/laravel-moderate/blob/89b0a8eac5fdffae85f63b2ac844c49747547f3d/src/Torann/Moderate/Moderator.php#L83-L107
train
Torann/laravel-moderate
src/Torann/Moderate/Moderator.php
Moderator.getDriver
public function getDriver() { if ($this->driver) { return $this->driver; } // Get driver configuration $config = $this->getConfig('drivers.' . $this->getConfig('driver'), []); // Get driver class $driver = Arr::pull($config, 'class'); // Create driver instance return $this->driver = new $driver($config, $this->locale); }
php
public function getDriver() { if ($this->driver) { return $this->driver; } // Get driver configuration $config = $this->getConfig('drivers.' . $this->getConfig('driver'), []); // Get driver class $driver = Arr::pull($config, 'class'); // Create driver instance return $this->driver = new $driver($config, $this->locale); }
[ "public", "function", "getDriver", "(", ")", "{", "if", "(", "$", "this", "->", "driver", ")", "{", "return", "$", "this", "->", "driver", ";", "}", "// Get driver configuration", "$", "config", "=", "$", "this", "->", "getConfig", "(", "'drivers.'", "."...
Get moderation driver. @return Drivers\AbstractDriver
[ "Get", "moderation", "driver", "." ]
89b0a8eac5fdffae85f63b2ac844c49747547f3d
https://github.com/Torann/laravel-moderate/blob/89b0a8eac5fdffae85f63b2ac844c49747547f3d/src/Torann/Moderate/Moderator.php#L157-L171
train
Torann/laravel-moderate
src/Torann/Moderate/Moderator.php
Moderator.loadBlacklist
protected function loadBlacklist() { // Check if caching is enabled if ($this->getConfig('cache.enabled', false) === false) { return $this->blackListRegex = $this->createRegex(); } // Get Black list items return $this->blackListRegex = $this->cache->rememberForever($this->getCacheKey(), function () { return $this->createRegex(); }); }
php
protected function loadBlacklist() { // Check if caching is enabled if ($this->getConfig('cache.enabled', false) === false) { return $this->blackListRegex = $this->createRegex(); } // Get Black list items return $this->blackListRegex = $this->cache->rememberForever($this->getCacheKey(), function () { return $this->createRegex(); }); }
[ "protected", "function", "loadBlacklist", "(", ")", "{", "// Check if caching is enabled", "if", "(", "$", "this", "->", "getConfig", "(", "'cache.enabled'", ",", "false", ")", "===", "false", ")", "{", "return", "$", "this", "->", "blackListRegex", "=", "$", ...
Load blacklist data @return string
[ "Load", "blacklist", "data" ]
89b0a8eac5fdffae85f63b2ac844c49747547f3d
https://github.com/Torann/laravel-moderate/blob/89b0a8eac5fdffae85f63b2ac844c49747547f3d/src/Torann/Moderate/Moderator.php#L231-L242
train
Torann/laravel-moderate
src/Torann/Moderate/Moderator.php
Moderator.createRegex
protected function createRegex() { // Load list from driver if (empty($list = $this->getDriver()->getList())) { return null; } return sprintf('/\b(%s)\b/i', implode('|', array_map(function ($value) { if (isset($value[0]) && $value[0] == '[') { return $value; } else if (preg_match("/\r\n|\r|\n/", $value)) { return preg_replace("/\r\n|\r|\n/", "|", $value); } return preg_quote($value); }, $list))); }
php
protected function createRegex() { // Load list from driver if (empty($list = $this->getDriver()->getList())) { return null; } return sprintf('/\b(%s)\b/i', implode('|', array_map(function ($value) { if (isset($value[0]) && $value[0] == '[') { return $value; } else if (preg_match("/\r\n|\r|\n/", $value)) { return preg_replace("/\r\n|\r|\n/", "|", $value); } return preg_quote($value); }, $list))); }
[ "protected", "function", "createRegex", "(", ")", "{", "// Load list from driver", "if", "(", "empty", "(", "$", "list", "=", "$", "this", "->", "getDriver", "(", ")", "->", "getList", "(", ")", ")", ")", "{", "return", "null", ";", "}", "return", "spr...
Create blacklist regex from driver data. @return string
[ "Create", "blacklist", "regex", "from", "driver", "data", "." ]
89b0a8eac5fdffae85f63b2ac844c49747547f3d
https://github.com/Torann/laravel-moderate/blob/89b0a8eac5fdffae85f63b2ac844c49747547f3d/src/Torann/Moderate/Moderator.php#L249-L267
train
inviqa/magento-symfony-container
app/code/community/Inviqa/SymfonyContainer/Model/StoreConfigCompilerPass.php
Inviqa_SymfonyContainer_Model_StoreConfigCompilerPass.process
public function process(ContainerBuilder $container) { $taggedServices = $container->findTaggedServiceIds( self::TAG_NAME ); foreach ($taggedServices as $id => $tag) { $definition = $container->findDefinition($id); $this->processTag($tag, $definition); } }
php
public function process(ContainerBuilder $container) { $taggedServices = $container->findTaggedServiceIds( self::TAG_NAME ); foreach ($taggedServices as $id => $tag) { $definition = $container->findDefinition($id); $this->processTag($tag, $definition); } }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "taggedServices", "=", "$", "container", "->", "findTaggedServiceIds", "(", "self", "::", "TAG_NAME", ")", ";", "foreach", "(", "$", "taggedServices", "as", "$", "id", ...
Adds requested store configuration as an argument to the services @param ContainerBuilder $container
[ "Adds", "requested", "store", "configuration", "as", "an", "argument", "to", "the", "services" ]
a358a23650b8e16ce158ff20eefeda70ae7db0ef
https://github.com/inviqa/magento-symfony-container/blob/a358a23650b8e16ce158ff20eefeda70ae7db0ef/app/code/community/Inviqa/SymfonyContainer/Model/StoreConfigCompilerPass.php#L26-L37
train
duncan3dc/php-helpers
src/DiskCache.php
DiskCache.path
public static function path($filename) { if ($filename[0] != "/") { $filename = static::$path . "/" . $filename; } if (substr($filename, -5) != ".json") { $filename .= ".json"; } $path = pathinfo($filename, PATHINFO_DIRNAME); # Ensure the cache directory exists if (!is_dir($path)) { if (!mkdir($path, 0777, true)) { throw new \Exception("Unable to create cache directory (" . $path . ")"); } } # Ensure directory is writable if (!is_writable($path)) { if (!chmod($path, 0777)) { throw new \Exception("Cache directory (" . $path . ") is not writable"); } } return $filename; }
php
public static function path($filename) { if ($filename[0] != "/") { $filename = static::$path . "/" . $filename; } if (substr($filename, -5) != ".json") { $filename .= ".json"; } $path = pathinfo($filename, PATHINFO_DIRNAME); # Ensure the cache directory exists if (!is_dir($path)) { if (!mkdir($path, 0777, true)) { throw new \Exception("Unable to create cache directory (" . $path . ")"); } } # Ensure directory is writable if (!is_writable($path)) { if (!chmod($path, 0777)) { throw new \Exception("Cache directory (" . $path . ") is not writable"); } } return $filename; }
[ "public", "static", "function", "path", "(", "$", "filename", ")", "{", "if", "(", "$", "filename", "[", "0", "]", "!=", "\"/\"", ")", "{", "$", "filename", "=", "static", "::", "$", "path", ".", "\"/\"", ".", "$", "filename", ";", "}", "if", "("...
Generate the fullpath to the cache file based on the passed filename. @param string $filename The filename specified to store the cache in @return string
[ "Generate", "the", "fullpath", "to", "the", "cache", "file", "based", "on", "the", "passed", "filename", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/DiskCache.php#L22-L49
train
duncan3dc/php-helpers
src/DiskCache.php
DiskCache.check
public static function check($filename) { if (!$filename = static::path($filename)) { return null; } if (!file_exists($filename)) { return null; } return filemtime($filename); }
php
public static function check($filename) { if (!$filename = static::path($filename)) { return null; } if (!file_exists($filename)) { return null; } return filemtime($filename); }
[ "public", "static", "function", "check", "(", "$", "filename", ")", "{", "if", "(", "!", "$", "filename", "=", "static", "::", "path", "(", "$", "filename", ")", ")", "{", "return", "null", ";", "}", "if", "(", "!", "file_exists", "(", "$", "filena...
Check if the specified key has already been cached. If it has been cached then the time the cached data was last modified is returned. @param string $filename The key of the cached data @return int|null
[ "Check", "if", "the", "specified", "key", "has", "already", "been", "cached", ".", "If", "it", "has", "been", "cached", "then", "the", "time", "the", "cached", "data", "was", "last", "modified", "is", "returned", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/DiskCache.php#L60-L71
train
duncan3dc/php-helpers
src/DiskCache.php
DiskCache.get
public static function get($filename, $mins = 0) { if (!$cache = static::check($filename)) { return null; } $limit = time() - ($mins * 60); if (!$mins || $cache > $limit) { $filename = static::path($filename); $return = Json::decodeFromFile($filename); if ($return instanceof \ArrayObject) { $return = $return->asArray(); } if (array_key_exists("_disk_cache", $return)) { $return = $return["_disk_cache"]; } return $return; } return null; }
php
public static function get($filename, $mins = 0) { if (!$cache = static::check($filename)) { return null; } $limit = time() - ($mins * 60); if (!$mins || $cache > $limit) { $filename = static::path($filename); $return = Json::decodeFromFile($filename); if ($return instanceof \ArrayObject) { $return = $return->asArray(); } if (array_key_exists("_disk_cache", $return)) { $return = $return["_disk_cache"]; } return $return; } return null; }
[ "public", "static", "function", "get", "(", "$", "filename", ",", "$", "mins", "=", "0", ")", "{", "if", "(", "!", "$", "cache", "=", "static", "::", "check", "(", "$", "filename", ")", ")", "{", "return", "null", ";", "}", "$", "limit", "=", "...
Get the stored value of the specified key. @param string $filename The key of the cached data @param int $mins The number of minutes to use the cache for, if the cache is present but older than this time then return null @return mixed
[ "Get", "the", "stored", "value", "of", "the", "specified", "key", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/DiskCache.php#L82-L106
train
duncan3dc/php-helpers
src/DiskCache.php
DiskCache.set
public static function set($filename, $data) { $data = ["_disk_cache" => $data]; $filename = static::path($filename); Json::encodeToFile($filename, $data); }
php
public static function set($filename, $data) { $data = ["_disk_cache" => $data]; $filename = static::path($filename); Json::encodeToFile($filename, $data); }
[ "public", "static", "function", "set", "(", "$", "filename", ",", "$", "data", ")", "{", "$", "data", "=", "[", "\"_disk_cache\"", "=>", "$", "data", "]", ";", "$", "filename", "=", "static", "::", "path", "(", "$", "filename", ")", ";", "Json", ":...
Set the specified key to the specified value. @param string $filename The key of the cached data @param string $data The value to storage against the key, this data must be JSON serializable @return void
[ "Set", "the", "specified", "key", "to", "the", "specified", "value", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/DiskCache.php#L117-L122
train
duncan3dc/php-helpers
src/DiskCache.php
DiskCache.clear
public static function clear($filename) { $filename = static::path($filename); if (!file_exists($filename)) { return; } if (!unlink($filename)) { throw new \Exception("Unable to delete file (" . $filename . ")"); } }
php
public static function clear($filename) { $filename = static::path($filename); if (!file_exists($filename)) { return; } if (!unlink($filename)) { throw new \Exception("Unable to delete file (" . $filename . ")"); } }
[ "public", "static", "function", "clear", "(", "$", "filename", ")", "{", "$", "filename", "=", "static", "::", "path", "(", "$", "filename", ")", ";", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "return", ";", "}", "if", "("...
Clear a key within the cache data. @param string $filename The key of the cached data @return void
[ "Clear", "a", "key", "within", "the", "cache", "data", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/DiskCache.php#L132-L143
train
duncan3dc/php-helpers
src/DiskCache.php
DiskCache.call
public static function call($key, callable $func) { $trace = debug_backtrace(); if ($function = $trace[1]["function"]) { $key = $function . "_" . $key; if ($class = $trace[1]["class"]) { $key = str_replace("\\", "_", $class) . "_" . $key; } } if (static::check($key)) { return static::get($key); } $return = $func(); static::set($key, $return); return $return; }
php
public static function call($key, callable $func) { $trace = debug_backtrace(); if ($function = $trace[1]["function"]) { $key = $function . "_" . $key; if ($class = $trace[1]["class"]) { $key = str_replace("\\", "_", $class) . "_" . $key; } } if (static::check($key)) { return static::get($key); } $return = $func(); static::set($key, $return); return $return; }
[ "public", "static", "function", "call", "(", "$", "key", ",", "callable", "$", "func", ")", "{", "$", "trace", "=", "debug_backtrace", "(", ")", ";", "if", "(", "$", "function", "=", "$", "trace", "[", "1", "]", "[", "\"function\"", "]", ")", "{", ...
Convience method to retrieve a value if it's cached, or run the callback and cache the data now if not. @param string $key The key of the cached data @param callable $func A function to call that will return the value to cache @return mixed
[ "Convience", "method", "to", "retrieve", "a", "value", "if", "it", "s", "cached", "or", "run", "the", "callback", "and", "cache", "the", "data", "now", "if", "not", "." ]
0305d220183d9b515f17600bf064291da7a8813b
https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/DiskCache.php#L154-L173
train
neos/Neos.MarketPlace
Classes/Service/PackageImporter.php
PackageImporter.cleanupPackages
public function cleanupPackages(Storage $storage, callable $callback = null) { $count = 0; $storageNode = $storage->node(); $query = new FlowQuery([$storageNode]); $query = $query->find('[instanceof Neos.MarketPlace:Package]'); $upstreamPackages = $this->getProcessedPackages(); foreach ($query as $package) { /** @var NodeInterface $package */ if (in_array($package->getProperty('title'), $upstreamPackages)) { continue; } $package->remove(); if ($callback !== null) { $callback($package); } $this->emitPackageDeleted($package); $count++; } return $count; }
php
public function cleanupPackages(Storage $storage, callable $callback = null) { $count = 0; $storageNode = $storage->node(); $query = new FlowQuery([$storageNode]); $query = $query->find('[instanceof Neos.MarketPlace:Package]'); $upstreamPackages = $this->getProcessedPackages(); foreach ($query as $package) { /** @var NodeInterface $package */ if (in_array($package->getProperty('title'), $upstreamPackages)) { continue; } $package->remove(); if ($callback !== null) { $callback($package); } $this->emitPackageDeleted($package); $count++; } return $count; }
[ "public", "function", "cleanupPackages", "(", "Storage", "$", "storage", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "count", "=", "0", ";", "$", "storageNode", "=", "$", "storage", "->", "node", "(", ")", ";", "$", "query", "=", "n...
Remove local package not preset in the processed packages list @param Storage $storage @param callable $callback function called after the package removal @return integer
[ "Remove", "local", "package", "not", "preset", "in", "the", "processed", "packages", "list" ]
42b844be976cfcd1e2ab4c8966da006047f04abf
https://github.com/neos/Neos.MarketPlace/blob/42b844be976cfcd1e2ab4c8966da006047f04abf/Classes/Service/PackageImporter.php#L77-L97
train
neos/Neos.MarketPlace
Classes/Service/PackageImporter.php
PackageImporter.cleanupVendors
public function cleanupVendors(Storage $storage, callable $callback = null) { $count = 0; $storageNode = $storage->node(); $query = new FlowQuery([$storageNode]); $query = $query->find('[instanceof Neos.MarketPlace:Vendor]'); foreach ($query as $vendor) { /** @var NodeInterface $vendor */ $hasPackageQuery = new FlowQuery([$vendor]); $packageCount = $hasPackageQuery->find('[instanceof Neos.MarketPlace:Package]')->count(); if ($packageCount > 0) { continue; } $vendor->remove(); if ($callback !== null) { $callback($vendor); } $this->emitVendorDeleted($vendor); $count++; } return $count; }
php
public function cleanupVendors(Storage $storage, callable $callback = null) { $count = 0; $storageNode = $storage->node(); $query = new FlowQuery([$storageNode]); $query = $query->find('[instanceof Neos.MarketPlace:Vendor]'); foreach ($query as $vendor) { /** @var NodeInterface $vendor */ $hasPackageQuery = new FlowQuery([$vendor]); $packageCount = $hasPackageQuery->find('[instanceof Neos.MarketPlace:Package]')->count(); if ($packageCount > 0) { continue; } $vendor->remove(); if ($callback !== null) { $callback($vendor); } $this->emitVendorDeleted($vendor); $count++; } return $count; }
[ "public", "function", "cleanupVendors", "(", "Storage", "$", "storage", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "count", "=", "0", ";", "$", "storageNode", "=", "$", "storage", "->", "node", "(", ")", ";", "$", "query", "=", "ne...
Remove vendors without packages @param Storage $storage @param callable $callback function called after the vendor removal @return integer
[ "Remove", "vendors", "without", "packages" ]
42b844be976cfcd1e2ab4c8966da006047f04abf
https://github.com/neos/Neos.MarketPlace/blob/42b844be976cfcd1e2ab4c8966da006047f04abf/Classes/Service/PackageImporter.php#L106-L127
train
Bartacus/BartacusBundle
ContentElement/Renderer.php
Renderer.filterResponse
private function filterResponse(Response $response, Request $request, int $type): string { $event = new FilterResponseEvent($this->kernel, $request, $type, $response); $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); $this->dispatcher->dispatch(KernelEvents::FINISH_REQUEST, new FinishRequestEvent($this->kernel, $request, $type)); $request->attributes->remove('data'); $request->attributes->set('_controller', 'typo3'); $response = $event->getResponse(); if ($response instanceof RedirectResponse) { $response->send(); $this->kernel->terminate($request, $response); exit(); } if (\count($response->headers) || 200 !== $response->getStatusCode()) { $response->sendHeaders(); } return $response->getContent(); }
php
private function filterResponse(Response $response, Request $request, int $type): string { $event = new FilterResponseEvent($this->kernel, $request, $type, $response); $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event); $this->dispatcher->dispatch(KernelEvents::FINISH_REQUEST, new FinishRequestEvent($this->kernel, $request, $type)); $request->attributes->remove('data'); $request->attributes->set('_controller', 'typo3'); $response = $event->getResponse(); if ($response instanceof RedirectResponse) { $response->send(); $this->kernel->terminate($request, $response); exit(); } if (\count($response->headers) || 200 !== $response->getStatusCode()) { $response->sendHeaders(); } return $response->getContent(); }
[ "private", "function", "filterResponse", "(", "Response", "$", "response", ",", "Request", "$", "request", ",", "int", "$", "type", ")", ":", "string", "{", "$", "event", "=", "new", "FilterResponseEvent", "(", "$", "this", "->", "kernel", ",", "$", "req...
Filters a response object and returns the content. @param Response $response A Response instance @param Request $request An error message in case the response is not a Response object @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) @throws \RuntimeException if the passed object is not a Response instance @return string The filtered and resulting content
[ "Filters", "a", "response", "object", "and", "returns", "the", "content", "." ]
a24937be00e1a8f0b35f92db0c722907339b1ccb
https://github.com/Bartacus/BartacusBundle/blob/a24937be00e1a8f0b35f92db0c722907339b1ccb/ContentElement/Renderer.php#L199-L222
train
Bartacus/BartacusBundle
ContentElement/Renderer.php
Renderer.varToString
private function varToString($var): string { if (\is_object($var)) { return \sprintf('an object of type %s', \get_class($var)); } if (\is_array($var)) { $a = []; foreach ($var as $k => $v) { $a[] = \sprintf('%s => ...', $k); } return \sprintf('an array ([%s])', \mb_substr(\implode(', ', $a), 0, 255)); } if (\is_resource($var)) { return \sprintf('a resource (%s)', \get_resource_type($var)); } if (null === $var) { return 'null'; } if (false === $var) { return 'a boolean value (false)'; } if (true === $var) { return 'a boolean value (true)'; } if (\is_string($var)) { return \sprintf('a string ("%s%s")', \mb_substr($var, 0, 255), \mb_strlen($var) > 255 ? '...' : ''); } if (\is_numeric($var)) { return \sprintf('a number (%s)', (string) $var); } return (string) $var; }
php
private function varToString($var): string { if (\is_object($var)) { return \sprintf('an object of type %s', \get_class($var)); } if (\is_array($var)) { $a = []; foreach ($var as $k => $v) { $a[] = \sprintf('%s => ...', $k); } return \sprintf('an array ([%s])', \mb_substr(\implode(', ', $a), 0, 255)); } if (\is_resource($var)) { return \sprintf('a resource (%s)', \get_resource_type($var)); } if (null === $var) { return 'null'; } if (false === $var) { return 'a boolean value (false)'; } if (true === $var) { return 'a boolean value (true)'; } if (\is_string($var)) { return \sprintf('a string ("%s%s")', \mb_substr($var, 0, 255), \mb_strlen($var) > 255 ? '...' : ''); } if (\is_numeric($var)) { return \sprintf('a number (%s)', (string) $var); } return (string) $var; }
[ "private", "function", "varToString", "(", "$", "var", ")", ":", "string", "{", "if", "(", "\\", "is_object", "(", "$", "var", ")", ")", "{", "return", "\\", "sprintf", "(", "'an object of type %s'", ",", "\\", "get_class", "(", "$", "var", ")", ")", ...
Returns a human-readable string for the specified variable. @param mixed $var
[ "Returns", "a", "human", "-", "readable", "string", "for", "the", "specified", "variable", "." ]
a24937be00e1a8f0b35f92db0c722907339b1ccb
https://github.com/Bartacus/BartacusBundle/blob/a24937be00e1a8f0b35f92db0c722907339b1ccb/ContentElement/Renderer.php#L229-L269
train
neos/party
Classes/Domain/Model/Person.php
Person.removeElectronicAddress
public function removeElectronicAddress(ElectronicAddress $electronicAddress) { $this->electronicAddresses->removeElement($electronicAddress); if ($electronicAddress === $this->primaryElectronicAddress) { $this->primaryElectronicAddress = null; } }
php
public function removeElectronicAddress(ElectronicAddress $electronicAddress) { $this->electronicAddresses->removeElement($electronicAddress); if ($electronicAddress === $this->primaryElectronicAddress) { $this->primaryElectronicAddress = null; } }
[ "public", "function", "removeElectronicAddress", "(", "ElectronicAddress", "$", "electronicAddress", ")", "{", "$", "this", "->", "electronicAddresses", "->", "removeElement", "(", "$", "electronicAddress", ")", ";", "if", "(", "$", "electronicAddress", "===", "$", ...
Removes the given electronic address from this person. @param ElectronicAddress $electronicAddress The electronic address @return void
[ "Removes", "the", "given", "electronic", "address", "from", "this", "person", "." ]
cf771039e8da24762c21640f8761d40d281c0cd0
https://github.com/neos/party/blob/cf771039e8da24762c21640f8761d40d281c0cd0/Classes/Domain/Model/Person.php#L93-L99
train
neos/party
Classes/Domain/Model/Person.php
Person.setElectronicAddresses
public function setElectronicAddresses(Collection $electronicAddresses) { if ($this->primaryElectronicAddress !== null && !$this->electronicAddresses->contains($this->primaryElectronicAddress)) { $this->primaryElectronicAddress = null; } $this->electronicAddresses = $electronicAddresses; }
php
public function setElectronicAddresses(Collection $electronicAddresses) { if ($this->primaryElectronicAddress !== null && !$this->electronicAddresses->contains($this->primaryElectronicAddress)) { $this->primaryElectronicAddress = null; } $this->electronicAddresses = $electronicAddresses; }
[ "public", "function", "setElectronicAddresses", "(", "Collection", "$", "electronicAddresses", ")", "{", "if", "(", "$", "this", "->", "primaryElectronicAddress", "!==", "null", "&&", "!", "$", "this", "->", "electronicAddresses", "->", "contains", "(", "$", "th...
Sets the electronic addresses of this person. @param \Doctrine\Common\Collections\Collection<\Neos\Party\Domain\Model\ElectronicAddress> $electronicAddresses @return void
[ "Sets", "the", "electronic", "addresses", "of", "this", "person", "." ]
cf771039e8da24762c21640f8761d40d281c0cd0
https://github.com/neos/party/blob/cf771039e8da24762c21640f8761d40d281c0cd0/Classes/Domain/Model/Person.php#L107-L113
train
chimeraphp/foundation
src/ExecuteQuery.php
ExecuteQuery.fetch
public function fetch(Input $input) { return $this->bus->handle( $this->messageCreator->create($this->query, $input) ); }
php
public function fetch(Input $input) { return $this->bus->handle( $this->messageCreator->create($this->query, $input) ); }
[ "public", "function", "fetch", "(", "Input", "$", "input", ")", "{", "return", "$", "this", "->", "bus", "->", "handle", "(", "$", "this", "->", "messageCreator", "->", "create", "(", "$", "this", "->", "query", ",", "$", "input", ")", ")", ";", "}...
Creates the query with given input, executes it, and returns the result @return mixed @throws MessageCannotBeCreated
[ "Creates", "the", "query", "with", "given", "input", "executes", "it", "and", "returns", "the", "result" ]
80535a588057a7d924233696c9c06db1faba3fa3
https://github.com/chimeraphp/foundation/blob/80535a588057a7d924233696c9c06db1faba3fa3/src/ExecuteQuery.php#L42-L47
train
vegas-cmf/core
src/Mvc/Dispatcher/Events/ExceptionListener.php
ExceptionListener.beforeException
public function beforeException() { /** * @param \Phalcon\Events\Event $event * @param \Phalcon\Dispatcher $dispatcher * @param \Exception $exception * @return callable */ return function(Event $event, Dispatcher $dispatcher, \Exception $exception) { $resolver = new ExceptionResolver(); $resolver->setDI($dispatcher->getDI()); $resolver->resolve($exception); return false; }; }
php
public function beforeException() { /** * @param \Phalcon\Events\Event $event * @param \Phalcon\Dispatcher $dispatcher * @param \Exception $exception * @return callable */ return function(Event $event, Dispatcher $dispatcher, \Exception $exception) { $resolver = new ExceptionResolver(); $resolver->setDI($dispatcher->getDI()); $resolver->resolve($exception); return false; }; }
[ "public", "function", "beforeException", "(", ")", "{", "/**\n * @param \\Phalcon\\Events\\Event $event\n * @param \\Phalcon\\Dispatcher $dispatcher\n * @param \\Exception $exception\n * @return callable\n */", "return", "function", "(", "Event", "$", ...
Event fired when exception is throwing
[ "Event", "fired", "when", "exception", "is", "throwing" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Dispatcher/Events/ExceptionListener.php#L28-L42
train
bradcornford/Googlitics
src/Cornford/Googlitics/Analytics.php
Analytics.render
public function render() { if (!$this->isEnabled()) { return; } if ($this->isAutomatic()) { $this->addItem("ga('send', '" . self::TYPE_PAGEVIEW . "');"); } if ($this->isAnonymised()) { $this->addItem("ga('set', 'anonymizeIp', true);"); } if ($this->application->environment() === 'dev') { $this->addItem("ga('create', '{$this->id}', { 'cookieDomain': 'none' });"); } else { $this->addItem("ga('create', '{$this->id}', '{$this->domain}');"); } return $this->view->make('googlitics::analytics')->withItems(array_reverse($this->getItems()))->render(); }
php
public function render() { if (!$this->isEnabled()) { return; } if ($this->isAutomatic()) { $this->addItem("ga('send', '" . self::TYPE_PAGEVIEW . "');"); } if ($this->isAnonymised()) { $this->addItem("ga('set', 'anonymizeIp', true);"); } if ($this->application->environment() === 'dev') { $this->addItem("ga('create', '{$this->id}', { 'cookieDomain': 'none' });"); } else { $this->addItem("ga('create', '{$this->id}', '{$this->domain}');"); } return $this->view->make('googlitics::analytics')->withItems(array_reverse($this->getItems()))->render(); }
[ "public", "function", "render", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "isAutomatic", "(", ")", ")", "{", "$", "this", "->", "addItem", "(", "\"ga('send...
Renders and returns Google Analytics code. @return string
[ "Renders", "and", "returns", "Google", "Analytics", "code", "." ]
644368a76703ce27bebd91e51eb6e77ec3eafdac
https://github.com/bradcornford/Googlitics/blob/644368a76703ce27bebd91e51eb6e77ec3eafdac/src/Cornford/Googlitics/Analytics.php#L13-L34
train
bradcornford/Googlitics
src/Cornford/Googlitics/Analytics.php
Analytics.trackPage
public function trackPage($page = null, $title = null, $type = self::TYPE_PAGEVIEW) { if (!defined('self::TYPE_'. strtoupper($type))) { throw new AnalyticsArgumentException('Type variable can\'t be of this type.'); } $item = "ga('send', 'pageview');"; if ($page !== null || $title !== null) { $page = ($page === null ? "window.location.href" : "'{$page}'"); $title = ($title === null ? "document.title" : "'{$title}'"); $item = "ga('send', { 'hitType': '{$type}', 'page': {$page}, 'title': {$title} });"; } $this->addItem($item); }
php
public function trackPage($page = null, $title = null, $type = self::TYPE_PAGEVIEW) { if (!defined('self::TYPE_'. strtoupper($type))) { throw new AnalyticsArgumentException('Type variable can\'t be of this type.'); } $item = "ga('send', 'pageview');"; if ($page !== null || $title !== null) { $page = ($page === null ? "window.location.href" : "'{$page}'"); $title = ($title === null ? "document.title" : "'{$title}'"); $item = "ga('send', { 'hitType': '{$type}', 'page': {$page}, 'title': {$title} });"; } $this->addItem($item); }
[ "public", "function", "trackPage", "(", "$", "page", "=", "null", ",", "$", "title", "=", "null", ",", "$", "type", "=", "self", "::", "TYPE_PAGEVIEW", ")", "{", "if", "(", "!", "defined", "(", "'self::TYPE_'", ".", "strtoupper", "(", "$", "type", ")...
Track a page view. @param string $page @param string $title @param string $type @throws AnalyticsArgumentException @return void
[ "Track", "a", "page", "view", "." ]
644368a76703ce27bebd91e51eb6e77ec3eafdac
https://github.com/bradcornford/Googlitics/blob/644368a76703ce27bebd91e51eb6e77ec3eafdac/src/Cornford/Googlitics/Analytics.php#L47-L62
train
bradcornford/Googlitics
src/Cornford/Googlitics/Analytics.php
Analytics.trackEvent
public function trackEvent($category, $action, $label = null, $value = null) { $item = "ga('send', 'event', '{$category}', '{$action}'" . ($label !== null ? ", '{$label}'" : '') . ($value !== null && is_numeric($value) ? ", {$value}" : '') . ");"; $this->addItem($item); }
php
public function trackEvent($category, $action, $label = null, $value = null) { $item = "ga('send', 'event', '{$category}', '{$action}'" . ($label !== null ? ", '{$label}'" : '') . ($value !== null && is_numeric($value) ? ", {$value}" : '') . ");"; $this->addItem($item); }
[ "public", "function", "trackEvent", "(", "$", "category", ",", "$", "action", ",", "$", "label", "=", "null", ",", "$", "value", "=", "null", ")", "{", "$", "item", "=", "\"ga('send', 'event', '{$category}', '{$action}'\"", ".", "(", "$", "label", "!==", "...
Track an event. @param string $category @param string $action @param string $label @param integer $value @return void
[ "Track", "an", "event", "." ]
644368a76703ce27bebd91e51eb6e77ec3eafdac
https://github.com/bradcornford/Googlitics/blob/644368a76703ce27bebd91e51eb6e77ec3eafdac/src/Cornford/Googlitics/Analytics.php#L89-L96
train
bradcornford/Googlitics
src/Cornford/Googlitics/Analytics.php
Analytics.trackTransaction
public function trackTransaction($id, array $options = []) { $options['id'] = $id; $this->trackEcommerce(self::ECOMMERCE_TRANSACTION, $options); }
php
public function trackTransaction($id, array $options = []) { $options['id'] = $id; $this->trackEcommerce(self::ECOMMERCE_TRANSACTION, $options); }
[ "public", "function", "trackTransaction", "(", "$", "id", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'id'", "]", "=", "$", "id", ";", "$", "this", "->", "trackEcommerce", "(", "self", "::", "ECOMMERCE_TRANSACTION", ","...
Track a transaction. @param string $id @param array $options (affiliation|revenue|shipping|tax) @return void
[ "Track", "a", "transaction", "." ]
644368a76703ce27bebd91e51eb6e77ec3eafdac
https://github.com/bradcornford/Googlitics/blob/644368a76703ce27bebd91e51eb6e77ec3eafdac/src/Cornford/Googlitics/Analytics.php#L106-L110
train
bradcornford/Googlitics
src/Cornford/Googlitics/Analytics.php
Analytics.trackItem
public function trackItem($id, $name, array $options = []) { $options['id'] = $id; $options['name'] = $name; $this->trackEcommerce(self::ECOMMERCE_ITEM, $options); }
php
public function trackItem($id, $name, array $options = []) { $options['id'] = $id; $options['name'] = $name; $this->trackEcommerce(self::ECOMMERCE_ITEM, $options); }
[ "public", "function", "trackItem", "(", "$", "id", ",", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'id'", "]", "=", "$", "id", ";", "$", "options", "[", "'name'", "]", "=", "$", "name", ";", "$", ...
Track a transaction item. @param string $id @param string $name @param array $options (sku|category|price|quantity) @return void
[ "Track", "a", "transaction", "item", "." ]
644368a76703ce27bebd91e51eb6e77ec3eafdac
https://github.com/bradcornford/Googlitics/blob/644368a76703ce27bebd91e51eb6e77ec3eafdac/src/Cornford/Googlitics/Analytics.php#L121-L126
train
bradcornford/Googlitics
src/Cornford/Googlitics/Analytics.php
Analytics.trackMetric
public function trackMetric($category, array $options = []) { $item = "ga('send', 'event', '{$category}'"; if (!empty($options)) { $item .= ", 'action', { "; foreach ($options as $key => $value) { $item .= "'{$key}': {$value}, "; } $item = rtrim($item, ', ') . " }"; } $item .= ");"; $this->addItem($item); }
php
public function trackMetric($category, array $options = []) { $item = "ga('send', 'event', '{$category}'"; if (!empty($options)) { $item .= ", 'action', { "; foreach ($options as $key => $value) { $item .= "'{$key}': {$value}, "; } $item = rtrim($item, ', ') . " }"; } $item .= ");"; $this->addItem($item); }
[ "public", "function", "trackMetric", "(", "$", "category", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "item", "=", "\"ga('send', 'event', '{$category}'\"", ";", "if", "(", "!", "empty", "(", "$", "options", ")", ")", "{", "$", "item", ...
Track a metric. @param string $category @param array $options @return void
[ "Track", "a", "metric", "." ]
644368a76703ce27bebd91e51eb6e77ec3eafdac
https://github.com/bradcornford/Googlitics/blob/644368a76703ce27bebd91e51eb6e77ec3eafdac/src/Cornford/Googlitics/Analytics.php#L136-L152
train
bradcornford/Googlitics
src/Cornford/Googlitics/Analytics.php
Analytics.trackException
public function trackException($description = null, $fatal = false) { $item = "ga('send', '" . self::TYPE_EXCEPTION . "'"; if ($description !== null && is_bool($fatal)) { $item .= ", { " . "'exDescription': '{$description}', " . "'exFatal': " . ($fatal ? 'true' : 'false') . " }"; } $item .= ");"; $this->addItem($item); }
php
public function trackException($description = null, $fatal = false) { $item = "ga('send', '" . self::TYPE_EXCEPTION . "'"; if ($description !== null && is_bool($fatal)) { $item .= ", { " . "'exDescription': '{$description}', " . "'exFatal': " . ($fatal ? 'true' : 'false') . " }"; } $item .= ");"; $this->addItem($item); }
[ "public", "function", "trackException", "(", "$", "description", "=", "null", ",", "$", "fatal", "=", "false", ")", "{", "$", "item", "=", "\"ga('send', '\"", ".", "self", "::", "TYPE_EXCEPTION", ".", "\"'\"", ";", "if", "(", "$", "description", "!==", "...
Track an exception. @param string $description @param boolean $fatal @return void
[ "Track", "an", "exception", "." ]
644368a76703ce27bebd91e51eb6e77ec3eafdac
https://github.com/bradcornford/Googlitics/blob/644368a76703ce27bebd91e51eb6e77ec3eafdac/src/Cornford/Googlitics/Analytics.php#L162-L176
train
vegas-cmf/core
src/Mvc/View/Engine/RegisterFiltersTrait.php
RegisterFiltersTrait.registerFilters
public function registerFilters () { foreach (glob($this->getFiltersDirectoryPath() . '*.php') as $file) { $filterName = pathinfo($file, PATHINFO_FILENAME); $this->registerFilter(lcfirst($filterName)); } }
php
public function registerFilters () { foreach (glob($this->getFiltersDirectoryPath() . '*.php') as $file) { $filterName = pathinfo($file, PATHINFO_FILENAME); $this->registerFilter(lcfirst($filterName)); } }
[ "public", "function", "registerFilters", "(", ")", "{", "foreach", "(", "glob", "(", "$", "this", "->", "getFiltersDirectoryPath", "(", ")", ".", "'*.php'", ")", "as", "$", "file", ")", "{", "$", "filterName", "=", "pathinfo", "(", "$", "file", ",", "P...
Registers view filters from directory
[ "Registers", "view", "filters", "from", "directory" ]
50fc3f31a6a8fc3cf274efd5b3eb3203d1206100
https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View/Engine/RegisterFiltersTrait.php#L37-L43
train
dreamfactorysoftware/df-oauth
src/Services/BaseOAuthService.php
BaseOAuthService.handleLogin
public function handleLogin($request) { /** @var RedirectResponse $response */ $response = $this->provider->redirect(); $traitsUsed = class_uses($this->provider); $traitTwo = DfOAuthTwoProvider::class; $traitOne = DfOAuthOneProvider::class; if (isset($traitsUsed[$traitTwo])) { $state = $this->provider->getState(); if (!empty($state)) { $key = static::CACHE_KEY_PREFIX . $state; \Cache::put($key, $this->getName(), 3); } } elseif (isset($traitsUsed[$traitOne])) { $token = $this->provider->getOAuthToken(); if (!empty($token)) { $key = static::CACHE_KEY_PREFIX . $token; \Cache::put($key, $this->getName(), 3); } } if (!$request->ajax()) { return $response; } $url = $response->getTargetUrl(); $result = ['response' => ['redirect' => true, 'url' => $url]]; return $result; }
php
public function handleLogin($request) { /** @var RedirectResponse $response */ $response = $this->provider->redirect(); $traitsUsed = class_uses($this->provider); $traitTwo = DfOAuthTwoProvider::class; $traitOne = DfOAuthOneProvider::class; if (isset($traitsUsed[$traitTwo])) { $state = $this->provider->getState(); if (!empty($state)) { $key = static::CACHE_KEY_PREFIX . $state; \Cache::put($key, $this->getName(), 3); } } elseif (isset($traitsUsed[$traitOne])) { $token = $this->provider->getOAuthToken(); if (!empty($token)) { $key = static::CACHE_KEY_PREFIX . $token; \Cache::put($key, $this->getName(), 3); } } if (!$request->ajax()) { return $response; } $url = $response->getTargetUrl(); $result = ['response' => ['redirect' => true, 'url' => $url]]; return $result; }
[ "public", "function", "handleLogin", "(", "$", "request", ")", "{", "/** @var RedirectResponse $response */", "$", "response", "=", "$", "this", "->", "provider", "->", "redirect", "(", ")", ";", "$", "traitsUsed", "=", "class_uses", "(", "$", "this", "->", ...
Handles login using this service. @param Request $request @return array|bool|RedirectResponse
[ "Handles", "login", "using", "this", "service", "." ]
2f82b3915ab59188fe6ba5b6f387291d1ac83f4d
https://github.com/dreamfactorysoftware/df-oauth/blob/2f82b3915ab59188fe6ba5b6f387291d1ac83f4d/src/Services/BaseOAuthService.php#L106-L134
train
dreamfactorysoftware/df-oauth
src/Services/BaseOAuthService.php
BaseOAuthService.handleOAuthCallback
public function handleOAuthCallback() { $provider = $this->getProvider(); /** @var OAuthUserContract $user */ $user = $provider->user(); return $this->loginOAuthUser($user); }
php
public function handleOAuthCallback() { $provider = $this->getProvider(); /** @var OAuthUserContract $user */ $user = $provider->user(); return $this->loginOAuthUser($user); }
[ "public", "function", "handleOAuthCallback", "(", ")", "{", "$", "provider", "=", "$", "this", "->", "getProvider", "(", ")", ";", "/** @var OAuthUserContract $user */", "$", "user", "=", "$", "provider", "->", "user", "(", ")", ";", "return", "$", "this", ...
Handles OAuth callback @return array
[ "Handles", "OAuth", "callback" ]
2f82b3915ab59188fe6ba5b6f387291d1ac83f4d
https://github.com/dreamfactorysoftware/df-oauth/blob/2f82b3915ab59188fe6ba5b6f387291d1ac83f4d/src/Services/BaseOAuthService.php#L141-L148
train
dreamfactorysoftware/df-oauth
src/Services/BaseOAuthService.php
BaseOAuthService.loginOAuthUser
public function loginOAuthUser(OAuthUserContract $user) { /** @noinspection PhpUndefinedFieldInspection */ $responseBody = $user->accessTokenResponseBody; /** @noinspection PhpUndefinedFieldInspection */ $token = $user->token; $dfUser = $this->createShadowOAuthUser($user); $dfUser->last_login_date = Carbon::now()->toDateTimeString(); $dfUser->confirm_code = null; $dfUser->save(); $map = OAuthTokenMap::whereServiceId($this->id)->whereUserId($dfUser->id)->first(); if (empty($map)) { OAuthTokenMap::create( [ 'user_id' => $dfUser->id, 'service_id' => $this->id, 'token' => $token, 'response' => $responseBody ]); } else { $map->update(['token' => $token, 'response' => $responseBody]); } Session::setUserInfoWithJWT($dfUser); $response = Session::getPublicInfo(); $response['oauth_token'] = $token; if (isset($responseBody['id_token'])) { $response['id_token'] = $responseBody['id_token']; } return $response; }
php
public function loginOAuthUser(OAuthUserContract $user) { /** @noinspection PhpUndefinedFieldInspection */ $responseBody = $user->accessTokenResponseBody; /** @noinspection PhpUndefinedFieldInspection */ $token = $user->token; $dfUser = $this->createShadowOAuthUser($user); $dfUser->last_login_date = Carbon::now()->toDateTimeString(); $dfUser->confirm_code = null; $dfUser->save(); $map = OAuthTokenMap::whereServiceId($this->id)->whereUserId($dfUser->id)->first(); if (empty($map)) { OAuthTokenMap::create( [ 'user_id' => $dfUser->id, 'service_id' => $this->id, 'token' => $token, 'response' => $responseBody ]); } else { $map->update(['token' => $token, 'response' => $responseBody]); } Session::setUserInfoWithJWT($dfUser); $response = Session::getPublicInfo(); $response['oauth_token'] = $token; if (isset($responseBody['id_token'])) { $response['id_token'] = $responseBody['id_token']; } return $response; }
[ "public", "function", "loginOAuthUser", "(", "OAuthUserContract", "$", "user", ")", "{", "/** @noinspection PhpUndefinedFieldInspection */", "$", "responseBody", "=", "$", "user", "->", "accessTokenResponseBody", ";", "/** @noinspection PhpUndefinedFieldInspection */", "$", "...
Logs in OAuth user @param \Laravel\Socialite\Contracts\User $user @return array
[ "Logs", "in", "OAuth", "user" ]
2f82b3915ab59188fe6ba5b6f387291d1ac83f4d
https://github.com/dreamfactorysoftware/df-oauth/blob/2f82b3915ab59188fe6ba5b6f387291d1ac83f4d/src/Services/BaseOAuthService.php#L157-L189
train
dreamfactorysoftware/df-oauth
src/Services/BaseOAuthService.php
BaseOAuthService.createShadowOAuthUser
public function createShadowOAuthUser(OAuthUserContract $OAuthUser) { $fullName = $OAuthUser->getName(); @list($firstName, $lastName) = explode(' ', $fullName); $email = $OAuthUser->getEmail(); $serviceName = $this->getName(); $providerName = $this->getProviderName(); if (empty($email)) { $email = $OAuthUser->getId() . '+' . $serviceName . '@' . $serviceName . '.com'; } else { list($emailId, $domain) = explode('@', $email); $email = $emailId . '+' . $serviceName . '@' . $domain; } $user = User::whereEmail($email)->first(); if (empty($user)) { $data = [ 'username' => $email, 'name' => $fullName, 'first_name' => $firstName, 'last_name' => $lastName, 'email' => $email, 'is_active' => true, 'oauth_provider' => $providerName, ]; $user = User::create($data); } // todo Should this be done only if the user was not already there? if (!empty($defaultRole = $this->getDefaultRole())) { User::applyDefaultUserAppRole($user, $defaultRole); } if (!empty($serviceId = $this->getServiceId())) { User::applyAppRoleMapByService($user, $serviceId); } return $user; }
php
public function createShadowOAuthUser(OAuthUserContract $OAuthUser) { $fullName = $OAuthUser->getName(); @list($firstName, $lastName) = explode(' ', $fullName); $email = $OAuthUser->getEmail(); $serviceName = $this->getName(); $providerName = $this->getProviderName(); if (empty($email)) { $email = $OAuthUser->getId() . '+' . $serviceName . '@' . $serviceName . '.com'; } else { list($emailId, $domain) = explode('@', $email); $email = $emailId . '+' . $serviceName . '@' . $domain; } $user = User::whereEmail($email)->first(); if (empty($user)) { $data = [ 'username' => $email, 'name' => $fullName, 'first_name' => $firstName, 'last_name' => $lastName, 'email' => $email, 'is_active' => true, 'oauth_provider' => $providerName, ]; $user = User::create($data); } // todo Should this be done only if the user was not already there? if (!empty($defaultRole = $this->getDefaultRole())) { User::applyDefaultUserAppRole($user, $defaultRole); } if (!empty($serviceId = $this->getServiceId())) { User::applyAppRoleMapByService($user, $serviceId); } return $user; }
[ "public", "function", "createShadowOAuthUser", "(", "OAuthUserContract", "$", "OAuthUser", ")", "{", "$", "fullName", "=", "$", "OAuthUser", "->", "getName", "(", ")", ";", "@", "list", "(", "$", "firstName", ",", "$", "lastName", ")", "=", "explode", "(",...
If does not exists, creates a shadow OAuth user using user info provided by the OAuth service provider and assigns default role to this user for all apps in the system. If user already exists then updates user's role for all apps and returns it. @param OAuthUserContract $OAuthUser @return User @throws \Exception
[ "If", "does", "not", "exists", "creates", "a", "shadow", "OAuth", "user", "using", "user", "info", "provided", "by", "the", "OAuth", "service", "provider", "and", "assigns", "default", "role", "to", "this", "user", "for", "all", "apps", "in", "the", "syste...
2f82b3915ab59188fe6ba5b6f387291d1ac83f4d
https://github.com/dreamfactorysoftware/df-oauth/blob/2f82b3915ab59188fe6ba5b6f387291d1ac83f4d/src/Services/BaseOAuthService.php#L202-L243
train