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
thecodingmachine/splash-router
src/TheCodingMachine/Splash/Services/SplashRequestParameterFetcher.php
SplashRequestParameterFetcher.fetchValue
public function fetchValue($data, SplashRequestContext $context) { $key = $data['key']; $compulsory = $data['compulsory']; $default = $data['default'] ?? null; return $context->getParameter($key, $compulsory, $default); }
php
public function fetchValue($data, SplashRequestContext $context) { $key = $data['key']; $compulsory = $data['compulsory']; $default = $data['default'] ?? null; return $context->getParameter($key, $compulsory, $default); }
[ "public", "function", "fetchValue", "(", "$", "data", ",", "SplashRequestContext", "$", "context", ")", "{", "$", "key", "=", "$", "data", "[", "'key'", "]", ";", "$", "compulsory", "=", "$", "data", "[", "'compulsory'", "]", ";", "$", "default", "=", ...
Returns the value to be injected in this parameter. @param mixed $data The data generated by "getFetcherData" @param SplashRequestContext $context @return mixed
[ "Returns", "the", "value", "to", "be", "injected", "in", "this", "parameter", "." ]
2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7
https://github.com/thecodingmachine/splash-router/blob/2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7/src/TheCodingMachine/Splash/Services/SplashRequestParameterFetcher.php#L62-L69
train
Litecms/News
src/Http/Controllers/NewsResourceController.php
NewsResourceController.index
public function index(NewsRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\News\Repositories\Presenter\NewsPresenter::class) ->$function(); } $news = $this->repository->paginate(); return $this->response->title(trans('news::news.names')) ->view('news::news.index', true) ->data(compact('news')) ->output(); }
php
public function index(NewsRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\News\Repositories\Presenter\NewsPresenter::class) ->$function(); } $news = $this->repository->paginate(); return $this->response->title(trans('news::news.names')) ->view('news::news.index', true) ->data(compact('news')) ->output(); }
[ "public", "function", "index", "(", "NewsRequest", "$", "request", ")", "{", "$", "view", "=", "$", "this", "->", "response", "->", "theme", "->", "listView", "(", ")", ";", "if", "(", "$", "this", "->", "response", "->", "typeIs", "(", "'json'", ")"...
Display a list of news. @return Response
[ "Display", "a", "list", "of", "news", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Http/Controllers/NewsResourceController.php#L38-L55
train
Litecms/News
src/Http/Controllers/NewsResourceController.php
NewsResourceController.show
public function show(NewsRequest $request, News $news) { if ($news->exists) { $view = 'news::news.show'; } else { $view = 'news::news.new'; } return $this->response->title(trans('app.view') . ' ' . trans('news::news.name')) ->data(compact('news')) ->view($view, true) ->output(); }
php
public function show(NewsRequest $request, News $news) { if ($news->exists) { $view = 'news::news.show'; } else { $view = 'news::news.new'; } return $this->response->title(trans('app.view') . ' ' . trans('news::news.name')) ->data(compact('news')) ->view($view, true) ->output(); }
[ "public", "function", "show", "(", "NewsRequest", "$", "request", ",", "News", "$", "news", ")", "{", "if", "(", "$", "news", "->", "exists", ")", "{", "$", "view", "=", "'news::news.show'", ";", "}", "else", "{", "$", "view", "=", "'news::news.new'", ...
Display news. @param Request $request @param Model $news @return Response
[ "Display", "news", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Http/Controllers/NewsResourceController.php#L65-L78
train
Litecms/News
src/Http/Controllers/NewsResourceController.php
NewsResourceController.edit
public function edit(NewsRequest $request, News $news) { return $this->response->title(trans('app.edit') . ' ' . trans('news::news.name')) ->view('news::news.edit', true) ->data(compact('news')) ->output(); }
php
public function edit(NewsRequest $request, News $news) { return $this->response->title(trans('app.edit') . ' ' . trans('news::news.name')) ->view('news::news.edit', true) ->data(compact('news')) ->output(); }
[ "public", "function", "edit", "(", "NewsRequest", "$", "request", ",", "News", "$", "news", ")", "{", "return", "$", "this", "->", "response", "->", "title", "(", "trans", "(", "'app.edit'", ")", ".", "' '", ".", "trans", "(", "'news::news.name'", ")", ...
Show news for editing. @param Request $request @param Model $news @return Response
[ "Show", "news", "for", "editing", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Http/Controllers/NewsResourceController.php#L135-L141
train
Litecms/News
src/Http/Controllers/NewsResourceController.php
NewsResourceController.update
public function update(NewsRequest $request, News $news) { try { $attributes = $request->all(); $news->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('news::news.name')])) ->code(204) ->status('success') ->url(guard_url('news/news/' . $news->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('news/news/' . $news->getRouteKey())) ->redirect(); } }
php
public function update(NewsRequest $request, News $news) { try { $attributes = $request->all(); $news->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('news::news.name')])) ->code(204) ->status('success') ->url(guard_url('news/news/' . $news->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('news/news/' . $news->getRouteKey())) ->redirect(); } }
[ "public", "function", "update", "(", "NewsRequest", "$", "request", ",", "News", "$", "news", ")", "{", "try", "{", "$", "attributes", "=", "$", "request", "->", "all", "(", ")", ";", "$", "news", "->", "update", "(", "$", "attributes", ")", ";", "...
Update the news. @param Request $request @param Model $news @return Response
[ "Update", "the", "news", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Http/Controllers/NewsResourceController.php#L151-L170
train
Litecms/News
src/Http/Controllers/NewsResourceController.php
NewsResourceController.destroy
public function destroy(NewsRequest $request, News $news) { try { $news->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('news::news.name')])) ->code(202) ->status('success') ->url(guard_url('news/news/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('news/news/' . $news->getRouteKey())) ->redirect(); } }
php
public function destroy(NewsRequest $request, News $news) { try { $news->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('news::news.name')])) ->code(202) ->status('success') ->url(guard_url('news/news/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('news/news/' . $news->getRouteKey())) ->redirect(); } }
[ "public", "function", "destroy", "(", "NewsRequest", "$", "request", ",", "News", "$", "news", ")", "{", "try", "{", "$", "news", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "response", "->", "message", "(", "trans", "(", "'messages.suc...
Remove the news. @param Model $news @return Response
[ "Remove", "the", "news", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Http/Controllers/NewsResourceController.php#L179-L199
train
thecodingmachine/splash-router
src/TheCodingMachine/Splash/Routers/SplashRouter.php
SplashRouter.purgeExpiredRoutes
private function purgeExpiredRoutes() { $expireTag = ''; foreach ($this->routeProviders as $routeProvider) { /* @var $routeProvider UrlProviderInterface */ $expireTag .= $routeProvider->getExpirationTag(); } $value = md5($expireTag); $urlNodesCacheItem = $this->cachePool->getItem('splashExpireTag'); if ($urlNodesCacheItem->isHit() && $urlNodesCacheItem->get() === $value) { return; } $this->purgeUrlsCache(); $urlNodesCacheItem->set($value); $this->cachePool->save($urlNodesCacheItem); }
php
private function purgeExpiredRoutes() { $expireTag = ''; foreach ($this->routeProviders as $routeProvider) { /* @var $routeProvider UrlProviderInterface */ $expireTag .= $routeProvider->getExpirationTag(); } $value = md5($expireTag); $urlNodesCacheItem = $this->cachePool->getItem('splashExpireTag'); if ($urlNodesCacheItem->isHit() && $urlNodesCacheItem->get() === $value) { return; } $this->purgeUrlsCache(); $urlNodesCacheItem->set($value); $this->cachePool->save($urlNodesCacheItem); }
[ "private", "function", "purgeExpiredRoutes", "(", ")", "{", "$", "expireTag", "=", "''", ";", "foreach", "(", "$", "this", "->", "routeProviders", "as", "$", "routeProvider", ")", "{", "/* @var $routeProvider UrlProviderInterface */", "$", "expireTag", ".=", "$", ...
Purges the cache if one of the url providers tells us to.
[ "Purges", "the", "cache", "if", "one", "of", "the", "url", "providers", "tells", "us", "to", "." ]
2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7
https://github.com/thecodingmachine/splash-router/blob/2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7/src/TheCodingMachine/Splash/Routers/SplashRouter.php#L224-L244
train
thecodingmachine/splash-router
src/TheCodingMachine/Splash/Routers/SplashRouter.php
SplashRouter.getSplashActionsList
public function getSplashActionsList(): array { $urls = array(); foreach ($this->routeProviders as $routeProvider) { /* @var $routeProvider UrlProviderInterface */ $tmpUrlList = $routeProvider->getUrlsList(null); $urls = array_merge($urls, $tmpUrlList); } return $urls; }
php
public function getSplashActionsList(): array { $urls = array(); foreach ($this->routeProviders as $routeProvider) { /* @var $routeProvider UrlProviderInterface */ $tmpUrlList = $routeProvider->getUrlsList(null); $urls = array_merge($urls, $tmpUrlList); } return $urls; }
[ "public", "function", "getSplashActionsList", "(", ")", ":", "array", "{", "$", "urls", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "routeProviders", "as", "$", "routeProvider", ")", "{", "/* @var $routeProvider UrlProviderInterface */", "$",...
Returns the list of all SplashActions. This call is LONG and should be cached. @return SplashRoute[]
[ "Returns", "the", "list", "of", "all", "SplashActions", ".", "This", "call", "is", "LONG", "and", "should", "be", "cached", "." ]
2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7
https://github.com/thecodingmachine/splash-router/blob/2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7/src/TheCodingMachine/Splash/Routers/SplashRouter.php#L252-L263
train
thecodingmachine/splash-router
src/TheCodingMachine/Splash/Routers/SplashRouter.php
SplashRouter.generateUrlNode
private function generateUrlNode($urlsList) { $urlNode = new SplashUrlNode(); foreach ($urlsList as $splashAction) { $urlNode->registerCallback($splashAction); } return $urlNode; }
php
private function generateUrlNode($urlsList) { $urlNode = new SplashUrlNode(); foreach ($urlsList as $splashAction) { $urlNode->registerCallback($splashAction); } return $urlNode; }
[ "private", "function", "generateUrlNode", "(", "$", "urlsList", ")", "{", "$", "urlNode", "=", "new", "SplashUrlNode", "(", ")", ";", "foreach", "(", "$", "urlsList", "as", "$", "splashAction", ")", "{", "$", "urlNode", "->", "registerCallback", "(", "$", ...
Generates the URLNodes from the list of URLS. URLNodes are a very efficient way to know whether we can access our page or not. @param SplashRouteInterface[] $urlsList @return SplashUrlNode
[ "Generates", "the", "URLNodes", "from", "the", "list", "of", "URLS", ".", "URLNodes", "are", "a", "very", "efficient", "way", "to", "know", "whether", "we", "can", "access", "our", "page", "or", "not", "." ]
2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7
https://github.com/thecodingmachine/splash-router/blob/2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7/src/TheCodingMachine/Splash/Routers/SplashRouter.php#L273-L281
train
thecodingmachine/splash-router
src/TheCodingMachine/Splash/Services/ControllerAnalyzer.php
ControllerAnalyzer.analyzeController
public function analyzeController(string $controllerInstanceName) : array { // Let's analyze the controller and get all the @Action annotations: $urlsList = array(); $controller = $this->container->get($controllerInstanceName); $refClass = new \ReflectionClass($controller); foreach ($refClass->getMethods() as $refMethod) { $title = null; // Now, let's check the "Title" annotation (note: we do not support multiple title annotations for the same method) /** @var Title */ $titleAnnotation = $this->annotationReader->getMethodAnnotation($refMethod, Title::class); if ($titleAnnotation !== null) { $title = $titleAnnotation->getTitle(); } // First, let's check the "Action" annotation $actionAnnotation = $this->annotationReader->getMethodAnnotation($refMethod, Action::class); if ($actionAnnotation !== null) { $methodName = $refMethod->getName(); if ($methodName === 'index') { $url = $controllerInstanceName.'/'; } else { $url = $controllerInstanceName.'/'.$methodName; } $parameters = $this->parameterFetcherRegistry->mapParameters($refMethod); $filters = FilterUtils::getFilters($refMethod, $this->annotationReader); $urlsList[] = new SplashRoute($url, $controllerInstanceName, $refMethod->getName(), $title, $refMethod->getDocComment(), $this->getSupportedHttpMethods($refMethod), $parameters, $filters, $refClass->getFileName()); } // Now, let's check the "URL" annotation (note: we support multiple URL annotations for the same method) $annotations = $this->annotationReader->getMethodAnnotations($refMethod); foreach ($annotations as $annotation) { if (!$annotation instanceof URL) { continue; } /* @var $annotation URL */ $url = $annotation->getUrl(); // Get public properties if they exist in the URL if (preg_match_all('/[^{]*{\$this->([^\/]*)}[^{]*/', $url, $output)) { foreach ($output[1] as $param) { $value = $this->readPrivateProperty($controller, $param); $url = str_replace('{$this->'.$param.'}', $value, $url); } } $url = ltrim($url, '/'); $parameters = $this->parameterFetcherRegistry->mapParameters($refMethod, $url); $filters = FilterUtils::getFilters($refMethod, $this->annotationReader); $urlsList[] = new SplashRoute($url, $controllerInstanceName, $refMethod->getName(), $title, $refMethod->getDocComment(), $this->getSupportedHttpMethods($refMethod), $parameters, $filters, $refClass->getFileName()); } } return $urlsList; }
php
public function analyzeController(string $controllerInstanceName) : array { // Let's analyze the controller and get all the @Action annotations: $urlsList = array(); $controller = $this->container->get($controllerInstanceName); $refClass = new \ReflectionClass($controller); foreach ($refClass->getMethods() as $refMethod) { $title = null; // Now, let's check the "Title" annotation (note: we do not support multiple title annotations for the same method) /** @var Title */ $titleAnnotation = $this->annotationReader->getMethodAnnotation($refMethod, Title::class); if ($titleAnnotation !== null) { $title = $titleAnnotation->getTitle(); } // First, let's check the "Action" annotation $actionAnnotation = $this->annotationReader->getMethodAnnotation($refMethod, Action::class); if ($actionAnnotation !== null) { $methodName = $refMethod->getName(); if ($methodName === 'index') { $url = $controllerInstanceName.'/'; } else { $url = $controllerInstanceName.'/'.$methodName; } $parameters = $this->parameterFetcherRegistry->mapParameters($refMethod); $filters = FilterUtils::getFilters($refMethod, $this->annotationReader); $urlsList[] = new SplashRoute($url, $controllerInstanceName, $refMethod->getName(), $title, $refMethod->getDocComment(), $this->getSupportedHttpMethods($refMethod), $parameters, $filters, $refClass->getFileName()); } // Now, let's check the "URL" annotation (note: we support multiple URL annotations for the same method) $annotations = $this->annotationReader->getMethodAnnotations($refMethod); foreach ($annotations as $annotation) { if (!$annotation instanceof URL) { continue; } /* @var $annotation URL */ $url = $annotation->getUrl(); // Get public properties if they exist in the URL if (preg_match_all('/[^{]*{\$this->([^\/]*)}[^{]*/', $url, $output)) { foreach ($output[1] as $param) { $value = $this->readPrivateProperty($controller, $param); $url = str_replace('{$this->'.$param.'}', $value, $url); } } $url = ltrim($url, '/'); $parameters = $this->parameterFetcherRegistry->mapParameters($refMethod, $url); $filters = FilterUtils::getFilters($refMethod, $this->annotationReader); $urlsList[] = new SplashRoute($url, $controllerInstanceName, $refMethod->getName(), $title, $refMethod->getDocComment(), $this->getSupportedHttpMethods($refMethod), $parameters, $filters, $refClass->getFileName()); } } return $urlsList; }
[ "public", "function", "analyzeController", "(", "string", "$", "controllerInstanceName", ")", ":", "array", "{", "// Let's analyze the controller and get all the @Action annotations:", "$", "urlsList", "=", "array", "(", ")", ";", "$", "controller", "=", "$", "this", ...
Returns an array of SplashRoute for the controller passed in parameter. @return SplashRoute[] @throws SplashException
[ "Returns", "an", "array", "of", "SplashRoute", "for", "the", "controller", "passed", "in", "parameter", "." ]
2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7
https://github.com/thecodingmachine/splash-router/blob/2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7/src/TheCodingMachine/Splash/Services/ControllerAnalyzer.php#L80-L139
train
Litecms/News
src/Policies/CommentPolicy.php
CommentPolicy.update
public function update(UserPolicy $user, Comment $comment) { if ($user->canDo('news.comment.edit') && $user->isAdmin()) { return true; } return $comment->user_id == user_id() && $comment->user_type == user_type(); }
php
public function update(UserPolicy $user, Comment $comment) { if ($user->canDo('news.comment.edit') && $user->isAdmin()) { return true; } return $comment->user_id == user_id() && $comment->user_type == user_type(); }
[ "public", "function", "update", "(", "UserPolicy", "$", "user", ",", "Comment", "$", "comment", ")", "{", "if", "(", "$", "user", "->", "canDo", "(", "'news.comment.edit'", ")", "&&", "$", "user", "->", "isAdmin", "(", ")", ")", "{", "return", "true", ...
Determine if the given user can update the given comment. @param UserPolicy $user @param Comment $comment @return bool
[ "Determine", "if", "the", "given", "user", "can", "update", "the", "given", "comment", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Policies/CommentPolicy.php#L49-L56
train
Litecms/News
src/Policies/CommentPolicy.php
CommentPolicy.destroy
public function destroy(UserPolicy $user, Comment $comment) { return $comment->user_id == user_id() && $comment->user_type == user_type(); }
php
public function destroy(UserPolicy $user, Comment $comment) { return $comment->user_id == user_id() && $comment->user_type == user_type(); }
[ "public", "function", "destroy", "(", "UserPolicy", "$", "user", ",", "Comment", "$", "comment", ")", "{", "return", "$", "comment", "->", "user_id", "==", "user_id", "(", ")", "&&", "$", "comment", "->", "user_type", "==", "user_type", "(", ")", ";", ...
Determine if the given user can delete the given comment. @param UserPolicy $user @param Comment $comment @return bool
[ "Determine", "if", "the", "given", "user", "can", "delete", "the", "given", "comment", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Policies/CommentPolicy.php#L66-L69
train
thecodingmachine/splash-router
src/TheCodingMachine/Splash/Services/ControllerRegistry.php
ControllerRegistry.getExpirationTag
public function getExpirationTag() : string { // An approximate, quick-to-compute rule that will force renewing the cache if a controller is added are a parameter is fetched. return implode('-/-', $this->controllers).($this->controllerDetector !== null ? $this->controllerDetector->getExpirationTag() : ''); }
php
public function getExpirationTag() : string { // An approximate, quick-to-compute rule that will force renewing the cache if a controller is added are a parameter is fetched. return implode('-/-', $this->controllers).($this->controllerDetector !== null ? $this->controllerDetector->getExpirationTag() : ''); }
[ "public", "function", "getExpirationTag", "(", ")", ":", "string", "{", "// An approximate, quick-to-compute rule that will force renewing the cache if a controller is added are a parameter is fetched.", "return", "implode", "(", "'-/-'", ",", "$", "this", "->", "controllers", ")...
Returns a unique tag representing the list of SplashRoutes returned. If the tag changes, the cache is flushed by Splash. Important! This must be quick to compute.
[ "Returns", "a", "unique", "tag", "representing", "the", "list", "of", "SplashRoutes", "returned", ".", "If", "the", "tag", "changes", "the", "cache", "is", "flushed", "by", "Splash", "." ]
2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7
https://github.com/thecodingmachine/splash-router/blob/2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7/src/TheCodingMachine/Splash/Services/ControllerRegistry.php#L93-L97
train
thecodingmachine/splash-router
src/TheCodingMachine/Splash/Services/ParameterFetcherRegistry.php
ParameterFetcherRegistry.toArguments
public function toArguments(SplashRequestContext $context, array $parametersMap) : array { $arguments = []; foreach ($parametersMap as $parameter) { $fetcherid = $parameter['fetcherId']; $data = $parameter['data']; $arguments[] = $this->parameterFetchers[$fetcherid]->fetchValue($data, $context); } return $arguments; }
php
public function toArguments(SplashRequestContext $context, array $parametersMap) : array { $arguments = []; foreach ($parametersMap as $parameter) { $fetcherid = $parameter['fetcherId']; $data = $parameter['data']; $arguments[] = $this->parameterFetchers[$fetcherid]->fetchValue($data, $context); } return $arguments; }
[ "public", "function", "toArguments", "(", "SplashRequestContext", "$", "context", ",", "array", "$", "parametersMap", ")", ":", "array", "{", "$", "arguments", "=", "[", "]", ";", "foreach", "(", "$", "parametersMap", "as", "$", "parameter", ")", "{", "$",...
Maps data returned by mapParameters to real arguments to be passed to the action. @param SplashRequestContext $context @param array $parametersMap @return array
[ "Maps", "data", "returned", "by", "mapParameters", "to", "real", "arguments", "to", "be", "passed", "to", "the", "action", "." ]
2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7
https://github.com/thecodingmachine/splash-router/blob/2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7/src/TheCodingMachine/Splash/Services/ParameterFetcherRegistry.php#L96-L106
train
Litecms/News
src/Policies/CategoryPolicy.php
CategoryPolicy.destroy
public function destroy(UserPolicy $user, Category $category) { return $category->user_id == user_id() && $category->user_type == user_type(); }
php
public function destroy(UserPolicy $user, Category $category) { return $category->user_id == user_id() && $category->user_type == user_type(); }
[ "public", "function", "destroy", "(", "UserPolicy", "$", "user", ",", "Category", "$", "category", ")", "{", "return", "$", "category", "->", "user_id", "==", "user_id", "(", ")", "&&", "$", "category", "->", "user_type", "==", "user_type", "(", ")", ";"...
Determine if the given user can delete the given category. @param UserPolicy $user @param Category $category @return bool
[ "Determine", "if", "the", "given", "user", "can", "delete", "the", "given", "category", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Policies/CategoryPolicy.php#L66-L69
train
Litecms/News
src/Policies/NewsPolicy.php
NewsPolicy.view
public function view(UserPolicy $user, News $news) { if ($user->canDo('news.news.view') && $user->isAdmin()) { return true; } return $news->user_id == user_id() && $news->user_type == user_type(); }
php
public function view(UserPolicy $user, News $news) { if ($user->canDo('news.news.view') && $user->isAdmin()) { return true; } return $news->user_id == user_id() && $news->user_type == user_type(); }
[ "public", "function", "view", "(", "UserPolicy", "$", "user", ",", "News", "$", "news", ")", "{", "if", "(", "$", "user", "->", "canDo", "(", "'news.news.view'", ")", "&&", "$", "user", "->", "isAdmin", "(", ")", ")", "{", "return", "true", ";", "}...
Determine if the given user can view the news. @param UserPolicy $user @param News $news @return bool
[ "Determine", "if", "the", "given", "user", "can", "view", "the", "news", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Policies/NewsPolicy.php#L19-L26
train
Litecms/News
src/Policies/NewsPolicy.php
NewsPolicy.destroy
public function destroy(UserPolicy $user, News $news) { return $news->user_id == user_id() && $news->user_type == user_type(); }
php
public function destroy(UserPolicy $user, News $news) { return $news->user_id == user_id() && $news->user_type == user_type(); }
[ "public", "function", "destroy", "(", "UserPolicy", "$", "user", ",", "News", "$", "news", ")", "{", "return", "$", "news", "->", "user_id", "==", "user_id", "(", ")", "&&", "$", "news", "->", "user_type", "==", "user_type", "(", ")", ";", "}" ]
Determine if the given user can delete the given news. @param UserPolicy $user @param News $news @return bool
[ "Determine", "if", "the", "given", "user", "can", "delete", "the", "given", "news", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Policies/NewsPolicy.php#L66-L69
train
Litecms/News
src/Http/Controllers/CommentResourceController.php
CommentResourceController.edit
public function edit(CommentRequest $request, Comment $comment) { return $this->response->title(trans('app.edit') . ' ' . trans('news::comment.name')) ->view('news::comment.edit', true) ->data(compact('comment')) ->output(); }
php
public function edit(CommentRequest $request, Comment $comment) { return $this->response->title(trans('app.edit') . ' ' . trans('news::comment.name')) ->view('news::comment.edit', true) ->data(compact('comment')) ->output(); }
[ "public", "function", "edit", "(", "CommentRequest", "$", "request", ",", "Comment", "$", "comment", ")", "{", "return", "$", "this", "->", "response", "->", "title", "(", "trans", "(", "'app.edit'", ")", ".", "' '", ".", "trans", "(", "'news::comment.name...
Show comment for editing. @param Request $request @param Model $comment @return Response
[ "Show", "comment", "for", "editing", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Http/Controllers/CommentResourceController.php#L135-L141
train
Litecms/News
src/Policies/TagPolicy.php
TagPolicy.view
public function view(UserPolicy $user, Tag $tag) { if ($user->canDo('news.tag.view') && $user->isAdmin()) { return true; } return $tag->user_id == user_id() && $tag->user_type == user_type(); }
php
public function view(UserPolicy $user, Tag $tag) { if ($user->canDo('news.tag.view') && $user->isAdmin()) { return true; } return $tag->user_id == user_id() && $tag->user_type == user_type(); }
[ "public", "function", "view", "(", "UserPolicy", "$", "user", ",", "Tag", "$", "tag", ")", "{", "if", "(", "$", "user", "->", "canDo", "(", "'news.tag.view'", ")", "&&", "$", "user", "->", "isAdmin", "(", ")", ")", "{", "return", "true", ";", "}", ...
Determine if the given user can view the tag. @param UserPolicy $user @param Tag $tag @return bool
[ "Determine", "if", "the", "given", "user", "can", "view", "the", "tag", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Policies/TagPolicy.php#L19-L26
train
Litecms/News
src/Policies/TagPolicy.php
TagPolicy.destroy
public function destroy(UserPolicy $user, Tag $tag) { return $tag->user_id == user_id() && $tag->user_type == user_type(); }
php
public function destroy(UserPolicy $user, Tag $tag) { return $tag->user_id == user_id() && $tag->user_type == user_type(); }
[ "public", "function", "destroy", "(", "UserPolicy", "$", "user", ",", "Tag", "$", "tag", ")", "{", "return", "$", "tag", "->", "user_id", "==", "user_id", "(", ")", "&&", "$", "tag", "->", "user_type", "==", "user_type", "(", ")", ";", "}" ]
Determine if the given user can delete the given tag. @param UserPolicy $user @param Tag $tag @return bool
[ "Determine", "if", "the", "given", "user", "can", "delete", "the", "given", "tag", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Policies/TagPolicy.php#L66-L69
train
Litecms/News
src/Http/Controllers/TagResourceController.php
TagResourceController.index
public function index(TagRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\News\Repositories\Presenter\TagPresenter::class) ->$function(); } $tags = $this->repository->paginate(); return $this->response->title(trans('news::tag.names')) ->view('news::tag.index', true) ->data(compact('tags')) ->output(); }
php
public function index(TagRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\News\Repositories\Presenter\TagPresenter::class) ->$function(); } $tags = $this->repository->paginate(); return $this->response->title(trans('news::tag.names')) ->view('news::tag.index', true) ->data(compact('tags')) ->output(); }
[ "public", "function", "index", "(", "TagRequest", "$", "request", ")", "{", "$", "view", "=", "$", "this", "->", "response", "->", "theme", "->", "listView", "(", ")", ";", "if", "(", "$", "this", "->", "response", "->", "typeIs", "(", "'json'", ")",...
Display a list of tag. @return Response
[ "Display", "a", "list", "of", "tag", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Http/Controllers/TagResourceController.php#L38-L55
train
Litecms/News
src/Http/Controllers/TagResourceController.php
TagResourceController.show
public function show(TagRequest $request, Tag $tag) { if ($tag->exists) { $view = 'news::tag.show'; } else { $view = 'news::tag.new'; } return $this->response->title(trans('app.view') . ' ' . trans('news::tag.name')) ->data(compact('tag')) ->view($view, true) ->output(); }
php
public function show(TagRequest $request, Tag $tag) { if ($tag->exists) { $view = 'news::tag.show'; } else { $view = 'news::tag.new'; } return $this->response->title(trans('app.view') . ' ' . trans('news::tag.name')) ->data(compact('tag')) ->view($view, true) ->output(); }
[ "public", "function", "show", "(", "TagRequest", "$", "request", ",", "Tag", "$", "tag", ")", "{", "if", "(", "$", "tag", "->", "exists", ")", "{", "$", "view", "=", "'news::tag.show'", ";", "}", "else", "{", "$", "view", "=", "'news::tag.new'", ";",...
Display tag. @param Request $request @param Model $tag @return Response
[ "Display", "tag", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Http/Controllers/TagResourceController.php#L65-L78
train
Litecms/News
src/Http/Controllers/TagResourceController.php
TagResourceController.delete
public function delete(TagRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('news::tag.name')])) ->status("success") ->code(202) ->url(guard_url('news/tag')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/news/tag')) ->redirect(); } }
php
public function delete(TagRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('news::tag.name')])) ->status("success") ->code(202) ->url(guard_url('news/tag')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/news/tag')) ->redirect(); } }
[ "public", "function", "delete", "(", "TagRequest", "$", "request", ",", "$", "type", ")", "{", "try", "{", "$", "ids", "=", "hashids_decode", "(", "$", "request", "->", "input", "(", "'ids'", ")", ")", ";", "if", "(", "$", "type", "==", "'purge'", ...
Remove multiple tag. @param Model $tag @return Response
[ "Remove", "multiple", "tag", "." ]
7eac12b500e4b2113078144bdb72357b93e45d40
https://github.com/Litecms/News/blob/7eac12b500e4b2113078144bdb72357b93e45d40/src/Http/Controllers/TagResourceController.php#L208-L234
train
thecodingmachine/splash-router
src/TheCodingMachine/Splash/Store/SplashUrlNode.php
SplashUrlNode.walkArray
private function walkArray(array $urlParts, ServerRequestInterface $request, array $parameters, $closestWildcardRoute = null) { $httpMethod = $request->getMethod(); if (isset($this->wildcardCallbacks[$httpMethod])) { $closestWildcardRoute = $this->wildcardCallbacks[$httpMethod]; $closestWildcardRoute->setFilledParameters($parameters); } elseif (isset($this->wildcardCallbacks[''])) { $closestWildcardRoute = $this->wildcardCallbacks['']; $closestWildcardRoute->setFilledParameters($parameters); } if (!empty($urlParts)) { $key = array_shift($urlParts); if (isset($this->children[$key])) { return $this->children[$key]->walkArray($urlParts, $request, $parameters, $closestWildcardRoute); } foreach ($this->parameterizedChildren as $varName => $splashUrlNode) { if (isset($parameters[$varName])) { throw new SplashException("An error occured while looking at the list URL managed in Splash. In a @URL annotation, the parameter '{$parameters[$varName]}' appears twice. That should never happen"); } $newParams = $parameters; $newParams[$varName] = $key; $result = $this->parameterizedChildren[$varName]->walkArray($urlParts, $request, $newParams, $closestWildcardRoute); if ($result !== null) { return $result; } } // If we arrive here, there was no parametrized URL matching our objective return $closestWildcardRoute; } else { if (isset($this->callbacks[$httpMethod])) { $route = $this->callbacks[$httpMethod]; $route->setFilledParameters($parameters); return $route; } elseif (isset($this->callbacks[''])) { $route = $this->callbacks['']; $route->setFilledParameters($parameters); return $route; } else { return $closestWildcardRoute; } } }
php
private function walkArray(array $urlParts, ServerRequestInterface $request, array $parameters, $closestWildcardRoute = null) { $httpMethod = $request->getMethod(); if (isset($this->wildcardCallbacks[$httpMethod])) { $closestWildcardRoute = $this->wildcardCallbacks[$httpMethod]; $closestWildcardRoute->setFilledParameters($parameters); } elseif (isset($this->wildcardCallbacks[''])) { $closestWildcardRoute = $this->wildcardCallbacks['']; $closestWildcardRoute->setFilledParameters($parameters); } if (!empty($urlParts)) { $key = array_shift($urlParts); if (isset($this->children[$key])) { return $this->children[$key]->walkArray($urlParts, $request, $parameters, $closestWildcardRoute); } foreach ($this->parameterizedChildren as $varName => $splashUrlNode) { if (isset($parameters[$varName])) { throw new SplashException("An error occured while looking at the list URL managed in Splash. In a @URL annotation, the parameter '{$parameters[$varName]}' appears twice. That should never happen"); } $newParams = $parameters; $newParams[$varName] = $key; $result = $this->parameterizedChildren[$varName]->walkArray($urlParts, $request, $newParams, $closestWildcardRoute); if ($result !== null) { return $result; } } // If we arrive here, there was no parametrized URL matching our objective return $closestWildcardRoute; } else { if (isset($this->callbacks[$httpMethod])) { $route = $this->callbacks[$httpMethod]; $route->setFilledParameters($parameters); return $route; } elseif (isset($this->callbacks[''])) { $route = $this->callbacks['']; $route->setFilledParameters($parameters); return $route; } else { return $closestWildcardRoute; } } }
[ "private", "function", "walkArray", "(", "array", "$", "urlParts", ",", "ServerRequestInterface", "$", "request", ",", "array", "$", "parameters", ",", "$", "closestWildcardRoute", "=", "null", ")", "{", "$", "httpMethod", "=", "$", "request", "->", "getMethod...
Walks through the nodes to find the callback associated to the URL. @param array $urlParts @param ServerRequestInterface $request @param array $parameters @param SplashRouteInterface $closestWildcardRoute The last wildcard (*) route encountered while navigating the tree. @return SplashRouteInterface @throws SplashException
[ "Walks", "through", "the", "nodes", "to", "find", "the", "callback", "associated", "to", "the", "URL", "." ]
2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7
https://github.com/thecodingmachine/splash-router/blob/2b56ec3d9ffd74a196e44cd6ca0a996caa76d4c7/src/TheCodingMachine/Splash/Store/SplashUrlNode.php#L145-L192
train
salted-herring/salted-cropper
code/Form/CroppableImageField.php
CroppableImageField.CroppableImageForm
public function CroppableImageForm() { $image = $this->getCroppableImageObject(); $action = FormAction::create('doSaveCroppableImage', _t('CroppableImageable.SAVE', 'Save'))->setUseButtonTag('true'); if (!$this->isFrontend) { $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'); } $image = null; if ($CroppableImageID = (int) $this->request->getVar('SaltedCroppableImageID')) { $image = SaltedCroppableImage::get()->byID($CroppableImageID); } $image = $image ? $image : singleton('SaltedCroppableImage'); // $image->setAllowedTypes($this->getAllowedTypes()); $fields = $image->getCMSFields(); $title = $image ? _t('CroppableImageable.EDITIMAGE', 'Edit Image') : _t('CroppableImageable.ADDIMAGE', 'Add Image'); $fields->insertBefore(HeaderField::create('CroppableImageHeader', $title), _t('CroppableImageable.TITLE', 'Title')); $actions = FieldList::create($action); $form = Form::create($this, 'CroppableImageForm', $fields, $actions); if ($image) { $form->loadDataFrom($image); if (!empty($this->folderName)) { $fields->fieldByName('Root.Main.Original')->setFolderName($this->folderName); } $fields->push(HiddenField::create('CropperRatio')->setValue($this->Ratio)); $fields->push(HiddenField::create('ContainerX')->setValue($image->ContainerX)); $fields->push(HiddenField::create('ContainerX')->setValue($image->ContainerX)); $fields->push(HiddenField::create('ContainerY')->setValue($image->ContainerY)); $fields->push(HiddenField::create('ContainerWidth')->setValue($image->ContainerWidth)); $fields->push(HiddenField::create('ContainerHeight')->setValue($image->ContainerHeight)); $fields->push(HiddenField::create('CropperX')->setValue($image->CropperX)); $fields->push(HiddenField::create('CropperY')->setValue($image->CropperY)); $fields->push(HiddenField::create('CropperWidth')->setValue($image->CropperWidth)); $fields->push(HiddenField::create('CropperHeight')->setValue($image->CropperHeight)); } $this->owner->extend('updateLinkForm', $form); return $form; }
php
public function CroppableImageForm() { $image = $this->getCroppableImageObject(); $action = FormAction::create('doSaveCroppableImage', _t('CroppableImageable.SAVE', 'Save'))->setUseButtonTag('true'); if (!$this->isFrontend) { $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'); } $image = null; if ($CroppableImageID = (int) $this->request->getVar('SaltedCroppableImageID')) { $image = SaltedCroppableImage::get()->byID($CroppableImageID); } $image = $image ? $image : singleton('SaltedCroppableImage'); // $image->setAllowedTypes($this->getAllowedTypes()); $fields = $image->getCMSFields(); $title = $image ? _t('CroppableImageable.EDITIMAGE', 'Edit Image') : _t('CroppableImageable.ADDIMAGE', 'Add Image'); $fields->insertBefore(HeaderField::create('CroppableImageHeader', $title), _t('CroppableImageable.TITLE', 'Title')); $actions = FieldList::create($action); $form = Form::create($this, 'CroppableImageForm', $fields, $actions); if ($image) { $form->loadDataFrom($image); if (!empty($this->folderName)) { $fields->fieldByName('Root.Main.Original')->setFolderName($this->folderName); } $fields->push(HiddenField::create('CropperRatio')->setValue($this->Ratio)); $fields->push(HiddenField::create('ContainerX')->setValue($image->ContainerX)); $fields->push(HiddenField::create('ContainerX')->setValue($image->ContainerX)); $fields->push(HiddenField::create('ContainerY')->setValue($image->ContainerY)); $fields->push(HiddenField::create('ContainerWidth')->setValue($image->ContainerWidth)); $fields->push(HiddenField::create('ContainerHeight')->setValue($image->ContainerHeight)); $fields->push(HiddenField::create('CropperX')->setValue($image->CropperX)); $fields->push(HiddenField::create('CropperY')->setValue($image->CropperY)); $fields->push(HiddenField::create('CropperWidth')->setValue($image->CropperWidth)); $fields->push(HiddenField::create('CropperHeight')->setValue($image->CropperHeight)); } $this->owner->extend('updateLinkForm', $form); return $form; }
[ "public", "function", "CroppableImageForm", "(", ")", "{", "$", "image", "=", "$", "this", "->", "getCroppableImageObject", "(", ")", ";", "$", "action", "=", "FormAction", "::", "create", "(", "'doSaveCroppableImage'", ",", "_t", "(", "'CroppableImageable.SAVE'...
The CroppableImageForm for the dialog window @return Form
[ "The", "CroppableImageForm", "for", "the", "dialog", "window" ]
1910cfff2ef7507edf7a262908725d984271de98
https://github.com/salted-herring/salted-cropper/blob/1910cfff2ef7507edf7a262908725d984271de98/code/Form/CroppableImageField.php#L57-L102
train
dreamfactorysoftware/df-script
src/Components/ScriptEngineManager.php
ScriptEngineManager.getConfig
protected function getConfig($name) { if (empty($name)) { throw new InvalidArgumentException("Script Engine 'name' can not be empty."); } $engines = $this->app['config']['df.script']; return array_get($engines, $name, []); }
php
protected function getConfig($name) { if (empty($name)) { throw new InvalidArgumentException("Script Engine 'name' can not be empty."); } $engines = $this->app['config']['df.script']; return array_get($engines, $name, []); }
[ "protected", "function", "getConfig", "(", "$", "name", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Script Engine 'name' can not be empty.\"", ")", ";", "}", "$", "engines", "=", "$", "th...
Get the configuration for a script engine. @param string $name @return array @throws InvalidArgumentException
[ "Get", "the", "configuration", "for", "a", "script", "engine", "." ]
14941f5dada6077286a0d992d6aa8c3d9243d5a0
https://github.com/dreamfactorysoftware/df-script/blob/14941f5dada6077286a0d992d6aa8c3d9243d5a0/src/Components/ScriptEngineManager.php#L122-L131
train
dreamfactorysoftware/df-script
src/Components/ScriptEngineManager.php
ScriptEngineManager.makeEngine
public function makeEngine($type, array $script_config = []) { if (!empty($disable = config('df.scripting.disable'))) { switch (strtolower($disable)) { case 'all': throw new ServiceUnavailableException("All scripting is disabled for this instance."); break; default: if (!empty($type) && (false !== stripos($disable, $type))) { throw new ServiceUnavailableException("Scripting with $type is disabled for this instance."); } break; } } $config = $this->getConfig($type); // Next we will check to see if a type extension has been registered for a engine type // and will call the factory Closure if so, which allows us to have a more generic // resolver for the engine types themselves which applies to all scripting. if (isset($this->types[$type])) { return $this->types[$type]->make(array_merge($config, $script_config)); } throw new InvalidArgumentException("Unsupported script engine type '$type'."); }
php
public function makeEngine($type, array $script_config = []) { if (!empty($disable = config('df.scripting.disable'))) { switch (strtolower($disable)) { case 'all': throw new ServiceUnavailableException("All scripting is disabled for this instance."); break; default: if (!empty($type) && (false !== stripos($disable, $type))) { throw new ServiceUnavailableException("Scripting with $type is disabled for this instance."); } break; } } $config = $this->getConfig($type); // Next we will check to see if a type extension has been registered for a engine type // and will call the factory Closure if so, which allows us to have a more generic // resolver for the engine types themselves which applies to all scripting. if (isset($this->types[$type])) { return $this->types[$type]->make(array_merge($config, $script_config)); } throw new InvalidArgumentException("Unsupported script engine type '$type'."); }
[ "public", "function", "makeEngine", "(", "$", "type", ",", "array", "$", "script_config", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "disable", "=", "config", "(", "'df.scripting.disable'", ")", ")", ")", "{", "switch", "(", "strtolowe...
Make the script engine instance. @param string $type @param array $script_config @return \DreamFactory\Core\Script\Contracts\ScriptingEngineInterface @throws \DreamFactory\Core\Exceptions\ServiceUnavailableException
[ "Make", "the", "script", "engine", "instance", "." ]
14941f5dada6077286a0d992d6aa8c3d9243d5a0
https://github.com/dreamfactorysoftware/df-script/blob/14941f5dada6077286a0d992d6aa8c3d9243d5a0/src/Components/ScriptEngineManager.php#L180-L205
train
dreamfactorysoftware/df-script
src/Engines/Php.php
Php.stripPhpTag
protected static function stripPhpTag($script) { $script = trim($script); $tagOpen = strtolower(substr($script, 0, 5)); $tagClose = substr($script, strlen($script)-2); if('<?php' === $tagOpen){ $script = substr($script, 5); } if('?>' === $tagClose){ $script = substr($script, 0, (strlen($script)-2)); } return $script; }
php
protected static function stripPhpTag($script) { $script = trim($script); $tagOpen = strtolower(substr($script, 0, 5)); $tagClose = substr($script, strlen($script)-2); if('<?php' === $tagOpen){ $script = substr($script, 5); } if('?>' === $tagClose){ $script = substr($script, 0, (strlen($script)-2)); } return $script; }
[ "protected", "static", "function", "stripPhpTag", "(", "$", "script", ")", "{", "$", "script", "=", "trim", "(", "$", "script", ")", ";", "$", "tagOpen", "=", "strtolower", "(", "substr", "(", "$", "script", ",", "0", ",", "5", ")", ")", ";", "$", ...
Removes any <?PHP tags. @param $script @return mixed|string
[ "Removes", "any", "<?PHP", "tags", "." ]
14941f5dada6077286a0d992d6aa8c3d9243d5a0
https://github.com/dreamfactorysoftware/df-script/blob/14941f5dada6077286a0d992d6aa8c3d9243d5a0/src/Engines/Php.php#L66-L80
train
thelia-modules/AttributeType
Model/Base/AttributeTypeAvMetaQuery.php
AttributeTypeAvMetaQuery.filterByAttributeAvId
public function filterByAttributeAvId($attributeAvId = null, $comparison = null) { if (is_array($attributeAvId)) { $useMinMax = false; if (isset($attributeAvId['min'])) { $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAvId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($attributeAvId['max'])) { $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAvId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAvId, $comparison); }
php
public function filterByAttributeAvId($attributeAvId = null, $comparison = null) { if (is_array($attributeAvId)) { $useMinMax = false; if (isset($attributeAvId['min'])) { $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAvId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($attributeAvId['max'])) { $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAvId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAvId, $comparison); }
[ "public", "function", "filterByAttributeAvId", "(", "$", "attributeAvId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "attributeAvId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset"...
Filter the query on the attribute_av_id column Example usage: <code> $query->filterByAttributeAvId(1234); // WHERE attribute_av_id = 1234 $query->filterByAttributeAvId(array(12, 34)); // WHERE attribute_av_id IN (12, 34) $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id > 12 </code> @see filterByAttributeAv() @param mixed $attributeAvId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildAttributeTypeAvMetaQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "attribute_av_id", "column" ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeTypeAvMetaQuery.php#L309-L330
train
thelia-modules/AttributeType
Model/Base/AttributeTypeAvMetaQuery.php
AttributeTypeAvMetaQuery.filterByAttributeAttributeTypeId
public function filterByAttributeAttributeTypeId($attributeAttributeTypeId = null, $comparison = null) { if (is_array($attributeAttributeTypeId)) { $useMinMax = false; if (isset($attributeAttributeTypeId['min'])) { $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_ATTRIBUTE_TYPE_ID, $attributeAttributeTypeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($attributeAttributeTypeId['max'])) { $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_ATTRIBUTE_TYPE_ID, $attributeAttributeTypeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_ATTRIBUTE_TYPE_ID, $attributeAttributeTypeId, $comparison); }
php
public function filterByAttributeAttributeTypeId($attributeAttributeTypeId = null, $comparison = null) { if (is_array($attributeAttributeTypeId)) { $useMinMax = false; if (isset($attributeAttributeTypeId['min'])) { $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_ATTRIBUTE_TYPE_ID, $attributeAttributeTypeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($attributeAttributeTypeId['max'])) { $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_ATTRIBUTE_TYPE_ID, $attributeAttributeTypeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_ATTRIBUTE_TYPE_ID, $attributeAttributeTypeId, $comparison); }
[ "public", "function", "filterByAttributeAttributeTypeId", "(", "$", "attributeAttributeTypeId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "attributeAttributeTypeId", ")", ")", "{", "$", "useMinMax", "=", "false"...
Filter the query on the attribute_attribute_type_id column Example usage: <code> $query->filterByAttributeAttributeTypeId(1234); // WHERE attribute_attribute_type_id = 1234 $query->filterByAttributeAttributeTypeId(array(12, 34)); // WHERE attribute_attribute_type_id IN (12, 34) $query->filterByAttributeAttributeTypeId(array('min' => 12)); // WHERE attribute_attribute_type_id > 12 </code> @see filterByAttributeAttributeType() @param mixed $attributeAttributeTypeId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildAttributeTypeAvMetaQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "attribute_attribute_type_id", "column" ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeTypeAvMetaQuery.php#L352-L373
train
thelia-modules/AttributeType
Model/Base/AttributeTypeAvMetaQuery.php
AttributeTypeAvMetaQuery.filterByAttributeAv
public function filterByAttributeAv($attributeAv, $comparison = null) { if ($attributeAv instanceof \Thelia\Model\AttributeAv) { return $this ->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison); } elseif ($attributeAv instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByAttributeAv() only accepts arguments of type \Thelia\Model\AttributeAv or Collection'); } }
php
public function filterByAttributeAv($attributeAv, $comparison = null) { if ($attributeAv instanceof \Thelia\Model\AttributeAv) { return $this ->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison); } elseif ($attributeAv instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByAttributeAv() only accepts arguments of type \Thelia\Model\AttributeAv or Collection'); } }
[ "public", "function", "filterByAttributeAv", "(", "$", "attributeAv", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "attributeAv", "instanceof", "\\", "Thelia", "\\", "Model", "\\", "AttributeAv", ")", "{", "return", "$", "this", "->", "ad...
Filter the query by a related \Thelia\Model\AttributeAv object @param \Thelia\Model\AttributeAv|ObjectCollection $attributeAv The related object(s) to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildAttributeTypeAvMetaQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "Thelia", "\\", "Model", "\\", "AttributeAv", "object" ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeTypeAvMetaQuery.php#L527-L542
train
thelia-modules/AttributeType
Model/Base/AttributeTypeAvMetaQuery.php
AttributeTypeAvMetaQuery.useAttributeAvQuery
public function useAttributeAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinAttributeAv($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery'); }
php
public function useAttributeAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinAttributeAv($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery'); }
[ "public", "function", "useAttributeAvQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinAttributeAv", "(", "$", "relationAlias", ",", "$", "joinType", ")", "-...
Use the AttributeAv relation AttributeAv object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Thelia\Model\AttributeAvQuery A secondary query class using the current class as primary query
[ "Use", "the", "AttributeAv", "relation", "AttributeAv", "object" ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeTypeAvMetaQuery.php#L587-L592
train
thelia-modules/AttributeType
Model/Base/AttributeTypeAvMetaQuery.php
AttributeTypeAvMetaQuery.useAttributeAttributeTypeQuery
public function useAttributeAttributeTypeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinAttributeAttributeType($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'AttributeAttributeType', '\AttributeType\Model\AttributeAttributeTypeQuery'); }
php
public function useAttributeAttributeTypeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinAttributeAttributeType($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'AttributeAttributeType', '\AttributeType\Model\AttributeAttributeTypeQuery'); }
[ "public", "function", "useAttributeAttributeTypeQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinAttributeAttributeType", "(", "$", "relationAlias", ",", "$", "...
Use the AttributeAttributeType relation AttributeAttributeType object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \AttributeType\Model\AttributeAttributeTypeQuery A secondary query class using the current class as primary query
[ "Use", "the", "AttributeAttributeType", "relation", "AttributeAttributeType", "object" ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeTypeAvMetaQuery.php#L662-L667
train
apioo/psx-framework
src/Http/RequestReader.php
RequestReader.getBody
public function getBody(RequestInterface $request, $readerType = null) { $data = (string) $request->getBody(); $payload = Payload::create($data, $request->getHeader('Content-Type')) ->setRwType($readerType); return $this->processor->parse($payload); }
php
public function getBody(RequestInterface $request, $readerType = null) { $data = (string) $request->getBody(); $payload = Payload::create($data, $request->getHeader('Content-Type')) ->setRwType($readerType); return $this->processor->parse($payload); }
[ "public", "function", "getBody", "(", "RequestInterface", "$", "request", ",", "$", "readerType", "=", "null", ")", "{", "$", "data", "=", "(", "string", ")", "$", "request", "->", "getBody", "(", ")", ";", "$", "payload", "=", "Payload", "::", "create...
Returns the result of the reader for the request @param \PSX\Http\RequestInterface $request @param string $readerType @return mixed
[ "Returns", "the", "result", "of", "the", "reader", "for", "the", "request" ]
e8e550a1a87dae49b615b42a05583395088c1efb
https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Http/RequestReader.php#L58-L65
train
syzygypl/kunstmaan-extra-bundle
src/Imagine/ImgixDataLoader.php
ImgixDataLoader.find
public function find($path) { $imgix = $this->serializer->deserialize($path); if ($imgix) { return file_get_contents($this->source . $imgix); } throw new NotLoadableException; }
php
public function find($path) { $imgix = $this->serializer->deserialize($path); if ($imgix) { return file_get_contents($this->source . $imgix); } throw new NotLoadableException; }
[ "public", "function", "find", "(", "$", "path", ")", "{", "$", "imgix", "=", "$", "this", "->", "serializer", "->", "deserialize", "(", "$", "path", ")", ";", "if", "(", "$", "imgix", ")", "{", "return", "file_get_contents", "(", "$", "this", "->", ...
Retrieve the Image represented by the given path. The path may be a file path on a filesystem, or any unique identifier among the storage engine implemented by this Loader. @param mixed $path @return \Liip\ImagineBundle\Binary\BinaryInterface|string An image binary content
[ "Retrieve", "the", "Image", "represented", "by", "the", "given", "path", "." ]
973d7226c3b19504e89a620cf045efb94e021c62
https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/Imagine/ImgixDataLoader.php#L41-L49
train
yangjian102621/herosphp
src/web/Smtp.php
Smtp.Smtp_Ok
private function Smtp_Ok() { $_res = str_replace("\r\n", '', fgets($this->Smtp_Socket, 512)); if ( ! preg_match('/^[23]/', $_res)) { fputs($this->Smtp_Socket, "QUIT\r\n"); fgets($this->Smtp_Socket, 512); return FALSE; } return TRUE; }
php
private function Smtp_Ok() { $_res = str_replace("\r\n", '', fgets($this->Smtp_Socket, 512)); if ( ! preg_match('/^[23]/', $_res)) { fputs($this->Smtp_Socket, "QUIT\r\n"); fgets($this->Smtp_Socket, 512); return FALSE; } return TRUE; }
[ "private", "function", "Smtp_Ok", "(", ")", "{", "$", "_res", "=", "str_replace", "(", "\"\\r\\n\"", ",", "''", ",", "fgets", "(", "$", "this", "->", "Smtp_Socket", ",", "512", ")", ")", ";", "if", "(", "!", "preg_match", "(", "'/^[23]/'", ",", "$", ...
check the response status code
[ "check", "the", "response", "status", "code" ]
dc0a7b1c73b005098fd627977cd787eb0ab4a4e2
https://github.com/yangjian102621/herosphp/blob/dc0a7b1c73b005098fd627977cd787eb0ab4a4e2/src/web/Smtp.php#L154-L164
train
yangjian102621/herosphp
src/web/Smtp.php
Smtp.Run_Cmd
private function Run_Cmd($_cmd, $_args = '') { if ( $_args != '' ) { if ( $_cmd == '' ) $_cmd = $_args; else $_cmd = $_cmd." ".$_args; //$_cmd == ''?$_cmd = $_args:$_cmd." ".$_args; } fputs($this->Smtp_Socket, $_cmd."\r\n"); return $this->Smtp_Ok(); //return the response code }
php
private function Run_Cmd($_cmd, $_args = '') { if ( $_args != '' ) { if ( $_cmd == '' ) $_cmd = $_args; else $_cmd = $_cmd." ".$_args; //$_cmd == ''?$_cmd = $_args:$_cmd." ".$_args; } fputs($this->Smtp_Socket, $_cmd."\r\n"); return $this->Smtp_Ok(); //return the response code }
[ "private", "function", "Run_Cmd", "(", "$", "_cmd", ",", "$", "_args", "=", "''", ")", "{", "if", "(", "$", "_args", "!=", "''", ")", "{", "if", "(", "$", "_cmd", "==", "''", ")", "$", "_cmd", "=", "$", "_args", ";", "else", "$", "_cmd", "=",...
send a cmd to smtp server
[ "send", "a", "cmd", "to", "smtp", "server" ]
dc0a7b1c73b005098fd627977cd787eb0ab4a4e2
https://github.com/yangjian102621/herosphp/blob/dc0a7b1c73b005098fd627977cd787eb0ab4a4e2/src/web/Smtp.php#L167-L178
train
yangjian102621/herosphp
src/web/Smtp.php
Smtp.Strip_Comment
private function Strip_Comment($_address) { $_pattern = "/\([^()]*\)/"; while ( preg_match($_pattern, $_address) ) $_address = preg_replace($_pattern, '', $_address); return $_address; }
php
private function Strip_Comment($_address) { $_pattern = "/\([^()]*\)/"; while ( preg_match($_pattern, $_address) ) $_address = preg_replace($_pattern, '', $_address); return $_address; }
[ "private", "function", "Strip_Comment", "(", "$", "_address", ")", "{", "$", "_pattern", "=", "\"/\\([^()]*\\)/\"", ";", "while", "(", "preg_match", "(", "$", "_pattern", ",", "$", "_address", ")", ")", "$", "_address", "=", "preg_replace", "(", "$", "_pat...
filter all the comment content
[ "filter", "all", "the", "comment", "content" ]
dc0a7b1c73b005098fd627977cd787eb0ab4a4e2
https://github.com/yangjian102621/herosphp/blob/dc0a7b1c73b005098fd627977cd787eb0ab4a4e2/src/web/Smtp.php#L188-L194
train
QoboLtd/cakephp-menu
src/MenuBuilder/MenuItemContainerTrait.php
MenuItemContainerTrait.getMenuItems
public function getMenuItems(): array { usort($this->menuItems, function ($a, $b) { return $a->getOrder() > $b->getOrder(); }); return $this->menuItems; }
php
public function getMenuItems(): array { usort($this->menuItems, function ($a, $b) { return $a->getOrder() > $b->getOrder(); }); return $this->menuItems; }
[ "public", "function", "getMenuItems", "(", ")", ":", "array", "{", "usort", "(", "$", "this", "->", "menuItems", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "$", "a", "->", "getOrder", "(", ")", ">", "$", "b", "->", "getOrd...
Returns the menu items. @return array List of menu items
[ "Returns", "the", "menu", "items", "." ]
1b987b5a82727e3f19cd0036341ca4f3c276fa8c
https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuItemContainerTrait.php#L39-L46
train
QoboLtd/cakephp-menu
src/MenuBuilder/MenuItemContainerTrait.php
MenuItemContainerTrait.removeMenuItem
public function removeMenuItem(MenuItemInterface $item): void { $key = array_search($item, $this->menuItems, true); if ($key !== false) { unset($this->menuItems[$key]); } }
php
public function removeMenuItem(MenuItemInterface $item): void { $key = array_search($item, $this->menuItems, true); if ($key !== false) { unset($this->menuItems[$key]); } }
[ "public", "function", "removeMenuItem", "(", "MenuItemInterface", "$", "item", ")", ":", "void", "{", "$", "key", "=", "array_search", "(", "$", "item", ",", "$", "this", "->", "menuItems", ",", "true", ")", ";", "if", "(", "$", "key", "!==", "false", ...
Removes the specified menu item from this container. If the provided item is not in this container, this method does nothing. @param MenuItemInterface $item The item to be removed from the menu. @return void
[ "Removes", "the", "specified", "menu", "item", "from", "this", "container", ".", "If", "the", "provided", "item", "is", "not", "in", "this", "container", "this", "method", "does", "nothing", "." ]
1b987b5a82727e3f19cd0036341ca4f3c276fa8c
https://github.com/QoboLtd/cakephp-menu/blob/1b987b5a82727e3f19cd0036341ca4f3c276fa8c/src/MenuBuilder/MenuItemContainerTrait.php#L55-L61
train
bestboysmedialab/language-list
src/Bestboysmedialab/LanguageList/LanguageList.php
LanguageList.getOne
public function getOne($languageCode, $locale = 'en') { $result = $this->has($languageCode, $locale); if (!$result) { throw new LanguageNotFoundException($languageCode); } return $result; }
php
public function getOne($languageCode, $locale = 'en') { $result = $this->has($languageCode, $locale); if (!$result) { throw new LanguageNotFoundException($languageCode); } return $result; }
[ "public", "function", "getOne", "(", "$", "languageCode", ",", "$", "locale", "=", "'en'", ")", "{", "$", "result", "=", "$", "this", "->", "has", "(", "$", "languageCode", ",", "$", "locale", ")", ";", "if", "(", "!", "$", "result", ")", "{", "t...
Returns one language. @param string $languageCode The Language @param string $locale The locale (default: en) @return string @throws LanguageNotFoundException If the language code doesn't match any language.
[ "Returns", "one", "language", "." ]
2b69cc19c618a2b3cf0184fa27ed89cb5c24295e
https://github.com/bestboysmedialab/language-list/blob/2b69cc19c618a2b3cf0184fa27ed89cb5c24295e/src/Bestboysmedialab/LanguageList/LanguageList.php#L76-L87
train
bestboysmedialab/language-list
src/Bestboysmedialab/LanguageList/LanguageList.php
LanguageList.loadData
protected function loadData($locale, $format) { if (!isset($this->dataCache[$locale][$format])) { $file = sprintf('%s/%s/language.'.$format, $this->dataDir, $locale); if (!is_file($file)) { throw new \RuntimeException(sprintf('Unable to load the language data file "%s"', $file)); } $this->dataCache[$locale][$format] = ($format == 'php') ? require $file : file_get_contents($file); } return $this->sortData($locale, $this->dataCache[$locale][$format]); }
php
protected function loadData($locale, $format) { if (!isset($this->dataCache[$locale][$format])) { $file = sprintf('%s/%s/language.'.$format, $this->dataDir, $locale); if (!is_file($file)) { throw new \RuntimeException(sprintf('Unable to load the language data file "%s"', $file)); } $this->dataCache[$locale][$format] = ($format == 'php') ? require $file : file_get_contents($file); } return $this->sortData($locale, $this->dataCache[$locale][$format]); }
[ "protected", "function", "loadData", "(", "$", "locale", ",", "$", "format", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "dataCache", "[", "$", "locale", "]", "[", "$", "format", "]", ")", ")", "{", "$", "file", "=", "sprintf", "("...
A lazy-loader that loads data from a PHP file if it is not stored in memory yet. @param string $locale The locale @param string $format The format (default: php) @return array An array (list) with language
[ "A", "lazy", "-", "loader", "that", "loads", "data", "from", "a", "PHP", "file", "if", "it", "is", "not", "stored", "in", "memory", "yet", "." ]
2b69cc19c618a2b3cf0184fa27ed89cb5c24295e
https://github.com/bestboysmedialab/language-list/blob/2b69cc19c618a2b3cf0184fa27ed89cb5c24295e/src/Bestboysmedialab/LanguageList/LanguageList.php#L120-L136
train
orchestral/model
src/Concerns/Searchable.php
Searchable.scopeSearch
public function scopeSearch(Builder $query, ?string $keyword, ?array $columns = null): Builder { return $this->setupWildcardQueryFilter($query, $keyword ?? '', $columns ?? $this->getSearchableColumns()); }
php
public function scopeSearch(Builder $query, ?string $keyword, ?array $columns = null): Builder { return $this->setupWildcardQueryFilter($query, $keyword ?? '', $columns ?? $this->getSearchableColumns()); }
[ "public", "function", "scopeSearch", "(", "Builder", "$", "query", ",", "?", "string", "$", "keyword", ",", "?", "array", "$", "columns", "=", "null", ")", ":", "Builder", "{", "return", "$", "this", "->", "setupWildcardQueryFilter", "(", "$", "query", "...
Search based on keyword. @param \Illuminate\Database\Eloquent\Builder $query @param string|null. $keyword @param array|null $columns @return \Illuminate\Database\Eloquent\Builder
[ "Search", "based", "on", "keyword", "." ]
59eb60a022afb3caa0ac5824d6faac85f3255c0d
https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/Searchable.php#L21-L24
train
kenarkose/Transit
src/File/HasMetadata.php
HasMetadata.getMetadata
public function getMetadata($key = null) { if (is_null($this->metadataCache)) { $this->metadataCache = json_decode($this->metadata, true); } if (is_null($key)) { return $this->metadataCache; } if (isset($this->metadataCache[$key])) { return $this->metadataCache[$key]; } return null; }
php
public function getMetadata($key = null) { if (is_null($this->metadataCache)) { $this->metadataCache = json_decode($this->metadata, true); } if (is_null($key)) { return $this->metadataCache; } if (isset($this->metadataCache[$key])) { return $this->metadataCache[$key]; } return null; }
[ "public", "function", "getMetadata", "(", "$", "key", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "metadataCache", ")", ")", "{", "$", "this", "->", "metadataCache", "=", "json_decode", "(", "$", "this", "->", "metadata", ",", ...
Getter for the metadata @param string $key @return mixed
[ "Getter", "for", "the", "metadata" ]
de8e1cd23d0f5814a5d3a6c1795d6f414046adbb
https://github.com/kenarkose/Transit/blob/de8e1cd23d0f5814a5d3a6c1795d6f414046adbb/src/File/HasMetadata.php#L33-L51
train
kenarkose/Transit
src/File/HasMetadata.php
HasMetadata.setMetadata
public function setMetadata($key, $value) { if (is_null($this->metadataCache)) { $this->metadataCache = []; } $this->metadataCache[$key] = $value; }
php
public function setMetadata($key, $value) { if (is_null($this->metadataCache)) { $this->metadataCache = []; } $this->metadataCache[$key] = $value; }
[ "public", "function", "setMetadata", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "metadataCache", ")", ")", "{", "$", "this", "->", "metadataCache", "=", "[", "]", ";", "}", "$", "this", "->", "metada...
Setter for metadata @param string $key @param mixed $value
[ "Setter", "for", "metadata" ]
de8e1cd23d0f5814a5d3a6c1795d6f414046adbb
https://github.com/kenarkose/Transit/blob/de8e1cd23d0f5814a5d3a6c1795d6f414046adbb/src/File/HasMetadata.php#L59-L67
train
usemarkup/contentful
src/ResourceBuilder.php
ResourceBuilder.isArrayResourceData
private function isArrayResourceData($data) { if (!is_array($data) || empty($data)) { return false; } foreach ($data as $datum) { if (!$this->isResourceData($datum)) { return false; } } return true; }
php
private function isArrayResourceData($data) { if (!is_array($data) || empty($data)) { return false; } foreach ($data as $datum) { if (!$this->isResourceData($datum)) { return false; } } return true; }
[ "private", "function", "isArrayResourceData", "(", "$", "data", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", "||", "empty", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "data", "as", "$", "datum...
Tests whether the provided data represents an array of resource data, or an array of links to resources. @param mixed $data @return bool
[ "Tests", "whether", "the", "provided", "data", "represents", "an", "array", "of", "resource", "data", "or", "an", "array", "of", "links", "to", "resources", "." ]
ac5902bf891c52fd00d349bd5aae78d516dcd601
https://github.com/usemarkup/contentful/blob/ac5902bf891c52fd00d349bd5aae78d516dcd601/src/ResourceBuilder.php#L334-L346
train
TZK-/TaigaPHP
src/RestClient.php
RestClient.request
public function request($method, $url, array $data = []) { return $this->request->send($this->baseUrl.'/'.$url, $method, $data); }
php
public function request($method, $url, array $data = []) { return $this->request->send($this->baseUrl.'/'.$url, $method, $data); }
[ "public", "function", "request", "(", "$", "method", ",", "$", "url", ",", "array", "$", "data", "=", "[", "]", ")", "{", "return", "$", "this", "->", "request", "->", "send", "(", "$", "this", "->", "baseUrl", ".", "'/'", ".", "$", "url", ",", ...
Send a HTTP request to a given URL with given data. @param string $method @param string $url @param array $data @return mixed
[ "Send", "a", "HTTP", "request", "to", "a", "given", "URL", "with", "given", "data", "." ]
b5d1ec9de999c1f04d33c8908cb41d77ced54186
https://github.com/TZK-/TaigaPHP/blob/b5d1ec9de999c1f04d33c8908cb41d77ced54186/src/RestClient.php#L53-L56
train
crysalead/chaos-orm
src/Document.php
Document.set
public function set($name, $data = []) { if (!is_array($name) || (isset($name[0]) && is_string($name[0]))) { $this->setAt($name, $data); return $this; } $data = $name; if (!is_array($data)) { throw new ORMException('Invalid bulk data for a document.'); } foreach ($data as $name => $value) { $this->setAt($name, $value); } return $this; }
php
public function set($name, $data = []) { if (!is_array($name) || (isset($name[0]) && is_string($name[0]))) { $this->setAt($name, $data); return $this; } $data = $name; if (!is_array($data)) { throw new ORMException('Invalid bulk data for a document.'); } foreach ($data as $name => $value) { $this->setAt($name, $value); } return $this; }
[ "public", "function", "set", "(", "$", "name", ",", "$", "data", "=", "[", "]", ")", "{", "if", "(", "!", "is_array", "(", "$", "name", ")", "||", "(", "isset", "(", "$", "name", "[", "0", "]", ")", "&&", "is_string", "(", "$", "name", "[", ...
Sets one or several properties. @param mixed $name A field name or an associative array of fields and values. @param array $data An associative array of fields and values or an options array. @return object Returns `$this`.
[ "Sets", "one", "or", "several", "properties", "." ]
835f891311bb30c9178910df7223d1cdfd269560
https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Document.php#L547-L561
train
crysalead/chaos-orm
src/Document.php
Document.hierarchy
public function hierarchy($prefix = '', &$ignore = [], $index = false) { $hash = spl_object_hash($this); if (isset($ignore[$hash])) { return false; } $ignore[$hash] = true; $tree = array_fill_keys($this->schema()->relations(), true); $result = []; $habtm = []; foreach ($tree as $field => $value) { $rel = $this->schema()->relation($field); if ($rel->type() === 'hasManyThrough') { $habtm[$field] = $rel; continue; } if (!isset($this->{$field})) { continue; } $entity = $this->__get($field); // Too Many Magic Kill The Magic. if ($entity) { $path = $prefix ? $prefix . '.' . $field : $field; if ($children = $entity->hierarchy($path, $ignore, true)) { $result += $children; } elseif ($children !== false) { $result[$path] = $path; } } } foreach ($habtm as $field => $rel) { $using = $rel->through() . '.' . $rel->using(); $path = $prefix ? $prefix . '.' . $using : $using; foreach ($result as $key) { if (strpos($key, $path) === 0) { $path = $prefix ? $prefix . '.' . $field : $field; $result[$path] = $path; } } } return $index ? $result : array_values($result); }
php
public function hierarchy($prefix = '', &$ignore = [], $index = false) { $hash = spl_object_hash($this); if (isset($ignore[$hash])) { return false; } $ignore[$hash] = true; $tree = array_fill_keys($this->schema()->relations(), true); $result = []; $habtm = []; foreach ($tree as $field => $value) { $rel = $this->schema()->relation($field); if ($rel->type() === 'hasManyThrough') { $habtm[$field] = $rel; continue; } if (!isset($this->{$field})) { continue; } $entity = $this->__get($field); // Too Many Magic Kill The Magic. if ($entity) { $path = $prefix ? $prefix . '.' . $field : $field; if ($children = $entity->hierarchy($path, $ignore, true)) { $result += $children; } elseif ($children !== false) { $result[$path] = $path; } } } foreach ($habtm as $field => $rel) { $using = $rel->through() . '.' . $rel->using(); $path = $prefix ? $prefix . '.' . $using : $using; foreach ($result as $key) { if (strpos($key, $path) === 0) { $path = $prefix ? $prefix . '.' . $field : $field; $result[$path] = $path; } } } return $index ? $result : array_values($result); }
[ "public", "function", "hierarchy", "(", "$", "prefix", "=", "''", ",", "&", "$", "ignore", "=", "[", "]", ",", "$", "index", "=", "false", ")", "{", "$", "hash", "=", "spl_object_hash", "(", "$", "this", ")", ";", "if", "(", "isset", "(", "$", ...
Returns all included relations accessible through this entity. @param string $prefix The parent relation path. @param array $ignore The already processed entities to ignore (address circular dependencies). @param boolean $index Returns an indexed array or not. @return array|false Returns an array of relation names or `false` when a circular loop is reached.
[ "Returns", "all", "included", "relations", "accessible", "through", "this", "entity", "." ]
835f891311bb30c9178910df7223d1cdfd269560
https://github.com/crysalead/chaos-orm/blob/835f891311bb30c9178910df7223d1cdfd269560/src/Document.php#L1077-L1121
train
dreamfactorysoftware/df-script
src/Components/BaseEngineAdapter.php
BaseEngineAdapter.loadScript
public static function loadScript($name, $path = null, $returnContents = true) { // Already read, return script if (null !== ($script = array_get(static::$libraries, $name))) { return $returnContents ? file_get_contents($script) : $script; } $script = ltrim($script, ' /'); // Spin through paths and look for the script foreach (static::$libraryPaths as $libPath) { $check = $libPath . '/' . $script; if (is_file($check) && is_readable($check)) { array_set(static::$libraries, $name, $check); return $returnContents ? file_get_contents($check) : $check; } } if ($path) { if (is_file($path) && is_readable($path)) { array_set(static::$libraries, $name, $path); return $returnContents ? file_get_contents($path) : $path; } } return false; }
php
public static function loadScript($name, $path = null, $returnContents = true) { // Already read, return script if (null !== ($script = array_get(static::$libraries, $name))) { return $returnContents ? file_get_contents($script) : $script; } $script = ltrim($script, ' /'); // Spin through paths and look for the script foreach (static::$libraryPaths as $libPath) { $check = $libPath . '/' . $script; if (is_file($check) && is_readable($check)) { array_set(static::$libraries, $name, $check); return $returnContents ? file_get_contents($check) : $check; } } if ($path) { if (is_file($path) && is_readable($path)) { array_set(static::$libraries, $name, $path); return $returnContents ? file_get_contents($path) : $path; } } return false; }
[ "public", "static", "function", "loadScript", "(", "$", "name", ",", "$", "path", "=", "null", ",", "$", "returnContents", "=", "true", ")", "{", "// Already read, return script", "if", "(", "null", "!==", "(", "$", "script", "=", "array_get", "(", "stati...
Look through the known paths for a particular script. Returns full path to script file. @param string $name The name/id of the script @param string $path The name of the script @param bool $returnContents If true, the contents of the file, if found, are returned. Otherwise, the only the path is returned @return string
[ "Look", "through", "the", "known", "paths", "for", "a", "particular", "script", ".", "Returns", "full", "path", "to", "script", "file", "." ]
14941f5dada6077286a0d992d6aa8c3d9243d5a0
https://github.com/dreamfactorysoftware/df-script/blob/14941f5dada6077286a0d992d6aa8c3d9243d5a0/src/Components/BaseEngineAdapter.php#L166-L195
train
dreamfactorysoftware/df-script
src/Components/BaseEngineAdapter.php
BaseEngineAdapter.getLibrary
protected static function getLibrary($id, $file = null) { if (null !== $file || array_key_exists($id, static::$libraries)) { $file = $file ?: static::$libraries[$id]; // Find the library foreach (static::$libraryPaths as $name => $path) { $filePath = $path . DIRECTORY_SEPARATOR . $file; if (file_exists($filePath) && is_readable($filePath)) { return file_get_contents($filePath, 'r'); } } } throw new \InvalidArgumentException('The library id "' . $id . '" could not be located.'); }
php
protected static function getLibrary($id, $file = null) { if (null !== $file || array_key_exists($id, static::$libraries)) { $file = $file ?: static::$libraries[$id]; // Find the library foreach (static::$libraryPaths as $name => $path) { $filePath = $path . DIRECTORY_SEPARATOR . $file; if (file_exists($filePath) && is_readable($filePath)) { return file_get_contents($filePath, 'r'); } } } throw new \InvalidArgumentException('The library id "' . $id . '" could not be located.'); }
[ "protected", "static", "function", "getLibrary", "(", "$", "id", ",", "$", "file", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "file", "||", "array_key_exists", "(", "$", "id", ",", "static", "::", "$", "libraries", ")", ")", "{", "$", "f...
Locates and loads a library returning the contents @param string $id The id of the library (i.e. "lodash", "underscore", etc.) @param string $file The relative path/name of the library file @return string
[ "Locates", "and", "loads", "a", "library", "returning", "the", "contents" ]
14941f5dada6077286a0d992d6aa8c3d9243d5a0
https://github.com/dreamfactorysoftware/df-script/blob/14941f5dada6077286a0d992d6aa8c3d9243d5a0/src/Components/BaseEngineAdapter.php#L286-L302
train
dreamfactorysoftware/df-script
src/Components/BaseEngineAdapter.php
BaseEngineAdapter.makeJsonSafe
protected function makeJsonSafe($data, $base64 = true) { if (is_array($data)) { foreach ($data as $key => $value) { $data[$key] = $this->makeJsonSafe($value, $base64); } } if (!$this->isJsonEncodable($data)) { if (true === $base64) { return 'base64:' . base64_encode($data); } else { return '--non-parsable-data--'; } } return $data; }
php
protected function makeJsonSafe($data, $base64 = true) { if (is_array($data)) { foreach ($data as $key => $value) { $data[$key] = $this->makeJsonSafe($value, $base64); } } if (!$this->isJsonEncodable($data)) { if (true === $base64) { return 'base64:' . base64_encode($data); } else { return '--non-parsable-data--'; } } return $data; }
[ "protected", "function", "makeJsonSafe", "(", "$", "data", ",", "$", "base64", "=", "true", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data"...
Base64 encodes any string or array of strings that cannot be JSON encoded. @param string|array $data @param bool $base64 @return array|string
[ "Base64", "encodes", "any", "string", "or", "array", "of", "strings", "that", "cannot", "be", "JSON", "encoded", "." ]
14941f5dada6077286a0d992d6aa8c3d9243d5a0
https://github.com/dreamfactorysoftware/df-script/blob/14941f5dada6077286a0d992d6aa8c3d9243d5a0/src/Components/BaseEngineAdapter.php#L562-L578
train
dreamfactorysoftware/df-script
src/Components/BaseEngineAdapter.php
BaseEngineAdapter.isJsonEncodable
protected function isJsonEncodable($data) { if (!is_array($data)) { $data = [$data]; } $json = json_encode($data, JSON_UNESCAPED_SLASHES); if ($json === false) { return false; } return true; }
php
protected function isJsonEncodable($data) { if (!is_array($data)) { $data = [$data]; } $json = json_encode($data, JSON_UNESCAPED_SLASHES); if ($json === false) { return false; } return true; }
[ "protected", "function", "isJsonEncodable", "(", "$", "data", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "[", "$", "data", "]", ";", "}", "$", "json", "=", "json_encode", "(", "$", "data", ",", "JSON_...
Checks to see if a string can be json encoded. @param string $data @return bool
[ "Checks", "to", "see", "if", "a", "string", "can", "be", "json", "encoded", "." ]
14941f5dada6077286a0d992d6aa8c3d9243d5a0
https://github.com/dreamfactorysoftware/df-script/blob/14941f5dada6077286a0d992d6aa8c3d9243d5a0/src/Components/BaseEngineAdapter.php#L587-L599
train
a2design-inc/Mandrill-CakePHP-plugin
Lib/Network/Email/MandrillTransport.php
MandrillTransport._exec
private function _exec($params) { $params['key'] = $this->_config['api_key']; $params = json_encode($params); $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, 'Mandrill-PHP/1.0.52'); curl_setopt($ch, CURLOPT_POST, true); if (!ini_get('safe_mode') && !ini_get('open_basedir')){ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); } curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 600); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send.json'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_VERBOSE, false); $response_body = curl_exec($ch); if(curl_error($ch)) { throw new Exception("API call to messages/send failed: " . curl_error($ch)); } $result = json_decode($response_body, true); if($result === null) throw new Exception('We were unable to decode the JSON response from the Mandrill API: ' . $response_body); return $result; }
php
private function _exec($params) { $params['key'] = $this->_config['api_key']; $params = json_encode($params); $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, 'Mandrill-PHP/1.0.52'); curl_setopt($ch, CURLOPT_POST, true); if (!ini_get('safe_mode') && !ini_get('open_basedir')){ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); } curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 600); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send.json'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_VERBOSE, false); $response_body = curl_exec($ch); if(curl_error($ch)) { throw new Exception("API call to messages/send failed: " . curl_error($ch)); } $result = json_decode($response_body, true); if($result === null) throw new Exception('We were unable to decode the JSON response from the Mandrill API: ' . $response_body); return $result; }
[ "private", "function", "_exec", "(", "$", "params", ")", "{", "$", "params", "[", "'key'", "]", "=", "$", "this", "->", "_config", "[", "'api_key'", "]", ";", "$", "params", "=", "json_encode", "(", "$", "params", ")", ";", "$", "ch", "=", "curl_in...
Sending API request @param array $params @return array @throws Exception
[ "Sending", "API", "request" ]
cb8a0ecd8f138fef4c99820a8610631a5fb38cc1
https://github.com/a2design-inc/Mandrill-CakePHP-plugin/blob/cb8a0ecd8f138fef4c99820a8610631a5fb38cc1/Lib/Network/Email/MandrillTransport.php#L138-L168
train
orchestral/model
src/Observer/Role.php
Role.saving
public function saving(Eloquent $model): void { $keyword = Keyword::make($model->getAttribute('name')); if ($keyword->searchIn(['guest']) !== false) { throw new InvalidArgumentException("Role [{$keyword->getValue()}] is not allowed to be used!"); } }
php
public function saving(Eloquent $model): void { $keyword = Keyword::make($model->getAttribute('name')); if ($keyword->searchIn(['guest']) !== false) { throw new InvalidArgumentException("Role [{$keyword->getValue()}] is not allowed to be used!"); } }
[ "public", "function", "saving", "(", "Eloquent", "$", "model", ")", ":", "void", "{", "$", "keyword", "=", "Keyword", "::", "make", "(", "$", "model", "->", "getAttribute", "(", "'name'", ")", ")", ";", "if", "(", "$", "keyword", "->", "searchIn", "(...
On saving observer. @param \Orchestra\Model\Role $model @return void
[ "On", "saving", "observer", "." ]
59eb60a022afb3caa0ac5824d6faac85f3255c0d
https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Observer/Role.php#L48-L55
train
orchestral/model
src/Observer/Role.php
Role.isRestoringModel
protected function isRestoringModel(Eloquent $model): bool { if (! $model->isSoftDeleting()) { return false; } $deleted = $model->getDeletedAtColumn(); return \is_null($model->getAttribute($deleted)) && ! \is_null($model->getOriginal($deleted)); }
php
protected function isRestoringModel(Eloquent $model): bool { if (! $model->isSoftDeleting()) { return false; } $deleted = $model->getDeletedAtColumn(); return \is_null($model->getAttribute($deleted)) && ! \is_null($model->getOriginal($deleted)); }
[ "protected", "function", "isRestoringModel", "(", "Eloquent", "$", "model", ")", ":", "bool", "{", "if", "(", "!", "$", "model", "->", "isSoftDeleting", "(", ")", ")", "{", "return", "false", ";", "}", "$", "deleted", "=", "$", "model", "->", "getDelet...
Is restoring model. @param \Orchestra\Model\Role $model @return bool
[ "Is", "restoring", "model", "." ]
59eb60a022afb3caa0ac5824d6faac85f3255c0d
https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Observer/Role.php#L95-L104
train
kenarkose/Transit
src/Provider/TransitServiceProvider.php
TransitServiceProvider.register
public function register() { $this->registerUploadPath(); $this->registerAssetPath(); $this->registerUploadService(); $this->registerDownloadService(); $this->registerCommands(); }
php
public function register() { $this->registerUploadPath(); $this->registerAssetPath(); $this->registerUploadService(); $this->registerDownloadService(); $this->registerCommands(); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "registerUploadPath", "(", ")", ";", "$", "this", "->", "registerAssetPath", "(", ")", ";", "$", "this", "->", "registerUploadService", "(", ")", ";", "$", "this", "->", "registerDownloadS...
Registers the service provider
[ "Registers", "the", "service", "provider" ]
de8e1cd23d0f5814a5d3a6c1795d6f414046adbb
https://github.com/kenarkose/Transit/blob/de8e1cd23d0f5814a5d3a6c1795d6f414046adbb/src/Provider/TransitServiceProvider.php#L37-L46
train
AltThree/Validator
src/ValidatingObserver.php
ValidatingObserver.validate
protected function validate(Model $model) { $attributes = $model->getAttributes(); $messages = isset($model->validationMessages) ? $model->validationMessages : []; $validator = $this->factory->make($attributes, $model->rules, $messages); if ($validator->fails()) { throw new ValidationException($validator->getMessageBag()); } if (method_exists($model, 'validate')) { $model->validate(); } }
php
protected function validate(Model $model) { $attributes = $model->getAttributes(); $messages = isset($model->validationMessages) ? $model->validationMessages : []; $validator = $this->factory->make($attributes, $model->rules, $messages); if ($validator->fails()) { throw new ValidationException($validator->getMessageBag()); } if (method_exists($model, 'validate')) { $model->validate(); } }
[ "protected", "function", "validate", "(", "Model", "$", "model", ")", "{", "$", "attributes", "=", "$", "model", "->", "getAttributes", "(", ")", ";", "$", "messages", "=", "isset", "(", "$", "model", "->", "validationMessages", ")", "?", "$", "model", ...
Validate the given model. @param \Illuminate\Database\Eloquent\Model $model @throws \AltThree\Validator\ValidationException @return void
[ "Validate", "the", "given", "model", "." ]
fae25a5423417dc31e637dc64774480fc7f0ff6b
https://github.com/AltThree/Validator/blob/fae25a5423417dc31e637dc64774480fc7f0ff6b/src/ValidatingObserver.php#L82-L97
train
orchestral/model
src/Concerns/AdvancedSearchable.php
AdvancedSearchable.resolveSearchKeywords
protected function resolveSearchKeywords(string $keyword): array { $basic = []; $advanced = []; $tags = \array_map(function ($value) { [$tag, ] = \explode(':', $value, 2); return "{$tag}:"; }, \array_keys($this->getSearchableRules())); if (\preg_match_all('/([\w]+:\"[\w\s]*\"|[\w]+:[\w\S]+|[\w\S]+)\s?/', $keyword, $keywords)) { foreach ($keywords[1] as $index => $keyword) { if (! Str::startsWith($keyword, $tags)) { \array_push($basic, $keyword); } else { \array_push($advanced, $keyword); } } } return [ 'basic' => \implode(' ', $basic), 'advanced' => $advanced, ]; }
php
protected function resolveSearchKeywords(string $keyword): array { $basic = []; $advanced = []; $tags = \array_map(function ($value) { [$tag, ] = \explode(':', $value, 2); return "{$tag}:"; }, \array_keys($this->getSearchableRules())); if (\preg_match_all('/([\w]+:\"[\w\s]*\"|[\w]+:[\w\S]+|[\w\S]+)\s?/', $keyword, $keywords)) { foreach ($keywords[1] as $index => $keyword) { if (! Str::startsWith($keyword, $tags)) { \array_push($basic, $keyword); } else { \array_push($advanced, $keyword); } } } return [ 'basic' => \implode(' ', $basic), 'advanced' => $advanced, ]; }
[ "protected", "function", "resolveSearchKeywords", "(", "string", "$", "keyword", ")", ":", "array", "{", "$", "basic", "=", "[", "]", ";", "$", "advanced", "=", "[", "]", ";", "$", "tags", "=", "\\", "array_map", "(", "function", "(", "$", "value", "...
Resolve search keywords. @param string $keyword @return array
[ "Resolve", "search", "keywords", "." ]
59eb60a022afb3caa0ac5824d6faac85f3255c0d
https://github.com/orchestral/model/blob/59eb60a022afb3caa0ac5824d6faac85f3255c0d/src/Concerns/AdvancedSearchable.php#L75-L100
train
wikiworldorder/survloop
src/Controllers/Tree/TreeNodeSurv.php
TreeNodeSurv.loadNodeCache
public function loadNodeCache($nID = -3, $nCache = []) { if (sizeof($nCache) > 0) { if (isset($nCache["pID"])) { $this->parentID = $nCache["pID"]; } if (isset($nCache["pOrd"])) { $this->parentOrd = $nCache["pOrd"]; } if (isset($nCache["opts"])) { $this->nodeOpts = $nCache["opts"]; } if (isset($nCache["type"])) { $this->nodeType = $nCache["type"]; } if (isset($nCache["branch"])) { $this->dataBranch = $nCache["branch"]; } if (isset($nCache["store"])) { $this->dataStore = $nCache["store"]; } if (isset($nCache["set"])) { $this->responseSet = $nCache["set"]; } if (isset($nCache["def"])) { $this->defaultVal = $nCache["def"]; } } return true; }
php
public function loadNodeCache($nID = -3, $nCache = []) { if (sizeof($nCache) > 0) { if (isset($nCache["pID"])) { $this->parentID = $nCache["pID"]; } if (isset($nCache["pOrd"])) { $this->parentOrd = $nCache["pOrd"]; } if (isset($nCache["opts"])) { $this->nodeOpts = $nCache["opts"]; } if (isset($nCache["type"])) { $this->nodeType = $nCache["type"]; } if (isset($nCache["branch"])) { $this->dataBranch = $nCache["branch"]; } if (isset($nCache["store"])) { $this->dataStore = $nCache["store"]; } if (isset($nCache["set"])) { $this->responseSet = $nCache["set"]; } if (isset($nCache["def"])) { $this->defaultVal = $nCache["def"]; } } return true; }
[ "public", "function", "loadNodeCache", "(", "$", "nID", "=", "-", "3", ",", "$", "nCache", "=", "[", "]", ")", "{", "if", "(", "sizeof", "(", "$", "nCache", ")", ">", "0", ")", "{", "if", "(", "isset", "(", "$", "nCache", "[", "\"pID\"", "]", ...
maybe initialize this way to lighten the tree's load?...
[ "maybe", "initialize", "this", "way", "to", "lighten", "the", "tree", "s", "load?", "..." ]
7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a
https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Tree/TreeNodeSurv.php#L99-L128
train
wikiworldorder/survloop
src/Controllers/Globals/GlobalsTables.php
GlobalsTables.getTblFldTypes
public function getTblFldTypes($tbl) { $flds = []; if (isset($this->fldTypes[$tbl]) && sizeof($this->fldTypes[$tbl]) > 0) { $flds = $this->fldTypes[$tbl]; } else { $tblRow = SLTables::where('TblName', $tbl) ->first(); if ($tblRow) { $chk = SLFields::where('FldTable', $tblRow->TblID) ->orderBy('FldOrd', 'asc') ->get(); if ($chk->isNotEmpty()) { foreach ($chk as $fldRow) { $flds[$tblRow->TblAbbr . $fldRow->FldName] = $fldRow->FldType; } } } } return $flds; }
php
public function getTblFldTypes($tbl) { $flds = []; if (isset($this->fldTypes[$tbl]) && sizeof($this->fldTypes[$tbl]) > 0) { $flds = $this->fldTypes[$tbl]; } else { $tblRow = SLTables::where('TblName', $tbl) ->first(); if ($tblRow) { $chk = SLFields::where('FldTable', $tblRow->TblID) ->orderBy('FldOrd', 'asc') ->get(); if ($chk->isNotEmpty()) { foreach ($chk as $fldRow) { $flds[$tblRow->TblAbbr . $fldRow->FldName] = $fldRow->FldType; } } } } return $flds; }
[ "public", "function", "getTblFldTypes", "(", "$", "tbl", ")", "{", "$", "flds", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "fldTypes", "[", "$", "tbl", "]", ")", "&&", "sizeof", "(", "$", "this", "->", "fldTypes", "[", "$", ...
not limited to loaded database
[ "not", "limited", "to", "loaded", "database" ]
7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a
https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Globals/GlobalsTables.php#L511-L531
train
wikiworldorder/survloop
src/Controllers/SurvLoopController.php
SurvLoopController.checkSystemInit
public function checkSystemInit() { if (!session()->has('chkSysInit') || $GLOBALS["SL"]->REQ->has('refresh')) { $sysChk = User::select('id') ->get(); if ($sysChk->isEmpty()) { return $this->freshUser($GLOBALS["SL"]->REQ); } $sysChk = SLDatabases::select('DbID') ->where('DbUser', '>', 0) ->get(); if ($sysChk->isEmpty()) { return $this->redir('/fresh/database', true); } if (!$this->chkHasTreeOne()) { return $this->redir('/fresh/survey', true); } $survInst = new SurvLoopInstaller; $survInst->checkSysInit(); session()->put('chkSysInit', 1); } return ''; }
php
public function checkSystemInit() { if (!session()->has('chkSysInit') || $GLOBALS["SL"]->REQ->has('refresh')) { $sysChk = User::select('id') ->get(); if ($sysChk->isEmpty()) { return $this->freshUser($GLOBALS["SL"]->REQ); } $sysChk = SLDatabases::select('DbID') ->where('DbUser', '>', 0) ->get(); if ($sysChk->isEmpty()) { return $this->redir('/fresh/database', true); } if (!$this->chkHasTreeOne()) { return $this->redir('/fresh/survey', true); } $survInst = new SurvLoopInstaller; $survInst->checkSysInit(); session()->put('chkSysInit', 1); } return ''; }
[ "public", "function", "checkSystemInit", "(", ")", "{", "if", "(", "!", "session", "(", ")", "->", "has", "(", "'chkSysInit'", ")", "||", "$", "GLOBALS", "[", "\"SL\"", "]", "->", "REQ", "->", "has", "(", "'refresh'", ")", ")", "{", "$", "sysChk", ...
Check For Basic System Setup First
[ "Check", "For", "Basic", "System", "Setup", "First" ]
7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a
https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/SurvLoopController.php#L237-L259
train
wikiworldorder/survloop
src/Controllers/SurvLoopController.php
SurvLoopController.isPageFirstTime
protected function isPageFirstTime($currPage = '') { if (trim($currPage) == '') { $currPage = $this->v["currPage"][0]; } $chk = SLUsersActivity::where('UserActUser', Auth::user()->id) ->where('UserActCurrPage', 'LIKE', '%'.$currPage) ->get(); if ($chk->isNotEmpty()) { return false; } return true; }
php
protected function isPageFirstTime($currPage = '') { if (trim($currPage) == '') { $currPage = $this->v["currPage"][0]; } $chk = SLUsersActivity::where('UserActUser', Auth::user()->id) ->where('UserActCurrPage', 'LIKE', '%'.$currPage) ->get(); if ($chk->isNotEmpty()) { return false; } return true; }
[ "protected", "function", "isPageFirstTime", "(", "$", "currPage", "=", "''", ")", "{", "if", "(", "trim", "(", "$", "currPage", ")", "==", "''", ")", "{", "$", "currPage", "=", "$", "this", "->", "v", "[", "\"currPage\"", "]", "[", "0", "]", ";", ...
Is this the first time this user has visited the current page?
[ "Is", "this", "the", "first", "time", "this", "user", "has", "visited", "the", "current", "page?" ]
7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a
https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/SurvLoopController.php#L336-L348
train
wikiworldorder/survloop
src/Controllers/SurvLoopController.php
SurvLoopController.doublecheckSurvTables
protected function doublecheckSurvTables() { if (!session()->has('doublecheckSurvTables')) { $chks = []; $chks[] = "ALTER TABLE `SL_Tree` CHANGE `TreeRootURL` `TreeSlug` VARCHAR(255)"; $chks[] = "ALTER TABLE `SL_Tree` ADD `TreeOpts` INT(11) DEFAULT 1 AFTER `TreeCoreTable`"; $chks[] = "ALTER TABLE `SL_DesignTweaks` ADD `TweakUniqueStr` INT(11) DEFAULT NULL AFTER `TweakVersionAB`"; $chks[] = "ALTER TABLE `SL_DesignTweaks` ADD `TweakIsMobile` VARCHAR(50) DEFAULT NULL AFTER " . "`TweakUniqueStr`"; ob_start(); try { foreach ($chks as $chk) { DB::select($chk); } } catch (QueryException $e) { } ob_end_clean(); session()->put('doublecheckSurvTables', 1); } return true; }
php
protected function doublecheckSurvTables() { if (!session()->has('doublecheckSurvTables')) { $chks = []; $chks[] = "ALTER TABLE `SL_Tree` CHANGE `TreeRootURL` `TreeSlug` VARCHAR(255)"; $chks[] = "ALTER TABLE `SL_Tree` ADD `TreeOpts` INT(11) DEFAULT 1 AFTER `TreeCoreTable`"; $chks[] = "ALTER TABLE `SL_DesignTweaks` ADD `TweakUniqueStr` INT(11) DEFAULT NULL AFTER `TweakVersionAB`"; $chks[] = "ALTER TABLE `SL_DesignTweaks` ADD `TweakIsMobile` VARCHAR(50) DEFAULT NULL AFTER " . "`TweakUniqueStr`"; ob_start(); try { foreach ($chks as $chk) { DB::select($chk); } } catch (QueryException $e) { } ob_end_clean(); session()->put('doublecheckSurvTables', 1); } return true; }
[ "protected", "function", "doublecheckSurvTables", "(", ")", "{", "if", "(", "!", "session", "(", ")", "->", "has", "(", "'doublecheckSurvTables'", ")", ")", "{", "$", "chks", "=", "[", "]", ";", "$", "chks", "[", "]", "=", "\"ALTER TABLE `SL_Tree` CHANGE `...
this should really be done using migrations, includes SurvLoop database changes since Feb 15, 2017
[ "this", "should", "really", "be", "done", "using", "migrations", "includes", "SurvLoop", "database", "changes", "since", "Feb", "15", "2017" ]
7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a
https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/SurvLoopController.php#L556-L575
train
wikiworldorder/survloop
src/Controllers/Auth/UpdatePasswordController.php
UpdatePasswordController.runUpdate
public function runUpdate(Request $request) { $user = User::find(Auth::id()); $this->validate($request, [ 'old' => 'required', 'password' => 'required|min:8|confirmed', ]); if (Auth::attempt(['name' => $user->name, 'password' => $request->old])) { $user->fill([ 'password' => bcrypt($request->password) ])->save(); $request->session()->flash('success', 'Your password has been changed.'); return redirect('/my-profile'); } $request->session()->flash('failure', 'Your password has not been changed.'); return redirect('/my-profile'); }
php
public function runUpdate(Request $request) { $user = User::find(Auth::id()); $this->validate($request, [ 'old' => 'required', 'password' => 'required|min:8|confirmed', ]); if (Auth::attempt(['name' => $user->name, 'password' => $request->old])) { $user->fill([ 'password' => bcrypt($request->password) ])->save(); $request->session()->flash('success', 'Your password has been changed.'); return redirect('/my-profile'); } $request->session()->flash('failure', 'Your password has not been changed.'); return redirect('/my-profile'); }
[ "public", "function", "runUpdate", "(", "Request", "$", "request", ")", "{", "$", "user", "=", "User", "::", "find", "(", "Auth", "::", "id", "(", ")", ")", ";", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'old'", "=>", "'require...
Update the password for the user. @param Request $request @return Response
[ "Update", "the", "password", "for", "the", "user", "." ]
7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a
https://github.com/wikiworldorder/survloop/blob/7fbd61a453e2ea8c3e55bbdd6b0bed1c859c8f4a/src/Controllers/Auth/UpdatePasswordController.php#L30-L44
train
JBZoo/Data
src/PHPArray.php
PHPArray.encode
protected function encode($data) { $data = [ '<?php', '', 'return ' . $this->render($data, 0) . ';', ]; return implode(Data::LE, $data); }
php
protected function encode($data) { $data = [ '<?php', '', 'return ' . $this->render($data, 0) . ';', ]; return implode(Data::LE, $data); }
[ "protected", "function", "encode", "(", "$", "data", ")", "{", "$", "data", "=", "[", "'<?php'", ",", "''", ",", "'return '", ".", "$", "this", "->", "render", "(", "$", "data", ",", "0", ")", ".", "';'", ",", "]", ";", "return", "implode", "(", ...
Utility Method to serialize the given data @param mixed $data The data to serialize @return string The serialized data
[ "Utility", "Method", "to", "serialize", "the", "given", "data" ]
1e1238e915b942b4147ea8746760423f3cbdf20b
https://github.com/JBZoo/Data/blob/1e1238e915b942b4147ea8746760423f3cbdf20b/src/PHPArray.php#L58-L67
train
cocur/human-date
src/HumanDate.php
HumanDate.transform
public function transform($date) { if (!$date instanceof DateTime) { $date = new DateTime($date); } $current = new DateTime('now'); if ($this->isToday($date)) { return $this->trans('Today'); } if ($this->isYesterday($date)) { return $this->trans('Yesterday'); } if ($this->isTomorrow($date)) { return $this->trans('Tomorrow'); } if ($this->isNextWeek($date)) { return $this->trans('Next %weekday%', [ '%weekday%' => $date->format('l') ]); } if ($this->isLastWeek($date)) { return $this->trans('Last %weekday%', [ '%weekday%' => $date->format('l') ]); } if ($this->isThisYear($date)) { return $date->format('F j'); } return $date->format('F j, Y'); }
php
public function transform($date) { if (!$date instanceof DateTime) { $date = new DateTime($date); } $current = new DateTime('now'); if ($this->isToday($date)) { return $this->trans('Today'); } if ($this->isYesterday($date)) { return $this->trans('Yesterday'); } if ($this->isTomorrow($date)) { return $this->trans('Tomorrow'); } if ($this->isNextWeek($date)) { return $this->trans('Next %weekday%', [ '%weekday%' => $date->format('l') ]); } if ($this->isLastWeek($date)) { return $this->trans('Last %weekday%', [ '%weekday%' => $date->format('l') ]); } if ($this->isThisYear($date)) { return $date->format('F j'); } return $date->format('F j, Y'); }
[ "public", "function", "transform", "(", "$", "date", ")", "{", "if", "(", "!", "$", "date", "instanceof", "DateTime", ")", "{", "$", "date", "=", "new", "DateTime", "(", "$", "date", ")", ";", "}", "$", "current", "=", "new", "DateTime", "(", "'now...
Transforms the given date into a human-readable date. @param DateTime|string $date Input date. @return string Human-readable date.
[ "Transforms", "the", "given", "date", "into", "a", "human", "-", "readable", "date", "." ]
6249bbaf0fe32768aebeab5b5f09033bcf0a0cb5
https://github.com/cocur/human-date/blob/6249bbaf0fe32768aebeab5b5f09033bcf0a0cb5/src/HumanDate.php#L58-L91
train
thelia-modules/AttributeType
Model/Base/AttributeAttributeType.php
AttributeAttributeType.copy
public function copy($deepCopy = false) { // we use get_class(), because this might be a subclass $clazz = get_class($this); $copyObj = new $clazz(); $this->copyInto($copyObj, $deepCopy); return $copyObj; }
php
public function copy($deepCopy = false) { // we use get_class(), because this might be a subclass $clazz = get_class($this); $copyObj = new $clazz(); $this->copyInto($copyObj, $deepCopy); return $copyObj; }
[ "public", "function", "copy", "(", "$", "deepCopy", "=", "false", ")", "{", "// we use get_class(), because this might be a subclass", "$", "clazz", "=", "get_class", "(", "$", "this", ")", ";", "$", "copyObj", "=", "new", "$", "clazz", "(", ")", ";", "$", ...
Makes a copy of this object that will be inserted as a new row in table when saved. It creates a new object filling in the simple attributes, but skipping any primary keys that are defined for the table. If desired, this method can also make copies of all associated (fkey referrers) objects. @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. @return \AttributeType\Model\AttributeAttributeType Clone of current object. @throws PropelException
[ "Makes", "a", "copy", "of", "this", "object", "that", "will", "be", "inserted", "as", "a", "new", "row", "in", "table", "when", "saved", ".", "It", "creates", "a", "new", "object", "filling", "in", "the", "simple", "attributes", "but", "skipping", "any",...
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeType.php#L1109-L1117
train
thelia-modules/AttributeType
Model/Base/AttributeAttributeType.php
AttributeAttributeType.setAttribute
public function setAttribute(ChildAttribute $v = null) { if ($v === null) { $this->setAttributeId(NULL); } else { $this->setAttributeId($v->getId()); } $this->aAttribute = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildAttribute object, it will not be re-added. if ($v !== null) { $v->addAttributeAttributeType($this); } return $this; }
php
public function setAttribute(ChildAttribute $v = null) { if ($v === null) { $this->setAttributeId(NULL); } else { $this->setAttributeId($v->getId()); } $this->aAttribute = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildAttribute object, it will not be re-added. if ($v !== null) { $v->addAttributeAttributeType($this); } return $this; }
[ "public", "function", "setAttribute", "(", "ChildAttribute", "$", "v", "=", "null", ")", "{", "if", "(", "$", "v", "===", "null", ")", "{", "$", "this", "->", "setAttributeId", "(", "NULL", ")", ";", "}", "else", "{", "$", "this", "->", "setAttribute...
Declares an association between this object and a ChildAttribute object. @param ChildAttribute $v @return \AttributeType\Model\AttributeAttributeType The current object (for fluent API support) @throws PropelException
[ "Declares", "an", "association", "between", "this", "object", "and", "a", "ChildAttribute", "object", "." ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeType.php#L1126-L1144
train
thelia-modules/AttributeType
Model/Base/AttributeAttributeType.php
AttributeAttributeType.getAttribute
public function getAttribute(ConnectionInterface $con = null) { if ($this->aAttribute === null && ($this->attribute_id !== null)) { $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aAttribute->addAttributeAttributeTypes($this); */ } return $this->aAttribute; }
php
public function getAttribute(ConnectionInterface $con = null) { if ($this->aAttribute === null && ($this->attribute_id !== null)) { $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aAttribute->addAttributeAttributeTypes($this); */ } return $this->aAttribute; }
[ "public", "function", "getAttribute", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "aAttribute", "===", "null", "&&", "(", "$", "this", "->", "attribute_id", "!==", "null", ")", ")", "{", "$", "this", "->...
Get the associated ChildAttribute object @param ConnectionInterface $con Optional Connection object. @return ChildAttribute The associated ChildAttribute object. @throws PropelException
[ "Get", "the", "associated", "ChildAttribute", "object" ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeType.php#L1154-L1168
train
thelia-modules/AttributeType
Model/Base/AttributeAttributeType.php
AttributeAttributeType.getAttributeType
public function getAttributeType(ConnectionInterface $con = null) { if ($this->aAttributeType === null && ($this->attribute_type_id !== null)) { $this->aAttributeType = ChildAttributeTypeQuery::create()->findPk($this->attribute_type_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aAttributeType->addAttributeAttributeTypes($this); */ } return $this->aAttributeType; }
php
public function getAttributeType(ConnectionInterface $con = null) { if ($this->aAttributeType === null && ($this->attribute_type_id !== null)) { $this->aAttributeType = ChildAttributeTypeQuery::create()->findPk($this->attribute_type_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aAttributeType->addAttributeAttributeTypes($this); */ } return $this->aAttributeType; }
[ "public", "function", "getAttributeType", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "aAttributeType", "===", "null", "&&", "(", "$", "this", "->", "attribute_type_id", "!==", "null", ")", ")", "{", "$", ...
Get the associated ChildAttributeType object @param ConnectionInterface $con Optional Connection object. @return ChildAttributeType The associated ChildAttributeType object. @throws PropelException
[ "Get", "the", "associated", "ChildAttributeType", "object" ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeType.php#L1205-L1219
train
thelia-modules/AttributeType
Model/Base/AttributeAttributeType.php
AttributeAttributeType.initAttributeTypeAvMetas
public function initAttributeTypeAvMetas($overrideExisting = true) { if (null !== $this->collAttributeTypeAvMetas && !$overrideExisting) { return; } $this->collAttributeTypeAvMetas = new ObjectCollection(); $this->collAttributeTypeAvMetas->setModel('\AttributeType\Model\AttributeTypeAvMeta'); }
php
public function initAttributeTypeAvMetas($overrideExisting = true) { if (null !== $this->collAttributeTypeAvMetas && !$overrideExisting) { return; } $this->collAttributeTypeAvMetas = new ObjectCollection(); $this->collAttributeTypeAvMetas->setModel('\AttributeType\Model\AttributeTypeAvMeta'); }
[ "public", "function", "initAttributeTypeAvMetas", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collAttributeTypeAvMetas", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->...
Initializes the collAttributeTypeAvMetas collection. By default this just sets the collAttributeTypeAvMetas collection to an empty array (like clearcollAttributeTypeAvMetas()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collAttributeTypeAvMetas", "collection", "." ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeType.php#L1271-L1278
train
thelia-modules/AttributeType
Model/Base/AttributeAttributeType.php
AttributeAttributeType.getAttributeTypeAvMetas
public function getAttributeTypeAvMetas($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeTypeAvMetasPartial && !$this->isNew(); if (null === $this->collAttributeTypeAvMetas || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeTypeAvMetas) { // return empty collection $this->initAttributeTypeAvMetas(); } else { $collAttributeTypeAvMetas = ChildAttributeTypeAvMetaQuery::create(null, $criteria) ->filterByAttributeAttributeType($this) ->find($con); if (null !== $criteria) { if (false !== $this->collAttributeTypeAvMetasPartial && count($collAttributeTypeAvMetas)) { $this->initAttributeTypeAvMetas(false); foreach ($collAttributeTypeAvMetas as $obj) { if (false == $this->collAttributeTypeAvMetas->contains($obj)) { $this->collAttributeTypeAvMetas->append($obj); } } $this->collAttributeTypeAvMetasPartial = true; } reset($collAttributeTypeAvMetas); return $collAttributeTypeAvMetas; } if ($partial && $this->collAttributeTypeAvMetas) { foreach ($this->collAttributeTypeAvMetas as $obj) { if ($obj->isNew()) { $collAttributeTypeAvMetas[] = $obj; } } } $this->collAttributeTypeAvMetas = $collAttributeTypeAvMetas; $this->collAttributeTypeAvMetasPartial = false; } } return $this->collAttributeTypeAvMetas; }
php
public function getAttributeTypeAvMetas($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeTypeAvMetasPartial && !$this->isNew(); if (null === $this->collAttributeTypeAvMetas || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeTypeAvMetas) { // return empty collection $this->initAttributeTypeAvMetas(); } else { $collAttributeTypeAvMetas = ChildAttributeTypeAvMetaQuery::create(null, $criteria) ->filterByAttributeAttributeType($this) ->find($con); if (null !== $criteria) { if (false !== $this->collAttributeTypeAvMetasPartial && count($collAttributeTypeAvMetas)) { $this->initAttributeTypeAvMetas(false); foreach ($collAttributeTypeAvMetas as $obj) { if (false == $this->collAttributeTypeAvMetas->contains($obj)) { $this->collAttributeTypeAvMetas->append($obj); } } $this->collAttributeTypeAvMetasPartial = true; } reset($collAttributeTypeAvMetas); return $collAttributeTypeAvMetas; } if ($partial && $this->collAttributeTypeAvMetas) { foreach ($this->collAttributeTypeAvMetas as $obj) { if ($obj->isNew()) { $collAttributeTypeAvMetas[] = $obj; } } } $this->collAttributeTypeAvMetas = $collAttributeTypeAvMetas; $this->collAttributeTypeAvMetasPartial = false; } } return $this->collAttributeTypeAvMetas; }
[ "public", "function", "getAttributeTypeAvMetas", "(", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collAttributeTypeAvMetasPartial", "&&", "!", "$", "this", "->", "isNew",...
Gets an array of ChildAttributeTypeAvMeta objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildAttributeAttributeType is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return Collection|ChildAttributeTypeAvMeta[] List of ChildAttributeTypeAvMeta objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildAttributeTypeAvMeta", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeType.php#L1294-L1338
train
thelia-modules/AttributeType
Model/Base/AttributeAttributeType.php
AttributeAttributeType.countAttributeTypeAvMetas
public function countAttributeTypeAvMetas(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeTypeAvMetasPartial && !$this->isNew(); if (null === $this->collAttributeTypeAvMetas || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeTypeAvMetas) { return 0; } if ($partial && !$criteria) { return count($this->getAttributeTypeAvMetas()); } $query = ChildAttributeTypeAvMetaQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByAttributeAttributeType($this) ->count($con); } return count($this->collAttributeTypeAvMetas); }
php
public function countAttributeTypeAvMetas(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeTypeAvMetasPartial && !$this->isNew(); if (null === $this->collAttributeTypeAvMetas || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeTypeAvMetas) { return 0; } if ($partial && !$criteria) { return count($this->getAttributeTypeAvMetas()); } $query = ChildAttributeTypeAvMetaQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByAttributeAttributeType($this) ->count($con); } return count($this->collAttributeTypeAvMetas); }
[ "public", "function", "countAttributeTypeAvMetas", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collAttributeTypeAvMet...
Returns the number of related AttributeTypeAvMeta objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related AttributeTypeAvMeta objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "AttributeTypeAvMeta", "objects", "." ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeType.php#L1381-L1404
train
thelia-modules/AttributeType
Model/Base/AttributeAttributeType.php
AttributeAttributeType.addAttributeTypeAvMeta
public function addAttributeTypeAvMeta(ChildAttributeTypeAvMeta $l) { if ($this->collAttributeTypeAvMetas === null) { $this->initAttributeTypeAvMetas(); $this->collAttributeTypeAvMetasPartial = true; } if (!in_array($l, $this->collAttributeTypeAvMetas->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeTypeAvMeta($l); } return $this; }
php
public function addAttributeTypeAvMeta(ChildAttributeTypeAvMeta $l) { if ($this->collAttributeTypeAvMetas === null) { $this->initAttributeTypeAvMetas(); $this->collAttributeTypeAvMetasPartial = true; } if (!in_array($l, $this->collAttributeTypeAvMetas->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeTypeAvMeta($l); } return $this; }
[ "public", "function", "addAttributeTypeAvMeta", "(", "ChildAttributeTypeAvMeta", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collAttributeTypeAvMetas", "===", "null", ")", "{", "$", "this", "->", "initAttributeTypeAvMetas", "(", ")", ";", "$", "this", "...
Method called to associate a ChildAttributeTypeAvMeta object to this object through the ChildAttributeTypeAvMeta foreign key attribute. @param ChildAttributeTypeAvMeta $l ChildAttributeTypeAvMeta @return \AttributeType\Model\AttributeAttributeType The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildAttributeTypeAvMeta", "object", "to", "this", "object", "through", "the", "ChildAttributeTypeAvMeta", "foreign", "key", "attribute", "." ]
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeType.php#L1413-L1425
train
thelia-modules/AttributeType
Model/Base/AttributeAttributeType.php
AttributeAttributeType.getAttributeTypeAvMetasJoinAttributeAv
public function getAttributeTypeAvMetasJoinAttributeAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildAttributeTypeAvMetaQuery::create(null, $criteria); $query->joinWith('AttributeAv', $joinBehavior); return $this->getAttributeTypeAvMetas($query, $con); }
php
public function getAttributeTypeAvMetasJoinAttributeAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildAttributeTypeAvMetaQuery::create(null, $criteria); $query->joinWith('AttributeAv', $joinBehavior); return $this->getAttributeTypeAvMetas($query, $con); }
[ "public", "function", "getAttributeTypeAvMetasJoinAttributeAv", "(", "$", "criteria", "=", "null", ",", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildAttributeTypeAvMetaQuery", "::", "cr...
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this AttributeAttributeType is new, it will return an empty collection; or if this AttributeAttributeType has previously been saved, it will retrieve related AttributeTypeAvMetas from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in AttributeAttributeType. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return Collection|ChildAttributeTypeAvMeta[] List of ChildAttributeTypeAvMeta objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "AttributeAttributeType", "is", "new", "it", "will", "return", "an", "empty", "colle...
674a18afab276039a251720c1779726084b2a639
https://github.com/thelia-modules/AttributeType/blob/674a18afab276039a251720c1779726084b2a639/Model/Base/AttributeAttributeType.php#L1472-L1478
train
syzygypl/kunstmaan-extra-bundle
src/Search/ChainSearchProvider.php
ChainSearchProvider.getClient
public function getClient() { $client = $this->reduceFirst(function (SearchProviderInterface $provider) { return $provider->getClient(); }); if (null === $client) { throw new \RuntimeException('No provider was able to return a client'); } return $client; }
php
public function getClient() { $client = $this->reduceFirst(function (SearchProviderInterface $provider) { return $provider->getClient(); }); if (null === $client) { throw new \RuntimeException('No provider was able to return a client'); } return $client; }
[ "public", "function", "getClient", "(", ")", "{", "$", "client", "=", "$", "this", "->", "reduceFirst", "(", "function", "(", "SearchProviderInterface", "$", "provider", ")", "{", "return", "$", "provider", "->", "getClient", "(", ")", ";", "}", ")", ";"...
Return the client object @return mixed
[ "Return", "the", "client", "object" ]
973d7226c3b19504e89a620cf045efb94e021c62
https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/Search/ChainSearchProvider.php#L46-L57
train
syzygypl/kunstmaan-extra-bundle
src/Search/ChainSearchProvider.php
ChainSearchProvider.getIndex
public function getIndex($indexName) { return $this->reduceFirst(function (SearchProviderInterface $provider) use ($indexName) { return $provider->getIndex($this->indexNamePrefix . $indexName); }); }
php
public function getIndex($indexName) { return $this->reduceFirst(function (SearchProviderInterface $provider) use ($indexName) { return $provider->getIndex($this->indexNamePrefix . $indexName); }); }
[ "public", "function", "getIndex", "(", "$", "indexName", ")", "{", "return", "$", "this", "->", "reduceFirst", "(", "function", "(", "SearchProviderInterface", "$", "provider", ")", "use", "(", "$", "indexName", ")", "{", "return", "$", "provider", "->", "...
Return the index object @param $indexName @return mixed
[ "Return", "the", "index", "object" ]
973d7226c3b19504e89a620cf045efb94e021c62
https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/Search/ChainSearchProvider.php#L81-L86
train
syzygypl/kunstmaan-extra-bundle
src/Search/ChainSearchProvider.php
ChainSearchProvider.createDocument
public function createDocument($document, $uid, $indexName = '', $indexType = '') { return new DocumentReference($document, $uid, $this->indexNamePrefix . $indexName, $indexType); }
php
public function createDocument($document, $uid, $indexName = '', $indexType = '') { return new DocumentReference($document, $uid, $this->indexNamePrefix . $indexName, $indexType); }
[ "public", "function", "createDocument", "(", "$", "document", ",", "$", "uid", ",", "$", "indexName", "=", "''", ",", "$", "indexType", "=", "''", ")", "{", "return", "new", "DocumentReference", "(", "$", "document", ",", "$", "uid", ",", "$", "this", ...
Create a document @param string $uid @param mixed $document @param string $indexName @param string $indexType @return mixed
[ "Create", "a", "document" ]
973d7226c3b19504e89a620cf045efb94e021c62
https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/Search/ChainSearchProvider.php#L98-L101
train
syzygypl/kunstmaan-extra-bundle
src/Search/ChainSearchProvider.php
ChainSearchProvider.addDocument
public function addDocument($indexName, $indexType, $document, $uid) { if ("" === $indexName && $document instanceof DocumentReference) { $indexName = $document->getIndexName(); } else { $indexName = $this->indexNamePrefix . $indexName; } $this->mapProviders(function (SearchProviderInterface $provider) use ($document, $uid, $indexName, $indexType) { $provider->addDocument($document, $uid, $indexName, $indexType); }); }
php
public function addDocument($indexName, $indexType, $document, $uid) { if ("" === $indexName && $document instanceof DocumentReference) { $indexName = $document->getIndexName(); } else { $indexName = $this->indexNamePrefix . $indexName; } $this->mapProviders(function (SearchProviderInterface $provider) use ($document, $uid, $indexName, $indexType) { $provider->addDocument($document, $uid, $indexName, $indexType); }); }
[ "public", "function", "addDocument", "(", "$", "indexName", ",", "$", "indexType", ",", "$", "document", ",", "$", "uid", ")", "{", "if", "(", "\"\"", "===", "$", "indexName", "&&", "$", "document", "instanceof", "DocumentReference", ")", "{", "$", "inde...
Add a document to the index @param string $indexName Name of the index @param string $indexType Type of the index to add the document to @param array $document The document to index @param string $uid Unique ID for this document, this will allow the document to be overwritten by new data instead of being duplicated
[ "Add", "a", "document", "to", "the", "index" ]
973d7226c3b19504e89a620cf045efb94e021c62
https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/Search/ChainSearchProvider.php#L112-L123
train
syzygypl/kunstmaan-extra-bundle
src/Search/ChainSearchProvider.php
ChainSearchProvider.addDocuments
public function addDocuments($documents, $indexName = '', $indexType = '') { if ("" === $indexName && isset($documents[0])) { $indexName = $documents[0]->getIndexName(); } else { $indexName = $this->indexNamePrefix . $indexName; } $this->mapProviders(function (SearchProviderInterface $provider) use ($documents, $indexName, $indexType) { $documents = array_map(function (DocumentReference $document) use ($provider) { return $provider->createDocument( $document->getDocument(), $document->getUid(), $document->getIndexName(), $document->getIndexType() ); }, $documents); $provider->addDocuments($documents, $indexName, $indexType); }); }
php
public function addDocuments($documents, $indexName = '', $indexType = '') { if ("" === $indexName && isset($documents[0])) { $indexName = $documents[0]->getIndexName(); } else { $indexName = $this->indexNamePrefix . $indexName; } $this->mapProviders(function (SearchProviderInterface $provider) use ($documents, $indexName, $indexType) { $documents = array_map(function (DocumentReference $document) use ($provider) { return $provider->createDocument( $document->getDocument(), $document->getUid(), $document->getIndexName(), $document->getIndexType() ); }, $documents); $provider->addDocuments($documents, $indexName, $indexType); }); }
[ "public", "function", "addDocuments", "(", "$", "documents", ",", "$", "indexName", "=", "''", ",", "$", "indexType", "=", "''", ")", "{", "if", "(", "\"\"", "===", "$", "indexName", "&&", "isset", "(", "$", "documents", "[", "0", "]", ")", ")", "{...
Add a collection of documents at once @param mixed $documents @param string $indexName Name of the index @param string $indexType Type of the index the document is located @return mixed
[ "Add", "a", "collection", "of", "documents", "at", "once" ]
973d7226c3b19504e89a620cf045efb94e021c62
https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/Search/ChainSearchProvider.php#L134-L155
train
syzygypl/kunstmaan-extra-bundle
src/Search/ChainSearchProvider.php
ChainSearchProvider.deleteDocument
public function deleteDocument($indexName, $indexType, $uid) { $this->mapProviders(function (SearchProviderInterface $provider) use ($indexName, $indexType, $uid) { $provider->deleteDocument($this->indexNamePrefix . $indexName, $indexType, $uid); }); }
php
public function deleteDocument($indexName, $indexType, $uid) { $this->mapProviders(function (SearchProviderInterface $provider) use ($indexName, $indexType, $uid) { $provider->deleteDocument($this->indexNamePrefix . $indexName, $indexType, $uid); }); }
[ "public", "function", "deleteDocument", "(", "$", "indexName", ",", "$", "indexType", ",", "$", "uid", ")", "{", "$", "this", "->", "mapProviders", "(", "function", "(", "SearchProviderInterface", "$", "provider", ")", "use", "(", "$", "indexName", ",", "$...
delete a document from the index @param string $indexName Name of the index @param string $indexType Type of the index the document is located @param string $uid Unique ID of the document to be delete
[ "delete", "a", "document", "from", "the", "index" ]
973d7226c3b19504e89a620cf045efb94e021c62
https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/Search/ChainSearchProvider.php#L164-L169
train
syzygypl/kunstmaan-extra-bundle
src/Search/ChainSearchProvider.php
ChainSearchProvider.deleteIndex
public function deleteIndex($indexName) { $this->mapProviders(function (SearchProviderInterface $provider) use ($indexName) { try { $provider->deleteIndex($this->indexNamePrefix . $indexName); } catch (\Exception $e) { // we don’t care } }); }
php
public function deleteIndex($indexName) { $this->mapProviders(function (SearchProviderInterface $provider) use ($indexName) { try { $provider->deleteIndex($this->indexNamePrefix . $indexName); } catch (\Exception $e) { // we don’t care } }); }
[ "public", "function", "deleteIndex", "(", "$", "indexName", ")", "{", "$", "this", "->", "mapProviders", "(", "function", "(", "SearchProviderInterface", "$", "provider", ")", "use", "(", "$", "indexName", ")", "{", "try", "{", "$", "provider", "->", "dele...
Delete an index @param string $indexName Name of the index to delete
[ "Delete", "an", "index" ]
973d7226c3b19504e89a620cf045efb94e021c62
https://github.com/syzygypl/kunstmaan-extra-bundle/blob/973d7226c3b19504e89a620cf045efb94e021c62/src/Search/ChainSearchProvider.php#L188-L197
train
AltThree/Validator
src/ValidatingMiddleware.php
ValidatingMiddleware.handle
public function handle($command, Closure $next) { if (property_exists($command, 'rules') && is_array($command->rules)) { $this->validate($command); } return $next($command); }
php
public function handle($command, Closure $next) { if (property_exists($command, 'rules') && is_array($command->rules)) { $this->validate($command); } return $next($command); }
[ "public", "function", "handle", "(", "$", "command", ",", "Closure", "$", "next", ")", "{", "if", "(", "property_exists", "(", "$", "command", ",", "'rules'", ")", "&&", "is_array", "(", "$", "command", "->", "rules", ")", ")", "{", "$", "this", "->"...
Validate the command before execution. @param object $command @param \Closure $next @throws \AltThree\Validator\ValidationException @return void
[ "Validate", "the", "command", "before", "execution", "." ]
fae25a5423417dc31e637dc64774480fc7f0ff6b
https://github.com/AltThree/Validator/blob/fae25a5423417dc31e637dc64774480fc7f0ff6b/src/ValidatingMiddleware.php#L57-L64
train
AltThree/Validator
src/ValidatingMiddleware.php
ValidatingMiddleware.validate
protected function validate($command) { if (method_exists($command, 'validate')) { $command->validate(); } $messages = property_exists($command, 'validationMessages') ? $command->validationMessages : []; $validator = $this->factory->make($this->getData($command), $command->rules, $messages); if ($validator->fails()) { throw new ValidationException($validator->getMessageBag()); } }
php
protected function validate($command) { if (method_exists($command, 'validate')) { $command->validate(); } $messages = property_exists($command, 'validationMessages') ? $command->validationMessages : []; $validator = $this->factory->make($this->getData($command), $command->rules, $messages); if ($validator->fails()) { throw new ValidationException($validator->getMessageBag()); } }
[ "protected", "function", "validate", "(", "$", "command", ")", "{", "if", "(", "method_exists", "(", "$", "command", ",", "'validate'", ")", ")", "{", "$", "command", "->", "validate", "(", ")", ";", "}", "$", "messages", "=", "property_exists", "(", "...
Validate the command. @param object $command @throws \AltThree\Validator\ValidationException @return void
[ "Validate", "the", "command", "." ]
fae25a5423417dc31e637dc64774480fc7f0ff6b
https://github.com/AltThree/Validator/blob/fae25a5423417dc31e637dc64774480fc7f0ff6b/src/ValidatingMiddleware.php#L75-L88
train
AltThree/Validator
src/ValidatingMiddleware.php
ValidatingMiddleware.getData
protected function getData($command) { $data = []; foreach ((new ReflectionClass($command))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { $name = $property->getName(); $value = $property->getValue($command); if (in_array($name, ['rules', 'validationMessages'], true)) { continue; } $data[$name] = $value; } return $data; }
php
protected function getData($command) { $data = []; foreach ((new ReflectionClass($command))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { $name = $property->getName(); $value = $property->getValue($command); if (in_array($name, ['rules', 'validationMessages'], true)) { continue; } $data[$name] = $value; } return $data; }
[ "protected", "function", "getData", "(", "$", "command", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "(", "new", "ReflectionClass", "(", "$", "command", ")", ")", "->", "getProperties", "(", "ReflectionProperty", "::", "IS_PUBLIC", ")", "a...
Get the data to be validated. @param object $command @return array
[ "Get", "the", "data", "to", "be", "validated", "." ]
fae25a5423417dc31e637dc64774480fc7f0ff6b
https://github.com/AltThree/Validator/blob/fae25a5423417dc31e637dc64774480fc7f0ff6b/src/ValidatingMiddleware.php#L97-L113
train
jacklul/monolog-telegram
src/TelegramHandler.php
TelegramHandler.send
private function send($message) { $url = self::BASE_URI . $this->token . '/sendMessage'; $data = [ 'chat_id' => $this->chatId, 'text' => $message, 'disable_web_page_preview' => true // Just in case there is a link in the message ]; // Set HTML parse mode when HTML code is detected if (preg_match('/<[^<]+>/', $data['text']) !== false) { $data['parse_mode'] = 'HTML'; } if ($this->useCurl === true && extension_loaded('curl')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verifyPeer); curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); $result = curl_exec($ch); if (!$result) { throw new \RuntimeException('Request to Telegram API failed: ' . curl_error($ch)); } } else { $opts = [ 'http' => [ 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($data), 'timeout' => $this->timeout, ], 'ssl' => [ 'verify_peer' => $this->verifyPeer, 'verify_peer_name' => $this->verifyPeer, ], ]; $result = @file_get_contents($url, false, stream_context_create($opts)); if (!$result) { $error = error_get_last(); if (isset($error['message'])) { throw new \RuntimeException('Request to Telegram API failed: ' . $error['message']); } throw new \RuntimeException('Request to Telegram API failed'); } } $result = json_decode($result, true); if (isset($result['ok']) && $result['ok'] === true) { return true; } if (isset($result['description'])) { throw new \RuntimeException('Telegram API error: ' . $result['description']); } return false; }
php
private function send($message) { $url = self::BASE_URI . $this->token . '/sendMessage'; $data = [ 'chat_id' => $this->chatId, 'text' => $message, 'disable_web_page_preview' => true // Just in case there is a link in the message ]; // Set HTML parse mode when HTML code is detected if (preg_match('/<[^<]+>/', $data['text']) !== false) { $data['parse_mode'] = 'HTML'; } if ($this->useCurl === true && extension_loaded('curl')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verifyPeer); curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); $result = curl_exec($ch); if (!$result) { throw new \RuntimeException('Request to Telegram API failed: ' . curl_error($ch)); } } else { $opts = [ 'http' => [ 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($data), 'timeout' => $this->timeout, ], 'ssl' => [ 'verify_peer' => $this->verifyPeer, 'verify_peer_name' => $this->verifyPeer, ], ]; $result = @file_get_contents($url, false, stream_context_create($opts)); if (!$result) { $error = error_get_last(); if (isset($error['message'])) { throw new \RuntimeException('Request to Telegram API failed: ' . $error['message']); } throw new \RuntimeException('Request to Telegram API failed'); } } $result = json_decode($result, true); if (isset($result['ok']) && $result['ok'] === true) { return true; } if (isset($result['description'])) { throw new \RuntimeException('Telegram API error: ' . $result['description']); } return false; }
[ "private", "function", "send", "(", "$", "message", ")", "{", "$", "url", "=", "self", "::", "BASE_URI", ".", "$", "this", "->", "token", ".", "'/sendMessage'", ";", "$", "data", "=", "[", "'chat_id'", "=>", "$", "this", "->", "chatId", ",", "'text'"...
Send sendMessage request to Telegram Bot API @param string $message The message to send @return bool
[ "Send", "sendMessage", "request", "to", "Telegram", "Bot", "API" ]
9bae1abc6c91c0f3e654057a8fa29feaf49f1e5f
https://github.com/jacklul/monolog-telegram/blob/9bae1abc6c91c0f3e654057a8fa29feaf49f1e5f/src/TelegramHandler.php#L129-L191
train
apioo/psx-framework
src/Controller/Behaviour/HttpTrait.php
HttpTrait.getParameter
protected function getParameter($key, $type = Validate::TYPE_STRING, array $filter = array(), $title = null, $required = true) { $parameter = $this->request->getUri()->getParameter($key); if (isset($parameter)) { return $this->validate->apply($parameter, $type, $filter, $title, $required); } else { return null; } }
php
protected function getParameter($key, $type = Validate::TYPE_STRING, array $filter = array(), $title = null, $required = true) { $parameter = $this->request->getUri()->getParameter($key); if (isset($parameter)) { return $this->validate->apply($parameter, $type, $filter, $title, $required); } else { return null; } }
[ "protected", "function", "getParameter", "(", "$", "key", ",", "$", "type", "=", "Validate", "::", "TYPE_STRING", ",", "array", "$", "filter", "=", "array", "(", ")", ",", "$", "title", "=", "null", ",", "$", "required", "=", "true", ")", "{", "$", ...
Returns a parameter from the query fragment of the request url @param string $key @param string $type @param array $filter @param string $title @param boolean $required @return mixed @deprecated
[ "Returns", "a", "parameter", "from", "the", "query", "fragment", "of", "the", "request", "url" ]
e8e550a1a87dae49b615b42a05583395088c1efb
https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Controller/Behaviour/HttpTrait.php#L133-L142
train
apioo/psx-framework
src/Controller/Behaviour/HttpTrait.php
HttpTrait.setBody
protected function setBody($data) { $this->responseWriter->setBody($this->response, $data, $this->request); }
php
protected function setBody($data) { $this->responseWriter->setBody($this->response, $data, $this->request); }
[ "protected", "function", "setBody", "(", "$", "data", ")", "{", "$", "this", "->", "responseWriter", "->", "setBody", "(", "$", "this", "->", "response", ",", "$", "data", ",", "$", "this", "->", "request", ")", ";", "}" ]
Method to set a response body @param mixed $data @param string $writerType @deprecated
[ "Method", "to", "set", "a", "response", "body" ]
e8e550a1a87dae49b615b42a05583395088c1efb
https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Controller/Behaviour/HttpTrait.php#L186-L189
train
apioo/psx-framework
src/Controller/Behaviour/RedirectTrait.php
RedirectTrait.forward
protected function forward($source, array $parameters = array()) { $path = $this->reverseRouter->getPath($source, $parameters); if ($path !== null) { $this->request->setUri($this->request->getUri()->withPath($path)); $this->loader->load($this->request, $this->response, $this->context); } else { throw new RuntimeException('Could not find route for source ' . $source); } }
php
protected function forward($source, array $parameters = array()) { $path = $this->reverseRouter->getPath($source, $parameters); if ($path !== null) { $this->request->setUri($this->request->getUri()->withPath($path)); $this->loader->load($this->request, $this->response, $this->context); } else { throw new RuntimeException('Could not find route for source ' . $source); } }
[ "protected", "function", "forward", "(", "$", "source", ",", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "path", "=", "$", "this", "->", "reverseRouter", "->", "getPath", "(", "$", "source", ",", "$", "parameters", ")", ";", "i...
Forwards the request to another controller @param string $source @param array $parameters @deprecated
[ "Forwards", "the", "request", "to", "another", "controller" ]
e8e550a1a87dae49b615b42a05583395088c1efb
https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Controller/Behaviour/RedirectTrait.php#L60-L71
train
apioo/psx-framework
src/Controller/Behaviour/RedirectTrait.php
RedirectTrait.redirect
protected function redirect($source, array $parameters = array(), $code = 307) { if ($source instanceof Url) { $url = $source->toString(); } elseif (filter_var($source, FILTER_VALIDATE_URL)) { $url = $source; } else { $url = $this->reverseRouter->getUrl($source, $parameters); } if ($code == 301) { throw new StatusCode\MovedPermanentlyException($url); } elseif ($code == 302) { throw new StatusCode\FoundException($url); } elseif ($code == 307) { throw new StatusCode\TemporaryRedirectException($url); } else { throw new RuntimeException('Invalid redirect status code'); } }
php
protected function redirect($source, array $parameters = array(), $code = 307) { if ($source instanceof Url) { $url = $source->toString(); } elseif (filter_var($source, FILTER_VALIDATE_URL)) { $url = $source; } else { $url = $this->reverseRouter->getUrl($source, $parameters); } if ($code == 301) { throw new StatusCode\MovedPermanentlyException($url); } elseif ($code == 302) { throw new StatusCode\FoundException($url); } elseif ($code == 307) { throw new StatusCode\TemporaryRedirectException($url); } else { throw new RuntimeException('Invalid redirect status code'); } }
[ "protected", "function", "redirect", "(", "$", "source", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "$", "code", "=", "307", ")", "{", "if", "(", "$", "source", "instanceof", "Url", ")", "{", "$", "url", "=", "$", "source", "->",...
Throws an redirect exception which sends an Location header. If source is not an url the reverse router is used to determine the url @param string $source @param array $parameters @param integer $code @deprecated
[ "Throws", "an", "redirect", "exception", "which", "sends", "an", "Location", "header", ".", "If", "source", "is", "not", "an", "url", "the", "reverse", "router", "is", "used", "to", "determine", "the", "url" ]
e8e550a1a87dae49b615b42a05583395088c1efb
https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Controller/Behaviour/RedirectTrait.php#L82-L101
train
AmsTaFFix/extjs-bundle
Service/GeneratorService.php
GeneratorService.generateRemotingApi
public function generateRemotingApi() { $list = array(); foreach($this->remotingBundles as $bundle) { $bundleRef = new \ReflectionClass($bundle); $controllerDir = new Finder(); $controllerDir->files()->in(dirname($bundleRef->getFileName()).'/Controller/')->name('/.*Controller\.php$/'); foreach($controllerDir as $controllerFile) { $controller = $bundleRef->getNamespaceName() . "\\Controller\\" . substr($controllerFile->getFilename(), 0, -4); $controllerRef = new \ReflectionClass($controller); foreach ($controllerRef->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { /** @var $methodDirectAnnotation Direct */ $methodDirectAnnotation = $this->annoReader->getMethodAnnotation($method, 'Tpg\ExtjsBundle\Annotation\Direct'); if ($methodDirectAnnotation !== null) { $nameSpace = str_replace("\\", ".", $bundleRef->getNamespaceName()); $className = str_replace("Controller", "", $controllerRef->getShortName()); $methodName = str_replace("Action", "", $method->getName()); $list[$nameSpace][$className][] = array( 'name'=>$methodName, 'len' => count($method->getParameters()) ); } } } } return $list; }
php
public function generateRemotingApi() { $list = array(); foreach($this->remotingBundles as $bundle) { $bundleRef = new \ReflectionClass($bundle); $controllerDir = new Finder(); $controllerDir->files()->in(dirname($bundleRef->getFileName()).'/Controller/')->name('/.*Controller\.php$/'); foreach($controllerDir as $controllerFile) { $controller = $bundleRef->getNamespaceName() . "\\Controller\\" . substr($controllerFile->getFilename(), 0, -4); $controllerRef = new \ReflectionClass($controller); foreach ($controllerRef->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { /** @var $methodDirectAnnotation Direct */ $methodDirectAnnotation = $this->annoReader->getMethodAnnotation($method, 'Tpg\ExtjsBundle\Annotation\Direct'); if ($methodDirectAnnotation !== null) { $nameSpace = str_replace("\\", ".", $bundleRef->getNamespaceName()); $className = str_replace("Controller", "", $controllerRef->getShortName()); $methodName = str_replace("Action", "", $method->getName()); $list[$nameSpace][$className][] = array( 'name'=>$methodName, 'len' => count($method->getParameters()) ); } } } } return $list; }
[ "public", "function", "generateRemotingApi", "(", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "remotingBundles", "as", "$", "bundle", ")", "{", "$", "bundleRef", "=", "new", "\\", "ReflectionClass", "(", "$", ...
Generate Remote API from a list of controllers
[ "Generate", "Remote", "API", "from", "a", "list", "of", "controllers" ]
c07bc2766f5af3f6d8460e0f025f31794b7d5ebd
https://github.com/AmsTaFFix/extjs-bundle/blob/c07bc2766f5af3f6d8460e0f025f31794b7d5ebd/Service/GeneratorService.php#L48-L73
train
AmsTaFFix/extjs-bundle
Service/GeneratorService.php
GeneratorService.tryToGetJoinColumnNameOfMappedBy
protected function tryToGetJoinColumnNameOfMappedBy($annotation){ $annotation = $this->tryToGetJoinColumnAnnotationOfMappedBy($annotation); if ($annotation !== null) { if ($annotation instanceof JoinColumn) { return $annotation->name; } else if ($annotation instanceof JoinColumns) { if (count($annotation->value) > 1) { throw new \Exception('Multiple foreign key is not supported'); } return $annotation->value[0]->name; } } return ''; }
php
protected function tryToGetJoinColumnNameOfMappedBy($annotation){ $annotation = $this->tryToGetJoinColumnAnnotationOfMappedBy($annotation); if ($annotation !== null) { if ($annotation instanceof JoinColumn) { return $annotation->name; } else if ($annotation instanceof JoinColumns) { if (count($annotation->value) > 1) { throw new \Exception('Multiple foreign key is not supported'); } return $annotation->value[0]->name; } } return ''; }
[ "protected", "function", "tryToGetJoinColumnNameOfMappedBy", "(", "$", "annotation", ")", "{", "$", "annotation", "=", "$", "this", "->", "tryToGetJoinColumnAnnotationOfMappedBy", "(", "$", "annotation", ")", ";", "if", "(", "$", "annotation", "!==", "null", ")", ...
Get the join column name. @param OneToMany $annotation @throws \Exception @return string
[ "Get", "the", "join", "column", "name", "." ]
c07bc2766f5af3f6d8460e0f025f31794b7d5ebd
https://github.com/AmsTaFFix/extjs-bundle/blob/c07bc2766f5af3f6d8460e0f025f31794b7d5ebd/Service/GeneratorService.php#L312-L325
train
AmsTaFFix/extjs-bundle
Service/GeneratorService.php
GeneratorService.tryToGetJoinColumnAnnotationOfMappedBy
protected function tryToGetJoinColumnAnnotationOfMappedBy($annotation){ $result = null; if($annotation->targetEntity && $annotation->mappedBy) { $result = $this->getAnnotation( $annotation->targetEntity, $annotation->mappedBy, 'Doctrine\ORM\Mapping\JoinColumn' ); if ($result === null) { $result = $this->getAnnotation( $annotation->targetEntity, $annotation->mappedBy, 'Doctrine\ORM\Mapping\JoinColumns' ); } } return $result; }
php
protected function tryToGetJoinColumnAnnotationOfMappedBy($annotation){ $result = null; if($annotation->targetEntity && $annotation->mappedBy) { $result = $this->getAnnotation( $annotation->targetEntity, $annotation->mappedBy, 'Doctrine\ORM\Mapping\JoinColumn' ); if ($result === null) { $result = $this->getAnnotation( $annotation->targetEntity, $annotation->mappedBy, 'Doctrine\ORM\Mapping\JoinColumns' ); } } return $result; }
[ "protected", "function", "tryToGetJoinColumnAnnotationOfMappedBy", "(", "$", "annotation", ")", "{", "$", "result", "=", "null", ";", "if", "(", "$", "annotation", "->", "targetEntity", "&&", "$", "annotation", "->", "mappedBy", ")", "{", "$", "result", "=", ...
Get the join column annotation @param OneToMany $annotation @return null|Annotation
[ "Get", "the", "join", "column", "annotation" ]
c07bc2766f5af3f6d8460e0f025f31794b7d5ebd
https://github.com/AmsTaFFix/extjs-bundle/blob/c07bc2766f5af3f6d8460e0f025f31794b7d5ebd/Service/GeneratorService.php#L332-L349
train
AmsTaFFix/extjs-bundle
Service/GeneratorService.php
GeneratorService.getEntityColumnType
public function getEntityColumnType($entity, $property) { $classRef = new \ReflectionClass($entity); if ($classRef->hasProperty($property)) { $propertyRef = $classRef->getProperty($property); $columnRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mapping\Column'); } else { /** Can not find the property on the class. Check the all the Column annotation */ foreach ($classRef->getProperties() as $propertyRef) { $columnRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mapping\Column'); if ($columnRef->name == $property) { break; } else { $columnRef = null; } } } if ($columnRef === null) { $idRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mapping\Id'); if ($idRef !== null) { return "int"; } else { return "string"; } } else { return $this->getColumnType($columnRef->type); } }
php
public function getEntityColumnType($entity, $property) { $classRef = new \ReflectionClass($entity); if ($classRef->hasProperty($property)) { $propertyRef = $classRef->getProperty($property); $columnRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mapping\Column'); } else { /** Can not find the property on the class. Check the all the Column annotation */ foreach ($classRef->getProperties() as $propertyRef) { $columnRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mapping\Column'); if ($columnRef->name == $property) { break; } else { $columnRef = null; } } } if ($columnRef === null) { $idRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mapping\Id'); if ($idRef !== null) { return "int"; } else { return "string"; } } else { return $this->getColumnType($columnRef->type); } }
[ "public", "function", "getEntityColumnType", "(", "$", "entity", ",", "$", "property", ")", "{", "$", "classRef", "=", "new", "\\", "ReflectionClass", "(", "$", "entity", ")", ";", "if", "(", "$", "classRef", "->", "hasProperty", "(", "$", "property", ")...
Get Column Type of a model. @param $entity string Class name of the entity @param $property string @return string
[ "Get", "Column", "Type", "of", "a", "model", "." ]
c07bc2766f5af3f6d8460e0f025f31794b7d5ebd
https://github.com/AmsTaFFix/extjs-bundle/blob/c07bc2766f5af3f6d8460e0f025f31794b7d5ebd/Service/GeneratorService.php#L372-L398
train
AmsTaFFix/extjs-bundle
Service/GeneratorService.php
GeneratorService.getValidator
protected function getValidator($name, $annotation) { $validate = array(); switch($name) { case 'NotBlank': case 'NotNull': $validate['type'] = "presence"; break; case 'Email': $validate['type'] = "email"; break; case 'Length': $validate['type'] = "length"; $validate['max'] = (int)$annotation->max; $validate['min'] = (int)$annotation->min; break; case 'Regex': if ($annotation->match) { $validate['type'] = "format"; $validate['matcher']['skipEncode'] = true; $validate['matcher']['value'] = $annotation->pattern; } break; case 'MaxLength': case 'MinLength': $validate['type'] = "length"; if ($name == "MaxLength") { $validate['max'] = (int)$annotation->limit; } else { $validate['min'] = (int)$annotation->limit; } break; case 'Choice': $validate['type'] = "inclusion"; $validate['list'] = $annotation->choices; break; default: $validate['type'] = strtolower($name); $validate += get_object_vars($annotation); break; } return $validate; }
php
protected function getValidator($name, $annotation) { $validate = array(); switch($name) { case 'NotBlank': case 'NotNull': $validate['type'] = "presence"; break; case 'Email': $validate['type'] = "email"; break; case 'Length': $validate['type'] = "length"; $validate['max'] = (int)$annotation->max; $validate['min'] = (int)$annotation->min; break; case 'Regex': if ($annotation->match) { $validate['type'] = "format"; $validate['matcher']['skipEncode'] = true; $validate['matcher']['value'] = $annotation->pattern; } break; case 'MaxLength': case 'MinLength': $validate['type'] = "length"; if ($name == "MaxLength") { $validate['max'] = (int)$annotation->limit; } else { $validate['min'] = (int)$annotation->limit; } break; case 'Choice': $validate['type'] = "inclusion"; $validate['list'] = $annotation->choices; break; default: $validate['type'] = strtolower($name); $validate += get_object_vars($annotation); break; } return $validate; }
[ "protected", "function", "getValidator", "(", "$", "name", ",", "$", "annotation", ")", "{", "$", "validate", "=", "array", "(", ")", ";", "switch", "(", "$", "name", ")", "{", "case", "'NotBlank'", ":", "case", "'NotNull'", ":", "$", "validate", "[", ...
Get the Ext JS Validator @param string $name @param array $annotation @return array
[ "Get", "the", "Ext", "JS", "Validator" ]
c07bc2766f5af3f6d8460e0f025f31794b7d5ebd
https://github.com/AmsTaFFix/extjs-bundle/blob/c07bc2766f5af3f6d8460e0f025f31794b7d5ebd/Service/GeneratorService.php#L458-L499
train
AmsTaFFix/extjs-bundle
Service/GeneratorService.php
GeneratorService.getModelName
public function getModelName($entity) { $classRef = new \ReflectionClass($entity); $classModelAnnotation = $this->annoReader->getClassAnnotation($classRef, 'Tpg\ExtjsBundle\Annotation\Model'); if ($classModelAnnotation !== null) { if ($classModelAnnotation->name) { return $classModelAnnotation->name; } else { return str_replace("\\", ".", $classRef->getName()); } } return null; }
php
public function getModelName($entity) { $classRef = new \ReflectionClass($entity); $classModelAnnotation = $this->annoReader->getClassAnnotation($classRef, 'Tpg\ExtjsBundle\Annotation\Model'); if ($classModelAnnotation !== null) { if ($classModelAnnotation->name) { return $classModelAnnotation->name; } else { return str_replace("\\", ".", $classRef->getName()); } } return null; }
[ "public", "function", "getModelName", "(", "$", "entity", ")", "{", "$", "classRef", "=", "new", "\\", "ReflectionClass", "(", "$", "entity", ")", ";", "$", "classModelAnnotation", "=", "$", "this", "->", "annoReader", "->", "getClassAnnotation", "(", "$", ...
Get model name of an entity @param $entity string Class name of the entity
[ "Get", "model", "name", "of", "an", "entity" ]
c07bc2766f5af3f6d8460e0f025f31794b7d5ebd
https://github.com/AmsTaFFix/extjs-bundle/blob/c07bc2766f5af3f6d8460e0f025f31794b7d5ebd/Service/GeneratorService.php#L505-L516
train
apioo/psx-framework
src/Dispatch/Dispatch.php
Dispatch.route
public function route(RequestInterface $request, ResponseInterface $response, Context $context = null) { $this->level++; $this->eventDispatcher->dispatch(Event::REQUEST_INCOMING, new RequestIncomingEvent($request)); // load controller if ($context === null) { $factory = $this->config->get('psx_context_factory'); if ($factory instanceof \Closure) { $context = $factory(); } else { $context = new Context(); } } try { $this->loader->load($request, $response, $context); } catch (StatusCode\NotModifiedException $e) { $response->setStatus($e->getStatusCode()); $response->setBody(new StringStream()); } catch (StatusCode\RedirectionException $e) { $response->setStatus($e->getStatusCode()); $response->setHeader('Location', $e->getLocation()); $response->setBody(new StringStream()); } catch (\Throwable $e) { $this->eventDispatcher->dispatch(Event::EXCEPTION_THROWN, new ExceptionThrownEvent($e, new ControllerContext($request, $response))); $this->handleException($e, $response); try { $context->setException($e); $class = isset($this->config['psx_error_controller']) ? $this->config['psx_error_controller'] : ErrorController::class; $controller = $this->controllerFactory->getController($class, $context); $this->loader->execute($controller, $request, $response); } catch (\Throwable $e) { // in this case the error controller has thrown an exception. // This can happen i.e. if we can not represent the error in an // fitting media type. In this case we send json to the client $this->handleException($e, $response); $record = $this->exceptionConverter->convert($e); $response->setHeader('Content-Type', 'application/json'); $response->setBody(new StringStream(Parser::encode($record, JSON_PRETTY_PRINT))); } } // for HEAD requests we never return a response body if ($request->getMethod() == 'HEAD') { $response->setHeader('Content-Length', $response->getBody()->getSize()); $response->setBody(new StringStream('')); } $this->eventDispatcher->dispatch(Event::RESPONSE_SEND, new ResponseSendEvent($response)); $this->level--; return $response; }
php
public function route(RequestInterface $request, ResponseInterface $response, Context $context = null) { $this->level++; $this->eventDispatcher->dispatch(Event::REQUEST_INCOMING, new RequestIncomingEvent($request)); // load controller if ($context === null) { $factory = $this->config->get('psx_context_factory'); if ($factory instanceof \Closure) { $context = $factory(); } else { $context = new Context(); } } try { $this->loader->load($request, $response, $context); } catch (StatusCode\NotModifiedException $e) { $response->setStatus($e->getStatusCode()); $response->setBody(new StringStream()); } catch (StatusCode\RedirectionException $e) { $response->setStatus($e->getStatusCode()); $response->setHeader('Location', $e->getLocation()); $response->setBody(new StringStream()); } catch (\Throwable $e) { $this->eventDispatcher->dispatch(Event::EXCEPTION_THROWN, new ExceptionThrownEvent($e, new ControllerContext($request, $response))); $this->handleException($e, $response); try { $context->setException($e); $class = isset($this->config['psx_error_controller']) ? $this->config['psx_error_controller'] : ErrorController::class; $controller = $this->controllerFactory->getController($class, $context); $this->loader->execute($controller, $request, $response); } catch (\Throwable $e) { // in this case the error controller has thrown an exception. // This can happen i.e. if we can not represent the error in an // fitting media type. In this case we send json to the client $this->handleException($e, $response); $record = $this->exceptionConverter->convert($e); $response->setHeader('Content-Type', 'application/json'); $response->setBody(new StringStream(Parser::encode($record, JSON_PRETTY_PRINT))); } } // for HEAD requests we never return a response body if ($request->getMethod() == 'HEAD') { $response->setHeader('Content-Length', $response->getBody()->getSize()); $response->setBody(new StringStream('')); } $this->eventDispatcher->dispatch(Event::RESPONSE_SEND, new ResponseSendEvent($response)); $this->level--; return $response; }
[ "public", "function", "route", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "Context", "$", "context", "=", "null", ")", "{", "$", "this", "->", "level", "++", ";", "$", "this", "->", "eventDispatcher", "->", "di...
Routes the request to the fitting controller and returns the response @param \PSX\Http\RequestInterface $request @param \PSX\Http\ResponseInterface $response @param \PSX\Framework\Loader\Context $context @return \PSX\Http\ResponseInterface
[ "Routes", "the", "request", "to", "the", "fitting", "controller", "and", "returns", "the", "response" ]
e8e550a1a87dae49b615b42a05583395088c1efb
https://github.com/apioo/psx-framework/blob/e8e550a1a87dae49b615b42a05583395088c1efb/src/Dispatch/Dispatch.php#L108-L170
train
FriendsOfCake/process-mq
src/Queue.php
Queue.consume
public static function consume($name) { $config = static::get($name); if (empty($config['consume'])) { throw new Exception('Missing consumer configuration (' . $name . ')'); } $config = $config['consume']; $config += [ 'connection' => 'rabbit', 'prefetchCount' => 1, ]; if (!array_key_exists($name, static::$_consumers)) { $connection = ConnectionManager::get($config['connection']); static::$_consumers[$name] = $connection->queue($config['queue'], $config); } return static::$_consumers[$name]; }
php
public static function consume($name) { $config = static::get($name); if (empty($config['consume'])) { throw new Exception('Missing consumer configuration (' . $name . ')'); } $config = $config['consume']; $config += [ 'connection' => 'rabbit', 'prefetchCount' => 1, ]; if (!array_key_exists($name, static::$_consumers)) { $connection = ConnectionManager::get($config['connection']); static::$_consumers[$name] = $connection->queue($config['queue'], $config); } return static::$_consumers[$name]; }
[ "public", "static", "function", "consume", "(", "$", "name", ")", "{", "$", "config", "=", "static", "::", "get", "(", "$", "name", ")", ";", "if", "(", "empty", "(", "$", "config", "[", "'consume'", "]", ")", ")", "{", "throw", "new", "Exception",...
Get the queue object for consumption @param string $name @return \AMQPQueue @throws \Exception on missing consumer configuration.
[ "Get", "the", "queue", "object", "for", "consumption" ]
184a868c2415781ebf4de48f85c45b93dfb60552
https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Queue.php#L43-L62
train
FriendsOfCake/process-mq
src/Queue.php
Queue.publish
public static function publish($name, $data, array $options = []) { $config = static::get($name); if (empty($config['publish'])) { throw new Exception('Missing publisher configuration (' . $name . ')'); } $config = $config['publish']; $config += $options; $config += [ 'connection' => 'rabbit', 'className' => 'RabbitMQ.RabbitQueue' ]; if (!array_key_exists($name, static::$_publishers)) { static::$_publishers[$name] = ConnectionManager::get($config['connection']); } return static::$_publishers[$name]->send($config['exchange'], $config['routing'], $data, $config); }
php
public static function publish($name, $data, array $options = []) { $config = static::get($name); if (empty($config['publish'])) { throw new Exception('Missing publisher configuration (' . $name . ')'); } $config = $config['publish']; $config += $options; $config += [ 'connection' => 'rabbit', 'className' => 'RabbitMQ.RabbitQueue' ]; if (!array_key_exists($name, static::$_publishers)) { static::$_publishers[$name] = ConnectionManager::get($config['connection']); } return static::$_publishers[$name]->send($config['exchange'], $config['routing'], $data, $config); }
[ "public", "static", "function", "publish", "(", "$", "name", ",", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "config", "=", "static", "::", "get", "(", "$", "name", ")", ";", "if", "(", "empty", "(", "$", "config", ...
Publish a message to a RabbitMQ exchange @param string $name @param mixed $data @param array $options @return boolean
[ "Publish", "a", "message", "to", "a", "RabbitMQ", "exchange" ]
184a868c2415781ebf4de48f85c45b93dfb60552
https://github.com/FriendsOfCake/process-mq/blob/184a868c2415781ebf4de48f85c45b93dfb60552/src/Queue.php#L72-L91
train