id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
230,500
everplays/agavi-form-models-set
src/Elements/FieldsetModel.class.php
Form_Elements_FieldsetModel.html
public function html($client=null) { $this->setRendered(true); $id = self::idPrefix.$this->id; $return = '<div class="'.self::elementClass.'">'; $result = "<fieldset ". "id=\"{$id}_container\" ". ">"; if(isset($this->title)) { $result .= "<legend>{$this->title}</legend>"; } // children level 2 or deeper will be at the end of list so // when their parent get rendered they will be rendered too foreach($this->children as $child) { $child->setRendered(false); } foreach($this->children as $child) { if(!$child->isRendered()) { $result .= $child->html($client); } } $result .= '</fieldset>'; return $result; }
php
public function html($client=null) { $this->setRendered(true); $id = self::idPrefix.$this->id; $return = '<div class="'.self::elementClass.'">'; $result = "<fieldset ". "id=\"{$id}_container\" ". ">"; if(isset($this->title)) { $result .= "<legend>{$this->title}</legend>"; } // children level 2 or deeper will be at the end of list so // when their parent get rendered they will be rendered too foreach($this->children as $child) { $child->setRendered(false); } foreach($this->children as $child) { if(!$child->isRendered()) { $result .= $child->html($client); } } $result .= '</fieldset>'; return $result; }
[ "public", "function", "html", "(", "$", "client", "=", "null", ")", "{", "$", "this", "->", "setRendered", "(", "true", ")", ";", "$", "id", "=", "self", "::", "idPrefix", ".", "$", "this", "->", "id", ";", "$", "return", "=", "'<div class=\"'", ".", "self", "::", "elementClass", ".", "'\">'", ";", "$", "result", "=", "\"<fieldset \"", ".", "\"id=\\\"{$id}_container\\\" \"", ".", "\">\"", ";", "if", "(", "isset", "(", "$", "this", "->", "title", ")", ")", "{", "$", "result", ".=", "\"<legend>{$this->title}</legend>\"", ";", "}", "// children level 2 or deeper will be at the end of list so", "// when their parent get rendered they will be rendered too", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "$", "child", "->", "setRendered", "(", "false", ")", ";", "}", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "if", "(", "!", "$", "child", "->", "isRendered", "(", ")", ")", "{", "$", "result", ".=", "$", "child", "->", "html", "(", "$", "client", ")", ";", "}", "}", "$", "result", ".=", "'</fieldset>'", ";", "return", "$", "result", ";", "}" ]
generates html presentation of element @return string generated html for element @param string $client javascript client library - for validation purpose
[ "generates", "html", "presentation", "of", "element" ]
84b76f5facc6cea686ed2872eb6f4bd499f72d0e
https://github.com/everplays/agavi-form-models-set/blob/84b76f5facc6cea686ed2872eb6f4bd499f72d0e/src/Elements/FieldsetModel.class.php#L161-L188
230,501
everplays/agavi-form-models-set
src/Elements/FieldsetModel.class.php
Form_Elements_FieldsetModel.parseChildren
public static function parseChildren($config, Form_Elements_FieldsetModel $container) { $contextProfile = AgaviConfig::get('core.default_context'); if(is_null($contextProfile)) { $contextProfile = md5(microtime()); AgaviConfig::set('core.default_context', $contextProfile); } $context = AgaviContext::getInstance(); if(isset($config->items) and is_array($config->items)) { foreach($config->items as $item) { if(isset($item->xtype)) { switch($item->xtype) { case 'textfield': if(isset($item->inputType) and $item->inputType=='password') $model = array('Elements.PasswordField', 'Form'); else $model = array('Elements.TextField', 'Form'); break; case 'numberfield': $model = array('Elements.NumberField', 'Form'); break; case 'combo': $model = array('Elements.ResourceField', 'Form'); break; case 'datefield': $model = array('Elements.DateField', 'Form'); break; case 'radiogroup': $model = array('Elements.RadioGroup', 'Form'); break; case 'checkbox': $model = array('Elements.Checkbox', 'Form'); break; case 'fieldset': $model = Form_Elements_FieldsetModel::fromJson($item, $container); break; case 'textarea': $model = array('Elements.TextArea', 'Form'); break; default: $model = null; } if(is_array($model)) { $el = $context->getModel($model[0], $model[1], array($item, $container)); $container->addChild($el); } elseif(!is_null($model)) { $container->addChild($model); } } } } }
php
public static function parseChildren($config, Form_Elements_FieldsetModel $container) { $contextProfile = AgaviConfig::get('core.default_context'); if(is_null($contextProfile)) { $contextProfile = md5(microtime()); AgaviConfig::set('core.default_context', $contextProfile); } $context = AgaviContext::getInstance(); if(isset($config->items) and is_array($config->items)) { foreach($config->items as $item) { if(isset($item->xtype)) { switch($item->xtype) { case 'textfield': if(isset($item->inputType) and $item->inputType=='password') $model = array('Elements.PasswordField', 'Form'); else $model = array('Elements.TextField', 'Form'); break; case 'numberfield': $model = array('Elements.NumberField', 'Form'); break; case 'combo': $model = array('Elements.ResourceField', 'Form'); break; case 'datefield': $model = array('Elements.DateField', 'Form'); break; case 'radiogroup': $model = array('Elements.RadioGroup', 'Form'); break; case 'checkbox': $model = array('Elements.Checkbox', 'Form'); break; case 'fieldset': $model = Form_Elements_FieldsetModel::fromJson($item, $container); break; case 'textarea': $model = array('Elements.TextArea', 'Form'); break; default: $model = null; } if(is_array($model)) { $el = $context->getModel($model[0], $model[1], array($item, $container)); $container->addChild($el); } elseif(!is_null($model)) { $container->addChild($model); } } } } }
[ "public", "static", "function", "parseChildren", "(", "$", "config", ",", "Form_Elements_FieldsetModel", "$", "container", ")", "{", "$", "contextProfile", "=", "AgaviConfig", "::", "get", "(", "'core.default_context'", ")", ";", "if", "(", "is_null", "(", "$", "contextProfile", ")", ")", "{", "$", "contextProfile", "=", "md5", "(", "microtime", "(", ")", ")", ";", "AgaviConfig", "::", "set", "(", "'core.default_context'", ",", "$", "contextProfile", ")", ";", "}", "$", "context", "=", "AgaviContext", "::", "getInstance", "(", ")", ";", "if", "(", "isset", "(", "$", "config", "->", "items", ")", "and", "is_array", "(", "$", "config", "->", "items", ")", ")", "{", "foreach", "(", "$", "config", "->", "items", "as", "$", "item", ")", "{", "if", "(", "isset", "(", "$", "item", "->", "xtype", ")", ")", "{", "switch", "(", "$", "item", "->", "xtype", ")", "{", "case", "'textfield'", ":", "if", "(", "isset", "(", "$", "item", "->", "inputType", ")", "and", "$", "item", "->", "inputType", "==", "'password'", ")", "$", "model", "=", "array", "(", "'Elements.PasswordField'", ",", "'Form'", ")", ";", "else", "$", "model", "=", "array", "(", "'Elements.TextField'", ",", "'Form'", ")", ";", "break", ";", "case", "'numberfield'", ":", "$", "model", "=", "array", "(", "'Elements.NumberField'", ",", "'Form'", ")", ";", "break", ";", "case", "'combo'", ":", "$", "model", "=", "array", "(", "'Elements.ResourceField'", ",", "'Form'", ")", ";", "break", ";", "case", "'datefield'", ":", "$", "model", "=", "array", "(", "'Elements.DateField'", ",", "'Form'", ")", ";", "break", ";", "case", "'radiogroup'", ":", "$", "model", "=", "array", "(", "'Elements.RadioGroup'", ",", "'Form'", ")", ";", "break", ";", "case", "'checkbox'", ":", "$", "model", "=", "array", "(", "'Elements.Checkbox'", ",", "'Form'", ")", ";", "break", ";", "case", "'fieldset'", ":", "$", "model", "=", "Form_Elements_FieldsetModel", "::", "fromJson", "(", "$", "item", ",", "$", "container", ")", ";", "break", ";", "case", "'textarea'", ":", "$", "model", "=", "array", "(", "'Elements.TextArea'", ",", "'Form'", ")", ";", "break", ";", "default", ":", "$", "model", "=", "null", ";", "}", "if", "(", "is_array", "(", "$", "model", ")", ")", "{", "$", "el", "=", "$", "context", "->", "getModel", "(", "$", "model", "[", "0", "]", ",", "$", "model", "[", "1", "]", ",", "array", "(", "$", "item", ",", "$", "container", ")", ")", ";", "$", "container", "->", "addChild", "(", "$", "el", ")", ";", "}", "elseif", "(", "!", "is_null", "(", "$", "model", ")", ")", "{", "$", "container", "->", "addChild", "(", "$", "model", ")", ";", "}", "}", "}", "}", "}" ]
parses children & adds them into given fieldset @param object $config @param Form_Elements_FieldsetModel $container fieldset
[ "parses", "children", "&", "adds", "them", "into", "given", "fieldset" ]
84b76f5facc6cea686ed2872eb6f4bd499f72d0e
https://github.com/everplays/agavi-form-models-set/blob/84b76f5facc6cea686ed2872eb6f4bd499f72d0e/src/Elements/FieldsetModel.class.php#L196-L255
230,502
everplays/agavi-form-models-set
src/Elements/FieldsetModel.class.php
Form_Elements_FieldsetModel.fromJson
public static function fromJson($config, Form_Elements_FieldsetModel $form=null) { $contextProfile = AgaviConfig::get('core.default_context'); if(is_null($contextProfile)) { $contextProfile = md5(microtime()); AgaviConfig::set('core.default_context', $contextProfile); } $context = AgaviContext::getInstance(); $fieldset = $context->getModel('Elements.Fieldset', 'Form', array($config, $form)); $children = array(); $columns = count($config->items); $rows = count($config->items[0]->items); for($i=0; $i<$rows; $i++) { for($j=0; $j<$columns; $j++) { if(isset($config->items[$j]->items[$i])) { $children[] = $config->items[$j]->items[$i]; } } } $tmp = new stdClass(); $tmp->items = $children; self::parseChildren($tmp, $fieldset); $form->addChild($fieldset); if(!is_null($form)) foreach($fieldset->children as $child) { $form->addChild($child); } return $fieldset; }
php
public static function fromJson($config, Form_Elements_FieldsetModel $form=null) { $contextProfile = AgaviConfig::get('core.default_context'); if(is_null($contextProfile)) { $contextProfile = md5(microtime()); AgaviConfig::set('core.default_context', $contextProfile); } $context = AgaviContext::getInstance(); $fieldset = $context->getModel('Elements.Fieldset', 'Form', array($config, $form)); $children = array(); $columns = count($config->items); $rows = count($config->items[0]->items); for($i=0; $i<$rows; $i++) { for($j=0; $j<$columns; $j++) { if(isset($config->items[$j]->items[$i])) { $children[] = $config->items[$j]->items[$i]; } } } $tmp = new stdClass(); $tmp->items = $children; self::parseChildren($tmp, $fieldset); $form->addChild($fieldset); if(!is_null($form)) foreach($fieldset->children as $child) { $form->addChild($child); } return $fieldset; }
[ "public", "static", "function", "fromJson", "(", "$", "config", ",", "Form_Elements_FieldsetModel", "$", "form", "=", "null", ")", "{", "$", "contextProfile", "=", "AgaviConfig", "::", "get", "(", "'core.default_context'", ")", ";", "if", "(", "is_null", "(", "$", "contextProfile", ")", ")", "{", "$", "contextProfile", "=", "md5", "(", "microtime", "(", ")", ")", ";", "AgaviConfig", "::", "set", "(", "'core.default_context'", ",", "$", "contextProfile", ")", ";", "}", "$", "context", "=", "AgaviContext", "::", "getInstance", "(", ")", ";", "$", "fieldset", "=", "$", "context", "->", "getModel", "(", "'Elements.Fieldset'", ",", "'Form'", ",", "array", "(", "$", "config", ",", "$", "form", ")", ")", ";", "$", "children", "=", "array", "(", ")", ";", "$", "columns", "=", "count", "(", "$", "config", "->", "items", ")", ";", "$", "rows", "=", "count", "(", "$", "config", "->", "items", "[", "0", "]", "->", "items", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "rows", ";", "$", "i", "++", ")", "{", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "$", "columns", ";", "$", "j", "++", ")", "{", "if", "(", "isset", "(", "$", "config", "->", "items", "[", "$", "j", "]", "->", "items", "[", "$", "i", "]", ")", ")", "{", "$", "children", "[", "]", "=", "$", "config", "->", "items", "[", "$", "j", "]", "->", "items", "[", "$", "i", "]", ";", "}", "}", "}", "$", "tmp", "=", "new", "stdClass", "(", ")", ";", "$", "tmp", "->", "items", "=", "$", "children", ";", "self", "::", "parseChildren", "(", "$", "tmp", ",", "$", "fieldset", ")", ";", "$", "form", "->", "addChild", "(", "$", "fieldset", ")", ";", "if", "(", "!", "is_null", "(", "$", "form", ")", ")", "foreach", "(", "$", "fieldset", "->", "children", "as", "$", "child", ")", "{", "$", "form", "->", "addChild", "(", "$", "child", ")", ";", "}", "return", "$", "fieldset", ";", "}" ]
parses config object from extjs @param object $config lazy configuration of extjs @param Form_FormModel $form @return Form_Elements_FieldsetModel
[ "parses", "config", "object", "from", "extjs" ]
84b76f5facc6cea686ed2872eb6f4bd499f72d0e
https://github.com/everplays/agavi-form-models-set/blob/84b76f5facc6cea686ed2872eb6f4bd499f72d0e/src/Elements/FieldsetModel.class.php#L264-L297
230,503
everplays/agavi-form-models-set
src/Elements/DateFieldModel.class.php
Form_Elements_DateFieldModel.setValue
public function setValue($value) { if(is_numeric($value)) $value = (int) $value; if(is_string($value)) $value = strtotime($value); $value = date('Y/m/d', $value); $value = parent::setValue($value); return $value; }
php
public function setValue($value) { if(is_numeric($value)) $value = (int) $value; if(is_string($value)) $value = strtotime($value); $value = date('Y/m/d', $value); $value = parent::setValue($value); return $value; }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "$", "value", "=", "(", "int", ")", "$", "value", ";", "if", "(", "is_string", "(", "$", "value", ")", ")", "$", "value", "=", "strtotime", "(", "$", "value", ")", ";", "$", "value", "=", "date", "(", "'Y/m/d'", ",", "$", "value", ")", ";", "$", "value", "=", "parent", "::", "setValue", "(", "$", "value", ")", ";", "return", "$", "value", ";", "}" ]
prepare date before checking validation @param mixed $value @return int
[ "prepare", "date", "before", "checking", "validation" ]
84b76f5facc6cea686ed2872eb6f4bd499f72d0e
https://github.com/everplays/agavi-form-models-set/blob/84b76f5facc6cea686ed2872eb6f4bd499f72d0e/src/Elements/DateFieldModel.class.php#L169-L178
230,504
everplays/agavi-form-models-set
src/ElementModel.class.php
Form_ElementModel.setConfiguration
public function setConfiguration($configuration) { if(is_array($configuration) or is_object($configuration)) foreach($configuration as $name => $value) { $this->{$name} = $value; } }
php
public function setConfiguration($configuration) { if(is_array($configuration) or is_object($configuration)) foreach($configuration as $name => $value) { $this->{$name} = $value; } }
[ "public", "function", "setConfiguration", "(", "$", "configuration", ")", "{", "if", "(", "is_array", "(", "$", "configuration", ")", "or", "is_object", "(", "$", "configuration", ")", ")", "foreach", "(", "$", "configuration", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "{", "$", "name", "}", "=", "$", "value", ";", "}", "}" ]
sets configutation by given array @param mixed $configuration
[ "sets", "configutation", "by", "given", "array" ]
84b76f5facc6cea686ed2872eb6f4bd499f72d0e
https://github.com/everplays/agavi-form-models-set/blob/84b76f5facc6cea686ed2872eb6f4bd499f72d0e/src/ElementModel.class.php#L69-L76
230,505
everplays/agavi-form-models-set
src/ElementModel.class.php
Form_ElementModel.addChild
public function addChild(Form_ElementModel $child) { if(!$this->allowChildren) { throw new Exception(__CLASS__." doesn't support children"); } $this->children[] = $child; }
php
public function addChild(Form_ElementModel $child) { if(!$this->allowChildren) { throw new Exception(__CLASS__." doesn't support children"); } $this->children[] = $child; }
[ "public", "function", "addChild", "(", "Form_ElementModel", "$", "child", ")", "{", "if", "(", "!", "$", "this", "->", "allowChildren", ")", "{", "throw", "new", "Exception", "(", "__CLASS__", ".", "\" doesn't support children\"", ")", ";", "}", "$", "this", "->", "children", "[", "]", "=", "$", "child", ";", "}" ]
adds a new child to element @param Form_ElementModel $child new child to get added
[ "adds", "a", "new", "child", "to", "element" ]
84b76f5facc6cea686ed2872eb6f4bd499f72d0e
https://github.com/everplays/agavi-form-models-set/blob/84b76f5facc6cea686ed2872eb6f4bd499f72d0e/src/ElementModel.class.php#L143-L150
230,506
everplays/agavi-form-models-set
src/ElementModel.class.php
Form_ElementModel.setValue
public function setValue($value) { // any preparation goes here, for example casting to int $errors = $this->getValidationErrors($value); // if specific validation existed would go here & if // anything goes wrong will put error message into errors if(!empty($errors)) throw $this->getContext()->getModel('ValidationException', 'Form', array(($errors))); return $value; }
php
public function setValue($value) { // any preparation goes here, for example casting to int $errors = $this->getValidationErrors($value); // if specific validation existed would go here & if // anything goes wrong will put error message into errors if(!empty($errors)) throw $this->getContext()->getModel('ValidationException', 'Form', array(($errors))); return $value; }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "// any preparation goes here, for example casting to int", "$", "errors", "=", "$", "this", "->", "getValidationErrors", "(", "$", "value", ")", ";", "// if specific validation existed would go here & if", "// anything goes wrong will put error message into errors", "if", "(", "!", "empty", "(", "$", "errors", ")", ")", "throw", "$", "this", "->", "getContext", "(", ")", "->", "getModel", "(", "'ValidationException'", ",", "'Form'", ",", "array", "(", "(", "$", "errors", ")", ")", ")", ";", "return", "$", "value", ";", "}" ]
prepares given value before regular validation check, also a good place for having element specifc validation check @param mixed $value @return mixed
[ "prepares", "given", "value", "before", "regular", "validation", "check", "also", "a", "good", "place", "for", "having", "element", "specifc", "validation", "check" ]
84b76f5facc6cea686ed2872eb6f4bd499f72d0e
https://github.com/everplays/agavi-form-models-set/blob/84b76f5facc6cea686ed2872eb6f4bd499f72d0e/src/ElementModel.class.php#L196-L205
230,507
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_templatecompilerbase.php
Smarty_Internal_TemplateCompilerBase.postFilter
public function postFilter($code) { // run post filter if on code if (!empty($code) && (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ])) ) { return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template); } else { return $code; } }
php
public function postFilter($code) { // run post filter if on code if (!empty($code) && (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ])) ) { return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template); } else { return $code; } }
[ "public", "function", "postFilter", "(", "$", "code", ")", "{", "// run post filter if on code", "if", "(", "!", "empty", "(", "$", "code", ")", "&&", "(", "isset", "(", "$", "this", "->", "smarty", "->", "autoload_filters", "[", "'post'", "]", ")", "||", "isset", "(", "$", "this", "->", "smarty", "->", "registered_filters", "[", "'post'", "]", ")", ")", ")", "{", "return", "$", "this", "->", "smarty", "->", "ext", "->", "_filterHandler", "->", "runFilter", "(", "'post'", ",", "$", "code", ",", "$", "this", "->", "template", ")", ";", "}", "else", "{", "return", "$", "code", ";", "}", "}" ]
Optionally process compiled code by post filter @param string $code compiled code @return string @throws \SmartyException
[ "Optionally", "process", "compiled", "code", "by", "post", "filter" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_templatecompilerbase.php#L423-L433
230,508
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_templatecompilerbase.php
Smarty_Internal_TemplateCompilerBase.preFilter
public function preFilter($_content) { // run pre filter if required if ($_content != '' && ((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ]))) ) { return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template); } else { return $_content; } }
php
public function preFilter($_content) { // run pre filter if required if ($_content != '' && ((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ]))) ) { return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template); } else { return $_content; } }
[ "public", "function", "preFilter", "(", "$", "_content", ")", "{", "// run pre filter if required", "if", "(", "$", "_content", "!=", "''", "&&", "(", "(", "isset", "(", "$", "this", "->", "smarty", "->", "autoload_filters", "[", "'pre'", "]", ")", "||", "isset", "(", "$", "this", "->", "smarty", "->", "registered_filters", "[", "'pre'", "]", ")", ")", ")", ")", "{", "return", "$", "this", "->", "smarty", "->", "ext", "->", "_filterHandler", "->", "runFilter", "(", "'pre'", ",", "$", "_content", ",", "$", "this", "->", "template", ")", ";", "}", "else", "{", "return", "$", "_content", ";", "}", "}" ]
Run optional prefilter @param string $_content template source @return string @throws \SmartyException
[ "Run", "optional", "prefilter" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_templatecompilerbase.php#L443-L453
230,509
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_templatecompilerbase.php
Smarty_Internal_TemplateCompilerBase.processText
public function processText($text) { if ((string) $text != '') { $store = array(); $_store = 0; $_offset = 0; if ($this->parser->strip) { if (strpos($text, '<') !== false) { // capture html elements not to be messed with $_offset = 0; if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { foreach ($matches as $match) { $store[] = $match[ 0 ][ 0 ]; $_length = strlen($match[ 0 ][ 0 ]); $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); $_offset += $_length - strlen($replace); $_store ++; } } $expressions = array(// replace multiple spaces between tags by a single space // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', // remove spaces between attributes (but not in attribute values!) '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', '#^\s+<#Ss' => '<', '#>\s+$#Ss' => '>', $this->stripRegEx => ''); $text = preg_replace(array_keys($expressions), array_values($expressions), $text); $_offset = 0; if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { foreach ($matches as $match) { $_length = strlen($match[ 0 ][ 0 ]); $replace = $store[ $match[ 1 ][ 0 ] ]; $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); $_offset += strlen($replace) - $_length; $_store ++; } } } else { $text = preg_replace($this->stripRegEx, '', $text); } } return new Smarty_Internal_ParseTree_Text($text); } return null; }
php
public function processText($text) { if ((string) $text != '') { $store = array(); $_store = 0; $_offset = 0; if ($this->parser->strip) { if (strpos($text, '<') !== false) { // capture html elements not to be messed with $_offset = 0; if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { foreach ($matches as $match) { $store[] = $match[ 0 ][ 0 ]; $_length = strlen($match[ 0 ][ 0 ]); $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); $_offset += $_length - strlen($replace); $_store ++; } } $expressions = array(// replace multiple spaces between tags by a single space // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', // remove spaces between attributes (but not in attribute values!) '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', '#^\s+<#Ss' => '<', '#>\s+$#Ss' => '>', $this->stripRegEx => ''); $text = preg_replace(array_keys($expressions), array_values($expressions), $text); $_offset = 0; if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { foreach ($matches as $match) { $_length = strlen($match[ 0 ][ 0 ]); $replace = $store[ $match[ 1 ][ 0 ] ]; $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); $_offset += strlen($replace) - $_length; $_store ++; } } } else { $text = preg_replace($this->stripRegEx, '', $text); } } return new Smarty_Internal_ParseTree_Text($text); } return null; }
[ "public", "function", "processText", "(", "$", "text", ")", "{", "if", "(", "(", "string", ")", "$", "text", "!=", "''", ")", "{", "$", "store", "=", "array", "(", ")", ";", "$", "_store", "=", "0", ";", "$", "_offset", "=", "0", ";", "if", "(", "$", "this", "->", "parser", "->", "strip", ")", "{", "if", "(", "strpos", "(", "$", "text", ",", "'<'", ")", "!==", "false", ")", "{", "// capture html elements not to be messed with", "$", "_offset", "=", "0", ";", "if", "(", "preg_match_all", "(", "'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is'", ",", "$", "text", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", "|", "PREG_SET_ORDER", ")", ")", "{", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "$", "store", "[", "]", "=", "$", "match", "[", "0", "]", "[", "0", "]", ";", "$", "_length", "=", "strlen", "(", "$", "match", "[", "0", "]", "[", "0", "]", ")", ";", "$", "replace", "=", "'@!@SMARTY:'", ".", "$", "_store", ".", "':SMARTY@!@'", ";", "$", "text", "=", "substr_replace", "(", "$", "text", ",", "$", "replace", ",", "$", "match", "[", "0", "]", "[", "1", "]", "-", "$", "_offset", ",", "$", "_length", ")", ";", "$", "_offset", "+=", "$", "_length", "-", "strlen", "(", "$", "replace", ")", ";", "$", "_store", "++", ";", "}", "}", "$", "expressions", "=", "array", "(", "// replace multiple spaces between tags by a single space", "// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements", "'#(:SMARTY@!@|>)\\s+(?=@!@SMARTY:|<)#s'", "=>", "'\\1 \\2'", ",", "// remove spaces between attributes (but not in attribute values!)", "'#(([a-z0-9]\\s*=\\s*(\"[^\"]*?\")|(\\'[^\\']*?\\'))|<[a-z0-9_]+)\\s+([a-z/>])#is'", "=>", "'\\1 \\5'", ",", "'#^\\s+<#Ss'", "=>", "'<'", ",", "'#>\\s+$#Ss'", "=>", "'>'", ",", "$", "this", "->", "stripRegEx", "=>", "''", ")", ";", "$", "text", "=", "preg_replace", "(", "array_keys", "(", "$", "expressions", ")", ",", "array_values", "(", "$", "expressions", ")", ",", "$", "text", ")", ";", "$", "_offset", "=", "0", ";", "if", "(", "preg_match_all", "(", "'#@!@SMARTY:([0-9]+):SMARTY@!@#is'", ",", "$", "text", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", "|", "PREG_SET_ORDER", ")", ")", "{", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "$", "_length", "=", "strlen", "(", "$", "match", "[", "0", "]", "[", "0", "]", ")", ";", "$", "replace", "=", "$", "store", "[", "$", "match", "[", "1", "]", "[", "0", "]", "]", ";", "$", "text", "=", "substr_replace", "(", "$", "text", ",", "$", "replace", ",", "$", "match", "[", "0", "]", "[", "1", "]", "+", "$", "_offset", ",", "$", "_length", ")", ";", "$", "_offset", "+=", "strlen", "(", "$", "replace", ")", "-", "$", "_length", ";", "$", "_store", "++", ";", "}", "}", "}", "else", "{", "$", "text", "=", "preg_replace", "(", "$", "this", "->", "stripRegEx", ",", "''", ",", "$", "text", ")", ";", "}", "}", "return", "new", "Smarty_Internal_ParseTree_Text", "(", "$", "text", ")", ";", "}", "return", "null", ";", "}" ]
This method is called from parser to process a text content section - remove text from inheritance child templates as they may generate output - strip text if strip is enabled @param string $text @return null|\Smarty_Internal_ParseTree_Text
[ "This", "method", "is", "called", "from", "parser", "to", "process", "a", "text", "content", "section", "-", "remove", "text", "from", "inheritance", "child", "templates", "as", "they", "may", "generate", "output", "-", "strip", "text", "if", "strip", "is", "enabled" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_templatecompilerbase.php#L785-L837
230,510
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_parsetree_tag.php
Smarty_Internal_ParseTree_Tag.assign_to_var
public function assign_to_var(Smarty_Internal_Templateparser $parser) { $var = sprintf('$_tmp%d', ++ Smarty_Internal_Templateparser::$prefix_number); $tmp = $parser->compiler->appendCode('<?php ob_start();?>', $this->data); $tmp = $parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>"); $parser->compiler->prefix_code[] = sprintf("%s", $tmp); return $var; }
php
public function assign_to_var(Smarty_Internal_Templateparser $parser) { $var = sprintf('$_tmp%d', ++ Smarty_Internal_Templateparser::$prefix_number); $tmp = $parser->compiler->appendCode('<?php ob_start();?>', $this->data); $tmp = $parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>"); $parser->compiler->prefix_code[] = sprintf("%s", $tmp); return $var; }
[ "public", "function", "assign_to_var", "(", "Smarty_Internal_Templateparser", "$", "parser", ")", "{", "$", "var", "=", "sprintf", "(", "'$_tmp%d'", ",", "++", "Smarty_Internal_Templateparser", "::", "$", "prefix_number", ")", ";", "$", "tmp", "=", "$", "parser", "->", "compiler", "->", "appendCode", "(", "'<?php ob_start();?>'", ",", "$", "this", "->", "data", ")", ";", "$", "tmp", "=", "$", "parser", "->", "compiler", "->", "appendCode", "(", "$", "tmp", ",", "\"<?php {$var}=ob_get_clean();?>\"", ")", ";", "$", "parser", "->", "compiler", "->", "prefix_code", "[", "]", "=", "sprintf", "(", "\"%s\"", ",", "$", "tmp", ")", ";", "return", "$", "var", ";", "}" ]
Return complied code that loads the evaluated output of buffer content into a temporary variable @param \Smarty_Internal_Templateparser $parser @return string template code
[ "Return", "complied", "code", "that", "loads", "the", "evaluated", "output", "of", "buffer", "content", "into", "a", "temporary", "variable" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_parsetree_tag.php#L60-L68
230,511
inetprocess/libsugarcrm
src/System.php
System.rebuildExtensions
public function rebuildExtensions(array $modules = array(), $user_id = '1') { $this->setUpQuickRepair($user_id); $repair = new \RepairAndClear(); $repair->repairAndClearAll( array('rebuildExtensions'), $modules ); return $this->getMessages(); }
php
public function rebuildExtensions(array $modules = array(), $user_id = '1') { $this->setUpQuickRepair($user_id); $repair = new \RepairAndClear(); $repair->repairAndClearAll( array('rebuildExtensions'), $modules ); return $this->getMessages(); }
[ "public", "function", "rebuildExtensions", "(", "array", "$", "modules", "=", "array", "(", ")", ",", "$", "user_id", "=", "'1'", ")", "{", "$", "this", "->", "setUpQuickRepair", "(", "$", "user_id", ")", ";", "$", "repair", "=", "new", "\\", "RepairAndClear", "(", ")", ";", "$", "repair", "->", "repairAndClearAll", "(", "array", "(", "'rebuildExtensions'", ")", ",", "$", "modules", ")", ";", "return", "$", "this", "->", "getMessages", "(", ")", ";", "}" ]
Rebuild only Extensions. @param array $modules Rebuild only the specified modules @param string $user_id User id of the admin user @return array Messages
[ "Rebuild", "only", "Extensions", "." ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/System.php#L109-L118
230,512
inetprocess/libsugarcrm
src/System.php
System.setUpQuickRepair
private function setUpQuickRepair($user_id = '1') { // Config ang language $sugarConfig = $this->getEntryPoint()->getApplication()->getSugarConfig(); // Force setting the admin user. $this->getEntryPoint()->setCurrentUser($user_id); $currentLanguage = $sugarConfig['default_language']; require_once('modules/Administration/QuickRepairAndRebuild.php'); require_once('include/utils/layout_utils.php'); $GLOBALS['mod_strings'] = return_module_language($currentLanguage, 'Administration'); ob_start(array($this, 'parseOutput')); $this->isFlushed = false; }
php
private function setUpQuickRepair($user_id = '1') { // Config ang language $sugarConfig = $this->getEntryPoint()->getApplication()->getSugarConfig(); // Force setting the admin user. $this->getEntryPoint()->setCurrentUser($user_id); $currentLanguage = $sugarConfig['default_language']; require_once('modules/Administration/QuickRepairAndRebuild.php'); require_once('include/utils/layout_utils.php'); $GLOBALS['mod_strings'] = return_module_language($currentLanguage, 'Administration'); ob_start(array($this, 'parseOutput')); $this->isFlushed = false; }
[ "private", "function", "setUpQuickRepair", "(", "$", "user_id", "=", "'1'", ")", "{", "// Config ang language", "$", "sugarConfig", "=", "$", "this", "->", "getEntryPoint", "(", ")", "->", "getApplication", "(", ")", "->", "getSugarConfig", "(", ")", ";", "// Force setting the admin user.", "$", "this", "->", "getEntryPoint", "(", ")", "->", "setCurrentUser", "(", "$", "user_id", ")", ";", "$", "currentLanguage", "=", "$", "sugarConfig", "[", "'default_language'", "]", ";", "require_once", "(", "'modules/Administration/QuickRepairAndRebuild.php'", ")", ";", "require_once", "(", "'include/utils/layout_utils.php'", ")", ";", "$", "GLOBALS", "[", "'mod_strings'", "]", "=", "return_module_language", "(", "$", "currentLanguage", ",", "'Administration'", ")", ";", "ob_start", "(", "array", "(", "$", "this", ",", "'parseOutput'", ")", ")", ";", "$", "this", "->", "isFlushed", "=", "false", ";", "}" ]
Prepare all the necessary thing to run a repair and rebuild ob is also started to catch any output
[ "Prepare", "all", "the", "necessary", "thing", "to", "run", "a", "repair", "and", "rebuild", "ob", "is", "also", "started", "to", "catch", "any", "output" ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/System.php#L135-L147
230,513
inetprocess/libsugarcrm
src/System.php
System.parseOutput
public function parseOutput($message) { $message = preg_replace('#<script.*</script>#i', '', $message); $message = preg_replace('#<(br\s*/?|/h3)>#i', PHP_EOL, $message); $message = trim(strip_tags($message)); $message = preg_replace('#'.PHP_EOL.'{2,}#', PHP_EOL, $message); $this->addMessage(trim($message)); return ''; }
php
public function parseOutput($message) { $message = preg_replace('#<script.*</script>#i', '', $message); $message = preg_replace('#<(br\s*/?|/h3)>#i', PHP_EOL, $message); $message = trim(strip_tags($message)); $message = preg_replace('#'.PHP_EOL.'{2,}#', PHP_EOL, $message); $this->addMessage(trim($message)); return ''; }
[ "public", "function", "parseOutput", "(", "$", "message", ")", "{", "$", "message", "=", "preg_replace", "(", "'#<script.*</script>#i'", ",", "''", ",", "$", "message", ")", ";", "$", "message", "=", "preg_replace", "(", "'#<(br\\s*/?|/h3)>#i'", ",", "PHP_EOL", ",", "$", "message", ")", ";", "$", "message", "=", "trim", "(", "strip_tags", "(", "$", "message", ")", ")", ";", "$", "message", "=", "preg_replace", "(", "'#'", ".", "PHP_EOL", ".", "'{2,}#'", ",", "PHP_EOL", ",", "$", "message", ")", ";", "$", "this", "->", "addMessage", "(", "trim", "(", "$", "message", ")", ")", ";", "return", "''", ";", "}" ]
Parse ouput of ob to remove html and store messages.
[ "Parse", "ouput", "of", "ob", "to", "remove", "html", "and", "store", "messages", "." ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/System.php#L153-L161
230,514
cygnite/framework
src/Cygnite/Alias/Manager.php
Manager.getInstance
public static function getInstance(array $aliases = []) : Manager { if (is_null(static::$instance)) { return static::$instance = new static($aliases); } static::$instance->alias($aliases); return static::$instance; }
php
public static function getInstance(array $aliases = []) : Manager { if (is_null(static::$instance)) { return static::$instance = new static($aliases); } static::$instance->alias($aliases); return static::$instance; }
[ "public", "static", "function", "getInstance", "(", "array", "$", "aliases", "=", "[", "]", ")", ":", "Manager", "{", "if", "(", "is_null", "(", "static", "::", "$", "instance", ")", ")", "{", "return", "static", "::", "$", "instance", "=", "new", "static", "(", "$", "aliases", ")", ";", "}", "static", "::", "$", "instance", "->", "alias", "(", "$", "aliases", ")", ";", "return", "static", "::", "$", "instance", ";", "}" ]
Get or create the singleton alias manager instance. @param array $aliases @return Manager
[ "Get", "or", "create", "the", "singleton", "alias", "manager", "instance", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Alias/Manager.php#L50-L59
230,515
cygnite/framework
src/Cygnite/Alias/Manager.php
Manager.alias
public function alias(array $class = [], string $alias = null) : Manager { if (!is_array($class)) { $this->set($class, $alias); return $this; } $this->aliases = array_merge($this->get(), $class); return $this; }
php
public function alias(array $class = [], string $alias = null) : Manager { if (!is_array($class)) { $this->set($class, $alias); return $this; } $this->aliases = array_merge($this->get(), $class); return $this; }
[ "public", "function", "alias", "(", "array", "$", "class", "=", "[", "]", ",", "string", "$", "alias", "=", "null", ")", ":", "Manager", "{", "if", "(", "!", "is_array", "(", "$", "class", ")", ")", "{", "$", "this", "->", "set", "(", "$", "class", ",", "$", "alias", ")", ";", "return", "$", "this", ";", "}", "$", "this", "->", "aliases", "=", "array_merge", "(", "$", "this", "->", "get", "(", ")", ",", "$", "class", ")", ";", "return", "$", "this", ";", "}" ]
Set number of alias of class as array. @param array $class @param string $alias @return Manager
[ "Set", "number", "of", "alias", "of", "class", "as", "array", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Alias/Manager.php#L68-L79
230,516
cygnite/framework
src/Cygnite/Alias/Manager.php
Manager.namespace
public function namespace(string $namespace, string $alias = null) : Manager { $this->namespaces[] = [trim($namespace, '\\'), trim($alias, '\\')]; return $this; }
php
public function namespace(string $namespace, string $alias = null) : Manager { $this->namespaces[] = [trim($namespace, '\\'), trim($alias, '\\')]; return $this; }
[ "public", "function", "namespace", "(", "string", "$", "namespace", ",", "string", "$", "alias", "=", "null", ")", ":", "Manager", "{", "$", "this", "->", "namespaces", "[", "]", "=", "[", "trim", "(", "$", "namespace", ",", "'\\\\'", ")", ",", "trim", "(", "$", "alias", ",", "'\\\\'", ")", "]", ";", "return", "$", "this", ";", "}" ]
Register a namespace alias. @param $namespace @param $alias @return Manager
[ "Register", "a", "namespace", "alias", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Alias/Manager.php#L88-L93
230,517
cygnite/framework
src/Cygnite/Alias/Manager.php
Manager.get
public function get(string $alias = null) { if (is_null($alias)) { return $this->aliases; } return $this->has($alias) ? $this->aliases[$alias] : false; }
php
public function get(string $alias = null) { if (is_null($alias)) { return $this->aliases; } return $this->has($alias) ? $this->aliases[$alias] : false; }
[ "public", "function", "get", "(", "string", "$", "alias", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "alias", ")", ")", "{", "return", "$", "this", "->", "aliases", ";", "}", "return", "$", "this", "->", "has", "(", "$", "alias", ")", "?", "$", "this", "->", "aliases", "[", "$", "alias", "]", ":", "false", ";", "}" ]
Returns the value stored in stack. @param string|null $alias @return array|bool|mixed
[ "Returns", "the", "value", "stored", "in", "stack", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Alias/Manager.php#L115-L122
230,518
cygnite/framework
src/Cygnite/Alias/Manager.php
Manager.resolveNamespaceAlias
public function resolveNamespaceAlias(string $alias) { foreach ($this->namespaces as $namespace) { list($className, $aliasTo) = $namespace; if (false == strpos($alias, $aliasTo)) { if (!empty($aliasTo)) { $alias = substr($alias, strlen($aliasTo) + 1); } return $this->getClassForNamespaceAlias($className.'\\'.$alias); } } return false; }
php
public function resolveNamespaceAlias(string $alias) { foreach ($this->namespaces as $namespace) { list($className, $aliasTo) = $namespace; if (false == strpos($alias, $aliasTo)) { if (!empty($aliasTo)) { $alias = substr($alias, strlen($aliasTo) + 1); } return $this->getClassForNamespaceAlias($className.'\\'.$alias); } } return false; }
[ "public", "function", "resolveNamespaceAlias", "(", "string", "$", "alias", ")", "{", "foreach", "(", "$", "this", "->", "namespaces", "as", "$", "namespace", ")", "{", "list", "(", "$", "className", ",", "$", "aliasTo", ")", "=", "$", "namespace", ";", "if", "(", "false", "==", "strpos", "(", "$", "alias", ",", "$", "aliasTo", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "aliasTo", ")", ")", "{", "$", "alias", "=", "substr", "(", "$", "alias", ",", "strlen", "(", "$", "aliasTo", ")", "+", "1", ")", ";", "}", "return", "$", "this", "->", "getClassForNamespaceAlias", "(", "$", "className", ".", "'\\\\'", ".", "$", "alias", ")", ";", "}", "}", "return", "false", ";", "}" ]
Resolve namespace alias and return class name. @param string $alias @return bool|string
[ "Resolve", "namespace", "alias", "and", "return", "class", "name", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Alias/Manager.php#L154-L169
230,519
cygnite/framework
src/Cygnite/Alias/Manager.php
Manager.resolve
public function resolve(string $alias) : bool { // return false if alias already resolved. if (in_array($alias, $this->resolved)) { return false; } $this->resolved[] = $alias; // Resolve class alias if set. if ($this->has($alias)) { $class = $this->get($alias); $class = (class_exists($class, true)) ? $class : false; } else { // Resolve namespace alias. $class = $this->resolveNamespaceAlias($alias); } // Remove the resolved class array_pop($this->resolved); // If class exists create and return a alias of the class. return (!class_exists($class)) ? false : class_alias($class, $alias); }
php
public function resolve(string $alias) : bool { // return false if alias already resolved. if (in_array($alias, $this->resolved)) { return false; } $this->resolved[] = $alias; // Resolve class alias if set. if ($this->has($alias)) { $class = $this->get($alias); $class = (class_exists($class, true)) ? $class : false; } else { // Resolve namespace alias. $class = $this->resolveNamespaceAlias($alias); } // Remove the resolved class array_pop($this->resolved); // If class exists create and return a alias of the class. return (!class_exists($class)) ? false : class_alias($class, $alias); }
[ "public", "function", "resolve", "(", "string", "$", "alias", ")", ":", "bool", "{", "// return false if alias already resolved.", "if", "(", "in_array", "(", "$", "alias", ",", "$", "this", "->", "resolved", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "resolved", "[", "]", "=", "$", "alias", ";", "// Resolve class alias if set.", "if", "(", "$", "this", "->", "has", "(", "$", "alias", ")", ")", "{", "$", "class", "=", "$", "this", "->", "get", "(", "$", "alias", ")", ";", "$", "class", "=", "(", "class_exists", "(", "$", "class", ",", "true", ")", ")", "?", "$", "class", ":", "false", ";", "}", "else", "{", "// Resolve namespace alias.", "$", "class", "=", "$", "this", "->", "resolveNamespaceAlias", "(", "$", "alias", ")", ";", "}", "// Remove the resolved class", "array_pop", "(", "$", "this", "->", "resolved", ")", ";", "// If class exists create and return a alias of the class.", "return", "(", "!", "class_exists", "(", "$", "class", ")", ")", "?", "false", ":", "class_alias", "(", "$", "class", ",", "$", "alias", ")", ";", "}" ]
Resolve all aliases. @param string $alias @return bool
[ "Resolve", "all", "aliases", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Alias/Manager.php#L195-L218
230,520
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.instance
public static function instance(Closure $callback = null, $argument = []) { if (!is_null($callback) && $callback instanceof Closure) { return $callback(static::getInstance($argument)); } return static::getInstance($argument); }
php
public static function instance(Closure $callback = null, $argument = []) { if (!is_null($callback) && $callback instanceof Closure) { return $callback(static::getInstance($argument)); } return static::getInstance($argument); }
[ "public", "static", "function", "instance", "(", "Closure", "$", "callback", "=", "null", ",", "$", "argument", "=", "[", "]", ")", "{", "if", "(", "!", "is_null", "(", "$", "callback", ")", "&&", "$", "callback", "instanceof", "Closure", ")", "{", "return", "$", "callback", "(", "static", "::", "getInstance", "(", "$", "argument", ")", ")", ";", "}", "return", "static", "::", "getInstance", "(", "$", "argument", ")", ";", "}" ]
Returns a Instance of Application either as Closure or static instance. @param Closure $callback @param array $argument @return Application
[ "Returns", "a", "Instance", "of", "Application", "either", "as", "Closure", "or", "static", "instance", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L93-L100
230,521
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.setLocale
public function setLocale($localization = null) { $locale = Config::get('global.config', 'locale'); if (!is_null($localization)) { $locale = $localization; } $fallbackLocale = Config::get('global.config', 'fallback.locale'); $trans = $this->getTranslator(); return $trans->setRootDirectory($this->container->get('app.path').DS.'Resources'.DS) ->setFallback($fallbackLocale) ->locale($locale); }
php
public function setLocale($localization = null) { $locale = Config::get('global.config', 'locale'); if (!is_null($localization)) { $locale = $localization; } $fallbackLocale = Config::get('global.config', 'fallback.locale'); $trans = $this->getTranslator(); return $trans->setRootDirectory($this->container->get('app.path').DS.'Resources'.DS) ->setFallback($fallbackLocale) ->locale($locale); }
[ "public", "function", "setLocale", "(", "$", "localization", "=", "null", ")", "{", "$", "locale", "=", "Config", "::", "get", "(", "'global.config'", ",", "'locale'", ")", ";", "if", "(", "!", "is_null", "(", "$", "localization", ")", ")", "{", "$", "locale", "=", "$", "localization", ";", "}", "$", "fallbackLocale", "=", "Config", "::", "get", "(", "'global.config'", ",", "'fallback.locale'", ")", ";", "$", "trans", "=", "$", "this", "->", "getTranslator", "(", ")", ";", "return", "$", "trans", "->", "setRootDirectory", "(", "$", "this", "->", "container", "->", "get", "(", "'app.path'", ")", ".", "DS", ".", "'Resources'", ".", "DS", ")", "->", "setFallback", "(", "$", "fallbackLocale", ")", "->", "locale", "(", "$", "locale", ")", ";", "}" ]
Set language to the translator. @param null $localization @return locale
[ "Set", "language", "to", "the", "translator", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L204-L217
230,522
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.executeServices
public function executeServices() { $serviceProvider = function () { $path = $this->container->get('app.config'); extract(['app' => $this]); return include $path.DS.'services.php'; }; return $serviceProvider(); }
php
public function executeServices() { $serviceProvider = function () { $path = $this->container->get('app.config'); extract(['app' => $this]); return include $path.DS.'services.php'; }; return $serviceProvider(); }
[ "public", "function", "executeServices", "(", ")", "{", "$", "serviceProvider", "=", "function", "(", ")", "{", "$", "path", "=", "$", "this", "->", "container", "->", "get", "(", "'app.config'", ")", ";", "extract", "(", "[", "'app'", "=>", "$", "this", "]", ")", ";", "return", "include", "$", "path", ".", "DS", ".", "'services.php'", ";", "}", ";", "return", "$", "serviceProvider", "(", ")", ";", "}" ]
Execute all registered services.
[ "Execute", "all", "registered", "services", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L223-L232
230,523
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.registerServiceProvider
public function registerServiceProvider(array $services = []) : Application { foreach ($services as $key => $serviceProvider) { $this->createProvider($serviceProvider)->register($this->container); } return $this; }
php
public function registerServiceProvider(array $services = []) : Application { foreach ($services as $key => $serviceProvider) { $this->createProvider($serviceProvider)->register($this->container); } return $this; }
[ "public", "function", "registerServiceProvider", "(", "array", "$", "services", "=", "[", "]", ")", ":", "Application", "{", "foreach", "(", "$", "services", "as", "$", "key", "=>", "$", "serviceProvider", ")", "{", "$", "this", "->", "createProvider", "(", "$", "serviceProvider", ")", "->", "register", "(", "$", "this", "->", "container", ")", ";", "}", "return", "$", "this", ";", "}" ]
We will register all service providers into application. @param array $services @return $this
[ "We", "will", "register", "all", "service", "providers", "into", "application", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L251-L258
230,524
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.setServiceController
public function setServiceController($key, $class) { $this->container[$key] = function () use ($class) { $serviceController = $this->container->singleton(\Cygnite\Mvc\Controller\ServiceController::class); $instance = new $class($serviceController, $this->container); $serviceController->setController($class); return $instance; }; }
php
public function setServiceController($key, $class) { $this->container[$key] = function () use ($class) { $serviceController = $this->container->singleton(\Cygnite\Mvc\Controller\ServiceController::class); $instance = new $class($serviceController, $this->container); $serviceController->setController($class); return $instance; }; }
[ "public", "function", "setServiceController", "(", "$", "key", ",", "$", "class", ")", "{", "$", "this", "->", "container", "[", "$", "key", "]", "=", "function", "(", ")", "use", "(", "$", "class", ")", "{", "$", "serviceController", "=", "$", "this", "->", "container", "->", "singleton", "(", "\\", "Cygnite", "\\", "Mvc", "\\", "Controller", "\\", "ServiceController", "::", "class", ")", ";", "$", "instance", "=", "new", "$", "class", "(", "$", "serviceController", ",", "$", "this", "->", "container", ")", ";", "$", "serviceController", "->", "setController", "(", "$", "class", ")", ";", "return", "$", "instance", ";", "}", ";", "}" ]
Set service controller. @param $key @param $class @return void
[ "Set", "service", "controller", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L278-L287
230,525
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.setPaths
public function setPaths() : ApplicationInterface { $this->container->set('app', $this); $paths = $this->bootstrappers->getBootstrapper()->getPaths(); foreach ($paths->all() as $key => $path) { $this->container->set($key, $path); } return $this; }
php
public function setPaths() : ApplicationInterface { $this->container->set('app', $this); $paths = $this->bootstrappers->getBootstrapper()->getPaths(); foreach ($paths->all() as $key => $path) { $this->container->set($key, $path); } return $this; }
[ "public", "function", "setPaths", "(", ")", ":", "ApplicationInterface", "{", "$", "this", "->", "container", "->", "set", "(", "'app'", ",", "$", "this", ")", ";", "$", "paths", "=", "$", "this", "->", "bootstrappers", "->", "getBootstrapper", "(", ")", "->", "getPaths", "(", ")", ";", "foreach", "(", "$", "paths", "->", "all", "(", ")", "as", "$", "key", "=>", "$", "path", ")", "{", "$", "this", "->", "container", "->", "set", "(", "$", "key", ",", "$", "path", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set Paths to Container. @return $this
[ "Set", "Paths", "to", "Container", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L315-L325
230,526
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.bootApplication
public function bootApplication(Request $request) : Application { /* | ------------------------------------------------------------------- | Check if script is running via cli and return false | ------------------------------------------------------------------- | | We will check if script running via console | then we will return from here, else application | fall back down */ if (isCli()) { return $this; } $this->bootInternals(); $this->booted = true; return $this; }
php
public function bootApplication(Request $request) : Application { /* | ------------------------------------------------------------------- | Check if script is running via cli and return false | ------------------------------------------------------------------- | | We will check if script running via console | then we will return from here, else application | fall back down */ if (isCli()) { return $this; } $this->bootInternals(); $this->booted = true; return $this; }
[ "public", "function", "bootApplication", "(", "Request", "$", "request", ")", ":", "Application", "{", "/*\n | -------------------------------------------------------------------\n | Check if script is running via cli and return false\n | -------------------------------------------------------------------\n |\n | We will check if script running via console\n | then we will return from here, else application\n | fall back down\n */", "if", "(", "isCli", "(", ")", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "bootInternals", "(", ")", ";", "$", "this", "->", "booted", "=", "true", ";", "return", "$", "this", ";", "}" ]
Set all configurations and boot application. @return $this
[ "Set", "all", "configurations", "and", "boot", "application", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L332-L351
230,527
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.registerCoreBootstrappers
protected function registerCoreBootstrappers() { foreach ($this->getBootStrappers() as $key => $class) { $this->container->set($key, $this->compose('\\'.$class)); } $this->bootstrappers->execute(); return $this; }
php
protected function registerCoreBootstrappers() { foreach ($this->getBootStrappers() as $key => $class) { $this->container->set($key, $this->compose('\\'.$class)); } $this->bootstrappers->execute(); return $this; }
[ "protected", "function", "registerCoreBootstrappers", "(", ")", "{", "foreach", "(", "$", "this", "->", "getBootStrappers", "(", ")", "as", "$", "key", "=>", "$", "class", ")", "{", "$", "this", "->", "container", "->", "set", "(", "$", "key", ",", "$", "this", "->", "compose", "(", "'\\\\'", ".", "$", "class", ")", ")", ";", "}", "$", "this", "->", "bootstrappers", "->", "execute", "(", ")", ";", "return", "$", "this", ";", "}" ]
We will register all core class into container. @return instance ContainerAwareInterface
[ "We", "will", "register", "all", "core", "class", "into", "container", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L385-L394
230,528
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.attachEvents
public function attachEvents() { $appEvents = $this->container->get('event')->getAppEvents(); if (!empty($appEvents)) { foreach ($appEvents as $event => $namespace) { // attach all before and after event to handler $this->container->get('event')->attach("$event", $namespace); } } }
php
public function attachEvents() { $appEvents = $this->container->get('event')->getAppEvents(); if (!empty($appEvents)) { foreach ($appEvents as $event => $namespace) { // attach all before and after event to handler $this->container->get('event')->attach("$event", $namespace); } } }
[ "public", "function", "attachEvents", "(", ")", "{", "$", "appEvents", "=", "$", "this", "->", "container", "->", "get", "(", "'event'", ")", "->", "getAppEvents", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "appEvents", ")", ")", "{", "foreach", "(", "$", "appEvents", "as", "$", "event", "=>", "$", "namespace", ")", "{", "// attach all before and after event to handler", "$", "this", "->", "container", "->", "get", "(", "'event'", ")", "->", "attach", "(", "\"$event\"", ",", "$", "namespace", ")", ";", "}", "}", "}" ]
Attach all application events to event handler.
[ "Attach", "all", "application", "events", "to", "event", "handler", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L428-L438
230,529
cygnite/framework
src/Cygnite/Foundation/Application.php
Application.abort
public function abort(int $code, string $message = '', array $headers = []) { if ($code == 404) { throw new \Cygnite\Exception\Http\HttpNotFoundException($message); } throw new \Cygnite\Exception\Http\HttpException($code, $message, null, $headers); }
php
public function abort(int $code, string $message = '', array $headers = []) { if ($code == 404) { throw new \Cygnite\Exception\Http\HttpNotFoundException($message); } throw new \Cygnite\Exception\Http\HttpException($code, $message, null, $headers); }
[ "public", "function", "abort", "(", "int", "$", "code", ",", "string", "$", "message", "=", "''", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "$", "code", "==", "404", ")", "{", "throw", "new", "\\", "Cygnite", "\\", "Exception", "\\", "Http", "\\", "HttpNotFoundException", "(", "$", "message", ")", ";", "}", "throw", "new", "\\", "Cygnite", "\\", "Exception", "\\", "Http", "\\", "HttpException", "(", "$", "code", ",", "$", "message", ",", "null", ",", "$", "headers", ")", ";", "}" ]
Throw an HttpException with the given message. @param int $code @param string $message @param array $headers @throw \Cygnite\Exception\Http\HttpNotFoundException|Cygnite\Exception\Http\HttpException @return void
[ "Throw", "an", "HttpException", "with", "the", "given", "message", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Application.php#L489-L496
230,530
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.resolveConnection
public function resolveConnection() { $connection = self::cyrus()->getDatabase(); $this->setDatabaseConnection($connection); return is_object($this->pdo[$connection]) ? $this->pdo[$connection] : null; }
php
public function resolveConnection() { $connection = self::cyrus()->getDatabase(); $this->setDatabaseConnection($connection); return is_object($this->pdo[$connection]) ? $this->pdo[$connection] : null; }
[ "public", "function", "resolveConnection", "(", ")", "{", "$", "connection", "=", "self", "::", "cyrus", "(", ")", "->", "getDatabase", "(", ")", ";", "$", "this", "->", "setDatabaseConnection", "(", "$", "connection", ")", ";", "return", "is_object", "(", "$", "this", "->", "pdo", "[", "$", "connection", "]", ")", "?", "$", "this", "->", "pdo", "[", "$", "connection", "]", ":", "null", ";", "}" ]
Get Database Connection Object based on database name provided into model class. @return null|object
[ "Get", "Database", "Connection", "Object", "based", "on", "database", "name", "provided", "into", "model", "class", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L155-L162
230,531
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.insert
public function insert($arguments = []) { $ar = null; $ar = self::cyrus(); /* | Trigger Before create events if | defined by user into model class | */ $this->triggerEvent('beforeCreate'); // Build Sql Query and prepare it $sql = $this->getInsertQuery(strtoupper(__FUNCTION__), $ar, $arguments); try { $statement = $this->resolveConnection()->prepare($sql); static::$queries[] = $statement->queryString; // we will bind all parameters into the statement using execute method if ($return = $statement->execute($arguments)) { $ar->{$ar->getKeyName()} = (int) $this->resolveConnection()->lastInsertId(); /* | Trigger after create events if | defined by user into model class | */ $this->triggerEvent('afterCreate'); return $return; } } catch (PDOException $exception) { throw new \RuntimeException($exception->getMessage()); } }
php
public function insert($arguments = []) { $ar = null; $ar = self::cyrus(); /* | Trigger Before create events if | defined by user into model class | */ $this->triggerEvent('beforeCreate'); // Build Sql Query and prepare it $sql = $this->getInsertQuery(strtoupper(__FUNCTION__), $ar, $arguments); try { $statement = $this->resolveConnection()->prepare($sql); static::$queries[] = $statement->queryString; // we will bind all parameters into the statement using execute method if ($return = $statement->execute($arguments)) { $ar->{$ar->getKeyName()} = (int) $this->resolveConnection()->lastInsertId(); /* | Trigger after create events if | defined by user into model class | */ $this->triggerEvent('afterCreate'); return $return; } } catch (PDOException $exception) { throw new \RuntimeException($exception->getMessage()); } }
[ "public", "function", "insert", "(", "$", "arguments", "=", "[", "]", ")", "{", "$", "ar", "=", "null", ";", "$", "ar", "=", "self", "::", "cyrus", "(", ")", ";", "/*\n | Trigger Before create events if\n | defined by user into model class\n |\n */", "$", "this", "->", "triggerEvent", "(", "'beforeCreate'", ")", ";", "// Build Sql Query and prepare it", "$", "sql", "=", "$", "this", "->", "getInsertQuery", "(", "strtoupper", "(", "__FUNCTION__", ")", ",", "$", "ar", ",", "$", "arguments", ")", ";", "try", "{", "$", "statement", "=", "$", "this", "->", "resolveConnection", "(", ")", "->", "prepare", "(", "$", "sql", ")", ";", "static", "::", "$", "queries", "[", "]", "=", "$", "statement", "->", "queryString", ";", "// we will bind all parameters into the statement using execute method", "if", "(", "$", "return", "=", "$", "statement", "->", "execute", "(", "$", "arguments", ")", ")", "{", "$", "ar", "->", "{", "$", "ar", "->", "getKeyName", "(", ")", "}", "=", "(", "int", ")", "$", "this", "->", "resolveConnection", "(", ")", "->", "lastInsertId", "(", ")", ";", "/*\n | Trigger after create events if\n | defined by user into model class\n |\n */", "$", "this", "->", "triggerEvent", "(", "'afterCreate'", ")", ";", "return", "$", "return", ";", "}", "}", "catch", "(", "PDOException", "$", "exception", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "exception", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Insert a record into database. @param array $arguments @throws \RuntimeException @return mixed
[ "Insert", "a", "record", "into", "database", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L173-L206
230,532
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.buildWhereForUpdate
private function buildWhereForUpdate() { $whereArray = array_combine($this->where, $this->bindings); list($whereNew, $condition) = $this->formatWhereToNamePlaceHolder($whereArray); return [$whereNew, $this->buildWherePlaceholderName($whereNew)]; }
php
private function buildWhereForUpdate() { $whereArray = array_combine($this->where, $this->bindings); list($whereNew, $condition) = $this->formatWhereToNamePlaceHolder($whereArray); return [$whereNew, $this->buildWherePlaceholderName($whereNew)]; }
[ "private", "function", "buildWhereForUpdate", "(", ")", "{", "$", "whereArray", "=", "array_combine", "(", "$", "this", "->", "where", ",", "$", "this", "->", "bindings", ")", ";", "list", "(", "$", "whereNew", ",", "$", "condition", ")", "=", "$", "this", "->", "formatWhereToNamePlaceHolder", "(", "$", "whereArray", ")", ";", "return", "[", "$", "whereNew", ",", "$", "this", "->", "buildWherePlaceholderName", "(", "$", "whereNew", ")", "]", ";", "}" ]
Build where condition for Update query. @return array
[ "Build", "where", "condition", "for", "Update", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L253-L259
230,533
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.update
public function update($data, $where = []) { /* | Trigger Before Update events if | defined by user into model class | */ $this->triggerEvent('beforeUpdate'); if (!empty($where)) { $whereStr = $this->buildWherePlaceholderName($where); } else { list($where, $whereStr) = $this->buildWhereForUpdate(); } $sql = $this->getUpdateQuery($data, strtoupper(__FUNCTION__)).$whereStr; try { $stmt = $this->resolveConnection()->prepare($sql); //Bind all values to query statement foreach ($data as $key => $val) { $stmt->bindValue(":$key", $val); } foreach ($where as $key => $value) { $stmt->bindValue(":$key", $value); } static::$queries[] = $stmt->queryString; $affectedRow = $stmt->execute(); /* | Trigger after update events if defined | into model class | */ $this->triggerEvent('afterUpdate'); return $affectedRow; } catch (\PDOException $exception) { throw new \Exception($exception->getMessage()); } }
php
public function update($data, $where = []) { /* | Trigger Before Update events if | defined by user into model class | */ $this->triggerEvent('beforeUpdate'); if (!empty($where)) { $whereStr = $this->buildWherePlaceholderName($where); } else { list($where, $whereStr) = $this->buildWhereForUpdate(); } $sql = $this->getUpdateQuery($data, strtoupper(__FUNCTION__)).$whereStr; try { $stmt = $this->resolveConnection()->prepare($sql); //Bind all values to query statement foreach ($data as $key => $val) { $stmt->bindValue(":$key", $val); } foreach ($where as $key => $value) { $stmt->bindValue(":$key", $value); } static::$queries[] = $stmt->queryString; $affectedRow = $stmt->execute(); /* | Trigger after update events if defined | into model class | */ $this->triggerEvent('afterUpdate'); return $affectedRow; } catch (\PDOException $exception) { throw new \Exception($exception->getMessage()); } }
[ "public", "function", "update", "(", "$", "data", ",", "$", "where", "=", "[", "]", ")", "{", "/*\n | Trigger Before Update events if\n | defined by user into model class\n |\n */", "$", "this", "->", "triggerEvent", "(", "'beforeUpdate'", ")", ";", "if", "(", "!", "empty", "(", "$", "where", ")", ")", "{", "$", "whereStr", "=", "$", "this", "->", "buildWherePlaceholderName", "(", "$", "where", ")", ";", "}", "else", "{", "list", "(", "$", "where", ",", "$", "whereStr", ")", "=", "$", "this", "->", "buildWhereForUpdate", "(", ")", ";", "}", "$", "sql", "=", "$", "this", "->", "getUpdateQuery", "(", "$", "data", ",", "strtoupper", "(", "__FUNCTION__", ")", ")", ".", "$", "whereStr", ";", "try", "{", "$", "stmt", "=", "$", "this", "->", "resolveConnection", "(", ")", "->", "prepare", "(", "$", "sql", ")", ";", "//Bind all values to query statement", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "stmt", "->", "bindValue", "(", "\":$key\"", ",", "$", "val", ")", ";", "}", "foreach", "(", "$", "where", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "stmt", "->", "bindValue", "(", "\":$key\"", ",", "$", "value", ")", ";", "}", "static", "::", "$", "queries", "[", "]", "=", "$", "stmt", "->", "queryString", ";", "$", "affectedRow", "=", "$", "stmt", "->", "execute", "(", ")", ";", "/*\n | Trigger after update events if defined\n | into model class\n |\n */", "$", "this", "->", "triggerEvent", "(", "'afterUpdate'", ")", ";", "return", "$", "affectedRow", ";", "}", "catch", "(", "\\", "PDOException", "$", "exception", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "exception", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Update record with new values. @param $args @throws \Exception @return mixed
[ "Update", "record", "with", "new", "values", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L270-L313
230,534
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.trash
public function trash($where = null, $multiple = false) { $whr = []; $ar = self::cyrus(); /* | Trigger Before Delete events if | defined by user into model class | */ $this->triggerEvent('beforeDelete'); // Bind where conditions $this->bindWhereClause($where, $multiple, $ar); $sql = self::DELETE. ' FROM '.$this->quoteIdentifier($ar->getDatabase()).'.'.$this->quoteIdentifier($ar->getTableName()) .$this->getWhere(); try { /* | Get the Connection, prepare and execute sql query | return affected rows */ $stmt = $this->resolveConnection()->prepare($sql); $this->bindParam($stmt); //bind parameters static::$queries[] = $stmt->queryString; $affectedRow = $stmt->execute(); /* | Trigger after delete model events if defined */ $this->triggerEvent('afterDelete'); return $affectedRow; } catch (\PDOException $ex) { throw new DatabaseException($ex->getMessage()); } }
php
public function trash($where = null, $multiple = false) { $whr = []; $ar = self::cyrus(); /* | Trigger Before Delete events if | defined by user into model class | */ $this->triggerEvent('beforeDelete'); // Bind where conditions $this->bindWhereClause($where, $multiple, $ar); $sql = self::DELETE. ' FROM '.$this->quoteIdentifier($ar->getDatabase()).'.'.$this->quoteIdentifier($ar->getTableName()) .$this->getWhere(); try { /* | Get the Connection, prepare and execute sql query | return affected rows */ $stmt = $this->resolveConnection()->prepare($sql); $this->bindParam($stmt); //bind parameters static::$queries[] = $stmt->queryString; $affectedRow = $stmt->execute(); /* | Trigger after delete model events if defined */ $this->triggerEvent('afterDelete'); return $affectedRow; } catch (\PDOException $ex) { throw new DatabaseException($ex->getMessage()); } }
[ "public", "function", "trash", "(", "$", "where", "=", "null", ",", "$", "multiple", "=", "false", ")", "{", "$", "whr", "=", "[", "]", ";", "$", "ar", "=", "self", "::", "cyrus", "(", ")", ";", "/*\n | Trigger Before Delete events if\n | defined by user into model class\n |\n */", "$", "this", "->", "triggerEvent", "(", "'beforeDelete'", ")", ";", "// Bind where conditions", "$", "this", "->", "bindWhereClause", "(", "$", "where", ",", "$", "multiple", ",", "$", "ar", ")", ";", "$", "sql", "=", "self", "::", "DELETE", ".", "' FROM '", ".", "$", "this", "->", "quoteIdentifier", "(", "$", "ar", "->", "getDatabase", "(", ")", ")", ".", "'.'", ".", "$", "this", "->", "quoteIdentifier", "(", "$", "ar", "->", "getTableName", "(", ")", ")", ".", "$", "this", "->", "getWhere", "(", ")", ";", "try", "{", "/*\n | Get the Connection, prepare and execute sql query\n | return affected rows\n */", "$", "stmt", "=", "$", "this", "->", "resolveConnection", "(", ")", "->", "prepare", "(", "$", "sql", ")", ";", "$", "this", "->", "bindParam", "(", "$", "stmt", ")", ";", "//bind parameters", "static", "::", "$", "queries", "[", "]", "=", "$", "stmt", "->", "queryString", ";", "$", "affectedRow", "=", "$", "stmt", "->", "execute", "(", ")", ";", "/*\n | Trigger after delete model events if defined\n */", "$", "this", "->", "triggerEvent", "(", "'afterDelete'", ")", ";", "return", "$", "affectedRow", ";", "}", "catch", "(", "\\", "PDOException", "$", "ex", ")", "{", "throw", "new", "DatabaseException", "(", "$", "ex", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Trash method. Delete a row from the table <code> $user = new User(); $user->trash(1); $user->trash([1,4,6,33,54], true) $user->trash(['id' => 23]) $user->where('name', '=', 'application')->trash(); </code> @param array $where $multiple false @param bool $multiple @throws \Exception @internal param \Cygnite\Database\the $string table to retrieve the results from @return object
[ "Trash", "method", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L339-L376
230,535
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder._select
private function _select($column) { if ($column === 'all' || $column == '*') { $this->selectColumns = $this->quoteIdentifier( self::cyrus()->getTableName() ).'.*'; } else { if (string_has($column, 'as') || string_has($column, 'AS')) { return $this->selectExpr($column); } $this->selectColumns = (string) str_replace(' ', '', $this->quoteIdentifier(explode(',', $column))); } return $this; }
php
private function _select($column) { if ($column === 'all' || $column == '*') { $this->selectColumns = $this->quoteIdentifier( self::cyrus()->getTableName() ).'.*'; } else { if (string_has($column, 'as') || string_has($column, 'AS')) { return $this->selectExpr($column); } $this->selectColumns = (string) str_replace(' ', '', $this->quoteIdentifier(explode(',', $column))); } return $this; }
[ "private", "function", "_select", "(", "$", "column", ")", "{", "if", "(", "$", "column", "===", "'all'", "||", "$", "column", "==", "'*'", ")", "{", "$", "this", "->", "selectColumns", "=", "$", "this", "->", "quoteIdentifier", "(", "self", "::", "cyrus", "(", ")", "->", "getTableName", "(", ")", ")", ".", "'.*'", ";", "}", "else", "{", "if", "(", "string_has", "(", "$", "column", ",", "'as'", ")", "||", "string_has", "(", "$", "column", ",", "'AS'", ")", ")", "{", "return", "$", "this", "->", "selectExpr", "(", "$", "column", ")", ";", "}", "$", "this", "->", "selectColumns", "=", "(", "string", ")", "str_replace", "(", "' '", ",", "''", ",", "$", "this", "->", "quoteIdentifier", "(", "explode", "(", "','", ",", "$", "column", ")", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Internally build select Columns. @param $column @return $this
[ "Internally", "build", "select", "Columns", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L443-L458
230,536
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.orWhereIn
public function orWhereIn($key, $value, $operator = 'IN') { $exp = explode(',', $value); $this->where[] = 'OR OR'.$key.' '.$operator.' ('.$this->createPlaceHolder($exp).') '; foreach ($exp as $key => $val) { $this->bindings[$key] = $val; } return $this; }
php
public function orWhereIn($key, $value, $operator = 'IN') { $exp = explode(',', $value); $this->where[] = 'OR OR'.$key.' '.$operator.' ('.$this->createPlaceHolder($exp).') '; foreach ($exp as $key => $val) { $this->bindings[$key] = $val; } return $this; }
[ "public", "function", "orWhereIn", "(", "$", "key", ",", "$", "value", ",", "$", "operator", "=", "'IN'", ")", "{", "$", "exp", "=", "explode", "(", "','", ",", "$", "value", ")", ";", "$", "this", "->", "where", "[", "]", "=", "'OR OR'", ".", "$", "key", ".", "' '", ".", "$", "operator", ".", "' ('", ".", "$", "this", "->", "createPlaceHolder", "(", "$", "exp", ")", ".", "') '", ";", "foreach", "(", "$", "exp", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "this", "->", "bindings", "[", "$", "key", "]", "=", "$", "val", ";", "}", "return", "$", "this", ";", "}" ]
Where conditions with "or". @param $key @param $value @param string $operator @return $this
[ "Where", "conditions", "with", "or", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L546-L556
230,537
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.having
public function having($column, $operator = '=', $value = null) { $this->havingType = 'AND'; return $this->addCondition('having', $column, $operator, $value); }
php
public function having($column, $operator = '=', $value = null) { $this->havingType = 'AND'; return $this->addCondition('having', $column, $operator, $value); }
[ "public", "function", "having", "(", "$", "column", ",", "$", "operator", "=", "'='", ",", "$", "value", "=", "null", ")", "{", "$", "this", "->", "havingType", "=", "'AND'", ";", "return", "$", "this", "->", "addCondition", "(", "'having'", ",", "$", "column", ",", "$", "operator", ",", "$", "value", ")", ";", "}" ]
Add having clause to the query. @param $column @param string $operator @param null $value @return $this
[ "Add", "having", "clause", "to", "the", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L567-L572
230,538
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.orHaving
public function orHaving($column, $operator = '=', $value = null) { $this->havingType = 'OR'; return $this->addCondition('having', $column, $operator, $value); }
php
public function orHaving($column, $operator = '=', $value = null) { $this->havingType = 'OR'; return $this->addCondition('having', $column, $operator, $value); }
[ "public", "function", "orHaving", "(", "$", "column", ",", "$", "operator", "=", "'='", ",", "$", "value", "=", "null", ")", "{", "$", "this", "->", "havingType", "=", "'OR'", ";", "return", "$", "this", "->", "addCondition", "(", "'having'", ",", "$", "column", ",", "$", "operator", ",", "$", "value", ")", ";", "}" ]
Add having clause to the query prefixing OR keyword. @param $column @param string $operator @param null $value @return $this|Builder
[ "Add", "having", "clause", "to", "the", "query", "prefixing", "OR", "keyword", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L583-L588
230,539
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.addCondition
protected function addCondition($type, $column, $separator, $value) { $multiple = is_array($column) ? $column : [$column => $value]; foreach ($multiple as $key => $val) { // Add the table name in case of ambiguous columns if (count($this->joinSources) > 0 && string_has($key, '.')) { $table = (!is_null($this->tableAlias)) ? $this->tableAlias : $this->formTable; $key = "{$table}.{$key}"; } $key = $this->quoteIdentifier($key); $this->bindCondition($type, "{$key} {$separator} ?", $val); } return $this; }
php
protected function addCondition($type, $column, $separator, $value) { $multiple = is_array($column) ? $column : [$column => $value]; foreach ($multiple as $key => $val) { // Add the table name in case of ambiguous columns if (count($this->joinSources) > 0 && string_has($key, '.')) { $table = (!is_null($this->tableAlias)) ? $this->tableAlias : $this->formTable; $key = "{$table}.{$key}"; } $key = $this->quoteIdentifier($key); $this->bindCondition($type, "{$key} {$separator} ?", $val); } return $this; }
[ "protected", "function", "addCondition", "(", "$", "type", ",", "$", "column", ",", "$", "separator", ",", "$", "value", ")", "{", "$", "multiple", "=", "is_array", "(", "$", "column", ")", "?", "$", "column", ":", "[", "$", "column", "=>", "$", "value", "]", ";", "foreach", "(", "$", "multiple", "as", "$", "key", "=>", "$", "val", ")", "{", "// Add the table name in case of ambiguous columns", "if", "(", "count", "(", "$", "this", "->", "joinSources", ")", ">", "0", "&&", "string_has", "(", "$", "key", ",", "'.'", ")", ")", "{", "$", "table", "=", "(", "!", "is_null", "(", "$", "this", "->", "tableAlias", ")", ")", "?", "$", "this", "->", "tableAlias", ":", "$", "this", "->", "formTable", ";", "$", "key", "=", "\"{$table}.{$key}\"", ";", "}", "$", "key", "=", "$", "this", "->", "quoteIdentifier", "(", "$", "key", ")", ";", "$", "this", "->", "bindCondition", "(", "$", "type", ",", "\"{$key} {$separator} ?\"", ",", "$", "val", ")", ";", "}", "return", "$", "this", ";", "}" ]
Method to compile a simple column separated value for HAVING clause. If column passed as array, we will add condition for each column. @param $type @param $column @param $separator @param $value @return $this
[ "Method", "to", "compile", "a", "simple", "column", "separated", "value", "for", "HAVING", "clause", ".", "If", "column", "passed", "as", "array", "we", "will", "add", "condition", "for", "each", "column", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L601-L619
230,540
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.bindCondition
protected function bindCondition($type, $key, $values = []) { $conditionHolder = "{$type}Conditions"; if (!is_array($values)) { $values = [$values]; } array_push($this->$conditionHolder, [$key, $values]); return $this; }
php
protected function bindCondition($type, $key, $values = []) { $conditionHolder = "{$type}Conditions"; if (!is_array($values)) { $values = [$values]; } array_push($this->$conditionHolder, [$key, $values]); return $this; }
[ "protected", "function", "bindCondition", "(", "$", "type", ",", "$", "key", ",", "$", "values", "=", "[", "]", ")", "{", "$", "conditionHolder", "=", "\"{$type}Conditions\"", ";", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "$", "values", "=", "[", "$", "values", "]", ";", "}", "array_push", "(", "$", "this", "->", "$", "conditionHolder", ",", "[", "$", "key", ",", "$", "values", "]", ")", ";", "return", "$", "this", ";", "}" ]
Build Having Conditions for the query. @param $type @param $key @param array $values @return $this
[ "Build", "Having", "Conditions", "for", "the", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L645-L655
230,541
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.makeConditions
protected function makeConditions($type, $join = 'AND') { $conditionHolder = "{$type}Conditions"; // If there are no clauses, return empty string if (count($this->$conditionHolder) === 0) { return ''; } $conditions = []; /* * Bind all values to property to execute query */ foreach ($this->$conditionHolder as $condition) { $conditions[] = $condition[0]; $this->bindings = array_merge($this->bindings, $condition[1]); } return strtoupper($type).' '.implode(" $join ", $conditions); }
php
protected function makeConditions($type, $join = 'AND') { $conditionHolder = "{$type}Conditions"; // If there are no clauses, return empty string if (count($this->$conditionHolder) === 0) { return ''; } $conditions = []; /* * Bind all values to property to execute query */ foreach ($this->$conditionHolder as $condition) { $conditions[] = $condition[0]; $this->bindings = array_merge($this->bindings, $condition[1]); } return strtoupper($type).' '.implode(" $join ", $conditions); }
[ "protected", "function", "makeConditions", "(", "$", "type", ",", "$", "join", "=", "'AND'", ")", "{", "$", "conditionHolder", "=", "\"{$type}Conditions\"", ";", "// If there are no clauses, return empty string", "if", "(", "count", "(", "$", "this", "->", "$", "conditionHolder", ")", "===", "0", ")", "{", "return", "''", ";", "}", "$", "conditions", "=", "[", "]", ";", "/*\n * Bind all values to property to execute query\n */", "foreach", "(", "$", "this", "->", "$", "conditionHolder", "as", "$", "condition", ")", "{", "$", "conditions", "[", "]", "=", "$", "condition", "[", "0", "]", ";", "$", "this", "->", "bindings", "=", "array_merge", "(", "$", "this", "->", "bindings", ",", "$", "condition", "[", "1", "]", ")", ";", "}", "return", "strtoupper", "(", "$", "type", ")", ".", "' '", ".", "implode", "(", "\" $join \"", ",", "$", "conditions", ")", ";", "}" ]
Build a HAVING clause conditions. @param string $type @param string $join @return string
[ "Build", "a", "HAVING", "clause", "conditions", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L678-L698
230,542
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.limit
public function limit($limit, $offset = '') { if (is_null($limit)) { throw new \Exception('Empty parameter given to limit clause '); } if (empty($offset) && !empty($limit)) { $this->limitValue = 0; $this->offsetValue = intval($limit); } else { $this->limitValue = intval($limit); $this->offsetValue = intval($offset); } return $this; }
php
public function limit($limit, $offset = '') { if (is_null($limit)) { throw new \Exception('Empty parameter given to limit clause '); } if (empty($offset) && !empty($limit)) { $this->limitValue = 0; $this->offsetValue = intval($limit); } else { $this->limitValue = intval($limit); $this->offsetValue = intval($offset); } return $this; }
[ "public", "function", "limit", "(", "$", "limit", ",", "$", "offset", "=", "''", ")", "{", "if", "(", "is_null", "(", "$", "limit", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Empty parameter given to limit clause '", ")", ";", "}", "if", "(", "empty", "(", "$", "offset", ")", "&&", "!", "empty", "(", "$", "limit", ")", ")", "{", "$", "this", "->", "limitValue", "=", "0", ";", "$", "this", "->", "offsetValue", "=", "intval", "(", "$", "limit", ")", ";", "}", "else", "{", "$", "this", "->", "limitValue", "=", "intval", "(", "$", "limit", ")", ";", "$", "this", "->", "offsetValue", "=", "intval", "(", "$", "offset", ")", ";", "}", "return", "$", "this", ";", "}" ]
Limit the record and fetch from database. @param type $limit @param string $offset @throws \Exception @return $this
[ "Limit", "the", "record", "and", "fetch", "from", "database", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L724-L739
230,543
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.orderBy
public function orderBy($column, $orderType = 'ASC') { if (empty($column) || is_null($column)) { throw new \Exception('Empty parameter given to order by clause'); } $this->orderType = $orderType; if (is_array($column)) { $this->columnName = $this->extractArrayAttributes($column); return $this; } if (is_null($this->columnName)) { $this->columnName = $column; } return $this; }
php
public function orderBy($column, $orderType = 'ASC') { if (empty($column) || is_null($column)) { throw new \Exception('Empty parameter given to order by clause'); } $this->orderType = $orderType; if (is_array($column)) { $this->columnName = $this->extractArrayAttributes($column); return $this; } if (is_null($this->columnName)) { $this->columnName = $column; } return $this; }
[ "public", "function", "orderBy", "(", "$", "column", ",", "$", "orderType", "=", "'ASC'", ")", "{", "if", "(", "empty", "(", "$", "column", ")", "||", "is_null", "(", "$", "column", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Empty parameter given to order by clause'", ")", ";", "}", "$", "this", "->", "orderType", "=", "$", "orderType", ";", "if", "(", "is_array", "(", "$", "column", ")", ")", "{", "$", "this", "->", "columnName", "=", "$", "this", "->", "extractArrayAttributes", "(", "$", "column", ")", ";", "return", "$", "this", ";", "}", "if", "(", "is_null", "(", "$", "this", "->", "columnName", ")", ")", "{", "$", "this", "->", "columnName", "=", "$", "column", ";", "}", "return", "$", "this", ";", "}" ]
This function to make order for selected query. @param $column @param string $orderType @throws \Exception @return $this
[ "This", "function", "to", "make", "order", "for", "selected", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L751-L769
230,544
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.groupBy
public function groupBy($column) { if (is_null($column)) { throw new \InvalidArgumentException('Cannot pass null argument to '.__METHOD__); } if (is_array($column)) { $this->groupBy = $this->extractArrayAttributes($column); return $this; } $this->groupBy = $this->quoteIdentifier($column); return $this; }
php
public function groupBy($column) { if (is_null($column)) { throw new \InvalidArgumentException('Cannot pass null argument to '.__METHOD__); } if (is_array($column)) { $this->groupBy = $this->extractArrayAttributes($column); return $this; } $this->groupBy = $this->quoteIdentifier($column); return $this; }
[ "public", "function", "groupBy", "(", "$", "column", ")", "{", "if", "(", "is_null", "(", "$", "column", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Cannot pass null argument to '", ".", "__METHOD__", ")", ";", "}", "if", "(", "is_array", "(", "$", "column", ")", ")", "{", "$", "this", "->", "groupBy", "=", "$", "this", "->", "extractArrayAttributes", "(", "$", "column", ")", ";", "return", "$", "this", ";", "}", "$", "this", "->", "groupBy", "=", "$", "this", "->", "quoteIdentifier", "(", "$", "column", ")", ";", "return", "$", "this", ";", "}" ]
Group By function to group columns based on aggregate functions. @param $column @throws \InvalidArgumentException @return $this
[ "Group", "By", "function", "to", "group", "columns", "based", "on", "aggregate", "functions", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L780-L795
230,545
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.findAll
public function findAll($type = '') { $data = []; $ar = self::cyrus(); /* | Trigger before select events defined into | model class */ $this->triggerEvent('beforeSelect'); $this->buildQuery(); // Build Sql Query try { $stmt = $this->resolveConnection()->prepare($this->sqlQuery); $this->sqlQuery = null; $this->setDbStatement($ar->getTableName(), $stmt); $this->bindParam($stmt); $stmt->execute(); $data = $this->fetchAs($stmt, $type); /* | Trigger after select events defined into model class */ $this->triggerEvent('afterSelect'); if ($stmt->rowCount() > 0) { return new Collection($data); } else { return new Collection([]); } } catch (PDOException $ex) { throw new \Exception('Database exceptions: Invalid query x'.$ex->getMessage()); } }
php
public function findAll($type = '') { $data = []; $ar = self::cyrus(); /* | Trigger before select events defined into | model class */ $this->triggerEvent('beforeSelect'); $this->buildQuery(); // Build Sql Query try { $stmt = $this->resolveConnection()->prepare($this->sqlQuery); $this->sqlQuery = null; $this->setDbStatement($ar->getTableName(), $stmt); $this->bindParam($stmt); $stmt->execute(); $data = $this->fetchAs($stmt, $type); /* | Trigger after select events defined into model class */ $this->triggerEvent('afterSelect'); if ($stmt->rowCount() > 0) { return new Collection($data); } else { return new Collection([]); } } catch (PDOException $ex) { throw new \Exception('Database exceptions: Invalid query x'.$ex->getMessage()); } }
[ "public", "function", "findAll", "(", "$", "type", "=", "''", ")", "{", "$", "data", "=", "[", "]", ";", "$", "ar", "=", "self", "::", "cyrus", "(", ")", ";", "/*\n | Trigger before select events defined into\n | model class\n */", "$", "this", "->", "triggerEvent", "(", "'beforeSelect'", ")", ";", "$", "this", "->", "buildQuery", "(", ")", ";", "// Build Sql Query", "try", "{", "$", "stmt", "=", "$", "this", "->", "resolveConnection", "(", ")", "->", "prepare", "(", "$", "this", "->", "sqlQuery", ")", ";", "$", "this", "->", "sqlQuery", "=", "null", ";", "$", "this", "->", "setDbStatement", "(", "$", "ar", "->", "getTableName", "(", ")", ",", "$", "stmt", ")", ";", "$", "this", "->", "bindParam", "(", "$", "stmt", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "$", "data", "=", "$", "this", "->", "fetchAs", "(", "$", "stmt", ",", "$", "type", ")", ";", "/*\n | Trigger after select events defined into model class\n */", "$", "this", "->", "triggerEvent", "(", "'afterSelect'", ")", ";", "if", "(", "$", "stmt", "->", "rowCount", "(", ")", ">", "0", ")", "{", "return", "new", "Collection", "(", "$", "data", ")", ";", "}", "else", "{", "return", "new", "Collection", "(", "[", "]", ")", ";", "}", "}", "catch", "(", "PDOException", "$", "ex", ")", "{", "throw", "new", "\\", "Exception", "(", "'Database exceptions: Invalid query x'", ".", "$", "ex", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Build and Find all the matching records from database. By default its returns class with properties values You can simply pass fetchMode into findAll to get various format output. @param string $type @throws \Exception @internal param string $type @return array or object
[ "Build", "and", "Find", "all", "the", "matching", "records", "from", "database", ".", "By", "default", "its", "returns", "class", "with", "properties", "values", "You", "can", "simply", "pass", "fetchMode", "into", "findAll", "to", "get", "various", "format", "output", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L825-L858
230,546
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.findOne
public function findOne($type = '') { $rows = $this->findAll($type)->asArray(); return isset($rows[0]) ? $rows[0] : null; }
php
public function findOne($type = '') { $rows = $this->findAll($type)->asArray(); return isset($rows[0]) ? $rows[0] : null; }
[ "public", "function", "findOne", "(", "$", "type", "=", "''", ")", "{", "$", "rows", "=", "$", "this", "->", "findAll", "(", "$", "type", ")", "->", "asArray", "(", ")", ";", "return", "isset", "(", "$", "rows", "[", "0", "]", ")", "?", "$", "rows", "[", "0", "]", ":", "null", ";", "}" ]
This method is alias of findAll, We will get only the zeroth row from the collection object. @return object|null
[ "This", "method", "is", "alias", "of", "findAll", "We", "will", "get", "only", "the", "zeroth", "row", "from", "the", "collection", "object", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L878-L883
230,547
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.fetchAs
public function fetchAs($stmt, $type = null) { $data = []; if ((is_null($type) || $type == '') && static::$dataSource) { $type = 'class'; static::$dataSource = false; } switch (strtolower($type)) { case 'group': $data = $stmt->fetchAll(\PDO::FETCH_GROUP | \PDO::FETCH_ASSOC); break; case 'both': $data = $stmt->fetchAll(\PDO::FETCH_BOTH); break; case 'object': $data = $stmt->fetchAll(\PDO::FETCH_OBJ); break; case 'assoc': $data = $stmt->fetchAll(\PDO::FETCH_ASSOC); break; case 'column': $data = $stmt->fetchAll(\PDO::FETCH_COLUMN); break; case 'class': $data = $stmt->fetchAll(\PDO::FETCH_CLASS, '\\Cygnite\\Database\\ResultSet'); break; default: $data = $stmt->fetchAll(\PDO::FETCH_CLASS, '\\'.self::cyrus()->getModelClassNs()); break; } return $data; }
php
public function fetchAs($stmt, $type = null) { $data = []; if ((is_null($type) || $type == '') && static::$dataSource) { $type = 'class'; static::$dataSource = false; } switch (strtolower($type)) { case 'group': $data = $stmt->fetchAll(\PDO::FETCH_GROUP | \PDO::FETCH_ASSOC); break; case 'both': $data = $stmt->fetchAll(\PDO::FETCH_BOTH); break; case 'object': $data = $stmt->fetchAll(\PDO::FETCH_OBJ); break; case 'assoc': $data = $stmt->fetchAll(\PDO::FETCH_ASSOC); break; case 'column': $data = $stmt->fetchAll(\PDO::FETCH_COLUMN); break; case 'class': $data = $stmt->fetchAll(\PDO::FETCH_CLASS, '\\Cygnite\\Database\\ResultSet'); break; default: $data = $stmt->fetchAll(\PDO::FETCH_CLASS, '\\'.self::cyrus()->getModelClassNs()); break; } return $data; }
[ "public", "function", "fetchAs", "(", "$", "stmt", ",", "$", "type", "=", "null", ")", "{", "$", "data", "=", "[", "]", ";", "if", "(", "(", "is_null", "(", "$", "type", ")", "||", "$", "type", "==", "''", ")", "&&", "static", "::", "$", "dataSource", ")", "{", "$", "type", "=", "'class'", ";", "static", "::", "$", "dataSource", "=", "false", ";", "}", "switch", "(", "strtolower", "(", "$", "type", ")", ")", "{", "case", "'group'", ":", "$", "data", "=", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_GROUP", "|", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "break", ";", "case", "'both'", ":", "$", "data", "=", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_BOTH", ")", ";", "break", ";", "case", "'object'", ":", "$", "data", "=", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_OBJ", ")", ";", "break", ";", "case", "'assoc'", ":", "$", "data", "=", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "break", ";", "case", "'column'", ":", "$", "data", "=", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_COLUMN", ")", ";", "break", ";", "case", "'class'", ":", "$", "data", "=", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_CLASS", ",", "'\\\\Cygnite\\\\Database\\\\ResultSet'", ")", ";", "break", ";", "default", ":", "$", "data", "=", "$", "stmt", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_CLASS", ",", "'\\\\'", ".", "self", "::", "cyrus", "(", ")", "->", "getModelClassNs", "(", ")", ")", ";", "break", ";", "}", "return", "$", "data", ";", "}" ]
Allows to fetch records as type specified. @param $stmt @param null $type @return string
[ "Allows", "to", "fetch", "records", "as", "type", "specified", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L893-L927
230,548
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.sql
public function sql($sql, $attributes = []) { try { $this->statement = $this->resolveConnection()->prepare($sql); if (!empty($attributes)) { $this->statement->execute($attributes); } else { $this->statement->execute(); } } catch (\PDOException $e) { throw new Exception($e->getMessage()); } return $this; }
php
public function sql($sql, $attributes = []) { try { $this->statement = $this->resolveConnection()->prepare($sql); if (!empty($attributes)) { $this->statement->execute($attributes); } else { $this->statement->execute(); } } catch (\PDOException $e) { throw new Exception($e->getMessage()); } return $this; }
[ "public", "function", "sql", "(", "$", "sql", ",", "$", "attributes", "=", "[", "]", ")", "{", "try", "{", "$", "this", "->", "statement", "=", "$", "this", "->", "resolveConnection", "(", ")", "->", "prepare", "(", "$", "sql", ")", ";", "if", "(", "!", "empty", "(", "$", "attributes", ")", ")", "{", "$", "this", "->", "statement", "->", "execute", "(", "$", "attributes", ")", ";", "}", "else", "{", "$", "this", "->", "statement", "->", "execute", "(", ")", ";", "}", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Build raw queries. @param string $sql @param array $attributes @throws \Exception|\PDOException @return object pointer $this
[ "Build", "raw", "queries", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L979-L994
230,549
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.buildFindersWhereCondition
public function buildFindersWhereCondition($method, $arguments, $type = 'And') { $condition = []; $condition = explode($type, str_replace('findBy', '', $method)); if (count($condition) == count($arguments[0])) { foreach ($condition as $key => $value) { $field = Inflector::tabilize($value); $whrValue = isset($arguments[0][$key]) ? trim($arguments[0][$key]) : ''; if ($type == 'And') { static::$query->select('all')->where($field, '=', $whrValue); } else { static::$query->select('all')->orWhere($field, '=', $whrValue); } } } else { throw new Exception("Arguments doesn't matched with number of fields"); } return static::$query; }
php
public function buildFindersWhereCondition($method, $arguments, $type = 'And') { $condition = []; $condition = explode($type, str_replace('findBy', '', $method)); if (count($condition) == count($arguments[0])) { foreach ($condition as $key => $value) { $field = Inflector::tabilize($value); $whrValue = isset($arguments[0][$key]) ? trim($arguments[0][$key]) : ''; if ($type == 'And') { static::$query->select('all')->where($field, '=', $whrValue); } else { static::$query->select('all')->orWhere($field, '=', $whrValue); } } } else { throw new Exception("Arguments doesn't matched with number of fields"); } return static::$query; }
[ "public", "function", "buildFindersWhereCondition", "(", "$", "method", ",", "$", "arguments", ",", "$", "type", "=", "'And'", ")", "{", "$", "condition", "=", "[", "]", ";", "$", "condition", "=", "explode", "(", "$", "type", ",", "str_replace", "(", "'findBy'", ",", "''", ",", "$", "method", ")", ")", ";", "if", "(", "count", "(", "$", "condition", ")", "==", "count", "(", "$", "arguments", "[", "0", "]", ")", ")", "{", "foreach", "(", "$", "condition", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "field", "=", "Inflector", "::", "tabilize", "(", "$", "value", ")", ";", "$", "whrValue", "=", "isset", "(", "$", "arguments", "[", "0", "]", "[", "$", "key", "]", ")", "?", "trim", "(", "$", "arguments", "[", "0", "]", "[", "$", "key", "]", ")", ":", "''", ";", "if", "(", "$", "type", "==", "'And'", ")", "{", "static", "::", "$", "query", "->", "select", "(", "'all'", ")", "->", "where", "(", "$", "field", ",", "'='", ",", "$", "whrValue", ")", ";", "}", "else", "{", "static", "::", "$", "query", "->", "select", "(", "'all'", ")", "->", "orWhere", "(", "$", "field", ",", "'='", ",", "$", "whrValue", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "Exception", "(", "\"Arguments doesn't matched with number of fields\"", ")", ";", "}", "return", "static", "::", "$", "query", ";", "}" ]
This method is mainly used for building where conditions as array for dynamic finders. @param $method String @param $arguments array @param $type string @throws \Exception @return object
[ "This", "method", "is", "mainly", "used", "for", "building", "where", "conditions", "as", "array", "for", "dynamic", "finders", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1072-L1094
230,550
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.findBySql
public function findBySql($sql) { $results = []; $stmt = $this->resolveConnection()->prepare(trim($sql)); $stmt->execute(); $results = $this->fetchAs($stmt); return new Collection($results); }
php
public function findBySql($sql) { $results = []; $stmt = $this->resolveConnection()->prepare(trim($sql)); $stmt->execute(); $results = $this->fetchAs($stmt); return new Collection($results); }
[ "public", "function", "findBySql", "(", "$", "sql", ")", "{", "$", "results", "=", "[", "]", ";", "$", "stmt", "=", "$", "this", "->", "resolveConnection", "(", ")", "->", "prepare", "(", "trim", "(", "$", "sql", ")", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "$", "results", "=", "$", "this", "->", "fetchAs", "(", "$", "stmt", ")", ";", "return", "new", "Collection", "(", "$", "results", ")", ";", "}" ]
Find result using raw sql query. @param $sql @return Collection
[ "Find", "result", "using", "raw", "sql", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1103-L1111
230,551
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.from
public function from($table) { $this->fromTable = (is_null($table)) ? get_class($this) : $table; return $this; }
php
public function from($table) { $this->fromTable = (is_null($table)) ? get_class($this) : $table; return $this; }
[ "public", "function", "from", "(", "$", "table", ")", "{", "$", "this", "->", "fromTable", "=", "(", "is_null", "(", "$", "table", ")", ")", "?", "get_class", "(", "$", "this", ")", ":", "$", "table", ";", "return", "$", "this", ";", "}" ]
Select from table. Alias method of table. @param $table @return $this
[ "Select", "from", "table", ".", "Alias", "method", "of", "table", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1120-L1125
230,552
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.table
public function table($table) { $ar = static::cyrus(); $ar->setTableName($table); static::$dataSource = true; return $this; }
php
public function table($table) { $ar = static::cyrus(); $ar->setTableName($table); static::$dataSource = true; return $this; }
[ "public", "function", "table", "(", "$", "table", ")", "{", "$", "ar", "=", "static", "::", "cyrus", "(", ")", ";", "$", "ar", "->", "setTableName", "(", "$", "table", ")", ";", "static", "::", "$", "dataSource", "=", "true", ";", "return", "$", "this", ";", "}" ]
Set table to run fluent query without model class. @param $table @return $this
[ "Set", "table", "to", "run", "fluent", "query", "without", "model", "class", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1142-L1149
230,553
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.find
public function find($method, $options = []) { if (isset($options['primaryKey']) && $method == __FUNCTION__) { return $this->select('all') ->where(self::cyrus()->getKeyName(), '=', array_shift($options['args'])) ->orderBy(self::cyrus()->getKeyName(), 'DESC') ->findAll(); } return $this->{$method}($options); }
php
public function find($method, $options = []) { if (isset($options['primaryKey']) && $method == __FUNCTION__) { return $this->select('all') ->where(self::cyrus()->getKeyName(), '=', array_shift($options['args'])) ->orderBy(self::cyrus()->getKeyName(), 'DESC') ->findAll(); } return $this->{$method}($options); }
[ "public", "function", "find", "(", "$", "method", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'primaryKey'", "]", ")", "&&", "$", "method", "==", "__FUNCTION__", ")", "{", "return", "$", "this", "->", "select", "(", "'all'", ")", "->", "where", "(", "self", "::", "cyrus", "(", ")", "->", "getKeyName", "(", ")", ",", "'='", ",", "array_shift", "(", "$", "options", "[", "'args'", "]", ")", ")", "->", "orderBy", "(", "self", "::", "cyrus", "(", ")", "->", "getKeyName", "(", ")", ",", "'DESC'", ")", "->", "findAll", "(", ")", ";", "}", "return", "$", "this", "->", "{", "$", "method", "}", "(", "$", "options", ")", ";", "}" ]
Find a single row. @param $method @param array $options @return mixed
[ "Find", "a", "single", "row", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1172-L1182
230,554
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.triggerEvent
protected function triggerEvent($event) { $instance = static::cyrus(); if (method_exists($instance, $event) && in_array($event, $instance->getModelEvents()) ) { $instance->{$event}($instance); } }
php
protected function triggerEvent($event) { $instance = static::cyrus(); if (method_exists($instance, $event) && in_array($event, $instance->getModelEvents()) ) { $instance->{$event}($instance); } }
[ "protected", "function", "triggerEvent", "(", "$", "event", ")", "{", "$", "instance", "=", "static", "::", "cyrus", "(", ")", ";", "if", "(", "method_exists", "(", "$", "instance", ",", "$", "event", ")", "&&", "in_array", "(", "$", "event", ",", "$", "instance", "->", "getModelEvents", "(", ")", ")", ")", "{", "$", "instance", "->", "{", "$", "event", "}", "(", "$", "instance", ")", ";", "}", "}" ]
We will trigger event. @param $event
[ "We", "will", "trigger", "event", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1226-L1235
230,555
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.getInsertQuery
private function getInsertQuery($function, $ar, $arguments) { $keys = array_keys($arguments); return $function.' INTO `'.$ar->getDatabase().'`.`'.$ar->getTableName(). '` ('.implode(', ', $keys).')'. ' VALUES(:'.implode(', :', $keys).')'; }
php
private function getInsertQuery($function, $ar, $arguments) { $keys = array_keys($arguments); return $function.' INTO `'.$ar->getDatabase().'`.`'.$ar->getTableName(). '` ('.implode(', ', $keys).')'. ' VALUES(:'.implode(', :', $keys).')'; }
[ "private", "function", "getInsertQuery", "(", "$", "function", ",", "$", "ar", ",", "$", "arguments", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "arguments", ")", ";", "return", "$", "function", ".", "' INTO `'", ".", "$", "ar", "->", "getDatabase", "(", ")", ".", "'`.`'", ".", "$", "ar", "->", "getTableName", "(", ")", ".", "'` ('", ".", "implode", "(", "', '", ",", "$", "keys", ")", ".", "')'", ".", "' VALUES(:'", ".", "implode", "(", "', :'", ",", "$", "keys", ")", ".", "')'", ";", "}" ]
Get insert sql statement. @param $function @param $ar @param $arguments @return string
[ "Get", "insert", "sql", "statement", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1246-L1253
230,556
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.getUpdateQuery
private function getUpdateQuery($data, $function) { $ar = static::cyrus(); $data = (empty($data)) ? $ar->getAttributes() : $data; /* | we will unset primary key from given array | This will avoid sql error (SQLSTATE[HY000]: General error: 2031) */ unset($data[$ar->getKeyName()]); $sql = ''; foreach ($data as $key => $value) { $sql .= "$key = :$key,"; } $sql = rtrim($sql, ','); return $function.' `'.$ar->getDatabase().'`.`'.$ar->getTableName().'` SET '.' '.$sql; }
php
private function getUpdateQuery($data, $function) { $ar = static::cyrus(); $data = (empty($data)) ? $ar->getAttributes() : $data; /* | we will unset primary key from given array | This will avoid sql error (SQLSTATE[HY000]: General error: 2031) */ unset($data[$ar->getKeyName()]); $sql = ''; foreach ($data as $key => $value) { $sql .= "$key = :$key,"; } $sql = rtrim($sql, ','); return $function.' `'.$ar->getDatabase().'`.`'.$ar->getTableName().'` SET '.' '.$sql; }
[ "private", "function", "getUpdateQuery", "(", "$", "data", ",", "$", "function", ")", "{", "$", "ar", "=", "static", "::", "cyrus", "(", ")", ";", "$", "data", "=", "(", "empty", "(", "$", "data", ")", ")", "?", "$", "ar", "->", "getAttributes", "(", ")", ":", "$", "data", ";", "/*\n | we will unset primary key from given array\n | This will avoid sql error (SQLSTATE[HY000]: General error: 2031)\n */", "unset", "(", "$", "data", "[", "$", "ar", "->", "getKeyName", "(", ")", "]", ")", ";", "$", "sql", "=", "''", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "sql", ".=", "\"$key = :$key,\"", ";", "}", "$", "sql", "=", "rtrim", "(", "$", "sql", ",", "','", ")", ";", "return", "$", "function", ".", "' `'", ".", "$", "ar", "->", "getDatabase", "(", ")", ".", "'`.`'", ".", "$", "ar", "->", "getTableName", "(", ")", ".", "'` SET '", ".", "' '", ".", "$", "sql", ";", "}" ]
Get update sql statement. @param $data @param $function @return string
[ "Get", "update", "sql", "statement", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1263-L1281
230,557
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.bindParam
private function bindParam($stmt) { // Bind parameters for ($i = 1; $i <= count($this->bindings); $i++) { $stmt->bindParam($i, $this->bindings[$i - 1]); } }
php
private function bindParam($stmt) { // Bind parameters for ($i = 1; $i <= count($this->bindings); $i++) { $stmt->bindParam($i, $this->bindings[$i - 1]); } }
[ "private", "function", "bindParam", "(", "$", "stmt", ")", "{", "// Bind parameters", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "count", "(", "$", "this", "->", "bindings", ")", ";", "$", "i", "++", ")", "{", "$", "stmt", "->", "bindParam", "(", "$", "i", ",", "$", "this", "->", "bindings", "[", "$", "i", "-", "1", "]", ")", ";", "}", "}" ]
We will bind Parameters to execute queries. @param $stmt
[ "We", "will", "bind", "Parameters", "to", "execute", "queries", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1288-L1294
230,558
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.createPlaceHolder
private function createPlaceHolder($arguments) { foreach (array_keys($arguments) as $key) { $placeholder[] = substr(str_repeat('?,', count($key)), 0, -1); } return implode(',', $placeholder); }
php
private function createPlaceHolder($arguments) { foreach (array_keys($arguments) as $key) { $placeholder[] = substr(str_repeat('?,', count($key)), 0, -1); } return implode(',', $placeholder); }
[ "private", "function", "createPlaceHolder", "(", "$", "arguments", ")", "{", "foreach", "(", "array_keys", "(", "$", "arguments", ")", "as", "$", "key", ")", "{", "$", "placeholder", "[", "]", "=", "substr", "(", "str_repeat", "(", "'?,'", ",", "count", "(", "$", "key", ")", ")", ",", "0", ",", "-", "1", ")", ";", "}", "return", "implode", "(", "','", ",", "$", "placeholder", ")", ";", "}" ]
Create placeholders for arguments. @param $arguments @return string
[ "Create", "placeholders", "for", "arguments", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1311-L1318
230,559
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.prepareExceptColumns
private function prepareExceptColumns() { $ar = self::cyrus(); if (!method_exists($ar, 'skip')) { return; } // we will get the table schema $select = Schema::make($this, function ($table) use ($ar) { $table->database = $ar->getDatabase(); $table->tableName = $ar->getTableName(); return $table->getColumns(); }); $columns = $this->sql($select->getSchemaPreparedQuery())->getAll(); // Get all column name which need to remove from the result set $exceptColumns = $ar->skip(); $columnArray = []; foreach ($columns as $key => $value) { if (!in_array($value->COLUMN_NAME, $exceptColumns)) { $columnArray[] = $value->COLUMN_NAME; } } $this->selectColumns = (string) implode(',', $columnArray); }
php
private function prepareExceptColumns() { $ar = self::cyrus(); if (!method_exists($ar, 'skip')) { return; } // we will get the table schema $select = Schema::make($this, function ($table) use ($ar) { $table->database = $ar->getDatabase(); $table->tableName = $ar->getTableName(); return $table->getColumns(); }); $columns = $this->sql($select->getSchemaPreparedQuery())->getAll(); // Get all column name which need to remove from the result set $exceptColumns = $ar->skip(); $columnArray = []; foreach ($columns as $key => $value) { if (!in_array($value->COLUMN_NAME, $exceptColumns)) { $columnArray[] = $value->COLUMN_NAME; } } $this->selectColumns = (string) implode(',', $columnArray); }
[ "private", "function", "prepareExceptColumns", "(", ")", "{", "$", "ar", "=", "self", "::", "cyrus", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "ar", ",", "'skip'", ")", ")", "{", "return", ";", "}", "// we will get the table schema", "$", "select", "=", "Schema", "::", "make", "(", "$", "this", ",", "function", "(", "$", "table", ")", "use", "(", "$", "ar", ")", "{", "$", "table", "->", "database", "=", "$", "ar", "->", "getDatabase", "(", ")", ";", "$", "table", "->", "tableName", "=", "$", "ar", "->", "getTableName", "(", ")", ";", "return", "$", "table", "->", "getColumns", "(", ")", ";", "}", ")", ";", "$", "columns", "=", "$", "this", "->", "sql", "(", "$", "select", "->", "getSchemaPreparedQuery", "(", ")", ")", "->", "getAll", "(", ")", ";", "// Get all column name which need to remove from the result set", "$", "exceptColumns", "=", "$", "ar", "->", "skip", "(", ")", ";", "$", "columnArray", "=", "[", "]", ";", "foreach", "(", "$", "columns", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "value", "->", "COLUMN_NAME", ",", "$", "exceptColumns", ")", ")", "{", "$", "columnArray", "[", "]", "=", "$", "value", "->", "COLUMN_NAME", ";", "}", "}", "$", "this", "->", "selectColumns", "=", "(", "string", ")", "implode", "(", "','", ",", "$", "columnArray", ")", ";", "}" ]
we will prepare query except columns given in model and assign it to selectColumns to find the results.
[ "we", "will", "prepare", "query", "except", "columns", "given", "in", "model", "and", "assign", "it", "to", "selectColumns", "to", "find", "the", "results", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1358-L1387
230,560
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.buildOriginalQuery
private function buildOriginalQuery() { return 'SELECT '.$this->buildSelectedColumns().' FROM '.$this->quoteIdentifier( self::cyrus()->getTableName() ).' '.$this->getWhere(). ' '.$this->getGroupBy().' '.$this->buildHavingConditions().' '.$this->getOrderBy().' '.$this->getLimit(); }
php
private function buildOriginalQuery() { return 'SELECT '.$this->buildSelectedColumns().' FROM '.$this->quoteIdentifier( self::cyrus()->getTableName() ).' '.$this->getWhere(). ' '.$this->getGroupBy().' '.$this->buildHavingConditions().' '.$this->getOrderBy().' '.$this->getLimit(); }
[ "private", "function", "buildOriginalQuery", "(", ")", "{", "return", "'SELECT '", ".", "$", "this", "->", "buildSelectedColumns", "(", ")", ".", "' FROM '", ".", "$", "this", "->", "quoteIdentifier", "(", "self", "::", "cyrus", "(", ")", "->", "getTableName", "(", ")", ")", ".", "' '", ".", "$", "this", "->", "getWhere", "(", ")", ".", "' '", ".", "$", "this", "->", "getGroupBy", "(", ")", ".", "' '", ".", "$", "this", "->", "buildHavingConditions", "(", ")", ".", "' '", ".", "$", "this", "->", "getOrderBy", "(", ")", ".", "' '", ".", "$", "this", "->", "getLimit", "(", ")", ";", "}" ]
We can use this method to debug query which executed last. @return string
[ "We", "can", "use", "this", "method", "to", "debug", "query", "which", "executed", "last", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1411-L1418
230,561
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.all
public function all($arguments) { if (isset($arguments[0]['orderBy'])) { $exp = []; $exp = explode(' ', $arguments[0]['orderBy']); $this->orderBy($this->quoteIdentifier($exp[0]), (isset($exp[1])) ? strtoupper($exp[1]) : 'ASC'); } else { $this->orderBy(self::cyrus()->getKeyName()); } // applying limit if (isset($arguments[0]['limit'])) { $start = '0'; $offset = $arguments[0]['limit']; if (strpos($arguments[0]['limit'], ',') == true) { list($start, $offset) = explode(',', $arguments[0]['limit']); } $this->limit($start, $offset); } // applying pagination limit if (isset($arguments[0]['paginate']) || method_exists(self::cyrus(), 'pageLimit')) { $page = $offset = $start = ''; $offset = self::cyrus()->perPage; //how many items to show per page $limit = !isset($arguments[0]['paginate']['limit']) ? self::cyrus()->pageLimit() : $arguments[0]['paginate']['limit']; $page = ($limit !== '') ? $limit : 0; if ($page) { $start = ($page - 1) * $offset; //first item to display on this page } else { $start = 0; //if no page var is given, set start to 0 } $this->limit(intval($start), intval($offset)); } // applying group by if (isset($arguments[0]['groupBy'])) { $this->groupBy(explode(',', $arguments[0]['groupBy'])); } return $this->select('all')->findAll(); }
php
public function all($arguments) { if (isset($arguments[0]['orderBy'])) { $exp = []; $exp = explode(' ', $arguments[0]['orderBy']); $this->orderBy($this->quoteIdentifier($exp[0]), (isset($exp[1])) ? strtoupper($exp[1]) : 'ASC'); } else { $this->orderBy(self::cyrus()->getKeyName()); } // applying limit if (isset($arguments[0]['limit'])) { $start = '0'; $offset = $arguments[0]['limit']; if (strpos($arguments[0]['limit'], ',') == true) { list($start, $offset) = explode(',', $arguments[0]['limit']); } $this->limit($start, $offset); } // applying pagination limit if (isset($arguments[0]['paginate']) || method_exists(self::cyrus(), 'pageLimit')) { $page = $offset = $start = ''; $offset = self::cyrus()->perPage; //how many items to show per page $limit = !isset($arguments[0]['paginate']['limit']) ? self::cyrus()->pageLimit() : $arguments[0]['paginate']['limit']; $page = ($limit !== '') ? $limit : 0; if ($page) { $start = ($page - 1) * $offset; //first item to display on this page } else { $start = 0; //if no page var is given, set start to 0 } $this->limit(intval($start), intval($offset)); } // applying group by if (isset($arguments[0]['groupBy'])) { $this->groupBy(explode(',', $arguments[0]['groupBy'])); } return $this->select('all')->findAll(); }
[ "public", "function", "all", "(", "$", "arguments", ")", "{", "if", "(", "isset", "(", "$", "arguments", "[", "0", "]", "[", "'orderBy'", "]", ")", ")", "{", "$", "exp", "=", "[", "]", ";", "$", "exp", "=", "explode", "(", "' '", ",", "$", "arguments", "[", "0", "]", "[", "'orderBy'", "]", ")", ";", "$", "this", "->", "orderBy", "(", "$", "this", "->", "quoteIdentifier", "(", "$", "exp", "[", "0", "]", ")", ",", "(", "isset", "(", "$", "exp", "[", "1", "]", ")", ")", "?", "strtoupper", "(", "$", "exp", "[", "1", "]", ")", ":", "'ASC'", ")", ";", "}", "else", "{", "$", "this", "->", "orderBy", "(", "self", "::", "cyrus", "(", ")", "->", "getKeyName", "(", ")", ")", ";", "}", "// applying limit", "if", "(", "isset", "(", "$", "arguments", "[", "0", "]", "[", "'limit'", "]", ")", ")", "{", "$", "start", "=", "'0'", ";", "$", "offset", "=", "$", "arguments", "[", "0", "]", "[", "'limit'", "]", ";", "if", "(", "strpos", "(", "$", "arguments", "[", "0", "]", "[", "'limit'", "]", ",", "','", ")", "==", "true", ")", "{", "list", "(", "$", "start", ",", "$", "offset", ")", "=", "explode", "(", "','", ",", "$", "arguments", "[", "0", "]", "[", "'limit'", "]", ")", ";", "}", "$", "this", "->", "limit", "(", "$", "start", ",", "$", "offset", ")", ";", "}", "// applying pagination limit", "if", "(", "isset", "(", "$", "arguments", "[", "0", "]", "[", "'paginate'", "]", ")", "||", "method_exists", "(", "self", "::", "cyrus", "(", ")", ",", "'pageLimit'", ")", ")", "{", "$", "page", "=", "$", "offset", "=", "$", "start", "=", "''", ";", "$", "offset", "=", "self", "::", "cyrus", "(", ")", "->", "perPage", ";", "//how many items to show per page", "$", "limit", "=", "!", "isset", "(", "$", "arguments", "[", "0", "]", "[", "'paginate'", "]", "[", "'limit'", "]", ")", "?", "self", "::", "cyrus", "(", ")", "->", "pageLimit", "(", ")", ":", "$", "arguments", "[", "0", "]", "[", "'paginate'", "]", "[", "'limit'", "]", ";", "$", "page", "=", "(", "$", "limit", "!==", "''", ")", "?", "$", "limit", ":", "0", ";", "if", "(", "$", "page", ")", "{", "$", "start", "=", "(", "$", "page", "-", "1", ")", "*", "$", "offset", ";", "//first item to display on this page", "}", "else", "{", "$", "start", "=", "0", ";", "//if no page var is given, set start to 0", "}", "$", "this", "->", "limit", "(", "intval", "(", "$", "start", ")", ",", "intval", "(", "$", "offset", ")", ")", ";", "}", "// applying group by", "if", "(", "isset", "(", "$", "arguments", "[", "0", "]", "[", "'groupBy'", "]", ")", ")", "{", "$", "this", "->", "groupBy", "(", "explode", "(", "','", ",", "$", "arguments", "[", "0", "]", "[", "'groupBy'", "]", ")", ")", ";", "}", "return", "$", "this", "->", "select", "(", "'all'", ")", "->", "findAll", "(", ")", ";", "}" ]
Find all values from the database table. @param $arguments @return mixed
[ "Find", "all", "values", "from", "the", "database", "table", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1482-L1528
230,562
cygnite/framework
src/Cygnite/Database/Query/Builder.php
Builder.findFirstOrLast
private function findFirstOrLast($order = null) { $orderBy = (!is_null($order)) ? $order : 'ASC'; $fetchObject = $this->select('all') ->orderBy(self::cyrus()->getKeyName(), $orderBy) ->limit(1) ->findAll(); if ($fetchObject == null) { return self::cyrus()->returnEmptyObject(); } return $fetchObject; }
php
private function findFirstOrLast($order = null) { $orderBy = (!is_null($order)) ? $order : 'ASC'; $fetchObject = $this->select('all') ->orderBy(self::cyrus()->getKeyName(), $orderBy) ->limit(1) ->findAll(); if ($fetchObject == null) { return self::cyrus()->returnEmptyObject(); } return $fetchObject; }
[ "private", "function", "findFirstOrLast", "(", "$", "order", "=", "null", ")", "{", "$", "orderBy", "=", "(", "!", "is_null", "(", "$", "order", ")", ")", "?", "$", "order", ":", "'ASC'", ";", "$", "fetchObject", "=", "$", "this", "->", "select", "(", "'all'", ")", "->", "orderBy", "(", "self", "::", "cyrus", "(", ")", "->", "getKeyName", "(", ")", ",", "$", "orderBy", ")", "->", "limit", "(", "1", ")", "->", "findAll", "(", ")", ";", "if", "(", "$", "fetchObject", "==", "null", ")", "{", "return", "self", "::", "cyrus", "(", ")", "->", "returnEmptyObject", "(", ")", ";", "}", "return", "$", "fetchObject", ";", "}" ]
Method to find first oof last row of the table. @param null $order @return mixed
[ "Method", "to", "find", "first", "oof", "last", "row", "of", "the", "table", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Builder.php#L1547-L1561
230,563
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.isExternal
public function isExternal($flag = false) { $this->external = true; if ($flag) { $this->baseUrl = ''; } return $this; }
php
public function isExternal($flag = false) { $this->external = true; if ($flag) { $this->baseUrl = ''; } return $this; }
[ "public", "function", "isExternal", "(", "$", "flag", "=", "false", ")", "{", "$", "this", "->", "external", "=", "true", ";", "if", "(", "$", "flag", ")", "{", "$", "this", "->", "baseUrl", "=", "''", ";", "}", "return", "$", "this", ";", "}" ]
We will check if external true, if so then we will set the base url as empty so that user can give his own path to load assets. @param bool $flag @return $this
[ "We", "will", "check", "if", "external", "true", "if", "so", "then", "we", "will", "set", "the", "base", "url", "as", "empty", "so", "that", "user", "can", "give", "his", "own", "path", "to", "load", "assets", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L85-L94
230,564
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.dump
public function dump($name) { // Check {style.final} and display only combined asset into browser if ( $this->combine && string_has($name, '.') && isset($this->combinedAssets[$this->tag[$this->where]][$name]) ) { $this->render($this->combinedAssets[$this->tag[$this->where]][$name]); } else { if (isset($this->assets[$this->tag[$this->where]][$name])) { $this->render($this->assets[$this->tag[$this->where]][$name]); } } }
php
public function dump($name) { // Check {style.final} and display only combined asset into browser if ( $this->combine && string_has($name, '.') && isset($this->combinedAssets[$this->tag[$this->where]][$name]) ) { $this->render($this->combinedAssets[$this->tag[$this->where]][$name]); } else { if (isset($this->assets[$this->tag[$this->where]][$name])) { $this->render($this->assets[$this->tag[$this->where]][$name]); } } }
[ "public", "function", "dump", "(", "$", "name", ")", "{", "// Check {style.final} and display only combined asset into browser", "if", "(", "$", "this", "->", "combine", "&&", "string_has", "(", "$", "name", ",", "'.'", ")", "&&", "isset", "(", "$", "this", "->", "combinedAssets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "render", "(", "$", "this", "->", "combinedAssets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "$", "name", "]", ")", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "this", "->", "assets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "render", "(", "$", "this", "->", "assets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "$", "name", "]", ")", ";", "}", "}", "}" ]
We will render all assets into browser. @param $name @return void
[ "We", "will", "render", "all", "assets", "into", "browser", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L156-L169
230,565
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.render
private function render($data) { foreach ($data as $key => $asset) { echo $this->stripCarriage($asset).PHP_EOL; } }
php
private function render($data) { foreach ($data as $key => $asset) { echo $this->stripCarriage($asset).PHP_EOL; } }
[ "private", "function", "render", "(", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "asset", ")", "{", "echo", "$", "this", "->", "stripCarriage", "(", "$", "asset", ")", ".", "PHP_EOL", ";", "}", "}" ]
Render assets into browser. @param $data
[ "Render", "assets", "into", "browser", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L176-L181
230,566
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.combine
public function combine($name, $path, $file, $compress = false) { $this->combine = true; if (file_exists($this->container->get('root').DS.$path.$file)) { $cssAsset = file_get_contents($this->container->get('root').DS.$path.$file); if (string_has($cssAsset, '@generator')) { return $this; } } $filePointer = fopen($this->container->get('root').DS.$path.$file, 'w') or die('Please set folder '.$this->container->get('root').DS.$path.$file.' permission to 777.'); $content = " /**\n | Import All CSS Assets here \n | @generator Cygnite AssetManager\n */\n\n"; foreach ($this->paths[$this->tag[$this->where]][$name] as $key => $src) { if ($name == 'style') { $content .= $this->combineStylesheets($src, $compress); } elseif ($name == 'script') { $content .= $this->combineScripts($src, $compress); } } fwrite($filePointer, $content); $content = ''; fclose($filePointer); $assetName = trim($this->getNameFromPathInfo($file)); $styleTag = ''; $styleTag = static::$stylesheet.' title="'.$file.'" href="'.$this->getBaseUrl( ).$path.$file.'" >'.PHP_EOL; $this->combinedAssets[$this->tag[$this->where]][$name.'.'.$assetName][] = (string) $styleTag; return $this; }
php
public function combine($name, $path, $file, $compress = false) { $this->combine = true; if (file_exists($this->container->get('root').DS.$path.$file)) { $cssAsset = file_get_contents($this->container->get('root').DS.$path.$file); if (string_has($cssAsset, '@generator')) { return $this; } } $filePointer = fopen($this->container->get('root').DS.$path.$file, 'w') or die('Please set folder '.$this->container->get('root').DS.$path.$file.' permission to 777.'); $content = " /**\n | Import All CSS Assets here \n | @generator Cygnite AssetManager\n */\n\n"; foreach ($this->paths[$this->tag[$this->where]][$name] as $key => $src) { if ($name == 'style') { $content .= $this->combineStylesheets($src, $compress); } elseif ($name == 'script') { $content .= $this->combineScripts($src, $compress); } } fwrite($filePointer, $content); $content = ''; fclose($filePointer); $assetName = trim($this->getNameFromPathInfo($file)); $styleTag = ''; $styleTag = static::$stylesheet.' title="'.$file.'" href="'.$this->getBaseUrl( ).$path.$file.'" >'.PHP_EOL; $this->combinedAssets[$this->tag[$this->where]][$name.'.'.$assetName][] = (string) $styleTag; return $this; }
[ "public", "function", "combine", "(", "$", "name", ",", "$", "path", ",", "$", "file", ",", "$", "compress", "=", "false", ")", "{", "$", "this", "->", "combine", "=", "true", ";", "if", "(", "file_exists", "(", "$", "this", "->", "container", "->", "get", "(", "'root'", ")", ".", "DS", ".", "$", "path", ".", "$", "file", ")", ")", "{", "$", "cssAsset", "=", "file_get_contents", "(", "$", "this", "->", "container", "->", "get", "(", "'root'", ")", ".", "DS", ".", "$", "path", ".", "$", "file", ")", ";", "if", "(", "string_has", "(", "$", "cssAsset", ",", "'@generator'", ")", ")", "{", "return", "$", "this", ";", "}", "}", "$", "filePointer", "=", "fopen", "(", "$", "this", "->", "container", "->", "get", "(", "'root'", ")", ".", "DS", ".", "$", "path", ".", "$", "file", ",", "'w'", ")", "or", "die", "(", "'Please set folder '", ".", "$", "this", "->", "container", "->", "get", "(", "'root'", ")", ".", "DS", ".", "$", "path", ".", "$", "file", ".", "' permission to 777.'", ")", ";", "$", "content", "=", "\"\n /**\\n\n | Import All CSS Assets here \\n\n | @generator Cygnite AssetManager\\n\n */\\n\\n\"", ";", "foreach", "(", "$", "this", "->", "paths", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "$", "name", "]", "as", "$", "key", "=>", "$", "src", ")", "{", "if", "(", "$", "name", "==", "'style'", ")", "{", "$", "content", ".=", "$", "this", "->", "combineStylesheets", "(", "$", "src", ",", "$", "compress", ")", ";", "}", "elseif", "(", "$", "name", "==", "'script'", ")", "{", "$", "content", ".=", "$", "this", "->", "combineScripts", "(", "$", "src", ",", "$", "compress", ")", ";", "}", "}", "fwrite", "(", "$", "filePointer", ",", "$", "content", ")", ";", "$", "content", "=", "''", ";", "fclose", "(", "$", "filePointer", ")", ";", "$", "assetName", "=", "trim", "(", "$", "this", "->", "getNameFromPathInfo", "(", "$", "file", ")", ")", ";", "$", "styleTag", "=", "''", ";", "$", "styleTag", "=", "static", "::", "$", "stylesheet", ".", "' title=\"'", ".", "$", "file", ".", "'\" href=\"'", ".", "$", "this", "->", "getBaseUrl", "(", ")", ".", "$", "path", ".", "$", "file", ".", "'\" >'", ".", "PHP_EOL", ";", "$", "this", "->", "combinedAssets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "$", "name", ".", "'.'", ".", "$", "assetName", "]", "[", "]", "=", "(", "string", ")", "$", "styleTag", ";", "return", "$", "this", ";", "}" ]
We will combine all assets tagged to the given key and make a final file which will contain all asset source. $asset->add('style', array('path' => '')) ->add('style', array('path' => '')) ->combine('style', 'final_css', 'assets/css/final.css'); @param $name @param $path @param $file @param bool $compress @return $this
[ "We", "will", "combine", "all", "assets", "tagged", "to", "the", "given", "key", "and", "make", "a", "final", "file", "which", "will", "contain", "all", "asset", "source", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L207-L247
230,567
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.style
public function style($href, $media = '', $title = '') { $media = (is_null($media)) ? 'media=all' : $media; $title = (!is_null($title)) ? 'title= "'.$title.'"' : ''; $this->setLocation($href, strtolower(__FUNCTION__)); if (is_null($href)) { throw new InvalidArgumentException('Style path cannot be null.'); } // Check if we regular expression exists if ($this->hasRegExp($href)) { //We will include all style sheets from the given directory $this->loadAssetsFromDir($href, $media, $title, 'style'); return $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)]; } $styleTag = ''; $styleTag = static::$stylesheet.' '.$media.' '.$title.' href="'.$this->getBaseUrl().$href.'" />'.PHP_EOL; if (isset($media) && $media == 'static') { return trim($styleTag); } $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)][] = trim((string) $styleTag); return $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)]; }
php
public function style($href, $media = '', $title = '') { $media = (is_null($media)) ? 'media=all' : $media; $title = (!is_null($title)) ? 'title= "'.$title.'"' : ''; $this->setLocation($href, strtolower(__FUNCTION__)); if (is_null($href)) { throw new InvalidArgumentException('Style path cannot be null.'); } // Check if we regular expression exists if ($this->hasRegExp($href)) { //We will include all style sheets from the given directory $this->loadAssetsFromDir($href, $media, $title, 'style'); return $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)]; } $styleTag = ''; $styleTag = static::$stylesheet.' '.$media.' '.$title.' href="'.$this->getBaseUrl().$href.'" />'.PHP_EOL; if (isset($media) && $media == 'static') { return trim($styleTag); } $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)][] = trim((string) $styleTag); return $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)]; }
[ "public", "function", "style", "(", "$", "href", ",", "$", "media", "=", "''", ",", "$", "title", "=", "''", ")", "{", "$", "media", "=", "(", "is_null", "(", "$", "media", ")", ")", "?", "'media=all'", ":", "$", "media", ";", "$", "title", "=", "(", "!", "is_null", "(", "$", "title", ")", ")", "?", "'title= \"'", ".", "$", "title", ".", "'\"'", ":", "''", ";", "$", "this", "->", "setLocation", "(", "$", "href", ",", "strtolower", "(", "__FUNCTION__", ")", ")", ";", "if", "(", "is_null", "(", "$", "href", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Style path cannot be null.'", ")", ";", "}", "// Check if we regular expression exists", "if", "(", "$", "this", "->", "hasRegExp", "(", "$", "href", ")", ")", "{", "//We will include all style sheets from the given directory", "$", "this", "->", "loadAssetsFromDir", "(", "$", "href", ",", "$", "media", ",", "$", "title", ",", "'style'", ")", ";", "return", "$", "this", "->", "assets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "strtolower", "(", "__FUNCTION__", ")", "]", ";", "}", "$", "styleTag", "=", "''", ";", "$", "styleTag", "=", "static", "::", "$", "stylesheet", ".", "' '", ".", "$", "media", ".", "'\n '", ".", "$", "title", ".", "' href=\"'", ".", "$", "this", "->", "getBaseUrl", "(", ")", ".", "$", "href", ".", "'\" />'", ".", "PHP_EOL", ";", "if", "(", "isset", "(", "$", "media", ")", "&&", "$", "media", "==", "'static'", ")", "{", "return", "trim", "(", "$", "styleTag", ")", ";", "}", "$", "this", "->", "assets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "strtolower", "(", "__FUNCTION__", ")", "]", "[", "]", "=", "trim", "(", "(", "string", ")", "$", "styleTag", ")", ";", "return", "$", "this", "->", "assets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "strtolower", "(", "__FUNCTION__", ")", "]", ";", "}" ]
Generate a link to a stylesheet file. <code> // Generate a link to a stylesheet file Asset::css('css/cygnite.css'); </code> @internal param $href @internal param string $media @internal param string $title @param $href @param $media @param $title @throws \InvalidArgumentException @return string
[ "Generate", "a", "link", "to", "a", "stylesheet", "file", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L489-L519
230,568
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.loadAssetsFromDir
private function loadAssetsFromDir($href, $attr, $title, $type = 'style') { $path = str_replace('\\', '/', $href); $assets = glob($path.'*'); foreach ($assets as $src) { ($type == 'style') ? $this->setStyle($attr, $src, $title) : $this->setScript($src, $attr); } }
php
private function loadAssetsFromDir($href, $attr, $title, $type = 'style') { $path = str_replace('\\', '/', $href); $assets = glob($path.'*'); foreach ($assets as $src) { ($type == 'style') ? $this->setStyle($attr, $src, $title) : $this->setScript($src, $attr); } }
[ "private", "function", "loadAssetsFromDir", "(", "$", "href", ",", "$", "attr", ",", "$", "title", ",", "$", "type", "=", "'style'", ")", "{", "$", "path", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "href", ")", ";", "$", "assets", "=", "glob", "(", "$", "path", ".", "'*'", ")", ";", "foreach", "(", "$", "assets", "as", "$", "src", ")", "{", "(", "$", "type", "==", "'style'", ")", "?", "$", "this", "->", "setStyle", "(", "$", "attr", ",", "$", "src", ",", "$", "title", ")", ":", "$", "this", "->", "setScript", "(", "$", "src", ",", "$", "attr", ")", ";", "}", "}" ]
Include all the stylesheets from the path. @param $href @param $attr @param $title @param string $type @return void
[ "Include", "all", "the", "stylesheets", "from", "the", "path", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L554-L562
230,569
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.setStyle
private function setStyle($media, $style, $title) { $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)][] = (string) static::$stylesheet.' '.$media.' '.$title.' href="'.$this->getBaseUrl().$style.'" >'.PHP_EOL; }
php
private function setStyle($media, $style, $title) { $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)][] = (string) static::$stylesheet.' '.$media.' '.$title.' href="'.$this->getBaseUrl().$style.'" >'.PHP_EOL; }
[ "private", "function", "setStyle", "(", "$", "media", ",", "$", "style", ",", "$", "title", ")", "{", "$", "this", "->", "assets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "strtolower", "(", "__FUNCTION__", ")", "]", "[", "]", "=", "(", "string", ")", "static", "::", "$", "stylesheet", ".", "' '", ".", "$", "media", ".", "'\n '", ".", "$", "title", ".", "' href=\"'", ".", "$", "this", "->", "getBaseUrl", "(", ")", ".", "$", "style", ".", "'\" >'", ".", "PHP_EOL", ";", "}" ]
We will set the styles into assets array. @param $media @param $style @param $title @return void
[ "We", "will", "set", "the", "styles", "into", "assets", "array", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L573-L578
230,570
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.getBaseUrl
public function getBaseUrl() { if ($this->external == false) { return $this->baseUrl = Url::getBase(); } return $this->baseUrl; }
php
public function getBaseUrl() { if ($this->external == false) { return $this->baseUrl = Url::getBase(); } return $this->baseUrl; }
[ "public", "function", "getBaseUrl", "(", ")", "{", "if", "(", "$", "this", "->", "external", "==", "false", ")", "{", "return", "$", "this", "->", "baseUrl", "=", "Url", "::", "getBase", "(", ")", ";", "}", "return", "$", "this", "->", "baseUrl", ";", "}" ]
get the base url.
[ "get", "the", "base", "url", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L583-L590
230,571
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.setScript
private function setScript($src, $attributes) { $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)][] = (string) static::$script.' src="'.Url::getBase().$src.'"'.$this->addAttributes($attributes).'></script>'.PHP_EOL; }
php
private function setScript($src, $attributes) { $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)][] = (string) static::$script.' src="'.Url::getBase().$src.'"'.$this->addAttributes($attributes).'></script>'.PHP_EOL; }
[ "private", "function", "setScript", "(", "$", "src", ",", "$", "attributes", ")", "{", "$", "this", "->", "assets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "strtolower", "(", "__FUNCTION__", ")", "]", "[", "]", "=", "(", "string", ")", "static", "::", "$", "script", ".", "'\n src=\"'", ".", "Url", "::", "getBase", "(", ")", ".", "$", "src", ".", "'\"'", ".", "$", "this", "->", "addAttributes", "(", "$", "attributes", ")", ".", "'></script>'", ".", "PHP_EOL", ";", "}" ]
We will set the script into assets array. @param $src @param $attributes
[ "We", "will", "set", "the", "script", "into", "assets", "array", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L598-L603
230,572
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.addAttributes
public function addAttributes($attributes, $html = []) { if (!empty($attributes)) { foreach ($attributes as $key => $value) { if (!is_null($value)) { $html[] = $key.'="'.Html::entities($value).'"'; } } } return (count($html) > 0) ? ' '.implode(' ', $html) : ''; }
php
public function addAttributes($attributes, $html = []) { if (!empty($attributes)) { foreach ($attributes as $key => $value) { if (!is_null($value)) { $html[] = $key.'="'.Html::entities($value).'"'; } } } return (count($html) > 0) ? ' '.implode(' ', $html) : ''; }
[ "public", "function", "addAttributes", "(", "$", "attributes", ",", "$", "html", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "attributes", ")", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "html", "[", "]", "=", "$", "key", ".", "'=\"'", ".", "Html", "::", "entities", "(", "$", "value", ")", ".", "'\"'", ";", "}", "}", "}", "return", "(", "count", "(", "$", "html", ")", ">", "0", ")", "?", "' '", ".", "implode", "(", "' '", ",", "$", "html", ")", ":", "''", ";", "}" ]
Form Html attributes from array. @false array $attributes @param array $attributes @param array $html @return string
[ "Form", "Html", "attributes", "from", "array", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L615-L626
230,573
cygnite/framework
src/Cygnite/AssetManager/Asset.php
Asset.link
public function link($url, $name = null, $attributes = []) { $name = (is_null($name)) ? $url : $name; $this->setLocation($url, strtolower(__FUNCTION__)); $lingTag = ''; $lingTag = '<a href="'.$this->getBaseUrl().Html::entities($url).'" '.$this->addAttributes($attributes).'>'.Html::entities($name).'</a>'.PHP_EOL; /* | If method called statically we will simply return | as string */ if (isset($attributes['type']) && $attributes['type'] == 'static') { return trim($this->stripCarriage($lingTag)); } $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)][] = trim($lingTag); return $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)]; }
php
public function link($url, $name = null, $attributes = []) { $name = (is_null($name)) ? $url : $name; $this->setLocation($url, strtolower(__FUNCTION__)); $lingTag = ''; $lingTag = '<a href="'.$this->getBaseUrl().Html::entities($url).'" '.$this->addAttributes($attributes).'>'.Html::entities($name).'</a>'.PHP_EOL; /* | If method called statically we will simply return | as string */ if (isset($attributes['type']) && $attributes['type'] == 'static') { return trim($this->stripCarriage($lingTag)); } $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)][] = trim($lingTag); return $this->assets[$this->tag[$this->where]][strtolower(__FUNCTION__)]; }
[ "public", "function", "link", "(", "$", "url", ",", "$", "name", "=", "null", ",", "$", "attributes", "=", "[", "]", ")", "{", "$", "name", "=", "(", "is_null", "(", "$", "name", ")", ")", "?", "$", "url", ":", "$", "name", ";", "$", "this", "->", "setLocation", "(", "$", "url", ",", "strtolower", "(", "__FUNCTION__", ")", ")", ";", "$", "lingTag", "=", "''", ";", "$", "lingTag", "=", "'<a href=\"'", ".", "$", "this", "->", "getBaseUrl", "(", ")", ".", "Html", "::", "entities", "(", "$", "url", ")", ".", "'\"\n '", ".", "$", "this", "->", "addAttributes", "(", "$", "attributes", ")", ".", "'>'", ".", "Html", "::", "entities", "(", "$", "name", ")", ".", "'</a>'", ".", "PHP_EOL", ";", "/*\n | If method called statically we will simply return\n | as string\n */", "if", "(", "isset", "(", "$", "attributes", "[", "'type'", "]", ")", "&&", "$", "attributes", "[", "'type'", "]", "==", "'static'", ")", "{", "return", "trim", "(", "$", "this", "->", "stripCarriage", "(", "$", "lingTag", ")", ")", ";", "}", "$", "this", "->", "assets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "strtolower", "(", "__FUNCTION__", ")", "]", "[", "]", "=", "trim", "(", "$", "lingTag", ")", ";", "return", "$", "this", "->", "assets", "[", "$", "this", "->", "tag", "[", "$", "this", "->", "where", "]", "]", "[", "strtolower", "(", "__FUNCTION__", ")", "]", ";", "}" ]
Generate anchor link. @false string $url @false string $name @false array $attributes @param $url @param null $name @param array $attributes @return string
[ "Generate", "anchor", "link", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/Asset.php#L699-L718
230,574
kaliop-uk/ezworkflowenginebundle
ezpublish_legacy/ezworkflowenginebridge/eventtypes/event/ezworkflowenginehook/ezworkflowenginehooktype.php
eZWorkflowEngineHookType.getsignalName
protected function getsignalName( $triggerName, $operationName ) { if ( !isset( self::$signalMapping[$operationName][$triggerName] ) ) { return $triggerName . '_' . $operationName; } return self::$signalMapping[$operationName][$triggerName]; }
php
protected function getsignalName( $triggerName, $operationName ) { if ( !isset( self::$signalMapping[$operationName][$triggerName] ) ) { return $triggerName . '_' . $operationName; } return self::$signalMapping[$operationName][$triggerName]; }
[ "protected", "function", "getsignalName", "(", "$", "triggerName", ",", "$", "operationName", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "signalMapping", "[", "$", "operationName", "]", "[", "$", "triggerName", "]", ")", ")", "{", "return", "$", "triggerName", ".", "'_'", ".", "$", "operationName", ";", "}", "return", "self", "::", "$", "signalMapping", "[", "$", "operationName", "]", "[", "$", "triggerName", "]", ";", "}" ]
Returns the eZ5 Signal known to map to the eZ4 Operation. If mapping is unknown, the eZ4 Operation name is returned @param string $triggerName @param string $operationName @return string mixed
[ "Returns", "the", "eZ5", "Signal", "known", "to", "map", "to", "the", "eZ4", "Operation", ".", "If", "mapping", "is", "unknown", "the", "eZ4", "Operation", "name", "is", "returned" ]
1540eff00b64b6db692ec865c9d25b0179b4b638
https://github.com/kaliop-uk/ezworkflowenginebundle/blob/1540eff00b64b6db692ec865c9d25b0179b4b638/ezpublish_legacy/ezworkflowenginebridge/eventtypes/event/ezworkflowenginehook/ezworkflowenginehooktype.php#L98-L106
230,575
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_method_setdebugtemplate.php
Smarty_Internal_Method_SetDebugTemplate.setDebugTemplate
public function setDebugTemplate(Smarty_Internal_TemplateBase $obj, $tpl_name) { $smarty = isset($obj->smarty) ? $obj->smarty : $obj; if (!is_readable($tpl_name)) { throw new SmartyException("Unknown file '{$tpl_name}'"); } $smarty->debug_tpl = $tpl_name; return $obj; }
php
public function setDebugTemplate(Smarty_Internal_TemplateBase $obj, $tpl_name) { $smarty = isset($obj->smarty) ? $obj->smarty : $obj; if (!is_readable($tpl_name)) { throw new SmartyException("Unknown file '{$tpl_name}'"); } $smarty->debug_tpl = $tpl_name; return $obj; }
[ "public", "function", "setDebugTemplate", "(", "Smarty_Internal_TemplateBase", "$", "obj", ",", "$", "tpl_name", ")", "{", "$", "smarty", "=", "isset", "(", "$", "obj", "->", "smarty", ")", "?", "$", "obj", "->", "smarty", ":", "$", "obj", ";", "if", "(", "!", "is_readable", "(", "$", "tpl_name", ")", ")", "{", "throw", "new", "SmartyException", "(", "\"Unknown file '{$tpl_name}'\"", ")", ";", "}", "$", "smarty", "->", "debug_tpl", "=", "$", "tpl_name", ";", "return", "$", "obj", ";", "}" ]
set the debug template @api Smarty::setDebugTemplate() @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj @param string $tpl_name @return \Smarty|\Smarty_Internal_Template @throws SmartyException if file is not readable
[ "set", "the", "debug", "template" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_method_setdebugtemplate.php#L32-L40
230,576
tapestry-cloud/tapestry
src/Modules/Content/Compile.php
Compile.iterateProjectContentTypes
private function iterateProjectContentTypes(ContentTypeFactory $contentTypes, Project $project, OutputInterface $output) { /** @var ContentType $contentType */ foreach ($contentTypes->all() as $contentType) { $output->writeln('[+] Compiling content within ['.$contentType->getName().']'); $project->set('compiled', $this->files); // Foreach ContentType look up their Files and run the particular Renderer on their $content before updating // the Project File. foreach (array_keys($contentType->getFileList()) as $fileKey) { /** @var File $file */ if (! $file = $project->get('files.'.$fileKey)) { continue; } // Pre-compile via use of File Generators if ($file instanceof FileGenerator) { $this->add($file->generate($project)); } else { $this->add($file); } $project->set('compiled', $this->files); } } }
php
private function iterateProjectContentTypes(ContentTypeFactory $contentTypes, Project $project, OutputInterface $output) { /** @var ContentType $contentType */ foreach ($contentTypes->all() as $contentType) { $output->writeln('[+] Compiling content within ['.$contentType->getName().']'); $project->set('compiled', $this->files); // Foreach ContentType look up their Files and run the particular Renderer on their $content before updating // the Project File. foreach (array_keys($contentType->getFileList()) as $fileKey) { /** @var File $file */ if (! $file = $project->get('files.'.$fileKey)) { continue; } // Pre-compile via use of File Generators if ($file instanceof FileGenerator) { $this->add($file->generate($project)); } else { $this->add($file); } $project->set('compiled', $this->files); } } }
[ "private", "function", "iterateProjectContentTypes", "(", "ContentTypeFactory", "$", "contentTypes", ",", "Project", "$", "project", ",", "OutputInterface", "$", "output", ")", "{", "/** @var ContentType $contentType */", "foreach", "(", "$", "contentTypes", "->", "all", "(", ")", "as", "$", "contentType", ")", "{", "$", "output", "->", "writeln", "(", "'[+] Compiling content within ['", ".", "$", "contentType", "->", "getName", "(", ")", ".", "']'", ")", ";", "$", "project", "->", "set", "(", "'compiled'", ",", "$", "this", "->", "files", ")", ";", "// Foreach ContentType look up their Files and run the particular Renderer on their $content before updating", "// the Project File.", "foreach", "(", "array_keys", "(", "$", "contentType", "->", "getFileList", "(", ")", ")", "as", "$", "fileKey", ")", "{", "/** @var File $file */", "if", "(", "!", "$", "file", "=", "$", "project", "->", "get", "(", "'files.'", ".", "$", "fileKey", ")", ")", "{", "continue", ";", "}", "// Pre-compile via use of File Generators", "if", "(", "$", "file", "instanceof", "FileGenerator", ")", "{", "$", "this", "->", "add", "(", "$", "file", "->", "generate", "(", "$", "project", ")", ")", ";", "}", "else", "{", "$", "this", "->", "add", "(", "$", "file", ")", ";", "}", "$", "project", "->", "set", "(", "'compiled'", ",", "$", "this", "->", "files", ")", ";", "}", "}", "}" ]
Iterate over the file list of all content types and add the files they contain to the local compiled file list also at this point run any generators that the file may be linked to. @param ContentTypeFactory $contentTypes @param Project $project @param OutputInterface $output
[ "Iterate", "over", "the", "file", "list", "of", "all", "content", "types", "and", "add", "the", "files", "they", "contain", "to", "the", "local", "compiled", "file", "list", "also", "at", "this", "point", "run", "any", "generators", "that", "the", "file", "may", "be", "linked", "to", "." ]
f3fc980b2484ccbe609a7f811c65b91254e8720e
https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Modules/Content/Compile.php#L131-L155
230,577
tapestry-cloud/tapestry
src/Modules/Content/Compile.php
Compile.collectProjectFilesUseData
private function collectProjectFilesUseData(Project $project) { /** @var File $file */ foreach ($project['compiled'] as $file) { if (! $uses = $file->getData('use')) { continue; } foreach ($uses as $use) { if (! $items = $file->getData($use.'_items')) { continue; } array_walk_recursive($items, function (&$file, $fileKey) use ($project) { /** @var File $compiledFile */ if (! $compiledFile = $project->get('compiled.'.$fileKey)) { $file = null; } else { $file = new ViewFile($project, $compiledFile->getUid()); } }); // Filter out deleted pages, such as drafts $items = array_filter($items, function ($value) { return ! is_null($value); }); $file->setData([$use.'_items' => $items]); } } }
php
private function collectProjectFilesUseData(Project $project) { /** @var File $file */ foreach ($project['compiled'] as $file) { if (! $uses = $file->getData('use')) { continue; } foreach ($uses as $use) { if (! $items = $file->getData($use.'_items')) { continue; } array_walk_recursive($items, function (&$file, $fileKey) use ($project) { /** @var File $compiledFile */ if (! $compiledFile = $project->get('compiled.'.$fileKey)) { $file = null; } else { $file = new ViewFile($project, $compiledFile->getUid()); } }); // Filter out deleted pages, such as drafts $items = array_filter($items, function ($value) { return ! is_null($value); }); $file->setData([$use.'_items' => $items]); } } }
[ "private", "function", "collectProjectFilesUseData", "(", "Project", "$", "project", ")", "{", "/** @var File $file */", "foreach", "(", "$", "project", "[", "'compiled'", "]", "as", "$", "file", ")", "{", "if", "(", "!", "$", "uses", "=", "$", "file", "->", "getData", "(", "'use'", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "uses", "as", "$", "use", ")", "{", "if", "(", "!", "$", "items", "=", "$", "file", "->", "getData", "(", "$", "use", ".", "'_items'", ")", ")", "{", "continue", ";", "}", "array_walk_recursive", "(", "$", "items", ",", "function", "(", "&", "$", "file", ",", "$", "fileKey", ")", "use", "(", "$", "project", ")", "{", "/** @var File $compiledFile */", "if", "(", "!", "$", "compiledFile", "=", "$", "project", "->", "get", "(", "'compiled.'", ".", "$", "fileKey", ")", ")", "{", "$", "file", "=", "null", ";", "}", "else", "{", "$", "file", "=", "new", "ViewFile", "(", "$", "project", ",", "$", "compiledFile", "->", "getUid", "(", ")", ")", ";", "}", "}", ")", ";", "// Filter out deleted pages, such as drafts", "$", "items", "=", "array_filter", "(", "$", "items", ",", "function", "(", "$", "value", ")", "{", "return", "!", "is_null", "(", "$", "value", ")", ";", "}", ")", ";", "$", "file", "->", "setData", "(", "[", "$", "use", ".", "'_items'", "=>", "$", "items", "]", ")", ";", "}", "}", "}" ]
Where a file has a use statement, we now need to collect the associated use data and inject it. @param Project $project
[ "Where", "a", "file", "has", "a", "use", "statement", "we", "now", "need", "to", "collect", "the", "associated", "use", "data", "and", "inject", "it", "." ]
f3fc980b2484ccbe609a7f811c65b91254e8720e
https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Modules/Content/Compile.php#L162-L191
230,578
tapestry-cloud/tapestry
src/Modules/Content/Compile.php
Compile.executeContentRenderers
private function executeContentRenderers(ContentRendererFactory $contentRenderers) { while (! $this->allFilesRendered()) { foreach ($this->files as &$file) { if ($file->isRendered()) { continue; } $contentRenderers->renderFile($file); } unset($file); } }
php
private function executeContentRenderers(ContentRendererFactory $contentRenderers) { while (! $this->allFilesRendered()) { foreach ($this->files as &$file) { if ($file->isRendered()) { continue; } $contentRenderers->renderFile($file); } unset($file); } }
[ "private", "function", "executeContentRenderers", "(", "ContentRendererFactory", "$", "contentRenderers", ")", "{", "while", "(", "!", "$", "this", "->", "allFilesRendered", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "files", "as", "&", "$", "file", ")", "{", "if", "(", "$", "file", "->", "isRendered", "(", ")", ")", "{", "continue", ";", "}", "$", "contentRenderers", "->", "renderFile", "(", "$", "file", ")", ";", "}", "unset", "(", "$", "file", ")", ";", "}", "}" ]
Execute Content Renderers. @param ContentRendererFactory $contentRenderers
[ "Execute", "Content", "Renderers", "." ]
f3fc980b2484ccbe609a7f811c65b91254e8720e
https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Modules/Content/Compile.php#L234-L245
230,579
tapestry-cloud/tapestry
src/Modules/Content/Compile.php
Compile.mutateFilesToFilesystemInterfaces
private function mutateFilesToFilesystemInterfaces(Project $project, Cache $cache) { foreach ($this->files as &$file) { /** @var CachedFile $cachedFile */ if ($cachedFile = $cache->getItem($file->getUid())) { if ($cachedFile->check($file)) { $file = new FileIgnored(clone $file, $project->destinationDirectory); continue; } } if ($file->isToCopy()) { $file = new FileCopier(clone $file, $project->destinationDirectory); } else { $file = new FileWriter(clone $file, $project->destinationDirectory); } } unset($file); }
php
private function mutateFilesToFilesystemInterfaces(Project $project, Cache $cache) { foreach ($this->files as &$file) { /** @var CachedFile $cachedFile */ if ($cachedFile = $cache->getItem($file->getUid())) { if ($cachedFile->check($file)) { $file = new FileIgnored(clone $file, $project->destinationDirectory); continue; } } if ($file->isToCopy()) { $file = new FileCopier(clone $file, $project->destinationDirectory); } else { $file = new FileWriter(clone $file, $project->destinationDirectory); } } unset($file); }
[ "private", "function", "mutateFilesToFilesystemInterfaces", "(", "Project", "$", "project", ",", "Cache", "$", "cache", ")", "{", "foreach", "(", "$", "this", "->", "files", "as", "&", "$", "file", ")", "{", "/** @var CachedFile $cachedFile */", "if", "(", "$", "cachedFile", "=", "$", "cache", "->", "getItem", "(", "$", "file", "->", "getUid", "(", ")", ")", ")", "{", "if", "(", "$", "cachedFile", "->", "check", "(", "$", "file", ")", ")", "{", "$", "file", "=", "new", "FileIgnored", "(", "clone", "$", "file", ",", "$", "project", "->", "destinationDirectory", ")", ";", "continue", ";", "}", "}", "if", "(", "$", "file", "->", "isToCopy", "(", ")", ")", "{", "$", "file", "=", "new", "FileCopier", "(", "clone", "$", "file", ",", "$", "project", "->", "destinationDirectory", ")", ";", "}", "else", "{", "$", "file", "=", "new", "FileWriter", "(", "clone", "$", "file", ",", "$", "project", "->", "destinationDirectory", ")", ";", "}", "}", "unset", "(", "$", "file", ")", ";", "}" ]
Mutate compiled File into FileIgnored, FileCopy or FileWrite entities. @param Project $project @param Cache $cache
[ "Mutate", "compiled", "File", "into", "FileIgnored", "FileCopy", "or", "FileWrite", "entities", "." ]
f3fc980b2484ccbe609a7f811c65b91254e8720e
https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Modules/Content/Compile.php#L253-L271
230,580
cygnite/framework
src/Cygnite/Database/Query/Joins.php
Joins.join
public function join($table, $constraint, $tableAlias = null) { return $this->addJoinSource('', $table, $constraint, $tableAlias); }
php
public function join($table, $constraint, $tableAlias = null) { return $this->addJoinSource('', $table, $constraint, $tableAlias); }
[ "public", "function", "join", "(", "$", "table", ",", "$", "constraint", ",", "$", "tableAlias", "=", "null", ")", "{", "return", "$", "this", "->", "addJoinSource", "(", "''", ",", "$", "table", ",", "$", "constraint", ",", "$", "tableAlias", ")", ";", "}" ]
Add a simple JOIN string to the query. @param $table @param $constraint @param null $tableAlias @return $this
[ "Add", "a", "simple", "JOIN", "string", "to", "the", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Joins.php#L31-L34
230,581
cygnite/framework
src/Cygnite/Database/Query/Joins.php
Joins.leftOuterJoin
public function leftOuterJoin($table, $constraint, $tableAlias = null) { return $this->addJoinSource('LEFT OUTER', $table, $constraint, $tableAlias); }
php
public function leftOuterJoin($table, $constraint, $tableAlias = null) { return $this->addJoinSource('LEFT OUTER', $table, $constraint, $tableAlias); }
[ "public", "function", "leftOuterJoin", "(", "$", "table", ",", "$", "constraint", ",", "$", "tableAlias", "=", "null", ")", "{", "return", "$", "this", "->", "addJoinSource", "(", "'LEFT OUTER'", ",", "$", "table", ",", "$", "constraint", ",", "$", "tableAlias", ")", ";", "}" ]
Add a LEFT OUTER JOIN string to the query. @param $table @param $constraint @param null $tableAlias @return $this
[ "Add", "a", "LEFT", "OUTER", "JOIN", "string", "to", "the", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Joins.php#L73-L76
230,582
cygnite/framework
src/Cygnite/Database/Query/Joins.php
Joins.rightOuterJoin
public function rightOuterJoin($table, $constraint, $tableAlias = null) { return $this->addJoinSource('RIGHT OUTER', $table, $constraint, $tableAlias); }
php
public function rightOuterJoin($table, $constraint, $tableAlias = null) { return $this->addJoinSource('RIGHT OUTER', $table, $constraint, $tableAlias); }
[ "public", "function", "rightOuterJoin", "(", "$", "table", ",", "$", "constraint", ",", "$", "tableAlias", "=", "null", ")", "{", "return", "$", "this", "->", "addJoinSource", "(", "'RIGHT OUTER'", ",", "$", "table", ",", "$", "constraint", ",", "$", "tableAlias", ")", ";", "}" ]
Add an RIGHT OUTER JOIN string to the query. @param $table @param $constraint @param null $tableAlias @return $this
[ "Add", "an", "RIGHT", "OUTER", "JOIN", "string", "to", "the", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Joins.php#L87-L90
230,583
cygnite/framework
src/Cygnite/Database/Query/Joins.php
Joins.fullOuterJoin
public function fullOuterJoin($table, $constraint, $tableAlias = null) { return $this->addJoinSource('FULL OUTER', $table, $constraint, $tableAlias); }
php
public function fullOuterJoin($table, $constraint, $tableAlias = null) { return $this->addJoinSource('FULL OUTER', $table, $constraint, $tableAlias); }
[ "public", "function", "fullOuterJoin", "(", "$", "table", ",", "$", "constraint", ",", "$", "tableAlias", "=", "null", ")", "{", "return", "$", "this", "->", "addJoinSource", "(", "'FULL OUTER'", ",", "$", "table", ",", "$", "constraint", ",", "$", "tableAlias", ")", ";", "}" ]
Add an FULL OUTER JOIN string to the query. @param $table @param $constraint @param null $tableAlias @return $this
[ "Add", "an", "FULL", "OUTER", "JOIN", "string", "to", "the", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Joins.php#L101-L104
230,584
cygnite/framework
src/Cygnite/Database/Query/Joins.php
Joins.addJoinSource
protected function addJoinSource($joinOperator, $table, $constraint, $tableAlias = null) { $joinOperator = trim("{$joinOperator} JOIN"); $table = Inflector::tabilize($this->quoteIdentifier(lcfirst($table))); // Add table alias if exists if (!is_null($tableAlias)) { $table .= " {$tableAlias}"; } // Build the constraint if (is_array($constraint)) { list($firstColumn, $operator, $secondColumn) = $constraint; $constraint = "{$firstColumn} {$operator} {$secondColumn}"; } //$table = Inflector::tabilize(lcfirst($table)); $this->hasJoin = true; $this->joinSources[] = "{$joinOperator} {$table} ON {$constraint}"; return $this; }
php
protected function addJoinSource($joinOperator, $table, $constraint, $tableAlias = null) { $joinOperator = trim("{$joinOperator} JOIN"); $table = Inflector::tabilize($this->quoteIdentifier(lcfirst($table))); // Add table alias if exists if (!is_null($tableAlias)) { $table .= " {$tableAlias}"; } // Build the constraint if (is_array($constraint)) { list($firstColumn, $operator, $secondColumn) = $constraint; $constraint = "{$firstColumn} {$operator} {$secondColumn}"; } //$table = Inflector::tabilize(lcfirst($table)); $this->hasJoin = true; $this->joinSources[] = "{$joinOperator} {$table} ON {$constraint}"; return $this; }
[ "protected", "function", "addJoinSource", "(", "$", "joinOperator", ",", "$", "table", ",", "$", "constraint", ",", "$", "tableAlias", "=", "null", ")", "{", "$", "joinOperator", "=", "trim", "(", "\"{$joinOperator} JOIN\"", ")", ";", "$", "table", "=", "Inflector", "::", "tabilize", "(", "$", "this", "->", "quoteIdentifier", "(", "lcfirst", "(", "$", "table", ")", ")", ")", ";", "// Add table alias if exists", "if", "(", "!", "is_null", "(", "$", "tableAlias", ")", ")", "{", "$", "table", ".=", "\" {$tableAlias}\"", ";", "}", "// Build the constraint", "if", "(", "is_array", "(", "$", "constraint", ")", ")", "{", "list", "(", "$", "firstColumn", ",", "$", "operator", ",", "$", "secondColumn", ")", "=", "$", "constraint", ";", "$", "constraint", "=", "\"{$firstColumn} {$operator} {$secondColumn}\"", ";", "}", "//$table = Inflector::tabilize(lcfirst($table));", "$", "this", "->", "hasJoin", "=", "true", ";", "$", "this", "->", "joinSources", "[", "]", "=", "\"{$joinOperator} {$table} ON {$constraint}\"", ";", "return", "$", "this", ";", "}" ]
Query Internal method to add a JOIN string to the query. The join operators can be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN. firstColumn, operator, secondColumn Example: ['user.id', '=', 'profile.user_id'] will compile to ON `user`.`id` = `profile`.`user_id` The final (optional) argument specifies an alias for the joined table. @param $joinOperator @param $table @param $constraint @param null $tableAlias @return $this
[ "Query", "Internal", "method", "to", "add", "a", "JOIN", "string", "to", "the", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Joins.php#L129-L150
230,585
cygnite/framework
src/Cygnite/Database/Query/Joins.php
Joins.rawJoin
public function rawJoin($query, $constraint, $tableAlias) { $this->hasJoin = true; // Add table alias if present if (!is_null($tableAlias)) { $tableAlias = $this->quoteIdentifier($tableAlias); $query .= " {$tableAlias}"; } // Build the constraint if (is_array($constraint)) { list($firstColumn, $operator, $secondColumn) = $constraint; $firstColumn = $this->quoteIdentifier($firstColumn); $secondColumn = $this->quoteIdentifier($secondColumn); $constraint = "{$firstColumn} {$operator} {$secondColumn}"; } $this->joinSources[] = "{$query} ON {$constraint}"; return $this; }
php
public function rawJoin($query, $constraint, $tableAlias) { $this->hasJoin = true; // Add table alias if present if (!is_null($tableAlias)) { $tableAlias = $this->quoteIdentifier($tableAlias); $query .= " {$tableAlias}"; } // Build the constraint if (is_array($constraint)) { list($firstColumn, $operator, $secondColumn) = $constraint; $firstColumn = $this->quoteIdentifier($firstColumn); $secondColumn = $this->quoteIdentifier($secondColumn); $constraint = "{$firstColumn} {$operator} {$secondColumn}"; } $this->joinSources[] = "{$query} ON {$constraint}"; return $this; }
[ "public", "function", "rawJoin", "(", "$", "query", ",", "$", "constraint", ",", "$", "tableAlias", ")", "{", "$", "this", "->", "hasJoin", "=", "true", ";", "// Add table alias if present", "if", "(", "!", "is_null", "(", "$", "tableAlias", ")", ")", "{", "$", "tableAlias", "=", "$", "this", "->", "quoteIdentifier", "(", "$", "tableAlias", ")", ";", "$", "query", ".=", "\" {$tableAlias}\"", ";", "}", "// Build the constraint", "if", "(", "is_array", "(", "$", "constraint", ")", ")", "{", "list", "(", "$", "firstColumn", ",", "$", "operator", ",", "$", "secondColumn", ")", "=", "$", "constraint", ";", "$", "firstColumn", "=", "$", "this", "->", "quoteIdentifier", "(", "$", "firstColumn", ")", ";", "$", "secondColumn", "=", "$", "this", "->", "quoteIdentifier", "(", "$", "secondColumn", ")", ";", "$", "constraint", "=", "\"{$firstColumn} {$operator} {$secondColumn}\"", ";", "}", "$", "this", "->", "joinSources", "[", "]", "=", "\"{$query} ON {$constraint}\"", ";", "return", "$", "this", ";", "}" ]
Add a RAW JOIN string to the query. @param $query @param $constraint @param $tableAlias @return $this
[ "Add", "a", "RAW", "JOIN", "string", "to", "the", "query", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Joins.php#L161-L182
230,586
cygnite/framework
src/Cygnite/Database/Query/Joins.php
Joins.quoteIdentifierSection
protected function quoteIdentifierSection($part) { if ($part === '*') { return $part; } $quoteCharacter = '`'; // double up any identifier quotes to escape them return $quoteCharacter. str_replace( $quoteCharacter, $quoteCharacter.$quoteCharacter, $part ).$quoteCharacter; }
php
protected function quoteIdentifierSection($part) { if ($part === '*') { return $part; } $quoteCharacter = '`'; // double up any identifier quotes to escape them return $quoteCharacter. str_replace( $quoteCharacter, $quoteCharacter.$quoteCharacter, $part ).$quoteCharacter; }
[ "protected", "function", "quoteIdentifierSection", "(", "$", "part", ")", "{", "if", "(", "$", "part", "===", "'*'", ")", "{", "return", "$", "part", ";", "}", "$", "quoteCharacter", "=", "'`'", ";", "// double up any identifier quotes to escape them", "return", "$", "quoteCharacter", ".", "str_replace", "(", "$", "quoteCharacter", ",", "$", "quoteCharacter", ".", "$", "quoteCharacter", ",", "$", "part", ")", ".", "$", "quoteCharacter", ";", "}" ]
This method for quoting of a single part of an identifier. @param $part @return string
[ "This", "method", "for", "quoting", "of", "a", "single", "part", "of", "an", "identifier", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Query/Joins.php#L228-L242
230,587
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_extension_handler.php
Smarty_Internal_Extension_Handler._callExternalMethod
public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args) { /* @var Smarty $data ->smarty */ $smarty = isset($data->smarty) ? $data->smarty : $data; if (!isset($smarty->ext->$name)) { $class = 'Smarty_Internal_Method_' . ucfirst($name); if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) { if (!isset($this->_property_info[$prop = $match[2]])) { // convert camel case to underscored name $this->resolvedProperties[$prop] = $pn = strtolower(join('_', preg_split('/([A-Z][^A-Z]*)/', $prop, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE))); $this->_property_info[$prop] = property_exists($data, $pn) ? 1 : ($data->_objType == 2 && property_exists($smarty, $pn) ? 2 : 0); } if ($this->_property_info[$prop]) { $pn = $this->resolvedProperties[$prop]; if ($match[1] == 'get') { return $this->_property_info[$prop] == 1 ? $data->$pn : $data->smarty->$pn; } else { return $this->_property_info[$prop] == 1 ? $data->$pn = $args[0] : $data->smarty->$pn = $args[0]; } } elseif (!class_exists($class)) { throw new SmartyException("property '$pn' does not exist."); } } if (class_exists($class)) { $callback = array($smarty->ext->$name = new $class(), $name); } } else { $callback = array($smarty->ext->$name, $name); } array_unshift($args, $data); if (isset($callback) && $callback[0]->objMap | $data->_objType) { return call_user_func_array($callback, $args); } return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args); }
php
public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args) { /* @var Smarty $data ->smarty */ $smarty = isset($data->smarty) ? $data->smarty : $data; if (!isset($smarty->ext->$name)) { $class = 'Smarty_Internal_Method_' . ucfirst($name); if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) { if (!isset($this->_property_info[$prop = $match[2]])) { // convert camel case to underscored name $this->resolvedProperties[$prop] = $pn = strtolower(join('_', preg_split('/([A-Z][^A-Z]*)/', $prop, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE))); $this->_property_info[$prop] = property_exists($data, $pn) ? 1 : ($data->_objType == 2 && property_exists($smarty, $pn) ? 2 : 0); } if ($this->_property_info[$prop]) { $pn = $this->resolvedProperties[$prop]; if ($match[1] == 'get') { return $this->_property_info[$prop] == 1 ? $data->$pn : $data->smarty->$pn; } else { return $this->_property_info[$prop] == 1 ? $data->$pn = $args[0] : $data->smarty->$pn = $args[0]; } } elseif (!class_exists($class)) { throw new SmartyException("property '$pn' does not exist."); } } if (class_exists($class)) { $callback = array($smarty->ext->$name = new $class(), $name); } } else { $callback = array($smarty->ext->$name, $name); } array_unshift($args, $data); if (isset($callback) && $callback[0]->objMap | $data->_objType) { return call_user_func_array($callback, $args); } return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args); }
[ "public", "function", "_callExternalMethod", "(", "Smarty_Internal_Data", "$", "data", ",", "$", "name", ",", "$", "args", ")", "{", "/* @var Smarty $data ->smarty */", "$", "smarty", "=", "isset", "(", "$", "data", "->", "smarty", ")", "?", "$", "data", "->", "smarty", ":", "$", "data", ";", "if", "(", "!", "isset", "(", "$", "smarty", "->", "ext", "->", "$", "name", ")", ")", "{", "$", "class", "=", "'Smarty_Internal_Method_'", ".", "ucfirst", "(", "$", "name", ")", ";", "if", "(", "preg_match", "(", "'/^(set|get)([A-Z].*)$/'", ",", "$", "name", ",", "$", "match", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_property_info", "[", "$", "prop", "=", "$", "match", "[", "2", "]", "]", ")", ")", "{", "// convert camel case to underscored name", "$", "this", "->", "resolvedProperties", "[", "$", "prop", "]", "=", "$", "pn", "=", "strtolower", "(", "join", "(", "'_'", ",", "preg_split", "(", "'/([A-Z][^A-Z]*)/'", ",", "$", "prop", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", "|", "PREG_SPLIT_DELIM_CAPTURE", ")", ")", ")", ";", "$", "this", "->", "_property_info", "[", "$", "prop", "]", "=", "property_exists", "(", "$", "data", ",", "$", "pn", ")", "?", "1", ":", "(", "$", "data", "->", "_objType", "==", "2", "&&", "property_exists", "(", "$", "smarty", ",", "$", "pn", ")", "?", "2", ":", "0", ")", ";", "}", "if", "(", "$", "this", "->", "_property_info", "[", "$", "prop", "]", ")", "{", "$", "pn", "=", "$", "this", "->", "resolvedProperties", "[", "$", "prop", "]", ";", "if", "(", "$", "match", "[", "1", "]", "==", "'get'", ")", "{", "return", "$", "this", "->", "_property_info", "[", "$", "prop", "]", "==", "1", "?", "$", "data", "->", "$", "pn", ":", "$", "data", "->", "smarty", "->", "$", "pn", ";", "}", "else", "{", "return", "$", "this", "->", "_property_info", "[", "$", "prop", "]", "==", "1", "?", "$", "data", "->", "$", "pn", "=", "$", "args", "[", "0", "]", ":", "$", "data", "->", "smarty", "->", "$", "pn", "=", "$", "args", "[", "0", "]", ";", "}", "}", "elseif", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "SmartyException", "(", "\"property '$pn' does not exist.\"", ")", ";", "}", "}", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "callback", "=", "array", "(", "$", "smarty", "->", "ext", "->", "$", "name", "=", "new", "$", "class", "(", ")", ",", "$", "name", ")", ";", "}", "}", "else", "{", "$", "callback", "=", "array", "(", "$", "smarty", "->", "ext", "->", "$", "name", ",", "$", "name", ")", ";", "}", "array_unshift", "(", "$", "args", ",", "$", "data", ")", ";", "if", "(", "isset", "(", "$", "callback", ")", "&&", "$", "callback", "[", "0", "]", "->", "objMap", "|", "$", "data", "->", "_objType", ")", "{", "return", "call_user_func_array", "(", "$", "callback", ",", "$", "args", ")", ";", "}", "return", "call_user_func_array", "(", "array", "(", "new", "Smarty_Internal_Undefined", "(", ")", ",", "$", "name", ")", ",", "$", "args", ")", ";", "}" ]
Call external Method @param \Smarty_Internal_Data $data @param string $name external method names @param array $args argument array @return mixed @throws SmartyException
[ "Call", "external", "Method" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_extension_handler.php#L67-L106
230,588
thrace-project/datagrid-bundle
Twig/Extension/DataGridExtension.php
DataGridExtension.dataGrid
public function dataGrid ($dataGrid) { if (!$dataGrid instanceof DataGridInterface){ $dataGrid = $this->container->get('thrace_data_grid.provider')->get($dataGrid); } return $this->container->get('templating')->render( 'ThraceDataGridBundle:DataGrid:index.html.twig', array( 'dataGrid' => $dataGrid, 'translationDomain' => $this->container ->getParameter('thrace_data_grid.translation_domain') ) ); }
php
public function dataGrid ($dataGrid) { if (!$dataGrid instanceof DataGridInterface){ $dataGrid = $this->container->get('thrace_data_grid.provider')->get($dataGrid); } return $this->container->get('templating')->render( 'ThraceDataGridBundle:DataGrid:index.html.twig', array( 'dataGrid' => $dataGrid, 'translationDomain' => $this->container ->getParameter('thrace_data_grid.translation_domain') ) ); }
[ "public", "function", "dataGrid", "(", "$", "dataGrid", ")", "{", "if", "(", "!", "$", "dataGrid", "instanceof", "DataGridInterface", ")", "{", "$", "dataGrid", "=", "$", "this", "->", "container", "->", "get", "(", "'thrace_data_grid.provider'", ")", "->", "get", "(", "$", "dataGrid", ")", ";", "}", "return", "$", "this", "->", "container", "->", "get", "(", "'templating'", ")", "->", "render", "(", "'ThraceDataGridBundle:DataGrid:index.html.twig'", ",", "array", "(", "'dataGrid'", "=>", "$", "dataGrid", ",", "'translationDomain'", "=>", "$", "this", "->", "container", "->", "getParameter", "(", "'thrace_data_grid.translation_domain'", ")", ")", ")", ";", "}" ]
Rendering initial content of the datagrid @param DataGridInterface|string $dataGrid @return string (html response)
[ "Rendering", "initial", "content", "of", "the", "datagrid" ]
07b39d6494336870933756276d6af1ef7039d700
https://github.com/thrace-project/datagrid-bundle/blob/07b39d6494336870933756276d6af1ef7039d700/Twig/Extension/DataGridExtension.php#L68-L82
230,589
cygnite/framework
src/Cygnite/AssetManager/AssetCollection.php
AssetCollection.make
public static function make(ContainerAwareInterface $container, Closure $callback = null) { $collection = new AssetCollection(new Asset($container)); if (is_null($callback)) { return $collection->asset(); } return $callback($collection); }
php
public static function make(ContainerAwareInterface $container, Closure $callback = null) { $collection = new AssetCollection(new Asset($container)); if (is_null($callback)) { return $collection->asset(); } return $callback($collection); }
[ "public", "static", "function", "make", "(", "ContainerAwareInterface", "$", "container", ",", "Closure", "$", "callback", "=", "null", ")", "{", "$", "collection", "=", "new", "AssetCollection", "(", "new", "Asset", "(", "$", "container", ")", ")", ";", "if", "(", "is_null", "(", "$", "callback", ")", ")", "{", "return", "$", "collection", "->", "asset", "(", ")", ";", "}", "return", "$", "callback", "(", "$", "collection", ")", ";", "}" ]
Create a Asset collection object return callback. @param ContainerAwareInterface $container @param callable|null $callback @return Closure
[ "Create", "a", "Asset", "collection", "object", "return", "callback", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/AssetCollection.php#L47-L56
230,590
cygnite/framework
src/Cygnite/AssetManager/AssetCollection.php
AssetCollection.create
public static function create($class, ContainerAwareInterface $container) : Asset { (new $class($a = new Asset($container)))->register(); return static::$asset = $a; }
php
public static function create($class, ContainerAwareInterface $container) : Asset { (new $class($a = new Asset($container)))->register(); return static::$asset = $a; }
[ "public", "static", "function", "create", "(", "$", "class", ",", "ContainerAwareInterface", "$", "container", ")", ":", "Asset", "{", "(", "new", "$", "class", "(", "$", "a", "=", "new", "Asset", "(", "$", "container", ")", ")", ")", "->", "register", "(", ")", ";", "return", "static", "::", "$", "asset", "=", "$", "a", ";", "}" ]
Register Asset into Asset object and returns Asset object. @param $class @param Closure $callback @return mixed
[ "Register", "Asset", "into", "Asset", "object", "and", "returns", "Asset", "object", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/AssetManager/AssetCollection.php#L66-L71
230,591
inetprocess/libsugarcrm
src/LangFileCleaner.php
LangFileCleaner.clean
public function clean($sort = true, $test = false) { $finder = new Finder(); $finder->files() ->in($this->getApplication()->getPath()) ->path('/^custom\/include\/language/') ->depth('== 3') ->name('*.lang.php'); $found_one = false; foreach ($finder as $file) { $this->getLogger()->notice('Processing file ' . $file); $found_one = true; $content = file_get_contents($file); if ($content === false) { throw new \Exception('Unable to load the file contents of ' . $file . '.'); } $lang = new LangFile($this->getLogger(), $content, $test); file_put_contents($file, $lang->getSortedFile($sort)); } if (!$found_one) { $this->getLogger()->notice('No lang files found to process.'); return false; } return true; }
php
public function clean($sort = true, $test = false) { $finder = new Finder(); $finder->files() ->in($this->getApplication()->getPath()) ->path('/^custom\/include\/language/') ->depth('== 3') ->name('*.lang.php'); $found_one = false; foreach ($finder as $file) { $this->getLogger()->notice('Processing file ' . $file); $found_one = true; $content = file_get_contents($file); if ($content === false) { throw new \Exception('Unable to load the file contents of ' . $file . '.'); } $lang = new LangFile($this->getLogger(), $content, $test); file_put_contents($file, $lang->getSortedFile($sort)); } if (!$found_one) { $this->getLogger()->notice('No lang files found to process.'); return false; } return true; }
[ "public", "function", "clean", "(", "$", "sort", "=", "true", ",", "$", "test", "=", "false", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "files", "(", ")", "->", "in", "(", "$", "this", "->", "getApplication", "(", ")", "->", "getPath", "(", ")", ")", "->", "path", "(", "'/^custom\\/include\\/language/'", ")", "->", "depth", "(", "'== 3'", ")", "->", "name", "(", "'*.lang.php'", ")", ";", "$", "found_one", "=", "false", ";", "foreach", "(", "$", "finder", "as", "$", "file", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "notice", "(", "'Processing file '", ".", "$", "file", ")", ";", "$", "found_one", "=", "true", ";", "$", "content", "=", "file_get_contents", "(", "$", "file", ")", ";", "if", "(", "$", "content", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unable to load the file contents of '", ".", "$", "file", ".", "'.'", ")", ";", "}", "$", "lang", "=", "new", "LangFile", "(", "$", "this", "->", "getLogger", "(", ")", ",", "$", "content", ",", "$", "test", ")", ";", "file_put_contents", "(", "$", "file", ",", "$", "lang", "->", "getSortedFile", "(", "$", "sort", ")", ")", ";", "}", "if", "(", "!", "$", "found_one", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "notice", "(", "'No lang files found to process.'", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Clean all sugar language files.
[ "Clean", "all", "sugar", "language", "files", "." ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/LangFileCleaner.php#L47-L73
230,592
cygnite/framework
src/Cygnite/Mvc/View/Template.php
Template.setDefaultFunctions
public function setDefaultFunctions() { $this->setLink() //set link() function ->setTwigBaseUrl(); //set baseUrl() function foreach ($this->functions as $key => $func) { $this->twigEnvironment->addFunction($func); } }
php
public function setDefaultFunctions() { $this->setLink() //set link() function ->setTwigBaseUrl(); //set baseUrl() function foreach ($this->functions as $key => $func) { $this->twigEnvironment->addFunction($func); } }
[ "public", "function", "setDefaultFunctions", "(", ")", "{", "$", "this", "->", "setLink", "(", ")", "//set link() function", "->", "setTwigBaseUrl", "(", ")", ";", "//set baseUrl() function", "foreach", "(", "$", "this", "->", "functions", "as", "$", "key", "=>", "$", "func", ")", "{", "$", "this", "->", "twigEnvironment", "->", "addFunction", "(", "$", "func", ")", ";", "}", "}" ]
Set default functions for the framework.
[ "Set", "default", "functions", "for", "the", "framework", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Mvc/View/Template.php#L83-L91
230,593
inetprocess/libsugarcrm
src/LangFile.php
LangFile.getTokenName
public static function getTokenName($token) { if (is_int($token[self::T_KEY])) { return token_name($token[self::T_KEY]); } else { return $token[self::T_KEY]; } }
php
public static function getTokenName($token) { if (is_int($token[self::T_KEY])) { return token_name($token[self::T_KEY]); } else { return $token[self::T_KEY]; } }
[ "public", "static", "function", "getTokenName", "(", "$", "token", ")", "{", "if", "(", "is_int", "(", "$", "token", "[", "self", "::", "T_KEY", "]", ")", ")", "{", "return", "token_name", "(", "$", "token", "[", "self", "::", "T_KEY", "]", ")", ";", "}", "else", "{", "return", "$", "token", "[", "self", "::", "T_KEY", "]", ";", "}", "}" ]
Return the token name as a string.
[ "Return", "the", "token", "name", "as", "a", "string", "." ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/LangFile.php#L71-L78
230,594
inetprocess/libsugarcrm
src/LangFile.php
LangFile.checkVarName
public function checkVarName($var_name) { if (empty($var_name)) { return; } if (array_key_exists($var_name, $this->var_blocks)) { $this->logger->warning("Found duplicate definition for $var_name."); } }
php
public function checkVarName($var_name) { if (empty($var_name)) { return; } if (array_key_exists($var_name, $this->var_blocks)) { $this->logger->warning("Found duplicate definition for $var_name."); } }
[ "public", "function", "checkVarName", "(", "$", "var_name", ")", "{", "if", "(", "empty", "(", "$", "var_name", ")", ")", "{", "return", ";", "}", "if", "(", "array_key_exists", "(", "$", "var_name", ",", "$", "this", "->", "var_blocks", ")", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "\"Found duplicate definition for $var_name.\"", ")", ";", "}", "}" ]
Log a warning if a variable name was already found. Also check for the global or local version of the same variable. @param var_name Name of the variable to check.
[ "Log", "a", "warning", "if", "a", "variable", "name", "was", "already", "found", ".", "Also", "check", "for", "the", "global", "or", "local", "version", "of", "the", "same", "variable", "." ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/LangFile.php#L86-L94
230,595
inetprocess/libsugarcrm
src/LangFile.php
LangFile.normalizeVariableName
public function normalizeVariableName($var_name) { if (substr($var_name, 0, 8) == '$GLOBALS') { // Replaces: // $GLOBALS['test'] => $test // $GLOBALS [ 'test' ] => $test $reg = <<<'EOS' /^\$GLOBALS\s*\[\s*'([^']+)'\s*\]/ EOS; $var_name = preg_replace($reg, '$\1', $var_name); } return $var_name; }
php
public function normalizeVariableName($var_name) { if (substr($var_name, 0, 8) == '$GLOBALS') { // Replaces: // $GLOBALS['test'] => $test // $GLOBALS [ 'test' ] => $test $reg = <<<'EOS' /^\$GLOBALS\s*\[\s*'([^']+)'\s*\]/ EOS; $var_name = preg_replace($reg, '$\1', $var_name); } return $var_name; }
[ "public", "function", "normalizeVariableName", "(", "$", "var_name", ")", "{", "if", "(", "substr", "(", "$", "var_name", ",", "0", ",", "8", ")", "==", "'$GLOBALS'", ")", "{", "// Replaces:", "// $GLOBALS['test'] => $test", "// $GLOBALS [ 'test' ] => $test", "$", "reg", "=", " <<<'EOS'\n/^\\$GLOBALS\\s*\\[\\s*'([^']+)'\\s*\\]/\nEOS", ";", "$", "var_name", "=", "preg_replace", "(", "$", "reg", ",", "'$\\1'", ",", "$", "var_name", ")", ";", "}", "return", "$", "var_name", ";", "}" ]
Remove the global part of a variable definition. All variables must be set to their local equivalent.
[ "Remove", "the", "global", "part", "of", "a", "variable", "definition", ".", "All", "variables", "must", "be", "set", "to", "their", "local", "equivalent", "." ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/LangFile.php#L99-L111
230,596
inetprocess/libsugarcrm
src/LangFile.php
LangFile.getSortedFile
public function getSortedFile($sort = true) { if (!$this->tokens->valid()) { $this->logger->info('File is empty.'); } while ($this->tokens->valid()) { $this->logger->info('parsing next block'); $this->parseNextBlock(); } if ($sort) { ksort($this->var_blocks); } $this->var_blocks = array_values($this->var_blocks); $blocks = array_merge($this->empty_blocks, $this->var_blocks, $this->end_blocks); return implode('', $blocks); }
php
public function getSortedFile($sort = true) { if (!$this->tokens->valid()) { $this->logger->info('File is empty.'); } while ($this->tokens->valid()) { $this->logger->info('parsing next block'); $this->parseNextBlock(); } if ($sort) { ksort($this->var_blocks); } $this->var_blocks = array_values($this->var_blocks); $blocks = array_merge($this->empty_blocks, $this->var_blocks, $this->end_blocks); return implode('', $blocks); }
[ "public", "function", "getSortedFile", "(", "$", "sort", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "tokens", "->", "valid", "(", ")", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "'File is empty.'", ")", ";", "}", "while", "(", "$", "this", "->", "tokens", "->", "valid", "(", ")", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "'parsing next block'", ")", ";", "$", "this", "->", "parseNextBlock", "(", ")", ";", "}", "if", "(", "$", "sort", ")", "{", "ksort", "(", "$", "this", "->", "var_blocks", ")", ";", "}", "$", "this", "->", "var_blocks", "=", "array_values", "(", "$", "this", "->", "var_blocks", ")", ";", "$", "blocks", "=", "array_merge", "(", "$", "this", "->", "empty_blocks", ",", "$", "this", "->", "var_blocks", ",", "$", "this", "->", "end_blocks", ")", ";", "return", "implode", "(", "''", ",", "$", "blocks", ")", ";", "}" ]
Parse all tokens from the file and return them sorted and cleaned. @param sort If true it will sort the variables. @return A string with the original file data sorted.
[ "Parse", "all", "tokens", "from", "the", "file", "and", "return", "them", "sorted", "and", "cleaned", "." ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/LangFile.php#L257-L273
230,597
crodas/SQLParser
src/SQLParser/Parser.php
SQLParser_Parser.tokenName
function tokenName($tokenType) { if ($tokenType === 0) { return 'End of Input'; } if ($tokenType > 0 && $tokenType < count(self::$yyTokenName)) { return self::$yyTokenName[$tokenType]; } else { return "Unknown"; } }
php
function tokenName($tokenType) { if ($tokenType === 0) { return 'End of Input'; } if ($tokenType > 0 && $tokenType < count(self::$yyTokenName)) { return self::$yyTokenName[$tokenType]; } else { return "Unknown"; } }
[ "function", "tokenName", "(", "$", "tokenType", ")", "{", "if", "(", "$", "tokenType", "===", "0", ")", "{", "return", "'End of Input'", ";", "}", "if", "(", "$", "tokenType", ">", "0", "&&", "$", "tokenType", "<", "count", "(", "self", "::", "$", "yyTokenName", ")", ")", "{", "return", "self", "::", "$", "yyTokenName", "[", "$", "tokenType", "]", ";", "}", "else", "{", "return", "\"Unknown\"", ";", "}", "}" ]
This function returns the symbolic name associated with a token value. @param int @return string
[ "This", "function", "returns", "the", "symbolic", "name", "associated", "with", "a", "token", "value", "." ]
a0241cb8755ed36b2a0d0812503ee71abfbe52ac
https://github.com/crodas/SQLParser/blob/a0241cb8755ed36b2a0d0812503ee71abfbe52ac/src/SQLParser/Parser.php#L1462-L1472
230,598
crodas/SQLParser
src/SQLParser/Parser.php
SQLParser_Parser.yy_reduce
function yy_reduce($yyruleno) { //int $yygoto; /* The next state */ //int $yyact; /* The next action */ //mixed $yygotominor; /* The LHS of the rule reduced */ //SQLParser_yyStackEntry $yymsp; /* The top of the parser's stack */ //int $yysize; /* Amount to pop the stack */ $yymsp = $this->yystack[$this->yyidx]; if (self::$yyTraceFILE && $yyruleno >= 0 && $yyruleno < count(self::$yyRuleName)) { fprintf(self::$yyTraceFILE, "%sReduce (%d) [%s].\n", self::$yyTracePrompt, $yyruleno, self::$yyRuleName[$yyruleno]); } $this->_retvalue = $yy_lefthand_side = null; if (array_key_exists($yyruleno, self::$yyReduceMap)) { // call the action $this->_retvalue = null; $this->{'yy_r' . self::$yyReduceMap[$yyruleno]}(); $yy_lefthand_side = $this->_retvalue; } $yygoto = self::$yyRuleInfo[$yyruleno]['lhs']; $yysize = self::$yyRuleInfo[$yyruleno]['rhs']; $this->yyidx -= $yysize; for ($i = $yysize; $i; $i--) { // pop all of the right-hand side parameters array_pop($this->yystack); } $yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto); if ($yyact < self::YYNSTATE) { /* If we are not debugging and the reduce action popped at least ** one element off the stack, then we can push the new element back ** onto the stack here, and skip the stack overflow test in yy_shift(). ** That gives a significant speed improvement. */ if (!self::$yyTraceFILE && $yysize) { $this->yyidx++; $x = new SQLParser_yyStackEntry; $x->stateno = $yyact; $x->major = $yygoto; $x->minor = $yy_lefthand_side; $this->yystack[$this->yyidx] = $x; } else { $this->yy_shift($yyact, $yygoto, $yy_lefthand_side); } } elseif ($yyact == self::YYNSTATE + self::YYNRULE + 1) { $this->yy_accept(); } }
php
function yy_reduce($yyruleno) { //int $yygoto; /* The next state */ //int $yyact; /* The next action */ //mixed $yygotominor; /* The LHS of the rule reduced */ //SQLParser_yyStackEntry $yymsp; /* The top of the parser's stack */ //int $yysize; /* Amount to pop the stack */ $yymsp = $this->yystack[$this->yyidx]; if (self::$yyTraceFILE && $yyruleno >= 0 && $yyruleno < count(self::$yyRuleName)) { fprintf(self::$yyTraceFILE, "%sReduce (%d) [%s].\n", self::$yyTracePrompt, $yyruleno, self::$yyRuleName[$yyruleno]); } $this->_retvalue = $yy_lefthand_side = null; if (array_key_exists($yyruleno, self::$yyReduceMap)) { // call the action $this->_retvalue = null; $this->{'yy_r' . self::$yyReduceMap[$yyruleno]}(); $yy_lefthand_side = $this->_retvalue; } $yygoto = self::$yyRuleInfo[$yyruleno]['lhs']; $yysize = self::$yyRuleInfo[$yyruleno]['rhs']; $this->yyidx -= $yysize; for ($i = $yysize; $i; $i--) { // pop all of the right-hand side parameters array_pop($this->yystack); } $yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto); if ($yyact < self::YYNSTATE) { /* If we are not debugging and the reduce action popped at least ** one element off the stack, then we can push the new element back ** onto the stack here, and skip the stack overflow test in yy_shift(). ** That gives a significant speed improvement. */ if (!self::$yyTraceFILE && $yysize) { $this->yyidx++; $x = new SQLParser_yyStackEntry; $x->stateno = $yyact; $x->major = $yygoto; $x->minor = $yy_lefthand_side; $this->yystack[$this->yyidx] = $x; } else { $this->yy_shift($yyact, $yygoto, $yy_lefthand_side); } } elseif ($yyact == self::YYNSTATE + self::YYNRULE + 1) { $this->yy_accept(); } }
[ "function", "yy_reduce", "(", "$", "yyruleno", ")", "{", "//int $yygoto; /* The next state */", "//int $yyact; /* The next action */", "//mixed $yygotominor; /* The LHS of the rule reduced */", "//SQLParser_yyStackEntry $yymsp; /* The top of the parser's stack */", "//int $yysize; /* Amount to pop the stack */", "$", "yymsp", "=", "$", "this", "->", "yystack", "[", "$", "this", "->", "yyidx", "]", ";", "if", "(", "self", "::", "$", "yyTraceFILE", "&&", "$", "yyruleno", ">=", "0", "&&", "$", "yyruleno", "<", "count", "(", "self", "::", "$", "yyRuleName", ")", ")", "{", "fprintf", "(", "self", "::", "$", "yyTraceFILE", ",", "\"%sReduce (%d) [%s].\\n\"", ",", "self", "::", "$", "yyTracePrompt", ",", "$", "yyruleno", ",", "self", "::", "$", "yyRuleName", "[", "$", "yyruleno", "]", ")", ";", "}", "$", "this", "->", "_retvalue", "=", "$", "yy_lefthand_side", "=", "null", ";", "if", "(", "array_key_exists", "(", "$", "yyruleno", ",", "self", "::", "$", "yyReduceMap", ")", ")", "{", "// call the action", "$", "this", "->", "_retvalue", "=", "null", ";", "$", "this", "->", "{", "'yy_r'", ".", "self", "::", "$", "yyReduceMap", "[", "$", "yyruleno", "]", "}", "(", ")", ";", "$", "yy_lefthand_side", "=", "$", "this", "->", "_retvalue", ";", "}", "$", "yygoto", "=", "self", "::", "$", "yyRuleInfo", "[", "$", "yyruleno", "]", "[", "'lhs'", "]", ";", "$", "yysize", "=", "self", "::", "$", "yyRuleInfo", "[", "$", "yyruleno", "]", "[", "'rhs'", "]", ";", "$", "this", "->", "yyidx", "-=", "$", "yysize", ";", "for", "(", "$", "i", "=", "$", "yysize", ";", "$", "i", ";", "$", "i", "--", ")", "{", "// pop all of the right-hand side parameters", "array_pop", "(", "$", "this", "->", "yystack", ")", ";", "}", "$", "yyact", "=", "$", "this", "->", "yy_find_reduce_action", "(", "$", "this", "->", "yystack", "[", "$", "this", "->", "yyidx", "]", "->", "stateno", ",", "$", "yygoto", ")", ";", "if", "(", "$", "yyact", "<", "self", "::", "YYNSTATE", ")", "{", "/* If we are not debugging and the reduce action popped at least\n ** one element off the stack, then we can push the new element back\n ** onto the stack here, and skip the stack overflow test in yy_shift().\n ** That gives a significant speed improvement. */", "if", "(", "!", "self", "::", "$", "yyTraceFILE", "&&", "$", "yysize", ")", "{", "$", "this", "->", "yyidx", "++", ";", "$", "x", "=", "new", "SQLParser_yyStackEntry", ";", "$", "x", "->", "stateno", "=", "$", "yyact", ";", "$", "x", "->", "major", "=", "$", "yygoto", ";", "$", "x", "->", "minor", "=", "$", "yy_lefthand_side", ";", "$", "this", "->", "yystack", "[", "$", "this", "->", "yyidx", "]", "=", "$", "x", ";", "}", "else", "{", "$", "this", "->", "yy_shift", "(", "$", "yyact", ",", "$", "yygoto", ",", "$", "yy_lefthand_side", ")", ";", "}", "}", "elseif", "(", "$", "yyact", "==", "self", "::", "YYNSTATE", "+", "self", "::", "YYNRULE", "+", "1", ")", "{", "$", "this", "->", "yy_accept", "(", ")", ";", "}", "}" ]
Perform a reduce action and the shift that must immediately follow the reduce. For a rule such as: <pre> A ::= B blah C. { dosomething(); } </pre> This function will first call the action, if any, ("dosomething();" in our example), and then it will pop three states from the stack, one for each entry on the right-hand side of the expression (B, blah, and C in our example rule), and then push the result of the action back on to the stack with the resulting state reduced to (as described in the .out file) @param int Number of the rule by which to reduce
[ "Perform", "a", "reduce", "action", "and", "the", "shift", "that", "must", "immediately", "follow", "the", "reduce", "." ]
a0241cb8755ed36b2a0d0812503ee71abfbe52ac
https://github.com/crodas/SQLParser/blob/a0241cb8755ed36b2a0d0812503ee71abfbe52ac/src/SQLParser/Parser.php#L2729-L2777
230,599
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.getViewInfo
public function getViewInfo($viewer_guid = 0) { if ($viewer_guid == 0) { $viewer_guid = elgg_get_logged_in_user_guid(); } $count = elgg_get_annotations([ 'guid' => $this->getGUID(), 'annotation_name' => 'tp_view', 'count' => true, ]); if ($count > 0) { $views = elgg_get_annotations([ 'guid' => $this->getGUID(), 'annotation_name' => 'tp_view', 'limit' => false, 'batch' => true, ]); if ($this->getOwnerGUID() == $viewer_guid) { // get unique number of viewers $diff_viewers = []; foreach ($views as $view) { $diff_viewers[$view->owner_guid] = 1; } $unique_viewers = count($diff_viewers); } else if ($viewer_guid) { // get the number of times this user has viewed the photo $my_views = 0; foreach ($views as $view) { if ($view->owner_guid == $viewer_guid) { $my_views++; } } } $view_info = [ "total" => $count, "unique" => $unique_viewers, "mine" => $my_views, ]; } else { $view_info = [ "total" => 0, "unique" => 0, "mine" => 0, ]; } return $view_info; }
php
public function getViewInfo($viewer_guid = 0) { if ($viewer_guid == 0) { $viewer_guid = elgg_get_logged_in_user_guid(); } $count = elgg_get_annotations([ 'guid' => $this->getGUID(), 'annotation_name' => 'tp_view', 'count' => true, ]); if ($count > 0) { $views = elgg_get_annotations([ 'guid' => $this->getGUID(), 'annotation_name' => 'tp_view', 'limit' => false, 'batch' => true, ]); if ($this->getOwnerGUID() == $viewer_guid) { // get unique number of viewers $diff_viewers = []; foreach ($views as $view) { $diff_viewers[$view->owner_guid] = 1; } $unique_viewers = count($diff_viewers); } else if ($viewer_guid) { // get the number of times this user has viewed the photo $my_views = 0; foreach ($views as $view) { if ($view->owner_guid == $viewer_guid) { $my_views++; } } } $view_info = [ "total" => $count, "unique" => $unique_viewers, "mine" => $my_views, ]; } else { $view_info = [ "total" => 0, "unique" => 0, "mine" => 0, ]; } return $view_info; }
[ "public", "function", "getViewInfo", "(", "$", "viewer_guid", "=", "0", ")", "{", "if", "(", "$", "viewer_guid", "==", "0", ")", "{", "$", "viewer_guid", "=", "elgg_get_logged_in_user_guid", "(", ")", ";", "}", "$", "count", "=", "elgg_get_annotations", "(", "[", "'guid'", "=>", "$", "this", "->", "getGUID", "(", ")", ",", "'annotation_name'", "=>", "'tp_view'", ",", "'count'", "=>", "true", ",", "]", ")", ";", "if", "(", "$", "count", ">", "0", ")", "{", "$", "views", "=", "elgg_get_annotations", "(", "[", "'guid'", "=>", "$", "this", "->", "getGUID", "(", ")", ",", "'annotation_name'", "=>", "'tp_view'", ",", "'limit'", "=>", "false", ",", "'batch'", "=>", "true", ",", "]", ")", ";", "if", "(", "$", "this", "->", "getOwnerGUID", "(", ")", "==", "$", "viewer_guid", ")", "{", "// get unique number of viewers", "$", "diff_viewers", "=", "[", "]", ";", "foreach", "(", "$", "views", "as", "$", "view", ")", "{", "$", "diff_viewers", "[", "$", "view", "->", "owner_guid", "]", "=", "1", ";", "}", "$", "unique_viewers", "=", "count", "(", "$", "diff_viewers", ")", ";", "}", "else", "if", "(", "$", "viewer_guid", ")", "{", "// get the number of times this user has viewed the photo", "$", "my_views", "=", "0", ";", "foreach", "(", "$", "views", "as", "$", "view", ")", "{", "if", "(", "$", "view", "->", "owner_guid", "==", "$", "viewer_guid", ")", "{", "$", "my_views", "++", ";", "}", "}", "}", "$", "view_info", "=", "[", "\"total\"", "=>", "$", "count", ",", "\"unique\"", "=>", "$", "unique_viewers", ",", "\"mine\"", "=>", "$", "my_views", ",", "]", ";", "}", "else", "{", "$", "view_info", "=", "[", "\"total\"", "=>", "0", ",", "\"unique\"", "=>", "0", ",", "\"mine\"", "=>", "0", ",", "]", ";", "}", "return", "$", "view_info", ";", "}" ]
Get the view information for this image @param $viewer_guid The guid of the viewer @return array with number of views, number of unique viewers, and number of views for this viewer
[ "Get", "the", "view", "information", "for", "this", "image" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L136-L186