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
movoin/one-swoole
src/FileSystem/Manager.php
Manager.copy
public function copy(string $from, string $to, array $config = []): bool { list($prefixFrom, $from) = $this->getPrefixAndPath($from); if (($buffer = $this->getFileSystem($prefixFrom)->readStream($from)) === false) { return false; } unset($prefixFrom, $from); list($prefixTo, $to) = $this->getPrefixAndPath($to); if ($this->getFileSystem($prefixTo)->writeStream($to, $buffer, $config)) { unset($prefixTo, $to, $buffer); return true; } return false; }
php
public function copy(string $from, string $to, array $config = []): bool { list($prefixFrom, $from) = $this->getPrefixAndPath($from); if (($buffer = $this->getFileSystem($prefixFrom)->readStream($from)) === false) { return false; } unset($prefixFrom, $from); list($prefixTo, $to) = $this->getPrefixAndPath($to); if ($this->getFileSystem($prefixTo)->writeStream($to, $buffer, $config)) { unset($prefixTo, $to, $buffer); return true; } return false; }
[ "public", "function", "copy", "(", "string", "$", "from", ",", "string", "$", "to", ",", "array", "$", "config", "=", "[", "]", ")", ":", "bool", "{", "list", "(", "$", "prefixFrom", ",", "$", "from", ")", "=", "$", "this", "->", "getPrefixAndPath", "(", "$", "from", ")", ";", "if", "(", "(", "$", "buffer", "=", "$", "this", "->", "getFileSystem", "(", "$", "prefixFrom", ")", "->", "readStream", "(", "$", "from", ")", ")", "===", "false", ")", "{", "return", "false", ";", "}", "unset", "(", "$", "prefixFrom", ",", "$", "from", ")", ";", "list", "(", "$", "prefixTo", ",", "$", "to", ")", "=", "$", "this", "->", "getPrefixAndPath", "(", "$", "to", ")", ";", "if", "(", "$", "this", "->", "getFileSystem", "(", "$", "prefixTo", ")", "->", "writeStream", "(", "$", "to", ",", "$", "buffer", ",", "$", "config", ")", ")", "{", "unset", "(", "$", "prefixTo", ",", "$", "to", ",", "$", "buffer", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
复制文件 @param string $from @param string $to @param array $config @return bool
[ "复制文件" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/FileSystem/Manager.php#L130-L148
movoin/one-swoole
src/FileSystem/Manager.php
Manager.move
public function move(string $from, string $to, array $config = []): bool { list($prefixFrom, $pathFrom) = $this->getPrefixAndPath($from); list($prefixTo, $pathTo) = $this->getPrefixAndPath($to); if ($prefixFrom === $prefixTo) { $fs = $this->getFileSystem($prefixFrom); $renamed = $fs->rename($pathFrom, $pathTo); unset($prefixFrom, $pathFrom, $prefixTo); if ($renamed && isset($config['visibility'])) { return $fs->setVisibility($pathTo, $config['visibility']); } unset($fs, $pathTo); return $renamed; } if ($this->copy($from, $to, $config)) { return $this->delete($from); } return false; }
php
public function move(string $from, string $to, array $config = []): bool { list($prefixFrom, $pathFrom) = $this->getPrefixAndPath($from); list($prefixTo, $pathTo) = $this->getPrefixAndPath($to); if ($prefixFrom === $prefixTo) { $fs = $this->getFileSystem($prefixFrom); $renamed = $fs->rename($pathFrom, $pathTo); unset($prefixFrom, $pathFrom, $prefixTo); if ($renamed && isset($config['visibility'])) { return $fs->setVisibility($pathTo, $config['visibility']); } unset($fs, $pathTo); return $renamed; } if ($this->copy($from, $to, $config)) { return $this->delete($from); } return false; }
[ "public", "function", "move", "(", "string", "$", "from", ",", "string", "$", "to", ",", "array", "$", "config", "=", "[", "]", ")", ":", "bool", "{", "list", "(", "$", "prefixFrom", ",", "$", "pathFrom", ")", "=", "$", "this", "->", "getPrefixAndPath", "(", "$", "from", ")", ";", "list", "(", "$", "prefixTo", ",", "$", "pathTo", ")", "=", "$", "this", "->", "getPrefixAndPath", "(", "$", "to", ")", ";", "if", "(", "$", "prefixFrom", "===", "$", "prefixTo", ")", "{", "$", "fs", "=", "$", "this", "->", "getFileSystem", "(", "$", "prefixFrom", ")", ";", "$", "renamed", "=", "$", "fs", "->", "rename", "(", "$", "pathFrom", ",", "$", "pathTo", ")", ";", "unset", "(", "$", "prefixFrom", ",", "$", "pathFrom", ",", "$", "prefixTo", ")", ";", "if", "(", "$", "renamed", "&&", "isset", "(", "$", "config", "[", "'visibility'", "]", ")", ")", "{", "return", "$", "fs", "->", "setVisibility", "(", "$", "pathTo", ",", "$", "config", "[", "'visibility'", "]", ")", ";", "}", "unset", "(", "$", "fs", ",", "$", "pathTo", ")", ";", "return", "$", "renamed", ";", "}", "if", "(", "$", "this", "->", "copy", "(", "$", "from", ",", "$", "to", ",", "$", "config", ")", ")", "{", "return", "$", "this", "->", "delete", "(", "$", "from", ")", ";", "}", "return", "false", ";", "}" ]
移动文件 @param string $from @param string $to @param array $config @return bool
[ "移动文件" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/FileSystem/Manager.php#L159-L184
movoin/one-swoole
src/FileSystem/Manager.php
Manager.filterPrefix
protected function filterPrefix(array $arguments) { if (empty($arguments)) { throw new InvalidArgumentException('The arguments cannot be empty'); } $path = array_shift($arguments); if (! Assert::stringNotEmpty($path)) { throw new InvalidArgumentException( sprintf('"%s" path must be string', __METHOD__) ); } list($prefix, $path) = $this->getPrefixAndPath($path); array_unshift($arguments, $path); unset($path); return [$prefix, $arguments]; }
php
protected function filterPrefix(array $arguments) { if (empty($arguments)) { throw new InvalidArgumentException('The arguments cannot be empty'); } $path = array_shift($arguments); if (! Assert::stringNotEmpty($path)) { throw new InvalidArgumentException( sprintf('"%s" path must be string', __METHOD__) ); } list($prefix, $path) = $this->getPrefixAndPath($path); array_unshift($arguments, $path); unset($path); return [$prefix, $arguments]; }
[ "protected", "function", "filterPrefix", "(", "array", "$", "arguments", ")", "{", "if", "(", "empty", "(", "$", "arguments", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The arguments cannot be empty'", ")", ";", "}", "$", "path", "=", "array_shift", "(", "$", "arguments", ")", ";", "if", "(", "!", "Assert", "::", "stringNotEmpty", "(", "$", "path", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" path must be string'", ",", "__METHOD__", ")", ")", ";", "}", "list", "(", "$", "prefix", ",", "$", "path", ")", "=", "$", "this", "->", "getPrefixAndPath", "(", "$", "path", ")", ";", "array_unshift", "(", "$", "arguments", ",", "$", "path", ")", ";", "unset", "(", "$", "path", ")", ";", "return", "[", "$", "prefix", ",", "$", "arguments", "]", ";", "}" ]
从参数中获得文件系统前缀 @param array $arguments @return array @throws \InvalidArgumentException
[ "从参数中获得文件系统前缀" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/FileSystem/Manager.php#L225-L244
werx/forms
src/Checkbox.php
Checkbox.conditionalChecked
public function conditionalChecked($value_1 = null, $value_2 = null) { if (isset($value_1) && isset($value_2) && ($value_1 === $value_2)) { return $this->checked(); } else { return $this; } }
php
public function conditionalChecked($value_1 = null, $value_2 = null) { if (isset($value_1) && isset($value_2) && ($value_1 === $value_2)) { return $this->checked(); } else { return $this; } }
[ "public", "function", "conditionalChecked", "(", "$", "value_1", "=", "null", ",", "$", "value_2", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "value_1", ")", "&&", "isset", "(", "$", "value_2", ")", "&&", "(", "$", "value_1", "===", "$", "value_2", ")", ")", "{", "return", "$", "this", "->", "checked", "(", ")", ";", "}", "else", "{", "return", "$", "this", ";", "}", "}" ]
@param null $value_1 @param null $value_2 @return $this @deprecated Deprecated the day after it was created. Use checkedWhen() instead.
[ "@param", "null", "$value_1", "@param", "null", "$value_2", "@return", "$this" ]
train
https://github.com/werx/forms/blob/e057e4890bd13541da72b3cb2d22c2c84435c16a/src/Checkbox.php#L62-L69
o2system/html
src/Dom/Lists/Meta.php
Meta.import
public function import(Meta $metaNodes) { if (is_array($metaNodes = $metaNodes->getArrayCopy())) { foreach ($metaNodes as $name => $value) { $this->offsetSet($name, $value); } } return $this; }
php
public function import(Meta $metaNodes) { if (is_array($metaNodes = $metaNodes->getArrayCopy())) { foreach ($metaNodes as $name => $value) { $this->offsetSet($name, $value); } } return $this; }
[ "public", "function", "import", "(", "Meta", "$", "metaNodes", ")", "{", "if", "(", "is_array", "(", "$", "metaNodes", "=", "$", "metaNodes", "->", "getArrayCopy", "(", ")", ")", ")", "{", "foreach", "(", "$", "metaNodes", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "offsetSet", "(", "$", "name", ",", "$", "value", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Meta::import @param \O2System\Html\Dom\Lists\Meta $metaNodes @return $this
[ "Meta", "::", "import" ]
train
https://github.com/o2system/html/blob/b7336fb45d42603ce1064b25572a05d495887670/src/Dom/Lists/Meta.php#L56-L65
o2system/html
src/Dom/Lists/Meta.php
Meta.createElement
public function createElement(array $attributes) { $meta = $this->ownerDocument->createElement('meta'); $name = null; foreach ($attributes as $key => $value) { $meta->setAttribute($key, $value); } $this[] = $meta; return $meta; }
php
public function createElement(array $attributes) { $meta = $this->ownerDocument->createElement('meta'); $name = null; foreach ($attributes as $key => $value) { $meta->setAttribute($key, $value); } $this[] = $meta; return $meta; }
[ "public", "function", "createElement", "(", "array", "$", "attributes", ")", "{", "$", "meta", "=", "$", "this", "->", "ownerDocument", "->", "createElement", "(", "'meta'", ")", ";", "$", "name", "=", "null", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "meta", "->", "setAttribute", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "this", "[", "]", "=", "$", "meta", ";", "return", "$", "meta", ";", "}" ]
Meta::createElement @param array $attributes @return \DOMElement
[ "Meta", "::", "createElement" ]
train
https://github.com/o2system/html/blob/b7336fb45d42603ce1064b25572a05d495887670/src/Dom/Lists/Meta.php#L96-L108
WellCommerce/OrderBundle
Form/Admin/OrderFormBuilder.php
OrderFormBuilder.addShippingOptions
private function addShippingOptions(ElementInterface $radioGroup) { $order = $this->getOrderProvider()->getCurrentOrder(); $collection = $this->getShippingMethodProvider()->getCosts(new OrderContext($order)); $collection->map(function (ShippingMethodCost $shippingMethodCost) use ($radioGroup) { $shippingMethod = $shippingMethodCost->getShippingMethod(); $baseCurrency = $shippingMethod->getCurrency()->getCode(); $grossAmount = $shippingMethodCost->getCost()->getGrossAmount(); $label = sprintf( '%s (%s)', $shippingMethod->translate()->getName(), $this->getCurrencyHelper()->convertAndFormat($grossAmount, $baseCurrency) ); $radioGroup->addOptionToSelect($shippingMethod->getId(), $label); }); }
php
private function addShippingOptions(ElementInterface $radioGroup) { $order = $this->getOrderProvider()->getCurrentOrder(); $collection = $this->getShippingMethodProvider()->getCosts(new OrderContext($order)); $collection->map(function (ShippingMethodCost $shippingMethodCost) use ($radioGroup) { $shippingMethod = $shippingMethodCost->getShippingMethod(); $baseCurrency = $shippingMethod->getCurrency()->getCode(); $grossAmount = $shippingMethodCost->getCost()->getGrossAmount(); $label = sprintf( '%s (%s)', $shippingMethod->translate()->getName(), $this->getCurrencyHelper()->convertAndFormat($grossAmount, $baseCurrency) ); $radioGroup->addOptionToSelect($shippingMethod->getId(), $label); }); }
[ "private", "function", "addShippingOptions", "(", "ElementInterface", "$", "radioGroup", ")", "{", "$", "order", "=", "$", "this", "->", "getOrderProvider", "(", ")", "->", "getCurrentOrder", "(", ")", ";", "$", "collection", "=", "$", "this", "->", "getShippingMethodProvider", "(", ")", "->", "getCosts", "(", "new", "OrderContext", "(", "$", "order", ")", ")", ";", "$", "collection", "->", "map", "(", "function", "(", "ShippingMethodCost", "$", "shippingMethodCost", ")", "use", "(", "$", "radioGroup", ")", "{", "$", "shippingMethod", "=", "$", "shippingMethodCost", "->", "getShippingMethod", "(", ")", ";", "$", "baseCurrency", "=", "$", "shippingMethod", "->", "getCurrency", "(", ")", "->", "getCode", "(", ")", ";", "$", "grossAmount", "=", "$", "shippingMethodCost", "->", "getCost", "(", ")", "->", "getGrossAmount", "(", ")", ";", "$", "label", "=", "sprintf", "(", "'%s (%s)'", ",", "$", "shippingMethod", "->", "translate", "(", ")", "->", "getName", "(", ")", ",", "$", "this", "->", "getCurrencyHelper", "(", ")", "->", "convertAndFormat", "(", "$", "grossAmount", ",", "$", "baseCurrency", ")", ")", ";", "$", "radioGroup", "->", "addOptionToSelect", "(", "$", "shippingMethod", "->", "getId", "(", ")", ",", "$", "label", ")", ";", "}", ")", ";", "}" ]
Adds shipping method options to select @param ElementInterface|Select $radioGroup
[ "Adds", "shipping", "method", "options", "to", "select" ]
train
https://github.com/WellCommerce/OrderBundle/blob/d72cfb51eab7a1f66f186900d1e2d533a822c424/Form/Admin/OrderFormBuilder.php#L303-L321
WellCommerce/OrderBundle
Form/Admin/OrderFormBuilder.php
OrderFormBuilder.addPaymentOptions
private function addPaymentOptions(ElementInterface $radioGroup) { $order = $this->getOrderProvider()->getCurrentOrder(); $shippingMethod = $order->getShippingMethod(); if ($shippingMethod instanceof ShippingMethod) { $collection = $shippingMethod->getPaymentMethods(); $collection->map(function (PaymentMethod $paymentMethod) use ($radioGroup) { $radioGroup->addOptionToSelect($paymentMethod->getId(), $paymentMethod->translate()->getName()); }); } }
php
private function addPaymentOptions(ElementInterface $radioGroup) { $order = $this->getOrderProvider()->getCurrentOrder(); $shippingMethod = $order->getShippingMethod(); if ($shippingMethod instanceof ShippingMethod) { $collection = $shippingMethod->getPaymentMethods(); $collection->map(function (PaymentMethod $paymentMethod) use ($radioGroup) { $radioGroup->addOptionToSelect($paymentMethod->getId(), $paymentMethod->translate()->getName()); }); } }
[ "private", "function", "addPaymentOptions", "(", "ElementInterface", "$", "radioGroup", ")", "{", "$", "order", "=", "$", "this", "->", "getOrderProvider", "(", ")", "->", "getCurrentOrder", "(", ")", ";", "$", "shippingMethod", "=", "$", "order", "->", "getShippingMethod", "(", ")", ";", "if", "(", "$", "shippingMethod", "instanceof", "ShippingMethod", ")", "{", "$", "collection", "=", "$", "shippingMethod", "->", "getPaymentMethods", "(", ")", ";", "$", "collection", "->", "map", "(", "function", "(", "PaymentMethod", "$", "paymentMethod", ")", "use", "(", "$", "radioGroup", ")", "{", "$", "radioGroup", "->", "addOptionToSelect", "(", "$", "paymentMethod", "->", "getId", "(", ")", ",", "$", "paymentMethod", "->", "translate", "(", ")", "->", "getName", "(", ")", ")", ";", "}", ")", ";", "}", "}" ]
Adds payment method options to select @param ElementInterface|Select $radioGroup
[ "Adds", "payment", "method", "options", "to", "select" ]
train
https://github.com/WellCommerce/OrderBundle/blob/d72cfb51eab7a1f66f186900d1e2d533a822c424/Form/Admin/OrderFormBuilder.php#L328-L339
FrenchFrogs/framework
src/Panel/Panel/Panel.php
Panel.addAction
public function addAction(Action\Action $element) { if (!$element->hasRenderer()) { $element->setRenderer($this->getRenderer()); } $this->actions[$element->getName()] = $element; return $this; }
php
public function addAction(Action\Action $element) { if (!$element->hasRenderer()) { $element->setRenderer($this->getRenderer()); } $this->actions[$element->getName()] = $element; return $this; }
[ "public", "function", "addAction", "(", "Action", "\\", "Action", "$", "element", ")", "{", "if", "(", "!", "$", "element", "->", "hasRenderer", "(", ")", ")", "{", "$", "element", "->", "setRenderer", "(", "$", "this", "->", "getRenderer", "(", ")", ")", ";", "}", "$", "this", "->", "actions", "[", "$", "element", "->", "getName", "(", ")", "]", "=", "$", "element", ";", "return", "$", "this", ";", "}" ]
Add an action to the action container @param Action\Action $element @return $this
[ "Add", "an", "action", "to", "the", "action", "container" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Panel/Panel/Panel.php#L187-L195
FrenchFrogs/framework
src/Panel/Panel/Panel.php
Panel.addSelectRemote
public function addSelectRemote($name, $placeholder, $data_url, $action_url, $length = 3 ) { $e = new Action\SelectRemote($name, $placeholder, $data_url, $action_url, $length); $this->addAction($e); return $e; }
php
public function addSelectRemote($name, $placeholder, $data_url, $action_url, $length = 3 ) { $e = new Action\SelectRemote($name, $placeholder, $data_url, $action_url, $length); $this->addAction($e); return $e; }
[ "public", "function", "addSelectRemote", "(", "$", "name", ",", "$", "placeholder", ",", "$", "data_url", ",", "$", "action_url", ",", "$", "length", "=", "3", ")", "{", "$", "e", "=", "new", "Action", "\\", "SelectRemote", "(", "$", "name", ",", "$", "placeholder", ",", "$", "data_url", ",", "$", "action_url", ",", "$", "length", ")", ";", "$", "this", "->", "addAction", "(", "$", "e", ")", ";", "return", "$", "e", ";", "}" ]
Add select remote @param $name @param $placeholder @param $data_url @param $action_url @param int $length @return \FrenchFrogs\Panel\Action\SelectRemote
[ "Add", "select", "remote" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Panel/Panel/Panel.php#L207-L212
opis/utils
lib/Dir.php
Dir.remove
public static function remove($dirname) { if (!is_dir($dirname)) { return false; } $dir = dir($dirname); while (false !== $entry = $dir->read()) { if ($entry == '.' || $entry == '..') { continue; } $item = $dirname . '/' . $entry; if (is_dir($item)) { static::remove($item); } else { unlink($item); } } return rmdir($dirname); }
php
public static function remove($dirname) { if (!is_dir($dirname)) { return false; } $dir = dir($dirname); while (false !== $entry = $dir->read()) { if ($entry == '.' || $entry == '..') { continue; } $item = $dirname . '/' . $entry; if (is_dir($item)) { static::remove($item); } else { unlink($item); } } return rmdir($dirname); }
[ "public", "static", "function", "remove", "(", "$", "dirname", ")", "{", "if", "(", "!", "is_dir", "(", "$", "dirname", ")", ")", "{", "return", "false", ";", "}", "$", "dir", "=", "dir", "(", "$", "dirname", ")", ";", "while", "(", "false", "!==", "$", "entry", "=", "$", "dir", "->", "read", "(", ")", ")", "{", "if", "(", "$", "entry", "==", "'.'", "||", "$", "entry", "==", "'..'", ")", "{", "continue", ";", "}", "$", "item", "=", "$", "dirname", ".", "'/'", ".", "$", "entry", ";", "if", "(", "is_dir", "(", "$", "item", ")", ")", "{", "static", "::", "remove", "(", "$", "item", ")", ";", "}", "else", "{", "unlink", "(", "$", "item", ")", ";", "}", "}", "return", "rmdir", "(", "$", "dirname", ")", ";", "}" ]
Remove directory @param string $dirname @return boolean
[ "Remove", "directory" ]
train
https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/Dir.php#L76-L98
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Map/RoleTableMap.php
RoleTableMap.addSelectColumns
public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { $criteria->addSelectColumn(RoleTableMap::COL_ID); $criteria->addSelectColumn(RoleTableMap::COL_NAME); $criteria->addSelectColumn(RoleTableMap::COL_DESCRIPTION); $criteria->addSelectColumn(RoleTableMap::COL_CREATE_DATE); $criteria->addSelectColumn(RoleTableMap::COL_UPDATE_DATE); $criteria->addSelectColumn(RoleTableMap::COL_STATUS); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.NAME'); $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.CREATE_DATE'); $criteria->addSelectColumn($alias . '.UPDATE_DATE'); $criteria->addSelectColumn($alias . '.STATUS'); } }
php
public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { $criteria->addSelectColumn(RoleTableMap::COL_ID); $criteria->addSelectColumn(RoleTableMap::COL_NAME); $criteria->addSelectColumn(RoleTableMap::COL_DESCRIPTION); $criteria->addSelectColumn(RoleTableMap::COL_CREATE_DATE); $criteria->addSelectColumn(RoleTableMap::COL_UPDATE_DATE); $criteria->addSelectColumn(RoleTableMap::COL_STATUS); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.NAME'); $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.CREATE_DATE'); $criteria->addSelectColumn($alias . '.UPDATE_DATE'); $criteria->addSelectColumn($alias . '.STATUS'); } }
[ "public", "static", "function", "addSelectColumns", "(", "Criteria", "$", "criteria", ",", "$", "alias", "=", "null", ")", "{", "if", "(", "null", "===", "$", "alias", ")", "{", "$", "criteria", "->", "addSelectColumn", "(", "RoleTableMap", "::", "COL_ID", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "RoleTableMap", "::", "COL_NAME", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "RoleTableMap", "::", "COL_DESCRIPTION", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "RoleTableMap", "::", "COL_CREATE_DATE", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "RoleTableMap", "::", "COL_UPDATE_DATE", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "RoleTableMap", "::", "COL_STATUS", ")", ";", "}", "else", "{", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.ID'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.NAME'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.DESCRIPTION'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.CREATE_DATE'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.UPDATE_DATE'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.STATUS'", ")", ";", "}", "}" ]
Add all the columns needed to create a new object. Note: any columns that were marked with lazyLoad="true" in the XML schema will not be added to the select list and only loaded on demand. @param Criteria $criteria object containing the columns to add. @param string $alias optional table alias @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Add", "all", "the", "columns", "needed", "to", "create", "a", "new", "object", "." ]
train
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Map/RoleTableMap.php#L322-L339
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Map/RoleTableMap.php
RoleTableMap.buildTableMap
public static function buildTableMap() { $dbMap = Propel::getServiceContainer()->getDatabaseMap(RoleTableMap::DATABASE_NAME); if (!$dbMap->hasTable(RoleTableMap::TABLE_NAME)) { $dbMap->addTableObject(new RoleTableMap()); } }
php
public static function buildTableMap() { $dbMap = Propel::getServiceContainer()->getDatabaseMap(RoleTableMap::DATABASE_NAME); if (!$dbMap->hasTable(RoleTableMap::TABLE_NAME)) { $dbMap->addTableObject(new RoleTableMap()); } }
[ "public", "static", "function", "buildTableMap", "(", ")", "{", "$", "dbMap", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getDatabaseMap", "(", "RoleTableMap", "::", "DATABASE_NAME", ")", ";", "if", "(", "!", "$", "dbMap", "->", "hasTable", "(", "RoleTableMap", "::", "TABLE_NAME", ")", ")", "{", "$", "dbMap", "->", "addTableObject", "(", "new", "RoleTableMap", "(", ")", ")", ";", "}", "}" ]
Add a TableMap instance to the database for this tableMap class.
[ "Add", "a", "TableMap", "instance", "to", "the", "database", "for", "this", "tableMap", "class", "." ]
train
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Map/RoleTableMap.php#L356-L362
matthiasbayer/datadog-client
src/Bayer/DataDogClient/Series.php
Series.getMetric
public function getMetric($name) { if (isset($this->metrics[$name])) { return $this->metrics[$name]; } throw new MetricNotFoundException("Metric $name not found"); }
php
public function getMetric($name) { if (isset($this->metrics[$name])) { return $this->metrics[$name]; } throw new MetricNotFoundException("Metric $name not found"); }
[ "public", "function", "getMetric", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "metrics", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "metrics", "[", "$", "name", "]", ";", "}", "throw", "new", "MetricNotFoundException", "(", "\"Metric $name not found\"", ")", ";", "}" ]
@param $name @throws Series\MetricNotFoundException @return Metric
[ "@param", "$name", "@throws", "Series", "\\", "MetricNotFoundException" ]
train
https://github.com/matthiasbayer/datadog-client/blob/e625132c34bf36f783077c9ee4ed3214633cd272/src/Bayer/DataDogClient/Series.php#L48-L54
matthiasbayer/datadog-client
src/Bayer/DataDogClient/Series.php
Series.removeMetric
public function removeMetric($name) { if (isset($this->metrics[$name])) { unset($this->metrics[$name]); return $this; } throw new MetricNotFoundException("Metric $name not found"); }
php
public function removeMetric($name) { if (isset($this->metrics[$name])) { unset($this->metrics[$name]); return $this; } throw new MetricNotFoundException("Metric $name not found"); }
[ "public", "function", "removeMetric", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "metrics", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "metrics", "[", "$", "name", "]", ")", ";", "return", "$", "this", ";", "}", "throw", "new", "MetricNotFoundException", "(", "\"Metric $name not found\"", ")", ";", "}" ]
@param $name @throws MetricNotFoundException @return Series
[ "@param", "$name", "@throws", "MetricNotFoundException" ]
train
https://github.com/matthiasbayer/datadog-client/blob/e625132c34bf36f783077c9ee4ed3214633cd272/src/Bayer/DataDogClient/Series.php#L93-L101
huasituo/hstcms
src/Libraries/Fields/Group.php
Group.option
public function option($option, $field = NULL) { $group = []; $option['value'] = isset($option['value']) && $option['value'] ? $option['value'] : ''; if ($field) { foreach ($field as $t) { if ($t['fieldtype'] == 'Group') { $t['setting'] = hst_str2array($t['setting']); if (preg_match_all('/\{(.+)\}/U', $t['setting']['option']['value'], $value)) { foreach ($value[1] as $v) { $group[] = $v; } } } } $_field = []; $_field[] = '<option value=""> -- </option>'; foreach ($field as $t) { if ($t['fieldtype'] != 'Group' && !@in_array($t['fieldname'], $group)) { $_field[] = '<option value="'.$t['fieldname'].'">'.$t['name'].'</option>'; } } $_field = @implode('', @array_unique($_field)); } return ' <div class="hstui-form-group hstui-form-group-sm"> <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::fields.group.field').'</label> <div class="hstui-u-sm-10 hstui-form-input"> <select class="hstui-input hstui-select" name="xx" id="fxx" >'.$_field.'</select> <div class="hstui-form-input-tips" id="J_form_tips_name">'.hst_lang('hstcms::fields.group.field.tips').'</div> </div> </div> <div class="hstui-form-group hstui-form-group-sm"> <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::fields.group.rule').'</label> <div class="hstui-u-sm-10 hstui-form-input"> <textarea name="setting[option][value]" id="fvalue" style="width:520px;height:120px;" class="hstui-input hstui-textarea">'.$option['value'].'</textarea> <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::fields.group.rule.tips').'">'.hst_lang('hstcms::fields.group.rule.tips').'</div> </div> </div> <script type="text/javascript"> Hstui.use(\'jquery\',function() { $("#fxx").change(function(){ var value = $(this).val(); var fvalue = $("#fvalue").val(); var text = $("#fxx").find("option:selected").text(); $("#fxx option[value=\'"+value+"\']").remove(); $("#fvalue").val(fvalue+" "+text+": {"+value+"}"); }); }); </script>'; }
php
public function option($option, $field = NULL) { $group = []; $option['value'] = isset($option['value']) && $option['value'] ? $option['value'] : ''; if ($field) { foreach ($field as $t) { if ($t['fieldtype'] == 'Group') { $t['setting'] = hst_str2array($t['setting']); if (preg_match_all('/\{(.+)\}/U', $t['setting']['option']['value'], $value)) { foreach ($value[1] as $v) { $group[] = $v; } } } } $_field = []; $_field[] = '<option value=""> -- </option>'; foreach ($field as $t) { if ($t['fieldtype'] != 'Group' && !@in_array($t['fieldname'], $group)) { $_field[] = '<option value="'.$t['fieldname'].'">'.$t['name'].'</option>'; } } $_field = @implode('', @array_unique($_field)); } return ' <div class="hstui-form-group hstui-form-group-sm"> <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::fields.group.field').'</label> <div class="hstui-u-sm-10 hstui-form-input"> <select class="hstui-input hstui-select" name="xx" id="fxx" >'.$_field.'</select> <div class="hstui-form-input-tips" id="J_form_tips_name">'.hst_lang('hstcms::fields.group.field.tips').'</div> </div> </div> <div class="hstui-form-group hstui-form-group-sm"> <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::fields.group.rule').'</label> <div class="hstui-u-sm-10 hstui-form-input"> <textarea name="setting[option][value]" id="fvalue" style="width:520px;height:120px;" class="hstui-input hstui-textarea">'.$option['value'].'</textarea> <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::fields.group.rule.tips').'">'.hst_lang('hstcms::fields.group.rule.tips').'</div> </div> </div> <script type="text/javascript"> Hstui.use(\'jquery\',function() { $("#fxx").change(function(){ var value = $(this).val(); var fvalue = $("#fvalue").val(); var text = $("#fxx").find("option:selected").text(); $("#fxx option[value=\'"+value+"\']").remove(); $("#fvalue").val(fvalue+" "+text+": {"+value+"}"); }); }); </script>'; }
[ "public", "function", "option", "(", "$", "option", ",", "$", "field", "=", "NULL", ")", "{", "$", "group", "=", "[", "]", ";", "$", "option", "[", "'value'", "]", "=", "isset", "(", "$", "option", "[", "'value'", "]", ")", "&&", "$", "option", "[", "'value'", "]", "?", "$", "option", "[", "'value'", "]", ":", "''", ";", "if", "(", "$", "field", ")", "{", "foreach", "(", "$", "field", "as", "$", "t", ")", "{", "if", "(", "$", "t", "[", "'fieldtype'", "]", "==", "'Group'", ")", "{", "$", "t", "[", "'setting'", "]", "=", "hst_str2array", "(", "$", "t", "[", "'setting'", "]", ")", ";", "if", "(", "preg_match_all", "(", "'/\\{(.+)\\}/U'", ",", "$", "t", "[", "'setting'", "]", "[", "'option'", "]", "[", "'value'", "]", ",", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "[", "1", "]", "as", "$", "v", ")", "{", "$", "group", "[", "]", "=", "$", "v", ";", "}", "}", "}", "}", "$", "_field", "=", "[", "]", ";", "$", "_field", "[", "]", "=", "'<option value=\"\"> -- </option>'", ";", "foreach", "(", "$", "field", "as", "$", "t", ")", "{", "if", "(", "$", "t", "[", "'fieldtype'", "]", "!=", "'Group'", "&&", "!", "@", "in_array", "(", "$", "t", "[", "'fieldname'", "]", ",", "$", "group", ")", ")", "{", "$", "_field", "[", "]", "=", "'<option value=\"'", ".", "$", "t", "[", "'fieldname'", "]", ".", "'\">'", ".", "$", "t", "[", "'name'", "]", ".", "'</option>'", ";", "}", "}", "$", "_field", "=", "@", "implode", "(", "''", ",", "@", "array_unique", "(", "$", "_field", ")", ")", ";", "}", "return", "'\n\t\t\t<div class=\"hstui-form-group hstui-form-group-sm\">\n\t <label class=\"hstui-u-sm-2 hstui-form-label\">'", ".", "hst_lang", "(", "'hstcms::fields.group.field'", ")", ".", "'</label>\n\t <div class=\"hstui-u-sm-10 hstui-form-input\">\n\t <select class=\"hstui-input hstui-select\" name=\"xx\" id=\"fxx\" >'", ".", "$", "_field", ".", "'</select>\n\t <div class=\"hstui-form-input-tips\" id=\"J_form_tips_name\">'", ".", "hst_lang", "(", "'hstcms::fields.group.field.tips'", ")", ".", "'</div>\n\t </div>\n\t </div>\n\t\t\t<div class=\"hstui-form-group hstui-form-group-sm\">\n\t <label class=\"hstui-u-sm-2 hstui-form-label\">'", ".", "hst_lang", "(", "'hstcms::fields.group.rule'", ")", ".", "'</label>\n\t <div class=\"hstui-u-sm-10 hstui-form-input\">\n\t <textarea name=\"setting[option][value]\" id=\"fvalue\" style=\"width:520px;height:120px;\" class=\"hstui-input hstui-textarea\">'", ".", "$", "option", "[", "'value'", "]", ".", "'</textarea>\n\t <div class=\"hstui-form-input-tips\" id=\"J_form_tips_name\" data-tips=\"'", ".", "hst_lang", "(", "'hstcms::fields.group.rule.tips'", ")", ".", "'\">'", ".", "hst_lang", "(", "'hstcms::fields.group.rule.tips'", ")", ".", "'</div>\n\t </div>\n\t </div>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\tHstui.use(\\'jquery\\',function() {\n\t\t\t\t\t$(\"#fxx\").change(function(){\n\t\t\t\t\t\tvar value = $(this).val();\n\t\t\t\t\t\tvar fvalue = $(\"#fvalue\").val();\n\t\t\t\t\t\tvar text = $(\"#fxx\").find(\"option:selected\").text();\n\t\t\t\t\t\t$(\"#fxx option[value=\\'\"+value+\"\\']\").remove();\n\t\t\t\t\t\t$(\"#fvalue\").val(fvalue+\" \"+text+\": {\"+value+\"}\");\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\t</script>'", ";", "}" ]
字段相关属性参数 @param array $value 值 @param array $field 字段集合 @return string
[ "字段相关属性参数" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Libraries/Fields/Group.php#L30-L80
huasituo/hstcms
src/Libraries/Fields/Group.php
Group.input
public function input($cname, $name, $cfg, $value = NULL, $id = 0) { // 字段显示名称 $text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '<font color="red">*</font>' : '').'&nbsp;'.$cname.':'; // 字段提示信息 $tips = isset($cfg['validate']['tips']) && $cfg['validate']['tips'] ? $cfg['validate']['tips']: ''; // 字段默认值 $value = isset($cfg['option']['value']) ? $cfg['option']['value'] : ""; // 当字段必填时,加入html5验证标签 if (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1) { $attr.= ' required="required"'; } return $this->input_format($name, $text, $value, $tips); }
php
public function input($cname, $name, $cfg, $value = NULL, $id = 0) { // 字段显示名称 $text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '<font color="red">*</font>' : '').'&nbsp;'.$cname.':'; // 字段提示信息 $tips = isset($cfg['validate']['tips']) && $cfg['validate']['tips'] ? $cfg['validate']['tips']: ''; // 字段默认值 $value = isset($cfg['option']['value']) ? $cfg['option']['value'] : ""; // 当字段必填时,加入html5验证标签 if (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1) { $attr.= ' required="required"'; } return $this->input_format($name, $text, $value, $tips); }
[ "public", "function", "input", "(", "$", "cname", ",", "$", "name", ",", "$", "cfg", ",", "$", "value", "=", "NULL", ",", "$", "id", "=", "0", ")", "{", "// 字段显示名称", "$", "text", "=", "(", "isset", "(", "$", "cfg", "[", "'validate'", "]", "[", "'required'", "]", ")", "&&", "$", "cfg", "[", "'validate'", "]", "[", "'required'", "]", "==", "1", "?", "'<font color=\"red\">*</font>'", ":", "''", ")", ".", "'&nbsp;'", ".", "$", "cname", ".", "':';", "", "// 字段提示信息", "$", "tips", "=", "isset", "(", "$", "cfg", "[", "'validate'", "]", "[", "'tips'", "]", ")", "&&", "$", "cfg", "[", "'validate'", "]", "[", "'tips'", "]", "?", "$", "cfg", "[", "'validate'", "]", "[", "'tips'", "]", ":", "''", ";", "// 字段默认值", "$", "value", "=", "isset", "(", "$", "cfg", "[", "'option'", "]", "[", "'value'", "]", ")", "?", "$", "cfg", "[", "'option'", "]", "[", "'value'", "]", ":", "\"\"", ";", "// 当字段必填时,加入html5验证标签", "if", "(", "isset", "(", "$", "cfg", "[", "'validate'", "]", "[", "'required'", "]", ")", "&&", "$", "cfg", "[", "'validate'", "]", "[", "'required'", "]", "==", "1", ")", "{", "$", "attr", ".=", "' required=\"required\"'", ";", "}", "return", "$", "this", "->", "input_format", "(", "$", "name", ",", "$", "text", ",", "$", "value", ",", "$", "tips", ")", ";", "}" ]
字段表单输入 @param string $cname 字段别名 @param string $name 字段名称 @param array $cfg 字段配置 @param array $data 值 @return string
[ "字段表单输入" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Libraries/Fields/Group.php#L91-L104
yosmanyga/resource
src/Yosmanyga/Resource/Compiler/DelegatorCompiler.php
DelegatorCompiler.pickCompiler
protected function pickCompiler($definition) { foreach ($this->compilers as $i => $compiler) { if ($compiler->supports($definition)) { if (0 != $i) { // Move compiler to top to improve next pick unset($this->compilers[$i]); array_unshift($this->compilers, $compiler); } return $this->compilers[0]; } } throw new \RuntimeException('No compiler is able to work with the resource'); }
php
protected function pickCompiler($definition) { foreach ($this->compilers as $i => $compiler) { if ($compiler->supports($definition)) { if (0 != $i) { // Move compiler to top to improve next pick unset($this->compilers[$i]); array_unshift($this->compilers, $compiler); } return $this->compilers[0]; } } throw new \RuntimeException('No compiler is able to work with the resource'); }
[ "protected", "function", "pickCompiler", "(", "$", "definition", ")", "{", "foreach", "(", "$", "this", "->", "compilers", "as", "$", "i", "=>", "$", "compiler", ")", "{", "if", "(", "$", "compiler", "->", "supports", "(", "$", "definition", ")", ")", "{", "if", "(", "0", "!=", "$", "i", ")", "{", "// Move compiler to top to improve next pick", "unset", "(", "$", "this", "->", "compilers", "[", "$", "i", "]", ")", ";", "array_unshift", "(", "$", "this", "->", "compilers", ",", "$", "compiler", ")", ";", "}", "return", "$", "this", "->", "compilers", "[", "0", "]", ";", "}", "}", "throw", "new", "\\", "RuntimeException", "(", "'No compiler is able to work with the resource'", ")", ";", "}" ]
@param mixed $definition @throws \RuntimeException If no compiler is able to support the resource @return \Yosmanyga\Resource\Compiler\CompilerInterface
[ "@param", "mixed", "$definition" ]
train
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Compiler/DelegatorCompiler.php#L48-L63
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtFontFace/FontFaceDeclaration.php
FontFaceDeclaration.checkProperty
public function checkProperty(&$property) { if (parent::checkProperty($property)) { if (preg_match( '/^(?:src|unicode-range|font-(?:family|variant|feature-settings|stretch|weight|style))$/D', $property)) { return true; } else { $this->setIsValid(false); $this->addValidationError("Invalid property '$property' for @font-face declaration."); } } return false; }
php
public function checkProperty(&$property) { if (parent::checkProperty($property)) { if (preg_match( '/^(?:src|unicode-range|font-(?:family|variant|feature-settings|stretch|weight|style))$/D', $property)) { return true; } else { $this->setIsValid(false); $this->addValidationError("Invalid property '$property' for @font-face declaration."); } } return false; }
[ "public", "function", "checkProperty", "(", "&", "$", "property", ")", "{", "if", "(", "parent", "::", "checkProperty", "(", "$", "property", ")", ")", "{", "if", "(", "preg_match", "(", "'/^(?:src|unicode-range|font-(?:family|variant|feature-settings|stretch|weight|style))$/D'", ",", "$", "property", ")", ")", "{", "return", "true", ";", "}", "else", "{", "$", "this", "->", "setIsValid", "(", "false", ")", ";", "$", "this", "->", "addValidationError", "(", "\"Invalid property '$property' for @font-face declaration.\"", ")", ";", "}", "}", "return", "false", ";", "}" ]
Checks the declaration property. @param string $property @return bool
[ "Checks", "the", "declaration", "property", "." ]
train
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtFontFace/FontFaceDeclaration.php#L15-L29
cronario/cronario
src/Manager.php
Manager.parseManagerStatKey
public static function parseManagerStatKey($key) { list($namespace, $appId, $workerClass) = explode(':', $key); return [ static::P_STATS_KEY_NAMESPACE => $namespace, static::P_STATS_KEY_APP_ID => $appId, static::P_STATS_KEY_WORKER_CLASS => $workerClass, ]; }
php
public static function parseManagerStatKey($key) { list($namespace, $appId, $workerClass) = explode(':', $key); return [ static::P_STATS_KEY_NAMESPACE => $namespace, static::P_STATS_KEY_APP_ID => $appId, static::P_STATS_KEY_WORKER_CLASS => $workerClass, ]; }
[ "public", "static", "function", "parseManagerStatKey", "(", "$", "key", ")", "{", "list", "(", "$", "namespace", ",", "$", "appId", ",", "$", "workerClass", ")", "=", "explode", "(", "':'", ",", "$", "key", ")", ";", "return", "[", "static", "::", "P_STATS_KEY_NAMESPACE", "=>", "$", "namespace", ",", "static", "::", "P_STATS_KEY_APP_ID", "=>", "$", "appId", ",", "static", "::", "P_STATS_KEY_WORKER_CLASS", "=>", "$", "workerClass", ",", "]", ";", "}" ]
@param $key @return array
[ "@param", "$key" ]
train
https://github.com/cronario/cronario/blob/954df60e95efd3085269331d435e8ce6f4980441/src/Manager.php#L265-L274
cronario/cronario
src/Manager.php
Manager.getWorkerConfig
protected function getWorkerConfig($key = null) { /** @var AbstractWorker $class */ if (null === static::$workerConfig) { $class = $this->workerClass; static::$workerConfig = $class::getConfig(); } return (null === $key) ? static::$workerConfig : static::$workerConfig[$key]; }
php
protected function getWorkerConfig($key = null) { /** @var AbstractWorker $class */ if (null === static::$workerConfig) { $class = $this->workerClass; static::$workerConfig = $class::getConfig(); } return (null === $key) ? static::$workerConfig : static::$workerConfig[$key]; }
[ "protected", "function", "getWorkerConfig", "(", "$", "key", "=", "null", ")", "{", "/** @var AbstractWorker $class */", "if", "(", "null", "===", "static", "::", "$", "workerConfig", ")", "{", "$", "class", "=", "$", "this", "->", "workerClass", ";", "static", "::", "$", "workerConfig", "=", "$", "class", "::", "getConfig", "(", ")", ";", "}", "return", "(", "null", "===", "$", "key", ")", "?", "static", "::", "$", "workerConfig", ":", "static", "::", "$", "workerConfig", "[", "$", "key", "]", ";", "}" ]
@param null $key @return mixed
[ "@param", "null", "$key" ]
train
https://github.com/cronario/cronario/blob/954df60e95efd3085269331d435e8ce6f4980441/src/Manager.php#L508-L519
huasituo/hstcms
src/HstcmsServiceProvider.php
HstcmsServiceProvider.boot
public function boot() { $this->publishes([ __DIR__.'/../config/hstcms.php' => config_path('hstcms.php'), ], 'config'); $this->loadViewsFrom(__DIR__.'/../views', 'hstcms'); $this->publishes([ __DIR__.'/../assets' => public_path('assets'), ], 'public'); $this->loadMigrationsFrom(__DIR__.'/Database/Migrations'); $this->loadTranslationsFrom(__DIR__.'/../translations', 'hstcms'); //处理单页多元化模版 $this->loadViewsFrom(public_path('theme/special'), 'special'); Paginator::defaultView('hstcms::pagination.default'); Paginator::defaultSimpleView('hstcms::pagination.simple-default'); }
php
public function boot() { $this->publishes([ __DIR__.'/../config/hstcms.php' => config_path('hstcms.php'), ], 'config'); $this->loadViewsFrom(__DIR__.'/../views', 'hstcms'); $this->publishes([ __DIR__.'/../assets' => public_path('assets'), ], 'public'); $this->loadMigrationsFrom(__DIR__.'/Database/Migrations'); $this->loadTranslationsFrom(__DIR__.'/../translations', 'hstcms'); //处理单页多元化模版 $this->loadViewsFrom(public_path('theme/special'), 'special'); Paginator::defaultView('hstcms::pagination.default'); Paginator::defaultSimpleView('hstcms::pagination.simple-default'); }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../config/hstcms.php'", "=>", "config_path", "(", "'hstcms.php'", ")", ",", "]", ",", "'config'", ")", ";", "$", "this", "->", "loadViewsFrom", "(", "__DIR__", ".", "'/../views'", ",", "'hstcms'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../assets'", "=>", "public_path", "(", "'assets'", ")", ",", "]", ",", "'public'", ")", ";", "$", "this", "->", "loadMigrationsFrom", "(", "__DIR__", ".", "'/Database/Migrations'", ")", ";", "$", "this", "->", "loadTranslationsFrom", "(", "__DIR__", ".", "'/../translations'", ",", "'hstcms'", ")", ";", "//处理单页多元化模版", "$", "this", "->", "loadViewsFrom", "(", "public_path", "(", "'theme/special'", ")", ",", "'special'", ")", ";", "Paginator", "::", "defaultView", "(", "'hstcms::pagination.default'", ")", ";", "Paginator", "::", "defaultSimpleView", "(", "'hstcms::pagination.simple-default'", ")", ";", "}" ]
Boot the service provider.
[ "Boot", "the", "service", "provider", "." ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/HstcmsServiceProvider.php#L31-L46
huasituo/hstcms
src/HstcmsServiceProvider.php
HstcmsServiceProvider.register
public function register() { $this->mergeConfigFrom( __DIR__.'/../config/hstcms.php', 'hstcms' ); $this->app->register(RouteServiceProvider::class); $this->app->register(HelperServiceProvider::class); $this->app->register(ConsoleServiceProvider::class); $this->app->register(LibrariesServiceProvider::class); $this->app->register(RepositoryServiceProvider::class); $this->app->register(MiddlewareServiceProvider::class); $this->app->register(GeneratorServiceProvider::class); $this->app->singleton('hstcms', function ($app) { $repository = $app->make(Repository::class); return new Hstcms($app, $repository); }); }
php
public function register() { $this->mergeConfigFrom( __DIR__.'/../config/hstcms.php', 'hstcms' ); $this->app->register(RouteServiceProvider::class); $this->app->register(HelperServiceProvider::class); $this->app->register(ConsoleServiceProvider::class); $this->app->register(LibrariesServiceProvider::class); $this->app->register(RepositoryServiceProvider::class); $this->app->register(MiddlewareServiceProvider::class); $this->app->register(GeneratorServiceProvider::class); $this->app->singleton('hstcms', function ($app) { $repository = $app->make(Repository::class); return new Hstcms($app, $repository); }); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/../config/hstcms.php'", ",", "'hstcms'", ")", ";", "$", "this", "->", "app", "->", "register", "(", "RouteServiceProvider", "::", "class", ")", ";", "$", "this", "->", "app", "->", "register", "(", "HelperServiceProvider", "::", "class", ")", ";", "$", "this", "->", "app", "->", "register", "(", "ConsoleServiceProvider", "::", "class", ")", ";", "$", "this", "->", "app", "->", "register", "(", "LibrariesServiceProvider", "::", "class", ")", ";", "$", "this", "->", "app", "->", "register", "(", "RepositoryServiceProvider", "::", "class", ")", ";", "$", "this", "->", "app", "->", "register", "(", "MiddlewareServiceProvider", "::", "class", ")", ";", "$", "this", "->", "app", "->", "register", "(", "GeneratorServiceProvider", "::", "class", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'hstcms'", ",", "function", "(", "$", "app", ")", "{", "$", "repository", "=", "$", "app", "->", "make", "(", "Repository", "::", "class", ")", ";", "return", "new", "Hstcms", "(", "$", "app", ",", "$", "repository", ")", ";", "}", ")", ";", "}" ]
Register the service provider.
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/HstcmsServiceProvider.php#L51-L68
drunomics/service-utils
src/Core/Render/MainContent/AjaxRendererTrait.php
AjaxRendererTrait.getAjaxRenderer
public function getAjaxRenderer() { if (empty($this->AjaxRenderer)) { $this->AjaxRenderer = \Drupal::service('main_content_renderer.ajax'); } return $this->AjaxRenderer; }
php
public function getAjaxRenderer() { if (empty($this->AjaxRenderer)) { $this->AjaxRenderer = \Drupal::service('main_content_renderer.ajax'); } return $this->AjaxRenderer; }
[ "public", "function", "getAjaxRenderer", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "AjaxRenderer", ")", ")", "{", "$", "this", "->", "AjaxRenderer", "=", "\\", "Drupal", "::", "service", "(", "'main_content_renderer.ajax'", ")", ";", "}", "return", "$", "this", "->", "AjaxRenderer", ";", "}" ]
Gets the ajax renderer. @return \Drupal\Core\Render\MainContent\MainContentRendererInterface The ajax renderer.
[ "Gets", "the", "ajax", "renderer", "." ]
train
https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/Core/Render/MainContent/AjaxRendererTrait.php#L38-L43
yosmanyga/resource
src/Yosmanyga/Resource/Normalizer/DelegatorNormalizer.php
DelegatorNormalizer.supports
public function supports($data, Resource $resource) { try { if ($this->pickNormalizer($data, $resource)) { return true; } } catch (\RuntimeException $e) { } return false; }
php
public function supports($data, Resource $resource) { try { if ($this->pickNormalizer($data, $resource)) { return true; } } catch (\RuntimeException $e) { } return false; }
[ "public", "function", "supports", "(", "$", "data", ",", "Resource", "$", "resource", ")", "{", "try", "{", "if", "(", "$", "this", "->", "pickNormalizer", "(", "$", "data", ",", "$", "resource", ")", ")", "{", "return", "true", ";", "}", "}", "catch", "(", "\\", "RuntimeException", "$", "e", ")", "{", "}", "return", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Normalizer/DelegatorNormalizer.php#L25-L35
yosmanyga/resource
src/Yosmanyga/Resource/Normalizer/DelegatorNormalizer.php
DelegatorNormalizer.normalize
public function normalize($data, Resource $resource) { return $this->pickNormalizer($data, $resource)->normalize($data, $resource); }
php
public function normalize($data, Resource $resource) { return $this->pickNormalizer($data, $resource)->normalize($data, $resource); }
[ "public", "function", "normalize", "(", "$", "data", ",", "Resource", "$", "resource", ")", "{", "return", "$", "this", "->", "pickNormalizer", "(", "$", "data", ",", "$", "resource", ")", "->", "normalize", "(", "$", "data", ",", "$", "resource", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Normalizer/DelegatorNormalizer.php#L40-L43
yosmanyga/resource
src/Yosmanyga/Resource/Normalizer/DelegatorNormalizer.php
DelegatorNormalizer.pickNormalizer
protected function pickNormalizer($data, Resource $resource) { foreach ($this->normalizers as $i => $normalizer) { if ($normalizer->supports($data, $resource)) { if (0 != $i) { // Move normalizer to top to improve next pick unset($this->normalizers[$i]); array_unshift($this->normalizers, $normalizer); } return $this->normalizers[0]; } } throw new \RuntimeException('No normalizer is able to work with the resource'); }
php
protected function pickNormalizer($data, Resource $resource) { foreach ($this->normalizers as $i => $normalizer) { if ($normalizer->supports($data, $resource)) { if (0 != $i) { // Move normalizer to top to improve next pick unset($this->normalizers[$i]); array_unshift($this->normalizers, $normalizer); } return $this->normalizers[0]; } } throw new \RuntimeException('No normalizer is able to work with the resource'); }
[ "protected", "function", "pickNormalizer", "(", "$", "data", ",", "Resource", "$", "resource", ")", "{", "foreach", "(", "$", "this", "->", "normalizers", "as", "$", "i", "=>", "$", "normalizer", ")", "{", "if", "(", "$", "normalizer", "->", "supports", "(", "$", "data", ",", "$", "resource", ")", ")", "{", "if", "(", "0", "!=", "$", "i", ")", "{", "// Move normalizer to top to improve next pick", "unset", "(", "$", "this", "->", "normalizers", "[", "$", "i", "]", ")", ";", "array_unshift", "(", "$", "this", "->", "normalizers", ",", "$", "normalizer", ")", ";", "}", "return", "$", "this", "->", "normalizers", "[", "0", "]", ";", "}", "}", "throw", "new", "\\", "RuntimeException", "(", "'No normalizer is able to work with the resource'", ")", ";", "}" ]
@param mixed $data @param \Yosmanyga\Resource\Resource $resource @throws \RuntimeException If no normalizer is able to support the resource @return \Yosmanyga\Resource\Normalizer\NormalizerInterface
[ "@param", "mixed", "$data", "@param", "\\", "Yosmanyga", "\\", "Resource", "\\", "Resource", "$resource" ]
train
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Normalizer/DelegatorNormalizer.php#L54-L69
constant-null/backstubber
src/Utility/Formatter.php
Formatter.isArrayMultiline
protected static function isArrayMultiline($array) { if (empty($array)) return false; switch (self::getArrayMode()) { case self::ARR_MODE_SINGLELINE: $isMultiline = false; break; case self::ARR_MODE_MULTILINE: $isMultiline = true; break; default: // for ARR_MODE_AUTO $isMultiline = Arr::isAssoc($array) ? true : false; return $isMultiline; } return $isMultiline; }
php
protected static function isArrayMultiline($array) { if (empty($array)) return false; switch (self::getArrayMode()) { case self::ARR_MODE_SINGLELINE: $isMultiline = false; break; case self::ARR_MODE_MULTILINE: $isMultiline = true; break; default: // for ARR_MODE_AUTO $isMultiline = Arr::isAssoc($array) ? true : false; return $isMultiline; } return $isMultiline; }
[ "protected", "static", "function", "isArrayMultiline", "(", "$", "array", ")", "{", "if", "(", "empty", "(", "$", "array", ")", ")", "return", "false", ";", "switch", "(", "self", "::", "getArrayMode", "(", ")", ")", "{", "case", "self", "::", "ARR_MODE_SINGLELINE", ":", "$", "isMultiline", "=", "false", ";", "break", ";", "case", "self", "::", "ARR_MODE_MULTILINE", ":", "$", "isMultiline", "=", "true", ";", "break", ";", "default", ":", "// for ARR_MODE_AUTO", "$", "isMultiline", "=", "Arr", "::", "isAssoc", "(", "$", "array", ")", "?", "true", ":", "false", ";", "return", "$", "isMultiline", ";", "}", "return", "$", "isMultiline", ";", "}" ]
Determines if array should be formatted as a multiline one or not @param array $array @return bool
[ "Determines", "if", "array", "should", "be", "formatted", "as", "a", "multiline", "one", "or", "not" ]
train
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Utility/Formatter.php#L28-L44
constant-null/backstubber
src/Utility/Formatter.php
Formatter.prepareArrayLines
protected static function prepareArrayLines(array $array) { $isAssoc = Arr::isAssoc($array); array_walk($array, function (&$value, $index, $withIndexes = false) { if (is_array($value)) { $value = self::formatArray($value); } else { $value = self::formatScalar($value); } if ($withIndexes) { $value = self::formatScalar($index) . ' => ' . $value; } }, $isAssoc); return $array; }
php
protected static function prepareArrayLines(array $array) { $isAssoc = Arr::isAssoc($array); array_walk($array, function (&$value, $index, $withIndexes = false) { if (is_array($value)) { $value = self::formatArray($value); } else { $value = self::formatScalar($value); } if ($withIndexes) { $value = self::formatScalar($index) . ' => ' . $value; } }, $isAssoc); return $array; }
[ "protected", "static", "function", "prepareArrayLines", "(", "array", "$", "array", ")", "{", "$", "isAssoc", "=", "Arr", "::", "isAssoc", "(", "$", "array", ")", ";", "array_walk", "(", "$", "array", ",", "function", "(", "&", "$", "value", ",", "$", "index", ",", "$", "withIndexes", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "self", "::", "formatArray", "(", "$", "value", ")", ";", "}", "else", "{", "$", "value", "=", "self", "::", "formatScalar", "(", "$", "value", ")", ";", "}", "if", "(", "$", "withIndexes", ")", "{", "$", "value", "=", "self", "::", "formatScalar", "(", "$", "index", ")", ".", "' => '", ".", "$", "value", ";", "}", "}", ",", "$", "isAssoc", ")", ";", "return", "$", "array", ";", "}" ]
Prepare array elements for formatting. @param array $array @return array
[ "Prepare", "array", "elements", "for", "formatting", "." ]
train
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Utility/Formatter.php#L63-L80
constant-null/backstubber
src/Utility/Formatter.php
Formatter.indentLines
public static function indentLines($text, $indent, $skipFirstLine = false) { $lines = explode(PHP_EOL, $text); // (つ◕.◕)つ━☆゚.*・。゚ !$skipFirstLine || $preparedLines[] = array_shift($lines); foreach ($lines as $line) { $preparedLines[] = self::indent($indent) . rtrim($line); } return implode(PHP_EOL, $preparedLines); }
php
public static function indentLines($text, $indent, $skipFirstLine = false) { $lines = explode(PHP_EOL, $text); // (つ◕.◕)つ━☆゚.*・。゚ !$skipFirstLine || $preparedLines[] = array_shift($lines); foreach ($lines as $line) { $preparedLines[] = self::indent($indent) . rtrim($line); } return implode(PHP_EOL, $preparedLines); }
[ "public", "static", "function", "indentLines", "(", "$", "text", ",", "$", "indent", ",", "$", "skipFirstLine", "=", "false", ")", "{", "$", "lines", "=", "explode", "(", "PHP_EOL", ",", "$", "text", ")", ";", "// (つ◕.◕)つ━☆゚.*・。゚", "!", "$", "skipFirstLine", "||", "$", "preparedLines", "[", "]", "=", "array_shift", "(", "$", "lines", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "preparedLines", "[", "]", "=", "self", "::", "indent", "(", "$", "indent", ")", ".", "rtrim", "(", "$", "line", ")", ";", "}", "return", "implode", "(", "PHP_EOL", ",", "$", "preparedLines", ")", ";", "}" ]
Add indents to multiline text @param string $text @param integer $indent indent in spaces @param bool $skipFirstLine = false not apply indent to the first line of text @return array
[ "Add", "indents", "to", "multiline", "text" ]
train
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Utility/Formatter.php#L90-L102
constant-null/backstubber
src/Utility/Formatter.php
Formatter.formatArray
public static function formatArray(array $array, $braces = true) { $isMultiline = self::isArrayMultiline($array); $array = self::prepareArrayLines($array); $eol = $isMultiline ? PHP_EOL : ''; $output = implode($array, ', ' . $eol); if ($isMultiline) { // apply base indent to array elements $output = self::indentLines($output, self::$tabSize); } if ($braces) { $output = implode(['[', $output, ']'], $eol); } else { $output = $eol . $output . $eol; } return $output; }
php
public static function formatArray(array $array, $braces = true) { $isMultiline = self::isArrayMultiline($array); $array = self::prepareArrayLines($array); $eol = $isMultiline ? PHP_EOL : ''; $output = implode($array, ', ' . $eol); if ($isMultiline) { // apply base indent to array elements $output = self::indentLines($output, self::$tabSize); } if ($braces) { $output = implode(['[', $output, ']'], $eol); } else { $output = $eol . $output . $eol; } return $output; }
[ "public", "static", "function", "formatArray", "(", "array", "$", "array", ",", "$", "braces", "=", "true", ")", "{", "$", "isMultiline", "=", "self", "::", "isArrayMultiline", "(", "$", "array", ")", ";", "$", "array", "=", "self", "::", "prepareArrayLines", "(", "$", "array", ")", ";", "$", "eol", "=", "$", "isMultiline", "?", "PHP_EOL", ":", "''", ";", "$", "output", "=", "implode", "(", "$", "array", ",", "', '", ".", "$", "eol", ")", ";", "if", "(", "$", "isMultiline", ")", "{", "// apply base indent to array elements", "$", "output", "=", "self", "::", "indentLines", "(", "$", "output", ",", "self", "::", "$", "tabSize", ")", ";", "}", "if", "(", "$", "braces", ")", "{", "$", "output", "=", "implode", "(", "[", "'['", ",", "$", "output", ",", "']'", "]", ",", "$", "eol", ")", ";", "}", "else", "{", "$", "output", "=", "$", "eol", ".", "$", "output", ".", "$", "eol", ";", "}", "return", "$", "output", ";", "}" ]
Return text representation of array @param array $array input array @param bool $braces add array braces to output @return string
[ "Return", "text", "representation", "of", "array" ]
train
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Utility/Formatter.php#L131-L153
goblindegook/Syllables
src/Exception/WP_Exception.php
WP_Exception.get_wp_error
public function get_wp_error() { return $this->wp_error ? $this->wp_error : new \WP_Error( $this->code, $this->message, $this ); }
php
public function get_wp_error() { return $this->wp_error ? $this->wp_error : new \WP_Error( $this->code, $this->message, $this ); }
[ "public", "function", "get_wp_error", "(", ")", "{", "return", "$", "this", "->", "wp_error", "?", "$", "this", "->", "wp_error", ":", "new", "\\", "WP_Error", "(", "$", "this", "->", "code", ",", "$", "this", "->", "message", ",", "$", "this", ")", ";", "}" ]
Obtain the exception's `\WP_Error` object. @return \WP_Error WordPress error.
[ "Obtain", "the", "exception", "s", "\\", "WP_Error", "object", "." ]
train
https://github.com/goblindegook/Syllables/blob/1a98cd15e37595a85b242242f88fee38c4e36acc/src/Exception/WP_Exception.php#L80-L82
movoin/one-swoole
src/Validation/Validators/CustomValidator.php
CustomValidator.createFromArray
public static function createFromArray(Validator $validator, array $callback): self { $self = new static($validator); $self->setCallback(function (array $attributes, string $name, array $parameters) use ($callback) { return call_user_func_array($callback, [ $attributes, $name, $parameters ]); }); return $self; }
php
public static function createFromArray(Validator $validator, array $callback): self { $self = new static($validator); $self->setCallback(function (array $attributes, string $name, array $parameters) use ($callback) { return call_user_func_array($callback, [ $attributes, $name, $parameters ]); }); return $self; }
[ "public", "static", "function", "createFromArray", "(", "Validator", "$", "validator", ",", "array", "$", "callback", ")", ":", "self", "{", "$", "self", "=", "new", "static", "(", "$", "validator", ")", ";", "$", "self", "->", "setCallback", "(", "function", "(", "array", "$", "attributes", ",", "string", "$", "name", ",", "array", "$", "parameters", ")", "use", "(", "$", "callback", ")", "{", "return", "call_user_func_array", "(", "$", "callback", ",", "[", "$", "attributes", ",", "$", "name", ",", "$", "parameters", "]", ")", ";", "}", ")", ";", "return", "$", "self", ";", "}" ]
从数组回调创建自定义校验器 @param \One\Validation\Validator $validator @param array $callback @return self
[ "从数组回调创建自定义校验器" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Validation/Validators/CustomValidator.php#L34-L47
movoin/one-swoole
src/Validation/Validators/CustomValidator.php
CustomValidator.createFromClosure
public static function createFromClosure(Validator $validator, callable $callback): self { $self = new static($validator); $self->setCallback(function (array $attributes, string $name, array $parameters) use ($callback) { return $callback($attributes, $name, $parameters); }); return $self; }
php
public static function createFromClosure(Validator $validator, callable $callback): self { $self = new static($validator); $self->setCallback(function (array $attributes, string $name, array $parameters) use ($callback) { return $callback($attributes, $name, $parameters); }); return $self; }
[ "public", "static", "function", "createFromClosure", "(", "Validator", "$", "validator", ",", "callable", "$", "callback", ")", ":", "self", "{", "$", "self", "=", "new", "static", "(", "$", "validator", ")", ";", "$", "self", "->", "setCallback", "(", "function", "(", "array", "$", "attributes", ",", "string", "$", "name", ",", "array", "$", "parameters", ")", "use", "(", "$", "callback", ")", "{", "return", "$", "callback", "(", "$", "attributes", ",", "$", "name", ",", "$", "parameters", ")", ";", "}", ")", ";", "return", "$", "self", ";", "}" ]
从回调创建自定义校验器 @param \One\Validation\Validator $validator @param callable $callback @return self
[ "从回调创建自定义校验器" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Validation/Validators/CustomValidator.php#L57-L66
movoin/one-swoole
src/Validation/Validators/CustomValidator.php
CustomValidator.validate
protected function validate(array $attributes, string $name, array $parameters = []): bool { $callback = $this->callback; if (($result = $callback($attributes, $name, $parameters)) === false) { $this->addError($name, $parameters, 'verification failed'); } unset($callback); return $result; }
php
protected function validate(array $attributes, string $name, array $parameters = []): bool { $callback = $this->callback; if (($result = $callback($attributes, $name, $parameters)) === false) { $this->addError($name, $parameters, 'verification failed'); } unset($callback); return $result; }
[ "protected", "function", "validate", "(", "array", "$", "attributes", ",", "string", "$", "name", ",", "array", "$", "parameters", "=", "[", "]", ")", ":", "bool", "{", "$", "callback", "=", "$", "this", "->", "callback", ";", "if", "(", "(", "$", "result", "=", "$", "callback", "(", "$", "attributes", ",", "$", "name", ",", "$", "parameters", ")", ")", "===", "false", ")", "{", "$", "this", "->", "addError", "(", "$", "name", ",", "$", "parameters", ",", "'verification failed'", ")", ";", "}", "unset", "(", "$", "callback", ")", ";", "return", "$", "result", ";", "}" ]
校验规则 @param array $attributes @param string $name @param array $parameters @return bool
[ "校验规则" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Validation/Validators/CustomValidator.php#L87-L98
movoin/one-swoole
src/Protocol/Message/UploadedFile.php
UploadedFile.moveTo
public function moveTo($targetPath) { if ($this->moved) { throw new RuntimeException('Uploaded file already moved'); } if (! is_writable(dirname($targetPath))) { throw new InvalidArgumentException('Upload target path is not writable'); } if (! @rename($this->file, $targetPath)) { throw new RuntimeException( sprintf('Error moving uploaded file %1s to %2s', $this->name, $targetPath) ); } $this->moved = true; }
php
public function moveTo($targetPath) { if ($this->moved) { throw new RuntimeException('Uploaded file already moved'); } if (! is_writable(dirname($targetPath))) { throw new InvalidArgumentException('Upload target path is not writable'); } if (! @rename($this->file, $targetPath)) { throw new RuntimeException( sprintf('Error moving uploaded file %1s to %2s', $this->name, $targetPath) ); } $this->moved = true; }
[ "public", "function", "moveTo", "(", "$", "targetPath", ")", "{", "if", "(", "$", "this", "->", "moved", ")", "{", "throw", "new", "RuntimeException", "(", "'Uploaded file already moved'", ")", ";", "}", "if", "(", "!", "is_writable", "(", "dirname", "(", "$", "targetPath", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Upload target path is not writable'", ")", ";", "}", "if", "(", "!", "@", "rename", "(", "$", "this", "->", "file", ",", "$", "targetPath", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Error moving uploaded file %1s to %2s'", ",", "$", "this", "->", "name", ",", "$", "targetPath", ")", ")", ";", "}", "$", "this", "->", "moved", "=", "true", ";", "}" ]
移动上传文件至目标路径 @param string $targetPath @throws \RuntimeException @throws \InvalidArgumentException
[ "移动上传文件至目标路径" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Protocol/Message/UploadedFile.php#L115-L132
huasituo/hstcms
src/Http/Controllers/Manage/BasicController.php
BasicController.loadTemplate
public function loadTemplate($tpl, $data = array(), $viewData = true) { $viewData && $data = $data + $this->viewData; if(substr_count($tpl,'::') ) { return view($tpl, $data); } return view('hstcms::manage.'.$tpl, $data); }
php
public function loadTemplate($tpl, $data = array(), $viewData = true) { $viewData && $data = $data + $this->viewData; if(substr_count($tpl,'::') ) { return view($tpl, $data); } return view('hstcms::manage.'.$tpl, $data); }
[ "public", "function", "loadTemplate", "(", "$", "tpl", ",", "$", "data", "=", "array", "(", ")", ",", "$", "viewData", "=", "true", ")", "{", "$", "viewData", "&&", "$", "data", "=", "$", "data", "+", "$", "this", "->", "viewData", ";", "if", "(", "substr_count", "(", "$", "tpl", ",", "'::'", ")", ")", "{", "return", "view", "(", "$", "tpl", ",", "$", "data", ")", ";", "}", "return", "view", "(", "'hstcms::manage.'", ".", "$", "tpl", ",", "$", "data", ")", ";", "}" ]
加载模版 @param string $tpl @param array $data @return template
[ "加载模版" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Http/Controllers/Manage/BasicController.php#L50-L57
heyday/heystack
src/Loader/DBClosureLoader.php
DBClosureLoader.load
public function load($resource, $type = null) { $handler = $this->handler; if (is_array($resource)) { $rows = \DB::query(sprintf( "SELECT %s FROM `%s` %s", $resource[0], $resource[1], isset($resource[2]) ? "WHERE {$resource[2]}" : '' )); foreach ($rows as $index => $record) { if (empty($record['ClassName'])) { throw new \RuntimeException("No classname in db record"); } $handler(new $record['ClassName']($record), $index); } } else { throw new \InvalidArgumentException('Resource provided to DBClosureLoader is not an array'); } }
php
public function load($resource, $type = null) { $handler = $this->handler; if (is_array($resource)) { $rows = \DB::query(sprintf( "SELECT %s FROM `%s` %s", $resource[0], $resource[1], isset($resource[2]) ? "WHERE {$resource[2]}" : '' )); foreach ($rows as $index => $record) { if (empty($record['ClassName'])) { throw new \RuntimeException("No classname in db record"); } $handler(new $record['ClassName']($record), $index); } } else { throw new \InvalidArgumentException('Resource provided to DBClosureLoader is not an array'); } }
[ "public", "function", "load", "(", "$", "resource", ",", "$", "type", "=", "null", ")", "{", "$", "handler", "=", "$", "this", "->", "handler", ";", "if", "(", "is_array", "(", "$", "resource", ")", ")", "{", "$", "rows", "=", "\\", "DB", "::", "query", "(", "sprintf", "(", "\"SELECT %s FROM `%s` %s\"", ",", "$", "resource", "[", "0", "]", ",", "$", "resource", "[", "1", "]", ",", "isset", "(", "$", "resource", "[", "2", "]", ")", "?", "\"WHERE {$resource[2]}\"", ":", "''", ")", ")", ";", "foreach", "(", "$", "rows", "as", "$", "index", "=>", "$", "record", ")", "{", "if", "(", "empty", "(", "$", "record", "[", "'ClassName'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"No classname in db record\"", ")", ";", "}", "$", "handler", "(", "new", "$", "record", "[", "'ClassName'", "]", "(", "$", "record", ")", ",", "$", "index", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Resource provided to DBClosureLoader is not an array'", ")", ";", "}", "}" ]
Loads a resource. @param mixed $resource The resource @param string $type The resource type @throws \InvalidArgumentException @throws \RuntimeException @return void
[ "Loads", "a", "resource", "." ]
train
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/Loader/DBClosureLoader.php#L37-L56
jan-dolata/crude-crud
src/Engine/Helpers/CrudeSpecialFiles.php
CrudeSpecialFiles.getList
public function getList() { $result = []; foreach (config('crude_special_files.files') as $key) $result[$key] = [ 'key' => $key, 'label' => $this->getLabel($key), 'data' => $this->getFileData($key) ]; return $result; }
php
public function getList() { $result = []; foreach (config('crude_special_files.files') as $key) $result[$key] = [ 'key' => $key, 'label' => $this->getLabel($key), 'data' => $this->getFileData($key) ]; return $result; }
[ "public", "function", "getList", "(", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "config", "(", "'crude_special_files.files'", ")", "as", "$", "key", ")", "$", "result", "[", "$", "key", "]", "=", "[", "'key'", "=>", "$", "key", ",", "'label'", "=>", "$", "this", "->", "getLabel", "(", "$", "key", ")", ",", "'data'", "=>", "$", "this", "->", "getFileData", "(", "$", "key", ")", "]", ";", "return", "$", "result", ";", "}" ]
Get information about all files (key, label, data) @return array
[ "Get", "information", "about", "all", "files", "(", "key", "label", "data", ")" ]
train
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Helpers/CrudeSpecialFiles.php#L15-L26
jan-dolata/crude-crud
src/Engine/Helpers/CrudeSpecialFiles.php
CrudeSpecialFiles.downloadData
public function downloadData($key) { $fileData = $this->getFileData($key); if (! $fileData) return false; return [ 'path' => $fileData['path'], 'name' => $this->getLabel($key) . '.' . $fileData['extension'] ]; }
php
public function downloadData($key) { $fileData = $this->getFileData($key); if (! $fileData) return false; return [ 'path' => $fileData['path'], 'name' => $this->getLabel($key) . '.' . $fileData['extension'] ]; }
[ "public", "function", "downloadData", "(", "$", "key", ")", "{", "$", "fileData", "=", "$", "this", "->", "getFileData", "(", "$", "key", ")", ";", "if", "(", "!", "$", "fileData", ")", "return", "false", ";", "return", "[", "'path'", "=>", "$", "fileData", "[", "'path'", "]", ",", "'name'", "=>", "$", "this", "->", "getLabel", "(", "$", "key", ")", ".", "'.'", ".", "$", "fileData", "[", "'extension'", "]", "]", ";", "}" ]
Get download params: path and name @param string $key @return array
[ "Get", "download", "params", ":", "path", "and", "name" ]
train
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Helpers/CrudeSpecialFiles.php#L34-L45
jan-dolata/crude-crud
src/Engine/Helpers/CrudeSpecialFiles.php
CrudeSpecialFiles.upload
public function upload($file, $key) { if (! $file || ! $this->isValidKey($key)) return; $fileName = $file->getClientOriginalName(); $pathinfo = pathinfo($fileName); $this->deleteStored($key); Storage::putFileAs($this->getStoragePath(), $file, $key . '.' . $pathinfo['extension']); }
php
public function upload($file, $key) { if (! $file || ! $this->isValidKey($key)) return; $fileName = $file->getClientOriginalName(); $pathinfo = pathinfo($fileName); $this->deleteStored($key); Storage::putFileAs($this->getStoragePath(), $file, $key . '.' . $pathinfo['extension']); }
[ "public", "function", "upload", "(", "$", "file", ",", "$", "key", ")", "{", "if", "(", "!", "$", "file", "||", "!", "$", "this", "->", "isValidKey", "(", "$", "key", ")", ")", "return", ";", "$", "fileName", "=", "$", "file", "->", "getClientOriginalName", "(", ")", ";", "$", "pathinfo", "=", "pathinfo", "(", "$", "fileName", ")", ";", "$", "this", "->", "deleteStored", "(", "$", "key", ")", ";", "Storage", "::", "putFileAs", "(", "$", "this", "->", "getStoragePath", "(", ")", ",", "$", "file", ",", "$", "key", ".", "'.'", ".", "$", "pathinfo", "[", "'extension'", "]", ")", ";", "}" ]
Upload file if exist and key is correct @param File $file @param string $key
[ "Upload", "file", "if", "exist", "and", "key", "is", "correct" ]
train
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Helpers/CrudeSpecialFiles.php#L53-L64
jan-dolata/crude-crud
src/Engine/Helpers/CrudeSpecialFiles.php
CrudeSpecialFiles.getFileData
private function getFileData($key) { foreach ($this->getStoredList() as $filePath) { $pathinfo = pathinfo($filePath); if ($key == $pathinfo['filename']) return [ 'storedPath' => $filePath, 'path' => storage_path('app/' . $filePath), 'extension' => $pathinfo['extension'], 'size' => Storage::size($filePath), 'lastModified' => Storage::lastModified($filePath) ]; } return false; }
php
private function getFileData($key) { foreach ($this->getStoredList() as $filePath) { $pathinfo = pathinfo($filePath); if ($key == $pathinfo['filename']) return [ 'storedPath' => $filePath, 'path' => storage_path('app/' . $filePath), 'extension' => $pathinfo['extension'], 'size' => Storage::size($filePath), 'lastModified' => Storage::lastModified($filePath) ]; } return false; }
[ "private", "function", "getFileData", "(", "$", "key", ")", "{", "foreach", "(", "$", "this", "->", "getStoredList", "(", ")", "as", "$", "filePath", ")", "{", "$", "pathinfo", "=", "pathinfo", "(", "$", "filePath", ")", ";", "if", "(", "$", "key", "==", "$", "pathinfo", "[", "'filename'", "]", ")", "return", "[", "'storedPath'", "=>", "$", "filePath", ",", "'path'", "=>", "storage_path", "(", "'app/'", ".", "$", "filePath", ")", ",", "'extension'", "=>", "$", "pathinfo", "[", "'extension'", "]", ",", "'size'", "=>", "Storage", "::", "size", "(", "$", "filePath", ")", ",", "'lastModified'", "=>", "Storage", "::", "lastModified", "(", "$", "filePath", ")", "]", ";", "}", "return", "false", ";", "}" ]
Get file path and extension or null if file is not stored @param string $key @return array|false
[ "Get", "file", "path", "and", "extension", "or", "null", "if", "file", "is", "not", "stored" ]
train
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Helpers/CrudeSpecialFiles.php#L76-L93
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.setCreator
public function setCreator(?string $creator = null) { $this->builder->getProperties()->setCreator($creator); return $this; }
php
public function setCreator(?string $creator = null) { $this->builder->getProperties()->setCreator($creator); return $this; }
[ "public", "function", "setCreator", "(", "?", "string", "$", "creator", "=", "null", ")", "{", "$", "this", "->", "builder", "->", "getProperties", "(", ")", "->", "setCreator", "(", "$", "creator", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L45-L50
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.setLastModifiedBy
public function setLastModifiedBy(?string $lastModifiedBy = null) { $this->builder->getProperties()->setLastModifiedBy($lastModifiedBy); return $this; }
php
public function setLastModifiedBy(?string $lastModifiedBy = null) { $this->builder->getProperties()->setLastModifiedBy($lastModifiedBy); return $this; }
[ "public", "function", "setLastModifiedBy", "(", "?", "string", "$", "lastModifiedBy", "=", "null", ")", "{", "$", "this", "->", "builder", "->", "getProperties", "(", ")", "->", "setLastModifiedBy", "(", "$", "lastModifiedBy", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L55-L60
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.setTitle
public function setTitle(?string $title = null) { $this->builder->getProperties()->setTitle($title); return $this; }
php
public function setTitle(?string $title = null) { $this->builder->getProperties()->setTitle($title); return $this; }
[ "public", "function", "setTitle", "(", "?", "string", "$", "title", "=", "null", ")", "{", "$", "this", "->", "builder", "->", "getProperties", "(", ")", "->", "setTitle", "(", "$", "title", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L65-L70
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.setSubject
public function setSubject(?string $subject = null) { $this->builder->getProperties()->setSubject($subject); return $this; }
php
public function setSubject(?string $subject = null) { $this->builder->getProperties()->setSubject($subject); return $this; }
[ "public", "function", "setSubject", "(", "?", "string", "$", "subject", "=", "null", ")", "{", "$", "this", "->", "builder", "->", "getProperties", "(", ")", "->", "setSubject", "(", "$", "subject", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L75-L80
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.setDescription
public function setDescription(?string $description = null) { $this->builder->getProperties()->setDescription($description); return $this; }
php
public function setDescription(?string $description = null) { $this->builder->getProperties()->setDescription($description); return $this; }
[ "public", "function", "setDescription", "(", "?", "string", "$", "description", "=", "null", ")", "{", "$", "this", "->", "builder", "->", "getProperties", "(", ")", "->", "setDescription", "(", "$", "description", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L85-L90
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.createNewSheet
public function createNewSheet(): void { $newSheet = $this->builder->createSheet(); $newSheetIndex = $this->builder->getIndex($newSheet); $this->setActiveSheetIndex($newSheetIndex); }
php
public function createNewSheet(): void { $newSheet = $this->builder->createSheet(); $newSheetIndex = $this->builder->getIndex($newSheet); $this->setActiveSheetIndex($newSheetIndex); }
[ "public", "function", "createNewSheet", "(", ")", ":", "void", "{", "$", "newSheet", "=", "$", "this", "->", "builder", "->", "createSheet", "(", ")", ";", "$", "newSheetIndex", "=", "$", "this", "->", "builder", "->", "getIndex", "(", "$", "newSheet", ")", ";", "$", "this", "->", "setActiveSheetIndex", "(", "$", "newSheetIndex", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L115-L122
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.buildRowStyle
public function buildRowStyle(array $style) { $finalStyleArray = []; $defaultStyleArray = [ 'alignment' => [ 'horizontal' => Alignment::HORIZONTAL_LEFT, ], 'font' => [ 'color' => [ 'rgb' => BuilderInterface::COLOUR_BLACK_RGB, ], 'bold' => true, ], 'fill' => [ 'type' => Fill::FILL_SOLID, 'color' => [ 'rgb' => '000000', ], ], ]; if (!array_key_exists('alignment', $style)) { $finalStyleArray['alignment']['horizontal'] = $defaultStyleArray['alignment']['horizontal']; } else { switch ($style['alignment']) { case 'right': $finalStyleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_RIGHT; break; case 'centre': case 'center': $finalStyleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER; break; case 'left': default: $finalStyleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_LEFT; break; } } if (!array_key_exists('font', $style)) { $finalStyleArray['font'] = $defaultStyleArray['font']; } else { $finalStyleArray['font'] = $style['font']; } return $finalStyleArray; }
php
public function buildRowStyle(array $style) { $finalStyleArray = []; $defaultStyleArray = [ 'alignment' => [ 'horizontal' => Alignment::HORIZONTAL_LEFT, ], 'font' => [ 'color' => [ 'rgb' => BuilderInterface::COLOUR_BLACK_RGB, ], 'bold' => true, ], 'fill' => [ 'type' => Fill::FILL_SOLID, 'color' => [ 'rgb' => '000000', ], ], ]; if (!array_key_exists('alignment', $style)) { $finalStyleArray['alignment']['horizontal'] = $defaultStyleArray['alignment']['horizontal']; } else { switch ($style['alignment']) { case 'right': $finalStyleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_RIGHT; break; case 'centre': case 'center': $finalStyleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER; break; case 'left': default: $finalStyleArray['alignment']['horizontal'] = Alignment::HORIZONTAL_LEFT; break; } } if (!array_key_exists('font', $style)) { $finalStyleArray['font'] = $defaultStyleArray['font']; } else { $finalStyleArray['font'] = $style['font']; } return $finalStyleArray; }
[ "public", "function", "buildRowStyle", "(", "array", "$", "style", ")", "{", "$", "finalStyleArray", "=", "[", "]", ";", "$", "defaultStyleArray", "=", "[", "'alignment'", "=>", "[", "'horizontal'", "=>", "Alignment", "::", "HORIZONTAL_LEFT", ",", "]", ",", "'font'", "=>", "[", "'color'", "=>", "[", "'rgb'", "=>", "BuilderInterface", "::", "COLOUR_BLACK_RGB", ",", "]", ",", "'bold'", "=>", "true", ",", "]", ",", "'fill'", "=>", "[", "'type'", "=>", "Fill", "::", "FILL_SOLID", ",", "'color'", "=>", "[", "'rgb'", "=>", "'000000'", ",", "]", ",", "]", ",", "]", ";", "if", "(", "!", "array_key_exists", "(", "'alignment'", ",", "$", "style", ")", ")", "{", "$", "finalStyleArray", "[", "'alignment'", "]", "[", "'horizontal'", "]", "=", "$", "defaultStyleArray", "[", "'alignment'", "]", "[", "'horizontal'", "]", ";", "}", "else", "{", "switch", "(", "$", "style", "[", "'alignment'", "]", ")", "{", "case", "'right'", ":", "$", "finalStyleArray", "[", "'alignment'", "]", "[", "'horizontal'", "]", "=", "Alignment", "::", "HORIZONTAL_RIGHT", ";", "break", ";", "case", "'centre'", ":", "case", "'center'", ":", "$", "finalStyleArray", "[", "'alignment'", "]", "[", "'horizontal'", "]", "=", "Alignment", "::", "HORIZONTAL_CENTER", ";", "break", ";", "case", "'left'", ":", "default", ":", "$", "finalStyleArray", "[", "'alignment'", "]", "[", "'horizontal'", "]", "=", "Alignment", "::", "HORIZONTAL_LEFT", ";", "break", ";", "}", "}", "if", "(", "!", "array_key_exists", "(", "'font'", ",", "$", "style", ")", ")", "{", "$", "finalStyleArray", "[", "'font'", "]", "=", "$", "defaultStyleArray", "[", "'font'", "]", ";", "}", "else", "{", "$", "finalStyleArray", "[", "'font'", "]", "=", "$", "style", "[", "'font'", "]", ";", "}", "return", "$", "finalStyleArray", ";", "}" ]
http://stackoverflow.com/questions/12918586/phpexcel-specific-cell-formatting-from-style-object @param array $style @return array
[ "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "12918586", "/", "phpexcel", "-", "specific", "-", "cell", "-", "formatting", "-", "from", "-", "style", "-", "object" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L131-L182
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.buildHeaderRow
public function buildHeaderRow( array $columns, $style = null ): void { // The row needs to start at 1 at the beginning of execution. // The top left corner of the sheet is actually position (col = 0, row = 1). $row = 1; $column = 1; foreach ($columns as $columnName) { $this->builder->getActiveSheet()->setCellValueByColumnAndRow($column, $row, $columnName); if (is_array($style)) { $this->builder ->getActiveSheet() ->getStyleByColumnAndRow($column, $row) ->applyFromArray($style); } $column++; } return; }
php
public function buildHeaderRow( array $columns, $style = null ): void { // The row needs to start at 1 at the beginning of execution. // The top left corner of the sheet is actually position (col = 0, row = 1). $row = 1; $column = 1; foreach ($columns as $columnName) { $this->builder->getActiveSheet()->setCellValueByColumnAndRow($column, $row, $columnName); if (is_array($style)) { $this->builder ->getActiveSheet() ->getStyleByColumnAndRow($column, $row) ->applyFromArray($style); } $column++; } return; }
[ "public", "function", "buildHeaderRow", "(", "array", "$", "columns", ",", "$", "style", "=", "null", ")", ":", "void", "{", "// The row needs to start at 1 at the beginning of execution.", "// The top left corner of the sheet is actually position (col = 0, row = 1).", "$", "row", "=", "1", ";", "$", "column", "=", "1", ";", "foreach", "(", "$", "columns", "as", "$", "columnName", ")", "{", "$", "this", "->", "builder", "->", "getActiveSheet", "(", ")", "->", "setCellValueByColumnAndRow", "(", "$", "column", ",", "$", "row", ",", "$", "columnName", ")", ";", "if", "(", "is_array", "(", "$", "style", ")", ")", "{", "$", "this", "->", "builder", "->", "getActiveSheet", "(", ")", "->", "getStyleByColumnAndRow", "(", "$", "column", ",", "$", "row", ")", "->", "applyFromArray", "(", "$", "style", ")", ";", "}", "$", "column", "++", ";", "}", "return", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L187-L210
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.buildRow
public function buildRow( array $row, $style = null, $rowIndex = 1 ): void { $columnIndex = 1; foreach ($row as $column) { $this->builder->getActiveSheet()->setCellValueByColumnAndRow($columnIndex, $rowIndex, $column); $columnIndex++; } return; }
php
public function buildRow( array $row, $style = null, $rowIndex = 1 ): void { $columnIndex = 1; foreach ($row as $column) { $this->builder->getActiveSheet()->setCellValueByColumnAndRow($columnIndex, $rowIndex, $column); $columnIndex++; } return; }
[ "public", "function", "buildRow", "(", "array", "$", "row", ",", "$", "style", "=", "null", ",", "$", "rowIndex", "=", "1", ")", ":", "void", "{", "$", "columnIndex", "=", "1", ";", "foreach", "(", "$", "row", "as", "$", "column", ")", "{", "$", "this", "->", "builder", "->", "getActiveSheet", "(", ")", "->", "setCellValueByColumnAndRow", "(", "$", "columnIndex", ",", "$", "rowIndex", ",", "$", "column", ")", ";", "$", "columnIndex", "++", ";", "}", "return", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L215-L229
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.buildRows
public function buildRows( array $rows, $style = null ): void { // The row needs to start at 1 at the beginning of execution. // The top left corner of the sheet is actually position (col = 1, row = 1). $rowIndex = 1; // If we have a header row then we need to bump the row index down one, // otherwise we'll overwrite the header (not ideal). if ($this->builder->getActiveSheet()->cellExistsByColumnAndRow(1, $rowIndex)) { $rowIndex = 2; } foreach ($rows as $row) { $this->buildRow($row, $style, $rowIndex); $rowIndex++; } return; }
php
public function buildRows( array $rows, $style = null ): void { // The row needs to start at 1 at the beginning of execution. // The top left corner of the sheet is actually position (col = 1, row = 1). $rowIndex = 1; // If we have a header row then we need to bump the row index down one, // otherwise we'll overwrite the header (not ideal). if ($this->builder->getActiveSheet()->cellExistsByColumnAndRow(1, $rowIndex)) { $rowIndex = 2; } foreach ($rows as $row) { $this->buildRow($row, $style, $rowIndex); $rowIndex++; } return; }
[ "public", "function", "buildRows", "(", "array", "$", "rows", ",", "$", "style", "=", "null", ")", ":", "void", "{", "// The row needs to start at 1 at the beginning of execution.", "// The top left corner of the sheet is actually position (col = 1, row = 1).", "$", "rowIndex", "=", "1", ";", "// If we have a header row then we need to bump the row index down one,", "// otherwise we'll overwrite the header (not ideal).", "if", "(", "$", "this", "->", "builder", "->", "getActiveSheet", "(", ")", "->", "cellExistsByColumnAndRow", "(", "1", ",", "$", "rowIndex", ")", ")", "{", "$", "rowIndex", "=", "2", ";", "}", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "this", "->", "buildRow", "(", "$", "row", ",", "$", "style", ",", "$", "rowIndex", ")", ";", "$", "rowIndex", "++", ";", "}", "return", ";", "}" ]
http://stackoverflow.com/questions/2584954/phpexcel-how-to-set-cell-value-dynamically {@inheritdoc}
[ "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "2584954", "/", "phpexcel", "-", "how", "-", "to", "-", "set", "-", "cell", "-", "value", "-", "dynamically" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L236-L257
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.applyColumnWidths
public function applyColumnWidths( array $columns, array $widths, $sheet = null ): void { if ($sheet !== null) { $this->builder->setActiveSheetIndex($sheet); } // Loop through all of our column values - we only set values for columns that we actually have. foreach ($widths as $columnKey => $columnWidth) { $this->builder->getActiveSheet()->getColumnDimension($columns[$columnKey])->setWidth($columnWidth); } return; }
php
public function applyColumnWidths( array $columns, array $widths, $sheet = null ): void { if ($sheet !== null) { $this->builder->setActiveSheetIndex($sheet); } // Loop through all of our column values - we only set values for columns that we actually have. foreach ($widths as $columnKey => $columnWidth) { $this->builder->getActiveSheet()->getColumnDimension($columns[$columnKey])->setWidth($columnWidth); } return; }
[ "public", "function", "applyColumnWidths", "(", "array", "$", "columns", ",", "array", "$", "widths", ",", "$", "sheet", "=", "null", ")", ":", "void", "{", "if", "(", "$", "sheet", "!==", "null", ")", "{", "$", "this", "->", "builder", "->", "setActiveSheetIndex", "(", "$", "sheet", ")", ";", "}", "// Loop through all of our column values - we only set values for columns that we actually have.", "foreach", "(", "$", "widths", "as", "$", "columnKey", "=>", "$", "columnWidth", ")", "{", "$", "this", "->", "builder", "->", "getActiveSheet", "(", ")", "->", "getColumnDimension", "(", "$", "columns", "[", "$", "columnKey", "]", ")", "->", "setWidth", "(", "$", "columnWidth", ")", ";", "}", "return", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L262-L277
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.autoSizeColumns
public function autoSizeColumns( array $columns, $sheet = null ): void { if ($sheet !== null) { $this->builder->setActiveSheetIndex($sheet); } $columnCount = count($columns); for ($columnIndex = 1; $columnIndex <= $columnCount; $columnIndex++) { $this->builder->getActiveSheet()->getColumnDimensionByColumn($columnIndex)->setAutoSize(true); } return; }
php
public function autoSizeColumns( array $columns, $sheet = null ): void { if ($sheet !== null) { $this->builder->setActiveSheetIndex($sheet); } $columnCount = count($columns); for ($columnIndex = 1; $columnIndex <= $columnCount; $columnIndex++) { $this->builder->getActiveSheet()->getColumnDimensionByColumn($columnIndex)->setAutoSize(true); } return; }
[ "public", "function", "autoSizeColumns", "(", "array", "$", "columns", ",", "$", "sheet", "=", "null", ")", ":", "void", "{", "if", "(", "$", "sheet", "!==", "null", ")", "{", "$", "this", "->", "builder", "->", "setActiveSheetIndex", "(", "$", "sheet", ")", ";", "}", "$", "columnCount", "=", "count", "(", "$", "columns", ")", ";", "for", "(", "$", "columnIndex", "=", "1", ";", "$", "columnIndex", "<=", "$", "columnCount", ";", "$", "columnIndex", "++", ")", "{", "$", "this", "->", "builder", "->", "getActiveSheet", "(", ")", "->", "getColumnDimensionByColumn", "(", "$", "columnIndex", ")", "->", "setAutoSize", "(", "true", ")", ";", "}", "return", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L282-L297
iter8-au/builder
src/Builder/Builders/PhpSpreadsheet.php
PhpSpreadsheet.closeAndWrite
public function closeAndWrite(string $type = 'Xlsx'): void { $writer = IOFactory::createWriter($this->builder, $type); $writer->save($this->getTempName()); }
php
public function closeAndWrite(string $type = 'Xlsx'): void { $writer = IOFactory::createWriter($this->builder, $type); $writer->save($this->getTempName()); }
[ "public", "function", "closeAndWrite", "(", "string", "$", "type", "=", "'Xlsx'", ")", ":", "void", "{", "$", "writer", "=", "IOFactory", "::", "createWriter", "(", "$", "this", "->", "builder", ",", "$", "type", ")", ";", "$", "writer", "->", "save", "(", "$", "this", "->", "getTempName", "(", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/iter8-au/builder/blob/95105636c2490c5c7a88da466702c523a9d0901c/src/Builder/Builders/PhpSpreadsheet.php#L302-L307
tonicospinelli/class-generation
src/ClassGeneration/Collection/ArrayCollection.php
ArrayCollection.contains
public function contains($element) { foreach ($this->elements as $collectionElement) { if ($element === $collectionElement) { return true; } } return false; }
php
public function contains($element) { foreach ($this->elements as $collectionElement) { if ($element === $collectionElement) { return true; } } return false; }
[ "public", "function", "contains", "(", "$", "element", ")", "{", "foreach", "(", "$", "this", "->", "elements", "as", "$", "collectionElement", ")", "{", "if", "(", "$", "element", "===", "$", "collectionElement", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/Collection/ArrayCollection.php#L163-L172
tonicospinelli/class-generation
src/ClassGeneration/Collection/ArrayCollection.php
ArrayCollection.exists
public function exists($findKey = null, $findElement = null) { if (!is_null($findKey) && is_null($findElement)) { return $this->containsKey($findKey); } elseif (is_null($findKey) && !is_null($findElement)) { return $this->contains($findElement); } else { return $this->containsKey($findKey) && $this->contains($findElement); } }
php
public function exists($findKey = null, $findElement = null) { if (!is_null($findKey) && is_null($findElement)) { return $this->containsKey($findKey); } elseif (is_null($findKey) && !is_null($findElement)) { return $this->contains($findElement); } else { return $this->containsKey($findKey) && $this->contains($findElement); } }
[ "public", "function", "exists", "(", "$", "findKey", "=", "null", ",", "$", "findElement", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "findKey", ")", "&&", "is_null", "(", "$", "findElement", ")", ")", "{", "return", "$", "this", "->", "containsKey", "(", "$", "findKey", ")", ";", "}", "elseif", "(", "is_null", "(", "$", "findKey", ")", "&&", "!", "is_null", "(", "$", "findElement", ")", ")", "{", "return", "$", "this", "->", "contains", "(", "$", "findElement", ")", ";", "}", "else", "{", "return", "$", "this", "->", "containsKey", "(", "$", "findKey", ")", "&&", "$", "this", "->", "contains", "(", "$", "findElement", ")", ";", "}", "}" ]
{@inheritdoc} @param string $findElement
[ "{" ]
train
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/Collection/ArrayCollection.php#L178-L187
movoin/one-swoole
src/Protocol/Exceptions/ProtocolException.php
ProtocolException.badRequest
public static function badRequest(string $message, string $protocol = Protocol::HTTP): self { return new static(sprintf('Bad Request: `%s`', $message), $protocol, 400); }
php
public static function badRequest(string $message, string $protocol = Protocol::HTTP): self { return new static(sprintf('Bad Request: `%s`', $message), $protocol, 400); }
[ "public", "static", "function", "badRequest", "(", "string", "$", "message", ",", "string", "$", "protocol", "=", "Protocol", "::", "HTTP", ")", ":", "self", "{", "return", "new", "static", "(", "sprintf", "(", "'Bad Request: `%s`'", ",", "$", "message", ")", ",", "$", "protocol", ",", "400", ")", ";", "}" ]
非法请求 @param string $message @param string $protocol @return self 400
[ "非法请求" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Protocol/Exceptions/ProtocolException.php#L50-L53
movoin/one-swoole
src/Protocol/Exceptions/ProtocolException.php
ProtocolException.unauthorized
public static function unauthorized(string $uri, string $protocol = Protocol::HTTP): self { return new static(sprintf('Unauthorized: `%s`', $uri), $protocol, 401); }
php
public static function unauthorized(string $uri, string $protocol = Protocol::HTTP): self { return new static(sprintf('Unauthorized: `%s`', $uri), $protocol, 401); }
[ "public", "static", "function", "unauthorized", "(", "string", "$", "uri", ",", "string", "$", "protocol", "=", "Protocol", "::", "HTTP", ")", ":", "self", "{", "return", "new", "static", "(", "sprintf", "(", "'Unauthorized: `%s`'", ",", "$", "uri", ")", ",", "$", "protocol", ",", "401", ")", ";", "}" ]
未授权请求 @param string $uri @param string $protocol @return self 401
[ "未授权请求" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Protocol/Exceptions/ProtocolException.php#L63-L66
movoin/one-swoole
src/Protocol/Exceptions/ProtocolException.php
ProtocolException.notFound
public static function notFound(string $uri, string $protocol = Protocol::HTTP): self { return new static(sprintf('Not Found: %s', $uri), $protocol, 404); }
php
public static function notFound(string $uri, string $protocol = Protocol::HTTP): self { return new static(sprintf('Not Found: %s', $uri), $protocol, 404); }
[ "public", "static", "function", "notFound", "(", "string", "$", "uri", ",", "string", "$", "protocol", "=", "Protocol", "::", "HTTP", ")", ":", "self", "{", "return", "new", "static", "(", "sprintf", "(", "'Not Found: %s'", ",", "$", "uri", ")", ",", "$", "protocol", ",", "404", ")", ";", "}" ]
URI 未找到 @param string $uri @param string $protocol @return self 404
[ "URI", "未找到" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Protocol/Exceptions/ProtocolException.php#L88-L91
movoin/one-swoole
src/Protocol/Exceptions/ProtocolException.php
ProtocolException.methodNotAllowed
public static function methodNotAllowed(string $method, string $uri, string $protocol = Protocol::HTTP): self { return new static(sprintf('`%s` not allowed `%s` method', $uri, $method), $protocol, 405); }
php
public static function methodNotAllowed(string $method, string $uri, string $protocol = Protocol::HTTP): self { return new static(sprintf('`%s` not allowed `%s` method', $uri, $method), $protocol, 405); }
[ "public", "static", "function", "methodNotAllowed", "(", "string", "$", "method", ",", "string", "$", "uri", ",", "string", "$", "protocol", "=", "Protocol", "::", "HTTP", ")", ":", "self", "{", "return", "new", "static", "(", "sprintf", "(", "'`%s` not allowed `%s` method'", ",", "$", "uri", ",", "$", "method", ")", ",", "$", "protocol", ",", "405", ")", ";", "}" ]
请求方式不允许 @param string $method @param string $uri @param string $protocol @return self 405
[ "请求方式不允许" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Protocol/Exceptions/ProtocolException.php#L102-L105
movoin/one-swoole
src/Protocol/Exceptions/ProtocolException.php
ProtocolException.notAcceptable
public static function notAcceptable(string $contentType, string $protocol = Protocol::HTTP): self { return new static(sprintf('Content type `%s` not acceptable', $contentType), $protocol, 406); }
php
public static function notAcceptable(string $contentType, string $protocol = Protocol::HTTP): self { return new static(sprintf('Content type `%s` not acceptable', $contentType), $protocol, 406); }
[ "public", "static", "function", "notAcceptable", "(", "string", "$", "contentType", ",", "string", "$", "protocol", "=", "Protocol", "::", "HTTP", ")", ":", "self", "{", "return", "new", "static", "(", "sprintf", "(", "'Content type `%s` not acceptable'", ",", "$", "contentType", ")", ",", "$", "protocol", ",", "406", ")", ";", "}" ]
请求内容类型不支持 @param string $contentType @param string $protocol @return self 406
[ "请求内容类型不支持" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Protocol/Exceptions/ProtocolException.php#L115-L118
movoin/one-swoole
src/Protocol/Exceptions/ProtocolException.php
ProtocolException.makeResponse
public function makeResponse(Request $request, Response $response, Responder $responder): Response { return $responder( $request, $response, new Payload( $this->getCode(), '', $this->getMessage() ) ); }
php
public function makeResponse(Request $request, Response $response, Responder $responder): Response { return $responder( $request, $response, new Payload( $this->getCode(), '', $this->getMessage() ) ); }
[ "public", "function", "makeResponse", "(", "Request", "$", "request", ",", "Response", "$", "response", ",", "Responder", "$", "responder", ")", ":", "Response", "{", "return", "$", "responder", "(", "$", "request", ",", "$", "response", ",", "new", "Payload", "(", "$", "this", "->", "getCode", "(", ")", ",", "''", ",", "$", "this", "->", "getMessage", "(", ")", ")", ")", ";", "}" ]
获得异常响应对象 @param \One\Protocol\Contracts\Request $request @param \One\Protocol\Contracts\Response $response @param \One\Protocol\Contracts\Responder $responder @return \One\Protocol\Contracts\Response
[ "获得异常响应对象" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Protocol/Exceptions/ProtocolException.php#L175-L186
Srokap/code_review
classes/CodeReview/Autoloader.php
Autoloader.registerDirectory
private function registerDirectory($basePath, $prefix = '') { $basePath = str_replace('\\', '/', $basePath); $basePath = rtrim($basePath, '/') . '/'; $prefix = ($prefix ? $prefix . '_' : '' ); $files = scandir($basePath); foreach ($files as $file) { if ($file[0] == '.') { continue; } $path = $basePath . $file; if (is_dir($path)) { $this->registerDirectory($path, $prefix . pathinfo($path, PATHINFO_FILENAME)); } elseif (strtolower(pathinfo($path, PATHINFO_EXTENSION)) == 'php') { $name = $prefix . pathinfo($path, PATHINFO_FILENAME); $this->classMap[$name] = $path; $name = str_replace('_', '\\', $name); // register again in case it was namespaced $this->classMap[$name] = $path; } } }
php
private function registerDirectory($basePath, $prefix = '') { $basePath = str_replace('\\', '/', $basePath); $basePath = rtrim($basePath, '/') . '/'; $prefix = ($prefix ? $prefix . '_' : '' ); $files = scandir($basePath); foreach ($files as $file) { if ($file[0] == '.') { continue; } $path = $basePath . $file; if (is_dir($path)) { $this->registerDirectory($path, $prefix . pathinfo($path, PATHINFO_FILENAME)); } elseif (strtolower(pathinfo($path, PATHINFO_EXTENSION)) == 'php') { $name = $prefix . pathinfo($path, PATHINFO_FILENAME); $this->classMap[$name] = $path; $name = str_replace('_', '\\', $name); // register again in case it was namespaced $this->classMap[$name] = $path; } } }
[ "private", "function", "registerDirectory", "(", "$", "basePath", ",", "$", "prefix", "=", "''", ")", "{", "$", "basePath", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "basePath", ")", ";", "$", "basePath", "=", "rtrim", "(", "$", "basePath", ",", "'/'", ")", ".", "'/'", ";", "$", "prefix", "=", "(", "$", "prefix", "?", "$", "prefix", ".", "'_'", ":", "''", ")", ";", "$", "files", "=", "scandir", "(", "$", "basePath", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "$", "file", "[", "0", "]", "==", "'.'", ")", "{", "continue", ";", "}", "$", "path", "=", "$", "basePath", ".", "$", "file", ";", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "$", "this", "->", "registerDirectory", "(", "$", "path", ",", "$", "prefix", ".", "pathinfo", "(", "$", "path", ",", "PATHINFO_FILENAME", ")", ")", ";", "}", "elseif", "(", "strtolower", "(", "pathinfo", "(", "$", "path", ",", "PATHINFO_EXTENSION", ")", ")", "==", "'php'", ")", "{", "$", "name", "=", "$", "prefix", ".", "pathinfo", "(", "$", "path", ",", "PATHINFO_FILENAME", ")", ";", "$", "this", "->", "classMap", "[", "$", "name", "]", "=", "$", "path", ";", "$", "name", "=", "str_replace", "(", "'_'", ",", "'\\\\'", ",", "$", "name", ")", ";", "// register again in case it was namespaced", "$", "this", "->", "classMap", "[", "$", "name", "]", "=", "$", "path", ";", "}", "}", "}" ]
Not fully PSR-0 compatible, but good enough for this particular plugin @param string $basePath @param string $prefix
[ "Not", "fully", "PSR", "-", "0", "compatible", "but", "good", "enough", "for", "this", "particular", "plugin" ]
train
https://github.com/Srokap/code_review/blob/c79c619f99279cf15713b118ae19b0ef017db362/classes/CodeReview/Autoloader.php#L24-L43
fuelphp/display
src/View.php
View.render
public function render(array $data = []) { if ( ! empty($data)) { $this->set($data); } return $this->parser->parse($this->file, $this->getData()); }
php
public function render(array $data = []) { if ( ! empty($data)) { $this->set($data); } return $this->parser->parse($this->file, $this->getData()); }
[ "public", "function", "render", "(", "array", "$", "data", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "$", "this", "->", "set", "(", "$", "data", ")", ";", "}", "return", "$", "this", "->", "parser", "->", "parse", "(", "$", "this", "->", "file", ",", "$", "this", "->", "getData", "(", ")", ")", ";", "}" ]
Renders the view @param array $data additional view data @return string
[ "Renders", "the", "view" ]
train
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/View.php#L68-L76
hudhaifas/silverstripe-dataobject-manager
src/Extension/DataObject_PrivicyExtension.php
DataObject_PrivicyExtension.canCreate
public function canCreate($member) { if (!$this->owner->isCreatable()) { return false; } if (!$member) { $member = Member::currentUserID(); } if ($member && is_numeric($member)) { $member = DataObject::get_by_id('Member', $member); } $cachedPermission = self::cache_permission_check('create', $member, $this->owner->ID); if (isset($cachedPermission)) { return $cachedPermission; } if ($member && Permission::checkMember($member, "ADMIN")) { return true; } $extended = $this->owner->extendedCan('canCreateLocations', $member); if ($extended !== null) { return $extended; } return false; }
php
public function canCreate($member) { if (!$this->owner->isCreatable()) { return false; } if (!$member) { $member = Member::currentUserID(); } if ($member && is_numeric($member)) { $member = DataObject::get_by_id('Member', $member); } $cachedPermission = self::cache_permission_check('create', $member, $this->owner->ID); if (isset($cachedPermission)) { return $cachedPermission; } if ($member && Permission::checkMember($member, "ADMIN")) { return true; } $extended = $this->owner->extendedCan('canCreateLocations', $member); if ($extended !== null) { return $extended; } return false; }
[ "public", "function", "canCreate", "(", "$", "member", ")", "{", "if", "(", "!", "$", "this", "->", "owner", "->", "isCreatable", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "member", ")", "{", "$", "member", "=", "Member", "::", "currentUserID", "(", ")", ";", "}", "if", "(", "$", "member", "&&", "is_numeric", "(", "$", "member", ")", ")", "{", "$", "member", "=", "DataObject", "::", "get_by_id", "(", "'Member'", ",", "$", "member", ")", ";", "}", "$", "cachedPermission", "=", "self", "::", "cache_permission_check", "(", "'create'", ",", "$", "member", ",", "$", "this", "->", "owner", "->", "ID", ")", ";", "if", "(", "isset", "(", "$", "cachedPermission", ")", ")", "{", "return", "$", "cachedPermission", ";", "}", "if", "(", "$", "member", "&&", "Permission", "::", "checkMember", "(", "$", "member", ",", "\"ADMIN\"", ")", ")", "{", "return", "true", ";", "}", "$", "extended", "=", "$", "this", "->", "owner", "->", "extendedCan", "(", "'canCreateLocations'", ",", "$", "member", ")", ";", "if", "(", "$", "extended", "!==", "null", ")", "{", "return", "$", "extended", ";", "}", "return", "false", ";", "}" ]
/ Permissions ///
[ "/", "Permissions", "///" ]
train
https://github.com/hudhaifas/silverstripe-dataobject-manager/blob/a8ecaeee785da4d3cdb722e44b40b8eff96e1f82/src/Extension/DataObject_PrivicyExtension.php#L116-L144
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php
TemplateController.getSystemUserArray
public function getSystemUserArray() { $repo = $this->get('sulu_security.user_repository'); $users = $repo->getUserInSystem(); $contacts = []; foreach ($users as $user) { $contact = $user->getContact(); $contacts[] = array( 'id' => $contact->getId(), 'fullName' => $contact->getFullName() ); } return $contacts; }
php
public function getSystemUserArray() { $repo = $this->get('sulu_security.user_repository'); $users = $repo->getUserInSystem(); $contacts = []; foreach ($users as $user) { $contact = $user->getContact(); $contacts[] = array( 'id' => $contact->getId(), 'fullName' => $contact->getFullName() ); } return $contacts; }
[ "public", "function", "getSystemUserArray", "(", ")", "{", "$", "repo", "=", "$", "this", "->", "get", "(", "'sulu_security.user_repository'", ")", ";", "$", "users", "=", "$", "repo", "->", "getUserInSystem", "(", ")", ";", "$", "contacts", "=", "[", "]", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "contact", "=", "$", "user", "->", "getContact", "(", ")", ";", "$", "contacts", "[", "]", "=", "array", "(", "'id'", "=>", "$", "contact", "->", "getId", "(", ")", ",", "'fullName'", "=>", "$", "contact", "->", "getFullName", "(", ")", ")", ";", "}", "return", "$", "contacts", ";", "}" ]
returns all sulu system users @return array
[ "returns", "all", "sulu", "system", "users" ]
train
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php#L51-L65
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php
TemplateController.getOrderStatus
public function getOrderStatus() { $statuses = $this->getDoctrine()->getRepository(self::$orderStatusEntityName)->findAll(); $locale = $this->getUser()->getLocale(); $statusArray = []; foreach ($statuses as $statusEntity) { $status = new OrderStatus($statusEntity, $locale); $statusArray[] = array( 'id' => $status->getId(), 'status' => $status->getStatus() ); } return $statusArray; }
php
public function getOrderStatus() { $statuses = $this->getDoctrine()->getRepository(self::$orderStatusEntityName)->findAll(); $locale = $this->getUser()->getLocale(); $statusArray = []; foreach ($statuses as $statusEntity) { $status = new OrderStatus($statusEntity, $locale); $statusArray[] = array( 'id' => $status->getId(), 'status' => $status->getStatus() ); } return $statusArray; }
[ "public", "function", "getOrderStatus", "(", ")", "{", "$", "statuses", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "self", "::", "$", "orderStatusEntityName", ")", "->", "findAll", "(", ")", ";", "$", "locale", "=", "$", "this", "->", "getUser", "(", ")", "->", "getLocale", "(", ")", ";", "$", "statusArray", "=", "[", "]", ";", "foreach", "(", "$", "statuses", "as", "$", "statusEntity", ")", "{", "$", "status", "=", "new", "OrderStatus", "(", "$", "statusEntity", ",", "$", "locale", ")", ";", "$", "statusArray", "[", "]", "=", "array", "(", "'id'", "=>", "$", "status", "->", "getId", "(", ")", ",", "'status'", "=>", "$", "status", "->", "getStatus", "(", ")", ")", ";", "}", "return", "$", "statusArray", ";", "}" ]
returns array of order statuses @return array
[ "returns", "array", "of", "order", "statuses" ]
train
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php#L90-L104
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php
TemplateController.getCurrencies
private function getCurrencies($language) { /** @var Currency[] $currencies */ $currencies = $this->get('sulu_product.currency_manager')->findAll($language); $currencyValues = array(); foreach ($currencies as $currency) { $currencyValues[] = array( 'id' => $currency->getId(), 'name' => $currency->getName(), 'code' => $currency->getCode() ); } return $currencyValues; }
php
private function getCurrencies($language) { /** @var Currency[] $currencies */ $currencies = $this->get('sulu_product.currency_manager')->findAll($language); $currencyValues = array(); foreach ($currencies as $currency) { $currencyValues[] = array( 'id' => $currency->getId(), 'name' => $currency->getName(), 'code' => $currency->getCode() ); } return $currencyValues; }
[ "private", "function", "getCurrencies", "(", "$", "language", ")", "{", "/** @var Currency[] $currencies */", "$", "currencies", "=", "$", "this", "->", "get", "(", "'sulu_product.currency_manager'", ")", "->", "findAll", "(", "$", "language", ")", ";", "$", "currencyValues", "=", "array", "(", ")", ";", "foreach", "(", "$", "currencies", "as", "$", "currency", ")", "{", "$", "currencyValues", "[", "]", "=", "array", "(", "'id'", "=>", "$", "currency", "->", "getId", "(", ")", ",", "'name'", "=>", "$", "currency", "->", "getName", "(", ")", ",", "'code'", "=>", "$", "currency", "->", "getCode", "(", ")", ")", ";", "}", "return", "$", "currencyValues", ";", "}" ]
Returns currencies @param $language @return array
[ "Returns", "currencies" ]
train
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php#L112-L128
geosocio/http-serializer-bundle
src/DependencyInjection/GeoSocioHttpSerializerExtension.php
GeoSocioHttpSerializerExtension.load
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); // Group Resolver $container->register( 'geosocio_http_serializer.request_group_resolver_manager', RequestGroupResolverManager::class ) ->setPublic(false); $container->register( 'geosocio_http_serializer.response_group_resolver_manager', ResponseGroupResolverManager::class ) ->setPublic(false); // Group Loader $container->register('geosocio_http_serializer.request_group_loader', RequestGroupLoader::class) ->setArguments([ new Reference('controller_resolver'), new Reference('annotation_reader'), ]) ->addTag('geosocio_http_serializer.request_group_resolver') ->setPublic(false); $container->register('geosocio_http_serializer.response_group_loader', ResponseGroupLoader::class) ->setArguments([ new Reference('controller_resolver'), new Reference('annotation_reader'), ]) ->addTag('geosocio_http_serializer.response_group_resolver') ->setPublic(false); // Return Listener $serializer = new Reference('serializer'); $container->register('geosocio_http_serializer.return_listener', KernelViewListener::class) ->setArguments([ $serializer, $serializer, $serializer, new Reference('event_dispatcher'), new Reference('geosocio_http_serializer.response_group_resolver_manager'), ]) ->addTag('kernel.event_listener', ['event' => 'kernel.view']) ->setPublic(false); // Exception Listener $serializer = new Reference('serializer'); $container->register('geosocio_http_serializer.exception_listener', KernelExceptionListener::class) ->setArguments([ $serializer, $serializer, $serializer, new Reference('event_dispatcher'), $config['default_format'] ?? null ]) ->addTag('kernel.event_listener', ['event' => 'kernel.exception']) ->setPublic(false); // Exception Normalizer $container->register('geosocio_http_serializer.serializer_exception', ExceptionNormalizer::class) ->setArguments([ '%kernel.environment%' ]) ->addTag('serializer.normalizer') ->setPublic(false); // Constraint Violation Normalizer $container->register( 'geosocio_http_serializer.serializer_constraint_violation', ConstraintViolationNormalizer::class ) ->addTag('serializer.normalizer') ->setPublic(false); // Content Class Resolver $serializer = new Reference('serializer'); $container->register('geosocio_http_serializer.content_class_resolver', ContentClassResolver::class) ->setArguments([ $serializer, $serializer, $serializer, new Reference('event_dispatcher'), new Reference('validator'), new Reference('geosocio_http_serializer.request_group_resolver_manager'), ]) ->addTag('controller.argument_value_resolver') ->setPublic(false); // Content Array Resolver $container->register('geosocio_http_serializer.content_array_resolver', ContentArrayResolver::class) ->setArguments([ new Reference('serializer') ]) ->addTag('controller.argument_value_resolver') ->setPublic(false); }
php
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); // Group Resolver $container->register( 'geosocio_http_serializer.request_group_resolver_manager', RequestGroupResolverManager::class ) ->setPublic(false); $container->register( 'geosocio_http_serializer.response_group_resolver_manager', ResponseGroupResolverManager::class ) ->setPublic(false); // Group Loader $container->register('geosocio_http_serializer.request_group_loader', RequestGroupLoader::class) ->setArguments([ new Reference('controller_resolver'), new Reference('annotation_reader'), ]) ->addTag('geosocio_http_serializer.request_group_resolver') ->setPublic(false); $container->register('geosocio_http_serializer.response_group_loader', ResponseGroupLoader::class) ->setArguments([ new Reference('controller_resolver'), new Reference('annotation_reader'), ]) ->addTag('geosocio_http_serializer.response_group_resolver') ->setPublic(false); // Return Listener $serializer = new Reference('serializer'); $container->register('geosocio_http_serializer.return_listener', KernelViewListener::class) ->setArguments([ $serializer, $serializer, $serializer, new Reference('event_dispatcher'), new Reference('geosocio_http_serializer.response_group_resolver_manager'), ]) ->addTag('kernel.event_listener', ['event' => 'kernel.view']) ->setPublic(false); // Exception Listener $serializer = new Reference('serializer'); $container->register('geosocio_http_serializer.exception_listener', KernelExceptionListener::class) ->setArguments([ $serializer, $serializer, $serializer, new Reference('event_dispatcher'), $config['default_format'] ?? null ]) ->addTag('kernel.event_listener', ['event' => 'kernel.exception']) ->setPublic(false); // Exception Normalizer $container->register('geosocio_http_serializer.serializer_exception', ExceptionNormalizer::class) ->setArguments([ '%kernel.environment%' ]) ->addTag('serializer.normalizer') ->setPublic(false); // Constraint Violation Normalizer $container->register( 'geosocio_http_serializer.serializer_constraint_violation', ConstraintViolationNormalizer::class ) ->addTag('serializer.normalizer') ->setPublic(false); // Content Class Resolver $serializer = new Reference('serializer'); $container->register('geosocio_http_serializer.content_class_resolver', ContentClassResolver::class) ->setArguments([ $serializer, $serializer, $serializer, new Reference('event_dispatcher'), new Reference('validator'), new Reference('geosocio_http_serializer.request_group_resolver_manager'), ]) ->addTag('controller.argument_value_resolver') ->setPublic(false); // Content Array Resolver $container->register('geosocio_http_serializer.content_array_resolver', ContentArrayResolver::class) ->setArguments([ new Reference('serializer') ]) ->addTag('controller.argument_value_resolver') ->setPublic(false); }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "configuration", "=", "new", "Configuration", "(", ")", ";", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "$", "configuration", ",", "$", "configs", ")", ";", "// Group Resolver", "$", "container", "->", "register", "(", "'geosocio_http_serializer.request_group_resolver_manager'", ",", "RequestGroupResolverManager", "::", "class", ")", "->", "setPublic", "(", "false", ")", ";", "$", "container", "->", "register", "(", "'geosocio_http_serializer.response_group_resolver_manager'", ",", "ResponseGroupResolverManager", "::", "class", ")", "->", "setPublic", "(", "false", ")", ";", "// Group Loader", "$", "container", "->", "register", "(", "'geosocio_http_serializer.request_group_loader'", ",", "RequestGroupLoader", "::", "class", ")", "->", "setArguments", "(", "[", "new", "Reference", "(", "'controller_resolver'", ")", ",", "new", "Reference", "(", "'annotation_reader'", ")", ",", "]", ")", "->", "addTag", "(", "'geosocio_http_serializer.request_group_resolver'", ")", "->", "setPublic", "(", "false", ")", ";", "$", "container", "->", "register", "(", "'geosocio_http_serializer.response_group_loader'", ",", "ResponseGroupLoader", "::", "class", ")", "->", "setArguments", "(", "[", "new", "Reference", "(", "'controller_resolver'", ")", ",", "new", "Reference", "(", "'annotation_reader'", ")", ",", "]", ")", "->", "addTag", "(", "'geosocio_http_serializer.response_group_resolver'", ")", "->", "setPublic", "(", "false", ")", ";", "// Return Listener", "$", "serializer", "=", "new", "Reference", "(", "'serializer'", ")", ";", "$", "container", "->", "register", "(", "'geosocio_http_serializer.return_listener'", ",", "KernelViewListener", "::", "class", ")", "->", "setArguments", "(", "[", "$", "serializer", ",", "$", "serializer", ",", "$", "serializer", ",", "new", "Reference", "(", "'event_dispatcher'", ")", ",", "new", "Reference", "(", "'geosocio_http_serializer.response_group_resolver_manager'", ")", ",", "]", ")", "->", "addTag", "(", "'kernel.event_listener'", ",", "[", "'event'", "=>", "'kernel.view'", "]", ")", "->", "setPublic", "(", "false", ")", ";", "// Exception Listener", "$", "serializer", "=", "new", "Reference", "(", "'serializer'", ")", ";", "$", "container", "->", "register", "(", "'geosocio_http_serializer.exception_listener'", ",", "KernelExceptionListener", "::", "class", ")", "->", "setArguments", "(", "[", "$", "serializer", ",", "$", "serializer", ",", "$", "serializer", ",", "new", "Reference", "(", "'event_dispatcher'", ")", ",", "$", "config", "[", "'default_format'", "]", "??", "null", "]", ")", "->", "addTag", "(", "'kernel.event_listener'", ",", "[", "'event'", "=>", "'kernel.exception'", "]", ")", "->", "setPublic", "(", "false", ")", ";", "// Exception Normalizer", "$", "container", "->", "register", "(", "'geosocio_http_serializer.serializer_exception'", ",", "ExceptionNormalizer", "::", "class", ")", "->", "setArguments", "(", "[", "'%kernel.environment%'", "]", ")", "->", "addTag", "(", "'serializer.normalizer'", ")", "->", "setPublic", "(", "false", ")", ";", "// Constraint Violation Normalizer", "$", "container", "->", "register", "(", "'geosocio_http_serializer.serializer_constraint_violation'", ",", "ConstraintViolationNormalizer", "::", "class", ")", "->", "addTag", "(", "'serializer.normalizer'", ")", "->", "setPublic", "(", "false", ")", ";", "// Content Class Resolver", "$", "serializer", "=", "new", "Reference", "(", "'serializer'", ")", ";", "$", "container", "->", "register", "(", "'geosocio_http_serializer.content_class_resolver'", ",", "ContentClassResolver", "::", "class", ")", "->", "setArguments", "(", "[", "$", "serializer", ",", "$", "serializer", ",", "$", "serializer", ",", "new", "Reference", "(", "'event_dispatcher'", ")", ",", "new", "Reference", "(", "'validator'", ")", ",", "new", "Reference", "(", "'geosocio_http_serializer.request_group_resolver_manager'", ")", ",", "]", ")", "->", "addTag", "(", "'controller.argument_value_resolver'", ")", "->", "setPublic", "(", "false", ")", ";", "// Content Array Resolver", "$", "container", "->", "register", "(", "'geosocio_http_serializer.content_array_resolver'", ",", "ContentArrayResolver", "::", "class", ")", "->", "setArguments", "(", "[", "new", "Reference", "(", "'serializer'", ")", "]", ")", "->", "addTag", "(", "'controller.argument_value_resolver'", ")", "->", "setPublic", "(", "false", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/geosocio/http-serializer-bundle/blob/2ceb24a148204b1f3b14083b202db7e5afff2099/src/DependencyInjection/GeoSocioHttpSerializerExtension.php#L37-L134
dpi/ak
src/AvatarIdentifier.php
AvatarIdentifier.setRaw
public function setRaw(string $raw) { $this->raw = $raw; $this->hashed = NULL; return $this; }
php
public function setRaw(string $raw) { $this->raw = $raw; $this->hashed = NULL; return $this; }
[ "public", "function", "setRaw", "(", "string", "$", "raw", ")", "{", "$", "this", "->", "raw", "=", "$", "raw", ";", "$", "this", "->", "hashed", "=", "NULL", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/dpi/ak/blob/cc61b172a827498cf6284191d51ce04d0f7c0f97/src/AvatarIdentifier.php#L48-L52
dpi/ak
src/AvatarIdentifier.php
AvatarIdentifier.getHashed
public function getHashed() { if (isset($this->hashed)) { return $this->hashed; } $hasher = $this->hasher ?? NULL; $raw = $this->raw ?? NULL; if ($raw) { if (!is_callable($hasher)) { throw new AvatarIdentifierException('No hashing algorithm set.'); } return call_user_func($hasher, $raw); } else { throw new AvatarIdentifierException('No values set.'); } }
php
public function getHashed() { if (isset($this->hashed)) { return $this->hashed; } $hasher = $this->hasher ?? NULL; $raw = $this->raw ?? NULL; if ($raw) { if (!is_callable($hasher)) { throw new AvatarIdentifierException('No hashing algorithm set.'); } return call_user_func($hasher, $raw); } else { throw new AvatarIdentifierException('No values set.'); } }
[ "public", "function", "getHashed", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "hashed", ")", ")", "{", "return", "$", "this", "->", "hashed", ";", "}", "$", "hasher", "=", "$", "this", "->", "hasher", "??", "NULL", ";", "$", "raw", "=", "$", "this", "->", "raw", "??", "NULL", ";", "if", "(", "$", "raw", ")", "{", "if", "(", "!", "is_callable", "(", "$", "hasher", ")", ")", "{", "throw", "new", "AvatarIdentifierException", "(", "'No hashing algorithm set.'", ")", ";", "}", "return", "call_user_func", "(", "$", "hasher", ",", "$", "raw", ")", ";", "}", "else", "{", "throw", "new", "AvatarIdentifierException", "(", "'No values set.'", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/dpi/ak/blob/cc61b172a827498cf6284191d51ce04d0f7c0f97/src/AvatarIdentifier.php#L57-L73
dpi/ak
src/AvatarIdentifier.php
AvatarIdentifier.setHashed
public function setHashed(string $string) { $this->raw = NULL; $this->hashed = $string; return $this; }
php
public function setHashed(string $string) { $this->raw = NULL; $this->hashed = $string; return $this; }
[ "public", "function", "setHashed", "(", "string", "$", "string", ")", "{", "$", "this", "->", "raw", "=", "NULL", ";", "$", "this", "->", "hashed", "=", "$", "string", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/dpi/ak/blob/cc61b172a827498cf6284191d51ce04d0f7c0f97/src/AvatarIdentifier.php#L78-L82
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php
CurlHttpClient.get
public function get($uri, array $params = array()) { $uri .= '?' . http_build_query($params); $ch = $this->initCurlHandler($uri); return $this->makeRequest($ch); }
php
public function get($uri, array $params = array()) { $uri .= '?' . http_build_query($params); $ch = $this->initCurlHandler($uri); return $this->makeRequest($ch); }
[ "public", "function", "get", "(", "$", "uri", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "uri", ".=", "'?'", ".", "http_build_query", "(", "$", "params", ")", ";", "$", "ch", "=", "$", "this", "->", "initCurlHandler", "(", "$", "uri", ")", ";", "return", "$", "this", "->", "makeRequest", "(", "$", "ch", ")", ";", "}" ]
(non-PHPdoc) @see TheTwelve\Foursquare.HttpClient::get()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php#L73-L81
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php
CurlHttpClient.post
public function post($uri, array $params = array()) { $ch = $this->initCurlHandler($uri); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); return $this->makeRequest($ch); }
php
public function post($uri, array $params = array()) { $ch = $this->initCurlHandler($uri); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); return $this->makeRequest($ch); }
[ "public", "function", "post", "(", "$", "uri", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "ch", "=", "$", "this", "->", "initCurlHandler", "(", "$", "uri", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "params", ")", ";", "return", "$", "this", "->", "makeRequest", "(", "$", "ch", ")", ";", "}" ]
(non-PHPdoc) @see TheTwelve\Foursquare.HttpClient::post()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php#L87-L96
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php
CurlHttpClient.initCurlHandler
protected function initCurlHandler($uri) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_USERAGENT, 'twelvelabs/foursquare client'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->verifyHost); if ($this->verifyPeer === false) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } else { // @see http://curl.haxx.se/docs/caextract.html if (!file_exists($this->certificatePath)) { throw new \RuntimeException('cacert.pem file not found'); } curl_setopt ($ch, CURLOPT_CAINFO, $this->certificatePath); } return $ch; }
php
protected function initCurlHandler($uri) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_USERAGENT, 'twelvelabs/foursquare client'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->verifyHost); if ($this->verifyPeer === false) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } else { // @see http://curl.haxx.se/docs/caextract.html if (!file_exists($this->certificatePath)) { throw new \RuntimeException('cacert.pem file not found'); } curl_setopt ($ch, CURLOPT_CAINFO, $this->certificatePath); } return $ch; }
[ "protected", "function", "initCurlHandler", "(", "$", "uri", ")", "{", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "uri", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_USERAGENT", ",", "'twelvelabs/foursquare client'", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYHOST", ",", "$", "this", "->", "verifyHost", ")", ";", "if", "(", "$", "this", "->", "verifyPeer", "===", "false", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "}", "else", "{", "// @see http://curl.haxx.se/docs/caextract.html", "if", "(", "!", "file_exists", "(", "$", "this", "->", "certificatePath", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'cacert.pem file not found'", ")", ";", "}", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CAINFO", ",", "$", "this", "->", "certificatePath", ")", ";", "}", "return", "$", "ch", ";", "}" ]
initialize the cURL handler @param string $uri @return resource
[ "initialize", "the", "cURL", "handler" ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php#L103-L128
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php
CurlHttpClient.makeRequest
protected function makeRequest($ch) { $response = curl_exec($ch); $error = curl_error($ch); $code = curl_errno($ch); if ($error) { curl_close($ch); throw new \RuntimeException($error, $code); } curl_close($ch); return $response; }
php
protected function makeRequest($ch) { $response = curl_exec($ch); $error = curl_error($ch); $code = curl_errno($ch); if ($error) { curl_close($ch); throw new \RuntimeException($error, $code); } curl_close($ch); return $response; }
[ "protected", "function", "makeRequest", "(", "$", "ch", ")", "{", "$", "response", "=", "curl_exec", "(", "$", "ch", ")", ";", "$", "error", "=", "curl_error", "(", "$", "ch", ")", ";", "$", "code", "=", "curl_errno", "(", "$", "ch", ")", ";", "if", "(", "$", "error", ")", "{", "curl_close", "(", "$", "ch", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "$", "error", ",", "$", "code", ")", ";", "}", "curl_close", "(", "$", "ch", ")", ";", "return", "$", "response", ";", "}" ]
make the cURL request @param resource $ch @return mixed
[ "make", "the", "cURL", "request" ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php#L135-L151
etki/opencart-core-installer
src/Installer.php
Installer.supports
public function supports($packageType) { DebugPrinter::log( 'Checking support for package type `%s` (%s)', array($packageType, $packageType === $this->packageType ? 'y' : 'n') ); return $packageType === $this->packageType; }
php
public function supports($packageType) { DebugPrinter::log( 'Checking support for package type `%s` (%s)', array($packageType, $packageType === $this->packageType ? 'y' : 'n') ); return $packageType === $this->packageType; }
[ "public", "function", "supports", "(", "$", "packageType", ")", "{", "DebugPrinter", "::", "log", "(", "'Checking support for package type `%s` (%s)'", ",", "array", "(", "$", "packageType", ",", "$", "packageType", "===", "$", "this", "->", "packageType", "?", "'y'", ":", "'n'", ")", ")", ";", "return", "$", "packageType", "===", "$", "this", "->", "packageType", ";", "}" ]
Tells composer if this installer supports provided package type. @param string $packageType Package type name. @return bool @since 0.1.0
[ "Tells", "composer", "if", "this", "installer", "supports", "provided", "package", "type", "." ]
train
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/Installer.php#L53-L60
etki/opencart-core-installer
src/Installer.php
Installer.getInstallPath
public function getInstallPath(PackageInterface $package) { $prettyName = $package->getPrettyName(); DebugPrinter::log( 'Getting install path for `%s` package', array($prettyName,) ); if (isset($this->installDirCache[$prettyName])) { return $this->installDirCache[$prettyName]; } $installDir = null; if ($this->composer->getPackage()) { $rootExtra = $this->composer->getPackage()->getExtra(); if (!empty($rootExtra['opencart-install-dir'])) { $installDir = $rootExtra['opencart-install-dir']; } } if (!$installDir) { $extra = $package->getExtra(); if (!empty($extra['opencart-install-dir'])) { $installDir = $extra['opencart-install-dir']; } } if (is_array($installDir)) { if (isset($installDir[$prettyName])) { $this->installDirCache[$prettyName] = $installDir[$prettyName]; return $installDir[$prettyName]; } $this->installDirCache[$prettyName] = $this->defaultInstallDir; return $this->defaultInstallDir; } $installDir = $installDir ? $installDir : $this->defaultInstallDir; DebugPrinter::log( 'Computed install dir for package `%s`: `%s`', array($prettyName, $installDir,) ); $this->installDirCache[$prettyName] = $installDir; return $installDir; }
php
public function getInstallPath(PackageInterface $package) { $prettyName = $package->getPrettyName(); DebugPrinter::log( 'Getting install path for `%s` package', array($prettyName,) ); if (isset($this->installDirCache[$prettyName])) { return $this->installDirCache[$prettyName]; } $installDir = null; if ($this->composer->getPackage()) { $rootExtra = $this->composer->getPackage()->getExtra(); if (!empty($rootExtra['opencart-install-dir'])) { $installDir = $rootExtra['opencart-install-dir']; } } if (!$installDir) { $extra = $package->getExtra(); if (!empty($extra['opencart-install-dir'])) { $installDir = $extra['opencart-install-dir']; } } if (is_array($installDir)) { if (isset($installDir[$prettyName])) { $this->installDirCache[$prettyName] = $installDir[$prettyName]; return $installDir[$prettyName]; } $this->installDirCache[$prettyName] = $this->defaultInstallDir; return $this->defaultInstallDir; } $installDir = $installDir ? $installDir : $this->defaultInstallDir; DebugPrinter::log( 'Computed install dir for package `%s`: `%s`', array($prettyName, $installDir,) ); $this->installDirCache[$prettyName] = $installDir; return $installDir; }
[ "public", "function", "getInstallPath", "(", "PackageInterface", "$", "package", ")", "{", "$", "prettyName", "=", "$", "package", "->", "getPrettyName", "(", ")", ";", "DebugPrinter", "::", "log", "(", "'Getting install path for `%s` package'", ",", "array", "(", "$", "prettyName", ",", ")", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "installDirCache", "[", "$", "prettyName", "]", ")", ")", "{", "return", "$", "this", "->", "installDirCache", "[", "$", "prettyName", "]", ";", "}", "$", "installDir", "=", "null", ";", "if", "(", "$", "this", "->", "composer", "->", "getPackage", "(", ")", ")", "{", "$", "rootExtra", "=", "$", "this", "->", "composer", "->", "getPackage", "(", ")", "->", "getExtra", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "rootExtra", "[", "'opencart-install-dir'", "]", ")", ")", "{", "$", "installDir", "=", "$", "rootExtra", "[", "'opencart-install-dir'", "]", ";", "}", "}", "if", "(", "!", "$", "installDir", ")", "{", "$", "extra", "=", "$", "package", "->", "getExtra", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "extra", "[", "'opencart-install-dir'", "]", ")", ")", "{", "$", "installDir", "=", "$", "extra", "[", "'opencart-install-dir'", "]", ";", "}", "}", "if", "(", "is_array", "(", "$", "installDir", ")", ")", "{", "if", "(", "isset", "(", "$", "installDir", "[", "$", "prettyName", "]", ")", ")", "{", "$", "this", "->", "installDirCache", "[", "$", "prettyName", "]", "=", "$", "installDir", "[", "$", "prettyName", "]", ";", "return", "$", "installDir", "[", "$", "prettyName", "]", ";", "}", "$", "this", "->", "installDirCache", "[", "$", "prettyName", "]", "=", "$", "this", "->", "defaultInstallDir", ";", "return", "$", "this", "->", "defaultInstallDir", ";", "}", "$", "installDir", "=", "$", "installDir", "?", "$", "installDir", ":", "$", "this", "->", "defaultInstallDir", ";", "DebugPrinter", "::", "log", "(", "'Computed install dir for package `%s`: `%s`'", ",", "array", "(", "$", "prettyName", ",", "$", "installDir", ",", ")", ")", ";", "$", "this", "->", "installDirCache", "[", "$", "prettyName", "]", "=", "$", "installDir", ";", "return", "$", "installDir", ";", "}" ]
Provides installation path for package. Kudos go to https://github.com/johnpbloch/wordpress-core-installer @param PackageInterface $package Installed package. @todo refactor @return string @since 0.1.0
[ "Provides", "installation", "path", "for", "package", ".", "Kudos", "go", "to", "https", ":", "//", "github", ".", "com", "/", "johnpbloch", "/", "wordpress", "-", "core", "-", "installer" ]
train
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/Installer.php#L73-L111
etki/opencart-core-installer
src/Installer.php
Installer.install
public function install( InstalledRepositoryInterface $repo, PackageInterface $package ) { $installPath = $this->getInstallPath($package); $junglist = new FileJunglist; DebugPrinter::log( 'Installing package `%s` to %s', array($package->getPrettyName(), $installPath,) ); parent::install($repo, $package); DebugPrinter::log('Post-install file rotating'); $junglist->rotateInstalledFiles($installPath); $junglist->copyConfigFiles($installPath); DebugPrinter::log('Finished installation'); }
php
public function install( InstalledRepositoryInterface $repo, PackageInterface $package ) { $installPath = $this->getInstallPath($package); $junglist = new FileJunglist; DebugPrinter::log( 'Installing package `%s` to %s', array($package->getPrettyName(), $installPath,) ); parent::install($repo, $package); DebugPrinter::log('Post-install file rotating'); $junglist->rotateInstalledFiles($installPath); $junglist->copyConfigFiles($installPath); DebugPrinter::log('Finished installation'); }
[ "public", "function", "install", "(", "InstalledRepositoryInterface", "$", "repo", ",", "PackageInterface", "$", "package", ")", "{", "$", "installPath", "=", "$", "this", "->", "getInstallPath", "(", "$", "package", ")", ";", "$", "junglist", "=", "new", "FileJunglist", ";", "DebugPrinter", "::", "log", "(", "'Installing package `%s` to %s'", ",", "array", "(", "$", "package", "->", "getPrettyName", "(", ")", ",", "$", "installPath", ",", ")", ")", ";", "parent", "::", "install", "(", "$", "repo", ",", "$", "package", ")", ";", "DebugPrinter", "::", "log", "(", "'Post-install file rotating'", ")", ";", "$", "junglist", "->", "rotateInstalledFiles", "(", "$", "installPath", ")", ";", "$", "junglist", "->", "copyConfigFiles", "(", "$", "installPath", ")", ";", "DebugPrinter", "::", "log", "(", "'Finished installation'", ")", ";", "}" ]
{@inheritdoc} @param InstalledRepositoryInterface $repo Repository, @param PackageInterface $package Package. @return void @since 0.1.0
[ "{", "@inheritdoc", "}" ]
train
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/Installer.php#L122-L137
etki/opencart-core-installer
src/Installer.php
Installer.update
public function update( InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target ) { $installPath = $this->getInstallPath($target); $junglist = new FileJunglist; $junglist->saveModifiedFiles($installPath); DebugPrinter::log('Updating package'); parent::update($repo, $initial, $target); DebugPrinter::log('Post-update file rotate'); $junglist->rotateInstalledFiles($installPath); $junglist->restoreModifiedFiles($installPath); DebugPrinter::log('Finished updating'); }
php
public function update( InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target ) { $installPath = $this->getInstallPath($target); $junglist = new FileJunglist; $junglist->saveModifiedFiles($installPath); DebugPrinter::log('Updating package'); parent::update($repo, $initial, $target); DebugPrinter::log('Post-update file rotate'); $junglist->rotateInstalledFiles($installPath); $junglist->restoreModifiedFiles($installPath); DebugPrinter::log('Finished updating'); }
[ "public", "function", "update", "(", "InstalledRepositoryInterface", "$", "repo", ",", "PackageInterface", "$", "initial", ",", "PackageInterface", "$", "target", ")", "{", "$", "installPath", "=", "$", "this", "->", "getInstallPath", "(", "$", "target", ")", ";", "$", "junglist", "=", "new", "FileJunglist", ";", "$", "junglist", "->", "saveModifiedFiles", "(", "$", "installPath", ")", ";", "DebugPrinter", "::", "log", "(", "'Updating package'", ")", ";", "parent", "::", "update", "(", "$", "repo", ",", "$", "initial", ",", "$", "target", ")", ";", "DebugPrinter", "::", "log", "(", "'Post-update file rotate'", ")", ";", "$", "junglist", "->", "rotateInstalledFiles", "(", "$", "installPath", ")", ";", "$", "junglist", "->", "restoreModifiedFiles", "(", "$", "installPath", ")", ";", "DebugPrinter", "::", "log", "(", "'Finished updating'", ")", ";", "}" ]
{@inheritdoc} @param InstalledRepositoryInterface $repo Repository, @param PackageInterface $initial Current package. @param PackageInterface $target Newly installed package. @return void @since 0.1.0
[ "{", "@inheritdoc", "}" ]
train
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/Installer.php#L149-L163
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.uploadForeverMedia
public function uploadForeverMedia($data, $type,$is_video=false,$video_info=array()){ if (!$this->access_token && !$this->checkAuth()) return false; //#TODO 暂不确定此接口是否需要让视频文件走http协议 //如果要获取的素材是视频文件时,不能使用https协议,必须更换成http协议 //$url_prefix = $is_video?str_replace('https','http',self::API_URL_PREFIX):self::API_URL_PREFIX; //当上传视频文件时,附加视频文件信息 if ($is_video) $data['description'] = self::json_encode($video_info); $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_UPLOAD_URL.'access_token='.$this->access_token.'&type='.$type,$data,true); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function uploadForeverMedia($data, $type,$is_video=false,$video_info=array()){ if (!$this->access_token && !$this->checkAuth()) return false; //#TODO 暂不确定此接口是否需要让视频文件走http协议 //如果要获取的素材是视频文件时,不能使用https协议,必须更换成http协议 //$url_prefix = $is_video?str_replace('https','http',self::API_URL_PREFIX):self::API_URL_PREFIX; //当上传视频文件时,附加视频文件信息 if ($is_video) $data['description'] = self::json_encode($video_info); $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_UPLOAD_URL.'access_token='.$this->access_token.'&type='.$type,$data,true); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "uploadForeverMedia", "(", "$", "data", ",", "$", "type", ",", "$", "is_video", "=", "false", ",", "$", "video_info", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "//#TODO 暂不确定此接口是否需要让视频文件走http协议", "//如果要获取的素材是视频文件时,不能使用https协议,必须更换成http协议", "//$url_prefix = $is_video?str_replace('https','http',self::API_URL_PREFIX):self::API_URL_PREFIX;", "//当上传视频文件时,附加视频文件信息", "if", "(", "$", "is_video", ")", "$", "data", "[", "'description'", "]", "=", "self", "::", "json_encode", "(", "$", "video_info", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_URL_PREFIX", ".", "self", "::", "MEDIA_FOREVER_UPLOAD_URL", ".", "'access_token='", ".", "$", "this", "->", "access_token", ".", "'&type='", ".", "$", "type", ",", "$", "data", ",", "true", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
上传永久素材(认证后的订阅号可用) 新增的永久素材也可以在公众平台官网素材管理模块中看到 注意:上传大文件时可能需要先调用 set_time_limit(0) 避免超时 注意:数组的键值任意,但文件名前必须加@,使用单引号以避免本地路径斜杠被转义 @param array $data {"media":'@Path\filename.jpg'} @param type 类型:图片:image 语音:voice 视频:video 缩略图:thumb @param boolean $is_video 是否为视频文件,默认为否 @param array $video_info 视频信息数组,非视频素材不需要提供 array('title'=>'视频标题','introduction'=>'描述') @return boolean|array
[ "上传永久素材", "(", "认证后的订阅号可用", ")", "新增的永久素材也可以在公众平台官网素材管理模块中看到", "注意:上传大文件时可能需要先调用", "set_time_limit", "(", "0", ")", "避免超时", "注意:数组的键值任意,但文件名前必须加" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L1572-L1591
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.updateForeverArticles
public function updateForeverArticles($media_id,$data,$index=0){ if (!$this->access_token && !$this->checkAuth()) return false; if (!isset($data['media_id'])) $data['media_id'] = $media_id; if (!isset($data['index'])) $data['index'] = $index; $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_NEWS_UPDATE_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function updateForeverArticles($media_id,$data,$index=0){ if (!$this->access_token && !$this->checkAuth()) return false; if (!isset($data['media_id'])) $data['media_id'] = $media_id; if (!isset($data['index'])) $data['index'] = $index; $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_NEWS_UPDATE_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "updateForeverArticles", "(", "$", "media_id", ",", "$", "data", ",", "$", "index", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'media_id'", "]", ")", ")", "$", "data", "[", "'media_id'", "]", "=", "$", "media_id", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'index'", "]", ")", ")", "$", "data", "[", "'index'", "]", "=", "$", "index", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_URL_PREFIX", ".", "self", "::", "MEDIA_FOREVER_NEWS_UPDATE_URL", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
修改永久图文素材(认证后的订阅号可用) 永久素材也可以在公众平台官网素材管理模块中看到 @param string $media_id 图文素材id @param array $data 消息结构{"articles":[{...}]} @param int $index 更新的文章在图文素材的位置,第一篇为0,仅多图文使用 @return boolean|array
[ "修改永久图文素材", "(", "认证后的订阅号可用", ")", "永久素材也可以在公众平台官网素材管理模块中看到" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L1623-L1639
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.delForeverMedia
public function delForeverMedia($media_id){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array('media_id' => $media_id); $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_DEL_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return true; } return false; }
php
public function delForeverMedia($media_id){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array('media_id' => $media_id); $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_DEL_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return true; } return false; }
[ "public", "function", "delForeverMedia", "(", "$", "media_id", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "data", "=", "array", "(", "'media_id'", "=>", "$", "media_id", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_URL_PREFIX", ".", "self", "::", "MEDIA_FOREVER_DEL_URL", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
删除永久素材(认证后的订阅号可用) @param string $media_id 媒体文件id @return boolean
[ "删除永久素材", "(", "认证后的订阅号可用", ")" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L1676-L1691
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.getForeverList
public function getForeverList($type,$offset,$count){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( 'type' => $type, 'offset' => $offset, 'count' => $count, ); $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_BATCHGET_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (isset($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function getForeverList($type,$offset,$count){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( 'type' => $type, 'offset' => $offset, 'count' => $count, ); $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_BATCHGET_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (isset($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "getForeverList", "(", "$", "type", ",", "$", "offset", ",", "$", "count", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "data", "=", "array", "(", "'type'", "=>", "$", "type", ",", "'offset'", "=>", "$", "offset", ",", "'count'", "=>", "$", "count", ",", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_URL_PREFIX", ".", "self", "::", "MEDIA_FOREVER_BATCHGET_URL", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
获取永久素材列表(认证后的订阅号可用) @param string $type 素材的类型,图片(image)、视频(video)、语音 (voice)、图文(news) @param int $offset 全部素材的偏移位置,0表示从第一个素材 @param int $count 返回素材的数量,取值在1到20之间 @return boolean|array 返回数组格式: array( 'total_count'=>0, //该类型的素材的总数 'item_count'=>0, //本次调用获取的素材的数量 'item'=>array() //素材列表数组,内容定义请参考官方文档 )
[ "获取永久素材列表", "(", "认证后的订阅号可用", ")" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L1706-L1725
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.getForeverCount
public function getForeverCount(){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_get(self::API_URL_PREFIX.self::MEDIA_FOREVER_COUNT_URL.'access_token='.$this->access_token); if ($result) { $json = json_decode($result,true); if (isset($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function getForeverCount(){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_get(self::API_URL_PREFIX.self::MEDIA_FOREVER_COUNT_URL.'access_token='.$this->access_token); if ($result) { $json = json_decode($result,true); if (isset($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "getForeverCount", "(", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "result", "=", "$", "this", "->", "http_get", "(", "self", "::", "API_URL_PREFIX", ".", "self", "::", "MEDIA_FOREVER_COUNT_URL", ".", "'access_token='", ".", "$", "this", "->", "access_token", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
获取永久素材总数(认证后的订阅号可用) @return boolean|array 返回数组格式: array( 'voice_count'=>0, //语音总数量 'video_count'=>0, //视频总数量 'image_count'=>0, //图片总数量 'news_count'=>0 //图文总数量 )
[ "获取永久素材总数", "(", "认证后的订阅号可用", ")" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L1738-L1752
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.getQRCode
public function getQRCode($scene_id,$type=0,$expire=1800){ if (!$this->access_token && !$this->checkAuth()) return false; $type = ($type && is_string($scene_id))?2:$type; $data = array( 'action_name'=>$type?($type == 2?"QR_LIMIT_STR_SCENE":"QR_LIMIT_SCENE"):"QR_SCENE", 'expire_seconds'=>$expire, 'action_info'=>array('scene'=>($type == 2?array('scene_str'=>$scene_id):array('scene_id'=>$scene_id))) ); if ($type == 1) { unset($data['expire_seconds']); } $result = $this->http_post(self::API_URL_PREFIX.self::QRCODE_CREATE_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function getQRCode($scene_id,$type=0,$expire=1800){ if (!$this->access_token && !$this->checkAuth()) return false; $type = ($type && is_string($scene_id))?2:$type; $data = array( 'action_name'=>$type?($type == 2?"QR_LIMIT_STR_SCENE":"QR_LIMIT_SCENE"):"QR_SCENE", 'expire_seconds'=>$expire, 'action_info'=>array('scene'=>($type == 2?array('scene_str'=>$scene_id):array('scene_id'=>$scene_id))) ); if ($type == 1) { unset($data['expire_seconds']); } $result = $this->http_post(self::API_URL_PREFIX.self::QRCODE_CREATE_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "getQRCode", "(", "$", "scene_id", ",", "$", "type", "=", "0", ",", "$", "expire", "=", "1800", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "type", "=", "(", "$", "type", "&&", "is_string", "(", "$", "scene_id", ")", ")", "?", "2", ":", "$", "type", ";", "$", "data", "=", "array", "(", "'action_name'", "=>", "$", "type", "?", "(", "$", "type", "==", "2", "?", "\"QR_LIMIT_STR_SCENE\"", ":", "\"QR_LIMIT_SCENE\"", ")", ":", "\"QR_SCENE\"", ",", "'expire_seconds'", "=>", "$", "expire", ",", "'action_info'", "=>", "array", "(", "'scene'", "=>", "(", "$", "type", "==", "2", "?", "array", "(", "'scene_str'", "=>", "$", "scene_id", ")", ":", "array", "(", "'scene_id'", "=>", "$", "scene_id", ")", ")", ")", ")", ";", "if", "(", "$", "type", "==", "1", ")", "{", "unset", "(", "$", "data", "[", "'expire_seconds'", "]", ")", ";", "}", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_URL_PREFIX", ".", "self", "::", "QRCODE_CREATE_URL", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
创建二维码ticket @param int|string $scene_id 自定义追踪id,临时二维码只能用数值型 @param int $type 0:临时二维码;1:永久二维码(此时expire参数无效);2:永久二维码(此时expire参数无效) @param int $expire 临时二维码有效期,最大为1800秒 @return array('ticket'=>'qrcode字串','expire_seconds'=>1800,'url'=>'二维码图片解析后的地址')
[ "创建二维码ticket" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L1955-L1978
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.batchUpdateGroupMembers
public function batchUpdateGroupMembers($groupid,$openid_list){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( 'openid_list'=>$openid_list, 'to_groupid'=>$groupid ); $result = $this->http_post(self::API_URL_PREFIX.self::GROUP_MEMBER_BATCHUPDATE_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function batchUpdateGroupMembers($groupid,$openid_list){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( 'openid_list'=>$openid_list, 'to_groupid'=>$groupid ); $result = $this->http_post(self::API_URL_PREFIX.self::GROUP_MEMBER_BATCHUPDATE_URL.'access_token='.$this->access_token,self::json_encode($data)); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "batchUpdateGroupMembers", "(", "$", "groupid", ",", "$", "openid_list", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "data", "=", "array", "(", "'openid_list'", "=>", "$", "openid_list", ",", "'to_groupid'", "=>", "$", "groupid", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_URL_PREFIX", ".", "self", "::", "GROUP_MEMBER_BATCHUPDATE_URL", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
批量移动用户分组 @param int $groupid 分组id @param string $openid_list 用户openid数组,一次不能超过50个 @return boolean|array
[ "批量移动用户分组" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L2237-L2255
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.getKFSession
public function getKFSession($openid){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_get(self::API_BASE_URL_PREFIX.self::CUSTOM_SESSION_GET .'access_token='.$this->access_token.'&openid='.$openid); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function getKFSession($openid){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_get(self::API_BASE_URL_PREFIX.self::CUSTOM_SESSION_GET .'access_token='.$this->access_token.'&openid='.$openid); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "getKFSession", "(", "$", "openid", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "result", "=", "$", "this", "->", "http_get", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "CUSTOM_SESSION_GET", ".", "'access_token='", ".", "$", "this", "->", "access_token", ".", "'&openid='", ".", "$", "openid", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
获取用户会话状态 @param string $openid //用户openid @return boolean | array //成功返回json数组 { "errcode" : 0, "errmsg" : "ok", "kf_account" : "test1@test", //正在接待的客服 "createtime": 123456789, //会话接入时间 }
[ "获取用户会话状态" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L2632-L2646
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.getKFSessionlist
public function getKFSessionlist($kf_account){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_get(self::API_BASE_URL_PREFIX.self::CUSTOM_SESSION_GET_LIST .'access_token='.$this->access_token.'&kf_account='.$kf_account); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function getKFSessionlist($kf_account){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_get(self::API_BASE_URL_PREFIX.self::CUSTOM_SESSION_GET_LIST .'access_token='.$this->access_token.'&kf_account='.$kf_account); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "getKFSessionlist", "(", "$", "kf_account", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "result", "=", "$", "this", "->", "http_get", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "CUSTOM_SESSION_GET_LIST", ".", "'access_token='", ".", "$", "this", "->", "access_token", ".", "'&kf_account='", ".", "$", "kf_account", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
获取指定客服的会话列表 @param string $openid //用户openid @return boolean | array //成功返回json数组 array( 'sessionlist' => array ( array ( 'openid'=>'OPENID', //客户 openid 'createtime'=>123456789, //会话创建时间,UNIX 时间戳 ), array ( 'openid'=>'OPENID', //客户 openid 'createtime'=>123456789, //会话创建时间,UNIX 时间戳 ), ) )
[ "获取指定客服的会话列表" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L2665-L2679
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.getKFSessionWait
public function getKFSessionWait(){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_get(self::API_BASE_URL_PREFIX.self::CUSTOM_SESSION_GET_WAIT .'access_token='.$this->access_token); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function getKFSessionWait(){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_get(self::API_BASE_URL_PREFIX.self::CUSTOM_SESSION_GET_WAIT .'access_token='.$this->access_token); if ($result) { $json = json_decode($result,true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "getKFSessionWait", "(", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "result", "=", "$", "this", "->", "http_get", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "CUSTOM_SESSION_GET_WAIT", ".", "'access_token='", ".", "$", "this", "->", "access_token", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
获取未接入会话列表 @param string $openid //用户openid @return boolean | array //成功返回json数组 array ( 'count' => 150 , //未接入会话数量 'waitcaselist' => array ( array ( 'openid'=>'OPENID', //客户 openid 'kf_account ' =>'', //指定接待的客服,为空则未指定 'createtime'=>123456789, //会话创建时间,UNIX 时间戳 ), array ( 'openid'=>'OPENID', //客户 openid 'kf_account ' =>'', //指定接待的客服,为空则未指定 'createtime'=>123456789, //会话创建时间,UNIX 时间戳 ) ) )
[ "获取未接入会话列表" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L2701-L2715
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.searchShakeAroundDevice
public function searchShakeAroundDevice($data){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_SEARCH . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function searchShakeAroundDevice($data){ if (!$this->access_token && !$this->checkAuth()) return false; $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_SEARCH . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "searchShakeAroundDevice", "(", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "SHAKEAROUND_DEVICE_SEARCH", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "log", "(", "$", "result", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
查询设备列表 [searchShakeAroundDevice 查询已有的设备ID、UUID、Major、Minor、激活状态、备注信息、关联门店、关联页面等信息。 可指定设备ID 或完整的UUID、Major、Minor 查询,也可批量拉取设备信息列表。] @param array $data $data 三种格式: ①查询指定设备时:$data = array( "device_identifiers" => array( array( "device_id" => 10100, "uuid" => "FDA50693-A4E2-4FB1-AFCF-C6EB07647825", "major" => 10001, "minor" => 10002 ) ) ); device_identifiers:指定的设备 device_id:设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先 uuid、major、minor:三个信息需填写完整,若填了设备编号,则可不填此信息 +------------------------------------------------------------------------------------------------------------- ②需要分页查询或者指定范围内的设备时: $data = array( "begin" => 0, "count" => 3 ); begin:设备列表的起始索引值 count:待查询的设备个数 +------------------------------------------------------------------------------------------------------------- ③当需要根据批次ID 查询时: $data = array( "apply_id" => 1231, "begin" => 0, "count" => 3 ); apply_id:批次ID +------------------------------------------------------------------------------------------------------------- @return boolean|mixed 正确迒回JSON 数据示例: 字段说明 { "data": { "devices": [ //指定的设备信息列表 { "comment": "", //设备的备注信息 "device_id": 10097, //设备编号 "major": 10001, "minor": 12102, "page_ids": "15369", //与此设备关联的页面ID 列表,用逗号隔开 "status": 1, //激活状态,0:未激活,1:已激活(但不活跃),2:活跃 "poi_id": 0, //门店ID "uuid": "FDA50693-A4E2-4FB1-AFCF-C6EB07647825" }, { "comment": "", //设备的备注信息 "device_id": 10098, //设备编号 "major": 10001, "minor": 12103, "page_ids": "15368", //与此设备关联的页面ID 列表,用逗号隔开 "status": 1, //激活状态,0:未激活,1:已激活(但不活跃),2:活跃 "poi_id": 0, //门店ID "uuid": "FDA50693-A4E2-4FB1-AFCF-C6EB07647825" } ], "total_count": 151 //商户名下的设备总量 }, "errcode": 0, "errmsg": "success." } @access public @author polo<[email protected]> @version 2015-3-25 下午1:45:42 @copyright Show More
[ "查询设备列表", "[", "searchShakeAroundDevice", "查询已有的设备ID、UUID、Major、Minor、激活状态、备注信息、关联门店、关联页面等信息。", "可指定设备ID", "或完整的UUID、Major、Minor", "查询,也可批量拉取设备信息列表。", "]" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L3545-L3559
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.bindLocationShakeAroundDevice
public function bindLocationShakeAroundDevice($device_id,$poi_id,$uuid='',$major=0,$minor=0){ if (!$this->access_token && !$this->checkAuth()) return false; if(!$device_id){ if(!$uuid || !$major || !$minor){ return false; } $device_identifier = array( 'uuid' => $uuid, 'major' => $major, 'minor' => $minor ); }else{ $device_identifier = array( 'device_id' => $device_id ); } $data = array( 'device_identifier' => $device_identifier, 'poi_id' => $poi_id ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDLOCATION . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; //这个可以更改为返回true } return false; }
php
public function bindLocationShakeAroundDevice($device_id,$poi_id,$uuid='',$major=0,$minor=0){ if (!$this->access_token && !$this->checkAuth()) return false; if(!$device_id){ if(!$uuid || !$major || !$minor){ return false; } $device_identifier = array( 'uuid' => $uuid, 'major' => $major, 'minor' => $minor ); }else{ $device_identifier = array( 'device_id' => $device_id ); } $data = array( 'device_identifier' => $device_identifier, 'poi_id' => $poi_id ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDLOCATION . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; //这个可以更改为返回true } return false; }
[ "public", "function", "bindLocationShakeAroundDevice", "(", "$", "device_id", ",", "$", "poi_id", ",", "$", "uuid", "=", "''", ",", "$", "major", "=", "0", ",", "$", "minor", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "if", "(", "!", "$", "device_id", ")", "{", "if", "(", "!", "$", "uuid", "||", "!", "$", "major", "||", "!", "$", "minor", ")", "{", "return", "false", ";", "}", "$", "device_identifier", "=", "array", "(", "'uuid'", "=>", "$", "uuid", ",", "'major'", "=>", "$", "major", ",", "'minor'", "=>", "$", "minor", ")", ";", "}", "else", "{", "$", "device_identifier", "=", "array", "(", "'device_id'", "=>", "$", "device_id", ")", ";", "}", "$", "data", "=", "array", "(", "'device_identifier'", "=>", "$", "device_identifier", ",", "'poi_id'", "=>", "$", "poi_id", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "SHAKEAROUND_DEVICE_BINDLOCATION", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "log", "(", "$", "result", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "//这个可以更改为返回true", "}", "return", "false", ";", "}" ]
[bindLocationShakeAroundDevice 配置设备与门店的关联关系] @param string $device_id 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先 @param int $poi_id 待关联的门店ID @param string $uuid UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息 @param int $major @param int $minor @return boolean|mixed 正确返回JSON 数据示例: { "data": { }, "errcode": 0, "errmsg": "success." } @access public @author polo<[email protected]> @version 2015-4-21 00:14:00 @copyright Show More
[ "[", "bindLocationShakeAroundDevice", "配置设备与门店的关联关系", "]" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L3581-L3613
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.bindPageShakeAroundDevice
public function bindPageShakeAroundDevice($device_id,$page_ids=array(),$bind=1,$append=1,$uuid='',$major=0,$minor=0){ if (!$this->access_token && !$this->checkAuth()) return false; if(!$device_id){ if(!$uuid || !$major || !$minor){ return false; } $device_identifier = array( 'uuid' => $uuid, 'major' => $major, 'minor' => $minor ); }else{ $device_identifier = array( 'device_id' => $device_id ); } $data = array( 'device_identifier' => $device_identifier, 'page_ids' => $page_ids, 'bind' => $bind, 'append' => $append ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDPAGE . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function bindPageShakeAroundDevice($device_id,$page_ids=array(),$bind=1,$append=1,$uuid='',$major=0,$minor=0){ if (!$this->access_token && !$this->checkAuth()) return false; if(!$device_id){ if(!$uuid || !$major || !$minor){ return false; } $device_identifier = array( 'uuid' => $uuid, 'major' => $major, 'minor' => $minor ); }else{ $device_identifier = array( 'device_id' => $device_id ); } $data = array( 'device_identifier' => $device_identifier, 'page_ids' => $page_ids, 'bind' => $bind, 'append' => $append ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDPAGE . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "bindPageShakeAroundDevice", "(", "$", "device_id", ",", "$", "page_ids", "=", "array", "(", ")", ",", "$", "bind", "=", "1", ",", "$", "append", "=", "1", ",", "$", "uuid", "=", "''", ",", "$", "major", "=", "0", ",", "$", "minor", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "if", "(", "!", "$", "device_id", ")", "{", "if", "(", "!", "$", "uuid", "||", "!", "$", "major", "||", "!", "$", "minor", ")", "{", "return", "false", ";", "}", "$", "device_identifier", "=", "array", "(", "'uuid'", "=>", "$", "uuid", ",", "'major'", "=>", "$", "major", ",", "'minor'", "=>", "$", "minor", ")", ";", "}", "else", "{", "$", "device_identifier", "=", "array", "(", "'device_id'", "=>", "$", "device_id", ")", ";", "}", "$", "data", "=", "array", "(", "'device_identifier'", "=>", "$", "device_identifier", ",", "'page_ids'", "=>", "$", "page_ids", ",", "'bind'", "=>", "$", "bind", ",", "'append'", "=>", "$", "append", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "SHAKEAROUND_DEVICE_BINDPAGE", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "log", "(", "$", "result", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
[bindPageShakeAroundDevice 配置设备与页面的关联关系。 支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。 配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。 若设备配置多个页面,则随机出现页面信息] @param string $device_id 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先 @param array $page_ids 待关联的页面列表 @param number $bind 关联操作标志位, 0 为解除关联关系,1 为建立关联关系 @param number $append 新增操作标志位, 0 为覆盖,1 为新增 @param string $uuid UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息 @param int $major @param int $minor @return boolean|mixed 正确返回JSON 数据示例: { "data": { }, "errcode": 0, "errmsg": "success." } @access public @author polo<[email protected]> @version 2015-4-21 00:31:00 @copyright Show More
[ "[", "bindPageShakeAroundDevice", "配置设备与页面的关联关系。", "支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。", "配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。", "若设备配置多个页面,则随机出现页面信息", "]" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L3640-L3674
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.addShakeAroundPage
public function addShakeAroundPage($title,$description,$icon_url,$page_url,$comment=''){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( "title" => $title, "description" => $description, "icon_url" => $icon_url, "page_url" => $page_url, "comment" => $comment ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_ADD . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function addShakeAroundPage($title,$description,$icon_url,$page_url,$comment=''){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( "title" => $title, "description" => $description, "icon_url" => $icon_url, "page_url" => $page_url, "comment" => $comment ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_ADD . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "addShakeAroundPage", "(", "$", "title", ",", "$", "description", ",", "$", "icon_url", ",", "$", "page_url", ",", "$", "comment", "=", "''", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "data", "=", "array", "(", "\"title\"", "=>", "$", "title", ",", "\"description\"", "=>", "$", "description", ",", "\"icon_url\"", "=>", "$", "icon_url", ",", "\"page_url\"", "=>", "$", "page_url", ",", "\"comment\"", "=>", "$", "comment", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "SHAKEAROUND_PAGE_ADD", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "log", "(", "$", "result", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
[addShakeAroundPage 增加摇一摇出来的页面信息,包括在摇一摇页面出现的主标题、副标题、图片和点击进去的超链接。] @param string $title 在摇一摇页面展示的主标题,不超过6 个字 @param string $description 在摇一摇页面展示的副标题,不超过7 个字 @param sting $icon_url 在摇一摇页面展示的图片, 格式限定为:jpg,jpeg,png,gif; 建议120*120 , 限制不超过200*200 @param string $page_url 跳转链接 @param string $comment 页面的备注信息,不超过15 个字,可不填 @return boolean|mixed 正确返回JSON 数据示例: { "data": { "page_id": 28840 //新增页面的页面id } "errcode": 0, "errmsg": "success." } @access public @author polo<[email protected]> @version 2015-3-25 下午2:57:09 @copyright Show More
[ "[", "addShakeAroundPage", "增加摇一摇出来的页面信息,包括在摇一摇页面出现的主标题、副标题、图片和点击进去的超链接。", "]" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L3729-L3750
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.searchShakeAroundPage
public function searchShakeAroundPage($page_ids=array(),$begin=0,$count=1){ if (!$this->access_token && !$this->checkAuth()) return false; if(!empty($page_ids)){ $data = array( 'page_ids' => $page_ids ); }else{ $data = array( 'begin' => $begin, 'count' => $count ); } $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_SEARCH . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function searchShakeAroundPage($page_ids=array(),$begin=0,$count=1){ if (!$this->access_token && !$this->checkAuth()) return false; if(!empty($page_ids)){ $data = array( 'page_ids' => $page_ids ); }else{ $data = array( 'begin' => $begin, 'count' => $count ); } $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_SEARCH . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "searchShakeAroundPage", "(", "$", "page_ids", "=", "array", "(", ")", ",", "$", "begin", "=", "0", ",", "$", "count", "=", "1", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "if", "(", "!", "empty", "(", "$", "page_ids", ")", ")", "{", "$", "data", "=", "array", "(", "'page_ids'", "=>", "$", "page_ids", ")", ";", "}", "else", "{", "$", "data", "=", "array", "(", "'begin'", "=>", "$", "begin", ",", "'count'", "=>", "$", "count", ")", ";", "}", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "SHAKEAROUND_PAGE_SEARCH", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "log", "(", "$", "result", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
[searchShakeAroundPage 查询已有的页面,包括在摇一摇页面出现的主标题、副标题、图片和点击进去的超链接。 提供两种查询方式,①可指定页面ID 查询,②也可批量拉取页面列表。] @param array $page_ids @param int $begin @param int $count ①需要查询指定页面时: { "page_ids":[12345, 23456, 34567] } +------------------------------------------------------------------------------------------------------------- ②需要分页查询或者指定范围内的页面时: { "begin": 0, "count": 3 } +------------------------------------------------------------------------------------------------------------- @return boolean|mixed 正确返回JSON 数据示例: { "data": { "pages": [ { "comment": "just for test", "description": "test", "icon_url": "https://www.baidu.com/img/bd_logo1.png", "page_id": 28840, "page_url": "http://xw.qq.com/testapi1", "title": "测试1" }, { "comment": "just for test", "description": "test", "icon_url": "https://www.baidu.com/img/bd_logo1.png", "page_id": 28842, "page_url": "http://xw.qq.com/testapi2", "title": "测试2" } ], "total_count": 2 }, "errcode": 0, "errmsg": "success." } 字段说明: total_count 商户名下的页面总数 page_id 摇周边页面唯一ID title 在摇一摇页面展示的主标题 description 在摇一摇页面展示的副标题 icon_url 在摇一摇页面展示的图片 page_url 跳转链接 comment 页面的备注信息 @access public @author polo<[email protected]> @version 2015-3-25 下午3:12:17 @copyright Show More
[ "[", "searchShakeAroundPage", "查询已有的页面,包括在摇一摇页面出现的主标题、副标题、图片和点击进去的超链接。", "提供两种查询方式,①可指定页面ID", "查询,②也可批量拉取页面列表。", "]" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L3855-L3879
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.deleteShakeAroundPage
public function deleteShakeAroundPage($page_ids=array()){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( 'page_ids' => $page_ids ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_DELETE . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function deleteShakeAroundPage($page_ids=array()){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( 'page_ids' => $page_ids ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_DELETE . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "deleteShakeAroundPage", "(", "$", "page_ids", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "data", "=", "array", "(", "'page_ids'", "=>", "$", "page_ids", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "SHAKEAROUND_PAGE_DELETE", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "log", "(", "$", "result", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
[deleteShakeAroundPage 删除已有的页面,包括在摇一摇页面出现的主标题、副标题、图片和点击进去的超链接。 只有页面与设备没有关联关系时,才可被删除。] @param array $page_ids { "page_ids":[12345,23456,34567] } @return boolean|mixed 正确返回JSON 数据示例: { "data": { }, "errcode": 0, "errmsg": "success." } @access public @author polo<[email protected]> @version 2015-3-25 下午3:23:00 @copyright Show More
[ "[", "deleteShakeAroundPage", "删除已有的页面,包括在摇一摇页面出现的主标题、副标题、图片和点击进去的超链接。", "只有页面与设备没有关联关系时,才可被删除。", "]" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L3901-L3918
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.getShakeInfoShakeAroundUser
public function getShakeInfoShakeAroundUser($ticket){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array('ticket' => $ticket); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_USER_GETSHAKEINFO . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function getShakeInfoShakeAroundUser($ticket){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array('ticket' => $ticket); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_USER_GETSHAKEINFO . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "getShakeInfoShakeAroundUser", "(", "$", "ticket", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "data", "=", "array", "(", "'ticket'", "=>", "$", "ticket", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "SHAKEAROUND_USER_GETSHAKEINFO", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "log", "(", "$", "result", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
[getShakeInfoShakeAroundUser 获取设备信息,包括UUID、major、minor,以及距离、openID 等信息。] @param string $ticket 摇周边业务的ticket,可在摇到的URL 中得到,ticket生效时间为30 分钟 @return boolean|mixed 正确返回JSON 数据示例: { "data": { "page_id ": 14211, "beacon_info": { "distance": 55.00620700469034, "major": 10001, "minor": 19007, "uuid": "FDA50693-A4E2-4FB1-AFCF-C6EB07647825" }, "openid": "oVDmXjp7y8aG2AlBuRpMZTb1-cmA" }, "errcode": 0, "errmsg": "success." } 字段说明: beacon_info 设备信息,包括UUID、major、minor,以及距离 UUID、major、minor UUID、major、minor distance Beacon 信号与手机的距离 page_id 摇周边页面唯一ID openid 商户AppID 下用户的唯一标识 poi_id 门店ID,有的话则返回,没有的话不会在JSON 格式内 @access public @author polo<[email protected]> @version 2015-3-25 下午3:28:20 @copyright Show More
[ "[", "getShakeInfoShakeAroundUser", "获取设备信息,包括UUID、major、minor,以及距离、openID", "等信息。", "]" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L3951-L3966
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.deviceShakeAroundStatistics
public function deviceShakeAroundStatistics($device_id,$begin_date,$end_date,$uuid='',$major=0,$minor=0){ if (!$this->access_token && !$this->checkAuth()) return false; if(!$device_id){ if(!$uuid || !$major || !$minor){ return false; } $device_identifier = array( 'uuid' => $uuid, 'major' => $major, 'minor' => $minor ); }else{ $device_identifier = array( 'device_id' => $device_id ); } $data = array( 'device_identifier' => $device_identifier, 'begin_date' => $begin_date, 'end_date' => $end_date ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_STATISTICS_DEVICE . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function deviceShakeAroundStatistics($device_id,$begin_date,$end_date,$uuid='',$major=0,$minor=0){ if (!$this->access_token && !$this->checkAuth()) return false; if(!$device_id){ if(!$uuid || !$major || !$minor){ return false; } $device_identifier = array( 'uuid' => $uuid, 'major' => $major, 'minor' => $minor ); }else{ $device_identifier = array( 'device_id' => $device_id ); } $data = array( 'device_identifier' => $device_identifier, 'begin_date' => $begin_date, 'end_date' => $end_date ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_STATISTICS_DEVICE . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "deviceShakeAroundStatistics", "(", "$", "device_id", ",", "$", "begin_date", ",", "$", "end_date", ",", "$", "uuid", "=", "''", ",", "$", "major", "=", "0", ",", "$", "minor", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "if", "(", "!", "$", "device_id", ")", "{", "if", "(", "!", "$", "uuid", "||", "!", "$", "major", "||", "!", "$", "minor", ")", "{", "return", "false", ";", "}", "$", "device_identifier", "=", "array", "(", "'uuid'", "=>", "$", "uuid", ",", "'major'", "=>", "$", "major", ",", "'minor'", "=>", "$", "minor", ")", ";", "}", "else", "{", "$", "device_identifier", "=", "array", "(", "'device_id'", "=>", "$", "device_id", ")", ";", "}", "$", "data", "=", "array", "(", "'device_identifier'", "=>", "$", "device_identifier", ",", "'begin_date'", "=>", "$", "begin_date", ",", "'end_date'", "=>", "$", "end_date", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "SHAKEAROUND_STATISTICS_DEVICE", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "log", "(", "$", "result", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
[deviceShakeAroundStatistics 以设备为维度的数据统计接口。 查询单个设备进行摇周边操作的人数、次数,点击摇周边消息的人数、次数;查询的最长时间跨度为30天。] @param int $device_id 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一 @param int $begin_date 起始日期时间戳,最长时间跨度为30 天 @param int $end_date 结束日期时间戳,最长时间跨度为30 天 @param string $uuid UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一 @param int $major @param int $minor @return boolean|mixed 正确返回JSON 数据示例: { "data": [ { "click_pv": 0, "click_uv": 0, "ftime": 1425052800, "shake_pv": 0, "shake_uv": 0 }, { "click_pv": 0, "click_uv": 0, "ftime": 1425139200, "shake_pv": 0, "shake_uv": 0 } ], "errcode": 0, "errmsg": "success." } 字段说明: ftime 当天0 点对应的时间戳 click_pv 点击摇周边消息的次数 click_uv 点击摇周边消息的人数 shake_pv 摇周边的次数 shake_uv 摇周边的人数 @access public @author polo<[email protected]> @version 2015-4-21 00:39:00 @copyright Show More
[ "[", "deviceShakeAroundStatistics", "以设备为维度的数据统计接口。", "查询单个设备进行摇周边操作的人数、次数,点击摇周边消息的人数、次数;查询的最长时间跨度为30天。", "]" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L4010-L4043
sfnt/wechat-php-sdk
src/Wechat.php
Wechat.pageShakeAroundStatistics
public function pageShakeAroundStatistics($page_id,$begin_date,$end_date){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( 'page_id' => $page_id, 'begin_date' => $begin_date, 'end_date' => $end_date ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_STATISTICS_DEVICE . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
php
public function pageShakeAroundStatistics($page_id,$begin_date,$end_date){ if (!$this->access_token && !$this->checkAuth()) return false; $data = array( 'page_id' => $page_id, 'begin_date' => $begin_date, 'end_date' => $end_date ); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_STATISTICS_DEVICE . 'access_token=' . $this->access_token, self::json_encode($data)); $this->log($result); if ($result) { $json = json_decode($result, true); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false; } return $json; } return false; }
[ "public", "function", "pageShakeAroundStatistics", "(", "$", "page_id", ",", "$", "begin_date", ",", "$", "end_date", ")", "{", "if", "(", "!", "$", "this", "->", "access_token", "&&", "!", "$", "this", "->", "checkAuth", "(", ")", ")", "return", "false", ";", "$", "data", "=", "array", "(", "'page_id'", "=>", "$", "page_id", ",", "'begin_date'", "=>", "$", "begin_date", ",", "'end_date'", "=>", "$", "end_date", ")", ";", "$", "result", "=", "$", "this", "->", "http_post", "(", "self", "::", "API_BASE_URL_PREFIX", ".", "self", "::", "SHAKEAROUND_STATISTICS_DEVICE", ".", "'access_token='", ".", "$", "this", "->", "access_token", ",", "self", "::", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "log", "(", "$", "result", ")", ";", "if", "(", "$", "result", ")", "{", "$", "json", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "!", "$", "json", "||", "!", "empty", "(", "$", "json", "[", "'errcode'", "]", ")", ")", "{", "$", "this", "->", "errCode", "=", "$", "json", "[", "'errcode'", "]", ";", "$", "this", "->", "errMsg", "=", "$", "json", "[", "'errmsg'", "]", ";", "return", "false", ";", "}", "return", "$", "json", ";", "}", "return", "false", ";", "}" ]
[pageShakeAroundStatistics 以页面为维度的数据统计接口。 查询单个页面通过摇周边摇出来的人数、次数,点击摇周边页面的人数、次数;查询的最长时间跨度为30天。] @param int $page_id 指定页面的ID @param int $begin_date 起始日期时间戳,最长时间跨度为30 天 @param int $end_date 结束日期时间戳,最长时间跨度为30 天 @return boolean|mixed 正确返回JSON 数据示例: { "data": [ { "click_pv": 0, "click_uv": 0, "ftime": 1425052800, "shake_pv": 0, "shake_uv": 0 }, { "click_pv": 0, "click_uv": 0, "ftime": 1425139200, "shake_pv": 0, "shake_uv": 0 } ], "errcode": 0, "errmsg": "success." } 字段说明: ftime 当天0 点对应的时间戳 click_pv 点击摇周边消息的次数 click_uv 点击摇周边消息的人数 shake_pv 摇周边的次数 shake_uv 摇周边的人数 @author binsee<[email protected]> @version 2015-4-21 00:43:00
[ "[", "pageShakeAroundStatistics", "以页面为维度的数据统计接口。", "查询单个页面通过摇周边摇出来的人数、次数,点击摇周边页面的人数、次数;查询的最长时间跨度为30天。", "]" ]
train
https://github.com/sfnt/wechat-php-sdk/blob/d14b8511f96cfcf0da5f413b446e69943cc3ea90/src/Wechat.php#L4083-L4102