repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
xiewulong/yii2-fileupload
Manager.php
Manager.getName
private function getName() { if($this->name === false) { $this->name = $this->pre . $this->getTime() . '_' . md5(mt_rand()) . $this->suf . '.' . $this->ext; } return $this->name; }
php
private function getName() { if($this->name === false) { $this->name = $this->pre . $this->getTime() . '_' . md5(mt_rand()) . $this->suf . '.' . $this->ext; } return $this->name; }
[ "private", "function", "getName", "(", ")", "{", "if", "(", "$", "this", "->", "name", "===", "false", ")", "{", "$", "this", "->", "name", "=", "$", "this", "->", "pre", ".", "$", "this", "->", "getTime", "(", ")", ".", "'_'", ".", "md5", "(", "mt_rand", "(", ")", ")", ".", "$", "this", "->", "suf", ".", "'.'", ".", "$", "this", "->", "ext", ";", "}", "return", "$", "this", "->", "name", ";", "}" ]
生成文件名 @method getName @since 0.0.1 @return {string}
[ "生成文件名" ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/Manager.php#L196-L201
xiewulong/yii2-fileupload
Manager.php
Manager.getPath
private function getPath() { if($this->path === false) { $this->path = $this->timepath ? date('Y/m/d', $this->getTime()) : ''; } return $this->path; }
php
private function getPath() { if($this->path === false) { $this->path = $this->timepath ? date('Y/m/d', $this->getTime()) : ''; } return $this->path; }
[ "private", "function", "getPath", "(", ")", "{", "if", "(", "$", "this", "->", "path", "===", "false", ")", "{", "$", "this", "->", "path", "=", "$", "this", "->", "timepath", "?", "date", "(", "'Y/m/d'", ",", "$", "this", "->", "getTime", "(", ")", ")", ":", "''", ";", "}", "return", "$", "this", "->", "path", ";", "}" ]
获取存放路径 @method getPath @since 0.0.1 @return {string}
[ "获取存放路径" ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/Manager.php#L209-L215
rhosocial/yii2-user
models/UserUsernameTrait.php
UserUsernameTrait.hasEnabledUsername
public function hasEnabledUsername() { if ($this->usernameClass === false || !is_string($this->usernameClass) || !class_exists($this->usernameClass)) { return false; } return true; }
php
public function hasEnabledUsername() { if ($this->usernameClass === false || !is_string($this->usernameClass) || !class_exists($this->usernameClass)) { return false; } return true; }
[ "public", "function", "hasEnabledUsername", "(", ")", "{", "if", "(", "$", "this", "->", "usernameClass", "===", "false", "||", "!", "is_string", "(", "$", "this", "->", "usernameClass", ")", "||", "!", "class_exists", "(", "$", "this", "->", "usernameClass", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check whether this user enables the username feature or not. @return boolean
[ "Check", "whether", "this", "user", "enables", "the", "username", "feature", "or", "not", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/UserUsernameTrait.php#L33-L39
rhosocial/yii2-user
models/UserUsernameTrait.php
UserUsernameTrait.getUsername
public function getUsername() { if (!$this->hasEnabledUsername()) { return null; } $usernameClass = $this->usernameClass; $noInit = $usernameClass::buildNoInitModel(); /* @var $noInit Username */ return $this->hasOne($usernameClass, [$noInit->createdByAttribute => $this->guidAttribute]); }
php
public function getUsername() { if (!$this->hasEnabledUsername()) { return null; } $usernameClass = $this->usernameClass; $noInit = $usernameClass::buildNoInitModel(); /* @var $noInit Username */ return $this->hasOne($usernameClass, [$noInit->createdByAttribute => $this->guidAttribute]); }
[ "public", "function", "getUsername", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasEnabledUsername", "(", ")", ")", "{", "return", "null", ";", "}", "$", "usernameClass", "=", "$", "this", "->", "usernameClass", ";", "$", "noInit", "=", "$", "usernameClass", "::", "buildNoInitModel", "(", ")", ";", "/* @var $noInit Username */", "return", "$", "this", "->", "hasOne", "(", "$", "usernameClass", ",", "[", "$", "noInit", "->", "createdByAttribute", "=>", "$", "this", "->", "guidAttribute", "]", ")", ";", "}" ]
Get username. This method may return null, please consider processing the abnormal conditions. @return BaseBlameableQuery
[ "Get", "username", ".", "This", "method", "may", "return", "null", "please", "consider", "processing", "the", "abnormal", "conditions", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/UserUsernameTrait.php#L46-L55
rhosocial/yii2-user
models/UserUsernameTrait.php
UserUsernameTrait.createUsername
public function createUsername($username) { if (!$this->hasEnabledUsername()) { return null; } $usernameClass = $this->usernameClass; $model = $usernameClass::findOne($this->getGUID()); if (!$model) { $model = $this->create($usernameClass); $model->setGUID($this->getGUID()); } $model->content = $username; return $model; }
php
public function createUsername($username) { if (!$this->hasEnabledUsername()) { return null; } $usernameClass = $this->usernameClass; $model = $usernameClass::findOne($this->getGUID()); if (!$model) { $model = $this->create($usernameClass); $model->setGUID($this->getGUID()); } $model->content = $username; return $model; }
[ "public", "function", "createUsername", "(", "$", "username", ")", "{", "if", "(", "!", "$", "this", "->", "hasEnabledUsername", "(", ")", ")", "{", "return", "null", ";", "}", "$", "usernameClass", "=", "$", "this", "->", "usernameClass", ";", "$", "model", "=", "$", "usernameClass", "::", "findOne", "(", "$", "this", "->", "getGUID", "(", ")", ")", ";", "if", "(", "!", "$", "model", ")", "{", "$", "model", "=", "$", "this", "->", "create", "(", "$", "usernameClass", ")", ";", "$", "model", "->", "setGUID", "(", "$", "this", "->", "getGUID", "(", ")", ")", ";", "}", "$", "model", "->", "content", "=", "$", "username", ";", "return", "$", "model", ";", "}" ]
Create or get username. @param $username @return null|Username
[ "Create", "or", "get", "username", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/UserUsernameTrait.php#L62-L75
rhosocial/yii2-user
models/UserUsernameTrait.php
UserUsernameTrait.setUsername
public function setUsername($username = null) { if ($username === null && ($model = $this->getUsername()->one())) { return $model->delete() > 0; } if ($username instanceof Username) { $username = $username->content; } $model = $this->createUsername($username); return $model->save(); }
php
public function setUsername($username = null) { if ($username === null && ($model = $this->getUsername()->one())) { return $model->delete() > 0; } if ($username instanceof Username) { $username = $username->content; } $model = $this->createUsername($username); return $model->save(); }
[ "public", "function", "setUsername", "(", "$", "username", "=", "null", ")", "{", "if", "(", "$", "username", "===", "null", "&&", "(", "$", "model", "=", "$", "this", "->", "getUsername", "(", ")", "->", "one", "(", ")", ")", ")", "{", "return", "$", "model", "->", "delete", "(", ")", ">", "0", ";", "}", "if", "(", "$", "username", "instanceof", "Username", ")", "{", "$", "username", "=", "$", "username", "->", "content", ";", "}", "$", "model", "=", "$", "this", "->", "createUsername", "(", "$", "username", ")", ";", "return", "$", "model", "->", "save", "(", ")", ";", "}" ]
Set username. @param string|Username $username @return bool
[ "Set", "username", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/UserUsernameTrait.php#L82-L92
Opifer/EavBundle
Form/Type/ValueProviderType.php
ValueProviderType.configureOptions
public function configureOptions(OptionsResolver $resolver) { $choices = []; foreach ($this->providerPool->getValues() as $alias => $value) { $choices[$alias] = $value->getLabel(); } $resolver->setDefaults([ 'label' => 'Type of value', 'choices' => $choices, ]); }
php
public function configureOptions(OptionsResolver $resolver) { $choices = []; foreach ($this->providerPool->getValues() as $alias => $value) { $choices[$alias] = $value->getLabel(); } $resolver->setDefaults([ 'label' => 'Type of value', 'choices' => $choices, ]); }
[ "public", "function", "configureOptions", "(", "OptionsResolver", "$", "resolver", ")", "{", "$", "choices", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "providerPool", "->", "getValues", "(", ")", "as", "$", "alias", "=>", "$", "value", ")", "{", "$", "choices", "[", "$", "alias", "]", "=", "$", "value", "->", "getLabel", "(", ")", ";", "}", "$", "resolver", "->", "setDefaults", "(", "[", "'label'", "=>", "'Type of value'", ",", "'choices'", "=>", "$", "choices", ",", "]", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/Opifer/EavBundle/blob/4236fdc28b7574dac43f420704d0fc3c04905a4c/Form/Type/ValueProviderType.php#L33-L44
42mate/towel
src/Towel/Controller/User.php
User.profileShow
public function profileShow() { if (!$this->isAuthenticated()) { return $this->redirect('/login'); } $userModel = $this->session()->get('user'); return $this->twig()->render('User\profile.twig', array('user' => $userModel)); }
php
public function profileShow() { if (!$this->isAuthenticated()) { return $this->redirect('/login'); } $userModel = $this->session()->get('user'); return $this->twig()->render('User\profile.twig', array('user' => $userModel)); }
[ "public", "function", "profileShow", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "'/login'", ")", ";", "}", "$", "userModel", "=", "$", "this", "->", "session", "(", ")", "->", "get", "(", "'user'", ")", ";", "return", "$", "this", "->", "twig", "(", ")", "->", "render", "(", "'User\\profile.twig'", ",", "array", "(", "'user'", "=>", "$", "userModel", ")", ")", ";", "}" ]
Shows the profile page. @return string|\Symfony\Component\HttpFoundation\RedirectResponse
[ "Shows", "the", "profile", "page", "." ]
train
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/User.php#L14-L22
42mate/towel
src/Towel/Controller/User.php
User.loginShow
public function loginShow() { if ($this->isAuthenticated()) { $this->setMessage('warning', 'you are already logged in'); return $this->redirect('/'); } return $this->twig()->render('user\login.twig'); }
php
public function loginShow() { if ($this->isAuthenticated()) { $this->setMessage('warning', 'you are already logged in'); return $this->redirect('/'); } return $this->twig()->render('user\login.twig'); }
[ "public", "function", "loginShow", "(", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'warning'", ",", "'you are already logged in'", ")", ";", "return", "$", "this", "->", "redirect", "(", "'/'", ")", ";", "}", "return", "$", "this", "->", "twig", "(", ")", "->", "render", "(", "'user\\login.twig'", ")", ";", "}" ]
Shows the login form. @return string|\Symfony\Component\HttpFoundation\RedirectResponse
[ "Shows", "the", "login", "form", "." ]
train
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/User.php#L29-L37
42mate/towel
src/Towel/Controller/User.php
User.loginAction
public function loginAction($request) { $data = $request->get('data'); $userModel = new ModelUser(); $validUser = $userModel->validateLogin($data['email'], $data['password']); if (!$validUser) { $this->setMessage('danger', 'Not valid user / password combination'); return $this->redirect(url('login')); } $this->session()->set('user', $userModel->record); $this->sessionClearMessages(); return $this->redirect('/'); }
php
public function loginAction($request) { $data = $request->get('data'); $userModel = new ModelUser(); $validUser = $userModel->validateLogin($data['email'], $data['password']); if (!$validUser) { $this->setMessage('danger', 'Not valid user / password combination'); return $this->redirect(url('login')); } $this->session()->set('user', $userModel->record); $this->sessionClearMessages(); return $this->redirect('/'); }
[ "public", "function", "loginAction", "(", "$", "request", ")", "{", "$", "data", "=", "$", "request", "->", "get", "(", "'data'", ")", ";", "$", "userModel", "=", "new", "ModelUser", "(", ")", ";", "$", "validUser", "=", "$", "userModel", "->", "validateLogin", "(", "$", "data", "[", "'email'", "]", ",", "$", "data", "[", "'password'", "]", ")", ";", "if", "(", "!", "$", "validUser", ")", "{", "$", "this", "->", "setMessage", "(", "'danger'", ",", "'Not valid user / password combination'", ")", ";", "return", "$", "this", "->", "redirect", "(", "url", "(", "'login'", ")", ")", ";", "}", "$", "this", "->", "session", "(", ")", "->", "set", "(", "'user'", ",", "$", "userModel", "->", "record", ")", ";", "$", "this", "->", "sessionClearMessages", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "'/'", ")", ";", "}" ]
Handles the login action. @param $request @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Handles", "the", "login", "action", "." ]
train
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/User.php#L46-L60
42mate/towel
src/Towel/Controller/User.php
User.logoutAction
public function logoutAction() { if ($this->isAuthenticated()) { $this->session()->set('user', null); } $this->setMessage('success', 'Bye Bye !'); return $this->redirect('/'); }
php
public function logoutAction() { if ($this->isAuthenticated()) { $this->session()->set('user', null); } $this->setMessage('success', 'Bye Bye !'); return $this->redirect('/'); }
[ "public", "function", "logoutAction", "(", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "this", "->", "session", "(", ")", "->", "set", "(", "'user'", ",", "null", ")", ";", "}", "$", "this", "->", "setMessage", "(", "'success'", ",", "'Bye Bye !'", ")", ";", "return", "$", "this", "->", "redirect", "(", "'/'", ")", ";", "}" ]
Handles the logout actions. @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Handles", "the", "logout", "actions", "." ]
train
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/User.php#L67-L75
42mate/towel
src/Towel/Controller/User.php
User.registerAction
public function registerAction($request) { $modelUser = new ModelUser(); $data = $request->get('data'); $error = false; if ($this->isAuthenticated()) { $this->setMessage('error', 'You are logged in'); $error = true; } if (!filter_var($data['model']['email'], FILTER_VALIDATE_EMAIL)) { $this->setMessage('error', 'That is not an Email'); $error = true; } if ($modelUser->findByName($data['model']['username'])) { $this->setMessage('error', 'Your account exists'); $error = true; } if ($modelUser->findByEmail($data['model']['email'])) { $this->setMessage('error', 'Your Email is already registered'); $error = true; } if (empty($data['model']['password'])) { $this->setMessage('error', 'You need to select a password'); $error = true; } if (empty($data['model']['email'])) { $this->setMessage('error', 'You need to select an email'); $error = true; } if (empty($data['model']['username'])) { $this->setMessage('error', 'You need to select an User Name'); $error = true; } if (!$error) { $modelUser->resetObject(); $modelUser->username = $data['model']['username']; $modelUser->password = md5($data['model']['password']); $modelUser->email = $data['model']['email']; $modelUser->address = $data['model']['address']; $modelUser->phone = $data['model']['phone']; $modelUser->save(); return $this->twig()->render('user\registerAction.twig'); } else { return $this->twig()->render('user\register.twig', array( 'data' => $data )); } }
php
public function registerAction($request) { $modelUser = new ModelUser(); $data = $request->get('data'); $error = false; if ($this->isAuthenticated()) { $this->setMessage('error', 'You are logged in'); $error = true; } if (!filter_var($data['model']['email'], FILTER_VALIDATE_EMAIL)) { $this->setMessage('error', 'That is not an Email'); $error = true; } if ($modelUser->findByName($data['model']['username'])) { $this->setMessage('error', 'Your account exists'); $error = true; } if ($modelUser->findByEmail($data['model']['email'])) { $this->setMessage('error', 'Your Email is already registered'); $error = true; } if (empty($data['model']['password'])) { $this->setMessage('error', 'You need to select a password'); $error = true; } if (empty($data['model']['email'])) { $this->setMessage('error', 'You need to select an email'); $error = true; } if (empty($data['model']['username'])) { $this->setMessage('error', 'You need to select an User Name'); $error = true; } if (!$error) { $modelUser->resetObject(); $modelUser->username = $data['model']['username']; $modelUser->password = md5($data['model']['password']); $modelUser->email = $data['model']['email']; $modelUser->address = $data['model']['address']; $modelUser->phone = $data['model']['phone']; $modelUser->save(); return $this->twig()->render('user\registerAction.twig'); } else { return $this->twig()->render('user\register.twig', array( 'data' => $data )); } }
[ "public", "function", "registerAction", "(", "$", "request", ")", "{", "$", "modelUser", "=", "new", "ModelUser", "(", ")", ";", "$", "data", "=", "$", "request", "->", "get", "(", "'data'", ")", ";", "$", "error", "=", "false", ";", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'You are logged in'", ")", ";", "$", "error", "=", "true", ";", "}", "if", "(", "!", "filter_var", "(", "$", "data", "[", "'model'", "]", "[", "'email'", "]", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'That is not an Email'", ")", ";", "$", "error", "=", "true", ";", "}", "if", "(", "$", "modelUser", "->", "findByName", "(", "$", "data", "[", "'model'", "]", "[", "'username'", "]", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'Your account exists'", ")", ";", "$", "error", "=", "true", ";", "}", "if", "(", "$", "modelUser", "->", "findByEmail", "(", "$", "data", "[", "'model'", "]", "[", "'email'", "]", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'Your Email is already registered'", ")", ";", "$", "error", "=", "true", ";", "}", "if", "(", "empty", "(", "$", "data", "[", "'model'", "]", "[", "'password'", "]", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'You need to select a password'", ")", ";", "$", "error", "=", "true", ";", "}", "if", "(", "empty", "(", "$", "data", "[", "'model'", "]", "[", "'email'", "]", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'You need to select an email'", ")", ";", "$", "error", "=", "true", ";", "}", "if", "(", "empty", "(", "$", "data", "[", "'model'", "]", "[", "'username'", "]", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'You need to select an User Name'", ")", ";", "$", "error", "=", "true", ";", "}", "if", "(", "!", "$", "error", ")", "{", "$", "modelUser", "->", "resetObject", "(", ")", ";", "$", "modelUser", "->", "username", "=", "$", "data", "[", "'model'", "]", "[", "'username'", "]", ";", "$", "modelUser", "->", "password", "=", "md5", "(", "$", "data", "[", "'model'", "]", "[", "'password'", "]", ")", ";", "$", "modelUser", "->", "email", "=", "$", "data", "[", "'model'", "]", "[", "'email'", "]", ";", "$", "modelUser", "->", "address", "=", "$", "data", "[", "'model'", "]", "[", "'address'", "]", ";", "$", "modelUser", "->", "phone", "=", "$", "data", "[", "'model'", "]", "[", "'phone'", "]", ";", "$", "modelUser", "->", "save", "(", ")", ";", "return", "$", "this", "->", "twig", "(", ")", "->", "render", "(", "'user\\registerAction.twig'", ")", ";", "}", "else", "{", "return", "$", "this", "->", "twig", "(", ")", "->", "render", "(", "'user\\register.twig'", ",", "array", "(", "'data'", "=>", "$", "data", ")", ")", ";", "}", "}" ]
Shows register form. @param $request @return string|\Symfony\Component\HttpFoundation\RedirectResponse
[ "Shows", "register", "form", "." ]
train
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/User.php#L94-L150
42mate/towel
src/Towel/Controller/User.php
User.recoverAction
public function recoverAction($request) { $data = $request->get('data'); $modelUser = new ModelUser; if ($this->isAuthenticated()) { $this->setMessage('error', 'Your are already authenticated.'); return $this->redirect('/'); } if (!filter_var($data['model']['email'], FILTER_VALIDATE_EMAIL)) { $this->setMessage('error', 'Thats is not an email'); return $this->redirect('/user/recover'); } if (!$modelUser->findByEmail($data['model']['email'])) { $this->setMessage('error', 'Your are not registered'); return $this->redirect('/user/register'); } //Send the email $password = $modelUser->regeneratePassword(); $to = $modelUser->email; $subject = 'Password from Reader'; $message = 'Your new password is ' . $password; $this->sendMail($to, $subject, $message); return $this->twig()->render('user\recoverAction.twig'); }
php
public function recoverAction($request) { $data = $request->get('data'); $modelUser = new ModelUser; if ($this->isAuthenticated()) { $this->setMessage('error', 'Your are already authenticated.'); return $this->redirect('/'); } if (!filter_var($data['model']['email'], FILTER_VALIDATE_EMAIL)) { $this->setMessage('error', 'Thats is not an email'); return $this->redirect('/user/recover'); } if (!$modelUser->findByEmail($data['model']['email'])) { $this->setMessage('error', 'Your are not registered'); return $this->redirect('/user/register'); } //Send the email $password = $modelUser->regeneratePassword(); $to = $modelUser->email; $subject = 'Password from Reader'; $message = 'Your new password is ' . $password; $this->sendMail($to, $subject, $message); return $this->twig()->render('user\recoverAction.twig'); }
[ "public", "function", "recoverAction", "(", "$", "request", ")", "{", "$", "data", "=", "$", "request", "->", "get", "(", "'data'", ")", ";", "$", "modelUser", "=", "new", "ModelUser", ";", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'Your are already authenticated.'", ")", ";", "return", "$", "this", "->", "redirect", "(", "'/'", ")", ";", "}", "if", "(", "!", "filter_var", "(", "$", "data", "[", "'model'", "]", "[", "'email'", "]", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'Thats is not an email'", ")", ";", "return", "$", "this", "->", "redirect", "(", "'/user/recover'", ")", ";", "}", "if", "(", "!", "$", "modelUser", "->", "findByEmail", "(", "$", "data", "[", "'model'", "]", "[", "'email'", "]", ")", ")", "{", "$", "this", "->", "setMessage", "(", "'error'", ",", "'Your are not registered'", ")", ";", "return", "$", "this", "->", "redirect", "(", "'/user/register'", ")", ";", "}", "//Send the email", "$", "password", "=", "$", "modelUser", "->", "regeneratePassword", "(", ")", ";", "$", "to", "=", "$", "modelUser", "->", "email", ";", "$", "subject", "=", "'Password from Reader'", ";", "$", "message", "=", "'Your new password is '", ".", "$", "password", ";", "$", "this", "->", "sendMail", "(", "$", "to", ",", "$", "subject", ",", "$", "message", ")", ";", "return", "$", "this", "->", "twig", "(", ")", "->", "render", "(", "'user\\recoverAction.twig'", ")", ";", "}" ]
Handles the recover action. @param $request @return string|\Symfony\Component\HttpFoundation\RedirectResponse
[ "Handles", "the", "recover", "action", "." ]
train
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/User.php#L169-L197
buse974/JRpc
src/JRpc/Json/Server/Server.php
Server.handleRequest
protected function handleRequest() { try { $request = $this->getRequest(); if ($request->isParseError() === true) { throw new ParseErrorException(); } $this->events->trigger('sendRequest.pre', $this, array('methode' => $request->getMethod())); if (($ret = $this->getParentHandle()) instanceof RPCERROR && ($ret = $ret->getData()) instanceof \Exception) { throw $ret; } } catch (AbstractException $e) { if(isset($this->options['log'])) { $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage()); } return $this->fault($e->getMessage(), $e->getCode()); } catch (\Exception $e) { if(isset($this->options['log'])) { $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getTrace()); } return ((isset($this->options['environment']) && $this->options['environment'] === "dev")) ? $this->fault('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getCode(), $e->getTrace()) : $this->fault('Internal error', RPCERROR::ERROR_INTERNAL); } }
php
protected function handleRequest() { try { $request = $this->getRequest(); if ($request->isParseError() === true) { throw new ParseErrorException(); } $this->events->trigger('sendRequest.pre', $this, array('methode' => $request->getMethod())); if (($ret = $this->getParentHandle()) instanceof RPCERROR && ($ret = $ret->getData()) instanceof \Exception) { throw $ret; } } catch (AbstractException $e) { if(isset($this->options['log'])) { $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage()); } return $this->fault($e->getMessage(), $e->getCode()); } catch (\Exception $e) { if(isset($this->options['log'])) { $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getTrace()); } return ((isset($this->options['environment']) && $this->options['environment'] === "dev")) ? $this->fault('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getCode(), $e->getTrace()) : $this->fault('Internal error', RPCERROR::ERROR_INTERNAL); } }
[ "protected", "function", "handleRequest", "(", ")", "{", "try", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "if", "(", "$", "request", "->", "isParseError", "(", ")", "===", "true", ")", "{", "throw", "new", "ParseErrorException", "(", ")", ";", "}", "$", "this", "->", "events", "->", "trigger", "(", "'sendRequest.pre'", ",", "$", "this", ",", "array", "(", "'methode'", "=>", "$", "request", "->", "getMethod", "(", ")", ")", ")", ";", "if", "(", "(", "$", "ret", "=", "$", "this", "->", "getParentHandle", "(", ")", ")", "instanceof", "RPCERROR", "&&", "(", "$", "ret", "=", "$", "ret", "->", "getData", "(", ")", ")", "instanceof", "\\", "Exception", ")", "{", "throw", "$", "ret", ";", "}", "}", "catch", "(", "AbstractException", "$", "e", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'log'", "]", ")", ")", "{", "$", "this", "->", "container", "->", "get", "(", "$", "this", "->", "options", "[", "'log'", "]", ")", "->", "err", "(", "'('", ".", "$", "e", "->", "getCode", "(", ")", ".", "') '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", "->", "fault", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'log'", "]", ")", ")", "{", "$", "this", "->", "container", "->", "get", "(", "$", "this", "->", "options", "[", "'log'", "]", ")", "->", "err", "(", "'('", ".", "$", "e", "->", "getCode", "(", ")", ".", "') '", ".", "$", "e", "->", "getMessage", "(", ")", ".", "' in '", ".", "$", "e", "->", "getFile", "(", ")", ".", "' line '", ".", "$", "e", "->", "getLine", "(", ")", ",", "$", "e", "->", "getTrace", "(", ")", ")", ";", "}", "return", "(", "(", "isset", "(", "$", "this", "->", "options", "[", "'environment'", "]", ")", "&&", "$", "this", "->", "options", "[", "'environment'", "]", "===", "\"dev\"", ")", ")", "?", "$", "this", "->", "fault", "(", "'('", ".", "$", "e", "->", "getCode", "(", ")", ".", "') '", ".", "$", "e", "->", "getMessage", "(", ")", ".", "' in '", ".", "$", "e", "->", "getFile", "(", ")", ".", "' line '", ".", "$", "e", "->", "getLine", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getTrace", "(", ")", ")", ":", "$", "this", "->", "fault", "(", "'Internal error'", ",", "RPCERROR", "::", "ERROR_INTERNAL", ")", ";", "}", "}" ]
(non-PHPdoc). @see \Zend\Json\Server\Server::_handle()
[ "(", "non", "-", "PHPdoc", ")", "." ]
train
https://github.com/buse974/JRpc/blob/c6100a5984d20a1ea00c43d41d3a022f2878b17f/src/JRpc/Json/Server/Server.php#L76-L98
buse974/JRpc
src/JRpc/Json/Server/Server.php
Server._dispatch
public function _dispatch(\Zend\Server\Method\Definition $invocable, array $params) { return call_user_func_array(array($this->container->get($invocable->getNameSm()),$invocable->getCallback()->getMethod()), $params); }
php
public function _dispatch(\Zend\Server\Method\Definition $invocable, array $params) { return call_user_func_array(array($this->container->get($invocable->getNameSm()),$invocable->getCallback()->getMethod()), $params); }
[ "public", "function", "_dispatch", "(", "\\", "Zend", "\\", "Server", "\\", "Method", "\\", "Definition", "$", "invocable", ",", "array", "$", "params", ")", "{", "return", "call_user_func_array", "(", "array", "(", "$", "this", "->", "container", "->", "get", "(", "$", "invocable", "->", "getNameSm", "(", ")", ")", ",", "$", "invocable", "->", "getCallback", "(", ")", "->", "getMethod", "(", ")", ")", ",", "$", "params", ")", ";", "}" ]
(non-PHPdoc). @see \Zend\Server\AbstractServer::_dispatch()
[ "(", "non", "-", "PHPdoc", ")", "." ]
train
https://github.com/buse974/JRpc/blob/c6100a5984d20a1ea00c43d41d3a022f2878b17f/src/JRpc/Json/Server/Server.php#L117-L120
buse974/JRpc
src/JRpc/Json/Server/Server.php
Server.initializeClass
public function initializeClass() { if (!isset($this->options['services']) || !is_array($this->options['services'])) { return; } if ($this->getPersistence() && $this->getCache() !== null && ($definition = $this->getCache()->getItem('jrpc-definition')) !== null && ($serviceMap = $this->getCache()->getItem('jrpc-serviceMap')) !== null) { $this->table = $definition; $this->serviceMap = $serviceMap; return; } foreach ($this->options['services'] as $c) { $this->setClass($c, ((isset($c['namespace'])) ? $c['namespace'] : '')); } if ($this->getPersistence() && $this->getCache() !== null) { $this->getCache()->setItem('jrpc-definition', $this->table); $this->getCache()->setItem('jrpc-serviceMap', $this->serviceMap); } }
php
public function initializeClass() { if (!isset($this->options['services']) || !is_array($this->options['services'])) { return; } if ($this->getPersistence() && $this->getCache() !== null && ($definition = $this->getCache()->getItem('jrpc-definition')) !== null && ($serviceMap = $this->getCache()->getItem('jrpc-serviceMap')) !== null) { $this->table = $definition; $this->serviceMap = $serviceMap; return; } foreach ($this->options['services'] as $c) { $this->setClass($c, ((isset($c['namespace'])) ? $c['namespace'] : '')); } if ($this->getPersistence() && $this->getCache() !== null) { $this->getCache()->setItem('jrpc-definition', $this->table); $this->getCache()->setItem('jrpc-serviceMap', $this->serviceMap); } }
[ "public", "function", "initializeClass", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "'services'", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "options", "[", "'services'", "]", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "getPersistence", "(", ")", "&&", "$", "this", "->", "getCache", "(", ")", "!==", "null", "&&", "(", "$", "definition", "=", "$", "this", "->", "getCache", "(", ")", "->", "getItem", "(", "'jrpc-definition'", ")", ")", "!==", "null", "&&", "(", "$", "serviceMap", "=", "$", "this", "->", "getCache", "(", ")", "->", "getItem", "(", "'jrpc-serviceMap'", ")", ")", "!==", "null", ")", "{", "$", "this", "->", "table", "=", "$", "definition", ";", "$", "this", "->", "serviceMap", "=", "$", "serviceMap", ";", "return", ";", "}", "foreach", "(", "$", "this", "->", "options", "[", "'services'", "]", "as", "$", "c", ")", "{", "$", "this", "->", "setClass", "(", "$", "c", ",", "(", "(", "isset", "(", "$", "c", "[", "'namespace'", "]", ")", ")", "?", "$", "c", "[", "'namespace'", "]", ":", "''", ")", ")", ";", "}", "if", "(", "$", "this", "->", "getPersistence", "(", ")", "&&", "$", "this", "->", "getCache", "(", ")", "!==", "null", ")", "{", "$", "this", "->", "getCache", "(", ")", "->", "setItem", "(", "'jrpc-definition'", ",", "$", "this", "->", "table", ")", ";", "$", "this", "->", "getCache", "(", ")", "->", "setItem", "(", "'jrpc-serviceMap'", ",", "$", "this", "->", "serviceMap", ")", ";", "}", "}" ]
Initialize all class.
[ "Initialize", "all", "class", "." ]
train
https://github.com/buse974/JRpc/blob/c6100a5984d20a1ea00c43d41d3a022f2878b17f/src/JRpc/Json/Server/Server.php#L125-L146
buse974/JRpc
src/JRpc/Json/Server/Server.php
Server.setClass
public function setClass($class, $namespace = '', $argv = null) { if (2 < func_num_args()) { $argv = func_get_args(); $argv = array_slice($argv, 2); } $methods = []; if (is_array($class)) { $methods = $class['methods']; $class = $class['class']; } $obj = $class; if ($this->container->has($class)) { $obj = $this->container->get($class); } $reflection = Reflection::reflectClass($obj, $argv, $namespace); foreach ($reflection->getMethods() as $method) { $docComment = $method->getDocComment(); if (($docComment !== false && (new DocBlockReflection($docComment))->hasTag('invokable')) || in_array($method->getName(), $methods)) { $definition = $this->_buildSignature($method, $class); $this->addMethodServiceMap($definition); } } return $this; }
php
public function setClass($class, $namespace = '', $argv = null) { if (2 < func_num_args()) { $argv = func_get_args(); $argv = array_slice($argv, 2); } $methods = []; if (is_array($class)) { $methods = $class['methods']; $class = $class['class']; } $obj = $class; if ($this->container->has($class)) { $obj = $this->container->get($class); } $reflection = Reflection::reflectClass($obj, $argv, $namespace); foreach ($reflection->getMethods() as $method) { $docComment = $method->getDocComment(); if (($docComment !== false && (new DocBlockReflection($docComment))->hasTag('invokable')) || in_array($method->getName(), $methods)) { $definition = $this->_buildSignature($method, $class); $this->addMethodServiceMap($definition); } } return $this; }
[ "public", "function", "setClass", "(", "$", "class", ",", "$", "namespace", "=", "''", ",", "$", "argv", "=", "null", ")", "{", "if", "(", "2", "<", "func_num_args", "(", ")", ")", "{", "$", "argv", "=", "func_get_args", "(", ")", ";", "$", "argv", "=", "array_slice", "(", "$", "argv", ",", "2", ")", ";", "}", "$", "methods", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "class", ")", ")", "{", "$", "methods", "=", "$", "class", "[", "'methods'", "]", ";", "$", "class", "=", "$", "class", "[", "'class'", "]", ";", "}", "$", "obj", "=", "$", "class", ";", "if", "(", "$", "this", "->", "container", "->", "has", "(", "$", "class", ")", ")", "{", "$", "obj", "=", "$", "this", "->", "container", "->", "get", "(", "$", "class", ")", ";", "}", "$", "reflection", "=", "Reflection", "::", "reflectClass", "(", "$", "obj", ",", "$", "argv", ",", "$", "namespace", ")", ";", "foreach", "(", "$", "reflection", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "$", "docComment", "=", "$", "method", "->", "getDocComment", "(", ")", ";", "if", "(", "(", "$", "docComment", "!==", "false", "&&", "(", "new", "DocBlockReflection", "(", "$", "docComment", ")", ")", "->", "hasTag", "(", "'invokable'", ")", ")", "||", "in_array", "(", "$", "method", "->", "getName", "(", ")", ",", "$", "methods", ")", ")", "{", "$", "definition", "=", "$", "this", "->", "_buildSignature", "(", "$", "method", ",", "$", "class", ")", ";", "$", "this", "->", "addMethodServiceMap", "(", "$", "definition", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
(non-PHPdoc). @see \Zend\Json\Server\Server::setClass()
[ "(", "non", "-", "PHPdoc", ")", "." ]
train
https://github.com/buse974/JRpc/blob/c6100a5984d20a1ea00c43d41d3a022f2878b17f/src/JRpc/Json/Server/Server.php#L195-L224
buse974/JRpc
src/JRpc/Json/Server/Server.php
Server._buildSignature
protected function _buildSignature(Reflection\AbstractFunction $reflection, $class = null) { $ns = $reflection->getNamespace(); $name = $reflection->getName(); $shortName = $reflection->getDeclaringClass()->getShortName(); $method = empty($ns) ? strtolower($shortName) . '.' . $name : $ns . '.' . $name; // Ignore Because copy to parent::_buildSignature // @codeCoverageIgnoreStart if (! $this->overwriteExistingMethods && $this->table->hasMethod($method)) { throw new Exception\RuntimeException('Duplicate method registered: ' . $method); } // @codeCoverageIgnoreEnd $definition = new Method\Definition(); $definition->setName($method) ->setCallback($this->_buildCallback($reflection)) ->setMethodHelp($reflection->getDescription()) ->setInvokeArguments($reflection->getInvokeArguments()); foreach ($reflection->getPrototypes() as $proto) { $prototype = new Prototype(); $prototype->setReturnType($this->_fixType($proto->getReturnType())); foreach ($proto->getParameters() as $parameter) { $param = new Parameter(array('type' => $this->_fixType($parameter->getType()),'name' => $parameter->getName(),'optional' => $parameter->isOptional())); // Ignore Because copy to parent::_buildSignature // @codeCoverageIgnoreStart if ($parameter->isDefaultValueAvailable()) { $param->setDefaultValue($parameter->getDefaultValue()); } // @codeCoverageIgnoreEnd $prototype->addParameter($param); } $definition->addPrototype($prototype); } if (is_object($class)) { // Ignore Because copy to parent::_buildSignature // @codeCoverageIgnoreStart $definition->setObject($class); // @codeCoverageIgnoreEnd } elseif ($this->container->has($class)) { $definition->setNameSm($class); } $this->table->addMethod($definition); return $definition; }
php
protected function _buildSignature(Reflection\AbstractFunction $reflection, $class = null) { $ns = $reflection->getNamespace(); $name = $reflection->getName(); $shortName = $reflection->getDeclaringClass()->getShortName(); $method = empty($ns) ? strtolower($shortName) . '.' . $name : $ns . '.' . $name; // Ignore Because copy to parent::_buildSignature // @codeCoverageIgnoreStart if (! $this->overwriteExistingMethods && $this->table->hasMethod($method)) { throw new Exception\RuntimeException('Duplicate method registered: ' . $method); } // @codeCoverageIgnoreEnd $definition = new Method\Definition(); $definition->setName($method) ->setCallback($this->_buildCallback($reflection)) ->setMethodHelp($reflection->getDescription()) ->setInvokeArguments($reflection->getInvokeArguments()); foreach ($reflection->getPrototypes() as $proto) { $prototype = new Prototype(); $prototype->setReturnType($this->_fixType($proto->getReturnType())); foreach ($proto->getParameters() as $parameter) { $param = new Parameter(array('type' => $this->_fixType($parameter->getType()),'name' => $parameter->getName(),'optional' => $parameter->isOptional())); // Ignore Because copy to parent::_buildSignature // @codeCoverageIgnoreStart if ($parameter->isDefaultValueAvailable()) { $param->setDefaultValue($parameter->getDefaultValue()); } // @codeCoverageIgnoreEnd $prototype->addParameter($param); } $definition->addPrototype($prototype); } if (is_object($class)) { // Ignore Because copy to parent::_buildSignature // @codeCoverageIgnoreStart $definition->setObject($class); // @codeCoverageIgnoreEnd } elseif ($this->container->has($class)) { $definition->setNameSm($class); } $this->table->addMethod($definition); return $definition; }
[ "protected", "function", "_buildSignature", "(", "Reflection", "\\", "AbstractFunction", "$", "reflection", ",", "$", "class", "=", "null", ")", "{", "$", "ns", "=", "$", "reflection", "->", "getNamespace", "(", ")", ";", "$", "name", "=", "$", "reflection", "->", "getName", "(", ")", ";", "$", "shortName", "=", "$", "reflection", "->", "getDeclaringClass", "(", ")", "->", "getShortName", "(", ")", ";", "$", "method", "=", "empty", "(", "$", "ns", ")", "?", "strtolower", "(", "$", "shortName", ")", ".", "'.'", ".", "$", "name", ":", "$", "ns", ".", "'.'", ".", "$", "name", ";", "// Ignore Because copy to parent::_buildSignature", "// @codeCoverageIgnoreStart", "if", "(", "!", "$", "this", "->", "overwriteExistingMethods", "&&", "$", "this", "->", "table", "->", "hasMethod", "(", "$", "method", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "'Duplicate method registered: '", ".", "$", "method", ")", ";", "}", "// @codeCoverageIgnoreEnd", "$", "definition", "=", "new", "Method", "\\", "Definition", "(", ")", ";", "$", "definition", "->", "setName", "(", "$", "method", ")", "->", "setCallback", "(", "$", "this", "->", "_buildCallback", "(", "$", "reflection", ")", ")", "->", "setMethodHelp", "(", "$", "reflection", "->", "getDescription", "(", ")", ")", "->", "setInvokeArguments", "(", "$", "reflection", "->", "getInvokeArguments", "(", ")", ")", ";", "foreach", "(", "$", "reflection", "->", "getPrototypes", "(", ")", "as", "$", "proto", ")", "{", "$", "prototype", "=", "new", "Prototype", "(", ")", ";", "$", "prototype", "->", "setReturnType", "(", "$", "this", "->", "_fixType", "(", "$", "proto", "->", "getReturnType", "(", ")", ")", ")", ";", "foreach", "(", "$", "proto", "->", "getParameters", "(", ")", "as", "$", "parameter", ")", "{", "$", "param", "=", "new", "Parameter", "(", "array", "(", "'type'", "=>", "$", "this", "->", "_fixType", "(", "$", "parameter", "->", "getType", "(", ")", ")", ",", "'name'", "=>", "$", "parameter", "->", "getName", "(", ")", ",", "'optional'", "=>", "$", "parameter", "->", "isOptional", "(", ")", ")", ")", ";", "// Ignore Because copy to parent::_buildSignature", "// @codeCoverageIgnoreStart", "if", "(", "$", "parameter", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "$", "param", "->", "setDefaultValue", "(", "$", "parameter", "->", "getDefaultValue", "(", ")", ")", ";", "}", "// @codeCoverageIgnoreEnd", "$", "prototype", "->", "addParameter", "(", "$", "param", ")", ";", "}", "$", "definition", "->", "addPrototype", "(", "$", "prototype", ")", ";", "}", "if", "(", "is_object", "(", "$", "class", ")", ")", "{", "// Ignore Because copy to parent::_buildSignature", "// @codeCoverageIgnoreStart", "$", "definition", "->", "setObject", "(", "$", "class", ")", ";", "// @codeCoverageIgnoreEnd", "}", "elseif", "(", "$", "this", "->", "container", "->", "has", "(", "$", "class", ")", ")", "{", "$", "definition", "->", "setNameSm", "(", "$", "class", ")", ";", "}", "$", "this", "->", "table", "->", "addMethod", "(", "$", "definition", ")", ";", "return", "$", "definition", ";", "}" ]
(non-PHPdoc). @see \Zend\Server\AbstractServer::_buildSignature()
[ "(", "non", "-", "PHPdoc", ")", "." ]
train
https://github.com/buse974/JRpc/blob/c6100a5984d20a1ea00c43d41d3a022f2878b17f/src/JRpc/Json/Server/Server.php#L231-L277
buse974/JRpc
src/JRpc/Json/Server/Server.php
Server.getPersistence
public function getPersistence() { if (null === $this->persistence) { $this->persistence = (isset($this->options['persistence']) && $this->options['persistence'] == true); } return $this->persistence; }
php
public function getPersistence() { if (null === $this->persistence) { $this->persistence = (isset($this->options['persistence']) && $this->options['persistence'] == true); } return $this->persistence; }
[ "public", "function", "getPersistence", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "persistence", ")", "{", "$", "this", "->", "persistence", "=", "(", "isset", "(", "$", "this", "->", "options", "[", "'persistence'", "]", ")", "&&", "$", "this", "->", "options", "[", "'persistence'", "]", "==", "true", ")", ";", "}", "return", "$", "this", "->", "persistence", ";", "}" ]
Check persistance. @return bool
[ "Check", "persistance", "." ]
train
https://github.com/buse974/JRpc/blob/c6100a5984d20a1ea00c43d41d3a022f2878b17f/src/JRpc/Json/Server/Server.php#L296-L303
buse974/JRpc
src/JRpc/Json/Server/Server.php
Server.getCache
public function getCache() { if (null === $this->cache) { if (isset($this->options['cache']) && is_string($this->options['cache'])) { $this->cache = $this->container->get($this->options['cache']); } } return $this->cache; }
php
public function getCache() { if (null === $this->cache) { if (isset($this->options['cache']) && is_string($this->options['cache'])) { $this->cache = $this->container->get($this->options['cache']); } } return $this->cache; }
[ "public", "function", "getCache", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "cache", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'cache'", "]", ")", "&&", "is_string", "(", "$", "this", "->", "options", "[", "'cache'", "]", ")", ")", "{", "$", "this", "->", "cache", "=", "$", "this", "->", "container", "->", "get", "(", "$", "this", "->", "options", "[", "'cache'", "]", ")", ";", "}", "}", "return", "$", "this", "->", "cache", ";", "}" ]
Get Storage if define in config. @return \Zend\Cache\Storage\StorageInterface|null
[ "Get", "Storage", "if", "define", "in", "config", "." ]
train
https://github.com/buse974/JRpc/blob/c6100a5984d20a1ea00c43d41d3a022f2878b17f/src/JRpc/Json/Server/Server.php#L310-L319
buse974/JRpc
src/JRpc/Json/Server/Server.php
Server.setEventManager
public function setEventManager(\Zend\EventManager\EventManagerInterface $events) { $this->events = $events; $this->events->setIdentifiers([__CLASS__,get_called_class()]); return $this; }
php
public function setEventManager(\Zend\EventManager\EventManagerInterface $events) { $this->events = $events; $this->events->setIdentifiers([__CLASS__,get_called_class()]); return $this; }
[ "public", "function", "setEventManager", "(", "\\", "Zend", "\\", "EventManager", "\\", "EventManagerInterface", "$", "events", ")", "{", "$", "this", "->", "events", "=", "$", "events", ";", "$", "this", "->", "events", "->", "setIdentifiers", "(", "[", "__CLASS__", ",", "get_called_class", "(", ")", "]", ")", ";", "return", "$", "this", ";", "}" ]
Inject an EventManager instance. @param \Zend\EventManager\EventManagerInterface $eventManager
[ "Inject", "an", "EventManager", "instance", "." ]
train
https://github.com/buse974/JRpc/blob/c6100a5984d20a1ea00c43d41d3a022f2878b17f/src/JRpc/Json/Server/Server.php#L326-L332
rhosocial/yii2-user
User.php
User.getCacheTag
public function getCacheTag() { return $this->cacheTagPrefix . ($this->isAttributeChanged($this->idAttribute) ? $this->getOldAttribute($this->idAttribute) : $this->getID()); }
php
public function getCacheTag() { return $this->cacheTagPrefix . ($this->isAttributeChanged($this->idAttribute) ? $this->getOldAttribute($this->idAttribute) : $this->getID()); }
[ "public", "function", "getCacheTag", "(", ")", "{", "return", "$", "this", "->", "cacheTagPrefix", ".", "(", "$", "this", "->", "isAttributeChanged", "(", "$", "this", "->", "idAttribute", ")", "?", "$", "this", "->", "getOldAttribute", "(", "$", "this", "->", "idAttribute", ")", ":", "$", "this", "->", "getID", "(", ")", ")", ";", "}" ]
Get cache tag. The cache tag ends with the user ID, but after the user ID is modified, the old ID will prevail. @return string
[ "Get", "cache", "tag", ".", "The", "cache", "tag", "ends", "with", "the", "user", "ID", "but", "after", "the", "user", "ID", "is", "modified", "the", "old", "ID", "will", "prevail", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/User.php#L199-L203
rhosocial/yii2-user
User.php
User.createProfile
public function createProfile($config = []) { $profileClass = $this->profileClass; if (empty($profileClass) || !is_string($this->profileClass)) { return null; } $profile = $profileClass::findOne($this->getGUID()); if (!$profile) { $profile = $this->create($profileClass, $config); $profile->setGUID($this->getGUID()); } return $profile; }
php
public function createProfile($config = []) { $profileClass = $this->profileClass; if (empty($profileClass) || !is_string($this->profileClass)) { return null; } $profile = $profileClass::findOne($this->getGUID()); if (!$profile) { $profile = $this->create($profileClass, $config); $profile->setGUID($this->getGUID()); } return $profile; }
[ "public", "function", "createProfile", "(", "$", "config", "=", "[", "]", ")", "{", "$", "profileClass", "=", "$", "this", "->", "profileClass", ";", "if", "(", "empty", "(", "$", "profileClass", ")", "||", "!", "is_string", "(", "$", "this", "->", "profileClass", ")", ")", "{", "return", "null", ";", "}", "$", "profile", "=", "$", "profileClass", "::", "findOne", "(", "$", "this", "->", "getGUID", "(", ")", ")", ";", "if", "(", "!", "$", "profile", ")", "{", "$", "profile", "=", "$", "this", "->", "create", "(", "$", "profileClass", ",", "$", "config", ")", ";", "$", "profile", "->", "setGUID", "(", "$", "this", "->", "getGUID", "(", ")", ")", ";", "}", "return", "$", "profile", ";", "}" ]
Create profile. If profile of this user exists, it will be returned instead of creating it. Meanwhile, the $config parameter will be skipped. @param array $config Profile configuration. Skipped if it exists. @return Profile
[ "Create", "profile", ".", "If", "profile", "of", "this", "user", "exists", "it", "will", "be", "returned", "instead", "of", "creating", "it", ".", "Meanwhile", "the", "$config", "parameter", "will", "be", "skipped", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/User.php#L228-L240
rhosocial/yii2-user
User.php
User.getProfile
public function getProfile() { if (!$this->hasProfile()) { return null; } $profileClass = $this->profileClass; $profileModel = $profileClass::buildNoInitModel(); return $this->hasOne($profileClass, [$profileModel->createdByAttribute => $this->guidAttribute])->inverseOf('user'); }
php
public function getProfile() { if (!$this->hasProfile()) { return null; } $profileClass = $this->profileClass; $profileModel = $profileClass::buildNoInitModel(); return $this->hasOne($profileClass, [$profileModel->createdByAttribute => $this->guidAttribute])->inverseOf('user'); }
[ "public", "function", "getProfile", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasProfile", "(", ")", ")", "{", "return", "null", ";", "}", "$", "profileClass", "=", "$", "this", "->", "profileClass", ";", "$", "profileModel", "=", "$", "profileClass", "::", "buildNoInitModel", "(", ")", ";", "return", "$", "this", "->", "hasOne", "(", "$", "profileClass", ",", "[", "$", "profileModel", "->", "createdByAttribute", "=>", "$", "this", "->", "guidAttribute", "]", ")", "->", "inverseOf", "(", "'user'", ")", ";", "}" ]
Get Profile query. If you want to get profile model, please access this method in magic property way, like following: ```php $user->profile; ``` @return BaseBlameableQuery
[ "Get", "Profile", "query", ".", "If", "you", "want", "to", "get", "profile", "model", "please", "access", "this", "method", "in", "magic", "property", "way", "like", "following", ":" ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/User.php#L265-L274
zicht/z
src/Zicht/Tool/Configuration/ConfigurationLoader.php
ConfigurationLoader.fromEnv
public static function fromEnv($configFilename, Version $version) { if (null === $configFilename) { $configFilename = getenv('ZFILE') ? getenv('ZFILE') : 'z.yml'; } return new self( $configFilename, new PathDefaultFileLocator('ZPATH', array(getcwd(), getenv('HOME') . '/.config/z')), new FileLoader( new PathDefaultFileLocator( 'ZPLUGINPATH', array(ZPREFIX . '/vendor/zicht/z-plugins/', getcwd()) ), $version ) ); }
php
public static function fromEnv($configFilename, Version $version) { if (null === $configFilename) { $configFilename = getenv('ZFILE') ? getenv('ZFILE') : 'z.yml'; } return new self( $configFilename, new PathDefaultFileLocator('ZPATH', array(getcwd(), getenv('HOME') . '/.config/z')), new FileLoader( new PathDefaultFileLocator( 'ZPLUGINPATH', array(ZPREFIX . '/vendor/zicht/z-plugins/', getcwd()) ), $version ) ); }
[ "public", "static", "function", "fromEnv", "(", "$", "configFilename", ",", "Version", "$", "version", ")", "{", "if", "(", "null", "===", "$", "configFilename", ")", "{", "$", "configFilename", "=", "getenv", "(", "'ZFILE'", ")", "?", "getenv", "(", "'ZFILE'", ")", ":", "'z.yml'", ";", "}", "return", "new", "self", "(", "$", "configFilename", ",", "new", "PathDefaultFileLocator", "(", "'ZPATH'", ",", "array", "(", "getcwd", "(", ")", ",", "getenv", "(", "'HOME'", ")", ".", "'/.config/z'", ")", ")", ",", "new", "FileLoader", "(", "new", "PathDefaultFileLocator", "(", "'ZPLUGINPATH'", ",", "array", "(", "ZPREFIX", ".", "'/vendor/zicht/z-plugins/'", ",", "getcwd", "(", ")", ")", ")", ",", "$", "version", ")", ")", ";", "}" ]
Create the configuration loader based the current shell environment variables. @param string $configFilename @param Version $version @return ConfigurationLoader @codeCoverageIgnore
[ "Create", "the", "configuration", "loader", "based", "the", "current", "shell", "environment", "variables", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Configuration/ConfigurationLoader.php#L29-L46
zicht/z
src/Zicht/Tool/Configuration/ConfigurationLoader.php
ConfigurationLoader.processConfiguration
public function processConfiguration() { Debug::enterScope('config'); Debug::enterScope('load'); try { $zfiles = (array)$this->configLocator->locate($this->configFilename, null, false); } catch (\InvalidArgumentException $e) { $zfiles = array(); } foreach ($zfiles as $file) { Debug::enterScope($file); $this->sourceFiles[] = $file; $this->loader->load($file); Debug::exitScope($file); } foreach ($this->loader->getPlugins() as $name => $file) { Debug::enterScope($file); $this->sourceFiles[] = $file; $this->loadPlugin($name, $file); Debug::exitScope($file); } Debug::exitScope('load'); Debug::enterScope('process'); $processor = new Processor(); $ret = $processor->processConfiguration( new Configuration($this->plugins), $this->loader->getConfigs() ); Debug::exitScope('process'); Debug::exitScope('config'); return $ret; }
php
public function processConfiguration() { Debug::enterScope('config'); Debug::enterScope('load'); try { $zfiles = (array)$this->configLocator->locate($this->configFilename, null, false); } catch (\InvalidArgumentException $e) { $zfiles = array(); } foreach ($zfiles as $file) { Debug::enterScope($file); $this->sourceFiles[] = $file; $this->loader->load($file); Debug::exitScope($file); } foreach ($this->loader->getPlugins() as $name => $file) { Debug::enterScope($file); $this->sourceFiles[] = $file; $this->loadPlugin($name, $file); Debug::exitScope($file); } Debug::exitScope('load'); Debug::enterScope('process'); $processor = new Processor(); $ret = $processor->processConfiguration( new Configuration($this->plugins), $this->loader->getConfigs() ); Debug::exitScope('process'); Debug::exitScope('config'); return $ret; }
[ "public", "function", "processConfiguration", "(", ")", "{", "Debug", "::", "enterScope", "(", "'config'", ")", ";", "Debug", "::", "enterScope", "(", "'load'", ")", ";", "try", "{", "$", "zfiles", "=", "(", "array", ")", "$", "this", "->", "configLocator", "->", "locate", "(", "$", "this", "->", "configFilename", ",", "null", ",", "false", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "$", "zfiles", "=", "array", "(", ")", ";", "}", "foreach", "(", "$", "zfiles", "as", "$", "file", ")", "{", "Debug", "::", "enterScope", "(", "$", "file", ")", ";", "$", "this", "->", "sourceFiles", "[", "]", "=", "$", "file", ";", "$", "this", "->", "loader", "->", "load", "(", "$", "file", ")", ";", "Debug", "::", "exitScope", "(", "$", "file", ")", ";", "}", "foreach", "(", "$", "this", "->", "loader", "->", "getPlugins", "(", ")", "as", "$", "name", "=>", "$", "file", ")", "{", "Debug", "::", "enterScope", "(", "$", "file", ")", ";", "$", "this", "->", "sourceFiles", "[", "]", "=", "$", "file", ";", "$", "this", "->", "loadPlugin", "(", "$", "name", ",", "$", "file", ")", ";", "Debug", "::", "exitScope", "(", "$", "file", ")", ";", "}", "Debug", "::", "exitScope", "(", "'load'", ")", ";", "Debug", "::", "enterScope", "(", "'process'", ")", ";", "$", "processor", "=", "new", "Processor", "(", ")", ";", "$", "ret", "=", "$", "processor", "->", "processConfiguration", "(", "new", "Configuration", "(", "$", "this", "->", "plugins", ")", ",", "$", "this", "->", "loader", "->", "getConfigs", "(", ")", ")", ";", "Debug", "::", "exitScope", "(", "'process'", ")", ";", "Debug", "::", "exitScope", "(", "'config'", ")", ";", "return", "$", "ret", ";", "}" ]
Processes the configuration contents @return array @throws \UnexpectedValueException
[ "Processes", "the", "configuration", "contents" ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Configuration/ConfigurationLoader.php#L89-L121
zicht/z
src/Zicht/Tool/Configuration/ConfigurationLoader.php
ConfigurationLoader.loadPlugin
protected function loadPlugin($name, $file) { require_once $file; $className = sprintf('Zicht\Tool\Plugin\%s\Plugin', ucfirst(basename($name))); $class = new \ReflectionClass($className); if (!$class->implementsInterface('Zicht\Tool\PluginInterface')) { throw new \UnexpectedValueException("The class $className is not a 'Zicht\\Tool\\PluginInterface'"); } $this->plugins[$name] = $class->newInstance(); }
php
protected function loadPlugin($name, $file) { require_once $file; $className = sprintf('Zicht\Tool\Plugin\%s\Plugin', ucfirst(basename($name))); $class = new \ReflectionClass($className); if (!$class->implementsInterface('Zicht\Tool\PluginInterface')) { throw new \UnexpectedValueException("The class $className is not a 'Zicht\\Tool\\PluginInterface'"); } $this->plugins[$name] = $class->newInstance(); }
[ "protected", "function", "loadPlugin", "(", "$", "name", ",", "$", "file", ")", "{", "require_once", "$", "file", ";", "$", "className", "=", "sprintf", "(", "'Zicht\\Tool\\Plugin\\%s\\Plugin'", ",", "ucfirst", "(", "basename", "(", "$", "name", ")", ")", ")", ";", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "if", "(", "!", "$", "class", "->", "implementsInterface", "(", "'Zicht\\Tool\\PluginInterface'", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"The class $className is not a 'Zicht\\\\Tool\\\\PluginInterface'\"", ")", ";", "}", "$", "this", "->", "plugins", "[", "$", "name", "]", "=", "$", "class", "->", "newInstance", "(", ")", ";", "}" ]
Load the specified plugin instance. @param string $name @param string $file @return void @throws \UnexpectedValueException
[ "Load", "the", "specified", "plugin", "instance", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Configuration/ConfigurationLoader.php#L133-L142
Erdiko/core
src/Layout.php
Layout.getTemplateFile
public function getTemplateFile($filename, $data) { $data['getRegion'] = function($name) { return $this->getRegion($name); }; // This is for mustache compatibility // Push the data into regions and then pass a pointer to this class to the layout // $this->setRegions($data); return parent::getTemplateFile($filename, $data); // Pass in layout object to template }
php
public function getTemplateFile($filename, $data) { $data['getRegion'] = function($name) { return $this->getRegion($name); }; // This is for mustache compatibility // Push the data into regions and then pass a pointer to this class to the layout // $this->setRegions($data); return parent::getTemplateFile($filename, $data); // Pass in layout object to template }
[ "public", "function", "getTemplateFile", "(", "$", "filename", ",", "$", "data", ")", "{", "$", "data", "[", "'getRegion'", "]", "=", "function", "(", "$", "name", ")", "{", "return", "$", "this", "->", "getRegion", "(", "$", "name", ")", ";", "}", ";", "// This is for mustache compatibility", "// Push the data into regions and then pass a pointer to this class to the layout", "// $this->setRegions($data);", "return", "parent", "::", "getTemplateFile", "(", "$", "filename", ",", "$", "data", ")", ";", "// Pass in layout object to template", "}" ]
Get template file @param string $filename @param mixed $data Typically a string, Container object or other object @return string @todo array merge regions with data
[ "Get", "template", "file" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Layout.php#L73-L82
Erdiko/core
src/Layout.php
Layout.getRegion
public function getRegion($name) { if(array_key_exists($name, $this->_regions)) { $html = (is_subclass_of($this->_regions[$name], 'erdiko\core\Container')) ? $this->_regions[$name]->toHtml() : $this->_regions[$name]; } else { throw new \Exception("Template region '{$name}' does not exits."); } return $html; }
php
public function getRegion($name) { if(array_key_exists($name, $this->_regions)) { $html = (is_subclass_of($this->_regions[$name], 'erdiko\core\Container')) ? $this->_regions[$name]->toHtml() : $this->_regions[$name]; } else { throw new \Exception("Template region '{$name}' does not exits."); } return $html; }
[ "public", "function", "getRegion", "(", "$", "name", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "_regions", ")", ")", "{", "$", "html", "=", "(", "is_subclass_of", "(", "$", "this", "->", "_regions", "[", "$", "name", "]", ",", "'erdiko\\core\\Container'", ")", ")", "?", "$", "this", "->", "_regions", "[", "$", "name", "]", "->", "toHtml", "(", ")", ":", "$", "this", "->", "_regions", "[", "$", "name", "]", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "\"Template region '{$name}' does not exits.\"", ")", ";", "}", "return", "$", "html", ";", "}" ]
get rendered region @param string $name @return mixed $content, typically a string, Container object or other object
[ "get", "rendered", "region" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Layout.php#L169-L179
Erdiko/core
src/Layout.php
Layout.toHtml
public function toHtml() { $filename = $this->getTemplateFolder().$this->getTemplate(); // $data = (is_subclass_of($this->_data, 'erdiko\core\Container')) ? $this->_data->toHtml() : $this->_data; return $this->getTemplateFile($filename, $this->_data); }
php
public function toHtml() { $filename = $this->getTemplateFolder().$this->getTemplate(); // $data = (is_subclass_of($this->_data, 'erdiko\core\Container')) ? $this->_data->toHtml() : $this->_data; return $this->getTemplateFile($filename, $this->_data); }
[ "public", "function", "toHtml", "(", ")", "{", "$", "filename", "=", "$", "this", "->", "getTemplateFolder", "(", ")", ".", "$", "this", "->", "getTemplate", "(", ")", ";", "// $data = (is_subclass_of($this->_data, 'erdiko\\core\\Container')) ? $this->_data->toHtml() : $this->_data;", "return", "$", "this", "->", "getTemplateFile", "(", "$", "filename", ",", "$", "this", "->", "_data", ")", ";", "}" ]
Render container to HTML @return string $html
[ "Render", "container", "to", "HTML" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Layout.php#L186-L192
antaresproject/notifications
src/NotificationsServiceProvider.php
NotificationsServiceProvider.register
public function register() { $this->bindContracts(); $this->app->singleton('notifications.contents', function () { return new Contents(); }); $this->commands([ NotificationCategoriesCommand::class, NotificationSeveritiesCommand::class, NotificationTypesCommand::class, NotificationsRemover::class, ]); }
php
public function register() { $this->bindContracts(); $this->app->singleton('notifications.contents', function () { return new Contents(); }); $this->commands([ NotificationCategoriesCommand::class, NotificationSeveritiesCommand::class, NotificationTypesCommand::class, NotificationsRemover::class, ]); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "bindContracts", "(", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'notifications.contents'", ",", "function", "(", ")", "{", "return", "new", "Contents", "(", ")", ";", "}", ")", ";", "$", "this", "->", "commands", "(", "[", "NotificationCategoriesCommand", "::", "class", ",", "NotificationSeveritiesCommand", "::", "class", ",", "NotificationTypesCommand", "::", "class", ",", "NotificationsRemover", "::", "class", ",", "]", ")", ";", "}" ]
Register service provider. @return void
[ "Register", "service", "provider", "." ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/NotificationsServiceProvider.php#L67-L79
antaresproject/notifications
src/NotificationsServiceProvider.php
NotificationsServiceProvider.bootExtensionComponents
public function bootExtensionComponents() { $path = __DIR__ . '/../'; $this->addConfigComponent('antares/notifications', 'antares/notifications', "{$path}/resources/config"); $this->addLanguageComponent('antares/notifications', 'antares/notifications', "{$path}/resources/lang"); $this->addViewComponent('antares/notifications', 'antares/notifications', "{$path}/resources/views"); $this->bootMemory(); $this->attachMenu(NotificationsTopMenuHandler::class); if (config('antares/notifications::sockets')) { publish('notifications', 'scripts.default'); } $this->attachMenu(NotificationsBreadcrumbMenu::class); $this->app->make('view')->composer('antares/notifications::admin.logs.config', ControlPane::class); Option::observe(new ConfigurationListener()); }
php
public function bootExtensionComponents() { $path = __DIR__ . '/../'; $this->addConfigComponent('antares/notifications', 'antares/notifications', "{$path}/resources/config"); $this->addLanguageComponent('antares/notifications', 'antares/notifications', "{$path}/resources/lang"); $this->addViewComponent('antares/notifications', 'antares/notifications', "{$path}/resources/views"); $this->bootMemory(); $this->attachMenu(NotificationsTopMenuHandler::class); if (config('antares/notifications::sockets')) { publish('notifications', 'scripts.default'); } $this->attachMenu(NotificationsBreadcrumbMenu::class); $this->app->make('view')->composer('antares/notifications::admin.logs.config', ControlPane::class); Option::observe(new ConfigurationListener()); }
[ "public", "function", "bootExtensionComponents", "(", ")", "{", "$", "path", "=", "__DIR__", ".", "'/../'", ";", "$", "this", "->", "addConfigComponent", "(", "'antares/notifications'", ",", "'antares/notifications'", ",", "\"{$path}/resources/config\"", ")", ";", "$", "this", "->", "addLanguageComponent", "(", "'antares/notifications'", ",", "'antares/notifications'", ",", "\"{$path}/resources/lang\"", ")", ";", "$", "this", "->", "addViewComponent", "(", "'antares/notifications'", ",", "'antares/notifications'", ",", "\"{$path}/resources/views\"", ")", ";", "$", "this", "->", "bootMemory", "(", ")", ";", "$", "this", "->", "attachMenu", "(", "NotificationsTopMenuHandler", "::", "class", ")", ";", "if", "(", "config", "(", "'antares/notifications::sockets'", ")", ")", "{", "publish", "(", "'notifications'", ",", "'scripts.default'", ")", ";", "}", "$", "this", "->", "attachMenu", "(", "NotificationsBreadcrumbMenu", "::", "class", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'view'", ")", "->", "composer", "(", "'antares/notifications::admin.logs.config'", ",", "ControlPane", "::", "class", ")", ";", "Option", "::", "observe", "(", "new", "ConfigurationListener", "(", ")", ")", ";", "}" ]
Boot the service provider. @return void
[ "Boot", "the", "service", "provider", "." ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/NotificationsServiceProvider.php#L105-L120
juskiewicz/Geolocation
src/Geolocation.php
Geolocation.getAddresses
public function getAddresses(CoordinatesInterface $coordinates) : AddressCollection { $url = $this->coordinatesQuery($coordinates); $json = $this->fetchUrl($url); // convert google data to address collection $results = []; foreach ($json->results as $result) { $address = AddressBuild::create($result); $address->setCoordinates($coordinates); $results[] = $address; } return new AddressCollection($results); }
php
public function getAddresses(CoordinatesInterface $coordinates) : AddressCollection { $url = $this->coordinatesQuery($coordinates); $json = $this->fetchUrl($url); // convert google data to address collection $results = []; foreach ($json->results as $result) { $address = AddressBuild::create($result); $address->setCoordinates($coordinates); $results[] = $address; } return new AddressCollection($results); }
[ "public", "function", "getAddresses", "(", "CoordinatesInterface", "$", "coordinates", ")", ":", "AddressCollection", "{", "$", "url", "=", "$", "this", "->", "coordinatesQuery", "(", "$", "coordinates", ")", ";", "$", "json", "=", "$", "this", "->", "fetchUrl", "(", "$", "url", ")", ";", "// convert google data to address collection", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "json", "->", "results", "as", "$", "result", ")", "{", "$", "address", "=", "AddressBuild", "::", "create", "(", "$", "result", ")", ";", "$", "address", "->", "setCoordinates", "(", "$", "coordinates", ")", ";", "$", "results", "[", "]", "=", "$", "address", ";", "}", "return", "new", "AddressCollection", "(", "$", "results", ")", ";", "}" ]
Get possible addresses using CoordinatesInterface @param CoordinatesInterface $coordinates @return AddressCollection
[ "Get", "possible", "addresses", "using", "CoordinatesInterface" ]
train
https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Geolocation.php#L69-L83
juskiewicz/Geolocation
src/Geolocation.php
Geolocation.getCoordinatesByObject
public function getCoordinatesByObject(AddressInterface $address) : CoordinatesInterface { $url = $this->addressQuery($address->getFormattedAddress()); $json = $this->fetchUrl($url); // convert google data to coordinates $coordinates = CoordinatesBuild::create($json->results[0]); return $coordinates; }
php
public function getCoordinatesByObject(AddressInterface $address) : CoordinatesInterface { $url = $this->addressQuery($address->getFormattedAddress()); $json = $this->fetchUrl($url); // convert google data to coordinates $coordinates = CoordinatesBuild::create($json->results[0]); return $coordinates; }
[ "public", "function", "getCoordinatesByObject", "(", "AddressInterface", "$", "address", ")", ":", "CoordinatesInterface", "{", "$", "url", "=", "$", "this", "->", "addressQuery", "(", "$", "address", "->", "getFormattedAddress", "(", ")", ")", ";", "$", "json", "=", "$", "this", "->", "fetchUrl", "(", "$", "url", ")", ";", "// convert google data to coordinates", "$", "coordinates", "=", "CoordinatesBuild", "::", "create", "(", "$", "json", "->", "results", "[", "0", "]", ")", ";", "return", "$", "coordinates", ";", "}" ]
Get coordinates using AddressInterface @param AddressInterface $address @return CoordinatesInterface
[ "Get", "coordinates", "using", "AddressInterface" ]
train
https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Geolocation.php#L91-L100
juskiewicz/Geolocation
src/Geolocation.php
Geolocation.getCoordinatesByString
public function getCoordinatesByString(string $address) : CoordinatesInterface { $url = $this->addressQuery($address); $json = $this->fetchUrl($url); // convert google data to coordinates $coordinates = CoordinatesBuild::create($json->results[0]); return $coordinates; }
php
public function getCoordinatesByString(string $address) : CoordinatesInterface { $url = $this->addressQuery($address); $json = $this->fetchUrl($url); // convert google data to coordinates $coordinates = CoordinatesBuild::create($json->results[0]); return $coordinates; }
[ "public", "function", "getCoordinatesByString", "(", "string", "$", "address", ")", ":", "CoordinatesInterface", "{", "$", "url", "=", "$", "this", "->", "addressQuery", "(", "$", "address", ")", ";", "$", "json", "=", "$", "this", "->", "fetchUrl", "(", "$", "url", ")", ";", "// convert google data to coordinates", "$", "coordinates", "=", "CoordinatesBuild", "::", "create", "(", "$", "json", "->", "results", "[", "0", "]", ")", ";", "return", "$", "coordinates", ";", "}" ]
Get coordinates using string @param string $address @return CoordinatesInterface
[ "Get", "coordinates", "using", "string" ]
train
https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Geolocation.php#L108-L117
juskiewicz/Geolocation
src/Geolocation.php
Geolocation.coordinatesQuery
private function coordinatesQuery(CoordinatesInterface $coordinates) : string { $url = sprintf(self::API_COORDINATES_URL_SSL, $coordinates->getLatitude(), $coordinates->getLongitude()); $url = $this->buildQuery($url, $this->apiKey, $this->locale, $this->region); return $url; }
php
private function coordinatesQuery(CoordinatesInterface $coordinates) : string { $url = sprintf(self::API_COORDINATES_URL_SSL, $coordinates->getLatitude(), $coordinates->getLongitude()); $url = $this->buildQuery($url, $this->apiKey, $this->locale, $this->region); return $url; }
[ "private", "function", "coordinatesQuery", "(", "CoordinatesInterface", "$", "coordinates", ")", ":", "string", "{", "$", "url", "=", "sprintf", "(", "self", "::", "API_COORDINATES_URL_SSL", ",", "$", "coordinates", "->", "getLatitude", "(", ")", ",", "$", "coordinates", "->", "getLongitude", "(", ")", ")", ";", "$", "url", "=", "$", "this", "->", "buildQuery", "(", "$", "url", ",", "$", "this", "->", "apiKey", ",", "$", "this", "->", "locale", ",", "$", "this", "->", "region", ")", ";", "return", "$", "url", ";", "}" ]
Build coordinates query @param CoordinatesInterface $coordinates @return string
[ "Build", "coordinates", "query" ]
train
https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Geolocation.php#L125-L131
juskiewicz/Geolocation
src/Geolocation.php
Geolocation.addressQuery
private function addressQuery(string $formattedAddress) : string { $url = sprintf(self::API_ADDRESS_URL_SSL, rawurlencode($formattedAddress)); $url = $this->buildQuery($url, $this->apiKey, $this->locale, $this->region); return $url; }
php
private function addressQuery(string $formattedAddress) : string { $url = sprintf(self::API_ADDRESS_URL_SSL, rawurlencode($formattedAddress)); $url = $this->buildQuery($url, $this->apiKey, $this->locale, $this->region); return $url; }
[ "private", "function", "addressQuery", "(", "string", "$", "formattedAddress", ")", ":", "string", "{", "$", "url", "=", "sprintf", "(", "self", "::", "API_ADDRESS_URL_SSL", ",", "rawurlencode", "(", "$", "formattedAddress", ")", ")", ";", "$", "url", "=", "$", "this", "->", "buildQuery", "(", "$", "url", ",", "$", "this", "->", "apiKey", ",", "$", "this", "->", "locale", ",", "$", "this", "->", "region", ")", ";", "return", "$", "url", ";", "}" ]
Build address query @param string $formattedAddress @return string
[ "Build", "address", "query" ]
train
https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Geolocation.php#L139-L145
juskiewicz/Geolocation
src/Geolocation.php
Geolocation.buildQuery
private function buildQuery(string $url, string $apiKey, string $locale = null, string $region = null) : string { if (null !== $apiKey) { $url = sprintf('%s&key=%s', $url, $apiKey); } if (null !== $locale) { $url = sprintf('%s&language=%s', $url, $locale); } if (null !== $region) { $url = sprintf('%s&region=%s', $url, $region); } return $url; }
php
private function buildQuery(string $url, string $apiKey, string $locale = null, string $region = null) : string { if (null !== $apiKey) { $url = sprintf('%s&key=%s', $url, $apiKey); } if (null !== $locale) { $url = sprintf('%s&language=%s', $url, $locale); } if (null !== $region) { $url = sprintf('%s&region=%s', $url, $region); } return $url; }
[ "private", "function", "buildQuery", "(", "string", "$", "url", ",", "string", "$", "apiKey", ",", "string", "$", "locale", "=", "null", ",", "string", "$", "region", "=", "null", ")", ":", "string", "{", "if", "(", "null", "!==", "$", "apiKey", ")", "{", "$", "url", "=", "sprintf", "(", "'%s&key=%s'", ",", "$", "url", ",", "$", "apiKey", ")", ";", "}", "if", "(", "null", "!==", "$", "locale", ")", "{", "$", "url", "=", "sprintf", "(", "'%s&language=%s'", ",", "$", "url", ",", "$", "locale", ")", ";", "}", "if", "(", "null", "!==", "$", "region", ")", "{", "$", "url", "=", "sprintf", "(", "'%s&region=%s'", ",", "$", "url", ",", "$", "region", ")", ";", "}", "return", "$", "url", ";", "}" ]
build query with extra params @param string $url @param string $locale @param string $region @param string $apiKey @return string
[ "build", "query", "with", "extra", "params" ]
train
https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Geolocation.php#L157-L170
zhouyl/mellivora
Mellivora/View/Compilers/Concerns/CompilesInjections.php
CompilesInjections.compileInject
protected function compileInject($expression) { $segments = explode(',', preg_replace("/[\\(\\)\\\"\\']/", '', $expression)); $variable = trim($segments[0]); $service = trim($segments[1]); return "<?php \${$variable} = app('{$service}'); ?>"; }
php
protected function compileInject($expression) { $segments = explode(',', preg_replace("/[\\(\\)\\\"\\']/", '', $expression)); $variable = trim($segments[0]); $service = trim($segments[1]); return "<?php \${$variable} = app('{$service}'); ?>"; }
[ "protected", "function", "compileInject", "(", "$", "expression", ")", "{", "$", "segments", "=", "explode", "(", "','", ",", "preg_replace", "(", "\"/[\\\\(\\\\)\\\\\\\"\\\\']/\"", ",", "''", ",", "$", "expression", ")", ")", ";", "$", "variable", "=", "trim", "(", "$", "segments", "[", "0", "]", ")", ";", "$", "service", "=", "trim", "(", "$", "segments", "[", "1", "]", ")", ";", "return", "\"<?php \\${$variable} = app('{$service}'); ?>\"", ";", "}" ]
Compile the inject statements into valid PHP. @param string $expression @return string
[ "Compile", "the", "inject", "statements", "into", "valid", "PHP", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/View/Compilers/Concerns/CompilesInjections.php#L14-L23
VincentChalnot/SidusDataGridBundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root($this->root); $rootNode ->children() ->scalarNode('default_form_theme')->defaultNull()->end() ->scalarNode('default_datagrid_template') ->defaultValue('SidusDataGridBundle:DataGrid:bootstrap4.html.twig') ->end() ->variableNode('default_column_value_renderer') ->defaultValue(new Reference(ColumnValueRendererInterface::class)) ->beforeNormalization()->always($this->serviceResolver)->end() ->end() ->variableNode('default_column_label_renderer') ->defaultValue(new Reference(ColumnLabelRendererInterface::class)) ->beforeNormalization()->always($this->serviceResolver)->end() ->end() ->variableNode('actions')->defaultValue([])->end() ->append($this->getDataGridConfigTreeBuilder()) ->end(); return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root($this->root); $rootNode ->children() ->scalarNode('default_form_theme')->defaultNull()->end() ->scalarNode('default_datagrid_template') ->defaultValue('SidusDataGridBundle:DataGrid:bootstrap4.html.twig') ->end() ->variableNode('default_column_value_renderer') ->defaultValue(new Reference(ColumnValueRendererInterface::class)) ->beforeNormalization()->always($this->serviceResolver)->end() ->end() ->variableNode('default_column_label_renderer') ->defaultValue(new Reference(ColumnLabelRendererInterface::class)) ->beforeNormalization()->always($this->serviceResolver)->end() ->end() ->variableNode('actions')->defaultValue([])->end() ->append($this->getDataGridConfigTreeBuilder()) ->end(); return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "$", "this", "->", "root", ")", ";", "$", "rootNode", "->", "children", "(", ")", "->", "scalarNode", "(", "'default_form_theme'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'default_datagrid_template'", ")", "->", "defaultValue", "(", "'SidusDataGridBundle:DataGrid:bootstrap4.html.twig'", ")", "->", "end", "(", ")", "->", "variableNode", "(", "'default_column_value_renderer'", ")", "->", "defaultValue", "(", "new", "Reference", "(", "ColumnValueRendererInterface", "::", "class", ")", ")", "->", "beforeNormalization", "(", ")", "->", "always", "(", "$", "this", "->", "serviceResolver", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "variableNode", "(", "'default_column_label_renderer'", ")", "->", "defaultValue", "(", "new", "Reference", "(", "ColumnLabelRendererInterface", "::", "class", ")", ")", "->", "beforeNormalization", "(", ")", "->", "always", "(", "$", "this", "->", "serviceResolver", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "variableNode", "(", "'actions'", ")", "->", "defaultValue", "(", "[", "]", ")", "->", "end", "(", ")", "->", "append", "(", "$", "this", "->", "getDataGridConfigTreeBuilder", "(", ")", ")", "->", "end", "(", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
{@inheritdoc} @throws \RuntimeException
[ "{" ]
train
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/DependencyInjection/Configuration.php#L52-L75
VincentChalnot/SidusDataGridBundle
DependencyInjection/Configuration.php
Configuration.getDataGridConfigTreeBuilder
protected function getDataGridConfigTreeBuilder(): NodeDefinition { $builder = new TreeBuilder(); $node = $builder->root('configurations'); $dataGridDefinition = $node ->useAttributeAsKey('code') ->prototype('array') ->performNoDeepMerging() ->children(); $this->appendDataGridDefinition($dataGridDefinition); $dataGridDefinition ->end() ->end() ->end(); return $node; }
php
protected function getDataGridConfigTreeBuilder(): NodeDefinition { $builder = new TreeBuilder(); $node = $builder->root('configurations'); $dataGridDefinition = $node ->useAttributeAsKey('code') ->prototype('array') ->performNoDeepMerging() ->children(); $this->appendDataGridDefinition($dataGridDefinition); $dataGridDefinition ->end() ->end() ->end(); return $node; }
[ "protected", "function", "getDataGridConfigTreeBuilder", "(", ")", ":", "NodeDefinition", "{", "$", "builder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "node", "=", "$", "builder", "->", "root", "(", "'configurations'", ")", ";", "$", "dataGridDefinition", "=", "$", "node", "->", "useAttributeAsKey", "(", "'code'", ")", "->", "prototype", "(", "'array'", ")", "->", "performNoDeepMerging", "(", ")", "->", "children", "(", ")", ";", "$", "this", "->", "appendDataGridDefinition", "(", "$", "dataGridDefinition", ")", ";", "$", "dataGridDefinition", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "return", "$", "node", ";", "}" ]
@throws \RuntimeException @return NodeDefinition
[ "@throws", "\\", "RuntimeException" ]
train
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/DependencyInjection/Configuration.php#L82-L100
wenbinye/PhalconX
src/Validation/Validation.php
Validation.validate
public function validate($model, $validators = null) { if (isset($validators) && is_array($validators)) { $validation = $this->validateArray($model, $validators); } else { $validation = $this->validateModel($model); } if ($validation) { $errors = $validation->validate($model); if (count($errors)) { throw new ValidationException($errors); } } }
php
public function validate($model, $validators = null) { if (isset($validators) && is_array($validators)) { $validation = $this->validateArray($model, $validators); } else { $validation = $this->validateModel($model); } if ($validation) { $errors = $validation->validate($model); if (count($errors)) { throw new ValidationException($errors); } } }
[ "public", "function", "validate", "(", "$", "model", ",", "$", "validators", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "validators", ")", "&&", "is_array", "(", "$", "validators", ")", ")", "{", "$", "validation", "=", "$", "this", "->", "validateArray", "(", "$", "model", ",", "$", "validators", ")", ";", "}", "else", "{", "$", "validation", "=", "$", "this", "->", "validateModel", "(", "$", "model", ")", ";", "}", "if", "(", "$", "validation", ")", "{", "$", "errors", "=", "$", "validation", "->", "validate", "(", "$", "model", ")", ";", "if", "(", "count", "(", "$", "errors", ")", ")", "{", "throw", "new", "ValidationException", "(", "$", "errors", ")", ";", "}", "}", "}" ]
Validate model object @param object|array $model @param array $validators @throws ValidationException
[ "Validate", "model", "object" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Validation/Validation.php#L66-L79
wenbinye/PhalconX
src/Validation/Validation.php
Validation.createForm
public function createForm($model, $formClass = null) { if (is_string($model)) { return $this->createFormInternal($model, new $model, $formClass); } else { return $this->createFormInternal(get_class($model), $model, $formClass); } }
php
public function createForm($model, $formClass = null) { if (is_string($model)) { return $this->createFormInternal($model, new $model, $formClass); } else { return $this->createFormInternal(get_class($model), $model, $formClass); } }
[ "public", "function", "createForm", "(", "$", "model", ",", "$", "formClass", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "model", ")", ")", "{", "return", "$", "this", "->", "createFormInternal", "(", "$", "model", ",", "new", "$", "model", ",", "$", "formClass", ")", ";", "}", "else", "{", "return", "$", "this", "->", "createFormInternal", "(", "get_class", "(", "$", "model", ")", ",", "$", "model", ",", "$", "formClass", ")", ";", "}", "}" ]
Create form object @param string|object $model model class or object @param string $formClass form class, default use Phalcon\Forms\Form @return Phalcon\Forms\Form
[ "Create", "form", "object" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Validation/Validation.php#L88-L95
wenbinye/PhalconX
src/Validation/Validation.php
Validation.getLabels
private function getLabels($annotations) { $it = $this->getAnnotations()->filter($annotations) ->is(Label::class) ->onProperties(); $labels = []; foreach ($it as $annotation) { $labels[$annotation->getPropertyName()] = $annotation->value; } return $labels; }
php
private function getLabels($annotations) { $it = $this->getAnnotations()->filter($annotations) ->is(Label::class) ->onProperties(); $labels = []; foreach ($it as $annotation) { $labels[$annotation->getPropertyName()] = $annotation->value; } return $labels; }
[ "private", "function", "getLabels", "(", "$", "annotations", ")", "{", "$", "it", "=", "$", "this", "->", "getAnnotations", "(", ")", "->", "filter", "(", "$", "annotations", ")", "->", "is", "(", "Label", "::", "class", ")", "->", "onProperties", "(", ")", ";", "$", "labels", "=", "[", "]", ";", "foreach", "(", "$", "it", "as", "$", "annotation", ")", "{", "$", "labels", "[", "$", "annotation", "->", "getPropertyName", "(", ")", "]", "=", "$", "annotation", "->", "value", ";", "}", "return", "$", "labels", ";", "}" ]
Gets property labels @return array
[ "Gets", "property", "labels" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Validation/Validation.php#L131-L141
wenbinye/PhalconX
src/Validation/Validation.php
Validation.getValidators
private function getValidators($annotations, $class) { $validators = []; $it = $this->getAnnotations()->filter($annotations) ->is(ValidatorInterface::class) ->onProperties(); foreach ($it as $annotation) { $property = $annotation->getPropertyName(); if (!isset($validators[$property])) { $validators[$property] = [ 'required' => false, 'validators' => [], ]; } $validators[$property]['validators'][] = $annotation->getValidator($this); if ($annotation instanceof Required) { $validators[$property]['required'] = true; } } return $validators; }
php
private function getValidators($annotations, $class) { $validators = []; $it = $this->getAnnotations()->filter($annotations) ->is(ValidatorInterface::class) ->onProperties(); foreach ($it as $annotation) { $property = $annotation->getPropertyName(); if (!isset($validators[$property])) { $validators[$property] = [ 'required' => false, 'validators' => [], ]; } $validators[$property]['validators'][] = $annotation->getValidator($this); if ($annotation instanceof Required) { $validators[$property]['required'] = true; } } return $validators; }
[ "private", "function", "getValidators", "(", "$", "annotations", ",", "$", "class", ")", "{", "$", "validators", "=", "[", "]", ";", "$", "it", "=", "$", "this", "->", "getAnnotations", "(", ")", "->", "filter", "(", "$", "annotations", ")", "->", "is", "(", "ValidatorInterface", "::", "class", ")", "->", "onProperties", "(", ")", ";", "foreach", "(", "$", "it", "as", "$", "annotation", ")", "{", "$", "property", "=", "$", "annotation", "->", "getPropertyName", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "validators", "[", "$", "property", "]", ")", ")", "{", "$", "validators", "[", "$", "property", "]", "=", "[", "'required'", "=>", "false", ",", "'validators'", "=>", "[", "]", ",", "]", ";", "}", "$", "validators", "[", "$", "property", "]", "[", "'validators'", "]", "[", "]", "=", "$", "annotation", "->", "getValidator", "(", "$", "this", ")", ";", "if", "(", "$", "annotation", "instanceof", "Required", ")", "{", "$", "validators", "[", "$", "property", "]", "[", "'required'", "]", "=", "true", ";", "}", "}", "return", "$", "validators", ";", "}" ]
Gets all validators @return array
[ "Gets", "all", "validators" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Validation/Validation.php#L177-L197
wenbinye/PhalconX
src/Validation/Validation.php
Validation.getElements
private function getElements($annotations, $formClass) { $labels = $this->getLabels($annotations); $reflection = new \ReflectionClass($formClass); $defaultValues = $reflection->getDefaultProperties(); $elements = []; $it = $this->getAnnotations()->filter($annotations) ->is(InputInterface::class) ->onProperties(); foreach ($it as $annotation) { $property = $annotation->getPropertyName(); if (!isset($annotation->name)) { $annotation->name = $property; } $elem = $annotation->getElement($this); if ($annotation->label) { $label = $annotation->label; } elseif (isset($labels[$property])) { $label = $labels[$property]; } else { $label = str_replace('_', ' ', ucfirst($property)); } $elem->setLabel($label); if (isset($defaultValues[$property])) { $elem->setDefault($defaultValues[$property]); } $elements[$property] = $elem; } return $elements; }
php
private function getElements($annotations, $formClass) { $labels = $this->getLabels($annotations); $reflection = new \ReflectionClass($formClass); $defaultValues = $reflection->getDefaultProperties(); $elements = []; $it = $this->getAnnotations()->filter($annotations) ->is(InputInterface::class) ->onProperties(); foreach ($it as $annotation) { $property = $annotation->getPropertyName(); if (!isset($annotation->name)) { $annotation->name = $property; } $elem = $annotation->getElement($this); if ($annotation->label) { $label = $annotation->label; } elseif (isset($labels[$property])) { $label = $labels[$property]; } else { $label = str_replace('_', ' ', ucfirst($property)); } $elem->setLabel($label); if (isset($defaultValues[$property])) { $elem->setDefault($defaultValues[$property]); } $elements[$property] = $elem; } return $elements; }
[ "private", "function", "getElements", "(", "$", "annotations", ",", "$", "formClass", ")", "{", "$", "labels", "=", "$", "this", "->", "getLabels", "(", "$", "annotations", ")", ";", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "formClass", ")", ";", "$", "defaultValues", "=", "$", "reflection", "->", "getDefaultProperties", "(", ")", ";", "$", "elements", "=", "[", "]", ";", "$", "it", "=", "$", "this", "->", "getAnnotations", "(", ")", "->", "filter", "(", "$", "annotations", ")", "->", "is", "(", "InputInterface", "::", "class", ")", "->", "onProperties", "(", ")", ";", "foreach", "(", "$", "it", "as", "$", "annotation", ")", "{", "$", "property", "=", "$", "annotation", "->", "getPropertyName", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "annotation", "->", "name", ")", ")", "{", "$", "annotation", "->", "name", "=", "$", "property", ";", "}", "$", "elem", "=", "$", "annotation", "->", "getElement", "(", "$", "this", ")", ";", "if", "(", "$", "annotation", "->", "label", ")", "{", "$", "label", "=", "$", "annotation", "->", "label", ";", "}", "elseif", "(", "isset", "(", "$", "labels", "[", "$", "property", "]", ")", ")", "{", "$", "label", "=", "$", "labels", "[", "$", "property", "]", ";", "}", "else", "{", "$", "label", "=", "str_replace", "(", "'_'", ",", "' '", ",", "ucfirst", "(", "$", "property", ")", ")", ";", "}", "$", "elem", "->", "setLabel", "(", "$", "label", ")", ";", "if", "(", "isset", "(", "$", "defaultValues", "[", "$", "property", "]", ")", ")", "{", "$", "elem", "->", "setDefault", "(", "$", "defaultValues", "[", "$", "property", "]", ")", ";", "}", "$", "elements", "[", "$", "property", "]", "=", "$", "elem", ";", "}", "return", "$", "elements", ";", "}" ]
Gets all form elements @return array key is property, value is Phalcon\Form\Element object
[ "Gets", "all", "form", "elements" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Validation/Validation.php#L204-L234
wenbinye/PhalconX
src/Validation/Validation.php
Validation.getValue
private function getValue($form, $name) { if (is_array($form)) { return isset($form[$name]) ? $form[$name] : null; } elseif (is_object($form)) { $method = 'get' . $name; if (method_exists($form, $method)) { return $form->$method(); } else { return isset($form->$name) ? $form->$name : null; } } }
php
private function getValue($form, $name) { if (is_array($form)) { return isset($form[$name]) ? $form[$name] : null; } elseif (is_object($form)) { $method = 'get' . $name; if (method_exists($form, $method)) { return $form->$method(); } else { return isset($form->$name) ? $form->$name : null; } } }
[ "private", "function", "getValue", "(", "$", "form", ",", "$", "name", ")", "{", "if", "(", "is_array", "(", "$", "form", ")", ")", "{", "return", "isset", "(", "$", "form", "[", "$", "name", "]", ")", "?", "$", "form", "[", "$", "name", "]", ":", "null", ";", "}", "elseif", "(", "is_object", "(", "$", "form", ")", ")", "{", "$", "method", "=", "'get'", ".", "$", "name", ";", "if", "(", "method_exists", "(", "$", "form", ",", "$", "method", ")", ")", "{", "return", "$", "form", "->", "$", "method", "(", ")", ";", "}", "else", "{", "return", "isset", "(", "$", "form", "->", "$", "name", ")", "?", "$", "form", "->", "$", "name", ":", "null", ";", "}", "}", "}" ]
Gets the value in the array/object data source @return mixed
[ "Gets", "the", "value", "in", "the", "array", "/", "object", "data", "source" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Validation/Validation.php#L241-L253
gedex/php-janrain-api
lib/Janrain/Api/Capture/Settings.php
Settings.getSingle
public function getSingle($key, $forClientId = null) { $params = array('key' => $key); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/get', $params); }
php
public function getSingle($key, $forClientId = null) { $params = array('key' => $key); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/get', $params); }
[ "public", "function", "getSingle", "(", "$", "key", ",", "$", "forClientId", "=", "null", ")", "{", "$", "params", "=", "array", "(", "'key'", "=>", "$", "key", ")", ";", "if", "(", "$", "forClientId", ")", "{", "$", "params", "[", "'for_client_id'", "]", "=", "$", "forClientId", ";", "}", "return", "$", "this", "->", "post", "(", "'settings/get'", ",", "$", "params", ")", ";", "}" ]
Get the value associated with a key for a particular `client_id`. If the key has not value for that client, then return the key's default value for the application, or if they key has not default value, then return null. @param string $key The key whose value you want to retrieve. To find out the values available, use the 'settings/keys' API call first @param string $forClientId The client identifier. If you do not enter a value for this parameter, it defaults to the value of the `client_id`, that is, you are getting the value for a key in your own record.
[ "Get", "the", "value", "associated", "with", "a", "key", "for", "a", "particular", "client_id", ".", "If", "the", "key", "has", "not", "value", "for", "that", "client", "then", "return", "the", "key", "s", "default", "value", "for", "the", "application", "or", "if", "they", "key", "has", "not", "default", "value", "then", "return", "null", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Settings.php#L23-L32
gedex/php-janrain-api
lib/Janrain/Api/Capture/Settings.php
Settings.getMulti
public function getMulti(array $keys, $forClientId = null) { $params = array( 'keys' => json_encode(array_values($keys)), ); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/get_multi', $params); }
php
public function getMulti(array $keys, $forClientId = null) { $params = array( 'keys' => json_encode(array_values($keys)), ); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/get_multi', $params); }
[ "public", "function", "getMulti", "(", "array", "$", "keys", ",", "$", "forClientId", "=", "null", ")", "{", "$", "params", "=", "array", "(", "'keys'", "=>", "json_encode", "(", "array_values", "(", "$", "keys", ")", ")", ",", ")", ";", "if", "(", "$", "forClientId", ")", "{", "$", "params", "[", "'for_client_id'", "]", "=", "$", "forClientId", ";", "}", "return", "$", "this", "->", "post", "(", "'settings/get_multi'", ",", "$", "params", ")", ";", "}" ]
Look up multiple keys. Each value is retrieved, as in the 'settings/get' command, by first looking at the client-specific setting, and then falling back to the application default setting. @param array $keys Array of the keys to retrieve @param string $forClientId The client identifier whose keys will be retrieved. If you do not enter a value for this parameter, it defaults to the value of the `client_id`, that is, you are getting the values for multiple keys in your own record
[ "Look", "up", "multiple", "keys", ".", "Each", "value", "is", "retrieved", "as", "in", "the", "settings", "/", "get", "command", "by", "first", "looking", "at", "the", "client", "-", "specific", "setting", "and", "then", "falling", "back", "to", "the", "application", "default", "setting", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Settings.php#L47-L58
gedex/php-janrain-api
lib/Janrain/Api/Capture/Settings.php
Settings.items
public function items($forClientId = null) { $params = array(); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/items', $params); }
php
public function items($forClientId = null) { $params = array(); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/items', $params); }
[ "public", "function", "items", "(", "$", "forClientId", "=", "null", ")", "{", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "forClientId", ")", "{", "$", "params", "[", "'for_client_id'", "]", "=", "$", "forClientId", ";", "}", "return", "$", "this", "->", "post", "(", "'settings/items'", ",", "$", "params", ")", ";", "}" ]
Get all settings for a particular client, including those from the application- wide default settings. If a key is defined in both the client and application settings, only the client-specific value is returned. @param string $forClientId The client identifier whose settings will be retrieved. If you do not enter a value for this parameter, it defaults to the value of the `client_id`
[ "Get", "all", "settings", "for", "a", "particular", "client", "including", "those", "from", "the", "application", "-", "wide", "default", "settings", ".", "If", "a", "key", "is", "defined", "in", "both", "the", "client", "and", "application", "settings", "only", "the", "client", "-", "specific", "value", "is", "returned", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Settings.php#L70-L78
gedex/php-janrain-api
lib/Janrain/Api/Capture/Settings.php
Settings.keys
public function keys($forClientId = null) { $params = array(); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/keys', $params); }
php
public function keys($forClientId = null) { $params = array(); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/keys', $params); }
[ "public", "function", "keys", "(", "$", "forClientId", "=", "null", ")", "{", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "forClientId", ")", "{", "$", "params", "[", "'for_client_id'", "]", "=", "$", "forClientId", ";", "}", "return", "$", "this", "->", "post", "(", "'settings/keys'", ",", "$", "params", ")", ";", "}" ]
Get all keys for a particular client, including those from the application- wide default settings. Returns an array of the keys. @param string $forClientId The client identifier whose setting will be modified. If you do not enter a value for this parameter, it defaults to the value of the `client_id`, that is, you are modifying the settings for your own record
[ "Get", "all", "keys", "for", "a", "particular", "client", "including", "those", "from", "the", "application", "-", "wide", "default", "settings", ".", "Returns", "an", "array", "of", "the", "keys", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Settings.php#L90-L98
gedex/php-janrain-api
lib/Janrain/Api/Capture/Settings.php
Settings.set
public function set($key, $value, $forClientId = null) { $params = array('key' => $key, 'value' => $value); if (is_array($value)) { $params['value'] = json_encode($value); } if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/set', $params); }
php
public function set($key, $value, $forClientId = null) { $params = array('key' => $key, 'value' => $value); if (is_array($value)) { $params['value'] = json_encode($value); } if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/set', $params); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "forClientId", "=", "null", ")", "{", "$", "params", "=", "array", "(", "'key'", "=>", "$", "key", ",", "'value'", "=>", "$", "value", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "params", "[", "'value'", "]", "=", "json_encode", "(", "$", "value", ")", ";", "}", "if", "(", "$", "forClientId", ")", "{", "$", "params", "[", "'for_client_id'", "]", "=", "$", "forClientId", ";", "}", "return", "$", "this", "->", "post", "(", "'settings/set'", ",", "$", "params", ")", ";", "}" ]
Assign a key-value pair for a particular `client_id`. If the key does not exist, it will be created. If they key already exists, this call overwrites the existing value. Returns a boolean that indicates whether the key already existed. True indicates the key has been overwritten. False indicates that a new key has been created. Note that you cannot use 'settings/set' to modify the application-wide default settings. @param string $key The key to add or modify @param mixed $value The value to assign to the key @param string $forClientId The client identifier whose setting will be modified. If you do not enter a value for this parameter, it defaults to the value of the `client_id`, that is, you are modifying the settings for your own record
[ "Assign", "a", "key", "-", "value", "pair", "for", "a", "particular", "client_id", ".", "If", "the", "key", "does", "not", "exist", "it", "will", "be", "created", ".", "If", "they", "key", "already", "exists", "this", "call", "overwrites", "the", "existing", "value", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Settings.php#L121-L133
gedex/php-janrain-api
lib/Janrain/Api/Capture/Settings.php
Settings.setMulti
public function setMulti(array $items, $forClientId = null) { $params = array('items' => json_encode($items)); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/set_multi', $params); }
php
public function setMulti(array $items, $forClientId = null) { $params = array('items' => json_encode($items)); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/set_multi', $params); }
[ "public", "function", "setMulti", "(", "array", "$", "items", ",", "$", "forClientId", "=", "null", ")", "{", "$", "params", "=", "array", "(", "'items'", "=>", "json_encode", "(", "$", "items", ")", ")", ";", "if", "(", "$", "forClientId", ")", "{", "$", "params", "[", "'for_client_id'", "]", "=", "$", "forClientId", ";", "}", "return", "$", "this", "->", "post", "(", "'settings/set_multi'", ",", "$", "params", ")", ";", "}" ]
Assign multiple settings for a particular `client_id`. Returns a JSON object in which each key is mapped to a boolean that indicates whether the key already existed. True indicates that a previous key did exist and has been overwritten. False indicates that there were no previous key and a new key has been created. Does not modify application-wide settings. @param array $items Array containing key-value pairs to set for the client identifier. @param string $forClientId The client identifier whose settings will be modified. If you do not enter a value for this parameter, it defaults to the value of the `client_id`, that is, you are setting the values for multiple keys in your own record.
[ "Assign", "multiple", "settings", "for", "a", "particular", "client_id", ".", "Returns", "a", "JSON", "object", "in", "which", "each", "key", "is", "mapped", "to", "a", "boolean", "that", "indicates", "whether", "the", "key", "already", "existed", ".", "True", "indicates", "that", "a", "previous", "key", "did", "exist", "and", "has", "been", "overwritten", ".", "False", "indicates", "that", "there", "were", "no", "previous", "key", "and", "a", "new", "key", "has", "been", "created", ".", "Does", "not", "modify", "application", "-", "wide", "settings", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Settings.php#L151-L160
gedex/php-janrain-api
lib/Janrain/Api/Capture/Settings.php
Settings.setDefault
public function setDefault($key, $value) { $params = array('key' => $key, 'value' => $value); if (is_array($value)) { $params['value'] = json_encode($value); } return $this->post('settings/set_default', $params); }
php
public function setDefault($key, $value) { $params = array('key' => $key, 'value' => $value); if (is_array($value)) { $params['value'] = json_encode($value); } return $this->post('settings/set_default', $params); }
[ "public", "function", "setDefault", "(", "$", "key", ",", "$", "value", ")", "{", "$", "params", "=", "array", "(", "'key'", "=>", "$", "key", ",", "'value'", "=>", "$", "value", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "params", "[", "'value'", "]", "=", "json_encode", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "post", "(", "'settings/set_default'", ",", "$", "params", ")", ";", "}" ]
Set the application-wide default value for a key. This will create a new key with a default value, if the key does not yet exist in the application. If the key does exist, the value will be overwritten. Returns a boolean that indicates whether the key already existed. "True" indicates the key has been overwritten. "False" indicates that a new key has been created. @param string $key The key to add or modifiy @param string $value The value to assign to the key
[ "Set", "the", "application", "-", "wide", "default", "value", "for", "a", "key", ".", "This", "will", "create", "a", "new", "key", "with", "a", "default", "value", "if", "the", "key", "does", "not", "yet", "exist", "in", "the", "application", ".", "If", "the", "key", "does", "exist", "the", "value", "will", "be", "overwritten", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Settings.php#L187-L195
gedex/php-janrain-api
lib/Janrain/Api/Capture/Settings.php
Settings.delete
public function delete($key, $forClientId = null) { $params = array('key' => $key); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/delete', $params); }
php
public function delete($key, $forClientId = null) { $params = array('key' => $key); if ($forClientId) { $params['for_client_id'] = $forClientId; } return $this->post('settings/delete', $params); }
[ "public", "function", "delete", "(", "$", "key", ",", "$", "forClientId", "=", "null", ")", "{", "$", "params", "=", "array", "(", "'key'", "=>", "$", "key", ")", ";", "if", "(", "$", "forClientId", ")", "{", "$", "params", "[", "'for_client_id'", "]", "=", "$", "forClientId", ";", "}", "return", "$", "this", "->", "post", "(", "'settings/delete'", ",", "$", "params", ")", ";", "}" ]
Delete a key from the settings for a particular client. Returns a boolean indicating whether the key existed. This does not modify the application- wide default value for a key. @param string $key The key to delete from the client settings. To find out the values available, use the 'settings/keys' API call first. @param string $forClientId The client identifier whose key will be deleted If you do not enter a value for this parameter, it defaults to the value of the `client_id`. In this case, you will delete the key from your own account.
[ "Delete", "a", "key", "from", "the", "settings", "for", "a", "particular", "client", ".", "Returns", "a", "boolean", "indicating", "whether", "the", "key", "existed", ".", "This", "does", "not", "modify", "the", "application", "-", "wide", "default", "value", "for", "a", "key", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Settings.php#L212-L221
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.init
public function init($server, $username, $password, $source, $prefix = '') { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $dsn = "mysql://$username:$password@$server/$source?charset=utf8"; $db = Eresus_DB::connect($dsn); $options = new ezcDbOptions(array('tableNamePrefix' => $prefix)); $db->setOptions($options); return true; }
php
public function init($server, $username, $password, $source, $prefix = '') { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $dsn = "mysql://$username:$password@$server/$source?charset=utf8"; $db = Eresus_DB::connect($dsn); $options = new ezcDbOptions(array('tableNamePrefix' => $prefix)); $db->setOptions($options); return true; }
[ "public", "function", "init", "(", "$", "server", ",", "$", "username", ",", "$", "password", ",", "$", "source", ",", "$", "prefix", "=", "''", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "dsn", "=", "\"mysql://$username:$password@$server/$source?charset=utf8\"", ";", "$", "db", "=", "Eresus_DB", "::", "connect", "(", "$", "dsn", ")", ";", "$", "options", "=", "new", "ezcDbOptions", "(", "array", "(", "'tableNamePrefix'", "=>", "$", "prefix", ")", ")", ";", "$", "db", "->", "setOptions", "(", "$", "options", ")", ";", "return", "true", ";", "}" ]
Открывает соединение сервером данных и выбирает источник @param string $server Сервер данных @param string $username Имя пользователя для доступа к серверу @param string $password Пароль пользователя @param string $source Имя источника данных @param string $prefix @throws Eresus_DB_Exception @return bool Результат соединения @deprecated
[ "Открывает", "соединение", "сервером", "данных", "и", "выбирает", "источник" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L90-L99
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.getSchema
public function getSchema() { if (!$this->dbSchema) { $db = Eresus_DB::getHandler(); $options = new ezcDbSchemaOptions(array('tableNamePrefix' => $db->options->tableNamePrefix)); ezcDbSchema::setOptions($options); $this->dbSchema = ezcDbSchema::createFromDb($db); } return $this->dbSchema; }
php
public function getSchema() { if (!$this->dbSchema) { $db = Eresus_DB::getHandler(); $options = new ezcDbSchemaOptions(array('tableNamePrefix' => $db->options->tableNamePrefix)); ezcDbSchema::setOptions($options); $this->dbSchema = ezcDbSchema::createFromDb($db); } return $this->dbSchema; }
[ "public", "function", "getSchema", "(", ")", "{", "if", "(", "!", "$", "this", "->", "dbSchema", ")", "{", "$", "db", "=", "Eresus_DB", "::", "getHandler", "(", ")", ";", "$", "options", "=", "new", "ezcDbSchemaOptions", "(", "array", "(", "'tableNamePrefix'", "=>", "$", "db", "->", "options", "->", "tableNamePrefix", ")", ")", ";", "ezcDbSchema", "::", "setOptions", "(", "$", "options", ")", ";", "$", "this", "->", "dbSchema", "=", "ezcDbSchema", "::", "createFromDb", "(", "$", "db", ")", ";", "}", "return", "$", "this", "->", "dbSchema", ";", "}" ]
Возвращает объект-одиночку схемы БД @return ezcDbSchema
[ "Возвращает", "объект", "-", "одиночку", "схемы", "БД" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L105-L117
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.query
public function query($query) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); Eresus_Kernel::log(__METHOD__, LOG_DEBUG, $query); $db->exec($query); return true; }
php
public function query($query) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); Eresus_Kernel::log(__METHOD__, LOG_DEBUG, $query); $db->exec($query); return true; }
[ "public", "function", "query", "(", "$", "query", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "db", "=", "Eresus_DB", "::", "getHandler", "(", ")", ";", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_DEBUG", ",", "$", "query", ")", ";", "$", "db", "->", "exec", "(", "$", "query", ")", ";", "return", "true", ";", "}" ]
Выполняет запрос к источнику @param string $query Запрос в формате источника @return mixed Результат запроса. Тип зависит от источника, запроса и результата @deprecated
[ "Выполняет", "запрос", "к", "источнику" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L127-L134
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.query_array
public function query_array($query) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); $stmt = $db->prepare($query); if (!$stmt->execute()) { return false; } $values = $stmt->fetchAll(PDO::FETCH_ASSOC); return $values; }
php
public function query_array($query) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); $stmt = $db->prepare($query); if (!$stmt->execute()) { return false; } $values = $stmt->fetchAll(PDO::FETCH_ASSOC); return $values; }
[ "public", "function", "query_array", "(", "$", "query", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "db", "=", "Eresus_DB", "::", "getHandler", "(", ")", ";", "$", "stmt", "=", "$", "db", "->", "prepare", "(", "$", "query", ")", ";", "if", "(", "!", "$", "stmt", "->", "execute", "(", ")", ")", "{", "return", "false", ";", "}", "$", "values", "=", "$", "stmt", "->", "fetchAll", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "return", "$", "values", ";", "}" ]
Выполняет запрос к источнику и возвращает ассоциативный массив значений @param string $query Запрос в формате источника @return array|bool Ответ в виде массива или FALSE в случае ошибки @deprecated
[ "Выполняет", "запрос", "к", "источнику", "и", "возвращает", "ассоциативный", "массив", "значений" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L144-L156
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.create
public function create($name, $structure, $options = '') { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); $name = $db->options->tableNamePrefix . $name; $query = "CREATE TABLE `$name` ($structure) $options"; $result = $this->query($query); if ($result) { $db = Eresus_DB::getHandler(); $this->dbSchema = ezcDbSchema::createFromDb($db); } return $result; }
php
public function create($name, $structure, $options = '') { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); $name = $db->options->tableNamePrefix . $name; $query = "CREATE TABLE `$name` ($structure) $options"; $result = $this->query($query); if ($result) { $db = Eresus_DB::getHandler(); $this->dbSchema = ezcDbSchema::createFromDb($db); } return $result; }
[ "public", "function", "create", "(", "$", "name", ",", "$", "structure", ",", "$", "options", "=", "''", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "db", "=", "Eresus_DB", "::", "getHandler", "(", ")", ";", "$", "name", "=", "$", "db", "->", "options", "->", "tableNamePrefix", ".", "$", "name", ";", "$", "query", "=", "\"CREATE TABLE `$name` ($structure) $options\"", ";", "$", "result", "=", "$", "this", "->", "query", "(", "$", "query", ")", ";", "if", "(", "$", "result", ")", "{", "$", "db", "=", "Eresus_DB", "::", "getHandler", "(", ")", ";", "$", "this", "->", "dbSchema", "=", "ezcDbSchema", "::", "createFromDb", "(", "$", "db", ")", ";", "}", "return", "$", "result", ";", "}" ]
Создание новой таблицы @param string $name Имя таблицы @param string $structure Описание структуры @param string $options Опции @return bool Результат @deprecated
[ "Создание", "новой", "таблицы" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L169-L184
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.select
public function select($tables, $condition = '', $order = '', $fields = '', $limit = 0, $offset = 0, $group = '', $distinct = false) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); $q = $db->createSelectQuery(); $e = $q->expr; if (empty($fields)) { $fields = '*'; } if ($distinct) { $q->selectDistinct($fields); } else { $q->select($fields); } $tables = explode(',', $tables); $q->from($tables); if ($condition) { $q->where($condition); } if (strlen($order)) { $order = explode(',', $order); for ($i = 0; $i < count($order); $i++) { switch ($order[$i]{0}) { case '+': $q->orderBy(substr($order[$i], 1)); break; case '-': $q->orderBy(substr($order[$i], 1), ezcQuerySelect::DESC); break; default: $q->orderBy($order[$i]); break; } } } if ($limit && $offset) { $q->limit($limit, $offset); } elseif ($limit) { $q->limit($limit); } if ($group) { $q->groupBy($group); } $result = $q->fetchAll(); return $result; }
php
public function select($tables, $condition = '', $order = '', $fields = '', $limit = 0, $offset = 0, $group = '', $distinct = false) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); $q = $db->createSelectQuery(); $e = $q->expr; if (empty($fields)) { $fields = '*'; } if ($distinct) { $q->selectDistinct($fields); } else { $q->select($fields); } $tables = explode(',', $tables); $q->from($tables); if ($condition) { $q->where($condition); } if (strlen($order)) { $order = explode(',', $order); for ($i = 0; $i < count($order); $i++) { switch ($order[$i]{0}) { case '+': $q->orderBy(substr($order[$i], 1)); break; case '-': $q->orderBy(substr($order[$i], 1), ezcQuerySelect::DESC); break; default: $q->orderBy($order[$i]); break; } } } if ($limit && $offset) { $q->limit($limit, $offset); } elseif ($limit) { $q->limit($limit); } if ($group) { $q->groupBy($group); } $result = $q->fetchAll(); return $result; }
[ "public", "function", "select", "(", "$", "tables", ",", "$", "condition", "=", "''", ",", "$", "order", "=", "''", ",", "$", "fields", "=", "''", ",", "$", "limit", "=", "0", ",", "$", "offset", "=", "0", ",", "$", "group", "=", "''", ",", "$", "distinct", "=", "false", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "db", "=", "Eresus_DB", "::", "getHandler", "(", ")", ";", "$", "q", "=", "$", "db", "->", "createSelectQuery", "(", ")", ";", "$", "e", "=", "$", "q", "->", "expr", ";", "if", "(", "empty", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "'*'", ";", "}", "if", "(", "$", "distinct", ")", "{", "$", "q", "->", "selectDistinct", "(", "$", "fields", ")", ";", "}", "else", "{", "$", "q", "->", "select", "(", "$", "fields", ")", ";", "}", "$", "tables", "=", "explode", "(", "','", ",", "$", "tables", ")", ";", "$", "q", "->", "from", "(", "$", "tables", ")", ";", "if", "(", "$", "condition", ")", "{", "$", "q", "->", "where", "(", "$", "condition", ")", ";", "}", "if", "(", "strlen", "(", "$", "order", ")", ")", "{", "$", "order", "=", "explode", "(", "','", ",", "$", "order", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "order", ")", ";", "$", "i", "++", ")", "{", "switch", "(", "$", "order", "[", "$", "i", "]", "{", "0", "}", ")", "{", "case", "'+'", ":", "$", "q", "->", "orderBy", "(", "substr", "(", "$", "order", "[", "$", "i", "]", ",", "1", ")", ")", ";", "break", ";", "case", "'-'", ":", "$", "q", "->", "orderBy", "(", "substr", "(", "$", "order", "[", "$", "i", "]", ",", "1", ")", ",", "ezcQuerySelect", "::", "DESC", ")", ";", "break", ";", "default", ":", "$", "q", "->", "orderBy", "(", "$", "order", "[", "$", "i", "]", ")", ";", "break", ";", "}", "}", "}", "if", "(", "$", "limit", "&&", "$", "offset", ")", "{", "$", "q", "->", "limit", "(", "$", "limit", ",", "$", "offset", ")", ";", "}", "elseif", "(", "$", "limit", ")", "{", "$", "q", "->", "limit", "(", "$", "limit", ")", ";", "}", "if", "(", "$", "group", ")", "{", "$", "q", "->", "groupBy", "(", "$", "group", ")", ";", "}", "$", "result", "=", "$", "q", "->", "fetchAll", "(", ")", ";", "return", "$", "result", ";", "}" ]
Производит выборку данных из источника @param string $tables Список таблиц из которых проводится выборка @param string $condition Условие для выборки (WHERE) @param string $order Поля для сортировки (ORDER BY) @param string $fields Список полей для получения @param int $limit Максимльное количество получаемых записей @param int $offset Начальное смещение для выборки @param string $group Поле для группировки @param bool $distinct Вернуть только уникальные записи @return array|bool Выбранные элементы в виде массива или FALSE в случае ошибки @deprecated
[ "Производит", "выборку", "данных", "из", "источника" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L228-L297
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.insert
public function insert($table, $item) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $fields = $this->fields($table); if (!$table) { return false; } $q = Eresus_DB::getHandler()->createInsertQuery(); $q->insertInto($table); foreach ($fields as $field) { if (isset($item[$field])) { $q->set($field, $q->bindValue($item[$field])); } } $q->execute(); return true; }
php
public function insert($table, $item) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $fields = $this->fields($table); if (!$table) { return false; } $q = Eresus_DB::getHandler()->createInsertQuery(); $q->insertInto($table); foreach ($fields as $field) { if (isset($item[$field])) { $q->set($field, $q->bindValue($item[$field])); } } $q->execute(); return true; }
[ "public", "function", "insert", "(", "$", "table", ",", "$", "item", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "fields", "=", "$", "this", "->", "fields", "(", "$", "table", ")", ";", "if", "(", "!", "$", "table", ")", "{", "return", "false", ";", "}", "$", "q", "=", "Eresus_DB", "::", "getHandler", "(", ")", "->", "createInsertQuery", "(", ")", ";", "$", "q", "->", "insertInto", "(", "$", "table", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "item", "[", "$", "field", "]", ")", ")", "{", "$", "q", "->", "set", "(", "$", "field", ",", "$", "q", "->", "bindValue", "(", "$", "item", "[", "$", "field", "]", ")", ")", ";", "}", "}", "$", "q", "->", "execute", "(", ")", ";", "return", "true", ";", "}" ]
Вставка элемента в БД @param string $table Таблица, в которую надо вставтиь элемент @param array $item Ассоциативный массив значений @return mixed Результат выполнения операции @deprecated
[ "Вставка", "элемента", "в", "БД" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L308-L330
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.update
public function update($table, $set, $condition) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $q = Eresus_DB::getHandler()->createUpdateQuery(); $q->update($table) ->where($condition); $set = explode(',', $set); foreach ($set as $each) { list($key, $value) = explode('=', $each); $key = str_replace('`', '', trim($key)); $value = preg_replace('/(^\'|\'$)/', '', trim($value)); $q->set($key, $q->bindValue($value)); } $q->execute(); }
php
public function update($table, $set, $condition) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $q = Eresus_DB::getHandler()->createUpdateQuery(); $q->update($table) ->where($condition); $set = explode(',', $set); foreach ($set as $each) { list($key, $value) = explode('=', $each); $key = str_replace('`', '', trim($key)); $value = preg_replace('/(^\'|\'$)/', '', trim($value)); $q->set($key, $q->bindValue($value)); } $q->execute(); }
[ "public", "function", "update", "(", "$", "table", ",", "$", "set", ",", "$", "condition", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "q", "=", "Eresus_DB", "::", "getHandler", "(", ")", "->", "createUpdateQuery", "(", ")", ";", "$", "q", "->", "update", "(", "$", "table", ")", "->", "where", "(", "$", "condition", ")", ";", "$", "set", "=", "explode", "(", "','", ",", "$", "set", ")", ";", "foreach", "(", "$", "set", "as", "$", "each", ")", "{", "list", "(", "$", "key", ",", "$", "value", ")", "=", "explode", "(", "'='", ",", "$", "each", ")", ";", "$", "key", "=", "str_replace", "(", "'`'", ",", "''", ",", "trim", "(", "$", "key", ")", ")", ";", "$", "value", "=", "preg_replace", "(", "'/(^\\'|\\'$)/'", ",", "''", ",", "trim", "(", "$", "value", ")", ")", ";", "$", "q", "->", "set", "(", "$", "key", ",", "$", "q", "->", "bindValue", "(", "$", "value", ")", ")", ";", "}", "$", "q", "->", "execute", "(", ")", ";", "}" ]
Выполняет обновление информации в источнике @param string $table Таблица @param mixed $set Изменения @param string $condition Условие @return void @deprecated
[ "Выполняет", "обновление", "информации", "в", "источнике" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L342-L359
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.delete
public function delete($table, $condition) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $q = Eresus_DB::getHandler()->createDeleteQuery(); $q->deleteFrom($table) ->where($condition); $q->execute(); return null; }
php
public function delete($table, $condition) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $q = Eresus_DB::getHandler()->createDeleteQuery(); $q->deleteFrom($table) ->where($condition); $q->execute(); return null; }
[ "public", "function", "delete", "(", "$", "table", ",", "$", "condition", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "q", "=", "Eresus_DB", "::", "getHandler", "(", ")", "->", "createDeleteQuery", "(", ")", ";", "$", "q", "->", "deleteFrom", "(", "$", "table", ")", "->", "where", "(", "$", "condition", ")", ";", "$", "q", "->", "execute", "(", ")", ";", "return", "null", ";", "}" ]
Выполняет запрос DELETE к базе данных @param string $table таблица, из которой требуется удалить записи @param string $condition признаки удаляемых записей @return mixed @deprecated
[ "Выполняет", "запрос", "DELETE", "к", "базе", "данных" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L369-L377
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.fields
public function fields($table, $info = false) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $schm = $this->getSchema()->getSchema(); if ($schm[$table]->fields) { return array_keys($schm[$table]->fields); } else { return false; } }
php
public function fields($table, $info = false) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $schm = $this->getSchema()->getSchema(); if ($schm[$table]->fields) { return array_keys($schm[$table]->fields); } else { return false; } }
[ "public", "function", "fields", "(", "$", "table", ",", "$", "info", "=", "false", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "schm", "=", "$", "this", "->", "getSchema", "(", ")", "->", "getSchema", "(", ")", ";", "if", "(", "$", "schm", "[", "$", "table", "]", "->", "fields", ")", "{", "return", "array_keys", "(", "$", "schm", "[", "$", "table", "]", "->", "fields", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Получение списка полей таблицы @param string $table Имя таблицы @param bool $info [optional] @return array|bool Список полей, с описанием, если $info = true @deprecated с 2.14
[ "Получение", "списка", "полей", "таблицы" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L388-L400
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.selectItem
public function selectItem($table, $condition, $fields = '') { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $q = Eresus_DB::getHandler()->createSelectQuery(); if ($fields == '') { $fields = '*'; } $q->select($fields); $q->from($table); $q->where($condition); $q->limit(1); $item = $q->fetch(); return $item; }
php
public function selectItem($table, $condition, $fields = '') { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $q = Eresus_DB::getHandler()->createSelectQuery(); if ($fields == '') { $fields = '*'; } $q->select($fields); $q->from($table); $q->where($condition); $q->limit(1); $item = $q->fetch(); return $item; }
[ "public", "function", "selectItem", "(", "$", "table", ",", "$", "condition", ",", "$", "fields", "=", "''", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "q", "=", "Eresus_DB", "::", "getHandler", "(", ")", "->", "createSelectQuery", "(", ")", ";", "if", "(", "$", "fields", "==", "''", ")", "{", "$", "fields", "=", "'*'", ";", "}", "$", "q", "->", "select", "(", "$", "fields", ")", ";", "$", "q", "->", "from", "(", "$", "table", ")", ";", "$", "q", "->", "where", "(", "$", "condition", ")", ";", "$", "q", "->", "limit", "(", "1", ")", ";", "$", "item", "=", "$", "q", "->", "fetch", "(", ")", ";", "return", "$", "item", ";", "}" ]
Выбрать одну запись из БД @param string $table Имя таблицы @param string $condition SQL-условие @param string $fields Выбираемые поля @return array|bool @deprecated
[ "Выбрать", "одну", "запись", "из", "БД" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L411-L429
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.updateItem
public function updateItem($table, $item, $condition) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $fields = $this->fields($table); if (!$table) { return false; } $q = Eresus_DB::getHandler()->createUpdateQuery(); $q->update($table) ->where($condition); foreach ($fields as $field) { if (isset($item[$field])) { $q->set($field, $q->bindValue($item[$field])); } } $q->execute(); return true; }
php
public function updateItem($table, $item, $condition) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $fields = $this->fields($table); if (!$table) { return false; } $q = Eresus_DB::getHandler()->createUpdateQuery(); $q->update($table) ->where($condition); foreach ($fields as $field) { if (isset($item[$field])) { $q->set($field, $q->bindValue($item[$field])); } } $q->execute(); return true; }
[ "public", "function", "updateItem", "(", "$", "table", ",", "$", "item", ",", "$", "condition", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "fields", "=", "$", "this", "->", "fields", "(", "$", "table", ")", ";", "if", "(", "!", "$", "table", ")", "{", "return", "false", ";", "}", "$", "q", "=", "Eresus_DB", "::", "getHandler", "(", ")", "->", "createUpdateQuery", "(", ")", ";", "$", "q", "->", "update", "(", "$", "table", ")", "->", "where", "(", "$", "condition", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "item", "[", "$", "field", "]", ")", ")", "{", "$", "q", "->", "set", "(", "$", "field", ",", "$", "q", "->", "bindValue", "(", "$", "item", "[", "$", "field", "]", ")", ")", ";", "}", "}", "$", "q", "->", "execute", "(", ")", ";", "return", "true", ";", "}" ]
Обновляет одну запись @param string $table @param array $item @param string $condition @return bool @deprecated
[ "Обновляет", "одну", "запись" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L440-L463
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.count
public function count($table, $condition = false, $group = false, $rows = false) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $q = Eresus_DB::getHandler()->createSelectQuery(); $e = $q->expr; $q->select($q->alias($e->count('*'), 'count')); $q->from($table); if ($condition) { $q->where($condition); } if ($group) { $q->groupBy($group); } $result = $q->fetchAll(); if ($rows) { return count($result); } else { return intval($result[0]['count']); } }
php
public function count($table, $condition = false, $group = false, $rows = false) { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $q = Eresus_DB::getHandler()->createSelectQuery(); $e = $q->expr; $q->select($q->alias($e->count('*'), 'count')); $q->from($table); if ($condition) { $q->where($condition); } if ($group) { $q->groupBy($group); } $result = $q->fetchAll(); if ($rows) { return count($result); } else { return intval($result[0]['count']); } }
[ "public", "function", "count", "(", "$", "table", ",", "$", "condition", "=", "false", ",", "$", "group", "=", "false", ",", "$", "rows", "=", "false", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "q", "=", "Eresus_DB", "::", "getHandler", "(", ")", "->", "createSelectQuery", "(", ")", ";", "$", "e", "=", "$", "q", "->", "expr", ";", "$", "q", "->", "select", "(", "$", "q", "->", "alias", "(", "$", "e", "->", "count", "(", "'*'", ")", ",", "'count'", ")", ")", ";", "$", "q", "->", "from", "(", "$", "table", ")", ";", "if", "(", "$", "condition", ")", "{", "$", "q", "->", "where", "(", "$", "condition", ")", ";", "}", "if", "(", "$", "group", ")", "{", "$", "q", "->", "groupBy", "(", "$", "group", ")", ";", "}", "$", "result", "=", "$", "q", "->", "fetchAll", "(", ")", ";", "if", "(", "$", "rows", ")", "{", "return", "count", "(", "$", "result", ")", ";", "}", "else", "{", "return", "intval", "(", "$", "result", "[", "0", "]", "[", "'count'", "]", ")", ";", "}", "}" ]
Возвращает количество записей в таблице @param string $table таблица, для которой требуется посчитать кол-во записей @param string $condition @param string $group @param bool $rows @return int @deprecated
[ "Возвращает", "количество", "записей", "в", "таблице" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L475-L503
Eresus/EresusCMS
src/core/lib/mysql.php
MySQL.getInsertedID
public function getInsertedID() { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); return $db->lastInsertId(); }
php
public function getInsertedID() { Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated'); $db = Eresus_DB::getHandler(); return $db->lastInsertId(); }
[ "public", "function", "getInsertedID", "(", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_NOTICE", ",", "'This method is deprecated'", ")", ";", "$", "db", "=", "Eresus_DB", "::", "getHandler", "(", ")", ";", "return", "$", "db", "->", "lastInsertId", "(", ")", ";", "}" ]
Возвращает идентификатор последней вставленной записи @return mixed @deprecated
[ "Возвращает", "идентификатор", "последней", "вставленной", "записи" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/mysql.php#L512-L517
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.setOptions
public function setOptions( $options ) { if ( is_array( $options ) ) { $this->options->merge( $options ); } else if ( $options instanceof ezcTranslationTsBackendOptions ) { $this->options = $options; } else { throw new ezcBaseValueException( "options", $options, "instance of ezcTranslationTsBackendOptions" ); } }
php
public function setOptions( $options ) { if ( is_array( $options ) ) { $this->options->merge( $options ); } else if ( $options instanceof ezcTranslationTsBackendOptions ) { $this->options = $options; } else { throw new ezcBaseValueException( "options", $options, "instance of ezcTranslationTsBackendOptions" ); } }
[ "public", "function", "setOptions", "(", "$", "options", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "$", "this", "->", "options", "->", "merge", "(", "$", "options", ")", ";", "}", "else", "if", "(", "$", "options", "instanceof", "ezcTranslationTsBackendOptions", ")", "{", "$", "this", "->", "options", "=", "$", "options", ";", "}", "else", "{", "throw", "new", "ezcBaseValueException", "(", "\"options\"", ",", "$", "options", ",", "\"instance of ezcTranslationTsBackendOptions\"", ")", ";", "}", "}" ]
Set new options. This method allows you to change the options of the translation backend. @param ezcTranslationTsBackendOptions $options The options to set. @throws ezcBaseSettingNotFoundException If you tried to set a non-existent option value. @throws ezcBaseSettingValueException If the value is not valid for the desired option. @throws ezcBaseValueException If you submit neither an array nor an instance of ezcTranslationTsBackendOptions.
[ "Set", "new", "options", ".", "This", "method", "allows", "you", "to", "change", "the", "options", "of", "the", "translation", "backend", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L162-L176
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.buildTranslationFileName
public function buildTranslationFileName( $locale ) { $filename = $this->options->location . $this->options->format; $filename = str_replace( '[LOCALE]', $locale, $filename ); return $filename; }
php
public function buildTranslationFileName( $locale ) { $filename = $this->options->location . $this->options->format; $filename = str_replace( '[LOCALE]', $locale, $filename ); return $filename; }
[ "public", "function", "buildTranslationFileName", "(", "$", "locale", ")", "{", "$", "filename", "=", "$", "this", "->", "options", "->", "location", ".", "$", "this", "->", "options", "->", "format", ";", "$", "filename", "=", "str_replace", "(", "'[LOCALE]'", ",", "$", "locale", ",", "$", "filename", ")", ";", "return", "$", "filename", ";", "}" ]
Returns the filename for the translation file using the locale $locale. This function uses the <i>location</i> and <i>format</i> options, combined with the $locale parameter to form a filename that contains the translation belonging to the specified locale. @param string $locale @return string
[ "Returns", "the", "filename", "for", "the", "translation", "file", "using", "the", "locale", "$locale", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L199-L204
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.openTranslationFile
public function openTranslationFile( $locale, $returnClass = 'SimpleXMLElement' ) { $filename = $this->buildTranslationFileName( $locale ); if ( !file_exists( $filename ) ) { throw new ezcTranslationMissingTranslationFileException( $filename ); } return simplexml_load_file( $filename, $returnClass ); }
php
public function openTranslationFile( $locale, $returnClass = 'SimpleXMLElement' ) { $filename = $this->buildTranslationFileName( $locale ); if ( !file_exists( $filename ) ) { throw new ezcTranslationMissingTranslationFileException( $filename ); } return simplexml_load_file( $filename, $returnClass ); }
[ "public", "function", "openTranslationFile", "(", "$", "locale", ",", "$", "returnClass", "=", "'SimpleXMLElement'", ")", "{", "$", "filename", "=", "$", "this", "->", "buildTranslationFileName", "(", "$", "locale", ")", ";", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "new", "ezcTranslationMissingTranslationFileException", "(", "$", "filename", ")", ";", "}", "return", "simplexml_load_file", "(", "$", "filename", ",", "$", "returnClass", ")", ";", "}" ]
Creates an SimpleXML parser object for the locale $locale. You can set the class of the returned object through the $returnClass parameter. That class should extend the SimpleXMLElement class. This function checks if the <i>location</i> setting is made, if the file with the filename as returned by buildTranslationFileName() exists and creates a SimpleXML parser object for this file. If either the setting is not made, or the file doesn't exists it throws an exception. @throws ezcTranslationMissingTranslationFileException if the translation could not be opened. @param string $locale @param string $returnClass The class of the returned XML Parser Object. @return object The created parser. The parameter $returnClass determines what type of class gets returned. The classname that you specify should be inherited from SimpleXMLElement.
[ "Creates", "an", "SimpleXML", "parser", "object", "for", "the", "locale", "$locale", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L226-L234
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.openTranslationFileForWriting
public function openTranslationFileForWriting( $locale ) { $filename = $this->buildTranslationFileName( $locale ); if ( !file_exists( $filename ) ) { $dom = new DOMDocument( '1.0', 'UTF-8' ); $dom->formatOutput = true; $root = $dom->createElement( 'TS' ); $dom->appendChild( $root ); } else { $dom = new DOMDocument( '1.0', 'UTF-8' ); $dom->preserveWhiteSpace = false; $dom->load( $filename ); $dom->formatOutput = true; $root = $dom->getElementsByTagName( 'TS' )->item( 0 ); } return $dom; }
php
public function openTranslationFileForWriting( $locale ) { $filename = $this->buildTranslationFileName( $locale ); if ( !file_exists( $filename ) ) { $dom = new DOMDocument( '1.0', 'UTF-8' ); $dom->formatOutput = true; $root = $dom->createElement( 'TS' ); $dom->appendChild( $root ); } else { $dom = new DOMDocument( '1.0', 'UTF-8' ); $dom->preserveWhiteSpace = false; $dom->load( $filename ); $dom->formatOutput = true; $root = $dom->getElementsByTagName( 'TS' )->item( 0 ); } return $dom; }
[ "public", "function", "openTranslationFileForWriting", "(", "$", "locale", ")", "{", "$", "filename", "=", "$", "this", "->", "buildTranslationFileName", "(", "$", "locale", ")", ";", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "dom", "=", "new", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "dom", "->", "formatOutput", "=", "true", ";", "$", "root", "=", "$", "dom", "->", "createElement", "(", "'TS'", ")", ";", "$", "dom", "->", "appendChild", "(", "$", "root", ")", ";", "}", "else", "{", "$", "dom", "=", "new", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "dom", "->", "preserveWhiteSpace", "=", "false", ";", "$", "dom", "->", "load", "(", "$", "filename", ")", ";", "$", "dom", "->", "formatOutput", "=", "true", ";", "$", "root", "=", "$", "dom", "->", "getElementsByTagName", "(", "'TS'", ")", "->", "item", "(", "0", ")", ";", "}", "return", "$", "dom", ";", "}" ]
Creates a DOM parser object for the locale $locale. This function checks if the <i>location</i> setting is made, if the file with the filename as returned by buildTranslationFileName() exists and creates a DOM parser object for this file. If the setting is not made, it throws an exception. IF the file does not exist, a new DomDocument is created. @param string $locale @return object The created parser.
[ "Creates", "a", "DOM", "parser", "object", "for", "the", "locale", "$locale", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L248-L268
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.parseSimpleXMLMessage
private function parseSimpleXMLMessage( SimpleXMLElement $message ) { $status = ezcTranslationData::TRANSLATED; if ( $message->translation['type'] == 'unfinished' ) { $status = ezcTranslationData::UNFINISHED; } else if ( $message->translation['type'] == 'obsolete' ) { if ( $this->options->keepObsolete ) { $status = ezcTranslationData::OBSOLETE; } else { return null; } } $source = trim( (string) $message->source ); $translation = trim( (string) $message->translation ); $comment = trim( (string) $message->comment ); $source = strlen( $source ) ? $source : false; $translation = strlen( $translation ) ? $translation : false; $comment = strlen( $comment ) ? $comment : false; $location = $message->location; $file = $line = false; if ( $location ) { $file = trim( (string) $location['filename'] ); $line = trim( (string) $location['line'] ); } return new ezcTranslationData( $source, $translation, $comment, $status, $file, $line ); }
php
private function parseSimpleXMLMessage( SimpleXMLElement $message ) { $status = ezcTranslationData::TRANSLATED; if ( $message->translation['type'] == 'unfinished' ) { $status = ezcTranslationData::UNFINISHED; } else if ( $message->translation['type'] == 'obsolete' ) { if ( $this->options->keepObsolete ) { $status = ezcTranslationData::OBSOLETE; } else { return null; } } $source = trim( (string) $message->source ); $translation = trim( (string) $message->translation ); $comment = trim( (string) $message->comment ); $source = strlen( $source ) ? $source : false; $translation = strlen( $translation ) ? $translation : false; $comment = strlen( $comment ) ? $comment : false; $location = $message->location; $file = $line = false; if ( $location ) { $file = trim( (string) $location['filename'] ); $line = trim( (string) $location['line'] ); } return new ezcTranslationData( $source, $translation, $comment, $status, $file, $line ); }
[ "private", "function", "parseSimpleXMLMessage", "(", "SimpleXMLElement", "$", "message", ")", "{", "$", "status", "=", "ezcTranslationData", "::", "TRANSLATED", ";", "if", "(", "$", "message", "->", "translation", "[", "'type'", "]", "==", "'unfinished'", ")", "{", "$", "status", "=", "ezcTranslationData", "::", "UNFINISHED", ";", "}", "else", "if", "(", "$", "message", "->", "translation", "[", "'type'", "]", "==", "'obsolete'", ")", "{", "if", "(", "$", "this", "->", "options", "->", "keepObsolete", ")", "{", "$", "status", "=", "ezcTranslationData", "::", "OBSOLETE", ";", "}", "else", "{", "return", "null", ";", "}", "}", "$", "source", "=", "trim", "(", "(", "string", ")", "$", "message", "->", "source", ")", ";", "$", "translation", "=", "trim", "(", "(", "string", ")", "$", "message", "->", "translation", ")", ";", "$", "comment", "=", "trim", "(", "(", "string", ")", "$", "message", "->", "comment", ")", ";", "$", "source", "=", "strlen", "(", "$", "source", ")", "?", "$", "source", ":", "false", ";", "$", "translation", "=", "strlen", "(", "$", "translation", ")", "?", "$", "translation", ":", "false", ";", "$", "comment", "=", "strlen", "(", "$", "comment", ")", "?", "$", "comment", ":", "false", ";", "$", "location", "=", "$", "message", "->", "location", ";", "$", "file", "=", "$", "line", "=", "false", ";", "if", "(", "$", "location", ")", "{", "$", "file", "=", "trim", "(", "(", "string", ")", "$", "location", "[", "'filename'", "]", ")", ";", "$", "line", "=", "trim", "(", "(", "string", ")", "$", "location", "[", "'line'", "]", ")", ";", "}", "return", "new", "ezcTranslationData", "(", "$", "source", ",", "$", "translation", ",", "$", "comment", ",", "$", "status", ",", "$", "file", ",", "$", "line", ")", ";", "}" ]
Returns the data from the XML element $message as an ezcTranslationData object. @param SimpleXMLElement $message @return ezcTranslationData
[ "Returns", "the", "data", "from", "the", "XML", "element", "$message", "as", "an", "ezcTranslationData", "object", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L277-L313
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.getContext
public function getContext( $locale, $context ) { $ts = $this->openTranslationFile( $locale ); $contextElements = array(); foreach ( $ts as $trContext ) { if ( (string) $trContext->name == $context ) { foreach ( $trContext as $message ) { if ( $message->source != '' ) { $element = $this->parseSimpleXMLMessage( $message ); if ( is_null( $element ) ) { continue; } $contextElements[] = $element; } } return $contextElements; } } throw new ezcTranslationContextNotAvailableException( $context ); }
php
public function getContext( $locale, $context ) { $ts = $this->openTranslationFile( $locale ); $contextElements = array(); foreach ( $ts as $trContext ) { if ( (string) $trContext->name == $context ) { foreach ( $trContext as $message ) { if ( $message->source != '' ) { $element = $this->parseSimpleXMLMessage( $message ); if ( is_null( $element ) ) { continue; } $contextElements[] = $element; } } return $contextElements; } } throw new ezcTranslationContextNotAvailableException( $context ); }
[ "public", "function", "getContext", "(", "$", "locale", ",", "$", "context", ")", "{", "$", "ts", "=", "$", "this", "->", "openTranslationFile", "(", "$", "locale", ")", ";", "$", "contextElements", "=", "array", "(", ")", ";", "foreach", "(", "$", "ts", "as", "$", "trContext", ")", "{", "if", "(", "(", "string", ")", "$", "trContext", "->", "name", "==", "$", "context", ")", "{", "foreach", "(", "$", "trContext", "as", "$", "message", ")", "{", "if", "(", "$", "message", "->", "source", "!=", "''", ")", "{", "$", "element", "=", "$", "this", "->", "parseSimpleXMLMessage", "(", "$", "message", ")", ";", "if", "(", "is_null", "(", "$", "element", ")", ")", "{", "continue", ";", "}", "$", "contextElements", "[", "]", "=", "$", "element", ";", "}", "}", "return", "$", "contextElements", ";", "}", "}", "throw", "new", "ezcTranslationContextNotAvailableException", "(", "$", "context", ")", ";", "}" ]
Returns a array containing a translation map for the locale $locale and the context $context. This method returns an array containing the translation map for the specified $locale and $context. It uses the location and format options to locate the file, unless caching is enabled. @throws ezcTranslationContextNotAvailableException if a context is not available @throws ezcTranslationMissingTranslationFileException if the translation file does not exist. @throws ezcTranslationNotConfiguredException if the option <i>format</i> is not set before this method is called. @param string $locale @param string $context @return array(ezcTranslationData)
[ "Returns", "a", "array", "containing", "a", "translation", "map", "for", "the", "locale", "$locale", "and", "the", "context", "$context", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L335-L359
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.getContextNames
public function getContextNames( $locale ) { $ts = $this->openTranslationFile( $locale ); $contextNames = array(); foreach ( $ts as $trContext ) { $contextNames[] = (string) $trContext->name; } return $contextNames; }
php
public function getContextNames( $locale ) { $ts = $this->openTranslationFile( $locale ); $contextNames = array(); foreach ( $ts as $trContext ) { $contextNames[] = (string) $trContext->name; } return $contextNames; }
[ "public", "function", "getContextNames", "(", "$", "locale", ")", "{", "$", "ts", "=", "$", "this", "->", "openTranslationFile", "(", "$", "locale", ")", ";", "$", "contextNames", "=", "array", "(", ")", ";", "foreach", "(", "$", "ts", "as", "$", "trContext", ")", "{", "$", "contextNames", "[", "]", "=", "(", "string", ")", "$", "trContext", "->", "name", ";", "}", "return", "$", "contextNames", ";", "}" ]
Returns a list with all context names for the locale $locale. @throws ezcTranslationMissingTranslationFileException if the translation file does not exist. @throws ezcTranslationNotConfiguredException if the option <i>format</i> is not set before this method is called. @param string $locale @return array(string)
[ "Returns", "a", "list", "with", "all", "context", "names", "for", "the", "locale", "$locale", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L371-L380
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.initReader
public function initReader( $locale ) { $this->xmlParser = $this->openTranslationFile( $locale, 'SimpleXMLIterator' ); $this->xmlParser->rewind(); }
php
public function initReader( $locale ) { $this->xmlParser = $this->openTranslationFile( $locale, 'SimpleXMLIterator' ); $this->xmlParser->rewind(); }
[ "public", "function", "initReader", "(", "$", "locale", ")", "{", "$", "this", "->", "xmlParser", "=", "$", "this", "->", "openTranslationFile", "(", "$", "locale", ",", "'SimpleXMLIterator'", ")", ";", "$", "this", "->", "xmlParser", "->", "rewind", "(", ")", ";", "}" ]
Initializes the reader to read from locale $locale. Opens the translation file. @throws ezcTranslationNotConfiguredException if the option <i>format</i> is not set before this method is called. @param string $locale @return void
[ "Initializes", "the", "reader", "to", "read", "from", "locale", "$locale", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L393-L397
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.storeContext
public function storeContext( $context, array $data ) { if ( is_null( $this->dom ) ) { throw new ezcTranslationWriterNotInitializedException(); } $dom = $this->dom; $root = $dom->getElementsByTagName( 'TS' )->item( 0 ); // find the context element $xpath = new DOMXPath( $dom ); $result = $xpath->query( '//context/name[text()="' . htmlspecialchars( $context ) . '"]' ); // If the context does not exist, we create a node for it; otherwise we just use it. if ( !$result->length ) { $contextNode = $dom->createElement( 'context' ); $nameNode = $dom->createElement( 'name', htmlspecialchars( $context ) ); $contextNode->appendChild( $nameNode ); $root->appendChild( $contextNode ); } else { $contextNode = $result->item( 0 )->parentNode; } // for every entry, we add a new message foreach ( $data as $info ) { // check if the string is already there, if so, remove it first $xpath = new DOMXPath( $dom ); $xpathString = str_replace( '"', '",\'"\',"', $info->original ); $result = $xpath->query( 'message/source[text()=concat("' . $xpathString . '","")]', $contextNode ); if ( $result->length ) { $node = $result->item( 0 )->parentNode; $contextNode->removeChild( $node ); } // create the new element $message = $dom->createElement( 'message' ); $source = $dom->createElement( 'source', htmlspecialchars( $info->original ) ); $message->appendChild( $source ); $translation = $dom->createElement( 'translation', htmlspecialchars( $info->translation ) ); switch ( $info->status ) { case ezcTranslationData::UNFINISHED: $translation->setAttribute( 'type', 'unfinished' ); break; case ezcTranslationData::OBSOLETE: $translation->setAttribute( 'type', 'obsolete' ); break; } $message->appendChild( $translation ); if ( $info->comment ) { $comment = $dom->createElement( 'comment', htmlspecialchars( $info->comment ) ); $message->appendChild( $comment ); } if ( $info->filename && $info->line ) { $location = $dom->createElement( 'location' ); $location->setAttribute( 'filename', $info->filename ); $location->setAttribute( 'line', $info->line ); $message->appendChild( $location ); } $contextNode->appendChild( $message ); } }
php
public function storeContext( $context, array $data ) { if ( is_null( $this->dom ) ) { throw new ezcTranslationWriterNotInitializedException(); } $dom = $this->dom; $root = $dom->getElementsByTagName( 'TS' )->item( 0 ); // find the context element $xpath = new DOMXPath( $dom ); $result = $xpath->query( '//context/name[text()="' . htmlspecialchars( $context ) . '"]' ); // If the context does not exist, we create a node for it; otherwise we just use it. if ( !$result->length ) { $contextNode = $dom->createElement( 'context' ); $nameNode = $dom->createElement( 'name', htmlspecialchars( $context ) ); $contextNode->appendChild( $nameNode ); $root->appendChild( $contextNode ); } else { $contextNode = $result->item( 0 )->parentNode; } // for every entry, we add a new message foreach ( $data as $info ) { // check if the string is already there, if so, remove it first $xpath = new DOMXPath( $dom ); $xpathString = str_replace( '"', '",\'"\',"', $info->original ); $result = $xpath->query( 'message/source[text()=concat("' . $xpathString . '","")]', $contextNode ); if ( $result->length ) { $node = $result->item( 0 )->parentNode; $contextNode->removeChild( $node ); } // create the new element $message = $dom->createElement( 'message' ); $source = $dom->createElement( 'source', htmlspecialchars( $info->original ) ); $message->appendChild( $source ); $translation = $dom->createElement( 'translation', htmlspecialchars( $info->translation ) ); switch ( $info->status ) { case ezcTranslationData::UNFINISHED: $translation->setAttribute( 'type', 'unfinished' ); break; case ezcTranslationData::OBSOLETE: $translation->setAttribute( 'type', 'obsolete' ); break; } $message->appendChild( $translation ); if ( $info->comment ) { $comment = $dom->createElement( 'comment', htmlspecialchars( $info->comment ) ); $message->appendChild( $comment ); } if ( $info->filename && $info->line ) { $location = $dom->createElement( 'location' ); $location->setAttribute( 'filename', $info->filename ); $location->setAttribute( 'line', $info->line ); $message->appendChild( $location ); } $contextNode->appendChild( $message ); } }
[ "public", "function", "storeContext", "(", "$", "context", ",", "array", "$", "data", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "dom", ")", ")", "{", "throw", "new", "ezcTranslationWriterNotInitializedException", "(", ")", ";", "}", "$", "dom", "=", "$", "this", "->", "dom", ";", "$", "root", "=", "$", "dom", "->", "getElementsByTagName", "(", "'TS'", ")", "->", "item", "(", "0", ")", ";", "// find the context element", "$", "xpath", "=", "new", "DOMXPath", "(", "$", "dom", ")", ";", "$", "result", "=", "$", "xpath", "->", "query", "(", "'//context/name[text()=\"'", ".", "htmlspecialchars", "(", "$", "context", ")", ".", "'\"]'", ")", ";", "// If the context does not exist, we create a node for it; otherwise we just use it.", "if", "(", "!", "$", "result", "->", "length", ")", "{", "$", "contextNode", "=", "$", "dom", "->", "createElement", "(", "'context'", ")", ";", "$", "nameNode", "=", "$", "dom", "->", "createElement", "(", "'name'", ",", "htmlspecialchars", "(", "$", "context", ")", ")", ";", "$", "contextNode", "->", "appendChild", "(", "$", "nameNode", ")", ";", "$", "root", "->", "appendChild", "(", "$", "contextNode", ")", ";", "}", "else", "{", "$", "contextNode", "=", "$", "result", "->", "item", "(", "0", ")", "->", "parentNode", ";", "}", "// for every entry, we add a new message", "foreach", "(", "$", "data", "as", "$", "info", ")", "{", "// check if the string is already there, if so, remove it first", "$", "xpath", "=", "new", "DOMXPath", "(", "$", "dom", ")", ";", "$", "xpathString", "=", "str_replace", "(", "'\"'", ",", "'\",\\'\"\\',\"'", ",", "$", "info", "->", "original", ")", ";", "$", "result", "=", "$", "xpath", "->", "query", "(", "'message/source[text()=concat(\"'", ".", "$", "xpathString", ".", "'\",\"\")]'", ",", "$", "contextNode", ")", ";", "if", "(", "$", "result", "->", "length", ")", "{", "$", "node", "=", "$", "result", "->", "item", "(", "0", ")", "->", "parentNode", ";", "$", "contextNode", "->", "removeChild", "(", "$", "node", ")", ";", "}", "// create the new element", "$", "message", "=", "$", "dom", "->", "createElement", "(", "'message'", ")", ";", "$", "source", "=", "$", "dom", "->", "createElement", "(", "'source'", ",", "htmlspecialchars", "(", "$", "info", "->", "original", ")", ")", ";", "$", "message", "->", "appendChild", "(", "$", "source", ")", ";", "$", "translation", "=", "$", "dom", "->", "createElement", "(", "'translation'", ",", "htmlspecialchars", "(", "$", "info", "->", "translation", ")", ")", ";", "switch", "(", "$", "info", "->", "status", ")", "{", "case", "ezcTranslationData", "::", "UNFINISHED", ":", "$", "translation", "->", "setAttribute", "(", "'type'", ",", "'unfinished'", ")", ";", "break", ";", "case", "ezcTranslationData", "::", "OBSOLETE", ":", "$", "translation", "->", "setAttribute", "(", "'type'", ",", "'obsolete'", ")", ";", "break", ";", "}", "$", "message", "->", "appendChild", "(", "$", "translation", ")", ";", "if", "(", "$", "info", "->", "comment", ")", "{", "$", "comment", "=", "$", "dom", "->", "createElement", "(", "'comment'", ",", "htmlspecialchars", "(", "$", "info", "->", "comment", ")", ")", ";", "$", "message", "->", "appendChild", "(", "$", "comment", ")", ";", "}", "if", "(", "$", "info", "->", "filename", "&&", "$", "info", "->", "line", ")", "{", "$", "location", "=", "$", "dom", "->", "createElement", "(", "'location'", ")", ";", "$", "location", "->", "setAttribute", "(", "'filename'", ",", "$", "info", "->", "filename", ")", ";", "$", "location", "->", "setAttribute", "(", "'line'", ",", "$", "info", "->", "line", ")", ";", "$", "message", "->", "appendChild", "(", "$", "location", ")", ";", "}", "$", "contextNode", "->", "appendChild", "(", "$", "message", ")", ";", "}", "}" ]
Stores a context. This method stores the context that it received to the backend specified storage place. @throws ezcTranslationWriterNotInitializedException when the writer is not initialized with initWriter(). @param string $context The context's name @param array(ezcTranslationData) $data The context's translation map @return void
[ "Stores", "a", "context", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L426-L500
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.initWriter
public function initWriter( $locale ) { $this->dom = $this->openTranslationFileForWriting( $locale ); $this->writeLocale = $locale; }
php
public function initWriter( $locale ) { $this->dom = $this->openTranslationFileForWriting( $locale ); $this->writeLocale = $locale; }
[ "public", "function", "initWriter", "(", "$", "locale", ")", "{", "$", "this", "->", "dom", "=", "$", "this", "->", "openTranslationFileForWriting", "(", "$", "locale", ")", ";", "$", "this", "->", "writeLocale", "=", "$", "locale", ";", "}" ]
Initializes the writer to write to locale $locale. Opens the translation file. @throws ezcTranslationNotConfiguredException if the option <i>format</i> is not set before this method is called. @param string $locale @return void
[ "Initializes", "the", "writer", "to", "write", "to", "locale", "$locale", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L513-L517
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.deinitWriter
public function deinitWriter() { if ( is_null( $this->dom ) ) { throw new ezcTranslationWriterNotInitializedException(); } $filename = $this->buildTranslationFileName( $this->writeLocale ); $this->dom->save( $filename ); }
php
public function deinitWriter() { if ( is_null( $this->dom ) ) { throw new ezcTranslationWriterNotInitializedException(); } $filename = $this->buildTranslationFileName( $this->writeLocale ); $this->dom->save( $filename ); }
[ "public", "function", "deinitWriter", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "dom", ")", ")", "{", "throw", "new", "ezcTranslationWriterNotInitializedException", "(", ")", ";", "}", "$", "filename", "=", "$", "this", "->", "buildTranslationFileName", "(", "$", "this", "->", "writeLocale", ")", ";", "$", "this", "->", "dom", "->", "save", "(", "$", "filename", ")", ";", "}" ]
Deinitializes the writer @return void
[ "Deinitializes", "the", "writer" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L524-L532
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php
ezcTranslationTsBackend.next
public function next() { if ( is_null( $this->xmlParser ) ) { throw new ezcTranslationReaderNotInitializedException(); } $valid = $this->xmlParser->valid(); if ( $valid ) { $newContext = array( trim( $this->xmlParser->getChildren()->name), array() ); foreach ( $this->xmlParser->getChildren()->message as $data ) { $translationItem = $this->parseSimpleXMLMessage( $data ); if ( !is_null( $translationItem ) ) { $newContext[1][] = $translationItem; } } $this->currentContext = $newContext; $this->xmlParser->next(); } else { $this->currentContext = null; } }
php
public function next() { if ( is_null( $this->xmlParser ) ) { throw new ezcTranslationReaderNotInitializedException(); } $valid = $this->xmlParser->valid(); if ( $valid ) { $newContext = array( trim( $this->xmlParser->getChildren()->name), array() ); foreach ( $this->xmlParser->getChildren()->message as $data ) { $translationItem = $this->parseSimpleXMLMessage( $data ); if ( !is_null( $translationItem ) ) { $newContext[1][] = $translationItem; } } $this->currentContext = $newContext; $this->xmlParser->next(); } else { $this->currentContext = null; } }
[ "public", "function", "next", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "xmlParser", ")", ")", "{", "throw", "new", "ezcTranslationReaderNotInitializedException", "(", ")", ";", "}", "$", "valid", "=", "$", "this", "->", "xmlParser", "->", "valid", "(", ")", ";", "if", "(", "$", "valid", ")", "{", "$", "newContext", "=", "array", "(", "trim", "(", "$", "this", "->", "xmlParser", "->", "getChildren", "(", ")", "->", "name", ")", ",", "array", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "xmlParser", "->", "getChildren", "(", ")", "->", "message", "as", "$", "data", ")", "{", "$", "translationItem", "=", "$", "this", "->", "parseSimpleXMLMessage", "(", "$", "data", ")", ";", "if", "(", "!", "is_null", "(", "$", "translationItem", ")", ")", "{", "$", "newContext", "[", "1", "]", "[", "]", "=", "$", "translationItem", ";", "}", "}", "$", "this", "->", "currentContext", "=", "$", "newContext", ";", "$", "this", "->", "xmlParser", "->", "next", "(", ")", ";", "}", "else", "{", "$", "this", "->", "currentContext", "=", "null", ";", "}", "}" ]
Advanced to the next context. This method parses a little bit more of the XML file to be able to return the next context. If no more contexts are available it sets the $currentContext member variable to null, so that the valid() method can pick this up. If there are more contexts available it reads the context from the file and stores it into the $currentContext member variable. This method is used for iteration as part of the Iterator interface. @throws ezcTranslationReaderNotInitializedException when the reader is not initialized with initReader(). @return void
[ "Advanced", "to", "the", "next", "context", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/backends/ts_backend.php#L548-L577
eloquent/cosmos
src/Eloquent/Cosmos/ClassName.php
ClassName.fromString
public static function fromString($className) { $atoms = explode(static::NAMESPACE_SEPARATOR, $className); $isAbsolute = false; if ('' === $atoms[0]) { $isAbsolute = true; array_shift($atoms); } return static::fromAtoms($atoms, $isAbsolute); }
php
public static function fromString($className) { $atoms = explode(static::NAMESPACE_SEPARATOR, $className); $isAbsolute = false; if ('' === $atoms[0]) { $isAbsolute = true; array_shift($atoms); } return static::fromAtoms($atoms, $isAbsolute); }
[ "public", "static", "function", "fromString", "(", "$", "className", ")", "{", "$", "atoms", "=", "explode", "(", "static", "::", "NAMESPACE_SEPARATOR", ",", "$", "className", ")", ";", "$", "isAbsolute", "=", "false", ";", "if", "(", "''", "===", "$", "atoms", "[", "0", "]", ")", "{", "$", "isAbsolute", "=", "true", ";", "array_shift", "(", "$", "atoms", ")", ";", "}", "return", "static", "::", "fromAtoms", "(", "$", "atoms", ",", "$", "isAbsolute", ")", ";", "}" ]
@param string $className @return ClassName
[ "@param", "string", "$className" ]
train
https://github.com/eloquent/cosmos/blob/0226b7aa39c629cdbb41bde759adff59d932d16d/src/Eloquent/Cosmos/ClassName.php#L24-L34
eloquent/cosmos
src/Eloquent/Cosmos/ClassName.php
ClassName.isEqualTo
public function isEqualTo(ClassName $className, Comparator $comparator = null) { if (null === $comparator) { $comparator = new Comparator; } return $comparator->equals($this, $className); }
php
public function isEqualTo(ClassName $className, Comparator $comparator = null) { if (null === $comparator) { $comparator = new Comparator; } return $comparator->equals($this, $className); }
[ "public", "function", "isEqualTo", "(", "ClassName", "$", "className", ",", "Comparator", "$", "comparator", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparator", ")", "{", "$", "comparator", "=", "new", "Comparator", ";", "}", "return", "$", "comparator", "->", "equals", "(", "$", "this", ",", "$", "className", ")", ";", "}" ]
@param ClassName $className @param Comparator|null $comparator @return boolean
[ "@param", "ClassName", "$className", "@param", "Comparator|null", "$comparator" ]
train
https://github.com/eloquent/cosmos/blob/0226b7aa39c629cdbb41bde759adff59d932d16d/src/Eloquent/Cosmos/ClassName.php#L76-L83
eloquent/cosmos
src/Eloquent/Cosmos/ClassName.php
ClassName.join
public function join(ClassName $className) { if ($className->isAbsolute()) { throw new Exception\AbsoluteJoinException($className); } return static::joinAtomsArray($className->atoms()); }
php
public function join(ClassName $className) { if ($className->isAbsolute()) { throw new Exception\AbsoluteJoinException($className); } return static::joinAtomsArray($className->atoms()); }
[ "public", "function", "join", "(", "ClassName", "$", "className", ")", "{", "if", "(", "$", "className", "->", "isAbsolute", "(", ")", ")", "{", "throw", "new", "Exception", "\\", "AbsoluteJoinException", "(", "$", "className", ")", ";", "}", "return", "static", "::", "joinAtomsArray", "(", "$", "className", "->", "atoms", "(", ")", ")", ";", "}" ]
@param ClassName $className @return ClassName
[ "@param", "ClassName", "$className" ]
train
https://github.com/eloquent/cosmos/blob/0226b7aa39c629cdbb41bde759adff59d932d16d/src/Eloquent/Cosmos/ClassName.php#L100-L107
eloquent/cosmos
src/Eloquent/Cosmos/ClassName.php
ClassName.hasDescendant
public function hasDescendant(ClassName $className, Comparator $comparator = null) { if ($this->isAbsolute() !== $className->isAbsolute()) { return false; } if (null === $comparator) { $comparator = new Comparator; } while ($className->hasParent()) { $className = $className->parent(); if ($comparator->equals($this, $className)) { return true; } } return false; }
php
public function hasDescendant(ClassName $className, Comparator $comparator = null) { if ($this->isAbsolute() !== $className->isAbsolute()) { return false; } if (null === $comparator) { $comparator = new Comparator; } while ($className->hasParent()) { $className = $className->parent(); if ($comparator->equals($this, $className)) { return true; } } return false; }
[ "public", "function", "hasDescendant", "(", "ClassName", "$", "className", ",", "Comparator", "$", "comparator", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isAbsolute", "(", ")", "!==", "$", "className", "->", "isAbsolute", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "null", "===", "$", "comparator", ")", "{", "$", "comparator", "=", "new", "Comparator", ";", "}", "while", "(", "$", "className", "->", "hasParent", "(", ")", ")", "{", "$", "className", "=", "$", "className", "->", "parent", "(", ")", ";", "if", "(", "$", "comparator", "->", "equals", "(", "$", "this", ",", "$", "className", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
@param ClassName $className @param Comparator|null $comparator @return boolean
[ "@param", "ClassName", "$className", "@param", "Comparator|null", "$comparator" ]
train
https://github.com/eloquent/cosmos/blob/0226b7aa39c629cdbb41bde759adff59d932d16d/src/Eloquent/Cosmos/ClassName.php#L197-L215
eloquent/cosmos
src/Eloquent/Cosmos/ClassName.php
ClassName.stripNamespace
public function stripNamespace(ClassName $namespaceName) { if (!$namespaceName->hasDescendant($this)) { throw new Exception\NamespaceMismatchException( $this, $namespaceName ); } $atoms = $this->atoms(); array_splice($atoms, 0, count($namespaceName->atoms())); return static::fromAtoms($atoms, false); }
php
public function stripNamespace(ClassName $namespaceName) { if (!$namespaceName->hasDescendant($this)) { throw new Exception\NamespaceMismatchException( $this, $namespaceName ); } $atoms = $this->atoms(); array_splice($atoms, 0, count($namespaceName->atoms())); return static::fromAtoms($atoms, false); }
[ "public", "function", "stripNamespace", "(", "ClassName", "$", "namespaceName", ")", "{", "if", "(", "!", "$", "namespaceName", "->", "hasDescendant", "(", "$", "this", ")", ")", "{", "throw", "new", "Exception", "\\", "NamespaceMismatchException", "(", "$", "this", ",", "$", "namespaceName", ")", ";", "}", "$", "atoms", "=", "$", "this", "->", "atoms", "(", ")", ";", "array_splice", "(", "$", "atoms", ",", "0", ",", "count", "(", "$", "namespaceName", "->", "atoms", "(", ")", ")", ")", ";", "return", "static", "::", "fromAtoms", "(", "$", "atoms", ",", "false", ")", ";", "}" ]
@param ClassName $namespaceName @return ClassName
[ "@param", "ClassName", "$namespaceName" ]
train
https://github.com/eloquent/cosmos/blob/0226b7aa39c629cdbb41bde759adff59d932d16d/src/Eloquent/Cosmos/ClassName.php#L222-L235
eloquent/cosmos
src/Eloquent/Cosmos/ClassName.php
ClassName.exists
public function exists($useAutoload = null, Isolator $isolator = null) { if (null === $useAutoload) { $useAutoload = true; } $isolator = Isolator::get($isolator); return $isolator->class_exists($this->string(), $useAutoload); }
php
public function exists($useAutoload = null, Isolator $isolator = null) { if (null === $useAutoload) { $useAutoload = true; } $isolator = Isolator::get($isolator); return $isolator->class_exists($this->string(), $useAutoload); }
[ "public", "function", "exists", "(", "$", "useAutoload", "=", "null", ",", "Isolator", "$", "isolator", "=", "null", ")", "{", "if", "(", "null", "===", "$", "useAutoload", ")", "{", "$", "useAutoload", "=", "true", ";", "}", "$", "isolator", "=", "Isolator", "::", "get", "(", "$", "isolator", ")", ";", "return", "$", "isolator", "->", "class_exists", "(", "$", "this", "->", "string", "(", ")", ",", "$", "useAutoload", ")", ";", "}" ]
@param boolean|null $useAutoload @param Isolator $isolator @return boolean
[ "@param", "boolean|null", "$useAutoload", "@param", "Isolator", "$isolator" ]
train
https://github.com/eloquent/cosmos/blob/0226b7aa39c629cdbb41bde759adff59d932d16d/src/Eloquent/Cosmos/ClassName.php#L243-L251
frdl/webfan
.ApplicationComposer/lib/frdl/aSQL/Engines/Terminal/CLI.php
CLI.state
public function state($state = null){ if($state !== null)$this->force_state($state); return $this->state; }
php
public function state($state = null){ if($state !== null)$this->force_state($state); return $this->state; }
[ "public", "function", "state", "(", "$", "state", "=", "null", ")", "{", "if", "(", "$", "state", "!==", "null", ")", "$", "this", "->", "force_state", "(", "$", "state", ")", ";", "return", "$", "this", "->", "state", ";", "}" ]
Core
[ "Core" ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/aSQL/Engines/Terminal/CLI.php#L127-L130
GreenCape/joomla-cli
src/GreenCape/JoomlaCLI/Driver/Factory.php
DriverFactory.create
public function create($basePath) { $parts = explode('.', $this->loadVersion($basePath)->getShortVersion()); while (!empty($parts)) { $version = implode('Dot', $parts); $classname = __NAMESPACE__ . '\\Joomla' . $version . 'Driver'; if (class_exists($classname)) { return new $classname; } array_pop($parts); } throw new \RuntimeException('No driver found'); }
php
public function create($basePath) { $parts = explode('.', $this->loadVersion($basePath)->getShortVersion()); while (!empty($parts)) { $version = implode('Dot', $parts); $classname = __NAMESPACE__ . '\\Joomla' . $version . 'Driver'; if (class_exists($classname)) { return new $classname; } array_pop($parts); } throw new \RuntimeException('No driver found'); }
[ "public", "function", "create", "(", "$", "basePath", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "this", "->", "loadVersion", "(", "$", "basePath", ")", "->", "getShortVersion", "(", ")", ")", ";", "while", "(", "!", "empty", "(", "$", "parts", ")", ")", "{", "$", "version", "=", "implode", "(", "'Dot'", ",", "$", "parts", ")", ";", "$", "classname", "=", "__NAMESPACE__", ".", "'\\\\Joomla'", ".", "$", "version", ".", "'Driver'", ";", "if", "(", "class_exists", "(", "$", "classname", ")", ")", "{", "return", "new", "$", "classname", ";", "}", "array_pop", "(", "$", "parts", ")", ";", "}", "throw", "new", "\\", "RuntimeException", "(", "'No driver found'", ")", ";", "}" ]
Create a version specific driver to Joomla @param string $basePath The Joomla base path (same as JPATH_BASE within Joomla) @return JoomlaDriver @throws \RuntimeException
[ "Create", "a", "version", "specific", "driver", "to", "Joomla" ]
train
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Driver/Factory.php#L52-L66
GreenCape/joomla-cli
src/GreenCape/JoomlaCLI/Driver/Factory.php
DriverFactory.loadVersion
private function loadVersion($basePath) { static $locations = array( '/libraries/cms/version/version.php', '/libraries/joomla/version.php', ); define('_JEXEC', 1); foreach ($locations as $location) { if (file_exists($basePath . $location)) { $code = file_get_contents($basePath . $location); $code = str_replace("defined('JPATH_BASE')", "defined('_JEXEC')", $code); eval('?>' . $code); return new \JVersion; } } throw new \RuntimeException('Unable to locate version information'); }
php
private function loadVersion($basePath) { static $locations = array( '/libraries/cms/version/version.php', '/libraries/joomla/version.php', ); define('_JEXEC', 1); foreach ($locations as $location) { if (file_exists($basePath . $location)) { $code = file_get_contents($basePath . $location); $code = str_replace("defined('JPATH_BASE')", "defined('_JEXEC')", $code); eval('?>' . $code); return new \JVersion; } } throw new \RuntimeException('Unable to locate version information'); }
[ "private", "function", "loadVersion", "(", "$", "basePath", ")", "{", "static", "$", "locations", "=", "array", "(", "'/libraries/cms/version/version.php'", ",", "'/libraries/joomla/version.php'", ",", ")", ";", "define", "(", "'_JEXEC'", ",", "1", ")", ";", "foreach", "(", "$", "locations", "as", "$", "location", ")", "{", "if", "(", "file_exists", "(", "$", "basePath", ".", "$", "location", ")", ")", "{", "$", "code", "=", "file_get_contents", "(", "$", "basePath", ".", "$", "location", ")", ";", "$", "code", "=", "str_replace", "(", "\"defined('JPATH_BASE')\"", ",", "\"defined('_JEXEC')\"", ",", "$", "code", ")", ";", "eval", "(", "'?>'", ".", "$", "code", ")", ";", "return", "new", "\\", "JVersion", ";", "}", "}", "throw", "new", "\\", "RuntimeException", "(", "'Unable to locate version information'", ")", ";", "}" ]
Load the Joomla version @param string $basePath The Joomla base path (same as JPATH_BASE within Joomla) @return \JVersion @throws \RuntimeException
[ "Load", "the", "Joomla", "version" ]
train
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Driver/Factory.php#L77-L98
nblum/silverstripe-flexible-content
code/ContentElement.php
ContentElement.LastChange
public function LastChange() { $today = new \DateTime(); // This object represents current date/time $today->setTime(0, 0, 0); // reset time part, to prevent partial comparison $dateTime = \DateTime::createFromFormat('Y-m-d H:i:s', $this->Changed); if (!($dateTime instanceof \DateTime)) { return '---'; } $todayTime = $dateTime; $todayTime->setTime(0, 0, 0); // reset time part, to prevent partial comparison $diff = $today->diff($todayTime); $diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval switch ($diffDays) { case 0: return _t('ContentElement.today', 'Today') . ' ' . date('H:i', strtotime($this->Changed)); break; case -1: return _t('ContentElement.yesterday', 'Yesterday') . ' ' . date('H:i', strtotime($this->Changed)); break; default: return date('j. M H:i', strtotime($this->Changed)); } }
php
public function LastChange() { $today = new \DateTime(); // This object represents current date/time $today->setTime(0, 0, 0); // reset time part, to prevent partial comparison $dateTime = \DateTime::createFromFormat('Y-m-d H:i:s', $this->Changed); if (!($dateTime instanceof \DateTime)) { return '---'; } $todayTime = $dateTime; $todayTime->setTime(0, 0, 0); // reset time part, to prevent partial comparison $diff = $today->diff($todayTime); $diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval switch ($diffDays) { case 0: return _t('ContentElement.today', 'Today') . ' ' . date('H:i', strtotime($this->Changed)); break; case -1: return _t('ContentElement.yesterday', 'Yesterday') . ' ' . date('H:i', strtotime($this->Changed)); break; default: return date('j. M H:i', strtotime($this->Changed)); } }
[ "public", "function", "LastChange", "(", ")", "{", "$", "today", "=", "new", "\\", "DateTime", "(", ")", ";", "// This object represents current date/time", "$", "today", "->", "setTime", "(", "0", ",", "0", ",", "0", ")", ";", "// reset time part, to prevent partial comparison", "$", "dateTime", "=", "\\", "DateTime", "::", "createFromFormat", "(", "'Y-m-d H:i:s'", ",", "$", "this", "->", "Changed", ")", ";", "if", "(", "!", "(", "$", "dateTime", "instanceof", "\\", "DateTime", ")", ")", "{", "return", "'---'", ";", "}", "$", "todayTime", "=", "$", "dateTime", ";", "$", "todayTime", "->", "setTime", "(", "0", ",", "0", ",", "0", ")", ";", "// reset time part, to prevent partial comparison", "$", "diff", "=", "$", "today", "->", "diff", "(", "$", "todayTime", ")", ";", "$", "diffDays", "=", "(", "integer", ")", "$", "diff", "->", "format", "(", "'%R%a'", ")", ";", "// Extract days count in interval", "switch", "(", "$", "diffDays", ")", "{", "case", "0", ":", "return", "_t", "(", "'ContentElement.today'", ",", "'Today'", ")", ".", "' '", ".", "date", "(", "'H:i'", ",", "strtotime", "(", "$", "this", "->", "Changed", ")", ")", ";", "break", ";", "case", "-", "1", ":", "return", "_t", "(", "'ContentElement.yesterday'", ",", "'Yesterday'", ")", ".", "' '", ".", "date", "(", "'H:i'", ",", "strtotime", "(", "$", "this", "->", "Changed", ")", ")", ";", "break", ";", "default", ":", "return", "date", "(", "'j. M H:i'", ",", "strtotime", "(", "$", "this", "->", "Changed", ")", ")", ";", "}", "}" ]
returns a readable last change/edit date @return string|null
[ "returns", "a", "readable", "last", "change", "/", "edit", "date" ]
train
https://github.com/nblum/silverstripe-flexible-content/blob/e20a06ee98b7f884965a951653d98af11eb6bc67/code/ContentElement.php#L177-L203
nblum/silverstripe-flexible-content
code/ContentElement.php
ContentElement.getReadableIdentifier
public function getReadableIdentifier() { return sprintf( '%s%s', $this->getField('ID'), !empty(trim($this->getField('Title'))) ? '-' . urlencode(strtolower(trim($this->getField('Title')))) : '' ); }
php
public function getReadableIdentifier() { return sprintf( '%s%s', $this->getField('ID'), !empty(trim($this->getField('Title'))) ? '-' . urlencode(strtolower(trim($this->getField('Title')))) : '' ); }
[ "public", "function", "getReadableIdentifier", "(", ")", "{", "return", "sprintf", "(", "'%s%s'", ",", "$", "this", "->", "getField", "(", "'ID'", ")", ",", "!", "empty", "(", "trim", "(", "$", "this", "->", "getField", "(", "'Title'", ")", ")", ")", "?", "'-'", ".", "urlencode", "(", "strtolower", "(", "trim", "(", "$", "this", "->", "getField", "(", "'Title'", ")", ")", ")", ")", ":", "''", ")", ";", "}" ]
creates a readable (page) unique identifier for the current content element
[ "creates", "a", "readable", "(", "page", ")", "unique", "identifier", "for", "the", "current", "content", "element" ]
train
https://github.com/nblum/silverstripe-flexible-content/blob/e20a06ee98b7f884965a951653d98af11eb6bc67/code/ContentElement.php#L241-L248
nblum/silverstripe-flexible-content
code/ContentElement.php
ContentElement.getSiblings
public function getSiblings($active = '1') { $stage = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_live_stage(); $results = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_by_stage( \ContentElement::class, $stage , [ 'Active' => $active ], [ 'Sort' => 'ASC' ]); return $results; }
php
public function getSiblings($active = '1') { $stage = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_live_stage(); $results = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_by_stage( \ContentElement::class, $stage , [ 'Active' => $active ], [ 'Sort' => 'ASC' ]); return $results; }
[ "public", "function", "getSiblings", "(", "$", "active", "=", "'1'", ")", "{", "$", "stage", "=", "\\", "Nblum", "\\", "FlexibleContent", "\\", "FlexibleContentVersionedDataObject", "::", "get_live_stage", "(", ")", ";", "$", "results", "=", "\\", "Nblum", "\\", "FlexibleContent", "\\", "FlexibleContentVersionedDataObject", "::", "get_by_stage", "(", "\\", "ContentElement", "::", "class", ",", "$", "stage", ",", "[", "'Active'", "=>", "$", "active", "]", ",", "[", "'Sort'", "=>", "'ASC'", "]", ")", ";", "return", "$", "results", ";", "}" ]
returns all content element of the same page @param string $active @return DataList
[ "returns", "all", "content", "element", "of", "the", "same", "page" ]
train
https://github.com/nblum/silverstripe-flexible-content/blob/e20a06ee98b7f884965a951653d98af11eb6bc67/code/ContentElement.php#L255-L268
nblum/silverstripe-flexible-content
code/ContentElement.php
ContentElement.forTemplate
public function forTemplate() { $template = $this->getClassName(); if (\SSViewer::hasTemplate($template)) { return $this->renderWith($template); } return _t('ContentElement.missingTemplate', 'Missing Template for {template}', [ 'template' => $template ]); }
php
public function forTemplate() { $template = $this->getClassName(); if (\SSViewer::hasTemplate($template)) { return $this->renderWith($template); } return _t('ContentElement.missingTemplate', 'Missing Template for {template}', [ 'template' => $template ]); }
[ "public", "function", "forTemplate", "(", ")", "{", "$", "template", "=", "$", "this", "->", "getClassName", "(", ")", ";", "if", "(", "\\", "SSViewer", "::", "hasTemplate", "(", "$", "template", ")", ")", "{", "return", "$", "this", "->", "renderWith", "(", "$", "template", ")", ";", "}", "return", "_t", "(", "'ContentElement.missingTemplate'", ",", "'Missing Template for {template}'", ",", "[", "'template'", "=>", "$", "template", "]", ")", ";", "}" ]
@return \HTMLText
[ "@return", "\\", "HTMLText" ]
train
https://github.com/nblum/silverstripe-flexible-content/blob/e20a06ee98b7f884965a951653d98af11eb6bc67/code/ContentElement.php#L275-L286
neyaoz/laravel-view-control
src/ViewControl/ViewControlServiceProvider.php
ViewControlServiceProvider.bindInstancesInContainer
protected function bindInstancesInContainer() { $this->app->instance("view-control.path", $this->path()); $this->app->instance("view-control.path.base", $this->basePath()); }
php
protected function bindInstancesInContainer() { $this->app->instance("view-control.path", $this->path()); $this->app->instance("view-control.path.base", $this->basePath()); }
[ "protected", "function", "bindInstancesInContainer", "(", ")", "{", "$", "this", "->", "app", "->", "instance", "(", "\"view-control.path\"", ",", "$", "this", "->", "path", "(", ")", ")", ";", "$", "this", "->", "app", "->", "instance", "(", "\"view-control.path.base\"", ",", "$", "this", "->", "basePath", "(", ")", ")", ";", "}" ]
Bind all of the instances in the container. @return void
[ "Bind", "all", "of", "the", "instances", "in", "the", "container", "." ]
train
https://github.com/neyaoz/laravel-view-control/blob/2f49777a5cd81223cd36da2ef4385ccd036a4b1e/src/ViewControl/ViewControlServiceProvider.php#L42-L46
neyaoz/laravel-view-control
src/ViewControl/ViewControlServiceProvider.php
ViewControlServiceProvider.basePath
public function basePath($path = '') { return $this->getFilesystem()->dirname($this->path()) . ($path ? DIRECTORY_SEPARATOR . $path : $path); }
php
public function basePath($path = '') { return $this->getFilesystem()->dirname($this->path()) . ($path ? DIRECTORY_SEPARATOR . $path : $path); }
[ "public", "function", "basePath", "(", "$", "path", "=", "''", ")", "{", "return", "$", "this", "->", "getFilesystem", "(", ")", "->", "dirname", "(", "$", "this", "->", "path", "(", ")", ")", ".", "(", "$", "path", "?", "DIRECTORY_SEPARATOR", ".", "$", "path", ":", "$", "path", ")", ";", "}" ]
Get the base path of the plugin installation. @param string $path @return string
[ "Get", "the", "base", "path", "of", "the", "plugin", "installation", "." ]
train
https://github.com/neyaoz/laravel-view-control/blob/2f49777a5cd81223cd36da2ef4385ccd036a4b1e/src/ViewControl/ViewControlServiceProvider.php#L123-L126
gedex/php-janrain-api
lib/Janrain/HttpClient/Listener/ErrorListener.php
ErrorListener.onRequestError
public function onRequestError(Event $event) { /** @var $request \Guzzle\Http\Message\Request */ $request = $event['request']; $response = $request->getResponse(); $content = ResponseMediator::getContent($response); if ($response->isClientError() || $response->isServerError() || (isset($content['stat']) && 'ok' !== strtolower($content['stat']))) { $errorMsg = isset($content['error_description']) ? $content['error_description'] : ''; if (empty($errorMsg) && isset($content['error']['msg'])) { $errorMsg = $content['error']['msg']; } if (is_array($content) && isset($content['stat']) && 'ok' !== strtolower($content['stat'])) { throw new ValidationFailedException('Validation Failed: '. $errorMsg, 422); } throw new RuntimeException($errorMsg ?: $content, $response->getStatusCode()); } }
php
public function onRequestError(Event $event) { /** @var $request \Guzzle\Http\Message\Request */ $request = $event['request']; $response = $request->getResponse(); $content = ResponseMediator::getContent($response); if ($response->isClientError() || $response->isServerError() || (isset($content['stat']) && 'ok' !== strtolower($content['stat']))) { $errorMsg = isset($content['error_description']) ? $content['error_description'] : ''; if (empty($errorMsg) && isset($content['error']['msg'])) { $errorMsg = $content['error']['msg']; } if (is_array($content) && isset($content['stat']) && 'ok' !== strtolower($content['stat'])) { throw new ValidationFailedException('Validation Failed: '. $errorMsg, 422); } throw new RuntimeException($errorMsg ?: $content, $response->getStatusCode()); } }
[ "public", "function", "onRequestError", "(", "Event", "$", "event", ")", "{", "/** @var $request \\Guzzle\\Http\\Message\\Request */", "$", "request", "=", "$", "event", "[", "'request'", "]", ";", "$", "response", "=", "$", "request", "->", "getResponse", "(", ")", ";", "$", "content", "=", "ResponseMediator", "::", "getContent", "(", "$", "response", ")", ";", "if", "(", "$", "response", "->", "isClientError", "(", ")", "||", "$", "response", "->", "isServerError", "(", ")", "||", "(", "isset", "(", "$", "content", "[", "'stat'", "]", ")", "&&", "'ok'", "!==", "strtolower", "(", "$", "content", "[", "'stat'", "]", ")", ")", ")", "{", "$", "errorMsg", "=", "isset", "(", "$", "content", "[", "'error_description'", "]", ")", "?", "$", "content", "[", "'error_description'", "]", ":", "''", ";", "if", "(", "empty", "(", "$", "errorMsg", ")", "&&", "isset", "(", "$", "content", "[", "'error'", "]", "[", "'msg'", "]", ")", ")", "{", "$", "errorMsg", "=", "$", "content", "[", "'error'", "]", "[", "'msg'", "]", ";", "}", "if", "(", "is_array", "(", "$", "content", ")", "&&", "isset", "(", "$", "content", "[", "'stat'", "]", ")", "&&", "'ok'", "!==", "strtolower", "(", "$", "content", "[", "'stat'", "]", ")", ")", "{", "throw", "new", "ValidationFailedException", "(", "'Validation Failed: '", ".", "$", "errorMsg", ",", "422", ")", ";", "}", "throw", "new", "RuntimeException", "(", "$", "errorMsg", "?", ":", "$", "content", ",", "$", "response", "->", "getStatusCode", "(", ")", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/HttpClient/Listener/ErrorListener.php#L34-L53
wenbinye/PhalconX
src/Mvc/RoleManager.php
RoleManager.checkAccess
public function checkAccess($user_id, $roles) { if ($this->isRoot($user_id)) { return true; } if (is_array($roles)) { return $this->hasRoles($user_id, $roles); } elseif (strpos($roles, '|') !== false) { return $this->hasAnyRole($user_id, explode('|', $roles)); } else { return $this->hasRoles($user_id, explode('&', $roles)); } }
php
public function checkAccess($user_id, $roles) { if ($this->isRoot($user_id)) { return true; } if (is_array($roles)) { return $this->hasRoles($user_id, $roles); } elseif (strpos($roles, '|') !== false) { return $this->hasAnyRole($user_id, explode('|', $roles)); } else { return $this->hasRoles($user_id, explode('&', $roles)); } }
[ "public", "function", "checkAccess", "(", "$", "user_id", ",", "$", "roles", ")", "{", "if", "(", "$", "this", "->", "isRoot", "(", "$", "user_id", ")", ")", "{", "return", "true", ";", "}", "if", "(", "is_array", "(", "$", "roles", ")", ")", "{", "return", "$", "this", "->", "hasRoles", "(", "$", "user_id", ",", "$", "roles", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "roles", ",", "'|'", ")", "!==", "false", ")", "{", "return", "$", "this", "->", "hasAnyRole", "(", "$", "user_id", ",", "explode", "(", "'|'", ",", "$", "roles", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "hasRoles", "(", "$", "user_id", ",", "explode", "(", "'&'", ",", "$", "roles", ")", ")", ";", "}", "}" ]
检查用户是否包含指定的所有权限 @param string $user_id @param string|array $roles | 表示或,&表示与 @return bool
[ "检查用户是否包含指定的所有权限" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/RoleManager.php#L191-L203
Isset/pushnotification
src/PushNotification/Type/Android/AndroidConnection.php
AndroidConnection.sendAndReceive
public function sendAndReceive(Message $message): Response { /* @var AndroidMessage $message */ $data = $message->getMessage(); if ($this->dryRun) { $data['dry_run'] = true; } $response = new ConnectionResponseImpl(); try { $requestData = json_encode($data); $request = new Request('POST', '', [], $requestData); $clientResponse = $this->client->send($request); $data = json_decode($clientResponse->getBody()->getContents(), true); $response->setResponse($data); $response->setSuccess($data['success'] > 0); } catch (RequestException $e) { $response->setErrorResponse($e); } return $response; }
php
public function sendAndReceive(Message $message): Response { /* @var AndroidMessage $message */ $data = $message->getMessage(); if ($this->dryRun) { $data['dry_run'] = true; } $response = new ConnectionResponseImpl(); try { $requestData = json_encode($data); $request = new Request('POST', '', [], $requestData); $clientResponse = $this->client->send($request); $data = json_decode($clientResponse->getBody()->getContents(), true); $response->setResponse($data); $response->setSuccess($data['success'] > 0); } catch (RequestException $e) { $response->setErrorResponse($e); } return $response; }
[ "public", "function", "sendAndReceive", "(", "Message", "$", "message", ")", ":", "Response", "{", "/* @var AndroidMessage $message */", "$", "data", "=", "$", "message", "->", "getMessage", "(", ")", ";", "if", "(", "$", "this", "->", "dryRun", ")", "{", "$", "data", "[", "'dry_run'", "]", "=", "true", ";", "}", "$", "response", "=", "new", "ConnectionResponseImpl", "(", ")", ";", "try", "{", "$", "requestData", "=", "json_encode", "(", "$", "data", ")", ";", "$", "request", "=", "new", "Request", "(", "'POST'", ",", "''", ",", "[", "]", ",", "$", "requestData", ")", ";", "$", "clientResponse", "=", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "$", "data", "=", "json_decode", "(", "$", "clientResponse", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "true", ")", ";", "$", "response", "->", "setResponse", "(", "$", "data", ")", ";", "$", "response", "->", "setSuccess", "(", "$", "data", "[", "'success'", "]", ">", "0", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "$", "response", "->", "setErrorResponse", "(", "$", "e", ")", ";", "}", "return", "$", "response", ";", "}" ]
@param Message $message @return Response
[ "@param", "Message", "$message" ]
train
https://github.com/Isset/pushnotification/blob/5e7634dc6b1cf4f7c371d1890243a25252db0d85/src/PushNotification/Type/Android/AndroidConnection.php#L88-L109
gdbots/iam-php
src/Validator/UserValidator.php
UserValidator.ensureEmailIsAvailable
protected function ensureEmailIsAvailable(PbjxEvent $pbjxEvent, NodeRef $nodeRef, string $email): void { $pbjx = $pbjxEvent::getPbjx(); $command = $pbjxEvent->getMessage(); try { $request = $this->createGetUserRequest($command, $nodeRef, $pbjx) ->set('consistent_read', true) ->set('qname', $nodeRef->getQName()->toString()) ->set('email', $email); $response = $pbjx->copyContext($command, $request)->request($request); } catch (RequestHandlingFailed $e) { if (Code::NOT_FOUND === $e->getResponse()->get('error_code')) { // this is what we want return; } throw $e; } catch (\Throwable $t) { throw $t; } /** @var User $node */ $node = $response->get('node'); if ($nodeRef->getId() === (string)$node->get('_id')) { // this is the same node. return; } throw new UserAlreadyExists( sprintf( 'User with email [%s] already exists so [%s] cannot continue.', $email, $command->generateMessageRef() ) ); }
php
protected function ensureEmailIsAvailable(PbjxEvent $pbjxEvent, NodeRef $nodeRef, string $email): void { $pbjx = $pbjxEvent::getPbjx(); $command = $pbjxEvent->getMessage(); try { $request = $this->createGetUserRequest($command, $nodeRef, $pbjx) ->set('consistent_read', true) ->set('qname', $nodeRef->getQName()->toString()) ->set('email', $email); $response = $pbjx->copyContext($command, $request)->request($request); } catch (RequestHandlingFailed $e) { if (Code::NOT_FOUND === $e->getResponse()->get('error_code')) { // this is what we want return; } throw $e; } catch (\Throwable $t) { throw $t; } /** @var User $node */ $node = $response->get('node'); if ($nodeRef->getId() === (string)$node->get('_id')) { // this is the same node. return; } throw new UserAlreadyExists( sprintf( 'User with email [%s] already exists so [%s] cannot continue.', $email, $command->generateMessageRef() ) ); }
[ "protected", "function", "ensureEmailIsAvailable", "(", "PbjxEvent", "$", "pbjxEvent", ",", "NodeRef", "$", "nodeRef", ",", "string", "$", "email", ")", ":", "void", "{", "$", "pbjx", "=", "$", "pbjxEvent", "::", "getPbjx", "(", ")", ";", "$", "command", "=", "$", "pbjxEvent", "->", "getMessage", "(", ")", ";", "try", "{", "$", "request", "=", "$", "this", "->", "createGetUserRequest", "(", "$", "command", ",", "$", "nodeRef", ",", "$", "pbjx", ")", "->", "set", "(", "'consistent_read'", ",", "true", ")", "->", "set", "(", "'qname'", ",", "$", "nodeRef", "->", "getQName", "(", ")", "->", "toString", "(", ")", ")", "->", "set", "(", "'email'", ",", "$", "email", ")", ";", "$", "response", "=", "$", "pbjx", "->", "copyContext", "(", "$", "command", ",", "$", "request", ")", "->", "request", "(", "$", "request", ")", ";", "}", "catch", "(", "RequestHandlingFailed", "$", "e", ")", "{", "if", "(", "Code", "::", "NOT_FOUND", "===", "$", "e", "->", "getResponse", "(", ")", "->", "get", "(", "'error_code'", ")", ")", "{", "// this is what we want", "return", ";", "}", "throw", "$", "e", ";", "}", "catch", "(", "\\", "Throwable", "$", "t", ")", "{", "throw", "$", "t", ";", "}", "/** @var User $node */", "$", "node", "=", "$", "response", "->", "get", "(", "'node'", ")", ";", "if", "(", "$", "nodeRef", "->", "getId", "(", ")", "===", "(", "string", ")", "$", "node", "->", "get", "(", "'_id'", ")", ")", "{", "// this is the same node.", "return", ";", "}", "throw", "new", "UserAlreadyExists", "(", "sprintf", "(", "'User with email [%s] already exists so [%s] cannot continue.'", ",", "$", "email", ",", "$", "command", "->", "generateMessageRef", "(", ")", ")", ")", ";", "}" ]
@param PbjxEvent $pbjxEvent @param NodeRef $nodeRef @param string $email @throws UserAlreadyExists @throws \Throwable
[ "@param", "PbjxEvent", "$pbjxEvent", "@param", "NodeRef", "$nodeRef", "@param", "string", "$email" ]
train
https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/Validator/UserValidator.php#L84-L122