id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
7,500
frogsystem/legacy-bridge
src/Services/Lang.php
Lang.get
public function get($tag) { // load if necessary if (!$this->loaded) { $this->load(); } // get tag if (!isset($this->phrases[$tag]) || $this->phrases[$tag] == '') { return 'LOCALIZE [' . $this->local . ']: ' . $tag; } else { return $this->phrases[$tag]; } }
php
public function get($tag) { // load if necessary if (!$this->loaded) { $this->load(); } // get tag if (!isset($this->phrases[$tag]) || $this->phrases[$tag] == '') { return 'LOCALIZE [' . $this->local . ']: ' . $tag; } else { return $this->phrases[$tag]; } }
[ "public", "function", "get", "(", "$", "tag", ")", "{", "// load if necessary", "if", "(", "!", "$", "this", "->", "loaded", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "// get tag", "if", "(", "!", "isset", "(", "$", "this", "->", "phrases", "[", "$", "tag", "]", ")", "||", "$", "this", "->", "phrases", "[", "$", "tag", "]", "==", "''", ")", "{", "return", "'LOCALIZE ['", ".", "$", "this", "->", "local", ".", "']: '", ".", "$", "tag", ";", "}", "else", "{", "return", "$", "this", "->", "phrases", "[", "$", "tag", "]", ";", "}", "}" ]
method to display phrases @param $tag @return mixed|string @throws \Exception
[ "method", "to", "display", "phrases" ]
a4ea3bea701e2b737c119a5d89b7778e8745658c
https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/Lang.php#L149-L162
7,501
tekkla/core-framework
Core/Framework/Page/Template.php
Template.getMeta
final protected function getMeta($data_only = false) { $meta_stack = $this->page->meta->getTags(); if ($data_only) { return $meta_stack; } $html = ''; foreach ($meta_stack as $tag) { $html .= PHP_EOL . '<meta'; foreach ($tag as $attribute => $value) { $html .= ' ' . $attribute . '="' . $value . '"'; } $html .= '>'; } return $html; }
php
final protected function getMeta($data_only = false) { $meta_stack = $this->page->meta->getTags(); if ($data_only) { return $meta_stack; } $html = ''; foreach ($meta_stack as $tag) { $html .= PHP_EOL . '<meta'; foreach ($tag as $attribute => $value) { $html .= ' ' . $attribute . '="' . $value . '"'; } $html .= '>'; } return $html; }
[ "final", "protected", "function", "getMeta", "(", "$", "data_only", "=", "false", ")", "{", "$", "meta_stack", "=", "$", "this", "->", "page", "->", "meta", "->", "getTags", "(", ")", ";", "if", "(", "$", "data_only", ")", "{", "return", "$", "meta_stack", ";", "}", "$", "html", "=", "''", ";", "foreach", "(", "$", "meta_stack", "as", "$", "tag", ")", "{", "$", "html", ".=", "PHP_EOL", ".", "'<meta'", ";", "foreach", "(", "$", "tag", "as", "$", "attribute", "=>", "$", "value", ")", "{", "$", "html", ".=", "' '", ".", "$", "attribute", ".", "'=\"'", ".", "$", "value", ".", "'\"'", ";", "}", "$", "html", ".=", "'>'", ";", "}", "return", "$", "html", ";", "}" ]
Creates and returns meta tags @param boolean $data_only Set to true if you want to get get only the data without a generated html @return string|array
[ "Creates", "and", "returns", "meta", "tags" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Template.php#L78-L100
7,502
tekkla/core-framework
Core/Framework/Page/Template.php
Template.getTitle
final protected function getTitle($data_only = false) { if ($data_only) { return $this->page->getTitle(); } return PHP_EOL . '<title>' . $this->page->getTitle() . '</title>'; }
php
final protected function getTitle($data_only = false) { if ($data_only) { return $this->page->getTitle(); } return PHP_EOL . '<title>' . $this->page->getTitle() . '</title>'; }
[ "final", "protected", "function", "getTitle", "(", "$", "data_only", "=", "false", ")", "{", "if", "(", "$", "data_only", ")", "{", "return", "$", "this", "->", "page", "->", "getTitle", "(", ")", ";", "}", "return", "PHP_EOL", ".", "'<title>'", ".", "$", "this", "->", "page", "->", "getTitle", "(", ")", ".", "'</title>'", ";", "}" ]
Creates and returns the title tag @param boolean $data_only Set to true if you want to get get only the data without a generated html @return string|array
[ "Creates", "and", "returns", "the", "title", "tag" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Template.php#L110-L117
7,503
tekkla/core-framework
Core/Framework/Page/Template.php
Template.getOpenGraph
final protected function getOpenGraph($data_only = false) { $og_stack = $this->page->og->getTags(); if ($data_only) { return $og_stack; } $html = ''; foreach ($og_stack as $property => $content) { $html .= '<meta property="' . $property . '" content="' . $content . '">' . PHP_EOL; } return $html; }
php
final protected function getOpenGraph($data_only = false) { $og_stack = $this->page->og->getTags(); if ($data_only) { return $og_stack; } $html = ''; foreach ($og_stack as $property => $content) { $html .= '<meta property="' . $property . '" content="' . $content . '">' . PHP_EOL; } return $html; }
[ "final", "protected", "function", "getOpenGraph", "(", "$", "data_only", "=", "false", ")", "{", "$", "og_stack", "=", "$", "this", "->", "page", "->", "og", "->", "getTags", "(", ")", ";", "if", "(", "$", "data_only", ")", "{", "return", "$", "og_stack", ";", "}", "$", "html", "=", "''", ";", "foreach", "(", "$", "og_stack", "as", "$", "property", "=>", "$", "content", ")", "{", "$", "html", ".=", "'<meta property=\"'", ".", "$", "property", ".", "'\" content=\"'", ".", "$", "content", ".", "'\">'", ".", "PHP_EOL", ";", "}", "return", "$", "html", ";", "}" ]
Creates and return OpenGraph tags @param boolean $data_only Set to true if you want to get get only the data without a generated html @return string|array
[ "Creates", "and", "return", "OpenGraph", "tags" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Template.php#L139-L154
7,504
tekkla/core-framework
Core/Framework/Page/Template.php
Template.getCss
final protected function getCss($data_only = false) { $files = $this->page->css->getFiles(); if ($data_only) { return $files; } $html = ''; // Start reading foreach ($files as $file) { $html .= PHP_EOL . '<link rel="stylesheet" type="text/css" href="' . $file . '">'; } return $html; }
php
final protected function getCss($data_only = false) { $files = $this->page->css->getFiles(); if ($data_only) { return $files; } $html = ''; // Start reading foreach ($files as $file) { $html .= PHP_EOL . '<link rel="stylesheet" type="text/css" href="' . $file . '">'; } return $html; }
[ "final", "protected", "function", "getCss", "(", "$", "data_only", "=", "false", ")", "{", "$", "files", "=", "$", "this", "->", "page", "->", "css", "->", "getFiles", "(", ")", ";", "if", "(", "$", "data_only", ")", "{", "return", "$", "files", ";", "}", "$", "html", "=", "''", ";", "// Start reading", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "html", ".=", "PHP_EOL", ".", "'<link rel=\"stylesheet\" type=\"text/css\" href=\"'", ".", "$", "file", ".", "'\">'", ";", "}", "return", "$", "html", ";", "}" ]
Creates and returns all css realted content @param boolean $data_only Set to true if you want to get get only the data without a generated html @return string|array
[ "Creates", "and", "returns", "all", "css", "realted", "content" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Template.php#L164-L180
7,505
tekkla/core-framework
Core/Framework/Page/Template.php
Template.getScript
final protected function getScript($area, $data_only = false) { $files = $this->page->js->getFiles($area); if ($data_only) { return $files; } // Init output var $html = ''; // Create files foreach ($files as $file) { // Create script html object $html .= PHP_EOL . '<script src="' . $file . '"></script>'; } return $html; }
php
final protected function getScript($area, $data_only = false) { $files = $this->page->js->getFiles($area); if ($data_only) { return $files; } // Init output var $html = ''; // Create files foreach ($files as $file) { // Create script html object $html .= PHP_EOL . '<script src="' . $file . '"></script>'; } return $html; }
[ "final", "protected", "function", "getScript", "(", "$", "area", ",", "$", "data_only", "=", "false", ")", "{", "$", "files", "=", "$", "this", "->", "page", "->", "js", "->", "getFiles", "(", "$", "area", ")", ";", "if", "(", "$", "data_only", ")", "{", "return", "$", "files", ";", "}", "// Init output var", "$", "html", "=", "''", ";", "// Create files", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "// Create script html object", "$", "html", ".=", "PHP_EOL", ".", "'<script src=\"'", ".", "$", "file", ".", "'\"></script>'", ";", "}", "return", "$", "html", ";", "}" ]
Creates and returns js script stuff for the requested area. @param string $area Valid areas are 'top' and 'below'. @param boolean $data_only Set to true if you want to get get only the data without a generated html @return string|array
[ "Creates", "and", "returns", "js", "script", "stuff", "for", "the", "requested", "area", "." ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Template.php#L192-L211
7,506
tekkla/core-framework
Core/Framework/Page/Template.php
Template.getHeadLinks
final protected function getHeadLinks($data_only = false) { $link_stack = $this->page->link->getLinkStack(); if ($data_only) { return $link_stack; } $html = ''; foreach ($link_stack as $link) { $html .= PHP_EOL . '<link'; foreach ($link as $attribute => $value) { $html .= ' ' . $attribute . '="' . $value . '"'; } $html .= '>'; } return $html; }
php
final protected function getHeadLinks($data_only = false) { $link_stack = $this->page->link->getLinkStack(); if ($data_only) { return $link_stack; } $html = ''; foreach ($link_stack as $link) { $html .= PHP_EOL . '<link'; foreach ($link as $attribute => $value) { $html .= ' ' . $attribute . '="' . $value . '"'; } $html .= '>'; } return $html; }
[ "final", "protected", "function", "getHeadLinks", "(", "$", "data_only", "=", "false", ")", "{", "$", "link_stack", "=", "$", "this", "->", "page", "->", "link", "->", "getLinkStack", "(", ")", ";", "if", "(", "$", "data_only", ")", "{", "return", "$", "link_stack", ";", "}", "$", "html", "=", "''", ";", "foreach", "(", "$", "link_stack", "as", "$", "link", ")", "{", "$", "html", ".=", "PHP_EOL", ".", "'<link'", ";", "foreach", "(", "$", "link", "as", "$", "attribute", "=>", "$", "value", ")", "{", "$", "html", ".=", "' '", ".", "$", "attribute", ".", "'=\"'", ".", "$", "value", ".", "'\"'", ";", "}", "$", "html", ".=", "'>'", ";", "}", "return", "$", "html", ";", "}" ]
Create and returns head link elements @param boolean $data_only Set to true if you want to get get only the data without a generated html @return string|array
[ "Create", "and", "returns", "head", "link", "elements" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Template.php#L221-L243
7,507
tekkla/core-framework
Core/Framework/Page/Template.php
Template.getMessages
final protected function getMessages($data_only = false, $container = 'container') { $messages = $this->page->message->getAll(); if ($data_only) { return $messages; } ob_start(); echo '<div id="core-message"', ($container ? ' class="' . $container . '"' : ''), '>'; /* @var $msg \Core\Message\Message */ foreach ($messages as $msg) { echo PHP_EOL, ' <div class="alert alert-', $msg->getType(), $msg->getDismissable() ? ' alert-dismissable' : ''; // Fadeout message? #if ($this->config->get('Core', 'js.style.fadeout_time') > 0 && $msg->getFadeout()) { # echo ' fadeout'; #} echo '"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button> ', $msg->getMessage(), ' </div>'; } echo '</div>'; return ob_get_clean(); }
php
final protected function getMessages($data_only = false, $container = 'container') { $messages = $this->page->message->getAll(); if ($data_only) { return $messages; } ob_start(); echo '<div id="core-message"', ($container ? ' class="' . $container . '"' : ''), '>'; /* @var $msg \Core\Message\Message */ foreach ($messages as $msg) { echo PHP_EOL, ' <div class="alert alert-', $msg->getType(), $msg->getDismissable() ? ' alert-dismissable' : ''; // Fadeout message? #if ($this->config->get('Core', 'js.style.fadeout_time') > 0 && $msg->getFadeout()) { # echo ' fadeout'; #} echo '"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button> ', $msg->getMessage(), ' </div>'; } echo '</div>'; return ob_get_clean(); }
[ "final", "protected", "function", "getMessages", "(", "$", "data_only", "=", "false", ",", "$", "container", "=", "'container'", ")", "{", "$", "messages", "=", "$", "this", "->", "page", "->", "message", "->", "getAll", "(", ")", ";", "if", "(", "$", "data_only", ")", "{", "return", "$", "messages", ";", "}", "ob_start", "(", ")", ";", "echo", "'<div id=\"core-message\"'", ",", "(", "$", "container", "?", "' class=\"'", ".", "$", "container", ".", "'\"'", ":", "''", ")", ",", "'>'", ";", "/* @var $msg \\Core\\Message\\Message */", "foreach", "(", "$", "messages", "as", "$", "msg", ")", "{", "echo", "PHP_EOL", ",", "'\n <div class=\"alert alert-'", ",", "$", "msg", "->", "getType", "(", ")", ",", "$", "msg", "->", "getDismissable", "(", ")", "?", "' alert-dismissable'", ":", "''", ";", "// Fadeout message?", "#if ($this->config->get('Core', 'js.style.fadeout_time') > 0 && $msg->getFadeout()) {", "# echo ' fadeout';", "#}", "echo", "'\">\n <button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>\n '", ",", "$", "msg", "->", "getMessage", "(", ")", ",", "'\n </div>'", ";", "}", "echo", "'</div>'", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
Creates and returns stored messages @param boolean $data_only Set to true if you want to get get only the data without a generated html @return string|array
[ "Creates", "and", "returns", "stored", "messages" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Template.php#L253-L285
7,508
tekkla/core-framework
Core/Framework/Page/Template.php
Template.getBreadcrumbs
final protected function getBreadcrumbs($data_only = false) { $breadcrumbs = $this->page->breadcrumbs->getBreadcrumbs(); if ($data_only) { return $breadcrumbs; } // Add home button $text = $this->page->txt('home'); if ($breadcrumbs) { $home_crumb = $this->page->breadcrumbs->createItem($text, BASEURL, $text); } else { $home_crumb = $this->page->breadcrumbs->createActiveItem($text, $text); } array_unshift($breadcrumbs, $home_crumb); ob_start(); if ($breadcrumbs) { echo '<ol class="breadcrumb">'; foreach ($breadcrumbs as $breadcrumb) { echo '<li'; if ($breadcrumb->getActive()) { echo ' class="active">' . $breadcrumb->getText(); } else { echo '><a href="' . $breadcrumb->getHref() . '">' . $breadcrumb->getText() . '</a>'; } echo '</li>'; } echo '</ol>'; } return ob_get_clean(); }
php
final protected function getBreadcrumbs($data_only = false) { $breadcrumbs = $this->page->breadcrumbs->getBreadcrumbs(); if ($data_only) { return $breadcrumbs; } // Add home button $text = $this->page->txt('home'); if ($breadcrumbs) { $home_crumb = $this->page->breadcrumbs->createItem($text, BASEURL, $text); } else { $home_crumb = $this->page->breadcrumbs->createActiveItem($text, $text); } array_unshift($breadcrumbs, $home_crumb); ob_start(); if ($breadcrumbs) { echo '<ol class="breadcrumb">'; foreach ($breadcrumbs as $breadcrumb) { echo '<li'; if ($breadcrumb->getActive()) { echo ' class="active">' . $breadcrumb->getText(); } else { echo '><a href="' . $breadcrumb->getHref() . '">' . $breadcrumb->getText() . '</a>'; } echo '</li>'; } echo '</ol>'; } return ob_get_clean(); }
[ "final", "protected", "function", "getBreadcrumbs", "(", "$", "data_only", "=", "false", ")", "{", "$", "breadcrumbs", "=", "$", "this", "->", "page", "->", "breadcrumbs", "->", "getBreadcrumbs", "(", ")", ";", "if", "(", "$", "data_only", ")", "{", "return", "$", "breadcrumbs", ";", "}", "// Add home button", "$", "text", "=", "$", "this", "->", "page", "->", "txt", "(", "'home'", ")", ";", "if", "(", "$", "breadcrumbs", ")", "{", "$", "home_crumb", "=", "$", "this", "->", "page", "->", "breadcrumbs", "->", "createItem", "(", "$", "text", ",", "BASEURL", ",", "$", "text", ")", ";", "}", "else", "{", "$", "home_crumb", "=", "$", "this", "->", "page", "->", "breadcrumbs", "->", "createActiveItem", "(", "$", "text", ",", "$", "text", ")", ";", "}", "array_unshift", "(", "$", "breadcrumbs", ",", "$", "home_crumb", ")", ";", "ob_start", "(", ")", ";", "if", "(", "$", "breadcrumbs", ")", "{", "echo", "'<ol class=\"breadcrumb\">'", ";", "foreach", "(", "$", "breadcrumbs", "as", "$", "breadcrumb", ")", "{", "echo", "'<li'", ";", "if", "(", "$", "breadcrumb", "->", "getActive", "(", ")", ")", "{", "echo", "' class=\"active\">'", ".", "$", "breadcrumb", "->", "getText", "(", ")", ";", "}", "else", "{", "echo", "'><a href=\"'", ".", "$", "breadcrumb", "->", "getHref", "(", ")", ".", "'\">'", ".", "$", "breadcrumb", "->", "getText", "(", ")", ".", "'</a>'", ";", "}", "echo", "'</li>'", ";", "}", "echo", "'</ol>'", ";", "}", "return", "ob_get_clean", "(", ")", ";", "}" ]
Creates breadcrumb html content or returns it's data- @param boolean $data_only Set to true if you want to get get only the data without a generated html @return string|array
[ "Creates", "breadcrumb", "html", "content", "or", "returns", "it", "s", "data", "-" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Template.php#L295-L339
7,509
tekkla/core-framework
Core/Framework/Page/Template.php
Template.getContent
final protected function getContent($data_only = false, $fluid = false) { if ($data_only) { return $this->page->getContent(); } return '<div id="content" class="container' . ($fluid ? '-fluid' : '') . '">' . $this->page->getContent() . '</div>'; }
php
final protected function getContent($data_only = false, $fluid = false) { if ($data_only) { return $this->page->getContent(); } return '<div id="content" class="container' . ($fluid ? '-fluid' : '') . '">' . $this->page->getContent() . '</div>'; }
[ "final", "protected", "function", "getContent", "(", "$", "data_only", "=", "false", ",", "$", "fluid", "=", "false", ")", "{", "if", "(", "$", "data_only", ")", "{", "return", "$", "this", "->", "page", "->", "getContent", "(", ")", ";", "}", "return", "'<div id=\"content\" class=\"container'", ".", "(", "$", "fluid", "?", "'-fluid'", ":", "''", ")", ".", "'\">'", ".", "$", "this", "->", "page", "->", "getContent", "(", ")", ".", "'</div>'", ";", "}" ]
Returns the content generated by app call
[ "Returns", "the", "content", "generated", "by", "app", "call" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Template.php#L384-L391
7,510
sebardo/ecommerce
EcommerceBundle/Controller/TransactionController.php
TransactionController.showAction
public function showAction($id) { $em = $this->getDoctrine()->getManager(); /** @var Transaction $entity */ $entity = $em->getRepository('EcommerceBundle:Transaction')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Transaction entity.'); } /** @var CheckoutManager $checkoutManager */ $checkoutManager = $this->get('checkout_manager'); $totals = $checkoutManager->calculateTotals($entity, $entity->getDelivery()); return array( 'entity' => $entity, 'totals' => $totals, ); }
php
public function showAction($id) { $em = $this->getDoctrine()->getManager(); /** @var Transaction $entity */ $entity = $em->getRepository('EcommerceBundle:Transaction')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Transaction entity.'); } /** @var CheckoutManager $checkoutManager */ $checkoutManager = $this->get('checkout_manager'); $totals = $checkoutManager->calculateTotals($entity, $entity->getDelivery()); return array( 'entity' => $entity, 'totals' => $totals, ); }
[ "public", "function", "showAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Transaction $entity */", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Transaction'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Transaction entity.'", ")", ";", "}", "/** @var CheckoutManager $checkoutManager */", "$", "checkoutManager", "=", "$", "this", "->", "get", "(", "'checkout_manager'", ")", ";", "$", "totals", "=", "$", "checkoutManager", "->", "calculateTotals", "(", "$", "entity", ",", "$", "entity", "->", "getDelivery", "(", ")", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'totals'", "=>", "$", "totals", ",", ")", ";", "}" ]
Finds and displays an Transaction entity. @param int $id The entity id @throws NotFoundHttpException @return array @Route("/{id}") @Method("GET") @Template
[ "Finds", "and", "displays", "an", "Transaction", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/TransactionController.php#L138-L158
7,511
sebardo/ecommerce
EcommerceBundle/Controller/TransactionController.php
TransactionController.authorizePaymentAction
public function authorizePaymentAction($id) { $em = $this->getDoctrine()->getManager(); /** @var Transaction $entity */ $entity = $em->getRepository('EcommerceBundle:Transaction')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Transaction entity.'); } $entity->setStatus(Transaction::STATUS_PAID); $em->persist($entity); $em->flush(); //send email $this->get('core.mailer')->sendBankTransferConfirmation($entity); $this->get('checkout_manager')->sendToTransport($entity); $this->get('session')->getFlashBag()->add('success', 'order.authorized.payment'); return $this->redirect($this->generateUrl('ecommerce_transaction_show', array('id' => $entity->getId()))); }
php
public function authorizePaymentAction($id) { $em = $this->getDoctrine()->getManager(); /** @var Transaction $entity */ $entity = $em->getRepository('EcommerceBundle:Transaction')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Transaction entity.'); } $entity->setStatus(Transaction::STATUS_PAID); $em->persist($entity); $em->flush(); //send email $this->get('core.mailer')->sendBankTransferConfirmation($entity); $this->get('checkout_manager')->sendToTransport($entity); $this->get('session')->getFlashBag()->add('success', 'order.authorized.payment'); return $this->redirect($this->generateUrl('ecommerce_transaction_show', array('id' => $entity->getId()))); }
[ "public", "function", "authorizePaymentAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Transaction $entity */", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Transaction'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Transaction entity.'", ")", ";", "}", "$", "entity", "->", "setStatus", "(", "Transaction", "::", "STATUS_PAID", ")", ";", "$", "em", "->", "persist", "(", "$", "entity", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "//send email", "$", "this", "->", "get", "(", "'core.mailer'", ")", "->", "sendBankTransferConfirmation", "(", "$", "entity", ")", ";", "$", "this", "->", "get", "(", "'checkout_manager'", ")", "->", "sendToTransport", "(", "$", "entity", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'order.authorized.payment'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_transaction_show'", ",", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ")", ";", "}" ]
Authorizes the payment of a pending transfer order @param int $id @throws NotFoundHttpException @return RedirectResponse @Route("/{id}/authorize-payment") @Method("GET")
[ "Authorizes", "the", "payment", "of", "a", "pending", "transfer", "order" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/TransactionController.php#L171-L194
7,512
sebardo/ecommerce
EcommerceBundle/Controller/TransactionController.php
TransactionController.deleteAction
public function deleteAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('EcommerceBundle:Transaction')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Transaction entity.'); } $em->remove($entity); $em->flush(); $this->get('session')->getFlashBag()->add('info', 'transaction.deleted'); return array(); }
php
public function deleteAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('EcommerceBundle:Transaction')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Transaction entity.'); } $em->remove($entity); $em->flush(); $this->get('session')->getFlashBag()->add('info', 'transaction.deleted'); return array(); }
[ "public", "function", "deleteAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Transaction'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Transaction entity.'", ")", ";", "}", "$", "em", "->", "remove", "(", "$", "entity", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'info'", ",", "'transaction.deleted'", ")", ";", "return", "array", "(", ")", ";", "}" ]
Deletes a Transaction entity. @param int $id The order id @throws NotFoundHttpException @return array @Route("/{id}/delete") @Method("GET") @Template("EcommerceBundle:Transaction:index.html.twig")
[ "Deletes", "a", "Transaction", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/TransactionController.php#L321-L337
7,513
Niirrty/Niirrty.IO
src/FolderAccessException.php
FolderAccessException.Read
public static function Read( string $folder, string $message = null, int $code = \E_USER_ERROR, \Throwable $previous = null ) : FolderAccessException { return new FolderAccessException ( $folder, FolderAccessException::ACCESS_READ, $message, $code, $previous ); }
php
public static function Read( string $folder, string $message = null, int $code = \E_USER_ERROR, \Throwable $previous = null ) : FolderAccessException { return new FolderAccessException ( $folder, FolderAccessException::ACCESS_READ, $message, $code, $previous ); }
[ "public", "static", "function", "Read", "(", "string", "$", "folder", ",", "string", "$", "message", "=", "null", ",", "int", "$", "code", "=", "\\", "E_USER_ERROR", ",", "\\", "Throwable", "$", "previous", "=", "null", ")", ":", "FolderAccessException", "{", "return", "new", "FolderAccessException", "(", "$", "folder", ",", "FolderAccessException", "::", "ACCESS_READ", ",", "$", "message", ",", "$", "code", ",", "$", "previous", ")", ";", "}" ]
Inits a new \Niirrty\IO\FolderAccessException for folder read mode. @param string $folder The folder where reading fails. @param string $message The optional error message. @param integer $code A optional error code (Defaults to \E_USER_ERROR) @param \Throwable $previous A Optional previous exception. @return \Niirrty\IO\FolderAccessException
[ "Inits", "a", "new", "\\", "Niirrty", "\\", "IO", "\\", "FolderAccessException", "for", "folder", "read", "mode", "." ]
13a19de41d3002d76771b3f2c85a1158a863a78e
https://github.com/Niirrty/Niirrty.IO/blob/13a19de41d3002d76771b3f2c85a1158a863a78e/src/FolderAccessException.php#L117-L128
7,514
Niirrty/Niirrty.IO
src/FolderAccessException.php
FolderAccessException.Write
public static function Write( string $folder, string $message = null, int $code = \E_USER_ERROR, \Throwable $previous = null ) : FolderAccessException { return new FolderAccessException ( $folder, FolderAccessException::ACCESS_WRITE, $message, $code, $previous ); }
php
public static function Write( string $folder, string $message = null, int $code = \E_USER_ERROR, \Throwable $previous = null ) : FolderAccessException { return new FolderAccessException ( $folder, FolderAccessException::ACCESS_WRITE, $message, $code, $previous ); }
[ "public", "static", "function", "Write", "(", "string", "$", "folder", ",", "string", "$", "message", "=", "null", ",", "int", "$", "code", "=", "\\", "E_USER_ERROR", ",", "\\", "Throwable", "$", "previous", "=", "null", ")", ":", "FolderAccessException", "{", "return", "new", "FolderAccessException", "(", "$", "folder", ",", "FolderAccessException", "::", "ACCESS_WRITE", ",", "$", "message", ",", "$", "code", ",", "$", "previous", ")", ";", "}" ]
Inits a new \UK\IO\FolderAccessException for folder write mode. @param string $folder The folder where reading fails. @param string $message The optional error message. @param integer $code A optional error code (Defaults to \E_USER_ERROR) @param \Throwable $previous A Optional previous exception. @return \Niirrty\IO\FolderAccessException
[ "Inits", "a", "new", "\\", "UK", "\\", "IO", "\\", "FolderAccessException", "for", "folder", "write", "mode", "." ]
13a19de41d3002d76771b3f2c85a1158a863a78e
https://github.com/Niirrty/Niirrty.IO/blob/13a19de41d3002d76771b3f2c85a1158a863a78e/src/FolderAccessException.php#L139-L150
7,515
tarsana/filesystem
src/File.php
File.create
public function create() { if (! $this->adapter->fileExists($this->path, true)) { // ensure the parent directory exists new Directory(dirname($this->path), $this->adapter); if ($this->adapter->createFile($this->path) === false) { $this->throwUnableToCreate(); } } return $this; }
php
public function create() { if (! $this->adapter->fileExists($this->path, true)) { // ensure the parent directory exists new Directory(dirname($this->path), $this->adapter); if ($this->adapter->createFile($this->path) === false) { $this->throwUnableToCreate(); } } return $this; }
[ "public", "function", "create", "(", ")", "{", "if", "(", "!", "$", "this", "->", "adapter", "->", "fileExists", "(", "$", "this", "->", "path", ",", "true", ")", ")", "{", "// ensure the parent directory exists", "new", "Directory", "(", "dirname", "(", "$", "this", "->", "path", ")", ",", "$", "this", "->", "adapter", ")", ";", "if", "(", "$", "this", "->", "adapter", "->", "createFile", "(", "$", "this", "->", "path", ")", "===", "false", ")", "{", "$", "this", "->", "throwUnableToCreate", "(", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Creates the file if it doesn't exist. @return self
[ "Creates", "the", "file", "if", "it", "doesn", "t", "exist", "." ]
db6c8f040af38dfb01066e382645aff6c72530fa
https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/File.php#L25-L37
7,516
tarsana/filesystem
src/File.php
File.copyAs
public function copyAs($dest) { $copy = new File($dest, $this->adapter); $copy->content($this->content()); return $copy; }
php
public function copyAs($dest) { $copy = new File($dest, $this->adapter); $copy->content($this->content()); return $copy; }
[ "public", "function", "copyAs", "(", "$", "dest", ")", "{", "$", "copy", "=", "new", "File", "(", "$", "dest", ",", "$", "this", "->", "adapter", ")", ";", "$", "copy", "->", "content", "(", "$", "this", "->", "content", "(", ")", ")", ";", "return", "$", "copy", ";", "}" ]
Copies the file to the provided destination and returns the copy. @param string $dest @return self @throws Tarsana\Filesystem\Exceptions\FilesystemException if unable to create the destination file.
[ "Copies", "the", "file", "to", "the", "provided", "destination", "and", "returns", "the", "copy", "." ]
db6c8f040af38dfb01066e382645aff6c72530fa
https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/File.php#L68-L73
7,517
tarsana/filesystem
src/File.php
File.content
public function content($content = false) { if ($content === false) { return $this->adapter->fileGetContents($this->path); } $this->adapter->filePutContents($this->path, $content); return $this; }
php
public function content($content = false) { if ($content === false) { return $this->adapter->fileGetContents($this->path); } $this->adapter->filePutContents($this->path, $content); return $this; }
[ "public", "function", "content", "(", "$", "content", "=", "false", ")", "{", "if", "(", "$", "content", "===", "false", ")", "{", "return", "$", "this", "->", "adapter", "->", "fileGetContents", "(", "$", "this", "->", "path", ")", ";", "}", "$", "this", "->", "adapter", "->", "filePutContents", "(", "$", "this", "->", "path", ",", "$", "content", ")", ";", "return", "$", "this", ";", "}" ]
Gets or sets the content of the file. @param string $content @return string|self
[ "Gets", "or", "sets", "the", "content", "of", "the", "file", "." ]
db6c8f040af38dfb01066e382645aff6c72530fa
https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/File.php#L91-L99
7,518
tarsana/filesystem
src/File.php
File.append
public function append($content) { if ($this->adapter->filePutContents($this->path, $content, FILE_APPEND) === false) { throw new FilesystemException("Cannot append content to the file '{$this->path}'"); } return $this; }
php
public function append($content) { if ($this->adapter->filePutContents($this->path, $content, FILE_APPEND) === false) { throw new FilesystemException("Cannot append content to the file '{$this->path}'"); } return $this; }
[ "public", "function", "append", "(", "$", "content", ")", "{", "if", "(", "$", "this", "->", "adapter", "->", "filePutContents", "(", "$", "this", "->", "path", ",", "$", "content", ",", "FILE_APPEND", ")", "===", "false", ")", "{", "throw", "new", "FilesystemException", "(", "\"Cannot append content to the file '{$this->path}'\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Appends a content to the file. @param string $content @return self @throws Tarsana\Filesystem\Exceptions\FilesystemException if unable to append the content.
[ "Appends", "a", "content", "to", "the", "file", "." ]
db6c8f040af38dfb01066e382645aff6c72530fa
https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/File.php#L109-L115
7,519
tarsana/filesystem
src/File.php
File.extension
public function extension($extension = false) { if($extension === false) { return $this->adapter->extension($this->path); } $newName = $this->name(); $index = strrpos($newName, '.'); if ($index !== false) { $newName = substr($newName, 0, $index + 1); } else { $newName .= '.'; } $newName .= $extension; return $this->name($newName); }
php
public function extension($extension = false) { if($extension === false) { return $this->adapter->extension($this->path); } $newName = $this->name(); $index = strrpos($newName, '.'); if ($index !== false) { $newName = substr($newName, 0, $index + 1); } else { $newName .= '.'; } $newName .= $extension; return $this->name($newName); }
[ "public", "function", "extension", "(", "$", "extension", "=", "false", ")", "{", "if", "(", "$", "extension", "===", "false", ")", "{", "return", "$", "this", "->", "adapter", "->", "extension", "(", "$", "this", "->", "path", ")", ";", "}", "$", "newName", "=", "$", "this", "->", "name", "(", ")", ";", "$", "index", "=", "strrpos", "(", "$", "newName", ",", "'.'", ")", ";", "if", "(", "$", "index", "!==", "false", ")", "{", "$", "newName", "=", "substr", "(", "$", "newName", ",", "0", ",", "$", "index", "+", "1", ")", ";", "}", "else", "{", "$", "newName", ".=", "'.'", ";", "}", "$", "newName", ".=", "$", "extension", ";", "return", "$", "this", "->", "name", "(", "$", "newName", ")", ";", "}" ]
Gets or sets the file extension. @param string $extension @return string|self
[ "Gets", "or", "sets", "the", "file", "extension", "." ]
db6c8f040af38dfb01066e382645aff6c72530fa
https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/File.php#L123-L139
7,520
FDT2k/php-root-object
src/IObject.php
IObject.getImplementations
function getImplementations ($instance){ $rc = new ReflectionClass(get_class($instance)); $interfaces = $rc->getInterfaces(); $i = array(); foreach($interfaces as $name => $crap){ $i[]=$name; } return $i; }
php
function getImplementations ($instance){ $rc = new ReflectionClass(get_class($instance)); $interfaces = $rc->getInterfaces(); $i = array(); foreach($interfaces as $name => $crap){ $i[]=$name; } return $i; }
[ "function", "getImplementations", "(", "$", "instance", ")", "{", "$", "rc", "=", "new", "ReflectionClass", "(", "get_class", "(", "$", "instance", ")", ")", ";", "$", "interfaces", "=", "$", "rc", "->", "getInterfaces", "(", ")", ";", "$", "i", "=", "array", "(", ")", ";", "foreach", "(", "$", "interfaces", "as", "$", "name", "=>", "$", "crap", ")", "{", "$", "i", "[", "]", "=", "$", "name", ";", "}", "return", "$", "i", ";", "}" ]
Get all the parents classes @see IMCoreObject @return array
[ "Get", "all", "the", "parents", "classes" ]
666b2fb69b93fc997ad7ac2ab791fdd5ceab922b
https://github.com/FDT2k/php-root-object/blob/666b2fb69b93fc997ad7ac2ab791fdd5ceab922b/src/IObject.php#L128-L137
7,521
budkit/budkit-framework
src/Budkit/Session/repository/File.php
File.read
public function read($splash, $session, $sessionId) { $ini = new Ini(); $store = $session->folder . DIRECTORY_SEPARATOR; //We need to know the array; if (!is_array($splash)) return false; $sfile = $store . $sessionId . ".ini"; if (!$ini->isFile($sfile)) { //If we can't file the sessionf file; //throw new \Exception("The session file does not exists"); return false; } //Temporarily chmode the file; $ini->chmod($sfile, 0755); if (!$ini->readParams($sfile)) { throw new \Exception("Could not read the session configuration file"); return false; } $sess = $ini->getParams($sfile); if (!is_array($sess) || empty($sess)) { throw new \Exception("Invalid session file"); return false; } //return data as an object; $object = new \stdClass; $object->session_id = $sessionId; $object->session_key = $sess['key']; $object->session_ip = $sess['ip']; $object->session_host = $sess['domain']; $object->session_agent = $sess['agent']; $object->session_token = $sess['token']; $object->session_expires = $sess['expiry']; $object->session_lastactive = $sess['active']; $object->session_registry = $sess['registry']; return $object; }
php
public function read($splash, $session, $sessionId) { $ini = new Ini(); $store = $session->folder . DIRECTORY_SEPARATOR; //We need to know the array; if (!is_array($splash)) return false; $sfile = $store . $sessionId . ".ini"; if (!$ini->isFile($sfile)) { //If we can't file the sessionf file; //throw new \Exception("The session file does not exists"); return false; } //Temporarily chmode the file; $ini->chmod($sfile, 0755); if (!$ini->readParams($sfile)) { throw new \Exception("Could not read the session configuration file"); return false; } $sess = $ini->getParams($sfile); if (!is_array($sess) || empty($sess)) { throw new \Exception("Invalid session file"); return false; } //return data as an object; $object = new \stdClass; $object->session_id = $sessionId; $object->session_key = $sess['key']; $object->session_ip = $sess['ip']; $object->session_host = $sess['domain']; $object->session_agent = $sess['agent']; $object->session_token = $sess['token']; $object->session_expires = $sess['expiry']; $object->session_lastactive = $sess['active']; $object->session_registry = $sess['registry']; return $object; }
[ "public", "function", "read", "(", "$", "splash", ",", "$", "session", ",", "$", "sessionId", ")", "{", "$", "ini", "=", "new", "Ini", "(", ")", ";", "$", "store", "=", "$", "session", "->", "folder", ".", "DIRECTORY_SEPARATOR", ";", "//We need to know the array;", "if", "(", "!", "is_array", "(", "$", "splash", ")", ")", "return", "false", ";", "$", "sfile", "=", "$", "store", ".", "$", "sessionId", ".", "\".ini\"", ";", "if", "(", "!", "$", "ini", "->", "isFile", "(", "$", "sfile", ")", ")", "{", "//If we can't file the sessionf file;", "//throw new \\Exception(\"The session file does not exists\");", "return", "false", ";", "}", "//Temporarily chmode the file;", "$", "ini", "->", "chmod", "(", "$", "sfile", ",", "0755", ")", ";", "if", "(", "!", "$", "ini", "->", "readParams", "(", "$", "sfile", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Could not read the session configuration file\"", ")", ";", "return", "false", ";", "}", "$", "sess", "=", "$", "ini", "->", "getParams", "(", "$", "sfile", ")", ";", "if", "(", "!", "is_array", "(", "$", "sess", ")", "||", "empty", "(", "$", "sess", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid session file\"", ")", ";", "return", "false", ";", "}", "//return data as an object;", "$", "object", "=", "new", "\\", "stdClass", ";", "$", "object", "->", "session_id", "=", "$", "sessionId", ";", "$", "object", "->", "session_key", "=", "$", "sess", "[", "'key'", "]", ";", "$", "object", "->", "session_ip", "=", "$", "sess", "[", "'ip'", "]", ";", "$", "object", "->", "session_host", "=", "$", "sess", "[", "'domain'", "]", ";", "$", "object", "->", "session_agent", "=", "$", "sess", "[", "'agent'", "]", ";", "$", "object", "->", "session_token", "=", "$", "sess", "[", "'token'", "]", ";", "$", "object", "->", "session_expires", "=", "$", "sess", "[", "'expiry'", "]", ";", "$", "object", "->", "session_lastactive", "=", "$", "sess", "[", "'active'", "]", ";", "$", "object", "->", "session_registry", "=", "$", "sess", "[", "'registry'", "]", ";", "return", "$", "object", ";", "}" ]
Reads session data from file @param type $splash @param type $session @param type $sessionId
[ "Reads", "session", "data", "from", "file" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/repository/File.php#L55-L102
7,522
budkit/budkit-framework
src/Budkit/Session/repository/File.php
File.write
public function write($userdata, $splash, $session, $sessionId, $expiry) { $ini = new Ini(); $store = $session->folder . DIRECTORY_SEPARATOR; if (!$ini->is($store)) { if (!$ini->create($store)) { throw new \Exception("Could not create the $store folder. Please create this manually and check it hass writable permissions"); return false; } } //We need to know the array; if (!is_array($splash)) return false; $sfile = $store . $sessionId . ".ini"; //We create the session file; if (!($sini = $ini->create($sfile))) { throw new \Exception("Could not create the session file"); return false; } //Temporarily chmode the file; $ini->chmod($sfile, 0755); $splash['expiry'] = $expiry; $splash['active'] = time(); $splash['key'] = $sessionId; $splash['registry'] = static::quote("'" . $userdata . "'"); //Now write to file if (!$ini->write($sfile, $ini->toIniString($splash))) { throw new \Exception("Could not write out to the configuration file"); return false; } return true; }
php
public function write($userdata, $splash, $session, $sessionId, $expiry) { $ini = new Ini(); $store = $session->folder . DIRECTORY_SEPARATOR; if (!$ini->is($store)) { if (!$ini->create($store)) { throw new \Exception("Could not create the $store folder. Please create this manually and check it hass writable permissions"); return false; } } //We need to know the array; if (!is_array($splash)) return false; $sfile = $store . $sessionId . ".ini"; //We create the session file; if (!($sini = $ini->create($sfile))) { throw new \Exception("Could not create the session file"); return false; } //Temporarily chmode the file; $ini->chmod($sfile, 0755); $splash['expiry'] = $expiry; $splash['active'] = time(); $splash['key'] = $sessionId; $splash['registry'] = static::quote("'" . $userdata . "'"); //Now write to file if (!$ini->write($sfile, $ini->toIniString($splash))) { throw new \Exception("Could not write out to the configuration file"); return false; } return true; }
[ "public", "function", "write", "(", "$", "userdata", ",", "$", "splash", ",", "$", "session", ",", "$", "sessionId", ",", "$", "expiry", ")", "{", "$", "ini", "=", "new", "Ini", "(", ")", ";", "$", "store", "=", "$", "session", "->", "folder", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "$", "ini", "->", "is", "(", "$", "store", ")", ")", "{", "if", "(", "!", "$", "ini", "->", "create", "(", "$", "store", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Could not create the $store folder. Please create this manually and check it hass writable permissions\"", ")", ";", "return", "false", ";", "}", "}", "//We need to know the array;", "if", "(", "!", "is_array", "(", "$", "splash", ")", ")", "return", "false", ";", "$", "sfile", "=", "$", "store", ".", "$", "sessionId", ".", "\".ini\"", ";", "//We create the session file;", "if", "(", "!", "(", "$", "sini", "=", "$", "ini", "->", "create", "(", "$", "sfile", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Could not create the session file\"", ")", ";", "return", "false", ";", "}", "//Temporarily chmode the file;", "$", "ini", "->", "chmod", "(", "$", "sfile", ",", "0755", ")", ";", "$", "splash", "[", "'expiry'", "]", "=", "$", "expiry", ";", "$", "splash", "[", "'active'", "]", "=", "time", "(", ")", ";", "$", "splash", "[", "'key'", "]", "=", "$", "sessionId", ";", "$", "splash", "[", "'registry'", "]", "=", "static", "::", "quote", "(", "\"'\"", ".", "$", "userdata", ".", "\"'\"", ")", ";", "//Now write to file", "if", "(", "!", "$", "ini", "->", "write", "(", "$", "sfile", ",", "$", "ini", "->", "toIniString", "(", "$", "splash", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Could not write out to the configuration file\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Writes session data to file store @param type $userdata @param type $splash @param type $session @param type $sessionId @param type $expiry
[ "Writes", "session", "data", "to", "file", "store" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/repository/File.php#L134-L174
7,523
SymBB/symbb
src/Symbb/Core/ForumBundle/Security/Authorization/ForumVoter.php
ForumVoter.getGroupedAttributes
public function getGroupedAttributes() { return array( AbstractVoter::GROUP_USER => array( self::VIEW, self::CREATE_POST, self::CREATE_TOPIC, self::UPLOAD_FILE ), AbstractVoter::GROUP_MOD => array( self::EDIT_POST, self::EDIT_TOPIC, self::DELETE_POST, self::DELETE_TOPIC, self::MOVE_POST, self::MOVE_TOPIC, self::SPLIT_TOPIC, ) ); }
php
public function getGroupedAttributes() { return array( AbstractVoter::GROUP_USER => array( self::VIEW, self::CREATE_POST, self::CREATE_TOPIC, self::UPLOAD_FILE ), AbstractVoter::GROUP_MOD => array( self::EDIT_POST, self::EDIT_TOPIC, self::DELETE_POST, self::DELETE_TOPIC, self::MOVE_POST, self::MOVE_TOPIC, self::SPLIT_TOPIC, ) ); }
[ "public", "function", "getGroupedAttributes", "(", ")", "{", "return", "array", "(", "AbstractVoter", "::", "GROUP_USER", "=>", "array", "(", "self", "::", "VIEW", ",", "self", "::", "CREATE_POST", ",", "self", "::", "CREATE_TOPIC", ",", "self", "::", "UPLOAD_FILE", ")", ",", "AbstractVoter", "::", "GROUP_MOD", "=>", "array", "(", "self", "::", "EDIT_POST", ",", "self", "::", "EDIT_TOPIC", ",", "self", "::", "DELETE_POST", ",", "self", "::", "DELETE_TOPIC", ",", "self", "::", "MOVE_POST", ",", "self", "::", "MOVE_TOPIC", ",", "self", "::", "SPLIT_TOPIC", ",", ")", ")", ";", "}" ]
this will define the groups for the acl form later @return array
[ "this", "will", "define", "the", "groups", "for", "the", "acl", "form", "later" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/ForumBundle/Security/Authorization/ForumVoter.php#L36-L55
7,524
SymBB/symbb
src/Symbb/Core/ForumBundle/Security/Authorization/ForumVoter.php
ForumVoter.getAccessSets
public function getAccessSets() { $default = array(); $guest = array( self::VIEW ); $user = array_merge($guest, array( self::CREATE_POST, self::CREATE_TOPIC ) ); $userFull = array_merge($user, array( self::UPLOAD_FILE ) ); $mod = array_merge($userFull, array( self::EDIT_POST, self::EDIT_TOPIC, self::DELETE_POST, self::DELETE_TOPIC, self::MOVE_POST, self::MOVE_TOPIC, self::SPLIT_TOPIC, ) ); return array( // no access "default_1" => $default, // readonly "default_2" => $guest, // normal "default_3" => $user, // full (add extension access) "default_4" => $userFull, // moderator "default_5" => $mod ); }
php
public function getAccessSets() { $default = array(); $guest = array( self::VIEW ); $user = array_merge($guest, array( self::CREATE_POST, self::CREATE_TOPIC ) ); $userFull = array_merge($user, array( self::UPLOAD_FILE ) ); $mod = array_merge($userFull, array( self::EDIT_POST, self::EDIT_TOPIC, self::DELETE_POST, self::DELETE_TOPIC, self::MOVE_POST, self::MOVE_TOPIC, self::SPLIT_TOPIC, ) ); return array( // no access "default_1" => $default, // readonly "default_2" => $guest, // normal "default_3" => $user, // full (add extension access) "default_4" => $userFull, // moderator "default_5" => $mod ); }
[ "public", "function", "getAccessSets", "(", ")", "{", "$", "default", "=", "array", "(", ")", ";", "$", "guest", "=", "array", "(", "self", "::", "VIEW", ")", ";", "$", "user", "=", "array_merge", "(", "$", "guest", ",", "array", "(", "self", "::", "CREATE_POST", ",", "self", "::", "CREATE_TOPIC", ")", ")", ";", "$", "userFull", "=", "array_merge", "(", "$", "user", ",", "array", "(", "self", "::", "UPLOAD_FILE", ")", ")", ";", "$", "mod", "=", "array_merge", "(", "$", "userFull", ",", "array", "(", "self", "::", "EDIT_POST", ",", "self", "::", "EDIT_TOPIC", ",", "self", "::", "DELETE_POST", ",", "self", "::", "DELETE_TOPIC", ",", "self", "::", "MOVE_POST", ",", "self", "::", "MOVE_TOPIC", ",", "self", "::", "SPLIT_TOPIC", ",", ")", ")", ";", "return", "array", "(", "// no access", "\"default_1\"", "=>", "$", "default", ",", "// readonly", "\"default_2\"", "=>", "$", "guest", ",", "// normal", "\"default_3\"", "=>", "$", "user", ",", "// full (add extension access)", "\"default_4\"", "=>", "$", "userFull", ",", "// moderator", "\"default_5\"", "=>", "$", "mod", ")", ";", "}" ]
this are the list of default access lists @return array
[ "this", "are", "the", "list", "of", "default", "access", "lists" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/ForumBundle/Security/Authorization/ForumVoter.php#L61-L107
7,525
konservs/brilliant.framework
libraries/Config/BConfigField.php
BConfigField.getVal
public function getVal(){ //Check for re-defined value (for example, by POST query) if(isset($this->value)){ return $this->value; } //Check for define if(defined($this->alias)){ return constant($this->alias); } //If nothing found - return default value return $this->default; }
php
public function getVal(){ //Check for re-defined value (for example, by POST query) if(isset($this->value)){ return $this->value; } //Check for define if(defined($this->alias)){ return constant($this->alias); } //If nothing found - return default value return $this->default; }
[ "public", "function", "getVal", "(", ")", "{", "//Check for re-defined value (for example, by POST query)", "if", "(", "isset", "(", "$", "this", "->", "value", ")", ")", "{", "return", "$", "this", "->", "value", ";", "}", "//Check for define", "if", "(", "defined", "(", "$", "this", "->", "alias", ")", ")", "{", "return", "constant", "(", "$", "this", "->", "alias", ")", ";", "}", "//If nothing found - return default value", "return", "$", "this", "->", "default", ";", "}" ]
Get field value. Check, if the variable is defined and return value, or return default data, if field not defined @return mixed data
[ "Get", "field", "value", ".", "Check", "if", "the", "variable", "is", "defined", "and", "return", "value", "or", "return", "default", "data", "if", "field", "not", "defined" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Config/BConfigField.php#L32-L43
7,526
konservs/brilliant.framework
libraries/Config/BConfigField.php
BConfigField.printbshtml
public function printbshtml(){ $bs=BBoostrapHelper::getInstance(); return $bs->formgroup_input($this->name,$this->alias,$this->getVal(),''); }
php
public function printbshtml(){ $bs=BBoostrapHelper::getInstance(); return $bs->formgroup_input($this->name,$this->alias,$this->getVal(),''); }
[ "public", "function", "printbshtml", "(", ")", "{", "$", "bs", "=", "BBoostrapHelper", "::", "getInstance", "(", ")", ";", "return", "$", "bs", "->", "formgroup_input", "(", "$", "this", "->", "name", ",", "$", "this", "->", "alias", ",", "$", "this", "->", "getVal", "(", ")", ",", "''", ")", ";", "}" ]
Print bootstrap HTML data @return string HTML data
[ "Print", "bootstrap", "HTML", "data" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Config/BConfigField.php#L49-L52
7,527
sgoendoer/sonic
src/Request/AbstractResponse.php
AbstractResponse.getStringForResponseSignature
public function getStringForResponseSignature() { return $this->headers[SONIC_HEADER__TARGET_API] . $this->headers[SONIC_HEADER__DATE] . $this->headers[SONIC_HEADER__PLATFORM_GID] . $this->headers[SONIC_HEADER__SOURCE_GID] . $this->headers[SONIC_HEADER__RANDOM] . $this->body; }
php
public function getStringForResponseSignature() { return $this->headers[SONIC_HEADER__TARGET_API] . $this->headers[SONIC_HEADER__DATE] . $this->headers[SONIC_HEADER__PLATFORM_GID] . $this->headers[SONIC_HEADER__SOURCE_GID] . $this->headers[SONIC_HEADER__RANDOM] . $this->body; }
[ "public", "function", "getStringForResponseSignature", "(", ")", "{", "return", "$", "this", "->", "headers", "[", "SONIC_HEADER__TARGET_API", "]", ".", "$", "this", "->", "headers", "[", "SONIC_HEADER__DATE", "]", ".", "$", "this", "->", "headers", "[", "SONIC_HEADER__PLATFORM_GID", "]", ".", "$", "this", "->", "headers", "[", "SONIC_HEADER__SOURCE_GID", "]", ".", "$", "this", "->", "headers", "[", "SONIC_HEADER__RANDOM", "]", ".", "$", "this", "->", "body", ";", "}" ]
returns string for response signature @return string
[ "returns", "string", "for", "response", "signature" ]
2c32ebd78607dc3e8558f10a0b7bf881d37fc168
https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Request/AbstractResponse.php#L30-L38
7,528
sgoendoer/sonic
src/Request/AbstractResponse.php
AbstractResponse.verifyDataFormat
protected function verifyDataFormat() { // TODO validate data and formats if(!XSDDateTime::validateXSDDateTime($this->headers[SONIC_HEADER__DATE])) throw new MalformedRequestHeaderException("Malformed response: Header " . SONIC_HEADER__DATE . " malformed: " . $this->headers[SONIC_HEADER__DATE]); if(!XSDDateTime::validateXSDDateTime($this->headers[SONIC_HEADER__DATE])) throw new MalformedRequestHeaderException("Malformed response: Header " . SONIC_HEADER__DATE . " malformed: " . $this->headers[SONIC_HEADER__DATE]); return true; }
php
protected function verifyDataFormat() { // TODO validate data and formats if(!XSDDateTime::validateXSDDateTime($this->headers[SONIC_HEADER__DATE])) throw new MalformedRequestHeaderException("Malformed response: Header " . SONIC_HEADER__DATE . " malformed: " . $this->headers[SONIC_HEADER__DATE]); if(!XSDDateTime::validateXSDDateTime($this->headers[SONIC_HEADER__DATE])) throw new MalformedRequestHeaderException("Malformed response: Header " . SONIC_HEADER__DATE . " malformed: " . $this->headers[SONIC_HEADER__DATE]); return true; }
[ "protected", "function", "verifyDataFormat", "(", ")", "{", "// TODO validate data and formats\r", "if", "(", "!", "XSDDateTime", "::", "validateXSDDateTime", "(", "$", "this", "->", "headers", "[", "SONIC_HEADER__DATE", "]", ")", ")", "throw", "new", "MalformedRequestHeaderException", "(", "\"Malformed response: Header \"", ".", "SONIC_HEADER__DATE", ".", "\" malformed: \"", ".", "$", "this", "->", "headers", "[", "SONIC_HEADER__DATE", "]", ")", ";", "if", "(", "!", "XSDDateTime", "::", "validateXSDDateTime", "(", "$", "this", "->", "headers", "[", "SONIC_HEADER__DATE", "]", ")", ")", "throw", "new", "MalformedRequestHeaderException", "(", "\"Malformed response: Header \"", ".", "SONIC_HEADER__DATE", ".", "\" malformed: \"", ".", "$", "this", "->", "headers", "[", "SONIC_HEADER__DATE", "]", ")", ";", "return", "true", ";", "}" ]
verifies the format and content of the response @throws MalformedRequestHeaderException on corrupt data
[ "verifies", "the", "format", "and", "content", "of", "the", "response" ]
2c32ebd78607dc3e8558f10a0b7bf881d37fc168
https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Request/AbstractResponse.php#L78-L87
7,529
laasti/lazydata
src/Resolvers/ContainerResolver.php
ContainerResolver.resolve
public function resolve($value, $default = 'value') { $callable = $this->getCallable($value); if (is_array($callable)) { if (is_callable($callable[0])) { return call_user_func_array($callable[0], $callable[1]); } else { return $callable[0]; } } return $this->fallback->resolve($value, $default); }
php
public function resolve($value, $default = 'value') { $callable = $this->getCallable($value); if (is_array($callable)) { if (is_callable($callable[0])) { return call_user_func_array($callable[0], $callable[1]); } else { return $callable[0]; } } return $this->fallback->resolve($value, $default); }
[ "public", "function", "resolve", "(", "$", "value", ",", "$", "default", "=", "'value'", ")", "{", "$", "callable", "=", "$", "this", "->", "getCallable", "(", "$", "value", ")", ";", "if", "(", "is_array", "(", "$", "callable", ")", ")", "{", "if", "(", "is_callable", "(", "$", "callable", "[", "0", "]", ")", ")", "{", "return", "call_user_func_array", "(", "$", "callable", "[", "0", "]", ",", "$", "callable", "[", "1", "]", ")", ";", "}", "else", "{", "return", "$", "callable", "[", "0", "]", ";", "}", "}", "return", "$", "this", "->", "fallback", "->", "resolve", "(", "$", "value", ",", "$", "default", ")", ";", "}" ]
Attempts to resolve through the container or fallback on CallableResolver @param mixed $value
[ "Attempts", "to", "resolve", "through", "the", "container", "or", "fallback", "on", "CallableResolver" ]
44ceab7475177fc94eeb4fa3b8b630f5fc4fa301
https://github.com/laasti/lazydata/blob/44ceab7475177fc94eeb4fa3b8b630f5fc4fa301/src/Resolvers/ContainerResolver.php#L47-L60
7,530
hemio-ev/form
src/Abstract_/Form.php
Form.dataValid
public function dataValid() { foreach (new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST) as $child) { if ($child instanceof FormElement && !$child->dataValid()) { return false; } } return true; }
php
public function dataValid() { foreach (new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST) as $child) { if ($child instanceof FormElement && !$child->dataValid()) { return false; } } return true; }
[ "public", "function", "dataValid", "(", ")", "{", "foreach", "(", "new", "\\", "RecursiveIteratorIterator", "(", "$", "this", ",", "\\", "RecursiveIteratorIterator", "::", "SELF_FIRST", ")", "as", "$", "child", ")", "{", "if", "(", "$", "child", "instanceof", "FormElement", "&&", "!", "$", "child", "->", "dataValid", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Check for occured errors @return boolean
[ "Check", "for", "occured", "errors" ]
b4de29c90ca6ec0c58e8e2a1a7db79926b38831d
https://github.com/hemio-ev/form/blob/b4de29c90ca6ec0c58e8e2a1a7db79926b38831d/src/Abstract_/Form.php#L84-L94
7,531
hemio-ev/form
src/Abstract_/Form.php
Form.getValueStored
public function getValueStored($key) { if (isset($this->storedValues[$key])) { return $this->storedValues[$key]; } else { return null; } }
php
public function getValueStored($key) { if (isset($this->storedValues[$key])) { return $this->storedValues[$key]; } else { return null; } }
[ "public", "function", "getValueStored", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "storedValues", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "storedValues", "[", "$", "key", "]", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Stored values like from database @param string $key @return mixed
[ "Stored", "values", "like", "from", "database" ]
b4de29c90ca6ec0c58e8e2a1a7db79926b38831d
https://github.com/hemio-ev/form/blob/b4de29c90ca6ec0c58e8e2a1a7db79926b38831d/src/Abstract_/Form.php#L148-L155
7,532
AKarismatik/KRSMailBundle
Mailer/Mailer.php
Mailer.setTemplate
public function setTemplate($templateName) { if($templateName instanceof MailTemplate) { $this->template = $templateName; } elseif (!$this->template = $this->mailerManager->getRepository()->findOneBy(array('name' => $templateName))) { $this->template = $this->mailerManager->createDefault($templateName); } return $this; }
php
public function setTemplate($templateName) { if($templateName instanceof MailTemplate) { $this->template = $templateName; } elseif (!$this->template = $this->mailerManager->getRepository()->findOneBy(array('name' => $templateName))) { $this->template = $this->mailerManager->createDefault($templateName); } return $this; }
[ "public", "function", "setTemplate", "(", "$", "templateName", ")", "{", "if", "(", "$", "templateName", "instanceof", "MailTemplate", ")", "{", "$", "this", "->", "template", "=", "$", "templateName", ";", "}", "elseif", "(", "!", "$", "this", "->", "template", "=", "$", "this", "->", "mailerManager", "->", "getRepository", "(", ")", "->", "findOneBy", "(", "array", "(", "'name'", "=>", "$", "templateName", ")", ")", ")", "{", "$", "this", "->", "template", "=", "$", "this", "->", "mailerManager", "->", "createDefault", "(", "$", "templateName", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set a template to the mail @return Mailer $this
[ "Set", "a", "template", "to", "the", "mail" ]
91869c7f29cd76cebf2c75fb16b29d349c6cb301
https://github.com/AKarismatik/KRSMailBundle/blob/91869c7f29cd76cebf2c75fb16b29d349c6cb301/Mailer/Mailer.php#L63-L75
7,533
AKarismatik/KRSMailBundle
Mailer/Mailer.php
Mailer.addValues
public function addValues($values, $prefix = null) { if(!is_array($values)) { throw new MailerException('KarisMailer->setValues arrays'); } foreach($values as $key => $value) { if(is_array($value)) { unset($values[$key]); } elseif(is_object($value)) { try { $values[$key] = $value; } catch(\Exception $e) { unset($values[$key]); } } elseif($prefix) { $values[$prefix.$key] = $value; unset($values[$key]); } } $this->values = array_merge($this->values, $values); return $this; }
php
public function addValues($values, $prefix = null) { if(!is_array($values)) { throw new MailerException('KarisMailer->setValues arrays'); } foreach($values as $key => $value) { if(is_array($value)) { unset($values[$key]); } elseif(is_object($value)) { try { $values[$key] = $value; } catch(\Exception $e) { unset($values[$key]); } } elseif($prefix) { $values[$prefix.$key] = $value; unset($values[$key]); } } $this->values = array_merge($this->values, $values); return $this; }
[ "public", "function", "addValues", "(", "$", "values", ",", "$", "prefix", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "throw", "new", "MailerException", "(", "'KarisMailer->setValues arrays'", ")", ";", "}", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "unset", "(", "$", "values", "[", "$", "key", "]", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "try", "{", "$", "values", "[", "$", "key", "]", "=", "$", "value", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "unset", "(", "$", "values", "[", "$", "key", "]", ")", ";", "}", "}", "elseif", "(", "$", "prefix", ")", "{", "$", "values", "[", "$", "prefix", ".", "$", "key", "]", "=", "$", "value", ";", "unset", "(", "$", "values", "[", "$", "key", "]", ")", ";", "}", "}", "$", "this", "->", "values", "=", "array_merge", "(", "$", "this", "->", "values", ",", "$", "values", ")", ";", "return", "$", "this", ";", "}" ]
Add values to the mail that will be available in the template @param mixed $data array @param string $prefix a prefix for this data @return Mailer $this
[ "Add", "values", "to", "the", "mail", "that", "will", "be", "available", "in", "the", "template" ]
91869c7f29cd76cebf2c75fb16b29d349c6cb301
https://github.com/AKarismatik/KRSMailBundle/blob/91869c7f29cd76cebf2c75fb16b29d349c6cb301/Mailer/Mailer.php#L172-L205
7,534
AKarismatik/KRSMailBundle
Mailer/Mailer.php
Mailer.send
public function send() { if(!$this->getTemplate()->getIsActive()) { return $this; } if(!$this->isRendered()) { $this->render(); } $eventParams = array( 'mailer' => $this->getMailer(), 'message' => $this->getMessage(), 'template' => $this->getTemplate() ); $this->getMailer()->send($this->getMessage()); $this->sentMailer->createSentMail($this->getTemplate()); return $this; }
php
public function send() { if(!$this->getTemplate()->getIsActive()) { return $this; } if(!$this->isRendered()) { $this->render(); } $eventParams = array( 'mailer' => $this->getMailer(), 'message' => $this->getMessage(), 'template' => $this->getTemplate() ); $this->getMailer()->send($this->getMessage()); $this->sentMailer->createSentMail($this->getTemplate()); return $this; }
[ "public", "function", "send", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getTemplate", "(", ")", "->", "getIsActive", "(", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "$", "this", "->", "isRendered", "(", ")", ")", "{", "$", "this", "->", "render", "(", ")", ";", "}", "$", "eventParams", "=", "array", "(", "'mailer'", "=>", "$", "this", "->", "getMailer", "(", ")", ",", "'message'", "=>", "$", "this", "->", "getMessage", "(", ")", ",", "'template'", "=>", "$", "this", "->", "getTemplate", "(", ")", ")", ";", "$", "this", "->", "getMailer", "(", ")", "->", "send", "(", "$", "this", "->", "getMessage", "(", ")", ")", ";", "$", "this", "->", "sentMailer", "->", "createSentMail", "(", "$", "this", "->", "getTemplate", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Binds the mail with available data Uses Swift to send it. @return Mailer $this
[ "Binds", "the", "mail", "with", "available", "data", "Uses", "Swift", "to", "send", "it", "." ]
91869c7f29cd76cebf2c75fb16b29d349c6cb301
https://github.com/AKarismatik/KRSMailBundle/blob/91869c7f29cd76cebf2c75fb16b29d349c6cb301/Mailer/Mailer.php#L228-L250
7,535
AKarismatik/KRSMailBundle
Mailer/Mailer.php
Mailer.render
public function render() { if (!$this->getTemplate()) { throw new MailerException('You must call setTemplate() to set a mail template'); } $template = $this->getTemplate(); $template = $this->mailerManager->updateTemplate($template,$this->getValues()); $replacements = $this->getReplacements(); //load the template content $templateFile = 'KRSMailBundle:mailTemplate:karisMailTemplate.html.twig'; $templateContent = $this->twig->loadTemplate($templateFile); $body = $templateContent->render(array('body' =>strtr($template->getBody(), $replacements))); $message = $this->getMessage(); $from = array($template->getFromEmail() => "KRS"); $message ->setSubject(strtr($template->getSubject(), $replacements)) ->setBody(strtr($body, $replacements),'text/html') ->setContentType("text/html") ->setFrom($from) ->setTo($this->emailListToArray(strtr($template->getToEmail(), $replacements))); if($template->getCcEmail()) { $message->setCc($this->emailListToArray(strtr($template->getCcEmail(), $replacements))); } if($template->getBccEmail()) { $message->setBcc($this->emailListToArray(strtr($template->getBccEmail(), $replacements))); } if($template->getReplyToEmail()) { $message->setReplyTo($this->emailListToArray(strtr($template->getReplyToEmail(), $replacements))); } if($template->getSenderEmail()) { $message->setSender($this->emailListToArray(strtr($template->getSenderEmail(), $replacements))); } $this->isRendered = true; return $this; }
php
public function render() { if (!$this->getTemplate()) { throw new MailerException('You must call setTemplate() to set a mail template'); } $template = $this->getTemplate(); $template = $this->mailerManager->updateTemplate($template,$this->getValues()); $replacements = $this->getReplacements(); //load the template content $templateFile = 'KRSMailBundle:mailTemplate:karisMailTemplate.html.twig'; $templateContent = $this->twig->loadTemplate($templateFile); $body = $templateContent->render(array('body' =>strtr($template->getBody(), $replacements))); $message = $this->getMessage(); $from = array($template->getFromEmail() => "KRS"); $message ->setSubject(strtr($template->getSubject(), $replacements)) ->setBody(strtr($body, $replacements),'text/html') ->setContentType("text/html") ->setFrom($from) ->setTo($this->emailListToArray(strtr($template->getToEmail(), $replacements))); if($template->getCcEmail()) { $message->setCc($this->emailListToArray(strtr($template->getCcEmail(), $replacements))); } if($template->getBccEmail()) { $message->setBcc($this->emailListToArray(strtr($template->getBccEmail(), $replacements))); } if($template->getReplyToEmail()) { $message->setReplyTo($this->emailListToArray(strtr($template->getReplyToEmail(), $replacements))); } if($template->getSenderEmail()) { $message->setSender($this->emailListToArray(strtr($template->getSenderEmail(), $replacements))); } $this->isRendered = true; return $this; }
[ "public", "function", "render", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getTemplate", "(", ")", ")", "{", "throw", "new", "MailerException", "(", "'You must call setTemplate() to set a mail template'", ")", ";", "}", "$", "template", "=", "$", "this", "->", "getTemplate", "(", ")", ";", "$", "template", "=", "$", "this", "->", "mailerManager", "->", "updateTemplate", "(", "$", "template", ",", "$", "this", "->", "getValues", "(", ")", ")", ";", "$", "replacements", "=", "$", "this", "->", "getReplacements", "(", ")", ";", "//load the template content", "$", "templateFile", "=", "'KRSMailBundle:mailTemplate:karisMailTemplate.html.twig'", ";", "$", "templateContent", "=", "$", "this", "->", "twig", "->", "loadTemplate", "(", "$", "templateFile", ")", ";", "$", "body", "=", "$", "templateContent", "->", "render", "(", "array", "(", "'body'", "=>", "strtr", "(", "$", "template", "->", "getBody", "(", ")", ",", "$", "replacements", ")", ")", ")", ";", "$", "message", "=", "$", "this", "->", "getMessage", "(", ")", ";", "$", "from", "=", "array", "(", "$", "template", "->", "getFromEmail", "(", ")", "=>", "\"KRS\"", ")", ";", "$", "message", "->", "setSubject", "(", "strtr", "(", "$", "template", "->", "getSubject", "(", ")", ",", "$", "replacements", ")", ")", "->", "setBody", "(", "strtr", "(", "$", "body", ",", "$", "replacements", ")", ",", "'text/html'", ")", "->", "setContentType", "(", "\"text/html\"", ")", "->", "setFrom", "(", "$", "from", ")", "->", "setTo", "(", "$", "this", "->", "emailListToArray", "(", "strtr", "(", "$", "template", "->", "getToEmail", "(", ")", ",", "$", "replacements", ")", ")", ")", ";", "if", "(", "$", "template", "->", "getCcEmail", "(", ")", ")", "{", "$", "message", "->", "setCc", "(", "$", "this", "->", "emailListToArray", "(", "strtr", "(", "$", "template", "->", "getCcEmail", "(", ")", ",", "$", "replacements", ")", ")", ")", ";", "}", "if", "(", "$", "template", "->", "getBccEmail", "(", ")", ")", "{", "$", "message", "->", "setBcc", "(", "$", "this", "->", "emailListToArray", "(", "strtr", "(", "$", "template", "->", "getBccEmail", "(", ")", ",", "$", "replacements", ")", ")", ")", ";", "}", "if", "(", "$", "template", "->", "getReplyToEmail", "(", ")", ")", "{", "$", "message", "->", "setReplyTo", "(", "$", "this", "->", "emailListToArray", "(", "strtr", "(", "$", "template", "->", "getReplyToEmail", "(", ")", ",", "$", "replacements", ")", ")", ")", ";", "}", "if", "(", "$", "template", "->", "getSenderEmail", "(", ")", ")", "{", "$", "message", "->", "setSender", "(", "$", "this", "->", "emailListToArray", "(", "strtr", "(", "$", "template", "->", "getSenderEmail", "(", ")", ",", "$", "replacements", ")", ")", ")", ";", "}", "$", "this", "->", "isRendered", "=", "true", ";", "return", "$", "this", ";", "}" ]
Builds the Swift message inserting vars in templates @return Mailer $this
[ "Builds", "the", "Swift", "message", "inserting", "vars", "in", "templates" ]
91869c7f29cd76cebf2c75fb16b29d349c6cb301
https://github.com/AKarismatik/KRSMailBundle/blob/91869c7f29cd76cebf2c75fb16b29d349c6cb301/Mailer/Mailer.php#L259-L309
7,536
ouranoshong/phbench
libs/Benchmark.php
Benchmark.getAll
public function getAll() { $benchmarks = array(); @reset($this->results); while (list($identifier, $elapsed_time) = @each($this->results)) { if (!isset($this->temporary[$identifier])) { $benchmarks[$identifier] = $elapsed_time; } } return $benchmarks; }
php
public function getAll() { $benchmarks = array(); @reset($this->results); while (list($identifier, $elapsed_time) = @each($this->results)) { if (!isset($this->temporary[$identifier])) { $benchmarks[$identifier] = $elapsed_time; } } return $benchmarks; }
[ "public", "function", "getAll", "(", ")", "{", "$", "benchmarks", "=", "array", "(", ")", ";", "@", "reset", "(", "$", "this", "->", "results", ")", ";", "while", "(", "list", "(", "$", "identifier", ",", "$", "elapsed_time", ")", "=", "@", "each", "(", "$", "this", "->", "results", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "temporary", "[", "$", "identifier", "]", ")", ")", "{", "$", "benchmarks", "[", "$", "identifier", "]", "=", "$", "elapsed_time", ";", "}", "}", "return", "$", "benchmarks", ";", "}" ]
Returns all registered benchmark-results. @return array associative Array. The keys are the benchmark-identifiers, the values the benchmark-times.
[ "Returns", "all", "registered", "benchmark", "-", "results", "." ]
32b0f60b03e7193c590d540d58e3911d1e98dfbb
https://github.com/ouranoshong/phbench/blob/32b0f60b03e7193c590d540d58e3911d1e98dfbb/libs/Benchmark.php#L153-L165
7,537
springimport/magento2-module-restapi-filters
Filter/AbstractFieldsFilter.php
AbstractFieldsFilter.filter
public function filter($response) { $filter = $this->_request->getParam(static::FILTER_PARAMETER); if (!is_string($filter)) { return $response; } $filterArray = $this->parse($filter); if ($filterArray === null) { return $response; } $partialResponse = $this->applyFilter($response, $filterArray); return $partialResponse; }
php
public function filter($response) { $filter = $this->_request->getParam(static::FILTER_PARAMETER); if (!is_string($filter)) { return $response; } $filterArray = $this->parse($filter); if ($filterArray === null) { return $response; } $partialResponse = $this->applyFilter($response, $filterArray); return $partialResponse; }
[ "public", "function", "filter", "(", "$", "response", ")", "{", "$", "filter", "=", "$", "this", "->", "_request", "->", "getParam", "(", "static", "::", "FILTER_PARAMETER", ")", ";", "if", "(", "!", "is_string", "(", "$", "filter", ")", ")", "{", "return", "$", "response", ";", "}", "$", "filterArray", "=", "$", "this", "->", "parse", "(", "$", "filter", ")", ";", "if", "(", "$", "filterArray", "===", "null", ")", "{", "return", "$", "response", ";", "}", "$", "partialResponse", "=", "$", "this", "->", "applyFilter", "(", "$", "response", ",", "$", "filterArray", ")", ";", "return", "$", "partialResponse", ";", "}" ]
Process filter from the request and apply over response to get the partial results @param array $response @return array response
[ "Process", "filter", "from", "the", "request", "and", "apply", "over", "response", "to", "get", "the", "partial", "results" ]
7206ac0ab20e8d435578be0e09e484a4b14f29a9
https://github.com/springimport/magento2-module-restapi-filters/blob/7206ac0ab20e8d435578be0e09e484a4b14f29a9/Filter/AbstractFieldsFilter.php#L38-L50
7,538
springimport/magento2-module-restapi-filters
Filter/AbstractFieldsFilter.php
AbstractFieldsFilter.parse
protected function parse($filterString) { $length = strlen($filterString); if ($length == 0 || preg_match('/[^\w\[\],]+/', $filterString)) { return null; } $start = null; $current = []; $stack = []; $parent = []; $currentElement = null; for ($position = 0; $position < $length; $position++) { //Extracting field when encountering field separators if (in_array($filterString[$position], ['[', ']', ','])) { if ($start !== null) { $currentElement = substr($filterString, $start, $position - $start); $current[$currentElement] = 1; } $start = null; } switch ($filterString[$position]) { case '[': array_push($parent, $currentElement); // push current field in stack and initialize current array_push($stack, $current); $current = []; break; case ']': //cache current $temp = $current; //Initialize with previous $current = array_pop($stack); //Add from cache $current[array_pop($parent)] = $temp; break; //Do nothing on comma. On the next iteration field will be extracted case ',': break; default: //Move position if no field separators found if ($start === null) { $start = $position; } } } //Check for wrongly formatted filter if (!empty($stack)) { return null; } //Check if there's any field remaining that's not added to response if ($start !== null) { $currentElement = substr($filterString, $start, $position - $start); $current[$currentElement] = 1; } return $current; }
php
protected function parse($filterString) { $length = strlen($filterString); if ($length == 0 || preg_match('/[^\w\[\],]+/', $filterString)) { return null; } $start = null; $current = []; $stack = []; $parent = []; $currentElement = null; for ($position = 0; $position < $length; $position++) { //Extracting field when encountering field separators if (in_array($filterString[$position], ['[', ']', ','])) { if ($start !== null) { $currentElement = substr($filterString, $start, $position - $start); $current[$currentElement] = 1; } $start = null; } switch ($filterString[$position]) { case '[': array_push($parent, $currentElement); // push current field in stack and initialize current array_push($stack, $current); $current = []; break; case ']': //cache current $temp = $current; //Initialize with previous $current = array_pop($stack); //Add from cache $current[array_pop($parent)] = $temp; break; //Do nothing on comma. On the next iteration field will be extracted case ',': break; default: //Move position if no field separators found if ($start === null) { $start = $position; } } } //Check for wrongly formatted filter if (!empty($stack)) { return null; } //Check if there's any field remaining that's not added to response if ($start !== null) { $currentElement = substr($filterString, $start, $position - $start); $current[$currentElement] = 1; } return $current; }
[ "protected", "function", "parse", "(", "$", "filterString", ")", "{", "$", "length", "=", "strlen", "(", "$", "filterString", ")", ";", "if", "(", "$", "length", "==", "0", "||", "preg_match", "(", "'/[^\\w\\[\\],]+/'", ",", "$", "filterString", ")", ")", "{", "return", "null", ";", "}", "$", "start", "=", "null", ";", "$", "current", "=", "[", "]", ";", "$", "stack", "=", "[", "]", ";", "$", "parent", "=", "[", "]", ";", "$", "currentElement", "=", "null", ";", "for", "(", "$", "position", "=", "0", ";", "$", "position", "<", "$", "length", ";", "$", "position", "++", ")", "{", "//Extracting field when encountering field separators", "if", "(", "in_array", "(", "$", "filterString", "[", "$", "position", "]", ",", "[", "'['", ",", "']'", ",", "','", "]", ")", ")", "{", "if", "(", "$", "start", "!==", "null", ")", "{", "$", "currentElement", "=", "substr", "(", "$", "filterString", ",", "$", "start", ",", "$", "position", "-", "$", "start", ")", ";", "$", "current", "[", "$", "currentElement", "]", "=", "1", ";", "}", "$", "start", "=", "null", ";", "}", "switch", "(", "$", "filterString", "[", "$", "position", "]", ")", "{", "case", "'['", ":", "array_push", "(", "$", "parent", ",", "$", "currentElement", ")", ";", "// push current field in stack and initialize current", "array_push", "(", "$", "stack", ",", "$", "current", ")", ";", "$", "current", "=", "[", "]", ";", "break", ";", "case", "']'", ":", "//cache current", "$", "temp", "=", "$", "current", ";", "//Initialize with previous", "$", "current", "=", "array_pop", "(", "$", "stack", ")", ";", "//Add from cache", "$", "current", "[", "array_pop", "(", "$", "parent", ")", "]", "=", "$", "temp", ";", "break", ";", "//Do nothing on comma. On the next iteration field will be extracted", "case", "','", ":", "break", ";", "default", ":", "//Move position if no field separators found", "if", "(", "$", "start", "===", "null", ")", "{", "$", "start", "=", "$", "position", ";", "}", "}", "}", "//Check for wrongly formatted filter", "if", "(", "!", "empty", "(", "$", "stack", ")", ")", "{", "return", "null", ";", "}", "//Check if there's any field remaining that's not added to response", "if", "(", "$", "start", "!==", "null", ")", "{", "$", "currentElement", "=", "substr", "(", "$", "filterString", ",", "$", "start", ",", "$", "position", "-", "$", "start", ")", ";", "$", "current", "[", "$", "currentElement", "]", "=", "1", ";", "}", "return", "$", "current", ";", "}" ]
Parse filter string into associative array. Field names are returned as keys with values for scalar fields as 1. @param string $filterString <pre> ex. customer[id,email],addresses[city,postcode,region[region_code,region]] </pre> @return array|null <pre> ex. array( 'customer' => array( 'id' => 1, 'email' => 1, ), 'addresses' => array( 'city' => 1, 'postcode' => 1, 'region' => array( 'region_code' => 1, 'region' => 1, ), ), ) </pre> @SuppressWarnings(PHPMD.CyclomaticComplexity)
[ "Parse", "filter", "string", "into", "associative", "array", ".", "Field", "names", "are", "returned", "as", "keys", "with", "values", "for", "scalar", "fields", "as", "1", "." ]
7206ac0ab20e8d435578be0e09e484a4b14f29a9
https://github.com/springimport/magento2-module-restapi-filters/blob/7206ac0ab20e8d435578be0e09e484a4b14f29a9/Filter/AbstractFieldsFilter.php#L83-L143
7,539
springimport/magento2-module-restapi-filters
Filter/AbstractFieldsFilter.php
AbstractFieldsFilter.applyFilter
protected function applyFilter(array $responseArray, array $filter) { $arrayIntersect = null; //Check if its a sequential array. Presence of sequential arrays mean that the filed is a collection //and the filtering will be applied to all the collection items if (!(bool)count(array_filter(array_keys($responseArray), 'is_string'))) { foreach ($responseArray as $key => &$item) { $arrayIntersect[$key] = $this->recursiveArrayCompare($item, $filter); } } else { $arrayIntersect = $this->recursiveArrayCompare($responseArray, $filter); } return $arrayIntersect; }
php
protected function applyFilter(array $responseArray, array $filter) { $arrayIntersect = null; //Check if its a sequential array. Presence of sequential arrays mean that the filed is a collection //and the filtering will be applied to all the collection items if (!(bool)count(array_filter(array_keys($responseArray), 'is_string'))) { foreach ($responseArray as $key => &$item) { $arrayIntersect[$key] = $this->recursiveArrayCompare($item, $filter); } } else { $arrayIntersect = $this->recursiveArrayCompare($responseArray, $filter); } return $arrayIntersect; }
[ "protected", "function", "applyFilter", "(", "array", "$", "responseArray", ",", "array", "$", "filter", ")", "{", "$", "arrayIntersect", "=", "null", ";", "//Check if its a sequential array. Presence of sequential arrays mean that the filed is a collection", "//and the filtering will be applied to all the collection items", "if", "(", "!", "(", "bool", ")", "count", "(", "array_filter", "(", "array_keys", "(", "$", "responseArray", ")", ",", "'is_string'", ")", ")", ")", "{", "foreach", "(", "$", "responseArray", "as", "$", "key", "=>", "&", "$", "item", ")", "{", "$", "arrayIntersect", "[", "$", "key", "]", "=", "$", "this", "->", "recursiveArrayCompare", "(", "$", "item", ",", "$", "filter", ")", ";", "}", "}", "else", "{", "$", "arrayIntersect", "=", "$", "this", "->", "recursiveArrayCompare", "(", "$", "responseArray", ",", "$", "filter", ")", ";", "}", "return", "$", "arrayIntersect", ";", "}" ]
Apply filter array @param array $responseArray @param array $filter @return array
[ "Apply", "filter", "array" ]
7206ac0ab20e8d435578be0e09e484a4b14f29a9
https://github.com/springimport/magento2-module-restapi-filters/blob/7206ac0ab20e8d435578be0e09e484a4b14f29a9/Filter/AbstractFieldsFilter.php#L152-L165
7,540
yongtiger/yii2-application
src/Application.php
Application.remoteAppCall
public static function remoteAppCall($appId, \Closure $callback, \Closure $filterConfigCallback = null) { if ($callback === null || !$callback instanceof \Closure) { throw new InvalidParamException("Invalid param: `callback`."); } if ($appId !== Yii::$app->id && isset(Yii::$app->params[static::$remoteAppConfigs])) { if (!isset(Yii::$app->params[static::$remoteAppConfigs][$appId])) { throw new InvalidParamException("Invalid param: `appId`."); } if (!is_array(Yii::$app->params[static::$remoteAppConfigs][$appId])) { throw new InvalidConfigException("Invalid config: Yii::$app->params[" . static::$remoteAppConfigs . "][$appId]."); } if (isset(Yii::$app->params[static::$remoteAppConfigs][$appId]['class'])) { $appClass = Yii::$app->params[static::$remoteAppConfigs][$appId]['class']; unset(Yii::$app->params[static::$remoteAppConfigs][$appId]['class']); } else { $appClass = get_called_class(); } // Save the original app to a temp app. $yiiApp = Yii::$app; ///[1.0.1 (fix:bug:i18n is invalid after Application::remoteAppCall('app-frontend'))] $yiiAliases = Yii::$aliases; // Create empty config array. $config = []; // Assemble configuration for the current app. foreach (Yii::$app->params[static::$remoteAppConfigs][$appId] as $configPath) { // Merge every new configuration with the old config array. $config = ArrayHelper::merge($config, require (Yii::getAlias($configPath))); } // Call filter config callback function if ($filterConfigCallback !== null || $filterConfigCallback instanceof \Closure) { $config = call_user_func($filterConfigCallback, $config); } // Create a new app using the config array. $app = new $appClass($config); ///[v0.12.1 (UGD# replace component/application into yongtiger/appliaction)] // Call callback function by using the new app call_user_func($callback, $app); // Dump the new app unset($app); // Switch back to the original app. Yii::$app = $yiiApp; ///[1.0.1 (fix:bug:i18n is invalid after Application::remoteAppCall('app-frontend'))] Yii::$aliases = $yiiAliases; // Dump the temp app unset($yiiApp, $yiiAliases); ///[1.0.1 (fix:bug:i18n is invalid after Application::remoteAppCall('app-frontend'))] } else { call_user_func($callback, Yii::$app); } }
php
public static function remoteAppCall($appId, \Closure $callback, \Closure $filterConfigCallback = null) { if ($callback === null || !$callback instanceof \Closure) { throw new InvalidParamException("Invalid param: `callback`."); } if ($appId !== Yii::$app->id && isset(Yii::$app->params[static::$remoteAppConfigs])) { if (!isset(Yii::$app->params[static::$remoteAppConfigs][$appId])) { throw new InvalidParamException("Invalid param: `appId`."); } if (!is_array(Yii::$app->params[static::$remoteAppConfigs][$appId])) { throw new InvalidConfigException("Invalid config: Yii::$app->params[" . static::$remoteAppConfigs . "][$appId]."); } if (isset(Yii::$app->params[static::$remoteAppConfigs][$appId]['class'])) { $appClass = Yii::$app->params[static::$remoteAppConfigs][$appId]['class']; unset(Yii::$app->params[static::$remoteAppConfigs][$appId]['class']); } else { $appClass = get_called_class(); } // Save the original app to a temp app. $yiiApp = Yii::$app; ///[1.0.1 (fix:bug:i18n is invalid after Application::remoteAppCall('app-frontend'))] $yiiAliases = Yii::$aliases; // Create empty config array. $config = []; // Assemble configuration for the current app. foreach (Yii::$app->params[static::$remoteAppConfigs][$appId] as $configPath) { // Merge every new configuration with the old config array. $config = ArrayHelper::merge($config, require (Yii::getAlias($configPath))); } // Call filter config callback function if ($filterConfigCallback !== null || $filterConfigCallback instanceof \Closure) { $config = call_user_func($filterConfigCallback, $config); } // Create a new app using the config array. $app = new $appClass($config); ///[v0.12.1 (UGD# replace component/application into yongtiger/appliaction)] // Call callback function by using the new app call_user_func($callback, $app); // Dump the new app unset($app); // Switch back to the original app. Yii::$app = $yiiApp; ///[1.0.1 (fix:bug:i18n is invalid after Application::remoteAppCall('app-frontend'))] Yii::$aliases = $yiiAliases; // Dump the temp app unset($yiiApp, $yiiAliases); ///[1.0.1 (fix:bug:i18n is invalid after Application::remoteAppCall('app-frontend'))] } else { call_user_func($callback, Yii::$app); } }
[ "public", "static", "function", "remoteAppCall", "(", "$", "appId", ",", "\\", "Closure", "$", "callback", ",", "\\", "Closure", "$", "filterConfigCallback", "=", "null", ")", "{", "if", "(", "$", "callback", "===", "null", "||", "!", "$", "callback", "instanceof", "\\", "Closure", ")", "{", "throw", "new", "InvalidParamException", "(", "\"Invalid param: `callback`.\"", ")", ";", "}", "if", "(", "$", "appId", "!==", "Yii", "::", "$", "app", "->", "id", "&&", "isset", "(", "Yii", "::", "$", "app", "->", "params", "[", "static", "::", "$", "remoteAppConfigs", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "Yii", "::", "$", "app", "->", "params", "[", "static", "::", "$", "remoteAppConfigs", "]", "[", "$", "appId", "]", ")", ")", "{", "throw", "new", "InvalidParamException", "(", "\"Invalid param: `appId`.\"", ")", ";", "}", "if", "(", "!", "is_array", "(", "Yii", "::", "$", "app", "->", "params", "[", "static", "::", "$", "remoteAppConfigs", "]", "[", "$", "appId", "]", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "\"Invalid config: Yii::$app->params[\"", ".", "static", "::", "$", "remoteAppConfigs", ".", "\"][$appId].\"", ")", ";", "}", "if", "(", "isset", "(", "Yii", "::", "$", "app", "->", "params", "[", "static", "::", "$", "remoteAppConfigs", "]", "[", "$", "appId", "]", "[", "'class'", "]", ")", ")", "{", "$", "appClass", "=", "Yii", "::", "$", "app", "->", "params", "[", "static", "::", "$", "remoteAppConfigs", "]", "[", "$", "appId", "]", "[", "'class'", "]", ";", "unset", "(", "Yii", "::", "$", "app", "->", "params", "[", "static", "::", "$", "remoteAppConfigs", "]", "[", "$", "appId", "]", "[", "'class'", "]", ")", ";", "}", "else", "{", "$", "appClass", "=", "get_called_class", "(", ")", ";", "}", "// Save the original app to a temp app.", "$", "yiiApp", "=", "Yii", "::", "$", "app", ";", "///[1.0.1 (fix:bug:i18n is invalid after Application::remoteAppCall('app-frontend'))]", "$", "yiiAliases", "=", "Yii", "::", "$", "aliases", ";", "// Create empty config array.", "$", "config", "=", "[", "]", ";", "// Assemble configuration for the current app.", "foreach", "(", "Yii", "::", "$", "app", "->", "params", "[", "static", "::", "$", "remoteAppConfigs", "]", "[", "$", "appId", "]", "as", "$", "configPath", ")", "{", "// Merge every new configuration with the old config array.", "$", "config", "=", "ArrayHelper", "::", "merge", "(", "$", "config", ",", "require", "(", "Yii", "::", "getAlias", "(", "$", "configPath", ")", ")", ")", ";", "}", "// Call filter config callback function", "if", "(", "$", "filterConfigCallback", "!==", "null", "||", "$", "filterConfigCallback", "instanceof", "\\", "Closure", ")", "{", "$", "config", "=", "call_user_func", "(", "$", "filterConfigCallback", ",", "$", "config", ")", ";", "}", "// Create a new app using the config array.", "$", "app", "=", "new", "$", "appClass", "(", "$", "config", ")", ";", "///[v0.12.1 (UGD# replace component/application into yongtiger/appliaction)]", "// Call callback function by using the new app", "call_user_func", "(", "$", "callback", ",", "$", "app", ")", ";", "// Dump the new app", "unset", "(", "$", "app", ")", ";", "// Switch back to the original app.", "Yii", "::", "$", "app", "=", "$", "yiiApp", ";", "///[1.0.1 (fix:bug:i18n is invalid after Application::remoteAppCall('app-frontend'))]", "Yii", "::", "$", "aliases", "=", "$", "yiiAliases", ";", "// Dump the temp app", "unset", "(", "$", "yiiApp", ",", "$", "yiiAliases", ")", ";", "///[1.0.1 (fix:bug:i18n is invalid after Application::remoteAppCall('app-frontend'))]", "}", "else", "{", "call_user_func", "(", "$", "callback", ",", "Yii", "::", "$", "app", ")", ";", "}", "}" ]
Call callback function with a remote application. @param string $appId @param Closure $callback @throws InvalidParamException|InvalidConfigException
[ "Call", "callback", "function", "with", "a", "remote", "application", "." ]
6c03de973a3046ad67951d0a27cedfe9613e4042
https://github.com/yongtiger/yii2-application/blob/6c03de973a3046ad67951d0a27cedfe9613e4042/src/Application.php#L64-L124
7,541
magdev/php-assimp
src/Command/Command.php
Command.getBinary
public function getBinary(): string { if (is_null($this->bin)) { $paths = array('/usr/bin/assimp', '/usr/local/bin/assimp', '~/bin/assimp'); foreach ($paths as $path) { try { $this->setBinary($path); } catch (\InvalidArgumentException $e) {} } if (!$this->bin) { throw new \RuntimeException('assimp-binary not found in '.explode(', ', $paths), ErrorCodes::FILE_NOT_FOUND); } if (!is_executable($this->bin)) { throw new \RuntimeException('Found a binary file, but it is not executable: '.$this->bin, ErrorCodes::FILE_NOT_EXECUTABLE); } } return $this->bin; }
php
public function getBinary(): string { if (is_null($this->bin)) { $paths = array('/usr/bin/assimp', '/usr/local/bin/assimp', '~/bin/assimp'); foreach ($paths as $path) { try { $this->setBinary($path); } catch (\InvalidArgumentException $e) {} } if (!$this->bin) { throw new \RuntimeException('assimp-binary not found in '.explode(', ', $paths), ErrorCodes::FILE_NOT_FOUND); } if (!is_executable($this->bin)) { throw new \RuntimeException('Found a binary file, but it is not executable: '.$this->bin, ErrorCodes::FILE_NOT_EXECUTABLE); } } return $this->bin; }
[ "public", "function", "getBinary", "(", ")", ":", "string", "{", "if", "(", "is_null", "(", "$", "this", "->", "bin", ")", ")", "{", "$", "paths", "=", "array", "(", "'/usr/bin/assimp'", ",", "'/usr/local/bin/assimp'", ",", "'~/bin/assimp'", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "try", "{", "$", "this", "->", "setBinary", "(", "$", "path", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "}", "}", "if", "(", "!", "$", "this", "->", "bin", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'assimp-binary not found in '", ".", "explode", "(", "', '", ",", "$", "paths", ")", ",", "ErrorCodes", "::", "FILE_NOT_FOUND", ")", ";", "}", "if", "(", "!", "is_executable", "(", "$", "this", "->", "bin", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Found a binary file, but it is not executable: '", ".", "$", "this", "->", "bin", ",", "ErrorCodes", "::", "FILE_NOT_EXECUTABLE", ")", ";", "}", "}", "return", "$", "this", "->", "bin", ";", "}" ]
Get the path to the assimp binary @return string @throws \RuntimeException
[ "Get", "the", "path", "to", "the", "assimp", "binary" ]
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Command.php#L110-L129
7,542
magdev/php-assimp
src/Command/Command.php
Command.setBinary
public function setBinary(string $bin): Command { if (!is_file($bin)) { throw new \InvalidArgumentException('Binary file not exists: '.$bin, ErrorCodes::FILE_NOT_FOUND); } if (!is_executable($bin)) { throw new \InvalidArgumentException('Binary file is not executable: '.$bin, ErrorCodes::FILE_NOT_EXECUTABLE); } $this->bin = $bin; return $this; }
php
public function setBinary(string $bin): Command { if (!is_file($bin)) { throw new \InvalidArgumentException('Binary file not exists: '.$bin, ErrorCodes::FILE_NOT_FOUND); } if (!is_executable($bin)) { throw new \InvalidArgumentException('Binary file is not executable: '.$bin, ErrorCodes::FILE_NOT_EXECUTABLE); } $this->bin = $bin; return $this; }
[ "public", "function", "setBinary", "(", "string", "$", "bin", ")", ":", "Command", "{", "if", "(", "!", "is_file", "(", "$", "bin", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Binary file not exists: '", ".", "$", "bin", ",", "ErrorCodes", "::", "FILE_NOT_FOUND", ")", ";", "}", "if", "(", "!", "is_executable", "(", "$", "bin", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Binary file is not executable: '", ".", "$", "bin", ",", "ErrorCodes", "::", "FILE_NOT_EXECUTABLE", ")", ";", "}", "$", "this", "->", "bin", "=", "$", "bin", ";", "return", "$", "this", ";", "}" ]
Set the path to the assimp binary @param string $bin Path to the assimp executable @throws \InvalidArgumentException @return \Assimp\Command\Command
[ "Set", "the", "path", "to", "the", "assimp", "binary" ]
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Command.php#L139-L149
7,543
magdev/php-assimp
src/Command/Command.php
Command.getCached
private static function getCached(CacheableInterface $verb): ResultInterface { $key = $verb->getCacheKey(); if (array_key_exists($key, self::$cache)) { return self::$cache[$key]; } return null; }
php
private static function getCached(CacheableInterface $verb): ResultInterface { $key = $verb->getCacheKey(); if (array_key_exists($key, self::$cache)) { return self::$cache[$key]; } return null; }
[ "private", "static", "function", "getCached", "(", "CacheableInterface", "$", "verb", ")", ":", "ResultInterface", "{", "$", "key", "=", "$", "verb", "->", "getCacheKey", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "self", "::", "$", "cache", ")", ")", "{", "return", "self", "::", "$", "cache", "[", "$", "key", "]", ";", "}", "return", "null", ";", "}" ]
Get a cached version of the verb @param \Assimp\Command\Verbs\Interfaces\CacheableInterface $verb @return \Assimp\Command\Result\Interfaces\ResultInterface|null
[ "Get", "a", "cached", "version", "of", "the", "verb" ]
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Command.php#L158-L165
7,544
magdev/php-assimp
src/Command/Command.php
Command.addCached
private static function addCached(CacheableInterface $verb, ResultInterface $result): void { self::$cache[$verb->getCacheKey()] = $result; }
php
private static function addCached(CacheableInterface $verb, ResultInterface $result): void { self::$cache[$verb->getCacheKey()] = $result; }
[ "private", "static", "function", "addCached", "(", "CacheableInterface", "$", "verb", ",", "ResultInterface", "$", "result", ")", ":", "void", "{", "self", "::", "$", "cache", "[", "$", "verb", "->", "getCacheKey", "(", ")", "]", "=", "$", "result", ";", "}" ]
Add a verb to the cache @param \Assimp\Command\Verbs\Interfaces\CacheableInterface $verb @param \Assimp\Command\Result\Interfaces\ResultInterface $result @return void
[ "Add", "a", "verb", "to", "the", "cache" ]
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Command.php#L175-L178
7,545
misterpaladin/gravatar
src/Gravatar.php
Gravatar.avatar
public static function avatar($email, $size = null) { $url = sprintf('%s/avatar/%s', self::$gravatarURL, md5($email)); if (!is_null($size)) { $url .= '?s=' . $size; } return $url; }
php
public static function avatar($email, $size = null) { $url = sprintf('%s/avatar/%s', self::$gravatarURL, md5($email)); if (!is_null($size)) { $url .= '?s=' . $size; } return $url; }
[ "public", "static", "function", "avatar", "(", "$", "email", ",", "$", "size", "=", "null", ")", "{", "$", "url", "=", "sprintf", "(", "'%s/avatar/%s'", ",", "self", "::", "$", "gravatarURL", ",", "md5", "(", "$", "email", ")", ")", ";", "if", "(", "!", "is_null", "(", "$", "size", ")", ")", "{", "$", "url", ".=", "'?s='", ".", "$", "size", ";", "}", "return", "$", "url", ";", "}" ]
Get user avatar @param string $email @param int $size @return string
[ "Get", "user", "avatar" ]
742329df8d64dfc8689e8fd577e9e63f9e917425
https://github.com/misterpaladin/gravatar/blob/742329df8d64dfc8689e8fd577e9e63f9e917425/src/Gravatar.php#L37-L46
7,546
misterpaladin/gravatar
src/Gravatar.php
Gravatar.profile
public static function profile($email) { $url = sprintf('%s/%s.json', self::$gravatarURL, md5($email)); $client = new Client(); return json_decode($client->get($url)->getBody()->getContents()); }
php
public static function profile($email) { $url = sprintf('%s/%s.json', self::$gravatarURL, md5($email)); $client = new Client(); return json_decode($client->get($url)->getBody()->getContents()); }
[ "public", "static", "function", "profile", "(", "$", "email", ")", "{", "$", "url", "=", "sprintf", "(", "'%s/%s.json'", ",", "self", "::", "$", "gravatarURL", ",", "md5", "(", "$", "email", ")", ")", ";", "$", "client", "=", "new", "Client", "(", ")", ";", "return", "json_decode", "(", "$", "client", "->", "get", "(", "$", "url", ")", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ")", ";", "}" ]
Get user profile @param string $email @return stdClass
[ "Get", "user", "profile" ]
742329df8d64dfc8689e8fd577e9e63f9e917425
https://github.com/misterpaladin/gravatar/blob/742329df8d64dfc8689e8fd577e9e63f9e917425/src/Gravatar.php#L54-L61
7,547
WellCommerce/DataSet
Paginator/DataSetPaginator.php
DataSetPaginator.replaceHaving
protected function replaceHaving(Query\Expr\Andx $having, ColumnCollection $columns, QueryBuilder $queryBuilder) { foreach ($having->getParts() as $part) { if ($part instanceof Query\Expr\Comparison) { $this->replaceSingleHavingClause($part, $columns, $queryBuilder); } } $queryBuilder->resetDQLPart('having'); $queryBuilder->resetDQLPart('groupBy'); }
php
protected function replaceHaving(Query\Expr\Andx $having, ColumnCollection $columns, QueryBuilder $queryBuilder) { foreach ($having->getParts() as $part) { if ($part instanceof Query\Expr\Comparison) { $this->replaceSingleHavingClause($part, $columns, $queryBuilder); } } $queryBuilder->resetDQLPart('having'); $queryBuilder->resetDQLPart('groupBy'); }
[ "protected", "function", "replaceHaving", "(", "Query", "\\", "Expr", "\\", "Andx", "$", "having", ",", "ColumnCollection", "$", "columns", ",", "QueryBuilder", "$", "queryBuilder", ")", "{", "foreach", "(", "$", "having", "->", "getParts", "(", ")", "as", "$", "part", ")", "{", "if", "(", "$", "part", "instanceof", "Query", "\\", "Expr", "\\", "Comparison", ")", "{", "$", "this", "->", "replaceSingleHavingClause", "(", "$", "part", ",", "$", "columns", ",", "$", "queryBuilder", ")", ";", "}", "}", "$", "queryBuilder", "->", "resetDQLPart", "(", "'having'", ")", ";", "$", "queryBuilder", "->", "resetDQLPart", "(", "'groupBy'", ")", ";", "}" ]
Replaces all having clauses and resets DQL's having part @param Query\Expr\Andx $having @param ColumnCollection $columns @param QueryBuilder $queryBuilder
[ "Replaces", "all", "having", "clauses", "and", "resets", "DQL", "s", "having", "part" ]
18720dc5416f245d22c502ceafce1a1b2db2b905
https://github.com/WellCommerce/DataSet/blob/18720dc5416f245d22c502ceafce1a1b2db2b905/Paginator/DataSetPaginator.php#L54-L64
7,548
WellCommerce/DataSet
Paginator/DataSetPaginator.php
DataSetPaginator.replaceSingleHavingClause
protected function replaceSingleHavingClause(Query\Expr\Comparison $comparison, ColumnCollection $columns, QueryBuilder $queryBuilder) { $source = $columns->get($comparison->getLeftExpr())->getPaginatorSource(); $param = $comparison->getRightExpr(); $operator = $this->getOperator($comparison->getOperator()); $expression = $queryBuilder->expr()->{$operator}($source, $param); $queryBuilder->andWhere($expression); }
php
protected function replaceSingleHavingClause(Query\Expr\Comparison $comparison, ColumnCollection $columns, QueryBuilder $queryBuilder) { $source = $columns->get($comparison->getLeftExpr())->getPaginatorSource(); $param = $comparison->getRightExpr(); $operator = $this->getOperator($comparison->getOperator()); $expression = $queryBuilder->expr()->{$operator}($source, $param); $queryBuilder->andWhere($expression); }
[ "protected", "function", "replaceSingleHavingClause", "(", "Query", "\\", "Expr", "\\", "Comparison", "$", "comparison", ",", "ColumnCollection", "$", "columns", ",", "QueryBuilder", "$", "queryBuilder", ")", "{", "$", "source", "=", "$", "columns", "->", "get", "(", "$", "comparison", "->", "getLeftExpr", "(", ")", ")", "->", "getPaginatorSource", "(", ")", ";", "$", "param", "=", "$", "comparison", "->", "getRightExpr", "(", ")", ";", "$", "operator", "=", "$", "this", "->", "getOperator", "(", "$", "comparison", "->", "getOperator", "(", ")", ")", ";", "$", "expression", "=", "$", "queryBuilder", "->", "expr", "(", ")", "->", "{", "$", "operator", "}", "(", "$", "source", ",", "$", "param", ")", ";", "$", "queryBuilder", "->", "andWhere", "(", "$", "expression", ")", ";", "}" ]
Replaces a single having clause because scalar types are not supported in doctrine paginator by default @param Query\Expr\Comparison $comparison @param ColumnCollection $columns @param QueryBuilder $queryBuilder
[ "Replaces", "a", "single", "having", "clause", "because", "scalar", "types", "are", "not", "supported", "in", "doctrine", "paginator", "by", "default" ]
18720dc5416f245d22c502ceafce1a1b2db2b905
https://github.com/WellCommerce/DataSet/blob/18720dc5416f245d22c502ceafce1a1b2db2b905/Paginator/DataSetPaginator.php#L73-L80
7,549
open-orchestra/open-orchestra-media-admin-bundle
MediaAdmin/FileUtils/Image/ImagickImageManager.php
ImagickImageManager.resizeImage
protected function resizeImage(array $format, Imagick $image) { $maxWidth = array_key_exists('max_width', $format)? $format['max_width']: $this->maxWidth; $maxHeight = array_key_exists('max_height', $format)? $format['max_height']: $this->maxHeight; if ($maxWidth > $this->maxWidth) { $maxWidth = $this->maxWidth; } if ($maxHeight > $this->maxHeight) { $maxHeight = $this->maxHeight; } $image->setimagebackgroundcolor('#000000'); $image->resizeImage($maxWidth, $maxHeight, Imagick::FILTER_LANCZOS, 1, true); return $image; }
php
protected function resizeImage(array $format, Imagick $image) { $maxWidth = array_key_exists('max_width', $format)? $format['max_width']: $this->maxWidth; $maxHeight = array_key_exists('max_height', $format)? $format['max_height']: $this->maxHeight; if ($maxWidth > $this->maxWidth) { $maxWidth = $this->maxWidth; } if ($maxHeight > $this->maxHeight) { $maxHeight = $this->maxHeight; } $image->setimagebackgroundcolor('#000000'); $image->resizeImage($maxWidth, $maxHeight, Imagick::FILTER_LANCZOS, 1, true); return $image; }
[ "protected", "function", "resizeImage", "(", "array", "$", "format", ",", "Imagick", "$", "image", ")", "{", "$", "maxWidth", "=", "array_key_exists", "(", "'max_width'", ",", "$", "format", ")", "?", "$", "format", "[", "'max_width'", "]", ":", "$", "this", "->", "maxWidth", ";", "$", "maxHeight", "=", "array_key_exists", "(", "'max_height'", ",", "$", "format", ")", "?", "$", "format", "[", "'max_height'", "]", ":", "$", "this", "->", "maxHeight", ";", "if", "(", "$", "maxWidth", ">", "$", "this", "->", "maxWidth", ")", "{", "$", "maxWidth", "=", "$", "this", "->", "maxWidth", ";", "}", "if", "(", "$", "maxHeight", ">", "$", "this", "->", "maxHeight", ")", "{", "$", "maxHeight", "=", "$", "this", "->", "maxHeight", ";", "}", "$", "image", "->", "setimagebackgroundcolor", "(", "'#000000'", ")", ";", "$", "image", "->", "resizeImage", "(", "$", "maxWidth", ",", "$", "maxHeight", ",", "Imagick", "::", "FILTER_LANCZOS", ",", "1", ",", "true", ")", ";", "return", "$", "image", ";", "}" ]
Resize an image keeping its ratio @param array $format @param Imagick $image @return Imagick
[ "Resize", "an", "image", "keeping", "its", "ratio" ]
743fa00a6491b84d67221e215a806d8b210bf773
https://github.com/open-orchestra/open-orchestra-media-admin-bundle/blob/743fa00a6491b84d67221e215a806d8b210bf773/MediaAdmin/FileUtils/Image/ImagickImageManager.php#L55-L70
7,550
open-orchestra/open-orchestra-media-admin-bundle
MediaAdmin/FileUtils/Image/ImagickImageManager.php
ImagickImageManager.resize
protected function resize(Imagick $image, $width, $height) { $image->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 1); return $image; }
php
protected function resize(Imagick $image, $width, $height) { $image->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 1); return $image; }
[ "protected", "function", "resize", "(", "Imagick", "$", "image", ",", "$", "width", ",", "$", "height", ")", "{", "$", "image", "->", "resizeImage", "(", "$", "width", ",", "$", "height", ",", "Imagick", "::", "FILTER_LANCZOS", ",", "1", ")", ";", "return", "$", "image", ";", "}" ]
Resize an image keeping @param Imagick $image @param int $height @param int $width @return Imagick
[ "Resize", "an", "image", "keeping" ]
743fa00a6491b84d67221e215a806d8b210bf773
https://github.com/open-orchestra/open-orchestra-media-admin-bundle/blob/743fa00a6491b84d67221e215a806d8b210bf773/MediaAdmin/FileUtils/Image/ImagickImageManager.php#L81-L86
7,551
nonetallt/jinitialize-core
src/Procedure.php
Procedure.execute
protected function execute(InputInterface $input, OutputInterface $output) { $style = new SymfonyStyle($input, $output); $this->validator->validate($input, $output, $style); /* Execute all commands */ foreach($this->commands as $command) { $success = $this->executeCommand($command, $input, $output, $style); } /* Print empty line before success */ $output->writeLn(''); $style->success("Procedure $this completed"); return true; }
php
protected function execute(InputInterface $input, OutputInterface $output) { $style = new SymfonyStyle($input, $output); $this->validator->validate($input, $output, $style); /* Execute all commands */ foreach($this->commands as $command) { $success = $this->executeCommand($command, $input, $output, $style); } /* Print empty line before success */ $output->writeLn(''); $style->success("Procedure $this completed"); return true; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "style", "=", "new", "SymfonyStyle", "(", "$", "input", ",", "$", "output", ")", ";", "$", "this", "->", "validator", "->", "validate", "(", "$", "input", ",", "$", "output", ",", "$", "style", ")", ";", "/* Execute all commands */", "foreach", "(", "$", "this", "->", "commands", "as", "$", "command", ")", "{", "$", "success", "=", "$", "this", "->", "executeCommand", "(", "$", "command", ",", "$", "input", ",", "$", "output", ",", "$", "style", ")", ";", "}", "/* Print empty line before success */", "$", "output", "->", "writeLn", "(", "''", ")", ";", "$", "style", "->", "success", "(", "\"Procedure $this completed\"", ")", ";", "return", "true", ";", "}" ]
Implemented from Command
[ "Implemented", "from", "Command" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/Procedure.php#L49-L63
7,552
nonetallt/jinitialize-core
src/Procedure.php
Procedure.revert
private function revert($output, $input, $style) { /* Revert commands in backwards order */ for($n = count($this->commandsExecuted); $n > 0; $n--) { $command = $this->commandsExecuted[$n-1]; /* Revert if possible */ if($command->hasPublicMethod('revert')) { $output->writeLn("Reverting $command"); $command->revert(); continue; } $style->warning("Command {$command->getName()} cannot be reverted, revert method is not defined"); } $this->commandsExecuted = []; }
php
private function revert($output, $input, $style) { /* Revert commands in backwards order */ for($n = count($this->commandsExecuted); $n > 0; $n--) { $command = $this->commandsExecuted[$n-1]; /* Revert if possible */ if($command->hasPublicMethod('revert')) { $output->writeLn("Reverting $command"); $command->revert(); continue; } $style->warning("Command {$command->getName()} cannot be reverted, revert method is not defined"); } $this->commandsExecuted = []; }
[ "private", "function", "revert", "(", "$", "output", ",", "$", "input", ",", "$", "style", ")", "{", "/* Revert commands in backwards order */", "for", "(", "$", "n", "=", "count", "(", "$", "this", "->", "commandsExecuted", ")", ";", "$", "n", ">", "0", ";", "$", "n", "--", ")", "{", "$", "command", "=", "$", "this", "->", "commandsExecuted", "[", "$", "n", "-", "1", "]", ";", "/* Revert if possible */", "if", "(", "$", "command", "->", "hasPublicMethod", "(", "'revert'", ")", ")", "{", "$", "output", "->", "writeLn", "(", "\"Reverting $command\"", ")", ";", "$", "command", "->", "revert", "(", ")", ";", "continue", ";", "}", "$", "style", "->", "warning", "(", "\"Command {$command->getName()} cannot be reverted, revert method is not defined\"", ")", ";", "}", "$", "this", "->", "commandsExecuted", "=", "[", "]", ";", "}" ]
Reverts executed commands
[ "Reverts", "executed", "commands" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/Procedure.php#L88-L103
7,553
bishopb/vanilla
applications/dashboard/models/class.importmodel.php
ImportModel.DeleteOverwriteTables
public function DeleteOverwriteTables() { $Tables = array('Activity', 'Category', 'Comment', 'Conversation', 'ConversationMessage', 'Discussion', 'Draft', 'Invitation', 'Media', 'Message', 'Photo', 'Permission', 'Rank', 'Poll', 'PollOption', 'PollVote', 'Role', 'UserAuthentication', 'UserComment', 'UserConversation', 'UserDiscussion', 'UserMeta', 'UserRole'); // Delete the default role settings. SaveToConfig(array( 'Garden.Registration.DefaultRoles' => array(), 'Garden.Registration.ApplicantRoleID' => 0 )); // Execute the SQL. $CurrentSubstep = GetValue('CurrentSubstep', $this->Data, 0); for($i = $CurrentSubstep; $i < count($Tables); $i++) { $Table = $Tables[$i]; // Make sure the table exists. $Exists = Gdn::Structure()->Table($Table)->TableExists(); Gdn::Structure()->Reset(); if (!$Exists) continue; $this->Data['CurrentStepMessage'] = $Table; if($Table == 'Permission') $this->SQL->Delete($Table, array('RoleID <>' => 0)); else $this->SQL->Truncate($Table); if($this->Timer->ElapsedTime() > $this->MaxStepTime) { // The step's taken too long. Save the state and return. $this->Data['CurrentSubstep'] = $i + 1; return FALSE; } } if(isset($this->Data['CurrentSubstep'])) unset($this->Data['CurrentSubstep']); $this->Data['CurrentStepMessage'] = ''; return TRUE; }
php
public function DeleteOverwriteTables() { $Tables = array('Activity', 'Category', 'Comment', 'Conversation', 'ConversationMessage', 'Discussion', 'Draft', 'Invitation', 'Media', 'Message', 'Photo', 'Permission', 'Rank', 'Poll', 'PollOption', 'PollVote', 'Role', 'UserAuthentication', 'UserComment', 'UserConversation', 'UserDiscussion', 'UserMeta', 'UserRole'); // Delete the default role settings. SaveToConfig(array( 'Garden.Registration.DefaultRoles' => array(), 'Garden.Registration.ApplicantRoleID' => 0 )); // Execute the SQL. $CurrentSubstep = GetValue('CurrentSubstep', $this->Data, 0); for($i = $CurrentSubstep; $i < count($Tables); $i++) { $Table = $Tables[$i]; // Make sure the table exists. $Exists = Gdn::Structure()->Table($Table)->TableExists(); Gdn::Structure()->Reset(); if (!$Exists) continue; $this->Data['CurrentStepMessage'] = $Table; if($Table == 'Permission') $this->SQL->Delete($Table, array('RoleID <>' => 0)); else $this->SQL->Truncate($Table); if($this->Timer->ElapsedTime() > $this->MaxStepTime) { // The step's taken too long. Save the state and return. $this->Data['CurrentSubstep'] = $i + 1; return FALSE; } } if(isset($this->Data['CurrentSubstep'])) unset($this->Data['CurrentSubstep']); $this->Data['CurrentStepMessage'] = ''; return TRUE; }
[ "public", "function", "DeleteOverwriteTables", "(", ")", "{", "$", "Tables", "=", "array", "(", "'Activity'", ",", "'Category'", ",", "'Comment'", ",", "'Conversation'", ",", "'ConversationMessage'", ",", "'Discussion'", ",", "'Draft'", ",", "'Invitation'", ",", "'Media'", ",", "'Message'", ",", "'Photo'", ",", "'Permission'", ",", "'Rank'", ",", "'Poll'", ",", "'PollOption'", ",", "'PollVote'", ",", "'Role'", ",", "'UserAuthentication'", ",", "'UserComment'", ",", "'UserConversation'", ",", "'UserDiscussion'", ",", "'UserMeta'", ",", "'UserRole'", ")", ";", "// Delete the default role settings.\r", "SaveToConfig", "(", "array", "(", "'Garden.Registration.DefaultRoles'", "=>", "array", "(", ")", ",", "'Garden.Registration.ApplicantRoleID'", "=>", "0", ")", ")", ";", "// Execute the SQL.\r", "$", "CurrentSubstep", "=", "GetValue", "(", "'CurrentSubstep'", ",", "$", "this", "->", "Data", ",", "0", ")", ";", "for", "(", "$", "i", "=", "$", "CurrentSubstep", ";", "$", "i", "<", "count", "(", "$", "Tables", ")", ";", "$", "i", "++", ")", "{", "$", "Table", "=", "$", "Tables", "[", "$", "i", "]", ";", "// Make sure the table exists.\r", "$", "Exists", "=", "Gdn", "::", "Structure", "(", ")", "->", "Table", "(", "$", "Table", ")", "->", "TableExists", "(", ")", ";", "Gdn", "::", "Structure", "(", ")", "->", "Reset", "(", ")", ";", "if", "(", "!", "$", "Exists", ")", "continue", ";", "$", "this", "->", "Data", "[", "'CurrentStepMessage'", "]", "=", "$", "Table", ";", "if", "(", "$", "Table", "==", "'Permission'", ")", "$", "this", "->", "SQL", "->", "Delete", "(", "$", "Table", ",", "array", "(", "'RoleID <>'", "=>", "0", ")", ")", ";", "else", "$", "this", "->", "SQL", "->", "Truncate", "(", "$", "Table", ")", ";", "if", "(", "$", "this", "->", "Timer", "->", "ElapsedTime", "(", ")", ">", "$", "this", "->", "MaxStepTime", ")", "{", "// The step's taken too long. Save the state and return.\r", "$", "this", "->", "Data", "[", "'CurrentSubstep'", "]", "=", "$", "i", "+", "1", ";", "return", "FALSE", ";", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "Data", "[", "'CurrentSubstep'", "]", ")", ")", "unset", "(", "$", "this", "->", "Data", "[", "'CurrentSubstep'", "]", ")", ";", "$", "this", "->", "Data", "[", "'CurrentStepMessage'", "]", "=", "''", ";", "return", "TRUE", ";", "}" ]
Remove the data from the appropriate tables when we are overwriting the forum.
[ "Remove", "the", "data", "from", "the", "appropriate", "tables", "when", "we", "are", "overwriting", "the", "forum", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.importmodel.php#L369-L408
7,554
bishopb/vanilla
applications/dashboard/models/class.importmodel.php
ImportModel.GetCountSQL
public function GetCountSQL( $Aggregate, // count, max, min, etc. $ParentTable, $ChildTable, $ParentColumnName = '', $ChildColumnName = '', $ParentJoinColumn = '', $ChildJoinColumn = '') { if(!$ParentColumnName) { switch(strtolower($Aggregate)) { case 'count': $ParentColumnName = "Count{$ChildTable}s"; break; case 'max': $ParentColumnName = "Last{$ChildTable}ID"; break; case 'min': $ParentColumnName = "First{$ChildTable}ID"; break; case 'sum': $ParentColumnName = "Sum{$ChildTable}s"; break; } } if(!$ChildColumnName) $ChildColumnName = $ChildTable.'ID'; if(!$ParentJoinColumn) $ParentJoinColumn = $ParentTable.'ID'; if(!$ChildJoinColumn) $ChildJoinColumn = $ParentJoinColumn; $Result = "update :_$ParentTable p set p.$ParentColumnName = ( select $Aggregate(c.$ChildColumnName) from :_$ChildTable c where p.$ParentJoinColumn = c.$ChildJoinColumn)"; return $Result; }
php
public function GetCountSQL( $Aggregate, // count, max, min, etc. $ParentTable, $ChildTable, $ParentColumnName = '', $ChildColumnName = '', $ParentJoinColumn = '', $ChildJoinColumn = '') { if(!$ParentColumnName) { switch(strtolower($Aggregate)) { case 'count': $ParentColumnName = "Count{$ChildTable}s"; break; case 'max': $ParentColumnName = "Last{$ChildTable}ID"; break; case 'min': $ParentColumnName = "First{$ChildTable}ID"; break; case 'sum': $ParentColumnName = "Sum{$ChildTable}s"; break; } } if(!$ChildColumnName) $ChildColumnName = $ChildTable.'ID'; if(!$ParentJoinColumn) $ParentJoinColumn = $ParentTable.'ID'; if(!$ChildJoinColumn) $ChildJoinColumn = $ParentJoinColumn; $Result = "update :_$ParentTable p set p.$ParentColumnName = ( select $Aggregate(c.$ChildColumnName) from :_$ChildTable c where p.$ParentJoinColumn = c.$ChildJoinColumn)"; return $Result; }
[ "public", "function", "GetCountSQL", "(", "$", "Aggregate", ",", "// count, max, min, etc.\r", "$", "ParentTable", ",", "$", "ChildTable", ",", "$", "ParentColumnName", "=", "''", ",", "$", "ChildColumnName", "=", "''", ",", "$", "ParentJoinColumn", "=", "''", ",", "$", "ChildJoinColumn", "=", "''", ")", "{", "if", "(", "!", "$", "ParentColumnName", ")", "{", "switch", "(", "strtolower", "(", "$", "Aggregate", ")", ")", "{", "case", "'count'", ":", "$", "ParentColumnName", "=", "\"Count{$ChildTable}s\"", ";", "break", ";", "case", "'max'", ":", "$", "ParentColumnName", "=", "\"Last{$ChildTable}ID\"", ";", "break", ";", "case", "'min'", ":", "$", "ParentColumnName", "=", "\"First{$ChildTable}ID\"", ";", "break", ";", "case", "'sum'", ":", "$", "ParentColumnName", "=", "\"Sum{$ChildTable}s\"", ";", "break", ";", "}", "}", "if", "(", "!", "$", "ChildColumnName", ")", "$", "ChildColumnName", "=", "$", "ChildTable", ".", "'ID'", ";", "if", "(", "!", "$", "ParentJoinColumn", ")", "$", "ParentJoinColumn", "=", "$", "ParentTable", ".", "'ID'", ";", "if", "(", "!", "$", "ChildJoinColumn", ")", "$", "ChildJoinColumn", "=", "$", "ParentJoinColumn", ";", "$", "Result", "=", "\"update :_$ParentTable p\r\n set p.$ParentColumnName = (\r\n select $Aggregate(c.$ChildColumnName)\r\n from :_$ChildTable c\r\n where p.$ParentJoinColumn = c.$ChildJoinColumn)\"", ";", "return", "$", "Result", ";", "}" ]
Return SQL for updating a count. @param string $Aggregate count, max, min, etc. @param string $ParentTable The name of the parent table. @param string $ChildTable The name of the child table @param type $ParentColumnName @param string $ChildColumnName @param string $ParentJoinColumn @param string $ChildJoinColumn @return type
[ "Return", "SQL", "for", "updating", "a", "count", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.importmodel.php#L442-L471
7,555
bishopb/vanilla
applications/dashboard/models/class.importmodel.php
ImportModel.GetCustomImportModel
public function GetCustomImportModel() { $Header = $this->GetImportHeader(); $Source = GetValue('Source', $Header, ''); $Result = NULL; if (substr_compare('vbulletin', $Source, 0, 9, TRUE) == 0) $Result = new vBulletinImportModel(); elseif (substr_compare('vanilla 1', $Source, 0, 9, TRUE) == 0) $Result = new Vanilla1ImportModel(); if ($Result !== NULL) $Result->ImportModel = $this; return $Result; }
php
public function GetCustomImportModel() { $Header = $this->GetImportHeader(); $Source = GetValue('Source', $Header, ''); $Result = NULL; if (substr_compare('vbulletin', $Source, 0, 9, TRUE) == 0) $Result = new vBulletinImportModel(); elseif (substr_compare('vanilla 1', $Source, 0, 9, TRUE) == 0) $Result = new Vanilla1ImportModel(); if ($Result !== NULL) $Result->ImportModel = $this; return $Result; }
[ "public", "function", "GetCustomImportModel", "(", ")", "{", "$", "Header", "=", "$", "this", "->", "GetImportHeader", "(", ")", ";", "$", "Source", "=", "GetValue", "(", "'Source'", ",", "$", "Header", ",", "''", ")", ";", "$", "Result", "=", "NULL", ";", "if", "(", "substr_compare", "(", "'vbulletin'", ",", "$", "Source", ",", "0", ",", "9", ",", "TRUE", ")", "==", "0", ")", "$", "Result", "=", "new", "vBulletinImportModel", "(", ")", ";", "elseif", "(", "substr_compare", "(", "'vanilla 1'", ",", "$", "Source", ",", "0", ",", "9", ",", "TRUE", ")", "==", "0", ")", "$", "Result", "=", "new", "Vanilla1ImportModel", "(", ")", ";", "if", "(", "$", "Result", "!==", "NULL", ")", "$", "Result", "->", "ImportModel", "=", "$", "this", ";", "return", "$", "Result", ";", "}" ]
Get a custom import model based on the import's source.
[ "Get", "a", "custom", "import", "model", "based", "on", "the", "import", "s", "source", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.importmodel.php#L476-L490
7,556
bishopb/vanilla
applications/dashboard/models/class.importmodel.php
ImportModel.ProcessImportDb
public function ProcessImportDb() { // Grab a list of all of the tables. $TableNames = $this->SQL->FetchTables(':_z%'); if (count($TableNames) == 0) { throw new Gdn_UserException('Your database does not contain any import tables.'); } $Tables = array(); foreach ($TableNames as $TableName) { $TableName = StringBeginsWith($TableName, $this->Database->DatabasePrefix, TRUE, TRUE); $DestTableName = StringBeginsWith($TableName, 'z', TRUE, TRUE); $TableInfo = array('Table' => $DestTableName); $ColumnInfos = $this->SQL->FetchTableSchema($TableName); $Columns = array(); foreach ($ColumnInfos as $ColumnInfo) { $Columns[GetValue('Name', $ColumnInfo)] = Gdn::Structure()->ColumnTypeString($ColumnInfo); } $TableInfo['Columns'] = $Columns; $Tables[$DestTableName] = $TableInfo; } $this->Data['Tables'] = $Tables; return TRUE; }
php
public function ProcessImportDb() { // Grab a list of all of the tables. $TableNames = $this->SQL->FetchTables(':_z%'); if (count($TableNames) == 0) { throw new Gdn_UserException('Your database does not contain any import tables.'); } $Tables = array(); foreach ($TableNames as $TableName) { $TableName = StringBeginsWith($TableName, $this->Database->DatabasePrefix, TRUE, TRUE); $DestTableName = StringBeginsWith($TableName, 'z', TRUE, TRUE); $TableInfo = array('Table' => $DestTableName); $ColumnInfos = $this->SQL->FetchTableSchema($TableName); $Columns = array(); foreach ($ColumnInfos as $ColumnInfo) { $Columns[GetValue('Name', $ColumnInfo)] = Gdn::Structure()->ColumnTypeString($ColumnInfo); } $TableInfo['Columns'] = $Columns; $Tables[$DestTableName] = $TableInfo; } $this->Data['Tables'] = $Tables; return TRUE; }
[ "public", "function", "ProcessImportDb", "(", ")", "{", "// Grab a list of all of the tables.\r", "$", "TableNames", "=", "$", "this", "->", "SQL", "->", "FetchTables", "(", "':_z%'", ")", ";", "if", "(", "count", "(", "$", "TableNames", ")", "==", "0", ")", "{", "throw", "new", "Gdn_UserException", "(", "'Your database does not contain any import tables.'", ")", ";", "}", "$", "Tables", "=", "array", "(", ")", ";", "foreach", "(", "$", "TableNames", "as", "$", "TableName", ")", "{", "$", "TableName", "=", "StringBeginsWith", "(", "$", "TableName", ",", "$", "this", "->", "Database", "->", "DatabasePrefix", ",", "TRUE", ",", "TRUE", ")", ";", "$", "DestTableName", "=", "StringBeginsWith", "(", "$", "TableName", ",", "'z'", ",", "TRUE", ",", "TRUE", ")", ";", "$", "TableInfo", "=", "array", "(", "'Table'", "=>", "$", "DestTableName", ")", ";", "$", "ColumnInfos", "=", "$", "this", "->", "SQL", "->", "FetchTableSchema", "(", "$", "TableName", ")", ";", "$", "Columns", "=", "array", "(", ")", ";", "foreach", "(", "$", "ColumnInfos", "as", "$", "ColumnInfo", ")", "{", "$", "Columns", "[", "GetValue", "(", "'Name'", ",", "$", "ColumnInfo", ")", "]", "=", "Gdn", "::", "Structure", "(", ")", "->", "ColumnTypeString", "(", "$", "ColumnInfo", ")", ";", "}", "$", "TableInfo", "[", "'Columns'", "]", "=", "$", "Columns", ";", "$", "Tables", "[", "$", "DestTableName", "]", "=", "$", "TableInfo", ";", "}", "$", "this", "->", "Data", "[", "'Tables'", "]", "=", "$", "Tables", ";", "return", "TRUE", ";", "}" ]
Process the import tables from the database.
[ "Process", "the", "import", "tables", "from", "the", "database", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.importmodel.php#L1232-L1255
7,557
bishopb/vanilla
applications/dashboard/models/class.importmodel.php
ImportModel.RunStep
public function RunStep($Step = 1) { $Started = $this->Stat('Started'); if($Started === NULL) $this->Stat('Started', microtime(TRUE), 'time'); $Steps = $this->Steps(); $LastStep = end(array_keys($Steps)); if(!isset($Steps[$Step]) || $Step > $LastStep) { return 'COMPLETE'; } if(!$this->Timer) { $NewTimer = TRUE; $this->Timer = new Gdn_Timer(); $this->Timer->Start(''); } // Run a standard step every time. if (isset($Steps[0])) { call_user_func(array($this, $Steps[0])); } $Method = $Steps[$Step]; $Result = call_user_func(array($this, $Method)); if ($this->GenerateSQL()) { $this->SaveSQL($Method); } $ElapsedTime = $this->Timer->ElapsedTime(); $this->Stat('Time Spent on Import', $ElapsedTime, 'add'); if(isset($NewTimer)) $this->Timer->Finish(''); if($Result && !array_key_exists($Step + 1, $this->Steps())) $this->Stat('Finished', microtime(TRUE), 'time'); return $Result; }
php
public function RunStep($Step = 1) { $Started = $this->Stat('Started'); if($Started === NULL) $this->Stat('Started', microtime(TRUE), 'time'); $Steps = $this->Steps(); $LastStep = end(array_keys($Steps)); if(!isset($Steps[$Step]) || $Step > $LastStep) { return 'COMPLETE'; } if(!$this->Timer) { $NewTimer = TRUE; $this->Timer = new Gdn_Timer(); $this->Timer->Start(''); } // Run a standard step every time. if (isset($Steps[0])) { call_user_func(array($this, $Steps[0])); } $Method = $Steps[$Step]; $Result = call_user_func(array($this, $Method)); if ($this->GenerateSQL()) { $this->SaveSQL($Method); } $ElapsedTime = $this->Timer->ElapsedTime(); $this->Stat('Time Spent on Import', $ElapsedTime, 'add'); if(isset($NewTimer)) $this->Timer->Finish(''); if($Result && !array_key_exists($Step + 1, $this->Steps())) $this->Stat('Finished', microtime(TRUE), 'time'); return $Result; }
[ "public", "function", "RunStep", "(", "$", "Step", "=", "1", ")", "{", "$", "Started", "=", "$", "this", "->", "Stat", "(", "'Started'", ")", ";", "if", "(", "$", "Started", "===", "NULL", ")", "$", "this", "->", "Stat", "(", "'Started'", ",", "microtime", "(", "TRUE", ")", ",", "'time'", ")", ";", "$", "Steps", "=", "$", "this", "->", "Steps", "(", ")", ";", "$", "LastStep", "=", "end", "(", "array_keys", "(", "$", "Steps", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "Steps", "[", "$", "Step", "]", ")", "||", "$", "Step", ">", "$", "LastStep", ")", "{", "return", "'COMPLETE'", ";", "}", "if", "(", "!", "$", "this", "->", "Timer", ")", "{", "$", "NewTimer", "=", "TRUE", ";", "$", "this", "->", "Timer", "=", "new", "Gdn_Timer", "(", ")", ";", "$", "this", "->", "Timer", "->", "Start", "(", "''", ")", ";", "}", "// Run a standard step every time.\r", "if", "(", "isset", "(", "$", "Steps", "[", "0", "]", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "this", ",", "$", "Steps", "[", "0", "]", ")", ")", ";", "}", "$", "Method", "=", "$", "Steps", "[", "$", "Step", "]", ";", "$", "Result", "=", "call_user_func", "(", "array", "(", "$", "this", ",", "$", "Method", ")", ")", ";", "if", "(", "$", "this", "->", "GenerateSQL", "(", ")", ")", "{", "$", "this", "->", "SaveSQL", "(", "$", "Method", ")", ";", "}", "$", "ElapsedTime", "=", "$", "this", "->", "Timer", "->", "ElapsedTime", "(", ")", ";", "$", "this", "->", "Stat", "(", "'Time Spent on Import'", ",", "$", "ElapsedTime", ",", "'add'", ")", ";", "if", "(", "isset", "(", "$", "NewTimer", ")", ")", "$", "this", "->", "Timer", "->", "Finish", "(", "''", ")", ";", "if", "(", "$", "Result", "&&", "!", "array_key_exists", "(", "$", "Step", "+", "1", ",", "$", "this", "->", "Steps", "(", ")", ")", ")", "$", "this", "->", "Stat", "(", "'Finished'", ",", "microtime", "(", "TRUE", ")", ",", "'time'", ")", ";", "return", "$", "Result", ";", "}" ]
Run the step in the import. @param int $Step the step to run. @return mixed Whether the step succeeded or an array of information.
[ "Run", "the", "step", "in", "the", "import", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.importmodel.php#L1338-L1376
7,558
bishopb/vanilla
applications/dashboard/models/class.importmodel.php
ImportModel.Query
public function Query($Sql, $Parameters = NULL) { $Db = Gdn::Database(); // Replace db prefixes. $Sql = str_replace(array(':_z', ':_'), array($Db->DatabasePrefix.self::TABLE_PREFIX, $Db->DatabasePrefix), $Sql); // Figure out the type of the type of the query. if (StringBeginsWith($Sql, 'select')) $Type = 'select'; elseif (StringBeginsWith($Sql, 'truncate')) $Type = 'truncate'; elseif (StringBeginsWith($Sql, 'insert')) $Type = 'insert'; elseif (StringBeginsWith($Sql, 'update')) $Type = 'update'; elseif (StringBeginsWith($Sql, 'delete')) $Type = 'delete'; else $Type = 'select'; // Execute the query. if (is_array($Parameters)) $this->SQL->NamedParameters($Parameters); $Result = $this->SQL->Query($Sql, $Type); //$this->Timer->Split('Sql: '. str_replace("\n", "\n ", $Sql)); return $Result; }
php
public function Query($Sql, $Parameters = NULL) { $Db = Gdn::Database(); // Replace db prefixes. $Sql = str_replace(array(':_z', ':_'), array($Db->DatabasePrefix.self::TABLE_PREFIX, $Db->DatabasePrefix), $Sql); // Figure out the type of the type of the query. if (StringBeginsWith($Sql, 'select')) $Type = 'select'; elseif (StringBeginsWith($Sql, 'truncate')) $Type = 'truncate'; elseif (StringBeginsWith($Sql, 'insert')) $Type = 'insert'; elseif (StringBeginsWith($Sql, 'update')) $Type = 'update'; elseif (StringBeginsWith($Sql, 'delete')) $Type = 'delete'; else $Type = 'select'; // Execute the query. if (is_array($Parameters)) $this->SQL->NamedParameters($Parameters); $Result = $this->SQL->Query($Sql, $Type); //$this->Timer->Split('Sql: '. str_replace("\n", "\n ", $Sql)); return $Result; }
[ "public", "function", "Query", "(", "$", "Sql", ",", "$", "Parameters", "=", "NULL", ")", "{", "$", "Db", "=", "Gdn", "::", "Database", "(", ")", ";", "// Replace db prefixes.\r", "$", "Sql", "=", "str_replace", "(", "array", "(", "':_z'", ",", "':_'", ")", ",", "array", "(", "$", "Db", "->", "DatabasePrefix", ".", "self", "::", "TABLE_PREFIX", ",", "$", "Db", "->", "DatabasePrefix", ")", ",", "$", "Sql", ")", ";", "// Figure out the type of the type of the query.\r", "if", "(", "StringBeginsWith", "(", "$", "Sql", ",", "'select'", ")", ")", "$", "Type", "=", "'select'", ";", "elseif", "(", "StringBeginsWith", "(", "$", "Sql", ",", "'truncate'", ")", ")", "$", "Type", "=", "'truncate'", ";", "elseif", "(", "StringBeginsWith", "(", "$", "Sql", ",", "'insert'", ")", ")", "$", "Type", "=", "'insert'", ";", "elseif", "(", "StringBeginsWith", "(", "$", "Sql", ",", "'update'", ")", ")", "$", "Type", "=", "'update'", ";", "elseif", "(", "StringBeginsWith", "(", "$", "Sql", ",", "'delete'", ")", ")", "$", "Type", "=", "'delete'", ";", "else", "$", "Type", "=", "'select'", ";", "// Execute the query.\r", "if", "(", "is_array", "(", "$", "Parameters", ")", ")", "$", "this", "->", "SQL", "->", "NamedParameters", "(", "$", "Parameters", ")", ";", "$", "Result", "=", "$", "this", "->", "SQL", "->", "Query", "(", "$", "Sql", ",", "$", "Type", ")", ";", "//$this->Timer->Split('Sql: '. str_replace(\"\\n\", \"\\n \", $Sql));\r", "return", "$", "Result", ";", "}" ]
Run a query, replacing database prefixes. @param string $Sql The sql to execute. - :_z will be replaced by the import prefix. - :_ will be replaced by the database prefix. @param array $Parameters PDO parameters to pass to the query. @return Gdn_DataSet
[ "Run", "a", "query", "replacing", "database", "prefixes", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.importmodel.php#L1386-L1415
7,559
bishopb/vanilla
applications/dashboard/models/class.importmodel.php
ImportModel.SetCategoryPermissionIDs
public function SetCategoryPermissionIDs() { // First build a list of category $Permissions = $this->SQL->GetWhere('Permission', array('JunctionColumn' => 'PermissionCategoryID', 'JunctionID >' => 0))->ResultArray(); $CategoryIDs = array(); foreach ($Permissions as $Row) { $CategoryIDs[$Row['JunctionID']] = $Row['JunctionID']; } // Update all of the child categories. $Root = CategoryModel::Categories(-1); $this->_SetCategoryPermissionIDs($Root, $Root['CategoryID'], $CategoryIDs); }
php
public function SetCategoryPermissionIDs() { // First build a list of category $Permissions = $this->SQL->GetWhere('Permission', array('JunctionColumn' => 'PermissionCategoryID', 'JunctionID >' => 0))->ResultArray(); $CategoryIDs = array(); foreach ($Permissions as $Row) { $CategoryIDs[$Row['JunctionID']] = $Row['JunctionID']; } // Update all of the child categories. $Root = CategoryModel::Categories(-1); $this->_SetCategoryPermissionIDs($Root, $Root['CategoryID'], $CategoryIDs); }
[ "public", "function", "SetCategoryPermissionIDs", "(", ")", "{", "// First build a list of category\r", "$", "Permissions", "=", "$", "this", "->", "SQL", "->", "GetWhere", "(", "'Permission'", ",", "array", "(", "'JunctionColumn'", "=>", "'PermissionCategoryID'", ",", "'JunctionID >'", "=>", "0", ")", ")", "->", "ResultArray", "(", ")", ";", "$", "CategoryIDs", "=", "array", "(", ")", ";", "foreach", "(", "$", "Permissions", "as", "$", "Row", ")", "{", "$", "CategoryIDs", "[", "$", "Row", "[", "'JunctionID'", "]", "]", "=", "$", "Row", "[", "'JunctionID'", "]", ";", "}", "// Update all of the child categories.\r", "$", "Root", "=", "CategoryModel", "::", "Categories", "(", "-", "1", ")", ";", "$", "this", "->", "_SetCategoryPermissionIDs", "(", "$", "Root", ",", "$", "Root", "[", "'CategoryID'", "]", ",", "$", "CategoryIDs", ")", ";", "}" ]
Set the category permissions based on the permission table.
[ "Set", "the", "category", "permissions", "based", "on", "the", "permission", "table", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.importmodel.php#L1440-L1451
7,560
budkit/budkit-framework
src/Budkit/Parameter/Repository/Parser/Ini.php
Ini.readParams
public function readParams($filename) { //We will only parse the file if it has not already been parsed!; if (!array_key_exists($filename, $this->namespace)) { if (file_exists($filename)) { if (($this->namespace[$filename] = parse_ini_file($filename, true)) === FALSE) { throw new Exception("Could not Parse the ini file {$filename}"); return false; } else { //Add the iniParams to $this->params; return $this->namespace[$filename]; } } else { // throw new Exception( sprintf("The configuration file (%s) does not exists",$filename ) ); return []; } } else { return $this->namespace[$filename]; } }
php
public function readParams($filename) { //We will only parse the file if it has not already been parsed!; if (!array_key_exists($filename, $this->namespace)) { if (file_exists($filename)) { if (($this->namespace[$filename] = parse_ini_file($filename, true)) === FALSE) { throw new Exception("Could not Parse the ini file {$filename}"); return false; } else { //Add the iniParams to $this->params; return $this->namespace[$filename]; } } else { // throw new Exception( sprintf("The configuration file (%s) does not exists",$filename ) ); return []; } } else { return $this->namespace[$filename]; } }
[ "public", "function", "readParams", "(", "$", "filename", ")", "{", "//We will only parse the file if it has not already been parsed!;", "if", "(", "!", "array_key_exists", "(", "$", "filename", ",", "$", "this", "->", "namespace", ")", ")", "{", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "if", "(", "(", "$", "this", "->", "namespace", "[", "$", "filename", "]", "=", "parse_ini_file", "(", "$", "filename", ",", "true", ")", ")", "===", "FALSE", ")", "{", "throw", "new", "Exception", "(", "\"Could not Parse the ini file {$filename}\"", ")", ";", "return", "false", ";", "}", "else", "{", "//Add the iniParams to $this->params;", "return", "$", "this", "->", "namespace", "[", "$", "filename", "]", ";", "}", "}", "else", "{", "// throw new Exception( sprintf(\"The configuration file (%s) does not exists\",$filename ) );", "return", "[", "]", ";", "}", "}", "else", "{", "return", "$", "this", "->", "namespace", "[", "$", "filename", "]", ";", "}", "}" ]
Parses an INI configuration file @param type $filename @return boolean
[ "Parses", "an", "INI", "configuration", "file" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Parameter/Repository/Parser/Ini.php#L50-L70
7,561
budkit/budkit-framework
src/Budkit/Parameter/Repository/Parser/Ini.php
Ini.saveParams
public function saveParams(array $parameters, $environment = "") { foreach ($parameters as $namespace => $section) { $_file = PATH_CONFIG . DS . strtolower($namespace) . ".ini"; $_globals = ""; foreach ($section as $key => $params) { if (!empty($params) && is_array($params)) { // 2 loops to write `globals' on top, alternative: buffer $_globals .= static::toIniString($params, $key); } } //Only save if the config file is not empty if (!empty($_globals)) { //check if we have a file; if (!$this->isFile($_file)) { if (!$this->create($_file)) { throw new \Exception("Could not create the configuration file {$_file}. Please check you have sufficient permission to do this"); return false; } } //write to file if (!$this->write($_file, $_globals)) { throw new \Exception(t("Could not write out to the configuration file")); return false; } } } return true; }
php
public function saveParams(array $parameters, $environment = "") { foreach ($parameters as $namespace => $section) { $_file = PATH_CONFIG . DS . strtolower($namespace) . ".ini"; $_globals = ""; foreach ($section as $key => $params) { if (!empty($params) && is_array($params)) { // 2 loops to write `globals' on top, alternative: buffer $_globals .= static::toIniString($params, $key); } } //Only save if the config file is not empty if (!empty($_globals)) { //check if we have a file; if (!$this->isFile($_file)) { if (!$this->create($_file)) { throw new \Exception("Could not create the configuration file {$_file}. Please check you have sufficient permission to do this"); return false; } } //write to file if (!$this->write($_file, $_globals)) { throw new \Exception(t("Could not write out to the configuration file")); return false; } } } return true; }
[ "public", "function", "saveParams", "(", "array", "$", "parameters", ",", "$", "environment", "=", "\"\"", ")", "{", "foreach", "(", "$", "parameters", "as", "$", "namespace", "=>", "$", "section", ")", "{", "$", "_file", "=", "PATH_CONFIG", ".", "DS", ".", "strtolower", "(", "$", "namespace", ")", ".", "\".ini\"", ";", "$", "_globals", "=", "\"\"", ";", "foreach", "(", "$", "section", "as", "$", "key", "=>", "$", "params", ")", "{", "if", "(", "!", "empty", "(", "$", "params", ")", "&&", "is_array", "(", "$", "params", ")", ")", "{", "// 2 loops to write `globals' on top, alternative: buffer", "$", "_globals", ".=", "static", "::", "toIniString", "(", "$", "params", ",", "$", "key", ")", ";", "}", "}", "//Only save if the config file is not empty", "if", "(", "!", "empty", "(", "$", "_globals", ")", ")", "{", "//check if we have a file;", "if", "(", "!", "$", "this", "->", "isFile", "(", "$", "_file", ")", ")", "{", "if", "(", "!", "$", "this", "->", "create", "(", "$", "_file", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Could not create the configuration file {$_file}. Please check you have sufficient permission to do this\"", ")", ";", "return", "false", ";", "}", "}", "//write to file", "if", "(", "!", "$", "this", "->", "write", "(", "$", "_file", ",", "$", "_globals", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "t", "(", "\"Could not write out to the configuration file\"", ")", ")", ";", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Save configuration param section or sections to an ini file @param type $file @param type $sections
[ "Save", "configuration", "param", "section", "or", "sections", "to", "an", "ini", "file" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Parameter/Repository/Parser/Ini.php#L78-L115
7,562
budkit/budkit-framework
src/Budkit/Parameter/Repository/Parser/Ini.php
Ini.getParams
public function getParams($filename = "") { if (empty($filename)) { return $this->namespace; } elseif (!empty($filename) && isset($this->namespace[$filename])) { return $this->namespace[$filename]; } else { return array(); //if the params don't exists; } }
php
public function getParams($filename = "") { if (empty($filename)) { return $this->namespace; } elseif (!empty($filename) && isset($this->namespace[$filename])) { return $this->namespace[$filename]; } else { return array(); //if the params don't exists; } }
[ "public", "function", "getParams", "(", "$", "filename", "=", "\"\"", ")", "{", "if", "(", "empty", "(", "$", "filename", ")", ")", "{", "return", "$", "this", "->", "namespace", ";", "}", "elseif", "(", "!", "empty", "(", "$", "filename", ")", "&&", "isset", "(", "$", "this", "->", "namespace", "[", "$", "filename", "]", ")", ")", "{", "return", "$", "this", "->", "namespace", "[", "$", "filename", "]", ";", "}", "else", "{", "return", "array", "(", ")", ";", "//if the params don't exists;", "}", "}" ]
Returns the read ini file parameters @param type $filename @return type
[ "Returns", "the", "read", "ini", "file", "parameters" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Parameter/Repository/Parser/Ini.php#L123-L133
7,563
budkit/budkit-framework
src/Budkit/Parameter/Repository/Parser/Ini.php
Ini.toIniString
public static function toIniString($params = array(), $section = NULL) { $_br = "\n"; $_tab = NULL; //Use "\t" to indent; $_globals = !empty($section) ? "\n[" . $section . "]\n" : ''; foreach ($params as $param => $value) { if (!is_array($value)) { $value = static::normalizeValue($value); //BUG: Non alphanumeric value need to be stored in double quotes $_globals .= $_tab . $param . ' = ' . (Validate::isAlphaNumeric($value) ? $value : '"' . $value . '"') . $_br; } } return $_globals; }
php
public static function toIniString($params = array(), $section = NULL) { $_br = "\n"; $_tab = NULL; //Use "\t" to indent; $_globals = !empty($section) ? "\n[" . $section . "]\n" : ''; foreach ($params as $param => $value) { if (!is_array($value)) { $value = static::normalizeValue($value); //BUG: Non alphanumeric value need to be stored in double quotes $_globals .= $_tab . $param . ' = ' . (Validate::isAlphaNumeric($value) ? $value : '"' . $value . '"') . $_br; } } return $_globals; }
[ "public", "static", "function", "toIniString", "(", "$", "params", "=", "array", "(", ")", ",", "$", "section", "=", "NULL", ")", "{", "$", "_br", "=", "\"\\n\"", ";", "$", "_tab", "=", "NULL", ";", "//Use \"\\t\" to indent;", "$", "_globals", "=", "!", "empty", "(", "$", "section", ")", "?", "\"\\n[\"", ".", "$", "section", ".", "\"]\\n\"", ":", "''", ";", "foreach", "(", "$", "params", "as", "$", "param", "=>", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "static", "::", "normalizeValue", "(", "$", "value", ")", ";", "//BUG: Non alphanumeric value need to be stored in double quotes", "$", "_globals", ".=", "$", "_tab", ".", "$", "param", ".", "' = '", ".", "(", "Validate", "::", "isAlphaNumeric", "(", "$", "value", ")", "?", "$", "value", ":", "'\"'", ".", "$", "value", ".", "'\"'", ")", ".", "$", "_br", ";", "}", "}", "return", "$", "_globals", ";", "}" ]
Converts a config array of elements to an ini string @param type $params @param type $section @return string
[ "Converts", "a", "config", "array", "of", "elements", "to", "an", "ini", "string" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Parameter/Repository/Parser/Ini.php#L142-L157
7,564
budkit/budkit-framework
src/Budkit/Parameter/Repository/Parser/Ini.php
Ini.normalizeValue
protected static function normalizeValue($value) { if (is_bool($value)) { $value = (bool)$value; return $value; } elseif (is_numeric($value)) { return (int)$value; } return $value; }
php
protected static function normalizeValue($value) { if (is_bool($value)) { $value = (bool)$value; return $value; } elseif (is_numeric($value)) { return (int)$value; } return $value; }
[ "protected", "static", "function", "normalizeValue", "(", "$", "value", ")", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "value", "=", "(", "bool", ")", "$", "value", ";", "return", "$", "value", ";", "}", "elseif", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "(", "int", ")", "$", "value", ";", "}", "return", "$", "value", ";", "}" ]
normalize a Value by determining the Type @param string $value value @return string
[ "normalize", "a", "Value", "by", "determining", "the", "Type" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Parameter/Repository/Parser/Ini.php#L167-L176
7,565
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.select
public function select($columns = "*") { $this->start = $columns; $this->queryType = self::QUERY_SELECT; return $this; }
php
public function select($columns = "*") { $this->start = $columns; $this->queryType = self::QUERY_SELECT; return $this; }
[ "public", "function", "select", "(", "$", "columns", "=", "\"*\"", ")", "{", "$", "this", "->", "start", "=", "$", "columns", ";", "$", "this", "->", "queryType", "=", "self", "::", "QUERY_SELECT", ";", "return", "$", "this", ";", "}" ]
Fake select method, used to maximize compatibility @param string $columns @return Query $this
[ "Fake", "select", "method", "used", "to", "maximize", "compatibility" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L141-L146
7,566
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.insert
public function insert($table = "") { $this->start = ""; $this->queryType = self::QUERY_INSERT; $this->into($table); return $this; }
php
public function insert($table = "") { $this->start = ""; $this->queryType = self::QUERY_INSERT; $this->into($table); return $this; }
[ "public", "function", "insert", "(", "$", "table", "=", "\"\"", ")", "{", "$", "this", "->", "start", "=", "\"\"", ";", "$", "this", "->", "queryType", "=", "self", "::", "QUERY_INSERT", ";", "$", "this", "->", "into", "(", "$", "table", ")", ";", "return", "$", "this", ";", "}" ]
Start insert mode @param string $table Table name @return Query $this
[ "Start", "insert", "mode" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L165-L171
7,567
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.into
public function into($table = "") { if (empty($table)) { $table = $this->structure->tableName; } $this->table = $table; $this->queryType = self::QUERY_INSERT; // Determinate the column order $this->columnOrder = array(); foreach ($this->structure->columns as $column) { $this->columnOrder[] = $column; } return $this; }
php
public function into($table = "") { if (empty($table)) { $table = $this->structure->tableName; } $this->table = $table; $this->queryType = self::QUERY_INSERT; // Determinate the column order $this->columnOrder = array(); foreach ($this->structure->columns as $column) { $this->columnOrder[] = $column; } return $this; }
[ "public", "function", "into", "(", "$", "table", "=", "\"\"", ")", "{", "if", "(", "empty", "(", "$", "table", ")", ")", "{", "$", "table", "=", "$", "this", "->", "structure", "->", "tableName", ";", "}", "$", "this", "->", "table", "=", "$", "table", ";", "$", "this", "->", "queryType", "=", "self", "::", "QUERY_INSERT", ";", "// Determinate the column order", "$", "this", "->", "columnOrder", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "structure", "->", "columns", "as", "$", "column", ")", "{", "$", "this", "->", "columnOrder", "[", "]", "=", "$", "column", ";", "}", "return", "$", "this", ";", "}" ]
Insert into table @param string $table @return Query $this
[ "Insert", "into", "table" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L179-L195
7,568
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.delete
public function delete($table = "") { if (empty($table)) { $table = $this->structure->tableName; // @codeCoverageIgnore } $this->table = $table; $this->queryType = self::QUERY_DELETE; return $this; }
php
public function delete($table = "") { if (empty($table)) { $table = $this->structure->tableName; // @codeCoverageIgnore } $this->table = $table; $this->queryType = self::QUERY_DELETE; return $this; }
[ "public", "function", "delete", "(", "$", "table", "=", "\"\"", ")", "{", "if", "(", "empty", "(", "$", "table", ")", ")", "{", "$", "table", "=", "$", "this", "->", "structure", "->", "tableName", ";", "// @codeCoverageIgnore", "}", "$", "this", "->", "table", "=", "$", "table", ";", "$", "this", "->", "queryType", "=", "self", "::", "QUERY_DELETE", ";", "return", "$", "this", ";", "}" ]
Set mode to Delete @param string $table Table name @return Query $this
[ "Set", "mode", "to", "Delete" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L227-L237
7,569
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.custom
public function custom($sql, $bind = array()) { // Prepare query $query = ConnectionManager::getConnection()->prepare($sql); // Bind when needed if (count($bind) > 0) { $numericBinding = true; // Check if we are going to use the numeric binding foreach($bind as $key => $value) { if (is_int($key)) { continue; }else{ $numericBinding = false; // @codeCoverageIgnore if (substr($key, 0, 1) !== ':') { // @codeCoverageIgnore throw new QueryException("When binding, you should use numeric keys or keys with : before each key to identify the binding place in the query!"); // @codeCoverageIgnore } // @codeCoverageIgnore } } // Bind it! $idx = 1; foreach($bind as $key => $value) { if ($numericBinding) { if (is_int($value)) { $type = \PDO::PARAM_INT; // @codeCoverageIgnore } elseif(is_bool($value)) { $type = \PDO::PARAM_BOOL; // @codeCoverageIgnore } else { $type = \PDO::PARAM_STR; } $query->bindValue($idx, $value, $type); } else { $query->bindValue($key, $value); } } } // Set fetch mode $query->setFetchMode(\PDO::FETCH_CLASS, $this->class); // Execute $query->execute(); // Fetch and return return $this->injectState($query->fetchAll()); }
php
public function custom($sql, $bind = array()) { // Prepare query $query = ConnectionManager::getConnection()->prepare($sql); // Bind when needed if (count($bind) > 0) { $numericBinding = true; // Check if we are going to use the numeric binding foreach($bind as $key => $value) { if (is_int($key)) { continue; }else{ $numericBinding = false; // @codeCoverageIgnore if (substr($key, 0, 1) !== ':') { // @codeCoverageIgnore throw new QueryException("When binding, you should use numeric keys or keys with : before each key to identify the binding place in the query!"); // @codeCoverageIgnore } // @codeCoverageIgnore } } // Bind it! $idx = 1; foreach($bind as $key => $value) { if ($numericBinding) { if (is_int($value)) { $type = \PDO::PARAM_INT; // @codeCoverageIgnore } elseif(is_bool($value)) { $type = \PDO::PARAM_BOOL; // @codeCoverageIgnore } else { $type = \PDO::PARAM_STR; } $query->bindValue($idx, $value, $type); } else { $query->bindValue($key, $value); } } } // Set fetch mode $query->setFetchMode(\PDO::FETCH_CLASS, $this->class); // Execute $query->execute(); // Fetch and return return $this->injectState($query->fetchAll()); }
[ "public", "function", "custom", "(", "$", "sql", ",", "$", "bind", "=", "array", "(", ")", ")", "{", "// Prepare query", "$", "query", "=", "ConnectionManager", "::", "getConnection", "(", ")", "->", "prepare", "(", "$", "sql", ")", ";", "// Bind when needed", "if", "(", "count", "(", "$", "bind", ")", ">", "0", ")", "{", "$", "numericBinding", "=", "true", ";", "// Check if we are going to use the numeric binding", "foreach", "(", "$", "bind", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "key", ")", ")", "{", "continue", ";", "}", "else", "{", "$", "numericBinding", "=", "false", ";", "// @codeCoverageIgnore", "if", "(", "substr", "(", "$", "key", ",", "0", ",", "1", ")", "!==", "':'", ")", "{", "// @codeCoverageIgnore", "throw", "new", "QueryException", "(", "\"When binding, you should use numeric keys or keys with : before each key to identify the binding place in the query!\"", ")", ";", "// @codeCoverageIgnore", "}", "// @codeCoverageIgnore", "}", "}", "// Bind it!", "$", "idx", "=", "1", ";", "foreach", "(", "$", "bind", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "numericBinding", ")", "{", "if", "(", "is_int", "(", "$", "value", ")", ")", "{", "$", "type", "=", "\\", "PDO", "::", "PARAM_INT", ";", "// @codeCoverageIgnore", "}", "elseif", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "type", "=", "\\", "PDO", "::", "PARAM_BOOL", ";", "// @codeCoverageIgnore", "}", "else", "{", "$", "type", "=", "\\", "PDO", "::", "PARAM_STR", ";", "}", "$", "query", "->", "bindValue", "(", "$", "idx", ",", "$", "value", ",", "$", "type", ")", ";", "}", "else", "{", "$", "query", "->", "bindValue", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}", "// Set fetch mode", "$", "query", "->", "setFetchMode", "(", "\\", "PDO", "::", "FETCH_CLASS", ",", "$", "this", "->", "class", ")", ";", "// Execute", "$", "query", "->", "execute", "(", ")", ";", "// Fetch and return", "return", "$", "this", "->", "injectState", "(", "$", "query", "->", "fetchAll", "(", ")", ")", ";", "}" ]
Execute custom query. @param string $sql @param array $bind @throws QueryException @throws \PDOException @return Entity[]
[ "Execute", "custom", "query", "." ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L251-L298
7,570
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.set
public function set($data) { if ($this->queryType !== self::QUERY_INSERT && $this->queryType !== self::QUERY_UPDATE) { $this->exception = new QueryException("When using set/data you must do a insert into or update first! Query is not in UPDATE or INSERT mode!", 0, $this->exception); // @codeCoverageIgnore return $this; // @codeCoverageIgnore } if (! is_array($data)) { $this->exception = new QueryException("set()/data() must have an array data parameter!", 0, $this->exception); // @codeCoverageIgnore return $this; // @codeCoverageIgnore } // Prepare the data $this->data = ""; $this->changeData = array(); // Verify and generate insert parts foreach ($this->columnOrder as $currentColumn) { // Verify if all the columns that are non-null exists when inserting if ($this->queryType === self::QUERY_INSERT) { // We MUST fill in the non null columns, with exception on the auto increment column if (! $currentColumn->null && ! $currentColumn->autoIncrement) { if (! isset($data[$currentColumn->name])) { $this->exception = new QueryException("Inserting data failed, data must contain all non-null columns defined in the entity!", 0, $this->exception); // @codeCoverageIgnore return $this; // @codeCoverageIgnore } } } // Skip primary key when updating. if ($this->queryType === self::QUERY_UPDATE && $currentColumn->primary) { // Skip continue; } // If data exists for current column if (isset($data[$currentColumn->name])) { $value = $data[$currentColumn->name]; // Current column exists, save data $this->changeData[$currentColumn->name] = $value; } else { // We will insert NULL in this column, it's not given in the $data array $this->changeData[$currentColumn->name] = null; } } return $this; }
php
public function set($data) { if ($this->queryType !== self::QUERY_INSERT && $this->queryType !== self::QUERY_UPDATE) { $this->exception = new QueryException("When using set/data you must do a insert into or update first! Query is not in UPDATE or INSERT mode!", 0, $this->exception); // @codeCoverageIgnore return $this; // @codeCoverageIgnore } if (! is_array($data)) { $this->exception = new QueryException("set()/data() must have an array data parameter!", 0, $this->exception); // @codeCoverageIgnore return $this; // @codeCoverageIgnore } // Prepare the data $this->data = ""; $this->changeData = array(); // Verify and generate insert parts foreach ($this->columnOrder as $currentColumn) { // Verify if all the columns that are non-null exists when inserting if ($this->queryType === self::QUERY_INSERT) { // We MUST fill in the non null columns, with exception on the auto increment column if (! $currentColumn->null && ! $currentColumn->autoIncrement) { if (! isset($data[$currentColumn->name])) { $this->exception = new QueryException("Inserting data failed, data must contain all non-null columns defined in the entity!", 0, $this->exception); // @codeCoverageIgnore return $this; // @codeCoverageIgnore } } } // Skip primary key when updating. if ($this->queryType === self::QUERY_UPDATE && $currentColumn->primary) { // Skip continue; } // If data exists for current column if (isset($data[$currentColumn->name])) { $value = $data[$currentColumn->name]; // Current column exists, save data $this->changeData[$currentColumn->name] = $value; } else { // We will insert NULL in this column, it's not given in the $data array $this->changeData[$currentColumn->name] = null; } } return $this; }
[ "public", "function", "set", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "queryType", "!==", "self", "::", "QUERY_INSERT", "&&", "$", "this", "->", "queryType", "!==", "self", "::", "QUERY_UPDATE", ")", "{", "$", "this", "->", "exception", "=", "new", "QueryException", "(", "\"When using set/data you must do a insert into or update first! Query is not in UPDATE or INSERT mode!\"", ",", "0", ",", "$", "this", "->", "exception", ")", ";", "// @codeCoverageIgnore", "return", "$", "this", ";", "// @codeCoverageIgnore", "}", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "this", "->", "exception", "=", "new", "QueryException", "(", "\"set()/data() must have an array data parameter!\"", ",", "0", ",", "$", "this", "->", "exception", ")", ";", "// @codeCoverageIgnore", "return", "$", "this", ";", "// @codeCoverageIgnore", "}", "// Prepare the data", "$", "this", "->", "data", "=", "\"\"", ";", "$", "this", "->", "changeData", "=", "array", "(", ")", ";", "// Verify and generate insert parts", "foreach", "(", "$", "this", "->", "columnOrder", "as", "$", "currentColumn", ")", "{", "// Verify if all the columns that are non-null exists when inserting", "if", "(", "$", "this", "->", "queryType", "===", "self", "::", "QUERY_INSERT", ")", "{", "// We MUST fill in the non null columns, with exception on the auto increment column", "if", "(", "!", "$", "currentColumn", "->", "null", "&&", "!", "$", "currentColumn", "->", "autoIncrement", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "currentColumn", "->", "name", "]", ")", ")", "{", "$", "this", "->", "exception", "=", "new", "QueryException", "(", "\"Inserting data failed, data must contain all non-null columns defined in the entity!\"", ",", "0", ",", "$", "this", "->", "exception", ")", ";", "// @codeCoverageIgnore", "return", "$", "this", ";", "// @codeCoverageIgnore", "}", "}", "}", "// Skip primary key when updating.", "if", "(", "$", "this", "->", "queryType", "===", "self", "::", "QUERY_UPDATE", "&&", "$", "currentColumn", "->", "primary", ")", "{", "// Skip", "continue", ";", "}", "// If data exists for current column", "if", "(", "isset", "(", "$", "data", "[", "$", "currentColumn", "->", "name", "]", ")", ")", "{", "$", "value", "=", "$", "data", "[", "$", "currentColumn", "->", "name", "]", ";", "// Current column exists, save data", "$", "this", "->", "changeData", "[", "$", "currentColumn", "->", "name", "]", "=", "$", "value", ";", "}", "else", "{", "// We will insert NULL in this column, it's not given in the $data array", "$", "this", "->", "changeData", "[", "$", "currentColumn", "->", "name", "]", "=", "null", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set data for inserting or updating @param array $data @return Query $this
[ "Set", "data", "for", "inserting", "or", "updating" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L314-L361
7,571
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.offset
public function offset($offset) { if ($this->queryType !== self::QUERY_SELECT) { $this->exception = new QueryException("Offset can only be applied on SELECT mode!", 0, $this->exception); return $this; } if (! is_int($offset) || $offset < 0) { $this->exception = new QueryException("Offset value should be an positive integer!", 0, $this->exception); return $this; } $this->limitOffset = intval($offset); return $this; }
php
public function offset($offset) { if ($this->queryType !== self::QUERY_SELECT) { $this->exception = new QueryException("Offset can only be applied on SELECT mode!", 0, $this->exception); return $this; } if (! is_int($offset) || $offset < 0) { $this->exception = new QueryException("Offset value should be an positive integer!", 0, $this->exception); return $this; } $this->limitOffset = intval($offset); return $this; }
[ "public", "function", "offset", "(", "$", "offset", ")", "{", "if", "(", "$", "this", "->", "queryType", "!==", "self", "::", "QUERY_SELECT", ")", "{", "$", "this", "->", "exception", "=", "new", "QueryException", "(", "\"Offset can only be applied on SELECT mode!\"", ",", "0", ",", "$", "this", "->", "exception", ")", ";", "return", "$", "this", ";", "}", "if", "(", "!", "is_int", "(", "$", "offset", ")", "||", "$", "offset", "<", "0", ")", "{", "$", "this", "->", "exception", "=", "new", "QueryException", "(", "\"Offset value should be an positive integer!\"", ",", "0", ",", "$", "this", "->", "exception", ")", ";", "return", "$", "this", ";", "}", "$", "this", "->", "limitOffset", "=", "intval", "(", "$", "offset", ")", ";", "return", "$", "this", ";", "}" ]
Offset the results @param int $offset Give the number of offset applied to the results. @return Query $this The current query stack.
[ "Offset", "the", "results" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L507-L520
7,572
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.sort
public function sort($column, $type = 'ASC') { if ($this->queryType !== self::QUERY_SELECT) { $this->exception = new QueryException("Sorting can only be applied on SELECT mode!", 0, $this->exception); return $this; } // First lets upper the type. $type = strtoupper($type); if (! is_string($column)) { $this->exception = new QueryException("Sorting column must be an string!", 0, $this->exception); } if (! $this->validOrderType($type)) { $this->exception = new QueryException("Sorting requires a type that is either 'ASC' or 'DESC'!", 0, $this->exception); return $this; } // Validate the column if (in_array($column, $this->structure->columnNames)) { $this->sortBy = $column; $this->sortOrder = $type; } return $this; }
php
public function sort($column, $type = 'ASC') { if ($this->queryType !== self::QUERY_SELECT) { $this->exception = new QueryException("Sorting can only be applied on SELECT mode!", 0, $this->exception); return $this; } // First lets upper the type. $type = strtoupper($type); if (! is_string($column)) { $this->exception = new QueryException("Sorting column must be an string!", 0, $this->exception); } if (! $this->validOrderType($type)) { $this->exception = new QueryException("Sorting requires a type that is either 'ASC' or 'DESC'!", 0, $this->exception); return $this; } // Validate the column if (in_array($column, $this->structure->columnNames)) { $this->sortBy = $column; $this->sortOrder = $type; } return $this; }
[ "public", "function", "sort", "(", "$", "column", ",", "$", "type", "=", "'ASC'", ")", "{", "if", "(", "$", "this", "->", "queryType", "!==", "self", "::", "QUERY_SELECT", ")", "{", "$", "this", "->", "exception", "=", "new", "QueryException", "(", "\"Sorting can only be applied on SELECT mode!\"", ",", "0", ",", "$", "this", "->", "exception", ")", ";", "return", "$", "this", ";", "}", "// First lets upper the type.", "$", "type", "=", "strtoupper", "(", "$", "type", ")", ";", "if", "(", "!", "is_string", "(", "$", "column", ")", ")", "{", "$", "this", "->", "exception", "=", "new", "QueryException", "(", "\"Sorting column must be an string!\"", ",", "0", ",", "$", "this", "->", "exception", ")", ";", "}", "if", "(", "!", "$", "this", "->", "validOrderType", "(", "$", "type", ")", ")", "{", "$", "this", "->", "exception", "=", "new", "QueryException", "(", "\"Sorting requires a type that is either 'ASC' or 'DESC'!\"", ",", "0", ",", "$", "this", "->", "exception", ")", ";", "return", "$", "this", ";", "}", "// Validate the column", "if", "(", "in_array", "(", "$", "column", ",", "$", "this", "->", "structure", "->", "columnNames", ")", ")", "{", "$", "this", "->", "sortBy", "=", "$", "column", ";", "$", "this", "->", "sortOrder", "=", "$", "type", ";", "}", "return", "$", "this", ";", "}" ]
Sort by column value, Ascending or descending @param string $column Column name to order with. @param string $type Either ASC or DESC for the order type. @return Query $this The current query stack.
[ "Sort", "by", "column", "value", "Ascending", "or", "descending" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L529-L555
7,573
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.all
public function all() { if ($this->exception !== null) { throw $this->exception; } return $this->fetch(true, $this->fetchAssoc); }
php
public function all() { if ($this->exception !== null) { throw $this->exception; } return $this->fetch(true, $this->fetchAssoc); }
[ "public", "function", "all", "(", ")", "{", "if", "(", "$", "this", "->", "exception", "!==", "null", ")", "{", "throw", "$", "this", "->", "exception", ";", "}", "return", "$", "this", "->", "fetch", "(", "true", ",", "$", "this", "->", "fetchAssoc", ")", ";", "}" ]
Execute Query and fetch all records as entities @return false|\SweetORM\Entity[] Entities as successful result or false on not found. @throws QueryException
[ "Execute", "Query", "and", "fetch", "all", "records", "as", "entities" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L573-L580
7,574
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.one
public function one() { if ($this->exception !== null) { throw $this->exception; } return $this->fetch(false, $this->fetchAssoc); }
php
public function one() { if ($this->exception !== null) { throw $this->exception; } return $this->fetch(false, $this->fetchAssoc); }
[ "public", "function", "one", "(", ")", "{", "if", "(", "$", "this", "->", "exception", "!==", "null", ")", "{", "throw", "$", "this", "->", "exception", ";", "}", "return", "$", "this", "->", "fetch", "(", "false", ",", "$", "this", "->", "fetchAssoc", ")", ";", "}" ]
Execute Query and fetch a single record as entity @return Entity[]|false Entities as successful result or false on not found. @throws QueryException
[ "Execute", "Query", "and", "fetch", "a", "single", "record", "as", "entity" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L588-L595
7,575
tomvlk/sweet-orm
src/SweetORM/Database/Query.php
Query.validValue
private function validValue($value, $operator) { if (! $this->validOperator($operator)) { return false; // @codeCoverageIgnore } if ($operator === "IN") { // Valid should be an array! return is_array($value); } if ($operator === "IS NOT") { return is_null($value); } return !is_array($value); }
php
private function validValue($value, $operator) { if (! $this->validOperator($operator)) { return false; // @codeCoverageIgnore } if ($operator === "IN") { // Valid should be an array! return is_array($value); } if ($operator === "IS NOT") { return is_null($value); } return !is_array($value); }
[ "private", "function", "validValue", "(", "$", "value", ",", "$", "operator", ")", "{", "if", "(", "!", "$", "this", "->", "validOperator", "(", "$", "operator", ")", ")", "{", "return", "false", ";", "// @codeCoverageIgnore", "}", "if", "(", "$", "operator", "===", "\"IN\"", ")", "{", "// Valid should be an array!", "return", "is_array", "(", "$", "value", ")", ";", "}", "if", "(", "$", "operator", "===", "\"IS NOT\"", ")", "{", "return", "is_null", "(", "$", "value", ")", ";", "}", "return", "!", "is_array", "(", "$", "value", ")", ";", "}" ]
Validate value for given operator @param mixed $value @param string $operator @return bool
[ "Validate", "value", "for", "given", "operator" ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/Query.php#L803-L818
7,576
clagiordano/weblibs-dbabstraction
src/AbstractEntity.php
AbstractEntity.__isset
public function __isset($name) { if (!in_array($name, $this->allowedFields)) { throw new \InvalidArgumentException( "The field '$name' is not allowed for this entity." ); } return isset($this->values[$name]); }
php
public function __isset($name) { if (!in_array($name, $this->allowedFields)) { throw new \InvalidArgumentException( "The field '$name' is not allowed for this entity." ); } return isset($this->values[$name]); }
[ "public", "function", "__isset", "(", "$", "name", ")", "{", "if", "(", "!", "in_array", "(", "$", "name", ",", "$", "this", "->", "allowedFields", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"The field '$name' is not allowed for this entity.\"", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "values", "[", "$", "name", "]", ")", ";", "}" ]
Check if the specified field has been assigned to the entity @param $name @return bool
[ "Check", "if", "the", "specified", "field", "has", "been", "assigned", "to", "the", "entity" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/AbstractEntity.php#L82-L91
7,577
novuso/system
src/Collection/Iterator/GeneratorIterator.php
GeneratorIterator.send
public function send($value = null) { if (!$this->generator) { $this->rewind(); } return $this->generator->send($value); }
php
public function send($value = null) { if (!$this->generator) { $this->rewind(); } return $this->generator->send($value); }
[ "public", "function", "send", "(", "$", "value", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "generator", ")", "{", "$", "this", "->", "rewind", "(", ")", ";", "}", "return", "$", "this", "->", "generator", "->", "send", "(", "$", "value", ")", ";", "}" ]
Sends a value to the generator Sends the given value to the generator as the result of the current yield expression and resumes execution of the generator. If the generator is not at a yield expression when this method is called, it will first be let to advance to the first yield expression before sending the value. As such it is not necessary to "prime" PHP generators with a Generator::next() call (like it is done in Python). @param mixed $value The value @return mixed
[ "Sends", "a", "value", "to", "the", "generator" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Iterator/GeneratorIterator.php#L134-L141
7,578
phn-io/dal
src/Phn/Dal/Engine.php
Engine.build
public function build() { $tokenParsers = []; $executionStrategies = []; $functions = []; foreach ($this->extensions as $extension) { $tokenParsers = array_merge($tokenParsers, $extension->getTokenParsers()); $executionStrategies = array_merge($executionStrategies, $extension->getExecutionStrategies()); $functions = array_merge($functions, $extension->getFunctions()); } $registry = new Registry($tokenParsers, [], [], '<{', '}>'); $this->syntax = new Syntax(new Lexer(new TemplateLexer($registry)), new Parser(new TemplateParser($registry))); $this->executionStrategies = new ExecutionStrategyCollection($executionStrategies); $this->environment = new Environment($functions); $this->isLocked = true; }
php
public function build() { $tokenParsers = []; $executionStrategies = []; $functions = []; foreach ($this->extensions as $extension) { $tokenParsers = array_merge($tokenParsers, $extension->getTokenParsers()); $executionStrategies = array_merge($executionStrategies, $extension->getExecutionStrategies()); $functions = array_merge($functions, $extension->getFunctions()); } $registry = new Registry($tokenParsers, [], [], '<{', '}>'); $this->syntax = new Syntax(new Lexer(new TemplateLexer($registry)), new Parser(new TemplateParser($registry))); $this->executionStrategies = new ExecutionStrategyCollection($executionStrategies); $this->environment = new Environment($functions); $this->isLocked = true; }
[ "public", "function", "build", "(", ")", "{", "$", "tokenParsers", "=", "[", "]", ";", "$", "executionStrategies", "=", "[", "]", ";", "$", "functions", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "extensions", "as", "$", "extension", ")", "{", "$", "tokenParsers", "=", "array_merge", "(", "$", "tokenParsers", ",", "$", "extension", "->", "getTokenParsers", "(", ")", ")", ";", "$", "executionStrategies", "=", "array_merge", "(", "$", "executionStrategies", ",", "$", "extension", "->", "getExecutionStrategies", "(", ")", ")", ";", "$", "functions", "=", "array_merge", "(", "$", "functions", ",", "$", "extension", "->", "getFunctions", "(", ")", ")", ";", "}", "$", "registry", "=", "new", "Registry", "(", "$", "tokenParsers", ",", "[", "]", ",", "[", "]", ",", "'<{'", ",", "'}>'", ")", ";", "$", "this", "->", "syntax", "=", "new", "Syntax", "(", "new", "Lexer", "(", "new", "TemplateLexer", "(", "$", "registry", ")", ")", ",", "new", "Parser", "(", "new", "TemplateParser", "(", "$", "registry", ")", ")", ")", ";", "$", "this", "->", "executionStrategies", "=", "new", "ExecutionStrategyCollection", "(", "$", "executionStrategies", ")", ";", "$", "this", "->", "environment", "=", "new", "Environment", "(", "$", "functions", ")", ";", "$", "this", "->", "isLocked", "=", "true", ";", "}" ]
Builds the Engine.
[ "Builds", "the", "Engine", "." ]
4bcb0d09eb049579ce128dcf2cd592ab7ae0ace3
https://github.com/phn-io/dal/blob/4bcb0d09eb049579ce128dcf2cd592ab7ae0ace3/src/Phn/Dal/Engine.php#L138-L159
7,579
phn-io/dal
src/Phn/Dal/Engine.php
Engine.loadLayerAndCheck
private function loadLayerAndCheck($path, array $stack) { if (in_array($path, $stack)) { throw new LogicException(sprintf( 'Circular reference detected:'.PHP_EOL.' - file: %s'.PHP_EOL.' - load: %s then crash', implode(PHP_EOL.' - load: ', $stack), $path )); } $metadata = unserialize(file_get_contents($this->getMetaFilename($path))); $pgVersion = $this->connection->getVersion(); $cmpVersion = $metadata->getSupport(); if (version_compare($pgVersion, $cmpVersion, '<')) { throw new LogicException(sprintf( 'The current version of PostgreSQL is "%s" and the DAL "%s" requires a minimum version of "%s"', $pgVersion, $path, $cmpVersion )); } $stack[] = $path; $this->graphNodes[$path] = $graphNode = new GraphNode(); $mapper = new HierarchicalMapper($graphNode); $mapper->setType('#', new FragmentConverter()); $blueprint = new HierarchicalBlueprint($graphNode, $this->connection, $mapper, $this->executionStrategies, $this->environment); foreach ($metadata->getImports() as $import => $map) { $this->doLoad($import, $stack); $graphNode->import($this->graphNodes[$import], $map); } return $this->loadLayer($this->getFilename($path), $mapper, $blueprint); }
php
private function loadLayerAndCheck($path, array $stack) { if (in_array($path, $stack)) { throw new LogicException(sprintf( 'Circular reference detected:'.PHP_EOL.' - file: %s'.PHP_EOL.' - load: %s then crash', implode(PHP_EOL.' - load: ', $stack), $path )); } $metadata = unserialize(file_get_contents($this->getMetaFilename($path))); $pgVersion = $this->connection->getVersion(); $cmpVersion = $metadata->getSupport(); if (version_compare($pgVersion, $cmpVersion, '<')) { throw new LogicException(sprintf( 'The current version of PostgreSQL is "%s" and the DAL "%s" requires a minimum version of "%s"', $pgVersion, $path, $cmpVersion )); } $stack[] = $path; $this->graphNodes[$path] = $graphNode = new GraphNode(); $mapper = new HierarchicalMapper($graphNode); $mapper->setType('#', new FragmentConverter()); $blueprint = new HierarchicalBlueprint($graphNode, $this->connection, $mapper, $this->executionStrategies, $this->environment); foreach ($metadata->getImports() as $import => $map) { $this->doLoad($import, $stack); $graphNode->import($this->graphNodes[$import], $map); } return $this->loadLayer($this->getFilename($path), $mapper, $blueprint); }
[ "private", "function", "loadLayerAndCheck", "(", "$", "path", ",", "array", "$", "stack", ")", "{", "if", "(", "in_array", "(", "$", "path", ",", "$", "stack", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'Circular reference detected:'", ".", "PHP_EOL", ".", "' - file: %s'", ".", "PHP_EOL", ".", "' - load: %s then crash'", ",", "implode", "(", "PHP_EOL", ".", "' - load: '", ",", "$", "stack", ")", ",", "$", "path", ")", ")", ";", "}", "$", "metadata", "=", "unserialize", "(", "file_get_contents", "(", "$", "this", "->", "getMetaFilename", "(", "$", "path", ")", ")", ")", ";", "$", "pgVersion", "=", "$", "this", "->", "connection", "->", "getVersion", "(", ")", ";", "$", "cmpVersion", "=", "$", "metadata", "->", "getSupport", "(", ")", ";", "if", "(", "version_compare", "(", "$", "pgVersion", ",", "$", "cmpVersion", ",", "'<'", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'The current version of PostgreSQL is \"%s\" and the DAL \"%s\" requires a minimum version of \"%s\"'", ",", "$", "pgVersion", ",", "$", "path", ",", "$", "cmpVersion", ")", ")", ";", "}", "$", "stack", "[", "]", "=", "$", "path", ";", "$", "this", "->", "graphNodes", "[", "$", "path", "]", "=", "$", "graphNode", "=", "new", "GraphNode", "(", ")", ";", "$", "mapper", "=", "new", "HierarchicalMapper", "(", "$", "graphNode", ")", ";", "$", "mapper", "->", "setType", "(", "'#'", ",", "new", "FragmentConverter", "(", ")", ")", ";", "$", "blueprint", "=", "new", "HierarchicalBlueprint", "(", "$", "graphNode", ",", "$", "this", "->", "connection", ",", "$", "mapper", ",", "$", "this", "->", "executionStrategies", ",", "$", "this", "->", "environment", ")", ";", "foreach", "(", "$", "metadata", "->", "getImports", "(", ")", "as", "$", "import", "=>", "$", "map", ")", "{", "$", "this", "->", "doLoad", "(", "$", "import", ",", "$", "stack", ")", ";", "$", "graphNode", "->", "import", "(", "$", "this", "->", "graphNodes", "[", "$", "import", "]", ",", "$", "map", ")", ";", "}", "return", "$", "this", "->", "loadLayer", "(", "$", "this", "->", "getFilename", "(", "$", "path", ")", ",", "$", "mapper", ",", "$", "blueprint", ")", ";", "}" ]
Loads the DAL for the given path and do some check about the supported version of the loaded files and that there is no circular references between them. This method will check that: - The PostgreSQL version matches the supported version of the DAL. - The loaded DAL does not induces circular reference. @param string $path The path of the DAL to load. @param string[] $stack The stack of paths that have been loaded since the current call. @throws LogicException When a circular reference is detected. @throws LogicException When the version of PostgreSQL doesn't match the minimum version required. @return AbstractDal
[ "Loads", "the", "DAL", "for", "the", "given", "path", "and", "do", "some", "check", "about", "the", "supported", "version", "of", "the", "loaded", "files", "and", "that", "there", "is", "no", "circular", "references", "between", "them", "." ]
4bcb0d09eb049579ce128dcf2cd592ab7ae0ace3
https://github.com/phn-io/dal/blob/4bcb0d09eb049579ce128dcf2cd592ab7ae0ace3/src/Phn/Dal/Engine.php#L225-L265
7,580
CupOfTea696/Chain
src/Chain.php
Chain.on
public function on($class) { $this->instance = is_string($class) ? $this->container !== null ? $this->container->make($class) : new $class : $class; return $this; }
php
public function on($class) { $this->instance = is_string($class) ? $this->container !== null ? $this->container->make($class) : new $class : $class; return $this; }
[ "public", "function", "on", "(", "$", "class", ")", "{", "$", "this", "->", "instance", "=", "is_string", "(", "$", "class", ")", "?", "$", "this", "->", "container", "!==", "null", "?", "$", "this", "->", "container", "->", "make", "(", "$", "class", ")", ":", "new", "$", "class", ":", "$", "class", ";", "return", "$", "this", ";", "}" ]
Specify Class or Class Instance to chain methods on. @param string|object $class Class or Class Instance to chain methods on. @return CupOfTea\Chain\Chain The Chain object.
[ "Specify", "Class", "or", "Class", "Instance", "to", "chain", "methods", "on", "." ]
51b53649924622b9001597a047b970bf83681950
https://github.com/CupOfTea696/Chain/blob/51b53649924622b9001597a047b970bf83681950/src/Chain.php#L96-L101
7,581
CupOfTea696/Chain
src/Chain.php
Chain.run
public function run() { if ($this->requires !== null && ! $this->instance instanceof $this->requires) { throw new WrongClassException(get_class($this->instance), $this->requires); } return array_reduce($this->methods, function ($results, $method) { if (! method_exists($this->instance, $method) && ! $this->forgiving) { throw new InvalidMethodException(get_class($this->instance), $method); } $results->addResult($method, call_user_func_array([$this->instance, $method], $this->parameters)); return $results; }, new Results())->done(); }
php
public function run() { if ($this->requires !== null && ! $this->instance instanceof $this->requires) { throw new WrongClassException(get_class($this->instance), $this->requires); } return array_reduce($this->methods, function ($results, $method) { if (! method_exists($this->instance, $method) && ! $this->forgiving) { throw new InvalidMethodException(get_class($this->instance), $method); } $results->addResult($method, call_user_func_array([$this->instance, $method], $this->parameters)); return $results; }, new Results())->done(); }
[ "public", "function", "run", "(", ")", "{", "if", "(", "$", "this", "->", "requires", "!==", "null", "&&", "!", "$", "this", "->", "instance", "instanceof", "$", "this", "->", "requires", ")", "{", "throw", "new", "WrongClassException", "(", "get_class", "(", "$", "this", "->", "instance", ")", ",", "$", "this", "->", "requires", ")", ";", "}", "return", "array_reduce", "(", "$", "this", "->", "methods", ",", "function", "(", "$", "results", ",", "$", "method", ")", "{", "if", "(", "!", "method_exists", "(", "$", "this", "->", "instance", ",", "$", "method", ")", "&&", "!", "$", "this", "->", "forgiving", ")", "{", "throw", "new", "InvalidMethodException", "(", "get_class", "(", "$", "this", "->", "instance", ")", ",", "$", "method", ")", ";", "}", "$", "results", "->", "addResult", "(", "$", "method", ",", "call_user_func_array", "(", "[", "$", "this", "->", "instance", ",", "$", "method", "]", ",", "$", "this", "->", "parameters", ")", ")", ";", "return", "$", "results", ";", "}", ",", "new", "Results", "(", ")", ")", "->", "done", "(", ")", ";", "}" ]
Run the Chain of methods on the Class. @return CupOfTea\Chain\Results Object containing the results from each method.
[ "Run", "the", "Chain", "of", "methods", "on", "the", "Class", "." ]
51b53649924622b9001597a047b970bf83681950
https://github.com/CupOfTea696/Chain/blob/51b53649924622b9001597a047b970bf83681950/src/Chain.php#L148-L163
7,582
taniko/romans
src/Roman.php
Roman.isRoman
public static function isRoman(string $str) : bool { $str = strtoupper(Parser::replaceRoman($str)); $ary = Parser::strToArray($str); $result = true; foreach ($ary as $key => $value) { $code = Mbstring::mb_ord($value); if ($code >= 97 && 122) { $value = strtoupper($value); } if (array_key_exists($value, self::$romans)) { continue; } else { $result = false; break; } } if ($result) { foreach (self::$romans as $key => $value) { while (mb_strpos($str, $key) === 0) { $str = mb_substr($str, strlen($key)); } } $result = mb_strlen($str) === 0; } return $result; }
php
public static function isRoman(string $str) : bool { $str = strtoupper(Parser::replaceRoman($str)); $ary = Parser::strToArray($str); $result = true; foreach ($ary as $key => $value) { $code = Mbstring::mb_ord($value); if ($code >= 97 && 122) { $value = strtoupper($value); } if (array_key_exists($value, self::$romans)) { continue; } else { $result = false; break; } } if ($result) { foreach (self::$romans as $key => $value) { while (mb_strpos($str, $key) === 0) { $str = mb_substr($str, strlen($key)); } } $result = mb_strlen($str) === 0; } return $result; }
[ "public", "static", "function", "isRoman", "(", "string", "$", "str", ")", ":", "bool", "{", "$", "str", "=", "strtoupper", "(", "Parser", "::", "replaceRoman", "(", "$", "str", ")", ")", ";", "$", "ary", "=", "Parser", "::", "strToArray", "(", "$", "str", ")", ";", "$", "result", "=", "true", ";", "foreach", "(", "$", "ary", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "code", "=", "Mbstring", "::", "mb_ord", "(", "$", "value", ")", ";", "if", "(", "$", "code", ">=", "97", "&&", "122", ")", "{", "$", "value", "=", "strtoupper", "(", "$", "value", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "value", ",", "self", "::", "$", "romans", ")", ")", "{", "continue", ";", "}", "else", "{", "$", "result", "=", "false", ";", "break", ";", "}", "}", "if", "(", "$", "result", ")", "{", "foreach", "(", "self", "::", "$", "romans", "as", "$", "key", "=>", "$", "value", ")", "{", "while", "(", "mb_strpos", "(", "$", "str", ",", "$", "key", ")", "===", "0", ")", "{", "$", "str", "=", "mb_substr", "(", "$", "str", ",", "strlen", "(", "$", "key", ")", ")", ";", "}", "}", "$", "result", "=", "mb_strlen", "(", "$", "str", ")", "===", "0", ";", "}", "return", "$", "result", ";", "}" ]
validate that string is roman numerals @param string $str variable being evaluated @return bool return true or false
[ "validate", "that", "string", "is", "roman", "numerals" ]
60721a61a0050c83e876cbf009e70aa93cabb1d2
https://github.com/taniko/romans/blob/60721a61a0050c83e876cbf009e70aa93cabb1d2/src/Roman.php#L19-L45
7,583
lciolecki/zf-extensions-library
library/Extlib/Session/SaveHandler/Doctrine2.php
Doctrine2.setLifetime
public function setLifetime($lifetime, $overrideLifetime = null) { if ($lifetime < 0) { throw new \Zend_Session_SaveHandler_Exception('$lifetime must be greater than 0.'); } else if (empty($lifetime)) { $this->lifetime = (int) ini_get('session.gc_maxlifetime'); } else { $this->lifetime = (int) $lifetime; } if ($overrideLifetime != null) { $this->setOverrideLifetime($overrideLifetime); } return $this; }
php
public function setLifetime($lifetime, $overrideLifetime = null) { if ($lifetime < 0) { throw new \Zend_Session_SaveHandler_Exception('$lifetime must be greater than 0.'); } else if (empty($lifetime)) { $this->lifetime = (int) ini_get('session.gc_maxlifetime'); } else { $this->lifetime = (int) $lifetime; } if ($overrideLifetime != null) { $this->setOverrideLifetime($overrideLifetime); } return $this; }
[ "public", "function", "setLifetime", "(", "$", "lifetime", ",", "$", "overrideLifetime", "=", "null", ")", "{", "if", "(", "$", "lifetime", "<", "0", ")", "{", "throw", "new", "\\", "Zend_Session_SaveHandler_Exception", "(", "'$lifetime must be greater than 0.'", ")", ";", "}", "else", "if", "(", "empty", "(", "$", "lifetime", ")", ")", "{", "$", "this", "->", "lifetime", "=", "(", "int", ")", "ini_get", "(", "'session.gc_maxlifetime'", ")", ";", "}", "else", "{", "$", "this", "->", "lifetime", "=", "(", "int", ")", "$", "lifetime", ";", "}", "if", "(", "$", "overrideLifetime", "!=", "null", ")", "{", "$", "this", "->", "setOverrideLifetime", "(", "$", "overrideLifetime", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set session lifetime and optional whether or not the lifetime of an existing session should be overridden $lifetime === false resets lifetime to session.gc_maxlifetime @param int $lifetime @param boolean $overrideLifetime (optional) @return \Extlib\Session\SaveHandler\Doctrine2 @throws \Zend_Session_SaveHandler_Exception
[ "Set", "session", "lifetime", "and", "optional", "whether", "or", "not", "the", "lifetime", "of", "an", "existing", "session", "should", "be", "overridden" ]
f479a63188d17f1488b392d4fc14fe47a417ea55
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Session/SaveHandler/Doctrine2.php#L157-L172
7,584
studyportals/Cache
src/Memcache.php
Memcache.connect
static public function connect( \Memcache $Memcache, $host, $port = 11211, $persistent = true){ $host = (string) $host; $port = (int) $port; if($persistent){ $result = @$Memcache->pconnect($host, $port); } else{ $result = @$Memcache->connect($host, $port); } if($result && self::COMPRESS_THRESHOLD > 0){ /** @noinspection PhpVoidFunctionResultUsedInspection */ /** @noinspection PhpUnusedLocalVariableInspection */ $compress = @$Memcache->setcompressthreshold( self::COMPRESS_THRESHOLD, self::COMPRESS_SAVINGS); assert('$compress !== false'); } return $result; }
php
static public function connect( \Memcache $Memcache, $host, $port = 11211, $persistent = true){ $host = (string) $host; $port = (int) $port; if($persistent){ $result = @$Memcache->pconnect($host, $port); } else{ $result = @$Memcache->connect($host, $port); } if($result && self::COMPRESS_THRESHOLD > 0){ /** @noinspection PhpVoidFunctionResultUsedInspection */ /** @noinspection PhpUnusedLocalVariableInspection */ $compress = @$Memcache->setcompressthreshold( self::COMPRESS_THRESHOLD, self::COMPRESS_SAVINGS); assert('$compress !== false'); } return $result; }
[ "static", "public", "function", "connect", "(", "\\", "Memcache", "$", "Memcache", ",", "$", "host", ",", "$", "port", "=", "11211", ",", "$", "persistent", "=", "true", ")", "{", "$", "host", "=", "(", "string", ")", "$", "host", ";", "$", "port", "=", "(", "int", ")", "$", "port", ";", "if", "(", "$", "persistent", ")", "{", "$", "result", "=", "@", "$", "Memcache", "->", "pconnect", "(", "$", "host", ",", "$", "port", ")", ";", "}", "else", "{", "$", "result", "=", "@", "$", "Memcache", "->", "connect", "(", "$", "host", ",", "$", "port", ")", ";", "}", "if", "(", "$", "result", "&&", "self", "::", "COMPRESS_THRESHOLD", ">", "0", ")", "{", "/** @noinspection PhpVoidFunctionResultUsedInspection */", "/** @noinspection PhpUnusedLocalVariableInspection */", "$", "compress", "=", "@", "$", "Memcache", "->", "setcompressthreshold", "(", "self", "::", "COMPRESS_THRESHOLD", ",", "self", "::", "COMPRESS_SAVINGS", ")", ";", "assert", "(", "'$compress !== false'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Connect a Memcache-instance. <p>The connection-state of the provided {@link $Memcache}-instance is <strong>not</strong> checked before attempting to connect it. So, passing in an already connected instance is not recommended and will most likely lead to unexpected results.</p> @param \Memcache $Memcache @param string $host @param integer $port @param boolean $persistent @return boolean
[ "Connect", "a", "Memcache", "-", "instance", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/Memcache.php#L39-L65
7,585
studyportals/Cache
src/Memcache.php
Memcache.isConnected
static public function isConnected(\Memcache $Memcache){ /** @noinspection PhpVoidFunctionResultUsedInspection */ $version = @$Memcache->getVersion(); if($version === false){ return false; } return true; }
php
static public function isConnected(\Memcache $Memcache){ /** @noinspection PhpVoidFunctionResultUsedInspection */ $version = @$Memcache->getVersion(); if($version === false){ return false; } return true; }
[ "static", "public", "function", "isConnected", "(", "\\", "Memcache", "$", "Memcache", ")", "{", "/** @noinspection PhpVoidFunctionResultUsedInspection */", "$", "version", "=", "@", "$", "Memcache", "->", "getVersion", "(", ")", ";", "if", "(", "$", "version", "===", "false", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if the provided Memcache-instance is connected. <p>As there is not built-in functionality in the PHP Memcache class to check if an instance is connected we use a simple workaround by querying the version of the (connected) Memcache server. If we fail to get a version it's (relatively) safe to assume the instance is not connected.</p> @param \Memcache $Memcache @return bool
[ "Check", "if", "the", "provided", "Memcache", "-", "instance", "is", "connected", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/Memcache.php#L80-L91
7,586
easy-system/es-http
src/Request.php
Request.setTarget
protected function setTarget($target) { if ('*' == $target) { $this->target = $target; return $this; } if (is_string($target)) { $target = new Uri($target); } if (! $target instanceof UriInterface) { throw new InvalidArgumentException(sprintf( 'Invalid target provided; must be an string or instance of ' . '"%s", "%s" received.', 'Psr\\Http\\Message\\UriInterface', is_object($target) ? get_class($target) : gettype($target) )); } $this->target = (string) $target->withFragment(''); return $this; }
php
protected function setTarget($target) { if ('*' == $target) { $this->target = $target; return $this; } if (is_string($target)) { $target = new Uri($target); } if (! $target instanceof UriInterface) { throw new InvalidArgumentException(sprintf( 'Invalid target provided; must be an string or instance of ' . '"%s", "%s" received.', 'Psr\\Http\\Message\\UriInterface', is_object($target) ? get_class($target) : gettype($target) )); } $this->target = (string) $target->withFragment(''); return $this; }
[ "protected", "function", "setTarget", "(", "$", "target", ")", "{", "if", "(", "'*'", "==", "$", "target", ")", "{", "$", "this", "->", "target", "=", "$", "target", ";", "return", "$", "this", ";", "}", "if", "(", "is_string", "(", "$", "target", ")", ")", "{", "$", "target", "=", "new", "Uri", "(", "$", "target", ")", ";", "}", "if", "(", "!", "$", "target", "instanceof", "UriInterface", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid target provided; must be an string or instance of '", ".", "'\"%s\", \"%s\" received.'", ",", "'Psr\\\\Http\\\\Message\\\\UriInterface'", ",", "is_object", "(", "$", "target", ")", "?", "get_class", "(", "$", "target", ")", ":", "gettype", "(", "$", "target", ")", ")", ")", ";", "}", "$", "this", "->", "target", "=", "(", "string", ")", "$", "target", "->", "withFragment", "(", "''", ")", ";", "return", "$", "this", ";", "}" ]
Sets the request HTTP target. @param string|\Psr\Http\Message\UriInterface $target The target @throws \InvalidArgumentException If invalid target provided @return self
[ "Sets", "the", "request", "HTTP", "target", "." ]
dd5852e94901e147a7546a8715133408ece767a1
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Request.php#L231-L253
7,587
easy-system/es-http
src/Request.php
Request.setUri
protected function setUri($uri, $preserveHost = false) { if (is_string($uri)) { $uri = new Uri($uri); } if (! $uri instanceof UriInterface) { throw new InvalidArgumentException(sprintf( 'Invalid URI provided. Must be null, a string, or ' . 'Psr\Http\Message\UriInterface; received "%s".', is_object($uri) ? get_class($uri) : gettype($uri) )); } $this->uri = $uri; if ($preserveHost && $this->hasHeader('Host')) { return $this; } if (! $uri->getHost()) { return $this; } $host = $uri->getHost(); if ($uri->getPort()) { $host .= ':' . $uri->getPort(); } $this->setHeader('Host', $host); return $this; }
php
protected function setUri($uri, $preserveHost = false) { if (is_string($uri)) { $uri = new Uri($uri); } if (! $uri instanceof UriInterface) { throw new InvalidArgumentException(sprintf( 'Invalid URI provided. Must be null, a string, or ' . 'Psr\Http\Message\UriInterface; received "%s".', is_object($uri) ? get_class($uri) : gettype($uri) )); } $this->uri = $uri; if ($preserveHost && $this->hasHeader('Host')) { return $this; } if (! $uri->getHost()) { return $this; } $host = $uri->getHost(); if ($uri->getPort()) { $host .= ':' . $uri->getPort(); } $this->setHeader('Host', $host); return $this; }
[ "protected", "function", "setUri", "(", "$", "uri", ",", "$", "preserveHost", "=", "false", ")", "{", "if", "(", "is_string", "(", "$", "uri", ")", ")", "{", "$", "uri", "=", "new", "Uri", "(", "$", "uri", ")", ";", "}", "if", "(", "!", "$", "uri", "instanceof", "UriInterface", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid URI provided. Must be null, a string, or '", ".", "'Psr\\Http\\Message\\UriInterface; received \"%s\".'", ",", "is_object", "(", "$", "uri", ")", "?", "get_class", "(", "$", "uri", ")", ":", "gettype", "(", "$", "uri", ")", ")", ")", ";", "}", "$", "this", "->", "uri", "=", "$", "uri", ";", "if", "(", "$", "preserveHost", "&&", "$", "this", "->", "hasHeader", "(", "'Host'", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "$", "uri", "->", "getHost", "(", ")", ")", "{", "return", "$", "this", ";", "}", "$", "host", "=", "$", "uri", "->", "getHost", "(", ")", ";", "if", "(", "$", "uri", "->", "getPort", "(", ")", ")", "{", "$", "host", ".=", "':'", ".", "$", "uri", "->", "getPort", "(", ")", ";", "}", "$", "this", "->", "setHeader", "(", "'Host'", ",", "$", "host", ")", ";", "return", "$", "this", ";", "}" ]
Sets the URI. @param string|\Psr\Http\Message\UriInterface $uri The URI If the URI contains a host component, the Host header will update. You can opt-in to preserving the original state of the Host header by setting `$preserveHost` to `true`. @param bool $preserveHost Preserve the original state of the Host header @throws \InvalidArgumentException If Invalid URI provided @return self
[ "Sets", "the", "URI", "." ]
dd5852e94901e147a7546a8715133408ece767a1
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Request.php#L269-L298
7,588
10usb/css-lib
src/values/Value.php
Value.parse
public static function parse($value){ if(preg_match(Name::PATTERN, $value)) return new Name($value); if(preg_match(Text::PATTERN, $value)) return new Text($value); if(preg_match(Color::PATTERN, $value)) return new Color($value); if(preg_match(Measurement::PATTERN, $value)) return new Measurement($value); throw new \Exception("Invalid Value '$value'"); }
php
public static function parse($value){ if(preg_match(Name::PATTERN, $value)) return new Name($value); if(preg_match(Text::PATTERN, $value)) return new Text($value); if(preg_match(Color::PATTERN, $value)) return new Color($value); if(preg_match(Measurement::PATTERN, $value)) return new Measurement($value); throw new \Exception("Invalid Value '$value'"); }
[ "public", "static", "function", "parse", "(", "$", "value", ")", "{", "if", "(", "preg_match", "(", "Name", "::", "PATTERN", ",", "$", "value", ")", ")", "return", "new", "Name", "(", "$", "value", ")", ";", "if", "(", "preg_match", "(", "Text", "::", "PATTERN", ",", "$", "value", ")", ")", "return", "new", "Text", "(", "$", "value", ")", ";", "if", "(", "preg_match", "(", "Color", "::", "PATTERN", ",", "$", "value", ")", ")", "return", "new", "Color", "(", "$", "value", ")", ";", "if", "(", "preg_match", "(", "Measurement", "::", "PATTERN", ",", "$", "value", ")", ")", "return", "new", "Measurement", "(", "$", "value", ")", ";", "throw", "new", "\\", "Exception", "(", "\"Invalid Value '$value'\"", ")", ";", "}" ]
Parses a string into the correct value @param unknown $value @throws \Exception @return \csslib\values\Value
[ "Parses", "a", "string", "into", "the", "correct", "value" ]
6370b1404bae3eecb44c214ed4eaaf33113858dd
https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/values/Value.php#L21-L28
7,589
duellsy/pockpack
src/Duellsy/Pockpack/PockpackAuth.php
PockpackAuth.receiveToken
public function receiveToken($consumer_key, $request_token) { $pocketData = $this->convertRequestToken($consumer_key, $request_token); $access_token = $pocketData->access_token; return $access_token; }
php
public function receiveToken($consumer_key, $request_token) { $pocketData = $this->convertRequestToken($consumer_key, $request_token); $access_token = $pocketData->access_token; return $access_token; }
[ "public", "function", "receiveToken", "(", "$", "consumer_key", ",", "$", "request_token", ")", "{", "$", "pocketData", "=", "$", "this", "->", "convertRequestToken", "(", "$", "consumer_key", ",", "$", "request_token", ")", ";", "$", "access_token", "=", "$", "pocketData", "->", "access_token", ";", "return", "$", "access_token", ";", "}" ]
Grab an access token from the pocket API, after sending it the consumer key and request token from earlier @param string $consumer_key @param string $request_token
[ "Grab", "an", "access", "token", "from", "the", "pocket", "API", "after", "sending", "it", "the", "consumer", "key", "and", "request", "token", "from", "earlier" ]
b38b9942631ae786c6ed953da65f666ea9305f3c
https://github.com/duellsy/pockpack/blob/b38b9942631ae786c6ed953da65f666ea9305f3c/src/Duellsy/Pockpack/PockpackAuth.php#L52-L59
7,590
duellsy/pockpack
src/Duellsy/Pockpack/PockpackAuth.php
PockpackAuth.receiveTokenAndUsername
public function receiveTokenAndUsername($consumer_key, $request_token) { $pocketData = $this->convertRequestToken($consumer_key, $request_token); $returnData['access_token'] = $pocketData->access_token; $returnData['username'] = $pocketData->username; return $returnData; }
php
public function receiveTokenAndUsername($consumer_key, $request_token) { $pocketData = $this->convertRequestToken($consumer_key, $request_token); $returnData['access_token'] = $pocketData->access_token; $returnData['username'] = $pocketData->username; return $returnData; }
[ "public", "function", "receiveTokenAndUsername", "(", "$", "consumer_key", ",", "$", "request_token", ")", "{", "$", "pocketData", "=", "$", "this", "->", "convertRequestToken", "(", "$", "consumer_key", ",", "$", "request_token", ")", ";", "$", "returnData", "[", "'access_token'", "]", "=", "$", "pocketData", "->", "access_token", ";", "$", "returnData", "[", "'username'", "]", "=", "$", "pocketData", "->", "username", ";", "return", "$", "returnData", ";", "}" ]
Grab an access token and the username from the pocket API, after sending it the consumer key and request token from earlier @param string $consumer_key @param string $request_token
[ "Grab", "an", "access", "token", "and", "the", "username", "from", "the", "pocket", "API", "after", "sending", "it", "the", "consumer", "key", "and", "request", "token", "from", "earlier" ]
b38b9942631ae786c6ed953da65f666ea9305f3c
https://github.com/duellsy/pockpack/blob/b38b9942631ae786c6ed953da65f666ea9305f3c/src/Duellsy/Pockpack/PockpackAuth.php#L68-L76
7,591
duellsy/pockpack
src/Duellsy/Pockpack/PockpackAuth.php
PockpackAuth.convertRequestToken
private function convertRequestToken($consumer_key, $request_token) { $params = array( 'consumer_key' => $consumer_key, 'code' => $request_token ); $request = $this->getClient()->post('/v3/oauth/authorize'); $request->getParams()->set('redirect.strict', true); $request->setHeader('Content-Type', 'application/json; charset=UTF8'); $request->setHeader('X-Accept', 'application/json'); $request->setBody(json_encode($params)); $response = $request->send(); $data = json_decode($response->getBody()); return $data; }
php
private function convertRequestToken($consumer_key, $request_token) { $params = array( 'consumer_key' => $consumer_key, 'code' => $request_token ); $request = $this->getClient()->post('/v3/oauth/authorize'); $request->getParams()->set('redirect.strict', true); $request->setHeader('Content-Type', 'application/json; charset=UTF8'); $request->setHeader('X-Accept', 'application/json'); $request->setBody(json_encode($params)); $response = $request->send(); $data = json_decode($response->getBody()); return $data; }
[ "private", "function", "convertRequestToken", "(", "$", "consumer_key", ",", "$", "request_token", ")", "{", "$", "params", "=", "array", "(", "'consumer_key'", "=>", "$", "consumer_key", ",", "'code'", "=>", "$", "request_token", ")", ";", "$", "request", "=", "$", "this", "->", "getClient", "(", ")", "->", "post", "(", "'/v3/oauth/authorize'", ")", ";", "$", "request", "->", "getParams", "(", ")", "->", "set", "(", "'redirect.strict'", ",", "true", ")", ";", "$", "request", "->", "setHeader", "(", "'Content-Type'", ",", "'application/json; charset=UTF8'", ")", ";", "$", "request", "->", "setHeader", "(", "'X-Accept'", ",", "'application/json'", ")", ";", "$", "request", "->", "setBody", "(", "json_encode", "(", "$", "params", ")", ")", ";", "$", "response", "=", "$", "request", "->", "send", "(", ")", ";", "$", "data", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "return", "$", "data", ";", "}" ]
Convert a request token into a Pocket access token. We also get the username in the same response from Pocket. @param string $consumer_key @param string $request_token
[ "Convert", "a", "request", "token", "into", "a", "Pocket", "access", "token", ".", "We", "also", "get", "the", "username", "in", "the", "same", "response", "from", "Pocket", "." ]
b38b9942631ae786c6ed953da65f666ea9305f3c
https://github.com/duellsy/pockpack/blob/b38b9942631ae786c6ed953da65f666ea9305f3c/src/Duellsy/Pockpack/PockpackAuth.php#L85-L102
7,592
wmateam/curling
src/CurlResponse.php
CurlResponse.getJson
public function getJson($asArray = false) { if ($this->isJson()) return json_decode($this->getBody(), $asArray); return null; }
php
public function getJson($asArray = false) { if ($this->isJson()) return json_decode($this->getBody(), $asArray); return null; }
[ "public", "function", "getJson", "(", "$", "asArray", "=", "false", ")", "{", "if", "(", "$", "this", "->", "isJson", "(", ")", ")", "return", "json_decode", "(", "$", "this", "->", "getBody", "(", ")", ",", "$", "asArray", ")", ";", "return", "null", ";", "}" ]
return json Response @param bool $asArray return as Array? @return \stdClass|array
[ "return", "json", "Response" ]
93ff2888b8a45b14cf9837460b8290f1d5e17a7e
https://github.com/wmateam/curling/blob/93ff2888b8a45b14cf9837460b8290f1d5e17a7e/src/CurlResponse.php#L197-L202
7,593
odtimetracker/odtimetracker-php-lib
src/Model/ProjectEntity.php
ProjectEntity.setCreated
public function setCreated($val) { if (($val instanceof \DateTime)) { $this->created = $val; } else if (is_string($val) && !empty($val)) { try { // There can be accidentaly exeption thrown whenever the given // string is not valid date. $this->created = new \DateTime($val); } catch(\Exception $e) { $this->created = null; } } else { $this->created = null; } return $this; }
php
public function setCreated($val) { if (($val instanceof \DateTime)) { $this->created = $val; } else if (is_string($val) && !empty($val)) { try { // There can be accidentaly exeption thrown whenever the given // string is not valid date. $this->created = new \DateTime($val); } catch(\Exception $e) { $this->created = null; } } else { $this->created = null; } return $this; }
[ "public", "function", "setCreated", "(", "$", "val", ")", "{", "if", "(", "(", "$", "val", "instanceof", "\\", "DateTime", ")", ")", "{", "$", "this", "->", "created", "=", "$", "val", ";", "}", "else", "if", "(", "is_string", "(", "$", "val", ")", "&&", "!", "empty", "(", "$", "val", ")", ")", "{", "try", "{", "// There can be accidentaly exeption thrown whenever the given", "// string is not valid date.", "$", "this", "->", "created", "=", "new", "\\", "DateTime", "(", "$", "val", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "created", "=", "null", ";", "}", "}", "else", "{", "$", "this", "->", "created", "=", "null", ";", "}", "return", "$", "this", ";", "}" ]
Set date time when was the project created. @param DateTime|string $val Date time of creation. @return \odTimeTracker\Model\ProjectEntity
[ "Set", "date", "time", "when", "was", "the", "project", "created", "." ]
0bb9081fea8b921241a53c46785441696022590d
https://github.com/odtimetracker/odtimetracker-php-lib/blob/0bb9081fea8b921241a53c46785441696022590d/src/Model/ProjectEntity.php#L195-L214
7,594
TAMULib/Pipit
Core/Classes/CoreLogger.php
CoreLogger.setLogLevel
public function setLogLevel($logLevel) { if (is_int($logLevel) && $logLevel <= count($this->loggerTypes)) { $this->logLevel = $logLevel; $this->debug("Log level was set to: {$this->loggerTypes[$logLevel]->getName()}"); } else { $this->warn("Invalid Log Level was requested"); } }
php
public function setLogLevel($logLevel) { if (is_int($logLevel) && $logLevel <= count($this->loggerTypes)) { $this->logLevel = $logLevel; $this->debug("Log level was set to: {$this->loggerTypes[$logLevel]->getName()}"); } else { $this->warn("Invalid Log Level was requested"); } }
[ "public", "function", "setLogLevel", "(", "$", "logLevel", ")", "{", "if", "(", "is_int", "(", "$", "logLevel", ")", "&&", "$", "logLevel", "<=", "count", "(", "$", "this", "->", "loggerTypes", ")", ")", "{", "$", "this", "->", "logLevel", "=", "$", "logLevel", ";", "$", "this", "->", "debug", "(", "\"Log level was set to: {$this->loggerTypes[$logLevel]->getName()}\"", ")", ";", "}", "else", "{", "$", "this", "->", "warn", "(", "\"Invalid Log Level was requested\"", ")", ";", "}", "}" ]
Sets the threshold for which log entries should actually get written to the log @param int $logLevel Corresponds to an index of $loggerTypes
[ "Sets", "the", "threshold", "for", "which", "log", "entries", "should", "actually", "get", "written", "to", "the", "log" ]
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/CoreLogger.php#L95-L102
7,595
face-orm/face
lib/Face/Sql/Query/SelectBuilder.php
SelectBuilder.join
public function join($path, $select = null) { $path = $this->getNameInContext($path); $face = $this->getBaseFace() ->getElement($path) ->getFace(); $sqlPath = $this->_doFQLTableName($path, "."); $qJoin = new JoinQueryFace($sqlPath, $face); if(null !== $select){ $qJoin->setColumns($select); } $this->addJoin($qJoin); return $this; }
php
public function join($path, $select = null) { $path = $this->getNameInContext($path); $face = $this->getBaseFace() ->getElement($path) ->getFace(); $sqlPath = $this->_doFQLTableName($path, "."); $qJoin = new JoinQueryFace($sqlPath, $face); if(null !== $select){ $qJoin->setColumns($select); } $this->addJoin($qJoin); return $this; }
[ "public", "function", "join", "(", "$", "path", ",", "$", "select", "=", "null", ")", "{", "$", "path", "=", "$", "this", "->", "getNameInContext", "(", "$", "path", ")", ";", "$", "face", "=", "$", "this", "->", "getBaseFace", "(", ")", "->", "getElement", "(", "$", "path", ")", "->", "getFace", "(", ")", ";", "$", "sqlPath", "=", "$", "this", "->", "_doFQLTableName", "(", "$", "path", ",", "\".\"", ")", ";", "$", "qJoin", "=", "new", "JoinQueryFace", "(", "$", "sqlPath", ",", "$", "face", ")", ";", "if", "(", "null", "!==", "$", "select", ")", "{", "$", "qJoin", "->", "setColumns", "(", "$", "select", ")", ";", "}", "$", "this", "->", "addJoin", "(", "$", "qJoin", ")", ";", "return", "$", "this", ";", "}" ]
add a join clause to the query @param string $path the face path to the join @return SelectBuilder
[ "add", "a", "join", "clause", "to", "the", "query" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/SelectBuilder.php#L66-L85
7,596
face-orm/face
lib/Face/Sql/Query/SelectBuilder.php
SelectBuilder.where
public function where($whereString) { $where = new Where\WhereString($whereString); $where->context($this->getContext()); $this->addWhere($where); return $this; }
php
public function where($whereString) { $where = new Where\WhereString($whereString); $where->context($this->getContext()); $this->addWhere($where); return $this; }
[ "public", "function", "where", "(", "$", "whereString", ")", "{", "$", "where", "=", "new", "Where", "\\", "WhereString", "(", "$", "whereString", ")", ";", "$", "where", "->", "context", "(", "$", "this", "->", "getContext", "(", ")", ")", ";", "$", "this", "->", "addWhere", "(", "$", "where", ")", ";", "return", "$", "this", ";", "}" ]
set the where clause @param string $whereString the FQuery formated where clause @return \Face\Sql\Query\SelectBuilder it returns itSelf
[ "set", "the", "where", "clause" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/SelectBuilder.php#L122-L131
7,597
slickframework/mvc
src/Http/SessionAwareMethods.php
SessionAwareMethods.getSessionDriver
public function getSessionDriver() { if (null == $this->sessionDriver) { $this->setSessionDriver(Application::container()->get('session')); } return $this->sessionDriver; }
php
public function getSessionDriver() { if (null == $this->sessionDriver) { $this->setSessionDriver(Application::container()->get('session')); } return $this->sessionDriver; }
[ "public", "function", "getSessionDriver", "(", ")", "{", "if", "(", "null", "==", "$", "this", "->", "sessionDriver", ")", "{", "$", "this", "->", "setSessionDriver", "(", "Application", "::", "container", "(", ")", "->", "get", "(", "'session'", ")", ")", ";", "}", "return", "$", "this", "->", "sessionDriver", ";", "}" ]
Gets Session driver @return SessionDriverInterface
[ "Gets", "Session", "driver" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Http/SessionAwareMethods.php#L34-L40
7,598
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader.autoload
public static function autoload($class) { $self = self::getInstance(); foreach ($self->getClassAutoloaders($class) as $autoloader) { if ($autoloader instanceof Zend_Loader_Autoloader_Interface) { if ($autoloader->autoload($class)) { return true; } } elseif (is_array($autoloader)) { if (call_user_func($autoloader, $class)) { return true; } } elseif (is_string($autoloader) || is_callable($autoloader)) { if ($autoloader($class)) { return true; } } } return false; }
php
public static function autoload($class) { $self = self::getInstance(); foreach ($self->getClassAutoloaders($class) as $autoloader) { if ($autoloader instanceof Zend_Loader_Autoloader_Interface) { if ($autoloader->autoload($class)) { return true; } } elseif (is_array($autoloader)) { if (call_user_func($autoloader, $class)) { return true; } } elseif (is_string($autoloader) || is_callable($autoloader)) { if ($autoloader($class)) { return true; } } } return false; }
[ "public", "static", "function", "autoload", "(", "$", "class", ")", "{", "$", "self", "=", "self", "::", "getInstance", "(", ")", ";", "foreach", "(", "$", "self", "->", "getClassAutoloaders", "(", "$", "class", ")", "as", "$", "autoloader", ")", "{", "if", "(", "$", "autoloader", "instanceof", "Zend_Loader_Autoloader_Interface", ")", "{", "if", "(", "$", "autoloader", "->", "autoload", "(", "$", "class", ")", ")", "{", "return", "true", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "autoloader", ")", ")", "{", "if", "(", "call_user_func", "(", "$", "autoloader", ",", "$", "class", ")", ")", "{", "return", "true", ";", "}", "}", "elseif", "(", "is_string", "(", "$", "autoloader", ")", "||", "is_callable", "(", "$", "autoloader", ")", ")", "{", "if", "(", "$", "autoloader", "(", "$", "class", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Autoload a class @param string $class @return bool
[ "Autoload", "a", "class" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L114-L135
7,599
joegreen88/zf1-components-base
src/Zend/Loader/Autoloader.php
Zend_Loader_Autoloader.registerNamespace
public function registerNamespace($namespace) { if (is_string($namespace)) { $namespace = (array) $namespace; } elseif (!is_array($namespace)) { throw new Zend_Loader_Exception('Invalid namespace provided'); } foreach ($namespace as $ns) { if (!isset($this->_namespaces[$ns])) { $this->_namespaces[$ns] = true; } } return $this; }
php
public function registerNamespace($namespace) { if (is_string($namespace)) { $namespace = (array) $namespace; } elseif (!is_array($namespace)) { throw new Zend_Loader_Exception('Invalid namespace provided'); } foreach ($namespace as $ns) { if (!isset($this->_namespaces[$ns])) { $this->_namespaces[$ns] = true; } } return $this; }
[ "public", "function", "registerNamespace", "(", "$", "namespace", ")", "{", "if", "(", "is_string", "(", "$", "namespace", ")", ")", "{", "$", "namespace", "=", "(", "array", ")", "$", "namespace", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "namespace", ")", ")", "{", "throw", "new", "Zend_Loader_Exception", "(", "'Invalid namespace provided'", ")", ";", "}", "foreach", "(", "$", "namespace", "as", "$", "ns", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_namespaces", "[", "$", "ns", "]", ")", ")", "{", "$", "this", "->", "_namespaces", "[", "$", "ns", "]", "=", "true", ";", "}", "}", "return", "$", "this", ";", "}" ]
Register a namespace to autoload @param string|array $namespace @return Zend_Loader_Autoloader
[ "Register", "a", "namespace", "to", "autoload" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/Autoloader.php#L206-L220