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
mihai-stancu/serializer
Serializer/Normalizer/TypehintNormalizer.php
TypehintNormalizer.normalize
public function normalize($object, $format = null, array $context = array()) { $data = parent::normalize($object, $format, $context); if (!is_array($data)) { return $data; } return array_merge($this->getHintFromObject($object), $data); }
php
public function normalize($object, $format = null, array $context = array()) { $data = parent::normalize($object, $format, $context); if (!is_array($data)) { return $data; } return array_merge($this->getHintFromObject($object), $data); }
[ "public", "function", "normalize", "(", "$", "object", ",", "$", "format", "=", "null", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "$", "data", "=", "parent", "::", "normalize", "(", "$", "object", ",", "$", "format", ",", "$", "context", ")", ";", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", "$", "data", ";", "}", "return", "array_merge", "(", "$", "this", "->", "getHintFromObject", "(", "$", "object", ")", ",", "$", "data", ")", ";", "}" ]
@param object $object @param string $format @param array $context @return array
[ "@param", "object", "$object", "@param", "string", "$format", "@param", "array", "$context" ]
train
https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/TypehintNormalizer.php#L55-L64
mihai-stancu/serializer
Serializer/Normalizer/TypehintNormalizer.php
TypehintNormalizer.supportsNormalization
public function supportsNormalization($data, $format = null) { if (is_object($data)) { return parent::supportsNormalization($data, $format); } return false; }
php
public function supportsNormalization($data, $format = null) { if (is_object($data)) { return parent::supportsNormalization($data, $format); } return false; }
[ "public", "function", "supportsNormalization", "(", "$", "data", ",", "$", "format", "=", "null", ")", "{", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "return", "parent", "::", "supportsNormalization", "(", "$", "data", ",", "$", "format", ")", ";", "}", "return", "false", ";", "}" ]
@param mixed $data @param string $format @return bool
[ "@param", "mixed", "$data", "@param", "string", "$format" ]
train
https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/TypehintNormalizer.php#L72-L79
mihai-stancu/serializer
Serializer/Normalizer/TypehintNormalizer.php
TypehintNormalizer.denormalize
public function denormalize($data, $class, $format = null, array $context = array()) { if (!($_class = $this->getClassFromArray($data))) { return parent::denormalize($data, $class, $format, $context); } $class = $_class; return parent::denormalize($data, $class, $format, $context); }
php
public function denormalize($data, $class, $format = null, array $context = array()) { if (!($_class = $this->getClassFromArray($data))) { return parent::denormalize($data, $class, $format, $context); } $class = $_class; return parent::denormalize($data, $class, $format, $context); }
[ "public", "function", "denormalize", "(", "$", "data", ",", "$", "class", ",", "$", "format", "=", "null", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "if", "(", "!", "(", "$", "_class", "=", "$", "this", "->", "getClassFromArray", "(", "$", "data", ")", ")", ")", "{", "return", "parent", "::", "denormalize", "(", "$", "data", ",", "$", "class", ",", "$", "format", ",", "$", "context", ")", ";", "}", "$", "class", "=", "$", "_class", ";", "return", "parent", "::", "denormalize", "(", "$", "data", ",", "$", "class", ",", "$", "format", ",", "$", "context", ")", ";", "}" ]
@param array $data @param string $class @param string $format @param array $context @return object
[ "@param", "array", "$data", "@param", "string", "$class", "@param", "string", "$format", "@param", "array", "$context" ]
train
https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/TypehintNormalizer.php#L89-L98
mihai-stancu/serializer
Serializer/Normalizer/TypehintNormalizer.php
TypehintNormalizer.denormalizeProperty
protected function denormalizeProperty($data, $class, $name, $format = null, array $context = array()) { if (!($_class = $this->getClassFromArray($data))) { return parent::denormalizeProperty($data, $class, $name, $format, $context); } $class = $_class; if (!$this->serializer instanceof DenormalizerInterface) { $message = 'Cannot denormalize attribute "%s" because injected serializer is not a denormalizer'; throw new RuntimeException(sprintf($message, $name)); } return $this->serializer->denormalize($data, $class, $format, $context); }
php
protected function denormalizeProperty($data, $class, $name, $format = null, array $context = array()) { if (!($_class = $this->getClassFromArray($data))) { return parent::denormalizeProperty($data, $class, $name, $format, $context); } $class = $_class; if (!$this->serializer instanceof DenormalizerInterface) { $message = 'Cannot denormalize attribute "%s" because injected serializer is not a denormalizer'; throw new RuntimeException(sprintf($message, $name)); } return $this->serializer->denormalize($data, $class, $format, $context); }
[ "protected", "function", "denormalizeProperty", "(", "$", "data", ",", "$", "class", ",", "$", "name", ",", "$", "format", "=", "null", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "if", "(", "!", "(", "$", "_class", "=", "$", "this", "->", "getClassFromArray", "(", "$", "data", ")", ")", ")", "{", "return", "parent", "::", "denormalizeProperty", "(", "$", "data", ",", "$", "class", ",", "$", "name", ",", "$", "format", ",", "$", "context", ")", ";", "}", "$", "class", "=", "$", "_class", ";", "if", "(", "!", "$", "this", "->", "serializer", "instanceof", "DenormalizerInterface", ")", "{", "$", "message", "=", "'Cannot denormalize attribute \"%s\" because injected serializer is not a denormalizer'", ";", "throw", "new", "RuntimeException", "(", "sprintf", "(", "$", "message", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "serializer", "->", "denormalize", "(", "$", "data", ",", "$", "class", ",", "$", "format", ",", "$", "context", ")", ";", "}" ]
@param mixed $data @param string $class @param string $name @param string $format @param array $context @throws RuntimeException @return mixed|object
[ "@param", "mixed", "$data", "@param", "string", "$class", "@param", "string", "$name", "@param", "string", "$format", "@param", "array", "$context" ]
train
https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/TypehintNormalizer.php#L111-L124
mihai-stancu/serializer
Serializer/Normalizer/TypehintNormalizer.php
TypehintNormalizer.supportsDenormalization
public function supportsDenormalization($data, $type, $format = null) { if (!($class = $this->getClassFromArray($data))) { return parent::supportsDenormalization($data, $type ?: $class, $format); } return true; }
php
public function supportsDenormalization($data, $type, $format = null) { if (!($class = $this->getClassFromArray($data))) { return parent::supportsDenormalization($data, $type ?: $class, $format); } return true; }
[ "public", "function", "supportsDenormalization", "(", "$", "data", ",", "$", "type", ",", "$", "format", "=", "null", ")", "{", "if", "(", "!", "(", "$", "class", "=", "$", "this", "->", "getClassFromArray", "(", "$", "data", ")", ")", ")", "{", "return", "parent", "::", "supportsDenormalization", "(", "$", "data", ",", "$", "type", "?", ":", "$", "class", ",", "$", "format", ")", ";", "}", "return", "true", ";", "}" ]
@param array $data @param string $type @param null $format @return bool
[ "@param", "array", "$data", "@param", "string", "$type", "@param", "null", "$format" ]
train
https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/TypehintNormalizer.php#L133-L140
mihai-stancu/serializer
Serializer/Normalizer/TypehintNormalizer.php
TypehintNormalizer.getClassFromArray
protected function getClassFromArray($data) { if (!is_array($data)) { return; } if (isset($data['@type']) and $type = $data['@type'] and isset($this->types[$type])) { $class = $this->types[$type]; } if (isset($data['@class'])) { $class = $data['@class']; } if (isset($class) and class_exists($class)) { return $class; } }
php
protected function getClassFromArray($data) { if (!is_array($data)) { return; } if (isset($data['@type']) and $type = $data['@type'] and isset($this->types[$type])) { $class = $this->types[$type]; } if (isset($data['@class'])) { $class = $data['@class']; } if (isset($class) and class_exists($class)) { return $class; } }
[ "protected", "function", "getClassFromArray", "(", "$", "data", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'@type'", "]", ")", "and", "$", "type", "=", "$", "data", "[", "'@type'", "]", "and", "isset", "(", "$", "this", "->", "types", "[", "$", "type", "]", ")", ")", "{", "$", "class", "=", "$", "this", "->", "types", "[", "$", "type", "]", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'@class'", "]", ")", ")", "{", "$", "class", "=", "$", "data", "[", "'@class'", "]", ";", "}", "if", "(", "isset", "(", "$", "class", ")", "and", "class_exists", "(", "$", "class", ")", ")", "{", "return", "$", "class", ";", "}", "}" ]
@param mixed $data @return string
[ "@param", "mixed", "$data" ]
train
https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/TypehintNormalizer.php#L147-L164
mihai-stancu/serializer
Serializer/Normalizer/TypehintNormalizer.php
TypehintNormalizer.getHintFromObject
protected function getHintFromObject($object) { if (!is_object($object)) { return array(); } $class = get_class($object); $type = array_search($class, $this->types); if ($type) { return array('@type' => $type); } return array('@class' => $class); }
php
protected function getHintFromObject($object) { if (!is_object($object)) { return array(); } $class = get_class($object); $type = array_search($class, $this->types); if ($type) { return array('@type' => $type); } return array('@class' => $class); }
[ "protected", "function", "getHintFromObject", "(", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "class", "=", "get_class", "(", "$", "object", ")", ";", "$", "type", "=", "array_search", "(", "$", "class", ",", "$", "this", "->", "types", ")", ";", "if", "(", "$", "type", ")", "{", "return", "array", "(", "'@type'", "=>", "$", "type", ")", ";", "}", "return", "array", "(", "'@class'", "=>", "$", "class", ")", ";", "}" ]
@param object $object @return array
[ "@param", "object", "$object" ]
train
https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/TypehintNormalizer.php#L171-L185
ClanCats/Core
src/classes/CCView/Builder.php
CCView_Builder.compile
public static function compile( $builder, $view_file ) { if ( !isset( static::$_view_builders[$builder] ) ) { throw new CCException( "CCView_Builder - view builder '".$builder."' is not registerd." ); } $builder = static::$_view_builders[$builder]; if ( !class_exists( $builder ) ) { throw new CCException( "CCView_Builder - invalid view builder '".$builder."'." ); } $builder = new $builder( CCFile::read( $view_file ) ); return $builder->compile(); }
php
public static function compile( $builder, $view_file ) { if ( !isset( static::$_view_builders[$builder] ) ) { throw new CCException( "CCView_Builder - view builder '".$builder."' is not registerd." ); } $builder = static::$_view_builders[$builder]; if ( !class_exists( $builder ) ) { throw new CCException( "CCView_Builder - invalid view builder '".$builder."'." ); } $builder = new $builder( CCFile::read( $view_file ) ); return $builder->compile(); }
[ "public", "static", "function", "compile", "(", "$", "builder", ",", "$", "view_file", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "_view_builders", "[", "$", "builder", "]", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCView_Builder - view builder '\"", ".", "$", "builder", ".", "\"' is not registerd.\"", ")", ";", "}", "$", "builder", "=", "static", "::", "$", "_view_builders", "[", "$", "builder", "]", ";", "if", "(", "!", "class_exists", "(", "$", "builder", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCView_Builder - invalid view builder '\"", ".", "$", "builder", ".", "\"'.\"", ")", ";", "}", "$", "builder", "=", "new", "$", "builder", "(", "CCFile", "::", "read", "(", "$", "view_file", ")", ")", ";", "return", "$", "builder", "->", "compile", "(", ")", ";", "}" ]
Compile the view @param string $builder @param string $view_file
[ "Compile", "the", "view" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView/Builder.php#L41-L57
haldayne/boost
src/MapOfNumerics.php
MapOfNumerics.increment
public function increment($key, $delta = 1) { if ($this->has($key)) { $this->set( $key, $this->get($key) + $delta ); } else { $this->set($key, $delta); } return $this; }
php
public function increment($key, $delta = 1) { if ($this->has($key)) { $this->set( $key, $this->get($key) + $delta ); } else { $this->set($key, $delta); } return $this; }
[ "public", "function", "increment", "(", "$", "key", ",", "$", "delta", "=", "1", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "this", "->", "get", "(", "$", "key", ")", "+", "$", "delta", ")", ";", "}", "else", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "delta", ")", ";", "}", "return", "$", "this", ";", "}" ]
Increment the value stored at the given key by the given delta. @return $this @since 1.0.3 @api
[ "Increment", "the", "value", "stored", "at", "the", "given", "key", "by", "the", "given", "delta", "." ]
train
https://github.com/haldayne/boost/blob/d18cc398557e23f9c316ea7fb40b90f84cc53650/src/MapOfNumerics.php#L134-L146
yuncms/framework
src/models/Volume.php
Volume.getSettingsModel
public function getSettingsModel() { /** @var FilesystemAdapter $volumeClass */ $volumeClass = $this->className; /** @var VolumeSettingsModel $model */ $model = $volumeClass::getSettingsModel(); $model->setVolume($this); if ($this->configuration) { $model->setAttributes($this->configuration->toArray(), false); } return $model; }
php
public function getSettingsModel() { /** @var FilesystemAdapter $volumeClass */ $volumeClass = $this->className; /** @var VolumeSettingsModel $model */ $model = $volumeClass::getSettingsModel(); $model->setVolume($this); if ($this->configuration) { $model->setAttributes($this->configuration->toArray(), false); } return $model; }
[ "public", "function", "getSettingsModel", "(", ")", "{", "/** @var FilesystemAdapter $volumeClass */", "$", "volumeClass", "=", "$", "this", "->", "className", ";", "/** @var VolumeSettingsModel $model */", "$", "model", "=", "$", "volumeClass", "::", "getSettingsModel", "(", ")", ";", "$", "model", "->", "setVolume", "(", "$", "this", ")", ";", "if", "(", "$", "this", "->", "configuration", ")", "{", "$", "model", "->", "setAttributes", "(", "$", "this", "->", "configuration", "->", "toArray", "(", ")", ",", "false", ")", ";", "}", "return", "$", "model", ";", "}" ]
获取渠道设置模型 @return VolumeSettingsModel
[ "获取渠道设置模型" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/models/Volume.php#L109-L120
spiral-modules/scaffolder
source/Scaffolder/Declarations/MigrationDeclaration.php
MigrationDeclaration.declareCreation
public function declareCreation(string $table, array $columns) { $source = $this->method('up')->getSource(); $source->addLine("\$this->table('{$table}')"); foreach ($columns as $name => $type) { $source->addLine(" ->addColumn('{$name}', '{$type}')"); } $source->addLine(" ->create();"); $this->method('down')->getSource()->addString("\$this->table('{$table}')->drop();"); }
php
public function declareCreation(string $table, array $columns) { $source = $this->method('up')->getSource(); $source->addLine("\$this->table('{$table}')"); foreach ($columns as $name => $type) { $source->addLine(" ->addColumn('{$name}', '{$type}')"); } $source->addLine(" ->create();"); $this->method('down')->getSource()->addString("\$this->table('{$table}')->drop();"); }
[ "public", "function", "declareCreation", "(", "string", "$", "table", ",", "array", "$", "columns", ")", "{", "$", "source", "=", "$", "this", "->", "method", "(", "'up'", ")", "->", "getSource", "(", ")", ";", "$", "source", "->", "addLine", "(", "\"\\$this->table('{$table}')\"", ")", ";", "foreach", "(", "$", "columns", "as", "$", "name", "=>", "$", "type", ")", "{", "$", "source", "->", "addLine", "(", "\" ->addColumn('{$name}', '{$type}')\"", ")", ";", "}", "$", "source", "->", "addLine", "(", "\" ->create();\"", ")", ";", "$", "this", "->", "method", "(", "'down'", ")", "->", "getSource", "(", ")", "->", "addString", "(", "\"\\$this->table('{$table}')->drop();\"", ")", ";", "}" ]
Declare table creation with specific set of columns @param string $table @param array $columns
[ "Declare", "table", "creation", "with", "specific", "set", "of", "columns" ]
train
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Declarations/MigrationDeclaration.php#L46-L58
spiral-modules/scaffolder
source/Scaffolder/Declarations/MigrationDeclaration.php
MigrationDeclaration.declareStructure
private function declareStructure() { $up = $this->method('up')->setAccess(MethodDeclaration::ACCESS_PUBLIC); $down = $this->method('down')->setAccess(MethodDeclaration::ACCESS_PUBLIC); $up->setComment('Create tables, add columns or insert data here'); $down->setComment('Drop created, columns and etc here'); }
php
private function declareStructure() { $up = $this->method('up')->setAccess(MethodDeclaration::ACCESS_PUBLIC); $down = $this->method('down')->setAccess(MethodDeclaration::ACCESS_PUBLIC); $up->setComment('Create tables, add columns or insert data here'); $down->setComment('Drop created, columns and etc here'); }
[ "private", "function", "declareStructure", "(", ")", "{", "$", "up", "=", "$", "this", "->", "method", "(", "'up'", ")", "->", "setAccess", "(", "MethodDeclaration", "::", "ACCESS_PUBLIC", ")", ";", "$", "down", "=", "$", "this", "->", "method", "(", "'down'", ")", "->", "setAccess", "(", "MethodDeclaration", "::", "ACCESS_PUBLIC", ")", ";", "$", "up", "->", "setComment", "(", "'Create tables, add columns or insert data here'", ")", ";", "$", "down", "->", "setComment", "(", "'Drop created, columns and etc here'", ")", ";", "}" ]
Declare default __invoke method body.
[ "Declare", "default", "__invoke", "method", "body", "." ]
train
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Declarations/MigrationDeclaration.php#L63-L70
yuncms/framework
src/actions/UploadAction.php
UploadAction.uploadMore
private function uploadMore(array $files) { $res = []; foreach ($files as $file) { $result = $this->uploadOne($file); $res[] = $result; } return $res; }
php
private function uploadMore(array $files) { $res = []; foreach ($files as $file) { $result = $this->uploadOne($file); $res[] = $result; } return $res; }
[ "private", "function", "uploadMore", "(", "array", "$", "files", ")", "{", "$", "res", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "result", "=", "$", "this", "->", "uploadOne", "(", "$", "file", ")", ";", "$", "res", "[", "]", "=", "$", "result", ";", "}", "return", "$", "res", ";", "}" ]
批量上传 @param array $files @return array @throws \yii\base\ErrorException
[ "批量上传" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/actions/UploadAction.php#L102-L110
yuncms/framework
src/actions/UploadAction.php
UploadAction.uploadOne
private function uploadOne(UploadedFile $file) { try { $validator = new FileValidator([$this->_config]); if ($validator->validate($file, $error)) { $fileInfo = $file->save(); $result = [ 'name' => Html::encode($fileInfo->filename), 'url' => $fileInfo->getUrl(), 'path' => $fileInfo->path, 'extension' => $file->extension, 'type' => $fileInfo->type, 'size' => $fileInfo->size ]; if ($this->onlyImage !== true) { $result['filename'] = $result['name']; } } else { $result = [ 'error' => $error ]; } } catch (Exception $e) { $result = [ 'error' => $e->getMessage() ]; } return $result; }
php
private function uploadOne(UploadedFile $file) { try { $validator = new FileValidator([$this->_config]); if ($validator->validate($file, $error)) { $fileInfo = $file->save(); $result = [ 'name' => Html::encode($fileInfo->filename), 'url' => $fileInfo->getUrl(), 'path' => $fileInfo->path, 'extension' => $file->extension, 'type' => $fileInfo->type, 'size' => $fileInfo->size ]; if ($this->onlyImage !== true) { $result['filename'] = $result['name']; } } else { $result = [ 'error' => $error ]; } } catch (Exception $e) { $result = [ 'error' => $e->getMessage() ]; } return $result; }
[ "private", "function", "uploadOne", "(", "UploadedFile", "$", "file", ")", "{", "try", "{", "$", "validator", "=", "new", "FileValidator", "(", "[", "$", "this", "->", "_config", "]", ")", ";", "if", "(", "$", "validator", "->", "validate", "(", "$", "file", ",", "$", "error", ")", ")", "{", "$", "fileInfo", "=", "$", "file", "->", "save", "(", ")", ";", "$", "result", "=", "[", "'name'", "=>", "Html", "::", "encode", "(", "$", "fileInfo", "->", "filename", ")", ",", "'url'", "=>", "$", "fileInfo", "->", "getUrl", "(", ")", ",", "'path'", "=>", "$", "fileInfo", "->", "path", ",", "'extension'", "=>", "$", "file", "->", "extension", ",", "'type'", "=>", "$", "fileInfo", "->", "type", ",", "'size'", "=>", "$", "fileInfo", "->", "size", "]", ";", "if", "(", "$", "this", "->", "onlyImage", "!==", "true", ")", "{", "$", "result", "[", "'filename'", "]", "=", "$", "result", "[", "'name'", "]", ";", "}", "}", "else", "{", "$", "result", "=", "[", "'error'", "=>", "$", "error", "]", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "result", "=", "[", "'error'", "=>", "$", "e", "->", "getMessage", "(", ")", "]", ";", "}", "return", "$", "result", ";", "}" ]
单文件上传 @param UploadedFile $file @return array|mixed @throws \yii\base\ErrorException
[ "单文件上传" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/actions/UploadAction.php#L118-L146
OpenClassrooms/ServiceProxy
src/Proxy/Factory/ProxyFactory.php
ProxyFactory.createProxy
public function createProxy($instance) { $proxyClassName = $this->generateProxy(get_class($instance)); /** @var ServiceProxyInterface $proxy */ $proxy = new $proxyClassName(); $proxy->setProxy_RealSubject($instance); return $proxy; }
php
public function createProxy($instance) { $proxyClassName = $this->generateProxy(get_class($instance)); /** @var ServiceProxyInterface $proxy */ $proxy = new $proxyClassName(); $proxy->setProxy_RealSubject($instance); return $proxy; }
[ "public", "function", "createProxy", "(", "$", "instance", ")", "{", "$", "proxyClassName", "=", "$", "this", "->", "generateProxy", "(", "get_class", "(", "$", "instance", ")", ")", ";", "/** @var ServiceProxyInterface $proxy */", "$", "proxy", "=", "new", "$", "proxyClassName", "(", ")", ";", "$", "proxy", "->", "setProxy_RealSubject", "(", "$", "instance", ")", ";", "return", "$", "proxy", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/OpenClassrooms/ServiceProxy/blob/31f9f8be8f064b4ca36873df83fc3833f53da438/src/Proxy/Factory/ProxyFactory.php#L37-L45
haldayne/boost
src/MapOfObjects.php
MapOfObjects.apply
public function apply($method, array $args = []) { $result = new Map; $this->walk(function ($object, $key) use ($method, $args, $result) { $result[$key] = call_user_func_array([$object, $method], $args); }); return $result; }
php
public function apply($method, array $args = []) { $result = new Map; $this->walk(function ($object, $key) use ($method, $args, $result) { $result[$key] = call_user_func_array([$object, $method], $args); }); return $result; }
[ "public", "function", "apply", "(", "$", "method", ",", "array", "$", "args", "=", "[", "]", ")", "{", "$", "result", "=", "new", "Map", ";", "$", "this", "->", "walk", "(", "function", "(", "$", "object", ",", "$", "key", ")", "use", "(", "$", "method", ",", "$", "args", ",", "$", "result", ")", "{", "$", "result", "[", "$", "key", "]", "=", "call_user_func_array", "(", "[", "$", "object", ",", "$", "method", "]", ",", "$", "args", ")", ";", "}", ")", ";", "return", "$", "result", ";", "}" ]
Call the given method on every object in the map, and return the results as a new map. @param string $method The method on each contained object to call. @param array|null $args The arguments to pass to the method. @return \Haldayne\Boost\Map @api
[ "Call", "the", "given", "method", "on", "every", "object", "in", "the", "map", "and", "return", "the", "results", "as", "a", "new", "map", "." ]
train
https://github.com/haldayne/boost/blob/d18cc398557e23f9c316ea7fb40b90f84cc53650/src/MapOfObjects.php#L18-L25
ufocoder/yii2-SyncSocial
src/actions/ConnectAction.php
ConnectAction.run
public function run( $service ) { return $this->redirectWithMessages( $this->synchronizer->connect( $service ), Yii::t( 'SyncSocial', 'Service was successfully connected' ), Yii::t( 'SyncSocial', 'Service could not be connected' ) ); }
php
public function run( $service ) { return $this->redirectWithMessages( $this->synchronizer->connect( $service ), Yii::t( 'SyncSocial', 'Service was successfully connected' ), Yii::t( 'SyncSocial', 'Service could not be connected' ) ); }
[ "public", "function", "run", "(", "$", "service", ")", "{", "return", "$", "this", "->", "redirectWithMessages", "(", "$", "this", "->", "synchronizer", "->", "connect", "(", "$", "service", ")", ",", "Yii", "::", "t", "(", "'SyncSocial'", ",", "'Service was successfully connected'", ")", ",", "Yii", "::", "t", "(", "'SyncSocial'", ",", "'Service could not be connected'", ")", ")", ";", "}" ]
@param $service @return \yii\web\Response
[ "@param", "$service" ]
train
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/actions/ConnectAction.php#L18-L26
JoshuaEstes/FeatureToggle
src/JoshuaEstes/Component/FeatureToggle/FeatureContainer.php
FeatureContainer.addFeature
public function addFeature(FeatureInterface $feature) { $this->features->set($feature->getKey(), $feature); return $this; }
php
public function addFeature(FeatureInterface $feature) { $this->features->set($feature->getKey(), $feature); return $this; }
[ "public", "function", "addFeature", "(", "FeatureInterface", "$", "feature", ")", "{", "$", "this", "->", "features", "->", "set", "(", "$", "feature", "->", "getKey", "(", ")", ",", "$", "feature", ")", ";", "return", "$", "this", ";", "}" ]
Add a feature to the container @param FeatureInterface @return FeatureBag
[ "Add", "a", "feature", "to", "the", "container" ]
train
https://github.com/JoshuaEstes/FeatureToggle/blob/d93b95b649acce80a6395d97cd165ba733971d84/src/JoshuaEstes/Component/FeatureToggle/FeatureContainer.php#L58-L63
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/DBALModel.php
DBALModel._delete
protected function _delete(array $criteria = array()) { if (!is_null($this->_table)) { $this->_affectedRows = $this->_db->delete($this->_table, $criteria); return $this->_affectedRows; } }
php
protected function _delete(array $criteria = array()) { if (!is_null($this->_table)) { $this->_affectedRows = $this->_db->delete($this->_table, $criteria); return $this->_affectedRows; } }
[ "protected", "function", "_delete", "(", "array", "$", "criteria", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "_table", ")", ")", "{", "$", "this", "->", "_affectedRows", "=", "$", "this", "->", "_db", "->", "delete", "(", "$", "this", "->", "_table", ",", "$", "criteria", ")", ";", "return", "$", "this", "->", "_affectedRows", ";", "}", "}" ]
@param array $criteria Criterios de la consulta DELETE adoptados en el WHERE @return int Filas afectadas
[ "@param", "array", "$criteria", "Criterios", "de", "la", "consulta", "DELETE", "adoptados", "en", "el", "WHERE" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/DBALModel.php#L106-L112
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/DBALModel.php
DBALModel._insert
protected function _insert(array $data = array()) { if (!is_null($this->_table)) { $this->_affectedRows = $this->_db->insert($this->_table, $data); if ($this->_affectedRows > 0) { $this->id = $this->_db->lastInsertId(); } return $this->_affectedRows; } }
php
protected function _insert(array $data = array()) { if (!is_null($this->_table)) { $this->_affectedRows = $this->_db->insert($this->_table, $data); if ($this->_affectedRows > 0) { $this->id = $this->_db->lastInsertId(); } return $this->_affectedRows; } }
[ "protected", "function", "_insert", "(", "array", "$", "data", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "_table", ")", ")", "{", "$", "this", "->", "_affectedRows", "=", "$", "this", "->", "_db", "->", "insert", "(", "$", "this", "->", "_table", ",", "$", "data", ")", ";", "if", "(", "$", "this", "->", "_affectedRows", ">", "0", ")", "{", "$", "this", "->", "id", "=", "$", "this", "->", "_db", "->", "lastInsertId", "(", ")", ";", "}", "return", "$", "this", "->", "_affectedRows", ";", "}", "}" ]
@param array $data Arreglo asociativo de los campos a insertar del registro @return int Filas afectadas
[ "@param", "array", "$data", "Arreglo", "asociativo", "de", "los", "campos", "a", "insertar", "del", "registro" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/DBALModel.php#L119-L128
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/DBALModel.php
DBALModel._join
protected function _join($table, $field_first, $field_second, $operator) { $join = ""; #If the parameters are array if ((is_array($table) && is_array($field_first)) && (is_array($field_second) && is_array($operator))) { #If the number of keys of the parameters are iquals if ((count($table) == count($field_first) && count($table) == count($field_second)) && count($table) == count($operator)) { for ($i = 0; $i < count($table); $i++) { $join .= " INNER JOIN $table[$i] ON $field_first[$i] $operator[$i] $field_second[$i] "; } } else { throw new Exception("Los parámetros no tienen el mismo número de elementos."); } } elseif (!is_array($table) || !is_array($field_first) || !is_array($field_second) || !is_array($operator)) { $join = " INNER JOIN $table ON $field_first $operator $field_second "; } else { throw new Exception("Los parámetros no son del mismo tipo"); } return $join; }
php
protected function _join($table, $field_first, $field_second, $operator) { $join = ""; #If the parameters are array if ((is_array($table) && is_array($field_first)) && (is_array($field_second) && is_array($operator))) { #If the number of keys of the parameters are iquals if ((count($table) == count($field_first) && count($table) == count($field_second)) && count($table) == count($operator)) { for ($i = 0; $i < count($table); $i++) { $join .= " INNER JOIN $table[$i] ON $field_first[$i] $operator[$i] $field_second[$i] "; } } else { throw new Exception("Los parámetros no tienen el mismo número de elementos."); } } elseif (!is_array($table) || !is_array($field_first) || !is_array($field_second) || !is_array($operator)) { $join = " INNER JOIN $table ON $field_first $operator $field_second "; } else { throw new Exception("Los parámetros no son del mismo tipo"); } return $join; }
[ "protected", "function", "_join", "(", "$", "table", ",", "$", "field_first", ",", "$", "field_second", ",", "$", "operator", ")", "{", "$", "join", "=", "\"\"", ";", "#If the parameters are array", "if", "(", "(", "is_array", "(", "$", "table", ")", "&&", "is_array", "(", "$", "field_first", ")", ")", "&&", "(", "is_array", "(", "$", "field_second", ")", "&&", "is_array", "(", "$", "operator", ")", ")", ")", "{", "#If the number of keys of the parameters are iquals", "if", "(", "(", "count", "(", "$", "table", ")", "==", "count", "(", "$", "field_first", ")", "&&", "count", "(", "$", "table", ")", "==", "count", "(", "$", "field_second", ")", ")", "&&", "count", "(", "$", "table", ")", "==", "count", "(", "$", "operator", ")", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "table", ")", ";", "$", "i", "++", ")", "{", "$", "join", ".=", "\" INNER JOIN $table[$i] ON $field_first[$i] $operator[$i] $field_second[$i] \"", ";", "}", "}", "else", "{", "throw", "new", "Exception", "(", "\"Los parámetros no tienen el mismo número de elementos.\");", "", "", "}", "}", "elseif", "(", "!", "is_array", "(", "$", "table", ")", "||", "!", "is_array", "(", "$", "field_first", ")", "||", "!", "is_array", "(", "$", "field_second", ")", "||", "!", "is_array", "(", "$", "operator", ")", ")", "{", "$", "join", "=", "\" INNER JOIN $table ON $field_first $operator $field_second \"", ";", "}", "else", "{", "throw", "new", "Exception", "(", "\"Los parámetros no son del mismo tipo\")", ";", "", "}", "return", "$", "join", ";", "}" ]
@param mixed $table Tabla(s) para el sentencia INNER JOIN @param mixed $field_first Primer(os) campo(s). Primer campo en la condición del INNER JOIN @param mixed $field_second Segundo(os) campo(s). Primer campo en la condición del INNER JOIN @param mixed $operator Operador(es) para el INNER JOIN. @return string Sentencia SQL INNER JOIN. @throws Exception
[ "@param", "mixed", "$table", "Tabla", "(", "s", ")", "para", "el", "sentencia", "INNER", "JOIN", "@param", "mixed", "$field_first", "Primer", "(", "os", ")", "campo", "(", "s", ")", ".", "Primer", "campo", "en", "la", "condición", "del", "INNER", "JOIN", "@param", "mixed", "$field_second", "Segundo", "(", "os", ")", "campo", "(", "s", ")", ".", "Primer", "campo", "en", "la", "condición", "del", "INNER", "JOIN", "@param", "mixed", "$operator", "Operador", "(", "es", ")", "para", "el", "INNER", "JOIN", "." ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/DBALModel.php#L139-L158
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/DBALModel.php
DBALModel._query
protected function _query($sql = "", array $criteria = array()) { try { // Preparar el SQL $this->_stmt = $this->_db->prepare($sql); // Agregar los parametros foreach ($criteria as $param => $value) { if (is_integer($param)) { $this->_stmt->bindValue(($param + 1), $value); } if (is_string($param)) { $this->_stmt->bindParam($param, $value); } } // Ejecutar el SQL $this->_stmt->execute(); } catch (DBALException $dbalException) { #throw $dbalException; } if (in_array($this->_stmt->errorCode(), array_keys($this->_errors))) { throw new Exception($this->_errors[$this->_stmt->errorCode()] . " SQL: $sql"); } return $this->_stmt; }
php
protected function _query($sql = "", array $criteria = array()) { try { // Preparar el SQL $this->_stmt = $this->_db->prepare($sql); // Agregar los parametros foreach ($criteria as $param => $value) { if (is_integer($param)) { $this->_stmt->bindValue(($param + 1), $value); } if (is_string($param)) { $this->_stmt->bindParam($param, $value); } } // Ejecutar el SQL $this->_stmt->execute(); } catch (DBALException $dbalException) { #throw $dbalException; } if (in_array($this->_stmt->errorCode(), array_keys($this->_errors))) { throw new Exception($this->_errors[$this->_stmt->errorCode()] . " SQL: $sql"); } return $this->_stmt; }
[ "protected", "function", "_query", "(", "$", "sql", "=", "\"\"", ",", "array", "$", "criteria", "=", "array", "(", ")", ")", "{", "try", "{", "// Preparar el SQL", "$", "this", "->", "_stmt", "=", "$", "this", "->", "_db", "->", "prepare", "(", "$", "sql", ")", ";", "// Agregar los parametros", "foreach", "(", "$", "criteria", "as", "$", "param", "=>", "$", "value", ")", "{", "if", "(", "is_integer", "(", "$", "param", ")", ")", "{", "$", "this", "->", "_stmt", "->", "bindValue", "(", "(", "$", "param", "+", "1", ")", ",", "$", "value", ")", ";", "}", "if", "(", "is_string", "(", "$", "param", ")", ")", "{", "$", "this", "->", "_stmt", "->", "bindParam", "(", "$", "param", ",", "$", "value", ")", ";", "}", "}", "// Ejecutar el SQL", "$", "this", "->", "_stmt", "->", "execute", "(", ")", ";", "}", "catch", "(", "DBALException", "$", "dbalException", ")", "{", "#throw $dbalException;", "}", "if", "(", "in_array", "(", "$", "this", "->", "_stmt", "->", "errorCode", "(", ")", ",", "array_keys", "(", "$", "this", "->", "_errors", ")", ")", ")", "{", "throw", "new", "Exception", "(", "$", "this", "->", "_errors", "[", "$", "this", "->", "_stmt", "->", "errorCode", "(", ")", "]", ".", "\" SQL: $sql\"", ")", ";", "}", "return", "$", "this", "->", "_stmt", ";", "}" ]
@param string $sql Consulta SQL a la base de datos @param array $criteria Criterios de la consulta SQL adoptados en el WHERE @return Statement Retorna el objeto de Doctrine Statement @throws DBALException Error de Doctrine @throws Exception Error en el SQL
[ "@param", "string", "$sql", "Consulta", "SQL", "a", "la", "base", "de", "datos", "@param", "array", "$criteria", "Criterios", "de", "la", "consulta", "SQL", "adoptados", "en", "el", "WHERE" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/DBALModel.php#L168-L192
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/DBALModel.php
DBALModel._select
protected function _select($sql = "", array $join = array(), $where = "", array $criteria = array()) { if ($this->_sql != $sql) $this->_sql = $sql; if (is_array($join)) { foreach ($join as $currentJoin) { if (is_array($currentJoin) && count($currentJoin) == 4) { $keys = array_keys($currentJoin); $this->_sql .= $this->_join($currentJoin[$keys[0]], $currentJoin[$keys[1]], $currentJoin[$keys[2]], $currentJoin[$keys[3]]); } elseif (is_string($currentJoin) && count($join) == 4) { $keys = array_keys($join); $this->_sql .= $this->_join($join[$keys[0]], $join[$keys[1]], $join[$keys[2]], $join[$keys[3]]); break; } } } elseif (empty($join)) { throw new Exception("Valores incorrectos del join. Array['table'], Array['field_first'], Array['field_second'], Array['operator']. Array[0], Array[1], Array[2], Array[3]."); } $stmt = $this->_query("$this->_sql $where", $criteria); $rows = $stmt->fetchAll(); return $rows; }
php
protected function _select($sql = "", array $join = array(), $where = "", array $criteria = array()) { if ($this->_sql != $sql) $this->_sql = $sql; if (is_array($join)) { foreach ($join as $currentJoin) { if (is_array($currentJoin) && count($currentJoin) == 4) { $keys = array_keys($currentJoin); $this->_sql .= $this->_join($currentJoin[$keys[0]], $currentJoin[$keys[1]], $currentJoin[$keys[2]], $currentJoin[$keys[3]]); } elseif (is_string($currentJoin) && count($join) == 4) { $keys = array_keys($join); $this->_sql .= $this->_join($join[$keys[0]], $join[$keys[1]], $join[$keys[2]], $join[$keys[3]]); break; } } } elseif (empty($join)) { throw new Exception("Valores incorrectos del join. Array['table'], Array['field_first'], Array['field_second'], Array['operator']. Array[0], Array[1], Array[2], Array[3]."); } $stmt = $this->_query("$this->_sql $where", $criteria); $rows = $stmt->fetchAll(); return $rows; }
[ "protected", "function", "_select", "(", "$", "sql", "=", "\"\"", ",", "array", "$", "join", "=", "array", "(", ")", ",", "$", "where", "=", "\"\"", ",", "array", "$", "criteria", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "_sql", "!=", "$", "sql", ")", "$", "this", "->", "_sql", "=", "$", "sql", ";", "if", "(", "is_array", "(", "$", "join", ")", ")", "{", "foreach", "(", "$", "join", "as", "$", "currentJoin", ")", "{", "if", "(", "is_array", "(", "$", "currentJoin", ")", "&&", "count", "(", "$", "currentJoin", ")", "==", "4", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "currentJoin", ")", ";", "$", "this", "->", "_sql", ".=", "$", "this", "->", "_join", "(", "$", "currentJoin", "[", "$", "keys", "[", "0", "]", "]", ",", "$", "currentJoin", "[", "$", "keys", "[", "1", "]", "]", ",", "$", "currentJoin", "[", "$", "keys", "[", "2", "]", "]", ",", "$", "currentJoin", "[", "$", "keys", "[", "3", "]", "]", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "currentJoin", ")", "&&", "count", "(", "$", "join", ")", "==", "4", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "join", ")", ";", "$", "this", "->", "_sql", ".=", "$", "this", "->", "_join", "(", "$", "join", "[", "$", "keys", "[", "0", "]", "]", ",", "$", "join", "[", "$", "keys", "[", "1", "]", "]", ",", "$", "join", "[", "$", "keys", "[", "2", "]", "]", ",", "$", "join", "[", "$", "keys", "[", "3", "]", "]", ")", ";", "break", ";", "}", "}", "}", "elseif", "(", "empty", "(", "$", "join", ")", ")", "{", "throw", "new", "Exception", "(", "\"Valores incorrectos del join. Array['table'], Array['field_first'], Array['field_second'], Array['operator']. Array[0], Array[1], Array[2], Array[3].\"", ")", ";", "}", "$", "stmt", "=", "$", "this", "->", "_query", "(", "\"$this->_sql $where\"", ",", "$", "criteria", ")", ";", "$", "rows", "=", "$", "stmt", "->", "fetchAll", "(", ")", ";", "return", "$", "rows", ";", "}" ]
@param string $sql Sentencia SQL SELECT básica @param array $join Arreglos de los parámetros del INNER JOIN @param string $where Sentencia SQL WHERE que identifica la condición de la consulta @param array $criteria Criterios de la consulta SELECT adoptados en el WHERE @return array $rows Arreglo asociativo de los registros @throws Exception Lanza una exception si los valores del INNER JOIN son incorrectos
[ "@param", "string", "$sql", "Sentencia", "SQL", "SELECT", "básica", "@param", "array", "$join", "Arreglos", "de", "los", "parámetros", "del", "INNER", "JOIN", "@param", "string", "$where", "Sentencia", "SQL", "WHERE", "que", "identifica", "la", "condición", "de", "la", "consulta", "@param", "array", "$criteria", "Criterios", "de", "la", "consulta", "SELECT", "adoptados", "en", "el", "WHERE" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/DBALModel.php#L203-L224
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/DBALModel.php
DBALModel._selectFields
protected function _selectFields(array $fields = array(), array $join = array(), $where = "", array $criteria = array()) { if (empty($fields)) { $fields = array('*'); } $this->_sql = "SELECT " . implode(',', $fields) . " FROM $this->_table"; return $this->_select($this->_sql, $join, $where, $criteria); }
php
protected function _selectFields(array $fields = array(), array $join = array(), $where = "", array $criteria = array()) { if (empty($fields)) { $fields = array('*'); } $this->_sql = "SELECT " . implode(',', $fields) . " FROM $this->_table"; return $this->_select($this->_sql, $join, $where, $criteria); }
[ "protected", "function", "_selectFields", "(", "array", "$", "fields", "=", "array", "(", ")", ",", "array", "$", "join", "=", "array", "(", ")", ",", "$", "where", "=", "\"\"", ",", "array", "$", "criteria", "=", "array", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "array", "(", "'*'", ")", ";", "}", "$", "this", "->", "_sql", "=", "\"SELECT \"", ".", "implode", "(", "','", ",", "$", "fields", ")", ".", "\" FROM $this->_table\"", ";", "return", "$", "this", "->", "_select", "(", "$", "this", "->", "_sql", ",", "$", "join", ",", "$", "where", ",", "$", "criteria", ")", ";", "}" ]
@param array $fields Arreglo de los campos del SELECT a consultar @param array $join Arreglos de los parámetros del INNER JOIN @param string $where Sentencia SQL WHERE que identifica la condición de la consulta @param array $criteria Criterios de la consulta SELECT adoptados en el WHERE @return array Arreglo asociativo de los registros @throws Exception Lanza una exception si los valores del INNER JOIN son incorrectos
[ "@param", "array", "$fields", "Arreglo", "de", "los", "campos", "del", "SELECT", "a", "consultar", "@param", "array", "$join", "Arreglos", "de", "los", "parámetros", "del", "INNER", "JOIN", "@param", "string", "$where", "Sentencia", "SQL", "WHERE", "que", "identifica", "la", "condición", "de", "la", "consulta", "@param", "array", "$criteria", "Criterios", "de", "la", "consulta", "SELECT", "adoptados", "en", "el", "WHERE" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/DBALModel.php#L235-L242
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/DBALModel.php
DBALModel._update
protected function _update(array $data = array(), array $criteria = array()) { if (!is_null($this->_table)) { $this->_affectedRows = $this->_db->update($this->_table, $data, $criteria); return $this->_affectedRows; } }
php
protected function _update(array $data = array(), array $criteria = array()) { if (!is_null($this->_table)) { $this->_affectedRows = $this->_db->update($this->_table, $data, $criteria); return $this->_affectedRows; } }
[ "protected", "function", "_update", "(", "array", "$", "data", "=", "array", "(", ")", ",", "array", "$", "criteria", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "_table", ")", ")", "{", "$", "this", "->", "_affectedRows", "=", "$", "this", "->", "_db", "->", "update", "(", "$", "this", "->", "_table", ",", "$", "data", ",", "$", "criteria", ")", ";", "return", "$", "this", "->", "_affectedRows", ";", "}", "}" ]
@param array $data Arreglo asociativo de los campos a actualizar del registro @param array $criteria Criterios de la consulta UPDATE adoptados en el WHERE @return int Filas afectadas
[ "@param", "array", "$data", "Arreglo", "asociativo", "de", "los", "campos", "a", "actualizar", "del", "registro", "@param", "array", "$criteria", "Criterios", "de", "la", "consulta", "UPDATE", "adoptados", "en", "el", "WHERE" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/DBALModel.php#L250-L256
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/DBALModel.php
DBALModel.getAll
public function getAll(array $fields = array(), array $join = array(), $where = "", array $criteria = array()) { if (!is_null($this->_table)) { if (empty($fields)) { $this->_sql = "SELECT * FROM $this->_table"; return $this->_select($this->_sql, $join, $where, $criteria); } else { return $this->_selectFields($fields, $join, $where, $criteria); } } }
php
public function getAll(array $fields = array(), array $join = array(), $where = "", array $criteria = array()) { if (!is_null($this->_table)) { if (empty($fields)) { $this->_sql = "SELECT * FROM $this->_table"; return $this->_select($this->_sql, $join, $where, $criteria); } else { return $this->_selectFields($fields, $join, $where, $criteria); } } }
[ "public", "function", "getAll", "(", "array", "$", "fields", "=", "array", "(", ")", ",", "array", "$", "join", "=", "array", "(", ")", ",", "$", "where", "=", "\"\"", ",", "array", "$", "criteria", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "_table", ")", ")", "{", "if", "(", "empty", "(", "$", "fields", ")", ")", "{", "$", "this", "->", "_sql", "=", "\"SELECT * FROM $this->_table\"", ";", "return", "$", "this", "->", "_select", "(", "$", "this", "->", "_sql", ",", "$", "join", ",", "$", "where", ",", "$", "criteria", ")", ";", "}", "else", "{", "return", "$", "this", "->", "_selectFields", "(", "$", "fields", ",", "$", "join", ",", "$", "where", ",", "$", "criteria", ")", ";", "}", "}", "}" ]
@param array $fields Arreglo de los campos del SELECT a consultar @param array $join Arreglos de los parámetros del INNER JOIN @param string $where Sentencia SQL WHERE que identifica la condición de la consulta @param array $criteria Criterios de la consulta SELECT adoptados en el WHERE @return array
[ "@param", "array", "$fields", "Arreglo", "de", "los", "campos", "del", "SELECT", "a", "consultar", "@param", "array", "$join", "Arreglos", "de", "los", "parámetros", "del", "INNER", "JOIN", "@param", "string", "$where", "Sentencia", "SQL", "WHERE", "que", "identifica", "la", "condición", "de", "la", "consulta", "@param", "array", "$criteria", "Criterios", "de", "la", "consulta", "SELECT", "adoptados", "en", "el", "WHERE" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/DBALModel.php#L266-L277
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/DBALModel.php
DBALModel.getById
public function getById($id) { if (!is_null($this->_table) && !is_null($id)) { $this->_sql = "SELECT * FROM $this->_table WHERE id = $id"; $row = $this->_select($this->_sql); return (isset($row[0])) ? $row[0] : null; } }
php
public function getById($id) { if (!is_null($this->_table) && !is_null($id)) { $this->_sql = "SELECT * FROM $this->_table WHERE id = $id"; $row = $this->_select($this->_sql); return (isset($row[0])) ? $row[0] : null; } }
[ "public", "function", "getById", "(", "$", "id", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "_table", ")", "&&", "!", "is_null", "(", "$", "id", ")", ")", "{", "$", "this", "->", "_sql", "=", "\"SELECT * FROM $this->_table WHERE id = $id\"", ";", "$", "row", "=", "$", "this", "->", "_select", "(", "$", "this", "->", "_sql", ")", ";", "return", "(", "isset", "(", "$", "row", "[", "0", "]", ")", ")", "?", "$", "row", "[", "0", "]", ":", "null", ";", "}", "}" ]
@param int $id Id del registro @return array Arreglo asociativo del registro
[ "@param", "int", "$id", "Id", "del", "registro" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/DBALModel.php#L284-L291
webforge-labs/psc-cms
lib/Psc/Code/AST/DSL.php
DSL.getClosures
public function getClosures() { if (!isset($this->closures)) { $cc = new ClosureCompiler(); list($closureCode, $methods) = $cc->compile(new GClass(\Psc\Code\Code::getClass($this))); unset($methods[array_search('getClosures', $methods)]); $that = $this; eval($closureCode); $this->closures = compact($methods); } return $this->closures; }
php
public function getClosures() { if (!isset($this->closures)) { $cc = new ClosureCompiler(); list($closureCode, $methods) = $cc->compile(new GClass(\Psc\Code\Code::getClass($this))); unset($methods[array_search('getClosures', $methods)]); $that = $this; eval($closureCode); $this->closures = compact($methods); } return $this->closures; }
[ "public", "function", "getClosures", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "closures", ")", ")", "{", "$", "cc", "=", "new", "ClosureCompiler", "(", ")", ";", "list", "(", "$", "closureCode", ",", "$", "methods", ")", "=", "$", "cc", "->", "compile", "(", "new", "GClass", "(", "\\", "Psc", "\\", "Code", "\\", "Code", "::", "getClass", "(", "$", "this", ")", ")", ")", ";", "unset", "(", "$", "methods", "[", "array_search", "(", "'getClosures'", ",", "$", "methods", ")", "]", ")", ";", "$", "that", "=", "$", "this", ";", "eval", "(", "$", "closureCode", ")", ";", "$", "this", "->", "closures", "=", "compact", "(", "$", "methods", ")", ";", "}", "return", "$", "this", "->", "closures", ";", "}" ]
Gibt für alle Methoden der Klasse eine Closure zurück extract($dsl->getClosures()); - $parameter defined - $type defined - ... usw @return array (für extract geeignet)
[ "Gibt", "für", "alle", "Methoden", "der", "Klasse", "eine", "Closure", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/AST/DSL.php#L188-L202
atkrad/data-tables
src/Request/Column.php
Column.setSearchable
public function setSearchable($searchable) { if ($searchable === 'true') { $this->searchable = true; return $this; } $this->searchable = false; return $this; }
php
public function setSearchable($searchable) { if ($searchable === 'true') { $this->searchable = true; return $this; } $this->searchable = false; return $this; }
[ "public", "function", "setSearchable", "(", "$", "searchable", ")", "{", "if", "(", "$", "searchable", "===", "'true'", ")", "{", "$", "this", "->", "searchable", "=", "true", ";", "return", "$", "this", ";", "}", "$", "this", "->", "searchable", "=", "false", ";", "return", "$", "this", ";", "}" ]
@param string $searchable @return Column
[ "@param", "string", "$searchable" ]
train
https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Request/Column.php#L48-L58
atkrad/data-tables
src/Request/Column.php
Column.setOrderable
public function setOrderable($orderable) { if ($orderable === 'true') { $this->orderable = true; return $this; } $this->orderable = false; return $this; }
php
public function setOrderable($orderable) { if ($orderable === 'true') { $this->orderable = true; return $this; } $this->orderable = false; return $this; }
[ "public", "function", "setOrderable", "(", "$", "orderable", ")", "{", "if", "(", "$", "orderable", "===", "'true'", ")", "{", "$", "this", "->", "orderable", "=", "true", ";", "return", "$", "this", ";", "}", "$", "this", "->", "orderable", "=", "false", ";", "return", "$", "this", ";", "}" ]
@param string $orderable @return Column
[ "@param", "string", "$orderable" ]
train
https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Request/Column.php#L65-L75
fond-of/spryker-brand
src/FondOfSpryker/Zed/Brand/Business/BrandExpander/BrandExpander.php
BrandExpander.expand
public function expand(BrandTransfer $brandTransfer): BrandTransfer { foreach ($this->brandTransferExpanderPlugins as $brandTransferExpanderPlugin) { $brandTransfer = $brandTransferExpanderPlugin->expandTransfer($brandTransfer); } return $brandTransfer; }
php
public function expand(BrandTransfer $brandTransfer): BrandTransfer { foreach ($this->brandTransferExpanderPlugins as $brandTransferExpanderPlugin) { $brandTransfer = $brandTransferExpanderPlugin->expandTransfer($brandTransfer); } return $brandTransfer; }
[ "public", "function", "expand", "(", "BrandTransfer", "$", "brandTransfer", ")", ":", "BrandTransfer", "{", "foreach", "(", "$", "this", "->", "brandTransferExpanderPlugins", "as", "$", "brandTransferExpanderPlugin", ")", "{", "$", "brandTransfer", "=", "$", "brandTransferExpanderPlugin", "->", "expandTransfer", "(", "$", "brandTransfer", ")", ";", "}", "return", "$", "brandTransfer", ";", "}" ]
@param \Generated\Shared\Transfer\BrandTransfer $brandTransfer @return \Generated\Shared\Transfer\BrandTransfer
[ "@param", "\\", "Generated", "\\", "Shared", "\\", "Transfer", "\\", "BrandTransfer", "$brandTransfer" ]
train
https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/Business/BrandExpander/BrandExpander.php#L27-L34
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/UserManager.php
UserManager.find
public function find(ValueObject $object) { try { if (isset($object->data['username'])) { $user = $this->userService->loadUserByLogin($object->data['username']); } } catch (NotFoundException $notFoundException) { // We'll throw our own exception later instead. } if (!isset($user)) { throw new ObjectNotFoundException(User::class, array('username')); } return $user; }
php
public function find(ValueObject $object) { try { if (isset($object->data['username'])) { $user = $this->userService->loadUserByLogin($object->data['username']); } } catch (NotFoundException $notFoundException) { // We'll throw our own exception later instead. } if (!isset($user)) { throw new ObjectNotFoundException(User::class, array('username')); } return $user; }
[ "public", "function", "find", "(", "ValueObject", "$", "object", ")", "{", "try", "{", "if", "(", "isset", "(", "$", "object", "->", "data", "[", "'username'", "]", ")", ")", "{", "$", "user", "=", "$", "this", "->", "userService", "->", "loadUserByLogin", "(", "$", "object", "->", "data", "[", "'username'", "]", ")", ";", "}", "}", "catch", "(", "NotFoundException", "$", "notFoundException", ")", "{", "// We'll throw our own exception later instead.", "}", "if", "(", "!", "isset", "(", "$", "user", ")", ")", "{", "throw", "new", "ObjectNotFoundException", "(", "User", "::", "class", ",", "array", "(", "'username'", ")", ")", ";", "}", "return", "$", "user", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/UserManager.php#L88-L103
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/UserManager.php
UserManager.create
public function create(ObjectInterface $object) { if (!$object instanceof UserObject) { throw new UnsupportedObjectOperationException(UserObject::class, get_class($object)); } $this->ensureDefaults($object); $userCreateStruct = $this->userService->newUserCreateStruct( $object->data['username'], $object->data['email'], $object->data['password'], $object->data['main_language_code'], $this->getContentType($object) ); $object->getMapper()->mapObjectToCreateStruct($userCreateStruct); $groups = []; foreach ($object->data['parents'] as $userGroup) { $userGroup = $this->userGroupManager->createOrUpdate($userGroup); if ($userGroup instanceof UserGroupObject) { $groups[] = $this->userGroupManager->find($userGroup); } } $user = $this->userService->createUser($userCreateStruct, $groups); $object->data['id'] = $user->getUserId(); return $object; }
php
public function create(ObjectInterface $object) { if (!$object instanceof UserObject) { throw new UnsupportedObjectOperationException(UserObject::class, get_class($object)); } $this->ensureDefaults($object); $userCreateStruct = $this->userService->newUserCreateStruct( $object->data['username'], $object->data['email'], $object->data['password'], $object->data['main_language_code'], $this->getContentType($object) ); $object->getMapper()->mapObjectToCreateStruct($userCreateStruct); $groups = []; foreach ($object->data['parents'] as $userGroup) { $userGroup = $this->userGroupManager->createOrUpdate($userGroup); if ($userGroup instanceof UserGroupObject) { $groups[] = $this->userGroupManager->find($userGroup); } } $user = $this->userService->createUser($userCreateStruct, $groups); $object->data['id'] = $user->getUserId(); return $object; }
[ "public", "function", "create", "(", "ObjectInterface", "$", "object", ")", "{", "if", "(", "!", "$", "object", "instanceof", "UserObject", ")", "{", "throw", "new", "UnsupportedObjectOperationException", "(", "UserObject", "::", "class", ",", "get_class", "(", "$", "object", ")", ")", ";", "}", "$", "this", "->", "ensureDefaults", "(", "$", "object", ")", ";", "$", "userCreateStruct", "=", "$", "this", "->", "userService", "->", "newUserCreateStruct", "(", "$", "object", "->", "data", "[", "'username'", "]", ",", "$", "object", "->", "data", "[", "'email'", "]", ",", "$", "object", "->", "data", "[", "'password'", "]", ",", "$", "object", "->", "data", "[", "'main_language_code'", "]", ",", "$", "this", "->", "getContentType", "(", "$", "object", ")", ")", ";", "$", "object", "->", "getMapper", "(", ")", "->", "mapObjectToCreateStruct", "(", "$", "userCreateStruct", ")", ";", "$", "groups", "=", "[", "]", ";", "foreach", "(", "$", "object", "->", "data", "[", "'parents'", "]", "as", "$", "userGroup", ")", "{", "$", "userGroup", "=", "$", "this", "->", "userGroupManager", "->", "createOrUpdate", "(", "$", "userGroup", ")", ";", "if", "(", "$", "userGroup", "instanceof", "UserGroupObject", ")", "{", "$", "groups", "[", "]", "=", "$", "this", "->", "userGroupManager", "->", "find", "(", "$", "userGroup", ")", ";", "}", "}", "$", "user", "=", "$", "this", "->", "userService", "->", "createUser", "(", "$", "userCreateStruct", ",", "$", "groups", ")", ";", "$", "object", "->", "data", "[", "'id'", "]", "=", "$", "user", "->", "getUserId", "(", ")", ";", "return", "$", "object", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/UserManager.php#L108-L138
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/UserManager.php
UserManager.update
public function update(ObjectInterface $object) { if (!$object instanceof UserObject) { throw new UnsupportedObjectOperationException(UserObject::class, get_class($object)); } $this->ensureDefaults($object); $user = $this->find($object); // Populate struct $userUpdateStruct = $this->userService->newUserUpdateStruct(); $object->getMapper()->mapObjectToUpdateStruct($userUpdateStruct); // Update user $user = $this->userService->updateUser($user, $userUpdateStruct); // Assign user to usergroups $userGroups = $this->assignUserToUserGroups($user, $object->data['parents']); // Unassign user from usergroups $this->unassignUserFromUserGroups($user, $userGroups); return $object; }
php
public function update(ObjectInterface $object) { if (!$object instanceof UserObject) { throw new UnsupportedObjectOperationException(UserObject::class, get_class($object)); } $this->ensureDefaults($object); $user = $this->find($object); // Populate struct $userUpdateStruct = $this->userService->newUserUpdateStruct(); $object->getMapper()->mapObjectToUpdateStruct($userUpdateStruct); // Update user $user = $this->userService->updateUser($user, $userUpdateStruct); // Assign user to usergroups $userGroups = $this->assignUserToUserGroups($user, $object->data['parents']); // Unassign user from usergroups $this->unassignUserFromUserGroups($user, $userGroups); return $object; }
[ "public", "function", "update", "(", "ObjectInterface", "$", "object", ")", "{", "if", "(", "!", "$", "object", "instanceof", "UserObject", ")", "{", "throw", "new", "UnsupportedObjectOperationException", "(", "UserObject", "::", "class", ",", "get_class", "(", "$", "object", ")", ")", ";", "}", "$", "this", "->", "ensureDefaults", "(", "$", "object", ")", ";", "$", "user", "=", "$", "this", "->", "find", "(", "$", "object", ")", ";", "// Populate struct", "$", "userUpdateStruct", "=", "$", "this", "->", "userService", "->", "newUserUpdateStruct", "(", ")", ";", "$", "object", "->", "getMapper", "(", ")", "->", "mapObjectToUpdateStruct", "(", "$", "userUpdateStruct", ")", ";", "// Update user", "$", "user", "=", "$", "this", "->", "userService", "->", "updateUser", "(", "$", "user", ",", "$", "userUpdateStruct", ")", ";", "// Assign user to usergroups", "$", "userGroups", "=", "$", "this", "->", "assignUserToUserGroups", "(", "$", "user", ",", "$", "object", "->", "data", "[", "'parents'", "]", ")", ";", "// Unassign user from usergroups", "$", "this", "->", "unassignUserFromUserGroups", "(", "$", "user", ",", "$", "userGroups", ")", ";", "return", "$", "object", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/UserManager.php#L143-L167
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/UserManager.php
UserManager.remove
public function remove(ObjectInterface $object) { if (!$object instanceof UserObject) { throw new UnsupportedObjectOperationException(UserObject::class, get_class($object)); } $user = $this->find($object); if ($user) { $this->userService->deleteUser($user); } return true; }
php
public function remove(ObjectInterface $object) { if (!$object instanceof UserObject) { throw new UnsupportedObjectOperationException(UserObject::class, get_class($object)); } $user = $this->find($object); if ($user) { $this->userService->deleteUser($user); } return true; }
[ "public", "function", "remove", "(", "ObjectInterface", "$", "object", ")", "{", "if", "(", "!", "$", "object", "instanceof", "UserObject", ")", "{", "throw", "new", "UnsupportedObjectOperationException", "(", "UserObject", "::", "class", ",", "get_class", "(", "$", "object", ")", ")", ";", "}", "$", "user", "=", "$", "this", "->", "find", "(", "$", "object", ")", ";", "if", "(", "$", "user", ")", "{", "$", "this", "->", "userService", "->", "deleteUser", "(", "$", "user", ")", ";", "}", "return", "true", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/UserManager.php#L190-L203
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/UserManager.php
UserManager.assignUserToUserGroups
protected function assignUserToUserGroups(User $user, array $userGroupObjects) { $ezUserGroups = []; foreach ($userGroupObjects as $userGroup) { $userGroup = $this->userGroupManager->createOrUpdate($userGroup); if ($userGroup instanceof UserGroupObject) { $ezUserGroup = $this->userGroupManager->find($userGroup); if ($ezUserGroup) { $ezUserGroups[$ezUserGroup->id] = $ezUserGroup; try { $this->userService->assignUserToUserGroup($user, $ezUserGroup); } catch (InvalidArgumentException $alreadyAssignedException) { // Ignore error about: user already assigned to usergroup. } } } } return $ezUserGroups; }
php
protected function assignUserToUserGroups(User $user, array $userGroupObjects) { $ezUserGroups = []; foreach ($userGroupObjects as $userGroup) { $userGroup = $this->userGroupManager->createOrUpdate($userGroup); if ($userGroup instanceof UserGroupObject) { $ezUserGroup = $this->userGroupManager->find($userGroup); if ($ezUserGroup) { $ezUserGroups[$ezUserGroup->id] = $ezUserGroup; try { $this->userService->assignUserToUserGroup($user, $ezUserGroup); } catch (InvalidArgumentException $alreadyAssignedException) { // Ignore error about: user already assigned to usergroup. } } } } return $ezUserGroups; }
[ "protected", "function", "assignUserToUserGroups", "(", "User", "$", "user", ",", "array", "$", "userGroupObjects", ")", "{", "$", "ezUserGroups", "=", "[", "]", ";", "foreach", "(", "$", "userGroupObjects", "as", "$", "userGroup", ")", "{", "$", "userGroup", "=", "$", "this", "->", "userGroupManager", "->", "createOrUpdate", "(", "$", "userGroup", ")", ";", "if", "(", "$", "userGroup", "instanceof", "UserGroupObject", ")", "{", "$", "ezUserGroup", "=", "$", "this", "->", "userGroupManager", "->", "find", "(", "$", "userGroup", ")", ";", "if", "(", "$", "ezUserGroup", ")", "{", "$", "ezUserGroups", "[", "$", "ezUserGroup", "->", "id", "]", "=", "$", "ezUserGroup", ";", "try", "{", "$", "this", "->", "userService", "->", "assignUserToUserGroup", "(", "$", "user", ",", "$", "ezUserGroup", ")", ";", "}", "catch", "(", "InvalidArgumentException", "$", "alreadyAssignedException", ")", "{", "// Ignore error about: user already assigned to usergroup.", "}", "}", "}", "}", "return", "$", "ezUserGroups", ";", "}" ]
Assigns a collection of Transfer user groups from an eZ user, and returns the once who were added. @param User $user @param UserGroupObject[] $userGroupObjects @return UserGroup[]
[ "Assigns", "a", "collection", "of", "Transfer", "user", "groups", "from", "an", "eZ", "user", "and", "returns", "the", "once", "who", "were", "added", "." ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/UserManager.php#L213-L232
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/UserManager.php
UserManager.unassignUserFromUserGroups
protected function unassignUserFromUserGroups(User $user, array $userGroups) { $existingUserGroups = $this->userService->loadUserGroupsOfUser($user); foreach ($existingUserGroups as $existingUserGroup) { if (!array_key_exists($existingUserGroup->id, $userGroups)) { $this->userService->unAssignUserFromUserGroup($user, $existingUserGroup); } } }
php
protected function unassignUserFromUserGroups(User $user, array $userGroups) { $existingUserGroups = $this->userService->loadUserGroupsOfUser($user); foreach ($existingUserGroups as $existingUserGroup) { if (!array_key_exists($existingUserGroup->id, $userGroups)) { $this->userService->unAssignUserFromUserGroup($user, $existingUserGroup); } } }
[ "protected", "function", "unassignUserFromUserGroups", "(", "User", "$", "user", ",", "array", "$", "userGroups", ")", "{", "$", "existingUserGroups", "=", "$", "this", "->", "userService", "->", "loadUserGroupsOfUser", "(", "$", "user", ")", ";", "foreach", "(", "$", "existingUserGroups", "as", "$", "existingUserGroup", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "existingUserGroup", "->", "id", ",", "$", "userGroups", ")", ")", "{", "$", "this", "->", "userService", "->", "unAssignUserFromUserGroup", "(", "$", "user", ",", "$", "existingUserGroup", ")", ";", "}", "}", "}" ]
Unassigns a collection of eZ UserGroups from an eZ User. @param User $user @param UserGroup[] $userGroups
[ "Unassigns", "a", "collection", "of", "eZ", "UserGroups", "from", "an", "eZ", "User", "." ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/UserManager.php#L240-L248
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/UserManager.php
UserManager.getContentType
protected function getContentType(UserObject $object) { if (isset($object->data['content_type'])) { return $this->contentTypeService->loadContentTypeByIdentifier($object->data['content_type']); } return; }
php
protected function getContentType(UserObject $object) { if (isset($object->data['content_type'])) { return $this->contentTypeService->loadContentTypeByIdentifier($object->data['content_type']); } return; }
[ "protected", "function", "getContentType", "(", "UserObject", "$", "object", ")", "{", "if", "(", "isset", "(", "$", "object", "->", "data", "[", "'content_type'", "]", ")", ")", "{", "return", "$", "this", "->", "contentTypeService", "->", "loadContentTypeByIdentifier", "(", "$", "object", "->", "data", "[", "'content_type'", "]", ")", ";", "}", "return", ";", "}" ]
@param UserObject $object @return \eZ\Publish\API\Repository\Values\ContentType\ContentType|null
[ "@param", "UserObject", "$object" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/UserManager.php#L255-L262
turanct/showpad-api
src/Showpad/Authentication.php
Authentication.authenticationStart
public function authenticationStart($redirectUrl) { $url = $this->config->getEndpoint(); $url .= '/oauth2/authorize'; $url .= '?client_id=' . $this->config->getClientId(); $url .= '&redirect_uri=' . urlencode($redirectUrl); $url .= '&response_type=code'; return $url; }
php
public function authenticationStart($redirectUrl) { $url = $this->config->getEndpoint(); $url .= '/oauth2/authorize'; $url .= '?client_id=' . $this->config->getClientId(); $url .= '&redirect_uri=' . urlencode($redirectUrl); $url .= '&response_type=code'; return $url; }
[ "public", "function", "authenticationStart", "(", "$", "redirectUrl", ")", "{", "$", "url", "=", "$", "this", "->", "config", "->", "getEndpoint", "(", ")", ";", "$", "url", ".=", "'/oauth2/authorize'", ";", "$", "url", ".=", "'?client_id='", ".", "$", "this", "->", "config", "->", "getClientId", "(", ")", ";", "$", "url", ".=", "'&redirect_uri='", ".", "urlencode", "(", "$", "redirectUrl", ")", ";", "$", "url", ".=", "'&response_type=code'", ";", "return", "$", "url", ";", "}" ]
Authentication Start (OAuth2 Step 1) This method will return the url where users can authenticate our application @param string $redirectUrl The url where we want to redirect users to (and where we'll catch the OAuth2 code) @return string
[ "Authentication", "Start", "(", "OAuth2", "Step", "1", ")" ]
train
https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Authentication.php#L50-L59
turanct/showpad-api
src/Showpad/Authentication.php
Authentication.authenticationFinish
public function authenticationFinish($code, $redirectUrl) { $resource = $this->config->getEndpoint() . '/oauth2/token'; $parameters = array( 'grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => $redirectUrl, ); // Auth with basic auth $data = $this->client->request( 'POST', $resource, $parameters, array('Authorization' => 'Basic ' . base64_encode($this->config->getClientId() . ':' . $this->config->getClientSecret())) ); // Overwrite $this->config with new settings $this->config->setAccessToken($data['access_token']); $this->config->setRefreshToken($data['refresh_token']); // Return token data return $data; }
php
public function authenticationFinish($code, $redirectUrl) { $resource = $this->config->getEndpoint() . '/oauth2/token'; $parameters = array( 'grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => $redirectUrl, ); // Auth with basic auth $data = $this->client->request( 'POST', $resource, $parameters, array('Authorization' => 'Basic ' . base64_encode($this->config->getClientId() . ':' . $this->config->getClientSecret())) ); // Overwrite $this->config with new settings $this->config->setAccessToken($data['access_token']); $this->config->setRefreshToken($data['refresh_token']); // Return token data return $data; }
[ "public", "function", "authenticationFinish", "(", "$", "code", ",", "$", "redirectUrl", ")", "{", "$", "resource", "=", "$", "this", "->", "config", "->", "getEndpoint", "(", ")", ".", "'/oauth2/token'", ";", "$", "parameters", "=", "array", "(", "'grant_type'", "=>", "'authorization_code'", ",", "'code'", "=>", "$", "code", ",", "'redirect_uri'", "=>", "$", "redirectUrl", ",", ")", ";", "// Auth with basic auth", "$", "data", "=", "$", "this", "->", "client", "->", "request", "(", "'POST'", ",", "$", "resource", ",", "$", "parameters", ",", "array", "(", "'Authorization'", "=>", "'Basic '", ".", "base64_encode", "(", "$", "this", "->", "config", "->", "getClientId", "(", ")", ".", "':'", ".", "$", "this", "->", "config", "->", "getClientSecret", "(", ")", ")", ")", ")", ";", "// Overwrite $this->config with new settings", "$", "this", "->", "config", "->", "setAccessToken", "(", "$", "data", "[", "'access_token'", "]", ")", ";", "$", "this", "->", "config", "->", "setRefreshToken", "(", "$", "data", "[", "'refresh_token'", "]", ")", ";", "// Return token data", "return", "$", "data", ";", "}" ]
Authentication Finish (OAuth2 Step 2) This method will request our access tokens using the code obtained in step 1 @param string $code The OAuth2 code obtained in step 1 @param string $redirectUrl The url where we want to redirect users to (and where we'll catch the OAuth2 tokens) @return New token pair
[ "Authentication", "Finish", "(", "OAuth2", "Step", "2", ")" ]
train
https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Authentication.php#L71-L95
turanct/showpad-api
src/Showpad/Authentication.php
Authentication.refreshTokens
public function refreshTokens() { $resource = $this->config->getEndpoint() . '/oauth2/token'; $parameters = array( 'grant_type' => 'refresh_token', 'refresh_token' => $this->config->getRefreshToken(), ); // Auth with basic auth $data = $this->client->request( 'POST', $resource, $parameters, array('Authorization' => 'Basic ' . base64_encode($this->config->getClientId() . ':' . $this->config->getClientSecret())) ); // Overwrite $this->config with new settings $this->config->setAccessToken($data['access_token']); $this->config->setRefreshToken($data['refresh_token']); // Return token data return $data; }
php
public function refreshTokens() { $resource = $this->config->getEndpoint() . '/oauth2/token'; $parameters = array( 'grant_type' => 'refresh_token', 'refresh_token' => $this->config->getRefreshToken(), ); // Auth with basic auth $data = $this->client->request( 'POST', $resource, $parameters, array('Authorization' => 'Basic ' . base64_encode($this->config->getClientId() . ':' . $this->config->getClientSecret())) ); // Overwrite $this->config with new settings $this->config->setAccessToken($data['access_token']); $this->config->setRefreshToken($data['refresh_token']); // Return token data return $data; }
[ "public", "function", "refreshTokens", "(", ")", "{", "$", "resource", "=", "$", "this", "->", "config", "->", "getEndpoint", "(", ")", ".", "'/oauth2/token'", ";", "$", "parameters", "=", "array", "(", "'grant_type'", "=>", "'refresh_token'", ",", "'refresh_token'", "=>", "$", "this", "->", "config", "->", "getRefreshToken", "(", ")", ",", ")", ";", "// Auth with basic auth", "$", "data", "=", "$", "this", "->", "client", "->", "request", "(", "'POST'", ",", "$", "resource", ",", "$", "parameters", ",", "array", "(", "'Authorization'", "=>", "'Basic '", ".", "base64_encode", "(", "$", "this", "->", "config", "->", "getClientId", "(", ")", ".", "':'", ".", "$", "this", "->", "config", "->", "getClientSecret", "(", ")", ")", ")", ")", ";", "// Overwrite $this->config with new settings", "$", "this", "->", "config", "->", "setAccessToken", "(", "$", "data", "[", "'access_token'", "]", ")", ";", "$", "this", "->", "config", "->", "setRefreshToken", "(", "$", "data", "[", "'refresh_token'", "]", ")", ";", "// Return token data", "return", "$", "data", ";", "}" ]
Refresh tokens @return array New token pair
[ "Refresh", "tokens" ]
train
https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Authentication.php#L102-L125
turanct/showpad-api
src/Showpad/Authentication.php
Authentication.request
public function request($method, $endpoint, array $parameters = null) { $url = $this->config->getEndpoint() . $endpoint; // Client should always send OAuth2 tokens in its headers $headers = array('Authorization' => 'Bearer ' . $this->config->getAccessToken()); return $this->client->request($method, $url, $parameters, $headers); }
php
public function request($method, $endpoint, array $parameters = null) { $url = $this->config->getEndpoint() . $endpoint; // Client should always send OAuth2 tokens in its headers $headers = array('Authorization' => 'Bearer ' . $this->config->getAccessToken()); return $this->client->request($method, $url, $parameters, $headers); }
[ "public", "function", "request", "(", "$", "method", ",", "$", "endpoint", ",", "array", "$", "parameters", "=", "null", ")", "{", "$", "url", "=", "$", "this", "->", "config", "->", "getEndpoint", "(", ")", ".", "$", "endpoint", ";", "// Client should always send OAuth2 tokens in its headers", "$", "headers", "=", "array", "(", "'Authorization'", "=>", "'Bearer '", ".", "$", "this", "->", "config", "->", "getAccessToken", "(", ")", ")", ";", "return", "$", "this", "->", "client", "->", "request", "(", "$", "method", ",", "$", "url", ",", "$", "parameters", ",", "$", "headers", ")", ";", "}" ]
Send an authenticated api request @param string $method The HTTP method @param string $endpoint The api endpoint to send the request to @param array $parameters The parameters for the request (assoc array) return mixed
[ "Send", "an", "authenticated", "api", "request" ]
train
https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Authentication.php#L136-L144
nimix3/Venus
Venus/library/t3rdparty/MiqroDB.php
MiqroTable.delete
public function delete( $options = [] ) { if( !is_array( $options ) ) throw new MiqroException( 'Parameter $options isn\'t an array', 3 ); $builder = new MiqroBuilder( $this->miqro, 'DELETE FROM $table ' ); $builder->set( 'table', $this->tablename ); if( !empty( $options[ 'where' ] ) ) { $builder->add( 'WHERE $whereData ' ); $builder->set( 'whereData', ( is_array( $options[ 'where' ] ) ? implode( ' AND ', $options[ 'where' ] ) : $options[ 'where' ] ) ); } if( !empty( $options[ 'limit' ] ) ) { $builder->add( 'LIMIT $limit' ); $builder->set( 'limit', $options[ 'limit' ] ); } $builder->execute(); }
php
public function delete( $options = [] ) { if( !is_array( $options ) ) throw new MiqroException( 'Parameter $options isn\'t an array', 3 ); $builder = new MiqroBuilder( $this->miqro, 'DELETE FROM $table ' ); $builder->set( 'table', $this->tablename ); if( !empty( $options[ 'where' ] ) ) { $builder->add( 'WHERE $whereData ' ); $builder->set( 'whereData', ( is_array( $options[ 'where' ] ) ? implode( ' AND ', $options[ 'where' ] ) : $options[ 'where' ] ) ); } if( !empty( $options[ 'limit' ] ) ) { $builder->add( 'LIMIT $limit' ); $builder->set( 'limit', $options[ 'limit' ] ); } $builder->execute(); }
[ "public", "function", "delete", "(", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "is_array", "(", "$", "options", ")", ")", "throw", "new", "MiqroException", "(", "'Parameter $options isn\\'t an array'", ",", "3", ")", ";", "$", "builder", "=", "new", "MiqroBuilder", "(", "$", "this", "->", "miqro", ",", "'DELETE FROM $table '", ")", ";", "$", "builder", "->", "set", "(", "'table'", ",", "$", "this", "->", "tablename", ")", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'where'", "]", ")", ")", "{", "$", "builder", "->", "add", "(", "'WHERE $whereData '", ")", ";", "$", "builder", "->", "set", "(", "'whereData'", ",", "(", "is_array", "(", "$", "options", "[", "'where'", "]", ")", "?", "implode", "(", "' AND '", ",", "$", "options", "[", "'where'", "]", ")", ":", "$", "options", "[", "'where'", "]", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'limit'", "]", ")", ")", "{", "$", "builder", "->", "add", "(", "'LIMIT $limit'", ")", ";", "$", "builder", "->", "set", "(", "'limit'", ",", "$", "options", "[", "'limit'", "]", ")", ";", "}", "$", "builder", "->", "execute", "(", ")", ";", "}" ]
Remove data
[ "Remove", "data" ]
train
https://github.com/nimix3/Venus/blob/612add7b048bc28553cc58239d46cf88b688d715/Venus/library/t3rdparty/MiqroDB.php#L171-L192
GrafiteInc/Mission-Control-Package
src/IssueService.php
IssueService.exception
public function exception($exception) { $headers = [ 'token' => $this->token, ]; if (is_null($this->token)) { throw new Exception("Missing token", 1); } $query = $this->processException($exception); $response = $this->curl::post($this->missionControlUrl, $headers, $query); if ($response->code != 200) { $this->error('Unable to message Mission Control, please confirm your token'); } return true; }
php
public function exception($exception) { $headers = [ 'token' => $this->token, ]; if (is_null($this->token)) { throw new Exception("Missing token", 1); } $query = $this->processException($exception); $response = $this->curl::post($this->missionControlUrl, $headers, $query); if ($response->code != 200) { $this->error('Unable to message Mission Control, please confirm your token'); } return true; }
[ "public", "function", "exception", "(", "$", "exception", ")", "{", "$", "headers", "=", "[", "'token'", "=>", "$", "this", "->", "token", ",", "]", ";", "if", "(", "is_null", "(", "$", "this", "->", "token", ")", ")", "{", "throw", "new", "Exception", "(", "\"Missing token\"", ",", "1", ")", ";", "}", "$", "query", "=", "$", "this", "->", "processException", "(", "$", "exception", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "::", "post", "(", "$", "this", "->", "missionControlUrl", ",", "$", "headers", ",", "$", "query", ")", ";", "if", "(", "$", "response", "->", "code", "!=", "200", ")", "{", "$", "this", "->", "error", "(", "'Unable to message Mission Control, please confirm your token'", ")", ";", "}", "return", "true", ";", "}" ]
Send the exception to Mission control. @param Exeption $exception @return bool
[ "Send", "the", "exception", "to", "Mission", "control", "." ]
train
https://github.com/GrafiteInc/Mission-Control-Package/blob/4e85f0b729329783b34e35d90abba2807899ff58/src/IssueService.php#L31-L50
GrafiteInc/Mission-Control-Package
src/IssueService.php
IssueService.log
public function log($message, $flag) { $headers = [ 'token' => $this->token, ]; $query = $this->processLog($message, $flag); $response = $this->curl::post($this->missionControlUrl, $headers, $query); if ($response->code != 200) { $this->error('Unable to message Mission Control, please confirm your token'); } return true; }
php
public function log($message, $flag) { $headers = [ 'token' => $this->token, ]; $query = $this->processLog($message, $flag); $response = $this->curl::post($this->missionControlUrl, $headers, $query); if ($response->code != 200) { $this->error('Unable to message Mission Control, please confirm your token'); } return true; }
[ "public", "function", "log", "(", "$", "message", ",", "$", "flag", ")", "{", "$", "headers", "=", "[", "'token'", "=>", "$", "this", "->", "token", ",", "]", ";", "$", "query", "=", "$", "this", "->", "processLog", "(", "$", "message", ",", "$", "flag", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "::", "post", "(", "$", "this", "->", "missionControlUrl", ",", "$", "headers", ",", "$", "query", ")", ";", "if", "(", "$", "response", "->", "code", "!=", "200", ")", "{", "$", "this", "->", "error", "(", "'Unable to message Mission Control, please confirm your token'", ")", ";", "}", "return", "true", ";", "}" ]
Send the log to Mission Control @param string $message @param string $flag @return bool
[ "Send", "the", "log", "to", "Mission", "Control" ]
train
https://github.com/GrafiteInc/Mission-Control-Package/blob/4e85f0b729329783b34e35d90abba2807899ff58/src/IssueService.php#L60-L75
GrafiteInc/Mission-Control-Package
src/IssueService.php
IssueService.processException
public function processException($exception) { $requestDetails = [ 'type' => 'exception', 'data' => json_encode([ 'exception_content' => $exception->getMessage() ?? 'No message', 'exception_trace' => $exception->getTrace(), 'exception_file' => $exception->getFile(), 'exception_line' => $exception->getLine(), ]), ]; return array_merge($this->baseRequest(), $requestDetails); }
php
public function processException($exception) { $requestDetails = [ 'type' => 'exception', 'data' => json_encode([ 'exception_content' => $exception->getMessage() ?? 'No message', 'exception_trace' => $exception->getTrace(), 'exception_file' => $exception->getFile(), 'exception_line' => $exception->getLine(), ]), ]; return array_merge($this->baseRequest(), $requestDetails); }
[ "public", "function", "processException", "(", "$", "exception", ")", "{", "$", "requestDetails", "=", "[", "'type'", "=>", "'exception'", ",", "'data'", "=>", "json_encode", "(", "[", "'exception_content'", "=>", "$", "exception", "->", "getMessage", "(", ")", "??", "'No message'", ",", "'exception_trace'", "=>", "$", "exception", "->", "getTrace", "(", ")", ",", "'exception_file'", "=>", "$", "exception", "->", "getFile", "(", ")", ",", "'exception_line'", "=>", "$", "exception", "->", "getLine", "(", ")", ",", "]", ")", ",", "]", ";", "return", "array_merge", "(", "$", "this", "->", "baseRequest", "(", ")", ",", "$", "requestDetails", ")", ";", "}" ]
Collect data and set report details. @param Exception $exception @return array
[ "Collect", "data", "and", "set", "report", "details", "." ]
train
https://github.com/GrafiteInc/Mission-Control-Package/blob/4e85f0b729329783b34e35d90abba2807899ff58/src/IssueService.php#L84-L97
GrafiteInc/Mission-Control-Package
src/IssueService.php
IssueService.processLog
public function processLog($message, $flag) { $requestDetails = [ 'type' => 'log', 'data' => json_encode([ 'flag' => $flag, 'message' => $message, ]), ]; return array_merge($this->baseRequest(), $requestDetails); }
php
public function processLog($message, $flag) { $requestDetails = [ 'type' => 'log', 'data' => json_encode([ 'flag' => $flag, 'message' => $message, ]), ]; return array_merge($this->baseRequest(), $requestDetails); }
[ "public", "function", "processLog", "(", "$", "message", ",", "$", "flag", ")", "{", "$", "requestDetails", "=", "[", "'type'", "=>", "'log'", ",", "'data'", "=>", "json_encode", "(", "[", "'flag'", "=>", "$", "flag", ",", "'message'", "=>", "$", "message", ",", "]", ")", ",", "]", ";", "return", "array_merge", "(", "$", "this", "->", "baseRequest", "(", ")", ",", "$", "requestDetails", ")", ";", "}" ]
Collect data and set report details. @param String $message @param String $flag @return array
[ "Collect", "data", "and", "set", "report", "details", "." ]
train
https://github.com/GrafiteInc/Mission-Control-Package/blob/4e85f0b729329783b34e35d90abba2807899ff58/src/IssueService.php#L107-L118
GrafiteInc/Mission-Control-Package
src/IssueService.php
IssueService.baseRequest
protected function baseRequest() { return [ 'report_referer' => $this->server('HTTP_REFERER', ''), 'report_user_agent' => $this->server('HTTP_USER_AGENT', ''), 'report_host' => $this->server('HTTP_HOST', ''), 'report_server_name' => $this->server('SERVER_NAME', ''), 'report_remote_addr' => $this->server('REMOTE_ADDR', ''), 'report_server_software' => $this->server('SERVER_SOFTWARE', ''), 'report_uri' => $this->server('REQUEST_URI', ''), 'report_time' => $this->server('REQUEST_TIME', ''), 'report_method' => $this->server('REQUEST_METHOD', ''), 'report_query' => $this->server('QUERY_STRING', ''), 'app_base' => $this->server('DOCUMENT_ROOT', ''), ]; }
php
protected function baseRequest() { return [ 'report_referer' => $this->server('HTTP_REFERER', ''), 'report_user_agent' => $this->server('HTTP_USER_AGENT', ''), 'report_host' => $this->server('HTTP_HOST', ''), 'report_server_name' => $this->server('SERVER_NAME', ''), 'report_remote_addr' => $this->server('REMOTE_ADDR', ''), 'report_server_software' => $this->server('SERVER_SOFTWARE', ''), 'report_uri' => $this->server('REQUEST_URI', ''), 'report_time' => $this->server('REQUEST_TIME', ''), 'report_method' => $this->server('REQUEST_METHOD', ''), 'report_query' => $this->server('QUERY_STRING', ''), 'app_base' => $this->server('DOCUMENT_ROOT', ''), ]; }
[ "protected", "function", "baseRequest", "(", ")", "{", "return", "[", "'report_referer'", "=>", "$", "this", "->", "server", "(", "'HTTP_REFERER'", ",", "''", ")", ",", "'report_user_agent'", "=>", "$", "this", "->", "server", "(", "'HTTP_USER_AGENT'", ",", "''", ")", ",", "'report_host'", "=>", "$", "this", "->", "server", "(", "'HTTP_HOST'", ",", "''", ")", ",", "'report_server_name'", "=>", "$", "this", "->", "server", "(", "'SERVER_NAME'", ",", "''", ")", ",", "'report_remote_addr'", "=>", "$", "this", "->", "server", "(", "'REMOTE_ADDR'", ",", "''", ")", ",", "'report_server_software'", "=>", "$", "this", "->", "server", "(", "'SERVER_SOFTWARE'", ",", "''", ")", ",", "'report_uri'", "=>", "$", "this", "->", "server", "(", "'REQUEST_URI'", ",", "''", ")", ",", "'report_time'", "=>", "$", "this", "->", "server", "(", "'REQUEST_TIME'", ",", "''", ")", ",", "'report_method'", "=>", "$", "this", "->", "server", "(", "'REQUEST_METHOD'", ",", "''", ")", ",", "'report_query'", "=>", "$", "this", "->", "server", "(", "'QUERY_STRING'", ",", "''", ")", ",", "'app_base'", "=>", "$", "this", "->", "server", "(", "'DOCUMENT_ROOT'", ",", "''", ")", ",", "]", ";", "}" ]
Collect basic server info @return array
[ "Collect", "basic", "server", "info" ]
train
https://github.com/GrafiteInc/Mission-Control-Package/blob/4e85f0b729329783b34e35d90abba2807899ff58/src/IssueService.php#L125-L140
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php
ContentTypeObject.setFieldDefinitions
public function setFieldDefinitions(array $fieldDefinitionObjects) { $this->data['fields'] = []; foreach ($fieldDefinitionObjects as $identifier => $fieldDefinitionObject) { $this->addFieldDefinitionObject($identifier, $fieldDefinitionObject); } }
php
public function setFieldDefinitions(array $fieldDefinitionObjects) { $this->data['fields'] = []; foreach ($fieldDefinitionObjects as $identifier => $fieldDefinitionObject) { $this->addFieldDefinitionObject($identifier, $fieldDefinitionObject); } }
[ "public", "function", "setFieldDefinitions", "(", "array", "$", "fieldDefinitionObjects", ")", "{", "$", "this", "->", "data", "[", "'fields'", "]", "=", "[", "]", ";", "foreach", "(", "$", "fieldDefinitionObjects", "as", "$", "identifier", "=>", "$", "fieldDefinitionObject", ")", "{", "$", "this", "->", "addFieldDefinitionObject", "(", "$", "identifier", ",", "$", "fieldDefinitionObject", ")", ";", "}", "}" ]
Values in array must be of type Location, LocationObject or int. @param array $fieldDefinitionObjects
[ "Values", "in", "array", "must", "be", "of", "type", "Location", "LocationObject", "or", "int", "." ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php#L55-L61
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php
ContentTypeObject.addFieldDefinitionObject
public function addFieldDefinitionObject($identifier, $fieldDefinition) { $this->data['fields'][$identifier] = $this->convertToFieldDefintionObject($identifier, $fieldDefinition); }
php
public function addFieldDefinitionObject($identifier, $fieldDefinition) { $this->data['fields'][$identifier] = $this->convertToFieldDefintionObject($identifier, $fieldDefinition); }
[ "public", "function", "addFieldDefinitionObject", "(", "$", "identifier", ",", "$", "fieldDefinition", ")", "{", "$", "this", "->", "data", "[", "'fields'", "]", "[", "$", "identifier", "]", "=", "$", "this", "->", "convertToFieldDefintionObject", "(", "$", "identifier", ",", "$", "fieldDefinition", ")", ";", "}" ]
Convert parameters to FieldDefinitionObject and stores it on the ContentTypeObject. @param string $identifier @param array|FieldDefinitionObject $fieldDefinition
[ "Convert", "parameters", "to", "FieldDefinitionObject", "and", "stores", "it", "on", "the", "ContentTypeObject", "." ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php#L69-L72
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php
ContentTypeObject.setMissingDefaults
private function setMissingDefaults() { if (!isset($this->data['contenttype_groups'])) { $this->data['contenttype_groups'] = array('Content'); } if ($this->notSetOrEmpty($this->data, 'names')) { $this->data['names'] = array( $this->data['main_language_code'] => $this->identifierToReadable($this->data['identifier']), ); } foreach (array('name_schema', 'url_alias_schema') as $schema) { if ($this->notSetOrEmpty($this->data, $schema)) { $this->data[$schema] = sprintf('<%s>', $this->data['fields'][key($this->data['fields'])]->data['identifier']); } } }
php
private function setMissingDefaults() { if (!isset($this->data['contenttype_groups'])) { $this->data['contenttype_groups'] = array('Content'); } if ($this->notSetOrEmpty($this->data, 'names')) { $this->data['names'] = array( $this->data['main_language_code'] => $this->identifierToReadable($this->data['identifier']), ); } foreach (array('name_schema', 'url_alias_schema') as $schema) { if ($this->notSetOrEmpty($this->data, $schema)) { $this->data[$schema] = sprintf('<%s>', $this->data['fields'][key($this->data['fields'])]->data['identifier']); } } }
[ "private", "function", "setMissingDefaults", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'contenttype_groups'", "]", ")", ")", "{", "$", "this", "->", "data", "[", "'contenttype_groups'", "]", "=", "array", "(", "'Content'", ")", ";", "}", "if", "(", "$", "this", "->", "notSetOrEmpty", "(", "$", "this", "->", "data", ",", "'names'", ")", ")", "{", "$", "this", "->", "data", "[", "'names'", "]", "=", "array", "(", "$", "this", "->", "data", "[", "'main_language_code'", "]", "=>", "$", "this", "->", "identifierToReadable", "(", "$", "this", "->", "data", "[", "'identifier'", "]", ")", ",", ")", ";", "}", "foreach", "(", "array", "(", "'name_schema'", ",", "'url_alias_schema'", ")", "as", "$", "schema", ")", "{", "if", "(", "$", "this", "->", "notSetOrEmpty", "(", "$", "this", "->", "data", ",", "$", "schema", ")", ")", "{", "$", "this", "->", "data", "[", "$", "schema", "]", "=", "sprintf", "(", "'<%s>'", ",", "$", "this", "->", "data", "[", "'fields'", "]", "[", "key", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", "]", "->", "data", "[", "'identifier'", "]", ")", ";", "}", "}", "}" ]
Build default values.
[ "Build", "default", "values", "." ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php#L77-L94
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php
ContentTypeObject.convertToFieldDefintionObject
private function convertToFieldDefintionObject($identifier, $fieldDefinition) { if ($fieldDefinition instanceof FieldDefinitionObject) { return $fieldDefinition; } else { return new FieldDefinitionObject($identifier, $this, $fieldDefinition); } }
php
private function convertToFieldDefintionObject($identifier, $fieldDefinition) { if ($fieldDefinition instanceof FieldDefinitionObject) { return $fieldDefinition; } else { return new FieldDefinitionObject($identifier, $this, $fieldDefinition); } }
[ "private", "function", "convertToFieldDefintionObject", "(", "$", "identifier", ",", "$", "fieldDefinition", ")", "{", "if", "(", "$", "fieldDefinition", "instanceof", "FieldDefinitionObject", ")", "{", "return", "$", "fieldDefinition", ";", "}", "else", "{", "return", "new", "FieldDefinitionObject", "(", "$", "identifier", ",", "$", "this", ",", "$", "fieldDefinition", ")", ";", "}", "}" ]
@param string $identifier @param array|FieldDefinitionObject $fieldDefinition @return FieldDefinitionObject
[ "@param", "string", "$identifier", "@param", "array|FieldDefinitionObject", "$fieldDefinition" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php#L155-L162
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/Competitions.php
Competitions.removeTeam
function removeTeam($competitionId, $teamId) { if(!$competitionId) { throw new Exception('Invalid competitionId'); } if(!$teamId) { throw new Exception('Invalid teamId'); } return $this->execute('DELETE', '/competitions/%d/teams/%d/', array($competitionId, $teamId)); }
php
function removeTeam($competitionId, $teamId) { if(!$competitionId) { throw new Exception('Invalid competitionId'); } if(!$teamId) { throw new Exception('Invalid teamId'); } return $this->execute('DELETE', '/competitions/%d/teams/%d/', array($competitionId, $teamId)); }
[ "function", "removeTeam", "(", "$", "competitionId", ",", "$", "teamId", ")", "{", "if", "(", "!", "$", "competitionId", ")", "{", "throw", "new", "Exception", "(", "'Invalid competitionId'", ")", ";", "}", "if", "(", "!", "$", "teamId", ")", "{", "throw", "new", "Exception", "(", "'Invalid teamId'", ")", ";", "}", "return", "$", "this", "->", "execute", "(", "'DELETE'", ",", "'/competitions/%d/teams/%d/'", ",", "array", "(", "$", "competitionId", ",", "$", "teamId", ")", ")", ";", "}" ]
Works only during the registration phase @param int $competitionId @param int $teamId @return type @throws Exception
[ "Works", "only", "during", "the", "registration", "phase" ]
train
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/Competitions.php#L68-L80
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/Competitions.php
Competitions.registerResults
function registerResults($competitionId, array $results) { if(!$competitionId) { throw new Exception; } if(!$results) { throw new Exception; } return $this->execute('POST', '/competitions/%d/results/', array($competitionId, array($results))); }
php
function registerResults($competitionId, array $results) { if(!$competitionId) { throw new Exception; } if(!$results) { throw new Exception; } return $this->execute('POST', '/competitions/%d/results/', array($competitionId, array($results))); }
[ "function", "registerResults", "(", "$", "competitionId", ",", "array", "$", "results", ")", "{", "if", "(", "!", "$", "competitionId", ")", "{", "throw", "new", "Exception", ";", "}", "if", "(", "!", "$", "results", ")", "{", "throw", "new", "Exception", ";", "}", "return", "$", "this", "->", "execute", "(", "'POST'", ",", "'/competitions/%d/results/'", ",", "array", "(", "$", "competitionId", ",", "array", "(", "$", "results", ")", ")", ")", ";", "}" ]
Register final results of your competition @param int $competitionId @param array $results results should be an array with numeric keys from 1 to n, with the team ids as value
[ "Register", "final", "results", "of", "your", "competition" ]
train
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/Competitions.php#L169-L180
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.del
public function del($cookie) { if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name"); $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie; if ( $this->isRegistered($name) ) { unset($this->cookies[$name]); } else { throw new CookieException("Cookie is not registered"); } return $this; }
php
public function del($cookie) { if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name"); $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie; if ( $this->isRegistered($name) ) { unset($this->cookies[$name]); } else { throw new CookieException("Cookie is not registered"); } return $this; }
[ "public", "function", "del", "(", "$", "cookie", ")", "{", "if", "(", "empty", "(", "$", "cookie", ")", ")", "throw", "new", "CookieException", "(", "\"Invalid cookie object or name\"", ")", ";", "$", "name", "=", "(", "$", "cookie", "instanceof", "CookieInterface", ")", "?", "$", "cookie", "->", "getName", "(", ")", ":", "$", "cookie", ";", "if", "(", "$", "this", "->", "isRegistered", "(", "$", "name", ")", ")", "{", "unset", "(", "$", "this", "->", "cookies", "[", "$", "name", "]", ")", ";", "}", "else", "{", "throw", "new", "CookieException", "(", "\"Cookie is not registered\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Delete a cookie from the stack @param CookieInterface|string $cookie @return CookieManager @throws CookieException
[ "Delete", "a", "cookie", "from", "the", "stack" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L69-L83
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.has
public function has($cookie) { if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name"); $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie; return array_key_exists($name, $this->cookies); }
php
public function has($cookie) { if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name"); $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie; return array_key_exists($name, $this->cookies); }
[ "public", "function", "has", "(", "$", "cookie", ")", "{", "if", "(", "empty", "(", "$", "cookie", ")", ")", "throw", "new", "CookieException", "(", "\"Invalid cookie object or name\"", ")", ";", "$", "name", "=", "(", "$", "cookie", "instanceof", "CookieInterface", ")", "?", "$", "cookie", "->", "getName", "(", ")", ":", "$", "cookie", ";", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "cookies", ")", ";", "}" ]
Check if a cookie is into the stack @param CookieInterface|string $cookie @return CookieManager @throws CookieException
[ "Check", "if", "a", "cookie", "is", "into", "the", "stack" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L108-L116
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.getValues
public function getValues() { $cookies = []; try { foreach ( $this->cookies as $name => $cookie ) { $cookies[$name] = $cookie->getValue(); } } catch (CookieException $ce) { throw $ce; } return $cookies; }
php
public function getValues() { $cookies = []; try { foreach ( $this->cookies as $name => $cookie ) { $cookies[$name] = $cookie->getValue(); } } catch (CookieException $ce) { throw $ce; } return $cookies; }
[ "public", "function", "getValues", "(", ")", "{", "$", "cookies", "=", "[", "]", ";", "try", "{", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "name", "=>", "$", "cookie", ")", "{", "$", "cookies", "[", "$", "name", "]", "=", "$", "cookie", "->", "getValue", "(", ")", ";", "}", "}", "catch", "(", "CookieException", "$", "ce", ")", "{", "throw", "$", "ce", ";", "}", "return", "$", "cookies", ";", "}" ]
Get values from all registered cookies and dump as an associative array @return array @throws CookieException
[ "Get", "values", "from", "all", "registered", "cookies", "and", "dump", "as", "an", "associative", "array" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L168-L188
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.save
public function save() { try { foreach ( $this->cookies as $c ) { $c->save(); } } catch (CookieException $ce) { throw $ce; } return true; }
php
public function save() { try { foreach ( $this->cookies as $c ) { $c->save(); } } catch (CookieException $ce) { throw $ce; } return true; }
[ "public", "function", "save", "(", ")", "{", "try", "{", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "c", ")", "{", "$", "c", "->", "save", "(", ")", ";", "}", "}", "catch", "(", "CookieException", "$", "ce", ")", "{", "throw", "$", "ce", ";", "}", "return", "true", ";", "}" ]
Save all registered cookies @return CookieManager @throws CookieException
[ "Save", "all", "registered", "cookies" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L196-L214
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.load
public function load() { try { foreach ( $this->cookies as $c ) { $c->load(); } } catch (CookieException $ce) { throw $ce; } return $this; }
php
public function load() { try { foreach ( $this->cookies as $c ) { $c->load(); } } catch (CookieException $ce) { throw $ce; } return $this; }
[ "public", "function", "load", "(", ")", "{", "try", "{", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "c", ")", "{", "$", "c", "->", "load", "(", ")", ";", "}", "}", "catch", "(", "CookieException", "$", "ce", ")", "{", "throw", "$", "ce", ";", "}", "return", "$", "this", ";", "}" ]
Load all registered cookies @return CookieManager @throws CookieException
[ "Load", "all", "registered", "cookies" ]
train
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L222-L240
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Entry.php
Zend_Feed_Builder_Entry.addCategory
public function addCategory(array $category) { if (empty($category['term'])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to define the name of the category"); } if (!$this->offsetExists('category')) { $categories = array($category); } else { $categories = $this->offsetGet('category'); $categories[] = $category; } $this->offsetSet('category', $categories); return $this; }
php
public function addCategory(array $category) { if (empty($category['term'])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to define the name of the category"); } if (!$this->offsetExists('category')) { $categories = array($category); } else { $categories = $this->offsetGet('category'); $categories[] = $category; } $this->offsetSet('category', $categories); return $this; }
[ "public", "function", "addCategory", "(", "array", "$", "category", ")", "{", "if", "(", "empty", "(", "$", "category", "[", "'term'", "]", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to define the name of the category\"", ")", ";", "}", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "'category'", ")", ")", "{", "$", "categories", "=", "array", "(", "$", "category", ")", ";", "}", "else", "{", "$", "categories", "=", "$", "this", "->", "offsetGet", "(", "'category'", ")", ";", "$", "categories", "[", "]", "=", "$", "category", ";", "}", "$", "this", "->", "offsetSet", "(", "'category'", ",", "$", "categories", ")", ";", "return", "$", "this", ";", "}" ]
Add a category to the entry @param array $category see Zend_Feed_Builder_Entry::setCategories() for format @return Zend_Feed_Builder_Entry @throws Zend_Feed_Builder_Exception
[ "Add", "a", "category", "to", "the", "entry" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Entry.php#L221-L239
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Entry.php
Zend_Feed_Builder_Entry.setEnclosures
public function setEnclosures(array $enclosures) { foreach ($enclosures as $enclosure) { if (empty($enclosure['url'])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to supply an url for your enclosure"); } $type = isset($enclosure['type']) ? $enclosure['type'] : ''; $length = isset($enclosure['length']) ? $enclosure['length'] : ''; $this->addEnclosure($enclosure['url'], $type, $length); } return $this; }
php
public function setEnclosures(array $enclosures) { foreach ($enclosures as $enclosure) { if (empty($enclosure['url'])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to supply an url for your enclosure"); } $type = isset($enclosure['type']) ? $enclosure['type'] : ''; $length = isset($enclosure['length']) ? $enclosure['length'] : ''; $this->addEnclosure($enclosure['url'], $type, $length); } return $this; }
[ "public", "function", "setEnclosures", "(", "array", "$", "enclosures", ")", "{", "foreach", "(", "$", "enclosures", "as", "$", "enclosure", ")", "{", "if", "(", "empty", "(", "$", "enclosure", "[", "'url'", "]", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to supply an url for your enclosure\"", ")", ";", "}", "$", "type", "=", "isset", "(", "$", "enclosure", "[", "'type'", "]", ")", "?", "$", "enclosure", "[", "'type'", "]", ":", "''", ";", "$", "length", "=", "isset", "(", "$", "enclosure", "[", "'length'", "]", ")", "?", "$", "enclosure", "[", "'length'", "]", ":", "''", ";", "$", "this", "->", "addEnclosure", "(", "$", "enclosure", "[", "'url'", "]", ",", "$", "type", ",", "$", "length", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the enclosures of the entry Format of the array: <code> array( array( 'url' => 'url of the linked enclosure', 'type' => 'mime type of the enclosure' // optional 'length' => 'length of the linked content in octets' // optional ), // second enclosure and so one ) </code> @param array $enclosures @return Zend_Feed_Builder_Entry @throws Zend_Feed_Builder_Exception
[ "Sets", "the", "enclosures", "of", "the", "entry", "Format", "of", "the", "array", ":", "<code", ">", "array", "(", "array", "(", "url", "=", ">", "url", "of", "the", "linked", "enclosure", "type", "=", ">", "mime", "type", "of", "the", "enclosure", "//", "optional", "length", "=", ">", "length", "of", "the", "linked", "content", "in", "octets", "//", "optional", ")", "//", "second", "enclosure", "and", "so", "one", ")", "<", "/", "code", ">" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Entry.php#L259-L274
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Entry.php
Zend_Feed_Builder_Entry.addEnclosure
public function addEnclosure($url, $type = '', $length = '') { if (!$this->offsetExists('enclosure')) { $enclosure = array(); } else { $enclosure = $this->offsetGet('enclosure'); } $enclosure[] = array('url' => $url, 'type' => $type, 'length' => $length); $this->offsetSet('enclosure', $enclosure); return $this; }
php
public function addEnclosure($url, $type = '', $length = '') { if (!$this->offsetExists('enclosure')) { $enclosure = array(); } else { $enclosure = $this->offsetGet('enclosure'); } $enclosure[] = array('url' => $url, 'type' => $type, 'length' => $length); $this->offsetSet('enclosure', $enclosure); return $this; }
[ "public", "function", "addEnclosure", "(", "$", "url", ",", "$", "type", "=", "''", ",", "$", "length", "=", "''", ")", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "'enclosure'", ")", ")", "{", "$", "enclosure", "=", "array", "(", ")", ";", "}", "else", "{", "$", "enclosure", "=", "$", "this", "->", "offsetGet", "(", "'enclosure'", ")", ";", "}", "$", "enclosure", "[", "]", "=", "array", "(", "'url'", "=>", "$", "url", ",", "'type'", "=>", "$", "type", ",", "'length'", "=>", "$", "length", ")", ";", "$", "this", "->", "offsetSet", "(", "'enclosure'", ",", "$", "enclosure", ")", ";", "return", "$", "this", ";", "}" ]
Add an enclosure to the entry @param string $url @param string $type @param string $length @return Zend_Feed_Builder_Entry
[ "Add", "an", "enclosure", "to", "the", "entry" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Entry.php#L284-L296
Double-Opt-in/php-client-api
src/Client/Commands/Responses/CommandResponse.php
CommandResponse.all
public function all() { $result = array(); $data = $this->data(); if ( ! is_array($data)) $data = array($data); foreach ($data as $entry) { $result[] = $this->resolveActionFromStdClass($entry); } return $result; }
php
public function all() { $result = array(); $data = $this->data(); if ( ! is_array($data)) $data = array($data); foreach ($data as $entry) { $result[] = $this->resolveActionFromStdClass($entry); } return $result; }
[ "public", "function", "all", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "data", "=", "$", "this", "->", "data", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "$", "data", "=", "array", "(", "$", "data", ")", ";", "foreach", "(", "$", "data", "as", "$", "entry", ")", "{", "$", "result", "[", "]", "=", "$", "this", "->", "resolveActionFromStdClass", "(", "$", "entry", ")", ";", "}", "return", "$", "result", ";", "}" ]
returns a list of all actions @return array|Action[]
[ "returns", "a", "list", "of", "all", "actions" ]
train
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/CommandResponse.php#L20-L33
Double-Opt-in/php-client-api
src/Client/Commands/Responses/CommandResponse.php
CommandResponse.action
public function action() { $action = $this->data(); if ( ! $action instanceof stdClass) return null; return $this->resolveActionFromStdClass($action); }
php
public function action() { $action = $this->data(); if ( ! $action instanceof stdClass) return null; return $this->resolveActionFromStdClass($action); }
[ "public", "function", "action", "(", ")", "{", "$", "action", "=", "$", "this", "->", "data", "(", ")", ";", "if", "(", "!", "$", "action", "instanceof", "stdClass", ")", "return", "null", ";", "return", "$", "this", "->", "resolveActionFromStdClass", "(", "$", "action", ")", ";", "}" ]
returns the action or null @return Action|null
[ "returns", "the", "action", "or", "null" ]
train
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/CommandResponse.php#L40-L48
webforge-labs/psc-cms
lib/Psc/CMS/Item/Exporter.php
Exporter.merge
public function merge($item, array $interfaces) { $export = array(); foreach ($interfaces as $interface) { $export = array_merge($export, $this->$interface($item)); } return $export; }
php
public function merge($item, array $interfaces) { $export = array(); foreach ($interfaces as $interface) { $export = array_merge($export, $this->$interface($item)); } return $export; }
[ "public", "function", "merge", "(", "$", "item", ",", "array", "$", "interfaces", ")", "{", "$", "export", "=", "array", "(", ")", ";", "foreach", "(", "$", "interfaces", "as", "$", "interface", ")", "{", "$", "export", "=", "array_merge", "(", "$", "export", ",", "$", "this", "->", "$", "interface", "(", "$", "item", ")", ")", ";", "}", "return", "$", "export", ";", "}" ]
wird z.b. vom AbstractEntityController für Autocomplete direkt benutzt @TODO wir müssen alle Interfaces finden die von den angegebenen Interfaces abgeleitet werden um alles zu exporiteren z. b. autocompletable exportiert nur die eigenen Properties. Dies muss implizit identifyable hinzufügen
[ "wird", "z", ".", "b", ".", "vom", "AbstractEntityController", "für", "Autocomplete", "direkt", "benutzt" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/Exporter.php#L110-L116
spiral-modules/auth
source/Auth/Operators/SessionOperator.php
SessionOperator.fetchToken
public function fetchToken(Request $request) { if (!$this->hasToken($request)) { return null; } return new AuthToken( 'session-auth', $this->sessionSection($request)->get(static::USER_PK), $this ); }
php
public function fetchToken(Request $request) { if (!$this->hasToken($request)) { return null; } return new AuthToken( 'session-auth', $this->sessionSection($request)->get(static::USER_PK), $this ); }
[ "public", "function", "fetchToken", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "this", "->", "hasToken", "(", "$", "request", ")", ")", "{", "return", "null", ";", "}", "return", "new", "AuthToken", "(", "'session-auth'", ",", "$", "this", "->", "sessionSection", "(", "$", "request", ")", "->", "get", "(", "static", "::", "USER_PK", ")", ",", "$", "this", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/spiral-modules/auth/blob/24e2070028f7257e8192914556963a4794428a99/source/Auth/Operators/SessionOperator.php#L71-L82
spiral-modules/auth
source/Auth/Operators/SessionOperator.php
SessionOperator.commitToken
public function commitToken( Request $request, Response $response, TokenInterface $token ): Response { $this->sessionSection($request)->set( static::USER_PK, $token->getUserPK() ); return $response; }
php
public function commitToken( Request $request, Response $response, TokenInterface $token ): Response { $this->sessionSection($request)->set( static::USER_PK, $token->getUserPK() ); return $response; }
[ "public", "function", "commitToken", "(", "Request", "$", "request", ",", "Response", "$", "response", ",", "TokenInterface", "$", "token", ")", ":", "Response", "{", "$", "this", "->", "sessionSection", "(", "$", "request", ")", "->", "set", "(", "static", "::", "USER_PK", ",", "$", "token", "->", "getUserPK", "(", ")", ")", ";", "return", "$", "response", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/spiral-modules/auth/blob/24e2070028f7257e8192914556963a4794428a99/source/Auth/Operators/SessionOperator.php#L87-L98
spiral-modules/auth
source/Auth/Operators/SessionOperator.php
SessionOperator.removeToken
public function removeToken( Request $request, Response $response, TokenInterface $token ): Response { $this->sessionSection($request)->clear(); return $response; }
php
public function removeToken( Request $request, Response $response, TokenInterface $token ): Response { $this->sessionSection($request)->clear(); return $response; }
[ "public", "function", "removeToken", "(", "Request", "$", "request", ",", "Response", "$", "response", ",", "TokenInterface", "$", "token", ")", ":", "Response", "{", "$", "this", "->", "sessionSection", "(", "$", "request", ")", "->", "clear", "(", ")", ";", "return", "$", "response", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/spiral-modules/auth/blob/24e2070028f7257e8192914556963a4794428a99/source/Auth/Operators/SessionOperator.php#L103-L111
spiral-modules/auth
source/Auth/Operators/SessionOperator.php
SessionOperator.sessionSection
protected function sessionSection(Request $request): SectionInterface { if (empty($request->getAttribute(SessionStarter::ATTRIBUTE))) { throw new AuthException("Unable to use authorization thought session, no session exists"); } /** @var SessionInterface $session */ $session = $request->getAttribute(SessionStarter::ATTRIBUTE); return $session->getSection($this->section); }
php
protected function sessionSection(Request $request): SectionInterface { if (empty($request->getAttribute(SessionStarter::ATTRIBUTE))) { throw new AuthException("Unable to use authorization thought session, no session exists"); } /** @var SessionInterface $session */ $session = $request->getAttribute(SessionStarter::ATTRIBUTE); return $session->getSection($this->section); }
[ "protected", "function", "sessionSection", "(", "Request", "$", "request", ")", ":", "SectionInterface", "{", "if", "(", "empty", "(", "$", "request", "->", "getAttribute", "(", "SessionStarter", "::", "ATTRIBUTE", ")", ")", ")", "{", "throw", "new", "AuthException", "(", "\"Unable to use authorization thought session, no session exists\"", ")", ";", "}", "/** @var SessionInterface $session */", "$", "session", "=", "$", "request", "->", "getAttribute", "(", "SessionStarter", "::", "ATTRIBUTE", ")", ";", "return", "$", "session", "->", "getSection", "(", "$", "this", "->", "section", ")", ";", "}" ]
Get session section from given request. @param Request $request @return SectionInterface @throws AuthException When no session is started.
[ "Get", "session", "section", "from", "given", "request", "." ]
train
https://github.com/spiral-modules/auth/blob/24e2070028f7257e8192914556963a4794428a99/source/Auth/Operators/SessionOperator.php#L121-L131
xinix-technology/norm
src/Norm/Cursor/FlatFileCursor.php
FlatFileCursor.current
public function current() { if ($this->valid()) { return $this->collection->attach($this->rows[$this->index]); } return null; }
php
public function current() { if ($this->valid()) { return $this->collection->attach($this->rows[$this->index]); } return null; }
[ "public", "function", "current", "(", ")", "{", "if", "(", "$", "this", "->", "valid", "(", ")", ")", "{", "return", "$", "this", "->", "collection", "->", "attach", "(", "$", "this", "->", "rows", "[", "$", "this", "->", "index", "]", ")", ";", "}", "return", "null", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/FlatFileCursor.php#L33-L40
xinix-technology/norm
src/Norm/Cursor/FlatFileCursor.php
FlatFileCursor.execute
protected function execute() { $connection = $this->collection->getConnection(); $rows = $connection->getCollectionData($this->collection->getName(), $this->criteria); $this->rows = array_slice($rows, $this->skip, $this->limit); foreach ((array) $this->sorts as $field => $flag) { usort($this->rows, function($a, $b) use ($field, $flag) { if (isset($a[$field])) { $aValue = utf8_encode(filter_var((string) $a[$field], FILTER_SANITIZE_STRING)); $bValue = utf8_encode(filter_var((string) $b[$field], FILTER_SANITIZE_STRING)); return strcasecmp($aValue, $bValue) * (int) $flag; } }); } }
php
protected function execute() { $connection = $this->collection->getConnection(); $rows = $connection->getCollectionData($this->collection->getName(), $this->criteria); $this->rows = array_slice($rows, $this->skip, $this->limit); foreach ((array) $this->sorts as $field => $flag) { usort($this->rows, function($a, $b) use ($field, $flag) { if (isset($a[$field])) { $aValue = utf8_encode(filter_var((string) $a[$field], FILTER_SANITIZE_STRING)); $bValue = utf8_encode(filter_var((string) $b[$field], FILTER_SANITIZE_STRING)); return strcasecmp($aValue, $bValue) * (int) $flag; } }); } }
[ "protected", "function", "execute", "(", ")", "{", "$", "connection", "=", "$", "this", "->", "collection", "->", "getConnection", "(", ")", ";", "$", "rows", "=", "$", "connection", "->", "getCollectionData", "(", "$", "this", "->", "collection", "->", "getName", "(", ")", ",", "$", "this", "->", "criteria", ")", ";", "$", "this", "->", "rows", "=", "array_slice", "(", "$", "rows", ",", "$", "this", "->", "skip", ",", "$", "this", "->", "limit", ")", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "sorts", "as", "$", "field", "=>", "$", "flag", ")", "{", "usort", "(", "$", "this", "->", "rows", ",", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "field", ",", "$", "flag", ")", "{", "if", "(", "isset", "(", "$", "a", "[", "$", "field", "]", ")", ")", "{", "$", "aValue", "=", "utf8_encode", "(", "filter_var", "(", "(", "string", ")", "$", "a", "[", "$", "field", "]", ",", "FILTER_SANITIZE_STRING", ")", ")", ";", "$", "bValue", "=", "utf8_encode", "(", "filter_var", "(", "(", "string", ")", "$", "b", "[", "$", "field", "]", ",", "FILTER_SANITIZE_STRING", ")", ")", ";", "return", "strcasecmp", "(", "$", "aValue", ",", "$", "bValue", ")", "*", "(", "int", ")", "$", "flag", ";", "}", "}", ")", ";", "}", "}" ]
Execute a query. @return void
[ "Execute", "a", "query", "." ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/FlatFileCursor.php#L65-L83
xinix-technology/norm
src/Norm/Cursor/FlatFileCursor.php
FlatFileCursor.valid
public function valid() { if (is_null($this->rows)) { $this->execute(); } return isset($this->rows[$this->index]); }
php
public function valid() { if (is_null($this->rows)) { $this->execute(); } return isset($this->rows[$this->index]); }
[ "public", "function", "valid", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "rows", ")", ")", "{", "$", "this", "->", "execute", "(", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "rows", "[", "$", "this", "->", "index", "]", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/FlatFileCursor.php#L96-L103
xinix-technology/norm
src/Norm/Cursor/FlatFileCursor.php
FlatFileCursor.count
public function count($foundOnly = false) { if (is_null($this->rows)) { $this->execute(); } else if (! $foundOnly) { $this->limit = null; $this->skip = null; $this->criteria = null; $this->execute(); } return count($this->rows); }
php
public function count($foundOnly = false) { if (is_null($this->rows)) { $this->execute(); } else if (! $foundOnly) { $this->limit = null; $this->skip = null; $this->criteria = null; $this->execute(); } return count($this->rows); }
[ "public", "function", "count", "(", "$", "foundOnly", "=", "false", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "rows", ")", ")", "{", "$", "this", "->", "execute", "(", ")", ";", "}", "else", "if", "(", "!", "$", "foundOnly", ")", "{", "$", "this", "->", "limit", "=", "null", ";", "$", "this", "->", "skip", "=", "null", ";", "$", "this", "->", "criteria", "=", "null", ";", "$", "this", "->", "execute", "(", ")", ";", "}", "return", "count", "(", "$", "this", "->", "rows", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/FlatFileCursor.php#L134-L147
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.toJson
public function toJson(array $fields = [], array $expand = [], $recursive = true) { return Json::encode($this->toArray($fields, $expand, $recursive)); }
php
public function toJson(array $fields = [], array $expand = [], $recursive = true) { return Json::encode($this->toArray($fields, $expand, $recursive)); }
[ "public", "function", "toJson", "(", "array", "$", "fields", "=", "[", "]", ",", "array", "$", "expand", "=", "[", "]", ",", "$", "recursive", "=", "true", ")", "{", "return", "Json", "::", "encode", "(", "$", "this", "->", "toArray", "(", "$", "fields", ",", "$", "expand", ",", "$", "recursive", ")", ")", ";", "}" ]
Converts the model into an json. This method will first identify which fields to be included in the resulting array by calling [[resolveFields()]]. If the model implements the [[Linkable]] interface, the resulting json will also have a `_link` element which refers to a list of links as specified by the interface. @param array $fields the fields being requested. If empty or if it contains '*', all fields as specified by [[fields()]] will be returned. Fields can be nested, separated with dots (.). e.g.: item.field.sub-field `$recursive` must be true for nested fields to be extracted. If `$recursive` is false, only the root fields will be extracted. @param array $expand the additional fields being requested for exporting. Only fields declared in [[extraFields()]] will be considered. Expand can also be nested, separated with dots (.). e.g.: item.expand1.expand2 `$recursive` must be true for nested expands to be extracted. If `$recursive` is false, only the root expands will be extracted. @param bool $recursive whether to recursively return array representation of embedded objects. @return string the json representation of the object
[ "Converts", "the", "model", "into", "an", "json", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L49-L52
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.generateId
public function generateId() { $keys = $this->primaryKey(); if (count($keys) === 1) { $i = rand(0, 9999); do { if (9999 == $i) { $i = 0; } $i++; $id = time() . str_pad($i, 4, '0', STR_PAD_LEFT); $row = (new Query())->from(static::tableName())->where([$keys[0] => $id])->exists(); } while ($row); return $id; } else { throw new NotSupportedException('"generateId" is not implemented.'); } }
php
public function generateId() { $keys = $this->primaryKey(); if (count($keys) === 1) { $i = rand(0, 9999); do { if (9999 == $i) { $i = 0; } $i++; $id = time() . str_pad($i, 4, '0', STR_PAD_LEFT); $row = (new Query())->from(static::tableName())->where([$keys[0] => $id])->exists(); } while ($row); return $id; } else { throw new NotSupportedException('"generateId" is not implemented.'); } }
[ "public", "function", "generateId", "(", ")", "{", "$", "keys", "=", "$", "this", "->", "primaryKey", "(", ")", ";", "if", "(", "count", "(", "$", "keys", ")", "===", "1", ")", "{", "$", "i", "=", "rand", "(", "0", ",", "9999", ")", ";", "do", "{", "if", "(", "9999", "==", "$", "i", ")", "{", "$", "i", "=", "0", ";", "}", "$", "i", "++", ";", "$", "id", "=", "time", "(", ")", ".", "str_pad", "(", "$", "i", ",", "4", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "$", "row", "=", "(", "new", "Query", "(", ")", ")", "->", "from", "(", "static", "::", "tableName", "(", ")", ")", "->", "where", "(", "[", "$", "keys", "[", "0", "]", "=>", "$", "id", "]", ")", "->", "exists", "(", ")", ";", "}", "while", "(", "$", "row", ")", ";", "return", "$", "id", ";", "}", "else", "{", "throw", "new", "NotSupportedException", "(", "'\"generateId\" is not implemented.'", ")", ";", "}", "}" ]
生成流水号 @return int @throws NotSupportedException
[ "生成流水号" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L59-L76
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.updateAttributesAsync
public function updateAttributesAsync($attributes) { Yii::$app->queue->push(new UpdateActiveRecordAttributesJob([ 'modelClass' => get_called_class(), 'condition' => $this->getPrimaryKey(true), 'attributes' => $attributes, ])); }
php
public function updateAttributesAsync($attributes) { Yii::$app->queue->push(new UpdateActiveRecordAttributesJob([ 'modelClass' => get_called_class(), 'condition' => $this->getPrimaryKey(true), 'attributes' => $attributes, ])); }
[ "public", "function", "updateAttributesAsync", "(", "$", "attributes", ")", "{", "Yii", "::", "$", "app", "->", "queue", "->", "push", "(", "new", "UpdateActiveRecordAttributesJob", "(", "[", "'modelClass'", "=>", "get_called_class", "(", ")", ",", "'condition'", "=>", "$", "this", "->", "getPrimaryKey", "(", "true", ")", ",", "'attributes'", "=>", "$", "attributes", ",", "]", ")", ")", ";", "}" ]
异步更新属性 @param array $attributes @return int|void
[ "异步更新属性" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L93-L100
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.updateCountersAsync
public function updateCountersAsync($counters) { Yii::$app->queue->push(new UpdateActiveRecordCountersJob([ 'modelClass' => get_called_class(), 'condition' => $this->getPrimaryKey(true), 'counters' => $counters, ])); }
php
public function updateCountersAsync($counters) { Yii::$app->queue->push(new UpdateActiveRecordCountersJob([ 'modelClass' => get_called_class(), 'condition' => $this->getPrimaryKey(true), 'counters' => $counters, ])); }
[ "public", "function", "updateCountersAsync", "(", "$", "counters", ")", "{", "Yii", "::", "$", "app", "->", "queue", "->", "push", "(", "new", "UpdateActiveRecordCountersJob", "(", "[", "'modelClass'", "=>", "get_called_class", "(", ")", ",", "'condition'", "=>", "$", "this", "->", "getPrimaryKey", "(", "true", ")", ",", "'counters'", "=>", "$", "counters", ",", "]", ")", ")", ";", "}" ]
异步更新计数器 @param $counters
[ "异步更新计数器" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L106-L113
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.deleteAsync
public function deleteAsync() { Yii::$app->queue->push(new DeleteActiveRecordJob([ 'modelClass' => get_called_class(), 'condition' => $this->getPrimaryKey(true) ])); }
php
public function deleteAsync() { Yii::$app->queue->push(new DeleteActiveRecordJob([ 'modelClass' => get_called_class(), 'condition' => $this->getPrimaryKey(true) ])); }
[ "public", "function", "deleteAsync", "(", ")", "{", "Yii", "::", "$", "app", "->", "queue", "->", "push", "(", "new", "DeleteActiveRecordJob", "(", "[", "'modelClass'", "=>", "get_called_class", "(", ")", ",", "'condition'", "=>", "$", "this", "->", "getPrimaryKey", "(", "true", ")", "]", ")", ")", ";", "}" ]
异步删除
[ "异步删除" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L118-L124
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.create
public static function create(array $attributes, $runValidation = true) { $model = new static(); $model->loadDefaultValues(); $model->load($attributes, ''); $model->save($runValidation); return $model; }
php
public static function create(array $attributes, $runValidation = true) { $model = new static(); $model->loadDefaultValues(); $model->load($attributes, ''); $model->save($runValidation); return $model; }
[ "public", "static", "function", "create", "(", "array", "$", "attributes", ",", "$", "runValidation", "=", "true", ")", "{", "$", "model", "=", "new", "static", "(", ")", ";", "$", "model", "->", "loadDefaultValues", "(", ")", ";", "$", "model", "->", "load", "(", "$", "attributes", ",", "''", ")", ";", "$", "model", "->", "save", "(", "$", "runValidation", ")", ";", "return", "$", "model", ";", "}" ]
快速创建实例 @param array $attributes @param boolean $runValidation @return ActiveRecord
[ "快速创建实例" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L132-L139
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.createAsync
public static function createAsync(array $attributes, $runValidation = true) { if ($runValidation) { $model = new static(); $model->loadDefaultValues(); $model->load($attributes, ''); if (!$model->validate()) { return $model; } } Yii::$app->queue->push(new CreateActiveRecordJob([ 'modelClass' => get_called_class(), 'attributes' => $attributes, 'runValidation' => $runValidation ])); return true; }
php
public static function createAsync(array $attributes, $runValidation = true) { if ($runValidation) { $model = new static(); $model->loadDefaultValues(); $model->load($attributes, ''); if (!$model->validate()) { return $model; } } Yii::$app->queue->push(new CreateActiveRecordJob([ 'modelClass' => get_called_class(), 'attributes' => $attributes, 'runValidation' => $runValidation ])); return true; }
[ "public", "static", "function", "createAsync", "(", "array", "$", "attributes", ",", "$", "runValidation", "=", "true", ")", "{", "if", "(", "$", "runValidation", ")", "{", "$", "model", "=", "new", "static", "(", ")", ";", "$", "model", "->", "loadDefaultValues", "(", ")", ";", "$", "model", "->", "load", "(", "$", "attributes", ",", "''", ")", ";", "if", "(", "!", "$", "model", "->", "validate", "(", ")", ")", "{", "return", "$", "model", ";", "}", "}", "Yii", "::", "$", "app", "->", "queue", "->", "push", "(", "new", "CreateActiveRecordJob", "(", "[", "'modelClass'", "=>", "get_called_class", "(", ")", ",", "'attributes'", "=>", "$", "attributes", ",", "'runValidation'", "=>", "$", "runValidation", "]", ")", ")", ";", "return", "true", ";", "}" ]
快速创建实例 @param array $attributes @param boolean $runValidation @return bool|ActiveRecord
[ "快速创建实例" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L147-L163
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.updateAllAsync
public static function updateAllAsync($attributes, $condition = '', $params = []) { Yii::$app->queue->push(new UpdateActiveRecordAllJob([ 'modelClass' => get_called_class(), 'condition' => $condition, 'attributes' => $attributes, 'params' => $params ])); }
php
public static function updateAllAsync($attributes, $condition = '', $params = []) { Yii::$app->queue->push(new UpdateActiveRecordAllJob([ 'modelClass' => get_called_class(), 'condition' => $condition, 'attributes' => $attributes, 'params' => $params ])); }
[ "public", "static", "function", "updateAllAsync", "(", "$", "attributes", ",", "$", "condition", "=", "''", ",", "$", "params", "=", "[", "]", ")", "{", "Yii", "::", "$", "app", "->", "queue", "->", "push", "(", "new", "UpdateActiveRecordAllJob", "(", "[", "'modelClass'", "=>", "get_called_class", "(", ")", ",", "'condition'", "=>", "$", "condition", ",", "'attributes'", "=>", "$", "attributes", ",", "'params'", "=>", "$", "params", "]", ")", ")", ";", "}" ]
异步更新全表 @param array $attributes @param string|array $condition @param array $params the parameters (name => value) to be bound to the query.
[ "异步更新全表" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L171-L179
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.updateAllCountersAsync
public static function updateAllCountersAsync($counters, $condition = '', $params = []) { Yii::$app->queue->push(new UpdateActiveRecordAllCountersJob([ 'modelClass' => get_called_class(), 'condition' => $condition, 'counters' => $counters, 'params' => $params ])); }
php
public static function updateAllCountersAsync($counters, $condition = '', $params = []) { Yii::$app->queue->push(new UpdateActiveRecordAllCountersJob([ 'modelClass' => get_called_class(), 'condition' => $condition, 'counters' => $counters, 'params' => $params ])); }
[ "public", "static", "function", "updateAllCountersAsync", "(", "$", "counters", ",", "$", "condition", "=", "''", ",", "$", "params", "=", "[", "]", ")", "{", "Yii", "::", "$", "app", "->", "queue", "->", "push", "(", "new", "UpdateActiveRecordAllCountersJob", "(", "[", "'modelClass'", "=>", "get_called_class", "(", ")", ",", "'condition'", "=>", "$", "condition", ",", "'counters'", "=>", "$", "counters", ",", "'params'", "=>", "$", "params", "]", ")", ")", ";", "}" ]
异步更新计数器 @param array $counters @param string $condition @param array $params the parameters (name => value) to be bound to the query.
[ "异步更新计数器" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L187-L195
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.deleteAllAsync
public static function deleteAllAsync($condition = null, $params = []) { Yii::$app->queue->push(new DeleteAllActiveRecordJob([ 'modelClass' => get_called_class(), 'condition' => $condition, 'params' => $params ])); }
php
public static function deleteAllAsync($condition = null, $params = []) { Yii::$app->queue->push(new DeleteAllActiveRecordJob([ 'modelClass' => get_called_class(), 'condition' => $condition, 'params' => $params ])); }
[ "public", "static", "function", "deleteAllAsync", "(", "$", "condition", "=", "null", ",", "$", "params", "=", "[", "]", ")", "{", "Yii", "::", "$", "app", "->", "queue", "->", "push", "(", "new", "DeleteAllActiveRecordJob", "(", "[", "'modelClass'", "=>", "get_called_class", "(", ")", ",", "'condition'", "=>", "$", "condition", ",", "'params'", "=>", "$", "params", "]", ")", ")", ";", "}" ]
异步删除 @param string|array $condition @param array $params
[ "异步删除" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L202-L209
ClanCats/Core
src/classes/CCConfig.php
CCConfig.create
public static function create( $name = null, $driver = 'file' ) { if ( is_null( $name ) ) { return new static( null, $driver ); } if ( !isset( static::$instances[$name] ) ) { static::$instances[$name] = new static( $name, $driver ); } return static::$instances[$name]; }
php
public static function create( $name = null, $driver = 'file' ) { if ( is_null( $name ) ) { return new static( null, $driver ); } if ( !isset( static::$instances[$name] ) ) { static::$instances[$name] = new static( $name, $driver ); } return static::$instances[$name]; }
[ "public", "static", "function", "create", "(", "$", "name", "=", "null", ",", "$", "driver", "=", "'file'", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "new", "static", "(", "null", ",", "$", "driver", ")", ";", "}", "if", "(", "!", "isset", "(", "static", "::", "$", "instances", "[", "$", "name", "]", ")", ")", "{", "static", "::", "$", "instances", "[", "$", "name", "]", "=", "new", "static", "(", "$", "name", ",", "$", "driver", ")", ";", "}", "return", "static", "::", "$", "instances", "[", "$", "name", "]", ";", "}" ]
Create a configuration instance @param string $name @return CCConfig
[ "Create", "a", "configuration", "instance" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L28-L41
ClanCats/Core
src/classes/CCConfig.php
CCConfig.driver
public function driver( $driver ) { $driver = CCCORE_NAMESPACE.'\\'.'CCConfig_'.ucfirst( $driver ); if ( !class_exists( $driver ) ) { throw new \InvalidArgumentException("CCConfig - Invalid driver '".$driver."'"); } $this->_driver = new $driver; }
php
public function driver( $driver ) { $driver = CCCORE_NAMESPACE.'\\'.'CCConfig_'.ucfirst( $driver ); if ( !class_exists( $driver ) ) { throw new \InvalidArgumentException("CCConfig - Invalid driver '".$driver."'"); } $this->_driver = new $driver; }
[ "public", "function", "driver", "(", "$", "driver", ")", "{", "$", "driver", "=", "CCCORE_NAMESPACE", ".", "'\\\\'", ".", "'CCConfig_'", ".", "ucfirst", "(", "$", "driver", ")", ";", "if", "(", "!", "class_exists", "(", "$", "driver", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"CCConfig - Invalid driver '\"", ".", "$", "driver", ".", "\"'\"", ")", ";", "}", "$", "this", "->", "_driver", "=", "new", "$", "driver", ";", "}" ]
Set the configuration dirver @param string $driver @return void
[ "Set", "the", "configuration", "dirver" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L77-L87
ClanCats/Core
src/classes/CCConfig.php
CCConfig.name
public function name( $name = null ) { if ( is_null( $name ) ) { return $this->_instance_name; } $this->_instance_name = $name; }
php
public function name( $name = null ) { if ( is_null( $name ) ) { return $this->_instance_name; } $this->_instance_name = $name; }
[ "public", "function", "name", "(", "$", "name", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "_instance_name", ";", "}", "$", "this", "->", "_instance_name", "=", "$", "name", ";", "}" ]
Name getter and setter @param string $name @return string
[ "Name", "getter", "and", "setter" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L95-L103
ClanCats/Core
src/classes/CCConfig.php
CCConfig.write
public function write( $driver = null ) { if ( empty( $this->_instance_name ) ) { throw new CCException("CCConfig::write - configuration name is missing."); } // set the dirver if ( !is_null( $driver ) ) { $this->driver( $driver ); } // run write $this->_driver->write( $this->_instance_name, $this->_data ); }
php
public function write( $driver = null ) { if ( empty( $this->_instance_name ) ) { throw new CCException("CCConfig::write - configuration name is missing."); } // set the dirver if ( !is_null( $driver ) ) { $this->driver( $driver ); } // run write $this->_driver->write( $this->_instance_name, $this->_data ); }
[ "public", "function", "write", "(", "$", "driver", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_instance_name", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCConfig::write - configuration name is missing.\"", ")", ";", "}", "// set the dirver", "if", "(", "!", "is_null", "(", "$", "driver", ")", ")", "{", "$", "this", "->", "driver", "(", "$", "driver", ")", ";", "}", "// run write", "$", "this", "->", "_driver", "->", "write", "(", "$", "this", "->", "_instance_name", ",", "$", "this", "->", "_data", ")", ";", "}" ]
save a configuration file this method overwrites your configuration file!! @param string $name @return bool
[ "save", "a", "configuration", "file", "this", "method", "overwrites", "your", "configuration", "file!!" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L124-L139
ClanCats/Core
src/classes/CCConfig.php
CCConfig._delete
public function _delete() { if ( empty( $this->_instance_name ) ) { throw new CCException("CCConfig::write - configuration name is missing."); } return $this->_driver->delete( $this->_instance_name ); }
php
public function _delete() { if ( empty( $this->_instance_name ) ) { throw new CCException("CCConfig::write - configuration name is missing."); } return $this->_driver->delete( $this->_instance_name ); }
[ "public", "function", "_delete", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_instance_name", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCConfig::write - configuration name is missing.\"", ")", ";", "}", "return", "$", "this", "->", "_driver", "->", "delete", "(", "$", "this", "->", "_instance_name", ")", ";", "}" ]
Delete the entire configuration Attention with this one he can be evil! @param string $name @return void
[ "Delete", "the", "entire", "configuration", "Attention", "with", "this", "one", "he", "can", "be", "evil!" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L148-L156
dashifen/wordpress-php7-plugin-boilerplate
src/Controller/ControllerTraits/TaxonomiesTrait.php
TaxonomiesTrait.getTaxonomy
final public function getTaxonomy(int $index): string { $taxonomies = $this->getTaxonomies(); if ($index >= sizeof($taxonomies)) { throw new ControllerException("Unknown taxonomy", ControllerException::UNKNOWN_TAX); } return $taxonomies[$index]; }
php
final public function getTaxonomy(int $index): string { $taxonomies = $this->getTaxonomies(); if ($index >= sizeof($taxonomies)) { throw new ControllerException("Unknown taxonomy", ControllerException::UNKNOWN_TAX); } return $taxonomies[$index]; }
[ "final", "public", "function", "getTaxonomy", "(", "int", "$", "index", ")", ":", "string", "{", "$", "taxonomies", "=", "$", "this", "->", "getTaxonomies", "(", ")", ";", "if", "(", "$", "index", ">=", "sizeof", "(", "$", "taxonomies", ")", ")", "{", "throw", "new", "ControllerException", "(", "\"Unknown taxonomy\"", ",", "ControllerException", "::", "UNKNOWN_TAX", ")", ";", "}", "return", "$", "taxonomies", "[", "$", "index", "]", ";", "}" ]
Given an index, return that taxonomy from the list of taxonomies provided by getTaxonomies(). It is recommended to specify a const value for each taxonomy to avoid errors. @param int $index @return string @throws ControllerException
[ "Given", "an", "index", "return", "that", "taxonomy", "from", "the", "list", "of", "taxonomies", "provided", "by", "getTaxonomies", "()", ".", "It", "is", "recommended", "to", "specify", "a", "const", "value", "for", "each", "taxonomy", "to", "avoid", "errors", "." ]
train
https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Controller/ControllerTraits/TaxonomiesTrait.php#L26-L34
dashifen/wordpress-php7-plugin-boilerplate
src/Controller/ControllerTraits/TaxonomiesTrait.php
TaxonomiesTrait.initTaxonomiesTrait
final protected function initTaxonomiesTrait(): void { // notice that this action is added at the 15th priority. since // taxonomies and post types are used in conjuction with each other, // we want to be sure that our types are registered before we start // to link taxonomies to them. so, the PostTypesTrait leaves its // registration at priority 10. then, this init action will process // at 15. add_action("init", function () { foreach ($this->getTaxonomies() as $taxonomy) { $this->registerTaxonomy($taxonomy); } }, 15); }
php
final protected function initTaxonomiesTrait(): void { // notice that this action is added at the 15th priority. since // taxonomies and post types are used in conjuction with each other, // we want to be sure that our types are registered before we start // to link taxonomies to them. so, the PostTypesTrait leaves its // registration at priority 10. then, this init action will process // at 15. add_action("init", function () { foreach ($this->getTaxonomies() as $taxonomy) { $this->registerTaxonomy($taxonomy); } }, 15); }
[ "final", "protected", "function", "initTaxonomiesTrait", "(", ")", ":", "void", "{", "// notice that this action is added at the 15th priority. since", "// taxonomies and post types are used in conjuction with each other,", "// we want to be sure that our types are registered before we start", "// to link taxonomies to them. so, the PostTypesTrait leaves its", "// registration at priority 10. then, this init action will process", "// at 15.", "add_action", "(", "\"init\"", ",", "function", "(", ")", "{", "foreach", "(", "$", "this", "->", "getTaxonomies", "(", ")", "as", "$", "taxonomy", ")", "{", "$", "this", "->", "registerTaxonomy", "(", "$", "taxonomy", ")", ";", "}", "}", ",", "15", ")", ";", "}" ]
Initializes this trait and registers these taxonomies using the appropriate WordPress action hook. @return void
[ "Initializes", "this", "trait", "and", "registers", "these", "taxonomies", "using", "the", "appropriate", "WordPress", "action", "hook", "." ]
train
https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Controller/ControllerTraits/TaxonomiesTrait.php#L84-L98
dashifen/wordpress-php7-plugin-boilerplate
src/Controller/ControllerTraits/TaxonomiesTrait.php
TaxonomiesTrait.registerTaxonomy
final public function registerTaxonomy(string $taxonomy): void { // this method is public since it's likely that the Activator of a // plugin will want to register taxonomies and then flush the rewrite // rules to update permalinks. $args = $this->getTaxonomyArgs($taxonomy); $args["labels"] = $this->getTaxonomyLabels($taxonomy); $args["rewrite"] = $this->getTaxonomyRewrite($taxonomy); register_taxonomy($taxonomy, $this->getTaxonomyTypes($taxonomy), $args); }
php
final public function registerTaxonomy(string $taxonomy): void { // this method is public since it's likely that the Activator of a // plugin will want to register taxonomies and then flush the rewrite // rules to update permalinks. $args = $this->getTaxonomyArgs($taxonomy); $args["labels"] = $this->getTaxonomyLabels($taxonomy); $args["rewrite"] = $this->getTaxonomyRewrite($taxonomy); register_taxonomy($taxonomy, $this->getTaxonomyTypes($taxonomy), $args); }
[ "final", "public", "function", "registerTaxonomy", "(", "string", "$", "taxonomy", ")", ":", "void", "{", "// this method is public since it's likely that the Activator of a", "// plugin will want to register taxonomies and then flush the rewrite", "// rules to update permalinks.", "$", "args", "=", "$", "this", "->", "getTaxonomyArgs", "(", "$", "taxonomy", ")", ";", "$", "args", "[", "\"labels\"", "]", "=", "$", "this", "->", "getTaxonomyLabels", "(", "$", "taxonomy", ")", ";", "$", "args", "[", "\"rewrite\"", "]", "=", "$", "this", "->", "getTaxonomyRewrite", "(", "$", "taxonomy", ")", ";", "register_taxonomy", "(", "$", "taxonomy", ",", "$", "this", "->", "getTaxonomyTypes", "(", "$", "taxonomy", ")", ",", "$", "args", ")", ";", "}" ]
Given the the name of a taxonomy, accumulates the arguments for the WordPress register_taxonomy() function and then calls it. @param string $taxonomy @return void
[ "Given", "the", "the", "name", "of", "a", "taxonomy", "accumulates", "the", "arguments", "for", "the", "WordPress", "register_taxonomy", "()", "function", "and", "then", "calls", "it", "." ]
train
https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Controller/ControllerTraits/TaxonomiesTrait.php#L108-L119
yuncms/framework
migrations/m180210_111034_create_cache_table.php
m180210_111034_create_cache_table.safeUp
public function safeUp() { $tableOptions = null; if ($this->db->driverName === 'mysql') { // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; } $this->createTable($this->tableName, [ 'id' => $this->string(128)->notNull(), 'expire' => $this->integer(), 'data' => $this->binary(), 'PRIMARY KEY ([[id]])', ], $tableOptions); }
php
public function safeUp() { $tableOptions = null; if ($this->db->driverName === 'mysql') { // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; } $this->createTable($this->tableName, [ 'id' => $this->string(128)->notNull(), 'expire' => $this->integer(), 'data' => $this->binary(), 'PRIMARY KEY ([[id]])', ], $tableOptions); }
[ "public", "function", "safeUp", "(", ")", "{", "$", "tableOptions", "=", "null", ";", "if", "(", "$", "this", "->", "db", "->", "driverName", "===", "'mysql'", ")", "{", "// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci", "$", "tableOptions", "=", "'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'", ";", "}", "$", "this", "->", "createTable", "(", "$", "this", "->", "tableName", ",", "[", "'id'", "=>", "$", "this", "->", "string", "(", "128", ")", "->", "notNull", "(", ")", ",", "'expire'", "=>", "$", "this", "->", "integer", "(", ")", ",", "'data'", "=>", "$", "this", "->", "binary", "(", ")", ",", "'PRIMARY KEY ([[id]])'", ",", "]", ",", "$", "tableOptions", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/migrations/m180210_111034_create_cache_table.php#L18-L32
ppetermann/king23
src/Mongo/MongoObject.php
MongoObject.refresh
public function refresh() { if ($data = $this->myCollection->findOne(['_id' => $this->myData['_id']])) { $this->myData = $data; } }
php
public function refresh() { if ($data = $this->myCollection->findOne(['_id' => $this->myData['_id']])) { $this->myData = $data; } }
[ "public", "function", "refresh", "(", ")", "{", "if", "(", "$", "data", "=", "$", "this", "->", "myCollection", "->", "findOne", "(", "[", "'_id'", "=>", "$", "this", "->", "myData", "[", "'_id'", "]", "]", ")", ")", "{", "$", "this", "->", "myData", "=", "$", "data", ";", "}", "}" ]
refreshes object from database (all changes be lost!) @return void
[ "refreshes", "object", "from", "database", "(", "all", "changes", "be", "lost!", ")" ]
train
https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Mongo/MongoObject.php#L122-L127
VincentChalnot/SidusEAVFilterBundle
Filter/Type/ChoiceFilterType.php
ChoiceFilterType.getFormOptions
public function getFormOptions(QueryHandlerInterface $queryHandler, FilterInterface $filter): array { if (!$queryHandler instanceof EAVQueryHandlerInterface) { throw new BadQueryHandlerException($queryHandler, EAVQueryHandlerInterface::class); } if (!$queryHandler->isEAVFilter($filter)) { return $this->fallbackFilterType->getFormOptions($queryHandler, $filter); } if (isset($filter->getFormOptions()['choices'])) { return parent::getFormOptions($queryHandler, $filter); } $choices = []; $attributes = $queryHandler->getEAVAttributes($filter); foreach ($attributes as $attribute) { /** @noinspection SlowArrayOperationsInLoopInspection */ $choices = array_merge($choices, $attribute->getFormOptions()['choices'] ?? []); } $formOptions = [ 'choices' => $choices, ]; if (1 === \count($attributes)) { /** @noinspection PhpUndefinedVariableInspection */ $attributeFormOptions = $attribute->getFormOptions(); if (array_key_exists('choice_translation_domain', $attributeFormOptions)) { $formOptions['choice_translation_domain'] = $attributeFormOptions['choice_translation_domain']; } } return array_merge( $this->getDefaultFormOptions($queryHandler, $filter), $formOptions, $filter->getFormOptions() ); }
php
public function getFormOptions(QueryHandlerInterface $queryHandler, FilterInterface $filter): array { if (!$queryHandler instanceof EAVQueryHandlerInterface) { throw new BadQueryHandlerException($queryHandler, EAVQueryHandlerInterface::class); } if (!$queryHandler->isEAVFilter($filter)) { return $this->fallbackFilterType->getFormOptions($queryHandler, $filter); } if (isset($filter->getFormOptions()['choices'])) { return parent::getFormOptions($queryHandler, $filter); } $choices = []; $attributes = $queryHandler->getEAVAttributes($filter); foreach ($attributes as $attribute) { /** @noinspection SlowArrayOperationsInLoopInspection */ $choices = array_merge($choices, $attribute->getFormOptions()['choices'] ?? []); } $formOptions = [ 'choices' => $choices, ]; if (1 === \count($attributes)) { /** @noinspection PhpUndefinedVariableInspection */ $attributeFormOptions = $attribute->getFormOptions(); if (array_key_exists('choice_translation_domain', $attributeFormOptions)) { $formOptions['choice_translation_domain'] = $attributeFormOptions['choice_translation_domain']; } } return array_merge( $this->getDefaultFormOptions($queryHandler, $filter), $formOptions, $filter->getFormOptions() ); }
[ "public", "function", "getFormOptions", "(", "QueryHandlerInterface", "$", "queryHandler", ",", "FilterInterface", "$", "filter", ")", ":", "array", "{", "if", "(", "!", "$", "queryHandler", "instanceof", "EAVQueryHandlerInterface", ")", "{", "throw", "new", "BadQueryHandlerException", "(", "$", "queryHandler", ",", "EAVQueryHandlerInterface", "::", "class", ")", ";", "}", "if", "(", "!", "$", "queryHandler", "->", "isEAVFilter", "(", "$", "filter", ")", ")", "{", "return", "$", "this", "->", "fallbackFilterType", "->", "getFormOptions", "(", "$", "queryHandler", ",", "$", "filter", ")", ";", "}", "if", "(", "isset", "(", "$", "filter", "->", "getFormOptions", "(", ")", "[", "'choices'", "]", ")", ")", "{", "return", "parent", "::", "getFormOptions", "(", "$", "queryHandler", ",", "$", "filter", ")", ";", "}", "$", "choices", "=", "[", "]", ";", "$", "attributes", "=", "$", "queryHandler", "->", "getEAVAttributes", "(", "$", "filter", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "/** @noinspection SlowArrayOperationsInLoopInspection */", "$", "choices", "=", "array_merge", "(", "$", "choices", ",", "$", "attribute", "->", "getFormOptions", "(", ")", "[", "'choices'", "]", "??", "[", "]", ")", ";", "}", "$", "formOptions", "=", "[", "'choices'", "=>", "$", "choices", ",", "]", ";", "if", "(", "1", "===", "\\", "count", "(", "$", "attributes", ")", ")", "{", "/** @noinspection PhpUndefinedVariableInspection */", "$", "attributeFormOptions", "=", "$", "attribute", "->", "getFormOptions", "(", ")", ";", "if", "(", "array_key_exists", "(", "'choice_translation_domain'", ",", "$", "attributeFormOptions", ")", ")", "{", "$", "formOptions", "[", "'choice_translation_domain'", "]", "=", "$", "attributeFormOptions", "[", "'choice_translation_domain'", "]", ";", "}", "}", "return", "array_merge", "(", "$", "this", "->", "getDefaultFormOptions", "(", "$", "queryHandler", ",", "$", "filter", ")", ",", "$", "formOptions", ",", "$", "filter", "->", "getFormOptions", "(", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Filter/Type/ChoiceFilterType.php#L19-L55
VincentChalnot/SidusEAVFilterBundle
Filter/Type/ChoiceFilterType.php
ChoiceFilterType.applyAttributeQueryBuilder
protected function applyAttributeQueryBuilder( AttributeQueryBuilderInterface $attributeQb, $data ): AttributeQueryBuilderInterface { if (\is_array($data)) { return $attributeQb->in($data); } return $attributeQb->equals($data); }
php
protected function applyAttributeQueryBuilder( AttributeQueryBuilderInterface $attributeQb, $data ): AttributeQueryBuilderInterface { if (\is_array($data)) { return $attributeQb->in($data); } return $attributeQb->equals($data); }
[ "protected", "function", "applyAttributeQueryBuilder", "(", "AttributeQueryBuilderInterface", "$", "attributeQb", ",", "$", "data", ")", ":", "AttributeQueryBuilderInterface", "{", "if", "(", "\\", "is_array", "(", "$", "data", ")", ")", "{", "return", "$", "attributeQb", "->", "in", "(", "$", "data", ")", ";", "}", "return", "$", "attributeQb", "->", "equals", "(", "$", "data", ")", ";", "}" ]
@param AttributeQueryBuilderInterface $attributeQb @param mixed $data @return AttributeQueryBuilderInterface
[ "@param", "AttributeQueryBuilderInterface", "$attributeQb", "@param", "mixed", "$data" ]
train
https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Filter/Type/ChoiceFilterType.php#L63-L72
fyuze/framework
src/Fyuze/Routing/Matcher.php
Matcher.compileRegex
public function compileRegex() { $route = $this->route->getUri(); if (strpos($route, '?')) { $route = preg_replace('@\/{([\w]+)\?}@', '(?:/{$1})?', $route); } $route = preg_replace('/{([a-z0-9_-]+)}/i', '(?P<$1>[^/]+)', $route); if(substr($route, -1) === '/') { $route .= '?'; } return "%^{$route}$%s"; }
php
public function compileRegex() { $route = $this->route->getUri(); if (strpos($route, '?')) { $route = preg_replace('@\/{([\w]+)\?}@', '(?:/{$1})?', $route); } $route = preg_replace('/{([a-z0-9_-]+)}/i', '(?P<$1>[^/]+)', $route); if(substr($route, -1) === '/') { $route .= '?'; } return "%^{$route}$%s"; }
[ "public", "function", "compileRegex", "(", ")", "{", "$", "route", "=", "$", "this", "->", "route", "->", "getUri", "(", ")", ";", "if", "(", "strpos", "(", "$", "route", ",", "'?'", ")", ")", "{", "$", "route", "=", "preg_replace", "(", "'@\\/{([\\w]+)\\?}@'", ",", "'(?:/{$1})?'", ",", "$", "route", ")", ";", "}", "$", "route", "=", "preg_replace", "(", "'/{([a-z0-9_-]+)}/i'", ",", "'(?P<$1>[^/]+)'", ",", "$", "route", ")", ";", "if", "(", "substr", "(", "$", "route", ",", "-", "1", ")", "===", "'/'", ")", "{", "$", "route", ".=", "'?'", ";", "}", "return", "\"%^{$route}$%s\"", ";", "}" ]
Returns the regex needed to match the route. @access public @return string
[ "Returns", "the", "regex", "needed", "to", "match", "the", "route", "." ]
train
https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Routing/Matcher.php#L55-L70
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Relations/HasManyThrough.php
HasManyThrough.setDefaultOptions
protected function setDefaultOptions(array $options=[]) { if (isset($options['intermediate_model'])) { $intermediateModel = $options['intermediate_model']; } else { $this->text['intermediate_text'] = "[".$this->command->paintString('intermediate model' ,'brown')."]"; $intermediateModel = $this->manager->getModel( $this->command->choice("Choice {$this->text['intermediate_text']} of both relation!", $this->manager->getModels()->keys()->toArray()) ); } $this->defaultOptions = [ 'intermediate_model' => $intermediateModel, 'first_key' => $this->model->getForeignKey(), 'second_key' => $intermediateModel->getForeignKey(), 'primary_key' => $this->model->getKeyName() ]; }
php
protected function setDefaultOptions(array $options=[]) { if (isset($options['intermediate_model'])) { $intermediateModel = $options['intermediate_model']; } else { $this->text['intermediate_text'] = "[".$this->command->paintString('intermediate model' ,'brown')."]"; $intermediateModel = $this->manager->getModel( $this->command->choice("Choice {$this->text['intermediate_text']} of both relation!", $this->manager->getModels()->keys()->toArray()) ); } $this->defaultOptions = [ 'intermediate_model' => $intermediateModel, 'first_key' => $this->model->getForeignKey(), 'second_key' => $intermediateModel->getForeignKey(), 'primary_key' => $this->model->getKeyName() ]; }
[ "protected", "function", "setDefaultOptions", "(", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'intermediate_model'", "]", ")", ")", "{", "$", "intermediateModel", "=", "$", "options", "[", "'intermediate_model'", "]", ";", "}", "else", "{", "$", "this", "->", "text", "[", "'intermediate_text'", "]", "=", "\"[\"", ".", "$", "this", "->", "command", "->", "paintString", "(", "'intermediate model'", ",", "'brown'", ")", ".", "\"]\"", ";", "$", "intermediateModel", "=", "$", "this", "->", "manager", "->", "getModel", "(", "$", "this", "->", "command", "->", "choice", "(", "\"Choice {$this->text['intermediate_text']} of both relation!\"", ",", "$", "this", "->", "manager", "->", "getModels", "(", ")", "->", "keys", "(", ")", "->", "toArray", "(", ")", ")", ")", ";", "}", "$", "this", "->", "defaultOptions", "=", "[", "'intermediate_model'", "=>", "$", "intermediateModel", ",", "'first_key'", "=>", "$", "this", "->", "model", "->", "getForeignKey", "(", ")", ",", "'second_key'", "=>", "$", "intermediateModel", "->", "getForeignKey", "(", ")", ",", "'primary_key'", "=>", "$", "this", "->", "model", "->", "getKeyName", "(", ")", "]", ";", "}" ]
set default options @param array $options @return void
[ "set", "default", "options" ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Relations/HasManyThrough.php#L16-L34
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Relations/HasManyThrough.php
HasManyThrough.stylingText
protected function stylingText() { $this->text['first_key'] = "[".$this->command->paintString($this->defaultOptions['first_key'] ,'green')."]"; $this->text['second_key'] = "[".$this->command->paintString($this->defaultOptions['second_key'] ,'green')."]"; $this->text['primary_key'] = "[".$this->command->paintString($this->defaultOptions['primary_key'] ,'green')."]"; $this->text['model_table'] = "[".$this->command->paintString($this->model->getTable() ,'green')."]"; $this->text['to_model_table'] = "[".$this->command->paintString($this->toModel->getTable() ,'green')."]"; $this->text['intermediate_model_table'] = "[".$this->command->paintString($this->defaultOptions['intermediate_model']->getTable() ,'green')."]"; $this->text['foreign_text'] = $this->command->paintString('foreign key', 'brown'); $this->text['primary_text'] = $this->command->paintString('primary key', 'brown'); }
php
protected function stylingText() { $this->text['first_key'] = "[".$this->command->paintString($this->defaultOptions['first_key'] ,'green')."]"; $this->text['second_key'] = "[".$this->command->paintString($this->defaultOptions['second_key'] ,'green')."]"; $this->text['primary_key'] = "[".$this->command->paintString($this->defaultOptions['primary_key'] ,'green')."]"; $this->text['model_table'] = "[".$this->command->paintString($this->model->getTable() ,'green')."]"; $this->text['to_model_table'] = "[".$this->command->paintString($this->toModel->getTable() ,'green')."]"; $this->text['intermediate_model_table'] = "[".$this->command->paintString($this->defaultOptions['intermediate_model']->getTable() ,'green')."]"; $this->text['foreign_text'] = $this->command->paintString('foreign key', 'brown'); $this->text['primary_text'] = $this->command->paintString('primary key', 'brown'); }
[ "protected", "function", "stylingText", "(", ")", "{", "$", "this", "->", "text", "[", "'first_key'", "]", "=", "\"[\"", ".", "$", "this", "->", "command", "->", "paintString", "(", "$", "this", "->", "defaultOptions", "[", "'first_key'", "]", ",", "'green'", ")", ".", "\"]\"", ";", "$", "this", "->", "text", "[", "'second_key'", "]", "=", "\"[\"", ".", "$", "this", "->", "command", "->", "paintString", "(", "$", "this", "->", "defaultOptions", "[", "'second_key'", "]", ",", "'green'", ")", ".", "\"]\"", ";", "$", "this", "->", "text", "[", "'primary_key'", "]", "=", "\"[\"", ".", "$", "this", "->", "command", "->", "paintString", "(", "$", "this", "->", "defaultOptions", "[", "'primary_key'", "]", ",", "'green'", ")", ".", "\"]\"", ";", "$", "this", "->", "text", "[", "'model_table'", "]", "=", "\"[\"", ".", "$", "this", "->", "command", "->", "paintString", "(", "$", "this", "->", "model", "->", "getTable", "(", ")", ",", "'green'", ")", ".", "\"]\"", ";", "$", "this", "->", "text", "[", "'to_model_table'", "]", "=", "\"[\"", ".", "$", "this", "->", "command", "->", "paintString", "(", "$", "this", "->", "toModel", "->", "getTable", "(", ")", ",", "'green'", ")", ".", "\"]\"", ";", "$", "this", "->", "text", "[", "'intermediate_model_table'", "]", "=", "\"[\"", ".", "$", "this", "->", "command", "->", "paintString", "(", "$", "this", "->", "defaultOptions", "[", "'intermediate_model'", "]", "->", "getTable", "(", ")", ",", "'green'", ")", ".", "\"]\"", ";", "$", "this", "->", "text", "[", "'foreign_text'", "]", "=", "$", "this", "->", "command", "->", "paintString", "(", "'foreign key'", ",", "'brown'", ")", ";", "$", "this", "->", "text", "[", "'primary_text'", "]", "=", "$", "this", "->", "command", "->", "paintString", "(", "'primary key'", ",", "'brown'", ")", ";", "}" ]
styling text @return void
[ "styling", "text" ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Relations/HasManyThrough.php#L41-L51
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Relations/HasManyThrough.php
HasManyThrough.setConnectedRelationOptions
protected function setConnectedRelationOptions() { $intermediateModel = $this->defaultOptions['intermediate_model']; if (! $this->db->isTableExists($intermediateModel->getTable())) { throw new TableNotExists($intermediateModel->getTable(), get_class($intermediateModel)); } if (! $this->db->isFieldExists($table = $intermediateModel->getTable(), $this->defaultOptions['first_key'])) { $this->options['first_key'] = $this->command->choice( "Can't find field {$this->text['first_key']} in the table {$this->text['intermediate_model_table']} as {$this->text['foreign_text']} of table {$this->text['model_table']}, choice one!", $this->getFields($table) ); } if (! $this->db->isFieldExists($table = $this->toModel->getTable(), $this->defaultOptions['second_key'])) { $this->options['second_key'] = $this->command->choice( "Can't find field {$this->text['second_key']} in the table {$this->text['to_model_table']} as {$this->text['foreign_text']} of table {$this->text['intermediate_model_table']}, choice one!", $this->getFields($table) ); } if (! $this->db->isFieldExists($table = $this->model->getTable(), $primaryKey = $this->defaultOptions['primary_key'])) { $this->options['primary_key'] = $this->command->choice( "Can't find field {$this->text['primary_key']} in the table {$this->text['model_table']} as {$this->text['primary_text']}, choice one!", $this->getFields($table) ); } }
php
protected function setConnectedRelationOptions() { $intermediateModel = $this->defaultOptions['intermediate_model']; if (! $this->db->isTableExists($intermediateModel->getTable())) { throw new TableNotExists($intermediateModel->getTable(), get_class($intermediateModel)); } if (! $this->db->isFieldExists($table = $intermediateModel->getTable(), $this->defaultOptions['first_key'])) { $this->options['first_key'] = $this->command->choice( "Can't find field {$this->text['first_key']} in the table {$this->text['intermediate_model_table']} as {$this->text['foreign_text']} of table {$this->text['model_table']}, choice one!", $this->getFields($table) ); } if (! $this->db->isFieldExists($table = $this->toModel->getTable(), $this->defaultOptions['second_key'])) { $this->options['second_key'] = $this->command->choice( "Can't find field {$this->text['second_key']} in the table {$this->text['to_model_table']} as {$this->text['foreign_text']} of table {$this->text['intermediate_model_table']}, choice one!", $this->getFields($table) ); } if (! $this->db->isFieldExists($table = $this->model->getTable(), $primaryKey = $this->defaultOptions['primary_key'])) { $this->options['primary_key'] = $this->command->choice( "Can't find field {$this->text['primary_key']} in the table {$this->text['model_table']} as {$this->text['primary_text']}, choice one!", $this->getFields($table) ); } }
[ "protected", "function", "setConnectedRelationOptions", "(", ")", "{", "$", "intermediateModel", "=", "$", "this", "->", "defaultOptions", "[", "'intermediate_model'", "]", ";", "if", "(", "!", "$", "this", "->", "db", "->", "isTableExists", "(", "$", "intermediateModel", "->", "getTable", "(", ")", ")", ")", "{", "throw", "new", "TableNotExists", "(", "$", "intermediateModel", "->", "getTable", "(", ")", ",", "get_class", "(", "$", "intermediateModel", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "db", "->", "isFieldExists", "(", "$", "table", "=", "$", "intermediateModel", "->", "getTable", "(", ")", ",", "$", "this", "->", "defaultOptions", "[", "'first_key'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'first_key'", "]", "=", "$", "this", "->", "command", "->", "choice", "(", "\"Can't find field {$this->text['first_key']} in the table {$this->text['intermediate_model_table']} as {$this->text['foreign_text']} of table {$this->text['model_table']}, choice one!\"", ",", "$", "this", "->", "getFields", "(", "$", "table", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "db", "->", "isFieldExists", "(", "$", "table", "=", "$", "this", "->", "toModel", "->", "getTable", "(", ")", ",", "$", "this", "->", "defaultOptions", "[", "'second_key'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'second_key'", "]", "=", "$", "this", "->", "command", "->", "choice", "(", "\"Can't find field {$this->text['second_key']} in the table {$this->text['to_model_table']} as {$this->text['foreign_text']} of table {$this->text['intermediate_model_table']}, choice one!\"", ",", "$", "this", "->", "getFields", "(", "$", "table", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "db", "->", "isFieldExists", "(", "$", "table", "=", "$", "this", "->", "model", "->", "getTable", "(", ")", ",", "$", "primaryKey", "=", "$", "this", "->", "defaultOptions", "[", "'primary_key'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'primary_key'", "]", "=", "$", "this", "->", "command", "->", "choice", "(", "\"Can't find field {$this->text['primary_key']} in the table {$this->text['model_table']} as {$this->text['primary_text']}, choice one!\"", ",", "$", "this", "->", "getFields", "(", "$", "table", ")", ")", ";", "}", "}" ]
set connected db relation options @return void
[ "set", "connected", "db", "relation", "options" ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Relations/HasManyThrough.php#L58-L86
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Relations/HasManyThrough.php
HasManyThrough.askToUseCustomeOptions
protected function askToUseCustomeOptions() { $intermediateModel = $this->defaultOptions['intermediate_model']; $this->options['first_key'] = $this->command->ask( "The {$this->text['foreign_text']} of table {$this->text['model_table']} in the table {$this->text['intermediate_model_table']} will be?", $this->defaultOptions['first_key'] ); $this->options['second_key'] = $this->command->ask( "The {$this->text['foreign_text']} of table {$this->text['intermediate_model_table']} in the table {$this->text['model_table']} will be?", $this->defaultOptions['second_key'] ); $this->options['primary_key'] = $this->command->ask( "The {$this->text['primary_text']} of table {$this->text['model_table']} will be?", $this->defaultOptions['primary_key'] ); }
php
protected function askToUseCustomeOptions() { $intermediateModel = $this->defaultOptions['intermediate_model']; $this->options['first_key'] = $this->command->ask( "The {$this->text['foreign_text']} of table {$this->text['model_table']} in the table {$this->text['intermediate_model_table']} will be?", $this->defaultOptions['first_key'] ); $this->options['second_key'] = $this->command->ask( "The {$this->text['foreign_text']} of table {$this->text['intermediate_model_table']} in the table {$this->text['model_table']} will be?", $this->defaultOptions['second_key'] ); $this->options['primary_key'] = $this->command->ask( "The {$this->text['primary_text']} of table {$this->text['model_table']} will be?", $this->defaultOptions['primary_key'] ); }
[ "protected", "function", "askToUseCustomeOptions", "(", ")", "{", "$", "intermediateModel", "=", "$", "this", "->", "defaultOptions", "[", "'intermediate_model'", "]", ";", "$", "this", "->", "options", "[", "'first_key'", "]", "=", "$", "this", "->", "command", "->", "ask", "(", "\"The {$this->text['foreign_text']} of table {$this->text['model_table']} in the table {$this->text['intermediate_model_table']} will be?\"", ",", "$", "this", "->", "defaultOptions", "[", "'first_key'", "]", ")", ";", "$", "this", "->", "options", "[", "'second_key'", "]", "=", "$", "this", "->", "command", "->", "ask", "(", "\"The {$this->text['foreign_text']} of table {$this->text['intermediate_model_table']} in the table {$this->text['model_table']} will be?\"", ",", "$", "this", "->", "defaultOptions", "[", "'second_key'", "]", ")", ";", "$", "this", "->", "options", "[", "'primary_key'", "]", "=", "$", "this", "->", "command", "->", "ask", "(", "\"The {$this->text['primary_text']} of table {$this->text['model_table']} will be?\"", ",", "$", "this", "->", "defaultOptions", "[", "'primary_key'", "]", ")", ";", "}" ]
ask to use custome options @return void
[ "ask", "to", "use", "custome", "options" ]
train
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Relations/HasManyThrough.php#L120-L139