repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
osflab/exception | PhpErrorException.php | PhpErrorException.triggerApplication | protected static function triggerApplication(self $e): void
{
if (class_exists('\Osf\Application\OsfApplication')) {
if (\Osf\Application\OsfApplication::isDevelopment()) {
\Osf\Exception\Error::displayException($e);
} else {
if (\Osf\Application\OsfApplication::isStaging()) {
$err = sprintf(__("%s. Details in log file."), $e->getMessage());
echo \Osf\Container\OsfContainer::getViewHelper()->alert(__("Error detected"), $err)->statusWarning();
}
}
}
} | php | protected static function triggerApplication(self $e): void
{
if (class_exists('\Osf\Application\OsfApplication')) {
if (\Osf\Application\OsfApplication::isDevelopment()) {
\Osf\Exception\Error::displayException($e);
} else {
if (\Osf\Application\OsfApplication::isStaging()) {
$err = sprintf(__("%s. Details in log file."), $e->getMessage());
echo \Osf\Container\OsfContainer::getViewHelper()->alert(__("Error detected"), $err)->statusWarning();
}
}
}
} | [
"protected",
"static",
"function",
"triggerApplication",
"(",
"self",
"$",
"e",
")",
":",
"void",
"{",
"if",
"(",
"class_exists",
"(",
"'\\Osf\\Application\\OsfApplication'",
")",
")",
"{",
"if",
"(",
"\\",
"Osf",
"\\",
"Application",
"\\",
"OsfApplication",
"... | Transmit error to the application context
@param self $e
@return void | [
"Transmit",
"error",
"to",
"the",
"application",
"context"
] | 01fda2339cc654ec01092aff7c581032b082cf38 | https://github.com/osflab/exception/blob/01fda2339cc654ec01092aff7c581032b082cf38/PhpErrorException.php#L125-L137 | train |
gearphp/loop | Manager/WhileManager.php | WhileManager.addTick | public function addTick(TickInterface $tick)
{
$tick->setManager($this);
$this->ticks[$tick->getName()] = [
'tick' => $tick,
'time' => 0,
];
return $this;
} | php | public function addTick(TickInterface $tick)
{
$tick->setManager($this);
$this->ticks[$tick->getName()] = [
'tick' => $tick,
'time' => 0,
];
return $this;
} | [
"public",
"function",
"addTick",
"(",
"TickInterface",
"$",
"tick",
")",
"{",
"$",
"tick",
"->",
"setManager",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"ticks",
"[",
"$",
"tick",
"->",
"getName",
"(",
")",
"]",
"=",
"[",
"'tick'",
"=>",
"$",
... | Add tick to loop.
@param TickInterface $tick
@return $this | [
"Add",
"tick",
"to",
"loop",
"."
] | 53032b3e9f789b729744922c75e09b2a33845f90 | https://github.com/gearphp/loop/blob/53032b3e9f789b729744922c75e09b2a33845f90/Manager/WhileManager.php#L68-L77 | train |
gearphp/loop | Manager/WhileManager.php | WhileManager.removeTick | public function removeTick($name)
{
if (isset($this->ticks[$name])) {
$this->ticks[$name]->setManager(null);
unset($this->ticks[$name]);
}
} | php | public function removeTick($name)
{
if (isset($this->ticks[$name])) {
$this->ticks[$name]->setManager(null);
unset($this->ticks[$name]);
}
} | [
"public",
"function",
"removeTick",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ticks",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"ticks",
"[",
"$",
"name",
"]",
"->",
"setManager",
"(",
"null",
")",
... | Remove tick by name from loop.
@param string $name
@return void | [
"Remove",
"tick",
"by",
"name",
"from",
"loop",
"."
] | 53032b3e9f789b729744922c75e09b2a33845f90 | https://github.com/gearphp/loop/blob/53032b3e9f789b729744922c75e09b2a33845f90/Manager/WhileManager.php#L85-L91 | train |
gearphp/loop | Manager/WhileManager.php | WhileManager.start | public function start()
{
if ($this->isStart) {
return;
}
$this->startAt = time();
$this->stopAt = null;
$this->isStart = true;
if (extension_loaded('xdebug')) {
xdebug_disable();
}
foreach ($this->onStart as $callable) {
call_user_func_array($callable, []);
}
while ($this->isStart) {
$this->tick();
}
$this->stopAt = time();
foreach ($this->onStop as $callable) {
call_user_func_array($callable, []);
}
if (extension_loaded('xdebug')) {
xdebug_enable();
}
} | php | public function start()
{
if ($this->isStart) {
return;
}
$this->startAt = time();
$this->stopAt = null;
$this->isStart = true;
if (extension_loaded('xdebug')) {
xdebug_disable();
}
foreach ($this->onStart as $callable) {
call_user_func_array($callable, []);
}
while ($this->isStart) {
$this->tick();
}
$this->stopAt = time();
foreach ($this->onStop as $callable) {
call_user_func_array($callable, []);
}
if (extension_loaded('xdebug')) {
xdebug_enable();
}
} | [
"public",
"function",
"start",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isStart",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"startAt",
"=",
"time",
"(",
")",
";",
"$",
"this",
"->",
"stopAt",
"=",
"null",
";",
"$",
"this",
"->",
"is... | Start loop.
@return void | [
"Start",
"loop",
"."
] | 53032b3e9f789b729744922c75e09b2a33845f90 | https://github.com/gearphp/loop/blob/53032b3e9f789b729744922c75e09b2a33845f90/Manager/WhileManager.php#L98-L129 | train |
gearphp/loop | Manager/WhileManager.php | WhileManager.tick | protected function tick()
{
$time = microtime(true);
foreach ($this->ticks as $name => $value) {
/* @var TickInterface $tick */
$tick = $value['tick'];
$interval = $tick->getInterval() >= $this->interval ? $tick->getInterval() : $this->interval;
$diff = ($time - $value['time']) * 1000;
if ($diff >= $interval) {
try {
$tick->tick();
} catch (\Exception $e) {
$this->catchTickException($tick, $e);
}
$this->ticks[$name]['time'] = $time;
}
}
usleep($this->interval * 1e3);
} | php | protected function tick()
{
$time = microtime(true);
foreach ($this->ticks as $name => $value) {
/* @var TickInterface $tick */
$tick = $value['tick'];
$interval = $tick->getInterval() >= $this->interval ? $tick->getInterval() : $this->interval;
$diff = ($time - $value['time']) * 1000;
if ($diff >= $interval) {
try {
$tick->tick();
} catch (\Exception $e) {
$this->catchTickException($tick, $e);
}
$this->ticks[$name]['time'] = $time;
}
}
usleep($this->interval * 1e3);
} | [
"protected",
"function",
"tick",
"(",
")",
"{",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"ticks",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"/* @var TickInterface $tick */",
"$",
"tick",
"=",
"$",
... | Loop tick. | [
"Loop",
"tick",
"."
] | 53032b3e9f789b729744922c75e09b2a33845f90 | https://github.com/gearphp/loop/blob/53032b3e9f789b729744922c75e09b2a33845f90/Manager/WhileManager.php#L134-L158 | train |
zugoripls/laravel-framework | src/Illuminate/Auth/Passwords/PasswordBroker.php | PasswordBroker.emailResetLink | public function emailResetLink(CanResetPasswordContract $user, $token, Closure $callback = null)
{
// We will use the reminder view that was given to the broker to display the
// password reminder e-mail. We'll pass a "token" variable into the views
// so that it may be displayed for an user to click for password reset.
$view = $this->emailView;
return $this->mailer->send($view, compact('token', 'user'), function($m) use ($user, $token, $callback)
{
$m->to($user->getEmailForPasswordReset());
if ( ! is_null($callback))
{
call_user_func($callback, $m, $user, $token);
}
});
} | php | public function emailResetLink(CanResetPasswordContract $user, $token, Closure $callback = null)
{
// We will use the reminder view that was given to the broker to display the
// password reminder e-mail. We'll pass a "token" variable into the views
// so that it may be displayed for an user to click for password reset.
$view = $this->emailView;
return $this->mailer->send($view, compact('token', 'user'), function($m) use ($user, $token, $callback)
{
$m->to($user->getEmailForPasswordReset());
if ( ! is_null($callback))
{
call_user_func($callback, $m, $user, $token);
}
});
} | [
"public",
"function",
"emailResetLink",
"(",
"CanResetPasswordContract",
"$",
"user",
",",
"$",
"token",
",",
"Closure",
"$",
"callback",
"=",
"null",
")",
"{",
"// We will use the reminder view that was given to the broker to display the",
"// password reminder e-mail. We'll p... | Send the password reset link via e-mail.
@param \Illuminate\Contracts\Auth\CanResetPassword $user
@param string $token
@param \Closure|null $callback
@return int | [
"Send",
"the",
"password",
"reset",
"link",
"via",
"e",
"-",
"mail",
"."
] | 90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655 | https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Auth/Passwords/PasswordBroker.php#L104-L120 | train |
open-orchestra/open-orchestra-elastica-admin-bundle | ElasticaAdmin/SchemaInitializer/Strategies/ContentTypeSchemaInitializer.php | ContentTypeSchemaInitializer.initialize | public function initialize()
{
$contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion();
foreach ($contentTypes as $contentType) {
$this->schemaGenerator->createMapping($contentType);
}
} | php | public function initialize()
{
$contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion();
foreach ($contentTypes as $contentType) {
$this->schemaGenerator->createMapping($contentType);
}
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"$",
"contentTypes",
"=",
"$",
"this",
"->",
"contentTypeRepository",
"->",
"findAllNotDeletedInLastVersion",
"(",
")",
";",
"foreach",
"(",
"$",
"contentTypes",
"as",
"$",
"contentType",
")",
"{",
"$",
"this"... | Initialize content type schema | [
"Initialize",
"content",
"type",
"schema"
] | 6d14beec9d78410e62549d6645d213548e4001a3 | https://github.com/open-orchestra/open-orchestra-elastica-admin-bundle/blob/6d14beec9d78410e62549d6645d213548e4001a3/ElasticaAdmin/SchemaInitializer/Strategies/ContentTypeSchemaInitializer.php#L30-L37 | train |
xqddd/Presentable | src/PresentableTrait.php | PresentableTrait.toOutput | public function toOutput($structure, $assoc = true)
{
switch ($structure) {
case 'string':
$output = $this->toString();
break;
case 'array':
default:
$output = $this->toArray($assoc);
break;
}
return $output;
} | php | public function toOutput($structure, $assoc = true)
{
switch ($structure) {
case 'string':
$output = $this->toString();
break;
case 'array':
default:
$output = $this->toArray($assoc);
break;
}
return $output;
} | [
"public",
"function",
"toOutput",
"(",
"$",
"structure",
",",
"$",
"assoc",
"=",
"true",
")",
"{",
"switch",
"(",
"$",
"structure",
")",
"{",
"case",
"'string'",
":",
"$",
"output",
"=",
"$",
"this",
"->",
"toString",
"(",
")",
";",
"break",
";",
"... | Get the public representation of the object
@param string $structure
@param bool $assoc
@return array|string | [
"Get",
"the",
"public",
"representation",
"of",
"the",
"object"
] | 995e55d2aa81467382272eddbf5df6a589439d7b | https://github.com/xqddd/Presentable/blob/995e55d2aa81467382272eddbf5df6a589439d7b/src/PresentableTrait.php#L35-L47 | train |
xqddd/Presentable | src/PresentableTrait.php | PresentableTrait.toJson | public function toJson($options = 0, $structure, $assoc = true)
{
return json_encode(
$this->toOutput($structure, $assoc),
$options
);
} | php | public function toJson($options = 0, $structure, $assoc = true)
{
return json_encode(
$this->toOutput($structure, $assoc),
$options
);
} | [
"public",
"function",
"toJson",
"(",
"$",
"options",
"=",
"0",
",",
"$",
"structure",
",",
"$",
"assoc",
"=",
"true",
")",
"{",
"return",
"json_encode",
"(",
"$",
"this",
"->",
"toOutput",
"(",
"$",
"structure",
",",
"$",
"assoc",
")",
",",
"$",
"o... | Get the JSON representation of the object
@param int $options
@param string $structure
@param bool $assoc
@return string | [
"Get",
"the",
"JSON",
"representation",
"of",
"the",
"object"
] | 995e55d2aa81467382272eddbf5df6a589439d7b | https://github.com/xqddd/Presentable/blob/995e55d2aa81467382272eddbf5df6a589439d7b/src/PresentableTrait.php#L57-L63 | train |
emhar/SearchDoctrineBundle | Query/QueryFactory.php | QueryFactory.doLoad | protected function doLoad($itemMetaData)
{
$query = $this->newQueryInstance($itemMetaData);
$databaseMapping = $this->ormDriver->loadDatabaseMapping($itemMetaData);
$query->mapDatabase($databaseMapping, $itemMetaData->getItemClass(), $itemMetaData->getHitPositions());
return $query;
} | php | protected function doLoad($itemMetaData)
{
$query = $this->newQueryInstance($itemMetaData);
$databaseMapping = $this->ormDriver->loadDatabaseMapping($itemMetaData);
$query->mapDatabase($databaseMapping, $itemMetaData->getItemClass(), $itemMetaData->getHitPositions());
return $query;
} | [
"protected",
"function",
"doLoad",
"(",
"$",
"itemMetaData",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"newQueryInstance",
"(",
"$",
"itemMetaData",
")",
";",
"$",
"databaseMapping",
"=",
"$",
"this",
"->",
"ormDriver",
"->",
"loadDatabaseMapping",
"("... | Loads Query for itemMetaData
@param ItemMetaData $itemMetaData | [
"Loads",
"Query",
"for",
"itemMetaData"
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/QueryFactory.php#L73-L79 | train |
sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendSubscribeToNewsletterMessage | public function sendSubscribeToNewsletterMessage(Actor $user)
{
$templateName = 'CoreBundle:Email:subscription.email.html.twig';
$context = array(
'user' => $user
);
$this->sendMessage(
$templateName,
$context,
$this->twigGlobal->getParameter('admin_email'),
$user->getEmail()
);
} | php | public function sendSubscribeToNewsletterMessage(Actor $user)
{
$templateName = 'CoreBundle:Email:subscription.email.html.twig';
$context = array(
'user' => $user
);
$this->sendMessage(
$templateName,
$context,
$this->twigGlobal->getParameter('admin_email'),
$user->getEmail()
);
} | [
"public",
"function",
"sendSubscribeToNewsletterMessage",
"(",
"Actor",
"$",
"user",
")",
"{",
"$",
"templateName",
"=",
"'CoreBundle:Email:subscription.email.html.twig'",
";",
"$",
"context",
"=",
"array",
"(",
"'user'",
"=>",
"$",
"user",
")",
";",
"$",
"this",
... | Send an email to a user to confirm the subscription
@param UserInterface $user
@return void | [
"Send",
"an",
"email",
"to",
"a",
"user",
"to",
"confirm",
"the",
"subscription"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L150-L164 | train |
sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendContactMessage | public function sendContactMessage(array $params)
{
$templateName = 'CoreBundle:Email:base.email.html.twig';
$context = array(
'params' => $params
);
$this->sendMessage(
$templateName,
$context,
$this->twigGlobal->getParameter('admin_email'),
$params['email']
);
$this->sendMessage(
$templateName,
$context,
$params['email'],
$this->twigGlobal->getParameter('admin_email')
);
} | php | public function sendContactMessage(array $params)
{
$templateName = 'CoreBundle:Email:base.email.html.twig';
$context = array(
'params' => $params
);
$this->sendMessage(
$templateName,
$context,
$this->twigGlobal->getParameter('admin_email'),
$params['email']
);
$this->sendMessage(
$templateName,
$context,
$params['email'],
$this->twigGlobal->getParameter('admin_email')
);
} | [
"public",
"function",
"sendContactMessage",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"templateName",
"=",
"'CoreBundle:Email:base.email.html.twig'",
";",
"$",
"context",
"=",
"array",
"(",
"'params'",
"=>",
"$",
"params",
")",
";",
"$",
"this",
"->",
"sendM... | Send an email to a user and admin
@param array $params (name, email, message)
@return void | [
"Send",
"an",
"email",
"to",
"a",
"user",
"and",
"admin"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L242-L264 | train |
sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendNotificationEmail | public function sendNotificationEmail($mail, $from=null)
{
$templateName = 'CoreBundle:Email:notification.email.html.twig';
$context = array(
'mail' => $mail
);
if(is_null($from)){
$this->sendMessage(
$templateName,
$context,
$mail->getSender(),
$mail->getRecipient(),
$mail->getAttachment()
);
}else{
$this->sendMessage(
$templateName,
$context,
$from,
$mail->getRecipient(),
$mail->getAttachment()
);
}
} | php | public function sendNotificationEmail($mail, $from=null)
{
$templateName = 'CoreBundle:Email:notification.email.html.twig';
$context = array(
'mail' => $mail
);
if(is_null($from)){
$this->sendMessage(
$templateName,
$context,
$mail->getSender(),
$mail->getRecipient(),
$mail->getAttachment()
);
}else{
$this->sendMessage(
$templateName,
$context,
$from,
$mail->getRecipient(),
$mail->getAttachment()
);
}
} | [
"public",
"function",
"sendNotificationEmail",
"(",
"$",
"mail",
",",
"$",
"from",
"=",
"null",
")",
"{",
"$",
"templateName",
"=",
"'CoreBundle:Email:notification.email.html.twig'",
";",
"$",
"context",
"=",
"array",
"(",
"'mail'",
"=>",
"$",
"mail",
")",
";"... | Send an email from notification
@param MailLog $mail
@return void | [
"Send",
"an",
"email",
"from",
"notification"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L273-L299 | train |
sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendAdvertPurchaseConfirmationMessage | public function sendAdvertPurchaseConfirmationMessage(Invoice $invoice, $amount)
{
//send email to optic to confirm plan purchase
//check empty bank number account
$templateName = 'PaymentBundle:Email:advert.confirmation.html.twig';
$advert = $invoice->getTransaction()->getItems()->first()->getAdvert();
if($invoice->getTransaction()->getActor() instanceof Actor){
$user = $invoice->getTransaction()->getActor();
}elseif($invoice->getTransaction()->getOptic() instanceof Optic){
$user = $invoice->getTransaction()->getOptic();
}
$toEmail = $user->getEmail();
$token = null;
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'advert' => $advert,
'user' => $user,
'token' => $token
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
} | php | public function sendAdvertPurchaseConfirmationMessage(Invoice $invoice, $amount)
{
//send email to optic to confirm plan purchase
//check empty bank number account
$templateName = 'PaymentBundle:Email:advert.confirmation.html.twig';
$advert = $invoice->getTransaction()->getItems()->first()->getAdvert();
if($invoice->getTransaction()->getActor() instanceof Actor){
$user = $invoice->getTransaction()->getActor();
}elseif($invoice->getTransaction()->getOptic() instanceof Optic){
$user = $invoice->getTransaction()->getOptic();
}
$toEmail = $user->getEmail();
$token = null;
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'advert' => $advert,
'user' => $user,
'token' => $token
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
} | [
"public",
"function",
"sendAdvertPurchaseConfirmationMessage",
"(",
"Invoice",
"$",
"invoice",
",",
"$",
"amount",
")",
"{",
"//send email to optic to confirm plan purchase",
"//check empty bank number account",
"$",
"templateName",
"=",
"'PaymentBundle:Email:advert.confirmation.ht... | Send plan purchase confirmation
@param Invoice $invoice
@param float $amount | [
"Send",
"plan",
"purchase",
"confirmation"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L400-L425 | train |
sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendPurchaseConfirmationMessage | public function sendPurchaseConfirmationMessage(Invoice $invoice, $amount)
{
$templateName = 'PaymentBundle:Email:sale.confirmation.html.twig';
$toEmail = $invoice->getTransaction()->getActor()->getEmail();
$orderUrl = $this->router->generate('payment_checkout_showinvoice', array('number' => $invoice->getInvoiceNumber()), UrlGeneratorInterface::ABSOLUTE_URL);
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'amount' => $amount,
'payment_type' => $invoice->getTransaction()->getPaymentMethod()->getName(),
'order_url' => $orderUrl,
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
//send email to optic to confirm purchase
//check empty bank number account
$templateName = 'PaymentBundle:Email:sale.confirmation.actor.html.twig';
$productItems = $invoice->getTransaction()->getItems();
$actor = $productItems->first()->getProduct()->getActor();
if($actor instanceof Actor) {
$toEmail = $actor->getEmail();
$token = null;
if($actor->getBankAccountNumber() == ''){
$token = sha1(uniqid());
$date = new \DateTime();
$actor->setBankAccountToken($token);
$actor->setBankAccountTime($date->getTimestamp());
$this->manager->persist($actor);
$this->manager->flush();
}
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'products' => $productItems,
'token' => $token,
'actor' => $actor
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
}
} | php | public function sendPurchaseConfirmationMessage(Invoice $invoice, $amount)
{
$templateName = 'PaymentBundle:Email:sale.confirmation.html.twig';
$toEmail = $invoice->getTransaction()->getActor()->getEmail();
$orderUrl = $this->router->generate('payment_checkout_showinvoice', array('number' => $invoice->getInvoiceNumber()), UrlGeneratorInterface::ABSOLUTE_URL);
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'amount' => $amount,
'payment_type' => $invoice->getTransaction()->getPaymentMethod()->getName(),
'order_url' => $orderUrl,
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
//send email to optic to confirm purchase
//check empty bank number account
$templateName = 'PaymentBundle:Email:sale.confirmation.actor.html.twig';
$productItems = $invoice->getTransaction()->getItems();
$actor = $productItems->first()->getProduct()->getActor();
if($actor instanceof Actor) {
$toEmail = $actor->getEmail();
$token = null;
if($actor->getBankAccountNumber() == ''){
$token = sha1(uniqid());
$date = new \DateTime();
$actor->setBankAccountToken($token);
$actor->setBankAccountTime($date->getTimestamp());
$this->manager->persist($actor);
$this->manager->flush();
}
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'products' => $productItems,
'token' => $token,
'actor' => $actor
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
}
} | [
"public",
"function",
"sendPurchaseConfirmationMessage",
"(",
"Invoice",
"$",
"invoice",
",",
"$",
"amount",
")",
"{",
"$",
"templateName",
"=",
"'PaymentBundle:Email:sale.confirmation.html.twig'",
";",
"$",
"toEmail",
"=",
"$",
"invoice",
"->",
"getTransaction",
"(",... | Send invest confirmation
@param Invoice $invoice
@param float $amount | [
"Send",
"invest",
"confirmation"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L462-L505 | train |
sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendTrackingCodeEmailMessage | public function sendTrackingCodeEmailMessage(Transaction $transaction)
{
$templateName = 'PaymentBundle:Email:trackingCode.html.twig';
$toEmail = $transaction->getActor()->getEmail();
$context = array(
'order_number' => $transaction->getTransactionKey(),
'tracking_code' => $transaction->getDelivery()->getTrackingCode(),
'carrier_name' => 'Transporte'//$transaction->getDelivery()->getCarrier()->getName()
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email'), $toEmail);
} | php | public function sendTrackingCodeEmailMessage(Transaction $transaction)
{
$templateName = 'PaymentBundle:Email:trackingCode.html.twig';
$toEmail = $transaction->getActor()->getEmail();
$context = array(
'order_number' => $transaction->getTransactionKey(),
'tracking_code' => $transaction->getDelivery()->getTrackingCode(),
'carrier_name' => 'Transporte'//$transaction->getDelivery()->getCarrier()->getName()
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email'), $toEmail);
} | [
"public",
"function",
"sendTrackingCodeEmailMessage",
"(",
"Transaction",
"$",
"transaction",
")",
"{",
"$",
"templateName",
"=",
"'PaymentBundle:Email:trackingCode.html.twig'",
";",
"$",
"toEmail",
"=",
"$",
"transaction",
"->",
"getActor",
"(",
")",
"->",
"getEmail"... | Send the tracking code
@param Transaction $transaction | [
"Send",
"the",
"tracking",
"code"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L512-L524 | train |
PowerOnSystem/WebFramework | src/Exceptions/PowerOnException.php | PowerOnException.log | public function log( \Monolog\Logger $logger) {
$reflection = new \ReflectionClass($this);
$logger->error($this->getMessage(), [
'type' => $reflection->getShortName(),
'code' => $this->getCode(),
'line' => $this->getLine(),
'file' => $this->getFile(),
'trace' => $this->getTrace(),
'context' => $this->getContext()
]);
} | php | public function log( \Monolog\Logger $logger) {
$reflection = new \ReflectionClass($this);
$logger->error($this->getMessage(), [
'type' => $reflection->getShortName(),
'code' => $this->getCode(),
'line' => $this->getLine(),
'file' => $this->getFile(),
'trace' => $this->getTrace(),
'context' => $this->getContext()
]);
} | [
"public",
"function",
"log",
"(",
"\\",
"Monolog",
"\\",
"Logger",
"$",
"logger",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"$",
"logger",
"->",
"error",
"(",
"$",
"this",
"->",
"getMessage",
"(",
"... | Guarda un log del error
@param \Monolog\Logger $logger | [
"Guarda",
"un",
"log",
"del",
"error"
] | 3b885a390adc42d6ad93d7900d33d97c66a6c2a9 | https://github.com/PowerOnSystem/WebFramework/blob/3b885a390adc42d6ad93d7900d33d97c66a6c2a9/src/Exceptions/PowerOnException.php#L90-L100 | train |
b01/slib | src/SlibException.php | SlibException.getMessageByCode | public function getMessageByCode(& $code, array $data = null)
{
// If we do not use a reference, then that defeats the purpose of
// making the $errorMap a static property.
$map = &static::getErrorMap();
// When you can't find the code, use a default one.
if (!\array_key_exists($code, $map)) {
$code = static::UNKNOWN;
}
if (\is_array($data) && count($data) > 0) {
return \vsprintf($map[$code], $data);
}
return $map[$code];
} | php | public function getMessageByCode(& $code, array $data = null)
{
// If we do not use a reference, then that defeats the purpose of
// making the $errorMap a static property.
$map = &static::getErrorMap();
// When you can't find the code, use a default one.
if (!\array_key_exists($code, $map)) {
$code = static::UNKNOWN;
}
if (\is_array($data) && count($data) > 0) {
return \vsprintf($map[$code], $data);
}
return $map[$code];
} | [
"public",
"function",
"getMessageByCode",
"(",
"&",
"$",
"code",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"// If we do not use a reference, then that defeats the purpose of",
"// making the $errorMap a static property.",
"$",
"map",
"=",
"&",
"static",
"::",
"g... | Convert error code to human readable text.
@param mixed & $code
@param array $data
@return string | [
"Convert",
"error",
"code",
"to",
"human",
"readable",
"text",
"."
] | 56149adcd85f1493c11651a50dda4612a3705cbb | https://github.com/b01/slib/blob/56149adcd85f1493c11651a50dda4612a3705cbb/src/SlibException.php#L43-L59 | train |
phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php | ElementtypeStructure.getParentDsId | public function getParentDsId($dsId)
{
if (!array_key_exists($dsId, $this->parentMap)) {
throw new InvalidArgumentException('Unknown ds_id ', $dsId);
}
return $this->parentMap[$dsId];
} | php | public function getParentDsId($dsId)
{
if (!array_key_exists($dsId, $this->parentMap)) {
throw new InvalidArgumentException('Unknown ds_id ', $dsId);
}
return $this->parentMap[$dsId];
} | [
"public",
"function",
"getParentDsId",
"(",
"$",
"dsId",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"dsId",
",",
"$",
"this",
"->",
"parentMap",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Unknown ds_id '",
",",
"$",
"dsI... | Get parent node by node id.
@param string $dsId
@return string
@throws InvalidArgumentException | [
"Get",
"parent",
"node",
"by",
"node",
"id",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L107-L114 | train |
phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php | ElementtypeStructure.getParentNode | public function getParentNode($dsId)
{
$parentDsId = $this->getParentDsId($dsId);
if (null === $parentDsId) {
return null;
}
return $this->dsIdMap[$parentDsId];
} | php | public function getParentNode($dsId)
{
$parentDsId = $this->getParentDsId($dsId);
if (null === $parentDsId) {
return null;
}
return $this->dsIdMap[$parentDsId];
} | [
"public",
"function",
"getParentNode",
"(",
"$",
"dsId",
")",
"{",
"$",
"parentDsId",
"=",
"$",
"this",
"->",
"getParentDsId",
"(",
"$",
"dsId",
")",
";",
"if",
"(",
"null",
"===",
"$",
"parentDsId",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$... | Get parent node by node ds_id.
@param string $dsId
@return ElementtypeStructureNode | [
"Get",
"parent",
"node",
"by",
"node",
"ds_id",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L123-L132 | train |
phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php | ElementtypeStructure.getChildrenDsIds | public function getChildrenDsIds($dsId, $level = 1)
{
$childrenDsIds = (array_key_exists($dsId, $this->childrenMap))
? $this->childrenMap[$dsId]
: [];
if (($level > 1) && count($childrenDsIds)) {
$subChildDsIds = [$childrenDsIds];
foreach ($childrenDsIds as $childDsId) {
$subChildDsIds[] = $this->getChildrenDsIds($childDsId, $level - 1);
}
$childrenDsIds = call_user_func_array('array_merge', $subChildDsIds);
}
return $childrenDsIds;
} | php | public function getChildrenDsIds($dsId, $level = 1)
{
$childrenDsIds = (array_key_exists($dsId, $this->childrenMap))
? $this->childrenMap[$dsId]
: [];
if (($level > 1) && count($childrenDsIds)) {
$subChildDsIds = [$childrenDsIds];
foreach ($childrenDsIds as $childDsId) {
$subChildDsIds[] = $this->getChildrenDsIds($childDsId, $level - 1);
}
$childrenDsIds = call_user_func_array('array_merge', $subChildDsIds);
}
return $childrenDsIds;
} | [
"public",
"function",
"getChildrenDsIds",
"(",
"$",
"dsId",
",",
"$",
"level",
"=",
"1",
")",
"{",
"$",
"childrenDsIds",
"=",
"(",
"array_key_exists",
"(",
"$",
"dsId",
",",
"$",
"this",
"->",
"childrenMap",
")",
")",
"?",
"$",
"this",
"->",
"childrenM... | Get ds_id of children.
@param string $dsId ds_id of node to fetch children
@param int $level (Optional) recursion depth
@return array | [
"Get",
"ds_id",
"of",
"children",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L192-L209 | train |
phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php | ElementtypeStructure.getChildNodes | public function getChildNodes($dsId, $level = 1)
{
$children = [];
$childrenDsIds = $this->getChildrenDsIds($dsId, $level);
foreach ($childrenDsIds as $childDsId) {
$children[] = $this->getNode($childDsId);
}
return $children;
} | php | public function getChildNodes($dsId, $level = 1)
{
$children = [];
$childrenDsIds = $this->getChildrenDsIds($dsId, $level);
foreach ($childrenDsIds as $childDsId) {
$children[] = $this->getNode($childDsId);
}
return $children;
} | [
"public",
"function",
"getChildNodes",
"(",
"$",
"dsId",
",",
"$",
"level",
"=",
"1",
")",
"{",
"$",
"children",
"=",
"[",
"]",
";",
"$",
"childrenDsIds",
"=",
"$",
"this",
"->",
"getChildrenDsIds",
"(",
"$",
"dsId",
",",
"$",
"level",
")",
";",
"f... | Get children nodes.
@param string $dsId ds_id of node to fetch children
@param int $level (Optional) recursion depth
@return ElementtypeStructureNode[] | [
"Get",
"children",
"nodes",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L233-L243 | train |
phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php | ElementtypeStructure.hasChildNodes | public function hasChildNodes($dsId = null)
{
if (!$dsId) {
// use root as default
$dsId = $this->rootDsId;
}
$childrenDsIds = $this->getChildrenDsIds($dsId);
$hasChildren = count($childrenDsIds) > 0;
return $hasChildren;
} | php | public function hasChildNodes($dsId = null)
{
if (!$dsId) {
// use root as default
$dsId = $this->rootDsId;
}
$childrenDsIds = $this->getChildrenDsIds($dsId);
$hasChildren = count($childrenDsIds) > 0;
return $hasChildren;
} | [
"public",
"function",
"hasChildNodes",
"(",
"$",
"dsId",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"dsId",
")",
"{",
"// use root as default",
"$",
"dsId",
"=",
"$",
"this",
"->",
"rootDsId",
";",
"}",
"$",
"childrenDsIds",
"=",
"$",
"this",
"->",
... | Has node children?
@param string $dsId (Optional) ds_id of node to check childrens
@return bool | [
"Has",
"node",
"children?"
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L266-L277 | train |
phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php | ElementtypeStructure.getDsIdsByFieldType | public function getDsIdsByFieldType($fieldType)
{
$result = [];
foreach ($this->dsIdMap as $dsId => $node) {
/* @var $node ElementtypeStructureNode */
if ($fieldType === $node->getType()) {
$result[] = $dsId;
}
}
return $result;
} | php | public function getDsIdsByFieldType($fieldType)
{
$result = [];
foreach ($this->dsIdMap as $dsId => $node) {
/* @var $node ElementtypeStructureNode */
if ($fieldType === $node->getType()) {
$result[] = $dsId;
}
}
return $result;
} | [
"public",
"function",
"getDsIdsByFieldType",
"(",
"$",
"fieldType",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"dsIdMap",
"as",
"$",
"dsId",
"=>",
"$",
"node",
")",
"{",
"/* @var $node ElementtypeStructureNode */",
"if",
... | Get the ds_ids of all fields in this structure tree of a specific type.
@param string $fieldType
@return array | [
"Get",
"the",
"ds_ids",
"of",
"all",
"fields",
"in",
"this",
"structure",
"tree",
"of",
"a",
"specific",
"type",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L319-L330 | train |
phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php | ElementtypeStructure.getNamesByFieldType | public function getNamesByFieldType($fieldType)
{
$result = [];
foreach ($this->dsIdMap as $node) {
/* @var $node ElementtypeStructureNode */
if ($fieldType === $node->getType()) {
$result[] = $node->getName();
}
}
return $result;
} | php | public function getNamesByFieldType($fieldType)
{
$result = [];
foreach ($this->dsIdMap as $node) {
/* @var $node ElementtypeStructureNode */
if ($fieldType === $node->getType()) {
$result[] = $node->getName();
}
}
return $result;
} | [
"public",
"function",
"getNamesByFieldType",
"(",
"$",
"fieldType",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"dsIdMap",
"as",
"$",
"node",
")",
"{",
"/* @var $node ElementtypeStructureNode */",
"if",
"(",
"$",
"fieldTyp... | Get the working titles of all fields in this structure tree of a specific type.
@param string $fieldType
@return array | [
"Get",
"the",
"working",
"titles",
"of",
"all",
"fields",
"in",
"this",
"structure",
"tree",
"of",
"a",
"specific",
"type",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Model/ElementtypeStructure.php#L339-L350 | train |
sebardo/ecommerce | EcommerceBundle/Controller/PaymentServiceProviderController.php | PaymentServiceProviderController.indexAction | public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$paymentServiceProviders = $em->getRepository('EcommerceBundle:PaymentServiceProvider')->findAll();
return array(
'paymentServiceProviders' => $paymentServiceProviders,
);
} | php | public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$paymentServiceProviders = $em->getRepository('EcommerceBundle:PaymentServiceProvider')->findAll();
return array(
'paymentServiceProviders' => $paymentServiceProviders,
);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"paymentServiceProviders",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'EcommerceBundle:PaymentServiceProvi... | Lists all PaymentServiceProvider entities.
@Route("/")
@Method("GET")
@Template() | [
"Lists",
"all",
"PaymentServiceProvider",
"entities",
"."
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L27-L36 | train |
sebardo/ecommerce | EcommerceBundle/Controller/PaymentServiceProviderController.php | PaymentServiceProviderController.newAction | public function newAction(Request $request)
{
$paymentServiceProvider = new PaymentServiceProvider();
$form = $this->createForm('EcommerceBundle\Form\PaymentServiceProviderType', $paymentServiceProvider);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($paymentServiceProvider);
$em->persist($paymentServiceProvider->getPaymentMethod());
$em->flush();
return $this->redirectToRoute('ecommerce_paymentserviceprovider_show', array('id' => $paymentServiceProvider->getId()));
}
return array(
'paymentServiceProvider' => $paymentServiceProvider,
'form' => $form->createView(),
);
} | php | public function newAction(Request $request)
{
$paymentServiceProvider = new PaymentServiceProvider();
$form = $this->createForm('EcommerceBundle\Form\PaymentServiceProviderType', $paymentServiceProvider);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($paymentServiceProvider);
$em->persist($paymentServiceProvider->getPaymentMethod());
$em->flush();
return $this->redirectToRoute('ecommerce_paymentserviceprovider_show', array('id' => $paymentServiceProvider->getId()));
}
return array(
'paymentServiceProvider' => $paymentServiceProvider,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"paymentServiceProvider",
"=",
"new",
"PaymentServiceProvider",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"'EcommerceBundle\\Form\\PaymentServiceProviderTy... | Creates a new PaymentServiceProvider entity.
@Route("/new")
@Method({"GET", "POST"})
@Template() | [
"Creates",
"a",
"new",
"PaymentServiceProvider",
"entity",
"."
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L66-L86 | train |
sebardo/ecommerce | EcommerceBundle/Controller/PaymentServiceProviderController.php | PaymentServiceProviderController.showAction | public function showAction(PaymentServiceProvider $paymentServiceProvider)
{
$deleteForm = $this->createDeleteForm($paymentServiceProvider);
return array(
'entity' => $paymentServiceProvider,
'delete_form' => $deleteForm->createView(),
);
} | php | public function showAction(PaymentServiceProvider $paymentServiceProvider)
{
$deleteForm = $this->createDeleteForm($paymentServiceProvider);
return array(
'entity' => $paymentServiceProvider,
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"showAction",
"(",
"PaymentServiceProvider",
"$",
"paymentServiceProvider",
")",
"{",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"paymentServiceProvider",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
... | Finds and displays a PaymentServiceProvider entity.
@Route("/{id}")
@Method("GET")
@Template() | [
"Finds",
"and",
"displays",
"a",
"PaymentServiceProvider",
"entity",
"."
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L95-L103 | train |
sebardo/ecommerce | EcommerceBundle/Controller/PaymentServiceProviderController.php | PaymentServiceProviderController.editAction | public function editAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
{
$deleteForm = $this->createDeleteForm($paymentServiceProvider);
$editForm = $this->createForm('EcommerceBundle\Form\PaymentServiceProviderType', $paymentServiceProvider);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($paymentServiceProvider);
$em->flush();
return $this->redirectToRoute('ecommerce_paymentserviceprovider_edit', array('id' => $paymentServiceProvider->getId()));
}
return array(
'entity' => $paymentServiceProvider,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function editAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
{
$deleteForm = $this->createDeleteForm($paymentServiceProvider);
$editForm = $this->createForm('EcommerceBundle\Form\PaymentServiceProviderType', $paymentServiceProvider);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($paymentServiceProvider);
$em->flush();
return $this->redirectToRoute('ecommerce_paymentserviceprovider_edit', array('id' => $paymentServiceProvider->getId()));
}
return array(
'entity' => $paymentServiceProvider,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"PaymentServiceProvider",
"$",
"paymentServiceProvider",
")",
"{",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"paymentServiceProvider",
")",
";",
"$",
"editForm"... | Displays a form to edit an existing PaymentServiceProvider entity.
@Route("/{id}/edit")
@Method({"GET", "POST"})
@Template() | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"PaymentServiceProvider",
"entity",
"."
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L112-L131 | train |
sebardo/ecommerce | EcommerceBundle/Controller/PaymentServiceProviderController.php | PaymentServiceProviderController.deleteAction | public function deleteAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
{
$form = $this->createDeleteForm($paymentServiceProvider);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($paymentServiceProvider);
$em->flush();
}
return $this->redirectToRoute('ecommerce_paymentserviceprovider_index');
} | php | public function deleteAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
{
$form = $this->createDeleteForm($paymentServiceProvider);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($paymentServiceProvider);
$em->flush();
}
return $this->redirectToRoute('ecommerce_paymentserviceprovider_index');
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"PaymentServiceProvider",
"$",
"paymentServiceProvider",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"paymentServiceProvider",
")",
";",
"$",
"form",
"->"... | Deletes a PaymentServiceProvider entity.
@Route("/{id}")
@Method("DELETE")
@Template() | [
"Deletes",
"a",
"PaymentServiceProvider",
"entity",
"."
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L140-L152 | train |
sebardo/ecommerce | EcommerceBundle/Controller/PaymentServiceProviderController.php | PaymentServiceProviderController.createDeleteForm | private function createDeleteForm(PaymentServiceProvider $paymentServiceProvider)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('ecommerce_paymentserviceprovider_delete', array('id' => $paymentServiceProvider->getId())))
->setMethod('DELETE')
->getForm()
;
} | php | private function createDeleteForm(PaymentServiceProvider $paymentServiceProvider)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('ecommerce_paymentserviceprovider_delete', array('id' => $paymentServiceProvider->getId())))
->setMethod('DELETE')
->getForm()
;
} | [
"private",
"function",
"createDeleteForm",
"(",
"PaymentServiceProvider",
"$",
"paymentServiceProvider",
")",
"{",
"return",
"$",
"this",
"->",
"createFormBuilder",
"(",
")",
"->",
"setAction",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'ecommerce_paymentserviceprov... | Creates a form to delete a PaymentServiceProvider entity.
@param PaymentServiceProvider $paymentServiceProvider The PaymentServiceProvider entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"delete",
"a",
"PaymentServiceProvider",
"entity",
"."
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/PaymentServiceProviderController.php#L161-L168 | train |
jmpantoja/planb-utils | src/Beautifier/Beautifier.php | Beautifier.parse | public function parse(string $template, array $values, ?Enviroment $enviroment = null): string
{
$parser = ParserFactory::factory($enviroment);
return $parser->parse($template, $values);
} | php | public function parse(string $template, array $values, ?Enviroment $enviroment = null): string
{
$parser = ParserFactory::factory($enviroment);
return $parser->parse($template, $values);
} | [
"public",
"function",
"parse",
"(",
"string",
"$",
"template",
",",
"array",
"$",
"values",
",",
"?",
"Enviroment",
"$",
"enviroment",
"=",
"null",
")",
":",
"string",
"{",
"$",
"parser",
"=",
"ParserFactory",
"::",
"factory",
"(",
"$",
"enviroment",
")"... | Parsea una plantilla
@param string $template
@param mixed[] $values
@param null|\PlanB\Beautifier\Enviroment $enviroment
@return string | [
"Parsea",
"una",
"plantilla"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Beautifier.php#L50-L55 | train |
jmpantoja/planb-utils | src/Beautifier/Beautifier.php | Beautifier.dump | public function dump($value, ?Enviroment $enviroment = null): string
{
$format = FormatFactory::factory($value);
return $this->format($format, $enviroment);
} | php | public function dump($value, ?Enviroment $enviroment = null): string
{
$format = FormatFactory::factory($value);
return $this->format($format, $enviroment);
} | [
"public",
"function",
"dump",
"(",
"$",
"value",
",",
"?",
"Enviroment",
"$",
"enviroment",
"=",
"null",
")",
":",
"string",
"{",
"$",
"format",
"=",
"FormatFactory",
"::",
"factory",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"format",
... | Devuelve la representacion de una variable
@param mixed $value
@param null|\PlanB\Beautifier\Enviroment $enviroment
@return string | [
"Devuelve",
"la",
"representacion",
"de",
"una",
"variable"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Beautifier.php#L66-L72 | train |
SymBB/symbb | src/Symbb/Core/BBCodeBundle/DependencyInjection/BBCodeManager.php | BBCodeManager.getBBCodes | public function getBBCodes($setId = 1)
{
$set = $this->getSet($setId);
$bbcodes = $set->getCodes();
return $bbcodes;
} | php | public function getBBCodes($setId = 1)
{
$set = $this->getSet($setId);
$bbcodes = $set->getCodes();
return $bbcodes;
} | [
"public",
"function",
"getBBCodes",
"(",
"$",
"setId",
"=",
"1",
")",
"{",
"$",
"set",
"=",
"$",
"this",
"->",
"getSet",
"(",
"$",
"setId",
")",
";",
"$",
"bbcodes",
"=",
"$",
"set",
"->",
"getCodes",
"(",
")",
";",
"return",
"$",
"bbcodes",
";",... | get a list of grouped BBCodes
@return \Symbb\Core\BBCodeBundle\Entity\BBCode[] | [
"get",
"a",
"list",
"of",
"grouped",
"BBCodes"
] | be25357502e6a51016fa0b128a46c2dc87fa8fb2 | https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/BBCodeBundle/DependencyInjection/BBCodeManager.php#L179-L184 | train |
jianfengye/hades | src/Hades/Dao/Connection.php | Connection.pdo | public function pdo()
{
if (!empty($this->pdo)) {
return $this->pdo;
}
$dns = "{$this->driver}:";
if (!empty($this->database)) {
$dns .= "dbname={$this->database};";
}
if (!empty($this->hostname)) {
$dns .= "host={$this->hostname};";
}
if (!empty($this->port)) {
$dns .= "port={$this->port};";
}
$this->pdo = new \PDO($dns, $this->username, $this->password);
return $this->pdo;
} | php | public function pdo()
{
if (!empty($this->pdo)) {
return $this->pdo;
}
$dns = "{$this->driver}:";
if (!empty($this->database)) {
$dns .= "dbname={$this->database};";
}
if (!empty($this->hostname)) {
$dns .= "host={$this->hostname};";
}
if (!empty($this->port)) {
$dns .= "port={$this->port};";
}
$this->pdo = new \PDO($dns, $this->username, $this->password);
return $this->pdo;
} | [
"public",
"function",
"pdo",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"pdo",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pdo",
";",
"}",
"$",
"dns",
"=",
"\"{$this->driver}:\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"t... | get raw pdo | [
"get",
"raw",
"pdo"
] | a0690d96dada070b4cf4b9ff63ab3aa024c34a67 | https://github.com/jianfengye/hades/blob/a0690d96dada070b4cf4b9ff63ab3aa024c34a67/src/Hades/Dao/Connection.php#L48-L67 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.getLastInsertID | public function getLastInsertID() {
if (count($this->rows) > 0) {
$end = end($this->rows);
if ($end->toRow() && $end->toRow()->getPrimary()) {
return (int) $end->toRow()->getPrimary();
} else if ($end->toRow() === NULL) {
return NULL;
} else {
throw new RepositoryException("Table \"" . self::TABLE . "\" does not have a primary key.");
}
} else {
return NULL;
}
} | php | public function getLastInsertID() {
if (count($this->rows) > 0) {
$end = end($this->rows);
if ($end->toRow() && $end->toRow()->getPrimary()) {
return (int) $end->toRow()->getPrimary();
} else if ($end->toRow() === NULL) {
return NULL;
} else {
throw new RepositoryException("Table \"" . self::TABLE . "\" does not have a primary key.");
}
} else {
return NULL;
}
} | [
"public",
"function",
"getLastInsertID",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"rows",
")",
">",
"0",
")",
"{",
"$",
"end",
"=",
"end",
"(",
"$",
"this",
"->",
"rows",
")",
";",
"if",
"(",
"$",
"end",
"->",
"toRow",
"(",
... | Return last insert ID
@return int|null
@throws RepositoryException | [
"Return",
"last",
"insert",
"ID"
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L120-L133 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.get | public function get($key) {
if (isset($this->rows[(int) $key])) {
return $this->rows[(int) $key];
} else {
/** @var ActiveRow|false $item */
$item = $this->buildSql()->get((int) $key);
if ($item) {
return $this->createEntity($item);
} else {
return NULL;
}
}
} | php | public function get($key) {
if (isset($this->rows[(int) $key])) {
return $this->rows[(int) $key];
} else {
/** @var ActiveRow|false $item */
$item = $this->buildSql()->get((int) $key);
if ($item) {
return $this->createEntity($item);
} else {
return NULL;
}
}
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"rows",
"[",
"(",
"int",
")",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"rows",
"[",
"(",
"int",
")",
"$",
"key",
"]",
";... | Find item by primary key
@param int $key
@return Entity|null | [
"Find",
"item",
"by",
"primary",
"key"
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L140-L152 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.limit | public function limit($limit, $offset = NULL) {
if ($this->selection)
$this->selection->limit($limit, $offset);
else
throw new RepositoryException("Before using the function limit(...) call read(...).");
return $this;
} | php | public function limit($limit, $offset = NULL) {
if ($this->selection)
$this->selection->limit($limit, $offset);
else
throw new RepositoryException("Before using the function limit(...) call read(...).");
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"limit",
",",
"$",
"offset",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"selection",
")",
"$",
"this",
"->",
"selection",
"->",
"limit",
"(",
"$",
"limit",
",",
"$",
"offset",
")",
";",
"else",
"... | Sets limit clause, more calls rewrite old values.
@param int $limit
@param int $offset
@return BaseRepository
@throws RepositoryException | [
"Sets",
"limit",
"clause",
"more",
"calls",
"rewrite",
"old",
"values",
"."
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L187-L193 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.fetchPairs | public function fetchPairs($key, $value = NULL) {
$return = array();
foreach ($this as $row) {
$return[$row->$key] = $value ? $row->$value : $row->$key;
}
return $return;
} | php | public function fetchPairs($key, $value = NULL) {
$return = array();
foreach ($this as $row) {
$return[$row->$key] = $value ? $row->$value : $row->$key;
}
return $return;
} | [
"public",
"function",
"fetchPairs",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"NULL",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"return",
"[",
"$",
"row",
"->",
"$",
"key"... | Returns all rows as associative array.
@param string
@param string $value name used for an array value or NULL for the whole row
@return array | [
"Returns",
"all",
"rows",
"as",
"associative",
"array",
"."
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L309-L315 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.fetchAll | public function fetchAll() {
if ($this->selection) {
/** @var ActiveRow $entity */
foreach ($this->selection as $entity) {
$this->createEntity($entity);
}
}
return $this->rows;
} | php | public function fetchAll() {
if ($this->selection) {
/** @var ActiveRow $entity */
foreach ($this->selection as $entity) {
$this->createEntity($entity);
}
}
return $this->rows;
} | [
"public",
"function",
"fetchAll",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"selection",
")",
"{",
"/** @var ActiveRow $entity */",
"foreach",
"(",
"$",
"this",
"->",
"selection",
"as",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"createEntity",
"(",
... | Returns all rows
@return array|NULL | [
"Returns",
"all",
"rows"
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L321-L330 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.hasNonSaveEntity | protected function hasNonSaveEntity() {
foreach($this->rows as $row) {
if ($row->toRow() === NULL) {
return TRUE;
} else {
$reflection = $row->getColumns();
$record = array();
foreach ($reflection as $property) {
$name = $property['name'];
if ($row->toRow()->$name != $row->$name) {
return TRUE;
}
}
}
}
return FALSE;
} | php | protected function hasNonSaveEntity() {
foreach($this->rows as $row) {
if ($row->toRow() === NULL) {
return TRUE;
} else {
$reflection = $row->getColumns();
$record = array();
foreach ($reflection as $property) {
$name = $property['name'];
if ($row->toRow()->$name != $row->$name) {
return TRUE;
}
}
}
}
return FALSE;
} | [
"protected",
"function",
"hasNonSaveEntity",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rows",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"->",
"toRow",
"(",
")",
"===",
"NULL",
")",
"{",
"return",
"TRUE",
";",
"}",
"else",
"{",
"... | Zjisti, zda-li repozitar obsahuje nejake entity k ulozeni
@return bool | [
"Zjisti",
"zda",
"-",
"li",
"repozitar",
"obsahuje",
"nejake",
"entity",
"k",
"ulozeni"
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L353-L369 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.read | public function read(Paginator $paginator = NULL) {
if ($this->hasNonSaveEntity() === FALSE) {
$this->rows = array();
}
$this->selection = $this->buildSql($paginator);
return $this;
} | php | public function read(Paginator $paginator = NULL) {
if ($this->hasNonSaveEntity() === FALSE) {
$this->rows = array();
}
$this->selection = $this->buildSql($paginator);
return $this;
} | [
"public",
"function",
"read",
"(",
"Paginator",
"$",
"paginator",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasNonSaveEntity",
"(",
")",
"===",
"FALSE",
")",
"{",
"$",
"this",
"->",
"rows",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",... | Create new Selection
@param Paginator $paginator
@return BaseRepository | [
"Create",
"new",
"Selection"
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L381-L387 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.push | public function push(Entity $entity) {
$entity->setEntityManager($this->entityManager);
if ($entity->toRow()) {
$this->rows[$entity->getPrimary()] = $entity;
} else {
$this->rows[] = $entity;
}
} | php | public function push(Entity $entity) {
$entity->setEntityManager($this->entityManager);
if ($entity->toRow()) {
$this->rows[$entity->getPrimary()] = $entity;
} else {
$this->rows[] = $entity;
}
} | [
"public",
"function",
"push",
"(",
"Entity",
"$",
"entity",
")",
"{",
"$",
"entity",
"->",
"setEntityManager",
"(",
"$",
"this",
"->",
"entityManager",
")",
";",
"if",
"(",
"$",
"entity",
"->",
"toRow",
"(",
")",
")",
"{",
"$",
"this",
"->",
"rows",
... | Push entity to array
@param Entity $entity | [
"Push",
"entity",
"to",
"array"
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L392-L399 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.updateActiveRow | private function updateActiveRow(Entity $entity) {
$reflection = $entity->getColumns();
$record = array();
foreach ($reflection as $property) {
$name = $property['name'];
if ($entity->toRow()->$name != $entity->$name) {
$record[$name] = $entity->$name;
}
}
if (count($record) > 0) {
$entity->toRow()->update($record);
}
$this->addLoop($entity);
} | php | private function updateActiveRow(Entity $entity) {
$reflection = $entity->getColumns();
$record = array();
foreach ($reflection as $property) {
$name = $property['name'];
if ($entity->toRow()->$name != $entity->$name) {
$record[$name] = $entity->$name;
}
}
if (count($record) > 0) {
$entity->toRow()->update($record);
}
$this->addLoop($entity);
} | [
"private",
"function",
"updateActiveRow",
"(",
"Entity",
"$",
"entity",
")",
"{",
"$",
"reflection",
"=",
"$",
"entity",
"->",
"getColumns",
"(",
")",
";",
"$",
"record",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"reflection",
"as",
"$",
"prope... | Update ActiveRow in current Entity
@param Entity $entity | [
"Update",
"ActiveRow",
"in",
"current",
"Entity"
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L495-L508 | train |
ViPErCZ/composer_slimORM | src/BaseRepository.php | BaseRepository.checkLoop | private function checkLoop(Entity $entity) {
foreach($this->protectLoop as $loop) {
if (EntityReflexion::getTable($loop) == EntityReflexion::getTable($entity) && $entity->getPrimary() == $loop->getPrimary()) {
return true;
}
}
return false;
} | php | private function checkLoop(Entity $entity) {
foreach($this->protectLoop as $loop) {
if (EntityReflexion::getTable($loop) == EntityReflexion::getTable($entity) && $entity->getPrimary() == $loop->getPrimary()) {
return true;
}
}
return false;
} | [
"private",
"function",
"checkLoop",
"(",
"Entity",
"$",
"entity",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"protectLoop",
"as",
"$",
"loop",
")",
"{",
"if",
"(",
"EntityReflexion",
"::",
"getTable",
"(",
"$",
"loop",
")",
"==",
"EntityReflexion",
"::... | Check loop protection
@param Entity $entity
@return bool | [
"Check",
"loop",
"protection"
] | 2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf | https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/BaseRepository.php#L733-L740 | train |
jivoo/core | src/Log/ErrorHandler.php | ErrorHandler.toString | public static function toString($type)
{
if (! isset(self::$strings[$type])) {
return $type;
}
return self::$strings[$type];
} | php | public static function toString($type)
{
if (! isset(self::$strings[$type])) {
return $type;
}
return self::$strings[$type];
} | [
"public",
"static",
"function",
"toString",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"strings",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"type",
";",
"}",
"return",
"self",
"::",
"$",
"strings",
"["... | Convert PHP error code to string.
@param int $type
Error code.
@return string Error code as a string. | [
"Convert",
"PHP",
"error",
"code",
"to",
"string",
"."
] | 4ef3445068f0ff9c0a6512cb741831a847013b76 | https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Log/ErrorHandler.php#L174-L180 | train |
jivoo/core | src/Log/ErrorHandler.php | ErrorHandler.handle | public function handle($type, $message, $file, $line)
{
if (self::$catch & $type > 0) {
self::$error = $message;
return;
}
switch ($type) {
case E_USER_NOTICE:
case E_USER_DEPRECATED:
case E_USER_WARNING:
case E_USER_ERROR:
$backtrace = debug_backtrace();
if (isset($backtrace[2]['file'])) {
$file = $backtrace[2]['file'];
}
if (isset($backtrace[2]['line'])) {
$line = $backtrace[2]['line'];
}
break;
}
switch ($type) {
case E_USER_ERROR:
case E_ERROR:
case E_RECOVERABLE_ERROR:
throw new ErrorException($message, 0, $type, $file, $line);
default:
$this->logger->log($this->map[$type], self::$strings[$type] . ': ' . $message, array(
'file' => $file,
'line' => $line,
'code' => $type
));
}
} | php | public function handle($type, $message, $file, $line)
{
if (self::$catch & $type > 0) {
self::$error = $message;
return;
}
switch ($type) {
case E_USER_NOTICE:
case E_USER_DEPRECATED:
case E_USER_WARNING:
case E_USER_ERROR:
$backtrace = debug_backtrace();
if (isset($backtrace[2]['file'])) {
$file = $backtrace[2]['file'];
}
if (isset($backtrace[2]['line'])) {
$line = $backtrace[2]['line'];
}
break;
}
switch ($type) {
case E_USER_ERROR:
case E_ERROR:
case E_RECOVERABLE_ERROR:
throw new ErrorException($message, 0, $type, $file, $line);
default:
$this->logger->log($this->map[$type], self::$strings[$type] . ': ' . $message, array(
'file' => $file,
'line' => $line,
'code' => $type
));
}
} | [
"public",
"function",
"handle",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"catch",
"&",
"$",
"type",
">",
"0",
")",
"{",
"self",
"::",
"$",
"error",
"=",
"$",
"message",
... | Handle error.
@param int $type
Error type.
@param string $message
Error message.
@param string $file
File.
@param int $line
Line.
@throws ErrorException To convert errors (E_USER_ERROR, E_ERROR, and
E_RECOVERABLE_ERROR) to exceptions. | [
"Handle",
"error",
"."
] | 4ef3445068f0ff9c0a6512cb741831a847013b76 | https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Log/ErrorHandler.php#L196-L228 | train |
jivoo/core | src/Log/ErrorHandler.php | ErrorHandler.detect | public static function detect($callable, $mask = -1)
{
$error = null;
set_error_handler(function ($type, $message, $file, $line) use ($error) {
$error = new ErrorException($message, 0, $type, $file, $line);
}, $mask);
$callable();
restore_error_handler();
return $error;
} | php | public static function detect($callable, $mask = -1)
{
$error = null;
set_error_handler(function ($type, $message, $file, $line) use ($error) {
$error = new ErrorException($message, 0, $type, $file, $line);
}, $mask);
$callable();
restore_error_handler();
return $error;
} | [
"public",
"static",
"function",
"detect",
"(",
"$",
"callable",
",",
"$",
"mask",
"=",
"-",
"1",
")",
"{",
"$",
"error",
"=",
"null",
";",
"set_error_handler",
"(",
"function",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"lin... | Detect one or more PHP error messages and return the last one.
@param callable $callable
Function to catch error in.
@param int $mask
Error type mask, e.g. `E_ERROR | E_WARNING` to detect
errors or warnings. Default is -1 which catches everything.
@return string|null Last error message or null if no error was triggered. | [
"Detect",
"one",
"or",
"more",
"PHP",
"error",
"messages",
"and",
"return",
"the",
"last",
"one",
"."
] | 4ef3445068f0ff9c0a6512cb741831a847013b76 | https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Log/ErrorHandler.php#L266-L275 | train |
erikkubica/netlime-theme-assets | ThemeAssets.php | ThemeAssets.registerAssets | protected function registerAssets()
{
do_action("before_theme_register_assets");
$assets = $this->getConfig("assets");
add_action("wp_enqueue_scripts", function () use ($assets) {
foreach ($assets as $id => $asset) :
$file = strpos($asset["file"], "//") === false ? get_template_directory_uri() . "/public/" . $asset["file"] : $asset["file"];
if ($asset["type"] == "js") :
wp_enqueue_script($id, $file, $asset["dependencies"], $asset["version"], $asset["footer"]);
elseif ($asset["type"] == "css") :
wp_enqueue_style($id, $file, $asset["dependencies"], $asset["version"], "all");
endif;
endforeach;
});
do_action("after_theme_register_assets");
} | php | protected function registerAssets()
{
do_action("before_theme_register_assets");
$assets = $this->getConfig("assets");
add_action("wp_enqueue_scripts", function () use ($assets) {
foreach ($assets as $id => $asset) :
$file = strpos($asset["file"], "//") === false ? get_template_directory_uri() . "/public/" . $asset["file"] : $asset["file"];
if ($asset["type"] == "js") :
wp_enqueue_script($id, $file, $asset["dependencies"], $asset["version"], $asset["footer"]);
elseif ($asset["type"] == "css") :
wp_enqueue_style($id, $file, $asset["dependencies"], $asset["version"], "all");
endif;
endforeach;
});
do_action("after_theme_register_assets");
} | [
"protected",
"function",
"registerAssets",
"(",
")",
"{",
"do_action",
"(",
"\"before_theme_register_assets\"",
")",
";",
"$",
"assets",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"\"assets\"",
")",
";",
"add_action",
"(",
"\"wp_enqueue_scripts\"",
",",
"function",... | Register css and js from config | [
"Register",
"css",
"and",
"js",
"from",
"config"
] | 71e43537cbf3fb774424933252ff17275799e86f | https://github.com/erikkubica/netlime-theme-assets/blob/71e43537cbf3fb774424933252ff17275799e86f/ThemeAssets.php#L16-L34 | train |
asbsoft/yii2-common_2_170212 | base/UniModule.php | UniModule.inform | public function inform($cmd, $params = [])
{
switch ($cmd) {
case 'label': // module's short name for menu
if (!empty($this->params['label'])) {
$label = $this->params['label'];
// try to translate label
$tcCat = TranslationsBuilder::getBaseTransCategory($this);
$tc = "{$tcCat}/module";
if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) {
$label = Yii::t($tc, $this->params['label']);
}
return $label;
} else {
//return false;
try {
$ms = Yii::$app->i18n->getMessageSource(static::$tc);
} catch(InvalidConfigException $ex) {
$ms = false;
}
return ($ms ? Yii::t(static::$tc, 'Module') : 'Module') . ' ' . $this->uniqueId;
}
break;
case 'sitetree-params-action': // return action in route format
//if (empty($params['module_full_id'])) return false;
if (!empty($this->params['sitetree-params-action'])) return $this->params['sitetree-params-action'];
break;
//todo
}
return null;
} | php | public function inform($cmd, $params = [])
{
switch ($cmd) {
case 'label': // module's short name for menu
if (!empty($this->params['label'])) {
$label = $this->params['label'];
// try to translate label
$tcCat = TranslationsBuilder::getBaseTransCategory($this);
$tc = "{$tcCat}/module";
if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) {
$label = Yii::t($tc, $this->params['label']);
}
return $label;
} else {
//return false;
try {
$ms = Yii::$app->i18n->getMessageSource(static::$tc);
} catch(InvalidConfigException $ex) {
$ms = false;
}
return ($ms ? Yii::t(static::$tc, 'Module') : 'Module') . ' ' . $this->uniqueId;
}
break;
case 'sitetree-params-action': // return action in route format
//if (empty($params['module_full_id'])) return false;
if (!empty($this->params['sitetree-params-action'])) return $this->params['sitetree-params-action'];
break;
//todo
}
return null;
} | [
"public",
"function",
"inform",
"(",
"$",
"cmd",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"switch",
"(",
"$",
"cmd",
")",
"{",
"case",
"'label'",
":",
"// module's short name for menu",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"params",
"... | Get some module info
@param string $cmd
@param array $params
@return mix|false|null | [
"Get",
"some",
"module",
"info"
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/UniModule.php#L48-L78 | train |
artkonekt/sylius-sync-bundle | Model/Remote/Image/Image.php | Image.getData | public function getData()
{
if (!$this->data && $this->getLocation()) {
$this->data = file_get_contents($this->getLocation());
}
return $this->data;
} | php | public function getData()
{
if (!$this->data && $this->getLocation()) {
$this->data = file_get_contents($this->getLocation());
}
return $this->data;
} | [
"public",
"function",
"getData",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"data",
"&&",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"getLocation",
"(",
... | Returns the image's data
@return string | [
"Returns",
"the",
"image",
"s",
"data"
] | fe2864c648971fc058994d8554549061a3a2a0c0 | https://github.com/artkonekt/sylius-sync-bundle/blob/fe2864c648971fc058994d8554549061a3a2a0c0/Model/Remote/Image/Image.php#L67-L74 | train |
comodojo/rpcserver | src/Comodojo/RpcServer/Component/Errors.php | Errors.delete | final public function delete($code) {
if ( array_key_exists($code, $this->rpc_errors) ) {
unset($this->rpc_errors[$code]);
$this->logger->debug("Deleted error $code");
return true;
} else {
$this->logger->warning("Cannot delete error $code: entry not found");
return false;
}
} | php | final public function delete($code) {
if ( array_key_exists($code, $this->rpc_errors) ) {
unset($this->rpc_errors[$code]);
$this->logger->debug("Deleted error $code");
return true;
} else {
$this->logger->warning("Cannot delete error $code: entry not found");
return false;
}
} | [
"final",
"public",
"function",
"delete",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"code",
",",
"$",
"this",
"->",
"rpc_errors",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"rpc_errors",
"[",
"$",
"code",
"]",
")",
";... | Delete an error
@param int $code
@return bool | [
"Delete",
"an",
"error"
] | 6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c | https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/Component/Errors.php#L85-L103 | train |
xjtuana-dev/cas-proxy-client-php | src/ClientV1.php | ClientV1.getLoginUrl | protected function getLoginUrl(string $redirect_url = '') {
if (empty($redirect_url)) {
$redirect_url = $this->getClientUrl();
}
return $this->getServerUrl() . self::LOGIN_PATH . '?redirect_url=' . $redirect_url;
} | php | protected function getLoginUrl(string $redirect_url = '') {
if (empty($redirect_url)) {
$redirect_url = $this->getClientUrl();
}
return $this->getServerUrl() . self::LOGIN_PATH . '?redirect_url=' . $redirect_url;
} | [
"protected",
"function",
"getLoginUrl",
"(",
"string",
"$",
"redirect_url",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"redirect_url",
")",
")",
"{",
"$",
"redirect_url",
"=",
"$",
"this",
"->",
"getClientUrl",
"(",
")",
";",
"}",
"return",
"$"... | Get the url of login
@return string | [
"Get",
"the",
"url",
"of",
"login"
] | fc0db0f3408416ad3b6f8b271bad2cfd143d648c | https://github.com/xjtuana-dev/cas-proxy-client-php/blob/fc0db0f3408416ad3b6f8b271bad2cfd143d648c/src/ClientV1.php#L27-L32 | train |
xjtuana-dev/cas-proxy-client-php | src/ClientV1.php | ClientV1.login | public function login(string $redirect_url = '') {
if ( null === $guid = $this->getGuidFromQuery() ) {
header( 'Location: ' . $this->getLoginUrl($redirect_url) );
exit();
} else {
return $this->verify($guid);
}
} | php | public function login(string $redirect_url = '') {
if ( null === $guid = $this->getGuidFromQuery() ) {
header( 'Location: ' . $this->getLoginUrl($redirect_url) );
exit();
} else {
return $this->verify($guid);
}
} | [
"public",
"function",
"login",
"(",
"string",
"$",
"redirect_url",
"=",
"''",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"guid",
"=",
"$",
"this",
"->",
"getGuidFromQuery",
"(",
")",
")",
"{",
"header",
"(",
"'Location: '",
".",
"$",
"this",
"->",
"get... | Login and return the username
@param $redirect_url string 从CAS登录后跳转的URL,用于接收guid ($redirect_url?guid=...)
@return string 返回登录用户名 | [
"Login",
"and",
"return",
"the",
"username"
] | fc0db0f3408416ad3b6f8b271bad2cfd143d648c | https://github.com/xjtuana-dev/cas-proxy-client-php/blob/fc0db0f3408416ad3b6f8b271bad2cfd143d648c/src/ClientV1.php#L110-L117 | train |
easy-system/es-system | src/Listener/ConfigureCacheListener.php | ConfigureCacheListener.configureFactory | public function configureFactory(SystemEvent $event)
{
$systemConfig = $this->getConfig();
$initialConfig = $systemConfig->getInitialConfig();
if (isset($initialConfig['cache'])) {
$cacheConfig = (array) $initialConfig['cache'];
CacheFactory::setConfig($cacheConfig);
}
} | php | public function configureFactory(SystemEvent $event)
{
$systemConfig = $this->getConfig();
$initialConfig = $systemConfig->getInitialConfig();
if (isset($initialConfig['cache'])) {
$cacheConfig = (array) $initialConfig['cache'];
CacheFactory::setConfig($cacheConfig);
}
} | [
"public",
"function",
"configureFactory",
"(",
"SystemEvent",
"$",
"event",
")",
"{",
"$",
"systemConfig",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"$",
"initialConfig",
"=",
"$",
"systemConfig",
"->",
"getInitialConfig",
"(",
")",
";",
"if",
"(... | Configures the cache factory.
@param \Es\System\SystemEvent $event The system event | [
"Configures",
"the",
"cache",
"factory",
"."
] | 750632b7a57f8c65d98c61cd0c29d2da3a9a04cc | https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/Listener/ConfigureCacheListener.php#L70-L79 | train |
easy-system/es-system | src/Listener/ConfigureCacheListener.php | ConfigureCacheListener.configureNamespace | public function configureNamespace(SystemEvent $event)
{
$systemConfig = $this->getConfig();
$cache = $this->getCache();
if ($cache->get('hash') !== $systemConfig->getInitialConfigHash()) {
$cache->clearNamespace();
$cache->set('hash', $systemConfig->getInitialConfigHash());
}
} | php | public function configureNamespace(SystemEvent $event)
{
$systemConfig = $this->getConfig();
$cache = $this->getCache();
if ($cache->get('hash') !== $systemConfig->getInitialConfigHash()) {
$cache->clearNamespace();
$cache->set('hash', $systemConfig->getInitialConfigHash());
}
} | [
"public",
"function",
"configureNamespace",
"(",
"SystemEvent",
"$",
"event",
")",
"{",
"$",
"systemConfig",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"$",
"cache",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
";",
"if",
"(",
"$",
"cache",
... | Configures the namespace registered in the cache for system.
@param \Es\System\SystemEvent $event The system event | [
"Configures",
"the",
"namespace",
"registered",
"in",
"the",
"cache",
"for",
"system",
"."
] | 750632b7a57f8c65d98c61cd0c29d2da3a9a04cc | https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/Listener/ConfigureCacheListener.php#L86-L95 | train |
webriq/core | module/Customize/src/Grid/Customize/Model/Rule/Model.php | Model.findBySelector | public function findBySelector( $selector, $media = '', $rootId = null )
{
$rootId = ( (int) $rootId ) ?: null;
$rule = $this->getMapper()
->findBySelector( $selector, $media, $rootId );
if ( empty( $rule ) )
{
$rule = $this->getMapper()
->create( array(
'media' => $media,
'selector' => $selector,
'rootParagraphId' => $rootId,
) );
}
return $rule;
} | php | public function findBySelector( $selector, $media = '', $rootId = null )
{
$rootId = ( (int) $rootId ) ?: null;
$rule = $this->getMapper()
->findBySelector( $selector, $media, $rootId );
if ( empty( $rule ) )
{
$rule = $this->getMapper()
->create( array(
'media' => $media,
'selector' => $selector,
'rootParagraphId' => $rootId,
) );
}
return $rule;
} | [
"public",
"function",
"findBySelector",
"(",
"$",
"selector",
",",
"$",
"media",
"=",
"''",
",",
"$",
"rootId",
"=",
"null",
")",
"{",
"$",
"rootId",
"=",
"(",
"(",
"int",
")",
"$",
"rootId",
")",
"?",
":",
"null",
";",
"$",
"rule",
"=",
"$",
"... | Get rule by selector & media
@param string $selector
@param string $media [optional]
@param null|int $rootId [optional]
@return \Customize\Model\Rule\Structure | [
"Get",
"rule",
"by",
"selector",
"&",
"media"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Model.php#L60-L77 | train |
veonik/VeonikBlogBundle | src/Controller/CommentController.php | CommentController.indexAction | public function indexAction($postid)
{
$post = $this->getPost($postid);
$entities = $post->getComments()->toArray();
usort($entities, function (Comment $a, Comment $b) {
return $a->getDateCreated() < $b->getDateCreated();
});
return array(
'post' => $post,
'entities' => $entities,
);
} | php | public function indexAction($postid)
{
$post = $this->getPost($postid);
$entities = $post->getComments()->toArray();
usort($entities, function (Comment $a, Comment $b) {
return $a->getDateCreated() < $b->getDateCreated();
});
return array(
'post' => $post,
'entities' => $entities,
);
} | [
"public",
"function",
"indexAction",
"(",
"$",
"postid",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getPost",
"(",
"$",
"postid",
")",
";",
"$",
"entities",
"=",
"$",
"post",
"->",
"getComments",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"usor... | Lists all of a post's comments.
@Route("s", name="post_comments")
@Template() | [
"Lists",
"all",
"of",
"a",
"post",
"s",
"comments",
"."
] | 52cca6b37feadd77fa564600b4db0e8e196099dd | https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/CommentController.php#L35-L48 | train |
veonik/VeonikBlogBundle | src/Controller/CommentController.php | CommentController.newAction | public function newAction($postid)
{
$post = $this->getPost($postid);
$entity = new Comment();
$form = $this->createForm(new CommentType(), $entity);
return array(
'entity' => $entity,
'post' => $post,
'form' => $form->createView(),
);
} | php | public function newAction($postid)
{
$post = $this->getPost($postid);
$entity = new Comment();
$form = $this->createForm(new CommentType(), $entity);
return array(
'entity' => $entity,
'post' => $post,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
"$",
"postid",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getPost",
"(",
"$",
"postid",
")",
";",
"$",
"entity",
"=",
"new",
"Comment",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
... | Displays a form to create a new Comment entity.
@Route("/new", name="post_comment_new")
@Secure("ROLE_COMMENT_WRITE")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Comment",
"entity",
"."
] | 52cca6b37feadd77fa564600b4db0e8e196099dd | https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/CommentController.php#L57-L69 | train |
veonik/VeonikBlogBundle | src/Controller/CommentController.php | CommentController.createAction | public function createAction(Request $request, $postid)
{
$post = $this->getPost($postid);
$entity = new Comment();
$entity->setPost($post);
$entity->setAuthor($this->getCurrentAuthor());
$form = $this->createForm(new CommentType(), $entity);
$form->bind($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->getSession()->getFlashBag()->set('success', 'The comment has been created successfully.');
return $this->redirect($this->generateUrl('page_or_post', array('slug' => $post->getSlug())));
}
return array(
'entity' => $entity,
'post' => $post,
'form' => $form->createView(),
);
} | php | public function createAction(Request $request, $postid)
{
$post = $this->getPost($postid);
$entity = new Comment();
$entity->setPost($post);
$entity->setAuthor($this->getCurrentAuthor());
$form = $this->createForm(new CommentType(), $entity);
$form->bind($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->getSession()->getFlashBag()->set('success', 'The comment has been created successfully.');
return $this->redirect($this->generateUrl('page_or_post', array('slug' => $post->getSlug())));
}
return array(
'entity' => $entity,
'post' => $post,
'form' => $form->createView(),
);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
",",
"$",
"postid",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getPost",
"(",
"$",
"postid",
")",
";",
"$",
"entity",
"=",
"new",
"Comment",
"(",
")",
";",
"$",
"entity",
"-... | Creates a new Comment entity.
@Route("/create", name="post_comment_create")
@Secure("ROLE_COMMENT_WRITE")
@Method("POST")
@Template("VeonikBlogBundle:Comment:new.html.twig") | [
"Creates",
"a",
"new",
"Comment",
"entity",
"."
] | 52cca6b37feadd77fa564600b4db0e8e196099dd | https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/CommentController.php#L79-L104 | train |
bishopb/vanilla | applications/dashboard/controllers/class.searchcontroller.php | SearchController.Index | public function Index($Page = '') {
$this->AddJsFile('search.js');
$this->Title(T('Search'));
SaveToConfig('Garden.Format.EmbedSize', '160x90', FALSE);
Gdn_Theme::Section('SearchResults');
list($Offset, $Limit) = OffsetLimit($Page, C('Garden.Search.PerPage', 20));
$this->SetData('_Limit', $Limit);
$Search = $this->Form->GetFormValue('Search');
$Mode = $this->Form->GetFormValue('Mode');
if ($Mode)
$this->SearchModel->ForceSearchMode = $Mode;
try {
$ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
} catch (Gdn_UserException $Ex) {
$this->Form->AddError($Ex);
$ResultSet = array();
} catch (Exception $Ex) {
LogException($Ex);
$this->Form->AddError($Ex);
$ResultSet = array();
}
Gdn::UserModel()->JoinUsers($ResultSet, array('UserID'));
// Fix up the summaries.
$SearchTerms = explode(' ', Gdn_Format::Text($Search));
foreach ($ResultSet as &$Row) {
$Row['Summary'] = SearchExcerpt(Gdn_Format::PlainText($Row['Summary'], $Row['Format']), $SearchTerms);
$Row['Format'] = 'Html';
}
$this->SetData('SearchResults', $ResultSet, TRUE);
$this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
if($ResultSet)
$NumResults = count($ResultSet);
else
$NumResults = 0;
if ($NumResults == $Offset + $Limit)
$NumResults++;
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('MorePager', $this);
$this->Pager->MoreCode = 'More Results';
$this->Pager->LessCode = 'Previous Results';
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure(
$Offset,
$Limit,
$NumResults,
'dashboard/search/%1$s/%2$s/?Search='.Gdn_Format::Url($Search)
);
// if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
// $this->SetJson('LessRow', $this->Pager->ToString('less'));
// $this->SetJson('MoreRow', $this->Pager->ToString('more'));
// $this->View = 'results';
// }
$this->CanonicalUrl(Url('search', TRUE));
$this->Render();
} | php | public function Index($Page = '') {
$this->AddJsFile('search.js');
$this->Title(T('Search'));
SaveToConfig('Garden.Format.EmbedSize', '160x90', FALSE);
Gdn_Theme::Section('SearchResults');
list($Offset, $Limit) = OffsetLimit($Page, C('Garden.Search.PerPage', 20));
$this->SetData('_Limit', $Limit);
$Search = $this->Form->GetFormValue('Search');
$Mode = $this->Form->GetFormValue('Mode');
if ($Mode)
$this->SearchModel->ForceSearchMode = $Mode;
try {
$ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
} catch (Gdn_UserException $Ex) {
$this->Form->AddError($Ex);
$ResultSet = array();
} catch (Exception $Ex) {
LogException($Ex);
$this->Form->AddError($Ex);
$ResultSet = array();
}
Gdn::UserModel()->JoinUsers($ResultSet, array('UserID'));
// Fix up the summaries.
$SearchTerms = explode(' ', Gdn_Format::Text($Search));
foreach ($ResultSet as &$Row) {
$Row['Summary'] = SearchExcerpt(Gdn_Format::PlainText($Row['Summary'], $Row['Format']), $SearchTerms);
$Row['Format'] = 'Html';
}
$this->SetData('SearchResults', $ResultSet, TRUE);
$this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
if($ResultSet)
$NumResults = count($ResultSet);
else
$NumResults = 0;
if ($NumResults == $Offset + $Limit)
$NumResults++;
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('MorePager', $this);
$this->Pager->MoreCode = 'More Results';
$this->Pager->LessCode = 'Previous Results';
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure(
$Offset,
$Limit,
$NumResults,
'dashboard/search/%1$s/%2$s/?Search='.Gdn_Format::Url($Search)
);
// if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
// $this->SetJson('LessRow', $this->Pager->ToString('less'));
// $this->SetJson('MoreRow', $this->Pager->ToString('more'));
// $this->View = 'results';
// }
$this->CanonicalUrl(Url('search', TRUE));
$this->Render();
} | [
"public",
"function",
"Index",
"(",
"$",
"Page",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"AddJsFile",
"(",
"'search.js'",
")",
";",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Search'",
")",
")",
";",
"SaveToConfig",
"(",
"'Garden.Format.EmbedSize'",
... | Default search functionality.
@since 2.0.0
@access public
@param int $Page Page number. | [
"Default",
"search",
"functionality",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.searchcontroller.php#L76-L140 | train |
marando/phpSOFA | src/Marando/IAU/iauFalp03.php | iauFalp03.Falp03 | public static function Falp03($t) {
$a;
/* Mean anomaly of the Sun (IERS Conventions 2003). */
$a = fmod(1287104.793048 +
$t * ( 129596581.0481 +
$t * ( - 0.5532 +
$t * ( 0.000136 +
$t * ( - 0.00001149 ) ) ) ), TURNAS) * DAS2R;
return $a;
} | php | public static function Falp03($t) {
$a;
/* Mean anomaly of the Sun (IERS Conventions 2003). */
$a = fmod(1287104.793048 +
$t * ( 129596581.0481 +
$t * ( - 0.5532 +
$t * ( 0.000136 +
$t * ( - 0.00001149 ) ) ) ), TURNAS) * DAS2R;
return $a;
} | [
"public",
"static",
"function",
"Falp03",
"(",
"$",
"t",
")",
"{",
"$",
"a",
";",
"/* Mean anomaly of the Sun (IERS Conventions 2003). */",
"$",
"a",
"=",
"fmod",
"(",
"1287104.793048",
"+",
"$",
"t",
"*",
"(",
"129596581.0481",
"+",
"$",
"t",
"*",
"(",
"-... | - - - - - - - - - -
i a u F a l p 0 3
- - - - - - - - - -
Fundamental argument, IERS Conventions (2003):
mean anomaly of the Sun.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: canonical model.
Given:
t double TDB, Julian centuries since J2000.0 (Note 1)
Returned (function value):
double l', radians (Note 2)
Notes:
1) Though t is strictly TDB, it is usually more convenient to use
TT, which makes no significant difference.
2) The expression used is as adopted in IERS Conventions (2003) and
is from Simon et al. (1994).
References:
McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
IERS Technical Note No. 32, BKG (2004)
Simon, J.-L., Bretagnon, P., Chapront, J., Chapront-Touze, M.,
Francou, G., Laskar, J. 1994, Astron.Astrophys. 282, 663-683
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"F",
"a",
"l",
"p",
"0",
"3",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauFalp03.php#L48-L59 | train |
rozaverta/cmf | core/Traits/GetTrait.php | GetTrait.choice | public function choice( array $keys, $default = false )
{
foreach( $keys as $key )
{
if( $this->offsetExists($key) )
{
return $this->items[$key];
}
}
return $default;
} | php | public function choice( array $keys, $default = false )
{
foreach( $keys as $key )
{
if( $this->offsetExists($key) )
{
return $this->items[$key];
}
}
return $default;
} | [
"public",
"function",
"choice",
"(",
"array",
"$",
"keys",
",",
"$",
"default",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"key",
")",
")",
"{",
"return... | Get an item from the collection by keys.
@param array $keys
@param bool $default default value
@return mixed | [
"Get",
"an",
"item",
"from",
"the",
"collection",
"by",
"keys",
"."
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Traits/GetTrait.php#L42-L53 | train |
marando/phpSOFA | src/Marando/IAU/iauPmpx.php | iauPmpx.Pmpx | public static function Pmpx($rc, $dc, $pr, $pd, $px, $rv, $pmt, array $pob,
array &$pco) {
/* Km/s to au/year */
$VF = DAYSEC * DJM / DAU;
/* Light time for 1 au, Julian years */
$AULTY = AULT / DAYSEC / DJY;
$i;
$sr;
$cr;
$sd;
$cd;
$x;
$y;
$z;
$p = [];
$dt;
$pxr;
$w;
$pdz;
$pm = [];
/* Spherical coordinates to unit vector (and useful functions). */
$sr = sin($rc);
$cr = cos($rc);
$sd = sin($dc);
$cd = cos($dc);
$p[0] = $x = $cr * $cd;
$p[1] = $y = $sr * $cd;
$p[2] = $z = $sd;
/* Proper motion time interval (y) including Roemer effect. */
$dt = $pmt + IAU::Pdp($p, $pob) * $AULTY;
/* Space motion (radians per year). */
$pxr = $px * DAS2R;
$w = $VF * $rv * $pxr;
$pdz = $pd * $z;
$pm[0] = - $pr * $y - $pdz * $cr + $w * $x;
$pm[1] = $pr * $x - $pdz * $sr + $w * $y;
$pm[2] = $pd * $cd + $w * $z;
/* Coordinate direction of star (unit vector, BCRS). */
for ($i = 0; $i < 3; $i++) {
$p[$i] += $dt * $pm[$i] - $pxr * $pob[$i];
}
IAU::Pn($p, $w, $pco);
/* Finished. */
} | php | public static function Pmpx($rc, $dc, $pr, $pd, $px, $rv, $pmt, array $pob,
array &$pco) {
/* Km/s to au/year */
$VF = DAYSEC * DJM / DAU;
/* Light time for 1 au, Julian years */
$AULTY = AULT / DAYSEC / DJY;
$i;
$sr;
$cr;
$sd;
$cd;
$x;
$y;
$z;
$p = [];
$dt;
$pxr;
$w;
$pdz;
$pm = [];
/* Spherical coordinates to unit vector (and useful functions). */
$sr = sin($rc);
$cr = cos($rc);
$sd = sin($dc);
$cd = cos($dc);
$p[0] = $x = $cr * $cd;
$p[1] = $y = $sr * $cd;
$p[2] = $z = $sd;
/* Proper motion time interval (y) including Roemer effect. */
$dt = $pmt + IAU::Pdp($p, $pob) * $AULTY;
/* Space motion (radians per year). */
$pxr = $px * DAS2R;
$w = $VF * $rv * $pxr;
$pdz = $pd * $z;
$pm[0] = - $pr * $y - $pdz * $cr + $w * $x;
$pm[1] = $pr * $x - $pdz * $sr + $w * $y;
$pm[2] = $pd * $cd + $w * $z;
/* Coordinate direction of star (unit vector, BCRS). */
for ($i = 0; $i < 3; $i++) {
$p[$i] += $dt * $pm[$i] - $pxr * $pob[$i];
}
IAU::Pn($p, $w, $pco);
/* Finished. */
} | [
"public",
"static",
"function",
"Pmpx",
"(",
"$",
"rc",
",",
"$",
"dc",
",",
"$",
"pr",
",",
"$",
"pd",
",",
"$",
"px",
",",
"$",
"rv",
",",
"$",
"pmt",
",",
"array",
"$",
"pob",
",",
"array",
"&",
"$",
"pco",
")",
"{",
"/* Km/s to au/year */",... | - - - - - - - -
i a u P m p x
- - - - - - - -
Proper motion and parallax.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: support function.
Given:
rc,dc double ICRS RA,Dec at catalog epoch (radians)
pr double RA proper motion (radians/year; Note 1)
pd double Dec proper motion (radians/year)
px double parallax (arcsec)
rv double radial velocity (km/s, +ve if receding)
pmt double proper motion time interval (SSB, Julian years)
pob double[3] SSB to observer vector (au)
Returned:
pco double[3] coordinate direction (BCRS unit vector)
Notes:
1) The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt.
2) The proper motion time interval is for when the starlight
reaches the solar system barycenter.
3) To avoid the need for iteration, the Roemer effect (i.e. the
small annual modulation of the proper motion coming from the
changing light time) is applied approximately, using the
direction of the star at the catalog epoch.
References:
1984 Astronomical Almanac, pp B39-B41.
Urban, S. & Seidelmann, P. K. (eds), Explanatory Supplement to
the Astronomical Almanac, 3rd ed., University Science Books
(2013), Section 7.2.
Called:
iauPdp scalar product of two p-vectors
iauPn decompose p-vector into modulus and direction
This revision: 2013 October 9
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"P",
"m",
"p",
"x",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauPmpx.php#L61-L112 | train |
squire-assistant/dependency-injection | Loader/YamlFileLoader.php | YamlFileLoader.parseImports | private function parseImports(array $content, $file)
{
if (!isset($content['imports'])) {
return;
}
if (!is_array($content['imports'])) {
throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file));
}
$defaultDirectory = dirname($file);
foreach ($content['imports'] as $import) {
if (!is_array($import)) {
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
}
$this->setCurrentDir($defaultDirectory);
$this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
}
} | php | private function parseImports(array $content, $file)
{
if (!isset($content['imports'])) {
return;
}
if (!is_array($content['imports'])) {
throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file));
}
$defaultDirectory = dirname($file);
foreach ($content['imports'] as $import) {
if (!is_array($import)) {
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
}
$this->setCurrentDir($defaultDirectory);
$this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
}
} | [
"private",
"function",
"parseImports",
"(",
"array",
"$",
"content",
",",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"content",
"[",
"'imports'",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"content"... | Parses all imports.
@param array $content
@param string $file | [
"Parses",
"all",
"imports",
"."
] | c61d77bf8814369344fd71b015d7238322126041 | https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/Loader/YamlFileLoader.php#L113-L132 | train |
squire-assistant/dependency-injection | Loader/YamlFileLoader.php | YamlFileLoader.parseCallable | private function parseCallable($callable, $parameter, $id, $file)
{
if (is_string($callable)) {
if ('' !== $callable && '@' === $callable[0]) {
throw new InvalidArgumentException(sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $parameter, $id, $callable, substr($callable, 1)));
}
if (false !== strpos($callable, ':') && false === strpos($callable, '::')) {
$parts = explode(':', $callable);
return array($this->resolveServices('@'.$parts[0]), $parts[1]);
}
return $callable;
}
if (is_array($callable)) {
if (isset($callable[0]) && isset($callable[1])) {
return array($this->resolveServices($callable[0]), $callable[1]);
}
throw new InvalidArgumentException(sprintf('Parameter "%s" must contain an array with two elements for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
}
throw new InvalidArgumentException(sprintf('Parameter "%s" must be a string or an array for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
} | php | private function parseCallable($callable, $parameter, $id, $file)
{
if (is_string($callable)) {
if ('' !== $callable && '@' === $callable[0]) {
throw new InvalidArgumentException(sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $parameter, $id, $callable, substr($callable, 1)));
}
if (false !== strpos($callable, ':') && false === strpos($callable, '::')) {
$parts = explode(':', $callable);
return array($this->resolveServices('@'.$parts[0]), $parts[1]);
}
return $callable;
}
if (is_array($callable)) {
if (isset($callable[0]) && isset($callable[1])) {
return array($this->resolveServices($callable[0]), $callable[1]);
}
throw new InvalidArgumentException(sprintf('Parameter "%s" must contain an array with two elements for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
}
throw new InvalidArgumentException(sprintf('Parameter "%s" must be a string or an array for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
} | [
"private",
"function",
"parseCallable",
"(",
"$",
"callable",
",",
"$",
"parameter",
",",
"$",
"id",
",",
"$",
"file",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"callable",
")",
")",
"{",
"if",
"(",
"''",
"!==",
"$",
"callable",
"&&",
"'@'",
"===... | Parses a callable.
@param string|array $callable A callable
@param string $parameter A parameter (e.g. 'factory' or 'configurator')
@param string $id A service identifier
@param string $file A parsed file
@throws InvalidArgumentException When errors are occuried
@return string|array A parsed callable | [
"Parses",
"a",
"callable",
"."
] | c61d77bf8814369344fd71b015d7238322126041 | https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/Loader/YamlFileLoader.php#L341-L366 | train |
JumpGateio/Database | src/JumpGate/Database/Console/Commands/Conversions/Conversion.php | Conversion.clearData | protected function clearData($table, $clearLinks = false)
{
if ($this->option('clear')) {
$this->db->statement('SET FOREIGN_KEY_CHECKS=0;');
$this->db->table($table)->truncate();
if ($clearLinks) {
$this->db->table('table_links')->where('new_table', $table)->delete();
}
$this->db->statement('SET FOREIGN_KEY_CHECKS=1;');
}
} | php | protected function clearData($table, $clearLinks = false)
{
if ($this->option('clear')) {
$this->db->statement('SET FOREIGN_KEY_CHECKS=0;');
$this->db->table($table)->truncate();
if ($clearLinks) {
$this->db->table('table_links')->where('new_table', $table)->delete();
}
$this->db->statement('SET FOREIGN_KEY_CHECKS=1;');
}
} | [
"protected",
"function",
"clearData",
"(",
"$",
"table",
",",
"$",
"clearLinks",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'clear'",
")",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"statement",
"(",
"'SET FOREIGN_KEY_CHECKS=0;'"... | If set, truncate the database table.
@param string $table
@param boolean $clearLinks | [
"If",
"set",
"truncate",
"the",
"database",
"table",
"."
] | 0d857a1fa85a66dfe380ab153feaa3b167339822 | https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Console/Commands/Conversions/Conversion.php#L58-L71 | train |
JumpGateio/Database | src/JumpGate/Database/Console/Commands/Conversions/Conversion.php | Conversion.getProperty | protected function getProperty($object, $key)
{
if (isset($object->{$key}) &&
(
(is_int($object->{$key}) && $object->{$key} != 0) ||
(is_string($object->{$key}) && $object->{$key} != '')
)
) {
return $object->{$key};
}
return null;
} | php | protected function getProperty($object, $key)
{
if (isset($object->{$key}) &&
(
(is_int($object->{$key}) && $object->{$key} != 0) ||
(is_string($object->{$key}) && $object->{$key} != '')
)
) {
return $object->{$key};
}
return null;
} | [
"protected",
"function",
"getProperty",
"(",
"$",
"object",
",",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"{",
"$",
"key",
"}",
")",
"&&",
"(",
"(",
"is_int",
"(",
"$",
"object",
"->",
"{",
"$",
"key",
"}",
")",
"&&",... | Get a property from an object. Return the value if it exists.
@param $object
@param $key
@return null | [
"Get",
"a",
"property",
"from",
"an",
"object",
".",
"Return",
"the",
"value",
"if",
"it",
"exists",
"."
] | 0d857a1fa85a66dfe380ab153feaa3b167339822 | https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Console/Commands/Conversions/Conversion.php#L81-L93 | train |
JumpGateio/Database | src/JumpGate/Database/Console/Commands/Conversions/Conversion.php | Conversion.getModifiedDate | protected function getModifiedDate($object)
{
if (! isset($object->modified)) {
return date('Y-m-d h:i:s');
}
return $object->modified === '0000-00-00 00:00:00'
? date('Y-m-d h:i:s')
: $object->modified;
} | php | protected function getModifiedDate($object)
{
if (! isset($object->modified)) {
return date('Y-m-d h:i:s');
}
return $object->modified === '0000-00-00 00:00:00'
? date('Y-m-d h:i:s')
: $object->modified;
} | [
"protected",
"function",
"getModifiedDate",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"object",
"->",
"modified",
")",
")",
"{",
"return",
"date",
"(",
"'Y-m-d h:i:s'",
")",
";",
"}",
"return",
"$",
"object",
"->",
"modified",
"=... | When a record has a modified date, make sure one is set.
@param $object
@return mixed | [
"When",
"a",
"record",
"has",
"a",
"modified",
"date",
"make",
"sure",
"one",
"is",
"set",
"."
] | 0d857a1fa85a66dfe380ab153feaa3b167339822 | https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Console/Commands/Conversions/Conversion.php#L119-L128 | train |
JumpGateio/Database | src/JumpGate/Database/Console/Commands/Conversions/Conversion.php | Conversion.findLink | protected function findLink($originalTable, $originalId)
{
$link = $this->db->table('table_links')
->where('original_table', $originalTable)
->where('original_id', $originalId)
->first();
if (is_null($link)) {
$this->error('Could not find a link from ' . $originalTable . ' with an id of ' . $originalId);
return false;
}
return $link->new_id;
} | php | protected function findLink($originalTable, $originalId)
{
$link = $this->db->table('table_links')
->where('original_table', $originalTable)
->where('original_id', $originalId)
->first();
if (is_null($link)) {
$this->error('Could not find a link from ' . $originalTable . ' with an id of ' . $originalId);
return false;
}
return $link->new_id;
} | [
"protected",
"function",
"findLink",
"(",
"$",
"originalTable",
",",
"$",
"originalId",
")",
"{",
"$",
"link",
"=",
"$",
"this",
"->",
"db",
"->",
"table",
"(",
"'table_links'",
")",
"->",
"where",
"(",
"'original_table'",
",",
"$",
"originalTable",
")",
... | Find a new table id based on the old table and id.
@param string $originalTable
@param integer $originalId
@return mixed | [
"Find",
"a",
"new",
"table",
"id",
"based",
"on",
"the",
"old",
"table",
"and",
"id",
"."
] | 0d857a1fa85a66dfe380ab153feaa3b167339822 | https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Console/Commands/Conversions/Conversion.php#L138-L152 | train |
ItinerisLtd/preflight-command | src/CheckerCollectionFactory.php | CheckerCollectionFactory.make | public static function make(): CheckerCollection
{
$checkerCollection = new CheckerCollection();
do_action(self::REGISTER_HOOK, $checkerCollection);
do_action(self::BOOT_HOOK, $checkerCollection);
return $checkerCollection;
} | php | public static function make(): CheckerCollection
{
$checkerCollection = new CheckerCollection();
do_action(self::REGISTER_HOOK, $checkerCollection);
do_action(self::BOOT_HOOK, $checkerCollection);
return $checkerCollection;
} | [
"public",
"static",
"function",
"make",
"(",
")",
":",
"CheckerCollection",
"{",
"$",
"checkerCollection",
"=",
"new",
"CheckerCollection",
"(",
")",
";",
"do_action",
"(",
"self",
"::",
"REGISTER_HOOK",
",",
"$",
"checkerCollection",
")",
";",
"do_action",
"(... | Instantiate a CheckerCollection instance.
Run the register hook to allow built-in and third-party checkers to be registered.
Run the boot hook to allow messaging registered checkers.
@return CheckerCollection | [
"Instantiate",
"a",
"CheckerCollection",
"instance",
"."
] | d1c1360ea8d7de0312b5c0c09c9c486949594049 | https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CheckerCollectionFactory.php#L19-L27 | train |
harvestcloud/CoreBundle | Entity/Posting.php | Posting.updateAccountBalance | public function updateAccountBalance()
{
$this->getAccount()->setBalance($this->getAccount()->getBalance()+$this->getAmount());
$this->setBalanceAfterwards($this->getAccount()->getBalance());
} | php | public function updateAccountBalance()
{
$this->getAccount()->setBalance($this->getAccount()->getBalance()+$this->getAmount());
$this->setBalanceAfterwards($this->getAccount()->getBalance());
} | [
"public",
"function",
"updateAccountBalance",
"(",
")",
"{",
"$",
"this",
"->",
"getAccount",
"(",
")",
"->",
"setBalance",
"(",
"$",
"this",
"->",
"getAccount",
"(",
")",
"->",
"getBalance",
"(",
")",
"+",
"$",
"this",
"->",
"getAmount",
"(",
")",
")"... | Update Account balance
@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since 2012-05-21 | [
"Update",
"Account",
"balance"
] | f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc | https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Entity/Posting.php#L196-L200 | train |
sebastianmonzel/webfiles-framework-php | source/core/datastore/MAbstractDatastore.php | MAbstractDatastore.storeWebfilesFromStream | public function storeWebfilesFromStream(MWebfileStream $webfileStream)
{
if ($this->isReadOnly()) {
throw new MDatastoreException("cannot modify data on read-only datastore.");
}
$webfiles = $webfileStream->getWebfiles();
foreach ($webfiles as $webfile) {
$this->storeWebfile($webfile);
}
} | php | public function storeWebfilesFromStream(MWebfileStream $webfileStream)
{
if ($this->isReadOnly()) {
throw new MDatastoreException("cannot modify data on read-only datastore.");
}
$webfiles = $webfileStream->getWebfiles();
foreach ($webfiles as $webfile) {
$this->storeWebfile($webfile);
}
} | [
"public",
"function",
"storeWebfilesFromStream",
"(",
"MWebfileStream",
"$",
"webfileStream",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isReadOnly",
"(",
")",
")",
"{",
"throw",
"new",
"MDatastoreException",
"(",
"\"cannot modify data on read-only datastore.\"",
")",
... | Stores all webfiles from a given webfilestream in the actual datastore
@param MWebfileStream $webfileStream
@throws MDatastoreException | [
"Stores",
"all",
"webfiles",
"from",
"a",
"given",
"webfilestream",
"in",
"the",
"actual",
"datastore"
] | 5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d | https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datastore/MAbstractDatastore.php#L130-L141 | train |
monolyth-php/formulaic | src/Element/Identify.php | Identify.id | public function id() : string
{
$id = $this->name();
if ($this->prefix) {
$id = implode('-', $this->prefix)."-$id";
}
$id = preg_replace('/[\W]+/', '-', $id);
return trim(preg_replace('/[-]+/', '-', $id), '-');
} | php | public function id() : string
{
$id = $this->name();
if ($this->prefix) {
$id = implode('-', $this->prefix)."-$id";
}
$id = preg_replace('/[\W]+/', '-', $id);
return trim(preg_replace('/[-]+/', '-', $id), '-');
} | [
"public",
"function",
"id",
"(",
")",
":",
"string",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"name",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"prefix",
")",
"{",
"$",
"id",
"=",
"implode",
"(",
"'-'",
",",
"$",
"this",
"->",
"prefix",
")"... | Returns the ID generated for the element.
@return string | [
"Returns",
"the",
"ID",
"generated",
"for",
"the",
"element",
"."
] | 4bf7853a0c29cc17957f1b26c79f633867742c14 | https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Element/Identify.php#L32-L40 | train |
webservices-nl/utils | src/StringUtils.php | StringUtils.stringEndsWith | public static function stringEndsWith($haystack, $needle)
{
if (!is_string($haystack) || !is_string($needle)) {
throw new \InvalidArgumentException('Not a string');
}
return (strrpos($haystack, $needle) + strlen($needle)) === strlen($haystack);
} | php | public static function stringEndsWith($haystack, $needle)
{
if (!is_string($haystack) || !is_string($needle)) {
throw new \InvalidArgumentException('Not a string');
}
return (strrpos($haystack, $needle) + strlen($needle)) === strlen($haystack);
} | [
"public",
"static",
"function",
"stringEndsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"haystack",
")",
"||",
"!",
"is_string",
"(",
"$",
"needle",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgum... | Determine if a string ends with a particular sequence.
@param string $haystack
@param string $needle
@throws \InvalidArgumentException
@return bool | [
"Determine",
"if",
"a",
"string",
"ends",
"with",
"a",
"particular",
"sequence",
"."
] | 052f41ff725808b19d529e640f890ce7c863e100 | https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/StringUtils.php#L40-L47 | train |
webservices-nl/utils | src/StringUtils.php | StringUtils.stringStartsWith | public static function stringStartsWith($haystack, $needle)
{
if (!is_string($haystack) || !is_string($needle)) {
throw new \InvalidArgumentException('Not a string');
}
return strpos($haystack, $needle) === 0;
} | php | public static function stringStartsWith($haystack, $needle)
{
if (!is_string($haystack) || !is_string($needle)) {
throw new \InvalidArgumentException('Not a string');
}
return strpos($haystack, $needle) === 0;
} | [
"public",
"static",
"function",
"stringStartsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"haystack",
")",
"||",
"!",
"is_string",
"(",
"$",
"needle",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArg... | Determine if a string starts with a particular sequence.
@param string $haystack
@param string $needle
@throws \InvalidArgumentException
@return bool | [
"Determine",
"if",
"a",
"string",
"starts",
"with",
"a",
"particular",
"sequence",
"."
] | 052f41ff725808b19d529e640f890ce7c863e100 | https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/StringUtils.php#L59-L66 | train |
webservices-nl/utils | src/StringUtils.php | StringUtils.removePrefix | public static function removePrefix($haystack, $prefix)
{
if (!is_string($haystack) || !is_string($prefix)) {
throw new \InvalidArgumentException('Not a string');
}
if (strpos($haystack, $prefix) === 0) {
$haystack = substr($haystack, strlen($prefix));
}
return $haystack;
} | php | public static function removePrefix($haystack, $prefix)
{
if (!is_string($haystack) || !is_string($prefix)) {
throw new \InvalidArgumentException('Not a string');
}
if (strpos($haystack, $prefix) === 0) {
$haystack = substr($haystack, strlen($prefix));
}
return $haystack;
} | [
"public",
"static",
"function",
"removePrefix",
"(",
"$",
"haystack",
",",
"$",
"prefix",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"haystack",
")",
"||",
"!",
"is_string",
"(",
"$",
"prefix",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumen... | Remove the prefix from the provided string.
@param string $haystack
@param string $prefix
@throws \InvalidArgumentException
@return string | [
"Remove",
"the",
"prefix",
"from",
"the",
"provided",
"string",
"."
] | 052f41ff725808b19d529e640f890ce7c863e100 | https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/StringUtils.php#L78-L89 | train |
webservices-nl/utils | src/StringUtils.php | StringUtils.toUnderscore | public static function toUnderscore($string)
{
if (!is_string($string)) {
throw new \InvalidArgumentException('Not a string');
}
$transCoder = Transcoder::create('ASCII');
$string = $transCoder->transcode(trim($string));
$words = explode(' ', $string);
return implode('_', array_filter(array_map([static::class, 'wordToUnderscored'], $words)));
} | php | public static function toUnderscore($string)
{
if (!is_string($string)) {
throw new \InvalidArgumentException('Not a string');
}
$transCoder = Transcoder::create('ASCII');
$string = $transCoder->transcode(trim($string));
$words = explode(' ', $string);
return implode('_', array_filter(array_map([static::class, 'wordToUnderscored'], $words)));
} | [
"public",
"static",
"function",
"toUnderscore",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Not a string'",
")",
";",
"}",
"$",
"transCoder",
"=",
... | Converts a string to underscore version.
Also tries to filter out higher UTF-8 chars.
@param string $string
@throws \Ddeboer\Transcoder\Exception\UnsupportedEncodingException
@throws \Ddeboer\Transcoder\Exception\ExtensionMissingException
@throws \InvalidArgumentException
@return string | [
"Converts",
"a",
"string",
"to",
"underscore",
"version",
".",
"Also",
"tries",
"to",
"filter",
"out",
"higher",
"UTF",
"-",
"8",
"chars",
"."
] | 052f41ff725808b19d529e640f890ce7c863e100 | https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/StringUtils.php#L158-L169 | train |
amercier/rectangular-mozaic | src/Assert.php | Assert.assertIntegerBetween | public static function assertIntegerBetween(int $min, int $max, int $value, string $name)
{
if ($value < $min || $value > $max) {
throw new InvalidArgumentException("Expecting {$name} to be between {$min} and {$max}, got {$value}");
}
} | php | public static function assertIntegerBetween(int $min, int $max, int $value, string $name)
{
if ($value < $min || $value > $max) {
throw new InvalidArgumentException("Expecting {$name} to be between {$min} and {$max}, got {$value}");
}
} | [
"public",
"static",
"function",
"assertIntegerBetween",
"(",
"int",
"$",
"min",
",",
"int",
"$",
"max",
",",
"int",
"$",
"value",
",",
"string",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"value",
"<",
"$",
"min",
"||",
"$",
"value",
">",
"$",
"max",
... | Assert an integer is between two known values
@param int $min Minimun acceptable value.
@param int $max Maximum acceptable value.
@param int $value Value to test.
@param string $name Name of the argument.
@return void
@throws InvalidArgumentException if `$value` is lower than `$min` or higher than `$max`. | [
"Assert",
"an",
"integer",
"is",
"between",
"two",
"known",
"values"
] | d026a82c1bc73979308235a7a440665e92ee8525 | https://github.com/amercier/rectangular-mozaic/blob/d026a82c1bc73979308235a7a440665e92ee8525/src/Assert.php#L52-L57 | train |
dlabas/DlcBase | src/DlcBase/Controller/AbstractActionController.php | AbstractActionController.getClassNameWithoutNamespace | public function getClassNameWithoutNamespace()
{
if ($this->classNameWithoutNamespace === null) {
$class = explode('\\', get_class($this));
$this->classNameWithoutNamespace = substr(end($class), 0, -10);
}
return $this->classNameWithoutNamespace;
} | php | public function getClassNameWithoutNamespace()
{
if ($this->classNameWithoutNamespace === null) {
$class = explode('\\', get_class($this));
$this->classNameWithoutNamespace = substr(end($class), 0, -10);
}
return $this->classNameWithoutNamespace;
} | [
"public",
"function",
"getClassNameWithoutNamespace",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"classNameWithoutNamespace",
"===",
"null",
")",
"{",
"$",
"class",
"=",
"explode",
"(",
"'\\\\'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"$",
... | Getter for the class name without it's namespace
@return string | [
"Getter",
"for",
"the",
"class",
"name",
"without",
"it",
"s",
"namespace"
] | 0f6b1056a670c68fffa0055901e209cc45621599 | https://github.com/dlabas/DlcBase/blob/0f6b1056a670c68fffa0055901e209cc45621599/src/DlcBase/Controller/AbstractActionController.php#L75-L82 | train |
dlabas/DlcBase | src/DlcBase/Controller/AbstractActionController.php | AbstractActionController.getRouteIdentifierPrefix | public function getRouteIdentifierPrefix()
{
if ($this->routeIdentifierPrefix === null) {
$this->routeIdentifierPrefix = strtolower($this->getModuleNamespace() . '/' . $this->getClassNameWithoutNamespace());
}
return $this->routeIdentifierPrefix;
} | php | public function getRouteIdentifierPrefix()
{
if ($this->routeIdentifierPrefix === null) {
$this->routeIdentifierPrefix = strtolower($this->getModuleNamespace() . '/' . $this->getClassNameWithoutNamespace());
}
return $this->routeIdentifierPrefix;
} | [
"public",
"function",
"getRouteIdentifierPrefix",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"routeIdentifierPrefix",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"routeIdentifierPrefix",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"getModuleNamespace",
"(",
"... | Returns the prefix for the route identifier | [
"Returns",
"the",
"prefix",
"for",
"the",
"route",
"identifier"
] | 0f6b1056a670c68fffa0055901e209cc45621599 | https://github.com/dlabas/DlcBase/blob/0f6b1056a670c68fffa0055901e209cc45621599/src/DlcBase/Controller/AbstractActionController.php#L113-L119 | train |
phossa2/libs | src/Phossa2/Route/Collector/Collector.php | Collector.checkDuplication | protected function checkDuplication(
RouteInterface $route,
/*# string */ $routeKey,
/*# string */ $method
) {
if (isset($this->routes[$routeKey][$method])) {
throw new LogicException(
Message::get(
Message::RTE_ROUTE_DUPLICATED,
$route->getPattern(),
$method
),
Message::RTE_ROUTE_DUPLICATED
);
}
} | php | protected function checkDuplication(
RouteInterface $route,
/*# string */ $routeKey,
/*# string */ $method
) {
if (isset($this->routes[$routeKey][$method])) {
throw new LogicException(
Message::get(
Message::RTE_ROUTE_DUPLICATED,
$route->getPattern(),
$method
),
Message::RTE_ROUTE_DUPLICATED
);
}
} | [
"protected",
"function",
"checkDuplication",
"(",
"RouteInterface",
"$",
"route",
",",
"/*# string */",
"$",
"routeKey",
",",
"/*# string */",
"$",
"method",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"routeKey",
"]",
"[",
"$... | Same route pattern and method ?
@param RouteInterface $route
@param string $routeKey
@param string $method
@throws LogicException if duplication found
@access protected | [
"Same",
"route",
"pattern",
"and",
"method",
"?"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Route/Collector/Collector.php#L113-L128 | train |
subcosm/observatory | src/ObservableTrait.php | ObservableTrait.notify | protected function notify(ObservationContainerInterface $container): ? ObservationContainerInterface
{
foreach ( $this->observers as $current ) {
$current->update($container);
}
return $container;
} | php | protected function notify(ObservationContainerInterface $container): ? ObservationContainerInterface
{
foreach ( $this->observers as $current ) {
$current->update($container);
}
return $container;
} | [
"protected",
"function",
"notify",
"(",
"ObservationContainerInterface",
"$",
"container",
")",
":",
"?",
"ObservationContainerInterface",
"{",
"foreach",
"(",
"$",
"this",
"->",
"observers",
"as",
"$",
"current",
")",
"{",
"$",
"current",
"->",
"update",
"(",
... | notifies all observers using a observation container implementation.
@param ObservationContainerInterface $container
@return ObservationContainerInterface|null | [
"notifies",
"all",
"observers",
"using",
"a",
"observation",
"container",
"implementation",
"."
] | 7c8c4eb0193fff9a2f40c33b2d3eb344314852e9 | https://github.com/subcosm/observatory/blob/7c8c4eb0193fff9a2f40c33b2d3eb344314852e9/src/ObservableTrait.php#L67-L74 | train |
rafflesargentina/l5-user-action | src/Providers/RouteServiceProvider.php | RouteServiceProvider.mapWebRoutes | protected function mapWebRoutes()
{
Route::group([
'middleware' => config($this->package.'.web_routes_middleware') ?: 'web',
'namespace' => $this->namespace,
'prefix' => $this->prefix,
], function ($router) {
require __DIR__.'/../Routes/web.php';
});
} | php | protected function mapWebRoutes()
{
Route::group([
'middleware' => config($this->package.'.web_routes_middleware') ?: 'web',
'namespace' => $this->namespace,
'prefix' => $this->prefix,
], function ($router) {
require __DIR__.'/../Routes/web.php';
});
} | [
"protected",
"function",
"mapWebRoutes",
"(",
")",
"{",
"Route",
"::",
"group",
"(",
"[",
"'middleware'",
"=>",
"config",
"(",
"$",
"this",
"->",
"package",
".",
"'.web_routes_middleware'",
")",
"?",
":",
"'web'",
",",
"'namespace'",
"=>",
"$",
"this",
"->... | Define the "web" routes for the module.
These routes all receive session state, CSRF protection, etc.
@return void | [
"Define",
"the",
"web",
"routes",
"for",
"the",
"module",
"."
] | eb13dd46bf8b45e498104bd14527afa0625f7ee1 | https://github.com/rafflesargentina/l5-user-action/blob/eb13dd46bf8b45e498104bd14527afa0625f7ee1/src/Providers/RouteServiceProvider.php#L70-L79 | train |
GrupaZero/core | src/Gzero/Core/Validators/AbstractValidator.php | AbstractValidator.validate | public function validate($context = 'default', array $data = [])
{
if (!empty($data)) {
$this->setData($data);
}
$this->setContext($context);
$rules = $this->buildRulesArray();
$validator = $this->factory->make($this->filterArray($rules, $this->data), $rules);
if ($validator->passes()) {
return $validator->getData();
}
throw new ValidationException($validator);
} | php | public function validate($context = 'default', array $data = [])
{
if (!empty($data)) {
$this->setData($data);
}
$this->setContext($context);
$rules = $this->buildRulesArray();
$validator = $this->factory->make($this->filterArray($rules, $this->data), $rules);
if ($validator->passes()) {
return $validator->getData();
}
throw new ValidationException($validator);
} | [
"public",
"function",
"validate",
"(",
"$",
"context",
"=",
"'default'",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"setData",
"(",
"$",
"data",
")",
";",
"}"... | Validate passed data
@param string $context Validation context
@param array $data Data to validate
@throws InvalidArgumentException
@throws ValidationException
@return array | [
"Validate",
"passed",
"data"
] | 093e515234fa0385b259ba4d8bc7832174a44eab | https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Validators/AbstractValidator.php#L57-L70 | train |
GrupaZero/core | src/Gzero/Core/Validators/AbstractValidator.php | AbstractValidator.buildRulesArray | protected function buildRulesArray()
{
if (method_exists($this, $this->context)) {
$rules = $this->{$this->context}();
} elseif (isset($this->rules[$this->context])) {
$rules = $this->rules[$this->context];
} else {
throw new InvalidArgumentException("Undefined validation context: " . $this->context);
}
return $this->bindPlaceholders($rules);
} | php | protected function buildRulesArray()
{
if (method_exists($this, $this->context)) {
$rules = $this->{$this->context}();
} elseif (isset($this->rules[$this->context])) {
$rules = $this->rules[$this->context];
} else {
throw new InvalidArgumentException("Undefined validation context: " . $this->context);
}
return $this->bindPlaceholders($rules);
} | [
"protected",
"function",
"buildRulesArray",
"(",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"context",
")",
")",
"{",
"$",
"rules",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"context",
"}",
"(",
")",
";",
... | Build rules array
@throws InvalidArgumentException
@return array | [
"Build",
"rules",
"array"
] | 093e515234fa0385b259ba4d8bc7832174a44eab | https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Validators/AbstractValidator.php#L131-L141 | train |
GrupaZero/core | src/Gzero/Core/Validators/AbstractValidator.php | AbstractValidator.filterArray | protected function filterArray($rules, $rawAttributes)
{
$attributes = [];
foreach (array_keys($rules) as $filedName) {
$value = array_get($rawAttributes, $filedName, 'not found in array'); // Default value !== null
if ($value !== 'not found in array') { // Only if field specified in incoming array
if (isset($this->filters[$filedName])) {
$filters = explode('|', $this->filters[$filedName]);
foreach ($filters as $filter) {
array_set($attributes, $filedName, $this->$filter($value));
}
} else {
array_set($attributes, $filedName, $value);
}
}
}
return $attributes;
} | php | protected function filterArray($rules, $rawAttributes)
{
$attributes = [];
foreach (array_keys($rules) as $filedName) {
$value = array_get($rawAttributes, $filedName, 'not found in array'); // Default value !== null
if ($value !== 'not found in array') { // Only if field specified in incoming array
if (isset($this->filters[$filedName])) {
$filters = explode('|', $this->filters[$filedName]);
foreach ($filters as $filter) {
array_set($attributes, $filedName, $this->$filter($value));
}
} else {
array_set($attributes, $filedName, $value);
}
}
}
return $attributes;
} | [
"protected",
"function",
"filterArray",
"(",
"$",
"rules",
",",
"$",
"rawAttributes",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"rules",
")",
"as",
"$",
"filedName",
")",
"{",
"$",
"value",
"=",
"array_get... | Filter array with data to validate
@param array $rules Rules array
@param array $rawAttributes Array with data passed to validation
@return array | [
"Filter",
"array",
"with",
"data",
"to",
"validate"
] | 093e515234fa0385b259ba4d8bc7832174a44eab | https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Validators/AbstractValidator.php#L151-L168 | train |
milkyway-multimedia/ss-zen-forms | src/Traits/RequestHandlerDecorator.php | RequestHandlerDecorator.handleRequest | public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
return $this->original()->handleRequest($request, $model);
} | php | public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
return $this->original()->handleRequest($request, $model);
} | [
"public",
"function",
"handleRequest",
"(",
"SS_HTTPRequest",
"$",
"request",
",",
"DataModel",
"$",
"model",
")",
"{",
"return",
"$",
"this",
"->",
"original",
"(",
")",
"->",
"handleRequest",
"(",
"$",
"request",
",",
"$",
"model",
")",
";",
"}"
] | Iterate until we reach the original object
A bit hacky but if it works, it works
@param SS_HTTPRequest $request
@param DataModel $model
@return array|\RequestHandler|\SS_HTTPResponse|string | [
"Iterate",
"until",
"we",
"reach",
"the",
"original",
"object",
"A",
"bit",
"hacky",
"but",
"if",
"it",
"works",
"it",
"works"
] | 24098390d88fff016a6e6299fd2fda50f11be064 | https://github.com/milkyway-multimedia/ss-zen-forms/blob/24098390d88fff016a6e6299fd2fda50f11be064/src/Traits/RequestHandlerDecorator.php#L24-L26 | train |
cosmow/riak | lib/CosmoW/Riak/Database.php | Database.getSlaveOkay | public function getSlaveOkay()
{
if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
return $this->riak->getSlaveOkay();
}
$readPref = $this->getReadPreference();
return \RiakClient::RP_PRIMARY !== $readPref['type'];
} | php | public function getSlaveOkay()
{
if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
return $this->riak->getSlaveOkay();
}
$readPref = $this->getReadPreference();
return \RiakClient::RP_PRIMARY !== $readPref['type'];
} | [
"public",
"function",
"getSlaveOkay",
"(",
")",
"{",
"if",
"(",
"version_compare",
"(",
"phpversion",
"(",
"'mongo'",
")",
",",
"'1.3.0'",
",",
"'<'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"riak",
"->",
"getSlaveOkay",
"(",
")",
";",
"}",
"$",
... | Get whether secondary read queries are allowed for this database.
This method wraps getSlaveOkay() for driver versions before 1.3.0. For
newer drivers, this method considers any read preference other than
PRIMARY as a true "slaveOkay" value.
@see http://php.net/manual/en/mongodb.getreadpreference.php
@see http://php.net/manual/en/mongodb.getslaveokay.php
@return boolean | [
"Get",
"whether",
"secondary",
"read",
"queries",
"are",
"allowed",
"for",
"this",
"database",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Database.php#L372-L381 | train |
cosmow/riak | lib/CosmoW/Riak/Database.php | Database.setSlaveOkay | public function setSlaveOkay($ok = true)
{
if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
return $this->riak->setSlaveOkay($ok);
}
$prevSlaveOkay = $this->getSlaveOkay();
if ($ok) {
// Preserve existing tags for non-primary read preferences
$readPref = $this->getReadPreference();
$tags = ! empty($readPref['tagsets']) ? $readPref['tagsets'] : array();
$this->riak->setReadPreference(\RiakClient::RP_SECONDARY_PREFERRED, $tags);
} else {
$this->riak->setReadPreference(\RiakClient::RP_PRIMARY);
}
return $prevSlaveOkay;
} | php | public function setSlaveOkay($ok = true)
{
if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
return $this->riak->setSlaveOkay($ok);
}
$prevSlaveOkay = $this->getSlaveOkay();
if ($ok) {
// Preserve existing tags for non-primary read preferences
$readPref = $this->getReadPreference();
$tags = ! empty($readPref['tagsets']) ? $readPref['tagsets'] : array();
$this->riak->setReadPreference(\RiakClient::RP_SECONDARY_PREFERRED, $tags);
} else {
$this->riak->setReadPreference(\RiakClient::RP_PRIMARY);
}
return $prevSlaveOkay;
} | [
"public",
"function",
"setSlaveOkay",
"(",
"$",
"ok",
"=",
"true",
")",
"{",
"if",
"(",
"version_compare",
"(",
"phpversion",
"(",
"'mongo'",
")",
",",
"'1.3.0'",
",",
"'<'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"riak",
"->",
"setSlaveOkay",
"("... | Set whether secondary read queries are allowed for this database.
This method wraps setSlaveOkay() for driver versions before 1.3.0. For
newer drivers, this method wraps setReadPreference() and specifies
SECONDARY_PREFERRED.
@see http://php.net/manual/en/mongodb.setreadpreference.php
@see http://php.net/manual/en/mongodb.setslaveokay.php
@param boolean $ok
@return boolean Previous slaveOk value | [
"Set",
"whether",
"secondary",
"read",
"queries",
"are",
"allowed",
"for",
"this",
"database",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Database.php#L395-L413 | train |
gossi/trixionary | src/model/Base/LineageQuery.php | LineageQuery.filterByAncestorId | public function filterByAncestorId($ancestorId = null, $comparison = null)
{
if (is_array($ancestorId)) {
$useMinMax = false;
if (isset($ancestorId['min'])) {
$this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($ancestorId['max'])) {
$this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId, $comparison);
} | php | public function filterByAncestorId($ancestorId = null, $comparison = null)
{
if (is_array($ancestorId)) {
$useMinMax = false;
if (isset($ancestorId['min'])) {
$this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($ancestorId['max'])) {
$this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(LineageTableMap::COL_ANCESTOR_ID, $ancestorId, $comparison);
} | [
"public",
"function",
"filterByAncestorId",
"(",
"$",
"ancestorId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"ancestorId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
... | Filter the query on the ancestor_id column
Example usage:
<code>
$query->filterByAncestorId(1234); // WHERE ancestor_id = 1234
$query->filterByAncestorId(array(12, 34)); // WHERE ancestor_id IN (12, 34)
$query->filterByAncestorId(array('min' => 12)); // WHERE ancestor_id > 12
</code>
@see filterByAncestor()
@param mixed $ancestorId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildLineageQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"ancestor_id",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/LineageQuery.php#L354-L375 | train |
gossi/trixionary | src/model/Base/LineageQuery.php | LineageQuery.useAncestorQuery | public function useAncestorQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAncestor($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Ancestor', '\gossi\trixionary\model\SkillQuery');
} | php | public function useAncestorQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAncestor($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Ancestor', '\gossi\trixionary\model\SkillQuery');
} | [
"public",
"function",
"useAncestorQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinAncestor",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
... | Use the Ancestor relation Skill object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \gossi\trixionary\model\SkillQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"Ancestor",
"relation",
"Skill",
"object"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/LineageQuery.php#L565-L570 | train |
chriscollins/general-utils | lib/ChrisCollins/GeneralUtils/Tree/TreeNode.php | TreeNode.buildTreeAndGetRoots | public static function buildTreeAndGetRoots(array $objects)
{
$nodeClass = get_called_class(); // Use late static binding so new nodes are created as the calling subclass.
// Build a TreeNode for each object.
$nodes = array();
foreach ($objects as $object) {
$nodes[] = new $nodeClass($object);
}
// Loop through each node and update set its parent and children.
foreach ($nodes as $node) {
$object = $node->getObject();
foreach ($nodes as $potentialParentNode) {
if ($potentialParentNode->getObject()->isParentOf($object)) {
$node->setParent($potentialParentNode);
$potentialParentNode->addChild($node);
break;
}
}
}
// Now find the root nodes and return them.
$roots = array();
foreach ($nodes as $potentialRoot) {
if ($potentialRoot->isRootNode()) {
$roots[] = $potentialRoot;
}
}
return $roots;
} | php | public static function buildTreeAndGetRoots(array $objects)
{
$nodeClass = get_called_class(); // Use late static binding so new nodes are created as the calling subclass.
// Build a TreeNode for each object.
$nodes = array();
foreach ($objects as $object) {
$nodes[] = new $nodeClass($object);
}
// Loop through each node and update set its parent and children.
foreach ($nodes as $node) {
$object = $node->getObject();
foreach ($nodes as $potentialParentNode) {
if ($potentialParentNode->getObject()->isParentOf($object)) {
$node->setParent($potentialParentNode);
$potentialParentNode->addChild($node);
break;
}
}
}
// Now find the root nodes and return them.
$roots = array();
foreach ($nodes as $potentialRoot) {
if ($potentialRoot->isRootNode()) {
$roots[] = $potentialRoot;
}
}
return $roots;
} | [
"public",
"static",
"function",
"buildTreeAndGetRoots",
"(",
"array",
"$",
"objects",
")",
"{",
"$",
"nodeClass",
"=",
"get_called_class",
"(",
")",
";",
"// Use late static binding so new nodes are created as the calling subclass.",
"// Build a TreeNode for each object.",
"$",... | Build a tree from an array of TreeNodeObjectInterface objects.
@param array $objects An array of TreeNodeObjectInterface objects to make into a tree.
@return array An array of TreeNodes, each representing a root (i.e. a node for which no parent was found). | [
"Build",
"a",
"tree",
"from",
"an",
"array",
"of",
"TreeNodeObjectInterface",
"objects",
"."
] | 3fef519f3dd97bf15aa16ff528152ae663e027ac | https://github.com/chriscollins/general-utils/blob/3fef519f3dd97bf15aa16ff528152ae663e027ac/lib/ChrisCollins/GeneralUtils/Tree/TreeNode.php#L136-L169 | train |
nice-php/twig | src/Twig/AssetExtension.php | AssetExtension.getAssetUrl | public function getAssetUrl($path)
{
if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
return $path;
}
if (!$this->container->has('request')) {
return $path;
}
if ('/' !== substr($path, 0, 1)) {
$path = '/' . $path;
}
$request = $this->container->get('request');
$path = $request->getBasePath() . $path;
return $path;
} | php | public function getAssetUrl($path)
{
if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
return $path;
}
if (!$this->container->has('request')) {
return $path;
}
if ('/' !== substr($path, 0, 1)) {
$path = '/' . $path;
}
$request = $this->container->get('request');
$path = $request->getBasePath() . $path;
return $path;
} | [
"public",
"function",
"getAssetUrl",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"path",
",",
"'://'",
")",
"||",
"0",
"===",
"strpos",
"(",
"$",
"path",
",",
"'//'",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
... | Returns the public path of an asset
@param string $path
@return string | [
"Returns",
"the",
"public",
"path",
"of",
"an",
"asset"
] | a7a634795bebcae250d0e83de1e070b0261d85e1 | https://github.com/nice-php/twig/blob/a7a634795bebcae250d0e83de1e070b0261d85e1/src/Twig/AssetExtension.php#L50-L68 | train |
cstabor/screw | src/Screw/Base64UrlSafe.php | Base64UrlSafe.encode | public static function encode($data, $pad = null) {
$str = str_replace(array('+', '/'), array('-', '_'), base64_encode($data));
if (!$pad) {
$str = rtrim($str, '=');
}
return $str;
} | php | public static function encode($data, $pad = null) {
$str = str_replace(array('+', '/'), array('-', '_'), base64_encode($data));
if (!$pad) {
$str = rtrim($str, '=');
}
return $str;
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"pad",
"=",
"null",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"array",
"(",
"'+'",
",",
"'/'",
")",
",",
"array",
"(",
"'-'",
",",
"'_'",
")",
",",
"base64_encode",
"(",
"... | encode a string
@param string $data
@param string $pad
@return string | [
"encode",
"a",
"string"
] | c160c2b740bd1e0e72535fddf1c15cab99558669 | https://github.com/cstabor/screw/blob/c160c2b740bd1e0e72535fddf1c15cab99558669/src/Screw/Base64UrlSafe.php#L22-L28 | train |
n0m4dz/laracasa | Zend/Gdata/YouTube/ActivityEntry.php | Zend_Gdata_YouTube_ActivityEntry.getActivityType | public function getActivityType()
{
$categories = $this->getCategory();
foreach($categories as $category) {
if ($category->getScheme() == self::ACTIVITY_CATEGORY_SCHEME) {
return $category->getTerm();
}
}
return null;
} | php | public function getActivityType()
{
$categories = $this->getCategory();
foreach($categories as $category) {
if ($category->getScheme() == self::ACTIVITY_CATEGORY_SCHEME) {
return $category->getTerm();
}
}
return null;
} | [
"public",
"function",
"getActivityType",
"(",
")",
"{",
"$",
"categories",
"=",
"$",
"this",
"->",
"getCategory",
"(",
")",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"{",
"if",
"(",
"$",
"category",
"->",
"getScheme",
"(",
")"... | Return the activity type that was performed.
Convenience method that inspects category where scheme is
http://gdata.youtube.com/schemas/2007/userevents.cat.
@return string|null The activity category if found. | [
"Return",
"the",
"activity",
"type",
"that",
"was",
"performed",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/ActivityEntry.php#L211-L220 | train |
prototypemvc/prototypemvc | Core/Bootstrap.php | Bootstrap._callControllerMethod | protected function _callControllerMethod() {
// Make sure the controller we are calling exists
if (!isset($this->_controller) || !is_object($this->_controller)) {
$this->_error("Controller does not exist: " . $this->_url_controller);
return false;
}
// Make sure the method we are calling exists
if (!method_exists($this->_controller, $this->_url_method)) {
$this->_error("Method does not exist: " . $this->_url_method);
return false;
}
call_user_func_array(array($this->_controller, $this->_url_method), $this->_url_args);
} | php | protected function _callControllerMethod() {
// Make sure the controller we are calling exists
if (!isset($this->_controller) || !is_object($this->_controller)) {
$this->_error("Controller does not exist: " . $this->_url_controller);
return false;
}
// Make sure the method we are calling exists
if (!method_exists($this->_controller, $this->_url_method)) {
$this->_error("Method does not exist: " . $this->_url_method);
return false;
}
call_user_func_array(array($this->_controller, $this->_url_method), $this->_url_args);
} | [
"protected",
"function",
"_callControllerMethod",
"(",
")",
"{",
"// Make sure the controller we are calling exists",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_controller",
")",
"||",
"!",
"is_object",
"(",
"$",
"this",
"->",
"_controller",
")",
")",
"{... | If a method is passed in the GET url paremter | [
"If",
"a",
"method",
"is",
"passed",
"in",
"the",
"GET",
"url",
"paremter"
] | 039e238857d4b627e40ba681a376583b0821cd36 | https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Bootstrap.php#L86-L101 | train |
chipaau/support | src/Support/JsonApi/Core/SchemaContainer.php | SchemaContainer.getSchemaByType | public function getSchemaByType($modelClass)
{
if (array_key_exists($modelClass, $this->schemaInstances) === true) {
return $this->schemaInstances[$modelClass];
}
if ($this->hasSchemaForModelClass($modelClass) === false) {
throw new InvalidArgumentException("Schema was not registered for model '$modelClass'.");
}
$schemaClass = $this->model2schemaMap[$modelClass];
$schema = new $schemaClass($this->factory, $this);
$this->schemaInstances[$modelClass] = $schema;
return $schema;
} | php | public function getSchemaByType($modelClass)
{
if (array_key_exists($modelClass, $this->schemaInstances) === true) {
return $this->schemaInstances[$modelClass];
}
if ($this->hasSchemaForModelClass($modelClass) === false) {
throw new InvalidArgumentException("Schema was not registered for model '$modelClass'.");
}
$schemaClass = $this->model2schemaMap[$modelClass];
$schema = new $schemaClass($this->factory, $this);
$this->schemaInstances[$modelClass] = $schema;
return $schema;
} | [
"public",
"function",
"getSchemaByType",
"(",
"$",
"modelClass",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"modelClass",
",",
"$",
"this",
"->",
"schemaInstances",
")",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"schemaInstances",
"[",
... | Get schema provider by resource type.
@param string $modelClass
@return SchemaProviderInterface | [
"Get",
"schema",
"provider",
"by",
"resource",
"type",
"."
] | 2fe3673ed2330bd064d37b2f0bac3e02ca110bef | https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/JsonApi/Core/SchemaContainer.php#L100-L116 | train |
mvccore/ext-form | src/MvcCore/Ext/Forms/Field/Getters.php | Getters.& | public function & HasValidator ($validatorNameOrInstance) {
if (is_string($validatorNameOrInstance)) {
$validatorClassName = $validatorNameOrInstance;
} else if ($validatorNameOrInstance instanceof \MvcCore\Ext\Forms\IValidator) {
$validatorClassName = get_class($validatorNameOrInstance);
} else {
return $this->throwNewInvalidArgumentException(
'Unknown validator type given: `' . $validatorNameOrInstance
. '`, type: `' . gettype($validatorNameOrInstance) . '`.'
);
}
$slashPos = strrpos($validatorClassName, '\\');
$validatorName = $slashPos !== FALSE
? substr($validatorClassName, $slashPos + 1)
: $validatorClassName;
return isset($this->validators[$validatorName]);
} | php | public function & HasValidator ($validatorNameOrInstance) {
if (is_string($validatorNameOrInstance)) {
$validatorClassName = $validatorNameOrInstance;
} else if ($validatorNameOrInstance instanceof \MvcCore\Ext\Forms\IValidator) {
$validatorClassName = get_class($validatorNameOrInstance);
} else {
return $this->throwNewInvalidArgumentException(
'Unknown validator type given: `' . $validatorNameOrInstance
. '`, type: `' . gettype($validatorNameOrInstance) . '`.'
);
}
$slashPos = strrpos($validatorClassName, '\\');
$validatorName = $slashPos !== FALSE
? substr($validatorClassName, $slashPos + 1)
: $validatorClassName;
return isset($this->validators[$validatorName]);
} | [
"public",
"function",
"&",
"HasValidator",
"(",
"$",
"validatorNameOrInstance",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"validatorNameOrInstance",
")",
")",
"{",
"$",
"validatorClassName",
"=",
"$",
"validatorNameOrInstance",
";",
"}",
"else",
"if",
"(",
"... | Get `TRUE`, if field has configured in it's validators array
given validator class ending name or validator instance.
@param string|\MvcCore\Ext\Forms\IValidator $validatorNameOrInstance
@return bool | [
"Get",
"TRUE",
"if",
"field",
"has",
"configured",
"in",
"it",
"s",
"validators",
"array",
"given",
"validator",
"class",
"ending",
"name",
"or",
"validator",
"instance",
"."
] | 8d81a3c7326236702f37dc4b9d968907b3230b9f | https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Forms/Field/Getters.php#L128-L144 | train |
rodchyn/elephant-lang | lib/ParserGenerator/PHP/ParserGenerator/ActionTable.php | PHP_ParserGenerator_ActionTable.acttab_action | function acttab_action($lookahead, $action)
{
if ($this->nLookahead === 0) {
$this->aLookahead = array();
$this->mxLookahead = $lookahead;
$this->mnLookahead = $lookahead;
$this->mnAction = $action;
} else {
if ($this->mxLookahead < $lookahead) {
$this->mxLookahead = $lookahead;
}
if ($this->mnLookahead > $lookahead) {
$this->mnLookahead = $lookahead;
$this->mnAction = $action;
}
}
$this->aLookahead[$this->nLookahead] = array(
'lookahead' => $lookahead,
'action' => $action);
$this->nLookahead++;
} | php | function acttab_action($lookahead, $action)
{
if ($this->nLookahead === 0) {
$this->aLookahead = array();
$this->mxLookahead = $lookahead;
$this->mnLookahead = $lookahead;
$this->mnAction = $action;
} else {
if ($this->mxLookahead < $lookahead) {
$this->mxLookahead = $lookahead;
}
if ($this->mnLookahead > $lookahead) {
$this->mnLookahead = $lookahead;
$this->mnAction = $action;
}
}
$this->aLookahead[$this->nLookahead] = array(
'lookahead' => $lookahead,
'action' => $action);
$this->nLookahead++;
} | [
"function",
"acttab_action",
"(",
"$",
"lookahead",
",",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nLookahead",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"aLookahead",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"mxLookahead",
"=",
... | Add a new action to the current transaction set
@param int $lookahead
@param int $action
@return void | [
"Add",
"a",
"new",
"action",
"to",
"the",
"current",
"transaction",
"set"
] | e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf | https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/ActionTable.php#L137-L157 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.