id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
19,800
teneleven/GeolocatorBundle
Controller/GeolocatorController.php
GeolocatorController.buildMap
protected function buildMap($template, Search $result) { $map = $this->getMap(); if (!$result->hasResults()) { //in case of no result we center on the searched location $map->setCenter( new Coordinate( $result->getCenter()->getLatitude(), $result->getCenter()->getLongitude() ) ); return $map; } $twigTemplate = $this->get('twig')->loadTemplate($template); $map->setAutoZoom(true); //this is important to set before adding markers foreach ($result->getResults() as $result) { /* @var $result Result */ $location = $result->location; if (!$location instanceof GeolocatableInterface) { continue; } $marker = new Marker( new Coordinate( $location->getLatitude(), $location->getLongitude() ) ); if ($twigTemplate->hasBlock('teneleven_geolocator_item_window', [])) { $infoWindow = new InfoWindow($twigTemplate->renderBlock( 'teneleven_geolocator_item_window', array('result' => $result) )); $marker->setInfoWindow($infoWindow); $result->mapWindowId = $infoWindow->getVariable(); } $result->mapMarkerId = $marker->getVariable(); $map->getOverlayManager()->addMarker($marker); } return $map; }
php
protected function buildMap($template, Search $result) { $map = $this->getMap(); if (!$result->hasResults()) { //in case of no result we center on the searched location $map->setCenter( new Coordinate( $result->getCenter()->getLatitude(), $result->getCenter()->getLongitude() ) ); return $map; } $twigTemplate = $this->get('twig')->loadTemplate($template); $map->setAutoZoom(true); //this is important to set before adding markers foreach ($result->getResults() as $result) { /* @var $result Result */ $location = $result->location; if (!$location instanceof GeolocatableInterface) { continue; } $marker = new Marker( new Coordinate( $location->getLatitude(), $location->getLongitude() ) ); if ($twigTemplate->hasBlock('teneleven_geolocator_item_window', [])) { $infoWindow = new InfoWindow($twigTemplate->renderBlock( 'teneleven_geolocator_item_window', array('result' => $result) )); $marker->setInfoWindow($infoWindow); $result->mapWindowId = $infoWindow->getVariable(); } $result->mapMarkerId = $marker->getVariable(); $map->getOverlayManager()->addMarker($marker); } return $map; }
[ "protected", "function", "buildMap", "(", "$", "template", ",", "Search", "$", "result", ")", "{", "$", "map", "=", "$", "this", "->", "getMap", "(", ")", ";", "if", "(", "!", "$", "result", "->", "hasResults", "(", ")", ")", "{", "//in case of no result we center on the searched location", "$", "map", "->", "setCenter", "(", "new", "Coordinate", "(", "$", "result", "->", "getCenter", "(", ")", "->", "getLatitude", "(", ")", ",", "$", "result", "->", "getCenter", "(", ")", "->", "getLongitude", "(", ")", ")", ")", ";", "return", "$", "map", ";", "}", "$", "twigTemplate", "=", "$", "this", "->", "get", "(", "'twig'", ")", "->", "loadTemplate", "(", "$", "template", ")", ";", "$", "map", "->", "setAutoZoom", "(", "true", ")", ";", "//this is important to set before adding markers", "foreach", "(", "$", "result", "->", "getResults", "(", ")", "as", "$", "result", ")", "{", "/* @var $result Result */", "$", "location", "=", "$", "result", "->", "location", ";", "if", "(", "!", "$", "location", "instanceof", "GeolocatableInterface", ")", "{", "continue", ";", "}", "$", "marker", "=", "new", "Marker", "(", "new", "Coordinate", "(", "$", "location", "->", "getLatitude", "(", ")", ",", "$", "location", "->", "getLongitude", "(", ")", ")", ")", ";", "if", "(", "$", "twigTemplate", "->", "hasBlock", "(", "'teneleven_geolocator_item_window'", ",", "[", "]", ")", ")", "{", "$", "infoWindow", "=", "new", "InfoWindow", "(", "$", "twigTemplate", "->", "renderBlock", "(", "'teneleven_geolocator_item_window'", ",", "array", "(", "'result'", "=>", "$", "result", ")", ")", ")", ";", "$", "marker", "->", "setInfoWindow", "(", "$", "infoWindow", ")", ";", "$", "result", "->", "mapWindowId", "=", "$", "infoWindow", "->", "getVariable", "(", ")", ";", "}", "$", "result", "->", "mapMarkerId", "=", "$", "marker", "->", "getVariable", "(", ")", ";", "$", "map", "->", "getOverlayManager", "(", ")", "->", "addMarker", "(", "$", "marker", ")", ";", "}", "return", "$", "map", ";", "}" ]
Builds a map of locations @param string $template @param Search $result @return \Ivory\GoogleMap\Map
[ "Builds", "a", "map", "of", "locations" ]
4ead8e783a91577f2a67aa302b79641d4b9e99ad
https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Controller/GeolocatorController.php#L108-L157
19,801
arsengoian/viper-framework
src/Viper/Core/Model/DB/MySQL/Types/StringType.php
StringType.validate
public function validate ($value): void { switch ($this -> sqlType) { case 'ENUM': case 'SET': // Not implemented; break; default: $common = self::TYPES[$this -> sqlType]; if (!$this -> size) $this -> size = $common; else $this -> size = min($this -> size, $common); $this -> getValidator()::apply('strlen', $value, $this -> size); } }
php
public function validate ($value): void { switch ($this -> sqlType) { case 'ENUM': case 'SET': // Not implemented; break; default: $common = self::TYPES[$this -> sqlType]; if (!$this -> size) $this -> size = $common; else $this -> size = min($this -> size, $common); $this -> getValidator()::apply('strlen', $value, $this -> size); } }
[ "public", "function", "validate", "(", "$", "value", ")", ":", "void", "{", "switch", "(", "$", "this", "->", "sqlType", ")", "{", "case", "'ENUM'", ":", "case", "'SET'", ":", "// Not implemented;", "break", ";", "default", ":", "$", "common", "=", "self", "::", "TYPES", "[", "$", "this", "->", "sqlType", "]", ";", "if", "(", "!", "$", "this", "->", "size", ")", "$", "this", "->", "size", "=", "$", "common", ";", "else", "$", "this", "->", "size", "=", "min", "(", "$", "this", "->", "size", ",", "$", "common", ")", ";", "$", "this", "->", "getValidator", "(", ")", "::", "apply", "(", "'strlen'", ",", "$", "value", ",", "$", "this", "->", "size", ")", ";", "}", "}" ]
Checks if the type is correspondent
[ "Checks", "if", "the", "type", "is", "correspondent" ]
22796c5cc219cae3ca0b4af370a347ba2acab0f2
https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Core/Model/DB/MySQL/Types/StringType.php#L36-L51
19,802
2amigos/yiifoundation
widgets/TopBar.php
TopBar.renderNavigation
protected function renderNavigation() { $nav = array(); if (!empty($this->wrapperOptions)) { $nav[] = \CHtml::openTag('div', $this->wrapperOptions); } $nav[] = \CHtml::openTag('nav', $this->htmlOptions); $nav[] = $this->renderTitle(); $nav[] = $this->renderItems(); $nav[] = \CHtml::closeTag('nav'); if (!empty($this->wrapperOptions)) { $nav[] = \CHtml::closeTag('div'); } return implode("\n", $nav); }
php
protected function renderNavigation() { $nav = array(); if (!empty($this->wrapperOptions)) { $nav[] = \CHtml::openTag('div', $this->wrapperOptions); } $nav[] = \CHtml::openTag('nav', $this->htmlOptions); $nav[] = $this->renderTitle(); $nav[] = $this->renderItems(); $nav[] = \CHtml::closeTag('nav'); if (!empty($this->wrapperOptions)) { $nav[] = \CHtml::closeTag('div'); } return implode("\n", $nav); }
[ "protected", "function", "renderNavigation", "(", ")", "{", "$", "nav", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "wrapperOptions", ")", ")", "{", "$", "nav", "[", "]", "=", "\\", "CHtml", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "wrapperOptions", ")", ";", "}", "$", "nav", "[", "]", "=", "\\", "CHtml", "::", "openTag", "(", "'nav'", ",", "$", "this", "->", "htmlOptions", ")", ";", "$", "nav", "[", "]", "=", "$", "this", "->", "renderTitle", "(", ")", ";", "$", "nav", "[", "]", "=", "$", "this", "->", "renderItems", "(", ")", ";", "$", "nav", "[", "]", "=", "\\", "CHtml", "::", "closeTag", "(", "'nav'", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "wrapperOptions", ")", ")", "{", "$", "nav", "[", "]", "=", "\\", "CHtml", "::", "closeTag", "(", "'div'", ")", ";", "}", "return", "implode", "(", "\"\\n\"", ",", "$", "nav", ")", ";", "}" ]
Renders the navigation
[ "Renders", "the", "navigation" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/TopBar.php#L168-L183
19,803
2amigos/yiifoundation
widgets/TopBar.php
TopBar.renderTitle
protected function renderTitle() { $items = array(); $title = \CHtml::tag('h1', array(), \CHtml::link($this->title, $this->titleUrl, $this->titleOptions)); $items[] = \CHtml::tag('li', array('class' => 'name'), $title); $items[] = \CHtml::tag( 'li', array('class' => 'toggle-topbar menu-icon'), \CHtml::link('<span>Menu</span>', '#') ); return \CHtml::tag('ul', array('class' => 'title-area'), implode("\n", $items)); }
php
protected function renderTitle() { $items = array(); $title = \CHtml::tag('h1', array(), \CHtml::link($this->title, $this->titleUrl, $this->titleOptions)); $items[] = \CHtml::tag('li', array('class' => 'name'), $title); $items[] = \CHtml::tag( 'li', array('class' => 'toggle-topbar menu-icon'), \CHtml::link('<span>Menu</span>', '#') ); return \CHtml::tag('ul', array('class' => 'title-area'), implode("\n", $items)); }
[ "protected", "function", "renderTitle", "(", ")", "{", "$", "items", "=", "array", "(", ")", ";", "$", "title", "=", "\\", "CHtml", "::", "tag", "(", "'h1'", ",", "array", "(", ")", ",", "\\", "CHtml", "::", "link", "(", "$", "this", "->", "title", ",", "$", "this", "->", "titleUrl", ",", "$", "this", "->", "titleOptions", ")", ")", ";", "$", "items", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'li'", ",", "array", "(", "'class'", "=>", "'name'", ")", ",", "$", "title", ")", ";", "$", "items", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'li'", ",", "array", "(", "'class'", "=>", "'toggle-topbar menu-icon'", ")", ",", "\\", "CHtml", "::", "link", "(", "'<span>Menu</span>'", ",", "'#'", ")", ")", ";", "return", "\\", "CHtml", "::", "tag", "(", "'ul'", ",", "array", "(", "'class'", "=>", "'title-area'", ")", ",", "implode", "(", "\"\\n\"", ",", "$", "items", ")", ")", ";", "}" ]
Renders the title of navigation @return string
[ "Renders", "the", "title", "of", "navigation" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/TopBar.php#L189-L200
19,804
2amigos/yiifoundation
widgets/TopBar.php
TopBar.renderItems
protected function renderItems() { $items = array(); if (!empty($this->leftItems)) { $tItems = array(); foreach ($this->leftItems as $item) { $tItems[] = $this->renderItem($item); } $items[] = \CHtml::openTag('ul', array('class' => Enum::POS_LEFT)) . implode( "\n", $tItems ) . \CHtml::closeTag( 'ul' ); } if (!empty($this->rightItems)) { $tItems = array(); foreach ($this->rightItems as $item) { $tItems[] = $this->renderItem($item); } $items[] = \CHtml::openTag('ul', array('class' => Enum::POS_RIGHT)) . implode( "\n", $tItems ) . \CHtml::closeTag( 'ul' ); } return \CHtml::tag('section', array('class' => 'top-bar-section'), implode("\n", $items), true); }
php
protected function renderItems() { $items = array(); if (!empty($this->leftItems)) { $tItems = array(); foreach ($this->leftItems as $item) { $tItems[] = $this->renderItem($item); } $items[] = \CHtml::openTag('ul', array('class' => Enum::POS_LEFT)) . implode( "\n", $tItems ) . \CHtml::closeTag( 'ul' ); } if (!empty($this->rightItems)) { $tItems = array(); foreach ($this->rightItems as $item) { $tItems[] = $this->renderItem($item); } $items[] = \CHtml::openTag('ul', array('class' => Enum::POS_RIGHT)) . implode( "\n", $tItems ) . \CHtml::closeTag( 'ul' ); } return \CHtml::tag('section', array('class' => 'top-bar-section'), implode("\n", $items), true); }
[ "protected", "function", "renderItems", "(", ")", "{", "$", "items", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "leftItems", ")", ")", "{", "$", "tItems", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "leftItems", "as", "$", "item", ")", "{", "$", "tItems", "[", "]", "=", "$", "this", "->", "renderItem", "(", "$", "item", ")", ";", "}", "$", "items", "[", "]", "=", "\\", "CHtml", "::", "openTag", "(", "'ul'", ",", "array", "(", "'class'", "=>", "Enum", "::", "POS_LEFT", ")", ")", ".", "implode", "(", "\"\\n\"", ",", "$", "tItems", ")", ".", "\\", "CHtml", "::", "closeTag", "(", "'ul'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "rightItems", ")", ")", "{", "$", "tItems", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "rightItems", "as", "$", "item", ")", "{", "$", "tItems", "[", "]", "=", "$", "this", "->", "renderItem", "(", "$", "item", ")", ";", "}", "$", "items", "[", "]", "=", "\\", "CHtml", "::", "openTag", "(", "'ul'", ",", "array", "(", "'class'", "=>", "Enum", "::", "POS_RIGHT", ")", ")", ".", "implode", "(", "\"\\n\"", ",", "$", "tItems", ")", ".", "\\", "CHtml", "::", "closeTag", "(", "'ul'", ")", ";", "}", "return", "\\", "CHtml", "::", "tag", "(", "'section'", ",", "array", "(", "'class'", "=>", "'top-bar-section'", ")", ",", "implode", "(", "\"\\n\"", ",", "$", "items", ")", ",", "true", ")", ";", "}" ]
Renders widget's items. @return string
[ "Renders", "widget", "s", "items", "." ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/TopBar.php#L206-L235
19,805
2amigos/yiifoundation
widgets/TopBar.php
TopBar.renderItem
protected function renderItem($item) { if (is_string($item)) { return $item; } 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()); $items = ArrayHelper::getValue($item, 'items'); $url = \CHtml::normalizeUrl(ArrayHelper::getValue($item, 'url', '#')); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', array()); if (ArrayHelper::getValue($item, Enum::STATE_ACTIVE)) { ArrayHelper::addValue('class', Enum::STATE_ACTIVE, $options); } if ($items !== null) { Html::addCssClass($options, Enum::DROPDOWN_HAS); if (is_array($items)) { $items = Nav::dropdown($items, $this->encodeLabels); } } return \CHtml::tag('li', $options, \CHtml::link($label, $url, $linkOptions) . $items); }
php
protected function renderItem($item) { if (is_string($item)) { return $item; } 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()); $items = ArrayHelper::getValue($item, 'items'); $url = \CHtml::normalizeUrl(ArrayHelper::getValue($item, 'url', '#')); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', array()); if (ArrayHelper::getValue($item, Enum::STATE_ACTIVE)) { ArrayHelper::addValue('class', Enum::STATE_ACTIVE, $options); } if ($items !== null) { Html::addCssClass($options, Enum::DROPDOWN_HAS); if (is_array($items)) { $items = Nav::dropdown($items, $this->encodeLabels); } } return \CHtml::tag('li', $options, \CHtml::link($label, $url, $linkOptions) . $items); }
[ "protected", "function", "renderItem", "(", "$", "item", ")", "{", "if", "(", "is_string", "(", "$", "item", ")", ")", "{", "return", "$", "item", ";", "}", "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", "(", ")", ")", ";", "$", "items", "=", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'items'", ")", ";", "$", "url", "=", "\\", "CHtml", "::", "normalizeUrl", "(", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'url'", ",", "'#'", ")", ")", ";", "$", "linkOptions", "=", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'linkOptions'", ",", "array", "(", ")", ")", ";", "if", "(", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "Enum", "::", "STATE_ACTIVE", ")", ")", "{", "ArrayHelper", "::", "addValue", "(", "'class'", ",", "Enum", "::", "STATE_ACTIVE", ",", "$", "options", ")", ";", "}", "if", "(", "$", "items", "!==", "null", ")", "{", "Html", "::", "addCssClass", "(", "$", "options", ",", "Enum", "::", "DROPDOWN_HAS", ")", ";", "if", "(", "is_array", "(", "$", "items", ")", ")", "{", "$", "items", "=", "Nav", "::", "dropdown", "(", "$", "items", ",", "$", "this", "->", "encodeLabels", ")", ";", "}", "}", "return", "\\", "CHtml", "::", "tag", "(", "'li'", ",", "$", "options", ",", "\\", "CHtml", "::", "link", "(", "$", "label", ",", "$", "url", ",", "$", "linkOptions", ")", ".", "$", "items", ")", ";", "}" ]
Renders a widget's item @param mixed $item the item to render @return string the rendering result. @throws InvalidConfigException
[ "Renders", "a", "widget", "s", "item" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/TopBar.php#L243-L269
19,806
afrittella/back-project
src/app/Http/ViewComposers/AdminMenuComposer.php
AdminMenuComposer.menu
function menu($menus) { // Retrieve current user (for permissions) $user = Auth::user(); $templates = [ "menu" => ' <ul class="sidebar-menu" data-widget="tree"> %s </ul> ', "menu_row" => ' <li class="%s"> %s </li> ', // class, link . submenu "menu_caret" => ' <span class="pull-right-container"> <i class="fa fa-angle-left pull-right"></i> </span>', "menu_subrow" => ' <ul class="treeview-menu"> %s </ul> ', "menu_link" => ' <a href="%s"><i class="%s text-red"></i><span>%s</span>%s</a> ' // url, icon, title ]; $traverse = function ($rows) use (&$traverse, $templates, $user) { $menuString = ""; $hasActive = false; foreach ($rows as $menu) { if (!empty($menu->permission) and !$user->hasPermission($menu->permission)) { continue; } $hasActive = false; $submenu = ""; $authorized = true; if ($menu->children->count() > 0) { list($submenuString, $hasActive) = $traverse($menu->children); $submenu = ""; if (!empty($submenuString)) { $submenu = sprintf($templates['menu_subrow'], $submenuString); } else { $authorized = false; } } $menu_caret = (!empty($submenu) ? $templates['menu_caret'] : ''); $link = sprintf($templates['menu_link'], (!empty($menu->route) ? url($menu->route) : '#'), (!empty($menu->icon) ? $menu->icon : 'fa fa-circle-o'), //trans('back-project::base.dashboard') \Lang::has('back-project::menu.' . $menu->title) ? __('back-project::menu.' . $menu->title) : $menu->title, $menu_caret ); $class = (!empty($submenu) ? 'treeview' : ''); $current_url = \Route::current()->uri(); if ($authorized) { $menuString .= sprintf($templates['menu_row'], $class, $link . $submenu); } } return [ $menuString, $hasActive ]; }; list($menu, $hasActive) = $traverse($menus); return sprintf($templates['menu'], $menu); }
php
function menu($menus) { // Retrieve current user (for permissions) $user = Auth::user(); $templates = [ "menu" => ' <ul class="sidebar-menu" data-widget="tree"> %s </ul> ', "menu_row" => ' <li class="%s"> %s </li> ', // class, link . submenu "menu_caret" => ' <span class="pull-right-container"> <i class="fa fa-angle-left pull-right"></i> </span>', "menu_subrow" => ' <ul class="treeview-menu"> %s </ul> ', "menu_link" => ' <a href="%s"><i class="%s text-red"></i><span>%s</span>%s</a> ' // url, icon, title ]; $traverse = function ($rows) use (&$traverse, $templates, $user) { $menuString = ""; $hasActive = false; foreach ($rows as $menu) { if (!empty($menu->permission) and !$user->hasPermission($menu->permission)) { continue; } $hasActive = false; $submenu = ""; $authorized = true; if ($menu->children->count() > 0) { list($submenuString, $hasActive) = $traverse($menu->children); $submenu = ""; if (!empty($submenuString)) { $submenu = sprintf($templates['menu_subrow'], $submenuString); } else { $authorized = false; } } $menu_caret = (!empty($submenu) ? $templates['menu_caret'] : ''); $link = sprintf($templates['menu_link'], (!empty($menu->route) ? url($menu->route) : '#'), (!empty($menu->icon) ? $menu->icon : 'fa fa-circle-o'), //trans('back-project::base.dashboard') \Lang::has('back-project::menu.' . $menu->title) ? __('back-project::menu.' . $menu->title) : $menu->title, $menu_caret ); $class = (!empty($submenu) ? 'treeview' : ''); $current_url = \Route::current()->uri(); if ($authorized) { $menuString .= sprintf($templates['menu_row'], $class, $link . $submenu); } } return [ $menuString, $hasActive ]; }; list($menu, $hasActive) = $traverse($menus); return sprintf($templates['menu'], $menu); }
[ "function", "menu", "(", "$", "menus", ")", "{", "// Retrieve current user (for permissions)", "$", "user", "=", "Auth", "::", "user", "(", ")", ";", "$", "templates", "=", "[", "\"menu\"", "=>", "'\n <ul class=\"sidebar-menu\" data-widget=\"tree\">\n %s\n </ul>\n '", ",", "\"menu_row\"", "=>", "'\n <li class=\"%s\">\n %s\n </li>\n '", ",", "// class, link . submenu", "\"menu_caret\"", "=>", "'\n <span class=\"pull-right-container\">\n <i class=\"fa fa-angle-left pull-right\"></i>\n </span>'", ",", "\"menu_subrow\"", "=>", "'\n <ul class=\"treeview-menu\">\n %s\n </ul>\n '", ",", "\"menu_link\"", "=>", "'\n <a href=\"%s\"><i class=\"%s text-red\"></i><span>%s</span>%s</a>\n '", "// url, icon, title", "]", ";", "$", "traverse", "=", "function", "(", "$", "rows", ")", "use", "(", "&", "$", "traverse", ",", "$", "templates", ",", "$", "user", ")", "{", "$", "menuString", "=", "\"\"", ";", "$", "hasActive", "=", "false", ";", "foreach", "(", "$", "rows", "as", "$", "menu", ")", "{", "if", "(", "!", "empty", "(", "$", "menu", "->", "permission", ")", "and", "!", "$", "user", "->", "hasPermission", "(", "$", "menu", "->", "permission", ")", ")", "{", "continue", ";", "}", "$", "hasActive", "=", "false", ";", "$", "submenu", "=", "\"\"", ";", "$", "authorized", "=", "true", ";", "if", "(", "$", "menu", "->", "children", "->", "count", "(", ")", ">", "0", ")", "{", "list", "(", "$", "submenuString", ",", "$", "hasActive", ")", "=", "$", "traverse", "(", "$", "menu", "->", "children", ")", ";", "$", "submenu", "=", "\"\"", ";", "if", "(", "!", "empty", "(", "$", "submenuString", ")", ")", "{", "$", "submenu", "=", "sprintf", "(", "$", "templates", "[", "'menu_subrow'", "]", ",", "$", "submenuString", ")", ";", "}", "else", "{", "$", "authorized", "=", "false", ";", "}", "}", "$", "menu_caret", "=", "(", "!", "empty", "(", "$", "submenu", ")", "?", "$", "templates", "[", "'menu_caret'", "]", ":", "''", ")", ";", "$", "link", "=", "sprintf", "(", "$", "templates", "[", "'menu_link'", "]", ",", "(", "!", "empty", "(", "$", "menu", "->", "route", ")", "?", "url", "(", "$", "menu", "->", "route", ")", ":", "'#'", ")", ",", "(", "!", "empty", "(", "$", "menu", "->", "icon", ")", "?", "$", "menu", "->", "icon", ":", "'fa fa-circle-o'", ")", ",", "//trans('back-project::base.dashboard')", "\\", "Lang", "::", "has", "(", "'back-project::menu.'", ".", "$", "menu", "->", "title", ")", "?", "__", "(", "'back-project::menu.'", ".", "$", "menu", "->", "title", ")", ":", "$", "menu", "->", "title", ",", "$", "menu_caret", ")", ";", "$", "class", "=", "(", "!", "empty", "(", "$", "submenu", ")", "?", "'treeview'", ":", "''", ")", ";", "$", "current_url", "=", "\\", "Route", "::", "current", "(", ")", "->", "uri", "(", ")", ";", "if", "(", "$", "authorized", ")", "{", "$", "menuString", ".=", "sprintf", "(", "$", "templates", "[", "'menu_row'", "]", ",", "$", "class", ",", "$", "link", ".", "$", "submenu", ")", ";", "}", "}", "return", "[", "$", "menuString", ",", "$", "hasActive", "]", ";", "}", ";", "list", "(", "$", "menu", ",", "$", "hasActive", ")", "=", "$", "traverse", "(", "$", "menus", ")", ";", "return", "sprintf", "(", "$", "templates", "[", "'menu'", "]", ",", "$", "menu", ")", ";", "}" ]
Format an AdminLTE Menu $menus must be formatted in this way: Menu children children @param array $menus @return string
[ "Format", "an", "AdminLTE", "Menu" ]
e1aa2e3ee03d453033f75a4b16f073c60b5f32d1
https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Http/ViewComposers/AdminMenuComposer.php#L39-L119
19,807
xinix-technology/norm
src/Norm/Cursor/OCICursor.php
OCICursor.prepareCriteria
public function prepareCriteria($criteria) { if (is_null($criteria)) { $criteria = array(); } if (array_key_exists('$id', $criteria)) { $criteria['id'] = $criteria['$id']; unset($criteria['$id']); } return $criteria ? : array(); }
php
public function prepareCriteria($criteria) { if (is_null($criteria)) { $criteria = array(); } if (array_key_exists('$id', $criteria)) { $criteria['id'] = $criteria['$id']; unset($criteria['$id']); } return $criteria ? : array(); }
[ "public", "function", "prepareCriteria", "(", "$", "criteria", ")", "{", "if", "(", "is_null", "(", "$", "criteria", ")", ")", "{", "$", "criteria", "=", "array", "(", ")", ";", "}", "if", "(", "array_key_exists", "(", "'$id'", ",", "$", "criteria", ")", ")", "{", "$", "criteria", "[", "'id'", "]", "=", "$", "criteria", "[", "'$id'", "]", ";", "unset", "(", "$", "criteria", "[", "'$id'", "]", ")", ";", "}", "return", "$", "criteria", "?", ":", "array", "(", ")", ";", "}" ]
comment for other criteria
[ "comment", "for", "other", "criteria" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/OCICursor.php#L244-L256
19,808
xinix-technology/norm
src/Norm/Cursor/OCICursor.php
OCICursor.getQueryReference
public function getQueryReference($key = '', $foreign = '', $foreignLabel = '', $foreignKey = '', &$i) { $model = Norm::factory($foreign); $refSchemes = $model->schema(); $foreignKey = $foreignKey ?: 'id'; if ($foreignKey == '$id') { $foreignKey = 'id'; } $query = $key . ' IN (SELECT '.$foreignKey.' FROM '.strtolower($foreign).' WHERE '.$foreignLabel.' LIKE :f'.$i.') '; $i++; return $query; }
php
public function getQueryReference($key = '', $foreign = '', $foreignLabel = '', $foreignKey = '', &$i) { $model = Norm::factory($foreign); $refSchemes = $model->schema(); $foreignKey = $foreignKey ?: 'id'; if ($foreignKey == '$id') { $foreignKey = 'id'; } $query = $key . ' IN (SELECT '.$foreignKey.' FROM '.strtolower($foreign).' WHERE '.$foreignLabel.' LIKE :f'.$i.') '; $i++; return $query; }
[ "public", "function", "getQueryReference", "(", "$", "key", "=", "''", ",", "$", "foreign", "=", "''", ",", "$", "foreignLabel", "=", "''", ",", "$", "foreignKey", "=", "''", ",", "&", "$", "i", ")", "{", "$", "model", "=", "Norm", "::", "factory", "(", "$", "foreign", ")", ";", "$", "refSchemes", "=", "$", "model", "->", "schema", "(", ")", ";", "$", "foreignKey", "=", "$", "foreignKey", "?", ":", "'id'", ";", "if", "(", "$", "foreignKey", "==", "'$id'", ")", "{", "$", "foreignKey", "=", "'id'", ";", "}", "$", "query", "=", "$", "key", ".", "' IN (SELECT '", ".", "$", "foreignKey", ".", "' FROM '", ".", "strtolower", "(", "$", "foreign", ")", ".", "' WHERE '", ".", "$", "foreignLabel", ".", "' LIKE :f'", ".", "$", "i", ".", "') '", ";", "$", "i", "++", ";", "return", "$", "query", ";", "}" ]
Find reference of a foreign key. @param string $key @param string $foreign @param string $foreignLabel @param string $foreignKey @param int &$i @return string
[ "Find", "reference", "of", "a", "foreign", "key", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/OCICursor.php#L450-L464
19,809
webforge-labs/psc-cms
lib/Psc/System/File.php
File.replaceContents
public function replaceContents(Array $replacements) { $this->writeContents( str_replace( array_keys($replacements), array_values($replacements), $this->getContents() ) ); return $this; }
php
public function replaceContents(Array $replacements) { $this->writeContents( str_replace( array_keys($replacements), array_values($replacements), $this->getContents() ) ); return $this; }
[ "public", "function", "replaceContents", "(", "Array", "$", "replacements", ")", "{", "$", "this", "->", "writeContents", "(", "str_replace", "(", "array_keys", "(", "$", "replacements", ")", ",", "array_values", "(", "$", "replacements", ")", ",", "$", "this", "->", "getContents", "(", ")", ")", ")", ";", "return", "$", "this", ";", "}" ]
Replaces the contents of the file @deprecated
[ "Replaces", "the", "contents", "of", "the", "file" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/System/File.php#L11-L20
19,810
askupasoftware/amarkal
Extensions/WordPress/Widget/Widget.php
Widget.set_field_names
private function set_field_names() { foreach ( $this->config->fields as $field ) { $field->init_name = $field->name; } }
php
private function set_field_names() { foreach ( $this->config->fields as $field ) { $field->init_name = $field->name; } }
[ "private", "function", "set_field_names", "(", ")", "{", "foreach", "(", "$", "this", "->", "config", "->", "fields", "as", "$", "field", ")", "{", "$", "field", "->", "init_name", "=", "$", "field", "->", "name", ";", "}", "}" ]
Since the widget's form sets custom names and ids to each field, the original field name must be stored seperately using this function.
[ "Since", "the", "widget", "s", "form", "sets", "custom", "names", "and", "ids", "to", "each", "field", "the", "original", "field", "name", "must", "be", "stored", "seperately", "using", "this", "function", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Widget/Widget.php#L85-L91
19,811
askupasoftware/amarkal
Extensions/WordPress/Widget/Widget.php
Widget.form
public function form( $instance ) { // Reset the names so that the form's update function works properly foreach ( $this->config->fields as $field ) { $field->name = $field->init_name; } // Update values $this->form->updater->set_new_instance( $instance ); $this->form->updater->update(); // Set the widget specific field names and ids foreach ( $this->config->fields as $field ) { $field->id = $this->get_field_id( $field->init_name ); $field->name = $this->get_field_name( $field->init_name ); } // Print the form $this->form->render(true); }
php
public function form( $instance ) { // Reset the names so that the form's update function works properly foreach ( $this->config->fields as $field ) { $field->name = $field->init_name; } // Update values $this->form->updater->set_new_instance( $instance ); $this->form->updater->update(); // Set the widget specific field names and ids foreach ( $this->config->fields as $field ) { $field->id = $this->get_field_id( $field->init_name ); $field->name = $this->get_field_name( $field->init_name ); } // Print the form $this->form->render(true); }
[ "public", "function", "form", "(", "$", "instance", ")", "{", "// Reset the names so that the form's update function works properly", "foreach", "(", "$", "this", "->", "config", "->", "fields", "as", "$", "field", ")", "{", "$", "field", "->", "name", "=", "$", "field", "->", "init_name", ";", "}", "// Update values", "$", "this", "->", "form", "->", "updater", "->", "set_new_instance", "(", "$", "instance", ")", ";", "$", "this", "->", "form", "->", "updater", "->", "update", "(", ")", ";", "// Set the widget specific field names and ids", "foreach", "(", "$", "this", "->", "config", "->", "fields", "as", "$", "field", ")", "{", "$", "field", "->", "id", "=", "$", "this", "->", "get_field_id", "(", "$", "field", "->", "init_name", ")", ";", "$", "field", "->", "name", "=", "$", "this", "->", "get_field_name", "(", "$", "field", "->", "init_name", ")", ";", "}", "// Print the form", "$", "this", "->", "form", "->", "render", "(", "true", ")", ";", "}" ]
Generates the administration form for the widget @param array $instance The array of keys and values for the widget
[ "Generates", "the", "administration", "form", "for", "the", "widget" ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Widget/Widget.php#L99-L119
19,812
askupasoftware/amarkal
Extensions/WordPress/Widget/Widget.php
Widget.update
public function update( $new_instance, $old_instance ) { $this->form->updater->set_new_instance( $new_instance ); return $this->form->updater->update( $old_instance ); }
php
public function update( $new_instance, $old_instance ) { $this->form->updater->set_new_instance( $new_instance ); return $this->form->updater->update( $old_instance ); }
[ "public", "function", "update", "(", "$", "new_instance", ",", "$", "old_instance", ")", "{", "$", "this", "->", "form", "->", "updater", "->", "set_new_instance", "(", "$", "new_instance", ")", ";", "return", "$", "this", "->", "form", "->", "updater", "->", "update", "(", "$", "old_instance", ")", ";", "}" ]
Processes the widget's options to be saved. @param array new_instance The previous instance of values before the update. @param array old_instance The new instance of values to be generated via the update.
[ "Processes", "the", "widget", "s", "options", "to", "be", "saved", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Widget/Widget.php#L129-L133
19,813
askupasoftware/amarkal
Form/Form.php
Form.validate_components
private function validate_components( $components ) { foreach( $components as $component ) { if( ! $component instanceof UI\AbstractComponent ) { throw new WrongTypeException( \gettype( $component ) ); } if( $component instanceof UI\Components\Composite ) { $this->validate_components( $component->components ); continue; } if( $component instanceof UI\ValueComponentInterface && in_array( $component->name, $this->names ) ) { throw new DuplicateNameException( $component->name ); } $this->names[] = $component->name; } }
php
private function validate_components( $components ) { foreach( $components as $component ) { if( ! $component instanceof UI\AbstractComponent ) { throw new WrongTypeException( \gettype( $component ) ); } if( $component instanceof UI\Components\Composite ) { $this->validate_components( $component->components ); continue; } if( $component instanceof UI\ValueComponentInterface && in_array( $component->name, $this->names ) ) { throw new DuplicateNameException( $component->name ); } $this->names[] = $component->name; } }
[ "private", "function", "validate_components", "(", "$", "components", ")", "{", "foreach", "(", "$", "components", "as", "$", "component", ")", "{", "if", "(", "!", "$", "component", "instanceof", "UI", "\\", "AbstractComponent", ")", "{", "throw", "new", "WrongTypeException", "(", "\\", "gettype", "(", "$", "component", ")", ")", ";", "}", "if", "(", "$", "component", "instanceof", "UI", "\\", "Components", "\\", "Composite", ")", "{", "$", "this", "->", "validate_components", "(", "$", "component", "->", "components", ")", ";", "continue", ";", "}", "if", "(", "$", "component", "instanceof", "UI", "\\", "ValueComponentInterface", "&&", "in_array", "(", "$", "component", "->", "name", ",", "$", "this", "->", "names", ")", ")", "{", "throw", "new", "DuplicateNameException", "(", "$", "component", "->", "name", ")", ";", "}", "$", "this", "->", "names", "[", "]", "=", "$", "component", "->", "name", ";", "}", "}" ]
Internally used to validate each form component. @param \Amarkal\UI\AbstractComponent[] $components @throws \Amarkal\Form\DuplicateNameException
[ "Internally", "used", "to", "validate", "each", "form", "component", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Form/Form.php#L42-L64
19,814
digitalkaoz/versioneye-php
src/Console/CommandFactory.php
CommandFactory.generateCommands
public function generateCommands(array $classes = []) { $classes = $this->readApis($classes); $token = $this->token->read(); $commands = []; foreach ($classes as $class) { $api = new \ReflectionClass($class); foreach ($api->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { if (0 !== strpos($method->getName(), '__')) { //skip magics $command = $this->generateCommand($api->getShortName(), $method, $token); $commands[$command->getName()] = $command; } } } return $commands; }
php
public function generateCommands(array $classes = []) { $classes = $this->readApis($classes); $token = $this->token->read(); $commands = []; foreach ($classes as $class) { $api = new \ReflectionClass($class); foreach ($api->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { if (0 !== strpos($method->getName(), '__')) { //skip magics $command = $this->generateCommand($api->getShortName(), $method, $token); $commands[$command->getName()] = $command; } } } return $commands; }
[ "public", "function", "generateCommands", "(", "array", "$", "classes", "=", "[", "]", ")", "{", "$", "classes", "=", "$", "this", "->", "readApis", "(", "$", "classes", ")", ";", "$", "token", "=", "$", "this", "->", "token", "->", "read", "(", ")", ";", "$", "commands", "=", "[", "]", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "$", "api", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "foreach", "(", "$", "api", "->", "getMethods", "(", "\\", "ReflectionMethod", "::", "IS_PUBLIC", ")", "as", "$", "method", ")", "{", "if", "(", "0", "!==", "strpos", "(", "$", "method", "->", "getName", "(", ")", ",", "'__'", ")", ")", "{", "//skip magics", "$", "command", "=", "$", "this", "->", "generateCommand", "(", "$", "api", "->", "getShortName", "(", ")", ",", "$", "method", ",", "$", "token", ")", ";", "$", "commands", "[", "$", "command", "->", "getName", "(", ")", "]", "=", "$", "command", ";", "}", "}", "}", "return", "$", "commands", ";", "}" ]
generates Commands from all Api Methods. @param array $classes @return Command[]
[ "generates", "Commands", "from", "all", "Api", "Methods", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Console/CommandFactory.php#L48-L66
19,815
digitalkaoz/versioneye-php
src/Console/CommandFactory.php
CommandFactory.buildDefinition
private function buildDefinition(\ReflectionMethod $method, $token = null) { $definition = new InputDefinition(); foreach ($method->getParameters() as $parameter) { if ($parameter->isDefaultValueAvailable()) { //option $definition->addOption(new InputOption($parameter->getName(), null, InputOption::VALUE_REQUIRED, null, $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null)); } else { //argument $definition->addArgument(new InputArgument($parameter->getName(), InputArgument::REQUIRED, null, null)); } } $definition->addOption(new InputOption('token', null, InputOption::VALUE_REQUIRED, 'the auth token to use', $token)); $definition->addOption(new InputOption('debug', null, InputOption::VALUE_NONE, 'display raw response')); return $definition; }
php
private function buildDefinition(\ReflectionMethod $method, $token = null) { $definition = new InputDefinition(); foreach ($method->getParameters() as $parameter) { if ($parameter->isDefaultValueAvailable()) { //option $definition->addOption(new InputOption($parameter->getName(), null, InputOption::VALUE_REQUIRED, null, $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null)); } else { //argument $definition->addArgument(new InputArgument($parameter->getName(), InputArgument::REQUIRED, null, null)); } } $definition->addOption(new InputOption('token', null, InputOption::VALUE_REQUIRED, 'the auth token to use', $token)); $definition->addOption(new InputOption('debug', null, InputOption::VALUE_NONE, 'display raw response')); return $definition; }
[ "private", "function", "buildDefinition", "(", "\\", "ReflectionMethod", "$", "method", ",", "$", "token", "=", "null", ")", "{", "$", "definition", "=", "new", "InputDefinition", "(", ")", ";", "foreach", "(", "$", "method", "->", "getParameters", "(", ")", "as", "$", "parameter", ")", "{", "if", "(", "$", "parameter", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "//option", "$", "definition", "->", "addOption", "(", "new", "InputOption", "(", "$", "parameter", "->", "getName", "(", ")", ",", "null", ",", "InputOption", "::", "VALUE_REQUIRED", ",", "null", ",", "$", "parameter", "->", "isDefaultValueAvailable", "(", ")", "?", "$", "parameter", "->", "getDefaultValue", "(", ")", ":", "null", ")", ")", ";", "}", "else", "{", "//argument", "$", "definition", "->", "addArgument", "(", "new", "InputArgument", "(", "$", "parameter", "->", "getName", "(", ")", ",", "InputArgument", "::", "REQUIRED", ",", "null", ",", "null", ")", ")", ";", "}", "}", "$", "definition", "->", "addOption", "(", "new", "InputOption", "(", "'token'", ",", "null", ",", "InputOption", "::", "VALUE_REQUIRED", ",", "'the auth token to use'", ",", "$", "token", ")", ")", ";", "$", "definition", "->", "addOption", "(", "new", "InputOption", "(", "'debug'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'display raw response'", ")", ")", ";", "return", "$", "definition", ";", "}" ]
builds the Input Definition based upon Api Method Parameters. @param \ReflectionMethod $method @param string $token @return InputDefinition
[ "builds", "the", "Input", "Definition", "based", "upon", "Api", "Method", "Parameters", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Console/CommandFactory.php#L99-L117
19,816
ClanCats/Core
src/bundles/UI/Builder.php
Builder.handle
public static function handle() { $args = func_get_args(); $key = array_shift( $args ); return call_user_func_array( array( static::$builder, 'build_'.$key ), $args ); }
php
public static function handle() { $args = func_get_args(); $key = array_shift( $args ); return call_user_func_array( array( static::$builder, 'build_'.$key ), $args ); }
[ "public", "static", "function", "handle", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "key", "=", "array_shift", "(", "$", "args", ")", ";", "return", "call_user_func_array", "(", "array", "(", "static", "::", "$", "builder", ",", "'build_'", ".", "$", "key", ")", ",", "$", "args", ")", ";", "}" ]
Handle a build request @param string $key @param mixed ...
[ "Handle", "a", "build", "request" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Builder.php#L48-L54
19,817
simple-php-mvc/simple-php-mvc
src/MVC/Server/Route.php
Route.getInstance
static function getInstance($methods, $patternUri, $action, $name = null) { if (!self::$instance) { self::$instance = new self($methods, $patternUri, $action, $name); } return self::$instance; }
php
static function getInstance($methods, $patternUri, $action, $name = null) { if (!self::$instance) { self::$instance = new self($methods, $patternUri, $action, $name); } return self::$instance; }
[ "static", "function", "getInstance", "(", "$", "methods", ",", "$", "patternUri", ",", "$", "action", ",", "$", "name", "=", "null", ")", "{", "if", "(", "!", "self", "::", "$", "instance", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", "$", "methods", ",", "$", "patternUri", ",", "$", "action", ",", "$", "name", ")", ";", "}", "return", "self", "::", "$", "instance", ";", "}" ]
Get Route instance @param string|array $methods @param string $patternUri @param string|\callable $action @param string $name @return Route
[ "Get", "Route", "instance" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Server/Route.php#L88-L95
19,818
simple-php-mvc/simple-php-mvc
src/MVC/Server/Route.php
Route.setAction
public function setAction($action) { if (!is_string($action) && !is_callable($action)) { throw new \LogicException(sprintf('Route action given "%s" is invalid. String or Callable expected.', gettype($action))); } $this->action = $action; return $this; }
php
public function setAction($action) { if (!is_string($action) && !is_callable($action)) { throw new \LogicException(sprintf('Route action given "%s" is invalid. String or Callable expected.', gettype($action))); } $this->action = $action; return $this; }
[ "public", "function", "setAction", "(", "$", "action", ")", "{", "if", "(", "!", "is_string", "(", "$", "action", ")", "&&", "!", "is_callable", "(", "$", "action", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Route action given \"%s\" is invalid. String or Callable expected.'", ",", "gettype", "(", "$", "action", ")", ")", ")", ";", "}", "$", "this", "->", "action", "=", "$", "action", ";", "return", "$", "this", ";", "}" ]
Set action callback @param string|\callable $action @return Route @throws \LogicException
[ "Set", "action", "callback" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Server/Route.php#L144-L152
19,819
slashworks/control-bundle
src/Slashworks/AppBundle/Command/ApiCommand.php
ApiCommand.configure
protected function configure() { // get systemname $sAppName = SystemSettings::get('app_name'); // set cli options $this->setName($sAppName . ':remote:cron')->addOption('app', null, InputOption::VALUE_REQUIRED, 'run only for specific remote app', false)->addOption('force', null, InputOption::VALUE_NONE, 'force to run remote app / ignore cron settings')->setDescription('Run/Crawl registered remote apps'); }
php
protected function configure() { // get systemname $sAppName = SystemSettings::get('app_name'); // set cli options $this->setName($sAppName . ':remote:cron')->addOption('app', null, InputOption::VALUE_REQUIRED, 'run only for specific remote app', false)->addOption('force', null, InputOption::VALUE_NONE, 'force to run remote app / ignore cron settings')->setDescription('Run/Crawl registered remote apps'); }
[ "protected", "function", "configure", "(", ")", "{", "// get systemname", "$", "sAppName", "=", "SystemSettings", "::", "get", "(", "'app_name'", ")", ";", "// set cli options", "$", "this", "->", "setName", "(", "$", "sAppName", ".", "':remote:cron'", ")", "->", "addOption", "(", "'app'", ",", "null", ",", "InputOption", "::", "VALUE_REQUIRED", ",", "'run only for specific remote app'", ",", "false", ")", "->", "addOption", "(", "'force'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'force to run remote app / ignore cron settings'", ")", "->", "setDescription", "(", "'Run/Crawl registered remote apps'", ")", ";", "}" ]
configure cli command for making api calls
[ "configure", "cli", "command", "for", "making", "api", "calls" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Command/ApiCommand.php#L45-L53
19,820
slashworks/control-bundle
src/Slashworks/AppBundle/Command/ApiCommand.php
ApiCommand._parseCrontab
private function _parseCrontab($sDatetime, $sCrontab) { $aTime = explode(' ', date('i G j n w', strtotime($sDatetime))); $sCrontab = explode(' ', $sCrontab); foreach ($sCrontab as $k => &$v) { $v = explode(',', $v); foreach ($v as &$v1) { $v1 = preg_replace(array( '/^\*$/', '/^\d+$/', '/^(\d+)\-(\d+)$/', '/^\*\/(\d+)$/' ), array( 'true', intval($aTime[$k]) . '===\0', '(\1<=' . intval($aTime[$k]) . ' and ' . intval($aTime[$k]) . '<=\2)', intval($aTime[$k]) . '%\1===0' ), $v1); } $v = '(' . implode(' or ', $v) . ')'; } $sCrontab = implode(' and ', $sCrontab); return eval('return ' . $sCrontab . ';'); }
php
private function _parseCrontab($sDatetime, $sCrontab) { $aTime = explode(' ', date('i G j n w', strtotime($sDatetime))); $sCrontab = explode(' ', $sCrontab); foreach ($sCrontab as $k => &$v) { $v = explode(',', $v); foreach ($v as &$v1) { $v1 = preg_replace(array( '/^\*$/', '/^\d+$/', '/^(\d+)\-(\d+)$/', '/^\*\/(\d+)$/' ), array( 'true', intval($aTime[$k]) . '===\0', '(\1<=' . intval($aTime[$k]) . ' and ' . intval($aTime[$k]) . '<=\2)', intval($aTime[$k]) . '%\1===0' ), $v1); } $v = '(' . implode(' or ', $v) . ')'; } $sCrontab = implode(' and ', $sCrontab); return eval('return ' . $sCrontab . ';'); }
[ "private", "function", "_parseCrontab", "(", "$", "sDatetime", ",", "$", "sCrontab", ")", "{", "$", "aTime", "=", "explode", "(", "' '", ",", "date", "(", "'i G j n w'", ",", "strtotime", "(", "$", "sDatetime", ")", ")", ")", ";", "$", "sCrontab", "=", "explode", "(", "' '", ",", "$", "sCrontab", ")", ";", "foreach", "(", "$", "sCrontab", "as", "$", "k", "=>", "&", "$", "v", ")", "{", "$", "v", "=", "explode", "(", "','", ",", "$", "v", ")", ";", "foreach", "(", "$", "v", "as", "&", "$", "v1", ")", "{", "$", "v1", "=", "preg_replace", "(", "array", "(", "'/^\\*$/'", ",", "'/^\\d+$/'", ",", "'/^(\\d+)\\-(\\d+)$/'", ",", "'/^\\*\\/(\\d+)$/'", ")", ",", "array", "(", "'true'", ",", "intval", "(", "$", "aTime", "[", "$", "k", "]", ")", ".", "'===\\0'", ",", "'(\\1<='", ".", "intval", "(", "$", "aTime", "[", "$", "k", "]", ")", ".", "' and '", ".", "intval", "(", "$", "aTime", "[", "$", "k", "]", ")", ".", "'<=\\2)'", ",", "intval", "(", "$", "aTime", "[", "$", "k", "]", ")", ".", "'%\\1===0'", ")", ",", "$", "v1", ")", ";", "}", "$", "v", "=", "'('", ".", "implode", "(", "' or '", ",", "$", "v", ")", ".", "')'", ";", "}", "$", "sCrontab", "=", "implode", "(", "' and '", ",", "$", "sCrontab", ")", ";", "return", "eval", "(", "'return '", ".", "$", "sCrontab", ".", "';'", ")", ";", "}" ]
Parse cron time string @param $sDatetime @param $sCrontab @return mixed
[ "Parse", "cron", "time", "string" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Command/ApiCommand.php#L180-L205
19,821
slashworks/control-bundle
src/Slashworks/AppBundle/Command/ApiCommand.php
ApiCommand._makeCall
private function _makeCall($oRemoteApp) { // get class $this->getContainer()->get('API'); // do call Api::$_container = $this->getContainer(); $aReturn = Api::call('getData', array( array( 'log' => $oRemoteApp->getIncludelog(), 'format' => 'json' ) ), $oRemoteApp->getFullApiUrl(), $oRemoteApp->getPublicKey(), $oRemoteApp); // build json response $sStatuscode = $aReturn['statuscode']; $aReturn = json_decode($aReturn['result'], true); if (!isset($aReturn['status'])) { $aReturn['status'] = true; } $aReturn['statuscode'] = $sStatuscode; if($sStatuscode != 200) { $this->getContainer()->get('logger')->error("ERROR in ".__FILE__." on line ".__LINE__." - ".json_encode($aReturn), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl() )); } return $aReturn; }
php
private function _makeCall($oRemoteApp) { // get class $this->getContainer()->get('API'); // do call Api::$_container = $this->getContainer(); $aReturn = Api::call('getData', array( array( 'log' => $oRemoteApp->getIncludelog(), 'format' => 'json' ) ), $oRemoteApp->getFullApiUrl(), $oRemoteApp->getPublicKey(), $oRemoteApp); // build json response $sStatuscode = $aReturn['statuscode']; $aReturn = json_decode($aReturn['result'], true); if (!isset($aReturn['status'])) { $aReturn['status'] = true; } $aReturn['statuscode'] = $sStatuscode; if($sStatuscode != 200) { $this->getContainer()->get('logger')->error("ERROR in ".__FILE__." on line ".__LINE__." - ".json_encode($aReturn), array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl() )); } return $aReturn; }
[ "private", "function", "_makeCall", "(", "$", "oRemoteApp", ")", "{", "// get class", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'API'", ")", ";", "// do call", "Api", "::", "$", "_container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "$", "aReturn", "=", "Api", "::", "call", "(", "'getData'", ",", "array", "(", "array", "(", "'log'", "=>", "$", "oRemoteApp", "->", "getIncludelog", "(", ")", ",", "'format'", "=>", "'json'", ")", ")", ",", "$", "oRemoteApp", "->", "getFullApiUrl", "(", ")", ",", "$", "oRemoteApp", "->", "getPublicKey", "(", ")", ",", "$", "oRemoteApp", ")", ";", "// build json response", "$", "sStatuscode", "=", "$", "aReturn", "[", "'statuscode'", "]", ";", "$", "aReturn", "=", "json_decode", "(", "$", "aReturn", "[", "'result'", "]", ",", "true", ")", ";", "if", "(", "!", "isset", "(", "$", "aReturn", "[", "'status'", "]", ")", ")", "{", "$", "aReturn", "[", "'status'", "]", "=", "true", ";", "}", "$", "aReturn", "[", "'statuscode'", "]", "=", "$", "sStatuscode", ";", "if", "(", "$", "sStatuscode", "!=", "200", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'logger'", ")", "->", "error", "(", "\"ERROR in \"", ".", "__FILE__", ".", "\" on line \"", ".", "__LINE__", ".", "\" - \"", ".", "json_encode", "(", "$", "aReturn", ")", ",", "array", "(", "\"Method\"", "=>", "__METHOD__", ",", "\"RemoteApp\"", "=>", "$", "oRemoteApp", "->", "getName", "(", ")", ",", "\"RemoteURL\"", "=>", "$", "oRemoteApp", "->", "getFullApiUrl", "(", ")", ")", ")", ";", "}", "return", "$", "aReturn", ";", "}" ]
perform api call @param RemoteApp $oRemoteApp @return mixed
[ "perform", "api", "call" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Command/ApiCommand.php#L215-L245
19,822
slashworks/control-bundle
src/Slashworks/AppBundle/Command/ApiCommand.php
ApiCommand._saveResponse
private function _saveResponse($aResponse, $oRemoteApp) { // get model by app-type $sClassName = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType()); $sQueryClassName = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType() . 'Query'); // if class exists, proceed... if (class_exists($sClassName)) { // find histories for remote-app $aHistories = $sQueryClassName::create()->findByRemoteAppId($oRemoteApp->getId()); // create new history-entry $oRemoteHistoryClass = new $sClassName(); $oRemoteHistoryClass->setRemoteApp($oRemoteApp); $oRemoteHistoryClass->setData($aResponse); // convert created class to array for comparsion $aNewHistory = $oRemoteHistoryClass->toArray(); $aNewHistory['Extensions'] = $aNewHistory['Extensions']->getArrayCopy(); if (is_object($aNewHistory['Log'])) { $aNewHistory['Log'] = $aNewHistory['Log']->getArrayCopy(); } else { $aNewHistory['Log'] = array(); } unset($aNewHistory['Id']); // interate old histories and convert to array for comparsion foreach ($aHistories as $oHistory) { $aHistory = $oHistory->toArray(); $aHistory['Extensions'] = $aHistory['Extensions']->getArrayCopy(); if (is_object($aHistory['Log'])) { $aHistory['Log'] = $aHistory['Log']->getArrayCopy(); } else { $aHistory['Log'] = array(); } unset($aHistory['Id']); // if api-call was not successful, send notifiations if configured if ($aResponse['statuscode'] != 200) { if ($oRemoteApp->checkNotificationSetting("NotificationError")) { $this->_sendErrorNotification($oRemoteApp, $aResponse); } } else { // if api-call was successful, compare old and new history and send differences to user $aNew = $this->arrayRecursiveDiff($aNewHistory, $aHistory); // diff exists? if (!empty($aNew) && $oRemoteApp->checkNotificationSetting("NotificationChange")) { $aOld = $this->arrayRecursiveDiff($aHistory, $aNewHistory); $this->_sendNotification(array( 'old' => $aOld, 'new' => $aNew ), $oRemoteApp, $aNewHistory); } } // delete old history $oHistory->delete(); } // save created history $oRemoteHistoryClass->save(); $oRemoteApp->setLastRun(time()); $oRemoteApp->save(); } else { $this->getContainer()->get('logger')->error('Class \'' . $sClassName . '\' not found... ', array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl() )); throw new \Exception('Class \'' . $sClassName . '\' not found... '); } }
php
private function _saveResponse($aResponse, $oRemoteApp) { // get model by app-type $sClassName = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType()); $sQueryClassName = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType() . 'Query'); // if class exists, proceed... if (class_exists($sClassName)) { // find histories for remote-app $aHistories = $sQueryClassName::create()->findByRemoteAppId($oRemoteApp->getId()); // create new history-entry $oRemoteHistoryClass = new $sClassName(); $oRemoteHistoryClass->setRemoteApp($oRemoteApp); $oRemoteHistoryClass->setData($aResponse); // convert created class to array for comparsion $aNewHistory = $oRemoteHistoryClass->toArray(); $aNewHistory['Extensions'] = $aNewHistory['Extensions']->getArrayCopy(); if (is_object($aNewHistory['Log'])) { $aNewHistory['Log'] = $aNewHistory['Log']->getArrayCopy(); } else { $aNewHistory['Log'] = array(); } unset($aNewHistory['Id']); // interate old histories and convert to array for comparsion foreach ($aHistories as $oHistory) { $aHistory = $oHistory->toArray(); $aHistory['Extensions'] = $aHistory['Extensions']->getArrayCopy(); if (is_object($aHistory['Log'])) { $aHistory['Log'] = $aHistory['Log']->getArrayCopy(); } else { $aHistory['Log'] = array(); } unset($aHistory['Id']); // if api-call was not successful, send notifiations if configured if ($aResponse['statuscode'] != 200) { if ($oRemoteApp->checkNotificationSetting("NotificationError")) { $this->_sendErrorNotification($oRemoteApp, $aResponse); } } else { // if api-call was successful, compare old and new history and send differences to user $aNew = $this->arrayRecursiveDiff($aNewHistory, $aHistory); // diff exists? if (!empty($aNew) && $oRemoteApp->checkNotificationSetting("NotificationChange")) { $aOld = $this->arrayRecursiveDiff($aHistory, $aNewHistory); $this->_sendNotification(array( 'old' => $aOld, 'new' => $aNew ), $oRemoteApp, $aNewHistory); } } // delete old history $oHistory->delete(); } // save created history $oRemoteHistoryClass->save(); $oRemoteApp->setLastRun(time()); $oRemoteApp->save(); } else { $this->getContainer()->get('logger')->error('Class \'' . $sClassName . '\' not found... ', array("Method" => __METHOD__, "RemoteApp" => $oRemoteApp->getName(), "RemoteURL" => $oRemoteApp->getFullApiUrl() )); throw new \Exception('Class \'' . $sClassName . '\' not found... '); } }
[ "private", "function", "_saveResponse", "(", "$", "aResponse", ",", "$", "oRemoteApp", ")", "{", "// get model by app-type", "$", "sClassName", "=", "'\\Slashworks\\AppBundle\\Model\\RemoteHistory'", ".", "ucfirst", "(", "$", "oRemoteApp", "->", "getType", "(", ")", ")", ";", "$", "sQueryClassName", "=", "'\\Slashworks\\AppBundle\\Model\\RemoteHistory'", ".", "ucfirst", "(", "$", "oRemoteApp", "->", "getType", "(", ")", ".", "'Query'", ")", ";", "// if class exists, proceed...", "if", "(", "class_exists", "(", "$", "sClassName", ")", ")", "{", "// find histories for remote-app", "$", "aHistories", "=", "$", "sQueryClassName", "::", "create", "(", ")", "->", "findByRemoteAppId", "(", "$", "oRemoteApp", "->", "getId", "(", ")", ")", ";", "// create new history-entry", "$", "oRemoteHistoryClass", "=", "new", "$", "sClassName", "(", ")", ";", "$", "oRemoteHistoryClass", "->", "setRemoteApp", "(", "$", "oRemoteApp", ")", ";", "$", "oRemoteHistoryClass", "->", "setData", "(", "$", "aResponse", ")", ";", "// convert created class to array for comparsion", "$", "aNewHistory", "=", "$", "oRemoteHistoryClass", "->", "toArray", "(", ")", ";", "$", "aNewHistory", "[", "'Extensions'", "]", "=", "$", "aNewHistory", "[", "'Extensions'", "]", "->", "getArrayCopy", "(", ")", ";", "if", "(", "is_object", "(", "$", "aNewHistory", "[", "'Log'", "]", ")", ")", "{", "$", "aNewHistory", "[", "'Log'", "]", "=", "$", "aNewHistory", "[", "'Log'", "]", "->", "getArrayCopy", "(", ")", ";", "}", "else", "{", "$", "aNewHistory", "[", "'Log'", "]", "=", "array", "(", ")", ";", "}", "unset", "(", "$", "aNewHistory", "[", "'Id'", "]", ")", ";", "// interate old histories and convert to array for comparsion", "foreach", "(", "$", "aHistories", "as", "$", "oHistory", ")", "{", "$", "aHistory", "=", "$", "oHistory", "->", "toArray", "(", ")", ";", "$", "aHistory", "[", "'Extensions'", "]", "=", "$", "aHistory", "[", "'Extensions'", "]", "->", "getArrayCopy", "(", ")", ";", "if", "(", "is_object", "(", "$", "aHistory", "[", "'Log'", "]", ")", ")", "{", "$", "aHistory", "[", "'Log'", "]", "=", "$", "aHistory", "[", "'Log'", "]", "->", "getArrayCopy", "(", ")", ";", "}", "else", "{", "$", "aHistory", "[", "'Log'", "]", "=", "array", "(", ")", ";", "}", "unset", "(", "$", "aHistory", "[", "'Id'", "]", ")", ";", "// if api-call was not successful, send notifiations if configured", "if", "(", "$", "aResponse", "[", "'statuscode'", "]", "!=", "200", ")", "{", "if", "(", "$", "oRemoteApp", "->", "checkNotificationSetting", "(", "\"NotificationError\"", ")", ")", "{", "$", "this", "->", "_sendErrorNotification", "(", "$", "oRemoteApp", ",", "$", "aResponse", ")", ";", "}", "}", "else", "{", "// if api-call was successful, compare old and new history and send differences to user", "$", "aNew", "=", "$", "this", "->", "arrayRecursiveDiff", "(", "$", "aNewHistory", ",", "$", "aHistory", ")", ";", "// diff exists?", "if", "(", "!", "empty", "(", "$", "aNew", ")", "&&", "$", "oRemoteApp", "->", "checkNotificationSetting", "(", "\"NotificationChange\"", ")", ")", "{", "$", "aOld", "=", "$", "this", "->", "arrayRecursiveDiff", "(", "$", "aHistory", ",", "$", "aNewHistory", ")", ";", "$", "this", "->", "_sendNotification", "(", "array", "(", "'old'", "=>", "$", "aOld", ",", "'new'", "=>", "$", "aNew", ")", ",", "$", "oRemoteApp", ",", "$", "aNewHistory", ")", ";", "}", "}", "// delete old history", "$", "oHistory", "->", "delete", "(", ")", ";", "}", "// save created history", "$", "oRemoteHistoryClass", "->", "save", "(", ")", ";", "$", "oRemoteApp", "->", "setLastRun", "(", "time", "(", ")", ")", ";", "$", "oRemoteApp", "->", "save", "(", ")", ";", "}", "else", "{", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'logger'", ")", "->", "error", "(", "'Class \\''", ".", "$", "sClassName", ".", "'\\' not found... '", ",", "array", "(", "\"Method\"", "=>", "__METHOD__", ",", "\"RemoteApp\"", "=>", "$", "oRemoteApp", "->", "getName", "(", ")", ",", "\"RemoteURL\"", "=>", "$", "oRemoteApp", "->", "getFullApiUrl", "(", ")", ")", ")", ";", "throw", "new", "\\", "Exception", "(", "'Class \\''", ".", "$", "sClassName", ".", "'\\' not found... '", ")", ";", "}", "}" ]
Save response to database @param array $aResponse @param RemoteApp $oRemoteApp @throws \Exception @return void
[ "Save", "response", "to", "database" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Command/ApiCommand.php#L258-L331
19,823
slashworks/control-bundle
src/Slashworks/AppBundle/Command/ApiCommand.php
ApiCommand._sendErrorNotification
private function _sendErrorNotification(&$oRemoteApp, $aResponse) { $iStatusCode = $aResponse['statuscode']; /* * Parse template by statuscode */ if ($iStatusCode === 404) { $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_error_404_notification.html.twig', array( 'remote_app' => $oRemoteApp, 'response' => $aResponse, 'controlurl' => $this->_getSiteURL() )); } elseif ($iStatusCode === 500) { $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_error_500_notification.html.twig', array( 'remote_app' => $oRemoteApp, 'response' => $aResponse, 'controlurl' => $this->_getSiteURL() )); } elseif ($iStatusCode === 403) { $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_error_403_notification.html.twig', array( 'remote_app' => $oRemoteApp, 'response' => $aResponse, 'controlurl' => $this->_getSiteURL() )); } else { $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_error_notification.html.twig', array( 'remote_app' => $oRemoteApp, 'response' => $aResponse, 'controlurl' => $this->_getSiteURL() )); } // translate Subject $sSubject = $this->getContainer()->get('translator')->trans('system.email.error.' . $iStatusCode . '.subject'); // get recipients and sender $sRecipient = $oRemoteApp->getNotificationRecipient(); $sSender = $oRemoteApp->getNotificationSender(); $sMessage = \Swift_Message::newInstance()->setSubject($sSubject)->setFrom($sSender)->setTo($sRecipient)->setContentType('text/html')->setBody($sHtml, 'text/html')->addPart($sHtml, 'text/html'); // send notification $this->getContainer()->get('mailer')->send($sMessage); }
php
private function _sendErrorNotification(&$oRemoteApp, $aResponse) { $iStatusCode = $aResponse['statuscode']; /* * Parse template by statuscode */ if ($iStatusCode === 404) { $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_error_404_notification.html.twig', array( 'remote_app' => $oRemoteApp, 'response' => $aResponse, 'controlurl' => $this->_getSiteURL() )); } elseif ($iStatusCode === 500) { $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_error_500_notification.html.twig', array( 'remote_app' => $oRemoteApp, 'response' => $aResponse, 'controlurl' => $this->_getSiteURL() )); } elseif ($iStatusCode === 403) { $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_error_403_notification.html.twig', array( 'remote_app' => $oRemoteApp, 'response' => $aResponse, 'controlurl' => $this->_getSiteURL() )); } else { $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_error_notification.html.twig', array( 'remote_app' => $oRemoteApp, 'response' => $aResponse, 'controlurl' => $this->_getSiteURL() )); } // translate Subject $sSubject = $this->getContainer()->get('translator')->trans('system.email.error.' . $iStatusCode . '.subject'); // get recipients and sender $sRecipient = $oRemoteApp->getNotificationRecipient(); $sSender = $oRemoteApp->getNotificationSender(); $sMessage = \Swift_Message::newInstance()->setSubject($sSubject)->setFrom($sSender)->setTo($sRecipient)->setContentType('text/html')->setBody($sHtml, 'text/html')->addPart($sHtml, 'text/html'); // send notification $this->getContainer()->get('mailer')->send($sMessage); }
[ "private", "function", "_sendErrorNotification", "(", "&", "$", "oRemoteApp", ",", "$", "aResponse", ")", "{", "$", "iStatusCode", "=", "$", "aResponse", "[", "'statuscode'", "]", ";", "/*\n * Parse template by statuscode\n */", "if", "(", "$", "iStatusCode", "===", "404", ")", "{", "$", "sHtml", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'templating'", ")", "->", "render", "(", "'SlashworksAppBundle:Email:cron_error_404_notification.html.twig'", ",", "array", "(", "'remote_app'", "=>", "$", "oRemoteApp", ",", "'response'", "=>", "$", "aResponse", ",", "'controlurl'", "=>", "$", "this", "->", "_getSiteURL", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "iStatusCode", "===", "500", ")", "{", "$", "sHtml", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'templating'", ")", "->", "render", "(", "'SlashworksAppBundle:Email:cron_error_500_notification.html.twig'", ",", "array", "(", "'remote_app'", "=>", "$", "oRemoteApp", ",", "'response'", "=>", "$", "aResponse", ",", "'controlurl'", "=>", "$", "this", "->", "_getSiteURL", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "iStatusCode", "===", "403", ")", "{", "$", "sHtml", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'templating'", ")", "->", "render", "(", "'SlashworksAppBundle:Email:cron_error_403_notification.html.twig'", ",", "array", "(", "'remote_app'", "=>", "$", "oRemoteApp", ",", "'response'", "=>", "$", "aResponse", ",", "'controlurl'", "=>", "$", "this", "->", "_getSiteURL", "(", ")", ")", ")", ";", "}", "else", "{", "$", "sHtml", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'templating'", ")", "->", "render", "(", "'SlashworksAppBundle:Email:cron_error_notification.html.twig'", ",", "array", "(", "'remote_app'", "=>", "$", "oRemoteApp", ",", "'response'", "=>", "$", "aResponse", ",", "'controlurl'", "=>", "$", "this", "->", "_getSiteURL", "(", ")", ")", ")", ";", "}", "// translate Subject", "$", "sSubject", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'system.email.error.'", ".", "$", "iStatusCode", ".", "'.subject'", ")", ";", "// get recipients and sender", "$", "sRecipient", "=", "$", "oRemoteApp", "->", "getNotificationRecipient", "(", ")", ";", "$", "sSender", "=", "$", "oRemoteApp", "->", "getNotificationSender", "(", ")", ";", "$", "sMessage", "=", "\\", "Swift_Message", "::", "newInstance", "(", ")", "->", "setSubject", "(", "$", "sSubject", ")", "->", "setFrom", "(", "$", "sSender", ")", "->", "setTo", "(", "$", "sRecipient", ")", "->", "setContentType", "(", "'text/html'", ")", "->", "setBody", "(", "$", "sHtml", ",", "'text/html'", ")", "->", "addPart", "(", "$", "sHtml", ",", "'text/html'", ")", ";", "// send notification", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'mailer'", ")", "->", "send", "(", "$", "sMessage", ")", ";", "}" ]
Send Error-Notification to user @param $oRemoteApp @param $aResponse
[ "Send", "Error", "-", "Notification", "to", "user" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Command/ApiCommand.php#L340-L383
19,824
slashworks/control-bundle
src/Slashworks/AppBundle/Command/ApiCommand.php
ApiCommand._sendNotification
private function _sendNotification($aDiff, &$oRemoteApp, $aNewHistory) { // parse template $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_notification.html.twig', array( 'diff' => $aDiff, 'log' => $aNewHistory['Log'], 'remote_app' => $oRemoteApp, 'controlurl' => $this->_getSiteURL() )); // get recipients $sRecipient = $oRemoteApp->getNotificationRecipient(); // get sender $sSender = $oRemoteApp->getNotificationSender(); // set subject and body of mail $sMessage = \Swift_Message::newInstance()->setSubject($this->getContainer()->get('translator')->trans('system.email.change.subject'))->setFrom($sSender)->setTo($sRecipient)->setContentType('text/html')->setBody($sHtml, 'text/html')->addPart($sHtml, 'text/html'); // send email $this->getContainer()->get('mailer')->send($sMessage); }
php
private function _sendNotification($aDiff, &$oRemoteApp, $aNewHistory) { // parse template $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_notification.html.twig', array( 'diff' => $aDiff, 'log' => $aNewHistory['Log'], 'remote_app' => $oRemoteApp, 'controlurl' => $this->_getSiteURL() )); // get recipients $sRecipient = $oRemoteApp->getNotificationRecipient(); // get sender $sSender = $oRemoteApp->getNotificationSender(); // set subject and body of mail $sMessage = \Swift_Message::newInstance()->setSubject($this->getContainer()->get('translator')->trans('system.email.change.subject'))->setFrom($sSender)->setTo($sRecipient)->setContentType('text/html')->setBody($sHtml, 'text/html')->addPart($sHtml, 'text/html'); // send email $this->getContainer()->get('mailer')->send($sMessage); }
[ "private", "function", "_sendNotification", "(", "$", "aDiff", ",", "&", "$", "oRemoteApp", ",", "$", "aNewHistory", ")", "{", "// parse template", "$", "sHtml", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'templating'", ")", "->", "render", "(", "'SlashworksAppBundle:Email:cron_notification.html.twig'", ",", "array", "(", "'diff'", "=>", "$", "aDiff", ",", "'log'", "=>", "$", "aNewHistory", "[", "'Log'", "]", ",", "'remote_app'", "=>", "$", "oRemoteApp", ",", "'controlurl'", "=>", "$", "this", "->", "_getSiteURL", "(", ")", ")", ")", ";", "// get recipients", "$", "sRecipient", "=", "$", "oRemoteApp", "->", "getNotificationRecipient", "(", ")", ";", "// get sender", "$", "sSender", "=", "$", "oRemoteApp", "->", "getNotificationSender", "(", ")", ";", "// set subject and body of mail", "$", "sMessage", "=", "\\", "Swift_Message", "::", "newInstance", "(", ")", "->", "setSubject", "(", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'system.email.change.subject'", ")", ")", "->", "setFrom", "(", "$", "sSender", ")", "->", "setTo", "(", "$", "sRecipient", ")", "->", "setContentType", "(", "'text/html'", ")", "->", "setBody", "(", "$", "sHtml", ",", "'text/html'", ")", "->", "addPart", "(", "$", "sHtml", ",", "'text/html'", ")", ";", "// send email", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'mailer'", ")", "->", "send", "(", "$", "sMessage", ")", ";", "}" ]
Send Notification to user @param array $aDiff @param RemoteApp $oRemoteApp @param RemoteHistoryContao $aNewHistory @return void
[ "Send", "Notification", "to", "user" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Command/ApiCommand.php#L395-L416
19,825
JBZoo/Less
src/Cache.php
Cache.isExpired
public function isExpired() { if (!FS::isFile($this->_resultFile)) { return true; } $fileAge = abs(time() - filemtime($this->_resultFile)); if ($fileAge >= $this->_cache_ttl) { return true; } $firstLine = trim(FS::firstLine($this->_resultFile)); $expected = trim($this->_getHeader()); if ($expected === $firstLine) { return false; } return true; }
php
public function isExpired() { if (!FS::isFile($this->_resultFile)) { return true; } $fileAge = abs(time() - filemtime($this->_resultFile)); if ($fileAge >= $this->_cache_ttl) { return true; } $firstLine = trim(FS::firstLine($this->_resultFile)); $expected = trim($this->_getHeader()); if ($expected === $firstLine) { return false; } return true; }
[ "public", "function", "isExpired", "(", ")", "{", "if", "(", "!", "FS", "::", "isFile", "(", "$", "this", "->", "_resultFile", ")", ")", "{", "return", "true", ";", "}", "$", "fileAge", "=", "abs", "(", "time", "(", ")", "-", "filemtime", "(", "$", "this", "->", "_resultFile", ")", ")", ";", "if", "(", "$", "fileAge", ">=", "$", "this", "->", "_cache_ttl", ")", "{", "return", "true", ";", "}", "$", "firstLine", "=", "trim", "(", "FS", "::", "firstLine", "(", "$", "this", "->", "_resultFile", ")", ")", ";", "$", "expected", "=", "trim", "(", "$", "this", "->", "_getHeader", "(", ")", ")", ";", "if", "(", "$", "expected", "===", "$", "firstLine", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check is current cache is expired
[ "Check", "is", "current", "cache", "is", "expired" ]
9e9c41e3c7b76222c0d81379dead222413f2f042
https://github.com/JBZoo/Less/blob/9e9c41e3c7b76222c0d81379dead222413f2f042/src/Cache.php#L86-L104
19,826
JBZoo/Less
src/Cache.php
Cache.save
public function save($content) { $content = $this->_getHeader() . $content; $result = file_put_contents($this->_resultFile, $content); if (!$result) { throw new Exception('JBZoo/Less: File not save - ' . $this->_resultFile); // @codeCoverageIgnore } }
php
public function save($content) { $content = $this->_getHeader() . $content; $result = file_put_contents($this->_resultFile, $content); if (!$result) { throw new Exception('JBZoo/Less: File not save - ' . $this->_resultFile); // @codeCoverageIgnore } }
[ "public", "function", "save", "(", "$", "content", ")", "{", "$", "content", "=", "$", "this", "->", "_getHeader", "(", ")", ".", "$", "content", ";", "$", "result", "=", "file_put_contents", "(", "$", "this", "->", "_resultFile", ",", "$", "content", ")", ";", "if", "(", "!", "$", "result", ")", "{", "throw", "new", "Exception", "(", "'JBZoo/Less: File not save - '", ".", "$", "this", "->", "_resultFile", ")", ";", "// @codeCoverageIgnore", "}", "}" ]
Save result to cache @param string $content @throws Exception
[ "Save", "result", "to", "cache" ]
9e9c41e3c7b76222c0d81379dead222413f2f042
https://github.com/JBZoo/Less/blob/9e9c41e3c7b76222c0d81379dead222413f2f042/src/Cache.php#L169-L177
19,827
claroline/ForumBundle
Manager/Manager.php
Manager.subscribe
public function subscribe(Forum $forum, User $user, $selfActivation = true) { $this->om->startFlushSuite(); $notification = new Notification(); $notification->setUser($user); $notification->setForum($forum); $notification->setSelfActivation($selfActivation); $this->om->persist($notification); $this->dispatch(new SubscribeForumEvent($forum)); $this->om->endFlushSuite(); }
php
public function subscribe(Forum $forum, User $user, $selfActivation = true) { $this->om->startFlushSuite(); $notification = new Notification(); $notification->setUser($user); $notification->setForum($forum); $notification->setSelfActivation($selfActivation); $this->om->persist($notification); $this->dispatch(new SubscribeForumEvent($forum)); $this->om->endFlushSuite(); }
[ "public", "function", "subscribe", "(", "Forum", "$", "forum", ",", "User", "$", "user", ",", "$", "selfActivation", "=", "true", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "notification", "=", "new", "Notification", "(", ")", ";", "$", "notification", "->", "setUser", "(", "$", "user", ")", ";", "$", "notification", "->", "setForum", "(", "$", "forum", ")", ";", "$", "notification", "->", "setSelfActivation", "(", "$", "selfActivation", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "notification", ")", ";", "$", "this", "->", "dispatch", "(", "new", "SubscribeForumEvent", "(", "$", "forum", ")", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "}" ]
Subscribe a user to a forum. A mail will be sent to the user each time a message is posted. @param \Claroline\ForumBundle\Entity\Forum $forum @param \Claroline\CoreBundle\Entity\User $user
[ "Subscribe", "a", "user", "to", "a", "forum", ".", "A", "mail", "will", "be", "sent", "to", "the", "user", "each", "time", "a", "message", "is", "posted", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L133-L143
19,828
claroline/ForumBundle
Manager/Manager.php
Manager.sendMessageNotification
public function sendMessageNotification(Message $message, User $user) { $forum = $message->getSubject()->getCategory()->getForum(); $notifications = $this->notificationRepo->findBy(array('forum' => $forum)); $users = array(); foreach ($notifications as $notification) { $users[] = $notification->getUser(); } $title = $this->translator->trans( 'forum_new_message', array('%forum%' => $forum->getResourceNode()->getName(), '%subject%' => $message->getSubject()->getTitle(), '%author%' => $message->getCreator()->getUsername()), 'forum' ); $url = $this->router->generate( 'claro_forum_subjects', array('category' => $message->getSubject()->getCategory()->getId()), true ); $body = "<a href='{$url}'>{$title}</a><hr>{$message->getContent()}"; $this->mailManager->send($title, $body, $users); }
php
public function sendMessageNotification(Message $message, User $user) { $forum = $message->getSubject()->getCategory()->getForum(); $notifications = $this->notificationRepo->findBy(array('forum' => $forum)); $users = array(); foreach ($notifications as $notification) { $users[] = $notification->getUser(); } $title = $this->translator->trans( 'forum_new_message', array('%forum%' => $forum->getResourceNode()->getName(), '%subject%' => $message->getSubject()->getTitle(), '%author%' => $message->getCreator()->getUsername()), 'forum' ); $url = $this->router->generate( 'claro_forum_subjects', array('category' => $message->getSubject()->getCategory()->getId()), true ); $body = "<a href='{$url}'>{$title}</a><hr>{$message->getContent()}"; $this->mailManager->send($title, $body, $users); }
[ "public", "function", "sendMessageNotification", "(", "Message", "$", "message", ",", "User", "$", "user", ")", "{", "$", "forum", "=", "$", "message", "->", "getSubject", "(", ")", "->", "getCategory", "(", ")", "->", "getForum", "(", ")", ";", "$", "notifications", "=", "$", "this", "->", "notificationRepo", "->", "findBy", "(", "array", "(", "'forum'", "=>", "$", "forum", ")", ")", ";", "$", "users", "=", "array", "(", ")", ";", "foreach", "(", "$", "notifications", "as", "$", "notification", ")", "{", "$", "users", "[", "]", "=", "$", "notification", "->", "getUser", "(", ")", ";", "}", "$", "title", "=", "$", "this", "->", "translator", "->", "trans", "(", "'forum_new_message'", ",", "array", "(", "'%forum%'", "=>", "$", "forum", "->", "getResourceNode", "(", ")", "->", "getName", "(", ")", ",", "'%subject%'", "=>", "$", "message", "->", "getSubject", "(", ")", "->", "getTitle", "(", ")", ",", "'%author%'", "=>", "$", "message", "->", "getCreator", "(", ")", "->", "getUsername", "(", ")", ")", ",", "'forum'", ")", ";", "$", "url", "=", "$", "this", "->", "router", "->", "generate", "(", "'claro_forum_subjects'", ",", "array", "(", "'category'", "=>", "$", "message", "->", "getSubject", "(", ")", "->", "getCategory", "(", ")", "->", "getId", "(", ")", ")", ",", "true", ")", ";", "$", "body", "=", "\"<a href='{$url}'>{$title}</a><hr>{$message->getContent()}\"", ";", "$", "this", "->", "mailManager", "->", "send", "(", "$", "title", ",", "$", "body", ",", "$", "users", ")", ";", "}" ]
Send a notification to a user about a message. @param \Claroline\ForumBundle\Entity\Message $message @param \Claroline\CoreBundle\Entity\User $user
[ "Send", "a", "notification", "to", "a", "user", "about", "a", "message", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L284-L307
19,829
claroline/ForumBundle
Manager/Manager.php
Manager.moveMessage
public function moveMessage(Message $message, Subject $newSubject) { $this->om->startFlushSuite(); $oldSubject = $message->getSubject(); $message->setSubject($newSubject); $this->om->persist($message); $this->dispatch(new MoveMessageEvent($message, $oldSubject, $newSubject)); $this->om->endFlushSuite(); }
php
public function moveMessage(Message $message, Subject $newSubject) { $this->om->startFlushSuite(); $oldSubject = $message->getSubject(); $message->setSubject($newSubject); $this->om->persist($message); $this->dispatch(new MoveMessageEvent($message, $oldSubject, $newSubject)); $this->om->endFlushSuite(); }
[ "public", "function", "moveMessage", "(", "Message", "$", "message", ",", "Subject", "$", "newSubject", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "oldSubject", "=", "$", "message", "->", "getSubject", "(", ")", ";", "$", "message", "->", "setSubject", "(", "$", "newSubject", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "message", ")", ";", "$", "this", "->", "dispatch", "(", "new", "MoveMessageEvent", "(", "$", "message", ",", "$", "oldSubject", ",", "$", "newSubject", ")", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "}" ]
Move a message to an other subject. @param \Claroline\ForumBundle\Entity\Message $message @param \Claroline\ForumBundle\Entity\Subject $newSubject
[ "Move", "a", "message", "to", "an", "other", "subject", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L342-L350
19,830
claroline/ForumBundle
Manager/Manager.php
Manager.moveSubject
public function moveSubject(Subject $subject, Category $newCategory) { $this->om->startFlushSuite(); $oldCategory = $subject->getCategory(); $subject->setCategory($newCategory); $this->om->persist($subject); $this->dispatch(new MoveSubjectEvent($subject, $oldCategory, $newCategory)); $this->om->endFlushSuite(); }
php
public function moveSubject(Subject $subject, Category $newCategory) { $this->om->startFlushSuite(); $oldCategory = $subject->getCategory(); $subject->setCategory($newCategory); $this->om->persist($subject); $this->dispatch(new MoveSubjectEvent($subject, $oldCategory, $newCategory)); $this->om->endFlushSuite(); }
[ "public", "function", "moveSubject", "(", "Subject", "$", "subject", ",", "Category", "$", "newCategory", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "oldCategory", "=", "$", "subject", "->", "getCategory", "(", ")", ";", "$", "subject", "->", "setCategory", "(", "$", "newCategory", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "subject", ")", ";", "$", "this", "->", "dispatch", "(", "new", "MoveSubjectEvent", "(", "$", "subject", ",", "$", "oldCategory", ",", "$", "newCategory", ")", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "}" ]
Move a subject to an other category. @param \Claroline\ForumBundle\Entity\Subject $subject @param \Claroline\ForumBundle\Entity\Category $newCategory
[ "Move", "a", "subject", "to", "an", "other", "category", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L358-L366
19,831
claroline/ForumBundle
Manager/Manager.php
Manager.stickSubject
public function stickSubject(Subject $subject) { $this->om->startFlushSuite(); $subject->setIsSticked(true); $this->om->persist($subject); $this->dispatch(new StickSubjectEvent($subject)); $this->om->endFlushSuite(); }
php
public function stickSubject(Subject $subject) { $this->om->startFlushSuite(); $subject->setIsSticked(true); $this->om->persist($subject); $this->dispatch(new StickSubjectEvent($subject)); $this->om->endFlushSuite(); }
[ "public", "function", "stickSubject", "(", "Subject", "$", "subject", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "subject", "->", "setIsSticked", "(", "true", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "subject", ")", ";", "$", "this", "->", "dispatch", "(", "new", "StickSubjectEvent", "(", "$", "subject", ")", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "}" ]
Stick a subject at the top of the subject list. @param \Claroline\ForumBundle\Entity\Subject $subject
[ "Stick", "a", "subject", "at", "the", "top", "of", "the", "subject", "list", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L373-L380
19,832
claroline/ForumBundle
Manager/Manager.php
Manager.unstickSubject
public function unstickSubject(Subject $subject) { $this->om->startFlushSuite(); $subject->setIsSticked(false); $this->om->persist($subject); $this->dispatch(new UnstickSubjectEvent($subject)); $this->om->endFlushSuite(); }
php
public function unstickSubject(Subject $subject) { $this->om->startFlushSuite(); $subject->setIsSticked(false); $this->om->persist($subject); $this->dispatch(new UnstickSubjectEvent($subject)); $this->om->endFlushSuite(); }
[ "public", "function", "unstickSubject", "(", "Subject", "$", "subject", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "subject", "->", "setIsSticked", "(", "false", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "subject", ")", ";", "$", "this", "->", "dispatch", "(", "new", "UnstickSubjectEvent", "(", "$", "subject", ")", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "}" ]
Unstick a subject from the top of the subject list. @param \Claroline\ForumBundle\Entity\Subject $subject
[ "Unstick", "a", "subject", "from", "the", "top", "of", "the", "subject", "list", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L387-L394
19,833
claroline/ForumBundle
Manager/Manager.php
Manager.closeSubject
public function closeSubject(Subject $subject) { $this->om->startFlushSuite(); $subject->setIsClosed(true); $this->om->persist($subject); $this->dispatch(new CloseSubjectEvent($subject)); $this->om->endFlushSuite(); }
php
public function closeSubject(Subject $subject) { $this->om->startFlushSuite(); $subject->setIsClosed(true); $this->om->persist($subject); $this->dispatch(new CloseSubjectEvent($subject)); $this->om->endFlushSuite(); }
[ "public", "function", "closeSubject", "(", "Subject", "$", "subject", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "subject", "->", "setIsClosed", "(", "true", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "subject", ")", ";", "$", "this", "->", "dispatch", "(", "new", "CloseSubjectEvent", "(", "$", "subject", ")", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "}" ]
Close a subject and no one can write in it. @param \Claroline\ForumBundle\Entity\Subject $subject
[ "Close", "a", "subject", "and", "no", "one", "can", "write", "in", "it", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L401-L408
19,834
claroline/ForumBundle
Manager/Manager.php
Manager.openSubject
public function openSubject(Subject $subject) { $this->om->startFlushSuite(); $subject->setIsClosed(false); $this->om->persist($subject); $this->dispatch(new OpenSubjectEvent($subject)); $this->om->endFlushSuite(); }
php
public function openSubject(Subject $subject) { $this->om->startFlushSuite(); $subject->setIsClosed(false); $this->om->persist($subject); $this->dispatch(new OpenSubjectEvent($subject)); $this->om->endFlushSuite(); }
[ "public", "function", "openSubject", "(", "Subject", "$", "subject", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "subject", "->", "setIsClosed", "(", "false", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "subject", ")", ";", "$", "this", "->", "dispatch", "(", "new", "OpenSubjectEvent", "(", "$", "subject", ")", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "}" ]
Open a subject. @param \Claroline\ForumBundle\Entity\Subject $subject
[ "Open", "a", "subject", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L415-L422
19,835
claroline/ForumBundle
Manager/Manager.php
Manager.getSubjectsPager
public function getSubjectsPager(Category $category, $page = 1, $max = 20) { $subjects = $this->forumRepo->findSubjects($category); return $this->pagerFactory->createPagerFromArray($subjects, $page, $max); }
php
public function getSubjectsPager(Category $category, $page = 1, $max = 20) { $subjects = $this->forumRepo->findSubjects($category); return $this->pagerFactory->createPagerFromArray($subjects, $page, $max); }
[ "public", "function", "getSubjectsPager", "(", "Category", "$", "category", ",", "$", "page", "=", "1", ",", "$", "max", "=", "20", ")", "{", "$", "subjects", "=", "$", "this", "->", "forumRepo", "->", "findSubjects", "(", "$", "category", ")", ";", "return", "$", "this", "->", "pagerFactory", "->", "createPagerFromArray", "(", "$", "subjects", ",", "$", "page", ",", "$", "max", ")", ";", "}" ]
Get the pager for the subject list of a category. @param \Claroline\ForumBundle\Entity\Category $category @param integer $page @param integer $max @return \Pagerfanta\Pagerfanta
[ "Get", "the", "pager", "for", "the", "subject", "list", "of", "a", "category", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L433-L438
19,836
claroline/ForumBundle
Manager/Manager.php
Manager.getMessagesPager
public function getMessagesPager(Subject $subject, $page = 1, $max = 20) { $messages = $this->messageRepo->findBySubject($subject); return $this->pagerFactory->createPagerFromArray($messages, $page, $max); }
php
public function getMessagesPager(Subject $subject, $page = 1, $max = 20) { $messages = $this->messageRepo->findBySubject($subject); return $this->pagerFactory->createPagerFromArray($messages, $page, $max); }
[ "public", "function", "getMessagesPager", "(", "Subject", "$", "subject", ",", "$", "page", "=", "1", ",", "$", "max", "=", "20", ")", "{", "$", "messages", "=", "$", "this", "->", "messageRepo", "->", "findBySubject", "(", "$", "subject", ")", ";", "return", "$", "this", "->", "pagerFactory", "->", "createPagerFromArray", "(", "$", "messages", ",", "$", "page", ",", "$", "max", ")", ";", "}" ]
Get the pager for the message list of a subject. @param \Claroline\ForumBundle\Entity\Subject $subject @param integer $page @param integer $max @return \Pagerfanta\Pagerfanta
[ "Get", "the", "pager", "for", "the", "message", "list", "of", "a", "subject", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L449-L454
19,837
claroline/ForumBundle
Manager/Manager.php
Manager.searchPager
public function searchPager(Forum $forum, $search, $page) { $query = $this->forumRepo->search($forum, $search); return $this->pagerFactory->createPager($query, $page); }
php
public function searchPager(Forum $forum, $search, $page) { $query = $this->forumRepo->search($forum, $search); return $this->pagerFactory->createPager($query, $page); }
[ "public", "function", "searchPager", "(", "Forum", "$", "forum", ",", "$", "search", ",", "$", "page", ")", "{", "$", "query", "=", "$", "this", "->", "forumRepo", "->", "search", "(", "$", "forum", ",", "$", "search", ")", ";", "return", "$", "this", "->", "pagerFactory", "->", "createPager", "(", "$", "query", ",", "$", "page", ")", ";", "}" ]
Get the pager for the forum search. @param \Claroline\ForumBundle\Entity\Forum $forum @param string $search @param integer $page @return \Pagerfanta\Pagerfanta
[ "Get", "the", "pager", "for", "the", "forum", "search", "." ]
bd85dfd870cacee541ea94fec8e59744bf90eaf4
https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Manager/Manager.php#L465-L470
19,838
nyeholt/silverstripe-external-content
thirdparty/Zend/Http/Client.php
Zend_Http_Client._prepareHeaders
protected function _prepareHeaders() { $headers = array(); // Set the host header if (! isset($this->headers['host'])) { $host = $this->uri->getHost(); // If the port is not default, add it if (! (($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80) || ($this->uri->getScheme() == 'https' && $this->uri->getPort() == 443))) { $host .= ':' . $this->uri->getPort(); } $headers[] = "Host: {$host}"; } // Set the connection header if (! isset($this->headers['connection'])) { if (! $this->config['keepalive']) { $headers[] = "Connection: close"; } } // Set the Accept-encoding header if not set - depending on whether // zlib is available or not. if (! isset($this->headers['accept-encoding'])) { if (function_exists('gzinflate')) { $headers[] = 'Accept-encoding: gzip, deflate'; } else { $headers[] = 'Accept-encoding: identity'; } } // Set the Content-Type header if ($this->method == self::POST && (! isset($this->headers[strtolower(self::CONTENT_TYPE)]) && isset($this->enctype))) { $headers[] = self::CONTENT_TYPE . ': ' . $this->enctype; } // Set the user agent header if (! isset($this->headers['user-agent']) && isset($this->config['useragent'])) { $headers[] = "User-Agent: {$this->config['useragent']}"; } // Set HTTP authentication if needed if (is_array($this->auth)) { $auth = self::encodeAuthHeader($this->auth['user'], $this->auth['password'], $this->auth['type']); $headers[] = "Authorization: {$auth}"; } // Load cookies from cookie jar if (isset($this->cookiejar)) { $cookstr = $this->cookiejar->getMatchingCookies($this->uri, true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT); if ($cookstr) { $headers[] = "Cookie: {$cookstr}"; } } // Add all other user defined headers foreach ($this->headers as $header) { list($name, $value) = $header; if (is_array($value)) { $value = implode(', ', $value); } $headers[] = "$name: $value"; } return $headers; }
php
protected function _prepareHeaders() { $headers = array(); // Set the host header if (! isset($this->headers['host'])) { $host = $this->uri->getHost(); // If the port is not default, add it if (! (($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80) || ($this->uri->getScheme() == 'https' && $this->uri->getPort() == 443))) { $host .= ':' . $this->uri->getPort(); } $headers[] = "Host: {$host}"; } // Set the connection header if (! isset($this->headers['connection'])) { if (! $this->config['keepalive']) { $headers[] = "Connection: close"; } } // Set the Accept-encoding header if not set - depending on whether // zlib is available or not. if (! isset($this->headers['accept-encoding'])) { if (function_exists('gzinflate')) { $headers[] = 'Accept-encoding: gzip, deflate'; } else { $headers[] = 'Accept-encoding: identity'; } } // Set the Content-Type header if ($this->method == self::POST && (! isset($this->headers[strtolower(self::CONTENT_TYPE)]) && isset($this->enctype))) { $headers[] = self::CONTENT_TYPE . ': ' . $this->enctype; } // Set the user agent header if (! isset($this->headers['user-agent']) && isset($this->config['useragent'])) { $headers[] = "User-Agent: {$this->config['useragent']}"; } // Set HTTP authentication if needed if (is_array($this->auth)) { $auth = self::encodeAuthHeader($this->auth['user'], $this->auth['password'], $this->auth['type']); $headers[] = "Authorization: {$auth}"; } // Load cookies from cookie jar if (isset($this->cookiejar)) { $cookstr = $this->cookiejar->getMatchingCookies($this->uri, true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT); if ($cookstr) { $headers[] = "Cookie: {$cookstr}"; } } // Add all other user defined headers foreach ($this->headers as $header) { list($name, $value) = $header; if (is_array($value)) { $value = implode(', ', $value); } $headers[] = "$name: $value"; } return $headers; }
[ "protected", "function", "_prepareHeaders", "(", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "// Set the host header", "if", "(", "!", "isset", "(", "$", "this", "->", "headers", "[", "'host'", "]", ")", ")", "{", "$", "host", "=", "$", "this", "->", "uri", "->", "getHost", "(", ")", ";", "// If the port is not default, add it", "if", "(", "!", "(", "(", "$", "this", "->", "uri", "->", "getScheme", "(", ")", "==", "'http'", "&&", "$", "this", "->", "uri", "->", "getPort", "(", ")", "==", "80", ")", "||", "(", "$", "this", "->", "uri", "->", "getScheme", "(", ")", "==", "'https'", "&&", "$", "this", "->", "uri", "->", "getPort", "(", ")", "==", "443", ")", ")", ")", "{", "$", "host", ".=", "':'", ".", "$", "this", "->", "uri", "->", "getPort", "(", ")", ";", "}", "$", "headers", "[", "]", "=", "\"Host: {$host}\"", ";", "}", "// Set the connection header", "if", "(", "!", "isset", "(", "$", "this", "->", "headers", "[", "'connection'", "]", ")", ")", "{", "if", "(", "!", "$", "this", "->", "config", "[", "'keepalive'", "]", ")", "{", "$", "headers", "[", "]", "=", "\"Connection: close\"", ";", "}", "}", "// Set the Accept-encoding header if not set - depending on whether", "// zlib is available or not.", "if", "(", "!", "isset", "(", "$", "this", "->", "headers", "[", "'accept-encoding'", "]", ")", ")", "{", "if", "(", "function_exists", "(", "'gzinflate'", ")", ")", "{", "$", "headers", "[", "]", "=", "'Accept-encoding: gzip, deflate'", ";", "}", "else", "{", "$", "headers", "[", "]", "=", "'Accept-encoding: identity'", ";", "}", "}", "// Set the Content-Type header", "if", "(", "$", "this", "->", "method", "==", "self", "::", "POST", "&&", "(", "!", "isset", "(", "$", "this", "->", "headers", "[", "strtolower", "(", "self", "::", "CONTENT_TYPE", ")", "]", ")", "&&", "isset", "(", "$", "this", "->", "enctype", ")", ")", ")", "{", "$", "headers", "[", "]", "=", "self", "::", "CONTENT_TYPE", ".", "': '", ".", "$", "this", "->", "enctype", ";", "}", "// Set the user agent header", "if", "(", "!", "isset", "(", "$", "this", "->", "headers", "[", "'user-agent'", "]", ")", "&&", "isset", "(", "$", "this", "->", "config", "[", "'useragent'", "]", ")", ")", "{", "$", "headers", "[", "]", "=", "\"User-Agent: {$this->config['useragent']}\"", ";", "}", "// Set HTTP authentication if needed", "if", "(", "is_array", "(", "$", "this", "->", "auth", ")", ")", "{", "$", "auth", "=", "self", "::", "encodeAuthHeader", "(", "$", "this", "->", "auth", "[", "'user'", "]", ",", "$", "this", "->", "auth", "[", "'password'", "]", ",", "$", "this", "->", "auth", "[", "'type'", "]", ")", ";", "$", "headers", "[", "]", "=", "\"Authorization: {$auth}\"", ";", "}", "// Load cookies from cookie jar", "if", "(", "isset", "(", "$", "this", "->", "cookiejar", ")", ")", "{", "$", "cookstr", "=", "$", "this", "->", "cookiejar", "->", "getMatchingCookies", "(", "$", "this", "->", "uri", ",", "true", ",", "Zend_Http_CookieJar", "::", "COOKIE_STRING_CONCAT", ")", ";", "if", "(", "$", "cookstr", ")", "{", "$", "headers", "[", "]", "=", "\"Cookie: {$cookstr}\"", ";", "}", "}", "// Add all other user defined headers", "foreach", "(", "$", "this", "->", "headers", "as", "$", "header", ")", "{", "list", "(", "$", "name", ",", "$", "value", ")", "=", "$", "header", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "implode", "(", "', '", ",", "$", "value", ")", ";", "}", "$", "headers", "[", "]", "=", "\"$name: $value\"", ";", "}", "return", "$", "headers", ";", "}" ]
Prepare the request headers @return array
[ "Prepare", "the", "request", "headers" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Http/Client.php#L942-L1015
19,839
fyuze/framework
src/Fyuze/Http/Kernel.php
Kernel.resolve
protected function resolve($action, $params) { if ($action instanceof Closure) { return $action($params); } list($controller, $method) = $action; $reflect = new ReflectionClass($controller); foreach (array_filter($reflect->getMethod($method)->getParameters(), $this->getParams()) as $param) { array_unshift($params, $this->registry->make( $param->getClass()->getName() )); } return $reflect->getMethod($method)->invokeArgs( $this->registry->make($controller), $params ); }
php
protected function resolve($action, $params) { if ($action instanceof Closure) { return $action($params); } list($controller, $method) = $action; $reflect = new ReflectionClass($controller); foreach (array_filter($reflect->getMethod($method)->getParameters(), $this->getParams()) as $param) { array_unshift($params, $this->registry->make( $param->getClass()->getName() )); } return $reflect->getMethod($method)->invokeArgs( $this->registry->make($controller), $params ); }
[ "protected", "function", "resolve", "(", "$", "action", ",", "$", "params", ")", "{", "if", "(", "$", "action", "instanceof", "Closure", ")", "{", "return", "$", "action", "(", "$", "params", ")", ";", "}", "list", "(", "$", "controller", ",", "$", "method", ")", "=", "$", "action", ";", "$", "reflect", "=", "new", "ReflectionClass", "(", "$", "controller", ")", ";", "foreach", "(", "array_filter", "(", "$", "reflect", "->", "getMethod", "(", "$", "method", ")", "->", "getParameters", "(", ")", ",", "$", "this", "->", "getParams", "(", ")", ")", "as", "$", "param", ")", "{", "array_unshift", "(", "$", "params", ",", "$", "this", "->", "registry", "->", "make", "(", "$", "param", "->", "getClass", "(", ")", "->", "getName", "(", ")", ")", ")", ";", "}", "return", "$", "reflect", "->", "getMethod", "(", "$", "method", ")", "->", "invokeArgs", "(", "$", "this", "->", "registry", "->", "make", "(", "$", "controller", ")", ",", "$", "params", ")", ";", "}" ]
Method injection resolver @param $action @param $params @return mixed
[ "Method", "injection", "resolver" ]
89b3984f7225e24bfcdafb090ee197275b3222c9
https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Http/Kernel.php#L76-L97
19,840
simplisti/jasper-starter
src/Starter.php
Starter.compile
public function compile (Report $report, bool $skipExec = false) { $sourceFullPath = $report->getSourceFile(); // $this->sourcePath . DIRECTORY_SEPARATOR . $report->getSourceFile(); $compiledPath = $this->compiledPath; $this->shellCommand = $this->executablePath . " cp -o $compiledPath $sourceFullPath"; if (!$skipExec) { $oldcwd = getcwd(); chdir($this->sourcePath); $error = shell_exec(escapeshellcmd($this->shellCommand)); chdir($oldcwd); if (!empty($error)) { throw new \Exception($error); } } return $compiledPath; }
php
public function compile (Report $report, bool $skipExec = false) { $sourceFullPath = $report->getSourceFile(); // $this->sourcePath . DIRECTORY_SEPARATOR . $report->getSourceFile(); $compiledPath = $this->compiledPath; $this->shellCommand = $this->executablePath . " cp -o $compiledPath $sourceFullPath"; if (!$skipExec) { $oldcwd = getcwd(); chdir($this->sourcePath); $error = shell_exec(escapeshellcmd($this->shellCommand)); chdir($oldcwd); if (!empty($error)) { throw new \Exception($error); } } return $compiledPath; }
[ "public", "function", "compile", "(", "Report", "$", "report", ",", "bool", "$", "skipExec", "=", "false", ")", "{", "$", "sourceFullPath", "=", "$", "report", "->", "getSourceFile", "(", ")", ";", "// $this->sourcePath . DIRECTORY_SEPARATOR . $report->getSourceFile(); \r", "$", "compiledPath", "=", "$", "this", "->", "compiledPath", ";", "$", "this", "->", "shellCommand", "=", "$", "this", "->", "executablePath", ".", "\" cp -o $compiledPath $sourceFullPath\"", ";", "if", "(", "!", "$", "skipExec", ")", "{", "$", "oldcwd", "=", "getcwd", "(", ")", ";", "chdir", "(", "$", "this", "->", "sourcePath", ")", ";", "$", "error", "=", "shell_exec", "(", "escapeshellcmd", "(", "$", "this", "->", "shellCommand", ")", ")", ";", "chdir", "(", "$", "oldcwd", ")", ";", "if", "(", "!", "empty", "(", "$", "error", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "error", ")", ";", "}", "}", "return", "$", "compiledPath", ";", "}" ]
Compile JRXML files into JASPER for processing. @return self
[ "Compile", "JRXML", "files", "into", "JASPER", "for", "processing", "." ]
e03e24663e983710fb4f1afad6c85bde8553de65
https://github.com/simplisti/jasper-starter/blob/e03e24663e983710fb4f1afad6c85bde8553de65/src/Starter.php#L75-L95
19,841
simplisti/jasper-starter
src/Starter.php
Starter.process
public function process (Report $report, bool $skipExec = false) { $compiledFullPath = $this->compiledPath . DIRECTORY_SEPARATOR . pathinfo($report->getSourceFile(), PATHINFO_FILENAME) . '.jasper'; $processedFullPath = $this->processedPath . DIRECTORY_SEPARATOR . uniqid('ASB'); $format = ' -f ' . $report->getTargetType(); $value = empty($report->getDataSource()) ? $this->getDataSource() : $report->getDataSource(); $type = "-t $value "; $datafile = ''; if (!empty($report->getFile('file'))) { $datafile .= $this->processCsvFileOptions($report); } $database = $this->processDatabaseOptions($report); $parameters = $this->processReportParameters($report); $this->shellCommand = $this->executablePath . " pr -o $processedFullPath $compiledFullPath $format $type $database $datafile $parameters"; if (!$skipExec) { $oldcwd = getcwd(); chdir($this->sourcePath); $error = shell_exec(escapeshellcmd($this->shellCommand)); chdir($oldcwd); if (!empty($error)) { throw new \Exception($error); } } return $processedFullPath . '.' . $report->getTargetType(); }
php
public function process (Report $report, bool $skipExec = false) { $compiledFullPath = $this->compiledPath . DIRECTORY_SEPARATOR . pathinfo($report->getSourceFile(), PATHINFO_FILENAME) . '.jasper'; $processedFullPath = $this->processedPath . DIRECTORY_SEPARATOR . uniqid('ASB'); $format = ' -f ' . $report->getTargetType(); $value = empty($report->getDataSource()) ? $this->getDataSource() : $report->getDataSource(); $type = "-t $value "; $datafile = ''; if (!empty($report->getFile('file'))) { $datafile .= $this->processCsvFileOptions($report); } $database = $this->processDatabaseOptions($report); $parameters = $this->processReportParameters($report); $this->shellCommand = $this->executablePath . " pr -o $processedFullPath $compiledFullPath $format $type $database $datafile $parameters"; if (!$skipExec) { $oldcwd = getcwd(); chdir($this->sourcePath); $error = shell_exec(escapeshellcmd($this->shellCommand)); chdir($oldcwd); if (!empty($error)) { throw new \Exception($error); } } return $processedFullPath . '.' . $report->getTargetType(); }
[ "public", "function", "process", "(", "Report", "$", "report", ",", "bool", "$", "skipExec", "=", "false", ")", "{", "$", "compiledFullPath", "=", "$", "this", "->", "compiledPath", ".", "DIRECTORY_SEPARATOR", ".", "pathinfo", "(", "$", "report", "->", "getSourceFile", "(", ")", ",", "PATHINFO_FILENAME", ")", ".", "'.jasper'", ";", "$", "processedFullPath", "=", "$", "this", "->", "processedPath", ".", "DIRECTORY_SEPARATOR", ".", "uniqid", "(", "'ASB'", ")", ";", "$", "format", "=", "' -f '", ".", "$", "report", "->", "getTargetType", "(", ")", ";", "$", "value", "=", "empty", "(", "$", "report", "->", "getDataSource", "(", ")", ")", "?", "$", "this", "->", "getDataSource", "(", ")", ":", "$", "report", "->", "getDataSource", "(", ")", ";", "$", "type", "=", "\"-t $value \"", ";", "$", "datafile", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "report", "->", "getFile", "(", "'file'", ")", ")", ")", "{", "$", "datafile", ".=", "$", "this", "->", "processCsvFileOptions", "(", "$", "report", ")", ";", "}", "$", "database", "=", "$", "this", "->", "processDatabaseOptions", "(", "$", "report", ")", ";", "$", "parameters", "=", "$", "this", "->", "processReportParameters", "(", "$", "report", ")", ";", "$", "this", "->", "shellCommand", "=", "$", "this", "->", "executablePath", ".", "\" pr -o $processedFullPath $compiledFullPath $format $type $database $datafile $parameters\"", ";", "if", "(", "!", "$", "skipExec", ")", "{", "$", "oldcwd", "=", "getcwd", "(", ")", ";", "chdir", "(", "$", "this", "->", "sourcePath", ")", ";", "$", "error", "=", "shell_exec", "(", "escapeshellcmd", "(", "$", "this", "->", "shellCommand", ")", ")", ";", "chdir", "(", "$", "oldcwd", ")", ";", "if", "(", "!", "empty", "(", "$", "error", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "error", ")", ";", "}", "}", "return", "$", "processedFullPath", ".", "'.'", ".", "$", "report", "->", "getTargetType", "(", ")", ";", "}" ]
Process JASPER file into PDF or similar output format. @return $this
[ "Process", "JASPER", "file", "into", "PDF", "or", "similar", "output", "format", "." ]
e03e24663e983710fb4f1afad6c85bde8553de65
https://github.com/simplisti/jasper-starter/blob/e03e24663e983710fb4f1afad6c85bde8553de65/src/Starter.php#L102-L134
19,842
simplisti/jasper-starter
src/Starter.php
Starter.processCsvFileOptions
protected function processCsvFileOptions (Report $report) { $value = $report->getFile('file'); $csvSwitch = "--data-file $value "; // NOTE: If column headers array is empty than we assume CSV first row $value = $report->getCsvfile('columnHeaderNames'); if (empty($value)) { $csvSwitch .= '--csv-first-row '; } else { $csvSwitch .= "--csv-columns " . implode(',', $value) . ' '; } $value = $report->getCsvfile('charSet'); $database = "--csv-charset $value "; $value = $report->getCsvfile('delimField'); $database = "--csv-field-del $value "; $value = $report->getCsvfile('delimNewLine'); $database = "--csv-record-del $value "; return $csvSwitch; }
php
protected function processCsvFileOptions (Report $report) { $value = $report->getFile('file'); $csvSwitch = "--data-file $value "; // NOTE: If column headers array is empty than we assume CSV first row $value = $report->getCsvfile('columnHeaderNames'); if (empty($value)) { $csvSwitch .= '--csv-first-row '; } else { $csvSwitch .= "--csv-columns " . implode(',', $value) . ' '; } $value = $report->getCsvfile('charSet'); $database = "--csv-charset $value "; $value = $report->getCsvfile('delimField'); $database = "--csv-field-del $value "; $value = $report->getCsvfile('delimNewLine'); $database = "--csv-record-del $value "; return $csvSwitch; }
[ "protected", "function", "processCsvFileOptions", "(", "Report", "$", "report", ")", "{", "$", "value", "=", "$", "report", "->", "getFile", "(", "'file'", ")", ";", "$", "csvSwitch", "=", "\"--data-file $value \"", ";", "// NOTE: If column headers array is empty than we assume CSV first row\r", "$", "value", "=", "$", "report", "->", "getCsvfile", "(", "'columnHeaderNames'", ")", ";", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "$", "csvSwitch", ".=", "'--csv-first-row '", ";", "}", "else", "{", "$", "csvSwitch", ".=", "\"--csv-columns \"", ".", "implode", "(", "','", ",", "$", "value", ")", ".", "' '", ";", "}", "$", "value", "=", "$", "report", "->", "getCsvfile", "(", "'charSet'", ")", ";", "$", "database", "=", "\"--csv-charset $value \"", ";", "$", "value", "=", "$", "report", "->", "getCsvfile", "(", "'delimField'", ")", ";", "$", "database", "=", "\"--csv-field-del $value \"", ";", "$", "value", "=", "$", "report", "->", "getCsvfile", "(", "'delimNewLine'", ")", ";", "$", "database", "=", "\"--csv-record-del $value \"", ";", "return", "$", "csvSwitch", ";", "}" ]
Process CSV file details @return $this
[ "Process", "CSV", "file", "details" ]
e03e24663e983710fb4f1afad6c85bde8553de65
https://github.com/simplisti/jasper-starter/blob/e03e24663e983710fb4f1afad6c85bde8553de65/src/Starter.php#L141-L165
19,843
webforge-labs/psc-cms
lib/Psc/PSC.php
PSC.getRoot
public static function getRoot() { if (!isset(self::$root)) { try { $root = getenv('PSC_CMS'); if (!empty($root)) { return self::$root = new Dir($root); } } catch (\Webforge\Common\System\Exception $e) {} throw MissingEnvironmentVariableException::factory('PSC_CMS', 'The variable should reference a directory, where the host-config.php can live. Use trailing slash/backslash.'); } return self::$root; }
php
public static function getRoot() { if (!isset(self::$root)) { try { $root = getenv('PSC_CMS'); if (!empty($root)) { return self::$root = new Dir($root); } } catch (\Webforge\Common\System\Exception $e) {} throw MissingEnvironmentVariableException::factory('PSC_CMS', 'The variable should reference a directory, where the host-config.php can live. Use trailing slash/backslash.'); } return self::$root; }
[ "public", "static", "function", "getRoot", "(", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "root", ")", ")", "{", "try", "{", "$", "root", "=", "getenv", "(", "'PSC_CMS'", ")", ";", "if", "(", "!", "empty", "(", "$", "root", ")", ")", "{", "return", "self", "::", "$", "root", "=", "new", "Dir", "(", "$", "root", ")", ";", "}", "}", "catch", "(", "\\", "Webforge", "\\", "Common", "\\", "System", "\\", "Exception", "$", "e", ")", "{", "}", "throw", "MissingEnvironmentVariableException", "::", "factory", "(", "'PSC_CMS'", ",", "'The variable should reference a directory, where the host-config.php can live. Use trailing slash/backslash.'", ")", ";", "}", "return", "self", "::", "$", "root", ";", "}" ]
Returns the root directory of the host where the host-config lives @return Psc\System\Directory @throws Psc\MissingEnvironmentVariableException
[ "Returns", "the", "root", "directory", "of", "the", "host", "where", "the", "host", "-", "config", "lives" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/PSC.php#L90-L106
19,844
geekwright/Po
src/PoFile.php
PoFile.createKey
public static function createKey(?string $msgid, ?string $msgctxt = null, ?string $msgid_plural = null): string { $key = ''; if (!empty($msgctxt)) { $key .= $msgctxt . '|'; } $key .= (string) $msgid; if (!empty($msgid_plural)) { $key .= '|' . $msgid_plural; } return $key; }
php
public static function createKey(?string $msgid, ?string $msgctxt = null, ?string $msgid_plural = null): string { $key = ''; if (!empty($msgctxt)) { $key .= $msgctxt . '|'; } $key .= (string) $msgid; if (!empty($msgid_plural)) { $key .= '|' . $msgid_plural; } return $key; }
[ "public", "static", "function", "createKey", "(", "?", "string", "$", "msgid", ",", "?", "string", "$", "msgctxt", "=", "null", ",", "?", "string", "$", "msgid_plural", "=", "null", ")", ":", "string", "{", "$", "key", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "msgctxt", ")", ")", "{", "$", "key", ".=", "$", "msgctxt", ".", "'|'", ";", "}", "$", "key", ".=", "(", "string", ")", "$", "msgid", ";", "if", "(", "!", "empty", "(", "$", "msgid_plural", ")", ")", "{", "$", "key", ".=", "'|'", ".", "$", "msgid_plural", ";", "}", "return", "$", "key", ";", "}" ]
Build the internal entries array key from id, context and plural id @param string|null $msgid the untranslated message of the entry @param string|null $msgctxt the context of the entry, if any @param string|null $msgid_plural the untranslated plural message of the entry, if any @return string
[ "Build", "the", "internal", "entries", "array", "key", "from", "id", "context", "and", "plural", "id" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoFile.php#L72-L83
19,845
geekwright/Po
src/PoFile.php
PoFile.createKeyFromEntry
public function createKeyFromEntry(PoEntry $entry): string { return $this->createKey( $entry->getAsString(PoTokens::MESSAGE), $entry->getAsString(PoTokens::CONTEXT), $entry->getAsString(PoTokens::PLURAL) ); }
php
public function createKeyFromEntry(PoEntry $entry): string { return $this->createKey( $entry->getAsString(PoTokens::MESSAGE), $entry->getAsString(PoTokens::CONTEXT), $entry->getAsString(PoTokens::PLURAL) ); }
[ "public", "function", "createKeyFromEntry", "(", "PoEntry", "$", "entry", ")", ":", "string", "{", "return", "$", "this", "->", "createKey", "(", "$", "entry", "->", "getAsString", "(", "PoTokens", "::", "MESSAGE", ")", ",", "$", "entry", "->", "getAsString", "(", "PoTokens", "::", "CONTEXT", ")", ",", "$", "entry", "->", "getAsString", "(", "PoTokens", "::", "PLURAL", ")", ")", ";", "}" ]
Build an internal entries array key from a PoEntry @param PoEntry $entry the PoEntry to build key from @return string
[ "Build", "an", "internal", "entries", "array", "key", "from", "a", "PoEntry" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoFile.php#L92-L99
19,846
geekwright/Po
src/PoFile.php
PoFile.addEntry
public function addEntry(PoEntry $entry, bool $replace = true): bool { $key = $this->createKeyFromEntry($entry); // some entires, such as obsolete entries, have no key // for some uses, these are dead weight - need better strategy for that case if (empty($key)) { $this->unkeyedEntries[] = $entry; return true; } if (isset($this->entries[$key]) && !$replace) { return false; } else { $this->entries[$key] = $entry; return true; } }
php
public function addEntry(PoEntry $entry, bool $replace = true): bool { $key = $this->createKeyFromEntry($entry); // some entires, such as obsolete entries, have no key // for some uses, these are dead weight - need better strategy for that case if (empty($key)) { $this->unkeyedEntries[] = $entry; return true; } if (isset($this->entries[$key]) && !$replace) { return false; } else { $this->entries[$key] = $entry; return true; } }
[ "public", "function", "addEntry", "(", "PoEntry", "$", "entry", ",", "bool", "$", "replace", "=", "true", ")", ":", "bool", "{", "$", "key", "=", "$", "this", "->", "createKeyFromEntry", "(", "$", "entry", ")", ";", "// some entires, such as obsolete entries, have no key", "// for some uses, these are dead weight - need better strategy for that case", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "$", "this", "->", "unkeyedEntries", "[", "]", "=", "$", "entry", ";", "return", "true", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "entries", "[", "$", "key", "]", ")", "&&", "!", "$", "replace", ")", "{", "return", "false", ";", "}", "else", "{", "$", "this", "->", "entries", "[", "$", "key", "]", "=", "$", "entry", ";", "return", "true", ";", "}", "}" ]
Add an entry to the PoFile using internal key @param PoEntry $entry the PoEntry to add @param boolean $replace true to replace any existing entry matching this key, false to not change the PoFile for a duplicated key @return boolean true if added, false if not
[ "Add", "an", "entry", "to", "the", "PoFile", "using", "internal", "key" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoFile.php#L164-L181
19,847
geekwright/Po
src/PoFile.php
PoFile.mergeEntry
public function mergeEntry(PoEntry $newEntry): bool { $key = $this->createKeyFromEntry($newEntry); // keyed entries only if (empty($key)) { return false; } if (isset($this->entries[$key])) { $existingEntry = $this->entries[$key]; $mergeTokens = array(PoTokens::REFERENCE, PoTokens::EXTRACTED_COMMENTS); foreach ($mergeTokens as $type) { $toMerge = $newEntry->get($type); if (!empty($toMerge)) { $toMerge = is_array($toMerge) ? $toMerge : array($toMerge); foreach ($toMerge as $value) { $existingEntry->add($type, $value); } } } } else { $this->entries[$key] = $newEntry; } return true; }
php
public function mergeEntry(PoEntry $newEntry): bool { $key = $this->createKeyFromEntry($newEntry); // keyed entries only if (empty($key)) { return false; } if (isset($this->entries[$key])) { $existingEntry = $this->entries[$key]; $mergeTokens = array(PoTokens::REFERENCE, PoTokens::EXTRACTED_COMMENTS); foreach ($mergeTokens as $type) { $toMerge = $newEntry->get($type); if (!empty($toMerge)) { $toMerge = is_array($toMerge) ? $toMerge : array($toMerge); foreach ($toMerge as $value) { $existingEntry->add($type, $value); } } } } else { $this->entries[$key] = $newEntry; } return true; }
[ "public", "function", "mergeEntry", "(", "PoEntry", "$", "newEntry", ")", ":", "bool", "{", "$", "key", "=", "$", "this", "->", "createKeyFromEntry", "(", "$", "newEntry", ")", ";", "// keyed entries only", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "entries", "[", "$", "key", "]", ")", ")", "{", "$", "existingEntry", "=", "$", "this", "->", "entries", "[", "$", "key", "]", ";", "$", "mergeTokens", "=", "array", "(", "PoTokens", "::", "REFERENCE", ",", "PoTokens", "::", "EXTRACTED_COMMENTS", ")", ";", "foreach", "(", "$", "mergeTokens", "as", "$", "type", ")", "{", "$", "toMerge", "=", "$", "newEntry", "->", "get", "(", "$", "type", ")", ";", "if", "(", "!", "empty", "(", "$", "toMerge", ")", ")", "{", "$", "toMerge", "=", "is_array", "(", "$", "toMerge", ")", "?", "$", "toMerge", ":", "array", "(", "$", "toMerge", ")", ";", "foreach", "(", "$", "toMerge", "as", "$", "value", ")", "{", "$", "existingEntry", "->", "add", "(", "$", "type", ",", "$", "value", ")", ";", "}", "}", "}", "}", "else", "{", "$", "this", "->", "entries", "[", "$", "key", "]", "=", "$", "newEntry", ";", "}", "return", "true", ";", "}" ]
Merge an entry with any existing entry with the same key. If the key does not exist, add the entry, otherwise merge comments, references, and flags. This is intended for use in building a POT, where the handling of translated strings is not a factor. @param PoEntry $newEntry the PoEntry to merge @return boolean true if merged or added, false if not
[ "Merge", "an", "entry", "with", "any", "existing", "entry", "with", "the", "same", "key", ".", "If", "the", "key", "does", "not", "exist", "add", "the", "entry", "otherwise", "merge", "comments", "references", "and", "flags", "." ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoFile.php#L194-L219
19,848
geekwright/Po
src/PoFile.php
PoFile.findEntry
public function findEntry(string $msgid, ?string $msgctxt = null, ?string $msgid_plural = null): ?PoEntry { $key = $this->createKey($msgid, $msgctxt, $msgid_plural); $entry = null; if (!empty($key) && isset($this->entries[$key])) { $entry = $this->entries[$key]; } return $entry; }
php
public function findEntry(string $msgid, ?string $msgctxt = null, ?string $msgid_plural = null): ?PoEntry { $key = $this->createKey($msgid, $msgctxt, $msgid_plural); $entry = null; if (!empty($key) && isset($this->entries[$key])) { $entry = $this->entries[$key]; } return $entry; }
[ "public", "function", "findEntry", "(", "string", "$", "msgid", ",", "?", "string", "$", "msgctxt", "=", "null", ",", "?", "string", "$", "msgid_plural", "=", "null", ")", ":", "?", "PoEntry", "{", "$", "key", "=", "$", "this", "->", "createKey", "(", "$", "msgid", ",", "$", "msgctxt", ",", "$", "msgid_plural", ")", ";", "$", "entry", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "key", ")", "&&", "isset", "(", "$", "this", "->", "entries", "[", "$", "key", "]", ")", ")", "{", "$", "entry", "=", "$", "this", "->", "entries", "[", "$", "key", "]", ";", "}", "return", "$", "entry", ";", "}" ]
Get an entry based on key values - msgid, msgctxt and msgid_plural @param string $msgid the untranslated message of the entry @param string|null $msgctxt the context of the entry, if any @param string|null $msgid_plural the untranslated plural message of the entry, if any @return PoEntry|null matching entry, or null if not found
[ "Get", "an", "entry", "based", "on", "key", "values", "-", "msgid", "msgctxt", "and", "msgid_plural" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoFile.php#L230-L240
19,849
geekwright/Po
src/PoFile.php
PoFile.removeEntry
public function removeEntry(PoEntry $entry): bool { $key = $this->createKeyFromEntry($entry); // try by the key first. if (!empty($key) && isset($this->entries[$key])) { if ($entry === $this->entries[$key]) { unset($this->entries[$key]); return true; } } // the entry can't be matched by key, so we have to loop :( foreach ($this->entries as $key => $value) { if ($entry === $value) { unset($this->entries[$key]); return true; } } // no match found in main entries, try the unkeyedEntries foreach ($this->unkeyedEntries as $key => $value) { if ($entry === $value) { unset($this->unkeyedEntries[$key]); return true; } } return false; }
php
public function removeEntry(PoEntry $entry): bool { $key = $this->createKeyFromEntry($entry); // try by the key first. if (!empty($key) && isset($this->entries[$key])) { if ($entry === $this->entries[$key]) { unset($this->entries[$key]); return true; } } // the entry can't be matched by key, so we have to loop :( foreach ($this->entries as $key => $value) { if ($entry === $value) { unset($this->entries[$key]); return true; } } // no match found in main entries, try the unkeyedEntries foreach ($this->unkeyedEntries as $key => $value) { if ($entry === $value) { unset($this->unkeyedEntries[$key]); return true; } } return false; }
[ "public", "function", "removeEntry", "(", "PoEntry", "$", "entry", ")", ":", "bool", "{", "$", "key", "=", "$", "this", "->", "createKeyFromEntry", "(", "$", "entry", ")", ";", "// try by the key first.", "if", "(", "!", "empty", "(", "$", "key", ")", "&&", "isset", "(", "$", "this", "->", "entries", "[", "$", "key", "]", ")", ")", "{", "if", "(", "$", "entry", "===", "$", "this", "->", "entries", "[", "$", "key", "]", ")", "{", "unset", "(", "$", "this", "->", "entries", "[", "$", "key", "]", ")", ";", "return", "true", ";", "}", "}", "// the entry can't be matched by key, so we have to loop :(", "foreach", "(", "$", "this", "->", "entries", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "entry", "===", "$", "value", ")", "{", "unset", "(", "$", "this", "->", "entries", "[", "$", "key", "]", ")", ";", "return", "true", ";", "}", "}", "// no match found in main entries, try the unkeyedEntries", "foreach", "(", "$", "this", "->", "unkeyedEntries", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "entry", "===", "$", "value", ")", "{", "unset", "(", "$", "this", "->", "unkeyedEntries", "[", "$", "key", "]", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Remove an entry from the PoFile In simple cases, the entry can be found by key. There are several cases where it is not that easy to locate the PoEntry to be removed: - the PoEntry was altered, making the generated and stored key different - the entry is not keyed and is in unkeyedEntries In any of these cases, we must loop thru the entry arrays looking for an exact object match, so the cost of the remove goes up @param PoEntry $entry the PoEntry to merge @return boolean true if remove, false if not
[ "Remove", "an", "entry", "from", "the", "PoFile" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoFile.php#L257-L286
19,850
geekwright/Po
src/PoFile.php
PoFile.writePoFile
public function writePoFile(string $file): void { $source = $this->dumpString(); $testName = file_exists($file) ? $file : dirname($file); $status = is_writable($testName); if ($status === true) { $status = file_put_contents($file, $source); } if (false === $status) { throw new FileNotWritableException($file); } }
php
public function writePoFile(string $file): void { $source = $this->dumpString(); $testName = file_exists($file) ? $file : dirname($file); $status = is_writable($testName); if ($status === true) { $status = file_put_contents($file, $source); } if (false === $status) { throw new FileNotWritableException($file); } }
[ "public", "function", "writePoFile", "(", "string", "$", "file", ")", ":", "void", "{", "$", "source", "=", "$", "this", "->", "dumpString", "(", ")", ";", "$", "testName", "=", "file_exists", "(", "$", "file", ")", "?", "$", "file", ":", "dirname", "(", "$", "file", ")", ";", "$", "status", "=", "is_writable", "(", "$", "testName", ")", ";", "if", "(", "$", "status", "===", "true", ")", "{", "$", "status", "=", "file_put_contents", "(", "$", "file", ",", "$", "source", ")", ";", "}", "if", "(", "false", "===", "$", "status", ")", "{", "throw", "new", "FileNotWritableException", "(", "$", "file", ")", ";", "}", "}" ]
Write any current contents to a po file @param string $file po file to write @return void @throws FileNotWritableException
[ "Write", "any", "current", "contents", "to", "a", "po", "file" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoFile.php#L297-L308
19,851
geekwright/Po
src/PoFile.php
PoFile.dumpString
public function dumpString(): string { if ($this->header === null) { $this->header = new PoHeader; $this->header->buildDefaultHeader(); } $output = ''; $output .= $this->header->dumpEntry(); foreach ($this->entries as $entry) { $output .= $entry->dumpEntry(); } foreach ($this->unkeyedEntries as $entry) { $output .= $entry->dumpEntry(); } $output .= "\n"; return $output; }
php
public function dumpString(): string { if ($this->header === null) { $this->header = new PoHeader; $this->header->buildDefaultHeader(); } $output = ''; $output .= $this->header->dumpEntry(); foreach ($this->entries as $entry) { $output .= $entry->dumpEntry(); } foreach ($this->unkeyedEntries as $entry) { $output .= $entry->dumpEntry(); } $output .= "\n"; return $output; }
[ "public", "function", "dumpString", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "header", "===", "null", ")", "{", "$", "this", "->", "header", "=", "new", "PoHeader", ";", "$", "this", "->", "header", "->", "buildDefaultHeader", "(", ")", ";", "}", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "header", "->", "dumpEntry", "(", ")", ";", "foreach", "(", "$", "this", "->", "entries", "as", "$", "entry", ")", "{", "$", "output", ".=", "$", "entry", "->", "dumpEntry", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "unkeyedEntries", "as", "$", "entry", ")", "{", "$", "output", ".=", "$", "entry", "->", "dumpEntry", "(", ")", ";", "}", "$", "output", ".=", "\"\\n\"", ";", "return", "$", "output", ";", "}" ]
Dump the current contents in PO format to a string @return string
[ "Dump", "the", "current", "contents", "in", "PO", "format", "to", "a", "string" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoFile.php#L315-L333
19,852
geekwright/Po
src/PoFile.php
PoFile.readPoFile
public function readPoFile(string $file, ?resource $context = null): void { $oldEr = error_reporting(E_ALL ^ E_WARNING); $source = file_get_contents($file, false, $context); error_reporting($oldEr); if (false===$source) { throw new FileNotReadableException($file); } $this->parsePoSource($source); }
php
public function readPoFile(string $file, ?resource $context = null): void { $oldEr = error_reporting(E_ALL ^ E_WARNING); $source = file_get_contents($file, false, $context); error_reporting($oldEr); if (false===$source) { throw new FileNotReadableException($file); } $this->parsePoSource($source); }
[ "public", "function", "readPoFile", "(", "string", "$", "file", ",", "?", "resource", "$", "context", "=", "null", ")", ":", "void", "{", "$", "oldEr", "=", "error_reporting", "(", "E_ALL", "^", "E_WARNING", ")", ";", "$", "source", "=", "file_get_contents", "(", "$", "file", ",", "false", ",", "$", "context", ")", ";", "error_reporting", "(", "$", "oldEr", ")", ";", "if", "(", "false", "===", "$", "source", ")", "{", "throw", "new", "FileNotReadableException", "(", "$", "file", ")", ";", "}", "$", "this", "->", "parsePoSource", "(", "$", "source", ")", ";", "}" ]
Replace any current contents with entries from a file @param string $file po file/stream to read @param resource|null $context context for stream if required @return void @throws FileNotReadableException
[ "Replace", "any", "current", "contents", "with", "entries", "from", "a", "file" ]
9474d059a83b64e6242cc41e5c5b7a08bc57e4e2
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoFile.php#L346-L355
19,853
simple-php-mvc/simple-php-mvc
src/MVC/View.php
View.addTemplatePath
public function addTemplatePath($path) { if (is_array($this->templatesPath)) { if (array_search($path, $this->templatesPath)) { throw new \LogicException(sprintf('Templates path "%s" exists.', $path)); } else { $this->templatesPath[] = $path; } } else if (is_string($this->templatesPath)) { $lastTemplate = $this->templatesPath; $this->templatesPath = array( $lastTemplate, $path ); } }
php
public function addTemplatePath($path) { if (is_array($this->templatesPath)) { if (array_search($path, $this->templatesPath)) { throw new \LogicException(sprintf('Templates path "%s" exists.', $path)); } else { $this->templatesPath[] = $path; } } else if (is_string($this->templatesPath)) { $lastTemplate = $this->templatesPath; $this->templatesPath = array( $lastTemplate, $path ); } }
[ "public", "function", "addTemplatePath", "(", "$", "path", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "templatesPath", ")", ")", "{", "if", "(", "array_search", "(", "$", "path", ",", "$", "this", "->", "templatesPath", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Templates path \"%s\" exists.'", ",", "$", "path", ")", ")", ";", "}", "else", "{", "$", "this", "->", "templatesPath", "[", "]", "=", "$", "path", ";", "}", "}", "else", "if", "(", "is_string", "(", "$", "this", "->", "templatesPath", ")", ")", "{", "$", "lastTemplate", "=", "$", "this", "->", "templatesPath", ";", "$", "this", "->", "templatesPath", "=", "array", "(", "$", "lastTemplate", ",", "$", "path", ")", ";", "}", "}" ]
Add Template Path @param string $path Templates path
[ "Add", "Template", "Path" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/View.php#L26-L40
19,854
simple-php-mvc/simple-php-mvc
src/MVC/View.php
View.render
public function render($file, $vars = null) { $template = ''; if (is_null($this->templatesPath)) { throw new \LogicException('Variable "templatesPath" can\'t be NULL.'); } else if (is_string($this->templatesPath) && !file_exists($this->templatesPath)) { throw new \LogicException(sprintf('Folder "%s" don\'t exists.', $this->templatesPath)); } else if (is_array($this->templatesPath)) { foreach ($this->templatesPath as $folderPath) { if (file_exists($template = "$folderPath/{$file}")) { break; } } } if (!$template) { $template = "$this->templatesPath/{$file}"; } if(!file_exists($template)){ throw new \LogicException(sprintf('View "%s" don\'t exists.', $template)); } if (is_array($vars)) { extract($vars); foreach ($vars as $key => $value) { $key = $value; } } ob_start(); require $template; return ob_get_clean(); }
php
public function render($file, $vars = null) { $template = ''; if (is_null($this->templatesPath)) { throw new \LogicException('Variable "templatesPath" can\'t be NULL.'); } else if (is_string($this->templatesPath) && !file_exists($this->templatesPath)) { throw new \LogicException(sprintf('Folder "%s" don\'t exists.', $this->templatesPath)); } else if (is_array($this->templatesPath)) { foreach ($this->templatesPath as $folderPath) { if (file_exists($template = "$folderPath/{$file}")) { break; } } } if (!$template) { $template = "$this->templatesPath/{$file}"; } if(!file_exists($template)){ throw new \LogicException(sprintf('View "%s" don\'t exists.', $template)); } if (is_array($vars)) { extract($vars); foreach ($vars as $key => $value) { $key = $value; } } ob_start(); require $template; return ob_get_clean(); }
[ "public", "function", "render", "(", "$", "file", ",", "$", "vars", "=", "null", ")", "{", "$", "template", "=", "''", ";", "if", "(", "is_null", "(", "$", "this", "->", "templatesPath", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Variable \"templatesPath\" can\\'t be NULL.'", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "this", "->", "templatesPath", ")", "&&", "!", "file_exists", "(", "$", "this", "->", "templatesPath", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Folder \"%s\" don\\'t exists.'", ",", "$", "this", "->", "templatesPath", ")", ")", ";", "}", "else", "if", "(", "is_array", "(", "$", "this", "->", "templatesPath", ")", ")", "{", "foreach", "(", "$", "this", "->", "templatesPath", "as", "$", "folderPath", ")", "{", "if", "(", "file_exists", "(", "$", "template", "=", "\"$folderPath/{$file}\"", ")", ")", "{", "break", ";", "}", "}", "}", "if", "(", "!", "$", "template", ")", "{", "$", "template", "=", "\"$this->templatesPath/{$file}\"", ";", "}", "if", "(", "!", "file_exists", "(", "$", "template", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'View \"%s\" don\\'t exists.'", ",", "$", "template", ")", ")", ";", "}", "if", "(", "is_array", "(", "$", "vars", ")", ")", "{", "extract", "(", "$", "vars", ")", ";", "foreach", "(", "$", "vars", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "$", "value", ";", "}", "}", "ob_start", "(", ")", ";", "require", "$", "template", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
Renders a given file with the supplied variables. @access public @param string $file The file to be rendered. @param mixed $vars The variables to be substituted in the view. @return string @throws \LogicException
[ "Renders", "a", "given", "file", "with", "the", "supplied", "variables", "." ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/View.php#L76-L110
19,855
zodream/thirdparty
src/OAuth/PayPal.php
PayPal.setMode
public function setMode($arg) { $this->mode = strtolower($arg) == self::LIVE ? self::LIVE : self::SANDBOX; return $this; }
php
public function setMode($arg) { $this->mode = strtolower($arg) == self::LIVE ? self::LIVE : self::SANDBOX; return $this; }
[ "public", "function", "setMode", "(", "$", "arg", ")", "{", "$", "this", "->", "mode", "=", "strtolower", "(", "$", "arg", ")", "==", "self", "::", "LIVE", "?", "self", "::", "LIVE", ":", "self", "::", "SANDBOX", ";", "return", "$", "this", ";", "}" ]
IS TEST OR LIVE @param string $arg @return $this
[ "IS", "TEST", "OR", "LIVE" ]
b9d39087913850f1c5c7c9165105fec22a128f8f
https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/OAuth/PayPal.php#L95-L98
19,856
anime-db/app-bundle
src/Service/WidgetsContainer.php
WidgetsContainer.registr
public function registr($place, $controller) { if (preg_match('/^[a-z0-9]+:[a-z0-9]+:[_a-z0-9]+$/i', $controller)) { if (!isset($this->widgets[$place])) { $this->widgets[$place][] = $controller; } elseif (!in_array($controller, $this->widgets[$place])) { $this->widgets[$place][] = $controller; } return true; } return false; }
php
public function registr($place, $controller) { if (preg_match('/^[a-z0-9]+:[a-z0-9]+:[_a-z0-9]+$/i', $controller)) { if (!isset($this->widgets[$place])) { $this->widgets[$place][] = $controller; } elseif (!in_array($controller, $this->widgets[$place])) { $this->widgets[$place][] = $controller; } return true; } return false; }
[ "public", "function", "registr", "(", "$", "place", ",", "$", "controller", ")", "{", "if", "(", "preg_match", "(", "'/^[a-z0-9]+:[a-z0-9]+:[_a-z0-9]+$/i'", ",", "$", "controller", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "widgets", "[", "$", "place", "]", ")", ")", "{", "$", "this", "->", "widgets", "[", "$", "place", "]", "[", "]", "=", "$", "controller", ";", "}", "elseif", "(", "!", "in_array", "(", "$", "controller", ",", "$", "this", "->", "widgets", "[", "$", "place", "]", ")", ")", "{", "$", "this", "->", "widgets", "[", "$", "place", "]", "[", "]", "=", "$", "controller", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Regist widget. Controller example: AcmeDemoBundle:Welcome:index AcmeArticleBundle:Article:show @param string $place @param string $controller @return bool
[ "Regist", "widget", "." ]
ca3b342081719d41ba018792a75970cbb1f1fe22
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/WidgetsContainer.php#L60-L73
19,857
redaigbaria/oauth2
src/TokenType/MAC.php
MAC.hash_equals
private function hash_equals($knownString, $userString) { if (function_exists('\hash_equals')) { return \hash_equals($knownString, $userString); } if (strlen($knownString) !== strlen($userString)) { return false; } $len = strlen($knownString); $result = 0; for ($i = 0; $i < $len; $i++) { $result |= (ord($knownString[$i]) ^ ord($userString[$i])); } // They are only identical strings if $result is exactly 0... return 0 === $result; }
php
private function hash_equals($knownString, $userString) { if (function_exists('\hash_equals')) { return \hash_equals($knownString, $userString); } if (strlen($knownString) !== strlen($userString)) { return false; } $len = strlen($knownString); $result = 0; for ($i = 0; $i < $len; $i++) { $result |= (ord($knownString[$i]) ^ ord($userString[$i])); } // They are only identical strings if $result is exactly 0... return 0 === $result; }
[ "private", "function", "hash_equals", "(", "$", "knownString", ",", "$", "userString", ")", "{", "if", "(", "function_exists", "(", "'\\hash_equals'", ")", ")", "{", "return", "\\", "hash_equals", "(", "$", "knownString", ",", "$", "userString", ")", ";", "}", "if", "(", "strlen", "(", "$", "knownString", ")", "!==", "strlen", "(", "$", "userString", ")", ")", "{", "return", "false", ";", "}", "$", "len", "=", "strlen", "(", "$", "knownString", ")", ";", "$", "result", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "$", "result", "|=", "(", "ord", "(", "$", "knownString", "[", "$", "i", "]", ")", "^", "ord", "(", "$", "userString", "[", "$", "i", "]", ")", ")", ";", "}", "// They are only identical strings if $result is exactly 0...", "return", "0", "===", "$", "result", ";", "}" ]
Prevent timing attack @param string $knownString @param string $userString @return bool
[ "Prevent", "timing", "attack" ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/TokenType/MAC.php#L140-L155
19,858
aedart/config-loader
src/Traits/ParserFactoryTrait.php
ParserFactoryTrait.getParserFactory
public function getParserFactory(): ?ParserFactory { if (!$this->hasParserFactory()) { $this->setParserFactory($this->getDefaultParserFactory()); } return $this->parserFactory; }
php
public function getParserFactory(): ?ParserFactory { if (!$this->hasParserFactory()) { $this->setParserFactory($this->getDefaultParserFactory()); } return $this->parserFactory; }
[ "public", "function", "getParserFactory", "(", ")", ":", "?", "ParserFactory", "{", "if", "(", "!", "$", "this", "->", "hasParserFactory", "(", ")", ")", "{", "$", "this", "->", "setParserFactory", "(", "$", "this", "->", "getDefaultParserFactory", "(", ")", ")", ";", "}", "return", "$", "this", "->", "parserFactory", ";", "}" ]
Get parser factory If no parser factory has been set, this method will set and return a default parser factory, if any such value is available @see getDefaultParserFactory() @return ParserFactory|null parser factory or null if none parser factory has been set
[ "Get", "parser", "factory" ]
9e1cf592bee46ba4930bb9c352aaf475d81266ea
https://github.com/aedart/config-loader/blob/9e1cf592bee46ba4930bb9c352aaf475d81266ea/src/Traits/ParserFactoryTrait.php#L53-L59
19,859
CakeCMS/Core
src/View/Helper/FilterHelper.php
FilterHelper.render
public function render($model, array $fields = [], $element = self::DEFAULT_ELEMENT, array $data = []) { $data = Hash::merge([ 'clearUrl' => [], 'model' => $model, 'formFields' => $fields, ], $data); return $this->_View->element($element, $data); }
php
public function render($model, array $fields = [], $element = self::DEFAULT_ELEMENT, array $data = []) { $data = Hash::merge([ 'clearUrl' => [], 'model' => $model, 'formFields' => $fields, ], $data); return $this->_View->element($element, $data); }
[ "public", "function", "render", "(", "$", "model", ",", "array", "$", "fields", "=", "[", "]", ",", "$", "element", "=", "self", "::", "DEFAULT_ELEMENT", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "data", "=", "Hash", "::", "merge", "(", "[", "'clearUrl'", "=>", "[", "]", ",", "'model'", "=>", "$", "model", ",", "'formFields'", "=>", "$", "fields", ",", "]", ",", "$", "data", ")", ";", "return", "$", "this", "->", "_View", "->", "element", "(", "$", "element", ",", "$", "data", ")", ";", "}" ]
Render filter element. @param string $model @param array $fields @param string $element @param array $data @return string
[ "Render", "filter", "element", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/FilterHelper.php#L39-L48
19,860
qcubed/orm
src/Database/Mysqli5/Database.php
Database.executeProcedure
public function executeProcedure($strProcName, $params = null) { $strParams = ''; if ($params) { $a = array_map(function ($val) { return $this->sqlVariable($val); }, $params); $strParams = implode(',', $a); } $strSql = "call {$strProcName}({$strParams})"; return $this->multiQuery($strSql); }
php
public function executeProcedure($strProcName, $params = null) { $strParams = ''; if ($params) { $a = array_map(function ($val) { return $this->sqlVariable($val); }, $params); $strParams = implode(',', $a); } $strSql = "call {$strProcName}({$strParams})"; return $this->multiQuery($strSql); }
[ "public", "function", "executeProcedure", "(", "$", "strProcName", ",", "$", "params", "=", "null", ")", "{", "$", "strParams", "=", "''", ";", "if", "(", "$", "params", ")", "{", "$", "a", "=", "array_map", "(", "function", "(", "$", "val", ")", "{", "return", "$", "this", "->", "sqlVariable", "(", "$", "val", ")", ";", "}", ",", "$", "params", ")", ";", "$", "strParams", "=", "implode", "(", "','", ",", "$", "a", ")", ";", "}", "$", "strSql", "=", "\"call {$strProcName}({$strParams})\"", ";", "return", "$", "this", "->", "multiQuery", "(", "$", "strSql", ")", ";", "}" ]
Generic stored procedure executor. For Mysql 5, you can have your stored procedure return results by "SELECT"ing the results. The results will be returned as an array. @param string $strProcName Name of stored procedure @param array|null $params @return Result[] @throws MysqliException
[ "Generic", "stored", "procedure", "executor", ".", "For", "Mysql", "5", "you", "can", "have", "your", "stored", "procedure", "return", "results", "by", "SELECT", "ing", "the", "results", ".", "The", "results", "will", "be", "returned", "as", "an", "array", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/Mysqli5/Database.php#L122-L133
19,861
spiral-modules/scaffolder
source/Scaffolder/Declarations/EntityDeclaration.php
EntityDeclaration.addField
public function addField(string $name, $value) { $schema = $this->constant('SCHEMA')->getValue(); $schema[$name] = $value; $this->constant('SCHEMA')->setValue($schema); }
php
public function addField(string $name, $value) { $schema = $this->constant('SCHEMA')->getValue(); $schema[$name] = $value; $this->constant('SCHEMA')->setValue($schema); }
[ "public", "function", "addField", "(", "string", "$", "name", ",", "$", "value", ")", "{", "$", "schema", "=", "$", "this", "->", "constant", "(", "'SCHEMA'", ")", "->", "getValue", "(", ")", ";", "$", "schema", "[", "$", "name", "]", "=", "$", "value", ";", "$", "this", "->", "constant", "(", "'SCHEMA'", ")", "->", "setValue", "(", "$", "schema", ")", ";", "}" ]
Add field into schema. @param string $name @param mixed $value
[ "Add", "field", "into", "schema", "." ]
9be9dd0da6e4b02232db24e797fe5c288afbbddf
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Declarations/EntityDeclaration.php#L44-L49
19,862
parsnick/steak
src/Boot/RunBootstrapsFromConfig.php
RunBootstrapsFromConfig.boot
public function boot(Container $app) { $toBoot = (array) $app['config']->get('bootstrap', []); foreach ($toBoot as $bootstrapClass) { $app->make($bootstrapClass)->boot($app); } }
php
public function boot(Container $app) { $toBoot = (array) $app['config']->get('bootstrap', []); foreach ($toBoot as $bootstrapClass) { $app->make($bootstrapClass)->boot($app); } }
[ "public", "function", "boot", "(", "Container", "$", "app", ")", "{", "$", "toBoot", "=", "(", "array", ")", "$", "app", "[", "'config'", "]", "->", "get", "(", "'bootstrap'", ",", "[", "]", ")", ";", "foreach", "(", "$", "toBoot", "as", "$", "bootstrapClass", ")", "{", "$", "app", "->", "make", "(", "$", "bootstrapClass", ")", "->", "boot", "(", "$", "app", ")", ";", "}", "}" ]
Call any other bootstraps defined by config. @param Container $app
[ "Call", "any", "other", "bootstraps", "defined", "by", "config", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Boot/RunBootstrapsFromConfig.php#L14-L21
19,863
picamator/CacheManager
src/ObjectManager.php
ObjectManager.getReflection
private function getReflection(string $className) : \ReflectionClass { if (empty($this->reflectionContainer[$className])) { $this->reflectionContainer[$className] = new \ReflectionClass($className); } return $this->reflectionContainer[$className]; }
php
private function getReflection(string $className) : \ReflectionClass { if (empty($this->reflectionContainer[$className])) { $this->reflectionContainer[$className] = new \ReflectionClass($className); } return $this->reflectionContainer[$className]; }
[ "private", "function", "getReflection", "(", "string", "$", "className", ")", ":", "\\", "ReflectionClass", "{", "if", "(", "empty", "(", "$", "this", "->", "reflectionContainer", "[", "$", "className", "]", ")", ")", "{", "$", "this", "->", "reflectionContainer", "[", "$", "className", "]", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "}", "return", "$", "this", "->", "reflectionContainer", "[", "$", "className", "]", ";", "}" ]
Retrieve reflection. @param string $className @return \ReflectionClass
[ "Retrieve", "reflection", "." ]
5e5493910610b65ae31a362786d7963ba3e33806
https://github.com/picamator/CacheManager/blob/5e5493910610b65ae31a362786d7963ba3e33806/src/ObjectManager.php#L47-L54
19,864
steeffeen/FancyManiaLinks
FML/Elements/Dico.php
Dico.getEntry
public function getEntry($language, $entryId) { if (isset($this->entries[$language]) && isset($this->entries[$language][$entryId])) { return $this->entries[$language][$entryId]; } return null; }
php
public function getEntry($language, $entryId) { if (isset($this->entries[$language]) && isset($this->entries[$language][$entryId])) { return $this->entries[$language][$entryId]; } return null; }
[ "public", "function", "getEntry", "(", "$", "language", ",", "$", "entryId", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "entries", "[", "$", "language", "]", ")", "&&", "isset", "(", "$", "this", "->", "entries", "[", "$", "language", "]", "[", "$", "entryId", "]", ")", ")", "{", "return", "$", "this", "->", "entries", "[", "$", "language", "]", "[", "$", "entryId", "]", ";", "}", "return", "null", ";", "}" ]
Get the translatable entry @api @param string $language Language id @param string $entryId Entry id @return string
[ "Get", "the", "translatable", "entry" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Elements/Dico.php#L179-L185
19,865
steeffeen/FancyManiaLinks
FML/Elements/Dico.php
Dico.setEntry
public function setEntry($language, $entryId, $entryValue) { $language = (string)$language; $entryId = (string)$entryId; $entryValue = (string)$entryValue; if (!isset($this->entries[$language]) && $entryValue) { $this->entries[$language] = array(); } if ($entryValue) { $this->entries[$language][$entryId] = $entryValue; } else { if (isset($this->entries[$language][$entryId])) { unset($this->entries[$language][$entryId]); } } return $this; }
php
public function setEntry($language, $entryId, $entryValue) { $language = (string)$language; $entryId = (string)$entryId; $entryValue = (string)$entryValue; if (!isset($this->entries[$language]) && $entryValue) { $this->entries[$language] = array(); } if ($entryValue) { $this->entries[$language][$entryId] = $entryValue; } else { if (isset($this->entries[$language][$entryId])) { unset($this->entries[$language][$entryId]); } } return $this; }
[ "public", "function", "setEntry", "(", "$", "language", ",", "$", "entryId", ",", "$", "entryValue", ")", "{", "$", "language", "=", "(", "string", ")", "$", "language", ";", "$", "entryId", "=", "(", "string", ")", "$", "entryId", ";", "$", "entryValue", "=", "(", "string", ")", "$", "entryValue", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "entries", "[", "$", "language", "]", ")", "&&", "$", "entryValue", ")", "{", "$", "this", "->", "entries", "[", "$", "language", "]", "=", "array", "(", ")", ";", "}", "if", "(", "$", "entryValue", ")", "{", "$", "this", "->", "entries", "[", "$", "language", "]", "[", "$", "entryId", "]", "=", "$", "entryValue", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "this", "->", "entries", "[", "$", "language", "]", "[", "$", "entryId", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "entries", "[", "$", "language", "]", "[", "$", "entryId", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set the translatable entry for the specific language @api @param string $language Language id @param string $entryId Entry id @param string $entryValue Translated entry value @return static
[ "Set", "the", "translatable", "entry", "for", "the", "specific", "language" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Elements/Dico.php#L196-L212
19,866
steeffeen/FancyManiaLinks
FML/Elements/Dico.php
Dico.removeEntry
public function removeEntry($entryId, $language = null) { $entryId = (string)$entryId; foreach ($this->entries as $languageKey => $entries) { if ($language && $language !== $languageKey) { continue; } if (isset($this->entries[$languageKey][$entryId])) { unset($this->entries[$languageKey][$entryId]); } } return $this; }
php
public function removeEntry($entryId, $language = null) { $entryId = (string)$entryId; foreach ($this->entries as $languageKey => $entries) { if ($language && $language !== $languageKey) { continue; } if (isset($this->entries[$languageKey][$entryId])) { unset($this->entries[$languageKey][$entryId]); } } return $this; }
[ "public", "function", "removeEntry", "(", "$", "entryId", ",", "$", "language", "=", "null", ")", "{", "$", "entryId", "=", "(", "string", ")", "$", "entryId", ";", "foreach", "(", "$", "this", "->", "entries", "as", "$", "languageKey", "=>", "$", "entries", ")", "{", "if", "(", "$", "language", "&&", "$", "language", "!==", "$", "languageKey", ")", "{", "continue", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "entries", "[", "$", "languageKey", "]", "[", "$", "entryId", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "entries", "[", "$", "languageKey", "]", "[", "$", "entryId", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Remove entries of the given id @api @param string $entryId Entry id that should be removed @param string $language (optional) Only remove entry from the given language @return static
[ "Remove", "entries", "of", "the", "given", "id" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Elements/Dico.php#L222-L234
19,867
steeffeen/FancyManiaLinks
FML/Elements/Dico.php
Dico.removeLanguage
public function removeLanguage($language) { $language = (string)$language; if (isset($this->entries[$language])) { unset($this->entries[$language]); } return $this; }
php
public function removeLanguage($language) { $language = (string)$language; if (isset($this->entries[$language])) { unset($this->entries[$language]); } return $this; }
[ "public", "function", "removeLanguage", "(", "$", "language", ")", "{", "$", "language", "=", "(", "string", ")", "$", "language", ";", "if", "(", "isset", "(", "$", "this", "->", "entries", "[", "$", "language", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "entries", "[", "$", "language", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove entries of the given language @api @param string $language Language which entries should be removed @return static
[ "Remove", "entries", "of", "the", "given", "language" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Elements/Dico.php#L243-L250
19,868
steeffeen/FancyManiaLinks
FML/Elements/Dico.php
Dico.render
public function render(\DOMDocument $domDocument) { $domElement = $domDocument->createElement("dico"); foreach ($this->entries as $language => $entries) { $languageElement = $domDocument->createElement("language"); $languageElement->setAttribute("id", $language); foreach ($entries as $entryId => $entryValue) { $entryElement = $domDocument->createElement($entryId, $entryValue); $languageElement->appendChild($entryElement); } $domElement->appendChild($languageElement); } return $domElement; }
php
public function render(\DOMDocument $domDocument) { $domElement = $domDocument->createElement("dico"); foreach ($this->entries as $language => $entries) { $languageElement = $domDocument->createElement("language"); $languageElement->setAttribute("id", $language); foreach ($entries as $entryId => $entryValue) { $entryElement = $domDocument->createElement($entryId, $entryValue); $languageElement->appendChild($entryElement); } $domElement->appendChild($languageElement); } return $domElement; }
[ "public", "function", "render", "(", "\\", "DOMDocument", "$", "domDocument", ")", "{", "$", "domElement", "=", "$", "domDocument", "->", "createElement", "(", "\"dico\"", ")", ";", "foreach", "(", "$", "this", "->", "entries", "as", "$", "language", "=>", "$", "entries", ")", "{", "$", "languageElement", "=", "$", "domDocument", "->", "createElement", "(", "\"language\"", ")", ";", "$", "languageElement", "->", "setAttribute", "(", "\"id\"", ",", "$", "language", ")", ";", "foreach", "(", "$", "entries", "as", "$", "entryId", "=>", "$", "entryValue", ")", "{", "$", "entryElement", "=", "$", "domDocument", "->", "createElement", "(", "$", "entryId", ",", "$", "entryValue", ")", ";", "$", "languageElement", "->", "appendChild", "(", "$", "entryElement", ")", ";", "}", "$", "domElement", "->", "appendChild", "(", "$", "languageElement", ")", ";", "}", "return", "$", "domElement", ";", "}" ]
Render the Dico @param \DOMDocument $domDocument DOMDocument for which the Dico should be rendered @return \DOMElement
[ "Render", "the", "Dico" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Elements/Dico.php#L283-L296
19,869
gries/rcon
src/ConnectionFactory.php
ConnectionFactory.create
public static function create($host, $port, $password) { $factory = new \Socket\Raw\Factory(); $socket = $factory->createClient(sprintf('%s:%s', $host, $port)); return new \gries\Rcon\Connection($socket, $password); }
php
public static function create($host, $port, $password) { $factory = new \Socket\Raw\Factory(); $socket = $factory->createClient(sprintf('%s:%s', $host, $port)); return new \gries\Rcon\Connection($socket, $password); }
[ "public", "static", "function", "create", "(", "$", "host", ",", "$", "port", ",", "$", "password", ")", "{", "$", "factory", "=", "new", "\\", "Socket", "\\", "Raw", "\\", "Factory", "(", ")", ";", "$", "socket", "=", "$", "factory", "->", "createClient", "(", "sprintf", "(", "'%s:%s'", ",", "$", "host", ",", "$", "port", ")", ")", ";", "return", "new", "\\", "gries", "\\", "Rcon", "\\", "Connection", "(", "$", "socket", ",", "$", "password", ")", ";", "}" ]
Create a new RconConnection @param $host @param $port @param $password @return \gries\Rcon\Connection
[ "Create", "a", "new", "RconConnection" ]
7fada05b329d89542692af00ab80db02ad59d45d
https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/ConnectionFactory.php#L21-L27
19,870
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaConnect/Client.php
Client.getLoginURL
function getLoginURL($scope = null, $redirectURI = null) { $redirectURI = $redirectURI ? : $this->getCurrentURI(); self::$persistance->setVariable('redirect_uri', $redirectURI); return $this->getAuthorizationURL($redirectURI, $scope); }
php
function getLoginURL($scope = null, $redirectURI = null) { $redirectURI = $redirectURI ? : $this->getCurrentURI(); self::$persistance->setVariable('redirect_uri', $redirectURI); return $this->getAuthorizationURL($redirectURI, $scope); }
[ "function", "getLoginURL", "(", "$", "scope", "=", "null", ",", "$", "redirectURI", "=", "null", ")", "{", "$", "redirectURI", "=", "$", "redirectURI", "?", ":", "$", "this", "->", "getCurrentURI", "(", ")", ";", "self", "::", "$", "persistance", "->", "setVariable", "(", "'redirect_uri'", ",", "$", "redirectURI", ")", ";", "return", "$", "this", "->", "getAuthorizationURL", "(", "$", "redirectURI", ",", "$", "scope", ")", ";", "}" ]
When a user is not authentified, you need to create a link to the URL returned by this method. @param string $scope Space-separated list of scopes. Leave empty if you just need the basic one @param string $redirectURI Where to redirect the user after auth. Leave empty for the current URI @return string Login URL
[ "When", "a", "user", "is", "not", "authentified", "you", "need", "to", "create", "a", "link", "to", "the", "URL", "returned", "by", "this", "method", "." ]
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaConnect/Client.php#L72-L77
19,871
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaConnect/Client.php
Client.getLogoutURL
function getLogoutURL($redirectURI = null) { $redirectURI = $redirectURI ? : $this->getCurrentURI(); return $this->logoutURL.'?'.http_build_query(array('redirect_uri' => $redirectURI), '', '&'); }
php
function getLogoutURL($redirectURI = null) { $redirectURI = $redirectURI ? : $this->getCurrentURI(); return $this->logoutURL.'?'.http_build_query(array('redirect_uri' => $redirectURI), '', '&'); }
[ "function", "getLogoutURL", "(", "$", "redirectURI", "=", "null", ")", "{", "$", "redirectURI", "=", "$", "redirectURI", "?", ":", "$", "this", "->", "getCurrentURI", "(", ")", ";", "return", "$", "this", "->", "logoutURL", ".", "'?'", ".", "http_build_query", "(", "array", "(", "'redirect_uri'", "=>", "$", "redirectURI", ")", ",", "''", ",", "'&'", ")", ";", "}" ]
If you want to place a "logout" button, you can use this link to log the user out of the player page too. Don't forget to empty your sessions . @see \Maniaplanet\WebServices\ManiaConnect\Client::logout() @param string $redirectURI Where to redirect the user after he logged out. Leave empty for current URI @return string Logout URL
[ "If", "you", "want", "to", "place", "a", "logout", "button", "you", "can", "use", "this", "link", "to", "log", "the", "user", "out", "of", "the", "player", "page", "too", ".", "Don", "t", "forget", "to", "empty", "your", "sessions", "." ]
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaConnect/Client.php#L87-L92
19,872
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaConnect/Client.php
Client.getAccessToken
protected function getAccessToken() { $token = self::$persistance->getVariable('token'); if(!$this->isAccessTokenExpired($token)) { return $token->access_token; } else if ($token !== null && $token->refresh_token !== null) { $token = $this->getTokenFromRefreshToken($token->refresh_token); return $token->access_token; } if(isset($_REQUEST['code'])) { $code = $_REQUEST['code']; if($code) { $redirectURI = self::$persistance->getVariable('redirect_uri') ? : $this->getCurrentURI(); $token = $this->getTokenFromCode($code, $redirectURI); self::$persistance->deleteVariable('redirect_uri'); self::$persistance->deleteVariable('code'); return $token->access_token; } } }
php
protected function getAccessToken() { $token = self::$persistance->getVariable('token'); if(!$this->isAccessTokenExpired($token)) { return $token->access_token; } else if ($token !== null && $token->refresh_token !== null) { $token = $this->getTokenFromRefreshToken($token->refresh_token); return $token->access_token; } if(isset($_REQUEST['code'])) { $code = $_REQUEST['code']; if($code) { $redirectURI = self::$persistance->getVariable('redirect_uri') ? : $this->getCurrentURI(); $token = $this->getTokenFromCode($code, $redirectURI); self::$persistance->deleteVariable('redirect_uri'); self::$persistance->deleteVariable('code'); return $token->access_token; } } }
[ "protected", "function", "getAccessToken", "(", ")", "{", "$", "token", "=", "self", "::", "$", "persistance", "->", "getVariable", "(", "'token'", ")", ";", "if", "(", "!", "$", "this", "->", "isAccessTokenExpired", "(", "$", "token", ")", ")", "{", "return", "$", "token", "->", "access_token", ";", "}", "else", "if", "(", "$", "token", "!==", "null", "&&", "$", "token", "->", "refresh_token", "!==", "null", ")", "{", "$", "token", "=", "$", "this", "->", "getTokenFromRefreshToken", "(", "$", "token", "->", "refresh_token", ")", ";", "return", "$", "token", "->", "access_token", ";", "}", "if", "(", "isset", "(", "$", "_REQUEST", "[", "'code'", "]", ")", ")", "{", "$", "code", "=", "$", "_REQUEST", "[", "'code'", "]", ";", "if", "(", "$", "code", ")", "{", "$", "redirectURI", "=", "self", "::", "$", "persistance", "->", "getVariable", "(", "'redirect_uri'", ")", "?", ":", "$", "this", "->", "getCurrentURI", "(", ")", ";", "$", "token", "=", "$", "this", "->", "getTokenFromCode", "(", "$", "code", ",", "$", "redirectURI", ")", ";", "self", "::", "$", "persistance", "->", "deleteVariable", "(", "'redirect_uri'", ")", ";", "self", "::", "$", "persistance", "->", "deleteVariable", "(", "'code'", ")", ";", "return", "$", "token", "->", "access_token", ";", "}", "}", "}" ]
Tries to get an access token. If one is found in the session, it returns it. If a code is found in the request, it tries to exchange it for an access token on the OAuth2 Token Endpoint Else it returns false @return string An OAuth2 access token, or false if none is found
[ "Tries", "to", "get", "an", "access", "token", ".", "If", "one", "is", "found", "in", "the", "session", "it", "returns", "it", ".", "If", "a", "code", "is", "found", "in", "the", "request", "it", "tries", "to", "exchange", "it", "for", "an", "access", "token", "on", "the", "OAuth2", "Token", "Endpoint", "Else", "it", "returns", "false" ]
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaConnect/Client.php#L193-L221
19,873
digitalkaoz/versioneye-php
src/Output/Projects.php
Projects.all
public function all(OutputInterface $output, array $response) { $this->printTable($output, ['Key', 'Name', 'Type', 'Public', 'Dependencies', 'Outdated', 'Updated At', 'Bad Licenses', 'Unknown Licenses'], ['ids', 'name', 'project_type', 'public', 'dep_number', 'out_number', 'updated_at', 'licenses_red', 'licenses_unknown'], $response, function ($key, $value) use ($output) { if ('public' === $key) { return $value === 1 ? 'Yes' : 'No'; } if (!in_array($key, ['out_number', 'licenses_red', 'licenses_unknown'], true)) { return $value; } return $this->printBoolean($output, $value > 0 ? $value : 'No', $value, !$value, false); } ); }
php
public function all(OutputInterface $output, array $response) { $this->printTable($output, ['Key', 'Name', 'Type', 'Public', 'Dependencies', 'Outdated', 'Updated At', 'Bad Licenses', 'Unknown Licenses'], ['ids', 'name', 'project_type', 'public', 'dep_number', 'out_number', 'updated_at', 'licenses_red', 'licenses_unknown'], $response, function ($key, $value) use ($output) { if ('public' === $key) { return $value === 1 ? 'Yes' : 'No'; } if (!in_array($key, ['out_number', 'licenses_red', 'licenses_unknown'], true)) { return $value; } return $this->printBoolean($output, $value > 0 ? $value : 'No', $value, !$value, false); } ); }
[ "public", "function", "all", "(", "OutputInterface", "$", "output", ",", "array", "$", "response", ")", "{", "$", "this", "->", "printTable", "(", "$", "output", ",", "[", "'Key'", ",", "'Name'", ",", "'Type'", ",", "'Public'", ",", "'Dependencies'", ",", "'Outdated'", ",", "'Updated At'", ",", "'Bad Licenses'", ",", "'Unknown Licenses'", "]", ",", "[", "'ids'", ",", "'name'", ",", "'project_type'", ",", "'public'", ",", "'dep_number'", ",", "'out_number'", ",", "'updated_at'", ",", "'licenses_red'", ",", "'licenses_unknown'", "]", ",", "$", "response", ",", "function", "(", "$", "key", ",", "$", "value", ")", "use", "(", "$", "output", ")", "{", "if", "(", "'public'", "===", "$", "key", ")", "{", "return", "$", "value", "===", "1", "?", "'Yes'", ":", "'No'", ";", "}", "if", "(", "!", "in_array", "(", "$", "key", ",", "[", "'out_number'", ",", "'licenses_red'", ",", "'licenses_unknown'", "]", ",", "true", ")", ")", "{", "return", "$", "value", ";", "}", "return", "$", "this", "->", "printBoolean", "(", "$", "output", ",", "$", "value", ">", "0", "?", "$", "value", ":", "'No'", ",", "$", "value", ",", "!", "$", "value", ",", "false", ")", ";", "}", ")", ";", "}" ]
output for projects API. @param OutputInterface $output @param array $response
[ "output", "for", "projects", "API", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Projects.php#L20-L38
19,874
digitalkaoz/versioneye-php
src/Output/Projects.php
Projects.licenses
public function licenses(OutputInterface $output, array $response) { $table = $this->createTable($output); $table->setHeaders(['license', 'name']); foreach ($response['licenses'] as $license => $projects) { foreach ($projects as $project) { $name = $license === 'unknown' ? '<error>' . $project['name'] . '</error>' : $project['name']; $license = $license === 'unknown' ? '<error>unknown</error>' : $license; $table->addRow([$license, $name]); } } $table->render($output); }
php
public function licenses(OutputInterface $output, array $response) { $table = $this->createTable($output); $table->setHeaders(['license', 'name']); foreach ($response['licenses'] as $license => $projects) { foreach ($projects as $project) { $name = $license === 'unknown' ? '<error>' . $project['name'] . '</error>' : $project['name']; $license = $license === 'unknown' ? '<error>unknown</error>' : $license; $table->addRow([$license, $name]); } } $table->render($output); }
[ "public", "function", "licenses", "(", "OutputInterface", "$", "output", ",", "array", "$", "response", ")", "{", "$", "table", "=", "$", "this", "->", "createTable", "(", "$", "output", ")", ";", "$", "table", "->", "setHeaders", "(", "[", "'license'", ",", "'name'", "]", ")", ";", "foreach", "(", "$", "response", "[", "'licenses'", "]", "as", "$", "license", "=>", "$", "projects", ")", "{", "foreach", "(", "$", "projects", "as", "$", "project", ")", "{", "$", "name", "=", "$", "license", "===", "'unknown'", "?", "'<error>'", ".", "$", "project", "[", "'name'", "]", ".", "'</error>'", ":", "$", "project", "[", "'name'", "]", ";", "$", "license", "=", "$", "license", "===", "'unknown'", "?", "'<error>unknown</error>'", ":", "$", "license", ";", "$", "table", "->", "addRow", "(", "[", "$", "license", ",", "$", "name", "]", ")", ";", "}", "}", "$", "table", "->", "render", "(", "$", "output", ")", ";", "}" ]
output for licenses API. @param OutputInterface $output @param array $response
[ "output", "for", "licenses", "API", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Output/Projects.php#L46-L61
19,875
sebastiaanluca/laravel-unbreakable-migrations
src/TransactionalMigration.php
TransactionalMigration.executeInTransaction
protected function executeInTransaction(string $method) : void { try { $this->database->beginTransaction(); $this->{$method}(); $this->database->commit(); } catch (Exception $exception) { $this->database->rollBack(); $this->handleException($exception); } }
php
protected function executeInTransaction(string $method) : void { try { $this->database->beginTransaction(); $this->{$method}(); $this->database->commit(); } catch (Exception $exception) { $this->database->rollBack(); $this->handleException($exception); } }
[ "protected", "function", "executeInTransaction", "(", "string", "$", "method", ")", ":", "void", "{", "try", "{", "$", "this", "->", "database", "->", "beginTransaction", "(", ")", ";", "$", "this", "->", "{", "$", "method", "}", "(", ")", ";", "$", "this", "->", "database", "->", "commit", "(", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "this", "->", "database", "->", "rollBack", "(", ")", ";", "$", "this", "->", "handleException", "(", "$", "exception", ")", ";", "}", "}" ]
Execute the migration command inside a transaction layer. @param string $method @return void
[ "Execute", "the", "migration", "command", "inside", "a", "transaction", "layer", "." ]
3c831b204770b80c97351c3b881dcbf924236a13
https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/TransactionalMigration.php#L38-L51
19,876
datasift/php_webdriver
src/php/DataSift/WebDriver/WebDriverContainer.php
WebDriverContainer.getElement
public function getElement($using, $value) { // try to get the requested element from the open session try { $results = $this->curl( 'POST', '/element', array( 'using' => $using, 'value' => $value ) ); } catch (E5xx_NoSuchElementWebDriverError $e) { // the element does not exist throw new E5xx_NoSuchElementWebDriverError( 500, sprintf( 'Element not found with %s, %s', $using, $value ) . "\n\n" . $e->getMessage(), $e->getResults() ); } // if we get here, then we can return the element back to the // caller :) return $this->newWebDriverElement($results['value']); }
php
public function getElement($using, $value) { // try to get the requested element from the open session try { $results = $this->curl( 'POST', '/element', array( 'using' => $using, 'value' => $value ) ); } catch (E5xx_NoSuchElementWebDriverError $e) { // the element does not exist throw new E5xx_NoSuchElementWebDriverError( 500, sprintf( 'Element not found with %s, %s', $using, $value ) . "\n\n" . $e->getMessage(), $e->getResults() ); } // if we get here, then we can return the element back to the // caller :) return $this->newWebDriverElement($results['value']); }
[ "public", "function", "getElement", "(", "$", "using", ",", "$", "value", ")", "{", "// try to get the requested element from the open session", "try", "{", "$", "results", "=", "$", "this", "->", "curl", "(", "'POST'", ",", "'/element'", ",", "array", "(", "'using'", "=>", "$", "using", ",", "'value'", "=>", "$", "value", ")", ")", ";", "}", "catch", "(", "E5xx_NoSuchElementWebDriverError", "$", "e", ")", "{", "// the element does not exist", "throw", "new", "E5xx_NoSuchElementWebDriverError", "(", "500", ",", "sprintf", "(", "'Element not found with %s, %s'", ",", "$", "using", ",", "$", "value", ")", ".", "\"\\n\\n\"", ".", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getResults", "(", ")", ")", ";", "}", "// if we get here, then we can return the element back to the", "// caller :)", "return", "$", "this", "->", "newWebDriverElement", "(", "$", "results", "[", "'value'", "]", ")", ";", "}" ]
retrieve an element from the currently loaded page @param string $using the search strategy @param string $value the term to search for @return WebDriverElement the element that has been searched for
[ "retrieve", "an", "element", "from", "the", "currently", "loaded", "page" ]
efca991198616b53c8f40b59ad05306e2b10e7f0
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/WebDriver/WebDriverContainer.php#L51-L80
19,877
datasift/php_webdriver
src/php/DataSift/WebDriver/WebDriverContainer.php
WebDriverContainer.getElements
public function getElements($using, $value) { try { $results = $this->curl( 'POST', '/elements', array( 'using' => $using, 'value' => $value ) ); } catch (E5xx_NoSuchElementWebDriverError $e) { // the element does not exist throw new E5xx_NoSuchElementWebDriverError( sprintf( 'Element not found with %s, %s', $using, $value ) . "\n\n" . $e->getMessage(), $e->getResults() ); } // if we get here, then we can return the set of elements back // to the caller :) // if (!(is_array($results['value']))) // { // var_dump($results); // } return array_filter(array_map( array($this, 'newWebDriverElement'), $results['value']) ); }
php
public function getElements($using, $value) { try { $results = $this->curl( 'POST', '/elements', array( 'using' => $using, 'value' => $value ) ); } catch (E5xx_NoSuchElementWebDriverError $e) { // the element does not exist throw new E5xx_NoSuchElementWebDriverError( sprintf( 'Element not found with %s, %s', $using, $value ) . "\n\n" . $e->getMessage(), $e->getResults() ); } // if we get here, then we can return the set of elements back // to the caller :) // if (!(is_array($results['value']))) // { // var_dump($results); // } return array_filter(array_map( array($this, 'newWebDriverElement'), $results['value']) ); }
[ "public", "function", "getElements", "(", "$", "using", ",", "$", "value", ")", "{", "try", "{", "$", "results", "=", "$", "this", "->", "curl", "(", "'POST'", ",", "'/elements'", ",", "array", "(", "'using'", "=>", "$", "using", ",", "'value'", "=>", "$", "value", ")", ")", ";", "}", "catch", "(", "E5xx_NoSuchElementWebDriverError", "$", "e", ")", "{", "// the element does not exist", "throw", "new", "E5xx_NoSuchElementWebDriverError", "(", "sprintf", "(", "'Element not found with %s, %s'", ",", "$", "using", ",", "$", "value", ")", ".", "\"\\n\\n\"", ".", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getResults", "(", ")", ")", ";", "}", "// if we get here, then we can return the set of elements back", "// to the caller :)", "// if (!(is_array($results['value'])))", "// {", "// var_dump($results);", "// }", "return", "array_filter", "(", "array_map", "(", "array", "(", "$", "this", ",", "'newWebDriverElement'", ")", ",", "$", "results", "[", "'value'", "]", ")", ")", ";", "}" ]
Find all occurances of an element on the current page @param string $using the search strategy @param string $value the term to search for @return array(WebDriverElement)
[ "Find", "all", "occurances", "of", "an", "element", "on", "the", "current", "page" ]
efca991198616b53c8f40b59ad05306e2b10e7f0
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/WebDriver/WebDriverContainer.php#L90-L125
19,878
datasift/php_webdriver
src/php/DataSift/WebDriver/WebDriverContainer.php
WebDriverContainer.newWebDriverElement
protected function newWebDriverElement($value) { // is the returned element in the format we expect? if (!array_key_exists('ELEMENT', (array) $value)) { // no, it is not return null; } return new WebDriverElement( $this->getElementPath($value['ELEMENT']), // url $value['ELEMENT'] // id ); }
php
protected function newWebDriverElement($value) { // is the returned element in the format we expect? if (!array_key_exists('ELEMENT', (array) $value)) { // no, it is not return null; } return new WebDriverElement( $this->getElementPath($value['ELEMENT']), // url $value['ELEMENT'] // id ); }
[ "protected", "function", "newWebDriverElement", "(", "$", "value", ")", "{", "// is the returned element in the format we expect?", "if", "(", "!", "array_key_exists", "(", "'ELEMENT'", ",", "(", "array", ")", "$", "value", ")", ")", "{", "// no, it is not", "return", "null", ";", "}", "return", "new", "WebDriverElement", "(", "$", "this", "->", "getElementPath", "(", "$", "value", "[", "'ELEMENT'", "]", ")", ",", "// url", "$", "value", "[", "'ELEMENT'", "]", "// id", ")", ";", "}" ]
helper method to wrap an element inside the WebDriverElement object @param array $value the raw element data returned from webdriver @return WebDriverElement the WebDriverElement object for the raw element
[ "helper", "method", "to", "wrap", "an", "element", "inside", "the", "WebDriverElement", "object" ]
efca991198616b53c8f40b59ad05306e2b10e7f0
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/WebDriver/WebDriverContainer.php#L136-L148
19,879
xinix-technology/norm
src/Norm/Collection.php
Collection.schema
public function schema($key = null, $value = null) { $numArgs = func_num_args(); if (0 === $numArgs) { return $this->schema; } elseif (1 === $numArgs) { if (is_array($key)) { $this->schema = new NObject($key); } elseif ($this->schema->offsetExists($key)) { return $this->schema[$key]; } } else { $this->schema[$key] = $value; } }
php
public function schema($key = null, $value = null) { $numArgs = func_num_args(); if (0 === $numArgs) { return $this->schema; } elseif (1 === $numArgs) { if (is_array($key)) { $this->schema = new NObject($key); } elseif ($this->schema->offsetExists($key)) { return $this->schema[$key]; } } else { $this->schema[$key] = $value; } }
[ "public", "function", "schema", "(", "$", "key", "=", "null", ",", "$", "value", "=", "null", ")", "{", "$", "numArgs", "=", "func_num_args", "(", ")", ";", "if", "(", "0", "===", "$", "numArgs", ")", "{", "return", "$", "this", "->", "schema", ";", "}", "elseif", "(", "1", "===", "$", "numArgs", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "this", "->", "schema", "=", "new", "NObject", "(", "$", "key", ")", ";", "}", "elseif", "(", "$", "this", "->", "schema", "->", "offsetExists", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "schema", "[", "$", "key", "]", ";", "}", "}", "else", "{", "$", "this", "->", "schema", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Getter and setter of collection schema. If there is no argument specified, the method will set and override schema. If argument specified, method will act as getter to specific field schema. @param string $schema @return mixed
[ "Getter", "and", "setter", "of", "collection", "schema", ".", "If", "there", "is", "no", "argument", "specified", "the", "method", "will", "set", "and", "override", "schema", ".", "If", "argument", "specified", "method", "will", "act", "as", "getter", "to", "specific", "field", "schema", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L172-L186
19,880
xinix-technology/norm
src/Norm/Collection.php
Collection.prepare
public function prepare($key, $value, $schema = null) { if (is_null($schema)) { $schema = $this->schema($key); if (is_null($schema)) { return $value; // throw new \Exception('Cannot prepare data to set. Schema not found for key ['.$key.'].'); } } return $schema->prepare($value); }
php
public function prepare($key, $value, $schema = null) { if (is_null($schema)) { $schema = $this->schema($key); if (is_null($schema)) { return $value; // throw new \Exception('Cannot prepare data to set. Schema not found for key ['.$key.'].'); } } return $schema->prepare($value); }
[ "public", "function", "prepare", "(", "$", "key", ",", "$", "value", ",", "$", "schema", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "schema", ")", ")", "{", "$", "schema", "=", "$", "this", "->", "schema", "(", "$", "key", ")", ";", "if", "(", "is_null", "(", "$", "schema", ")", ")", "{", "return", "$", "value", ";", "// throw new \\Exception('Cannot prepare data to set. Schema not found for key ['.$key.'].');", "}", "}", "return", "$", "schema", "->", "prepare", "(", "$", "value", ")", ";", "}" ]
Prepare data value for specific field name @param string $key Field name @param mixed $value Original data value @param Norm\Schema\Field $schema If specified will override default schema @return mixed Prepared data value
[ "Prepare", "data", "value", "for", "specific", "field", "name" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L197-L207
19,881
xinix-technology/norm
src/Norm/Collection.php
Collection.attach
public function attach($document) { if (isset($this->connection)) { $document = $this->connection->unmarshall($document); } // wrap document as NObject instance to make sure it can be override by hooks $document = new NObject($document); $this->applyHook('attaching', $document); if (isset($this->options['model'])) { $Model = $this->options['model']; $model = new $Model($document->toArray(), array( 'collection' => $this, )); } else { $model = new Model($document->toArray(), array( 'collection' => $this, )); } $this->applyHook('attached', $model); return $model; }
php
public function attach($document) { if (isset($this->connection)) { $document = $this->connection->unmarshall($document); } // wrap document as NObject instance to make sure it can be override by hooks $document = new NObject($document); $this->applyHook('attaching', $document); if (isset($this->options['model'])) { $Model = $this->options['model']; $model = new $Model($document->toArray(), array( 'collection' => $this, )); } else { $model = new Model($document->toArray(), array( 'collection' => $this, )); } $this->applyHook('attached', $model); return $model; }
[ "public", "function", "attach", "(", "$", "document", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "connection", ")", ")", "{", "$", "document", "=", "$", "this", "->", "connection", "->", "unmarshall", "(", "$", "document", ")", ";", "}", "// wrap document as NObject instance to make sure it can be override by hooks", "$", "document", "=", "new", "NObject", "(", "$", "document", ")", ";", "$", "this", "->", "applyHook", "(", "'attaching'", ",", "$", "document", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'model'", "]", ")", ")", "{", "$", "Model", "=", "$", "this", "->", "options", "[", "'model'", "]", ";", "$", "model", "=", "new", "$", "Model", "(", "$", "document", "->", "toArray", "(", ")", ",", "array", "(", "'collection'", "=>", "$", "this", ",", ")", ")", ";", "}", "else", "{", "$", "model", "=", "new", "Model", "(", "$", "document", "->", "toArray", "(", ")", ",", "array", "(", "'collection'", "=>", "$", "this", ",", ")", ")", ";", "}", "$", "this", "->", "applyHook", "(", "'attached'", ",", "$", "model", ")", ";", "return", "$", "model", ";", "}" ]
Attach document to Norm system as model. @param mixed document Raw document data @return Norm\Model Attached model
[ "Attach", "document", "to", "Norm", "system", "as", "model", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L216-L241
19,882
xinix-technology/norm
src/Norm/Collection.php
Collection.find
public function find($criteria = array()) { if (!is_array($criteria)) { $criteria = array( '$id' => $criteria, ); } // wrap criteria as NObject instance to make sure it can be override by hooks $criteria = new NObject($criteria); $this->applyHook('searching', $criteria); $cursor = $this->connection->query($this, $criteria->toArray()); $this->applyHook('searched', $cursor); return $cursor; }
php
public function find($criteria = array()) { if (!is_array($criteria)) { $criteria = array( '$id' => $criteria, ); } // wrap criteria as NObject instance to make sure it can be override by hooks $criteria = new NObject($criteria); $this->applyHook('searching', $criteria); $cursor = $this->connection->query($this, $criteria->toArray()); $this->applyHook('searched', $cursor); return $cursor; }
[ "public", "function", "find", "(", "$", "criteria", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "criteria", ")", ")", "{", "$", "criteria", "=", "array", "(", "'$id'", "=>", "$", "criteria", ",", ")", ";", "}", "// wrap criteria as NObject instance to make sure it can be override by hooks", "$", "criteria", "=", "new", "NObject", "(", "$", "criteria", ")", ";", "$", "this", "->", "applyHook", "(", "'searching'", ",", "$", "criteria", ")", ";", "$", "cursor", "=", "$", "this", "->", "connection", "->", "query", "(", "$", "this", ",", "$", "criteria", "->", "toArray", "(", ")", ")", ";", "$", "this", "->", "applyHook", "(", "'searched'", ",", "$", "cursor", ")", ";", "return", "$", "cursor", ";", "}" ]
Find data with specified criteria @param array $criteria @return Norm\Cursor
[ "Find", "data", "with", "specified", "criteria" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L250-L266
19,883
xinix-technology/norm
src/Norm/Collection.php
Collection.findOne
public function findOne($criteria = array()) { $model = $this->fetchCache($criteria); if (is_null($model)) { $cursor = $this->find($criteria); $model = $cursor->getNext(); $this->rememberCache($criteria, $model); } return $model; }
php
public function findOne($criteria = array()) { $model = $this->fetchCache($criteria); if (is_null($model)) { $cursor = $this->find($criteria); $model = $cursor->getNext(); $this->rememberCache($criteria, $model); } return $model; }
[ "public", "function", "findOne", "(", "$", "criteria", "=", "array", "(", ")", ")", "{", "$", "model", "=", "$", "this", "->", "fetchCache", "(", "$", "criteria", ")", ";", "if", "(", "is_null", "(", "$", "model", ")", ")", "{", "$", "cursor", "=", "$", "this", "->", "find", "(", "$", "criteria", ")", ";", "$", "model", "=", "$", "cursor", "->", "getNext", "(", ")", ";", "$", "this", "->", "rememberCache", "(", "$", "criteria", ",", "$", "model", ")", ";", "}", "return", "$", "model", ";", "}" ]
Find one document from collection @param array|mixed $criteria Criteria to search @return Norm\Model
[ "Find", "one", "document", "from", "collection" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L275-L286
19,884
xinix-technology/norm
src/Norm/Collection.php
Collection.newInstance
public function newInstance($cloned = array()) { if ($cloned instanceof Model) { $cloned = $cloned->toArray(Model::FETCH_PUBLISHED); } if (isset($this->options['model'])) { $Model = $this->options['model']; return new $Model($cloned, array('collection' => $this)); } else { return new Model($cloned, array('collection' => $this)); } }
php
public function newInstance($cloned = array()) { if ($cloned instanceof Model) { $cloned = $cloned->toArray(Model::FETCH_PUBLISHED); } if (isset($this->options['model'])) { $Model = $this->options['model']; return new $Model($cloned, array('collection' => $this)); } else { return new Model($cloned, array('collection' => $this)); } }
[ "public", "function", "newInstance", "(", "$", "cloned", "=", "array", "(", ")", ")", "{", "if", "(", "$", "cloned", "instanceof", "Model", ")", "{", "$", "cloned", "=", "$", "cloned", "->", "toArray", "(", "Model", "::", "FETCH_PUBLISHED", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'model'", "]", ")", ")", "{", "$", "Model", "=", "$", "this", "->", "options", "[", "'model'", "]", ";", "return", "new", "$", "Model", "(", "$", "cloned", ",", "array", "(", "'collection'", "=>", "$", "this", ")", ")", ";", "}", "else", "{", "return", "new", "Model", "(", "$", "cloned", ",", "array", "(", "'collection'", "=>", "$", "this", ")", ")", ";", "}", "}" ]
Create new instance of model @param array|\Norm\Model $cloned Model to clone @return \Norm\Model
[ "Create", "new", "instance", "of", "model" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L295-L307
19,885
xinix-technology/norm
src/Norm/Collection.php
Collection.filter
public function filter(Model $model, $key = null) { if (is_null($this->filter)) { $this->filter = Filter::fromSchema($this->schema()); } $this->applyHook('filtering', $model, $key); $result = $this->filter->run($model, $key); $this->applyHook('filtered', $model, $key); return $result; }
php
public function filter(Model $model, $key = null) { if (is_null($this->filter)) { $this->filter = Filter::fromSchema($this->schema()); } $this->applyHook('filtering', $model, $key); $result = $this->filter->run($model, $key); $this->applyHook('filtered', $model, $key); return $result; }
[ "public", "function", "filter", "(", "Model", "$", "model", ",", "$", "key", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "filter", ")", ")", "{", "$", "this", "->", "filter", "=", "Filter", "::", "fromSchema", "(", "$", "this", "->", "schema", "(", ")", ")", ";", "}", "$", "this", "->", "applyHook", "(", "'filtering'", ",", "$", "model", ",", "$", "key", ")", ";", "$", "result", "=", "$", "this", "->", "filter", "->", "run", "(", "$", "model", ",", "$", "key", ")", ";", "$", "this", "->", "applyHook", "(", "'filtered'", ",", "$", "model", ",", "$", "key", ")", ";", "return", "$", "result", ";", "}" ]
Filter model data with functions to cleanse, prepare and validate data. When key argument specified, filter will run partially for specified key only. @param \Norm\Model $model @param string $key Key field of model @return bool True if success and false if fail
[ "Filter", "model", "data", "with", "functions", "to", "cleanse", "prepare", "and", "validate", "data", ".", "When", "key", "argument", "specified", "filter", "will", "run", "partially", "for", "specified", "key", "only", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L318-L329
19,886
xinix-technology/norm
src/Norm/Collection.php
Collection.save
public function save(Model $model, $options = array()) { $options = array_merge(array( 'filter' => true, 'observer' => true, ), $options); if ($options['filter']) { $this->filter($model); } if ($options['observer']) { $this->applyHook('saving', $model, $options); } $modified = $this->connection->persist($this, $model->dump()); $model->setId($modified['$id']); if ($options['observer']) { $this->applyHook('saved', $model, $options); } $model->sync($modified); $this->resetCache(); }
php
public function save(Model $model, $options = array()) { $options = array_merge(array( 'filter' => true, 'observer' => true, ), $options); if ($options['filter']) { $this->filter($model); } if ($options['observer']) { $this->applyHook('saving', $model, $options); } $modified = $this->connection->persist($this, $model->dump()); $model->setId($modified['$id']); if ($options['observer']) { $this->applyHook('saved', $model, $options); } $model->sync($modified); $this->resetCache(); }
[ "public", "function", "save", "(", "Model", "$", "model", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array_merge", "(", "array", "(", "'filter'", "=>", "true", ",", "'observer'", "=>", "true", ",", ")", ",", "$", "options", ")", ";", "if", "(", "$", "options", "[", "'filter'", "]", ")", "{", "$", "this", "->", "filter", "(", "$", "model", ")", ";", "}", "if", "(", "$", "options", "[", "'observer'", "]", ")", "{", "$", "this", "->", "applyHook", "(", "'saving'", ",", "$", "model", ",", "$", "options", ")", ";", "}", "$", "modified", "=", "$", "this", "->", "connection", "->", "persist", "(", "$", "this", ",", "$", "model", "->", "dump", "(", ")", ")", ";", "$", "model", "->", "setId", "(", "$", "modified", "[", "'$id'", "]", ")", ";", "if", "(", "$", "options", "[", "'observer'", "]", ")", "{", "$", "this", "->", "applyHook", "(", "'saved'", ",", "$", "model", ",", "$", "options", ")", ";", "}", "$", "model", "->", "sync", "(", "$", "modified", ")", ";", "$", "this", "->", "resetCache", "(", ")", ";", "}" ]
Save model to persistent state @param \Norm\Model $model @param array $options @return void
[ "Save", "model", "to", "persistent", "state" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L339-L363
19,887
xinix-technology/norm
src/Norm/Collection.php
Collection.remove
public function remove(Model $model = null) { if (func_num_args() === 0) { $this->connection->remove($this); } else { // avoid remove empty model if (is_null($model)) { throw new \Exception('[Norm/Collection] Cannot remove null model'); } $this->applyHook('removing', $model); $result = $this->connection->remove($this, $model); if ($result) { $model->reset(); } $this->applyHook('removed', $model); } }
php
public function remove(Model $model = null) { if (func_num_args() === 0) { $this->connection->remove($this); } else { // avoid remove empty model if (is_null($model)) { throw new \Exception('[Norm/Collection] Cannot remove null model'); } $this->applyHook('removing', $model); $result = $this->connection->remove($this, $model); if ($result) { $model->reset(); } $this->applyHook('removed', $model); } }
[ "public", "function", "remove", "(", "Model", "$", "model", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "===", "0", ")", "{", "$", "this", "->", "connection", "->", "remove", "(", "$", "this", ")", ";", "}", "else", "{", "// avoid remove empty model", "if", "(", "is_null", "(", "$", "model", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'[Norm/Collection] Cannot remove null model'", ")", ";", "}", "$", "this", "->", "applyHook", "(", "'removing'", ",", "$", "model", ")", ";", "$", "result", "=", "$", "this", "->", "connection", "->", "remove", "(", "$", "this", ",", "$", "model", ")", ";", "if", "(", "$", "result", ")", "{", "$", "model", "->", "reset", "(", ")", ";", "}", "$", "this", "->", "applyHook", "(", "'removed'", ",", "$", "model", ")", ";", "}", "}" ]
Remove single model @param \Norm\Model $model @return void
[ "Remove", "single", "model" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L372-L391
19,888
xinix-technology/norm
src/Norm/Collection.php
Collection.rememberCache
protected function rememberCache($criteria, $model) { $ser = serialize($criteria); $this->cache[$ser] = $model; }
php
protected function rememberCache($criteria, $model) { $ser = serialize($criteria); $this->cache[$ser] = $model; }
[ "protected", "function", "rememberCache", "(", "$", "criteria", ",", "$", "model", ")", "{", "$", "ser", "=", "serialize", "(", "$", "criteria", ")", ";", "$", "this", "->", "cache", "[", "$", "ser", "]", "=", "$", "model", ";", "}" ]
Put item in cache bags. @method rememberCache @param mixed $criteria @param \Norm\Model $model [description] @return void
[ "Put", "item", "in", "cache", "bags", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L468-L473
19,889
xinix-technology/norm
src/Norm/Collection.php
Collection.fetchCache
protected function fetchCache($criteria) { $ser = serialize($criteria); if (isset($this->cache[$ser])) { return $this->cache[$ser]; } }
php
protected function fetchCache($criteria) { $ser = serialize($criteria); if (isset($this->cache[$ser])) { return $this->cache[$ser]; } }
[ "protected", "function", "fetchCache", "(", "$", "criteria", ")", "{", "$", "ser", "=", "serialize", "(", "$", "criteria", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "ser", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "ser", "]", ";", "}", "}" ]
Get item from cache. @method fetchCache @param NObject $criteria @return void|\Norm\Model
[ "Get", "item", "from", "cache", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Collection.php#L484-L491
19,890
Josantonius/WP_Menu
src/class-wp-menu.php
WP_Menu.add
public static function add( $type, $data = [], $function = 0, $styles = 0, $scripts = 0 ) { if ( ! is_admin() || ! self::required_params_exist( $type, $data ) ) { return false; } $data = self::set_params( $data, $function, $styles, $scripts ); $slug = $data['slug']; self::$data[ $type ][ $slug ] = $data; add_action( 'admin_menu', function() use ( $type, $slug ) { self::set( $type, $slug ); } ); return true; }
php
public static function add( $type, $data = [], $function = 0, $styles = 0, $scripts = 0 ) { if ( ! is_admin() || ! self::required_params_exist( $type, $data ) ) { return false; } $data = self::set_params( $data, $function, $styles, $scripts ); $slug = $data['slug']; self::$data[ $type ][ $slug ] = $data; add_action( 'admin_menu', function() use ( $type, $slug ) { self::set( $type, $slug ); } ); return true; }
[ "public", "static", "function", "add", "(", "$", "type", ",", "$", "data", "=", "[", "]", ",", "$", "function", "=", "0", ",", "$", "styles", "=", "0", ",", "$", "scripts", "=", "0", ")", "{", "if", "(", "!", "is_admin", "(", ")", "||", "!", "self", "::", "required_params_exist", "(", "$", "type", ",", "$", "data", ")", ")", "{", "return", "false", ";", "}", "$", "data", "=", "self", "::", "set_params", "(", "$", "data", ",", "$", "function", ",", "$", "styles", ",", "$", "scripts", ")", ";", "$", "slug", "=", "$", "data", "[", "'slug'", "]", ";", "self", "::", "$", "data", "[", "$", "type", "]", "[", "$", "slug", "]", "=", "$", "data", ";", "add_action", "(", "'admin_menu'", ",", "function", "(", ")", "use", "(", "$", "type", ",", "$", "slug", ")", "{", "self", "::", "set", "(", "$", "type", ",", "$", "slug", ")", ";", "}", ")", ";", "return", "true", ";", "}" ]
Add menu or submenu. @param string $type → menu | submenu. @param array $data → settings. @param mixed $function → method to be called to output page content. @param mixed $styles → method to be called to load page styles. @param mixed $scripts → method to be called to load page scripts. @see https://github.com/Josantonius/WP_Menu#addtype-data-function-styles-scripts @return boolean
[ "Add", "menu", "or", "submenu", "." ]
90df3355007083cc156353dde94ee73d3fea0ce5
https://github.com/Josantonius/WP_Menu/blob/90df3355007083cc156353dde94ee73d3fea0ce5/src/class-wp-menu.php#L40-L59
19,891
Josantonius/WP_Menu
src/class-wp-menu.php
WP_Menu.required_params_exist
private static function required_params_exist( $type, $data ) { $required = [ 'name', 'slug' ]; if ( 'submenu' === $type ) { array_push( $required, 'parent' ); } foreach ( $required as $field ) { if ( ! isset( $data[ $field ] ) || empty( $data[ $field ] ) ) { return false; } } return true; }
php
private static function required_params_exist( $type, $data ) { $required = [ 'name', 'slug' ]; if ( 'submenu' === $type ) { array_push( $required, 'parent' ); } foreach ( $required as $field ) { if ( ! isset( $data[ $field ] ) || empty( $data[ $field ] ) ) { return false; } } return true; }
[ "private", "static", "function", "required_params_exist", "(", "$", "type", ",", "$", "data", ")", "{", "$", "required", "=", "[", "'name'", ",", "'slug'", "]", ";", "if", "(", "'submenu'", "===", "$", "type", ")", "{", "array_push", "(", "$", "required", ",", "'parent'", ")", ";", "}", "foreach", "(", "$", "required", "as", "$", "field", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "field", "]", ")", "||", "empty", "(", "$", "data", "[", "$", "field", "]", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Validate if the required parameters exist. @since 1.0.4 @param string $type → menu | submenu. @param array $data → settings. @return boolean
[ "Validate", "if", "the", "required", "parameters", "exist", "." ]
90df3355007083cc156353dde94ee73d3fea0ce5
https://github.com/Josantonius/WP_Menu/blob/90df3355007083cc156353dde94ee73d3fea0ce5/src/class-wp-menu.php#L121-L136
19,892
Josantonius/WP_Menu
src/class-wp-menu.php
WP_Menu.set
private static function set( $type, $slug ) { global $pagenow; $data = self::$data[ $type ][ $slug ]; do_action( 'wp_menu_pre_add_' . $type . '_page' ); if ( 'menu' === $type ) { $page = add_menu_page( $data['title'], $data['name'], $data['capability'], $data['slug'], $data['function'], $data['icon_url'], $data['position'] ); } elseif ( 'submenu' === $type ) { $page = add_submenu_page( $data['parent'], $data['title'], $data['name'], $data['capability'], $data['slug'], $data['function'] ); } do_action( 'wp_menu_after_add_' . $type . '_page', 'load-' . $page ); if ( ! $pagenow || 'admin.php' === $pagenow ) { self::set_action( $page, $data['styles'] ); self::set_action( $page, $data['scripts'] ); } }
php
private static function set( $type, $slug ) { global $pagenow; $data = self::$data[ $type ][ $slug ]; do_action( 'wp_menu_pre_add_' . $type . '_page' ); if ( 'menu' === $type ) { $page = add_menu_page( $data['title'], $data['name'], $data['capability'], $data['slug'], $data['function'], $data['icon_url'], $data['position'] ); } elseif ( 'submenu' === $type ) { $page = add_submenu_page( $data['parent'], $data['title'], $data['name'], $data['capability'], $data['slug'], $data['function'] ); } do_action( 'wp_menu_after_add_' . $type . '_page', 'load-' . $page ); if ( ! $pagenow || 'admin.php' === $pagenow ) { self::set_action( $page, $data['styles'] ); self::set_action( $page, $data['scripts'] ); } }
[ "private", "static", "function", "set", "(", "$", "type", ",", "$", "slug", ")", "{", "global", "$", "pagenow", ";", "$", "data", "=", "self", "::", "$", "data", "[", "$", "type", "]", "[", "$", "slug", "]", ";", "do_action", "(", "'wp_menu_pre_add_'", ".", "$", "type", ".", "'_page'", ")", ";", "if", "(", "'menu'", "===", "$", "type", ")", "{", "$", "page", "=", "add_menu_page", "(", "$", "data", "[", "'title'", "]", ",", "$", "data", "[", "'name'", "]", ",", "$", "data", "[", "'capability'", "]", ",", "$", "data", "[", "'slug'", "]", ",", "$", "data", "[", "'function'", "]", ",", "$", "data", "[", "'icon_url'", "]", ",", "$", "data", "[", "'position'", "]", ")", ";", "}", "elseif", "(", "'submenu'", "===", "$", "type", ")", "{", "$", "page", "=", "add_submenu_page", "(", "$", "data", "[", "'parent'", "]", ",", "$", "data", "[", "'title'", "]", ",", "$", "data", "[", "'name'", "]", ",", "$", "data", "[", "'capability'", "]", ",", "$", "data", "[", "'slug'", "]", ",", "$", "data", "[", "'function'", "]", ")", ";", "}", "do_action", "(", "'wp_menu_after_add_'", ".", "$", "type", ".", "'_page'", ",", "'load-'", ".", "$", "page", ")", ";", "if", "(", "!", "$", "pagenow", "||", "'admin.php'", "===", "$", "pagenow", ")", "{", "self", "::", "set_action", "(", "$", "page", ",", "$", "data", "[", "'styles'", "]", ")", ";", "self", "::", "set_action", "(", "$", "page", ",", "$", "data", "[", "'scripts'", "]", ")", ";", "}", "}" ]
Set menu and submenu admin. @since 1.0.1 @param string $type → menu|submenu. @param string $slug → menu|submenu slug.
[ "Set", "menu", "and", "submenu", "admin", "." ]
90df3355007083cc156353dde94ee73d3fea0ce5
https://github.com/Josantonius/WP_Menu/blob/90df3355007083cc156353dde94ee73d3fea0ce5/src/class-wp-menu.php#L146-L184
19,893
Josantonius/WP_Menu
src/class-wp-menu.php
WP_Menu.validate_method
private static function validate_method( $method ) { if ( $method && isset( $method[0] ) && isset( $method[1] ) ) { if ( method_exists( $method[0], $method[1] ) ) { return true; } } return false; }
php
private static function validate_method( $method ) { if ( $method && isset( $method[0] ) && isset( $method[1] ) ) { if ( method_exists( $method[0], $method[1] ) ) { return true; } } return false; }
[ "private", "static", "function", "validate_method", "(", "$", "method", ")", "{", "if", "(", "$", "method", "&&", "isset", "(", "$", "method", "[", "0", "]", ")", "&&", "isset", "(", "$", "method", "[", "1", "]", ")", ")", "{", "if", "(", "method_exists", "(", "$", "method", "[", "0", "]", ",", "$", "method", "[", "1", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if method exists. @since 1.0.2 @param array $method → [class|object, method]. @return boolean
[ "Check", "if", "method", "exists", "." ]
90df3355007083cc156353dde94ee73d3fea0ce5
https://github.com/Josantonius/WP_Menu/blob/90df3355007083cc156353dde94ee73d3fea0ce5/src/class-wp-menu.php#L195-L204
19,894
cohesion/cohesion-core
src/Structure/DTO.php
DTO.getVarsWithoutCircularReferences
private function getVarsWithoutCircularReferences($showNulls, &$previousDTOs = []) { $previousDTOs[spl_object_hash($this)] = true; $classProperties = $this->reflection->getProperties(\ReflectionProperty::IS_PROTECTED); $vars = array(); foreach ($classProperties as $property) { if (!isset($this->{$property->name})) { $var = null; // if it's another DTO } else if ($this->{$property->name} instanceof DTO) { // If this will cause a circular reference issue just ignore it if (!isset($previousDTOs[spl_object_hash($this->{$property->name})])) { // Get it's vars $var = $this->{$property->name}->getVarsWithoutCircularReferences($showNulls, $previousDTOs); } // If it's an array of DTOs } else if (is_array($this->{$property->name}) && count($this->{$property->name}) > 0 && $this->{$property->name}[0] instanceof DTO) { $var = array(); // Get the vars for each foreach ($this->{$property->name} as $i => $v) { if (!isset($previousDTOs[spl_object_hash($v)])) { $var[$i] = $v->getVarsWithoutCircularReferences($showNulls, $previousDTOs); } } // If it's some other kind of object } else if (is_object($this->{$property->name}) && method_exists($this->{$property->name}, '__toString')) { $var = (string)$this->{$property->name}; // Otherwise } else { // Just use the value $var = $this->{$property->name}; } if ($showNulls || ($var !== null && (!is_array($var) || count($var) > 0))) { $vars[$this->camelToUnderscore($property->name)] = $var; } } return $vars; }
php
private function getVarsWithoutCircularReferences($showNulls, &$previousDTOs = []) { $previousDTOs[spl_object_hash($this)] = true; $classProperties = $this->reflection->getProperties(\ReflectionProperty::IS_PROTECTED); $vars = array(); foreach ($classProperties as $property) { if (!isset($this->{$property->name})) { $var = null; // if it's another DTO } else if ($this->{$property->name} instanceof DTO) { // If this will cause a circular reference issue just ignore it if (!isset($previousDTOs[spl_object_hash($this->{$property->name})])) { // Get it's vars $var = $this->{$property->name}->getVarsWithoutCircularReferences($showNulls, $previousDTOs); } // If it's an array of DTOs } else if (is_array($this->{$property->name}) && count($this->{$property->name}) > 0 && $this->{$property->name}[0] instanceof DTO) { $var = array(); // Get the vars for each foreach ($this->{$property->name} as $i => $v) { if (!isset($previousDTOs[spl_object_hash($v)])) { $var[$i] = $v->getVarsWithoutCircularReferences($showNulls, $previousDTOs); } } // If it's some other kind of object } else if (is_object($this->{$property->name}) && method_exists($this->{$property->name}, '__toString')) { $var = (string)$this->{$property->name}; // Otherwise } else { // Just use the value $var = $this->{$property->name}; } if ($showNulls || ($var !== null && (!is_array($var) || count($var) > 0))) { $vars[$this->camelToUnderscore($property->name)] = $var; } } return $vars; }
[ "private", "function", "getVarsWithoutCircularReferences", "(", "$", "showNulls", ",", "&", "$", "previousDTOs", "=", "[", "]", ")", "{", "$", "previousDTOs", "[", "spl_object_hash", "(", "$", "this", ")", "]", "=", "true", ";", "$", "classProperties", "=", "$", "this", "->", "reflection", "->", "getProperties", "(", "\\", "ReflectionProperty", "::", "IS_PROTECTED", ")", ";", "$", "vars", "=", "array", "(", ")", ";", "foreach", "(", "$", "classProperties", "as", "$", "property", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "{", "$", "property", "->", "name", "}", ")", ")", "{", "$", "var", "=", "null", ";", "// if it's another DTO", "}", "else", "if", "(", "$", "this", "->", "{", "$", "property", "->", "name", "}", "instanceof", "DTO", ")", "{", "// If this will cause a circular reference issue just ignore it", "if", "(", "!", "isset", "(", "$", "previousDTOs", "[", "spl_object_hash", "(", "$", "this", "->", "{", "$", "property", "->", "name", "}", ")", "]", ")", ")", "{", "// Get it's vars", "$", "var", "=", "$", "this", "->", "{", "$", "property", "->", "name", "}", "->", "getVarsWithoutCircularReferences", "(", "$", "showNulls", ",", "$", "previousDTOs", ")", ";", "}", "// If it's an array of DTOs", "}", "else", "if", "(", "is_array", "(", "$", "this", "->", "{", "$", "property", "->", "name", "}", ")", "&&", "count", "(", "$", "this", "->", "{", "$", "property", "->", "name", "}", ")", ">", "0", "&&", "$", "this", "->", "{", "$", "property", "->", "name", "}", "[", "0", "]", "instanceof", "DTO", ")", "{", "$", "var", "=", "array", "(", ")", ";", "// Get the vars for each", "foreach", "(", "$", "this", "->", "{", "$", "property", "->", "name", "}", "as", "$", "i", "=>", "$", "v", ")", "{", "if", "(", "!", "isset", "(", "$", "previousDTOs", "[", "spl_object_hash", "(", "$", "v", ")", "]", ")", ")", "{", "$", "var", "[", "$", "i", "]", "=", "$", "v", "->", "getVarsWithoutCircularReferences", "(", "$", "showNulls", ",", "$", "previousDTOs", ")", ";", "}", "}", "// If it's some other kind of object", "}", "else", "if", "(", "is_object", "(", "$", "this", "->", "{", "$", "property", "->", "name", "}", ")", "&&", "method_exists", "(", "$", "this", "->", "{", "$", "property", "->", "name", "}", ",", "'__toString'", ")", ")", "{", "$", "var", "=", "(", "string", ")", "$", "this", "->", "{", "$", "property", "->", "name", "}", ";", "// Otherwise", "}", "else", "{", "// Just use the value", "$", "var", "=", "$", "this", "->", "{", "$", "property", "->", "name", "}", ";", "}", "if", "(", "$", "showNulls", "||", "(", "$", "var", "!==", "null", "&&", "(", "!", "is_array", "(", "$", "var", ")", "||", "count", "(", "$", "var", ")", ">", "0", ")", ")", ")", "{", "$", "vars", "[", "$", "this", "->", "camelToUnderscore", "(", "$", "property", "->", "name", ")", "]", "=", "$", "var", ";", "}", "}", "return", "$", "vars", ";", "}" ]
Export protected class parameters as an associative array. This function will make sure that even if the object has a circular reference it won't crash the system by calling the `getVars` function. If there is a circular reference the later one will be left out of the output
[ "Export", "protected", "class", "parameters", "as", "an", "associative", "array", "." ]
c6352aef7336e06285f0943da68235dc45523998
https://github.com/cohesion/cohesion-core/blob/c6352aef7336e06285f0943da68235dc45523998/src/Structure/DTO.php#L120-L158
19,895
aedart/laravel-helpers
src/Traits/Redis/RedisTrait.php
RedisTrait.getDefaultRedis
public function getDefaultRedis(): ?Connection { // From Laravel 5.4, the redis facade now returns the // Redis Manager, which is why we must use it to obtain // the default Redis connection. Thus, the // "Illuminate\Contracts\Redis\Database" interface is no // longer used. $factory = Redis::getFacadeRoot(); if (isset($factory)) { return $factory->connection(); } return $factory; }
php
public function getDefaultRedis(): ?Connection { // From Laravel 5.4, the redis facade now returns the // Redis Manager, which is why we must use it to obtain // the default Redis connection. Thus, the // "Illuminate\Contracts\Redis\Database" interface is no // longer used. $factory = Redis::getFacadeRoot(); if (isset($factory)) { return $factory->connection(); } return $factory; }
[ "public", "function", "getDefaultRedis", "(", ")", ":", "?", "Connection", "{", "// From Laravel 5.4, the redis facade now returns the", "// Redis Manager, which is why we must use it to obtain", "// the default Redis connection. Thus, the", "// \"Illuminate\\Contracts\\Redis\\Database\" interface is no", "// longer used.", "$", "factory", "=", "Redis", "::", "getFacadeRoot", "(", ")", ";", "if", "(", "isset", "(", "$", "factory", ")", ")", "{", "return", "$", "factory", "->", "connection", "(", ")", ";", "}", "return", "$", "factory", ";", "}" ]
Get a default redis value, if any is available @return Connection|null A default redis value or Null if no default value is available
[ "Get", "a", "default", "redis", "value", "if", "any", "is", "available" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Redis/RedisTrait.php#L76-L88
19,896
steeffeen/FancyManiaLinks
FML/UniqueID.php
UniqueID.check
public static function check(Identifiable $element) { $elementId = $element->getId(); if (!$elementId) { $element->setId(new static()); return $element->getId(); } $dangerousCharacters = array(' ', '|', PHP_EOL); $danger = false; foreach ($dangerousCharacters as $dangerousCharacter) { if (stripos($elementId, $dangerousCharacter) !== false) { $danger = true; break; } } if ($danger) { trigger_error("Don't use special characters in IDs, they might cause problems! Stripping them for you..."); $elementId = str_ireplace($dangerousCharacters, '', $elementId); $element->setId($elementId); } return $element->getId(); }
php
public static function check(Identifiable $element) { $elementId = $element->getId(); if (!$elementId) { $element->setId(new static()); return $element->getId(); } $dangerousCharacters = array(' ', '|', PHP_EOL); $danger = false; foreach ($dangerousCharacters as $dangerousCharacter) { if (stripos($elementId, $dangerousCharacter) !== false) { $danger = true; break; } } if ($danger) { trigger_error("Don't use special characters in IDs, they might cause problems! Stripping them for you..."); $elementId = str_ireplace($dangerousCharacters, '', $elementId); $element->setId($elementId); } return $element->getId(); }
[ "public", "static", "function", "check", "(", "Identifiable", "$", "element", ")", "{", "$", "elementId", "=", "$", "element", "->", "getId", "(", ")", ";", "if", "(", "!", "$", "elementId", ")", "{", "$", "element", "->", "setId", "(", "new", "static", "(", ")", ")", ";", "return", "$", "element", "->", "getId", "(", ")", ";", "}", "$", "dangerousCharacters", "=", "array", "(", "' '", ",", "'|'", ",", "PHP_EOL", ")", ";", "$", "danger", "=", "false", ";", "foreach", "(", "$", "dangerousCharacters", "as", "$", "dangerousCharacter", ")", "{", "if", "(", "stripos", "(", "$", "elementId", ",", "$", "dangerousCharacter", ")", "!==", "false", ")", "{", "$", "danger", "=", "true", ";", "break", ";", "}", "}", "if", "(", "$", "danger", ")", "{", "trigger_error", "(", "\"Don't use special characters in IDs, they might cause problems! Stripping them for you...\"", ")", ";", "$", "elementId", "=", "str_ireplace", "(", "$", "dangerousCharacters", ",", "''", ",", "$", "elementId", ")", ";", "$", "element", "->", "setId", "(", "$", "elementId", ")", ";", "}", "return", "$", "element", "->", "getId", "(", ")", ";", "}" ]
Check and return the Id of an Identifable Element @param Identifiable $element Identifable element @return string
[ "Check", "and", "return", "the", "Id", "of", "an", "Identifable", "Element" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/UniqueID.php#L48-L73
19,897
simple-php-mvc/simple-php-mvc
src/MVC/Server/HttpRequest.php
HttpRequest.is
public function is($characteristic) { switch ( strtolower($characteristic) ) { case "ajax": return ( isset($this->_env['HTTP_X_REQUESTED_WITH']) && $this->_env['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest" ); case "delete": return ( $this->method == "DELETE" ); case "flash": return ( $this->_env['HTTP_USER_AGENT'] == "Shockwave Flash" ); case "get": return ( $this->method == "GET" ); case "head": return ( $this->method == "HEAD" ); case "mobile": $mobile_user_agents = array( "Android", "AvantGo", "Blackberry", "DoCoMo", "iPod", "iPhone", "J2ME", "NetFront", "Nokia", "MIDP", "Opera Mini", "PalmOS", "PalmSource", "Plucker", "portalmmm", "ReqwirelessWeb", "SonyEricsson", "Symbian", "UP\.Browser", "Windows CE", "Xiino" ); $pattern = "/" . implode("|", $mobile_user_agents) . "/i"; return (boolean) preg_match( $pattern, $this->_env['HTTP_USER_AGENT'] ); case "options": return ( $this->method == "OPTIONS" ); case "post": return ( $this->method == "POST" ); case "put": return ( $this->method == "PUT" ); case "ssl": return $this->_env['HTTPS']; default: return false; } }
php
public function is($characteristic) { switch ( strtolower($characteristic) ) { case "ajax": return ( isset($this->_env['HTTP_X_REQUESTED_WITH']) && $this->_env['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest" ); case "delete": return ( $this->method == "DELETE" ); case "flash": return ( $this->_env['HTTP_USER_AGENT'] == "Shockwave Flash" ); case "get": return ( $this->method == "GET" ); case "head": return ( $this->method == "HEAD" ); case "mobile": $mobile_user_agents = array( "Android", "AvantGo", "Blackberry", "DoCoMo", "iPod", "iPhone", "J2ME", "NetFront", "Nokia", "MIDP", "Opera Mini", "PalmOS", "PalmSource", "Plucker", "portalmmm", "ReqwirelessWeb", "SonyEricsson", "Symbian", "UP\.Browser", "Windows CE", "Xiino" ); $pattern = "/" . implode("|", $mobile_user_agents) . "/i"; return (boolean) preg_match( $pattern, $this->_env['HTTP_USER_AGENT'] ); case "options": return ( $this->method == "OPTIONS" ); case "post": return ( $this->method == "POST" ); case "put": return ( $this->method == "PUT" ); case "ssl": return $this->_env['HTTPS']; default: return false; } }
[ "public", "function", "is", "(", "$", "characteristic", ")", "{", "switch", "(", "strtolower", "(", "$", "characteristic", ")", ")", "{", "case", "\"ajax\"", ":", "return", "(", "isset", "(", "$", "this", "->", "_env", "[", "'HTTP_X_REQUESTED_WITH'", "]", ")", "&&", "$", "this", "->", "_env", "[", "'HTTP_X_REQUESTED_WITH'", "]", "==", "\"XMLHttpRequest\"", ")", ";", "case", "\"delete\"", ":", "return", "(", "$", "this", "->", "method", "==", "\"DELETE\"", ")", ";", "case", "\"flash\"", ":", "return", "(", "$", "this", "->", "_env", "[", "'HTTP_USER_AGENT'", "]", "==", "\"Shockwave Flash\"", ")", ";", "case", "\"get\"", ":", "return", "(", "$", "this", "->", "method", "==", "\"GET\"", ")", ";", "case", "\"head\"", ":", "return", "(", "$", "this", "->", "method", "==", "\"HEAD\"", ")", ";", "case", "\"mobile\"", ":", "$", "mobile_user_agents", "=", "array", "(", "\"Android\"", ",", "\"AvantGo\"", ",", "\"Blackberry\"", ",", "\"DoCoMo\"", ",", "\"iPod\"", ",", "\"iPhone\"", ",", "\"J2ME\"", ",", "\"NetFront\"", ",", "\"Nokia\"", ",", "\"MIDP\"", ",", "\"Opera Mini\"", ",", "\"PalmOS\"", ",", "\"PalmSource\"", ",", "\"Plucker\"", ",", "\"portalmmm\"", ",", "\"ReqwirelessWeb\"", ",", "\"SonyEricsson\"", ",", "\"Symbian\"", ",", "\"UP\\.Browser\"", ",", "\"Windows CE\"", ",", "\"Xiino\"", ")", ";", "$", "pattern", "=", "\"/\"", ".", "implode", "(", "\"|\"", ",", "$", "mobile_user_agents", ")", ".", "\"/i\"", ";", "return", "(", "boolean", ")", "preg_match", "(", "$", "pattern", ",", "$", "this", "->", "_env", "[", "'HTTP_USER_AGENT'", "]", ")", ";", "case", "\"options\"", ":", "return", "(", "$", "this", "->", "method", "==", "\"OPTIONS\"", ")", ";", "case", "\"post\"", ":", "return", "(", "$", "this", "->", "method", "==", "\"POST\"", ")", ";", "case", "\"put\"", ":", "return", "(", "$", "this", "->", "method", "==", "\"PUT\"", ")", ";", "case", "\"ssl\"", ":", "return", "$", "this", "->", "_env", "[", "'HTTPS'", "]", ";", "default", ":", "return", "false", ";", "}", "}" ]
Checks for request characteristics. The full list of request characteristics is as follows: * "ajax" - XHR * "delete" - DELETE REQUEST_METHOD * "flash" - "Shockwave Flash" HTTP_USER_AGENT * "get" - GET REQUEST_METHOD * "head" - HEAD REQUEST_METHOD * "mobile" - any one of the following HTTP_USER_AGENTS: 1. "Android" 1. "AvantGo" 1. "Blackberry" 1. "DoCoMo" 1. "iPod" 1. "iPhone" 1. "J2ME" 1. "NetFront" 1. "Nokia" 1. "MIDP" 1. "Opera Mini" 1. "PalmOS" 1. "PalmSource" 1. "Plucker" 1. "portalmmm" 1. "ReqwirelessWeb" 1. "SonyEricsson" 1. "Symbian" 1. "UP.Browser" 1. "Windows CE" 1. "Xiino" * "options" - OPTIONS REQUEST_METHOD * "post" - POST REQUEST_METHOD * "put" - PUT REQUEST_METHOD * "ssl" - HTTPS @access public @param string $characteristic The characteristic. @return bool
[ "Checks", "for", "request", "characteristics", "." ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Server/HttpRequest.php#L277-L318
19,898
simple-php-mvc/simple-php-mvc
src/MVC/Server/HttpRequest.php
HttpRequest.parseUrl
protected function parseUrl($url = "") { $parsed = ($url) ? parse_url($url) : parse_url($this->_env['REQUEST_URI']); if (preg_match('/[a-zA-Z0-9_]+\.php/i', $parsed['path'], $matches)) { $parsed['path'] = preg_replace("/$matches[0]/", '/', $parsed['path']); } return $parsed; }
php
protected function parseUrl($url = "") { $parsed = ($url) ? parse_url($url) : parse_url($this->_env['REQUEST_URI']); if (preg_match('/[a-zA-Z0-9_]+\.php/i', $parsed['path'], $matches)) { $parsed['path'] = preg_replace("/$matches[0]/", '/', $parsed['path']); } return $parsed; }
[ "protected", "function", "parseUrl", "(", "$", "url", "=", "\"\"", ")", "{", "$", "parsed", "=", "(", "$", "url", ")", "?", "parse_url", "(", "$", "url", ")", ":", "parse_url", "(", "$", "this", "->", "_env", "[", "'REQUEST_URI'", "]", ")", ";", "if", "(", "preg_match", "(", "'/[a-zA-Z0-9_]+\\.php/i'", ",", "$", "parsed", "[", "'path'", "]", ",", "$", "matches", ")", ")", "{", "$", "parsed", "[", "'path'", "]", "=", "preg_replace", "(", "\"/$matches[0]/\"", ",", "'/'", ",", "$", "parsed", "[", "'path'", "]", ")", ";", "}", "return", "$", "parsed", ";", "}" ]
Get parsed url @param string $url Url to parse @return array Parsed Url
[ "Get", "parsed", "url" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Server/HttpRequest.php#L396-L405
19,899
steeffeen/FancyManiaLinks
FML/Script/Features/ControlScript.php
ControlScript.setControl
public function setControl(Control $control) { $control->checkId(); $control->addScriptFeature($this); $this->control = $control; $this->updateScriptEvents(); return $this; }
php
public function setControl(Control $control) { $control->checkId(); $control->addScriptFeature($this); $this->control = $control; $this->updateScriptEvents(); return $this; }
[ "public", "function", "setControl", "(", "Control", "$", "control", ")", "{", "$", "control", "->", "checkId", "(", ")", ";", "$", "control", "->", "addScriptFeature", "(", "$", "this", ")", ";", "$", "this", "->", "control", "=", "$", "control", ";", "$", "this", "->", "updateScriptEvents", "(", ")", ";", "return", "$", "this", ";", "}" ]
Set the Control @api @param Control $control Control @return static
[ "Set", "the", "Control" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ControlScript.php#L75-L82