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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
brightnucleus/shortcodes | src/ShortcodeManager.php | ShortcodeManager.get_shortcode_atts_parser_class | protected function get_shortcode_atts_parser_class( $tag ) {
$atts_parser = $this->hasConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER )
? $this->getConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER )
: self::DEFAULT_SHORTCODE_ATTS_PARSER;
return $atts_parser;
} | php | protected function get_shortcode_atts_parser_class( $tag ) {
$atts_parser = $this->hasConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER )
? $this->getConfigKey( $tag, self::KEY_CUSTOM_ATTS_PARSER )
: self::DEFAULT_SHORTCODE_ATTS_PARSER;
return $atts_parser;
} | [
"protected",
"function",
"get_shortcode_atts_parser_class",
"(",
"$",
"tag",
")",
"{",
"$",
"atts_parser",
"=",
"$",
"this",
"->",
"hasConfigKey",
"(",
"$",
"tag",
",",
"self",
"::",
"KEY_CUSTOM_ATTS_PARSER",
")",
"?",
"$",
"this",
"->",
"getConfigKey",
"(",
... | Get the class name of an implementation of the
ShortcodeAttsParsersInterface.
@since 0.1.0
@param string $tag Shortcode tag to get the class for.
@return string Class name of the ShortcodeAttsParser. | [
"Get",
"the",
"class",
"name",
"of",
"an",
"implementation",
"of",
"the",
"ShortcodeAttsParsersInterface",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/ShortcodeManager.php#L221-L227 | train |
brightnucleus/shortcodes | src/ShortcodeManager.php | ShortcodeManager.init_shortcode_ui | protected function init_shortcode_ui( $tag ) {
$shortcode_ui_class = $this->get_shortcode_ui_class( $tag );
$this->shortcode_uis[] = $this->instantiate(
ShortcodeUIInterface::class,
$shortcode_ui_class,
[
'shortcode_tag' => $tag,
'config' => $this->config->getSubConfig( $tag, self::KEY_UI ),
'dependencies' => $this->dependencies,
]
);
} | php | protected function init_shortcode_ui( $tag ) {
$shortcode_ui_class = $this->get_shortcode_ui_class( $tag );
$this->shortcode_uis[] = $this->instantiate(
ShortcodeUIInterface::class,
$shortcode_ui_class,
[
'shortcode_tag' => $tag,
'config' => $this->config->getSubConfig( $tag, self::KEY_UI ),
'dependencies' => $this->dependencies,
]
);
} | [
"protected",
"function",
"init_shortcode_ui",
"(",
"$",
"tag",
")",
"{",
"$",
"shortcode_ui_class",
"=",
"$",
"this",
"->",
"get_shortcode_ui_class",
"(",
"$",
"tag",
")",
";",
"$",
"this",
"->",
"shortcode_uis",
"[",
"]",
"=",
"$",
"this",
"->",
"instanti... | Initialize the Shortcode UI for a single shortcode.
@since 0.1.0
@param string $tag The tag of the shortcode to register
the UI for.
@throws FailedToInstantiateObject If the Shortcode UI object could not
be instantiated. | [
"Initialize",
"the",
"Shortcode",
"UI",
"for",
"a",
"single",
"shortcode",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/ShortcodeManager.php#L240-L252 | train |
brightnucleus/shortcodes | src/ShortcodeManager.php | ShortcodeManager.get_shortcode_ui_class | protected function get_shortcode_ui_class( $tag ) {
$ui_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_UI )
? $this->getConfigKey( $tag, self::KEY_CUSTOM_UI )
: self::DEFAULT_SHORTCODE_UI;
return $ui_class;
} | php | protected function get_shortcode_ui_class( $tag ) {
$ui_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_UI )
? $this->getConfigKey( $tag, self::KEY_CUSTOM_UI )
: self::DEFAULT_SHORTCODE_UI;
return $ui_class;
} | [
"protected",
"function",
"get_shortcode_ui_class",
"(",
"$",
"tag",
")",
"{",
"$",
"ui_class",
"=",
"$",
"this",
"->",
"hasConfigKey",
"(",
"$",
"tag",
",",
"self",
"::",
"KEY_CUSTOM_UI",
")",
"?",
"$",
"this",
"->",
"getConfigKey",
"(",
"$",
"tag",
",",... | Get the class name of an implementation of the ShortcodeUIInterface.
@since 0.1.0
@param string $tag Configuration settings.
@return string Class name of the ShortcodeUI. | [
"Get",
"the",
"class",
"name",
"of",
"an",
"implementation",
"of",
"the",
"ShortcodeUIInterface",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/ShortcodeManager.php#L263-L269 | train |
brightnucleus/shortcodes | src/ShortcodeManager.php | ShortcodeManager.register | public function register( $context = null ) {
$this->init_shortcodes();
$context = $this->validate_context( $context );
$context['page_template'] = $this->get_page_template();
array_walk( $this->shortcodes,
function ( ShortcodeInterface $shortcode ) use ( $context ) {
$shortcode->register( $context );
} );
// This hook only gets fired when Shortcode UI plugin is active.
\add_action(
'register_shortcode_ui',
[ $this, 'register_shortcode_ui', ]
);
} | php | public function register( $context = null ) {
$this->init_shortcodes();
$context = $this->validate_context( $context );
$context['page_template'] = $this->get_page_template();
array_walk( $this->shortcodes,
function ( ShortcodeInterface $shortcode ) use ( $context ) {
$shortcode->register( $context );
} );
// This hook only gets fired when Shortcode UI plugin is active.
\add_action(
'register_shortcode_ui',
[ $this, 'register_shortcode_ui', ]
);
} | [
"public",
"function",
"register",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"init_shortcodes",
"(",
")",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"validate_context",
"(",
"$",
"context",
")",
";",
"$",
"context",
"[",
"'page_te... | Register all of the shortcode handlers.
@since 0.1.0
@param mixed $context Optional. Context information to pass to shortcode.
@return void | [
"Register",
"all",
"of",
"the",
"shortcode",
"handlers",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/ShortcodeManager.php#L280-L296 | train |
brightnucleus/shortcodes | src/ShortcodeManager.php | ShortcodeManager.register_shortcode_ui | public function register_shortcode_ui() {
$template = $this->get_page_template();
$context = [ 'page_template' => $template ];
array_walk( $this->shortcode_uis,
function ( ShortcodeUIInterface $shortcode_ui ) use ( $context ) {
$shortcode_ui->register( $context );
}
);
} | php | public function register_shortcode_ui() {
$template = $this->get_page_template();
$context = [ 'page_template' => $template ];
array_walk( $this->shortcode_uis,
function ( ShortcodeUIInterface $shortcode_ui ) use ( $context ) {
$shortcode_ui->register( $context );
}
);
} | [
"public",
"function",
"register_shortcode_ui",
"(",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"get_page_template",
"(",
")",
";",
"$",
"context",
"=",
"[",
"'page_template'",
"=>",
"$",
"template",
"]",
";",
"array_walk",
"(",
"$",
"this",
"->",
... | Register the shortcode UI handlers.
@since 0.1.0 | [
"Register",
"the",
"shortcode",
"UI",
"handlers",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/ShortcodeManager.php#L337-L346 | train |
brightnucleus/shortcodes | src/ShortcodeManager.php | ShortcodeManager.do_tag | public function do_tag( $tag, array $atts = [], $content = null ) {
return \BrightNucleus\Shortcode\do_tag( $tag, $atts, $content );
} | php | public function do_tag( $tag, array $atts = [], $content = null ) {
return \BrightNucleus\Shortcode\do_tag( $tag, $atts, $content );
} | [
"public",
"function",
"do_tag",
"(",
"$",
"tag",
",",
"array",
"$",
"atts",
"=",
"[",
"]",
",",
"$",
"content",
"=",
"null",
")",
"{",
"return",
"\\",
"BrightNucleus",
"\\",
"Shortcode",
"\\",
"do_tag",
"(",
"$",
"tag",
",",
"$",
"atts",
",",
"$",
... | Execute a specific shortcode directly from code.
@since 0.2.4
@param string $tag Tag of the shortcode to execute.
@param array $atts Array of attributes to pass to the shortcode.
@param null $content Inner content to pass to the shortcode.
@return string|false Rendered HTML. | [
"Execute",
"a",
"specific",
"shortcode",
"directly",
"from",
"code",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/ShortcodeManager.php#L359-L361 | train |
brightnucleus/shortcodes | src/ShortcodeManager.php | ShortcodeManager.instantiate | protected function instantiate( $interface, $class, array $args ) {
try {
if ( is_callable( $class ) ) {
$class = call_user_func_array( $class, $args );
}
if ( is_string( $class ) ) {
if ( null !== $this->injector ) {
$class = $this->injector->make( $class, $args );
} else {
$class = $this->instantiateClass( $class, $args );
}
}
} catch ( Exception $exception ) {
throw FailedToInstantiateObject::fromFactory(
$class,
$interface,
$exception
);
}
if ( ! is_subclass_of( $class, $interface ) ) {
throw FailedToInstantiateObject::fromInvalidObject(
$class,
$interface
);
}
return $class;
} | php | protected function instantiate( $interface, $class, array $args ) {
try {
if ( is_callable( $class ) ) {
$class = call_user_func_array( $class, $args );
}
if ( is_string( $class ) ) {
if ( null !== $this->injector ) {
$class = $this->injector->make( $class, $args );
} else {
$class = $this->instantiateClass( $class, $args );
}
}
} catch ( Exception $exception ) {
throw FailedToInstantiateObject::fromFactory(
$class,
$interface,
$exception
);
}
if ( ! is_subclass_of( $class, $interface ) ) {
throw FailedToInstantiateObject::fromInvalidObject(
$class,
$interface
);
}
return $class;
} | [
"protected",
"function",
"instantiate",
"(",
"$",
"interface",
",",
"$",
"class",
",",
"array",
"$",
"args",
")",
"{",
"try",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"call_user_func_array",
"(",
"$",
"class",... | Instantiate a new object through either a class name or a factory method.
@since 0.3.0
@param string $interface Interface the object needs to
implement.
@param callable|string $class Fully qualified class name or factory
method.
@param array $args Arguments passed to the constructor or
factory method.
@return object Object that implements the interface.
@throws FailedToInstantiateObject If no valid object could be
instantiated. | [
"Instantiate",
"a",
"new",
"object",
"through",
"either",
"a",
"class",
"name",
"or",
"a",
"factory",
"method",
"."
] | 5db6fa3c18db856ab550e56960a844d6aa99dabb | https://github.com/brightnucleus/shortcodes/blob/5db6fa3c18db856ab550e56960a844d6aa99dabb/src/ShortcodeManager.php#L379-L408 | train |
railken/lara-eye | src/Query/Visitors/BaseOperatorVisitor.php | BaseOperatorVisitor.parseNode | public function parseNode($query, $node)
{
if ($node instanceof Nodes\KeyNode) {
return $this->parseKey($node->getValue());
}
if ($node instanceof Nodes\ValueNode) {
return $this->parseValue($node->getValue());
}
if ($node instanceof Nodes\FunctionNode) {
// .. ?
$f = $this->getBuilder()->getFunctions()->first(function ($item, $key) use ($node) {
$class = $item->getNode();
return $node instanceof $class;
});
if (!$f) {
throw new \Railken\SQ\Exceptions\QuerySyntaxException();
}
$childs = new Collection();
foreach ($node->getChildren() as $child) {
$childs[] = $this->parseNode($query, $child);
}
$childs = $childs->map(function ($v) use ($query) {
if ($v instanceof \Illuminate\Database\Query\Expression) {
return $v->getValue();
}
$query->addBinding($v, 'where');
return '?';
});
return DB::raw($f->getName().'('.$childs->implode(',').')');
}
} | php | public function parseNode($query, $node)
{
if ($node instanceof Nodes\KeyNode) {
return $this->parseKey($node->getValue());
}
if ($node instanceof Nodes\ValueNode) {
return $this->parseValue($node->getValue());
}
if ($node instanceof Nodes\FunctionNode) {
// .. ?
$f = $this->getBuilder()->getFunctions()->first(function ($item, $key) use ($node) {
$class = $item->getNode();
return $node instanceof $class;
});
if (!$f) {
throw new \Railken\SQ\Exceptions\QuerySyntaxException();
}
$childs = new Collection();
foreach ($node->getChildren() as $child) {
$childs[] = $this->parseNode($query, $child);
}
$childs = $childs->map(function ($v) use ($query) {
if ($v instanceof \Illuminate\Database\Query\Expression) {
return $v->getValue();
}
$query->addBinding($v, 'where');
return '?';
});
return DB::raw($f->getName().'('.$childs->implode(',').')');
}
} | [
"public",
"function",
"parseNode",
"(",
"$",
"query",
",",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Nodes",
"\\",
"KeyNode",
")",
"{",
"return",
"$",
"this",
"->",
"parseKey",
"(",
"$",
"node",
"->",
"getValue",
"(",
")",
")",
... | Parse the node.
@param mixed $query
@param \Railken\SQ\Contracts\NodeContract $node
@return mixed | [
"Parse",
"the",
"node",
"."
] | 7f32a578a8187a08ca99cecf56645c818b103498 | https://github.com/railken/lara-eye/blob/7f32a578a8187a08ca99cecf56645c818b103498/src/Query/Visitors/BaseOperatorVisitor.php#L56-L97 | train |
railken/lara-eye | src/Query/Visitors/BaseOperatorVisitor.php | BaseOperatorVisitor.parseKey | public function parseKey($key)
{
$keys = explode('.', $key);
$keys = [implode(".", array_slice($keys, 0, -1)), $keys[count($keys) - 1]];
$key = (new Collection($keys))->map(function ($part) {
return '`'.$part.'`';
})->implode('.');
return DB::raw($key);
} | php | public function parseKey($key)
{
$keys = explode('.', $key);
$keys = [implode(".", array_slice($keys, 0, -1)), $keys[count($keys) - 1]];
$key = (new Collection($keys))->map(function ($part) {
return '`'.$part.'`';
})->implode('.');
return DB::raw($key);
} | [
"public",
"function",
"parseKey",
"(",
"$",
"key",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"keys",
"=",
"[",
"implode",
"(",
"\".\"",
",",
"array_slice",
"(",
"$",
"keys",
",",
"0",
",",
"-",
"1",
")",... | Parse key.
@param string $key
@return string | [
"Parse",
"key",
"."
] | 7f32a578a8187a08ca99cecf56645c818b103498 | https://github.com/railken/lara-eye/blob/7f32a578a8187a08ca99cecf56645c818b103498/src/Query/Visitors/BaseOperatorVisitor.php#L106-L117 | train |
arcanedev-maroc/QrCode | src/Modes/ModesManager.php | ModesManager.prepareDataBits | private function prepareDataBits()
{
$n = $this->structureAppendN;
$m = $this->structureAppendM;
$parity = $this->structureAppendParity;
$originalData = $this->structureAppendOriginalData;
$dataCounter = 0;
if ( $this->checkStructureAppend($n, $m) )
{
$dataValue[0] = 3;
$dataBits[0] = 4;
$dataValue[1] = $m - 1;
$dataBits[1] = 4;
$dataValue[2] = $n - 1;
$dataBits[2] = 4;
$originalDataLength = strlen($originalData);
if ( $originalDataLength > 1 )
{
$parity = 0;
$i = 0;
while ($i < $originalDataLength)
{
$parity = ($parity ^ ord(substr($originalData, $i, 1)));
$i++;
}
}
$dataValue[3] = $parity;
$dataBits[3] = 8;
$dataCounter = 4;
}
$dataBits[$dataCounter] = 4;
return $dataBits;
} | php | private function prepareDataBits()
{
$n = $this->structureAppendN;
$m = $this->structureAppendM;
$parity = $this->structureAppendParity;
$originalData = $this->structureAppendOriginalData;
$dataCounter = 0;
if ( $this->checkStructureAppend($n, $m) )
{
$dataValue[0] = 3;
$dataBits[0] = 4;
$dataValue[1] = $m - 1;
$dataBits[1] = 4;
$dataValue[2] = $n - 1;
$dataBits[2] = 4;
$originalDataLength = strlen($originalData);
if ( $originalDataLength > 1 )
{
$parity = 0;
$i = 0;
while ($i < $originalDataLength)
{
$parity = ($parity ^ ord(substr($originalData, $i, 1)));
$i++;
}
}
$dataValue[3] = $parity;
$dataBits[3] = 8;
$dataCounter = 4;
}
$dataBits[$dataCounter] = 4;
return $dataBits;
} | [
"private",
"function",
"prepareDataBits",
"(",
")",
"{",
"$",
"n",
"=",
"$",
"this",
"->",
"structureAppendN",
";",
"$",
"m",
"=",
"$",
"this",
"->",
"structureAppendM",
";",
"$",
"parity",
"=",
"$",
"this",
"->",
"structureAppendParity",
";",
"$",
"orig... | Get Data Bits Array
@return array | [
"Get",
"Data",
"Bits",
"Array"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/Modes/ModesManager.php#L84-L127 | train |
arcanedev-maroc/QrCode | src/Modes/ModesManager.php | ModesManager.getModeName | public function getModeName()
{
return $this->isNumericData()
? self::NUMERIC_MODE
: ( $this->isAlphaNumericData()
? self::ALPHA_NUMERIC_MODE
: self::EIGHT_BITS_MODE
);
} | php | public function getModeName()
{
return $this->isNumericData()
? self::NUMERIC_MODE
: ( $this->isAlphaNumericData()
? self::ALPHA_NUMERIC_MODE
: self::EIGHT_BITS_MODE
);
} | [
"public",
"function",
"getModeName",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"isNumericData",
"(",
")",
"?",
"self",
"::",
"NUMERIC_MODE",
":",
"(",
"$",
"this",
"->",
"isAlphaNumericData",
"(",
")",
"?",
"self",
"::",
"ALPHA_NUMERIC_MODE",
":",
"self"... | Get the encoding mode name
@return string | [
"Get",
"the",
"encoding",
"mode",
"name"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/Modes/ModesManager.php#L134-L142 | train |
arcanedev-maroc/QrCode | src/Modes/ModesManager.php | ModesManager.switchMode | private function switchMode()
{
switch ( $this->getModeName() )
{
case self::NUMERIC_MODE:
return new NumericMode;
case self::ALPHA_NUMERIC_MODE:
return new AlphanumericMode;
case self::EIGHT_BITS_MODE:
default:
return new EightBitMode;
}
} | php | private function switchMode()
{
switch ( $this->getModeName() )
{
case self::NUMERIC_MODE:
return new NumericMode;
case self::ALPHA_NUMERIC_MODE:
return new AlphanumericMode;
case self::EIGHT_BITS_MODE:
default:
return new EightBitMode;
}
} | [
"private",
"function",
"switchMode",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"getModeName",
"(",
")",
")",
"{",
"case",
"self",
"::",
"NUMERIC_MODE",
":",
"return",
"new",
"NumericMode",
";",
"case",
"self",
"::",
"ALPHA_NUMERIC_MODE",
":",
"retur... | Switch the Encoding mode
@return AlphanumericMode | EightBitMode | NumericMode | [
"Switch",
"the",
"Encoding",
"mode"
] | c0e3429df86bf9e4668c1e4f083c742ae677f6fe | https://github.com/arcanedev-maroc/QrCode/blob/c0e3429df86bf9e4668c1e4f083c742ae677f6fe/src/Modes/ModesManager.php#L149-L163 | train |
nekudo/Angela | src/Logger/LoggerFactory.php | LoggerFactory.create | public function create() : LoggerInterface
{
$loggerType = $this->config['type'] ?? 'null';
switch ($loggerType) {
case 'file':
return new Logger($this->config['path'], $this->config['level']);
case 'null':
return new NullLogger;
default:
throw new \RuntimeException('Invalid logger type');
}
} | php | public function create() : LoggerInterface
{
$loggerType = $this->config['type'] ?? 'null';
switch ($loggerType) {
case 'file':
return new Logger($this->config['path'], $this->config['level']);
case 'null':
return new NullLogger;
default:
throw new \RuntimeException('Invalid logger type');
}
} | [
"public",
"function",
"create",
"(",
")",
":",
"LoggerInterface",
"{",
"$",
"loggerType",
"=",
"$",
"this",
"->",
"config",
"[",
"'type'",
"]",
"??",
"'null'",
";",
"switch",
"(",
"$",
"loggerType",
")",
"{",
"case",
"'file'",
":",
"return",
"new",
"Lo... | Creates logger depending on configuration.
@return LoggerInterface | [
"Creates",
"logger",
"depending",
"on",
"configuration",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Logger/LoggerFactory.php#L23-L34 | train |
oat-sa/extension-tao-deliverysimple | models/classes/class.DeliveryCompiler.php | taoSimpleDelivery_models_classes_DeliveryCompiler.compile | public function compile() {
$test = $this->getResource()->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_DELIVERYCONTENT_TEST));
if (is_null($test)) {
throw new EmptyDeliveryException($this->getResource());
}
return $this->subCompile($test);
} | php | public function compile() {
$test = $this->getResource()->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_DELIVERYCONTENT_TEST));
if (is_null($test)) {
throw new EmptyDeliveryException($this->getResource());
}
return $this->subCompile($test);
} | [
"public",
"function",
"compile",
"(",
")",
"{",
"$",
"test",
"=",
"$",
"this",
"->",
"getResource",
"(",
")",
"->",
"getOnePropertyValue",
"(",
"new",
"core_kernel_classes_Property",
"(",
"PROPERTY_DELIVERYCONTENT_TEST",
")",
")",
";",
"if",
"(",
"is_null",
"(... | Compiles a simple delivery
@return tao_models_classes_service_ServiceCall | [
"Compiles",
"a",
"simple",
"delivery"
] | 5816ebfad8d926a72711720e012e23d809a889dc | https://github.com/oat-sa/extension-tao-deliverysimple/blob/5816ebfad8d926a72711720e012e23d809a889dc/models/classes/class.DeliveryCompiler.php#L38-L45 | train |
itmh/service-tools-soap-old | src/Camcima/Soap/Client.php | Client.parseCookies | protected function parseCookies ()
{
$cookie = '';
foreach( $this->cookies as $name => $value )
$cookie .= $name . '=' . $value . '; ';
return rtrim( $cookie, ';' );
} | php | protected function parseCookies ()
{
$cookie = '';
foreach( $this->cookies as $name => $value )
$cookie .= $name . '=' . $value . '; ';
return rtrim( $cookie, ';' );
} | [
"protected",
"function",
"parseCookies",
"(",
")",
"{",
"$",
"cookie",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"cookies",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"$",
"cookie",
".=",
"$",
"name",
".",
"'='",
".",
"$",
"value",
".",
... | Parse the cookies into a valid HTTP Cookie header value
@return string | [
"Parse",
"the",
"cookies",
"into",
"a",
"valid",
"HTTP",
"Cookie",
"header",
"value"
] | 3dfe08222df3d90813e2bf1b420fa7f7aa70c388 | https://github.com/itmh/service-tools-soap-old/blob/3dfe08222df3d90813e2bf1b420fa7f7aa70c388/src/Camcima/Soap/Client.php#L232-L240 | train |
itmh/service-tools-soap-old | src/Camcima/Soap/Client.php | Client.getSoapVariables | public function getSoapVariables($requestObject, $lowerCaseFirst = false, $keepNullProperties = true)
{
if (!is_object($requestObject)) {
throw new InvalidParameterException('Parameter requestObject is not an object');
}
$objectName = $this->getClassNameWithoutNamespaces($requestObject);
if ($lowerCaseFirst) {
$objectName = lcfirst($objectName);
}
$stdClass = new \stdClass();
$stdClass->$objectName = $requestObject;
return $this->objectToArray($stdClass, $keepNullProperties);
} | php | public function getSoapVariables($requestObject, $lowerCaseFirst = false, $keepNullProperties = true)
{
if (!is_object($requestObject)) {
throw new InvalidParameterException('Parameter requestObject is not an object');
}
$objectName = $this->getClassNameWithoutNamespaces($requestObject);
if ($lowerCaseFirst) {
$objectName = lcfirst($objectName);
}
$stdClass = new \stdClass();
$stdClass->$objectName = $requestObject;
return $this->objectToArray($stdClass, $keepNullProperties);
} | [
"public",
"function",
"getSoapVariables",
"(",
"$",
"requestObject",
",",
"$",
"lowerCaseFirst",
"=",
"false",
",",
"$",
"keepNullProperties",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"requestObject",
")",
")",
"{",
"throw",
"new",
"In... | Get SOAP Request Variables
Prepares request parameters to be
sent in the SOAP Request Body.
@param object $requestObject
@param boolean $lowerCaseFirst Lowercase first character of the root element name
@param boolean $keepNullProperties Keep null object properties when building the request parameters
@throws \Camcima\Exception\InvalidParameterException
@return array | [
"Get",
"SOAP",
"Request",
"Variables"
] | 3dfe08222df3d90813e2bf1b420fa7f7aa70c388 | https://github.com/itmh/service-tools-soap-old/blob/3dfe08222df3d90813e2bf1b420fa7f7aa70c388/src/Camcima/Soap/Client.php#L392-L405 | train |
itmh/service-tools-soap-old | src/Camcima/Soap/Client.php | Client.logCurlMessage | protected function logCurlMessage($message, \DateTime $messageTimestamp)
{
if (!$this->debugLogFilePath) {
throw new \RuntimeException('Debug log file path not defined.');
}
$logMessage = '[' . $messageTimestamp->format('Y-m-d H:i:s') . "] ----------------------------------------------------------\n" . $message . "\n\n";
$logHandle = fopen($this->debugLogFilePath, 'a+');
fwrite($logHandle, $logMessage);
fclose($logHandle);
} | php | protected function logCurlMessage($message, \DateTime $messageTimestamp)
{
if (!$this->debugLogFilePath) {
throw new \RuntimeException('Debug log file path not defined.');
}
$logMessage = '[' . $messageTimestamp->format('Y-m-d H:i:s') . "] ----------------------------------------------------------\n" . $message . "\n\n";
$logHandle = fopen($this->debugLogFilePath, 'a+');
fwrite($logHandle, $logMessage);
fclose($logHandle);
} | [
"protected",
"function",
"logCurlMessage",
"(",
"$",
"message",
",",
"\\",
"DateTime",
"$",
"messageTimestamp",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"debugLogFilePath",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Debug log file path not de... | Log cURL Debug Message
@param string $message
@param \DateTime $messageTimestamp
@throws \RuntimeException | [
"Log",
"cURL",
"Debug",
"Message"
] | 3dfe08222df3d90813e2bf1b420fa7f7aa70c388 | https://github.com/itmh/service-tools-soap-old/blob/3dfe08222df3d90813e2bf1b420fa7f7aa70c388/src/Camcima/Soap/Client.php#L591-L600 | train |
oat-sa/extension-tao-datauri | controller/Base64Converter.php | Base64Converter.convert | public function convert() {
$resource = $file = \tao_helpers_Http::getUploadedFile('content');
$base64Converter = new Base64ConverterModel($resource);
$this -> returnJson($base64Converter->convertToBase64());
} | php | public function convert() {
$resource = $file = \tao_helpers_Http::getUploadedFile('content');
$base64Converter = new Base64ConverterModel($resource);
$this -> returnJson($base64Converter->convertToBase64());
} | [
"public",
"function",
"convert",
"(",
")",
"{",
"$",
"resource",
"=",
"$",
"file",
"=",
"\\",
"tao_helpers_Http",
"::",
"getUploadedFile",
"(",
"'content'",
")",
";",
"$",
"base64Converter",
"=",
"new",
"Base64ConverterModel",
"(",
"$",
"resource",
")",
";",... | Convert uploaded resource to base 64 code
@return mixed | [
"Convert",
"uploaded",
"resource",
"to",
"base",
"64",
"code"
] | 4fcbd1ec55335852f82cf8c5d1a6760d8c1800a2 | https://github.com/oat-sa/extension-tao-datauri/blob/4fcbd1ec55335852f82cf8c5d1a6760d8c1800a2/controller/Base64Converter.php#L44-L51 | train |
RogerWaters/react-thread-pool | examples/example_5.php | FatalThread.emulateFatal | public function emulateFatal()
{
if ($this->isExternal()) {
$obj = null;
$obj->callOnNull();
} else {
$this->callOnChild(__FUNCTION__, func_get_args());
}
} | php | public function emulateFatal()
{
if ($this->isExternal()) {
$obj = null;
$obj->callOnNull();
} else {
$this->callOnChild(__FUNCTION__, func_get_args());
}
} | [
"public",
"function",
"emulateFatal",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isExternal",
"(",
")",
")",
"{",
"$",
"obj",
"=",
"null",
";",
"$",
"obj",
"->",
"callOnNull",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"callOnChild",
... | Will create PHP Fatal on remote thread | [
"Will",
"create",
"PHP",
"Fatal",
"on",
"remote",
"thread"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/examples/example_5.php#L39-L47 | train |
RogerWaters/react-thread-pool | examples/example_5.php | FatalThread.emulateExceptionOnRemoteLoop | public function emulateExceptionOnRemoteLoop()
{
if ($this->isExternal()) {
$this->loop->nextTick(function () {
$this->emulateException();
});
} else {
$this->callOnChild(__FUNCTION__, func_get_args());
}
} | php | public function emulateExceptionOnRemoteLoop()
{
if ($this->isExternal()) {
$this->loop->nextTick(function () {
$this->emulateException();
});
} else {
$this->callOnChild(__FUNCTION__, func_get_args());
}
} | [
"public",
"function",
"emulateExceptionOnRemoteLoop",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isExternal",
"(",
")",
")",
"{",
"$",
"this",
"->",
"loop",
"->",
"nextTick",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"emulateException",
"(",
... | Will throw exception on remote thread within loop
@throws Exception | [
"Will",
"throw",
"exception",
"on",
"remote",
"thread",
"within",
"loop"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/examples/example_5.php#L66-L75 | train |
RogerWaters/react-thread-pool | examples/example_5.php | FatalThread.emulateFatalOnRemoteLoop | public function emulateFatalOnRemoteLoop()
{
if ($this->isExternal()) {
$this->loop->nextTick(function () {
$this->emulateFatal();
});
} else {
$this->callOnChild(__FUNCTION__, func_get_args());
}
} | php | public function emulateFatalOnRemoteLoop()
{
if ($this->isExternal()) {
$this->loop->nextTick(function () {
$this->emulateFatal();
});
} else {
$this->callOnChild(__FUNCTION__, func_get_args());
}
} | [
"public",
"function",
"emulateFatalOnRemoteLoop",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isExternal",
"(",
")",
")",
"{",
"$",
"this",
"->",
"loop",
"->",
"nextTick",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"emulateFatal",
"(",
")",
... | Will create PGP Fatal on remote thread within loop
@throws Exception | [
"Will",
"create",
"PGP",
"Fatal",
"on",
"remote",
"thread",
"within",
"loop"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/examples/example_5.php#L81-L90 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.getTrashed | public function getTrashed()
{
if (!$this->modelAdmin->hasSoftDeleting()) {
return $this->missingMethod();
}
return view('flare::admin.modeladmin.trashed', [
'modelItems' => $this->modelAdmin->onlyTrashedItems(),
'totals' => $this->modelAdmin->totals(),
]
);
} | php | public function getTrashed()
{
if (!$this->modelAdmin->hasSoftDeleting()) {
return $this->missingMethod();
}
return view('flare::admin.modeladmin.trashed', [
'modelItems' => $this->modelAdmin->onlyTrashedItems(),
'totals' => $this->modelAdmin->totals(),
]
);
} | [
"public",
"function",
"getTrashed",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasSoftDeleting",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"return",
"view",
"(",
"'flare::admin.model... | Lists Trashed Model Items.
@return \Illuminate\Http\Response | [
"Lists",
"Trashed",
"Model",
"Items",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L66-L77 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.getAll | public function getAll()
{
if (!$this->modelAdmin->hasSoftDeleting()) {
return $this->missingMethod();
}
return view('flare::admin.modeladmin.all', [
'modelItems' => $this->modelAdmin->allItems(),
'totals' => $this->modelAdmin->totals(),
]
);
} | php | public function getAll()
{
if (!$this->modelAdmin->hasSoftDeleting()) {
return $this->missingMethod();
}
return view('flare::admin.modeladmin.all', [
'modelItems' => $this->modelAdmin->allItems(),
'totals' => $this->modelAdmin->totals(),
]
);
} | [
"public",
"function",
"getAll",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasSoftDeleting",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"return",
"view",
"(",
"'flare::admin.modeladmi... | List All Model Items inc Trashed.
@return \Illuminate\Http\Response | [
"List",
"All",
"Model",
"Items",
"inc",
"Trashed",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L84-L95 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.postCreate | public function postCreate(ModelCreateRequest $request)
{
if (!$this->modelAdmin->hasCreating()) {
return $this->missingMethod();
}
$this->modelAdmin->create();
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully created.', 'dismissable' => false]]);
} | php | public function postCreate(ModelCreateRequest $request)
{
if (!$this->modelAdmin->hasCreating()) {
return $this->missingMethod();
}
$this->modelAdmin->create();
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully created.', 'dismissable' => false]]);
} | [
"public",
"function",
"postCreate",
"(",
"ModelCreateRequest",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasCreating",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"$",
"t... | Receive new Model Entry Post Data, validate it and return user.
@return \Illuminate\Http\RedirectResponse | [
"Receive",
"new",
"Model",
"Entry",
"Post",
"Data",
"validate",
"it",
"and",
"return",
"user",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L116-L125 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.getView | public function getView($modelitemId)
{
if (!$this->modelAdmin->hasViewing()) {
return $this->missingMethod();
}
$this->modelAdmin->find($modelitemId);
event(new ModelView($this->modelAdmin));
return view('flare::admin.modeladmin.view', ['modelItem' => $this->modelAdmin->model]);
} | php | public function getView($modelitemId)
{
if (!$this->modelAdmin->hasViewing()) {
return $this->missingMethod();
}
$this->modelAdmin->find($modelitemId);
event(new ModelView($this->modelAdmin));
return view('flare::admin.modeladmin.view', ['modelItem' => $this->modelAdmin->model]);
} | [
"public",
"function",
"getView",
"(",
"$",
"modelitemId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasViewing",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"$",
"this",
"->",
"modelAd... | View a Model Entry from ModelAdmin View Page.
@return \Illuminate\Http\Response | [
"View",
"a",
"Model",
"Entry",
"from",
"ModelAdmin",
"View",
"Page",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L132-L143 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.getEdit | public function getEdit($modelitemId)
{
if (!$this->modelAdmin->hasEditing()) {
return $this->missingMethod();
}
$this->modelAdmin->find($modelitemId);
return view('flare::admin.modeladmin.edit', ['modelItem' => $this->modelAdmin->model]);
} | php | public function getEdit($modelitemId)
{
if (!$this->modelAdmin->hasEditing()) {
return $this->missingMethod();
}
$this->modelAdmin->find($modelitemId);
return view('flare::admin.modeladmin.edit', ['modelItem' => $this->modelAdmin->model]);
} | [
"public",
"function",
"getEdit",
"(",
"$",
"modelitemId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasEditing",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"$",
"this",
"->",
"modelAd... | Edit Model Entry from ModelAdmin Edit Page.
@param int $modelitemId
@return \Illuminate\Http\Response | [
"Edit",
"Model",
"Entry",
"from",
"ModelAdmin",
"Edit",
"Page",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L152-L161 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.postEdit | public function postEdit(ModelEditRequest $request, $modelitemId)
{
if (!$this->modelAdmin->hasEditing()) {
return $this->missingMethod();
}
$this->modelAdmin->edit($modelitemId);
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully updated.', 'dismissable' => false]]);
} | php | public function postEdit(ModelEditRequest $request, $modelitemId)
{
if (!$this->modelAdmin->hasEditing()) {
return $this->missingMethod();
}
$this->modelAdmin->edit($modelitemId);
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully updated.', 'dismissable' => false]]);
} | [
"public",
"function",
"postEdit",
"(",
"ModelEditRequest",
"$",
"request",
",",
"$",
"modelitemId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasEditing",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",... | Receive Model Entry Update Post Data, validate it and return user.
@param int $modelitemId
@return \Illuminate\Http\RedirectResponse | [
"Receive",
"Model",
"Entry",
"Update",
"Post",
"Data",
"validate",
"it",
"and",
"return",
"user",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L170-L179 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.getDelete | public function getDelete($modelitemId)
{
if (!$this->modelAdmin->hasDeleting()) {
return $this->missingMethod();
}
if ($this->modelAdmin->hasSoftDeleting()) {
$this->modelAdmin->findWithTrashed($modelitemId);
} else {
$this->modelAdmin->find($modelitemId);
}
return view('flare::admin.modeladmin.delete', ['modelItem' => $this->modelAdmin->model]);
} | php | public function getDelete($modelitemId)
{
if (!$this->modelAdmin->hasDeleting()) {
return $this->missingMethod();
}
if ($this->modelAdmin->hasSoftDeleting()) {
$this->modelAdmin->findWithTrashed($modelitemId);
} else {
$this->modelAdmin->find($modelitemId);
}
return view('flare::admin.modeladmin.delete', ['modelItem' => $this->modelAdmin->model]);
} | [
"public",
"function",
"getDelete",
"(",
"$",
"modelitemId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasDeleting",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
... | Delete Model Entry from ModelAdmin Delete Page.
@param int $modelitemId
@return \Illuminate\Http\Response | [
"Delete",
"Model",
"Entry",
"from",
"ModelAdmin",
"Delete",
"Page",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L188-L201 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.postDelete | public function postDelete($modelitemId)
{
if (!$this->modelAdmin->hasDeleting()) {
return $this->missingMethod();
}
$this->modelAdmin->delete($modelitemId);
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully removed.', 'dismissable' => false]]);
} | php | public function postDelete($modelitemId)
{
if (!$this->modelAdmin->hasDeleting()) {
return $this->missingMethod();
}
$this->modelAdmin->delete($modelitemId);
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully removed.', 'dismissable' => false]]);
} | [
"public",
"function",
"postDelete",
"(",
"$",
"modelitemId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasDeleting",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"$",
"this",
"->",
"mod... | Receive Model Entry Delete Post Data, validate it and return user.
@param int $modelitemId
@return \Illuminate\Http\RedirectResponse | [
"Receive",
"Model",
"Entry",
"Delete",
"Post",
"Data",
"validate",
"it",
"and",
"return",
"user",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L210-L219 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.getRestore | public function getRestore($modelitemId)
{
if (!$this->modelAdmin->hasSoftDeleting()) {
return $this->missingMethod();
}
return view('flare::admin.modeladmin.restore', ['modelItem' => $this->modelAdmin->model]);
} | php | public function getRestore($modelitemId)
{
if (!$this->modelAdmin->hasSoftDeleting()) {
return $this->missingMethod();
}
return view('flare::admin.modeladmin.restore', ['modelItem' => $this->modelAdmin->model]);
} | [
"public",
"function",
"getRestore",
"(",
"$",
"modelitemId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasSoftDeleting",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"return",
"view",
"("... | Restore a ModelItem.
@param int $modelitemId
@return \Illuminate\Http\Response | [
"Restore",
"a",
"ModelItem",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L228-L235 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.postRestore | public function postRestore($modelitemId)
{
if (!$this->modelAdmin->hasSoftDeleting()) {
return $this->missingMethod();
}
$this->modelAdmin->restore($modelitemId);
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully restored.', 'dismissable' => false]]);
} | php | public function postRestore($modelitemId)
{
if (!$this->modelAdmin->hasSoftDeleting()) {
return $this->missingMethod();
}
$this->modelAdmin->restore($modelitemId);
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully restored.', 'dismissable' => false]]);
} | [
"public",
"function",
"postRestore",
"(",
"$",
"modelitemId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasSoftDeleting",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"$",
"this",
"->",
... | Process Restore ModelItem Request.
@param int $page_id
@return \Illuminate\Http\RedirectResponse | [
"Process",
"Restore",
"ModelItem",
"Request",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L244-L253 | train |
laravelflare/flare | src/Flare/Admin/Models/ModelAdminController.php | ModelAdminController.getClone | public function getClone($modelitemId)
{
if (!$this->modelAdmin->hasCloning()) {
return $this->missingMethod();
}
$this->modelAdmin->clone($modelitemId);
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully cloned.', 'dismissable' => false]]);
} | php | public function getClone($modelitemId)
{
if (!$this->modelAdmin->hasCloning()) {
return $this->missingMethod();
}
$this->modelAdmin->clone($modelitemId);
return redirect($this->modelAdmin->currentUrl())->with('notifications_below_header', [['type' => 'success', 'icon' => 'check-circle', 'title' => 'Success!', 'message' => 'The '.$this->modelAdmin->getTitle().' was successfully cloned.', 'dismissable' => false]]);
} | [
"public",
"function",
"getClone",
"(",
"$",
"modelitemId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelAdmin",
"->",
"hasCloning",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"missingMethod",
"(",
")",
";",
"}",
"$",
"this",
"->",
"modelA... | Clone a Page.
@param int $modelitemId
@return \Illuminate\Http\Response | [
"Clone",
"a",
"Page",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdminController.php#L262-L271 | train |
ARCANEDEV/LaravelImpersonator | src/Impersonator.php | Impersonator.start | public function start(Impersonatable $impersonater, Impersonatable $impersonated)
{
$this->checkImpersonation($impersonater, $impersonated);
try {
session()->put($this->getSessionKey(), $impersonater->getAuthIdentifier());
$this->auth()->silentLogout();
$this->auth()->silentLogin($impersonated);
$this->events()->dispatch(
new Events\ImpersonationStarted($impersonater, $impersonated)
);
return true;
}
catch (\Exception $e) {
return false;
}
} | php | public function start(Impersonatable $impersonater, Impersonatable $impersonated)
{
$this->checkImpersonation($impersonater, $impersonated);
try {
session()->put($this->getSessionKey(), $impersonater->getAuthIdentifier());
$this->auth()->silentLogout();
$this->auth()->silentLogin($impersonated);
$this->events()->dispatch(
new Events\ImpersonationStarted($impersonater, $impersonated)
);
return true;
}
catch (\Exception $e) {
return false;
}
} | [
"public",
"function",
"start",
"(",
"Impersonatable",
"$",
"impersonater",
",",
"Impersonatable",
"$",
"impersonated",
")",
"{",
"$",
"this",
"->",
"checkImpersonation",
"(",
"$",
"impersonater",
",",
"$",
"impersonated",
")",
";",
"try",
"{",
"session",
"(",
... | Start the impersonation.
@param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonater
@param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonated
@return bool | [
"Start",
"the",
"impersonation",
"."
] | f72bc3f1bcd11530887b23f62a9975c6321efdf8 | https://github.com/ARCANEDEV/LaravelImpersonator/blob/f72bc3f1bcd11530887b23f62a9975c6321efdf8/src/Impersonator.php#L115-L133 | train |
ARCANEDEV/LaravelImpersonator | src/Impersonator.php | Impersonator.stop | public function stop()
{
try {
$impersonated = $this->auth()->user();
$impersonater = $this->findUserById($this->getImpersonatorId());
$this->auth()->silentLogout();
$this->auth()->silentLogin($impersonater);
$this->clear();
$this->events()->dispatch(
new Events\ImpersonationStopped($impersonater, $impersonated)
);
return true;
}
catch (\Exception $e) {
return false;
}
} | php | public function stop()
{
try {
$impersonated = $this->auth()->user();
$impersonater = $this->findUserById($this->getImpersonatorId());
$this->auth()->silentLogout();
$this->auth()->silentLogin($impersonater);
$this->clear();
$this->events()->dispatch(
new Events\ImpersonationStopped($impersonater, $impersonated)
);
return true;
}
catch (\Exception $e) {
return false;
}
} | [
"public",
"function",
"stop",
"(",
")",
"{",
"try",
"{",
"$",
"impersonated",
"=",
"$",
"this",
"->",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"$",
"impersonater",
"=",
"$",
"this",
"->",
"findUserById",
"(",
"$",
"this",
"->",
"getImpersonator... | Stop the impersonation.
@return bool | [
"Stop",
"the",
"impersonation",
"."
] | f72bc3f1bcd11530887b23f62a9975c6321efdf8 | https://github.com/ARCANEDEV/LaravelImpersonator/blob/f72bc3f1bcd11530887b23f62a9975c6321efdf8/src/Impersonator.php#L140-L159 | train |
ARCANEDEV/LaravelImpersonator | src/Impersonator.php | Impersonator.checkImpersonation | private function checkImpersonation(Impersonatable $impersonater, Impersonatable $impersonated)
{
$this->mustBeEnabled();
$this->mustBeDifferentImpersonatable($impersonater, $impersonated);
$this->checkImpersonater($impersonater);
$this->checkImpersonated($impersonated);
} | php | private function checkImpersonation(Impersonatable $impersonater, Impersonatable $impersonated)
{
$this->mustBeEnabled();
$this->mustBeDifferentImpersonatable($impersonater, $impersonated);
$this->checkImpersonater($impersonater);
$this->checkImpersonated($impersonated);
} | [
"private",
"function",
"checkImpersonation",
"(",
"Impersonatable",
"$",
"impersonater",
",",
"Impersonatable",
"$",
"impersonated",
")",
"{",
"$",
"this",
"->",
"mustBeEnabled",
"(",
")",
";",
"$",
"this",
"->",
"mustBeDifferentImpersonatable",
"(",
"$",
"imperso... | Check the impersonation.
@param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonater
@param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonated | [
"Check",
"the",
"impersonation",
"."
] | f72bc3f1bcd11530887b23f62a9975c6321efdf8 | https://github.com/ARCANEDEV/LaravelImpersonator/blob/f72bc3f1bcd11530887b23f62a9975c6321efdf8/src/Impersonator.php#L219-L225 | train |
ARCANEDEV/LaravelImpersonator | src/Impersonator.php | Impersonator.mustBeDifferentImpersonatable | private function mustBeDifferentImpersonatable(Impersonatable $impersonater, Impersonatable $impersonated)
{
if ($impersonater->getAuthIdentifier() == $impersonated->getAuthIdentifier())
throw new Exceptions\ImpersonationException(
'The impersonater & impersonated with must be different.'
);
} | php | private function mustBeDifferentImpersonatable(Impersonatable $impersonater, Impersonatable $impersonated)
{
if ($impersonater->getAuthIdentifier() == $impersonated->getAuthIdentifier())
throw new Exceptions\ImpersonationException(
'The impersonater & impersonated with must be different.'
);
} | [
"private",
"function",
"mustBeDifferentImpersonatable",
"(",
"Impersonatable",
"$",
"impersonater",
",",
"Impersonatable",
"$",
"impersonated",
")",
"{",
"if",
"(",
"$",
"impersonater",
"->",
"getAuthIdentifier",
"(",
")",
"==",
"$",
"impersonated",
"->",
"getAuthId... | Check the impersonater and the impersonated are different.
@param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonater
@param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonated
@throws \Arcanedev\LaravelImpersonator\Exceptions\ImpersonationException | [
"Check",
"the",
"impersonater",
"and",
"the",
"impersonated",
"are",
"different",
"."
] | f72bc3f1bcd11530887b23f62a9975c6321efdf8 | https://github.com/ARCANEDEV/LaravelImpersonator/blob/f72bc3f1bcd11530887b23f62a9975c6321efdf8/src/Impersonator.php#L248-L254 | train |
phptuts/StarterBundleForSymfony | src/Service/UserService.php | UserService.searchUser | public function searchUser($searchTerm, $page = 1, $limit = 10)
{
$total = $this->userRepository->countNumberOfUserInSearch($searchTerm);
$users = $this->userRepository->searchUsers($searchTerm, $page, $limit);
$results = [];
foreach ($users as $user) {
$results[] = $user->listView();
}
return new PageModel($results, $page, $total, $limit, 'users');
} | php | public function searchUser($searchTerm, $page = 1, $limit = 10)
{
$total = $this->userRepository->countNumberOfUserInSearch($searchTerm);
$users = $this->userRepository->searchUsers($searchTerm, $page, $limit);
$results = [];
foreach ($users as $user) {
$results[] = $user->listView();
}
return new PageModel($results, $page, $total, $limit, 'users');
} | [
"public",
"function",
"searchUser",
"(",
"$",
"searchTerm",
",",
"$",
"page",
"=",
"1",
",",
"$",
"limit",
"=",
"10",
")",
"{",
"$",
"total",
"=",
"$",
"this",
"->",
"userRepository",
"->",
"countNumberOfUserInSearch",
"(",
"$",
"searchTerm",
")",
";",
... | Return a paginator of users
@param $searchTerm
@param int $page
@param int $limit
@return PageModel | [
"Return",
"a",
"paginator",
"of",
"users"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/UserService.php#L199-L212 | train |
phptuts/StarterBundleForSymfony | src/Service/UserService.php | UserService.registerUser | public function registerUser(BaseUser $user, $source = self::SOURCE_TYPE_WEBSITE)
{
$user->setRoles(["ROLE_USER"])
->setSource($source)
->setEnabled(true);
$this->saveUserWithPlainPassword($user);
$this->dispatcher->dispatch(self::REGISTER_EVENT, new UserEvent($user));
return $user;
} | php | public function registerUser(BaseUser $user, $source = self::SOURCE_TYPE_WEBSITE)
{
$user->setRoles(["ROLE_USER"])
->setSource($source)
->setEnabled(true);
$this->saveUserWithPlainPassword($user);
$this->dispatcher->dispatch(self::REGISTER_EVENT, new UserEvent($user));
return $user;
} | [
"public",
"function",
"registerUser",
"(",
"BaseUser",
"$",
"user",
",",
"$",
"source",
"=",
"self",
"::",
"SOURCE_TYPE_WEBSITE",
")",
"{",
"$",
"user",
"->",
"setRoles",
"(",
"[",
"\"ROLE_USER\"",
"]",
")",
"->",
"setSource",
"(",
"$",
"source",
")",
"-... | Saves a new user to our database
@param BaseUser $user
@param string $source
@return BaseUser | [
"Saves",
"a",
"new",
"user",
"to",
"our",
"database"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/UserService.php#L270-L281 | train |
phptuts/StarterBundleForSymfony | src/Service/UserService.php | UserService.saveUserForResetPassword | public function saveUserForResetPassword(BaseUser $user)
{
$user->setForgetPasswordToken(null)
->setForgetPasswordExpired(null);
$this->saveUserWithPlainPassword($user);
} | php | public function saveUserForResetPassword(BaseUser $user)
{
$user->setForgetPasswordToken(null)
->setForgetPasswordExpired(null);
$this->saveUserWithPlainPassword($user);
} | [
"public",
"function",
"saveUserForResetPassword",
"(",
"BaseUser",
"$",
"user",
")",
"{",
"$",
"user",
"->",
"setForgetPasswordToken",
"(",
"null",
")",
"->",
"setForgetPasswordExpired",
"(",
"null",
")",
";",
"$",
"this",
"->",
"saveUserWithPlainPassword",
"(",
... | Makes sure the forget password token and forget password token expiration time are set to null
@param BaseUser $user | [
"Makes",
"sure",
"the",
"forget",
"password",
"token",
"and",
"forget",
"password",
"token",
"expiration",
"time",
"are",
"set",
"to",
"null"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/UserService.php#L308-L314 | train |
phptuts/StarterBundleForSymfony | src/Service/UserService.php | UserService.updateUserRefreshToken | public function updateUserRefreshToken(BaseUser $user)
{
if (!$user->isRefreshTokenValid()) {
$user->setRefreshToken(bin2hex(random_bytes(90)));
}
$expirationDate = new \DateTime();
$expirationDate->modify('+' . $this->refreshTokenTTL . ' seconds');
$user->setRefreshTokenExpire($expirationDate);
$this->save($user);
return $user;
} | php | public function updateUserRefreshToken(BaseUser $user)
{
if (!$user->isRefreshTokenValid()) {
$user->setRefreshToken(bin2hex(random_bytes(90)));
}
$expirationDate = new \DateTime();
$expirationDate->modify('+' . $this->refreshTokenTTL . ' seconds');
$user->setRefreshTokenExpire($expirationDate);
$this->save($user);
return $user;
} | [
"public",
"function",
"updateUserRefreshToken",
"(",
"BaseUser",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"$",
"user",
"->",
"isRefreshTokenValid",
"(",
")",
")",
"{",
"$",
"user",
"->",
"setRefreshToken",
"(",
"bin2hex",
"(",
"random_bytes",
"(",
"90",
")",... | Saves the user with an updated refresh token
@param BaseUser|RefreshTokenTrait $user
@return BaseUser | [
"Saves",
"the",
"user",
"with",
"an",
"updated",
"refresh",
"token"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/UserService.php#L323-L335 | train |
Mihai-P/yii2-core | models/Email.php | Email.create | public static function create()
{
$email = new static();
$email->from(Yii::$app->params['mandrill']['from_name'], Yii::$app->params['mandrill']['from_email']);
return $email;
} | php | public static function create()
{
$email = new static();
$email->from(Yii::$app->params['mandrill']['from_name'], Yii::$app->params['mandrill']['from_email']);
return $email;
} | [
"public",
"static",
"function",
"create",
"(",
")",
"{",
"$",
"email",
"=",
"new",
"static",
"(",
")",
";",
"$",
"email",
"->",
"from",
"(",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'mandrill'",
"]",
"[",
"'from_name'",
"]",
",",
"Yii",
"::",... | Creates a new email model and returns it
@access public
@return $this | [
"Creates",
"a",
"new",
"email",
"model",
"and",
"returns",
"it"
] | c52753c9c8e133b2f1ca708ae02178b51eb2e5a3 | https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/models/Email.php#L88-L93 | train |
Mihai-P/yii2-core | models/Email.php | Email.from | public function from($name, $email)
{
$this->from_email = $email;
$this->from_name = $name;
return $this;
} | php | public function from($name, $email)
{
$this->from_email = $email;
$this->from_name = $name;
return $this;
} | [
"public",
"function",
"from",
"(",
"$",
"name",
",",
"$",
"email",
")",
"{",
"$",
"this",
"->",
"from_email",
"=",
"$",
"email",
";",
"$",
"this",
"->",
"from_name",
"=",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the from fields
Usage:
$email->from('name', 'name@test.com');
@access public
@param string $name the name of the receiver
@param string $email array with the keys email, name
@return $this | [
"Sets",
"the",
"from",
"fields"
] | c52753c9c8e133b2f1ca708ae02178b51eb2e5a3 | https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/models/Email.php#L127-L133 | train |
Mihai-P/yii2-core | models/Email.php | Email.send | public function send()
{
if (!$this->validate()) {
return $this->getErrors();
}
foreach ($this->multipleRecipients as $to) {
$email_copy = clone $this;
if (is_array($to)) {
$email_copy->to_email = $to['email'];
$email_copy->to_name = $to['name'];
} else {
$email_copy->to_email = $to;
$email_copy->to_name = '';
}
$email_copy->save(false);
}
return true;
} | php | public function send()
{
if (!$this->validate()) {
return $this->getErrors();
}
foreach ($this->multipleRecipients as $to) {
$email_copy = clone $this;
if (is_array($to)) {
$email_copy->to_email = $to['email'];
$email_copy->to_name = $to['name'];
} else {
$email_copy->to_email = $to;
$email_copy->to_name = '';
}
$email_copy->save(false);
}
return true;
} | [
"public",
"function",
"send",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getErrors",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"multipleRecipients",
"as",
"$",
"to",
... | Sends the email to the email queue
Usage:
$success = Email::create()
->html("Hello World!!!")
->subject("Hello");
->to(['email' => 'recipient1@biti.ro', 'name' => 'Recipient1'])
->to(['email' => 'recipient2@biti.ro', 'name' => 'Recipient2'])
->send()
if($success) {}
it returns true if it was successful or the errors of the model
@access public
@return mixed | [
"Sends",
"the",
"email",
"to",
"the",
"email",
"queue"
] | c52753c9c8e133b2f1ca708ae02178b51eb2e5a3 | https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/models/Email.php#L171-L189 | train |
Mihai-P/yii2-core | models/Email.php | Email.sendEmail | public function sendEmail()
{
$mandrill = new Mandrill(Yii::$app->params['mandrill']['key']);
$message = [
'html' => $this->html,
'text' => $this->text,
'subject' => $this->subject,
'from_email' => $this->from_email,
'from_name' => $this->from_name,
'track_opens' => true,
'track_clicks' => true,
'auto_text' => true,
'to' => [['email' => $this->to_email, 'name' => $this->to_name]],
'bcc_address' => 'mihai.petrescu@gmail.com',
];
$result = $mandrill->messages->send($message);
if ($result[0]['status'] == 'sent') {
$this->status = 'sent';
} else {
$this->tries++;
}
$this->save();
} | php | public function sendEmail()
{
$mandrill = new Mandrill(Yii::$app->params['mandrill']['key']);
$message = [
'html' => $this->html,
'text' => $this->text,
'subject' => $this->subject,
'from_email' => $this->from_email,
'from_name' => $this->from_name,
'track_opens' => true,
'track_clicks' => true,
'auto_text' => true,
'to' => [['email' => $this->to_email, 'name' => $this->to_name]],
'bcc_address' => 'mihai.petrescu@gmail.com',
];
$result = $mandrill->messages->send($message);
if ($result[0]['status'] == 'sent') {
$this->status = 'sent';
} else {
$this->tries++;
}
$this->save();
} | [
"public",
"function",
"sendEmail",
"(",
")",
"{",
"$",
"mandrill",
"=",
"new",
"Mandrill",
"(",
"Yii",
"::",
"$",
"app",
"->",
"params",
"[",
"'mandrill'",
"]",
"[",
"'key'",
"]",
")",
";",
"$",
"message",
"=",
"[",
"'html'",
"=>",
"$",
"this",
"->... | Tries to send the email to mandril
If it is successful then it updates the email
If it is NOT successful then it updates number of tries
@access public | [
"Tries",
"to",
"send",
"the",
"email",
"to",
"mandril"
] | c52753c9c8e133b2f1ca708ae02178b51eb2e5a3 | https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/models/Email.php#L199-L221 | train |
proem/proem | lib/Proem/Signal/Event.php | Event.haltQueue | public function haltQueue($early = false)
{
if ($early) {
$this->haltedQueueEarly = true;
}
$this->haltedQueue = true;
return $this;
} | php | public function haltQueue($early = false)
{
if ($early) {
$this->haltedQueueEarly = true;
}
$this->haltedQueue = true;
return $this;
} | [
"public",
"function",
"haltQueue",
"(",
"$",
"early",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"early",
")",
"{",
"$",
"this",
"->",
"haltedQueueEarly",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"haltedQueue",
"=",
"true",
";",
"return",
"$",
"this",
... | Set the halt queue flag to true
@param bool $early If true, the queue will be halted prior to the triggers callback being executed | [
"Set",
"the",
"halt",
"queue",
"flag",
"to",
"true"
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Signal/Event.php#L85-L93 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/Searchable.php | Searchable.getElasticaFields | public function getElasticaFields() {
$db = \DataObject::database_fields(get_class($this->owner));
$fields = $this->owner->searchableFields();
$result = new \ArrayObject();
foreach ($fields as $name => $params) {
$type = null;
$spec = array();
if (array_key_exists($name, $db)) {
$class = $db[$name];
if (($pos = strpos($class, '('))) {
$class = substr($class, 0, $pos);
}
if (array_key_exists($class, self::$mappings)) {
$spec['type'] = self::$mappings[$class];
}
}
$result[$name] = $spec;
}
$result['LastEdited'] = array('type' => 'date');
$result['Created'] = array('type' => 'date');
$result['ID'] = array('type' => 'integer');
$result['ParentID'] = array('type' => 'integer');
$result['Sort'] = array('type' => 'integer');
$result['Name'] = array('type' => 'string');
$result['MenuTitle'] = array('type' => 'string');
$result['ShowInSearch'] = array('type' => 'integer');
$result['ClassName'] = array('type' => 'string');
$result['ClassNameHierarchy'] = array('type' => 'string');
$result['SS_Stage'] = array('type' => 'keyword');
$result['PublicView'] = array('type' => 'boolean');
if ($this->owner->hasExtension('Hierarchy') || $this->owner->hasField('ParentID')) {
$result['ParentsHierarchy'] = array('type' => 'long',);
}
// fix up dates
foreach ($result as $field => $spec) {
if (isset($spec['type']) && ($spec['type'] == 'date')) {
$spec['format'] = 'yyyy-MM-dd HH:mm:ss';
$result[$field] = $spec;
}
}
if (isset($result['Content']) && count($result['Content'])) {
$spec = $result['Content'];
$spec['store'] = false;
$result['Content'] = $spec;
}
$this->owner->invokeWithExtensions('updateElasticMappings', $result);
return $result->getArrayCopy();
} | php | public function getElasticaFields() {
$db = \DataObject::database_fields(get_class($this->owner));
$fields = $this->owner->searchableFields();
$result = new \ArrayObject();
foreach ($fields as $name => $params) {
$type = null;
$spec = array();
if (array_key_exists($name, $db)) {
$class = $db[$name];
if (($pos = strpos($class, '('))) {
$class = substr($class, 0, $pos);
}
if (array_key_exists($class, self::$mappings)) {
$spec['type'] = self::$mappings[$class];
}
}
$result[$name] = $spec;
}
$result['LastEdited'] = array('type' => 'date');
$result['Created'] = array('type' => 'date');
$result['ID'] = array('type' => 'integer');
$result['ParentID'] = array('type' => 'integer');
$result['Sort'] = array('type' => 'integer');
$result['Name'] = array('type' => 'string');
$result['MenuTitle'] = array('type' => 'string');
$result['ShowInSearch'] = array('type' => 'integer');
$result['ClassName'] = array('type' => 'string');
$result['ClassNameHierarchy'] = array('type' => 'string');
$result['SS_Stage'] = array('type' => 'keyword');
$result['PublicView'] = array('type' => 'boolean');
if ($this->owner->hasExtension('Hierarchy') || $this->owner->hasField('ParentID')) {
$result['ParentsHierarchy'] = array('type' => 'long',);
}
// fix up dates
foreach ($result as $field => $spec) {
if (isset($spec['type']) && ($spec['type'] == 'date')) {
$spec['format'] = 'yyyy-MM-dd HH:mm:ss';
$result[$field] = $spec;
}
}
if (isset($result['Content']) && count($result['Content'])) {
$spec = $result['Content'];
$spec['store'] = false;
$result['Content'] = $spec;
}
$this->owner->invokeWithExtensions('updateElasticMappings', $result);
return $result->getArrayCopy();
} | [
"public",
"function",
"getElasticaFields",
"(",
")",
"{",
"$",
"db",
"=",
"\\",
"DataObject",
"::",
"database_fields",
"(",
"get_class",
"(",
"$",
"this",
"->",
"owner",
")",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"owner",
"->",
"searchableFiel... | Gets an array of elastic field definitions.
@return array | [
"Gets",
"an",
"array",
"of",
"elastic",
"field",
"definitions",
"."
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/Searchable.php#L52-L114 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/Searchable.php | Searchable.onAfterWrite | public function onAfterWrite() {
if (\Config::inst()->get('ElasticSearch', 'disabled') || !$this->owner->autoIndex()) {
return;
}
$stage = \Versioned::current_stage();
$this->service->index($this->owner, $stage);
} | php | public function onAfterWrite() {
if (\Config::inst()->get('ElasticSearch', 'disabled') || !$this->owner->autoIndex()) {
return;
}
$stage = \Versioned::current_stage();
$this->service->index($this->owner, $stage);
} | [
"public",
"function",
"onAfterWrite",
"(",
")",
"{",
"if",
"(",
"\\",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'ElasticSearch'",
",",
"'disabled'",
")",
"||",
"!",
"$",
"this",
"->",
"owner",
"->",
"autoIndex",
"(",
")",
")",
"{",
"return... | Updates the record in the search index. | [
"Updates",
"the",
"record",
"in",
"the",
"search",
"index",
"."
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/Searchable.php#L211-L218 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/Searchable.php | Searchable.onAfterDelete | public function onAfterDelete() {
if (\Config::inst()->get('ElasticSearch', 'disabled')) {
return;
}
$stage = \Versioned::current_stage();
$this->service->remove($this->owner, $stage);
} | php | public function onAfterDelete() {
if (\Config::inst()->get('ElasticSearch', 'disabled')) {
return;
}
$stage = \Versioned::current_stage();
$this->service->remove($this->owner, $stage);
} | [
"public",
"function",
"onAfterDelete",
"(",
")",
"{",
"if",
"(",
"\\",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'ElasticSearch'",
",",
"'disabled'",
")",
")",
"{",
"return",
";",
"}",
"$",
"stage",
"=",
"\\",
"Versioned",
"::",
"current_sta... | Removes the record from the search index. | [
"Removes",
"the",
"record",
"from",
"the",
"search",
"index",
"."
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/Searchable.php#L223-L230 | train |
russsiq/bixbite | app/Http/Controllers/Admin/UsersController.php | UsersController.massUpdate | public function massUpdate(UsersRequest $request, User $users)
{
$this->authorize('otherUpdate', User::class);
$data = $request->except('_token', 'updated_at', 'image', 'submit');
$users = $users->whereIn('id', $data['users']);
$messages = [];
switch ($data['mass_action']) {
case 'mass_activate':
// if (! $users->update(['approve' => 1])) {
// $messages[] = '!mass_activate';
// }
break;
case 'mass_lock':
// if (! $users->update(['approve' => 0])) {
// $messages[] = '!mass_lock';
// }
break;
case 'mass_delete':
$usersTemp = $users->get();
foreach ($usersTemp as $user) {
if (! $user->delete()) {
$messages[] = '!mass_delete';
}
}
break;
case 'mass_delete_inactive':
// if (! $users->update(['on_mainpage' => 1])) {
// $messages[] = '!mass_delete_inactive';
// }
break;
}
$message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';
return $this->makeRedirect(true, 'admin.users.index', $message);
} | php | public function massUpdate(UsersRequest $request, User $users)
{
$this->authorize('otherUpdate', User::class);
$data = $request->except('_token', 'updated_at', 'image', 'submit');
$users = $users->whereIn('id', $data['users']);
$messages = [];
switch ($data['mass_action']) {
case 'mass_activate':
// if (! $users->update(['approve' => 1])) {
// $messages[] = '!mass_activate';
// }
break;
case 'mass_lock':
// if (! $users->update(['approve' => 0])) {
// $messages[] = '!mass_lock';
// }
break;
case 'mass_delete':
$usersTemp = $users->get();
foreach ($usersTemp as $user) {
if (! $user->delete()) {
$messages[] = '!mass_delete';
}
}
break;
case 'mass_delete_inactive':
// if (! $users->update(['on_mainpage' => 1])) {
// $messages[] = '!mass_delete_inactive';
// }
break;
}
$message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';
return $this->makeRedirect(true, 'admin.users.index', $message);
} | [
"public",
"function",
"massUpdate",
"(",
"UsersRequest",
"$",
"request",
",",
"User",
"$",
"users",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'otherUpdate'",
",",
"User",
"::",
"class",
")",
";",
"$",
"data",
"=",
"$",
"request",
"->",
"except",
... | Mass update the specified resource in storage.
@param \BBCMS\Http\Requests\Admin\UsersRequest $request
@param \BBCMS\Models\User $users
@return \Illuminate\Http\Response | [
"Mass",
"update",
"the",
"specified",
"resource",
"in",
"storage",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Http/Controllers/Admin/UsersController.php#L137-L174 | train |
TypiCMS/Translations | src/Repositories/EloquentTranslation.php | EloquentTranslation.allToArray | public function allToArray($locale, $group, $namespace = null)
{
$args = func_get_args();
$args[] = config('app.locale');
return $this->executeCallback(static::class, __FUNCTION__, $args, function () use ($locale, $group) {
$array = DB::table('translations')
->select(DB::raw("JSON_UNQUOTE(JSON_EXTRACT(`translation`, '$.".$locale."')) AS translation"), 'key')
->where('group', $group)
->pluck('translation', 'key')
->all();
return $array;
});
} | php | public function allToArray($locale, $group, $namespace = null)
{
$args = func_get_args();
$args[] = config('app.locale');
return $this->executeCallback(static::class, __FUNCTION__, $args, function () use ($locale, $group) {
$array = DB::table('translations')
->select(DB::raw("JSON_UNQUOTE(JSON_EXTRACT(`translation`, '$.".$locale."')) AS translation"), 'key')
->where('group', $group)
->pluck('translation', 'key')
->all();
return $array;
});
} | [
"public",
"function",
"allToArray",
"(",
"$",
"locale",
",",
"$",
"group",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"args",
"[",
"]",
"=",
"config",
"(",
"'app.locale'",
")",
";",
"return",
... | Get translations to Array.
@return array | [
"Get",
"translations",
"to",
"Array",
"."
] | 58e2d12b68cb5d09557e4d5cd84a0b0366e040ea | https://github.com/TypiCMS/Translations/blob/58e2d12b68cb5d09557e4d5cd84a0b0366e040ea/src/Repositories/EloquentTranslation.php#L20-L34 | train |
reliv/Rcm | core/src/Entity/PluginWrapper.php | PluginWrapper.setInstance | public function setInstance(PluginInstance $instance)
{
$this->instance = $instance;
$this->pluginInstanceId = $instance->getInstanceId();
} | php | public function setInstance(PluginInstance $instance)
{
$this->instance = $instance;
$this->pluginInstanceId = $instance->getInstanceId();
} | [
"public",
"function",
"setInstance",
"(",
"PluginInstance",
"$",
"instance",
")",
"{",
"$",
"this",
"->",
"instance",
"=",
"$",
"instance",
";",
"$",
"this",
"->",
"pluginInstanceId",
"=",
"$",
"instance",
"->",
"getInstanceId",
"(",
")",
";",
"}"
] | Set the plugin instance to be wrapped
@param PluginInstance $instance Instance to wrap
@return void | [
"Set",
"the",
"plugin",
"instance",
"to",
"be",
"wrapped"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/PluginWrapper.php#L305-L309 | train |
Mihai-P/yii2-core | controllers/TagController.php | TagController.actionList | public function actionList($type, $term)
{
$tags = Tag::find()->where('type = :type AND LOWER(name) LIKE :term AND status<>"deleted"', [':type' => $type, ':term' => '%' . strtolower($term) . '%'])->all();
$response = [];
foreach($tags as $tag) {
$response[] = ["id" => $tag->id, "label" => $tag->name, "value" => $tag->name];
}
Yii::$app->response->format = 'json';
return $response;
} | php | public function actionList($type, $term)
{
$tags = Tag::find()->where('type = :type AND LOWER(name) LIKE :term AND status<>"deleted"', [':type' => $type, ':term' => '%' . strtolower($term) . '%'])->all();
$response = [];
foreach($tags as $tag) {
$response[] = ["id" => $tag->id, "label" => $tag->name, "value" => $tag->name];
}
Yii::$app->response->format = 'json';
return $response;
} | [
"public",
"function",
"actionList",
"(",
"$",
"type",
",",
"$",
"term",
")",
"{",
"$",
"tags",
"=",
"Tag",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'type = :type AND LOWER(name) LIKE :term AND status<>\"deleted\"'",
",",
"[",
"':type'",
"=>",
"$",
"type",
... | Updates the prices of a product
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed | [
"Updates",
"the",
"prices",
"of",
"a",
"product",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | c52753c9c8e133b2f1ca708ae02178b51eb2e5a3 | https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/controllers/TagController.php#L45-L54 | train |
webeweb/core-bundle | Quote/QuoteProvider.php | QuoteProvider.setFilename | protected function setFilename($filename) {
if (false === realpath($filename)) {
throw new FileNotFoundException(sprintf("The file \"%s\" was not found", $filename));
}
$this->filename = realpath($filename);
return $this;
} | php | protected function setFilename($filename) {
if (false === realpath($filename)) {
throw new FileNotFoundException(sprintf("The file \"%s\" was not found", $filename));
}
$this->filename = realpath($filename);
return $this;
} | [
"protected",
"function",
"setFilename",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"false",
"===",
"realpath",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"sprintf",
"(",
"\"The file \\\"%s\\\" was not found\"",
",",
"$",
... | Set the filename.
@param string $filename The filename.
@return QuoteProvider Returns this quote provider.
@throws FileNotFoundException Throws a file not found exception. | [
"Set",
"the",
"filename",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Quote/QuoteProvider.php#L125-L131 | train |
dadajuice/zephyrus | src/Zephyrus/Application/Route.php | Route.match | public function match(string $uri): bool
{
if ($this->uri == $uri) {
return true;
}
$pattern = '/^' . $this->regex . '$/';
return !is_null($this->regex) && preg_match($pattern, $uri);
} | php | public function match(string $uri): bool
{
if ($this->uri == $uri) {
return true;
}
$pattern = '/^' . $this->regex . '$/';
return !is_null($this->regex) && preg_match($pattern, $uri);
} | [
"public",
"function",
"match",
"(",
"string",
"$",
"uri",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"uri",
"==",
"$",
"uri",
")",
"{",
"return",
"true",
";",
"}",
"$",
"pattern",
"=",
"'/^'",
".",
"$",
"this",
"->",
"regex",
".",
"'$... | Verifies if the given uri matches the route definition.
@param string $uri
@return bool | [
"Verifies",
"if",
"the",
"given",
"uri",
"matches",
"the",
"route",
"definition",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Route.php#L41-L48 | train |
dadajuice/zephyrus | src/Zephyrus/Application/Route.php | Route.getArguments | public function getArguments(string $uri, $callback = null): array
{
$values = [];
$pattern = '/^' . $this->regex . '$/';
preg_match_all($pattern, $uri, $matches);
$matchCount = count($matches);
for ($i = 1; $i < $matchCount; ++$i) {
$values[] = (!is_null($callback))
? (new Callback($callback))->execute($matches[$i][0])
: $matches[$i][0];
}
$arguments = [];
$i = 0;
foreach ($this->parameters as $parameter) {
$arguments[$parameter] = $values[$i];
++$i;
}
return $arguments;
} | php | public function getArguments(string $uri, $callback = null): array
{
$values = [];
$pattern = '/^' . $this->regex . '$/';
preg_match_all($pattern, $uri, $matches);
$matchCount = count($matches);
for ($i = 1; $i < $matchCount; ++$i) {
$values[] = (!is_null($callback))
? (new Callback($callback))->execute($matches[$i][0])
: $matches[$i][0];
}
$arguments = [];
$i = 0;
foreach ($this->parameters as $parameter) {
$arguments[$parameter] = $values[$i];
++$i;
}
return $arguments;
} | [
"public",
"function",
"getArguments",
"(",
"string",
"$",
"uri",
",",
"$",
"callback",
"=",
"null",
")",
":",
"array",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"$",
"pattern",
"=",
"'/^'",
".",
"$",
"this",
"->",
"regex",
".",
"'$/'",
";",
"preg_mat... | Retrieves all uri arguments matching the given uri.
@param string $uri
@param null $callback
@return array | [
"Retrieves",
"all",
"uri",
"arguments",
"matching",
"the",
"given",
"uri",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Route.php#L57-L75 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/ResultList.php | ResultList.getDataObjects | public function getDataObjects($limit = 0, $start = 0) {
$pagination = \PaginatedList::create($this->toArrayList())
->setPageLength($limit)
->setPageStart($start)
->setTotalItems($this->getTotalResults())
->setLimitItems(false);
return $pagination;
} | php | public function getDataObjects($limit = 0, $start = 0) {
$pagination = \PaginatedList::create($this->toArrayList())
->setPageLength($limit)
->setPageStart($start)
->setTotalItems($this->getTotalResults())
->setLimitItems(false);
return $pagination;
} | [
"public",
"function",
"getDataObjects",
"(",
"$",
"limit",
"=",
"0",
",",
"$",
"start",
"=",
"0",
")",
"{",
"$",
"pagination",
"=",
"\\",
"PaginatedList",
"::",
"create",
"(",
"$",
"this",
"->",
"toArrayList",
"(",
")",
")",
"->",
"setPageLength",
"(",... | The paginated result set that is rendered onto the search page.
@return PaginatedList | [
"The",
"paginated",
"result",
"set",
"that",
"is",
"rendered",
"onto",
"the",
"search",
"page",
"."
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/ResultList.php#L103-L111 | train |
phptuts/StarterBundleForSymfony | src/Security/Guard/StateLess/ApiGuard.php | ApiGuard.onAuthenticationFailure | public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
$this->dispatcher->dispatch(self::API_GUARD_FAILED, new AuthFailedEvent($request, $exception));
return $this->removeAuthCookieFromResponse(new Response('Authentication Failed', Response::HTTP_FORBIDDEN));
} | php | public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
$this->dispatcher->dispatch(self::API_GUARD_FAILED, new AuthFailedEvent($request, $exception));
return $this->removeAuthCookieFromResponse(new Response('Authentication Failed', Response::HTTP_FORBIDDEN));
} | [
"public",
"function",
"onAuthenticationFailure",
"(",
"Request",
"$",
"request",
",",
"AuthenticationException",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"self",
"::",
"API_GUARD_FAILED",
",",
"new",
"AuthFailedEvent",
"(... | 4a ) This is fired when authentication fails. This can be caused by expired tokens, deleted users, etc
@param Request $request
@param AuthenticationException $exception
@return Response | [
"4a",
")",
"This",
"is",
"fired",
"when",
"authentication",
"fails",
".",
"This",
"can",
"be",
"caused",
"by",
"expired",
"tokens",
"deleted",
"users",
"etc"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/StateLess/ApiGuard.php#L32-L37 | train |
lsv/rejseplan-php-api | src/AbstractCall.php | AbstractCall.setClient | public function setClient(ClientInterface $client = null): self
{
if (null === $client) {
$this->client = new Client();
return $this;
}
$this->client = $client;
return $this;
} | php | public function setClient(ClientInterface $client = null): self
{
if (null === $client) {
$this->client = new Client();
return $this;
}
$this->client = $client;
return $this;
} | [
"public",
"function",
"setClient",
"(",
"ClientInterface",
"$",
"client",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"null",
"===",
"$",
"client",
")",
"{",
"$",
"this",
"->",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"return",
"$",
"this",
... | Set the client used for the operations.
@param ClientInterface|null $client
@return $this | [
"Set",
"the",
"client",
"used",
"for",
"the",
"operations",
"."
] | f09add92e160f167a19ff2a290951d202d7ece67 | https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/AbstractCall.php#L116-L127 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/ElasticaService.php | ElasticaService.index | public function index($record, $stage = 'Stage') {
if (!$this->enabled) {
return;
}
$document = $record->getElasticaDocument($stage);
$type = $record->getElasticaType();
$this->indexDocument($document, $type);
} | php | public function index($record, $stage = 'Stage') {
if (!$this->enabled) {
return;
}
$document = $record->getElasticaDocument($stage);
$type = $record->getElasticaType();
$this->indexDocument($document, $type);
} | [
"public",
"function",
"index",
"(",
"$",
"record",
",",
"$",
"stage",
"=",
"'Stage'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
")",
"{",
"return",
";",
"}",
"$",
"document",
"=",
"$",
"record",
"->",
"getElasticaDocument",
"(",
"$",
... | Either creates or updates a record in the index.
@param Searchable $record | [
"Either",
"creates",
"or",
"updates",
"a",
"record",
"in",
"the",
"index",
"."
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/ElasticaService.php#L93-L101 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/ElasticaService.php | ElasticaService.endBulkIndex | public function endBulkIndex() {
if (!$this->connected) {
return;
}
$index = $this->getIndex();
try {
foreach ($this->buffer as $type => $documents) {
$index->getType($type)->addDocuments($documents);
$index->refresh();
}
} catch (HttpException $ex) {
$this->connected = false;
// TODO LOG THIS ERROR
\SS_Log::log($ex, \SS_Log::ERR);
} catch (\Elastica\Exception\BulkException $be) {
\SS_Log::log($be, \SS_Log::ERR);
throw $be;
}
$this->buffered = false;
$this->buffer = array();
} | php | public function endBulkIndex() {
if (!$this->connected) {
return;
}
$index = $this->getIndex();
try {
foreach ($this->buffer as $type => $documents) {
$index->getType($type)->addDocuments($documents);
$index->refresh();
}
} catch (HttpException $ex) {
$this->connected = false;
// TODO LOG THIS ERROR
\SS_Log::log($ex, \SS_Log::ERR);
} catch (\Elastica\Exception\BulkException $be) {
\SS_Log::log($be, \SS_Log::ERR);
throw $be;
}
$this->buffered = false;
$this->buffer = array();
} | [
"public",
"function",
"endBulkIndex",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"connected",
")",
"{",
"return",
";",
"}",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"bu... | Ends the current bulk index operation and indexes the buffered documents. | [
"Ends",
"the",
"current",
"bulk",
"index",
"operation",
"and",
"indexes",
"the",
"buffered",
"documents",
"."
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/ElasticaService.php#L147-L171 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/ElasticaService.php | ElasticaService.remove | public function remove($record, $stage = 'Stage') {
$index = $this->getIndex();
$type = $index->getType($record->getElasticaType());
try {
$type->deleteDocument($record->getElasticaDocument($stage));
} catch (\Exception $ex) {
\SS_Log::log($ex, \SS_Log::WARN);
return false;
}
return true;
} | php | public function remove($record, $stage = 'Stage') {
$index = $this->getIndex();
$type = $index->getType($record->getElasticaType());
try {
$type->deleteDocument($record->getElasticaDocument($stage));
} catch (\Exception $ex) {
\SS_Log::log($ex, \SS_Log::WARN);
return false;
}
return true;
} | [
"public",
"function",
"remove",
"(",
"$",
"record",
",",
"$",
"stage",
"=",
"'Stage'",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
")",
";",
"$",
"type",
"=",
"$",
"index",
"->",
"getType",
"(",
"$",
"record",
"->",
"getElastic... | Deletes a record from the index.
@param Searchable $record | [
"Deletes",
"a",
"record",
"from",
"the",
"index",
"."
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/ElasticaService.php#L178-L190 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/ElasticaService.php | ElasticaService.define | public function define() {
$index = $this->getIndex();
if (!$index->exists()) {
$index->create();
}
try {
$this->createMappings($index);
} catch (\Elastica\Exception\ResponseException $ex) {
\SS_Log::log($ex, \SS_Log::WARN);
}
} | php | public function define() {
$index = $this->getIndex();
if (!$index->exists()) {
$index->create();
}
try {
$this->createMappings($index);
} catch (\Elastica\Exception\ResponseException $ex) {
\SS_Log::log($ex, \SS_Log::WARN);
}
} | [
"public",
"function",
"define",
"(",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
")",
";",
"if",
"(",
"!",
"$",
"index",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"index",
"->",
"create",
"(",
")",
";",
"}",
"try",
"{",
"$... | Creates the index and the type mappings. | [
"Creates",
"the",
"index",
"and",
"the",
"type",
"mappings",
"."
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/ElasticaService.php#L195-L207 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/ElasticaService.php | ElasticaService.createMappings | protected function createMappings(\Elastica\Index $index) {
foreach ($this->getIndexedClasses() as $class) {
/** @var $sng Searchable */
$sng = singleton($class);
$type = $sng->getElasticaType();
if (isset($this->mappings[$type])) {
// captured later
continue;
}
$mapping = $sng->getElasticaMapping();
$mapping->setType($index->getType($type));
$mapping->send();
}
if ($this->mappings) {
foreach ($this->mappings as $type => $fields) {
$mapping = new Mapping();
$mapping->setProperties($fields);
$mapping->setParam('date_detection', false);
$mapping->setType($index->getType($type));
$mapping->send();
}
}
} | php | protected function createMappings(\Elastica\Index $index) {
foreach ($this->getIndexedClasses() as $class) {
/** @var $sng Searchable */
$sng = singleton($class);
$type = $sng->getElasticaType();
if (isset($this->mappings[$type])) {
// captured later
continue;
}
$mapping = $sng->getElasticaMapping();
$mapping->setType($index->getType($type));
$mapping->send();
}
if ($this->mappings) {
foreach ($this->mappings as $type => $fields) {
$mapping = new Mapping();
$mapping->setProperties($fields);
$mapping->setParam('date_detection', false);
$mapping->setType($index->getType($type));
$mapping->send();
}
}
} | [
"protected",
"function",
"createMappings",
"(",
"\\",
"Elastica",
"\\",
"Index",
"$",
"index",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getIndexedClasses",
"(",
")",
"as",
"$",
"class",
")",
"{",
"/** @var $sng Searchable */",
"$",
"sng",
"=",
"singleto... | Define all known mappings | [
"Define",
"all",
"known",
"mappings"
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/ElasticaService.php#L212-L238 | train |
symbiote-library/silverstripe-elastica | src/Symbiote/Elastica/ElasticaService.php | ElasticaService.refresh | public function refresh($logFunc = null) {
$index = $this->getIndex();
if (!$logFunc) {
$logFunc = function ($msg) {
};
}
foreach ($this->getIndexedClasses() as $class) {
$logFunc("Indexing items of type $class");
$this->startBulkIndex();
foreach ($class::get() as $record) {
$logFunc("Indexing " . $record->Title);
$this->index($record);
}
if (\Object::has_extension($class, 'Versioned')) {
$live = \Versioned::get_by_stage($class, 'Live');
foreach ($live as $liveRecord) {
$logFunc("Indexing Live record " . $liveRecord->Title);
$this->index($liveRecord, 'Live');
}
}
$this->endBulkIndex();
}
} | php | public function refresh($logFunc = null) {
$index = $this->getIndex();
if (!$logFunc) {
$logFunc = function ($msg) {
};
}
foreach ($this->getIndexedClasses() as $class) {
$logFunc("Indexing items of type $class");
$this->startBulkIndex();
foreach ($class::get() as $record) {
$logFunc("Indexing " . $record->Title);
$this->index($record);
}
if (\Object::has_extension($class, 'Versioned')) {
$live = \Versioned::get_by_stage($class, 'Live');
foreach ($live as $liveRecord) {
$logFunc("Indexing Live record " . $liveRecord->Title);
$this->index($liveRecord, 'Live');
}
}
$this->endBulkIndex();
}
} | [
"public",
"function",
"refresh",
"(",
"$",
"logFunc",
"=",
"null",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
")",
";",
"if",
"(",
"!",
"$",
"logFunc",
")",
"{",
"$",
"logFunc",
"=",
"function",
"(",
"$",
"msg",
")",
"{",
... | Re-indexes each record in the index. | [
"Re",
"-",
"indexes",
"each",
"record",
"in",
"the",
"index",
"."
] | 8d978034fb5191d06906206830a80f6caa788f6a | https://github.com/symbiote-library/silverstripe-elastica/blob/8d978034fb5191d06906206830a80f6caa788f6a/src/Symbiote/Elastica/ElasticaService.php#L243-L269 | train |
andreas-glaser/php-helpers | src/DateHelper.php | DateHelper.formatOrNull | public static function formatOrNull($dateTime, $format = 'Y-m-d H:i:s', $null = null)
{
if ($dateTime instanceof \DateTime) {
return $dateTime->format($format);
} elseif (ValueHelper::isDateTime($dateTime)) {
return static::stringToDateTime($dateTime)->format($format);
} else {
return $null;
}
} | php | public static function formatOrNull($dateTime, $format = 'Y-m-d H:i:s', $null = null)
{
if ($dateTime instanceof \DateTime) {
return $dateTime->format($format);
} elseif (ValueHelper::isDateTime($dateTime)) {
return static::stringToDateTime($dateTime)->format($format);
} else {
return $null;
}
} | [
"public",
"static",
"function",
"formatOrNull",
"(",
"$",
"dateTime",
",",
"$",
"format",
"=",
"'Y-m-d H:i:s'",
",",
"$",
"null",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"dateTime",
"instanceof",
"\\",
"DateTime",
")",
"{",
"return",
"$",
"dateTime",
"->"... | Tries to format given input.
@param string|\DateTime $dateTime
@param string $format
@param null $null
@return null|string | [
"Tries",
"to",
"format",
"given",
"input",
"."
] | 84d8b98b72d01c262a5df0fb8545cb80a63afcc4 | https://github.com/andreas-glaser/php-helpers/blob/84d8b98b72d01c262a5df0fb8545cb80a63afcc4/src/DateHelper.php#L35-L44 | train |
reliv/Rcm | core/src/Repository/Domain.php | Domain.getDomainInfo | public function getDomainInfo($domain)
{
try {
$result = $this->getDomainLookupQuery($domain)->getSingleResult();
} catch (NoResultException $e) {
$result = null;
}
return $result;
} | php | public function getDomainInfo($domain)
{
try {
$result = $this->getDomainLookupQuery($domain)->getSingleResult();
} catch (NoResultException $e) {
$result = null;
}
return $result;
} | [
"public",
"function",
"getDomainInfo",
"(",
"$",
"domain",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getDomainLookupQuery",
"(",
"$",
"domain",
")",
"->",
"getSingleResult",
"(",
")",
";",
"}",
"catch",
"(",
"NoResultException",
"$",
... | Get the info for a single domain
@param string $domain Domain name to search by
@return array | [
"Get",
"the",
"info",
"for",
"a",
"single",
"domain"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Domain.php#L48-L57 | train |
reliv/Rcm | core/src/Repository/Domain.php | Domain.getDomainLookupQuery | private function getDomainLookupQuery($domain = null)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select(
'domain.domain,
primary.domain primaryDomain,
language.iso639_2b languageId,
site.siteId,
country.iso3 countryId'
)
->from(\Rcm\Entity\Domain::class, 'domain', 'domain.domain')
->leftJoin('domain.primaryDomain', 'primary')
->leftJoin('domain.defaultLanguage', 'language')
->leftJoin(
\Rcm\Entity\Site::class,
'site',
Join::WITH,
'site.domain = domain.domainId'
)
->leftJoin('site.country', 'country');
if (!empty($domain)) {
$queryBuilder->andWhere('domain.domain = :domain')
->setParameter('domain', $domain);
}
return $queryBuilder->getQuery();
} | php | private function getDomainLookupQuery($domain = null)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select(
'domain.domain,
primary.domain primaryDomain,
language.iso639_2b languageId,
site.siteId,
country.iso3 countryId'
)
->from(\Rcm\Entity\Domain::class, 'domain', 'domain.domain')
->leftJoin('domain.primaryDomain', 'primary')
->leftJoin('domain.defaultLanguage', 'language')
->leftJoin(
\Rcm\Entity\Site::class,
'site',
Join::WITH,
'site.domain = domain.domainId'
)
->leftJoin('site.country', 'country');
if (!empty($domain)) {
$queryBuilder->andWhere('domain.domain = :domain')
->setParameter('domain', $domain);
}
return $queryBuilder->getQuery();
} | [
"private",
"function",
"getDomainLookupQuery",
"(",
"$",
"domain",
"=",
"null",
")",
"{",
"/** @var \\Doctrine\\ORM\\QueryBuilder $queryBuilder */",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"... | Get Doctrine Query Object for Domain Lookups
@param null $domain
@return Query | [
"Get",
"Doctrine",
"Query",
"Object",
"for",
"Domain",
"Lookups"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Domain.php#L66-L95 | train |
reliv/Rcm | core/src/Repository/Domain.php | Domain.searchForDomain | public function searchForDomain($domainSearchParam)
{
$domainsQueryBuilder = $this->createQueryBuilder('domain');
$domainsQueryBuilder->where('domain.domain LIKE :domainSearchParam');
$query = $domainsQueryBuilder->getQuery();
$query->setParameter('domainSearchParam', $domainSearchParam);
return $query->getResult();
} | php | public function searchForDomain($domainSearchParam)
{
$domainsQueryBuilder = $this->createQueryBuilder('domain');
$domainsQueryBuilder->where('domain.domain LIKE :domainSearchParam');
$query = $domainsQueryBuilder->getQuery();
$query->setParameter('domainSearchParam', $domainSearchParam);
return $query->getResult();
} | [
"public",
"function",
"searchForDomain",
"(",
"$",
"domainSearchParam",
")",
"{",
"$",
"domainsQueryBuilder",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'domain'",
")",
";",
"$",
"domainsQueryBuilder",
"->",
"where",
"(",
"'domain.domain LIKE :domainSearchPar... | Search for a domain name by query string.
@param string $domainSearchParam Query String... ie. "domain LIKE '[queryString]"
@return array | [
"Search",
"for",
"a",
"domain",
"name",
"by",
"query",
"string",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Domain.php#L187-L196 | train |
reliv/Rcm | core/src/Repository/Redirect.php | Redirect.getRedirectList | public function getRedirectList($siteId)
{
try {
$result = $this->getQuery($siteId)->getResult();
} catch (NoResultException $e) {
$result = [];
}
return $result;
} | php | public function getRedirectList($siteId)
{
try {
$result = $this->getQuery($siteId)->getResult();
} catch (NoResultException $e) {
$result = [];
}
return $result;
} | [
"public",
"function",
"getRedirectList",
"(",
"$",
"siteId",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getQuery",
"(",
"$",
"siteId",
")",
"->",
"getResult",
"(",
")",
";",
"}",
"catch",
"(",
"NoResultException",
"$",
"e",
")",
"{... | Get Redirect List From DB
@param int $siteId Site Id
@return array
@throws \Rcm\Exception\InvalidArgumentException | [
"Get",
"Redirect",
"List",
"From",
"DB"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Redirect.php#L37-L46 | train |
reliv/Rcm | core/src/Repository/Redirect.php | Redirect.getQuery | private function getQuery($siteId, $url = null)
{
if (empty($siteId) || !is_numeric($siteId)) {
throw new InvalidArgumentException('Invalid Site Id To Search By');
}
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder
->select('r')
->from(\Rcm\Entity\Redirect::class, 'r', 'r.requestUrl')
->leftJoin('r.site', 'site')
->where('r.site = :siteId')
->orWhere('r.site is null')
->orderBy('site.siteId', 'DESC')//Makes site-specific rules take priority
->setMaxResults(1)//Improves speed when no match found
->setParameter('siteId', $siteId);
if (!empty($url)) {
$queryBuilder->andWhere('r.requestUrl = :requestUrl');
$queryBuilder->setParameter('requestUrl', $url);
}
return $queryBuilder->getQuery();
} | php | private function getQuery($siteId, $url = null)
{
if (empty($siteId) || !is_numeric($siteId)) {
throw new InvalidArgumentException('Invalid Site Id To Search By');
}
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder
->select('r')
->from(\Rcm\Entity\Redirect::class, 'r', 'r.requestUrl')
->leftJoin('r.site', 'site')
->where('r.site = :siteId')
->orWhere('r.site is null')
->orderBy('site.siteId', 'DESC')//Makes site-specific rules take priority
->setMaxResults(1)//Improves speed when no match found
->setParameter('siteId', $siteId);
if (!empty($url)) {
$queryBuilder->andWhere('r.requestUrl = :requestUrl');
$queryBuilder->setParameter('requestUrl', $url);
}
return $queryBuilder->getQuery();
} | [
"private",
"function",
"getQuery",
"(",
"$",
"siteId",
",",
"$",
"url",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"siteId",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"siteId",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"... | Get Doctrine Query
@param int $siteId Site Id For Search
@param null $url Url for search
@return \Doctrine\ORM\Query | [
"Get",
"Doctrine",
"Query"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Redirect.php#L136-L161 | train |
abandroid/open-weather-map | src/Client.php | Client.query | public function query($name, $parameters = [])
{
if (!isset($parameters['APPID'])) {
$parameters['APPID'] = $this->apiKey;
}
if (!isset($parameters['units'])) {
$parameters['units'] = $this->units;
}
if (!isset($parameters['lang'])) {
$parameters['lang'] = $this->lang;
}
$baseUrl = $this->apiUrl.$name;
$requestQueryParts = [];
foreach ($parameters as $key => $value) {
$requestQueryParts[] = $key.'='.rawurlencode($value);
}
$baseUrl .= '?'.implode('&', $requestQueryParts);
$response = $this->guzzleClient->get($baseUrl);
$response = json_decode($response->getBody()->getContents());
return $response;
} | php | public function query($name, $parameters = [])
{
if (!isset($parameters['APPID'])) {
$parameters['APPID'] = $this->apiKey;
}
if (!isset($parameters['units'])) {
$parameters['units'] = $this->units;
}
if (!isset($parameters['lang'])) {
$parameters['lang'] = $this->lang;
}
$baseUrl = $this->apiUrl.$name;
$requestQueryParts = [];
foreach ($parameters as $key => $value) {
$requestQueryParts[] = $key.'='.rawurlencode($value);
}
$baseUrl .= '?'.implode('&', $requestQueryParts);
$response = $this->guzzleClient->get($baseUrl);
$response = json_decode($response->getBody()->getContents());
return $response;
} | [
"public",
"function",
"query",
"(",
"$",
"name",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"parameters",
"[",
"'APPID'",
"]",
")",
")",
"{",
"$",
"parameters",
"[",
"'APPID'",
"]",
"=",
"$",
"this",
"->",... | Performs a query to the OpenWeatherMap API.
@param string $name
@param array $parameters
@return stdClass | [
"Performs",
"a",
"query",
"to",
"the",
"OpenWeatherMap",
"API",
"."
] | 42916dee86ff17519f63daf57d6f50786760f010 | https://github.com/abandroid/open-weather-map/blob/42916dee86ff17519f63daf57d6f50786760f010/src/Client.php#L77-L103 | train |
abandroid/open-weather-map | src/Client.php | Client.getForecast | public function getForecast($city, $days = null, $parameters = [])
{
if ($days) {
if (!empty($parameters)) {
$parameters['cnt'] = $days;
} else {
$parameters = ['cnt' => $days];
}
}
return $this->doGenericQuery('forecast/daily', $city, $parameters);
} | php | public function getForecast($city, $days = null, $parameters = [])
{
if ($days) {
if (!empty($parameters)) {
$parameters['cnt'] = $days;
} else {
$parameters = ['cnt' => $days];
}
}
return $this->doGenericQuery('forecast/daily', $city, $parameters);
} | [
"public",
"function",
"getForecast",
"(",
"$",
"city",
",",
"$",
"days",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"days",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"param... | Returns the forecast for a city.
@param string $city
@param int $days
@param array $parameters
@return stdClass | [
"Returns",
"the",
"forecast",
"for",
"a",
"city",
"."
] | 42916dee86ff17519f63daf57d6f50786760f010 | https://github.com/abandroid/open-weather-map/blob/42916dee86ff17519f63daf57d6f50786760f010/src/Client.php#L127-L138 | train |
dadajuice/zephyrus | src/Zephyrus/Network/Router.php | Router.post | public function post($uri, $callback, $acceptedFormats = null)
{
parent::addRoute('POST', $uri, $callback, $acceptedFormats);
} | php | public function post($uri, $callback, $acceptedFormats = null)
{
parent::addRoute('POST', $uri, $callback, $acceptedFormats);
} | [
"public",
"function",
"post",
"(",
"$",
"uri",
",",
"$",
"callback",
",",
"$",
"acceptedFormats",
"=",
"null",
")",
"{",
"parent",
"::",
"addRoute",
"(",
"'POST'",
",",
"$",
"uri",
",",
"$",
"callback",
",",
"$",
"acceptedFormats",
")",
";",
"}"
] | Add a new POST route for the application. The POST method must be
used to create a new entry in a collection. Rarely used on a
specific resource.
E.g. POST /books
@param string $uri
@param callable $callback
@param string| array | null $acceptedFormats | [
"Add",
"a",
"new",
"POST",
"route",
"for",
"the",
"application",
".",
"The",
"POST",
"method",
"must",
"be",
"used",
"to",
"create",
"a",
"new",
"entry",
"in",
"a",
"collection",
".",
"Rarely",
"used",
"on",
"a",
"specific",
"resource",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Network/Router.php#L36-L39 | train |
webeweb/core-bundle | Icon/IconFactory.php | IconFactory.parseFontAwesomeIcon | public static function parseFontAwesomeIcon(array $args) {
$icon = static::newFontAwesomeIcon();
$icon->setName(ArrayHelper::get($args, "name", "home"));
$icon->setStyle(ArrayHelper::get($args, "style"));
$icon->setAnimation(ArrayHelper::get($args, "animation"));
$icon->setBordered(ArrayHelper::get($args, "bordered", false));
$icon->setFixedWidth(ArrayHelper::get($args, "fixedWidth", false));
$icon->setFont(ArrayHelper::get($args, "font"));
$icon->setPull(ArrayHelper::get($args, "pull"));
$icon->setSize(ArrayHelper::get($args, "size"));
return $icon;
} | php | public static function parseFontAwesomeIcon(array $args) {
$icon = static::newFontAwesomeIcon();
$icon->setName(ArrayHelper::get($args, "name", "home"));
$icon->setStyle(ArrayHelper::get($args, "style"));
$icon->setAnimation(ArrayHelper::get($args, "animation"));
$icon->setBordered(ArrayHelper::get($args, "bordered", false));
$icon->setFixedWidth(ArrayHelper::get($args, "fixedWidth", false));
$icon->setFont(ArrayHelper::get($args, "font"));
$icon->setPull(ArrayHelper::get($args, "pull"));
$icon->setSize(ArrayHelper::get($args, "size"));
return $icon;
} | [
"public",
"static",
"function",
"parseFontAwesomeIcon",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"icon",
"=",
"static",
"::",
"newFontAwesomeIcon",
"(",
")",
";",
"$",
"icon",
"->",
"setName",
"(",
"ArrayHelper",
"::",
"get",
"(",
"$",
"args",
",",
"\"n... | Parses a Font Awesome icon.
@param array $args The arguments.
@return FontAwesomeIconInterface Returns the parsed Font Awesome icon. | [
"Parses",
"a",
"Font",
"Awesome",
"icon",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Icon/IconFactory.php#L52-L67 | train |
webeweb/core-bundle | Icon/IconFactory.php | IconFactory.parseMaterialDesignIconicFontIcon | public static function parseMaterialDesignIconicFontIcon(array $args) {
$icon = static::newMaterialDesignIconicFontIcon();
$icon->setName(ArrayHelper::get($args, "name", "home"));
$icon->setStyle(ArrayHelper::get($args, "style"));
$icon->setBorder(ArrayHelper::get($args, "border", false));
$icon->setFixedWidth(ArrayHelper::get($args, "fixedWidth", false));
$icon->setFlip(ArrayHelper::get($args, "flip"));
$icon->setPull(ArrayHelper::get($args, "pull"));
$icon->setRotate(ArrayHelper::get($args, "rotate"));
$icon->setSize(ArrayHelper::get($args, "size"));
$icon->setSpin(ArrayHelper::get($args, "spin"));
return $icon;
} | php | public static function parseMaterialDesignIconicFontIcon(array $args) {
$icon = static::newMaterialDesignIconicFontIcon();
$icon->setName(ArrayHelper::get($args, "name", "home"));
$icon->setStyle(ArrayHelper::get($args, "style"));
$icon->setBorder(ArrayHelper::get($args, "border", false));
$icon->setFixedWidth(ArrayHelper::get($args, "fixedWidth", false));
$icon->setFlip(ArrayHelper::get($args, "flip"));
$icon->setPull(ArrayHelper::get($args, "pull"));
$icon->setRotate(ArrayHelper::get($args, "rotate"));
$icon->setSize(ArrayHelper::get($args, "size"));
$icon->setSpin(ArrayHelper::get($args, "spin"));
return $icon;
} | [
"public",
"static",
"function",
"parseMaterialDesignIconicFontIcon",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"icon",
"=",
"static",
"::",
"newMaterialDesignIconicFontIcon",
"(",
")",
";",
"$",
"icon",
"->",
"setName",
"(",
"ArrayHelper",
"::",
"get",
"(",
"$... | Parses a Material Design Iconic Font icon.
@param array $args The arguments.
@return MaterialDesignIconicFontIconInterface Returns the parsed Material Design Iconic Font icon. | [
"Parses",
"a",
"Material",
"Design",
"Iconic",
"Font",
"icon",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Icon/IconFactory.php#L75-L91 | train |
reliv/Rcm | core/src/Plugin/BaseController.php | BaseController.renderInstance | public function renderInstance($instanceId, $instanceConfig)
{
$view = new ViewModel(
[
'instanceId' => $instanceId,
'instanceConfig' => $instanceConfig,
'config' => $this->config,
]
);
$view->setTemplate($this->template);
return $view;
} | php | public function renderInstance($instanceId, $instanceConfig)
{
$view = new ViewModel(
[
'instanceId' => $instanceId,
'instanceConfig' => $instanceConfig,
'config' => $this->config,
]
);
$view->setTemplate($this->template);
return $view;
} | [
"public",
"function",
"renderInstance",
"(",
"$",
"instanceId",
",",
"$",
"instanceConfig",
")",
"{",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
"[",
"'instanceId'",
"=>",
"$",
"instanceId",
",",
"'instanceConfig'",
"=>",
"$",
"instanceConfig",
",",
"'config'"... | Reads a plugin instance from persistent storage returns a view model for
it
@param int $instanceId
@param array $instanceConfig
@return ViewModel | [
"Reads",
"a",
"plugin",
"instance",
"from",
"persistent",
"storage",
"returns",
"a",
"view",
"model",
"for",
"it"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Plugin/BaseController.php#L94-L107 | train |
reliv/Rcm | core/src/Plugin/BaseController.php | BaseController.postIsForThisPlugin | public function postIsForThisPlugin()
{
if (!$this->getRequest()->isPost()) {
return false;
}
return
$this->getRequest()->getPost('rcmPluginName') == $this->pluginName;
} | php | public function postIsForThisPlugin()
{
if (!$this->getRequest()->isPost()) {
return false;
}
return
$this->getRequest()->getPost('rcmPluginName') == $this->pluginName;
} | [
"public",
"function",
"postIsForThisPlugin",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"isPost",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getPos... | Is the post for this plugin
@return bool | [
"Is",
"the",
"post",
"for",
"this",
"plugin"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Plugin/BaseController.php#L114-L122 | train |
phptuts/StarterBundleForSymfony | src/Repository/UserRepository.php | UserRepository.findUserByForgetPasswordToken | public function findUserByForgetPasswordToken($token)
{
try {
$builder = $this->createQueryBuilder('u');
return $builder->where($builder->expr()->eq('u.forgetPasswordToken', ':token'))
->andWhere($builder->expr()->isNotNull('u.forgetPasswordExpired'))
->andWhere('u.forgetPasswordExpired >= :today')
->setParameter('token', $token)
->setParameter('today', new \DateTime(), Type::DATETIME)
->getQuery()
->getSingleResult();
} catch (NoResultException $ex) {
// This means that nothing was found this thrown by the getSingleResult method
return null;
} catch (NonUniqueResultException $ex) {
// this means that there was more then one result found and we have duplicate tokens in our database.
// Look up the code for the error message in the logs
throw new ProgrammerException('Duplicate Forget Password Token was found.', ProgrammerException::FORGET_PASSWORD_TOKEN_DUPLICATE_EXCEPTION_CODE);
}
} | php | public function findUserByForgetPasswordToken($token)
{
try {
$builder = $this->createQueryBuilder('u');
return $builder->where($builder->expr()->eq('u.forgetPasswordToken', ':token'))
->andWhere($builder->expr()->isNotNull('u.forgetPasswordExpired'))
->andWhere('u.forgetPasswordExpired >= :today')
->setParameter('token', $token)
->setParameter('today', new \DateTime(), Type::DATETIME)
->getQuery()
->getSingleResult();
} catch (NoResultException $ex) {
// This means that nothing was found this thrown by the getSingleResult method
return null;
} catch (NonUniqueResultException $ex) {
// this means that there was more then one result found and we have duplicate tokens in our database.
// Look up the code for the error message in the logs
throw new ProgrammerException('Duplicate Forget Password Token was found.', ProgrammerException::FORGET_PASSWORD_TOKEN_DUPLICATE_EXCEPTION_CODE);
}
} | [
"public",
"function",
"findUserByForgetPasswordToken",
"(",
"$",
"token",
")",
"{",
"try",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'u'",
")",
";",
"return",
"$",
"builder",
"->",
"where",
"(",
"$",
"builder",
"->",
"expr",
... | Returns a user with the right password token.
If multiple tokens are found in the db a programmer exception is thrown with a specific code.
@param $token
@return null|BaseUser
@throws ProgrammerException | [
"Returns",
"a",
"user",
"with",
"the",
"right",
"password",
"token",
".",
"If",
"multiple",
"tokens",
"are",
"found",
"in",
"the",
"db",
"a",
"programmer",
"exception",
"is",
"thrown",
"with",
"a",
"specific",
"code",
"."
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Repository/UserRepository.php#L72-L93 | train |
phptuts/StarterBundleForSymfony | src/Repository/UserRepository.php | UserRepository.searchUsers | public function searchUsers($searchString = null, $page, $limit)
{
return $this->buildUserSearchQuery($searchString)
->getQuery()
->setMaxResults($limit)
->setFirstResult($limit * ($page - 1))
->getResult();
} | php | public function searchUsers($searchString = null, $page, $limit)
{
return $this->buildUserSearchQuery($searchString)
->getQuery()
->setMaxResults($limit)
->setFirstResult($limit * ($page - 1))
->getResult();
} | [
"public",
"function",
"searchUsers",
"(",
"$",
"searchString",
"=",
"null",
",",
"$",
"page",
",",
"$",
"limit",
")",
"{",
"return",
"$",
"this",
"->",
"buildUserSearchQuery",
"(",
"$",
"searchString",
")",
"->",
"getQuery",
"(",
")",
"->",
"setMaxResults"... | Gets a paginated list of users
@param null $searchString
@param int $page
@param int $limit
@return BaseUser[] | [
"Gets",
"a",
"paginated",
"list",
"of",
"users"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Repository/UserRepository.php#L104-L111 | train |
phptuts/StarterBundleForSymfony | src/Repository/UserRepository.php | UserRepository.countNumberOfUserInSearch | public function countNumberOfUserInSearch($searchString = null)
{
$builder = $this->buildUserSearchQuery($searchString);
return $builder->select($builder->expr()->count('u.id'))
->getQuery()
->getSingleScalarResult();
} | php | public function countNumberOfUserInSearch($searchString = null)
{
$builder = $this->buildUserSearchQuery($searchString);
return $builder->select($builder->expr()->count('u.id'))
->getQuery()
->getSingleScalarResult();
} | [
"public",
"function",
"countNumberOfUserInSearch",
"(",
"$",
"searchString",
"=",
"null",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"buildUserSearchQuery",
"(",
"$",
"searchString",
")",
";",
"return",
"$",
"builder",
"->",
"select",
"(",
"$",
"build... | Counts the number of users in the search
@param string $searchString
@return mixed | [
"Counts",
"the",
"number",
"of",
"users",
"in",
"the",
"search"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Repository/UserRepository.php#L119-L126 | train |
phptuts/StarterBundleForSymfony | src/Repository/UserRepository.php | UserRepository.findUserByValidRefreshToken | public function findUserByValidRefreshToken($token)
{
/** @var BaseUser $user */
$user = $this->findOneBy(['refreshToken' => $token]);
if (!empty($user) && $user->isRefreshTokenValid()) {
return $user;
}
return null;
} | php | public function findUserByValidRefreshToken($token)
{
/** @var BaseUser $user */
$user = $this->findOneBy(['refreshToken' => $token]);
if (!empty($user) && $user->isRefreshTokenValid()) {
return $user;
}
return null;
} | [
"public",
"function",
"findUserByValidRefreshToken",
"(",
"$",
"token",
")",
"{",
"/** @var BaseUser $user */",
"$",
"user",
"=",
"$",
"this",
"->",
"findOneBy",
"(",
"[",
"'refreshToken'",
"=>",
"$",
"token",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"... | Finds a user by refresh token that is not expired
@param $token
@return null|object|BaseUser | [
"Finds",
"a",
"user",
"by",
"refresh",
"token",
"that",
"is",
"not",
"expired"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Repository/UserRepository.php#L154-L164 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelSaving.php | ModelSaving.save | public function save()
{
event(new BeforeSave($this));
$this->beforeSave();
$this->doSave();
$this->afterSave();
event(new AfterSave($this));
} | php | public function save()
{
event(new BeforeSave($this));
$this->beforeSave();
$this->doSave();
$this->afterSave();
event(new AfterSave($this));
} | [
"public",
"function",
"save",
"(",
")",
"{",
"event",
"(",
"new",
"BeforeSave",
"(",
"$",
"this",
")",
")",
";",
"$",
"this",
"->",
"beforeSave",
"(",
")",
";",
"$",
"this",
"->",
"doSave",
"(",
")",
";",
"$",
"this",
"->",
"afterSave",
"(",
")",... | Save Action.
Fires off beforeSave(), doSave() and afterSave()
@return | [
"Save",
"Action",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelSaving.php#L43-L54 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelSaving.php | ModelSaving.afterSave | protected function afterSave()
{
$this->brokenAfterSave = false;
foreach (\Request::except('_token') as $key => $value) {
// Could swap this out for model -> getAttribute, then check if we have an attribute or a relation... getRelationValue() is helpful
if (method_exists($this->model, $key) && is_a(call_user_func_array([$this->model, $key], []), 'Illuminate\Database\Eloquent\Relations\Relation')) {
$this->saveRelation('afterSave', $key, $value);
}
}
} | php | protected function afterSave()
{
$this->brokenAfterSave = false;
foreach (\Request::except('_token') as $key => $value) {
// Could swap this out for model -> getAttribute, then check if we have an attribute or a relation... getRelationValue() is helpful
if (method_exists($this->model, $key) && is_a(call_user_func_array([$this->model, $key], []), 'Illuminate\Database\Eloquent\Relations\Relation')) {
$this->saveRelation('afterSave', $key, $value);
}
}
} | [
"protected",
"function",
"afterSave",
"(",
")",
"{",
"$",
"this",
"->",
"brokenAfterSave",
"=",
"false",
";",
"foreach",
"(",
"\\",
"Request",
"::",
"except",
"(",
"'_token'",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// Could swap this out for... | Method fired after the Save action is complete.
@return | [
"Method",
"fired",
"after",
"the",
"Save",
"action",
"is",
"complete",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelSaving.php#L89-L100 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelSaving.php | ModelSaving.saveRelation | private function saveRelation($action, $key, $value)
{
// Could swap this out for model -> getAttribute, then check if we have an attribute or a relation... getRelationValue() is helpful
if (method_exists($this->model, $key) && is_a(call_user_func_array([$this->model, $key], []), 'Illuminate\Database\Eloquent\Relations\Relation')) {
foreach ($this->{$action.'Relations'} as $relationship => $method) {
if (is_a(call_user_func_array([$this->model, $key], []), 'Illuminate\Database\Eloquent\Relations\\'.$relationship)) {
$this->model->$key()->$method($value);
return;
}
}
}
} | php | private function saveRelation($action, $key, $value)
{
// Could swap this out for model -> getAttribute, then check if we have an attribute or a relation... getRelationValue() is helpful
if (method_exists($this->model, $key) && is_a(call_user_func_array([$this->model, $key], []), 'Illuminate\Database\Eloquent\Relations\Relation')) {
foreach ($this->{$action.'Relations'} as $relationship => $method) {
if (is_a(call_user_func_array([$this->model, $key], []), 'Illuminate\Database\Eloquent\Relations\\'.$relationship)) {
$this->model->$key()->$method($value);
return;
}
}
}
} | [
"private",
"function",
"saveRelation",
"(",
"$",
"action",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"// Could swap this out for model -> getAttribute, then check if we have an attribute or a relation... getRelationValue() is helpful",
"if",
"(",
"method_exists",
"(",
"$",
... | Method fired to Save Relations.
@param string $action The current action (either doSave or afterSave)
@param string $key
@param string $value
@return | [
"Method",
"fired",
"to",
"Save",
"Relations",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelSaving.php#L111-L123 | train |
proem/proem | lib/Proem/Signal/EventManager.php | EventManager.storeCallback | protected function storeCallback(\Closure $callback)
{
$key = md5(microtime());
$this->callbacks[$key] = $callback;
return $key;
} | php | protected function storeCallback(\Closure $callback)
{
$key = md5(microtime());
$this->callbacks[$key] = $callback;
return $key;
} | [
"protected",
"function",
"storeCallback",
"(",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"$",
"key",
"=",
"md5",
"(",
"microtime",
"(",
")",
")",
";",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"key",
"]",
"=",
"$",
"callback",
";",
"return",
"$",
... | Store a callback index by a generated key
@param callable $callback
@return string $key | [
"Store",
"a",
"callback",
"index",
"by",
"a",
"generated",
"key"
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Signal/EventManager.php#L111-L116 | train |
proem/proem | lib/Proem/Signal/EventManager.php | EventManager.pushToQueue | protected function pushToQueue($event, $key, $priority)
{
$end = substr($event, -2);
if (isset($this->queues[$event])) {
if ($end == self::WILDCARD) {
$this->wildcardSearching = true;
$this->queues[$event][] = ['key' => $key, 'priority' => $priority];
} else {
$this->queues[$event]->insert($key, $priority);
}
} else {
if ($end == self::WILDCARD) {
$this->wildcardSearching = true;
$this->queues[$event][] = ['key' => $key, 'priority' => $priority];
} else {
$this->queues[$event] = new PriorityQueue;
$this->queues[$event]->insert($key, $priority);
}
}
} | php | protected function pushToQueue($event, $key, $priority)
{
$end = substr($event, -2);
if (isset($this->queues[$event])) {
if ($end == self::WILDCARD) {
$this->wildcardSearching = true;
$this->queues[$event][] = ['key' => $key, 'priority' => $priority];
} else {
$this->queues[$event]->insert($key, $priority);
}
} else {
if ($end == self::WILDCARD) {
$this->wildcardSearching = true;
$this->queues[$event][] = ['key' => $key, 'priority' => $priority];
} else {
$this->queues[$event] = new PriorityQueue;
$this->queues[$event]->insert($key, $priority);
}
}
} | [
"protected",
"function",
"pushToQueue",
"(",
"$",
"event",
",",
"$",
"key",
",",
"$",
"priority",
")",
"{",
"$",
"end",
"=",
"substr",
"(",
"$",
"event",
",",
"-",
"2",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queues",
"[",
"$",
"... | Store a callback's key and priority in a queue indexed
by the event they are attached to.
@param $event The name of the event this callback is being attached to
@param string $key The key the callback is stored under
@priority The priority this callback has within this queue | [
"Store",
"a",
"callback",
"s",
"key",
"and",
"priority",
"in",
"a",
"queue",
"indexed",
"by",
"the",
"event",
"they",
"are",
"attached",
"to",
"."
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Signal/EventManager.php#L126-L145 | train |
proem/proem | lib/Proem/Signal/EventManager.php | EventManager.remove | public function remove($name)
{
if (isset($this->queues[$name])) {
unset($this->queues[$name]);
}
return $this;
} | php | public function remove($name)
{
if (isset($this->queues[$name])) {
unset($this->queues[$name]);
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queues",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"queues",
"[",
"$",
"name",
"]",
")",
";",
"}",
"return",
... | Remove event listeners from a particular index.
Be aware that removeing listeners from the wildcard '*' will not literally
remove them from *all* events. If they have been attached to a specifically
named event that will need to be removed seperately.
@param string $name | [
"Remove",
"event",
"listeners",
"from",
"a",
"particular",
"index",
"."
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Signal/EventManager.php#L156-L162 | train |
proem/proem | lib/Proem/Signal/EventManager.php | EventManager.getListeners | public function getListeners($name)
{
$listenerMatched = false;
/**
* Do we have an exact match?
*/
if (isset($this->queues[$name])) {
$listenerMatched = true;
}
/**
* Optionally search for wildcard matches.
*/
if ($this->wildcardSearching) {
if ($this->populateQueueFromWildSearch($name)) {
$listenerMatched = true;
}
}
$listeners = [];
if ($listenerMatched) {
foreach ($this->queues[$name] as $key) {
$listeners[] = $this->callbacks[$key];
}
}
return $listeners;
} | php | public function getListeners($name)
{
$listenerMatched = false;
/**
* Do we have an exact match?
*/
if (isset($this->queues[$name])) {
$listenerMatched = true;
}
/**
* Optionally search for wildcard matches.
*/
if ($this->wildcardSearching) {
if ($this->populateQueueFromWildSearch($name)) {
$listenerMatched = true;
}
}
$listeners = [];
if ($listenerMatched) {
foreach ($this->queues[$name] as $key) {
$listeners[] = $this->callbacks[$key];
}
}
return $listeners;
} | [
"public",
"function",
"getListeners",
"(",
"$",
"name",
")",
"{",
"$",
"listenerMatched",
"=",
"false",
";",
"/**\n * Do we have an exact match?\n */",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queues",
"[",
"$",
"name",
"]",
")",
")",
"{",
... | Retrieve listeners by name
@param string $name
@return array $listeners | [
"Retrieve",
"listeners",
"by",
"name"
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Signal/EventManager.php#L170-L198 | train |
proem/proem | lib/Proem/Signal/EventManager.php | EventManager.attach | public function attach($name, \Closure $callback, $priority = 0)
{
$key = $this->storeCallback($callback);
if (is_array($name)) {
foreach ($name as $event) {
$this->pushToQueue($event, $key, $priority);
}
} else {
$this->pushToQueue($name, $key, $priority);
}
return $this;
} | php | public function attach($name, \Closure $callback, $priority = 0)
{
$key = $this->storeCallback($callback);
if (is_array($name)) {
foreach ($name as $event) {
$this->pushToQueue($event, $key, $priority);
}
} else {
$this->pushToQueue($name, $key, $priority);
}
return $this;
} | [
"public",
"function",
"attach",
"(",
"$",
"name",
",",
"\\",
"Closure",
"$",
"callback",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"storeCallback",
"(",
"$",
"callback",
")",
";",
"if",
"(",
"is_array",
"(",
"$",... | Register a listener attached to a particular named event.
All listeners have there callbacks firstly stored within an associative array
using a unique md5 hash as an index and the callback as it's value.
All event names are then stored within an associative array of splpriorityqueues. The
index of these arrays is the name of the event while the value inserted into the queue
is the above metnioned unique md5 hash.
This allows a listener to attach itself to be triggered against multiple events
without having multiple copies of the callback being stored.
Default priority is 0, the higher the number of the priority the earlier the
listener will respond, negative priorities are allowed.
The name option can optionally take the form of an array of events for the listener
to attach itself with. A wildcard '*' is also provided and will attach the
listener to be triggered against all events.
Be aware that attaching a listener to the same event multiple times will trigger
that listener multiple times. This includes using the wildcard.
@param string|array The name(s) of the event(s) to listen for.
@param closure $callback The callback to execute when the event is triggered.
@param int $priority The priority at which to execute this listener. | [
"Register",
"a",
"listener",
"attached",
"to",
"a",
"particular",
"named",
"event",
"."
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Signal/EventManager.php#L227-L240 | train |
reliv/Rcm | http-lib/src/JsonBodyParserMiddleware.php | JsonBodyParserMiddleware.process | public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
$contentType = $request->getHeaderLine('Content-Type');
if (!$this->match($contentType)) {
return $delegate->process($request);
}
$rawBody = (string)$request->getBody();
$parsedBody = json_decode($rawBody, true);
if (!empty($rawBody) && json_last_error() !== JSON_ERROR_NONE) {
$statusCode = 400;
$apiMessage = new HttpStatusCodeApiMessage($statusCode);
$apiMessage->setCode('invalid-json');
$apiMessage->setValue('Invalid JSON');
$apiResponse = $this->newPsrResponseWithTranslatedMessages->__invoke(
null,
$statusCode,
$apiMessage
);
return $apiResponse;
}
$request = $request
->withAttribute('rawBody', $rawBody)
->withParsedBody($parsedBody);
return $delegate->process($request);
} | php | public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
$contentType = $request->getHeaderLine('Content-Type');
if (!$this->match($contentType)) {
return $delegate->process($request);
}
$rawBody = (string)$request->getBody();
$parsedBody = json_decode($rawBody, true);
if (!empty($rawBody) && json_last_error() !== JSON_ERROR_NONE) {
$statusCode = 400;
$apiMessage = new HttpStatusCodeApiMessage($statusCode);
$apiMessage->setCode('invalid-json');
$apiMessage->setValue('Invalid JSON');
$apiResponse = $this->newPsrResponseWithTranslatedMessages->__invoke(
null,
$statusCode,
$apiMessage
);
return $apiResponse;
}
$request = $request
->withAttribute('rawBody', $rawBody)
->withParsedBody($parsedBody);
return $delegate->process($request);
} | [
"public",
"function",
"process",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"DelegateInterface",
"$",
"delegate",
")",
"{",
"$",
"contentType",
"=",
"$",
"request",
"->",
"getHeaderLine",
"(",
"'Content-Type'",
")",
";",
"if",
"(",
"!",
"$",
"this",
... | Adds JSON decoded request body to the request, where appropriate.
@param ServerRequestInterface $request
@param DelegateInterface $delegate
@return ResponseInterface|void | [
"Adds",
"JSON",
"decoded",
"request",
"body",
"to",
"the",
"request",
"where",
"appropriate",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/http-lib/src/JsonBodyParserMiddleware.php#L50-L80 | train |
reliv/Rcm | core/src/Renderer/ContainerRenderer.php | ContainerRenderer.renderContainer | public function renderContainer(
PhpRenderer $view,
$name,
$revisionId = null
) {
$site = $this->getSite($view);
$container = $site->getContainer($name);
$pluginHtml = '';
if (!empty($container)) {
if (empty($revisionId)) {
$revision = $container->getPublishedRevision();
} else {
$revision = $container->getRevisionById($revisionId);
}
$pluginWrapperRows = $revision->getPluginWrappersByRow();
if (!empty($pluginWrapperRows)) {
$pluginHtml = $this->getPluginRowsHtml($view, $pluginWrapperRows);
}
$revisionId = $revision->getRevisionId();
} else {
$revisionId = -1;
}
// The front end demands rows in empty containers
if (empty($pluginHtml)) {
$pluginHtml .= '<div class="row"></div>';
}
return $this->getContainerWrapperHtml(
$revisionId,
$name,
$pluginHtml,
false
);
} | php | public function renderContainer(
PhpRenderer $view,
$name,
$revisionId = null
) {
$site = $this->getSite($view);
$container = $site->getContainer($name);
$pluginHtml = '';
if (!empty($container)) {
if (empty($revisionId)) {
$revision = $container->getPublishedRevision();
} else {
$revision = $container->getRevisionById($revisionId);
}
$pluginWrapperRows = $revision->getPluginWrappersByRow();
if (!empty($pluginWrapperRows)) {
$pluginHtml = $this->getPluginRowsHtml($view, $pluginWrapperRows);
}
$revisionId = $revision->getRevisionId();
} else {
$revisionId = -1;
}
// The front end demands rows in empty containers
if (empty($pluginHtml)) {
$pluginHtml .= '<div class="row"></div>';
}
return $this->getContainerWrapperHtml(
$revisionId,
$name,
$pluginHtml,
false
);
} | [
"public",
"function",
"renderContainer",
"(",
"PhpRenderer",
"$",
"view",
",",
"$",
"name",
",",
"$",
"revisionId",
"=",
"null",
")",
"{",
"$",
"site",
"=",
"$",
"this",
"->",
"getSite",
"(",
"$",
"view",
")",
";",
"$",
"container",
"=",
"$",
"site",... | Render a plugin container
@param PhpRenderer $view
@param string $name Container Name
@param integer $revisionId Revision Id to Render
@return null|string | [
"Render",
"a",
"plugin",
"container"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Renderer/ContainerRenderer.php#L98-L138 | train |
reliv/Rcm | core/src/Renderer/ContainerRenderer.php | ContainerRenderer.isDuplicateCss | protected function isDuplicateCss(
PhpRenderer $view,
$container
) {
/** @var \Zend\View\Helper\HeadLink $headLink */
$headLink = $view->headLink();
$containers = $headLink->getContainer();
foreach ($containers as &$item) {
if (($item->rel == 'stylesheet')
&& ($item->href == $container->href)
) {
return true;
}
}
return false;
} | php | protected function isDuplicateCss(
PhpRenderer $view,
$container
) {
/** @var \Zend\View\Helper\HeadLink $headLink */
$headLink = $view->headLink();
$containers = $headLink->getContainer();
foreach ($containers as &$item) {
if (($item->rel == 'stylesheet')
&& ($item->href == $container->href)
) {
return true;
}
}
return false;
} | [
"protected",
"function",
"isDuplicateCss",
"(",
"PhpRenderer",
"$",
"view",
",",
"$",
"container",
")",
"{",
"/** @var \\Zend\\View\\Helper\\HeadLink $headLink */",
"$",
"headLink",
"=",
"$",
"view",
"->",
"headLink",
"(",
")",
";",
"$",
"containers",
"=",
"$",
... | Check to see if CSS is duplicated
@param PhpRenderer $view
@param \Zend\View\Helper\HeadLink $container Css Headlink
@return bool | [
"Check",
"to",
"see",
"if",
"CSS",
"is",
"duplicated"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Renderer/ContainerRenderer.php#L411-L429 | train |
reliv/Rcm | core/src/Renderer/ContainerRenderer.php | ContainerRenderer.isDuplicateScript | protected function isDuplicateScript(
PhpRenderer $view,
$container
) {
/** @var \Zend\View\Helper\HeadScript $headScript */
$headScript = $view->headScript();
$container = $headScript->getContainer();
foreach ($container as &$item) {
if (($item->source === null)
&& !empty($item->attributes['src'])
&& !empty($container->attributes['src'])
&& ($container->attributes['src'] == $item->attributes['src'])
) {
return true;
}
}
return false;
} | php | protected function isDuplicateScript(
PhpRenderer $view,
$container
) {
/** @var \Zend\View\Helper\HeadScript $headScript */
$headScript = $view->headScript();
$container = $headScript->getContainer();
foreach ($container as &$item) {
if (($item->source === null)
&& !empty($item->attributes['src'])
&& !empty($container->attributes['src'])
&& ($container->attributes['src'] == $item->attributes['src'])
) {
return true;
}
}
return false;
} | [
"protected",
"function",
"isDuplicateScript",
"(",
"PhpRenderer",
"$",
"view",
",",
"$",
"container",
")",
"{",
"/** @var \\Zend\\View\\Helper\\HeadScript $headScript */",
"$",
"headScript",
"=",
"$",
"view",
"->",
"headScript",
"(",
")",
";",
"$",
"container",
"=",... | Check to see if Scripts are duplicated
@param PhpRenderer $view
@param \Zend\View\Helper\HeadScript $container
@return bool | [
"Check",
"to",
"see",
"if",
"Scripts",
"are",
"duplicated"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Renderer/ContainerRenderer.php#L439-L459 | train |
dadajuice/zephyrus | src/Zephyrus/Application/ErrorHandler.php | ErrorHandler.registerError | public function registerError($level, callable $callback)
{
$reflection = new \ReflectionFunction($callback);
$parameters = $reflection->getParameters();
if (count($parameters) > 4) {
throw new \Exception("Specified callback cannot have more than 4 arguments (message, file, line, context)");
}
$this->registeredErrorCallbacks[$level] = $callback;
} | php | public function registerError($level, callable $callback)
{
$reflection = new \ReflectionFunction($callback);
$parameters = $reflection->getParameters();
if (count($parameters) > 4) {
throw new \Exception("Specified callback cannot have more than 4 arguments (message, file, line, context)");
}
$this->registeredErrorCallbacks[$level] = $callback;
} | [
"public",
"function",
"registerError",
"(",
"$",
"level",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"callback",
")",
";",
"$",
"parameters",
"=",
"$",
"reflection",
"->",
"getParameters",... | Register an error level with a specific user defined callback. The
specified callback can have up to 4 arguments, but they are not
required. First provided argument is the message, second is the file
path, third is the line number and the fourth is an error context.
@param int $level
@param callable $callback
@throws \Exception | [
"Register",
"an",
"error",
"level",
"with",
"a",
"specific",
"user",
"defined",
"callback",
".",
"The",
"specified",
"callback",
"can",
"have",
"up",
"to",
"4",
"arguments",
"but",
"they",
"are",
"not",
"required",
".",
"First",
"provided",
"argument",
"is",... | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/ErrorHandler.php#L120-L128 | train |
dadajuice/zephyrus | src/Zephyrus/Application/ErrorHandler.php | ErrorHandler.exceptionHandler | public function exceptionHandler(\Throwable $error)
{
$reflection = new \ReflectionClass($error);
$registeredException = $this->findRegisteredExceptions($reflection);
if (!is_null($registeredException)) {
$registeredException($error);
}
} | php | public function exceptionHandler(\Throwable $error)
{
$reflection = new \ReflectionClass($error);
$registeredException = $this->findRegisteredExceptions($reflection);
if (!is_null($registeredException)) {
$registeredException($error);
}
} | [
"public",
"function",
"exceptionHandler",
"(",
"\\",
"Throwable",
"$",
"error",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"error",
")",
";",
"$",
"registeredException",
"=",
"$",
"this",
"->",
"findRegisteredExceptions",
"(",
... | When an exception is thrown, this method catches it and tries to find
the best user defined callback as a response. If there is no direct
callback associated, it will tries to find a definition within the
Exception class hierarchy. If nothing is found, the default behavior is
to die the script. Should not be called manually. Used as a registered
PHP handler.
@param \Throwable $error
@throws \Throwable | [
"When",
"an",
"exception",
"is",
"thrown",
"this",
"method",
"catches",
"it",
"and",
"tries",
"to",
"find",
"the",
"best",
"user",
"defined",
"callback",
"as",
"a",
"response",
".",
"If",
"there",
"is",
"no",
"direct",
"callback",
"associated",
"it",
"will... | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/ErrorHandler.php#L141-L148 | train |
dadajuice/zephyrus | src/Zephyrus/Application/ErrorHandler.php | ErrorHandler.errorHandler | public function errorHandler($type, ...$args)
{
if (!(error_reporting() & $type)) {
// This error code is not included in error_reporting
return true;
}
if (array_key_exists($type, $this->registeredErrorCallbacks)) {
$callback = $this->registeredErrorCallbacks[$type];
$reflection = new \ReflectionFunction($callback);
$reflection->invokeArgs($args);
return true;
}
return false;
} | php | public function errorHandler($type, ...$args)
{
if (!(error_reporting() & $type)) {
// This error code is not included in error_reporting
return true;
}
if (array_key_exists($type, $this->registeredErrorCallbacks)) {
$callback = $this->registeredErrorCallbacks[$type];
$reflection = new \ReflectionFunction($callback);
$reflection->invokeArgs($args);
return true;
}
return false;
} | [
"public",
"function",
"errorHandler",
"(",
"$",
"type",
",",
"...",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"(",
"error_reporting",
"(",
")",
"&",
"$",
"type",
")",
")",
"{",
"// This error code is not included in error_reporting",
"return",
"true",
";",
"}",... | When an error, a notice or a warning is thrown, this method catches it
and tries to find the a user defined callback matching the PHP internal
error type. Will validate if the raised error type is included in the
error_reporting config. Should not be called manually. Used as a
registered PHP handler.
@param int $type
@throws \Exception
@return bool | [
"When",
"an",
"error",
"a",
"notice",
"or",
"a",
"warning",
"is",
"thrown",
"this",
"method",
"catches",
"it",
"and",
"tries",
"to",
"find",
"the",
"a",
"user",
"defined",
"callback",
"matching",
"the",
"PHP",
"internal",
"error",
"type",
".",
"Will",
"v... | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/ErrorHandler.php#L161-L174 | train |
CHECK24/apitk-common-bundle | ParamConverter/ContextAwareParamConverterTrait.php | ContextAwareParamConverterTrait.initialize | protected function initialize(Request $request, ParamConverter $configuration): void
{
$this->request = $request;
$this->configuration = $configuration;
$this->options = new ParameterBag($configuration->getOptions());
} | php | protected function initialize(Request $request, ParamConverter $configuration): void
{
$this->request = $request;
$this->configuration = $configuration;
$this->options = new ParameterBag($configuration->getOptions());
} | [
"protected",
"function",
"initialize",
"(",
"Request",
"$",
"request",
",",
"ParamConverter",
"$",
"configuration",
")",
":",
"void",
"{",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
";",
"$",
"this",
"->",
"configuration",
"=",
"$",
"configuration",
... | Set request and configuration context as class properties for easy access.
@param Request $request
@param ParamConverter $configuration | [
"Set",
"request",
"and",
"configuration",
"context",
"as",
"class",
"properties",
"for",
"easy",
"access",
"."
] | 4b312eaf26f368db77d2e786c1acf144244c0d21 | https://github.com/CHECK24/apitk-common-bundle/blob/4b312eaf26f368db77d2e786c1acf144244c0d21/ParamConverter/ContextAwareParamConverterTrait.php#L41-L46 | train |
dadajuice/zephyrus | src/Zephyrus/Database/DatabaseStatement.php | DatabaseStatement.next | public function next($fetchStyle = \PDO::FETCH_BOTH)
{
$row = $this->statement->fetch($fetchStyle);
$this->sanitizeOutput($row);
return $row;
} | php | public function next($fetchStyle = \PDO::FETCH_BOTH)
{
$row = $this->statement->fetch($fetchStyle);
$this->sanitizeOutput($row);
return $row;
} | [
"public",
"function",
"next",
"(",
"$",
"fetchStyle",
"=",
"\\",
"PDO",
"::",
"FETCH_BOTH",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"statement",
"->",
"fetch",
"(",
"$",
"fetchStyle",
")",
";",
"$",
"this",
"->",
"sanitizeOutput",
"(",
"$",
"ro... | Return the next row from the current result set obtained from the last
executed query. Automatically strip slashes that would have been stored
in database as escaping.
@param int $fetchStyle
@return array | [
"Return",
"the",
"next",
"row",
"from",
"the",
"current",
"result",
"set",
"obtained",
"from",
"the",
"last",
"executed",
"query",
".",
"Automatically",
"strip",
"slashes",
"that",
"would",
"have",
"been",
"stored",
"in",
"database",
"as",
"escaping",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Database/DatabaseStatement.php#L30-L35 | train |
phptuts/StarterBundleForSymfony | src/Security/Provider/FacebookProvider.php | FacebookProvider.loadUserByUsername | public function loadUserByUsername($username)
{
try {
// If you want to request the user's picture you can picture
// You can also specify the picture height using picture.height(500).width(500)
// Be sure request the scope param in the js
$response = $this->facebookClient->get('/me?fields=email', $username);
$facebookUser = $response->getGraphUser();
$email = $facebookUser->getEmail();
$facebookUserId = $facebookUser->getId();
$user = $this->userService->findByFacebookUserId($facebookUserId);
// We always check their facebook user id first because they could have change their email address
if (!empty($user)) {
return $user;
}
$user = $this->userService->findUserByEmail($email);
// This means that user already register and we need to associate their facebook account to their user entity
if (!empty($user)) {
$this->updateUserWithFacebookId($user, $facebookUserId);
return $user;
}
// This means no user was found and we need to register user with their facebook user id
return $this->registerUser($email, $facebookUserId);
} catch (FacebookResponseException $ex) {
throw new UsernameNotFoundException("Facebook AuthToken Did Not validate, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::FACEBOOK_RESPONSE_EXCEPTION_CODE);
} catch (FacebookSDKException $ex) {
throw new UsernameNotFoundException("Facebook SDK failed, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::FACEBOOK_SDK_EXCEPTION_CODE);
} catch (\Exception $ex) {
throw new UsernameNotFoundException("Something unknown went wrong, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::FACEBOOK_PROVIDER_EXCEPTION);
}
} | php | public function loadUserByUsername($username)
{
try {
// If you want to request the user's picture you can picture
// You can also specify the picture height using picture.height(500).width(500)
// Be sure request the scope param in the js
$response = $this->facebookClient->get('/me?fields=email', $username);
$facebookUser = $response->getGraphUser();
$email = $facebookUser->getEmail();
$facebookUserId = $facebookUser->getId();
$user = $this->userService->findByFacebookUserId($facebookUserId);
// We always check their facebook user id first because they could have change their email address
if (!empty($user)) {
return $user;
}
$user = $this->userService->findUserByEmail($email);
// This means that user already register and we need to associate their facebook account to their user entity
if (!empty($user)) {
$this->updateUserWithFacebookId($user, $facebookUserId);
return $user;
}
// This means no user was found and we need to register user with their facebook user id
return $this->registerUser($email, $facebookUserId);
} catch (FacebookResponseException $ex) {
throw new UsernameNotFoundException("Facebook AuthToken Did Not validate, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::FACEBOOK_RESPONSE_EXCEPTION_CODE);
} catch (FacebookSDKException $ex) {
throw new UsernameNotFoundException("Facebook SDK failed, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::FACEBOOK_SDK_EXCEPTION_CODE);
} catch (\Exception $ex) {
throw new UsernameNotFoundException("Something unknown went wrong, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::FACEBOOK_PROVIDER_EXCEPTION);
}
} | [
"public",
"function",
"loadUserByUsername",
"(",
"$",
"username",
")",
"{",
"try",
"{",
"// If you want to request the user's picture you can picture",
"// You can also specify the picture height using picture.height(500).width(500)",
"// Be sure request the scope param in the js",
"$",
... | 1) We validate the access token by fetching the user information
2) We search for facebook user id and if one is found we return that user
3) Then we search by email and if one is found we update the user to have that facebook user id
4) If nothing is found we register the user with facebook user id
@param string $username The facebook auth token used to fetch the user
@return UserInterface
@throws UsernameNotFoundException if the user is not found | [
"1",
")",
"We",
"validate",
"the",
"access",
"token",
"by",
"fetching",
"the",
"user",
"information",
"2",
")",
"We",
"search",
"for",
"facebook",
"user",
"id",
"and",
"if",
"one",
"is",
"found",
"we",
"return",
"that",
"user",
"3",
")",
"Then",
"we",
... | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Provider/FacebookProvider.php#L50-L84 | train |
phptuts/StarterBundleForSymfony | src/Security/Provider/FacebookProvider.php | FacebookProvider.updateUserWithFacebookId | protected function updateUserWithFacebookId(BaseUser $user, $facebookUserId)
{
$user->setFacebookUserId($facebookUserId);
$this->userService->save($user);
} | php | protected function updateUserWithFacebookId(BaseUser $user, $facebookUserId)
{
$user->setFacebookUserId($facebookUserId);
$this->userService->save($user);
} | [
"protected",
"function",
"updateUserWithFacebookId",
"(",
"BaseUser",
"$",
"user",
",",
"$",
"facebookUserId",
")",
"{",
"$",
"user",
"->",
"setFacebookUserId",
"(",
"$",
"facebookUserId",
")",
";",
"$",
"this",
"->",
"userService",
"->",
"save",
"(",
"$",
"... | Updates the user with their facebook id creating a link between their facebook account and user information.
@param BaseUser $user
@param string $facebookUserId | [
"Updates",
"the",
"user",
"with",
"their",
"facebook",
"id",
"creating",
"a",
"link",
"between",
"their",
"facebook",
"account",
"and",
"user",
"information",
"."
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Provider/FacebookProvider.php#L92-L96 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.