id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
236,000
jakecleary/ultrapress-library
src/Ultra/Helpers/PostObject.php
PostObject.imageSizes
public static function imageSizes($size = false) { global $_wp_additional_image_sizes; $additionalSizes = $_wp_additional_image_sizes; $sizes = []; $imageSizes = get_intermediate_image_sizes(); foreach($imageSizes as $imageSize) { if(in_array($imageSize, ['thumbnail', 'medium', 'large'])) { $sizes[$imageSize] = (object) [ 'name' => $imageSize, 'width' => get_option($imageSize . '_size_w'), 'height' => get_option($imageSize . '_size_h'), 'crop' => (bool) get_option($imageSize . '_crop') ]; } elseif(isset($additionalSizes[$imageSize])) { $sizes[$imageSize] = (object) [ 'name' => $imageSize, 'width' => $additionalSizes[$imageSize]['width'], 'height' => $additionalSizes[$imageSize]['height'], 'crop' => $additionalSizes[$imageSize]['crop'] ]; } } if($size) { if(isset($sizes[$size])) { return $sizes[$size]; } else { return false; } } return $sizes; }
php
public static function imageSizes($size = false) { global $_wp_additional_image_sizes; $additionalSizes = $_wp_additional_image_sizes; $sizes = []; $imageSizes = get_intermediate_image_sizes(); foreach($imageSizes as $imageSize) { if(in_array($imageSize, ['thumbnail', 'medium', 'large'])) { $sizes[$imageSize] = (object) [ 'name' => $imageSize, 'width' => get_option($imageSize . '_size_w'), 'height' => get_option($imageSize . '_size_h'), 'crop' => (bool) get_option($imageSize . '_crop') ]; } elseif(isset($additionalSizes[$imageSize])) { $sizes[$imageSize] = (object) [ 'name' => $imageSize, 'width' => $additionalSizes[$imageSize]['width'], 'height' => $additionalSizes[$imageSize]['height'], 'crop' => $additionalSizes[$imageSize]['crop'] ]; } } if($size) { if(isset($sizes[$size])) { return $sizes[$size]; } else { return false; } } return $sizes; }
[ "public", "static", "function", "imageSizes", "(", "$", "size", "=", "false", ")", "{", "global", "$", "_wp_additional_image_sizes", ";", "$", "additionalSizes", "=", "$", "_wp_additional_image_sizes", ";", "$", "sizes", "=", "[", "]", ";", "$", "imageSizes", "=", "get_intermediate_image_sizes", "(", ")", ";", "foreach", "(", "$", "imageSizes", "as", "$", "imageSize", ")", "{", "if", "(", "in_array", "(", "$", "imageSize", ",", "[", "'thumbnail'", ",", "'medium'", ",", "'large'", "]", ")", ")", "{", "$", "sizes", "[", "$", "imageSize", "]", "=", "(", "object", ")", "[", "'name'", "=>", "$", "imageSize", ",", "'width'", "=>", "get_option", "(", "$", "imageSize", ".", "'_size_w'", ")", ",", "'height'", "=>", "get_option", "(", "$", "imageSize", ".", "'_size_h'", ")", ",", "'crop'", "=>", "(", "bool", ")", "get_option", "(", "$", "imageSize", ".", "'_crop'", ")", "]", ";", "}", "elseif", "(", "isset", "(", "$", "additionalSizes", "[", "$", "imageSize", "]", ")", ")", "{", "$", "sizes", "[", "$", "imageSize", "]", "=", "(", "object", ")", "[", "'name'", "=>", "$", "imageSize", ",", "'width'", "=>", "$", "additionalSizes", "[", "$", "imageSize", "]", "[", "'width'", "]", ",", "'height'", "=>", "$", "additionalSizes", "[", "$", "imageSize", "]", "[", "'height'", "]", ",", "'crop'", "=>", "$", "additionalSizes", "[", "$", "imageSize", "]", "[", "'crop'", "]", "]", ";", "}", "}", "if", "(", "$", "size", ")", "{", "if", "(", "isset", "(", "$", "sizes", "[", "$", "size", "]", ")", ")", "{", "return", "$", "sizes", "[", "$", "size", "]", ";", "}", "else", "{", "return", "false", ";", "}", "}", "return", "$", "sizes", ";", "}" ]
Create an array of all image sizes and their meta data. @param string $size Optionally return a specific image size only
[ "Create", "an", "array", "of", "all", "image", "sizes", "and", "their", "meta", "data", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Helpers/PostObject.php#L63-L106
236,001
jakecleary/ultrapress-library
src/Ultra/Helpers/PostObject.php
PostObject.images
public static function images($id) { $sizes = self::imageSizes(); $urls = []; if(has_post_thumbnail($id)) { $image = wp_get_attachment_image_src( get_post_thumbnail_id($id), 'full' ); $image = pathinfo($image[0]); $extension = $image['extension']; $image = $image['dirname'] . '/' . $image['filename']; $urls['full'] = $image . '.' . $extension; foreach($sizes as $size) { $urls[Data::spaceToCamelCase($size->name, '-')] = $image . '-' . $size->width . 'x' . $size->height . '.' . $extension; } return (object) $urls; } else { return false; } }
php
public static function images($id) { $sizes = self::imageSizes(); $urls = []; if(has_post_thumbnail($id)) { $image = wp_get_attachment_image_src( get_post_thumbnail_id($id), 'full' ); $image = pathinfo($image[0]); $extension = $image['extension']; $image = $image['dirname'] . '/' . $image['filename']; $urls['full'] = $image . '.' . $extension; foreach($sizes as $size) { $urls[Data::spaceToCamelCase($size->name, '-')] = $image . '-' . $size->width . 'x' . $size->height . '.' . $extension; } return (object) $urls; } else { return false; } }
[ "public", "static", "function", "images", "(", "$", "id", ")", "{", "$", "sizes", "=", "self", "::", "imageSizes", "(", ")", ";", "$", "urls", "=", "[", "]", ";", "if", "(", "has_post_thumbnail", "(", "$", "id", ")", ")", "{", "$", "image", "=", "wp_get_attachment_image_src", "(", "get_post_thumbnail_id", "(", "$", "id", ")", ",", "'full'", ")", ";", "$", "image", "=", "pathinfo", "(", "$", "image", "[", "0", "]", ")", ";", "$", "extension", "=", "$", "image", "[", "'extension'", "]", ";", "$", "image", "=", "$", "image", "[", "'dirname'", "]", ".", "'/'", ".", "$", "image", "[", "'filename'", "]", ";", "$", "urls", "[", "'full'", "]", "=", "$", "image", ".", "'.'", ".", "$", "extension", ";", "foreach", "(", "$", "sizes", "as", "$", "size", ")", "{", "$", "urls", "[", "Data", "::", "spaceToCamelCase", "(", "$", "size", "->", "name", ",", "'-'", ")", "]", "=", "$", "image", ".", "'-'", ".", "$", "size", "->", "width", ".", "'x'", ".", "$", "size", "->", "height", ".", "'.'", ".", "$", "extension", ";", "}", "return", "(", "object", ")", "$", "urls", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Create an object casted array of the featured image in all sizes. @param integer $id The post objects ID @return object|boolean The object casted array or false
[ "Create", "an", "object", "casted", "array", "of", "the", "featured", "image", "in", "all", "sizes", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Helpers/PostObject.php#L114-L142
236,002
vitodtagliente/pure-orm
SchemaPropertyDescriptor.php
SchemaPropertyDescriptor.getQueryStatements
public function getQueryStatements($table){ // field declaration $query = array(); array_push($query, $this->name . ' ' . $this->type); if($this->nullable == false) array_push($query, ' NOT NULL'); else array_push($query, ' NULL'); if(isset($this->default_value)){ $value = $this->default_value; if($this->type == 'BOOL') $value = ($this->default_value)?1:0; array_push($query, " DEFAULT '$value'"); } if($this->auto_increments && $this->type == 'INT') array_push($query, ' AUTO_INCREMENT'); // constraints if($this->primary) array_push($query, ",\n\t" . 'CONSTRAINT PK_' . $this->name . ' PRIMARY KEY (' . $this->name . ')'); if($this->unique) array_push($query, ",\n\t" . 'CONSTRAINT UC_' . $this->name . ' UNIQUE KEY (' . $this->name . ')'); if($this->foreign) array_push($query, ",\n\tCONSTRAINT FK_$table" . $this->foreign_class . '_' . $this->name . ' FOREIGN KEY (' . $this->name . ") REFERENCES " . $this->foreign_class . " (" . $this->foreign_property . ')'); return implode($query); }
php
public function getQueryStatements($table){ // field declaration $query = array(); array_push($query, $this->name . ' ' . $this->type); if($this->nullable == false) array_push($query, ' NOT NULL'); else array_push($query, ' NULL'); if(isset($this->default_value)){ $value = $this->default_value; if($this->type == 'BOOL') $value = ($this->default_value)?1:0; array_push($query, " DEFAULT '$value'"); } if($this->auto_increments && $this->type == 'INT') array_push($query, ' AUTO_INCREMENT'); // constraints if($this->primary) array_push($query, ",\n\t" . 'CONSTRAINT PK_' . $this->name . ' PRIMARY KEY (' . $this->name . ')'); if($this->unique) array_push($query, ",\n\t" . 'CONSTRAINT UC_' . $this->name . ' UNIQUE KEY (' . $this->name . ')'); if($this->foreign) array_push($query, ",\n\tCONSTRAINT FK_$table" . $this->foreign_class . '_' . $this->name . ' FOREIGN KEY (' . $this->name . ") REFERENCES " . $this->foreign_class . " (" . $this->foreign_property . ')'); return implode($query); }
[ "public", "function", "getQueryStatements", "(", "$", "table", ")", "{", "// field declaration", "$", "query", "=", "array", "(", ")", ";", "array_push", "(", "$", "query", ",", "$", "this", "->", "name", ".", "' '", ".", "$", "this", "->", "type", ")", ";", "if", "(", "$", "this", "->", "nullable", "==", "false", ")", "array_push", "(", "$", "query", ",", "' NOT NULL'", ")", ";", "else", "array_push", "(", "$", "query", ",", "' NULL'", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "default_value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "default_value", ";", "if", "(", "$", "this", "->", "type", "==", "'BOOL'", ")", "$", "value", "=", "(", "$", "this", "->", "default_value", ")", "?", "1", ":", "0", ";", "array_push", "(", "$", "query", ",", "\" DEFAULT '$value'\"", ")", ";", "}", "if", "(", "$", "this", "->", "auto_increments", "&&", "$", "this", "->", "type", "==", "'INT'", ")", "array_push", "(", "$", "query", ",", "' AUTO_INCREMENT'", ")", ";", "// constraints", "if", "(", "$", "this", "->", "primary", ")", "array_push", "(", "$", "query", ",", "\",\\n\\t\"", ".", "'CONSTRAINT PK_'", ".", "$", "this", "->", "name", ".", "' PRIMARY KEY ('", ".", "$", "this", "->", "name", ".", "')'", ")", ";", "if", "(", "$", "this", "->", "unique", ")", "array_push", "(", "$", "query", ",", "\",\\n\\t\"", ".", "'CONSTRAINT UC_'", ".", "$", "this", "->", "name", ".", "' UNIQUE KEY ('", ".", "$", "this", "->", "name", ".", "')'", ")", ";", "if", "(", "$", "this", "->", "foreign", ")", "array_push", "(", "$", "query", ",", "\",\\n\\tCONSTRAINT FK_$table\"", ".", "$", "this", "->", "foreign_class", ".", "'_'", ".", "$", "this", "->", "name", ".", "' FOREIGN KEY ('", ".", "$", "this", "->", "name", ".", "\") REFERENCES \"", ".", "$", "this", "->", "foreign_class", ".", "\" (\"", ".", "$", "this", "->", "foreign_property", ".", "')'", ")", ";", "return", "implode", "(", "$", "query", ")", ";", "}" ]
query statement generation
[ "query", "statement", "generation" ]
04d80106430f45f82f922cc9da25de3d278dbb94
https://github.com/vitodtagliente/pure-orm/blob/04d80106430f45f82f922cc9da25de3d278dbb94/SchemaPropertyDescriptor.php#L68-L93
236,003
jaimeeee/laravelpanel
src/LaravelPanel/fields/date/DateField.php
DateField.footer
public static function footer() { $code = '<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>'.chr(10); if (App::getLocale() != 'en') { $code .= ' <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.'.App::getLocale().'.min.js"></script>'.chr(10); } $code .= ' <script> $(\'input.date-field\').datepicker({ autoclose: true, format: \''.self::$format.'\', language: \''.App::getLocale().'\', todayHighlight: true }); </script>'; return $code; }
php
public static function footer() { $code = '<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>'.chr(10); if (App::getLocale() != 'en') { $code .= ' <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.'.App::getLocale().'.min.js"></script>'.chr(10); } $code .= ' <script> $(\'input.date-field\').datepicker({ autoclose: true, format: \''.self::$format.'\', language: \''.App::getLocale().'\', todayHighlight: true }); </script>'; return $code; }
[ "public", "static", "function", "footer", "(", ")", "{", "$", "code", "=", "'<script src=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js\"></script>'", ".", "chr", "(", "10", ")", ";", "if", "(", "App", "::", "getLocale", "(", ")", "!=", "'en'", ")", "{", "$", "code", ".=", "' <script src=\"https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.'", ".", "App", "::", "getLocale", "(", ")", ".", "'.min.js\"></script>'", ".", "chr", "(", "10", ")", ";", "}", "$", "code", ".=", "' <script>\n $(\\'input.date-field\\').datepicker({\n autoclose: true,\n format: \\''", ".", "self", "::", "$", "format", ".", "'\\',\n language: \\''", ".", "App", "::", "getLocale", "(", ")", ".", "'\\',\n todayHighlight: true\n });\n </script>'", ";", "return", "$", "code", ";", "}" ]
Add stuff to the footer. @return string
[ "Add", "stuff", "to", "the", "footer", "." ]
211599ba0be7dc5ea11af292a75d4104c41512ca
https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/fields/date/DateField.php#L50-L68
236,004
calgamo/di
src/Slot.php
Slot.mustBeTypeOf
public function mustBeTypeOf(string $type) : Slot { static $allowed_types = [ 'boolean', 'bool', 'integer', 'int', 'float', 'double', 'string', 'array', 'object', 'resource', 'NULL', 'null', ]; $this->type = in_array($type,$allowed_types) ? $type : self::TYPE_ANY; return $this; }
php
public function mustBeTypeOf(string $type) : Slot { static $allowed_types = [ 'boolean', 'bool', 'integer', 'int', 'float', 'double', 'string', 'array', 'object', 'resource', 'NULL', 'null', ]; $this->type = in_array($type,$allowed_types) ? $type : self::TYPE_ANY; return $this; }
[ "public", "function", "mustBeTypeOf", "(", "string", "$", "type", ")", ":", "Slot", "{", "static", "$", "allowed_types", "=", "[", "'boolean'", ",", "'bool'", ",", "'integer'", ",", "'int'", ",", "'float'", ",", "'double'", ",", "'string'", ",", "'array'", ",", "'object'", ",", "'resource'", ",", "'NULL'", ",", "'null'", ",", "]", ";", "$", "this", "->", "type", "=", "in_array", "(", "$", "type", ",", "$", "allowed_types", ")", "?", "$", "type", ":", "self", "::", "TYPE_ANY", ";", "return", "$", "this", ";", "}" ]
Set type restriction @param string $type @return Slot
[ "Set", "type", "restriction" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Slot.php#L111-L129
236,005
calgamo/di
src/Slot.php
Slot.mustBeInstanceOf
public function mustBeInstanceOf(string $instanceOf) : Slot { $this->instanceOf = class_exists($instanceOf) || interface_exists($instanceOf) ? $instanceOf : self::INSTANCE_OF_ANY; return $this; }
php
public function mustBeInstanceOf(string $instanceOf) : Slot { $this->instanceOf = class_exists($instanceOf) || interface_exists($instanceOf) ? $instanceOf : self::INSTANCE_OF_ANY; return $this; }
[ "public", "function", "mustBeInstanceOf", "(", "string", "$", "instanceOf", ")", ":", "Slot", "{", "$", "this", "->", "instanceOf", "=", "class_exists", "(", "$", "instanceOf", ")", "||", "interface_exists", "(", "$", "instanceOf", ")", "?", "$", "instanceOf", ":", "self", "::", "INSTANCE_OF_ANY", ";", "return", "$", "this", ";", "}" ]
Set instance-of restriction @param string $instanceOf @return Slot
[ "Set", "instance", "-", "of", "restriction" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Slot.php#L192-L196
236,006
jivoo/core
src/EventSubjectTrait.php
EventSubjectTrait.triggerEvent
public function triggerEvent($name, Event $event = null) { return $this->e->trigger($name, $event); }
php
public function triggerEvent($name, Event $event = null) { return $this->e->trigger($name, $event); }
[ "public", "function", "triggerEvent", "(", "$", "name", ",", "Event", "$", "event", "=", "null", ")", "{", "return", "$", "this", "->", "e", "->", "trigger", "(", "$", "name", ",", "$", "event", ")", ";", "}" ]
Trigger an event on this object. @param string $name Name of event. @param Event $event Event object. @return bool False if event was stopped, true otherwise.
[ "Trigger", "an", "event", "on", "this", "object", "." ]
4ef3445068f0ff9c0a6512cb741831a847013b76
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/EventSubjectTrait.php#L113-L116
236,007
irs/magento-initializer
src/Irs/MagentoInitializer/Initializer/GenericInitializer.php
GenericInitializer.initialize
public function initialize() { if (!file_exists($this->paramsPathname)) { throw new \InvalidArgumentException("Invalid Magento root '$this->magentoRoot'."); } $params = $this->getParams(); $params['code'] = $this->store; $params['type'] = $this->scope; $this->saveParams($params); }
php
public function initialize() { if (!file_exists($this->paramsPathname)) { throw new \InvalidArgumentException("Invalid Magento root '$this->magentoRoot'."); } $params = $this->getParams(); $params['code'] = $this->store; $params['type'] = $this->scope; $this->saveParams($params); }
[ "public", "function", "initialize", "(", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "paramsPathname", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid Magento root '$this->magentoRoot'.\"", ")", ";", "}", "$", "params", "=", "$", "this", "->", "getParams", "(", ")", ";", "$", "params", "[", "'code'", "]", "=", "$", "this", "->", "store", ";", "$", "params", "[", "'type'", "]", "=", "$", "this", "->", "scope", ";", "$", "this", "->", "saveParams", "(", "$", "params", ")", ";", "}" ]
Sets store and scope code into index.php generated by GenericInstaller @see \Irs\MagentoInitializer\Initializer\InitializerInterface::initialize()
[ "Sets", "store", "and", "scope", "code", "into", "index", ".", "php", "generated", "by", "GenericInstaller" ]
a5583ab01759f320717547a79c7dae2121588a14
https://github.com/irs/magento-initializer/blob/a5583ab01759f320717547a79c7dae2121588a14/src/Irs/MagentoInitializer/Initializer/GenericInitializer.php#L46-L56
236,008
onesimus-systems/oslogger
src/Adaptors/ChromeLoggerAdaptor.php
ChromeLoggerAdaptor.write
public function write($level, $message, array $context = array()) { if ($this->overflowed){ return; } $backtraceLine = ''; if ($this->logBacktrace) { $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 3); $backtrace = array_pop($backtrace); $backtraceLine = "{$backtrace['file']} : {$backtrace['line']}"; } if (in_array($backtraceLine, $this->backtraces)) { $backtraceLine = ''; } else { $this->backtraces []= $backtraceLine; } $this->json['rows'] []= array( $this->format('', $message, array('__context'=>$context)), $backtraceLine, $this->logLevelMappings[$level] ); $this->setLastLogLine($message); $this->send(); }
php
public function write($level, $message, array $context = array()) { if ($this->overflowed){ return; } $backtraceLine = ''; if ($this->logBacktrace) { $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 3); $backtrace = array_pop($backtrace); $backtraceLine = "{$backtrace['file']} : {$backtrace['line']}"; } if (in_array($backtraceLine, $this->backtraces)) { $backtraceLine = ''; } else { $this->backtraces []= $backtraceLine; } $this->json['rows'] []= array( $this->format('', $message, array('__context'=>$context)), $backtraceLine, $this->logLevelMappings[$level] ); $this->setLastLogLine($message); $this->send(); }
[ "public", "function", "write", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "overflowed", ")", "{", "return", ";", "}", "$", "backtraceLine", "=", "''", ";", "if", "(", "$", "this", "->", "logBacktrace", ")", "{", "$", "backtrace", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_PROVIDE_OBJECT", ",", "3", ")", ";", "$", "backtrace", "=", "array_pop", "(", "$", "backtrace", ")", ";", "$", "backtraceLine", "=", "\"{$backtrace['file']} : {$backtrace['line']}\"", ";", "}", "if", "(", "in_array", "(", "$", "backtraceLine", ",", "$", "this", "->", "backtraces", ")", ")", "{", "$", "backtraceLine", "=", "''", ";", "}", "else", "{", "$", "this", "->", "backtraces", "[", "]", "=", "$", "backtraceLine", ";", "}", "$", "this", "->", "json", "[", "'rows'", "]", "[", "]", "=", "array", "(", "$", "this", "->", "format", "(", "''", ",", "$", "message", ",", "array", "(", "'__context'", "=>", "$", "context", ")", ")", ",", "$", "backtraceLine", ",", "$", "this", "->", "logLevelMappings", "[", "$", "level", "]", ")", ";", "$", "this", "->", "setLastLogLine", "(", "$", "message", ")", ";", "$", "this", "->", "send", "(", ")", ";", "}" ]
Write logs to the void @param mixed $level @param string $message @param array $context @return null
[ "Write", "logs", "to", "the", "void" ]
98138d4fbcae83b9cedac13ab173a3f8273de3e0
https://github.com/onesimus-systems/oslogger/blob/98138d4fbcae83b9cedac13ab173a3f8273de3e0/src/Adaptors/ChromeLoggerAdaptor.php#L75-L102
236,009
onesimus-systems/oslogger
src/Adaptors/ChromeLoggerAdaptor.php
ChromeLoggerAdaptor.send
protected function send() { if (!$this->initialized) { $this->initialized = true; $this->sendHeader = $this->headersAccepted(); if (!$this->sendHeader) { return; } } $jsonEncoded = json_encode($this->json); $jsonEncoded = str_replace("\n", '', $jsonEncoded); $encoded = base64_encode(utf8_encode($jsonEncoded)); // Note it's 240KB to leave room for an error message if (strlen($encoded) > 240*1024) { $this->overflowed = true; $this->json['rows'][count($this->json['rows']) - 1] = array( 'Logs truncated, exceeded Chrome header size limit', '', '' ); $jsonEncoded = json_encode($this->json); $jsonEncoded = str_replace("\n", '', $jsonEncoded); $encoded = base64_encode(utf8_encode($jsonEncoded)); } $this->sendHeader($encoded); }
php
protected function send() { if (!$this->initialized) { $this->initialized = true; $this->sendHeader = $this->headersAccepted(); if (!$this->sendHeader) { return; } } $jsonEncoded = json_encode($this->json); $jsonEncoded = str_replace("\n", '', $jsonEncoded); $encoded = base64_encode(utf8_encode($jsonEncoded)); // Note it's 240KB to leave room for an error message if (strlen($encoded) > 240*1024) { $this->overflowed = true; $this->json['rows'][count($this->json['rows']) - 1] = array( 'Logs truncated, exceeded Chrome header size limit', '', '' ); $jsonEncoded = json_encode($this->json); $jsonEncoded = str_replace("\n", '', $jsonEncoded); $encoded = base64_encode(utf8_encode($jsonEncoded)); } $this->sendHeader($encoded); }
[ "protected", "function", "send", "(", ")", "{", "if", "(", "!", "$", "this", "->", "initialized", ")", "{", "$", "this", "->", "initialized", "=", "true", ";", "$", "this", "->", "sendHeader", "=", "$", "this", "->", "headersAccepted", "(", ")", ";", "if", "(", "!", "$", "this", "->", "sendHeader", ")", "{", "return", ";", "}", "}", "$", "jsonEncoded", "=", "json_encode", "(", "$", "this", "->", "json", ")", ";", "$", "jsonEncoded", "=", "str_replace", "(", "\"\\n\"", ",", "''", ",", "$", "jsonEncoded", ")", ";", "$", "encoded", "=", "base64_encode", "(", "utf8_encode", "(", "$", "jsonEncoded", ")", ")", ";", "// Note it's 240KB to leave room for an error message", "if", "(", "strlen", "(", "$", "encoded", ")", ">", "240", "*", "1024", ")", "{", "$", "this", "->", "overflowed", "=", "true", ";", "$", "this", "->", "json", "[", "'rows'", "]", "[", "count", "(", "$", "this", "->", "json", "[", "'rows'", "]", ")", "-", "1", "]", "=", "array", "(", "'Logs truncated, exceeded Chrome header size limit'", ",", "''", ",", "''", ")", ";", "$", "jsonEncoded", "=", "json_encode", "(", "$", "this", "->", "json", ")", ";", "$", "jsonEncoded", "=", "str_replace", "(", "\"\\n\"", ",", "''", ",", "$", "jsonEncoded", ")", ";", "$", "encoded", "=", "base64_encode", "(", "utf8_encode", "(", "$", "jsonEncoded", ")", ")", ";", "}", "$", "this", "->", "sendHeader", "(", "$", "encoded", ")", ";", "}" ]
Prepare to send header
[ "Prepare", "to", "send", "header" ]
98138d4fbcae83b9cedac13ab173a3f8273de3e0
https://github.com/onesimus-systems/oslogger/blob/98138d4fbcae83b9cedac13ab173a3f8273de3e0/src/Adaptors/ChromeLoggerAdaptor.php#L112-L143
236,010
nirvana-msu/yii2-helpers
MathHelper.php
MathHelper.histogram
public static function histogram($values, $edges) { $bins = []; foreach ($edges as $key => $val) { if (!isset($edges[$key + 1])) break; $bins[] = $val . '-' . ($edges[$key + 1]); } $histogram = array_fill_keys($bins, []); foreach ($values as $value) { $i = MathHelper::binary_search($edges, $value); if ($i == -1) { $message = "Value $value is outside of specified edges array: " . print_r($edges, true) . "\n"; throw new \Exception($message); } $key = $bins[$i]; $histogram[$key][] = $value; } return $histogram; }
php
public static function histogram($values, $edges) { $bins = []; foreach ($edges as $key => $val) { if (!isset($edges[$key + 1])) break; $bins[] = $val . '-' . ($edges[$key + 1]); } $histogram = array_fill_keys($bins, []); foreach ($values as $value) { $i = MathHelper::binary_search($edges, $value); if ($i == -1) { $message = "Value $value is outside of specified edges array: " . print_r($edges, true) . "\n"; throw new \Exception($message); } $key = $bins[$i]; $histogram[$key][] = $value; } return $histogram; }
[ "public", "static", "function", "histogram", "(", "$", "values", ",", "$", "edges", ")", "{", "$", "bins", "=", "[", "]", ";", "foreach", "(", "$", "edges", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "isset", "(", "$", "edges", "[", "$", "key", "+", "1", "]", ")", ")", "break", ";", "$", "bins", "[", "]", "=", "$", "val", ".", "'-'", ".", "(", "$", "edges", "[", "$", "key", "+", "1", "]", ")", ";", "}", "$", "histogram", "=", "array_fill_keys", "(", "$", "bins", ",", "[", "]", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "i", "=", "MathHelper", "::", "binary_search", "(", "$", "edges", ",", "$", "value", ")", ";", "if", "(", "$", "i", "==", "-", "1", ")", "{", "$", "message", "=", "\"Value $value is outside of specified edges array: \"", ".", "print_r", "(", "$", "edges", ",", "true", ")", ".", "\"\\n\"", ";", "throw", "new", "\\", "Exception", "(", "$", "message", ")", ";", "}", "$", "key", "=", "$", "bins", "[", "$", "i", "]", ";", "$", "histogram", "[", "$", "key", "]", "[", "]", "=", "$", "value", ";", "}", "return", "$", "histogram", ";", "}" ]
Creates a histogram with specified bins out of a given array @param array $values , e.g. [11, 12, 20, 25, 20.1, 33.5] @param array $edges , e.g. [0, 10, 20, 30, 40] @throws \Exception @return array histogram, e.g. ['0-10' => [], '10-20' => [11,12], '20-30' => [20,25,20.1], '30-40' => [33.5]]
[ "Creates", "a", "histogram", "with", "specified", "bins", "out", "of", "a", "given", "array" ]
1aeecfe8c47211440bab1aa30b65cc205f0ea9ba
https://github.com/nirvana-msu/yii2-helpers/blob/1aeecfe8c47211440bab1aa30b65cc205f0ea9ba/MathHelper.php#L26-L45
236,011
konservs/brilliant.framework
libraries/Modules/BSoftModules.php
BSoftModules.getmodulescounts_forgroups
public function getmodulescounts_forgroups($groupids){ if(!$db=BFactory::getDBO()){ return array(); } $qr='select count(pageid)as cnt,pageid from soft_modules_rules '; $qr.=' where pageid in ('.implode(',',$groupids).')'; $qr.='group by pageid'; $q=$db->Query($qr); $counts=array(); while($l=$db->fetch($q)){ $counts[$l['pageid']]=$l['cnt']; } return $counts; }
php
public function getmodulescounts_forgroups($groupids){ if(!$db=BFactory::getDBO()){ return array(); } $qr='select count(pageid)as cnt,pageid from soft_modules_rules '; $qr.=' where pageid in ('.implode(',',$groupids).')'; $qr.='group by pageid'; $q=$db->Query($qr); $counts=array(); while($l=$db->fetch($q)){ $counts[$l['pageid']]=$l['cnt']; } return $counts; }
[ "public", "function", "getmodulescounts_forgroups", "(", "$", "groupids", ")", "{", "if", "(", "!", "$", "db", "=", "BFactory", "::", "getDBO", "(", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "qr", "=", "'select count(pageid)as cnt,pageid from soft_modules_rules '", ";", "$", "qr", ".=", "' where pageid in ('", ".", "implode", "(", "','", ",", "$", "groupids", ")", ".", "')'", ";", "$", "qr", ".=", "'group by pageid'", ";", "$", "q", "=", "$", "db", "->", "Query", "(", "$", "qr", ")", ";", "$", "counts", "=", "array", "(", ")", ";", "while", "(", "$", "l", "=", "$", "db", "->", "fetch", "(", "$", "q", ")", ")", "{", "$", "counts", "[", "$", "l", "[", "'pageid'", "]", "]", "=", "$", "l", "[", "'cnt'", "]", ";", "}", "return", "$", "counts", ";", "}" ]
end of get
[ "end", "of", "get" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Modules/BSoftModules.php#L273-L286
236,012
codebobbly/dvoconnector
Classes/Hooks/RealUrlAutoConfiguration.php
RealUrlAutoConfiguration.addDVOConnectorConfig
public function addDVOConnectorConfig($params) { return array_merge_recursive($params['config'], [ 'postVarSets' => [ '_DEFAULT' => [ 'dvoconnector' => [ [ 'GETvar' => 'tx_dvoconnector_pi1[controller]', 'noMatch' => 'bypass', ], [ 'GETvar' => 'tx_dvoconnector_pi1[aID]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlAssociation::class . '->convert', ], [ 'GETvar' => 'tx_dvoconnector_pi1[action]', 'valueMap' => [ 'veranstaltungen' => 'listEvents', 'meldungen' => 'listAnnouncements', 'funktionaere' => 'listFunctionaries', 'vereinigungen' => 'listAssociations', 'veranstaltungen-suche' => 'filterEvents', 'meldungen-suche' => 'filterAnnouncements', 'funktionaere-suche' => 'filterFunctionaries', 'vereinigungen-suche' => 'filterAssociations', 'funktionaer' => 'detailFunctionary', 'meldung' => 'detailAnnouncement', 'veranstaltung' => 'detailEvent', ], 'noMatch' => 'bypass', ], [ 'GETvar' => 'tx_dvoconnector_pi1[@widget_0][currentPage]', 'noMatch' => 'bypass', ], [ 'GETvar' => 'tx_dvoconnector_pi1[eID]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlEvent::class . '->convert', ], [ 'GETvar' => 'tx_dvoconnector_pi1[anID]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlAnnouncement::class . '->convert', ], [ 'GETvar' => 'tx_dvoconnector_pi1[fID]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlFunctionary::class . '->convert', ], [ 'GETvar' => 'tx_dvoconnector_pi1[filter]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlFilter::class . '->convert', ], ] ] ] ]); }
php
public function addDVOConnectorConfig($params) { return array_merge_recursive($params['config'], [ 'postVarSets' => [ '_DEFAULT' => [ 'dvoconnector' => [ [ 'GETvar' => 'tx_dvoconnector_pi1[controller]', 'noMatch' => 'bypass', ], [ 'GETvar' => 'tx_dvoconnector_pi1[aID]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlAssociation::class . '->convert', ], [ 'GETvar' => 'tx_dvoconnector_pi1[action]', 'valueMap' => [ 'veranstaltungen' => 'listEvents', 'meldungen' => 'listAnnouncements', 'funktionaere' => 'listFunctionaries', 'vereinigungen' => 'listAssociations', 'veranstaltungen-suche' => 'filterEvents', 'meldungen-suche' => 'filterAnnouncements', 'funktionaere-suche' => 'filterFunctionaries', 'vereinigungen-suche' => 'filterAssociations', 'funktionaer' => 'detailFunctionary', 'meldung' => 'detailAnnouncement', 'veranstaltung' => 'detailEvent', ], 'noMatch' => 'bypass', ], [ 'GETvar' => 'tx_dvoconnector_pi1[@widget_0][currentPage]', 'noMatch' => 'bypass', ], [ 'GETvar' => 'tx_dvoconnector_pi1[eID]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlEvent::class . '->convert', ], [ 'GETvar' => 'tx_dvoconnector_pi1[anID]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlAnnouncement::class . '->convert', ], [ 'GETvar' => 'tx_dvoconnector_pi1[fID]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlFunctionary::class . '->convert', ], [ 'GETvar' => 'tx_dvoconnector_pi1[filter]', 'userFunc' => RGU\Dvoconnector\Service\Url\RealUrlFilter::class . '->convert', ], ] ] ] ]); }
[ "public", "function", "addDVOConnectorConfig", "(", "$", "params", ")", "{", "return", "array_merge_recursive", "(", "$", "params", "[", "'config'", "]", ",", "[", "'postVarSets'", "=>", "[", "'_DEFAULT'", "=>", "[", "'dvoconnector'", "=>", "[", "[", "'GETvar'", "=>", "'tx_dvoconnector_pi1[controller]'", ",", "'noMatch'", "=>", "'bypass'", ",", "]", ",", "[", "'GETvar'", "=>", "'tx_dvoconnector_pi1[aID]'", ",", "'userFunc'", "=>", "RGU", "\\", "Dvoconnector", "\\", "Service", "\\", "Url", "\\", "RealUrlAssociation", "::", "class", ".", "'->convert'", ",", "]", ",", "[", "'GETvar'", "=>", "'tx_dvoconnector_pi1[action]'", ",", "'valueMap'", "=>", "[", "'veranstaltungen'", "=>", "'listEvents'", ",", "'meldungen'", "=>", "'listAnnouncements'", ",", "'funktionaere'", "=>", "'listFunctionaries'", ",", "'vereinigungen'", "=>", "'listAssociations'", ",", "'veranstaltungen-suche'", "=>", "'filterEvents'", ",", "'meldungen-suche'", "=>", "'filterAnnouncements'", ",", "'funktionaere-suche'", "=>", "'filterFunctionaries'", ",", "'vereinigungen-suche'", "=>", "'filterAssociations'", ",", "'funktionaer'", "=>", "'detailFunctionary'", ",", "'meldung'", "=>", "'detailAnnouncement'", ",", "'veranstaltung'", "=>", "'detailEvent'", ",", "]", ",", "'noMatch'", "=>", "'bypass'", ",", "]", ",", "[", "'GETvar'", "=>", "'tx_dvoconnector_pi1[@widget_0][currentPage]'", ",", "'noMatch'", "=>", "'bypass'", ",", "]", ",", "[", "'GETvar'", "=>", "'tx_dvoconnector_pi1[eID]'", ",", "'userFunc'", "=>", "RGU", "\\", "Dvoconnector", "\\", "Service", "\\", "Url", "\\", "RealUrlEvent", "::", "class", ".", "'->convert'", ",", "]", ",", "[", "'GETvar'", "=>", "'tx_dvoconnector_pi1[anID]'", ",", "'userFunc'", "=>", "RGU", "\\", "Dvoconnector", "\\", "Service", "\\", "Url", "\\", "RealUrlAnnouncement", "::", "class", ".", "'->convert'", ",", "]", ",", "[", "'GETvar'", "=>", "'tx_dvoconnector_pi1[fID]'", ",", "'userFunc'", "=>", "RGU", "\\", "Dvoconnector", "\\", "Service", "\\", "Url", "\\", "RealUrlFunctionary", "::", "class", ".", "'->convert'", ",", "]", ",", "[", "'GETvar'", "=>", "'tx_dvoconnector_pi1[filter]'", ",", "'userFunc'", "=>", "RGU", "\\", "Dvoconnector", "\\", "Service", "\\", "Url", "\\", "RealUrlFilter", "::", "class", ".", "'->convert'", ",", "]", ",", "]", "]", "]", "]", ")", ";", "}" ]
Generates additional RealURL configuration and merges it with provided configuration @param array $params Default configuration @return array Updated configuration @hook TYPO3_CONF_VARS|SC_OPTIONS|ext/realurl/class.tx_realurl_autoconfgen.php|extensionConfiguration
[ "Generates", "additional", "RealURL", "configuration", "and", "merges", "it", "with", "provided", "configuration" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Hooks/RealUrlAutoConfiguration.php#L19-L74
236,013
encorephp/development
src/ServiceProvider.php
ServiceProvider.register
public function register() { $this->container['config']->addLocation($this->container->basePath().'/dev/config'); foreach ($this->container['config']->get('app.providers') as $provider) { $this->container->addProvider($provider); } }
php
public function register() { $this->container['config']->addLocation($this->container->basePath().'/dev/config'); foreach ($this->container['config']->get('app.providers') as $provider) { $this->container->addProvider($provider); } }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "container", "[", "'config'", "]", "->", "addLocation", "(", "$", "this", "->", "container", "->", "basePath", "(", ")", ".", "'/dev/config'", ")", ";", "foreach", "(", "$", "this", "->", "container", "[", "'config'", "]", "->", "get", "(", "'app.providers'", ")", "as", "$", "provider", ")", "{", "$", "this", "->", "container", "->", "addProvider", "(", "$", "provider", ")", ";", "}", "}" ]
Register the dev config directory and register providers. @return void
[ "Register", "the", "dev", "config", "directory", "and", "register", "providers", "." ]
734ea31fab803d62b7baeb5ae3a33a0d655833cd
https://github.com/encorephp/development/blob/734ea31fab803d62b7baeb5ae3a33a0d655833cd/src/ServiceProvider.php#L20-L27
236,014
coolms/common
src/Permissions/Acl/AclAwareTrait.php
AclAwareTrait.hasAcl
public function hasAcl() { if ($this->acl instanceof Acl\Acl || static::$defaultAcl instanceof Acl\Acl ) { return true; } return false; }
php
public function hasAcl() { if ($this->acl instanceof Acl\Acl || static::$defaultAcl instanceof Acl\Acl ) { return true; } return false; }
[ "public", "function", "hasAcl", "(", ")", "{", "if", "(", "$", "this", "->", "acl", "instanceof", "Acl", "\\", "Acl", "||", "static", "::", "$", "defaultAcl", "instanceof", "Acl", "\\", "Acl", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if the helper has an ACL instance Implements {@link AclAwareInterface::hasAcl()}. @return bool
[ "Checks", "if", "the", "helper", "has", "an", "ACL", "instance" ]
3572993cdcdb2898cdde396a2f1de9864b193660
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Permissions/Acl/AclAwareTrait.php#L92-L101
236,015
coolms/common
src/Permissions/Acl/AclAwareTrait.php
AclAwareTrait.hasRole
public function hasRole() { if ($this->role instanceof Acl\Role\RoleInterface || is_string($this->role) || static::$defaultRole instanceof Acl\Role\RoleInterface || is_string(static::$defaultRole) ) { return true; } return false; }
php
public function hasRole() { if ($this->role instanceof Acl\Role\RoleInterface || is_string($this->role) || static::$defaultRole instanceof Acl\Role\RoleInterface || is_string(static::$defaultRole) ) { return true; } return false; }
[ "public", "function", "hasRole", "(", ")", "{", "if", "(", "$", "this", "->", "role", "instanceof", "Acl", "\\", "Role", "\\", "RoleInterface", "||", "is_string", "(", "$", "this", "->", "role", ")", "||", "static", "::", "$", "defaultRole", "instanceof", "Acl", "\\", "Role", "\\", "RoleInterface", "||", "is_string", "(", "static", "::", "$", "defaultRole", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if the helper has an ACL role Implements {@link AclAwareInterface::hasRole()}. @return bool
[ "Checks", "if", "the", "helper", "has", "an", "ACL", "role" ]
3572993cdcdb2898cdde396a2f1de9864b193660
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Permissions/Acl/AclAwareTrait.php#L181-L192
236,016
FelixOnline/Core
src/FelixOnline/Core/User.php
User.jsonEncode
public static function jsonEncode($data) { $json = json_encode($data); // if json_encode failed if ($json === false) { self::jsonLastError(); } return $json; }
php
public static function jsonEncode($data) { $json = json_encode($data); // if json_encode failed if ($json === false) { self::jsonLastError(); } return $json; }
[ "public", "static", "function", "jsonEncode", "(", "$", "data", ")", "{", "$", "json", "=", "json_encode", "(", "$", "data", ")", ";", "// if json_encode failed", "if", "(", "$", "json", "===", "false", ")", "{", "self", "::", "jsonLastError", "(", ")", ";", "}", "return", "$", "json", ";", "}" ]
Encode as JSON and throw error if fails @param mixed $data - data to encode @static @return string - json string @throws \Exception if json decode fails with message about why
[ "Encode", "as", "JSON", "and", "throw", "error", "if", "fails" ]
b29f50cd96cee73da83968ee1eb88d8b3ab1c430
https://github.com/FelixOnline/Core/blob/b29f50cd96cee73da83968ee1eb88d8b3ab1c430/src/FelixOnline/Core/User.php#L299-L307
236,017
FelixOnline/Core
src/FelixOnline/Core/User.php
User.updateName
private function updateName() { if (!LOCAL) { $ds = ldap_connect("addressbook.ic.ac.uk"); $r = ldap_bind($ds); $justthese = array("displayname"); $sr = ldap_search( $ds, "ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk", "uid=".$this->getUser(), $justthese ); $info = ldap_get_entries($ds, $sr); if ($info["count"] > 0) { $this->setName($info[0]['displayname'][0]); return ($info[0]['displayname'][0]); } else { return false; } } else { $name = $this->getName(); return $name; } }
php
private function updateName() { if (!LOCAL) { $ds = ldap_connect("addressbook.ic.ac.uk"); $r = ldap_bind($ds); $justthese = array("displayname"); $sr = ldap_search( $ds, "ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk", "uid=".$this->getUser(), $justthese ); $info = ldap_get_entries($ds, $sr); if ($info["count"] > 0) { $this->setName($info[0]['displayname'][0]); return ($info[0]['displayname'][0]); } else { return false; } } else { $name = $this->getName(); return $name; } }
[ "private", "function", "updateName", "(", ")", "{", "if", "(", "!", "LOCAL", ")", "{", "$", "ds", "=", "ldap_connect", "(", "\"addressbook.ic.ac.uk\"", ")", ";", "$", "r", "=", "ldap_bind", "(", "$", "ds", ")", ";", "$", "justthese", "=", "array", "(", "\"displayname\"", ")", ";", "$", "sr", "=", "ldap_search", "(", "$", "ds", ",", "\"ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk\"", ",", "\"uid=\"", ".", "$", "this", "->", "getUser", "(", ")", ",", "$", "justthese", ")", ";", "$", "info", "=", "ldap_get_entries", "(", "$", "ds", ",", "$", "sr", ")", ";", "if", "(", "$", "info", "[", "\"count\"", "]", ">", "0", ")", "{", "$", "this", "->", "setName", "(", "$", "info", "[", "0", "]", "[", "'displayname'", "]", "[", "0", "]", ")", ";", "return", "(", "$", "info", "[", "0", "]", "[", "'displayname'", "]", "[", "0", "]", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "return", "$", "name", ";", "}", "}" ]
Update user's name from ldap
[ "Update", "user", "s", "name", "from", "ldap" ]
b29f50cd96cee73da83968ee1eb88d8b3ab1c430
https://github.com/FelixOnline/Core/blob/b29f50cd96cee73da83968ee1eb88d8b3ab1c430/src/FelixOnline/Core/User.php#L458-L481
236,018
FelixOnline/Core
src/FelixOnline/Core/User.php
User.updateEmail
private function updateEmail() { if (!LOCAL) { $ds = ldap_connect("addressbook.ic.ac.uk"); $r = ldap_bind($ds); $justthese = array("mail"); $sr = ldap_search( $ds, "ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk", "uid=".$this->getUser(), $justthese ); $info = ldap_get_entries($ds, $sr); if ($info["count"] > 0) { $this->setEmail($info[0]['mail'][0]); return ($info[0]['mail'][0]); } else { return false; } } else { $email = $this->getEmail(); return $email; } }
php
private function updateEmail() { if (!LOCAL) { $ds = ldap_connect("addressbook.ic.ac.uk"); $r = ldap_bind($ds); $justthese = array("mail"); $sr = ldap_search( $ds, "ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk", "uid=".$this->getUser(), $justthese ); $info = ldap_get_entries($ds, $sr); if ($info["count"] > 0) { $this->setEmail($info[0]['mail'][0]); return ($info[0]['mail'][0]); } else { return false; } } else { $email = $this->getEmail(); return $email; } }
[ "private", "function", "updateEmail", "(", ")", "{", "if", "(", "!", "LOCAL", ")", "{", "$", "ds", "=", "ldap_connect", "(", "\"addressbook.ic.ac.uk\"", ")", ";", "$", "r", "=", "ldap_bind", "(", "$", "ds", ")", ";", "$", "justthese", "=", "array", "(", "\"mail\"", ")", ";", "$", "sr", "=", "ldap_search", "(", "$", "ds", ",", "\"ou=People,ou=shibboleth,dc=ic,dc=ac,dc=uk\"", ",", "\"uid=\"", ".", "$", "this", "->", "getUser", "(", ")", ",", "$", "justthese", ")", ";", "$", "info", "=", "ldap_get_entries", "(", "$", "ds", ",", "$", "sr", ")", ";", "if", "(", "$", "info", "[", "\"count\"", "]", ">", "0", ")", "{", "$", "this", "->", "setEmail", "(", "$", "info", "[", "0", "]", "[", "'mail'", "]", "[", "0", "]", ")", ";", "return", "(", "$", "info", "[", "0", "]", "[", "'mail'", "]", "[", "0", "]", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "$", "email", "=", "$", "this", "->", "getEmail", "(", ")", ";", "return", "$", "email", ";", "}", "}" ]
Update user's email address from ldap
[ "Update", "user", "s", "email", "address", "from", "ldap" ]
b29f50cd96cee73da83968ee1eb88d8b3ab1c430
https://github.com/FelixOnline/Core/blob/b29f50cd96cee73da83968ee1eb88d8b3ab1c430/src/FelixOnline/Core/User.php#L486-L509
236,019
silverorange/Net_Notifier
Net/Notifier/ServerCLI.php
Net_Notifier_ServerCLI.getUiXml
protected function getUiXml() { $dir = '@data-dir@' . DIRECTORY_SEPARATOR . '@package-name@' . DIRECTORY_SEPARATOR . 'data'; if ($dir[0] == '@') { $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data'; } return $dir . DIRECTORY_SEPARATOR . 'server-cli.xml'; }
php
protected function getUiXml() { $dir = '@data-dir@' . DIRECTORY_SEPARATOR . '@package-name@' . DIRECTORY_SEPARATOR . 'data'; if ($dir[0] == '@') { $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data'; } return $dir . DIRECTORY_SEPARATOR . 'server-cli.xml'; }
[ "protected", "function", "getUiXml", "(", ")", "{", "$", "dir", "=", "'@data-dir@'", ".", "DIRECTORY_SEPARATOR", ".", "'@package-name@'", ".", "DIRECTORY_SEPARATOR", ".", "'data'", ";", "if", "(", "$", "dir", "[", "0", "]", "==", "'@'", ")", "{", "$", "dir", "=", "dirname", "(", "__FILE__", ")", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'data'", ";", "}", "return", "$", "dir", ".", "DIRECTORY_SEPARATOR", ".", "'server-cli.xml'", ";", "}" ]
Gets the XML command line interface definition for this server @return string the XML command line interface definition for this server.
[ "Gets", "the", "XML", "command", "line", "interface", "definition", "for", "this", "server" ]
b446e27cd1bebd58ba89243cde1272c5d281d3fb
https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/ServerCLI.php#L165-L176
236,020
rezzza/jobflow
src/Rezzza/Jobflow/Scheduler/JobGraph.php
JobGraph.move
public function move($value) { // No need to update if $value is already current one if ($value === $this->current()) { return; } $index = $this->search($value); if (false === $index) { throw new \InvalidArgumentException(sprintf('"%s" value not found in JobGraph', $value)); } return $this->seek($index); }
php
public function move($value) { // No need to update if $value is already current one if ($value === $this->current()) { return; } $index = $this->search($value); if (false === $index) { throw new \InvalidArgumentException(sprintf('"%s" value not found in JobGraph', $value)); } return $this->seek($index); }
[ "public", "function", "move", "(", "$", "value", ")", "{", "// No need to update if $value is already current one", "if", "(", "$", "value", "===", "$", "this", "->", "current", "(", ")", ")", "{", "return", ";", "}", "$", "index", "=", "$", "this", "->", "search", "(", "$", "value", ")", ";", "if", "(", "false", "===", "$", "index", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" value not found in JobGraph'", ",", "$", "value", ")", ")", ";", "}", "return", "$", "this", "->", "seek", "(", "$", "index", ")", ";", "}" ]
Moves cursor to the given value. Useful when using asynchronous transport @param string $value
[ "Moves", "cursor", "to", "the", "given", "value", ".", "Useful", "when", "using", "asynchronous", "transport" ]
80ded8ac6ed6a2f4500b8f86e2958701ec84fd65
https://github.com/rezzza/jobflow/blob/80ded8ac6ed6a2f4500b8f86e2958701ec84fd65/src/Rezzza/Jobflow/Scheduler/JobGraph.php#L60-L74
236,021
rezzza/jobflow
src/Rezzza/Jobflow/Scheduler/JobGraph.php
JobGraph.getJob
public function getJob($index) { if ($this->hasNextJob($index)) { return $this->getIterator()->offsetGet($index); } return false; }
php
public function getJob($index) { if ($this->hasNextJob($index)) { return $this->getIterator()->offsetGet($index); } return false; }
[ "public", "function", "getJob", "(", "$", "index", ")", "{", "if", "(", "$", "this", "->", "hasNextJob", "(", "$", "index", ")", ")", "{", "return", "$", "this", "->", "getIterator", "(", ")", "->", "offsetGet", "(", "$", "index", ")", ";", "}", "return", "false", ";", "}" ]
Get name of the job for given index @param string|integer $index @return string
[ "Get", "name", "of", "the", "job", "for", "given", "index" ]
80ded8ac6ed6a2f4500b8f86e2958701ec84fd65
https://github.com/rezzza/jobflow/blob/80ded8ac6ed6a2f4500b8f86e2958701ec84fd65/src/Rezzza/Jobflow/Scheduler/JobGraph.php#L93-L100
236,022
rsmike/fa
dist/FA.php
FA.css
public function css($css) { $css = trim($css); if (substr($css, -1) !== ';') { $css = $css . ';'; } return $this->att(['style' => $css]); }
php
public function css($css) { $css = trim($css); if (substr($css, -1) !== ';') { $css = $css . ';'; } return $this->att(['style' => $css]); }
[ "public", "function", "css", "(", "$", "css", ")", "{", "$", "css", "=", "trim", "(", "$", "css", ")", ";", "if", "(", "substr", "(", "$", "css", ",", "-", "1", ")", "!==", "';'", ")", "{", "$", "css", "=", "$", "css", ".", "';'", ";", "}", "return", "$", "this", "->", "att", "(", "[", "'style'", "=>", "$", "css", "]", ")", ";", "}" ]
Add custom style for the icon Example: echo FA::check('ok')->css('padding-right:20px'); echo FA::check('ok', FA::FA_ROT90&FA::FA_SPIN)->css('padding-right:20px'); @param $css string @return static
[ "Add", "custom", "style", "for", "the", "icon" ]
5c08e836a6871b17ee9f15cb3bf87033b2267922
https://github.com/rsmike/fa/blob/5c08e836a6871b17ee9f15cb3bf87033b2267922/dist/FA.php#L821-L827
236,023
phPoirot/Http
HttpMessage/Request/Plugin/MethodType.php
MethodType.isXmlHttpRequest
function isXmlHttpRequest() { /** @var iHeader $header */ if (! $this->getMessageObject()->headers()->has('X-Requested-With') ) return false; $header = $this->getMessageObject()->headers()->get('X-Requested-With'); return false !== $header && \Poirot\Http\Header\renderHeader($header) == 'XMLHttpRequest'; }
php
function isXmlHttpRequest() { /** @var iHeader $header */ if (! $this->getMessageObject()->headers()->has('X-Requested-With') ) return false; $header = $this->getMessageObject()->headers()->get('X-Requested-With'); return false !== $header && \Poirot\Http\Header\renderHeader($header) == 'XMLHttpRequest'; }
[ "function", "isXmlHttpRequest", "(", ")", "{", "/** @var iHeader $header */", "if", "(", "!", "$", "this", "->", "getMessageObject", "(", ")", "->", "headers", "(", ")", "->", "has", "(", "'X-Requested-With'", ")", ")", "return", "false", ";", "$", "header", "=", "$", "this", "->", "getMessageObject", "(", ")", "->", "headers", "(", ")", "->", "get", "(", "'X-Requested-With'", ")", ";", "return", "false", "!==", "$", "header", "&&", "\\", "Poirot", "\\", "Http", "\\", "Header", "\\", "renderHeader", "(", "$", "header", ")", "==", "'XMLHttpRequest'", ";", "}" ]
Is the request a Javascript XMLHttpRequest? Should work with Prototype/Script.aculo.us, possibly others. @return bool
[ "Is", "the", "request", "a", "Javascript", "XMLHttpRequest?" ]
3230b3555abf0e74c3d593fc49c8978758969736
https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpMessage/Request/Plugin/MethodType.php#L123-L131
236,024
phPoirot/Http
HttpMessage/Request/Plugin/MethodType.php
MethodType.isFlashRequest
function isFlashRequest() { /** @var iHeader $header */ if (! $this->getMessageObject()->headers()->has('User-Agent') ) return false; $header = $this->getMessageObject()->headers()->get('User-Agent'); return false !== $header && stristr(\Poirot\Http\Header\renderHeader($header), ' flash'); }
php
function isFlashRequest() { /** @var iHeader $header */ if (! $this->getMessageObject()->headers()->has('User-Agent') ) return false; $header = $this->getMessageObject()->headers()->get('User-Agent'); return false !== $header && stristr(\Poirot\Http\Header\renderHeader($header), ' flash'); }
[ "function", "isFlashRequest", "(", ")", "{", "/** @var iHeader $header */", "if", "(", "!", "$", "this", "->", "getMessageObject", "(", ")", "->", "headers", "(", ")", "->", "has", "(", "'User-Agent'", ")", ")", "return", "false", ";", "$", "header", "=", "$", "this", "->", "getMessageObject", "(", ")", "->", "headers", "(", ")", "->", "get", "(", "'User-Agent'", ")", ";", "return", "false", "!==", "$", "header", "&&", "stristr", "(", "\\", "Poirot", "\\", "Http", "\\", "Header", "\\", "renderHeader", "(", "$", "header", ")", ",", "' flash'", ")", ";", "}" ]
Is this a Flash request? @return bool
[ "Is", "this", "a", "Flash", "request?" ]
3230b3555abf0e74c3d593fc49c8978758969736
https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpMessage/Request/Plugin/MethodType.php#L138-L146
236,025
acacha/ebre_escool_model
src/Study.php
Study.modules
public function modules() { $courses = $this->courses->pluck('course_id'); return StudyModule::whereHas('modulesByPeriod.courses', function ($query) use ($courses) { $query->whereIn('course_id',$courses); }); }
php
public function modules() { $courses = $this->courses->pluck('course_id'); return StudyModule::whereHas('modulesByPeriod.courses', function ($query) use ($courses) { $query->whereIn('course_id',$courses); }); }
[ "public", "function", "modules", "(", ")", "{", "$", "courses", "=", "$", "this", "->", "courses", "->", "pluck", "(", "'course_id'", ")", ";", "return", "StudyModule", "::", "whereHas", "(", "'modulesByPeriod.courses'", ",", "function", "(", "$", "query", ")", "use", "(", "$", "courses", ")", "{", "$", "query", "->", "whereIn", "(", "'course_id'", ",", "$", "courses", ")", ";", "}", ")", ";", "}" ]
Get the active study modules for this study.
[ "Get", "the", "active", "study", "modules", "for", "this", "study", "." ]
91c0b870714490baa9500215a6dc07935e525a75
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Study.php#L104-L110
236,026
acacha/ebre_escool_model
src/Study.php
Study.modulesActiveOn
public function modulesActiveOn($periodId) { $courses = $this->coursesActiveOn($periodId)->pluck('course_id'); return StudyModule::whereHas('modulesByPeriod.courses', function ($query) use ($courses) { $query->whereIn('course_id',$courses); }); }
php
public function modulesActiveOn($periodId) { $courses = $this->coursesActiveOn($periodId)->pluck('course_id'); return StudyModule::whereHas('modulesByPeriod.courses', function ($query) use ($courses) { $query->whereIn('course_id',$courses); }); }
[ "public", "function", "modulesActiveOn", "(", "$", "periodId", ")", "{", "$", "courses", "=", "$", "this", "->", "coursesActiveOn", "(", "$", "periodId", ")", "->", "pluck", "(", "'course_id'", ")", ";", "return", "StudyModule", "::", "whereHas", "(", "'modulesByPeriod.courses'", ",", "function", "(", "$", "query", ")", "use", "(", "$", "courses", ")", "{", "$", "query", "->", "whereIn", "(", "'course_id'", ",", "$", "courses", ")", ";", "}", ")", ";", "}" ]
Get the active study modules for this study on period id.
[ "Get", "the", "active", "study", "modules", "for", "this", "study", "on", "period", "id", "." ]
91c0b870714490baa9500215a6dc07935e525a75
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Study.php#L116-L122
236,027
monomelodies/ornament
src/Virtual.php
Virtual.__isset
public function __isset($prop) { if (property_exists($this, $prop) && $prop{0} != '_') { return true; } $method = 'get'.ucfirst(Helper::denormalize($prop)); if (method_exists($this, $method)) { return true; } if (method_exists($this, 'callback')) { try { $this->callback($method, null); return true; } catch (Exception\UndefinedCallback $e) { } } return false; }
php
public function __isset($prop) { if (property_exists($this, $prop) && $prop{0} != '_') { return true; } $method = 'get'.ucfirst(Helper::denormalize($prop)); if (method_exists($this, $method)) { return true; } if (method_exists($this, 'callback')) { try { $this->callback($method, null); return true; } catch (Exception\UndefinedCallback $e) { } } return false; }
[ "public", "function", "__isset", "(", "$", "prop", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "prop", ")", "&&", "$", "prop", "{", "0", "}", "!=", "'_'", ")", "{", "return", "true", ";", "}", "$", "method", "=", "'get'", ".", "ucfirst", "(", "Helper", "::", "denormalize", "(", "$", "prop", ")", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "return", "true", ";", "}", "if", "(", "method_exists", "(", "$", "this", ",", "'callback'", ")", ")", "{", "try", "{", "$", "this", "->", "callback", "(", "$", "method", ",", "null", ")", ";", "return", "true", ";", "}", "catch", "(", "Exception", "\\", "UndefinedCallback", "$", "e", ")", "{", "}", "}", "return", "false", ";", "}" ]
Check if a property is defined, but not public or virtual. Note that it will return true if a property _is_ defined, but has a value of null. @param string $prop The property to check. @return boolean True if set, otherwise false.
[ "Check", "if", "a", "property", "is", "defined", "but", "not", "public", "or", "virtual", ".", "Note", "that", "it", "will", "return", "true", "if", "a", "property", "_is_", "defined", "but", "has", "a", "value", "of", "null", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Virtual.php#L84-L101
236,028
marando/phpSOFA
src/Marando/IAU/iauEors.php
iauEors.Eors
public static function Eors(array $rnpb, $s) { $x; $ax; $xs; $ys; $zs; $p; $q; $eo; /* Evaluate Wallace & Capitaine (2006) expression (16). */ $x = $rnpb[2][0]; $ax = $x / (1.0 + $rnpb[2][2]); $xs = 1.0 - $ax * $x; $ys = -$ax * $rnpb[2][1]; $zs = -$x; $p = $rnpb[0][0] * $xs + $rnpb[0][1] * $ys + $rnpb[0][2] * $zs; $q = $rnpb[1][0] * $xs + $rnpb[1][1] * $ys + $rnpb[1][2] * $zs; $eo = (($p != 0) || ($q != 0)) ? $s - atan2($q, $p) : $s; return $eo; }
php
public static function Eors(array $rnpb, $s) { $x; $ax; $xs; $ys; $zs; $p; $q; $eo; /* Evaluate Wallace & Capitaine (2006) expression (16). */ $x = $rnpb[2][0]; $ax = $x / (1.0 + $rnpb[2][2]); $xs = 1.0 - $ax * $x; $ys = -$ax * $rnpb[2][1]; $zs = -$x; $p = $rnpb[0][0] * $xs + $rnpb[0][1] * $ys + $rnpb[0][2] * $zs; $q = $rnpb[1][0] * $xs + $rnpb[1][1] * $ys + $rnpb[1][2] * $zs; $eo = (($p != 0) || ($q != 0)) ? $s - atan2($q, $p) : $s; return $eo; }
[ "public", "static", "function", "Eors", "(", "array", "$", "rnpb", ",", "$", "s", ")", "{", "$", "x", ";", "$", "ax", ";", "$", "xs", ";", "$", "ys", ";", "$", "zs", ";", "$", "p", ";", "$", "q", ";", "$", "eo", ";", "/* Evaluate Wallace & Capitaine (2006) expression (16). */", "$", "x", "=", "$", "rnpb", "[", "2", "]", "[", "0", "]", ";", "$", "ax", "=", "$", "x", "/", "(", "1.0", "+", "$", "rnpb", "[", "2", "]", "[", "2", "]", ")", ";", "$", "xs", "=", "1.0", "-", "$", "ax", "*", "$", "x", ";", "$", "ys", "=", "-", "$", "ax", "*", "$", "rnpb", "[", "2", "]", "[", "1", "]", ";", "$", "zs", "=", "-", "$", "x", ";", "$", "p", "=", "$", "rnpb", "[", "0", "]", "[", "0", "]", "*", "$", "xs", "+", "$", "rnpb", "[", "0", "]", "[", "1", "]", "*", "$", "ys", "+", "$", "rnpb", "[", "0", "]", "[", "2", "]", "*", "$", "zs", ";", "$", "q", "=", "$", "rnpb", "[", "1", "]", "[", "0", "]", "*", "$", "xs", "+", "$", "rnpb", "[", "1", "]", "[", "1", "]", "*", "$", "ys", "+", "$", "rnpb", "[", "1", "]", "[", "2", "]", "*", "$", "zs", ";", "$", "eo", "=", "(", "(", "$", "p", "!=", "0", ")", "||", "(", "$", "q", "!=", "0", ")", ")", "?", "$", "s", "-", "atan2", "(", "$", "q", ",", "$", "p", ")", ":", "$", "s", ";", "return", "$", "eo", ";", "}" ]
- - - - - - - - i a u E o r s - - - - - - - - Equation of the origins, given the classical NPB matrix and the quantity s. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: support function. Given: rnpb double[3][3] classical nutation x precession x bias matrix s double the quantity s (the CIO locator) Returned (function value): double the equation of the origins in radians. Notes: 1) The equation of the origins is the distance between the true equinox and the celestial intermediate origin and, equivalently, the difference between Earth rotation angle and Greenwich apparent sidereal time (ERA-GST). It comprises the precession (since J2000.0) in right ascension plus the equation of the equinoxes (including the small correction terms). 2) The algorithm is from Wallace & Capitaine (2006). References: Capitaine, N. & Wallace, P.T., 2006, Astron.Astrophys. 450, 855 Wallace, P. & Capitaine, N., 2006, Astron.Astrophys. 459, 981 This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "E", "o", "r", "s", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauEors.php#L50-L71
236,029
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/ResourcesController.php
ResourcesController.scriptsAction
public function scriptsAction() { $locator = $this->get('file_locator'); $content = file_get_contents($locator->locate('@PhlexibleUserBundle/Resources/scripts/ChangePasswordWindow.js')). file_get_contents($locator->locate('@PhlexibleUserBundle/Resources/scripts/ValidateWindow.js')). file_get_contents($locator->locate('@PhlexibleUserBundle/Resources/scripts/SetPasswordWindow.js')); return new Response($content, 200, ['Content-Type' => 'text/javascript']); }
php
public function scriptsAction() { $locator = $this->get('file_locator'); $content = file_get_contents($locator->locate('@PhlexibleUserBundle/Resources/scripts/ChangePasswordWindow.js')). file_get_contents($locator->locate('@PhlexibleUserBundle/Resources/scripts/ValidateWindow.js')). file_get_contents($locator->locate('@PhlexibleUserBundle/Resources/scripts/SetPasswordWindow.js')); return new Response($content, 200, ['Content-Type' => 'text/javascript']); }
[ "public", "function", "scriptsAction", "(", ")", "{", "$", "locator", "=", "$", "this", "->", "get", "(", "'file_locator'", ")", ";", "$", "content", "=", "file_get_contents", "(", "$", "locator", "->", "locate", "(", "'@PhlexibleUserBundle/Resources/scripts/ChangePasswordWindow.js'", ")", ")", ".", "file_get_contents", "(", "$", "locator", "->", "locate", "(", "'@PhlexibleUserBundle/Resources/scripts/ValidateWindow.js'", ")", ")", ".", "file_get_contents", "(", "$", "locator", "->", "locate", "(", "'@PhlexibleUserBundle/Resources/scripts/SetPasswordWindow.js'", ")", ")", ";", "return", "new", "Response", "(", "$", "content", ",", "200", ",", "[", "'Content-Type'", "=>", "'text/javascript'", "]", ")", ";", "}" ]
Return user javascripts. @return Response
[ "Return", "user", "javascripts", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/ResourcesController.php#L29-L39
236,030
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/ResourcesController.php
ResourcesController.translationsAction
public function translationsAction($language) { $language = $this->getUser()->getInterfaceLanguage($language); $translations = $this->get('resourcesTranslations'); $content = $translations->get($language); return new Response($content, 200, ['Content-Type' => 'text/javascript']); }
php
public function translationsAction($language) { $language = $this->getUser()->getInterfaceLanguage($language); $translations = $this->get('resourcesTranslations'); $content = $translations->get($language); return new Response($content, 200, ['Content-Type' => 'text/javascript']); }
[ "public", "function", "translationsAction", "(", "$", "language", ")", "{", "$", "language", "=", "$", "this", "->", "getUser", "(", ")", "->", "getInterfaceLanguage", "(", "$", "language", ")", ";", "$", "translations", "=", "$", "this", "->", "get", "(", "'resourcesTranslations'", ")", ";", "$", "content", "=", "$", "translations", "->", "get", "(", "$", "language", ")", ";", "return", "new", "Response", "(", "$", "content", ",", "200", ",", "[", "'Content-Type'", "=>", "'text/javascript'", "]", ")", ";", "}" ]
Return users translations. @param string $language @return Response
[ "Return", "users", "translations", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/ResourcesController.php#L72-L80
236,031
devsdmf/slice-http
src/Slice/Http/Client.php
Client.setUri
public function setUri($uri) { if (filter_var($uri, FILTER_VALIDATE_URL)) { $this->uri = $uri; } else { throw new RuntimeException('Invalid URI setted.'); } return $this; }
php
public function setUri($uri) { if (filter_var($uri, FILTER_VALIDATE_URL)) { $this->uri = $uri; } else { throw new RuntimeException('Invalid URI setted.'); } return $this; }
[ "public", "function", "setUri", "(", "$", "uri", ")", "{", "if", "(", "filter_var", "(", "$", "uri", ",", "FILTER_VALIDATE_URL", ")", ")", "{", "$", "this", "->", "uri", "=", "$", "uri", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'Invalid URI setted.'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the URI to perform the request @param string $uri @throws RuntimeException @return \Slice\Http\Client
[ "Set", "the", "URI", "to", "perform", "the", "request" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L194-L203
236,032
devsdmf/slice-http
src/Slice/Http/Client.php
Client.setMethod
public function setMethod($method = self::GET) { if (in_array($method, $this->allowedMethods)) { $this->method = $method; } else { throw new RuntimeException('Invalid method setted.'); } return $this; }
php
public function setMethod($method = self::GET) { if (in_array($method, $this->allowedMethods)) { $this->method = $method; } else { throw new RuntimeException('Invalid method setted.'); } return $this; }
[ "public", "function", "setMethod", "(", "$", "method", "=", "self", "::", "GET", ")", "{", "if", "(", "in_array", "(", "$", "method", ",", "$", "this", "->", "allowedMethods", ")", ")", "{", "$", "this", "->", "method", "=", "$", "method", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'Invalid method setted.'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the request method to use @param string $method Recommended use of Client class constants @throws RuntimeException @return \Slice\Http\Client
[ "Set", "the", "request", "method", "to", "use" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L222-L231
236,033
devsdmf/slice-http
src/Slice/Http/Client.php
Client.setHeaders
public function setHeaders($name, $value = null) { //Verifying if is array if (is_array($name)) { foreach ($name as $k => $v) { if (is_string($k)) { $this->setHeaders($k, $v); } else { $this->setHeaders($v, null); } } } else { // Verifying if is a string without $value parameter if (is_null($value) && (strpos($name, ':') > 0)) { list($name, $value) = explode(':', $name, 2); } if (is_null($value) || $value === false) { unset($this->headers[$name]); } else { if (is_string($value)) { $value = trim($value); } $this->headers[$name] = $value; } } return $this; }
php
public function setHeaders($name, $value = null) { //Verifying if is array if (is_array($name)) { foreach ($name as $k => $v) { if (is_string($k)) { $this->setHeaders($k, $v); } else { $this->setHeaders($v, null); } } } else { // Verifying if is a string without $value parameter if (is_null($value) && (strpos($name, ':') > 0)) { list($name, $value) = explode(':', $name, 2); } if (is_null($value) || $value === false) { unset($this->headers[$name]); } else { if (is_string($value)) { $value = trim($value); } $this->headers[$name] = $value; } } return $this; }
[ "public", "function", "setHeaders", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "//Verifying if is array", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "foreach", "(", "$", "name", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_string", "(", "$", "k", ")", ")", "{", "$", "this", "->", "setHeaders", "(", "$", "k", ",", "$", "v", ")", ";", "}", "else", "{", "$", "this", "->", "setHeaders", "(", "$", "v", ",", "null", ")", ";", "}", "}", "}", "else", "{", "// Verifying if is a string without $value parameter", "if", "(", "is_null", "(", "$", "value", ")", "&&", "(", "strpos", "(", "$", "name", ",", "':'", ")", ">", "0", ")", ")", "{", "list", "(", "$", "name", ",", "$", "value", ")", "=", "explode", "(", "':'", ",", "$", "name", ",", "2", ")", ";", "}", "if", "(", "is_null", "(", "$", "value", ")", "||", "$", "value", "===", "false", ")", "{", "unset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", ";", "}", "else", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "}", "$", "this", "->", "headers", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set the headers to send in request @param string|array $name The header name or an associative array with mutiples headers @param mixed $value @return \Slice\Http\Client
[ "Set", "the", "headers", "to", "send", "in", "request" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L250-L278
236,034
devsdmf/slice-http
src/Slice/Http/Client.php
Client.setParameterGet
public function setParameterGet($name, $value = null) { // Verifying if is array if (is_array($name)) { foreach ($name as $k => $v) { $this->setParameterGet($k,$v); } } else { $parray = &$this->paramsGet; if (is_null($value)) { if (isset($parray[$name])) unset($parray[$name]); } else { $parray[$name] = $value; } } return $this; }
php
public function setParameterGet($name, $value = null) { // Verifying if is array if (is_array($name)) { foreach ($name as $k => $v) { $this->setParameterGet($k,$v); } } else { $parray = &$this->paramsGet; if (is_null($value)) { if (isset($parray[$name])) unset($parray[$name]); } else { $parray[$name] = $value; } } return $this; }
[ "public", "function", "setParameterGet", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "// Verifying if is array", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "foreach", "(", "$", "name", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "setParameterGet", "(", "$", "k", ",", "$", "v", ")", ";", "}", "}", "else", "{", "$", "parray", "=", "&", "$", "this", "->", "paramsGet", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "if", "(", "isset", "(", "$", "parray", "[", "$", "name", "]", ")", ")", "unset", "(", "$", "parray", "[", "$", "name", "]", ")", ";", "}", "else", "{", "$", "parray", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set a GET parameter for the request @param string|array $name Parameter name or an associative array with multiple parameters @param mixed $value @return \Slice\Http\Client
[ "Set", "a", "GET", "parameter", "for", "the", "request" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L302-L320
236,035
devsdmf/slice-http
src/Slice/Http/Client.php
Client.setParameterPost
public function setParameterPost($name, $value = null) { // Verifying if is array if (is_array($name)) { foreach ($name as $k => $v) { $this->setParameterPost($k,$v); } } else { $parray = &$this->paramsPost; if (is_null($value)) { if (isset($parray[$name])) unset($parray[$name]); } else { $parray[$name] = $value; } } return $this; }
php
public function setParameterPost($name, $value = null) { // Verifying if is array if (is_array($name)) { foreach ($name as $k => $v) { $this->setParameterPost($k,$v); } } else { $parray = &$this->paramsPost; if (is_null($value)) { if (isset($parray[$name])) unset($parray[$name]); } else { $parray[$name] = $value; } } return $this; }
[ "public", "function", "setParameterPost", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "// Verifying if is array", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "foreach", "(", "$", "name", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "setParameterPost", "(", "$", "k", ",", "$", "v", ")", ";", "}", "}", "else", "{", "$", "parray", "=", "&", "$", "this", "->", "paramsPost", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "if", "(", "isset", "(", "$", "parray", "[", "$", "name", "]", ")", ")", "unset", "(", "$", "parray", "[", "$", "name", "]", ")", ";", "}", "else", "{", "$", "parray", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set a POST parameter for the request @param string|array $name Parameter name or an associative array with multiples parameters @param string $value @return \Slice\Http\Client
[ "Set", "a", "POST", "parameter", "for", "the", "request" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L329-L347
236,036
devsdmf/slice-http
src/Slice/Http/Client.php
Client.rawData
public function rawData($bool = false) { if (is_bool($bool)) { $this->useRawData = $bool; } else { throw new RuntimeException('Invalid parameter type, expected boolean, got ' . gettype($bool)); } return $this; }
php
public function rawData($bool = false) { if (is_bool($bool)) { $this->useRawData = $bool; } else { throw new RuntimeException('Invalid parameter type, expected boolean, got ' . gettype($bool)); } return $this; }
[ "public", "function", "rawData", "(", "$", "bool", "=", "false", ")", "{", "if", "(", "is_bool", "(", "$", "bool", ")", ")", "{", "$", "this", "->", "useRawData", "=", "$", "bool", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'Invalid parameter type, expected boolean, got '", ".", "gettype", "(", "$", "bool", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set true or false to use RAW data in request @param boolean $bool @throws RuntimeException @return \Slice\Http\Client
[ "Set", "true", "or", "false", "to", "use", "RAW", "data", "in", "request" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L356-L365
236,037
devsdmf/slice-http
src/Slice/Http/Client.php
Client.setRawData
public function setRawData($data) { if (is_string($data)) { $this->rawData(true); $this->dataRaw = $data; } else { throw new RuntimeException('Invalid RAW data setted.'); } return $this; }
php
public function setRawData($data) { if (is_string($data)) { $this->rawData(true); $this->dataRaw = $data; } else { throw new RuntimeException('Invalid RAW data setted.'); } return $this; }
[ "public", "function", "setRawData", "(", "$", "data", ")", "{", "if", "(", "is_string", "(", "$", "data", ")", ")", "{", "$", "this", "->", "rawData", "(", "true", ")", ";", "$", "this", "->", "dataRaw", "=", "$", "data", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'Invalid RAW data setted.'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the RAW data for the request @param string $data @throws RuntimeException @return \Slice\Http\Client
[ "Set", "the", "RAW", "data", "for", "the", "request" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L374-L384
236,038
devsdmf/slice-http
src/Slice/Http/Client.php
Client.setFiles
public function setFiles($file, $name = null) { // Verifying if is array if (is_array($file)) { foreach ($file as $k => $v) { $this->setFiles($v,$k); } } else { $parray = &$this->files; if (file_exists($file)) { if (is_null($file)) { if (isset($parray[$name])) unset($parray[$name]); } else { if (is_null($name) || is_integer($name)) { $count = count($parray); $name = 'file_contents_' . $count; } $parray[$name] = $file; } } else { throw new RuntimeException('Invalid file, file not exists.'); } } return $this; }
php
public function setFiles($file, $name = null) { // Verifying if is array if (is_array($file)) { foreach ($file as $k => $v) { $this->setFiles($v,$k); } } else { $parray = &$this->files; if (file_exists($file)) { if (is_null($file)) { if (isset($parray[$name])) unset($parray[$name]); } else { if (is_null($name) || is_integer($name)) { $count = count($parray); $name = 'file_contents_' . $count; } $parray[$name] = $file; } } else { throw new RuntimeException('Invalid file, file not exists.'); } } return $this; }
[ "public", "function", "setFiles", "(", "$", "file", ",", "$", "name", "=", "null", ")", "{", "// Verifying if is array", "if", "(", "is_array", "(", "$", "file", ")", ")", "{", "foreach", "(", "$", "file", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "setFiles", "(", "$", "v", ",", "$", "k", ")", ";", "}", "}", "else", "{", "$", "parray", "=", "&", "$", "this", "->", "files", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "if", "(", "is_null", "(", "$", "file", ")", ")", "{", "if", "(", "isset", "(", "$", "parray", "[", "$", "name", "]", ")", ")", "unset", "(", "$", "parray", "[", "$", "name", "]", ")", ";", "}", "else", "{", "if", "(", "is_null", "(", "$", "name", ")", "||", "is_integer", "(", "$", "name", ")", ")", "{", "$", "count", "=", "count", "(", "$", "parray", ")", ";", "$", "name", "=", "'file_contents_'", ".", "$", "count", ";", "}", "$", "parray", "[", "$", "name", "]", "=", "$", "file", ";", "}", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'Invalid file, file not exists.'", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set files for send in request @param string|array $file @param string $name @return \Slice\Http\Client
[ "Set", "files", "for", "send", "in", "request" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L393-L420
236,039
devsdmf/slice-http
src/Slice/Http/Client.php
Client.setHTTPVersion
public function setHTTPVersion($version = self::HTTP_1) { if ($version == self::HTTP_0 || $version == self::HTTP_1) { $this->httpVersion = $version; } else { throw new RuntimeException('Invalid HTTP version setted.'); } return $this; }
php
public function setHTTPVersion($version = self::HTTP_1) { if ($version == self::HTTP_0 || $version == self::HTTP_1) { $this->httpVersion = $version; } else { throw new RuntimeException('Invalid HTTP version setted.'); } return $this; }
[ "public", "function", "setHTTPVersion", "(", "$", "version", "=", "self", "::", "HTTP_1", ")", "{", "if", "(", "$", "version", "==", "self", "::", "HTTP_0", "||", "$", "version", "==", "self", "::", "HTTP_1", ")", "{", "$", "this", "->", "httpVersion", "=", "$", "version", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'Invalid HTTP version setted.'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set HTTP protocol version for request @param integer $version @throws RuntimeException @return \Slice\Http\Client
[ "Set", "HTTP", "protocol", "version", "for", "request" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L439-L448
236,040
devsdmf/slice-http
src/Slice/Http/Client.php
Client.setCurlOpts
public function setCurlOpts($opt, $value = null) { // Verifying if is array if (is_array($opt)) { foreach ($opt as $k => $v) { $this->setCurlOpts($k,$v); } } else { $this->curlOpts[$opt] = $value; } return $this; }
php
public function setCurlOpts($opt, $value = null) { // Verifying if is array if (is_array($opt)) { foreach ($opt as $k => $v) { $this->setCurlOpts($k,$v); } } else { $this->curlOpts[$opt] = $value; } return $this; }
[ "public", "function", "setCurlOpts", "(", "$", "opt", ",", "$", "value", "=", "null", ")", "{", "// Verifying if is array", "if", "(", "is_array", "(", "$", "opt", ")", ")", "{", "foreach", "(", "$", "opt", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "setCurlOpts", "(", "$", "k", ",", "$", "v", ")", ";", "}", "}", "else", "{", "$", "this", "->", "curlOpts", "[", "$", "opt", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set custom CURL options for CURL handle @param mixed $opt The option value in CURL or an associative array with multiples options @param mixed $value The value of parameter @return \Slice\Http\Client
[ "Set", "custom", "CURL", "options", "for", "CURL", "handle" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L457-L469
236,041
devsdmf/slice-http
src/Slice/Http/Client.php
Client.noReset
public function noReset($bool = false) { if (is_bool($bool)) { $this->noReset = $bool; } else { throw new RuntimeException('Invalid parameter type setted, expected boolean, got ' . gettype($bool)); } }
php
public function noReset($bool = false) { if (is_bool($bool)) { $this->noReset = $bool; } else { throw new RuntimeException('Invalid parameter type setted, expected boolean, got ' . gettype($bool)); } }
[ "public", "function", "noReset", "(", "$", "bool", "=", "false", ")", "{", "if", "(", "is_bool", "(", "$", "bool", ")", ")", "{", "$", "this", "->", "noReset", "=", "$", "bool", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'Invalid parameter type setted, expected boolean, got '", ".", "gettype", "(", "$", "bool", ")", ")", ";", "}", "}" ]
Set true or false for reset the Client state after request @param boolean $bool @throws RuntimeException
[ "Set", "true", "or", "false", "for", "reset", "the", "Client", "state", "after", "request" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L497-L504
236,042
devsdmf/slice-http
src/Slice/Http/Client.php
Client.reset
public function reset() { $this->uri = null; $this->method = self::GET; $this->headers = array(); $this->paramsGet = array(); $this->paramsPost = array(); $this->useRawData = false; $this->dataRaw = null; $this->httpVersion = self::HTTP_1; $this->curlOpts = array(); return $this; }
php
public function reset() { $this->uri = null; $this->method = self::GET; $this->headers = array(); $this->paramsGet = array(); $this->paramsPost = array(); $this->useRawData = false; $this->dataRaw = null; $this->httpVersion = self::HTTP_1; $this->curlOpts = array(); return $this; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "uri", "=", "null", ";", "$", "this", "->", "method", "=", "self", "::", "GET", ";", "$", "this", "->", "headers", "=", "array", "(", ")", ";", "$", "this", "->", "paramsGet", "=", "array", "(", ")", ";", "$", "this", "->", "paramsPost", "=", "array", "(", ")", ";", "$", "this", "->", "useRawData", "=", "false", ";", "$", "this", "->", "dataRaw", "=", "null", ";", "$", "this", "->", "httpVersion", "=", "self", "::", "HTTP_1", ";", "$", "this", "->", "curlOpts", "=", "array", "(", ")", ";", "return", "$", "this", ";", "}" ]
Reset the Client state @return \Slice\Http\Client
[ "Reset", "the", "Client", "state" ]
8ab12b42354ff092d88d29d265733186698cb829
https://github.com/devsdmf/slice-http/blob/8ab12b42354ff092d88d29d265733186698cb829/src/Slice/Http/Client.php#L638-L651
236,043
harmony-project/modular-routing
source/Bridge/Doctrine/EventListener/ModularSubscriber.php
ModularSubscriber.loadClassMetadata
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $classMetadata */ $classMetadata = $eventArgs->getClassMetadata(); if (null === $classMetadata->getReflectionClass() || false == $this->isModular($classMetadata) || 'Harmony\Component\ModularRouting\StaticModule' == $this->getModuleClass() || $classMetadata->hasField('module') || $classMetadata->hasAssociation('module')) { return; } $classMetadata->mapManyToOne([ 'targetEntity' => $this->getModuleClass(), 'fieldName' => 'module', 'joinColumns' => [ [ 'name' => 'module_id', 'referencedColumnName' => 'id', ], ], ]); }
php
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $classMetadata */ $classMetadata = $eventArgs->getClassMetadata(); if (null === $classMetadata->getReflectionClass() || false == $this->isModular($classMetadata) || 'Harmony\Component\ModularRouting\StaticModule' == $this->getModuleClass() || $classMetadata->hasField('module') || $classMetadata->hasAssociation('module')) { return; } $classMetadata->mapManyToOne([ 'targetEntity' => $this->getModuleClass(), 'fieldName' => 'module', 'joinColumns' => [ [ 'name' => 'module_id', 'referencedColumnName' => 'id', ], ], ]); }
[ "public", "function", "loadClassMetadata", "(", "LoadClassMetadataEventArgs", "$", "eventArgs", ")", "{", "/** @var ClassMetadata $classMetadata */", "$", "classMetadata", "=", "$", "eventArgs", "->", "getClassMetadata", "(", ")", ";", "if", "(", "null", "===", "$", "classMetadata", "->", "getReflectionClass", "(", ")", "||", "false", "==", "$", "this", "->", "isModular", "(", "$", "classMetadata", ")", "||", "'Harmony\\Component\\ModularRouting\\StaticModule'", "==", "$", "this", "->", "getModuleClass", "(", ")", "||", "$", "classMetadata", "->", "hasField", "(", "'module'", ")", "||", "$", "classMetadata", "->", "hasAssociation", "(", "'module'", ")", ")", "{", "return", ";", "}", "$", "classMetadata", "->", "mapManyToOne", "(", "[", "'targetEntity'", "=>", "$", "this", "->", "getModuleClass", "(", ")", ",", "'fieldName'", "=>", "'module'", ",", "'joinColumns'", "=>", "[", "[", "'name'", "=>", "'module_id'", ",", "'referencedColumnName'", "=>", "'id'", ",", "]", ",", "]", ",", "]", ")", ";", "}" ]
Handles actions when metadata is loaded. Creates an association for entities that inherit ModularTrait. @param LoadClassMetadataEventArgs $eventArgs
[ "Handles", "actions", "when", "metadata", "is", "loaded", "." ]
399bb427678ddc17c67295c738b96faea485e2d8
https://github.com/harmony-project/modular-routing/blob/399bb427678ddc17c67295c738b96faea485e2d8/source/Bridge/Doctrine/EventListener/ModularSubscriber.php#L80-L103
236,044
harmony-project/modular-routing
source/Bridge/Doctrine/EventListener/ModularSubscriber.php
ModularSubscriber.prePersist
public function prePersist(LifecycleEventArgs $args) { $entity = $args->getEntity(); $entityManager = $args->getEntityManager(); $classMetadata = $entityManager->getClassMetadata(get_class($entity)); if (false == $this->isModular($classMetadata)) { return; } if (null === $entity->getModule() && null !== $this->getModuleManager()->getCurrentModule()) { $entity->setModule($this->getModuleManager()->getCurrentModule()); } }
php
public function prePersist(LifecycleEventArgs $args) { $entity = $args->getEntity(); $entityManager = $args->getEntityManager(); $classMetadata = $entityManager->getClassMetadata(get_class($entity)); if (false == $this->isModular($classMetadata)) { return; } if (null === $entity->getModule() && null !== $this->getModuleManager()->getCurrentModule()) { $entity->setModule($this->getModuleManager()->getCurrentModule()); } }
[ "public", "function", "prePersist", "(", "LifecycleEventArgs", "$", "args", ")", "{", "$", "entity", "=", "$", "args", "->", "getEntity", "(", ")", ";", "$", "entityManager", "=", "$", "args", "->", "getEntityManager", "(", ")", ";", "$", "classMetadata", "=", "$", "entityManager", "->", "getClassMetadata", "(", "get_class", "(", "$", "entity", ")", ")", ";", "if", "(", "false", "==", "$", "this", "->", "isModular", "(", "$", "classMetadata", ")", ")", "{", "return", ";", "}", "if", "(", "null", "===", "$", "entity", "->", "getModule", "(", ")", "&&", "null", "!==", "$", "this", "->", "getModuleManager", "(", ")", "->", "getCurrentModule", "(", ")", ")", "{", "$", "entity", "->", "setModule", "(", "$", "this", "->", "getModuleManager", "(", ")", "->", "getCurrentModule", "(", ")", ")", ";", "}", "}" ]
Handles actions before creation of an entity. Sets the module of an entity to the current module defined by the module manager if it has been left empty. @param LifecycleEventArgs $args
[ "Handles", "actions", "before", "creation", "of", "an", "entity", "." ]
399bb427678ddc17c67295c738b96faea485e2d8
https://github.com/harmony-project/modular-routing/blob/399bb427678ddc17c67295c738b96faea485e2d8/source/Bridge/Doctrine/EventListener/ModularSubscriber.php#L113-L127
236,045
perfumer/framework
src/Component/Container/Container.php
Container.get
public function get($name, array $parameters = []) { // Shared services are preserved through whole request if (isset($this->shared[$name])) { return $this->shared[$name]; } if (!$this->has($name)) { throw new NotFoundException('No definition found for service "' . $name . '".'); } $definition = $this->definitions[$name]; // Alias is a link to another definition if (isset($definition['alias'])) { return $this->get($definition['alias']); } // "Init" directive is a function that returns instance of service if (isset($definition['init'])) { $service_class = call_user_func($definition['init'], $this, $parameters); if ($service_class === false) { throw new NotFoundException('"Init" directive for service "' . $name . '" did not produced any object.'); } } else { $arguments = []; // Array of arguments which are given to constructor method if (isset($definition['arguments'])) { $arguments = $this->resolveArrayOfArguments($definition['arguments'], $parameters); } // Service is made by static method if (isset($definition['static'])) { $service_class = call_user_func_array([$definition['class'], $definition['static']], $arguments); if ($service_class === false) { throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.'); } } else { // Service is made by normal constructor try { $reflection_class = new \ReflectionClass($definition['class']); } catch (\ReflectionException $e) { throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.'); } $service_class = $reflection_class->newInstanceArgs($arguments); } } // "After" directive is a function that is called after instantiation of service object if (isset($definition['after'])) { call_user_func($definition['after'], $this, $service_class, $parameters); } // Preserve shared service if (isset($definition['shared']) && $definition['shared'] === true) { $this->shared[$name] = $service_class; } return $service_class; }
php
public function get($name, array $parameters = []) { // Shared services are preserved through whole request if (isset($this->shared[$name])) { return $this->shared[$name]; } if (!$this->has($name)) { throw new NotFoundException('No definition found for service "' . $name . '".'); } $definition = $this->definitions[$name]; // Alias is a link to another definition if (isset($definition['alias'])) { return $this->get($definition['alias']); } // "Init" directive is a function that returns instance of service if (isset($definition['init'])) { $service_class = call_user_func($definition['init'], $this, $parameters); if ($service_class === false) { throw new NotFoundException('"Init" directive for service "' . $name . '" did not produced any object.'); } } else { $arguments = []; // Array of arguments which are given to constructor method if (isset($definition['arguments'])) { $arguments = $this->resolveArrayOfArguments($definition['arguments'], $parameters); } // Service is made by static method if (isset($definition['static'])) { $service_class = call_user_func_array([$definition['class'], $definition['static']], $arguments); if ($service_class === false) { throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.'); } } else { // Service is made by normal constructor try { $reflection_class = new \ReflectionClass($definition['class']); } catch (\ReflectionException $e) { throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.'); } $service_class = $reflection_class->newInstanceArgs($arguments); } } // "After" directive is a function that is called after instantiation of service object if (isset($definition['after'])) { call_user_func($definition['after'], $this, $service_class, $parameters); } // Preserve shared service if (isset($definition['shared']) && $definition['shared'] === true) { $this->shared[$name] = $service_class; } return $service_class; }
[ "public", "function", "get", "(", "$", "name", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "// Shared services are preserved through whole request", "if", "(", "isset", "(", "$", "this", "->", "shared", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "shared", "[", "$", "name", "]", ";", "}", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "NotFoundException", "(", "'No definition found for service \"'", ".", "$", "name", ".", "'\".'", ")", ";", "}", "$", "definition", "=", "$", "this", "->", "definitions", "[", "$", "name", "]", ";", "// Alias is a link to another definition", "if", "(", "isset", "(", "$", "definition", "[", "'alias'", "]", ")", ")", "{", "return", "$", "this", "->", "get", "(", "$", "definition", "[", "'alias'", "]", ")", ";", "}", "// \"Init\" directive is a function that returns instance of service", "if", "(", "isset", "(", "$", "definition", "[", "'init'", "]", ")", ")", "{", "$", "service_class", "=", "call_user_func", "(", "$", "definition", "[", "'init'", "]", ",", "$", "this", ",", "$", "parameters", ")", ";", "if", "(", "$", "service_class", "===", "false", ")", "{", "throw", "new", "NotFoundException", "(", "'\"Init\" directive for service \"'", ".", "$", "name", ".", "'\" did not produced any object.'", ")", ";", "}", "}", "else", "{", "$", "arguments", "=", "[", "]", ";", "// Array of arguments which are given to constructor method", "if", "(", "isset", "(", "$", "definition", "[", "'arguments'", "]", ")", ")", "{", "$", "arguments", "=", "$", "this", "->", "resolveArrayOfArguments", "(", "$", "definition", "[", "'arguments'", "]", ",", "$", "parameters", ")", ";", "}", "// Service is made by static method", "if", "(", "isset", "(", "$", "definition", "[", "'static'", "]", ")", ")", "{", "$", "service_class", "=", "call_user_func_array", "(", "[", "$", "definition", "[", "'class'", "]", ",", "$", "definition", "[", "'static'", "]", "]", ",", "$", "arguments", ")", ";", "if", "(", "$", "service_class", "===", "false", ")", "{", "throw", "new", "NotFoundException", "(", "'Class \"'", ".", "$", "definition", "[", "'class'", "]", ".", "'\" for service \"'", ".", "$", "name", ".", "'\" was not found.'", ")", ";", "}", "}", "else", "{", "// Service is made by normal constructor", "try", "{", "$", "reflection_class", "=", "new", "\\", "ReflectionClass", "(", "$", "definition", "[", "'class'", "]", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", "{", "throw", "new", "NotFoundException", "(", "'Class \"'", ".", "$", "definition", "[", "'class'", "]", ".", "'\" for service \"'", ".", "$", "name", ".", "'\" was not found.'", ")", ";", "}", "$", "service_class", "=", "$", "reflection_class", "->", "newInstanceArgs", "(", "$", "arguments", ")", ";", "}", "}", "// \"After\" directive is a function that is called after instantiation of service object", "if", "(", "isset", "(", "$", "definition", "[", "'after'", "]", ")", ")", "{", "call_user_func", "(", "$", "definition", "[", "'after'", "]", ",", "$", "this", ",", "$", "service_class", ",", "$", "parameters", ")", ";", "}", "// Preserve shared service", "if", "(", "isset", "(", "$", "definition", "[", "'shared'", "]", ")", "&&", "$", "definition", "[", "'shared'", "]", "===", "true", ")", "{", "$", "this", "->", "shared", "[", "$", "name", "]", "=", "$", "service_class", ";", "}", "return", "$", "service_class", ";", "}" ]
get Get service instance. @param string $name @param array $parameters @return mixed @access public @uses \ReflectionClass @throws NotFoundException
[ "get", "Get", "service", "instance", "." ]
3565b560e9b45dfac0a28600f70496afa91179be
https://github.com/perfumer/framework/blob/3565b560e9b45dfac0a28600f70496afa91179be/src/Component/Container/Container.php#L56-L119
236,046
pMatviienko/zf2-data-grid
DataGrid/src/DataGrid/Condition/Pair.php
Pair.calculate
public function calculate($values) { $dataToReplace = array(); foreach ($this->getVariables() as $mask => $var) { $var = $values[$var]; if ($var instanceof \DateTime) { $var = new \Zend_Date($var->getTimestamp()); $var = $var->get(self::DEFAULT_DATETIME_MASK); } $dataToReplace[$mask] = $var; } $condition = str_replace(array_keys($dataToReplace), array_values($dataToReplace), $this->condition); $condition = explode($this->operator, $condition); if (is_numeric($condition[0])) { $condition[0] = floatval($condition[0]); } else { $condition[0] = trim($condition[0]); } if (is_numeric($condition[1])) { $condition[1] = floatval($condition[1]); } else { $condition[1] = trim($condition[1]); } $out = null; switch ($this->operator) { case self::OPERATOR_EQ: $out = $condition[0] == $condition[1]; break; case self::OPERATOR_NEQ: $out = $condition[0] != $condition[1]; break; case self::OPERATOR_GRATER: $out = $condition[0] > $condition[1]; break; case self::OPERATOR_GRATER_EQ: $out = $condition[0] >= $condition[1]; break; case self::OPERATOR_LESS: $out = $condition[0] < $condition[1]; break; case self::OPERATOR_LESS_EQ: $out = $condition[0] <= $condition[1]; break; default: throw new Exception\UnknownPairOperatorException('Operator "' . $this->operator . '" is not supported.'); } return $out; }
php
public function calculate($values) { $dataToReplace = array(); foreach ($this->getVariables() as $mask => $var) { $var = $values[$var]; if ($var instanceof \DateTime) { $var = new \Zend_Date($var->getTimestamp()); $var = $var->get(self::DEFAULT_DATETIME_MASK); } $dataToReplace[$mask] = $var; } $condition = str_replace(array_keys($dataToReplace), array_values($dataToReplace), $this->condition); $condition = explode($this->operator, $condition); if (is_numeric($condition[0])) { $condition[0] = floatval($condition[0]); } else { $condition[0] = trim($condition[0]); } if (is_numeric($condition[1])) { $condition[1] = floatval($condition[1]); } else { $condition[1] = trim($condition[1]); } $out = null; switch ($this->operator) { case self::OPERATOR_EQ: $out = $condition[0] == $condition[1]; break; case self::OPERATOR_NEQ: $out = $condition[0] != $condition[1]; break; case self::OPERATOR_GRATER: $out = $condition[0] > $condition[1]; break; case self::OPERATOR_GRATER_EQ: $out = $condition[0] >= $condition[1]; break; case self::OPERATOR_LESS: $out = $condition[0] < $condition[1]; break; case self::OPERATOR_LESS_EQ: $out = $condition[0] <= $condition[1]; break; default: throw new Exception\UnknownPairOperatorException('Operator "' . $this->operator . '" is not supported.'); } return $out; }
[ "public", "function", "calculate", "(", "$", "values", ")", "{", "$", "dataToReplace", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getVariables", "(", ")", "as", "$", "mask", "=>", "$", "var", ")", "{", "$", "var", "=", "$", "values", "[", "$", "var", "]", ";", "if", "(", "$", "var", "instanceof", "\\", "DateTime", ")", "{", "$", "var", "=", "new", "\\", "Zend_Date", "(", "$", "var", "->", "getTimestamp", "(", ")", ")", ";", "$", "var", "=", "$", "var", "->", "get", "(", "self", "::", "DEFAULT_DATETIME_MASK", ")", ";", "}", "$", "dataToReplace", "[", "$", "mask", "]", "=", "$", "var", ";", "}", "$", "condition", "=", "str_replace", "(", "array_keys", "(", "$", "dataToReplace", ")", ",", "array_values", "(", "$", "dataToReplace", ")", ",", "$", "this", "->", "condition", ")", ";", "$", "condition", "=", "explode", "(", "$", "this", "->", "operator", ",", "$", "condition", ")", ";", "if", "(", "is_numeric", "(", "$", "condition", "[", "0", "]", ")", ")", "{", "$", "condition", "[", "0", "]", "=", "floatval", "(", "$", "condition", "[", "0", "]", ")", ";", "}", "else", "{", "$", "condition", "[", "0", "]", "=", "trim", "(", "$", "condition", "[", "0", "]", ")", ";", "}", "if", "(", "is_numeric", "(", "$", "condition", "[", "1", "]", ")", ")", "{", "$", "condition", "[", "1", "]", "=", "floatval", "(", "$", "condition", "[", "1", "]", ")", ";", "}", "else", "{", "$", "condition", "[", "1", "]", "=", "trim", "(", "$", "condition", "[", "1", "]", ")", ";", "}", "$", "out", "=", "null", ";", "switch", "(", "$", "this", "->", "operator", ")", "{", "case", "self", "::", "OPERATOR_EQ", ":", "$", "out", "=", "$", "condition", "[", "0", "]", "==", "$", "condition", "[", "1", "]", ";", "break", ";", "case", "self", "::", "OPERATOR_NEQ", ":", "$", "out", "=", "$", "condition", "[", "0", "]", "!=", "$", "condition", "[", "1", "]", ";", "break", ";", "case", "self", "::", "OPERATOR_GRATER", ":", "$", "out", "=", "$", "condition", "[", "0", "]", ">", "$", "condition", "[", "1", "]", ";", "break", ";", "case", "self", "::", "OPERATOR_GRATER_EQ", ":", "$", "out", "=", "$", "condition", "[", "0", "]", ">=", "$", "condition", "[", "1", "]", ";", "break", ";", "case", "self", "::", "OPERATOR_LESS", ":", "$", "out", "=", "$", "condition", "[", "0", "]", "<", "$", "condition", "[", "1", "]", ";", "break", ";", "case", "self", "::", "OPERATOR_LESS_EQ", ":", "$", "out", "=", "$", "condition", "[", "0", "]", "<=", "$", "condition", "[", "1", "]", ";", "break", ";", "default", ":", "throw", "new", "Exception", "\\", "UnknownPairOperatorException", "(", "'Operator \"'", ".", "$", "this", "->", "operator", ".", "'\" is not supported.'", ")", ";", "}", "return", "$", "out", ";", "}" ]
Calculating condition by given values. @param array $values @throws Exception\UnknownPairOperatorException @return boolean
[ "Calculating", "condition", "by", "given", "values", "." ]
1d1958c059d2ac31b972bfd4a49c70e068677461
https://github.com/pMatviienko/zf2-data-grid/blob/1d1958c059d2ac31b972bfd4a49c70e068677461/DataGrid/src/DataGrid/Condition/Pair.php#L54-L101
236,047
n0m4dz/laracasa
Zend/Gdata/Gapps/GroupEntry.php
Zend_Gdata_Gapps_GroupEntry.getProperty
public function getProperty($rel = null) { if ($rel == null) { return $this->_property; } else { foreach ($this->_property as $p) { if ($p->rel == $rel) { return $p; } } return null; } }
php
public function getProperty($rel = null) { if ($rel == null) { return $this->_property; } else { foreach ($this->_property as $p) { if ($p->rel == $rel) { return $p; } } return null; } }
[ "public", "function", "getProperty", "(", "$", "rel", "=", "null", ")", "{", "if", "(", "$", "rel", "==", "null", ")", "{", "return", "$", "this", "->", "_property", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "_property", "as", "$", "p", ")", "{", "if", "(", "$", "p", "->", "rel", "==", "$", "rel", ")", "{", "return", "$", "p", ";", "}", "}", "return", "null", ";", "}", "}" ]
Returns all property tags for this entry @param string $rel The rel value of the property to be found. If null, the array of properties is returned instead. @return mixed Either an array of Zend_Gdata_Gapps_Extension_Property objects if $rel is null, a single Zend_Gdata_Gapps_Extension_Property object if $rel is specified and a matching feed link is found, or null if $rel is specified and no matching property is found.
[ "Returns", "all", "property", "tags", "for", "this", "entry" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Gapps/GroupEntry.php#L130-L142
236,048
JoshuaEstes/Daedalus
src/Daedalus/Loader/YamlBuildFileLoader.php
YamlBuildFileLoader.processTasks
protected function processTasks($tasks) { foreach ($tasks as $taskName => $taskConfig) { $serviceId = sprintf('task.%s', $taskName); $this->container->setDefinition( $serviceId, new Definition() )->setSynthetic(true); $command = $this->buildTask($taskName, $taskConfig); $this->container->set($serviceId, $command); $this->container->get('application')->add($command); } }
php
protected function processTasks($tasks) { foreach ($tasks as $taskName => $taskConfig) { $serviceId = sprintf('task.%s', $taskName); $this->container->setDefinition( $serviceId, new Definition() )->setSynthetic(true); $command = $this->buildTask($taskName, $taskConfig); $this->container->set($serviceId, $command); $this->container->get('application')->add($command); } }
[ "protected", "function", "processTasks", "(", "$", "tasks", ")", "{", "foreach", "(", "$", "tasks", "as", "$", "taskName", "=>", "$", "taskConfig", ")", "{", "$", "serviceId", "=", "sprintf", "(", "'task.%s'", ",", "$", "taskName", ")", ";", "$", "this", "->", "container", "->", "setDefinition", "(", "$", "serviceId", ",", "new", "Definition", "(", ")", ")", "->", "setSynthetic", "(", "true", ")", ";", "$", "command", "=", "$", "this", "->", "buildTask", "(", "$", "taskName", ",", "$", "taskConfig", ")", ";", "$", "this", "->", "container", "->", "set", "(", "$", "serviceId", ",", "$", "command", ")", ";", "$", "this", "->", "container", "->", "get", "(", "'application'", ")", "->", "add", "(", "$", "command", ")", ";", "}", "}" ]
Process tasks that the user has defined and turn them into commands that can be ran. @param array $tasks
[ "Process", "tasks", "that", "the", "user", "has", "defined", "and", "turn", "them", "into", "commands", "that", "can", "be", "ran", "." ]
4c898c41433242e46b30d45ebe03fdc91512b444
https://github.com/JoshuaEstes/Daedalus/blob/4c898c41433242e46b30d45ebe03fdc91512b444/src/Daedalus/Loader/YamlBuildFileLoader.php#L117-L131
236,049
psiphp/grid
lib/ActionPerformer.php
ActionPerformer.perform
public function perform( AgentInterface $agent, GridMetadata $gridMetadata, string $actionName, array $selectedIdentifiers ): ActionResponseInterface { $actionMetadatas = $gridMetadata->getActions(); if (!isset($actionMetadatas[$actionName])) { throw new \InvalidArgumentException(sprintf( 'Action "%s" is not available for class "%s". Availabile actions: "%s"', $actionName, $gridMetadata->getClassMetadata()->name, implode('", "', array_keys($actionMetadatas)) )); } $actionMetadata = $actionMetadatas[$actionName]; $action = $this->registry->get($actionMetadata->getType()); $options = new OptionsResolver(); $action->configureOptions($options); $options = $options->resolve($actionMetadata->getOptions()); return $action->perform($agent, $gridMetadata->getClassMetadata()->name, $selectedIdentifiers, $options); }
php
public function perform( AgentInterface $agent, GridMetadata $gridMetadata, string $actionName, array $selectedIdentifiers ): ActionResponseInterface { $actionMetadatas = $gridMetadata->getActions(); if (!isset($actionMetadatas[$actionName])) { throw new \InvalidArgumentException(sprintf( 'Action "%s" is not available for class "%s". Availabile actions: "%s"', $actionName, $gridMetadata->getClassMetadata()->name, implode('", "', array_keys($actionMetadatas)) )); } $actionMetadata = $actionMetadatas[$actionName]; $action = $this->registry->get($actionMetadata->getType()); $options = new OptionsResolver(); $action->configureOptions($options); $options = $options->resolve($actionMetadata->getOptions()); return $action->perform($agent, $gridMetadata->getClassMetadata()->name, $selectedIdentifiers, $options); }
[ "public", "function", "perform", "(", "AgentInterface", "$", "agent", ",", "GridMetadata", "$", "gridMetadata", ",", "string", "$", "actionName", ",", "array", "$", "selectedIdentifiers", ")", ":", "ActionResponseInterface", "{", "$", "actionMetadatas", "=", "$", "gridMetadata", "->", "getActions", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "actionMetadatas", "[", "$", "actionName", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Action \"%s\" is not available for class \"%s\". Availabile actions: \"%s\"'", ",", "$", "actionName", ",", "$", "gridMetadata", "->", "getClassMetadata", "(", ")", "->", "name", ",", "implode", "(", "'\", \"'", ",", "array_keys", "(", "$", "actionMetadatas", ")", ")", ")", ")", ";", "}", "$", "actionMetadata", "=", "$", "actionMetadatas", "[", "$", "actionName", "]", ";", "$", "action", "=", "$", "this", "->", "registry", "->", "get", "(", "$", "actionMetadata", "->", "getType", "(", ")", ")", ";", "$", "options", "=", "new", "OptionsResolver", "(", ")", ";", "$", "action", "->", "configureOptions", "(", "$", "options", ")", ";", "$", "options", "=", "$", "options", "->", "resolve", "(", "$", "actionMetadata", "->", "getOptions", "(", ")", ")", ";", "return", "$", "action", "->", "perform", "(", "$", "agent", ",", "$", "gridMetadata", "->", "getClassMetadata", "(", ")", "->", "name", ",", "$", "selectedIdentifiers", ",", "$", "options", ")", ";", "}" ]
Retrieve a collection from the given agent using the given metadata and identifiers and perform the named action on each member of the collection. It should be assumed that the storage will be flushed by the action which is executed. @throws \InvalidArgumentException If the action is not available.
[ "Retrieve", "a", "collection", "from", "the", "given", "agent", "using", "the", "given", "metadata", "and", "identifiers", "and", "perform", "the", "named", "action", "on", "each", "member", "of", "the", "collection", "." ]
3c2183db23321d019147bb7c2a93575865d96789
https://github.com/psiphp/grid/blob/3c2183db23321d019147bb7c2a93575865d96789/lib/ActionPerformer.php#L30-L51
236,050
marando/phpSOFA
src/Marando/IAU/iauRx.php
iauRx.Rx
public static function Rx($phi, array &$r) { $s; $c; $a10; $a11; $a12; $a20; $a21; $a22; $s = sin($phi); $c = cos($phi); $a10 = $c * $r[1][0] + $s * $r[2][0]; $a11 = $c * $r[1][1] + $s * $r[2][1]; $a12 = $c * $r[1][2] + $s * $r[2][2]; $a20 = - $s * $r[1][0] + $c * $r[2][0]; $a21 = - $s * $r[1][1] + $c * $r[2][1]; $a22 = - $s * $r[1][2] + $c * $r[2][2]; $r[1][0] = $a10; $r[1][1] = $a11; $r[1][2] = $a12; $r[2][0] = $a20; $r[2][1] = $a21; $r[2][2] = $a22; return; }
php
public static function Rx($phi, array &$r) { $s; $c; $a10; $a11; $a12; $a20; $a21; $a22; $s = sin($phi); $c = cos($phi); $a10 = $c * $r[1][0] + $s * $r[2][0]; $a11 = $c * $r[1][1] + $s * $r[2][1]; $a12 = $c * $r[1][2] + $s * $r[2][2]; $a20 = - $s * $r[1][0] + $c * $r[2][0]; $a21 = - $s * $r[1][1] + $c * $r[2][1]; $a22 = - $s * $r[1][2] + $c * $r[2][2]; $r[1][0] = $a10; $r[1][1] = $a11; $r[1][2] = $a12; $r[2][0] = $a20; $r[2][1] = $a21; $r[2][2] = $a22; return; }
[ "public", "static", "function", "Rx", "(", "$", "phi", ",", "array", "&", "$", "r", ")", "{", "$", "s", ";", "$", "c", ";", "$", "a10", ";", "$", "a11", ";", "$", "a12", ";", "$", "a20", ";", "$", "a21", ";", "$", "a22", ";", "$", "s", "=", "sin", "(", "$", "phi", ")", ";", "$", "c", "=", "cos", "(", "$", "phi", ")", ";", "$", "a10", "=", "$", "c", "*", "$", "r", "[", "1", "]", "[", "0", "]", "+", "$", "s", "*", "$", "r", "[", "2", "]", "[", "0", "]", ";", "$", "a11", "=", "$", "c", "*", "$", "r", "[", "1", "]", "[", "1", "]", "+", "$", "s", "*", "$", "r", "[", "2", "]", "[", "1", "]", ";", "$", "a12", "=", "$", "c", "*", "$", "r", "[", "1", "]", "[", "2", "]", "+", "$", "s", "*", "$", "r", "[", "2", "]", "[", "2", "]", ";", "$", "a20", "=", "-", "$", "s", "*", "$", "r", "[", "1", "]", "[", "0", "]", "+", "$", "c", "*", "$", "r", "[", "2", "]", "[", "0", "]", ";", "$", "a21", "=", "-", "$", "s", "*", "$", "r", "[", "1", "]", "[", "1", "]", "+", "$", "c", "*", "$", "r", "[", "2", "]", "[", "1", "]", ";", "$", "a22", "=", "-", "$", "s", "*", "$", "r", "[", "1", "]", "[", "2", "]", "+", "$", "c", "*", "$", "r", "[", "2", "]", "[", "2", "]", ";", "$", "r", "[", "1", "]", "[", "0", "]", "=", "$", "a10", ";", "$", "r", "[", "1", "]", "[", "1", "]", "=", "$", "a11", ";", "$", "r", "[", "1", "]", "[", "2", "]", "=", "$", "a12", ";", "$", "r", "[", "2", "]", "[", "0", "]", "=", "$", "a20", ";", "$", "r", "[", "2", "]", "[", "1", "]", "=", "$", "a21", ";", "$", "r", "[", "2", "]", "[", "2", "]", "=", "$", "a22", ";", "return", ";", "}" ]
- - - - - - i a u R x - - - - - - Rotate an r-matrix about the x-axis. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: vector/matrix support function. Given: phi double angle (radians) Given and returned: r double[3][3] r-matrix, rotated Notes: 1) Calling this function with positive phi incorporates in the supplied r-matrix r an additional rotation, about the x-axis, anticlockwise as seen looking towards the origin from positive x. 2) The additional rotation can be represented by this matrix: ( 1 0 0 ) ( ) ( 0 + cos(phi) + sin(phi) ) ( ) ( 0 - sin(phi) + cos(phi) ) This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "i", "a", "u", "R", "x", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauRx.php#L45-L73
236,051
Webiny/Hrc
src/Webiny/Hrc/IndexStorage/FileSystem.php
FileSystem.getIndex
private function getIndex($key, $tags) { // tags folder $tagFolder = $this->createFolderNameFromTags($tags); if (!is_dir($tagFolder)) { mkdir($tagFolder, 0755, true); } // key folder $folder = $tagFolder . substr($key, 0, 2) . DIRECTORY_SEPARATOR . substr($key, 2, 2) . DIRECTORY_SEPARATOR . substr($key, 4, 2) . DIRECTORY_SEPARATOR; if (!is_dir($folder)) { mkdir($folder, 0755, true); } // check if index exists return $folder . 'index.db'; }
php
private function getIndex($key, $tags) { // tags folder $tagFolder = $this->createFolderNameFromTags($tags); if (!is_dir($tagFolder)) { mkdir($tagFolder, 0755, true); } // key folder $folder = $tagFolder . substr($key, 0, 2) . DIRECTORY_SEPARATOR . substr($key, 2, 2) . DIRECTORY_SEPARATOR . substr($key, 4, 2) . DIRECTORY_SEPARATOR; if (!is_dir($folder)) { mkdir($folder, 0755, true); } // check if index exists return $folder . 'index.db'; }
[ "private", "function", "getIndex", "(", "$", "key", ",", "$", "tags", ")", "{", "// tags folder", "$", "tagFolder", "=", "$", "this", "->", "createFolderNameFromTags", "(", "$", "tags", ")", ";", "if", "(", "!", "is_dir", "(", "$", "tagFolder", ")", ")", "{", "mkdir", "(", "$", "tagFolder", ",", "0755", ",", "true", ")", ";", "}", "// key folder", "$", "folder", "=", "$", "tagFolder", ".", "substr", "(", "$", "key", ",", "0", ",", "2", ")", ".", "DIRECTORY_SEPARATOR", ".", "substr", "(", "$", "key", ",", "2", ",", "2", ")", ".", "DIRECTORY_SEPARATOR", ".", "substr", "(", "$", "key", ",", "4", ",", "2", ")", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "is_dir", "(", "$", "folder", ")", ")", "{", "mkdir", "(", "$", "folder", ",", "0755", ",", "true", ")", ";", "}", "// check if index exists", "return", "$", "folder", ".", "'index.db'", ";", "}" ]
Based on the provided key and tag list, a path to the index is created and returned. @param string $key @param string $tags @return string
[ "Based", "on", "the", "provided", "key", "and", "tag", "list", "a", "path", "to", "the", "index", "is", "created", "and", "returned", "." ]
2594d645dd79a579916d90ec93ce815bd413558f
https://github.com/Webiny/Hrc/blob/2594d645dd79a579916d90ec93ce815bd413558f/src/Webiny/Hrc/IndexStorage/FileSystem.php#L224-L242
236,052
Webiny/Hrc
src/Webiny/Hrc/IndexStorage/FileSystem.php
FileSystem.createFolderNameFromTags
private function createFolderNameFromTags(array $tags) { natsort($tags); $tagFolder = '_'; foreach ($tags as $t) { $tagFolder .= $t . '_'; } return $this->indexDir . $tagFolder . DIRECTORY_SEPARATOR; }
php
private function createFolderNameFromTags(array $tags) { natsort($tags); $tagFolder = '_'; foreach ($tags as $t) { $tagFolder .= $t . '_'; } return $this->indexDir . $tagFolder . DIRECTORY_SEPARATOR; }
[ "private", "function", "createFolderNameFromTags", "(", "array", "$", "tags", ")", "{", "natsort", "(", "$", "tags", ")", ";", "$", "tagFolder", "=", "'_'", ";", "foreach", "(", "$", "tags", "as", "$", "t", ")", "{", "$", "tagFolder", ".=", "$", "t", ".", "'_'", ";", "}", "return", "$", "this", "->", "indexDir", ".", "$", "tagFolder", ".", "DIRECTORY_SEPARATOR", ";", "}" ]
Based on the provided list of tags, a path to the root tags folder is created. @param array $tags @return string
[ "Based", "on", "the", "provided", "list", "of", "tags", "a", "path", "to", "the", "root", "tags", "folder", "is", "created", "." ]
2594d645dd79a579916d90ec93ce815bd413558f
https://github.com/Webiny/Hrc/blob/2594d645dd79a579916d90ec93ce815bd413558f/src/Webiny/Hrc/IndexStorage/FileSystem.php#L251-L260
236,053
jurchiks/commons
src/upload/UploadedFile.php
UploadedFile.getErrorMessage
public function getErrorMessage(): string { static $messages = [ UPLOAD_ERR_OK => 'Upload successful', UPLOAD_ERR_INI_SIZE => 'The size of the file exceeds the value of the "upload_max_filesize" directive in php.ini', UPLOAD_ERR_FORM_SIZE => 'The size of the file exceeds the value of the "MAX_FILE_SIZE" input in the HTML form', UPLOAD_ERR_PARTIAL => 'The file was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Temporary directory is missing', UPLOAD_ERR_CANT_WRITE => 'Failed to write the file to disk', UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload', ]; return $messages[$this->statusCode]; }
php
public function getErrorMessage(): string { static $messages = [ UPLOAD_ERR_OK => 'Upload successful', UPLOAD_ERR_INI_SIZE => 'The size of the file exceeds the value of the "upload_max_filesize" directive in php.ini', UPLOAD_ERR_FORM_SIZE => 'The size of the file exceeds the value of the "MAX_FILE_SIZE" input in the HTML form', UPLOAD_ERR_PARTIAL => 'The file was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Temporary directory is missing', UPLOAD_ERR_CANT_WRITE => 'Failed to write the file to disk', UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload', ]; return $messages[$this->statusCode]; }
[ "public", "function", "getErrorMessage", "(", ")", ":", "string", "{", "static", "$", "messages", "=", "[", "UPLOAD_ERR_OK", "=>", "'Upload successful'", ",", "UPLOAD_ERR_INI_SIZE", "=>", "'The size of the file exceeds the value of the \"upload_max_filesize\" directive in php.ini'", ",", "UPLOAD_ERR_FORM_SIZE", "=>", "'The size of the file exceeds the value of the \"MAX_FILE_SIZE\" input in the HTML form'", ",", "UPLOAD_ERR_PARTIAL", "=>", "'The file was only partially uploaded'", ",", "UPLOAD_ERR_NO_FILE", "=>", "'No file was uploaded'", ",", "UPLOAD_ERR_NO_TMP_DIR", "=>", "'Temporary directory is missing'", ",", "UPLOAD_ERR_CANT_WRITE", "=>", "'Failed to write the file to disk'", ",", "UPLOAD_ERR_EXTENSION", "=>", "'A PHP extension stopped the file upload'", ",", "]", ";", "return", "$", "messages", "[", "$", "this", "->", "statusCode", "]", ";", "}" ]
Get a human-readable error message of the upload status. Do not use this to check the upload status! @see getErrorCode @see getErrorConstant @see isValid @see http://php.net/manual/en/features.file-upload.errors.php
[ "Get", "a", "human", "-", "readable", "error", "message", "of", "the", "upload", "status", ".", "Do", "not", "use", "this", "to", "check", "the", "upload", "status!" ]
be9e1eca6a94380647160a882b8476bee3e4d8f8
https://github.com/jurchiks/commons/blob/be9e1eca6a94380647160a882b8476bee3e4d8f8/src/upload/UploadedFile.php#L135-L149
236,054
jurchiks/commons
src/upload/UploadedFile.php
UploadedFile.moveTo
public function moveTo(string $destination) { if (!$this->isValid()) { throw new FileMoveException('File was not uploaded successfully and thus cannot be moved'); } if ($this->hasBeenMoved) { throw new FileMoveException('Uploaded file has already been moved'); } if (is_dir($destination)) { $directory = $destination; $filename = $this->name; } else { $directory = dirname($destination); $filename = basename($destination); } if (!is_dir($directory)) { throw new FileMoveException($destination . ' - folder does not exist'); } if (!is_writable($directory)) { throw new FileMoveException($destination . ' - folder is not writable, check permissions'); } if (!move_uploaded_file($this->path, $directory . DIRECTORY_SEPARATOR . $filename)) { throw new FileMoveException('Failed to move uploaded file to ' . $destination); } $this->hasBeenMoved = true; return $directory . DIRECTORY_SEPARATOR . $filename; }
php
public function moveTo(string $destination) { if (!$this->isValid()) { throw new FileMoveException('File was not uploaded successfully and thus cannot be moved'); } if ($this->hasBeenMoved) { throw new FileMoveException('Uploaded file has already been moved'); } if (is_dir($destination)) { $directory = $destination; $filename = $this->name; } else { $directory = dirname($destination); $filename = basename($destination); } if (!is_dir($directory)) { throw new FileMoveException($destination . ' - folder does not exist'); } if (!is_writable($directory)) { throw new FileMoveException($destination . ' - folder is not writable, check permissions'); } if (!move_uploaded_file($this->path, $directory . DIRECTORY_SEPARATOR . $filename)) { throw new FileMoveException('Failed to move uploaded file to ' . $destination); } $this->hasBeenMoved = true; return $directory . DIRECTORY_SEPARATOR . $filename; }
[ "public", "function", "moveTo", "(", "string", "$", "destination", ")", "{", "if", "(", "!", "$", "this", "->", "isValid", "(", ")", ")", "{", "throw", "new", "FileMoveException", "(", "'File was not uploaded successfully and thus cannot be moved'", ")", ";", "}", "if", "(", "$", "this", "->", "hasBeenMoved", ")", "{", "throw", "new", "FileMoveException", "(", "'Uploaded file has already been moved'", ")", ";", "}", "if", "(", "is_dir", "(", "$", "destination", ")", ")", "{", "$", "directory", "=", "$", "destination", ";", "$", "filename", "=", "$", "this", "->", "name", ";", "}", "else", "{", "$", "directory", "=", "dirname", "(", "$", "destination", ")", ";", "$", "filename", "=", "basename", "(", "$", "destination", ")", ";", "}", "if", "(", "!", "is_dir", "(", "$", "directory", ")", ")", "{", "throw", "new", "FileMoveException", "(", "$", "destination", ".", "' - folder does not exist'", ")", ";", "}", "if", "(", "!", "is_writable", "(", "$", "directory", ")", ")", "{", "throw", "new", "FileMoveException", "(", "$", "destination", ".", "' - folder is not writable, check permissions'", ")", ";", "}", "if", "(", "!", "move_uploaded_file", "(", "$", "this", "->", "path", ",", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "$", "filename", ")", ")", "{", "throw", "new", "FileMoveException", "(", "'Failed to move uploaded file to '", ".", "$", "destination", ")", ";", "}", "$", "this", "->", "hasBeenMoved", "=", "true", ";", "return", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "$", "filename", ";", "}" ]
Move the newly uploaded file to another directory and optionally rename it. This method can only be called once, subsequent calls will throw an exception. @param string $destination : the absolute path to where to move the file; if this does not include the file name, the original file name is used @return string the absolute path to the moved file @throws FileMoveException if anything is wrong or if attempting to move the file more than once
[ "Move", "the", "newly", "uploaded", "file", "to", "another", "directory", "and", "optionally", "rename", "it", ".", "This", "method", "can", "only", "be", "called", "once", "subsequent", "calls", "will", "throw", "an", "exception", "." ]
be9e1eca6a94380647160a882b8476bee3e4d8f8
https://github.com/jurchiks/commons/blob/be9e1eca6a94380647160a882b8476bee3e4d8f8/src/upload/UploadedFile.php#L160-L201
236,055
hamjoint/mustard-commerce
src/lib/Http/Controllers/InventoryController.php
InventoryController.getBought
public function getBought() { $items = Item::join('seller') ->leftJoin('purchases') ->where('purchases.user_id', Auth::user()->userId); if (mustard_loaded('auctions')) { $items->leftJoin('winningBid') ->orWhere('bids.user_id', Auth::user()->userId); } $table = new InventoryBought($items); return view('mustard::inventory.bought', [ 'table' => $table, 'items' => $table->paginate(), ]); }
php
public function getBought() { $items = Item::join('seller') ->leftJoin('purchases') ->where('purchases.user_id', Auth::user()->userId); if (mustard_loaded('auctions')) { $items->leftJoin('winningBid') ->orWhere('bids.user_id', Auth::user()->userId); } $table = new InventoryBought($items); return view('mustard::inventory.bought', [ 'table' => $table, 'items' => $table->paginate(), ]); }
[ "public", "function", "getBought", "(", ")", "{", "$", "items", "=", "Item", "::", "join", "(", "'seller'", ")", "->", "leftJoin", "(", "'purchases'", ")", "->", "where", "(", "'purchases.user_id'", ",", "Auth", "::", "user", "(", ")", "->", "userId", ")", ";", "if", "(", "mustard_loaded", "(", "'auctions'", ")", ")", "{", "$", "items", "->", "leftJoin", "(", "'winningBid'", ")", "->", "orWhere", "(", "'bids.user_id'", ",", "Auth", "::", "user", "(", ")", "->", "userId", ")", ";", "}", "$", "table", "=", "new", "InventoryBought", "(", "$", "items", ")", ";", "return", "view", "(", "'mustard::inventory.bought'", ",", "[", "'table'", "=>", "$", "table", ",", "'items'", "=>", "$", "table", "->", "paginate", "(", ")", ",", "]", ")", ";", "}" ]
Return the inventory bought items view. @return \Illuminate\View\View
[ "Return", "the", "inventory", "bought", "items", "view", "." ]
886caeb5a88d827c8e9201e90020b64651dd87ad
https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Http/Controllers/InventoryController.php#L40-L57
236,056
hamjoint/mustard-commerce
src/lib/Http/Controllers/InventoryController.php
InventoryController.getSold
public function getSold() { $items = Auth::user()->items() ->leftJoin('purchases') ->where(function ($query) { $query->typeFixed()->whereNotNull('purchases.purchase_id'); }); // Allows sorting by buyer username $items->getBaseQuery() ->join('users', 'users.user_id', '=', 'purchases.user_id'); if (mustard_loaded('auctions')) { $items->leftJoin('winningBid') ->orWhere(function ($query) { $query->typeAuction()->whereNotNull('bids.bid_id'); }); } $table = new InventorySold($items); return view('mustard::inventory.sold', [ 'table' => $table, 'items' => $table->paginate(), ]); }
php
public function getSold() { $items = Auth::user()->items() ->leftJoin('purchases') ->where(function ($query) { $query->typeFixed()->whereNotNull('purchases.purchase_id'); }); // Allows sorting by buyer username $items->getBaseQuery() ->join('users', 'users.user_id', '=', 'purchases.user_id'); if (mustard_loaded('auctions')) { $items->leftJoin('winningBid') ->orWhere(function ($query) { $query->typeAuction()->whereNotNull('bids.bid_id'); }); } $table = new InventorySold($items); return view('mustard::inventory.sold', [ 'table' => $table, 'items' => $table->paginate(), ]); }
[ "public", "function", "getSold", "(", ")", "{", "$", "items", "=", "Auth", "::", "user", "(", ")", "->", "items", "(", ")", "->", "leftJoin", "(", "'purchases'", ")", "->", "where", "(", "function", "(", "$", "query", ")", "{", "$", "query", "->", "typeFixed", "(", ")", "->", "whereNotNull", "(", "'purchases.purchase_id'", ")", ";", "}", ")", ";", "// Allows sorting by buyer username", "$", "items", "->", "getBaseQuery", "(", ")", "->", "join", "(", "'users'", ",", "'users.user_id'", ",", "'='", ",", "'purchases.user_id'", ")", ";", "if", "(", "mustard_loaded", "(", "'auctions'", ")", ")", "{", "$", "items", "->", "leftJoin", "(", "'winningBid'", ")", "->", "orWhere", "(", "function", "(", "$", "query", ")", "{", "$", "query", "->", "typeAuction", "(", ")", "->", "whereNotNull", "(", "'bids.bid_id'", ")", ";", "}", ")", ";", "}", "$", "table", "=", "new", "InventorySold", "(", "$", "items", ")", ";", "return", "view", "(", "'mustard::inventory.sold'", ",", "[", "'table'", "=>", "$", "table", ",", "'items'", "=>", "$", "table", "->", "paginate", "(", ")", ",", "]", ")", ";", "}" ]
Return the inventory sold items view. @return \Illuminate\View\View
[ "Return", "the", "inventory", "sold", "items", "view", "." ]
886caeb5a88d827c8e9201e90020b64651dd87ad
https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Http/Controllers/InventoryController.php#L64-L89
236,057
hamjoint/mustard-commerce
src/lib/Http/Controllers/InventoryController.php
InventoryController.getUnsold
public function getUnsold() { $items = Auth::user()->items() ->with('purchases') ->where(function ($query) { $query->has('purchases', 0) ->where('end_date', '<', time()) ->where('auction', false) ->orWhere(function ($query) { $query->where('auction', true) ->where('end_date', '<', time()) ->where('winning_bid_id', 0); }); }); $table = new InventoryUnsold($items); return view('mustard::inventory.unsold', [ 'table' => $table, 'items' => $table->paginate(), ]); }
php
public function getUnsold() { $items = Auth::user()->items() ->with('purchases') ->where(function ($query) { $query->has('purchases', 0) ->where('end_date', '<', time()) ->where('auction', false) ->orWhere(function ($query) { $query->where('auction', true) ->where('end_date', '<', time()) ->where('winning_bid_id', 0); }); }); $table = new InventoryUnsold($items); return view('mustard::inventory.unsold', [ 'table' => $table, 'items' => $table->paginate(), ]); }
[ "public", "function", "getUnsold", "(", ")", "{", "$", "items", "=", "Auth", "::", "user", "(", ")", "->", "items", "(", ")", "->", "with", "(", "'purchases'", ")", "->", "where", "(", "function", "(", "$", "query", ")", "{", "$", "query", "->", "has", "(", "'purchases'", ",", "0", ")", "->", "where", "(", "'end_date'", ",", "'<'", ",", "time", "(", ")", ")", "->", "where", "(", "'auction'", ",", "false", ")", "->", "orWhere", "(", "function", "(", "$", "query", ")", "{", "$", "query", "->", "where", "(", "'auction'", ",", "true", ")", "->", "where", "(", "'end_date'", ",", "'<'", ",", "time", "(", ")", ")", "->", "where", "(", "'winning_bid_id'", ",", "0", ")", ";", "}", ")", ";", "}", ")", ";", "$", "table", "=", "new", "InventoryUnsold", "(", "$", "items", ")", ";", "return", "view", "(", "'mustard::inventory.unsold'", ",", "[", "'table'", "=>", "$", "table", ",", "'items'", "=>", "$", "table", "->", "paginate", "(", ")", ",", "]", ")", ";", "}" ]
Return the inventory unsold items view. @return \Illuminate\View\View
[ "Return", "the", "inventory", "unsold", "items", "view", "." ]
886caeb5a88d827c8e9201e90020b64651dd87ad
https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Http/Controllers/InventoryController.php#L96-L117
236,058
webriq/core
module/User/src/Grid/User/Authentication/AuthenticationServiceFactory.php
AuthenticationServiceFactory.createService
public function createService( ServiceLocatorInterface $services ) { $manager = $services->get( 'Zend\Session\ManagerInterface' ); $storage = new Session( null, null, $manager ); return new AuthenticationService( $services, $storage ); }
php
public function createService( ServiceLocatorInterface $services ) { $manager = $services->get( 'Zend\Session\ManagerInterface' ); $storage = new Session( null, null, $manager ); return new AuthenticationService( $services, $storage ); }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "services", ")", "{", "$", "manager", "=", "$", "services", "->", "get", "(", "'Zend\\Session\\ManagerInterface'", ")", ";", "$", "storage", "=", "new", "Session", "(", "null", ",", "null", ",", "$", "manager", ")", ";", "return", "new", "AuthenticationService", "(", "$", "services", ",", "$", "storage", ")", ";", "}" ]
Create authentication service @param ServiceLocatorInterface $services @return AuthenticationService
[ "Create", "authentication", "service" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/User/src/Grid/User/Authentication/AuthenticationServiceFactory.php#L23-L28
236,059
arvici/framework
src/Arvici/Heart/Router/Router.php
Router.addMiddleware
public function addMiddleware(Middleware $middleware) { $group = $middleware->getGroup(); if (! isset($this->middleware[$group])) { $this->middleware[$group] = array( 'before' => array(), 'after' => array() ); } $this->middleware[$group][$middleware->getPosition()][] = &$middleware; }
php
public function addMiddleware(Middleware $middleware) { $group = $middleware->getGroup(); if (! isset($this->middleware[$group])) { $this->middleware[$group] = array( 'before' => array(), 'after' => array() ); } $this->middleware[$group][$middleware->getPosition()][] = &$middleware; }
[ "public", "function", "addMiddleware", "(", "Middleware", "$", "middleware", ")", "{", "$", "group", "=", "$", "middleware", "->", "getGroup", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "middleware", "[", "$", "group", "]", ")", ")", "{", "$", "this", "->", "middleware", "[", "$", "group", "]", "=", "array", "(", "'before'", "=>", "array", "(", ")", ",", "'after'", "=>", "array", "(", ")", ")", ";", "}", "$", "this", "->", "middleware", "[", "$", "group", "]", "[", "$", "middleware", "->", "getPosition", "(", ")", "]", "[", "]", "=", "&", "$", "middleware", ";", "}" ]
Add middleware trigger to registry. @param Middleware $middleware
[ "Add", "middleware", "trigger", "to", "registry", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Router/Router.php#L130-L141
236,060
arvici/framework
src/Arvici/Heart/Router/Router.php
Router.executeRoute
private function executeRoute(Route &$route, $method, $force = false) { $continue = true; if (! $force) { $continue = $this->executeRouteMiddleware($route, 'before', $method); } if ($continue === true) { $route->execute($this->compiled); } if (! $force) { $this->executeRouteMiddleware($route, 'after', $method); } }
php
private function executeRoute(Route &$route, $method, $force = false) { $continue = true; if (! $force) { $continue = $this->executeRouteMiddleware($route, 'before', $method); } if ($continue === true) { $route->execute($this->compiled); } if (! $force) { $this->executeRouteMiddleware($route, 'after', $method); } }
[ "private", "function", "executeRoute", "(", "Route", "&", "$", "route", ",", "$", "method", ",", "$", "force", "=", "false", ")", "{", "$", "continue", "=", "true", ";", "if", "(", "!", "$", "force", ")", "{", "$", "continue", "=", "$", "this", "->", "executeRouteMiddleware", "(", "$", "route", ",", "'before'", ",", "$", "method", ")", ";", "}", "if", "(", "$", "continue", "===", "true", ")", "{", "$", "route", "->", "execute", "(", "$", "this", "->", "compiled", ")", ";", "}", "if", "(", "!", "$", "force", ")", "{", "$", "this", "->", "executeRouteMiddleware", "(", "$", "route", ",", "'after'", ",", "$", "method", ")", ";", "}", "}" ]
Will try to match parameters and execute the callback. Will also trigger middleware. @param Route $route @param string $method Method of request. @param bool $force true for skipping middleware. Could be bad to do!
[ "Will", "try", "to", "match", "parameters", "and", "execute", "the", "callback", ".", "Will", "also", "trigger", "middleware", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Router/Router.php#L184-L198
236,061
arvici/framework
src/Arvici/Heart/Router/Router.php
Router.executeRouteMiddleware
private function executeRouteMiddleware(Route &$route, $position, $method) { $method = strtoupper($method); /** @var Middleware[] $middleware */ $middleware = array(); $continue = true; // Get all global middleware's. if (isset( $this->middleware['global'], $this->middleware['global'][$position]) && count($this->middleware['global'][$position]) > 0) { $middleware = array_merge($middleware, $this->middleware['global'][$position]); } // Group middleware if defined. if ($route->getGroup() !== null && isset($this->middleware[$route->getGroup()], $this->middleware[$route->getGroup()][$position]) && count($this->middleware[$route->getGroup()][$position]) > 0) { $middleware = array_merge($middleware, $this->middleware[$route->getGroup()][$position]); } // Will execute all middleware in order..: foreach ($middleware as $trigger) { if (count($trigger->getMethods()) === 0 || in_array(strtoupper($method), $trigger->getMethods())) { if ($this->executeMiddleware($trigger) === false) { $continue = false; } } } return $continue; }
php
private function executeRouteMiddleware(Route &$route, $position, $method) { $method = strtoupper($method); /** @var Middleware[] $middleware */ $middleware = array(); $continue = true; // Get all global middleware's. if (isset( $this->middleware['global'], $this->middleware['global'][$position]) && count($this->middleware['global'][$position]) > 0) { $middleware = array_merge($middleware, $this->middleware['global'][$position]); } // Group middleware if defined. if ($route->getGroup() !== null && isset($this->middleware[$route->getGroup()], $this->middleware[$route->getGroup()][$position]) && count($this->middleware[$route->getGroup()][$position]) > 0) { $middleware = array_merge($middleware, $this->middleware[$route->getGroup()][$position]); } // Will execute all middleware in order..: foreach ($middleware as $trigger) { if (count($trigger->getMethods()) === 0 || in_array(strtoupper($method), $trigger->getMethods())) { if ($this->executeMiddleware($trigger) === false) { $continue = false; } } } return $continue; }
[ "private", "function", "executeRouteMiddleware", "(", "Route", "&", "$", "route", ",", "$", "position", ",", "$", "method", ")", "{", "$", "method", "=", "strtoupper", "(", "$", "method", ")", ";", "/** @var Middleware[] $middleware */", "$", "middleware", "=", "array", "(", ")", ";", "$", "continue", "=", "true", ";", "// Get all global middleware's.", "if", "(", "isset", "(", "$", "this", "->", "middleware", "[", "'global'", "]", ",", "$", "this", "->", "middleware", "[", "'global'", "]", "[", "$", "position", "]", ")", "&&", "count", "(", "$", "this", "->", "middleware", "[", "'global'", "]", "[", "$", "position", "]", ")", ">", "0", ")", "{", "$", "middleware", "=", "array_merge", "(", "$", "middleware", ",", "$", "this", "->", "middleware", "[", "'global'", "]", "[", "$", "position", "]", ")", ";", "}", "// Group middleware if defined.", "if", "(", "$", "route", "->", "getGroup", "(", ")", "!==", "null", "&&", "isset", "(", "$", "this", "->", "middleware", "[", "$", "route", "->", "getGroup", "(", ")", "]", ",", "$", "this", "->", "middleware", "[", "$", "route", "->", "getGroup", "(", ")", "]", "[", "$", "position", "]", ")", "&&", "count", "(", "$", "this", "->", "middleware", "[", "$", "route", "->", "getGroup", "(", ")", "]", "[", "$", "position", "]", ")", ">", "0", ")", "{", "$", "middleware", "=", "array_merge", "(", "$", "middleware", ",", "$", "this", "->", "middleware", "[", "$", "route", "->", "getGroup", "(", ")", "]", "[", "$", "position", "]", ")", ";", "}", "// Will execute all middleware in order..:", "foreach", "(", "$", "middleware", "as", "$", "trigger", ")", "{", "if", "(", "count", "(", "$", "trigger", "->", "getMethods", "(", ")", ")", "===", "0", "||", "in_array", "(", "strtoupper", "(", "$", "method", ")", ",", "$", "trigger", "->", "getMethods", "(", ")", ")", ")", "{", "if", "(", "$", "this", "->", "executeMiddleware", "(", "$", "trigger", ")", "===", "false", ")", "{", "$", "continue", "=", "false", ";", "}", "}", "}", "return", "$", "continue", ";", "}" ]
Execute middleware found for the route. @param Route $route @param string $position 'before' or 'after' @param string $method @return bool Continue?
[ "Execute", "middleware", "found", "for", "the", "route", "." ]
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Router/Router.php#L211-L250
236,062
teamelf/ext-mailer
src/Driver.php
Driver.subject
public function subject($subject) { $name = Config::get('name'); $subject = '[' . $name . '] ' . $subject; /** * strange subject encode error * occurred when there's both chinese and english * solution see: https://github.com/swiftmailer/swiftmailer/issues/665 */ $subject = '=?utf-8?B?'.base64_encode($subject).'?='; $this->message->setSubject($subject); return $this; }
php
public function subject($subject) { $name = Config::get('name'); $subject = '[' . $name . '] ' . $subject; /** * strange subject encode error * occurred when there's both chinese and english * solution see: https://github.com/swiftmailer/swiftmailer/issues/665 */ $subject = '=?utf-8?B?'.base64_encode($subject).'?='; $this->message->setSubject($subject); return $this; }
[ "public", "function", "subject", "(", "$", "subject", ")", "{", "$", "name", "=", "Config", "::", "get", "(", "'name'", ")", ";", "$", "subject", "=", "'['", ".", "$", "name", ".", "'] '", ".", "$", "subject", ";", "/**\n * strange subject encode error\n * occurred when there's both chinese and english\n * solution see: https://github.com/swiftmailer/swiftmailer/issues/665\n */", "$", "subject", "=", "'=?utf-8?B?'", ".", "base64_encode", "(", "$", "subject", ")", ".", "'?='", ";", "$", "this", "->", "message", "->", "setSubject", "(", "$", "subject", ")", ";", "return", "$", "this", ";", "}" ]
set message subject @param string $subject @return $this
[ "set", "message", "subject" ]
46d88f5e3dd11b3631a1fed2cd7a7dc46698cc99
https://github.com/teamelf/ext-mailer/blob/46d88f5e3dd11b3631a1fed2cd7a7dc46698cc99/src/Driver.php#L92-L104
236,063
teamelf/ext-mailer
src/Driver.php
Driver.body
public function body($body, $contentType = null) { $this->message->setBody($body, $contentType); return $this; }
php
public function body($body, $contentType = null) { $this->message->setBody($body, $contentType); return $this; }
[ "public", "function", "body", "(", "$", "body", ",", "$", "contentType", "=", "null", ")", "{", "$", "this", "->", "message", "->", "setBody", "(", "$", "body", ",", "$", "contentType", ")", ";", "return", "$", "this", ";", "}" ]
set message body @param string $body @param string $contentType @return $this
[ "set", "message", "body" ]
46d88f5e3dd11b3631a1fed2cd7a7dc46698cc99
https://github.com/teamelf/ext-mailer/blob/46d88f5e3dd11b3631a1fed2cd7a7dc46698cc99/src/Driver.php#L113-L117
236,064
teamelf/ext-mailer
src/Driver.php
Driver.view
public function view($template, $data = []) { $html = ViewService::getEngine()->render($template, $data); $this->message->setBody($html, 'text/html'); return $this; }
php
public function view($template, $data = []) { $html = ViewService::getEngine()->render($template, $data); $this->message->setBody($html, 'text/html'); return $this; }
[ "public", "function", "view", "(", "$", "template", ",", "$", "data", "=", "[", "]", ")", "{", "$", "html", "=", "ViewService", "::", "getEngine", "(", ")", "->", "render", "(", "$", "template", ",", "$", "data", ")", ";", "$", "this", "->", "message", "->", "setBody", "(", "$", "html", ",", "'text/html'", ")", ";", "return", "$", "this", ";", "}" ]
set message body with twig template @param string $template @param array $data @return $this
[ "set", "message", "body", "with", "twig", "template" ]
46d88f5e3dd11b3631a1fed2cd7a7dc46698cc99
https://github.com/teamelf/ext-mailer/blob/46d88f5e3dd11b3631a1fed2cd7a7dc46698cc99/src/Driver.php#L126-L131
236,065
nicholasnet/common
src/Utils/Collection.php
Collection.median
public function median($key = null) { $count = $this->count(); if ($count == 0) { return; } $values = $this->with(isset($key) ? $this->pluck($key) : $this)->sort()->values(); $middle = (int) ($count / 2); if ($count % 2) { return $values->get($middle); } return (new static([$values->get($middle - 1), $values->get($middle)]))->average(); }
php
public function median($key = null) { $count = $this->count(); if ($count == 0) { return; } $values = $this->with(isset($key) ? $this->pluck($key) : $this)->sort()->values(); $middle = (int) ($count / 2); if ($count % 2) { return $values->get($middle); } return (new static([$values->get($middle - 1), $values->get($middle)]))->average(); }
[ "public", "function", "median", "(", "$", "key", "=", "null", ")", "{", "$", "count", "=", "$", "this", "->", "count", "(", ")", ";", "if", "(", "$", "count", "==", "0", ")", "{", "return", ";", "}", "$", "values", "=", "$", "this", "->", "with", "(", "isset", "(", "$", "key", ")", "?", "$", "this", "->", "pluck", "(", "$", "key", ")", ":", "$", "this", ")", "->", "sort", "(", ")", "->", "values", "(", ")", ";", "$", "middle", "=", "(", "int", ")", "(", "$", "count", "/", "2", ")", ";", "if", "(", "$", "count", "%", "2", ")", "{", "return", "$", "values", "->", "get", "(", "$", "middle", ")", ";", "}", "return", "(", "new", "static", "(", "[", "$", "values", "->", "get", "(", "$", "middle", "-", "1", ")", ",", "$", "values", "->", "get", "(", "$", "middle", ")", "]", ")", ")", "->", "average", "(", ")", ";", "}" ]
Get the median of a given key. @param null $key @return mixed
[ "Get", "the", "median", "of", "a", "given", "key", "." ]
8b948592ecf2a3a9060d05d04f12e30058dabf3f
https://github.com/nicholasnet/common/blob/8b948592ecf2a3a9060d05d04f12e30058dabf3f/src/Utils/Collection.php#L114-L132
236,066
nicholasnet/common
src/Utils/Collection.php
Collection.containsStrict
public function containsStrict($key, $value = null) { if (func_num_args() == 2) { return $this->contains(function ($item) use ($key, $value) { return ArrayHelper::dataGet($item, $key) === $value; }); } if ($this->useAsCallable($key)) { return !is_null($this->first($key)); } return in_array($key, $this->items, true); }
php
public function containsStrict($key, $value = null) { if (func_num_args() == 2) { return $this->contains(function ($item) use ($key, $value) { return ArrayHelper::dataGet($item, $key) === $value; }); } if ($this->useAsCallable($key)) { return !is_null($this->first($key)); } return in_array($key, $this->items, true); }
[ "public", "function", "containsStrict", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "==", "2", ")", "{", "return", "$", "this", "->", "contains", "(", "function", "(", "$", "item", ")", "use", "(", "$", "key", ",", "$", "value", ")", "{", "return", "ArrayHelper", "::", "dataGet", "(", "$", "item", ",", "$", "key", ")", "===", "$", "value", ";", "}", ")", ";", "}", "if", "(", "$", "this", "->", "useAsCallable", "(", "$", "key", ")", ")", "{", "return", "!", "is_null", "(", "$", "this", "->", "first", "(", "$", "key", ")", ")", ";", "}", "return", "in_array", "(", "$", "key", ",", "$", "this", "->", "items", ",", "true", ")", ";", "}" ]
Determine if an item exists in the collection using strict comparison. @param mixed $key @param mixed $value @return bool
[ "Determine", "if", "an", "item", "exists", "in", "the", "collection", "using", "strict", "comparison", "." ]
8b948592ecf2a3a9060d05d04f12e30058dabf3f
https://github.com/nicholasnet/common/blob/8b948592ecf2a3a9060d05d04f12e30058dabf3f/src/Utils/Collection.php#L219-L235
236,067
PublisherHub/Publisher
src/Publisher/Selector/Parameter/AbstractSelector.php
AbstractSelector.doRequest
protected final function doRequest() { $stepId = count($this->results); $request = $this->steps[$stepId]($this->results); $response = $this->requestor->doRequest($request); $this->checkGotResponse($response); $this->saveResult($stepId, $response); }
php
protected final function doRequest() { $stepId = count($this->results); $request = $this->steps[$stepId]($this->results); $response = $this->requestor->doRequest($request); $this->checkGotResponse($response); $this->saveResult($stepId, $response); }
[ "protected", "final", "function", "doRequest", "(", ")", "{", "$", "stepId", "=", "count", "(", "$", "this", "->", "results", ")", ";", "$", "request", "=", "$", "this", "->", "steps", "[", "$", "stepId", "]", "(", "$", "this", "->", "results", ")", ";", "$", "response", "=", "$", "this", "->", "requestor", "->", "doRequest", "(", "$", "request", ")", ";", "$", "this", "->", "checkGotResponse", "(", "$", "response", ")", ";", "$", "this", "->", "saveResult", "(", "$", "stepId", ",", "$", "response", ")", ";", "}" ]
Request and store the choices for the current step. @return void
[ "Request", "and", "store", "the", "choices", "for", "the", "current", "step", "." ]
954e05118be9956e0c8631e44958af4ba42606b3
https://github.com/PublisherHub/Publisher/blob/954e05118be9956e0c8631e44958af4ba42606b3/src/Publisher/Selector/Parameter/AbstractSelector.php#L187-L194
236,068
mcfedr/twitterpushbundle
src/Mcfedr/TwitterPushBundle/Service/TweetPusher.php
TweetPusher.pushTweet
public function pushTweet($tweet) { if ($this->maxPushesPerHour > 0 && $this->cache) { $hourAgo = new \DateTime('- 1 hour'); /** @var \DateTime[] $tweetTimes */ $tweetTimes = $this->cache->fetch(static::CACHE_KEY) ?: []; foreach ($tweetTimes as $k => $time) { if ($time < $hourAgo) { unset($tweetTimes[$k]); } } if (($count = count($tweetTimes)) >= $this->maxPushesPerHour) { throw new MaxPushesPerHourException("Cannot send push, $count have already been sent. The limit is {$this->maxPushesPerHour}"); } $tweetTimes[] = new \DateTime(); $this->cache->save(static::CACHE_KEY, $tweetTimes, 3600); } $m = $this->getMessageForTweet($tweet); if ($this->topicArn) { $this->messages->send($m, $this->topicArn); } else { $this->messages->broadcast($m); } }
php
public function pushTweet($tweet) { if ($this->maxPushesPerHour > 0 && $this->cache) { $hourAgo = new \DateTime('- 1 hour'); /** @var \DateTime[] $tweetTimes */ $tweetTimes = $this->cache->fetch(static::CACHE_KEY) ?: []; foreach ($tweetTimes as $k => $time) { if ($time < $hourAgo) { unset($tweetTimes[$k]); } } if (($count = count($tweetTimes)) >= $this->maxPushesPerHour) { throw new MaxPushesPerHourException("Cannot send push, $count have already been sent. The limit is {$this->maxPushesPerHour}"); } $tweetTimes[] = new \DateTime(); $this->cache->save(static::CACHE_KEY, $tweetTimes, 3600); } $m = $this->getMessageForTweet($tweet); if ($this->topicArn) { $this->messages->send($m, $this->topicArn); } else { $this->messages->broadcast($m); } }
[ "public", "function", "pushTweet", "(", "$", "tweet", ")", "{", "if", "(", "$", "this", "->", "maxPushesPerHour", ">", "0", "&&", "$", "this", "->", "cache", ")", "{", "$", "hourAgo", "=", "new", "\\", "DateTime", "(", "'- 1 hour'", ")", ";", "/** @var \\DateTime[] $tweetTimes */", "$", "tweetTimes", "=", "$", "this", "->", "cache", "->", "fetch", "(", "static", "::", "CACHE_KEY", ")", "?", ":", "[", "]", ";", "foreach", "(", "$", "tweetTimes", "as", "$", "k", "=>", "$", "time", ")", "{", "if", "(", "$", "time", "<", "$", "hourAgo", ")", "{", "unset", "(", "$", "tweetTimes", "[", "$", "k", "]", ")", ";", "}", "}", "if", "(", "(", "$", "count", "=", "count", "(", "$", "tweetTimes", ")", ")", ">=", "$", "this", "->", "maxPushesPerHour", ")", "{", "throw", "new", "MaxPushesPerHourException", "(", "\"Cannot send push, $count have already been sent. The limit is {$this->maxPushesPerHour}\"", ")", ";", "}", "$", "tweetTimes", "[", "]", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "this", "->", "cache", "->", "save", "(", "static", "::", "CACHE_KEY", ",", "$", "tweetTimes", ",", "3600", ")", ";", "}", "$", "m", "=", "$", "this", "->", "getMessageForTweet", "(", "$", "tweet", ")", ";", "if", "(", "$", "this", "->", "topicArn", ")", "{", "$", "this", "->", "messages", "->", "send", "(", "$", "m", ",", "$", "this", "->", "topicArn", ")", ";", "}", "else", "{", "$", "this", "->", "messages", "->", "broadcast", "(", "$", "m", ")", ";", "}", "}" ]
Send a tweet to everyone @param array $tweet @throws MaxPushesPerHourException @throws \Mcfedr\AwsPushBundle\Exception\PlatformNotConfiguredException
[ "Send", "a", "tweet", "to", "everyone" ]
f18de2d69561f6b9a2d3dda60a1d8f5a230ca6c8
https://github.com/mcfedr/twitterpushbundle/blob/f18de2d69561f6b9a2d3dda60a1d8f5a230ca6c8/src/Mcfedr/TwitterPushBundle/Service/TweetPusher.php#L74-L99
236,069
movicon/movicon-http
src/http/HttpView.php
HttpView.printDocument
public function printDocument() { header("Content-Type: {$this->_contentType}; {$this->_charset}"); try { $this->controller->processRequest(); } catch (Exception $e) { $message = substr( preg_replace('/\s+/', ' ', $e->getMessage()), 0, 150 ); header("HTTP/1.0 400 $message"); throw $e; } echo $this->getDocument(); }
php
public function printDocument() { header("Content-Type: {$this->_contentType}; {$this->_charset}"); try { $this->controller->processRequest(); } catch (Exception $e) { $message = substr( preg_replace('/\s+/', ' ', $e->getMessage()), 0, 150 ); header("HTTP/1.0 400 $message"); throw $e; } echo $this->getDocument(); }
[ "public", "function", "printDocument", "(", ")", "{", "header", "(", "\"Content-Type: {$this->_contentType}; {$this->_charset}\"", ")", ";", "try", "{", "$", "this", "->", "controller", "->", "processRequest", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "message", "=", "substr", "(", "preg_replace", "(", "'/\\s+/'", ",", "' '", ",", "$", "e", "->", "getMessage", "(", ")", ")", ",", "0", ",", "150", ")", ";", "header", "(", "\"HTTP/1.0 400 $message\"", ")", ";", "throw", "$", "e", ";", "}", "echo", "$", "this", "->", "getDocument", "(", ")", ";", "}" ]
Prints the document. Returns a 'client exception' if an exception has occurred. @return void
[ "Prints", "the", "document", "." ]
ae9e4aa763c52f272c628fef0ec4496478312355
https://github.com/movicon/movicon-http/blob/ae9e4aa763c52f272c628fef0ec4496478312355/src/http/HttpView.php#L46-L61
236,070
christianklisch/phpcache
PHPCache.class.php
PHPCache.getConfig
public function getConfig($name) { return isset($this->settings[$name]) ? $this->settings[$name] : null; }
php
public function getConfig($name) { return isset($this->settings[$name]) ? $this->settings[$name] : null; }
[ "public", "function", "getConfig", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "settings", "[", "$", "name", "]", ")", "?", "$", "this", "->", "settings", "[", "$", "name", "]", ":", "null", ";", "}" ]
Read and Write config @param $name setting name @return string
[ "Read", "and", "Write", "config" ]
3fad52b670f0f00d7edd16c3357fb64cada24366
https://github.com/christianklisch/phpcache/blob/3fad52b670f0f00d7edd16c3357fb64cada24366/PHPCache.class.php#L81-L83
236,071
christianklisch/phpcache
PHPCache.class.php
PHPCache.cacheVal
public function cacheVal($value, $id = null) { if ($id == null) { if (is_object($value)) $id = $this->getIDfromOjb($value); if ($id == null && $this->getConfig('debug')) { echo "no caching key"; return $value; } } $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id); $cachetime = $this->getConfig('cacheTime'); if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) { $ser = file_get_contents($cachefile); $val = bzdecompress(unserialize($ser)); return $val; } else { $ser = bzcompress(serialize($value)); file_put_contents($cachefile, $ser); return $value; } if ($this->getConfig('debug')) echo "no caching"; }
php
public function cacheVal($value, $id = null) { if ($id == null) { if (is_object($value)) $id = $this->getIDfromOjb($value); if ($id == null && $this->getConfig('debug')) { echo "no caching key"; return $value; } } $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id); $cachetime = $this->getConfig('cacheTime'); if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) { $ser = file_get_contents($cachefile); $val = bzdecompress(unserialize($ser)); return $val; } else { $ser = bzcompress(serialize($value)); file_put_contents($cachefile, $ser); return $value; } if ($this->getConfig('debug')) echo "no caching"; }
[ "public", "function", "cacheVal", "(", "$", "value", ",", "$", "id", "=", "null", ")", "{", "if", "(", "$", "id", "==", "null", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "$", "id", "=", "$", "this", "->", "getIDfromOjb", "(", "$", "value", ")", ";", "if", "(", "$", "id", "==", "null", "&&", "$", "this", "->", "getConfig", "(", "'debug'", ")", ")", "{", "echo", "\"no caching key\"", ";", "return", "$", "value", ";", "}", "}", "$", "cachefile", "=", "$", "this", "->", "getConfig", "(", "'cacheDir'", ")", ".", "'/'", ".", "utf8_decode", "(", "$", "id", ")", ";", "$", "cachetime", "=", "$", "this", "->", "getConfig", "(", "'cacheTime'", ")", ";", "if", "(", "file_exists", "(", "$", "cachefile", ")", "&&", "time", "(", ")", "-", "$", "cachetime", "<", "fileatime", "(", "$", "cachefile", ")", ")", "{", "$", "ser", "=", "file_get_contents", "(", "$", "cachefile", ")", ";", "$", "val", "=", "bzdecompress", "(", "unserialize", "(", "$", "ser", ")", ")", ";", "return", "$", "val", ";", "}", "else", "{", "$", "ser", "=", "bzcompress", "(", "serialize", "(", "$", "value", ")", ")", ";", "file_put_contents", "(", "$", "cachefile", ",", "$", "ser", ")", ";", "return", "$", "value", ";", "}", "if", "(", "$", "this", "->", "getConfig", "(", "'debug'", ")", ")", "echo", "\"no caching\"", ";", "}" ]
get cached value in time or return value @param $value value or object to cache @param $id key for cache @return object
[ "get", "cached", "value", "in", "time", "or", "return", "value" ]
3fad52b670f0f00d7edd16c3357fb64cada24366
https://github.com/christianklisch/phpcache/blob/3fad52b670f0f00d7edd16c3357fb64cada24366/PHPCache.class.php#L103-L129
236,072
christianklisch/phpcache
PHPCache.class.php
PHPCache.cacheFun
public function cacheFun($function) { if ($this->getConfig('debug') && !is_callable($function)) echo "no valid function"; $r = new ReflectionFunction($function); $id = null; foreach ($r->getStaticVariables() as $key => $var) { if ($key == 'key') $id = $var; } if (is_object($id)) $id = $this->getIDfromOjb($id); if ($id == null && $this->getConfig('debug')) { echo "no caching key"; return $function(); } $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id); $cachetime = $this->getConfig('cacheTime'); if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) { $ser = file_get_contents($cachefile); $val = bzdecompress(unserialize($ser)); return $val; } else { $value = $function(); $ser = serialize(bzcompress($value)); file_put_contents($cachefile, $ser); return $value; } if ($this->getConfig('debug')) echo "no caching"; }
php
public function cacheFun($function) { if ($this->getConfig('debug') && !is_callable($function)) echo "no valid function"; $r = new ReflectionFunction($function); $id = null; foreach ($r->getStaticVariables() as $key => $var) { if ($key == 'key') $id = $var; } if (is_object($id)) $id = $this->getIDfromOjb($id); if ($id == null && $this->getConfig('debug')) { echo "no caching key"; return $function(); } $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id); $cachetime = $this->getConfig('cacheTime'); if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) { $ser = file_get_contents($cachefile); $val = bzdecompress(unserialize($ser)); return $val; } else { $value = $function(); $ser = serialize(bzcompress($value)); file_put_contents($cachefile, $ser); return $value; } if ($this->getConfig('debug')) echo "no caching"; }
[ "public", "function", "cacheFun", "(", "$", "function", ")", "{", "if", "(", "$", "this", "->", "getConfig", "(", "'debug'", ")", "&&", "!", "is_callable", "(", "$", "function", ")", ")", "echo", "\"no valid function\"", ";", "$", "r", "=", "new", "ReflectionFunction", "(", "$", "function", ")", ";", "$", "id", "=", "null", ";", "foreach", "(", "$", "r", "->", "getStaticVariables", "(", ")", "as", "$", "key", "=>", "$", "var", ")", "{", "if", "(", "$", "key", "==", "'key'", ")", "$", "id", "=", "$", "var", ";", "}", "if", "(", "is_object", "(", "$", "id", ")", ")", "$", "id", "=", "$", "this", "->", "getIDfromOjb", "(", "$", "id", ")", ";", "if", "(", "$", "id", "==", "null", "&&", "$", "this", "->", "getConfig", "(", "'debug'", ")", ")", "{", "echo", "\"no caching key\"", ";", "return", "$", "function", "(", ")", ";", "}", "$", "cachefile", "=", "$", "this", "->", "getConfig", "(", "'cacheDir'", ")", ".", "'/'", ".", "utf8_decode", "(", "$", "id", ")", ";", "$", "cachetime", "=", "$", "this", "->", "getConfig", "(", "'cacheTime'", ")", ";", "if", "(", "file_exists", "(", "$", "cachefile", ")", "&&", "time", "(", ")", "-", "$", "cachetime", "<", "fileatime", "(", "$", "cachefile", ")", ")", "{", "$", "ser", "=", "file_get_contents", "(", "$", "cachefile", ")", ";", "$", "val", "=", "bzdecompress", "(", "unserialize", "(", "$", "ser", ")", ")", ";", "return", "$", "val", ";", "}", "else", "{", "$", "value", "=", "$", "function", "(", ")", ";", "$", "ser", "=", "serialize", "(", "bzcompress", "(", "$", "value", ")", ")", ";", "file_put_contents", "(", "$", "cachefile", ",", "$", "ser", ")", ";", "return", "$", "value", ";", "}", "if", "(", "$", "this", "->", "getConfig", "(", "'debug'", ")", ")", "echo", "\"no caching\"", ";", "}" ]
cache function result and return it @param $function closure to cache @return object
[ "cache", "function", "result", "and", "return", "it" ]
3fad52b670f0f00d7edd16c3357fb64cada24366
https://github.com/christianklisch/phpcache/blob/3fad52b670f0f00d7edd16c3357fb64cada24366/PHPCache.class.php#L136-L172
236,073
christianklisch/phpcache
PHPCache.class.php
PHPCache.isCached
public function isCached($id) { if ($id != null) { $id = $this->getIDfromOjb($id); } if ($id == null) return false; $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id); $cachetime = $this->getConfig('cacheTime'); if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) { return true; } return false; }
php
public function isCached($id) { if ($id != null) { $id = $this->getIDfromOjb($id); } if ($id == null) return false; $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id); $cachetime = $this->getConfig('cacheTime'); if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) { return true; } return false; }
[ "public", "function", "isCached", "(", "$", "id", ")", "{", "if", "(", "$", "id", "!=", "null", ")", "{", "$", "id", "=", "$", "this", "->", "getIDfromOjb", "(", "$", "id", ")", ";", "}", "if", "(", "$", "id", "==", "null", ")", "return", "false", ";", "$", "cachefile", "=", "$", "this", "->", "getConfig", "(", "'cacheDir'", ")", ".", "'/'", ".", "utf8_decode", "(", "$", "id", ")", ";", "$", "cachetime", "=", "$", "this", "->", "getConfig", "(", "'cacheTime'", ")", ";", "if", "(", "file_exists", "(", "$", "cachefile", ")", "&&", "time", "(", ")", "-", "$", "cachetime", "<", "fileatime", "(", "$", "cachefile", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
check, if key or object in first parameter is cached. Returns true, if cached @param $id key of cached object or value @return bool
[ "check", "if", "key", "or", "object", "in", "first", "parameter", "is", "cached", ".", "Returns", "true", "if", "cached" ]
3fad52b670f0f00d7edd16c3357fb64cada24366
https://github.com/christianklisch/phpcache/blob/3fad52b670f0f00d7edd16c3357fb64cada24366/PHPCache.class.php#L179-L195
236,074
christianklisch/phpcache
PHPCache.class.php
PHPCache.clearCache
public function clearCache() { $files = glob($this->getConfig('cacheDir') . '/*', GLOB_MARK); foreach ($files as $file) { unlink($file); } }
php
public function clearCache() { $files = glob($this->getConfig('cacheDir') . '/*', GLOB_MARK); foreach ($files as $file) { unlink($file); } }
[ "public", "function", "clearCache", "(", ")", "{", "$", "files", "=", "glob", "(", "$", "this", "->", "getConfig", "(", "'cacheDir'", ")", ".", "'/*'", ",", "GLOB_MARK", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "unlink", "(", "$", "file", ")", ";", "}", "}" ]
delete all cached files
[ "delete", "all", "cached", "files" ]
3fad52b670f0f00d7edd16c3357fb64cada24366
https://github.com/christianklisch/phpcache/blob/3fad52b670f0f00d7edd16c3357fb64cada24366/PHPCache.class.php#L218-L223
236,075
christianklisch/phpcache
PHPCache.class.php
PHPCache.gc
public function gc() { $files = glob($this->getConfig('cacheDir') . '/*', GLOB_MARK); $cachetime = $this->getConfig('cacheTime'); foreach ($files as $file) { if(time() - $cachetime > fileatime($file)) unlink($file); } }
php
public function gc() { $files = glob($this->getConfig('cacheDir') . '/*', GLOB_MARK); $cachetime = $this->getConfig('cacheTime'); foreach ($files as $file) { if(time() - $cachetime > fileatime($file)) unlink($file); } }
[ "public", "function", "gc", "(", ")", "{", "$", "files", "=", "glob", "(", "$", "this", "->", "getConfig", "(", "'cacheDir'", ")", ".", "'/*'", ",", "GLOB_MARK", ")", ";", "$", "cachetime", "=", "$", "this", "->", "getConfig", "(", "'cacheTime'", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "time", "(", ")", "-", "$", "cachetime", ">", "fileatime", "(", "$", "file", ")", ")", "unlink", "(", "$", "file", ")", ";", "}", "}" ]
delete old cached files
[ "delete", "old", "cached", "files" ]
3fad52b670f0f00d7edd16c3357fb64cada24366
https://github.com/christianklisch/phpcache/blob/3fad52b670f0f00d7edd16c3357fb64cada24366/PHPCache.class.php#L228-L235
236,076
spipremix/facteur
lib/markdownify/markdownify.php
Markdownify.parseString
function parseString($html) { $this->parser->html = $html; $this->parse(); return $this->output; }
php
function parseString($html) { $this->parser->html = $html; $this->parse(); return $this->output; }
[ "function", "parseString", "(", "$", "html", ")", "{", "$", "this", "->", "parser", "->", "html", "=", "$", "html", ";", "$", "this", "->", "parse", "(", ")", ";", "return", "$", "this", "->", "output", ";", "}" ]
parse a HTML string @param string $html @return string markdown formatted
[ "parse", "a", "HTML", "string" ]
9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca
https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/lib/markdownify/markdownify.php#L150-L154
236,077
spipremix/facteur
lib/markdownify/markdownify.php
Markdownify.flushStacked
function flushStacked() { # links foreach ($this->stack as $tag => $a) { if (!empty($a)) { call_user_func(array(&$this, 'flushStacked_'.$tag)); } } }
php
function flushStacked() { # links foreach ($this->stack as $tag => $a) { if (!empty($a)) { call_user_func(array(&$this, 'flushStacked_'.$tag)); } } }
[ "function", "flushStacked", "(", ")", "{", "# links", "foreach", "(", "$", "this", "->", "stack", "as", "$", "tag", "=>", "$", "a", ")", "{", "if", "(", "!", "empty", "(", "$", "a", ")", ")", "{", "call_user_func", "(", "array", "(", "&", "$", "this", ",", "'flushStacked_'", ".", "$", "tag", ")", ")", ";", "}", "}", "}" ]
output all stacked tags @param void @return void
[ "output", "all", "stacked", "tags" ]
9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca
https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/lib/markdownify/markdownify.php#L388-L395
236,078
spipremix/facteur
lib/markdownify/markdownify.php
Markdownify.flushLinebreaks
function flushLinebreaks() { if ($this->lineBreaks && !empty($this->output)) { $this->out(str_repeat("\n".$this->indent, $this->lineBreaks), true); } $this->lineBreaks = 0; }
php
function flushLinebreaks() { if ($this->lineBreaks && !empty($this->output)) { $this->out(str_repeat("\n".$this->indent, $this->lineBreaks), true); } $this->lineBreaks = 0; }
[ "function", "flushLinebreaks", "(", ")", "{", "if", "(", "$", "this", "->", "lineBreaks", "&&", "!", "empty", "(", "$", "this", "->", "output", ")", ")", "{", "$", "this", "->", "out", "(", "str_repeat", "(", "\"\\n\"", ".", "$", "this", "->", "indent", ",", "$", "this", "->", "lineBreaks", ")", ",", "true", ")", ";", "}", "$", "this", "->", "lineBreaks", "=", "0", ";", "}" ]
flush enqued linebreaks @param void @return void
[ "flush", "enqued", "linebreaks" ]
9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca
https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/lib/markdownify/markdownify.php#L424-L429
236,079
spipremix/facteur
lib/markdownify/markdownify.php
Markdownify.handleText
function handleText() { if ($this->hasParent('pre') && strpos($this->parser->node, "\n") !== false) { $this->parser->node = str_replace("\n", "\n".$this->indent, $this->parser->node); } if (!$this->hasParent('code') && !$this->hasParent('pre')) { # entity decode $this->parser->node = $this->decode($this->parser->node); if (!$this->skipConversion) { # escape some chars in normal Text $this->parser->node = preg_replace($this->escapeInText['search'], $this->escapeInText['replace'], $this->parser->node); } } else { $this->parser->node = str_replace(array('&quot;', '&apos'), array('"', '\''), $this->parser->node); } $this->out($this->parser->node); $this->lastClosedTag = ''; }
php
function handleText() { if ($this->hasParent('pre') && strpos($this->parser->node, "\n") !== false) { $this->parser->node = str_replace("\n", "\n".$this->indent, $this->parser->node); } if (!$this->hasParent('code') && !$this->hasParent('pre')) { # entity decode $this->parser->node = $this->decode($this->parser->node); if (!$this->skipConversion) { # escape some chars in normal Text $this->parser->node = preg_replace($this->escapeInText['search'], $this->escapeInText['replace'], $this->parser->node); } } else { $this->parser->node = str_replace(array('&quot;', '&apos'), array('"', '\''), $this->parser->node); } $this->out($this->parser->node); $this->lastClosedTag = ''; }
[ "function", "handleText", "(", ")", "{", "if", "(", "$", "this", "->", "hasParent", "(", "'pre'", ")", "&&", "strpos", "(", "$", "this", "->", "parser", "->", "node", ",", "\"\\n\"", ")", "!==", "false", ")", "{", "$", "this", "->", "parser", "->", "node", "=", "str_replace", "(", "\"\\n\"", ",", "\"\\n\"", ".", "$", "this", "->", "indent", ",", "$", "this", "->", "parser", "->", "node", ")", ";", "}", "if", "(", "!", "$", "this", "->", "hasParent", "(", "'code'", ")", "&&", "!", "$", "this", "->", "hasParent", "(", "'pre'", ")", ")", "{", "# entity decode", "$", "this", "->", "parser", "->", "node", "=", "$", "this", "->", "decode", "(", "$", "this", "->", "parser", "->", "node", ")", ";", "if", "(", "!", "$", "this", "->", "skipConversion", ")", "{", "# escape some chars in normal Text", "$", "this", "->", "parser", "->", "node", "=", "preg_replace", "(", "$", "this", "->", "escapeInText", "[", "'search'", "]", ",", "$", "this", "->", "escapeInText", "[", "'replace'", "]", ",", "$", "this", "->", "parser", "->", "node", ")", ";", "}", "}", "else", "{", "$", "this", "->", "parser", "->", "node", "=", "str_replace", "(", "array", "(", "'&quot;'", ",", "'&apos'", ")", ",", "array", "(", "'\"'", ",", "'\\''", ")", ",", "$", "this", "->", "parser", "->", "node", ")", ";", "}", "$", "this", "->", "out", "(", "$", "this", "->", "parser", "->", "node", ")", ";", "$", "this", "->", "lastClosedTag", "=", "''", ";", "}" ]
handle plain text @param void @return void
[ "handle", "plain", "text" ]
9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca
https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/lib/markdownify/markdownify.php#L522-L538
236,080
spipremix/facteur
lib/markdownify/markdownify.php
Markdownify.stack
function stack() { if (!isset($this->stack[$this->parser->tagName])) { $this->stack[$this->parser->tagName] = array(); } array_push($this->stack[$this->parser->tagName], $this->parser->tagAttributes); }
php
function stack() { if (!isset($this->stack[$this->parser->tagName])) { $this->stack[$this->parser->tagName] = array(); } array_push($this->stack[$this->parser->tagName], $this->parser->tagAttributes); }
[ "function", "stack", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "stack", "[", "$", "this", "->", "parser", "->", "tagName", "]", ")", ")", "{", "$", "this", "->", "stack", "[", "$", "this", "->", "parser", "->", "tagName", "]", "=", "array", "(", ")", ";", "}", "array_push", "(", "$", "this", "->", "stack", "[", "$", "this", "->", "parser", "->", "tagName", "]", ",", "$", "this", "->", "parser", "->", "tagAttributes", ")", ";", "}" ]
add current node to the stack this only stores the attributes @param void @return void
[ "add", "current", "node", "to", "the", "stack", "this", "only", "stores", "the", "attributes" ]
9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca
https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/lib/markdownify/markdownify.php#L929-L934
236,081
spipremix/facteur
lib/markdownify/markdownify.php
Markdownify.unstack
function unstack() { if (!isset($this->stack[$this->parser->tagName]) || !is_array($this->stack[$this->parser->tagName])) { trigger_error('Trying to unstack from empty stack. This must not happen.', E_USER_ERROR); } return array_pop($this->stack[$this->parser->tagName]); }
php
function unstack() { if (!isset($this->stack[$this->parser->tagName]) || !is_array($this->stack[$this->parser->tagName])) { trigger_error('Trying to unstack from empty stack. This must not happen.', E_USER_ERROR); } return array_pop($this->stack[$this->parser->tagName]); }
[ "function", "unstack", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "stack", "[", "$", "this", "->", "parser", "->", "tagName", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "stack", "[", "$", "this", "->", "parser", "->", "tagName", "]", ")", ")", "{", "trigger_error", "(", "'Trying to unstack from empty stack. This must not happen.'", ",", "E_USER_ERROR", ")", ";", "}", "return", "array_pop", "(", "$", "this", "->", "stack", "[", "$", "this", "->", "parser", "->", "tagName", "]", ")", ";", "}" ]
remove current tag from stack @param void @return array
[ "remove", "current", "tag", "from", "stack" ]
9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca
https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/lib/markdownify/markdownify.php#L941-L946
236,082
spipremix/facteur
lib/markdownify/markdownify.php
Markdownify.decode
function decode($text, $quote_style = ENT_QUOTES) { if (version_compare(PHP_VERSION, '5', '>=')) { # UTF-8 is only supported in PHP 5.x.x and above $text = html_entity_decode($text, $quote_style, 'UTF-8'); } else { if (function_exists('html_entity_decode')) { $text = html_entity_decode($text, $quote_style, 'ISO-8859-1'); } else { static $trans_tbl; if (!isset($trans_tbl)) { $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES, $quote_style)); } $text = strtr($text, $trans_tbl); } $text = preg_replace_callback('~&#x([0-9a-f]+);~i', array(&$this, '_decode_hex'), $text); $text = preg_replace_callback('~&#(\d{2,5});~', array(&$this, '_decode_numeric'), $text); } return $text; }
php
function decode($text, $quote_style = ENT_QUOTES) { if (version_compare(PHP_VERSION, '5', '>=')) { # UTF-8 is only supported in PHP 5.x.x and above $text = html_entity_decode($text, $quote_style, 'UTF-8'); } else { if (function_exists('html_entity_decode')) { $text = html_entity_decode($text, $quote_style, 'ISO-8859-1'); } else { static $trans_tbl; if (!isset($trans_tbl)) { $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES, $quote_style)); } $text = strtr($text, $trans_tbl); } $text = preg_replace_callback('~&#x([0-9a-f]+);~i', array(&$this, '_decode_hex'), $text); $text = preg_replace_callback('~&#(\d{2,5});~', array(&$this, '_decode_numeric'), $text); } return $text; }
[ "function", "decode", "(", "$", "text", ",", "$", "quote_style", "=", "ENT_QUOTES", ")", "{", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5'", ",", "'>='", ")", ")", "{", "# UTF-8 is only supported in PHP 5.x.x and above", "$", "text", "=", "html_entity_decode", "(", "$", "text", ",", "$", "quote_style", ",", "'UTF-8'", ")", ";", "}", "else", "{", "if", "(", "function_exists", "(", "'html_entity_decode'", ")", ")", "{", "$", "text", "=", "html_entity_decode", "(", "$", "text", ",", "$", "quote_style", ",", "'ISO-8859-1'", ")", ";", "}", "else", "{", "static", "$", "trans_tbl", ";", "if", "(", "!", "isset", "(", "$", "trans_tbl", ")", ")", "{", "$", "trans_tbl", "=", "array_flip", "(", "get_html_translation_table", "(", "HTML_ENTITIES", ",", "$", "quote_style", ")", ")", ";", "}", "$", "text", "=", "strtr", "(", "$", "text", ",", "$", "trans_tbl", ")", ";", "}", "$", "text", "=", "preg_replace_callback", "(", "'~&#x([0-9a-f]+);~i'", ",", "array", "(", "&", "$", "this", ",", "'_decode_hex'", ")", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace_callback", "(", "'~&#(\\d{2,5});~'", ",", "array", "(", "&", "$", "this", ",", "'_decode_numeric'", ")", ",", "$", "text", ")", ";", "}", "return", "$", "text", ";", "}" ]
decode email addresses @author derernst@gmx.ch <http://www.php.net/manual/en/function.html-entity-decode.php#68536> @author Milian Wolff <http://milianw.de>
[ "decode", "email", "addresses" ]
9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca
https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/lib/markdownify/markdownify.php#L1075-L1093
236,083
flowcode/AmulenMediaBundle
src/Flowcode/MediaBundle/Controller/AdminMediaTypeController.php
AdminMediaTypeController.createCreateForm
private function createCreateForm(MediaType $entity) { $form = $this->createForm(new MediaTypeType(), $entity, array( 'action' => $this->generateUrl('mediatype_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
private function createCreateForm(MediaType $entity) { $form = $this->createForm(new MediaTypeType(), $entity, array( 'action' => $this->generateUrl('mediatype_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
[ "private", "function", "createCreateForm", "(", "MediaType", "$", "entity", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "MediaTypeType", "(", ")", ",", "$", "entity", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'mediatype_create'", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Create'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to create a MediaType entity. @param MediaType $entity The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "MediaType", "entity", "." ]
3be28720ff108cca1480de609872d29283776643
https://github.com/flowcode/AmulenMediaBundle/blob/3be28720ff108cca1480de609872d29283776643/src/Flowcode/MediaBundle/Controller/AdminMediaTypeController.php#L72-L82
236,084
flowcode/AmulenMediaBundle
src/Flowcode/MediaBundle/Controller/AdminMediaTypeController.php
AdminMediaTypeController.newAction
public function newAction() { $entity = new MediaType(); $form = $this->createCreateForm($entity); return array( 'entity' => $entity, 'form' => $form->createView(), ); }
php
public function newAction() { $entity = new MediaType(); $form = $this->createCreateForm($entity); return array( 'entity' => $entity, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", ")", "{", "$", "entity", "=", "new", "MediaType", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "entity", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to create a new MediaType entity. @Route("/new", name="mediatype_new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "MediaType", "entity", "." ]
3be28720ff108cca1480de609872d29283776643
https://github.com/flowcode/AmulenMediaBundle/blob/3be28720ff108cca1480de609872d29283776643/src/Flowcode/MediaBundle/Controller/AdminMediaTypeController.php#L91-L100
236,085
flowcode/AmulenMediaBundle
src/Flowcode/MediaBundle/Controller/AdminMediaTypeController.php
AdminMediaTypeController.createEditForm
private function createEditForm(MediaType $entity) { $form = $this->createForm(new MediaTypeType(), $entity, array( 'action' => $this->generateUrl('mediatype_update', array('id' => $entity->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
php
private function createEditForm(MediaType $entity) { $form = $this->createForm(new MediaTypeType(), $entity, array( 'action' => $this->generateUrl('mediatype_update', array('id' => $entity->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
[ "private", "function", "createEditForm", "(", "MediaType", "$", "entity", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "MediaTypeType", "(", ")", ",", "$", "entity", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'mediatype_update'", ",", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Update'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to edit a MediaType entity. @param MediaType $entity The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "edit", "a", "MediaType", "entity", "." ]
3be28720ff108cca1480de609872d29283776643
https://github.com/flowcode/AmulenMediaBundle/blob/3be28720ff108cca1480de609872d29283776643/src/Flowcode/MediaBundle/Controller/AdminMediaTypeController.php#L161-L171
236,086
bkdotcom/Toolbox
src/FetchUrl.php
FetchUrl.extractHeaders
private function extractHeaders($str) { $this->debug->log(__METHOD__); $this->debug->groupUncollapse(); $headerStart = 0; #$this->debug->log(('top', \substr($return, 0, $this->curlInfo['header_size'])); $headerLenStack = array(); $i = 0; while (true) { $headerEnd = \strpos($str, "\r\n\r\n", $headerStart); $headerLength = $headerEnd - $headerStart; $headers = \substr($str, $headerStart, $headerLength); $headerStart = $headerEnd+4; $headerLenStack[] = \strlen($headers)+4; #$this->debug->log('headers', \str_replace(array("\r","\n"), array('|','|'), $headers)); if (\count($headerLenStack) > $this->curlInfo['redirect_count']) { #$this->debug->log('header_len_stack','['.\implode(',',$header_len_stack).']'); $sum = 0; for ($j=$i; $j>=0; $j--) { $sum += $headerLenStack[$j]; if ($sum == $this->curlInfo['header_size']) { #$this->debug->info('found headers'); break 2; } } } if ($headerEnd === false || $i > 20) { $this->debug->warn('error parsing headers'); break; } $i++; } // $this->debug->log('headers', $headers); return $headers; }
php
private function extractHeaders($str) { $this->debug->log(__METHOD__); $this->debug->groupUncollapse(); $headerStart = 0; #$this->debug->log(('top', \substr($return, 0, $this->curlInfo['header_size'])); $headerLenStack = array(); $i = 0; while (true) { $headerEnd = \strpos($str, "\r\n\r\n", $headerStart); $headerLength = $headerEnd - $headerStart; $headers = \substr($str, $headerStart, $headerLength); $headerStart = $headerEnd+4; $headerLenStack[] = \strlen($headers)+4; #$this->debug->log('headers', \str_replace(array("\r","\n"), array('|','|'), $headers)); if (\count($headerLenStack) > $this->curlInfo['redirect_count']) { #$this->debug->log('header_len_stack','['.\implode(',',$header_len_stack).']'); $sum = 0; for ($j=$i; $j>=0; $j--) { $sum += $headerLenStack[$j]; if ($sum == $this->curlInfo['header_size']) { #$this->debug->info('found headers'); break 2; } } } if ($headerEnd === false || $i > 20) { $this->debug->warn('error parsing headers'); break; } $i++; } // $this->debug->log('headers', $headers); return $headers; }
[ "private", "function", "extractHeaders", "(", "$", "str", ")", "{", "$", "this", "->", "debug", "->", "log", "(", "__METHOD__", ")", ";", "$", "this", "->", "debug", "->", "groupUncollapse", "(", ")", ";", "$", "headerStart", "=", "0", ";", "#$this->debug->log(('top', \\substr($return, 0, $this->curlInfo['header_size']));", "$", "headerLenStack", "=", "array", "(", ")", ";", "$", "i", "=", "0", ";", "while", "(", "true", ")", "{", "$", "headerEnd", "=", "\\", "strpos", "(", "$", "str", ",", "\"\\r\\n\\r\\n\"", ",", "$", "headerStart", ")", ";", "$", "headerLength", "=", "$", "headerEnd", "-", "$", "headerStart", ";", "$", "headers", "=", "\\", "substr", "(", "$", "str", ",", "$", "headerStart", ",", "$", "headerLength", ")", ";", "$", "headerStart", "=", "$", "headerEnd", "+", "4", ";", "$", "headerLenStack", "[", "]", "=", "\\", "strlen", "(", "$", "headers", ")", "+", "4", ";", "#$this->debug->log('headers', \\str_replace(array(\"\\r\",\"\\n\"), array('|','|'), $headers));", "if", "(", "\\", "count", "(", "$", "headerLenStack", ")", ">", "$", "this", "->", "curlInfo", "[", "'redirect_count'", "]", ")", "{", "#$this->debug->log('header_len_stack','['.\\implode(',',$header_len_stack).']');", "$", "sum", "=", "0", ";", "for", "(", "$", "j", "=", "$", "i", ";", "$", "j", ">=", "0", ";", "$", "j", "--", ")", "{", "$", "sum", "+=", "$", "headerLenStack", "[", "$", "j", "]", ";", "if", "(", "$", "sum", "==", "$", "this", "->", "curlInfo", "[", "'header_size'", "]", ")", "{", "#$this->debug->info('found headers');", "break", "2", ";", "}", "}", "}", "if", "(", "$", "headerEnd", "===", "false", "||", "$", "i", ">", "20", ")", "{", "$", "this", "->", "debug", "->", "warn", "(", "'error parsing headers'", ")", ";", "break", ";", "}", "$", "i", "++", ";", "}", "// $this->debug->log('headers', $headers);", "return", "$", "headers", ";", "}" ]
for a string containing both headers and content, return the header portion @param string $str headers + content @return string
[ "for", "a", "string", "containing", "both", "headers", "and", "content", "return", "the", "header", "portion" ]
2f9d34fd57bd8382baee4c29aac13a6710e3a994
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/FetchUrl.php#L189-L223
236,087
bkdotcom/Toolbox
src/FetchUrl.php
FetchUrl.curlGetOptions
protected function curlGetOptions($url, $options = array()) { $this->debug->groupCollapsed(__METHOD__); $urlParts = Html::parseUrl($url); $optionsDefault = $this->curlOptionsDefault($url); $options = $this->curlOptionsNormalize($options); // $this->debug->log('optionsDefault', $optionsDefault); $options = ArrayUtil::mergeDeep($optionsDefault, $options); $options['CURLOPT_URL'] = \str_replace(' ', '%20', $options['CURLOPT_URL']); $options['CURLOPT_FOLLOWLOCATION'] = false; // we will follow manually if ($options['verbose']) { $options['CURLOPT_VERBOSE'] = true; /* $options['tempfile'] = tempnam(\sys_get_temp_dir(), 'curl_'); if (\is_writable($options['tempfile'])) { $fh = \fopen($options['tempfile'], 'w+'); $options['CURLOPT_STDERR'] = $fh; } */ $options['CURLINFO_HEADER_OUT'] = false; // https://bugs.php.net/bug.php?id=65348 $options['CURLOPT_STDERR'] = \fopen('php://temp', 'rw'); } if (!empty($options['CURLOPT_PROXY']) && \in_array($urlParts['host'], array('127.0.0.1','localhost'))) { $this->debug->log('not using proxy for localhost'); $options['CURLOPT_PROXY'] = false; // formerly set to null... which no longer works } if (empty($options['CURLOPT_PROXY']) && \getenv('http_proxy')) { $this->debug->log('http_proxy env variable is set.... setting NO_PROXY env variable'); \putenv('NO_PROXY='.$urlParts['host']); } $this->debug->groupEnd(); return $options; }
php
protected function curlGetOptions($url, $options = array()) { $this->debug->groupCollapsed(__METHOD__); $urlParts = Html::parseUrl($url); $optionsDefault = $this->curlOptionsDefault($url); $options = $this->curlOptionsNormalize($options); // $this->debug->log('optionsDefault', $optionsDefault); $options = ArrayUtil::mergeDeep($optionsDefault, $options); $options['CURLOPT_URL'] = \str_replace(' ', '%20', $options['CURLOPT_URL']); $options['CURLOPT_FOLLOWLOCATION'] = false; // we will follow manually if ($options['verbose']) { $options['CURLOPT_VERBOSE'] = true; /* $options['tempfile'] = tempnam(\sys_get_temp_dir(), 'curl_'); if (\is_writable($options['tempfile'])) { $fh = \fopen($options['tempfile'], 'w+'); $options['CURLOPT_STDERR'] = $fh; } */ $options['CURLINFO_HEADER_OUT'] = false; // https://bugs.php.net/bug.php?id=65348 $options['CURLOPT_STDERR'] = \fopen('php://temp', 'rw'); } if (!empty($options['CURLOPT_PROXY']) && \in_array($urlParts['host'], array('127.0.0.1','localhost'))) { $this->debug->log('not using proxy for localhost'); $options['CURLOPT_PROXY'] = false; // formerly set to null... which no longer works } if (empty($options['CURLOPT_PROXY']) && \getenv('http_proxy')) { $this->debug->log('http_proxy env variable is set.... setting NO_PROXY env variable'); \putenv('NO_PROXY='.$urlParts['host']); } $this->debug->groupEnd(); return $options; }
[ "protected", "function", "curlGetOptions", "(", "$", "url", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "debug", "->", "groupCollapsed", "(", "__METHOD__", ")", ";", "$", "urlParts", "=", "Html", "::", "parseUrl", "(", "$", "url", ")", ";", "$", "optionsDefault", "=", "$", "this", "->", "curlOptionsDefault", "(", "$", "url", ")", ";", "$", "options", "=", "$", "this", "->", "curlOptionsNormalize", "(", "$", "options", ")", ";", "// $this->debug->log('optionsDefault', $optionsDefault);", "$", "options", "=", "ArrayUtil", "::", "mergeDeep", "(", "$", "optionsDefault", ",", "$", "options", ")", ";", "$", "options", "[", "'CURLOPT_URL'", "]", "=", "\\", "str_replace", "(", "' '", ",", "'%20'", ",", "$", "options", "[", "'CURLOPT_URL'", "]", ")", ";", "$", "options", "[", "'CURLOPT_FOLLOWLOCATION'", "]", "=", "false", ";", "// we will follow manually", "if", "(", "$", "options", "[", "'verbose'", "]", ")", "{", "$", "options", "[", "'CURLOPT_VERBOSE'", "]", "=", "true", ";", "/*\n $options['tempfile'] = tempnam(\\sys_get_temp_dir(), 'curl_');\n if (\\is_writable($options['tempfile'])) {\n $fh = \\fopen($options['tempfile'], 'w+');\n $options['CURLOPT_STDERR'] = $fh;\n }\n */", "$", "options", "[", "'CURLINFO_HEADER_OUT'", "]", "=", "false", ";", "// https://bugs.php.net/bug.php?id=65348", "$", "options", "[", "'CURLOPT_STDERR'", "]", "=", "\\", "fopen", "(", "'php://temp'", ",", "'rw'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'CURLOPT_PROXY'", "]", ")", "&&", "\\", "in_array", "(", "$", "urlParts", "[", "'host'", "]", ",", "array", "(", "'127.0.0.1'", ",", "'localhost'", ")", ")", ")", "{", "$", "this", "->", "debug", "->", "log", "(", "'not using proxy for localhost'", ")", ";", "$", "options", "[", "'CURLOPT_PROXY'", "]", "=", "false", ";", "// formerly set to null... which no longer works", "}", "if", "(", "empty", "(", "$", "options", "[", "'CURLOPT_PROXY'", "]", ")", "&&", "\\", "getenv", "(", "'http_proxy'", ")", ")", "{", "$", "this", "->", "debug", "->", "log", "(", "'http_proxy env variable is set.... setting NO_PROXY env variable'", ")", ";", "\\", "putenv", "(", "'NO_PROXY='", ".", "$", "urlParts", "[", "'host'", "]", ")", ";", "}", "$", "this", "->", "debug", "->", "groupEnd", "(", ")", ";", "return", "$", "options", ";", "}" ]
Get complete options @param string $url url to fetch @param array $options array o options @return array
[ "Get", "complete", "options" ]
2f9d34fd57bd8382baee4c29aac13a6710e3a994
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/FetchUrl.php#L406-L438
236,088
bkdotcom/Toolbox
src/FetchUrl.php
FetchUrl.curlOptionsDefault
protected function curlOptionsDefault($url) { $this->debug->groupCollapsed(__METHOD__); $opts = array( // 'CURLOPT_VERBOSE' => 1, // 'CURLOPT_STDERR' => fopen(dirname($_SERVER['SCRIPT_FILENAME']).'/stderr.txt','a'), // 'CURLOPT_COOKIEJAR' => 'c:/shazbot.txt', // broken was only grabbing 2 of 3 cookies // 'CURLOPT_COOKIEFILE' => 'c:/shazbot.txt', // 'CURLOPT_CAINFO' => '/usr/local/apache/htdocs/ca-bundle.cert', 'curl_getinfo' => false, // whether to display 'verbose' => false, 'CURLINFO_HEADER_OUT' => true, 'CURLOPT_FOLLOWLOCATION'=> false, // will follow manualy because of the cookie problem 'CURLOPT_HEADER' => true, // return header (to grab cookies n whatnot) 'CURLOPT_IPRESOLVE' => CURL_IPRESOLVE_V4, 'CURLOPT_URL' => $url, 'CURLOPT_HTTPHEADER' => array(), 'CURLOPT_REFERER' => Html::getSelfUrl(array(), array('fullUrl'=>true,'chars'=>false)), 'CURLOPT_RETURNTRANSFER'=> true, // return string rather than echo 'CURLOPT_SSL_VERIFYPEER'=> false, 'CURLOPT_USERAGENT' => !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)', ); $opts = \array_merge($opts, $this->cfg['curl_opts']); $proxy = \getenv('http_proxy'); if ($proxy) { $this->debug->log('http_proxy env var set...setting default PROXY, CURLOPT_PROXYUSERPWD, and PROXYAUTH'); $pup = \parse_url($proxy); $opts['CURLOPT_PROXY'] = $pup['host']; if (!empty($pup['port'])) { $opts['CURLOPT_PROXY'] .= ':'.$pup['port']; } if (!empty($pup['user'])) { $opts['CURLOPT_PROXYUSERPWD'] = $pup['user']; if (!empty($pup['pass'])) { $opts['CURLOPT_PROXYUSERPWD'] .= ':'.$pup['pass']; } } $opts['CURLOPT_PROXYAUTH'] = CURLAUTH_BASIC; // | CURLAUTH_NTLM; } // $this->debug->log('opts', $opts); $this->debug->groupEnd(); return $opts; }
php
protected function curlOptionsDefault($url) { $this->debug->groupCollapsed(__METHOD__); $opts = array( // 'CURLOPT_VERBOSE' => 1, // 'CURLOPT_STDERR' => fopen(dirname($_SERVER['SCRIPT_FILENAME']).'/stderr.txt','a'), // 'CURLOPT_COOKIEJAR' => 'c:/shazbot.txt', // broken was only grabbing 2 of 3 cookies // 'CURLOPT_COOKIEFILE' => 'c:/shazbot.txt', // 'CURLOPT_CAINFO' => '/usr/local/apache/htdocs/ca-bundle.cert', 'curl_getinfo' => false, // whether to display 'verbose' => false, 'CURLINFO_HEADER_OUT' => true, 'CURLOPT_FOLLOWLOCATION'=> false, // will follow manualy because of the cookie problem 'CURLOPT_HEADER' => true, // return header (to grab cookies n whatnot) 'CURLOPT_IPRESOLVE' => CURL_IPRESOLVE_V4, 'CURLOPT_URL' => $url, 'CURLOPT_HTTPHEADER' => array(), 'CURLOPT_REFERER' => Html::getSelfUrl(array(), array('fullUrl'=>true,'chars'=>false)), 'CURLOPT_RETURNTRANSFER'=> true, // return string rather than echo 'CURLOPT_SSL_VERIFYPEER'=> false, 'CURLOPT_USERAGENT' => !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)', ); $opts = \array_merge($opts, $this->cfg['curl_opts']); $proxy = \getenv('http_proxy'); if ($proxy) { $this->debug->log('http_proxy env var set...setting default PROXY, CURLOPT_PROXYUSERPWD, and PROXYAUTH'); $pup = \parse_url($proxy); $opts['CURLOPT_PROXY'] = $pup['host']; if (!empty($pup['port'])) { $opts['CURLOPT_PROXY'] .= ':'.$pup['port']; } if (!empty($pup['user'])) { $opts['CURLOPT_PROXYUSERPWD'] = $pup['user']; if (!empty($pup['pass'])) { $opts['CURLOPT_PROXYUSERPWD'] .= ':'.$pup['pass']; } } $opts['CURLOPT_PROXYAUTH'] = CURLAUTH_BASIC; // | CURLAUTH_NTLM; } // $this->debug->log('opts', $opts); $this->debug->groupEnd(); return $opts; }
[ "protected", "function", "curlOptionsDefault", "(", "$", "url", ")", "{", "$", "this", "->", "debug", "->", "groupCollapsed", "(", "__METHOD__", ")", ";", "$", "opts", "=", "array", "(", "// 'CURLOPT_VERBOSE' => 1,", "// 'CURLOPT_STDERR' => fopen(dirname($_SERVER['SCRIPT_FILENAME']).'/stderr.txt','a'),", "// 'CURLOPT_COOKIEJAR' => 'c:/shazbot.txt', // broken was only grabbing 2 of 3 cookies", "// 'CURLOPT_COOKIEFILE' => 'c:/shazbot.txt',", "// 'CURLOPT_CAINFO' => '/usr/local/apache/htdocs/ca-bundle.cert',", "'curl_getinfo'", "=>", "false", ",", "// whether to display", "'verbose'", "=>", "false", ",", "'CURLINFO_HEADER_OUT'", "=>", "true", ",", "'CURLOPT_FOLLOWLOCATION'", "=>", "false", ",", "// will follow manualy because of the cookie problem", "'CURLOPT_HEADER'", "=>", "true", ",", "// return header (to grab cookies n whatnot)", "'CURLOPT_IPRESOLVE'", "=>", "CURL_IPRESOLVE_V4", ",", "'CURLOPT_URL'", "=>", "$", "url", ",", "'CURLOPT_HTTPHEADER'", "=>", "array", "(", ")", ",", "'CURLOPT_REFERER'", "=>", "Html", "::", "getSelfUrl", "(", "array", "(", ")", ",", "array", "(", "'fullUrl'", "=>", "true", ",", "'chars'", "=>", "false", ")", ")", ",", "'CURLOPT_RETURNTRANSFER'", "=>", "true", ",", "// return string rather than echo", "'CURLOPT_SSL_VERIFYPEER'", "=>", "false", ",", "'CURLOPT_USERAGENT'", "=>", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ":", "'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'", ",", ")", ";", "$", "opts", "=", "\\", "array_merge", "(", "$", "opts", ",", "$", "this", "->", "cfg", "[", "'curl_opts'", "]", ")", ";", "$", "proxy", "=", "\\", "getenv", "(", "'http_proxy'", ")", ";", "if", "(", "$", "proxy", ")", "{", "$", "this", "->", "debug", "->", "log", "(", "'http_proxy env var set...setting default PROXY, CURLOPT_PROXYUSERPWD, and PROXYAUTH'", ")", ";", "$", "pup", "=", "\\", "parse_url", "(", "$", "proxy", ")", ";", "$", "opts", "[", "'CURLOPT_PROXY'", "]", "=", "$", "pup", "[", "'host'", "]", ";", "if", "(", "!", "empty", "(", "$", "pup", "[", "'port'", "]", ")", ")", "{", "$", "opts", "[", "'CURLOPT_PROXY'", "]", ".=", "':'", ".", "$", "pup", "[", "'port'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "pup", "[", "'user'", "]", ")", ")", "{", "$", "opts", "[", "'CURLOPT_PROXYUSERPWD'", "]", "=", "$", "pup", "[", "'user'", "]", ";", "if", "(", "!", "empty", "(", "$", "pup", "[", "'pass'", "]", ")", ")", "{", "$", "opts", "[", "'CURLOPT_PROXYUSERPWD'", "]", ".=", "':'", ".", "$", "pup", "[", "'pass'", "]", ";", "}", "}", "$", "opts", "[", "'CURLOPT_PROXYAUTH'", "]", "=", "CURLAUTH_BASIC", ";", "// | CURLAUTH_NTLM;", "}", "// $this->debug->log('opts', $opts);", "$", "this", "->", "debug", "->", "groupEnd", "(", ")", ";", "return", "$", "opts", ";", "}" ]
Get defautl cURL options @param string $url url @return array
[ "Get", "defautl", "cURL", "options" ]
2f9d34fd57bd8382baee4c29aac13a6710e3a994
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/FetchUrl.php#L447-L491
236,089
bkdotcom/Toolbox
src/FetchUrl.php
FetchUrl.curlGetReturn
protected function curlGetReturn() { $follow = !isset($this->optionsPassed['CURLOPT_FOLLOWLOCATION']) || $this->optionsPassed['CURLOPT_FOLLOWLOCATION']; $headers = $this->fetchResponse['headers']; if ($follow && isset($headers['Location'])) { // follow location $location = Html::getAbsUrl($this->options['CURLOPT_URL'], $headers['Location']); $this->debug->info('redirect', $location); if (\count(\array_keys($this->redirectHistory, $location)) > 1) { // a -> b -> a is OK $this->debug->warn('redirect loop', $this->redirectHistory); $return = false; } else { if (\in_array($headers['Return-Code'], array(302,303))) { $this->optionsPassed['CURLOPT_POSTFIELDS'] = null; $this->optionsPassed['post'] = null; } $this->optionsPassed['cookies'] = $this->fetchResponse['cookies']; unset($this->optionsPassed['url']); // url used by scrape() unset($this->optionsPassed['CURLOPT_URL']); $return = $this->fetchCurl($location, $this->optionsPassed); } } else { $this->redirectHistory = array(); if ($headers && $headers['Return-Code'] != 200 && $follow) { #$this->debug->log('fetchResponse', $this->fetchResponse); $return = false; } else { if (!empty($headers['Content-Encoding']) && $headers['Content-Encoding'] == 'gzip') { $this->debug->info('decompressing gzip content'); $this->fetchResponse['body'] = Gzip::decompressString($this->fetchResponse['body']); } $return = $this->fetchResponse; } } return $return; }
php
protected function curlGetReturn() { $follow = !isset($this->optionsPassed['CURLOPT_FOLLOWLOCATION']) || $this->optionsPassed['CURLOPT_FOLLOWLOCATION']; $headers = $this->fetchResponse['headers']; if ($follow && isset($headers['Location'])) { // follow location $location = Html::getAbsUrl($this->options['CURLOPT_URL'], $headers['Location']); $this->debug->info('redirect', $location); if (\count(\array_keys($this->redirectHistory, $location)) > 1) { // a -> b -> a is OK $this->debug->warn('redirect loop', $this->redirectHistory); $return = false; } else { if (\in_array($headers['Return-Code'], array(302,303))) { $this->optionsPassed['CURLOPT_POSTFIELDS'] = null; $this->optionsPassed['post'] = null; } $this->optionsPassed['cookies'] = $this->fetchResponse['cookies']; unset($this->optionsPassed['url']); // url used by scrape() unset($this->optionsPassed['CURLOPT_URL']); $return = $this->fetchCurl($location, $this->optionsPassed); } } else { $this->redirectHistory = array(); if ($headers && $headers['Return-Code'] != 200 && $follow) { #$this->debug->log('fetchResponse', $this->fetchResponse); $return = false; } else { if (!empty($headers['Content-Encoding']) && $headers['Content-Encoding'] == 'gzip') { $this->debug->info('decompressing gzip content'); $this->fetchResponse['body'] = Gzip::decompressString($this->fetchResponse['body']); } $return = $this->fetchResponse; } } return $return; }
[ "protected", "function", "curlGetReturn", "(", ")", "{", "$", "follow", "=", "!", "isset", "(", "$", "this", "->", "optionsPassed", "[", "'CURLOPT_FOLLOWLOCATION'", "]", ")", "||", "$", "this", "->", "optionsPassed", "[", "'CURLOPT_FOLLOWLOCATION'", "]", ";", "$", "headers", "=", "$", "this", "->", "fetchResponse", "[", "'headers'", "]", ";", "if", "(", "$", "follow", "&&", "isset", "(", "$", "headers", "[", "'Location'", "]", ")", ")", "{", "// follow location", "$", "location", "=", "Html", "::", "getAbsUrl", "(", "$", "this", "->", "options", "[", "'CURLOPT_URL'", "]", ",", "$", "headers", "[", "'Location'", "]", ")", ";", "$", "this", "->", "debug", "->", "info", "(", "'redirect'", ",", "$", "location", ")", ";", "if", "(", "\\", "count", "(", "\\", "array_keys", "(", "$", "this", "->", "redirectHistory", ",", "$", "location", ")", ")", ">", "1", ")", "{", "// a -> b -> a is OK", "$", "this", "->", "debug", "->", "warn", "(", "'redirect loop'", ",", "$", "this", "->", "redirectHistory", ")", ";", "$", "return", "=", "false", ";", "}", "else", "{", "if", "(", "\\", "in_array", "(", "$", "headers", "[", "'Return-Code'", "]", ",", "array", "(", "302", ",", "303", ")", ")", ")", "{", "$", "this", "->", "optionsPassed", "[", "'CURLOPT_POSTFIELDS'", "]", "=", "null", ";", "$", "this", "->", "optionsPassed", "[", "'post'", "]", "=", "null", ";", "}", "$", "this", "->", "optionsPassed", "[", "'cookies'", "]", "=", "$", "this", "->", "fetchResponse", "[", "'cookies'", "]", ";", "unset", "(", "$", "this", "->", "optionsPassed", "[", "'url'", "]", ")", ";", "// url used by scrape()", "unset", "(", "$", "this", "->", "optionsPassed", "[", "'CURLOPT_URL'", "]", ")", ";", "$", "return", "=", "$", "this", "->", "fetchCurl", "(", "$", "location", ",", "$", "this", "->", "optionsPassed", ")", ";", "}", "}", "else", "{", "$", "this", "->", "redirectHistory", "=", "array", "(", ")", ";", "if", "(", "$", "headers", "&&", "$", "headers", "[", "'Return-Code'", "]", "!=", "200", "&&", "$", "follow", ")", "{", "#$this->debug->log('fetchResponse', $this->fetchResponse);", "$", "return", "=", "false", ";", "}", "else", "{", "if", "(", "!", "empty", "(", "$", "headers", "[", "'Content-Encoding'", "]", ")", "&&", "$", "headers", "[", "'Content-Encoding'", "]", "==", "'gzip'", ")", "{", "$", "this", "->", "debug", "->", "info", "(", "'decompressing gzip content'", ")", ";", "$", "this", "->", "fetchResponse", "[", "'body'", "]", "=", "Gzip", "::", "decompressString", "(", "$", "this", "->", "fetchResponse", "[", "'body'", "]", ")", ";", "}", "$", "return", "=", "$", "this", "->", "fetchResponse", ";", "}", "}", "return", "$", "return", ";", "}" ]
Build return value from fetchResponse @return array|false
[ "Build", "return", "value", "from", "fetchResponse" ]
2f9d34fd57bd8382baee4c29aac13a6710e3a994
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/FetchUrl.php#L629-L665
236,090
fabsgc/framework
Core/Asset/Asset.php
Asset._setFile
protected function _setFile($path) { $this->_name .= $path; $this->_data['' . $path . ''] = file_get_contents($path); if ($this->_type == 'css') { $this->_currentPath = dirname($path) . '/'; $this->_data['' . $path . ''] = preg_replace_callback('`url\((.*)\)`isU', ['Gcs\Framework\Core\Asset\Asset', '_parseRelativePathCssUrl'], $this->_data['' . $path . '']); $this->_data['' . $path . ''] = preg_replace_callback('`src=\'(.*)\'`isU', ['Gcs\Framework\Core\Asset\Asset', '_parseRelativePathCssSrc'], $this->_data['' . $path . '']); } }
php
protected function _setFile($path) { $this->_name .= $path; $this->_data['' . $path . ''] = file_get_contents($path); if ($this->_type == 'css') { $this->_currentPath = dirname($path) . '/'; $this->_data['' . $path . ''] = preg_replace_callback('`url\((.*)\)`isU', ['Gcs\Framework\Core\Asset\Asset', '_parseRelativePathCssUrl'], $this->_data['' . $path . '']); $this->_data['' . $path . ''] = preg_replace_callback('`src=\'(.*)\'`isU', ['Gcs\Framework\Core\Asset\Asset', '_parseRelativePathCssSrc'], $this->_data['' . $path . '']); } }
[ "protected", "function", "_setFile", "(", "$", "path", ")", "{", "$", "this", "->", "_name", ".=", "$", "path", ";", "$", "this", "->", "_data", "[", "''", ".", "$", "path", ".", "''", "]", "=", "file_get_contents", "(", "$", "path", ")", ";", "if", "(", "$", "this", "->", "_type", "==", "'css'", ")", "{", "$", "this", "->", "_currentPath", "=", "dirname", "(", "$", "path", ")", ".", "'/'", ";", "$", "this", "->", "_data", "[", "''", ".", "$", "path", ".", "''", "]", "=", "preg_replace_callback", "(", "'`url\\((.*)\\)`isU'", ",", "[", "'Gcs\\Framework\\Core\\Asset\\Asset'", ",", "'_parseRelativePathCssUrl'", "]", ",", "$", "this", "->", "_data", "[", "''", ".", "$", "path", ".", "''", "]", ")", ";", "$", "this", "->", "_data", "[", "''", ".", "$", "path", ".", "''", "]", "=", "preg_replace_callback", "(", "'`src=\\'(.*)\\'`isU'", ",", "[", "'Gcs\\Framework\\Core\\Asset\\Asset'", ",", "'_parseRelativePathCssSrc'", "]", ",", "$", "this", "->", "_data", "[", "''", ".", "$", "path", ".", "''", "]", ")", ";", "}", "}" ]
configure one file @access public @param $path string @return void @since 3.0 @package Gcs\Framework\Core\Asset
[ "configure", "one", "file" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Asset/Asset.php#L172-L181
236,091
fabsgc/framework
Core/Asset/Asset.php
Asset._setDir
protected function _setDir($path) { if ($handle = opendir($path)) { while (false !== ($entry = readdir($handle))) { $extension = explode('.', basename($entry)); $ext = $extension[count($extension) - 1]; if ($ext == $this->_type) { $this->_setFile($path . $entry); } } closedir($handle); } }
php
protected function _setDir($path) { if ($handle = opendir($path)) { while (false !== ($entry = readdir($handle))) { $extension = explode('.', basename($entry)); $ext = $extension[count($extension) - 1]; if ($ext == $this->_type) { $this->_setFile($path . $entry); } } closedir($handle); } }
[ "protected", "function", "_setDir", "(", "$", "path", ")", "{", "if", "(", "$", "handle", "=", "opendir", "(", "$", "path", ")", ")", "{", "while", "(", "false", "!==", "(", "$", "entry", "=", "readdir", "(", "$", "handle", ")", ")", ")", "{", "$", "extension", "=", "explode", "(", "'.'", ",", "basename", "(", "$", "entry", ")", ")", ";", "$", "ext", "=", "$", "extension", "[", "count", "(", "$", "extension", ")", "-", "1", "]", ";", "if", "(", "$", "ext", "==", "$", "this", "->", "_type", ")", "{", "$", "this", "->", "_setFile", "(", "$", "path", ".", "$", "entry", ")", ";", "}", "}", "closedir", "(", "$", "handle", ")", ";", "}", "}" ]
configure a directory @access public @param $path string @return void @since 3.0 @package Gcs\Framework\Core\Asset
[ "configure", "a", "directory" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Asset/Asset.php#L192-L205
236,092
fabsgc/framework
Core/Asset/Asset.php
Asset._parseRelativePathCss
protected function _parseRelativePathCss($m) { /** * We take the page. Each time we have a '../' in a path file in the css, we drop a folder of the parent file. Zxample : * css file : css/dossier/truc/test.css * image file in css : ../../test.png * we have two ../ so we delete two folder : css/test/test.png */ $pathReplace = ''; if (!preg_match('~(?:f|ht)tps?://~i', $m[1]) && !preg_match('~(data)~i', $m[1])) { //we clear the '/' at the beginning $m[1] = preg_replace("#^/#isU", '', $m[1]); $m[1] = str_replace('"', '', $m[1]); $m[1] = str_replace("'", '', $m[1]); $this->_currentPath = preg_replace("#^/#isU", '', $this->_currentPath); //on count the number of '../' $numberParentDir = substr_count($m[1], '../'); if ($numberParentDir > 0) { for ($i = 0; $i < $numberParentDir; $i++) { $pathReplace .= '(.[^\/]+)\/'; } $pathReplace .= '$'; $newCurrentPath = preg_replace('#' . $pathReplace . '#isU', '/', $this->_currentPath); $m[1] = preg_replace('#\.\./#isU', '', $m[1]); if ($newCurrentPath != $this->_currentPath) { $m[1] = $newCurrentPath . $m[1]; } else if (!preg_match('#^' . preg_quote($newCurrentPath) . '#isU', $m[1])) { if (!preg_match('#^/asset#isU', $m[1]) && !preg_match('#^asset#isU', $m[1])) { $m[1] = $newCurrentPath . $m[1]; } } } if (!preg_match('#^/#isU', $m[1])) { $m[1] = '/' . $m[1]; } if (Config::config()['user']['output']['https']) { return 'https://' . str_replace('//', '/', $_SERVER['HTTP_HOST'] . '/' . Config::config()['user']['framework']['folder'] . $m[1]); } else { return 'http://' . str_replace('//', '/', $_SERVER['HTTP_HOST'] . '/' . Config::config()['user']['framework']['folder'] . $m[1]); } } else { return $m[1]; } }
php
protected function _parseRelativePathCss($m) { /** * We take the page. Each time we have a '../' in a path file in the css, we drop a folder of the parent file. Zxample : * css file : css/dossier/truc/test.css * image file in css : ../../test.png * we have two ../ so we delete two folder : css/test/test.png */ $pathReplace = ''; if (!preg_match('~(?:f|ht)tps?://~i', $m[1]) && !preg_match('~(data)~i', $m[1])) { //we clear the '/' at the beginning $m[1] = preg_replace("#^/#isU", '', $m[1]); $m[1] = str_replace('"', '', $m[1]); $m[1] = str_replace("'", '', $m[1]); $this->_currentPath = preg_replace("#^/#isU", '', $this->_currentPath); //on count the number of '../' $numberParentDir = substr_count($m[1], '../'); if ($numberParentDir > 0) { for ($i = 0; $i < $numberParentDir; $i++) { $pathReplace .= '(.[^\/]+)\/'; } $pathReplace .= '$'; $newCurrentPath = preg_replace('#' . $pathReplace . '#isU', '/', $this->_currentPath); $m[1] = preg_replace('#\.\./#isU', '', $m[1]); if ($newCurrentPath != $this->_currentPath) { $m[1] = $newCurrentPath . $m[1]; } else if (!preg_match('#^' . preg_quote($newCurrentPath) . '#isU', $m[1])) { if (!preg_match('#^/asset#isU', $m[1]) && !preg_match('#^asset#isU', $m[1])) { $m[1] = $newCurrentPath . $m[1]; } } } if (!preg_match('#^/#isU', $m[1])) { $m[1] = '/' . $m[1]; } if (Config::config()['user']['output']['https']) { return 'https://' . str_replace('//', '/', $_SERVER['HTTP_HOST'] . '/' . Config::config()['user']['framework']['folder'] . $m[1]); } else { return 'http://' . str_replace('//', '/', $_SERVER['HTTP_HOST'] . '/' . Config::config()['user']['framework']['folder'] . $m[1]); } } else { return $m[1]; } }
[ "protected", "function", "_parseRelativePathCss", "(", "$", "m", ")", "{", "/**\n * We take the page. Each time we have a '../' in a path file in the css, we drop a folder of the parent file. Zxample :\n * css file : css/dossier/truc/test.css\n * image file in css : ../../test.png\n * we have two ../ so we delete two folder : css/test/test.png\n */", "$", "pathReplace", "=", "''", ";", "if", "(", "!", "preg_match", "(", "'~(?:f|ht)tps?://~i'", ",", "$", "m", "[", "1", "]", ")", "&&", "!", "preg_match", "(", "'~(data)~i'", ",", "$", "m", "[", "1", "]", ")", ")", "{", "//we clear the '/' at the beginning", "$", "m", "[", "1", "]", "=", "preg_replace", "(", "\"#^/#isU\"", ",", "''", ",", "$", "m", "[", "1", "]", ")", ";", "$", "m", "[", "1", "]", "=", "str_replace", "(", "'\"'", ",", "''", ",", "$", "m", "[", "1", "]", ")", ";", "$", "m", "[", "1", "]", "=", "str_replace", "(", "\"'\"", ",", "''", ",", "$", "m", "[", "1", "]", ")", ";", "$", "this", "->", "_currentPath", "=", "preg_replace", "(", "\"#^/#isU\"", ",", "''", ",", "$", "this", "->", "_currentPath", ")", ";", "//on count the number of '../'", "$", "numberParentDir", "=", "substr_count", "(", "$", "m", "[", "1", "]", ",", "'../'", ")", ";", "if", "(", "$", "numberParentDir", ">", "0", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "numberParentDir", ";", "$", "i", "++", ")", "{", "$", "pathReplace", ".=", "'(.[^\\/]+)\\/'", ";", "}", "$", "pathReplace", ".=", "'$'", ";", "$", "newCurrentPath", "=", "preg_replace", "(", "'#'", ".", "$", "pathReplace", ".", "'#isU'", ",", "'/'", ",", "$", "this", "->", "_currentPath", ")", ";", "$", "m", "[", "1", "]", "=", "preg_replace", "(", "'#\\.\\./#isU'", ",", "''", ",", "$", "m", "[", "1", "]", ")", ";", "if", "(", "$", "newCurrentPath", "!=", "$", "this", "->", "_currentPath", ")", "{", "$", "m", "[", "1", "]", "=", "$", "newCurrentPath", ".", "$", "m", "[", "1", "]", ";", "}", "else", "if", "(", "!", "preg_match", "(", "'#^'", ".", "preg_quote", "(", "$", "newCurrentPath", ")", ".", "'#isU'", ",", "$", "m", "[", "1", "]", ")", ")", "{", "if", "(", "!", "preg_match", "(", "'#^/asset#isU'", ",", "$", "m", "[", "1", "]", ")", "&&", "!", "preg_match", "(", "'#^asset#isU'", ",", "$", "m", "[", "1", "]", ")", ")", "{", "$", "m", "[", "1", "]", "=", "$", "newCurrentPath", ".", "$", "m", "[", "1", "]", ";", "}", "}", "}", "if", "(", "!", "preg_match", "(", "'#^/#isU'", ",", "$", "m", "[", "1", "]", ")", ")", "{", "$", "m", "[", "1", "]", "=", "'/'", ".", "$", "m", "[", "1", "]", ";", "}", "if", "(", "Config", "::", "config", "(", ")", "[", "'user'", "]", "[", "'output'", "]", "[", "'https'", "]", ")", "{", "return", "'https://'", ".", "str_replace", "(", "'//'", ",", "'/'", ",", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ".", "'/'", ".", "Config", "::", "config", "(", ")", "[", "'user'", "]", "[", "'framework'", "]", "[", "'folder'", "]", ".", "$", "m", "[", "1", "]", ")", ";", "}", "else", "{", "return", "'http://'", ".", "str_replace", "(", "'//'", ",", "'/'", ",", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ".", "'/'", ".", "Config", "::", "config", "(", ")", "[", "'user'", "]", "[", "'framework'", "]", "[", "'folder'", "]", ".", "$", "m", "[", "1", "]", ")", ";", "}", "}", "else", "{", "return", "$", "m", "[", "1", "]", ";", "}", "}" ]
correct wrong links @access public @param $m array @return string @since 3.0 @package Gcs\Framework\Core\Asset
[ "correct", "wrong", "links" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Asset/Asset.php#L242-L295
236,093
fabsgc/framework
Core/Asset/Asset.php
Asset._compress
protected function _compress() { //$before = '(?<=[:(, ])'; //$after = '(?=[ ,);}])'; //$units = '(em|ex|%|px|cm|mm|in|pt|pc|ch|rem|vh|vw|vmin|vmax|vm)'; foreach ($this->_data as $value) { $this->_concatContent .= $value; } if ($this->_type == 'css') { $this->_concatContent = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $this->_concatContent); $this->_concatContent = str_replace(': ', ':', $this->_concatContent); $this->_concatContent = str_replace(["\r\n", "\r", "\n", "\t", ' ', ' ', ' '], '', $this->_concatContent); } }
php
protected function _compress() { //$before = '(?<=[:(, ])'; //$after = '(?=[ ,);}])'; //$units = '(em|ex|%|px|cm|mm|in|pt|pc|ch|rem|vh|vw|vmin|vmax|vm)'; foreach ($this->_data as $value) { $this->_concatContent .= $value; } if ($this->_type == 'css') { $this->_concatContent = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $this->_concatContent); $this->_concatContent = str_replace(': ', ':', $this->_concatContent); $this->_concatContent = str_replace(["\r\n", "\r", "\n", "\t", ' ', ' ', ' '], '', $this->_concatContent); } }
[ "protected", "function", "_compress", "(", ")", "{", "//$before = '(?<=[:(, ])';", "//$after = '(?=[ ,);}])';", "//$units = '(em|ex|%|px|cm|mm|in|pt|pc|ch|rem|vh|vw|vmin|vmax|vm)';", "foreach", "(", "$", "this", "->", "_data", "as", "$", "value", ")", "{", "$", "this", "->", "_concatContent", ".=", "$", "value", ";", "}", "if", "(", "$", "this", "->", "_type", "==", "'css'", ")", "{", "$", "this", "->", "_concatContent", "=", "preg_replace", "(", "'!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!'", ",", "''", ",", "$", "this", "->", "_concatContent", ")", ";", "$", "this", "->", "_concatContent", "=", "str_replace", "(", "': '", ",", "':'", ",", "$", "this", "->", "_concatContent", ")", ";", "$", "this", "->", "_concatContent", "=", "str_replace", "(", "[", "\"\\r\\n\"", ",", "\"\\r\"", ",", "\"\\n\"", ",", "\"\\t\"", ",", "' '", ",", "' '", ",", "' '", "]", ",", "''", ",", "$", "this", "->", "_concatContent", ")", ";", "}", "}" ]
concatenate parser content @access public @return void @since 3.0 @package Gcs\Framework\Core\Asset
[ "concatenate", "parser", "content" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Asset/Asset.php#L305-L319
236,094
Ingewikkeld/oauth-server-bundle
src/Ingewikkeld/Rest/OAuthServerBundle/ResourceMapper/Client.php
Client.getResource
public function getResource($identifier) { /** @var ClientEntity $client */ $client = $this->getRepository()->findOneBy(array('id' => $identifier)); if (!$client) { throw new NotFoundHttpException( $this->translator->trans('error.client_not_found', array('%id%' => $identifier)) ); } return $this->createResourceFromClient($client); }
php
public function getResource($identifier) { /** @var ClientEntity $client */ $client = $this->getRepository()->findOneBy(array('id' => $identifier)); if (!$client) { throw new NotFoundHttpException( $this->translator->trans('error.client_not_found', array('%id%' => $identifier)) ); } return $this->createResourceFromClient($client); }
[ "public", "function", "getResource", "(", "$", "identifier", ")", "{", "/** @var ClientEntity $client */", "$", "client", "=", "$", "this", "->", "getRepository", "(", ")", "->", "findOneBy", "(", "array", "(", "'id'", "=>", "$", "identifier", ")", ")", ";", "if", "(", "!", "$", "client", ")", "{", "throw", "new", "NotFoundHttpException", "(", "$", "this", "->", "translator", "->", "trans", "(", "'error.client_not_found'", ",", "array", "(", "'%id%'", "=>", "$", "identifier", ")", ")", ")", ";", "}", "return", "$", "this", "->", "createResourceFromClient", "(", "$", "client", ")", ";", "}" ]
Returns the oAuth2 Client with the given identifier. @param string|integer $identifier @throws NotFoundHttpException if the client could not be found. @return Resource
[ "Returns", "the", "oAuth2", "Client", "with", "the", "given", "identifier", "." ]
b5957414e57aeb2223d3b403aff4b108c10fd5cc
https://github.com/Ingewikkeld/oauth-server-bundle/blob/b5957414e57aeb2223d3b403aff4b108c10fd5cc/src/Ingewikkeld/Rest/OAuthServerBundle/ResourceMapper/Client.php#L60-L71
236,095
Ingewikkeld/oauth-server-bundle
src/Ingewikkeld/Rest/OAuthServerBundle/ResourceMapper/Client.php
Client.getCollection
public function getCollection(array $options = array()) { /** @var ClientEntity[] $collection */ $collection = $this->getRepository()->findAll(); $resource = new Resource($this->generateBrowseUrl(), array('count' => count($collection))); foreach ($collection as $element) { $resource->setEmbedded('client', $this->createResourceFromClient($element)); } return $resource; }
php
public function getCollection(array $options = array()) { /** @var ClientEntity[] $collection */ $collection = $this->getRepository()->findAll(); $resource = new Resource($this->generateBrowseUrl(), array('count' => count($collection))); foreach ($collection as $element) { $resource->setEmbedded('client', $this->createResourceFromClient($element)); } return $resource; }
[ "public", "function", "getCollection", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "/** @var ClientEntity[] $collection */", "$", "collection", "=", "$", "this", "->", "getRepository", "(", ")", "->", "findAll", "(", ")", ";", "$", "resource", "=", "new", "Resource", "(", "$", "this", "->", "generateBrowseUrl", "(", ")", ",", "array", "(", "'count'", "=>", "count", "(", "$", "collection", ")", ")", ")", ";", "foreach", "(", "$", "collection", "as", "$", "element", ")", "{", "$", "resource", "->", "setEmbedded", "(", "'client'", ",", "$", "this", "->", "createResourceFromClient", "(", "$", "element", ")", ")", ";", "}", "return", "$", "resource", ";", "}" ]
Returns all clients in a single collection resource. @param string[] $options @return Resource
[ "Returns", "all", "clients", "in", "a", "single", "collection", "resource", "." ]
b5957414e57aeb2223d3b403aff4b108c10fd5cc
https://github.com/Ingewikkeld/oauth-server-bundle/blob/b5957414e57aeb2223d3b403aff4b108c10fd5cc/src/Ingewikkeld/Rest/OAuthServerBundle/ResourceMapper/Client.php#L80-L91
236,096
Ingewikkeld/oauth-server-bundle
src/Ingewikkeld/Rest/OAuthServerBundle/ResourceMapper/Client.php
Client.delete
public function delete(Resource $resource) { $data = $resource->toArray(); $client = $this->getRepository()->findOneBy(array('id' => $data['id'])); if (!$client) { $errorMessage = $this->translator->trans('error.client_not_found', array('%id%' => $data['id'])); throw new NotFoundHttpException($errorMessage); } $this->entityManager->remove($client); }
php
public function delete(Resource $resource) { $data = $resource->toArray(); $client = $this->getRepository()->findOneBy(array('id' => $data['id'])); if (!$client) { $errorMessage = $this->translator->trans('error.client_not_found', array('%id%' => $data['id'])); throw new NotFoundHttpException($errorMessage); } $this->entityManager->remove($client); }
[ "public", "function", "delete", "(", "Resource", "$", "resource", ")", "{", "$", "data", "=", "$", "resource", "->", "toArray", "(", ")", ";", "$", "client", "=", "$", "this", "->", "getRepository", "(", ")", "->", "findOneBy", "(", "array", "(", "'id'", "=>", "$", "data", "[", "'id'", "]", ")", ")", ";", "if", "(", "!", "$", "client", ")", "{", "$", "errorMessage", "=", "$", "this", "->", "translator", "->", "trans", "(", "'error.client_not_found'", ",", "array", "(", "'%id%'", "=>", "$", "data", "[", "'id'", "]", ")", ")", ";", "throw", "new", "NotFoundHttpException", "(", "$", "errorMessage", ")", ";", "}", "$", "this", "->", "entityManager", "->", "remove", "(", "$", "client", ")", ";", "}" ]
Removes the Client from the database. @param \Hal\Resource $resource @throws NotFoundHttpException if no client with the given id could be found. @return void
[ "Removes", "the", "Client", "from", "the", "database", "." ]
b5957414e57aeb2223d3b403aff4b108c10fd5cc
https://github.com/Ingewikkeld/oauth-server-bundle/blob/b5957414e57aeb2223d3b403aff4b108c10fd5cc/src/Ingewikkeld/Rest/OAuthServerBundle/ResourceMapper/Client.php#L151-L162
236,097
Ingewikkeld/oauth-server-bundle
src/Ingewikkeld/Rest/OAuthServerBundle/ResourceMapper/Client.php
Client.createResourceFromClient
protected function createResourceFromClient(ClientEntity $client) { $resource = new Resource( $this->generateReadUrl($client->getId()), array( 'id' => $client->getId(), 'publicId' => $client->getPublicId(), 'secret' => $client->getSecret(), 'redirectUris' => $client->getRedirectUris(), 'grants' => $client->getAllowedGrantTypes(), ) ); return $resource; }
php
protected function createResourceFromClient(ClientEntity $client) { $resource = new Resource( $this->generateReadUrl($client->getId()), array( 'id' => $client->getId(), 'publicId' => $client->getPublicId(), 'secret' => $client->getSecret(), 'redirectUris' => $client->getRedirectUris(), 'grants' => $client->getAllowedGrantTypes(), ) ); return $resource; }
[ "protected", "function", "createResourceFromClient", "(", "ClientEntity", "$", "client", ")", "{", "$", "resource", "=", "new", "Resource", "(", "$", "this", "->", "generateReadUrl", "(", "$", "client", "->", "getId", "(", ")", ")", ",", "array", "(", "'id'", "=>", "$", "client", "->", "getId", "(", ")", ",", "'publicId'", "=>", "$", "client", "->", "getPublicId", "(", ")", ",", "'secret'", "=>", "$", "client", "->", "getSecret", "(", ")", ",", "'redirectUris'", "=>", "$", "client", "->", "getRedirectUris", "(", ")", ",", "'grants'", "=>", "$", "client", "->", "getAllowedGrantTypes", "(", ")", ",", ")", ")", ";", "return", "$", "resource", ";", "}" ]
Creates a new resource from the given Client entity. @param ClientEntity $client @return Resource
[ "Creates", "a", "new", "resource", "from", "the", "given", "Client", "entity", "." ]
b5957414e57aeb2223d3b403aff4b108c10fd5cc
https://github.com/Ingewikkeld/oauth-server-bundle/blob/b5957414e57aeb2223d3b403aff4b108c10fd5cc/src/Ingewikkeld/Rest/OAuthServerBundle/ResourceMapper/Client.php#L230-L244
236,098
vgrdominik/VGRElasticsearchHttpFoundationBundle
Security/Http/Firewall/ElasticsearchContextListener.php
ElasticsearchContextListener.handle
public function handle(GetResponseEvent $event) { if (!$this->registered && null !== $this->dispatcher && $event->isMasterRequest()) { $this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse')); $this->registered = true; } $request = $event->getRequest(); $session = $request->getSession(); /*$sessionId = $session->getId(); if(empty($sessionId)) { $session = null; }*/ if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) { $this->context->setToken(null); return; } $token = unserialize($token); if (null !== $this->logger) { $this->logger->debug('Read SecurityContext from the session'); } if ($token instanceof TokenInterface) { $token = $this->refreshUser($token); } elseif (null !== $token) { if (null !== $this->logger) { $this->logger->warning(sprintf('Session includes a "%s" where a security token is expected', is_object($token) ? get_class($token) : gettype($token))); } $token = null; } $this->context->setToken($token); }
php
public function handle(GetResponseEvent $event) { if (!$this->registered && null !== $this->dispatcher && $event->isMasterRequest()) { $this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse')); $this->registered = true; } $request = $event->getRequest(); $session = $request->getSession(); /*$sessionId = $session->getId(); if(empty($sessionId)) { $session = null; }*/ if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) { $this->context->setToken(null); return; } $token = unserialize($token); if (null !== $this->logger) { $this->logger->debug('Read SecurityContext from the session'); } if ($token instanceof TokenInterface) { $token = $this->refreshUser($token); } elseif (null !== $token) { if (null !== $this->logger) { $this->logger->warning(sprintf('Session includes a "%s" where a security token is expected', is_object($token) ? get_class($token) : gettype($token))); } $token = null; } $this->context->setToken($token); }
[ "public", "function", "handle", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "registered", "&&", "null", "!==", "$", "this", "->", "dispatcher", "&&", "$", "event", "->", "isMasterRequest", "(", ")", ")", "{", "$", "this", "->", "dispatcher", "->", "addListener", "(", "KernelEvents", "::", "RESPONSE", ",", "array", "(", "$", "this", ",", "'onKernelResponse'", ")", ")", ";", "$", "this", "->", "registered", "=", "true", ";", "}", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "$", "session", "=", "$", "request", "->", "getSession", "(", ")", ";", "/*$sessionId = $session->getId();\n if(empty($sessionId))\n {\n $session = null;\n }*/", "if", "(", "null", "===", "$", "session", "||", "null", "===", "$", "token", "=", "$", "session", "->", "get", "(", "'_security_'", ".", "$", "this", "->", "contextKey", ")", ")", "{", "$", "this", "->", "context", "->", "setToken", "(", "null", ")", ";", "return", ";", "}", "$", "token", "=", "unserialize", "(", "$", "token", ")", ";", "if", "(", "null", "!==", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Read SecurityContext from the session'", ")", ";", "}", "if", "(", "$", "token", "instanceof", "TokenInterface", ")", "{", "$", "token", "=", "$", "this", "->", "refreshUser", "(", "$", "token", ")", ";", "}", "elseif", "(", "null", "!==", "$", "token", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "sprintf", "(", "'Session includes a \"%s\" where a security token is expected'", ",", "is_object", "(", "$", "token", ")", "?", "get_class", "(", "$", "token", ")", ":", "gettype", "(", "$", "token", ")", ")", ")", ";", "}", "$", "token", "=", "null", ";", "}", "$", "this", "->", "context", "->", "setToken", "(", "$", "token", ")", ";", "}" ]
Reads the SecurityContext from the session. @param GetResponseEvent $event A GetResponseEvent instance
[ "Reads", "the", "SecurityContext", "from", "the", "session", "." ]
06fad4b3619bfaf481b3141800d0b9eb5ae45b07
https://github.com/vgrdominik/VGRElasticsearchHttpFoundationBundle/blob/06fad4b3619bfaf481b3141800d0b9eb5ae45b07/Security/Http/Firewall/ElasticsearchContextListener.php#L91-L129
236,099
vgrdominik/VGRElasticsearchHttpFoundationBundle
Security/Http/Firewall/ElasticsearchContextListener.php
ElasticsearchContextListener.onKernelResponse
public function onKernelResponse(FilterResponseEvent $event) { if (!$event->isMasterRequest()) { return; } if (!$event->getRequest()->hasSession()) { return; } if (null !== $this->logger) { $this->logger->debug('Write SecurityContext in the session'); } $request = $event->getRequest(); $session = $request->getSession(); if (null === $session) { return; } if ((null === $token = $this->context->getToken()) || ($token instanceof AnonymousToken)) { if ($request->hasPreviousSession()) { $session->remove('_security_'.$this->contextKey); } } else { $session->set('_security_'.$this->contextKey, serialize($token)); } }
php
public function onKernelResponse(FilterResponseEvent $event) { if (!$event->isMasterRequest()) { return; } if (!$event->getRequest()->hasSession()) { return; } if (null !== $this->logger) { $this->logger->debug('Write SecurityContext in the session'); } $request = $event->getRequest(); $session = $request->getSession(); if (null === $session) { return; } if ((null === $token = $this->context->getToken()) || ($token instanceof AnonymousToken)) { if ($request->hasPreviousSession()) { $session->remove('_security_'.$this->contextKey); } } else { $session->set('_security_'.$this->contextKey, serialize($token)); } }
[ "public", "function", "onKernelResponse", "(", "FilterResponseEvent", "$", "event", ")", "{", "if", "(", "!", "$", "event", "->", "isMasterRequest", "(", ")", ")", "{", "return", ";", "}", "if", "(", "!", "$", "event", "->", "getRequest", "(", ")", "->", "hasSession", "(", ")", ")", "{", "return", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Write SecurityContext in the session'", ")", ";", "}", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "$", "session", "=", "$", "request", "->", "getSession", "(", ")", ";", "if", "(", "null", "===", "$", "session", ")", "{", "return", ";", "}", "if", "(", "(", "null", "===", "$", "token", "=", "$", "this", "->", "context", "->", "getToken", "(", ")", ")", "||", "(", "$", "token", "instanceof", "AnonymousToken", ")", ")", "{", "if", "(", "$", "request", "->", "hasPreviousSession", "(", ")", ")", "{", "$", "session", "->", "remove", "(", "'_security_'", ".", "$", "this", "->", "contextKey", ")", ";", "}", "}", "else", "{", "$", "session", "->", "set", "(", "'_security_'", ".", "$", "this", "->", "contextKey", ",", "serialize", "(", "$", "token", ")", ")", ";", "}", "}" ]
Writes the SecurityContext to the session. @param FilterResponseEvent $event A FilterResponseEvent instance
[ "Writes", "the", "SecurityContext", "to", "the", "session", "." ]
06fad4b3619bfaf481b3141800d0b9eb5ae45b07
https://github.com/vgrdominik/VGRElasticsearchHttpFoundationBundle/blob/06fad4b3619bfaf481b3141800d0b9eb5ae45b07/Security/Http/Firewall/ElasticsearchContextListener.php#L136-L164