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
23,300
WScore/Validation
src/Dio.php
Dio.setupRules
private function setupRules($rules) { // prepares filter for requiredIf $rules = Utils\HelperRequiredIf::prepare($this, $rules); // prepares filter for sameWith. $rules = Utils\HelperSameWith::prepare($this, $rules); return $rules; }
php
private function setupRules($rules) { // prepares filter for requiredIf $rules = Utils\HelperRequiredIf::prepare($this, $rules); // prepares filter for sameWith. $rules = Utils\HelperSameWith::prepare($this, $rules); return $rules; }
[ "private", "function", "setupRules", "(", "$", "rules", ")", "{", "// prepares filter for requiredIf", "$", "rules", "=", "Utils", "\\", "HelperRequiredIf", "::", "prepare", "(", "$", "this", ",", "$", "rules", ")", ";", "// prepares filter for sameWith.", "$", "rules", "=", "Utils", "\\", "HelperSameWith", "::", "prepare", "(", "$", "this", ",", "$", "rules", ")", ";", "return", "$", "rules", ";", "}" ]
set up rules; - add required rule based on requiredIf rule. - add sameAs rule based on sameWith rule. @param array|Rules $rules @return array|Rules
[ "set", "up", "rules", ";", "-", "add", "required", "rule", "based", "on", "requiredIf", "rule", ".", "-", "add", "sameAs", "rule", "based", "on", "sameWith", "rule", "." ]
25c0dca37d624bb0bb22f8e79ba54db2f69e0950
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Dio.php#L276-L285
23,301
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/IsArgumentInDocBlockValidator.php
IsArgumentInDocBlockValidator.existsParamTagWithArgument
private function existsParamTagWithArgument($parameters, ArgumentDescriptor $argument) { foreach ($parameters as $parameter) { if ($argument->getName() == $parameter->getVariableName()) { return true; } } return false; }
php
private function existsParamTagWithArgument($parameters, ArgumentDescriptor $argument) { foreach ($parameters as $parameter) { if ($argument->getName() == $parameter->getVariableName()) { return true; } } return false; }
[ "private", "function", "existsParamTagWithArgument", "(", "$", "parameters", ",", "ArgumentDescriptor", "$", "argument", ")", "{", "foreach", "(", "$", "parameters", "as", "$", "parameter", ")", "{", "if", "(", "$", "argument", "->", "getName", "(", ")", "==", "$", "parameter", "->", "getVariableName", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns whether the list of param tags features the given argument. @param ParamDescriptor[]|Collection $parameters @param ArgumentDescriptor $argument @return boolean
[ "Returns", "whether", "the", "list", "of", "param", "tags", "features", "the", "given", "argument", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/IsArgumentInDocBlockValidator.php#L62-L71
23,302
heidelpay/PhpDoc
src/phpDocumentor/Parser/Command/Project/ParseCommand.php
ParseCommand.getProgressBar
protected function getProgressBar(InputInterface $input) { $progress = parent::getProgressBar($input); if (!$progress) { return null; } $this->getService('event_dispatcher')->addListener( 'parser.file.pre', function (PreFileEvent $event) use ($progress) { $progress->advance(); } ); return $progress; }
php
protected function getProgressBar(InputInterface $input) { $progress = parent::getProgressBar($input); if (!$progress) { return null; } $this->getService('event_dispatcher')->addListener( 'parser.file.pre', function (PreFileEvent $event) use ($progress) { $progress->advance(); } ); return $progress; }
[ "protected", "function", "getProgressBar", "(", "InputInterface", "$", "input", ")", "{", "$", "progress", "=", "parent", "::", "getProgressBar", "(", "$", "input", ")", ";", "if", "(", "!", "$", "progress", ")", "{", "return", "null", ";", "}", "$", "this", "->", "getService", "(", "'event_dispatcher'", ")", "->", "addListener", "(", "'parser.file.pre'", ",", "function", "(", "PreFileEvent", "$", "event", ")", "use", "(", "$", "progress", ")", "{", "$", "progress", "->", "advance", "(", ")", ";", "}", ")", ";", "return", "$", "progress", ";", "}" ]
Adds the parser.file.pre event to the advance the progressbar. @param InputInterface $input @return \Symfony\Component\Console\Helper\HelperInterface|null
[ "Adds", "the", "parser", ".", "file", ".", "pre", "event", "to", "the", "advance", "the", "progressbar", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/Command/Project/ParseCommand.php#L346-L361
23,303
zhouyl/mellivora
Mellivora/Database/Query/Grammars/PostgresGrammar.php
PostgresGrammar.compileUpdateJoinWheres
protected function compileUpdateJoinWheres(Builder $query) { $joinWheres = []; // Here we will just loop through all of the join constraints and compile them // all out then implode them. This should give us "where" like syntax after // everything has been built and then we will join it to the real wheres. foreach ($query->joins as $join) { foreach ($join->wheres as $where) { $method = "where{$where['type']}"; $joinWheres[] = $where['boolean'] . ' ' . $this->{$method}($query, $where); } } return implode(' ', $joinWheres); }
php
protected function compileUpdateJoinWheres(Builder $query) { $joinWheres = []; // Here we will just loop through all of the join constraints and compile them // all out then implode them. This should give us "where" like syntax after // everything has been built and then we will join it to the real wheres. foreach ($query->joins as $join) { foreach ($join->wheres as $where) { $method = "where{$where['type']}"; $joinWheres[] = $where['boolean'] . ' ' . $this->{$method}($query, $where); } } return implode(' ', $joinWheres); }
[ "protected", "function", "compileUpdateJoinWheres", "(", "Builder", "$", "query", ")", "{", "$", "joinWheres", "=", "[", "]", ";", "// Here we will just loop through all of the join constraints and compile them", "// all out then implode them. This should give us \"where\" like syntax after", "// everything has been built and then we will join it to the real wheres.", "foreach", "(", "$", "query", "->", "joins", "as", "$", "join", ")", "{", "foreach", "(", "$", "join", "->", "wheres", "as", "$", "where", ")", "{", "$", "method", "=", "\"where{$where['type']}\"", ";", "$", "joinWheres", "[", "]", "=", "$", "where", "[", "'boolean'", "]", ".", "' '", ".", "$", "this", "->", "{", "$", "method", "}", "(", "$", "query", ",", "$", "where", ")", ";", "}", "}", "return", "implode", "(", "' '", ",", "$", "joinWheres", ")", ";", "}" ]
Compile the "join" clause where clauses for an update. @param \Mellivora\Database\Query\Builder $query @return string
[ "Compile", "the", "join", "clause", "where", "clauses", "for", "an", "update", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Query/Grammars/PostgresGrammar.php#L189-L205
23,304
xiewulong/yii2-fileupload
oss/libs/guzzle/plugin/Guzzle/Plugin/Backoff/BackoffPlugin.php
BackoffPlugin.onRequestSent
public function onRequestSent(Event $event) { $request = $event['request']; $response = $event['response']; $exception = $event['exception']; $params = $request->getParams(); $retries = (int) $params->get(self::RETRY_PARAM); $delay = $this->strategy->getBackoffPeriod($retries, $request, $response, $exception); if ($delay !== false) { // Calculate how long to wait until the request should be retried $params->set(self::RETRY_PARAM, ++$retries) ->set(self::DELAY_PARAM, microtime(true) + $delay); // Send the request again $request->setState(RequestInterface::STATE_TRANSFER); $this->dispatch(self::RETRY_EVENT, array( 'request' => $request, 'response' => $response, 'handle' => $exception ? $exception->getCurlHandle() : null, 'retries' => $retries, 'delay' => $delay )); } }
php
public function onRequestSent(Event $event) { $request = $event['request']; $response = $event['response']; $exception = $event['exception']; $params = $request->getParams(); $retries = (int) $params->get(self::RETRY_PARAM); $delay = $this->strategy->getBackoffPeriod($retries, $request, $response, $exception); if ($delay !== false) { // Calculate how long to wait until the request should be retried $params->set(self::RETRY_PARAM, ++$retries) ->set(self::DELAY_PARAM, microtime(true) + $delay); // Send the request again $request->setState(RequestInterface::STATE_TRANSFER); $this->dispatch(self::RETRY_EVENT, array( 'request' => $request, 'response' => $response, 'handle' => $exception ? $exception->getCurlHandle() : null, 'retries' => $retries, 'delay' => $delay )); } }
[ "public", "function", "onRequestSent", "(", "Event", "$", "event", ")", "{", "$", "request", "=", "$", "event", "[", "'request'", "]", ";", "$", "response", "=", "$", "event", "[", "'response'", "]", ";", "$", "exception", "=", "$", "event", "[", "'exception'", "]", ";", "$", "params", "=", "$", "request", "->", "getParams", "(", ")", ";", "$", "retries", "=", "(", "int", ")", "$", "params", "->", "get", "(", "self", "::", "RETRY_PARAM", ")", ";", "$", "delay", "=", "$", "this", "->", "strategy", "->", "getBackoffPeriod", "(", "$", "retries", ",", "$", "request", ",", "$", "response", ",", "$", "exception", ")", ";", "if", "(", "$", "delay", "!==", "false", ")", "{", "// Calculate how long to wait until the request should be retried", "$", "params", "->", "set", "(", "self", "::", "RETRY_PARAM", ",", "++", "$", "retries", ")", "->", "set", "(", "self", "::", "DELAY_PARAM", ",", "microtime", "(", "true", ")", "+", "$", "delay", ")", ";", "// Send the request again", "$", "request", "->", "setState", "(", "RequestInterface", "::", "STATE_TRANSFER", ")", ";", "$", "this", "->", "dispatch", "(", "self", "::", "RETRY_EVENT", ",", "array", "(", "'request'", "=>", "$", "request", ",", "'response'", "=>", "$", "response", ",", "'handle'", "=>", "$", "exception", "?", "$", "exception", "->", "getCurlHandle", "(", ")", ":", "null", ",", "'retries'", "=>", "$", "retries", ",", "'delay'", "=>", "$", "delay", ")", ")", ";", "}", "}" ]
Called when a request has been sent and isn't finished processing @param Event $event
[ "Called", "when", "a", "request", "has", "been", "sent", "and", "isn", "t", "finished", "processing" ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/plugin/Guzzle/Plugin/Backoff/BackoffPlugin.php#L76-L100
23,305
expectation-php/expect
src/config/ConfigurationLoader.php
ConfigurationLoader.createPackages
private function createPackages(array $packages) { $matcherPackages = []; foreach ($packages as $package) { $reflection = new ReflectionClass($package); if ($reflection->implementsInterface(self::PACKAGE_REGISTRAR) === false) { throw NotAvailableException::createForPackage(self::PACKAGE_REGISTRAR); } $matcherPackages[] = $reflection->newInstance(); } return $matcherPackages; }
php
private function createPackages(array $packages) { $matcherPackages = []; foreach ($packages as $package) { $reflection = new ReflectionClass($package); if ($reflection->implementsInterface(self::PACKAGE_REGISTRAR) === false) { throw NotAvailableException::createForPackage(self::PACKAGE_REGISTRAR); } $matcherPackages[] = $reflection->newInstance(); } return $matcherPackages; }
[ "private", "function", "createPackages", "(", "array", "$", "packages", ")", "{", "$", "matcherPackages", "=", "[", "]", ";", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "package", ")", ";", "if", "(", "$", "reflection", "->", "implementsInterface", "(", "self", "::", "PACKAGE_REGISTRAR", ")", "===", "false", ")", "{", "throw", "NotAvailableException", "::", "createForPackage", "(", "self", "::", "PACKAGE_REGISTRAR", ")", ";", "}", "$", "matcherPackages", "[", "]", "=", "$", "reflection", "->", "newInstance", "(", ")", ";", "}", "return", "$", "matcherPackages", ";", "}" ]
Create a few new package registrars @param array $packages @return \expect\PackageRegistrar[]
[ "Create", "a", "few", "new", "package", "registrars" ]
1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/config/ConfigurationLoader.php#L62-L76
23,306
expectation-php/expect
src/config/ConfigurationLoader.php
ConfigurationLoader.createReporter
private function createReporter($reporter) { $reflection = new ReflectionClass($reporter); if ($reflection->implementsInterface(self::REPORTER) === false) { throw NotAvailableException::createForReporter(self::REPORTER); } return $reflection->newInstance(); }
php
private function createReporter($reporter) { $reflection = new ReflectionClass($reporter); if ($reflection->implementsInterface(self::REPORTER) === false) { throw NotAvailableException::createForReporter(self::REPORTER); } return $reflection->newInstance(); }
[ "private", "function", "createReporter", "(", "$", "reporter", ")", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "reporter", ")", ";", "if", "(", "$", "reflection", "->", "implementsInterface", "(", "self", "::", "REPORTER", ")", "===", "false", ")", "{", "throw", "NotAvailableException", "::", "createForReporter", "(", "self", "::", "REPORTER", ")", ";", "}", "return", "$", "reflection", "->", "newInstance", "(", ")", ";", "}" ]
Create a new result reporter @param string $reporter @return \expect\ResultReporter
[ "Create", "a", "new", "result", "reporter" ]
1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/config/ConfigurationLoader.php#L85-L94
23,307
engineor/flysystem-runabove
src/RunaboveAdapter.php
RunaboveAdapter.getObject
protected function getObject($path) { $location = $this->applyPathPrefix($path); return $this->container->getObject($location); }
php
protected function getObject($path) { $location = $this->applyPathPrefix($path); return $this->container->getObject($location); }
[ "protected", "function", "getObject", "(", "$", "path", ")", "{", "$", "location", "=", "$", "this", "->", "applyPathPrefix", "(", "$", "path", ")", ";", "return", "$", "this", "->", "container", "->", "getObject", "(", "$", "location", ")", ";", "}" ]
Get an object. @param string $path @return DataObject
[ "Get", "an", "object", "." ]
d8c22dbf25c3bf2b62187f9da07efb48888d44de
https://github.com/engineor/flysystem-runabove/blob/d8c22dbf25c3bf2b62187f9da07efb48888d44de/src/RunaboveAdapter.php#L60-L65
23,308
raulfraile/ladybug-installer
src/Ladybug/Installer/Composer/Installer.php
Installer.getRootPath
protected function getRootPath(PackageInterface $package) { $rootPath = $this->vendorDir . '/raulfraile/ladybug-themes/Ladybug/'; if ($this->composer->getPackage()->getName() === 'raulfraile/ladybug') { $rootPath = 'data/' . ($package->getType() === self::PACKAGE_TYPE_THEME ? 'themes' : 'plugins') . '/Ladybug/'; } $rootPath .= ($package->getType() === self::PACKAGE_TYPE_THEME) ? 'Theme' : 'Plugin'; return $rootPath; }
php
protected function getRootPath(PackageInterface $package) { $rootPath = $this->vendorDir . '/raulfraile/ladybug-themes/Ladybug/'; if ($this->composer->getPackage()->getName() === 'raulfraile/ladybug') { $rootPath = 'data/' . ($package->getType() === self::PACKAGE_TYPE_THEME ? 'themes' : 'plugins') . '/Ladybug/'; } $rootPath .= ($package->getType() === self::PACKAGE_TYPE_THEME) ? 'Theme' : 'Plugin'; return $rootPath; }
[ "protected", "function", "getRootPath", "(", "PackageInterface", "$", "package", ")", "{", "$", "rootPath", "=", "$", "this", "->", "vendorDir", ".", "'/raulfraile/ladybug-themes/Ladybug/'", ";", "if", "(", "$", "this", "->", "composer", "->", "getPackage", "(", ")", "->", "getName", "(", ")", "===", "'raulfraile/ladybug'", ")", "{", "$", "rootPath", "=", "'data/'", ".", "(", "$", "package", "->", "getType", "(", ")", "===", "self", "::", "PACKAGE_TYPE_THEME", "?", "'themes'", ":", "'plugins'", ")", ".", "'/Ladybug/'", ";", "}", "$", "rootPath", ".=", "(", "$", "package", "->", "getType", "(", ")", "===", "self", "::", "PACKAGE_TYPE_THEME", ")", "?", "'Theme'", ":", "'Plugin'", ";", "return", "$", "rootPath", ";", "}" ]
Returns the root installation path for templates. @param PackageInterface $package @return string a path relative to the root of the composer.json
[ "Returns", "the", "root", "installation", "path", "for", "templates", "." ]
04f38f50cac673d3ca93de9c0805889e37804b33
https://github.com/raulfraile/ladybug-installer/blob/04f38f50cac673d3ca93de9c0805889e37804b33/src/Ladybug/Installer/Composer/Installer.php#L55-L66
23,309
pinepain/amqpy
src/AMQPy/AbstractListener.php
AbstractListener.consume
public function consume(AbstractConsumer $consumer, $auto_ack = false) { if (!$consumer->active()) { // prevent dirty consumer been listening on queue return; } $outside_error = null; try { $consumer->begin($this); $this->queue->consume( function (AMQPEnvelope $envelope /*, AMQPQueue $queue*/) use ($consumer) { $delivery = $this->builder->build($envelope); $this->feed($delivery, $consumer); return $consumer->active(); }, $auto_ack ? AMQP_AUTOACK : AMQP_NOPARAM ); } catch (Exception $e) { $outside_error = $e; } try { $this->queue->cancel(); } catch (Exception $e) { } $consumer->end($this, $outside_error); if ($outside_error) { throw $outside_error; } }
php
public function consume(AbstractConsumer $consumer, $auto_ack = false) { if (!$consumer->active()) { // prevent dirty consumer been listening on queue return; } $outside_error = null; try { $consumer->begin($this); $this->queue->consume( function (AMQPEnvelope $envelope /*, AMQPQueue $queue*/) use ($consumer) { $delivery = $this->builder->build($envelope); $this->feed($delivery, $consumer); return $consumer->active(); }, $auto_ack ? AMQP_AUTOACK : AMQP_NOPARAM ); } catch (Exception $e) { $outside_error = $e; } try { $this->queue->cancel(); } catch (Exception $e) { } $consumer->end($this, $outside_error); if ($outside_error) { throw $outside_error; } }
[ "public", "function", "consume", "(", "AbstractConsumer", "$", "consumer", ",", "$", "auto_ack", "=", "false", ")", "{", "if", "(", "!", "$", "consumer", "->", "active", "(", ")", ")", "{", "// prevent dirty consumer been listening on queue", "return", ";", "}", "$", "outside_error", "=", "null", ";", "try", "{", "$", "consumer", "->", "begin", "(", "$", "this", ")", ";", "$", "this", "->", "queue", "->", "consume", "(", "function", "(", "AMQPEnvelope", "$", "envelope", "/*, AMQPQueue $queue*/", ")", "use", "(", "$", "consumer", ")", "{", "$", "delivery", "=", "$", "this", "->", "builder", "->", "build", "(", "$", "envelope", ")", ";", "$", "this", "->", "feed", "(", "$", "delivery", ",", "$", "consumer", ")", ";", "return", "$", "consumer", "->", "active", "(", ")", ";", "}", ",", "$", "auto_ack", "?", "AMQP_AUTOACK", ":", "AMQP_NOPARAM", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "outside_error", "=", "$", "e", ";", "}", "try", "{", "$", "this", "->", "queue", "->", "cancel", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "}", "$", "consumer", "->", "end", "(", "$", "this", ",", "$", "outside_error", ")", ";", "if", "(", "$", "outside_error", ")", "{", "throw", "$", "outside_error", ";", "}", "}" ]
Attach consumer to process payload from queue @param AbstractConsumer $consumer Consumer to process payload and handle possible errors @param bool $auto_ack Should message been acknowledged upon receive @return mixed @throws SerializerException @throws Exception Any exception from pre/post-consume handlers and from exception handler
[ "Attach", "consumer", "to", "process", "payload", "from", "queue" ]
fc61dacc37a97a100caf67232a72be32dd7cc896
https://github.com/pinepain/amqpy/blob/fc61dacc37a97a100caf67232a72be32dd7cc896/src/AMQPy/AbstractListener.php#L93-L128
23,310
hametuha/wpametu
src/WPametu/UI/Field/Taxonomy.php
Taxonomy.get_options
protected function get_options(){ $terms = get_terms($this->name); if( !$terms || is_wp_error($terms) ){ return []; }else{ $result = []; foreach( $terms as $term ){ $result[$term->term_id] = $term->name; } return $result; } }
php
protected function get_options(){ $terms = get_terms($this->name); if( !$terms || is_wp_error($terms) ){ return []; }else{ $result = []; foreach( $terms as $term ){ $result[$term->term_id] = $term->name; } return $result; } }
[ "protected", "function", "get_options", "(", ")", "{", "$", "terms", "=", "get_terms", "(", "$", "this", "->", "name", ")", ";", "if", "(", "!", "$", "terms", "||", "is_wp_error", "(", "$", "terms", ")", ")", "{", "return", "[", "]", ";", "}", "else", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "terms", "as", "$", "term", ")", "{", "$", "result", "[", "$", "term", "->", "term_id", "]", "=", "$", "term", "->", "name", ";", "}", "return", "$", "result", ";", "}", "}" ]
Get terms as option @return array
[ "Get", "terms", "as", "option" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Taxonomy.php#L53-L64
23,311
antaresproject/notifications
src/Http/Form/Form.php
Form.buttons
protected function buttons($fluent, Fieldset $fieldset) { $fieldset->control('button', 'cancel') ->field(function() { return app('html')->link(handles("antares::notifications/"), trans('Cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']); }); $acl = app('antares.acl')->make('antares/notifications'); if ($acl->can('notifications-preview')) { $fieldset->control('button', 'preview') ->attributes([ 'type' => 'button', 'value' => trans('Preview'), 'class' => 'btn btn-default notification-template-preview', 'url' => handles('antares::notifications/preview/' . $fluent->id), 'data-title' => trans('antares/notifications::messages.generating_notification_preview') ]) ->value(trans('Preview')); } if ($acl->can('notifications-test') && in_array($this->fluent->type, ['email', 'sms'])) { $fieldset->control('button', 'sendtest') ->attributes([ 'type' => 'button', 'class' => 'btn btn-default send-test-notification', 'rel' => handles('antares::notifications/sendtest', ['csrf' => true]) ]) ->value(trans('Send test')); } $fieldset->control('button', 'button') ->attributes(['type' => 'submit', 'class' => 'btn btn-primary']) ->value($fluent->id ? trans('antares/foundation::label.save_changes') : trans('Save')); }
php
protected function buttons($fluent, Fieldset $fieldset) { $fieldset->control('button', 'cancel') ->field(function() { return app('html')->link(handles("antares::notifications/"), trans('Cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']); }); $acl = app('antares.acl')->make('antares/notifications'); if ($acl->can('notifications-preview')) { $fieldset->control('button', 'preview') ->attributes([ 'type' => 'button', 'value' => trans('Preview'), 'class' => 'btn btn-default notification-template-preview', 'url' => handles('antares::notifications/preview/' . $fluent->id), 'data-title' => trans('antares/notifications::messages.generating_notification_preview') ]) ->value(trans('Preview')); } if ($acl->can('notifications-test') && in_array($this->fluent->type, ['email', 'sms'])) { $fieldset->control('button', 'sendtest') ->attributes([ 'type' => 'button', 'class' => 'btn btn-default send-test-notification', 'rel' => handles('antares::notifications/sendtest', ['csrf' => true]) ]) ->value(trans('Send test')); } $fieldset->control('button', 'button') ->attributes(['type' => 'submit', 'class' => 'btn btn-primary']) ->value($fluent->id ? trans('antares/foundation::label.save_changes') : trans('Save')); }
[ "protected", "function", "buttons", "(", "$", "fluent", ",", "Fieldset", "$", "fieldset", ")", "{", "$", "fieldset", "->", "control", "(", "'button'", ",", "'cancel'", ")", "->", "field", "(", "function", "(", ")", "{", "return", "app", "(", "'html'", ")", "->", "link", "(", "handles", "(", "\"antares::notifications/\"", ")", ",", "trans", "(", "'Cancel'", ")", ",", "[", "'class'", "=>", "'btn btn--md btn--default mdl-button mdl-js-button'", "]", ")", ";", "}", ")", ";", "$", "acl", "=", "app", "(", "'antares.acl'", ")", "->", "make", "(", "'antares/notifications'", ")", ";", "if", "(", "$", "acl", "->", "can", "(", "'notifications-preview'", ")", ")", "{", "$", "fieldset", "->", "control", "(", "'button'", ",", "'preview'", ")", "->", "attributes", "(", "[", "'type'", "=>", "'button'", ",", "'value'", "=>", "trans", "(", "'Preview'", ")", ",", "'class'", "=>", "'btn btn-default notification-template-preview'", ",", "'url'", "=>", "handles", "(", "'antares::notifications/preview/'", ".", "$", "fluent", "->", "id", ")", ",", "'data-title'", "=>", "trans", "(", "'antares/notifications::messages.generating_notification_preview'", ")", "]", ")", "->", "value", "(", "trans", "(", "'Preview'", ")", ")", ";", "}", "if", "(", "$", "acl", "->", "can", "(", "'notifications-test'", ")", "&&", "in_array", "(", "$", "this", "->", "fluent", "->", "type", ",", "[", "'email'", ",", "'sms'", "]", ")", ")", "{", "$", "fieldset", "->", "control", "(", "'button'", ",", "'sendtest'", ")", "->", "attributes", "(", "[", "'type'", "=>", "'button'", ",", "'class'", "=>", "'btn btn-default send-test-notification'", ",", "'rel'", "=>", "handles", "(", "'antares::notifications/sendtest'", ",", "[", "'csrf'", "=>", "true", "]", ")", "]", ")", "->", "value", "(", "trans", "(", "'Send test'", ")", ")", ";", "}", "$", "fieldset", "->", "control", "(", "'button'", ",", "'button'", ")", "->", "attributes", "(", "[", "'type'", "=>", "'submit'", ",", "'class'", "=>", "'btn btn-primary'", "]", ")", "->", "value", "(", "$", "fluent", "->", "id", "?", "trans", "(", "'antares/foundation::label.save_changes'", ")", ":", "trans", "(", "'Save'", ")", ")", ";", "}" ]
buttons in form @param Fluent $fluent @param Fieldset $fieldset
[ "buttons", "in", "form" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Form/Form.php#L160-L193
23,312
antaresproject/notifications
src/Http/Form/Form.php
Form.onCreate
public function onCreate() { $this->grid->attributes([ 'url' => handles('antares::notifications/store'), 'method' => 'POST', ]); $layout = ($this->fluent->type == 'sms') ? 'antares/notifications::admin.index.form_sms' : 'antares/notifications::admin.index.form'; $this->grid->layout($layout, $this->layoutAttributes); return $this; }
php
public function onCreate() { $this->grid->attributes([ 'url' => handles('antares::notifications/store'), 'method' => 'POST', ]); $layout = ($this->fluent->type == 'sms') ? 'antares/notifications::admin.index.form_sms' : 'antares/notifications::admin.index.form'; $this->grid->layout($layout, $this->layoutAttributes); return $this; }
[ "public", "function", "onCreate", "(", ")", "{", "$", "this", "->", "grid", "->", "attributes", "(", "[", "'url'", "=>", "handles", "(", "'antares::notifications/store'", ")", ",", "'method'", "=>", "'POST'", ",", "]", ")", ";", "$", "layout", "=", "(", "$", "this", "->", "fluent", "->", "type", "==", "'sms'", ")", "?", "'antares/notifications::admin.index.form_sms'", ":", "'antares/notifications::admin.index.form'", ";", "$", "this", "->", "grid", "->", "layout", "(", "$", "layout", ",", "$", "this", "->", "layoutAttributes", ")", ";", "return", "$", "this", ";", "}" ]
on create scenario @param String $type @return \Antares\Notifications\Http\Form\Form
[ "on", "create", "scenario" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Form/Form.php#L213-L222
23,313
antaresproject/notifications
src/Http/Form/Form.php
Form.getNotificationContentData
protected function getNotificationContentData($fluent, $langId, $key = 'title') { foreach ($fluent->contents as $content) { if ($langId !== $content['lang_id']) { continue; } return array_get($content, $key); } return ''; }
php
protected function getNotificationContentData($fluent, $langId, $key = 'title') { foreach ($fluent->contents as $content) { if ($langId !== $content['lang_id']) { continue; } return array_get($content, $key); } return ''; }
[ "protected", "function", "getNotificationContentData", "(", "$", "fluent", ",", "$", "langId", ",", "$", "key", "=", "'title'", ")", "{", "foreach", "(", "$", "fluent", "->", "contents", "as", "$", "content", ")", "{", "if", "(", "$", "langId", "!==", "$", "content", "[", "'lang_id'", "]", ")", "{", "continue", ";", "}", "return", "array_get", "(", "$", "content", ",", "$", "key", ")", ";", "}", "return", "''", ";", "}" ]
Gets notification data @param Fluent $fluent @param mixed $langId @param String $key @return String
[ "Gets", "notification", "data" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Form/Form.php#L232-L241
23,314
RhubarbPHP/Module.RestApi
src/Modelling/ApiModel.php
ApiModel.delete
public function delete() { if ($this->isNewRecord()) { throw new DeleteModelException("New models can't be deleted."); } $this->beforeDelete(); $this->raiseEvent("BeforeDelete"); $this->Deleted = true; $this->save(); $this->afterDelete(); $this->raiseEvent("AfterDelete"); }
php
public function delete() { if ($this->isNewRecord()) { throw new DeleteModelException("New models can't be deleted."); } $this->beforeDelete(); $this->raiseEvent("BeforeDelete"); $this->Deleted = true; $this->save(); $this->afterDelete(); $this->raiseEvent("AfterDelete"); }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "$", "this", "->", "isNewRecord", "(", ")", ")", "{", "throw", "new", "DeleteModelException", "(", "\"New models can't be deleted.\"", ")", ";", "}", "$", "this", "->", "beforeDelete", "(", ")", ";", "$", "this", "->", "raiseEvent", "(", "\"BeforeDelete\"", ")", ";", "$", "this", "->", "Deleted", "=", "true", ";", "$", "this", "->", "save", "(", ")", ";", "$", "this", "->", "afterDelete", "(", ")", ";", "$", "this", "->", "raiseEvent", "(", "\"AfterDelete\"", ")", ";", "}" ]
Replaces the standard delete by flagging the entry deleted instead.
[ "Replaces", "the", "standard", "delete", "by", "flagging", "the", "entry", "deleted", "instead", "." ]
825d2b920caed13811971c5eb2784a94417787bd
https://github.com/RhubarbPHP/Module.RestApi/blob/825d2b920caed13811971c5eb2784a94417787bd/src/Modelling/ApiModel.php#L55-L69
23,315
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package._init
protected function _init($definition=null) { if (!is_null($definition)) { $this->_packageXml = simplexml_load_string($definition); } else { $packageXmlStub = <<<END <?xml version="1.0"?> <package> <name /> <version /> <stability /> <license /> <channel /> <extends /> <summary /> <description /> <notes /> <authors /> <date /> <time /> <contents /> <compatible /> <dependencies /> </package> END; $this->_packageXml = simplexml_load_string($packageXmlStub); } return $this; }
php
protected function _init($definition=null) { if (!is_null($definition)) { $this->_packageXml = simplexml_load_string($definition); } else { $packageXmlStub = <<<END <?xml version="1.0"?> <package> <name /> <version /> <stability /> <license /> <channel /> <extends /> <summary /> <description /> <notes /> <authors /> <date /> <time /> <contents /> <compatible /> <dependencies /> </package> END; $this->_packageXml = simplexml_load_string($packageXmlStub); } return $this; }
[ "protected", "function", "_init", "(", "$", "definition", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "definition", ")", ")", "{", "$", "this", "->", "_packageXml", "=", "simplexml_load_string", "(", "$", "definition", ")", ";", "}", "else", "{", "$", "packageXmlStub", "=", " <<<END\n<?xml version=\"1.0\"?>\n<package>\n <name />\n <version />\n <stability />\n <license />\n <channel />\n <extends />\n <summary />\n <description />\n <notes />\n <authors />\n <date />\n <time />\n <contents />\n <compatible />\n <dependencies />\n</package>\nEND", ";", "$", "this", "->", "_packageXml", "=", "simplexml_load_string", "(", "$", "packageXmlStub", ")", ";", "}", "return", "$", "this", ";", "}" ]
Initializes an empty package object @param null|string $definition optional package definition xml @return Mage_Connect_Package
[ "Initializes", "an", "empty", "package", "object" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L165-L194
23,316
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package._loadFile
protected function _loadFile($filename='') { if (is_null($this->_reader)) { $this->_reader = new Mage_Connect_Package_Reader($filename); } $content = $this->_reader->load(); $this->_packageXml = simplexml_load_string($content); return $this; }
php
protected function _loadFile($filename='') { if (is_null($this->_reader)) { $this->_reader = new Mage_Connect_Package_Reader($filename); } $content = $this->_reader->load(); $this->_packageXml = simplexml_load_string($content); return $this; }
[ "protected", "function", "_loadFile", "(", "$", "filename", "=", "''", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "_reader", ")", ")", "{", "$", "this", "->", "_reader", "=", "new", "Mage_Connect_Package_Reader", "(", "$", "filename", ")", ";", "}", "$", "content", "=", "$", "this", "->", "_reader", "->", "load", "(", ")", ";", "$", "this", "->", "_packageXml", "=", "simplexml_load_string", "(", "$", "content", ")", ";", "return", "$", "this", ";", "}" ]
Loads a package from specified file @param string $filename @return Mage_Connect_Package
[ "Loads", "a", "package", "from", "specified", "file" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L202-L210
23,317
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.save
public function save($path) { $this->validate(); $path = rtrim($path, "\\/") . DS; $this->_savePackage($path); return $this; }
php
public function save($path) { $this->validate(); $path = rtrim($path, "\\/") . DS; $this->_savePackage($path); return $this; }
[ "public", "function", "save", "(", "$", "path", ")", "{", "$", "this", "->", "validate", "(", ")", ";", "$", "path", "=", "rtrim", "(", "$", "path", ",", "\"\\\\/\"", ")", ".", "DS", ";", "$", "this", "->", "_savePackage", "(", "$", "path", ")", ";", "return", "$", "this", ";", "}" ]
Creates a package and saves it @param string $path @return Mage_Connect_Package
[ "Creates", "a", "package", "and", "saves", "it" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L218-L224
23,318
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package._savePackage
protected function _savePackage($path) { $fileName = $this->getReleaseFilename(); if (is_null($this->_writer)) { $this->_writer = new Mage_Connect_Package_Writer($this->getContents(), $path.$fileName); } $this->_writer ->composePackage() ->addPackageXml($this->getPackageXml()) ->archivePackage(); return $this; }
php
protected function _savePackage($path) { $fileName = $this->getReleaseFilename(); if (is_null($this->_writer)) { $this->_writer = new Mage_Connect_Package_Writer($this->getContents(), $path.$fileName); } $this->_writer ->composePackage() ->addPackageXml($this->getPackageXml()) ->archivePackage(); return $this; }
[ "protected", "function", "_savePackage", "(", "$", "path", ")", "{", "$", "fileName", "=", "$", "this", "->", "getReleaseFilename", "(", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "_writer", ")", ")", "{", "$", "this", "->", "_writer", "=", "new", "Mage_Connect_Package_Writer", "(", "$", "this", "->", "getContents", "(", ")", ",", "$", "path", ".", "$", "fileName", ")", ";", "}", "$", "this", "->", "_writer", "->", "composePackage", "(", ")", "->", "addPackageXml", "(", "$", "this", "->", "getPackageXml", "(", ")", ")", "->", "archivePackage", "(", ")", ";", "return", "$", "this", ";", "}" ]
Creates a package archive and saves it to specified path @param string $path @return Mage_Connect_Package
[ "Creates", "a", "package", "archive", "and", "saves", "it", "to", "specified", "path" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L232-L243
23,319
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package._getNode
protected function _getNode($tag, $parent, $name='') { $found = false; foreach ($parent->xpath($tag) as $_node) { if ($_node['name'] == $name) { $node = $_node; $found = true; break; } } if (!$found) { $node = $parent->addChild($tag); if ($name) { $node->addAttribute('name', $name); } } return $node; }
php
protected function _getNode($tag, $parent, $name='') { $found = false; foreach ($parent->xpath($tag) as $_node) { if ($_node['name'] == $name) { $node = $_node; $found = true; break; } } if (!$found) { $node = $parent->addChild($tag); if ($name) { $node->addAttribute('name', $name); } } return $node; }
[ "protected", "function", "_getNode", "(", "$", "tag", ",", "$", "parent", ",", "$", "name", "=", "''", ")", "{", "$", "found", "=", "false", ";", "foreach", "(", "$", "parent", "->", "xpath", "(", "$", "tag", ")", "as", "$", "_node", ")", "{", "if", "(", "$", "_node", "[", "'name'", "]", "==", "$", "name", ")", "{", "$", "node", "=", "$", "_node", ";", "$", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "$", "found", ")", "{", "$", "node", "=", "$", "parent", "->", "addChild", "(", "$", "tag", ")", ";", "if", "(", "$", "name", ")", "{", "$", "node", "->", "addAttribute", "(", "'name'", ",", "$", "name", ")", ";", "}", "}", "return", "$", "node", ";", "}" ]
Retrieve SimpleXMLElement node by xpath. If it absent, create new. For comparing nodes method uses attribute "name" in each nodes. If attribute "name" is same for both nodes, nodes are same. @param string $tag @param SimpleXMLElement $parent @param string $name @return SimpleXMLElement
[ "Retrieve", "SimpleXMLElement", "node", "by", "xpath", ".", "If", "it", "absent", "create", "new", ".", "For", "comparing", "nodes", "method", "uses", "attribute", "name", "in", "each", "nodes", ".", "If", "attribute", "name", "is", "same", "for", "both", "nodes", "nodes", "are", "same", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L443-L460
23,320
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.setDependencyPhpVersion
public function setDependencyPhpVersion($minVersion, $maxVersion) { $parent = $this->_packageXml->dependencies; $parent = $this->_getNode('required', $parent); $parent = $this->_getNode('php', $parent); $parent->addChild('min', $minVersion); $parent->addChild('max', $maxVersion); return $this; }
php
public function setDependencyPhpVersion($minVersion, $maxVersion) { $parent = $this->_packageXml->dependencies; $parent = $this->_getNode('required', $parent); $parent = $this->_getNode('php', $parent); $parent->addChild('min', $minVersion); $parent->addChild('max', $maxVersion); return $this; }
[ "public", "function", "setDependencyPhpVersion", "(", "$", "minVersion", ",", "$", "maxVersion", ")", "{", "$", "parent", "=", "$", "this", "->", "_packageXml", "->", "dependencies", ";", "$", "parent", "=", "$", "this", "->", "_getNode", "(", "'required'", ",", "$", "parent", ")", ";", "$", "parent", "=", "$", "this", "->", "_getNode", "(", "'php'", ",", "$", "parent", ")", ";", "$", "parent", "->", "addChild", "(", "'min'", ",", "$", "minVersion", ")", ";", "$", "parent", "->", "addChild", "(", "'max'", ",", "$", "maxVersion", ")", ";", "return", "$", "this", ";", "}" ]
Set dependency from php version. @param string $minVersion @param string $maxVersion @return Mage_Connect_Package
[ "Set", "dependency", "from", "php", "version", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L557-L565
23,321
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.checkPhpVersion
public function checkPhpVersion() { $min = $this->getDependencyPhpVersionMin(); $max = $this->getDependencyPhpVersionMax(); $minOk = $min? version_compare(PHP_VERSION, $min, ">=") : true; $maxOk = $max? version_compare(PHP_VERSION, $max, "<=") : true; if(!$minOk || !$maxOk) { $err = "requires PHP version "; if($min && $max) { $err .= " >= $min and <= $max "; } elseif($min) { $err .= " >= $min "; } elseif($max) { $err .= " <= $max "; } $err .= " current is: ".PHP_VERSION; return $err; } return true; }
php
public function checkPhpVersion() { $min = $this->getDependencyPhpVersionMin(); $max = $this->getDependencyPhpVersionMax(); $minOk = $min? version_compare(PHP_VERSION, $min, ">=") : true; $maxOk = $max? version_compare(PHP_VERSION, $max, "<=") : true; if(!$minOk || !$maxOk) { $err = "requires PHP version "; if($min && $max) { $err .= " >= $min and <= $max "; } elseif($min) { $err .= " >= $min "; } elseif($max) { $err .= " <= $max "; } $err .= " current is: ".PHP_VERSION; return $err; } return true; }
[ "public", "function", "checkPhpVersion", "(", ")", "{", "$", "min", "=", "$", "this", "->", "getDependencyPhpVersionMin", "(", ")", ";", "$", "max", "=", "$", "this", "->", "getDependencyPhpVersionMax", "(", ")", ";", "$", "minOk", "=", "$", "min", "?", "version_compare", "(", "PHP_VERSION", ",", "$", "min", ",", "\">=\"", ")", ":", "true", ";", "$", "maxOk", "=", "$", "max", "?", "version_compare", "(", "PHP_VERSION", ",", "$", "max", ",", "\"<=\"", ")", ":", "true", ";", "if", "(", "!", "$", "minOk", "||", "!", "$", "maxOk", ")", "{", "$", "err", "=", "\"requires PHP version \"", ";", "if", "(", "$", "min", "&&", "$", "max", ")", "{", "$", "err", ".=", "\" >= $min and <= $max \"", ";", "}", "elseif", "(", "$", "min", ")", "{", "$", "err", ".=", "\" >= $min \"", ";", "}", "elseif", "(", "$", "max", ")", "{", "$", "err", ".=", "\" <= $max \"", ";", "}", "$", "err", ".=", "\" current is: \"", ".", "PHP_VERSION", ";", "return", "$", "err", ";", "}", "return", "true", ";", "}" ]
Check PHP version restriction @param $phpVersion PHP_VERSION by default @return true | string
[ "Check", "PHP", "version", "restriction" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L573-L594
23,322
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.checkPhpDependencies
public function checkPhpDependencies() { $errors = array(); foreach($this->getDependencyPhpExtensions() as $dep) { if(!extension_loaded($dep['name'])) { $errors[] = $dep; } } if(count($errors)) { return $errors; } return true; }
php
public function checkPhpDependencies() { $errors = array(); foreach($this->getDependencyPhpExtensions() as $dep) { if(!extension_loaded($dep['name'])) { $errors[] = $dep; } } if(count($errors)) { return $errors; } return true; }
[ "public", "function", "checkPhpDependencies", "(", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getDependencyPhpExtensions", "(", ")", "as", "$", "dep", ")", "{", "if", "(", "!", "extension_loaded", "(", "$", "dep", "[", "'name'", "]", ")", ")", "{", "$", "errors", "[", "]", "=", "$", "dep", ";", "}", "}", "if", "(", "count", "(", "$", "errors", ")", ")", "{", "return", "$", "errors", ";", "}", "return", "true", ";", "}" ]
Check PHP extensions availability @throws Exceptiom on failure @return true | array
[ "Check", "PHP", "extensions", "availability" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L602-L615
23,323
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.setDependencyPhpExtensions
public function setDependencyPhpExtensions($extensions) { foreach($extensions as $_extension) { $this->addDependencyExtension( $_extension['name'], $_extension['min_version'], $_extension['max_version'] ); } return $this; }
php
public function setDependencyPhpExtensions($extensions) { foreach($extensions as $_extension) { $this->addDependencyExtension( $_extension['name'], $_extension['min_version'], $_extension['max_version'] ); } return $this; }
[ "public", "function", "setDependencyPhpExtensions", "(", "$", "extensions", ")", "{", "foreach", "(", "$", "extensions", "as", "$", "_extension", ")", "{", "$", "this", "->", "addDependencyExtension", "(", "$", "_extension", "[", "'name'", "]", ",", "$", "_extension", "[", "'min_version'", "]", ",", "$", "_extension", "[", "'max_version'", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set dependency from php extensions. $extension has next view: array('curl', 'mysql') @param array|string $extensions @return Mage_Connect_Package
[ "Set", "dependency", "from", "php", "extensions", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L627-L637
23,324
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.setDependencyPackages
public function setDependencyPackages($packages, $clear = false) { if($clear) { unset($this->_packageXml->dependencies->required->package); } foreach($packages as $_package) { $filesArrayCondition = isset($_package['files']) && is_array($_package['files']); $filesArray = $filesArrayCondition ? $_package['files'] : array(); $this->addDependencyPackage( $_package['name'], $_package['channel'], $_package['min_version'], $_package['max_version'], $filesArray ); } return $this; }
php
public function setDependencyPackages($packages, $clear = false) { if($clear) { unset($this->_packageXml->dependencies->required->package); } foreach($packages as $_package) { $filesArrayCondition = isset($_package['files']) && is_array($_package['files']); $filesArray = $filesArrayCondition ? $_package['files'] : array(); $this->addDependencyPackage( $_package['name'], $_package['channel'], $_package['min_version'], $_package['max_version'], $filesArray ); } return $this; }
[ "public", "function", "setDependencyPackages", "(", "$", "packages", ",", "$", "clear", "=", "false", ")", "{", "if", "(", "$", "clear", ")", "{", "unset", "(", "$", "this", "->", "_packageXml", "->", "dependencies", "->", "required", "->", "package", ")", ";", "}", "foreach", "(", "$", "packages", "as", "$", "_package", ")", "{", "$", "filesArrayCondition", "=", "isset", "(", "$", "_package", "[", "'files'", "]", ")", "&&", "is_array", "(", "$", "_package", "[", "'files'", "]", ")", ";", "$", "filesArray", "=", "$", "filesArrayCondition", "?", "$", "_package", "[", "'files'", "]", ":", "array", "(", ")", ";", "$", "this", "->", "addDependencyPackage", "(", "$", "_package", "[", "'name'", "]", ",", "$", "_package", "[", "'channel'", "]", ",", "$", "_package", "[", "'min_version'", "]", ",", "$", "_package", "[", "'max_version'", "]", ",", "$", "filesArray", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set dependency from another packages. $packages should contain: array( array('name'=>'test1', 'channel'=>'test1', 'min_version'=>'0.0.1', 'max_version'=>'0.1.0'), array('name'=>'test2', 'channel'=>'test2', 'min_version'=>'0.0.1', 'max_version'=>'0.1.0'), ) @param array $packages @param bool $clear @return Mage_Connect_Package
[ "Set", "dependency", "from", "another", "packages", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L652-L672
23,325
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.addDependencyPackage
public function addDependencyPackage($name, $channel, $minVersion, $maxVersion, $files = array()) { $parent = $this->_packageXml->dependencies; $parent = $this->_getNode('required', $parent); $parent = $parent->addChild('package'); $parent->addChild('name', $name); $parent->addChild('channel', $channel); $parent->addChild('min', $minVersion); $parent->addChild('max', $maxVersion); if(count($files)) { $parent = $parent->addChild('files'); foreach($files as $row) { if(!empty($row['target']) && !empty($row['path'])) { $node = $parent->addChild("file"); $node["target"] = $row['target']; $node["path"] = $row['path']; } } } return $this; }
php
public function addDependencyPackage($name, $channel, $minVersion, $maxVersion, $files = array()) { $parent = $this->_packageXml->dependencies; $parent = $this->_getNode('required', $parent); $parent = $parent->addChild('package'); $parent->addChild('name', $name); $parent->addChild('channel', $channel); $parent->addChild('min', $minVersion); $parent->addChild('max', $maxVersion); if(count($files)) { $parent = $parent->addChild('files'); foreach($files as $row) { if(!empty($row['target']) && !empty($row['path'])) { $node = $parent->addChild("file"); $node["target"] = $row['target']; $node["path"] = $row['path']; } } } return $this; }
[ "public", "function", "addDependencyPackage", "(", "$", "name", ",", "$", "channel", ",", "$", "minVersion", ",", "$", "maxVersion", ",", "$", "files", "=", "array", "(", ")", ")", "{", "$", "parent", "=", "$", "this", "->", "_packageXml", "->", "dependencies", ";", "$", "parent", "=", "$", "this", "->", "_getNode", "(", "'required'", ",", "$", "parent", ")", ";", "$", "parent", "=", "$", "parent", "->", "addChild", "(", "'package'", ")", ";", "$", "parent", "->", "addChild", "(", "'name'", ",", "$", "name", ")", ";", "$", "parent", "->", "addChild", "(", "'channel'", ",", "$", "channel", ")", ";", "$", "parent", "->", "addChild", "(", "'min'", ",", "$", "minVersion", ")", ";", "$", "parent", "->", "addChild", "(", "'max'", ",", "$", "maxVersion", ")", ";", "if", "(", "count", "(", "$", "files", ")", ")", "{", "$", "parent", "=", "$", "parent", "->", "addChild", "(", "'files'", ")", ";", "foreach", "(", "$", "files", "as", "$", "row", ")", "{", "if", "(", "!", "empty", "(", "$", "row", "[", "'target'", "]", ")", "&&", "!", "empty", "(", "$", "row", "[", "'path'", "]", ")", ")", "{", "$", "node", "=", "$", "parent", "->", "addChild", "(", "\"file\"", ")", ";", "$", "node", "[", "\"target\"", "]", "=", "$", "row", "[", "'target'", "]", ";", "$", "node", "[", "\"path\"", "]", "=", "$", "row", "[", "'path'", "]", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Add package to dependency packages. @param string $package @param string $channel @param string $minVersion @param string $maxVersion @return Mage_Connect_Package
[ "Add", "package", "to", "dependency", "packages", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L685-L706
23,326
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.addDependencyExtension
public function addDependencyExtension($name, $minVersion, $maxVersion) { $parent = $this->_packageXml->dependencies; $parent = $this->_getNode('required', $parent); $parent = $parent->addChild('extension'); $parent->addChild('name', $name); $parent->addChild('min', $minVersion); $parent->addChild('max', $maxVersion); return $this; }
php
public function addDependencyExtension($name, $minVersion, $maxVersion) { $parent = $this->_packageXml->dependencies; $parent = $this->_getNode('required', $parent); $parent = $parent->addChild('extension'); $parent->addChild('name', $name); $parent->addChild('min', $minVersion); $parent->addChild('max', $maxVersion); return $this; }
[ "public", "function", "addDependencyExtension", "(", "$", "name", ",", "$", "minVersion", ",", "$", "maxVersion", ")", "{", "$", "parent", "=", "$", "this", "->", "_packageXml", "->", "dependencies", ";", "$", "parent", "=", "$", "this", "->", "_getNode", "(", "'required'", ",", "$", "parent", ")", ";", "$", "parent", "=", "$", "parent", "->", "addChild", "(", "'extension'", ")", ";", "$", "parent", "->", "addChild", "(", "'name'", ",", "$", "name", ")", ";", "$", "parent", "->", "addChild", "(", "'min'", ",", "$", "minVersion", ")", ";", "$", "parent", "->", "addChild", "(", "'max'", ",", "$", "maxVersion", ")", ";", "return", "$", "this", ";", "}" ]
Add package to dependency extension. @param string $package @param string $minVersion @param string $maxVersion @return Mage_Connect_Package
[ "Add", "package", "to", "dependency", "extension", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L718-L727
23,327
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.getAuthors
public function getAuthors() { if (is_array($this->_authors)) return $this->_authors; $this->_authors = array(); if(!isset($this->_packageXml->authors->author)) { return array(); } foreach ($this->_packageXml->authors->author as $_author) { $this->_authors[] = array( 'name' => (string)$_author->name, 'user' => (string)$_author->user, 'email'=> (string)$_author->email ); } return $this->_authors; }
php
public function getAuthors() { if (is_array($this->_authors)) return $this->_authors; $this->_authors = array(); if(!isset($this->_packageXml->authors->author)) { return array(); } foreach ($this->_packageXml->authors->author as $_author) { $this->_authors[] = array( 'name' => (string)$_author->name, 'user' => (string)$_author->user, 'email'=> (string)$_author->email ); } return $this->_authors; }
[ "public", "function", "getAuthors", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_authors", ")", ")", "return", "$", "this", "->", "_authors", ";", "$", "this", "->", "_authors", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_packageXml", "->", "authors", "->", "author", ")", ")", "{", "return", "array", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "_packageXml", "->", "authors", "->", "author", "as", "$", "_author", ")", "{", "$", "this", "->", "_authors", "[", "]", "=", "array", "(", "'name'", "=>", "(", "string", ")", "$", "_author", "->", "name", ",", "'user'", "=>", "(", "string", ")", "$", "_author", "->", "user", ",", "'email'", "=>", "(", "string", ")", "$", "_author", "->", "email", ")", ";", "}", "return", "$", "this", "->", "_authors", ";", "}" ]
Get list of authors in associative array. @return array
[ "Get", "list", "of", "authors", "in", "associative", "array", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L776-L791
23,328
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.getContents
public function getContents() { if (is_array($this->_contents)) return $this->_contents; $this->_contents = array(); if(!isset($this->_packageXml->contents->target)) { return $this->_contents; } foreach($this->_packageXml->contents->target as $target) { $targetUri = $this->getTarget()->getTargetUri($target['name']); $this->_getList($target, $targetUri); } return $this->_contents; }
php
public function getContents() { if (is_array($this->_contents)) return $this->_contents; $this->_contents = array(); if(!isset($this->_packageXml->contents->target)) { return $this->_contents; } foreach($this->_packageXml->contents->target as $target) { $targetUri = $this->getTarget()->getTargetUri($target['name']); $this->_getList($target, $targetUri); } return $this->_contents; }
[ "public", "function", "getContents", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_contents", ")", ")", "return", "$", "this", "->", "_contents", ";", "$", "this", "->", "_contents", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_packageXml", "->", "contents", "->", "target", ")", ")", "{", "return", "$", "this", "->", "_contents", ";", "}", "foreach", "(", "$", "this", "->", "_packageXml", "->", "contents", "->", "target", "as", "$", "target", ")", "{", "$", "targetUri", "=", "$", "this", "->", "getTarget", "(", ")", "->", "getTargetUri", "(", "$", "target", "[", "'name'", "]", ")", ";", "$", "this", "->", "_getList", "(", "$", "target", ",", "$", "targetUri", ")", ";", "}", "return", "$", "this", "->", "_contents", ";", "}" ]
Create list of all files from package.xml @return array
[ "Create", "list", "of", "all", "files", "from", "package", ".", "xml" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L868-L880
23,329
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.getHashContents
public function getHashContents() { if (is_array($this->_hashContents)) return $this->_hashContents; $this->_hashContents = array(); if(!isset($this->_packageXml->contents->target)) { return $this->_hashContents; } foreach($this->_packageXml->contents->target as $target) { $targetUri = $this->getTarget()->getTargetUri($target['name']); $this->_getHashList($target, $targetUri); } return $this->_hashContents; }
php
public function getHashContents() { if (is_array($this->_hashContents)) return $this->_hashContents; $this->_hashContents = array(); if(!isset($this->_packageXml->contents->target)) { return $this->_hashContents; } foreach($this->_packageXml->contents->target as $target) { $targetUri = $this->getTarget()->getTargetUri($target['name']); $this->_getHashList($target, $targetUri); } return $this->_hashContents; }
[ "public", "function", "getHashContents", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_hashContents", ")", ")", "return", "$", "this", "->", "_hashContents", ";", "$", "this", "->", "_hashContents", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_packageXml", "->", "contents", "->", "target", ")", ")", "{", "return", "$", "this", "->", "_hashContents", ";", "}", "foreach", "(", "$", "this", "->", "_packageXml", "->", "contents", "->", "target", "as", "$", "target", ")", "{", "$", "targetUri", "=", "$", "this", "->", "getTarget", "(", ")", "->", "getTargetUri", "(", "$", "target", "[", "'name'", "]", ")", ";", "$", "this", "->", "_getHashList", "(", "$", "target", ",", "$", "targetUri", ")", ";", "}", "return", "$", "this", "->", "_hashContents", ";", "}" ]
Create list of all files from package.xml with hash @return array
[ "Create", "list", "of", "all", "files", "from", "package", ".", "xml", "with", "hash" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L904-L916
23,330
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.getCompatible
public function getCompatible() { if (is_array($this->_compatible)) return $this->_compatible; $this->_compatible = array(); if(!isset($this->_packageXml->compatible->package)) { return array(); } foreach ($this->_packageXml->compatible->package as $_package) { $this->_compatible[] = array( 'name' => (string)$_package->name, 'channel' => (string)$_package->channel, 'min' => (string)$_package->min, 'max' => (string)$_package->max ); } return $this->_compatible; }
php
public function getCompatible() { if (is_array($this->_compatible)) return $this->_compatible; $this->_compatible = array(); if(!isset($this->_packageXml->compatible->package)) { return array(); } foreach ($this->_packageXml->compatible->package as $_package) { $this->_compatible[] = array( 'name' => (string)$_package->name, 'channel' => (string)$_package->channel, 'min' => (string)$_package->min, 'max' => (string)$_package->max ); } return $this->_compatible; }
[ "public", "function", "getCompatible", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_compatible", ")", ")", "return", "$", "this", "->", "_compatible", ";", "$", "this", "->", "_compatible", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_packageXml", "->", "compatible", "->", "package", ")", ")", "{", "return", "array", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "_packageXml", "->", "compatible", "->", "package", "as", "$", "_package", ")", "{", "$", "this", "->", "_compatible", "[", "]", "=", "array", "(", "'name'", "=>", "(", "string", ")", "$", "_package", "->", "name", ",", "'channel'", "=>", "(", "string", ")", "$", "_package", "->", "channel", ",", "'min'", "=>", "(", "string", ")", "$", "_package", "->", "min", ",", "'max'", "=>", "(", "string", ")", "$", "_package", "->", "max", ")", ";", "}", "return", "$", "this", "->", "_compatible", ";", "}" ]
Get compatible packages. @return array
[ "Get", "compatible", "packages", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L944-L960
23,331
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.getDependencyPhpExtensions
public function getDependencyPhpExtensions() { if (is_array($this->_dependencyPhpExtensions)) return $this->_dependencyPhpExtensions; $this->_dependencyPhpExtensions = array(); if (!isset($this->_packageXml->dependencies->required->extension)) { return $this->_dependencyPhpExtensions; } foreach($this->_packageXml->dependencies->required->extension as $_package) { $this->_dependencyPhpExtensions[] = array( 'name' => (string)$_package->name, 'min' => (string)$_package->min, 'max' => (string)$_package->max, ); } return $this->_dependencyPhpExtensions; }
php
public function getDependencyPhpExtensions() { if (is_array($this->_dependencyPhpExtensions)) return $this->_dependencyPhpExtensions; $this->_dependencyPhpExtensions = array(); if (!isset($this->_packageXml->dependencies->required->extension)) { return $this->_dependencyPhpExtensions; } foreach($this->_packageXml->dependencies->required->extension as $_package) { $this->_dependencyPhpExtensions[] = array( 'name' => (string)$_package->name, 'min' => (string)$_package->min, 'max' => (string)$_package->max, ); } return $this->_dependencyPhpExtensions; }
[ "public", "function", "getDependencyPhpExtensions", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_dependencyPhpExtensions", ")", ")", "return", "$", "this", "->", "_dependencyPhpExtensions", ";", "$", "this", "->", "_dependencyPhpExtensions", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_packageXml", "->", "dependencies", "->", "required", "->", "extension", ")", ")", "{", "return", "$", "this", "->", "_dependencyPhpExtensions", ";", "}", "foreach", "(", "$", "this", "->", "_packageXml", "->", "dependencies", "->", "required", "->", "extension", "as", "$", "_package", ")", "{", "$", "this", "->", "_dependencyPhpExtensions", "[", "]", "=", "array", "(", "'name'", "=>", "(", "string", ")", "$", "_package", "->", "name", ",", "'min'", "=>", "(", "string", ")", "$", "_package", "->", "min", ",", "'max'", "=>", "(", "string", ")", "$", "_package", "->", "max", ",", ")", ";", "}", "return", "$", "this", "->", "_dependencyPhpExtensions", ";", "}" ]
Get list of php extensions. @return array
[ "Get", "list", "of", "php", "extensions", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L993-L1008
23,332
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.getDependencyPackages
public function getDependencyPackages() { $this->_dependencyPackages = array(); if (!isset($this->_packageXml->dependencies->required->package)) { return $this->_dependencyPackages; } foreach($this->_packageXml->dependencies->required->package as $_package) { $add = array( 'name' => (string)$_package->name, 'channel' => (string)$_package->channel, 'min' => (string)$_package->min, 'max' => (string)$_package->max, ); if(isset($_package->files)) { $add['files'] = array(); foreach($_package->files as $node) { if(isset($node->file)) { $add['files'][] = array('target' => (string) $node->file['target'], 'path'=> (string) $node->file['path']); } } } $this->_dependencyPackages[] = $add; } return $this->_dependencyPackages; }
php
public function getDependencyPackages() { $this->_dependencyPackages = array(); if (!isset($this->_packageXml->dependencies->required->package)) { return $this->_dependencyPackages; } foreach($this->_packageXml->dependencies->required->package as $_package) { $add = array( 'name' => (string)$_package->name, 'channel' => (string)$_package->channel, 'min' => (string)$_package->min, 'max' => (string)$_package->max, ); if(isset($_package->files)) { $add['files'] = array(); foreach($_package->files as $node) { if(isset($node->file)) { $add['files'][] = array('target' => (string) $node->file['target'], 'path'=> (string) $node->file['path']); } } } $this->_dependencyPackages[] = $add; } return $this->_dependencyPackages; }
[ "public", "function", "getDependencyPackages", "(", ")", "{", "$", "this", "->", "_dependencyPackages", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_packageXml", "->", "dependencies", "->", "required", "->", "package", ")", ")", "{", "return", "$", "this", "->", "_dependencyPackages", ";", "}", "foreach", "(", "$", "this", "->", "_packageXml", "->", "dependencies", "->", "required", "->", "package", "as", "$", "_package", ")", "{", "$", "add", "=", "array", "(", "'name'", "=>", "(", "string", ")", "$", "_package", "->", "name", ",", "'channel'", "=>", "(", "string", ")", "$", "_package", "->", "channel", ",", "'min'", "=>", "(", "string", ")", "$", "_package", "->", "min", ",", "'max'", "=>", "(", "string", ")", "$", "_package", "->", "max", ",", ")", ";", "if", "(", "isset", "(", "$", "_package", "->", "files", ")", ")", "{", "$", "add", "[", "'files'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "_package", "->", "files", "as", "$", "node", ")", "{", "if", "(", "isset", "(", "$", "node", "->", "file", ")", ")", "{", "$", "add", "[", "'files'", "]", "[", "]", "=", "array", "(", "'target'", "=>", "(", "string", ")", "$", "node", "->", "file", "[", "'target'", "]", ",", "'path'", "=>", "(", "string", ")", "$", "node", "->", "file", "[", "'path'", "]", ")", ";", "}", "}", "}", "$", "this", "->", "_dependencyPackages", "[", "]", "=", "$", "add", ";", "}", "return", "$", "this", "->", "_dependencyPackages", ";", "}" ]
Get list of dependency packages. @return array
[ "Get", "list", "of", "dependency", "packages", "." ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L1015-L1040
23,333
mridang/magazine
lib/magento/Package.php
Mage_Connect_Package.convertChannelFromV1x
public function convertChannelFromV1x($channel) { $channelMap = array( 'connect.magentocommerce.com/community' => 'community', 'connect.magentocommerce.com/core' => 'community' ); if (!empty($channel) && isset($channelMap[$channel])) { $channel = $channelMap[$channel]; } return $channel; }
php
public function convertChannelFromV1x($channel) { $channelMap = array( 'connect.magentocommerce.com/community' => 'community', 'connect.magentocommerce.com/core' => 'community' ); if (!empty($channel) && isset($channelMap[$channel])) { $channel = $channelMap[$channel]; } return $channel; }
[ "public", "function", "convertChannelFromV1x", "(", "$", "channel", ")", "{", "$", "channelMap", "=", "array", "(", "'connect.magentocommerce.com/community'", "=>", "'community'", ",", "'connect.magentocommerce.com/core'", "=>", "'community'", ")", ";", "if", "(", "!", "empty", "(", "$", "channel", ")", "&&", "isset", "(", "$", "channelMap", "[", "$", "channel", "]", ")", ")", "{", "$", "channel", "=", "$", "channelMap", "[", "$", "channel", "]", ";", "}", "return", "$", "channel", ";", "}" ]
Convert package channel in order for it to be compatible with current version of Magento Connect Manager @param string $channel @return string
[ "Convert", "package", "channel", "in", "order", "for", "it", "to", "be", "compatible", "with", "current", "version", "of", "Magento", "Connect", "Manager" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Package.php#L1488-L1498
23,334
protophp/session
src/SessionManager.php
SessionManager.getUniqueKey
private function getUniqueKey(): string { do { try { $isDuplicate = null; $key = random_bytes($this->getOpt(self::OPT_SESSION_KEY_LENGTH)); // Ask for duplicate key from storage $this->emit('duplicate-check', [$key, &$isDuplicate]); } catch (\Exception $e) { throw new SessionException($e->getMessage(), SessionException::ERR_RANDOM_BYTES); } } while (isset($this->SESSION[$key]) || $isDuplicate === true); return $key; }
php
private function getUniqueKey(): string { do { try { $isDuplicate = null; $key = random_bytes($this->getOpt(self::OPT_SESSION_KEY_LENGTH)); // Ask for duplicate key from storage $this->emit('duplicate-check', [$key, &$isDuplicate]); } catch (\Exception $e) { throw new SessionException($e->getMessage(), SessionException::ERR_RANDOM_BYTES); } } while (isset($this->SESSION[$key]) || $isDuplicate === true); return $key; }
[ "private", "function", "getUniqueKey", "(", ")", ":", "string", "{", "do", "{", "try", "{", "$", "isDuplicate", "=", "null", ";", "$", "key", "=", "random_bytes", "(", "$", "this", "->", "getOpt", "(", "self", "::", "OPT_SESSION_KEY_LENGTH", ")", ")", ";", "// Ask for duplicate key from storage", "$", "this", "->", "emit", "(", "'duplicate-check'", ",", "[", "$", "key", ",", "&", "$", "isDuplicate", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "SessionException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "SessionException", "::", "ERR_RANDOM_BYTES", ")", ";", "}", "}", "while", "(", "isset", "(", "$", "this", "->", "SESSION", "[", "$", "key", "]", ")", "||", "$", "isDuplicate", "===", "true", ")", ";", "return", "$", "key", ";", "}" ]
Generate unique key @return string @throws SessionException
[ "Generate", "unique", "key" ]
bd90c882628a556727b5bc02d63005a59afa4c3a
https://github.com/protophp/session/blob/bd90c882628a556727b5bc02d63005a59afa4c3a/src/SessionManager.php#L68-L84
23,335
traderinteractive/util-http-php
src/Util/Http.php
Http.parseHeaders
public static function parseHeaders(string $rawHeaders) : array { if (empty(trim($rawHeaders))) { throw new InvalidArgumentException('$rawHeaders cannot be whitespace'); } $headers = []; $rawHeaders = preg_replace("/\r\n[\t ]+/", ' ', trim($rawHeaders)); $fields = explode("\r\n", $rawHeaders); foreach ($fields as $field) { $match = null; if (preg_match('/([^:]+): (.+)/m', $field, $match)) { $key = $match[1]; // convert 'some-header' to 'Some-Header' $key = strtolower(trim($key)); $key = ucwords(preg_replace('/[\s-]/', ' ', $key)); $key = strtr($key, ' ', '-'); $value = trim($match[2]); if (!array_key_exists($key, $headers)) { $headers[$key] = $value; continue; } if (!is_array($headers[$key])) { $headers[$key] = [$headers[$key]]; } $headers[$key][] = $value; continue; } if (preg_match('#([A-Za-z]+) +([^ ]+) +HTTP/([\d.]+)#', $field, $match)) { $headers = self::addRequestDataToHeaders($match, $headers); continue; } if (preg_match('#HTTP/([\d.]+) +(\d{3}) +(.*)#', $field, $match)) { $headers = self::addResponseDataToHeaders($match, $headers); continue; } throw new Exception("Unsupported header format: {$field}"); } return $headers; }
php
public static function parseHeaders(string $rawHeaders) : array { if (empty(trim($rawHeaders))) { throw new InvalidArgumentException('$rawHeaders cannot be whitespace'); } $headers = []; $rawHeaders = preg_replace("/\r\n[\t ]+/", ' ', trim($rawHeaders)); $fields = explode("\r\n", $rawHeaders); foreach ($fields as $field) { $match = null; if (preg_match('/([^:]+): (.+)/m', $field, $match)) { $key = $match[1]; // convert 'some-header' to 'Some-Header' $key = strtolower(trim($key)); $key = ucwords(preg_replace('/[\s-]/', ' ', $key)); $key = strtr($key, ' ', '-'); $value = trim($match[2]); if (!array_key_exists($key, $headers)) { $headers[$key] = $value; continue; } if (!is_array($headers[$key])) { $headers[$key] = [$headers[$key]]; } $headers[$key][] = $value; continue; } if (preg_match('#([A-Za-z]+) +([^ ]+) +HTTP/([\d.]+)#', $field, $match)) { $headers = self::addRequestDataToHeaders($match, $headers); continue; } if (preg_match('#HTTP/([\d.]+) +(\d{3}) +(.*)#', $field, $match)) { $headers = self::addResponseDataToHeaders($match, $headers); continue; } throw new Exception("Unsupported header format: {$field}"); } return $headers; }
[ "public", "static", "function", "parseHeaders", "(", "string", "$", "rawHeaders", ")", ":", "array", "{", "if", "(", "empty", "(", "trim", "(", "$", "rawHeaders", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'$rawHeaders cannot be whitespace'", ")", ";", "}", "$", "headers", "=", "[", "]", ";", "$", "rawHeaders", "=", "preg_replace", "(", "\"/\\r\\n[\\t ]+/\"", ",", "' '", ",", "trim", "(", "$", "rawHeaders", ")", ")", ";", "$", "fields", "=", "explode", "(", "\"\\r\\n\"", ",", "$", "rawHeaders", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "match", "=", "null", ";", "if", "(", "preg_match", "(", "'/([^:]+): (.+)/m'", ",", "$", "field", ",", "$", "match", ")", ")", "{", "$", "key", "=", "$", "match", "[", "1", "]", ";", "// convert 'some-header' to 'Some-Header'", "$", "key", "=", "strtolower", "(", "trim", "(", "$", "key", ")", ")", ";", "$", "key", "=", "ucwords", "(", "preg_replace", "(", "'/[\\s-]/'", ",", "' '", ",", "$", "key", ")", ")", ";", "$", "key", "=", "strtr", "(", "$", "key", ",", "' '", ",", "'-'", ")", ";", "$", "value", "=", "trim", "(", "$", "match", "[", "2", "]", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "headers", ")", ")", "{", "$", "headers", "[", "$", "key", "]", "=", "$", "value", ";", "continue", ";", "}", "if", "(", "!", "is_array", "(", "$", "headers", "[", "$", "key", "]", ")", ")", "{", "$", "headers", "[", "$", "key", "]", "=", "[", "$", "headers", "[", "$", "key", "]", "]", ";", "}", "$", "headers", "[", "$", "key", "]", "[", "]", "=", "$", "value", ";", "continue", ";", "}", "if", "(", "preg_match", "(", "'#([A-Za-z]+) +([^ ]+) +HTTP/([\\d.]+)#'", ",", "$", "field", ",", "$", "match", ")", ")", "{", "$", "headers", "=", "self", "::", "addRequestDataToHeaders", "(", "$", "match", ",", "$", "headers", ")", ";", "continue", ";", "}", "if", "(", "preg_match", "(", "'#HTTP/([\\d.]+) +(\\d{3}) +(.*)#'", ",", "$", "field", ",", "$", "match", ")", ")", "{", "$", "headers", "=", "self", "::", "addResponseDataToHeaders", "(", "$", "match", ",", "$", "headers", ")", ";", "continue", ";", "}", "throw", "new", "Exception", "(", "\"Unsupported header format: {$field}\"", ")", ";", "}", "return", "$", "headers", ";", "}" ]
Parses HTTP headers into an associative array. Example: <code> $headers = "HTTP/1.1 200 OK\r\n". "content-type: text/html; charset=UTF-8\r\n". "Server: Funky/1.0\r\n". "Set-Cookie: foo=bar\r\n". "Set-Cookie: baz=quux\r\n". "Folds: are\r\n\treformatted\r\n"; print_r(\TraderInteractive\HttpUtil::parseHeaders($headers)); </code> The above example will output: <pre> Array ( [Response Code] => 200 [Response Status] => OK [Content-Type] => text/html; charset=UTF-8 [Server] => Funky/1.0 [Set-Cookie] => Array ( [0] => foo=bar [1] => baz=quux ) [Folds] => are reformatted ) </pre> @param string $rawHeaders string containing HTTP headers @return array the parsed headers @throws Exception Thrown if unable to parse the headers
[ "Parses", "HTTP", "headers", "into", "an", "associative", "array", "." ]
d3bba26fbd9ec5a3227c4580717019bf16a58c67
https://github.com/traderinteractive/util-http-php/blob/d3bba26fbd9ec5a3227c4580717019bf16a58c67/src/Util/Http.php#L49-L96
23,336
traderinteractive/util-http-php
src/Util/Http.php
Http.buildQueryString
public static function buildQueryString(array $parameters) : string { $queryStrings = []; foreach ($parameters as $parameterName => $parameterValue) { $parameterName = rawurlencode($parameterName); if (is_array($parameterValue)) { foreach ($parameterValue as $eachValue) { $eachValue = rawurlencode($eachValue); $queryStrings[] = "{$parameterName}={$eachValue}"; } } elseif ($parameterValue === false) { $queryStrings[] = "{$parameterName}=false"; } elseif ($parameterValue === true) { $queryStrings[] = "{$parameterName}=true"; } else { $parameterValue = rawurlencode($parameterValue); $queryStrings[] = "{$parameterName}={$parameterValue}"; } } return implode('&', $queryStrings); }
php
public static function buildQueryString(array $parameters) : string { $queryStrings = []; foreach ($parameters as $parameterName => $parameterValue) { $parameterName = rawurlencode($parameterName); if (is_array($parameterValue)) { foreach ($parameterValue as $eachValue) { $eachValue = rawurlencode($eachValue); $queryStrings[] = "{$parameterName}={$eachValue}"; } } elseif ($parameterValue === false) { $queryStrings[] = "{$parameterName}=false"; } elseif ($parameterValue === true) { $queryStrings[] = "{$parameterName}=true"; } else { $parameterValue = rawurlencode($parameterValue); $queryStrings[] = "{$parameterName}={$parameterValue}"; } } return implode('&', $queryStrings); }
[ "public", "static", "function", "buildQueryString", "(", "array", "$", "parameters", ")", ":", "string", "{", "$", "queryStrings", "=", "[", "]", ";", "foreach", "(", "$", "parameters", "as", "$", "parameterName", "=>", "$", "parameterValue", ")", "{", "$", "parameterName", "=", "rawurlencode", "(", "$", "parameterName", ")", ";", "if", "(", "is_array", "(", "$", "parameterValue", ")", ")", "{", "foreach", "(", "$", "parameterValue", "as", "$", "eachValue", ")", "{", "$", "eachValue", "=", "rawurlencode", "(", "$", "eachValue", ")", ";", "$", "queryStrings", "[", "]", "=", "\"{$parameterName}={$eachValue}\"", ";", "}", "}", "elseif", "(", "$", "parameterValue", "===", "false", ")", "{", "$", "queryStrings", "[", "]", "=", "\"{$parameterName}=false\"", ";", "}", "elseif", "(", "$", "parameterValue", "===", "true", ")", "{", "$", "queryStrings", "[", "]", "=", "\"{$parameterName}=true\"", ";", "}", "else", "{", "$", "parameterValue", "=", "rawurlencode", "(", "$", "parameterValue", ")", ";", "$", "queryStrings", "[", "]", "=", "\"{$parameterName}={$parameterValue}\"", ";", "}", "}", "return", "implode", "(", "'&'", ",", "$", "queryStrings", ")", ";", "}" ]
Generate URL-encoded query string Example: <code> $parameters = [ 'param1' => ['value', 'another value'], 'param2' => 'a value', 'param3' => false, ]; $queryString = \TraderInteractive\HttpUtil::buildQueryString($parameters); echo $queryString </code> Output: <pre> param1=value&param1=another+value&param2=a+value&param3=false </pre> @param array $parameters An associative array containing parameter key/value(s) @return string the built query string
[ "Generate", "URL", "-", "encoded", "query", "string" ]
d3bba26fbd9ec5a3227c4580717019bf16a58c67
https://github.com/traderinteractive/util-http-php/blob/d3bba26fbd9ec5a3227c4580717019bf16a58c67/src/Util/Http.php#L137-L159
23,337
mikelgoig/nova-spotify-auth-tool
src/SpotifyAuthToolServiceProvider.php
SpotifyAuthToolServiceProvider.routes
protected function routes() { if ($this->app->routesAreCached()) { return; } Route::middleware(['nova', Authorize::class]) ->prefix('nova-vendor/nova-spotify-auth-tool') ->group(__DIR__.'/../routes/web.php'); Route::middleware(['nova', Authorize::class]) ->prefix('nova-vendor/nova-spotify-auth-tool') ->group(__DIR__.'/../routes/api.php'); }
php
protected function routes() { if ($this->app->routesAreCached()) { return; } Route::middleware(['nova', Authorize::class]) ->prefix('nova-vendor/nova-spotify-auth-tool') ->group(__DIR__.'/../routes/web.php'); Route::middleware(['nova', Authorize::class]) ->prefix('nova-vendor/nova-spotify-auth-tool') ->group(__DIR__.'/../routes/api.php'); }
[ "protected", "function", "routes", "(", ")", "{", "if", "(", "$", "this", "->", "app", "->", "routesAreCached", "(", ")", ")", "{", "return", ";", "}", "Route", "::", "middleware", "(", "[", "'nova'", ",", "Authorize", "::", "class", "]", ")", "->", "prefix", "(", "'nova-vendor/nova-spotify-auth-tool'", ")", "->", "group", "(", "__DIR__", ".", "'/../routes/web.php'", ")", ";", "Route", "::", "middleware", "(", "[", "'nova'", ",", "Authorize", "::", "class", "]", ")", "->", "prefix", "(", "'nova-vendor/nova-spotify-auth-tool'", ")", "->", "group", "(", "__DIR__", ".", "'/../routes/api.php'", ")", ";", "}" ]
Register the tool's routes. @return void
[ "Register", "the", "tool", "s", "routes", "." ]
a5351c386206c45f77fe6ae833cdac51f2a030f4
https://github.com/mikelgoig/nova-spotify-auth-tool/blob/a5351c386206c45f77fe6ae833cdac51f2a030f4/src/SpotifyAuthToolServiceProvider.php#L42-L55
23,338
hametuha/wpametu
src/WPametu/UI/Admin/EditMetaBox.php
EditMetaBox.add_meta_boxes
public function add_meta_boxes($post_type, $post){ if( $this->is_valid_post_type($post_type) && $this->has_cap() ){ if( empty($this->name) || empty($this->label) ){ $message = sprintf($this->__('<code>%s</code> has invalid name or label.'), get_called_class()); add_action('admin_notices', function() use ($message) { printf('<div class="error"><p>%s</p></div>', $message); }); }else{ add_meta_box($this->name, $this->label, [$this, 'render'], $post_type, $this->context, $this->priority); } } }
php
public function add_meta_boxes($post_type, $post){ if( $this->is_valid_post_type($post_type) && $this->has_cap() ){ if( empty($this->name) || empty($this->label) ){ $message = sprintf($this->__('<code>%s</code> has invalid name or label.'), get_called_class()); add_action('admin_notices', function() use ($message) { printf('<div class="error"><p>%s</p></div>', $message); }); }else{ add_meta_box($this->name, $this->label, [$this, 'render'], $post_type, $this->context, $this->priority); } } }
[ "public", "function", "add_meta_boxes", "(", "$", "post_type", ",", "$", "post", ")", "{", "if", "(", "$", "this", "->", "is_valid_post_type", "(", "$", "post_type", ")", "&&", "$", "this", "->", "has_cap", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "name", ")", "||", "empty", "(", "$", "this", "->", "label", ")", ")", "{", "$", "message", "=", "sprintf", "(", "$", "this", "->", "__", "(", "'<code>%s</code> has invalid name or label.'", ")", ",", "get_called_class", "(", ")", ")", ";", "add_action", "(", "'admin_notices'", ",", "function", "(", ")", "use", "(", "$", "message", ")", "{", "printf", "(", "'<div class=\"error\"><p>%s</p></div>'", ",", "$", "message", ")", ";", "}", ")", ";", "}", "else", "{", "add_meta_box", "(", "$", "this", "->", "name", ",", "$", "this", "->", "label", ",", "[", "$", "this", ",", "'render'", "]", ",", "$", "post_type", ",", "$", "this", "->", "context", ",", "$", "this", "->", "priority", ")", ";", "}", "}", "}" ]
Register meta box @param string $post_type @param \WP_Post $post
[ "Register", "meta", "box" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Admin/EditMetaBox.php#L38-L49
23,339
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php
ezcBase.autoload
public static function autoload( $className ) { Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '(%s)', $className); ezcBase::setPackageDir(); // Check whether the classname is already in the cached autoloadArray. if ( array_key_exists( $className, ezcBase::$autoloadArray ) ) { // Is it registered as 'unloadable'? if ( ezcBase::$autoloadArray[$className] == false ) { return false; } ezcBase::loadFile( ezcBase::$autoloadArray[$className] ); return true; } // Check whether the classname is already in the cached autoloadArray // for external repositories. if ( array_key_exists( $className, ezcBase::$externalAutoloadArray ) ) { // Is it registered as 'unloadable'? if ( ezcBase::$externalAutoloadArray[$className] == false ) { return false; } ezcBase::loadExternalFile( ezcBase::$externalAutoloadArray[$className] ); return true; } // Not cached, so load the autoload from the package. // Matches the first and optionally the second 'word' from the classname. $fileNames = array(); if ( preg_match( "/^([a-z0-9]*)([A-Z][a-z0-9]*)?([A-Z][a-z0-9]*)?/", $className, $matches ) !== false ) { $autoloadFile = ""; // Try to match with both names, if available. switch ( sizeof( $matches ) ) { case 4: // check for x_y_autoload.php $autoloadFile = strtolower( "{$matches[2]}_{$matches[3]}_autoload.php" ); $fileNames[] = $autoloadFile; if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) ) { return true; } // break intentionally missing. case 3: // check for x_autoload.php $autoloadFile = strtolower( "{$matches[2]}_autoload.php" ); $fileNames[] = $autoloadFile; if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) ) { return true; } // break intentionally missing. case 2: // check for autoload.php $autoloadFile = 'autoload.php'; $fileNames[] = $autoloadFile; if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) ) { return true; } break; } // Maybe there is another autoload available. // Register this classname as false. ezcBase::$autoloadArray[$className] = false; } $path = ezcBase::$packageDir . 'autoload/'; $realPath = realpath( $path ); if ( $realPath == '' ) { // Can not be tested, because if this happens, then the autoload // environment has not been set-up correctly. trigger_error( "Couldn't find autoload directory '$path'", E_USER_ERROR ); } $dirs = self::getRepositoryDirectories(); if ( ezcBase::$options && ezcBase::$options->debug ) { throw new ezcBaseAutoloadException( $className, $fileNames, $dirs ); } return false; }
php
public static function autoload( $className ) { Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '(%s)', $className); ezcBase::setPackageDir(); // Check whether the classname is already in the cached autoloadArray. if ( array_key_exists( $className, ezcBase::$autoloadArray ) ) { // Is it registered as 'unloadable'? if ( ezcBase::$autoloadArray[$className] == false ) { return false; } ezcBase::loadFile( ezcBase::$autoloadArray[$className] ); return true; } // Check whether the classname is already in the cached autoloadArray // for external repositories. if ( array_key_exists( $className, ezcBase::$externalAutoloadArray ) ) { // Is it registered as 'unloadable'? if ( ezcBase::$externalAutoloadArray[$className] == false ) { return false; } ezcBase::loadExternalFile( ezcBase::$externalAutoloadArray[$className] ); return true; } // Not cached, so load the autoload from the package. // Matches the first and optionally the second 'word' from the classname. $fileNames = array(); if ( preg_match( "/^([a-z0-9]*)([A-Z][a-z0-9]*)?([A-Z][a-z0-9]*)?/", $className, $matches ) !== false ) { $autoloadFile = ""; // Try to match with both names, if available. switch ( sizeof( $matches ) ) { case 4: // check for x_y_autoload.php $autoloadFile = strtolower( "{$matches[2]}_{$matches[3]}_autoload.php" ); $fileNames[] = $autoloadFile; if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) ) { return true; } // break intentionally missing. case 3: // check for x_autoload.php $autoloadFile = strtolower( "{$matches[2]}_autoload.php" ); $fileNames[] = $autoloadFile; if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) ) { return true; } // break intentionally missing. case 2: // check for autoload.php $autoloadFile = 'autoload.php'; $fileNames[] = $autoloadFile; if ( ezcBase::requireFile( $autoloadFile, $className, $matches[1] ) ) { return true; } break; } // Maybe there is another autoload available. // Register this classname as false. ezcBase::$autoloadArray[$className] = false; } $path = ezcBase::$packageDir . 'autoload/'; $realPath = realpath( $path ); if ( $realPath == '' ) { // Can not be tested, because if this happens, then the autoload // environment has not been set-up correctly. trigger_error( "Couldn't find autoload directory '$path'", E_USER_ERROR ); } $dirs = self::getRepositoryDirectories(); if ( ezcBase::$options && ezcBase::$options->debug ) { throw new ezcBaseAutoloadException( $className, $fileNames, $dirs ); } return false; }
[ "public", "static", "function", "autoload", "(", "$", "className", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_DEBUG", ",", "'(%s)'", ",", "$", "className", ")", ";", "ezcBase", "::", "setPackageDir", "(", ")", ";", "// Check whether the classname is already in the cached autoloadArray.", "if", "(", "array_key_exists", "(", "$", "className", ",", "ezcBase", "::", "$", "autoloadArray", ")", ")", "{", "// Is it registered as 'unloadable'?", "if", "(", "ezcBase", "::", "$", "autoloadArray", "[", "$", "className", "]", "==", "false", ")", "{", "return", "false", ";", "}", "ezcBase", "::", "loadFile", "(", "ezcBase", "::", "$", "autoloadArray", "[", "$", "className", "]", ")", ";", "return", "true", ";", "}", "// Check whether the classname is already in the cached autoloadArray", "// for external repositories.", "if", "(", "array_key_exists", "(", "$", "className", ",", "ezcBase", "::", "$", "externalAutoloadArray", ")", ")", "{", "// Is it registered as 'unloadable'?", "if", "(", "ezcBase", "::", "$", "externalAutoloadArray", "[", "$", "className", "]", "==", "false", ")", "{", "return", "false", ";", "}", "ezcBase", "::", "loadExternalFile", "(", "ezcBase", "::", "$", "externalAutoloadArray", "[", "$", "className", "]", ")", ";", "return", "true", ";", "}", "// Not cached, so load the autoload from the package.", "// Matches the first and optionally the second 'word' from the classname.", "$", "fileNames", "=", "array", "(", ")", ";", "if", "(", "preg_match", "(", "\"/^([a-z0-9]*)([A-Z][a-z0-9]*)?([A-Z][a-z0-9]*)?/\"", ",", "$", "className", ",", "$", "matches", ")", "!==", "false", ")", "{", "$", "autoloadFile", "=", "\"\"", ";", "// Try to match with both names, if available.", "switch", "(", "sizeof", "(", "$", "matches", ")", ")", "{", "case", "4", ":", "// check for x_y_autoload.php", "$", "autoloadFile", "=", "strtolower", "(", "\"{$matches[2]}_{$matches[3]}_autoload.php\"", ")", ";", "$", "fileNames", "[", "]", "=", "$", "autoloadFile", ";", "if", "(", "ezcBase", "::", "requireFile", "(", "$", "autoloadFile", ",", "$", "className", ",", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "true", ";", "}", "// break intentionally missing.", "case", "3", ":", "// check for x_autoload.php", "$", "autoloadFile", "=", "strtolower", "(", "\"{$matches[2]}_autoload.php\"", ")", ";", "$", "fileNames", "[", "]", "=", "$", "autoloadFile", ";", "if", "(", "ezcBase", "::", "requireFile", "(", "$", "autoloadFile", ",", "$", "className", ",", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "true", ";", "}", "// break intentionally missing.", "case", "2", ":", "// check for autoload.php", "$", "autoloadFile", "=", "'autoload.php'", ";", "$", "fileNames", "[", "]", "=", "$", "autoloadFile", ";", "if", "(", "ezcBase", "::", "requireFile", "(", "$", "autoloadFile", ",", "$", "className", ",", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "true", ";", "}", "break", ";", "}", "// Maybe there is another autoload available.", "// Register this classname as false.", "ezcBase", "::", "$", "autoloadArray", "[", "$", "className", "]", "=", "false", ";", "}", "$", "path", "=", "ezcBase", "::", "$", "packageDir", ".", "'autoload/'", ";", "$", "realPath", "=", "realpath", "(", "$", "path", ")", ";", "if", "(", "$", "realPath", "==", "''", ")", "{", "// Can not be tested, because if this happens, then the autoload", "// environment has not been set-up correctly.", "trigger_error", "(", "\"Couldn't find autoload directory '$path'\"", ",", "E_USER_ERROR", ")", ";", "}", "$", "dirs", "=", "self", "::", "getRepositoryDirectories", "(", ")", ";", "if", "(", "ezcBase", "::", "$", "options", "&&", "ezcBase", "::", "$", "options", "->", "debug", ")", "{", "throw", "new", "ezcBaseAutoloadException", "(", "$", "className", ",", "$", "fileNames", ",", "$", "dirs", ")", ";", "}", "return", "false", ";", "}" ]
Tries to autoload the given className. If the className could be found this method returns true, otherwise false. This class caches the requested class names (including the ones who failed to load). @param string $className The name of the class that should be loaded. @return bool
[ "Tries", "to", "autoload", "the", "given", "className", ".", "If", "the", "className", "could", "be", "found", "this", "method", "returns", "true", "otherwise", "false", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php#L123-L217
23,340
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php
ezcBase.setPackageDir
protected static function setPackageDir() { if ( ezcBase::$packageDir !== null ) { return; } // Get the path to the components. $baseDir = dirname( __FILE__ ); switch ( ezcBase::$libraryMode ) { case "custom": ezcBase::$packageDir = self::$currentWorkingDirectory . '/'; break; case "devel": case "tarball": ezcBase::$packageDir = $baseDir. "/../../"; break; case "pear"; ezcBase::$packageDir = $baseDir. "/../"; break; } }
php
protected static function setPackageDir() { if ( ezcBase::$packageDir !== null ) { return; } // Get the path to the components. $baseDir = dirname( __FILE__ ); switch ( ezcBase::$libraryMode ) { case "custom": ezcBase::$packageDir = self::$currentWorkingDirectory . '/'; break; case "devel": case "tarball": ezcBase::$packageDir = $baseDir. "/../../"; break; case "pear"; ezcBase::$packageDir = $baseDir. "/../"; break; } }
[ "protected", "static", "function", "setPackageDir", "(", ")", "{", "if", "(", "ezcBase", "::", "$", "packageDir", "!==", "null", ")", "{", "return", ";", "}", "// Get the path to the components.", "$", "baseDir", "=", "dirname", "(", "__FILE__", ")", ";", "switch", "(", "ezcBase", "::", "$", "libraryMode", ")", "{", "case", "\"custom\"", ":", "ezcBase", "::", "$", "packageDir", "=", "self", "::", "$", "currentWorkingDirectory", ".", "'/'", ";", "break", ";", "case", "\"devel\"", ":", "case", "\"tarball\"", ":", "ezcBase", "::", "$", "packageDir", "=", "$", "baseDir", ".", "\"/../../\"", ";", "break", ";", "case", "\"pear\"", ";", "ezcBase", "::", "$", "packageDir", "=", "$", "baseDir", ".", "\"/../\"", ";", "break", ";", "}", "}" ]
Figures out the base path of the eZ Components installation. It stores the path that it finds in a static member variable. The path depends on the installation method of the eZ Components. The SVN version has a different path than the PEAR installed version.
[ "Figures", "out", "the", "base", "path", "of", "the", "eZ", "Components", "installation", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php#L237-L260
23,341
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php
ezcBase.requireFile
protected static function requireFile( $fileName, $className, $prefix ) { $autoloadDir = ezcBase::$packageDir . "autoload/"; // We need the full path to the fileName. The method file_exists() doesn't // automatically check the (php.ini) library paths. Therefore: // file_exists( "ezc/autoload/$fileName" ) doesn't work. if ( $prefix === 'ezc' && file_exists( "$autoloadDir$fileName" ) ) { $array = require( "$autoloadDir$fileName" ); if ( is_array( $array) && array_key_exists( $className, $array ) ) { // Add the array to the cache, and include the requested file. ezcBase::$autoloadArray = array_merge( ezcBase::$autoloadArray, $array ); if ( ezcBase::$options !== null && ezcBase::$options->preload && !preg_match( '/Exception$/', $className ) ) { foreach ( $array as $loadClassName => $file ) { if ( $loadClassName !== 'ezcBase' && !class_exists( $loadClassName, false ) && !interface_exists( $loadClassName, false ) && !preg_match( '/Exception$/', $loadClassName ) /*&& !class_exists( $loadClassName, false ) && !interface_exists( $loadClassName, false )*/ ) { ezcBase::loadFile( ezcBase::$autoloadArray[$loadClassName] ); } } } else { ezcBase::loadFile( ezcBase::$autoloadArray[$className] ); } return true; } } // It is not in components autoload/ dir. // try to search in additional dirs. foreach ( ezcBase::$repositoryDirs as $repositoryPrefix => $extraDir ) { if ( gettype( $repositoryPrefix ) === 'string' && $repositoryPrefix !== $prefix ) { continue; } if ( file_exists( $extraDir['autoloadDirPath'] . '/' . $fileName ) ) { $array = array(); $originalArray = require( $extraDir['autoloadDirPath'] . '/' . $fileName ); // Building paths. // Resulting path to class definition file consists of: // path to extra directory with autoload file + // basePath provided for current extra directory + // path to class definition file stored in autoload file. foreach ( $originalArray as $class => $classPath ) { $array[$class] = $extraDir['basePath'] . '/' . $classPath; } if ( is_array( $array ) && array_key_exists( $className, $array ) ) { // Add the array to the cache, and include the requested file. ezcBase::$externalAutoloadArray = array_merge( ezcBase::$externalAutoloadArray, $array ); ezcBase::loadExternalFile( ezcBase::$externalAutoloadArray[$className] ); return true; } } } // Nothing found :-(. return false; }
php
protected static function requireFile( $fileName, $className, $prefix ) { $autoloadDir = ezcBase::$packageDir . "autoload/"; // We need the full path to the fileName. The method file_exists() doesn't // automatically check the (php.ini) library paths. Therefore: // file_exists( "ezc/autoload/$fileName" ) doesn't work. if ( $prefix === 'ezc' && file_exists( "$autoloadDir$fileName" ) ) { $array = require( "$autoloadDir$fileName" ); if ( is_array( $array) && array_key_exists( $className, $array ) ) { // Add the array to the cache, and include the requested file. ezcBase::$autoloadArray = array_merge( ezcBase::$autoloadArray, $array ); if ( ezcBase::$options !== null && ezcBase::$options->preload && !preg_match( '/Exception$/', $className ) ) { foreach ( $array as $loadClassName => $file ) { if ( $loadClassName !== 'ezcBase' && !class_exists( $loadClassName, false ) && !interface_exists( $loadClassName, false ) && !preg_match( '/Exception$/', $loadClassName ) /*&& !class_exists( $loadClassName, false ) && !interface_exists( $loadClassName, false )*/ ) { ezcBase::loadFile( ezcBase::$autoloadArray[$loadClassName] ); } } } else { ezcBase::loadFile( ezcBase::$autoloadArray[$className] ); } return true; } } // It is not in components autoload/ dir. // try to search in additional dirs. foreach ( ezcBase::$repositoryDirs as $repositoryPrefix => $extraDir ) { if ( gettype( $repositoryPrefix ) === 'string' && $repositoryPrefix !== $prefix ) { continue; } if ( file_exists( $extraDir['autoloadDirPath'] . '/' . $fileName ) ) { $array = array(); $originalArray = require( $extraDir['autoloadDirPath'] . '/' . $fileName ); // Building paths. // Resulting path to class definition file consists of: // path to extra directory with autoload file + // basePath provided for current extra directory + // path to class definition file stored in autoload file. foreach ( $originalArray as $class => $classPath ) { $array[$class] = $extraDir['basePath'] . '/' . $classPath; } if ( is_array( $array ) && array_key_exists( $className, $array ) ) { // Add the array to the cache, and include the requested file. ezcBase::$externalAutoloadArray = array_merge( ezcBase::$externalAutoloadArray, $array ); ezcBase::loadExternalFile( ezcBase::$externalAutoloadArray[$className] ); return true; } } } // Nothing found :-(. return false; }
[ "protected", "static", "function", "requireFile", "(", "$", "fileName", ",", "$", "className", ",", "$", "prefix", ")", "{", "$", "autoloadDir", "=", "ezcBase", "::", "$", "packageDir", ".", "\"autoload/\"", ";", "// We need the full path to the fileName. The method file_exists() doesn't", "// automatically check the (php.ini) library paths. Therefore:", "// file_exists( \"ezc/autoload/$fileName\" ) doesn't work.", "if", "(", "$", "prefix", "===", "'ezc'", "&&", "file_exists", "(", "\"$autoloadDir$fileName\"", ")", ")", "{", "$", "array", "=", "require", "(", "\"$autoloadDir$fileName\"", ")", ";", "if", "(", "is_array", "(", "$", "array", ")", "&&", "array_key_exists", "(", "$", "className", ",", "$", "array", ")", ")", "{", "// Add the array to the cache, and include the requested file.", "ezcBase", "::", "$", "autoloadArray", "=", "array_merge", "(", "ezcBase", "::", "$", "autoloadArray", ",", "$", "array", ")", ";", "if", "(", "ezcBase", "::", "$", "options", "!==", "null", "&&", "ezcBase", "::", "$", "options", "->", "preload", "&&", "!", "preg_match", "(", "'/Exception$/'", ",", "$", "className", ")", ")", "{", "foreach", "(", "$", "array", "as", "$", "loadClassName", "=>", "$", "file", ")", "{", "if", "(", "$", "loadClassName", "!==", "'ezcBase'", "&&", "!", "class_exists", "(", "$", "loadClassName", ",", "false", ")", "&&", "!", "interface_exists", "(", "$", "loadClassName", ",", "false", ")", "&&", "!", "preg_match", "(", "'/Exception$/'", ",", "$", "loadClassName", ")", "/*&& !class_exists( $loadClassName, false ) && !interface_exists( $loadClassName, false )*/", ")", "{", "ezcBase", "::", "loadFile", "(", "ezcBase", "::", "$", "autoloadArray", "[", "$", "loadClassName", "]", ")", ";", "}", "}", "}", "else", "{", "ezcBase", "::", "loadFile", "(", "ezcBase", "::", "$", "autoloadArray", "[", "$", "className", "]", ")", ";", "}", "return", "true", ";", "}", "}", "// It is not in components autoload/ dir.", "// try to search in additional dirs.", "foreach", "(", "ezcBase", "::", "$", "repositoryDirs", "as", "$", "repositoryPrefix", "=>", "$", "extraDir", ")", "{", "if", "(", "gettype", "(", "$", "repositoryPrefix", ")", "===", "'string'", "&&", "$", "repositoryPrefix", "!==", "$", "prefix", ")", "{", "continue", ";", "}", "if", "(", "file_exists", "(", "$", "extraDir", "[", "'autoloadDirPath'", "]", ".", "'/'", ".", "$", "fileName", ")", ")", "{", "$", "array", "=", "array", "(", ")", ";", "$", "originalArray", "=", "require", "(", "$", "extraDir", "[", "'autoloadDirPath'", "]", ".", "'/'", ".", "$", "fileName", ")", ";", "// Building paths.", "// Resulting path to class definition file consists of:", "// path to extra directory with autoload file +", "// basePath provided for current extra directory +", "// path to class definition file stored in autoload file.", "foreach", "(", "$", "originalArray", "as", "$", "class", "=>", "$", "classPath", ")", "{", "$", "array", "[", "$", "class", "]", "=", "$", "extraDir", "[", "'basePath'", "]", ".", "'/'", ".", "$", "classPath", ";", "}", "if", "(", "is_array", "(", "$", "array", ")", "&&", "array_key_exists", "(", "$", "className", ",", "$", "array", ")", ")", "{", "// Add the array to the cache, and include the requested file.", "ezcBase", "::", "$", "externalAutoloadArray", "=", "array_merge", "(", "ezcBase", "::", "$", "externalAutoloadArray", ",", "$", "array", ")", ";", "ezcBase", "::", "loadExternalFile", "(", "ezcBase", "::", "$", "externalAutoloadArray", "[", "$", "className", "]", ")", ";", "return", "true", ";", "}", "}", "}", "// Nothing found :-(.", "return", "false", ";", "}" ]
Tries to load the autoload array and, if loaded correctly, includes the class. @param string $fileName Name of the autoload file. @param string $className Name of the class that should be autoloaded. @param string $prefix The prefix of the class repository. @return bool True is returned when the file is correctly loaded. Otherwise false is returned.
[ "Tries", "to", "load", "the", "autoload", "array", "and", "if", "loaded", "correctly", "includes", "the", "class", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php#L272-L341
23,342
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php
ezcBase.checkDependency
public static function checkDependency( $component, $type, $value ) { switch ( $type ) { case self::DEP_PHP_EXTENSION: if ( extension_loaded( $value ) ) { return; } else { // Can not be tested as it would abort the PHP script. die( "\nThe {$component} component depends on the default PHP extension '{$value}', which is not loaded.\n" ); } break; case self::DEP_PHP_VERSION: $phpVersion = phpversion(); if ( version_compare( $phpVersion, $value, '>=' ) ) { return; } else { // Can not be tested as it would abort the PHP script. die( "\nThe {$component} component depends on the PHP version '{$value}', but the current version is '{$phpVersion}'.\n" ); } break; } }
php
public static function checkDependency( $component, $type, $value ) { switch ( $type ) { case self::DEP_PHP_EXTENSION: if ( extension_loaded( $value ) ) { return; } else { // Can not be tested as it would abort the PHP script. die( "\nThe {$component} component depends on the default PHP extension '{$value}', which is not loaded.\n" ); } break; case self::DEP_PHP_VERSION: $phpVersion = phpversion(); if ( version_compare( $phpVersion, $value, '>=' ) ) { return; } else { // Can not be tested as it would abort the PHP script. die( "\nThe {$component} component depends on the PHP version '{$value}', but the current version is '{$phpVersion}'.\n" ); } break; } }
[ "public", "static", "function", "checkDependency", "(", "$", "component", ",", "$", "type", ",", "$", "value", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "self", "::", "DEP_PHP_EXTENSION", ":", "if", "(", "extension_loaded", "(", "$", "value", ")", ")", "{", "return", ";", "}", "else", "{", "// Can not be tested as it would abort the PHP script.", "die", "(", "\"\\nThe {$component} component depends on the default PHP extension '{$value}', which is not loaded.\\n\"", ")", ";", "}", "break", ";", "case", "self", "::", "DEP_PHP_VERSION", ":", "$", "phpVersion", "=", "phpversion", "(", ")", ";", "if", "(", "version_compare", "(", "$", "phpVersion", ",", "$", "value", ",", "'>='", ")", ")", "{", "return", ";", "}", "else", "{", "// Can not be tested as it would abort the PHP script.", "die", "(", "\"\\nThe {$component} component depends on the PHP version '{$value}', but the current version is '{$phpVersion}'.\\n\"", ")", ";", "}", "break", ";", "}", "}" ]
Checks for dependencies on PHP versions or extensions The function as called by the $component component checks for the $type dependency. The dependency $type is compared against the $value. The function aborts the script if the dependency is not matched. @param string $component @param int $type @param mixed $value
[ "Checks", "for", "dependencies", "on", "PHP", "versions", "or", "extensions" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php#L419-L448
23,343
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php
ezcBase.getRepositoryDirectories
public static function getRepositoryDirectories() { $autoloadDirs = array(); ezcBase::setPackageDir(); $repositoryDir = self::$currentWorkingDirectory ? self::$currentWorkingDirectory : ( realpath( dirname( __FILE__ ) . '/../../' ) ); $autoloadDirs['ezc'] = new ezcBaseRepositoryDirectory( ezcBaseRepositoryDirectory::TYPE_INTERNAL, $repositoryDir, $repositoryDir . "/autoload" ); foreach ( ezcBase::$repositoryDirs as $extraDirKey => $extraDirArray ) { $repositoryDirectory = new ezcBaseRepositoryDirectory( ezcBaseRepositoryDirectory::TYPE_EXTERNAL, realpath( $extraDirArray['basePath'] ), realpath( $extraDirArray['autoloadDirPath'] ) ); $autoloadDirs[$extraDirKey] = $repositoryDirectory; } return $autoloadDirs; }
php
public static function getRepositoryDirectories() { $autoloadDirs = array(); ezcBase::setPackageDir(); $repositoryDir = self::$currentWorkingDirectory ? self::$currentWorkingDirectory : ( realpath( dirname( __FILE__ ) . '/../../' ) ); $autoloadDirs['ezc'] = new ezcBaseRepositoryDirectory( ezcBaseRepositoryDirectory::TYPE_INTERNAL, $repositoryDir, $repositoryDir . "/autoload" ); foreach ( ezcBase::$repositoryDirs as $extraDirKey => $extraDirArray ) { $repositoryDirectory = new ezcBaseRepositoryDirectory( ezcBaseRepositoryDirectory::TYPE_EXTERNAL, realpath( $extraDirArray['basePath'] ), realpath( $extraDirArray['autoloadDirPath'] ) ); $autoloadDirs[$extraDirKey] = $repositoryDirectory; } return $autoloadDirs; }
[ "public", "static", "function", "getRepositoryDirectories", "(", ")", "{", "$", "autoloadDirs", "=", "array", "(", ")", ";", "ezcBase", "::", "setPackageDir", "(", ")", ";", "$", "repositoryDir", "=", "self", "::", "$", "currentWorkingDirectory", "?", "self", "::", "$", "currentWorkingDirectory", ":", "(", "realpath", "(", "dirname", "(", "__FILE__", ")", ".", "'/../../'", ")", ")", ";", "$", "autoloadDirs", "[", "'ezc'", "]", "=", "new", "ezcBaseRepositoryDirectory", "(", "ezcBaseRepositoryDirectory", "::", "TYPE_INTERNAL", ",", "$", "repositoryDir", ",", "$", "repositoryDir", ".", "\"/autoload\"", ")", ";", "foreach", "(", "ezcBase", "::", "$", "repositoryDirs", "as", "$", "extraDirKey", "=>", "$", "extraDirArray", ")", "{", "$", "repositoryDirectory", "=", "new", "ezcBaseRepositoryDirectory", "(", "ezcBaseRepositoryDirectory", "::", "TYPE_EXTERNAL", ",", "realpath", "(", "$", "extraDirArray", "[", "'basePath'", "]", ")", ",", "realpath", "(", "$", "extraDirArray", "[", "'autoloadDirPath'", "]", ")", ")", ";", "$", "autoloadDirs", "[", "$", "extraDirKey", "]", "=", "$", "repositoryDirectory", ";", "}", "return", "$", "autoloadDirs", ";", "}" ]
Return the list of directories that contain class repositories. The path to the eZ components directory is always included in the result array. Each element in the returned array has the format of: packageDirectory => ezcBaseRepositoryDirectory @return array(string=>ezcBaseRepositoryDirectory)
[ "Return", "the", "list", "of", "directories", "that", "contain", "class", "repositories", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php#L459-L473
23,344
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php
ezcBase.addClassRepository
public static function addClassRepository( $basePath, $autoloadDirPath = null, $prefix = null ) { // check if base path exists if ( !is_dir( $basePath ) ) { throw new ezcBaseFileNotFoundException( $basePath, 'base directory' ); } // calculate autoload path if it wasn't given if ( is_null( $autoloadDirPath ) ) { $autoloadDirPath = $basePath . '/autoload'; } // check if autoload dir exists if ( !is_dir( $autoloadDirPath ) ) { throw new ezcBaseFileNotFoundException( $autoloadDirPath, 'autoload directory' ); } // add info to $repositoryDirs if ( $prefix === null ) { $array = array( 'basePath' => $basePath, 'autoloadDirPath' => $autoloadDirPath ); // add info to the list of extra dirs ezcBase::$repositoryDirs[] = $array; } else { if ( array_key_exists( $prefix, ezcBase::$repositoryDirs ) ) { throw new ezcBaseDoubleClassRepositoryPrefixException( $prefix, $basePath, $autoloadDirPath ); } // add info to the list of extra dirs, and use the prefix to identify the new repository. ezcBase::$repositoryDirs[$prefix] = array( 'basePath' => $basePath, 'autoloadDirPath' => $autoloadDirPath ); } }
php
public static function addClassRepository( $basePath, $autoloadDirPath = null, $prefix = null ) { // check if base path exists if ( !is_dir( $basePath ) ) { throw new ezcBaseFileNotFoundException( $basePath, 'base directory' ); } // calculate autoload path if it wasn't given if ( is_null( $autoloadDirPath ) ) { $autoloadDirPath = $basePath . '/autoload'; } // check if autoload dir exists if ( !is_dir( $autoloadDirPath ) ) { throw new ezcBaseFileNotFoundException( $autoloadDirPath, 'autoload directory' ); } // add info to $repositoryDirs if ( $prefix === null ) { $array = array( 'basePath' => $basePath, 'autoloadDirPath' => $autoloadDirPath ); // add info to the list of extra dirs ezcBase::$repositoryDirs[] = $array; } else { if ( array_key_exists( $prefix, ezcBase::$repositoryDirs ) ) { throw new ezcBaseDoubleClassRepositoryPrefixException( $prefix, $basePath, $autoloadDirPath ); } // add info to the list of extra dirs, and use the prefix to identify the new repository. ezcBase::$repositoryDirs[$prefix] = array( 'basePath' => $basePath, 'autoloadDirPath' => $autoloadDirPath ); } }
[ "public", "static", "function", "addClassRepository", "(", "$", "basePath", ",", "$", "autoloadDirPath", "=", "null", ",", "$", "prefix", "=", "null", ")", "{", "// check if base path exists", "if", "(", "!", "is_dir", "(", "$", "basePath", ")", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "basePath", ",", "'base directory'", ")", ";", "}", "// calculate autoload path if it wasn't given", "if", "(", "is_null", "(", "$", "autoloadDirPath", ")", ")", "{", "$", "autoloadDirPath", "=", "$", "basePath", ".", "'/autoload'", ";", "}", "// check if autoload dir exists", "if", "(", "!", "is_dir", "(", "$", "autoloadDirPath", ")", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "autoloadDirPath", ",", "'autoload directory'", ")", ";", "}", "// add info to $repositoryDirs", "if", "(", "$", "prefix", "===", "null", ")", "{", "$", "array", "=", "array", "(", "'basePath'", "=>", "$", "basePath", ",", "'autoloadDirPath'", "=>", "$", "autoloadDirPath", ")", ";", "// add info to the list of extra dirs", "ezcBase", "::", "$", "repositoryDirs", "[", "]", "=", "$", "array", ";", "}", "else", "{", "if", "(", "array_key_exists", "(", "$", "prefix", ",", "ezcBase", "::", "$", "repositoryDirs", ")", ")", "{", "throw", "new", "ezcBaseDoubleClassRepositoryPrefixException", "(", "$", "prefix", ",", "$", "basePath", ",", "$", "autoloadDirPath", ")", ";", "}", "// add info to the list of extra dirs, and use the prefix to identify the new repository.", "ezcBase", "::", "$", "repositoryDirs", "[", "$", "prefix", "]", "=", "array", "(", "'basePath'", "=>", "$", "basePath", ",", "'autoloadDirPath'", "=>", "$", "autoloadDirPath", ")", ";", "}", "}" ]
Adds an additional class repository. Used for adding class repositoryies outside the eZ components to be loaded by the autoload system. This function takes two arguments: $basePath is the base path for the whole class repository and $autoloadDirPath the path where autoload files for this repository are found. The paths in the autoload files are relative to the package directory as specified by the $basePath argument. I.e. class definition file will be searched at location $basePath + path to the class definition file as stored in the autoload file. addClassRepository() should be called somewhere in code before external classes are used. Example: Take the following facts: <ul> <li>there is a class repository stored in the directory "./repos"</li> <li>autoload files for that repository are stored in "./repos/autoloads"</li> <li>there are two components in this repository: "Me" and "You"</li> <li>the "Me" component has the classes "erMyClass1" and "erMyClass2"</li> <li>the "You" component has the classes "erYourClass1" and "erYourClass2"</li> </ul> In this case you would need to create the following files in "./repos/autoloads". Please note that the part before _autoload.php in the filename is the first part of the <b>classname</b>, not considering the all lower-case letter prefix. "my_autoload.php": <code> <?php return array ( 'erMyClass1' => 'Me/myclass1.php', 'erMyClass2' => 'Me/myclass2.php', ); ?> </code> "your_autoload.php": <code> <?php return array ( 'erYourClass1' => 'You/yourclass1.php', 'erYourClass2' => 'You/yourclass2.php', ); ?> </code> The directory structure for the external repository is then: <code> ./repos/autoloads/my_autoload.php ./repos/autoloads/you_autoload.php ./repos/Me/myclass1.php ./repos/Me/myclass2.php ./repos/You/yourclass1.php ./repos/You/yourclass2.php </code> To use this repository with the autoload mechanism you have to use the following code: <code> <?php ezcBase::addClassRepository( './repos', './repos/autoloads' ); $myVar = new erMyClass2(); ?> </code> @throws ezcBaseFileNotFoundException if $autoloadDirPath or $basePath do not exist. @param string $basePath @param string $autoloadDirPath @param string $prefix
[ "Adds", "an", "additional", "class", "repository", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php#L551-L589
23,345
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php
ezcBase.getInstallationPath
public static function getInstallationPath() { self::setPackageDir(); $path = realpath( self::$packageDir ); if ( substr( $path, -1 ) !== DIRECTORY_SEPARATOR ) { $path .= DIRECTORY_SEPARATOR; } return $path; }
php
public static function getInstallationPath() { self::setPackageDir(); $path = realpath( self::$packageDir ); if ( substr( $path, -1 ) !== DIRECTORY_SEPARATOR ) { $path .= DIRECTORY_SEPARATOR; } return $path; }
[ "public", "static", "function", "getInstallationPath", "(", ")", "{", "self", "::", "setPackageDir", "(", ")", ";", "$", "path", "=", "realpath", "(", "self", "::", "$", "packageDir", ")", ";", "if", "(", "substr", "(", "$", "path", ",", "-", "1", ")", "!==", "DIRECTORY_SEPARATOR", ")", "{", "$", "path", ".=", "DIRECTORY_SEPARATOR", ";", "}", "return", "$", "path", ";", "}" ]
Returns the base path of the eZ Components installation This method returns the base path, including a trailing directory separator. @return string
[ "Returns", "the", "base", "path", "of", "the", "eZ", "Components", "installation" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php#L599-L609
23,346
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php
ezcBase.setRunMode
public static function setRunMode( $runMode ) { if ( !in_array( $runMode, array( ezcBase::MODE_PRODUCTION, ezcBase::MODE_DEVELOPMENT ) ) ) { throw new ezcBaseValueException( 'runMode', $runMode, 'ezcBase::MODE_PRODUCTION or ezcBase::MODE_DEVELOPMENT' ); } self::$runMode = $runMode; }
php
public static function setRunMode( $runMode ) { if ( !in_array( $runMode, array( ezcBase::MODE_PRODUCTION, ezcBase::MODE_DEVELOPMENT ) ) ) { throw new ezcBaseValueException( 'runMode', $runMode, 'ezcBase::MODE_PRODUCTION or ezcBase::MODE_DEVELOPMENT' ); } self::$runMode = $runMode; }
[ "public", "static", "function", "setRunMode", "(", "$", "runMode", ")", "{", "if", "(", "!", "in_array", "(", "$", "runMode", ",", "array", "(", "ezcBase", "::", "MODE_PRODUCTION", ",", "ezcBase", "::", "MODE_DEVELOPMENT", ")", ")", ")", "{", "throw", "new", "ezcBaseValueException", "(", "'runMode'", ",", "$", "runMode", ",", "'ezcBase::MODE_PRODUCTION or ezcBase::MODE_DEVELOPMENT'", ")", ";", "}", "self", "::", "$", "runMode", "=", "$", "runMode", ";", "}" ]
Sets the development mode to the one specified. @param int $runMode
[ "Sets", "the", "development", "mode", "to", "the", "one", "specified", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/base.php#L616-L624
23,347
xiewulong/yii2-fileupload
oss/libs/symfony/yaml/Symfony/Component/Yaml/Inline.php
Inline.parse
public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) { self::$exceptionOnInvalidType = $exceptionOnInvalidType; self::$objectSupport = $objectSupport; $value = trim($value); if (0 == strlen($value)) { return ''; } if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } $i = 0; switch ($value[0]) { case '[': $result = self::parseSequence($value, $i); ++$i; break; case '{': $result = self::parseMapping($value, $i); ++$i; break; default: $result = self::parseScalar($value, null, array('"', "'"), $i); } // some comments are allowed at the end if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i))); } if (isset($mbEncoding)) { mb_internal_encoding($mbEncoding); } return $result; }
php
public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) { self::$exceptionOnInvalidType = $exceptionOnInvalidType; self::$objectSupport = $objectSupport; $value = trim($value); if (0 == strlen($value)) { return ''; } if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } $i = 0; switch ($value[0]) { case '[': $result = self::parseSequence($value, $i); ++$i; break; case '{': $result = self::parseMapping($value, $i); ++$i; break; default: $result = self::parseScalar($value, null, array('"', "'"), $i); } // some comments are allowed at the end if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i))); } if (isset($mbEncoding)) { mb_internal_encoding($mbEncoding); } return $result; }
[ "public", "static", "function", "parse", "(", "$", "value", ",", "$", "exceptionOnInvalidType", "=", "false", ",", "$", "objectSupport", "=", "false", ")", "{", "self", "::", "$", "exceptionOnInvalidType", "=", "$", "exceptionOnInvalidType", ";", "self", "::", "$", "objectSupport", "=", "$", "objectSupport", ";", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "if", "(", "0", "==", "strlen", "(", "$", "value", ")", ")", "{", "return", "''", ";", "}", "if", "(", "function_exists", "(", "'mb_internal_encoding'", ")", "&&", "(", "(", "int", ")", "ini_get", "(", "'mbstring.func_overload'", ")", ")", "&", "2", ")", "{", "$", "mbEncoding", "=", "mb_internal_encoding", "(", ")", ";", "mb_internal_encoding", "(", "'ASCII'", ")", ";", "}", "$", "i", "=", "0", ";", "switch", "(", "$", "value", "[", "0", "]", ")", "{", "case", "'['", ":", "$", "result", "=", "self", "::", "parseSequence", "(", "$", "value", ",", "$", "i", ")", ";", "++", "$", "i", ";", "break", ";", "case", "'{'", ":", "$", "result", "=", "self", "::", "parseMapping", "(", "$", "value", ",", "$", "i", ")", ";", "++", "$", "i", ";", "break", ";", "default", ":", "$", "result", "=", "self", "::", "parseScalar", "(", "$", "value", ",", "null", ",", "array", "(", "'\"'", ",", "\"'\"", ")", ",", "$", "i", ")", ";", "}", "// some comments are allowed at the end", "if", "(", "preg_replace", "(", "'/\\s+#.*$/A'", ",", "''", ",", "substr", "(", "$", "value", ",", "$", "i", ")", ")", ")", "{", "throw", "new", "ParseException", "(", "sprintf", "(", "'Unexpected characters near \"%s\".'", ",", "substr", "(", "$", "value", ",", "$", "i", ")", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "mbEncoding", ")", ")", "{", "mb_internal_encoding", "(", "$", "mbEncoding", ")", ";", "}", "return", "$", "result", ";", "}" ]
Converts a YAML string to a PHP array. @param string $value A YAML string @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise @param Boolean $objectSupport true if object support is enabled, false otherwise @return array A PHP array representing the YAML string @throws ParseException
[ "Converts", "a", "YAML", "string", "to", "a", "PHP", "array", "." ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Inline.php#L39-L79
23,348
xiewulong/yii2-fileupload
oss/libs/symfony/yaml/Symfony/Component/Yaml/Inline.php
Inline.parseScalar
public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) { if (in_array($scalar[$i], $stringDelimiters)) { // quoted scalar $output = self::parseQuotedScalar($scalar, $i); if (null !== $delimiters) { $tmp = ltrim(substr($scalar, $i), ' '); if (!in_array($tmp[0], $delimiters)) { throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i))); } } } else { // "normal" string if (!$delimiters) { $output = substr($scalar, $i); $i += strlen($output); // remove comments if (false !== $strpos = strpos($output, ' #')) { $output = rtrim(substr($output, 0, $strpos)); } } elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) { $output = $match[1]; $i += strlen($output); } else { throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar)); } $output = $evaluate ? self::evaluateScalar($output) : $output; } return $output; }
php
public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) { if (in_array($scalar[$i], $stringDelimiters)) { // quoted scalar $output = self::parseQuotedScalar($scalar, $i); if (null !== $delimiters) { $tmp = ltrim(substr($scalar, $i), ' '); if (!in_array($tmp[0], $delimiters)) { throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i))); } } } else { // "normal" string if (!$delimiters) { $output = substr($scalar, $i); $i += strlen($output); // remove comments if (false !== $strpos = strpos($output, ' #')) { $output = rtrim(substr($output, 0, $strpos)); } } elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) { $output = $match[1]; $i += strlen($output); } else { throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar)); } $output = $evaluate ? self::evaluateScalar($output) : $output; } return $output; }
[ "public", "static", "function", "parseScalar", "(", "$", "scalar", ",", "$", "delimiters", "=", "null", ",", "$", "stringDelimiters", "=", "array", "(", "'\"'", ",", "\"'\"", ")", ",", "&", "$", "i", "=", "0", ",", "$", "evaluate", "=", "true", ")", "{", "if", "(", "in_array", "(", "$", "scalar", "[", "$", "i", "]", ",", "$", "stringDelimiters", ")", ")", "{", "// quoted scalar", "$", "output", "=", "self", "::", "parseQuotedScalar", "(", "$", "scalar", ",", "$", "i", ")", ";", "if", "(", "null", "!==", "$", "delimiters", ")", "{", "$", "tmp", "=", "ltrim", "(", "substr", "(", "$", "scalar", ",", "$", "i", ")", ",", "' '", ")", ";", "if", "(", "!", "in_array", "(", "$", "tmp", "[", "0", "]", ",", "$", "delimiters", ")", ")", "{", "throw", "new", "ParseException", "(", "sprintf", "(", "'Unexpected characters (%s).'", ",", "substr", "(", "$", "scalar", ",", "$", "i", ")", ")", ")", ";", "}", "}", "}", "else", "{", "// \"normal\" string", "if", "(", "!", "$", "delimiters", ")", "{", "$", "output", "=", "substr", "(", "$", "scalar", ",", "$", "i", ")", ";", "$", "i", "+=", "strlen", "(", "$", "output", ")", ";", "// remove comments", "if", "(", "false", "!==", "$", "strpos", "=", "strpos", "(", "$", "output", ",", "' #'", ")", ")", "{", "$", "output", "=", "rtrim", "(", "substr", "(", "$", "output", ",", "0", ",", "$", "strpos", ")", ")", ";", "}", "}", "elseif", "(", "preg_match", "(", "'/^(.+?)('", ".", "implode", "(", "'|'", ",", "$", "delimiters", ")", ".", "')/'", ",", "substr", "(", "$", "scalar", ",", "$", "i", ")", ",", "$", "match", ")", ")", "{", "$", "output", "=", "$", "match", "[", "1", "]", ";", "$", "i", "+=", "strlen", "(", "$", "output", ")", ";", "}", "else", "{", "throw", "new", "ParseException", "(", "sprintf", "(", "'Malformed inline YAML string (%s).'", ",", "$", "scalar", ")", ")", ";", "}", "$", "output", "=", "$", "evaluate", "?", "self", "::", "evaluateScalar", "(", "$", "output", ")", ":", "$", "output", ";", "}", "return", "$", "output", ";", "}" ]
Parses a scalar to a YAML string. @param scalar $scalar @param string $delimiters @param array $stringDelimiters @param integer &$i @param Boolean $evaluate @return string A YAML string @throws ParseException When malformed inline YAML string is parsed
[ "Parses", "a", "scalar", "to", "a", "YAML", "string", "." ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Inline.php#L193-L226
23,349
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Controller/SecurityController.php
SecurityController.forgotCheckAction
public function forgotCheckAction(Request $request) { $error = null; $last_email = null; $userService = $this->get("flowcode.user"); $user = $userService->loadUserByUsername($request->get("_username")); if ($user) { $userService->resetPasssword($user); } else { $error = array( "messageKey" => "security.login.unknown_user", "messageData" => array(), ); } return array( "error" => $error, "last_email" => $last_email, ); }
php
public function forgotCheckAction(Request $request) { $error = null; $last_email = null; $userService = $this->get("flowcode.user"); $user = $userService->loadUserByUsername($request->get("_username")); if ($user) { $userService->resetPasssword($user); } else { $error = array( "messageKey" => "security.login.unknown_user", "messageData" => array(), ); } return array( "error" => $error, "last_email" => $last_email, ); }
[ "public", "function", "forgotCheckAction", "(", "Request", "$", "request", ")", "{", "$", "error", "=", "null", ";", "$", "last_email", "=", "null", ";", "$", "userService", "=", "$", "this", "->", "get", "(", "\"flowcode.user\"", ")", ";", "$", "user", "=", "$", "userService", "->", "loadUserByUsername", "(", "$", "request", "->", "get", "(", "\"_username\"", ")", ")", ";", "if", "(", "$", "user", ")", "{", "$", "userService", "->", "resetPasssword", "(", "$", "user", ")", ";", "}", "else", "{", "$", "error", "=", "array", "(", "\"messageKey\"", "=>", "\"security.login.unknown_user\"", ",", "\"messageData\"", "=>", "array", "(", ")", ",", ")", ";", "}", "return", "array", "(", "\"error\"", "=>", "$", "error", ",", "\"last_email\"", "=>", "$", "last_email", ",", ")", ";", "}" ]
Forget check. @Route("/forgot_check", name="amulen_forgot_check") @Method("POST") @Template("FlowcodeUserBundle:Security:forgot.html.twig")
[ "Forget", "check", "." ]
00055834d9f094e63dcd8d66e2fedb822fcddee0
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/SecurityController.php#L90-L112
23,350
Laralum/Events
src/Policies/EventPolicy.php
EventPolicy.view
public function view($user, Event $event) { if ($event->creator->id == $user->id) { return true; } return User::findOrFail($user->id)->hasPermission('laralum::events.view'); }
php
public function view($user, Event $event) { if ($event->creator->id == $user->id) { return true; } return User::findOrFail($user->id)->hasPermission('laralum::events.view'); }
[ "public", "function", "view", "(", "$", "user", ",", "Event", "$", "event", ")", "{", "if", "(", "$", "event", "->", "creator", "->", "id", "==", "$", "user", "->", "id", ")", "{", "return", "true", ";", "}", "return", "User", "::", "findOrFail", "(", "$", "user", "->", "id", ")", "->", "hasPermission", "(", "'laralum::events.view'", ")", ";", "}" ]
Determine if the current user can view events. @param mixed $user @return bool
[ "Determine", "if", "the", "current", "user", "can", "view", "events", "." ]
9dc36468f4253e7d040863a115ea94cded0e6aa5
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Policies/EventPolicy.php#L57-L64
23,351
Laralum/Events
src/Policies/EventPolicy.php
EventPolicy.publicDelete
public function publicDelete($user, Event $event) { if ($event->creator->id == $user->id) { return User::findOrFail($user->id)->hasPermission('laralum::events.delete-public'); } return false; }
php
public function publicDelete($user, Event $event) { if ($event->creator->id == $user->id) { return User::findOrFail($user->id)->hasPermission('laralum::events.delete-public'); } return false; }
[ "public", "function", "publicDelete", "(", "$", "user", ",", "Event", "$", "event", ")", "{", "if", "(", "$", "event", "->", "creator", "->", "id", "==", "$", "user", "->", "id", ")", "{", "return", "User", "::", "findOrFail", "(", "$", "user", "->", "id", ")", "->", "hasPermission", "(", "'laralum::events.delete-public'", ")", ";", "}", "return", "false", ";", "}" ]
Determine if the current user can delete events on public views. @param mixed $user @return bool
[ "Determine", "if", "the", "current", "user", "can", "delete", "events", "on", "public", "views", "." ]
9dc36468f4253e7d040863a115ea94cded0e6aa5
https://github.com/Laralum/Events/blob/9dc36468f4253e7d040863a115ea94cded0e6aa5/src/Policies/EventPolicy.php#L185-L192
23,352
42mate/towel
src/Towel/Controller/BaseController.php
BaseController.routeError
public function routeError(\Exception $e) { if ($e instanceof NotFoundHttpException) { $responseContent = $this->twig()->render('Default\404.twig'); $response = new Response($responseContent, 404); } else { $responseContent = $this->twig()->render('Default\500.twig', array('error' => $e->getMessage())); $response = new Response($responseContent, 500); } return $response; }
php
public function routeError(\Exception $e) { if ($e instanceof NotFoundHttpException) { $responseContent = $this->twig()->render('Default\404.twig'); $response = new Response($responseContent, 404); } else { $responseContent = $this->twig()->render('Default\500.twig', array('error' => $e->getMessage())); $response = new Response($responseContent, 500); } return $response; }
[ "public", "function", "routeError", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "$", "e", "instanceof", "NotFoundHttpException", ")", "{", "$", "responseContent", "=", "$", "this", "->", "twig", "(", ")", "->", "render", "(", "'Default\\404.twig'", ")", ";", "$", "response", "=", "new", "Response", "(", "$", "responseContent", ",", "404", ")", ";", "}", "else", "{", "$", "responseContent", "=", "$", "this", "->", "twig", "(", ")", "->", "render", "(", "'Default\\500.twig'", ",", "array", "(", "'error'", "=>", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "$", "response", "=", "new", "Response", "(", "$", "responseContent", ",", "500", ")", ";", "}", "return", "$", "response", ";", "}" ]
404 and 500 error page for non debug mode @param \Exception $e @return Response
[ "404", "and", "500", "error", "page", "for", "non", "debug", "mode" ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/BaseController.php#L34-L45
23,353
42mate/towel
src/Towel/Controller/BaseController.php
BaseController.setMessage
public function setMessage($type, $content) { $message = new \stdClass; $message->mt = $type; $message->content = $content; $messages = $this->session()->get('messages', array()); $messages[] = $message; $this->session()->set('messages', $messages); }
php
public function setMessage($type, $content) { $message = new \stdClass; $message->mt = $type; $message->content = $content; $messages = $this->session()->get('messages', array()); $messages[] = $message; $this->session()->set('messages', $messages); }
[ "public", "function", "setMessage", "(", "$", "type", ",", "$", "content", ")", "{", "$", "message", "=", "new", "\\", "stdClass", ";", "$", "message", "->", "mt", "=", "$", "type", ";", "$", "message", "->", "content", "=", "$", "content", ";", "$", "messages", "=", "$", "this", "->", "session", "(", ")", "->", "get", "(", "'messages'", ",", "array", "(", ")", ")", ";", "$", "messages", "[", "]", "=", "$", "message", ";", "$", "this", "->", "session", "(", ")", "->", "set", "(", "'messages'", ",", "$", "messages", ")", ";", "}" ]
Sets a user message to present after reload or redirect. @param $type @param $content
[ "Sets", "a", "user", "message", "to", "present", "after", "reload", "or", "redirect", "." ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/BaseController.php#L83-L91
23,354
42mate/towel
src/Towel/Controller/BaseController.php
BaseController.hasErrorMessages
public function hasErrorMessages() { $messages = $this->getMessages(); foreach ($messages as $message) { if ($message->mt == 'error') { return true; } } return false; }
php
public function hasErrorMessages() { $messages = $this->getMessages(); foreach ($messages as $message) { if ($message->mt == 'error') { return true; } } return false; }
[ "public", "function", "hasErrorMessages", "(", ")", "{", "$", "messages", "=", "$", "this", "->", "getMessages", "(", ")", ";", "foreach", "(", "$", "messages", "as", "$", "message", ")", "{", "if", "(", "$", "message", "->", "mt", "==", "'error'", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks into the message bag if there is some error message. Type == error
[ "Checks", "into", "the", "message", "bag", "if", "there", "is", "some", "error", "message", ".", "Type", "==", "error" ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/BaseController.php#L97-L105
23,355
42mate/towel
src/Towel/Controller/BaseController.php
BaseController.attachFiles
public function attachFiles($id, $table, $files) { foreach ($files as $file) { if (!empty($file)) { $this->attachFile($id, $table, $file); } } }
php
public function attachFiles($id, $table, $files) { foreach ($files as $file) { if (!empty($file)) { $this->attachFile($id, $table, $file); } } }
[ "public", "function", "attachFiles", "(", "$", "id", ",", "$", "table", ",", "$", "files", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "!", "empty", "(", "$", "file", ")", ")", "{", "$", "this", "->", "attachFile", "(", "$", "id", ",", "$", "table", ",", "$", "file", ")", ";", "}", "}", "}" ]
It will attach the array of files to the entity. @param $id @param $table @param $files
[ "It", "will", "attach", "the", "array", "of", "files", "to", "the", "entity", "." ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/BaseController.php#L124-L131
23,356
42mate/towel
src/Towel/Controller/BaseController.php
BaseController.attachFile
public function attachFile($id, $table, \Symfony\Component\HttpFoundation\File\UploadedFile $file) { $newFileName = md5(microtime() . '.' . strtolower($file->getClientOriginalExtension())); $relativePath = $table . '/' . date('Y/m/d'); $relativeFilePath = $relativePath . '/' . $newFileName; $dstPath = APP_UPLOADS_DIR . '/' . $relativePath; $file->move($dstPath, $newFileName); $pic = new \Towel\Model\Pic(); $pic->object_id = $id; $pic->object_type = $table; $pic->pic = $relativeFilePath; $pic->created = time(); $pic->save(); }
php
public function attachFile($id, $table, \Symfony\Component\HttpFoundation\File\UploadedFile $file) { $newFileName = md5(microtime() . '.' . strtolower($file->getClientOriginalExtension())); $relativePath = $table . '/' . date('Y/m/d'); $relativeFilePath = $relativePath . '/' . $newFileName; $dstPath = APP_UPLOADS_DIR . '/' . $relativePath; $file->move($dstPath, $newFileName); $pic = new \Towel\Model\Pic(); $pic->object_id = $id; $pic->object_type = $table; $pic->pic = $relativeFilePath; $pic->created = time(); $pic->save(); }
[ "public", "function", "attachFile", "(", "$", "id", ",", "$", "table", ",", "\\", "Symfony", "\\", "Component", "\\", "HttpFoundation", "\\", "File", "\\", "UploadedFile", "$", "file", ")", "{", "$", "newFileName", "=", "md5", "(", "microtime", "(", ")", ".", "'.'", ".", "strtolower", "(", "$", "file", "->", "getClientOriginalExtension", "(", ")", ")", ")", ";", "$", "relativePath", "=", "$", "table", ".", "'/'", ".", "date", "(", "'Y/m/d'", ")", ";", "$", "relativeFilePath", "=", "$", "relativePath", ".", "'/'", ".", "$", "newFileName", ";", "$", "dstPath", "=", "APP_UPLOADS_DIR", ".", "'/'", ".", "$", "relativePath", ";", "$", "file", "->", "move", "(", "$", "dstPath", ",", "$", "newFileName", ")", ";", "$", "pic", "=", "new", "\\", "Towel", "\\", "Model", "\\", "Pic", "(", ")", ";", "$", "pic", "->", "object_id", "=", "$", "id", ";", "$", "pic", "->", "object_type", "=", "$", "table", ";", "$", "pic", "->", "pic", "=", "$", "relativeFilePath", ";", "$", "pic", "->", "created", "=", "time", "(", ")", ";", "$", "pic", "->", "save", "(", ")", ";", "}" ]
It will attach the file. @param $id @param $table @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
[ "It", "will", "attach", "the", "file", "." ]
5316c3075fc844e8a5cbae113712b26556227dff
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/BaseController.php#L140-L154
23,357
dappur/dappurware
app/src/Dappurware/Cookies.php
Cookies.setResponseCookie
public function setResponseCookie($response, $name, $value = null, $expiration = 0) { $expiration = 1; if ($expiration == 0) { $expiration = 30; } if (is_numeric($expiration)) { $expiration = $expiration; } $response = FigResponseCookies::set( $response, SetCookie::create($name) ->withExpires(Carbon::parse()->timestamp + 60*60*24*$expiration) ->withValue($value) ); return $response; }
php
public function setResponseCookie($response, $name, $value = null, $expiration = 0) { $expiration = 1; if ($expiration == 0) { $expiration = 30; } if (is_numeric($expiration)) { $expiration = $expiration; } $response = FigResponseCookies::set( $response, SetCookie::create($name) ->withExpires(Carbon::parse()->timestamp + 60*60*24*$expiration) ->withValue($value) ); return $response; }
[ "public", "function", "setResponseCookie", "(", "$", "response", ",", "$", "name", ",", "$", "value", "=", "null", ",", "$", "expiration", "=", "0", ")", "{", "$", "expiration", "=", "1", ";", "if", "(", "$", "expiration", "==", "0", ")", "{", "$", "expiration", "=", "30", ";", "}", "if", "(", "is_numeric", "(", "$", "expiration", ")", ")", "{", "$", "expiration", "=", "$", "expiration", ";", "}", "$", "response", "=", "FigResponseCookies", "::", "set", "(", "$", "response", ",", "SetCookie", "::", "create", "(", "$", "name", ")", "->", "withExpires", "(", "Carbon", "::", "parse", "(", ")", "->", "timestamp", "+", "60", "*", "60", "*", "24", "*", "$", "expiration", ")", "->", "withValue", "(", "$", "value", ")", ")", ";", "return", "$", "response", ";", "}" ]
Set New Response Cookie
[ "Set", "New", "Response", "Cookie" ]
453ca999047693a1f009618820f8497a287f6a05
https://github.com/dappur/dappurware/blob/453ca999047693a1f009618820f8497a287f6a05/app/src/Dappurware/Cookies.php#L22-L40
23,358
dappur/dappurware
app/src/Dappurware/Cookies.php
Cookies.modifyResponseCookie
public function modifyResponseCookie($response, $name, $value = null, $expiration = 0) { $expiration = 1; if ($expiration == 0) { $expiration = 30; //Expire After 30 Days } if (is_numeric($expiration)) { $expiration = $expiration; } $modify = function (SetCookie $setCookie) { $value = $setCookie->getValue(); // ... inspect current $value and determine if $value should // change or if it can stay the same. in all cases, a cookie // should be returned from this callback... return $setCookie ->withValue($value) ->withExpires($expiration) ; }; $response = FigResponseCookies::modify($response, $name, $modify); return $response; }
php
public function modifyResponseCookie($response, $name, $value = null, $expiration = 0) { $expiration = 1; if ($expiration == 0) { $expiration = 30; //Expire After 30 Days } if (is_numeric($expiration)) { $expiration = $expiration; } $modify = function (SetCookie $setCookie) { $value = $setCookie->getValue(); // ... inspect current $value and determine if $value should // change or if it can stay the same. in all cases, a cookie // should be returned from this callback... return $setCookie ->withValue($value) ->withExpires($expiration) ; }; $response = FigResponseCookies::modify($response, $name, $modify); return $response; }
[ "public", "function", "modifyResponseCookie", "(", "$", "response", ",", "$", "name", ",", "$", "value", "=", "null", ",", "$", "expiration", "=", "0", ")", "{", "$", "expiration", "=", "1", ";", "if", "(", "$", "expiration", "==", "0", ")", "{", "$", "expiration", "=", "30", ";", "//Expire After 30 Days", "}", "if", "(", "is_numeric", "(", "$", "expiration", ")", ")", "{", "$", "expiration", "=", "$", "expiration", ";", "}", "$", "modify", "=", "function", "(", "SetCookie", "$", "setCookie", ")", "{", "$", "value", "=", "$", "setCookie", "->", "getValue", "(", ")", ";", "// ... inspect current $value and determine if $value should", "// change or if it can stay the same. in all cases, a cookie", "// should be returned from this callback...", "return", "$", "setCookie", "->", "withValue", "(", "$", "value", ")", "->", "withExpires", "(", "$", "expiration", ")", ";", "}", ";", "$", "response", "=", "FigResponseCookies", "::", "modify", "(", "$", "response", ",", "$", "name", ",", "$", "modify", ")", ";", "return", "$", "response", ";", "}" ]
Modify Response Cookie
[ "Modify", "Response", "Cookie" ]
453ca999047693a1f009618820f8497a287f6a05
https://github.com/dappur/dappurware/blob/453ca999047693a1f009618820f8497a287f6a05/app/src/Dappurware/Cookies.php#L43-L69
23,359
dappur/dappurware
app/src/Dappurware/Cookies.php
Cookies.setRequestCookie
public function setRequestCookie($request, $name, $value = null) { if (empty($name)) { return false; } $request = FigRequestCookies::set($request, Cookie::create($name, $value)); return $request; }
php
public function setRequestCookie($request, $name, $value = null) { if (empty($name)) { return false; } $request = FigRequestCookies::set($request, Cookie::create($name, $value)); return $request; }
[ "public", "function", "setRequestCookie", "(", "$", "request", ",", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "return", "false", ";", "}", "$", "request", "=", "FigRequestCookies", "::", "set", "(", "$", "request", ",", "Cookie", "::", "create", "(", "$", "name", ",", "$", "value", ")", ")", ";", "return", "$", "request", ";", "}" ]
Set New Request Cookie
[ "Set", "New", "Request", "Cookie" ]
453ca999047693a1f009618820f8497a287f6a05
https://github.com/dappur/dappurware/blob/453ca999047693a1f009618820f8497a287f6a05/app/src/Dappurware/Cookies.php#L86-L95
23,360
dappur/dappurware
app/src/Dappurware/Cookies.php
Cookies.modifyRequestCookie
public function modifyRequestCookie($request, $name, $value = null) { $modify = function (Cookie $cookie) { $value = $cookie->getValue(); return $cookie->withValue($value); }; $request = FigRequestCookies::modify($request, $name, $modify); return $request; }
php
public function modifyRequestCookie($request, $name, $value = null) { $modify = function (Cookie $cookie) { $value = $cookie->getValue(); return $cookie->withValue($value); }; $request = FigRequestCookies::modify($request, $name, $modify); return $request; }
[ "public", "function", "modifyRequestCookie", "(", "$", "request", ",", "$", "name", ",", "$", "value", "=", "null", ")", "{", "$", "modify", "=", "function", "(", "Cookie", "$", "cookie", ")", "{", "$", "value", "=", "$", "cookie", "->", "getValue", "(", ")", ";", "return", "$", "cookie", "->", "withValue", "(", "$", "value", ")", ";", "}", ";", "$", "request", "=", "FigRequestCookies", "::", "modify", "(", "$", "request", ",", "$", "name", ",", "$", "modify", ")", ";", "return", "$", "request", ";", "}" ]
Modify Request Cookie
[ "Modify", "Request", "Cookie" ]
453ca999047693a1f009618820f8497a287f6a05
https://github.com/dappur/dappurware/blob/453ca999047693a1f009618820f8497a287f6a05/app/src/Dappurware/Cookies.php#L98-L109
23,361
kecik-framework/kecik
Kecik/Request.php
UploadFile.move
public function move( $destination, $newName = '' ) { $source = $this->file['tmp_name']; if ( $destination != '' && substr( $destination, - 1 ) != '/' ) { $destination .= '/'; } if ( ! empty( $newName ) ) { $target = $destination . $newName; } else { $target = $destination . $this->file['name']; } if ( ! @move_uploaded_file( $source, $target ) ) { $error = error_get_last(); throw new FileException( sprintf( 'Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags( $error['message'] ) ) ); } @chmod( $target, 0666 & ~umask() ); return $target; }
php
public function move( $destination, $newName = '' ) { $source = $this->file['tmp_name']; if ( $destination != '' && substr( $destination, - 1 ) != '/' ) { $destination .= '/'; } if ( ! empty( $newName ) ) { $target = $destination . $newName; } else { $target = $destination . $this->file['name']; } if ( ! @move_uploaded_file( $source, $target ) ) { $error = error_get_last(); throw new FileException( sprintf( 'Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags( $error['message'] ) ) ); } @chmod( $target, 0666 & ~umask() ); return $target; }
[ "public", "function", "move", "(", "$", "destination", ",", "$", "newName", "=", "''", ")", "{", "$", "source", "=", "$", "this", "->", "file", "[", "'tmp_name'", "]", ";", "if", "(", "$", "destination", "!=", "''", "&&", "substr", "(", "$", "destination", ",", "-", "1", ")", "!=", "'/'", ")", "{", "$", "destination", ".=", "'/'", ";", "}", "if", "(", "!", "empty", "(", "$", "newName", ")", ")", "{", "$", "target", "=", "$", "destination", ".", "$", "newName", ";", "}", "else", "{", "$", "target", "=", "$", "destination", ".", "$", "this", "->", "file", "[", "'name'", "]", ";", "}", "if", "(", "!", "@", "move_uploaded_file", "(", "$", "source", ",", "$", "target", ")", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "throw", "new", "FileException", "(", "sprintf", "(", "'Could not move the file \"%s\" to \"%s\" (%s)'", ",", "$", "this", "->", "getPathname", "(", ")", ",", "$", "target", ",", "strip_tags", "(", "$", "error", "[", "'message'", "]", ")", ")", ")", ";", "}", "@", "chmod", "(", "$", "target", ",", "0666", "&", "~", "umask", "(", ")", ")", ";", "return", "$", "target", ";", "}" ]
Move file from temporary to actual location @param $destination @param string $newName @return string @throws FileException
[ "Move", "file", "from", "temporary", "to", "actual", "location" ]
fa87e593affe1c9c51a2acd264b85ec06df31d7c
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Request.php#L225-L255
23,362
heidelpay/PhpDoc
src/phpDocumentor/Transformer/Router/Rule.php
Rule.translateToUrlEncodedPath
protected function translateToUrlEncodedPath($generatedPathAsUtf8) { $iso88591Path = explode('/', $generatedPathAsUtf8); foreach ($iso88591Path as &$part) { // identify and skip schemes if (substr($part, -1) == ':') { continue; } // only encode and transliterate that which comes before the anchor $subparts = explode('#', $part); if (extension_loaded('iconv')) { $subparts[0] = iconv('UTF-8', 'ASCII//TRANSLIT', $subparts[0]); } $subparts[0] = urlencode($subparts[0]); $part = implode('#', $subparts); } return implode('/', $iso88591Path); }
php
protected function translateToUrlEncodedPath($generatedPathAsUtf8) { $iso88591Path = explode('/', $generatedPathAsUtf8); foreach ($iso88591Path as &$part) { // identify and skip schemes if (substr($part, -1) == ':') { continue; } // only encode and transliterate that which comes before the anchor $subparts = explode('#', $part); if (extension_loaded('iconv')) { $subparts[0] = iconv('UTF-8', 'ASCII//TRANSLIT', $subparts[0]); } $subparts[0] = urlencode($subparts[0]); $part = implode('#', $subparts); } return implode('/', $iso88591Path); }
[ "protected", "function", "translateToUrlEncodedPath", "(", "$", "generatedPathAsUtf8", ")", "{", "$", "iso88591Path", "=", "explode", "(", "'/'", ",", "$", "generatedPathAsUtf8", ")", ";", "foreach", "(", "$", "iso88591Path", "as", "&", "$", "part", ")", "{", "// identify and skip schemes", "if", "(", "substr", "(", "$", "part", ",", "-", "1", ")", "==", "':'", ")", "{", "continue", ";", "}", "// only encode and transliterate that which comes before the anchor", "$", "subparts", "=", "explode", "(", "'#'", ",", "$", "part", ")", ";", "if", "(", "extension_loaded", "(", "'iconv'", ")", ")", "{", "$", "subparts", "[", "0", "]", "=", "iconv", "(", "'UTF-8'", ",", "'ASCII//TRANSLIT'", ",", "$", "subparts", "[", "0", "]", ")", ";", "}", "$", "subparts", "[", "0", "]", "=", "urlencode", "(", "$", "subparts", "[", "0", "]", ")", ";", "$", "part", "=", "implode", "(", "'#'", ",", "$", "subparts", ")", ";", "}", "return", "implode", "(", "'/'", ",", "$", "iso88591Path", ")", ";", "}" ]
Translates the provided path, with UTF-8 characters, into a web- and windows-safe variant. Windows does not support the use of UTF-8 characters on their file-system. In order to be sure that both the web and windows can support the given filename we decode the UTF-8 characters and then url encode them so that they will be plain characters that are suitable for the web. If an anchor is found in the path, then it is neither url_encoded not transliterated because it should not result in a filename (otherwise another part of the application has made an error) but may be used during rendering of templates. @param string $generatedPathAsUtf8 @return string
[ "Translates", "the", "provided", "path", "with", "UTF", "-", "8", "characters", "into", "a", "web", "-", "and", "windows", "-", "safe", "variant", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Router/Rule.php#L88-L110
23,363
DevGroup-ru/yii2-measure
src/actions/UpdateAction.php
UpdateAction.run
public function run($id = null) { if ($id === null) { $model = new Measure; $model->loadDefaultValues(); } else { $model = $this->controller->findModel($id); } $isLoaded = $model->load(\Yii::$app->request->post()); $hasAccess = ($model->isNewRecord && \Yii::$app->user->can('measure-create-measure')) || (!$model->isNewRecord && \Yii::$app->user->can('measure-edit-measure')); if ($isLoaded && !$hasAccess) { throw new ForbiddenHttpException; } if ($isLoaded && $model->save()) { return $this->controller->redirect(['update', 'id' => $model->id]); } else { return $this->controller->render( 'update', [ 'hasAccess' => $hasAccess, 'model' => $model, ] ); } }
php
public function run($id = null) { if ($id === null) { $model = new Measure; $model->loadDefaultValues(); } else { $model = $this->controller->findModel($id); } $isLoaded = $model->load(\Yii::$app->request->post()); $hasAccess = ($model->isNewRecord && \Yii::$app->user->can('measure-create-measure')) || (!$model->isNewRecord && \Yii::$app->user->can('measure-edit-measure')); if ($isLoaded && !$hasAccess) { throw new ForbiddenHttpException; } if ($isLoaded && $model->save()) { return $this->controller->redirect(['update', 'id' => $model->id]); } else { return $this->controller->render( 'update', [ 'hasAccess' => $hasAccess, 'model' => $model, ] ); } }
[ "public", "function", "run", "(", "$", "id", "=", "null", ")", "{", "if", "(", "$", "id", "===", "null", ")", "{", "$", "model", "=", "new", "Measure", ";", "$", "model", "->", "loadDefaultValues", "(", ")", ";", "}", "else", "{", "$", "model", "=", "$", "this", "->", "controller", "->", "findModel", "(", "$", "id", ")", ";", "}", "$", "isLoaded", "=", "$", "model", "->", "load", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", ";", "$", "hasAccess", "=", "(", "$", "model", "->", "isNewRecord", "&&", "\\", "Yii", "::", "$", "app", "->", "user", "->", "can", "(", "'measure-create-measure'", ")", ")", "||", "(", "!", "$", "model", "->", "isNewRecord", "&&", "\\", "Yii", "::", "$", "app", "->", "user", "->", "can", "(", "'measure-edit-measure'", ")", ")", ";", "if", "(", "$", "isLoaded", "&&", "!", "$", "hasAccess", ")", "{", "throw", "new", "ForbiddenHttpException", ";", "}", "if", "(", "$", "isLoaded", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "return", "$", "this", "->", "controller", "->", "redirect", "(", "[", "'update'", ",", "'id'", "=>", "$", "model", "->", "id", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "controller", "->", "render", "(", "'update'", ",", "[", "'hasAccess'", "=>", "$", "hasAccess", ",", "'model'", "=>", "$", "model", ",", "]", ")", ";", "}", "}" ]
Updates an existing Measure model. If update is successful, the browser will be redirected to the 'view' page. @param integer $id @return mixed
[ "Updates", "an", "existing", "Measure", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/actions/UpdateAction.php#L22-L47
23,364
Laralum/Users
src/Models/User.php
User.avatar
public function avatar($size = 100) { /* if(File::exists(public_path('/avatars'.'/'.md5($this->email)))){ return asset('/avatars'.'/'.md5($this->email)); } return "https://tracker.moodle.org/secure/attachment/30912/f3.png"; */ // Get gavatar avatar if (Utilities::validGravatar($this->email)) { return Utilities::gavatar($this->email); } $color = Packages::installed('customization') ? \Laralum\Customization\Models\Customization::first()->navbar_color : '#1e87f0'; return MaterialFunctions::materialAvatar($this->name, $size, $color); }
php
public function avatar($size = 100) { /* if(File::exists(public_path('/avatars'.'/'.md5($this->email)))){ return asset('/avatars'.'/'.md5($this->email)); } return "https://tracker.moodle.org/secure/attachment/30912/f3.png"; */ // Get gavatar avatar if (Utilities::validGravatar($this->email)) { return Utilities::gavatar($this->email); } $color = Packages::installed('customization') ? \Laralum\Customization\Models\Customization::first()->navbar_color : '#1e87f0'; return MaterialFunctions::materialAvatar($this->name, $size, $color); }
[ "public", "function", "avatar", "(", "$", "size", "=", "100", ")", "{", "/*\n if(File::exists(public_path('/avatars'.'/'.md5($this->email)))){\n return asset('/avatars'.'/'.md5($this->email));\n }\n return \"https://tracker.moodle.org/secure/attachment/30912/f3.png\";\n */", "// Get gavatar avatar", "if", "(", "Utilities", "::", "validGravatar", "(", "$", "this", "->", "email", ")", ")", "{", "return", "Utilities", "::", "gavatar", "(", "$", "this", "->", "email", ")", ";", "}", "$", "color", "=", "Packages", "::", "installed", "(", "'customization'", ")", "?", "\\", "Laralum", "\\", "Customization", "\\", "Models", "\\", "Customization", "::", "first", "(", ")", "->", "navbar_color", ":", "'#1e87f0'", ";", "return", "MaterialFunctions", "::", "materialAvatar", "(", "$", "this", "->", "name", ",", "$", "size", ",", "$", "color", ")", ";", "}" ]
Returns the user avatar.
[ "Returns", "the", "user", "avatar", "." ]
788851d4cdf4bff548936faf1b12cf4697d13428
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Models/User.php#L47-L63
23,365
vuer/token
src/Traits/Tokenable.php
Tokenable.getLastToken
public function getLastToken($type, $key = 'type') { return $this->token()->orderBy('tokens.created_at', 'desc')->where($key, $type)->first(); }
php
public function getLastToken($type, $key = 'type') { return $this->token()->orderBy('tokens.created_at', 'desc')->where($key, $type)->first(); }
[ "public", "function", "getLastToken", "(", "$", "type", ",", "$", "key", "=", "'type'", ")", "{", "return", "$", "this", "->", "token", "(", ")", "->", "orderBy", "(", "'tokens.created_at'", ",", "'desc'", ")", "->", "where", "(", "$", "key", ",", "$", "type", ")", "->", "first", "(", ")", ";", "}" ]
Get the last Token by the type. @param string $type @param string $key @return Token
[ "Get", "the", "last", "Token", "by", "the", "type", "." ]
096ba1820c850d5e29062a304bdc399789388714
https://github.com/vuer/token/blob/096ba1820c850d5e29062a304bdc399789388714/src/Traits/Tokenable.php#L55-L58
23,366
vuer/token
src/Traits/Tokenable.php
Tokenable.checkToken
public function checkToken($token) { return (bool) $this->token()->where('token', $token)->where('expiration_date', '>', Carbon::now())->count(); }
php
public function checkToken($token) { return (bool) $this->token()->where('token', $token)->where('expiration_date', '>', Carbon::now())->count(); }
[ "public", "function", "checkToken", "(", "$", "token", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "token", "(", ")", "->", "where", "(", "'token'", ",", "$", "token", ")", "->", "where", "(", "'expiration_date'", ",", "'>'", ",", "Carbon", "::", "now", "(", ")", ")", "->", "count", "(", ")", ";", "}" ]
Check the token. @param string $token @return boolean
[ "Check", "the", "token", "." ]
096ba1820c850d5e29062a304bdc399789388714
https://github.com/vuer/token/blob/096ba1820c850d5e29062a304bdc399789388714/src/Traits/Tokenable.php#L76-L79
23,367
vuer/token
src/Traits/Tokenable.php
Tokenable.createToken
public function createToken($type, $expire = 60, $length = 48, $customProperties = null) { return $this->token()->create([ 'token' => $this->generateTokenString($length), 'expiration_date' => Carbon::now()->addMinutes($expire), 'type' => $type, 'custom_properties' => $customProperties, ]); }
php
public function createToken($type, $expire = 60, $length = 48, $customProperties = null) { return $this->token()->create([ 'token' => $this->generateTokenString($length), 'expiration_date' => Carbon::now()->addMinutes($expire), 'type' => $type, 'custom_properties' => $customProperties, ]); }
[ "public", "function", "createToken", "(", "$", "type", ",", "$", "expire", "=", "60", ",", "$", "length", "=", "48", ",", "$", "customProperties", "=", "null", ")", "{", "return", "$", "this", "->", "token", "(", ")", "->", "create", "(", "[", "'token'", "=>", "$", "this", "->", "generateTokenString", "(", "$", "length", ")", ",", "'expiration_date'", "=>", "Carbon", "::", "now", "(", ")", "->", "addMinutes", "(", "$", "expire", ")", ",", "'type'", "=>", "$", "type", ",", "'custom_properties'", "=>", "$", "customProperties", ",", "]", ")", ";", "}" ]
Create new token and return the instance. @param string $type token type @param integer $expire expire in minutes @param integer $length key length @return Token
[ "Create", "new", "token", "and", "return", "the", "instance", "." ]
096ba1820c850d5e29062a304bdc399789388714
https://github.com/vuer/token/blob/096ba1820c850d5e29062a304bdc399789388714/src/Traits/Tokenable.php#L99-L107
23,368
ouropencode/dachi
src/Router.php
Router.route
public static function route() { if(defined('DACHI_CLI')) return false; $uri = Request::getFullUri(); $route = self::findRoute($uri); self::performRoute($route); return Template::render(); }
php
public static function route() { if(defined('DACHI_CLI')) return false; $uri = Request::getFullUri(); $route = self::findRoute($uri); self::performRoute($route); return Template::render(); }
[ "public", "static", "function", "route", "(", ")", "{", "if", "(", "defined", "(", "'DACHI_CLI'", ")", ")", "return", "false", ";", "$", "uri", "=", "Request", "::", "getFullUri", "(", ")", ";", "$", "route", "=", "self", "::", "findRoute", "(", "$", "uri", ")", ";", "self", "::", "performRoute", "(", "$", "route", ")", ";", "return", "Template", "::", "render", "(", ")", ";", "}" ]
Performs routing based upon the loaded routing information and the incoming request @return null
[ "Performs", "routing", "based", "upon", "the", "loaded", "routing", "information", "and", "the", "incoming", "request" ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Router.php#L28-L37
23,369
ouropencode/dachi
src/Router.php
Router.findRoute
public static function findRoute($uri) { if(self::$routes === array()) self::load(); $count = count($uri); $position = &self::$routes; for($i = 0; $i < $count; $i++) { if($i == $count - 1) { if(isset($position[$uri[$i]]) && isset($position[$uri[$i]]["route"])) { return $position[$uri[$i]]["route"]; } else if(isset($position["*"]) && isset($position["*"]["route"])) { return $position["*"]["route"]; } else { throw new ValidRouteNotFoundException; } } else { if(isset($position[$uri[$i]])) { $position = &$position[$uri[$i]]["children"]; } elseif(isset($position["*"])) { $position = &$position["*"]["children"]; } else { throw new ValidRouteNotFoundException; } } } throw new ValidRouteNotFoundException; }
php
public static function findRoute($uri) { if(self::$routes === array()) self::load(); $count = count($uri); $position = &self::$routes; for($i = 0; $i < $count; $i++) { if($i == $count - 1) { if(isset($position[$uri[$i]]) && isset($position[$uri[$i]]["route"])) { return $position[$uri[$i]]["route"]; } else if(isset($position["*"]) && isset($position["*"]["route"])) { return $position["*"]["route"]; } else { throw new ValidRouteNotFoundException; } } else { if(isset($position[$uri[$i]])) { $position = &$position[$uri[$i]]["children"]; } elseif(isset($position["*"])) { $position = &$position["*"]["children"]; } else { throw new ValidRouteNotFoundException; } } } throw new ValidRouteNotFoundException; }
[ "public", "static", "function", "findRoute", "(", "$", "uri", ")", "{", "if", "(", "self", "::", "$", "routes", "===", "array", "(", ")", ")", "self", "::", "load", "(", ")", ";", "$", "count", "=", "count", "(", "$", "uri", ")", ";", "$", "position", "=", "&", "self", "::", "$", "routes", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "if", "(", "$", "i", "==", "$", "count", "-", "1", ")", "{", "if", "(", "isset", "(", "$", "position", "[", "$", "uri", "[", "$", "i", "]", "]", ")", "&&", "isset", "(", "$", "position", "[", "$", "uri", "[", "$", "i", "]", "]", "[", "\"route\"", "]", ")", ")", "{", "return", "$", "position", "[", "$", "uri", "[", "$", "i", "]", "]", "[", "\"route\"", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "position", "[", "\"*\"", "]", ")", "&&", "isset", "(", "$", "position", "[", "\"*\"", "]", "[", "\"route\"", "]", ")", ")", "{", "return", "$", "position", "[", "\"*\"", "]", "[", "\"route\"", "]", ";", "}", "else", "{", "throw", "new", "ValidRouteNotFoundException", ";", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "position", "[", "$", "uri", "[", "$", "i", "]", "]", ")", ")", "{", "$", "position", "=", "&", "$", "position", "[", "$", "uri", "[", "$", "i", "]", "]", "[", "\"children\"", "]", ";", "}", "elseif", "(", "isset", "(", "$", "position", "[", "\"*\"", "]", ")", ")", "{", "$", "position", "=", "&", "$", "position", "[", "\"*\"", "]", "[", "\"children\"", "]", ";", "}", "else", "{", "throw", "new", "ValidRouteNotFoundException", ";", "}", "}", "}", "throw", "new", "ValidRouteNotFoundException", ";", "}" ]
Find and process a valid route from the uri @internal @param array $uri Array of uri parts (split by /) @throws ValidRouteNotFoundException @return array
[ "Find", "and", "process", "a", "valid", "route", "from", "the", "uri" ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Router.php#L46-L74
23,370
ouropencode/dachi
src/Router.php
Router.performRoute
public static function performRoute($route) { $api_mode = isset($route["api-mode"]); Request::setRequestVariables($route["variables"], $api_mode); $controller = new $route["class"]; $response = $controller->$route["method"](); if(!Request::isAjax() && !Request::isAPI() && isset($route["render-path"])) { Request::setRenderPath($route["render-path"]); try { $route = self::findRoute(explode('/', $route["render-path"])); } catch(ValidRouteNotFoundException $e) { throw new ValidRenderRouteNotFoundException($e); } $response = self::performRoute($route); } return $response; }
php
public static function performRoute($route) { $api_mode = isset($route["api-mode"]); Request::setRequestVariables($route["variables"], $api_mode); $controller = new $route["class"]; $response = $controller->$route["method"](); if(!Request::isAjax() && !Request::isAPI() && isset($route["render-path"])) { Request::setRenderPath($route["render-path"]); try { $route = self::findRoute(explode('/', $route["render-path"])); } catch(ValidRouteNotFoundException $e) { throw new ValidRenderRouteNotFoundException($e); } $response = self::performRoute($route); } return $response; }
[ "public", "static", "function", "performRoute", "(", "$", "route", ")", "{", "$", "api_mode", "=", "isset", "(", "$", "route", "[", "\"api-mode\"", "]", ")", ";", "Request", "::", "setRequestVariables", "(", "$", "route", "[", "\"variables\"", "]", ",", "$", "api_mode", ")", ";", "$", "controller", "=", "new", "$", "route", "[", "\"class\"", "]", ";", "$", "response", "=", "$", "controller", "->", "$", "route", "[", "\"method\"", "]", "(", ")", ";", "if", "(", "!", "Request", "::", "isAjax", "(", ")", "&&", "!", "Request", "::", "isAPI", "(", ")", "&&", "isset", "(", "$", "route", "[", "\"render-path\"", "]", ")", ")", "{", "Request", "::", "setRenderPath", "(", "$", "route", "[", "\"render-path\"", "]", ")", ";", "try", "{", "$", "route", "=", "self", "::", "findRoute", "(", "explode", "(", "'/'", ",", "$", "route", "[", "\"render-path\"", "]", ")", ")", ";", "}", "catch", "(", "ValidRouteNotFoundException", "$", "e", ")", "{", "throw", "new", "ValidRenderRouteNotFoundException", "(", "$", "e", ")", ";", "}", "$", "response", "=", "self", "::", "performRoute", "(", "$", "route", ")", ";", "}", "return", "$", "response", ";", "}" ]
Perform routing based upon the discovered route @internal @param array $route Format: array(class, method, uri_variables) @see Request::setRequestVariables() @return mixed Return value of last route to be executed
[ "Perform", "routing", "based", "upon", "the", "discovered", "route" ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Router.php#L83-L101
23,371
digipolisgent/robo-digipolis-general
src/Common/DigipolisPropertiesAware.php
DigipolisPropertiesAware.readProperties
public function readProperties($root = null, $web = null, $vendor = null) { if (!$this->propertiesRead) { if (is_null($root)) { if (is_callable([$this, 'taskDetermineProjectRoot'])) { $this->taskDetermineProjectRoot()->run(); } $root = $this->getConfig()->get('digipolis.root.project', getcwd()); } if (is_null($web)) { if (is_callable([$this, 'taskDetermineWebRoot'])) { $this->taskDetermineWebRoot()->run(); } $web = $this->getConfig()->get('digipolis.root.web', $root); } if (is_null($vendor)) { $vendor = $root . '/vendor'; } $this->taskReadProperties([$web, $vendor])->run(); $this->propertiesRead = true; } }
php
public function readProperties($root = null, $web = null, $vendor = null) { if (!$this->propertiesRead) { if (is_null($root)) { if (is_callable([$this, 'taskDetermineProjectRoot'])) { $this->taskDetermineProjectRoot()->run(); } $root = $this->getConfig()->get('digipolis.root.project', getcwd()); } if (is_null($web)) { if (is_callable([$this, 'taskDetermineWebRoot'])) { $this->taskDetermineWebRoot()->run(); } $web = $this->getConfig()->get('digipolis.root.web', $root); } if (is_null($vendor)) { $vendor = $root . '/vendor'; } $this->taskReadProperties([$web, $vendor])->run(); $this->propertiesRead = true; } }
[ "public", "function", "readProperties", "(", "$", "root", "=", "null", ",", "$", "web", "=", "null", ",", "$", "vendor", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "propertiesRead", ")", "{", "if", "(", "is_null", "(", "$", "root", ")", ")", "{", "if", "(", "is_callable", "(", "[", "$", "this", ",", "'taskDetermineProjectRoot'", "]", ")", ")", "{", "$", "this", "->", "taskDetermineProjectRoot", "(", ")", "->", "run", "(", ")", ";", "}", "$", "root", "=", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'digipolis.root.project'", ",", "getcwd", "(", ")", ")", ";", "}", "if", "(", "is_null", "(", "$", "web", ")", ")", "{", "if", "(", "is_callable", "(", "[", "$", "this", ",", "'taskDetermineWebRoot'", "]", ")", ")", "{", "$", "this", "->", "taskDetermineWebRoot", "(", ")", "->", "run", "(", ")", ";", "}", "$", "web", "=", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'digipolis.root.web'", ",", "$", "root", ")", ";", "}", "if", "(", "is_null", "(", "$", "vendor", ")", ")", "{", "$", "vendor", "=", "$", "root", ".", "'/vendor'", ";", "}", "$", "this", "->", "taskReadProperties", "(", "[", "$", "web", ",", "$", "vendor", "]", ")", "->", "run", "(", ")", ";", "$", "this", "->", "propertiesRead", "=", "true", ";", "}", "}" ]
Read the properties from the YAML files. Determine project and web root if needed. @param string|null $root The path to the project root, if null the project root will be determined by taskDetermineProjectRoot(). @param string|null $web The path to the project web root, if null the web root will be determined by taskDetermineWebRoot(). @param string|null $vendor The path to the vendor dir, if null defaults to $root/vendor.
[ "Read", "the", "properties", "from", "the", "YAML", "files", ".", "Determine", "project", "and", "web", "root", "if", "needed", "." ]
66f0806c9ed7bd4e5aaf3f57ae1363f6aaae7cd9
https://github.com/digipolisgent/robo-digipolis-general/blob/66f0806c9ed7bd4e5aaf3f57ae1363f6aaae7cd9/src/Common/DigipolisPropertiesAware.php#L27-L48
23,372
netzmacht/contao-leaflet-geocode-widget
src/EventListener/RadiusWizardCallbackListener.php
RadiusWizardCallbackListener.generateWizard
public function generateWizard($dataContainer) { if (!isset($GLOBALS['TL_DCA'][$dataContainer->table]['fields'][$dataContainer->field]['eval']['coordinates'])) { return ''; } return sprintf( '<a href="#" onclick="$(\'ctrl_%s_toggle\').click();return false;"><img src="%s"></a>', $GLOBALS['TL_DCA'][$dataContainer->table]['fields'][$dataContainer->field]['eval']['coordinates'], 'bundles/leafletgeocodewidget/img/map.png' ); }
php
public function generateWizard($dataContainer) { if (!isset($GLOBALS['TL_DCA'][$dataContainer->table]['fields'][$dataContainer->field]['eval']['coordinates'])) { return ''; } return sprintf( '<a href="#" onclick="$(\'ctrl_%s_toggle\').click();return false;"><img src="%s"></a>', $GLOBALS['TL_DCA'][$dataContainer->table]['fields'][$dataContainer->field]['eval']['coordinates'], 'bundles/leafletgeocodewidget/img/map.png' ); }
[ "public", "function", "generateWizard", "(", "$", "dataContainer", ")", "{", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "dataContainer", "->", "table", "]", "[", "'fields'", "]", "[", "$", "dataContainer", "->", "field", "]", "[", "'eval'", "]", "[", "'coordinates'", "]", ")", ")", "{", "return", "''", ";", "}", "return", "sprintf", "(", "'<a href=\"#\" onclick=\"$(\\'ctrl_%s_toggle\\').click();return false;\"><img src=\"%s\"></a>'", ",", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "dataContainer", "->", "table", "]", "[", "'fields'", "]", "[", "$", "dataContainer", "->", "field", "]", "[", "'eval'", "]", "[", "'coordinates'", "]", ",", "'bundles/leafletgeocodewidget/img/map.png'", ")", ";", "}" ]
Generate the wizard for the radius widget. @param DataContainer $dataContainer Data container driver. @return string @SuppressWarnings(PHPMD.Superglobals)
[ "Generate", "the", "wizard", "for", "the", "radius", "widget", "." ]
08acfbc473696f385d7c6aed6148e51c91443e12
https://github.com/netzmacht/contao-leaflet-geocode-widget/blob/08acfbc473696f385d7c6aed6148e51c91443e12/src/EventListener/RadiusWizardCallbackListener.php#L33-L44
23,373
wenbinye/PhalconX
src/Helper/ArrayHelper.php
ArrayHelper.pull
public static function pull($arr, $name, $type = null) { $ret = []; if ($type == self::GETTER) { $method = 'get' . $name; foreach ($arr as $elem) { $ret[] = $elem->$method(); } } elseif ($type == self::OBJ) { foreach ($arr as $elem) { $ret[] = $elem->$name; } } else { foreach ($arr as $elem) { $ret[] = $elem[$name]; } } return $ret; }
php
public static function pull($arr, $name, $type = null) { $ret = []; if ($type == self::GETTER) { $method = 'get' . $name; foreach ($arr as $elem) { $ret[] = $elem->$method(); } } elseif ($type == self::OBJ) { foreach ($arr as $elem) { $ret[] = $elem->$name; } } else { foreach ($arr as $elem) { $ret[] = $elem[$name]; } } return $ret; }
[ "public", "static", "function", "pull", "(", "$", "arr", ",", "$", "name", ",", "$", "type", "=", "null", ")", "{", "$", "ret", "=", "[", "]", ";", "if", "(", "$", "type", "==", "self", "::", "GETTER", ")", "{", "$", "method", "=", "'get'", ".", "$", "name", ";", "foreach", "(", "$", "arr", "as", "$", "elem", ")", "{", "$", "ret", "[", "]", "=", "$", "elem", "->", "$", "method", "(", ")", ";", "}", "}", "elseif", "(", "$", "type", "==", "self", "::", "OBJ", ")", "{", "foreach", "(", "$", "arr", "as", "$", "elem", ")", "{", "$", "ret", "[", "]", "=", "$", "elem", "->", "$", "name", ";", "}", "}", "else", "{", "foreach", "(", "$", "arr", "as", "$", "elem", ")", "{", "$", "ret", "[", "]", "=", "$", "elem", "[", "$", "name", "]", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Collects value from array @param array $array @param string $name @param string $type @return array
[ "Collects", "value", "from", "array" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/ArrayHelper.php#L37-L55
23,374
wenbinye/PhalconX
src/Helper/ArrayHelper.php
ArrayHelper.assoc
public static function assoc($arr, $name, $type = null) { $ret = []; if (empty($arr)) { return $ret; } if ($type == self::GETTER) { $method = 'get' . $name; foreach ($arr as $elem) { $ret[$elem->$method()] = $elem; } } elseif ($type == self::OBJ) { foreach ($arr as $elem) { $ret[$elem->$name] = $elem; } } else { foreach ($arr as $elem) { $ret[$elem[$name]] = $elem; } } return $ret; }
php
public static function assoc($arr, $name, $type = null) { $ret = []; if (empty($arr)) { return $ret; } if ($type == self::GETTER) { $method = 'get' . $name; foreach ($arr as $elem) { $ret[$elem->$method()] = $elem; } } elseif ($type == self::OBJ) { foreach ($arr as $elem) { $ret[$elem->$name] = $elem; } } else { foreach ($arr as $elem) { $ret[$elem[$name]] = $elem; } } return $ret; }
[ "public", "static", "function", "assoc", "(", "$", "arr", ",", "$", "name", ",", "$", "type", "=", "null", ")", "{", "$", "ret", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "arr", ")", ")", "{", "return", "$", "ret", ";", "}", "if", "(", "$", "type", "==", "self", "::", "GETTER", ")", "{", "$", "method", "=", "'get'", ".", "$", "name", ";", "foreach", "(", "$", "arr", "as", "$", "elem", ")", "{", "$", "ret", "[", "$", "elem", "->", "$", "method", "(", ")", "]", "=", "$", "elem", ";", "}", "}", "elseif", "(", "$", "type", "==", "self", "::", "OBJ", ")", "{", "foreach", "(", "$", "arr", "as", "$", "elem", ")", "{", "$", "ret", "[", "$", "elem", "->", "$", "name", "]", "=", "$", "elem", ";", "}", "}", "else", "{", "foreach", "(", "$", "arr", "as", "$", "elem", ")", "{", "$", "ret", "[", "$", "elem", "[", "$", "name", "]", "]", "=", "$", "elem", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Creates associated array @param array $array @param string $name @param string $type @return array
[ "Creates", "associated", "array" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/ArrayHelper.php#L65-L86
23,375
wenbinye/PhalconX
src/Helper/ArrayHelper.php
ArrayHelper.select
public static function select($arr, $includedKeys) { $ret = []; foreach ($includedKeys as $key) { if (array_key_exists($key, $arr)) { $ret[$key] = $arr[$key]; } } return $ret; }
php
public static function select($arr, $includedKeys) { $ret = []; foreach ($includedKeys as $key) { if (array_key_exists($key, $arr)) { $ret[$key] = $arr[$key]; } } return $ret; }
[ "public", "static", "function", "select", "(", "$", "arr", ",", "$", "includedKeys", ")", "{", "$", "ret", "=", "[", "]", ";", "foreach", "(", "$", "includedKeys", "as", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "arr", ")", ")", "{", "$", "ret", "[", "$", "key", "]", "=", "$", "arr", "[", "$", "key", "]", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Create array with given keys @param array $array @param array $includedKeys @return array
[ "Create", "array", "with", "given", "keys" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/ArrayHelper.php#L107-L116
23,376
i-lateral/silverstripe-deferedimages
src/DeferedImageExtension.php
DeferedImage.MicroImage
public function MicroImage() { $pixel = $this->config()->pixelate; $blur = $this->config()->blur; $quality = $this->config()->quality; $scale = $this->config()->scale; $variant = $this->owner->variantName(__FUNCTION__, $pixel, $blur, $quality, $scale); return $this->owner->manipulateImage( $variant, function (Image_Backend $backend) use ($pixel, $blur, $quality, $scale) { $clone = clone $backend; $resource = clone $backend->getImageResource(); $resource->pixelate($pixel)->blur($blur)->encode('jpg', $quality); if ($scale != 100) { $width = $backend->getWidth() * ($scale/100); $height = $backend->getHeight() * ($scale/100); $resource->resize($width, $height); } $clone->setImageResource($resource); return $clone; } ); }
php
public function MicroImage() { $pixel = $this->config()->pixelate; $blur = $this->config()->blur; $quality = $this->config()->quality; $scale = $this->config()->scale; $variant = $this->owner->variantName(__FUNCTION__, $pixel, $blur, $quality, $scale); return $this->owner->manipulateImage( $variant, function (Image_Backend $backend) use ($pixel, $blur, $quality, $scale) { $clone = clone $backend; $resource = clone $backend->getImageResource(); $resource->pixelate($pixel)->blur($blur)->encode('jpg', $quality); if ($scale != 100) { $width = $backend->getWidth() * ($scale/100); $height = $backend->getHeight() * ($scale/100); $resource->resize($width, $height); } $clone->setImageResource($resource); return $clone; } ); }
[ "public", "function", "MicroImage", "(", ")", "{", "$", "pixel", "=", "$", "this", "->", "config", "(", ")", "->", "pixelate", ";", "$", "blur", "=", "$", "this", "->", "config", "(", ")", "->", "blur", ";", "$", "quality", "=", "$", "this", "->", "config", "(", ")", "->", "quality", ";", "$", "scale", "=", "$", "this", "->", "config", "(", ")", "->", "scale", ";", "$", "variant", "=", "$", "this", "->", "owner", "->", "variantName", "(", "__FUNCTION__", ",", "$", "pixel", ",", "$", "blur", ",", "$", "quality", ",", "$", "scale", ")", ";", "return", "$", "this", "->", "owner", "->", "manipulateImage", "(", "$", "variant", ",", "function", "(", "Image_Backend", "$", "backend", ")", "use", "(", "$", "pixel", ",", "$", "blur", ",", "$", "quality", ",", "$", "scale", ")", "{", "$", "clone", "=", "clone", "$", "backend", ";", "$", "resource", "=", "clone", "$", "backend", "->", "getImageResource", "(", ")", ";", "$", "resource", "->", "pixelate", "(", "$", "pixel", ")", "->", "blur", "(", "$", "blur", ")", "->", "encode", "(", "'jpg'", ",", "$", "quality", ")", ";", "if", "(", "$", "scale", "!=", "100", ")", "{", "$", "width", "=", "$", "backend", "->", "getWidth", "(", ")", "*", "(", "$", "scale", "/", "100", ")", ";", "$", "height", "=", "$", "backend", "->", "getHeight", "(", ")", "*", "(", "$", "scale", "/", "100", ")", ";", "$", "resource", "->", "resize", "(", "$", "width", ",", "$", "height", ")", ";", "}", "$", "clone", "->", "setImageResource", "(", "$", "resource", ")", ";", "return", "$", "clone", ";", "}", ")", ";", "}" ]
Generates a reduced quality version of the current image @config @return void
[ "Generates", "a", "reduced", "quality", "version", "of", "the", "current", "image" ]
6095e2404bbc5e33a8d996909f34111d4f751026
https://github.com/i-lateral/silverstripe-deferedimages/blob/6095e2404bbc5e33a8d996909f34111d4f751026/src/DeferedImageExtension.php#L50-L73
23,377
zicht/z
src/Zicht/Tool/Container/Traverser.php
Traverser.addVisitor
public function addVisitor($callable, $condition, $when = self::BEFORE) { $this->visitors[] = array($when, $condition, $callable); return $this; }
php
public function addVisitor($callable, $condition, $when = self::BEFORE) { $this->visitors[] = array($when, $condition, $callable); return $this; }
[ "public", "function", "addVisitor", "(", "$", "callable", ",", "$", "condition", ",", "$", "when", "=", "self", "::", "BEFORE", ")", "{", "$", "this", "->", "visitors", "[", "]", "=", "array", "(", "$", "when", ",", "$", "condition", ",", "$", "callable", ")", ";", "return", "$", "this", ";", "}" ]
Add a visitor to the traverser. The node being visited is passed to the second callback to determine whether the first callback should be called with the node. The arguments passed to both callbacks are the current node and the path to the node. The result of the first callback is used to replace the node in the tree. Example: <code> $traverser->addVisitor( function($path, $node) { $node['i was visited'] = true; return $node; }, function($path, $node) { return count($path) == 3 && $path[0] == 'foo' && $path[2] == 'bar'; } ); $traverser->traverse( array( 'foo' => array( array( 'bar' => array('i should be visited' => true), 'baz' => array('i should not be visited' => true) ) ) ) ); </code> @param callable $callable @param callable $condition @param int $when @return self
[ "Add", "a", "visitor", "to", "the", "traverser", ".", "The", "node", "being", "visited", "is", "passed", "to", "the", "second", "callback", "to", "determine", "whether", "the", "first", "callback", "should", "be", "called", "with", "the", "node", ".", "The", "arguments", "passed", "to", "both", "callbacks", "are", "the", "current", "node", "and", "the", "path", "to", "the", "node", ".", "The", "result", "of", "the", "first", "callback", "is", "used", "to", "replace", "the", "node", "in", "the", "tree", "." ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Traverser.php#L86-L91
23,378
zicht/z
src/Zicht/Tool/Container/Traverser.php
Traverser.doTraverse
private function doTraverse($node, $path = array()) { foreach ($node as $name => $value) { $path[] = $name; $value = $this->doVisit($path, $value, self::BEFORE); if (is_array($value)) { $value = $this->doTraverse($value, $path); } $value = $this->doVisit($path, $value, self::AFTER); $node[$name] = $value; array_pop($path); } return $node; }
php
private function doTraverse($node, $path = array()) { foreach ($node as $name => $value) { $path[] = $name; $value = $this->doVisit($path, $value, self::BEFORE); if (is_array($value)) { $value = $this->doTraverse($value, $path); } $value = $this->doVisit($path, $value, self::AFTER); $node[$name] = $value; array_pop($path); } return $node; }
[ "private", "function", "doTraverse", "(", "$", "node", ",", "$", "path", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "node", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "path", "[", "]", "=", "$", "name", ";", "$", "value", "=", "$", "this", "->", "doVisit", "(", "$", "path", ",", "$", "value", ",", "self", "::", "BEFORE", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "doTraverse", "(", "$", "value", ",", "$", "path", ")", ";", "}", "$", "value", "=", "$", "this", "->", "doVisit", "(", "$", "path", ",", "$", "value", ",", "self", "::", "AFTER", ")", ";", "$", "node", "[", "$", "name", "]", "=", "$", "value", ";", "array_pop", "(", "$", "path", ")", ";", "}", "return", "$", "node", ";", "}" ]
Recursive traversal implementation @param mixed $node @param array $path @return mixed
[ "Recursive", "traversal", "implementation" ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Traverser.php#L112-L128
23,379
zicht/z
src/Zicht/Tool/Container/Traverser.php
Traverser.doVisit
private function doVisit($path, $value, $when) { foreach ($this->visitors as $visitor) { if ($visitor[0] === $when && call_user_func($visitor[1], $path, $value)) { try { $value = call_user_func($visitor[2], $path, $value); } catch (\Exception $e) { if ($path) { $path = join('.', $path); } $path = json_encode($path); $value = json_encode($value); throw new \RuntimeException("While visiting value '{$value}' at path {$path}", 0, $e); } } } return $value; }
php
private function doVisit($path, $value, $when) { foreach ($this->visitors as $visitor) { if ($visitor[0] === $when && call_user_func($visitor[1], $path, $value)) { try { $value = call_user_func($visitor[2], $path, $value); } catch (\Exception $e) { if ($path) { $path = join('.', $path); } $path = json_encode($path); $value = json_encode($value); throw new \RuntimeException("While visiting value '{$value}' at path {$path}", 0, $e); } } } return $value; }
[ "private", "function", "doVisit", "(", "$", "path", ",", "$", "value", ",", "$", "when", ")", "{", "foreach", "(", "$", "this", "->", "visitors", "as", "$", "visitor", ")", "{", "if", "(", "$", "visitor", "[", "0", "]", "===", "$", "when", "&&", "call_user_func", "(", "$", "visitor", "[", "1", "]", ",", "$", "path", ",", "$", "value", ")", ")", "{", "try", "{", "$", "value", "=", "call_user_func", "(", "$", "visitor", "[", "2", "]", ",", "$", "path", ",", "$", "value", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "$", "path", ")", "{", "$", "path", "=", "join", "(", "'.'", ",", "$", "path", ")", ";", "}", "$", "path", "=", "json_encode", "(", "$", "path", ")", ";", "$", "value", "=", "json_encode", "(", "$", "value", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "\"While visiting value '{$value}' at path {$path}\"", ",", "0", ",", "$", "e", ")", ";", "}", "}", "}", "return", "$", "value", ";", "}" ]
Visits the node with all visitors at the specified time. @param array $path @param mixed $value @param int $when @return mixed @throws \RuntimeException
[ "Visits", "the", "node", "with", "all", "visitors", "at", "the", "specified", "time", "." ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Traverser.php#L141-L158
23,380
hametuha/wpametu
src/WPametu/API/Ajax/AjaxPostSearch.php
AjaxPostSearch.get_data
protected function get_data() { $post_type = $this->input->get('post_type'); if( !post_type_exists($post_type) ){ $this->error(sprintf($this->__('Post type %s does not exist.'), $post_type), 404); } if( !current_user_can('edit_posts') ){ $this->error($this->__('Sorry, but you have no permission.'), 403); } $paged = max(intval($this->input->get('paged')), 1) - 1; $args = [ 'post_type' => $post_type, 'suppress_filters' => false, 'orderby' => 'title', 'order' => 'ASC', 'offset' => $paged * get_option('posts_per_page'), 's' => $this->input->get('s'), ]; if( $this->is_public_search ){ // This is public search. $args = array_merge($args, [ 'post_status' => ['publish'] ]); }else{ // This is private search. $args = array_merge($args, [ 'post_status' => ['publish', 'draft', 'future'], ]); if( !current_user_can('edit_others_posts') ){ $args['author'] = get_current_user_id(); } } $data = []; foreach( get_posts($args) as $post){ $data[] = [ 'id' => $post->ID, 'name' => get_the_title($post), ]; } return $data; }
php
protected function get_data() { $post_type = $this->input->get('post_type'); if( !post_type_exists($post_type) ){ $this->error(sprintf($this->__('Post type %s does not exist.'), $post_type), 404); } if( !current_user_can('edit_posts') ){ $this->error($this->__('Sorry, but you have no permission.'), 403); } $paged = max(intval($this->input->get('paged')), 1) - 1; $args = [ 'post_type' => $post_type, 'suppress_filters' => false, 'orderby' => 'title', 'order' => 'ASC', 'offset' => $paged * get_option('posts_per_page'), 's' => $this->input->get('s'), ]; if( $this->is_public_search ){ // This is public search. $args = array_merge($args, [ 'post_status' => ['publish'] ]); }else{ // This is private search. $args = array_merge($args, [ 'post_status' => ['publish', 'draft', 'future'], ]); if( !current_user_can('edit_others_posts') ){ $args['author'] = get_current_user_id(); } } $data = []; foreach( get_posts($args) as $post){ $data[] = [ 'id' => $post->ID, 'name' => get_the_title($post), ]; } return $data; }
[ "protected", "function", "get_data", "(", ")", "{", "$", "post_type", "=", "$", "this", "->", "input", "->", "get", "(", "'post_type'", ")", ";", "if", "(", "!", "post_type_exists", "(", "$", "post_type", ")", ")", "{", "$", "this", "->", "error", "(", "sprintf", "(", "$", "this", "->", "__", "(", "'Post type %s does not exist.'", ")", ",", "$", "post_type", ")", ",", "404", ")", ";", "}", "if", "(", "!", "current_user_can", "(", "'edit_posts'", ")", ")", "{", "$", "this", "->", "error", "(", "$", "this", "->", "__", "(", "'Sorry, but you have no permission.'", ")", ",", "403", ")", ";", "}", "$", "paged", "=", "max", "(", "intval", "(", "$", "this", "->", "input", "->", "get", "(", "'paged'", ")", ")", ",", "1", ")", "-", "1", ";", "$", "args", "=", "[", "'post_type'", "=>", "$", "post_type", ",", "'suppress_filters'", "=>", "false", ",", "'orderby'", "=>", "'title'", ",", "'order'", "=>", "'ASC'", ",", "'offset'", "=>", "$", "paged", "*", "get_option", "(", "'posts_per_page'", ")", ",", "'s'", "=>", "$", "this", "->", "input", "->", "get", "(", "'s'", ")", ",", "]", ";", "if", "(", "$", "this", "->", "is_public_search", ")", "{", "// This is public search.", "$", "args", "=", "array_merge", "(", "$", "args", ",", "[", "'post_status'", "=>", "[", "'publish'", "]", "]", ")", ";", "}", "else", "{", "// This is private search.", "$", "args", "=", "array_merge", "(", "$", "args", ",", "[", "'post_status'", "=>", "[", "'publish'", ",", "'draft'", ",", "'future'", "]", ",", "]", ")", ";", "if", "(", "!", "current_user_can", "(", "'edit_others_posts'", ")", ")", "{", "$", "args", "[", "'author'", "]", "=", "get_current_user_id", "(", ")", ";", "}", "}", "$", "data", "=", "[", "]", ";", "foreach", "(", "get_posts", "(", "$", "args", ")", "as", "$", "post", ")", "{", "$", "data", "[", "]", "=", "[", "'id'", "=>", "$", "post", "->", "ID", ",", "'name'", "=>", "get_the_title", "(", "$", "post", ")", ",", "]", ";", "}", "return", "$", "data", ";", "}" ]
Returns data as array. @return array
[ "Returns", "data", "as", "array", "." ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Ajax/AjaxPostSearch.php#L29-L69
23,381
WellCommerce/AppBundle
Form/DataTransformer/MediaEntityToIdentifierTransformer.php
MediaEntityToIdentifierTransformer.reverseTransform
public function reverseTransform($modelData, PropertyPathInterface $propertyPath, $value) { $unmodified = intval($value['unmodified']); if ($unmodified === 1) { return; } $item = null; if (isset($value[0])) { $id = $value[0]; $item = $this->getRepository()->find($id); } $this->propertyAccessor->setValue($modelData, $propertyPath, $item); }
php
public function reverseTransform($modelData, PropertyPathInterface $propertyPath, $value) { $unmodified = intval($value['unmodified']); if ($unmodified === 1) { return; } $item = null; if (isset($value[0])) { $id = $value[0]; $item = $this->getRepository()->find($id); } $this->propertyAccessor->setValue($modelData, $propertyPath, $item); }
[ "public", "function", "reverseTransform", "(", "$", "modelData", ",", "PropertyPathInterface", "$", "propertyPath", ",", "$", "value", ")", "{", "$", "unmodified", "=", "intval", "(", "$", "value", "[", "'unmodified'", "]", ")", ";", "if", "(", "$", "unmodified", "===", "1", ")", "{", "return", ";", "}", "$", "item", "=", "null", ";", "if", "(", "isset", "(", "$", "value", "[", "0", "]", ")", ")", "{", "$", "id", "=", "$", "value", "[", "0", "]", ";", "$", "item", "=", "$", "this", "->", "getRepository", "(", ")", "->", "find", "(", "$", "id", ")", ";", "}", "$", "this", "->", "propertyAccessor", "->", "setValue", "(", "$", "modelData", ",", "$", "propertyPath", ",", "$", "item", ")", ";", "}" ]
Transforms identifier to entity @param object $modelData @param PropertyPathInterface $propertyPath @param mixed $value
[ "Transforms", "identifier", "to", "entity" ]
2add687d1c898dd0b24afd611d896e3811a0eac3
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Form/DataTransformer/MediaEntityToIdentifierTransformer.php#L32-L46
23,382
traderinteractive/filter-dates-php
src/Filter/DateTime.php
DateTime.filter
public static function filter($value, bool $allowNull = false, DateTimeZoneStandard $timezone = null) { if (self::valueIsNullAndValid($allowNull, $value)) { return null; } if ($value instanceof DateTimeStandard) { return $value; } if (is_int($value) || ctype_digit($value)) { $value = "@{$value}"; } if (!is_string($value) || trim($value) == '') { throw new FilterException('$value is not a non-empty string'); } return new DateTimeStandard($value, $timezone); }
php
public static function filter($value, bool $allowNull = false, DateTimeZoneStandard $timezone = null) { if (self::valueIsNullAndValid($allowNull, $value)) { return null; } if ($value instanceof DateTimeStandard) { return $value; } if (is_int($value) || ctype_digit($value)) { $value = "@{$value}"; } if (!is_string($value) || trim($value) == '') { throw new FilterException('$value is not a non-empty string'); } return new DateTimeStandard($value, $timezone); }
[ "public", "static", "function", "filter", "(", "$", "value", ",", "bool", "$", "allowNull", "=", "false", ",", "DateTimeZoneStandard", "$", "timezone", "=", "null", ")", "{", "if", "(", "self", "::", "valueIsNullAndValid", "(", "$", "allowNull", ",", "$", "value", ")", ")", "{", "return", "null", ";", "}", "if", "(", "$", "value", "instanceof", "DateTimeStandard", ")", "{", "return", "$", "value", ";", "}", "if", "(", "is_int", "(", "$", "value", ")", "||", "ctype_digit", "(", "$", "value", ")", ")", "{", "$", "value", "=", "\"@{$value}\"", ";", "}", "if", "(", "!", "is_string", "(", "$", "value", ")", "||", "trim", "(", "$", "value", ")", "==", "''", ")", "{", "throw", "new", "FilterException", "(", "'$value is not a non-empty string'", ")", ";", "}", "return", "new", "DateTimeStandard", "(", "$", "value", ",", "$", "timezone", ")", ";", "}" ]
Filters the given value into a \DateTime object. @param mixed $value The value to be filtered. @param boolean $allowNull True to allow nulls through, and false (default) if nulls should not be allowed. @param DateTimeZoneStandard $timezone A \DateTimeZone object representing the timezone of $value. If $timezone is omitted, the current timezone will be used. @return DateTimeStandard|null @throws FilterException if the value did not pass validation.
[ "Filters", "the", "given", "value", "into", "a", "\\", "DateTime", "object", "." ]
f9e60f139da3ebb565317c5d62a6fb0c347be4ee
https://github.com/traderinteractive/filter-dates-php/blob/f9e60f139da3ebb565317c5d62a6fb0c347be4ee/src/Filter/DateTime.php#L28-L47
23,383
traderinteractive/filter-dates-php
src/Filter/DateTime.php
DateTime.format
public static function format(DateTimeInterface $dateTime, string $format = 'c') : string { if (empty(trim($format))) { throw new \InvalidArgumentException('$format is not a non-empty string'); } return $dateTime->format($format); }
php
public static function format(DateTimeInterface $dateTime, string $format = 'c') : string { if (empty(trim($format))) { throw new \InvalidArgumentException('$format is not a non-empty string'); } return $dateTime->format($format); }
[ "public", "static", "function", "format", "(", "DateTimeInterface", "$", "dateTime", ",", "string", "$", "format", "=", "'c'", ")", ":", "string", "{", "if", "(", "empty", "(", "trim", "(", "$", "format", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$format is not a non-empty string'", ")", ";", "}", "return", "$", "dateTime", "->", "format", "(", "$", "format", ")", ";", "}" ]
Filters the give \DateTime object to a formatted string. @param DateTimeInterface $dateTime The date to be formatted. @param string $format The format of the outputted date string. @return string @throws \InvalidArgumentException Thrown if $format is not a string
[ "Filters", "the", "give", "\\", "DateTime", "object", "to", "a", "formatted", "string", "." ]
f9e60f139da3ebb565317c5d62a6fb0c347be4ee
https://github.com/traderinteractive/filter-dates-php/blob/f9e60f139da3ebb565317c5d62a6fb0c347be4ee/src/Filter/DateTime.php#L59-L66
23,384
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.disconnect
public function disconnect() { if ( $this->state !== self::STATE_NOT_CONNECTED && $this->connection->isConnected() === true ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} LOGOUT" ); // discard the "bye bye" message ("{$tag} OK Logout completed.") $this->getResponse( $tag ); $this->state = self::STATE_LOGOUT; $this->selectedMailbox = null; $this->connection->close(); $this->connection = null; $this->state = self::STATE_NOT_CONNECTED; } }
php
public function disconnect() { if ( $this->state !== self::STATE_NOT_CONNECTED && $this->connection->isConnected() === true ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} LOGOUT" ); // discard the "bye bye" message ("{$tag} OK Logout completed.") $this->getResponse( $tag ); $this->state = self::STATE_LOGOUT; $this->selectedMailbox = null; $this->connection->close(); $this->connection = null; $this->state = self::STATE_NOT_CONNECTED; } }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!==", "self", "::", "STATE_NOT_CONNECTED", "&&", "$", "this", "->", "connection", "->", "isConnected", "(", ")", "===", "true", ")", "{", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} LOGOUT\"", ")", ";", "// discard the \"bye bye\" message (\"{$tag} OK Logout completed.\")", "$", "this", "->", "getResponse", "(", "$", "tag", ")", ";", "$", "this", "->", "state", "=", "self", "::", "STATE_LOGOUT", ";", "$", "this", "->", "selectedMailbox", "=", "null", ";", "$", "this", "->", "connection", "->", "close", "(", ")", ";", "$", "this", "->", "connection", "=", "null", ";", "$", "this", "->", "state", "=", "self", "::", "STATE_NOT_CONNECTED", ";", "}", "}" ]
Disconnects the transport from the IMAP server.
[ "Disconnects", "the", "transport", "from", "the", "IMAP", "server", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L478-L494
23,385
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.listMailboxes
public function listMailboxes( $reference = '', $mailbox = '*' ) { if ( $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call listMailboxes() when not successfully logged in." ); } $result = array(); $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} LIST \"{$reference}\" \"{$mailbox}\"" ); $response = trim( $this->connection->getLine() ); while ( strpos( $response, '* LIST (' ) !== false ) { // only consider the selectable mailboxes if ( strpos( $response, "\\Noselect" ) === false ) { $response = substr( $response, strpos( $response, "\" " ) + 2 ); $response = trim( $response ); $response = trim( $response, "\"" ); $result[] = $response; } $response = $this->connection->getLine(); } $response = $this->getResponse( $tag, $response ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "Could not list mailboxes with the parameters '\"{$reference}\"' and '\"{$mailbox}\"': {$response}." ); } return $result; }
php
public function listMailboxes( $reference = '', $mailbox = '*' ) { if ( $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call listMailboxes() when not successfully logged in." ); } $result = array(); $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} LIST \"{$reference}\" \"{$mailbox}\"" ); $response = trim( $this->connection->getLine() ); while ( strpos( $response, '* LIST (' ) !== false ) { // only consider the selectable mailboxes if ( strpos( $response, "\\Noselect" ) === false ) { $response = substr( $response, strpos( $response, "\" " ) + 2 ); $response = trim( $response ); $response = trim( $response, "\"" ); $result[] = $response; } $response = $this->connection->getLine(); } $response = $this->getResponse( $tag, $response ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "Could not list mailboxes with the parameters '\"{$reference}\"' and '\"{$mailbox}\"': {$response}." ); } return $result; }
[ "public", "function", "listMailboxes", "(", "$", "reference", "=", "''", ",", "$", "mailbox", "=", "'*'", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_AUTHENTICATED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call listMailboxes() when not successfully logged in.\"", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} LIST \\\"{$reference}\\\" \\\"{$mailbox}\\\"\"", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "connection", "->", "getLine", "(", ")", ")", ";", "while", "(", "strpos", "(", "$", "response", ",", "'* LIST ('", ")", "!==", "false", ")", "{", "// only consider the selectable mailboxes", "if", "(", "strpos", "(", "$", "response", ",", "\"\\\\Noselect\"", ")", "===", "false", ")", "{", "$", "response", "=", "substr", "(", "$", "response", ",", "strpos", "(", "$", "response", ",", "\"\\\" \"", ")", "+", "2", ")", ";", "$", "response", "=", "trim", "(", "$", "response", ")", ";", "$", "response", "=", "trim", "(", "$", "response", ",", "\"\\\"\"", ")", ";", "$", "result", "[", "]", "=", "$", "response", ";", "}", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "}", "$", "response", "=", "$", "this", "->", "getResponse", "(", "$", "tag", ",", "$", "response", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Could not list mailboxes with the parameters '\\\"{$reference}\\\"' and '\\\"{$mailbox}\\\"': {$response}.\"", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns an array with the names of the available mailboxes for the user currently authenticated on the IMAP server. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully. For more information about $reference and $mailbox, consult the IMAP RFCs documents ({@link http://www.faqs.org/rfcs/rfc1730.html} or {@link http://www.faqs.org/rfcs/rfc2060.html}, section 7.2.2.). By default, $reference is "" and $mailbox is "*". The array returned contains the mailboxes available for the connected user on this IMAP server. Inbox is a special mailbox, and it can be specified upper-case or lower-case or mixed-case. The other mailboxes should be specified as they are (to the {@link selectMailbox()} method). Example of listing mailboxes: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $mailboxes = $imap->listMailboxes(); </code> @throws ezcMailMailTransportException if the current server state is not accepted or if the server sent a negative response @param string $reference @param string $mailbox @return array(string)
[ "Returns", "an", "array", "with", "the", "names", "of", "the", "available", "mailboxes", "for", "the", "user", "currently", "authenticated", "on", "the", "IMAP", "server", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L593-L626
23,386
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.getHierarchyDelimiter
public function getHierarchyDelimiter() { if ( $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call getDelimiter() when not successfully logged in." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} LIST \"\" \"\"" ); // there should be only one * LIST response line from IMAP $response = trim( $this->getResponse( '* LIST' ) ); $parts = explode( '"', $response ); if ( count( $parts ) >= 2 ) { $result = $parts[1]; } else { throw new ezcMailTransportException( "Could not retrieve the hierarchy delimiter: {$response}." ); } $response = $this->getResponse( $tag, $response ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "Could not retrieve the hierarchy delimiter: {$response}." ); } return $result; }
php
public function getHierarchyDelimiter() { if ( $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call getDelimiter() when not successfully logged in." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} LIST \"\" \"\"" ); // there should be only one * LIST response line from IMAP $response = trim( $this->getResponse( '* LIST' ) ); $parts = explode( '"', $response ); if ( count( $parts ) >= 2 ) { $result = $parts[1]; } else { throw new ezcMailTransportException( "Could not retrieve the hierarchy delimiter: {$response}." ); } $response = $this->getResponse( $tag, $response ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "Could not retrieve the hierarchy delimiter: {$response}." ); } return $result; }
[ "public", "function", "getHierarchyDelimiter", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_AUTHENTICATED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call getDelimiter() when not successfully logged in.\"", ")", ";", "}", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} LIST \\\"\\\" \\\"\\\"\"", ")", ";", "// there should be only one * LIST response line from IMAP", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "'* LIST'", ")", ")", ";", "$", "parts", "=", "explode", "(", "'\"'", ",", "$", "response", ")", ";", "if", "(", "count", "(", "$", "parts", ")", ">=", "2", ")", "{", "$", "result", "=", "$", "parts", "[", "1", "]", ";", "}", "else", "{", "throw", "new", "ezcMailTransportException", "(", "\"Could not retrieve the hierarchy delimiter: {$response}.\"", ")", ";", "}", "$", "response", "=", "$", "this", "->", "getResponse", "(", "$", "tag", ",", "$", "response", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Could not retrieve the hierarchy delimiter: {$response}.\"", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the hierarchy delimiter of the IMAP server, useful for handling nested IMAP folders. For more information about the hierarchy delimiter, consult the IMAP RFCs {@link http://www.faqs.org/rfcs/rfc1730.html} or {@link http://www.faqs.org/rfcs/rfc2060.html}, section 6.3.8. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully. Example of returning the hierarchy delimiter: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $delimiter = $imap->getDelimiter(); </code> After running the above code, $delimiter should be something like "/". @throws ezcMailMailTransportException if the current server state is not accepted or if the server sent a negative response @return string
[ "Returns", "the", "hierarchy", "delimiter", "of", "the", "IMAP", "server", "useful", "for", "handling", "nested", "IMAP", "folders", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L654-L685
23,387
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.listMessages
public function listMessages( $contentType = null ) { if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call listMessages() on the IMAP transport when a mailbox is not selected." ); } $messageList = array(); $messages = array(); // get the numbers of the existing messages $tag = $this->getNextTag(); $command = "{$tag} SEARCH UNDELETED"; if ( !is_null( $contentType ) ) { $command .= " HEADER \"Content-Type\" \"{$contentType}\""; } $this->connection->sendData( $command ); $response = trim( $this->getResponse( '* SEARCH' ) ); if ( strpos( $response, '* SEARCH' ) !== false ) { $ids = trim( substr( $response, 9 ) ); if ( $ids !== "" ) { $messageList = explode( ' ', $ids ); } } // skip the OK response ("{$tag} OK Search completed.") $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not list messages: {$response}." ); } if ( !empty( $messageList ) ) { // get the sizes of the messages $tag = $this->getNextTag(); $query = trim( implode( ',', $messageList ) ); $this->connection->sendData( "{$tag} FETCH {$query} RFC822.SIZE" ); $response = $this->getResponse( 'FETCH (' ); $currentMessage = trim( reset( $messageList ) ); while ( strpos( $response, 'FETCH (' ) !== false ) { $line = $response; $line = explode( ' ', $line ); $line = trim( $line[count( $line ) - 1] ); $line = substr( $line, 0, strlen( $line ) - 1 ); $messages[$currentMessage] = intval( $line ); $currentMessage = next( $messageList ); $response = $this->connection->getLine(); } // skip the OK response ("{$tag} OK Fetch completed.") $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not list messages: {$response}." ); } } return $messages; }
php
public function listMessages( $contentType = null ) { if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call listMessages() on the IMAP transport when a mailbox is not selected." ); } $messageList = array(); $messages = array(); // get the numbers of the existing messages $tag = $this->getNextTag(); $command = "{$tag} SEARCH UNDELETED"; if ( !is_null( $contentType ) ) { $command .= " HEADER \"Content-Type\" \"{$contentType}\""; } $this->connection->sendData( $command ); $response = trim( $this->getResponse( '* SEARCH' ) ); if ( strpos( $response, '* SEARCH' ) !== false ) { $ids = trim( substr( $response, 9 ) ); if ( $ids !== "" ) { $messageList = explode( ' ', $ids ); } } // skip the OK response ("{$tag} OK Search completed.") $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not list messages: {$response}." ); } if ( !empty( $messageList ) ) { // get the sizes of the messages $tag = $this->getNextTag(); $query = trim( implode( ',', $messageList ) ); $this->connection->sendData( "{$tag} FETCH {$query} RFC822.SIZE" ); $response = $this->getResponse( 'FETCH (' ); $currentMessage = trim( reset( $messageList ) ); while ( strpos( $response, 'FETCH (' ) !== false ) { $line = $response; $line = explode( ' ', $line ); $line = trim( $line[count( $line ) - 1] ); $line = substr( $line, 0, strlen( $line ) - 1 ); $messages[$currentMessage] = intval( $line ); $currentMessage = next( $messageList ); $response = $this->connection->getLine(); } // skip the OK response ("{$tag} OK Fetch completed.") $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not list messages: {$response}." ); } } return $messages; }
[ "public", "function", "listMessages", "(", "$", "contentType", "=", "null", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call listMessages() on the IMAP transport when a mailbox is not selected.\"", ")", ";", "}", "$", "messageList", "=", "array", "(", ")", ";", "$", "messages", "=", "array", "(", ")", ";", "// get the numbers of the existing messages", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "command", "=", "\"{$tag} SEARCH UNDELETED\"", ";", "if", "(", "!", "is_null", "(", "$", "contentType", ")", ")", "{", "$", "command", ".=", "\" HEADER \\\"Content-Type\\\" \\\"{$contentType}\\\"\"", ";", "}", "$", "this", "->", "connection", "->", "sendData", "(", "$", "command", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "'* SEARCH'", ")", ")", ";", "if", "(", "strpos", "(", "$", "response", ",", "'* SEARCH'", ")", "!==", "false", ")", "{", "$", "ids", "=", "trim", "(", "substr", "(", "$", "response", ",", "9", ")", ")", ";", "if", "(", "$", "ids", "!==", "\"\"", ")", "{", "$", "messageList", "=", "explode", "(", "' '", ",", "$", "ids", ")", ";", "}", "}", "// skip the OK response (\"{$tag} OK Search completed.\")", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ",", "$", "response", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not list messages: {$response}.\"", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "messageList", ")", ")", "{", "// get the sizes of the messages", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "query", "=", "trim", "(", "implode", "(", "','", ",", "$", "messageList", ")", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} FETCH {$query} RFC822.SIZE\"", ")", ";", "$", "response", "=", "$", "this", "->", "getResponse", "(", "'FETCH ('", ")", ";", "$", "currentMessage", "=", "trim", "(", "reset", "(", "$", "messageList", ")", ")", ";", "while", "(", "strpos", "(", "$", "response", ",", "'FETCH ('", ")", "!==", "false", ")", "{", "$", "line", "=", "$", "response", ";", "$", "line", "=", "explode", "(", "' '", ",", "$", "line", ")", ";", "$", "line", "=", "trim", "(", "$", "line", "[", "count", "(", "$", "line", ")", "-", "1", "]", ")", ";", "$", "line", "=", "substr", "(", "$", "line", ",", "0", ",", "strlen", "(", "$", "line", ")", "-", "1", ")", ";", "$", "messages", "[", "$", "currentMessage", "]", "=", "intval", "(", "$", "line", ")", ";", "$", "currentMessage", "=", "next", "(", "$", "messageList", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "}", "// skip the OK response (\"{$tag} OK Fetch completed.\")", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ",", "$", "response", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not list messages: {$response}.\"", ")", ";", "}", "}", "return", "$", "messages", ";", "}" ]
Returns a list of the not deleted messages in the current mailbox. It returns only the messages with the flag DELETED not set. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. The format of the returned array is <code> array( message_id => size ); </code> Example: <code> array( 2 => 1700, 5 => 1450, 6 => 21043 ); </code> If $contentType is set, it returns only the messages with $contentType in the Content-Type header. For example $contentType can be "multipart/mixed" to return only the messages with attachments. @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response @param string $contentType @return array(int)
[ "Returns", "a", "list", "of", "the", "not", "deleted", "messages", "in", "the", "current", "mailbox", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L958-L1019
23,388
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.status
public function status( &$numMessages, &$sizeMessages, &$recent = 0, &$unseen = 0 ) { if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call status() on the IMAP transport when a mailbox is not selected." ); } $messages = $this->listMessages(); $numMessages = count( $messages ); $sizeMessages = array_sum( $messages ); $messages = array_keys( $messages ); $recentMessages = array_intersect( $this->searchByFlag( "RECENT" ), $messages ); $unseenMessages = array_intersect( $this->searchByFlag( "UNSEEN" ), $messages ); $recent = count( $recentMessages ); $unseen = count( $unseenMessages ); return true; }
php
public function status( &$numMessages, &$sizeMessages, &$recent = 0, &$unseen = 0 ) { if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call status() on the IMAP transport when a mailbox is not selected." ); } $messages = $this->listMessages(); $numMessages = count( $messages ); $sizeMessages = array_sum( $messages ); $messages = array_keys( $messages ); $recentMessages = array_intersect( $this->searchByFlag( "RECENT" ), $messages ); $unseenMessages = array_intersect( $this->searchByFlag( "UNSEEN" ), $messages ); $recent = count( $recentMessages ); $unseen = count( $unseenMessages ); return true; }
[ "public", "function", "status", "(", "&", "$", "numMessages", ",", "&", "$", "sizeMessages", ",", "&", "$", "recent", "=", "0", ",", "&", "$", "unseen", "=", "0", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call status() on the IMAP transport when a mailbox is not selected.\"", ")", ";", "}", "$", "messages", "=", "$", "this", "->", "listMessages", "(", ")", ";", "$", "numMessages", "=", "count", "(", "$", "messages", ")", ";", "$", "sizeMessages", "=", "array_sum", "(", "$", "messages", ")", ";", "$", "messages", "=", "array_keys", "(", "$", "messages", ")", ";", "$", "recentMessages", "=", "array_intersect", "(", "$", "this", "->", "searchByFlag", "(", "\"RECENT\"", ")", ",", "$", "messages", ")", ";", "$", "unseenMessages", "=", "array_intersect", "(", "$", "this", "->", "searchByFlag", "(", "\"UNSEEN\"", ")", ",", "$", "messages", ")", ";", "$", "recent", "=", "count", "(", "$", "recentMessages", ")", ";", "$", "unseen", "=", "count", "(", "$", "unseenMessages", ")", ";", "return", "true", ";", "}" ]
Returns information about the messages in the current mailbox. The information returned through the parameters is: - $numMessages = number of not deleted messages in the selected mailbox - $sizeMessages = sum of the not deleted messages sizes - $recent = number of recent and not deleted messages - $unseen = number of unseen and not deleted messages Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. Example of returning the status of the currently selected mailbox: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'Inbox' ); $imap->status( $numMessages, $sizeMessages, $recent, $unseen ); </code> After running the above code, $numMessages, $sizeMessages, $recent and $unseen will be populated with values. @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response @param int &$numMessages @param int &$sizeMessages @param int &$recent @param int &$unseen @return bool
[ "Returns", "information", "about", "the", "messages", "in", "the", "current", "mailbox", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1142-L1158
23,389
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.listUniqueIdentifiers
public function listUniqueIdentifiers( $msgNum = null ) { if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call listUniqueIdentifiers() on the IMAP transport when a mailbox is not selected." ); } $result = array(); if ( $msgNum !== null ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} UID SEARCH {$msgNum}" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $result[(int)$msgNum] = trim( substr( $response, 9 ) ); } $response = trim( $this->getResponse( $tag, $response ) ); } else { $uids = array(); $messages = array_keys( $this->listMessages() ); $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} UID SEARCH UNDELETED" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $response = trim( substr( $response, 9 ) ); if ( $response !== "" ) { $uids = explode( ' ', $response ); } for ( $i = 0; $i < count( $messages ); $i++ ) { $result[trim( $messages[$i] )] = $uids[$i]; } } $response = trim( $this->getResponse( $tag ) ); } if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not fetch the unique identifiers: {$response}." ); } return $result; }
php
public function listUniqueIdentifiers( $msgNum = null ) { if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call listUniqueIdentifiers() on the IMAP transport when a mailbox is not selected." ); } $result = array(); if ( $msgNum !== null ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} UID SEARCH {$msgNum}" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $result[(int)$msgNum] = trim( substr( $response, 9 ) ); } $response = trim( $this->getResponse( $tag, $response ) ); } else { $uids = array(); $messages = array_keys( $this->listMessages() ); $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} UID SEARCH UNDELETED" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $response = trim( substr( $response, 9 ) ); if ( $response !== "" ) { $uids = explode( ' ', $response ); } for ( $i = 0; $i < count( $messages ); $i++ ) { $result[trim( $messages[$i] )] = $uids[$i]; } } $response = trim( $this->getResponse( $tag ) ); } if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not fetch the unique identifiers: {$response}." ); } return $result; }
[ "public", "function", "listUniqueIdentifiers", "(", "$", "msgNum", "=", "null", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call listUniqueIdentifiers() on the IMAP transport when a mailbox is not selected.\"", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "if", "(", "$", "msgNum", "!==", "null", ")", "{", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} UID SEARCH {$msgNum}\"", ")", ";", "$", "response", "=", "$", "this", "->", "getResponse", "(", "'* SEARCH'", ")", ";", "if", "(", "strpos", "(", "$", "response", ",", "'* SEARCH'", ")", "!==", "false", ")", "{", "$", "result", "[", "(", "int", ")", "$", "msgNum", "]", "=", "trim", "(", "substr", "(", "$", "response", ",", "9", ")", ")", ";", "}", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ",", "$", "response", ")", ")", ";", "}", "else", "{", "$", "uids", "=", "array", "(", ")", ";", "$", "messages", "=", "array_keys", "(", "$", "this", "->", "listMessages", "(", ")", ")", ";", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} UID SEARCH UNDELETED\"", ")", ";", "$", "response", "=", "$", "this", "->", "getResponse", "(", "'* SEARCH'", ")", ";", "if", "(", "strpos", "(", "$", "response", ",", "'* SEARCH'", ")", "!==", "false", ")", "{", "$", "response", "=", "trim", "(", "substr", "(", "$", "response", ",", "9", ")", ")", ";", "if", "(", "$", "response", "!==", "\"\"", ")", "{", "$", "uids", "=", "explode", "(", "' '", ",", "$", "response", ")", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "messages", ")", ";", "$", "i", "++", ")", "{", "$", "result", "[", "trim", "(", "$", "messages", "[", "$", "i", "]", ")", "]", "=", "$", "uids", "[", "$", "i", "]", ";", "}", "}", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ")", ")", ";", "}", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not fetch the unique identifiers: {$response}.\"", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the unique identifiers for the messages from the current mailbox. You can fetch the unique identifier for a specific message by providing the $msgNum parameter. The unique identifier can be used to recognize mail from servers between requests. In contrast to the message numbers the unique numbers assigned to an email usually never changes. The format of the returned array is: <code> array( message_num => unique_id ); </code> Example: <code> array( 1 => 216, 2 => 217, 3 => 218, 4 => 219 ); </code> Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. @todo add UIVALIDITY value to UID (like in POP3) (if necessary). @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response @param int $msgNum @return array(string)
[ "Returns", "the", "unique", "identifiers", "for", "the", "messages", "from", "the", "current", "mailbox", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1389-L1435
23,390
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.countByFlag
public function countByFlag( $flag ) { $flag = $this->normalizeFlag( $flag ); $messages = $this->searchByFlag( $flag ); return count( $messages ); }
php
public function countByFlag( $flag ) { $flag = $this->normalizeFlag( $flag ); $messages = $this->searchByFlag( $flag ); return count( $messages ); }
[ "public", "function", "countByFlag", "(", "$", "flag", ")", "{", "$", "flag", "=", "$", "this", "->", "normalizeFlag", "(", "$", "flag", ")", ";", "$", "messages", "=", "$", "this", "->", "searchByFlag", "(", "$", "flag", ")", ";", "return", "count", "(", "$", "messages", ")", ";", "}" ]
Wrapper function to fetch count of messages by a certain flag. $flag can be one of: Basic flags: - ANSWERED - message has been answered - DELETED - message is marked to be deleted by later EXPUNGE - DRAFT - message is marked as a draft - FLAGGED - message is "flagged" for urgent/special attention - RECENT - message is recent - SEEN - message has been read Opposites of the above flags: - UNANSWERED - UNDELETED - UNDRAFT - UNFLAGGED - OLD - UNSEEN Composite flags: - NEW - equivalent to RECENT + UNSEEN - ALL - all the messages Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response or if $flag is not valid @param string $flag @return int
[ "Wrapper", "function", "to", "fetch", "count", "of", "messages", "by", "a", "certain", "flag", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1960-L1965
23,391
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.searchByFlag
protected function searchByFlag( $flag ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call searchByFlag() on the IMAP transport when a mailbox is not selected." ); } $matchingMessages = array(); $flag = $this->normalizeFlag( $flag ); if ( in_array( $flag, self::$extendedFlags ) ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}SEARCH ({$flag})" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $ids = substr( trim( $response ), 9 ); if ( trim( $ids ) !== "" ) { $matchingMessages = explode( ' ', $ids ); } } $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not search the messages by flags: {$response}." ); } } else { throw new ezcMailTransportException( "Flag '{$flag}' is not allowed for searching." ); } return $matchingMessages; }
php
protected function searchByFlag( $flag ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call searchByFlag() on the IMAP transport when a mailbox is not selected." ); } $matchingMessages = array(); $flag = $this->normalizeFlag( $flag ); if ( in_array( $flag, self::$extendedFlags ) ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}SEARCH ({$flag})" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $ids = substr( trim( $response ), 9 ); if ( trim( $ids ) !== "" ) { $matchingMessages = explode( ' ', $ids ); } } $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not search the messages by flags: {$response}." ); } } else { throw new ezcMailTransportException( "Flag '{$flag}' is not allowed for searching." ); } return $matchingMessages; }
[ "protected", "function", "searchByFlag", "(", "$", "flag", ")", "{", "$", "uid", "=", "(", "$", "this", "->", "options", "->", "uidReferencing", ")", "?", "self", "::", "UID", ":", "self", "::", "NO_UID", ";", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call searchByFlag() on the IMAP transport when a mailbox is not selected.\"", ")", ";", "}", "$", "matchingMessages", "=", "array", "(", ")", ";", "$", "flag", "=", "$", "this", "->", "normalizeFlag", "(", "$", "flag", ")", ";", "if", "(", "in_array", "(", "$", "flag", ",", "self", "::", "$", "extendedFlags", ")", ")", "{", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} {$uid}SEARCH ({$flag})\"", ")", ";", "$", "response", "=", "$", "this", "->", "getResponse", "(", "'* SEARCH'", ")", ";", "if", "(", "strpos", "(", "$", "response", ",", "'* SEARCH'", ")", "!==", "false", ")", "{", "$", "ids", "=", "substr", "(", "trim", "(", "$", "response", ")", ",", "9", ")", ";", "if", "(", "trim", "(", "$", "ids", ")", "!==", "\"\"", ")", "{", "$", "matchingMessages", "=", "explode", "(", "' '", ",", "$", "ids", ")", ";", "}", "}", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ",", "$", "response", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not search the messages by flags: {$response}.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "ezcMailTransportException", "(", "\"Flag '{$flag}' is not allowed for searching.\"", ")", ";", "}", "return", "$", "matchingMessages", ";", "}" ]
Returns an array of message numbers from the selected mailbox which have a certain flag set. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. $flag can be one of: Basic flags: - ANSWERED - message has been answered - DELETED - message is marked to be deleted by later EXPUNGE - DRAFT - message is marked as a draft - FLAGGED - message is "flagged" for urgent/special attention - RECENT - message is recent - SEEN - message has been read Opposites of the above flags: - UNANSWERED - UNDELETED - UNDRAFT - UNFLAGGED - OLD - UNSEEN Composite flags: - NEW - equivalent to RECENT + UNSEEN - ALL - all the messages The returned array is something like this: <code> array( 0 => 1, 1 => 5 ); </code> Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response or if $flag is not valid @param string $flag @return array(int)
[ "Returns", "an", "array", "of", "message", "numbers", "from", "the", "selected", "mailbox", "which", "have", "a", "certain", "flag", "set", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2241-L2278
23,392
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.capability
public function capability() { if ( $this->state != self::STATE_NOT_AUTHENTICATED && $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Trying to request capability when not connected to server." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} CAPABILITY" ); $response = $this->connection->getLine(); while ( $this->responseType( $response ) != self::RESPONSE_UNTAGGED && strpos( $response, '* CAPABILITY ' ) === false ) { $response = $this->connection->getLine(); } $result = trim( $response ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server responded negative to the CAPABILITY command: {$response}." ); } return explode( ' ', str_replace( '* CAPABILITY ', '', $result ) ); }
php
public function capability() { if ( $this->state != self::STATE_NOT_AUTHENTICATED && $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Trying to request capability when not connected to server." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} CAPABILITY" ); $response = $this->connection->getLine(); while ( $this->responseType( $response ) != self::RESPONSE_UNTAGGED && strpos( $response, '* CAPABILITY ' ) === false ) { $response = $this->connection->getLine(); } $result = trim( $response ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server responded negative to the CAPABILITY command: {$response}." ); } return explode( ' ', str_replace( '* CAPABILITY ', '', $result ) ); }
[ "public", "function", "capability", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_NOT_AUTHENTICATED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_AUTHENTICATED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Trying to request capability when not connected to server.\"", ")", ";", "}", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} CAPABILITY\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "while", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_UNTAGGED", "&&", "strpos", "(", "$", "response", ",", "'* CAPABILITY '", ")", "===", "false", ")", "{", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "}", "$", "result", "=", "trim", "(", "$", "response", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server responded negative to the CAPABILITY command: {$response}.\"", ")", ";", "}", "return", "explode", "(", "' '", ",", "str_replace", "(", "'* CAPABILITY '", ",", "''", ",", "$", "result", ")", ")", ";", "}" ]
Returns an array with the capabilities of the IMAP server. The returned array will be something like this: <code> array( 'IMAP4rev1', 'SASL-IR SORT', 'THREAD=REFERENCES', 'MULTIAPPEND', 'UNSELECT', 'LITERAL+', 'IDLE', 'CHILDREN', 'NAMESPACE', 'LOGIN-REFERRALS' ); </code> Before calling this method, a connection to the IMAP server must be established. @throws ezcMailTransportException if there was no connection to the server or if the server sent a negative response @return array(string)
[ "Returns", "an", "array", "with", "the", "capabilities", "of", "the", "IMAP", "server", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2328-L2356
23,393
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.expunge
public function expunge() { if ( $this->state != self::STATE_SELECTED ) { throw new ezcMailTransportException( "Can not issue EXPUNGE command if a mailbox is not selected." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} EXPUNGE" ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "EXPUNGE failed: {$response}." ); } }
php
public function expunge() { if ( $this->state != self::STATE_SELECTED ) { throw new ezcMailTransportException( "Can not issue EXPUNGE command if a mailbox is not selected." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} EXPUNGE" ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "EXPUNGE failed: {$response}." ); } }
[ "public", "function", "expunge", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can not issue EXPUNGE command if a mailbox is not selected.\"", ")", ";", "}", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} EXPUNGE\"", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"EXPUNGE failed: {$response}.\"", ")", ";", "}", "}" ]
Sends an EXPUNGE command to the server. This method permanently deletes the messages marked for deletion by the method {@link delete()}. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. @throws ezcMailTransportException if a mailbox was not selected or if the server sent a negative response
[ "Sends", "an", "EXPUNGE", "command", "to", "the", "server", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2372-L2386
23,394
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.getNextTag
protected function getNextTag() { $tagLetter = substr( $this->currentTag, 0, 1 ); $tagNumber = intval( substr( $this->currentTag, 1 ) ); $tagNumber++; if ( $tagLetter == 'Z' && $tagNumber == 10000 ) { $tagLetter = 'A'; $tagNumber = 1; } if ( $tagNumber == 10000 ) { $tagLetter++; $tagNumber = 0; } $this->currentTag = $tagLetter . sprintf( "%04s", $tagNumber ); return $this->currentTag; }
php
protected function getNextTag() { $tagLetter = substr( $this->currentTag, 0, 1 ); $tagNumber = intval( substr( $this->currentTag, 1 ) ); $tagNumber++; if ( $tagLetter == 'Z' && $tagNumber == 10000 ) { $tagLetter = 'A'; $tagNumber = 1; } if ( $tagNumber == 10000 ) { $tagLetter++; $tagNumber = 0; } $this->currentTag = $tagLetter . sprintf( "%04s", $tagNumber ); return $this->currentTag; }
[ "protected", "function", "getNextTag", "(", ")", "{", "$", "tagLetter", "=", "substr", "(", "$", "this", "->", "currentTag", ",", "0", ",", "1", ")", ";", "$", "tagNumber", "=", "intval", "(", "substr", "(", "$", "this", "->", "currentTag", ",", "1", ")", ")", ";", "$", "tagNumber", "++", ";", "if", "(", "$", "tagLetter", "==", "'Z'", "&&", "$", "tagNumber", "==", "10000", ")", "{", "$", "tagLetter", "=", "'A'", ";", "$", "tagNumber", "=", "1", ";", "}", "if", "(", "$", "tagNumber", "==", "10000", ")", "{", "$", "tagLetter", "++", ";", "$", "tagNumber", "=", "0", ";", "}", "$", "this", "->", "currentTag", "=", "$", "tagLetter", ".", "sprintf", "(", "\"%04s\"", ",", "$", "tagNumber", ")", ";", "return", "$", "this", "->", "currentTag", ";", "}" ]
Generates the next IMAP tag to prepend to client commands. The structure of the IMAP tag is Axxxx, where: - A is a letter (uppercase for conformity) - x is a digit from 0 to 9 example of generated tag: T5439 It uses the class variable $this->currentTag. Everytime it is called, the tag increases by 1. If it reaches the last tag, it wraps around to the first tag. By default, the first generated tag is A0001. @return string
[ "Generates", "the", "next", "IMAP", "tag", "to", "prepend", "to", "client", "commands", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2688-L2705
23,395
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.getMessageSectionSize
protected function getMessageSectionSize( $response ) { $size = 0; preg_match( '/\{(.*)\}/', $response, $matches ); if ( count( $matches ) > 0 ) { $size = (int) $matches[1]; } return $size; }
php
protected function getMessageSectionSize( $response ) { $size = 0; preg_match( '/\{(.*)\}/', $response, $matches ); if ( count( $matches ) > 0 ) { $size = (int) $matches[1]; } return $size; }
[ "protected", "function", "getMessageSectionSize", "(", "$", "response", ")", "{", "$", "size", "=", "0", ";", "preg_match", "(", "'/\\{(.*)\\}/'", ",", "$", "response", ",", "$", "matches", ")", ";", "if", "(", "count", "(", "$", "matches", ")", ">", "0", ")", "{", "$", "size", "=", "(", "int", ")", "$", "matches", "[", "1", "]", ";", "}", "return", "$", "size", ";", "}" ]
Returns the size of a FETCH section in bytes. The section header looks like: * id FETCH (BODY[TEXT] {size} where size is the size in bytes and id is the message number or ID. Example: for " * 2 FETCH (BODY[TEXT] {377}" this function returns 377. @return int
[ "Returns", "the", "size", "of", "a", "FETCH", "section", "in", "bytes", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2717-L2726
23,396
caffeinated/beverage
src/Traits/EventDispatcher.php
EventDispatcher.registerEvent
protected function registerEvent($name, Closure $callback) { if (! isset(static::$dispatcher)) { $this->initEventDispatcher(); } static::$dispatcher->listen($name, $callback); }
php
protected function registerEvent($name, Closure $callback) { if (! isset(static::$dispatcher)) { $this->initEventDispatcher(); } static::$dispatcher->listen($name, $callback); }
[ "protected", "function", "registerEvent", "(", "$", "name", ",", "Closure", "$", "callback", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "dispatcher", ")", ")", "{", "$", "this", "->", "initEventDispatcher", "(", ")", ";", "}", "static", "::", "$", "dispatcher", "->", "listen", "(", "$", "name", ",", "$", "callback", ")", ";", "}" ]
Register an event for the dispatcher to listen for. @param string $name @param Closure $callback @return void
[ "Register", "an", "event", "for", "the", "dispatcher", "to", "listen", "for", "." ]
c7d612a1d3bc1baddc97fec60ab17224550efaf3
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Traits/EventDispatcher.php#L55-L62
23,397
caffeinated/beverage
src/Traits/EventDispatcher.php
EventDispatcher.fireEvent
protected function fireEvent($name, $payload = null) { if (! isset(static::$dispatcher)) { $this->initEventDispatcher(); } static::$dispatcher->fire($name, $payload); }
php
protected function fireEvent($name, $payload = null) { if (! isset(static::$dispatcher)) { $this->initEventDispatcher(); } static::$dispatcher->fire($name, $payload); }
[ "protected", "function", "fireEvent", "(", "$", "name", ",", "$", "payload", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "dispatcher", ")", ")", "{", "$", "this", "->", "initEventDispatcher", "(", ")", ";", "}", "static", "::", "$", "dispatcher", "->", "fire", "(", "$", "name", ",", "$", "payload", ")", ";", "}" ]
Fire off an event. @param string $name @param mixed $payload @return mixed
[ "Fire", "off", "an", "event", "." ]
c7d612a1d3bc1baddc97fec60ab17224550efaf3
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Traits/EventDispatcher.php#L71-L78
23,398
CupOfTea696/WordPress-Composer
src/WordPressInstallationCleaner.php
WordPressInstallationCleaner.clean
public function clean(Composer $composer) { $rootPkg = $composer->getPackage(); $extra = $rootPkg->getExtra(); if (! isset($extra['wordpress-install-dir'])) { return; } $filesystem = new Filesystem(); $filesystem->remove($extra['wordpress-install-dir'] . '/wp-content'); }
php
public function clean(Composer $composer) { $rootPkg = $composer->getPackage(); $extra = $rootPkg->getExtra(); if (! isset($extra['wordpress-install-dir'])) { return; } $filesystem = new Filesystem(); $filesystem->remove($extra['wordpress-install-dir'] . '/wp-content'); }
[ "public", "function", "clean", "(", "Composer", "$", "composer", ")", "{", "$", "rootPkg", "=", "$", "composer", "->", "getPackage", "(", ")", ";", "$", "extra", "=", "$", "rootPkg", "->", "getExtra", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "extra", "[", "'wordpress-install-dir'", "]", ")", ")", "{", "return", ";", "}", "$", "filesystem", "=", "new", "Filesystem", "(", ")", ";", "$", "filesystem", "->", "remove", "(", "$", "extra", "[", "'wordpress-install-dir'", "]", ".", "'/wp-content'", ")", ";", "}" ]
Clean up the WordPress installation directory. @param \Composer\Composer $composer @return void
[ "Clean", "up", "the", "WordPress", "installation", "directory", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/WordPressInstallationCleaner.php#L35-L46
23,399
ekuiter/feature-php
FeaturePhp/File/TextFileContent.php
TextFileContent.copy
public function copy($target) { if (!parent::copy($target)) return false; return file_put_contents($target, $this->content) !== false; }
php
public function copy($target) { if (!parent::copy($target)) return false; return file_put_contents($target, $this->content) !== false; }
[ "public", "function", "copy", "(", "$", "target", ")", "{", "if", "(", "!", "parent", "::", "copy", "(", "$", "target", ")", ")", "return", "false", ";", "return", "file_put_contents", "(", "$", "target", ",", "$", "this", "->", "content", ")", "!==", "false", ";", "}" ]
Copies the text file's content to the local filesystem. @param string $target the file target in the filesystem
[ "Copies", "the", "text", "file", "s", "content", "to", "the", "local", "filesystem", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/File/TextFileContent.php#L50-L54