repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.addFontStyle | public function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
} | php | public function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
} | [
"public",
"function",
"addFontStyle",
"(",
"$",
"styleName",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
"=",
"null",
")",
"{",
"PHPWord_Style",
"::",
"addFontStyle",
"(",
"$",
"styleName",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
")",
";",
"}"
]
| Adds a font style definition to styles.xml
@param $styleName string
@param $styles array | [
"Adds",
"a",
"font",
"style",
"definition",
"to",
"styles",
".",
"xml"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L157-L159 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.addTableStyle | public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) {
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
} | php | public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) {
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
} | [
"public",
"function",
"addTableStyle",
"(",
"$",
"styleName",
",",
"$",
"styleTable",
",",
"$",
"styleFirstRow",
"=",
"null",
")",
"{",
"PHPWord_Style",
"::",
"addTableStyle",
"(",
"$",
"styleName",
",",
"$",
"styleTable",
",",
"$",
"styleFirstRow",
")",
";",
"}"
]
| Adds a table style definition to styles.xml
@param $styleName string
@param $styles array | [
"Adds",
"a",
"table",
"style",
"definition",
"to",
"styles",
".",
"xml"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L167-L169 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.addTitleStyle | public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) {
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
} | php | public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) {
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
} | [
"public",
"function",
"addTitleStyle",
"(",
"$",
"titleCount",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
"=",
"null",
")",
"{",
"PHPWord_Style",
"::",
"addTitleStyle",
"(",
"$",
"titleCount",
",",
"$",
"styleFont",
",",
"$",
"styleParagraph",
")",
";",
"}"
]
| Adds a heading style definition to styles.xml
@param $titleCount int
@param $styles array | [
"Adds",
"a",
"heading",
"style",
"definition",
"to",
"styles",
".",
"xml"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L177-L179 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord.php | PHPWord.loadTemplate | public function loadTemplate($strFilename) {
if(file_exists($strFilename)) {
$template = new PHPWord_Template($strFilename);
return $template;
} else {
trigger_error('Template file '.$strFilename.' not found.', E_ERROR);
}
} | php | public function loadTemplate($strFilename) {
if(file_exists($strFilename)) {
$template = new PHPWord_Template($strFilename);
return $template;
} else {
trigger_error('Template file '.$strFilename.' not found.', E_ERROR);
}
} | [
"public",
"function",
"loadTemplate",
"(",
"$",
"strFilename",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"strFilename",
")",
")",
"{",
"$",
"template",
"=",
"new",
"PHPWord_Template",
"(",
"$",
"strFilename",
")",
";",
"return",
"$",
"template",
";",
"}",
"else",
"{",
"trigger_error",
"(",
"'Template file '",
".",
"$",
"strFilename",
".",
"' not found.'",
",",
"E_ERROR",
")",
";",
"}",
"}"
]
| Load a Template File
@param string $strFilename
@return PHPWord_Template | [
"Load",
"a",
"Template",
"File"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord.php#L213-L220 |
egeloen/IvorySerializerBundle | CacheWarmer/SerializerCacheWarmer.php | SerializerCacheWarmer.warmUp | public function warmUp($cacheDir)
{
if (!$this->loader instanceof MappedClassMetadataLoaderInterface) {
return;
}
foreach ($this->loader->getMappedClasses() as $class) {
$this->factory->getClassMetadata($class);
}
$this->pool->commit();
} | php | public function warmUp($cacheDir)
{
if (!$this->loader instanceof MappedClassMetadataLoaderInterface) {
return;
}
foreach ($this->loader->getMappedClasses() as $class) {
$this->factory->getClassMetadata($class);
}
$this->pool->commit();
} | [
"public",
"function",
"warmUp",
"(",
"$",
"cacheDir",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"loader",
"instanceof",
"MappedClassMetadataLoaderInterface",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"loader",
"->",
"getMappedClasses",
"(",
")",
"as",
"$",
"class",
")",
"{",
"$",
"this",
"->",
"factory",
"->",
"getClassMetadata",
"(",
"$",
"class",
")",
";",
"}",
"$",
"this",
"->",
"pool",
"->",
"commit",
"(",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/egeloen/IvorySerializerBundle/blob/a2bdd912bf715c61b823cf7257ee232d5c823dd3/CacheWarmer/SerializerCacheWarmer.php#L58-L69 |
steeffeen/FancyManiaLinks | FML/Script/Features/Menu.php | Menu.addItem | public function addItem(Control $item, Control $control, $isStartElement = false)
{
$menuElement = new MenuElement($item, $control);
$this->addElement($menuElement, $isStartElement);
return $this;
} | php | public function addItem(Control $item, Control $control, $isStartElement = false)
{
$menuElement = new MenuElement($item, $control);
$this->addElement($menuElement, $isStartElement);
return $this;
} | [
"public",
"function",
"addItem",
"(",
"Control",
"$",
"item",
",",
"Control",
"$",
"control",
",",
"$",
"isStartElement",
"=",
"false",
")",
"{",
"$",
"menuElement",
"=",
"new",
"MenuElement",
"(",
"$",
"item",
",",
"$",
"control",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"$",
"menuElement",
",",
"$",
"isStartElement",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a Menu item
@api
@param Control $item Item Control in the Menu bar
@param Control $control Toggled Menu Control
@param bool $isStartElement (optional) Whether the Menu should start with this Element
@return static | [
"Add",
"a",
"Menu",
"item"
]
| train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Menu.php#L70-L75 |
steeffeen/FancyManiaLinks | FML/Script/Features/Menu.php | Menu.addElement | public function addElement(MenuElement $menuElement, $isStartElement = false)
{
if (!in_array($menuElement, $this->elements, true)) {
array_push($this->elements, $menuElement);
if ($isStartElement) {
// new start element
$this->setStartElement($menuElement);
} else {
// additional element - set invisible
$menuElement->getControl()
->setVisible(false);
}
}
return $this;
} | php | public function addElement(MenuElement $menuElement, $isStartElement = false)
{
if (!in_array($menuElement, $this->elements, true)) {
array_push($this->elements, $menuElement);
if ($isStartElement) {
// new start element
$this->setStartElement($menuElement);
} else {
// additional element - set invisible
$menuElement->getControl()
->setVisible(false);
}
}
return $this;
} | [
"public",
"function",
"addElement",
"(",
"MenuElement",
"$",
"menuElement",
",",
"$",
"isStartElement",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"menuElement",
",",
"$",
"this",
"->",
"elements",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"elements",
",",
"$",
"menuElement",
")",
";",
"if",
"(",
"$",
"isStartElement",
")",
"{",
"// new start element",
"$",
"this",
"->",
"setStartElement",
"(",
"$",
"menuElement",
")",
";",
"}",
"else",
"{",
"// additional element - set invisible",
"$",
"menuElement",
"->",
"getControl",
"(",
")",
"->",
"setVisible",
"(",
"false",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a Menu Element
@api
@param MenuElement $menuElement Menu Element
@param bool $isStartElement (optional) Whether the Menu should start with this Element
@return static | [
"Add",
"a",
"Menu",
"Element"
]
| train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Menu.php#L85-L99 |
steeffeen/FancyManiaLinks | FML/Script/Features/Menu.php | Menu.setStartElement | public function setStartElement(MenuElement $startElement = null)
{
$this->startElement = $startElement;
if ($startElement && !in_array($startElement, $this->elements, true)) {
array_push($this->elements, $startElement);
}
return $this;
} | php | public function setStartElement(MenuElement $startElement = null)
{
$this->startElement = $startElement;
if ($startElement && !in_array($startElement, $this->elements, true)) {
array_push($this->elements, $startElement);
}
return $this;
} | [
"public",
"function",
"setStartElement",
"(",
"MenuElement",
"$",
"startElement",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"startElement",
"=",
"$",
"startElement",
";",
"if",
"(",
"$",
"startElement",
"&&",
"!",
"in_array",
"(",
"$",
"startElement",
",",
"$",
"this",
"->",
"elements",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"elements",
",",
"$",
"startElement",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the Element to start with
@api
@param MenuElement $startElement Start Element
@return static | [
"Set",
"the",
"Element",
"to",
"start",
"with"
]
| train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Menu.php#L119-L126 |
steeffeen/FancyManiaLinks | FML/Script/Features/Menu.php | Menu.getElementsArrayText | protected function getElementsArrayText()
{
$elements = array();
foreach ($this->elements as $element) {
$elementId = $element->getItem()
->getId();
$elements[$elementId] = $element->getControl()
->getId();
}
return Builder::getArray($elements, true);
} | php | protected function getElementsArrayText()
{
$elements = array();
foreach ($this->elements as $element) {
$elementId = $element->getItem()
->getId();
$elements[$elementId] = $element->getControl()
->getId();
}
return Builder::getArray($elements, true);
} | [
"protected",
"function",
"getElementsArrayText",
"(",
")",
"{",
"$",
"elements",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"$",
"elementId",
"=",
"$",
"element",
"->",
"getItem",
"(",
")",
"->",
"getId",
"(",
")",
";",
"$",
"elements",
"[",
"$",
"elementId",
"]",
"=",
"$",
"element",
"->",
"getControl",
"(",
")",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"Builder",
"::",
"getArray",
"(",
"$",
"elements",
",",
"true",
")",
";",
"}"
]
| Build the array text for the Elements
@return string | [
"Build",
"the",
"array",
"text",
"for",
"the",
"Elements"
]
| train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Menu.php#L172-L182 |
benmanu/silverstripe-knowledgebase | code/extensions/FAQRelatedArticlesExtension.php | FAQRelatedArticlesExtension.getTagNameList | public function getTagNameList()
{
$tags = $this->owner->Tags();
$names = [];
foreach ($tags as $tag) {
$names[] = $tag->Name;
}
return implode(', ', $names);
} | php | public function getTagNameList()
{
$tags = $this->owner->Tags();
$names = [];
foreach ($tags as $tag) {
$names[] = $tag->Name;
}
return implode(', ', $names);
} | [
"public",
"function",
"getTagNameList",
"(",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"owner",
"->",
"Tags",
"(",
")",
";",
"$",
"names",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"$",
"tag",
"->",
"Name",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"names",
")",
";",
"}"
]
| Helper to get a comma separated list of all the associated tags.
@return string | [
"Helper",
"to",
"get",
"a",
"comma",
"separated",
"list",
"of",
"all",
"the",
"associated",
"tags",
"."
]
| train | https://github.com/benmanu/silverstripe-knowledgebase/blob/db19bfd4836f43da17ab52e8b53e72a11be64210/code/extensions/FAQRelatedArticlesExtension.php#L45-L55 |
benmanu/silverstripe-knowledgebase | code/extensions/FAQRelatedArticlesExtension.php | FAQRelatedArticlesExtension.getRelatedFAQs | public function getRelatedFAQs($limit = null)
{
$tags = $this->owner->Tags();
if ($tags->count() == 0) {
return null;
}
// find any FAQ that has one of the same tags
$faqs = FAQ::get()
->innerJoin('FAQ_Tags', '"FAQ"."ID" = "FAQ_Tags"."FAQID"')
->where(sprintf('"FAQ_Tags"."TaxonomyTermID" IN (%s)', implode(',', $tags->column('ID'))))
->exclude('ID', $this->owner->ID);
// limit the faqs if applicable
if ($limit && is_int($limit)) {
$faqs = $faqs->limit($limit);
}
return $faqs;
} | php | public function getRelatedFAQs($limit = null)
{
$tags = $this->owner->Tags();
if ($tags->count() == 0) {
return null;
}
// find any FAQ that has one of the same tags
$faqs = FAQ::get()
->innerJoin('FAQ_Tags', '"FAQ"."ID" = "FAQ_Tags"."FAQID"')
->where(sprintf('"FAQ_Tags"."TaxonomyTermID" IN (%s)', implode(',', $tags->column('ID'))))
->exclude('ID', $this->owner->ID);
// limit the faqs if applicable
if ($limit && is_int($limit)) {
$faqs = $faqs->limit($limit);
}
return $faqs;
} | [
"public",
"function",
"getRelatedFAQs",
"(",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"owner",
"->",
"Tags",
"(",
")",
";",
"if",
"(",
"$",
"tags",
"->",
"count",
"(",
")",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"// find any FAQ that has one of the same tags",
"$",
"faqs",
"=",
"FAQ",
"::",
"get",
"(",
")",
"->",
"innerJoin",
"(",
"'FAQ_Tags'",
",",
"'\"FAQ\".\"ID\" = \"FAQ_Tags\".\"FAQID\"'",
")",
"->",
"where",
"(",
"sprintf",
"(",
"'\"FAQ_Tags\".\"TaxonomyTermID\" IN (%s)'",
",",
"implode",
"(",
"','",
",",
"$",
"tags",
"->",
"column",
"(",
"'ID'",
")",
")",
")",
")",
"->",
"exclude",
"(",
"'ID'",
",",
"$",
"this",
"->",
"owner",
"->",
"ID",
")",
";",
"// limit the faqs if applicable",
"if",
"(",
"$",
"limit",
"&&",
"is_int",
"(",
"$",
"limit",
")",
")",
"{",
"$",
"faqs",
"=",
"$",
"faqs",
"->",
"limit",
"(",
"$",
"limit",
")",
";",
"}",
"return",
"$",
"faqs",
";",
"}"
]
| Helper to get all the FAQ articles that are tagged with the same
tags.
@return DataList|null | [
"Helper",
"to",
"get",
"all",
"the",
"FAQ",
"articles",
"that",
"are",
"tagged",
"with",
"the",
"same",
"tags",
"."
]
| train | https://github.com/benmanu/silverstripe-knowledgebase/blob/db19bfd4836f43da17ab52e8b53e72a11be64210/code/extensions/FAQRelatedArticlesExtension.php#L63-L83 |
2amigos/yiifoundation | widgets/Dropdown.php | Dropdown.init | public function init()
{
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.dropdown.js' : 'foundation.min.js'
);
Html::addCssClass($this->htmlOptions, Enum::DROPDOWN_LIST);
ArrayHelper::addValue('data-dropdown-content', '-', $this->htmlOptions);
if ($this->type === Enum::DROPDOWN_CONTENT) {
Html::addCssClass($this->htmlOptions, Enum::CONTENT);
}
parent::init();
} | php | public function init()
{
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.dropdown.js' : 'foundation.min.js'
);
Html::addCssClass($this->htmlOptions, Enum::DROPDOWN_LIST);
ArrayHelper::addValue('data-dropdown-content', '-', $this->htmlOptions);
if ($this->type === Enum::DROPDOWN_CONTENT) {
Html::addCssClass($this->htmlOptions, Enum::CONTENT);
}
parent::init();
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"assets",
"=",
"array",
"(",
"'js'",
"=>",
"YII_DEBUG",
"?",
"'foundation/foundation.dropdown.js'",
":",
"'foundation.min.js'",
")",
";",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"Enum",
"::",
"DROPDOWN_LIST",
")",
";",
"ArrayHelper",
"::",
"addValue",
"(",
"'data-dropdown-content'",
",",
"'-'",
",",
"$",
"this",
"->",
"htmlOptions",
")",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"Enum",
"::",
"DROPDOWN_CONTENT",
")",
"{",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"Enum",
"::",
"CONTENT",
")",
";",
"}",
"parent",
"::",
"init",
"(",
")",
";",
"}"
]
| Initializes the widget | [
"Initializes",
"the",
"widget"
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Dropdown.php#L53-L67 |
2amigos/yiifoundation | widgets/Dropdown.php | Dropdown.renderItems | protected function renderItems()
{
$lines = array();
if ($this->type === Enum::DROPDOWN_CONTENT) {
$lines[] = $this->dropdownContent;
}
if ($this->type === Enum::DROPDOWN_LIST) {
foreach ($this->items as $item) {
if (is_string($item)) {
$lines[] = $item;
continue;
}
if (!isset($item['label'])) {
throw new InvalidConfigException("The 'label' option is required.");
}
$label = $this->encodeLabels ? \CHtml::encode($item['label']) : $item['label'];
$options = ArrayHelper::getValue($item, 'options', array());
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
$linkOptions['tabindex'] = '-1';
$content = \CHtml::link($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
$lines[] = \CHtml::tag('li', $options, $content);
}
}
return \CHtml::tag('ul', $this->htmlOptions, implode("\n", $lines));
} | php | protected function renderItems()
{
$lines = array();
if ($this->type === Enum::DROPDOWN_CONTENT) {
$lines[] = $this->dropdownContent;
}
if ($this->type === Enum::DROPDOWN_LIST) {
foreach ($this->items as $item) {
if (is_string($item)) {
$lines[] = $item;
continue;
}
if (!isset($item['label'])) {
throw new InvalidConfigException("The 'label' option is required.");
}
$label = $this->encodeLabels ? \CHtml::encode($item['label']) : $item['label'];
$options = ArrayHelper::getValue($item, 'options', array());
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
$linkOptions['tabindex'] = '-1';
$content = \CHtml::link($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
$lines[] = \CHtml::tag('li', $options, $content);
}
}
return \CHtml::tag('ul', $this->htmlOptions, implode("\n", $lines));
} | [
"protected",
"function",
"renderItems",
"(",
")",
"{",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"Enum",
"::",
"DROPDOWN_CONTENT",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"$",
"this",
"->",
"dropdownContent",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"Enum",
"::",
"DROPDOWN_LIST",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"item",
")",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"$",
"item",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"item",
"[",
"'label'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"\"The 'label' option is required.\"",
")",
";",
"}",
"$",
"label",
"=",
"$",
"this",
"->",
"encodeLabels",
"?",
"\\",
"CHtml",
"::",
"encode",
"(",
"$",
"item",
"[",
"'label'",
"]",
")",
":",
"$",
"item",
"[",
"'label'",
"]",
";",
"$",
"options",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'options'",
",",
"array",
"(",
")",
")",
";",
"$",
"linkOptions",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'linkOptions'",
",",
"array",
"(",
")",
")",
";",
"$",
"linkOptions",
"[",
"'tabindex'",
"]",
"=",
"'-1'",
";",
"$",
"content",
"=",
"\\",
"CHtml",
"::",
"link",
"(",
"$",
"label",
",",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'url'",
",",
"'#'",
")",
",",
"$",
"linkOptions",
")",
";",
"$",
"lines",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"tag",
"(",
"'li'",
",",
"$",
"options",
",",
"$",
"content",
")",
";",
"}",
"}",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'ul'",
",",
"$",
"this",
"->",
"htmlOptions",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"lines",
")",
")",
";",
"}"
]
| Renders dropdown items
@return string
@throws InvalidConfigException | [
"Renders",
"dropdown",
"items"
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Dropdown.php#L82-L109 |
JBZoo/Less | src/Driver/Gpeasy.php | Gpeasy.setImportPath | public function setImportPath($fullPath, $relPath = null)
{
$this->_initCompiler();
$relPath = $relPath ?: $this->_options->get('root_url');
if (!FS::isDir($fullPath)) {
throw new Exception('Undefined import path: ' . $fullPath);
}
$importPaths = \Less_Parser::$options['import_dirs'];
$importPaths[$fullPath] = $relPath;
$this->_compiler->SetImportDirs($importPaths);
} | php | public function setImportPath($fullPath, $relPath = null)
{
$this->_initCompiler();
$relPath = $relPath ?: $this->_options->get('root_url');
if (!FS::isDir($fullPath)) {
throw new Exception('Undefined import path: ' . $fullPath);
}
$importPaths = \Less_Parser::$options['import_dirs'];
$importPaths[$fullPath] = $relPath;
$this->_compiler->SetImportDirs($importPaths);
} | [
"public",
"function",
"setImportPath",
"(",
"$",
"fullPath",
",",
"$",
"relPath",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_initCompiler",
"(",
")",
";",
"$",
"relPath",
"=",
"$",
"relPath",
"?",
":",
"$",
"this",
"->",
"_options",
"->",
"get",
"(",
"'root_url'",
")",
";",
"if",
"(",
"!",
"FS",
"::",
"isDir",
"(",
"$",
"fullPath",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Undefined import path: '",
".",
"$",
"fullPath",
")",
";",
"}",
"$",
"importPaths",
"=",
"\\",
"Less_Parser",
"::",
"$",
"options",
"[",
"'import_dirs'",
"]",
";",
"$",
"importPaths",
"[",
"$",
"fullPath",
"]",
"=",
"$",
"relPath",
";",
"$",
"this",
"->",
"_compiler",
"->",
"SetImportDirs",
"(",
"$",
"importPaths",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/JBZoo/Less/blob/9e9c41e3c7b76222c0d81379dead222413f2f042/src/Driver/Gpeasy.php#L102-L117 |
ClanCats/Core | src/bundles/Session/CCSession.php | CCSession.valid_fingerprint | public static function valid_fingerprint( $fingerprint = null, $name = null )
{
return Manager::create( $name )->valid_fingerprint( $fingerprint );
} | php | public static function valid_fingerprint( $fingerprint = null, $name = null )
{
return Manager::create( $name )->valid_fingerprint( $fingerprint );
} | [
"public",
"static",
"function",
"valid_fingerprint",
"(",
"$",
"fingerprint",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"Manager",
"::",
"create",
"(",
"$",
"name",
")",
"->",
"valid_fingerprint",
"(",
"$",
"fingerprint",
")",
";",
"}"
]
| Check if the given fingerprint or the default fingerprint
parameter matches the curent session fingerprint.
@param string $manager
@return string | [
"Check",
"if",
"the",
"given",
"fingerprint",
"or",
"the",
"default",
"fingerprint",
"parameter",
"matches",
"the",
"curent",
"session",
"fingerprint",
"."
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/CCSession.php#L43-L46 |
ClanCats/Core | src/bundles/Session/CCSession.php | CCSession.set | public static function set( $key, $value, $manager = null )
{
return Manager::create( $manager )->set( $key, $value );
} | php | public static function set( $key, $value, $manager = null )
{
return Manager::create( $manager )->set( $key, $value );
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"manager",
"=",
"null",
")",
"{",
"return",
"Manager",
"::",
"create",
"(",
"$",
"manager",
")",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
]
| Set a value on the session
@param string $key
@param string $value
@param string $manager
@return Session\Manager | [
"Set",
"a",
"value",
"on",
"the",
"session"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/CCSession.php#L82-L85 |
ClanCats/Core | src/bundles/Session/CCSession.php | CCSession.add | public static function add( $key, $value, $manager = null )
{
return Manager::create( $manager )->add( $key, $value );
} | php | public static function add( $key, $value, $manager = null )
{
return Manager::create( $manager )->add( $key, $value );
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"manager",
"=",
"null",
")",
"{",
"return",
"Manager",
"::",
"create",
"(",
"$",
"manager",
")",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
]
| Similar to add but forces the element to be an array
and appends an item.
@param string $key
@param string $value
@param string $manager
@return Session\Manager | [
"Similar",
"to",
"add",
"but",
"forces",
"the",
"element",
"to",
"be",
"an",
"array",
"and",
"appends",
"an",
"item",
"."
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/CCSession.php#L96-L99 |
webforge-labs/psc-cms | lib/Psc/Doctrine/UniqueEntityHydrator.php | UniqueEntityHydrator.getEntity | public function getEntity(Array $fieldsData) {
$qb = $this->getQueryBuilder();
$qFields = array_keys($this->queryFields);
// short track querying if standard case: only id
if ($qFields === array('id')) {
// this saves a query, because the qb->getQuery is executed everytime, ever ever
return isset($fieldsData['id']) ? $this->repository->find($fieldsData['id']) : NULL;
}
// sicherheit: parameter filtern ist zwar nicht nötig, weil wir ja sowieso nur feste parameter im statement haben
// aber doctrine ist picky, wenn man auch zu viele felder übergibt
$binds = array();
foreach ($fieldsData as $field => $value) {
if (array_key_exists($field, $this->queryFields)) {
if ($this->repository->getClassMetadata()->isSingleValuedAssociation($field)) {
$value = $value->getIdentifier();
}
$qb->setParameter($field, $value);
$binds[$field] = TRUE;
}
}
if (count($qFields) !== count($bindFields = array_keys($binds))) {
throw new \RuntimeException(
'Die Anzahl er Parameter im Query und die Anzahl der gebundenen Werte ist nicht gleich. Dies gibt eine QueryException:'."\n".
$qb->getDQL()."\n".
Helper::debugCollectionDiff($qFields, $bindFields, 'query Fields', 'parameter/bound Fields')
);
}
$result = $this->repository->deliverQuery($qb, NULL, 'singleOrNull');
return $result;
} | php | public function getEntity(Array $fieldsData) {
$qb = $this->getQueryBuilder();
$qFields = array_keys($this->queryFields);
// short track querying if standard case: only id
if ($qFields === array('id')) {
// this saves a query, because the qb->getQuery is executed everytime, ever ever
return isset($fieldsData['id']) ? $this->repository->find($fieldsData['id']) : NULL;
}
// sicherheit: parameter filtern ist zwar nicht nötig, weil wir ja sowieso nur feste parameter im statement haben
// aber doctrine ist picky, wenn man auch zu viele felder übergibt
$binds = array();
foreach ($fieldsData as $field => $value) {
if (array_key_exists($field, $this->queryFields)) {
if ($this->repository->getClassMetadata()->isSingleValuedAssociation($field)) {
$value = $value->getIdentifier();
}
$qb->setParameter($field, $value);
$binds[$field] = TRUE;
}
}
if (count($qFields) !== count($bindFields = array_keys($binds))) {
throw new \RuntimeException(
'Die Anzahl er Parameter im Query und die Anzahl der gebundenen Werte ist nicht gleich. Dies gibt eine QueryException:'."\n".
$qb->getDQL()."\n".
Helper::debugCollectionDiff($qFields, $bindFields, 'query Fields', 'parameter/bound Fields')
);
}
$result = $this->repository->deliverQuery($qb, NULL, 'singleOrNull');
return $result;
} | [
"public",
"function",
"getEntity",
"(",
"Array",
"$",
"fieldsData",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"qFields",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"queryFields",
")",
";",
"// short track querying if standard case: only id",
"if",
"(",
"$",
"qFields",
"===",
"array",
"(",
"'id'",
")",
")",
"{",
"// this saves a query, because the qb->getQuery is executed everytime, ever ever",
"return",
"isset",
"(",
"$",
"fieldsData",
"[",
"'id'",
"]",
")",
"?",
"$",
"this",
"->",
"repository",
"->",
"find",
"(",
"$",
"fieldsData",
"[",
"'id'",
"]",
")",
":",
"NULL",
";",
"}",
"// sicherheit: parameter filtern ist zwar nicht nötig, weil wir ja sowieso nur feste parameter im statement haben",
"// aber doctrine ist picky, wenn man auch zu viele felder übergibt",
"$",
"binds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fieldsData",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"queryFields",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"repository",
"->",
"getClassMetadata",
"(",
")",
"->",
"isSingleValuedAssociation",
"(",
"$",
"field",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"getIdentifier",
"(",
")",
";",
"}",
"$",
"qb",
"->",
"setParameter",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"$",
"binds",
"[",
"$",
"field",
"]",
"=",
"TRUE",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"qFields",
")",
"!==",
"count",
"(",
"$",
"bindFields",
"=",
"array_keys",
"(",
"$",
"binds",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Die Anzahl er Parameter im Query und die Anzahl der gebundenen Werte ist nicht gleich. Dies gibt eine QueryException:'",
".",
"\"\\n\"",
".",
"$",
"qb",
"->",
"getDQL",
"(",
")",
".",
"\"\\n\"",
".",
"Helper",
"::",
"debugCollectionDiff",
"(",
"$",
"qFields",
",",
"$",
"bindFields",
",",
"'query Fields'",
",",
"'parameter/bound Fields'",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"repository",
"->",
"deliverQuery",
"(",
"$",
"qb",
",",
"NULL",
",",
"'singleOrNull'",
")",
";",
"return",
"$",
"result",
";",
"}"
]
| Hydriert das Entity aus einem Array mit Daten für Primary Keys oder Unique Constraints
es wird NULL zurückgegeben wenn kein UniqueConstraint und kein Primary Key matched
@return Psc\Doctrine\Entity|NULL
@TODO Psc\Doctrine\QueryException fangen und erklären was fehlt / was geegeben ist | [
"Hydriert",
"das",
"Entity",
"aus",
"einem",
"Array",
"mit",
"Daten",
"für",
"Primary",
"Keys",
"oder",
"Unique",
"Constraints"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/UniqueEntityHydrator.php#L46-L79 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.getFieldNames | public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, UserCustomerRelationPeer::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return UserCustomerRelationPeer::$fieldNames[$type];
} | php | public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, UserCustomerRelationPeer::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return UserCustomerRelationPeer::$fieldNames[$type];
} | [
"public",
"static",
"function",
"getFieldNames",
"(",
"$",
"type",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"type",
",",
"UserCustomerRelationPeer",
"::",
"$",
"fieldNames",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. '",
".",
"$",
"type",
".",
"' was given.'",
")",
";",
"}",
"return",
"UserCustomerRelationPeer",
"::",
"$",
"fieldNames",
"[",
"$",
"type",
"]",
";",
"}"
]
| Returns an array of field names.
@param string $type The type of fieldnames to return:
One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
@return array A list of field names
@throws PropelException - if the type is not valid. | [
"Returns",
"an",
"array",
"of",
"field",
"names",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L123-L130 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.addSelectColumns | public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(UserCustomerRelationPeer::ID);
$criteria->addSelectColumn(UserCustomerRelationPeer::USER_ID);
$criteria->addSelectColumn(UserCustomerRelationPeer::CUSTOMER_ID);
} else {
$criteria->addSelectColumn($alias . '.id');
$criteria->addSelectColumn($alias . '.user_id');
$criteria->addSelectColumn($alias . '.customer_id');
}
} | php | public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(UserCustomerRelationPeer::ID);
$criteria->addSelectColumn(UserCustomerRelationPeer::USER_ID);
$criteria->addSelectColumn(UserCustomerRelationPeer::CUSTOMER_ID);
} else {
$criteria->addSelectColumn($alias . '.id');
$criteria->addSelectColumn($alias . '.user_id');
$criteria->addSelectColumn($alias . '.customer_id');
}
} | [
"public",
"static",
"function",
"addSelectColumns",
"(",
"Criteria",
"$",
"criteria",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"alias",
")",
"{",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"UserCustomerRelationPeer",
"::",
"USER_ID",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"UserCustomerRelationPeer",
"::",
"CUSTOMER_ID",
")",
";",
"}",
"else",
"{",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.id'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.user_id'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.customer_id'",
")",
";",
"}",
"}"
]
| Add all the columns needed to create a new object.
Note: any columns that were marked with lazyLoad="true" in the
XML schema will not be added to the select list and only loaded
on demand.
@param Criteria $criteria object containing the columns to add.
@param string $alias optional table alias
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Add",
"all",
"the",
"columns",
"needed",
"to",
"create",
"a",
"new",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L161-L172 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.getInstanceFromPool | public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(UserCustomerRelationPeer::$instances[$key])) {
return UserCustomerRelationPeer::$instances[$key];
}
}
return null; // just to be explicit
} | php | public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(UserCustomerRelationPeer::$instances[$key])) {
return UserCustomerRelationPeer::$instances[$key];
}
}
return null; // just to be explicit
} | [
"public",
"static",
"function",
"getInstanceFromPool",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"Propel",
"::",
"isInstancePoolingEnabled",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"UserCustomerRelationPeer",
"::",
"$",
"instances",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"UserCustomerRelationPeer",
"::",
"$",
"instances",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"null",
";",
"// just to be explicit",
"}"
]
| Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
For tables with a single-column primary key, that simple pkey value will be returned. For tables with
a multi-column primary key, a serialize()d version of the primary key will be returned.
@param string $key The key (@see getPrimaryKeyHash()) for this instance.
@return UserCustomerRelation Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
@see getPrimaryKeyHash() | [
"Retrieves",
"a",
"string",
"version",
"of",
"the",
"primary",
"key",
"from",
"the",
"DB",
"resultset",
"row",
"that",
"can",
"be",
"used",
"to",
"uniquely",
"identify",
"a",
"row",
"in",
"this",
"table",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L343-L352 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.getPrimaryKeyHashFromRow | public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
{
// If the PK cannot be derived from the row, return null.
if ($row[$startcol] === null) {
return null;
}
return (string) $row[$startcol];
} | php | public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
{
// If the PK cannot be derived from the row, return null.
if ($row[$startcol] === null) {
return null;
}
return (string) $row[$startcol];
} | [
"public",
"static",
"function",
"getPrimaryKeyHashFromRow",
"(",
"$",
"row",
",",
"$",
"startcol",
"=",
"0",
")",
"{",
"// If the PK cannot be derived from the row, return null.",
"if",
"(",
"$",
"row",
"[",
"$",
"startcol",
"]",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"(",
"string",
")",
"$",
"row",
"[",
"$",
"startcol",
"]",
";",
"}"
]
| Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
For tables with a single-column primary key, that simple pkey value will be returned. For tables with
a multi-column primary key, a serialize()d version of the primary key will be returned.
@param array $row PropelPDO resultset row.
@param int $startcol The 0-based offset for reading from the resultset row.
@return string A string version of PK or null if the components of primary key in result array are all null. | [
"Retrieves",
"a",
"string",
"version",
"of",
"the",
"primary",
"key",
"from",
"the",
"DB",
"resultset",
"row",
"that",
"can",
"be",
"used",
"to",
"uniquely",
"identify",
"a",
"row",
"in",
"this",
"table",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L387-L395 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.buildTableMap | public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseUserCustomerRelationPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseUserCustomerRelationPeer::TABLE_NAME)) {
$dbMap->addTableObject(new \Slashworks\AppBundle\Model\map\UserCustomerRelationTableMap());
}
} | php | public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseUserCustomerRelationPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseUserCustomerRelationPeer::TABLE_NAME)) {
$dbMap->addTableObject(new \Slashworks\AppBundle\Model\map\UserCustomerRelationTableMap());
}
} | [
"public",
"static",
"function",
"buildTableMap",
"(",
")",
"{",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"BaseUserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"!",
"$",
"dbMap",
"->",
"hasTable",
"(",
"BaseUserCustomerRelationPeer",
"::",
"TABLE_NAME",
")",
")",
"{",
"$",
"dbMap",
"->",
"addTableObject",
"(",
"new",
"\\",
"Slashworks",
"\\",
"AppBundle",
"\\",
"Model",
"\\",
"map",
"\\",
"UserCustomerRelationTableMap",
"(",
")",
")",
";",
"}",
"}"
]
| Add a TableMap instance to the database for this peer class. | [
"Add",
"a",
"TableMap",
"instance",
"to",
"the",
"database",
"for",
"this",
"peer",
"class",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1117-L1123 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.doDeleteAll | public static function doDeleteAll(PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDeleteAll(UserCustomerRelationPeer::TABLE_NAME, $con, UserCustomerRelationPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
UserCustomerRelationPeer::clearInstancePool();
UserCustomerRelationPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | php | public static function doDeleteAll(PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDeleteAll(UserCustomerRelationPeer::TABLE_NAME, $con, UserCustomerRelationPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
UserCustomerRelationPeer::clearInstancePool();
UserCustomerRelationPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | [
"public",
"static",
"function",
"doDeleteAll",
"(",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"$",
"affectedRows",
"=",
"0",
";",
"// initialize var to track total num of affected rows",
"try",
"{",
"// use transaction because $criteria could contain info",
"// for more than one table or we could emulating ON DELETE CASCADE, etc.",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"$",
"affectedRows",
"+=",
"BasePeer",
"::",
"doDeleteAll",
"(",
"UserCustomerRelationPeer",
"::",
"TABLE_NAME",
",",
"$",
"con",
",",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"// Because this db requires some delete cascade/set null emulation, we have to",
"// clear the cached instance *after* the emulation has happened (since",
"// instances get re-added by the select statement contained therein).",
"UserCustomerRelationPeer",
"::",
"clearInstancePool",
"(",
")",
";",
"UserCustomerRelationPeer",
"::",
"clearRelatedInstancePool",
"(",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"affectedRows",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollBack",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
]
| Deletes all rows from the user_customer_relation table.
@param PropelPDO $con the connection to use
@return int The number of affected rows (if supported by underlying database driver).
@throws PropelException | [
"Deletes",
"all",
"rows",
"from",
"the",
"user_customer_relation",
"table",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1225-L1248 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.doDelete | public static function doDelete($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
// invalidate the cache for all objects of this type, since we have no
// way of knowing (without running a query) what objects should be invalidated
// from the cache based on this Criteria.
UserCustomerRelationPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof UserCustomerRelation) { // it's a model object
// invalidate the cache for this single object
UserCustomerRelationPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, (array) $values, Criteria::IN);
// invalidate the cache for this object(s)
foreach ((array) $values as $singleval) {
UserCustomerRelationPeer::removeInstanceFromPool($singleval);
}
}
// Set the correct dbName
$criteria->setDbName(UserCustomerRelationPeer::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDelete($criteria, $con);
UserCustomerRelationPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | php | public static function doDelete($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($values instanceof Criteria) {
// invalidate the cache for all objects of this type, since we have no
// way of knowing (without running a query) what objects should be invalidated
// from the cache based on this Criteria.
UserCustomerRelationPeer::clearInstancePool();
// rename for clarity
$criteria = clone $values;
} elseif ($values instanceof UserCustomerRelation) { // it's a model object
// invalidate the cache for this single object
UserCustomerRelationPeer::removeInstanceFromPool($values);
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, (array) $values, Criteria::IN);
// invalidate the cache for this object(s)
foreach ((array) $values as $singleval) {
UserCustomerRelationPeer::removeInstanceFromPool($singleval);
}
}
// Set the correct dbName
$criteria->setDbName(UserCustomerRelationPeer::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += BasePeer::doDelete($criteria, $con);
UserCustomerRelationPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | [
"public",
"static",
"function",
"doDelete",
"(",
"$",
"values",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"if",
"(",
"$",
"values",
"instanceof",
"Criteria",
")",
"{",
"// invalidate the cache for all objects of this type, since we have no",
"// way of knowing (without running a query) what objects should be invalidated",
"// from the cache based on this Criteria.",
"UserCustomerRelationPeer",
"::",
"clearInstancePool",
"(",
")",
";",
"// rename for clarity",
"$",
"criteria",
"=",
"clone",
"$",
"values",
";",
"}",
"elseif",
"(",
"$",
"values",
"instanceof",
"UserCustomerRelation",
")",
"{",
"// it's a model object",
"// invalidate the cache for this single object",
"UserCustomerRelationPeer",
"::",
"removeInstanceFromPool",
"(",
"$",
"values",
")",
";",
"// create criteria based on pk values",
"$",
"criteria",
"=",
"$",
"values",
"->",
"buildPkeyCriteria",
"(",
")",
";",
"}",
"else",
"{",
"// it's a primary key, or an array of pks",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
",",
"(",
"array",
")",
"$",
"values",
",",
"Criteria",
"::",
"IN",
")",
";",
"// invalidate the cache for this object(s)",
"foreach",
"(",
"(",
"array",
")",
"$",
"values",
"as",
"$",
"singleval",
")",
"{",
"UserCustomerRelationPeer",
"::",
"removeInstanceFromPool",
"(",
"$",
"singleval",
")",
";",
"}",
"}",
"// Set the correct dbName",
"$",
"criteria",
"->",
"setDbName",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"affectedRows",
"=",
"0",
";",
"// initialize var to track total num of affected rows",
"try",
"{",
"// use transaction because $criteria could contain info",
"// for more than one table or we could emulating ON DELETE CASCADE, etc.",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"$",
"affectedRows",
"+=",
"BasePeer",
"::",
"doDelete",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"UserCustomerRelationPeer",
"::",
"clearRelatedInstancePool",
"(",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"affectedRows",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollBack",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
]
| Performs a DELETE on the database, given a UserCustomerRelation or Criteria object OR a primary key value.
@param mixed $values Criteria or UserCustomerRelation object or primary key or array of primary keys
which is used to create the DELETE statement
@param PropelPDO $con the connection to use
@return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
if supported by native driver or if emulated using Propel.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"a",
"DELETE",
"on",
"the",
"database",
"given",
"a",
"UserCustomerRelation",
"or",
"Criteria",
"object",
"OR",
"a",
"primary",
"key",
"value",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1261-L1307 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.doValidate | public static function doValidate($obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(UserCustomerRelationPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(UserCustomerRelationPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach ($cols as $colName) {
if ($tableMap->hasColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
return BasePeer::doValidate(UserCustomerRelationPeer::DATABASE_NAME, UserCustomerRelationPeer::TABLE_NAME, $columns);
} | php | public static function doValidate($obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(UserCustomerRelationPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(UserCustomerRelationPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach ($cols as $colName) {
if ($tableMap->hasColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
return BasePeer::doValidate(UserCustomerRelationPeer::DATABASE_NAME, UserCustomerRelationPeer::TABLE_NAME, $columns);
} | [
"public",
"static",
"function",
"doValidate",
"(",
"$",
"obj",
",",
"$",
"cols",
"=",
"null",
")",
"{",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"cols",
")",
"{",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"tableMap",
"=",
"$",
"dbMap",
"->",
"getTable",
"(",
"UserCustomerRelationPeer",
"::",
"TABLE_NAME",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"cols",
")",
")",
"{",
"$",
"cols",
"=",
"array",
"(",
"$",
"cols",
")",
";",
"}",
"foreach",
"(",
"$",
"cols",
"as",
"$",
"colName",
")",
"{",
"if",
"(",
"$",
"tableMap",
"->",
"hasColumn",
"(",
"$",
"colName",
")",
")",
"{",
"$",
"get",
"=",
"'get'",
".",
"$",
"tableMap",
"->",
"getColumn",
"(",
"$",
"colName",
")",
"->",
"getPhpName",
"(",
")",
";",
"$",
"columns",
"[",
"$",
"colName",
"]",
"=",
"$",
"obj",
"->",
"$",
"get",
"(",
")",
";",
"}",
"}",
"}",
"else",
"{",
"}",
"return",
"BasePeer",
"::",
"doValidate",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
",",
"UserCustomerRelationPeer",
"::",
"TABLE_NAME",
",",
"$",
"columns",
")",
";",
"}"
]
| Validates all modified columns of given UserCustomerRelation object.
If parameter $columns is either a single column name or an array of column names
than only those columns are validated.
NOTICE: This does not apply to primary or foreign keys for now.
@param UserCustomerRelation $obj The object to validate.
@param mixed $cols Column name or array of column names.
@return mixed TRUE if all columns are valid or the error message of the first invalid column. | [
"Validates",
"all",
"modified",
"columns",
"of",
"given",
"UserCustomerRelation",
"object",
".",
"If",
"parameter",
"$columns",
"is",
"either",
"a",
"single",
"column",
"name",
"or",
"an",
"array",
"of",
"column",
"names",
"than",
"only",
"those",
"columns",
"are",
"validated",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1321-L1344 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.retrieveByPK | public static function retrieveByPK($pk, PropelPDO $con = null)
{
if (null !== ($obj = UserCustomerRelationPeer::getInstanceFromPool((string) $pk))) {
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, $pk);
$v = UserCustomerRelationPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
} | php | public static function retrieveByPK($pk, PropelPDO $con = null)
{
if (null !== ($obj = UserCustomerRelationPeer::getInstanceFromPool((string) $pk))) {
return $obj;
}
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, $pk);
$v = UserCustomerRelationPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
} | [
"public",
"static",
"function",
"retrieveByPK",
"(",
"$",
"pk",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"obj",
"=",
"UserCustomerRelationPeer",
"::",
"getInstanceFromPool",
"(",
"(",
"string",
")",
"$",
"pk",
")",
")",
")",
"{",
"return",
"$",
"obj",
";",
"}",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
",",
"$",
"pk",
")",
";",
"$",
"v",
"=",
"UserCustomerRelationPeer",
"::",
"doSelect",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"return",
"!",
"empty",
"(",
"$",
"v",
")",
">",
"0",
"?",
"$",
"v",
"[",
"0",
"]",
":",
"null",
";",
"}"
]
| Retrieve a single object by pkey.
@param int $pk the primary key.
@param PropelPDO $con the connection to use
@return UserCustomerRelation | [
"Retrieve",
"a",
"single",
"object",
"by",
"pkey",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1353-L1370 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php | BaseUserCustomerRelationPeer.retrieveByPKs | public static function retrieveByPKs($pks, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, $pks, Criteria::IN);
$objs = UserCustomerRelationPeer::doSelect($criteria, $con);
}
return $objs;
} | php | public static function retrieveByPKs($pks, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(UserCustomerRelationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
$criteria->add(UserCustomerRelationPeer::ID, $pks, Criteria::IN);
$objs = UserCustomerRelationPeer::doSelect($criteria, $con);
}
return $objs;
} | [
"public",
"static",
"function",
"retrieveByPKs",
"(",
"$",
"pks",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"$",
"objs",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"pks",
")",
")",
"{",
"$",
"objs",
"=",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
",",
"$",
"pks",
",",
"Criteria",
"::",
"IN",
")",
";",
"$",
"objs",
"=",
"UserCustomerRelationPeer",
"::",
"doSelect",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"}",
"return",
"$",
"objs",
";",
"}"
]
| Retrieve multiple objects by pkey.
@param array $pks List of primary keys
@param PropelPDO $con the connection to use
@return UserCustomerRelation[]
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Retrieve",
"multiple",
"objects",
"by",
"pkey",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelationPeer.php#L1381-L1397 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.setSettingValue | public function setSettingValue($key, $value) {
if($key == '_orientation' && $value == 'landscape') {
$this->setLandscape();
} elseif($key == '_orientation' && is_null($value)) {
$this->setPortrait();
} elseif($key == '_borderSize') {
$this->setBorderSize($value);
} elseif($key == '_borderColor') {
$this->setBorderColor($value);
} else {
$this->$key = $value;
}
} | php | public function setSettingValue($key, $value) {
if($key == '_orientation' && $value == 'landscape') {
$this->setLandscape();
} elseif($key == '_orientation' && is_null($value)) {
$this->setPortrait();
} elseif($key == '_borderSize') {
$this->setBorderSize($value);
} elseif($key == '_borderColor') {
$this->setBorderColor($value);
} else {
$this->$key = $value;
}
} | [
"public",
"function",
"setSettingValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'_orientation'",
"&&",
"$",
"value",
"==",
"'landscape'",
")",
"{",
"$",
"this",
"->",
"setLandscape",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'_orientation'",
"&&",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"setPortrait",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'_borderSize'",
")",
"{",
"$",
"this",
"->",
"setBorderSize",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'_borderColor'",
")",
"{",
"$",
"this",
"->",
"setBorderColor",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}"
]
| Set Setting Value
@param string $key
@param string $value | [
"Set",
"Setting",
"Value"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L184-L196 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.setLandscape | public function setLandscape() {
$this->_orientation = 'landscape';
$this->_pageSizeW = $this->_defaultPageSizeH;
$this->_pageSizeH = $this->_defaultPageSizeW;
} | php | public function setLandscape() {
$this->_orientation = 'landscape';
$this->_pageSizeW = $this->_defaultPageSizeH;
$this->_pageSizeH = $this->_defaultPageSizeW;
} | [
"public",
"function",
"setLandscape",
"(",
")",
"{",
"$",
"this",
"->",
"_orientation",
"=",
"'landscape'",
";",
"$",
"this",
"->",
"_pageSizeW",
"=",
"$",
"this",
"->",
"_defaultPageSizeH",
";",
"$",
"this",
"->",
"_pageSizeH",
"=",
"$",
"this",
"->",
"_defaultPageSizeW",
";",
"}"
]
| Set Landscape Orientation | [
"Set",
"Landscape",
"Orientation"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L277-L281 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.setPortrait | public function setPortrait() {
$this->_orientation = null;
$this->_pageSizeW = $this->_defaultPageSizeW;
$this->_pageSizeH = $this->_defaultPageSizeH;
} | php | public function setPortrait() {
$this->_orientation = null;
$this->_pageSizeW = $this->_defaultPageSizeW;
$this->_pageSizeH = $this->_defaultPageSizeH;
} | [
"public",
"function",
"setPortrait",
"(",
")",
"{",
"$",
"this",
"->",
"_orientation",
"=",
"null",
";",
"$",
"this",
"->",
"_pageSizeW",
"=",
"$",
"this",
"->",
"_defaultPageSizeW",
";",
"$",
"this",
"->",
"_pageSizeH",
"=",
"$",
"this",
"->",
"_defaultPageSizeH",
";",
"}"
]
| Set Portrait Orientation | [
"Set",
"Portrait",
"Orientation"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L286-L290 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.getBorderSize | public function getBorderSize() {
$t = $this->getBorderTopSize();
$l = $this->getBorderLeftSize();
$r = $this->getBorderRightSize();
$b = $this->getBorderBottomSize();
return array($t, $l, $r, $b);
} | php | public function getBorderSize() {
$t = $this->getBorderTopSize();
$l = $this->getBorderLeftSize();
$r = $this->getBorderRightSize();
$b = $this->getBorderBottomSize();
return array($t, $l, $r, $b);
} | [
"public",
"function",
"getBorderSize",
"(",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"getBorderTopSize",
"(",
")",
";",
"$",
"l",
"=",
"$",
"this",
"->",
"getBorderLeftSize",
"(",
")",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"getBorderRightSize",
"(",
")",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"getBorderBottomSize",
"(",
")",
";",
"return",
"array",
"(",
"$",
"t",
",",
"$",
"l",
",",
"$",
"r",
",",
"$",
"b",
")",
";",
"}"
]
| Get Border Size
@return array | [
"Get",
"Border",
"Size"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L336-L343 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.setBorderColor | public function setBorderColor($pValue = null) {
$this->_borderTopColor = $pValue;
$this->_borderLeftColor = $pValue;
$this->_borderRightColor = $pValue;
$this->_borderBottomColor = $pValue;
} | php | public function setBorderColor($pValue = null) {
$this->_borderTopColor = $pValue;
$this->_borderLeftColor = $pValue;
$this->_borderRightColor = $pValue;
$this->_borderBottomColor = $pValue;
} | [
"public",
"function",
"setBorderColor",
"(",
"$",
"pValue",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_borderTopColor",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderLeftColor",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderRightColor",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderBottomColor",
"=",
"$",
"pValue",
";",
"}"
]
| Set Border Color
@param string $pValue | [
"Set",
"Border",
"Color"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L350-L355 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Settings.php | PHPWord_Section_Settings.getBorderColor | public function getBorderColor() {
$t = $this->getBorderTopColor();
$l = $this->getBorderLeftColor();
$r = $this->getBorderRightColor();
$b = $this->getBorderBottomColor();
return array($t, $l, $r, $b);
} | php | public function getBorderColor() {
$t = $this->getBorderTopColor();
$l = $this->getBorderLeftColor();
$r = $this->getBorderRightColor();
$b = $this->getBorderBottomColor();
return array($t, $l, $r, $b);
} | [
"public",
"function",
"getBorderColor",
"(",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"getBorderTopColor",
"(",
")",
";",
"$",
"l",
"=",
"$",
"this",
"->",
"getBorderLeftColor",
"(",
")",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"getBorderRightColor",
"(",
")",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"getBorderBottomColor",
"(",
")",
";",
"return",
"array",
"(",
"$",
"t",
",",
"$",
"l",
",",
"$",
"r",
",",
"$",
"b",
")",
";",
"}"
]
| Get Border Color
@return array | [
"Get",
"Border",
"Color"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Settings.php#L362-L369 |
miisieq/InfaktClient | src/Infakt/Infakt.php | Infakt.getRepository | public function getRepository(string $className): AbstractObjectRepository
{
$className = 'Infakt\\Repository\\'.substr($className, strrpos($className, '\\') + 1).'Repository';
if (!class_exists($className)) {
throw new LogicException("There is no repository to work with class $className.");
}
return new $className($this);
} | php | public function getRepository(string $className): AbstractObjectRepository
{
$className = 'Infakt\\Repository\\'.substr($className, strrpos($className, '\\') + 1).'Repository';
if (!class_exists($className)) {
throw new LogicException("There is no repository to work with class $className.");
}
return new $className($this);
} | [
"public",
"function",
"getRepository",
"(",
"string",
"$",
"className",
")",
":",
"AbstractObjectRepository",
"{",
"$",
"className",
"=",
"'Infakt\\\\Repository\\\\'",
".",
"substr",
"(",
"$",
"className",
",",
"strrpos",
"(",
"$",
"className",
",",
"'\\\\'",
")",
"+",
"1",
")",
".",
"'Repository'",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"There is no repository to work with class $className.\"",
")",
";",
"}",
"return",
"new",
"$",
"className",
"(",
"$",
"this",
")",
";",
"}"
]
| Return object repository for a specific model class name.
@param $className
@throws LogicException
@return AbstractObjectRepository | [
"Return",
"object",
"repository",
"for",
"a",
"specific",
"model",
"class",
"name",
"."
]
| train | https://github.com/miisieq/InfaktClient/blob/5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81/src/Infakt/Infakt.php#L53-L62 |
miisieq/InfaktClient | src/Infakt/Infakt.php | Infakt.get | public function get(string $query): ResponseInterface
{
return $this->client->request('get', $this->buildQuery($query), ['headers' => $this->getAuthorizationHeader()]);
} | php | public function get(string $query): ResponseInterface
{
return $this->client->request('get', $this->buildQuery($query), ['headers' => $this->getAuthorizationHeader()]);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"query",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'get'",
",",
"$",
"this",
"->",
"buildQuery",
"(",
"$",
"query",
")",
",",
"[",
"'headers'",
"=>",
"$",
"this",
"->",
"getAuthorizationHeader",
"(",
")",
"]",
")",
";",
"}"
]
| Send HTTP GET request.
@param string $query
@return \Psr\Http\Message\ResponseInterface | [
"Send",
"HTTP",
"GET",
"request",
"."
]
| train | https://github.com/miisieq/InfaktClient/blob/5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81/src/Infakt/Infakt.php#L71-L74 |
miisieq/InfaktClient | src/Infakt/Infakt.php | Infakt.post | public function post(string $query, ?string $body = null): ResponseInterface
{
$options = [
'headers' => $this->getAuthorizationHeader(),
];
if ($body) {
$options['body'] = $body;
}
return $this->client->request('post', $this->buildQuery($query), $options);
} | php | public function post(string $query, ?string $body = null): ResponseInterface
{
$options = [
'headers' => $this->getAuthorizationHeader(),
];
if ($body) {
$options['body'] = $body;
}
return $this->client->request('post', $this->buildQuery($query), $options);
} | [
"public",
"function",
"post",
"(",
"string",
"$",
"query",
",",
"?",
"string",
"$",
"body",
"=",
"null",
")",
":",
"ResponseInterface",
"{",
"$",
"options",
"=",
"[",
"'headers'",
"=>",
"$",
"this",
"->",
"getAuthorizationHeader",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"body",
")",
"{",
"$",
"options",
"[",
"'body'",
"]",
"=",
"$",
"body",
";",
"}",
"return",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'post'",
",",
"$",
"this",
"->",
"buildQuery",
"(",
"$",
"query",
")",
",",
"$",
"options",
")",
";",
"}"
]
| Send HTTP POST request.
@param string $query
@param null|string $body
@return \Psr\Http\Message\ResponseInterface | [
"Send",
"HTTP",
"POST",
"request",
"."
]
| train | https://github.com/miisieq/InfaktClient/blob/5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81/src/Infakt/Infakt.php#L96-L107 |
ARCANEDEV/Sanitizer | src/SanitizerServiceProvider.php | SanitizerServiceProvider.registerSanitizer | private function registerSanitizer()
{
$this->singleton(Contracts\Sanitizer::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return new Factory($config->get('sanitizer.filters'));
});
$this->singleton('arcanedev.sanitizer', Contracts\Sanitizer::class);
} | php | private function registerSanitizer()
{
$this->singleton(Contracts\Sanitizer::class, function ($app) {
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $app['config'];
return new Factory($config->get('sanitizer.filters'));
});
$this->singleton('arcanedev.sanitizer', Contracts\Sanitizer::class);
} | [
"private",
"function",
"registerSanitizer",
"(",
")",
"{",
"$",
"this",
"->",
"singleton",
"(",
"Contracts",
"\\",
"Sanitizer",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"/** @var \\Illuminate\\Contracts\\Config\\Repository $config */",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
";",
"return",
"new",
"Factory",
"(",
"$",
"config",
"->",
"get",
"(",
"'sanitizer.filters'",
")",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"singleton",
"(",
"'arcanedev.sanitizer'",
",",
"Contracts",
"\\",
"Sanitizer",
"::",
"class",
")",
";",
"}"
]
| Register Helpers. | [
"Register",
"Helpers",
"."
]
| train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/SanitizerServiceProvider.php#L81-L91 |
digitalkaoz/versioneye-php | src/Output/Github.php | Github.hook | public function hook(OutputInterface $output, array $response)
{
$this->printBoolean($output, 'OK', $response['success'], true === $response['success']);
} | php | public function hook(OutputInterface $output, array $response)
{
$this->printBoolean($output, 'OK', $response['success'], true === $response['success']);
} | [
"public",
"function",
"hook",
"(",
"OutputInterface",
"$",
"output",
",",
"array",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"printBoolean",
"(",
"$",
"output",
",",
"'OK'",
",",
"$",
"response",
"[",
"'success'",
"]",
",",
"true",
"===",
"$",
"response",
"[",
"'success'",
"]",
")",
";",
"}"
]
| output for hook api.
@param OutputInterface $output
@param array $response | [
"output",
"for",
"hook",
"api",
"."
]
| train | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Github.php#L31-L34 |
digitalkaoz/versioneye-php | src/Output/Github.php | Github.delete | public function delete(OutputInterface $output, array $response)
{
$this->printBoolean($output, 'OK', $response['success'], true === $response['success']);
} | php | public function delete(OutputInterface $output, array $response)
{
$this->printBoolean($output, 'OK', $response['success'], true === $response['success']);
} | [
"public",
"function",
"delete",
"(",
"OutputInterface",
"$",
"output",
",",
"array",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"printBoolean",
"(",
"$",
"output",
",",
"'OK'",
",",
"$",
"response",
"[",
"'success'",
"]",
",",
"true",
"===",
"$",
"response",
"[",
"'success'",
"]",
")",
";",
"}"
]
| output for delete api.
@param OutputInterface $output
@param array $response | [
"output",
"for",
"delete",
"api",
"."
]
| train | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Github.php#L42-L45 |
GrahamDeprecated/CMS-Core | src/Seeds/UsersGroupsTableSeeder.php | UsersGroupsTableSeeder.run | public function run()
{
DB::table('users_groups')->delete();
$this->matchUser('[email protected]', 'Admins');
$this->matchUser('[email protected]', 'Moderators');
$this->matchUser('[email protected]', 'Bloggers');
$this->matchUser('[email protected]', 'Editors');
$this->matchUser('[email protected]', 'Moderators');
$this->matchUser('[email protected]', 'Bloggers');
$this->matchUser('[email protected]', 'Editors');
$this->matchUser('[email protected]', 'Users');
} | php | public function run()
{
DB::table('users_groups')->delete();
$this->matchUser('[email protected]', 'Admins');
$this->matchUser('[email protected]', 'Moderators');
$this->matchUser('[email protected]', 'Bloggers');
$this->matchUser('[email protected]', 'Editors');
$this->matchUser('[email protected]', 'Moderators');
$this->matchUser('[email protected]', 'Bloggers');
$this->matchUser('[email protected]', 'Editors');
$this->matchUser('[email protected]', 'Users');
} | [
"public",
"function",
"run",
"(",
")",
"{",
"DB",
"::",
"table",
"(",
"'users_groups'",
")",
"->",
"delete",
"(",
")",
";",
"$",
"this",
"->",
"matchUser",
"(",
"'[email protected]'",
",",
"'Admins'",
")",
";",
"$",
"this",
"->",
"matchUser",
"(",
"'[email protected]'",
",",
"'Moderators'",
")",
";",
"$",
"this",
"->",
"matchUser",
"(",
"'[email protected]'",
",",
"'Bloggers'",
")",
";",
"$",
"this",
"->",
"matchUser",
"(",
"'[email protected]'",
",",
"'Editors'",
")",
";",
"$",
"this",
"->",
"matchUser",
"(",
"'[email protected]'",
",",
"'Moderators'",
")",
";",
"$",
"this",
"->",
"matchUser",
"(",
"'[email protected]'",
",",
"'Bloggers'",
")",
";",
"$",
"this",
"->",
"matchUser",
"(",
"'[email protected]'",
",",
"'Editors'",
")",
";",
"$",
"this",
"->",
"matchUser",
"(",
"'[email protected]'",
",",
"'Users'",
")",
";",
"}"
]
| Run the database seeding.
@return void | [
"Run",
"the",
"database",
"seeding",
"."
]
| train | https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/Seeds/UsersGroupsTableSeeder.php#L39-L51 |
GrahamDeprecated/CMS-Core | src/Seeds/UsersGroupsTableSeeder.php | UsersGroupsTableSeeder.matchUser | protected function matchUser($email, $group)
{
return Credentials::getUserProvider()->findByLogin($email)->addGroup(Credentials::getGroupProvider()->findByName($group));
} | php | protected function matchUser($email, $group)
{
return Credentials::getUserProvider()->findByLogin($email)->addGroup(Credentials::getGroupProvider()->findByName($group));
} | [
"protected",
"function",
"matchUser",
"(",
"$",
"email",
",",
"$",
"group",
")",
"{",
"return",
"Credentials",
"::",
"getUserProvider",
"(",
")",
"->",
"findByLogin",
"(",
"$",
"email",
")",
"->",
"addGroup",
"(",
"Credentials",
"::",
"getGroupProvider",
"(",
")",
"->",
"findByName",
"(",
"$",
"group",
")",
")",
";",
"}"
]
| Add the user by email to a group.
@param string $email
@param string $group
@return void | [
"Add",
"the",
"user",
"by",
"email",
"to",
"a",
"group",
"."
]
| train | https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/Seeds/UsersGroupsTableSeeder.php#L60-L63 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.prefixFromType | public static function prefixFromType($strType)
{
switch ($strType) {
case Type::ARRAY_TYPE:
return "obj";
case Type::BOOLEAN:
return "bln";
case Type::DATE_TIME:
return "dtt";
case Type::FLOAT:
return "flt";
case Type::INTEGER:
return "int";
case Type::OBJECT:
return "obj";
case Type::STRING:
return "str";
}
// Suppressing the IDE warning about no value being return
return "";
} | php | public static function prefixFromType($strType)
{
switch ($strType) {
case Type::ARRAY_TYPE:
return "obj";
case Type::BOOLEAN:
return "bln";
case Type::DATE_TIME:
return "dtt";
case Type::FLOAT:
return "flt";
case Type::INTEGER:
return "int";
case Type::OBJECT:
return "obj";
case Type::STRING:
return "str";
}
// Suppressing the IDE warning about no value being return
return "";
} | [
"public",
"static",
"function",
"prefixFromType",
"(",
"$",
"strType",
")",
"{",
"switch",
"(",
"$",
"strType",
")",
"{",
"case",
"Type",
"::",
"ARRAY_TYPE",
":",
"return",
"\"obj\"",
";",
"case",
"Type",
"::",
"BOOLEAN",
":",
"return",
"\"bln\"",
";",
"case",
"Type",
"::",
"DATE_TIME",
":",
"return",
"\"dtt\"",
";",
"case",
"Type",
"::",
"FLOAT",
":",
"return",
"\"flt\"",
";",
"case",
"Type",
"::",
"INTEGER",
":",
"return",
"\"int\"",
";",
"case",
"Type",
"::",
"OBJECT",
":",
"return",
"\"obj\"",
";",
"case",
"Type",
"::",
"STRING",
":",
"return",
"\"str\"",
";",
"}",
"// Suppressing the IDE warning about no value being return",
"return",
"\"\"",
";",
"}"
]
| Returns prefix for variable according to variable type
@param string $strType The type of variable for which the prefix is needed
@return string The variable prefix
@was QString::PrefixFromType | [
"Returns",
"prefix",
"for",
"variable",
"according",
"to",
"variable",
"type"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L177-L197 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.getInstalledTemplatePaths | public function getInstalledTemplatePaths()
{
$dir = QCUBED_CONFIG_DIR . '/templates';
$paths = [];
if ($dir !== false) { // does the active directory exist?
foreach (scandir($dir) as $strFileName) {
if (substr($strFileName, -8) == '.inc.php') {
$paths2 = include($dir . '/' . $strFileName);
if ($paths2 && is_array($paths2)) {
$paths = array_merge($paths, $paths2);
}
}
}
}
return $paths;
} | php | public function getInstalledTemplatePaths()
{
$dir = QCUBED_CONFIG_DIR . '/templates';
$paths = [];
if ($dir !== false) { // does the active directory exist?
foreach (scandir($dir) as $strFileName) {
if (substr($strFileName, -8) == '.inc.php') {
$paths2 = include($dir . '/' . $strFileName);
if ($paths2 && is_array($paths2)) {
$paths = array_merge($paths, $paths2);
}
}
}
}
return $paths;
} | [
"public",
"function",
"getInstalledTemplatePaths",
"(",
")",
"{",
"$",
"dir",
"=",
"QCUBED_CONFIG_DIR",
".",
"'/templates'",
";",
"$",
"paths",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"dir",
"!==",
"false",
")",
"{",
"// does the active directory exist?",
"foreach",
"(",
"scandir",
"(",
"$",
"dir",
")",
"as",
"$",
"strFileName",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"strFileName",
",",
"-",
"8",
")",
"==",
"'.inc.php'",
")",
"{",
"$",
"paths2",
"=",
"include",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"strFileName",
")",
";",
"if",
"(",
"$",
"paths2",
"&&",
"is_array",
"(",
"$",
"paths2",
")",
")",
"{",
"$",
"paths",
"=",
"array_merge",
"(",
"$",
"paths",
",",
"$",
"paths2",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"paths",
";",
"}"
]
| Return an array of paths to template files. This base class versions searches a config directory for pointers
to template files to use. This allows qcubed repos to inject templates into the codegen process.
This process is similar to how the control registry works. | [
"Return",
"an",
"array",
"of",
"paths",
"to",
"template",
"files",
".",
"This",
"base",
"class",
"versions",
"searches",
"a",
"config",
"directory",
"for",
"pointers",
"to",
"template",
"files",
"to",
"use",
".",
"This",
"allows",
"qcubed",
"repos",
"to",
"inject",
"templates",
"into",
"the",
"codegen",
"process",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L205-L223 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.getSettingsXml | public static function getSettingsXml()
{
$strCrLf = "\r\n";
$strToReturn = sprintf('<codegen>%s', $strCrLf);
$strToReturn .= sprintf(' <name application="%s"/>%s', Codegen::$ApplicationName, $strCrLf);
$strToReturn .= sprintf(' <render preferredRenderMethod="%s"/>%s', Codegen::$PreferredRenderMethod,
$strCrLf);
$strToReturn .= sprintf(' <dataSources>%s', $strCrLf);
foreach (Codegen::$CodeGenArray as $objCodeGen) {
$strToReturn .= $strCrLf . $objCodeGen->getConfigXml();
}
$strToReturn .= sprintf('%s </dataSources>%s', $strCrLf, $strCrLf);
$strToReturn .= '</codegen>';
return $strToReturn;
} | php | public static function getSettingsXml()
{
$strCrLf = "\r\n";
$strToReturn = sprintf('<codegen>%s', $strCrLf);
$strToReturn .= sprintf(' <name application="%s"/>%s', Codegen::$ApplicationName, $strCrLf);
$strToReturn .= sprintf(' <render preferredRenderMethod="%s"/>%s', Codegen::$PreferredRenderMethod,
$strCrLf);
$strToReturn .= sprintf(' <dataSources>%s', $strCrLf);
foreach (Codegen::$CodeGenArray as $objCodeGen) {
$strToReturn .= $strCrLf . $objCodeGen->getConfigXml();
}
$strToReturn .= sprintf('%s </dataSources>%s', $strCrLf, $strCrLf);
$strToReturn .= '</codegen>';
return $strToReturn;
} | [
"public",
"static",
"function",
"getSettingsXml",
"(",
")",
"{",
"$",
"strCrLf",
"=",
"\"\\r\\n\"",
";",
"$",
"strToReturn",
"=",
"sprintf",
"(",
"'<codegen>%s'",
",",
"$",
"strCrLf",
")",
";",
"$",
"strToReturn",
".=",
"sprintf",
"(",
"'\t<name application=\"%s\"/>%s'",
",",
"Codegen",
"::",
"$",
"ApplicationName",
",",
"$",
"strCrLf",
")",
";",
"$",
"strToReturn",
".=",
"sprintf",
"(",
"'\t<render preferredRenderMethod=\"%s\"/>%s'",
",",
"Codegen",
"::",
"$",
"PreferredRenderMethod",
",",
"$",
"strCrLf",
")",
";",
"$",
"strToReturn",
".=",
"sprintf",
"(",
"'\t<dataSources>%s'",
",",
"$",
"strCrLf",
")",
";",
"foreach",
"(",
"Codegen",
"::",
"$",
"CodeGenArray",
"as",
"$",
"objCodeGen",
")",
"{",
"$",
"strToReturn",
".=",
"$",
"strCrLf",
".",
"$",
"objCodeGen",
"->",
"getConfigXml",
"(",
")",
";",
"}",
"$",
"strToReturn",
".=",
"sprintf",
"(",
"'%s\t</dataSources>%s'",
",",
"$",
"strCrLf",
",",
"$",
"strCrLf",
")",
";",
"$",
"strToReturn",
".=",
"'</codegen>'",
";",
"return",
"$",
"strToReturn",
";",
"}"
]
| Gets the settings in codegen_settings.xml file and returns its text without comments
@return string | [
"Gets",
"the",
"settings",
"in",
"codegen_settings",
".",
"xml",
"file",
"and",
"returns",
"its",
"text",
"without",
"comments"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L230-L246 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.run | public static function run($strSettingsXmlFilePath)
{
if (!defined('QCUBED_CODE_GENERATING')) {
define('QCUBED_CODE_GENERATING', true);
}
Codegen::$CodeGenArray = array();
Codegen::$SettingsFilePath = $strSettingsXmlFilePath;
if (!file_exists($strSettingsXmlFilePath)) {
Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
return;
}
if (!is_file($strSettingsXmlFilePath)) {
Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
return;
}
// Try Parsing the Xml Settings File
try {
$errorHandler = new Error\Handler('\\QCubed\\Codegen\\QcubedHandleCodeGenParseError', E_ALL);
Codegen::$SettingsXml = new \SimpleXMLElement(file_get_contents($strSettingsXmlFilePath));
$errorHandler->restore();
} catch (\Exception $objExc) {
Codegen::$RootErrors .= 'FATAL ERROR: Unable to parse CodeGenSettings XML File: ' . $strSettingsXmlFilePath;
Codegen::$RootErrors .= "\r\n";
Codegen::$RootErrors .= $objExc->getMessage();
return;
}
// Application Name
Codegen::$ApplicationName = Codegen::lookupSetting(Codegen::$SettingsXml, 'name', 'application');
// Codegen Defaults
Codegen::$PreferredRenderMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen',
'preferredRenderMethod');
Codegen::$CreateMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'createMethod');
Codegen::$DefaultButtonClass = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'buttonClass');
if (!Codegen::$DefaultButtonClass) {
Codegen::$RootErrors .= "CodeGen Settings XML Fatal Error: buttonClass was not defined\r\n";
return;
}
// Iterate Through DataSources
if (Codegen::$SettingsXml->dataSources->asXML()) {
foreach (Codegen::$SettingsXml->dataSources->children() as $objChildNode) {
switch (dom_import_simplexml($objChildNode)->nodeName) {
case 'database':
Codegen::$CodeGenArray[] = new DatabaseCodeGen($objChildNode);
break;
case 'restService':
Codegen::$CodeGenArray[] = new RestServiceCodeGen($objChildNode);
break;
default:
Codegen::$RootErrors .= sprintf("Invalid Data Source Type in CodeGen Settings XML File (%s): %s\r\n",
$strSettingsXmlFilePath, dom_import_simplexml($objChildNode)->nodeName);
break;
}
}
}
} | php | public static function run($strSettingsXmlFilePath)
{
if (!defined('QCUBED_CODE_GENERATING')) {
define('QCUBED_CODE_GENERATING', true);
}
Codegen::$CodeGenArray = array();
Codegen::$SettingsFilePath = $strSettingsXmlFilePath;
if (!file_exists($strSettingsXmlFilePath)) {
Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
return;
}
if (!is_file($strSettingsXmlFilePath)) {
Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
return;
}
// Try Parsing the Xml Settings File
try {
$errorHandler = new Error\Handler('\\QCubed\\Codegen\\QcubedHandleCodeGenParseError', E_ALL);
Codegen::$SettingsXml = new \SimpleXMLElement(file_get_contents($strSettingsXmlFilePath));
$errorHandler->restore();
} catch (\Exception $objExc) {
Codegen::$RootErrors .= 'FATAL ERROR: Unable to parse CodeGenSettings XML File: ' . $strSettingsXmlFilePath;
Codegen::$RootErrors .= "\r\n";
Codegen::$RootErrors .= $objExc->getMessage();
return;
}
// Application Name
Codegen::$ApplicationName = Codegen::lookupSetting(Codegen::$SettingsXml, 'name', 'application');
// Codegen Defaults
Codegen::$PreferredRenderMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen',
'preferredRenderMethod');
Codegen::$CreateMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'createMethod');
Codegen::$DefaultButtonClass = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'buttonClass');
if (!Codegen::$DefaultButtonClass) {
Codegen::$RootErrors .= "CodeGen Settings XML Fatal Error: buttonClass was not defined\r\n";
return;
}
// Iterate Through DataSources
if (Codegen::$SettingsXml->dataSources->asXML()) {
foreach (Codegen::$SettingsXml->dataSources->children() as $objChildNode) {
switch (dom_import_simplexml($objChildNode)->nodeName) {
case 'database':
Codegen::$CodeGenArray[] = new DatabaseCodeGen($objChildNode);
break;
case 'restService':
Codegen::$CodeGenArray[] = new RestServiceCodeGen($objChildNode);
break;
default:
Codegen::$RootErrors .= sprintf("Invalid Data Source Type in CodeGen Settings XML File (%s): %s\r\n",
$strSettingsXmlFilePath, dom_import_simplexml($objChildNode)->nodeName);
break;
}
}
}
} | [
"public",
"static",
"function",
"run",
"(",
"$",
"strSettingsXmlFilePath",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'QCUBED_CODE_GENERATING'",
")",
")",
"{",
"define",
"(",
"'QCUBED_CODE_GENERATING'",
",",
"true",
")",
";",
"}",
"Codegen",
"::",
"$",
"CodeGenArray",
"=",
"array",
"(",
")",
";",
"Codegen",
"::",
"$",
"SettingsFilePath",
"=",
"$",
"strSettingsXmlFilePath",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"strSettingsXmlFilePath",
")",
")",
"{",
"Codegen",
"::",
"$",
"RootErrors",
"=",
"'FATAL ERROR: CodeGen Settings XML File ('",
".",
"$",
"strSettingsXmlFilePath",
".",
"') was not found.'",
";",
"return",
";",
"}",
"if",
"(",
"!",
"is_file",
"(",
"$",
"strSettingsXmlFilePath",
")",
")",
"{",
"Codegen",
"::",
"$",
"RootErrors",
"=",
"'FATAL ERROR: CodeGen Settings XML File ('",
".",
"$",
"strSettingsXmlFilePath",
".",
"') was not found.'",
";",
"return",
";",
"}",
"// Try Parsing the Xml Settings File",
"try",
"{",
"$",
"errorHandler",
"=",
"new",
"Error",
"\\",
"Handler",
"(",
"'\\\\QCubed\\\\Codegen\\\\QcubedHandleCodeGenParseError'",
",",
"E_ALL",
")",
";",
"Codegen",
"::",
"$",
"SettingsXml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"file_get_contents",
"(",
"$",
"strSettingsXmlFilePath",
")",
")",
";",
"$",
"errorHandler",
"->",
"restore",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"objExc",
")",
"{",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"'FATAL ERROR: Unable to parse CodeGenSettings XML File: '",
".",
"$",
"strSettingsXmlFilePath",
";",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"\"\\r\\n\"",
";",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"$",
"objExc",
"->",
"getMessage",
"(",
")",
";",
"return",
";",
"}",
"// Application Name",
"Codegen",
"::",
"$",
"ApplicationName",
"=",
"Codegen",
"::",
"lookupSetting",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
",",
"'name'",
",",
"'application'",
")",
";",
"// Codegen Defaults",
"Codegen",
"::",
"$",
"PreferredRenderMethod",
"=",
"Codegen",
"::",
"lookupSetting",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
",",
"'formgen'",
",",
"'preferredRenderMethod'",
")",
";",
"Codegen",
"::",
"$",
"CreateMethod",
"=",
"Codegen",
"::",
"lookupSetting",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
",",
"'formgen'",
",",
"'createMethod'",
")",
";",
"Codegen",
"::",
"$",
"DefaultButtonClass",
"=",
"Codegen",
"::",
"lookupSetting",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
",",
"'formgen'",
",",
"'buttonClass'",
")",
";",
"if",
"(",
"!",
"Codegen",
"::",
"$",
"DefaultButtonClass",
")",
"{",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"\"CodeGen Settings XML Fatal Error: buttonClass was not defined\\r\\n\"",
";",
"return",
";",
"}",
"// Iterate Through DataSources",
"if",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
"->",
"dataSources",
"->",
"asXML",
"(",
")",
")",
"{",
"foreach",
"(",
"Codegen",
"::",
"$",
"SettingsXml",
"->",
"dataSources",
"->",
"children",
"(",
")",
"as",
"$",
"objChildNode",
")",
"{",
"switch",
"(",
"dom_import_simplexml",
"(",
"$",
"objChildNode",
")",
"->",
"nodeName",
")",
"{",
"case",
"'database'",
":",
"Codegen",
"::",
"$",
"CodeGenArray",
"[",
"]",
"=",
"new",
"DatabaseCodeGen",
"(",
"$",
"objChildNode",
")",
";",
"break",
";",
"case",
"'restService'",
":",
"Codegen",
"::",
"$",
"CodeGenArray",
"[",
"]",
"=",
"new",
"RestServiceCodeGen",
"(",
"$",
"objChildNode",
")",
";",
"break",
";",
"default",
":",
"Codegen",
"::",
"$",
"RootErrors",
".=",
"sprintf",
"(",
"\"Invalid Data Source Type in CodeGen Settings XML File (%s): %s\\r\\n\"",
",",
"$",
"strSettingsXmlFilePath",
",",
"dom_import_simplexml",
"(",
"$",
"objChildNode",
")",
"->",
"nodeName",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
]
| The function which actually performs the steps for code generation
Code generation begins here.
@param string $strSettingsXmlFilePath Path to the settings file | [
"The",
"function",
"which",
"actually",
"performs",
"the",
"steps",
"for",
"code",
"generation",
"Code",
"generation",
"begins",
"here",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L253-L315 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.lookupSetting | static public function lookupSetting($objNode, $strTagName, $strAttributeName = null, $strType = Type::STRING)
{
if ($strTagName) {
$objNode = $objNode->$strTagName;
}
if ($strAttributeName) {
switch ($strType) {
case Type::INTEGER:
try {
$intToReturn = Type::cast($objNode[$strAttributeName], Type::INTEGER);
return $intToReturn;
} catch (\Exception $objExc) {
return null;
}
case Type::BOOLEAN:
try {
$blnToReturn = Type::cast($objNode[$strAttributeName], Type::BOOLEAN);
return $blnToReturn;
} catch (\Exception $objExc) {
return null;
}
default:
$strToReturn = trim(Type::cast($objNode[$strAttributeName], Type::STRING));
return $strToReturn;
}
} else {
$strToReturn = trim(Type::cast($objNode, Type::STRING));
return $strToReturn;
}
} | php | static public function lookupSetting($objNode, $strTagName, $strAttributeName = null, $strType = Type::STRING)
{
if ($strTagName) {
$objNode = $objNode->$strTagName;
}
if ($strAttributeName) {
switch ($strType) {
case Type::INTEGER:
try {
$intToReturn = Type::cast($objNode[$strAttributeName], Type::INTEGER);
return $intToReturn;
} catch (\Exception $objExc) {
return null;
}
case Type::BOOLEAN:
try {
$blnToReturn = Type::cast($objNode[$strAttributeName], Type::BOOLEAN);
return $blnToReturn;
} catch (\Exception $objExc) {
return null;
}
default:
$strToReturn = trim(Type::cast($objNode[$strAttributeName], Type::STRING));
return $strToReturn;
}
} else {
$strToReturn = trim(Type::cast($objNode, Type::STRING));
return $strToReturn;
}
} | [
"static",
"public",
"function",
"lookupSetting",
"(",
"$",
"objNode",
",",
"$",
"strTagName",
",",
"$",
"strAttributeName",
"=",
"null",
",",
"$",
"strType",
"=",
"Type",
"::",
"STRING",
")",
"{",
"if",
"(",
"$",
"strTagName",
")",
"{",
"$",
"objNode",
"=",
"$",
"objNode",
"->",
"$",
"strTagName",
";",
"}",
"if",
"(",
"$",
"strAttributeName",
")",
"{",
"switch",
"(",
"$",
"strType",
")",
"{",
"case",
"Type",
"::",
"INTEGER",
":",
"try",
"{",
"$",
"intToReturn",
"=",
"Type",
"::",
"cast",
"(",
"$",
"objNode",
"[",
"$",
"strAttributeName",
"]",
",",
"Type",
"::",
"INTEGER",
")",
";",
"return",
"$",
"intToReturn",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"objExc",
")",
"{",
"return",
"null",
";",
"}",
"case",
"Type",
"::",
"BOOLEAN",
":",
"try",
"{",
"$",
"blnToReturn",
"=",
"Type",
"::",
"cast",
"(",
"$",
"objNode",
"[",
"$",
"strAttributeName",
"]",
",",
"Type",
"::",
"BOOLEAN",
")",
";",
"return",
"$",
"blnToReturn",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"objExc",
")",
"{",
"return",
"null",
";",
"}",
"default",
":",
"$",
"strToReturn",
"=",
"trim",
"(",
"Type",
"::",
"cast",
"(",
"$",
"objNode",
"[",
"$",
"strAttributeName",
"]",
",",
"Type",
"::",
"STRING",
")",
")",
";",
"return",
"$",
"strToReturn",
";",
"}",
"}",
"else",
"{",
"$",
"strToReturn",
"=",
"trim",
"(",
"Type",
"::",
"cast",
"(",
"$",
"objNode",
",",
"Type",
"::",
"STRING",
")",
")",
";",
"return",
"$",
"strToReturn",
";",
"}",
"}"
]
| This will lookup either the node value (if no attributename is passed in) or the attribute value
for a given Tag. Node Searches only apply from the root level of the configuration XML being passed in
(e.g. it will not be able to lookup the tag name of a grandchild of the root node)
If No Tag Name is passed in, then attribute/value lookup is based on the root node, itself.
@param \SimpleXmlElement $objNode
@param string $strTagName
@param string $strAttributeName
@param string $strType
@return mixed the return type depends on the Type you pass in to $strType | [
"This",
"will",
"lookup",
"either",
"the",
"node",
"value",
"(",
"if",
"no",
"attributename",
"is",
"passed",
"in",
")",
"or",
"the",
"attribute",
"value",
"for",
"a",
"given",
"Tag",
".",
"Node",
"Searches",
"only",
"apply",
"from",
"the",
"root",
"level",
"of",
"the",
"configuration",
"XML",
"being",
"passed",
"in",
"(",
"e",
".",
"g",
".",
"it",
"will",
"not",
"be",
"able",
"to",
"lookup",
"the",
"tag",
"name",
"of",
"a",
"grandchild",
"of",
"the",
"root",
"node",
")"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L330-L360 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.generateFiles | public function generateFiles($strTemplatePrefix, $mixArgumentArray)
{
// If you are editing core templates, and getting EOF errors only on the travis build, this may be your problem. Scan your files and remove short tags.
if (Codegen::DEBUG_MODE && ini_get('short_open_tag')) {
_p("Warning: PHP directive short_open_tag is on. Using short tags will cause unexpected EOF on travis build.\n",
false);
}
// validate the template paths
foreach (static::$TemplatePaths as $strPath) {
if (!is_dir($strPath)) {
throw new \Exception(sprintf("Template path: %s does not appear to be a valid directory.", $strPath));
}
}
// Create an array of arrays of standard templates and custom (override) templates to process
// Index by [module_name][filename] => true/false where
// module name (e.g. "class_gen", "form_delegates) is name of folder within the prefix (e.g. "db_orm")
// filename is the template filename itself (in a _*.tpl format)
// true = override (use custom) and false = do not override (use standard)
$strTemplateArray = array();
// Go through standard templates first, then override in order
foreach (static::$TemplatePaths as $strPath) {
$this->buildTemplateArray($strPath . $strTemplatePrefix, $strTemplateArray);
}
// Finally, iterate through all the TemplateFiles and call GenerateFile to Evaluate/Generate/Save them
$blnSuccess = true;
foreach ($strTemplateArray as $strModuleName => $strFileArray) {
foreach ($strFileArray as $strFilename => $strPath) {
if (!$this->generateFile($strTemplatePrefix . '/' . $strModuleName, $strPath, $mixArgumentArray)) {
$blnSuccess = false;
}
}
}
return $blnSuccess;
} | php | public function generateFiles($strTemplatePrefix, $mixArgumentArray)
{
// If you are editing core templates, and getting EOF errors only on the travis build, this may be your problem. Scan your files and remove short tags.
if (Codegen::DEBUG_MODE && ini_get('short_open_tag')) {
_p("Warning: PHP directive short_open_tag is on. Using short tags will cause unexpected EOF on travis build.\n",
false);
}
// validate the template paths
foreach (static::$TemplatePaths as $strPath) {
if (!is_dir($strPath)) {
throw new \Exception(sprintf("Template path: %s does not appear to be a valid directory.", $strPath));
}
}
// Create an array of arrays of standard templates and custom (override) templates to process
// Index by [module_name][filename] => true/false where
// module name (e.g. "class_gen", "form_delegates) is name of folder within the prefix (e.g. "db_orm")
// filename is the template filename itself (in a _*.tpl format)
// true = override (use custom) and false = do not override (use standard)
$strTemplateArray = array();
// Go through standard templates first, then override in order
foreach (static::$TemplatePaths as $strPath) {
$this->buildTemplateArray($strPath . $strTemplatePrefix, $strTemplateArray);
}
// Finally, iterate through all the TemplateFiles and call GenerateFile to Evaluate/Generate/Save them
$blnSuccess = true;
foreach ($strTemplateArray as $strModuleName => $strFileArray) {
foreach ($strFileArray as $strFilename => $strPath) {
if (!$this->generateFile($strTemplatePrefix . '/' . $strModuleName, $strPath, $mixArgumentArray)) {
$blnSuccess = false;
}
}
}
return $blnSuccess;
} | [
"public",
"function",
"generateFiles",
"(",
"$",
"strTemplatePrefix",
",",
"$",
"mixArgumentArray",
")",
"{",
"// If you are editing core templates, and getting EOF errors only on the travis build, this may be your problem. Scan your files and remove short tags.",
"if",
"(",
"Codegen",
"::",
"DEBUG_MODE",
"&&",
"ini_get",
"(",
"'short_open_tag'",
")",
")",
"{",
"_p",
"(",
"\"Warning: PHP directive short_open_tag is on. Using short tags will cause unexpected EOF on travis build.\\n\"",
",",
"false",
")",
";",
"}",
"// validate the template paths",
"foreach",
"(",
"static",
"::",
"$",
"TemplatePaths",
"as",
"$",
"strPath",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"strPath",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"Template path: %s does not appear to be a valid directory.\"",
",",
"$",
"strPath",
")",
")",
";",
"}",
"}",
"// Create an array of arrays of standard templates and custom (override) templates to process",
"// Index by [module_name][filename] => true/false where",
"// module name (e.g. \"class_gen\", \"form_delegates) is name of folder within the prefix (e.g. \"db_orm\")",
"// filename is the template filename itself (in a _*.tpl format)",
"// true = override (use custom) and false = do not override (use standard)",
"$",
"strTemplateArray",
"=",
"array",
"(",
")",
";",
"// Go through standard templates first, then override in order",
"foreach",
"(",
"static",
"::",
"$",
"TemplatePaths",
"as",
"$",
"strPath",
")",
"{",
"$",
"this",
"->",
"buildTemplateArray",
"(",
"$",
"strPath",
".",
"$",
"strTemplatePrefix",
",",
"$",
"strTemplateArray",
")",
";",
"}",
"// Finally, iterate through all the TemplateFiles and call GenerateFile to Evaluate/Generate/Save them",
"$",
"blnSuccess",
"=",
"true",
";",
"foreach",
"(",
"$",
"strTemplateArray",
"as",
"$",
"strModuleName",
"=>",
"$",
"strFileArray",
")",
"{",
"foreach",
"(",
"$",
"strFileArray",
"as",
"$",
"strFilename",
"=>",
"$",
"strPath",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"generateFile",
"(",
"$",
"strTemplatePrefix",
".",
"'/'",
".",
"$",
"strModuleName",
",",
"$",
"strPath",
",",
"$",
"mixArgumentArray",
")",
")",
"{",
"$",
"blnSuccess",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"$",
"blnSuccess",
";",
"}"
]
| Given a template prefix (e.g. db_orm_, db_type_, rest_, soap_, etc.), pull
all the _*.tpl templates from any subfolders of the template prefix
in Codegen::TemplatesPath and Codegen::TemplatesPathCustom,
and call GenerateFile() on each one. If there are any template files that reside
in BOTH TemplatesPath AND TemplatesPathCustom, then only use the TemplatesPathCustom one (which
in essence overrides the one in TemplatesPath)
@param string $strTemplatePrefix the prefix of the templates you want to generate against
@param mixed[] $mixArgumentArray array of arguments to send to EvaluateTemplate
@throws \Exception
@throws Caller
@return boolean success/failure on whether or not all the files generated successfully | [
"Given",
"a",
"template",
"prefix",
"(",
"e",
".",
"g",
".",
"db_orm_",
"db_type_",
"rest_",
"soap_",
"etc",
".",
")",
"pull",
"all",
"the",
"_",
"*",
".",
"tpl",
"templates",
"from",
"any",
"subfolders",
"of",
"the",
"template",
"prefix",
"in",
"Codegen",
"::",
"TemplatesPath",
"and",
"Codegen",
"::",
"TemplatesPathCustom",
"and",
"call",
"GenerateFile",
"()",
"on",
"each",
"one",
".",
"If",
"there",
"are",
"any",
"template",
"files",
"that",
"reside",
"in",
"BOTH",
"TemplatesPath",
"AND",
"TemplatesPathCustom",
"then",
"only",
"use",
"the",
"TemplatesPathCustom",
"one",
"(",
"which",
"in",
"essence",
"overrides",
"the",
"one",
"in",
"TemplatesPath",
")"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L402-L440 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.getTemplateSettings | protected function getTemplateSettings($strTemplateFilePath, &$strTemplate = null)
{
if ($strTemplate === null) {
$strTemplate = file_get_contents($strTemplateFilePath);
}
$strError = 'Template\'s first line must be <template OverwriteFlag="boolean" TargetDirectory="string" DirectorySuffix="string" TargetFileName="string"/>: ' . $strTemplateFilePath;
// Parse out the first line (which contains path and overwriting information)
$intPosition = strpos($strTemplate, "\n");
if ($intPosition === false) {
throw new \Exception($strError);
}
$strFirstLine = trim(substr($strTemplate, 0, $intPosition));
$objTemplateXml = null;
// Attempt to Parse the First Line as XML
try {
@$objTemplateXml = new \SimpleXMLElement($strFirstLine);
} catch (\Exception $objExc) {
}
if (is_null($objTemplateXml) || (!($objTemplateXml instanceof \SimpleXMLElement))) {
throw new \Exception($strError);
}
$strTemplate = substr($strTemplate, $intPosition + 1);
return $objTemplateXml;
} | php | protected function getTemplateSettings($strTemplateFilePath, &$strTemplate = null)
{
if ($strTemplate === null) {
$strTemplate = file_get_contents($strTemplateFilePath);
}
$strError = 'Template\'s first line must be <template OverwriteFlag="boolean" TargetDirectory="string" DirectorySuffix="string" TargetFileName="string"/>: ' . $strTemplateFilePath;
// Parse out the first line (which contains path and overwriting information)
$intPosition = strpos($strTemplate, "\n");
if ($intPosition === false) {
throw new \Exception($strError);
}
$strFirstLine = trim(substr($strTemplate, 0, $intPosition));
$objTemplateXml = null;
// Attempt to Parse the First Line as XML
try {
@$objTemplateXml = new \SimpleXMLElement($strFirstLine);
} catch (\Exception $objExc) {
}
if (is_null($objTemplateXml) || (!($objTemplateXml instanceof \SimpleXMLElement))) {
throw new \Exception($strError);
}
$strTemplate = substr($strTemplate, $intPosition + 1);
return $objTemplateXml;
} | [
"protected",
"function",
"getTemplateSettings",
"(",
"$",
"strTemplateFilePath",
",",
"&",
"$",
"strTemplate",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"strTemplate",
"===",
"null",
")",
"{",
"$",
"strTemplate",
"=",
"file_get_contents",
"(",
"$",
"strTemplateFilePath",
")",
";",
"}",
"$",
"strError",
"=",
"'Template\\'s first line must be <template OverwriteFlag=\"boolean\" TargetDirectory=\"string\" DirectorySuffix=\"string\" TargetFileName=\"string\"/>: '",
".",
"$",
"strTemplateFilePath",
";",
"// Parse out the first line (which contains path and overwriting information)",
"$",
"intPosition",
"=",
"strpos",
"(",
"$",
"strTemplate",
",",
"\"\\n\"",
")",
";",
"if",
"(",
"$",
"intPosition",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"strError",
")",
";",
"}",
"$",
"strFirstLine",
"=",
"trim",
"(",
"substr",
"(",
"$",
"strTemplate",
",",
"0",
",",
"$",
"intPosition",
")",
")",
";",
"$",
"objTemplateXml",
"=",
"null",
";",
"// Attempt to Parse the First Line as XML",
"try",
"{",
"@",
"$",
"objTemplateXml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"$",
"strFirstLine",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"objExc",
")",
"{",
"}",
"if",
"(",
"is_null",
"(",
"$",
"objTemplateXml",
")",
"||",
"(",
"!",
"(",
"$",
"objTemplateXml",
"instanceof",
"\\",
"SimpleXMLElement",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"strError",
")",
";",
"}",
"$",
"strTemplate",
"=",
"substr",
"(",
"$",
"strTemplate",
",",
"$",
"intPosition",
"+",
"1",
")",
";",
"return",
"$",
"objTemplateXml",
";",
"}"
]
| Returns the settings of the template file as SimpleXMLElement object
@param null|string $strTemplateFilePath Path to the file
@param null|string $strTemplate Text of the template (if $strTemplateFilePath is null, this field must be string)
@deprecated
@return \SimpleXMLElement
@throws \Exception | [
"Returns",
"the",
"settings",
"of",
"the",
"template",
"file",
"as",
"SimpleXMLElement",
"object"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L479-L505 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.generateFile | public function generateFile($strModuleSubPath, $strTemplateFilePath, $mixArgumentArray, $blnSave = true)
{
// Setup Debug/Exception Message
if (Codegen::DEBUG_MODE) {
echo("Evaluating $strTemplateFilePath<br/>");
}
// Check to see if the template file exists, and if it does, Load It
if (!file_exists($strTemplateFilePath)) {
throw new Caller('Template File Not Found: ' . $strTemplateFilePath);
}
// Evaluate the Template
// make sure paths are set up to pick up included files from the various directories.
// Must be the reverse of the buildTemplateArray order
$a = array();
foreach (static::$TemplatePaths as $strTemplatePath) {
array_unshift($a, $strTemplatePath . $strModuleSubPath);
}
$strSearchPath = implode(PATH_SEPARATOR, $a) . PATH_SEPARATOR . get_include_path();
$strOldIncludePath = set_include_path($strSearchPath);
if ($strSearchPath != get_include_path()) {
throw new Caller ('Can\'t override include path. Make sure your apache or server settings allow include paths to be overridden. ');
}
$strTemplate = $this->evaluatePHP($strTemplateFilePath, $mixArgumentArray, $templateSettings);
set_include_path($strOldIncludePath);
$blnOverwriteFlag = Type::cast($templateSettings['OverwriteFlag'], Type::BOOLEAN);
$strTargetDirectory = Type::cast($templateSettings['TargetDirectory'], Type::STRING);
$strDirectorySuffix = Type::cast($templateSettings['DirectorySuffix'], Type::STRING);
$strTargetFileName = Type::cast($templateSettings['TargetFileName'], Type::STRING);
if (is_null($blnOverwriteFlag) || is_null($strTargetFileName) || is_null($strTargetDirectory) || is_null($strDirectorySuffix)) {
throw new \Exception('the template settings cannot be null');
}
if ($blnSave && $strTargetDirectory) {
// Figure out the REAL target directory
$strTargetDirectory = $strTargetDirectory . $strDirectorySuffix;
// Create Directory (if needed)
if (!is_dir($strTargetDirectory)) {
if (!Folder::makeDirectory($strTargetDirectory, 0777)) {
throw new \Exception('Unable to mkdir ' . $strTargetDirectory);
}
}
// Save to Disk
$strFilePath = sprintf('%s/%s', $strTargetDirectory, $strTargetFileName);
if ($blnOverwriteFlag || (!file_exists($strFilePath))) {
$intBytesSaved = file_put_contents($strFilePath, $strTemplate);
$this->setGeneratedFilePermissions($strFilePath);
return ($intBytesSaved == strlen($strTemplate));
} else // Becuase we are not supposed to overwrite, we should return "true" by default
{
return true;
}
}
// Why Did We Not Save?
if ($blnSave) {
// We WANT to Save, but QCubed Configuration says that this functionality/feature should no longer be generated
// By definition, we should return "true"
return true;
}
// Running GenerateFile() specifically asking it not to save -- so return the evaluated template instead
return $strTemplate;
} | php | public function generateFile($strModuleSubPath, $strTemplateFilePath, $mixArgumentArray, $blnSave = true)
{
// Setup Debug/Exception Message
if (Codegen::DEBUG_MODE) {
echo("Evaluating $strTemplateFilePath<br/>");
}
// Check to see if the template file exists, and if it does, Load It
if (!file_exists($strTemplateFilePath)) {
throw new Caller('Template File Not Found: ' . $strTemplateFilePath);
}
// Evaluate the Template
// make sure paths are set up to pick up included files from the various directories.
// Must be the reverse of the buildTemplateArray order
$a = array();
foreach (static::$TemplatePaths as $strTemplatePath) {
array_unshift($a, $strTemplatePath . $strModuleSubPath);
}
$strSearchPath = implode(PATH_SEPARATOR, $a) . PATH_SEPARATOR . get_include_path();
$strOldIncludePath = set_include_path($strSearchPath);
if ($strSearchPath != get_include_path()) {
throw new Caller ('Can\'t override include path. Make sure your apache or server settings allow include paths to be overridden. ');
}
$strTemplate = $this->evaluatePHP($strTemplateFilePath, $mixArgumentArray, $templateSettings);
set_include_path($strOldIncludePath);
$blnOverwriteFlag = Type::cast($templateSettings['OverwriteFlag'], Type::BOOLEAN);
$strTargetDirectory = Type::cast($templateSettings['TargetDirectory'], Type::STRING);
$strDirectorySuffix = Type::cast($templateSettings['DirectorySuffix'], Type::STRING);
$strTargetFileName = Type::cast($templateSettings['TargetFileName'], Type::STRING);
if (is_null($blnOverwriteFlag) || is_null($strTargetFileName) || is_null($strTargetDirectory) || is_null($strDirectorySuffix)) {
throw new \Exception('the template settings cannot be null');
}
if ($blnSave && $strTargetDirectory) {
// Figure out the REAL target directory
$strTargetDirectory = $strTargetDirectory . $strDirectorySuffix;
// Create Directory (if needed)
if (!is_dir($strTargetDirectory)) {
if (!Folder::makeDirectory($strTargetDirectory, 0777)) {
throw new \Exception('Unable to mkdir ' . $strTargetDirectory);
}
}
// Save to Disk
$strFilePath = sprintf('%s/%s', $strTargetDirectory, $strTargetFileName);
if ($blnOverwriteFlag || (!file_exists($strFilePath))) {
$intBytesSaved = file_put_contents($strFilePath, $strTemplate);
$this->setGeneratedFilePermissions($strFilePath);
return ($intBytesSaved == strlen($strTemplate));
} else // Becuase we are not supposed to overwrite, we should return "true" by default
{
return true;
}
}
// Why Did We Not Save?
if ($blnSave) {
// We WANT to Save, but QCubed Configuration says that this functionality/feature should no longer be generated
// By definition, we should return "true"
return true;
}
// Running GenerateFile() specifically asking it not to save -- so return the evaluated template instead
return $strTemplate;
} | [
"public",
"function",
"generateFile",
"(",
"$",
"strModuleSubPath",
",",
"$",
"strTemplateFilePath",
",",
"$",
"mixArgumentArray",
",",
"$",
"blnSave",
"=",
"true",
")",
"{",
"// Setup Debug/Exception Message",
"if",
"(",
"Codegen",
"::",
"DEBUG_MODE",
")",
"{",
"echo",
"(",
"\"Evaluating $strTemplateFilePath<br/>\"",
")",
";",
"}",
"// Check to see if the template file exists, and if it does, Load It",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"strTemplateFilePath",
")",
")",
"{",
"throw",
"new",
"Caller",
"(",
"'Template File Not Found: '",
".",
"$",
"strTemplateFilePath",
")",
";",
"}",
"// Evaluate the Template",
"// make sure paths are set up to pick up included files from the various directories.",
"// Must be the reverse of the buildTemplateArray order",
"$",
"a",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"static",
"::",
"$",
"TemplatePaths",
"as",
"$",
"strTemplatePath",
")",
"{",
"array_unshift",
"(",
"$",
"a",
",",
"$",
"strTemplatePath",
".",
"$",
"strModuleSubPath",
")",
";",
"}",
"$",
"strSearchPath",
"=",
"implode",
"(",
"PATH_SEPARATOR",
",",
"$",
"a",
")",
".",
"PATH_SEPARATOR",
".",
"get_include_path",
"(",
")",
";",
"$",
"strOldIncludePath",
"=",
"set_include_path",
"(",
"$",
"strSearchPath",
")",
";",
"if",
"(",
"$",
"strSearchPath",
"!=",
"get_include_path",
"(",
")",
")",
"{",
"throw",
"new",
"Caller",
"(",
"'Can\\'t override include path. Make sure your apache or server settings allow include paths to be overridden. '",
")",
";",
"}",
"$",
"strTemplate",
"=",
"$",
"this",
"->",
"evaluatePHP",
"(",
"$",
"strTemplateFilePath",
",",
"$",
"mixArgumentArray",
",",
"$",
"templateSettings",
")",
";",
"set_include_path",
"(",
"$",
"strOldIncludePath",
")",
";",
"$",
"blnOverwriteFlag",
"=",
"Type",
"::",
"cast",
"(",
"$",
"templateSettings",
"[",
"'OverwriteFlag'",
"]",
",",
"Type",
"::",
"BOOLEAN",
")",
";",
"$",
"strTargetDirectory",
"=",
"Type",
"::",
"cast",
"(",
"$",
"templateSettings",
"[",
"'TargetDirectory'",
"]",
",",
"Type",
"::",
"STRING",
")",
";",
"$",
"strDirectorySuffix",
"=",
"Type",
"::",
"cast",
"(",
"$",
"templateSettings",
"[",
"'DirectorySuffix'",
"]",
",",
"Type",
"::",
"STRING",
")",
";",
"$",
"strTargetFileName",
"=",
"Type",
"::",
"cast",
"(",
"$",
"templateSettings",
"[",
"'TargetFileName'",
"]",
",",
"Type",
"::",
"STRING",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"blnOverwriteFlag",
")",
"||",
"is_null",
"(",
"$",
"strTargetFileName",
")",
"||",
"is_null",
"(",
"$",
"strTargetDirectory",
")",
"||",
"is_null",
"(",
"$",
"strDirectorySuffix",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'the template settings cannot be null'",
")",
";",
"}",
"if",
"(",
"$",
"blnSave",
"&&",
"$",
"strTargetDirectory",
")",
"{",
"// Figure out the REAL target directory",
"$",
"strTargetDirectory",
"=",
"$",
"strTargetDirectory",
".",
"$",
"strDirectorySuffix",
";",
"// Create Directory (if needed)",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"strTargetDirectory",
")",
")",
"{",
"if",
"(",
"!",
"Folder",
"::",
"makeDirectory",
"(",
"$",
"strTargetDirectory",
",",
"0777",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unable to mkdir '",
".",
"$",
"strTargetDirectory",
")",
";",
"}",
"}",
"// Save to Disk",
"$",
"strFilePath",
"=",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"strTargetDirectory",
",",
"$",
"strTargetFileName",
")",
";",
"if",
"(",
"$",
"blnOverwriteFlag",
"||",
"(",
"!",
"file_exists",
"(",
"$",
"strFilePath",
")",
")",
")",
"{",
"$",
"intBytesSaved",
"=",
"file_put_contents",
"(",
"$",
"strFilePath",
",",
"$",
"strTemplate",
")",
";",
"$",
"this",
"->",
"setGeneratedFilePermissions",
"(",
"$",
"strFilePath",
")",
";",
"return",
"(",
"$",
"intBytesSaved",
"==",
"strlen",
"(",
"$",
"strTemplate",
")",
")",
";",
"}",
"else",
"// Becuase we are not supposed to overwrite, we should return \"true\" by default",
"{",
"return",
"true",
";",
"}",
"}",
"// Why Did We Not Save?",
"if",
"(",
"$",
"blnSave",
")",
"{",
"// We WANT to Save, but QCubed Configuration says that this functionality/feature should no longer be generated",
"// By definition, we should return \"true\"",
"return",
"true",
";",
"}",
"// Running GenerateFile() specifically asking it not to save -- so return the evaluated template instead",
"return",
"$",
"strTemplate",
";",
"}"
]
| Generates a php code using a template file
@param string $strModuleSubPath
@param string $strTemplateFilePath Path to the template file
@param mixed[] $mixArgumentArray
@param boolean $blnSave whether or not to actually perform the save
@throws Caller
@throws \Exception
@return mixed returns the evaluated template or boolean save success. | [
"Generates",
"a",
"php",
"code",
"using",
"a",
"template",
"file"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L519-L588 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.setGeneratedFilePermissions | protected function setGeneratedFilePermissions($strFilePath)
{
// CHMOD to full read/write permissions (applicable only to nonwindows)
// Need to ignore error handling for this call just in case
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
$e = new Error\Handler();
chmod($strFilePath, 0666);
}
} | php | protected function setGeneratedFilePermissions($strFilePath)
{
// CHMOD to full read/write permissions (applicable only to nonwindows)
// Need to ignore error handling for this call just in case
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
$e = new Error\Handler();
chmod($strFilePath, 0666);
}
} | [
"protected",
"function",
"setGeneratedFilePermissions",
"(",
"$",
"strFilePath",
")",
"{",
"// CHMOD to full read/write permissions (applicable only to nonwindows)",
"// Need to ignore error handling for this call just in case",
"if",
"(",
"strtoupper",
"(",
"substr",
"(",
"PHP_OS",
",",
"0",
",",
"3",
")",
")",
"!==",
"'WIN'",
")",
"{",
"$",
"e",
"=",
"new",
"Error",
"\\",
"Handler",
"(",
")",
";",
"chmod",
"(",
"$",
"strFilePath",
",",
"0666",
")",
";",
"}",
"}"
]
| Sets the file permissions (Linux only) for a file generated by the Code Generator
@param string $strFilePath Path of the generated file
@throws Caller | [
"Sets",
"the",
"file",
"permissions",
"(",
"Linux",
"only",
")",
"for",
"a",
"file",
"generated",
"by",
"the",
"Code",
"Generator",
"@param",
"string",
"$strFilePath",
"Path",
"of",
"the",
"generated",
"file"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L596-L604 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.evaluatePHP | protected function evaluatePHP($strFilename, $mixArgumentArray, &$templateSettings = null)
{
// Get all the arguments and set them locally
if ($mixArgumentArray) {
foreach ($mixArgumentArray as $strName => $mixValue) {
$$strName = $mixValue;
}
}
global $_TEMPLATE_SETTINGS;
unset($_TEMPLATE_SETTINGS);
$_TEMPLATE_SETTINGS = null;
// Of course, we also need to locally allow "objCodeGen"
$objCodeGen = $this;
// Get Database Escape Identifiers
$strEscapeIdentifierBegin = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierBegin;
$strEscapeIdentifierEnd = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierEnd;
// Store the Output Buffer locally
$strAlreadyRendered = ob_get_contents();
if (ob_get_level()) {
ob_clean();
}
ob_start();
include($strFilename);
$strTemplate = ob_get_contents();
ob_end_clean();
$templateSettings = $_TEMPLATE_SETTINGS;
unset($_TEMPLATE_SETTINGS);
// Restore the output buffer and return evaluated template
print($strAlreadyRendered);
// Remove all \r from the template (for Win/*nix compatibility)
$strTemplate = str_replace("\r", '', $strTemplate);
return $strTemplate;
} | php | protected function evaluatePHP($strFilename, $mixArgumentArray, &$templateSettings = null)
{
// Get all the arguments and set them locally
if ($mixArgumentArray) {
foreach ($mixArgumentArray as $strName => $mixValue) {
$$strName = $mixValue;
}
}
global $_TEMPLATE_SETTINGS;
unset($_TEMPLATE_SETTINGS);
$_TEMPLATE_SETTINGS = null;
// Of course, we also need to locally allow "objCodeGen"
$objCodeGen = $this;
// Get Database Escape Identifiers
$strEscapeIdentifierBegin = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierBegin;
$strEscapeIdentifierEnd = \QCubed\Database\Service::getDatabase($this->intDatabaseIndex)->EscapeIdentifierEnd;
// Store the Output Buffer locally
$strAlreadyRendered = ob_get_contents();
if (ob_get_level()) {
ob_clean();
}
ob_start();
include($strFilename);
$strTemplate = ob_get_contents();
ob_end_clean();
$templateSettings = $_TEMPLATE_SETTINGS;
unset($_TEMPLATE_SETTINGS);
// Restore the output buffer and return evaluated template
print($strAlreadyRendered);
// Remove all \r from the template (for Win/*nix compatibility)
$strTemplate = str_replace("\r", '', $strTemplate);
return $strTemplate;
} | [
"protected",
"function",
"evaluatePHP",
"(",
"$",
"strFilename",
",",
"$",
"mixArgumentArray",
",",
"&",
"$",
"templateSettings",
"=",
"null",
")",
"{",
"// Get all the arguments and set them locally",
"if",
"(",
"$",
"mixArgumentArray",
")",
"{",
"foreach",
"(",
"$",
"mixArgumentArray",
"as",
"$",
"strName",
"=>",
"$",
"mixValue",
")",
"{",
"$",
"$",
"strName",
"=",
"$",
"mixValue",
";",
"}",
"}",
"global",
"$",
"_TEMPLATE_SETTINGS",
";",
"unset",
"(",
"$",
"_TEMPLATE_SETTINGS",
")",
";",
"$",
"_TEMPLATE_SETTINGS",
"=",
"null",
";",
"// Of course, we also need to locally allow \"objCodeGen\"",
"$",
"objCodeGen",
"=",
"$",
"this",
";",
"// Get Database Escape Identifiers",
"$",
"strEscapeIdentifierBegin",
"=",
"\\",
"QCubed",
"\\",
"Database",
"\\",
"Service",
"::",
"getDatabase",
"(",
"$",
"this",
"->",
"intDatabaseIndex",
")",
"->",
"EscapeIdentifierBegin",
";",
"$",
"strEscapeIdentifierEnd",
"=",
"\\",
"QCubed",
"\\",
"Database",
"\\",
"Service",
"::",
"getDatabase",
"(",
"$",
"this",
"->",
"intDatabaseIndex",
")",
"->",
"EscapeIdentifierEnd",
";",
"// Store the Output Buffer locally",
"$",
"strAlreadyRendered",
"=",
"ob_get_contents",
"(",
")",
";",
"if",
"(",
"ob_get_level",
"(",
")",
")",
"{",
"ob_clean",
"(",
")",
";",
"}",
"ob_start",
"(",
")",
";",
"include",
"(",
"$",
"strFilename",
")",
";",
"$",
"strTemplate",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"$",
"templateSettings",
"=",
"$",
"_TEMPLATE_SETTINGS",
";",
"unset",
"(",
"$",
"_TEMPLATE_SETTINGS",
")",
";",
"// Restore the output buffer and return evaluated template",
"print",
"(",
"$",
"strAlreadyRendered",
")",
";",
"// Remove all \\r from the template (for Win/*nix compatibility)",
"$",
"strTemplate",
"=",
"str_replace",
"(",
"\"\\r\"",
",",
"''",
",",
"$",
"strTemplate",
")",
";",
"return",
"$",
"strTemplate",
";",
"}"
]
| Returns the evaluated PHP
@param $strFilename
@param $mixArgumentArray
@param null $templateSettings
@return mixed|string | [
"Returns",
"the",
"evaluated",
"PHP"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L614-L653 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelClassName | protected function modelClassName($strTableName)
{
$strTableName = $this->stripPrefixFromTable($strTableName);
return sprintf('%s%s%s',
$this->strClassPrefix,
QString::camelCaseFromUnderscore($strTableName),
$this->strClassSuffix);
} | php | protected function modelClassName($strTableName)
{
$strTableName = $this->stripPrefixFromTable($strTableName);
return sprintf('%s%s%s',
$this->strClassPrefix,
QString::camelCaseFromUnderscore($strTableName),
$this->strClassSuffix);
} | [
"protected",
"function",
"modelClassName",
"(",
"$",
"strTableName",
")",
"{",
"$",
"strTableName",
"=",
"$",
"this",
"->",
"stripPrefixFromTable",
"(",
"$",
"strTableName",
")",
";",
"return",
"sprintf",
"(",
"'%s%s%s'",
",",
"$",
"this",
"->",
"strClassPrefix",
",",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strTableName",
")",
",",
"$",
"this",
"->",
"strClassSuffix",
")",
";",
"}"
]
| Given a table name, returns the name of the class for the corresponding model object.
@param string $strTableName
@return string | [
"Given",
"a",
"table",
"name",
"returns",
"the",
"name",
"of",
"the",
"class",
"for",
"the",
"corresponding",
"model",
"object",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L669-L676 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelVariableName | public function modelVariableName($strTableName)
{
$strTableName = $this->stripPrefixFromTable($strTableName);
return Codegen::prefixFromType(Type::OBJECT) .
QString::camelCaseFromUnderscore($strTableName);
} | php | public function modelVariableName($strTableName)
{
$strTableName = $this->stripPrefixFromTable($strTableName);
return Codegen::prefixFromType(Type::OBJECT) .
QString::camelCaseFromUnderscore($strTableName);
} | [
"public",
"function",
"modelVariableName",
"(",
"$",
"strTableName",
")",
"{",
"$",
"strTableName",
"=",
"$",
"this",
"->",
"stripPrefixFromTable",
"(",
"$",
"strTableName",
")",
";",
"return",
"Codegen",
"::",
"prefixFromType",
"(",
"Type",
"::",
"OBJECT",
")",
".",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strTableName",
")",
";",
"}"
]
| Given a table name, returns a variable name that will be used to represent the corresponding model object.
@param string $strTableName
@return string | [
"Given",
"a",
"table",
"name",
"returns",
"a",
"variable",
"name",
"that",
"will",
"be",
"used",
"to",
"represent",
"the",
"corresponding",
"model",
"object",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L683-L688 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelColumnVariableName | protected function modelColumnVariableName(SqlColumn $objColumn)
{
return Codegen::prefixFromType($objColumn->VariableType) .
QString::camelCaseFromUnderscore($objColumn->Name);
} | php | protected function modelColumnVariableName(SqlColumn $objColumn)
{
return Codegen::prefixFromType($objColumn->VariableType) .
QString::camelCaseFromUnderscore($objColumn->Name);
} | [
"protected",
"function",
"modelColumnVariableName",
"(",
"SqlColumn",
"$",
"objColumn",
")",
"{",
"return",
"Codegen",
"::",
"prefixFromType",
"(",
"$",
"objColumn",
"->",
"VariableType",
")",
".",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"objColumn",
"->",
"Name",
")",
";",
"}"
]
| Given a column, returns the name of the variable used to represent the column's value inside
the model object.
@param SqlColumn $objColumn
@return string | [
"Given",
"a",
"column",
"returns",
"the",
"name",
"of",
"the",
"variable",
"used",
"to",
"represent",
"the",
"column",
"s",
"value",
"inside",
"the",
"model",
"object",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L722-L726 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelReferenceColumnName | protected function modelReferenceColumnName($strColumnName)
{
$intNameLength = strlen($strColumnName);
// Does the column name for this reference column end in "_id"?
if (($intNameLength > 3) && (substr($strColumnName, $intNameLength - 3) == "_id")) {
// It ends in "_id" but we don't want to include the "Id" suffix
// in the Variable Name. So remove it.
$strColumnName = substr($strColumnName, 0, $intNameLength - 3);
} else {
// Otherwise, let's add "_object" so that we don't confuse this variable name
// from the variable that was mapped from the physical database
// E.g., if it's a numeric FK, and the column is defined as "person INT",
// there will end up being two variables, one for the Person id integer, and
// one for the Person object itself. We'll add Object to the name of the Person object
// to make this deliniation.
$strColumnName = sprintf("%s_object", $strColumnName);
}
return $strColumnName;
} | php | protected function modelReferenceColumnName($strColumnName)
{
$intNameLength = strlen($strColumnName);
// Does the column name for this reference column end in "_id"?
if (($intNameLength > 3) && (substr($strColumnName, $intNameLength - 3) == "_id")) {
// It ends in "_id" but we don't want to include the "Id" suffix
// in the Variable Name. So remove it.
$strColumnName = substr($strColumnName, 0, $intNameLength - 3);
} else {
// Otherwise, let's add "_object" so that we don't confuse this variable name
// from the variable that was mapped from the physical database
// E.g., if it's a numeric FK, and the column is defined as "person INT",
// there will end up being two variables, one for the Person id integer, and
// one for the Person object itself. We'll add Object to the name of the Person object
// to make this deliniation.
$strColumnName = sprintf("%s_object", $strColumnName);
}
return $strColumnName;
} | [
"protected",
"function",
"modelReferenceColumnName",
"(",
"$",
"strColumnName",
")",
"{",
"$",
"intNameLength",
"=",
"strlen",
"(",
"$",
"strColumnName",
")",
";",
"// Does the column name for this reference column end in \"_id\"?",
"if",
"(",
"(",
"$",
"intNameLength",
">",
"3",
")",
"&&",
"(",
"substr",
"(",
"$",
"strColumnName",
",",
"$",
"intNameLength",
"-",
"3",
")",
"==",
"\"_id\"",
")",
")",
"{",
"// It ends in \"_id\" but we don't want to include the \"Id\" suffix",
"// in the Variable Name. So remove it.",
"$",
"strColumnName",
"=",
"substr",
"(",
"$",
"strColumnName",
",",
"0",
",",
"$",
"intNameLength",
"-",
"3",
")",
";",
"}",
"else",
"{",
"// Otherwise, let's add \"_object\" so that we don't confuse this variable name",
"// from the variable that was mapped from the physical database",
"// E.g., if it's a numeric FK, and the column is defined as \"person INT\",",
"// there will end up being two variables, one for the Person id integer, and",
"// one for the Person object itself. We'll add Object to the name of the Person object",
"// to make this deliniation.",
"$",
"strColumnName",
"=",
"sprintf",
"(",
"\"%s_object\"",
",",
"$",
"strColumnName",
")",
";",
"}",
"return",
"$",
"strColumnName",
";",
"}"
]
| Given the name of a column that is a foreign key to another table, returns a kind of
virtual column name that would refer to the object pointed to. This new name is used to refer to the object
version of the column by json and other encodings, and derivatives
of this name are used to represent a variable and property name that refers to this object that will get stored
in the model.
@param string $strColumnName
@return string | [
"Given",
"the",
"name",
"of",
"a",
"column",
"that",
"is",
"a",
"foreign",
"key",
"to",
"another",
"table",
"returns",
"a",
"kind",
"of",
"virtual",
"column",
"name",
"that",
"would",
"refer",
"to",
"the",
"object",
"pointed",
"to",
".",
"This",
"new",
"name",
"is",
"used",
"to",
"refer",
"to",
"the",
"object",
"version",
"of",
"the",
"column",
"by",
"json",
"and",
"other",
"encodings",
"and",
"derivatives",
"of",
"this",
"name",
"are",
"used",
"to",
"represent",
"a",
"variable",
"and",
"property",
"name",
"that",
"refers",
"to",
"this",
"object",
"that",
"will",
"get",
"stored",
"in",
"the",
"model",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L760-L780 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelReferenceVariableName | protected function modelReferenceVariableName($strColumnName)
{
$strColumnName = $this->modelReferenceColumnName($strColumnName);
return Codegen::prefixFromType(Type::OBJECT) .
QString::camelCaseFromUnderscore($strColumnName);
} | php | protected function modelReferenceVariableName($strColumnName)
{
$strColumnName = $this->modelReferenceColumnName($strColumnName);
return Codegen::prefixFromType(Type::OBJECT) .
QString::camelCaseFromUnderscore($strColumnName);
} | [
"protected",
"function",
"modelReferenceVariableName",
"(",
"$",
"strColumnName",
")",
"{",
"$",
"strColumnName",
"=",
"$",
"this",
"->",
"modelReferenceColumnName",
"(",
"$",
"strColumnName",
")",
";",
"return",
"Codegen",
"::",
"prefixFromType",
"(",
"Type",
"::",
"OBJECT",
")",
".",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strColumnName",
")",
";",
"}"
]
| Given a column name to a foreign key, returns the name of the variable that will represent the foreign object
stored in the model.
@param string $strColumnName
@return string | [
"Given",
"a",
"column",
"name",
"to",
"a",
"foreign",
"key",
"returns",
"the",
"name",
"of",
"the",
"variable",
"that",
"will",
"represent",
"the",
"foreign",
"object",
"stored",
"in",
"the",
"model",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L789-L794 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelConnectorControlName | public static function modelConnectorControlName(ColumnInterface $objColumn)
{
if (($o = $objColumn->Options) && isset ($o['Name'])) { // Did developer default?
return $o['Name'];
}
return QString::wordsFromCamelCase(Codegen::modelConnectorPropertyName($objColumn));
} | php | public static function modelConnectorControlName(ColumnInterface $objColumn)
{
if (($o = $objColumn->Options) && isset ($o['Name'])) { // Did developer default?
return $o['Name'];
}
return QString::wordsFromCamelCase(Codegen::modelConnectorPropertyName($objColumn));
} | [
"public",
"static",
"function",
"modelConnectorControlName",
"(",
"ColumnInterface",
"$",
"objColumn",
")",
"{",
"if",
"(",
"(",
"$",
"o",
"=",
"$",
"objColumn",
"->",
"Options",
")",
"&&",
"isset",
"(",
"$",
"o",
"[",
"'Name'",
"]",
")",
")",
"{",
"// Did developer default?",
"return",
"$",
"o",
"[",
"'Name'",
"]",
";",
"}",
"return",
"QString",
"::",
"wordsFromCamelCase",
"(",
"Codegen",
"::",
"modelConnectorPropertyName",
"(",
"$",
"objColumn",
")",
")",
";",
"}"
]
| Returns the control label name as used in the ModelConnector corresponding to this column or table.
@param ColumnInterface $objColumn
@return string | [
"Returns",
"the",
"control",
"label",
"name",
"as",
"used",
"in",
"the",
"ModelConnector",
"corresponding",
"to",
"this",
"column",
"or",
"table",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L868-L874 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelConnectorPropertyName | public static function modelConnectorPropertyName(ColumnInterface $objColumn)
{
if ($objColumn instanceof SqlColumn) {
if ($objColumn->Reference) {
return $objColumn->Reference->PropertyName;
} else {
return $objColumn->PropertyName;
}
} elseif ($objColumn instanceof ReverseReference) {
if ($objColumn->Unique) {
return ($objColumn->ObjectDescription);
} else {
return ($objColumn->ObjectDescriptionPlural);
}
} elseif ($objColumn instanceof ManyToManyReference) {
return $objColumn->ObjectDescriptionPlural;
} else {
throw new \Exception ('Unknown column type.');
}
} | php | public static function modelConnectorPropertyName(ColumnInterface $objColumn)
{
if ($objColumn instanceof SqlColumn) {
if ($objColumn->Reference) {
return $objColumn->Reference->PropertyName;
} else {
return $objColumn->PropertyName;
}
} elseif ($objColumn instanceof ReverseReference) {
if ($objColumn->Unique) {
return ($objColumn->ObjectDescription);
} else {
return ($objColumn->ObjectDescriptionPlural);
}
} elseif ($objColumn instanceof ManyToManyReference) {
return $objColumn->ObjectDescriptionPlural;
} else {
throw new \Exception ('Unknown column type.');
}
} | [
"public",
"static",
"function",
"modelConnectorPropertyName",
"(",
"ColumnInterface",
"$",
"objColumn",
")",
"{",
"if",
"(",
"$",
"objColumn",
"instanceof",
"SqlColumn",
")",
"{",
"if",
"(",
"$",
"objColumn",
"->",
"Reference",
")",
"{",
"return",
"$",
"objColumn",
"->",
"Reference",
"->",
"PropertyName",
";",
"}",
"else",
"{",
"return",
"$",
"objColumn",
"->",
"PropertyName",
";",
"}",
"}",
"elseif",
"(",
"$",
"objColumn",
"instanceof",
"ReverseReference",
")",
"{",
"if",
"(",
"$",
"objColumn",
"->",
"Unique",
")",
"{",
"return",
"(",
"$",
"objColumn",
"->",
"ObjectDescription",
")",
";",
"}",
"else",
"{",
"return",
"(",
"$",
"objColumn",
"->",
"ObjectDescriptionPlural",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"objColumn",
"instanceof",
"ManyToManyReference",
")",
"{",
"return",
"$",
"objColumn",
"->",
"ObjectDescriptionPlural",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unknown column type.'",
")",
";",
"}",
"}"
]
| The property name used in the ModelConnector for the given column, virtual column or table
@param ColumnInterface $objColumn
@return string
@throws \Exception | [
"The",
"property",
"name",
"used",
"in",
"the",
"ModelConnector",
"for",
"the",
"given",
"column",
"virtual",
"column",
"or",
"table"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L884-L903 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelConnectorVariableName | public function modelConnectorVariableName(ColumnInterface $objColumn)
{
$strPropName = static::modelConnectorPropertyName($objColumn);
$objControlHelper = $this->getControlCodeGenerator($objColumn);
return $objControlHelper->varName($strPropName);
} | php | public function modelConnectorVariableName(ColumnInterface $objColumn)
{
$strPropName = static::modelConnectorPropertyName($objColumn);
$objControlHelper = $this->getControlCodeGenerator($objColumn);
return $objControlHelper->varName($strPropName);
} | [
"public",
"function",
"modelConnectorVariableName",
"(",
"ColumnInterface",
"$",
"objColumn",
")",
"{",
"$",
"strPropName",
"=",
"static",
"::",
"modelConnectorPropertyName",
"(",
"$",
"objColumn",
")",
";",
"$",
"objControlHelper",
"=",
"$",
"this",
"->",
"getControlCodeGenerator",
"(",
"$",
"objColumn",
")",
";",
"return",
"$",
"objControlHelper",
"->",
"varName",
"(",
"$",
"strPropName",
")",
";",
"}"
]
| Return a variable name corresponding to the given column, including virtual columns like
ReverseReference and QManyToMany references.
@param ColumnInterface $objColumn
@return string | [
"Return",
"a",
"variable",
"name",
"corresponding",
"to",
"the",
"given",
"column",
"including",
"virtual",
"columns",
"like",
"ReverseReference",
"and",
"QManyToMany",
"references",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L911-L916 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelConnectorLabelVariableName | public function modelConnectorLabelVariableName(ColumnInterface $objColumn)
{
$strPropName = static::modelConnectorPropertyName($objColumn);
return \QCubed\Codegen\Generator\Label::instance()->varName($strPropName);
} | php | public function modelConnectorLabelVariableName(ColumnInterface $objColumn)
{
$strPropName = static::modelConnectorPropertyName($objColumn);
return \QCubed\Codegen\Generator\Label::instance()->varName($strPropName);
} | [
"public",
"function",
"modelConnectorLabelVariableName",
"(",
"ColumnInterface",
"$",
"objColumn",
")",
"{",
"$",
"strPropName",
"=",
"static",
"::",
"modelConnectorPropertyName",
"(",
"$",
"objColumn",
")",
";",
"return",
"\\",
"QCubed",
"\\",
"Codegen",
"\\",
"Generator",
"\\",
"Label",
"::",
"instance",
"(",
")",
"->",
"varName",
"(",
"$",
"strPropName",
")",
";",
"}"
]
| Returns a variable name for the "label" version of a control, which would be the read-only version
of viewing the data in the column.
@param ColumnInterface $objColumn
@return string | [
"Returns",
"a",
"variable",
"name",
"for",
"the",
"label",
"version",
"of",
"a",
"control",
"which",
"would",
"be",
"the",
"read",
"-",
"only",
"version",
"of",
"viewing",
"the",
"data",
"in",
"the",
"column",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L924-L928 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.modelConnectorControlClass | protected function modelConnectorControlClass(ColumnInterface $objColumn)
{
// Is the class specified by the developer?
if ($o = $objColumn->Options) {
if (isset ($o['FormGen']) && $o['FormGen'] == \QCubed\ModelConnector\Options::FORMGEN_LABEL_ONLY) {
return '\\QCubed\\Control\\Label';
}
if (isset($o['ControlClass'])) {
return $o['ControlClass'];
}
}
// otherwise, return the default class based on the column
if ($objColumn instanceof SqlColumn) {
if ($objColumn->Identity) {
return '\\QCubed\\Control\\Label';
}
if ($objColumn->Timestamp) {
return '\\QCubed\\Control\\Label';
}
if ($objColumn->Reference) {
return '\\QCubed\\Project\\Control\\ListBox';
}
switch ($objColumn->VariableType) {
case Type::BOOLEAN:
return '\\QCubed\\Project\\Control\\Checkbox';
case Type::DATE_TIME:
return '\\QCubed\\Control\\DateTimePicker';
case Type::INTEGER:
return '\\QCubed\\Control\\IntegerTextBox';
case Type::FLOAT:
return '\\QCubed\\Control\\FloatTextBox';
default:
return '\\QCubed\\Project\\Control\\TextBox';
}
} elseif ($objColumn instanceof ReverseReference) {
if ($objColumn->Unique) {
return '\\QCubed\\Project\\Control\\ListBox';
} else {
return '\\QCubed\\Control\\CheckboxList'; // for multi-selection
}
} elseif ($objColumn instanceof ManyToManyReference) {
return '\\QCubed\\Control\\CheckboxList'; // for multi-selection
}
throw new \Exception('Unknown column type.');
} | php | protected function modelConnectorControlClass(ColumnInterface $objColumn)
{
// Is the class specified by the developer?
if ($o = $objColumn->Options) {
if (isset ($o['FormGen']) && $o['FormGen'] == \QCubed\ModelConnector\Options::FORMGEN_LABEL_ONLY) {
return '\\QCubed\\Control\\Label';
}
if (isset($o['ControlClass'])) {
return $o['ControlClass'];
}
}
// otherwise, return the default class based on the column
if ($objColumn instanceof SqlColumn) {
if ($objColumn->Identity) {
return '\\QCubed\\Control\\Label';
}
if ($objColumn->Timestamp) {
return '\\QCubed\\Control\\Label';
}
if ($objColumn->Reference) {
return '\\QCubed\\Project\\Control\\ListBox';
}
switch ($objColumn->VariableType) {
case Type::BOOLEAN:
return '\\QCubed\\Project\\Control\\Checkbox';
case Type::DATE_TIME:
return '\\QCubed\\Control\\DateTimePicker';
case Type::INTEGER:
return '\\QCubed\\Control\\IntegerTextBox';
case Type::FLOAT:
return '\\QCubed\\Control\\FloatTextBox';
default:
return '\\QCubed\\Project\\Control\\TextBox';
}
} elseif ($objColumn instanceof ReverseReference) {
if ($objColumn->Unique) {
return '\\QCubed\\Project\\Control\\ListBox';
} else {
return '\\QCubed\\Control\\CheckboxList'; // for multi-selection
}
} elseif ($objColumn instanceof ManyToManyReference) {
return '\\QCubed\\Control\\CheckboxList'; // for multi-selection
}
throw new \Exception('Unknown column type.');
} | [
"protected",
"function",
"modelConnectorControlClass",
"(",
"ColumnInterface",
"$",
"objColumn",
")",
"{",
"// Is the class specified by the developer?",
"if",
"(",
"$",
"o",
"=",
"$",
"objColumn",
"->",
"Options",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"o",
"[",
"'FormGen'",
"]",
")",
"&&",
"$",
"o",
"[",
"'FormGen'",
"]",
"==",
"\\",
"QCubed",
"\\",
"ModelConnector",
"\\",
"Options",
"::",
"FORMGEN_LABEL_ONLY",
")",
"{",
"return",
"'\\\\QCubed\\\\Control\\\\Label'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"o",
"[",
"'ControlClass'",
"]",
")",
")",
"{",
"return",
"$",
"o",
"[",
"'ControlClass'",
"]",
";",
"}",
"}",
"// otherwise, return the default class based on the column",
"if",
"(",
"$",
"objColumn",
"instanceof",
"SqlColumn",
")",
"{",
"if",
"(",
"$",
"objColumn",
"->",
"Identity",
")",
"{",
"return",
"'\\\\QCubed\\\\Control\\\\Label'",
";",
"}",
"if",
"(",
"$",
"objColumn",
"->",
"Timestamp",
")",
"{",
"return",
"'\\\\QCubed\\\\Control\\\\Label'",
";",
"}",
"if",
"(",
"$",
"objColumn",
"->",
"Reference",
")",
"{",
"return",
"'\\\\QCubed\\\\Project\\\\Control\\\\ListBox'",
";",
"}",
"switch",
"(",
"$",
"objColumn",
"->",
"VariableType",
")",
"{",
"case",
"Type",
"::",
"BOOLEAN",
":",
"return",
"'\\\\QCubed\\\\Project\\\\Control\\\\Checkbox'",
";",
"case",
"Type",
"::",
"DATE_TIME",
":",
"return",
"'\\\\QCubed\\\\Control\\\\DateTimePicker'",
";",
"case",
"Type",
"::",
"INTEGER",
":",
"return",
"'\\\\QCubed\\\\Control\\\\IntegerTextBox'",
";",
"case",
"Type",
"::",
"FLOAT",
":",
"return",
"'\\\\QCubed\\\\Control\\\\FloatTextBox'",
";",
"default",
":",
"return",
"'\\\\QCubed\\\\Project\\\\Control\\\\TextBox'",
";",
"}",
"}",
"elseif",
"(",
"$",
"objColumn",
"instanceof",
"ReverseReference",
")",
"{",
"if",
"(",
"$",
"objColumn",
"->",
"Unique",
")",
"{",
"return",
"'\\\\QCubed\\\\Project\\\\Control\\\\ListBox'",
";",
"}",
"else",
"{",
"return",
"'\\\\QCubed\\\\Control\\\\CheckboxList'",
";",
"// for multi-selection",
"}",
"}",
"elseif",
"(",
"$",
"objColumn",
"instanceof",
"ManyToManyReference",
")",
"{",
"return",
"'\\\\QCubed\\\\Control\\\\CheckboxList'",
";",
"// for multi-selection",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unknown column type.'",
")",
";",
"}"
]
| Returns the class for the control that will be created to edit the given column,
including the 'virtual' columns of reverse references (many to one) and many-to-many references.
@param ColumnInterface $objColumn
@return string Class name of control which can handle this column's data
@throws \Exception | [
"Returns",
"the",
"class",
"for",
"the",
"control",
"that",
"will",
"be",
"created",
"to",
"edit",
"the",
"given",
"column",
"including",
"the",
"virtual",
"columns",
"of",
"reverse",
"references",
"(",
"many",
"to",
"one",
")",
"and",
"many",
"-",
"to",
"-",
"many",
"references",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L939-L988 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.dataListControlName | public static function dataListControlName(SqlTable $objTable)
{
if (($o = $objTable->Options) && isset ($o['Name'])) { // Did developer default?
return $o['Name'];
}
return QString::wordsFromCamelCase($objTable->ClassNamePlural);
} | php | public static function dataListControlName(SqlTable $objTable)
{
if (($o = $objTable->Options) && isset ($o['Name'])) { // Did developer default?
return $o['Name'];
}
return QString::wordsFromCamelCase($objTable->ClassNamePlural);
} | [
"public",
"static",
"function",
"dataListControlName",
"(",
"SqlTable",
"$",
"objTable",
")",
"{",
"if",
"(",
"(",
"$",
"o",
"=",
"$",
"objTable",
"->",
"Options",
")",
"&&",
"isset",
"(",
"$",
"o",
"[",
"'Name'",
"]",
")",
")",
"{",
"// Did developer default?",
"return",
"$",
"o",
"[",
"'Name'",
"]",
";",
"}",
"return",
"QString",
"::",
"wordsFromCamelCase",
"(",
"$",
"objTable",
"->",
"ClassNamePlural",
")",
";",
"}"
]
| Returns the control label name as used in the data list panel corresponding to this column.
@param SqlTable $objTable
@return string | [
"Returns",
"the",
"control",
"label",
"name",
"as",
"used",
"in",
"the",
"data",
"list",
"panel",
"corresponding",
"to",
"this",
"column",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1011-L1017 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.dataListItemName | public static function dataListItemName(SqlTable $objTable)
{
if (($o = $objTable->Options) && isset ($o['ItemName'])) { // Did developer override?
return $o['ItemName'];
}
return QString::wordsFromCamelCase($objTable->ClassName);
} | php | public static function dataListItemName(SqlTable $objTable)
{
if (($o = $objTable->Options) && isset ($o['ItemName'])) { // Did developer override?
return $o['ItemName'];
}
return QString::wordsFromCamelCase($objTable->ClassName);
} | [
"public",
"static",
"function",
"dataListItemName",
"(",
"SqlTable",
"$",
"objTable",
")",
"{",
"if",
"(",
"(",
"$",
"o",
"=",
"$",
"objTable",
"->",
"Options",
")",
"&&",
"isset",
"(",
"$",
"o",
"[",
"'ItemName'",
"]",
")",
")",
"{",
"// Did developer override?",
"return",
"$",
"o",
"[",
"'ItemName'",
"]",
";",
"}",
"return",
"QString",
"::",
"wordsFromCamelCase",
"(",
"$",
"objTable",
"->",
"ClassName",
")",
";",
"}"
]
| Returns the name of an item in the data list as will be displayed in the edit panel.
@param SqlTable $objTable
@return string | [
"Returns",
"the",
"name",
"of",
"an",
"item",
"in",
"the",
"data",
"list",
"as",
"will",
"be",
"displayed",
"in",
"the",
"edit",
"panel",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1026-L1032 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.getControlCodeGenerator | public function getControlCodeGenerator($objColumn)
{
$strControlClass = $this->modelConnectorControlClass($objColumn);
if (method_exists($strControlClass, 'getCodeGenerator')) {
return $strControlClass::getCodeGenerator();
} else {
throw new Caller("Class " . $strControlClass . " must implement getCodeGenerator()");
}
} | php | public function getControlCodeGenerator($objColumn)
{
$strControlClass = $this->modelConnectorControlClass($objColumn);
if (method_exists($strControlClass, 'getCodeGenerator')) {
return $strControlClass::getCodeGenerator();
} else {
throw new Caller("Class " . $strControlClass . " must implement getCodeGenerator()");
}
} | [
"public",
"function",
"getControlCodeGenerator",
"(",
"$",
"objColumn",
")",
"{",
"$",
"strControlClass",
"=",
"$",
"this",
"->",
"modelConnectorControlClass",
"(",
"$",
"objColumn",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"strControlClass",
",",
"'getCodeGenerator'",
")",
")",
"{",
"return",
"$",
"strControlClass",
"::",
"getCodeGenerator",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Caller",
"(",
"\"Class \"",
".",
"$",
"strControlClass",
".",
"\" must implement getCodeGenerator()\"",
")",
";",
"}",
"}"
]
| Returns the class for the control that will be created to edit the given column,
including the 'virtual' columns of reverse references (many to one) and many-to-many references.
@param ColumnInterface $objColumn
@return \QCubed\Codegen\Generator\GeneratorBase helper object
@throws \Exception | [
"Returns",
"the",
"class",
"for",
"the",
"control",
"that",
"will",
"be",
"created",
"to",
"edit",
"the",
"given",
"column",
"including",
"the",
"virtual",
"columns",
"of",
"reverse",
"references",
"(",
"many",
"to",
"one",
")",
"and",
"many",
"-",
"to",
"-",
"many",
"references",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1061-L1070 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.calculateObjectDescription | protected function calculateObjectDescription($strTableName, $strColumnName, $strReferencedTableName, $blnPluralize)
{
// Strip Prefixes (if applicable)
$strTableName = $this->stripPrefixFromTable($strTableName);
$strReferencedTableName = $this->stripPrefixFromTable($strReferencedTableName);
// Starting Point
$strToReturn = QString::camelCaseFromUnderscore($strTableName);
if ($blnPluralize) {
$strToReturn = $this->pluralize($strToReturn);
}
if ($strTableName == $strReferencedTableName) {
// Self-referencing Reference to Describe
// If Column Name is only the name of the referenced table, or the name of the referenced table with "_id",
// then the object description is simply based off the table name.
if (($strColumnName == $strReferencedTableName) ||
($strColumnName == $strReferencedTableName . '_id')
) {
return sprintf('Child%s', $strToReturn);
}
// Rip out trailing "_id" if applicable
$intLength = strlen($strColumnName);
if (($intLength > 3) && (substr($strColumnName, $intLength - 3) == "_id")) {
$strColumnName = substr($strColumnName, 0, $intLength - 3);
}
// Rip out the referenced table name from the column name
$strColumnName = str_replace($strReferencedTableName, "", $strColumnName);
// Change any double "_" to single "_"
$strColumnName = str_replace("__", "_", $strColumnName);
$strColumnName = str_replace("__", "_", $strColumnName);
$strColumnName = QString::camelCaseFromUnderscore($strColumnName);
// Special case for Parent/Child
if ($strColumnName == 'Parent') {
return sprintf('Child%s', $strToReturn);
}
return sprintf("%sAs%s",
$strToReturn, $strColumnName);
} else {
// If Column Name is only the name of the referenced table, or the name of the referenced table with "_id",
// then the object description is simply based off the table name.
if (($strColumnName == $strReferencedTableName) ||
($strColumnName == $strReferencedTableName . '_id')
) {
return $strToReturn;
}
// Rip out trailing "_id" if applicable
$intLength = strlen($strColumnName);
if (($intLength > 3) && (substr($strColumnName, $intLength - 3) == "_id")) {
$strColumnName = substr($strColumnName, 0, $intLength - 3);
}
// Rip out the referenced table name from the column name
$strColumnName = str_replace($strReferencedTableName, "", $strColumnName);
// Change any double "_" to single "_"
$strColumnName = str_replace("__", "_", $strColumnName);
$strColumnName = str_replace("__", "_", $strColumnName);
return sprintf("%sAs%s",
$strToReturn,
QString::camelCaseFromUnderscore($strColumnName));
}
} | php | protected function calculateObjectDescription($strTableName, $strColumnName, $strReferencedTableName, $blnPluralize)
{
// Strip Prefixes (if applicable)
$strTableName = $this->stripPrefixFromTable($strTableName);
$strReferencedTableName = $this->stripPrefixFromTable($strReferencedTableName);
// Starting Point
$strToReturn = QString::camelCaseFromUnderscore($strTableName);
if ($blnPluralize) {
$strToReturn = $this->pluralize($strToReturn);
}
if ($strTableName == $strReferencedTableName) {
// Self-referencing Reference to Describe
// If Column Name is only the name of the referenced table, or the name of the referenced table with "_id",
// then the object description is simply based off the table name.
if (($strColumnName == $strReferencedTableName) ||
($strColumnName == $strReferencedTableName . '_id')
) {
return sprintf('Child%s', $strToReturn);
}
// Rip out trailing "_id" if applicable
$intLength = strlen($strColumnName);
if (($intLength > 3) && (substr($strColumnName, $intLength - 3) == "_id")) {
$strColumnName = substr($strColumnName, 0, $intLength - 3);
}
// Rip out the referenced table name from the column name
$strColumnName = str_replace($strReferencedTableName, "", $strColumnName);
// Change any double "_" to single "_"
$strColumnName = str_replace("__", "_", $strColumnName);
$strColumnName = str_replace("__", "_", $strColumnName);
$strColumnName = QString::camelCaseFromUnderscore($strColumnName);
// Special case for Parent/Child
if ($strColumnName == 'Parent') {
return sprintf('Child%s', $strToReturn);
}
return sprintf("%sAs%s",
$strToReturn, $strColumnName);
} else {
// If Column Name is only the name of the referenced table, or the name of the referenced table with "_id",
// then the object description is simply based off the table name.
if (($strColumnName == $strReferencedTableName) ||
($strColumnName == $strReferencedTableName . '_id')
) {
return $strToReturn;
}
// Rip out trailing "_id" if applicable
$intLength = strlen($strColumnName);
if (($intLength > 3) && (substr($strColumnName, $intLength - 3) == "_id")) {
$strColumnName = substr($strColumnName, 0, $intLength - 3);
}
// Rip out the referenced table name from the column name
$strColumnName = str_replace($strReferencedTableName, "", $strColumnName);
// Change any double "_" to single "_"
$strColumnName = str_replace("__", "_", $strColumnName);
$strColumnName = str_replace("__", "_", $strColumnName);
return sprintf("%sAs%s",
$strToReturn,
QString::camelCaseFromUnderscore($strColumnName));
}
} | [
"protected",
"function",
"calculateObjectDescription",
"(",
"$",
"strTableName",
",",
"$",
"strColumnName",
",",
"$",
"strReferencedTableName",
",",
"$",
"blnPluralize",
")",
"{",
"// Strip Prefixes (if applicable)",
"$",
"strTableName",
"=",
"$",
"this",
"->",
"stripPrefixFromTable",
"(",
"$",
"strTableName",
")",
";",
"$",
"strReferencedTableName",
"=",
"$",
"this",
"->",
"stripPrefixFromTable",
"(",
"$",
"strReferencedTableName",
")",
";",
"// Starting Point",
"$",
"strToReturn",
"=",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strTableName",
")",
";",
"if",
"(",
"$",
"blnPluralize",
")",
"{",
"$",
"strToReturn",
"=",
"$",
"this",
"->",
"pluralize",
"(",
"$",
"strToReturn",
")",
";",
"}",
"if",
"(",
"$",
"strTableName",
"==",
"$",
"strReferencedTableName",
")",
"{",
"// Self-referencing Reference to Describe",
"// If Column Name is only the name of the referenced table, or the name of the referenced table with \"_id\",",
"// then the object description is simply based off the table name.",
"if",
"(",
"(",
"$",
"strColumnName",
"==",
"$",
"strReferencedTableName",
")",
"||",
"(",
"$",
"strColumnName",
"==",
"$",
"strReferencedTableName",
".",
"'_id'",
")",
")",
"{",
"return",
"sprintf",
"(",
"'Child%s'",
",",
"$",
"strToReturn",
")",
";",
"}",
"// Rip out trailing \"_id\" if applicable",
"$",
"intLength",
"=",
"strlen",
"(",
"$",
"strColumnName",
")",
";",
"if",
"(",
"(",
"$",
"intLength",
">",
"3",
")",
"&&",
"(",
"substr",
"(",
"$",
"strColumnName",
",",
"$",
"intLength",
"-",
"3",
")",
"==",
"\"_id\"",
")",
")",
"{",
"$",
"strColumnName",
"=",
"substr",
"(",
"$",
"strColumnName",
",",
"0",
",",
"$",
"intLength",
"-",
"3",
")",
";",
"}",
"// Rip out the referenced table name from the column name",
"$",
"strColumnName",
"=",
"str_replace",
"(",
"$",
"strReferencedTableName",
",",
"\"\"",
",",
"$",
"strColumnName",
")",
";",
"// Change any double \"_\" to single \"_\"",
"$",
"strColumnName",
"=",
"str_replace",
"(",
"\"__\"",
",",
"\"_\"",
",",
"$",
"strColumnName",
")",
";",
"$",
"strColumnName",
"=",
"str_replace",
"(",
"\"__\"",
",",
"\"_\"",
",",
"$",
"strColumnName",
")",
";",
"$",
"strColumnName",
"=",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strColumnName",
")",
";",
"// Special case for Parent/Child",
"if",
"(",
"$",
"strColumnName",
"==",
"'Parent'",
")",
"{",
"return",
"sprintf",
"(",
"'Child%s'",
",",
"$",
"strToReturn",
")",
";",
"}",
"return",
"sprintf",
"(",
"\"%sAs%s\"",
",",
"$",
"strToReturn",
",",
"$",
"strColumnName",
")",
";",
"}",
"else",
"{",
"// If Column Name is only the name of the referenced table, or the name of the referenced table with \"_id\",",
"// then the object description is simply based off the table name.",
"if",
"(",
"(",
"$",
"strColumnName",
"==",
"$",
"strReferencedTableName",
")",
"||",
"(",
"$",
"strColumnName",
"==",
"$",
"strReferencedTableName",
".",
"'_id'",
")",
")",
"{",
"return",
"$",
"strToReturn",
";",
"}",
"// Rip out trailing \"_id\" if applicable",
"$",
"intLength",
"=",
"strlen",
"(",
"$",
"strColumnName",
")",
";",
"if",
"(",
"(",
"$",
"intLength",
">",
"3",
")",
"&&",
"(",
"substr",
"(",
"$",
"strColumnName",
",",
"$",
"intLength",
"-",
"3",
")",
"==",
"\"_id\"",
")",
")",
"{",
"$",
"strColumnName",
"=",
"substr",
"(",
"$",
"strColumnName",
",",
"0",
",",
"$",
"intLength",
"-",
"3",
")",
";",
"}",
"// Rip out the referenced table name from the column name",
"$",
"strColumnName",
"=",
"str_replace",
"(",
"$",
"strReferencedTableName",
",",
"\"\"",
",",
"$",
"strColumnName",
")",
";",
"// Change any double \"_\" to single \"_\"",
"$",
"strColumnName",
"=",
"str_replace",
"(",
"\"__\"",
",",
"\"_\"",
",",
"$",
"strColumnName",
")",
";",
"$",
"strColumnName",
"=",
"str_replace",
"(",
"\"__\"",
",",
"\"_\"",
",",
"$",
"strColumnName",
")",
";",
"return",
"sprintf",
"(",
"\"%sAs%s\"",
",",
"$",
"strToReturn",
",",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strColumnName",
")",
")",
";",
"}",
"}"
]
| TODO: These functions need to be documented heavily with information from "lexical analysis on fk names.txt" | [
"TODO",
":",
"These",
"functions",
"need",
"to",
"be",
"documented",
"heavily",
"with",
"information",
"from",
"lexical",
"analysis",
"on",
"fk",
"names",
".",
"txt"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1102-L1175 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.calculateObjectDescriptionForAssociation | protected function calculateObjectDescriptionForAssociation(
$strAssociationTableName,
$strTableName,
$strReferencedTableName,
$blnPluralize
) {
// Strip Prefixes (if applicable)
$strTableName = $this->stripPrefixFromTable($strTableName);
$strAssociationTableName = $this->stripPrefixFromTable($strAssociationTableName);
$strReferencedTableName = $this->stripPrefixFromTable($strReferencedTableName);
// Starting Point
$strToReturn = QString::camelCaseFromUnderscore($strReferencedTableName);
if ($blnPluralize) {
$strToReturn = $this->pluralize($strToReturn);
}
// Let's start with strAssociationTableName
// Rip out trailing "_assn" if applicable
$strAssociationTableName = str_replace($this->strAssociationTableSuffix, '', $strAssociationTableName);
// remove instances of the table names in the association table name
$strTableName2 = str_replace('_', '', $strTableName); // remove underscores if they are there
$strReferencedTableName2 = str_replace('_', '',
$strReferencedTableName); // remove underscores if they are there
if (beginsWith($strAssociationTableName, $strTableName . '_')) {
$strAssociationTableName = trimOffFront($strTableName . '_', $strAssociationTableName);
} elseif (beginsWith($strAssociationTableName, $strTableName2 . '_')) {
$strAssociationTableName = trimOffFront($strTableName2 . '_', $strAssociationTableName);
} elseif (beginsWith($strAssociationTableName, $strReferencedTableName . '_')) {
$strAssociationTableName = trimOffFront($strReferencedTableName . '_', $strAssociationTableName);
} elseif (beginsWith($strAssociationTableName, $strReferencedTableName2 . '_')) {
$strAssociationTableName = trimOffFront($strReferencedTableName2 . '_', $strAssociationTableName);
} elseif ($strAssociationTableName == $strTableName ||
$strAssociationTableName == $strTableName2 ||
$strAssociationTableName == $strReferencedTableName ||
$strAssociationTableName == $strReferencedTableName2
) {
$strAssociationTableName = "";
}
if (endsWith($strAssociationTableName, '_' . $strTableName)) {
$strAssociationTableName = trimOffEnd('_' . $strTableName, $strAssociationTableName);
} elseif (endsWith($strAssociationTableName, '_' . $strTableName2)) {
$strAssociationTableName = trimOffEnd('_' . $strTableName2, $strAssociationTableName);
} elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName)) {
$strAssociationTableName = trimOffEnd('_' . $strReferencedTableName, $strAssociationTableName);
} elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName2)) {
$strAssociationTableName = trimOffEnd('_' . $strReferencedTableName2, $strAssociationTableName);
} elseif ($strAssociationTableName == $strTableName ||
$strAssociationTableName == $strTableName2 ||
$strAssociationTableName == $strReferencedTableName ||
$strAssociationTableName == $strReferencedTableName2
) {
$strAssociationTableName = "";
}
// Change any double "__" to single "_"
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
// If we have nothing left or just a single "_" in AssociationTableName, return "Starting Point"
if (($strAssociationTableName == "_") || ($strAssociationTableName == "")) {
return sprintf("%s%s%s",
$this->strAssociatedObjectPrefix,
$strToReturn,
$this->strAssociatedObjectSuffix);
}
// Otherwise, add "As" and the predicate
return sprintf("%s%sAs%s%s",
$this->strAssociatedObjectPrefix,
$strToReturn,
QString::camelCaseFromUnderscore($strAssociationTableName),
$this->strAssociatedObjectSuffix);
} | php | protected function calculateObjectDescriptionForAssociation(
$strAssociationTableName,
$strTableName,
$strReferencedTableName,
$blnPluralize
) {
// Strip Prefixes (if applicable)
$strTableName = $this->stripPrefixFromTable($strTableName);
$strAssociationTableName = $this->stripPrefixFromTable($strAssociationTableName);
$strReferencedTableName = $this->stripPrefixFromTable($strReferencedTableName);
// Starting Point
$strToReturn = QString::camelCaseFromUnderscore($strReferencedTableName);
if ($blnPluralize) {
$strToReturn = $this->pluralize($strToReturn);
}
// Let's start with strAssociationTableName
// Rip out trailing "_assn" if applicable
$strAssociationTableName = str_replace($this->strAssociationTableSuffix, '', $strAssociationTableName);
// remove instances of the table names in the association table name
$strTableName2 = str_replace('_', '', $strTableName); // remove underscores if they are there
$strReferencedTableName2 = str_replace('_', '',
$strReferencedTableName); // remove underscores if they are there
if (beginsWith($strAssociationTableName, $strTableName . '_')) {
$strAssociationTableName = trimOffFront($strTableName . '_', $strAssociationTableName);
} elseif (beginsWith($strAssociationTableName, $strTableName2 . '_')) {
$strAssociationTableName = trimOffFront($strTableName2 . '_', $strAssociationTableName);
} elseif (beginsWith($strAssociationTableName, $strReferencedTableName . '_')) {
$strAssociationTableName = trimOffFront($strReferencedTableName . '_', $strAssociationTableName);
} elseif (beginsWith($strAssociationTableName, $strReferencedTableName2 . '_')) {
$strAssociationTableName = trimOffFront($strReferencedTableName2 . '_', $strAssociationTableName);
} elseif ($strAssociationTableName == $strTableName ||
$strAssociationTableName == $strTableName2 ||
$strAssociationTableName == $strReferencedTableName ||
$strAssociationTableName == $strReferencedTableName2
) {
$strAssociationTableName = "";
}
if (endsWith($strAssociationTableName, '_' . $strTableName)) {
$strAssociationTableName = trimOffEnd('_' . $strTableName, $strAssociationTableName);
} elseif (endsWith($strAssociationTableName, '_' . $strTableName2)) {
$strAssociationTableName = trimOffEnd('_' . $strTableName2, $strAssociationTableName);
} elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName)) {
$strAssociationTableName = trimOffEnd('_' . $strReferencedTableName, $strAssociationTableName);
} elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName2)) {
$strAssociationTableName = trimOffEnd('_' . $strReferencedTableName2, $strAssociationTableName);
} elseif ($strAssociationTableName == $strTableName ||
$strAssociationTableName == $strTableName2 ||
$strAssociationTableName == $strReferencedTableName ||
$strAssociationTableName == $strReferencedTableName2
) {
$strAssociationTableName = "";
}
// Change any double "__" to single "_"
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
// If we have nothing left or just a single "_" in AssociationTableName, return "Starting Point"
if (($strAssociationTableName == "_") || ($strAssociationTableName == "")) {
return sprintf("%s%s%s",
$this->strAssociatedObjectPrefix,
$strToReturn,
$this->strAssociatedObjectSuffix);
}
// Otherwise, add "As" and the predicate
return sprintf("%s%sAs%s%s",
$this->strAssociatedObjectPrefix,
$strToReturn,
QString::camelCaseFromUnderscore($strAssociationTableName),
$this->strAssociatedObjectSuffix);
} | [
"protected",
"function",
"calculateObjectDescriptionForAssociation",
"(",
"$",
"strAssociationTableName",
",",
"$",
"strTableName",
",",
"$",
"strReferencedTableName",
",",
"$",
"blnPluralize",
")",
"{",
"// Strip Prefixes (if applicable)",
"$",
"strTableName",
"=",
"$",
"this",
"->",
"stripPrefixFromTable",
"(",
"$",
"strTableName",
")",
";",
"$",
"strAssociationTableName",
"=",
"$",
"this",
"->",
"stripPrefixFromTable",
"(",
"$",
"strAssociationTableName",
")",
";",
"$",
"strReferencedTableName",
"=",
"$",
"this",
"->",
"stripPrefixFromTable",
"(",
"$",
"strReferencedTableName",
")",
";",
"// Starting Point",
"$",
"strToReturn",
"=",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strReferencedTableName",
")",
";",
"if",
"(",
"$",
"blnPluralize",
")",
"{",
"$",
"strToReturn",
"=",
"$",
"this",
"->",
"pluralize",
"(",
"$",
"strToReturn",
")",
";",
"}",
"// Let's start with strAssociationTableName",
"// Rip out trailing \"_assn\" if applicable",
"$",
"strAssociationTableName",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"strAssociationTableSuffix",
",",
"''",
",",
"$",
"strAssociationTableName",
")",
";",
"// remove instances of the table names in the association table name",
"$",
"strTableName2",
"=",
"str_replace",
"(",
"'_'",
",",
"''",
",",
"$",
"strTableName",
")",
";",
"// remove underscores if they are there",
"$",
"strReferencedTableName2",
"=",
"str_replace",
"(",
"'_'",
",",
"''",
",",
"$",
"strReferencedTableName",
")",
";",
"// remove underscores if they are there",
"if",
"(",
"beginsWith",
"(",
"$",
"strAssociationTableName",
",",
"$",
"strTableName",
".",
"'_'",
")",
")",
"{",
"$",
"strAssociationTableName",
"=",
"trimOffFront",
"(",
"$",
"strTableName",
".",
"'_'",
",",
"$",
"strAssociationTableName",
")",
";",
"}",
"elseif",
"(",
"beginsWith",
"(",
"$",
"strAssociationTableName",
",",
"$",
"strTableName2",
".",
"'_'",
")",
")",
"{",
"$",
"strAssociationTableName",
"=",
"trimOffFront",
"(",
"$",
"strTableName2",
".",
"'_'",
",",
"$",
"strAssociationTableName",
")",
";",
"}",
"elseif",
"(",
"beginsWith",
"(",
"$",
"strAssociationTableName",
",",
"$",
"strReferencedTableName",
".",
"'_'",
")",
")",
"{",
"$",
"strAssociationTableName",
"=",
"trimOffFront",
"(",
"$",
"strReferencedTableName",
".",
"'_'",
",",
"$",
"strAssociationTableName",
")",
";",
"}",
"elseif",
"(",
"beginsWith",
"(",
"$",
"strAssociationTableName",
",",
"$",
"strReferencedTableName2",
".",
"'_'",
")",
")",
"{",
"$",
"strAssociationTableName",
"=",
"trimOffFront",
"(",
"$",
"strReferencedTableName2",
".",
"'_'",
",",
"$",
"strAssociationTableName",
")",
";",
"}",
"elseif",
"(",
"$",
"strAssociationTableName",
"==",
"$",
"strTableName",
"||",
"$",
"strAssociationTableName",
"==",
"$",
"strTableName2",
"||",
"$",
"strAssociationTableName",
"==",
"$",
"strReferencedTableName",
"||",
"$",
"strAssociationTableName",
"==",
"$",
"strReferencedTableName2",
")",
"{",
"$",
"strAssociationTableName",
"=",
"\"\"",
";",
"}",
"if",
"(",
"endsWith",
"(",
"$",
"strAssociationTableName",
",",
"'_'",
".",
"$",
"strTableName",
")",
")",
"{",
"$",
"strAssociationTableName",
"=",
"trimOffEnd",
"(",
"'_'",
".",
"$",
"strTableName",
",",
"$",
"strAssociationTableName",
")",
";",
"}",
"elseif",
"(",
"endsWith",
"(",
"$",
"strAssociationTableName",
",",
"'_'",
".",
"$",
"strTableName2",
")",
")",
"{",
"$",
"strAssociationTableName",
"=",
"trimOffEnd",
"(",
"'_'",
".",
"$",
"strTableName2",
",",
"$",
"strAssociationTableName",
")",
";",
"}",
"elseif",
"(",
"endsWith",
"(",
"$",
"strAssociationTableName",
",",
"'_'",
".",
"$",
"strReferencedTableName",
")",
")",
"{",
"$",
"strAssociationTableName",
"=",
"trimOffEnd",
"(",
"'_'",
".",
"$",
"strReferencedTableName",
",",
"$",
"strAssociationTableName",
")",
";",
"}",
"elseif",
"(",
"endsWith",
"(",
"$",
"strAssociationTableName",
",",
"'_'",
".",
"$",
"strReferencedTableName2",
")",
")",
"{",
"$",
"strAssociationTableName",
"=",
"trimOffEnd",
"(",
"'_'",
".",
"$",
"strReferencedTableName2",
",",
"$",
"strAssociationTableName",
")",
";",
"}",
"elseif",
"(",
"$",
"strAssociationTableName",
"==",
"$",
"strTableName",
"||",
"$",
"strAssociationTableName",
"==",
"$",
"strTableName2",
"||",
"$",
"strAssociationTableName",
"==",
"$",
"strReferencedTableName",
"||",
"$",
"strAssociationTableName",
"==",
"$",
"strReferencedTableName2",
")",
"{",
"$",
"strAssociationTableName",
"=",
"\"\"",
";",
"}",
"// Change any double \"__\" to single \"_\"",
"$",
"strAssociationTableName",
"=",
"str_replace",
"(",
"\"__\"",
",",
"\"_\"",
",",
"$",
"strAssociationTableName",
")",
";",
"$",
"strAssociationTableName",
"=",
"str_replace",
"(",
"\"__\"",
",",
"\"_\"",
",",
"$",
"strAssociationTableName",
")",
";",
"$",
"strAssociationTableName",
"=",
"str_replace",
"(",
"\"__\"",
",",
"\"_\"",
",",
"$",
"strAssociationTableName",
")",
";",
"// If we have nothing left or just a single \"_\" in AssociationTableName, return \"Starting Point\"",
"if",
"(",
"(",
"$",
"strAssociationTableName",
"==",
"\"_\"",
")",
"||",
"(",
"$",
"strAssociationTableName",
"==",
"\"\"",
")",
")",
"{",
"return",
"sprintf",
"(",
"\"%s%s%s\"",
",",
"$",
"this",
"->",
"strAssociatedObjectPrefix",
",",
"$",
"strToReturn",
",",
"$",
"this",
"->",
"strAssociatedObjectSuffix",
")",
";",
"}",
"// Otherwise, add \"As\" and the predicate",
"return",
"sprintf",
"(",
"\"%s%sAs%s%s\"",
",",
"$",
"this",
"->",
"strAssociatedObjectPrefix",
",",
"$",
"strToReturn",
",",
"QString",
"::",
"camelCaseFromUnderscore",
"(",
"$",
"strAssociationTableName",
")",
",",
"$",
"this",
"->",
"strAssociatedObjectSuffix",
")",
";",
"}"
]
| this is called for ReverseReference Object Descriptions for association tables (many-to-many) | [
"this",
"is",
"called",
"for",
"ReverseReference",
"Object",
"Descriptions",
"for",
"association",
"tables",
"(",
"many",
"-",
"to",
"-",
"many",
")"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1178-L1257 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.calculateGraphPrefixArray | protected function calculateGraphPrefixArray($objForeignKeyArray)
{
// Analyze Column Names to determine GraphPrefixArray
if ((strpos(strtolower($objForeignKeyArray[0]->ColumnNameArray[0]), 'parent') !== false) ||
(strpos(strtolower($objForeignKeyArray[1]->ColumnNameArray[0]), 'child') !== false)
) {
$strGraphPrefixArray[0] = '';
$strGraphPrefixArray[1] = 'Parent';
} else {
if ((strpos(strtolower($objForeignKeyArray[0]->ColumnNameArray[0]), 'child') !== false) ||
(strpos(strtolower($objForeignKeyArray[1]->ColumnNameArray[0]), 'parent') !== false)
) {
$strGraphPrefixArray[0] = 'Parent';
$strGraphPrefixArray[1] = '';
} else {
// Use Default Prefixing for Graphs
$strGraphPrefixArray[0] = 'Parent';
$strGraphPrefixArray[1] = '';
}
}
return $strGraphPrefixArray;
} | php | protected function calculateGraphPrefixArray($objForeignKeyArray)
{
// Analyze Column Names to determine GraphPrefixArray
if ((strpos(strtolower($objForeignKeyArray[0]->ColumnNameArray[0]), 'parent') !== false) ||
(strpos(strtolower($objForeignKeyArray[1]->ColumnNameArray[0]), 'child') !== false)
) {
$strGraphPrefixArray[0] = '';
$strGraphPrefixArray[1] = 'Parent';
} else {
if ((strpos(strtolower($objForeignKeyArray[0]->ColumnNameArray[0]), 'child') !== false) ||
(strpos(strtolower($objForeignKeyArray[1]->ColumnNameArray[0]), 'parent') !== false)
) {
$strGraphPrefixArray[0] = 'Parent';
$strGraphPrefixArray[1] = '';
} else {
// Use Default Prefixing for Graphs
$strGraphPrefixArray[0] = 'Parent';
$strGraphPrefixArray[1] = '';
}
}
return $strGraphPrefixArray;
} | [
"protected",
"function",
"calculateGraphPrefixArray",
"(",
"$",
"objForeignKeyArray",
")",
"{",
"// Analyze Column Names to determine GraphPrefixArray",
"if",
"(",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"objForeignKeyArray",
"[",
"0",
"]",
"->",
"ColumnNameArray",
"[",
"0",
"]",
")",
",",
"'parent'",
")",
"!==",
"false",
")",
"||",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"objForeignKeyArray",
"[",
"1",
"]",
"->",
"ColumnNameArray",
"[",
"0",
"]",
")",
",",
"'child'",
")",
"!==",
"false",
")",
")",
"{",
"$",
"strGraphPrefixArray",
"[",
"0",
"]",
"=",
"''",
";",
"$",
"strGraphPrefixArray",
"[",
"1",
"]",
"=",
"'Parent'",
";",
"}",
"else",
"{",
"if",
"(",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"objForeignKeyArray",
"[",
"0",
"]",
"->",
"ColumnNameArray",
"[",
"0",
"]",
")",
",",
"'child'",
")",
"!==",
"false",
")",
"||",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"objForeignKeyArray",
"[",
"1",
"]",
"->",
"ColumnNameArray",
"[",
"0",
"]",
")",
",",
"'parent'",
")",
"!==",
"false",
")",
")",
"{",
"$",
"strGraphPrefixArray",
"[",
"0",
"]",
"=",
"'Parent'",
";",
"$",
"strGraphPrefixArray",
"[",
"1",
"]",
"=",
"''",
";",
"}",
"else",
"{",
"// Use Default Prefixing for Graphs",
"$",
"strGraphPrefixArray",
"[",
"0",
"]",
"=",
"'Parent'",
";",
"$",
"strGraphPrefixArray",
"[",
"1",
"]",
"=",
"''",
";",
"}",
"}",
"return",
"$",
"strGraphPrefixArray",
";",
"}"
]
| This is called by AnalyzeAssociationTable to calculate the GraphPrefixArray for a self-referencing association table (e.g. directed graph) | [
"This",
"is",
"called",
"by",
"AnalyzeAssociationTable",
"to",
"calculate",
"the",
"GraphPrefixArray",
"for",
"a",
"self",
"-",
"referencing",
"association",
"table",
"(",
"e",
".",
"g",
".",
"directed",
"graph",
")"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1260-L1282 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.variableTypeFromDbType | protected function variableTypeFromDbType($strDbType)
{
switch ($strDbType) {
case Database\FieldType::BIT:
return Type::BOOLEAN;
case Database\FieldType::BLOB:
return Type::STRING;
case Database\FieldType::CHAR:
return Type::STRING;
case Database\FieldType::DATE:
return Type::DATE_TIME;
case Database\FieldType::DATE_TIME:
return Type::DATE_TIME;
case Database\FieldType::FLOAT:
return Type::FLOAT;
case Database\FieldType::INTEGER:
return Type::INTEGER;
case Database\FieldType::TIME:
return Type::DATE_TIME;
case Database\FieldType::VAR_CHAR:
return Type::STRING;
case Database\FieldType::JSON:
return Type::STRING;
default:
throw new \Exception("Invalid Db Type to Convert: $strDbType");
}
} | php | protected function variableTypeFromDbType($strDbType)
{
switch ($strDbType) {
case Database\FieldType::BIT:
return Type::BOOLEAN;
case Database\FieldType::BLOB:
return Type::STRING;
case Database\FieldType::CHAR:
return Type::STRING;
case Database\FieldType::DATE:
return Type::DATE_TIME;
case Database\FieldType::DATE_TIME:
return Type::DATE_TIME;
case Database\FieldType::FLOAT:
return Type::FLOAT;
case Database\FieldType::INTEGER:
return Type::INTEGER;
case Database\FieldType::TIME:
return Type::DATE_TIME;
case Database\FieldType::VAR_CHAR:
return Type::STRING;
case Database\FieldType::JSON:
return Type::STRING;
default:
throw new \Exception("Invalid Db Type to Convert: $strDbType");
}
} | [
"protected",
"function",
"variableTypeFromDbType",
"(",
"$",
"strDbType",
")",
"{",
"switch",
"(",
"$",
"strDbType",
")",
"{",
"case",
"Database",
"\\",
"FieldType",
"::",
"BIT",
":",
"return",
"Type",
"::",
"BOOLEAN",
";",
"case",
"Database",
"\\",
"FieldType",
"::",
"BLOB",
":",
"return",
"Type",
"::",
"STRING",
";",
"case",
"Database",
"\\",
"FieldType",
"::",
"CHAR",
":",
"return",
"Type",
"::",
"STRING",
";",
"case",
"Database",
"\\",
"FieldType",
"::",
"DATE",
":",
"return",
"Type",
"::",
"DATE_TIME",
";",
"case",
"Database",
"\\",
"FieldType",
"::",
"DATE_TIME",
":",
"return",
"Type",
"::",
"DATE_TIME",
";",
"case",
"Database",
"\\",
"FieldType",
"::",
"FLOAT",
":",
"return",
"Type",
"::",
"FLOAT",
";",
"case",
"Database",
"\\",
"FieldType",
"::",
"INTEGER",
":",
"return",
"Type",
"::",
"INTEGER",
";",
"case",
"Database",
"\\",
"FieldType",
"::",
"TIME",
":",
"return",
"Type",
"::",
"DATE_TIME",
";",
"case",
"Database",
"\\",
"FieldType",
"::",
"VAR_CHAR",
":",
"return",
"Type",
"::",
"STRING",
";",
"case",
"Database",
"\\",
"FieldType",
"::",
"JSON",
":",
"return",
"Type",
"::",
"STRING",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid Db Type to Convert: $strDbType\"",
")",
";",
"}",
"}"
]
| Returns the variable type corresponding to the database column type
@param string $strDbType
@return string
@throws \Exception | [
"Returns",
"the",
"variable",
"type",
"corresponding",
"to",
"the",
"database",
"column",
"type"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1290-L1316 |
qcubed/orm | src/Codegen/CodegenBase.php | CodegenBase.pluralize | protected function pluralize($strName)
{
// Special Rules go Here
switch (true) {
case (strtolower($strName) == 'play'):
return $strName . 's';
}
$intLength = strlen($strName);
if (substr($strName, $intLength - 1) == "y") {
return substr($strName, 0, $intLength - 1) . "ies";
}
if (substr($strName, $intLength - 1) == "s") {
return $strName . "es";
}
if (substr($strName, $intLength - 1) == "x") {
return $strName . "es";
}
if (substr($strName, $intLength - 1) == "z") {
return $strName . "zes";
}
if (substr($strName, $intLength - 2) == "sh") {
return $strName . "es";
}
if (substr($strName, $intLength - 2) == "ch") {
return $strName . "es";
}
return $strName . "s";
} | php | protected function pluralize($strName)
{
// Special Rules go Here
switch (true) {
case (strtolower($strName) == 'play'):
return $strName . 's';
}
$intLength = strlen($strName);
if (substr($strName, $intLength - 1) == "y") {
return substr($strName, 0, $intLength - 1) . "ies";
}
if (substr($strName, $intLength - 1) == "s") {
return $strName . "es";
}
if (substr($strName, $intLength - 1) == "x") {
return $strName . "es";
}
if (substr($strName, $intLength - 1) == "z") {
return $strName . "zes";
}
if (substr($strName, $intLength - 2) == "sh") {
return $strName . "es";
}
if (substr($strName, $intLength - 2) == "ch") {
return $strName . "es";
}
return $strName . "s";
} | [
"protected",
"function",
"pluralize",
"(",
"$",
"strName",
")",
"{",
"// Special Rules go Here",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"strtolower",
"(",
"$",
"strName",
")",
"==",
"'play'",
")",
":",
"return",
"$",
"strName",
".",
"'s'",
";",
"}",
"$",
"intLength",
"=",
"strlen",
"(",
"$",
"strName",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"strName",
",",
"$",
"intLength",
"-",
"1",
")",
"==",
"\"y\"",
")",
"{",
"return",
"substr",
"(",
"$",
"strName",
",",
"0",
",",
"$",
"intLength",
"-",
"1",
")",
".",
"\"ies\"",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"strName",
",",
"$",
"intLength",
"-",
"1",
")",
"==",
"\"s\"",
")",
"{",
"return",
"$",
"strName",
".",
"\"es\"",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"strName",
",",
"$",
"intLength",
"-",
"1",
")",
"==",
"\"x\"",
")",
"{",
"return",
"$",
"strName",
".",
"\"es\"",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"strName",
",",
"$",
"intLength",
"-",
"1",
")",
"==",
"\"z\"",
")",
"{",
"return",
"$",
"strName",
".",
"\"zes\"",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"strName",
",",
"$",
"intLength",
"-",
"2",
")",
"==",
"\"sh\"",
")",
"{",
"return",
"$",
"strName",
".",
"\"es\"",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"strName",
",",
"$",
"intLength",
"-",
"2",
")",
"==",
"\"ch\"",
")",
"{",
"return",
"$",
"strName",
".",
"\"es\"",
";",
"}",
"return",
"$",
"strName",
".",
"\"s\"",
";",
"}"
]
| Return the plural of the given name. Override this and return the plural version of particular names
if this generic version isn't working for you.
@param string $strName
@return string | [
"Return",
"the",
"plural",
"of",
"the",
"given",
"name",
".",
"Override",
"this",
"and",
"return",
"the",
"plural",
"version",
"of",
"particular",
"names",
"if",
"this",
"generic",
"version",
"isn",
"t",
"working",
"for",
"you",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1325-L1354 |
webforge-labs/psc-cms | lib/Psc/Doctrine/UniqueConstraint.php | UniqueConstraint.getDataHelper | public function getDataHelper() {
$keys = $this->getKeys();
$data = function () use ($keys) {
$args = func_get_args();
$argsNum = count($args);
if ($argsNum > count($keys)+1 || $argsNum < count($keys)) {
throw new \InvalidArgumentException('Es ist eine Anzahl von '.count($keys).'( + 1) Argumenten erwartet: '.$argsNum.' übergeben');
}
$keyData = array();
foreach ($keys as $key) {
$keyData[$key] = array_shift($args);
}
if (count($args) > 0) {
$keyData['identifier'] = array_shift($args);
}
return $keyData;
};
return $data;
} | php | public function getDataHelper() {
$keys = $this->getKeys();
$data = function () use ($keys) {
$args = func_get_args();
$argsNum = count($args);
if ($argsNum > count($keys)+1 || $argsNum < count($keys)) {
throw new \InvalidArgumentException('Es ist eine Anzahl von '.count($keys).'( + 1) Argumenten erwartet: '.$argsNum.' übergeben');
}
$keyData = array();
foreach ($keys as $key) {
$keyData[$key] = array_shift($args);
}
if (count($args) > 0) {
$keyData['identifier'] = array_shift($args);
}
return $keyData;
};
return $data;
} | [
"public",
"function",
"getDataHelper",
"(",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"getKeys",
"(",
")",
";",
"$",
"data",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"keys",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"argsNum",
"=",
"count",
"(",
"$",
"args",
")",
";",
"if",
"(",
"$",
"argsNum",
">",
"count",
"(",
"$",
"keys",
")",
"+",
"1",
"||",
"$",
"argsNum",
"<",
"count",
"(",
"$",
"keys",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Es ist eine Anzahl von '",
".",
"count",
"(",
"$",
"keys",
")",
".",
"'( + 1) Argumenten erwartet: '",
".",
"$",
"argsNum",
".",
"' übergeben')",
";",
"",
"}",
"$",
"keyData",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"keyData",
"[",
"$",
"key",
"]",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"args",
")",
">",
"0",
")",
"{",
"$",
"keyData",
"[",
"'identifier'",
"]",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"}",
"return",
"$",
"keyData",
";",
"}",
";",
"return",
"$",
"data",
";",
"}"
]
| Gibt einen Helper zurück, der die Daten des Unique-Keys für z. B. UniqueConstraintValidator vorbereitet
der Helper hat soviele Parameter wie es Keys im UnqiueConstraint gibt. Die Reihenfolge der Argumente ist die Reihenfolge der Keys
@see Test::testHelperGeneration()
@return Closure | [
"Gibt",
"einen",
"Helper",
"zurück",
"der",
"die",
"Daten",
"des",
"Unique",
"-",
"Keys",
"für",
"z",
".",
"B",
".",
"UniqueConstraintValidator",
"vorbereitet"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/UniqueConstraint.php#L65-L87 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBOGeneratorBundle/Datatable/Data/DatatableData.php | DatatableData.setColumns | private function setColumns()
{
$this->datatableQuery->setSelectColumns($this->selectColumns);
$this->datatableQuery->setAllColumns($this->allColumns);
$this->datatableQuery->setJoins($this->joins);
$this->datatableQuery->setSearchColumns($this->searchColumns);
$this->datatableQuery->setOrderColumns($this->orderColumns);
return $this;
} | php | private function setColumns()
{
$this->datatableQuery->setSelectColumns($this->selectColumns);
$this->datatableQuery->setAllColumns($this->allColumns);
$this->datatableQuery->setJoins($this->joins);
$this->datatableQuery->setSearchColumns($this->searchColumns);
$this->datatableQuery->setOrderColumns($this->orderColumns);
return $this;
} | [
"private",
"function",
"setColumns",
"(",
")",
"{",
"$",
"this",
"->",
"datatableQuery",
"->",
"setSelectColumns",
"(",
"$",
"this",
"->",
"selectColumns",
")",
";",
"$",
"this",
"->",
"datatableQuery",
"->",
"setAllColumns",
"(",
"$",
"this",
"->",
"allColumns",
")",
";",
"$",
"this",
"->",
"datatableQuery",
"->",
"setJoins",
"(",
"$",
"this",
"->",
"joins",
")",
";",
"$",
"this",
"->",
"datatableQuery",
"->",
"setSearchColumns",
"(",
"$",
"this",
"->",
"searchColumns",
")",
";",
"$",
"this",
"->",
"datatableQuery",
"->",
"setOrderColumns",
"(",
"$",
"this",
"->",
"orderColumns",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set columns.
@return $this | [
"Set",
"columns",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBOGeneratorBundle/Datatable/Data/DatatableData.php#L27-L36 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBOGeneratorBundle/Datatable/Data/DatatableData.php | DatatableData.buildQuery | private function buildQuery()
{
$this->datatableQuery->setSelectFrom();
$this->datatableQuery->setLeftJoins();
$this->datatableQuery->setWhere();
$this->datatableQuery->setWhereCallbacks();
$this->datatableQuery->setOrderBy();
$this->datatableQuery->setLimit();
return $this;
} | php | private function buildQuery()
{
$this->datatableQuery->setSelectFrom();
$this->datatableQuery->setLeftJoins();
$this->datatableQuery->setWhere();
$this->datatableQuery->setWhereCallbacks();
$this->datatableQuery->setOrderBy();
$this->datatableQuery->setLimit();
return $this;
} | [
"private",
"function",
"buildQuery",
"(",
")",
"{",
"$",
"this",
"->",
"datatableQuery",
"->",
"setSelectFrom",
"(",
")",
";",
"$",
"this",
"->",
"datatableQuery",
"->",
"setLeftJoins",
"(",
")",
";",
"$",
"this",
"->",
"datatableQuery",
"->",
"setWhere",
"(",
")",
";",
"$",
"this",
"->",
"datatableQuery",
"->",
"setWhereCallbacks",
"(",
")",
";",
"$",
"this",
"->",
"datatableQuery",
"->",
"setOrderBy",
"(",
")",
";",
"$",
"this",
"->",
"datatableQuery",
"->",
"setLimit",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Build query.
@return $this | [
"Build",
"query",
"."
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBOGeneratorBundle/Datatable/Data/DatatableData.php#L43-L53 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBOGeneratorBundle/Datatable/Data/DatatableData.php | DatatableData.getResponse | public function getResponse()
{
$this->setColumns();
$this->buildQuery();
$fresults = new Paginator($this->datatableQuery->execute(), true);
$output = array('data' => array());
$outputHeader = array(
'draw' => (integer) $this->requestParams['draw'],
'recordsTotal' => (integer) $this->datatableQuery->getCountAllResults($this->rootEntityIdentifier),
'recordsFiltered' => (integer) $this->datatableQuery->getCountFilteredResults($this->rootEntityIdentifier),
);
foreach ($fresults as $item) {
if (is_callable($this->lineFormatter)) {
$callable = $this->lineFormatter;
$item = call_user_func($callable, $item, $outputHeader);
}
$output['data'][] = $item;
}
$this->response = array_merge($outputHeader, $output);
$json = $this->serializer->serialize($this->response, 'json');
$response = new Response($json);
$response->headers->set('Content-Type', 'application/json');
return $response;
} | php | public function getResponse()
{
$this->setColumns();
$this->buildQuery();
$fresults = new Paginator($this->datatableQuery->execute(), true);
$output = array('data' => array());
$outputHeader = array(
'draw' => (integer) $this->requestParams['draw'],
'recordsTotal' => (integer) $this->datatableQuery->getCountAllResults($this->rootEntityIdentifier),
'recordsFiltered' => (integer) $this->datatableQuery->getCountFilteredResults($this->rootEntityIdentifier),
);
foreach ($fresults as $item) {
if (is_callable($this->lineFormatter)) {
$callable = $this->lineFormatter;
$item = call_user_func($callable, $item, $outputHeader);
}
$output['data'][] = $item;
}
$this->response = array_merge($outputHeader, $output);
$json = $this->serializer->serialize($this->response, 'json');
$response = new Response($json);
$response->headers->set('Content-Type', 'application/json');
return $response;
} | [
"public",
"function",
"getResponse",
"(",
")",
"{",
"$",
"this",
"->",
"setColumns",
"(",
")",
";",
"$",
"this",
"->",
"buildQuery",
"(",
")",
";",
"$",
"fresults",
"=",
"new",
"Paginator",
"(",
"$",
"this",
"->",
"datatableQuery",
"->",
"execute",
"(",
")",
",",
"true",
")",
";",
"$",
"output",
"=",
"array",
"(",
"'data'",
"=>",
"array",
"(",
")",
")",
";",
"$",
"outputHeader",
"=",
"array",
"(",
"'draw'",
"=>",
"(",
"integer",
")",
"$",
"this",
"->",
"requestParams",
"[",
"'draw'",
"]",
",",
"'recordsTotal'",
"=>",
"(",
"integer",
")",
"$",
"this",
"->",
"datatableQuery",
"->",
"getCountAllResults",
"(",
"$",
"this",
"->",
"rootEntityIdentifier",
")",
",",
"'recordsFiltered'",
"=>",
"(",
"integer",
")",
"$",
"this",
"->",
"datatableQuery",
"->",
"getCountFilteredResults",
"(",
"$",
"this",
"->",
"rootEntityIdentifier",
")",
",",
")",
";",
"foreach",
"(",
"$",
"fresults",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"lineFormatter",
")",
")",
"{",
"$",
"callable",
"=",
"$",
"this",
"->",
"lineFormatter",
";",
"$",
"item",
"=",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"item",
",",
"$",
"outputHeader",
")",
";",
"}",
"$",
"output",
"[",
"'data'",
"]",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"$",
"this",
"->",
"response",
"=",
"array_merge",
"(",
"$",
"outputHeader",
",",
"$",
"output",
")",
";",
"$",
"json",
"=",
"$",
"this",
"->",
"serializer",
"->",
"serialize",
"(",
"$",
"this",
"->",
"response",
",",
"'json'",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"json",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"return",
"$",
"response",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBOGeneratorBundle/Datatable/Data/DatatableData.php#L62-L92 |
austinkregel/Warden | src/Warden/Traits/Wardenable.php | Wardenable.toArray | public function toArray()
{
$attr = !empty($this->getWarden()) ? $this->getWarden() : null;
if (empty($attr)) {
$attr = empty($this->getVisible()) ? $this->getFillable() : $this->getVisible();
}
$returnable = [];
$f_model = \FormModel::using('plain')->withModel($this);
foreach ($attr as $old => $new) {
if (!empty($relations = $f_model->getRelationalDataAndModels($this, $old))) {
$returnable[$new] = $relations;
}
if (stripos($old, '_id') !== false) {
if (!empty($this->$new)) {
$returnable[$new] = $relations;
}
} else {
if (isset($this->$old)) {
$returnable[$new] = $this->$old;
}
}
}
return $returnable;
} | php | public function toArray()
{
$attr = !empty($this->getWarden()) ? $this->getWarden() : null;
if (empty($attr)) {
$attr = empty($this->getVisible()) ? $this->getFillable() : $this->getVisible();
}
$returnable = [];
$f_model = \FormModel::using('plain')->withModel($this);
foreach ($attr as $old => $new) {
if (!empty($relations = $f_model->getRelationalDataAndModels($this, $old))) {
$returnable[$new] = $relations;
}
if (stripos($old, '_id') !== false) {
if (!empty($this->$new)) {
$returnable[$new] = $relations;
}
} else {
if (isset($this->$old)) {
$returnable[$new] = $this->$old;
}
}
}
return $returnable;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"attr",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"getWarden",
"(",
")",
")",
"?",
"$",
"this",
"->",
"getWarden",
"(",
")",
":",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"attr",
")",
")",
"{",
"$",
"attr",
"=",
"empty",
"(",
"$",
"this",
"->",
"getVisible",
"(",
")",
")",
"?",
"$",
"this",
"->",
"getFillable",
"(",
")",
":",
"$",
"this",
"->",
"getVisible",
"(",
")",
";",
"}",
"$",
"returnable",
"=",
"[",
"]",
";",
"$",
"f_model",
"=",
"\\",
"FormModel",
"::",
"using",
"(",
"'plain'",
")",
"->",
"withModel",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"attr",
"as",
"$",
"old",
"=>",
"$",
"new",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"relations",
"=",
"$",
"f_model",
"->",
"getRelationalDataAndModels",
"(",
"$",
"this",
",",
"$",
"old",
")",
")",
")",
"{",
"$",
"returnable",
"[",
"$",
"new",
"]",
"=",
"$",
"relations",
";",
"}",
"if",
"(",
"stripos",
"(",
"$",
"old",
",",
"'_id'",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"$",
"new",
")",
")",
"{",
"$",
"returnable",
"[",
"$",
"new",
"]",
"=",
"$",
"relations",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"$",
"old",
")",
")",
"{",
"$",
"returnable",
"[",
"$",
"new",
"]",
"=",
"$",
"this",
"->",
"$",
"old",
";",
"}",
"}",
"}",
"return",
"$",
"returnable",
";",
"}"
]
| Parses the warden config.
@return array | [
"Parses",
"the",
"warden",
"config",
"."
]
| train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Traits/Wardenable.php#L36-L61 |
mimicreative/yii2-datatables | src/actions/DataTableAction.php | DataTableAction.applyFilter | public function applyFilter(ActiveQuery $query, $columns, $search)
{
if ($this->applyFilter !== null) {
return call_user_func($this->applyFilter, $query, $columns, $search);
}
/** @var \yii\db\ActiveRecord $modelClass */
$modelClass = $query->modelClass;
$tableName = $modelClass::tableName();
$tableColumn = $modelClass::getTableSchema()->columnNames;
foreach ($columns as $column) {
$specialCond = (
(!$this->searchEveryField and in_array($column['data'], $tableColumn))
or ($this->searchEveryField and $column['data'] != "")
);
if ($column['searchable'] == 'true' and $specialCond) {
$value = empty($search['value']) ? $column['search']['value'] : $search['value'];
$field = $column['data'];
if (strpos($column['data'], ".") === false) {
$field = $tableName . "." . $column['data'];
}
$query->orFilterWhere(['like', $field, $value]);
}
}
return $query;
} | php | public function applyFilter(ActiveQuery $query, $columns, $search)
{
if ($this->applyFilter !== null) {
return call_user_func($this->applyFilter, $query, $columns, $search);
}
/** @var \yii\db\ActiveRecord $modelClass */
$modelClass = $query->modelClass;
$tableName = $modelClass::tableName();
$tableColumn = $modelClass::getTableSchema()->columnNames;
foreach ($columns as $column) {
$specialCond = (
(!$this->searchEveryField and in_array($column['data'], $tableColumn))
or ($this->searchEveryField and $column['data'] != "")
);
if ($column['searchable'] == 'true' and $specialCond) {
$value = empty($search['value']) ? $column['search']['value'] : $search['value'];
$field = $column['data'];
if (strpos($column['data'], ".") === false) {
$field = $tableName . "." . $column['data'];
}
$query->orFilterWhere(['like', $field, $value]);
}
}
return $query;
} | [
"public",
"function",
"applyFilter",
"(",
"ActiveQuery",
"$",
"query",
",",
"$",
"columns",
",",
"$",
"search",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"applyFilter",
"!==",
"null",
")",
"{",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"applyFilter",
",",
"$",
"query",
",",
"$",
"columns",
",",
"$",
"search",
")",
";",
"}",
"/** @var \\yii\\db\\ActiveRecord $modelClass */",
"$",
"modelClass",
"=",
"$",
"query",
"->",
"modelClass",
";",
"$",
"tableName",
"=",
"$",
"modelClass",
"::",
"tableName",
"(",
")",
";",
"$",
"tableColumn",
"=",
"$",
"modelClass",
"::",
"getTableSchema",
"(",
")",
"->",
"columnNames",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"specialCond",
"=",
"(",
"(",
"!",
"$",
"this",
"->",
"searchEveryField",
"and",
"in_array",
"(",
"$",
"column",
"[",
"'data'",
"]",
",",
"$",
"tableColumn",
")",
")",
"or",
"(",
"$",
"this",
"->",
"searchEveryField",
"and",
"$",
"column",
"[",
"'data'",
"]",
"!=",
"\"\"",
")",
")",
";",
"if",
"(",
"$",
"column",
"[",
"'searchable'",
"]",
"==",
"'true'",
"and",
"$",
"specialCond",
")",
"{",
"$",
"value",
"=",
"empty",
"(",
"$",
"search",
"[",
"'value'",
"]",
")",
"?",
"$",
"column",
"[",
"'search'",
"]",
"[",
"'value'",
"]",
":",
"$",
"search",
"[",
"'value'",
"]",
";",
"$",
"field",
"=",
"$",
"column",
"[",
"'data'",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"column",
"[",
"'data'",
"]",
",",
"\".\"",
")",
"===",
"false",
")",
"{",
"$",
"field",
"=",
"$",
"tableName",
".",
"\".\"",
".",
"$",
"column",
"[",
"'data'",
"]",
";",
"}",
"$",
"query",
"->",
"orFilterWhere",
"(",
"[",
"'like'",
",",
"$",
"field",
",",
"$",
"value",
"]",
")",
";",
"}",
"}",
"return",
"$",
"query",
";",
"}"
]
| @param ActiveQuery $query
@param array $columns
@param array $search
@return ActiveQuery
@throws InvalidConfigException | [
"@param",
"ActiveQuery",
"$query",
"@param",
"array",
"$columns",
"@param",
"array",
"$search"
]
| train | https://github.com/mimicreative/yii2-datatables/blob/8d27b3a6f642e07c98785aeedd0400902416aa75/src/actions/DataTableAction.php#L155-L182 |
ClanCats/Core | src/bundles/Mail/CCMail.php | CCMail.cc | public function cc( $email, $name = null )
{
if ( !is_array( $email ) )
{
$email = array( $email => $name );
}
foreach( $email as $address => $name )
{
if ( is_numeric( $address ) && is_string( $name ) )
{
$this->cc[$name] = null;
}
else
{
$this->cc[$address] = $name;
}
}
return $this;
} | php | public function cc( $email, $name = null )
{
if ( !is_array( $email ) )
{
$email = array( $email => $name );
}
foreach( $email as $address => $name )
{
if ( is_numeric( $address ) && is_string( $name ) )
{
$this->cc[$name] = null;
}
else
{
$this->cc[$address] = $name;
}
}
return $this;
} | [
"public",
"function",
"cc",
"(",
"$",
"email",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"email",
")",
")",
"{",
"$",
"email",
"=",
"array",
"(",
"$",
"email",
"=>",
"$",
"name",
")",
";",
"}",
"foreach",
"(",
"$",
"email",
"as",
"$",
"address",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"address",
")",
"&&",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"cc",
"[",
"$",
"name",
"]",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"cc",
"[",
"$",
"address",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add Carbon copies
Works like the 'to' function.
@param string $email
@param string $name
@return self | [
"Add",
"Carbon",
"copies"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/CCMail.php#L196-L216 |
ClanCats/Core | src/bundles/Mail/CCMail.php | CCMail.attachment | public function attachment( $path, $name )
{
if ( !is_array( $path ) )
{
$path = array( $path => $name );
}
foreach( $path as $file => $name )
{
if ( is_numeric( $file ) && is_string( $name ) )
{
$this->attachments[$name] = null;
}
else
{
$this->attachments[$file] = $name;
}
}
return $this;
} | php | public function attachment( $path, $name )
{
if ( !is_array( $path ) )
{
$path = array( $path => $name );
}
foreach( $path as $file => $name )
{
if ( is_numeric( $file ) && is_string( $name ) )
{
$this->attachments[$name] = null;
}
else
{
$this->attachments[$file] = $name;
}
}
return $this;
} | [
"public",
"function",
"attachment",
"(",
"$",
"path",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"array",
"(",
"$",
"path",
"=>",
"$",
"name",
")",
";",
"}",
"foreach",
"(",
"$",
"path",
"as",
"$",
"file",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"file",
")",
"&&",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"attachments",
"[",
"$",
"name",
"]",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"attachments",
"[",
"$",
"file",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a recipient
$mail->attachment( '/path/to/my/file.zip' );
$mail->attachment( '/some/image.jpg', 'your_photo.jpg' );
$mail->attachment( array( '/some/other/image.jpg' => 'wallpaper.jpg' ) );
@param string $path The path to your file
@param string $name
@return self | [
"Add",
"a",
"recipient"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/CCMail.php#L241-L261 |
ClanCats/Core | src/bundles/Mail/CCMail.php | CCMail.render | public function render()
{
$message = $this->message;
reset( $this->to );
// default view parameters for the message and the layout
$params = array(
'mail' => $this,
'to_email' => key($this->to),
'to_name' => $this->to[ key($this->to) ],
);
// if the message is a view
if ( $message instanceof \CCView )
{
$message->_data = $message->_data + $params;
$message = $message->render();
}
// prepare the layout
if ( $this->layout )
{
$this->layout->content = $message;
$this->layout->_data = $this->layout->_data + $params;
$message = $this->layout->render();
}
// return the renderd message
return $message;
} | php | public function render()
{
$message = $this->message;
reset( $this->to );
// default view parameters for the message and the layout
$params = array(
'mail' => $this,
'to_email' => key($this->to),
'to_name' => $this->to[ key($this->to) ],
);
// if the message is a view
if ( $message instanceof \CCView )
{
$message->_data = $message->_data + $params;
$message = $message->render();
}
// prepare the layout
if ( $this->layout )
{
$this->layout->content = $message;
$this->layout->_data = $this->layout->_data + $params;
$message = $this->layout->render();
}
// return the renderd message
return $message;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"message",
";",
"reset",
"(",
"$",
"this",
"->",
"to",
")",
";",
"// default view parameters for the message and the layout",
"$",
"params",
"=",
"array",
"(",
"'mail'",
"=>",
"$",
"this",
",",
"'to_email'",
"=>",
"key",
"(",
"$",
"this",
"->",
"to",
")",
",",
"'to_name'",
"=>",
"$",
"this",
"->",
"to",
"[",
"key",
"(",
"$",
"this",
"->",
"to",
")",
"]",
",",
")",
";",
"// if the message is a view",
"if",
"(",
"$",
"message",
"instanceof",
"\\",
"CCView",
")",
"{",
"$",
"message",
"->",
"_data",
"=",
"$",
"message",
"->",
"_data",
"+",
"$",
"params",
";",
"$",
"message",
"=",
"$",
"message",
"->",
"render",
"(",
")",
";",
"}",
"// prepare the layout",
"if",
"(",
"$",
"this",
"->",
"layout",
")",
"{",
"$",
"this",
"->",
"layout",
"->",
"content",
"=",
"$",
"message",
";",
"$",
"this",
"->",
"layout",
"->",
"_data",
"=",
"$",
"this",
"->",
"layout",
"->",
"_data",
"+",
"$",
"params",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"layout",
"->",
"render",
"(",
")",
";",
"}",
"// return the renderd message",
"return",
"$",
"message",
";",
"}"
]
| Render the message
@return string | [
"Render",
"the",
"message"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/CCMail.php#L323-L354 |
ClanCats/Core | src/bundles/Mail/CCMail.php | CCMail.send | public function send()
{
// load the mail configuration
$config = \CCConfig::create( 'mail' );
// when mailing is disabled do nothing just return
if ( $config->disabled === true )
{
return;
}
// we cannot send a mail without recipients
if ( empty( $this->to ) )
{
throw new Exception( "Cannot send mail without recipients." );
}
// is a catch all enabled?
if ( $config->get( 'catch_all.enabled' ) === true )
{
// to be able to modify the mail without removing
// the user options we have to clone the mail
$mail = clone $this;
// we have to remove all recipients ( to, ccc, bcc ) and set them
// to our catch all recipients
$mail->to = array();
$mail->cc = array();
$mail->bcc = array();
$mail->to( $config->get( 'catch_all.addresses' ) );
// transport the cloned mail
return $mail->transport( $config->get( 'catch_all.transporter' ) );
}
// transport the mail
$this->transport();
} | php | public function send()
{
// load the mail configuration
$config = \CCConfig::create( 'mail' );
// when mailing is disabled do nothing just return
if ( $config->disabled === true )
{
return;
}
// we cannot send a mail without recipients
if ( empty( $this->to ) )
{
throw new Exception( "Cannot send mail without recipients." );
}
// is a catch all enabled?
if ( $config->get( 'catch_all.enabled' ) === true )
{
// to be able to modify the mail without removing
// the user options we have to clone the mail
$mail = clone $this;
// we have to remove all recipients ( to, ccc, bcc ) and set them
// to our catch all recipients
$mail->to = array();
$mail->cc = array();
$mail->bcc = array();
$mail->to( $config->get( 'catch_all.addresses' ) );
// transport the cloned mail
return $mail->transport( $config->get( 'catch_all.transporter' ) );
}
// transport the mail
$this->transport();
} | [
"public",
"function",
"send",
"(",
")",
"{",
"// load the mail configuration",
"$",
"config",
"=",
"\\",
"CCConfig",
"::",
"create",
"(",
"'mail'",
")",
";",
"// when mailing is disabled do nothing just return",
"if",
"(",
"$",
"config",
"->",
"disabled",
"===",
"true",
")",
"{",
"return",
";",
"}",
"// we cannot send a mail without recipients",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"to",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Cannot send mail without recipients.\"",
")",
";",
"}",
"// is a catch all enabled?",
"if",
"(",
"$",
"config",
"->",
"get",
"(",
"'catch_all.enabled'",
")",
"===",
"true",
")",
"{",
"// to be able to modify the mail without removing",
"// the user options we have to clone the mail",
"$",
"mail",
"=",
"clone",
"$",
"this",
";",
"// we have to remove all recipients ( to, ccc, bcc ) and set them",
"// to our catch all recipients",
"$",
"mail",
"->",
"to",
"=",
"array",
"(",
")",
";",
"$",
"mail",
"->",
"cc",
"=",
"array",
"(",
")",
";",
"$",
"mail",
"->",
"bcc",
"=",
"array",
"(",
")",
";",
"$",
"mail",
"->",
"to",
"(",
"$",
"config",
"->",
"get",
"(",
"'catch_all.addresses'",
")",
")",
";",
"// transport the cloned mail",
"return",
"$",
"mail",
"->",
"transport",
"(",
"$",
"config",
"->",
"get",
"(",
"'catch_all.transporter'",
")",
")",
";",
"}",
"// transport the mail",
"$",
"this",
"->",
"transport",
"(",
")",
";",
"}"
]
| Prepare the message for sending to the transport
@return void | [
"Prepare",
"the",
"message",
"for",
"sending",
"to",
"the",
"transport"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/CCMail.php#L361-L399 |
ClanCats/Core | src/bundles/Mail/CCMail.php | CCMail.transport | protected function transport( $transporter = null )
{
if ( !is_null( $transporter ) )
{
$transporter = Transporter::create( $transporter );
}
else
{
$transporter = $this->transporter;
}
// pass the current mail to the transporter
$transporter->send( $this );
} | php | protected function transport( $transporter = null )
{
if ( !is_null( $transporter ) )
{
$transporter = Transporter::create( $transporter );
}
else
{
$transporter = $this->transporter;
}
// pass the current mail to the transporter
$transporter->send( $this );
} | [
"protected",
"function",
"transport",
"(",
"$",
"transporter",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"transporter",
")",
")",
"{",
"$",
"transporter",
"=",
"Transporter",
"::",
"create",
"(",
"$",
"transporter",
")",
";",
"}",
"else",
"{",
"$",
"transporter",
"=",
"$",
"this",
"->",
"transporter",
";",
"}",
"// pass the current mail to the transporter",
"$",
"transporter",
"->",
"send",
"(",
"$",
"this",
")",
";",
"}"
]
| Transport the message
@param string $transport Use a diffrent transporter
@return void | [
"Transport",
"the",
"message"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/CCMail.php#L407-L420 |
tomphp/siren-php | src/ActionBuilder.php | ActionBuilder.addField | public function addField(
$fieldOrName,
$classes = [],
string $type = null,
$value = null,
string $title = null
) : self {
if (!$fieldOrName instanceof Field) {
$fieldOrName = new Field(
$fieldOrName,
is_array($classes) ? $classes : [$classes],
$type,
$value,
$title
);
}
$this->fields[] = $fieldOrName;
return $this;
} | php | public function addField(
$fieldOrName,
$classes = [],
string $type = null,
$value = null,
string $title = null
) : self {
if (!$fieldOrName instanceof Field) {
$fieldOrName = new Field(
$fieldOrName,
is_array($classes) ? $classes : [$classes],
$type,
$value,
$title
);
}
$this->fields[] = $fieldOrName;
return $this;
} | [
"public",
"function",
"addField",
"(",
"$",
"fieldOrName",
",",
"$",
"classes",
"=",
"[",
"]",
",",
"string",
"$",
"type",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"string",
"$",
"title",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"!",
"$",
"fieldOrName",
"instanceof",
"Field",
")",
"{",
"$",
"fieldOrName",
"=",
"new",
"Field",
"(",
"$",
"fieldOrName",
",",
"is_array",
"(",
"$",
"classes",
")",
"?",
"$",
"classes",
":",
"[",
"$",
"classes",
"]",
",",
"$",
"type",
",",
"$",
"value",
",",
"$",
"title",
")",
";",
"}",
"$",
"this",
"->",
"fields",
"[",
"]",
"=",
"$",
"fieldOrName",
";",
"return",
"$",
"this",
";",
"}"
]
| @param Field|string $fieldOrName
@param string[]|null $classes
@param string|null $type
@param mixed $value
@param string|null $title
@return $this | [
"@param",
"Field|string",
"$fieldOrName",
"@param",
"string",
"[]",
"|null",
"$classes",
"@param",
"string|null",
"$type",
"@param",
"mixed",
"$value",
"@param",
"string|null",
"$title"
]
| train | https://github.com/tomphp/siren-php/blob/22bdce3d7d87693df29011a5139dbad349c875db/src/ActionBuilder.php#L96-L116 |
datasift/php_webdriver | src/php/DataSift/WebDriver/WebDriverBase.php | WebDriverBase.returnExceptionToThrow | public function returnExceptionToThrow($status_code)
{
static $map = array (
1 => 'E4xx_IndexOutOfBoundsWebDriverError',
2 => 'E4xx_NoCollectionWebDriverError',
3 => 'E4xx_NoStringWebDriverError',
4 => 'E4xx_NoStringLengthWebDriverError',
5 => 'E4xx_NoStringWrapperWebDriverError',
6 => 'E4xx_NoSuchDriverWebDriverError',
7 => 'E4xx_NoSuchElementWebDriverError',
8 => 'E4xx_NoSuchFrameWebDriverError',
9 => 'E5xx_UnknownCommandWebDriverError',
10 => 'E4xx_ObsoleteElementWebDriverError',
11 => 'E4xx_ElementNotDisplayedWebDriverError',
12 => 'E5xx_InvalidElementStateWebDriverError',
13 => 'E5xx_UnhandledWebDriverError',
14 => 'E4xx_ExpectedWebDriverError',
15 => 'E4xx_ElementNotSelectableWebDriverError',
16 => 'E4xx_NoSuchDocumentWebDriverError',
17 => 'E5xx_UnexpectedJavascriptWebDriverError',
18 => 'E4xx_NoScriptResultWebDriverError',
19 => 'E4xx_XPathLookupWebDriverError',
20 => 'E4xx_NoSuchCollectionWebDriverError',
21 => 'E4xx_TimeOutWebDriverError',
22 => 'E5xx_NullPointerWebDriverError',
23 => 'E4xx_NoSuchWindowWebDriverError',
24 => 'E4xx_InvalidCookieDomainWebDriverError',
25 => 'E4xx_UnableToSetCookieWebDriverError',
26 => 'E4xx_UnexpectedAlertOpenWebDriverError',
27 => 'E4xx_NoAlertOpenWebDriverError',
28 => 'E4xx_ScriptTimeoutWebDriverError',
29 => 'E4xx_InvalidElementCoordinatesWebDriverError',
30 => 'E4xx_IMENotAvailableWebDriverError',
31 => 'E5xx_IMEEngineActivationFailedWebDriverError',
32 => 'E4xx_InvalidSelectorWebDriverError',
33 => 'E5xx_SessionNotCreatedWebDriverError',
34 => 'E4xx_MoveTargetOutOfBoundsWebDriverError',
);
// did an error occur?
if ($status_code == 0) {
return null;
}
// is this a known problem?
if (isset($map[$status_code])) {
return __NAMESPACE__ . '\\' . $map[$status_code];
}
// we have an unknown exception
return __NAMESPACE__ . '\\UnknownWebDriverError';
} | php | public function returnExceptionToThrow($status_code)
{
static $map = array (
1 => 'E4xx_IndexOutOfBoundsWebDriverError',
2 => 'E4xx_NoCollectionWebDriverError',
3 => 'E4xx_NoStringWebDriverError',
4 => 'E4xx_NoStringLengthWebDriverError',
5 => 'E4xx_NoStringWrapperWebDriverError',
6 => 'E4xx_NoSuchDriverWebDriverError',
7 => 'E4xx_NoSuchElementWebDriverError',
8 => 'E4xx_NoSuchFrameWebDriverError',
9 => 'E5xx_UnknownCommandWebDriverError',
10 => 'E4xx_ObsoleteElementWebDriverError',
11 => 'E4xx_ElementNotDisplayedWebDriverError',
12 => 'E5xx_InvalidElementStateWebDriverError',
13 => 'E5xx_UnhandledWebDriverError',
14 => 'E4xx_ExpectedWebDriverError',
15 => 'E4xx_ElementNotSelectableWebDriverError',
16 => 'E4xx_NoSuchDocumentWebDriverError',
17 => 'E5xx_UnexpectedJavascriptWebDriverError',
18 => 'E4xx_NoScriptResultWebDriverError',
19 => 'E4xx_XPathLookupWebDriverError',
20 => 'E4xx_NoSuchCollectionWebDriverError',
21 => 'E4xx_TimeOutWebDriverError',
22 => 'E5xx_NullPointerWebDriverError',
23 => 'E4xx_NoSuchWindowWebDriverError',
24 => 'E4xx_InvalidCookieDomainWebDriverError',
25 => 'E4xx_UnableToSetCookieWebDriverError',
26 => 'E4xx_UnexpectedAlertOpenWebDriverError',
27 => 'E4xx_NoAlertOpenWebDriverError',
28 => 'E4xx_ScriptTimeoutWebDriverError',
29 => 'E4xx_InvalidElementCoordinatesWebDriverError',
30 => 'E4xx_IMENotAvailableWebDriverError',
31 => 'E5xx_IMEEngineActivationFailedWebDriverError',
32 => 'E4xx_InvalidSelectorWebDriverError',
33 => 'E5xx_SessionNotCreatedWebDriverError',
34 => 'E4xx_MoveTargetOutOfBoundsWebDriverError',
);
// did an error occur?
if ($status_code == 0) {
return null;
}
// is this a known problem?
if (isset($map[$status_code])) {
return __NAMESPACE__ . '\\' . $map[$status_code];
}
// we have an unknown exception
return __NAMESPACE__ . '\\UnknownWebDriverError';
} | [
"public",
"function",
"returnExceptionToThrow",
"(",
"$",
"status_code",
")",
"{",
"static",
"$",
"map",
"=",
"array",
"(",
"1",
"=>",
"'E4xx_IndexOutOfBoundsWebDriverError'",
",",
"2",
"=>",
"'E4xx_NoCollectionWebDriverError'",
",",
"3",
"=>",
"'E4xx_NoStringWebDriverError'",
",",
"4",
"=>",
"'E4xx_NoStringLengthWebDriverError'",
",",
"5",
"=>",
"'E4xx_NoStringWrapperWebDriverError'",
",",
"6",
"=>",
"'E4xx_NoSuchDriverWebDriverError'",
",",
"7",
"=>",
"'E4xx_NoSuchElementWebDriverError'",
",",
"8",
"=>",
"'E4xx_NoSuchFrameWebDriverError'",
",",
"9",
"=>",
"'E5xx_UnknownCommandWebDriverError'",
",",
"10",
"=>",
"'E4xx_ObsoleteElementWebDriverError'",
",",
"11",
"=>",
"'E4xx_ElementNotDisplayedWebDriverError'",
",",
"12",
"=>",
"'E5xx_InvalidElementStateWebDriverError'",
",",
"13",
"=>",
"'E5xx_UnhandledWebDriverError'",
",",
"14",
"=>",
"'E4xx_ExpectedWebDriverError'",
",",
"15",
"=>",
"'E4xx_ElementNotSelectableWebDriverError'",
",",
"16",
"=>",
"'E4xx_NoSuchDocumentWebDriverError'",
",",
"17",
"=>",
"'E5xx_UnexpectedJavascriptWebDriverError'",
",",
"18",
"=>",
"'E4xx_NoScriptResultWebDriverError'",
",",
"19",
"=>",
"'E4xx_XPathLookupWebDriverError'",
",",
"20",
"=>",
"'E4xx_NoSuchCollectionWebDriverError'",
",",
"21",
"=>",
"'E4xx_TimeOutWebDriverError'",
",",
"22",
"=>",
"'E5xx_NullPointerWebDriverError'",
",",
"23",
"=>",
"'E4xx_NoSuchWindowWebDriverError'",
",",
"24",
"=>",
"'E4xx_InvalidCookieDomainWebDriverError'",
",",
"25",
"=>",
"'E4xx_UnableToSetCookieWebDriverError'",
",",
"26",
"=>",
"'E4xx_UnexpectedAlertOpenWebDriverError'",
",",
"27",
"=>",
"'E4xx_NoAlertOpenWebDriverError'",
",",
"28",
"=>",
"'E4xx_ScriptTimeoutWebDriverError'",
",",
"29",
"=>",
"'E4xx_InvalidElementCoordinatesWebDriverError'",
",",
"30",
"=>",
"'E4xx_IMENotAvailableWebDriverError'",
",",
"31",
"=>",
"'E5xx_IMEEngineActivationFailedWebDriverError'",
",",
"32",
"=>",
"'E4xx_InvalidSelectorWebDriverError'",
",",
"33",
"=>",
"'E5xx_SessionNotCreatedWebDriverError'",
",",
"34",
"=>",
"'E4xx_MoveTargetOutOfBoundsWebDriverError'",
",",
")",
";",
"// did an error occur?",
"if",
"(",
"$",
"status_code",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"// is this a known problem?",
"if",
"(",
"isset",
"(",
"$",
"map",
"[",
"$",
"status_code",
"]",
")",
")",
"{",
"return",
"__NAMESPACE__",
".",
"'\\\\'",
".",
"$",
"map",
"[",
"$",
"status_code",
"]",
";",
"}",
"// we have an unknown exception",
"return",
"__NAMESPACE__",
".",
"'\\\\UnknownWebDriverError'",
";",
"}"
]
| Returns the name of the exception class to throw
@param int $status_code the status code returned from webdriver
@return string the name of the exception class to throw, or null if no error occurred | [
"Returns",
"the",
"name",
"of",
"the",
"exception",
"class",
"to",
"throw"
]
| train | https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/WebDriver/WebDriverBase.php#L45-L96 |
datasift/php_webdriver | src/php/DataSift/WebDriver/WebDriverBase.php | WebDriverBase.curl | protected function curl(
$http_method,
$command,
$params = null,
$extra_opts = array()
)
{
// catch problems with the definition of allowed methods in
// child classes
if ($params && is_array($params) && $http_method !== 'POST') {
throw new E5xx_BadMethodCallWebDriverError(sprintf(
'The http method called for %s is %s but it has to be POST' .
' if you want to pass the JSON params %s',
$command,
$http_method,
json_encode($params)));
}
// determine the URL we are posting to
$url = sprintf('%s%s', $this->url, $command);
if ($http_method == 'GET' && $params && (is_int($params) || is_string($params))) {
$url .= '/' . $params;
}
// var_dump($http_method . ' ' . $url);
// create the curl request
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt(
$curl,
CURLOPT_HTTPHEADER,
array(
'Content-Type: application/json;charset=UTF-8',
'Accept: application/json'
)
);
if ($http_method === 'POST') {
curl_setopt($curl, CURLOPT_POST, true);
if ($params) {
if (is_array($params)) {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params));
}
else {
// assume they've already been encoded
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
}
}
}
else if ($http_method == 'DELETE') {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
}
foreach ($extra_opts as $option => $value) {
curl_setopt($curl, $option, $value);
}
// make the curl request
$raw_results = trim(curl_exec($curl));
// find out from curl what happened
$info = curl_getinfo($curl);
// was there an error?
if ($error = curl_error($curl)) {
// yes, there was
// we throw an exception to explain that the call failed
$msg = sprintf(
'Curl error thrown for http %s to %s',
$http_method,
$url
);
if ($params && is_array($params)) {
$msg .= sprintf(' with params: %s', json_encode($params));
}
throw new E5xx_WebDriverCurlException($msg . "\n\n" . $error);
}
// we're done with curl for this request
curl_close($curl);
// convert the response from webdriver into something we can work with
$results = json_decode($raw_results, true);
$results['info'] = $info;
// var_dump($raw_results);
// var_dump($results);
// did we get a value back from webdriver?
if (!isset($results['value'])) {
$results['value'] = null;
}
// did we get a message back from webdriver?
$message = null;
if (isset($results['value']) && is_array($results['value']) && isset($results['value']['message'])) {
$message = $results['value']['message'];
}
// did webdriver send us back an error?
if (isset($results['status']) && $results['status'] != 0) {
// yes it did ... throw the appropriate exception from here
$className = $this->returnExceptionToThrow($results['status']);
throw new $className($message, $results);
}
// if we get here, return the results back to the caller
return $results;
} | php | protected function curl(
$http_method,
$command,
$params = null,
$extra_opts = array()
)
{
// catch problems with the definition of allowed methods in
// child classes
if ($params && is_array($params) && $http_method !== 'POST') {
throw new E5xx_BadMethodCallWebDriverError(sprintf(
'The http method called for %s is %s but it has to be POST' .
' if you want to pass the JSON params %s',
$command,
$http_method,
json_encode($params)));
}
// determine the URL we are posting to
$url = sprintf('%s%s', $this->url, $command);
if ($http_method == 'GET' && $params && (is_int($params) || is_string($params))) {
$url .= '/' . $params;
}
// var_dump($http_method . ' ' . $url);
// create the curl request
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt(
$curl,
CURLOPT_HTTPHEADER,
array(
'Content-Type: application/json;charset=UTF-8',
'Accept: application/json'
)
);
if ($http_method === 'POST') {
curl_setopt($curl, CURLOPT_POST, true);
if ($params) {
if (is_array($params)) {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params));
}
else {
// assume they've already been encoded
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
}
}
}
else if ($http_method == 'DELETE') {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
}
foreach ($extra_opts as $option => $value) {
curl_setopt($curl, $option, $value);
}
// make the curl request
$raw_results = trim(curl_exec($curl));
// find out from curl what happened
$info = curl_getinfo($curl);
// was there an error?
if ($error = curl_error($curl)) {
// yes, there was
// we throw an exception to explain that the call failed
$msg = sprintf(
'Curl error thrown for http %s to %s',
$http_method,
$url
);
if ($params && is_array($params)) {
$msg .= sprintf(' with params: %s', json_encode($params));
}
throw new E5xx_WebDriverCurlException($msg . "\n\n" . $error);
}
// we're done with curl for this request
curl_close($curl);
// convert the response from webdriver into something we can work with
$results = json_decode($raw_results, true);
$results['info'] = $info;
// var_dump($raw_results);
// var_dump($results);
// did we get a value back from webdriver?
if (!isset($results['value'])) {
$results['value'] = null;
}
// did we get a message back from webdriver?
$message = null;
if (isset($results['value']) && is_array($results['value']) && isset($results['value']['message'])) {
$message = $results['value']['message'];
}
// did webdriver send us back an error?
if (isset($results['status']) && $results['status'] != 0) {
// yes it did ... throw the appropriate exception from here
$className = $this->returnExceptionToThrow($results['status']);
throw new $className($message, $results);
}
// if we get here, return the results back to the caller
return $results;
} | [
"protected",
"function",
"curl",
"(",
"$",
"http_method",
",",
"$",
"command",
",",
"$",
"params",
"=",
"null",
",",
"$",
"extra_opts",
"=",
"array",
"(",
")",
")",
"{",
"// catch problems with the definition of allowed methods in",
"// child classes",
"if",
"(",
"$",
"params",
"&&",
"is_array",
"(",
"$",
"params",
")",
"&&",
"$",
"http_method",
"!==",
"'POST'",
")",
"{",
"throw",
"new",
"E5xx_BadMethodCallWebDriverError",
"(",
"sprintf",
"(",
"'The http method called for %s is %s but it has to be POST'",
".",
"' if you want to pass the JSON params %s'",
",",
"$",
"command",
",",
"$",
"http_method",
",",
"json_encode",
"(",
"$",
"params",
")",
")",
")",
";",
"}",
"// determine the URL we are posting to",
"$",
"url",
"=",
"sprintf",
"(",
"'%s%s'",
",",
"$",
"this",
"->",
"url",
",",
"$",
"command",
")",
";",
"if",
"(",
"$",
"http_method",
"==",
"'GET'",
"&&",
"$",
"params",
"&&",
"(",
"is_int",
"(",
"$",
"params",
")",
"||",
"is_string",
"(",
"$",
"params",
")",
")",
")",
"{",
"$",
"url",
".=",
"'/'",
".",
"$",
"params",
";",
"}",
"// var_dump($http_method . ' ' . $url);",
"// create the curl request",
"$",
"curl",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_HTTPHEADER",
",",
"array",
"(",
"'Content-Type: application/json;charset=UTF-8'",
",",
"'Accept: application/json'",
")",
")",
";",
"if",
"(",
"$",
"http_method",
"===",
"'POST'",
")",
"{",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"if",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_POSTFIELDS",
",",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"else",
"{",
"// assume they've already been encoded",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"params",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"$",
"http_method",
"==",
"'DELETE'",
")",
"{",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"'DELETE'",
")",
";",
"}",
"foreach",
"(",
"$",
"extra_opts",
"as",
"$",
"option",
"=>",
"$",
"value",
")",
"{",
"curl_setopt",
"(",
"$",
"curl",
",",
"$",
"option",
",",
"$",
"value",
")",
";",
"}",
"// make the curl request",
"$",
"raw_results",
"=",
"trim",
"(",
"curl_exec",
"(",
"$",
"curl",
")",
")",
";",
"// find out from curl what happened",
"$",
"info",
"=",
"curl_getinfo",
"(",
"$",
"curl",
")",
";",
"// was there an error?",
"if",
"(",
"$",
"error",
"=",
"curl_error",
"(",
"$",
"curl",
")",
")",
"{",
"// yes, there was",
"// we throw an exception to explain that the call failed",
"$",
"msg",
"=",
"sprintf",
"(",
"'Curl error thrown for http %s to %s'",
",",
"$",
"http_method",
",",
"$",
"url",
")",
";",
"if",
"(",
"$",
"params",
"&&",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"msg",
".=",
"sprintf",
"(",
"' with params: %s'",
",",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"throw",
"new",
"E5xx_WebDriverCurlException",
"(",
"$",
"msg",
".",
"\"\\n\\n\"",
".",
"$",
"error",
")",
";",
"}",
"// we're done with curl for this request",
"curl_close",
"(",
"$",
"curl",
")",
";",
"// convert the response from webdriver into something we can work with",
"$",
"results",
"=",
"json_decode",
"(",
"$",
"raw_results",
",",
"true",
")",
";",
"$",
"results",
"[",
"'info'",
"]",
"=",
"$",
"info",
";",
"// var_dump($raw_results);",
"// var_dump($results);",
"// did we get a value back from webdriver?",
"if",
"(",
"!",
"isset",
"(",
"$",
"results",
"[",
"'value'",
"]",
")",
")",
"{",
"$",
"results",
"[",
"'value'",
"]",
"=",
"null",
";",
"}",
"// did we get a message back from webdriver?",
"$",
"message",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"results",
"[",
"'value'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"results",
"[",
"'value'",
"]",
")",
"&&",
"isset",
"(",
"$",
"results",
"[",
"'value'",
"]",
"[",
"'message'",
"]",
")",
")",
"{",
"$",
"message",
"=",
"$",
"results",
"[",
"'value'",
"]",
"[",
"'message'",
"]",
";",
"}",
"// did webdriver send us back an error?",
"if",
"(",
"isset",
"(",
"$",
"results",
"[",
"'status'",
"]",
")",
"&&",
"$",
"results",
"[",
"'status'",
"]",
"!=",
"0",
")",
"{",
"// yes it did ... throw the appropriate exception from here",
"$",
"className",
"=",
"$",
"this",
"->",
"returnExceptionToThrow",
"(",
"$",
"results",
"[",
"'status'",
"]",
")",
";",
"throw",
"new",
"$",
"className",
"(",
"$",
"message",
",",
"$",
"results",
")",
";",
"}",
"// if we get here, return the results back to the caller",
"return",
"$",
"results",
";",
"}"
]
| Curl request to webdriver server.
$http_method 'GET', 'POST', or 'DELETE'
$command If not defined in methods() this function will throw.
$params If an array(), they will be posted as JSON parameters
If a number or string, "/$params" is appended to url
$extra_opts key=>value pairs of curl options to pass to curl_setopt() | [
"Curl",
"request",
"to",
"webdriver",
"server",
"."
]
| train | https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/WebDriver/WebDriverBase.php#L145-L252 |
datasift/php_webdriver | src/php/DataSift/WebDriver/WebDriverBase.php | WebDriverBase.getHttpVerb | private function getHttpVerb($webdriver_command)
{
$methods = $this->getMethods();
if (!isset($methods[$webdriver_command])) {
throw new E5xx_BadMethodCallWebDriverError(sprintf(
'%s is not a valid webdriver command.',
$webdriver_command
));
}
// the first element in the array is the default HTTP verb to use
return $methods[$webdriver_command];
} | php | private function getHttpVerb($webdriver_command)
{
$methods = $this->getMethods();
if (!isset($methods[$webdriver_command])) {
throw new E5xx_BadMethodCallWebDriverError(sprintf(
'%s is not a valid webdriver command.',
$webdriver_command
));
}
// the first element in the array is the default HTTP verb to use
return $methods[$webdriver_command];
} | [
"private",
"function",
"getHttpVerb",
"(",
"$",
"webdriver_command",
")",
"{",
"$",
"methods",
"=",
"$",
"this",
"->",
"getMethods",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"methods",
"[",
"$",
"webdriver_command",
"]",
")",
")",
"{",
"throw",
"new",
"E5xx_BadMethodCallWebDriverError",
"(",
"sprintf",
"(",
"'%s is not a valid webdriver command.'",
",",
"$",
"webdriver_command",
")",
")",
";",
"}",
"// the first element in the array is the default HTTP verb to use",
"return",
"$",
"methods",
"[",
"$",
"webdriver_command",
"]",
";",
"}"
]
| determine the HTTP verb to use for a given webdriver command
@param string $webdriver_command the webdriver command to use
@return string the HTTP verb to use | [
"determine",
"the",
"HTTP",
"verb",
"to",
"use",
"for",
"a",
"given",
"webdriver",
"command"
]
| train | https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/WebDriver/WebDriverBase.php#L311-L324 |
boekkooi/tactician-amqp | src/Middleware/CommandTransformerMiddleware.php | CommandTransformerMiddleware.execute | public function execute($command, callable $next)
{
if (!is_object($command) || !in_array(get_class($command), $this->commands, true)) {
return $next($command);
}
$message = $this->transformer->transformCommandToMessage($command);
if (!$message instanceof Message) {
throw CommandTransformationException::invalidMessageFromTransformer($message, $command);
}
return $next($message);
} | php | public function execute($command, callable $next)
{
if (!is_object($command) || !in_array(get_class($command), $this->commands, true)) {
return $next($command);
}
$message = $this->transformer->transformCommandToMessage($command);
if (!$message instanceof Message) {
throw CommandTransformationException::invalidMessageFromTransformer($message, $command);
}
return $next($message);
} | [
"public",
"function",
"execute",
"(",
"$",
"command",
",",
"callable",
"$",
"next",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"command",
")",
"||",
"!",
"in_array",
"(",
"get_class",
"(",
"$",
"command",
")",
",",
"$",
"this",
"->",
"commands",
",",
"true",
")",
")",
"{",
"return",
"$",
"next",
"(",
"$",
"command",
")",
";",
"}",
"$",
"message",
"=",
"$",
"this",
"->",
"transformer",
"->",
"transformCommandToMessage",
"(",
"$",
"command",
")",
";",
"if",
"(",
"!",
"$",
"message",
"instanceof",
"Message",
")",
"{",
"throw",
"CommandTransformationException",
"::",
"invalidMessageFromTransformer",
"(",
"$",
"message",
",",
"$",
"command",
")",
";",
"}",
"return",
"$",
"next",
"(",
"$",
"message",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/boekkooi/tactician-amqp/blob/55cbb8b9e20aab7891e6a6090b248377c599360e/src/Middleware/CommandTransformerMiddleware.php#L59-L71 |
webforge-labs/psc-cms | lib/Psc/CMS/ProjectsFactory.php | ProjectsFactory.getProjectPaths | public function getProjectPaths($name, $mode = self::MODE_SRC) {
if (!array_key_exists($name, $this->paths)) {
$this->paths[$name] = array();
}
$defaultPaths = array();
if ($mode === self::MODE_SRC) {
$defaultPaths[PSC::PATH_SRC] = './base/src/';
$defaultPaths[PSC::PATH_HTDOCS] = './base/htdocs/';
$defaultPaths[PSC::PATH_BASE] = './base/';
$defaultPaths[PSC::PATH_CACHE] = './base/cache/';
$defaultPaths[PSC::PATH_BIN] = './base/bin/';
$defaultPaths[PSC::PATH_TPL] = './base/src/tpl/';
$defaultPaths[PSC::PATH_TESTDATA] = './base/files/testdata/';
$defaultPaths[PSC::PATH_TESTS] = $name === 'psc-cms' ? './base/src/psc/tests/' : './base/src/'.$name.'/tests/';
$defaultPaths[PSC::PATH_CLASS] = $name === 'psc-cms' ? './base/src/psc/class/Psc/' : './base/src/'.$name.'/';
$defaultPaths[PSC::PATH_FILES] = './base/files/';
$defaultPaths[PSC::PATH_BUILD] = './base/build/';
$defaultPaths[PSC::PATH_VENDOR] = './base/src/vendor/';
} elseif ($mode === self::MODE_PHAR) {
$defaultPaths[PSC::PATH_SRC] = './'; // bedeutet das verzeichnis vom phar.gz
$defaultPaths[PSC::PATH_HTDOCS] = './www/';
$defaultPaths[PSC::PATH_BASE] = './';
$defaultPaths[PSC::PATH_CACHE] = './cache/';
$defaultPaths[PSC::PATH_BIN] = './';
$defaultPaths[PSC::PATH_TPL] = './tpl/';
$defaultPaths[PSC::PATH_TESTDATA] = './files/testdata/';
$defaultPaths[PSC::PATH_CLASS] = './lib/';
$defaultPaths[PSC::PATH_TESTS] = './tests/';
$defaultPaths[PSC::PATH_FILES] = './files/';
$defaultPaths[PSC::PATH_BUILD] = './build/';
$defaultPaths[PSC::PATH_VENDOR] = './vendor/';
}
return array_replace($defaultPaths, $this->paths[$name]);
} | php | public function getProjectPaths($name, $mode = self::MODE_SRC) {
if (!array_key_exists($name, $this->paths)) {
$this->paths[$name] = array();
}
$defaultPaths = array();
if ($mode === self::MODE_SRC) {
$defaultPaths[PSC::PATH_SRC] = './base/src/';
$defaultPaths[PSC::PATH_HTDOCS] = './base/htdocs/';
$defaultPaths[PSC::PATH_BASE] = './base/';
$defaultPaths[PSC::PATH_CACHE] = './base/cache/';
$defaultPaths[PSC::PATH_BIN] = './base/bin/';
$defaultPaths[PSC::PATH_TPL] = './base/src/tpl/';
$defaultPaths[PSC::PATH_TESTDATA] = './base/files/testdata/';
$defaultPaths[PSC::PATH_TESTS] = $name === 'psc-cms' ? './base/src/psc/tests/' : './base/src/'.$name.'/tests/';
$defaultPaths[PSC::PATH_CLASS] = $name === 'psc-cms' ? './base/src/psc/class/Psc/' : './base/src/'.$name.'/';
$defaultPaths[PSC::PATH_FILES] = './base/files/';
$defaultPaths[PSC::PATH_BUILD] = './base/build/';
$defaultPaths[PSC::PATH_VENDOR] = './base/src/vendor/';
} elseif ($mode === self::MODE_PHAR) {
$defaultPaths[PSC::PATH_SRC] = './'; // bedeutet das verzeichnis vom phar.gz
$defaultPaths[PSC::PATH_HTDOCS] = './www/';
$defaultPaths[PSC::PATH_BASE] = './';
$defaultPaths[PSC::PATH_CACHE] = './cache/';
$defaultPaths[PSC::PATH_BIN] = './';
$defaultPaths[PSC::PATH_TPL] = './tpl/';
$defaultPaths[PSC::PATH_TESTDATA] = './files/testdata/';
$defaultPaths[PSC::PATH_CLASS] = './lib/';
$defaultPaths[PSC::PATH_TESTS] = './tests/';
$defaultPaths[PSC::PATH_FILES] = './files/';
$defaultPaths[PSC::PATH_BUILD] = './build/';
$defaultPaths[PSC::PATH_VENDOR] = './vendor/';
}
return array_replace($defaultPaths, $this->paths[$name]);
} | [
"public",
"function",
"getProjectPaths",
"(",
"$",
"name",
",",
"$",
"mode",
"=",
"self",
"::",
"MODE_SRC",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"paths",
")",
")",
"{",
"$",
"this",
"->",
"paths",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"defaultPaths",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"MODE_SRC",
")",
"{",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_SRC",
"]",
"=",
"'./base/src/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_HTDOCS",
"]",
"=",
"'./base/htdocs/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_BASE",
"]",
"=",
"'./base/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_CACHE",
"]",
"=",
"'./base/cache/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_BIN",
"]",
"=",
"'./base/bin/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_TPL",
"]",
"=",
"'./base/src/tpl/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_TESTDATA",
"]",
"=",
"'./base/files/testdata/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_TESTS",
"]",
"=",
"$",
"name",
"===",
"'psc-cms'",
"?",
"'./base/src/psc/tests/'",
":",
"'./base/src/'",
".",
"$",
"name",
".",
"'/tests/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_CLASS",
"]",
"=",
"$",
"name",
"===",
"'psc-cms'",
"?",
"'./base/src/psc/class/Psc/'",
":",
"'./base/src/'",
".",
"$",
"name",
".",
"'/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_FILES",
"]",
"=",
"'./base/files/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_BUILD",
"]",
"=",
"'./base/build/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_VENDOR",
"]",
"=",
"'./base/src/vendor/'",
";",
"}",
"elseif",
"(",
"$",
"mode",
"===",
"self",
"::",
"MODE_PHAR",
")",
"{",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_SRC",
"]",
"=",
"'./'",
";",
"// bedeutet das verzeichnis vom phar.gz",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_HTDOCS",
"]",
"=",
"'./www/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_BASE",
"]",
"=",
"'./'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_CACHE",
"]",
"=",
"'./cache/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_BIN",
"]",
"=",
"'./'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_TPL",
"]",
"=",
"'./tpl/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_TESTDATA",
"]",
"=",
"'./files/testdata/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_CLASS",
"]",
"=",
"'./lib/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_TESTS",
"]",
"=",
"'./tests/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_FILES",
"]",
"=",
"'./files/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_BUILD",
"]",
"=",
"'./build/'",
";",
"$",
"defaultPaths",
"[",
"PSC",
"::",
"PATH_VENDOR",
"]",
"=",
"'./vendor/'",
";",
"}",
"return",
"array_replace",
"(",
"$",
"defaultPaths",
",",
"$",
"this",
"->",
"paths",
"[",
"$",
"name",
"]",
")",
";",
"}"
]
| Gibt ALLE Pfade für das Projekt zurück
wenn vorher pfade mit setProjectPath gesetzt wurden, werden diese nie überschrieben (auch wenn der modus ein anderer ist)
alle anderen Pfade werden mit defaults gesetzt (je nach modus) | [
"Gibt",
"ALLE",
"Pfade",
"für",
"das",
"Projekt",
"zurück"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectsFactory.php#L66-L101 |
webforge-labs/psc-cms | lib/Psc/CMS/ProjectsFactory.php | ProjectsFactory.getProjectInstance | public function getProjectInstance($name, Dir $root, Configuration $hostConfig, Array $paths, $mode = Project::MODE_SRC, $staging = FALSE) {
$c = array_key_exists($name, $this->projectsClasses) ? $this->projectsClasses[$name] : 'Psc\CMS\Project';
return new $c($name, $root, $hostConfig, $paths, $mode, $staging);
} | php | public function getProjectInstance($name, Dir $root, Configuration $hostConfig, Array $paths, $mode = Project::MODE_SRC, $staging = FALSE) {
$c = array_key_exists($name, $this->projectsClasses) ? $this->projectsClasses[$name] : 'Psc\CMS\Project';
return new $c($name, $root, $hostConfig, $paths, $mode, $staging);
} | [
"public",
"function",
"getProjectInstance",
"(",
"$",
"name",
",",
"Dir",
"$",
"root",
",",
"Configuration",
"$",
"hostConfig",
",",
"Array",
"$",
"paths",
",",
"$",
"mode",
"=",
"Project",
"::",
"MODE_SRC",
",",
"$",
"staging",
"=",
"FALSE",
")",
"{",
"$",
"c",
"=",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"projectsClasses",
")",
"?",
"$",
"this",
"->",
"projectsClasses",
"[",
"$",
"name",
"]",
":",
"'Psc\\CMS\\Project'",
";",
"return",
"new",
"$",
"c",
"(",
"$",
"name",
",",
"$",
"root",
",",
"$",
"hostConfig",
",",
"$",
"paths",
",",
"$",
"mode",
",",
"$",
"staging",
")",
";",
"}"
]
| Interne Methode für die Erstellung eines Projektes
nicht diese Methode nehmen um ein Projekt zu erhalten. Dann getProject() nehmen | [
"Interne",
"Methode",
"für",
"die",
"Erstellung",
"eines",
"Projektes"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectsFactory.php#L123-L127 |
webforge-labs/psc-cms | lib/Psc/CMS/ProjectsFactory.php | ProjectsFactory.getProjectRoot | public function getProjectRoot($name, $mode = Project::MODE_SRC) {
/* root
entweder ist projects.$name.root in der host-config gesetzt, oder es wird angenommen
dass das projekt in
CONFIG[projects.root]/$name/Umsetzung
ist
wenn der Mode PHAR ist, wird das Phar base Directory genommen
wir müssen hier noch unterscheiden, wenn das phar aus dem bin verzeichnis aufgerufen werden sollte
@TODO siehe ePaper42
*/
if ($mode === Project::MODE_PHAR) {
$root = new Dir(PHAR_ROOT); // siehe ProjectBuilder
} elseif (($proot = $this->hostConfig->get(array('projects',$name,'root'))) != NULL)
$root = new Dir($proot);
else
$root = $this->getProjectsRoot()->sub($name.'/Umsetzung/');
return $root;
} | php | public function getProjectRoot($name, $mode = Project::MODE_SRC) {
/* root
entweder ist projects.$name.root in der host-config gesetzt, oder es wird angenommen
dass das projekt in
CONFIG[projects.root]/$name/Umsetzung
ist
wenn der Mode PHAR ist, wird das Phar base Directory genommen
wir müssen hier noch unterscheiden, wenn das phar aus dem bin verzeichnis aufgerufen werden sollte
@TODO siehe ePaper42
*/
if ($mode === Project::MODE_PHAR) {
$root = new Dir(PHAR_ROOT); // siehe ProjectBuilder
} elseif (($proot = $this->hostConfig->get(array('projects',$name,'root'))) != NULL)
$root = new Dir($proot);
else
$root = $this->getProjectsRoot()->sub($name.'/Umsetzung/');
return $root;
} | [
"public",
"function",
"getProjectRoot",
"(",
"$",
"name",
",",
"$",
"mode",
"=",
"Project",
"::",
"MODE_SRC",
")",
"{",
"/* root\n \n entweder ist projects.$name.root in der host-config gesetzt, oder es wird angenommen\n dass das projekt in\n CONFIG[projects.root]/$name/Umsetzung\n ist\n \n wenn der Mode PHAR ist, wird das Phar base Directory genommen\n \n wir müssen hier noch unterscheiden, wenn das phar aus dem bin verzeichnis aufgerufen werden sollte\n @TODO siehe ePaper42\n */",
"if",
"(",
"$",
"mode",
"===",
"Project",
"::",
"MODE_PHAR",
")",
"{",
"$",
"root",
"=",
"new",
"Dir",
"(",
"PHAR_ROOT",
")",
";",
"// siehe ProjectBuilder",
"}",
"elseif",
"(",
"(",
"$",
"proot",
"=",
"$",
"this",
"->",
"hostConfig",
"->",
"get",
"(",
"array",
"(",
"'projects'",
",",
"$",
"name",
",",
"'root'",
")",
")",
")",
"!=",
"NULL",
")",
"$",
"root",
"=",
"new",
"Dir",
"(",
"$",
"proot",
")",
";",
"else",
"$",
"root",
"=",
"$",
"this",
"->",
"getProjectsRoot",
"(",
")",
"->",
"sub",
"(",
"$",
"name",
".",
"'/Umsetzung/'",
")",
";",
"return",
"$",
"root",
";",
"}"
]
| Macht keine Checks ob das Projekt existiert
@return Dir | [
"Macht",
"keine",
"Checks",
"ob",
"das",
"Projekt",
"existiert"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectsFactory.php#L134-L155 |
webforge-labs/psc-cms | lib/Psc/CMS/ProjectsFactory.php | ProjectsFactory.getProjectsRoot | public function getProjectsRoot() {
if (!isset($this->projectsRoot)) {
$this->projectsRoot = new Dir($this->hostConfig->req('projects.root'));
}
return $this->projectsRoot;
} | php | public function getProjectsRoot() {
if (!isset($this->projectsRoot)) {
$this->projectsRoot = new Dir($this->hostConfig->req('projects.root'));
}
return $this->projectsRoot;
} | [
"public",
"function",
"getProjectsRoot",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"projectsRoot",
")",
")",
"{",
"$",
"this",
"->",
"projectsRoot",
"=",
"new",
"Dir",
"(",
"$",
"this",
"->",
"hostConfig",
"->",
"req",
"(",
"'projects.root'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"projectsRoot",
";",
"}"
]
| Gibt das Verzeichnis zurück in dem sich die psc-Projekte befinden
insbesondere sollte dor psc-cms als Verzeichnis drin liegen mit dem Repository fürs CMS
@return Dir | [
"Gibt",
"das",
"Verzeichnis",
"zurück",
"in",
"dem",
"sich",
"die",
"psc",
"-",
"Projekte",
"befinden"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectsFactory.php#L169-L175 |
spiral-modules/scaffolder | source/Scaffolder/Configs/ScaffolderConfig.php | ScaffolderConfig.className | public function className(string $element, string $name): string
{
list($namespace, $name) = $this->parseName($name);
return Inflector::classify($name) . $this->elementPostfix($element);
} | php | public function className(string $element, string $name): string
{
list($namespace, $name) = $this->parseName($name);
return Inflector::classify($name) . $this->elementPostfix($element);
} | [
"public",
"function",
"className",
"(",
"string",
"$",
"element",
",",
"string",
"$",
"name",
")",
":",
"string",
"{",
"list",
"(",
"$",
"namespace",
",",
"$",
"name",
")",
"=",
"$",
"this",
"->",
"parseName",
"(",
"$",
"name",
")",
";",
"return",
"Inflector",
"::",
"classify",
"(",
"$",
"name",
")",
".",
"$",
"this",
"->",
"elementPostfix",
"(",
"$",
"element",
")",
";",
"}"
]
| @param string $element
@param string $name
@return string | [
"@param",
"string",
"$element",
"@param",
"string",
"$name"
]
| train | https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Configs/ScaffolderConfig.php#L65-L70 |
spiral-modules/scaffolder | source/Scaffolder/Configs/ScaffolderConfig.php | ScaffolderConfig.classNamespace | public function classNamespace(string $element, string $name = ''): string
{
$localNamespace = trim($this->getOption($element, 'namespace', ''), '\\');
list($namespace, $name) = $this->parseName($name);
if (!empty($namespace)) {
$localNamespace .= '\\' . Inflector::classify($namespace);
}
if (empty($this->baseNamespace())) {
return $localNamespace;
}
return trim($this->baseNamespace() . '\\' . $localNamespace, '\\');
} | php | public function classNamespace(string $element, string $name = ''): string
{
$localNamespace = trim($this->getOption($element, 'namespace', ''), '\\');
list($namespace, $name) = $this->parseName($name);
if (!empty($namespace)) {
$localNamespace .= '\\' . Inflector::classify($namespace);
}
if (empty($this->baseNamespace())) {
return $localNamespace;
}
return trim($this->baseNamespace() . '\\' . $localNamespace, '\\');
} | [
"public",
"function",
"classNamespace",
"(",
"string",
"$",
"element",
",",
"string",
"$",
"name",
"=",
"''",
")",
":",
"string",
"{",
"$",
"localNamespace",
"=",
"trim",
"(",
"$",
"this",
"->",
"getOption",
"(",
"$",
"element",
",",
"'namespace'",
",",
"''",
")",
",",
"'\\\\'",
")",
";",
"list",
"(",
"$",
"namespace",
",",
"$",
"name",
")",
"=",
"$",
"this",
"->",
"parseName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"namespace",
")",
")",
"{",
"$",
"localNamespace",
".=",
"'\\\\'",
".",
"Inflector",
"::",
"classify",
"(",
"$",
"namespace",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"baseNamespace",
"(",
")",
")",
")",
"{",
"return",
"$",
"localNamespace",
";",
"}",
"return",
"trim",
"(",
"$",
"this",
"->",
"baseNamespace",
"(",
")",
".",
"'\\\\'",
".",
"$",
"localNamespace",
",",
"'\\\\'",
")",
";",
"}"
]
| @param string $element
@param string $name
@return string | [
"@param",
"string",
"$element",
"@param",
"string",
"$name"
]
| train | https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Configs/ScaffolderConfig.php#L78-L92 |
spiral-modules/scaffolder | source/Scaffolder/Configs/ScaffolderConfig.php | ScaffolderConfig.classFilename | public function classFilename(string $element, string $name): string
{
$namespace = $this->classNamespace($element, $name);
$namespace = substr($namespace, strlen($this->baseNamespace()));
$directory = $this->baseDirectory() . '/' . str_replace('\\', '/', $namespace);
return rtrim($directory, '/') . '/' . $this->className($element, $name) . '.php';
} | php | public function classFilename(string $element, string $name): string
{
$namespace = $this->classNamespace($element, $name);
$namespace = substr($namespace, strlen($this->baseNamespace()));
$directory = $this->baseDirectory() . '/' . str_replace('\\', '/', $namespace);
return rtrim($directory, '/') . '/' . $this->className($element, $name) . '.php';
} | [
"public",
"function",
"classFilename",
"(",
"string",
"$",
"element",
",",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"classNamespace",
"(",
"$",
"element",
",",
"$",
"name",
")",
";",
"$",
"namespace",
"=",
"substr",
"(",
"$",
"namespace",
",",
"strlen",
"(",
"$",
"this",
"->",
"baseNamespace",
"(",
")",
")",
")",
";",
"$",
"directory",
"=",
"$",
"this",
"->",
"baseDirectory",
"(",
")",
".",
"'/'",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"namespace",
")",
";",
"return",
"rtrim",
"(",
"$",
"directory",
",",
"'/'",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"className",
"(",
"$",
"element",
",",
"$",
"name",
")",
".",
"'.php'",
";",
"}"
]
| @param string $element
@param string $name
@return string | [
"@param",
"string",
"$element",
"@param",
"string",
"$name"
]
| train | https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Configs/ScaffolderConfig.php#L100-L108 |
spiral-modules/scaffolder | source/Scaffolder/Configs/ScaffolderConfig.php | ScaffolderConfig.getOption | private function getOption(string $element, string $section, $default = null)
{
if (!isset($this->config['declarations'][$element])) {
throw new ScaffolderException("Undefined declaration '{$element}'.");
}
if (array_key_exists($section, $this->config['declarations'][$element])) {
return $this->config['declarations'][$element][$section];
}
return $default;
} | php | private function getOption(string $element, string $section, $default = null)
{
if (!isset($this->config['declarations'][$element])) {
throw new ScaffolderException("Undefined declaration '{$element}'.");
}
if (array_key_exists($section, $this->config['declarations'][$element])) {
return $this->config['declarations'][$element][$section];
}
return $default;
} | [
"private",
"function",
"getOption",
"(",
"string",
"$",
"element",
",",
"string",
"$",
"section",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'declarations'",
"]",
"[",
"$",
"element",
"]",
")",
")",
"{",
"throw",
"new",
"ScaffolderException",
"(",
"\"Undefined declaration '{$element}'.\"",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"section",
",",
"$",
"this",
"->",
"config",
"[",
"'declarations'",
"]",
"[",
"$",
"element",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"config",
"[",
"'declarations'",
"]",
"[",
"$",
"element",
"]",
"[",
"$",
"section",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
]
| @param string $element
@param string $section
@param mixed $default
@return mixed | [
"@param",
"string",
"$element",
"@param",
"string",
"$section",
"@param",
"mixed",
"$default"
]
| train | https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Configs/ScaffolderConfig.php#L159-L170 |
spiral-modules/scaffolder | source/Scaffolder/Configs/ScaffolderConfig.php | ScaffolderConfig.parseName | private function parseName(string $name): array
{
$name = str_replace('/', '\\', $name);
if (strpos($name, '\\') !== false) {
$names = explode('\\', $name);
$class = array_pop($names);
return [join('\\', $names), $class];
}
//No user namespace
return ['', $name];
} | php | private function parseName(string $name): array
{
$name = str_replace('/', '\\', $name);
if (strpos($name, '\\') !== false) {
$names = explode('\\', $name);
$class = array_pop($names);
return [join('\\', $names), $class];
}
//No user namespace
return ['', $name];
} | [
"private",
"function",
"parseName",
"(",
"string",
"$",
"name",
")",
":",
"array",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"name",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'\\\\'",
")",
"!==",
"false",
")",
"{",
"$",
"names",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"name",
")",
";",
"$",
"class",
"=",
"array_pop",
"(",
"$",
"names",
")",
";",
"return",
"[",
"join",
"(",
"'\\\\'",
",",
"$",
"names",
")",
",",
"$",
"class",
"]",
";",
"}",
"//No user namespace",
"return",
"[",
"''",
",",
"$",
"name",
"]",
";",
"}"
]
| Split user name into namespace and class name.
@param string $name
@return array [namespace, name] | [
"Split",
"user",
"name",
"into",
"namespace",
"and",
"class",
"name",
"."
]
| train | https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Configs/ScaffolderConfig.php#L179-L192 |
weew/url | src/Weew/Url/Url.php | Url.match | public function match($pattern, array $patterns = []) {
return $this->matcher->match(
$this->addLeadingSlash($pattern), $this->getPath(), $patterns
);
} | php | public function match($pattern, array $patterns = []) {
return $this->matcher->match(
$this->addLeadingSlash($pattern), $this->getPath(), $patterns
);
} | [
"public",
"function",
"match",
"(",
"$",
"pattern",
",",
"array",
"$",
"patterns",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"matcher",
"->",
"match",
"(",
"$",
"this",
"->",
"addLeadingSlash",
"(",
"$",
"pattern",
")",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"$",
"patterns",
")",
";",
"}"
]
| @param string $pattern
@param array $patterns
@return bool | [
"@param",
"string",
"$pattern",
"@param",
"array",
"$patterns"
]
| train | https://github.com/weew/url/blob/117be15e899cc343f22f04f5eb9e92e2164c56c1/src/Weew/Url/Url.php#L232-L236 |
weew/url | src/Weew/Url/Url.php | Url.parse | public function parse($pattern, array $patterns = []) {
return $this->matcher->parse(
$pattern, $this->getPath(), $patterns
);
} | php | public function parse($pattern, array $patterns = []) {
return $this->matcher->parse(
$pattern, $this->getPath(), $patterns
);
} | [
"public",
"function",
"parse",
"(",
"$",
"pattern",
",",
"array",
"$",
"patterns",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"matcher",
"->",
"parse",
"(",
"$",
"pattern",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"$",
"patterns",
")",
";",
"}"
]
| @param string $pattern
@param array $patterns
@return IDictionary | [
"@param",
"string",
"$pattern",
"@param",
"array",
"$patterns"
]
| train | https://github.com/weew/url/blob/117be15e899cc343f22f04f5eb9e92e2164c56c1/src/Weew/Url/Url.php#L244-L248 |
4devs/ElfinderPhpConnector | Driver/PhotatoesDriver.php | PhotatoesDriver.getRootFileInfo | public function getRootFileInfo()
{
$root = new FileInfo($this->driverOptions['rootName'], $this->getDriverId(), time());
$root->setVolumeid($this->getDriverId().'_');
$root->setDirs(1);
return $root;
} | php | public function getRootFileInfo()
{
$root = new FileInfo($this->driverOptions['rootName'], $this->getDriverId(), time());
$root->setVolumeid($this->getDriverId().'_');
$root->setDirs(1);
return $root;
} | [
"public",
"function",
"getRootFileInfo",
"(",
")",
"{",
"$",
"root",
"=",
"new",
"FileInfo",
"(",
"$",
"this",
"->",
"driverOptions",
"[",
"'rootName'",
"]",
",",
"$",
"this",
"->",
"getDriverId",
"(",
")",
",",
"time",
"(",
")",
")",
";",
"$",
"root",
"->",
"setVolumeid",
"(",
"$",
"this",
"->",
"getDriverId",
"(",
")",
".",
"'_'",
")",
";",
"$",
"root",
"->",
"setDirs",
"(",
"1",
")",
";",
"return",
"$",
"root",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L51-L58 |
4devs/ElfinderPhpConnector | Driver/PhotatoesDriver.php | PhotatoesDriver.open | public function open(Response $response, $target = '', $tree = false, $init = false)
{
$this->getGallery($response, $target);
$root = $this->getRootFileInfo();
if ($init) {
}
if (!$target || $root->getName() == $target) {
$this->getGalleryList($response);
$response->setCwd($root);
$response->addFile($root);
}
if ($tree) {
$this->tree($response, $target);
}
} | php | public function open(Response $response, $target = '', $tree = false, $init = false)
{
$this->getGallery($response, $target);
$root = $this->getRootFileInfo();
if ($init) {
}
if (!$target || $root->getName() == $target) {
$this->getGalleryList($response);
$response->setCwd($root);
$response->addFile($root);
}
if ($tree) {
$this->tree($response, $target);
}
} | [
"public",
"function",
"open",
"(",
"Response",
"$",
"response",
",",
"$",
"target",
"=",
"''",
",",
"$",
"tree",
"=",
"false",
",",
"$",
"init",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"getGallery",
"(",
"$",
"response",
",",
"$",
"target",
")",
";",
"$",
"root",
"=",
"$",
"this",
"->",
"getRootFileInfo",
"(",
")",
";",
"if",
"(",
"$",
"init",
")",
"{",
"}",
"if",
"(",
"!",
"$",
"target",
"||",
"$",
"root",
"->",
"getName",
"(",
")",
"==",
"$",
"target",
")",
"{",
"$",
"this",
"->",
"getGalleryList",
"(",
"$",
"response",
")",
";",
"$",
"response",
"->",
"setCwd",
"(",
"$",
"root",
")",
";",
"$",
"response",
"->",
"addFile",
"(",
"$",
"root",
")",
";",
"}",
"if",
"(",
"$",
"tree",
")",
"{",
"$",
"this",
"->",
"tree",
"(",
"$",
"response",
",",
"$",
"target",
")",
";",
"}",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L63-L78 |
4devs/ElfinderPhpConnector | Driver/PhotatoesDriver.php | PhotatoesDriver.getGalleryList | private function getGalleryList(Response $response)
{
$list = $this->manager->getGalleryList();
foreach ($list as $gallery) {
/* @var \FDevs\Photatoes\Gallery $gallery */
$file = $this->prepareGallery($gallery);
$response->addFile($file);
$response->addTreeFile($file);
}
} | php | private function getGalleryList(Response $response)
{
$list = $this->manager->getGalleryList();
foreach ($list as $gallery) {
/* @var \FDevs\Photatoes\Gallery $gallery */
$file = $this->prepareGallery($gallery);
$response->addFile($file);
$response->addTreeFile($file);
}
} | [
"private",
"function",
"getGalleryList",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"manager",
"->",
"getGalleryList",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"gallery",
")",
"{",
"/* @var \\FDevs\\Photatoes\\Gallery $gallery */",
"$",
"file",
"=",
"$",
"this",
"->",
"prepareGallery",
"(",
"$",
"gallery",
")",
";",
"$",
"response",
"->",
"addFile",
"(",
"$",
"file",
")",
";",
"$",
"response",
"->",
"addTreeFile",
"(",
"$",
"file",
")",
";",
"}",
"}"
]
| get Gallery list.
@param Response $response | [
"get",
"Gallery",
"list",
"."
]
| train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L160-L169 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.