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_search/src/NodeIndexerChain.php | NodeIndexerChain.delete | public function delete(NodeInterface $node)
{
foreach ($this->chain as $indexer) {
$indexer->delete($node);
}
} | php | public function delete(NodeInterface $node)
{
foreach ($this->chain as $indexer) {
$indexer->delete($node);
}
} | [
"public",
"function",
"delete",
"(",
"NodeInterface",
"$",
"node",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"chain",
"as",
"$",
"indexer",
")",
"{",
"$",
"indexer",
"->",
"delete",
"(",
"$",
"node",
")",
";",
"}",
"}"
] | {inheritdoc} | [
"{",
"inheritdoc",
"}"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/NodeIndexerChain.php#L112-L117 |
makinacorpus/drupal-ucms | ucms_search/src/NodeIndexerChain.php | NodeIndexerChain.bulkUpsert | public function bulkUpsert($nodeList, $force = false, $refresh = false)
{
foreach ($this->chain as $indexer) {
$indexer->bulkUpsert($nodeList, $force, $refresh);
}
} | php | public function bulkUpsert($nodeList, $force = false, $refresh = false)
{
foreach ($this->chain as $indexer) {
$indexer->bulkUpsert($nodeList, $force, $refresh);
}
} | [
"public",
"function",
"bulkUpsert",
"(",
"$",
"nodeList",
",",
"$",
"force",
"=",
"false",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"chain",
"as",
"$",
"indexer",
")",
"{",
"$",
"indexer",
"->",
"bulkUpsert",
"(... | {inheritdoc} | [
"{",
"inheritdoc",
"}"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/NodeIndexerChain.php#L122-L127 |
makinacorpus/drupal-ucms | ucms_search/src/NodeIndexerChain.php | NodeIndexerChain.upsert | public function upsert(NodeInterface $node, $force = false, $refresh = false)
{
$ret = false;
foreach ($this->chain as $indexer) {
$ret |= $indexer->upsert($node, $force, $refresh);
}
return $ret;
} | php | public function upsert(NodeInterface $node, $force = false, $refresh = false)
{
$ret = false;
foreach ($this->chain as $indexer) {
$ret |= $indexer->upsert($node, $force, $refresh);
}
return $ret;
} | [
"public",
"function",
"upsert",
"(",
"NodeInterface",
"$",
"node",
",",
"$",
"force",
"=",
"false",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"$",
"ret",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"chain",
"as",
"$",
"indexer",
")",
"... | {inheritdoc} | [
"{",
"inheritdoc",
"}"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/NodeIndexerChain.php#L132-L141 |
PHPixie/HTTP | src/PHPixie/HTTP/Context/Cookies.php | Cookies.getRequired | public function getRequired($name)
{
if($this->exists($name)) {
return $this->cookies[$name];
}
throw new \PHPixie\HTTP\Exception("Cookie '$name' is not set");
} | php | public function getRequired($name)
{
if($this->exists($name)) {
return $this->cookies[$name];
}
throw new \PHPixie\HTTP\Exception("Cookie '$name' is not set");
} | [
"public",
"function",
"getRequired",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cookies",
"[",
"$",
"name",
"]",
";",
"}",
"throw",
"new",
"\\",
"PHPixie",
"\... | Get cookie or throw an exception if it's missing
@param string $name
@return mixed
@throws \PHPixie\HTTP\Exception | [
"Get",
"cookie",
"or",
"throw",
"an",
"exception",
"if",
"it",
"s",
"missing"
] | train | https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Context/Cookies.php#L58-L65 |
PHPixie/HTTP | src/PHPixie/HTTP/Context/Cookies.php | Cookies.set | public function set(
$name,
$value,
$lifetime = null,
$path = '/',
$domain = null,
$secure = false,
$httpOnly = false
)
{
if($lifetime !== null) {
$expires = time() + $lifetime;
}else{
$expires = null;
}
if($lifetime < 0) {
unset($this->cookies[$name]);
}else {
$this->cookies[$name] = $value;
}
$this->updates[$name] = $this->builder->cookiesUpdate(
$name,
$value,
$expires,
$path,
$domain,
$secure,
$httpOnly
);
} | php | public function set(
$name,
$value,
$lifetime = null,
$path = '/',
$domain = null,
$secure = false,
$httpOnly = false
)
{
if($lifetime !== null) {
$expires = time() + $lifetime;
}else{
$expires = null;
}
if($lifetime < 0) {
unset($this->cookies[$name]);
}else {
$this->cookies[$name] = $value;
}
$this->updates[$name] = $this->builder->cookiesUpdate(
$name,
$value,
$expires,
$path,
$domain,
$secure,
$httpOnly
);
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
"=",
"null",
",",
"$",
"path",
"=",
"'/'",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"secure",
"=",
"false",
",",
"$",
"httpOnly",
"=",
"false",
")",
"{",
... | Set cookie
See the PHP setcookie() function for more details
@param string $name
@param mixed $value
@param int|null $lifetime
@param string|null $path
@param string|null $domain
@param boolean $secure
@param bool $httpOnly
@return void | [
"Set",
"cookie"
] | train | https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Context/Cookies.php#L80-L113 |
makinacorpus/drupal-ucms | ucms_site/src/Form/NodeDereferenceFrom.php | NodeDereferenceFrom.buildForm | public function buildForm(array $form, FormStateInterface $form_state, $node = null)
{
if (!$node instanceof NodeInterface) {
$this->logger('form')->critical("There is no node to dereference!");
return $form;
}
if (!$this->siteManager->hasContext()) {
$this->logger('form')->critical("There is no site to remove reference from!");
return $form;
}
$form_state->setTemporaryValue('node', $node);
$site = $this->siteManager->getContext();
return confirm_form(
$form,
$this->t("Remove %title from the %site site?", [
'%title' => $node->title,
'%site' => $site->title,
]),
'node/' . $node->id()
);
} | php | public function buildForm(array $form, FormStateInterface $form_state, $node = null)
{
if (!$node instanceof NodeInterface) {
$this->logger('form')->critical("There is no node to dereference!");
return $form;
}
if (!$this->siteManager->hasContext()) {
$this->logger('form')->critical("There is no site to remove reference from!");
return $form;
}
$form_state->setTemporaryValue('node', $node);
$site = $this->siteManager->getContext();
return confirm_form(
$form,
$this->t("Remove %title from the %site site?", [
'%title' => $node->title,
'%site' => $site->title,
]),
'node/' . $node->id()
);
} | [
"public",
"function",
"buildForm",
"(",
"array",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
",",
"$",
"node",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"node",
"instanceof",
"NodeInterface",
")",
"{",
"$",
"this",
"->",
"logger",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Form/NodeDereferenceFrom.php#L51-L74 |
makinacorpus/drupal-ucms | ucms_site/src/Form/NodeDereferenceFrom.php | NodeDereferenceFrom.submitForm | public function submitForm(array &$form, FormStateInterface $form_state)
{
$node = $form_state->getTemporaryValue('node');
$site = $this->siteManager->getContext();
$this->nodeManager->deleteReferenceBulkFromSite($site->getId(), [$node->id()]);
drupal_set_message($this->t("%title has been removed from site %site", [
'%title' => $node->title,
'%site' => $site->title,
]));
$form_state->setRedirect('node/' . $node->id());
} | php | public function submitForm(array &$form, FormStateInterface $form_state)
{
$node = $form_state->getTemporaryValue('node');
$site = $this->siteManager->getContext();
$this->nodeManager->deleteReferenceBulkFromSite($site->getId(), [$node->id()]);
drupal_set_message($this->t("%title has been removed from site %site", [
'%title' => $node->title,
'%site' => $site->title,
]));
$form_state->setRedirect('node/' . $node->id());
} | [
"public",
"function",
"submitForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"$",
"node",
"=",
"$",
"form_state",
"->",
"getTemporaryValue",
"(",
"'node'",
")",
";",
"$",
"site",
"=",
"$",
"this",
"->",
"sit... | Step B form submit | [
"Step",
"B",
"form",
"submit"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Form/NodeDereferenceFrom.php#L79-L92 |
stephweb/daw-php-orm | example/core/Routing/Router.php | Router.setUri | private function setUri()
{
if (Input::hasGet('uri')) {
$this->uri = ltrim(Input::get('uri'), '/');
if (strpos(Request::getRequestUri(), '?uri=') !== false) {
Response::redirect($this->uri, 301);
}
}
} | php | private function setUri()
{
if (Input::hasGet('uri')) {
$this->uri = ltrim(Input::get('uri'), '/');
if (strpos(Request::getRequestUri(), '?uri=') !== false) {
Response::redirect($this->uri, 301);
}
}
} | [
"private",
"function",
"setUri",
"(",
")",
"{",
"if",
"(",
"Input",
"::",
"hasGet",
"(",
"'uri'",
")",
")",
"{",
"$",
"this",
"->",
"uri",
"=",
"ltrim",
"(",
"Input",
"::",
"get",
"(",
"'uri'",
")",
",",
"'/'",
")",
";",
"if",
"(",
"strpos",
"(... | Setter de l'URI | [
"Setter",
"de",
"l",
"URI"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Routing/Router.php#L60-L69 |
stephweb/daw-php-orm | example/core/Routing/Router.php | Router.run | public function run()
{
foreach ($this->routes as $path => $action) {
if ($this->uri == $path) {
return $this->executeAction($action);
}
}
return $this->executeError404();
} | php | public function run()
{
foreach ($this->routes as $path => $action) {
if ($this->uri == $path) {
return $this->executeAction($action);
}
}
return $this->executeError404();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"as",
"$",
"path",
"=>",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"uri",
"==",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"executeActi... | Executer le Routing
@return mixed | [
"Executer",
"le",
"Routing"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Routing/Router.php#L87-L96 |
stephweb/daw-php-orm | example/core/Routing/Router.php | Router.executeAction | private function executeAction(string $action)
{
list($controller, $method) = explode('@', $action);
$class = '\App\Controllers\\'.ucfirst($controller).'Controller';
if (!class_exists($class)) {
throw new ExceptionHandler('Class "'.$class.'" not found.');
}
$controllerInstantiate = new $class();
if (!method_exists($controllerInstantiate, $method)) {
throw new ExceptionHandler('Method "'.$method.'" not found in '.$class.'.');
}
return call_user_func_array([new $controllerInstantiate, $method], []);
} | php | private function executeAction(string $action)
{
list($controller, $method) = explode('@', $action);
$class = '\App\Controllers\\'.ucfirst($controller).'Controller';
if (!class_exists($class)) {
throw new ExceptionHandler('Class "'.$class.'" not found.');
}
$controllerInstantiate = new $class();
if (!method_exists($controllerInstantiate, $method)) {
throw new ExceptionHandler('Method "'.$method.'" not found in '.$class.'.');
}
return call_user_func_array([new $controllerInstantiate, $method], []);
} | [
"private",
"function",
"executeAction",
"(",
"string",
"$",
"action",
")",
"{",
"list",
"(",
"$",
"controller",
",",
"$",
"method",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"action",
")",
";",
"$",
"class",
"=",
"'\\App\\Controllers\\\\'",
".",
"ucfirs... | Executer l'action
@param string $action
@return mixed | [
"Executer",
"l",
"action"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/example/core/Routing/Router.php#L104-L121 |
makinacorpus/drupal-ucms | ucms_widget/src/Impl/MenuRoleWidget.php | MenuRoleWidget.findAllMenuWithRole | private function findAllMenuWithRole(Site $site, $role)
{
return $this->treeManager->getMenuStorage()->loadWithConditions([
'site_id' => $site->getId(),
'role' => $role,
]);
} | php | private function findAllMenuWithRole(Site $site, $role)
{
return $this->treeManager->getMenuStorage()->loadWithConditions([
'site_id' => $site->getId(),
'role' => $role,
]);
} | [
"private",
"function",
"findAllMenuWithRole",
"(",
"Site",
"$",
"site",
",",
"$",
"role",
")",
"{",
"return",
"$",
"this",
"->",
"treeManager",
"->",
"getMenuStorage",
"(",
")",
"->",
"loadWithConditions",
"(",
"[",
"'site_id'",
"=>",
"$",
"site",
"->",
"g... | Find all the menus with the given role in the given site
@param Site $site
@param string $role
@return Menu[] | [
"Find",
"all",
"the",
"menus",
"with",
"the",
"given",
"role",
"in",
"the",
"given",
"site"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_widget/src/Impl/MenuRoleWidget.php#L48-L54 |
makinacorpus/drupal-ucms | ucms_widget/src/Impl/MenuRoleWidget.php | MenuRoleWidget.render | public function render(EntityInterface $entity, Site $site, $options = [], $formatterOptions = [], Request $request)
{
$ret = [];
if ($options['role']) {
try {
if (!$this->siteManager->hasContext()) { // Shortcut
return;
}
$site = $this->siteManager->getContext();
$menuList = $this->findAllMenuWithRole($site, $options['role']);
if ($menuList && !$options['multiple']) {
$menuList = [reset($menuList)];
}
if (!$menuList) { // Shortcut
return;
}
if ($formatterOptions['suggestion']) {
$themeHook = 'umenu__' . $formatterOptions['suggestion'];
} else {
$themeHook = 'umenu';
}
$current = null;
if ($node = menu_get_object()) { // FIXME
$current = $node->nid;
}
foreach ($menuList as $menu) {
$ret[$menu->getName()] = [
'#theme' => $themeHook,
'#tree' => $this->treeManager->buildTree($menu->getName()),
'#current' => $current,
];
}
} catch (\Exception $e) {
// Be silent about this, we are rendering the front page
}
}
return $ret;
} | php | public function render(EntityInterface $entity, Site $site, $options = [], $formatterOptions = [], Request $request)
{
$ret = [];
if ($options['role']) {
try {
if (!$this->siteManager->hasContext()) { // Shortcut
return;
}
$site = $this->siteManager->getContext();
$menuList = $this->findAllMenuWithRole($site, $options['role']);
if ($menuList && !$options['multiple']) {
$menuList = [reset($menuList)];
}
if (!$menuList) { // Shortcut
return;
}
if ($formatterOptions['suggestion']) {
$themeHook = 'umenu__' . $formatterOptions['suggestion'];
} else {
$themeHook = 'umenu';
}
$current = null;
if ($node = menu_get_object()) { // FIXME
$current = $node->nid;
}
foreach ($menuList as $menu) {
$ret[$menu->getName()] = [
'#theme' => $themeHook,
'#tree' => $this->treeManager->buildTree($menu->getName()),
'#current' => $current,
];
}
} catch (\Exception $e) {
// Be silent about this, we are rendering the front page
}
}
return $ret;
} | [
"public",
"function",
"render",
"(",
"EntityInterface",
"$",
"entity",
",",
"Site",
"$",
"site",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"formatterOptions",
"=",
"[",
"]",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_widget/src/Impl/MenuRoleWidget.php#L59-L104 |
makinacorpus/drupal-ucms | ucms_widget/src/Impl/MenuRoleWidget.php | MenuRoleWidget.getOptionsForm | public function getOptionsForm($options = [])
{
$form = [];
$allowedRoles = ucms_tree_role_list();
if ($allowedRoles) {
$form['role'] = [
'#type' => 'select',
'#title' => $this->t("Menu role"),
'#options' => $allowedRoles,
'#empty_option' => $this->t("Select a role"),
'#default_value' => $options['role'],
'#required' => true,
];
} else {
$form['role'] = [
'#type' => 'textfield',
'#title' => $this->t("Menu role"),
'#maxlength' => 64,
'#default_value' => $options['role'],
'#required' => true,
];
}
$form['multiple'] = [
'#type' => 'checkbox',
'#title' => $this->t("Display all matching menus"),
'#description' => $this->t("If unchecked, only the first menu found with the given role in the current site will be displayed"),
'#default_value' => $options['multiple'],
];
return $form;
} | php | public function getOptionsForm($options = [])
{
$form = [];
$allowedRoles = ucms_tree_role_list();
if ($allowedRoles) {
$form['role'] = [
'#type' => 'select',
'#title' => $this->t("Menu role"),
'#options' => $allowedRoles,
'#empty_option' => $this->t("Select a role"),
'#default_value' => $options['role'],
'#required' => true,
];
} else {
$form['role'] = [
'#type' => 'textfield',
'#title' => $this->t("Menu role"),
'#maxlength' => 64,
'#default_value' => $options['role'],
'#required' => true,
];
}
$form['multiple'] = [
'#type' => 'checkbox',
'#title' => $this->t("Display all matching menus"),
'#description' => $this->t("If unchecked, only the first menu found with the given role in the current site will be displayed"),
'#default_value' => $options['multiple'],
];
return $form;
} | [
"public",
"function",
"getOptionsForm",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"form",
"=",
"[",
"]",
";",
"$",
"allowedRoles",
"=",
"ucms_tree_role_list",
"(",
")",
";",
"if",
"(",
"$",
"allowedRoles",
")",
"{",
"$",
"form",
"[",
"'role'... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_widget/src/Impl/MenuRoleWidget.php#L117-L149 |
runcmf/runbb | src/RunBB/Core/Preferences.php | Preferences.setUser | public function setUser($user = null, array $prefs = [])
{
list($uid, $gid) = $this->getInfosFromUser($user);
foreach ($prefs as $pref_name => $pref_value) {
$pref_name = (string) $pref_name;
$pref_value = (string) $pref_value;
if ((int) $pref_name > 0) {
throw new RunBBException('Internal error : preference name cannot be an integer', 500);
}
$result = DB::forTable('preferences')
->where('preference_name', $pref_name)
->where('user', $uid)
->find_one();
if ($result) {
DB::forTable('preferences')
->find_one($result->id())
->set(['preference_value' => $pref_value])
->save();
} else {
DB::forTable('preferences')
->create()
->set([
'preference_name' => $pref_name,
'preference_value' => $pref_value,
'user' => $uid
])
->save();
}
$this->preferences[$gid][$uid][$pref_name] = $pref_value;
}
return $this;
} | php | public function setUser($user = null, array $prefs = [])
{
list($uid, $gid) = $this->getInfosFromUser($user);
foreach ($prefs as $pref_name => $pref_value) {
$pref_name = (string) $pref_name;
$pref_value = (string) $pref_value;
if ((int) $pref_name > 0) {
throw new RunBBException('Internal error : preference name cannot be an integer', 500);
}
$result = DB::forTable('preferences')
->where('preference_name', $pref_name)
->where('user', $uid)
->find_one();
if ($result) {
DB::forTable('preferences')
->find_one($result->id())
->set(['preference_value' => $pref_value])
->save();
} else {
DB::forTable('preferences')
->create()
->set([
'preference_name' => $pref_name,
'preference_value' => $pref_value,
'user' => $uid
])
->save();
}
$this->preferences[$gid][$uid][$pref_name] = $pref_value;
}
return $this;
} | [
"public",
"function",
"setUser",
"(",
"$",
"user",
"=",
"null",
",",
"array",
"$",
"prefs",
"=",
"[",
"]",
")",
"{",
"list",
"(",
"$",
"uid",
",",
"$",
"gid",
")",
"=",
"$",
"this",
"->",
"getInfosFromUser",
"(",
"$",
"user",
")",
";",
"foreach",... | Add / Update | [
"Add",
"/",
"Update"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Preferences.php#L24-L57 |
runcmf/runbb | src/RunBB/Core/Preferences.php | Preferences.delUser | public function delUser($user = null, $prefs = null)
{
list($uid, $gid) = $this->getInfosFromUser($user);
$prefs = (array) $prefs;
foreach ($prefs as $pref_id => $pref_name) {
$pref_name = (string) $pref_name;
if ((int) $pref_name > 0) {
throw new RunBBException('Internal error : preference name cannot be an integer', 500);
}
$result = DB::forTable('preferences')
->where('preference_name', $pref_name)
->where('user', $uid)
->find_one();
if ($result) {
$result->delete();
unset($this->preferences[$gid][$uid][$pref_name]);
} else {
throw new RunBBException('Internal error : Unknown preference name', 500);
}
}
return $this;
} | php | public function delUser($user = null, $prefs = null)
{
list($uid, $gid) = $this->getInfosFromUser($user);
$prefs = (array) $prefs;
foreach ($prefs as $pref_id => $pref_name) {
$pref_name = (string) $pref_name;
if ((int) $pref_name > 0) {
throw new RunBBException('Internal error : preference name cannot be an integer', 500);
}
$result = DB::forTable('preferences')
->where('preference_name', $pref_name)
->where('user', $uid)
->find_one();
if ($result) {
$result->delete();
unset($this->preferences[$gid][$uid][$pref_name]);
} else {
throw new RunBBException('Internal error : Unknown preference name', 500);
}
}
return $this;
} | [
"public",
"function",
"delUser",
"(",
"$",
"user",
"=",
"null",
",",
"$",
"prefs",
"=",
"null",
")",
"{",
"list",
"(",
"$",
"uid",
",",
"$",
"gid",
")",
"=",
"$",
"this",
"->",
"getInfosFromUser",
"(",
"$",
"user",
")",
";",
"$",
"prefs",
"=",
... | Delete | [
"Delete"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Preferences.php#L125-L147 |
runcmf/runbb | src/RunBB/Core/Preferences.php | Preferences.get | public function get($user = null, $pref = null)
{
list($uid, $gid) = $this->getInfosFromUser($user);
if (!isset($this->preferences[$gid][$uid])) {
$this->loadPrefs($user);
}
if (empty($pref)) {
return $this->preferences[$gid][$uid];
}
return (isset($this->preferences[$gid][$uid][(string) $pref])) ?
$this->preferences[$gid][$uid][(string) $pref] : null;
} | php | public function get($user = null, $pref = null)
{
list($uid, $gid) = $this->getInfosFromUser($user);
if (!isset($this->preferences[$gid][$uid])) {
$this->loadPrefs($user);
}
if (empty($pref)) {
return $this->preferences[$gid][$uid];
}
return (isset($this->preferences[$gid][$uid][(string) $pref])) ?
$this->preferences[$gid][$uid][(string) $pref] : null;
} | [
"public",
"function",
"get",
"(",
"$",
"user",
"=",
"null",
",",
"$",
"pref",
"=",
"null",
")",
"{",
"list",
"(",
"$",
"uid",
",",
"$",
"gid",
")",
"=",
"$",
"this",
"->",
"getInfosFromUser",
"(",
"$",
"user",
")",
";",
"if",
"(",
"!",
"isset",... | Getters | [
"Getters"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Preferences.php#L200-L212 |
runcmf/runbb | src/RunBB/Core/Preferences.php | Preferences.loadPrefs | protected function loadPrefs($user = null)
{
list($uid, $gid) = $this->getInfosFromUser($user);
$result = DB::forTable('preferences')
->table_alias('p')
->where_any_is([
['p.user' => $uid],
['p.group' => $gid],
['p.default' => 1],
])
->order_by_desc('p.default')
->order_by_asc('p.user')
->find_array();
$this->preferences[$gid][$uid] = [];
foreach ($result as $pref) {
$this->preferences[$gid][$uid][(string) $pref['preference_name']] = $pref['preference_value'];
}
return $this->preferences[$gid][$uid];
} | php | protected function loadPrefs($user = null)
{
list($uid, $gid) = $this->getInfosFromUser($user);
$result = DB::forTable('preferences')
->table_alias('p')
->where_any_is([
['p.user' => $uid],
['p.group' => $gid],
['p.default' => 1],
])
->order_by_desc('p.default')
->order_by_asc('p.user')
->find_array();
$this->preferences[$gid][$uid] = [];
foreach ($result as $pref) {
$this->preferences[$gid][$uid][(string) $pref['preference_name']] = $pref['preference_value'];
}
return $this->preferences[$gid][$uid];
} | [
"protected",
"function",
"loadPrefs",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"list",
"(",
"$",
"uid",
",",
"$",
"gid",
")",
"=",
"$",
"this",
"->",
"getInfosFromUser",
"(",
"$",
"user",
")",
";",
"$",
"result",
"=",
"DB",
"::",
"forTable",
"(",
... | Utils | [
"Utils"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Preferences.php#L216-L236 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Order/Base/Standard.php | Standard.saveItems | public function saveItems( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$ids = [];
$manager = $this->getManager();
$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );
foreach( $items as $entry )
{
$langid = ( isset( $entry->{'order.base.languageid'} ) ? $entry->{'order.base.languageid'} : null );
$currencyid = ( isset( $entry->{'order.base.currencyid'} ) ? $entry->{'order.base.currencyid'} : null );
$this->setLocale( $params->site, $langid, $currencyid );
$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( 'site', 'items' ) );
$ids = [];
$manager = $this->getManager();
$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );
foreach( $items as $entry )
{
$langid = ( isset( $entry->{'order.base.languageid'} ) ? $entry->{'order.base.languageid'} : null );
$currencyid = ( isset( $entry->{'order.base.currencyid'} ) ? $entry->{'order.base.currencyid'} : null );
$this->setLocale( $params->site, $langid, $currencyid );
$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",
"(",
"'site'",
",",
"'items'",
")",
")",
";",
"$",
"ids",
"=",
"[",
"]",
";",
"$",
"manager",
"="... | Creates a new order base item or updates an existing one or a list thereof.
@param \stdClass $params Associative array containing the order base properties | [
"Creates",
"a",
"new",
"order",
"base",
"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/Order/Base/Standard.php#L44-L66 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Order/Base/Standard.php | Standard.getManager | protected function getManager()
{
if( $this->manager === null ) {
$this->manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base' );
}
return $this->manager;
} | php | protected function getManager()
{
if( $this->manager === null ) {
$this->manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base' );
}
return $this->manager;
} | [
"protected",
"function",
"getManager",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"manager",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Factory",
"::",
"createManager",
"(",
"$",
"this",
"->",
... | Returns the manager the controller is using.
@return \Aimeos\MShop\Common\Manager\Iface Manager object | [
"Returns",
"the",
"manager",
"the",
"controller",
"is",
"using",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Order/Base/Standard.php#L74-L81 |
makinacorpus/drupal-ucms | ucms_user/src/Form/UserResetPassword.php | UserResetPassword.buildForm | public function buildForm(array $form, FormStateInterface $form_state, UserInterface $user = null)
{
if ($user === null) {
return [];
}
$form_state->setTemporaryValue('user', $user);
$question = $this->t("Do you really want to reset the password of the user @name?", ['@name' => $user->getDisplayName()]);
return confirm_form($form, $question, 'admin/dashboard/user');
} | php | public function buildForm(array $form, FormStateInterface $form_state, UserInterface $user = null)
{
if ($user === null) {
return [];
}
$form_state->setTemporaryValue('user', $user);
$question = $this->t("Do you really want to reset the password of the user @name?", ['@name' => $user->getDisplayName()]);
return confirm_form($form, $question, 'admin/dashboard/user');
} | [
"public",
"function",
"buildForm",
"(",
"array",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
",",
"UserInterface",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"user",
"===",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/Form/UserResetPassword.php#L76-L86 |
makinacorpus/drupal-ucms | ucms_user/src/Form/UserResetPassword.php | UserResetPassword.submitForm | public function submitForm(array &$form, FormStateInterface $form_state)
{
require_once DRUPAL_ROOT . '/includes/password.inc';
/* @var $user UserInterface */
$user = $form_state->getTemporaryValue('user');
$user->pass = user_hash_password(user_password(20));
$saved = $this->entityManager->getStorage('user')->save($user);
if ($saved) {
drupal_set_message($this->t("@name's password has been resetted.", array('@name' => $user->getDisplayName())));
$this->tokenManager->sendTokenMail($user, 'ucms_user', 'password-reset');
$this->dispatcher->dispatch('user:reset_password', new UserEvent($user->uid, $this->currentUser()->id()));
} else {
drupal_set_message($this->t("An error occured. Please try again."), 'error');
}
$form_state->setRedirect('admin/dashboard/user');
} | php | public function submitForm(array &$form, FormStateInterface $form_state)
{
require_once DRUPAL_ROOT . '/includes/password.inc';
/* @var $user UserInterface */
$user = $form_state->getTemporaryValue('user');
$user->pass = user_hash_password(user_password(20));
$saved = $this->entityManager->getStorage('user')->save($user);
if ($saved) {
drupal_set_message($this->t("@name's password has been resetted.", array('@name' => $user->getDisplayName())));
$this->tokenManager->sendTokenMail($user, 'ucms_user', 'password-reset');
$this->dispatcher->dispatch('user:reset_password', new UserEvent($user->uid, $this->currentUser()->id()));
} else {
drupal_set_message($this->t("An error occured. Please try again."), 'error');
}
$form_state->setRedirect('admin/dashboard/user');
} | [
"public",
"function",
"submitForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"require_once",
"DRUPAL_ROOT",
".",
"'/includes/password.inc'",
";",
"/* @var $user UserInterface */",
"$",
"user",
"=",
"$",
"form_state",
"-... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/Form/UserResetPassword.php#L92-L111 |
edvler/yii2-accounting | tools/StaticEb.php | StaticEb.formatAccountside | public static function formatAccountside($value) {
if ($value === StaticEb::$accountsideDebitSign) {
return \Yii::t('common/staticeb', 'Debit');
} else if ($value === StaticEb::$accountsideCreditSign) {
return \Yii::t('common/staticeb', 'Credit');
} else {
throw new Exception(\Yii::t('common/staticeb', '{value} is not a accounside. Valid values: ' . StaticEb::$accountsideDebitSign . ',' . StaticEb::$accountsideCreditSign, [ 'value' => $value]
));
}
} | php | public static function formatAccountside($value) {
if ($value === StaticEb::$accountsideDebitSign) {
return \Yii::t('common/staticeb', 'Debit');
} else if ($value === StaticEb::$accountsideCreditSign) {
return \Yii::t('common/staticeb', 'Credit');
} else {
throw new Exception(\Yii::t('common/staticeb', '{value} is not a accounside. Valid values: ' . StaticEb::$accountsideDebitSign . ',' . StaticEb::$accountsideCreditSign, [ 'value' => $value]
));
}
} | [
"public",
"static",
"function",
"formatAccountside",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"StaticEb",
"::",
"$",
"accountsideDebitSign",
")",
"{",
"return",
"\\",
"Yii",
"::",
"t",
"(",
"'common/staticeb'",
",",
"'Debit'",
")",
";",... | Format credit or debit accountside
@param string $value
@return string formatted language string
@throws Exception if sign other than C,D given | [
"Format",
"credit",
"or",
"debit",
"accountside"
] | train | https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L54-L63 |
edvler/yii2-accounting | tools/StaticEb.php | StaticEb.getAccountSideSignFromLanguage | public static function getAccountSideSignFromLanguage($value) {
switch (strtolower($value)) {
case strtolower(StaticEb::$accountsideDebitSign):
case strtolower(StaticEb::formatAccountside('D')):
return 'D';
case strtolower(StaticEb::$accountsideCreditSign):
case strtolower(StaticEb::formatAccountside('C')):
return 'C';
default:
throw new Exception(\Yii::t('common/staticeb', 'Cannot determine accoundside sign from value "{value}". Valid values: '
. StaticEb::$accountsideDebitSign . ', ' . StaticEb::formatAccountside('D') . ', '
. StaticEb::$accountsideCreditSign . ', ' . StaticEb::formatAccountside('C'), [ 'value' => $value]
));
}
} | php | public static function getAccountSideSignFromLanguage($value) {
switch (strtolower($value)) {
case strtolower(StaticEb::$accountsideDebitSign):
case strtolower(StaticEb::formatAccountside('D')):
return 'D';
case strtolower(StaticEb::$accountsideCreditSign):
case strtolower(StaticEb::formatAccountside('C')):
return 'C';
default:
throw new Exception(\Yii::t('common/staticeb', 'Cannot determine accoundside sign from value "{value}". Valid values: '
. StaticEb::$accountsideDebitSign . ', ' . StaticEb::formatAccountside('D') . ', '
. StaticEb::$accountsideCreditSign . ', ' . StaticEb::formatAccountside('C'), [ 'value' => $value]
));
}
} | [
"public",
"static",
"function",
"getAccountSideSignFromLanguage",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"value",
")",
")",
"{",
"case",
"strtolower",
"(",
"StaticEb",
"::",
"$",
"accountsideDebitSign",
")",
":",
"case",
"strtolowe... | Get AccountsideSign from current language
@param string $value
@return string formatted language string
@throws Exception if accountside sign could not be determined | [
"Get",
"AccountsideSign",
"from",
"current",
"language"
] | train | https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L72-L86 |
edvler/yii2-accounting | tools/StaticEb.php | StaticEb.parseDate | public static function parseDate($sourceDate, $sourceFormat, $destinationFormat) {
$myDateTime = \DateTime::createFromFormat($sourceFormat, $sourceDate);
if ($myDateTime === false) {
throw new Exception("Date " . $sourceDate . " cannot be parsed with format \"" . $sourceFormat . "\"");
}
return $myDateTime->format($destinationFormat);
} | php | public static function parseDate($sourceDate, $sourceFormat, $destinationFormat) {
$myDateTime = \DateTime::createFromFormat($sourceFormat, $sourceDate);
if ($myDateTime === false) {
throw new Exception("Date " . $sourceDate . " cannot be parsed with format \"" . $sourceFormat . "\"");
}
return $myDateTime->format($destinationFormat);
} | [
"public",
"static",
"function",
"parseDate",
"(",
"$",
"sourceDate",
",",
"$",
"sourceFormat",
",",
"$",
"destinationFormat",
")",
"{",
"$",
"myDateTime",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"sourceFormat",
",",
"$",
"sourceDate",
")",
... | Parse a date from a string
@param string String to parse
@param string Source format according to http://php.net/manual/de/datetime.createfromformat.php
@param string Destination format according to http://php.net/manual/de/datetime.createfromformat.php
@return string the formatted date | [
"Parse",
"a",
"date",
"from",
"a",
"string"
] | train | https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L115-L123 |
edvler/yii2-accounting | tools/StaticEb.php | StaticEb.mathAdd | public static function mathAdd($decimal1, $decimal2) {
if (!is_numeric($decimal1)) {
throw new Exception("decimal1 is not a numeric value: " . $decimal1);
}
if (!is_numeric($decimal2)) {
throw new Exception("decimal2 is not a numeric value: " . $decimal2);
}
return round($decimal1 + $decimal2, StaticEb::$roundPrecision);
} | php | public static function mathAdd($decimal1, $decimal2) {
if (!is_numeric($decimal1)) {
throw new Exception("decimal1 is not a numeric value: " . $decimal1);
}
if (!is_numeric($decimal2)) {
throw new Exception("decimal2 is not a numeric value: " . $decimal2);
}
return round($decimal1 + $decimal2, StaticEb::$roundPrecision);
} | [
"public",
"static",
"function",
"mathAdd",
"(",
"$",
"decimal1",
",",
"$",
"decimal2",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"decimal1",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"decimal1 is not a numeric value: \"",
".",
"$",
"decimal1... | Add two float values with precision given by StaticEb::$roundPrecision
@param float/int Number one
@param float/int Number two
@return float the sum | [
"Add",
"two",
"float",
"values",
"with",
"precision",
"given",
"by",
"StaticEb",
"::",
"$roundPrecision"
] | train | https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L132-L142 |
edvler/yii2-accounting | tools/StaticEb.php | StaticEb.mathSubtract | public static function mathSubtract($decimal1, $decimal2) {
if (!is_numeric($decimal1)) {
throw new Exception("decimal1 is not a numeric value: " . $decimal1);
}
if (!is_numeric($decimal2)) {
throw new Exception("decimal2 is not a numeric value: " . $decimal2);
}
return round($decimal1 - $decimal2, StaticEb::$roundPrecision);
} | php | public static function mathSubtract($decimal1, $decimal2) {
if (!is_numeric($decimal1)) {
throw new Exception("decimal1 is not a numeric value: " . $decimal1);
}
if (!is_numeric($decimal2)) {
throw new Exception("decimal2 is not a numeric value: " . $decimal2);
}
return round($decimal1 - $decimal2, StaticEb::$roundPrecision);
} | [
"public",
"static",
"function",
"mathSubtract",
"(",
"$",
"decimal1",
",",
"$",
"decimal2",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"decimal1",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"decimal1 is not a numeric value: \"",
".",
"$",
"dec... | Subtract two float values with precision given by StaticEb::$roundPrecision
@param float/int Number one
@param float/int Number two
@return float the sum | [
"Subtract",
"two",
"float",
"values",
"with",
"precision",
"given",
"by",
"StaticEb",
"::",
"$roundPrecision"
] | train | https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L151-L161 |
edvler/yii2-accounting | tools/StaticEb.php | StaticEb.getLoacleconv | public static function getLoacleconv() {
if (setlocale(LC_MONETARY, \Yii::$app->language)) {
$arr = localeconv();
//\Yii::error($arr['currency_symbol'] . setlocale(LC_MONETARY,0). ' ' . bin2hex($arr['mon_thousands_sep']));
$arr['currency_symbol'] = iconv("Windows-1252", "UTF-8", $arr['currency_symbol']);
$arr['mon_thousands_sep'] = iconv("Windows-1252", "UTF-8", $arr['mon_thousands_sep']);
return $arr;
} else {
throw new \yii\base\Exception('Cannot set locale ' . \Yii::$app->language . '. Maybe the local is not installed. See php manual for further information');
}
} | php | public static function getLoacleconv() {
if (setlocale(LC_MONETARY, \Yii::$app->language)) {
$arr = localeconv();
//\Yii::error($arr['currency_symbol'] . setlocale(LC_MONETARY,0). ' ' . bin2hex($arr['mon_thousands_sep']));
$arr['currency_symbol'] = iconv("Windows-1252", "UTF-8", $arr['currency_symbol']);
$arr['mon_thousands_sep'] = iconv("Windows-1252", "UTF-8", $arr['mon_thousands_sep']);
return $arr;
} else {
throw new \yii\base\Exception('Cannot set locale ' . \Yii::$app->language . '. Maybe the local is not installed. See php manual for further information');
}
} | [
"public",
"static",
"function",
"getLoacleconv",
"(",
")",
"{",
"if",
"(",
"setlocale",
"(",
"LC_MONETARY",
",",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"language",
")",
")",
"{",
"$",
"arr",
"=",
"localeconv",
"(",
")",
";",
"//\\Yii::error($arr['currency_sy... | Get the localeconv array.
http://php.net/manual/de/function.localeconv.php
@return array with local informations for numbers and currency | [
"Get",
"the",
"localeconv",
"array",
".",
"http",
":",
"//",
"php",
".",
"net",
"/",
"manual",
"/",
"de",
"/",
"function",
".",
"localeconv",
".",
"php"
] | train | https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L170-L182 |
edvler/yii2-accounting | tools/StaticEb.php | StaticEb.initTransaction | public static function initTransaction($transactionTemplate = null) {
$fields = ['description', 'date', 'value'];
$transaction = new Transaction();
if ($transactionTemplate !== null) {
foreach ($fields as $f) {
$transaction->$f = $transactionTemplate->$f;
}
}
return $transaction;
} | php | public static function initTransaction($transactionTemplate = null) {
$fields = ['description', 'date', 'value'];
$transaction = new Transaction();
if ($transactionTemplate !== null) {
foreach ($fields as $f) {
$transaction->$f = $transactionTemplate->$f;
}
}
return $transaction;
} | [
"public",
"static",
"function",
"initTransaction",
"(",
"$",
"transactionTemplate",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"'description'",
",",
"'date'",
",",
"'value'",
"]",
";",
"$",
"transaction",
"=",
"new",
"Transaction",
"(",
")",
";",
"if"... | Clone transaction
Clone fields description, date, value into a new transaction object
@param Transaction The Transation to clone
@return Transaction New Transaction object | [
"Clone",
"transaction",
"Clone",
"fields",
"description",
"date",
"value",
"into",
"a",
"new",
"transaction",
"object"
] | train | https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L191-L203 |
edvler/yii2-accounting | tools/StaticEb.php | StaticEb.initTransactionPartsDebit | public static function initTransactionPartsDebit($transactionPartsTemplate = null) {
$fields = ['account_id', 'value', 'description'];
$transactionParts = [new TransactionPartDebit()];
$c = 0;
if ($transactionPartsTemplate !== null) {
foreach ($transactionPartsTemplate as $tp) {
if ($c >= 1) {
array_push($transactionParts, new TransactionPartDebit());
}
foreach ($fields as $f) {
$transactionParts[$c]->$f = $tp->$f;
}
$c++;
}
}
return $transactionParts;
} | php | public static function initTransactionPartsDebit($transactionPartsTemplate = null) {
$fields = ['account_id', 'value', 'description'];
$transactionParts = [new TransactionPartDebit()];
$c = 0;
if ($transactionPartsTemplate !== null) {
foreach ($transactionPartsTemplate as $tp) {
if ($c >= 1) {
array_push($transactionParts, new TransactionPartDebit());
}
foreach ($fields as $f) {
$transactionParts[$c]->$f = $tp->$f;
}
$c++;
}
}
return $transactionParts;
} | [
"public",
"static",
"function",
"initTransactionPartsDebit",
"(",
"$",
"transactionPartsTemplate",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"'account_id'",
",",
"'value'",
",",
"'description'",
"]",
";",
"$",
"transactionParts",
"=",
"[",
"new",
"Transact... | Clone transaction
Clone fields description, date, value into a new transaction object
@param Transaction The Transation to clone
@return Transaction New Transaction object | [
"Clone",
"transaction",
"Clone",
"fields",
"description",
"date",
"value",
"into",
"a",
"new",
"transaction",
"object"
] | train | https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L212-L233 |
edvler/yii2-accounting | tools/StaticEb.php | StaticEb.initTransactionPartsCredit | public static function initTransactionPartsCredit($transactionPartsTemplate = null) {
$fields = ['account_id', 'value', 'description'];
$transactionParts = [new TransactionPartCredit()];
$c = 0;
if ($transactionPartsTemplate !== null) {
foreach ($transactionPartsTemplate as $tp) {
if ($c >= 1) {
array_push($transactionParts, new TransactionPartCredit());
}
foreach ($fields as $f) {
$transactionParts[$c]->$f = $tp->$f;
}
$c++;
}
}
return $transactionParts;
} | php | public static function initTransactionPartsCredit($transactionPartsTemplate = null) {
$fields = ['account_id', 'value', 'description'];
$transactionParts = [new TransactionPartCredit()];
$c = 0;
if ($transactionPartsTemplate !== null) {
foreach ($transactionPartsTemplate as $tp) {
if ($c >= 1) {
array_push($transactionParts, new TransactionPartCredit());
}
foreach ($fields as $f) {
$transactionParts[$c]->$f = $tp->$f;
}
$c++;
}
}
return $transactionParts;
} | [
"public",
"static",
"function",
"initTransactionPartsCredit",
"(",
"$",
"transactionPartsTemplate",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"[",
"'account_id'",
",",
"'value'",
",",
"'description'",
"]",
";",
"$",
"transactionParts",
"=",
"[",
"new",
"Transac... | Clone transaction
Clone fields description, date, value into a new transaction object
@param Transaction The Transation to clone
@return Transaction New Transaction object | [
"Clone",
"transaction",
"Clone",
"fields",
"description",
"date",
"value",
"into",
"a",
"new",
"transaction",
"object"
] | train | https://github.com/edvler/yii2-accounting/blob/26c5f8731b47a3e6e28da2a460ec2bf72c94422b/tools/StaticEb.php#L242-L263 |
schnittstabil/csrf-tokenservice | src/TokenService.php | TokenService.generate | public function generate($nonce, $iat = null, $exp = null)
{
$generator = $this->generator;
return $generator($nonce, $iat, $exp);
} | php | public function generate($nonce, $iat = null, $exp = null)
{
$generator = $this->generator;
return $generator($nonce, $iat, $exp);
} | [
"public",
"function",
"generate",
"(",
"$",
"nonce",
",",
"$",
"iat",
"=",
"null",
",",
"$",
"exp",
"=",
"null",
")",
"{",
"$",
"generator",
"=",
"$",
"this",
"->",
"generator",
";",
"return",
"$",
"generator",
"(",
"$",
"nonce",
",",
"$",
"iat",
... | Generate a CSRF token.
@param string $nonce Value used to associate a client session
@param int $iat The time that the token was issued, defaults to `time()`
@param int $exp The expiration time, defaults to `$iat + $this->ttl`
@return string
@throws \InvalidArgumentException For invalid $iat and $exp arguments | [
"Generate",
"a",
"CSRF",
"token",
"."
] | train | https://github.com/schnittstabil/csrf-tokenservice/blob/22aefee674137e661fe439d08414b6abc1fe0d25/src/TokenService.php#L43-L48 |
schnittstabil/csrf-tokenservice | src/TokenService.php | TokenService.getConstraintViolations | public function getConstraintViolations($nonce, $token, $now = null, $leeway = 0)
{
$validator = $this->validator;
return $validator($nonce, $token, $now, $leeway);
} | php | public function getConstraintViolations($nonce, $token, $now = null, $leeway = 0)
{
$validator = $this->validator;
return $validator($nonce, $token, $now, $leeway);
} | [
"public",
"function",
"getConstraintViolations",
"(",
"$",
"nonce",
",",
"$",
"token",
",",
"$",
"now",
"=",
"null",
",",
"$",
"leeway",
"=",
"0",
")",
"{",
"$",
"validator",
"=",
"$",
"this",
"->",
"validator",
";",
"return",
"$",
"validator",
"(",
... | Determine constraint violations of CSRF tokens.
@param string $nonce Value used to associate a client session
@param string $token The token to validate
@param int $now The current time, defaults to `time()`
@return InvalidArgumentException[] Constraint violations; if $token is valid, an empty array | [
"Determine",
"constraint",
"violations",
"of",
"CSRF",
"tokens",
"."
] | train | https://github.com/schnittstabil/csrf-tokenservice/blob/22aefee674137e661fe439d08414b6abc1fe0d25/src/TokenService.php#L59-L64 |
schnittstabil/csrf-tokenservice | src/TokenService.php | TokenService.validate | public function validate($nonce, $token, $now = null, $leeway = 0)
{
return count($this->getConstraintViolations($nonce, $token, $now, $leeway)) === 0;
} | php | public function validate($nonce, $token, $now = null, $leeway = 0)
{
return count($this->getConstraintViolations($nonce, $token, $now, $leeway)) === 0;
} | [
"public",
"function",
"validate",
"(",
"$",
"nonce",
",",
"$",
"token",
",",
"$",
"now",
"=",
"null",
",",
"$",
"leeway",
"=",
"0",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getConstraintViolations",
"(",
"$",
"nonce",
",",
"$",
"token",
... | Validate a CSRF token.
@param string $nonce Value used to associate a client session
@param string $token The token to validate
@param int $now The current time, defaults to `time()`
@param int $leeway The leeway in seconds
@return bool true iff $token is valid | [
"Validate",
"a",
"CSRF",
"token",
"."
] | train | https://github.com/schnittstabil/csrf-tokenservice/blob/22aefee674137e661fe439d08414b6abc1fe0d25/src/TokenService.php#L76-L79 |
noherczeg/breadcrumb | src/Noherczeg/Breadcrumb/Builders/Builder.php | Builder.link | public function link($skip_last = true, $different_links = false)
{
if (!is_bool($skip_last) || !is_bool($different_links))
throw new \InvalidArgumentException('Link method expects a boolean variable!');
$this->initCurrentUrl();
$this->skipLast = $skip_last;
$position = 1;
foreach ($this->segments as $key => $segment) {
$this->setNextCurrentURL($segment, $different_links);
$this->setLink($key, $segment, $position);
$position++;
}
return $this->segments;
} | php | public function link($skip_last = true, $different_links = false)
{
if (!is_bool($skip_last) || !is_bool($different_links))
throw new \InvalidArgumentException('Link method expects a boolean variable!');
$this->initCurrentUrl();
$this->skipLast = $skip_last;
$position = 1;
foreach ($this->segments as $key => $segment) {
$this->setNextCurrentURL($segment, $different_links);
$this->setLink($key, $segment, $position);
$position++;
}
return $this->segments;
} | [
"public",
"function",
"link",
"(",
"$",
"skip_last",
"=",
"true",
",",
"$",
"different_links",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"skip_last",
")",
"||",
"!",
"is_bool",
"(",
"$",
"different_links",
")",
")",
"throw",
"new",
... | link: Inserts proper URLs to each Segment which is IN THE BUILDER's list.
@param boolean $skip_last To create a link for the last element or not
@param boolean $different_links Each segment is appended to base_url instead of the previous segment
@throws \InvalidArgumentException
@return array | [
"link",
":",
"Inserts",
"proper",
"URLs",
"to",
"each",
"Segment",
"which",
"is",
"IN",
"THE",
"BUILDER",
"s",
"list",
"."
] | train | https://github.com/noherczeg/breadcrumb/blob/d46ad3b58fbc6fa118ccad57e42e95214a0416c8/src/Noherczeg/Breadcrumb/Builders/Builder.php#L48-L64 |
noherczeg/breadcrumb | src/Noherczeg/Breadcrumb/Builders/Builder.php | Builder.casing | public function casing ($string, $to = '')
{
$res = null;
// Pick one! :)
switch ($to) {
case 'lower':
$res = mb_strtolower($string);
break;
case 'upper':
$res = mb_strtoupper($string);
break;
case 'title':
$res = ucfirst(strtolower($string));
break;
default:
$res = $string;
break;
}
return $res;
} | php | public function casing ($string, $to = '')
{
$res = null;
// Pick one! :)
switch ($to) {
case 'lower':
$res = mb_strtolower($string);
break;
case 'upper':
$res = mb_strtoupper($string);
break;
case 'title':
$res = ucfirst(strtolower($string));
break;
default:
$res = $string;
break;
}
return $res;
} | [
"public",
"function",
"casing",
"(",
"$",
"string",
",",
"$",
"to",
"=",
"''",
")",
"{",
"$",
"res",
"=",
"null",
";",
"// Pick one! :)\r",
"switch",
"(",
"$",
"to",
")",
"{",
"case",
"'lower'",
":",
"$",
"res",
"=",
"mb_strtolower",
"(",
"$",
"str... | casing: Provides casing operation to the class.
@param String $string String to format
@param String $to Name of casing
@return String | [
"casing",
":",
"Provides",
"casing",
"operation",
"to",
"the",
"class",
"."
] | train | https://github.com/noherczeg/breadcrumb/blob/d46ad3b58fbc6fa118ccad57e42e95214a0416c8/src/Noherczeg/Breadcrumb/Builders/Builder.php#L117-L138 |
noherczeg/breadcrumb | src/Noherczeg/Breadcrumb/Builders/Builder.php | Builder.properties | public function properties (array $properties = array())
{
$res = '';
if (!empty($properties)) {
foreach ($properties as $key => $property) {
$res .= ' ' . $key . '="' . $property . '"';
}
}
return $res;
} | php | public function properties (array $properties = array())
{
$res = '';
if (!empty($properties)) {
foreach ($properties as $key => $property) {
$res .= ' ' . $key . '="' . $property . '"';
}
}
return $res;
} | [
"public",
"function",
"properties",
"(",
"array",
"$",
"properties",
"=",
"array",
"(",
")",
")",
"{",
"$",
"res",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"properties",
")",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"key",
... | properties: Transforms an array of properties to a chain of html property key + value pairs.
@param array $properties Array of properties
@return string Chained properties
@throws \InvalidArgumentException | [
"properties",
":",
"Transforms",
"an",
"array",
"of",
"properties",
"to",
"a",
"chain",
"of",
"html",
"property",
"key",
"+",
"value",
"pairs",
"."
] | train | https://github.com/noherczeg/breadcrumb/blob/d46ad3b58fbc6fa118ccad57e42e95214a0416c8/src/Noherczeg/Breadcrumb/Builders/Builder.php#L147-L158 |
h4cc/StackLogger | src/Logger.php | Logger.handle | public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if ($type !== HttpKernelInterface::MASTER_REQUEST && false == $this->container['log_sub_request']) {
// Do not log SUB requests.
return $this->app->handle($request, $type, $catch);
}
$this->logRequest($request);
$response = $this->app->handle($request, $type, $catch);
$this->logResponse($response, $request);
return $response;
} | php | public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if ($type !== HttpKernelInterface::MASTER_REQUEST && false == $this->container['log_sub_request']) {
// Do not log SUB requests.
return $this->app->handle($request, $type, $catch);
}
$this->logRequest($request);
$response = $this->app->handle($request, $type, $catch);
$this->logResponse($response, $request);
return $response;
} | [
"public",
"function",
"handle",
"(",
"Request",
"$",
"request",
",",
"$",
"type",
"=",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
",",
"$",
"catch",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"type",
"!==",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
"&&"... | {@inheritDoc} | [
"{"
] | train | https://github.com/h4cc/StackLogger/blob/1bdbb3e7d157aa9069ace90267c249f43dc02b77/src/Logger.php#L47-L61 |
h4cc/StackLogger | src/Logger.php | Logger.log | private function log($msg, array $context = array())
{
/** @var \Psr\Log\LoggerInterface $logger */
$logger = $this->container['logger'];
$logger->log($this->container['log_level'], $msg, $context);
} | php | private function log($msg, array $context = array())
{
/** @var \Psr\Log\LoggerInterface $logger */
$logger = $this->container['logger'];
$logger->log($this->container['log_level'], $msg, $context);
} | [
"private",
"function",
"log",
"(",
"$",
"msg",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"/** @var \\Psr\\Log\\LoggerInterface $logger */",
"$",
"logger",
"=",
"$",
"this",
"->",
"container",
"[",
"'logger'",
"]",
";",
"$",
"logger",
... | Logs a message and given context.
@param $msg
@param array $context | [
"Logs",
"a",
"message",
"and",
"given",
"context",
"."
] | train | https://github.com/h4cc/StackLogger/blob/1bdbb3e7d157aa9069ace90267c249f43dc02b77/src/Logger.php#L125-L130 |
makinacorpus/drupal-ucms | ucms_notification/src/EventDispatcher/NotificationContextEventSubscriber.php | NotificationContextEventSubscriber.getSubscribedEvents | static public function getSubscribedEvents()
{
return [
'site:request' => [
['onSiteResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'site:switch' => [
['onSiteResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:add' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:edit' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:publish' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:unpublish' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:flag' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:delete' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:new_labels' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
];
} | php | static public function getSubscribedEvents()
{
return [
'site:request' => [
['onSiteResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'site:switch' => [
['onSiteResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:add' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:edit' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:publish' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:unpublish' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:flag' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:delete' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
'node:new_labels' => [
['onNodeResourceEventAlterChannels', self::DEFAULT_PRIORITY],
],
];
} | [
"static",
"public",
"function",
"getSubscribedEvents",
"(",
")",
"{",
"return",
"[",
"'site:request'",
"=>",
"[",
"[",
"'onSiteResourceEventAlterChannels'",
",",
"self",
"::",
"DEFAULT_PRIORITY",
"]",
",",
"]",
",",
"'site:switch'",
"=>",
"[",
"[",
"'onSiteResourc... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/NotificationContextEventSubscriber.php#L28-L59 |
makinacorpus/drupal-ucms | ucms_notification/src/EventDispatcher/NotificationContextEventSubscriber.php | NotificationContextEventSubscriber.onSiteResourceEventAlterChannels | public function onSiteResourceEventAlterChannels(Event $event)
{
if (!$this->groupManager || !$event instanceof ResourceEvent) {
return;
}
$done = [];
// Fetch site groups, and yes we don't really have a choice here
$sites = $this->siteManager->getStorage()->loadAll($event->getResourceIdList(), false);
foreach ($sites as $site) {
$groupId = (int)$site->getGroupId();
if ($groupId) {
$done[$groupId] = $groupId;
}
}
foreach ($done as $groupId) {
$event->addArbitraryChanId('admin:site:' . $groupId);
}
} | php | public function onSiteResourceEventAlterChannels(Event $event)
{
if (!$this->groupManager || !$event instanceof ResourceEvent) {
return;
}
$done = [];
// Fetch site groups, and yes we don't really have a choice here
$sites = $this->siteManager->getStorage()->loadAll($event->getResourceIdList(), false);
foreach ($sites as $site) {
$groupId = (int)$site->getGroupId();
if ($groupId) {
$done[$groupId] = $groupId;
}
}
foreach ($done as $groupId) {
$event->addArbitraryChanId('admin:site:' . $groupId);
}
} | [
"public",
"function",
"onSiteResourceEventAlterChannels",
"(",
"Event",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"groupManager",
"||",
"!",
"$",
"event",
"instanceof",
"ResourceEvent",
")",
"{",
"return",
";",
"}",
"$",
"done",
"=",
"[",
... | On resource events, if applyable, attempt to alter channels to drop the
global subscription and set it to group channels | [
"On",
"resource",
"events",
"if",
"applyable",
"attempt",
"to",
"alter",
"channels",
"to",
"drop",
"the",
"global",
"subscription",
"and",
"set",
"it",
"to",
"group",
"channels"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/NotificationContextEventSubscriber.php#L90-L110 |
makinacorpus/drupal-ucms | ucms_notification/src/EventDispatcher/NotificationContextEventSubscriber.php | NotificationContextEventSubscriber.onNodeResourceEventAlterChannels | public function onNodeResourceEventAlterChannels(Event $event)
{
if (!$this->groupManager || !$event instanceof ResourceEvent) {
return;
}
$done = [];
// Fetch site groups, and yes we don't really have a choice here
$nodes = $this->entityManager->getStorage('node')->loadMultiple($event->getResourceIdList());
foreach ($nodes as $node) {
if ($node->group_id) {
$groupId = (int)$node->group_id;
$done[$groupId] = $groupId;
}
}
foreach ($done as $groupId) {
$event->addArbitraryChanId('admin:content:' . $groupId);
}
} | php | public function onNodeResourceEventAlterChannels(Event $event)
{
if (!$this->groupManager || !$event instanceof ResourceEvent) {
return;
}
$done = [];
// Fetch site groups, and yes we don't really have a choice here
$nodes = $this->entityManager->getStorage('node')->loadMultiple($event->getResourceIdList());
foreach ($nodes as $node) {
if ($node->group_id) {
$groupId = (int)$node->group_id;
$done[$groupId] = $groupId;
}
}
foreach ($done as $groupId) {
$event->addArbitraryChanId('admin:content:' . $groupId);
}
} | [
"public",
"function",
"onNodeResourceEventAlterChannels",
"(",
"Event",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"groupManager",
"||",
"!",
"$",
"event",
"instanceof",
"ResourceEvent",
")",
"{",
"return",
";",
"}",
"$",
"done",
"=",
"[",
... | On resource events, if applyable, attempt to alter channels to drop the
global subscription and set it to group channels | [
"On",
"resource",
"events",
"if",
"applyable",
"attempt",
"to",
"alter",
"channels",
"to",
"drop",
"the",
"global",
"subscription",
"and",
"set",
"it",
"to",
"group",
"channels"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/NotificationContextEventSubscriber.php#L116-L136 |
TYPO3-Console/typo3-console-plugin | src/Plugin.php | Plugin.listen | public function listen(Event $event)
{
if (!empty($this->handledEvents[$event->getName()])) {
return;
}
$this->handledEvents[$event->getName()] = true;
// Plugin has been uninstalled
if (!file_exists(__FILE__) || !file_exists(__DIR__ . '/PluginImplementation.php')) {
return;
}
// Load the implementation only after updating Composer so that we get
// the new version of the plugin when a new one was installed
if (null === $this->pluginImplementation) {
$this->pluginImplementation = new PluginImplementation($event);
}
switch ($event->getName()) {
case ScriptEvents::PRE_AUTOLOAD_DUMP:
$this->pluginImplementation->preAutoloadDump();
break;
case ScriptEvents::POST_AUTOLOAD_DUMP:
$this->pluginImplementation->postAutoloadDump();
break;
}
} | php | public function listen(Event $event)
{
if (!empty($this->handledEvents[$event->getName()])) {
return;
}
$this->handledEvents[$event->getName()] = true;
// Plugin has been uninstalled
if (!file_exists(__FILE__) || !file_exists(__DIR__ . '/PluginImplementation.php')) {
return;
}
// Load the implementation only after updating Composer so that we get
// the new version of the plugin when a new one was installed
if (null === $this->pluginImplementation) {
$this->pluginImplementation = new PluginImplementation($event);
}
switch ($event->getName()) {
case ScriptEvents::PRE_AUTOLOAD_DUMP:
$this->pluginImplementation->preAutoloadDump();
break;
case ScriptEvents::POST_AUTOLOAD_DUMP:
$this->pluginImplementation->postAutoloadDump();
break;
}
} | [
"public",
"function",
"listen",
"(",
"Event",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"handledEvents",
"[",
"$",
"event",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"hand... | Listens to Composer events.
This method is very minimalist on purpose. We want to load the actual
implementation only after updating the Composer packages so that we get
the updated version (if available).
@param Event $event The Composer event. | [
"Listens",
"to",
"Composer",
"events",
"."
] | train | https://github.com/TYPO3-Console/typo3-console-plugin/blob/4a80b494adb97306bb19a14c72c214be79b5b079/src/Plugin.php#L61-L86 |
makinacorpus/drupal-ucms | ucms_search/src/EventDispatcher/NodeIndexEvent.php | NodeIndexEvent.fieldToFulltext | public function fieldToFulltext($name, $target = self::FIELD_BODY)
{
if (field_get_items('node', $this->node, $name)) {
$build = field_view_field('node', $this->node, $name, 'full');
$this->add($target, drupal_render($build));
}
} | php | public function fieldToFulltext($name, $target = self::FIELD_BODY)
{
if (field_get_items('node', $this->node, $name)) {
$build = field_view_field('node', $this->node, $name, 'full');
$this->add($target, drupal_render($build));
}
} | [
"public",
"function",
"fieldToFulltext",
"(",
"$",
"name",
",",
"$",
"target",
"=",
"self",
"::",
"FIELD_BODY",
")",
"{",
"if",
"(",
"field_get_items",
"(",
"'node'",
",",
"$",
"this",
"->",
"node",
",",
"$",
"name",
")",
")",
"{",
"$",
"build",
"=",... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/EventDispatcher/NodeIndexEvent.php#L57-L64 |
makinacorpus/drupal-ucms | ucms_search/src/EventDispatcher/NodeIndexEvent.php | NodeIndexEvent.fieldToTagIdList | public function fieldToTagIdList($name, $target = self::FIELD_TAGS)
{
if ($items = field_get_items('node', $this->node, $name)) {
foreach ($items as $item) {
if (isset($item['tid'])) {
$this->add($target, (int)$item['tid']);
}
}
}
} | php | public function fieldToTagIdList($name, $target = self::FIELD_TAGS)
{
if ($items = field_get_items('node', $this->node, $name)) {
foreach ($items as $item) {
if (isset($item['tid'])) {
$this->add($target, (int)$item['tid']);
}
}
}
} | [
"public",
"function",
"fieldToTagIdList",
"(",
"$",
"name",
",",
"$",
"target",
"=",
"self",
"::",
"FIELD_TAGS",
")",
"{",
"if",
"(",
"$",
"items",
"=",
"field_get_items",
"(",
"'node'",
",",
"$",
"this",
"->",
"node",
",",
"$",
"name",
")",
")",
"{"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/EventDispatcher/NodeIndexEvent.php#L69-L78 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Media/Standard.php | Standard.deleteItems | public function deleteItems( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$idList = [];
$context = $this->getContext();
$manager = \Aimeos\MShop\Factory::createManager( $context, 'media' );
$cntl = \Aimeos\Controller\Common\Media\Factory::createController( $context );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'media.id', (array) $params->items ) );
$search->setSlice( 0, count( (array) $params->items ) );
foreach( $manager->searchItems( $search ) as $id => $item )
{
$idList[$item->getDomain()][] = $id;
$cntl->delete( $item );
}
$manager->deleteItems( (array) $params->items );
foreach( $idList as $domain => $domainIds )
{
$manager = \Aimeos\MShop\Factory::createManager( $context, $domain . '/lists' );
$search = $manager->createSearch();
$expr = array(
$search->compare( '==', $domain . '.lists.refid', $domainIds ),
$search->compare( '==', $domain . '.lists.domain', 'media' )
);
$search->setConditions( $search->combine( '&&', $expr ) );
$search->setSortations( array( $search->sort( '+', $domain . '.lists.id' ) ) );
$start = 0;
do
{
$result = $manager->searchItems( $search );
$manager->deleteItems( array_keys( $result ) );
$count = count( $result );
$start += $count;
$search->setSlice( $start );
}
while( $count >= $search->getSliceSize() );
}
$this->clearCache( (array) $params->items );
return array(
'success' => true,
);
} | php | public function deleteItems( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$idList = [];
$context = $this->getContext();
$manager = \Aimeos\MShop\Factory::createManager( $context, 'media' );
$cntl = \Aimeos\Controller\Common\Media\Factory::createController( $context );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'media.id', (array) $params->items ) );
$search->setSlice( 0, count( (array) $params->items ) );
foreach( $manager->searchItems( $search ) as $id => $item )
{
$idList[$item->getDomain()][] = $id;
$cntl->delete( $item );
}
$manager->deleteItems( (array) $params->items );
foreach( $idList as $domain => $domainIds )
{
$manager = \Aimeos\MShop\Factory::createManager( $context, $domain . '/lists' );
$search = $manager->createSearch();
$expr = array(
$search->compare( '==', $domain . '.lists.refid', $domainIds ),
$search->compare( '==', $domain . '.lists.domain', 'media' )
);
$search->setConditions( $search->combine( '&&', $expr ) );
$search->setSortations( array( $search->sort( '+', $domain . '.lists.id' ) ) );
$start = 0;
do
{
$result = $manager->searchItems( $search );
$manager->deleteItems( array_keys( $result ) );
$count = count( $result );
$start += $count;
$search->setSlice( $start );
}
while( $count >= $search->getSliceSize() );
}
$this->clearCache( (array) $params->items );
return array(
'success' => true,
);
} | [
"public",
"function",
"deleteItems",
"(",
"\\",
"stdClass",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"checkParams",
"(",
"$",
"params",
",",
"array",
"(",
"'site'",
",",
"'items'",
")",
")",
";",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"params",
... | Deletes an item or a list of items.
@param \stdClass $params Associative list of parameters
@return array Associative list with success value | [
"Deletes",
"an",
"item",
"or",
"a",
"list",
"of",
"items",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Media/Standard.php#L45-L100 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Media/Standard.php | Standard.uploadItem | public function uploadItem( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'domain' ) );
$this->setLocale( $params->site );
$context = $this->getContext();
$manager = \Aimeos\MShop\Factory::createManager( $context, 'media' );
$typeManager = \Aimeos\MShop\Factory::createManager( $context, 'media/type' );
$item = $manager->createItem();
$item->setTypeId( $typeManager->findItem( 'default', [], 'product' )->getId() );
$item->setDomain( 'product' );
$item->setStatus( 1 );
$file = $this->getUploadedFile();
\Aimeos\Controller\Common\Media\Factory::createController( $context )->add( $item, $file );
$item = $manager->saveItem( $item );
return (object) $item->toArray( true );
} | php | public function uploadItem( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'domain' ) );
$this->setLocale( $params->site );
$context = $this->getContext();
$manager = \Aimeos\MShop\Factory::createManager( $context, 'media' );
$typeManager = \Aimeos\MShop\Factory::createManager( $context, 'media/type' );
$item = $manager->createItem();
$item->setTypeId( $typeManager->findItem( 'default', [], 'product' )->getId() );
$item->setDomain( 'product' );
$item->setStatus( 1 );
$file = $this->getUploadedFile();
\Aimeos\Controller\Common\Media\Factory::createController( $context )->add( $item, $file );
$item = $manager->saveItem( $item );
return (object) $item->toArray( true );
} | [
"public",
"function",
"uploadItem",
"(",
"\\",
"stdClass",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"checkParams",
"(",
"$",
"params",
",",
"array",
"(",
"'site'",
",",
"'domain'",
")",
")",
";",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"params",
... | Stores an uploaded file
@param \stdClass $params Associative list of parameters
@return \stdClass Object with success value
@throws \Aimeos\Controller\ExtJS\Exception If an error occurs | [
"Stores",
"an",
"uploaded",
"file"
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Media/Standard.php#L110-L130 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Media/Standard.php | Standard.getUploadedFile | protected function getUploadedFile()
{
$files = $this->getContext()->getView()->request()->getUploadedFiles();
if( ( $file = reset( $files ) ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'No file was uploaded' );
}
return $file;
} | php | protected function getUploadedFile()
{
$files = $this->getContext()->getView()->request()->getUploadedFiles();
if( ( $file = reset( $files ) ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'No file was uploaded' );
}
return $file;
} | [
"protected",
"function",
"getUploadedFile",
"(",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
"->",
"getView",
"(",
")",
"->",
"request",
"(",
")",
"->",
"getUploadedFiles",
"(",
")",
";",
"if",
"(",
"(",
"$",
"file",
"=",
... | Returns the PHP file information of the uploaded file
@return Psr\Http\Message\UploadedFileInterface Uploaded file
@throws \Aimeos\Controller\ExtJS\Exception If no file upload is available | [
"Returns",
"the",
"PHP",
"file",
"information",
"of",
"the",
"uploaded",
"file"
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Media/Standard.php#L215-L224 |
qloog/yaf-library | src/Validators/CompareValidator.php | CompareValidator.validator | public function validator($field, array $data)
{
$value = isset($data[$field]) ? $data[$field] : null;
$targetValue = isset($data[$this->target]) ? $data[$this->target] : null;
if ($value === $targetValue) {
return true;
}
return $this->message('{fieldName}与{targetName}不相等!', [
'{fieldName}' => $this->getName($field),
'{targetName}' => $this->getName($this->target),
]);
} | php | public function validator($field, array $data)
{
$value = isset($data[$field]) ? $data[$field] : null;
$targetValue = isset($data[$this->target]) ? $data[$this->target] : null;
if ($value === $targetValue) {
return true;
}
return $this->message('{fieldName}与{targetName}不相等!', [
'{fieldName}' => $this->getName($field),
'{targetName}' => $this->getName($this->target),
]);
} | [
"public",
"function",
"validator",
"(",
"$",
"field",
",",
"array",
"$",
"data",
")",
"{",
"$",
"value",
"=",
"isset",
"(",
"$",
"data",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"field",
"]",
":",
"null",
";",
"$",
"targetValue",
... | 验证
@param string $field
@param array $data
@return bool|string | [
"验证"
] | train | https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Validators/CompareValidator.php#L24-L36 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.asXml | public function asXml(Shopgate_Model_XmlResultObject $itemsNode)
{
/**
* global info
*
* @var $itemNode Shopgate_Model_XmlResultObject
*/
$itemNode = $itemsNode->addChild(self::DEFAULT_ITEM_IDENTIFIER);
$itemNode->addAttribute('uid', $this->getUid());
$itemNode->addAttribute('last_update', $this->getLastUpdate());
$itemNode->addChildWithCDATA('name', $this->getName());
$itemNode->addChild('tax_percent', $this->getTaxPercent(), null, false);
$itemNode->addChildWithCDATA('tax_class', $this->getTaxClass(), false);
$itemNode->addChild('currency', $this->getCurrency());
$itemNode->addChildWithCDATA('description', $this->getDescription());
$itemNode->addChildWithCDATA('deeplink', $this->getDeeplink());
$itemNode->addChild('promotion')->addAttribute('sort_order', $this->getPromotionSortOrder());
$itemNode->addChildWithCDATA('internal_order_info', $this->getInternalOrderInfo());
$itemNode->addChild('age_rating', $this->getAgeRating(), null, false);
$itemNode->addChild('weight', $this->getWeight())->addAttribute('unit', $this->getWeightUnit());
/**
* is default child
*/
if ($this->getIsChild()) {
$itemNode->addAttribute('default_child', $this->getIsDefaultChild());
}
/**
* prices / tier prices
*/
$this->getPrice()->asXml($itemNode);
/**
* images
*
* @var Shopgate_Model_XmlResultObject $imagesNode
* @var Shopgate_Model_Media_Image $imageItem
*/
$imagesNode = $itemNode->addChild('images');
foreach ($this->getImages() as $imageItem) {
$imageItem->asXml($imagesNode);
}
/**
* categories
*
* @var Shopgate_Model_XmlResultObject $categoryPathNode
* @var Shopgate_Model_Catalog_CategoryPath $categoryPathItem
*/
$categoryPathNode = $itemNode->addChild('categories');
foreach ($this->getCategoryPaths() as $categoryPathItem) {
$categoryPathItem->asXml($categoryPathNode);
}
/**
* shipping
*/
$this->getShipping()->asXml($itemNode);
/**
* manufacture
*/
$this->getManufacturer()->asXml($itemNode);
/**
* visibility
*/
$this->getVisibility()->asXml($itemNode);
/**
* properties
*
* @var Shopgate_Model_XmlResultObject $propertiesNode
* @var Shopgate_Model_Catalog_Property $propertyItem
*/
$propertiesNode = $itemNode->addChild('properties');
foreach ($this->getProperties() as $propertyItem) {
$propertyItem->asXml($propertiesNode);
}
/**
* stock
*/
$this->getStock()->asXml($itemNode);
/**
* identifiers
*
* @var Shopgate_Model_XmlResultObject $identifiersNode
* @var Shopgate_Model_Catalog_Identifier $identifierItem
*/
$identifiersNode = $itemNode->addChild('identifiers');
foreach ($this->getIdentifiers() as $identifierItem) {
$identifierItem->asXml($identifiersNode);
}
/**
* tags
*
* @var Shopgate_Model_XmlResultObject $tagsNode
* @var Shopgate_Model_Catalog_Tag $tagItem
*/
$tagsNode = $itemNode->addChild('tags');
foreach ($this->getTags() as $tagItem) {
$tagItem->asXml($tagsNode);
}
/**
* relations
*
* @var Shopgate_Model_XmlResultObject $relationsNode
* @var Shopgate_Model_Catalog_Relation $relationItem
*/
$relationsNode = $itemNode->addChild('relations');
foreach ($this->getRelations() as $relationItem) {
$relationItem->asXml($relationsNode);
}
/**
* attribute / options
*
* @var Shopgate_Model_XmlResultObject $attributeGroupsNode
* @var Shopgate_Model_XmlResultObject $attributesNode
* @var Shopgate_Model_Catalog_Attribute $attributeItem
* @var Shopgate_Model_Catalog_AttributeGroup $attributeGroupItem
*/
if ($this->getIsChild()) {
$attributesNode = $itemNode->addChild('attributes');
foreach ($this->getAttributes() as $attributeItem) {
$attributeItem->asXml($attributesNode);
}
} else {
$attributeGroupsNode = $itemNode->addChild('attribute_groups');
foreach ($this->getAttributeGroups() as $attributeGroupItem) {
$attributeGroupItem->asXml($attributeGroupsNode);
}
}
/**
* inputs
*
* @var Shopgate_Model_XmlResultObject $inputsNode
* @var Shopgate_Model_Catalog_Input $inputItem
*/
$inputsNode = $itemNode->addChild('inputs');
foreach ($this->getInputs() as $inputItem) {
$inputItem->asXml($inputsNode);
}
$itemNode->addChild('display_type', $this->getDisplayType());
/**
* children
*
* @var Shopgate_Model_XmlResultObject $childrenNode
* @var object $itemNode ->children
* @var Shopgate_Model_Catalog_Product $child
* @var Shopgate_Model_XmlResultObject $childXml
*/
if (!$this->getIsChild()) {
$childrenNode = $itemNode->addChild('children');
foreach ($this->getChildren() as $child) {
$child->asXml($childrenNode);
}
/**
* remove empty nodes
*/
if (self::DEFAULT_CLEAN_CHILDREN_NODES && count($this->getChildren()) > 0) {
foreach ($itemNode->children as $childXml) {
$itemNode->replaceChild($this->removeEmptyNodes($childXml), $itemNode->children);
}
}
}
return $itemsNode;
} | php | public function asXml(Shopgate_Model_XmlResultObject $itemsNode)
{
/**
* global info
*
* @var $itemNode Shopgate_Model_XmlResultObject
*/
$itemNode = $itemsNode->addChild(self::DEFAULT_ITEM_IDENTIFIER);
$itemNode->addAttribute('uid', $this->getUid());
$itemNode->addAttribute('last_update', $this->getLastUpdate());
$itemNode->addChildWithCDATA('name', $this->getName());
$itemNode->addChild('tax_percent', $this->getTaxPercent(), null, false);
$itemNode->addChildWithCDATA('tax_class', $this->getTaxClass(), false);
$itemNode->addChild('currency', $this->getCurrency());
$itemNode->addChildWithCDATA('description', $this->getDescription());
$itemNode->addChildWithCDATA('deeplink', $this->getDeeplink());
$itemNode->addChild('promotion')->addAttribute('sort_order', $this->getPromotionSortOrder());
$itemNode->addChildWithCDATA('internal_order_info', $this->getInternalOrderInfo());
$itemNode->addChild('age_rating', $this->getAgeRating(), null, false);
$itemNode->addChild('weight', $this->getWeight())->addAttribute('unit', $this->getWeightUnit());
/**
* is default child
*/
if ($this->getIsChild()) {
$itemNode->addAttribute('default_child', $this->getIsDefaultChild());
}
/**
* prices / tier prices
*/
$this->getPrice()->asXml($itemNode);
/**
* images
*
* @var Shopgate_Model_XmlResultObject $imagesNode
* @var Shopgate_Model_Media_Image $imageItem
*/
$imagesNode = $itemNode->addChild('images');
foreach ($this->getImages() as $imageItem) {
$imageItem->asXml($imagesNode);
}
/**
* categories
*
* @var Shopgate_Model_XmlResultObject $categoryPathNode
* @var Shopgate_Model_Catalog_CategoryPath $categoryPathItem
*/
$categoryPathNode = $itemNode->addChild('categories');
foreach ($this->getCategoryPaths() as $categoryPathItem) {
$categoryPathItem->asXml($categoryPathNode);
}
/**
* shipping
*/
$this->getShipping()->asXml($itemNode);
/**
* manufacture
*/
$this->getManufacturer()->asXml($itemNode);
/**
* visibility
*/
$this->getVisibility()->asXml($itemNode);
/**
* properties
*
* @var Shopgate_Model_XmlResultObject $propertiesNode
* @var Shopgate_Model_Catalog_Property $propertyItem
*/
$propertiesNode = $itemNode->addChild('properties');
foreach ($this->getProperties() as $propertyItem) {
$propertyItem->asXml($propertiesNode);
}
/**
* stock
*/
$this->getStock()->asXml($itemNode);
/**
* identifiers
*
* @var Shopgate_Model_XmlResultObject $identifiersNode
* @var Shopgate_Model_Catalog_Identifier $identifierItem
*/
$identifiersNode = $itemNode->addChild('identifiers');
foreach ($this->getIdentifiers() as $identifierItem) {
$identifierItem->asXml($identifiersNode);
}
/**
* tags
*
* @var Shopgate_Model_XmlResultObject $tagsNode
* @var Shopgate_Model_Catalog_Tag $tagItem
*/
$tagsNode = $itemNode->addChild('tags');
foreach ($this->getTags() as $tagItem) {
$tagItem->asXml($tagsNode);
}
/**
* relations
*
* @var Shopgate_Model_XmlResultObject $relationsNode
* @var Shopgate_Model_Catalog_Relation $relationItem
*/
$relationsNode = $itemNode->addChild('relations');
foreach ($this->getRelations() as $relationItem) {
$relationItem->asXml($relationsNode);
}
/**
* attribute / options
*
* @var Shopgate_Model_XmlResultObject $attributeGroupsNode
* @var Shopgate_Model_XmlResultObject $attributesNode
* @var Shopgate_Model_Catalog_Attribute $attributeItem
* @var Shopgate_Model_Catalog_AttributeGroup $attributeGroupItem
*/
if ($this->getIsChild()) {
$attributesNode = $itemNode->addChild('attributes');
foreach ($this->getAttributes() as $attributeItem) {
$attributeItem->asXml($attributesNode);
}
} else {
$attributeGroupsNode = $itemNode->addChild('attribute_groups');
foreach ($this->getAttributeGroups() as $attributeGroupItem) {
$attributeGroupItem->asXml($attributeGroupsNode);
}
}
/**
* inputs
*
* @var Shopgate_Model_XmlResultObject $inputsNode
* @var Shopgate_Model_Catalog_Input $inputItem
*/
$inputsNode = $itemNode->addChild('inputs');
foreach ($this->getInputs() as $inputItem) {
$inputItem->asXml($inputsNode);
}
$itemNode->addChild('display_type', $this->getDisplayType());
/**
* children
*
* @var Shopgate_Model_XmlResultObject $childrenNode
* @var object $itemNode ->children
* @var Shopgate_Model_Catalog_Product $child
* @var Shopgate_Model_XmlResultObject $childXml
*/
if (!$this->getIsChild()) {
$childrenNode = $itemNode->addChild('children');
foreach ($this->getChildren() as $child) {
$child->asXml($childrenNode);
}
/**
* remove empty nodes
*/
if (self::DEFAULT_CLEAN_CHILDREN_NODES && count($this->getChildren()) > 0) {
foreach ($itemNode->children as $childXml) {
$itemNode->replaceChild($this->removeEmptyNodes($childXml), $itemNode->children);
}
}
}
return $itemsNode;
} | [
"public",
"function",
"asXml",
"(",
"Shopgate_Model_XmlResultObject",
"$",
"itemsNode",
")",
"{",
"/**\n * global info\n *\n * @var $itemNode Shopgate_Model_XmlResultObject\n */",
"$",
"itemNode",
"=",
"$",
"itemsNode",
"->",
"addChild",
"(",
"self... | generate xml result object
@param Shopgate_Model_XmlResultObject $itemsNode
@return Shopgate_Model_XmlResultObject | [
"generate",
"xml",
"result",
"object"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L312-L489 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addImage | public function addImage(Shopgate_Model_Media_Image $image)
{
$images = $this->getImages();
array_push($images, $image);
$this->setImages($images);
} | php | public function addImage(Shopgate_Model_Media_Image $image)
{
$images = $this->getImages();
array_push($images, $image);
$this->setImages($images);
} | [
"public",
"function",
"addImage",
"(",
"Shopgate_Model_Media_Image",
"$",
"image",
")",
"{",
"$",
"images",
"=",
"$",
"this",
"->",
"getImages",
"(",
")",
";",
"array_push",
"(",
"$",
"images",
",",
"$",
"image",
")",
";",
"$",
"this",
"->",
"setImages",... | add image
@param Shopgate_Model_Media_Image $image | [
"add",
"image"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L496-L501 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addChild | public function addChild($child)
{
$children = $this->getChildren();
array_push($children, $child);
$this->setChildren($children);
} | php | public function addChild($child)
{
$children = $this->getChildren();
array_push($children, $child);
$this->setChildren($children);
} | [
"public",
"function",
"addChild",
"(",
"$",
"child",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"getChildren",
"(",
")",
";",
"array_push",
"(",
"$",
"children",
",",
"$",
"child",
")",
";",
"$",
"this",
"->",
"setChildren",
"(",
"$",
"childr... | add child
@param Shopgate_Model_Catalog_Product $child | [
"add",
"child"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L508-L513 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addCategoryPath | public function addCategoryPath(Shopgate_Model_Catalog_CategoryPath $categoryPath)
{
$categoryPaths = $this->getCategoryPaths();
array_push($categoryPaths, $categoryPath);
$this->setCategoryPaths($categoryPaths);
} | php | public function addCategoryPath(Shopgate_Model_Catalog_CategoryPath $categoryPath)
{
$categoryPaths = $this->getCategoryPaths();
array_push($categoryPaths, $categoryPath);
$this->setCategoryPaths($categoryPaths);
} | [
"public",
"function",
"addCategoryPath",
"(",
"Shopgate_Model_Catalog_CategoryPath",
"$",
"categoryPath",
")",
"{",
"$",
"categoryPaths",
"=",
"$",
"this",
"->",
"getCategoryPaths",
"(",
")",
";",
"array_push",
"(",
"$",
"categoryPaths",
",",
"$",
"categoryPath",
... | add category
@param Shopgate_Model_Catalog_CategoryPath $categoryPath | [
"add",
"category"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L534-L539 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addAttributeGroup | public function addAttributeGroup($attributeGroup)
{
$attributesGroups = $this->getAttributeGroups();
array_push($attributesGroups, $attributeGroup);
$this->setAttributeGroups($attributesGroups);
} | php | public function addAttributeGroup($attributeGroup)
{
$attributesGroups = $this->getAttributeGroups();
array_push($attributesGroups, $attributeGroup);
$this->setAttributeGroups($attributesGroups);
} | [
"public",
"function",
"addAttributeGroup",
"(",
"$",
"attributeGroup",
")",
"{",
"$",
"attributesGroups",
"=",
"$",
"this",
"->",
"getAttributeGroups",
"(",
")",
";",
"array_push",
"(",
"$",
"attributesGroups",
",",
"$",
"attributeGroup",
")",
";",
"$",
"this"... | add attribute group
@param Shopgate_Model_Catalog_AttributeGroup $attributeGroup | [
"add",
"attribute",
"group"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L546-L551 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addProperty | public function addProperty($property)
{
$properties = $this->getProperties();
array_push($properties, $property);
$this->setProperties($properties);
} | php | public function addProperty($property)
{
$properties = $this->getProperties();
array_push($properties, $property);
$this->setProperties($properties);
} | [
"public",
"function",
"addProperty",
"(",
"$",
"property",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getProperties",
"(",
")",
";",
"array_push",
"(",
"$",
"properties",
",",
"$",
"property",
")",
";",
"$",
"this",
"->",
"setProperties",
"(",... | add property
@param Shopgate_Model_Catalog_Property $property | [
"add",
"property"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L558-L563 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addIdentifier | public function addIdentifier($identifier)
{
$identifiers = $this->getIdentifiers();
array_push($identifiers, $identifier);
$this->setIdentifiers($identifiers);
} | php | public function addIdentifier($identifier)
{
$identifiers = $this->getIdentifiers();
array_push($identifiers, $identifier);
$this->setIdentifiers($identifiers);
} | [
"public",
"function",
"addIdentifier",
"(",
"$",
"identifier",
")",
"{",
"$",
"identifiers",
"=",
"$",
"this",
"->",
"getIdentifiers",
"(",
")",
";",
"array_push",
"(",
"$",
"identifiers",
",",
"$",
"identifier",
")",
";",
"$",
"this",
"->",
"setIdentifier... | add identifier
@param Shopgate_Model_Catalog_Identifier $identifier | [
"add",
"identifier"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L570-L575 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addTag | public function addTag($tag)
{
$tags = $this->getTags();
array_push($tags, $tag);
$this->setTags($tags);
} | php | public function addTag($tag)
{
$tags = $this->getTags();
array_push($tags, $tag);
$this->setTags($tags);
} | [
"public",
"function",
"addTag",
"(",
"$",
"tag",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"getTags",
"(",
")",
";",
"array_push",
"(",
"$",
"tags",
",",
"$",
"tag",
")",
";",
"$",
"this",
"->",
"setTags",
"(",
"$",
"tags",
")",
";",
"}"
] | add tag
@param Shopgate_Model_Catalog_Tag $tag | [
"add",
"tag"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L582-L587 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addRelation | public function addRelation($relation)
{
$relations = $this->getRelations();
array_push($relations, $relation);
$this->setRelations($relations);
} | php | public function addRelation($relation)
{
$relations = $this->getRelations();
array_push($relations, $relation);
$this->setRelations($relations);
} | [
"public",
"function",
"addRelation",
"(",
"$",
"relation",
")",
"{",
"$",
"relations",
"=",
"$",
"this",
"->",
"getRelations",
"(",
")",
";",
"array_push",
"(",
"$",
"relations",
",",
"$",
"relation",
")",
";",
"$",
"this",
"->",
"setRelations",
"(",
"... | add relation
@param Shopgate_Model_Catalog_Relation $relation | [
"add",
"relation"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L594-L599 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addInput | public function addInput($input)
{
$inputs = $this->getInputs();
array_push($inputs, $input);
$this->setInputs($inputs);
} | php | public function addInput($input)
{
$inputs = $this->getInputs();
array_push($inputs, $input);
$this->setInputs($inputs);
} | [
"public",
"function",
"addInput",
"(",
"$",
"input",
")",
"{",
"$",
"inputs",
"=",
"$",
"this",
"->",
"getInputs",
"(",
")",
";",
"array_push",
"(",
"$",
"inputs",
",",
"$",
"input",
")",
";",
"$",
"this",
"->",
"setInputs",
"(",
"$",
"inputs",
")"... | add input
@param Shopgate_Model_Catalog_Input $input | [
"add",
"input"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L606-L611 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.addAttribute | public function addAttribute($attribute)
{
$attributes = $this->getAttributes();
array_push($attributes, $attribute);
$this->setAttributes($attributes);
} | php | public function addAttribute($attribute)
{
$attributes = $this->getAttributes();
array_push($attributes, $attribute);
$this->setAttributes($attributes);
} | [
"public",
"function",
"addAttribute",
"(",
"$",
"attribute",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
")",
";",
"array_push",
"(",
"$",
"attributes",
",",
"$",
"attribute",
")",
";",
"$",
"this",
"->",
"setAttributes",
"... | add attribute option
@param Shopgate_Model_Catalog_Attribute $attribute | [
"add",
"attribute",
"option"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L618-L623 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.removeEmptyNodes | public function removeEmptyNodes($childItem)
{
$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$doc->loadXML($childItem->asXML());
$xpath = new DOMXPath($doc);
$xpQuery = '//*[not(@forceEmpty) and not(descendant::*[@forceEmpty]) and normalize-space() = ""]';
/** @var DOMElement $node */
foreach ($xpath->query($xpQuery) as $node) {
$node->parentNode->removeChild($node);
}
foreach ($xpath->query('//*[@forceEmpty]') as $node) {
$node->removeAttribute('forceEmpty');
}
return simplexml_import_dom($doc);
} | php | public function removeEmptyNodes($childItem)
{
$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$doc->loadXML($childItem->asXML());
$xpath = new DOMXPath($doc);
$xpQuery = '//*[not(@forceEmpty) and not(descendant::*[@forceEmpty]) and normalize-space() = ""]';
/** @var DOMElement $node */
foreach ($xpath->query($xpQuery) as $node) {
$node->parentNode->removeChild($node);
}
foreach ($xpath->query('//*[@forceEmpty]') as $node) {
$node->removeAttribute('forceEmpty');
}
return simplexml_import_dom($doc);
} | [
"public",
"function",
"removeEmptyNodes",
"(",
"$",
"childItem",
")",
"{",
"$",
"doc",
"=",
"new",
"DOMDocument",
";",
"$",
"doc",
"->",
"preserveWhiteSpace",
"=",
"false",
";",
"$",
"doc",
"->",
"loadXML",
"(",
"$",
"childItem",
"->",
"asXML",
"(",
")",... | @param Shopgate_Model_XmlResultObject $childItem
@return SimpleXMLElement | [
"@param",
"Shopgate_Model_XmlResultObject",
"$childItem"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L630-L649 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.asArray | public function asArray()
{
$productResult = new Shopgate_Model_Abstract();
$productResult->setData('uid', $this->getUid());
$productResult->setData('last_update', $this->getLastUpdate());
$productResult->setData('name', $this->getName());
$productResult->setData('tax_percent', $this->getTaxPercent());
$productResult->setData('tax_class', $this->getTaxClass());
$productResult->setData('currency', $this->getCurrency());
$productResult->setData('description', $this->getDescription());
$productResult->setData('deeplink', $this->getDeeplink());
$productResult->setData('promotion_sort_order', $this->getPromotionSortOrder());
$productResult->setData('internal_order_info', $this->getInternalOrderInfo());
$productResult->setData('age_rating', $this->getAgeRating());
$productResult->setData('weight', $this->getWeight());
$productResult->setData('weight_unit', $this->getWeightUnit());
$productResult->setData('display_type', $this->getDisplayType());
//prices
/**
* images
*
* @var Shopgate_Model_Media_Image $image
*/
$imagesData = array();
foreach ($this->getImages() as $image) {
array_push($imagesData, $image->asArray());
}
$productResult->setData('images', $imagesData);
/**
* category paths
*
* @var Shopgate_Model_Catalog_CategoryPath $categoryPath
*/
$categoryPathsData = array();
foreach ($this->getCategoryPaths() as $categoryPath) {
array_push($categoryPathsData, $categoryPath->asArray());
}
$productResult->setData('categories', $categoryPathsData);
/**
* shipping
*/
$productResult->setData('shipping', $this->getShipping()->asArray());
/**
* manufacturer
*/
$productResult->setData('manufacturer', $this->getManufacturer()->asArray());
/**
* visibility
*/
$productResult->setData('visibility', $this->getVisibility()->asArray());
/**
* properties
*
* @var Shopgate_Model_Catalog_Property $property
*/
$propertiesData = array();
foreach ($this->getProperties() as $property) {
array_push($propertiesData, $property->asArray());
}
$productResult->setData('properties', $propertiesData);
/**
* stock
*/
$productResult->setData('stock', $this->getStock()->asArray());
/**
* identifiers
*
* @var Shopgate_Model_Catalog_Identifier $identifier
*/
$identifiersData = array();
foreach ($this->getIdentifiers() as $identifier) {
array_push($identifiersData, $identifier->asArray());
}
$productResult->setData('identifiers', $identifiersData);
/**
* tags
*
* @var Shopgate_Model_Catalog_Tag $tag
*/
$tagsData = array();
foreach ($this->getTags() as $tag) {
array_push($tagsData, $tag->asArray());
}
$productResult->setData('tags', $tagsData);
return $productResult->getData();
} | php | public function asArray()
{
$productResult = new Shopgate_Model_Abstract();
$productResult->setData('uid', $this->getUid());
$productResult->setData('last_update', $this->getLastUpdate());
$productResult->setData('name', $this->getName());
$productResult->setData('tax_percent', $this->getTaxPercent());
$productResult->setData('tax_class', $this->getTaxClass());
$productResult->setData('currency', $this->getCurrency());
$productResult->setData('description', $this->getDescription());
$productResult->setData('deeplink', $this->getDeeplink());
$productResult->setData('promotion_sort_order', $this->getPromotionSortOrder());
$productResult->setData('internal_order_info', $this->getInternalOrderInfo());
$productResult->setData('age_rating', $this->getAgeRating());
$productResult->setData('weight', $this->getWeight());
$productResult->setData('weight_unit', $this->getWeightUnit());
$productResult->setData('display_type', $this->getDisplayType());
//prices
/**
* images
*
* @var Shopgate_Model_Media_Image $image
*/
$imagesData = array();
foreach ($this->getImages() as $image) {
array_push($imagesData, $image->asArray());
}
$productResult->setData('images', $imagesData);
/**
* category paths
*
* @var Shopgate_Model_Catalog_CategoryPath $categoryPath
*/
$categoryPathsData = array();
foreach ($this->getCategoryPaths() as $categoryPath) {
array_push($categoryPathsData, $categoryPath->asArray());
}
$productResult->setData('categories', $categoryPathsData);
/**
* shipping
*/
$productResult->setData('shipping', $this->getShipping()->asArray());
/**
* manufacturer
*/
$productResult->setData('manufacturer', $this->getManufacturer()->asArray());
/**
* visibility
*/
$productResult->setData('visibility', $this->getVisibility()->asArray());
/**
* properties
*
* @var Shopgate_Model_Catalog_Property $property
*/
$propertiesData = array();
foreach ($this->getProperties() as $property) {
array_push($propertiesData, $property->asArray());
}
$productResult->setData('properties', $propertiesData);
/**
* stock
*/
$productResult->setData('stock', $this->getStock()->asArray());
/**
* identifiers
*
* @var Shopgate_Model_Catalog_Identifier $identifier
*/
$identifiersData = array();
foreach ($this->getIdentifiers() as $identifier) {
array_push($identifiersData, $identifier->asArray());
}
$productResult->setData('identifiers', $identifiersData);
/**
* tags
*
* @var Shopgate_Model_Catalog_Tag $tag
*/
$tagsData = array();
foreach ($this->getTags() as $tag) {
array_push($tagsData, $tag->asArray());
}
$productResult->setData('tags', $tagsData);
return $productResult->getData();
} | [
"public",
"function",
"asArray",
"(",
")",
"{",
"$",
"productResult",
"=",
"new",
"Shopgate_Model_Abstract",
"(",
")",
";",
"$",
"productResult",
"->",
"setData",
"(",
"'uid'",
",",
"$",
"this",
"->",
"getUid",
"(",
")",
")",
";",
"$",
"productResult",
"... | generate json result object
@return array | [
"generate",
"json",
"result",
"object"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L656-L753 |
shopgate/cart-integration-sdk | src/models/catalog/Product.php | Shopgate_Model_Catalog_Product.getItemByUid | protected function getItemByUid($data, $uid)
{
/* @var Shopgate_Model_Abstract $item */
foreach ($data as $item) {
if ($item->getData(self::DEFAULT_IDENTIFIER_UID) == $uid) {
return $item;
}
}
return false;
} | php | protected function getItemByUid($data, $uid)
{
/* @var Shopgate_Model_Abstract $item */
foreach ($data as $item) {
if ($item->getData(self::DEFAULT_IDENTIFIER_UID) == $uid) {
return $item;
}
}
return false;
} | [
"protected",
"function",
"getItemByUid",
"(",
"$",
"data",
",",
"$",
"uid",
")",
"{",
"/* @var Shopgate_Model_Abstract $item */",
"foreach",
"(",
"$",
"data",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"getData",
"(",
"self",
"::",
"DEFAULT... | @param array $data
@param int $uid
@return mixed | [
"@param",
"array",
"$data",
"@param",
"int",
"$uid"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Product.php#L809-L819 |
qloog/yaf-library | src/Views/Adapter/TwigAdapter.php | TwigAdapter.assign | public function assign($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->variables[$k] = $v;
}
} else {
$this->variables[$name] = $value;
}
} | php | public function assign($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->variables[$k] = $v;
}
} else {
$this->variables[$name] = $value;
}
} | [
"public",
"function",
"assign",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"foreach",
"(",
"$",
"name",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"var... | If $name is a k=>v array, it will assign it to template
@param string | array $name
@param mixed $value
@return bool | [
"If",
"$name",
"is",
"a",
"k",
"=",
">",
"v",
"array",
"it",
"will",
"assign",
"it",
"to",
"template"
] | train | https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Views/Adapter/TwigAdapter.php#L80-L89 |
kelixlabs/KelixNetTools | src/Network.php | Network.getMac | public function getMac() {
$macAddr = '00:00:00:00:00:00';
$host = escapeshellcmd($this->ip);
$ping = new Ping($host);
if ($ping->ping()) {
// Exec string for Windows-based systems.
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
// -a = Display current ARP entries by introgating current protocol data.
$exec_string = 'arp -a ' . $host;
exec($exec_string, $output, $return);
// $lines=explode("\n", $output);
#look for the output line describing our IP address
foreach($output as $line)
{
$cols=preg_split('/\s+/', trim($line));
if (trim($cols[0])==$this->ip)
{
$macAddr=str_replace('-', ':', $cols[1]);
}
}
}
// Exec string for UNIX-based systems (Mac, Linux).
else {
// -n = Don't resolve names.
$exec_string = 'arp -n ' . $host;
exec($exec_string, $output, $return);
// $lines=explode("\n", $output);
#look for the output line describing our IP address
foreach($output as $line)
{
$cols=preg_split('/\s+/', trim($line));
if (trim($cols[0])==$this->ip)
{
if (substr(trim($cols[1]),0,1) != '(') {
$macAddr=$cols[2];
}
}
}
}
}
return strtolower($macAddr);
// return $return;
} | php | public function getMac() {
$macAddr = '00:00:00:00:00:00';
$host = escapeshellcmd($this->ip);
$ping = new Ping($host);
if ($ping->ping()) {
// Exec string for Windows-based systems.
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
// -a = Display current ARP entries by introgating current protocol data.
$exec_string = 'arp -a ' . $host;
exec($exec_string, $output, $return);
// $lines=explode("\n", $output);
#look for the output line describing our IP address
foreach($output as $line)
{
$cols=preg_split('/\s+/', trim($line));
if (trim($cols[0])==$this->ip)
{
$macAddr=str_replace('-', ':', $cols[1]);
}
}
}
// Exec string for UNIX-based systems (Mac, Linux).
else {
// -n = Don't resolve names.
$exec_string = 'arp -n ' . $host;
exec($exec_string, $output, $return);
// $lines=explode("\n", $output);
#look for the output line describing our IP address
foreach($output as $line)
{
$cols=preg_split('/\s+/', trim($line));
if (trim($cols[0])==$this->ip)
{
if (substr(trim($cols[1]),0,1) != '(') {
$macAddr=$cols[2];
}
}
}
}
}
return strtolower($macAddr);
// return $return;
} | [
"public",
"function",
"getMac",
"(",
")",
"{",
"$",
"macAddr",
"=",
"'00:00:00:00:00:00'",
";",
"$",
"host",
"=",
"escapeshellcmd",
"(",
"$",
"this",
"->",
"ip",
")",
";",
"$",
"ping",
"=",
"new",
"Ping",
"(",
"$",
"host",
")",
";",
"if",
"(",
"$",... | The exec method uses the possibly insecure exec() function, which passes
the input to the system. This is potentially VERY dangerous if you pass in
any user-submitted data. Be SURE you sanitize your inputs!
@return string
macAddr, in string. | [
"The",
"exec",
"method",
"uses",
"the",
"possibly",
"insecure",
"exec",
"()",
"function",
"which",
"passes",
"the",
"input",
"to",
"the",
"system",
".",
"This",
"is",
"potentially",
"VERY",
"dangerous",
"if",
"you",
"pass",
"in",
"any",
"user",
"-",
"submi... | train | https://github.com/kelixlabs/KelixNetTools/blob/9759b526f6d255c44ef6d407480932e5b92c4785/src/Network.php#L391-L439 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Catalog/Export/Text/Standard.php | Standard.exportData | protected function exportData( array $ids, array $lang, $filename )
{
$context = $this->getContext();
$manager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context );
$globalLanguageManager = $manager->getSubManager( 'language' );
$search = $globalLanguageManager->createSearch();
$search->setSortations( array( $search->sort( '+', 'locale.language.id' ) ) );
if( !empty( $lang ) ) {
$search->setConditions( $search->compare( '==', 'locale.language.id', $lang ) );
}
/** controller/extjs/catalog/export/text/standard/container/type
* Container file type storing all language files for the exported texts
*
* When exporting texts, one file or content object is created per
* language. All those files or content objects are put into one container
* file so editors don't have to download one file for each language.
*
* The container file types that are supported by default are:
* * Zip
*
* Extensions implement other container types like spread sheets, XMLs or
* more advanced ways of handling the exported data.
*
* @param string Container file type
* @since 2014.03
* @category Developer
* @category User
*/
/** controller/extjs/catalog/export/text/standard/container/format
* Format of the language files for the exported texts
*
* The exported texts are stored in one file or content object per
* language. The format of that file or content object can be configured
* with this option but most formats are bound to a specific container
* type.
*
* The formats that are supported by default are:
* * CSV (requires container type "Zip")
*
* Extensions implement other container types like spread sheets, XMLs or
* more advanced ways of handling the exported data.
*
* @param string Content file type
* @since 2014.03
* @category Developer
* @category User
*/
/** controller/extjs/catalog/export/text/standard/container/options
* Options changing the output format of the exported texts
*
* Each content format may support some configuration options to change
* the output for that content type.
*
* The options for the CSV content format are:
* * csv-separator, default ','
* * csv-enclosure, default '"'
* * csv-escape, default '"'
* * csv-lineend, default '\n'
*
* For format options provided by other container types implemented by
* extensions, please have a look into the extension documentation.
*
* @param array Associative list of options with the name as key and its value
* @since 2014.03
* @category Developer
* @category User
*/
$containerItem = $this->createContainer( $filename, 'controller/extjs/catalog/export/text/standard/container' );
$actualLangid = $context->getLocale()->getLanguageId();
$start = 0;
do
{
$result = $globalLanguageManager->searchItems( $search );
foreach( $result as $item )
{
$langid = $item->getId();
$contentItem = $containerItem->create( $langid );
$contentItem->add( array( 'Language ID', 'Catalog label', 'Catalog ID', 'List type', 'Text type', 'Text ID', 'Text' ) );
$context->getLocale()->setLanguageId( $langid );
$this->addLanguage( $contentItem, $langid, $ids );
$containerItem->add( $contentItem );
}
$count = count( $result );
$start += $count;
$search->setSlice( $start );
}
while( $count == $search->getSliceSize() );
$context->getLocale()->setLanguageId( $actualLangid );
$containerItem->close();
return $containerItem->getName();
} | php | protected function exportData( array $ids, array $lang, $filename )
{
$context = $this->getContext();
$manager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context );
$globalLanguageManager = $manager->getSubManager( 'language' );
$search = $globalLanguageManager->createSearch();
$search->setSortations( array( $search->sort( '+', 'locale.language.id' ) ) );
if( !empty( $lang ) ) {
$search->setConditions( $search->compare( '==', 'locale.language.id', $lang ) );
}
/** controller/extjs/catalog/export/text/standard/container/type
* Container file type storing all language files for the exported texts
*
* When exporting texts, one file or content object is created per
* language. All those files or content objects are put into one container
* file so editors don't have to download one file for each language.
*
* The container file types that are supported by default are:
* * Zip
*
* Extensions implement other container types like spread sheets, XMLs or
* more advanced ways of handling the exported data.
*
* @param string Container file type
* @since 2014.03
* @category Developer
* @category User
*/
/** controller/extjs/catalog/export/text/standard/container/format
* Format of the language files for the exported texts
*
* The exported texts are stored in one file or content object per
* language. The format of that file or content object can be configured
* with this option but most formats are bound to a specific container
* type.
*
* The formats that are supported by default are:
* * CSV (requires container type "Zip")
*
* Extensions implement other container types like spread sheets, XMLs or
* more advanced ways of handling the exported data.
*
* @param string Content file type
* @since 2014.03
* @category Developer
* @category User
*/
/** controller/extjs/catalog/export/text/standard/container/options
* Options changing the output format of the exported texts
*
* Each content format may support some configuration options to change
* the output for that content type.
*
* The options for the CSV content format are:
* * csv-separator, default ','
* * csv-enclosure, default '"'
* * csv-escape, default '"'
* * csv-lineend, default '\n'
*
* For format options provided by other container types implemented by
* extensions, please have a look into the extension documentation.
*
* @param array Associative list of options with the name as key and its value
* @since 2014.03
* @category Developer
* @category User
*/
$containerItem = $this->createContainer( $filename, 'controller/extjs/catalog/export/text/standard/container' );
$actualLangid = $context->getLocale()->getLanguageId();
$start = 0;
do
{
$result = $globalLanguageManager->searchItems( $search );
foreach( $result as $item )
{
$langid = $item->getId();
$contentItem = $containerItem->create( $langid );
$contentItem->add( array( 'Language ID', 'Catalog label', 'Catalog ID', 'List type', 'Text type', 'Text ID', 'Text' ) );
$context->getLocale()->setLanguageId( $langid );
$this->addLanguage( $contentItem, $langid, $ids );
$containerItem->add( $contentItem );
}
$count = count( $result );
$start += $count;
$search->setSlice( $start );
}
while( $count == $search->getSliceSize() );
$context->getLocale()->setLanguageId( $actualLangid );
$containerItem->close();
return $containerItem->getName();
} | [
"protected",
"function",
"exportData",
"(",
"array",
"$",
"ids",
",",
"array",
"$",
"lang",
",",
"$",
"filename",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
";",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",... | Gets all data and exports it to the content files.
@param array $ids List of item IDs that should be part of the document
@param array $lang List of languages to export (empty array for all)
@param string $filename Temporary folder name where to write export files
@return string Path to the exported file | [
"Gets",
"all",
"data",
"and",
"exports",
"it",
"to",
"the",
"content",
"files",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Catalog/Export/Text/Standard.php#L166-L268 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Catalog/Export/Text/Standard.php | Standard.addLanguage | protected function addLanguage( \Aimeos\MW\Container\Content\Iface $contentItem, $langid, array $ids )
{
$manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->getContext() );
foreach( $ids as $id )
{
foreach( $this->getNodeList( $manager->getTree( $id, array( 'text' ) ) ) as $item ) {
$this->addItem( $contentItem, $item, $langid );
}
}
} | php | protected function addLanguage( \Aimeos\MW\Container\Content\Iface $contentItem, $langid, array $ids )
{
$manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->getContext() );
foreach( $ids as $id )
{
foreach( $this->getNodeList( $manager->getTree( $id, array( 'text' ) ) ) as $item ) {
$this->addItem( $contentItem, $item, $langid );
}
}
} | [
"protected",
"function",
"addLanguage",
"(",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Container",
"\\",
"Content",
"\\",
"Iface",
"$",
"contentItem",
",",
"$",
"langid",
",",
"array",
"$",
"ids",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
... | Adds data for the given language.
@param \Aimeos\MW\Container\Content\Iface $contentItem Content item
@param string $langid Language ID to add the texts for
@param array $ids List of of item ids whose texts should be added | [
"Adds",
"data",
"for",
"the",
"given",
"language",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Catalog/Export/Text/Standard.php#L278-L288 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Catalog/Export/Text/Standard.php | Standard.getNodeList | protected function getNodeList( \Aimeos\MShop\Catalog\Item\Iface $node )
{
$nodes = array( $node );
foreach( $node->getChildren() as $child ) {
$nodes = array_merge( $nodes, $this->getNodeList( $child ) );
}
return $nodes;
} | php | protected function getNodeList( \Aimeos\MShop\Catalog\Item\Iface $node )
{
$nodes = array( $node );
foreach( $node->getChildren() as $child ) {
$nodes = array_merge( $nodes, $this->getNodeList( $child ) );
}
return $nodes;
} | [
"protected",
"function",
"getNodeList",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Catalog",
"\\",
"Item",
"\\",
"Iface",
"$",
"node",
")",
"{",
"$",
"nodes",
"=",
"array",
"(",
"$",
"node",
")",
";",
"foreach",
"(",
"$",
"node",
"->",
"getChildren",
... | Get all child nodes.
@param \Aimeos\MShop\Catalog\Item\Iface $node
@return \Aimeos\MShop\Catalog\Item\Iface[] $nodes List of nodes | [
"Get",
"all",
"child",
"nodes",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Catalog/Export/Text/Standard.php#L343-L352 |
accompli/accompli | src/Task/SSHAgentTask.php | SSHAgentTask.onPrepareWorkspaceInitializeSSHAgent | public function onPrepareWorkspaceInitializeSSHAgent(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$this->host = $event->getHost();
$connection = $this->ensureConnection($this->host);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Initializing SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$result = $connection->executeCommand('eval $(ssh-agent)');
if ($result->isSuccessful()) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Initialized SSH agent. {output}', $eventName, $this, array('output' => trim($result->getOutput()), 'event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
foreach ($this->keys as $key) {
$this->addKeyToSSHAgent($event->getWorkspace(), $connection, $key, $eventName, $eventDispatcher);
}
} else {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed initializing SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true)));
}
} | php | public function onPrepareWorkspaceInitializeSSHAgent(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$this->host = $event->getHost();
$connection = $this->ensureConnection($this->host);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Initializing SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$result = $connection->executeCommand('eval $(ssh-agent)');
if ($result->isSuccessful()) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Initialized SSH agent. {output}', $eventName, $this, array('output' => trim($result->getOutput()), 'event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
foreach ($this->keys as $key) {
$this->addKeyToSSHAgent($event->getWorkspace(), $connection, $key, $eventName, $eventDispatcher);
}
} else {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed initializing SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true)));
}
} | [
"public",
"function",
"onPrepareWorkspaceInitializeSSHAgent",
"(",
"WorkspaceEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"$",
"this",
"->",
"host",
"=",
"$",
"event",
"->",
"getHost",
"(",
")",
... | Initializes the SSH agent and adds the configured keys.
@param WorkspaceEvent $event
@param string $eventName
@param EventDispatcherInterface $eventDispatcher | [
"Initializes",
"the",
"SSH",
"agent",
"and",
"adds",
"the",
"configured",
"keys",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/SSHAgentTask.php#L71-L89 |
accompli/accompli | src/Task/SSHAgentTask.php | SSHAgentTask.onInstallReleaseCompleteOrFailedShutdownSSHAgent | public function onInstallReleaseCompleteOrFailedShutdownSSHAgent(Event $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
if ($this->host instanceof Host) {
$connection = $this->ensureConnection($this->host);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Terminating SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$result = $connection->executeCommand('eval $(ssh-agent -k)');
if ($result->isSuccessful()) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Terminated SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
} else {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed terminating SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true)));
}
}
} | php | public function onInstallReleaseCompleteOrFailedShutdownSSHAgent(Event $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
if ($this->host instanceof Host) {
$connection = $this->ensureConnection($this->host);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Terminating SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$result = $connection->executeCommand('eval $(ssh-agent -k)');
if ($result->isSuccessful()) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Terminated SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
} else {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed terminating SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true)));
}
}
} | [
"public",
"function",
"onInstallReleaseCompleteOrFailedShutdownSSHAgent",
"(",
"Event",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"host",
"instanceof",
"Host",
")",
"{",
"$... | Terminates SSH agent after release installation is successful or has failed.
@param Event $event
@param string $eventName
@param EventDispatcherInterface $eventDispatcher | [
"Terminates",
"SSH",
"agent",
"after",
"release",
"installation",
"is",
"successful",
"or",
"has",
"failed",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/SSHAgentTask.php#L98-L112 |
accompli/accompli | src/Task/SSHAgentTask.php | SSHAgentTask.addKeyToSSHAgent | private function addKeyToSSHAgent(Workspace $workspace, ConnectionAdapterInterface $connection, $key, $eventName, EventDispatcherInterface $eventDispatcher)
{
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Adding key to SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$keyFile = $workspace->getHost()->getPath().'/tmp.key';
if ($connection->createFile($keyFile, 0700) && $connection->putContents($keyFile, $key)) {
$result = $connection->executeCommand('ssh-add', array($keyFile));
if ($result->isSuccessful()) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Added key to SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
}
$connection->delete($keyFile);
if ($result->isSuccessful()) {
return;
}
}
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Failed adding key to SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true)));
} | php | private function addKeyToSSHAgent(Workspace $workspace, ConnectionAdapterInterface $connection, $key, $eventName, EventDispatcherInterface $eventDispatcher)
{
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Adding key to SSH agent...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$keyFile = $workspace->getHost()->getPath().'/tmp.key';
if ($connection->createFile($keyFile, 0700) && $connection->putContents($keyFile, $key)) {
$result = $connection->executeCommand('ssh-add', array($keyFile));
if ($result->isSuccessful()) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Added key to SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
}
$connection->delete($keyFile);
if ($result->isSuccessful()) {
return;
}
}
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Failed adding key to SSH agent.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_FAILED, 'output.resetLine' => true)));
} | [
"private",
"function",
"addKeyToSSHAgent",
"(",
"Workspace",
"$",
"workspace",
",",
"ConnectionAdapterInterface",
"$",
"connection",
",",
"$",
"key",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"$",
"eventDispatcher",
"-... | Adds an SSH key to the initialized SSH agent.
@param Workspace $workspace
@param ConnectionAdapterInterface $connection
@param string $key
@param string $eventName
@param EventDispatcherInterface $eventDispatcher | [
"Adds",
"an",
"SSH",
"key",
"to",
"the",
"initialized",
"SSH",
"agent",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/SSHAgentTask.php#L123-L142 |
saxulum/saxulum-elasticsearch-querybuilder | src/Node/ObjectNode.php | ObjectNode.create | public static function create(bool $allowSerializeEmpty = false): ObjectNode
{
$node = new self();
$node->allowSerializeEmpty = $allowSerializeEmpty;
return $node;
} | php | public static function create(bool $allowSerializeEmpty = false): ObjectNode
{
$node = new self();
$node->allowSerializeEmpty = $allowSerializeEmpty;
return $node;
} | [
"public",
"static",
"function",
"create",
"(",
"bool",
"$",
"allowSerializeEmpty",
"=",
"false",
")",
":",
"ObjectNode",
"{",
"$",
"node",
"=",
"new",
"self",
"(",
")",
";",
"$",
"node",
"->",
"allowSerializeEmpty",
"=",
"$",
"allowSerializeEmpty",
";",
"r... | @param bool $allowSerializeEmpty
@return ObjectNode | [
"@param",
"bool",
"$allowSerializeEmpty"
] | train | https://github.com/saxulum/saxulum-elasticsearch-querybuilder/blob/2f5a15925f3f3afe6a8efabf1f2c9af42f81d9b1/src/Node/ObjectNode.php#L14-L20 |
saxulum/saxulum-elasticsearch-querybuilder | src/Node/ObjectNode.php | ObjectNode.add | public function add(string $key, AbstractNode $node)
{
if (isset($this->children[$key])) {
throw new \InvalidArgumentException(sprintf('There is already a node with key %s!', $key));
}
$node->setParent($this);
$this->children[$key] = $node;
return $this;
} | php | public function add(string $key, AbstractNode $node)
{
if (isset($this->children[$key])) {
throw new \InvalidArgumentException(sprintf('There is already a node with key %s!', $key));
}
$node->setParent($this);
$this->children[$key] = $node;
return $this;
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"key",
",",
"AbstractNode",
"$",
"node",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"children",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"s... | @param string $key
@param AbstractNode $node
@return $this
@throws \InvalidArgumentException | [
"@param",
"string",
"$key",
"@param",
"AbstractNode",
"$node"
] | train | https://github.com/saxulum/saxulum-elasticsearch-querybuilder/blob/2f5a15925f3f3afe6a8efabf1f2c9af42f81d9b1/src/Node/ObjectNode.php#L43-L54 |
qloog/yaf-library | src/Validators/StringValidator.php | StringValidator.validator | public function validator($field, array $data)
{
$value = isset($data[$field]) ? $data[$field] : null;
if ($value === '' || $value === null) {
return $this->allowEmpty ? true : $this->message('{fieldName}不能为空!', [
'{fieldName}' => $this->getName($field),
], 'emptyMsg');
}
if (!is_callable($this->checkBy)) {
throw new ParamsException('checkBy', 'not callable');
}
$len = call_user_func($this->checkBy, $value);
if ($this->min !== null && $this->min > $len) {
return $this->message('{fieldName}长度不能小于{min}!', [
'{fieldName}' => $this->getName($field),
'{min}' => $this->min,
], 'tooSmall');
}
if ($this->max !== null && $this->max < $len) {
return $this->message('{fieldName}长度不能大于{max}!', [
'{fieldName}' => $this->getName($field),
'{max}' => $this->max,
], 'tooBig');
}
if ($this->equal !== null && $this->equal != $len) {
return $this->message('{fieldName}长度不等于{equal}!', [
'{fieldName}' => $this->getName($field),
'{equal}' => $this->equal,
], 'notEqual');
}
return true;
} | php | public function validator($field, array $data)
{
$value = isset($data[$field]) ? $data[$field] : null;
if ($value === '' || $value === null) {
return $this->allowEmpty ? true : $this->message('{fieldName}不能为空!', [
'{fieldName}' => $this->getName($field),
], 'emptyMsg');
}
if (!is_callable($this->checkBy)) {
throw new ParamsException('checkBy', 'not callable');
}
$len = call_user_func($this->checkBy, $value);
if ($this->min !== null && $this->min > $len) {
return $this->message('{fieldName}长度不能小于{min}!', [
'{fieldName}' => $this->getName($field),
'{min}' => $this->min,
], 'tooSmall');
}
if ($this->max !== null && $this->max < $len) {
return $this->message('{fieldName}长度不能大于{max}!', [
'{fieldName}' => $this->getName($field),
'{max}' => $this->max,
], 'tooBig');
}
if ($this->equal !== null && $this->equal != $len) {
return $this->message('{fieldName}长度不等于{equal}!', [
'{fieldName}' => $this->getName($field),
'{equal}' => $this->equal,
], 'notEqual');
}
return true;
} | [
"public",
"function",
"validator",
"(",
"$",
"field",
",",
"array",
"$",
"data",
")",
"{",
"$",
"value",
"=",
"isset",
"(",
"$",
"data",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"field",
"]",
":",
"null",
";",
"if",
"(",
"$",
... | 验证
@param string $field
@param array $data
@return bool|string
@throws ParamsException | [
"验证"
] | train | https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Validators/StringValidator.php#L77-L113 |
qloog/yaf-library | src/Validators/StringValidator.php | StringValidator.validatorValue | protected function validatorValue($value)
{
if ($value === null) {
return $this->allowEmpty;
}
if (preg_match($this->pattern, $value)) {
return true;
}
return false;
} | php | protected function validatorValue($value)
{
if ($value === null) {
return $this->allowEmpty;
}
if (preg_match($this->pattern, $value)) {
return true;
}
return false;
} | [
"protected",
"function",
"validatorValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"allowEmpty",
";",
"}",
"if",
"(",
"preg_match",
"(",
"$",
"this",
"->",
"pattern",
",",
"$",
"valu... | 验证值
@param $value
@return bool|string | [
"验证值"
] | train | https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Validators/StringValidator.php#L121-L132 |
despark/ignicms | src/Admin/Helpers/FormBuilder.php | FormBuilder.renderInput | public function renderInput($view)
{
// First check if there isn't a model view.
$viewName = 'ignicms::admin.formElements.'.$view;
if ($this->model instanceof AdminModel && $identifier = $this->model->getIdentifier()) {
// First check if there is a rewrite on specific field type
$field = str_slug($this->field);
if (\View::exists('resources.'.$identifier.'.formElements.'.$field)) {
$viewName = 'resources.'.$identifier.'.formElements.'.$field;
} elseif (\View::exists('resources.'.$identifier.'.formElements.'.$view)) {
$viewName = 'resources.'.$identifier.'.formElements.'.$view;
}
}
return view($viewName, [
'record' => $this->model,
'fieldName' => $this->field,
'elementName' => $this->elementName,
'options' => $this->options,
'sourceModel' => $this->sourceModel,
]);
} | php | public function renderInput($view)
{
// First check if there isn't a model view.
$viewName = 'ignicms::admin.formElements.'.$view;
if ($this->model instanceof AdminModel && $identifier = $this->model->getIdentifier()) {
// First check if there is a rewrite on specific field type
$field = str_slug($this->field);
if (\View::exists('resources.'.$identifier.'.formElements.'.$field)) {
$viewName = 'resources.'.$identifier.'.formElements.'.$field;
} elseif (\View::exists('resources.'.$identifier.'.formElements.'.$view)) {
$viewName = 'resources.'.$identifier.'.formElements.'.$view;
}
}
return view($viewName, [
'record' => $this->model,
'fieldName' => $this->field,
'elementName' => $this->elementName,
'options' => $this->options,
'sourceModel' => $this->sourceModel,
]);
} | [
"public",
"function",
"renderInput",
"(",
"$",
"view",
")",
"{",
"// First check if there isn't a model view.",
"$",
"viewName",
"=",
"'ignicms::admin.formElements.'",
".",
"$",
"view",
";",
"if",
"(",
"$",
"this",
"->",
"model",
"instanceof",
"AdminModel",
"&&",
... | @param string $view
@return \Illuminate\View\View | [
"@param",
"string",
"$view"
] | train | https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Admin/Helpers/FormBuilder.php#L42-L65 |
shopgate/cart-integration-sdk | src/helper/redirect/SettingsManager.php | Shopgate_Helper_Redirect_SettingsManager.getShopgateUrl | protected function getShopgateUrl()
{
switch ($this->config->getServer()) {
default: // fall through to "live"
case 'live':
return self::SHOPGATE_LIVE_ALIAS;
case 'sl':
return self::SHOPGATE_SL_ALIAS;
case 'pg':
return self::SHOPGATE_PG_ALIAS;
case 'custom':
return self::SHOPGATE_DEV_ALIAS; // for Shopgate development & testing
}
} | php | protected function getShopgateUrl()
{
switch ($this->config->getServer()) {
default: // fall through to "live"
case 'live':
return self::SHOPGATE_LIVE_ALIAS;
case 'sl':
return self::SHOPGATE_SL_ALIAS;
case 'pg':
return self::SHOPGATE_PG_ALIAS;
case 'custom':
return self::SHOPGATE_DEV_ALIAS; // for Shopgate development & testing
}
} | [
"protected",
"function",
"getShopgateUrl",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"config",
"->",
"getServer",
"(",
")",
")",
"{",
"default",
":",
"// fall through to \"live\"",
"case",
"'live'",
":",
"return",
"self",
"::",
"SHOPGATE_LIVE_ALIAS",
";... | Returns the URL to be appended to the alias of a shop.
The method determines this by the "server" setting in ShopgateConfig. If it's set to
"custom", localdev.cc will be used for Shopgate local development and testing.
@return string The URL that can be appended to the alias, e.g. ".shopgate.com" | [
"Returns",
"the",
"URL",
"to",
"be",
"appended",
"to",
"the",
"alias",
"of",
"a",
"shop",
"."
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/redirect/SettingsManager.php#L182-L195 |
despark/ignicms | src/Console/Commands/Admin/ResourceCommand.php | ResourceCommand.handle | public function handle()
{
$this->identifier = self::normalize($this->argument('identifier'));
$this->askImageUploads();
$this->askFileUploads();
$this->askMigration();
$this->askActions();
$this->compiler = new ResourceCompiler($this, $this->identifier, $this->resourceOptions);
$this->createResource('config');
$this->createResource('model');
$this->createResource('request');
$this->createResource('controller');
if ($this->resourceOptions['migration']) {
$this->createResource('migration');
}
} | php | public function handle()
{
$this->identifier = self::normalize($this->argument('identifier'));
$this->askImageUploads();
$this->askFileUploads();
$this->askMigration();
$this->askActions();
$this->compiler = new ResourceCompiler($this, $this->identifier, $this->resourceOptions);
$this->createResource('config');
$this->createResource('model');
$this->createResource('request');
$this->createResource('controller');
if ($this->resourceOptions['migration']) {
$this->createResource('migration');
}
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"this",
"->",
"identifier",
"=",
"self",
"::",
"normalize",
"(",
"$",
"this",
"->",
"argument",
"(",
"'identifier'",
")",
")",
";",
"$",
"this",
"->",
"askImageUploads",
"(",
")",
";",
"$",
"this",
... | Execute the command. | [
"Execute",
"the",
"command",
"."
] | train | https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Console/Commands/Admin/ResourceCommand.php#L62-L81 |
bacart/guzzle-client | src/Client/GuzzleClient.php | GuzzleClient.getGuzzleResponse | public function getGuzzleResponse(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): ResponseInterface {
try {
return $this->request(
$method,
$uri,
$options
);
} catch (GuzzleException $e) {
throw new GuzzleClientException($e);
}
} | php | public function getGuzzleResponse(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): ResponseInterface {
try {
return $this->request(
$method,
$uri,
$options
);
} catch (GuzzleException $e) {
throw new GuzzleClientException($e);
}
} | [
"public",
"function",
"getGuzzleResponse",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"string",
"$",
"method",
"=",
"GuzzleClientInterface",
"::",
"METHOD_GET",
")",
":",
"ResponseInterface",
"{",
"try",
"{",
"return",
"$",
... | {@inheritdoc}
@throws GuzzleClientException | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Client/GuzzleClient.php#L58-L72 |
bacart/guzzle-client | src/Client/GuzzleClient.php | GuzzleClient.writeGuzzleResponseToFile | public function writeGuzzleResponseToFile(
string $uri,
string $filename,
array $options = [],
string $method = self::METHOD_GET
): ResponseInterface {
return $this->getGuzzleResponse($uri, $options + [
RequestOptions::SINK => $filename,
], $method);
} | php | public function writeGuzzleResponseToFile(
string $uri,
string $filename,
array $options = [],
string $method = self::METHOD_GET
): ResponseInterface {
return $this->getGuzzleResponse($uri, $options + [
RequestOptions::SINK => $filename,
], $method);
} | [
"public",
"function",
"writeGuzzleResponseToFile",
"(",
"string",
"$",
"uri",
",",
"string",
"$",
"filename",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"string",
"$",
"method",
"=",
"self",
"::",
"METHOD_GET",
")",
":",
"ResponseInterface",
"{",
"r... | {@inheritdoc}
@throws GuzzleClientException | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Client/GuzzleClient.php#L79-L88 |
bacart/guzzle-client | src/Client/GuzzleClient.php | GuzzleClient.getGuzzleResponseAsString | public function getGuzzleResponseAsString(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): string {
return (string) $this->getGuzzleResponse(
$uri,
$options,
$method
)->getBody();
} | php | public function getGuzzleResponseAsString(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): string {
return (string) $this->getGuzzleResponse(
$uri,
$options,
$method
)->getBody();
} | [
"public",
"function",
"getGuzzleResponseAsString",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"string",
"$",
"method",
"=",
"GuzzleClientInterface",
"::",
"METHOD_GET",
")",
":",
"string",
"{",
"return",
"(",
"string",
")",
... | {@inheritdoc}
@throws GuzzleClientException | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Client/GuzzleClient.php#L95-L105 |
bacart/guzzle-client | src/Client/GuzzleClient.php | GuzzleClient.getGuzzleResponseAsJson | public function getGuzzleResponseAsJson(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): ?array {
$stringResponse = $this->getGuzzleResponseAsString(
$uri,
$options,
$method
);
try {
return JsonUtils::jsonDecode($stringResponse, true);
} catch (JsonException $e) {
throw new GuzzleClientException($e);
}
} | php | public function getGuzzleResponseAsJson(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): ?array {
$stringResponse = $this->getGuzzleResponseAsString(
$uri,
$options,
$method
);
try {
return JsonUtils::jsonDecode($stringResponse, true);
} catch (JsonException $e) {
throw new GuzzleClientException($e);
}
} | [
"public",
"function",
"getGuzzleResponseAsJson",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"string",
"$",
"method",
"=",
"GuzzleClientInterface",
"::",
"METHOD_GET",
")",
":",
"?",
"array",
"{",
"$",
"stringResponse",
"=",
... | {@inheritdoc}
@throws GuzzleClientException | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Client/GuzzleClient.php#L112-L128 |
bacart/guzzle-client | src/Client/GuzzleClient.php | GuzzleClient.getGuzzleResponseAsCrawler | public function getGuzzleResponseAsCrawler(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): Crawler {
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
throw new MissingPackageException('symfony/dom-crawler');
}
$stringResponse = $this->getGuzzleResponseAsString(
$uri,
$options,
$method
);
$baseHref = trim($uri, '/');
$baseUri = rtrim(
$this->getConfig(GuzzleClientInterface::BASE_URI),
'/'
);
return new Crawler(
$stringResponse,
$baseUri.'/'.$baseHref,
$uri
);
} | php | public function getGuzzleResponseAsCrawler(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): Crawler {
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
throw new MissingPackageException('symfony/dom-crawler');
}
$stringResponse = $this->getGuzzleResponseAsString(
$uri,
$options,
$method
);
$baseHref = trim($uri, '/');
$baseUri = rtrim(
$this->getConfig(GuzzleClientInterface::BASE_URI),
'/'
);
return new Crawler(
$stringResponse,
$baseUri.'/'.$baseHref,
$uri
);
} | [
"public",
"function",
"getGuzzleResponseAsCrawler",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"string",
"$",
"method",
"=",
"GuzzleClientInterface",
"::",
"METHOD_GET",
")",
":",
"Crawler",
"{",
"if",
"(",
"!",
"class_exist... | {@inheritdoc}
@throws MissingPackageException
@throws GuzzleClientException | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Client/GuzzleClient.php#L136-L162 |
bacart/guzzle-client | src/Client/GuzzleClient.php | GuzzleClient.getGuzzleResponseAsHtmlPage | public function getGuzzleResponseAsHtmlPage(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): HtmlPage {
if (!class_exists('Wa72\HtmlPageDom\HtmlPage')) {
throw new MissingPackageException('wa72/htmlpagedom');
}
$stringResponse = $this->getGuzzleResponseAsString(
$uri,
$options,
$method
);
return new HtmlPage(
$stringResponse,
$uri
);
} | php | public function getGuzzleResponseAsHtmlPage(
string $uri,
array $options = [],
string $method = GuzzleClientInterface::METHOD_GET
): HtmlPage {
if (!class_exists('Wa72\HtmlPageDom\HtmlPage')) {
throw new MissingPackageException('wa72/htmlpagedom');
}
$stringResponse = $this->getGuzzleResponseAsString(
$uri,
$options,
$method
);
return new HtmlPage(
$stringResponse,
$uri
);
} | [
"public",
"function",
"getGuzzleResponseAsHtmlPage",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"string",
"$",
"method",
"=",
"GuzzleClientInterface",
"::",
"METHOD_GET",
")",
":",
"HtmlPage",
"{",
"if",
"(",
"!",
"class_exi... | {@inheritdoc}
@throws MissingPackageException
@throws GuzzleClientException | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Client/GuzzleClient.php#L170-L189 |
runcmf/runbb | src/RunBB/Model/Userlist.php | Userlist.fetchUserCount | public function fetchUserCount($username, $show_group)
{
// Fetch user count
$num_users = DB::forTable('users')
->tableAlias('u')
->whereGt('u.id', 1)
->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED'));
if ($username != '') {
$num_users = $num_users->whereLike('u.username', str_replace('*', '%', $username));
}
if ($show_group > -1) {
$num_users = $num_users->where('u.group_id', $show_group);
}
$num_users = $num_users->count('id');
$num_users = Container::get('hooks')->fire('model.userlist.fetch_user_count', $num_users);
return $num_users;
} | php | public function fetchUserCount($username, $show_group)
{
// Fetch user count
$num_users = DB::forTable('users')
->tableAlias('u')
->whereGt('u.id', 1)
->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED'));
if ($username != '') {
$num_users = $num_users->whereLike('u.username', str_replace('*', '%', $username));
}
if ($show_group > -1) {
$num_users = $num_users->where('u.group_id', $show_group);
}
$num_users = $num_users->count('id');
$num_users = Container::get('hooks')->fire('model.userlist.fetch_user_count', $num_users);
return $num_users;
} | [
"public",
"function",
"fetchUserCount",
"(",
"$",
"username",
",",
"$",
"show_group",
")",
"{",
"// Fetch user count",
"$",
"num_users",
"=",
"DB",
"::",
"forTable",
"(",
"'users'",
")",
"->",
"tableAlias",
"(",
"'u'",
")",
"->",
"whereGt",
"(",
"'u.id'",
... | Counts the number of user for a specific query | [
"Counts",
"the",
"number",
"of",
"user",
"for",
"a",
"specific",
"query"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Userlist.php#L17-L37 |
runcmf/runbb | src/RunBB/Model/Userlist.php | Userlist.generateDropdownMenu | public function generateDropdownMenu($show_group)
{
$show_group = Container::get('hooks')->fire('model.userlist.generate_dropdown_menu_start', $show_group);
$dropdown_menu = '';
$result['select'] = ['g_id', 'g_title'];
$result = DB::forTable('groups')
->selectMany($result['select'])
->whereNotEqual('g_id', ForumEnv::get('FEATHER_GUEST'))
->orderByExpr('g_id');
$result = Container::get('hooks')->fireDB('model.userlist.generate_dropdown_menu_query', $result);
$result = $result->findMany();
foreach ($result as $cur_group) {
if ($cur_group['g_id'] == $show_group) {
$dropdown_menu .= "\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '" selected="selected">' .
Utils::escape($cur_group['g_title']) . '</option>' . "\n";
} else {
$dropdown_menu .= "\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '">' .
Utils::escape($cur_group['g_title']) . '</option>' . "\n";
}
}
$dropdown_menu = Container::get('hooks')->fire('model.userlist.generate_dropdown_menu', $dropdown_menu);
return $dropdown_menu;
} | php | public function generateDropdownMenu($show_group)
{
$show_group = Container::get('hooks')->fire('model.userlist.generate_dropdown_menu_start', $show_group);
$dropdown_menu = '';
$result['select'] = ['g_id', 'g_title'];
$result = DB::forTable('groups')
->selectMany($result['select'])
->whereNotEqual('g_id', ForumEnv::get('FEATHER_GUEST'))
->orderByExpr('g_id');
$result = Container::get('hooks')->fireDB('model.userlist.generate_dropdown_menu_query', $result);
$result = $result->findMany();
foreach ($result as $cur_group) {
if ($cur_group['g_id'] == $show_group) {
$dropdown_menu .= "\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '" selected="selected">' .
Utils::escape($cur_group['g_title']) . '</option>' . "\n";
} else {
$dropdown_menu .= "\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '">' .
Utils::escape($cur_group['g_title']) . '</option>' . "\n";
}
}
$dropdown_menu = Container::get('hooks')->fire('model.userlist.generate_dropdown_menu', $dropdown_menu);
return $dropdown_menu;
} | [
"public",
"function",
"generateDropdownMenu",
"(",
"$",
"show_group",
")",
"{",
"$",
"show_group",
"=",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fire",
"(",
"'model.userlist.generate_dropdown_menu_start'",
",",
"$",
"show_group",
")",
";",
"$",
"dro... | Generates the dropdown menu containing groups | [
"Generates",
"the",
"dropdown",
"menu",
"containing",
"groups"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Userlist.php#L40-L68 |
runcmf/runbb | src/RunBB/Model/Userlist.php | Userlist.printUsers | public function printUsers($username, $start_from, $sort_by, $sort_dir, $show_group)
{
$userlist_data = [];
$username = Container::get('hooks')
->fire('model.userlist.print_users_start', $username, $start_from, $sort_by, $sort_dir, $show_group);
// Retrieve a list of user IDs, LIMIT is (really) expensive so we only fetch the
// IDs here then later fetch the remaining data
$result = DB::forTable('users')
->select('u.id')
->tableAlias('u')
->whereGt('u.id', 1)
->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED'));
if ($username != '') {
$result = $result->whereLike('u.username', str_replace('*', '%', $username));
}
if ($show_group > -1) {
$result = $result->where('u.group_id', $show_group);
}
$result = $result->orderByExpr($sort_by . ' ' . $sort_dir)
->orderByAsc('u.id')
->limit(50)
->offset($start_from);
$result = Container::get('hooks')->fireDB('model.userlist.print_users_query', $result);
$result = $result->findMany();
if ($result) {
$user_ids = [];
foreach ($result as $cur_user_id) {
$user_ids[] = $cur_user_id['id'];
}
// Grab the users
$result['select'] = ['u.id', 'u.username', 'u.title', 'u.num_posts', 'u.registered',
'g.g_id', 'g.g_user_title'];
$result = DB::forTable('users')
->tableAlias('u')
->selectMany($result['select'])
->leftOuterJoin(DB::prefix() . 'groups', ['g.g_id', '=', 'u.group_id'], 'g')
->whereIn('u.id', $user_ids)
->orderByExpr($sort_by . ' ' . $sort_dir)
->orderByAsc('u.id');
$result = Container::get('hooks')->fireDB('model.userlist.print_users_grab_query', $result);
$result = $result->find_many();
foreach ($result as $user_data) {
$userlist_data[] = $user_data;
}
}
$userlist_data = Container::get('hooks')->fire('model.userlist.print_users', $userlist_data);
return $userlist_data;
} | php | public function printUsers($username, $start_from, $sort_by, $sort_dir, $show_group)
{
$userlist_data = [];
$username = Container::get('hooks')
->fire('model.userlist.print_users_start', $username, $start_from, $sort_by, $sort_dir, $show_group);
// Retrieve a list of user IDs, LIMIT is (really) expensive so we only fetch the
// IDs here then later fetch the remaining data
$result = DB::forTable('users')
->select('u.id')
->tableAlias('u')
->whereGt('u.id', 1)
->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED'));
if ($username != '') {
$result = $result->whereLike('u.username', str_replace('*', '%', $username));
}
if ($show_group > -1) {
$result = $result->where('u.group_id', $show_group);
}
$result = $result->orderByExpr($sort_by . ' ' . $sort_dir)
->orderByAsc('u.id')
->limit(50)
->offset($start_from);
$result = Container::get('hooks')->fireDB('model.userlist.print_users_query', $result);
$result = $result->findMany();
if ($result) {
$user_ids = [];
foreach ($result as $cur_user_id) {
$user_ids[] = $cur_user_id['id'];
}
// Grab the users
$result['select'] = ['u.id', 'u.username', 'u.title', 'u.num_posts', 'u.registered',
'g.g_id', 'g.g_user_title'];
$result = DB::forTable('users')
->tableAlias('u')
->selectMany($result['select'])
->leftOuterJoin(DB::prefix() . 'groups', ['g.g_id', '=', 'u.group_id'], 'g')
->whereIn('u.id', $user_ids)
->orderByExpr($sort_by . ' ' . $sort_dir)
->orderByAsc('u.id');
$result = Container::get('hooks')->fireDB('model.userlist.print_users_grab_query', $result);
$result = $result->find_many();
foreach ($result as $user_data) {
$userlist_data[] = $user_data;
}
}
$userlist_data = Container::get('hooks')->fire('model.userlist.print_users', $userlist_data);
return $userlist_data;
} | [
"public",
"function",
"printUsers",
"(",
"$",
"username",
",",
"$",
"start_from",
",",
"$",
"sort_by",
",",
"$",
"sort_dir",
",",
"$",
"show_group",
")",
"{",
"$",
"userlist_data",
"=",
"[",
"]",
";",
"$",
"username",
"=",
"Container",
"::",
"get",
"("... | Prints the users | [
"Prints",
"the",
"users"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Userlist.php#L71-L129 |
makinacorpus/drupal-ucms | ucms_contrib/src/Form/NodeDuplicate.php | NodeDuplicate.buildForm | public function buildForm(array $form, FormStateInterface $form_state, $node = null)
{
$account = $this->currentUser();
$candidates = $this->nodeManager->findSiteCandidatesForCloning($node, $this->currentUser()->id());
$siteContext = $this->siteManager->hasContext() ? $this->siteManager->getContext() : null;
$isNodeInSite = $siteContext && ($node->site_id == $siteContext->getId());
$canEditAll = $node->access(Permission::UPDATE, $account);
$canDuplicate = $candidates && !$isNodeInSite && $this->authorizationChecker->isGranted(Permission::CLONE, $node, $account);
$form_state->setTemporaryValue('node', $node);
if ($canEditAll && $canDuplicate) {
$form['action'] = [
'#type' => 'radios',
'#options' => [],
'#required' => true,
];
} else {
$form['action'] = [
'#type' => 'value',
'#value' => $canDuplicate ? 'duplicate' : 'edit',
];
if ($canDuplicate) {
$form['help'] = [
'#markup' => $this->t("Do you want to duplicate this content within your site ?"),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
} else {
$form['help'] = [
'#markup' => $this->t("Do you want to edit this content ?"),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
}
}
if ($canDuplicate && (!$isNodeInSite || $candidates)) {
if ('value' !== $form['action']['#type']) {
$form['action']['#options']['duplicate'] = $this->t("Duplicate in my site");
$form['action']['#default_value'] = 'duplicate';
}
// If duplicate is possible, let the user choose the site.
if ($siteContext) {
$form['site'] = ['#type' => 'value', '#value' => $siteContext->getId()];
} else {
$options = [];
foreach ($candidates as $site) {
$options[$site->id] = check_plain($site->title);
}
$form['site'] = [
'#type' => count($options) < 11 ? 'radios' : 'select',
'#title' => $this->t("Select a site"),
'#options' => $options,
// If "create a global content" is selected, this widget does
// not serve any purpose, so we don't care about default value
'#default_value' => key($options),
'#required' => true,
'#states' => ['visible' => [':input[name="action"]' => ['value' => 'duplicate']]],
];
}
}
if ($canEditAll && 'value' !== $form['action']['#type']) {
// Duplicate action superseed the 'edit' action, which means that
// by the order of execution, default will always be 'duplicate'
// whenever the user can.
$form['action']['#options']['edit'] = $this->t("Edit the content globally (affects all site the content is in)");
$form['action']['#default_value'] = 'edit';
}
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t("Continue"),
];
if (isset($_GET['destination'])) {
$form['actions']['cancel'] = [
'#markup' => l(
$this->t("Cancel"),
$_GET['destination'],
['attributes' => ['class' => ['btn', 'btn-danger']]]
),
];
}
return $form;
} | php | public function buildForm(array $form, FormStateInterface $form_state, $node = null)
{
$account = $this->currentUser();
$candidates = $this->nodeManager->findSiteCandidatesForCloning($node, $this->currentUser()->id());
$siteContext = $this->siteManager->hasContext() ? $this->siteManager->getContext() : null;
$isNodeInSite = $siteContext && ($node->site_id == $siteContext->getId());
$canEditAll = $node->access(Permission::UPDATE, $account);
$canDuplicate = $candidates && !$isNodeInSite && $this->authorizationChecker->isGranted(Permission::CLONE, $node, $account);
$form_state->setTemporaryValue('node', $node);
if ($canEditAll && $canDuplicate) {
$form['action'] = [
'#type' => 'radios',
'#options' => [],
'#required' => true,
];
} else {
$form['action'] = [
'#type' => 'value',
'#value' => $canDuplicate ? 'duplicate' : 'edit',
];
if ($canDuplicate) {
$form['help'] = [
'#markup' => $this->t("Do you want to duplicate this content within your site ?"),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
} else {
$form['help'] = [
'#markup' => $this->t("Do you want to edit this content ?"),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
}
}
if ($canDuplicate && (!$isNodeInSite || $candidates)) {
if ('value' !== $form['action']['#type']) {
$form['action']['#options']['duplicate'] = $this->t("Duplicate in my site");
$form['action']['#default_value'] = 'duplicate';
}
// If duplicate is possible, let the user choose the site.
if ($siteContext) {
$form['site'] = ['#type' => 'value', '#value' => $siteContext->getId()];
} else {
$options = [];
foreach ($candidates as $site) {
$options[$site->id] = check_plain($site->title);
}
$form['site'] = [
'#type' => count($options) < 11 ? 'radios' : 'select',
'#title' => $this->t("Select a site"),
'#options' => $options,
// If "create a global content" is selected, this widget does
// not serve any purpose, so we don't care about default value
'#default_value' => key($options),
'#required' => true,
'#states' => ['visible' => [':input[name="action"]' => ['value' => 'duplicate']]],
];
}
}
if ($canEditAll && 'value' !== $form['action']['#type']) {
// Duplicate action superseed the 'edit' action, which means that
// by the order of execution, default will always be 'duplicate'
// whenever the user can.
$form['action']['#options']['edit'] = $this->t("Edit the content globally (affects all site the content is in)");
$form['action']['#default_value'] = 'edit';
}
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t("Continue"),
];
if (isset($_GET['destination'])) {
$form['actions']['cancel'] = [
'#markup' => l(
$this->t("Cancel"),
$_GET['destination'],
['attributes' => ['class' => ['btn', 'btn-danger']]]
),
];
}
return $form;
} | [
"public",
"function",
"buildForm",
"(",
"array",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
",",
"$",
"node",
"=",
"null",
")",
"{",
"$",
"account",
"=",
"$",
"this",
"->",
"currentUser",
"(",
")",
";",
"$",
"candidates",
"=",
"$",
"thi... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/Form/NodeDuplicate.php#L64-L153 |
makinacorpus/drupal-ucms | ucms_contrib/src/Form/NodeDuplicate.php | NodeDuplicate.submitForm | public function submitForm(array &$form, FormStateInterface $form_state)
{
$node = $form_state->getTemporaryValue('node');
$action = $form_state->getValue('action');
$siteId = $form_state->getValue('site');
$options = [];
if (isset($_GET['destination'])) {
$options['query']['destination'] = $_GET['destination'];
unset($_GET['destination']);
}
switch ($action) {
case 'duplicate':
list($path, $options) = $this->siteManager->getUrlGenerator()->getRouteAndParams($siteId, 'node/' . $node->id(). '/clone', $options);
drupal_set_message($this->t("You can now edit this node on this site, it will be automatically duplicated."));
break;
default:
$path = 'node/' . $node->id() . '/edit';
drupal_set_message($this->t("You are now editing the global content for all sites."));
break;
}
$form_state->setRedirect($path, $options);
} | php | public function submitForm(array &$form, FormStateInterface $form_state)
{
$node = $form_state->getTemporaryValue('node');
$action = $form_state->getValue('action');
$siteId = $form_state->getValue('site');
$options = [];
if (isset($_GET['destination'])) {
$options['query']['destination'] = $_GET['destination'];
unset($_GET['destination']);
}
switch ($action) {
case 'duplicate':
list($path, $options) = $this->siteManager->getUrlGenerator()->getRouteAndParams($siteId, 'node/' . $node->id(). '/clone', $options);
drupal_set_message($this->t("You can now edit this node on this site, it will be automatically duplicated."));
break;
default:
$path = 'node/' . $node->id() . '/edit';
drupal_set_message($this->t("You are now editing the global content for all sites."));
break;
}
$form_state->setRedirect($path, $options);
} | [
"public",
"function",
"submitForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"$",
"node",
"=",
"$",
"form_state",
"->",
"getTemporaryValue",
"(",
"'node'",
")",
";",
"$",
"action",
"=",
"$",
"form_state",
"->"... | Duplicate in context submit. | [
"Duplicate",
"in",
"context",
"submit",
"."
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/Form/NodeDuplicate.php#L158-L184 |
mosbth/Anax-MVC | src/HTMLForm/FormController.php | FormController.indexAction | public function indexAction()
{
$this->di->session(); // Will load the session service which also starts the session
$form = $this->di->form->create([], [
'name' => [
'type' => 'text',
'label' => 'Name of contact person:',
'required' => true,
'validation' => ['not_empty'],
],
'email' => [
'type' => 'text',
'required' => true,
'validation' => ['not_empty', 'email_adress'],
],
'phone' => [
'type' => 'text',
'required' => true,
'validation' => ['not_empty', 'numeric'],
],
'submit' => [
'type' => 'submit',
'callback' => [$this, 'callbackSubmit'],
],
'submit-fail' => [
'type' => 'submit',
'callback' => [$this, 'callbackSubmitFail'],
],
]);
// Check the status of the form
$form->check([$this, 'callbackSuccess'], [$this, 'callbackFail']);
$this->di->theme->setTitle("Testing CForm with Anax");
$this->di->views->add('default/page', [
'title' => "Try out a form using CForm",
'content' => $form->getHTML()
]);
} | php | public function indexAction()
{
$this->di->session(); // Will load the session service which also starts the session
$form = $this->di->form->create([], [
'name' => [
'type' => 'text',
'label' => 'Name of contact person:',
'required' => true,
'validation' => ['not_empty'],
],
'email' => [
'type' => 'text',
'required' => true,
'validation' => ['not_empty', 'email_adress'],
],
'phone' => [
'type' => 'text',
'required' => true,
'validation' => ['not_empty', 'numeric'],
],
'submit' => [
'type' => 'submit',
'callback' => [$this, 'callbackSubmit'],
],
'submit-fail' => [
'type' => 'submit',
'callback' => [$this, 'callbackSubmitFail'],
],
]);
// Check the status of the form
$form->check([$this, 'callbackSuccess'], [$this, 'callbackFail']);
$this->di->theme->setTitle("Testing CForm with Anax");
$this->di->views->add('default/page', [
'title' => "Try out a form using CForm",
'content' => $form->getHTML()
]);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"this",
"->",
"di",
"->",
"session",
"(",
")",
";",
"// Will load the session service which also starts the session",
"$",
"form",
"=",
"$",
"this",
"->",
"di",
"->",
"form",
"->",
"create",
"(",
"[",
... | Index action. | [
"Index",
"action",
"."
] | train | https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/HTMLForm/FormController.php#L20-L60 |
mosbth/Anax-MVC | src/HTMLForm/FormController.php | FormController.callbackSubmit | public function callbackSubmit($form)
{
$form->AddOutput("<p>DoSubmit(): Form was submitted.<p>");
$form->AddOutput("<p>Do stuff (save to database) and return true (success) or false (failed processing)</p>");
$form->AddOutput("<p><b>Name: " . $form->Value('name') . "</b></p>");
$form->AddOutput("<p><b>Email: " . $form->Value('email') . "</b></p>");
$form->AddOutput("<p><b>Phone: " . $form->Value('phone') . "</b></p>");
$form->saveInSession = true;
return true;
} | php | public function callbackSubmit($form)
{
$form->AddOutput("<p>DoSubmit(): Form was submitted.<p>");
$form->AddOutput("<p>Do stuff (save to database) and return true (success) or false (failed processing)</p>");
$form->AddOutput("<p><b>Name: " . $form->Value('name') . "</b></p>");
$form->AddOutput("<p><b>Email: " . $form->Value('email') . "</b></p>");
$form->AddOutput("<p><b>Phone: " . $form->Value('phone') . "</b></p>");
$form->saveInSession = true;
return true;
} | [
"public",
"function",
"callbackSubmit",
"(",
"$",
"form",
")",
"{",
"$",
"form",
"->",
"AddOutput",
"(",
"\"<p>DoSubmit(): Form was submitted.<p>\"",
")",
";",
"$",
"form",
"->",
"AddOutput",
"(",
"\"<p>Do stuff (save to database) and return true (success) or false (failed ... | Callback for submit-button. | [
"Callback",
"for",
"submit",
"-",
"button",
"."
] | train | https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/HTMLForm/FormController.php#L68-L77 |
makinacorpus/drupal-ucms | ucms_layout/src/TemporaryStorage.php | TemporaryStorage.save | public function save(Layout $layout)
{
cache_set(
$this->buildId($layout->getId()),
$layout,
'cache_layout',
time() + $this->lifetime
);
} | php | public function save(Layout $layout)
{
cache_set(
$this->buildId($layout->getId()),
$layout,
'cache_layout',
time() + $this->lifetime
);
} | [
"public",
"function",
"save",
"(",
"Layout",
"$",
"layout",
")",
"{",
"cache_set",
"(",
"$",
"this",
"->",
"buildId",
"(",
"$",
"layout",
"->",
"getId",
"(",
")",
")",
",",
"$",
"layout",
",",
"'cache_layout'",
",",
"time",
"(",
")",
"+",
"$",
"thi... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/TemporaryStorage.php#L73-L81 |
makinacorpus/drupal-ucms | ucms_layout/src/TemporaryStorage.php | TemporaryStorage.delete | public function delete($id)
{
if ($id instanceof Layout) {
$id = $id->getId();
}
cache_clear_all($this->buildId($id), 'cache_layout');
} | php | public function delete($id)
{
if ($id instanceof Layout) {
$id = $id->getId();
}
cache_clear_all($this->buildId($id), 'cache_layout');
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
"instanceof",
"Layout",
")",
"{",
"$",
"id",
"=",
"$",
"id",
"->",
"getId",
"(",
")",
";",
"}",
"cache_clear_all",
"(",
"$",
"this",
"->",
"buildId",
"(",
"$",
"id",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/TemporaryStorage.php#L86-L93 |
makinacorpus/drupal-ucms | ucms_layout/src/TemporaryStorage.php | TemporaryStorage.load | public function load($id)
{
if ($cached = cache_get($this->buildId($id), 'cache_layout')) {
if ($cached->data instanceof Layout) {
return $cached->data;
}
}
} | php | public function load($id)
{
if ($cached = cache_get($this->buildId($id), 'cache_layout')) {
if ($cached->data instanceof Layout) {
return $cached->data;
}
}
} | [
"public",
"function",
"load",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"cached",
"=",
"cache_get",
"(",
"$",
"this",
"->",
"buildId",
"(",
"$",
"id",
")",
",",
"'cache_layout'",
")",
")",
"{",
"if",
"(",
"$",
"cached",
"->",
"data",
"instanceof",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/TemporaryStorage.php#L98-L105 |
makinacorpus/drupal-ucms | ucms_layout/src/TemporaryStorage.php | TemporaryStorage.findForNodeOnSite | public function findForNodeOnSite($nodeId, $siteId, $createOnMiss = false)
{
$id = (int)$this
->db
->query(
"SELECT id FROM {ucms_layout} WHERE nid = ? AND site_id = ?",
[$nodeId, $siteId]
)
->fetchField()
;
if (!$id) {
throw new \LogicException("Temporary storage points to a non existing layout");
}
return $this->load($id);
} | php | public function findForNodeOnSite($nodeId, $siteId, $createOnMiss = false)
{
$id = (int)$this
->db
->query(
"SELECT id FROM {ucms_layout} WHERE nid = ? AND site_id = ?",
[$nodeId, $siteId]
)
->fetchField()
;
if (!$id) {
throw new \LogicException("Temporary storage points to a non existing layout");
}
return $this->load($id);
} | [
"public",
"function",
"findForNodeOnSite",
"(",
"$",
"nodeId",
",",
"$",
"siteId",
",",
"$",
"createOnMiss",
"=",
"false",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"SELECT id FROM {ucms_layout} WHERE nid = ? A... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_layout/src/TemporaryStorage.php#L110-L126 |
runcmf/runbb | src/RunBB/Core/Lister.php | Lister.getPlugins | public static function getPlugins(array $list = [])
{
$plugins = [];
if (!empty($list)) {
foreach ($list as $plug) {
if (class_exists($plug['class'])) {
$plugins[] = json_decode($plug['class']::getInfo());
}
}
}
return $plugins;
} | php | public static function getPlugins(array $list = [])
{
$plugins = [];
if (!empty($list)) {
foreach ($list as $plug) {
if (class_exists($plug['class'])) {
$plugins[] = json_decode($plug['class']::getInfo());
}
}
}
return $plugins;
} | [
"public",
"static",
"function",
"getPlugins",
"(",
"array",
"$",
"list",
"=",
"[",
"]",
")",
"{",
"$",
"plugins",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"foreach",
"(",
"$",
"list",
"as",
"$",
"plug",
")",... | Get all valid plugin files.
@param array $list
@return array | [
"Get",
"all",
"valid",
"plugin",
"files",
"."
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Lister.php#L19-L32 |
runcmf/runbb | src/RunBB/Core/Lister.php | Lister.getOfficialPlugins | public static function getOfficialPlugins()
{
$plugins = [];
// Get the official list from the website
$content = json_decode(AdminUtils::getContent('http://featherbb.org/plugins.json'));
// If internet is available
if (!is_null($content)) {
foreach ($content as $plugin) {
// Get information from each repo
// TODO: cache
$plugins[] = json_decode(
AdminUtils::getContent(
'https://raw.githubusercontent.com/featherbb/'.$plugin.'/master/featherbb.json'
)
);
}
}
return $plugins;
} | php | public static function getOfficialPlugins()
{
$plugins = [];
// Get the official list from the website
$content = json_decode(AdminUtils::getContent('http://featherbb.org/plugins.json'));
// If internet is available
if (!is_null($content)) {
foreach ($content as $plugin) {
// Get information from each repo
// TODO: cache
$plugins[] = json_decode(
AdminUtils::getContent(
'https://raw.githubusercontent.com/featherbb/'.$plugin.'/master/featherbb.json'
)
);
}
}
return $plugins;
} | [
"public",
"static",
"function",
"getOfficialPlugins",
"(",
")",
"{",
"$",
"plugins",
"=",
"[",
"]",
";",
"// Get the official list from the website",
"$",
"content",
"=",
"json_decode",
"(",
"AdminUtils",
"::",
"getContent",
"(",
"'http://featherbb.org/plugins.json'",
... | Get all official plugins using GitHub API | [
"Get",
"all",
"official",
"plugins",
"using",
"GitHub",
"API"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Lister.php#L37-L58 |
runcmf/runbb | src/RunBB/Core/Lister.php | Lister.getStyles | public static function getStyles()
{
$styles = [];
$iterator = new \DirectoryIterator(ForumEnv::get('WEB_ROOT').'themes/');
foreach ($iterator as $child) {
if (!$child->isDot() && $child->isDir() &&
file_exists($child->getPathname().DIRECTORY_SEPARATOR.'style.css')) {
// If the theme is well formed, add it to the list
$styles[] = $child->getFileName();
}
}
natcasesort($styles);
return $styles;
} | php | public static function getStyles()
{
$styles = [];
$iterator = new \DirectoryIterator(ForumEnv::get('WEB_ROOT').'themes/');
foreach ($iterator as $child) {
if (!$child->isDot() && $child->isDir() &&
file_exists($child->getPathname().DIRECTORY_SEPARATOR.'style.css')) {
// If the theme is well formed, add it to the list
$styles[] = $child->getFileName();
}
}
natcasesort($styles);
return $styles;
} | [
"public",
"static",
"function",
"getStyles",
"(",
")",
"{",
"$",
"styles",
"=",
"[",
"]",
";",
"$",
"iterator",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"ForumEnv",
"::",
"get",
"(",
"'WEB_ROOT'",
")",
".",
"'themes/'",
")",
";",
"foreach",
"(",
"$"... | Get available styles | [
"Get",
"available",
"styles"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Lister.php#L63-L78 |
qloog/yaf-library | src/Providers/RedisServiceProvider.php | RedisServiceProvider.register | public function register(Container $pimple)
{
$pimple['redis'] = function ($app) {
$config = $app['config']['redis']['default'];
$redis = new \Redis();
$redis->connect($config['host'], $config['port'], $config['timeout']);
return $redis;
};
} | php | public function register(Container $pimple)
{
$pimple['redis'] = function ($app) {
$config = $app['config']['redis']['default'];
$redis = new \Redis();
$redis->connect($config['host'], $config['port'], $config['timeout']);
return $redis;
};
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"pimple",
")",
"{",
"$",
"pimple",
"[",
"'redis'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'redis'",
"]",
"[",
"'default'",
... | Registers services on the given container.
@param Container $pimple | [
"Registers",
"services",
"on",
"the",
"given",
"container",
"."
] | train | https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Providers/RedisServiceProvider.php#L18-L28 |
anlutro/laravel-validation | examples/ProjectValidator.php | ProjectValidator.prepareRules | protected function prepareRules(array $rules, array $attributes)
{
// start and deadline are both optional, but if they're both set, we
// want to validate that the deadline is after the start.
if (!empty($attributes['start']) && !empty($attributes['deadline'])) {
// because we're validating that start and deadline are valid date/
// time strings, we can use the "after" validation rule.
$rules['deadline'][] = 'after:' . $attributes['start'];
}
// always return the modified rules!
return $rules;
} | php | protected function prepareRules(array $rules, array $attributes)
{
// start and deadline are both optional, but if they're both set, we
// want to validate that the deadline is after the start.
if (!empty($attributes['start']) && !empty($attributes['deadline'])) {
// because we're validating that start and deadline are valid date/
// time strings, we can use the "after" validation rule.
$rules['deadline'][] = 'after:' . $attributes['start'];
}
// always return the modified rules!
return $rules;
} | [
"protected",
"function",
"prepareRules",
"(",
"array",
"$",
"rules",
",",
"array",
"$",
"attributes",
")",
"{",
"// start and deadline are both optional, but if they're both set, we",
"// want to validate that the deadline is after the start.",
"if",
"(",
"!",
"empty",
"(",
"... | Prepare the rules before passing them to the validator. | [
"Prepare",
"the",
"rules",
"before",
"passing",
"them",
"to",
"the",
"validator",
"."
] | train | https://github.com/anlutro/laravel-validation/blob/fb653cf29f230bf53beda4b35a4e1042d52faaeb/examples/ProjectValidator.php#L47-L59 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Supplier/Lists/Factory.php | Factory.createController | public static function createController( \Aimeos\MShop\Context\Item\Iface $context, $name = null )
{
/** controller/extjs/supplier/lists/name
* Class name of the used ExtJS supplier list controller implementation
*
* Each default ExtJS controller can be replace by an alternative imlementation.
* To use this implementation, you have to set the last part of the class
* name as configuration value so the client factory knows which class it
* has to instantiate.
*
* For example, if the name of the default class is
*
* \Aimeos\Controller\ExtJS\Supplier\Lists\Standard
*
* and you want to replace it with your own version named
*
* \Aimeos\Controller\ExtJS\Supplier\Lists\Mylist
*
* then you have to set the this configuration option:
*
* controller/extjs/supplier/lists/name = Mylist
*
* The value is the last part of your own class name and it's case sensitive,
* so take care that the configuration value is exactly named like the last
* part of the class name.
*
* The allowed characters of the class name are A-Z, a-z and 0-9. No other
* characters are possible! You should always start the last part of the class
* name with an upper case character and continue only with lower case characters
* or numbers. Avoid chamel case names like "MyList"!
*
* @param string Last part of the class name
* @since 2015.08
* @category Developer
*/
if( $name === null ) {
$name = $context->getConfig()->get( 'controller/extjs/supplier/lists/name', 'Standard' );
}
if( ctype_alnum( $name ) === false )
{
$classname = is_string( $name ) ? '\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\' . $name : '<not a string>';
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
}
$iface = '\\Aimeos\\Controller\\ExtJS\\Common\\Iface';
$classname = '\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\' . $name;
$controller = self::createControllerBase( $context, $classname, $iface );
/** controller/extjs/supplier/lists/decorators/excludes
* Excludes decorators added by the "common" option from the supplier list ExtJS controllers
*
* Decorators extend the functionality of a class by adding new aspects
* (e.g. log what is currently done), executing the methods of the underlying
* class only in certain conditions (e.g. only for logged in users) or
* modify what is returned to the caller.
*
* This option allows you to remove a decorator added via
* "controller/extjs/common/decorators/default" before they are wrapped
* around the ExtJS controller.
*
* controller/extjs/supplier/lists/decorators/excludes = array( 'decorator1' )
*
* This would remove the decorator named "decorator1" from the list of
* common decorators ("\Aimeos\Controller\ExtJS\Common\Decorator\*") added via
* "controller/extjs/common/decorators/default" for the admin ExtJS controller.
*
* @param array List of decorator names
* @since 2015.09
* @category Developer
* @see controller/extjs/common/decorators/default
* @see controller/extjs/supplier/lists/decorators/global
* @see controller/extjs/supplier/lists/decorators/local
*/
/** controller/extjs/supplier/lists/decorators/global
* Adds a list of globally available decorators only to the supplier list ExtJS controllers
*
* Decorators extend the functionality of a class by adding new aspects
* (e.g. log what is currently done), executing the methods of the underlying
* class only in certain conditions (e.g. only for logged in users) or
* modify what is returned to the caller.
*
* This option allows you to wrap global decorators
* ("\Aimeos\Controller\ExtJS\Common\Decorator\*") around the ExtJS controller.
*
* controller/extjs/supplier/lists/decorators/global = array( 'decorator1' )
*
* This would add the decorator named "decorator1" defined by
* "\Aimeos\Controller\ExtJS\Common\Decorator\Decorator1" only to the ExtJS controller.
*
* @param array List of decorator names
* @since 2015.09
* @category Developer
* @see controller/extjs/common/decorators/default
* @see controller/extjs/supplier/lists/decorators/excludes
* @see controller/extjs/supplier/lists/decorators/local
*/
/** controller/extjs/supplier/lists/decorators/local
* Adds a list of local decorators only to the supplier list ExtJS controllers
*
* Decorators extend the functionality of a class by adding new aspects
* (e.g. log what is currently done), executing the methods of the underlying
* class only in certain conditions (e.g. only for logged in users) or
* modify what is returned to the caller.
*
* This option allows you to wrap local decorators
* ("\Aimeos\Controller\ExtJS\Supplier\Lists\Decorator\*") around the ExtJS controller.
*
* controller/extjs/supplier/lists/decorators/local = array( 'decorator2' )
*
* This would add the decorator named "decorator2" defined by
* "\Aimeos\Controller\ExtJS\Supplier\Lists\Decorator\Decorator2" only to the ExtJS
* controller.
*
* @param array List of decorator names
* @since 2015.09
* @category Developer
* @see controller/extjs/common/decorators/default
* @see controller/extjs/supplier/lists/decorators/excludes
* @see controller/extjs/supplier/lists/decorators/global
*/
return self::addControllerDecorators( $context, $controller, 'supplier/lists' );
} | php | public static function createController( \Aimeos\MShop\Context\Item\Iface $context, $name = null )
{
/** controller/extjs/supplier/lists/name
* Class name of the used ExtJS supplier list controller implementation
*
* Each default ExtJS controller can be replace by an alternative imlementation.
* To use this implementation, you have to set the last part of the class
* name as configuration value so the client factory knows which class it
* has to instantiate.
*
* For example, if the name of the default class is
*
* \Aimeos\Controller\ExtJS\Supplier\Lists\Standard
*
* and you want to replace it with your own version named
*
* \Aimeos\Controller\ExtJS\Supplier\Lists\Mylist
*
* then you have to set the this configuration option:
*
* controller/extjs/supplier/lists/name = Mylist
*
* The value is the last part of your own class name and it's case sensitive,
* so take care that the configuration value is exactly named like the last
* part of the class name.
*
* The allowed characters of the class name are A-Z, a-z and 0-9. No other
* characters are possible! You should always start the last part of the class
* name with an upper case character and continue only with lower case characters
* or numbers. Avoid chamel case names like "MyList"!
*
* @param string Last part of the class name
* @since 2015.08
* @category Developer
*/
if( $name === null ) {
$name = $context->getConfig()->get( 'controller/extjs/supplier/lists/name', 'Standard' );
}
if( ctype_alnum( $name ) === false )
{
$classname = is_string( $name ) ? '\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\' . $name : '<not a string>';
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
}
$iface = '\\Aimeos\\Controller\\ExtJS\\Common\\Iface';
$classname = '\\Aimeos\\Controller\\ExtJS\\Supplier\\Lists\\' . $name;
$controller = self::createControllerBase( $context, $classname, $iface );
/** controller/extjs/supplier/lists/decorators/excludes
* Excludes decorators added by the "common" option from the supplier list ExtJS controllers
*
* Decorators extend the functionality of a class by adding new aspects
* (e.g. log what is currently done), executing the methods of the underlying
* class only in certain conditions (e.g. only for logged in users) or
* modify what is returned to the caller.
*
* This option allows you to remove a decorator added via
* "controller/extjs/common/decorators/default" before they are wrapped
* around the ExtJS controller.
*
* controller/extjs/supplier/lists/decorators/excludes = array( 'decorator1' )
*
* This would remove the decorator named "decorator1" from the list of
* common decorators ("\Aimeos\Controller\ExtJS\Common\Decorator\*") added via
* "controller/extjs/common/decorators/default" for the admin ExtJS controller.
*
* @param array List of decorator names
* @since 2015.09
* @category Developer
* @see controller/extjs/common/decorators/default
* @see controller/extjs/supplier/lists/decorators/global
* @see controller/extjs/supplier/lists/decorators/local
*/
/** controller/extjs/supplier/lists/decorators/global
* Adds a list of globally available decorators only to the supplier list ExtJS controllers
*
* Decorators extend the functionality of a class by adding new aspects
* (e.g. log what is currently done), executing the methods of the underlying
* class only in certain conditions (e.g. only for logged in users) or
* modify what is returned to the caller.
*
* This option allows you to wrap global decorators
* ("\Aimeos\Controller\ExtJS\Common\Decorator\*") around the ExtJS controller.
*
* controller/extjs/supplier/lists/decorators/global = array( 'decorator1' )
*
* This would add the decorator named "decorator1" defined by
* "\Aimeos\Controller\ExtJS\Common\Decorator\Decorator1" only to the ExtJS controller.
*
* @param array List of decorator names
* @since 2015.09
* @category Developer
* @see controller/extjs/common/decorators/default
* @see controller/extjs/supplier/lists/decorators/excludes
* @see controller/extjs/supplier/lists/decorators/local
*/
/** controller/extjs/supplier/lists/decorators/local
* Adds a list of local decorators only to the supplier list ExtJS controllers
*
* Decorators extend the functionality of a class by adding new aspects
* (e.g. log what is currently done), executing the methods of the underlying
* class only in certain conditions (e.g. only for logged in users) or
* modify what is returned to the caller.
*
* This option allows you to wrap local decorators
* ("\Aimeos\Controller\ExtJS\Supplier\Lists\Decorator\*") around the ExtJS controller.
*
* controller/extjs/supplier/lists/decorators/local = array( 'decorator2' )
*
* This would add the decorator named "decorator2" defined by
* "\Aimeos\Controller\ExtJS\Supplier\Lists\Decorator\Decorator2" only to the ExtJS
* controller.
*
* @param array List of decorator names
* @since 2015.09
* @category Developer
* @see controller/extjs/common/decorators/default
* @see controller/extjs/supplier/lists/decorators/excludes
* @see controller/extjs/supplier/lists/decorators/global
*/
return self::addControllerDecorators( $context, $controller, 'supplier/lists' );
} | [
"public",
"static",
"function",
"createController",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Context",
"\\",
"Item",
"\\",
"Iface",
"$",
"context",
",",
"$",
"name",
"=",
"null",
")",
"{",
"/** controller/extjs/supplier/lists/name\n\t\t * Class name of the used ExtJ... | Creates a new supplier lists controller object.
@param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects
@param string|null $name Name of the controller implementaton (default: "Standard")
@return \Aimeos\Controller\ExtJS\Iface Controller object | [
"Creates",
"a",
"new",
"supplier",
"lists",
"controller",
"object",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Supplier/Lists/Factory.php#L31-L156 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.