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
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
makinacorpus/drupal-ucms
ucms_layout/src/Form/LayoutContextEditForm.php
LayoutContextEditForm.cancelTransversalSubmit
public function cancelTransversalSubmit(array &$form, FormStateInterface $form_state) { if ($this->manager->getSiteContext()->isTemporary()) { $this->manager->getSiteContext()->rollback(); drupal_set_message(t("Changes have been dropped"), 'error'); $form_state->setRedirect( current_path(), ['query' => drupal_get_query_parameters(null, ['q', ContextManager::PARAM_SITE_TOKEN])] ); } }
php
public function cancelTransversalSubmit(array &$form, FormStateInterface $form_state) { if ($this->manager->getSiteContext()->isTemporary()) { $this->manager->getSiteContext()->rollback(); drupal_set_message(t("Changes have been dropped"), 'error'); $form_state->setRedirect( current_path(), ['query' => drupal_get_query_parameters(null, ['q', ContextManager::PARAM_SITE_TOKEN])] ); } }
[ "public", "function", "cancelTransversalSubmit", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "if", "(", "$", "this", "->", "manager", "->", "getSiteContext", "(", ")", "->", "isTemporary", "(", ")", ")", "{", "$"...
Cancel form submit
[ "Cancel", "form", "submit" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Form/LayoutContextEditForm.php#L175-L187
makinacorpus/drupal-ucms
ucms_layout/src/Form/LayoutContextEditForm.php
LayoutContextEditForm.editTransversalSubmit
public function editTransversalSubmit(array &$form, FormStateInterface $form_state) { if (!$this->manager->getSiteContext()->isTemporary()) { // @todo Generate a better token (random). $token = drupal_get_token(); $layout = $this->manager->getSiteContext()->getCurrentLayout(); $this->manager->getSiteContext()->setToken($token); // Saving the layout will force it be saved in the temporary storage. $this->manager->getSiteContext()->getStorage()->save($layout); $form_state->setRedirect( current_path(), ['query' => [ContextManager::PARAM_SITE_TOKEN => $token] + drupal_get_query_parameters()] ); } }
php
public function editTransversalSubmit(array &$form, FormStateInterface $form_state) { if (!$this->manager->getSiteContext()->isTemporary()) { // @todo Generate a better token (random). $token = drupal_get_token(); $layout = $this->manager->getSiteContext()->getCurrentLayout(); $this->manager->getSiteContext()->setToken($token); // Saving the layout will force it be saved in the temporary storage. $this->manager->getSiteContext()->getStorage()->save($layout); $form_state->setRedirect( current_path(), ['query' => [ContextManager::PARAM_SITE_TOKEN => $token] + drupal_get_query_parameters()] ); } }
[ "public", "function", "editTransversalSubmit", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "if", "(", "!", "$", "this", "->", "manager", "->", "getSiteContext", "(", ")", "->", "isTemporary", "(", ")", ")", "{", ...
Edit form submit
[ "Edit", "form", "submit" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/Form/LayoutContextEditForm.php#L192-L209
noherczeg/breadcrumb
src/Noherczeg/Breadcrumb/Segment.php
Segment.get
public function get($property_name) { if (!is_string($property_name)) { throw new \InvalidArgumentException('Invalid parameter given!'); } elseif (array_key_exists($property_name, get_object_vars($this))) { return $this->$property_name; } else { throw new \OutOfRangeException("Requested property does not exist!"); } }
php
public function get($property_name) { if (!is_string($property_name)) { throw new \InvalidArgumentException('Invalid parameter given!'); } elseif (array_key_exists($property_name, get_object_vars($this))) { return $this->$property_name; } else { throw new \OutOfRangeException("Requested property does not exist!"); } }
[ "public", "function", "get", "(", "$", "property_name", ")", "{", "if", "(", "!", "is_string", "(", "$", "property_name", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid parameter given!'", ")", ";", "}", "elseif", "(", "array...
get: Mediocre getter which returns a single requested property. @param string $property_name @return string @throws \InvalidArgumentException @throws \OutOfRangeException
[ "get", ":", "Mediocre", "getter", "which", "returns", "a", "single", "requested", "property", "." ]
train
https://github.com/noherczeg/breadcrumb/blob/d46ad3b58fbc6fa118ccad57e42e95214a0416c8/src/Noherczeg/Breadcrumb/Segment.php#L86-L95
makinacorpus/drupal-ucms
ucms_site/src/Twig/Extension/SiteExtension.php
SiteExtension.renderState
public function renderState($state) { $list = SiteState::getList(); if (isset($list[$state])) { return $this->t($list[$state]); } return $this->t("Unknown"); }
php
public function renderState($state) { $list = SiteState::getList(); if (isset($list[$state])) { return $this->t($list[$state]); } return $this->t("Unknown"); }
[ "public", "function", "renderState", "(", "$", "state", ")", "{", "$", "list", "=", "SiteState", "::", "getList", "(", ")", ";", "if", "(", "isset", "(", "$", "list", "[", "$", "state", "]", ")", ")", "{", "return", "$", "this", "->", "t", "(", ...
Render state human readable label @param int $state @return string
[ "Render", "state", "human", "readable", "label" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Twig/Extension/SiteExtension.php#L58-L67
makinacorpus/drupal-ucms
ucms_site/src/Twig/Extension/SiteExtension.php
SiteExtension.renderSiteUrl
public function renderSiteUrl($site, $path = null, array $options = [], $ignoreSso = false, $dropDestination = true) { return $this->siteManager->getUrlGenerator()->generateUrl($site, $path, $options, $ignoreSso, $dropDestination); }
php
public function renderSiteUrl($site, $path = null, array $options = [], $ignoreSso = false, $dropDestination = true) { return $this->siteManager->getUrlGenerator()->generateUrl($site, $path, $options, $ignoreSso, $dropDestination); }
[ "public", "function", "renderSiteUrl", "(", "$", "site", ",", "$", "path", "=", "null", ",", "array", "$", "options", "=", "[", "]", ",", "$", "ignoreSso", "=", "false", ",", "$", "dropDestination", "=", "true", ")", "{", "return", "$", "this", "->",...
Render site link @param int|Site $site Site identifier, if site is null @param string $path Drupal path to hit in site @param mixed[] $options Link options, see url() @return string
[ "Render", "site", "link" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Twig/Extension/SiteExtension.php#L105-L108
makinacorpus/drupal-ucms
ucms_site/src/Form/SiteDelete.php
SiteDelete.buildForm
public function buildForm(array $form, FormStateInterface $form_state, Site $site = null) { $form['#form_horizontal'] = true; if (!$site) { $this->logger('form')->critical("There is not site to delete!"); return $form; } // if (!$this->manager->getAccess()->userCanDelete($this->currentUser(), $site)) { // $this->logger('form')->critical("User can't delete site!"); // return $form; // } $form_state->setTemporaryValue('site', $site); $form['#site'] = $site; // This is used in *_form_alter() return confirm_form($form, $this->t("Do you want to delete site %site", ['%site' => $site->getAdminTitle()]), 'admin/dashboard/site'); }
php
public function buildForm(array $form, FormStateInterface $form_state, Site $site = null) { $form['#form_horizontal'] = true; if (!$site) { $this->logger('form')->critical("There is not site to delete!"); return $form; } // if (!$this->manager->getAccess()->userCanDelete($this->currentUser(), $site)) { // $this->logger('form')->critical("User can't delete site!"); // return $form; // } $form_state->setTemporaryValue('site', $site); $form['#site'] = $site; // This is used in *_form_alter() return confirm_form($form, $this->t("Do you want to delete site %site", ['%site' => $site->getAdminTitle()]), 'admin/dashboard/site'); }
[ "public", "function", "buildForm", "(", "array", "$", "form", ",", "FormStateInterface", "$", "form_state", ",", "Site", "$", "site", "=", "null", ")", "{", "$", "form", "[", "'#form_horizontal'", "]", "=", "true", ";", "if", "(", "!", "$", "site", ")"...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Form/SiteDelete.php#L56-L73
makinacorpus/drupal-ucms
ucms_site/src/Form/SiteDelete.php
SiteDelete.submitForm
public function submitForm(array &$form, FormStateInterface $form_state) { $site = &$form_state->getTemporaryValue('site'); $this->manager->getStorage()->delete($site, $this->currentUser()->id()); drupal_set_message($this->t("Site %title has been deleted", ['%title' => $site->getAdminTitle()])); $form_state->setRedirect('admin/dashboard/site'); }
php
public function submitForm(array &$form, FormStateInterface $form_state) { $site = &$form_state->getTemporaryValue('site'); $this->manager->getStorage()->delete($site, $this->currentUser()->id()); drupal_set_message($this->t("Site %title has been deleted", ['%title' => $site->getAdminTitle()])); $form_state->setRedirect('admin/dashboard/site'); }
[ "public", "function", "submitForm", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "site", "=", "&", "$", "form_state", "->", "getTemporaryValue", "(", "'site'", ")", ";", "$", "this", "->", "manager", "->", ...
Step B form submit
[ "Step", "B", "form", "submit" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Form/SiteDelete.php#L78-L86
mosbth/Anax-MVC
src/Url/CUrl.php
CUrl.create
public function create($uri = null) { if (empty($uri)) { // Empty uri means baseurl return $this->baseUrl . (($this->urlType == self::URL_APPEND) ? "/$this->scriptName" : null); } elseif (substr($uri, 0, 7) == "http://" || substr($uri, 0, 2) == "//") { // Fully qualified, just leave as is. return rtrim($uri, '/'); } elseif ($uri[0] == '/') { // Absolute url, prepend with siteUrl return rtrim($this->siteUrl . rtrim($uri, '/'), '/'); } $uri = rtrim($uri, '/'); if ($this->urlType == self::URL_CLEAN) { return $this->baseUrl . '/' . $uri; } else { return $this->baseUrl . '/' . $this->scriptName . '/' . $uri; } }
php
public function create($uri = null) { if (empty($uri)) { // Empty uri means baseurl return $this->baseUrl . (($this->urlType == self::URL_APPEND) ? "/$this->scriptName" : null); } elseif (substr($uri, 0, 7) == "http://" || substr($uri, 0, 2) == "//") { // Fully qualified, just leave as is. return rtrim($uri, '/'); } elseif ($uri[0] == '/') { // Absolute url, prepend with siteUrl return rtrim($this->siteUrl . rtrim($uri, '/'), '/'); } $uri = rtrim($uri, '/'); if ($this->urlType == self::URL_CLEAN) { return $this->baseUrl . '/' . $uri; } else { return $this->baseUrl . '/' . $this->scriptName . '/' . $uri; } }
[ "public", "function", "create", "(", "$", "uri", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "uri", ")", ")", "{", "// Empty uri means baseurl", "return", "$", "this", "->", "baseUrl", ".", "(", "(", "$", "this", "->", "urlType", "==", "self...
Create an url and prepending the baseUrl. @param string $uri part of uri to use when creating an url. "" or null means baseurl to current frontcontroller. @return string as resulting url.
[ "Create", "an", "url", "and", "prepending", "the", "baseUrl", "." ]
train
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/Url/CUrl.php#L39-L67
shopgate/cart-integration-sdk
src/models/catalog/Relation.php
Shopgate_Model_Catalog_Relation.asXml
public function asXml(Shopgate_Model_XmlResultObject $itemNode) { /** * @var Shopgate_Model_XmlResultObject $relationNode */ $relationNode = $itemNode->addChild('relation'); $relationNode->addAttribute('type', $this->getType()); if ($this->getType() == self::DEFAULT_RELATION_TYPE_CUSTOM) { $relationNode->addChildWithCDATA('label', $this->getLabel()); } foreach ($this->getValues() as $value) { $relationNode->addChild('uid', $value); } return $itemNode; }
php
public function asXml(Shopgate_Model_XmlResultObject $itemNode) { /** * @var Shopgate_Model_XmlResultObject $relationNode */ $relationNode = $itemNode->addChild('relation'); $relationNode->addAttribute('type', $this->getType()); if ($this->getType() == self::DEFAULT_RELATION_TYPE_CUSTOM) { $relationNode->addChildWithCDATA('label', $this->getLabel()); } foreach ($this->getValues() as $value) { $relationNode->addChild('uid', $value); } return $itemNode; }
[ "public", "function", "asXml", "(", "Shopgate_Model_XmlResultObject", "$", "itemNode", ")", "{", "/**\n * @var Shopgate_Model_XmlResultObject $relationNode\n */", "$", "relationNode", "=", "$", "itemNode", "->", "addChild", "(", "'relation'", ")", ";", "$", ...
@param Shopgate_Model_XmlResultObject $itemNode @return Shopgate_Model_XmlResultObject
[ "@param", "Shopgate_Model_XmlResultObject", "$itemNode" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Relation.php#L68-L83
shopgate/cart-integration-sdk
src/models/catalog/Relation.php
Shopgate_Model_Catalog_Relation.addValue
public function addValue($value) { $values = $this->getValues(); array_push($values, $value); $this->setValues($values); }
php
public function addValue($value) { $values = $this->getValues(); array_push($values, $value); $this->setValues($values); }
[ "public", "function", "addValue", "(", "$", "value", ")", "{", "$", "values", "=", "$", "this", "->", "getValues", "(", ")", ";", "array_push", "(", "$", "values", ",", "$", "value", ")", ";", "$", "this", "->", "setValues", "(", "$", "values", ")"...
add new value @param int $value
[ "add", "new", "value" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Relation.php#L90-L95
makinacorpus/drupal-ucms
ucms_contrib/src/Action/SiteActionProvider.php
SiteActionProvider.getActions
public function getActions($item, $primaryOnly = false, array $groups = []) { /** @var $item Site */ $ret = []; $urlGenerator = $this->manager->getUrlGenerator(); if ($this->isGranted(Permission::OVERVIEW, $item)) { list($path, $options) = $urlGenerator->getRouteAndParams($item->getId(), 'admin/dashboard/content'); $ret[] = new Action($this->t("Content in site"), $path, $options, 'file', 100, false, false, false, 'content'); list($path, $options) = $urlGenerator->getRouteAndParams($item->getId(), 'admin/dashboard/media'); $ret[] = new Action($this->t("Medias in site"), $path, $options, 'picture', 100, false, false, false, 'content'); } return $ret; }
php
public function getActions($item, $primaryOnly = false, array $groups = []) { /** @var $item Site */ $ret = []; $urlGenerator = $this->manager->getUrlGenerator(); if ($this->isGranted(Permission::OVERVIEW, $item)) { list($path, $options) = $urlGenerator->getRouteAndParams($item->getId(), 'admin/dashboard/content'); $ret[] = new Action($this->t("Content in site"), $path, $options, 'file', 100, false, false, false, 'content'); list($path, $options) = $urlGenerator->getRouteAndParams($item->getId(), 'admin/dashboard/media'); $ret[] = new Action($this->t("Medias in site"), $path, $options, 'picture', 100, false, false, false, 'content'); } return $ret; }
[ "public", "function", "getActions", "(", "$", "item", ",", "$", "primaryOnly", "=", "false", ",", "array", "$", "groups", "=", "[", "]", ")", "{", "/** @var $item Site */", "$", "ret", "=", "[", "]", ";", "$", "urlGenerator", "=", "$", "this", "->", ...
{inheritdoc}
[ "{", "inheritdoc", "}" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/Action/SiteActionProvider.php#L28-L43
makinacorpus/drupal-ucms
ucms_label/ucms_label.container.php
ServiceProvider.register
public function register(ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/config')); $loader->load('pages.yml'); $container->addCompilerPass(new NotificationSupportCompilerPass(), PassConfig::TYPE_REMOVE); }
php
public function register(ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/config')); $loader->load('pages.yml'); $container->addCompilerPass(new NotificationSupportCompilerPass(), PassConfig::TYPE_REMOVE); }
[ "public", "function", "register", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "loader", "=", "new", "YamlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/config'", ")", ")", ";", "$", "loader", "->", "loa...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_label/ucms_label.container.php#L17-L23
makinacorpus/drupal-ucms
ucms_contrib/src/DependencyInjection/ContribConfiguration.php
ContribConfiguration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('ucms_contrib'); $rootNode ->children() // Keys will be tab route part for Drupal menu ->arrayNode('admin_pages') ->normalizeKeys(true) ->prototype('array') ->children() // Tab definition ->scalarNode('tab') ->isRequired() ->defaultValue('all') ->validate() ->ifNotInArray(['content', 'media', 'all']) ->thenInvalid('Invalid type type %s') ->end() ->end() // Permission or access callback ->scalarNode('access')->isRequired()->defaultValue(Access::PERM_SITE_DASHBOARD_ACCESS)->end() // Page and tab title ->scalarNode('title')->isRequired()->end() // Arbitrary base query filters ->variableNode('base_query')->end() ->end() // children ->end() // prototype ->end() // pages ->end() // children ; return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('ucms_contrib'); $rootNode ->children() // Keys will be tab route part for Drupal menu ->arrayNode('admin_pages') ->normalizeKeys(true) ->prototype('array') ->children() // Tab definition ->scalarNode('tab') ->isRequired() ->defaultValue('all') ->validate() ->ifNotInArray(['content', 'media', 'all']) ->thenInvalid('Invalid type type %s') ->end() ->end() // Permission or access callback ->scalarNode('access')->isRequired()->defaultValue(Access::PERM_SITE_DASHBOARD_ACCESS)->end() // Page and tab title ->scalarNode('title')->isRequired()->end() // Arbitrary base query filters ->variableNode('base_query')->end() ->end() // children ->end() // prototype ->end() // pages ->end() // children ; return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'ucms_contrib'", ")", ";", "$", "rootNode", "->", "children", "(", ")",...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/DependencyInjection/ContribConfiguration.php#L17-L51
qloog/yaf-library
src/Validators/Validator.php
Validator.validator
public static function validator(array $data, array $rules, $isReturnAll = false) { $errors = []; foreach ($rules as $rule) { if (count($rule) < 2) { throw new ParamsException('rules', '规则错误'); } $validator = $rule[1]; if (!isset(static::$builtInValidators[$validator])) { throw new ParamsException('rules', "[{$validator}]规则不存在"); } $validator = __NAMESPACE__ . '\\' . static::$builtInValidators[$validator]; $fields = explode(',', $rule[0]); unset($rule[0], $rule[1]); $validatorObj = new $validator($rule); foreach ($fields as $field) { if (isset($errors[$field])) { continue; } $result = $validatorObj->validator($field, $data); if ($result === true) { continue; } if (!$isReturnAll) { return $result; } $errors[$field] = $result; } } return $errors ?: true; }
php
public static function validator(array $data, array $rules, $isReturnAll = false) { $errors = []; foreach ($rules as $rule) { if (count($rule) < 2) { throw new ParamsException('rules', '规则错误'); } $validator = $rule[1]; if (!isset(static::$builtInValidators[$validator])) { throw new ParamsException('rules', "[{$validator}]规则不存在"); } $validator = __NAMESPACE__ . '\\' . static::$builtInValidators[$validator]; $fields = explode(',', $rule[0]); unset($rule[0], $rule[1]); $validatorObj = new $validator($rule); foreach ($fields as $field) { if (isset($errors[$field])) { continue; } $result = $validatorObj->validator($field, $data); if ($result === true) { continue; } if (!$isReturnAll) { return $result; } $errors[$field] = $result; } } return $errors ?: true; }
[ "public", "static", "function", "validator", "(", "array", "$", "data", ",", "array", "$", "rules", ",", "$", "isReturnAll", "=", "false", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "if",...
验证 @param array $data 待验证的数据 @param array $rules 验证规则 @param bool $isReturnAll 是否一次返回所有错误 @return bool|string|array @throws ParamsException
[ "验证" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Validators/Validator.php#L41-L80
qloog/yaf-library
src/Http/Support/OutputTrait.php
OutputTrait.success
public function success(array $data = null) { $codes = $this->code; $code = $codes::SUCCESS; return $this->output($code, $this->codeMessage($code), $data); }
php
public function success(array $data = null) { $codes = $this->code; $code = $codes::SUCCESS; return $this->output($code, $this->codeMessage($code), $data); }
[ "public", "function", "success", "(", "array", "$", "data", "=", "null", ")", "{", "$", "codes", "=", "$", "this", "->", "code", ";", "$", "code", "=", "$", "codes", "::", "SUCCESS", ";", "return", "$", "this", "->", "output", "(", "$", "code", "...
输出成功 @param array $data @return bool
[ "输出成功" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Support/OutputTrait.php#L25-L31
qloog/yaf-library
src/Http/Support/OutputTrait.php
OutputTrait.error
public function error($code, $msg = null, array $data = null) { $codes = $this->code; if (func_num_args() < 3 && ($msg === null || $msg === '' || is_array($msg))) { if (is_array($msg)) { $data = $msg; } if (is_numeric($code)) { // 不过于严格的检查,例如浮点数 $msg = $this->codeMessage($code); } else { $msg = $code; $code = $codes::UNDEFINED_ERROR; } } return $this->output($code, $msg, $data); }
php
public function error($code, $msg = null, array $data = null) { $codes = $this->code; if (func_num_args() < 3 && ($msg === null || $msg === '' || is_array($msg))) { if (is_array($msg)) { $data = $msg; } if (is_numeric($code)) { // 不过于严格的检查,例如浮点数 $msg = $this->codeMessage($code); } else { $msg = $code; $code = $codes::UNDEFINED_ERROR; } } return $this->output($code, $msg, $data); }
[ "public", "function", "error", "(", "$", "code", ",", "$", "msg", "=", "null", ",", "array", "$", "data", "=", "null", ")", "{", "$", "codes", "=", "$", "this", "->", "code", ";", "if", "(", "func_num_args", "(", ")", "<", "3", "&&", "(", "$", ...
输出错误 $this->error(Code::PASSWORD); @param int $code @param string $msg @param array $data @return bool
[ "输出错误" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Support/OutputTrait.php#L43-L60
qloog/yaf-library
src/Http/Support/OutputTrait.php
OutputTrait.output
public function output($code, $msg = '', array $data = null) { $result = json_encode([ 'code' => $code, 'msg' => $msg, 'data' => $data === null ? [] : $data, ], $data === null ? JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE: 0); $response = null; if (method_exists($this, 'getResponse')) { $response = $this->getResponse(); } elseif (property_exists($this, 'response')) { $response = $this->response; } if (! $response instanceof Response_Abstract) { throw new RuntimeException('Need response object'); } // support jsonp if (isset($_GET['_callback']) && $callback = $_GET['_callback']) { $response->setBody(htmlspecialchars($callback) . '(' . $result . ')'); } else { $response->setHeader('Content-Type', 'application/json'); $response->setBody($result); } return true; }
php
public function output($code, $msg = '', array $data = null) { $result = json_encode([ 'code' => $code, 'msg' => $msg, 'data' => $data === null ? [] : $data, ], $data === null ? JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE: 0); $response = null; if (method_exists($this, 'getResponse')) { $response = $this->getResponse(); } elseif (property_exists($this, 'response')) { $response = $this->response; } if (! $response instanceof Response_Abstract) { throw new RuntimeException('Need response object'); } // support jsonp if (isset($_GET['_callback']) && $callback = $_GET['_callback']) { $response->setBody(htmlspecialchars($callback) . '(' . $result . ')'); } else { $response->setHeader('Content-Type', 'application/json'); $response->setBody($result); } return true; }
[ "public", "function", "output", "(", "$", "code", ",", "$", "msg", "=", "''", ",", "array", "$", "data", "=", "null", ")", "{", "$", "result", "=", "json_encode", "(", "[", "'code'", "=>", "$", "code", ",", "'msg'", "=>", "$", "msg", ",", "'data'...
输出结果并退出 @param int $code @param string $msg @param array $data @return bool @throws RuntimeException
[ "输出结果并退出" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Support/OutputTrait.php#L71-L99
qloog/yaf-library
src/Http/Support/OutputTrait.php
OutputTrait.codeMessage
private function codeMessage($code) { // 在控制器中定义code属性后,会优先使用业务定义的代码,否则使用系统定义码 $codes = $this->code; if (isset($codes::$msg[$code])) { return $codes::$msg[$code]; } if (isset(Code::$msg[$code])) { return Code::$msg[$code]; } return $this->codeMessage(Code::UNDEFINED_ERROR); }
php
private function codeMessage($code) { // 在控制器中定义code属性后,会优先使用业务定义的代码,否则使用系统定义码 $codes = $this->code; if (isset($codes::$msg[$code])) { return $codes::$msg[$code]; } if (isset(Code::$msg[$code])) { return Code::$msg[$code]; } return $this->codeMessage(Code::UNDEFINED_ERROR); }
[ "private", "function", "codeMessage", "(", "$", "code", ")", "{", "// 在控制器中定义code属性后,会优先使用业务定义的代码,否则使用系统定义码", "$", "codes", "=", "$", "this", "->", "code", ";", "if", "(", "isset", "(", "$", "codes", "::", "$", "msg", "[", "$", "code", "]", ")", ")", "...
返回Code对应的Message @param $code @return mixed
[ "返回Code对应的Message" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Support/OutputTrait.php#L107-L120
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Factory.php
Factory.clear
static public function clear( $id = null, $path = null ) { if( $id !== null ) { if( $path !== null ) { self::$controllers[$id][$path] = null; } else { self::$controllers[$id] = []; } return; } self::$controllers = []; }
php
static public function clear( $id = null, $path = null ) { if( $id !== null ) { if( $path !== null ) { self::$controllers[$id][$path] = null; } else { self::$controllers[$id] = []; } return; } self::$controllers = []; }
[ "static", "public", "function", "clear", "(", "$", "id", "=", "null", ",", "$", "path", "=", "null", ")", "{", "if", "(", "$", "id", "!==", "null", ")", "{", "if", "(", "$", "path", "!==", "null", ")", "{", "self", "::", "$", "controllers", "["...
Removes the controller objects from the cache. If neither a context ID nor a path is given, the complete cache will be pruned. @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) @param string $path Path describing the controller to clear, e.g. "product/lists/type"
[ "Removes", "the", "controller", "objects", "from", "the", "cache", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Factory.php#L35-L49
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Factory.php
Factory.createController
static public function createController( \Aimeos\MShop\Context\Item\Iface $context, $path ) { $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); if( empty( $path ) ) { throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Controller path is empty' ) ); } $id = (string) $context; if( self::$cache === false || !isset( self::$controllers[$id][$path] ) ) { $parts = explode( '/', $path ); foreach( $parts as $key => $part ) { if( ctype_alnum( $part ) === false ) { throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid controller "%1$s" in "%2$s"', $part, $path ) ); } $parts[$key] = ucwords( $part ); } $factory = '\\Aimeos\\Controller\\ExtJS\\' . join( '\\', $parts ) . '\\Factory'; if( class_exists( $factory ) === false ) { throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Class "%1$s" not found', $factory ) ); } $controller = @call_user_func_array( array( $factory, 'createController' ), array( $context ) ); if( $controller === false ) { throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) ); } self::$controllers[$id][$path] = $controller; } return self::$controllers[$id][$path]; }
php
static public function createController( \Aimeos\MShop\Context\Item\Iface $context, $path ) { $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); if( empty( $path ) ) { throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Controller path is empty' ) ); } $id = (string) $context; if( self::$cache === false || !isset( self::$controllers[$id][$path] ) ) { $parts = explode( '/', $path ); foreach( $parts as $key => $part ) { if( ctype_alnum( $part ) === false ) { throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid controller "%1$s" in "%2$s"', $part, $path ) ); } $parts[$key] = ucwords( $part ); } $factory = '\\Aimeos\\Controller\\ExtJS\\' . join( '\\', $parts ) . '\\Factory'; if( class_exists( $factory ) === false ) { throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Class "%1$s" not found', $factory ) ); } $controller = @call_user_func_array( array( $factory, 'createController' ), array( $context ) ); if( $controller === false ) { throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) ); } self::$controllers[$id][$path] = $controller; } return self::$controllers[$id][$path]; }
[ "static", "public", "function", "createController", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Context", "\\", "Item", "\\", "Iface", "$", "context", ",", "$", "path", ")", "{", "$", "path", "=", "strtolower", "(", "trim", "(", "$", "path", ",", "\"/ \...
Creates the required controller specified by the given path of controller names. Controllers are created by providing only the domain name, e.g. "product" for the \Aimeos\Controller\ExtJS\Product\Standard or a path of names to retrieve a specific sub-controller, e.g. "product/type" for the \Aimeos\Controller\ExtJS\Product\Type\Standard controller. Please note, that only the default controllers can be created. If you need a specific implementation, you need to use the factory class of the controller to hand over specifc implementation names. @param \Aimeos\MShop\Context\Item\Iface $context Context object required by managers @param string $path Name of the domain (and sub-managers) separated by slashes, e.g "product/list" @throws \Aimeos\Controller\ExtJS\Exception If the given path is invalid or the manager wasn't found
[ "Creates", "the", "required", "controller", "specified", "by", "the", "given", "path", "of", "controller", "names", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Factory.php#L67-L106
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Factory.php
Factory.setCache
static public function setCache( $value ) { $old = self::$cache; self::$cache = (boolean) $value; return $old; }
php
static public function setCache( $value ) { $old = self::$cache; self::$cache = (boolean) $value; return $old; }
[ "static", "public", "function", "setCache", "(", "$", "value", ")", "{", "$", "old", "=", "self", "::", "$", "cache", ";", "self", "::", "$", "cache", "=", "(", "boolean", ")", "$", "value", ";", "return", "$", "old", ";", "}" ]
Enables or disables caching of class instances. @param boolean $value True to enable caching, false to disable it. @return boolean Previous cache setting
[ "Enables", "or", "disables", "caching", "of", "class", "instances", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Factory.php#L115-L121
BugBuster1701/botdetection
src/modules/ModuleBrowscapCache.php
ModuleBrowscapCache.compile
protected function compile() { $cachdir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'cache'; //before $before_path = ''; if (!file_exists($cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version')) { $before = '---'; } else { $before = file_get_contents($cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version'); $arrCacheDir = scan($cachdir,true); // nicht cachen foreach ($arrCacheDir as $dirs) { if (0 === substr_compare( basename($dirs), 'largebrowscap_v', 0,15)) { $before_path .= '<br>- ' . $dirs ; } } } $arrProxy = false; //Daten aus localconfig sofern Proxyerweiterung installiert und aktiv als Parameter if ( \Config::get('useProxy') && in_array('proxy', \ModuleLoader::getActive()) ) { $parsedUrl = parse_url(\Config::get('proxy_url')); $arrProxy['ProxyProtocol'] = (isset($parsedUrl['scheme'])) ? $parsedUrl['scheme'] : null; $arrProxy['ProxyHost'] = (isset($parsedUrl['host'])) ? $parsedUrl['host'] : null; $arrProxy['ProxyPort'] = (isset($parsedUrl['port'])) ? $parsedUrl['port'] : null; $arrProxy['ProxyUser'] = (isset($parsedUrl['user'])) ? $parsedUrl['user'] : null; $arrProxy['ProxyPassword'] = (isset($parsedUrl['pass'])) ? $parsedUrl['pass'] : null; } //Using Class BrowscapCache $return = BrowscapCache::generateBrowscapCache(false, $arrProxy); if (!file_exists($cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version')) { $return = $cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version not found'; $after = '---'; } else { $return = 'Cache generated.'; $after = file_get_contents($cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version'); $after_path = $cachdir . DIRECTORY_SEPARATOR . 'largebrowscap'; $after_path .= '_v' . $after; $after_path .= '_' . \Crossjoin\Browscap\Browscap::VERSION; } $this->Template->before = $before; $this->Template->before_path = $before_path; $this->Template->after = $after; $this->Template->after_path = basename($after_path); $this->Template->return = $return; }
php
protected function compile() { $cachdir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'cache'; //before $before_path = ''; if (!file_exists($cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version')) { $before = '---'; } else { $before = file_get_contents($cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version'); $arrCacheDir = scan($cachdir,true); // nicht cachen foreach ($arrCacheDir as $dirs) { if (0 === substr_compare( basename($dirs), 'largebrowscap_v', 0,15)) { $before_path .= '<br>- ' . $dirs ; } } } $arrProxy = false; //Daten aus localconfig sofern Proxyerweiterung installiert und aktiv als Parameter if ( \Config::get('useProxy') && in_array('proxy', \ModuleLoader::getActive()) ) { $parsedUrl = parse_url(\Config::get('proxy_url')); $arrProxy['ProxyProtocol'] = (isset($parsedUrl['scheme'])) ? $parsedUrl['scheme'] : null; $arrProxy['ProxyHost'] = (isset($parsedUrl['host'])) ? $parsedUrl['host'] : null; $arrProxy['ProxyPort'] = (isset($parsedUrl['port'])) ? $parsedUrl['port'] : null; $arrProxy['ProxyUser'] = (isset($parsedUrl['user'])) ? $parsedUrl['user'] : null; $arrProxy['ProxyPassword'] = (isset($parsedUrl['pass'])) ? $parsedUrl['pass'] : null; } //Using Class BrowscapCache $return = BrowscapCache::generateBrowscapCache(false, $arrProxy); if (!file_exists($cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version')) { $return = $cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version not found'; $after = '---'; } else { $return = 'Cache generated.'; $after = file_get_contents($cachdir . DIRECTORY_SEPARATOR . 'largebrowscap.version'); $after_path = $cachdir . DIRECTORY_SEPARATOR . 'largebrowscap'; $after_path .= '_v' . $after; $after_path .= '_' . \Crossjoin\Browscap\Browscap::VERSION; } $this->Template->before = $before; $this->Template->before_path = $before_path; $this->Template->after = $after; $this->Template->after_path = basename($after_path); $this->Template->return = $return; }
[ "protected", "function", "compile", "(", ")", "{", "$", "cachdir", "=", "__DIR__", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'cache'", ";", "//before", "$", "before_path", "=", "''", ";", "if", "(", "!", "file_exists", "(", ...
Generate module
[ "Generate", "module" ]
train
https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/modules/ModuleBrowscapCache.php#L61-L118
runcmf/runbb
src/RunBB/Core/Hooks.php
Hooks.fire
public function fire($name) { $args = func_get_args(); array_shift($args); if (!isset($this->hooks[$name])) { //$this->hooks[$name] = array(array()); if (isset($args[0])) { return $args[0]; } else { return; } } if (!empty($this->hooks[$name])) { // Sort by priority, low to high, if there's more than one priority if (count($this->hooks[$name]) > 1) { ksort($this->hooks[$name]); } $output = []; $count = 0; foreach ($this->hooks[$name] as $priority) { if (!empty($priority)) { foreach ($priority as $callable) { $output[] = call_user_func_array($callable, $args); ++$count; } } } // If we only have one hook binded or the argument is not an array, // let's return the first output if ($count == 1 || !is_array($args[0])) { return $output[0]; } else { $data = []; // Move all the keys to the same level foreach ($output as $k => $vars) { if ($k === 0) { $data = $vars; continue; } // проверить если в массиве есть callable // $data = array_merge($data, $vars); $data = $data + $vars; } // array_walk_recursive($output, function ($v, $k) use (&$data) { // $data[] = $v; // }); return $data; // Remove any duplicate key // return array_unique($data, SORT_REGULAR); } } }
php
public function fire($name) { $args = func_get_args(); array_shift($args); if (!isset($this->hooks[$name])) { //$this->hooks[$name] = array(array()); if (isset($args[0])) { return $args[0]; } else { return; } } if (!empty($this->hooks[$name])) { // Sort by priority, low to high, if there's more than one priority if (count($this->hooks[$name]) > 1) { ksort($this->hooks[$name]); } $output = []; $count = 0; foreach ($this->hooks[$name] as $priority) { if (!empty($priority)) { foreach ($priority as $callable) { $output[] = call_user_func_array($callable, $args); ++$count; } } } // If we only have one hook binded or the argument is not an array, // let's return the first output if ($count == 1 || !is_array($args[0])) { return $output[0]; } else { $data = []; // Move all the keys to the same level foreach ($output as $k => $vars) { if ($k === 0) { $data = $vars; continue; } // проверить если в массиве есть callable // $data = array_merge($data, $vars); $data = $data + $vars; } // array_walk_recursive($output, function ($v, $k) use (&$data) { // $data[] = $v; // }); return $data; // Remove any duplicate key // return array_unique($data, SORT_REGULAR); } } }
[ "public", "function", "fire", "(", "$", "name", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "hooks", "[", "$", "name", "]", ")", ")", "{...
Invoke hook @param string $name The hook name @param mixed ... (Optional) Argument(s) for hooked functions, can specify multiple arguments @return mixed
[ "Invoke", "hook" ]
train
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Hooks.php#L47-L102
runcmf/runbb
src/RunBB/Core/Hooks.php
Hooks.fireDB
public function fireDB($name) { $args = func_get_args(); array_shift($args); if (!isset($this->hooks[$name])) { //$this->hooks[$name] = array(array()); return $args[0]; } if (!empty($this->hooks[$name])) { // Sort by priority, low to high, if there's more than one priority if (count($this->hooks[$name]) > 1) { ksort($this->hooks[$name]); } $output = []; foreach ($this->hooks[$name] as $priority) { if (!empty($priority)) { foreach ($priority as $callable) { $output[] = call_user_func_array($callable, $args); } } } return $output[0]; } }
php
public function fireDB($name) { $args = func_get_args(); array_shift($args); if (!isset($this->hooks[$name])) { //$this->hooks[$name] = array(array()); return $args[0]; } if (!empty($this->hooks[$name])) { // Sort by priority, low to high, if there's more than one priority if (count($this->hooks[$name]) > 1) { ksort($this->hooks[$name]); } $output = []; foreach ($this->hooks[$name] as $priority) { if (!empty($priority)) { foreach ($priority as $callable) { $output[] = call_user_func_array($callable, $args); } } } return $output[0]; } }
[ "public", "function", "fireDB", "(", "$", "name", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "hooks", "[", "$", "name", "]", ")", ")", ...
Invoke hook for DB @param string $name The hook name @param mixed ... Argument(s) for hooked functions, can specify multiple arguments @return mixed
[ "Invoke", "hook", "for", "DB" ]
train
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Hooks.php#L110-L137
saxulum/saxulum-elasticsearch-querybuilder
src/Node/ArrayNode.php
ArrayNode.create
public static function create(bool $allowSerializeEmpty = false): ArrayNode { $node = new self(); $node->allowSerializeEmpty = $allowSerializeEmpty; return $node; }
php
public static function create(bool $allowSerializeEmpty = false): ArrayNode { $node = new self(); $node->allowSerializeEmpty = $allowSerializeEmpty; return $node; }
[ "public", "static", "function", "create", "(", "bool", "$", "allowSerializeEmpty", "=", "false", ")", ":", "ArrayNode", "{", "$", "node", "=", "new", "self", "(", ")", ";", "$", "node", "->", "allowSerializeEmpty", "=", "$", "allowSerializeEmpty", ";", "re...
@param bool $allowSerializeEmpty @return ArrayNode
[ "@param", "bool", "$allowSerializeEmpty" ]
train
https://github.com/saxulum/saxulum-elasticsearch-querybuilder/blob/2f5a15925f3f3afe6a8efabf1f2c9af42f81d9b1/src/Node/ArrayNode.php#L14-L20
saxulum/saxulum-elasticsearch-querybuilder
src/Node/ArrayNode.php
ArrayNode.add
public function add(AbstractNode $node) { $node->setParent($this); $this->children[] = $node; return $this; }
php
public function add(AbstractNode $node) { $node->setParent($this); $this->children[] = $node; return $this; }
[ "public", "function", "add", "(", "AbstractNode", "$", "node", ")", "{", "$", "node", "->", "setParent", "(", "$", "this", ")", ";", "$", "this", "->", "children", "[", "]", "=", "$", "node", ";", "return", "$", "this", ";", "}" ]
@param AbstractNode $node @return $this @throws \InvalidArgumentException
[ "@param", "AbstractNode", "$node" ]
train
https://github.com/saxulum/saxulum-elasticsearch-querybuilder/blob/2f5a15925f3f3afe6a8efabf1f2c9af42f81d9b1/src/Node/ArrayNode.php#L42-L49
shopgate/cart-integration-sdk
src/orders.php
ShopgateOrder.getCreatedTime
public function getCreatedTime($format = "") { $time = $this->created_time; if (!empty($format)) { $timestamp = strtotime($time); $time = date($format, $timestamp); } return $time; }
php
public function getCreatedTime($format = "") { $time = $this->created_time; if (!empty($format)) { $timestamp = strtotime($time); $time = date($format, $timestamp); } return $time; }
[ "public", "function", "getCreatedTime", "(", "$", "format", "=", "\"\"", ")", "{", "$", "time", "=", "$", "this", "->", "created_time", ";", "if", "(", "!", "empty", "(", "$", "format", ")", ")", "{", "$", "timestamp", "=", "strtotime", "(", "$", "...
@see http://www.php.net/manual/de/function.date.php @see http://en.wikipedia.org/wiki/ISO_8601 @param string $format @return string
[ "@see", "http", ":", "//", "www", ".", "php", ".", "net", "/", "manual", "/", "de", "/", "function", ".", "date", ".", "php", "@see", "http", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "ISO_8601" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/orders.php#L1122-L1131
shopgate/cart-integration-sdk
src/orders.php
ShopgateOrder.getPaymentTime
public function getPaymentTime($format = "") { $time = $this->payment_time; if (!empty($format)) { $timestamp = strtotime($time); $time = date($format, $timestamp); } return $time; }
php
public function getPaymentTime($format = "") { $time = $this->payment_time; if (!empty($format)) { $timestamp = strtotime($time); $time = date($format, $timestamp); } return $time; }
[ "public", "function", "getPaymentTime", "(", "$", "format", "=", "\"\"", ")", "{", "$", "time", "=", "$", "this", "->", "payment_time", ";", "if", "(", "!", "empty", "(", "$", "format", ")", ")", "{", "$", "timestamp", "=", "strtotime", "(", "$", "...
@see http://www.php.net/manual/de/function.date.php @see http://en.wikipedia.org/wiki/ISO_8601 @param string $format @return string
[ "@see", "http", ":", "//", "www", ".", "php", ".", "net", "/", "manual", "/", "de", "/", "function", ".", "date", ".", "php", "@see", "http", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "ISO_8601" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/orders.php#L1149-L1158
shopgate/cart-integration-sdk
src/orders.php
ShopgateOrder.getShippingCompletedTime
public function getShippingCompletedTime($format = '') { $time = $this->shipping_completed_time; if (!empty($format)) { $timestamp = strtotime($time); $time = date($format, $timestamp); } return $time; }
php
public function getShippingCompletedTime($format = '') { $time = $this->shipping_completed_time; if (!empty($format)) { $timestamp = strtotime($time); $time = date($format, $timestamp); } return $time; }
[ "public", "function", "getShippingCompletedTime", "(", "$", "format", "=", "''", ")", "{", "$", "time", "=", "$", "this", "->", "shipping_completed_time", ";", "if", "(", "!", "empty", "(", "$", "format", ")", ")", "{", "$", "timestamp", "=", "strtotime"...
@see http://www.php.net/manual/de/function.date.php @see http://en.wikipedia.org/wiki/ISO_8601 @param string $format @return string
[ "@see", "http", ":", "//", "www", ".", "php", ".", "net", "/", "manual", "/", "de", "/", "function", ".", "date", ".", "php", "@see", "http", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "ISO_8601" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/orders.php#L1200-L1209
qloog/yaf-library
src/Http/Client.php
Client.addHeader
public function addHeader($name, $value) { if (isset($this->headers[$name])) { if (is_array($this->headers[$name])) { $this->headers[$name][] = $value; } else { $this->headers[$name] = $value; } } else { $this->headers[$name] = [$value]; } return $this; }
php
public function addHeader($name, $value) { if (isset($this->headers[$name])) { if (is_array($this->headers[$name])) { $this->headers[$name][] = $value; } else { $this->headers[$name] = $value; } } else { $this->headers[$name] = [$value]; } return $this; }
[ "public", "function", "addHeader", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "headers", "[", "$", "...
添加一个请求头 @param string $name 头名称 @param string $value 头内容 @return $this
[ "添加一个请求头" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Client.php#L112-L125
qloog/yaf-library
src/Http/Client.php
Client.setHeader
public function setHeader($name, $value) { if (isset($this->headers[$name])) { if (is_array($this->headers[$name])) { $this->headers[$name] = (array)$value; } else { $this->headers[$name] = $value; } } else { $this->headers[$name] = (array)$value; } return $this; }
php
public function setHeader($name, $value) { if (isset($this->headers[$name])) { if (is_array($this->headers[$name])) { $this->headers[$name] = (array)$value; } else { $this->headers[$name] = $value; } } else { $this->headers[$name] = (array)$value; } return $this; }
[ "public", "function", "setHeader", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "headers", "[", "$", "...
设置一个请求头 @param string $name 头名称 @param string $value 头内容 @return $this
[ "设置一个请求头" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Client.php#L149-L162
qloog/yaf-library
src/Http/Client.php
Client.head
public function head($url, array $query = []) { $url = $this->buildUrl($url, $query); $handle = $this->getHandler(); curl_setopt_array($handle, [ CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => true, ]); return $this->run($handle, $url); }
php
public function head($url, array $query = []) { $url = $this->buildUrl($url, $query); $handle = $this->getHandler(); curl_setopt_array($handle, [ CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => true, ]); return $this->run($handle, $url); }
[ "public", "function", "head", "(", "$", "url", ",", "array", "$", "query", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "buildUrl", "(", "$", "url", ",", "$", "query", ")", ";", "$", "handle", "=", "$", "this", "->", "getHandler...
HEAD Request @param string $url 链接地址 @param array $query 发送的数据 @return Response|null 请求失败返回null,成功返回Response对象
[ "HEAD", "Request" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Client.php#L186-L197
qloog/yaf-library
src/Http/Client.php
Client.get
public function get($url, array $query = []) { $url = $this->buildUrl($url, $query); $handle = $this->getHandler(); return $this->run($handle, $url); }
php
public function get($url, array $query = []) { $url = $this->buildUrl($url, $query); $handle = $this->getHandler(); return $this->run($handle, $url); }
[ "public", "function", "get", "(", "$", "url", ",", "array", "$", "query", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "buildUrl", "(", "$", "url", ",", "$", "query", ")", ";", "$", "handle", "=", "$", "this", "->", "getHandler"...
GET Request @param string $url 链接地址 @param array $query 发送的数据 @return Response|null 请求失败返回null,成功返回Response对象
[ "GET", "Request" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Client.php#L206-L212
qloog/yaf-library
src/Http/Client.php
Client.post
public function post($url, array $query = [], array $data = [], array $files = []) { $url = $this->buildUrl($url, $query); if ($files) { foreach ($files as $key => $file) { $data[$key] = new CURLFile($file['tmp_name']); } } else { $data = http_build_query($data); } $handle = $this->getHandler(); curl_setopt_array($handle, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data, ]); return $this->run($handle, $url); }
php
public function post($url, array $query = [], array $data = [], array $files = []) { $url = $this->buildUrl($url, $query); if ($files) { foreach ($files as $key => $file) { $data[$key] = new CURLFile($file['tmp_name']); } } else { $data = http_build_query($data); } $handle = $this->getHandler(); curl_setopt_array($handle, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data, ]); return $this->run($handle, $url); }
[ "public", "function", "post", "(", "$", "url", ",", "array", "$", "query", "=", "[", "]", ",", "array", "$", "data", "=", "[", "]", ",", "array", "$", "files", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "buildUrl", "(", "$",...
POST Request @param string $url 链接地址 @param array $query 拼接在URL后的数据 @param array $data 发送的数据 @param array $files 文件列表 @return Response|null 请求失败返回null,成功返回Response对象
[ "POST", "Request" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Client.php#L223-L244
qloog/yaf-library
src/Http/Client.php
Client.delete
public function delete($url, array $query = [], array $data = []) { $url = $this->buildUrl($url, $query); $handle = $this->getHandler(); curl_setopt_array($handle, [ CURLOPT_CUSTOMREQUEST => 'DELETE', CURLOPT_POSTFIELDS => http_build_query($data), ]); return $this->run($handle, $url); }
php
public function delete($url, array $query = [], array $data = []) { $url = $this->buildUrl($url, $query); $handle = $this->getHandler(); curl_setopt_array($handle, [ CURLOPT_CUSTOMREQUEST => 'DELETE', CURLOPT_POSTFIELDS => http_build_query($data), ]); return $this->run($handle, $url); }
[ "public", "function", "delete", "(", "$", "url", ",", "array", "$", "query", "=", "[", "]", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "buildUrl", "(", "$", "url", ",", "$", "query", ")", ";", "$",...
GET Request @param string $url 链接地址 @param array $query 拼接在URL后的数据 @param array $data 发送的数据 @return Response|null 请求失败返回null,成功返回Response对象
[ "GET", "Request" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Client.php#L254-L265
qloog/yaf-library
src/Http/Client.php
Client.run
protected function run($handler, $url) { $headers = [ 'X-REQUEST-ID: ' . $this->requestId(), ]; foreach ($this->headers as $name => $values) { if (is_array($values)) { foreach ($values as $value) { $headers[] = $name . ': ' . $value; } } else { $headers[] = $name . ': ' . $values; } } $options = $this->options; $options[CURLINFO_HEADER_OUT] = true; $options[CURLOPT_HEADER] = true; $options[CURLOPT_URL] = $url; $options[CURLOPT_HTTPHEADER] = $headers; curl_setopt_array($handler, $options); // 如果是并发请求则停止向下执行 if ($this->isMulti) { return $handler; } $result = curl_exec($handler); if ($result === false) { Log::warning('Curl error: ' . curl_error($handler), [$url, 'trace' => debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS & DEBUG_BACKTRACE_PROVIDE_OBJECT)]); return null; } return new Response($result, $handler); }
php
protected function run($handler, $url) { $headers = [ 'X-REQUEST-ID: ' . $this->requestId(), ]; foreach ($this->headers as $name => $values) { if (is_array($values)) { foreach ($values as $value) { $headers[] = $name . ': ' . $value; } } else { $headers[] = $name . ': ' . $values; } } $options = $this->options; $options[CURLINFO_HEADER_OUT] = true; $options[CURLOPT_HEADER] = true; $options[CURLOPT_URL] = $url; $options[CURLOPT_HTTPHEADER] = $headers; curl_setopt_array($handler, $options); // 如果是并发请求则停止向下执行 if ($this->isMulti) { return $handler; } $result = curl_exec($handler); if ($result === false) { Log::warning('Curl error: ' . curl_error($handler), [$url, 'trace' => debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS & DEBUG_BACKTRACE_PROVIDE_OBJECT)]); return null; } return new Response($result, $handler); }
[ "protected", "function", "run", "(", "$", "handler", ",", "$", "url", ")", "{", "$", "headers", "=", "[", "'X-REQUEST-ID: '", ".", "$", "this", "->", "requestId", "(", ")", ",", "]", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "na...
执行 @param resource $handler @param string $url @return Response|null
[ "执行" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Client.php#L286-L322
qloog/yaf-library
src/Http/Client.php
Client.buildUrl
protected function buildUrl($url, array $data) { if (!$data) { return $url; } if (strpos($url, '?') === false) { $url .= '?'; } elseif (substr($url, 0, -1) != '?') { $url .= '&'; } return $url . http_build_query($data); }
php
protected function buildUrl($url, array $data) { if (!$data) { return $url; } if (strpos($url, '?') === false) { $url .= '?'; } elseif (substr($url, 0, -1) != '?') { $url .= '&'; } return $url . http_build_query($data); }
[ "protected", "function", "buildUrl", "(", "$", "url", ",", "array", "$", "data", ")", "{", "if", "(", "!", "$", "data", ")", "{", "return", "$", "url", ";", "}", "if", "(", "strpos", "(", "$", "url", ",", "'?'", ")", "===", "false", ")", "{", ...
URL Build @param string $url @param array $data @return string
[ "URL", "Build" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Client.php#L331-L344
oasmobile/php-aws-wrappers
src/AwsWrappers/DynamoDbManager.php
DynamoDbManager.listTables
public function listTables($pattern = '/.*/') { $tables = []; $lastEvaluatedTableName = null; do { $args = [ "Limit" => 30, ]; if ($lastEvaluatedTableName) { $args['ExclusiveStartTableName'] = $lastEvaluatedTableName; } $cmd = $this->db->getCommand( 'ListTables', $args ); $result = $this->db->execute($cmd); if (isset($result['LastEvaluatedTableName'])) { $lastEvaluatedTableName = $result['LastEvaluatedTableName']; } else { $lastEvaluatedTableName = null; } foreach ($result['TableNames'] as $tableName) { if (preg_match($pattern, $tableName)) { $tables[] = $tableName; } } } while ($lastEvaluatedTableName != null); return $tables; }
php
public function listTables($pattern = '/.*/') { $tables = []; $lastEvaluatedTableName = null; do { $args = [ "Limit" => 30, ]; if ($lastEvaluatedTableName) { $args['ExclusiveStartTableName'] = $lastEvaluatedTableName; } $cmd = $this->db->getCommand( 'ListTables', $args ); $result = $this->db->execute($cmd); if (isset($result['LastEvaluatedTableName'])) { $lastEvaluatedTableName = $result['LastEvaluatedTableName']; } else { $lastEvaluatedTableName = null; } foreach ($result['TableNames'] as $tableName) { if (preg_match($pattern, $tableName)) { $tables[] = $tableName; } } } while ($lastEvaluatedTableName != null); return $tables; }
[ "public", "function", "listTables", "(", "$", "pattern", "=", "'/.*/'", ")", "{", "$", "tables", "=", "[", "]", ";", "$", "lastEvaluatedTableName", "=", "null", ";", "do", "{", "$", "args", "=", "[", "\"Limit\"", "=>", "30", ",", "]", ";", "if", "(...
@param string $pattern a pattern that table name should match, if emtpy, all tables will be returned @return array
[ "@param", "string", "$pattern", "a", "pattern", "that", "table", "name", "should", "match", "if", "emtpy", "all", "tables", "will", "be", "returned" ]
train
https://github.com/oasmobile/php-aws-wrappers/blob/0f756dc60ef6f51e9a99f67c9125289e40f19e3f/src/AwsWrappers/DynamoDbManager.php#L32-L63
oasmobile/php-aws-wrappers
src/AwsWrappers/DynamoDbManager.php
DynamoDbManager.createTable
public function createTable($tableName, DynamoDbIndex $primaryIndex, array $localSecondaryIndices = [], array $globalSecondaryIndices = [], $readCapacity = 5, $writeCapacity = 5 ) { $attrDef = $primaryIndex->getAttributeDefinitions(); foreach ($globalSecondaryIndices as $gsi) { $gsiDef = $gsi->getAttributeDefinitions(); $attrDef = array_merge($attrDef, $gsiDef); } foreach ($localSecondaryIndices as $lsi) { $lsiDef = $lsi->getAttributeDefinitions(); $attrDef = array_merge($attrDef, $lsiDef); } $attrDef = array_values($attrDef); $keySchema = $primaryIndex->getKeySchema(); $gsiDef = []; foreach ($globalSecondaryIndices as $globalSecondaryIndex) { $gsiDef[] = [ "IndexName" => $globalSecondaryIndex->getName(), "KeySchema" => $globalSecondaryIndex->getKeySchema(), "Projection" => $globalSecondaryIndex->getProjection(), "ProvisionedThroughput" => [ "ReadCapacityUnits" => $readCapacity, "WriteCapacityUnits" => $writeCapacity, ], ]; } $lsiDef = []; foreach ($localSecondaryIndices as $localSecondaryIndex) { $lsiDef[] = [ "IndexName" => $localSecondaryIndex->getName(), "KeySchema" => $localSecondaryIndex->getKeySchema(), "Projection" => $localSecondaryIndex->getProjection(), ]; } $args = [ "TableName" => $tableName, "ProvisionedThroughput" => [ "ReadCapacityUnits" => $readCapacity, "WriteCapacityUnits" => $writeCapacity, ], "AttributeDefinitions" => $attrDef, "KeySchema" => $keySchema, ]; if ($gsiDef) { $args["GlobalSecondaryIndexes"] = $gsiDef; } if ($lsiDef) { $args["LocalSecondaryIndexes"] = $lsiDef; } $result = $this->db->createTable($args); if (isset($result['TableDescription']) && $result['TableDescription']) { return true; } else { return false; } }
php
public function createTable($tableName, DynamoDbIndex $primaryIndex, array $localSecondaryIndices = [], array $globalSecondaryIndices = [], $readCapacity = 5, $writeCapacity = 5 ) { $attrDef = $primaryIndex->getAttributeDefinitions(); foreach ($globalSecondaryIndices as $gsi) { $gsiDef = $gsi->getAttributeDefinitions(); $attrDef = array_merge($attrDef, $gsiDef); } foreach ($localSecondaryIndices as $lsi) { $lsiDef = $lsi->getAttributeDefinitions(); $attrDef = array_merge($attrDef, $lsiDef); } $attrDef = array_values($attrDef); $keySchema = $primaryIndex->getKeySchema(); $gsiDef = []; foreach ($globalSecondaryIndices as $globalSecondaryIndex) { $gsiDef[] = [ "IndexName" => $globalSecondaryIndex->getName(), "KeySchema" => $globalSecondaryIndex->getKeySchema(), "Projection" => $globalSecondaryIndex->getProjection(), "ProvisionedThroughput" => [ "ReadCapacityUnits" => $readCapacity, "WriteCapacityUnits" => $writeCapacity, ], ]; } $lsiDef = []; foreach ($localSecondaryIndices as $localSecondaryIndex) { $lsiDef[] = [ "IndexName" => $localSecondaryIndex->getName(), "KeySchema" => $localSecondaryIndex->getKeySchema(), "Projection" => $localSecondaryIndex->getProjection(), ]; } $args = [ "TableName" => $tableName, "ProvisionedThroughput" => [ "ReadCapacityUnits" => $readCapacity, "WriteCapacityUnits" => $writeCapacity, ], "AttributeDefinitions" => $attrDef, "KeySchema" => $keySchema, ]; if ($gsiDef) { $args["GlobalSecondaryIndexes"] = $gsiDef; } if ($lsiDef) { $args["LocalSecondaryIndexes"] = $lsiDef; } $result = $this->db->createTable($args); if (isset($result['TableDescription']) && $result['TableDescription']) { return true; } else { return false; } }
[ "public", "function", "createTable", "(", "$", "tableName", ",", "DynamoDbIndex", "$", "primaryIndex", ",", "array", "$", "localSecondaryIndices", "=", "[", "]", ",", "array", "$", "globalSecondaryIndices", "=", "[", "]", ",", "$", "readCapacity", "=", "5", ...
@param $tableName @param DynamoDbIndex $primaryIndex @param DynamoDbIndex[] $localSecondaryIndices @param DynamoDbIndex[] $globalSecondaryIndices @param int $readCapacity @param int $writeCapacity @return bool @internal param DynamoDbIndex $primaryKey
[ "@param", "$tableName", "@param", "DynamoDbIndex", "$primaryIndex", "@param", "DynamoDbIndex", "[]", "$localSecondaryIndices", "@param", "DynamoDbIndex", "[]", "$globalSecondaryIndices", "@param", "int", "$readCapacity", "@param", "int", "$writeCapacity" ]
train
https://github.com/oasmobile/php-aws-wrappers/blob/0f756dc60ef6f51e9a99f67c9125289e40f19e3f/src/AwsWrappers/DynamoDbManager.php#L76-L144
qloog/yaf-library
src/Rpc/Server/Json.php
Json.init
public function init() { parent::init(); $params = json_decode(urldecode($this->get('params')), true); $props = ['id', 'module', 'fun']; foreach ($props as $prop) { $this->{$prop} = isset($params[$prop]) ? $params[$prop] : ''; } $this->args = isset($params['args']) ? $params['args'] : []; }
php
public function init() { parent::init(); $params = json_decode(urldecode($this->get('params')), true); $props = ['id', 'module', 'fun']; foreach ($props as $prop) { $this->{$prop} = isset($params[$prop]) ? $params[$prop] : ''; } $this->args = isset($params['args']) ? $params['args'] : []; }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "$", "params", "=", "json_decode", "(", "urldecode", "(", "$", "this", "->", "get", "(", "'params'", ")", ")", ",", "true", ")", ";", "$", "props", "=", "[", "'id...
初始化, 解析请求参数为属性
[ "初始化", "解析请求参数为属性" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Rpc/Server/Json.php#L45-L57
qloog/yaf-library
src/Rpc/Server/Json.php
Json.callAction
public function callAction() { $info = ['id' => $this->id, 'module' => $this->module, 'fun' => $this->fun, 'args' => $this->args]; $this->eventsManager->fire('rpc:beforeHandle', $this, $info); try { $rs = $this->handle(); $info['rs'] = $rs; $this->eventsManager->fire('rpc:afterHandled', $this, $info); } catch (\Exception $e) { $info['exception'] = $e; $this->eventsManager->fire('rpc:onException', $this, $info); $rs = $this->buildFromException($e); } $this->success($rs); }
php
public function callAction() { $info = ['id' => $this->id, 'module' => $this->module, 'fun' => $this->fun, 'args' => $this->args]; $this->eventsManager->fire('rpc:beforeHandle', $this, $info); try { $rs = $this->handle(); $info['rs'] = $rs; $this->eventsManager->fire('rpc:afterHandled', $this, $info); } catch (\Exception $e) { $info['exception'] = $e; $this->eventsManager->fire('rpc:onException', $this, $info); $rs = $this->buildFromException($e); } $this->success($rs); }
[ "public", "function", "callAction", "(", ")", "{", "$", "info", "=", "[", "'id'", "=>", "$", "this", "->", "id", ",", "'module'", "=>", "$", "this", "->", "module", ",", "'fun'", "=>", "$", "this", "->", "fun", ",", "'args'", "=>", "$", "this", "...
RPC请求入口action
[ "RPC请求入口action" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Rpc/Server/Json.php#L62-L79
qloog/yaf-library
src/Rpc/Server/Json.php
Json.handle
public function handle() { @ob_start(); $ret = call_user_func_array([$this->di->get($this->module), $this->fun], $this->args); $out = ob_get_clean(); ob_end_clean(); return $this->packResult(['return' => $ret, 'output' => $out ?: '']); }
php
public function handle() { @ob_start(); $ret = call_user_func_array([$this->di->get($this->module), $this->fun], $this->args); $out = ob_get_clean(); ob_end_clean(); return $this->packResult(['return' => $ret, 'output' => $out ?: '']); }
[ "public", "function", "handle", "(", ")", "{", "@", "ob_start", "(", ")", ";", "$", "ret", "=", "call_user_func_array", "(", "[", "$", "this", "->", "di", "->", "get", "(", "$", "this", "->", "module", ")", ",", "$", "this", "->", "fun", "]", ","...
请求处理 @return array
[ "请求处理" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Rpc/Server/Json.php#L85-L93
qloog/yaf-library
src/Rpc/Server/Json.php
Json.buildFromException
protected function buildFromException(\Exception $e) { $rs = [ 'return' => false, 'status' => 500, 'exception' => [ 'msg' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), ], ]; return $this->packResult($rs); }
php
protected function buildFromException(\Exception $e) { $rs = [ 'return' => false, 'status' => 500, 'exception' => [ 'msg' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), ], ]; return $this->packResult($rs); }
[ "protected", "function", "buildFromException", "(", "\\", "Exception", "$", "e", ")", "{", "$", "rs", "=", "[", "'return'", "=>", "false", ",", "'status'", "=>", "500", ",", "'exception'", "=>", "[", "'msg'", "=>", "$", "e", "->", "getMessage", "(", ")...
拼装异常结果 @param \Exception $e @return array
[ "拼装异常结果", "@param", "\\", "Exception", "$e" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Rpc/Server/Json.php#L101-L114
qloog/yaf-library
src/Rpc/Server/Json.php
Json.packResult
protected function packResult($rs) { return [ 'id' => $this->id, 'module' => $this->module, 'fun' => $this->fun, 'args' => $this->args, 'return' => isset($rs['return']) ? $rs['return'] : null, 'status' => isset($rs['status']) ? $rs['status'] : 200, 'output' => isset($rs['output']) ? $rs['output'] : '', 'exception' => isset($rs['exception']) ? $rs['exception'] : [], ]; }
php
protected function packResult($rs) { return [ 'id' => $this->id, 'module' => $this->module, 'fun' => $this->fun, 'args' => $this->args, 'return' => isset($rs['return']) ? $rs['return'] : null, 'status' => isset($rs['status']) ? $rs['status'] : 200, 'output' => isset($rs['output']) ? $rs['output'] : '', 'exception' => isset($rs['exception']) ? $rs['exception'] : [], ]; }
[ "protected", "function", "packResult", "(", "$", "rs", ")", "{", "return", "[", "'id'", "=>", "$", "this", "->", "id", ",", "'module'", "=>", "$", "this", "->", "module", ",", "'fun'", "=>", "$", "this", "->", "fun", ",", "'args'", "=>", "$", "this...
拼装处理结果 @param array $rs @return array
[ "拼装处理结果", "@param", "array", "$rs" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Rpc/Server/Json.php#L122-L134
makinacorpus/drupal-ucms
ucms_group/src/Datasource/GroupSiteAdminDatasource.php
GroupSiteAdminDatasource.getSorts
public function getSorts() { return [ 's.id' => $this->t("identifier"), 's.title' => $this->t("title"), 's.title_admin' => $this->t("administrative title"), 's.state' => $this->t("state"), 's.type' => $this->t("type"), 's.http_host' => $this->t("domain name"), ]; }
php
public function getSorts() { return [ 's.id' => $this->t("identifier"), 's.title' => $this->t("title"), 's.title_admin' => $this->t("administrative title"), 's.state' => $this->t("state"), 's.type' => $this->t("type"), 's.http_host' => $this->t("domain name"), ]; }
[ "public", "function", "getSorts", "(", ")", "{", "return", "[", "'s.id'", "=>", "$", "this", "->", "t", "(", "\"identifier\"", ")", ",", "'s.title'", "=>", "$", "this", "->", "t", "(", "\"title\"", ")", ",", "'s.title_admin'", "=>", "$", "this", "->", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/Datasource/GroupSiteAdminDatasource.php#L59-L69
makinacorpus/drupal-ucms
ucms_group/src/Datasource/GroupSiteAdminDatasource.php
GroupSiteAdminDatasource.getItems
public function getItems(Query $query) { $q = $this ->database ->select('ucms_site', 's') ->addTag('ucms_group_access') ->addTag('ucms_site_access') //->groupBy('s.id') ; // We need aliases $q->addField('s', 'id', 'site_id'); $q->addField('s', 'group_id', 'group_id'); if ($query->has('group')) { $q->condition('s.group_id', $query->get('group')); } if ($query->has('site')) { $q->condition('s.id', $query->get('site')); } // Filters if ($query->has('state')) { $q->condition('s.state', $query->get('state')); } if ($query->has('theme')) { $q->condition('s.theme', $query->get('theme')); } if ($query->has('template')) { $q->condition('s.template_id', $query->get('template')); } if ($query->hasSortField()) { $q->orderBy($query->getSortField(), $query->getSortOrder()); } $q->orderBy('s.title', $query->getSortOrder()); $search = $query->getSearchString(); if ($search) { $q->condition( (new \DatabaseCondition('OR')) ->condition('s.title', '%' . db_like($search) . '%', 'LIKE') ->condition('s.title_admin', '%' . db_like($search) . '%', 'LIKE') ->condition('s.http_host', '%' . db_like($search) . '%', 'LIKE') ); } /** @var \MakinaCorpus\Drupal\Calista\Datasource\QueryExtender\DrupalPager $pager */ $pager = $q->extend(DrupalPager::class)->setDatasourceQuery($query); $r = $pager->execute(); $r->setFetchMode(\PDO::FETCH_CLASS, GroupSite::class); $ret = $r->fetchAll(); // Preload all sites, we will need it in display $siteIdList = array_map(function (GroupSite $item) { return $item->getSiteId(); }, $ret); $sites = $this->siteManager->getStorage()->loadAll($siteIdList, false); /** @var \MakinaCorpus\Ucms\Site\GroupSite $record */ foreach ($ret as $record) { $siteId = $record->getSiteId(); if (isset($sites[$siteId])) { $record->setSite($sites[$siteId]); } } return $this->createResult($ret, $pager->getTotalCount()); }
php
public function getItems(Query $query) { $q = $this ->database ->select('ucms_site', 's') ->addTag('ucms_group_access') ->addTag('ucms_site_access') //->groupBy('s.id') ; // We need aliases $q->addField('s', 'id', 'site_id'); $q->addField('s', 'group_id', 'group_id'); if ($query->has('group')) { $q->condition('s.group_id', $query->get('group')); } if ($query->has('site')) { $q->condition('s.id', $query->get('site')); } // Filters if ($query->has('state')) { $q->condition('s.state', $query->get('state')); } if ($query->has('theme')) { $q->condition('s.theme', $query->get('theme')); } if ($query->has('template')) { $q->condition('s.template_id', $query->get('template')); } if ($query->hasSortField()) { $q->orderBy($query->getSortField(), $query->getSortOrder()); } $q->orderBy('s.title', $query->getSortOrder()); $search = $query->getSearchString(); if ($search) { $q->condition( (new \DatabaseCondition('OR')) ->condition('s.title', '%' . db_like($search) . '%', 'LIKE') ->condition('s.title_admin', '%' . db_like($search) . '%', 'LIKE') ->condition('s.http_host', '%' . db_like($search) . '%', 'LIKE') ); } /** @var \MakinaCorpus\Drupal\Calista\Datasource\QueryExtender\DrupalPager $pager */ $pager = $q->extend(DrupalPager::class)->setDatasourceQuery($query); $r = $pager->execute(); $r->setFetchMode(\PDO::FETCH_CLASS, GroupSite::class); $ret = $r->fetchAll(); // Preload all sites, we will need it in display $siteIdList = array_map(function (GroupSite $item) { return $item->getSiteId(); }, $ret); $sites = $this->siteManager->getStorage()->loadAll($siteIdList, false); /** @var \MakinaCorpus\Ucms\Site\GroupSite $record */ foreach ($ret as $record) { $siteId = $record->getSiteId(); if (isset($sites[$siteId])) { $record->setSite($sites[$siteId]); } } return $this->createResult($ret, $pager->getTotalCount()); }
[ "public", "function", "getItems", "(", "Query", "$", "query", ")", "{", "$", "q", "=", "$", "this", "->", "database", "->", "select", "(", "'ucms_site'", ",", "'s'", ")", "->", "addTag", "(", "'ucms_group_access'", ")", "->", "addTag", "(", "'ucms_site_a...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/Datasource/GroupSiteAdminDatasource.php#L83-L149
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php
Standard.deleteItems
public function deleteItems( \stdClass $params ) { $this->checkParams( $params, array( 'items' ) ); foreach( (array) $params->items as $id ) { $this->getManager()->deleteItem( $id ); } return array( 'success' => true, ); }
php
public function deleteItems( \stdClass $params ) { $this->checkParams( $params, array( 'items' ) ); foreach( (array) $params->items as $id ) { $this->getManager()->deleteItem( $id ); } return array( 'success' => true, ); }
[ "public", "function", "deleteItems", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'items'", ")", ")", ";", "foreach", "(", "(", "array", ")", "$", "params", "->", "items", "...
Deletes an item or a list of items. @param \stdClass $params Associative list of parameters
[ "Deletes", "an", "item", "or", "a", "list", "of", "items", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php#L44-L55
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php
Standard.saveItems
public function saveItems( \stdClass $params ) { $this->checkParams( $params, array( 'items' ) ); $ids = []; $manager = $this->getManager(); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $entry ) { $item = $manager->createItem(); $item->fromArray( (array) $this->transformValues( $entry ) ); $item = $manager->saveItem( $item ); $ids[] = $item->getId(); } return $this->getItems( $ids, $this->getPrefix() ); }
php
public function saveItems( \stdClass $params ) { $this->checkParams( $params, array( 'items' ) ); $ids = []; $manager = $this->getManager(); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $entry ) { $item = $manager->createItem(); $item->fromArray( (array) $this->transformValues( $entry ) ); $item = $manager->saveItem( $item ); $ids[] = $item->getId(); } return $this->getItems( $ids, $this->getPrefix() ); }
[ "public", "function", "saveItems", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'items'", ")", ")", ";", "$", "ids", "=", "[", "]", ";", "$", "manager", "=", "$", "this", ...
Creates a new site item or updates an existing one or a list thereof. @param \stdClass $params Associative array containing the product properties
[ "Creates", "a", "new", "site", "item", "or", "updates", "an", "existing", "one", "or", "a", "list", "thereof", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php#L63-L80
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php
Standard.searchItems
public function searchItems( \stdClass $params ) { $total = 0; $search = $this->initCriteria( $this->getManager()->createSearch(), $params ); $sort = $search->getSortations(); $sort[] = $search->sort( '+', 'locale.site.left' ); $search->setSortations( $sort ); $items = $this->getManager()->searchItems( $search, [], $total ); return array( 'items' => $this->toArray( $items ), 'total' => $total, 'success' => true, ); }
php
public function searchItems( \stdClass $params ) { $total = 0; $search = $this->initCriteria( $this->getManager()->createSearch(), $params ); $sort = $search->getSortations(); $sort[] = $search->sort( '+', 'locale.site.left' ); $search->setSortations( $sort ); $items = $this->getManager()->searchItems( $search, [], $total ); return array( 'items' => $this->toArray( $items ), 'total' => $total, 'success' => true, ); }
[ "public", "function", "searchItems", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "total", "=", "0", ";", "$", "search", "=", "$", "this", "->", "initCriteria", "(", "$", "this", "->", "getManager", "(", ")", "->", "createSearch", "(", ")", "...
Retrieves all items matching the given criteria. @param \stdClass $params Associative array containing the parameters @return array List of associative arrays with item properties, total number of items and success property
[ "Retrieves", "all", "items", "matching", "the", "given", "criteria", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php#L89-L105
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php
Standard.insertItems
public function insertItems( \stdClass $params ) { $this->checkParams( $params, array( 'items' ) ); $manager = $this->getManager(); $refId = ( isset( $params->refid ) ? $params->refid : null ); $parentId = ( ( isset( $params->parentid ) && $params->parentid !== 'root' ) ? $params->parentid : null ); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $entry ) { $item = $manager->createItem(); $item->fromArray( (array) $this->transformValues( $entry ) ); $manager->insertItem( $item, $parentId, $refId ); $entry->{'locale.site.id'} = $item->getId(); } return array( 'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ), 'success' => true, ); }
php
public function insertItems( \stdClass $params ) { $this->checkParams( $params, array( 'items' ) ); $manager = $this->getManager(); $refId = ( isset( $params->refid ) ? $params->refid : null ); $parentId = ( ( isset( $params->parentid ) && $params->parentid !== 'root' ) ? $params->parentid : null ); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $entry ) { $item = $manager->createItem(); $item->fromArray( (array) $this->transformValues( $entry ) ); $manager->insertItem( $item, $parentId, $refId ); $entry->{'locale.site.id'} = $item->getId(); } return array( 'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ), 'success' => true, ); }
[ "public", "function", "insertItems", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'items'", ")", ")", ";", "$", "manager", "=", "$", "this", "->", "getManager", "(", ")", ";...
Inserts a new item or a list of new items depending on the parent and the referenced item ID. @param \stdClass $params Associative list of parameters @return array Associative list with nodes and success value
[ "Inserts", "a", "new", "item", "or", "a", "list", "of", "new", "items", "depending", "on", "the", "parent", "and", "the", "referenced", "item", "ID", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php#L114-L137
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php
Standard.moveItems
public function moveItems( \stdClass $params ) { $this->checkParams( $params, array( 'items', 'oldparentid', 'newparentid', 'refid' ) ); $manager = $this->getManager(); if( $params->newparentid === 'root' ) { $params->newparentid = null; } if( $params->refid === 'root' ) { $params->refid = null; } $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $id ) { $manager->moveItem( $id, $params->oldparentid, $params->newparentid, $params->refid ); } return array( 'success' => true, ); }
php
public function moveItems( \stdClass $params ) { $this->checkParams( $params, array( 'items', 'oldparentid', 'newparentid', 'refid' ) ); $manager = $this->getManager(); if( $params->newparentid === 'root' ) { $params->newparentid = null; } if( $params->refid === 'root' ) { $params->refid = null; } $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $id ) { $manager->moveItem( $id, $params->oldparentid, $params->newparentid, $params->refid ); } return array( 'success' => true, ); }
[ "public", "function", "moveItems", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'items'", ",", "'oldparentid'", ",", "'newparentid'", ",", "'refid'", ")", ")", ";", "$", "manage...
Moves an item or a list of items depending on the old parent, the new parent and the referenced item ID. @param \stdClass $params Associative list of parameters @return array Associative list with success value
[ "Moves", "an", "item", "or", "a", "list", "of", "items", "depending", "on", "the", "old", "parent", "the", "new", "parent", "and", "the", "referenced", "item", "ID", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php#L146-L169
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php
Standard.getTree
public function getTree( \stdClass $params ) { $this->checkParams( $params, array( 'items' ) ); $manager = $this->getManager(); $result = []; $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $entry ) { if( $entry == 'root' ) { $search = $this->manager->createSearch(); $search->setConditions( $search->compare( '==', 'locale.site.level', 0 ) ); $item = $this->manager->createItem(); $item->setLabel( 'Root' ); foreach( $this->manager->searchItems( $search ) as $siteItem ) { $item->addChild( $siteItem ); } } else { $item = $manager->getTree( $entry, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST ); } $result[] = $this->createNodeArray( $item ); } return array( 'items' => ( !is_array( $params->items ) ? reset( $result ) : $result ), 'success' => true, ); }
php
public function getTree( \stdClass $params ) { $this->checkParams( $params, array( 'items' ) ); $manager = $this->getManager(); $result = []; $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $entry ) { if( $entry == 'root' ) { $search = $this->manager->createSearch(); $search->setConditions( $search->compare( '==', 'locale.site.level', 0 ) ); $item = $this->manager->createItem(); $item->setLabel( 'Root' ); foreach( $this->manager->searchItems( $search ) as $siteItem ) { $item->addChild( $siteItem ); } } else { $item = $manager->getTree( $entry, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST ); } $result[] = $this->createNodeArray( $item ); } return array( 'items' => ( !is_array( $params->items ) ? reset( $result ) : $result ), 'success' => true, ); }
[ "public", "function", "getTree", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'items'", ")", ")", ";", "$", "manager", "=", "$", "this", "->", "getManager", "(", ")", ";", ...
Returns an item or a list of items including their children for the given IDs. @param \stdClass $params Associative list of parameters @return array Associative list with nodes and success value
[ "Returns", "an", "item", "or", "a", "list", "of", "items", "including", "their", "children", "for", "the", "given", "IDs", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php#L178-L213
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php
Standard.createNodeArray
protected function createNodeArray( \Aimeos\MShop\Locale\Item\Site\Iface $item ) { $result = $item->toArray( true ); if( method_exists( $item, 'getChildren' ) ) { foreach( $item->getChildren() as $child ) { $result['children'][] = $this->createNodeArray( $child ); } } return (object) $result; }
php
protected function createNodeArray( \Aimeos\MShop\Locale\Item\Site\Iface $item ) { $result = $item->toArray( true ); if( method_exists( $item, 'getChildren' ) ) { foreach( $item->getChildren() as $child ) { $result['children'][] = $this->createNodeArray( $child ); } } return (object) $result; }
[ "protected", "function", "createNodeArray", "(", "\\", "Aimeos", "\\", "MShop", "\\", "Locale", "\\", "Item", "\\", "Site", "\\", "Iface", "$", "item", ")", "{", "$", "result", "=", "$", "item", "->", "toArray", "(", "true", ")", ";", "if", "(", "met...
Creates a list of items with children. @param \Aimeos\MShop\Locale\Item\Site\Iface $item Locale site item
[ "Creates", "a", "list", "of", "items", "with", "children", "." ]
train
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Locale/Site/Standard.php#L280-L292
platformsh/console-form
src/Field/OptionsField.php
OptionsField.matchesCondition
public function matchesCondition($userValue, $condition) { if (is_callable($condition)) { return $condition($userValue); } return is_array($condition) ? in_array($userValue, $condition) : $userValue === $condition; }
php
public function matchesCondition($userValue, $condition) { if (is_callable($condition)) { return $condition($userValue); } return is_array($condition) ? in_array($userValue, $condition) : $userValue === $condition; }
[ "public", "function", "matchesCondition", "(", "$", "userValue", ",", "$", "condition", ")", "{", "if", "(", "is_callable", "(", "$", "condition", ")", ")", "{", "return", "$", "condition", "(", "$", "userValue", ")", ";", "}", "return", "is_array", "(",...
{@inheritdoc}
[ "{" ]
train
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/OptionsField.php#L54-L63
platformsh/console-form
src/Field/OptionsField.php
OptionsField.getAsQuestion
public function getAsQuestion() { if ($this->asChoice) { $question = $this->getChoiceQuestion(); } else { $question = parent::getAsQuestion(); $question->setAutocompleterValues($this->options); } return $question; }
php
public function getAsQuestion() { if ($this->asChoice) { $question = $this->getChoiceQuestion(); } else { $question = parent::getAsQuestion(); $question->setAutocompleterValues($this->options); } return $question; }
[ "public", "function", "getAsQuestion", "(", ")", "{", "if", "(", "$", "this", "->", "asChoice", ")", "{", "$", "question", "=", "$", "this", "->", "getChoiceQuestion", "(", ")", ";", "}", "else", "{", "$", "question", "=", "parent", "::", "getAsQuestio...
{@inheritdoc}
[ "{" ]
train
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/OptionsField.php#L68-L79
platformsh/console-form
src/Field/OptionsField.php
OptionsField.getChoiceQuestion
protected function getChoiceQuestion() { $numeric = $this->isNumeric(); $text = $this->getQuestionHeader(); if ($numeric) { $text .= "\nEnter a number to choose: "; } $question = new ChoiceQuestion( $text, $this->options, $this->default ); $question->setPrompt($this->prompt); $question->setMaxAttempts($this->maxAttempts); if (!$numeric) { $question->setAutocompleterValues(array_keys($this->options)); } return $question; }
php
protected function getChoiceQuestion() { $numeric = $this->isNumeric(); $text = $this->getQuestionHeader(); if ($numeric) { $text .= "\nEnter a number to choose: "; } $question = new ChoiceQuestion( $text, $this->options, $this->default ); $question->setPrompt($this->prompt); $question->setMaxAttempts($this->maxAttempts); if (!$numeric) { $question->setAutocompleterValues(array_keys($this->options)); } return $question; }
[ "protected", "function", "getChoiceQuestion", "(", ")", "{", "$", "numeric", "=", "$", "this", "->", "isNumeric", "(", ")", ";", "$", "text", "=", "$", "this", "->", "getQuestionHeader", "(", ")", ";", "if", "(", "$", "numeric", ")", "{", "$", "text"...
{@inheritdoc}
[ "{" ]
train
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/OptionsField.php#L84-L104
platformsh/console-form
src/Field/OptionsField.php
OptionsField.onChange
public function onChange(array $previousValues) { parent::onChange($previousValues); if (isset($this->optionsCallback)) { $callback = $this->optionsCallback; $this->options = $callback($previousValues); } }
php
public function onChange(array $previousValues) { parent::onChange($previousValues); if (isset($this->optionsCallback)) { $callback = $this->optionsCallback; $this->options = $callback($previousValues); } }
[ "public", "function", "onChange", "(", "array", "$", "previousValues", ")", "{", "parent", "::", "onChange", "(", "$", "previousValues", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "optionsCallback", ")", ")", "{", "$", "callback", "=", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/OptionsField.php#L131-L138
platformsh/console-form
src/Field/OptionsField.php
OptionsField.isNumeric
private function isNumeric() { foreach (array_keys($this->options) as $key) { if (!is_int($key)) { return false; } } return true; }
php
private function isNumeric() { foreach (array_keys($this->options) as $key) { if (!is_int($key)) { return false; } } return true; }
[ "private", "function", "isNumeric", "(", ")", "{", "foreach", "(", "array_keys", "(", "$", "this", "->", "options", ")", "as", "$", "key", ")", "{", "if", "(", "!", "is_int", "(", "$", "key", ")", ")", "{", "return", "false", ";", "}", "}", "retu...
Check if this is numeric, rather than associative. @return bool
[ "Check", "if", "this", "is", "numeric", "rather", "than", "associative", "." ]
train
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/OptionsField.php#L145-L154
qloog/yaf-library
src/Http/Support/Cookies.php
Cookies.setExpire
public function setExpire($expire) { // 一年内认为是相对时间 if ($expire < 31536001 && $expire != 0) { $expire += time(); } $this->expire = $expire; return $this; }
php
public function setExpire($expire) { // 一年内认为是相对时间 if ($expire < 31536001 && $expire != 0) { $expire += time(); } $this->expire = $expire; return $this; }
[ "public", "function", "setExpire", "(", "$", "expire", ")", "{", "// 一年内认为是相对时间", "if", "(", "$", "expire", "<", "31536001", "&&", "$", "expire", "!=", "0", ")", "{", "$", "expire", "+=", "time", "(", ")", ";", "}", "$", "this", "->", "expire", "="...
设置过期时间 @param int $expire @return $this
[ "设置过期时间" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Support/Cookies.php#L88-L97
qloog/yaf-library
src/Http/Support/Cookies.php
Cookies.get
public function get($name, $default = null) { $name = $this->prefix . $name; return isset($_COOKIE[$name]) ? $_COOKIE[$name] : $default; }
php
public function get($name, $default = null) { $name = $this->prefix . $name; return isset($_COOKIE[$name]) ? $_COOKIE[$name] : $default; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "name", "=", "$", "this", "->", "prefix", ".", "$", "name", ";", "return", "isset", "(", "$", "_COOKIE", "[", "$", "name", "]", ")", "?", "$", "_COO...
获取Cookie值 @param string $name @param mixed $default @return string|null
[ "获取Cookie值" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Support/Cookies.php#L130-L134
qloog/yaf-library
src/Http/Support/Cookies.php
Cookies.set
public function set($name, $value) { $name = $this->prefix . $name; return setcookie($name, $value, $this->expire, $this->path, $this->domain, $this->secure, $this->httpOnly); }
php
public function set($name, $value) { $name = $this->prefix . $name; return setcookie($name, $value, $this->expire, $this->path, $this->domain, $this->secure, $this->httpOnly); }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "$", "name", "=", "$", "this", "->", "prefix", ".", "$", "name", ";", "return", "setcookie", "(", "$", "name", ",", "$", "value", ",", "$", "this", "->", "expire", ",", ...
设置Cookie @param string $name @param string $value @return bool
[ "设置Cookie" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Support/Cookies.php#L143-L147
qloog/yaf-library
src/Http/Support/Cookies.php
Cookies.del
public function del($name) { $name = $this->prefix . $name; return setcookie($name, '', 1, $this->path, $this->domain, $this->secure, $this->httpOnly); }
php
public function del($name) { $name = $this->prefix . $name; return setcookie($name, '', 1, $this->path, $this->domain, $this->secure, $this->httpOnly); }
[ "public", "function", "del", "(", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "prefix", ".", "$", "name", ";", "return", "setcookie", "(", "$", "name", ",", "''", ",", "1", ",", "$", "this", "->", "path", ",", "$", "this", "->",...
删除Cookie @param $name @return bool
[ "删除Cookie" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Http/Support/Cookies.php#L155-L159
shopgate/cart-integration-sdk
src/helper/logging/strategy/DefaultLogging.php
Shopgate_Helper_Logging_Strategy_DefaultLogging.setLogFilePaths
public function setLogFilePaths($accessLogPath, $requestLogPath, $errorLogPath, $debugLogPath) { if (!empty($accessLogPath)) { $this->logFiles[self::LOGTYPE_ACCESS]['path'] = $accessLogPath; } if (!empty($requestLogPath)) { $this->logFiles[self::LOGTYPE_REQUEST]['path'] = $requestLogPath; } if (!empty($errorLogPath)) { $this->logFiles[self::LOGTYPE_ERROR]['path'] = $errorLogPath; } if (!empty($debugLogPath)) { $this->logFiles[self::LOGTYPE_DEBUG]['path'] = $debugLogPath; } }
php
public function setLogFilePaths($accessLogPath, $requestLogPath, $errorLogPath, $debugLogPath) { if (!empty($accessLogPath)) { $this->logFiles[self::LOGTYPE_ACCESS]['path'] = $accessLogPath; } if (!empty($requestLogPath)) { $this->logFiles[self::LOGTYPE_REQUEST]['path'] = $requestLogPath; } if (!empty($errorLogPath)) { $this->logFiles[self::LOGTYPE_ERROR]['path'] = $errorLogPath; } if (!empty($debugLogPath)) { $this->logFiles[self::LOGTYPE_DEBUG]['path'] = $debugLogPath; } }
[ "public", "function", "setLogFilePaths", "(", "$", "accessLogPath", ",", "$", "requestLogPath", ",", "$", "errorLogPath", ",", "$", "debugLogPath", ")", "{", "if", "(", "!", "empty", "(", "$", "accessLogPath", ")", ")", "{", "$", "this", "->", "logFiles", ...
Sets the paths to the log files. @param string $accessLogPath @param string $requestLogPath @param string $errorLogPath @param string $debugLogPath
[ "Sets", "the", "paths", "to", "the", "log", "files", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/logging/strategy/DefaultLogging.php#L196-L213
shopgate/cart-integration-sdk
src/helper/logging/strategy/DefaultLogging.php
Shopgate_Helper_Logging_Strategy_DefaultLogging.openLogFileHandle
protected function openLogFileHandle($type) { // don't open file handle if already open if (!empty($this->logFiles[$type]['handle'])) { return true; } // set the file handle $this->logFiles[$type]['handle'] = @fopen($this->logFiles[$type]['path'], $this->logFiles[$type]['mode']); // if log files are not writeable continue silently to the next handle // TODO: This seems a bit too silent... How could we get notice of the error? if ($this->logFiles[$type]['handle'] === false) { return false; } return true; }
php
protected function openLogFileHandle($type) { // don't open file handle if already open if (!empty($this->logFiles[$type]['handle'])) { return true; } // set the file handle $this->logFiles[$type]['handle'] = @fopen($this->logFiles[$type]['path'], $this->logFiles[$type]['mode']); // if log files are not writeable continue silently to the next handle // TODO: This seems a bit too silent... How could we get notice of the error? if ($this->logFiles[$type]['handle'] === false) { return false; } return true; }
[ "protected", "function", "openLogFileHandle", "(", "$", "type", ")", "{", "// don't open file handle if already open", "if", "(", "!", "empty", "(", "$", "this", "->", "logFiles", "[", "$", "type", "]", "[", "'handle'", "]", ")", ")", "{", "return", "true", ...
Opens log file handles for the requested log type if necessary. Already opened file handles will not be opened again. @param string $type The log type, that would be one of the self::LOGTYPE_* constants. @return bool true if opening succeeds or the handle is already open; false on error.
[ "Opens", "log", "file", "handles", "for", "the", "requested", "log", "type", "if", "necessary", "." ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/logging/strategy/DefaultLogging.php#L224-L241
makinacorpus/drupal-ucms
ucms_site/src/Form/WebmasterChangeRole.php
WebmasterChangeRole.buildForm
public function buildForm(array $form, FormStateInterface $formState, Site $site = null, AccountInterface $user = null) { if (null === $site || null === $user) { return []; } $formState->setTemporaryValue('site', $site); $formState->setTemporaryValue('user', $user); $form['#form_horizontal'] = true; $roles = $this->siteManager->getAccess()->collectRelativeRoles($site); $userRelativeRole = $this->siteManager->getAccess()->getUserRole($user, $site); $form['role'] = [ '#type' => 'radios', '#title' => $this->t("Role"), '#options' => $roles, '#default_value' => $userRelativeRole, '#required' => true, ]; $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t("Validate"), ]; return $form; }
php
public function buildForm(array $form, FormStateInterface $formState, Site $site = null, AccountInterface $user = null) { if (null === $site || null === $user) { return []; } $formState->setTemporaryValue('site', $site); $formState->setTemporaryValue('user', $user); $form['#form_horizontal'] = true; $roles = $this->siteManager->getAccess()->collectRelativeRoles($site); $userRelativeRole = $this->siteManager->getAccess()->getUserRole($user, $site); $form['role'] = [ '#type' => 'radios', '#title' => $this->t("Role"), '#options' => $roles, '#default_value' => $userRelativeRole, '#required' => true, ]; $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t("Validate"), ]; return $form; }
[ "public", "function", "buildForm", "(", "array", "$", "form", ",", "FormStateInterface", "$", "formState", ",", "Site", "$", "site", "=", "null", ",", "AccountInterface", "$", "user", "=", "null", ")", "{", "if", "(", "null", "===", "$", "site", "||", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Form/WebmasterChangeRole.php#L58-L87
makinacorpus/drupal-ucms
ucms_site/src/Form/WebmasterChangeRole.php
WebmasterChangeRole.submitForm
public function submitForm(array &$form, FormStateInterface $formState) { /* @var Site $site */ $site = $formState->getTemporaryValue('site'); $user = $formState->getTemporaryValue('user'); $role = $formState->getValue('role'); $oldAccess = $this->siteManager->getAccess()->getUserRole($user, $site); $this->siteManager->getAccess()->mergeUsersWithRole($site, $user->id(), $role); drupal_set_message($this->t("!name is from now on %role.", [ '!name' => $user->getDisplayName(), '%role' => $this->siteManager->getAccess()->getRelativeRoleName($role), ])); $event = new SiteEvent($site, $this->currentUser()->id(), [ 'webmaster_id' => $user->id(), 'previous_role' => $oldAccess->getRole(), ]); $this->dispatcher->dispatch(SiteEvents::EVENT_WEBMASTER_CHANGE_ROLE, $event); }
php
public function submitForm(array &$form, FormStateInterface $formState) { /* @var Site $site */ $site = $formState->getTemporaryValue('site'); $user = $formState->getTemporaryValue('user'); $role = $formState->getValue('role'); $oldAccess = $this->siteManager->getAccess()->getUserRole($user, $site); $this->siteManager->getAccess()->mergeUsersWithRole($site, $user->id(), $role); drupal_set_message($this->t("!name is from now on %role.", [ '!name' => $user->getDisplayName(), '%role' => $this->siteManager->getAccess()->getRelativeRoleName($role), ])); $event = new SiteEvent($site, $this->currentUser()->id(), [ 'webmaster_id' => $user->id(), 'previous_role' => $oldAccess->getRole(), ]); $this->dispatcher->dispatch(SiteEvents::EVENT_WEBMASTER_CHANGE_ROLE, $event); }
[ "public", "function", "submitForm", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "formState", ")", "{", "/* @var Site $site */", "$", "site", "=", "$", "formState", "->", "getTemporaryValue", "(", "'site'", ")", ";", "$", "user", "=", "$",...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Form/WebmasterChangeRole.php#L92-L112
qloog/yaf-library
src/Queue/Subscriber.php
Subscriber.dispatch
protected function dispatch($event) { if (empty($event['type'])) { $this->logger->warning('wrong event type, maybe something wrong'); return false; } if (strpos($event['type'], ':') === false) { $event['type'] .= ':handleEvent'; } try { $this->eventsManager->fire($event['type'], $this, $event['data']); } catch (\Exception $e) { $this->logger->warning('dispatch event exception while subscribing event queue', ['code' => $e->getCode(), 'msg' => $e->getMessage(), 'trace' => $e->getTrace()]); } finally { $this->mq->confirm($event, Queue::CONFIRM_SUCC); } return true; }
php
protected function dispatch($event) { if (empty($event['type'])) { $this->logger->warning('wrong event type, maybe something wrong'); return false; } if (strpos($event['type'], ':') === false) { $event['type'] .= ':handleEvent'; } try { $this->eventsManager->fire($event['type'], $this, $event['data']); } catch (\Exception $e) { $this->logger->warning('dispatch event exception while subscribing event queue', ['code' => $e->getCode(), 'msg' => $e->getMessage(), 'trace' => $e->getTrace()]); } finally { $this->mq->confirm($event, Queue::CONFIRM_SUCC); } return true; }
[ "protected", "function", "dispatch", "(", "$", "event", ")", "{", "if", "(", "empty", "(", "$", "event", "[", "'type'", "]", ")", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "'wrong event type, maybe something wrong'", ")", ";", "return", ...
分发事件 @param array $event [ 'id' => 'a random id which should be unique', 'timestamp' => 1468234243, 'type' => '\Some\Class or service name in container or someEntity:someEventOccurred', 'data' => ['k1' => 'v1' , 'k2' => 'v2', ...] ] @return bool
[ "分发事件" ]
train
https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Queue/Subscriber.php#L51-L71
isfonzar/sentiment-thermometer
src/Providers/SocialNetwork.php
SocialNetwork.get
public function get($keyword) { $response = []; if (!empty($this->twitterProvider)) { $results = $this->twitterProvider->getByKeyword($keyword); $response = array_merge($response, $results); } return $response; }
php
public function get($keyword) { $response = []; if (!empty($this->twitterProvider)) { $results = $this->twitterProvider->getByKeyword($keyword); $response = array_merge($response, $results); } return $response; }
[ "public", "function", "get", "(", "$", "keyword", ")", "{", "$", "response", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "twitterProvider", ")", ")", "{", "$", "results", "=", "$", "this", "->", "twitterProvider", "->", "ge...
@param $keyword @return array
[ "@param", "$keyword" ]
train
https://github.com/isfonzar/sentiment-thermometer/blob/457bf2b0b1e6bd287b069f32f8decb77dc5d59fc/src/Providers/SocialNetwork.php#L35-L47
runcmf/runbb
src/RunBB/Middleware/Csrf.php
Csrf.generateNewToken
public function generateNewToken(ServerRequestInterface $request) { $pair = $this->generateToken(); $request = $request->withAttribute($this->prefix . '_name', $pair[$this->prefix . '_name']) ->withAttribute($this->prefix . '_value', $pair[$this->prefix . '_value']); View::setPageInfo([ $this->prefix . '_name' => $pair[$this->prefix . '_name'], $this->prefix . '_value' => $pair[$this->prefix . '_value'] ]); return $request; }
php
public function generateNewToken(ServerRequestInterface $request) { $pair = $this->generateToken(); $request = $request->withAttribute($this->prefix . '_name', $pair[$this->prefix . '_name']) ->withAttribute($this->prefix . '_value', $pair[$this->prefix . '_value']); View::setPageInfo([ $this->prefix . '_name' => $pair[$this->prefix . '_name'], $this->prefix . '_value' => $pair[$this->prefix . '_value'] ]); return $request; }
[ "public", "function", "generateNewToken", "(", "ServerRequestInterface", "$", "request", ")", "{", "$", "pair", "=", "$", "this", "->", "generateToken", "(", ")", ";", "$", "request", "=", "$", "request", "->", "withAttribute", "(", "$", "this", "->", "pre...
Generates a new CSRF token and attaches it to the Request Object @param ServerRequestInterface $request PSR7 response object. @return ServerRequestInterface PSR7 response object.
[ "Generates", "a", "new", "CSRF", "token", "and", "attaches", "it", "to", "the", "Request", "Object" ]
train
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Middleware/Csrf.php#L191-L205
runcmf/runbb
src/RunBB/Middleware/Csrf.php
Csrf.validateToken
protected function validateToken($name, $value) { $token = $this->getFromStorage($name); if (function_exists('hash_equals')) { $result = ($token !== false && hash_equals($token, $value)); } else { $result = ($token !== false && $token === $value); } $this->removeFromStorage($name); return $result; }
php
protected function validateToken($name, $value) { $token = $this->getFromStorage($name); if (function_exists('hash_equals')) { $result = ($token !== false && hash_equals($token, $value)); } else { $result = ($token !== false && $token === $value); } $this->removeFromStorage($name); return $result; }
[ "protected", "function", "validateToken", "(", "$", "name", ",", "$", "value", ")", "{", "$", "token", "=", "$", "this", "->", "getFromStorage", "(", "$", "name", ")", ";", "if", "(", "function_exists", "(", "'hash_equals'", ")", ")", "{", "$", "result...
Validate CSRF token from current request against token value stored in $_SESSION @param string $name CSRF name @param string $value CSRF token value @return bool
[ "Validate", "CSRF", "token", "from", "current", "request", "against", "token", "value", "stored", "in", "$_SESSION" ]
train
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Middleware/Csrf.php#L216-L227
runcmf/runbb
src/RunBB/Middleware/Csrf.php
Csrf.getFailureCallable
public function getFailureCallable() { if (is_null($this->failureCallable)) { $this->failureCallable = function (ServerRequestInterface $request, ResponseInterface $response, $next) { throw new RunBBException('Failed CSRF check!', 500); }; } return $this->failureCallable; }
php
public function getFailureCallable() { if (is_null($this->failureCallable)) { $this->failureCallable = function (ServerRequestInterface $request, ResponseInterface $response, $next) { throw new RunBBException('Failed CSRF check!', 500); }; } return $this->failureCallable; }
[ "public", "function", "getFailureCallable", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "failureCallable", ")", ")", "{", "$", "this", "->", "failureCallable", "=", "function", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInter...
Getter for failureCallable @return callable|\Closure
[ "Getter", "for", "failureCallable" ]
train
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Middleware/Csrf.php#L316-L324
mosbth/Anax-MVC
src/Response/CResponseBasic.php
CResponseBasic.redirect
public function redirect($url) { $this->checkIfHeadersAlreadySent(); $url = $this->di->get("url")->create($url); header('Location: ' . $url); exit(); }
php
public function redirect($url) { $this->checkIfHeadersAlreadySent(); $url = $this->di->get("url")->create($url); header('Location: ' . $url); exit(); }
[ "public", "function", "redirect", "(", "$", "url", ")", "{", "$", "this", "->", "checkIfHeadersAlreadySent", "(", ")", ";", "$", "url", "=", "$", "this", "->", "di", "->", "get", "(", "\"url\"", ")", "->", "create", "(", "$", "url", ")", ";", "head...
Redirect to another page. @param string $url to redirect to @return void
[ "Redirect", "to", "another", "page", "." ]
train
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/Response/CResponseBasic.php#L97-L103
layerhq/layer-identity-token-php
src/Layer/LayerIdentityTokenProvider.php
LayerIdentityTokenProvider._checkLayerConfig
private function _checkLayerConfig() { $errorString = array(); if ($this->_providerID == '') { array_push($errorString, 'LAYER_PROVIDER_ID'); } if ($this->_keyID == '') { array_push($errorString, 'LAYER_PRIVATE_KEY_ID'); } if ($this->_privateKey == '') { array_push($errorString, 'LAYER_PRIVATE_KEY'); } if (count($errorString) > 0) { $joined = implode(',', $errorString); trigger_error("$joined not configured. See README.md", E_USER_ERROR); } }
php
private function _checkLayerConfig() { $errorString = array(); if ($this->_providerID == '') { array_push($errorString, 'LAYER_PROVIDER_ID'); } if ($this->_keyID == '') { array_push($errorString, 'LAYER_PRIVATE_KEY_ID'); } if ($this->_privateKey == '') { array_push($errorString, 'LAYER_PRIVATE_KEY'); } if (count($errorString) > 0) { $joined = implode(',', $errorString); trigger_error("$joined not configured. See README.md", E_USER_ERROR); } }
[ "private", "function", "_checkLayerConfig", "(", ")", "{", "$", "errorString", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "_providerID", "==", "''", ")", "{", "array_push", "(", "$", "errorString", ",", "'LAYER_PROVIDER_ID'", ")", ";", "}...
Checks if all the proper config has been prvided.
[ "Checks", "if", "all", "the", "proper", "config", "has", "been", "prvided", "." ]
train
https://github.com/layerhq/layer-identity-token-php/blob/0bad3f751f1c9a7b6582f902fcd425281f5501ae/src/Layer/LayerIdentityTokenProvider.php#L78-L97
makinacorpus/drupal-ucms
ucms_contrib/src/NodeAccess/NodeAccessEventSubscriber.php
NodeAccessEventSubscriber.onNodeAccess
public function onNodeAccess(NodeAccessEvent $event) { $node = $event->getNode(); $account = $event->getAccount(); $op = $event->getOperation(); $access = $this->siteManager->getAccess(); if ('create' === $op) { // Drupal gave a wrong input, this may happen if (!is_string($node) && !$node instanceof NodeInterface) { return $this->deny(); } $type = is_string($node) ? $node : $node->bundle(); // Locked types if (in_array($type, $this->typeHandler->getLockedTypes()) && !$account->hasPermission(Access::PERM_CONTENT_GOD)) { return $event->deny(); } if ($this->siteManager->hasContext()) { $site = $this->siteManager->getContext(); // Contributor can only create editorial content if ($access->userIsContributor($account, $site) && in_array($type, $this->typeHandler->getEditorialTypes())) { return $event->allow(); } // Webmasters can create anything if ($access->userIsWebmaster($account, $site) && in_array($type, $this->typeHandler->getAllTypes())) { return $event->allow(); } } else { // All user that may manage global content or manage group // content may create content outside of a site context, as // long as content is editorial (text and media) $canManage = $account->hasPermission(Access::PERM_CONTENT_MANAGE_GLOBAL) || $account->hasPermission(Access::PERM_CONTENT_MANAGE_CORPORATE) ; if ($canManage && in_array($type, $this->typeHandler->getEditorialTypes())) { return $event->allow(); } } } else if (Permission::DELETE === $op) { // Locked types if (in_array($node->bundle(), $this->typeHandler->getLockedTypes()) && !$account->hasPermission(Access::PERM_CONTENT_GOD)) { return $event->deny(); } } return $event->ignore(); }
php
public function onNodeAccess(NodeAccessEvent $event) { $node = $event->getNode(); $account = $event->getAccount(); $op = $event->getOperation(); $access = $this->siteManager->getAccess(); if ('create' === $op) { // Drupal gave a wrong input, this may happen if (!is_string($node) && !$node instanceof NodeInterface) { return $this->deny(); } $type = is_string($node) ? $node : $node->bundle(); // Locked types if (in_array($type, $this->typeHandler->getLockedTypes()) && !$account->hasPermission(Access::PERM_CONTENT_GOD)) { return $event->deny(); } if ($this->siteManager->hasContext()) { $site = $this->siteManager->getContext(); // Contributor can only create editorial content if ($access->userIsContributor($account, $site) && in_array($type, $this->typeHandler->getEditorialTypes())) { return $event->allow(); } // Webmasters can create anything if ($access->userIsWebmaster($account, $site) && in_array($type, $this->typeHandler->getAllTypes())) { return $event->allow(); } } else { // All user that may manage global content or manage group // content may create content outside of a site context, as // long as content is editorial (text and media) $canManage = $account->hasPermission(Access::PERM_CONTENT_MANAGE_GLOBAL) || $account->hasPermission(Access::PERM_CONTENT_MANAGE_CORPORATE) ; if ($canManage && in_array($type, $this->typeHandler->getEditorialTypes())) { return $event->allow(); } } } else if (Permission::DELETE === $op) { // Locked types if (in_array($node->bundle(), $this->typeHandler->getLockedTypes()) && !$account->hasPermission(Access::PERM_CONTENT_GOD)) { return $event->deny(); } } return $event->ignore(); }
[ "public", "function", "onNodeAccess", "(", "NodeAccessEvent", "$", "event", ")", "{", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "account", "=", "$", "event", "->", "getAccount", "(", ")", ";", "$", "op", "=", "$", "event", ...
Checks node access for content creation
[ "Checks", "node", "access", "for", "content", "creation" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/NodeAccess/NodeAccessEventSubscriber.php#L54-L108
makinacorpus/drupal-ucms
ucms_site/src/Form/SiteEdit.php
SiteEdit.buildForm
public function buildForm(array $form, FormStateInterface $form_state, Site $site = null) { $form['#form_horizontal'] = true; if (!$site) { $this->logger('form')->critical("There is not site to edit!"); return $form; } $form_state->setTemporaryValue('site', $site); $form['#site'] = $site; // This is used in *_form_alter() $form['title'] = [ '#title' => $this->t("Name"), '#type' => 'textfield', '#default_value' => $site->title, '#attributes' => ['placeholder' => $this->t("Martin's blog")], '#description' => $this->t("This will appear as the site's title on the frontoffice."), '#maxlength' => 255, '#required' => true, ]; $form['title_admin'] = [ '#title' => $this->t("Administrative title"), '#type' => 'textfield', '#default_value' => $site->title_admin, '#attributes' => ['placeholder' => $this->t("Martin's blog")], '#description' => $this->t("This will be the site's title for the backoffice."), '#maxlength' => 255, '#required' => true, ]; $form['http_host'] = [ '#title' => $this->t("Host name"), '#type' => 'textfield', '#field_prefix' => "http://", '#default_value' => $site->http_host, '#attributes' => ['placeholder' => "martin-blog.fr"], '#description' => $this->t("Type here the site URL"), '#element_validate' => ['::validateHttpHost'], '#required' => true, '#disabled' => !user_access(Access::PERM_SITE_GOD), ]; $form['allowed_protocols'] = [ '#title' => $this->t("Allowed protocols"), '#type' => 'select', '#options' => [ Site::ALLOWED_PROTOCOL_HTTPS => $this->t("Secure HTTPS only"), Site::ALLOWED_PROTOCOL_HTTP => $this->t("Unsecure HTTP only"), Site::ALLOWED_PROTOCOL_ALL => $this->t("Both secure HTTPS and unsecure HTTP"), Site::ALLOWED_PROTOCOL_PASS => $this->t("Let Drupal decide depending on the environment") ], '#default_value' => $site->allowed_protocols, '#description' => $this->t("This is a technical setting that depends on the web server configuration, the technical administrators might change it."), '#required' => !user_access(Access::PERM_SITE_GOD), ]; $form['replacement_of'] = [ '#title' => $this->t("Replaces"), '#type' => 'textarea', '#default_value' => $site->replacement_of, '#attributes' => ['placeholder' => "martin-blog.fr"], '#description' => $this->t("If the new site aims to replace an existing site, please copy/paste the site URI into this textarea, you may write more than one URI or any useful textual information."), '#required' => false, '#rows' => 2, ]; $form['http_redirects'] = [ '#title' => $this->t("Host name redirects"), '#type' => 'textarea', '#default_value' => $site->http_redirects, '#attributes' => ['placeholder' => "www.my-domain.com, example.fr"], '#description' => $this->t("List of domain names that should redirect on this site, this is, you may write more than one URI or any useful textual information."), '#required' => false, '#rows' => 2, ]; // WARNING I won't fetch the whole Drupal 8 API in the sf_dic module, // this has to stop at some point, so I'll use only Drupal 7 API to // handle themes, this will need porting. $themes = list_themes(); $options = []; foreach ($this->manager->getAllowedThemes() as $theme) { if (!isset($themes[$theme])) { $this->logger('default')->alert(sprintf("Theme '%s' does not exist but is referenced into sites possible selection", $theme)); continue; } if (!$themes[$theme]->status) { $this->logger('default')->alert(sprintf("Theme '%s' is not enabled but is referenced into sites possible selection", $theme)); continue; } if (isset($themes[$theme]) && file_exists($themes[$theme]->info['screenshot'])) { $text = theme('image', [ 'path' => $themes[$theme]->info['screenshot'], 'alt' => $this->t('Screenshot for !theme theme', ['!theme' => $themes[$theme]->info['name']]), 'attributes' => ['class' => ['screenshot']], ]); $text .= '<p>'.$themes[$theme]->info['name'].'</p>'; } else { $text = $themes[$theme]->info['name']; } $options[$theme] = $text; } $form['theme'] = [ '#title' => $this->t("Theme"), '#type' => 'radios', '#options' => $options, '#default_value' => $site->theme, '#description' => $this->t("This will be used for the whole site and cannot be changed once set") ]; $form['attributes']['#tree'] = true; $form['actions']['#type'] = 'actions'; $form['actions']['continue'] = [ '#type' => 'submit', '#value' => $this->t("Save"), ]; $form['actions']['cancel'] = [ '#markup' => l( $this->t("Cancel"), isset($_GET['destination']) ? $_GET['destination'] : 'admin/dashboard/site/' . $site->id, ['attributes' => ['class' => ['btn', 'btn-danger']]] ), ]; return $form; }
php
public function buildForm(array $form, FormStateInterface $form_state, Site $site = null) { $form['#form_horizontal'] = true; if (!$site) { $this->logger('form')->critical("There is not site to edit!"); return $form; } $form_state->setTemporaryValue('site', $site); $form['#site'] = $site; // This is used in *_form_alter() $form['title'] = [ '#title' => $this->t("Name"), '#type' => 'textfield', '#default_value' => $site->title, '#attributes' => ['placeholder' => $this->t("Martin's blog")], '#description' => $this->t("This will appear as the site's title on the frontoffice."), '#maxlength' => 255, '#required' => true, ]; $form['title_admin'] = [ '#title' => $this->t("Administrative title"), '#type' => 'textfield', '#default_value' => $site->title_admin, '#attributes' => ['placeholder' => $this->t("Martin's blog")], '#description' => $this->t("This will be the site's title for the backoffice."), '#maxlength' => 255, '#required' => true, ]; $form['http_host'] = [ '#title' => $this->t("Host name"), '#type' => 'textfield', '#field_prefix' => "http://", '#default_value' => $site->http_host, '#attributes' => ['placeholder' => "martin-blog.fr"], '#description' => $this->t("Type here the site URL"), '#element_validate' => ['::validateHttpHost'], '#required' => true, '#disabled' => !user_access(Access::PERM_SITE_GOD), ]; $form['allowed_protocols'] = [ '#title' => $this->t("Allowed protocols"), '#type' => 'select', '#options' => [ Site::ALLOWED_PROTOCOL_HTTPS => $this->t("Secure HTTPS only"), Site::ALLOWED_PROTOCOL_HTTP => $this->t("Unsecure HTTP only"), Site::ALLOWED_PROTOCOL_ALL => $this->t("Both secure HTTPS and unsecure HTTP"), Site::ALLOWED_PROTOCOL_PASS => $this->t("Let Drupal decide depending on the environment") ], '#default_value' => $site->allowed_protocols, '#description' => $this->t("This is a technical setting that depends on the web server configuration, the technical administrators might change it."), '#required' => !user_access(Access::PERM_SITE_GOD), ]; $form['replacement_of'] = [ '#title' => $this->t("Replaces"), '#type' => 'textarea', '#default_value' => $site->replacement_of, '#attributes' => ['placeholder' => "martin-blog.fr"], '#description' => $this->t("If the new site aims to replace an existing site, please copy/paste the site URI into this textarea, you may write more than one URI or any useful textual information."), '#required' => false, '#rows' => 2, ]; $form['http_redirects'] = [ '#title' => $this->t("Host name redirects"), '#type' => 'textarea', '#default_value' => $site->http_redirects, '#attributes' => ['placeholder' => "www.my-domain.com, example.fr"], '#description' => $this->t("List of domain names that should redirect on this site, this is, you may write more than one URI or any useful textual information."), '#required' => false, '#rows' => 2, ]; // WARNING I won't fetch the whole Drupal 8 API in the sf_dic module, // this has to stop at some point, so I'll use only Drupal 7 API to // handle themes, this will need porting. $themes = list_themes(); $options = []; foreach ($this->manager->getAllowedThemes() as $theme) { if (!isset($themes[$theme])) { $this->logger('default')->alert(sprintf("Theme '%s' does not exist but is referenced into sites possible selection", $theme)); continue; } if (!$themes[$theme]->status) { $this->logger('default')->alert(sprintf("Theme '%s' is not enabled but is referenced into sites possible selection", $theme)); continue; } if (isset($themes[$theme]) && file_exists($themes[$theme]->info['screenshot'])) { $text = theme('image', [ 'path' => $themes[$theme]->info['screenshot'], 'alt' => $this->t('Screenshot for !theme theme', ['!theme' => $themes[$theme]->info['name']]), 'attributes' => ['class' => ['screenshot']], ]); $text .= '<p>'.$themes[$theme]->info['name'].'</p>'; } else { $text = $themes[$theme]->info['name']; } $options[$theme] = $text; } $form['theme'] = [ '#title' => $this->t("Theme"), '#type' => 'radios', '#options' => $options, '#default_value' => $site->theme, '#description' => $this->t("This will be used for the whole site and cannot be changed once set") ]; $form['attributes']['#tree'] = true; $form['actions']['#type'] = 'actions'; $form['actions']['continue'] = [ '#type' => 'submit', '#value' => $this->t("Save"), ]; $form['actions']['cancel'] = [ '#markup' => l( $this->t("Cancel"), isset($_GET['destination']) ? $_GET['destination'] : 'admin/dashboard/site/' . $site->id, ['attributes' => ['class' => ['btn', 'btn-danger']]] ), ]; return $form; }
[ "public", "function", "buildForm", "(", "array", "$", "form", ",", "FormStateInterface", "$", "form_state", ",", "Site", "$", "site", "=", "null", ")", "{", "$", "form", "[", "'#form_horizontal'", "]", "=", "true", ";", "if", "(", "!", "$", "site", ")"...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Form/SiteEdit.php#L57-L190
makinacorpus/drupal-ucms
ucms_site/src/Form/SiteEdit.php
SiteEdit.submitForm
public function submitForm(array &$form, FormStateInterface $form_state) { $site = &$form_state->getTemporaryValue('site'); $values = &$form_state->getValues(); /** @var $site Site */ $site->title = $values['title']; $site->title_admin = $values['title_admin']; $site->http_redirects = $values['http_redirects']; $site->replacement_of = $values['replacement_of']; $site->http_host = $values['http_host']; $site->allowed_protocols = $values['allowed_protocols']; $site->theme = $values['theme']; $attributes = $form_state->getValue('attributes', []); foreach ($attributes as $name => $attribute) { $site->setAttribute($name, $attribute); } $this->manager->getStorage()->save($site); drupal_set_message($this->t("Site modifications have been saved")); $this->dispatcher->dispatch('site:update', new SiteEvent($site, $this->currentUser()->uid)); $form_state->setRedirect('admin/dashboard/site/' . $site->id); }
php
public function submitForm(array &$form, FormStateInterface $form_state) { $site = &$form_state->getTemporaryValue('site'); $values = &$form_state->getValues(); /** @var $site Site */ $site->title = $values['title']; $site->title_admin = $values['title_admin']; $site->http_redirects = $values['http_redirects']; $site->replacement_of = $values['replacement_of']; $site->http_host = $values['http_host']; $site->allowed_protocols = $values['allowed_protocols']; $site->theme = $values['theme']; $attributes = $form_state->getValue('attributes', []); foreach ($attributes as $name => $attribute) { $site->setAttribute($name, $attribute); } $this->manager->getStorage()->save($site); drupal_set_message($this->t("Site modifications have been saved")); $this->dispatcher->dispatch('site:update', new SiteEvent($site, $this->currentUser()->uid)); $form_state->setRedirect('admin/dashboard/site/' . $site->id); }
[ "public", "function", "submitForm", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "site", "=", "&", "$", "form_state", "->", "getTemporaryValue", "(", "'site'", ")", ";", "$", "values", "=", "&", "$", "form_...
Step B form submit
[ "Step", "B", "form", "submit" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Form/SiteEdit.php#L195-L219
makinacorpus/drupal-ucms
ucms_site/src/Form/SiteEdit.php
SiteEdit.validateHttpHost
public function validateHttpHost(&$element, FormStateInterface $form_state) { $value = $form_state->getValue($element['#parents']); if (empty($value)) { $form_state->setError($element, $this->t("Host name cannot be empty")); return; } $existing = $this->manager->getStorage()->findByHostname($value); if ($existing && $existing->getId() != $form_state->getTemporaryValue('site')->getId()) { $form_state->setError($element, $this->t("Host name already exists")); } // Validate host name format $regex = '@^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$@i'; if (!preg_match($regex, $value)) { $form_state->setError($element, $this->t("Host name contains invalid characters or has a wrong format")); } }
php
public function validateHttpHost(&$element, FormStateInterface $form_state) { $value = $form_state->getValue($element['#parents']); if (empty($value)) { $form_state->setError($element, $this->t("Host name cannot be empty")); return; } $existing = $this->manager->getStorage()->findByHostname($value); if ($existing && $existing->getId() != $form_state->getTemporaryValue('site')->getId()) { $form_state->setError($element, $this->t("Host name already exists")); } // Validate host name format $regex = '@^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$@i'; if (!preg_match($regex, $value)) { $form_state->setError($element, $this->t("Host name contains invalid characters or has a wrong format")); } }
[ "public", "function", "validateHttpHost", "(", "&", "$", "element", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "value", "=", "$", "form_state", "->", "getValue", "(", "$", "element", "[", "'#parents'", "]", ")", ";", "if", "(", "empty", ...
Validate HTTP host (must be unique and valid) @param $element @param \Drupal\Core\Form\FormStateInterface $form_state
[ "Validate", "HTTP", "host", "(", "must", "be", "unique", "and", "valid", ")" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Form/SiteEdit.php#L227-L247
makinacorpus/drupal-ucms
ucms_search/src/Lucene/RangeQuery.php
RangeQuery.setRange
public function setRange($start, $stop) { $this->start = $start; $this->stop = $stop; return $this; }
php
public function setRange($start, $stop) { $this->start = $start; $this->stop = $stop; return $this; }
[ "public", "function", "setRange", "(", "$", "start", ",", "$", "stop", ")", "{", "$", "this", "->", "start", "=", "$", "start", ";", "$", "this", "->", "stop", "=", "$", "stop", ";", "return", "$", "this", ";", "}" ]
Construct a range statement If you build the object with both $start and $stop set to NULL, this statement won't been built at all in the final query. We can, but we won't send [* TO *] useless range. @param null|mixed $start @param null|mixed $stop @return RangeQuery
[ "Construct", "a", "range", "statement" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Lucene/RangeQuery.php#L53-L59
makinacorpus/drupal-ucms
ucms_search/src/Lucene/RangeQuery.php
RangeQuery.escapeElement
protected function escapeElement($value) { if (empty($value)) { $element = '*'; } else { $element = $this->renderElement($value); } return self::escapeToken($element); }
php
protected function escapeElement($value) { if (empty($value)) { $element = '*'; } else { $element = $this->renderElement($value); } return self::escapeToken($element); }
[ "protected", "function", "escapeElement", "(", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "$", "element", "=", "'*'", ";", "}", "else", "{", "$", "element", "=", "$", "this", "->", "renderElement", "(", "$", "valu...
Render range element Overriding classes must implement this function in order to escape values Replace the element by '*' wildcard if empty @param string $value @return string
[ "Render", "range", "element" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Lucene/RangeQuery.php#L86-L95
makinacorpus/drupal-ucms
ucms_search/src/Lucene/RangeQuery.php
RangeQuery.toRawString
protected function toRawString() { if (empty($this->start) && empty($this->stop)) { return ''; } if ($this->inclusive) { return '[' . $this->escapeElement($this->start) . ' TO ' . $this->escapeElement($this->stop) . ']'; } else { return '{' . $this->escapeElement($this->start) . ' TO ' . $this->escapeElement($this->stop) . '}'; } }
php
protected function toRawString() { if (empty($this->start) && empty($this->stop)) { return ''; } if ($this->inclusive) { return '[' . $this->escapeElement($this->start) . ' TO ' . $this->escapeElement($this->stop) . ']'; } else { return '{' . $this->escapeElement($this->start) . ' TO ' . $this->escapeElement($this->stop) . '}'; } }
[ "protected", "function", "toRawString", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "start", ")", "&&", "empty", "(", "$", "this", "->", "stop", ")", ")", "{", "return", "''", ";", "}", "if", "(", "$", "this", "->", "inclusive", ")...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Lucene/RangeQuery.php#L100-L111
isfonzar/sentiment-thermometer
src/Providers/DataModels/SentimentResponse.php
SentimentResponse.divideAllFields
public function divideAllFields($divisor) { $this->positive = $this->positive / $divisor; $this->negative = $this->negative / $divisor; $this->neutral = $this->neutral / $divisor; return $this; }
php
public function divideAllFields($divisor) { $this->positive = $this->positive / $divisor; $this->negative = $this->negative / $divisor; $this->neutral = $this->neutral / $divisor; return $this; }
[ "public", "function", "divideAllFields", "(", "$", "divisor", ")", "{", "$", "this", "->", "positive", "=", "$", "this", "->", "positive", "/", "$", "divisor", ";", "$", "this", "->", "negative", "=", "$", "this", "->", "negative", "/", "$", "divisor",...
@param int $divisor @return SentimentResponse
[ "@param", "int", "$divisor" ]
train
https://github.com/isfonzar/sentiment-thermometer/blob/457bf2b0b1e6bd287b069f32f8decb77dc5d59fc/src/Providers/DataModels/SentimentResponse.php#L63-L70
h4cc/StackLogger
src/Logger/ContainerBuilder.php
ContainerBuilder.process
public function process(Pimple $container, array $options) { $container['logger'] = $container->share( function () { return new NullLogger(); } ); $container['log_level'] = LogLevel::INFO; $container['log_sub_request'] = false; foreach ($options as $name => $value) { $container[$name] = $value; } return $container; }
php
public function process(Pimple $container, array $options) { $container['logger'] = $container->share( function () { return new NullLogger(); } ); $container['log_level'] = LogLevel::INFO; $container['log_sub_request'] = false; foreach ($options as $name => $value) { $container[$name] = $value; } return $container; }
[ "public", "function", "process", "(", "Pimple", "$", "container", ",", "array", "$", "options", ")", "{", "$", "container", "[", "'logger'", "]", "=", "$", "container", "->", "share", "(", "function", "(", ")", "{", "return", "new", "NullLogger", "(", ...
Adds services and parameters to given container. ALso applies given options. @param Pimple $container @param array $options @return Pimple
[ "Adds", "services", "and", "parameters", "to", "given", "container", ".", "ALso", "applies", "given", "options", "." ]
train
https://github.com/h4cc/StackLogger/blob/1bdbb3e7d157aa9069ace90267c249f43dc02b77/src/Logger/ContainerBuilder.php#L30-L47
noherczeg/breadcrumb
src/Noherczeg/Breadcrumb/Config.php
Config.value
public function value($key = null) { if (!is_string($key)) { throw new \InvalidArgumentException("Invalid argument provided, string required!"); } elseif(method_exists('\Illuminate\Config\Repository', 'get') && \Config::get('breadcrumb::' . $key, false) !== false) { return \Config::get('breadcrumb::' . $key, false); } elseif (!array_key_exists($key, $this->configs)) { throw new \OutOfRangeException("There is no " . $key . " key in the Configurations!"); } else { return $this->configs[$key]; } }
php
public function value($key = null) { if (!is_string($key)) { throw new \InvalidArgumentException("Invalid argument provided, string required!"); } elseif(method_exists('\Illuminate\Config\Repository', 'get') && \Config::get('breadcrumb::' . $key, false) !== false) { return \Config::get('breadcrumb::' . $key, false); } elseif (!array_key_exists($key, $this->configs)) { throw new \OutOfRangeException("There is no " . $key . " key in the Configurations!"); } else { return $this->configs[$key]; } }
[ "public", "function", "value", "(", "$", "key", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid argument provided, string required!\"", ")", ";", "}", "else...
value: Returns the value of the requested key. @param String $key Requested value's key @return String @throws \InvalidArgumentException @throws \OutOfRangeException
[ "value", ":", "Returns", "the", "value", "of", "the", "requested", "key", "." ]
train
https://github.com/noherczeg/breadcrumb/blob/d46ad3b58fbc6fa118ccad57e42e95214a0416c8/src/Noherczeg/Breadcrumb/Config.php#L42-L53
makinacorpus/drupal-ucms
ucms_user/src/Form/UserSetPassword.php
UserSetPassword.buildForm
public function buildForm(array $form, FormStateInterface $form_state, $token = null) { if ($token === null) { return []; } /* @var Token $token */ $token = $this->tokenManager->loadToken($token); if ($token === null) { drupal_set_message( $this->t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'), 'error'); return []; } $currentUser = $this->currentUser(); $userStorage = $this->entityManager->getStorage('user'); if ($currentUser->id()) { // The existing user is already logged in. if ($currentUser->id() == $token->uid) { drupal_set_message($this->t('You are logged in as %user. <a href="!user_edit">Change your password.</a>', [ '%user' => $currentUser->getAccountName(), '!user_edit' => url('user/password'), ])); } // A different user is already logged in on the computer. else { /* @var UserInterface $user */ $tokenUser = $userStorage->load($token->uid); drupal_set_message($this->t('Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please <a href="!logout">logout</a> and try using the link again.', [ '%other_user' => $currentUser->getAccountName(), '%resetting_user' => $tokenUser->getAccountName(), '!logout' => url('user/logout'), ]), 'warning'); } drupal_goto(); } else { /* @var UserInterface $user */ $user = $userStorage->load($token->uid); if ($user->isBlocked() && $user->getLastLoginTime() > 0) { drupal_access_denied(); drupal_exit(); } if ($token->isValid()) { $form_state->setTemporaryValue('token', $token); $form_state->setTemporaryValue('user', $user); $form['#form_horizontal'] = true; $form['password'] = [ '#type' => 'password_confirm', '#size' => 20, '#required' => true, '#description' => $this->t("!count characters at least. Mix letters, digits and special characters for a better password.", ['!count' => UCMS_USER_PWD_MIN_LENGTH]), ]; $form['actions'] = [ '#type' => 'actions', 'submit' => [ '#type' => 'submit', '#value' => $this->t('Save my password'), ], ]; } else { drupal_set_message( $this->t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'), 'error'); drupal_goto('user/password'); } } return $form; }
php
public function buildForm(array $form, FormStateInterface $form_state, $token = null) { if ($token === null) { return []; } /* @var Token $token */ $token = $this->tokenManager->loadToken($token); if ($token === null) { drupal_set_message( $this->t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'), 'error'); return []; } $currentUser = $this->currentUser(); $userStorage = $this->entityManager->getStorage('user'); if ($currentUser->id()) { // The existing user is already logged in. if ($currentUser->id() == $token->uid) { drupal_set_message($this->t('You are logged in as %user. <a href="!user_edit">Change your password.</a>', [ '%user' => $currentUser->getAccountName(), '!user_edit' => url('user/password'), ])); } // A different user is already logged in on the computer. else { /* @var UserInterface $user */ $tokenUser = $userStorage->load($token->uid); drupal_set_message($this->t('Another user (%other_user) is already logged into the site on this computer, but you tried to use a one-time link for user %resetting_user. Please <a href="!logout">logout</a> and try using the link again.', [ '%other_user' => $currentUser->getAccountName(), '%resetting_user' => $tokenUser->getAccountName(), '!logout' => url('user/logout'), ]), 'warning'); } drupal_goto(); } else { /* @var UserInterface $user */ $user = $userStorage->load($token->uid); if ($user->isBlocked() && $user->getLastLoginTime() > 0) { drupal_access_denied(); drupal_exit(); } if ($token->isValid()) { $form_state->setTemporaryValue('token', $token); $form_state->setTemporaryValue('user', $user); $form['#form_horizontal'] = true; $form['password'] = [ '#type' => 'password_confirm', '#size' => 20, '#required' => true, '#description' => $this->t("!count characters at least. Mix letters, digits and special characters for a better password.", ['!count' => UCMS_USER_PWD_MIN_LENGTH]), ]; $form['actions'] = [ '#type' => 'actions', 'submit' => [ '#type' => 'submit', '#value' => $this->t('Save my password'), ], ]; } else { drupal_set_message( $this->t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'), 'error'); drupal_goto('user/password'); } } return $form; }
[ "public", "function", "buildForm", "(", "array", "$", "form", ",", "FormStateInterface", "$", "form_state", ",", "$", "token", "=", "null", ")", "{", "if", "(", "$", "token", "===", "null", ")", "{", "return", "[", "]", ";", "}", "/* @var Token $token */...
{@inheritdoc} @param string $token
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/Form/UserSetPassword.php#L77-L154
makinacorpus/drupal-ucms
ucms_user/src/Form/UserSetPassword.php
UserSetPassword.validateForm
public function validateForm(array &$form, FormStateInterface $form_state) { $password = $form_state->getValue('password'); if (strlen($password) < UCMS_USER_PWD_MIN_LENGTH) { $form_state->setErrorByName('password', $this->t("Your password must contain at least !count characters.", ['!count' => UCMS_USER_PWD_MIN_LENGTH])); } /* @var UserInterface $user */ // $user = $form_state->getTemporaryValue('user'); // if (user_check_password($password, $user)) { // $form_state->setErrorByName('password', $this->t("Please choose a password different than the previous one.")); // } }
php
public function validateForm(array &$form, FormStateInterface $form_state) { $password = $form_state->getValue('password'); if (strlen($password) < UCMS_USER_PWD_MIN_LENGTH) { $form_state->setErrorByName('password', $this->t("Your password must contain at least !count characters.", ['!count' => UCMS_USER_PWD_MIN_LENGTH])); } /* @var UserInterface $user */ // $user = $form_state->getTemporaryValue('user'); // if (user_check_password($password, $user)) { // $form_state->setErrorByName('password', $this->t("Please choose a password different than the previous one.")); // } }
[ "public", "function", "validateForm", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "password", "=", "$", "form_state", "->", "getValue", "(", "'password'", ")", ";", "if", "(", "strlen", "(", "$", "password",...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/Form/UserSetPassword.php#L160-L173
makinacorpus/drupal-ucms
ucms_user/src/Form/UserSetPassword.php
UserSetPassword.submitForm
public function submitForm(array &$form, FormStateInterface $form_state) { require_once DRUPAL_ROOT . '/includes/password.inc'; /* @var Token $token */ $token = $form_state->getTemporaryValue('token'); /* @var UserInterface $user */ $user = $form_state->getTemporaryValue('user'); $user->pass = user_hash_password($form_state->getValue('password')); if ($user->getLastLoginTime() == 0) { $user->status = 1; } $saved = $this->entityManager->getStorage('user')->save($user); if ($saved) { $this->tokenManager->deleteToken($token); drupal_set_message($this->t("Your password has been recorded.")); $this->dispatcher->dispatch('user:set_password', new UserEvent($user->uid, $this->currentUser()->id())); } else { drupal_set_message($this->t("An error occured. Please try again."), 'error'); } $form_state->setRedirect('user/login'); }
php
public function submitForm(array &$form, FormStateInterface $form_state) { require_once DRUPAL_ROOT . '/includes/password.inc'; /* @var Token $token */ $token = $form_state->getTemporaryValue('token'); /* @var UserInterface $user */ $user = $form_state->getTemporaryValue('user'); $user->pass = user_hash_password($form_state->getValue('password')); if ($user->getLastLoginTime() == 0) { $user->status = 1; } $saved = $this->entityManager->getStorage('user')->save($user); if ($saved) { $this->tokenManager->deleteToken($token); drupal_set_message($this->t("Your password has been recorded.")); $this->dispatcher->dispatch('user:set_password', new UserEvent($user->uid, $this->currentUser()->id())); } else { drupal_set_message($this->t("An error occured. Please try again."), 'error'); } $form_state->setRedirect('user/login'); }
[ "public", "function", "submitForm", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "require_once", "DRUPAL_ROOT", ".", "'/includes/password.inc'", ";", "/* @var Token $token */", "$", "token", "=", "$", "form_state", "->", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/Form/UserSetPassword.php#L179-L205
umpirsky/list-generator
src/Umpirsky/ListGenerator/Exporter/HtmlExporter.php
HtmlExporter.exportHtml
protected function exportHtml(\DOMElement $element) { $body = $this->getDocument()->createElement('body'); $body->appendChild($element); $html = $this->getDocument()->getElementsByTagName('html')->item(0); $html->appendChild($this->getHead()); $html->appendChild($body); $html = $this->getDocument()->saveHTML(); $this->reset(); return $html; }
php
protected function exportHtml(\DOMElement $element) { $body = $this->getDocument()->createElement('body'); $body->appendChild($element); $html = $this->getDocument()->getElementsByTagName('html')->item(0); $html->appendChild($this->getHead()); $html->appendChild($body); $html = $this->getDocument()->saveHTML(); $this->reset(); return $html; }
[ "protected", "function", "exportHtml", "(", "\\", "DOMElement", "$", "element", ")", "{", "$", "body", "=", "$", "this", "->", "getDocument", "(", ")", "->", "createElement", "(", "'body'", ")", ";", "$", "body", "->", "appendChild", "(", "$", "element",...
Wraps DOM element to document and exports it as HTML string. @param \DOMElement $element @return string
[ "Wraps", "DOM", "element", "to", "document", "and", "exports", "it", "as", "HTML", "string", "." ]
train
https://github.com/umpirsky/list-generator/blob/103182faf6e48611901263a49e7a9ba33e7515b8/src/Umpirsky/ListGenerator/Exporter/HtmlExporter.php#L25-L37
umpirsky/list-generator
src/Umpirsky/ListGenerator/Exporter/HtmlExporter.php
HtmlExporter.getDocument
protected function getDocument() { if (null === $this->document) { $this->document = \DOMImplementation::createDocument( 'http://www.w3.org/1999/xhtml', 'html', \DOMImplementation::createDocumentType( 'html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd' ) ); } return $this->document; }
php
protected function getDocument() { if (null === $this->document) { $this->document = \DOMImplementation::createDocument( 'http://www.w3.org/1999/xhtml', 'html', \DOMImplementation::createDocumentType( 'html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd' ) ); } return $this->document; }
[ "protected", "function", "getDocument", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "document", ")", "{", "$", "this", "->", "document", "=", "\\", "DOMImplementation", "::", "createDocument", "(", "'http://www.w3.org/1999/xhtml'", ",", "'html'...
Creates HTML document. @return \DOMDocument
[ "Creates", "HTML", "document", "." ]
train
https://github.com/umpirsky/list-generator/blob/103182faf6e48611901263a49e7a9ba33e7515b8/src/Umpirsky/ListGenerator/Exporter/HtmlExporter.php#L44-L59
umpirsky/list-generator
src/Umpirsky/ListGenerator/Exporter/HtmlExporter.php
HtmlExporter.getHead
protected function getHead() { $head = $this->getDocument()->createElement('head'); $metahttp = $this->getDocument()->createElement('meta'); $metahttp->setAttribute('http-equiv', 'Content-Type'); $metahttp->setAttribute('content', 'text/html; charset=utf-8'); $head->appendChild($metahttp); $head->appendChild($this->getDocument()->createElement('title', 'Generated List')); foreach ($this->getStylesheets() as $href) { $stylesheet = $this->getDocument()->createElement('link'); $stylesheet->setAttribute('href', $href); $stylesheet->setAttribute('rel', 'stylesheet'); $stylesheet->setAttribute('type', 'text/css'); $head->appendChild($stylesheet); } return $head; }
php
protected function getHead() { $head = $this->getDocument()->createElement('head'); $metahttp = $this->getDocument()->createElement('meta'); $metahttp->setAttribute('http-equiv', 'Content-Type'); $metahttp->setAttribute('content', 'text/html; charset=utf-8'); $head->appendChild($metahttp); $head->appendChild($this->getDocument()->createElement('title', 'Generated List')); foreach ($this->getStylesheets() as $href) { $stylesheet = $this->getDocument()->createElement('link'); $stylesheet->setAttribute('href', $href); $stylesheet->setAttribute('rel', 'stylesheet'); $stylesheet->setAttribute('type', 'text/css'); $head->appendChild($stylesheet); } return $head; }
[ "protected", "function", "getHead", "(", ")", "{", "$", "head", "=", "$", "this", "->", "getDocument", "(", ")", "->", "createElement", "(", "'head'", ")", ";", "$", "metahttp", "=", "$", "this", "->", "getDocument", "(", ")", "->", "createElement", "(...
Creates HTML head. @return \DOMElement
[ "Creates", "HTML", "head", "." ]
train
https://github.com/umpirsky/list-generator/blob/103182faf6e48611901263a49e7a9ba33e7515b8/src/Umpirsky/ListGenerator/Exporter/HtmlExporter.php#L95-L113
makinacorpus/drupal-ucms
ucms_tree/src/EventDispatcher/SiteEventSubscriber.php
SiteEventSubscriber.onSiteInit
public function onSiteInit(SiteInitEvent $event) { $site = $event->getSite(); // Reset menus. $activeMenus = []; if ($this->treeManager) { $menuList = $this->treeManager->getMenuStorage()->loadWithConditions(['site_id' => $site->getId()]); if (empty($menuList)) { $menuList = $this->ensureSiteMenus($event->getSite()); } // @todo // pri: keeping this code in case it happens again, on my env // all menus have been droppped for an obscure reason... if (false && $menuList) { foreach ($menuList as $menu) { $activeMenus[] = $menu['name']; } } } $activeMenus[] = 'navigation'; $GLOBALS['conf']['menu_default_active_menus'] = $activeMenus; }
php
public function onSiteInit(SiteInitEvent $event) { $site = $event->getSite(); // Reset menus. $activeMenus = []; if ($this->treeManager) { $menuList = $this->treeManager->getMenuStorage()->loadWithConditions(['site_id' => $site->getId()]); if (empty($menuList)) { $menuList = $this->ensureSiteMenus($event->getSite()); } // @todo // pri: keeping this code in case it happens again, on my env // all menus have been droppped for an obscure reason... if (false && $menuList) { foreach ($menuList as $menu) { $activeMenus[] = $menu['name']; } } } $activeMenus[] = 'navigation'; $GLOBALS['conf']['menu_default_active_menus'] = $activeMenus; }
[ "public", "function", "onSiteInit", "(", "SiteInitEvent", "$", "event", ")", "{", "$", "site", "=", "$", "event", "->", "getSite", "(", ")", ";", "// Reset menus.", "$", "activeMenus", "=", "[", "]", ";", "if", "(", "$", "this", "->", "treeManager", ")...
On site context initialization.
[ "On", "site", "context", "initialization", "." ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/EventDispatcher/SiteEventSubscriber.php#L73-L98
makinacorpus/drupal-ucms
ucms_tree/src/EventDispatcher/SiteEventSubscriber.php
SiteEventSubscriber.onSiteClone
public function onSiteClone(SiteCloneEvent $event) { $source = $event->getTemplateSite(); $target = $event->getSite(); $this->ensureSiteMenus($source); $this->ensureSiteMenus($target); if ($this->treeManager && $this->allowedMenus) { foreach (array_keys($this->allowedMenus) as $prefix) { $sourceName = $prefix . '-' . $source->getId(); $targetName = $prefix . '-' . $target->getId(); $this->treeManager->cloneMenuIn($sourceName, $targetName); } } }
php
public function onSiteClone(SiteCloneEvent $event) { $source = $event->getTemplateSite(); $target = $event->getSite(); $this->ensureSiteMenus($source); $this->ensureSiteMenus($target); if ($this->treeManager && $this->allowedMenus) { foreach (array_keys($this->allowedMenus) as $prefix) { $sourceName = $prefix . '-' . $source->getId(); $targetName = $prefix . '-' . $target->getId(); $this->treeManager->cloneMenuIn($sourceName, $targetName); } } }
[ "public", "function", "onSiteClone", "(", "SiteCloneEvent", "$", "event", ")", "{", "$", "source", "=", "$", "event", "->", "getTemplateSite", "(", ")", ";", "$", "target", "=", "$", "event", "->", "getSite", "(", ")", ";", "$", "this", "->", "ensureSi...
On site cloning. @param SiteCloneEvent $event
[ "On", "site", "cloning", "." ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/EventDispatcher/SiteEventSubscriber.php#L115-L132
makinacorpus/drupal-ucms
ucms_tree/src/EventDispatcher/SiteEventSubscriber.php
SiteEventSubscriber.ensureSiteMenus
private function ensureSiteMenus(Site $site) { $ret = []; if ($this->treeManager && $this->allowedMenus) { $storage = $this->treeManager->getMenuStorage(); foreach ($this->allowedMenus as $prefix => $title) { $name = $prefix.'-'.$site->getId(); if (!$storage->exists($name)) { $ret[$name] = $storage->create($name, ['title' => $this->t($title), 'site_id' => $site->getId()]); } } } return $ret; }
php
private function ensureSiteMenus(Site $site) { $ret = []; if ($this->treeManager && $this->allowedMenus) { $storage = $this->treeManager->getMenuStorage(); foreach ($this->allowedMenus as $prefix => $title) { $name = $prefix.'-'.$site->getId(); if (!$storage->exists($name)) { $ret[$name] = $storage->create($name, ['title' => $this->t($title), 'site_id' => $site->getId()]); } } } return $ret; }
[ "private", "function", "ensureSiteMenus", "(", "Site", "$", "site", ")", "{", "$", "ret", "=", "[", "]", ";", "if", "(", "$", "this", "->", "treeManager", "&&", "$", "this", "->", "allowedMenus", ")", "{", "$", "storage", "=", "$", "this", "->", "t...
Create missing menus for site @param Site $site @return string[][] Newly created menus
[ "Create", "missing", "menus", "for", "site" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/EventDispatcher/SiteEventSubscriber.php#L142-L160
accompli/accompli
src/Deployment/Connection/ConnectionManager.php
ConnectionManager.registerConnectionAdapter
public function registerConnectionAdapter($connectionType, $connectionAdapterClass) { if (class_exists($connectionAdapterClass) && in_array(ConnectionAdapterInterface::class, class_implements($connectionAdapterClass))) { $this->connectionAdapters[$connectionType] = $connectionAdapterClass; } }
php
public function registerConnectionAdapter($connectionType, $connectionAdapterClass) { if (class_exists($connectionAdapterClass) && in_array(ConnectionAdapterInterface::class, class_implements($connectionAdapterClass))) { $this->connectionAdapters[$connectionType] = $connectionAdapterClass; } }
[ "public", "function", "registerConnectionAdapter", "(", "$", "connectionType", ",", "$", "connectionAdapterClass", ")", "{", "if", "(", "class_exists", "(", "$", "connectionAdapterClass", ")", "&&", "in_array", "(", "ConnectionAdapterInterface", "::", "class", ",", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Deployment/Connection/ConnectionManager.php#L33-L38
accompli/accompli
src/Deployment/Connection/ConnectionManager.php
ConnectionManager.getConnectionAdapter
public function getConnectionAdapter(Host $host) { if (isset($this->connectionAdapters[$host->getConnectionType()])) { $connectionIdentifier = spl_object_hash($host); if (isset($this->connections[$connectionIdentifier]) === false) { $connectionAdapterArguments = $host->getConnectionOptions(); $connectionAdapterArguments['hostname'] = $host->getHostname(); $this->connections[$connectionIdentifier] = ObjectFactory::getInstance()->newInstance($this->connectionAdapters[$host->getConnectionType()], $connectionAdapterArguments); } return $this->connections[$connectionIdentifier]; } }
php
public function getConnectionAdapter(Host $host) { if (isset($this->connectionAdapters[$host->getConnectionType()])) { $connectionIdentifier = spl_object_hash($host); if (isset($this->connections[$connectionIdentifier]) === false) { $connectionAdapterArguments = $host->getConnectionOptions(); $connectionAdapterArguments['hostname'] = $host->getHostname(); $this->connections[$connectionIdentifier] = ObjectFactory::getInstance()->newInstance($this->connectionAdapters[$host->getConnectionType()], $connectionAdapterArguments); } return $this->connections[$connectionIdentifier]; } }
[ "public", "function", "getConnectionAdapter", "(", "Host", "$", "host", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "connectionAdapters", "[", "$", "host", "->", "getConnectionType", "(", ")", "]", ")", ")", "{", "$", "connectionIdentifier", "=",...
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Deployment/Connection/ConnectionManager.php#L43-L57
accompli/accompli
src/Deployment/Connection/ConnectionManager.php
ConnectionManager.onCreateConnection
public function onCreateConnection(HostEvent $event) { $connectionAdapter = $this->getConnectionAdapter($event->getHost()); if ($connectionAdapter instanceof ConnectionAdapterInterface) { $event->getHost()->setConnection($connectionAdapter); } }
php
public function onCreateConnection(HostEvent $event) { $connectionAdapter = $this->getConnectionAdapter($event->getHost()); if ($connectionAdapter instanceof ConnectionAdapterInterface) { $event->getHost()->setConnection($connectionAdapter); } }
[ "public", "function", "onCreateConnection", "(", "HostEvent", "$", "event", ")", "{", "$", "connectionAdapter", "=", "$", "this", "->", "getConnectionAdapter", "(", "$", "event", "->", "getHost", "(", ")", ")", ";", "if", "(", "$", "connectionAdapter", "inst...
Sets a connection adapter on a Host when an 'accompli.create_connection' event is dispatched. @param HostEvent $event
[ "Sets", "a", "connection", "adapter", "on", "a", "Host", "when", "an", "accompli", ".", "create_connection", "event", "is", "dispatched", "." ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Deployment/Connection/ConnectionManager.php#L64-L70
accompli/accompli
src/EventDispatcher/Subscriber/GenerateReportSubscriber.php
GenerateReportSubscriber.onInstallCommandCompletedOutputReport
public function onInstallCommandCompletedOutputReport() { $report = new InstallReport($this->eventDataCollector, $this->dataCollectors); $report->generate($this->logger); }
php
public function onInstallCommandCompletedOutputReport() { $report = new InstallReport($this->eventDataCollector, $this->dataCollectors); $report->generate($this->logger); }
[ "public", "function", "onInstallCommandCompletedOutputReport", "(", ")", "{", "$", "report", "=", "new", "InstallReport", "(", "$", "this", "->", "eventDataCollector", ",", "$", "this", "->", "dataCollectors", ")", ";", "$", "report", "->", "generate", "(", "$...
Generates an installation report.
[ "Generates", "an", "installation", "report", "." ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/EventDispatcher/Subscriber/GenerateReportSubscriber.php#L73-L77
accompli/accompli
src/EventDispatcher/Subscriber/GenerateReportSubscriber.php
GenerateReportSubscriber.onDeployCommandCompletedOutputReport
public function onDeployCommandCompletedOutputReport() { $report = new DeployReport($this->eventDataCollector, $this->dataCollectors); $report->generate($this->logger); }
php
public function onDeployCommandCompletedOutputReport() { $report = new DeployReport($this->eventDataCollector, $this->dataCollectors); $report->generate($this->logger); }
[ "public", "function", "onDeployCommandCompletedOutputReport", "(", ")", "{", "$", "report", "=", "new", "DeployReport", "(", "$", "this", "->", "eventDataCollector", ",", "$", "this", "->", "dataCollectors", ")", ";", "$", "report", "->", "generate", "(", "$",...
Generates a deployment report.
[ "Generates", "a", "deployment", "report", "." ]
train
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/EventDispatcher/Subscriber/GenerateReportSubscriber.php#L82-L86
shopgate/cart-integration-sdk
src/models/catalog/Price.php
Shopgate_Model_Catalog_Price.addTierPriceGroup
public function addTierPriceGroup(Shopgate_Model_Catalog_TierPrice $tierPrice) { $tierPrices = $this->getTierPricesGroup(); array_push($tierPrices, $tierPrice); $this->setTierPricesGroup($tierPrices); }
php
public function addTierPriceGroup(Shopgate_Model_Catalog_TierPrice $tierPrice) { $tierPrices = $this->getTierPricesGroup(); array_push($tierPrices, $tierPrice); $this->setTierPricesGroup($tierPrices); }
[ "public", "function", "addTierPriceGroup", "(", "Shopgate_Model_Catalog_TierPrice", "$", "tierPrice", ")", "{", "$", "tierPrices", "=", "$", "this", "->", "getTierPricesGroup", "(", ")", ";", "array_push", "(", "$", "tierPrices", ",", "$", "tierPrice", ")", ";",...
add tier price @param Shopgate_Model_Catalog_TierPrice $tierPrice
[ "add", "tier", "price" ]
train
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Price.php#L121-L126
ARCANEDEV/Settings
src/Utilities/Arr.php
Arr.get
public static function get($array, $key, $default = null) { return is_array($key) ? static::getArray($array, $key, $default) : parent::get($array, $key, $default); }
php
public static function get($array, $key, $default = null) { return is_array($key) ? static::getArray($array, $key, $default) : parent::get($array, $key, $default); }
[ "public", "static", "function", "get", "(", "$", "array", ",", "$", "key", ",", "$", "default", "=", "null", ")", "{", "return", "is_array", "(", "$", "key", ")", "?", "static", "::", "getArray", "(", "$", "array", ",", "$", "key", ",", "$", "def...
Get an item from an array using "dot" notation. @param array $array @param array|string $key @param mixed $default @return mixed
[ "Get", "an", "item", "from", "an", "array", "using", "dot", "notation", "." ]
train
https://github.com/ARCANEDEV/Settings/blob/8e08dadc29d5a47c64099454696100babb356530/src/Utilities/Arr.php#L26-L31
makinacorpus/drupal-ucms
ucms_search/src/Aggs/TopHits.php
TopHits.buildQueryData
public function buildQueryData(Search $search, $query) { return [ $this->getAggregationName() => [ "terms" => [ "field" => $this->field, "size" => $this->size, ], "aggs" => [ $this->getAggregationBucketName() => [ "top_hits" => [ /*"sort" => [ // @todo Should we handle sort? default is score [ "created" => [ "order" => "desc", ], ], ],*/ "_source" => [ "include" => [ "title", // @todo this is arbitrary, should we do something else? ] ], "size" => $this->size, // @todo WTF size per bucket? ], ], ], ], ]; }
php
public function buildQueryData(Search $search, $query) { return [ $this->getAggregationName() => [ "terms" => [ "field" => $this->field, "size" => $this->size, ], "aggs" => [ $this->getAggregationBucketName() => [ "top_hits" => [ /*"sort" => [ // @todo Should we handle sort? default is score [ "created" => [ "order" => "desc", ], ], ],*/ "_source" => [ "include" => [ "title", // @todo this is arbitrary, should we do something else? ] ], "size" => $this->size, // @todo WTF size per bucket? ], ], ], ], ]; }
[ "public", "function", "buildQueryData", "(", "Search", "$", "search", ",", "$", "query", ")", "{", "return", "[", "$", "this", "->", "getAggregationName", "(", ")", "=>", "[", "\"terms\"", "=>", "[", "\"field\"", "=>", "$", "this", "->", "field", ",", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Aggs/TopHits.php#L107-L136