repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
wenbinye/PhalconX
src/Php/ClassHierarchy.php
ClassHierarchy.getImplements
public function getImplements($class) { $interfaces = []; $classId = $this->getClassId($class); if (isset($classId)) { if (isset($this->implements[$classId])) { foreach ($this->implements[$classId] as $interfaceId) { $interfaces[$this->interfaces[$interfaceId]] = 1; } } foreach ($this->getAncestors($class) as $parent) { foreach ($this->getImplements($parent) as $interface) { $interfaces[$interface] = 1; } } } return array_keys($interfaces); }
php
public function getImplements($class) { $interfaces = []; $classId = $this->getClassId($class); if (isset($classId)) { if (isset($this->implements[$classId])) { foreach ($this->implements[$classId] as $interfaceId) { $interfaces[$this->interfaces[$interfaceId]] = 1; } } foreach ($this->getAncestors($class) as $parent) { foreach ($this->getImplements($parent) as $interface) { $interfaces[$interface] = 1; } } } return array_keys($interfaces); }
[ "public", "function", "getImplements", "(", "$", "class", ")", "{", "$", "interfaces", "=", "[", "]", ";", "$", "classId", "=", "$", "this", "->", "getClassId", "(", "$", "class", ")", ";", "if", "(", "isset", "(", "$", "classId", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "implements", "[", "$", "classId", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "implements", "[", "$", "classId", "]", "as", "$", "interfaceId", ")", "{", "$", "interfaces", "[", "$", "this", "->", "interfaces", "[", "$", "interfaceId", "]", "]", "=", "1", ";", "}", "}", "foreach", "(", "$", "this", "->", "getAncestors", "(", "$", "class", ")", "as", "$", "parent", ")", "{", "foreach", "(", "$", "this", "->", "getImplements", "(", "$", "parent", ")", "as", "$", "interface", ")", "{", "$", "interfaces", "[", "$", "interface", "]", "=", "1", ";", "}", "}", "}", "return", "array_keys", "(", "$", "interfaces", ")", ";", "}" ]
gets implemented interfaces @param string $class @return array|false
[ "gets", "implemented", "interfaces" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L152-L169
wenbinye/PhalconX
src/Php/ClassHierarchy.php
ClassHierarchy.isA
public function isA($class, $test_class) { $test_class = $this->normalize($test_class); if ($this->classExists($test_class)) { return in_array($test_class, $this->getAncestors($class)); } elseif ($this->interfaceExists($test_class)) { return in_array($test_class, $this->getImplements($class)); } else { throw new ClassNotExistException($test_class); } }
php
public function isA($class, $test_class) { $test_class = $this->normalize($test_class); if ($this->classExists($test_class)) { return in_array($test_class, $this->getAncestors($class)); } elseif ($this->interfaceExists($test_class)) { return in_array($test_class, $this->getImplements($class)); } else { throw new ClassNotExistException($test_class); } }
[ "public", "function", "isA", "(", "$", "class", ",", "$", "test_class", ")", "{", "$", "test_class", "=", "$", "this", "->", "normalize", "(", "$", "test_class", ")", ";", "if", "(", "$", "this", "->", "classExists", "(", "$", "test_class", ")", ")", "{", "return", "in_array", "(", "$", "test_class", ",", "$", "this", "->", "getAncestors", "(", "$", "class", ")", ")", ";", "}", "elseif", "(", "$", "this", "->", "interfaceExists", "(", "$", "test_class", ")", ")", "{", "return", "in_array", "(", "$", "test_class", ",", "$", "this", "->", "getImplements", "(", "$", "class", ")", ")", ";", "}", "else", "{", "throw", "new", "ClassNotExistException", "(", "$", "test_class", ")", ";", "}", "}" ]
checks the class is subclass or implements the test class @param string $class @param string $test_class class or interface name @return boolean
[ "checks", "the", "class", "is", "subclass", "or", "implements", "the", "test", "class" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L202-L212
wenbinye/PhalconX
src/Php/ClassHierarchy.php
ClassHierarchy.getSubClasses
public function getSubClasses($class) { $class = $this->normalize($class); if ($this->classExists($class)) { return $this->getSubclassOfClass($class); } elseif ($this->interfaceExists($class)) { return $this->getSubclassOfInterface($class); } else { throw new ClassNotExistException($class); } }
php
public function getSubClasses($class) { $class = $this->normalize($class); if ($this->classExists($class)) { return $this->getSubclassOfClass($class); } elseif ($this->interfaceExists($class)) { return $this->getSubclassOfInterface($class); } else { throw new ClassNotExistException($class); } }
[ "public", "function", "getSubClasses", "(", "$", "class", ")", "{", "$", "class", "=", "$", "this", "->", "normalize", "(", "$", "class", ")", ";", "if", "(", "$", "this", "->", "classExists", "(", "$", "class", ")", ")", "{", "return", "$", "this", "->", "getSubclassOfClass", "(", "$", "class", ")", ";", "}", "elseif", "(", "$", "this", "->", "interfaceExists", "(", "$", "class", ")", ")", "{", "return", "$", "this", "->", "getSubclassOfInterface", "(", "$", "class", ")", ";", "}", "else", "{", "throw", "new", "ClassNotExistException", "(", "$", "class", ")", ";", "}", "}" ]
gets all subclass of the class or interface @param string $class @return array
[ "gets", "all", "subclass", "of", "the", "class", "or", "interface" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L220-L230
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/Commands/LaravelSeederOnlyCommand.php
LaravelSeederOnlyCommand.fire
public function fire() { if ($this->option('files') != '') { $seeder = $this->getLaravelSeeder(); $seeder->only($this->option('files')); $this->call('db:seed'); $seeder->restore(); if ($seeder->getSeeded() == 0) { $this->info('No seeders were ran!'); } } else { throw new \InvalidArgumentException('The "--files" option is required.'); } }
php
public function fire() { if ($this->option('files') != '') { $seeder = $this->getLaravelSeeder(); $seeder->only($this->option('files')); $this->call('db:seed'); $seeder->restore(); if ($seeder->getSeeded() == 0) { $this->info('No seeders were ran!'); } } else { throw new \InvalidArgumentException('The "--files" option is required.'); } }
[ "public", "function", "fire", "(", ")", "{", "if", "(", "$", "this", "->", "option", "(", "'files'", ")", "!=", "''", ")", "{", "$", "seeder", "=", "$", "this", "->", "getLaravelSeeder", "(", ")", ";", "$", "seeder", "->", "only", "(", "$", "this", "->", "option", "(", "'files'", ")", ")", ";", "$", "this", "->", "call", "(", "'db:seed'", ")", ";", "$", "seeder", "->", "restore", "(", ")", ";", "if", "(", "$", "seeder", "->", "getSeeded", "(", ")", "==", "0", ")", "{", "$", "this", "->", "info", "(", "'No seeders were ran!'", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The \"--files\" option is required.'", ")", ";", "}", "}" ]
Execute the console command. @return mixed
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/Commands/LaravelSeederOnlyCommand.php#L65-L86
WellCommerce/AppBundle
Form/DataTransformer/MediaCollectionToArrayTransformer.php
MediaCollectionToArrayTransformer.transform
public function transform($modelData) { if (null === $modelData || !$modelData instanceof PersistentCollection) { return []; } $items = []; foreach ($modelData as $item) { if ($item->isMainPhoto() == 1) { $items['main_photo'] = $item->getPhoto()->getId(); } $items['photos'][] = $item->getPhoto()->getId(); } return $items; }
php
public function transform($modelData) { if (null === $modelData || !$modelData instanceof PersistentCollection) { return []; } $items = []; foreach ($modelData as $item) { if ($item->isMainPhoto() == 1) { $items['main_photo'] = $item->getPhoto()->getId(); } $items['photos'][] = $item->getPhoto()->getId(); } return $items; }
[ "public", "function", "transform", "(", "$", "modelData", ")", "{", "if", "(", "null", "===", "$", "modelData", "||", "!", "$", "modelData", "instanceof", "PersistentCollection", ")", "{", "return", "[", "]", ";", "}", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "modelData", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "isMainPhoto", "(", ")", "==", "1", ")", "{", "$", "items", "[", "'main_photo'", "]", "=", "$", "item", "->", "getPhoto", "(", ")", "->", "getId", "(", ")", ";", "}", "$", "items", "[", "'photos'", "]", "[", "]", "=", "$", "item", "->", "getPhoto", "(", ")", "->", "getId", "(", ")", ";", "}", "return", "$", "items", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Form/DataTransformer/MediaCollectionToArrayTransformer.php#L28-L43
philiplb/Valdi
src/Valdi/Validator/Nested.php
Nested.isValidArray
protected function isValidArray($values, Validator $validator, array $rules) { if (!is_array($values)) { $this->invalidDetails = $values; return false; } $elementValidation = $validator->isValid($rules, $values); if (!$elementValidation['valid']) { $this->invalidDetails = $elementValidation['errors']; return false; } return true; }
php
protected function isValidArray($values, Validator $validator, array $rules) { if (!is_array($values)) { $this->invalidDetails = $values; return false; } $elementValidation = $validator->isValid($rules, $values); if (!$elementValidation['valid']) { $this->invalidDetails = $elementValidation['errors']; return false; } return true; }
[ "protected", "function", "isValidArray", "(", "$", "values", ",", "Validator", "$", "validator", ",", "array", "$", "rules", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "$", "this", "->", "invalidDetails", "=", "$", "values", ";", "return", "false", ";", "}", "$", "elementValidation", "=", "$", "validator", "->", "isValid", "(", "$", "rules", ",", "$", "values", ")", ";", "if", "(", "!", "$", "elementValidation", "[", "'valid'", "]", ")", "{", "$", "this", "->", "invalidDetails", "=", "$", "elementValidation", "[", "'errors'", "]", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/Nested.php#L24-L36
thupan/framework
src/Service/Crypt.php
Crypt.encode
public static function encode($string,$senha,$algorithm ='rijndael-256') { $key = md5($senha, true); // bynary raw 16 byte dimension. $iv_length = mcrypt_get_iv_size( $algorithm, MCRYPT_MODE_CBC ); $iv = mcrypt_create_iv( $iv_length, MCRYPT_RAND ); $encrypted = mcrypt_encrypt( $algorithm, $key, $string, MCRYPT_MODE_CBC, $iv ); $result = base64_encode( $iv . $encrypted ); return $result; }
php
public static function encode($string,$senha,$algorithm ='rijndael-256') { $key = md5($senha, true); // bynary raw 16 byte dimension. $iv_length = mcrypt_get_iv_size( $algorithm, MCRYPT_MODE_CBC ); $iv = mcrypt_create_iv( $iv_length, MCRYPT_RAND ); $encrypted = mcrypt_encrypt( $algorithm, $key, $string, MCRYPT_MODE_CBC, $iv ); $result = base64_encode( $iv . $encrypted ); return $result; }
[ "public", "static", "function", "encode", "(", "$", "string", ",", "$", "senha", ",", "$", "algorithm", "=", "'rijndael-256'", ")", "{", "$", "key", "=", "md5", "(", "$", "senha", ",", "true", ")", ";", "// bynary raw 16 byte dimension.", "$", "iv_length", "=", "mcrypt_get_iv_size", "(", "$", "algorithm", ",", "MCRYPT_MODE_CBC", ")", ";", "$", "iv", "=", "mcrypt_create_iv", "(", "$", "iv_length", ",", "MCRYPT_RAND", ")", ";", "$", "encrypted", "=", "mcrypt_encrypt", "(", "$", "algorithm", ",", "$", "key", ",", "$", "string", ",", "MCRYPT_MODE_CBC", ",", "$", "iv", ")", ";", "$", "result", "=", "base64_encode", "(", "$", "iv", ".", "$", "encrypted", ")", ";", "return", "$", "result", ";", "}" ]
Método público encode. @method merge() @param String @param String @param String @return String
[ "Método", "público", "encode", "." ]
train
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/Crypt.php#L26-L33
thupan/framework
src/Service/Crypt.php
Crypt.decode
public static function decode($string,$senha,$algorithm ='rijndael-256') { $key = md5($senha, true); $iv_length = mcrypt_get_iv_size( $algorithm, MCRYPT_MODE_CBC ); $string = base64_decode( $string ); $iv = substr( $string, 0, $iv_length ); $encrypted = substr( $string, $iv_length ); $result = mcrypt_decrypt( $algorithm, $key, $encrypted, MCRYPT_MODE_CBC, $iv ); return $result; }
php
public static function decode($string,$senha,$algorithm ='rijndael-256') { $key = md5($senha, true); $iv_length = mcrypt_get_iv_size( $algorithm, MCRYPT_MODE_CBC ); $string = base64_decode( $string ); $iv = substr( $string, 0, $iv_length ); $encrypted = substr( $string, $iv_length ); $result = mcrypt_decrypt( $algorithm, $key, $encrypted, MCRYPT_MODE_CBC, $iv ); return $result; }
[ "public", "static", "function", "decode", "(", "$", "string", ",", "$", "senha", ",", "$", "algorithm", "=", "'rijndael-256'", ")", "{", "$", "key", "=", "md5", "(", "$", "senha", ",", "true", ")", ";", "$", "iv_length", "=", "mcrypt_get_iv_size", "(", "$", "algorithm", ",", "MCRYPT_MODE_CBC", ")", ";", "$", "string", "=", "base64_decode", "(", "$", "string", ")", ";", "$", "iv", "=", "substr", "(", "$", "string", ",", "0", ",", "$", "iv_length", ")", ";", "$", "encrypted", "=", "substr", "(", "$", "string", ",", "$", "iv_length", ")", ";", "$", "result", "=", "mcrypt_decrypt", "(", "$", "algorithm", ",", "$", "key", ",", "$", "encrypted", ",", "MCRYPT_MODE_CBC", ",", "$", "iv", ")", ";", "return", "$", "result", ";", "}" ]
Método público decode. @method decode() @param String @param String @param String @return String
[ "Método", "público", "decode", "." ]
train
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/Crypt.php#L43-L51
blast-project/BaseEntitiesBundle
src/Loggable/Mapping/Driver/Annotation.php
Annotation.validateFullMetadata
public function validateFullMetadata(ClassMetadata $meta, array $config) { if ($config && is_array($meta->identifier) && count($meta->identifier) > 1) { throw new InvalidMappingException("Loggable does not support composite identifiers in class - {$meta->name}"); } if (isset($config['versioned']) && !isset($config['loggable'])) { throw new InvalidMappingException("Class must be annotated with Loggable annotation in order to track versioned fields in class - {$meta->name}"); } }
php
public function validateFullMetadata(ClassMetadata $meta, array $config) { if ($config && is_array($meta->identifier) && count($meta->identifier) > 1) { throw new InvalidMappingException("Loggable does not support composite identifiers in class - {$meta->name}"); } if (isset($config['versioned']) && !isset($config['loggable'])) { throw new InvalidMappingException("Class must be annotated with Loggable annotation in order to track versioned fields in class - {$meta->name}"); } }
[ "public", "function", "validateFullMetadata", "(", "ClassMetadata", "$", "meta", ",", "array", "$", "config", ")", "{", "if", "(", "$", "config", "&&", "is_array", "(", "$", "meta", "->", "identifier", ")", "&&", "count", "(", "$", "meta", "->", "identifier", ")", ">", "1", ")", "{", "throw", "new", "InvalidMappingException", "(", "\"Loggable does not support composite identifiers in class - {$meta->name}\"", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'versioned'", "]", ")", "&&", "!", "isset", "(", "$", "config", "[", "'loggable'", "]", ")", ")", "{", "throw", "new", "InvalidMappingException", "(", "\"Class must be annotated with Loggable annotation in order to track versioned fields in class - {$meta->name}\"", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Loggable/Mapping/Driver/Annotation.php#L53-L61
blast-project/BaseEntitiesBundle
src/Loggable/Mapping/Driver/Annotation.php
Annotation.readExtendedMetadata
public function readExtendedMetadata($meta, array &$config) { $class = $this->getMetaReflectionClass($meta); // class annotations if ($annot = $this->reader->getClassAnnotation($class, self::LOGGABLE)) { $config['loggable'] = true; if ($annot->logEntryClass) { if (!$cl = $this->getRelatedClassName($meta, $annot->logEntryClass)) { throw new InvalidMappingException("LogEntry class: {$annot->logEntryClass} does not exist."); } $config['logEntryClass'] = $cl; } } // property annotations foreach ($class->getProperties() as $property) { if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || isset($meta->associationMappings[$property->name]['inherited']) ) { continue; } // versioned property if ($this->reader->getPropertyAnnotation($property, self::VERSIONED)) { $field = $property->getName(); if (!$this->isMappingValid($meta, $field)) { throw new InvalidMappingException("Cannot versioned [{$field}] as it is collection in object - {$meta->name}"); } if (isset($meta->embeddedClasses[$field])) { $this->inspectEmbeddedForVersioned($field, $config, $meta); continue; } // fields cannot be overrided and throws mapping exception $config['versioned'][] = $field; } } if (!$meta->isMappedSuperclass && $config) { if (is_array($meta->identifier) && count($meta->identifier) > 1) { throw new InvalidMappingException("Loggable does not support composite identifiers in class - {$meta->name}"); } if ($this->isClassAnnotationInValid($meta, $config)) { throw new InvalidMappingException("Class must be annotated with Loggable annotation in order to track versioned fields in class - {$meta->name}"); } } }
php
public function readExtendedMetadata($meta, array &$config) { $class = $this->getMetaReflectionClass($meta); // class annotations if ($annot = $this->reader->getClassAnnotation($class, self::LOGGABLE)) { $config['loggable'] = true; if ($annot->logEntryClass) { if (!$cl = $this->getRelatedClassName($meta, $annot->logEntryClass)) { throw new InvalidMappingException("LogEntry class: {$annot->logEntryClass} does not exist."); } $config['logEntryClass'] = $cl; } } // property annotations foreach ($class->getProperties() as $property) { if ($meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || isset($meta->associationMappings[$property->name]['inherited']) ) { continue; } // versioned property if ($this->reader->getPropertyAnnotation($property, self::VERSIONED)) { $field = $property->getName(); if (!$this->isMappingValid($meta, $field)) { throw new InvalidMappingException("Cannot versioned [{$field}] as it is collection in object - {$meta->name}"); } if (isset($meta->embeddedClasses[$field])) { $this->inspectEmbeddedForVersioned($field, $config, $meta); continue; } // fields cannot be overrided and throws mapping exception $config['versioned'][] = $field; } } if (!$meta->isMappedSuperclass && $config) { if (is_array($meta->identifier) && count($meta->identifier) > 1) { throw new InvalidMappingException("Loggable does not support composite identifiers in class - {$meta->name}"); } if ($this->isClassAnnotationInValid($meta, $config)) { throw new InvalidMappingException("Class must be annotated with Loggable annotation in order to track versioned fields in class - {$meta->name}"); } } }
[ "public", "function", "readExtendedMetadata", "(", "$", "meta", ",", "array", "&", "$", "config", ")", "{", "$", "class", "=", "$", "this", "->", "getMetaReflectionClass", "(", "$", "meta", ")", ";", "// class annotations", "if", "(", "$", "annot", "=", "$", "this", "->", "reader", "->", "getClassAnnotation", "(", "$", "class", ",", "self", "::", "LOGGABLE", ")", ")", "{", "$", "config", "[", "'loggable'", "]", "=", "true", ";", "if", "(", "$", "annot", "->", "logEntryClass", ")", "{", "if", "(", "!", "$", "cl", "=", "$", "this", "->", "getRelatedClassName", "(", "$", "meta", ",", "$", "annot", "->", "logEntryClass", ")", ")", "{", "throw", "new", "InvalidMappingException", "(", "\"LogEntry class: {$annot->logEntryClass} does not exist.\"", ")", ";", "}", "$", "config", "[", "'logEntryClass'", "]", "=", "$", "cl", ";", "}", "}", "// property annotations", "foreach", "(", "$", "class", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "if", "(", "$", "meta", "->", "isMappedSuperclass", "&&", "!", "$", "property", "->", "isPrivate", "(", ")", "||", "$", "meta", "->", "isInheritedField", "(", "$", "property", "->", "name", ")", "||", "isset", "(", "$", "meta", "->", "associationMappings", "[", "$", "property", "->", "name", "]", "[", "'inherited'", "]", ")", ")", "{", "continue", ";", "}", "// versioned property", "if", "(", "$", "this", "->", "reader", "->", "getPropertyAnnotation", "(", "$", "property", ",", "self", "::", "VERSIONED", ")", ")", "{", "$", "field", "=", "$", "property", "->", "getName", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isMappingValid", "(", "$", "meta", ",", "$", "field", ")", ")", "{", "throw", "new", "InvalidMappingException", "(", "\"Cannot versioned [{$field}] as it is collection in object - {$meta->name}\"", ")", ";", "}", "if", "(", "isset", "(", "$", "meta", "->", "embeddedClasses", "[", "$", "field", "]", ")", ")", "{", "$", "this", "->", "inspectEmbeddedForVersioned", "(", "$", "field", ",", "$", "config", ",", "$", "meta", ")", ";", "continue", ";", "}", "// fields cannot be overrided and throws mapping exception", "$", "config", "[", "'versioned'", "]", "[", "]", "=", "$", "field", ";", "}", "}", "if", "(", "!", "$", "meta", "->", "isMappedSuperclass", "&&", "$", "config", ")", "{", "if", "(", "is_array", "(", "$", "meta", "->", "identifier", ")", "&&", "count", "(", "$", "meta", "->", "identifier", ")", ">", "1", ")", "{", "throw", "new", "InvalidMappingException", "(", "\"Loggable does not support composite identifiers in class - {$meta->name}\"", ")", ";", "}", "if", "(", "$", "this", "->", "isClassAnnotationInValid", "(", "$", "meta", ",", "$", "config", ")", ")", "{", "throw", "new", "InvalidMappingException", "(", "\"Class must be annotated with Loggable annotation in order to track versioned fields in class - {$meta->name}\"", ")", ";", "}", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Loggable/Mapping/Driver/Annotation.php#L66-L112
blast-project/BaseEntitiesBundle
src/Loggable/Mapping/Driver/Annotation.php
Annotation.isClassAnnotationInValid
protected function isClassAnnotationInValid(ClassMetadata $meta, array &$config) { return isset($config['versioned']) && !isset($config['loggable']) && (!isset($meta->isEmbeddedClass) || !$meta->isEmbeddedClass); }
php
protected function isClassAnnotationInValid(ClassMetadata $meta, array &$config) { return isset($config['versioned']) && !isset($config['loggable']) && (!isset($meta->isEmbeddedClass) || !$meta->isEmbeddedClass); }
[ "protected", "function", "isClassAnnotationInValid", "(", "ClassMetadata", "$", "meta", ",", "array", "&", "$", "config", ")", "{", "return", "isset", "(", "$", "config", "[", "'versioned'", "]", ")", "&&", "!", "isset", "(", "$", "config", "[", "'loggable'", "]", ")", "&&", "(", "!", "isset", "(", "$", "meta", "->", "isEmbeddedClass", ")", "||", "!", "$", "meta", "->", "isEmbeddedClass", ")", ";", "}" ]
@param ClassMetadata $meta @param array $config @return bool
[ "@param", "ClassMetadata", "$meta", "@param", "array", "$config" ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Loggable/Mapping/Driver/Annotation.php#L131-L134
blast-project/BaseEntitiesBundle
src/Loggable/Mapping/Driver/Annotation.php
Annotation.inspectEmbeddedForVersioned
private function inspectEmbeddedForVersioned($field, array &$config, \Doctrine\ORM\Mapping\ClassMetadata $meta) { $сlass = new \ReflectionClass($meta->embeddedClasses[$field]['class']); // property annotations foreach ($сlass->getProperties() as $property) { // versioned property if ($this->reader->getPropertyAnnotation($property, self::VERSIONED)) { $config['versioned'][] = $field . '.' . $property->getName(); } } }
php
private function inspectEmbeddedForVersioned($field, array &$config, \Doctrine\ORM\Mapping\ClassMetadata $meta) { $сlass = new \ReflectionClass($meta->embeddedClasses[$field]['class']); // property annotations foreach ($сlass->getProperties() as $property) { // versioned property if ($this->reader->getPropertyAnnotation($property, self::VERSIONED)) { $config['versioned'][] = $field . '.' . $property->getName(); } } }
[ "private", "function", "inspectEmbeddedForVersioned", "(", "$", "field", ",", "array", "&", "$", "config", ",", "\\", "Doctrine", "\\", "ORM", "\\", "Mapping", "\\", "ClassMetadata", "$", "meta", ")", "{", "$", "сl", "ass ", " ", "ew ", "R", "eflectionClass(", "$", "m", "eta-", ">e", "mbeddedClasses[", "$", "f", "ield]", "[", "'", "class']", ")", ";", "", "// property annotations", "foreach", "(", "$", "сl", "ass-", ">g", "etProperties(", ")", " ", "s ", "p", "roperty)", " ", "", "// versioned property", "if", "(", "$", "this", "->", "reader", "->", "getPropertyAnnotation", "(", "$", "property", ",", "self", "::", "VERSIONED", ")", ")", "{", "$", "config", "[", "'versioned'", "]", "[", "]", "=", "$", "field", ".", "'.'", ".", "$", "property", "->", "getName", "(", ")", ";", "}", "}", "}" ]
Searches properties of embedded object for versioned fields. @param string $field @param array $config @param \Doctrine\ORM\Mapping\ClassMetadata $meta
[ "Searches", "properties", "of", "embedded", "object", "for", "versioned", "fields", "." ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Loggable/Mapping/Driver/Annotation.php#L143-L154
php-lug/lug
src/Component/Grid/Column/Type/ResourceType.php
ResourceType.render
public function render($data, array $options) { if (($resource = $this->getValue($data, $options)) === null) { return; } if (!isset($this->cache[$hash = spl_object_hash($options['grid']).':'.spl_object_hash($options['column'])])) { $this->cache[$hash] = new Column($options['resource_path'], null, $options['type'], $options['options']); } return $this->renderer->render($options['grid'], $this->cache[$hash], $resource); }
php
public function render($data, array $options) { if (($resource = $this->getValue($data, $options)) === null) { return; } if (!isset($this->cache[$hash = spl_object_hash($options['grid']).':'.spl_object_hash($options['column'])])) { $this->cache[$hash] = new Column($options['resource_path'], null, $options['type'], $options['options']); } return $this->renderer->render($options['grid'], $this->cache[$hash], $resource); }
[ "public", "function", "render", "(", "$", "data", ",", "array", "$", "options", ")", "{", "if", "(", "(", "$", "resource", "=", "$", "this", "->", "getValue", "(", "$", "data", ",", "$", "options", ")", ")", "===", "null", ")", "{", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "cache", "[", "$", "hash", "=", "spl_object_hash", "(", "$", "options", "[", "'grid'", "]", ")", ".", "':'", ".", "spl_object_hash", "(", "$", "options", "[", "'column'", "]", ")", "]", ")", ")", "{", "$", "this", "->", "cache", "[", "$", "hash", "]", "=", "new", "Column", "(", "$", "options", "[", "'resource_path'", "]", ",", "null", ",", "$", "options", "[", "'type'", "]", ",", "$", "options", "[", "'options'", "]", ")", ";", "}", "return", "$", "this", "->", "renderer", "->", "render", "(", "$", "options", "[", "'grid'", "]", ",", "$", "this", "->", "cache", "[", "$", "hash", "]", ",", "$", "resource", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Column/Type/ResourceType.php#L67-L78
php-lug/lug
src/Component/Grid/Column/Type/ResourceType.php
ResourceType.configureOptions
public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver ->setRequired(['resource', 'type']) ->setDefaults([ 'options' => [], 'resource_path' => function (Options $options, $resourcePath) { return $resourcePath === null ? $options['resource']->getLabelPropertyPath() : $resourcePath; }, ]) ->setNormalizer('resource', function (Options $options, $resource) { return is_string($resource) ? $this->resourceRegistry[$resource] : $resource; }) ->setAllowedTypes('resource', ['string', ResourceInterface::class]) ->setAllowedTypes('resource_path', 'string') ->setAllowedTypes('type', 'string') ->setAllowedTypes('options', 'array'); }
php
public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver ->setRequired(['resource', 'type']) ->setDefaults([ 'options' => [], 'resource_path' => function (Options $options, $resourcePath) { return $resourcePath === null ? $options['resource']->getLabelPropertyPath() : $resourcePath; }, ]) ->setNormalizer('resource', function (Options $options, $resource) { return is_string($resource) ? $this->resourceRegistry[$resource] : $resource; }) ->setAllowedTypes('resource', ['string', ResourceInterface::class]) ->setAllowedTypes('resource_path', 'string') ->setAllowedTypes('type', 'string') ->setAllowedTypes('options', 'array'); }
[ "public", "function", "configureOptions", "(", "OptionsResolver", "$", "resolver", ")", "{", "parent", "::", "configureOptions", "(", "$", "resolver", ")", ";", "$", "resolver", "->", "setRequired", "(", "[", "'resource'", ",", "'type'", "]", ")", "->", "setDefaults", "(", "[", "'options'", "=>", "[", "]", ",", "'resource_path'", "=>", "function", "(", "Options", "$", "options", ",", "$", "resourcePath", ")", "{", "return", "$", "resourcePath", "===", "null", "?", "$", "options", "[", "'resource'", "]", "->", "getLabelPropertyPath", "(", ")", ":", "$", "resourcePath", ";", "}", ",", "]", ")", "->", "setNormalizer", "(", "'resource'", ",", "function", "(", "Options", "$", "options", ",", "$", "resource", ")", "{", "return", "is_string", "(", "$", "resource", ")", "?", "$", "this", "->", "resourceRegistry", "[", "$", "resource", "]", ":", "$", "resource", ";", "}", ")", "->", "setAllowedTypes", "(", "'resource'", ",", "[", "'string'", ",", "ResourceInterface", "::", "class", "]", ")", "->", "setAllowedTypes", "(", "'resource_path'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'type'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'options'", ",", "'array'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Column/Type/ResourceType.php#L83-L102
jnaxo/country-codes
src/Store/api/Paginator.php
Paginator.paginate
public function paginate() { $this->count = $this->query->get()->count(); $this->limit = $this->limit ?: $this->count; $this->query->skip($this->offset)->take($this->limit); }
php
public function paginate() { $this->count = $this->query->get()->count(); $this->limit = $this->limit ?: $this->count; $this->query->skip($this->offset)->take($this->limit); }
[ "public", "function", "paginate", "(", ")", "{", "$", "this", "->", "count", "=", "$", "this", "->", "query", "->", "get", "(", ")", "->", "count", "(", ")", ";", "$", "this", "->", "limit", "=", "$", "this", "->", "limit", "?", ":", "$", "this", "->", "count", ";", "$", "this", "->", "query", "->", "skip", "(", "$", "this", "->", "offset", ")", "->", "take", "(", "$", "this", "->", "limit", ")", ";", "}" ]
Will modify a query builder to get paginated data and will return an array with the meta data. @param Illuminate\Database\Query\Builder $query @return array
[ "Will", "modify", "a", "query", "builder", "to", "get", "paginated", "data", "and", "will", "return", "an", "array", "with", "the", "meta", "data", "." ]
train
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L68-L73
jnaxo/country-codes
src/Store/api/Paginator.php
Paginator.getNextPageParams
public function getNextPageParams() { $limit = $this->limit <= 0 ? $this->count : $this->limit; $next_url = $this->offset_key . $this->offset . $this->limit_key . $limit; if ($this->count <= ($this->offset + $limit)) { return false; } if ($this->count >= $limit) { $next_url = $this->offset_key . ($this->offset + $limit) . $this->limit_key . $limit; } return $next_url; }
php
public function getNextPageParams() { $limit = $this->limit <= 0 ? $this->count : $this->limit; $next_url = $this->offset_key . $this->offset . $this->limit_key . $limit; if ($this->count <= ($this->offset + $limit)) { return false; } if ($this->count >= $limit) { $next_url = $this->offset_key . ($this->offset + $limit) . $this->limit_key . $limit; } return $next_url; }
[ "public", "function", "getNextPageParams", "(", ")", "{", "$", "limit", "=", "$", "this", "->", "limit", "<=", "0", "?", "$", "this", "->", "count", ":", "$", "this", "->", "limit", ";", "$", "next_url", "=", "$", "this", "->", "offset_key", ".", "$", "this", "->", "offset", ".", "$", "this", "->", "limit_key", ".", "$", "limit", ";", "if", "(", "$", "this", "->", "count", "<=", "(", "$", "this", "->", "offset", "+", "$", "limit", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "count", ">=", "$", "limit", ")", "{", "$", "next_url", "=", "$", "this", "->", "offset_key", ".", "(", "$", "this", "->", "offset", "+", "$", "limit", ")", ".", "$", "this", "->", "limit_key", ".", "$", "limit", ";", "}", "return", "$", "next_url", ";", "}" ]
Generate the next page url parameters as string. @param int $count @param int $currentOffset @param int $limit @return string
[ "Generate", "the", "next", "page", "url", "parameters", "as", "string", "." ]
train
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L84-L104
jnaxo/country-codes
src/Store/api/Paginator.php
Paginator.getPrevPageParams
public function getPrevPageParams() { $limit = $this->limit <= 0 ? $this->count : $this->limit; $prev_url = $this->offset_key . $this->offset . $this->limit_key . $limit; if ($this->count >= $limit) { $prev_url = $this->offset_key . ($this->offset - $limit) . $this->limit_key . $limit; } if ($this->count <= ($this->offset - $limit)) { $prev_url = $this->offset_key . $this->offset . $this->limit_key . $limit; } return $prev_url; }
php
public function getPrevPageParams() { $limit = $this->limit <= 0 ? $this->count : $this->limit; $prev_url = $this->offset_key . $this->offset . $this->limit_key . $limit; if ($this->count >= $limit) { $prev_url = $this->offset_key . ($this->offset - $limit) . $this->limit_key . $limit; } if ($this->count <= ($this->offset - $limit)) { $prev_url = $this->offset_key . $this->offset . $this->limit_key . $limit; } return $prev_url; }
[ "public", "function", "getPrevPageParams", "(", ")", "{", "$", "limit", "=", "$", "this", "->", "limit", "<=", "0", "?", "$", "this", "->", "count", ":", "$", "this", "->", "limit", ";", "$", "prev_url", "=", "$", "this", "->", "offset_key", ".", "$", "this", "->", "offset", ".", "$", "this", "->", "limit_key", ".", "$", "limit", ";", "if", "(", "$", "this", "->", "count", ">=", "$", "limit", ")", "{", "$", "prev_url", "=", "$", "this", "->", "offset_key", ".", "(", "$", "this", "->", "offset", "-", "$", "limit", ")", ".", "$", "this", "->", "limit_key", ".", "$", "limit", ";", "}", "if", "(", "$", "this", "->", "count", "<=", "(", "$", "this", "->", "offset", "-", "$", "limit", ")", ")", "{", "$", "prev_url", "=", "$", "this", "->", "offset_key", ".", "$", "this", "->", "offset", ".", "$", "this", "->", "limit_key", ".", "$", "limit", ";", "}", "return", "$", "prev_url", ";", "}" ]
Generate the prev page url parameters as string. @param int $count @param int $currentOffset @param int $limit @return string
[ "Generate", "the", "prev", "page", "url", "parameters", "as", "string", "." ]
train
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L115-L136
jnaxo/country-codes
src/Store/api/Paginator.php
Paginator.getLastPageParams
public function getLastPageParams() { $limit = $this->limit <= 0 ? $this->count : $this->limit; $last_page = intdiv(intval($this->count), intval($limit)); $last_url = $this->offset_key . ($last_page * $limit) . $this->limit_key . $limit; return $last_url; }
php
public function getLastPageParams() { $limit = $this->limit <= 0 ? $this->count : $this->limit; $last_page = intdiv(intval($this->count), intval($limit)); $last_url = $this->offset_key . ($last_page * $limit) . $this->limit_key . $limit; return $last_url; }
[ "public", "function", "getLastPageParams", "(", ")", "{", "$", "limit", "=", "$", "this", "->", "limit", "<=", "0", "?", "$", "this", "->", "count", ":", "$", "this", "->", "limit", ";", "$", "last_page", "=", "intdiv", "(", "intval", "(", "$", "this", "->", "count", ")", ",", "intval", "(", "$", "limit", ")", ")", ";", "$", "last_url", "=", "$", "this", "->", "offset_key", ".", "(", "$", "last_page", "*", "$", "limit", ")", ".", "$", "this", "->", "limit_key", ".", "$", "limit", ";", "return", "$", "last_url", ";", "}" ]
Generate the last page url parameters as string. @param int $count @param int $currentOffset @param int $limit @return string
[ "Generate", "the", "last", "page", "url", "parameters", "as", "string", "." ]
train
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L147-L157
jnaxo/country-codes
src/Store/api/Paginator.php
Paginator.getFirstPageParams
public function getFirstPageParams() { $limit = $this->limit <= 0 ? $this->count : $this->limit; $first_url = $this->offset_key . '0' . $this->limit_key . $limit; return $first_url; }
php
public function getFirstPageParams() { $limit = $this->limit <= 0 ? $this->count : $this->limit; $first_url = $this->offset_key . '0' . $this->limit_key . $limit; return $first_url; }
[ "public", "function", "getFirstPageParams", "(", ")", "{", "$", "limit", "=", "$", "this", "->", "limit", "<=", "0", "?", "$", "this", "->", "count", ":", "$", "this", "->", "limit", ";", "$", "first_url", "=", "$", "this", "->", "offset_key", ".", "'0'", ".", "$", "this", "->", "limit_key", ".", "$", "limit", ";", "return", "$", "first_url", ";", "}" ]
Generate the first page url parameters as string. @param int $count @param int $currentOffset @param int $limit @return string
[ "Generate", "the", "first", "page", "url", "parameters", "as", "string", "." ]
train
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L168-L174
jnaxo/country-codes
src/Store/api/Paginator.php
Paginator.getPaginationMetaData
public function getPaginationMetaData() { $pagination = [ 'count' => $this->count, 'offset' => $this->offset, 'limit' => $this->limit, 'next_page_params' => $this->getNextPageParams(), ]; return $pagination; }
php
public function getPaginationMetaData() { $pagination = [ 'count' => $this->count, 'offset' => $this->offset, 'limit' => $this->limit, 'next_page_params' => $this->getNextPageParams(), ]; return $pagination; }
[ "public", "function", "getPaginationMetaData", "(", ")", "{", "$", "pagination", "=", "[", "'count'", "=>", "$", "this", "->", "count", ",", "'offset'", "=>", "$", "this", "->", "offset", ",", "'limit'", "=>", "$", "this", "->", "limit", ",", "'next_page_params'", "=>", "$", "this", "->", "getNextPageParams", "(", ")", ",", "]", ";", "return", "$", "pagination", ";", "}" ]
Get a json encoded array with pagination metadata
[ "Get", "a", "json", "encoded", "array", "with", "pagination", "metadata" ]
train
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L180-L190
letyii/yii2-mongo-nested-set
NestedSetsQueryBehavior.php
NestedSetsQueryBehavior.roots
public function roots() { $model = new $this->owner->modelClass(); $this->owner ->andWhere([$model->leftAttribute => 1]) ->addOrderBy([$model->primaryKey()[0] => SORT_ASC]); return $this->owner; }
php
public function roots() { $model = new $this->owner->modelClass(); $this->owner ->andWhere([$model->leftAttribute => 1]) ->addOrderBy([$model->primaryKey()[0] => SORT_ASC]); return $this->owner; }
[ "public", "function", "roots", "(", ")", "{", "$", "model", "=", "new", "$", "this", "->", "owner", "->", "modelClass", "(", ")", ";", "$", "this", "->", "owner", "->", "andWhere", "(", "[", "$", "model", "->", "leftAttribute", "=>", "1", "]", ")", "->", "addOrderBy", "(", "[", "$", "model", "->", "primaryKey", "(", ")", "[", "0", "]", "=>", "SORT_ASC", "]", ")", ";", "return", "$", "this", "->", "owner", ";", "}" ]
Gets the root nodes. @return \yii\db\ActiveQuery the owner
[ "Gets", "the", "root", "nodes", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsQueryBehavior.php#L27-L36
letyii/yii2-mongo-nested-set
NestedSetsQueryBehavior.php
NestedSetsQueryBehavior.leaves
public function leaves() { $model = new $this->owner->modelClass(); $db = $model->getDb(); $columns = [$model->leftAttribute => SORT_ASC]; if ($model->treeAttribute !== false) { $columns = [$model->treeAttribute => SORT_ASC] + $columns; } $this->owner ->andWhere(['$where' => "this.{$model->rightAttribute} = this.{$model->leftAttribute} + 1"]) ->addOrderBy($columns); return $this->owner; }
php
public function leaves() { $model = new $this->owner->modelClass(); $db = $model->getDb(); $columns = [$model->leftAttribute => SORT_ASC]; if ($model->treeAttribute !== false) { $columns = [$model->treeAttribute => SORT_ASC] + $columns; } $this->owner ->andWhere(['$where' => "this.{$model->rightAttribute} = this.{$model->leftAttribute} + 1"]) ->addOrderBy($columns); return $this->owner; }
[ "public", "function", "leaves", "(", ")", "{", "$", "model", "=", "new", "$", "this", "->", "owner", "->", "modelClass", "(", ")", ";", "$", "db", "=", "$", "model", "->", "getDb", "(", ")", ";", "$", "columns", "=", "[", "$", "model", "->", "leftAttribute", "=>", "SORT_ASC", "]", ";", "if", "(", "$", "model", "->", "treeAttribute", "!==", "false", ")", "{", "$", "columns", "=", "[", "$", "model", "->", "treeAttribute", "=>", "SORT_ASC", "]", "+", "$", "columns", ";", "}", "$", "this", "->", "owner", "->", "andWhere", "(", "[", "'$where'", "=>", "\"this.{$model->rightAttribute} = this.{$model->leftAttribute} + 1\"", "]", ")", "->", "addOrderBy", "(", "$", "columns", ")", ";", "return", "$", "this", "->", "owner", ";", "}" ]
Gets the leaf nodes. @return \yii\db\ActiveQuery the owner
[ "Gets", "the", "leaf", "nodes", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsQueryBehavior.php#L42-L58
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php
ezcDbSchemaHandlerManager.getReaderByFormat
static public function getReaderByFormat( $format ) { if ( !isset( self::$readHandlers[$format] ) ) { throw new ezcDbSchemaUnknownFormatException( $format, 'read' ); } return self::$readHandlers[$format]; }
php
static public function getReaderByFormat( $format ) { if ( !isset( self::$readHandlers[$format] ) ) { throw new ezcDbSchemaUnknownFormatException( $format, 'read' ); } return self::$readHandlers[$format]; }
[ "static", "public", "function", "getReaderByFormat", "(", "$", "format", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "readHandlers", "[", "$", "format", "]", ")", ")", "{", "throw", "new", "ezcDbSchemaUnknownFormatException", "(", "$", "format", ",", "'read'", ")", ";", "}", "return", "self", "::", "$", "readHandlers", "[", "$", "format", "]", ";", "}" ]
Returns the class name of the read handler for format $format. @param string $format @return string
[ "Returns", "the", "class", "name", "of", "the", "read", "handler", "for", "format", "$format", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php#L93-L100
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php
ezcDbSchemaHandlerManager.getWriterByFormat
static public function getWriterByFormat( $format ) { if ( !isset( self::$writeHandlers[$format] ) ) { throw new ezcDbSchemaUnknownFormatException( $format, 'write' ); } return self::$writeHandlers[$format]; }
php
static public function getWriterByFormat( $format ) { if ( !isset( self::$writeHandlers[$format] ) ) { throw new ezcDbSchemaUnknownFormatException( $format, 'write' ); } return self::$writeHandlers[$format]; }
[ "static", "public", "function", "getWriterByFormat", "(", "$", "format", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "writeHandlers", "[", "$", "format", "]", ")", ")", "{", "throw", "new", "ezcDbSchemaUnknownFormatException", "(", "$", "format", ",", "'write'", ")", ";", "}", "return", "self", "::", "$", "writeHandlers", "[", "$", "format", "]", ";", "}" ]
Returns the class name of the write handler for format $format. @param string $format @return string
[ "Returns", "the", "class", "name", "of", "the", "write", "handler", "for", "format", "$format", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php#L108-L115
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php
ezcDbSchemaHandlerManager.getDiffReaderByFormat
static public function getDiffReaderByFormat( $format ) { if ( !isset( self::$diffReadHandlers[$format] ) ) { throw new ezcDbSchemaUnknownFormatException( $format, 'difference read' ); } return self::$diffReadHandlers[$format]; }
php
static public function getDiffReaderByFormat( $format ) { if ( !isset( self::$diffReadHandlers[$format] ) ) { throw new ezcDbSchemaUnknownFormatException( $format, 'difference read' ); } return self::$diffReadHandlers[$format]; }
[ "static", "public", "function", "getDiffReaderByFormat", "(", "$", "format", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "diffReadHandlers", "[", "$", "format", "]", ")", ")", "{", "throw", "new", "ezcDbSchemaUnknownFormatException", "(", "$", "format", ",", "'difference read'", ")", ";", "}", "return", "self", "::", "$", "diffReadHandlers", "[", "$", "format", "]", ";", "}" ]
Returns the class name of the differences read handler for format $format. @param string $format @return string
[ "Returns", "the", "class", "name", "of", "the", "differences", "read", "handler", "for", "format", "$format", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php#L123-L130
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php
ezcDbSchemaHandlerManager.getDiffWriterByFormat
static public function getDiffWriterByFormat( $format ) { if ( !isset( self::$diffWriteHandlers[$format] ) ) { throw new ezcDbSchemaUnknownFormatException( $format, 'difference write' ); } return self::$diffWriteHandlers[$format]; }
php
static public function getDiffWriterByFormat( $format ) { if ( !isset( self::$diffWriteHandlers[$format] ) ) { throw new ezcDbSchemaUnknownFormatException( $format, 'difference write' ); } return self::$diffWriteHandlers[$format]; }
[ "static", "public", "function", "getDiffWriterByFormat", "(", "$", "format", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "diffWriteHandlers", "[", "$", "format", "]", ")", ")", "{", "throw", "new", "ezcDbSchemaUnknownFormatException", "(", "$", "format", ",", "'difference write'", ")", ";", "}", "return", "self", "::", "$", "diffWriteHandlers", "[", "$", "format", "]", ";", "}" ]
Returns the class name of the differences write handler for format $format. @param string $format @return string
[ "Returns", "the", "class", "name", "of", "the", "differences", "write", "handler", "for", "format", "$format", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php#L138-L145
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php
ezcDbSchemaHandlerManager.addReader
static public function addReader( $type, $readerClass ) { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $readerClass, true ) ) { throw new ezcDbSchemaInvalidReaderClassException( $readerClass ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcDbSchemaReader', class_implements( $readerClass ) ) ) { throw new ezcDbSchemaInvalidReaderClassException( $readerClass ); } self::$readHandlers[$type] = $readerClass; }
php
static public function addReader( $type, $readerClass ) { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $readerClass, true ) ) { throw new ezcDbSchemaInvalidReaderClassException( $readerClass ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcDbSchemaReader', class_implements( $readerClass ) ) ) { throw new ezcDbSchemaInvalidReaderClassException( $readerClass ); } self::$readHandlers[$type] = $readerClass; }
[ "static", "public", "function", "addReader", "(", "$", "type", ",", "$", "readerClass", ")", "{", "// Check if the passed classname actually exists", "if", "(", "!", "ezcBaseFeatures", "::", "classExists", "(", "$", "readerClass", ",", "true", ")", ")", "{", "throw", "new", "ezcDbSchemaInvalidReaderClassException", "(", "$", "readerClass", ")", ";", "}", "// Check if the passed classname actually implements the interface.", "if", "(", "!", "in_array", "(", "'ezcDbSchemaReader'", ",", "class_implements", "(", "$", "readerClass", ")", ")", ")", "{", "throw", "new", "ezcDbSchemaInvalidReaderClassException", "(", "$", "readerClass", ")", ";", "}", "self", "::", "$", "readHandlers", "[", "$", "type", "]", "=", "$", "readerClass", ";", "}" ]
Adds the read handler class $readerClass to the manager for $type @throws ezcDbSchemaInvalidReaderClassException if the $readerClass doesn't exist or doesn't extend the abstract class ezcDbSchemaReader. @param string $type @param string $readerClass
[ "Adds", "the", "read", "handler", "class", "$readerClass", "to", "the", "manager", "for", "$type" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php#L182-L196
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php
ezcDbSchemaHandlerManager.addWriter
static public function addWriter( $type, $writerClass ) { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $writerClass, true ) ) { throw new ezcDbSchemaInvalidWriterClassException( $writerClass ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcDbSchemaWriter', class_implements( $writerClass ) ) ) { throw new ezcDbSchemaInvalidWriterClassException( $writerClass ); } self::$writeHandlers[$type] = $writerClass; }
php
static public function addWriter( $type, $writerClass ) { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $writerClass, true ) ) { throw new ezcDbSchemaInvalidWriterClassException( $writerClass ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcDbSchemaWriter', class_implements( $writerClass ) ) ) { throw new ezcDbSchemaInvalidWriterClassException( $writerClass ); } self::$writeHandlers[$type] = $writerClass; }
[ "static", "public", "function", "addWriter", "(", "$", "type", ",", "$", "writerClass", ")", "{", "// Check if the passed classname actually exists", "if", "(", "!", "ezcBaseFeatures", "::", "classExists", "(", "$", "writerClass", ",", "true", ")", ")", "{", "throw", "new", "ezcDbSchemaInvalidWriterClassException", "(", "$", "writerClass", ")", ";", "}", "// Check if the passed classname actually implements the interface.", "if", "(", "!", "in_array", "(", "'ezcDbSchemaWriter'", ",", "class_implements", "(", "$", "writerClass", ")", ")", ")", "{", "throw", "new", "ezcDbSchemaInvalidWriterClassException", "(", "$", "writerClass", ")", ";", "}", "self", "::", "$", "writeHandlers", "[", "$", "type", "]", "=", "$", "writerClass", ";", "}" ]
Adds the write handler class $writerClass to the manager for $type @throws ezcDbSchemaInvalidWriterClassException if the $writerClass doesn't exist or doesn't extend the abstract class ezcDbSchemaWriter. @param string $type @param string $writerClass
[ "Adds", "the", "write", "handler", "class", "$writerClass", "to", "the", "manager", "for", "$type" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php#L207-L221
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php
ezcDbSchemaHandlerManager.addDiffReader
static public function addDiffReader( $type, $readerClass ) { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $readerClass, true ) ) { throw new ezcDbSchemaInvalidDiffReaderClassException( $readerClass ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcDbSchemaDiffReader', class_implements( $readerClass ) ) ) { throw new ezcDbSchemaInvalidDiffReaderClassException( $readerClass ); } self::$diffReadHandlers[$type] = $readerClass; }
php
static public function addDiffReader( $type, $readerClass ) { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $readerClass, true ) ) { throw new ezcDbSchemaInvalidDiffReaderClassException( $readerClass ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcDbSchemaDiffReader', class_implements( $readerClass ) ) ) { throw new ezcDbSchemaInvalidDiffReaderClassException( $readerClass ); } self::$diffReadHandlers[$type] = $readerClass; }
[ "static", "public", "function", "addDiffReader", "(", "$", "type", ",", "$", "readerClass", ")", "{", "// Check if the passed classname actually exists", "if", "(", "!", "ezcBaseFeatures", "::", "classExists", "(", "$", "readerClass", ",", "true", ")", ")", "{", "throw", "new", "ezcDbSchemaInvalidDiffReaderClassException", "(", "$", "readerClass", ")", ";", "}", "// Check if the passed classname actually implements the interface.", "if", "(", "!", "in_array", "(", "'ezcDbSchemaDiffReader'", ",", "class_implements", "(", "$", "readerClass", ")", ")", ")", "{", "throw", "new", "ezcDbSchemaInvalidDiffReaderClassException", "(", "$", "readerClass", ")", ";", "}", "self", "::", "$", "diffReadHandlers", "[", "$", "type", "]", "=", "$", "readerClass", ";", "}" ]
Adds the difference read handler class $readerClass to the manager for $type @throws ezcDbSchemaInvalidReaderClassException if the $readerClass doesn't exist or doesn't extend the abstract class ezcDbSchemaDiffReader. @param string $type @param string $readerClass
[ "Adds", "the", "difference", "read", "handler", "class", "$readerClass", "to", "the", "manager", "for", "$type" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php#L232-L246
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php
ezcDbSchemaHandlerManager.addDiffWriter
static public function addDiffWriter( $type, $writerClass ) { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $writerClass, true ) ) { throw new ezcDbSchemaInvalidDiffWriterClassException( $writerClass ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcDbSchemaDiffWriter', class_implements( $writerClass ) ) ) { throw new ezcDbSchemaInvalidDiffWriterClassException( $writerClass ); } self::$diffWriteHandlers[$type] = $writerClass; }
php
static public function addDiffWriter( $type, $writerClass ) { // Check if the passed classname actually exists if ( !ezcBaseFeatures::classExists( $writerClass, true ) ) { throw new ezcDbSchemaInvalidDiffWriterClassException( $writerClass ); } // Check if the passed classname actually implements the interface. if ( !in_array( 'ezcDbSchemaDiffWriter', class_implements( $writerClass ) ) ) { throw new ezcDbSchemaInvalidDiffWriterClassException( $writerClass ); } self::$diffWriteHandlers[$type] = $writerClass; }
[ "static", "public", "function", "addDiffWriter", "(", "$", "type", ",", "$", "writerClass", ")", "{", "// Check if the passed classname actually exists", "if", "(", "!", "ezcBaseFeatures", "::", "classExists", "(", "$", "writerClass", ",", "true", ")", ")", "{", "throw", "new", "ezcDbSchemaInvalidDiffWriterClassException", "(", "$", "writerClass", ")", ";", "}", "// Check if the passed classname actually implements the interface.", "if", "(", "!", "in_array", "(", "'ezcDbSchemaDiffWriter'", ",", "class_implements", "(", "$", "writerClass", ")", ")", ")", "{", "throw", "new", "ezcDbSchemaInvalidDiffWriterClassException", "(", "$", "writerClass", ")", ";", "}", "self", "::", "$", "diffWriteHandlers", "[", "$", "type", "]", "=", "$", "writerClass", ";", "}" ]
Adds the difference write handler class $writerClass to the manager for $type @throws ezcDbSchemaInvalidWriterClassException if the $writerClass doesn't exist or doesn't extend the abstract class ezcDbSchemaDiffWriter. @param string $type @param string $writerClass
[ "Adds", "the", "difference", "write", "handler", "class", "$writerClass", "to", "the", "manager", "for", "$type" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handler_manager.php#L257-L271
lokhman/silex-tools
src/Silex/Console/Provider/DoctrineMigrationsServiceProvider.php
DoctrineMigrationsServiceProvider.register
public function register(Container $app) { $app['migrations.output_writer'] = new OutputWriter( function ($message) { $output = new ConsoleOutput(); $output->writeln($message); } ); $app['migrations.directory'] = null; $app['migrations.namespace'] = null; $app['migrations.name'] = 'Migrations'; $app['migrations.table_name'] = '_migrations'; }
php
public function register(Container $app) { $app['migrations.output_writer'] = new OutputWriter( function ($message) { $output = new ConsoleOutput(); $output->writeln($message); } ); $app['migrations.directory'] = null; $app['migrations.namespace'] = null; $app['migrations.name'] = 'Migrations'; $app['migrations.table_name'] = '_migrations'; }
[ "public", "function", "register", "(", "Container", "$", "app", ")", "{", "$", "app", "[", "'migrations.output_writer'", "]", "=", "new", "OutputWriter", "(", "function", "(", "$", "message", ")", "{", "$", "output", "=", "new", "ConsoleOutput", "(", ")", ";", "$", "output", "->", "writeln", "(", "$", "message", ")", ";", "}", ")", ";", "$", "app", "[", "'migrations.directory'", "]", "=", "null", ";", "$", "app", "[", "'migrations.namespace'", "]", "=", "null", ";", "$", "app", "[", "'migrations.name'", "]", "=", "'Migrations'", ";", "$", "app", "[", "'migrations.table_name'", "]", "=", "'_migrations'", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/lokhman/silex-tools/blob/91e84099479beb4e866abc88a55ed1e457a8a9e9/src/Silex/Console/Provider/DoctrineMigrationsServiceProvider.php#L54-L67
lokhman/silex-tools
src/Silex/Console/Provider/DoctrineMigrationsServiceProvider.php
DoctrineMigrationsServiceProvider.boot
public function boot(Application $app) { $commands = [ 'Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\LatestCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand', ]; $helperSet = new HelperSet([ 'connection' => new ConnectionHelper($app['db']), 'question' => new QuestionHelper(), ]); if (isset($app['orm.em'])) { // Doctrine ORM commands and helpers $helperSet->set(new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($app['orm.em']), 'em'); $commands[] = 'Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand'; } $this->getConsole()->setHelperSet($helperSet); $configuration = new Configuration($app['db'], $app['migrations.output_writer']); $configuration->setMigrationsDirectory($app['migrations.directory']); $configuration->setMigrationsNamespace($app['migrations.namespace']); $configuration->setMigrationsTableName($app['migrations.table_name']); $configuration->setName($app['migrations.name']); $configuration->registerMigrationsFromDirectory($app['migrations.directory']); foreach ($commands as $name) { /** @var AbstractCommand $command */ $command = new $name(); $command->setMigrationConfiguration($configuration); $this->getConsole()->add($command); } }
php
public function boot(Application $app) { $commands = [ 'Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\LatestCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand', 'Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand', ]; $helperSet = new HelperSet([ 'connection' => new ConnectionHelper($app['db']), 'question' => new QuestionHelper(), ]); if (isset($app['orm.em'])) { // Doctrine ORM commands and helpers $helperSet->set(new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($app['orm.em']), 'em'); $commands[] = 'Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand'; } $this->getConsole()->setHelperSet($helperSet); $configuration = new Configuration($app['db'], $app['migrations.output_writer']); $configuration->setMigrationsDirectory($app['migrations.directory']); $configuration->setMigrationsNamespace($app['migrations.namespace']); $configuration->setMigrationsTableName($app['migrations.table_name']); $configuration->setName($app['migrations.name']); $configuration->registerMigrationsFromDirectory($app['migrations.directory']); foreach ($commands as $name) { /** @var AbstractCommand $command */ $command = new $name(); $command->setMigrationConfiguration($configuration); $this->getConsole()->add($command); } }
[ "public", "function", "boot", "(", "Application", "$", "app", ")", "{", "$", "commands", "=", "[", "'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\ExecuteCommand'", ",", "'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\GenerateCommand'", ",", "'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\LatestCommand'", ",", "'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\MigrateCommand'", ",", "'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\StatusCommand'", ",", "'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\VersionCommand'", ",", "]", ";", "$", "helperSet", "=", "new", "HelperSet", "(", "[", "'connection'", "=>", "new", "ConnectionHelper", "(", "$", "app", "[", "'db'", "]", ")", ",", "'question'", "=>", "new", "QuestionHelper", "(", ")", ",", "]", ")", ";", "if", "(", "isset", "(", "$", "app", "[", "'orm.em'", "]", ")", ")", "{", "// Doctrine ORM commands and helpers", "$", "helperSet", "->", "set", "(", "new", "\\", "Doctrine", "\\", "ORM", "\\", "Tools", "\\", "Console", "\\", "Helper", "\\", "EntityManagerHelper", "(", "$", "app", "[", "'orm.em'", "]", ")", ",", "'em'", ")", ";", "$", "commands", "[", "]", "=", "'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\DiffCommand'", ";", "}", "$", "this", "->", "getConsole", "(", ")", "->", "setHelperSet", "(", "$", "helperSet", ")", ";", "$", "configuration", "=", "new", "Configuration", "(", "$", "app", "[", "'db'", "]", ",", "$", "app", "[", "'migrations.output_writer'", "]", ")", ";", "$", "configuration", "->", "setMigrationsDirectory", "(", "$", "app", "[", "'migrations.directory'", "]", ")", ";", "$", "configuration", "->", "setMigrationsNamespace", "(", "$", "app", "[", "'migrations.namespace'", "]", ")", ";", "$", "configuration", "->", "setMigrationsTableName", "(", "$", "app", "[", "'migrations.table_name'", "]", ")", ";", "$", "configuration", "->", "setName", "(", "$", "app", "[", "'migrations.name'", "]", ")", ";", "$", "configuration", "->", "registerMigrationsFromDirectory", "(", "$", "app", "[", "'migrations.directory'", "]", ")", ";", "foreach", "(", "$", "commands", "as", "$", "name", ")", "{", "/** @var AbstractCommand $command */", "$", "command", "=", "new", "$", "name", "(", ")", ";", "$", "command", "->", "setMigrationConfiguration", "(", "$", "configuration", ")", ";", "$", "this", "->", "getConsole", "(", ")", "->", "add", "(", "$", "command", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/lokhman/silex-tools/blob/91e84099479beb4e866abc88a55ed1e457a8a9e9/src/Silex/Console/Provider/DoctrineMigrationsServiceProvider.php#L72-L109
Danzabar/config-builder
src/Data/ParamBag.php
ParamBag.recursiveReplace
public function recursiveReplace($search, $replace) { $json = json_encode($this->params); $json = str_replace($search, $replace, $json); $this->params = json_decode($json, TRUE); }
php
public function recursiveReplace($search, $replace) { $json = json_encode($this->params); $json = str_replace($search, $replace, $json); $this->params = json_decode($json, TRUE); }
[ "public", "function", "recursiveReplace", "(", "$", "search", ",", "$", "replace", ")", "{", "$", "json", "=", "json_encode", "(", "$", "this", "->", "params", ")", ";", "$", "json", "=", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "$", "json", ")", ";", "$", "this", "->", "params", "=", "json_decode", "(", "$", "json", ",", "TRUE", ")", ";", "}" ]
Search and replace function for multi level arrays @param String $search @param String $replace @return void @author Dan Cox
[ "Search", "and", "replace", "function", "for", "multi", "level", "arrays" ]
train
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/ParamBag.php#L145-L152
Danzabar/config-builder
src/Data/ParamBag.php
ParamBag.rollback
public function rollback() { if($this->hasBackup) { $this->params = $this->backup; } else { throw new Exceptions\NoValidBackup($this->params); } }
php
public function rollback() { if($this->hasBackup) { $this->params = $this->backup; } else { throw new Exceptions\NoValidBackup($this->params); } }
[ "public", "function", "rollback", "(", ")", "{", "if", "(", "$", "this", "->", "hasBackup", ")", "{", "$", "this", "->", "params", "=", "$", "this", "->", "backup", ";", "}", "else", "{", "throw", "new", "Exceptions", "\\", "NoValidBackup", "(", "$", "this", "->", "params", ")", ";", "}", "}" ]
Uses the backup array to revert the params array @return void @author Dan Cox @throws Exceptions\NoValidBackup
[ "Uses", "the", "backup", "array", "to", "revert", "the", "params", "array" ]
train
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/ParamBag.php#L187-L197
Isset/pushnotification
src/PushNotification/Type/Android/AndroidNotifier.php
AndroidNotifier.sendMessage
protected function sendMessage(Message $message, string $connectionName = null): MessageEnvelope { /* @var AndroidMessage $message */ $connection = $this->getConnectionHandler()->getConnection($connectionName); /* @var AndroidConnection $connection */ $messageEnvelope = $this->createMessageEnvelope($message); /* @var AndroidMessageEnvelope $messageEnvelope */ $this->sendMessageEnvelope($connection, $messageEnvelope); return $messageEnvelope; }
php
protected function sendMessage(Message $message, string $connectionName = null): MessageEnvelope { /* @var AndroidMessage $message */ $connection = $this->getConnectionHandler()->getConnection($connectionName); /* @var AndroidConnection $connection */ $messageEnvelope = $this->createMessageEnvelope($message); /* @var AndroidMessageEnvelope $messageEnvelope */ $this->sendMessageEnvelope($connection, $messageEnvelope); return $messageEnvelope; }
[ "protected", "function", "sendMessage", "(", "Message", "$", "message", ",", "string", "$", "connectionName", "=", "null", ")", ":", "MessageEnvelope", "{", "/* @var AndroidMessage $message */", "$", "connection", "=", "$", "this", "->", "getConnectionHandler", "(", ")", "->", "getConnection", "(", "$", "connectionName", ")", ";", "/* @var AndroidConnection $connection */", "$", "messageEnvelope", "=", "$", "this", "->", "createMessageEnvelope", "(", "$", "message", ")", ";", "/* @var AndroidMessageEnvelope $messageEnvelope */", "$", "this", "->", "sendMessageEnvelope", "(", "$", "connection", ",", "$", "messageEnvelope", ")", ";", "return", "$", "messageEnvelope", ";", "}" ]
@param Message $message @param string $connectionName @throws ConnectionHandlerException @throws ConnectionException @return MessageEnvelope
[ "@param", "Message", "$message", "@param", "string", "$connectionName" ]
train
https://github.com/Isset/pushnotification/blob/5e7634dc6b1cf4f7c371d1890243a25252db0d85/src/PushNotification/Type/Android/AndroidNotifier.php#L40-L50
Isset/pushnotification
src/PushNotification/Type/Android/AndroidNotifier.php
AndroidNotifier.flushQueueItem
protected function flushQueueItem(string $connectionName = null, MessageEnvelopeQueue $queue) { if ($queue->isEmpty()) { return; } $connection = $this->getConnectionHandler()->getConnection($connectionName); /* @var AndroidConnection $connection */ foreach ($queue->getQueue() as $messageEnvelope) { /* @var AndroidMessageEnvelope $messageEnvelope */ $this->sendMessageEnvelope($connection, $messageEnvelope); } $queue->clear(); }
php
protected function flushQueueItem(string $connectionName = null, MessageEnvelopeQueue $queue) { if ($queue->isEmpty()) { return; } $connection = $this->getConnectionHandler()->getConnection($connectionName); /* @var AndroidConnection $connection */ foreach ($queue->getQueue() as $messageEnvelope) { /* @var AndroidMessageEnvelope $messageEnvelope */ $this->sendMessageEnvelope($connection, $messageEnvelope); } $queue->clear(); }
[ "protected", "function", "flushQueueItem", "(", "string", "$", "connectionName", "=", "null", ",", "MessageEnvelopeQueue", "$", "queue", ")", "{", "if", "(", "$", "queue", "->", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "$", "connection", "=", "$", "this", "->", "getConnectionHandler", "(", ")", "->", "getConnection", "(", "$", "connectionName", ")", ";", "/* @var AndroidConnection $connection */", "foreach", "(", "$", "queue", "->", "getQueue", "(", ")", "as", "$", "messageEnvelope", ")", "{", "/* @var AndroidMessageEnvelope $messageEnvelope */", "$", "this", "->", "sendMessageEnvelope", "(", "$", "connection", ",", "$", "messageEnvelope", ")", ";", "}", "$", "queue", "->", "clear", "(", ")", ";", "}" ]
@param string $connectionName @param MessageEnvelopeQueue $queue @throws ConnectionHandlerException @throws ConnectionException
[ "@param", "string", "$connectionName", "@param", "MessageEnvelopeQueue", "$queue" ]
train
https://github.com/Isset/pushnotification/blob/5e7634dc6b1cf4f7c371d1890243a25252db0d85/src/PushNotification/Type/Android/AndroidNotifier.php#L70-L82
bobfridley/laravel-vonage
src/Vonage.php
Vonage.makeRequest
public function makeRequest($uri) { $request = $this->client->get($uri, [ // 'cookies' => $this->cookie, 'query' => [ 'htmlLogin' => $this->auth['username'], 'htmlPassword' => $this->auth['password'] ], 'headers' => ['X-Vonage' => 'vonage'] ]); if (!isset($request)) { throw BadResponse::create($request); } $response = json_decode($request->getBody()->getContents(), true); return $response; }
php
public function makeRequest($uri) { $request = $this->client->get($uri, [ // 'cookies' => $this->cookie, 'query' => [ 'htmlLogin' => $this->auth['username'], 'htmlPassword' => $this->auth['password'] ], 'headers' => ['X-Vonage' => 'vonage'] ]); if (!isset($request)) { throw BadResponse::create($request); } $response = json_decode($request->getBody()->getContents(), true); return $response; }
[ "public", "function", "makeRequest", "(", "$", "uri", ")", "{", "$", "request", "=", "$", "this", "->", "client", "->", "get", "(", "$", "uri", ",", "[", "// 'cookies' => $this->cookie,", "'query'", "=>", "[", "'htmlLogin'", "=>", "$", "this", "->", "auth", "[", "'username'", "]", ",", "'htmlPassword'", "=>", "$", "this", "->", "auth", "[", "'password'", "]", "]", ",", "'headers'", "=>", "[", "'X-Vonage'", "=>", "'vonage'", "]", "]", ")", ";", "if", "(", "!", "isset", "(", "$", "request", ")", ")", "{", "throw", "BadResponse", "::", "create", "(", "$", "request", ")", ";", "}", "$", "response", "=", "json_decode", "(", "$", "request", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "true", ")", ";", "return", "$", "response", ";", "}" ]
[makeRequest description] @param [type] $uri [description] @return [type] [description]
[ "[", "makeRequest", "description", "]" ]
train
https://github.com/bobfridley/laravel-vonage/blob/e422af44a449c3147878c317b865508b1afa50e6/src/Vonage.php#L68-L86
bobfridley/laravel-vonage
src/Vonage.php
Vonage.getExtensions
public function getExtensions() { $uri = $this->base_uri . '/presence/rest/directory'; $extensions = $this->makeRequest($uri); if (!isset($extensions['extensions'])) { throw BadResponse::create($vonage); } if (!count($extensions['extensions'])) { return false; }; foreach ($extensions['extensions'] as $extension => $value) { if (strlen(trim($value['name'])) > 0) { switch ($value['status']) { case 'available': $callIcon = 'fa-phone'; break; case 'busy': $callIcon = 'fa-volume-control-phone'; break; default: $callIcon = 'fa-times'; break; } $callDirection = ''; $onCallWith = ''; $onCallWithName = ''; $onCallWithNumber = ''; $directionIcon = ''; if ($value['status'] == 'busy') { $extentionDetails = $this->getExtension($extension); $extentionDetails = $extentionDetails['details']['presence']; if (count($extentionDetails) > 0) { $callDirection = $extentionDetails['direction']; switch ($callDirection) { case 'inbound': $directionIcon = 'fa-long-arrow-left'; break; case 'outbound': $directionIcon = 'fa-long-arrow-right'; break; default: $directionIcon = ''; break; } $onCallWithName = $extentionDetails['onCallWithName']; // remove 1st digit = 1 $onCallWithNumber = substr($extentionDetails['onCallWith'], 1, 10); // get Crm company $company = Crm::getCompanyByPhone($onCallWithNumber); $onCallWith = (count($company) === 0) // ? (!empty($onCallWithName) ? $onCallWithName : $onCallWithNumber) ? ($onCallWithName == 'null' ? $onCallWithNumber : $onCallWithName) : $company[0]['company']; } } $extensionInfo[$extension] = array( 'extension' => $extension, 'name' => $value['name'], 'status' => $value['status'], 'loginName' => $value['loginName'], 'callIcon' => $callIcon, 'directionIcon' => $directionIcon, 'company' => $onCallWith, 'callerId' => $onCallWithName ); } } return $extensionInfo; }
php
public function getExtensions() { $uri = $this->base_uri . '/presence/rest/directory'; $extensions = $this->makeRequest($uri); if (!isset($extensions['extensions'])) { throw BadResponse::create($vonage); } if (!count($extensions['extensions'])) { return false; }; foreach ($extensions['extensions'] as $extension => $value) { if (strlen(trim($value['name'])) > 0) { switch ($value['status']) { case 'available': $callIcon = 'fa-phone'; break; case 'busy': $callIcon = 'fa-volume-control-phone'; break; default: $callIcon = 'fa-times'; break; } $callDirection = ''; $onCallWith = ''; $onCallWithName = ''; $onCallWithNumber = ''; $directionIcon = ''; if ($value['status'] == 'busy') { $extentionDetails = $this->getExtension($extension); $extentionDetails = $extentionDetails['details']['presence']; if (count($extentionDetails) > 0) { $callDirection = $extentionDetails['direction']; switch ($callDirection) { case 'inbound': $directionIcon = 'fa-long-arrow-left'; break; case 'outbound': $directionIcon = 'fa-long-arrow-right'; break; default: $directionIcon = ''; break; } $onCallWithName = $extentionDetails['onCallWithName']; // remove 1st digit = 1 $onCallWithNumber = substr($extentionDetails['onCallWith'], 1, 10); // get Crm company $company = Crm::getCompanyByPhone($onCallWithNumber); $onCallWith = (count($company) === 0) // ? (!empty($onCallWithName) ? $onCallWithName : $onCallWithNumber) ? ($onCallWithName == 'null' ? $onCallWithNumber : $onCallWithName) : $company[0]['company']; } } $extensionInfo[$extension] = array( 'extension' => $extension, 'name' => $value['name'], 'status' => $value['status'], 'loginName' => $value['loginName'], 'callIcon' => $callIcon, 'directionIcon' => $directionIcon, 'company' => $onCallWith, 'callerId' => $onCallWithName ); } } return $extensionInfo; }
[ "public", "function", "getExtensions", "(", ")", "{", "$", "uri", "=", "$", "this", "->", "base_uri", ".", "'/presence/rest/directory'", ";", "$", "extensions", "=", "$", "this", "->", "makeRequest", "(", "$", "uri", ")", ";", "if", "(", "!", "isset", "(", "$", "extensions", "[", "'extensions'", "]", ")", ")", "{", "throw", "BadResponse", "::", "create", "(", "$", "vonage", ")", ";", "}", "if", "(", "!", "count", "(", "$", "extensions", "[", "'extensions'", "]", ")", ")", "{", "return", "false", ";", "}", ";", "foreach", "(", "$", "extensions", "[", "'extensions'", "]", "as", "$", "extension", "=>", "$", "value", ")", "{", "if", "(", "strlen", "(", "trim", "(", "$", "value", "[", "'name'", "]", ")", ")", ">", "0", ")", "{", "switch", "(", "$", "value", "[", "'status'", "]", ")", "{", "case", "'available'", ":", "$", "callIcon", "=", "'fa-phone'", ";", "break", ";", "case", "'busy'", ":", "$", "callIcon", "=", "'fa-volume-control-phone'", ";", "break", ";", "default", ":", "$", "callIcon", "=", "'fa-times'", ";", "break", ";", "}", "$", "callDirection", "=", "''", ";", "$", "onCallWith", "=", "''", ";", "$", "onCallWithName", "=", "''", ";", "$", "onCallWithNumber", "=", "''", ";", "$", "directionIcon", "=", "''", ";", "if", "(", "$", "value", "[", "'status'", "]", "==", "'busy'", ")", "{", "$", "extentionDetails", "=", "$", "this", "->", "getExtension", "(", "$", "extension", ")", ";", "$", "extentionDetails", "=", "$", "extentionDetails", "[", "'details'", "]", "[", "'presence'", "]", ";", "if", "(", "count", "(", "$", "extentionDetails", ")", ">", "0", ")", "{", "$", "callDirection", "=", "$", "extentionDetails", "[", "'direction'", "]", ";", "switch", "(", "$", "callDirection", ")", "{", "case", "'inbound'", ":", "$", "directionIcon", "=", "'fa-long-arrow-left'", ";", "break", ";", "case", "'outbound'", ":", "$", "directionIcon", "=", "'fa-long-arrow-right'", ";", "break", ";", "default", ":", "$", "directionIcon", "=", "''", ";", "break", ";", "}", "$", "onCallWithName", "=", "$", "extentionDetails", "[", "'onCallWithName'", "]", ";", "// remove 1st digit = 1", "$", "onCallWithNumber", "=", "substr", "(", "$", "extentionDetails", "[", "'onCallWith'", "]", ",", "1", ",", "10", ")", ";", "// get Crm company", "$", "company", "=", "Crm", "::", "getCompanyByPhone", "(", "$", "onCallWithNumber", ")", ";", "$", "onCallWith", "=", "(", "count", "(", "$", "company", ")", "===", "0", ")", "// ? (!empty($onCallWithName) ? $onCallWithName : $onCallWithNumber)", "?", "(", "$", "onCallWithName", "==", "'null'", "?", "$", "onCallWithNumber", ":", "$", "onCallWithName", ")", ":", "$", "company", "[", "0", "]", "[", "'company'", "]", ";", "}", "}", "$", "extensionInfo", "[", "$", "extension", "]", "=", "array", "(", "'extension'", "=>", "$", "extension", ",", "'name'", "=>", "$", "value", "[", "'name'", "]", ",", "'status'", "=>", "$", "value", "[", "'status'", "]", ",", "'loginName'", "=>", "$", "value", "[", "'loginName'", "]", ",", "'callIcon'", "=>", "$", "callIcon", ",", "'directionIcon'", "=>", "$", "directionIcon", ",", "'company'", "=>", "$", "onCallWith", ",", "'callerId'", "=>", "$", "onCallWithName", ")", ";", "}", "}", "return", "$", "extensionInfo", ";", "}" ]
[getExtensions description] @return [type] [description]
[ "[", "getExtensions", "description", "]" ]
train
https://github.com/bobfridley/laravel-vonage/blob/e422af44a449c3147878c317b865508b1afa50e6/src/Vonage.php#L92-L174
bobfridley/laravel-vonage
src/Vonage.php
Vonage.getExtension
public function getExtension($extension) { $uri = $this->base_uri . "/presence/rest/extension/{$extension}"; $extentionDetails = $this->makeRequest($uri); return $extentionDetails; }
php
public function getExtension($extension) { $uri = $this->base_uri . "/presence/rest/extension/{$extension}"; $extentionDetails = $this->makeRequest($uri); return $extentionDetails; }
[ "public", "function", "getExtension", "(", "$", "extension", ")", "{", "$", "uri", "=", "$", "this", "->", "base_uri", ".", "\"/presence/rest/extension/{$extension}\"", ";", "$", "extentionDetails", "=", "$", "this", "->", "makeRequest", "(", "$", "uri", ")", ";", "return", "$", "extentionDetails", ";", "}" ]
[getExtension description] @param [type] $extension [description] @return [type] [description]
[ "[", "getExtension", "description", "]" ]
train
https://github.com/bobfridley/laravel-vonage/blob/e422af44a449c3147878c317b865508b1afa50e6/src/Vonage.php#L181-L188
bobfridley/laravel-vonage
src/Vonage.php
Vonage.getCallHistory
public function getCallHistory( string $extension = null, Carbon $start = null, Carbon $end = null, string $result = null) { if (is_null($start)) { $start = Carbon::now('America/New_York')->startOfDay()->format(DateTime::RFC3339); $start = substr($start, 0, -6); } if (is_null($end)) { $end = Carbon::now('America/New_York')->format(DateTime::RFC3339); } if (is_null($result)) { $result = 'answered,unanswered,voicemail'; } $uri = $this->base_uri . "/presence/rest/callhistory/{$extension}?start={$start}&end={$end}&result={$result}"; $callHistory = $this->makeRequest($uri); return $callHistory; }
php
public function getCallHistory( string $extension = null, Carbon $start = null, Carbon $end = null, string $result = null) { if (is_null($start)) { $start = Carbon::now('America/New_York')->startOfDay()->format(DateTime::RFC3339); $start = substr($start, 0, -6); } if (is_null($end)) { $end = Carbon::now('America/New_York')->format(DateTime::RFC3339); } if (is_null($result)) { $result = 'answered,unanswered,voicemail'; } $uri = $this->base_uri . "/presence/rest/callhistory/{$extension}?start={$start}&end={$end}&result={$result}"; $callHistory = $this->makeRequest($uri); return $callHistory; }
[ "public", "function", "getCallHistory", "(", "string", "$", "extension", "=", "null", ",", "Carbon", "$", "start", "=", "null", ",", "Carbon", "$", "end", "=", "null", ",", "string", "$", "result", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "start", ")", ")", "{", "$", "start", "=", "Carbon", "::", "now", "(", "'America/New_York'", ")", "->", "startOfDay", "(", ")", "->", "format", "(", "DateTime", "::", "RFC3339", ")", ";", "$", "start", "=", "substr", "(", "$", "start", ",", "0", ",", "-", "6", ")", ";", "}", "if", "(", "is_null", "(", "$", "end", ")", ")", "{", "$", "end", "=", "Carbon", "::", "now", "(", "'America/New_York'", ")", "->", "format", "(", "DateTime", "::", "RFC3339", ")", ";", "}", "if", "(", "is_null", "(", "$", "result", ")", ")", "{", "$", "result", "=", "'answered,unanswered,voicemail'", ";", "}", "$", "uri", "=", "$", "this", "->", "base_uri", ".", "\"/presence/rest/callhistory/{$extension}?start={$start}&end={$end}&result={$result}\"", ";", "$", "callHistory", "=", "$", "this", "->", "makeRequest", "(", "$", "uri", ")", ";", "return", "$", "callHistory", ";", "}" ]
[getCallHistory description] @param string $extension [description] @param Carbon|null $start [description] @param Carbon|null $end [description] @param string $result [description] @return array [description]
[ "[", "getCallHistory", "description", "]" ]
train
https://github.com/bobfridley/laravel-vonage/blob/e422af44a449c3147878c317b865508b1afa50e6/src/Vonage.php#L198-L222
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validator.php
ezcDbSchemaValidator.validate
static public function validate( ezcDbSchema $schema ) { $validationErrors = array(); foreach ( self::$validators as $validatorClass ) { $errors = call_user_func( array( $validatorClass, 'validate' ), $schema ); foreach ( $errors as $error ) { $validationErrors[] = $error; } } return $validationErrors; }
php
static public function validate( ezcDbSchema $schema ) { $validationErrors = array(); foreach ( self::$validators as $validatorClass ) { $errors = call_user_func( array( $validatorClass, 'validate' ), $schema ); foreach ( $errors as $error ) { $validationErrors[] = $error; } } return $validationErrors; }
[ "static", "public", "function", "validate", "(", "ezcDbSchema", "$", "schema", ")", "{", "$", "validationErrors", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "validators", "as", "$", "validatorClass", ")", "{", "$", "errors", "=", "call_user_func", "(", "array", "(", "$", "validatorClass", ",", "'validate'", ")", ",", "$", "schema", ")", ";", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "$", "validationErrors", "[", "]", "=", "$", "error", ";", "}", "}", "return", "$", "validationErrors", ";", "}" ]
Validates the ezcDbSchema object $schema with the recorded validator classes. This method loops over all the known validator classes and calls their validate() method with the $schema as argument. It returns an array containing validation errors as strings. @todo implement from an interface @param ezcDbSchema $schema @return array(string)
[ "Validates", "the", "ezcDbSchema", "object", "$schema", "with", "the", "recorded", "validator", "classes", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validator.php#L58-L71
mustardandrew/muan-laravel-acl
src/Commands/Role/ListCommand.php
ListCommand.handle
public function handle() { $roles = Role::all(['id', 'name', 'created_at', 'updated_at']); if ($roles->count()) { $this->table( ['ID', 'Role', 'Created At', 'Updated At'], $roles->toArray() ); } else { $this->warn("Not found any roles!"); } return 0; }
php
public function handle() { $roles = Role::all(['id', 'name', 'created_at', 'updated_at']); if ($roles->count()) { $this->table( ['ID', 'Role', 'Created At', 'Updated At'], $roles->toArray() ); } else { $this->warn("Not found any roles!"); } return 0; }
[ "public", "function", "handle", "(", ")", "{", "$", "roles", "=", "Role", "::", "all", "(", "[", "'id'", ",", "'name'", ",", "'created_at'", ",", "'updated_at'", "]", ")", ";", "if", "(", "$", "roles", "->", "count", "(", ")", ")", "{", "$", "this", "->", "table", "(", "[", "'ID'", ",", "'Role'", ",", "'Created At'", ",", "'Updated At'", "]", ",", "$", "roles", "->", "toArray", "(", ")", ")", ";", "}", "else", "{", "$", "this", "->", "warn", "(", "\"Not found any roles!\"", ")", ";", "}", "return", "0", ";", "}" ]
Execute the console command. @return mixed
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Commands/Role/ListCommand.php#L34-L48
php-lug/lug
src/Bundle/GridBundle/DependencyInjection/LugGridExtension.php
LugGridExtension.loadInternal
protected function loadInternal(array $config, ContainerBuilder $container) { $resources = [ 'action', 'batch', 'builder', 'column', 'context', 'filter', 'form', 'handler', 'registry', 'renderer', 'slicer', 'sort', 'twig', 'view', ]; $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); foreach ($resources as $resource) { $loader->load($resource.'.xml'); } $this->loadTemplates($config['templates'], $container); $this->loadColumns($config['columns'], $container); }
php
protected function loadInternal(array $config, ContainerBuilder $container) { $resources = [ 'action', 'batch', 'builder', 'column', 'context', 'filter', 'form', 'handler', 'registry', 'renderer', 'slicer', 'sort', 'twig', 'view', ]; $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); foreach ($resources as $resource) { $loader->load($resource.'.xml'); } $this->loadTemplates($config['templates'], $container); $this->loadColumns($config['columns'], $container); }
[ "protected", "function", "loadInternal", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "resources", "=", "[", "'action'", ",", "'batch'", ",", "'builder'", ",", "'column'", ",", "'context'", ",", "'filter'", ",", "'form'", ",", "'handler'", ",", "'registry'", ",", "'renderer'", ",", "'slicer'", ",", "'sort'", ",", "'twig'", ",", "'view'", ",", "]", ";", "$", "loader", "=", "new", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "foreach", "(", "$", "resources", "as", "$", "resource", ")", "{", "$", "loader", "->", "load", "(", "$", "resource", ".", "'.xml'", ")", ";", "}", "$", "this", "->", "loadTemplates", "(", "$", "config", "[", "'templates'", "]", ",", "$", "container", ")", ";", "$", "this", "->", "loadColumns", "(", "$", "config", "[", "'columns'", "]", ",", "$", "container", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/DependencyInjection/LugGridExtension.php#L27-L54
ezsystems/ezcomments-ls-extension
classes/ezcomsubscriptionmanager.php
ezcomSubscriptionManager.activateSubscription
public function activateSubscription( $hashString ) { // 1. fetch the subscription object $subscription = ezcomSubscription::fetchByHashString( $hashString ); if ( is_null( $subscription ) ) { $this->tpl->setVariable( 'error_message', ezpI18n::tr( 'ezcomments/comment/activate', 'There is no subscription with the hash string!' ) ); } else { if ( $subscription->attribute( 'enabled' ) ) { ezDebugSetting::writeNotice( 'extension-ezcomments', 'Subscription activated', __METHOD__ ); } $subscriber = ezcomSubscriber::fetch( $subscription->attribute( 'subscriber_id' ) ); if ( $subscriber->attribute( 'enabled' ) ) { $subscription->enable(); $this->tpl->setVariable( 'subscriber', $subscriber ); } else { $this->tpl->setVariable( 'error_message', ezpI18n::tr( 'ezcomments/comment/activate', 'The subscriber is disabled!' ) ); } } }
php
public function activateSubscription( $hashString ) { // 1. fetch the subscription object $subscription = ezcomSubscription::fetchByHashString( $hashString ); if ( is_null( $subscription ) ) { $this->tpl->setVariable( 'error_message', ezpI18n::tr( 'ezcomments/comment/activate', 'There is no subscription with the hash string!' ) ); } else { if ( $subscription->attribute( 'enabled' ) ) { ezDebugSetting::writeNotice( 'extension-ezcomments', 'Subscription activated', __METHOD__ ); } $subscriber = ezcomSubscriber::fetch( $subscription->attribute( 'subscriber_id' ) ); if ( $subscriber->attribute( 'enabled' ) ) { $subscription->enable(); $this->tpl->setVariable( 'subscriber', $subscriber ); } else { $this->tpl->setVariable( 'error_message', ezpI18n::tr( 'ezcomments/comment/activate', 'The subscriber is disabled!' ) ); } } }
[ "public", "function", "activateSubscription", "(", "$", "hashString", ")", "{", "// 1. fetch the subscription object", "$", "subscription", "=", "ezcomSubscription", "::", "fetchByHashString", "(", "$", "hashString", ")", ";", "if", "(", "is_null", "(", "$", "subscription", ")", ")", "{", "$", "this", "->", "tpl", "->", "setVariable", "(", "'error_message'", ",", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/activate'", ",", "'There is no subscription with the hash string!'", ")", ")", ";", "}", "else", "{", "if", "(", "$", "subscription", "->", "attribute", "(", "'enabled'", ")", ")", "{", "ezDebugSetting", "::", "writeNotice", "(", "'extension-ezcomments'", ",", "'Subscription activated'", ",", "__METHOD__", ")", ";", "}", "$", "subscriber", "=", "ezcomSubscriber", "::", "fetch", "(", "$", "subscription", "->", "attribute", "(", "'subscriber_id'", ")", ")", ";", "if", "(", "$", "subscriber", "->", "attribute", "(", "'enabled'", ")", ")", "{", "$", "subscription", "->", "enable", "(", ")", ";", "$", "this", "->", "tpl", "->", "setVariable", "(", "'subscriber'", ",", "$", "subscriber", ")", ";", "}", "else", "{", "$", "this", "->", "tpl", "->", "setVariable", "(", "'error_message'", ",", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/activate'", ",", "'The subscriber is disabled!'", ")", ")", ";", "}", "}", "}" ]
Activate subscription If there is error,set 'error_message' to the template, If activation succeeds, set 'subscriber' to the template @param string: $hashString @return void
[ "Activate", "subscription", "If", "there", "is", "error", "set", "error_message", "to", "the", "template", "If", "activation", "succeeds", "set", "subscriber", "to", "the", "template" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L35-L64
ezsystems/ezcomments-ls-extension
classes/ezcomsubscriptionmanager.php
ezcomSubscriptionManager.addSubscription
public function addSubscription( $email, $user, $contentID, $languageID, $subscriptionType, $currentTime, $activate = true ) { //1. insert into subscriber $ezcommentsINI = eZINI::instance( 'ezcomments.ini' ); $subscriber = ezcomSubscriber::fetchByEmail( $email ); //if there is no data in subscriber for same email, save it if ( is_null( $subscriber ) ) { $subscriber = ezcomSubscriber::create(); $subscriber->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) ); $subscriber->setAttribute( 'email', $email ); if ( $user->isAnonymous() ) { $util = ezcomUtility::instance(); $hashString = $util->generateSusbcriberHashString( $subscriber ); $subscriber->setAttribute( 'hash_string', $hashString ); } $subscriber->store(); eZDebugSetting::writeNotice( 'extension-ezcomments', 'Subscriber does not exist, added one', __METHOD__ ); $subscriber = ezcomSubscriber::fetchByEmail( $email ); } else { if ( $subscriber->attribute( 'enabled' ) == false ) { throw new Exception('Subscription can not be added because the subscriber is disabled.', self::ERROR_SUBSCRIBER_DISABLED ); } } //3 insert into subscription table // if there is no data in ezcomment_subscription with given contentobject_id and subscriber_id $hasSubscription = ezcomSubscription::exists( $contentID, $languageID, $subscriptionType, $email ); if ( $hasSubscription === false ) { $subscription = ezcomSubscription::create(); $subscription->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) ); $subscription->setAttribute( 'subscriber_id', $subscriber->attribute( 'id' ) ); $subscription->setAttribute( 'subscription_type', $subscriptionType ); $subscription->setAttribute( 'content_id', $contentID ); $subscription->setAttribute( 'language_id', $languageID ); $subscription->setAttribute( 'subscription_time', $currentTime ); $defaultActivated = $ezcommentsINI->variable( 'CommentSettings', 'SubscriptionActivated' ); if ( $user->isAnonymous() && $defaultActivated !== 'true' && $activate === true ) { $subscription->setAttribute( 'enabled', 0 ); $utility = ezcomUtility::instance(); $subscription->setAttribute( 'hash_string', $utility->generateSubscriptionHashString( $subscription ) ); $subscription->store(); $result = ezcomSubscriptionManager::sendActivationEmail( eZContentObject::fetch( $contentID ), $subscriber, $subscription ); if ( !$result ) { eZDebug::writeError( "Error sending mail to '$email'", __METHOD__ ); } } else { $subscription->setAttribute( 'enabled', 1 ); $subscription->store(); } eZDebugSetting::writeNotice( 'extension-ezcomments', 'No existing subscription for this content and user, added one', __METHOD__ ); } }
php
public function addSubscription( $email, $user, $contentID, $languageID, $subscriptionType, $currentTime, $activate = true ) { //1. insert into subscriber $ezcommentsINI = eZINI::instance( 'ezcomments.ini' ); $subscriber = ezcomSubscriber::fetchByEmail( $email ); //if there is no data in subscriber for same email, save it if ( is_null( $subscriber ) ) { $subscriber = ezcomSubscriber::create(); $subscriber->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) ); $subscriber->setAttribute( 'email', $email ); if ( $user->isAnonymous() ) { $util = ezcomUtility::instance(); $hashString = $util->generateSusbcriberHashString( $subscriber ); $subscriber->setAttribute( 'hash_string', $hashString ); } $subscriber->store(); eZDebugSetting::writeNotice( 'extension-ezcomments', 'Subscriber does not exist, added one', __METHOD__ ); $subscriber = ezcomSubscriber::fetchByEmail( $email ); } else { if ( $subscriber->attribute( 'enabled' ) == false ) { throw new Exception('Subscription can not be added because the subscriber is disabled.', self::ERROR_SUBSCRIBER_DISABLED ); } } //3 insert into subscription table // if there is no data in ezcomment_subscription with given contentobject_id and subscriber_id $hasSubscription = ezcomSubscription::exists( $contentID, $languageID, $subscriptionType, $email ); if ( $hasSubscription === false ) { $subscription = ezcomSubscription::create(); $subscription->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) ); $subscription->setAttribute( 'subscriber_id', $subscriber->attribute( 'id' ) ); $subscription->setAttribute( 'subscription_type', $subscriptionType ); $subscription->setAttribute( 'content_id', $contentID ); $subscription->setAttribute( 'language_id', $languageID ); $subscription->setAttribute( 'subscription_time', $currentTime ); $defaultActivated = $ezcommentsINI->variable( 'CommentSettings', 'SubscriptionActivated' ); if ( $user->isAnonymous() && $defaultActivated !== 'true' && $activate === true ) { $subscription->setAttribute( 'enabled', 0 ); $utility = ezcomUtility::instance(); $subscription->setAttribute( 'hash_string', $utility->generateSubscriptionHashString( $subscription ) ); $subscription->store(); $result = ezcomSubscriptionManager::sendActivationEmail( eZContentObject::fetch( $contentID ), $subscriber, $subscription ); if ( !$result ) { eZDebug::writeError( "Error sending mail to '$email'", __METHOD__ ); } } else { $subscription->setAttribute( 'enabled', 1 ); $subscription->store(); } eZDebugSetting::writeNotice( 'extension-ezcomments', 'No existing subscription for this content and user, added one', __METHOD__ ); } }
[ "public", "function", "addSubscription", "(", "$", "email", ",", "$", "user", ",", "$", "contentID", ",", "$", "languageID", ",", "$", "subscriptionType", ",", "$", "currentTime", ",", "$", "activate", "=", "true", ")", "{", "//1. insert into subscriber", "$", "ezcommentsINI", "=", "eZINI", "::", "instance", "(", "'ezcomments.ini'", ")", ";", "$", "subscriber", "=", "ezcomSubscriber", "::", "fetchByEmail", "(", "$", "email", ")", ";", "//if there is no data in subscriber for same email, save it", "if", "(", "is_null", "(", "$", "subscriber", ")", ")", "{", "$", "subscriber", "=", "ezcomSubscriber", "::", "create", "(", ")", ";", "$", "subscriber", "->", "setAttribute", "(", "'user_id'", ",", "$", "user", "->", "attribute", "(", "'contentobject_id'", ")", ")", ";", "$", "subscriber", "->", "setAttribute", "(", "'email'", ",", "$", "email", ")", ";", "if", "(", "$", "user", "->", "isAnonymous", "(", ")", ")", "{", "$", "util", "=", "ezcomUtility", "::", "instance", "(", ")", ";", "$", "hashString", "=", "$", "util", "->", "generateSusbcriberHashString", "(", "$", "subscriber", ")", ";", "$", "subscriber", "->", "setAttribute", "(", "'hash_string'", ",", "$", "hashString", ")", ";", "}", "$", "subscriber", "->", "store", "(", ")", ";", "eZDebugSetting", "::", "writeNotice", "(", "'extension-ezcomments'", ",", "'Subscriber does not exist, added one'", ",", "__METHOD__", ")", ";", "$", "subscriber", "=", "ezcomSubscriber", "::", "fetchByEmail", "(", "$", "email", ")", ";", "}", "else", "{", "if", "(", "$", "subscriber", "->", "attribute", "(", "'enabled'", ")", "==", "false", ")", "{", "throw", "new", "Exception", "(", "'Subscription can not be added because the subscriber is disabled.'", ",", "self", "::", "ERROR_SUBSCRIBER_DISABLED", ")", ";", "}", "}", "//3 insert into subscription table", "// if there is no data in ezcomment_subscription with given contentobject_id and subscriber_id", "$", "hasSubscription", "=", "ezcomSubscription", "::", "exists", "(", "$", "contentID", ",", "$", "languageID", ",", "$", "subscriptionType", ",", "$", "email", ")", ";", "if", "(", "$", "hasSubscription", "===", "false", ")", "{", "$", "subscription", "=", "ezcomSubscription", "::", "create", "(", ")", ";", "$", "subscription", "->", "setAttribute", "(", "'user_id'", ",", "$", "user", "->", "attribute", "(", "'contentobject_id'", ")", ")", ";", "$", "subscription", "->", "setAttribute", "(", "'subscriber_id'", ",", "$", "subscriber", "->", "attribute", "(", "'id'", ")", ")", ";", "$", "subscription", "->", "setAttribute", "(", "'subscription_type'", ",", "$", "subscriptionType", ")", ";", "$", "subscription", "->", "setAttribute", "(", "'content_id'", ",", "$", "contentID", ")", ";", "$", "subscription", "->", "setAttribute", "(", "'language_id'", ",", "$", "languageID", ")", ";", "$", "subscription", "->", "setAttribute", "(", "'subscription_time'", ",", "$", "currentTime", ")", ";", "$", "defaultActivated", "=", "$", "ezcommentsINI", "->", "variable", "(", "'CommentSettings'", ",", "'SubscriptionActivated'", ")", ";", "if", "(", "$", "user", "->", "isAnonymous", "(", ")", "&&", "$", "defaultActivated", "!==", "'true'", "&&", "$", "activate", "===", "true", ")", "{", "$", "subscription", "->", "setAttribute", "(", "'enabled'", ",", "0", ")", ";", "$", "utility", "=", "ezcomUtility", "::", "instance", "(", ")", ";", "$", "subscription", "->", "setAttribute", "(", "'hash_string'", ",", "$", "utility", "->", "generateSubscriptionHashString", "(", "$", "subscription", ")", ")", ";", "$", "subscription", "->", "store", "(", ")", ";", "$", "result", "=", "ezcomSubscriptionManager", "::", "sendActivationEmail", "(", "eZContentObject", "::", "fetch", "(", "$", "contentID", ")", ",", "$", "subscriber", ",", "$", "subscription", ")", ";", "if", "(", "!", "$", "result", ")", "{", "eZDebug", "::", "writeError", "(", "\"Error sending mail to '$email'\"", ",", "__METHOD__", ")", ";", "}", "}", "else", "{", "$", "subscription", "->", "setAttribute", "(", "'enabled'", ",", "1", ")", ";", "$", "subscription", "->", "store", "(", ")", ";", "}", "eZDebugSetting", "::", "writeNotice", "(", "'extension-ezcomments'", ",", "'No existing subscription for this content and user, added one'", ",", "__METHOD__", ")", ";", "}", "}" ]
Add an subscription. If the subscriber is disabled, throw an exception If there is no subscriber, add one. If there is no subscription for the content, add one @param $email: user's email @return void
[ "Add", "an", "subscription", ".", "If", "the", "subscriber", "is", "disabled", "throw", "an", "exception", "If", "there", "is", "no", "subscriber", "add", "one", ".", "If", "there", "is", "no", "subscription", "for", "the", "content", "add", "one" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L73-L140
ezsystems/ezcomments-ls-extension
classes/ezcomsubscriptionmanager.php
ezcomSubscriptionManager.sendActivationEmail
public static function sendActivationEmail( $contentObject, $subscriber, $subscription ) { $transport = eZNotificationTransport::instance( 'ezmail' ); $email = $subscriber->attribute( 'email' ); $tpl = eZTemplate::factory(); $tpl->setVariable( 'contentobject', $contentObject ); $tpl->setVariable( 'subscriber', $subscriber ); $tpl->setVariable( 'subscription', $subscription ); $mailSubject = $tpl->fetch( 'design:comment/notification_activation_subject.tpl' ); $mailBody = $tpl->fetch( 'design:comment/notification_activation_body.tpl' ); $parameters = array(); $ezcommentsINI = eZINI::instance( 'ezcomments.ini' ); $mailContentType = $ezcommentsINI->variable( 'NotificationSettings', 'ActivationMailContentType' ); $parameters['from'] = $ezcommentsINI->variable( 'NotificationSettings', 'MailFrom' ); $parameters['content_type'] = $mailContentType; $result = $transport->send( array( $email ), $mailSubject, $mailBody, null, $parameters ); return $result; }
php
public static function sendActivationEmail( $contentObject, $subscriber, $subscription ) { $transport = eZNotificationTransport::instance( 'ezmail' ); $email = $subscriber->attribute( 'email' ); $tpl = eZTemplate::factory(); $tpl->setVariable( 'contentobject', $contentObject ); $tpl->setVariable( 'subscriber', $subscriber ); $tpl->setVariable( 'subscription', $subscription ); $mailSubject = $tpl->fetch( 'design:comment/notification_activation_subject.tpl' ); $mailBody = $tpl->fetch( 'design:comment/notification_activation_body.tpl' ); $parameters = array(); $ezcommentsINI = eZINI::instance( 'ezcomments.ini' ); $mailContentType = $ezcommentsINI->variable( 'NotificationSettings', 'ActivationMailContentType' ); $parameters['from'] = $ezcommentsINI->variable( 'NotificationSettings', 'MailFrom' ); $parameters['content_type'] = $mailContentType; $result = $transport->send( array( $email ), $mailSubject, $mailBody, null, $parameters ); return $result; }
[ "public", "static", "function", "sendActivationEmail", "(", "$", "contentObject", ",", "$", "subscriber", ",", "$", "subscription", ")", "{", "$", "transport", "=", "eZNotificationTransport", "::", "instance", "(", "'ezmail'", ")", ";", "$", "email", "=", "$", "subscriber", "->", "attribute", "(", "'email'", ")", ";", "$", "tpl", "=", "eZTemplate", "::", "factory", "(", ")", ";", "$", "tpl", "->", "setVariable", "(", "'contentobject'", ",", "$", "contentObject", ")", ";", "$", "tpl", "->", "setVariable", "(", "'subscriber'", ",", "$", "subscriber", ")", ";", "$", "tpl", "->", "setVariable", "(", "'subscription'", ",", "$", "subscription", ")", ";", "$", "mailSubject", "=", "$", "tpl", "->", "fetch", "(", "'design:comment/notification_activation_subject.tpl'", ")", ";", "$", "mailBody", "=", "$", "tpl", "->", "fetch", "(", "'design:comment/notification_activation_body.tpl'", ")", ";", "$", "parameters", "=", "array", "(", ")", ";", "$", "ezcommentsINI", "=", "eZINI", "::", "instance", "(", "'ezcomments.ini'", ")", ";", "$", "mailContentType", "=", "$", "ezcommentsINI", "->", "variable", "(", "'NotificationSettings'", ",", "'ActivationMailContentType'", ")", ";", "$", "parameters", "[", "'from'", "]", "=", "$", "ezcommentsINI", "->", "variable", "(", "'NotificationSettings'", ",", "'MailFrom'", ")", ";", "$", "parameters", "[", "'content_type'", "]", "=", "$", "mailContentType", ";", "$", "result", "=", "$", "transport", "->", "send", "(", "array", "(", "$", "email", ")", ",", "$", "mailSubject", ",", "$", "mailBody", ",", "null", ",", "$", "parameters", ")", ";", "return", "$", "result", ";", "}" ]
send activation email to the user @param ezcomContentObject $contentObject @param ezcomSubscriber $subscriber @param ezcomSubscription $subscription @return true if mail sending succeeds false if mail sending fails
[ "send", "activation", "email", "to", "the", "user" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L150-L169
ezsystems/ezcomments-ls-extension
classes/ezcomsubscriptionmanager.php
ezcomSubscriptionManager.cleanupExpiredSubscription
public static function cleanupExpiredSubscription( $time ) { //1. find the subscription which is disabled and whose time is too long $startTime = time() - $time; $db = eZDB::instance(); $selectSql = "SELECT id FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0"; $result = $db->arrayQuery( $selectSql ); if ( is_array( $result ) && count( $result ) > 0 ) { //2. clean up the subscription $deleteSql = "DELETE FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0"; $db->query( $deleteSql ); return $result; } else { return null; } }
php
public static function cleanupExpiredSubscription( $time ) { //1. find the subscription which is disabled and whose time is too long $startTime = time() - $time; $db = eZDB::instance(); $selectSql = "SELECT id FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0"; $result = $db->arrayQuery( $selectSql ); if ( is_array( $result ) && count( $result ) > 0 ) { //2. clean up the subscription $deleteSql = "DELETE FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0"; $db->query( $deleteSql ); return $result; } else { return null; } }
[ "public", "static", "function", "cleanupExpiredSubscription", "(", "$", "time", ")", "{", "//1. find the subscription which is disabled and whose time is too long", "$", "startTime", "=", "time", "(", ")", "-", "$", "time", ";", "$", "db", "=", "eZDB", "::", "instance", "(", ")", ";", "$", "selectSql", "=", "\"SELECT id FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0\"", ";", "$", "result", "=", "$", "db", "->", "arrayQuery", "(", "$", "selectSql", ")", ";", "if", "(", "is_array", "(", "$", "result", ")", "&&", "count", "(", "$", "result", ")", ">", "0", ")", "{", "//2. clean up the subscription", "$", "deleteSql", "=", "\"DELETE FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0\"", ";", "$", "db", "->", "query", "(", "$", "deleteSql", ")", ";", "return", "$", "result", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
clean up the subscription if the subscription has not been activate for very long @return array id of subscription cleaned up null if nothing cleaned up
[ "clean", "up", "the", "subscription", "if", "the", "subscription", "has", "not", "been", "activate", "for", "very", "long" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L176-L194
ezsystems/ezcomments-ls-extension
classes/ezcomsubscriptionmanager.php
ezcomSubscriptionManager.deleteSubscription
public function deleteSubscription( $email, $contentObjectID, $languageID ) { $subscriber = ezcomSubscriber::fetchByEmail( $email ); $cond = array(); $cond['subscriber_id'] = $subscriber->attribute( 'id' ); $cond['content_id'] = $contentObjectID; $cond['language_id'] = $languageID; $cond['subscription_type'] = 'ezcomcomment'; $subscription = ezcomSubscription::fetchByCond( $cond ); $subscription->remove(); }
php
public function deleteSubscription( $email, $contentObjectID, $languageID ) { $subscriber = ezcomSubscriber::fetchByEmail( $email ); $cond = array(); $cond['subscriber_id'] = $subscriber->attribute( 'id' ); $cond['content_id'] = $contentObjectID; $cond['language_id'] = $languageID; $cond['subscription_type'] = 'ezcomcomment'; $subscription = ezcomSubscription::fetchByCond( $cond ); $subscription->remove(); }
[ "public", "function", "deleteSubscription", "(", "$", "email", ",", "$", "contentObjectID", ",", "$", "languageID", ")", "{", "$", "subscriber", "=", "ezcomSubscriber", "::", "fetchByEmail", "(", "$", "email", ")", ";", "$", "cond", "=", "array", "(", ")", ";", "$", "cond", "[", "'subscriber_id'", "]", "=", "$", "subscriber", "->", "attribute", "(", "'id'", ")", ";", "$", "cond", "[", "'content_id'", "]", "=", "$", "contentObjectID", ";", "$", "cond", "[", "'language_id'", "]", "=", "$", "languageID", ";", "$", "cond", "[", "'subscription_type'", "]", "=", "'ezcomcomment'", ";", "$", "subscription", "=", "ezcomSubscription", "::", "fetchByCond", "(", "$", "cond", ")", ";", "$", "subscription", "->", "remove", "(", ")", ";", "}" ]
delete the subscription given the subscriber's email @param $email @param $contentObjectID @param $languageID @return unknown_type
[ "delete", "the", "subscription", "given", "the", "subscriber", "s", "email" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L203-L213
ezsystems/ezcomments-ls-extension
classes/ezcomsubscriptionmanager.php
ezcomSubscriptionManager.instance
public static function instance( $tpl = null, $module = null, $params = null, $className = null ) { $object = null; if ( is_null( $className ) ) { $ini = eZINI::instance( 'ezcomments.ini' ); $className = $ini->variable( 'ManagerClasses', 'SubscriptionManagerClass' ); } if ( !is_null( self::$instance ) ) { $object = self::$instance; } else { $object = new $className(); $object->tpl = $tpl; $object->module = $module; $object->params = $params; } return $object; }
php
public static function instance( $tpl = null, $module = null, $params = null, $className = null ) { $object = null; if ( is_null( $className ) ) { $ini = eZINI::instance( 'ezcomments.ini' ); $className = $ini->variable( 'ManagerClasses', 'SubscriptionManagerClass' ); } if ( !is_null( self::$instance ) ) { $object = self::$instance; } else { $object = new $className(); $object->tpl = $tpl; $object->module = $module; $object->params = $params; } return $object; }
[ "public", "static", "function", "instance", "(", "$", "tpl", "=", "null", ",", "$", "module", "=", "null", ",", "$", "params", "=", "null", ",", "$", "className", "=", "null", ")", "{", "$", "object", "=", "null", ";", "if", "(", "is_null", "(", "$", "className", ")", ")", "{", "$", "ini", "=", "eZINI", "::", "instance", "(", "'ezcomments.ini'", ")", ";", "$", "className", "=", "$", "ini", "->", "variable", "(", "'ManagerClasses'", ",", "'SubscriptionManagerClass'", ")", ";", "}", "if", "(", "!", "is_null", "(", "self", "::", "$", "instance", ")", ")", "{", "$", "object", "=", "self", "::", "$", "instance", ";", "}", "else", "{", "$", "object", "=", "new", "$", "className", "(", ")", ";", "$", "object", "->", "tpl", "=", "$", "tpl", ";", "$", "object", "->", "module", "=", "$", "module", ";", "$", "object", "->", "params", "=", "$", "params", ";", "}", "return", "$", "object", ";", "}" ]
method for creating object @return ezcomSubscriptionManager
[ "method", "for", "creating", "object" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L219-L240
raideer/twitch-api
src/Resources/Games.php
Games.getTopGames
public function getTopGames($params = []) { $defaults = [ 'limit' => 10, 'offset' => 0, ]; return $this->wrapper->request('GET', 'games/top', ['query' => $this->resolveOptions($params, $defaults)]); }
php
public function getTopGames($params = []) { $defaults = [ 'limit' => 10, 'offset' => 0, ]; return $this->wrapper->request('GET', 'games/top', ['query' => $this->resolveOptions($params, $defaults)]); }
[ "public", "function", "getTopGames", "(", "$", "params", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'limit'", "=>", "10", ",", "'offset'", "=>", "0", ",", "]", ";", "return", "$", "this", "->", "wrapper", "->", "request", "(", "'GET'", ",", "'games/top'", ",", "[", "'query'", "=>", "$", "this", "->", "resolveOptions", "(", "$", "params", ",", "$", "defaults", ")", "]", ")", ";", "}" ]
Returns a list of games objects sorted by number of current viewers on Twitch, most popular first. Learn more: https://github.com/justintv/Twitch-API/blob/master/v3_resources/games.md#get-gamestop @param array $params Optional parameters @return array
[ "Returns", "a", "list", "of", "games", "objects", "sorted", "by", "number", "of", "current", "viewers", "on", "Twitch", "most", "popular", "first", "." ]
train
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Games.php#L31-L39
philiplb/Valdi
src/Valdi/RulesBuilder.php
RulesBuilder.addRule
public function addRule($field, $rule) { if (!isset($this->rules[$field])) { $this->rules[$field] = []; } $newRule = [$rule]; $numArgs = func_num_args(); for ($i = 2; $i < $numArgs; ++$i) { $newRule[] = func_get_arg($i); } $this->rules[$field][] = $newRule; return $this; }
php
public function addRule($field, $rule) { if (!isset($this->rules[$field])) { $this->rules[$field] = []; } $newRule = [$rule]; $numArgs = func_num_args(); for ($i = 2; $i < $numArgs; ++$i) { $newRule[] = func_get_arg($i); } $this->rules[$field][] = $newRule; return $this; }
[ "public", "function", "addRule", "(", "$", "field", ",", "$", "rule", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "rules", "[", "$", "field", "]", ")", ")", "{", "$", "this", "->", "rules", "[", "$", "field", "]", "=", "[", "]", ";", "}", "$", "newRule", "=", "[", "$", "rule", "]", ";", "$", "numArgs", "=", "func_num_args", "(", ")", ";", "for", "(", "$", "i", "=", "2", ";", "$", "i", "<", "$", "numArgs", ";", "++", "$", "i", ")", "{", "$", "newRule", "[", "]", "=", "func_get_arg", "(", "$", "i", ")", ";", "}", "$", "this", "->", "rules", "[", "$", "field", "]", "[", "]", "=", "$", "newRule", ";", "return", "$", "this", ";", "}" ]
Adds a rule to the set. This function takes a variable amount of parameters in order to cover the rule parameters. Example for a rule without parameter: addRule('myField', 'required') Example for a rule with two parameters: addRule('myField', 'between', 3, 7) @param string $field the field for the rule @param string $rule the rule to add @return RulesBuilder the instance of the called RulesBuilder in order to chain the rules creation
[ "Adds", "a", "rule", "to", "the", "set", ".", "This", "function", "takes", "a", "variable", "amount", "of", "parameters", "in", "order", "to", "cover", "the", "rule", "parameters", ".", "Example", "for", "a", "rule", "without", "parameter", ":", "addRule", "(", "myField", "required", ")", "Example", "for", "a", "rule", "with", "two", "parameters", ":", "addRule", "(", "myField", "between", "3", "7", ")" ]
train
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/RulesBuilder.php#L58-L69
derhasi/buddy
src/Config.php
Config.load
public function load($workingDir) { $locator = new FileLocator($this->getPotentialDirectories($workingDir)); $loader = new YamlLoader($locator); // Config validation. $processor = new Processor(); $schema = new BuddySchema(); $files = $locator->locate(static::FILENAME, NULL, FALSE); foreach ($files as $file) { // After loading the raw data from the yaml file, we validate given // configuration. $raw = $loader->load($file); $conf = $processor->processConfiguration($schema, array('buddy' => $raw)); if (isset($conf['commands'])) { foreach($conf['commands'] as $command => $specs) { if (!isset($this->commands[$command])) { $this->commands[$command] = array( 'options' => $specs, 'file' => $file, ); } } } // In the case 'root' is set, we do not process any parent buddy files. if (!empty($values['root'])) { break; } } return $this; }
php
public function load($workingDir) { $locator = new FileLocator($this->getPotentialDirectories($workingDir)); $loader = new YamlLoader($locator); // Config validation. $processor = new Processor(); $schema = new BuddySchema(); $files = $locator->locate(static::FILENAME, NULL, FALSE); foreach ($files as $file) { // After loading the raw data from the yaml file, we validate given // configuration. $raw = $loader->load($file); $conf = $processor->processConfiguration($schema, array('buddy' => $raw)); if (isset($conf['commands'])) { foreach($conf['commands'] as $command => $specs) { if (!isset($this->commands[$command])) { $this->commands[$command] = array( 'options' => $specs, 'file' => $file, ); } } } // In the case 'root' is set, we do not process any parent buddy files. if (!empty($values['root'])) { break; } } return $this; }
[ "public", "function", "load", "(", "$", "workingDir", ")", "{", "$", "locator", "=", "new", "FileLocator", "(", "$", "this", "->", "getPotentialDirectories", "(", "$", "workingDir", ")", ")", ";", "$", "loader", "=", "new", "YamlLoader", "(", "$", "locator", ")", ";", "// Config validation.", "$", "processor", "=", "new", "Processor", "(", ")", ";", "$", "schema", "=", "new", "BuddySchema", "(", ")", ";", "$", "files", "=", "$", "locator", "->", "locate", "(", "static", "::", "FILENAME", ",", "NULL", ",", "FALSE", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "// After loading the raw data from the yaml file, we validate given", "// configuration.", "$", "raw", "=", "$", "loader", "->", "load", "(", "$", "file", ")", ";", "$", "conf", "=", "$", "processor", "->", "processConfiguration", "(", "$", "schema", ",", "array", "(", "'buddy'", "=>", "$", "raw", ")", ")", ";", "if", "(", "isset", "(", "$", "conf", "[", "'commands'", "]", ")", ")", "{", "foreach", "(", "$", "conf", "[", "'commands'", "]", "as", "$", "command", "=>", "$", "specs", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "commands", "[", "$", "command", "]", ")", ")", "{", "$", "this", "->", "commands", "[", "$", "command", "]", "=", "array", "(", "'options'", "=>", "$", "specs", ",", "'file'", "=>", "$", "file", ",", ")", ";", "}", "}", "}", "// In the case 'root' is set, we do not process any parent buddy files.", "if", "(", "!", "empty", "(", "$", "values", "[", "'root'", "]", ")", ")", "{", "break", ";", "}", "}", "return", "$", "this", ";", "}" ]
Loads the configuration file data.
[ "Loads", "the", "configuration", "file", "data", "." ]
train
https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/Config.php#L29-L62
derhasi/buddy
src/Config.php
Config.getCommand
public function getCommand($command) { return new CommandShortcut($command, $this->commands[$command]['options'], $this->commands[$command]['file']); }
php
public function getCommand($command) { return new CommandShortcut($command, $this->commands[$command]['options'], $this->commands[$command]['file']); }
[ "public", "function", "getCommand", "(", "$", "command", ")", "{", "return", "new", "CommandShortcut", "(", "$", "command", ",", "$", "this", "->", "commands", "[", "$", "command", "]", "[", "'options'", "]", ",", "$", "this", "->", "commands", "[", "$", "command", "]", "[", "'file'", "]", ")", ";", "}" ]
Provides the command specification. @param string $command @return \derhasi\buddy\CommandShortcut Command shortcut
[ "Provides", "the", "command", "specification", "." ]
train
https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/Config.php#L86-L89
derhasi/buddy
src/Config.php
Config.getPotentialDirectories
protected function getPotentialDirectories($workingDir) { $paths = array(); $path = ''; foreach (explode('/', $workingDir) as $part) { $path .= $part . '/'; $paths[] = rtrim($path, '/'); } return $paths; }
php
protected function getPotentialDirectories($workingDir) { $paths = array(); $path = ''; foreach (explode('/', $workingDir) as $part) { $path .= $part . '/'; $paths[] = rtrim($path, '/'); } return $paths; }
[ "protected", "function", "getPotentialDirectories", "(", "$", "workingDir", ")", "{", "$", "paths", "=", "array", "(", ")", ";", "$", "path", "=", "''", ";", "foreach", "(", "explode", "(", "'/'", ",", "$", "workingDir", ")", "as", "$", "part", ")", "{", "$", "path", ".=", "$", "part", ".", "'/'", ";", "$", "paths", "[", "]", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "}", "return", "$", "paths", ";", "}" ]
Helper to provide potential directories to look for .buddy.yml files. @return array List of directory paths.
[ "Helper", "to", "provide", "potential", "directories", "to", "look", "for", ".", "buddy", ".", "yml", "files", "." ]
train
https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/Config.php#L97-L106
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.escape
public function escape(string $item): string { $items = explode('.', str_replace($this->qte, '', $item)); $r = []; foreach ( $items as $m ){ if ( !bbn\str::check_name($m) ){ return false; } $r[] = $this->qte.$m.$this->qte; } return implode('.', $r); }
php
public function escape(string $item): string { $items = explode('.', str_replace($this->qte, '', $item)); $r = []; foreach ( $items as $m ){ if ( !bbn\str::check_name($m) ){ return false; } $r[] = $this->qte.$m.$this->qte; } return implode('.', $r); }
[ "public", "function", "escape", "(", "string", "$", "item", ")", ":", "string", "{", "$", "items", "=", "explode", "(", "'.'", ",", "str_replace", "(", "$", "this", "->", "qte", ",", "''", ",", "$", "item", ")", ")", ";", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "items", "as", "$", "m", ")", "{", "if", "(", "!", "bbn", "\\", "str", "::", "check_name", "(", "$", "m", ")", ")", "{", "return", "false", ";", "}", "$", "r", "[", "]", "=", "$", "this", "->", "qte", ".", "$", "m", ".", "$", "this", "->", "qte", ";", "}", "return", "implode", "(", "'.'", ",", "$", "r", ")", ";", "}" ]
Returns a database item expression escaped like database, table, column, key names @param string $item The item's name (escaped or not) @return string
[ "Returns", "a", "database", "item", "expression", "escaped", "like", "database", "table", "column", "key", "names" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L158-L169
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.table_full_name
public function table_full_name(string $table, bool $escaped = false): ?string { $bits = explode('.', str_replace($this->qte, '', $table)); if ( \count($bits) === 3 ){ $db = trim($bits[0]); $table = trim($bits[1]); } else if ( \count($bits) === 2 ){ $db = trim($bits[0]); $table = trim($bits[1]); } else{ $db = $this->db->current; $table = trim($bits[0]); } if ( bbn\str::check_name($db, $table) ){ return $escaped ? $this->qte.$db.$this->qte.'.'.$this->qte.$table.$this->qte : $db.'.'.$table; } return null; }
php
public function table_full_name(string $table, bool $escaped = false): ?string { $bits = explode('.', str_replace($this->qte, '', $table)); if ( \count($bits) === 3 ){ $db = trim($bits[0]); $table = trim($bits[1]); } else if ( \count($bits) === 2 ){ $db = trim($bits[0]); $table = trim($bits[1]); } else{ $db = $this->db->current; $table = trim($bits[0]); } if ( bbn\str::check_name($db, $table) ){ return $escaped ? $this->qte.$db.$this->qte.'.'.$this->qte.$table.$this->qte : $db.'.'.$table; } return null; }
[ "public", "function", "table_full_name", "(", "string", "$", "table", ",", "bool", "$", "escaped", "=", "false", ")", ":", "?", "string", "{", "$", "bits", "=", "explode", "(", "'.'", ",", "str_replace", "(", "$", "this", "->", "qte", ",", "''", ",", "$", "table", ")", ")", ";", "if", "(", "\\", "count", "(", "$", "bits", ")", "===", "3", ")", "{", "$", "db", "=", "trim", "(", "$", "bits", "[", "0", "]", ")", ";", "$", "table", "=", "trim", "(", "$", "bits", "[", "1", "]", ")", ";", "}", "else", "if", "(", "\\", "count", "(", "$", "bits", ")", "===", "2", ")", "{", "$", "db", "=", "trim", "(", "$", "bits", "[", "0", "]", ")", ";", "$", "table", "=", "trim", "(", "$", "bits", "[", "1", "]", ")", ";", "}", "else", "{", "$", "db", "=", "$", "this", "->", "db", "->", "current", ";", "$", "table", "=", "trim", "(", "$", "bits", "[", "0", "]", ")", ";", "}", "if", "(", "bbn", "\\", "str", "::", "check_name", "(", "$", "db", ",", "$", "table", ")", ")", "{", "return", "$", "escaped", "?", "$", "this", "->", "qte", ".", "$", "db", ".", "$", "this", "->", "qte", ".", "'.'", ".", "$", "this", "->", "qte", ".", "$", "table", ".", "$", "this", "->", "qte", ":", "$", "db", ".", "'.'", ".", "$", "table", ";", "}", "return", "null", ";", "}" ]
Returns a table's full name i.e. database.table @param string $table The table's name (escaped or not) @param bool $escaped If set to true the returned string will be escaped @return null|string
[ "Returns", "a", "table", "s", "full", "name", "i", ".", "e", ".", "database", ".", "table" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L178-L197
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.table_simple_name
public function table_simple_name(string $table, bool $escaped = false): ?string { if ( $table = trim($table) ){ $bits = explode('.', str_replace($this->qte, '', $table)); switch ( \count($bits) ){ case 1: $table = $bits[0]; break; case 2: $table = $bits[1]; break; case 3: $table = $bits[1]; break; } if ( bbn\str::check_name($table) ){ return $escaped ? $this->qte.$table.$this->qte : $table; } } return null; }
php
public function table_simple_name(string $table, bool $escaped = false): ?string { if ( $table = trim($table) ){ $bits = explode('.', str_replace($this->qte, '', $table)); switch ( \count($bits) ){ case 1: $table = $bits[0]; break; case 2: $table = $bits[1]; break; case 3: $table = $bits[1]; break; } if ( bbn\str::check_name($table) ){ return $escaped ? $this->qte.$table.$this->qte : $table; } } return null; }
[ "public", "function", "table_simple_name", "(", "string", "$", "table", ",", "bool", "$", "escaped", "=", "false", ")", ":", "?", "string", "{", "if", "(", "$", "table", "=", "trim", "(", "$", "table", ")", ")", "{", "$", "bits", "=", "explode", "(", "'.'", ",", "str_replace", "(", "$", "this", "->", "qte", ",", "''", ",", "$", "table", ")", ")", ";", "switch", "(", "\\", "count", "(", "$", "bits", ")", ")", "{", "case", "1", ":", "$", "table", "=", "$", "bits", "[", "0", "]", ";", "break", ";", "case", "2", ":", "$", "table", "=", "$", "bits", "[", "1", "]", ";", "break", ";", "case", "3", ":", "$", "table", "=", "$", "bits", "[", "1", "]", ";", "break", ";", "}", "if", "(", "bbn", "\\", "str", "::", "check_name", "(", "$", "table", ")", ")", "{", "return", "$", "escaped", "?", "$", "this", "->", "qte", ".", "$", "table", ".", "$", "this", "->", "qte", ":", "$", "table", ";", "}", "}", "return", "null", ";", "}" ]
Returns a table's simple name i.e. table @param string $table The table's name (escaped or not) @param bool $escaped If set to true the returned string will be escaped @return null|string
[ "Returns", "a", "table", "s", "simple", "name", "i", ".", "e", ".", "table" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L206-L226
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.col_simple_name
public function col_simple_name(string $col, bool $escaped=false): ?string { if ( $col = trim($col) ){ $bits = explode('.', str_replace($this->qte, '', $col)); $col = end($bits); if ( bbn\str::check_name($col) ){ return $escaped ? $this->qte.$col.$this->qte : $col; } } return null; }
php
public function col_simple_name(string $col, bool $escaped=false): ?string { if ( $col = trim($col) ){ $bits = explode('.', str_replace($this->qte, '', $col)); $col = end($bits); if ( bbn\str::check_name($col) ){ return $escaped ? $this->qte.$col.$this->qte : $col; } } return null; }
[ "public", "function", "col_simple_name", "(", "string", "$", "col", ",", "bool", "$", "escaped", "=", "false", ")", ":", "?", "string", "{", "if", "(", "$", "col", "=", "trim", "(", "$", "col", ")", ")", "{", "$", "bits", "=", "explode", "(", "'.'", ",", "str_replace", "(", "$", "this", "->", "qte", ",", "''", ",", "$", "col", ")", ")", ";", "$", "col", "=", "end", "(", "$", "bits", ")", ";", "if", "(", "bbn", "\\", "str", "::", "check_name", "(", "$", "col", ")", ")", "{", "return", "$", "escaped", "?", "$", "this", "->", "qte", ".", "$", "col", ".", "$", "this", "->", "qte", ":", "$", "col", ";", "}", "}", "return", "null", ";", "}" ]
Returns a column's simple name i.e. column @param string $col The column's name (escaped or not) @param bool $escaped If set to true the returned string will be escaped @return null|string
[ "Returns", "a", "column", "s", "simple", "name", "i", ".", "e", ".", "column" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L263-L273
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.get_delete
public function get_delete(array $cfg): string { $res = ''; if ( count($cfg['tables']) === 1 ){ $res = 'DELETE '.( $cfg['ignore'] ? 'IGNORE ' : '' ). 'FROM '.$this->table_full_name(current($cfg['tables']), true).PHP_EOL; } return $res; }
php
public function get_delete(array $cfg): string { $res = ''; if ( count($cfg['tables']) === 1 ){ $res = 'DELETE '.( $cfg['ignore'] ? 'IGNORE ' : '' ). 'FROM '.$this->table_full_name(current($cfg['tables']), true).PHP_EOL; } return $res; }
[ "public", "function", "get_delete", "(", "array", "$", "cfg", ")", ":", "string", "{", "$", "res", "=", "''", ";", "if", "(", "count", "(", "$", "cfg", "[", "'tables'", "]", ")", "===", "1", ")", "{", "$", "res", "=", "'DELETE '", ".", "(", "$", "cfg", "[", "'ignore'", "]", "?", "'IGNORE '", ":", "''", ")", ".", "'FROM '", ".", "$", "this", "->", "table_full_name", "(", "current", "(", "$", "cfg", "[", "'tables'", "]", ")", ",", "true", ")", ".", "PHP_EOL", ";", "}", "return", "$", "res", ";", "}" ]
Return SQL code for row(s) DELETE. ```php \bbn\x::dump($db->get_delete('table_users',['id'=>1])); // (string) DELETE FROM `db_example`.`table_users` * WHERE 1 AND `table_users`.`id` = ? ``` @param array $cfg The configuration array @return string
[ "Return", "SQL", "code", "for", "row", "(", "s", ")", "DELETE", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L895-L903
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.get_join
public function get_join(array $cfg): string { $res = ''; if ( !empty($cfg['join']) ){ foreach ( $cfg['join'] as $join ){ if ( isset($join['table'], $join['on']) && ($cond = $this->db->get_conditions($join['on'], $cfg)) ){ $res .= (isset($join['type']) && ($join['type'] === 'left') ? 'LEFT ' : ''). 'JOIN '.$this->table_full_name($join['table'],true). (!empty($join['alias']) ? ' AS '.$this->escape($join['alias']) : '').PHP_EOL.'ON '.$cond; } } } return $res; }
php
public function get_join(array $cfg): string { $res = ''; if ( !empty($cfg['join']) ){ foreach ( $cfg['join'] as $join ){ if ( isset($join['table'], $join['on']) && ($cond = $this->db->get_conditions($join['on'], $cfg)) ){ $res .= (isset($join['type']) && ($join['type'] === 'left') ? 'LEFT ' : ''). 'JOIN '.$this->table_full_name($join['table'],true). (!empty($join['alias']) ? ' AS '.$this->escape($join['alias']) : '').PHP_EOL.'ON '.$cond; } } } return $res; }
[ "public", "function", "get_join", "(", "array", "$", "cfg", ")", ":", "string", "{", "$", "res", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "cfg", "[", "'join'", "]", ")", ")", "{", "foreach", "(", "$", "cfg", "[", "'join'", "]", "as", "$", "join", ")", "{", "if", "(", "isset", "(", "$", "join", "[", "'table'", "]", ",", "$", "join", "[", "'on'", "]", ")", "&&", "(", "$", "cond", "=", "$", "this", "->", "db", "->", "get_conditions", "(", "$", "join", "[", "'on'", "]", ",", "$", "cfg", ")", ")", ")", "{", "$", "res", ".=", "(", "isset", "(", "$", "join", "[", "'type'", "]", ")", "&&", "(", "$", "join", "[", "'type'", "]", "===", "'left'", ")", "?", "'LEFT '", ":", "''", ")", ".", "'JOIN '", ".", "$", "this", "->", "table_full_name", "(", "$", "join", "[", "'table'", "]", ",", "true", ")", ".", "(", "!", "empty", "(", "$", "join", "[", "'alias'", "]", ")", "?", "' AS '", ".", "$", "this", "->", "escape", "(", "$", "join", "[", "'alias'", "]", ")", ":", "''", ")", ".", "PHP_EOL", ".", "'ON '", ".", "$", "cond", ";", "}", "}", "}", "return", "$", "res", ";", "}" ]
Returns a string with the JOIN part of the query if there is, empty otherwise @param array $cfg @return string
[ "Returns", "a", "string", "with", "the", "JOIN", "part", "of", "the", "query", "if", "there", "is", "empty", "otherwise" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L911-L925
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.get_where
public function get_where(array $cfg): string { $res = $this->get_conditions($cfg['filters'] ?? [], $cfg); if ( !empty($res) ){ $res = 'WHERE '.$res; } return $res; }
php
public function get_where(array $cfg): string { $res = $this->get_conditions($cfg['filters'] ?? [], $cfg); if ( !empty($res) ){ $res = 'WHERE '.$res; } return $res; }
[ "public", "function", "get_where", "(", "array", "$", "cfg", ")", ":", "string", "{", "$", "res", "=", "$", "this", "->", "get_conditions", "(", "$", "cfg", "[", "'filters'", "]", "??", "[", "]", ",", "$", "cfg", ")", ";", "if", "(", "!", "empty", "(", "$", "res", ")", ")", "{", "$", "res", "=", "'WHERE '", ".", "$", "res", ";", "}", "return", "$", "res", ";", "}" ]
Returns a string with the JOIN part of the query if there is, empty otherwise @param array $cfg @return string
[ "Returns", "a", "string", "with", "the", "JOIN", "part", "of", "the", "query", "if", "there", "is", "empty", "otherwise" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L933-L940
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.get_group_by
public function get_group_by(array $cfg): string { $res = ''; $group_to_put = []; if ( !empty($cfg['group_by']) ){ foreach ( $cfg['group_by'] as $g ){ if ( isset($cfg['available_fields'][$g]) ){ $group_to_put[] = $this->escape($g); //$group_to_put[] = $this->col_full_name($g, $cfg['available_fields'][$g], true); } else{ $this->db->error("Error! The column '$g' doesn't exist for group by ".print_r($cfg, true)); } } if ( count($group_to_put) ){ $res .= 'GROUP BY '.implode(', ', $group_to_put).PHP_EOL; } } return $res; }
php
public function get_group_by(array $cfg): string { $res = ''; $group_to_put = []; if ( !empty($cfg['group_by']) ){ foreach ( $cfg['group_by'] as $g ){ if ( isset($cfg['available_fields'][$g]) ){ $group_to_put[] = $this->escape($g); //$group_to_put[] = $this->col_full_name($g, $cfg['available_fields'][$g], true); } else{ $this->db->error("Error! The column '$g' doesn't exist for group by ".print_r($cfg, true)); } } if ( count($group_to_put) ){ $res .= 'GROUP BY '.implode(', ', $group_to_put).PHP_EOL; } } return $res; }
[ "public", "function", "get_group_by", "(", "array", "$", "cfg", ")", ":", "string", "{", "$", "res", "=", "''", ";", "$", "group_to_put", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "cfg", "[", "'group_by'", "]", ")", ")", "{", "foreach", "(", "$", "cfg", "[", "'group_by'", "]", "as", "$", "g", ")", "{", "if", "(", "isset", "(", "$", "cfg", "[", "'available_fields'", "]", "[", "$", "g", "]", ")", ")", "{", "$", "group_to_put", "[", "]", "=", "$", "this", "->", "escape", "(", "$", "g", ")", ";", "//$group_to_put[] = $this->col_full_name($g, $cfg['available_fields'][$g], true);", "}", "else", "{", "$", "this", "->", "db", "->", "error", "(", "\"Error! The column '$g' doesn't exist for group by \"", ".", "print_r", "(", "$", "cfg", ",", "true", ")", ")", ";", "}", "}", "if", "(", "count", "(", "$", "group_to_put", ")", ")", "{", "$", "res", ".=", "'GROUP BY '", ".", "implode", "(", "', '", ",", "$", "group_to_put", ")", ".", "PHP_EOL", ";", "}", "}", "return", "$", "res", ";", "}" ]
Returns a string with the GROUP BY part of the query if there is, empty otherwise @param array $cfg @return string
[ "Returns", "a", "string", "with", "the", "GROUP", "BY", "part", "of", "the", "query", "if", "there", "is", "empty", "otherwise" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L948-L967
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.get_having
public function get_having(array $cfg): string { $res = ''; if ( !empty($cfg['group_by']) && !empty($cfg['having']) && ($cond = $this->get_conditions($cfg['having'], $cfg, true)) ){ $res .= 'HAVING '.$cond.PHP_EOL; } return $res; }
php
public function get_having(array $cfg): string { $res = ''; if ( !empty($cfg['group_by']) && !empty($cfg['having']) && ($cond = $this->get_conditions($cfg['having'], $cfg, true)) ){ $res .= 'HAVING '.$cond.PHP_EOL; } return $res; }
[ "public", "function", "get_having", "(", "array", "$", "cfg", ")", ":", "string", "{", "$", "res", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "cfg", "[", "'group_by'", "]", ")", "&&", "!", "empty", "(", "$", "cfg", "[", "'having'", "]", ")", "&&", "(", "$", "cond", "=", "$", "this", "->", "get_conditions", "(", "$", "cfg", "[", "'having'", "]", ",", "$", "cfg", ",", "true", ")", ")", ")", "{", "$", "res", ".=", "'HAVING '", ".", "$", "cond", ".", "PHP_EOL", ";", "}", "return", "$", "res", ";", "}" ]
Returns a string with the HAVING part of the query if there is, empty otherwise @param array $cfg @return string
[ "Returns", "a", "string", "with", "the", "HAVING", "part", "of", "the", "query", "if", "there", "is", "empty", "otherwise" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L975-L982
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.get_limit
public function get_limit(array $cfg): string { $res = ''; if ( !empty($cfg['limit']) && bbn\str::is_integer($cfg['limit']) ){ $res .= 'LIMIT '.(!empty($cfg['start']) && bbn\str::is_integer($cfg['start']) ? (string)$cfg['start'] : '0').', '.$cfg['limit']; } return $res; }
php
public function get_limit(array $cfg): string { $res = ''; if ( !empty($cfg['limit']) && bbn\str::is_integer($cfg['limit']) ){ $res .= 'LIMIT '.(!empty($cfg['start']) && bbn\str::is_integer($cfg['start']) ? (string)$cfg['start'] : '0').', '.$cfg['limit']; } return $res; }
[ "public", "function", "get_limit", "(", "array", "$", "cfg", ")", ":", "string", "{", "$", "res", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "cfg", "[", "'limit'", "]", ")", "&&", "bbn", "\\", "str", "::", "is_integer", "(", "$", "cfg", "[", "'limit'", "]", ")", ")", "{", "$", "res", ".=", "'LIMIT '", ".", "(", "!", "empty", "(", "$", "cfg", "[", "'start'", "]", ")", "&&", "bbn", "\\", "str", "::", "is_integer", "(", "$", "cfg", "[", "'start'", "]", ")", "?", "(", "string", ")", "$", "cfg", "[", "'start'", "]", ":", "'0'", ")", ".", "', '", ".", "$", "cfg", "[", "'limit'", "]", ";", "}", "return", "$", "res", ";", "}" ]
Get a string starting with LIMIT with corresponding parameters to $where @param array $cfg @return string
[ "Get", "a", "string", "starting", "with", "LIMIT", "with", "corresponding", "parameters", "to", "$where" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L1024-L1031
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.create_index
public function create_index(string $table, $column, bool $unique = false, $length = null): bool { $column = (array)$column; if ( $length ){ $length = (array)$length; } $name = bbn\str::encode_filename($table); if ( $table = $this->table_full_name($table, true) ){ foreach ( $column as $i => $c ){ if ( !bbn\str::check_name($c) ){ $this->db->error("Illegal column $c"); } $name .= '_'.$c; $column[$i] = $this->escape($column[$i]); if ( \is_int($length[$i]) && $length[$i] > 0 ){ $column[$i] .= '('.$length[$i].')'; } } $name = bbn\str::cut($name, 50); return (bool)$this->db->query('CREATE '.( $unique ? 'UNIQUE ' : '' )."INDEX `$name` ON $table ( ". implode(', ', $column).' )'); } return false; }
php
public function create_index(string $table, $column, bool $unique = false, $length = null): bool { $column = (array)$column; if ( $length ){ $length = (array)$length; } $name = bbn\str::encode_filename($table); if ( $table = $this->table_full_name($table, true) ){ foreach ( $column as $i => $c ){ if ( !bbn\str::check_name($c) ){ $this->db->error("Illegal column $c"); } $name .= '_'.$c; $column[$i] = $this->escape($column[$i]); if ( \is_int($length[$i]) && $length[$i] > 0 ){ $column[$i] .= '('.$length[$i].')'; } } $name = bbn\str::cut($name, 50); return (bool)$this->db->query('CREATE '.( $unique ? 'UNIQUE ' : '' )."INDEX `$name` ON $table ( ". implode(', ', $column).' )'); } return false; }
[ "public", "function", "create_index", "(", "string", "$", "table", ",", "$", "column", ",", "bool", "$", "unique", "=", "false", ",", "$", "length", "=", "null", ")", ":", "bool", "{", "$", "column", "=", "(", "array", ")", "$", "column", ";", "if", "(", "$", "length", ")", "{", "$", "length", "=", "(", "array", ")", "$", "length", ";", "}", "$", "name", "=", "bbn", "\\", "str", "::", "encode_filename", "(", "$", "table", ")", ";", "if", "(", "$", "table", "=", "$", "this", "->", "table_full_name", "(", "$", "table", ",", "true", ")", ")", "{", "foreach", "(", "$", "column", "as", "$", "i", "=>", "$", "c", ")", "{", "if", "(", "!", "bbn", "\\", "str", "::", "check_name", "(", "$", "c", ")", ")", "{", "$", "this", "->", "db", "->", "error", "(", "\"Illegal column $c\"", ")", ";", "}", "$", "name", ".=", "'_'", ".", "$", "c", ";", "$", "column", "[", "$", "i", "]", "=", "$", "this", "->", "escape", "(", "$", "column", "[", "$", "i", "]", ")", ";", "if", "(", "\\", "is_int", "(", "$", "length", "[", "$", "i", "]", ")", "&&", "$", "length", "[", "$", "i", "]", ">", "0", ")", "{", "$", "column", "[", "$", "i", "]", ".=", "'('", ".", "$", "length", "[", "$", "i", "]", ".", "')'", ";", "}", "}", "$", "name", "=", "bbn", "\\", "str", "::", "cut", "(", "$", "name", ",", "50", ")", ";", "return", "(", "bool", ")", "$", "this", "->", "db", "->", "query", "(", "'CREATE '", ".", "(", "$", "unique", "?", "'UNIQUE '", ":", "''", ")", ".", "\"INDEX `$name` ON $table ( \"", ".", "implode", "(", "', '", ",", "$", "column", ")", ".", "' )'", ")", ";", "}", "return", "false", ";", "}" ]
Creates an index @param null|string $table @param string|array $column @param bool $unique @param null $length @return bool
[ "Creates", "an", "index" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L1124-L1147
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.create_user
public function create_user(string $user, string $pass, string $db = null): bool { if ( null === $db ){ $db = $this->db->current; } if ( ($db = $this->escape($db)) && bbn\str::check_name($user, $db) && (strpos($pass, "'") === false) ){ return (bool)$this->db->raw_query(<<<MYSQL GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON $db . * TO '$user'@'{$this->db->host}' IDENTIFIED BY '$pass' MYSQL ); } return false; }
php
public function create_user(string $user, string $pass, string $db = null): bool { if ( null === $db ){ $db = $this->db->current; } if ( ($db = $this->escape($db)) && bbn\str::check_name($user, $db) && (strpos($pass, "'") === false) ){ return (bool)$this->db->raw_query(<<<MYSQL GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON $db . * TO '$user'@'{$this->db->host}' IDENTIFIED BY '$pass' MYSQL ); } return false; }
[ "public", "function", "create_user", "(", "string", "$", "user", ",", "string", "$", "pass", ",", "string", "$", "db", "=", "null", ")", ":", "bool", "{", "if", "(", "null", "===", "$", "db", ")", "{", "$", "db", "=", "$", "this", "->", "db", "->", "current", ";", "}", "if", "(", "(", "$", "db", "=", "$", "this", "->", "escape", "(", "$", "db", ")", ")", "&&", "bbn", "\\", "str", "::", "check_name", "(", "$", "user", ",", "$", "db", ")", "&&", "(", "strpos", "(", "$", "pass", ",", "\"'\"", ")", "===", "false", ")", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "db", "->", "raw_query", "(", "<<<MYSQL\nGRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER\nON $db . *\nTO '$user'@'{$this->db->host}'\nIDENTIFIED BY '$pass'\nMYSQL", ")", ";", "}", "return", "false", ";", "}" ]
Creates a database user @param string $user @param string $pass @param string $db @return bool
[ "Creates", "a", "database", "user" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L1179-L1198
nabab/bbn
src/bbn/db/languages/mysql.php
mysql.delete_user
public function delete_user(string $user): bool { if ( bbn\str::check_name($user) ){ $this->db->raw_query(" REVOKE ALL PRIVILEGES ON *.* FROM $user"); return (bool)$this->db->query("DROP USER $user"); } return false; }
php
public function delete_user(string $user): bool { if ( bbn\str::check_name($user) ){ $this->db->raw_query(" REVOKE ALL PRIVILEGES ON *.* FROM $user"); return (bool)$this->db->query("DROP USER $user"); } return false; }
[ "public", "function", "delete_user", "(", "string", "$", "user", ")", ":", "bool", "{", "if", "(", "bbn", "\\", "str", "::", "check_name", "(", "$", "user", ")", ")", "{", "$", "this", "->", "db", "->", "raw_query", "(", "\"\n\t\t\tREVOKE ALL PRIVILEGES ON *.*\n\t\t\tFROM $user\"", ")", ";", "return", "(", "bool", ")", "$", "this", "->", "db", "->", "query", "(", "\"DROP USER $user\"", ")", ";", "}", "return", "false", ";", "}" ]
Deletes a database user @param string $user @return bool
[ "Deletes", "a", "database", "user" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L1206-L1215
Laralum/Users
src/Controllers/UserController.php
UserController.store
public function store(Request $request) { $this->authorize('create', User::class); $this->validate($request, [ 'name' => 'required|max:255', 'email' => 'sometimes|required|email|unique:users', 'password' => 'required|min:6|confirmed', ]); User::create($request->all()); return redirect()->route('laralum::users.index')->with('success', __('laralum_users::general.user_created', ['email' => $request->email])); }
php
public function store(Request $request) { $this->authorize('create', User::class); $this->validate($request, [ 'name' => 'required|max:255', 'email' => 'sometimes|required|email|unique:users', 'password' => 'required|min:6|confirmed', ]); User::create($request->all()); return redirect()->route('laralum::users.index')->with('success', __('laralum_users::general.user_created', ['email' => $request->email])); }
[ "public", "function", "store", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "authorize", "(", "'create'", ",", "User", "::", "class", ")", ";", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'name'", "=>", "'required|max:255'", ",", "'email'", "=>", "'sometimes|required|email|unique:users'", ",", "'password'", "=>", "'required|min:6|confirmed'", ",", "]", ")", ";", "User", "::", "create", "(", "$", "request", "->", "all", "(", ")", ")", ";", "return", "redirect", "(", ")", "->", "route", "(", "'laralum::users.index'", ")", "->", "with", "(", "'success'", ",", "__", "(", "'laralum_users::general.user_created'", ",", "[", "'email'", "=>", "$", "request", "->", "email", "]", ")", ")", ";", "}" ]
Store a newly created resource in storage. @param \Illuminate\Http\Request $request @return \Illuminate\Http\Response
[ "Store", "a", "newly", "created", "resource", "in", "storage", "." ]
train
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Controllers/UserController.php#L44-L57
Laralum/Users
src/Controllers/UserController.php
UserController.update
public function update(Request $request, User $user) { $this->authorize('update', $user); $this->validate($request, [ 'name' => 'required|max:255', ]); $user->update([ 'name' => $request->name, ]); return redirect()->route('laralum::users.index'); }
php
public function update(Request $request, User $user) { $this->authorize('update', $user); $this->validate($request, [ 'name' => 'required|max:255', ]); $user->update([ 'name' => $request->name, ]); return redirect()->route('laralum::users.index'); }
[ "public", "function", "update", "(", "Request", "$", "request", ",", "User", "$", "user", ")", "{", "$", "this", "->", "authorize", "(", "'update'", ",", "$", "user", ")", ";", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'name'", "=>", "'required|max:255'", ",", "]", ")", ";", "$", "user", "->", "update", "(", "[", "'name'", "=>", "$", "request", "->", "name", ",", "]", ")", ";", "return", "redirect", "(", ")", "->", "route", "(", "'laralum::users.index'", ")", ";", "}" ]
Update the specified resource in storage. @param \Illuminate\Http\Request $request @param \Laralum\Users\Models\User $user @return \Illuminate\Http\Response
[ "Update", "the", "specified", "resource", "in", "storage", "." ]
train
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Controllers/UserController.php#L81-L93
Laralum/Users
src/Controllers/UserController.php
UserController.destroy
public function destroy(User $user) { $this->authorize('delete', $user); $user->delete(); File::delete(public_path('/avatars/'.md5($user->email))); return redirect()->route('laralum::users.index')->with('success', __('laralum_users::general.user_deleted', ['id' => $user->id])); }
php
public function destroy(User $user) { $this->authorize('delete', $user); $user->delete(); File::delete(public_path('/avatars/'.md5($user->email))); return redirect()->route('laralum::users.index')->with('success', __('laralum_users::general.user_deleted', ['id' => $user->id])); }
[ "public", "function", "destroy", "(", "User", "$", "user", ")", "{", "$", "this", "->", "authorize", "(", "'delete'", ",", "$", "user", ")", ";", "$", "user", "->", "delete", "(", ")", ";", "File", "::", "delete", "(", "public_path", "(", "'/avatars/'", ".", "md5", "(", "$", "user", "->", "email", ")", ")", ")", ";", "return", "redirect", "(", ")", "->", "route", "(", "'laralum::users.index'", ")", "->", "with", "(", "'success'", ",", "__", "(", "'laralum_users::general.user_deleted'", ",", "[", "'id'", "=>", "$", "user", "->", "id", "]", ")", ")", ";", "}" ]
Remove the specified resource from storage. @param \Laralum\Users\Models\User $user @return \Illuminate\Http\Response
[ "Remove", "the", "specified", "resource", "from", "storage", "." ]
train
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Controllers/UserController.php#L119-L128
Laralum/Users
src/Controllers/UserController.php
UserController.manageRoles
public function manageRoles(User $user) { $this->authorize('roles', $user); $roles = Role::all(); return view('laralum_users::roles', ['user' => $user, 'roles' => $roles]); }
php
public function manageRoles(User $user) { $this->authorize('roles', $user); $roles = Role::all(); return view('laralum_users::roles', ['user' => $user, 'roles' => $roles]); }
[ "public", "function", "manageRoles", "(", "User", "$", "user", ")", "{", "$", "this", "->", "authorize", "(", "'roles'", ",", "$", "user", ")", ";", "$", "roles", "=", "Role", "::", "all", "(", ")", ";", "return", "view", "(", "'laralum_users::roles'", ",", "[", "'user'", "=>", "$", "user", ",", "'roles'", "=>", "$", "roles", "]", ")", ";", "}" ]
Manage roles from users. @param \Laralum\Users\Models\User $user @return \Illuminate\Http\Response
[ "Manage", "roles", "from", "users", "." ]
train
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Controllers/UserController.php#L137-L144
Laralum/Users
src/Controllers/UserController.php
UserController.updateRoles
public function updateRoles(Request $request, User $user) { $this->authorize('roles', $user); $roles = Role::all(); foreach ($roles as $role) { if (array_key_exists($role->id, $request->all())) { $role->addUser($user); } else { $role->deleteUser($user); } } return redirect()->route('laralum::users.index')->with('success', __('laralum_users::general.user_roles_updated', ['id' => $user->id])); }
php
public function updateRoles(Request $request, User $user) { $this->authorize('roles', $user); $roles = Role::all(); foreach ($roles as $role) { if (array_key_exists($role->id, $request->all())) { $role->addUser($user); } else { $role->deleteUser($user); } } return redirect()->route('laralum::users.index')->with('success', __('laralum_users::general.user_roles_updated', ['id' => $user->id])); }
[ "public", "function", "updateRoles", "(", "Request", "$", "request", ",", "User", "$", "user", ")", "{", "$", "this", "->", "authorize", "(", "'roles'", ",", "$", "user", ")", ";", "$", "roles", "=", "Role", "::", "all", "(", ")", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "if", "(", "array_key_exists", "(", "$", "role", "->", "id", ",", "$", "request", "->", "all", "(", ")", ")", ")", "{", "$", "role", "->", "addUser", "(", "$", "user", ")", ";", "}", "else", "{", "$", "role", "->", "deleteUser", "(", "$", "user", ")", ";", "}", "}", "return", "redirect", "(", ")", "->", "route", "(", "'laralum::users.index'", ")", "->", "with", "(", "'success'", ",", "__", "(", "'laralum_users::general.user_roles_updated'", ",", "[", "'id'", "=>", "$", "user", "->", "id", "]", ")", ")", ";", "}" ]
Remove the specified resource from storage. @param \Illuminate\Http\Request $request @param \Laralum\Users\Models\User $user @return \Illuminate\Http\Response
[ "Remove", "the", "specified", "resource", "from", "storage", "." ]
train
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Controllers/UserController.php#L154-L169
GrupaZero/api
src/Gzero/Api/Transformer/FileTranslationTransformer.php
FileTranslationTransformer.transform
public function transform($translation) { $translation = $this->entityToArray(FileTranslation::class, $translation); return [ 'id' => (int) $translation['id'], 'langCode' => $translation['lang_code'], 'title' => $translation['title'], 'description' => $translation['description'], 'createdAt' => $translation['created_at'], 'updatedAt' => $translation['updated_at'], ]; }
php
public function transform($translation) { $translation = $this->entityToArray(FileTranslation::class, $translation); return [ 'id' => (int) $translation['id'], 'langCode' => $translation['lang_code'], 'title' => $translation['title'], 'description' => $translation['description'], 'createdAt' => $translation['created_at'], 'updatedAt' => $translation['updated_at'], ]; }
[ "public", "function", "transform", "(", "$", "translation", ")", "{", "$", "translation", "=", "$", "this", "->", "entityToArray", "(", "FileTranslation", "::", "class", ",", "$", "translation", ")", ";", "return", "[", "'id'", "=>", "(", "int", ")", "$", "translation", "[", "'id'", "]", ",", "'langCode'", "=>", "$", "translation", "[", "'lang_code'", "]", ",", "'title'", "=>", "$", "translation", "[", "'title'", "]", ",", "'description'", "=>", "$", "translation", "[", "'description'", "]", ",", "'createdAt'", "=>", "$", "translation", "[", "'created_at'", "]", ",", "'updatedAt'", "=>", "$", "translation", "[", "'updated_at'", "]", ",", "]", ";", "}" ]
Transforms route translation entity @param FileTranslation|array $translation FileTranslation entity @return array
[ "Transforms", "route", "translation", "entity" ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/FileTranslationTransformer.php#L26-L37
GrupaZero/api
src/Gzero/Api/Transformer/UserTransformer.php
UserTransformer.transform
public function transform($user) { $user = $this->entityToArray(User::class, $user); return [ 'id' => (int) $user['id'], 'email' => $user['email'], 'nick' => $user['nick'], 'firstName' => $user['first_name'], 'lastName' => $user['last_name'], 'roles' => !empty($user['roles']) ? $user['roles'] : [] ]; }
php
public function transform($user) { $user = $this->entityToArray(User::class, $user); return [ 'id' => (int) $user['id'], 'email' => $user['email'], 'nick' => $user['nick'], 'firstName' => $user['first_name'], 'lastName' => $user['last_name'], 'roles' => !empty($user['roles']) ? $user['roles'] : [] ]; }
[ "public", "function", "transform", "(", "$", "user", ")", "{", "$", "user", "=", "$", "this", "->", "entityToArray", "(", "User", "::", "class", ",", "$", "user", ")", ";", "return", "[", "'id'", "=>", "(", "int", ")", "$", "user", "[", "'id'", "]", ",", "'email'", "=>", "$", "user", "[", "'email'", "]", ",", "'nick'", "=>", "$", "user", "[", "'nick'", "]", ",", "'firstName'", "=>", "$", "user", "[", "'first_name'", "]", ",", "'lastName'", "=>", "$", "user", "[", "'last_name'", "]", ",", "'roles'", "=>", "!", "empty", "(", "$", "user", "[", "'roles'", "]", ")", "?", "$", "user", "[", "'roles'", "]", ":", "[", "]", "]", ";", "}" ]
Transforms user entity @param User|array $user User entity @return array
[ "Transforms", "user", "entity" ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/UserTransformer.php#L35-L46
GrupaZero/api
src/Gzero/Api/Transformer/UserTransformer.php
UserTransformer.includeRoles
public function includeRoles(User $user) { $roles = $user->roles; return $this->collection($roles, new RoleTransformer()); }
php
public function includeRoles(User $user) { $roles = $user->roles; return $this->collection($roles, new RoleTransformer()); }
[ "public", "function", "includeRoles", "(", "User", "$", "user", ")", "{", "$", "roles", "=", "$", "user", "->", "roles", ";", "return", "$", "this", "->", "collection", "(", "$", "roles", ",", "new", "RoleTransformer", "(", ")", ")", ";", "}" ]
Include Roles @param User $user Translation @return \League\Fractal\ItemResource
[ "Include", "Roles" ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/UserTransformer.php#L55-L59
DesignPond/newsletter
src/Newsletter/Service/UploadWorker.php
UploadWorker.upload
public function upload( $file , $destination , $type = null){ $name = $file->getClientOriginalName(); $ext = $file->getClientOriginalExtension(); // Get the name first because after moving, the file doesn't exist anymore $new = $file->move($destination,$name); $size = $new->getSize(); $mime = $new->getMimeType(); $path = $new->getRealPath(); $image_name = basename($name,'.'.$ext); //resize if($type) { // resize if we have to $sizes = config('size.'.$type); $this->resize( $path, $image_name, $sizes['width'], $sizes['height']); } return array('name' => $name ,'ext' => $ext ,'size' => $size ,'mime' => $mime ,'path' => $path ); }
php
public function upload( $file , $destination , $type = null){ $name = $file->getClientOriginalName(); $ext = $file->getClientOriginalExtension(); // Get the name first because after moving, the file doesn't exist anymore $new = $file->move($destination,$name); $size = $new->getSize(); $mime = $new->getMimeType(); $path = $new->getRealPath(); $image_name = basename($name,'.'.$ext); //resize if($type) { // resize if we have to $sizes = config('size.'.$type); $this->resize( $path, $image_name, $sizes['width'], $sizes['height']); } return array('name' => $name ,'ext' => $ext ,'size' => $size ,'mime' => $mime ,'path' => $path ); }
[ "public", "function", "upload", "(", "$", "file", ",", "$", "destination", ",", "$", "type", "=", "null", ")", "{", "$", "name", "=", "$", "file", "->", "getClientOriginalName", "(", ")", ";", "$", "ext", "=", "$", "file", "->", "getClientOriginalExtension", "(", ")", ";", "// Get the name first because after moving, the file doesn't exist anymore", "$", "new", "=", "$", "file", "->", "move", "(", "$", "destination", ",", "$", "name", ")", ";", "$", "size", "=", "$", "new", "->", "getSize", "(", ")", ";", "$", "mime", "=", "$", "new", "->", "getMimeType", "(", ")", ";", "$", "path", "=", "$", "new", "->", "getRealPath", "(", ")", ";", "$", "image_name", "=", "basename", "(", "$", "name", ",", "'.'", ".", "$", "ext", ")", ";", "//resize", "if", "(", "$", "type", ")", "{", "// resize if we have to", "$", "sizes", "=", "config", "(", "'size.'", ".", "$", "type", ")", ";", "$", "this", "->", "resize", "(", "$", "path", ",", "$", "image_name", ",", "$", "sizes", "[", "'width'", "]", ",", "$", "sizes", "[", "'height'", "]", ")", ";", "}", "return", "array", "(", "'name'", "=>", "$", "name", ",", "'ext'", "=>", "$", "ext", ",", "'size'", "=>", "$", "size", ",", "'mime'", "=>", "$", "mime", ",", "'path'", "=>", "$", "path", ")", ";", "}" ]
/* upload selected file @return array
[ "/", "*", "upload", "selected", "file" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Newsletter/Service/UploadWorker.php#L11-L34
DesignPond/newsletter
src/Newsletter/Service/UploadWorker.php
UploadWorker.rename
public function rename($file , $name , $path ) { $new = $path.'/'.$name; return \Image::make( $file )->save($new); }
php
public function rename($file , $name , $path ) { $new = $path.'/'.$name; return \Image::make( $file )->save($new); }
[ "public", "function", "rename", "(", "$", "file", ",", "$", "name", ",", "$", "path", ")", "{", "$", "new", "=", "$", "path", ".", "'/'", ".", "$", "name", ";", "return", "\\", "Image", "::", "make", "(", "$", "file", ")", "->", "save", "(", "$", "new", ")", ";", "}" ]
/* rename file @return instance
[ "/", "*", "rename", "file" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Newsletter/Service/UploadWorker.php#L40-L45
DesignPond/newsletter
src/Newsletter/Service/UploadWorker.php
UploadWorker.resize
public function resize( $path, $name , $width = null , $height = null) { $img = \Image::make($path); // prevent possible upsizing $img->resize($width, $height, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); }); $img->save($path); }
php
public function resize( $path, $name , $width = null , $height = null) { $img = \Image::make($path); // prevent possible upsizing $img->resize($width, $height, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); }); $img->save($path); }
[ "public", "function", "resize", "(", "$", "path", ",", "$", "name", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ")", "{", "$", "img", "=", "\\", "Image", "::", "make", "(", "$", "path", ")", ";", "// prevent possible upsizing", "$", "img", "->", "resize", "(", "$", "width", ",", "$", "height", ",", "function", "(", "$", "constraint", ")", "{", "$", "constraint", "->", "aspectRatio", "(", ")", ";", "$", "constraint", "->", "upsize", "(", ")", ";", "}", ")", ";", "$", "img", "->", "save", "(", "$", "path", ")", ";", "}" ]
/* resize file @return instance
[ "/", "*", "resize", "file" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Newsletter/Service/UploadWorker.php#L51-L63
SporkCode/Spork
src/Mvc/Listener/XmlHttpRequestStrategy.php
XmlHttpRequestStrategy.handleXmlHttpRequest
public function handleXmlHttpRequest(MvcEvent $event) { $request = $event->getRequest(); if ($request->isXMLHttpRequest()) { $dispatchResult = $event->getResult(); if ($dispatchResult instanceof ViewModel) { $dispatchResult->setTerminal(true); } } }
php
public function handleXmlHttpRequest(MvcEvent $event) { $request = $event->getRequest(); if ($request->isXMLHttpRequest()) { $dispatchResult = $event->getResult(); if ($dispatchResult instanceof ViewModel) { $dispatchResult->setTerminal(true); } } }
[ "public", "function", "handleXmlHttpRequest", "(", "MvcEvent", "$", "event", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "$", "request", "->", "isXMLHttpRequest", "(", ")", ")", "{", "$", "dispatchResult", "=", "$", "event", "->", "getResult", "(", ")", ";", "if", "(", "$", "dispatchResult", "instanceof", "ViewModel", ")", "{", "$", "dispatchResult", "->", "setTerminal", "(", "true", ")", ";", "}", "}", "}" ]
If request is an XML HTTP Request disable layouts @param MvcEvent $event
[ "If", "request", "is", "an", "XML", "HTTP", "Request", "disable", "layouts" ]
train
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/XmlHttpRequestStrategy.php#L41-L50
ajgarlag/AjglSessionConcurrency
src/Http/Session/ConcurrentSessionControlAuthenticationStrategy.php
ConcurrentSessionControlAuthenticationStrategy.onAuthentication
public function onAuthentication(Request $request, TokenInterface $token) { $username = $token->getUsername(); $sessions = $this->registry->getAllSessions($username); $sessionCount = count($sessions); $maxSessions = $this->getMaximumSessionsForThisUser($username); if ($sessionCount < $maxSessions) { return; } if ($sessionCount === $maxSessions) { foreach ($sessions as $sessionInfo) { /* @var $sessionInfo Registry\SessionInformation */ if ($sessionInfo->getSessionId() === $request->getSession()->getId()) { return; } } } $this->allowedSessionsExceeded($sessions, $maxSessions, $this->registry); }
php
public function onAuthentication(Request $request, TokenInterface $token) { $username = $token->getUsername(); $sessions = $this->registry->getAllSessions($username); $sessionCount = count($sessions); $maxSessions = $this->getMaximumSessionsForThisUser($username); if ($sessionCount < $maxSessions) { return; } if ($sessionCount === $maxSessions) { foreach ($sessions as $sessionInfo) { /* @var $sessionInfo Registry\SessionInformation */ if ($sessionInfo->getSessionId() === $request->getSession()->getId()) { return; } } } $this->allowedSessionsExceeded($sessions, $maxSessions, $this->registry); }
[ "public", "function", "onAuthentication", "(", "Request", "$", "request", ",", "TokenInterface", "$", "token", ")", "{", "$", "username", "=", "$", "token", "->", "getUsername", "(", ")", ";", "$", "sessions", "=", "$", "this", "->", "registry", "->", "getAllSessions", "(", "$", "username", ")", ";", "$", "sessionCount", "=", "count", "(", "$", "sessions", ")", ";", "$", "maxSessions", "=", "$", "this", "->", "getMaximumSessionsForThisUser", "(", "$", "username", ")", ";", "if", "(", "$", "sessionCount", "<", "$", "maxSessions", ")", "{", "return", ";", "}", "if", "(", "$", "sessionCount", "===", "$", "maxSessions", ")", "{", "foreach", "(", "$", "sessions", "as", "$", "sessionInfo", ")", "{", "/* @var $sessionInfo Registry\\SessionInformation */", "if", "(", "$", "sessionInfo", "->", "getSessionId", "(", ")", "===", "$", "request", "->", "getSession", "(", ")", "->", "getId", "(", ")", ")", "{", "return", ";", "}", "}", "}", "$", "this", "->", "allowedSessionsExceeded", "(", "$", "sessions", ",", "$", "maxSessions", ",", "$", "this", "->", "registry", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/ConcurrentSessionControlAuthenticationStrategy.php#L53-L75
ajgarlag/AjglSessionConcurrency
src/Http/Session/ConcurrentSessionControlAuthenticationStrategy.php
ConcurrentSessionControlAuthenticationStrategy.allowedSessionsExceeded
protected function allowedSessionsExceeded($orderedSessions, $allowableSessions, SessionRegistry $registry) { if ($this->errorIfMaximumExceeded) { throw new MaxSessionsExceededException(sprintf('Maximum number of sessions (%s) exceeded', $allowableSessions)); } // Expire oldest session $orderedSessionsVector = array_values($orderedSessions); for ($i = $allowableSessions - 1, $countSessions = count($orderedSessionsVector); $i < $countSessions; $i++) { $registry->expireNow($orderedSessionsVector[$i]->getSessionId()); } }
php
protected function allowedSessionsExceeded($orderedSessions, $allowableSessions, SessionRegistry $registry) { if ($this->errorIfMaximumExceeded) { throw new MaxSessionsExceededException(sprintf('Maximum number of sessions (%s) exceeded', $allowableSessions)); } // Expire oldest session $orderedSessionsVector = array_values($orderedSessions); for ($i = $allowableSessions - 1, $countSessions = count($orderedSessionsVector); $i < $countSessions; $i++) { $registry->expireNow($orderedSessionsVector[$i]->getSessionId()); } }
[ "protected", "function", "allowedSessionsExceeded", "(", "$", "orderedSessions", ",", "$", "allowableSessions", ",", "SessionRegistry", "$", "registry", ")", "{", "if", "(", "$", "this", "->", "errorIfMaximumExceeded", ")", "{", "throw", "new", "MaxSessionsExceededException", "(", "sprintf", "(", "'Maximum number of sessions (%s) exceeded'", ",", "$", "allowableSessions", ")", ")", ";", "}", "// Expire oldest session", "$", "orderedSessionsVector", "=", "array_values", "(", "$", "orderedSessions", ")", ";", "for", "(", "$", "i", "=", "$", "allowableSessions", "-", "1", ",", "$", "countSessions", "=", "count", "(", "$", "orderedSessionsVector", ")", ";", "$", "i", "<", "$", "countSessions", ";", "$", "i", "++", ")", "{", "$", "registry", "->", "expireNow", "(", "$", "orderedSessionsVector", "[", "$", "i", "]", "->", "getSessionId", "(", ")", ")", ";", "}", "}" ]
Allows subclasses to customize behavior when too many sessions are detected. @param Registry\SessionInformation[] $orderedSessions Array of SessionInformation ordered from newest to oldest @param int $allowableSessions @param SessionRegistry $registry
[ "Allows", "subclasses", "to", "customize", "behavior", "when", "too", "many", "sessions", "are", "detected", "." ]
train
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/ConcurrentSessionControlAuthenticationStrategy.php#L104-L115
gaptree/gap-php-open-server
src/Service/RefreshTokenService.php
RefreshTokenService.create
public function create(array $opts): RefreshTokenDto { $appId = $opts['appId'] ?? ''; $userId = $opts['userId'] ?? ''; $scope = $opts['scope'] ?? ''; $created = new DateTime(); $expired = (new DateTime())->add($this->getTtl()); if (empty($appId)) { throw new \Exception('appId cannot be empty'); } $refreshToken = new RefreshTokenDto([ 'refresh' => $this->randomCode(), 'appId' => $appId, 'userId' => $userId, 'scope' => $scope, 'created' => $created, 'expired' => $expired ]); $this->cacheSet($refreshToken->refresh, $refreshToken, $this->getTtl()); $this->getRepo()->create($refreshToken); return $refreshToken; }
php
public function create(array $opts): RefreshTokenDto { $appId = $opts['appId'] ?? ''; $userId = $opts['userId'] ?? ''; $scope = $opts['scope'] ?? ''; $created = new DateTime(); $expired = (new DateTime())->add($this->getTtl()); if (empty($appId)) { throw new \Exception('appId cannot be empty'); } $refreshToken = new RefreshTokenDto([ 'refresh' => $this->randomCode(), 'appId' => $appId, 'userId' => $userId, 'scope' => $scope, 'created' => $created, 'expired' => $expired ]); $this->cacheSet($refreshToken->refresh, $refreshToken, $this->getTtl()); $this->getRepo()->create($refreshToken); return $refreshToken; }
[ "public", "function", "create", "(", "array", "$", "opts", ")", ":", "RefreshTokenDto", "{", "$", "appId", "=", "$", "opts", "[", "'appId'", "]", "??", "''", ";", "$", "userId", "=", "$", "opts", "[", "'userId'", "]", "??", "''", ";", "$", "scope", "=", "$", "opts", "[", "'scope'", "]", "??", "''", ";", "$", "created", "=", "new", "DateTime", "(", ")", ";", "$", "expired", "=", "(", "new", "DateTime", "(", ")", ")", "->", "add", "(", "$", "this", "->", "getTtl", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "appId", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'appId cannot be empty'", ")", ";", "}", "$", "refreshToken", "=", "new", "RefreshTokenDto", "(", "[", "'refresh'", "=>", "$", "this", "->", "randomCode", "(", ")", ",", "'appId'", "=>", "$", "appId", ",", "'userId'", "=>", "$", "userId", ",", "'scope'", "=>", "$", "scope", ",", "'created'", "=>", "$", "created", ",", "'expired'", "=>", "$", "expired", "]", ")", ";", "$", "this", "->", "cacheSet", "(", "$", "refreshToken", "->", "refresh", ",", "$", "refreshToken", ",", "$", "this", "->", "getTtl", "(", ")", ")", ";", "$", "this", "->", "getRepo", "(", ")", "->", "create", "(", "$", "refreshToken", ")", ";", "return", "$", "refreshToken", ";", "}" ]
/* public function generate( string $appId, string $userId = '', string $scope = '' ): RefreshTokenDto { $created = new DateTime(); $expired = (new DateTime())->add($this->getTtl()); $refreshToken = new RefreshTokenDto([ 'refresh' => $this->randomCode(), 'appId' => $appId, 'userId' => $userId, 'scope' => $scope, 'created' => $created, 'expired' => $expired ]); return $refreshToken; } public function create(RefreshTokenDto $refreshToken): void { if ($this->cache) { $this->cache->set($refreshToken->refresh, $refreshToken, $this->getTtl()); } $this->getRepo()->create($refreshToken); }
[ "/", "*", "public", "function", "generate", "(", "string", "$appId", "string", "$userId", "=", "string", "$scope", "=", ")", ":", "RefreshTokenDto", "{", "$created", "=", "new", "DateTime", "()", ";", "$expired", "=", "(", "new", "DateTime", "()", ")", "-", ">", "add", "(", "$this", "-", ">", "getTtl", "()", ")", ";" ]
train
https://github.com/gaptree/gap-php-open-server/blob/cd53c192066c32455f45ca50de822d87dc726b66/src/Service/RefreshTokenService.php#L43-L68
WellCommerce/StandardEditionBundle
DataFixtures/ORM/LoadCurrencyData.php
LoadCurrencyData.load
public function load(ObjectManager $manager) { if (!$this->isEnabled()) { return; } foreach (self::$samples as $name) { $currency = new Currency(); $currency->setCode($name); $currency->setEnabled(true); $manager->persist($currency); $this->setReference('currency_' . $name, $currency); } $manager->flush(); $this->container->get('currency.importer.ecb')->importExchangeRates(); }
php
public function load(ObjectManager $manager) { if (!$this->isEnabled()) { return; } foreach (self::$samples as $name) { $currency = new Currency(); $currency->setCode($name); $currency->setEnabled(true); $manager->persist($currency); $this->setReference('currency_' . $name, $currency); } $manager->flush(); $this->container->get('currency.importer.ecb')->importExchangeRates(); }
[ "public", "function", "load", "(", "ObjectManager", "$", "manager", ")", "{", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "foreach", "(", "self", "::", "$", "samples", "as", "$", "name", ")", "{", "$", "currency", "=", "new", "Currency", "(", ")", ";", "$", "currency", "->", "setCode", "(", "$", "name", ")", ";", "$", "currency", "->", "setEnabled", "(", "true", ")", ";", "$", "manager", "->", "persist", "(", "$", "currency", ")", ";", "$", "this", "->", "setReference", "(", "'currency_'", ".", "$", "name", ",", "$", "currency", ")", ";", "}", "$", "manager", "->", "flush", "(", ")", ";", "$", "this", "->", "container", "->", "get", "(", "'currency.importer.ecb'", ")", "->", "importExchangeRates", "(", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/WellCommerce/StandardEditionBundle/blob/6367bd20bbb6bde37c710a6ba87ae72b5f05f61e/DataFixtures/ORM/LoadCurrencyData.php#L31-L49
ajgarlag/AjglCsv
src/Reader/ReaderAbstract.php
ReaderAbstract.readNextRow
public function readNextRow($outputCharset = IoInterface::CHARSET_DEFAULT) { $row = $this->doRead($this->getHandler(), $this->getDelimiter()); if ($row !== null && $outputCharset !== $this->getFileCharset()) { $row = $this->convertRowCharset($row, $this->getFileCharset(), $outputCharset); } return $row; }
php
public function readNextRow($outputCharset = IoInterface::CHARSET_DEFAULT) { $row = $this->doRead($this->getHandler(), $this->getDelimiter()); if ($row !== null && $outputCharset !== $this->getFileCharset()) { $row = $this->convertRowCharset($row, $this->getFileCharset(), $outputCharset); } return $row; }
[ "public", "function", "readNextRow", "(", "$", "outputCharset", "=", "IoInterface", "::", "CHARSET_DEFAULT", ")", "{", "$", "row", "=", "$", "this", "->", "doRead", "(", "$", "this", "->", "getHandler", "(", ")", ",", "$", "this", "->", "getDelimiter", "(", ")", ")", ";", "if", "(", "$", "row", "!==", "null", "&&", "$", "outputCharset", "!==", "$", "this", "->", "getFileCharset", "(", ")", ")", "{", "$", "row", "=", "$", "this", "->", "convertRowCharset", "(", "$", "row", ",", "$", "this", "->", "getFileCharset", "(", ")", ",", "$", "outputCharset", ")", ";", "}", "return", "$", "row", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ajgarlag/AjglCsv/blob/28872f58b9ef864893cac6faddfcb1229c2c2047/src/Reader/ReaderAbstract.php#L43-L52
ajgarlag/AjglCsv
src/Reader/ReaderAbstract.php
ReaderAbstract.readNextRows
public function readNextRows($inputCharset = IoInterface::CHARSET_DEFAULT, $limit = null) { $res = array(); if ($limit === null) { while ($row = $this->readNextRow($inputCharset)) { array_push($res, $row); } } else { $limit = (int) $limit; for ($i = 0; $i < $limit; ++$i) { if ($row = $this->readNextRow($inputCharset)) { array_push($res, $row); } else { break; } } } return $res; }
php
public function readNextRows($inputCharset = IoInterface::CHARSET_DEFAULT, $limit = null) { $res = array(); if ($limit === null) { while ($row = $this->readNextRow($inputCharset)) { array_push($res, $row); } } else { $limit = (int) $limit; for ($i = 0; $i < $limit; ++$i) { if ($row = $this->readNextRow($inputCharset)) { array_push($res, $row); } else { break; } } } return $res; }
[ "public", "function", "readNextRows", "(", "$", "inputCharset", "=", "IoInterface", "::", "CHARSET_DEFAULT", ",", "$", "limit", "=", "null", ")", "{", "$", "res", "=", "array", "(", ")", ";", "if", "(", "$", "limit", "===", "null", ")", "{", "while", "(", "$", "row", "=", "$", "this", "->", "readNextRow", "(", "$", "inputCharset", ")", ")", "{", "array_push", "(", "$", "res", ",", "$", "row", ")", ";", "}", "}", "else", "{", "$", "limit", "=", "(", "int", ")", "$", "limit", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "limit", ";", "++", "$", "i", ")", "{", "if", "(", "$", "row", "=", "$", "this", "->", "readNextRow", "(", "$", "inputCharset", ")", ")", "{", "array_push", "(", "$", "res", ",", "$", "row", ")", ";", "}", "else", "{", "break", ";", "}", "}", "}", "return", "$", "res", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ajgarlag/AjglCsv/blob/28872f58b9ef864893cac6faddfcb1229c2c2047/src/Reader/ReaderAbstract.php#L57-L76
xiewulong/yii2-fileupload
oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php
ApcUniversalClassLoader.findFile
public function findFile($class) { if (false === $file = apc_fetch($this->prefix.$class)) { apc_store($this->prefix.$class, $file = parent::findFile($class)); } return $file; }
php
public function findFile($class) { if (false === $file = apc_fetch($this->prefix.$class)) { apc_store($this->prefix.$class, $file = parent::findFile($class)); } return $file; }
[ "public", "function", "findFile", "(", "$", "class", ")", "{", "if", "(", "false", "===", "$", "file", "=", "apc_fetch", "(", "$", "this", "->", "prefix", ".", "$", "class", ")", ")", "{", "apc_store", "(", "$", "this", "->", "prefix", ".", "$", "class", ",", "$", "file", "=", "parent", "::", "findFile", "(", "$", "class", ")", ")", ";", "}", "return", "$", "file", ";", "}" ]
Finds a file by class name while caching lookups to APC. @param string $class A class name to resolve to file @return string|null The path, if found
[ "Finds", "a", "file", "by", "class", "name", "while", "caching", "lookups", "to", "APC", "." ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php#L92-L99
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Controller/ProfileController.php
ProfileController.editAction
public function editAction() { $entity = $this->getUser(); if (!$entity) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditForm($entity); return array( 'entity' => $entity, 'edit_form' => $editForm->createView(), ); }
php
public function editAction() { $entity = $this->getUser(); if (!$entity) { throw $this->createNotFoundException('Unable to find User entity.'); } $editForm = $this->createEditForm($entity); return array( 'entity' => $entity, 'edit_form' => $editForm->createView(), ); }
[ "public", "function", "editAction", "(", ")", "{", "$", "entity", "=", "$", "this", "->", "getUser", "(", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find User entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "entity", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to edit an existing User entity. @Route("/edit", name="amulen_profile_edit") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "edit", "an", "existing", "User", "entity", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/ProfileController.php#L43-L57
ClementIV/yii-rest-rbac2.0
controllers/MenuController.php
MenuController.actionIndex
public function actionIndex() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['index']); } try{ return Menu::getPageMenus(Yii::$app->request->queryParams); }catch(Exception $e) { throw new Exception($e); } }
php
public function actionIndex() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['index']); } try{ return Menu::getPageMenus(Yii::$app->request->queryParams); }catch(Exception $e) { throw new Exception($e); } }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'index'", "]", ")", ";", "}", "try", "{", "return", "Menu", "::", "getPageMenus", "(", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
Lists all Menu models. @return mixed
[ "Lists", "all", "Menu", "models", "." ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/MenuController.php#L49-L65
ClementIV/yii-rest-rbac2.0
controllers/MenuController.php
MenuController.actionGetMenus
public function actionGetMenus() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['index']); } try{ return Menu::getMenuSource(); }catch(Exception $e){ throw new Exception($e); } }
php
public function actionGetMenus() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['index']); } try{ return Menu::getMenuSource(); }catch(Exception $e){ throw new Exception($e); } }
[ "public", "function", "actionGetMenus", "(", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'index'", "]", ")", ";", "}", "try", "{", "return", "Menu", "::", "getMenuSource", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
list all menus @return json list
[ "list", "all", "menus" ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/MenuController.php#L71-L82
ClementIV/yii-rest-rbac2.0
controllers/MenuController.php
MenuController.actionGetSavedRoutes
public function actionGetSavedRoutes() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['index']); } try{ return Menu::getSavedRoutes(); }catch(Exception $e){ throw new Exception($e); } }
php
public function actionGetSavedRoutes() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['index']); } try{ return Menu::getSavedRoutes(); }catch(Exception $e){ throw new Exception($e); } }
[ "public", "function", "actionGetSavedRoutes", "(", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'index'", "]", ")", ";", "}", "try", "{", "return", "Menu", "::", "getSavedRoutes", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
list all menus route @return json list
[ "list", "all", "menus", "route" ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/MenuController.php#L88-L99
ClementIV/yii-rest-rbac2.0
controllers/MenuController.php
MenuController.actionCreate
public function actionCreate() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['create']); } try{ $model = new Menu; if ($model->load(Yii::$app->request->post()) && $model->save()) { Helper::invalidate(); return ["success"=> true]; } else { return ["success"=> false]; } }catch(Exception $e){ throw new Exception($e); } }
php
public function actionCreate() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['create']); } try{ $model = new Menu; if ($model->load(Yii::$app->request->post()) && $model->save()) { Helper::invalidate(); return ["success"=> true]; } else { return ["success"=> false]; } }catch(Exception $e){ throw new Exception($e); } }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'create'", "]", ")", ";", "}", "try", "{", "$", "model", "=", "new", "Menu", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "Helper", "::", "invalidate", "(", ")", ";", "return", "[", "\"success\"", "=>", "true", "]", ";", "}", "else", "{", "return", "[", "\"success\"", "=>", "false", "]", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
Creates a new Menu model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "Menu", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/MenuController.php#L124-L143
ClementIV/yii-rest-rbac2.0
controllers/MenuController.php
MenuController.actionUpdate
public function actionUpdate($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['update']); } try{ $model = $this->findModel($id); if ($model->menuParent) { $model->parent_name = $model->menuParent->name; } if ($model->load(Yii::$app->request->post()) && $model->save()) { Helper::invalidate(); return ["success"=> true]; } else { return ["success"=> false]; } }catch(Exception $e){ throw new Exception($e); } }
php
public function actionUpdate($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['update']); } try{ $model = $this->findModel($id); if ($model->menuParent) { $model->parent_name = $model->menuParent->name; } if ($model->load(Yii::$app->request->post()) && $model->save()) { Helper::invalidate(); return ["success"=> true]; } else { return ["success"=> false]; } }catch(Exception $e){ throw new Exception($e); } }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'update'", "]", ")", ";", "}", "try", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "if", "(", "$", "model", "->", "menuParent", ")", "{", "$", "model", "->", "parent_name", "=", "$", "model", "->", "menuParent", "->", "name", ";", "}", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "Helper", "::", "invalidate", "(", ")", ";", "return", "[", "\"success\"", "=>", "true", "]", ";", "}", "else", "{", "return", "[", "\"success\"", "=>", "false", "]", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
Updates an existing Menu model. If update is successful, the browser will be redirected to the 'view' page. @param integer $id @return mixed
[ "Updates", "an", "existing", "Menu", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/MenuController.php#L151-L171
ClementIV/yii-rest-rbac2.0
controllers/MenuController.php
MenuController.actionDelete
public function actionDelete($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['delete']); } $this->findModel($id)->delete(); Helper::invalidate(); return ["success"=> true]; }
php
public function actionDelete($id) { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['delete']); } $this->findModel($id)->delete(); Helper::invalidate(); return ["success"=> true]; }
[ "public", "function", "actionDelete", "(", "$", "id", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'delete'", "]", ")", ";", "}", "$", "this", "->", "findModel", "(", "$", "id", ")", "->", "delete", "(", ")", ";", "Helper", "::", "invalidate", "(", ")", ";", "return", "[", "\"success\"", "=>", "true", "]", ";", "}" ]
Deletes an existing Menu model. If deletion is successful, the browser will be redirected to the 'index' page. @param integer $id @return mixed
[ "Deletes", "an", "existing", "Menu", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "index", "page", "." ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/MenuController.php#L179-L189
novaway/open-graph
src/OpenGraphGenerator.php
OpenGraphGenerator.generate
public function generate($obj) { if (!is_object($obj)) { throw new \InvalidArgumentException('OpenGraphGenerator::generate only accept object argument.'); } $openGraph = new OpenGraph(); $classType = get_class($obj); $metadata = $this->factory->getMetadataForClass($classType); if (is_array($metadata->namespaces)) { foreach ($metadata->namespaces as $namespace) { $openGraph->addNamespace($namespace->prefix, $namespace->uri); } } if (is_array($metadata->nodes)) { foreach ($metadata->nodes as $graphNode) { if (!empty($graphNode['node']->namespaceUri)) { $openGraph->addNamespace($graphNode['node']->namespace, $graphNode['node']->namespaceUri); } $openGraph->add($graphNode['node']->namespace, $graphNode['node']->tag, $graphNode['object']->getValue($obj)); } } return $openGraph; }
php
public function generate($obj) { if (!is_object($obj)) { throw new \InvalidArgumentException('OpenGraphGenerator::generate only accept object argument.'); } $openGraph = new OpenGraph(); $classType = get_class($obj); $metadata = $this->factory->getMetadataForClass($classType); if (is_array($metadata->namespaces)) { foreach ($metadata->namespaces as $namespace) { $openGraph->addNamespace($namespace->prefix, $namespace->uri); } } if (is_array($metadata->nodes)) { foreach ($metadata->nodes as $graphNode) { if (!empty($graphNode['node']->namespaceUri)) { $openGraph->addNamespace($graphNode['node']->namespace, $graphNode['node']->namespaceUri); } $openGraph->add($graphNode['node']->namespace, $graphNode['node']->tag, $graphNode['object']->getValue($obj)); } } return $openGraph; }
[ "public", "function", "generate", "(", "$", "obj", ")", "{", "if", "(", "!", "is_object", "(", "$", "obj", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'OpenGraphGenerator::generate only accept object argument.'", ")", ";", "}", "$", "openGraph", "=", "new", "OpenGraph", "(", ")", ";", "$", "classType", "=", "get_class", "(", "$", "obj", ")", ";", "$", "metadata", "=", "$", "this", "->", "factory", "->", "getMetadataForClass", "(", "$", "classType", ")", ";", "if", "(", "is_array", "(", "$", "metadata", "->", "namespaces", ")", ")", "{", "foreach", "(", "$", "metadata", "->", "namespaces", "as", "$", "namespace", ")", "{", "$", "openGraph", "->", "addNamespace", "(", "$", "namespace", "->", "prefix", ",", "$", "namespace", "->", "uri", ")", ";", "}", "}", "if", "(", "is_array", "(", "$", "metadata", "->", "nodes", ")", ")", "{", "foreach", "(", "$", "metadata", "->", "nodes", "as", "$", "graphNode", ")", "{", "if", "(", "!", "empty", "(", "$", "graphNode", "[", "'node'", "]", "->", "namespaceUri", ")", ")", "{", "$", "openGraph", "->", "addNamespace", "(", "$", "graphNode", "[", "'node'", "]", "->", "namespace", ",", "$", "graphNode", "[", "'node'", "]", "->", "namespaceUri", ")", ";", "}", "$", "openGraph", "->", "add", "(", "$", "graphNode", "[", "'node'", "]", "->", "namespace", ",", "$", "graphNode", "[", "'node'", "]", "->", "tag", ",", "$", "graphNode", "[", "'object'", "]", "->", "getValue", "(", "$", "obj", ")", ")", ";", "}", "}", "return", "$", "openGraph", ";", "}" ]
Generate OpenGraph through metadata @param object $obj @return OpenGraphInterface
[ "Generate", "OpenGraph", "through", "metadata" ]
train
https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/OpenGraphGenerator.php#L29-L58
OKTOTV/OktolabMediaBundle
Model/EpisodeAssetDataJob.php
EpisodeAssetDataJob.getStreamInformationsOfEpisode
private function getStreamInformationsOfEpisode($episode) { $uri = $this->getContainer()->get('bprs.asset_helper')->getAbsoluteUrl($episode->getVideo()); if (!$uri) { // can't create uri of episode video $this->logbook->error('oktolab_media.episode_assetdatajob_nourl', [], $this->args['uniqID']); return false; } $metadata = ['video' => false, 'audio' => false]; try { $metainfo = json_decode(shell_exec(sprintf('ffprobe -v error -show_streams -print_format json %s', $uri)), true); foreach ($metainfo['streams'] as $stream) { if ($metadata['video'] && $metadata['audio']) { break; } if ($stream['codec_type'] == "audio") { $metadata['audio'] = $stream; } if ($stream['codec_type'] == "video") { $metadata['video'] = $stream; } } } catch (Exception $e) { $metadata = null; } return $metadata; }
php
private function getStreamInformationsOfEpisode($episode) { $uri = $this->getContainer()->get('bprs.asset_helper')->getAbsoluteUrl($episode->getVideo()); if (!$uri) { // can't create uri of episode video $this->logbook->error('oktolab_media.episode_assetdatajob_nourl', [], $this->args['uniqID']); return false; } $metadata = ['video' => false, 'audio' => false]; try { $metainfo = json_decode(shell_exec(sprintf('ffprobe -v error -show_streams -print_format json %s', $uri)), true); foreach ($metainfo['streams'] as $stream) { if ($metadata['video'] && $metadata['audio']) { break; } if ($stream['codec_type'] == "audio") { $metadata['audio'] = $stream; } if ($stream['codec_type'] == "video") { $metadata['video'] = $stream; } } } catch (Exception $e) { $metadata = null; } return $metadata; }
[ "private", "function", "getStreamInformationsOfEpisode", "(", "$", "episode", ")", "{", "$", "uri", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'bprs.asset_helper'", ")", "->", "getAbsoluteUrl", "(", "$", "episode", "->", "getVideo", "(", ")", ")", ";", "if", "(", "!", "$", "uri", ")", "{", "// can't create uri of episode video", "$", "this", "->", "logbook", "->", "error", "(", "'oktolab_media.episode_assetdatajob_nourl'", ",", "[", "]", ",", "$", "this", "->", "args", "[", "'uniqID'", "]", ")", ";", "return", "false", ";", "}", "$", "metadata", "=", "[", "'video'", "=>", "false", ",", "'audio'", "=>", "false", "]", ";", "try", "{", "$", "metainfo", "=", "json_decode", "(", "shell_exec", "(", "sprintf", "(", "'ffprobe -v error -show_streams -print_format json %s'", ",", "$", "uri", ")", ")", ",", "true", ")", ";", "foreach", "(", "$", "metainfo", "[", "'streams'", "]", "as", "$", "stream", ")", "{", "if", "(", "$", "metadata", "[", "'video'", "]", "&&", "$", "metadata", "[", "'audio'", "]", ")", "{", "break", ";", "}", "if", "(", "$", "stream", "[", "'codec_type'", "]", "==", "\"audio\"", ")", "{", "$", "metadata", "[", "'audio'", "]", "=", "$", "stream", ";", "}", "if", "(", "$", "stream", "[", "'codec_type'", "]", "==", "\"video\"", ")", "{", "$", "metadata", "[", "'video'", "]", "=", "$", "stream", ";", "}", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "metadata", "=", "null", ";", "}", "return", "$", "metadata", ";", "}" ]
extracts streaminformations of an episode from its video. returns false if informations can't be extracted returns array of video and audio info.
[ "extracts", "streaminformations", "of", "an", "episode", "from", "its", "video", ".", "returns", "false", "if", "informations", "can", "t", "be", "extracted", "returns", "array", "of", "video", "and", "audio", "info", "." ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EpisodeAssetDataJob.php#L77-L103
oroinc/OroLayoutComponent
Layouts.php
Layouts.createLayoutFactoryBuilder
public static function createLayoutFactoryBuilder() { $builder = new LayoutFactoryBuilder( new ExpressionProcessor( new ExpressionLanguage(), new ExpressionEncoderRegistry( [ 'json' => new JsonExpressionEncoder(new ExpressionManipulator()) ] ) ) ); $builder->addExtension(new CoreExtension()); return $builder; }
php
public static function createLayoutFactoryBuilder() { $builder = new LayoutFactoryBuilder( new ExpressionProcessor( new ExpressionLanguage(), new ExpressionEncoderRegistry( [ 'json' => new JsonExpressionEncoder(new ExpressionManipulator()) ] ) ) ); $builder->addExtension(new CoreExtension()); return $builder; }
[ "public", "static", "function", "createLayoutFactoryBuilder", "(", ")", "{", "$", "builder", "=", "new", "LayoutFactoryBuilder", "(", "new", "ExpressionProcessor", "(", "new", "ExpressionLanguage", "(", ")", ",", "new", "ExpressionEncoderRegistry", "(", "[", "'json'", "=>", "new", "JsonExpressionEncoder", "(", "new", "ExpressionManipulator", "(", ")", ")", "]", ")", ")", ")", ";", "$", "builder", "->", "addExtension", "(", "new", "CoreExtension", "(", ")", ")", ";", "return", "$", "builder", ";", "}" ]
Creates a layout factory builder with the default configuration. @return LayoutFactoryBuilderInterface
[ "Creates", "a", "layout", "factory", "builder", "with", "the", "default", "configuration", "." ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Layouts.php#L110-L126
phpnfe/tools
src/Strings.php
Strings.cleanString
public static function cleanString($texto = '') { $texto = trim($texto); $aFind = ['&', 'á', 'à', 'ã', 'â', 'é', 'ê', 'í', 'ó', 'ô', 'õ', 'ú', 'ü', 'ç', 'Á', 'À', 'Ã', 'Â', 'É', 'Ê', 'Í', 'Ó', 'Ô', 'Õ', 'Ú', 'Ü', 'Ç']; $aSubs = ['e', 'a', 'a', 'a', 'a', 'e', 'e', 'i', 'o', 'o', 'o', 'u', 'u', 'c', 'A', 'A', 'A', 'A', 'E', 'E', 'I', 'O', 'O', 'O', 'U', 'U', 'C', ]; $novoTexto = str_replace($aFind, $aSubs, $texto); $novoTexto = preg_replace("/[^a-zA-Z0-9 @,-.;:\/]/", '', $novoTexto); return $novoTexto; }
php
public static function cleanString($texto = '') { $texto = trim($texto); $aFind = ['&', 'á', 'à', 'ã', 'â', 'é', 'ê', 'í', 'ó', 'ô', 'õ', 'ú', 'ü', 'ç', 'Á', 'À', 'Ã', 'Â', 'É', 'Ê', 'Í', 'Ó', 'Ô', 'Õ', 'Ú', 'Ü', 'Ç']; $aSubs = ['e', 'a', 'a', 'a', 'a', 'e', 'e', 'i', 'o', 'o', 'o', 'u', 'u', 'c', 'A', 'A', 'A', 'A', 'E', 'E', 'I', 'O', 'O', 'O', 'U', 'U', 'C', ]; $novoTexto = str_replace($aFind, $aSubs, $texto); $novoTexto = preg_replace("/[^a-zA-Z0-9 @,-.;:\/]/", '', $novoTexto); return $novoTexto; }
[ "public", "static", "function", "cleanString", "(", "$", "texto", "=", "''", ")", "{", "$", "texto", "=", "trim", "(", "$", "texto", ")", ";", "$", "aFind", "=", "[", "'&'", ",", "'á',", " ", "à', ", "'", "', '", "â", ", 'é", "'", " 'ê'", ",", "'í',", " ", "ó', ", "'", "', '", "õ", ", 'ú", "'", " 'ü'", ",", "'ç',", " ", "Á', ", "'", "', '", "Ã", ", 'Â", "'", " 'É'", ",", "'Ê',", " ", "Í', ", "'", "', '", "Ô", ", 'Õ", "'", " 'Ú'", ",", "'Ü',", " ", "Ç'];", "", "", "", "", "", "", "", "", "", "", "$", "aSubs", "=", "[", "'e'", ",", "'a'", ",", "'a'", ",", "'a'", ",", "'a'", ",", "'e'", ",", "'e'", ",", "'i'", ",", "'o'", ",", "'o'", ",", "'o'", ",", "'u'", ",", "'u'", ",", "'c'", ",", "'A'", ",", "'A'", ",", "'A'", ",", "'A'", ",", "'E'", ",", "'E'", ",", "'I'", ",", "'O'", ",", "'O'", ",", "'O'", ",", "'U'", ",", "'U'", ",", "'C'", ",", "]", ";", "$", "novoTexto", "=", "str_replace", "(", "$", "aFind", ",", "$", "aSubs", ",", "$", "texto", ")", ";", "$", "novoTexto", "=", "preg_replace", "(", "\"/[^a-zA-Z0-9 @,-.;:\\/]/\"", ",", "''", ",", "$", "novoTexto", ")", ";", "return", "$", "novoTexto", ";", "}" ]
cleanString Remove todos dos caracteres especiais do texto e os acentos. @param string $texto @return string Texto sem caractere especiais
[ "cleanString", "Remove", "todos", "dos", "caracteres", "especiais", "do", "texto", "e", "os", "acentos", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Strings.php#L19-L29
phpnfe/tools
src/Strings.php
Strings.clearXml
public static function clearXml($xml = '', $remEnc = false) { //$xml = self::clearMsg($xml); $aFind = [ 'xmlns:default="http://www.w3.org/2000/09/xmldsig#"', ' standalone="no"', 'default:', ':default', "\n", "\r", "\t", ]; if ($remEnc) { $aFind[] = '<?xml version="1.0"?>'; $aFind[] = '<?xml version="1.0" encoding="utf-8"?>'; $aFind[] = '<?xml version="1.0" encoding="UTF-8"?>'; $aFind[] = '<?xml version="1.0" encoding="utf-8" standalone="no"?>'; $aFind[] = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'; } $retXml = str_replace($aFind, '', $xml); return $retXml; }
php
public static function clearXml($xml = '', $remEnc = false) { //$xml = self::clearMsg($xml); $aFind = [ 'xmlns:default="http://www.w3.org/2000/09/xmldsig#"', ' standalone="no"', 'default:', ':default', "\n", "\r", "\t", ]; if ($remEnc) { $aFind[] = '<?xml version="1.0"?>'; $aFind[] = '<?xml version="1.0" encoding="utf-8"?>'; $aFind[] = '<?xml version="1.0" encoding="UTF-8"?>'; $aFind[] = '<?xml version="1.0" encoding="utf-8" standalone="no"?>'; $aFind[] = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'; } $retXml = str_replace($aFind, '', $xml); return $retXml; }
[ "public", "static", "function", "clearXml", "(", "$", "xml", "=", "''", ",", "$", "remEnc", "=", "false", ")", "{", "//$xml = self::clearMsg($xml);", "$", "aFind", "=", "[", "'xmlns:default=\"http://www.w3.org/2000/09/xmldsig#\"'", ",", "' standalone=\"no\"'", ",", "'default:'", ",", "':default'", ",", "\"\\n\"", ",", "\"\\r\"", ",", "\"\\t\"", ",", "]", ";", "if", "(", "$", "remEnc", ")", "{", "$", "aFind", "[", "]", "=", "'<?xml version=\"1.0\"?>'", ";", "$", "aFind", "[", "]", "=", "'<?xml version=\"1.0\" encoding=\"utf-8\"?>'", ";", "$", "aFind", "[", "]", "=", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'", ";", "$", "aFind", "[", "]", "=", "'<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>'", ";", "$", "aFind", "[", "]", "=", "'<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>'", ";", "}", "$", "retXml", "=", "str_replace", "(", "$", "aFind", ",", "''", ",", "$", "xml", ")", ";", "return", "$", "retXml", ";", "}" ]
clearXml Remove \r \n \s \t. @param string $xml @param bool $remEnc remover encoding do xml @return string
[ "clearXml", "Remove", "\\", "r", "\\", "n", "\\", "s", "\\", "t", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Strings.php#L38-L60
phpnfe/tools
src/Strings.php
Strings.clearProt
public static function clearProt($procXML = '') { $procXML = self::clearMsg($procXML); $aApp = ['nfe', 'cte', 'mdfe']; foreach ($aApp as $app) { $procXML = str_replace( 'xmlns="http://www.portalfiscal.inf.br/' . $app . '" xmlns="http://www.w3.org/2000/09/xmldsig#"', 'xmlns="http://www.portalfiscal.inf.br/' . $app . '"', $procXML ); } return $procXML; }
php
public static function clearProt($procXML = '') { $procXML = self::clearMsg($procXML); $aApp = ['nfe', 'cte', 'mdfe']; foreach ($aApp as $app) { $procXML = str_replace( 'xmlns="http://www.portalfiscal.inf.br/' . $app . '" xmlns="http://www.w3.org/2000/09/xmldsig#"', 'xmlns="http://www.portalfiscal.inf.br/' . $app . '"', $procXML ); } return $procXML; }
[ "public", "static", "function", "clearProt", "(", "$", "procXML", "=", "''", ")", "{", "$", "procXML", "=", "self", "::", "clearMsg", "(", "$", "procXML", ")", ";", "$", "aApp", "=", "[", "'nfe'", ",", "'cte'", ",", "'mdfe'", "]", ";", "foreach", "(", "$", "aApp", "as", "$", "app", ")", "{", "$", "procXML", "=", "str_replace", "(", "'xmlns=\"http://www.portalfiscal.inf.br/'", ".", "$", "app", ".", "'\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\"'", ",", "'xmlns=\"http://www.portalfiscal.inf.br/'", ".", "$", "app", ".", "'\"'", ",", "$", "procXML", ")", ";", "}", "return", "$", "procXML", ";", "}" ]
clearProt Limpa o xml após adição do protocolo. @param string $procXML @return string
[ "clearProt", "Limpa", "o", "xml", "após", "adição", "do", "protocolo", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Strings.php#L68-L81
phpnfe/tools
src/Strings.php
Strings.clearMsg
public static function clearMsg($msg) { $nmsg = str_replace([' standalone="no"', 'default:', ':default', "\n", "\r", "\t"], '', $msg); $nnmsg = str_replace('> ', '>', $nmsg); if (strpos($nnmsg, '> ')) { $nnmsg = self::clearMsg((string) $nnmsg); } return $nnmsg; }
php
public static function clearMsg($msg) { $nmsg = str_replace([' standalone="no"', 'default:', ':default', "\n", "\r", "\t"], '', $msg); $nnmsg = str_replace('> ', '>', $nmsg); if (strpos($nnmsg, '> ')) { $nnmsg = self::clearMsg((string) $nnmsg); } return $nnmsg; }
[ "public", "static", "function", "clearMsg", "(", "$", "msg", ")", "{", "$", "nmsg", "=", "str_replace", "(", "[", "' standalone=\"no\"'", ",", "'default:'", ",", "':default'", ",", "\"\\n\"", ",", "\"\\r\"", ",", "\"\\t\"", "]", ",", "''", ",", "$", "msg", ")", ";", "$", "nnmsg", "=", "str_replace", "(", "'> '", ",", "'>'", ",", "$", "nmsg", ")", ";", "if", "(", "strpos", "(", "$", "nnmsg", ",", "'> '", ")", ")", "{", "$", "nnmsg", "=", "self", "::", "clearMsg", "(", "(", "string", ")", "$", "nnmsg", ")", ";", "}", "return", "$", "nnmsg", ";", "}" ]
clearMsg. @param string $msg @return string
[ "clearMsg", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Strings.php#L88-L97