id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
23,100
|
ezsystems/ezcomments-ls-extension
|
classes/ezcomsubscription.php
|
ezcomSubscription.countWithSubscriberID
|
static function countWithSubscriberID( $subscriberID, $languageID =false , $enabled = false )
{
$cond = array();
$cond['subscriber_id'] = $subscriberID;
if ( $enabled !== false )
{
$cond['enabled'] = $enabled;
}
if ( $languageID !== false )
{
$cond['language_id'] = $languageID;
}
$count = eZPersistentObject::count( self::definition(), $cond );
return $count;
}
|
php
|
static function countWithSubscriberID( $subscriberID, $languageID =false , $enabled = false )
{
$cond = array();
$cond['subscriber_id'] = $subscriberID;
if ( $enabled !== false )
{
$cond['enabled'] = $enabled;
}
if ( $languageID !== false )
{
$cond['language_id'] = $languageID;
}
$count = eZPersistentObject::count( self::definition(), $cond );
return $count;
}
|
[
"static",
"function",
"countWithSubscriberID",
"(",
"$",
"subscriberID",
",",
"$",
"languageID",
"=",
"false",
",",
"$",
"enabled",
"=",
"false",
")",
"{",
"$",
"cond",
"=",
"array",
"(",
")",
";",
"$",
"cond",
"[",
"'subscriber_id'",
"]",
"=",
"$",
"subscriberID",
";",
"if",
"(",
"$",
"enabled",
"!==",
"false",
")",
"{",
"$",
"cond",
"[",
"'enabled'",
"]",
"=",
"$",
"enabled",
";",
"}",
"if",
"(",
"$",
"languageID",
"!==",
"false",
")",
"{",
"$",
"cond",
"[",
"'language_id'",
"]",
"=",
"$",
"languageID",
";",
"}",
"$",
"count",
"=",
"eZPersistentObject",
"::",
"count",
"(",
"self",
"::",
"definition",
"(",
")",
",",
"$",
"cond",
")",
";",
"return",
"$",
"count",
";",
"}"
] |
get the count of subscription in a subscriber ID
@param $subscriberID
@param $status
@return unknown_type
|
[
"get",
"the",
"count",
"of",
"subscription",
"in",
"a",
"subscriber",
"ID"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscription.php#L143-L157
|
23,101
|
ezsystems/ezcomments-ls-extension
|
classes/ezcomsubscription.php
|
ezcomSubscription.contentObject
|
public function contentObject()
{
$contentID = $this->attribute( 'content_id' );
//TODO:try to get the language id
$languageID = $this->attribute( 'language_id' );
return eZContentObject::fetch( $contentID );
}
|
php
|
public function contentObject()
{
$contentID = $this->attribute( 'content_id' );
//TODO:try to get the language id
$languageID = $this->attribute( 'language_id' );
return eZContentObject::fetch( $contentID );
}
|
[
"public",
"function",
"contentObject",
"(",
")",
"{",
"$",
"contentID",
"=",
"$",
"this",
"->",
"attribute",
"(",
"'content_id'",
")",
";",
"//TODO:try to get the language id",
"$",
"languageID",
"=",
"$",
"this",
"->",
"attribute",
"(",
"'language_id'",
")",
";",
"return",
"eZContentObject",
"::",
"fetch",
"(",
"$",
"contentID",
")",
";",
"}"
] |
get the content of the subscription
@return ezcontentobject
|
[
"get",
"the",
"content",
"of",
"the",
"subscription"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscription.php#L182-L188
|
23,102
|
ezsystems/ezcomments-ls-extension
|
classes/ezcomsubscription.php
|
ezcomSubscription.exists
|
static function exists( $contentID, $languageID , $subscriptionType, $email = null, $enabled = false )
{
$emailString = '';
if ( !is_null($email) )
{
$emailString = " WHERE email = '$email'";
}
$countArray = null;
$db = eZDB::instance();
if ( $enabled === false )
{
$countArray = $db->arrayQuery( "SELECT count(*) AS count" .
" FROM ezcomment_subscription" .
" WHERE " .
" content_id = $contentID" .
" AND language_id = $languageID" .
" AND subscription_type = '$subscriptionType'" .
" AND subscriber_id IN" .
"( SELECT id FROM ezcomment_subscriber" .
"$emailString )");
}
else
if ( $enabled === 1 || $enabled === 0 )
{
$enabledString = "enabled = $enabled";
if ( $emailString != '' )
{
$enabledString = " AND " . $enabledString;
}
else
{
$enabledString = " WHERE " . $enabledString;
}
$countArray = $db->arrayQuery( "SELECT count(*) AS count" .
" FROM ezcomment_subscription" .
" WHERE" .
" content_id = $contentID" .
" AND language_id = $languageID" .
" AND subscription_type = '$subscriptionType'" .
" AND subscriber_id IN" .
" ( SELECT id FROM ezcomment_subscriber" .
$emailString .
"$enabledString )" );
}
else
{
return null;
}
$totalCount = $countArray[0]['count'];
if ( $totalCount === '0' )
{
return false;
}
else
{
return true;
}
}
|
php
|
static function exists( $contentID, $languageID , $subscriptionType, $email = null, $enabled = false )
{
$emailString = '';
if ( !is_null($email) )
{
$emailString = " WHERE email = '$email'";
}
$countArray = null;
$db = eZDB::instance();
if ( $enabled === false )
{
$countArray = $db->arrayQuery( "SELECT count(*) AS count" .
" FROM ezcomment_subscription" .
" WHERE " .
" content_id = $contentID" .
" AND language_id = $languageID" .
" AND subscription_type = '$subscriptionType'" .
" AND subscriber_id IN" .
"( SELECT id FROM ezcomment_subscriber" .
"$emailString )");
}
else
if ( $enabled === 1 || $enabled === 0 )
{
$enabledString = "enabled = $enabled";
if ( $emailString != '' )
{
$enabledString = " AND " . $enabledString;
}
else
{
$enabledString = " WHERE " . $enabledString;
}
$countArray = $db->arrayQuery( "SELECT count(*) AS count" .
" FROM ezcomment_subscription" .
" WHERE" .
" content_id = $contentID" .
" AND language_id = $languageID" .
" AND subscription_type = '$subscriptionType'" .
" AND subscriber_id IN" .
" ( SELECT id FROM ezcomment_subscriber" .
$emailString .
"$enabledString )" );
}
else
{
return null;
}
$totalCount = $countArray[0]['count'];
if ( $totalCount === '0' )
{
return false;
}
else
{
return true;
}
}
|
[
"static",
"function",
"exists",
"(",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
",",
"$",
"email",
"=",
"null",
",",
"$",
"enabled",
"=",
"false",
")",
"{",
"$",
"emailString",
"=",
"''",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"email",
")",
")",
"{",
"$",
"emailString",
"=",
"\" WHERE email = '$email'\"",
";",
"}",
"$",
"countArray",
"=",
"null",
";",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"enabled",
"===",
"false",
")",
"{",
"$",
"countArray",
"=",
"$",
"db",
"->",
"arrayQuery",
"(",
"\"SELECT count(*) AS count\"",
".",
"\" FROM ezcomment_subscription\"",
".",
"\" WHERE \"",
".",
"\" content_id = $contentID\"",
".",
"\" AND language_id = $languageID\"",
".",
"\" AND subscription_type = '$subscriptionType'\"",
".",
"\" AND subscriber_id IN\"",
".",
"\"( SELECT id FROM ezcomment_subscriber\"",
".",
"\"$emailString )\"",
")",
";",
"}",
"else",
"if",
"(",
"$",
"enabled",
"===",
"1",
"||",
"$",
"enabled",
"===",
"0",
")",
"{",
"$",
"enabledString",
"=",
"\"enabled = $enabled\"",
";",
"if",
"(",
"$",
"emailString",
"!=",
"''",
")",
"{",
"$",
"enabledString",
"=",
"\" AND \"",
".",
"$",
"enabledString",
";",
"}",
"else",
"{",
"$",
"enabledString",
"=",
"\" WHERE \"",
".",
"$",
"enabledString",
";",
"}",
"$",
"countArray",
"=",
"$",
"db",
"->",
"arrayQuery",
"(",
"\"SELECT count(*) AS count\"",
".",
"\" FROM ezcomment_subscription\"",
".",
"\" WHERE\"",
".",
"\" content_id = $contentID\"",
".",
"\" AND language_id = $languageID\"",
".",
"\" AND subscription_type = '$subscriptionType'\"",
".",
"\" AND subscriber_id IN\"",
".",
"\" ( SELECT id FROM ezcomment_subscriber\"",
".",
"$",
"emailString",
".",
"\"$enabledString )\"",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"$",
"totalCount",
"=",
"$",
"countArray",
"[",
"0",
"]",
"[",
"'count'",
"]",
";",
"if",
"(",
"$",
"totalCount",
"===",
"'0'",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] |
Check if the subscription exists by a given contentID
@param string $contentID : the ID of content subscribed
@param string $languageID : the language ID of content
@param string $subscriptionType : type of the subscription
@param string $email : email in table subscriber
@param integer $enabled : 1/0 - check if the subscriber is enabled.
Empty/false - not check if the subscriber is enabled
@return boolean: true if existing, false if not, null if error happens
|
[
"Check",
"if",
"the",
"subscription",
"exists",
"by",
"a",
"given",
"contentID"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscription.php#L227-L285
|
23,103
|
ShaoZeMing/laravel-merchant
|
src/Tree.php
|
Tree.render
|
public function render()
{
Merchant::script($this->script());
view()->share([
'path' => $this->path,
'keyName' => $this->model->getKeyName(),
'branchView' => $this->view['branch'],
'branchCallback' => $this->branchCallback,
]);
return view($this->view['tree'], $this->variables())->render();
}
|
php
|
public function render()
{
Merchant::script($this->script());
view()->share([
'path' => $this->path,
'keyName' => $this->model->getKeyName(),
'branchView' => $this->view['branch'],
'branchCallback' => $this->branchCallback,
]);
return view($this->view['tree'], $this->variables())->render();
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"Merchant",
"::",
"script",
"(",
"$",
"this",
"->",
"script",
"(",
")",
")",
";",
"view",
"(",
")",
"->",
"share",
"(",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"path",
",",
"'keyName'",
"=>",
"$",
"this",
"->",
"model",
"->",
"getKeyName",
"(",
")",
",",
"'branchView'",
"=>",
"$",
"this",
"->",
"view",
"[",
"'branch'",
"]",
",",
"'branchCallback'",
"=>",
"$",
"this",
"->",
"branchCallback",
",",
"]",
")",
";",
"return",
"view",
"(",
"$",
"this",
"->",
"view",
"[",
"'tree'",
"]",
",",
"$",
"this",
"->",
"variables",
"(",
")",
")",
"->",
"render",
"(",
")",
";",
"}"
] |
Render a tree.
@return \Illuminate\Http\JsonResponse|string
|
[
"Render",
"a",
"tree",
"."
] |
20801b1735e7832a6e58b37c2c391328f8d626fa
|
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Tree.php#L356-L368
|
23,104
|
fortis/silex-graphite
|
src/Graphite/Silex/Client/GraphiteClient.php
|
GraphiteClient.send
|
public function send($data)
{
$pieces = [
$this->config['apiKey'],
$this->config['prefix'],
$data.' '.time(),
];
$message = implode('.', $pieces).PHP_EOL;
return $this->sendData($this->config['host'], $this->config['port'], $message);
}
|
php
|
public function send($data)
{
$pieces = [
$this->config['apiKey'],
$this->config['prefix'],
$data.' '.time(),
];
$message = implode('.', $pieces).PHP_EOL;
return $this->sendData($this->config['host'], $this->config['port'], $message);
}
|
[
"public",
"function",
"send",
"(",
"$",
"data",
")",
"{",
"$",
"pieces",
"=",
"[",
"$",
"this",
"->",
"config",
"[",
"'apiKey'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'prefix'",
"]",
",",
"$",
"data",
".",
"' '",
".",
"time",
"(",
")",
",",
"]",
";",
"$",
"message",
"=",
"implode",
"(",
"'.'",
",",
"$",
"pieces",
")",
".",
"PHP_EOL",
";",
"return",
"$",
"this",
"->",
"sendData",
"(",
"$",
"this",
"->",
"config",
"[",
"'host'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'port'",
"]",
",",
"$",
"message",
")",
";",
"}"
] |
Data to send to Graphite host
@param string $data
@return bool
|
[
"Data",
"to",
"send",
"to",
"Graphite",
"host"
] |
1faf4b53531c62d19b281b736a1dda326e127c7f
|
https://github.com/fortis/silex-graphite/blob/1faf4b53531c62d19b281b736a1dda326e127c7f/src/Graphite/Silex/Client/GraphiteClient.php#L21-L31
|
23,105
|
ArrowSphere/Client
|
src/xAC/MagicFactoryTrait.php
|
MagicFactoryTrait.__callstatic
|
public static function __callstatic($name, $arguments)
{
// Get global services or entity services
$services = Client::getServices(isset($arguments['context']) ? $arguments['context'] : null);
if (array_key_exists($name, $services)) {
$service = $services[$name];
switch ($service['type']) {
case 'collection':
return new Cursor(
$service,
Client::getInstance(),
isset($arguments['context']) ? $arguments['context'] : null
);
break;
case 'entity':
return new Entity(
$service,
Client::getInstance(),
isset($arguments[0]) ? $arguments[0] : null
);
break;
// $name represents an action on an entity
case 'action':
return new Action(
$service,
$arguments['context'],
Client::getInstance()
);
break;
default:
throw new \Exception("Don't know of any service type named '$name'");
break;
}
} else {
throw new \Exception("can't find service definition for '$name'");
}
}
|
php
|
public static function __callstatic($name, $arguments)
{
// Get global services or entity services
$services = Client::getServices(isset($arguments['context']) ? $arguments['context'] : null);
if (array_key_exists($name, $services)) {
$service = $services[$name];
switch ($service['type']) {
case 'collection':
return new Cursor(
$service,
Client::getInstance(),
isset($arguments['context']) ? $arguments['context'] : null
);
break;
case 'entity':
return new Entity(
$service,
Client::getInstance(),
isset($arguments[0]) ? $arguments[0] : null
);
break;
// $name represents an action on an entity
case 'action':
return new Action(
$service,
$arguments['context'],
Client::getInstance()
);
break;
default:
throw new \Exception("Don't know of any service type named '$name'");
break;
}
} else {
throw new \Exception("can't find service definition for '$name'");
}
}
|
[
"public",
"static",
"function",
"__callstatic",
"(",
"$",
"name",
",",
"$",
"arguments",
")",
"{",
"// Get global services or entity services",
"$",
"services",
"=",
"Client",
"::",
"getServices",
"(",
"isset",
"(",
"$",
"arguments",
"[",
"'context'",
"]",
")",
"?",
"$",
"arguments",
"[",
"'context'",
"]",
":",
"null",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"services",
")",
")",
"{",
"$",
"service",
"=",
"$",
"services",
"[",
"$",
"name",
"]",
";",
"switch",
"(",
"$",
"service",
"[",
"'type'",
"]",
")",
"{",
"case",
"'collection'",
":",
"return",
"new",
"Cursor",
"(",
"$",
"service",
",",
"Client",
"::",
"getInstance",
"(",
")",
",",
"isset",
"(",
"$",
"arguments",
"[",
"'context'",
"]",
")",
"?",
"$",
"arguments",
"[",
"'context'",
"]",
":",
"null",
")",
";",
"break",
";",
"case",
"'entity'",
":",
"return",
"new",
"Entity",
"(",
"$",
"service",
",",
"Client",
"::",
"getInstance",
"(",
")",
",",
"isset",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
"?",
"$",
"arguments",
"[",
"0",
"]",
":",
"null",
")",
";",
"break",
";",
"// $name represents an action on an entity",
"case",
"'action'",
":",
"return",
"new",
"Action",
"(",
"$",
"service",
",",
"$",
"arguments",
"[",
"'context'",
"]",
",",
"Client",
"::",
"getInstance",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Don't know of any service type named '$name'\"",
")",
";",
"break",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"can't find service definition for '$name'\"",
")",
";",
"}",
"}"
] |
Magic method for static calls
@param string $name
@param array $arguments
@return mixed
|
[
"Magic",
"method",
"for",
"static",
"calls"
] |
6608f8257060375e7d3a27c485b23268b73f6ef7
|
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/MagicFactoryTrait.php#L17-L59
|
23,106
|
NuclearCMS/Hierarchy
|
src/Tags/TagRepository.php
|
TagRepository.getTagAndSetLocale
|
public function getTagAndSetLocale($name, $locale = null)
{
$tag = $this->getTag($name);
// Override locale or use tag locale
// this is for when a tag does not have to be translated
// and the app locale is determined via route parameter (etiket|tag)
$locale = $locale ?: $tag->getLocaleForName($name);
set_app_locale($locale);
return $tag;
}
|
php
|
public function getTagAndSetLocale($name, $locale = null)
{
$tag = $this->getTag($name);
// Override locale or use tag locale
// this is for when a tag does not have to be translated
// and the app locale is determined via route parameter (etiket|tag)
$locale = $locale ?: $tag->getLocaleForName($name);
set_app_locale($locale);
return $tag;
}
|
[
"public",
"function",
"getTagAndSetLocale",
"(",
"$",
"name",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"tag",
"=",
"$",
"this",
"->",
"getTag",
"(",
"$",
"name",
")",
";",
"// Override locale or use tag locale",
"// this is for when a tag does not have to be translated",
"// and the app locale is determined via route parameter (etiket|tag)",
"$",
"locale",
"=",
"$",
"locale",
"?",
":",
"$",
"tag",
"->",
"getLocaleForName",
"(",
"$",
"name",
")",
";",
"set_app_locale",
"(",
"$",
"locale",
")",
";",
"return",
"$",
"tag",
";",
"}"
] |
Returns a tag by name and sets the locale
@param string $name
@param string $locale
@return Tag
|
[
"Returns",
"a",
"tag",
"by",
"name",
"and",
"sets",
"the",
"locale"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Tags/TagRepository.php#L27-L39
|
23,107
|
OKTOTV/OktolabMediaBundle
|
Controller/EpisodeController.php
|
EpisodeController.createCreateForm
|
private function createCreateForm(Episode $entity)
{
$form = $this->createForm(EpisodeType::class, $entity, array(
'action' => $this->generateUrl('oktolab_episode_create'),
'method' => 'POST',
));
$form->add(
'submit',
SubmitType::class,
[
'label' => 'oktolab_media.new_episode_create_button',
'attr' => ['class' => 'btn btn-primary']
]
);
return $form;
}
|
php
|
private function createCreateForm(Episode $entity)
{
$form = $this->createForm(EpisodeType::class, $entity, array(
'action' => $this->generateUrl('oktolab_episode_create'),
'method' => 'POST',
));
$form->add(
'submit',
SubmitType::class,
[
'label' => 'oktolab_media.new_episode_create_button',
'attr' => ['class' => 'btn btn-primary']
]
);
return $form;
}
|
[
"private",
"function",
"createCreateForm",
"(",
"Episode",
"$",
"entity",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"EpisodeType",
"::",
"class",
",",
"$",
"entity",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'oktolab_episode_create'",
")",
",",
"'method'",
"=>",
"'POST'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"SubmitType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'oktolab_media.new_episode_create_button'",
",",
"'attr'",
"=>",
"[",
"'class'",
"=>",
"'btn btn-primary'",
"]",
"]",
")",
";",
"return",
"$",
"form",
";",
"}"
] |
Creates a form to create a Episode entity.
@param Episode $entity The entity
@return \Symfony\Component\Form\Form The form
|
[
"Creates",
"a",
"form",
"to",
"create",
"a",
"Episode",
"entity",
"."
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/EpisodeController.php#L99-L116
|
23,108
|
OKTOTV/OktolabMediaBundle
|
Controller/EpisodeController.php
|
EpisodeController.newAction
|
public function newAction(Request $request)
{
$entity = new Episode();
$form = $this->createCreateForm($entity);
return [
'entity' => $entity,
'form' => $form->createView(),
];
}
|
php
|
public function newAction(Request $request)
{
$entity = new Episode();
$form = $this->createCreateForm($entity);
return [
'entity' => $entity,
'form' => $form->createView(),
];
}
|
[
"public",
"function",
"newAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"entity",
"=",
"new",
"Episode",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createCreateForm",
"(",
"$",
"entity",
")",
";",
"return",
"[",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"]",
";",
"}"
] |
Displays a form to create a new Episode entity.
@Route("/new", name="oktolab_episode_new")
@Method("GET")
@Template()
|
[
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Episode",
"entity",
"."
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/EpisodeController.php#L125-L134
|
23,109
|
OKTOTV/OktolabMediaBundle
|
Controller/EpisodeController.php
|
EpisodeController.createEditForm
|
private function createEditForm(Episode $entity)
{
$form = $this->createForm(
new EpisodeType(),
$entity,
[
'action' => $this->generateUrl(
'oktolab_episode_update',
['id' => $entity->getId()]
),
'method' => 'POST'
]
);
$form->add(
'submit',
'submit',
['label' => 'oktolab_media.edit_episode_button']
);
return $form;
}
|
php
|
private function createEditForm(Episode $entity)
{
$form = $this->createForm(
new EpisodeType(),
$entity,
[
'action' => $this->generateUrl(
'oktolab_episode_update',
['id' => $entity->getId()]
),
'method' => 'POST'
]
);
$form->add(
'submit',
'submit',
['label' => 'oktolab_media.edit_episode_button']
);
return $form;
}
|
[
"private",
"function",
"createEditForm",
"(",
"Episode",
"$",
"entity",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"EpisodeType",
"(",
")",
",",
"$",
"entity",
",",
"[",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'oktolab_episode_update'",
",",
"[",
"'id'",
"=>",
"$",
"entity",
"->",
"getId",
"(",
")",
"]",
")",
",",
"'method'",
"=>",
"'POST'",
"]",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"[",
"'label'",
"=>",
"'oktolab_media.edit_episode_button'",
"]",
")",
";",
"return",
"$",
"form",
";",
"}"
] |
Creates a form to edit a Episode entity.
@param Episode $entity The entity
@return \Symfony\Component\Form\Form The form
|
[
"Creates",
"a",
"form",
"to",
"edit",
"a",
"Episode",
"entity",
"."
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/EpisodeController.php#L229-L250
|
23,110
|
OKTOTV/OktolabMediaBundle
|
Controller/EpisodeController.php
|
EpisodeController.deleteAction
|
public function deleteAction(Request $request, $id)
{
$form = $this->createDeleteForm($id);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('OktolabMediaBundle:Episode')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Episode entity.');
}
$this->get('oktolab_media_helper')->deleteEpisode($episode);
}
return $this->redirect($this->generateUrl('oktolab_episode'));
}
|
php
|
public function deleteAction(Request $request, $id)
{
$form = $this->createDeleteForm($id);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('OktolabMediaBundle:Episode')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Episode entity.');
}
$this->get('oktolab_media_helper')->deleteEpisode($episode);
}
return $this->redirect($this->generateUrl('oktolab_episode'));
}
|
[
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"id",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'OktolabMediaBundle:Episode'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find Episode entity.'",
")",
";",
"}",
"$",
"this",
"->",
"get",
"(",
"'oktolab_media_helper'",
")",
"->",
"deleteEpisode",
"(",
"$",
"episode",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'oktolab_episode'",
")",
")",
";",
"}"
] |
Deletes a Episode entity.
@Route("/{id}", name="oktolab_episode_delete")
@Method("DELETE")
|
[
"Deletes",
"a",
"Episode",
"entity",
"."
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/EpisodeController.php#L306-L323
|
23,111
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox.Image_Toolbox
|
function Image_Toolbox()
{
$args = func_get_args();
$argc = func_num_args();
//get GD information. see what types we can handle
$gd_info = function_exists('gd_info') ? gd_info() : $this->_gd_info();
preg_match("/\A[\D]*([\d+\.]*)[\D]*\Z/", $gd_info['GD Version'], $matches);
list($this->_gd_version_string, $this->_gd_version_number) = $matches;
$this->_gd_version = substr($this->_gd_version_number, 0, strpos($this->_gd_version_number, '.'));
if ($this->_gd_version >= 2)
{
$this->_imagecreatefunction = 'imagecreatetruecolor';
$this->_resize_function = 'imagecopyresampled';
}
else
{
$this->_imagecreatefunction = 'imagecreate';
$this->_resize_function = 'imagecopyresized';
}
$this->_gd_ttf = $gd_info['FreeType Support'];
$this->_gd_ps = $gd_info['T1Lib Support'];
if (isset($gd_info['GIF Read Support']))
{
$this->_types[1]['supported'] = 1;
if ($gd_info['GIF Create Support'])
{
$this->_types[1]['supported'] = 2;
}
}
if (isset($gd_info['JPEG Support']) || isset($gd_info['JPG Support']))
{
$this->_types[2]['supported'] = 2;
}
if (isset($gd_info['PNG Support']))
{
$this->_types[3]['supported'] = 2;
}
//load or create main image
if ($argc == 0)
{
return true;
}
else
{
if ($this->_addImage($argc, $args))
{
foreach ($this->_img['operator'] as $key => $value)
{
$this->_img['main'][$key] = $value;
}
$this->_img['main']['output_type'] = $this->_img['main']['type'];
unset($this->_img['operator']);
return true;
}
else
{
//trigger_error($this->_error_prefix . 'No appropriate constructor found.', E_USER_ERROR);
return null;
}
}
}
|
php
|
function Image_Toolbox()
{
$args = func_get_args();
$argc = func_num_args();
//get GD information. see what types we can handle
$gd_info = function_exists('gd_info') ? gd_info() : $this->_gd_info();
preg_match("/\A[\D]*([\d+\.]*)[\D]*\Z/", $gd_info['GD Version'], $matches);
list($this->_gd_version_string, $this->_gd_version_number) = $matches;
$this->_gd_version = substr($this->_gd_version_number, 0, strpos($this->_gd_version_number, '.'));
if ($this->_gd_version >= 2)
{
$this->_imagecreatefunction = 'imagecreatetruecolor';
$this->_resize_function = 'imagecopyresampled';
}
else
{
$this->_imagecreatefunction = 'imagecreate';
$this->_resize_function = 'imagecopyresized';
}
$this->_gd_ttf = $gd_info['FreeType Support'];
$this->_gd_ps = $gd_info['T1Lib Support'];
if (isset($gd_info['GIF Read Support']))
{
$this->_types[1]['supported'] = 1;
if ($gd_info['GIF Create Support'])
{
$this->_types[1]['supported'] = 2;
}
}
if (isset($gd_info['JPEG Support']) || isset($gd_info['JPG Support']))
{
$this->_types[2]['supported'] = 2;
}
if (isset($gd_info['PNG Support']))
{
$this->_types[3]['supported'] = 2;
}
//load or create main image
if ($argc == 0)
{
return true;
}
else
{
if ($this->_addImage($argc, $args))
{
foreach ($this->_img['operator'] as $key => $value)
{
$this->_img['main'][$key] = $value;
}
$this->_img['main']['output_type'] = $this->_img['main']['type'];
unset($this->_img['operator']);
return true;
}
else
{
//trigger_error($this->_error_prefix . 'No appropriate constructor found.', E_USER_ERROR);
return null;
}
}
}
|
[
"function",
"Image_Toolbox",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"argc",
"=",
"func_num_args",
"(",
")",
";",
"//get GD information. see what types we can handle",
"$",
"gd_info",
"=",
"function_exists",
"(",
"'gd_info'",
")",
"?",
"gd_info",
"(",
")",
":",
"$",
"this",
"->",
"_gd_info",
"(",
")",
";",
"preg_match",
"(",
"\"/\\A[\\D]*([\\d+\\.]*)[\\D]*\\Z/\"",
",",
"$",
"gd_info",
"[",
"'GD Version'",
"]",
",",
"$",
"matches",
")",
";",
"list",
"(",
"$",
"this",
"->",
"_gd_version_string",
",",
"$",
"this",
"->",
"_gd_version_number",
")",
"=",
"$",
"matches",
";",
"$",
"this",
"->",
"_gd_version",
"=",
"substr",
"(",
"$",
"this",
"->",
"_gd_version_number",
",",
"0",
",",
"strpos",
"(",
"$",
"this",
"->",
"_gd_version_number",
",",
"'.'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_gd_version",
">=",
"2",
")",
"{",
"$",
"this",
"->",
"_imagecreatefunction",
"=",
"'imagecreatetruecolor'",
";",
"$",
"this",
"->",
"_resize_function",
"=",
"'imagecopyresampled'",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_imagecreatefunction",
"=",
"'imagecreate'",
";",
"$",
"this",
"->",
"_resize_function",
"=",
"'imagecopyresized'",
";",
"}",
"$",
"this",
"->",
"_gd_ttf",
"=",
"$",
"gd_info",
"[",
"'FreeType Support'",
"]",
";",
"$",
"this",
"->",
"_gd_ps",
"=",
"$",
"gd_info",
"[",
"'T1Lib Support'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"gd_info",
"[",
"'GIF Read Support'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_types",
"[",
"1",
"]",
"[",
"'supported'",
"]",
"=",
"1",
";",
"if",
"(",
"$",
"gd_info",
"[",
"'GIF Create Support'",
"]",
")",
"{",
"$",
"this",
"->",
"_types",
"[",
"1",
"]",
"[",
"'supported'",
"]",
"=",
"2",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"gd_info",
"[",
"'JPEG Support'",
"]",
")",
"||",
"isset",
"(",
"$",
"gd_info",
"[",
"'JPG Support'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_types",
"[",
"2",
"]",
"[",
"'supported'",
"]",
"=",
"2",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"gd_info",
"[",
"'PNG Support'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_types",
"[",
"3",
"]",
"[",
"'supported'",
"]",
"=",
"2",
";",
"}",
"//load or create main image",
"if",
"(",
"$",
"argc",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"_addImage",
"(",
"$",
"argc",
",",
"$",
"args",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"'output_type'",
"]",
"=",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"'type'",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"//trigger_error($this->_error_prefix . 'No appropriate constructor found.', E_USER_ERROR);",
"return",
"null",
";",
"}",
"}",
"}"
] |
The class constructor.
Determines the image features of the server and sets the according values.<br>
Additionally you can specify a image to be created/loaded. like {@link addImage() addImage}.
If no parameter is given, no image resource will be generated<br>
Or:<br>
<i>string</i> <b>$file</b> imagefile to load<br>
Or:<br>
<i>integer</i> <b>$width</b> imagewidth of new image to be created<br>
<i>integer</i> <b>$height</b> imageheight of new image to be created<br>
<i>string</i> <b>$fillcolor</b> optional fill the new image with this color (hexformat, e.g. '#FF0000')<br>
|
[
"The",
"class",
"constructor",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L175-L239
|
23,112
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox.getServerFeatures
|
function getServerFeatures()
{
$features = array();
$features['gd_version'] = $this->_gd_version_number;
$features['gif'] = $this->_types[1]['supported'];
$features['jpg'] = $this->_types[2]['supported'];
$features['png'] = $this->_types[3]['supported'];
$features['ttf'] = $this->_gd_ttf;
return $features;
}
|
php
|
function getServerFeatures()
{
$features = array();
$features['gd_version'] = $this->_gd_version_number;
$features['gif'] = $this->_types[1]['supported'];
$features['jpg'] = $this->_types[2]['supported'];
$features['png'] = $this->_types[3]['supported'];
$features['ttf'] = $this->_gd_ttf;
return $features;
}
|
[
"function",
"getServerFeatures",
"(",
")",
"{",
"$",
"features",
"=",
"array",
"(",
")",
";",
"$",
"features",
"[",
"'gd_version'",
"]",
"=",
"$",
"this",
"->",
"_gd_version_number",
";",
"$",
"features",
"[",
"'gif'",
"]",
"=",
"$",
"this",
"->",
"_types",
"[",
"1",
"]",
"[",
"'supported'",
"]",
";",
"$",
"features",
"[",
"'jpg'",
"]",
"=",
"$",
"this",
"->",
"_types",
"[",
"2",
"]",
"[",
"'supported'",
"]",
";",
"$",
"features",
"[",
"'png'",
"]",
"=",
"$",
"this",
"->",
"_types",
"[",
"3",
"]",
"[",
"'supported'",
"]",
";",
"$",
"features",
"[",
"'ttf'",
"]",
"=",
"$",
"this",
"->",
"_gd_ttf",
";",
"return",
"$",
"features",
";",
"}"
] |
Returns an assocative array with information about the image features of this server
Array values:
<ul>
<li>'gd_version' -> what GD version is installed on this server (e.g. 2.0)</li>
<li>'gif' -> 0 = not supported, 1 = reading is supported, 2 = creating is supported</li>
<li>'jpg' -> 0 = not supported, 1 = reading is supported, 2 = creating is supported</li>
<li>'png' -> 0 = not supported, 1 = reading is supported, 2 = creating is supported</li>
<li>'ttf' -> TTF text creation. true = supported, false = not supported
</ul>
@return array
|
[
"Returns",
"an",
"assocative",
"array",
"with",
"information",
"about",
"the",
"image",
"features",
"of",
"this",
"server"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L255-L264
|
23,113
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox.newImage
|
function newImage()
{
$args = func_get_args();
$argc = func_num_args();
if ($this->_addImage($argc, $args))
{
foreach ($this->_img['operator'] as $key => $value)
{
$this->_img['main'][$key] = $value;
}
$this->_img['main']['output_type'] = $this->_img['main']['type'];
unset($this->_img['operator']);
return true;
}
else
{
//trigger_error($this->_error_prefix . 'No appropriate constructor found.', E_USER_ERROR);
return null;
}
}
|
php
|
function newImage()
{
$args = func_get_args();
$argc = func_num_args();
if ($this->_addImage($argc, $args))
{
foreach ($this->_img['operator'] as $key => $value)
{
$this->_img['main'][$key] = $value;
}
$this->_img['main']['output_type'] = $this->_img['main']['type'];
unset($this->_img['operator']);
return true;
}
else
{
//trigger_error($this->_error_prefix . 'No appropriate constructor found.', E_USER_ERROR);
return null;
}
}
|
[
"function",
"newImage",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"argc",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_addImage",
"(",
"$",
"argc",
",",
"$",
"args",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"'output_type'",
"]",
"=",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"'type'",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"//trigger_error($this->_error_prefix . 'No appropriate constructor found.', E_USER_ERROR);",
"return",
"null",
";",
"}",
"}"
] |
Flush all image resources and init a new one
Parameter:<br>
<i>string</i> <b>$file</b> imagefile to load<br>
Or:<br>
<i>integer</i> <b>$width</b> imagewidth of new image to be created<br>
<i>integer</i> <b>$height</b> imageheight of new image to be created<br>
<i>string</i> <b>$fillcolor</b> optional fill the new image with this color (hexformat, e.g. '#FF0000')<br>
|
[
"Flush",
"all",
"image",
"resources",
"and",
"init",
"a",
"new",
"one"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L276-L296
|
23,114
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox._hexToPHPColor
|
function _hexToPHPColor($hex)
{
$length = strlen($hex);
$dr = hexdec(substr($hex, $length - 6, 2));
$dg = hexdec(substr($hex, $length - 4, 2));
$db = hexdec(substr($hex, $length - 2, 2));
$color = ($dr << 16) + ($dg << 8) + $db;
return $color;
}
|
php
|
function _hexToPHPColor($hex)
{
$length = strlen($hex);
$dr = hexdec(substr($hex, $length - 6, 2));
$dg = hexdec(substr($hex, $length - 4, 2));
$db = hexdec(substr($hex, $length - 2, 2));
$color = ($dr << 16) + ($dg << 8) + $db;
return $color;
}
|
[
"function",
"_hexToPHPColor",
"(",
"$",
"hex",
")",
"{",
"$",
"length",
"=",
"strlen",
"(",
"$",
"hex",
")",
";",
"$",
"dr",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"$",
"length",
"-",
"6",
",",
"2",
")",
")",
";",
"$",
"dg",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"$",
"length",
"-",
"4",
",",
"2",
")",
")",
";",
"$",
"db",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"$",
"length",
"-",
"2",
",",
"2",
")",
")",
";",
"$",
"color",
"=",
"(",
"$",
"dr",
"<<",
"16",
")",
"+",
"(",
"$",
"dg",
"<<",
"8",
")",
"+",
"$",
"db",
";",
"return",
"$",
"color",
";",
"}"
] |
Convert a color defined in hexvalues to the PHP color format
@access private
@param string $hex color value in hexformat (e.g. '#FF0000')
@return integer color value in PHP format
|
[
"Convert",
"a",
"color",
"defined",
"in",
"hexvalues",
"to",
"the",
"PHP",
"color",
"format"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L429-L437
|
23,115
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox._hexToDecColor
|
function _hexToDecColor($hex)
{
$length = strlen($hex);
$color['red'] = hexdec(substr($hex, $length - 6, 2));
$color['green'] = hexdec(substr($hex, $length - 4, 2));
$color['blue'] = hexdec(substr($hex, $length - 2, 2));
return $color;
}
|
php
|
function _hexToDecColor($hex)
{
$length = strlen($hex);
$color['red'] = hexdec(substr($hex, $length - 6, 2));
$color['green'] = hexdec(substr($hex, $length - 4, 2));
$color['blue'] = hexdec(substr($hex, $length - 2, 2));
return $color;
}
|
[
"function",
"_hexToDecColor",
"(",
"$",
"hex",
")",
"{",
"$",
"length",
"=",
"strlen",
"(",
"$",
"hex",
")",
";",
"$",
"color",
"[",
"'red'",
"]",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"$",
"length",
"-",
"6",
",",
"2",
")",
")",
";",
"$",
"color",
"[",
"'green'",
"]",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"$",
"length",
"-",
"4",
",",
"2",
")",
")",
";",
"$",
"color",
"[",
"'blue'",
"]",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"hex",
",",
"$",
"length",
"-",
"2",
",",
"2",
")",
")",
";",
"return",
"$",
"color",
";",
"}"
] |
Convert a color defined in hexvalues to corresponding dezimal values
@access private
@param string $hex color value in hexformat (e.g. '#FF0000')
@return array associative array with color values in dezimal format (fields: 'red', 'green', 'blue')
|
[
"Convert",
"a",
"color",
"defined",
"in",
"hexvalues",
"to",
"corresponding",
"dezimal",
"values"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L446-L453
|
23,116
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox._addImage
|
function _addImage($argc, $args)
{
if (($argc == 2 || $argc == 3) && is_int($args[0]) && is_int($args[1]) && (is_string($args[2]) || !isset($args[2])))
{
//neues leeres bild mit width und height (fillcolor optional)
$this->_img['operator']['width'] = $args[0];
$this->_img['operator']['height'] = $args[1];
($this->_img['operator']['width'] >= $this->_img['operator']['height']) ? ($this->_img['operator']['bias'] = IMAGE_TOOLBOX_BIAS_HORIZONTAL) : ($this->_img['operator']['bias'] = IMAGE_TOOLBOX_BIAS_VERTICAL);
$this->_img['operator']['aspectratio'] = $this->_img['operator']['width'] / $this->_img['operator']['height'];
$this->_img['operator']['indexedcolors'] = 0;
$functionname = $this->_imagecreatefunction;
$this->_img['operator']['resource'] = $functionname($this->_img['operator']['width'], $this->_img['operator']['height']);
// set default type jpg.
$this->_img['operator']['type'] = 2;
if (isset($args[2]) && is_string($args[2]))
{
//neues bild mit farbe f�llen
$fillcolor = $this->_hexToPHPColor($args[2]);
imagefill($this->_img['operator']['resource'], 0, 0, $fillcolor);
$this->_img['operator']['color'] = $fillcolor;
}
else
{
$this->_img['operator']['color'] = 0;
}
}
elseif ($argc == 1 && is_string($args[0]))
{
//bild aus datei laden. width und height original gr�sse
$this->_img['operator'] = $this->_loadFile($args[0]);
$this->_img['operator']['indexedcolors'] = imagecolorstotal($this->_img['operator']['resource']);
$this->_img['operator']['color'] = -1;
}
else
{
return false;
}
return true;
}
|
php
|
function _addImage($argc, $args)
{
if (($argc == 2 || $argc == 3) && is_int($args[0]) && is_int($args[1]) && (is_string($args[2]) || !isset($args[2])))
{
//neues leeres bild mit width und height (fillcolor optional)
$this->_img['operator']['width'] = $args[0];
$this->_img['operator']['height'] = $args[1];
($this->_img['operator']['width'] >= $this->_img['operator']['height']) ? ($this->_img['operator']['bias'] = IMAGE_TOOLBOX_BIAS_HORIZONTAL) : ($this->_img['operator']['bias'] = IMAGE_TOOLBOX_BIAS_VERTICAL);
$this->_img['operator']['aspectratio'] = $this->_img['operator']['width'] / $this->_img['operator']['height'];
$this->_img['operator']['indexedcolors'] = 0;
$functionname = $this->_imagecreatefunction;
$this->_img['operator']['resource'] = $functionname($this->_img['operator']['width'], $this->_img['operator']['height']);
// set default type jpg.
$this->_img['operator']['type'] = 2;
if (isset($args[2]) && is_string($args[2]))
{
//neues bild mit farbe f�llen
$fillcolor = $this->_hexToPHPColor($args[2]);
imagefill($this->_img['operator']['resource'], 0, 0, $fillcolor);
$this->_img['operator']['color'] = $fillcolor;
}
else
{
$this->_img['operator']['color'] = 0;
}
}
elseif ($argc == 1 && is_string($args[0]))
{
//bild aus datei laden. width und height original gr�sse
$this->_img['operator'] = $this->_loadFile($args[0]);
$this->_img['operator']['indexedcolors'] = imagecolorstotal($this->_img['operator']['resource']);
$this->_img['operator']['color'] = -1;
}
else
{
return false;
}
return true;
}
|
[
"function",
"_addImage",
"(",
"$",
"argc",
",",
"$",
"args",
")",
"{",
"if",
"(",
"(",
"$",
"argc",
"==",
"2",
"||",
"$",
"argc",
"==",
"3",
")",
"&&",
"is_int",
"(",
"$",
"args",
"[",
"0",
"]",
")",
"&&",
"is_int",
"(",
"$",
"args",
"[",
"1",
"]",
")",
"&&",
"(",
"is_string",
"(",
"$",
"args",
"[",
"2",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"args",
"[",
"2",
"]",
")",
")",
")",
"{",
"//neues leeres bild mit width und height (fillcolor optional)",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'width'",
"]",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'height'",
"]",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'width'",
"]",
">=",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'height'",
"]",
")",
"?",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'bias'",
"]",
"=",
"IMAGE_TOOLBOX_BIAS_HORIZONTAL",
")",
":",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'bias'",
"]",
"=",
"IMAGE_TOOLBOX_BIAS_VERTICAL",
")",
";",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'aspectratio'",
"]",
"=",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'width'",
"]",
"/",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'height'",
"]",
";",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'indexedcolors'",
"]",
"=",
"0",
";",
"$",
"functionname",
"=",
"$",
"this",
"->",
"_imagecreatefunction",
";",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'resource'",
"]",
"=",
"$",
"functionname",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'width'",
"]",
",",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'height'",
"]",
")",
";",
"// set default type jpg.",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'type'",
"]",
"=",
"2",
";",
"if",
"(",
"isset",
"(",
"$",
"args",
"[",
"2",
"]",
")",
"&&",
"is_string",
"(",
"$",
"args",
"[",
"2",
"]",
")",
")",
"{",
"//neues bild mit farbe f�llen",
"$",
"fillcolor",
"=",
"$",
"this",
"->",
"_hexToPHPColor",
"(",
"$",
"args",
"[",
"2",
"]",
")",
";",
"imagefill",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'resource'",
"]",
",",
"0",
",",
"0",
",",
"$",
"fillcolor",
")",
";",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'color'",
"]",
"=",
"$",
"fillcolor",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'color'",
"]",
"=",
"0",
";",
"}",
"}",
"elseif",
"(",
"$",
"argc",
"==",
"1",
"&&",
"is_string",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"//bild aus datei laden. width und height original gr�sse",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"=",
"$",
"this",
"->",
"_loadFile",
"(",
"$",
"args",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'indexedcolors'",
"]",
"=",
"imagecolorstotal",
"(",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'resource'",
"]",
")",
";",
"$",
"this",
"->",
"_img",
"[",
"'operator'",
"]",
"[",
"'color'",
"]",
"=",
"-",
"1",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Generate a new image resource based on the given parameters
Parameter:
<i>string</i> <b>$file</b> imagefile to load<br>
Or:<br>
<i>integer</i> <b>$width</b> imagewidth of new image to be created<br>
<i>integer</i> <b>$height</b> imageheight of new image to be created<br>
<i>string</i> <b>$fillcolor</b> optional fill the new image with this color (hexformat, e.g. '#FF0000')<br>
@access private
|
[
"Generate",
"a",
"new",
"image",
"resource",
"based",
"on",
"the",
"given",
"parameters"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L467-L505
|
23,117
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox._loadFile
|
function _loadFile($filename)
{
if (file_exists($filename))
{
$info = getimagesize($filename);
$filedata['width'] = $info[0];
$filedata['height'] = $info[1];
($filedata['width'] >= $filedata['height']) ? ($filedata['bias'] = IMAGE_TOOLBOX_BIAS_HORIZONTAL) : ($filedata['bias'] = IMAGE_TOOLBOX_BIAS_VERTICAL);
$filedata['aspectratio'] = $filedata['width'] / $filedata['height'];
$filedata['type'] = $info[2];
if ($this->_types[$filedata['type']]['supported'] < 1)
{
//trigger_error($this->_error_prefix . 'Imagetype ('.$this->_types[$filedata['type']]['ext'].') not supported for reading.', E_USER_ERROR);
return null;
}
switch ($filedata['type'])
{
case 1:
$dummy = imagecreatefromgif($filename);
$functionname = $this->_imagecreatefunction;
$filedata['resource'] = $functionname($filedata['width'], $filedata['height']);
imagecopy($filedata['resource'], $dummy, 0, 0, 0, 0, $filedata['width'], $filedata['height']);
imagedestroy($dummy);
break;
case 2:
$filedata['resource'] = imagecreatefromjpeg($filename);
break;
case 3:
$dummy = imagecreatefrompng($filename);
if (imagecolorstotal($dummy) != 0)
{
$functionname = $this->_imagecreatefunction;
$filedata['resource'] = $functionname($filedata['width'], $filedata['height']);
imagecopy($filedata['resource'], $dummy, 0, 0, 0, 0, $filedata['width'], $filedata['height']);
}
else
{
$filedata['resource'] = $dummy;
}
unset($dummy);
break;
default:
//trigger_error($this->_error_prefix . 'Imagetype not supported.', E_USER_ERROR);
return null;
}
return $filedata;
}
else
{
//trigger_error($this->_error_prefix . 'Imagefile (' . $filename . ') does not exist.', E_USER_ERROR);
return null;
}
}
|
php
|
function _loadFile($filename)
{
if (file_exists($filename))
{
$info = getimagesize($filename);
$filedata['width'] = $info[0];
$filedata['height'] = $info[1];
($filedata['width'] >= $filedata['height']) ? ($filedata['bias'] = IMAGE_TOOLBOX_BIAS_HORIZONTAL) : ($filedata['bias'] = IMAGE_TOOLBOX_BIAS_VERTICAL);
$filedata['aspectratio'] = $filedata['width'] / $filedata['height'];
$filedata['type'] = $info[2];
if ($this->_types[$filedata['type']]['supported'] < 1)
{
//trigger_error($this->_error_prefix . 'Imagetype ('.$this->_types[$filedata['type']]['ext'].') not supported for reading.', E_USER_ERROR);
return null;
}
switch ($filedata['type'])
{
case 1:
$dummy = imagecreatefromgif($filename);
$functionname = $this->_imagecreatefunction;
$filedata['resource'] = $functionname($filedata['width'], $filedata['height']);
imagecopy($filedata['resource'], $dummy, 0, 0, 0, 0, $filedata['width'], $filedata['height']);
imagedestroy($dummy);
break;
case 2:
$filedata['resource'] = imagecreatefromjpeg($filename);
break;
case 3:
$dummy = imagecreatefrompng($filename);
if (imagecolorstotal($dummy) != 0)
{
$functionname = $this->_imagecreatefunction;
$filedata['resource'] = $functionname($filedata['width'], $filedata['height']);
imagecopy($filedata['resource'], $dummy, 0, 0, 0, 0, $filedata['width'], $filedata['height']);
}
else
{
$filedata['resource'] = $dummy;
}
unset($dummy);
break;
default:
//trigger_error($this->_error_prefix . 'Imagetype not supported.', E_USER_ERROR);
return null;
}
return $filedata;
}
else
{
//trigger_error($this->_error_prefix . 'Imagefile (' . $filename . ') does not exist.', E_USER_ERROR);
return null;
}
}
|
[
"function",
"_loadFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"info",
"=",
"getimagesize",
"(",
"$",
"filename",
")",
";",
"$",
"filedata",
"[",
"'width'",
"]",
"=",
"$",
"info",
"[",
"0",
"]",
";",
"$",
"filedata",
"[",
"'height'",
"]",
"=",
"$",
"info",
"[",
"1",
"]",
";",
"(",
"$",
"filedata",
"[",
"'width'",
"]",
">=",
"$",
"filedata",
"[",
"'height'",
"]",
")",
"?",
"(",
"$",
"filedata",
"[",
"'bias'",
"]",
"=",
"IMAGE_TOOLBOX_BIAS_HORIZONTAL",
")",
":",
"(",
"$",
"filedata",
"[",
"'bias'",
"]",
"=",
"IMAGE_TOOLBOX_BIAS_VERTICAL",
")",
";",
"$",
"filedata",
"[",
"'aspectratio'",
"]",
"=",
"$",
"filedata",
"[",
"'width'",
"]",
"/",
"$",
"filedata",
"[",
"'height'",
"]",
";",
"$",
"filedata",
"[",
"'type'",
"]",
"=",
"$",
"info",
"[",
"2",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"_types",
"[",
"$",
"filedata",
"[",
"'type'",
"]",
"]",
"[",
"'supported'",
"]",
"<",
"1",
")",
"{",
"//trigger_error($this->_error_prefix . 'Imagetype ('.$this->_types[$filedata['type']]['ext'].') not supported for reading.', E_USER_ERROR);",
"return",
"null",
";",
"}",
"switch",
"(",
"$",
"filedata",
"[",
"'type'",
"]",
")",
"{",
"case",
"1",
":",
"$",
"dummy",
"=",
"imagecreatefromgif",
"(",
"$",
"filename",
")",
";",
"$",
"functionname",
"=",
"$",
"this",
"->",
"_imagecreatefunction",
";",
"$",
"filedata",
"[",
"'resource'",
"]",
"=",
"$",
"functionname",
"(",
"$",
"filedata",
"[",
"'width'",
"]",
",",
"$",
"filedata",
"[",
"'height'",
"]",
")",
";",
"imagecopy",
"(",
"$",
"filedata",
"[",
"'resource'",
"]",
",",
"$",
"dummy",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"filedata",
"[",
"'width'",
"]",
",",
"$",
"filedata",
"[",
"'height'",
"]",
")",
";",
"imagedestroy",
"(",
"$",
"dummy",
")",
";",
"break",
";",
"case",
"2",
":",
"$",
"filedata",
"[",
"'resource'",
"]",
"=",
"imagecreatefromjpeg",
"(",
"$",
"filename",
")",
";",
"break",
";",
"case",
"3",
":",
"$",
"dummy",
"=",
"imagecreatefrompng",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"imagecolorstotal",
"(",
"$",
"dummy",
")",
"!=",
"0",
")",
"{",
"$",
"functionname",
"=",
"$",
"this",
"->",
"_imagecreatefunction",
";",
"$",
"filedata",
"[",
"'resource'",
"]",
"=",
"$",
"functionname",
"(",
"$",
"filedata",
"[",
"'width'",
"]",
",",
"$",
"filedata",
"[",
"'height'",
"]",
")",
";",
"imagecopy",
"(",
"$",
"filedata",
"[",
"'resource'",
"]",
",",
"$",
"dummy",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"filedata",
"[",
"'width'",
"]",
",",
"$",
"filedata",
"[",
"'height'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"filedata",
"[",
"'resource'",
"]",
"=",
"$",
"dummy",
";",
"}",
"unset",
"(",
"$",
"dummy",
")",
";",
"break",
";",
"default",
":",
"//trigger_error($this->_error_prefix . 'Imagetype not supported.', E_USER_ERROR);",
"return",
"null",
";",
"}",
"return",
"$",
"filedata",
";",
"}",
"else",
"{",
"//trigger_error($this->_error_prefix . 'Imagefile (' . $filename . ') does not exist.', E_USER_ERROR);",
"return",
"null",
";",
"}",
"}"
] |
Loads a image file
@access private
@param string $filename imagefile to load
@return array associative array with the loaded filedata
|
[
"Loads",
"a",
"image",
"file"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L514-L570
|
23,118
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox.setResizeMethod
|
function setResizeMethod($method)
{
switch ($method)
{
case 1:
case 'resize':
$this->_resize_function = 'imagecopyresized';
break;
case 2:
case 'resample':
if (!function_exists('imagecopyresampled'))
{
// no error message. just return false.
return null;
}
$this->_resize_function = 'imagecopyresampled';
break;
case 3:
case 'resample_workaround':
case 'workaround':
case 'bicubic':
$this->_resize_function = '$this->_imageCopyResampledWorkaround';
break;
case 4:
case 'resample_workaround2':
case 'workaround2':
case 'bicubic2':
$this->_resize_function = '$this->_imageCopyResampledWorkaround2';
break;
default:
return null;
}
return true;
}
|
php
|
function setResizeMethod($method)
{
switch ($method)
{
case 1:
case 'resize':
$this->_resize_function = 'imagecopyresized';
break;
case 2:
case 'resample':
if (!function_exists('imagecopyresampled'))
{
// no error message. just return false.
return null;
}
$this->_resize_function = 'imagecopyresampled';
break;
case 3:
case 'resample_workaround':
case 'workaround':
case 'bicubic':
$this->_resize_function = '$this->_imageCopyResampledWorkaround';
break;
case 4:
case 'resample_workaround2':
case 'workaround2':
case 'bicubic2':
$this->_resize_function = '$this->_imageCopyResampledWorkaround2';
break;
default:
return null;
}
return true;
}
|
[
"function",
"setResizeMethod",
"(",
"$",
"method",
")",
"{",
"switch",
"(",
"$",
"method",
")",
"{",
"case",
"1",
":",
"case",
"'resize'",
":",
"$",
"this",
"->",
"_resize_function",
"=",
"'imagecopyresized'",
";",
"break",
";",
"case",
"2",
":",
"case",
"'resample'",
":",
"if",
"(",
"!",
"function_exists",
"(",
"'imagecopyresampled'",
")",
")",
"{",
"// no error message. just return false.",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"_resize_function",
"=",
"'imagecopyresampled'",
";",
"break",
";",
"case",
"3",
":",
"case",
"'resample_workaround'",
":",
"case",
"'workaround'",
":",
"case",
"'bicubic'",
":",
"$",
"this",
"->",
"_resize_function",
"=",
"'$this->_imageCopyResampledWorkaround'",
";",
"break",
";",
"case",
"4",
":",
"case",
"'resample_workaround2'",
":",
"case",
"'workaround2'",
":",
"case",
"'bicubic2'",
":",
"$",
"this",
"->",
"_resize_function",
"=",
"'$this->_imageCopyResampledWorkaround2'",
";",
"break",
";",
"default",
":",
"return",
"null",
";",
"}",
"return",
"true",
";",
"}"
] |
Sets the resize method of choice
$method can be one of the following:<br>
<ul>
<li>'resize' -> supported by every version of GD (fast but ugly resize of image)</li>
<li>'resample' -> only supported by GD version >= 2.0 (slower but antialiased resize of image)</li>
<li>'workaround' -> supported by every version of GD (workaround function for bicubic resizing, downsizing, VERY slow!, taken from php.net comments)</li>
<li>'workaround2' -> supported by every version of GD (alternative workaround function for bicubic resizing, down- and upsizing, VERY VERY slow!, taken from php.net comments)</li>
</ul>
@param string|integer $method resize method
@return bool true on success, otherwise false
|
[
"Sets",
"the",
"resize",
"method",
"of",
"choice"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L827-L860
|
23,119
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox.addImage
|
function addImage()
{
$args = func_get_args();
$argc = func_num_args();
if ($this->_addImage($argc, $args))
{
return true;
}
else
{
//trigger_error($this->_error_prefix . 'failed to add image.', E_USER_ERROR);
return false;
}
}
|
php
|
function addImage()
{
$args = func_get_args();
$argc = func_num_args();
if ($this->_addImage($argc, $args))
{
return true;
}
else
{
//trigger_error($this->_error_prefix . 'failed to add image.', E_USER_ERROR);
return false;
}
}
|
[
"function",
"addImage",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"argc",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_addImage",
"(",
"$",
"argc",
",",
"$",
"args",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"//trigger_error($this->_error_prefix . 'failed to add image.', E_USER_ERROR);",
"return",
"false",
";",
"}",
"}"
] |
Adds a new image resource based on the given parameters.
It does not overwrite the existing image resource.<br>
Instead it is used to load a second image to merge with the existing image.
Parameter:<br>
<i>string</i> <b>$file</b> imagefile to load<br>
Or:<br>
<i>integer</i> <b>$width</b> imagewidth of new image to be created<br>
<i>integer</i> <b>$height</b> imageheight of new image to be created<br>
<i>string</i> <b>$fillcolor</b> optional fill the new image with this color (hexformat, e.g. '#FF0000')<br>
|
[
"Adds",
"a",
"new",
"image",
"resource",
"based",
"on",
"the",
"given",
"parameters",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L1056-L1070
|
23,120
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox.addText
|
function addText($text, $font, $size, $color, $x, $y, $angle = 0)
{
global $HTTP_SERVER_VARS;
if (substr($font, 0, 1) == DIRECTORY_SEPARATOR || (substr($font, 1, 1) == ":" && (substr($font, 2, 1) == "\\" || substr($font, 2, 1) == "/")))
{
$prepath = '';
}
else
{
$prepath = substr($HTTP_SERVER_VARS['SCRIPT_FILENAME'], 0, strrpos($HTTP_SERVER_VARS['SCRIPT_FILENAME'], DIRECTORY_SEPARATOR)) . DIRECTORY_SEPARATOR;
}
$text = $this->_iso2uni($text);
if (is_string($x) || is_string($y))
{
$textsize = imagettfbbox($size, $angle, $prepath . $font, $text);
$textwidth = abs($textsize[2]);
$textheight = abs($textsize[7]);
list($xalign, $xalign_offset) = explode(" ", $x);
list($yalign, $yalign_offset) = explode(" ", $y);
}
if (is_string($x))
{
switch ($xalign)
{
case 'left':
$x = 0 + $xalign_offset;
break;
case 'right':
$x = ($this->_img['main']['width'] - $textwidth) + $xalign_offset;
break;
case 'middle':
case 'center':
$x = (($this->_img['main']['width'] - $textwidth) / 2) + $xalign_offset;
break;
}
}
if (is_string($y))
{
switch ($yalign)
{
case 'top':
$y = (0 + $textheight) + $yalign_offset;
break;
case 'bottom':
$y = ($this->_img['main']['height']) + $yalign_offset;
break;
case 'middle':
case 'center':
$y = ((($this->_img['main']['height'] - $textheight) / 2) + $textheight) + $yalign_offset;
break;
}
}
imagettftext($this->_img['main']['resource'], $size, $angle, $x, $y, $this->_hexToPHPColor($color), $prepath . $font, $text);
return true;
}
|
php
|
function addText($text, $font, $size, $color, $x, $y, $angle = 0)
{
global $HTTP_SERVER_VARS;
if (substr($font, 0, 1) == DIRECTORY_SEPARATOR || (substr($font, 1, 1) == ":" && (substr($font, 2, 1) == "\\" || substr($font, 2, 1) == "/")))
{
$prepath = '';
}
else
{
$prepath = substr($HTTP_SERVER_VARS['SCRIPT_FILENAME'], 0, strrpos($HTTP_SERVER_VARS['SCRIPT_FILENAME'], DIRECTORY_SEPARATOR)) . DIRECTORY_SEPARATOR;
}
$text = $this->_iso2uni($text);
if (is_string($x) || is_string($y))
{
$textsize = imagettfbbox($size, $angle, $prepath . $font, $text);
$textwidth = abs($textsize[2]);
$textheight = abs($textsize[7]);
list($xalign, $xalign_offset) = explode(" ", $x);
list($yalign, $yalign_offset) = explode(" ", $y);
}
if (is_string($x))
{
switch ($xalign)
{
case 'left':
$x = 0 + $xalign_offset;
break;
case 'right':
$x = ($this->_img['main']['width'] - $textwidth) + $xalign_offset;
break;
case 'middle':
case 'center':
$x = (($this->_img['main']['width'] - $textwidth) / 2) + $xalign_offset;
break;
}
}
if (is_string($y))
{
switch ($yalign)
{
case 'top':
$y = (0 + $textheight) + $yalign_offset;
break;
case 'bottom':
$y = ($this->_img['main']['height']) + $yalign_offset;
break;
case 'middle':
case 'center':
$y = ((($this->_img['main']['height'] - $textheight) / 2) + $textheight) + $yalign_offset;
break;
}
}
imagettftext($this->_img['main']['resource'], $size, $angle, $x, $y, $this->_hexToPHPColor($color), $prepath . $font, $text);
return true;
}
|
[
"function",
"addText",
"(",
"$",
"text",
",",
"$",
"font",
",",
"$",
"size",
",",
"$",
"color",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"angle",
"=",
"0",
")",
"{",
"global",
"$",
"HTTP_SERVER_VARS",
";",
"if",
"(",
"substr",
"(",
"$",
"font",
",",
"0",
",",
"1",
")",
"==",
"DIRECTORY_SEPARATOR",
"||",
"(",
"substr",
"(",
"$",
"font",
",",
"1",
",",
"1",
")",
"==",
"\":\"",
"&&",
"(",
"substr",
"(",
"$",
"font",
",",
"2",
",",
"1",
")",
"==",
"\"\\\\\"",
"||",
"substr",
"(",
"$",
"font",
",",
"2",
",",
"1",
")",
"==",
"\"/\"",
")",
")",
")",
"{",
"$",
"prepath",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"prepath",
"=",
"substr",
"(",
"$",
"HTTP_SERVER_VARS",
"[",
"'SCRIPT_FILENAME'",
"]",
",",
"0",
",",
"strrpos",
"(",
"$",
"HTTP_SERVER_VARS",
"[",
"'SCRIPT_FILENAME'",
"]",
",",
"DIRECTORY_SEPARATOR",
")",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"}",
"$",
"text",
"=",
"$",
"this",
"->",
"_iso2uni",
"(",
"$",
"text",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"x",
")",
"||",
"is_string",
"(",
"$",
"y",
")",
")",
"{",
"$",
"textsize",
"=",
"imagettfbbox",
"(",
"$",
"size",
",",
"$",
"angle",
",",
"$",
"prepath",
".",
"$",
"font",
",",
"$",
"text",
")",
";",
"$",
"textwidth",
"=",
"abs",
"(",
"$",
"textsize",
"[",
"2",
"]",
")",
";",
"$",
"textheight",
"=",
"abs",
"(",
"$",
"textsize",
"[",
"7",
"]",
")",
";",
"list",
"(",
"$",
"xalign",
",",
"$",
"xalign_offset",
")",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"x",
")",
";",
"list",
"(",
"$",
"yalign",
",",
"$",
"yalign_offset",
")",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"y",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"x",
")",
")",
"{",
"switch",
"(",
"$",
"xalign",
")",
"{",
"case",
"'left'",
":",
"$",
"x",
"=",
"0",
"+",
"$",
"xalign_offset",
";",
"break",
";",
"case",
"'right'",
":",
"$",
"x",
"=",
"(",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"'width'",
"]",
"-",
"$",
"textwidth",
")",
"+",
"$",
"xalign_offset",
";",
"break",
";",
"case",
"'middle'",
":",
"case",
"'center'",
":",
"$",
"x",
"=",
"(",
"(",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"'width'",
"]",
"-",
"$",
"textwidth",
")",
"/",
"2",
")",
"+",
"$",
"xalign_offset",
";",
"break",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"y",
")",
")",
"{",
"switch",
"(",
"$",
"yalign",
")",
"{",
"case",
"'top'",
":",
"$",
"y",
"=",
"(",
"0",
"+",
"$",
"textheight",
")",
"+",
"$",
"yalign_offset",
";",
"break",
";",
"case",
"'bottom'",
":",
"$",
"y",
"=",
"(",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"'height'",
"]",
")",
"+",
"$",
"yalign_offset",
";",
"break",
";",
"case",
"'middle'",
":",
"case",
"'center'",
":",
"$",
"y",
"=",
"(",
"(",
"(",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"'height'",
"]",
"-",
"$",
"textheight",
")",
"/",
"2",
")",
"+",
"$",
"textheight",
")",
"+",
"$",
"yalign_offset",
";",
"break",
";",
"}",
"}",
"imagettftext",
"(",
"$",
"this",
"->",
"_img",
"[",
"'main'",
"]",
"[",
"'resource'",
"]",
",",
"$",
"size",
",",
"$",
"angle",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"this",
"->",
"_hexToPHPColor",
"(",
"$",
"color",
")",
",",
"$",
"prepath",
".",
"$",
"font",
",",
"$",
"text",
")",
";",
"return",
"true",
";",
"}"
] |
Writes text over the image
only TTF fonts are supported at the moment
$x:<br>
You can also use the following keywords ('left', 'center' or 'middle', 'right').<br>
Additionally you can specify an offset in pixel with the keywords like this 'left +10'.<br>
(default = 0)
$y:<br>
You can also use the following keywords ('top', 'center' or 'middle', 'bottom').<br>
Additionally you can specify an offset in pixel with the keywords like this 'bottom -10'.<br>
(default = 0)
@param string $text text to be generated.
@param string $font TTF fontfile to be used. (relative paths are ok).
@param integer $size textsize.
@param string $color textcolor in hexformat (e.g. '#FF0000').
@param string|integer $x horizontal postion in pixel.
@param string|integer $y vertical postion in pixel.
@param integer $angle rotation of the text.
|
[
"Writes",
"text",
"over",
"the",
"image"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L1454-L1513
|
23,121
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox._imageCopyResampledWorkaround
|
function _imageCopyResampledWorkaround(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
/*
for ($i = 0; $i < imagecolorstotal($src_img); $i++)
{
$colors = ImageColorsForIndex ($src_img, $i);
ImageColorAllocate ($dst_img, $colors['red'],$colors['green'], $colors['blue']);
}
*/
$scaleX = ($src_w - 1) / $dst_w;
$scaleY = ($src_h - 1) / $dst_h;
$scaleX2 = $scaleX / 2.0;
$scaleY2 = $scaleY / 2.0;
for ($j = $src_y; $j < $src_y + $dst_h; $j++)
{
$sY = $j * $scaleY;
for ($i = $src_x; $i < $src_x + $dst_w; $i++)
{
$sX = $i * $scaleX;
$c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX, (int)$sY + $scaleY2));
$c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX, (int)$sY));
$c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX + $scaleX2, (int)$sY + $scaleY2));
$c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX + $scaleX2, (int)$sY));
$red = (integer)(($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4);
$green = (integer)(($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4);
$blue = (integer)(($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4);
$color = ImageColorClosest($dst_img, $red, $green, $blue);
ImageSetPixel($dst_img, $dst_x + $i - $src_x, $dst_y + $j - $src_y, $color);
}
}
}
|
php
|
function _imageCopyResampledWorkaround(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
/*
for ($i = 0; $i < imagecolorstotal($src_img); $i++)
{
$colors = ImageColorsForIndex ($src_img, $i);
ImageColorAllocate ($dst_img, $colors['red'],$colors['green'], $colors['blue']);
}
*/
$scaleX = ($src_w - 1) / $dst_w;
$scaleY = ($src_h - 1) / $dst_h;
$scaleX2 = $scaleX / 2.0;
$scaleY2 = $scaleY / 2.0;
for ($j = $src_y; $j < $src_y + $dst_h; $j++)
{
$sY = $j * $scaleY;
for ($i = $src_x; $i < $src_x + $dst_w; $i++)
{
$sX = $i * $scaleX;
$c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX, (int)$sY + $scaleY2));
$c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX, (int)$sY));
$c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX + $scaleX2, (int)$sY + $scaleY2));
$c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX + $scaleX2, (int)$sY));
$red = (integer)(($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4);
$green = (integer)(($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4);
$blue = (integer)(($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4);
$color = ImageColorClosest($dst_img, $red, $green, $blue);
ImageSetPixel($dst_img, $dst_x + $i - $src_x, $dst_y + $j - $src_y, $color);
}
}
}
|
[
"function",
"_imageCopyResampledWorkaround",
"(",
"&",
"$",
"dst_img",
",",
"&",
"$",
"src_img",
",",
"$",
"dst_x",
",",
"$",
"dst_y",
",",
"$",
"src_x",
",",
"$",
"src_y",
",",
"$",
"dst_w",
",",
"$",
"dst_h",
",",
"$",
"src_w",
",",
"$",
"src_h",
")",
"{",
"/*\n for ($i = 0; $i < imagecolorstotal($src_img); $i++)\n {\n $colors = ImageColorsForIndex ($src_img, $i);\n ImageColorAllocate ($dst_img, $colors['red'],$colors['green'], $colors['blue']);\n }\n */",
"$",
"scaleX",
"=",
"(",
"$",
"src_w",
"-",
"1",
")",
"/",
"$",
"dst_w",
";",
"$",
"scaleY",
"=",
"(",
"$",
"src_h",
"-",
"1",
")",
"/",
"$",
"dst_h",
";",
"$",
"scaleX2",
"=",
"$",
"scaleX",
"/",
"2.0",
";",
"$",
"scaleY2",
"=",
"$",
"scaleY",
"/",
"2.0",
";",
"for",
"(",
"$",
"j",
"=",
"$",
"src_y",
";",
"$",
"j",
"<",
"$",
"src_y",
"+",
"$",
"dst_h",
";",
"$",
"j",
"++",
")",
"{",
"$",
"sY",
"=",
"$",
"j",
"*",
"$",
"scaleY",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"src_x",
";",
"$",
"i",
"<",
"$",
"src_x",
"+",
"$",
"dst_w",
";",
"$",
"i",
"++",
")",
"{",
"$",
"sX",
"=",
"$",
"i",
"*",
"$",
"scaleX",
";",
"$",
"c1",
"=",
"ImageColorsForIndex",
"(",
"$",
"src_img",
",",
"ImageColorAt",
"(",
"$",
"src_img",
",",
"(",
"int",
")",
"$",
"sX",
",",
"(",
"int",
")",
"$",
"sY",
"+",
"$",
"scaleY2",
")",
")",
";",
"$",
"c2",
"=",
"ImageColorsForIndex",
"(",
"$",
"src_img",
",",
"ImageColorAt",
"(",
"$",
"src_img",
",",
"(",
"int",
")",
"$",
"sX",
",",
"(",
"int",
")",
"$",
"sY",
")",
")",
";",
"$",
"c3",
"=",
"ImageColorsForIndex",
"(",
"$",
"src_img",
",",
"ImageColorAt",
"(",
"$",
"src_img",
",",
"(",
"int",
")",
"$",
"sX",
"+",
"$",
"scaleX2",
",",
"(",
"int",
")",
"$",
"sY",
"+",
"$",
"scaleY2",
")",
")",
";",
"$",
"c4",
"=",
"ImageColorsForIndex",
"(",
"$",
"src_img",
",",
"ImageColorAt",
"(",
"$",
"src_img",
",",
"(",
"int",
")",
"$",
"sX",
"+",
"$",
"scaleX2",
",",
"(",
"int",
")",
"$",
"sY",
")",
")",
";",
"$",
"red",
"=",
"(",
"integer",
")",
"(",
"(",
"$",
"c1",
"[",
"'red'",
"]",
"+",
"$",
"c2",
"[",
"'red'",
"]",
"+",
"$",
"c3",
"[",
"'red'",
"]",
"+",
"$",
"c4",
"[",
"'red'",
"]",
")",
"/",
"4",
")",
";",
"$",
"green",
"=",
"(",
"integer",
")",
"(",
"(",
"$",
"c1",
"[",
"'green'",
"]",
"+",
"$",
"c2",
"[",
"'green'",
"]",
"+",
"$",
"c3",
"[",
"'green'",
"]",
"+",
"$",
"c4",
"[",
"'green'",
"]",
")",
"/",
"4",
")",
";",
"$",
"blue",
"=",
"(",
"integer",
")",
"(",
"(",
"$",
"c1",
"[",
"'blue'",
"]",
"+",
"$",
"c2",
"[",
"'blue'",
"]",
"+",
"$",
"c3",
"[",
"'blue'",
"]",
"+",
"$",
"c4",
"[",
"'blue'",
"]",
")",
"/",
"4",
")",
";",
"$",
"color",
"=",
"ImageColorClosest",
"(",
"$",
"dst_img",
",",
"$",
"red",
",",
"$",
"green",
",",
"$",
"blue",
")",
";",
"ImageSetPixel",
"(",
"$",
"dst_img",
",",
"$",
"dst_x",
"+",
"$",
"i",
"-",
"$",
"src_x",
",",
"$",
"dst_y",
"+",
"$",
"j",
"-",
"$",
"src_y",
",",
"$",
"color",
")",
";",
"}",
"}",
"}"
] |
workaround function for bicubic resizing. works well for downsizing only. VERY slow. taken from php.net comments
@access private
|
[
"workaround",
"function",
"for",
"bicubic",
"resizing",
".",
"works",
"well",
"for",
"downsizing",
"only",
".",
"VERY",
"slow",
".",
"taken",
"from",
"php",
".",
"net",
"comments"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L1520-L1555
|
23,122
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
|
Image_Toolbox._imageCopyResampledWorkaround2
|
function _imageCopyResampledWorkaround2(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
ImagePaletteCopy($dst_img, $src_img);
$rX = $src_w / $dst_w;
$rY = $src_h / $dst_h;
$w = 0;
for ($y = $dst_y; $y < $dst_h; $y++)
{
$ow = $w;
$w = round(($y + 1) * $rY);
$t = 0;
for ($x = $dst_x; $x < $dst_w; $x++)
{
$r = $g = $b = 0;
$a = 0;
$ot = $t;
$t = round(($x + 1) * $rX);
for ($u = 0; $u < ($w - $ow); $u++)
{
for ($p = 0; $p < ($t - $ot); $p++)
{
$c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $ot + $p, $ow + $u));
$r += $c['red'];
$g += $c['green'];
$b += $c['blue'];
$a++;
}
}
ImageSetPixel($dst_img, $x, $y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
}
}
}
|
php
|
function _imageCopyResampledWorkaround2(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
{
ImagePaletteCopy($dst_img, $src_img);
$rX = $src_w / $dst_w;
$rY = $src_h / $dst_h;
$w = 0;
for ($y = $dst_y; $y < $dst_h; $y++)
{
$ow = $w;
$w = round(($y + 1) * $rY);
$t = 0;
for ($x = $dst_x; $x < $dst_w; $x++)
{
$r = $g = $b = 0;
$a = 0;
$ot = $t;
$t = round(($x + 1) * $rX);
for ($u = 0; $u < ($w - $ow); $u++)
{
for ($p = 0; $p < ($t - $ot); $p++)
{
$c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $ot + $p, $ow + $u));
$r += $c['red'];
$g += $c['green'];
$b += $c['blue'];
$a++;
}
}
ImageSetPixel($dst_img, $x, $y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
}
}
}
|
[
"function",
"_imageCopyResampledWorkaround2",
"(",
"&",
"$",
"dst_img",
",",
"&",
"$",
"src_img",
",",
"$",
"dst_x",
",",
"$",
"dst_y",
",",
"$",
"src_x",
",",
"$",
"src_y",
",",
"$",
"dst_w",
",",
"$",
"dst_h",
",",
"$",
"src_w",
",",
"$",
"src_h",
")",
"{",
"ImagePaletteCopy",
"(",
"$",
"dst_img",
",",
"$",
"src_img",
")",
";",
"$",
"rX",
"=",
"$",
"src_w",
"/",
"$",
"dst_w",
";",
"$",
"rY",
"=",
"$",
"src_h",
"/",
"$",
"dst_h",
";",
"$",
"w",
"=",
"0",
";",
"for",
"(",
"$",
"y",
"=",
"$",
"dst_y",
";",
"$",
"y",
"<",
"$",
"dst_h",
";",
"$",
"y",
"++",
")",
"{",
"$",
"ow",
"=",
"$",
"w",
";",
"$",
"w",
"=",
"round",
"(",
"(",
"$",
"y",
"+",
"1",
")",
"*",
"$",
"rY",
")",
";",
"$",
"t",
"=",
"0",
";",
"for",
"(",
"$",
"x",
"=",
"$",
"dst_x",
";",
"$",
"x",
"<",
"$",
"dst_w",
";",
"$",
"x",
"++",
")",
"{",
"$",
"r",
"=",
"$",
"g",
"=",
"$",
"b",
"=",
"0",
";",
"$",
"a",
"=",
"0",
";",
"$",
"ot",
"=",
"$",
"t",
";",
"$",
"t",
"=",
"round",
"(",
"(",
"$",
"x",
"+",
"1",
")",
"*",
"$",
"rX",
")",
";",
"for",
"(",
"$",
"u",
"=",
"0",
";",
"$",
"u",
"<",
"(",
"$",
"w",
"-",
"$",
"ow",
")",
";",
"$",
"u",
"++",
")",
"{",
"for",
"(",
"$",
"p",
"=",
"0",
";",
"$",
"p",
"<",
"(",
"$",
"t",
"-",
"$",
"ot",
")",
";",
"$",
"p",
"++",
")",
"{",
"$",
"c",
"=",
"ImageColorsForIndex",
"(",
"$",
"src_img",
",",
"ImageColorAt",
"(",
"$",
"src_img",
",",
"$",
"ot",
"+",
"$",
"p",
",",
"$",
"ow",
"+",
"$",
"u",
")",
")",
";",
"$",
"r",
"+=",
"$",
"c",
"[",
"'red'",
"]",
";",
"$",
"g",
"+=",
"$",
"c",
"[",
"'green'",
"]",
";",
"$",
"b",
"+=",
"$",
"c",
"[",
"'blue'",
"]",
";",
"$",
"a",
"++",
";",
"}",
"}",
"ImageSetPixel",
"(",
"$",
"dst_img",
",",
"$",
"x",
",",
"$",
"y",
",",
"ImageColorClosest",
"(",
"$",
"dst_img",
",",
"$",
"r",
"/",
"$",
"a",
",",
"$",
"g",
"/",
"$",
"a",
",",
"$",
"b",
"/",
"$",
"a",
")",
")",
";",
"}",
"}",
"}"
] |
alternative workaround function for bicubic resizing. works well for downsizing and upsizing. VERY VERY slow. taken from php.net comments
@access private
|
[
"alternative",
"workaround",
"function",
"for",
"bicubic",
"resizing",
".",
"works",
"well",
"for",
"downsizing",
"and",
"upsizing",
".",
"VERY",
"VERY",
"slow",
".",
"taken",
"from",
"php",
".",
"net",
"comments"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php#L1562-L1593
|
23,123
|
99designs/ergo-http
|
src/HeaderField.php
|
HeaderField.fromString
|
public static function fromString($headerString)
{
$headerString = trim($headerString);
list($name, $value) = explode(': ', trim($headerString), 2);
return new self($name, $value);
}
|
php
|
public static function fromString($headerString)
{
$headerString = trim($headerString);
list($name, $value) = explode(': ', trim($headerString), 2);
return new self($name, $value);
}
|
[
"public",
"static",
"function",
"fromString",
"(",
"$",
"headerString",
")",
"{",
"$",
"headerString",
"=",
"trim",
"(",
"$",
"headerString",
")",
";",
"list",
"(",
"$",
"name",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"': '",
",",
"trim",
"(",
"$",
"headerString",
")",
",",
"2",
")",
";",
"return",
"new",
"self",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] |
Creates a header from a string representing a single header.
@param string $headerString
@return
|
[
"Creates",
"a",
"header",
"from",
"a",
"string",
"representing",
"a",
"single",
"header",
"."
] |
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
|
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderField.php#L76-L81
|
23,124
|
CupOfTea696/WordPress-Composer
|
src/Installer.php
|
Installer.installDotEnv
|
protected function installDotEnv(PackageInterface $package)
{
$templatePath = $this->getTempPath($package) . '/.env.template';
$dotEnvPath = $this->getInstallPath($package) . '/.env';
$dotEnvExamplePath = $this->getInstallPath($package) . '/.env.example';
if (! file_exists($templatePath)) {
return;
}
$saltKeys = [
'AUTH_KEY',
'SECURE_AUTH_KEY',
'LOGGED_IN_KEY',
'NONCE_KEY',
'AUTH_SALT',
'SECURE_AUTH_SALT',
'LOGGED_IN_SALT',
'NONCE_SALT',
];
$envExample = ['APP_PUBLIC' => 'public'];
foreach ($saltKeys as $salt) {
$envExample[$salt] = 'YOUR_' . $salt . '_GOES_HERE';
}
$this->compileTemplate($templatePath, $dotEnvExamplePath, $envExample);
if (file_exists($dotEnvPath)) {
return;
}
$env = ['APP_PUBLIC' => $this->plugin->getPublicDirectory()];
foreach ($saltKeys as $salt) {
$env[$salt] = $this->generateSalt();
}
$this->compileTemplate($templatePath, $dotEnvPath, $env);
}
|
php
|
protected function installDotEnv(PackageInterface $package)
{
$templatePath = $this->getTempPath($package) . '/.env.template';
$dotEnvPath = $this->getInstallPath($package) . '/.env';
$dotEnvExamplePath = $this->getInstallPath($package) . '/.env.example';
if (! file_exists($templatePath)) {
return;
}
$saltKeys = [
'AUTH_KEY',
'SECURE_AUTH_KEY',
'LOGGED_IN_KEY',
'NONCE_KEY',
'AUTH_SALT',
'SECURE_AUTH_SALT',
'LOGGED_IN_SALT',
'NONCE_SALT',
];
$envExample = ['APP_PUBLIC' => 'public'];
foreach ($saltKeys as $salt) {
$envExample[$salt] = 'YOUR_' . $salt . '_GOES_HERE';
}
$this->compileTemplate($templatePath, $dotEnvExamplePath, $envExample);
if (file_exists($dotEnvPath)) {
return;
}
$env = ['APP_PUBLIC' => $this->plugin->getPublicDirectory()];
foreach ($saltKeys as $salt) {
$env[$salt] = $this->generateSalt();
}
$this->compileTemplate($templatePath, $dotEnvPath, $env);
}
|
[
"protected",
"function",
"installDotEnv",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"templatePath",
"=",
"$",
"this",
"->",
"getTempPath",
"(",
"$",
"package",
")",
".",
"'/.env.template'",
";",
"$",
"dotEnvPath",
"=",
"$",
"this",
"->",
"getInstallPath",
"(",
"$",
"package",
")",
".",
"'/.env'",
";",
"$",
"dotEnvExamplePath",
"=",
"$",
"this",
"->",
"getInstallPath",
"(",
"$",
"package",
")",
".",
"'/.env.example'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"templatePath",
")",
")",
"{",
"return",
";",
"}",
"$",
"saltKeys",
"=",
"[",
"'AUTH_KEY'",
",",
"'SECURE_AUTH_KEY'",
",",
"'LOGGED_IN_KEY'",
",",
"'NONCE_KEY'",
",",
"'AUTH_SALT'",
",",
"'SECURE_AUTH_SALT'",
",",
"'LOGGED_IN_SALT'",
",",
"'NONCE_SALT'",
",",
"]",
";",
"$",
"envExample",
"=",
"[",
"'APP_PUBLIC'",
"=>",
"'public'",
"]",
";",
"foreach",
"(",
"$",
"saltKeys",
"as",
"$",
"salt",
")",
"{",
"$",
"envExample",
"[",
"$",
"salt",
"]",
"=",
"'YOUR_'",
".",
"$",
"salt",
".",
"'_GOES_HERE'",
";",
"}",
"$",
"this",
"->",
"compileTemplate",
"(",
"$",
"templatePath",
",",
"$",
"dotEnvExamplePath",
",",
"$",
"envExample",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"dotEnvPath",
")",
")",
"{",
"return",
";",
"}",
"$",
"env",
"=",
"[",
"'APP_PUBLIC'",
"=>",
"$",
"this",
"->",
"plugin",
"->",
"getPublicDirectory",
"(",
")",
"]",
";",
"foreach",
"(",
"$",
"saltKeys",
"as",
"$",
"salt",
")",
"{",
"$",
"env",
"[",
"$",
"salt",
"]",
"=",
"$",
"this",
"->",
"generateSalt",
"(",
")",
";",
"}",
"$",
"this",
"->",
"compileTemplate",
"(",
"$",
"templatePath",
",",
"$",
"dotEnvPath",
",",
"$",
"env",
")",
";",
"}"
] |
Set up the .env file.
@param \Composer\Package\PackageInterface $package
@return void
|
[
"Set",
"up",
"the",
".",
"env",
"file",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/Installer.php#L213-L253
|
23,125
|
CupOfTea696/WordPress-Composer
|
src/Installer.php
|
Installer.checkWordPressInstallation
|
protected function checkWordPressInstallation()
{
$defaultWpInstallDir = $this->plugin->getRootDirectory() . '/wordpress';
$wpInstallDir = $this->getComposerConfigurator()->getWordPressInstallDirectory();
if (file_exists($defaultWpInstallDir) && is_dir($defaultWpInstallDir)) {
if (! is_dir($wpInstallDir)) {
if (file_exists($wpInstallDir)) {
unlink($wpInstallDir);
}
rename($defaultWpInstallDir, $wpInstallDir);
} else {
rmdir($defaultWpInstallDir);
}
}
}
|
php
|
protected function checkWordPressInstallation()
{
$defaultWpInstallDir = $this->plugin->getRootDirectory() . '/wordpress';
$wpInstallDir = $this->getComposerConfigurator()->getWordPressInstallDirectory();
if (file_exists($defaultWpInstallDir) && is_dir($defaultWpInstallDir)) {
if (! is_dir($wpInstallDir)) {
if (file_exists($wpInstallDir)) {
unlink($wpInstallDir);
}
rename($defaultWpInstallDir, $wpInstallDir);
} else {
rmdir($defaultWpInstallDir);
}
}
}
|
[
"protected",
"function",
"checkWordPressInstallation",
"(",
")",
"{",
"$",
"defaultWpInstallDir",
"=",
"$",
"this",
"->",
"plugin",
"->",
"getRootDirectory",
"(",
")",
".",
"'/wordpress'",
";",
"$",
"wpInstallDir",
"=",
"$",
"this",
"->",
"getComposerConfigurator",
"(",
")",
"->",
"getWordPressInstallDirectory",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"defaultWpInstallDir",
")",
"&&",
"is_dir",
"(",
"$",
"defaultWpInstallDir",
")",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"wpInstallDir",
")",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"wpInstallDir",
")",
")",
"{",
"unlink",
"(",
"$",
"wpInstallDir",
")",
";",
"}",
"rename",
"(",
"$",
"defaultWpInstallDir",
",",
"$",
"wpInstallDir",
")",
";",
"}",
"else",
"{",
"rmdir",
"(",
"$",
"defaultWpInstallDir",
")",
";",
"}",
"}",
"}"
] |
Check if WordPress is installed in the correct directory,
and move it there if it is not.
@return void
|
[
"Check",
"if",
"WordPress",
"is",
"installed",
"in",
"the",
"correct",
"directory",
"and",
"move",
"it",
"there",
"if",
"it",
"is",
"not",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/Installer.php#L281-L297
|
23,126
|
CupOfTea696/WordPress-Composer
|
src/Installer.php
|
Installer.selectPreferredLanguageOnWordPressInstall
|
protected function selectPreferredLanguageOnWordPressInstall()
{
$wpInstallScriptPath = $this->getComposerConfigurator()->getWordPressInstallDirectory() . '/wp-admin/install.php';
if (file_exists($wpInstallScriptPath)) {
$wpInstallScript = file_get_contents($wpInstallScriptPath);
$wpInstallScript = preg_replace('/<\\/body>\\n<\\/html>\\s*$/', '<script>' . PHP_EOL
. 'if (jQuery(\'#language\').find(\'option[value="en_GB"]\').length) {' . PHP_EOL
. ' jQuery(\'#language\').val(\'en_GB\').change();' . PHP_EOL
. '}' . PHP_EOL
. '</script>' . PHP_EOL
. '</body>' . PHP_EOL
. '</html>' . PHP_EOL, $wpInstallScript);
file_put_contents($wpInstallScriptPath, $wpInstallScript);
}
}
|
php
|
protected function selectPreferredLanguageOnWordPressInstall()
{
$wpInstallScriptPath = $this->getComposerConfigurator()->getWordPressInstallDirectory() . '/wp-admin/install.php';
if (file_exists($wpInstallScriptPath)) {
$wpInstallScript = file_get_contents($wpInstallScriptPath);
$wpInstallScript = preg_replace('/<\\/body>\\n<\\/html>\\s*$/', '<script>' . PHP_EOL
. 'if (jQuery(\'#language\').find(\'option[value="en_GB"]\').length) {' . PHP_EOL
. ' jQuery(\'#language\').val(\'en_GB\').change();' . PHP_EOL
. '}' . PHP_EOL
. '</script>' . PHP_EOL
. '</body>' . PHP_EOL
. '</html>' . PHP_EOL, $wpInstallScript);
file_put_contents($wpInstallScriptPath, $wpInstallScript);
}
}
|
[
"protected",
"function",
"selectPreferredLanguageOnWordPressInstall",
"(",
")",
"{",
"$",
"wpInstallScriptPath",
"=",
"$",
"this",
"->",
"getComposerConfigurator",
"(",
")",
"->",
"getWordPressInstallDirectory",
"(",
")",
".",
"'/wp-admin/install.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"wpInstallScriptPath",
")",
")",
"{",
"$",
"wpInstallScript",
"=",
"file_get_contents",
"(",
"$",
"wpInstallScriptPath",
")",
";",
"$",
"wpInstallScript",
"=",
"preg_replace",
"(",
"'/<\\\\/body>\\\\n<\\\\/html>\\\\s*$/'",
",",
"'<script>'",
".",
"PHP_EOL",
".",
"'if (jQuery(\\'#language\\').find(\\'option[value=\"en_GB\"]\\').length) {'",
".",
"PHP_EOL",
".",
"' jQuery(\\'#language\\').val(\\'en_GB\\').change();'",
".",
"PHP_EOL",
".",
"'}'",
".",
"PHP_EOL",
".",
"'</script>'",
".",
"PHP_EOL",
".",
"'</body>'",
".",
"PHP_EOL",
".",
"'</html>'",
".",
"PHP_EOL",
",",
"$",
"wpInstallScript",
")",
";",
"file_put_contents",
"(",
"$",
"wpInstallScriptPath",
",",
"$",
"wpInstallScript",
")",
";",
"}",
"}"
] |
Select the preferred en_GB option in the WordPress installation language form.
@return void
|
[
"Select",
"the",
"preferred",
"en_GB",
"option",
"in",
"the",
"WordPress",
"installation",
"language",
"form",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/Installer.php#L304-L320
|
23,127
|
CupOfTea696/WordPress-Composer
|
src/Installer.php
|
Installer.installFiles
|
protected function installFiles($installPath, $downloadPath, $publicPath, $files = [])
{
foreach ($files as $file => $overwrite) {
if ($overwrite || (! $overwrite && ! file_exists($installPath . '/' . $file))) {
if (! file_exists($downloadPath . '/' . $file)) {
throw new FilesystemException('The file ' . $file . ' could not be found. Please report to cupoftea/wordpress.');
}
$installFile = $installPath . '/' . $file;
if ($publicPath != 'public') {
$installFile = $installPath . '/' . preg_replace('/^public/', $publicPath, $file);
}
if (preg_match('/\\/$/', $file)) {
$this->filesystem->ensureDirectoryExists($installFile);
continue;
}
$this->filesystem->rename($downloadPath . '/' . $file, $installFile);
}
}
}
|
php
|
protected function installFiles($installPath, $downloadPath, $publicPath, $files = [])
{
foreach ($files as $file => $overwrite) {
if ($overwrite || (! $overwrite && ! file_exists($installPath . '/' . $file))) {
if (! file_exists($downloadPath . '/' . $file)) {
throw new FilesystemException('The file ' . $file . ' could not be found. Please report to cupoftea/wordpress.');
}
$installFile = $installPath . '/' . $file;
if ($publicPath != 'public') {
$installFile = $installPath . '/' . preg_replace('/^public/', $publicPath, $file);
}
if (preg_match('/\\/$/', $file)) {
$this->filesystem->ensureDirectoryExists($installFile);
continue;
}
$this->filesystem->rename($downloadPath . '/' . $file, $installFile);
}
}
}
|
[
"protected",
"function",
"installFiles",
"(",
"$",
"installPath",
",",
"$",
"downloadPath",
",",
"$",
"publicPath",
",",
"$",
"files",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
"=>",
"$",
"overwrite",
")",
"{",
"if",
"(",
"$",
"overwrite",
"||",
"(",
"!",
"$",
"overwrite",
"&&",
"!",
"file_exists",
"(",
"$",
"installPath",
".",
"'/'",
".",
"$",
"file",
")",
")",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"downloadPath",
".",
"'/'",
".",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"FilesystemException",
"(",
"'The file '",
".",
"$",
"file",
".",
"' could not be found. Please report to cupoftea/wordpress.'",
")",
";",
"}",
"$",
"installFile",
"=",
"$",
"installPath",
".",
"'/'",
".",
"$",
"file",
";",
"if",
"(",
"$",
"publicPath",
"!=",
"'public'",
")",
"{",
"$",
"installFile",
"=",
"$",
"installPath",
".",
"'/'",
".",
"preg_replace",
"(",
"'/^public/'",
",",
"$",
"publicPath",
",",
"$",
"file",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/\\\\/$/'",
",",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"ensureDirectoryExists",
"(",
"$",
"installFile",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"filesystem",
"->",
"rename",
"(",
"$",
"downloadPath",
".",
"'/'",
".",
"$",
"file",
",",
"$",
"installFile",
")",
";",
"}",
"}",
"}"
] |
Install files.
@param string $installPath
@param string $downloadPath
@param string $publicPath
@param array $files
@return void
|
[
"Install",
"files",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/Installer.php#L401-L424
|
23,128
|
CupOfTea696/WordPress-Composer
|
src/Installer.php
|
Installer.compileTemplate
|
private function compileTemplate($templatePath, $destinationPath, $data = null)
{
if ($data == null) {
$data = $destinationPath;
$destinationPath = null;
}
if (! isset($this->templates[$templatePath])) {
$this->templates[$templatePath] = file_get_contents($templatePath);
}
$compiled = preg_replace_callback('/{{\s*([A-z0-9_-]+)\s*}}/', function ($matches) use ($data) {
if (isset($data[$matches[1]])) {
return $data[$matches[1]];
}
return $matches[0];
}, $this->templates[$templatePath]);
if ($destinationPath) {
file_put_contents($destinationPath, $compiled);
}
return $compiled;
}
|
php
|
private function compileTemplate($templatePath, $destinationPath, $data = null)
{
if ($data == null) {
$data = $destinationPath;
$destinationPath = null;
}
if (! isset($this->templates[$templatePath])) {
$this->templates[$templatePath] = file_get_contents($templatePath);
}
$compiled = preg_replace_callback('/{{\s*([A-z0-9_-]+)\s*}}/', function ($matches) use ($data) {
if (isset($data[$matches[1]])) {
return $data[$matches[1]];
}
return $matches[0];
}, $this->templates[$templatePath]);
if ($destinationPath) {
file_put_contents($destinationPath, $compiled);
}
return $compiled;
}
|
[
"private",
"function",
"compileTemplate",
"(",
"$",
"templatePath",
",",
"$",
"destinationPath",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"data",
"==",
"null",
")",
"{",
"$",
"data",
"=",
"$",
"destinationPath",
";",
"$",
"destinationPath",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"templates",
"[",
"$",
"templatePath",
"]",
")",
")",
"{",
"$",
"this",
"->",
"templates",
"[",
"$",
"templatePath",
"]",
"=",
"file_get_contents",
"(",
"$",
"templatePath",
")",
";",
"}",
"$",
"compiled",
"=",
"preg_replace_callback",
"(",
"'/{{\\s*([A-z0-9_-]+)\\s*}}/'",
",",
"function",
"(",
"$",
"matches",
")",
"use",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
")",
")",
"{",
"return",
"$",
"data",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
";",
"}",
"return",
"$",
"matches",
"[",
"0",
"]",
";",
"}",
",",
"$",
"this",
"->",
"templates",
"[",
"$",
"templatePath",
"]",
")",
";",
"if",
"(",
"$",
"destinationPath",
")",
"{",
"file_put_contents",
"(",
"$",
"destinationPath",
",",
"$",
"compiled",
")",
";",
"}",
"return",
"$",
"compiled",
";",
"}"
] |
Compile a template file.
@param string $templatePath
@param string $destinationPath
@param array|null $data
@return string
|
[
"Compile",
"a",
"template",
"file",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/Installer.php#L434-L458
|
23,129
|
CupOfTea696/WordPress-Composer
|
src/Installer.php
|
Installer.sortRules
|
private function sortRules(&$rules)
{
sort($rules);
usort($rules, function ($a, $b) {
return strlen($a) - strlen($b);
});
}
|
php
|
private function sortRules(&$rules)
{
sort($rules);
usort($rules, function ($a, $b) {
return strlen($a) - strlen($b);
});
}
|
[
"private",
"function",
"sortRules",
"(",
"&",
"$",
"rules",
")",
"{",
"sort",
"(",
"$",
"rules",
")",
";",
"usort",
"(",
"$",
"rules",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"strlen",
"(",
"$",
"a",
")",
"-",
"strlen",
"(",
"$",
"b",
")",
";",
"}",
")",
";",
"}"
] |
Sort gitignore rules.
@param array &$rules
@return void
|
[
"Sort",
"gitignore",
"rules",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/Installer.php#L466-L472
|
23,130
|
CupOfTea696/WordPress-Composer
|
src/Installer.php
|
Installer.generateSalt
|
private function generateSalt()
{
$str = '';
$length = 64;
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(){}[]/|`,.?+-_=:;<> ';
$count = strlen($chars);
while ($length--) {
$str .= $chars[mt_rand(0, $count - 1)];
}
return 'base64:' . base64_encode($str);
}
|
php
|
private function generateSalt()
{
$str = '';
$length = 64;
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(){}[]/|`,.?+-_=:;<> ';
$count = strlen($chars);
while ($length--) {
$str .= $chars[mt_rand(0, $count - 1)];
}
return 'base64:' . base64_encode($str);
}
|
[
"private",
"function",
"generateSalt",
"(",
")",
"{",
"$",
"str",
"=",
"''",
";",
"$",
"length",
"=",
"64",
";",
"$",
"chars",
"=",
"'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(){}[]/|`,.?+-_=:;<> '",
";",
"$",
"count",
"=",
"strlen",
"(",
"$",
"chars",
")",
";",
"while",
"(",
"$",
"length",
"--",
")",
"{",
"$",
"str",
".=",
"$",
"chars",
"[",
"mt_rand",
"(",
"0",
",",
"$",
"count",
"-",
"1",
")",
"]",
";",
"}",
"return",
"'base64:'",
".",
"base64_encode",
"(",
"$",
"str",
")",
";",
"}"
] |
Generate a Salt Key.
@return string
|
[
"Generate",
"a",
"Salt",
"Key",
"."
] |
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
|
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/Installer.php#L479-L491
|
23,131
|
ShaoZeMing/laravel-merchant
|
src/Form/Field.php
|
Field.removeElementClass
|
public function removeElementClass($class)
{
$delClass = [];
if (is_string($class) || is_array($class)) {
$delClass = (array) $class;
}
foreach ($delClass as $del) {
if (($key = array_search($del, $this->elementClass))) {
unset($this->elementClass[$key]);
}
}
return $this;
}
|
php
|
public function removeElementClass($class)
{
$delClass = [];
if (is_string($class) || is_array($class)) {
$delClass = (array) $class;
}
foreach ($delClass as $del) {
if (($key = array_search($del, $this->elementClass))) {
unset($this->elementClass[$key]);
}
}
return $this;
}
|
[
"public",
"function",
"removeElementClass",
"(",
"$",
"class",
")",
"{",
"$",
"delClass",
"=",
"[",
"]",
";",
"if",
"(",
"is_string",
"(",
"$",
"class",
")",
"||",
"is_array",
"(",
"$",
"class",
")",
")",
"{",
"$",
"delClass",
"=",
"(",
"array",
")",
"$",
"class",
";",
"}",
"foreach",
"(",
"$",
"delClass",
"as",
"$",
"del",
")",
"{",
"if",
"(",
"(",
"$",
"key",
"=",
"array_search",
"(",
"$",
"del",
",",
"$",
"this",
"->",
"elementClass",
")",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"elementClass",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove element class.
@param $class
@return $this
|
[
"Remove",
"element",
"class",
"."
] |
20801b1735e7832a6e58b37c2c391328f8d626fa
|
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Form/Field.php#L835-L850
|
23,132
|
ShaoZeMing/laravel-merchant
|
src/Form/Field.php
|
Field.getView
|
public function getView()
{
if (!empty($this->view)) {
return $this->view;
}
$class = explode('\\', get_called_class());
return 'merchant::form.'.strtolower(end($class));
}
|
php
|
public function getView()
{
if (!empty($this->view)) {
return $this->view;
}
$class = explode('\\', get_called_class());
return 'merchant::form.'.strtolower(end($class));
}
|
[
"public",
"function",
"getView",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"view",
")",
")",
"{",
"return",
"$",
"this",
"->",
"view",
";",
"}",
"$",
"class",
"=",
"explode",
"(",
"'\\\\'",
",",
"get_called_class",
"(",
")",
")",
";",
"return",
"'merchant::form.'",
".",
"strtolower",
"(",
"end",
"(",
"$",
"class",
")",
")",
";",
"}"
] |
Get view of this field.
@return string
|
[
"Get",
"view",
"of",
"this",
"field",
"."
] |
20801b1735e7832a6e58b37c2c391328f8d626fa
|
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Form/Field.php#L879-L888
|
23,133
|
ezsystems/ezcomments-ls-extension
|
classes/ezcomcommentmanager.php
|
ezcomCommentManager.updateComment
|
public function updateComment( $comment, $user=null, $time = null , $notified = null )
{
if ( $time === null )
{
$time = time();
}
$beforeUpdating = $this->beforeUpdatingComment( $comment, $notified, $time );
if ( $beforeUpdating !== true )
{
return $beforeUpdating;
}
$comment->store();
$afterUpdating = $this->afterUpdatingComment( $comment, $notified, $time );
if ( $afterUpdating !== true )
{
return $afterUpdating;
}
return true;
}
|
php
|
public function updateComment( $comment, $user=null, $time = null , $notified = null )
{
if ( $time === null )
{
$time = time();
}
$beforeUpdating = $this->beforeUpdatingComment( $comment, $notified, $time );
if ( $beforeUpdating !== true )
{
return $beforeUpdating;
}
$comment->store();
$afterUpdating = $this->afterUpdatingComment( $comment, $notified, $time );
if ( $afterUpdating !== true )
{
return $afterUpdating;
}
return true;
}
|
[
"public",
"function",
"updateComment",
"(",
"$",
"comment",
",",
"$",
"user",
"=",
"null",
",",
"$",
"time",
"=",
"null",
",",
"$",
"notified",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"time",
"===",
"null",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"}",
"$",
"beforeUpdating",
"=",
"$",
"this",
"->",
"beforeUpdatingComment",
"(",
"$",
"comment",
",",
"$",
"notified",
",",
"$",
"time",
")",
";",
"if",
"(",
"$",
"beforeUpdating",
"!==",
"true",
")",
"{",
"return",
"$",
"beforeUpdating",
";",
"}",
"$",
"comment",
"->",
"store",
"(",
")",
";",
"$",
"afterUpdating",
"=",
"$",
"this",
"->",
"afterUpdatingComment",
"(",
"$",
"comment",
",",
"$",
"notified",
",",
"$",
"time",
")",
";",
"if",
"(",
"$",
"afterUpdating",
"!==",
"true",
")",
"{",
"return",
"$",
"afterUpdating",
";",
"}",
"return",
"true",
";",
"}"
] |
Update the comment
@param $comment comment to be updated
@param $notified change the notification
@param $time
@param $user user to change
@return
|
[
"Update",
"the",
"comment"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcommentmanager.php#L120-L140
|
23,134
|
ezsystems/ezcomments-ls-extension
|
classes/ezcomcommentmanager.php
|
ezcomCommentManager.instance
|
public static function instance()
{
if ( !isset( self::$instance ) )
{
$ini = eZINI::instance( 'ezcomments.ini' );
$className = $ini->variable( 'ManagerClasses', 'CommentManagerClass' );
self::$instance = new $className();
}
return self::$instance;
}
|
php
|
public static function instance()
{
if ( !isset( self::$instance ) )
{
$ini = eZINI::instance( 'ezcomments.ini' );
$className = $ini->variable( 'ManagerClasses', 'CommentManagerClass' );
self::$instance = new $className();
}
return self::$instance;
}
|
[
"public",
"static",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezcomments.ini'",
")",
";",
"$",
"className",
"=",
"$",
"ini",
"->",
"variable",
"(",
"'ManagerClasses'",
",",
"'CommentManagerClass'",
")",
";",
"self",
"::",
"$",
"instance",
"=",
"new",
"$",
"className",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] |
create an instance of ezcomCommentManager
@return ezcomCommentManager
|
[
"create",
"an",
"instance",
"of",
"ezcomCommentManager"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcommentmanager.php#L159-L168
|
23,135
|
LeaseCloud/leasecloud-php-sdk
|
src/ApiResource.php
|
ApiResource.staticRequest
|
protected static function staticRequest($method, $url, $params)
{
$requestor = new ApiRequestor();
list($response, $code) = $requestor->request($method, $url, $params);
return array($response, $code);
}
|
php
|
protected static function staticRequest($method, $url, $params)
{
$requestor = new ApiRequestor();
list($response, $code) = $requestor->request($method, $url, $params);
return array($response, $code);
}
|
[
"protected",
"static",
"function",
"staticRequest",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"params",
")",
"{",
"$",
"requestor",
"=",
"new",
"ApiRequestor",
"(",
")",
";",
"list",
"(",
"$",
"response",
",",
"$",
"code",
")",
"=",
"$",
"requestor",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"params",
")",
";",
"return",
"array",
"(",
"$",
"response",
",",
"$",
"code",
")",
";",
"}"
] |
Make the http GET or POST request
@param string $method
@param string $url
@param array|null $params
@return array
|
[
"Make",
"the",
"http",
"GET",
"or",
"POST",
"request"
] |
091b073dd4f79ba915a68c0ed151bd9bfa61e7ca
|
https://github.com/LeaseCloud/leasecloud-php-sdk/blob/091b073dd4f79ba915a68c0ed151bd9bfa61e7ca/src/ApiResource.php#L68-L73
|
23,136
|
xiewulong/yii2-fileupload
|
oss/libs/guzzle/http/Guzzle/Http/Message/Response.php
|
Response.xml
|
public function xml()
{
try {
// Allow XML to be retrieved even if there is no response body
$xml = new \SimpleXMLElement((string) $this->body ?: '<root />');
} catch (\Exception $e) {
throw new RuntimeException('Unable to parse response body into XML: ' . $e->getMessage());
}
return $xml;
}
|
php
|
public function xml()
{
try {
// Allow XML to be retrieved even if there is no response body
$xml = new \SimpleXMLElement((string) $this->body ?: '<root />');
} catch (\Exception $e) {
throw new RuntimeException('Unable to parse response body into XML: ' . $e->getMessage());
}
return $xml;
}
|
[
"public",
"function",
"xml",
"(",
")",
"{",
"try",
"{",
"// Allow XML to be retrieved even if there is no response body",
"$",
"xml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"body",
"?",
":",
"'<root />'",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Unable to parse response body into XML: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"xml",
";",
"}"
] |
Parse the XML response body and return a SimpleXMLElement
@return \SimpleXMLElement
@throws RuntimeException if the response body is not in XML format
|
[
"Parse",
"the",
"XML",
"response",
"body",
"and",
"return",
"a",
"SimpleXMLElement"
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/Message/Response.php#L873-L883
|
23,137
|
j-d/draggy
|
src/Draggy/Utils/Yaml/YamlLoader.php
|
YamlLoader.mergeConfigurations
|
public static function mergeConfigurations($target, $source)
{
foreach (['attributes', 'entities', 'relationships', 'autocode', 'languages', 'frameworks', 'orms'] as $configurationPart) {
if (isset($source[$configurationPart])) {
$target[$configurationPart] = self::mergeArrays($target[$configurationPart], $source[$configurationPart]);
}
}
return $target;
}
|
php
|
public static function mergeConfigurations($target, $source)
{
foreach (['attributes', 'entities', 'relationships', 'autocode', 'languages', 'frameworks', 'orms'] as $configurationPart) {
if (isset($source[$configurationPart])) {
$target[$configurationPart] = self::mergeArrays($target[$configurationPart], $source[$configurationPart]);
}
}
return $target;
}
|
[
"public",
"static",
"function",
"mergeConfigurations",
"(",
"$",
"target",
",",
"$",
"source",
")",
"{",
"foreach",
"(",
"[",
"'attributes'",
",",
"'entities'",
",",
"'relationships'",
",",
"'autocode'",
",",
"'languages'",
",",
"'frameworks'",
",",
"'orms'",
"]",
"as",
"$",
"configurationPart",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"source",
"[",
"$",
"configurationPart",
"]",
")",
")",
"{",
"$",
"target",
"[",
"$",
"configurationPart",
"]",
"=",
"self",
"::",
"mergeArrays",
"(",
"$",
"target",
"[",
"$",
"configurationPart",
"]",
",",
"$",
"source",
"[",
"$",
"configurationPart",
"]",
")",
";",
"}",
"}",
"return",
"$",
"target",
";",
"}"
] |
Complete the different configuration sections on the target array with those ones found on the source array
@param array $target
@param array $source
@return array
|
[
"Complete",
"the",
"different",
"configuration",
"sections",
"on",
"the",
"target",
"array",
"with",
"those",
"ones",
"found",
"on",
"the",
"source",
"array"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Utils/Yaml/YamlLoader.php#L48-L57
|
23,138
|
j-d/draggy
|
src/Draggy/Utils/Yaml/YamlLoader.php
|
YamlLoader.loadConfiguration
|
public static function loadConfiguration()
{
$defaultsFile = __DIR__ . '/../../../../app/config/defaults.yml';
$draggyFile = __DIR__ . '/../../../../app/config/draggy.yml';
$userFile = __DIR__ . '/../../../../app/config/user.yml';
$defaultsArray = Yaml::parse($defaultsFile);
$configurationArray = is_file($userFile)
? Yaml::parse($userFile)
: Yaml::parse($draggyFile);
$mergedArray = self::mergeConfigurations($defaultsArray, $configurationArray);
return $mergedArray;
}
|
php
|
public static function loadConfiguration()
{
$defaultsFile = __DIR__ . '/../../../../app/config/defaults.yml';
$draggyFile = __DIR__ . '/../../../../app/config/draggy.yml';
$userFile = __DIR__ . '/../../../../app/config/user.yml';
$defaultsArray = Yaml::parse($defaultsFile);
$configurationArray = is_file($userFile)
? Yaml::parse($userFile)
: Yaml::parse($draggyFile);
$mergedArray = self::mergeConfigurations($defaultsArray, $configurationArray);
return $mergedArray;
}
|
[
"public",
"static",
"function",
"loadConfiguration",
"(",
")",
"{",
"$",
"defaultsFile",
"=",
"__DIR__",
".",
"'/../../../../app/config/defaults.yml'",
";",
"$",
"draggyFile",
"=",
"__DIR__",
".",
"'/../../../../app/config/draggy.yml'",
";",
"$",
"userFile",
"=",
"__DIR__",
".",
"'/../../../../app/config/user.yml'",
";",
"$",
"defaultsArray",
"=",
"Yaml",
"::",
"parse",
"(",
"$",
"defaultsFile",
")",
";",
"$",
"configurationArray",
"=",
"is_file",
"(",
"$",
"userFile",
")",
"?",
"Yaml",
"::",
"parse",
"(",
"$",
"userFile",
")",
":",
"Yaml",
"::",
"parse",
"(",
"$",
"draggyFile",
")",
";",
"$",
"mergedArray",
"=",
"self",
"::",
"mergeConfigurations",
"(",
"$",
"defaultsArray",
",",
"$",
"configurationArray",
")",
";",
"return",
"$",
"mergedArray",
";",
"}"
] |
Load the model configuration, merge it onto the default one and return the result array
@return array
|
[
"Load",
"the",
"model",
"configuration",
"merge",
"it",
"onto",
"the",
"default",
"one",
"and",
"return",
"the",
"result",
"array"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Utils/Yaml/YamlLoader.php#L64-L79
|
23,139
|
m4grio/bangkok-insurance-php
|
src/ClientBuilder.php
|
ClientBuilder.build
|
public function build()
{
$soapClient = (new Factory)->getClient($this->getEndpoint(), $this->getSoapOptions());
$params['user_id'] = $this->userId;
$params['agent_code'] = $this->agentCode;
$params['agent_seq'] = $this->agentSeq;
$client = new $this->client($soapClient, $params);
if ($this->log) {
//
}
return $client;
}
|
php
|
public function build()
{
$soapClient = (new Factory)->getClient($this->getEndpoint(), $this->getSoapOptions());
$params['user_id'] = $this->userId;
$params['agent_code'] = $this->agentCode;
$params['agent_seq'] = $this->agentSeq;
$client = new $this->client($soapClient, $params);
if ($this->log) {
//
}
return $client;
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"soapClient",
"=",
"(",
"new",
"Factory",
")",
"->",
"getClient",
"(",
"$",
"this",
"->",
"getEndpoint",
"(",
")",
",",
"$",
"this",
"->",
"getSoapOptions",
"(",
")",
")",
";",
"$",
"params",
"[",
"'user_id'",
"]",
"=",
"$",
"this",
"->",
"userId",
";",
"$",
"params",
"[",
"'agent_code'",
"]",
"=",
"$",
"this",
"->",
"agentCode",
";",
"$",
"params",
"[",
"'agent_seq'",
"]",
"=",
"$",
"this",
"->",
"agentSeq",
";",
"$",
"client",
"=",
"new",
"$",
"this",
"->",
"client",
"(",
"$",
"soapClient",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"this",
"->",
"log",
")",
"{",
"//",
"}",
"return",
"$",
"client",
";",
"}"
] |
Build a new client's instance
@return Client
|
[
"Build",
"a",
"new",
"client",
"s",
"instance"
] |
400266d043abe6b7cacb9da36064cbb169149c2a
|
https://github.com/m4grio/bangkok-insurance-php/blob/400266d043abe6b7cacb9da36064cbb169149c2a/src/ClientBuilder.php#L147-L161
|
23,140
|
husccexo/php-handlersocket-core
|
src/HSCore/Socket.php
|
Socket.parseResponse
|
protected function parseResponse($string)
{
$exp = explode(Driver::SEP, $string);
if ($exp[0] != 0) {
throw new HSException(isset($exp[2]) ? $exp[2] : '', $exp[0]);
}
array_shift($exp); // skip error code
$numCols = intval(array_shift($exp));
$exp = array_map([$this->socket, 'decode'], $exp);
return array_chunk($exp, $numCols);
}
|
php
|
protected function parseResponse($string)
{
$exp = explode(Driver::SEP, $string);
if ($exp[0] != 0) {
throw new HSException(isset($exp[2]) ? $exp[2] : '', $exp[0]);
}
array_shift($exp); // skip error code
$numCols = intval(array_shift($exp));
$exp = array_map([$this->socket, 'decode'], $exp);
return array_chunk($exp, $numCols);
}
|
[
"protected",
"function",
"parseResponse",
"(",
"$",
"string",
")",
"{",
"$",
"exp",
"=",
"explode",
"(",
"Driver",
"::",
"SEP",
",",
"$",
"string",
")",
";",
"if",
"(",
"$",
"exp",
"[",
"0",
"]",
"!=",
"0",
")",
"{",
"throw",
"new",
"HSException",
"(",
"isset",
"(",
"$",
"exp",
"[",
"2",
"]",
")",
"?",
"$",
"exp",
"[",
"2",
"]",
":",
"''",
",",
"$",
"exp",
"[",
"0",
"]",
")",
";",
"}",
"array_shift",
"(",
"$",
"exp",
")",
";",
"// skip error code",
"$",
"numCols",
"=",
"intval",
"(",
"array_shift",
"(",
"$",
"exp",
")",
")",
";",
"$",
"exp",
"=",
"array_map",
"(",
"[",
"$",
"this",
"->",
"socket",
",",
"'decode'",
"]",
",",
"$",
"exp",
")",
";",
"return",
"array_chunk",
"(",
"$",
"exp",
",",
"$",
"numCols",
")",
";",
"}"
] |
Parse response from server
@param $string
@return array
@throws HSException
|
[
"Parse",
"response",
"from",
"server"
] |
aaeeece9c90a89bbc861a6fe390bc0c892496bf0
|
https://github.com/husccexo/php-handlersocket-core/blob/aaeeece9c90a89bbc861a6fe390bc0c892496bf0/src/HSCore/Socket.php#L100-L114
|
23,141
|
husccexo/php-handlersocket-core
|
src/HSCore/Socket.php
|
Socket.connect
|
private function connect()
{
if (!$this->socket->isOpened()) {
$this->socket->open();
if ($this->secret) {
$this->socket->send(join(Driver::SEP, ['A', 1, Driver::encode($this->secret)]).Driver::EOL);
}
}
}
|
php
|
private function connect()
{
if (!$this->socket->isOpened()) {
$this->socket->open();
if ($this->secret) {
$this->socket->send(join(Driver::SEP, ['A', 1, Driver::encode($this->secret)]).Driver::EOL);
}
}
}
|
[
"private",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
"->",
"isOpened",
"(",
")",
")",
"{",
"$",
"this",
"->",
"socket",
"->",
"open",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"secret",
")",
"{",
"$",
"this",
"->",
"socket",
"->",
"send",
"(",
"join",
"(",
"Driver",
"::",
"SEP",
",",
"[",
"'A'",
",",
"1",
",",
"Driver",
"::",
"encode",
"(",
"$",
"this",
"->",
"secret",
")",
"]",
")",
".",
"Driver",
"::",
"EOL",
")",
";",
"}",
"}",
"}"
] |
Connect to Handler Socket
@throws HSException
|
[
"Connect",
"to",
"Handler",
"Socket"
] |
aaeeece9c90a89bbc861a6fe390bc0c892496bf0
|
https://github.com/husccexo/php-handlersocket-core/blob/aaeeece9c90a89bbc861a6fe390bc0c892496bf0/src/HSCore/Socket.php#L122-L131
|
23,142
|
blast-project/BaseEntitiesBundle
|
src/Controller/SortableController.php
|
SortableController.moveSortableItemAction
|
public function moveSortableItemAction(Request $request)
{
$admin = $this->container->get('sonata.admin.pool')->getInstance($request->get('admin_code'));
$class = $admin->getClass();
$id = $request->get('id');
$prev_rank = (int) $request->get('prev_rank');
$next_rank = (int) $request->get('next_rank');
$em = $this->getDoctrine()->getEntityManager();
$meta = new ClassMetadata($class);
$repo = new SortableRepository($em, $meta);
if ($prev_rank) {
$new_rank = $repo->moveObjectAfter($id, $prev_rank);
} elseif ($next_rank) {
$new_rank = $repo->moveObjectBefore($id, $next_rank);
}
return new JsonResponse(array(
'status' => $new_rank ? 'OK' : 'KO',
'new_rank' => $new_rank,
'class' => $admin->getClass(),
));
}
|
php
|
public function moveSortableItemAction(Request $request)
{
$admin = $this->container->get('sonata.admin.pool')->getInstance($request->get('admin_code'));
$class = $admin->getClass();
$id = $request->get('id');
$prev_rank = (int) $request->get('prev_rank');
$next_rank = (int) $request->get('next_rank');
$em = $this->getDoctrine()->getEntityManager();
$meta = new ClassMetadata($class);
$repo = new SortableRepository($em, $meta);
if ($prev_rank) {
$new_rank = $repo->moveObjectAfter($id, $prev_rank);
} elseif ($next_rank) {
$new_rank = $repo->moveObjectBefore($id, $next_rank);
}
return new JsonResponse(array(
'status' => $new_rank ? 'OK' : 'KO',
'new_rank' => $new_rank,
'class' => $admin->getClass(),
));
}
|
[
"public",
"function",
"moveSortableItemAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"admin",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'sonata.admin.pool'",
")",
"->",
"getInstance",
"(",
"$",
"request",
"->",
"get",
"(",
"'admin_code'",
")",
")",
";",
"$",
"class",
"=",
"$",
"admin",
"->",
"getClass",
"(",
")",
";",
"$",
"id",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"prev_rank",
"=",
"(",
"int",
")",
"$",
"request",
"->",
"get",
"(",
"'prev_rank'",
")",
";",
"$",
"next_rank",
"=",
"(",
"int",
")",
"$",
"request",
"->",
"get",
"(",
"'next_rank'",
")",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"meta",
"=",
"new",
"ClassMetadata",
"(",
"$",
"class",
")",
";",
"$",
"repo",
"=",
"new",
"SortableRepository",
"(",
"$",
"em",
",",
"$",
"meta",
")",
";",
"if",
"(",
"$",
"prev_rank",
")",
"{",
"$",
"new_rank",
"=",
"$",
"repo",
"->",
"moveObjectAfter",
"(",
"$",
"id",
",",
"$",
"prev_rank",
")",
";",
"}",
"elseif",
"(",
"$",
"next_rank",
")",
"{",
"$",
"new_rank",
"=",
"$",
"repo",
"->",
"moveObjectBefore",
"(",
"$",
"id",
",",
"$",
"next_rank",
")",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'status'",
"=>",
"$",
"new_rank",
"?",
"'OK'",
":",
"'KO'",
",",
"'new_rank'",
"=>",
"$",
"new_rank",
",",
"'class'",
"=>",
"$",
"admin",
"->",
"getClass",
"(",
")",
",",
")",
")",
";",
"}"
] |
Move a sortable item.
@param Request $request
@return JsonResponse
@throws \RuntimeException
@throws AccessDeniedException
|
[
"Move",
"a",
"sortable",
"item",
"."
] |
abd06891fc38922225ab7e4fcb437a286ba2c0c4
|
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Controller/SortableController.php#L34-L57
|
23,143
|
gn36/phpbb-oo-posting-api
|
src/Gn36/OoPostingApi/topic.php
|
topic.bump
|
function bump($user_id = 0)
{
global $db, $user;
$current_time = time();
if ($user_id == 0)
$user_id = $user->data['user_id'];
$db->sql_transaction('begin');
$sql = 'UPDATE ' . POSTS_TABLE . "
SET post_time = $current_time
WHERE post_id = {$this->topic_last_post_id}
AND topic_id = {$this->topic_id}";
$db->sql_query($sql);
$this->topic_bumped = 1;
$this->topic_bumper = $user_id;
$this->topic_last_post_time = $current_time;
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_last_post_time = $current_time,
topic_bumped = 1,
topic_bumper = $user_id
WHERE topic_id = $topic_id";
$db->sql_query($sql);
update_post_information('forum', $this->forum_id);
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_lastpost_time = $current_time
WHERE user_id = $user_id";
$db->sql_query($sql);
$db->sql_transaction('commit');
markread('post', $this->forum_id, $this->topic_id, $current_time, $user_id);
add_log('mod', $this->forum_id, $this->topic_id, 'LOG_BUMP_TOPIC', $this->topic_title);
}
|
php
|
function bump($user_id = 0)
{
global $db, $user;
$current_time = time();
if ($user_id == 0)
$user_id = $user->data['user_id'];
$db->sql_transaction('begin');
$sql = 'UPDATE ' . POSTS_TABLE . "
SET post_time = $current_time
WHERE post_id = {$this->topic_last_post_id}
AND topic_id = {$this->topic_id}";
$db->sql_query($sql);
$this->topic_bumped = 1;
$this->topic_bumper = $user_id;
$this->topic_last_post_time = $current_time;
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_last_post_time = $current_time,
topic_bumped = 1,
topic_bumper = $user_id
WHERE topic_id = $topic_id";
$db->sql_query($sql);
update_post_information('forum', $this->forum_id);
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_lastpost_time = $current_time
WHERE user_id = $user_id";
$db->sql_query($sql);
$db->sql_transaction('commit');
markread('post', $this->forum_id, $this->topic_id, $current_time, $user_id);
add_log('mod', $this->forum_id, $this->topic_id, 'LOG_BUMP_TOPIC', $this->topic_title);
}
|
[
"function",
"bump",
"(",
"$",
"user_id",
"=",
"0",
")",
"{",
"global",
"$",
"db",
",",
"$",
"user",
";",
"$",
"current_time",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"user_id",
"==",
"0",
")",
"$",
"user_id",
"=",
"$",
"user",
"->",
"data",
"[",
"'user_id'",
"]",
";",
"$",
"db",
"->",
"sql_transaction",
"(",
"'begin'",
")",
";",
"$",
"sql",
"=",
"'UPDATE '",
".",
"POSTS_TABLE",
".",
"\"\n\t\tSET post_time = $current_time\n\t\tWHERE post_id = {$this->topic_last_post_id}\n\t\tAND topic_id = {$this->topic_id}\"",
";",
"$",
"db",
"->",
"sql_query",
"(",
"$",
"sql",
")",
";",
"$",
"this",
"->",
"topic_bumped",
"=",
"1",
";",
"$",
"this",
"->",
"topic_bumper",
"=",
"$",
"user_id",
";",
"$",
"this",
"->",
"topic_last_post_time",
"=",
"$",
"current_time",
";",
"$",
"sql",
"=",
"'UPDATE '",
".",
"TOPICS_TABLE",
".",
"\"\n\t\tSET topic_last_post_time = $current_time,\n\t\ttopic_bumped = 1,\n\t\ttopic_bumper = $user_id\n\t\tWHERE topic_id = $topic_id\"",
";",
"$",
"db",
"->",
"sql_query",
"(",
"$",
"sql",
")",
";",
"update_post_information",
"(",
"'forum'",
",",
"$",
"this",
"->",
"forum_id",
")",
";",
"$",
"sql",
"=",
"'UPDATE '",
".",
"USERS_TABLE",
".",
"\"\n\t\tSET user_lastpost_time = $current_time\n\t\tWHERE user_id = $user_id\"",
";",
"$",
"db",
"->",
"sql_query",
"(",
"$",
"sql",
")",
";",
"$",
"db",
"->",
"sql_transaction",
"(",
"'commit'",
")",
";",
"markread",
"(",
"'post'",
",",
"$",
"this",
"->",
"forum_id",
",",
"$",
"this",
"->",
"topic_id",
",",
"$",
"current_time",
",",
"$",
"user_id",
")",
";",
"add_log",
"(",
"'mod'",
",",
"$",
"this",
"->",
"forum_id",
",",
"$",
"this",
"->",
"topic_id",
",",
"'LOG_BUMP_TOPIC'",
",",
"$",
"this",
"->",
"topic_title",
")",
";",
"}"
] |
bumps the topic
@param
|
[
"bumps",
"the",
"topic"
] |
d0e19482a9e1e93a435c1758a66df9324145381a
|
https://github.com/gn36/phpbb-oo-posting-api/blob/d0e19482a9e1e93a435c1758a66df9324145381a/src/Gn36/OoPostingApi/topic.php#L717-L755
|
23,144
|
Baachi/CouchDB
|
src/CouchDB/Connection.php
|
Connection.version
|
public function version()
{
$json = (string) $this->client->request('GET', '/')->getBody();
$value = JSONEncoder::decode($json);
return $value['version'];
}
|
php
|
public function version()
{
$json = (string) $this->client->request('GET', '/')->getBody();
$value = JSONEncoder::decode($json);
return $value['version'];
}
|
[
"public",
"function",
"version",
"(",
")",
"{",
"$",
"json",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"'/'",
")",
"->",
"getBody",
"(",
")",
";",
"$",
"value",
"=",
"JSONEncoder",
"::",
"decode",
"(",
"$",
"json",
")",
";",
"return",
"$",
"value",
"[",
"'version'",
"]",
";",
"}"
] |
Get the couchdb version.
@return string
|
[
"Get",
"the",
"couchdb",
"version",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Connection.php#L52-L58
|
23,145
|
Baachi/CouchDB
|
src/CouchDB/Connection.php
|
Connection.listDatabases
|
public function listDatabases()
{
$json = (string) $this->client->request('GET', '/_all_dbs')->getBody();
$databases = JSONEncoder::decode($json);
return $databases;
}
|
php
|
public function listDatabases()
{
$json = (string) $this->client->request('GET', '/_all_dbs')->getBody();
$databases = JSONEncoder::decode($json);
return $databases;
}
|
[
"public",
"function",
"listDatabases",
"(",
")",
"{",
"$",
"json",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"'/_all_dbs'",
")",
"->",
"getBody",
"(",
")",
";",
"$",
"databases",
"=",
"JSONEncoder",
"::",
"decode",
"(",
"$",
"json",
")",
";",
"return",
"$",
"databases",
";",
"}"
] |
Show all databases.
@return array
|
[
"Show",
"all",
"databases",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Connection.php#L65-L71
|
23,146
|
Baachi/CouchDB
|
src/CouchDB/Connection.php
|
Connection.dropDatabase
|
public function dropDatabase($name)
{
if ($this->eventManager->hasListeners(Events::PRE_DROP_DATABASE)) {
// @codeCoverageIgnoreStart
$this->eventManager->dispatchEvent(Events::PRE_DROP_DATABASE, new EventArgs($this, $name));
// @codeCoverageIgnoreEnd
}
$response = $this->client->request('DELETE', sprintf('/%s/', urlencode($name)));
if (404 === $response->getStatusCode()) {
throw new Exception(sprintf('The database "%s" does not exist', $name));
}
$json = (string) $response->getBody();
$status = JSONEncoder::decode($json);
if ($this->eventManager->hasListeners(Events::POST_DROP_DATABASE)) {
// @codeCoverageIgnoreStart
$this->eventManager->dispatchEvent(Events::POST_DROP_DATABASE, new EventArgs($this, $name));
// @codeCoverageIgnoreEnd
}
return isset($status['ok']) && $status['ok'] === true;
}
|
php
|
public function dropDatabase($name)
{
if ($this->eventManager->hasListeners(Events::PRE_DROP_DATABASE)) {
// @codeCoverageIgnoreStart
$this->eventManager->dispatchEvent(Events::PRE_DROP_DATABASE, new EventArgs($this, $name));
// @codeCoverageIgnoreEnd
}
$response = $this->client->request('DELETE', sprintf('/%s/', urlencode($name)));
if (404 === $response->getStatusCode()) {
throw new Exception(sprintf('The database "%s" does not exist', $name));
}
$json = (string) $response->getBody();
$status = JSONEncoder::decode($json);
if ($this->eventManager->hasListeners(Events::POST_DROP_DATABASE)) {
// @codeCoverageIgnoreStart
$this->eventManager->dispatchEvent(Events::POST_DROP_DATABASE, new EventArgs($this, $name));
// @codeCoverageIgnoreEnd
}
return isset($status['ok']) && $status['ok'] === true;
}
|
[
"public",
"function",
"dropDatabase",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"PRE_DROP_DATABASE",
")",
")",
"{",
"// @codeCoverageIgnoreStart",
"$",
"this",
"->",
"eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"PRE_DROP_DATABASE",
",",
"new",
"EventArgs",
"(",
"$",
"this",
",",
"$",
"name",
")",
")",
";",
"// @codeCoverageIgnoreEnd",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'DELETE'",
",",
"sprintf",
"(",
"'/%s/'",
",",
"urlencode",
"(",
"$",
"name",
")",
")",
")",
";",
"if",
"(",
"404",
"===",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'The database \"%s\" does not exist'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"json",
"=",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"$",
"status",
"=",
"JSONEncoder",
"::",
"decode",
"(",
"$",
"json",
")",
";",
"if",
"(",
"$",
"this",
"->",
"eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"POST_DROP_DATABASE",
")",
")",
"{",
"// @codeCoverageIgnoreStart",
"$",
"this",
"->",
"eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"POST_DROP_DATABASE",
",",
"new",
"EventArgs",
"(",
"$",
"this",
",",
"$",
"name",
")",
")",
";",
"// @codeCoverageIgnoreEnd",
"}",
"return",
"isset",
"(",
"$",
"status",
"[",
"'ok'",
"]",
")",
"&&",
"$",
"status",
"[",
"'ok'",
"]",
"===",
"true",
";",
"}"
] |
Drop a database.
@param string $name
@return bool
|
[
"Drop",
"a",
"database",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Connection.php#L80-L104
|
23,147
|
antismok/domain-events-publisher
|
src/DomainEventPublisher.php
|
DomainEventPublisher.removeListener
|
public function removeListener(string $eventName, $listener): void
{
$this->dispatcher->removeListener($eventName, $listener);
}
|
php
|
public function removeListener(string $eventName, $listener): void
{
$this->dispatcher->removeListener($eventName, $listener);
}
|
[
"public",
"function",
"removeListener",
"(",
"string",
"$",
"eventName",
",",
"$",
"listener",
")",
":",
"void",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"removeListener",
"(",
"$",
"eventName",
",",
"$",
"listener",
")",
";",
"}"
] |
Remove event listener
@param string $eventName
@param type $listener
@return void
|
[
"Remove",
"event",
"listener"
] |
3ce431a0b81b1de10cd189281b05b8084c42bc63
|
https://github.com/antismok/domain-events-publisher/blob/3ce431a0b81b1de10cd189281b05b8084c42bc63/src/DomainEventPublisher.php#L75-L78
|
23,148
|
antismok/domain-events-publisher
|
src/DomainEventPublisher.php
|
DomainEventPublisher.removeListeners
|
public function removeListeners(string $eventName): void
{
foreach ($this->dispatcher->getListeners($eventName) as $listener) {
$this->removeListener($eventName, $listener);
}
}
|
php
|
public function removeListeners(string $eventName): void
{
foreach ($this->dispatcher->getListeners($eventName) as $listener) {
$this->removeListener($eventName, $listener);
}
}
|
[
"public",
"function",
"removeListeners",
"(",
"string",
"$",
"eventName",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"dispatcher",
"->",
"getListeners",
"(",
"$",
"eventName",
")",
"as",
"$",
"listener",
")",
"{",
"$",
"this",
"->",
"removeListener",
"(",
"$",
"eventName",
",",
"$",
"listener",
")",
";",
"}",
"}"
] |
Remove all event listeners
@param string $eventName
@return void
|
[
"Remove",
"all",
"event",
"listeners"
] |
3ce431a0b81b1de10cd189281b05b8084c42bc63
|
https://github.com/antismok/domain-events-publisher/blob/3ce431a0b81b1de10cd189281b05b8084c42bc63/src/DomainEventPublisher.php#L87-L92
|
23,149
|
surebert/surebert-framework
|
src/sb/XMPP/Packet.php
|
Packet.setTo
|
public function setTo($to)
{
$attr = $this->createAttribute('to');
$this->doc->appendChild($attr);
$attr->appendChild($this->createTextNode($to));
}
|
php
|
public function setTo($to)
{
$attr = $this->createAttribute('to');
$this->doc->appendChild($attr);
$attr->appendChild($this->createTextNode($to));
}
|
[
"public",
"function",
"setTo",
"(",
"$",
"to",
")",
"{",
"$",
"attr",
"=",
"$",
"this",
"->",
"createAttribute",
"(",
"'to'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"attr",
")",
";",
"$",
"attr",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createTextNode",
"(",
"$",
"to",
")",
")",
";",
"}"
] |
Sets the to jid of the message
@param string $to e.g. paul.visco@chat.roswellpark.org
|
[
"Sets",
"the",
"to",
"jid",
"of",
"the",
"message"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Packet.php#L62-L67
|
23,150
|
surebert/surebert-framework
|
src/sb/XMPP/Packet.php
|
Packet.setFrom
|
public function setFrom($from)
{
$attr = $this->createAttribute('from');
$this->doc->appendChild($attr);
$attr->appendChild($this->createTextNode($from));
}
|
php
|
public function setFrom($from)
{
$attr = $this->createAttribute('from');
$this->doc->appendChild($attr);
$attr->appendChild($this->createTextNode($from));
}
|
[
"public",
"function",
"setFrom",
"(",
"$",
"from",
")",
"{",
"$",
"attr",
"=",
"$",
"this",
"->",
"createAttribute",
"(",
"'from'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"attr",
")",
";",
"$",
"attr",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createTextNode",
"(",
"$",
"from",
")",
")",
";",
"}"
] |
Sets the from jid of the message
@param string $from e.g. paul.visco@chat.roswellpark.org
|
[
"Sets",
"the",
"from",
"jid",
"of",
"the",
"message"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Packet.php#L73-L78
|
23,151
|
surebert/surebert-framework
|
src/sb/XMPP/Packet.php
|
Packet.addXML
|
public function addXML($xml)
{
$next_elem = $this->createDocumentFragment();
$next_elem->appendXML($xml);
$this->doc->appendChild($next_elem);
}
|
php
|
public function addXML($xml)
{
$next_elem = $this->createDocumentFragment();
$next_elem->appendXML($xml);
$this->doc->appendChild($next_elem);
}
|
[
"public",
"function",
"addXML",
"(",
"$",
"xml",
")",
"{",
"$",
"next_elem",
"=",
"$",
"this",
"->",
"createDocumentFragment",
"(",
")",
";",
"$",
"next_elem",
"->",
"appendXML",
"(",
"$",
"xml",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"next_elem",
")",
";",
"}"
] |
Adds an arbitrary XML string to the packet's root node
@param string $xml
|
[
"Adds",
"an",
"arbitrary",
"XML",
"string",
"to",
"the",
"packet",
"s",
"root",
"node"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Packet.php#L104-L110
|
23,152
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Repository/AbstractRepository.php
|
AbstractRepository.findBy
|
public function findBy(array $conditions)
{
$s = $this->selector();
foreach ($conditions as $column => $value) {
$s->where($column, '=', $value);
}
return $s->execute();
}
|
php
|
public function findBy(array $conditions)
{
$s = $this->selector();
foreach ($conditions as $column => $value) {
$s->where($column, '=', $value);
}
return $s->execute();
}
|
[
"public",
"function",
"findBy",
"(",
"array",
"$",
"conditions",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"selector",
"(",
")",
";",
"foreach",
"(",
"$",
"conditions",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"$",
"s",
"->",
"where",
"(",
"$",
"column",
",",
"'='",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"s",
"->",
"execute",
"(",
")",
";",
"}"
] |
Select entities matching an array of conditions.
@param array $conditions An array of the form 'column => value'
@return EntityCollection The selected entities
|
[
"Select",
"entities",
"matching",
"an",
"array",
"of",
"conditions",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Repository/AbstractRepository.php#L57-L65
|
23,153
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Repository/AbstractRepository.php
|
AbstractRepository.findOneBy
|
public function findOneBy(array $conditions)
{
$s = $this->selector()->one();
foreach ($conditions as $column => $value) {
$s->where($column, '=', $value);
}
return $s->execute();
}
|
php
|
public function findOneBy(array $conditions)
{
$s = $this->selector()->one();
foreach ($conditions as $column => $value) {
$s->where($column, '=', $value);
}
return $s->execute();
}
|
[
"public",
"function",
"findOneBy",
"(",
"array",
"$",
"conditions",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"selector",
"(",
")",
"->",
"one",
"(",
")",
";",
"foreach",
"(",
"$",
"conditions",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"$",
"s",
"->",
"where",
"(",
"$",
"column",
",",
"'='",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"s",
"->",
"execute",
"(",
")",
";",
"}"
] |
Select a single entity matching an array of conditions.
@param array $conditions An array of the form 'column => value'
@return Entity|null The selected entity or null
|
[
"Select",
"a",
"single",
"entity",
"matching",
"an",
"array",
"of",
"conditions",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Repository/AbstractRepository.php#L73-L81
|
23,154
|
scherersoftware/cake-monitor
|
src/Error/SentryHandler.php
|
SentryHandler.captureMessage
|
public function captureMessage($message, $params = [], $data = [], $stack = false, $vars = null)
{
if (!Configure::read('CakeMonitor.Sentry.enabled') || error_reporting() === 0) {
return false;
}
if (is_callable(Configure::read('CakeMonitor.Sentry.extraDataCallback'))) {
$data['extra']['extraDataCallback'] = call_user_func(Configure::read('CakeMonitor.Sentry.extraDataCallback'));
}
return $this->_ravenClient->captureMessage($message, $params, $data, $stack, $vars);
}
|
php
|
public function captureMessage($message, $params = [], $data = [], $stack = false, $vars = null)
{
if (!Configure::read('CakeMonitor.Sentry.enabled') || error_reporting() === 0) {
return false;
}
if (is_callable(Configure::read('CakeMonitor.Sentry.extraDataCallback'))) {
$data['extra']['extraDataCallback'] = call_user_func(Configure::read('CakeMonitor.Sentry.extraDataCallback'));
}
return $this->_ravenClient->captureMessage($message, $params, $data, $stack, $vars);
}
|
[
"public",
"function",
"captureMessage",
"(",
"$",
"message",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"stack",
"=",
"false",
",",
"$",
"vars",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"Configure",
"::",
"read",
"(",
"'CakeMonitor.Sentry.enabled'",
")",
"||",
"error_reporting",
"(",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_callable",
"(",
"Configure",
"::",
"read",
"(",
"'CakeMonitor.Sentry.extraDataCallback'",
")",
")",
")",
"{",
"$",
"data",
"[",
"'extra'",
"]",
"[",
"'extraDataCallback'",
"]",
"=",
"call_user_func",
"(",
"Configure",
"::",
"read",
"(",
"'CakeMonitor.Sentry.extraDataCallback'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_ravenClient",
"->",
"captureMessage",
"(",
"$",
"message",
",",
"$",
"params",
",",
"$",
"data",
",",
"$",
"stack",
",",
"$",
"vars",
")",
";",
"}"
] |
Capture a message via sentry
@param string $message The message (primary description) for the event.
@param array $params params to use when formatting the message.
@param array $data Additional attributes to pass with this event (see Sentry docs).
@param bool $stack Print stack trace
@param null $vars Variables
@return bool
|
[
"Capture",
"a",
"message",
"via",
"sentry"
] |
dbe07a1aac41b3db15e631d9e59cf26214bf6938
|
https://github.com/scherersoftware/cake-monitor/blob/dbe07a1aac41b3db15e631d9e59cf26214bf6938/src/Error/SentryHandler.php#L65-L76
|
23,155
|
oroinc/OroLayoutComponent
|
Loader/Generator/ConfigLayoutUpdateGenerator.php
|
ConfigLayoutUpdateGenerator.validate
|
protected function validate(GeneratorData $data)
{
$source = $data->getSource();
if (!(is_array($source) && isset($source[self::NODE_ACTIONS]) && is_array($source[self::NODE_ACTIONS]))) {
throw new SyntaxException(sprintf('expected array with "%s" node', self::NODE_ACTIONS), $source);
}
$actions = $source[self::NODE_ACTIONS];
foreach ($actions as $nodeNo => $actionDefinition) {
if (isset($actionDefinition[self::PATH_ATTR])) {
$path = $actionDefinition[self::PATH_ATTR];
unset($actionDefinition[self::PATH_ATTR]);
} else {
$path = self::NODE_ACTIONS . '.' . $nodeNo;
}
if (!is_array($actionDefinition)) {
throw new SyntaxException('expected array with action name as key', $actionDefinition, $path);
}
$actionName = key($actionDefinition);
$arguments = is_array($actionDefinition[$actionName])
? $actionDefinition[$actionName] : [$actionDefinition[$actionName]];
if (strpos($actionName, '@') !== 0) {
throw new SyntaxException(
sprintf('action name should start with "@" symbol, current name "%s"', $actionName),
$actionDefinition,
$path
);
}
$this->normalizeActionName($actionName);
if (!$this->getHelper()->hasMethod($actionName)) {
throw new SyntaxException(
sprintf('unknown action "%s", should be one of LayoutManipulatorInterface\'s methods', $actionName),
$actionDefinition,
$path
);
}
if (!$this->getHelper()->isValidArguments($actionName, $arguments)) {
throw new SyntaxException($this->getHelper()->getLastError(), $actionDefinition, $path);
}
}
}
|
php
|
protected function validate(GeneratorData $data)
{
$source = $data->getSource();
if (!(is_array($source) && isset($source[self::NODE_ACTIONS]) && is_array($source[self::NODE_ACTIONS]))) {
throw new SyntaxException(sprintf('expected array with "%s" node', self::NODE_ACTIONS), $source);
}
$actions = $source[self::NODE_ACTIONS];
foreach ($actions as $nodeNo => $actionDefinition) {
if (isset($actionDefinition[self::PATH_ATTR])) {
$path = $actionDefinition[self::PATH_ATTR];
unset($actionDefinition[self::PATH_ATTR]);
} else {
$path = self::NODE_ACTIONS . '.' . $nodeNo;
}
if (!is_array($actionDefinition)) {
throw new SyntaxException('expected array with action name as key', $actionDefinition, $path);
}
$actionName = key($actionDefinition);
$arguments = is_array($actionDefinition[$actionName])
? $actionDefinition[$actionName] : [$actionDefinition[$actionName]];
if (strpos($actionName, '@') !== 0) {
throw new SyntaxException(
sprintf('action name should start with "@" symbol, current name "%s"', $actionName),
$actionDefinition,
$path
);
}
$this->normalizeActionName($actionName);
if (!$this->getHelper()->hasMethod($actionName)) {
throw new SyntaxException(
sprintf('unknown action "%s", should be one of LayoutManipulatorInterface\'s methods', $actionName),
$actionDefinition,
$path
);
}
if (!$this->getHelper()->isValidArguments($actionName, $arguments)) {
throw new SyntaxException($this->getHelper()->getLastError(), $actionDefinition, $path);
}
}
}
|
[
"protected",
"function",
"validate",
"(",
"GeneratorData",
"$",
"data",
")",
"{",
"$",
"source",
"=",
"$",
"data",
"->",
"getSource",
"(",
")",
";",
"if",
"(",
"!",
"(",
"is_array",
"(",
"$",
"source",
")",
"&&",
"isset",
"(",
"$",
"source",
"[",
"self",
"::",
"NODE_ACTIONS",
"]",
")",
"&&",
"is_array",
"(",
"$",
"source",
"[",
"self",
"::",
"NODE_ACTIONS",
"]",
")",
")",
")",
"{",
"throw",
"new",
"SyntaxException",
"(",
"sprintf",
"(",
"'expected array with \"%s\" node'",
",",
"self",
"::",
"NODE_ACTIONS",
")",
",",
"$",
"source",
")",
";",
"}",
"$",
"actions",
"=",
"$",
"source",
"[",
"self",
"::",
"NODE_ACTIONS",
"]",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"nodeNo",
"=>",
"$",
"actionDefinition",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"actionDefinition",
"[",
"self",
"::",
"PATH_ATTR",
"]",
")",
")",
"{",
"$",
"path",
"=",
"$",
"actionDefinition",
"[",
"self",
"::",
"PATH_ATTR",
"]",
";",
"unset",
"(",
"$",
"actionDefinition",
"[",
"self",
"::",
"PATH_ATTR",
"]",
")",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"self",
"::",
"NODE_ACTIONS",
".",
"'.'",
".",
"$",
"nodeNo",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"actionDefinition",
")",
")",
"{",
"throw",
"new",
"SyntaxException",
"(",
"'expected array with action name as key'",
",",
"$",
"actionDefinition",
",",
"$",
"path",
")",
";",
"}",
"$",
"actionName",
"=",
"key",
"(",
"$",
"actionDefinition",
")",
";",
"$",
"arguments",
"=",
"is_array",
"(",
"$",
"actionDefinition",
"[",
"$",
"actionName",
"]",
")",
"?",
"$",
"actionDefinition",
"[",
"$",
"actionName",
"]",
":",
"[",
"$",
"actionDefinition",
"[",
"$",
"actionName",
"]",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"actionName",
",",
"'@'",
")",
"!==",
"0",
")",
"{",
"throw",
"new",
"SyntaxException",
"(",
"sprintf",
"(",
"'action name should start with \"@\" symbol, current name \"%s\"'",
",",
"$",
"actionName",
")",
",",
"$",
"actionDefinition",
",",
"$",
"path",
")",
";",
"}",
"$",
"this",
"->",
"normalizeActionName",
"(",
"$",
"actionName",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getHelper",
"(",
")",
"->",
"hasMethod",
"(",
"$",
"actionName",
")",
")",
"{",
"throw",
"new",
"SyntaxException",
"(",
"sprintf",
"(",
"'unknown action \"%s\", should be one of LayoutManipulatorInterface\\'s methods'",
",",
"$",
"actionName",
")",
",",
"$",
"actionDefinition",
",",
"$",
"path",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getHelper",
"(",
")",
"->",
"isValidArguments",
"(",
"$",
"actionName",
",",
"$",
"arguments",
")",
")",
"{",
"throw",
"new",
"SyntaxException",
"(",
"$",
"this",
"->",
"getHelper",
"(",
")",
"->",
"getLastError",
"(",
")",
",",
"$",
"actionDefinition",
",",
"$",
"path",
")",
";",
"}",
"}",
"}"
] |
Validates given resource data, checks that "actions" node exists and consist valid actions.
{@inheritdoc}
@SuppressWarnings(PHPMD.NPathComplexity)
|
[
"Validates",
"given",
"resource",
"data",
"checks",
"that",
"actions",
"node",
"exists",
"and",
"consist",
"valid",
"actions",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Generator/ConfigLayoutUpdateGenerator.php#L68-L115
|
23,156
|
tylernathanreed/flash
|
src/Flash.php
|
Flash.flash
|
private function flash($type, $message)
{
// Determine the Current Session Flash Type
$flash = Session::has($type) ? Session::get($type) : array();
// Prevent Duplicate Messages from Appearing
if(!in_array($message, $flash))
$flash[] = $message; // Add the Message to the Flashes
// Flash the Message
Session::flash($type, $flash);
}
|
php
|
private function flash($type, $message)
{
// Determine the Current Session Flash Type
$flash = Session::has($type) ? Session::get($type) : array();
// Prevent Duplicate Messages from Appearing
if(!in_array($message, $flash))
$flash[] = $message; // Add the Message to the Flashes
// Flash the Message
Session::flash($type, $flash);
}
|
[
"private",
"function",
"flash",
"(",
"$",
"type",
",",
"$",
"message",
")",
"{",
"// Determine the Current Session Flash Type",
"$",
"flash",
"=",
"Session",
"::",
"has",
"(",
"$",
"type",
")",
"?",
"Session",
"::",
"get",
"(",
"$",
"type",
")",
":",
"array",
"(",
")",
";",
"// Prevent Duplicate Messages from Appearing",
"if",
"(",
"!",
"in_array",
"(",
"$",
"message",
",",
"$",
"flash",
")",
")",
"$",
"flash",
"[",
"]",
"=",
"$",
"message",
";",
"// Add the Message to the Flashes",
"// Flash the Message",
"Session",
"::",
"flash",
"(",
"$",
"type",
",",
"$",
"flash",
")",
";",
"}"
] |
Flashes a Message to the Session.
@param string $type The Type of Message to Flash.
@param string $message The Message to Flash.
@return void
|
[
"Flashes",
"a",
"Message",
"to",
"the",
"Session",
"."
] |
6ca4b361493e7e48e3c3cf6b1ed95f8a1b2b724c
|
https://github.com/tylernathanreed/flash/blob/6ca4b361493e7e48e3c3cf6b1ed95f8a1b2b724c/src/Flash.php#L82-L93
|
23,157
|
nabab/bbn
|
src/bbn/appui/mailbox.php
|
mailbox.mbox_exists
|
public function mbox_exists($name){
if ( $this->is_connected() && !empty($name) ){
$names = $this->get_all_names_mboxes();
if ( !empty($names) && \in_array($name, $names) ){
return true;
}
}
return false;
}
|
php
|
public function mbox_exists($name){
if ( $this->is_connected() && !empty($name) ){
$names = $this->get_all_names_mboxes();
if ( !empty($names) && \in_array($name, $names) ){
return true;
}
}
return false;
}
|
[
"public",
"function",
"mbox_exists",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_connected",
"(",
")",
"&&",
"!",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"names",
"=",
"$",
"this",
"->",
"get_all_names_mboxes",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"names",
")",
"&&",
"\\",
"in_array",
"(",
"$",
"name",
",",
"$",
"names",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if a mailbox exists
@param string $name The mailbox name
@return bool
|
[
"Check",
"if",
"a",
"mailbox",
"exists"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/mailbox.php#L710-L718
|
23,158
|
surebert/surebert-framework
|
src/sb/Gitlab/Project.php
|
Project.issueCreate
|
public function issueCreate($title, $description, $assignee_email, $labels='') {
$post = [
'id' => $this->id,
'title' => $title,
'description' => $description
];
if($assignee_email){
$user = new \sb\Gitlab\User($assignee_email, $this->_client);
$post['assignee_id']= $user->id;
}
$response = $this->_client->get('/projects/'.$this->id.'/issues',$post);
if($response){
return \sb\Gitlab\Issue::fromObject($response);
}
}
|
php
|
public function issueCreate($title, $description, $assignee_email, $labels='') {
$post = [
'id' => $this->id,
'title' => $title,
'description' => $description
];
if($assignee_email){
$user = new \sb\Gitlab\User($assignee_email, $this->_client);
$post['assignee_id']= $user->id;
}
$response = $this->_client->get('/projects/'.$this->id.'/issues',$post);
if($response){
return \sb\Gitlab\Issue::fromObject($response);
}
}
|
[
"public",
"function",
"issueCreate",
"(",
"$",
"title",
",",
"$",
"description",
",",
"$",
"assignee_email",
",",
"$",
"labels",
"=",
"''",
")",
"{",
"$",
"post",
"=",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'title'",
"=>",
"$",
"title",
",",
"'description'",
"=>",
"$",
"description",
"]",
";",
"if",
"(",
"$",
"assignee_email",
")",
"{",
"$",
"user",
"=",
"new",
"\\",
"sb",
"\\",
"Gitlab",
"\\",
"User",
"(",
"$",
"assignee_email",
",",
"$",
"this",
"->",
"_client",
")",
";",
"$",
"post",
"[",
"'assignee_id'",
"]",
"=",
"$",
"user",
"->",
"id",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"_client",
"->",
"get",
"(",
"'/projects/'",
".",
"$",
"this",
"->",
"id",
".",
"'/issues'",
",",
"$",
"post",
")",
";",
"if",
"(",
"$",
"response",
")",
"{",
"return",
"\\",
"sb",
"\\",
"Gitlab",
"\\",
"Issue",
"::",
"fromObject",
"(",
"$",
"response",
")",
";",
"}",
"}"
] |
Adds an issue to a git repository
@param string $title
@param string $description
@param string $assignee_email
@return \Gitlab\Model\Issue
@throws \Exception
|
[
"Adds",
"an",
"issue",
"to",
"a",
"git",
"repository"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Gitlab/Project.php#L183-L200
|
23,159
|
surebert/surebert-framework
|
src/sb/Gitlab/Project.php
|
Project.issueClose
|
public function issueClose(\sb\Gitlab\Issue $issue){
$response = $this->_client->get("/projects/".$this->id."/issues/".$issue->id, [
'state_event' => 'close'
], 'PUT');
if(is_object($response) && isset($response->message)){
throw new \Exception("Could not close issue ".$issue->id." on project ".$this->id.": ".json_encode($response));
}
return $response;
}
|
php
|
public function issueClose(\sb\Gitlab\Issue $issue){
$response = $this->_client->get("/projects/".$this->id."/issues/".$issue->id, [
'state_event' => 'close'
], 'PUT');
if(is_object($response) && isset($response->message)){
throw new \Exception("Could not close issue ".$issue->id." on project ".$this->id.": ".json_encode($response));
}
return $response;
}
|
[
"public",
"function",
"issueClose",
"(",
"\\",
"sb",
"\\",
"Gitlab",
"\\",
"Issue",
"$",
"issue",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_client",
"->",
"get",
"(",
"\"/projects/\"",
".",
"$",
"this",
"->",
"id",
".",
"\"/issues/\"",
".",
"$",
"issue",
"->",
"id",
",",
"[",
"'state_event'",
"=>",
"'close'",
"]",
",",
"'PUT'",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"response",
")",
"&&",
"isset",
"(",
"$",
"response",
"->",
"message",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Could not close issue \"",
".",
"$",
"issue",
"->",
"id",
".",
"\" on project \"",
".",
"$",
"this",
"->",
"id",
".",
"\": \"",
".",
"json_encode",
"(",
"$",
"response",
")",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Closes an issue by id within the project
@param int $issue_id
@return type
|
[
"Closes",
"an",
"issue",
"by",
"id",
"within",
"the",
"project"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Gitlab/Project.php#L207-L217
|
23,160
|
surebert/surebert-framework
|
src/sb/Gitlab/Project.php
|
Project.fromObject
|
public static function fromObject($object){
$issue = new \sb\Gitlab\P();
foreach(get_object_vars($object) as $k=>$v){
switch($k){
case 'assignee':
case 'author':
if(!is_object($v)){
$issue->{$k} = $v;
break;
}
$user = new \sb\Gitlab\User();
foreach(get_object_vars($v) as $uk=>$uv){
$user->{$uk} = $uv;
}
$issue->{$k} = $user;
break;
default:
$issue->{$k} = $v;
}
}
return $issue;
}
|
php
|
public static function fromObject($object){
$issue = new \sb\Gitlab\P();
foreach(get_object_vars($object) as $k=>$v){
switch($k){
case 'assignee':
case 'author':
if(!is_object($v)){
$issue->{$k} = $v;
break;
}
$user = new \sb\Gitlab\User();
foreach(get_object_vars($v) as $uk=>$uv){
$user->{$uk} = $uv;
}
$issue->{$k} = $user;
break;
default:
$issue->{$k} = $v;
}
}
return $issue;
}
|
[
"public",
"static",
"function",
"fromObject",
"(",
"$",
"object",
")",
"{",
"$",
"issue",
"=",
"new",
"\\",
"sb",
"\\",
"Gitlab",
"\\",
"P",
"(",
")",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"object",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"switch",
"(",
"$",
"k",
")",
"{",
"case",
"'assignee'",
":",
"case",
"'author'",
":",
"if",
"(",
"!",
"is_object",
"(",
"$",
"v",
")",
")",
"{",
"$",
"issue",
"->",
"{",
"$",
"k",
"}",
"=",
"$",
"v",
";",
"break",
";",
"}",
"$",
"user",
"=",
"new",
"\\",
"sb",
"\\",
"Gitlab",
"\\",
"User",
"(",
")",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"v",
")",
"as",
"$",
"uk",
"=>",
"$",
"uv",
")",
"{",
"$",
"user",
"->",
"{",
"$",
"uk",
"}",
"=",
"$",
"uv",
";",
"}",
"$",
"issue",
"->",
"{",
"$",
"k",
"}",
"=",
"$",
"user",
";",
"break",
";",
"default",
":",
"$",
"issue",
"->",
"{",
"$",
"k",
"}",
"=",
"$",
"v",
";",
"}",
"}",
"return",
"$",
"issue",
";",
"}"
] |
Convert stdClass Object to actual \sb\Gitlab\Issue
@param \stdClass $object
@return \sb\Gitlab\Issue
|
[
"Convert",
"stdClass",
"Object",
"to",
"actual",
"\\",
"sb",
"\\",
"Gitlab",
"\\",
"Issue"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Gitlab/Project.php#L277-L302
|
23,161
|
DevFactoryCH/api
|
src/Provider/RequestProvider.php
|
RequestProvider.put
|
public function put($url, $params = null) {
$this->params = $params;
$this->method = 'PUT';
$this->url = $url;
return $this->request();
}
|
php
|
public function put($url, $params = null) {
$this->params = $params;
$this->method = 'PUT';
$this->url = $url;
return $this->request();
}
|
[
"public",
"function",
"put",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"$",
"this",
"->",
"method",
"=",
"'PUT'",
";",
"$",
"this",
"->",
"url",
"=",
"$",
"url",
";",
"return",
"$",
"this",
"->",
"request",
"(",
")",
";",
"}"
] |
Make a PUT query
@param data
@return
|
[
"Make",
"a",
"PUT",
"query"
] |
ed239aac6e15cba23ae527b1d175c478d2b7d6ae
|
https://github.com/DevFactoryCH/api/blob/ed239aac6e15cba23ae527b1d175c478d2b7d6ae/src/Provider/RequestProvider.php#L27-L33
|
23,162
|
DevFactoryCH/api
|
src/Provider/RequestProvider.php
|
RequestProvider.post
|
public function post($url, $params = null) {
$this->params = $params;
$this->method = 'POST';
$this->url = $url;
return $this->request();
}
|
php
|
public function post($url, $params = null) {
$this->params = $params;
$this->method = 'POST';
$this->url = $url;
return $this->request();
}
|
[
"public",
"function",
"post",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"$",
"this",
"->",
"method",
"=",
"'POST'",
";",
"$",
"this",
"->",
"url",
"=",
"$",
"url",
";",
"return",
"$",
"this",
"->",
"request",
"(",
")",
";",
"}"
] |
Make a POST query
@param data
@return
|
[
"Make",
"a",
"POST",
"query"
] |
ed239aac6e15cba23ae527b1d175c478d2b7d6ae
|
https://github.com/DevFactoryCH/api/blob/ed239aac6e15cba23ae527b1d175c478d2b7d6ae/src/Provider/RequestProvider.php#L42-L48
|
23,163
|
DevFactoryCH/api
|
src/Provider/RequestProvider.php
|
RequestProvider.get
|
public function get($url, $params = null) {
$this->params = $params;
$this->method = 'GET';
$this->url = $url;
return $this->request();
}
|
php
|
public function get($url, $params = null) {
$this->params = $params;
$this->method = 'GET';
$this->url = $url;
return $this->request();
}
|
[
"public",
"function",
"get",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"$",
"this",
"->",
"method",
"=",
"'GET'",
";",
"$",
"this",
"->",
"url",
"=",
"$",
"url",
";",
"return",
"$",
"this",
"->",
"request",
"(",
")",
";",
"}"
] |
Make a GET query
@param data
@return
|
[
"Make",
"a",
"GET",
"query"
] |
ed239aac6e15cba23ae527b1d175c478d2b7d6ae
|
https://github.com/DevFactoryCH/api/blob/ed239aac6e15cba23ae527b1d175c478d2b7d6ae/src/Provider/RequestProvider.php#L57-L63
|
23,164
|
rafalkot/yii2-settings
|
SettingsTrait.php
|
SettingsTrait.getSetting
|
public function getSetting($key = null, $default = null)
{
return $this->getSettingsComponent()->get($this->getSettingsCategory(), $key, $default);
}
|
php
|
public function getSetting($key = null, $default = null)
{
return $this->getSettingsComponent()->get($this->getSettingsCategory(), $key, $default);
}
|
[
"public",
"function",
"getSetting",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getSettingsComponent",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getSettingsCategory",
"(",
")",
",",
"$",
"key",
",",
"$",
"default",
")",
";",
"}"
] |
Returns settings from current category.
@param string|array $key Single or multiple keys in array
@param mixed $default Default value when setting does not exist
@return mixed Setting value
@throws Exception
|
[
"Returns",
"settings",
"from",
"current",
"category",
"."
] |
b601b58809322f617273093766dc28c08e74d566
|
https://github.com/rafalkot/yii2-settings/blob/b601b58809322f617273093766dc28c08e74d566/SettingsTrait.php#L39-L42
|
23,165
|
oroinc/OroLayoutComponent
|
StringOptionValueBuilder.php
|
StringOptionValueBuilder.add
|
public function add($value)
{
if (!is_string($value)) {
throw new UnexpectedTypeException($value, 'string', 'value');
}
if (empty($value)) {
return;
}
if ($this->allowTokenize) {
$this->values = array_merge($this->values, explode($this->delimiter, $value));
} else {
$this->values[] = $value;
}
}
|
php
|
public function add($value)
{
if (!is_string($value)) {
throw new UnexpectedTypeException($value, 'string', 'value');
}
if (empty($value)) {
return;
}
if ($this->allowTokenize) {
$this->values = array_merge($this->values, explode($this->delimiter, $value));
} else {
$this->values[] = $value;
}
}
|
[
"public",
"function",
"add",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"value",
",",
"'string'",
",",
"'value'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"allowTokenize",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"values",
",",
"explode",
"(",
"$",
"this",
"->",
"delimiter",
",",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"values",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] |
Requests to add new value
@param string $value
|
[
"Requests",
"to",
"add",
"new",
"value"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/StringOptionValueBuilder.php#L38-L52
|
23,166
|
oroinc/OroLayoutComponent
|
StringOptionValueBuilder.php
|
StringOptionValueBuilder.remove
|
public function remove($value)
{
if (!is_string($value)) {
throw new UnexpectedTypeException($value, 'string', 'value');
}
if (empty($value)) {
return;
}
if ($this->allowTokenize) {
$this->values = array_diff($this->values, explode($this->delimiter, $value));
} else {
$this->values = array_diff($this->values, [$value]);
}
}
|
php
|
public function remove($value)
{
if (!is_string($value)) {
throw new UnexpectedTypeException($value, 'string', 'value');
}
if (empty($value)) {
return;
}
if ($this->allowTokenize) {
$this->values = array_diff($this->values, explode($this->delimiter, $value));
} else {
$this->values = array_diff($this->values, [$value]);
}
}
|
[
"public",
"function",
"remove",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"value",
",",
"'string'",
",",
"'value'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"allowTokenize",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"values",
",",
"explode",
"(",
"$",
"this",
"->",
"delimiter",
",",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"values",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"values",
",",
"[",
"$",
"value",
"]",
")",
";",
"}",
"}"
] |
Requests to remove existing value
@param string $value
|
[
"Requests",
"to",
"remove",
"existing",
"value"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/StringOptionValueBuilder.php#L59-L73
|
23,167
|
oroinc/OroLayoutComponent
|
StringOptionValueBuilder.php
|
StringOptionValueBuilder.replace
|
public function replace($oldValue, $newValue)
{
if (!is_string($oldValue)) {
throw new UnexpectedTypeException($oldValue, 'string', 'oldValue');
}
if (empty($oldValue)) {
return;
}
if (!is_string($newValue) && null !== $newValue) {
throw new UnexpectedTypeException($newValue, 'string or null', 'newValue');
}
$key = array_search($oldValue, $this->values, true);
if (false !== $key) {
if (empty($newValue)) {
unset($this->values[$key]);
} else {
$this->values[$key] = $newValue;
}
}
}
|
php
|
public function replace($oldValue, $newValue)
{
if (!is_string($oldValue)) {
throw new UnexpectedTypeException($oldValue, 'string', 'oldValue');
}
if (empty($oldValue)) {
return;
}
if (!is_string($newValue) && null !== $newValue) {
throw new UnexpectedTypeException($newValue, 'string or null', 'newValue');
}
$key = array_search($oldValue, $this->values, true);
if (false !== $key) {
if (empty($newValue)) {
unset($this->values[$key]);
} else {
$this->values[$key] = $newValue;
}
}
}
|
[
"public",
"function",
"replace",
"(",
"$",
"oldValue",
",",
"$",
"newValue",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"oldValue",
")",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"oldValue",
",",
"'string'",
",",
"'oldValue'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"oldValue",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"newValue",
")",
"&&",
"null",
"!==",
"$",
"newValue",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"newValue",
",",
"'string or null'",
",",
"'newValue'",
")",
";",
"}",
"$",
"key",
"=",
"array_search",
"(",
"$",
"oldValue",
",",
"$",
"this",
"->",
"values",
",",
"true",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"key",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"newValue",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"newValue",
";",
"}",
"}",
"}"
] |
Requests to replace one value with another value
@param string $oldValue
@param string|null $newValue
|
[
"Requests",
"to",
"replace",
"one",
"value",
"with",
"another",
"value"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/StringOptionValueBuilder.php#L81-L101
|
23,168
|
ekuiter/feature-php
|
FeaturePhp/File/StoredFileContent.php
|
StoredFileContent.copy
|
public function copy($target) {
if (!parent::copy($target))
return false;
return copy($this->fileSource, $target);
}
|
php
|
public function copy($target) {
if (!parent::copy($target))
return false;
return copy($this->fileSource, $target);
}
|
[
"public",
"function",
"copy",
"(",
"$",
"target",
")",
"{",
"if",
"(",
"!",
"parent",
"::",
"copy",
"(",
"$",
"target",
")",
")",
"return",
"false",
";",
"return",
"copy",
"(",
"$",
"this",
"->",
"fileSource",
",",
"$",
"target",
")",
";",
"}"
] |
Copies the stored file's content to the local filesystem.
@param string $target the file target in the filesystem
|
[
"Copies",
"the",
"stored",
"file",
"s",
"content",
"to",
"the",
"local",
"filesystem",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/File/StoredFileContent.php#L59-L63
|
23,169
|
blast-project/BaseEntitiesBundle
|
src/Search/SearchHandler.php
|
SearchHandler.indexSearch
|
public function indexSearch($searchText, $maxResults)
{
// split the phrase into words
$words = SearchAnalyser::analyse($searchText);
if (!$words) {
return [];
}
$query = $this->_em->createQueryBuilder()
->select('o')
->from($this->_entityName, 'o')
->setMaxResults($maxResults);
$parameters = [];
foreach ($words as $k => $word) {
$subquery = $this->_em->createQueryBuilder()
->select("i$k.keyword")
->from($this->getSearchIndexClass(), "i$k")
->where("i$k.object = o")
->andWhere("i$k.keyword ILIKE :search$k");
$query->andWhere($query->expr()->exists($subquery->getDql()));
$parameters["search$k"] = '%' . $word . '%';
}
$query->setParameters($parameters);
$results = $query->getQuery()->execute();
return $results;
}
|
php
|
public function indexSearch($searchText, $maxResults)
{
// split the phrase into words
$words = SearchAnalyser::analyse($searchText);
if (!$words) {
return [];
}
$query = $this->_em->createQueryBuilder()
->select('o')
->from($this->_entityName, 'o')
->setMaxResults($maxResults);
$parameters = [];
foreach ($words as $k => $word) {
$subquery = $this->_em->createQueryBuilder()
->select("i$k.keyword")
->from($this->getSearchIndexClass(), "i$k")
->where("i$k.object = o")
->andWhere("i$k.keyword ILIKE :search$k");
$query->andWhere($query->expr()->exists($subquery->getDql()));
$parameters["search$k"] = '%' . $word . '%';
}
$query->setParameters($parameters);
$results = $query->getQuery()->execute();
return $results;
}
|
[
"public",
"function",
"indexSearch",
"(",
"$",
"searchText",
",",
"$",
"maxResults",
")",
"{",
"// split the phrase into words",
"$",
"words",
"=",
"SearchAnalyser",
"::",
"analyse",
"(",
"$",
"searchText",
")",
";",
"if",
"(",
"!",
"$",
"words",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'o'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"_entityName",
",",
"'o'",
")",
"->",
"setMaxResults",
"(",
"$",
"maxResults",
")",
";",
"$",
"parameters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"k",
"=>",
"$",
"word",
")",
"{",
"$",
"subquery",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"\"i$k.keyword\"",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"getSearchIndexClass",
"(",
")",
",",
"\"i$k\"",
")",
"->",
"where",
"(",
"\"i$k.object = o\"",
")",
"->",
"andWhere",
"(",
"\"i$k.keyword ILIKE :search$k\"",
")",
";",
"$",
"query",
"->",
"andWhere",
"(",
"$",
"query",
"->",
"expr",
"(",
")",
"->",
"exists",
"(",
"$",
"subquery",
"->",
"getDql",
"(",
")",
")",
")",
";",
"$",
"parameters",
"[",
"\"search$k\"",
"]",
"=",
"'%'",
".",
"$",
"word",
".",
"'%'",
";",
"}",
"$",
"query",
"->",
"setParameters",
"(",
"$",
"parameters",
")",
";",
"$",
"results",
"=",
"$",
"query",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"results",
";",
"}"
] |
Find the entities that have the appropriate keywords in their searchIndex.
@param string $searchText
@param int $maxResults
@return Collection found entities
|
[
"Find",
"the",
"entities",
"that",
"have",
"the",
"appropriate",
"keywords",
"in",
"their",
"searchIndex",
"."
] |
abd06891fc38922225ab7e4fcb437a286ba2c0c4
|
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Search/SearchHandler.php#L113-L141
|
23,170
|
blast-project/BaseEntitiesBundle
|
src/Search/SearchHandler.php
|
SearchHandler.truncateTable
|
public function truncateTable()
{
$connection = $this->_em->getConnection();
$dbPlatform = $connection->getDatabasePlatform();
$connection->beginTransaction();
try {
$q = $dbPlatform->getTruncateTableSql($this->getSearchIndexTable());
$connection->executeUpdate($q);
$connection->commit();
return true;
} catch (\Exception $e) {
$connection->rollback();
return false;
}
}
|
php
|
public function truncateTable()
{
$connection = $this->_em->getConnection();
$dbPlatform = $connection->getDatabasePlatform();
$connection->beginTransaction();
try {
$q = $dbPlatform->getTruncateTableSql($this->getSearchIndexTable());
$connection->executeUpdate($q);
$connection->commit();
return true;
} catch (\Exception $e) {
$connection->rollback();
return false;
}
}
|
[
"public",
"function",
"truncateTable",
"(",
")",
"{",
"$",
"connection",
"=",
"$",
"this",
"->",
"_em",
"->",
"getConnection",
"(",
")",
";",
"$",
"dbPlatform",
"=",
"$",
"connection",
"->",
"getDatabasePlatform",
"(",
")",
";",
"$",
"connection",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"q",
"=",
"$",
"dbPlatform",
"->",
"getTruncateTableSql",
"(",
"$",
"this",
"->",
"getSearchIndexTable",
"(",
")",
")",
";",
"$",
"connection",
"->",
"executeUpdate",
"(",
"$",
"q",
")",
";",
"$",
"connection",
"->",
"commit",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"connection",
"->",
"rollback",
"(",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Truncates the search index table.
@return bool true if success
|
[
"Truncates",
"the",
"search",
"index",
"table",
"."
] |
abd06891fc38922225ab7e4fcb437a286ba2c0c4
|
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Search/SearchHandler.php#L148-L164
|
23,171
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.setAttribute
|
public function setAttribute($key, $value)
{
if ($value instanceof BaseModel || $value instanceof Collection)
$this->setRelationship($value, $key);
elseif ( !is_array($value))
$this->attributes[$key] = $value;
else
$this->setRelationship($value, $key);
}
|
php
|
public function setAttribute($key, $value)
{
if ($value instanceof BaseModel || $value instanceof Collection)
$this->setRelationship($value, $key);
elseif ( !is_array($value))
$this->attributes[$key] = $value;
else
$this->setRelationship($value, $key);
}
|
[
"public",
"function",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"BaseModel",
"||",
"$",
"value",
"instanceof",
"Collection",
")",
"$",
"this",
"->",
"setRelationship",
"(",
"$",
"value",
",",
"$",
"key",
")",
";",
"elseif",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"else",
"$",
"this",
"->",
"setRelationship",
"(",
"$",
"value",
",",
"$",
"key",
")",
";",
"}"
] |
Sets the attributes for this model
@param mixed $key
@param mixed $value
|
[
"Sets",
"the",
"attributes",
"for",
"this",
"model"
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L115-L123
|
23,172
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.setRelationship
|
public function setRelationship($value, $key = '')
{
if (is_array($value)) {
$class = __NAMESPACE__ . '\\' . str_singular($key);
if (class_exists($class)) {
// Check to see if the key value is plural or singular
// if it is plural then we create a collection
// otherwise we instantiate the class and add a single item to the relationship
if (str_singular($key) == $key) {
$this->addRelationship(new $class($value));
}
else {
$collection = $class::newCollection($value);
$this->addRelationship($collection);
}
}
}
elseif ($value instanceof Collection) {
$this->addRelationship($value);
}
elseif ($value instanceof BaseModel) {
$this->addRelationship($value);
}
}
|
php
|
public function setRelationship($value, $key = '')
{
if (is_array($value)) {
$class = __NAMESPACE__ . '\\' . str_singular($key);
if (class_exists($class)) {
// Check to see if the key value is plural or singular
// if it is plural then we create a collection
// otherwise we instantiate the class and add a single item to the relationship
if (str_singular($key) == $key) {
$this->addRelationship(new $class($value));
}
else {
$collection = $class::newCollection($value);
$this->addRelationship($collection);
}
}
}
elseif ($value instanceof Collection) {
$this->addRelationship($value);
}
elseif ($value instanceof BaseModel) {
$this->addRelationship($value);
}
}
|
[
"public",
"function",
"setRelationship",
"(",
"$",
"value",
",",
"$",
"key",
"=",
"''",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"class",
"=",
"__NAMESPACE__",
".",
"'\\\\'",
".",
"str_singular",
"(",
"$",
"key",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"// Check to see if the key value is plural or singular",
"// if it is plural then we create a collection",
"// otherwise we instantiate the class and add a single item to the relationship",
"if",
"(",
"str_singular",
"(",
"$",
"key",
")",
"==",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"addRelationship",
"(",
"new",
"$",
"class",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"collection",
"=",
"$",
"class",
"::",
"newCollection",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"addRelationship",
"(",
"$",
"collection",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Collection",
")",
"{",
"$",
"this",
"->",
"addRelationship",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"BaseModel",
")",
"{",
"$",
"this",
"->",
"addRelationship",
"(",
"$",
"value",
")",
";",
"}",
"}"
] |
Sets the relationships on this model,
which in fact are collections of other models
@param string $key
@param array $value
|
[
"Sets",
"the",
"relationships",
"on",
"this",
"model",
"which",
"in",
"fact",
"are",
"collections",
"of",
"other",
"models"
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L132-L158
|
23,173
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.setAttributes
|
public function setAttributes(array $data)
{
$data = $this->stripResponseData($data);
foreach ($data as $key => $value) {
$this->setAttribute($key, $value);
}
return $this->getAttributes();
}
|
php
|
public function setAttributes(array $data)
{
$data = $this->stripResponseData($data);
foreach ($data as $key => $value) {
$this->setAttribute($key, $value);
}
return $this->getAttributes();
}
|
[
"public",
"function",
"setAttributes",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"stripResponseData",
"(",
"$",
"data",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getAttributes",
"(",
")",
";",
"}"
] |
Set all the attributes from an array.
@param array $data
|
[
"Set",
"all",
"the",
"attributes",
"from",
"an",
"array",
"."
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L192-L201
|
23,174
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.getSingularEntityName
|
public static function getSingularEntityName()
{
if ( isset(self::$entity_singular) && ! empty(self::$entity_singular))
return self::$entity_singular;
return str_singular(self::getEntityName());
}
|
php
|
public static function getSingularEntityName()
{
if ( isset(self::$entity_singular) && ! empty(self::$entity_singular))
return self::$entity_singular;
return str_singular(self::getEntityName());
}
|
[
"public",
"static",
"function",
"getSingularEntityName",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"entity_singular",
")",
"&&",
"!",
"empty",
"(",
"self",
"::",
"$",
"entity_singular",
")",
")",
"return",
"self",
"::",
"$",
"entity_singular",
";",
"return",
"str_singular",
"(",
"self",
"::",
"getEntityName",
"(",
")",
")",
";",
"}"
] |
Retrieves the singular name of the entity we are querying.
@return string
|
[
"Retrieves",
"the",
"singular",
"name",
"of",
"the",
"entity",
"we",
"are",
"querying",
"."
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L285-L291
|
23,175
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.request
|
public function request($method, $url, $params = array(), $xml = "", $format = "")
{
if ( !$format) $format = $this->format;
$response = $this->api->request($method, $url, $params, $xml, $format);
return $this->parseResponse($response);
}
|
php
|
public function request($method, $url, $params = array(), $xml = "", $format = "")
{
if ( !$format) $format = $this->format;
$response = $this->api->request($method, $url, $params, $xml, $format);
return $this->parseResponse($response);
}
|
[
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"xml",
"=",
"\"\"",
",",
"$",
"format",
"=",
"\"\"",
")",
"{",
"if",
"(",
"!",
"$",
"format",
")",
"$",
"format",
"=",
"$",
"this",
"->",
"format",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"params",
",",
"$",
"xml",
",",
"$",
"format",
")",
";",
"return",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"}"
] |
A high level request method used from static methods.
@param string $method
@param string $url
@param array $params
@param string $xml
@param string $format
@return Daursu\Xero\BaseModel
|
[
"A",
"high",
"level",
"request",
"method",
"used",
"from",
"static",
"methods",
"."
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L303-L309
|
23,176
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.get
|
public static function get($params = array())
{
$object = new static;
$data = $object->request('GET', $object->getUrl(), $params);
$data = $object->stripResponseData($data);
// Initialise a collection
$collection = self::newCollection();
if (isset($data[0]) && is_array($data[0])) {
// This should be a collection
$collection->setItems($data);
}
return $collection;
}
|
php
|
public static function get($params = array())
{
$object = new static;
$data = $object->request('GET', $object->getUrl(), $params);
$data = $object->stripResponseData($data);
// Initialise a collection
$collection = self::newCollection();
if (isset($data[0]) && is_array($data[0])) {
// This should be a collection
$collection->setItems($data);
}
return $collection;
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"object",
"=",
"new",
"static",
";",
"$",
"data",
"=",
"$",
"object",
"->",
"request",
"(",
"'GET'",
",",
"$",
"object",
"->",
"getUrl",
"(",
")",
",",
"$",
"params",
")",
";",
"$",
"data",
"=",
"$",
"object",
"->",
"stripResponseData",
"(",
"$",
"data",
")",
";",
"// Initialise a collection",
"$",
"collection",
"=",
"self",
"::",
"newCollection",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"0",
"]",
")",
"&&",
"is_array",
"(",
"$",
"data",
"[",
"0",
"]",
")",
")",
"{",
"// This should be a collection",
"$",
"collection",
"->",
"setItems",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"collection",
";",
"}"
] |
Get a collection of items
@param array $params
@return Daursu\Xero\BaseModel
|
[
"Get",
"a",
"collection",
"of",
"items"
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L317-L332
|
23,177
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.find
|
public static function find($id)
{
$object = new static;
$response = $object->request('GET', sprintf('%s/%s', $object->getUrl(), $id));
return $response ? $object : false;
}
|
php
|
public static function find($id)
{
$object = new static;
$response = $object->request('GET', sprintf('%s/%s', $object->getUrl(), $id));
return $response ? $object : false;
}
|
[
"public",
"static",
"function",
"find",
"(",
"$",
"id",
")",
"{",
"$",
"object",
"=",
"new",
"static",
";",
"$",
"response",
"=",
"$",
"object",
"->",
"request",
"(",
"'GET'",
",",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"object",
"->",
"getUrl",
"(",
")",
",",
"$",
"id",
")",
")",
";",
"return",
"$",
"response",
"?",
"$",
"object",
":",
"false",
";",
"}"
] |
Find a single element by its ID
@param mixed $id
@return Daursu\Xero\BaseModel
|
[
"Find",
"a",
"single",
"element",
"by",
"its",
"ID"
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L340-L346
|
23,178
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.create
|
public function create($params = array())
{
$response = $this->api->request('PUT', $this->getUrl(), $params, $this->toXML(), $this->format);
return $this->parseResponse($response) ? true : false;
}
|
php
|
public function create($params = array())
{
$response = $this->api->request('PUT', $this->getUrl(), $params, $this->toXML(), $this->format);
return $this->parseResponse($response) ? true : false;
}
|
[
"public",
"function",
"create",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'PUT'",
",",
"$",
"this",
"->",
"getUrl",
"(",
")",
",",
"$",
"params",
",",
"$",
"this",
"->",
"toXML",
"(",
")",
",",
"$",
"this",
"->",
"format",
")",
";",
"return",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"response",
")",
"?",
"true",
":",
"false",
";",
"}"
] |
Creates a new entity in Xero
@param array $data
@return boolean
|
[
"Creates",
"a",
"new",
"entity",
"in",
"Xero"
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L365-L369
|
23,179
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.save
|
public function save($params = array())
{
if ( isset($this->attributes[$this->primary_column])) {
return $this->update($params);
}
else {
return $this->create($params);
}
}
|
php
|
public function save($params = array())
{
if ( isset($this->attributes[$this->primary_column])) {
return $this->update($params);
}
else {
return $this->create($params);
}
}
|
[
"public",
"function",
"save",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"this",
"->",
"primary_column",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"update",
"(",
"$",
"params",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"create",
"(",
"$",
"params",
")",
";",
"}",
"}"
] |
Save an entity. If it doesn't have the primary key set
then it will create it, otherwise it will update it.
@param array $params
@return boolean
|
[
"Save",
"an",
"entity",
".",
"If",
"it",
"doesn",
"t",
"have",
"the",
"primary",
"key",
"set",
"then",
"it",
"will",
"create",
"it",
"otherwise",
"it",
"will",
"update",
"it",
"."
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L391-L399
|
23,180
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.array_to_xml
|
public static function array_to_xml($array, &$xml)
{
foreach($array as $key => $value) {
if(is_array($value)) {
if(!is_numeric($key)){
$subnode = $xml->addChild("$key");
self::array_to_xml($value, $subnode);
} elseif ($key == 0) {
self::array_to_xml($value, $xml);
} else {
$name = $xml->getName();
$subnode = $xml->xpath("..")[0]->addChild("$name");
self::array_to_xml($value, $subnode);
}
} else {
$xml->addChild("$key","$value");
}
}
}
|
php
|
public static function array_to_xml($array, &$xml)
{
foreach($array as $key => $value) {
if(is_array($value)) {
if(!is_numeric($key)){
$subnode = $xml->addChild("$key");
self::array_to_xml($value, $subnode);
} elseif ($key == 0) {
self::array_to_xml($value, $xml);
} else {
$name = $xml->getName();
$subnode = $xml->xpath("..")[0]->addChild("$name");
self::array_to_xml($value, $subnode);
}
} else {
$xml->addChild("$key","$value");
}
}
}
|
[
"public",
"static",
"function",
"array_to_xml",
"(",
"$",
"array",
",",
"&",
"$",
"xml",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"$",
"subnode",
"=",
"$",
"xml",
"->",
"addChild",
"(",
"\"$key\"",
")",
";",
"self",
"::",
"array_to_xml",
"(",
"$",
"value",
",",
"$",
"subnode",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"0",
")",
"{",
"self",
"::",
"array_to_xml",
"(",
"$",
"value",
",",
"$",
"xml",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"xml",
"->",
"getName",
"(",
")",
";",
"$",
"subnode",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"\"..\"",
")",
"[",
"0",
"]",
"->",
"addChild",
"(",
"\"$name\"",
")",
";",
"self",
"::",
"array_to_xml",
"(",
"$",
"value",
",",
"$",
"subnode",
")",
";",
"}",
"}",
"else",
"{",
"$",
"xml",
"->",
"addChild",
"(",
"\"$key\"",
",",
"\"$value\"",
")",
";",
"}",
"}",
"}"
] |
Helper function to convert an array to XML
@param array $array
@param SimpleXMLElement $xml
@return string
|
[
"Helper",
"function",
"to",
"convert",
"an",
"array",
"to",
"XML"
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L504-L522
|
23,181
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.stripResponseData
|
public function stripResponseData(array $data)
{
if (isset($data[self::getEntityName()]) && is_array($data[self::getEntityName()]))
$data = $data[self::getEntityName()];
if (isset($data[self::getSingularEntityName()]) && is_array($data[self::getSingularEntityName()]))
$data = $data[self::getSingularEntityName()];
return $data;
}
|
php
|
public function stripResponseData(array $data)
{
if (isset($data[self::getEntityName()]) && is_array($data[self::getEntityName()]))
$data = $data[self::getEntityName()];
if (isset($data[self::getSingularEntityName()]) && is_array($data[self::getSingularEntityName()]))
$data = $data[self::getSingularEntityName()];
return $data;
}
|
[
"public",
"function",
"stripResponseData",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"self",
"::",
"getEntityName",
"(",
")",
"]",
")",
"&&",
"is_array",
"(",
"$",
"data",
"[",
"self",
"::",
"getEntityName",
"(",
")",
"]",
")",
")",
"$",
"data",
"=",
"$",
"data",
"[",
"self",
"::",
"getEntityName",
"(",
")",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"self",
"::",
"getSingularEntityName",
"(",
")",
"]",
")",
"&&",
"is_array",
"(",
"$",
"data",
"[",
"self",
"::",
"getSingularEntityName",
"(",
")",
"]",
")",
")",
"$",
"data",
"=",
"$",
"data",
"[",
"self",
"::",
"getSingularEntityName",
"(",
")",
"]",
";",
"return",
"$",
"data",
";",
"}"
] |
This function removes all the unecessary data from a response
and leaves us with what we need when trying to populate objects or
collections with data
@param array $data
@return array
|
[
"This",
"function",
"removes",
"all",
"the",
"unecessary",
"data",
"from",
"a",
"response",
"and",
"leaves",
"us",
"with",
"what",
"we",
"need",
"when",
"trying",
"to",
"populate",
"objects",
"or",
"collections",
"with",
"data"
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L532-L541
|
23,182
|
Daursu/xero
|
src/Daursu/Xero/models/BaseModel.php
|
BaseModel.parseResponse
|
protected function parseResponse($response, $setAttributes = true)
{
if ($response['code'] == 200)
{
$data = $this->api->parseResponse($response['response'], $response['format']);
if ($response['format'] == 'xml') {
$data = json_encode($data);
$data = json_decode($data, true);
}
// print_r($data);
if ($setAttributes && is_array($data))
$this->setAttributes($data);
return $data;
}
elseif ($response['code'] == 404)
{
return false;
}
else
{
throw new XeroGeneralException('Error from Xero: ' . $response['response']);
}
}
|
php
|
protected function parseResponse($response, $setAttributes = true)
{
if ($response['code'] == 200)
{
$data = $this->api->parseResponse($response['response'], $response['format']);
if ($response['format'] == 'xml') {
$data = json_encode($data);
$data = json_decode($data, true);
}
// print_r($data);
if ($setAttributes && is_array($data))
$this->setAttributes($data);
return $data;
}
elseif ($response['code'] == 404)
{
return false;
}
else
{
throw new XeroGeneralException('Error from Xero: ' . $response['response']);
}
}
|
[
"protected",
"function",
"parseResponse",
"(",
"$",
"response",
",",
"$",
"setAttributes",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"response",
"[",
"'code'",
"]",
"==",
"200",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"api",
"->",
"parseResponse",
"(",
"$",
"response",
"[",
"'response'",
"]",
",",
"$",
"response",
"[",
"'format'",
"]",
")",
";",
"if",
"(",
"$",
"response",
"[",
"'format'",
"]",
"==",
"'xml'",
")",
"{",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
";",
"}",
"// print_r($data);",
"if",
"(",
"$",
"setAttributes",
"&&",
"is_array",
"(",
"$",
"data",
")",
")",
"$",
"this",
"->",
"setAttributes",
"(",
"$",
"data",
")",
";",
"return",
"$",
"data",
";",
"}",
"elseif",
"(",
"$",
"response",
"[",
"'code'",
"]",
"==",
"404",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"throw",
"new",
"XeroGeneralException",
"(",
"'Error from Xero: '",
".",
"$",
"response",
"[",
"'response'",
"]",
")",
";",
"}",
"}"
] |
Parses the response retrieved from Xero,
or throws an exception if it fails.
@param array $response
@return array
|
[
"Parses",
"the",
"response",
"retrieved",
"from",
"Xero",
"or",
"throws",
"an",
"exception",
"if",
"it",
"fails",
"."
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/BaseModel.php#L550-L576
|
23,183
|
phergie/phergie-irc-plugin-react-nickserv
|
src/Plugin.php
|
Plugin.handleNotice
|
public function handleNotice(UserEvent $event, Queue $queue)
{
// Ignore notices that aren't from the NickServ agent
if (strcasecmp($event->getNick(), $this->botNick) !== 0) {
return;
}
$connection = $event->getConnection();
$params = $event->getParams();
$message = $params['text'];
// Authenticate the bot's identity for authentication requests
if (preg_match($this->identifyPattern, $message)) {
return $queue->ircPrivmsg($this->botNick, 'IDENTIFY ' . $this->password);
}
// Emit an event on successful authentication
if (preg_match($this->loginPattern, $message)) {
return $this->getEventEmitter()->emit('nickserv.identified', [$connection, $queue]);
}
// Reclaim primary nick on ghost confirmation
if ($this->ghostNick !== null && preg_match($this->ghostPattern, $message)) {
$queue->ircNick($this->ghostNick);
$this->ghostNick = null;
return;
}
}
|
php
|
public function handleNotice(UserEvent $event, Queue $queue)
{
// Ignore notices that aren't from the NickServ agent
if (strcasecmp($event->getNick(), $this->botNick) !== 0) {
return;
}
$connection = $event->getConnection();
$params = $event->getParams();
$message = $params['text'];
// Authenticate the bot's identity for authentication requests
if (preg_match($this->identifyPattern, $message)) {
return $queue->ircPrivmsg($this->botNick, 'IDENTIFY ' . $this->password);
}
// Emit an event on successful authentication
if (preg_match($this->loginPattern, $message)) {
return $this->getEventEmitter()->emit('nickserv.identified', [$connection, $queue]);
}
// Reclaim primary nick on ghost confirmation
if ($this->ghostNick !== null && preg_match($this->ghostPattern, $message)) {
$queue->ircNick($this->ghostNick);
$this->ghostNick = null;
return;
}
}
|
[
"public",
"function",
"handleNotice",
"(",
"UserEvent",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"// Ignore notices that aren't from the NickServ agent",
"if",
"(",
"strcasecmp",
"(",
"$",
"event",
"->",
"getNick",
"(",
")",
",",
"$",
"this",
"->",
"botNick",
")",
"!==",
"0",
")",
"{",
"return",
";",
"}",
"$",
"connection",
"=",
"$",
"event",
"->",
"getConnection",
"(",
")",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"message",
"=",
"$",
"params",
"[",
"'text'",
"]",
";",
"// Authenticate the bot's identity for authentication requests",
"if",
"(",
"preg_match",
"(",
"$",
"this",
"->",
"identifyPattern",
",",
"$",
"message",
")",
")",
"{",
"return",
"$",
"queue",
"->",
"ircPrivmsg",
"(",
"$",
"this",
"->",
"botNick",
",",
"'IDENTIFY '",
".",
"$",
"this",
"->",
"password",
")",
";",
"}",
"// Emit an event on successful authentication",
"if",
"(",
"preg_match",
"(",
"$",
"this",
"->",
"loginPattern",
",",
"$",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getEventEmitter",
"(",
")",
"->",
"emit",
"(",
"'nickserv.identified'",
",",
"[",
"$",
"connection",
",",
"$",
"queue",
"]",
")",
";",
"}",
"// Reclaim primary nick on ghost confirmation",
"if",
"(",
"$",
"this",
"->",
"ghostNick",
"!==",
"null",
"&&",
"preg_match",
"(",
"$",
"this",
"->",
"ghostPattern",
",",
"$",
"message",
")",
")",
"{",
"$",
"queue",
"->",
"ircNick",
"(",
"$",
"this",
"->",
"ghostNick",
")",
";",
"$",
"this",
"->",
"ghostNick",
"=",
"null",
";",
"return",
";",
"}",
"}"
] |
Responds to authentication requests and notifications of ghost
connections being killed from NickServ.
@param \Phergie\Irc\Event\UserEventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue
|
[
"Responds",
"to",
"authentication",
"requests",
"and",
"notifications",
"of",
"ghost",
"connections",
"being",
"killed",
"from",
"NickServ",
"."
] |
0319c79314029bd1ebab0de04a67ff20705e36da
|
https://github.com/phergie/phergie-irc-plugin-react-nickserv/blob/0319c79314029bd1ebab0de04a67ff20705e36da/src/Plugin.php#L146-L173
|
23,184
|
phergie/phergie-irc-plugin-react-nickserv
|
src/Plugin.php
|
Plugin.handleNick
|
public function handleNick(UserEvent $event, Queue $queue)
{
$connection = $event->getConnection();
if (strcasecmp($event->getNick(), $connection->getNickname()) === 0) {
$params = $event->getParams();
$connection->setNickname($params['nickname']);
}
}
|
php
|
public function handleNick(UserEvent $event, Queue $queue)
{
$connection = $event->getConnection();
if (strcasecmp($event->getNick(), $connection->getNickname()) === 0) {
$params = $event->getParams();
$connection->setNickname($params['nickname']);
}
}
|
[
"public",
"function",
"handleNick",
"(",
"UserEvent",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"$",
"connection",
"=",
"$",
"event",
"->",
"getConnection",
"(",
")",
";",
"if",
"(",
"strcasecmp",
"(",
"$",
"event",
"->",
"getNick",
"(",
")",
",",
"$",
"connection",
"->",
"getNickname",
"(",
")",
")",
"===",
"0",
")",
"{",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"connection",
"->",
"setNickname",
"(",
"$",
"params",
"[",
"'nickname'",
"]",
")",
";",
"}",
"}"
] |
Changes the nick associated with the bot in local memory when a change
to it is successfully registered with the server.
@param \Phergie\Irc\Event\UserEventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue
|
[
"Changes",
"the",
"nick",
"associated",
"with",
"the",
"bot",
"in",
"local",
"memory",
"when",
"a",
"change",
"to",
"it",
"is",
"successfully",
"registered",
"with",
"the",
"server",
"."
] |
0319c79314029bd1ebab0de04a67ff20705e36da
|
https://github.com/phergie/phergie-irc-plugin-react-nickserv/blob/0319c79314029bd1ebab0de04a67ff20705e36da/src/Plugin.php#L182-L189
|
23,185
|
phergie/phergie-irc-plugin-react-nickserv
|
src/Plugin.php
|
Plugin.handleNicknameInUse
|
public function handleNicknameInUse(ServerEvent $event, Queue $queue)
{
// Don't listen if ghost isn't enabled, or this isn't the first nickname-in-use error
if (!$this->ghostEnabled || $this->ghostNick !== null) {
return;
}
// Save the nick, so that we can send a ghost request once registration is complete
$params = $event->getParams();
$this->ghostNick = $params[1];
}
|
php
|
public function handleNicknameInUse(ServerEvent $event, Queue $queue)
{
// Don't listen if ghost isn't enabled, or this isn't the first nickname-in-use error
if (!$this->ghostEnabled || $this->ghostNick !== null) {
return;
}
// Save the nick, so that we can send a ghost request once registration is complete
$params = $event->getParams();
$this->ghostNick = $params[1];
}
|
[
"public",
"function",
"handleNicknameInUse",
"(",
"ServerEvent",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"// Don't listen if ghost isn't enabled, or this isn't the first nickname-in-use error",
"if",
"(",
"!",
"$",
"this",
"->",
"ghostEnabled",
"||",
"$",
"this",
"->",
"ghostNick",
"!==",
"null",
")",
"{",
"return",
";",
"}",
"// Save the nick, so that we can send a ghost request once registration is complete",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"this",
"->",
"ghostNick",
"=",
"$",
"params",
"[",
"1",
"]",
";",
"}"
] |
Kick-starts the ghost process.
@param \Phergie\Irc\Event\ServerEventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue
|
[
"Kick",
"-",
"starts",
"the",
"ghost",
"process",
"."
] |
0319c79314029bd1ebab0de04a67ff20705e36da
|
https://github.com/phergie/phergie-irc-plugin-react-nickserv/blob/0319c79314029bd1ebab0de04a67ff20705e36da/src/Plugin.php#L197-L207
|
23,186
|
phergie/phergie-irc-plugin-react-nickserv
|
src/Plugin.php
|
Plugin.handleGhost
|
public function handleGhost(ServerEvent $event, Queue $queue)
{
if ($this->ghostNick === null) {
return;
}
// Attempt to kill the ghost connection
$queue->ircPrivmsg($this->botNick, 'GHOST ' . $this->ghostNick . ' ' . $this->password);
}
|
php
|
public function handleGhost(ServerEvent $event, Queue $queue)
{
if ($this->ghostNick === null) {
return;
}
// Attempt to kill the ghost connection
$queue->ircPrivmsg($this->botNick, 'GHOST ' . $this->ghostNick . ' ' . $this->password);
}
|
[
"public",
"function",
"handleGhost",
"(",
"ServerEvent",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ghostNick",
"===",
"null",
")",
"{",
"return",
";",
"}",
"// Attempt to kill the ghost connection",
"$",
"queue",
"->",
"ircPrivmsg",
"(",
"$",
"this",
"->",
"botNick",
",",
"'GHOST '",
".",
"$",
"this",
"->",
"ghostNick",
".",
"' '",
".",
"$",
"this",
"->",
"password",
")",
";",
"}"
] |
Completes the ghost process.
@param \Phergie\Irc\Event\ServerEventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue
|
[
"Completes",
"the",
"ghost",
"process",
"."
] |
0319c79314029bd1ebab0de04a67ff20705e36da
|
https://github.com/phergie/phergie-irc-plugin-react-nickserv/blob/0319c79314029bd1ebab0de04a67ff20705e36da/src/Plugin.php#L215-L223
|
23,187
|
phergie/phergie-irc-plugin-react-nickserv
|
src/Plugin.php
|
Plugin.getConfigOption
|
protected function getConfigOption(array $config, $key)
{
if (empty($config[$key]) || !is_string($config[$key])) {
throw new \DomainException(
"$key must be a non-empty string"
);
}
return $config[$key];
}
|
php
|
protected function getConfigOption(array $config, $key)
{
if (empty($config[$key]) || !is_string($config[$key])) {
throw new \DomainException(
"$key must be a non-empty string"
);
}
return $config[$key];
}
|
[
"protected",
"function",
"getConfigOption",
"(",
"array",
"$",
"config",
",",
"$",
"key",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"config",
"[",
"$",
"key",
"]",
")",
"||",
"!",
"is_string",
"(",
"$",
"config",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"\"$key must be a non-empty string\"",
")",
";",
"}",
"return",
"$",
"config",
"[",
"$",
"key",
"]",
";",
"}"
] |
Extracts a string from the config options map.
@param array $config
@param string $key
@return string
@throws \DomainException if password is unspecified or not a string
|
[
"Extracts",
"a",
"string",
"from",
"the",
"config",
"options",
"map",
"."
] |
0319c79314029bd1ebab0de04a67ff20705e36da
|
https://github.com/phergie/phergie-irc-plugin-react-nickserv/blob/0319c79314029bd1ebab0de04a67ff20705e36da/src/Plugin.php#L233-L241
|
23,188
|
willishq/laravel5-flash
|
src/Flash.php
|
Flash.message
|
protected function message($message, $title = '', $type = 'info')
{
$this->message = $message;
$this->title = $title;
$this->type = $type;
$this->session->flash($this->namespace, (array) $this);
}
|
php
|
protected function message($message, $title = '', $type = 'info')
{
$this->message = $message;
$this->title = $title;
$this->type = $type;
$this->session->flash($this->namespace, (array) $this);
}
|
[
"protected",
"function",
"message",
"(",
"$",
"message",
",",
"$",
"title",
"=",
"''",
",",
"$",
"type",
"=",
"'info'",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"$",
"message",
";",
"$",
"this",
"->",
"title",
"=",
"$",
"title",
";",
"$",
"this",
"->",
"type",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"session",
"->",
"flash",
"(",
"$",
"this",
"->",
"namespace",
",",
"(",
"array",
")",
"$",
"this",
")",
";",
"}"
] |
Setup the flash messsage data.
@param string $message
@param string $title
@param string $level
|
[
"Setup",
"the",
"flash",
"messsage",
"data",
"."
] |
47f436b30e5a2f5b06a742e8ed9d49251eac5589
|
https://github.com/willishq/laravel5-flash/blob/47f436b30e5a2f5b06a742e8ed9d49251eac5589/src/Flash.php#L68-L74
|
23,189
|
FrenzelGmbH/cm-address
|
controllers/AddressController.php
|
AddressController.actionDelete
|
public function actionDelete($id)
{
$date = new DateTime('now');
$model = $this->findModel($id);
$model->deleted_at = $date->format("U");
$model->save();
return $this->redirect(['index']);
}
|
php
|
public function actionDelete($id)
{
$date = new DateTime('now');
$model = $this->findModel($id);
$model->deleted_at = $date->format("U");
$model->save();
return $this->redirect(['index']);
}
|
[
"public",
"function",
"actionDelete",
"(",
"$",
"id",
")",
"{",
"$",
"date",
"=",
"new",
"DateTime",
"(",
"'now'",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"->",
"deleted_at",
"=",
"$",
"date",
"->",
"format",
"(",
"\"U\"",
")",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'index'",
"]",
")",
";",
"}"
] |
Deletes an existing Address model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed
|
[
"Deletes",
"an",
"existing",
"Address",
"model",
".",
"If",
"deletion",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] |
4295671dc603beed4bea6c5a7f77dac9846127f3
|
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/AddressController.php#L101-L109
|
23,190
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.lookup
|
public function lookup($context, $path, $require = false)
{
if (empty($path)) {
throw new \InvalidArgumentException("Passed lookup path is empty.");
}
if (empty($context)) {
throw new \InvalidArgumentException("Specified context is empty while resolving path " . json_encode($path));
}
return PropertyAccessor::getByPath($context, $this->path($path), $require);
}
|
php
|
public function lookup($context, $path, $require = false)
{
if (empty($path)) {
throw new \InvalidArgumentException("Passed lookup path is empty.");
}
if (empty($context)) {
throw new \InvalidArgumentException("Specified context is empty while resolving path " . json_encode($path));
}
return PropertyAccessor::getByPath($context, $this->path($path), $require);
}
|
[
"public",
"function",
"lookup",
"(",
"$",
"context",
",",
"$",
"path",
",",
"$",
"require",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Passed lookup path is empty.\"",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"context",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Specified context is empty while resolving path \"",
".",
"json_encode",
"(",
"$",
"path",
")",
")",
";",
"}",
"return",
"PropertyAccessor",
"::",
"getByPath",
"(",
"$",
"context",
",",
"$",
"this",
"->",
"path",
"(",
"$",
"path",
")",
",",
"$",
"require",
")",
";",
"}"
] |
Looks up a path in the specified context
@param array $context
@param array $path
@param bool $require
@return string
@throws \RuntimeException
@throws \InvalidArgumentException
|
[
"Looks",
"up",
"a",
"path",
"in",
"the",
"specified",
"context"
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L216-L225
|
23,191
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.resolve
|
public function resolve($id, $required = false)
{
$id = $this->path($id);
try {
if (in_array($id, $this->resolutionStack)) {
$path = array_map(
function ($a) {
return join('.', $a);
},
$this->resolutionStack
);
throw new CircularReferenceException(
sprintf(
"Circular reference detected: %s -> %s",
implode(' -> ', $path),
join('.', $id)
)
);
}
array_push($this->resolutionStack, $id);
$ret = $this->value($this->lookup($this->values, $id, $required));
array_pop($this->resolutionStack);
return $ret;
} catch (\Exception $e) {
if ($e instanceof CircularReferenceException) {
throw $e;
}
throw new \RuntimeException("While resolving value " . join(".", $id), 0, $e);
}
}
|
php
|
public function resolve($id, $required = false)
{
$id = $this->path($id);
try {
if (in_array($id, $this->resolutionStack)) {
$path = array_map(
function ($a) {
return join('.', $a);
},
$this->resolutionStack
);
throw new CircularReferenceException(
sprintf(
"Circular reference detected: %s -> %s",
implode(' -> ', $path),
join('.', $id)
)
);
}
array_push($this->resolutionStack, $id);
$ret = $this->value($this->lookup($this->values, $id, $required));
array_pop($this->resolutionStack);
return $ret;
} catch (\Exception $e) {
if ($e instanceof CircularReferenceException) {
throw $e;
}
throw new \RuntimeException("While resolving value " . join(".", $id), 0, $e);
}
}
|
[
"public",
"function",
"resolve",
"(",
"$",
"id",
",",
"$",
"required",
"=",
"false",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"path",
"(",
"$",
"id",
")",
";",
"try",
"{",
"if",
"(",
"in_array",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"resolutionStack",
")",
")",
"{",
"$",
"path",
"=",
"array_map",
"(",
"function",
"(",
"$",
"a",
")",
"{",
"return",
"join",
"(",
"'.'",
",",
"$",
"a",
")",
";",
"}",
",",
"$",
"this",
"->",
"resolutionStack",
")",
";",
"throw",
"new",
"CircularReferenceException",
"(",
"sprintf",
"(",
"\"Circular reference detected: %s -> %s\"",
",",
"implode",
"(",
"' -> '",
",",
"$",
"path",
")",
",",
"join",
"(",
"'.'",
",",
"$",
"id",
")",
")",
")",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"resolutionStack",
",",
"$",
"id",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"value",
"(",
"$",
"this",
"->",
"lookup",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"id",
",",
"$",
"required",
")",
")",
";",
"array_pop",
"(",
"$",
"this",
"->",
"resolutionStack",
")",
";",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"CircularReferenceException",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"While resolving value \"",
".",
"join",
"(",
"\".\"",
",",
"$",
"id",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Resolve the specified path. If the resulting value is a Closure, it's assumed a declaration and therefore
executed
@param array|string $id
@param bool $required
@return string
@throws \RuntimeException
@throws CircularReferenceException
|
[
"Resolve",
"the",
"specified",
"path",
".",
"If",
"the",
"resulting",
"value",
"is",
"a",
"Closure",
"it",
"s",
"assumed",
"a",
"declaration",
"and",
"therefore",
"executed"
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L238-L270
|
23,192
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.set
|
public function set($path, $value)
{
PropertyAccessor::setByPath($this->values, $this->path($path), $value);
}
|
php
|
public function set($path, $value)
{
PropertyAccessor::setByPath($this->values, $this->path($path), $value);
}
|
[
"public",
"function",
"set",
"(",
"$",
"path",
",",
"$",
"value",
")",
"{",
"PropertyAccessor",
"::",
"setByPath",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"this",
"->",
"path",
"(",
"$",
"path",
")",
",",
"$",
"value",
")",
";",
"}"
] |
Set the value at the specified path
@param array|string $path
@param mixed $value
@return void
@throws \UnexpectedValueException
|
[
"Set",
"the",
"value",
"at",
"the",
"specified",
"path"
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L282-L285
|
23,193
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.helperExec
|
public function helperExec($cmd)
{
if ($this->resolve('EXPLAIN')) {
$this->output->writeln("# Task needs the following helper command:");
$this->output->writeln("# " . str_replace("\n", "\\n", $cmd));
}
$ret = '';
$this->executor->execute($cmd, $ret);
return $ret;
}
|
php
|
public function helperExec($cmd)
{
if ($this->resolve('EXPLAIN')) {
$this->output->writeln("# Task needs the following helper command:");
$this->output->writeln("# " . str_replace("\n", "\\n", $cmd));
}
$ret = '';
$this->executor->execute($cmd, $ret);
return $ret;
}
|
[
"public",
"function",
"helperExec",
"(",
"$",
"cmd",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"resolve",
"(",
"'EXPLAIN'",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"\"# Task needs the following helper command:\"",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"\"# \"",
".",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\\\n\"",
",",
"$",
"cmd",
")",
")",
";",
"}",
"$",
"ret",
"=",
"''",
";",
"$",
"this",
"->",
"executor",
"->",
"execute",
"(",
"$",
"cmd",
",",
"$",
"ret",
")",
";",
"return",
"$",
"ret",
";",
"}"
] |
This is useful for commands that need the shell regardless of the 'explain' value setting.
@param string $cmd
@return mixed
|
[
"This",
"is",
"useful",
"for",
"commands",
"that",
"need",
"the",
"shell",
"regardless",
"of",
"the",
"explain",
"value",
"setting",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L293-L302
|
23,194
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.fn
|
public function fn($id, $callable = null, $needsContainer = false)
{
if ($callable === null) {
$callable = $id;
}
if (!is_callable($callable)) {
throw new \InvalidArgumentException("Not callable");
}
$this->set($id, array($callable, $needsContainer));
}
|
php
|
public function fn($id, $callable = null, $needsContainer = false)
{
if ($callable === null) {
$callable = $id;
}
if (!is_callable($callable)) {
throw new \InvalidArgumentException("Not callable");
}
$this->set($id, array($callable, $needsContainer));
}
|
[
"public",
"function",
"fn",
"(",
"$",
"id",
",",
"$",
"callable",
"=",
"null",
",",
"$",
"needsContainer",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"callable",
"===",
"null",
")",
"{",
"$",
"callable",
"=",
"$",
"id",
";",
"}",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Not callable\"",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"$",
"id",
",",
"array",
"(",
"$",
"callable",
",",
"$",
"needsContainer",
")",
")",
";",
"}"
] |
Set a function at the specified path.
@param array|string $id
@param callable $callable
@param bool $needsContainer
@return void
@throws \InvalidArgumentException
|
[
"Set",
"a",
"function",
"at",
"the",
"specified",
"path",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L331-L340
|
23,195
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.decl
|
public function decl($id, $callable)
{
if (!is_callable($callable)) {
throw new \InvalidArgumentException("Passed declaration is not callable");
}
$this->set($id, function (Container $c) use($callable, $id) {
Debug::enterScope(join('.', (array)$id));
if (null !== ($value = call_user_func($callable, $c))) {
$c->set($id, $value);
}
Debug::exitScope(join('.', (array)$id));
return $value;
});
}
|
php
|
public function decl($id, $callable)
{
if (!is_callable($callable)) {
throw new \InvalidArgumentException("Passed declaration is not callable");
}
$this->set($id, function (Container $c) use($callable, $id) {
Debug::enterScope(join('.', (array)$id));
if (null !== ($value = call_user_func($callable, $c))) {
$c->set($id, $value);
}
Debug::exitScope(join('.', (array)$id));
return $value;
});
}
|
[
"public",
"function",
"decl",
"(",
"$",
"id",
",",
"$",
"callable",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Passed declaration is not callable\"",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"$",
"id",
",",
"function",
"(",
"Container",
"$",
"c",
")",
"use",
"(",
"$",
"callable",
",",
"$",
"id",
")",
"{",
"Debug",
"::",
"enterScope",
"(",
"join",
"(",
"'.'",
",",
"(",
"array",
")",
"$",
"id",
")",
")",
";",
"if",
"(",
"null",
"!==",
"(",
"$",
"value",
"=",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"c",
")",
")",
")",
"{",
"$",
"c",
"->",
"set",
"(",
"$",
"id",
",",
"$",
"value",
")",
";",
"}",
"Debug",
"::",
"exitScope",
"(",
"join",
"(",
"'.'",
",",
"(",
"array",
")",
"$",
"id",
")",
")",
";",
"return",
"$",
"value",
";",
"}",
")",
";",
"}"
] |
Does a declaration, i.e., the first time the declaration is called, it's resulting value overwrites the
declaration.
@param array|string $id
@param callable $callable
@return void
@throws \InvalidArgumentException
|
[
"Does",
"a",
"declaration",
"i",
".",
"e",
".",
"the",
"first",
"time",
"the",
"declaration",
"is",
"called",
"it",
"s",
"resulting",
"value",
"overwrites",
"the",
"declaration",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L366-L379
|
23,196
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.has
|
public function has($id)
{
try {
$existing = $this->get($id);
} catch (\OutOfBoundsException $e) {
return false;
}
return Util::typeOf($existing);
}
|
php
|
public function has($id)
{
try {
$existing = $this->get($id);
} catch (\OutOfBoundsException $e) {
return false;
}
return Util::typeOf($existing);
}
|
[
"public",
"function",
"has",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"existing",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"\\",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"Util",
"::",
"typeOf",
"(",
"$",
"existing",
")",
";",
"}"
] |
Checks for existence of the specified path.
@param string $id
@return string
|
[
"Checks",
"for",
"existence",
"of",
"the",
"specified",
"path",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L421-L429
|
23,197
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.isEmpty
|
public function isEmpty($path)
{
try {
$value = $this->get($path);
} catch (\OutOfBoundsException $e) {
return true;
}
return '' === $value || null === $value;
}
|
php
|
public function isEmpty($path)
{
try {
$value = $this->get($path);
} catch (\OutOfBoundsException $e) {
return true;
}
return '' === $value || null === $value;
}
|
[
"public",
"function",
"isEmpty",
"(",
"$",
"path",
")",
"{",
"try",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"\\",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"return",
"true",
";",
"}",
"return",
"''",
"===",
"$",
"value",
"||",
"null",
"===",
"$",
"value",
";",
"}"
] |
Checks if a value is empty.
@param mixed $path
@return bool
|
[
"Checks",
"if",
"a",
"value",
"is",
"empty",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L438-L446
|
23,198
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.call
|
public function call()
{
$args = func_get_args();
$service = array_shift($args);
if (!is_array($service)) {
throw new \RuntimeException("Expected an array");
}
if (!is_callable($service[0])) {
throw new \InvalidArgumentException("Can not use service '{$service[0]}' as a function, it is not callable");
}
// if the service needs the container, it is specified in the decl() call as the second param:
if ($service[1]) {
array_unshift($args, $this);
}
return call_user_func_array($service[0], $args);
}
|
php
|
public function call()
{
$args = func_get_args();
$service = array_shift($args);
if (!is_array($service)) {
throw new \RuntimeException("Expected an array");
}
if (!is_callable($service[0])) {
throw new \InvalidArgumentException("Can not use service '{$service[0]}' as a function, it is not callable");
}
// if the service needs the container, it is specified in the decl() call as the second param:
if ($service[1]) {
array_unshift($args, $this);
}
return call_user_func_array($service[0], $args);
}
|
[
"public",
"function",
"call",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"service",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"service",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Expected an array\"",
")",
";",
"}",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"service",
"[",
"0",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Can not use service '{$service[0]}' as a function, it is not callable\"",
")",
";",
"}",
"// if the service needs the container, it is specified in the decl() call as the second param:",
"if",
"(",
"$",
"service",
"[",
"1",
"]",
")",
"{",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"this",
")",
";",
"}",
"return",
"call_user_func_array",
"(",
"$",
"service",
"[",
"0",
"]",
",",
"$",
"args",
")",
";",
"}"
] |
Separate helper for calling a service as a function.
@return mixed
@throws \InvalidArgumentException
|
[
"Separate",
"helper",
"for",
"calling",
"a",
"service",
"as",
"a",
"function",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L456-L472
|
23,199
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.setOutputPrefix
|
private function setOutputPrefix($prefix)
{
if (!($this->output->getFormatter() instanceof PrefixFormatter)) {
return;
}
$this->output->getFormatter()->prefix = $prefix;
}
|
php
|
private function setOutputPrefix($prefix)
{
if (!($this->output->getFormatter() instanceof PrefixFormatter)) {
return;
}
$this->output->getFormatter()->prefix = $prefix;
}
|
[
"private",
"function",
"setOutputPrefix",
"(",
"$",
"prefix",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"output",
"->",
"getFormatter",
"(",
")",
"instanceof",
"PrefixFormatter",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"getFormatter",
"(",
")",
"->",
"prefix",
"=",
"$",
"prefix",
";",
"}"
] |
Helper to set prefix if the output if PrefixFormatter
@param string $prefix
@return void
|
[
"Helper",
"to",
"set",
"prefix",
"if",
"the",
"output",
"if",
"PrefixFormatter"
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L480-L487
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.