repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
CESNET/perun-simplesamlphp-module
lib/Disco.php
Disco.handleRequest
public function handleRequest() { // test if user has selected an idp or idp can be deremine automatically somehow. $this->start(); // no choice possible. Show discovery service page $idpList = $this->getIdPList(); if (isset($this->originalsp['disco.addInstitutionApp']) && $this->originalsp['disco.addInstitutionApp'] === true ) { $idpList = $this->filterAddInstitutionList($idpList); } else { $idpList = $this->filterList($idpList); } $preferredIdP = $this->getRecommendedIdP(); $preferredIdP = array_key_exists($preferredIdP, $idpList) ? $preferredIdP : null; if (sizeof($idpList) === 1) { $idp = array_keys($idpList)[0]; $url = Disco::buildContinueUrl( $this->spEntityId, $this->returnURL, $this->returnIdParam, $idp ); Logger::info('perun.Disco: Only one Idp left. Redirecting automatically. IdP: ' . $idp); HTTP::redirectTrustedURL($url); } $t = new DiscoTemplate($this->config); $t->data['originalsp'] = $this->originalsp; $t->data['idplist'] = $this->idplistStructured($idpList); $t->data['preferredidp'] = $preferredIdP; $t->data['entityID'] = $this->spEntityId; $t->data['return'] = $this->returnURL; $t->data['returnIDParam'] = $this->returnIdParam; $t->data['AuthnContextClassRef'] = $this->authnContextClassRef; $t->show(); }
php
public function handleRequest() { // test if user has selected an idp or idp can be deremine automatically somehow. $this->start(); // no choice possible. Show discovery service page $idpList = $this->getIdPList(); if (isset($this->originalsp['disco.addInstitutionApp']) && $this->originalsp['disco.addInstitutionApp'] === true ) { $idpList = $this->filterAddInstitutionList($idpList); } else { $idpList = $this->filterList($idpList); } $preferredIdP = $this->getRecommendedIdP(); $preferredIdP = array_key_exists($preferredIdP, $idpList) ? $preferredIdP : null; if (sizeof($idpList) === 1) { $idp = array_keys($idpList)[0]; $url = Disco::buildContinueUrl( $this->spEntityId, $this->returnURL, $this->returnIdParam, $idp ); Logger::info('perun.Disco: Only one Idp left. Redirecting automatically. IdP: ' . $idp); HTTP::redirectTrustedURL($url); } $t = new DiscoTemplate($this->config); $t->data['originalsp'] = $this->originalsp; $t->data['idplist'] = $this->idplistStructured($idpList); $t->data['preferredidp'] = $preferredIdP; $t->data['entityID'] = $this->spEntityId; $t->data['return'] = $this->returnURL; $t->data['returnIDParam'] = $this->returnIdParam; $t->data['AuthnContextClassRef'] = $this->authnContextClassRef; $t->show(); }
[ "public", "function", "handleRequest", "(", ")", "{", "// test if user has selected an idp or idp can be deremine automatically somehow.", "$", "this", "->", "start", "(", ")", ";", "// no choice possible. Show discovery service page", "$", "idpList", "=", "$", "this", "->", ...
Handles a request to this discovery service. It is enry point of Discovery service. The IdP disco parameters should be set before calling this function.
[ "Handles", "a", "request", "to", "this", "discovery", "service", ".", "It", "is", "enry", "point", "of", "Discovery", "service", "." ]
f1d686f06472053a7cdb31f2b2776f9714779ee1
https://github.com/CESNET/perun-simplesamlphp-module/blob/f1d686f06472053a7cdb31f2b2776f9714779ee1/lib/Disco.php#L79-L119
train
CESNET/perun-simplesamlphp-module
lib/Disco.php
Disco.filterList
protected function filterList($list) { $conf = Configuration::getConfig(self::CONFIG_FILE_NAME); $disableWhitelisting = $conf->getBoolean(self::PROPNAME_DISABLE_WHITELISTING, false); if (!isset($this->originalsp['disco.doNotFilterIdps']) || !$this->originalsp['disco.doNotFilterIdps'] ) { $list = parent::filterList($list); $list = $this->scoping($list); if (!$disableWhitelisting) { $list = $this->whitelisting($list); } $list = $this->greylisting($list); $list = $this->greylistingPerSP($list, $this->originalsp); } if (empty($list)) { throw new Exception('All IdPs has been filtered out. And no one left.'); } return $list; }
php
protected function filterList($list) { $conf = Configuration::getConfig(self::CONFIG_FILE_NAME); $disableWhitelisting = $conf->getBoolean(self::PROPNAME_DISABLE_WHITELISTING, false); if (!isset($this->originalsp['disco.doNotFilterIdps']) || !$this->originalsp['disco.doNotFilterIdps'] ) { $list = parent::filterList($list); $list = $this->scoping($list); if (!$disableWhitelisting) { $list = $this->whitelisting($list); } $list = $this->greylisting($list); $list = $this->greylistingPerSP($list, $this->originalsp); } if (empty($list)) { throw new Exception('All IdPs has been filtered out. And no one left.'); } return $list; }
[ "protected", "function", "filterList", "(", "$", "list", ")", "{", "$", "conf", "=", "Configuration", "::", "getConfig", "(", "self", "::", "CONFIG_FILE_NAME", ")", ";", "$", "disableWhitelisting", "=", "$", "conf", "->", "getBoolean", "(", "self", "::", "...
Filter a list of entities according to any filters defined in the parent class, plus @param array $list A map of entities to filter. @return array The list in $list after filtering entities. @throws Exception if all IdPs are filtered out and no one left.
[ "Filter", "a", "list", "of", "entities", "according", "to", "any", "filters", "defined", "in", "the", "parent", "class", "plus" ]
f1d686f06472053a7cdb31f2b2776f9714779ee1
https://github.com/CESNET/perun-simplesamlphp-module/blob/f1d686f06472053a7cdb31f2b2776f9714779ee1/lib/Disco.php#L128-L151
train
CESNET/perun-simplesamlphp-module
lib/Disco.php
Disco.filterAddInstitutionList
protected function filterAddInstitutionList($list) { foreach ($list as $entityId => $idp) { if (in_array($entityId, $this->whitelist)) { unset($list[$entityId]); } } if (empty($list)) { throw new Exception('All IdPs has been filtered out. And no one left.'); } return $list; }
php
protected function filterAddInstitutionList($list) { foreach ($list as $entityId => $idp) { if (in_array($entityId, $this->whitelist)) { unset($list[$entityId]); } } if (empty($list)) { throw new Exception('All IdPs has been filtered out. And no one left.'); } return $list; }
[ "protected", "function", "filterAddInstitutionList", "(", "$", "list", ")", "{", "foreach", "(", "$", "list", "as", "$", "entityId", "=>", "$", "idp", ")", "{", "if", "(", "in_array", "(", "$", "entityId", ",", "$", "this", "->", "whitelist", ")", ")",...
Filter a list of entities for addInstitution app according to if entityID is whitelisted or not @param array $list A map of entities to filter. @return array The list in $list after filtering entities. @throws Exception if all IdPs are filtered out and no one left.
[ "Filter", "a", "list", "of", "entities", "for", "addInstitution", "app", "according", "to", "if", "entityID", "is", "whitelisted", "or", "not" ]
f1d686f06472053a7cdb31f2b2776f9714779ee1
https://github.com/CESNET/perun-simplesamlphp-module/blob/f1d686f06472053a7cdb31f2b2776f9714779ee1/lib/Disco.php#L160-L173
train
CESNET/perun-simplesamlphp-module
lib/Disco.php
Disco.removeAuthContextClassRefWithPrefix
public function removeAuthContextClassRefWithPrefix(&$state) { $conf = Configuration::getConfig(self::CONFIG_FILE_NAME); $prefix = $conf->getString(self::PROPNAME_PREFIX, null); if (is_null($prefix)) { return; } unset($state['saml:RequestedAuthnContext']['AuthnContextClassRef']); $array = array(); foreach ($this->authnContextClassRef as $value) { if (!(substr($value, 0, strlen($prefix)) === $prefix)) { array_push($array, $value); } } if (!empty($array)) { $state['saml:RequestedAuthnContext']['AuthnContextClassRef'] = $array; } }
php
public function removeAuthContextClassRefWithPrefix(&$state) { $conf = Configuration::getConfig(self::CONFIG_FILE_NAME); $prefix = $conf->getString(self::PROPNAME_PREFIX, null); if (is_null($prefix)) { return; } unset($state['saml:RequestedAuthnContext']['AuthnContextClassRef']); $array = array(); foreach ($this->authnContextClassRef as $value) { if (!(substr($value, 0, strlen($prefix)) === $prefix)) { array_push($array, $value); } } if (!empty($array)) { $state['saml:RequestedAuthnContext']['AuthnContextClassRef'] = $array; } }
[ "public", "function", "removeAuthContextClassRefWithPrefix", "(", "&", "$", "state", ")", "{", "$", "conf", "=", "Configuration", "::", "getConfig", "(", "self", "::", "CONFIG_FILE_NAME", ")", ";", "$", "prefix", "=", "$", "conf", "->", "getString", "(", "se...
This method remove all AuthnContextClassRef which start with prefix from configuration @param $state
[ "This", "method", "remove", "all", "AuthnContextClassRef", "which", "start", "with", "prefix", "from", "configuration" ]
f1d686f06472053a7cdb31f2b2776f9714779ee1
https://github.com/CESNET/perun-simplesamlphp-module/blob/f1d686f06472053a7cdb31f2b2776f9714779ee1/lib/Disco.php#L307-L326
train
jon48/webtrees-lib
src/Webtrees/Module/Certificates/Model/Certificate.php
Certificate.setSource
public function setSource($xref){ if($xref instanceof Source){ $this->source = $xref; } else { $this->source = Source::getInstance($xref, $this->tree); } }
php
public function setSource($xref){ if($xref instanceof Source){ $this->source = $xref; } else { $this->source = Source::getInstance($xref, $this->tree); } }
[ "public", "function", "setSource", "(", "$", "xref", ")", "{", "if", "(", "$", "xref", "instanceof", "Source", ")", "{", "$", "this", "->", "source", "=", "$", "xref", ";", "}", "else", "{", "$", "this", "->", "source", "=", "Source", "::", "getIns...
Define a source associated with the certificate @param string|Source $xref
[ "Define", "a", "source", "associated", "with", "the", "certificate" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/Certificates/Model/Certificate.php#L156-L162
train
jon48/webtrees-lib
src/Webtrees/Module/Certificates/Model/Certificate.php
Certificate.fetchALinkedSource
public function fetchALinkedSource(){ $sid = null; // Try to find in individual, then families, then other types of records. We are interested in the first available value. $ged = Database::prepare( 'SELECT i_gedcom AS gedrec FROM `##individuals`'. ' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); if(!$ged){ $ged = Database::prepare( 'SELECT f_gedcom AS gedrec FROM `##families`'. ' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); if(!$ged){ $ged = Database::prepare( 'SELECT o_gedcom AS gedrec FROM `##other`'. ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); } } //If a record has been found, parse it to find the source reference. if($ged){ $gedlines = explode("\n", $ged); $level = 0; $levelsource = -1; $sid_tmp=null; $sourcefound = false; foreach($gedlines as $gedline){ // Get the level $match = null; if (!$sourcefound && preg_match('~^('.WT_REGEX_INTEGER.') ~', $gedline, $match)) { $level = $match[1]; //If we are not any more within the context of a source, reset if($level <= $levelsource){ $levelsource = -1; $sid_tmp = null; } // If a source, get the level and the reference $match2 = null; if (preg_match('~^'.$level.' SOUR @('.WT_REGEX_XREF.')@$~', $gedline, $match2)) { $levelsource = $level; $sid_tmp=$match2[1]; } // If the image has be found, get the source reference and exit. $match3 = null; if($levelsource>=0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)){ $sid = $sid_tmp; $sourcefound = true; } } } } if($sid) $this->source = Source::getInstance($sid, $this->tree); return $this->source; }
php
public function fetchALinkedSource(){ $sid = null; // Try to find in individual, then families, then other types of records. We are interested in the first available value. $ged = Database::prepare( 'SELECT i_gedcom AS gedrec FROM `##individuals`'. ' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); if(!$ged){ $ged = Database::prepare( 'SELECT f_gedcom AS gedrec FROM `##families`'. ' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); if(!$ged){ $ged = Database::prepare( 'SELECT o_gedcom AS gedrec FROM `##other`'. ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); } } //If a record has been found, parse it to find the source reference. if($ged){ $gedlines = explode("\n", $ged); $level = 0; $levelsource = -1; $sid_tmp=null; $sourcefound = false; foreach($gedlines as $gedline){ // Get the level $match = null; if (!$sourcefound && preg_match('~^('.WT_REGEX_INTEGER.') ~', $gedline, $match)) { $level = $match[1]; //If we are not any more within the context of a source, reset if($level <= $levelsource){ $levelsource = -1; $sid_tmp = null; } // If a source, get the level and the reference $match2 = null; if (preg_match('~^'.$level.' SOUR @('.WT_REGEX_XREF.')@$~', $gedline, $match2)) { $levelsource = $level; $sid_tmp=$match2[1]; } // If the image has be found, get the source reference and exit. $match3 = null; if($levelsource>=0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)){ $sid = $sid_tmp; $sourcefound = true; } } } } if($sid) $this->source = Source::getInstance($sid, $this->tree); return $this->source; }
[ "public", "function", "fetchALinkedSource", "(", ")", "{", "$", "sid", "=", "null", ";", "// Try to find in individual, then families, then other types of records. We are interested in the first available value.", "$", "ged", "=", "Database", "::", "prepare", "(", "'SELECT i_ge...
Returns a unique source linked to the certificate @return Source|NULL Linked source
[ "Returns", "a", "unique", "source", "linked", "to", "the", "certificate" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/Certificates/Model/Certificate.php#L369-L435
train
c4studio/chronos
src/Chronos/Scaffolding/app/Exceptions/Handler.php
Handler.tokenMismatch
protected function tokenMismatch($request, TokenMismatchException $e) { // check if Chronos path or app if ($request && ($request->is('admin') || $request->is('admin/*'))) return response()->view("chronos::errors.token_mismatch", ['exception' => $e]); else return $this->convertExceptionToResponse($e); }
php
protected function tokenMismatch($request, TokenMismatchException $e) { // check if Chronos path or app if ($request && ($request->is('admin') || $request->is('admin/*'))) return response()->view("chronos::errors.token_mismatch", ['exception' => $e]); else return $this->convertExceptionToResponse($e); }
[ "protected", "function", "tokenMismatch", "(", "$", "request", ",", "TokenMismatchException", "$", "e", ")", "{", "// check if Chronos path or app", "if", "(", "$", "request", "&&", "(", "$", "request", "->", "is", "(", "'admin'", ")", "||", "$", "request", ...
Renders the token mismatch exception page. @param \Illuminate\Http\Request $request @param \Illuminate\Auth\AuthenticationException $e @return \Illuminate\Http\Response
[ "Renders", "the", "token", "mismatch", "exception", "page", "." ]
df7f3a9794afaade3bee8f6be1223c98e4936cb2
https://github.com/c4studio/chronos/blob/df7f3a9794afaade3bee8f6be1223c98e4936cb2/src/Chronos/Scaffolding/app/Exceptions/Handler.php#L107-L114
train
voslartomas/WebCMS2
libs/helpers/PriceFormatter.php
PriceFormatter.format
public static function format($price, $string = "%2n") { setlocale(LC_MONETARY, self::$locale); if (function_exists("money_format")) { return money_format($string, $price); } else { return $price; } }
php
public static function format($price, $string = "%2n") { setlocale(LC_MONETARY, self::$locale); if (function_exists("money_format")) { return money_format($string, $price); } else { return $price; } }
[ "public", "static", "function", "format", "(", "$", "price", ",", "$", "string", "=", "\"%2n\"", ")", "{", "setlocale", "(", "LC_MONETARY", ",", "self", "::", "$", "locale", ")", ";", "if", "(", "function_exists", "(", "\"money_format\"", ")", ")", "{", ...
Format the given price. @param type $price @param type $string @return type
[ "Format", "the", "given", "price", "." ]
b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf
https://github.com/voslartomas/WebCMS2/blob/b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf/libs/helpers/PriceFormatter.php#L28-L37
train
jon48/webtrees-lib
src/Webtrees/Functions/FunctionsPrint.php
FunctionsPrint.htmlFactPlaceIcon
public static function htmlFactPlaceIcon( \Fisharebest\Webtrees\Fact $fact, \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider ) { $place = $fact->getPlace(); if(!$place->isEmpty()) { $iconPlace= $mapProvider->getPlaceIcon($place); if($iconPlace && strlen($iconPlace) > 0){ return '<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>'; } } return ''; }
php
public static function htmlFactPlaceIcon( \Fisharebest\Webtrees\Fact $fact, \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider ) { $place = $fact->getPlace(); if(!$place->isEmpty()) { $iconPlace= $mapProvider->getPlaceIcon($place); if($iconPlace && strlen($iconPlace) > 0){ return '<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>'; } } return ''; }
[ "public", "static", "function", "htmlFactPlaceIcon", "(", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Fact", "$", "fact", ",", "\\", "MyArtJaub", "\\", "Webtrees", "\\", "Map", "\\", "MapProviderInterface", "$", "mapProvider", ")", "{", "$", "place", "=", ...
Return HTML code to include a flag icon in facts description @param \Fisharebest\Webtrees\Fact $fact Fact record @param \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider Map Provider @return string HTML code of the inserted flag
[ "Return", "HTML", "code", "to", "include", "a", "flag", "icon", "in", "facts", "description" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Functions/FunctionsPrint.php#L58-L70
train
jon48/webtrees-lib
src/Webtrees/Functions/FunctionsPrint.php
FunctionsPrint.htmlPlaceIcon
public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; }
php
public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; }
[ "public", "static", "function", "htmlPlaceIcon", "(", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Place", "$", "place", ",", "$", "icon_path", ",", "$", "size", "=", "50", ")", "{", "return", "'<img class=\"flag_gm_h'", ".", "$", "size", ".", "'\" src=\"'"...
Return HTML code to include a flag icon @param \Fisharebest\Webtrees\Place $place @param string $icon_path @param number $size @return string HTML code of the inserted flag
[ "Return", "HTML", "code", "to", "include", "a", "flag", "icon" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Functions/FunctionsPrint.php#L80-L82
train
jon48/webtrees-lib
src/Webtrees/Functions/FunctionsPrint.php
FunctionsPrint.htmlPlacesCloud
public static function htmlPlacesCloud($places, $totals, Tree $tree) { $items = array(); foreach ($places as $place => $count) { /** var \MyArtJaub\Webtrees\Place */ $dplace = Place::getIntance($place, $tree); $items[] = array( 'text' => $dplace->htmlFormattedName('%1 (%2)'), 'count' => $count, 'url' => $dplace->getDerivedPlace()->getURL() ); } return self::htmlListCloud($items, $totals); }
php
public static function htmlPlacesCloud($places, $totals, Tree $tree) { $items = array(); foreach ($places as $place => $count) { /** var \MyArtJaub\Webtrees\Place */ $dplace = Place::getIntance($place, $tree); $items[] = array( 'text' => $dplace->htmlFormattedName('%1 (%2)'), 'count' => $count, 'url' => $dplace->getDerivedPlace()->getURL() ); } return self::htmlListCloud($items, $totals); }
[ "public", "static", "function", "htmlPlacesCloud", "(", "$", "places", ",", "$", "totals", ",", "Tree", "$", "tree", ")", "{", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "places", "as", "$", "place", "=>", "$", "count", ")", "{...
Returns HTML code to include a place cloud @param array $places Array of places to display in the cloud @param bool $totals Display totals for a place @param \Fisharebest\Webtrees\Tree $tree Tree @return string Place Cloud HTML Code
[ "Returns", "HTML", "code", "to", "include", "a", "place", "cloud" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Functions/FunctionsPrint.php#L137-L151
train
jon48/webtrees-lib
src/Webtrees/Functions/FunctionsPrint.php
FunctionsPrint.formatFactPlaceShort
public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ $html=''; if ($fact === null) return $html; $place = $fact->getPlace(); if($place){ $dplace = new Place($place); $html .= $dplace->htmlFormattedName($format, $anchor); } return $html; }
php
public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ $html=''; if ($fact === null) return $html; $place = $fact->getPlace(); if($place){ $dplace = new Place($place); $html .= $dplace->htmlFormattedName($format, $anchor); } return $html; }
[ "public", "static", "function", "formatFactPlaceShort", "(", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Fact", "$", "fact", ",", "$", "format", ",", "$", "anchor", "=", "false", ")", "{", "$", "html", "=", "''", ";", "if", "(", "$", "fact", "===", ...
Format fact place to display short @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date @param string $format Format of the place @param boolean $anchor option to print a link to placelist @return string HTML code for short place
[ "Format", "fact", "place", "to", "display", "short" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Functions/FunctionsPrint.php#L218-L228
train
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.seoTitle
public function seoTitle($alternativeField = false) { if (!$alternativeField) { $alternativeField = config('gzero-cms.seo.alternative_title', 'title'); } $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]); // if alternative field is not empty if ($text) { return $this->translation['seo_title'] ? $this->removeNewLinesAndWhitespace($this->translation['seo_title']) : $text; } // show site name as default return option('general', 'site_name'); }
php
public function seoTitle($alternativeField = false) { if (!$alternativeField) { $alternativeField = config('gzero-cms.seo.alternative_title', 'title'); } $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]); // if alternative field is not empty if ($text) { return $this->translation['seo_title'] ? $this->removeNewLinesAndWhitespace($this->translation['seo_title']) : $text; } // show site name as default return option('general', 'site_name'); }
[ "public", "function", "seoTitle", "(", "$", "alternativeField", "=", "false", ")", "{", "if", "(", "!", "$", "alternativeField", ")", "{", "$", "alternativeField", "=", "config", "(", "'gzero-cms.seo.alternative_title'", ",", "'title'", ")", ";", "}", "$", "...
Return seoTitle of translation if exists otherwise return generated one @param mixed $alternativeField alternative field to display when seoTitle field is empty @return string
[ "Return", "seoTitle", "of", "translation", "if", "exists", "otherwise", "return", "generated", "one" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L235-L248
train
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.seoDescription
public function seoDescription($alternativeField = false) { $descLength = option('seo', 'desc_length', config('gzero.seo.desc_length', 160)); if (!$alternativeField) { $alternativeField = config('gzero-cms.seo.alternative_desc', 'body'); } // if SEO description is set if ($this->translation['seo_description']) { return $this->removeNewLinesAndWhitespace($this->translation['seo_description']); } $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]); // if alternative field is not empty if ($text) { return strlen($text) >= $descLength ? substr($text, 0, strpos($text, ' ', $descLength)) : $text; }; // show site description as default return option('general', 'site_desc'); }
php
public function seoDescription($alternativeField = false) { $descLength = option('seo', 'desc_length', config('gzero.seo.desc_length', 160)); if (!$alternativeField) { $alternativeField = config('gzero-cms.seo.alternative_desc', 'body'); } // if SEO description is set if ($this->translation['seo_description']) { return $this->removeNewLinesAndWhitespace($this->translation['seo_description']); } $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]); // if alternative field is not empty if ($text) { return strlen($text) >= $descLength ? substr($text, 0, strpos($text, ' ', $descLength)) : $text; }; // show site description as default return option('general', 'site_desc'); }
[ "public", "function", "seoDescription", "(", "$", "alternativeField", "=", "false", ")", "{", "$", "descLength", "=", "option", "(", "'seo'", ",", "'desc_length'", ",", "config", "(", "'gzero.seo.desc_length'", ",", "160", ")", ")", ";", "if", "(", "!", "$...
Return seoDescription of translation if exists otherwise return generated one @param mixed $alternativeField alternative field to display when seoDescription field is empty @return string
[ "Return", "seoDescription", "of", "translation", "if", "exists", "otherwise", "return", "generated", "one" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L258-L276
train
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.publishedAt
public function publishedAt() { $publishedAt = array_get($this->data, 'published_at', null); if ($publishedAt === null) { return trans('gzero-core::common.unknown'); } return $publishedAt; }
php
public function publishedAt() { $publishedAt = array_get($this->data, 'published_at', null); if ($publishedAt === null) { return trans('gzero-core::common.unknown'); } return $publishedAt; }
[ "public", "function", "publishedAt", "(", ")", "{", "$", "publishedAt", "=", "array_get", "(", "$", "this", "->", "data", ",", "'published_at'", ",", "null", ")", ";", "if", "(", "$", "publishedAt", "===", "null", ")", "{", "return", "trans", "(", "'gz...
This function returns formatted publish date @return string
[ "This", "function", "returns", "formatted", "publish", "date" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L291-L300
train
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.updatedAt
public function updatedAt() { $updatedAt = array_get($this->data, 'updated_at', null); if ($updatedAt === null) { return trans('gzero-core::common.unknown'); } return $updatedAt; }
php
public function updatedAt() { $updatedAt = array_get($this->data, 'updated_at', null); if ($updatedAt === null) { return trans('gzero-core::common.unknown'); } return $updatedAt; }
[ "public", "function", "updatedAt", "(", ")", "{", "$", "updatedAt", "=", "array_get", "(", "$", "this", "->", "data", ",", "'updated_at'", ",", "null", ")", ";", "if", "(", "$", "updatedAt", "===", "null", ")", "{", "return", "trans", "(", "'gzero-core...
This function returns formatted updated date @return string
[ "This", "function", "returns", "formatted", "updated", "date" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L307-L316
train
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.firstImageUrl
public function firstImageUrl($text, $default = null) { $url = $default; if (!empty($text)) { preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $text, $matches); } if (!empty($matches) && isset($matches[1])) { $url = $matches[1]; } return $url; }
php
public function firstImageUrl($text, $default = null) { $url = $default; if (!empty($text)) { preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $text, $matches); } if (!empty($matches) && isset($matches[1])) { $url = $matches[1]; } return $url; }
[ "public", "function", "firstImageUrl", "(", "$", "text", ",", "$", "default", "=", "null", ")", "{", "$", "url", "=", "$", "default", ";", "if", "(", "!", "empty", "(", "$", "text", ")", ")", "{", "preg_match", "(", "'/< *img[^>]*src *= *[\"\\']?([^\"\\'...
This function returns the first img url from provided text @param string $text text to get first image url from @param null $default default url to return if image is not found @return string first image url
[ "This", "function", "returns", "the", "first", "img", "url", "from", "provided", "text" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L347-L360
train
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.ancestorsNames
public function ancestorsNames() { $ancestors = explode('/', array_get($this->route, 'path')); if (empty($ancestors)) { return null; } array_pop($ancestors); return array_map('ucfirst', $ancestors); }
php
public function ancestorsNames() { $ancestors = explode('/', array_get($this->route, 'path')); if (empty($ancestors)) { return null; } array_pop($ancestors); return array_map('ucfirst', $ancestors); }
[ "public", "function", "ancestorsNames", "(", ")", "{", "$", "ancestors", "=", "explode", "(", "'/'", ",", "array_get", "(", "$", "this", "->", "route", ",", "'path'", ")", ")", ";", "if", "(", "empty", "(", "$", "ancestors", ")", ")", "{", "return", ...
This function returns names of all ancestors based on route path @return array ancestors names
[ "This", "function", "returns", "names", "of", "all", "ancestors", "based", "on", "route", "path" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L367-L378
train
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.getIntance
public static function getIntance($xref, Tree $tree, $gedcom = null){ $indi = \Fisharebest\Webtrees\Individual::getInstance($xref, $tree, $gedcom); if($indi){ return new Individual($indi); } return null; }
php
public static function getIntance($xref, Tree $tree, $gedcom = null){ $indi = \Fisharebest\Webtrees\Individual::getInstance($xref, $tree, $gedcom); if($indi){ return new Individual($indi); } return null; }
[ "public", "static", "function", "getIntance", "(", "$", "xref", ",", "Tree", "$", "tree", ",", "$", "gedcom", "=", "null", ")", "{", "$", "indi", "=", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Individual", "::", "getInstance", "(", "$", "xref", ","...
Extend \Fisharebest\Webtrees\Individual getInstance, in order to retrieve directly a object @param string $xref @param Tree $tree @param null|string $gedcom @return null|Individual
[ "Extend", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Individual", "getInstance", "in", "order", "to", "retrieve", "directly", "a", "object" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L46-L52
train
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.getEstimatedBirthPlace
public function getEstimatedBirthPlace($perc=false){ if($bplace = $this->gedcomrecord->getBirthPlace()){ if($perc){ return array ($bplace, 1); } else{ return $bplace; } } return null; }
php
public function getEstimatedBirthPlace($perc=false){ if($bplace = $this->gedcomrecord->getBirthPlace()){ if($perc){ return array ($bplace, 1); } else{ return $bplace; } } return null; }
[ "public", "function", "getEstimatedBirthPlace", "(", "$", "perc", "=", "false", ")", "{", "if", "(", "$", "bplace", "=", "$", "this", "->", "gedcomrecord", "->", "getBirthPlace", "(", ")", ")", "{", "if", "(", "$", "perc", ")", "{", "return", "array", ...
Returns an estimated birth place based on statistics on the base @param boolean $perc Should the coefficient of reliability be returned @return string|array Estimated birth place if found, null otherwise
[ "Returns", "an", "estimated", "birth", "place", "based", "on", "statistics", "on", "the", "base" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L97-L107
train
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.getSignificantPlace
public function getSignificantPlace(){ if($bplace = $this->gedcomrecord->getBirthPlace()){ return $bplace; } foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { if ($rplace) { return $rplace; } } if($dplace = $this->gedcomrecord->getDeathPlace()){ return $dplace; } foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { foreach ($fams->getAllEventPlaces('RESI') as $rplace) { if ($rplace) { return $rplace; } } } return null; }
php
public function getSignificantPlace(){ if($bplace = $this->gedcomrecord->getBirthPlace()){ return $bplace; } foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { if ($rplace) { return $rplace; } } if($dplace = $this->gedcomrecord->getDeathPlace()){ return $dplace; } foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { foreach ($fams->getAllEventPlaces('RESI') as $rplace) { if ($rplace) { return $rplace; } } } return null; }
[ "public", "function", "getSignificantPlace", "(", ")", "{", "if", "(", "$", "bplace", "=", "$", "this", "->", "gedcomrecord", "->", "getBirthPlace", "(", ")", ")", "{", "return", "$", "bplace", ";", "}", "foreach", "(", "$", "this", "->", "gedcomrecord",...
Returns a significant place for the individual @param boolean $perc Should the coefficient of reliability be returned @return string|array Estimated birth place if found, null otherwise
[ "Returns", "a", "significant", "place", "for", "the", "individual" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L115-L139
train
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.getSosaNumbers
public function getSosaNumbers(){ if($this->sosa === null) { $provider = new SosaProvider($this->gedcomrecord->getTree()); $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); } return $this->sosa; }
php
public function getSosaNumbers(){ if($this->sosa === null) { $provider = new SosaProvider($this->gedcomrecord->getTree()); $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); } return $this->sosa; }
[ "public", "function", "getSosaNumbers", "(", ")", "{", "if", "(", "$", "this", "->", "sosa", "===", "null", ")", "{", "$", "provider", "=", "new", "SosaProvider", "(", "$", "this", "->", "gedcomrecord", "->", "getTree", "(", ")", ")", ";", "$", "this...
Get the list of Sosa numbers for this individual This list is cached. @uses \MyArtJaub\Webtrees\Functions\ModuleManager @return array List of Sosa numbers
[ "Get", "the", "list", "of", "Sosa", "numbers", "for", "this", "individual", "This", "list", "is", "cached", "." ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L157-L163
train
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.isBirthSourced
public function isBirthSourced(){ if($this->is_birth_sourced !== null) return $this->is_birth_sourced; $this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT); return $this->is_birth_sourced; }
php
public function isBirthSourced(){ if($this->is_birth_sourced !== null) return $this->is_birth_sourced; $this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT); return $this->is_birth_sourced; }
[ "public", "function", "isBirthSourced", "(", ")", "{", "if", "(", "$", "this", "->", "is_birth_sourced", "!==", "null", ")", "return", "$", "this", "->", "is_birth_sourced", ";", "$", "this", "->", "is_birth_sourced", "=", "$", "this", "->", "isFactSourced",...
Check if this individual's birth is sourced @return int Level of sources
[ "Check", "if", "this", "individual", "s", "birth", "is", "sourced" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L170-L174
train
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.isDeathSourced
public function isDeathSourced(){ if($this->is_death_sourced !== null) return $this->is_death_sourced; $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); return $this->is_death_sourced; }
php
public function isDeathSourced(){ if($this->is_death_sourced !== null) return $this->is_death_sourced; $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); return $this->is_death_sourced; }
[ "public", "function", "isDeathSourced", "(", ")", "{", "if", "(", "$", "this", "->", "is_death_sourced", "!==", "null", ")", "return", "$", "this", "->", "is_death_sourced", ";", "$", "this", "->", "is_death_sourced", "=", "$", "this", "->", "isFactSourced",...
Check if this individual's death is sourced @return int Level of sources
[ "Check", "if", "this", "individual", "s", "death", "is", "sourced" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L181-L185
train
KnpLabs/packagist-api
src/Packagist/Api/Client.php
Client.respond
protected function respond($url) { $response = $this->request($url); $response = $this->parse($response); return $this->create($response); }
php
protected function respond($url) { $response = $this->request($url); $response = $this->parse($response); return $this->create($response); }
[ "protected", "function", "respond", "(", "$", "url", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "$", "url", ")", ";", "$", "response", "=", "$", "this", "->", "parse", "(", "$", "response", ")", ";", "return", "$", "this", ...
Execute the url request and parse the response @param string $url @return array|\Packagist\Api\Result\Package
[ "Execute", "the", "url", "request", "and", "parse", "the", "response" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Client.php#L168-L174
train
KnpLabs/packagist-api
src/Packagist/Api/Client.php
Client.request
protected function request($url) { if (null === $this->httpClient) { $this->httpClient = new HttpClient(); } return $this->httpClient ->get($url) ->getBody(); }
php
protected function request($url) { if (null === $this->httpClient) { $this->httpClient = new HttpClient(); } return $this->httpClient ->get($url) ->getBody(); }
[ "protected", "function", "request", "(", "$", "url", ")", "{", "if", "(", "null", "===", "$", "this", "->", "httpClient", ")", "{", "$", "this", "->", "httpClient", "=", "new", "HttpClient", "(", ")", ";", "}", "return", "$", "this", "->", "httpClien...
Execute the url request @param string $url @return \Psr\Http\Message\StreamInterface
[ "Execute", "the", "url", "request" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Client.php#L183-L192
train
KnpLabs/packagist-api
src/Packagist/Api/Client.php
Client.create
protected function create(array $data) { if (null === $this->resultFactory) { $this->resultFactory = new Factory(); } return $this->resultFactory->create($data); }
php
protected function create(array $data) { if (null === $this->resultFactory) { $this->resultFactory = new Factory(); } return $this->resultFactory->create($data); }
[ "protected", "function", "create", "(", "array", "$", "data", ")", "{", "if", "(", "null", "===", "$", "this", "->", "resultFactory", ")", "{", "$", "this", "->", "resultFactory", "=", "new", "Factory", "(", ")", ";", "}", "return", "$", "this", "->"...
Hydrate the knowing type depending on passed data @param array $data @return array|\Packagist\Api\Result\Package
[ "Hydrate", "the", "knowing", "type", "depending", "on", "passed", "data" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Client.php#L213-L220
train
KnpLabs/packagist-api
src/Packagist/Api/Result/Factory.php
Factory.create
public function create(array $data) { if (isset($data['results'])) { return $this->createSearchResults($data['results']); } elseif (isset($data['packages'])) { return $this->createSearchResults($data['packages']); } elseif (isset($data['package'])) { return $this->createPackageResults($data['package']); } elseif (isset($data['packageNames'])) { return $data['packageNames']; } throw new InvalidArgumentException('Invalid input data.'); }
php
public function create(array $data) { if (isset($data['results'])) { return $this->createSearchResults($data['results']); } elseif (isset($data['packages'])) { return $this->createSearchResults($data['packages']); } elseif (isset($data['package'])) { return $this->createPackageResults($data['package']); } elseif (isset($data['packageNames'])) { return $data['packageNames']; } throw new InvalidArgumentException('Invalid input data.'); }
[ "public", "function", "create", "(", "array", "$", "data", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'results'", "]", ")", ")", "{", "return", "$", "this", "->", "createSearchResults", "(", "$", "data", "[", "'results'", "]", ")", ";", ...
Analyse the data and transform to a known type @param array $data @throws InvalidArgumentException @return array|Package
[ "Analyse", "the", "data", "and", "transform", "to", "a", "known", "type" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Result/Factory.php#L22-L35
train
KnpLabs/packagist-api
src/Packagist/Api/Result/Factory.php
Factory.createSearchResults
public function createSearchResults(array $results) { $created = array(); foreach ($results as $key => $result) { $created[$key] = $this->createResult('Packagist\Api\Result\Result', $result); } return $created; }
php
public function createSearchResults(array $results) { $created = array(); foreach ($results as $key => $result) { $created[$key] = $this->createResult('Packagist\Api\Result\Result', $result); } return $created; }
[ "public", "function", "createSearchResults", "(", "array", "$", "results", ")", "{", "$", "created", "=", "array", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "key", "=>", "$", "result", ")", "{", "$", "created", "[", "$", "key", "]", ...
Create a collection of \Packagist\Api\Result\Result @param array $results @return array
[ "Create", "a", "collection", "of", "\\", "Packagist", "\\", "Api", "\\", "Result", "\\", "Result" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Result/Factory.php#L44-L52
train
KnpLabs/packagist-api
src/Packagist/Api/Result/Factory.php
Factory.createPackageResults
public function createPackageResults(array $package) { $created = array(); if (isset($package['maintainers']) && $package['maintainers']) { foreach ($package['maintainers'] as $key => $maintainer) { $package['maintainers'][$key] = $this->createResult('Packagist\Api\Result\Package\Maintainer', $maintainer); } } if (isset($package['downloads']) && $package['downloads']) { $package['downloads'] = $this->createResult('Packagist\Api\Result\Package\Downloads', $package['downloads']); } foreach ($package['versions'] as $branch => $version) { if (isset($version['authors']) && $version['authors']) { foreach ($version['authors'] as $key => $author) { $version['authors'][$key] = $this->createResult('Packagist\Api\Result\Package\Author', $author); } } if ($version['source']) { $version['source'] = $this->createResult('Packagist\Api\Result\Package\Source', $version['source']); } if (isset($version['dist']) && $version['dist']) { $version['dist'] = $this->createResult('Packagist\Api\Result\Package\Dist', $version['dist']); } $package['versions'][$branch] = $this->createResult('Packagist\Api\Result\Package\Version', $version); } $created = new Package(); $created->fromArray($package); return $created; }
php
public function createPackageResults(array $package) { $created = array(); if (isset($package['maintainers']) && $package['maintainers']) { foreach ($package['maintainers'] as $key => $maintainer) { $package['maintainers'][$key] = $this->createResult('Packagist\Api\Result\Package\Maintainer', $maintainer); } } if (isset($package['downloads']) && $package['downloads']) { $package['downloads'] = $this->createResult('Packagist\Api\Result\Package\Downloads', $package['downloads']); } foreach ($package['versions'] as $branch => $version) { if (isset($version['authors']) && $version['authors']) { foreach ($version['authors'] as $key => $author) { $version['authors'][$key] = $this->createResult('Packagist\Api\Result\Package\Author', $author); } } if ($version['source']) { $version['source'] = $this->createResult('Packagist\Api\Result\Package\Source', $version['source']); } if (isset($version['dist']) && $version['dist']) { $version['dist'] = $this->createResult('Packagist\Api\Result\Package\Dist', $version['dist']); } $package['versions'][$branch] = $this->createResult('Packagist\Api\Result\Package\Version', $version); } $created = new Package(); $created->fromArray($package); return $created; }
[ "public", "function", "createPackageResults", "(", "array", "$", "package", ")", "{", "$", "created", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "package", "[", "'maintainers'", "]", ")", "&&", "$", "package", "[", "'maintainers'", "]", ...
Parse array to \Packagist\Api\Result\Result @param array $package @return Package
[ "Parse", "array", "to", "\\", "Packagist", "\\", "Api", "\\", "Result", "\\", "Result" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Result/Factory.php#L61-L95
train
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Event/DaemonEvent.php
DaemonEvent.getCommandLastExceptionClassName
public function getCommandLastExceptionClassName() { $exception = $this->command->getLastException(); if (!is_null($exception)) { return get_class($exception); } return null; }
php
public function getCommandLastExceptionClassName() { $exception = $this->command->getLastException(); if (!is_null($exception)) { return get_class($exception); } return null; }
[ "public", "function", "getCommandLastExceptionClassName", "(", ")", "{", "$", "exception", "=", "$", "this", "->", "command", "->", "getLastException", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "exception", ")", ")", "{", "return", "get_class", "...
Gets last exception class name. @return string|null
[ "Gets", "last", "exception", "class", "name", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Event/DaemonEvent.php#L84-L93
train
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.configureDaemonDefinition
private function configureDaemonDefinition(): void { $this->addOption('run-once', null, InputOption::VALUE_NONE, 'Run the command just once.'); $this->addOption('run-max', null, InputOption::VALUE_OPTIONAL, 'Run the command x time.'); $this->addOption('memory-max', null, InputOption::VALUE_OPTIONAL, 'Gracefully stop running command when given memory volume, in bytes, is reached.', 0); $this->addOption('shutdown-on-exception', null, InputOption::VALUE_NONE, 'Ask for shutdown if an exception is thrown.'); $this->addOption('show-exceptions', null, InputOption::VALUE_NONE, 'Display exception on command output.'); }
php
private function configureDaemonDefinition(): void { $this->addOption('run-once', null, InputOption::VALUE_NONE, 'Run the command just once.'); $this->addOption('run-max', null, InputOption::VALUE_OPTIONAL, 'Run the command x time.'); $this->addOption('memory-max', null, InputOption::VALUE_OPTIONAL, 'Gracefully stop running command when given memory volume, in bytes, is reached.', 0); $this->addOption('shutdown-on-exception', null, InputOption::VALUE_NONE, 'Ask for shutdown if an exception is thrown.'); $this->addOption('show-exceptions', null, InputOption::VALUE_NONE, 'Display exception on command output.'); }
[ "private", "function", "configureDaemonDefinition", "(", ")", ":", "void", "{", "$", "this", "->", "addOption", "(", "'run-once'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Run the command just once.'", ")", ";", "$", "this", "->", "addOption",...
Add daemon options to the command definition.
[ "Add", "daemon", "options", "to", "the", "command", "definition", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L133-L140
train
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.configureEvents
protected function configureEvents(): self { $container = $this->getContainer(); $key = 'm6web_daemon.iterations_events'; if ($container->hasParameter($key)) { $this->iterationsEvents = $container->getParameter($key); } return $this; }
php
protected function configureEvents(): self { $container = $this->getContainer(); $key = 'm6web_daemon.iterations_events'; if ($container->hasParameter($key)) { $this->iterationsEvents = $container->getParameter($key); } return $this; }
[ "protected", "function", "configureEvents", "(", ")", ":", "self", "{", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "$", "key", "=", "'m6web_daemon.iterations_events'", ";", "if", "(", "$", "container", "->", "hasParameter", "(",...
Retrieve configured events. @return DaemonCommand
[ "Retrieve", "configured", "events", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L258-L268
train
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.dispatchEvent
protected function dispatchEvent(string $eventName): self { $dispatcher = $this->getEventDispatcher(); if (!is_null($dispatcher)) { $time = !is_null($this->startTime) ? microtime(true) - $this->startTime : 0; $event = new DaemonEvent($this); $event->setExecutionTime($time); $dispatcher->dispatch($eventName, $event); } return $this; }
php
protected function dispatchEvent(string $eventName): self { $dispatcher = $this->getEventDispatcher(); if (!is_null($dispatcher)) { $time = !is_null($this->startTime) ? microtime(true) - $this->startTime : 0; $event = new DaemonEvent($this); $event->setExecutionTime($time); $dispatcher->dispatch($eventName, $event); } return $this; }
[ "protected", "function", "dispatchEvent", "(", "string", "$", "eventName", ")", ":", "self", "{", "$", "dispatcher", "=", "$", "this", "->", "getEventDispatcher", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "dispatcher", ")", ")", "{", "$", "ti...
Dispatch a daemon event. @param string $eventName @return DaemonCommand
[ "Dispatch", "a", "daemon", "event", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L276-L289
train
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.callIterationsIntervalCallbacks
protected function callIterationsIntervalCallbacks(InputInterface $input, OutputInterface $output) { foreach ($this->iterationsIntervalCallbacks as $iterationsIntervalCallback) { if (($this->getLoopCount() + 1) % $iterationsIntervalCallback['interval'] === 0) { call_user_func($iterationsIntervalCallback['callable'], $input, $output); } } }
php
protected function callIterationsIntervalCallbacks(InputInterface $input, OutputInterface $output) { foreach ($this->iterationsIntervalCallbacks as $iterationsIntervalCallback) { if (($this->getLoopCount() + 1) % $iterationsIntervalCallback['interval'] === 0) { call_user_func($iterationsIntervalCallback['callable'], $input, $output); } } }
[ "protected", "function", "callIterationsIntervalCallbacks", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "foreach", "(", "$", "this", "->", "iterationsIntervalCallbacks", "as", "$", "iterationsIntervalCallback", ")", "{", "if",...
Execute callbacks after every iteration interval. @param InputInterface $input @param OutputInterface $output
[ "Execute", "callbacks", "after", "every", "iteration", "interval", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L369-L376
train
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.dispatchConfigurationEvents
protected function dispatchConfigurationEvents(): self { foreach ($this->iterationsEvents as $event) { if (!($this->loopCount % $event['count'])) { $this->dispatchEvent($event['name']); } } return $this; }
php
protected function dispatchConfigurationEvents(): self { foreach ($this->iterationsEvents as $event) { if (!($this->loopCount % $event['count'])) { $this->dispatchEvent($event['name']); } } return $this; }
[ "protected", "function", "dispatchConfigurationEvents", "(", ")", ":", "self", "{", "foreach", "(", "$", "this", "->", "iterationsEvents", "as", "$", "event", ")", "{", "if", "(", "!", "(", "$", "this", "->", "loopCount", "%", "$", "event", "[", "'count'...
Dispatch configured events. @return DaemonCommand
[ "Dispatch", "configured", "events", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L469-L478
train
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.isLastLoop
protected function isLastLoop(): bool { // Count loop if (!is_null($this->getLoopMax()) && ($this->getLoopCount() >= $this->getLoopMax())) { $this->requestShutdown(); } // Memory if ($this->memoryMax > 0 && memory_get_peak_usage(true) >= $this->memoryMax) { $this->dispatchEvent(DaemonEvents::DAEMON_LOOP_MAX_MEMORY_REACHED); $this->requestShutdown(); } return $this->isShutdownRequested(); }
php
protected function isLastLoop(): bool { // Count loop if (!is_null($this->getLoopMax()) && ($this->getLoopCount() >= $this->getLoopMax())) { $this->requestShutdown(); } // Memory if ($this->memoryMax > 0 && memory_get_peak_usage(true) >= $this->memoryMax) { $this->dispatchEvent(DaemonEvents::DAEMON_LOOP_MAX_MEMORY_REACHED); $this->requestShutdown(); } return $this->isShutdownRequested(); }
[ "protected", "function", "isLastLoop", "(", ")", ":", "bool", "{", "// Count loop", "if", "(", "!", "is_null", "(", "$", "this", "->", "getLoopMax", "(", ")", ")", "&&", "(", "$", "this", "->", "getLoopCount", "(", ")", ">=", "$", "this", "->", "getL...
Return true after the last loop. @return bool
[ "Return", "true", "after", "the", "last", "loop", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L485-L499
train
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.addIterationsIntervalCallback
public function addIterationsIntervalCallback($iterationsInterval, callable $onIterationsInterval) { if (!is_int($iterationsInterval) || ($iterationsInterval <= 0)) { throw new \InvalidArgumentException('Iteration interval must be a positive integer'); } $this->iterationsIntervalCallbacks[] = ['interval' => $iterationsInterval, 'callable' => $onIterationsInterval,]; }
php
public function addIterationsIntervalCallback($iterationsInterval, callable $onIterationsInterval) { if (!is_int($iterationsInterval) || ($iterationsInterval <= 0)) { throw new \InvalidArgumentException('Iteration interval must be a positive integer'); } $this->iterationsIntervalCallbacks[] = ['interval' => $iterationsInterval, 'callable' => $onIterationsInterval,]; }
[ "public", "function", "addIterationsIntervalCallback", "(", "$", "iterationsInterval", ",", "callable", "$", "onIterationsInterval", ")", "{", "if", "(", "!", "is_int", "(", "$", "iterationsInterval", ")", "||", "(", "$", "iterationsInterval", "<=", "0", ")", ")...
Add your own callback after every iteration interval. @param int $iterationsInterval @param callable $onIterationsInterval
[ "Add", "your", "own", "callback", "after", "every", "iteration", "interval", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L615-L622
train
TiendaNube/tiendanube-php-sdk
src/TiendaNube/Auth.php
Auth.request_access_token
public function request_access_token($code){ $params = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'code' => $code, 'grant_type' => 'authorization_code', ]; $response = $this->requests->post($this->auth_url, [], $params); if (!$response->success){ throw new Auth\Exception('Auth url returned with status code ' . $response->status_code); } $body = json_decode($response->body); if (isset($body->error)){ throw new Auth\Exception("[{$body->error}] {$body->error_description}"); } return [ 'store_id' => $body->user_id, 'access_token' => $body->access_token, 'scope' => $body->scope, ]; }
php
public function request_access_token($code){ $params = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'code' => $code, 'grant_type' => 'authorization_code', ]; $response = $this->requests->post($this->auth_url, [], $params); if (!$response->success){ throw new Auth\Exception('Auth url returned with status code ' . $response->status_code); } $body = json_decode($response->body); if (isset($body->error)){ throw new Auth\Exception("[{$body->error}] {$body->error_description}"); } return [ 'store_id' => $body->user_id, 'access_token' => $body->access_token, 'scope' => $body->scope, ]; }
[ "public", "function", "request_access_token", "(", "$", "code", ")", "{", "$", "params", "=", "[", "'client_id'", "=>", "$", "this", "->", "client_id", ",", "'client_secret'", "=>", "$", "this", "->", "client_secret", ",", "'code'", "=>", "$", "code", ",",...
Obtain a permanent access token from an authorization code. @param string $code Authorization code retrieved from the redirect URI.
[ "Obtain", "a", "permanent", "access", "token", "from", "an", "authorization", "code", "." ]
7e2c025fafdc942d5ec334da133896f4c918e8e8
https://github.com/TiendaNube/tiendanube-php-sdk/blob/7e2c025fafdc942d5ec334da133896f4c918e8e8/src/TiendaNube/Auth.php#L50-L73
train
TiendaNube/tiendanube-php-sdk
src/TiendaNube/API.php
API.get
public function get($path, $params = null){ $url_params = ''; if (is_array($params)){ $url_params = '?' . http_build_query($params); } return $this->_call('GET', $path . $url_params); }
php
public function get($path, $params = null){ $url_params = ''; if (is_array($params)){ $url_params = '?' . http_build_query($params); } return $this->_call('GET', $path . $url_params); }
[ "public", "function", "get", "(", "$", "path", ",", "$", "params", "=", "null", ")", "{", "$", "url_params", "=", "''", ";", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "$", "url_params", "=", "'?'", ".", "http_build_query", "(", "$",...
Make a GET request to the specified path. @param string $path The path to the desired resource @param array $params Optional parameters to send in the query string @return TiendaNube/API/Response
[ "Make", "a", "GET", "request", "to", "the", "specified", "path", "." ]
7e2c025fafdc942d5ec334da133896f4c918e8e8
https://github.com/TiendaNube/tiendanube-php-sdk/blob/7e2c025fafdc942d5ec334da133896f4c918e8e8/src/TiendaNube/API.php#L38-L45
train
TiendaNube/tiendanube-php-sdk
src/TiendaNube/API.php
API.post
public function post($path, $params = []){ $json = json_encode($params); return $this->_call('POST', $path, $json); }
php
public function post($path, $params = []){ $json = json_encode($params); return $this->_call('POST', $path, $json); }
[ "public", "function", "post", "(", "$", "path", ",", "$", "params", "=", "[", "]", ")", "{", "$", "json", "=", "json_encode", "(", "$", "params", ")", ";", "return", "$", "this", "->", "_call", "(", "'POST'", ",", "$", "path", ",", "$", "json", ...
Make a POST request to the specified path. @param string $path The path to the desired resource @param array $params Parameters to send in the POST data @return TiendaNube/API/Response
[ "Make", "a", "POST", "request", "to", "the", "specified", "path", "." ]
7e2c025fafdc942d5ec334da133896f4c918e8e8
https://github.com/TiendaNube/tiendanube-php-sdk/blob/7e2c025fafdc942d5ec334da133896f4c918e8e8/src/TiendaNube/API.php#L54-L58
train
TiendaNube/tiendanube-php-sdk
src/TiendaNube/API.php
API.put
public function put($path, $params = []){ $json = json_encode($params); return $this->_call('PUT', $path, $json); }
php
public function put($path, $params = []){ $json = json_encode($params); return $this->_call('PUT', $path, $json); }
[ "public", "function", "put", "(", "$", "path", ",", "$", "params", "=", "[", "]", ")", "{", "$", "json", "=", "json_encode", "(", "$", "params", ")", ";", "return", "$", "this", "->", "_call", "(", "'PUT'", ",", "$", "path", ",", "$", "json", "...
Make a PUT request to the specified path. @param string $path The path to the desired resource @param array $params Parameters to send in the PUT data @return TiendaNube/API/Response
[ "Make", "a", "PUT", "request", "to", "the", "specified", "path", "." ]
7e2c025fafdc942d5ec334da133896f4c918e8e8
https://github.com/TiendaNube/tiendanube-php-sdk/blob/7e2c025fafdc942d5ec334da133896f4c918e8e8/src/TiendaNube/API.php#L67-L71
train
teamdeeson/wardenapi
src/Api.php
Api.getPublicKey
public function getPublicKey() { if (empty($this->wardenPublicKey)) { $result = $this->request('/public-key'); $this->wardenPublicKey = base64_decode($result->getBody()); } return $this->wardenPublicKey; }
php
public function getPublicKey() { if (empty($this->wardenPublicKey)) { $result = $this->request('/public-key'); $this->wardenPublicKey = base64_decode($result->getBody()); } return $this->wardenPublicKey; }
[ "public", "function", "getPublicKey", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "wardenPublicKey", ")", ")", "{", "$", "result", "=", "$", "this", "->", "request", "(", "'/public-key'", ")", ";", "$", "this", "->", "wardenPublicKey", "...
Get the public key. @throws WardenBadResponseException If the response status was not 200
[ "Get", "the", "public", "key", "." ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L109-L117
train
teamdeeson/wardenapi
src/Api.php
Api.isValidWardenToken
public function isValidWardenToken($encryptedRemoteToken, $timestamp) { $envelope = json_decode(base64_decode($encryptedRemoteToken)); if (!is_object($envelope) || empty($envelope->time) || empty($envelope->signature)) { return FALSE; } $remoteTimestamp = base64_decode($envelope->time); if (!is_numeric($remoteTimestamp) || ($remoteTimestamp > $timestamp + 20) || ($remoteTimestamp < $timestamp - 20) ) { return FALSE; } $result = openssl_verify($remoteTimestamp, base64_decode($envelope->signature), $this->getPublicKey()); return $result === 1; }
php
public function isValidWardenToken($encryptedRemoteToken, $timestamp) { $envelope = json_decode(base64_decode($encryptedRemoteToken)); if (!is_object($envelope) || empty($envelope->time) || empty($envelope->signature)) { return FALSE; } $remoteTimestamp = base64_decode($envelope->time); if (!is_numeric($remoteTimestamp) || ($remoteTimestamp > $timestamp + 20) || ($remoteTimestamp < $timestamp - 20) ) { return FALSE; } $result = openssl_verify($remoteTimestamp, base64_decode($envelope->signature), $this->getPublicKey()); return $result === 1; }
[ "public", "function", "isValidWardenToken", "(", "$", "encryptedRemoteToken", ",", "$", "timestamp", ")", "{", "$", "envelope", "=", "json_decode", "(", "base64_decode", "(", "$", "encryptedRemoteToken", ")", ")", ";", "if", "(", "!", "is_object", "(", "$", ...
Check the validity of a token sent from Warden. To prove a request came from the Warden application, Warden encrypts the current timestamp using its private key which can be decrypted with its public key. Only the true Warden can produce the encrypted message. Since it is possible to reply the token, the token only lasts for 20 seconds. @param string $encryptedRemoteToken The token sent from the warden site which has been encrypted with Warden's private key. @return bool TRUE if we can trust the token.
[ "Check", "the", "validity", "of", "a", "token", "sent", "from", "Warden", "." ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L135-L153
train
teamdeeson/wardenapi
src/Api.php
Api.encrypt
public function encrypt($data) { $plaintext = json_encode($data); $public_key = $this->getPublicKey(); $result = openssl_seal($plaintext, $message, $keys, array($public_key)); if ($result === FALSE || empty($keys[0]) || empty($message) || $message === $plaintext) { throw new EncryptionException('Unable to encrypt a message: ' . openssl_error_string()); } $envelope = (object) array( 'key' => base64_encode($keys[0]), 'message' => base64_encode($message), ); return base64_encode(json_encode($envelope)); }
php
public function encrypt($data) { $plaintext = json_encode($data); $public_key = $this->getPublicKey(); $result = openssl_seal($plaintext, $message, $keys, array($public_key)); if ($result === FALSE || empty($keys[0]) || empty($message) || $message === $plaintext) { throw new EncryptionException('Unable to encrypt a message: ' . openssl_error_string()); } $envelope = (object) array( 'key' => base64_encode($keys[0]), 'message' => base64_encode($message), ); return base64_encode(json_encode($envelope)); }
[ "public", "function", "encrypt", "(", "$", "data", ")", "{", "$", "plaintext", "=", "json_encode", "(", "$", "data", ")", ";", "$", "public_key", "=", "$", "this", "->", "getPublicKey", "(", ")", ";", "$", "result", "=", "openssl_seal", "(", "$", "pl...
Encrypt a plaintext message. @param mixed $data The data to encrypt for transport. @return string The encoded message @throws EncryptionException If there is a problem with the encryption process. @throws WardenBadResponseException If the response status from Warden was not 200 when retrieving the public key.
[ "Encrypt", "a", "plaintext", "message", "." ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L170-L187
train
teamdeeson/wardenapi
src/Api.php
Api.decrypt
public function decrypt($cypherText) { $envelope = json_decode(base64_decode($cypherText)); if (!is_object($envelope) || empty($envelope->key) || empty($envelope->message)) { throw new EncryptionException('Encrypted message is not understood'); } $key = base64_decode($envelope->key); $message = base64_decode($envelope->message); $decrypted = ''; $result = openssl_open($message, $decrypted, $key, $this->getPublicKey()); if ($result === FALSE) { throw new EncryptionException('Unable to decrypt a message: ' . openssl_error_string()); } return json_decode($decrypted); }
php
public function decrypt($cypherText) { $envelope = json_decode(base64_decode($cypherText)); if (!is_object($envelope) || empty($envelope->key) || empty($envelope->message)) { throw new EncryptionException('Encrypted message is not understood'); } $key = base64_decode($envelope->key); $message = base64_decode($envelope->message); $decrypted = ''; $result = openssl_open($message, $decrypted, $key, $this->getPublicKey()); if ($result === FALSE) { throw new EncryptionException('Unable to decrypt a message: ' . openssl_error_string()); } return json_decode($decrypted); }
[ "public", "function", "decrypt", "(", "$", "cypherText", ")", "{", "$", "envelope", "=", "json_decode", "(", "base64_decode", "(", "$", "cypherText", ")", ")", ";", "if", "(", "!", "is_object", "(", "$", "envelope", ")", "||", "empty", "(", "$", "envel...
Decrypt a message which was encrypted with the Warden private key. @param string $cypherText The encrypted text @return mixed The original data @throws EncryptionException If there was a problem with the decryption process. @throws WardenBadResponseException If the response status from Warden was not 200 when retrieving the public key.
[ "Decrypt", "a", "message", "which", "was", "encrypted", "with", "the", "Warden", "private", "key", "." ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L203-L221
train
teamdeeson/wardenapi
src/Api.php
Api.request
public function request($path, $content = '') { $url = $this->getWardenUrl() . $path; $options = []; if ($this->hasBasicAuthentication()) { $options['auth'] = [ $this->getUsername(), $this->getPassword()]; } $method = 'GET'; if (!empty($content)) { $method = 'POST'; $options['body'] = $content; } if (!empty($this->hasCertificatePath())) { $options['cert'] = $this->getCertificatePath(); } $client = new Client(); $res = $client->request($method, $url, $options); if ($res->getStatusCode() !== 200) { throw new WardenBadResponseException('Unable to communicate with Warden (' . $res->getStatusCode() . ') ' . $res->getReasonPhrase()); } return $res; }
php
public function request($path, $content = '') { $url = $this->getWardenUrl() . $path; $options = []; if ($this->hasBasicAuthentication()) { $options['auth'] = [ $this->getUsername(), $this->getPassword()]; } $method = 'GET'; if (!empty($content)) { $method = 'POST'; $options['body'] = $content; } if (!empty($this->hasCertificatePath())) { $options['cert'] = $this->getCertificatePath(); } $client = new Client(); $res = $client->request($method, $url, $options); if ($res->getStatusCode() !== 200) { throw new WardenBadResponseException('Unable to communicate with Warden (' . $res->getStatusCode() . ') ' . $res->getReasonPhrase()); } return $res; }
[ "public", "function", "request", "(", "$", "path", ",", "$", "content", "=", "''", ")", "{", "$", "url", "=", "$", "this", "->", "getWardenUrl", "(", ")", ".", "$", "path", ";", "$", "options", "=", "[", "]", ";", "if", "(", "$", "this", "->", ...
Send a message to warden @param string $path The query path including the leading slash (e.g. '/public-key') @param string $content The body of the request. If this is not empty, the request is a post. @return ResponseInterface The response object @throws WardenBadResponseException If the response status was not 200
[ "Send", "a", "message", "to", "warden" ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L250-L278
train
yawik/jobs
src/Entity/Job.php
Job.getCompany
public function getCompany($useOrganizationEntity = true) { if ($this->organization && $useOrganizationEntity) { return $this->organization->getOrganizationName()->getName(); } return $this->company; }
php
public function getCompany($useOrganizationEntity = true) { if ($this->organization && $useOrganizationEntity) { return $this->organization->getOrganizationName()->getName(); } return $this->company; }
[ "public", "function", "getCompany", "(", "$", "useOrganizationEntity", "=", "true", ")", "{", "if", "(", "$", "this", "->", "organization", "&&", "$", "useOrganizationEntity", ")", "{", "return", "$", "this", "->", "organization", "->", "getOrganizationName", ...
Gets the name oof the company. If there is an organization assigned to the job posting. Take the name of the organization. @param bool $useOrganizationEntity Get the name from the organization entity, if it is available. @see \Jobs\Entity\JobInterface::getCompany() @return string
[ "Gets", "the", "name", "oof", "the", "company", ".", "If", "there", "is", "an", "organization", "assigned", "to", "the", "job", "posting", ".", "Take", "the", "name", "of", "the", "organization", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Job.php#L419-L426
train
yawik/jobs
src/Entity/Job.php
Job.changeStatus
public function changeStatus($status, $message = '[System]') { $this->setStatus($status); $status = $this->getStatus(); // ensure StatusEntity $history = new History($status, $message); $this->getHistory()->add($history); return $this; }
php
public function changeStatus($status, $message = '[System]') { $this->setStatus($status); $status = $this->getStatus(); // ensure StatusEntity $history = new History($status, $message); $this->getHistory()->add($history); return $this; }
[ "public", "function", "changeStatus", "(", "$", "status", ",", "$", "message", "=", "'[System]'", ")", "{", "$", "this", "->", "setStatus", "(", "$", "status", ")", ";", "$", "status", "=", "$", "this", "->", "getStatus", "(", ")", ";", "// ensure Stat...
Modifies the state of an application. Creates a history entry. @param StatusInterface|string $status @param string $message @return Job
[ "Modifies", "the", "state", "of", "an", "application", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Job.php#L705-L714
train
yawik/jobs
src/Entity/Job.php
Job.getLogoRef
public function getLogoRef() { /** @var $organization \Organizations\Entity\Organization */ $organization = $this->organization; if (is_object($organization) && $organization->getImage()) { $organizationImage = $organization->getImage(); return "/file/Organizations.OrganizationImage/" . $organizationImage->getId(); } return $this->logoRef; }
php
public function getLogoRef() { /** @var $organization \Organizations\Entity\Organization */ $organization = $this->organization; if (is_object($organization) && $organization->getImage()) { $organizationImage = $organization->getImage(); return "/file/Organizations.OrganizationImage/" . $organizationImage->getId(); } return $this->logoRef; }
[ "public", "function", "getLogoRef", "(", ")", "{", "/** @var $organization \\Organizations\\Entity\\Organization */", "$", "organization", "=", "$", "this", "->", "organization", ";", "if", "(", "is_object", "(", "$", "organization", ")", "&&", "$", "organization", ...
returns an uri to the organization logo. @return string
[ "returns", "an", "uri", "to", "the", "organization", "logo", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Job.php#L863-L872
train
yawik/jobs
src/Options/ProviderOptions.php
ProviderOptions.getChannel
public function getChannel($key) { if (array_key_exists($key, $this->channels)) { return $this->channels[$key]; } return null; }
php
public function getChannel($key) { if (array_key_exists($key, $this->channels)) { return $this->channels[$key]; } return null; }
[ "public", "function", "getChannel", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "channels", ")", ")", "{", "return", "$", "this", "->", "channels", "[", "$", "key", "]", ";", "}", "return", "nu...
Get a channel by "key" @param string $key @return ChannelOptions
[ "Get", "a", "channel", "by", "key" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Options/ProviderOptions.php#L66-L72
train
yawik/jobs
src/Filter/ViewModelTemplateFilterJob.php
ViewModelTemplateFilterJob.extract
protected function extract($job) { $this->job = $job; $this->getJsonLdHelper()->setJob($job); $this->setApplyData(); $this->setOrganizationInfo(); $this->setLocation(); $this->setDescription(); $this->setTemplate(); $this->setTemplateDefaultValues(); $this->container['descriptionEditable'] = $job->getTemplateValues()->getDescription(); $this->container['benefits'] = $job->getTemplateValues()->getBenefits(); $this->container['requirements'] = $job->getTemplateValues()->getRequirements(); $this->container['qualifications'] = $job->getTemplateValues()->getQualifications(); $this->container['title'] = $job->getTemplateValues()->getTitle(); $this->container['headTitle'] = strip_tags($job->getTemplateValues()->getTitle()); $this->container['uriApply'] = $this->container['applyData']['uri']; $this->container['contactEmail'] = strip_tags($job->getContactEmail()); $this->container['html'] = $job->getTemplateValues()->getHtml(); $this->container['jobId'] = $job->getId(); $this->container['uriJob'] = $this->urlPlugin->fromRoute( 'lang/jobs/view', [], [ 'query' => [ 'id' => $job->getId() ], 'force_canonical' => true ] ); return $this; }
php
protected function extract($job) { $this->job = $job; $this->getJsonLdHelper()->setJob($job); $this->setApplyData(); $this->setOrganizationInfo(); $this->setLocation(); $this->setDescription(); $this->setTemplate(); $this->setTemplateDefaultValues(); $this->container['descriptionEditable'] = $job->getTemplateValues()->getDescription(); $this->container['benefits'] = $job->getTemplateValues()->getBenefits(); $this->container['requirements'] = $job->getTemplateValues()->getRequirements(); $this->container['qualifications'] = $job->getTemplateValues()->getQualifications(); $this->container['title'] = $job->getTemplateValues()->getTitle(); $this->container['headTitle'] = strip_tags($job->getTemplateValues()->getTitle()); $this->container['uriApply'] = $this->container['applyData']['uri']; $this->container['contactEmail'] = strip_tags($job->getContactEmail()); $this->container['html'] = $job->getTemplateValues()->getHtml(); $this->container['jobId'] = $job->getId(); $this->container['uriJob'] = $this->urlPlugin->fromRoute( 'lang/jobs/view', [], [ 'query' => [ 'id' => $job->getId() ], 'force_canonical' => true ] ); return $this; }
[ "protected", "function", "extract", "(", "$", "job", ")", "{", "$", "this", "->", "job", "=", "$", "job", ";", "$", "this", "->", "getJsonLdHelper", "(", ")", "->", "setJob", "(", "$", "job", ")", ";", "$", "this", "->", "setApplyData", "(", ")", ...
assign the form-elements to the template @param \Jobs\Entity\Job $job @return $this
[ "assign", "the", "form", "-", "elements", "to", "the", "template" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Filter/ViewModelTemplateFilterJob.php#L27-L59
train
yawik/jobs
src/Entity/AtsMode.php
AtsMode.setMode
public function setMode($mode) { $validModes = array( self::MODE_INTERN, self::MODE_URI, self::MODE_EMAIL, self::MODE_NONE, ); if (!in_array($mode, $validModes)) { throw new \InvalidArgumentException('Unknown value for ats mode.'); } $this->mode = $mode; return $this; }
php
public function setMode($mode) { $validModes = array( self::MODE_INTERN, self::MODE_URI, self::MODE_EMAIL, self::MODE_NONE, ); if (!in_array($mode, $validModes)) { throw new \InvalidArgumentException('Unknown value for ats mode.'); } $this->mode = $mode; return $this; }
[ "public", "function", "setMode", "(", "$", "mode", ")", "{", "$", "validModes", "=", "array", "(", "self", "::", "MODE_INTERN", ",", "self", "::", "MODE_URI", ",", "self", "::", "MODE_EMAIL", ",", "self", "::", "MODE_NONE", ",", ")", ";", "if", "(", ...
Sets the ATS mode. @throws \InvalidArgumentException
[ "Sets", "the", "ATS", "mode", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/AtsMode.php#L95-L111
train
yawik/jobs
src/Listener/MailSender.php
MailSender.onJobCreated
public function onJobCreated(JobEvent $e) { $job = $e->getJobEntity(); $this->sendMail( $job, 'mail/job-created', /*@translate*/ 'A new job opening was created', /*adminMail*/ true ); $this->sendMail( $job, 'mail/job-pending', /*@translate*/ 'Your Job have been wrapped up for approval' ); }
php
public function onJobCreated(JobEvent $e) { $job = $e->getJobEntity(); $this->sendMail( $job, 'mail/job-created', /*@translate*/ 'A new job opening was created', /*adminMail*/ true ); $this->sendMail( $job, 'mail/job-pending', /*@translate*/ 'Your Job have been wrapped up for approval' ); }
[ "public", "function", "onJobCreated", "(", "JobEvent", "$", "e", ")", "{", "$", "job", "=", "$", "e", "->", "getJobEntity", "(", ")", ";", "$", "this", "->", "sendMail", "(", "$", "job", ",", "'mail/job-created'", ",", "/*@translate*/", "'A new job opening...
Callback for the job created event. @param JobEvent $e
[ "Callback", "for", "the", "job", "created", "event", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Listener/MailSender.php#L85-L99
train
yawik/jobs
src/Listener/MailSender.php
MailSender.sendMail
protected function sendMail(Job $job, $template, $subject, $adminMail = false) { $mail = $this->mailer->get('htmltemplate'); $mail->setTemplate($template) ->setSubject($subject) ->setVariables( array( 'job' => $job, 'siteName' => $this->options['siteName'], ) ); if ($adminMail) { $mail->setTo($this->options['adminEmail']); } else { if (! ($user = $job->getUser())) { return; } $userInfo = $user->getInfo(); $userEmail = $userInfo->getEmail(); $userName = $userInfo->getDisplayName(/*emailIfEmpty*/ false); $mail->setTo($userEmail, $userName); } $this->mailer->send($mail); }
php
protected function sendMail(Job $job, $template, $subject, $adminMail = false) { $mail = $this->mailer->get('htmltemplate'); $mail->setTemplate($template) ->setSubject($subject) ->setVariables( array( 'job' => $job, 'siteName' => $this->options['siteName'], ) ); if ($adminMail) { $mail->setTo($this->options['adminEmail']); } else { if (! ($user = $job->getUser())) { return; } $userInfo = $user->getInfo(); $userEmail = $userInfo->getEmail(); $userName = $userInfo->getDisplayName(/*emailIfEmpty*/ false); $mail->setTo($userEmail, $userName); } $this->mailer->send($mail); }
[ "protected", "function", "sendMail", "(", "Job", "$", "job", ",", "$", "template", ",", "$", "subject", ",", "$", "adminMail", "=", "false", ")", "{", "$", "mail", "=", "$", "this", "->", "mailer", "->", "get", "(", "'htmltemplate'", ")", ";", "$", ...
Sends a job event related mail @param Job $job @param string $template @param string $subject @param bool $adminMail if true, the mail is send to the administrator instead of to the user.
[ "Sends", "a", "job", "event", "related", "mail" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Listener/MailSender.php#L137-L163
train
yawik/jobs
src/Acl/WriteAssertion.php
WriteAssertion.assert
public function assert( Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null ) { if (!$role instanceof UserInterface || !$resource instanceof JobInterface || 'edit' != $privilege) { return false; } /* @var $resource \Jobs\Entity\JobInterface */ return $resource->getPermissions()->isGranted($role->getId(), Permissions::PERMISSION_CHANGE) || $this->checkOrganizationPermissions($role, $resource) || (null === $resource->getUser() && \Auth\Entity\UserInterface::ROLE_ADMIN == $role->getRole()); }
php
public function assert( Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null ) { if (!$role instanceof UserInterface || !$resource instanceof JobInterface || 'edit' != $privilege) { return false; } /* @var $resource \Jobs\Entity\JobInterface */ return $resource->getPermissions()->isGranted($role->getId(), Permissions::PERMISSION_CHANGE) || $this->checkOrganizationPermissions($role, $resource) || (null === $resource->getUser() && \Auth\Entity\UserInterface::ROLE_ADMIN == $role->getRole()); }
[ "public", "function", "assert", "(", "Acl", "$", "acl", ",", "RoleInterface", "$", "role", "=", "null", ",", "ResourceInterface", "$", "resource", "=", "null", ",", "$", "privilege", "=", "null", ")", "{", "if", "(", "!", "$", "role", "instanceof", "Us...
Returns true, if the user has write access to the job. {@inheritDoc} @see \Zend\Permissions\Acl\Assertion\AssertionInterface::assert()
[ "Returns", "true", "if", "the", "user", "has", "write", "access", "to", "the", "job", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Acl/WriteAssertion.php#L36-L50
train
yawik/jobs
src/Acl/WriteAssertion.php
WriteAssertion.checkOrganizationPermissions
protected function checkOrganizationPermissions($role, $resource) { /* @var $resource \Jobs\Entity\JobInterface */ /* @var $role \Auth\Entity\UserInterface */ $organization = $resource->getOrganization(); if (!$organization) { return false; } if ($organization->isHiringOrganization()) { $organization = $organization->getParent(); } $orgUser = $organization->getUser(); if ($orgUser && $role->getId() == $orgUser->getId()) { return true; } $employees = $organization->getEmployees(); foreach ($employees as $emp) { /* @var $emp \Organizations\Entity\EmployeeInterface */ if ($emp->getUser()->getId() == $role->getId() && $emp->getPermissions()->isAllowed(EmployeePermissionsInterface::JOBS_CHANGE) ) { return true; } } return false; }
php
protected function checkOrganizationPermissions($role, $resource) { /* @var $resource \Jobs\Entity\JobInterface */ /* @var $role \Auth\Entity\UserInterface */ $organization = $resource->getOrganization(); if (!$organization) { return false; } if ($organization->isHiringOrganization()) { $organization = $organization->getParent(); } $orgUser = $organization->getUser(); if ($orgUser && $role->getId() == $orgUser->getId()) { return true; } $employees = $organization->getEmployees(); foreach ($employees as $emp) { /* @var $emp \Organizations\Entity\EmployeeInterface */ if ($emp->getUser()->getId() == $role->getId() && $emp->getPermissions()->isAllowed(EmployeePermissionsInterface::JOBS_CHANGE) ) { return true; } } return false; }
[ "protected", "function", "checkOrganizationPermissions", "(", "$", "role", ",", "$", "resource", ")", "{", "/* @var $resource \\Jobs\\Entity\\JobInterface */", "/* @var $role \\Auth\\Entity\\UserInterface */", "$", "organization", "=", "$", "resource", "->", "getOrganizatio...
Returns true, if the user has write access to the job granted from the organization. @param RoleInterface $role This must be a UserInterface instance @param ResourceInterface $resource This must be a JobInterface instance @return bool
[ "Returns", "true", "if", "the", "user", "has", "write", "access", "to", "the", "job", "granted", "from", "the", "organization", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Acl/WriteAssertion.php#L60-L91
train
yawik/jobs
src/Form/InputFilter/AtsMode.php
AtsMode.setData
public function setData($data) { switch ($data['mode']) { default: break; case AtsModeInterface::MODE_URI: $this->add( array( 'name' => 'uri', 'validators' => array( array( 'name' => 'uri', 'options' => array( 'allowRelative' => false, ), ), ), 'filters' => array( array('name' => 'StripTags'), ), ) ); break; case AtsModeInterface::MODE_EMAIL: $this->add( array( 'name' => 'email', 'validators' => array( array('name' => 'EmailAddress') ), ) ); break; } $this->add([ 'name' => 'oneClickApplyProfiles', 'required' => $data['mode'] == AtsModeInterface::MODE_INTERN && $data['oneClickApply'] ]); return parent::setData($data); }
php
public function setData($data) { switch ($data['mode']) { default: break; case AtsModeInterface::MODE_URI: $this->add( array( 'name' => 'uri', 'validators' => array( array( 'name' => 'uri', 'options' => array( 'allowRelative' => false, ), ), ), 'filters' => array( array('name' => 'StripTags'), ), ) ); break; case AtsModeInterface::MODE_EMAIL: $this->add( array( 'name' => 'email', 'validators' => array( array('name' => 'EmailAddress') ), ) ); break; } $this->add([ 'name' => 'oneClickApplyProfiles', 'required' => $data['mode'] == AtsModeInterface::MODE_INTERN && $data['oneClickApply'] ]); return parent::setData($data); }
[ "public", "function", "setData", "(", "$", "data", ")", "{", "switch", "(", "$", "data", "[", "'mode'", "]", ")", "{", "default", ":", "break", ";", "case", "AtsModeInterface", "::", "MODE_URI", ":", "$", "this", "->", "add", "(", "array", "(", "'nam...
Sets data for validating and filtering. @internal We needed to add dynamically validators, because when "mode" is "intern" or "none" we must not validate anything. When "mode" is "uri" we must not validate "email address" and we must not validate "uri" if mode is "uri". And only when the data is set we do know what has to be validated.
[ "Sets", "data", "for", "validating", "and", "filtering", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Form/InputFilter/AtsMode.php#L50-L93
train
yawik/jobs
src/Repository/Job.php
Job.getPaginatorCursor
public function getPaginatorCursor($params) { $filter = $this->getService('filterManager')->get('Jobs/PaginationQuery'); /* @var $filter \Core\Repository\Filter\AbstractPaginationQuery */ $qb = $filter->filter($params, $this->createQueryBuilder()); return $qb->getQuery()->execute(); }
php
public function getPaginatorCursor($params) { $filter = $this->getService('filterManager')->get('Jobs/PaginationQuery'); /* @var $filter \Core\Repository\Filter\AbstractPaginationQuery */ $qb = $filter->filter($params, $this->createQueryBuilder()); return $qb->getQuery()->execute(); }
[ "public", "function", "getPaginatorCursor", "(", "$", "params", ")", "{", "$", "filter", "=", "$", "this", "->", "getService", "(", "'filterManager'", ")", "->", "get", "(", "'Jobs/PaginationQuery'", ")", ";", "/* @var $filter \\Core\\Repository\\Filter\\AbstractPagin...
Gets a pagination cursor to the jobs collection @param $params @return mixed
[ "Gets", "a", "pagination", "cursor", "to", "the", "jobs", "collection" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Repository/Job.php#L39-L45
train
yawik/jobs
src/Repository/Job.php
Job.findByOrganization
public function findByOrganization($organizationId) { $criteria = $this->getIsDeletedCriteria([ 'organization' => new \MongoId($organizationId), ]); return $this->findBy($criteria); }
php
public function findByOrganization($organizationId) { $criteria = $this->getIsDeletedCriteria([ 'organization' => new \MongoId($organizationId), ]); return $this->findBy($criteria); }
[ "public", "function", "findByOrganization", "(", "$", "organizationId", ")", "{", "$", "criteria", "=", "$", "this", "->", "getIsDeletedCriteria", "(", "[", "'organization'", "=>", "new", "\\", "MongoId", "(", "$", "organizationId", ")", ",", "]", ")", ";", ...
Selects job postings of a certain organization @param int $organizationId @return \Jobs\Entity\Job[]
[ "Selects", "job", "postings", "of", "a", "certain", "organization" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Repository/Job.php#L119-L126
train
yawik/jobs
src/Repository/Job.php
Job.findActiveOrganizations
public function findActiveOrganizations($term = null) { $qb = $this->createQueryBuilder(); $qb->distinct('organization') ->hydrate(true) ->field('status.name')->notIn([ StatusInterface::EXPIRED, StatusInterface::INACTIVE ]); $q = $qb->getQuery(); $r = $q->execute(); $r = $r->toArray(); $qb = $this->dm->createQueryBuilder('Organizations\Entity\Organization'); $qb->field('_id')->in($r); if ($term) { $qb->field('_organizationName')->equals(new \MongoRegex('/' . addslashes($term) . '/i')); } $q = $qb->getQuery(); $r = $q->execute(); return $r; }
php
public function findActiveOrganizations($term = null) { $qb = $this->createQueryBuilder(); $qb->distinct('organization') ->hydrate(true) ->field('status.name')->notIn([ StatusInterface::EXPIRED, StatusInterface::INACTIVE ]); $q = $qb->getQuery(); $r = $q->execute(); $r = $r->toArray(); $qb = $this->dm->createQueryBuilder('Organizations\Entity\Organization'); $qb->field('_id')->in($r); if ($term) { $qb->field('_organizationName')->equals(new \MongoRegex('/' . addslashes($term) . '/i')); } $q = $qb->getQuery(); $r = $q->execute(); return $r; }
[ "public", "function", "findActiveOrganizations", "(", "$", "term", "=", "null", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", ")", ";", "$", "qb", "->", "distinct", "(", "'organization'", ")", "->", "hydrate", "(", "true", ")", ...
Selects all Organizations with Active Jobs @return mixed @throws \Doctrine\ODM\MongoDB\MongoDBException
[ "Selects", "all", "Organizations", "with", "Active", "Jobs" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Repository/Job.php#L134-L155
train
yawik/jobs
src/Repository/Job.php
Job.createQueryBuilder
public function createQueryBuilder($isDeleted = false) { $qb = parent::createQueryBuilder(); if (null !== $isDeleted) { $qb->addAnd( $qb->expr()->addOr($qb->expr()->field('isDeleted')->equals($isDeleted)) ->addOr($qb->expr()->field('isDeleted')->exists(false)) ); } return $qb; }
php
public function createQueryBuilder($isDeleted = false) { $qb = parent::createQueryBuilder(); if (null !== $isDeleted) { $qb->addAnd( $qb->expr()->addOr($qb->expr()->field('isDeleted')->equals($isDeleted)) ->addOr($qb->expr()->field('isDeleted')->exists(false)) ); } return $qb; }
[ "public", "function", "createQueryBuilder", "(", "$", "isDeleted", "=", "false", ")", "{", "$", "qb", "=", "parent", "::", "createQueryBuilder", "(", ")", ";", "if", "(", "null", "!==", "$", "isDeleted", ")", "{", "$", "qb", "->", "addAnd", "(", "$", ...
Create a query builder instance. @param bool $isDeleted Value of the isDeleted flag. Pass "null" to ignore this field. @return Query\Builder
[ "Create", "a", "query", "builder", "instance", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Repository/Job.php#L203-L215
train
yawik/jobs
src/Repository/Categories.php
Categories.createDefaultCategory
public function createDefaultCategory($value) { if (is_array($value)) { $value = isset($value['value']) ? $value['value'] : ''; } if ('professions' != $value && 'employmentTypes' != $value && 'industries' != $value) { return null; } $builder = $this->getService('Jobs/DefaultCategoriesBuilder'); $category = $builder->build($value); $this->store($category); return $category; }
php
public function createDefaultCategory($value) { if (is_array($value)) { $value = isset($value['value']) ? $value['value'] : ''; } if ('professions' != $value && 'employmentTypes' != $value && 'industries' != $value) { return null; } $builder = $this->getService('Jobs/DefaultCategoriesBuilder'); $category = $builder->build($value); $this->store($category); return $category; }
[ "public", "function", "createDefaultCategory", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "isset", "(", "$", "value", "[", "'value'", "]", ")", "?", "$", "value", "[", "'value'", "]", ":...
Creates and stores the default category hirarchy for the given value. @param array|string $value @return null|\Jobs\Entity\Category
[ "Creates", "and", "stores", "the", "default", "category", "hirarchy", "for", "the", "given", "value", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Repository/Categories.php#L46-L63
train
yawik/jobs
src/Controller/TemplateController.php
TemplateController.viewAction
public function viewAction() { $id = $this->params()->fromQuery('id'); $channel = $this->params()->fromRoute('channel', 'default'); $response = $this->getResponse(); /* @var \Jobs\Entity\Job $job */ try { $job = $this->initializeJob()->get($this->params(), true); } catch (NotFoundException $e) { $response->setStatusCode(Response::STATUS_CODE_404); return [ 'message' => sprintf($this->translator->translate('Job with id "%s" not found'), $id) ]; } $mvcEvent = $this->getEvent(); $applicationViewModel = $mvcEvent->getViewModel(); /* @var \Auth\Entity\User $user */ $user = $this->auth()->getUser(); /* @var \Zend\View\Model\ViewModel $model */ $model = $this->viewModelTemplateFilter->getModel($job); if ( Status::ACTIVE == $job->getStatus() or Status::WAITING_FOR_APPROVAL == $job->getStatus() or $job->getPermissions()->isGranted($user, PermissionsInterface::PERMISSION_VIEW) or $this->auth()->isAdmin() ) { $applicationViewModel->setTemplate('iframe/iFrameInjection'); } elseif (Status::EXPIRED == $job->getStatus() or Status::INACTIVE == $job->getStatus()) { $response->setStatusCode(Response::STATUS_CODE_410); $model->setTemplate('jobs/error/expired'); $model->setVariables( [ 'job'=>$job, 'message', 'the job posting you were trying to open, was inactivated or has expired' ] ); } else { // there is a special handling for 404 in ZF2 $response->setStatusCode(Response::STATUS_CODE_404); $model->setVariable('message', 'job is not available'); } return $model; }
php
public function viewAction() { $id = $this->params()->fromQuery('id'); $channel = $this->params()->fromRoute('channel', 'default'); $response = $this->getResponse(); /* @var \Jobs\Entity\Job $job */ try { $job = $this->initializeJob()->get($this->params(), true); } catch (NotFoundException $e) { $response->setStatusCode(Response::STATUS_CODE_404); return [ 'message' => sprintf($this->translator->translate('Job with id "%s" not found'), $id) ]; } $mvcEvent = $this->getEvent(); $applicationViewModel = $mvcEvent->getViewModel(); /* @var \Auth\Entity\User $user */ $user = $this->auth()->getUser(); /* @var \Zend\View\Model\ViewModel $model */ $model = $this->viewModelTemplateFilter->getModel($job); if ( Status::ACTIVE == $job->getStatus() or Status::WAITING_FOR_APPROVAL == $job->getStatus() or $job->getPermissions()->isGranted($user, PermissionsInterface::PERMISSION_VIEW) or $this->auth()->isAdmin() ) { $applicationViewModel->setTemplate('iframe/iFrameInjection'); } elseif (Status::EXPIRED == $job->getStatus() or Status::INACTIVE == $job->getStatus()) { $response->setStatusCode(Response::STATUS_CODE_410); $model->setTemplate('jobs/error/expired'); $model->setVariables( [ 'job'=>$job, 'message', 'the job posting you were trying to open, was inactivated or has expired' ] ); } else { // there is a special handling for 404 in ZF2 $response->setStatusCode(Response::STATUS_CODE_404); $model->setVariable('message', 'job is not available'); } return $model; }
[ "public", "function", "viewAction", "(", ")", "{", "$", "id", "=", "$", "this", "->", "params", "(", ")", "->", "fromQuery", "(", "'id'", ")", ";", "$", "channel", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'channel'", ","...
Handles the job opening template in preview mode @return ViewModel @throws \RuntimeException
[ "Handles", "the", "job", "opening", "template", "in", "preview", "mode" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Controller/TemplateController.php#L76-L122
train
yawik/jobs
src/Entity/Decorator/JsonLdProvider.php
JsonLdProvider.getLocations
private function getLocations($locations) { $array=[]; foreach ($locations as $location) { /* @var \Core\Entity\LocationInterface $location */ array_push( $array, [ '@type' => 'Place', 'address' => [ '@type' => 'PostalAddress', 'streetAddress' => $location->getStreetname() .' '.$location->getStreetnumber(), 'postalCode' => $location->getPostalCode(), 'addressLocality' => $location->getCity(), 'addressCountry' => $location->getCountry(), 'addressRegion' => $location->getRegion(), ] ] ); } return $array; }
php
private function getLocations($locations) { $array=[]; foreach ($locations as $location) { /* @var \Core\Entity\LocationInterface $location */ array_push( $array, [ '@type' => 'Place', 'address' => [ '@type' => 'PostalAddress', 'streetAddress' => $location->getStreetname() .' '.$location->getStreetnumber(), 'postalCode' => $location->getPostalCode(), 'addressLocality' => $location->getCity(), 'addressCountry' => $location->getCountry(), 'addressRegion' => $location->getRegion(), ] ] ); } return $array; }
[ "private", "function", "getLocations", "(", "$", "locations", ")", "{", "$", "array", "=", "[", "]", ";", "foreach", "(", "$", "locations", "as", "$", "location", ")", "{", "/* @var \\Core\\Entity\\LocationInterface $location */", "array_push", "(", "$", "array"...
Generates a location array @param Collection $locations, @return array
[ "Generates", "a", "location", "array" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Decorator/JsonLdProvider.php#L96-L116
train
yawik/jobs
src/Entity/Decorator/JsonLdProvider.php
JsonLdProvider.getDescription
private function getDescription(TemplateValuesInterface $values) { $description=sprintf( "<p>%s</p>". "<h1>%s</h1>". "<h3>Requirements</h3><p>%s</p>". "<h3>Qualifications</h3><p>%s</p>". "<h3>Benefits</h3><p>%s</p>", $values->getDescription(), $values->getTitle(), $values->getRequirements(), $values->getQualifications(), $values->getBenefits() ); return $description; }
php
private function getDescription(TemplateValuesInterface $values) { $description=sprintf( "<p>%s</p>". "<h1>%s</h1>". "<h3>Requirements</h3><p>%s</p>". "<h3>Qualifications</h3><p>%s</p>". "<h3>Benefits</h3><p>%s</p>", $values->getDescription(), $values->getTitle(), $values->getRequirements(), $values->getQualifications(), $values->getBenefits() ); return $description; }
[ "private", "function", "getDescription", "(", "TemplateValuesInterface", "$", "values", ")", "{", "$", "description", "=", "sprintf", "(", "\"<p>%s</p>\"", ".", "\"<h1>%s</h1>\"", ".", "\"<h3>Requirements</h3><p>%s</p>\"", ".", "\"<h3>Qualifications</h3><p>%s</p>\"", ".", ...
Generates a description from template values @param TemplateValuesInterface $values @return string
[ "Generates", "a", "description", "from", "template", "values" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Decorator/JsonLdProvider.php#L125-L140
train
yawik/jobs
src/Controller/ManageController.php
ManageController.preDispatch
public function preDispatch(MvcEvent $e) { if ('calculate' == $this->params()->fromQuery('do')) { return; } $routeMatch = $e->getRouteMatch(); $action = $routeMatch->getParam('action'); $services = $e->getApplication()->getServiceManager(); if (in_array($action, array('edit', 'approval', 'completion'))) { $jobEvents = $services->get('Jobs/Events'); $mailSender = $services->get('Jobs/Listener/MailSender'); $mailSender->attach($jobEvents); } }
php
public function preDispatch(MvcEvent $e) { if ('calculate' == $this->params()->fromQuery('do')) { return; } $routeMatch = $e->getRouteMatch(); $action = $routeMatch->getParam('action'); $services = $e->getApplication()->getServiceManager(); if (in_array($action, array('edit', 'approval', 'completion'))) { $jobEvents = $services->get('Jobs/Events'); $mailSender = $services->get('Jobs/Listener/MailSender'); $mailSender->attach($jobEvents); } }
[ "public", "function", "preDispatch", "(", "MvcEvent", "$", "e", ")", "{", "if", "(", "'calculate'", "==", "$", "this", "->", "params", "(", ")", "->", "fromQuery", "(", "'do'", ")", ")", "{", "return", ";", "}", "$", "routeMatch", "=", "$", "e", "-...
Dispatch listener callback. Attaches the MailSender aggregate listener to the job event manager. @param MvcEvent $e @since 0.19
[ "Dispatch", "listener", "callback", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Controller/ManageController.php#L154-L168
train
yawik/jobs
src/Controller/ManageController.php
ManageController.completionAction
public function completionAction() { $job = $this->initializeJob()->get($this->params(), false, true); if ($job->isDraft()) { $job->setIsDraft(false); $reference = $job->getReference(); if (empty($reference)) { /* @var $repository \Jobs\Repository\Job */ $repository = $this->repositoryService->get('Jobs/Job'); $job->setReference($repository->getUniqueReference()); } $job->changeStatus(Status::CREATED, "job was created"); $job->setAtsEnabled(true); // sets ATS-Mode on intern $job->getAtsMode(); /* * make the job opening persist and fire the EVENT_JOB_CREATED */ $this->repositoryService->store($job); $jobEvents = $this->jobEvents; $jobEvents->trigger(JobEvent::EVENT_JOB_CREATED, $this, array('job' => $job)); } else if ($job->isActive()) { $eventParams = [ 'job' => $job, 'statusWas' => $job->getStatus()->getName(), ]; $job->getOriginalEntity()->changeStatus(Status::WAITING_FOR_APPROVAL, 'job was edited.'); $this->jobEvents->trigger(JobEvent::EVENT_STATUS_CHANGED, $this, $eventParams); } /* @var \Auth\Controller\Plugin\UserSwitcher $switcher */ $switcher = $this->plugin('Auth/User/Switcher'); if ($switcher->isSwitchedUser()) { $return = $switcher->getSessionParam('return'); $switcher->clear(); if ($return) { return $this->redirect()->toUrl($return); } } return array('job' => $job); }
php
public function completionAction() { $job = $this->initializeJob()->get($this->params(), false, true); if ($job->isDraft()) { $job->setIsDraft(false); $reference = $job->getReference(); if (empty($reference)) { /* @var $repository \Jobs\Repository\Job */ $repository = $this->repositoryService->get('Jobs/Job'); $job->setReference($repository->getUniqueReference()); } $job->changeStatus(Status::CREATED, "job was created"); $job->setAtsEnabled(true); // sets ATS-Mode on intern $job->getAtsMode(); /* * make the job opening persist and fire the EVENT_JOB_CREATED */ $this->repositoryService->store($job); $jobEvents = $this->jobEvents; $jobEvents->trigger(JobEvent::EVENT_JOB_CREATED, $this, array('job' => $job)); } else if ($job->isActive()) { $eventParams = [ 'job' => $job, 'statusWas' => $job->getStatus()->getName(), ]; $job->getOriginalEntity()->changeStatus(Status::WAITING_FOR_APPROVAL, 'job was edited.'); $this->jobEvents->trigger(JobEvent::EVENT_STATUS_CHANGED, $this, $eventParams); } /* @var \Auth\Controller\Plugin\UserSwitcher $switcher */ $switcher = $this->plugin('Auth/User/Switcher'); if ($switcher->isSwitchedUser()) { $return = $switcher->getSessionParam('return'); $switcher->clear(); if ($return) { return $this->redirect()->toUrl($return); } } return array('job' => $job); }
[ "public", "function", "completionAction", "(", ")", "{", "$", "job", "=", "$", "this", "->", "initializeJob", "(", ")", "->", "get", "(", "$", "this", "->", "params", "(", ")", ",", "false", ",", "true", ")", ";", "if", "(", "$", "job", "->", "is...
Job opening is completed. @return array
[ "Job", "opening", "is", "completed", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Controller/ManageController.php#L492-L542
train
yawik/jobs
src/Controller/ManageController.php
ManageController.deactivateAction
public function deactivateAction() { $user = $this->auth->getUser(); $jobEntity = $this->initializeJob()->get($this->params()); try { $jobEntity->changeStatus(Status::INACTIVE, sprintf(/*@translate*/ "Job was deactivated by %s", $user->getInfo()->getDisplayName())); $this->notification()->success(/*@translate*/ 'Job has been deactivated'); } catch (\Exception $e) { $this->notification()->danger(/*@translate*/ 'Job could not be deactivated'); } exit; return $this->save(array('page' => 2)); }
php
public function deactivateAction() { $user = $this->auth->getUser(); $jobEntity = $this->initializeJob()->get($this->params()); try { $jobEntity->changeStatus(Status::INACTIVE, sprintf(/*@translate*/ "Job was deactivated by %s", $user->getInfo()->getDisplayName())); $this->notification()->success(/*@translate*/ 'Job has been deactivated'); } catch (\Exception $e) { $this->notification()->danger(/*@translate*/ 'Job could not be deactivated'); } exit; return $this->save(array('page' => 2)); }
[ "public", "function", "deactivateAction", "(", ")", "{", "$", "user", "=", "$", "this", "->", "auth", "->", "getUser", "(", ")", ";", "$", "jobEntity", "=", "$", "this", "->", "initializeJob", "(", ")", "->", "get", "(", "$", "this", "->", "params", ...
Deactivate a job posting @return null|ViewModel
[ "Deactivate", "a", "job", "posting" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Controller/ManageController.php#L644-L658
train
yawik/jobs
src/Controller/ManageController.php
ManageController.templateAction
public function templateAction() { try { $jobEntity = $this->initializeJob()->get($this->params()); $jobEntity->setTemplate($this->params('template', 'default')); $this->repositoryService->store($jobEntity); $this->notification()->success(/* @translate*/ 'Template changed'); } catch (\Exception $e) { $this->notification()->danger(/* @translate */ 'Template not changed'); } return new JsonModel(array()); }
php
public function templateAction() { try { $jobEntity = $this->initializeJob()->get($this->params()); $jobEntity->setTemplate($this->params('template', 'default')); $this->repositoryService->store($jobEntity); $this->notification()->success(/* @translate*/ 'Template changed'); } catch (\Exception $e) { $this->notification()->danger(/* @translate */ 'Template not changed'); } return new JsonModel(array()); }
[ "public", "function", "templateAction", "(", ")", "{", "try", "{", "$", "jobEntity", "=", "$", "this", "->", "initializeJob", "(", ")", "->", "get", "(", "$", "this", "->", "params", "(", ")", ")", ";", "$", "jobEntity", "->", "setTemplate", "(", "$"...
Assign a template to a job posting @return JsonModel
[ "Assign", "a", "template", "to", "a", "job", "posting" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Controller/ManageController.php#L676-L688
train
yawik/jobs
src/Filter/ViewModelTemplateFilterAbstract.php
ViewModelTemplateFilterAbstract.setApplyData
protected function setApplyData() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job'); } $data = [ 'applyId' => $this->job->getApplyId(), 'uri' => null, 'oneClickProfiles' => [] ]; $atsMode = $this->job->getAtsMode(); if ($atsMode->isIntern() || $atsMode->isEmail()) { $data['uri'] = $this->urlPlugin->fromRoute('lang/apply', ['applyId' => $this->job->getApplyId()], ['force_canonical' => true]); } elseif ($atsMode->isUri()) { $data['uri'] = $atsMode->getUri(); } if ($atsMode->isIntern() && $atsMode->getOneClickApply()) { $data['oneClickProfiles'] = $atsMode->getOneClickApplyProfiles(); } $this->container['applyData'] = $data; return $this; }
php
protected function setApplyData() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job'); } $data = [ 'applyId' => $this->job->getApplyId(), 'uri' => null, 'oneClickProfiles' => [] ]; $atsMode = $this->job->getAtsMode(); if ($atsMode->isIntern() || $atsMode->isEmail()) { $data['uri'] = $this->urlPlugin->fromRoute('lang/apply', ['applyId' => $this->job->getApplyId()], ['force_canonical' => true]); } elseif ($atsMode->isUri()) { $data['uri'] = $atsMode->getUri(); } if ($atsMode->isIntern() && $atsMode->getOneClickApply()) { $data['oneClickProfiles'] = $atsMode->getOneClickApplyProfiles(); } $this->container['applyData'] = $data; return $this; }
[ "protected", "function", "setApplyData", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "job", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'cannot create a viewModel for Templates without a $job'", ")", ";", "}", "$", ...
Set the apply buttons of the job posting @return ViewModelTemplateFilterAbstract @throws \InvalidArgumentException
[ "Set", "the", "apply", "buttons", "of", "the", "job", "posting" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Filter/ViewModelTemplateFilterAbstract.php#L198-L224
train
yawik/jobs
src/Filter/ViewModelTemplateFilterAbstract.php
ViewModelTemplateFilterAbstract.setLocation
protected function setLocation() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without aa $job'); } $location = $this->job->getLocation(); $this->container['location'] = isset($location)?$location:''; return $this; }
php
protected function setLocation() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without aa $job'); } $location = $this->job->getLocation(); $this->container['location'] = isset($location)?$location:''; return $this; }
[ "protected", "function", "setLocation", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "job", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'cannot create a viewModel for Templates without aa $job'", ")", ";", "}", "$", ...
Sets the location of a jobs @return $this @throws \InvalidArgumentException
[ "Sets", "the", "location", "of", "a", "jobs" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Filter/ViewModelTemplateFilterAbstract.php#L232-L240
train
yawik/jobs
src/Filter/ViewModelTemplateFilterAbstract.php
ViewModelTemplateFilterAbstract.setDescription
protected function setDescription() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job'); } if (empty($this->job->getTemplateValues()->getDescription()) && is_object($this->job->getOrganization())) { $this->job->getTemplateValues()->setDescription($this->job->getOrganization()->getDescription()); } $description = $this->job->getTemplateValues()->getDescription(); $this->container['description'] = isset($description)?$description:''; return $this; }
php
protected function setDescription() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job'); } if (empty($this->job->getTemplateValues()->getDescription()) && is_object($this->job->getOrganization())) { $this->job->getTemplateValues()->setDescription($this->job->getOrganization()->getDescription()); } $description = $this->job->getTemplateValues()->getDescription(); $this->container['description'] = isset($description)?$description:''; return $this; }
[ "protected", "function", "setDescription", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "job", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'cannot create a viewModel for Templates without a $job'", ")", ";", "}", "if...
Sets the company description of a job. Use the description of an organization as default @return $this @throws \InvalidArgumentException
[ "Sets", "the", "company", "description", "of", "a", "job", ".", "Use", "the", "description", "of", "an", "organization", "as", "default" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Filter/ViewModelTemplateFilterAbstract.php#L248-L261
train
yawik/jobs
src/Filter/ViewModelTemplateFilterAbstract.php
ViewModelTemplateFilterAbstract.setOrganizationInfo
protected function setOrganizationInfo() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job'); } $organizationName = ''; $organizationStreet = ''; $organizationPostalCode = ''; $organizationPostalCity = ''; $organization = $this->job->getOrganization(); $user = $this->job->getUser(); if (isset($organization)) { $organizationName = $organization->getOrganizationName()->getName(); $organizationStreet = $organization->getContact()->getStreet().' '.$organization->getContact()->getHouseNumber(); $organizationPostalCode = $organization->getContact()->getPostalcode(); $organizationPostalCity = $organization->getContact()->getCity(); $organizationPhone = $organization->getContact()->getPhone(); $organizationFax = $organization->getContact()->getFax(); } else { $organizationName = $organizationStreet = $organizationPostalCode = $organizationPostalCity = $organizationPhone = $organizationFax = ''; } $this->container['contactEmail'] = $user ? $user->getInfo()->getEmail() : ''; $this->container['organizationName'] = $organizationName; $this->container['street'] = $organizationStreet; $this->container['postalCode'] = $organizationPostalCode; $this->container['city'] = $organizationPostalCity; $this->container['phone'] = $organizationPhone; $this->container['fax'] = $organizationFax; if (is_object($organization) && is_object($organization->getImage()) && $organization->getImage()->getUri()) { $this->container['uriLogo'] = $this->basePathHelper->__invoke($this->imageFileCacheHelper->getUri($organization->getImage(true))); } else { $this->container['uriLogo'] = $this->makeAbsolutePath($this->config->default_logo); } return $this; }
php
protected function setOrganizationInfo() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job'); } $organizationName = ''; $organizationStreet = ''; $organizationPostalCode = ''; $organizationPostalCity = ''; $organization = $this->job->getOrganization(); $user = $this->job->getUser(); if (isset($organization)) { $organizationName = $organization->getOrganizationName()->getName(); $organizationStreet = $organization->getContact()->getStreet().' '.$organization->getContact()->getHouseNumber(); $organizationPostalCode = $organization->getContact()->getPostalcode(); $organizationPostalCity = $organization->getContact()->getCity(); $organizationPhone = $organization->getContact()->getPhone(); $organizationFax = $organization->getContact()->getFax(); } else { $organizationName = $organizationStreet = $organizationPostalCode = $organizationPostalCity = $organizationPhone = $organizationFax = ''; } $this->container['contactEmail'] = $user ? $user->getInfo()->getEmail() : ''; $this->container['organizationName'] = $organizationName; $this->container['street'] = $organizationStreet; $this->container['postalCode'] = $organizationPostalCode; $this->container['city'] = $organizationPostalCity; $this->container['phone'] = $organizationPhone; $this->container['fax'] = $organizationFax; if (is_object($organization) && is_object($organization->getImage()) && $organization->getImage()->getUri()) { $this->container['uriLogo'] = $this->basePathHelper->__invoke($this->imageFileCacheHelper->getUri($organization->getImage(true))); } else { $this->container['uriLogo'] = $this->makeAbsolutePath($this->config->default_logo); } return $this; }
[ "protected", "function", "setOrganizationInfo", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "job", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'cannot create a viewModel for Templates without a $job'", ")", ";", "}", ...
Sets the organizations contact address @return $this @throws \InvalidArgumentException
[ "Sets", "the", "organizations", "contact", "address" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Filter/ViewModelTemplateFilterAbstract.php#L269-L310
train
yawik/jobs
src/Filter/ViewModelTemplateFilterAbstract.php
ViewModelTemplateFilterAbstract.setTemplateDefaultValues
protected function setTemplateDefaultValues() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job'); } $labelQualifications=''; $labelBenefits=''; $labelRequirements=''; $organization = $this->job->getOrganization(); if (isset($organization)) { $labelRequirements = $organization->getTemplate()->getLabelRequirements(); $labelQualifications = $organization->getTemplate()->getLabelQualifications(); $labelBenefits = $organization->getTemplate()->getLabelBenefits(); } $this->container['labelRequirements'] = $labelRequirements; $this->container['labelQualifications'] = $labelQualifications; $this->container['labelBenefits'] = $labelBenefits; return $this; }
php
protected function setTemplateDefaultValues() { if (!isset($this->job)) { throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job'); } $labelQualifications=''; $labelBenefits=''; $labelRequirements=''; $organization = $this->job->getOrganization(); if (isset($organization)) { $labelRequirements = $organization->getTemplate()->getLabelRequirements(); $labelQualifications = $organization->getTemplate()->getLabelQualifications(); $labelBenefits = $organization->getTemplate()->getLabelBenefits(); } $this->container['labelRequirements'] = $labelRequirements; $this->container['labelQualifications'] = $labelQualifications; $this->container['labelBenefits'] = $labelBenefits; return $this; }
[ "protected", "function", "setTemplateDefaultValues", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "job", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'cannot create a viewModel for Templates without a $job'", ")", ";", ...
Sets the default values of an organizations job template @return $this @throws \InvalidArgumentException
[ "Sets", "the", "default", "values", "of", "an", "organizations", "job", "template" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Filter/ViewModelTemplateFilterAbstract.php#L318-L338
train
yawik/jobs
src/Filter/ViewModelTemplateFilterAbstract.php
ViewModelTemplateFilterAbstract.makeAbsolutePath
protected function makeAbsolutePath($path) { $path = $this->serverUrlHelper->__invoke($this->basePathHelper->__invoke($path)); return $path; }
php
protected function makeAbsolutePath($path) { $path = $this->serverUrlHelper->__invoke($this->basePathHelper->__invoke($path)); return $path; }
[ "protected", "function", "makeAbsolutePath", "(", "$", "path", ")", "{", "$", "path", "=", "$", "this", "->", "serverUrlHelper", "->", "__invoke", "(", "$", "this", "->", "basePathHelper", "->", "__invoke", "(", "$", "path", ")", ")", ";", "return", "$",...
combines two helper @param $path @return mixed
[ "combines", "two", "helper" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Filter/ViewModelTemplateFilterAbstract.php#L357-L361
train
yawik/jobs
src/Filter/ChannelPrices.php
ChannelPrices.filter
public function filter($value = []) { $sum = 0; $amount = 0; $absoluteDiscount = 0; if (empty($value)) { return 0; } foreach ($value as $channelKey) { /* @var $channel ChannelOptions */ $channel = $this->providers->getChannel($channelKey); if ('yawik' == $channelKey) { $absoluteDiscount = 100; } if ($channel instanceof ChannelOptions && $channel->getPrice('base')>0) { $sum += $channel->getPrice('base'); $amount++; } } $discount=1-($amount-1)*13.5/100; if ($discount>0) { $sum= round($sum * $discount, 2); } return $sum-$absoluteDiscount; }
php
public function filter($value = []) { $sum = 0; $amount = 0; $absoluteDiscount = 0; if (empty($value)) { return 0; } foreach ($value as $channelKey) { /* @var $channel ChannelOptions */ $channel = $this->providers->getChannel($channelKey); if ('yawik' == $channelKey) { $absoluteDiscount = 100; } if ($channel instanceof ChannelOptions && $channel->getPrice('base')>0) { $sum += $channel->getPrice('base'); $amount++; } } $discount=1-($amount-1)*13.5/100; if ($discount>0) { $sum= round($sum * $discount, 2); } return $sum-$absoluteDiscount; }
[ "public", "function", "filter", "(", "$", "value", "=", "[", "]", ")", "{", "$", "sum", "=", "0", ";", "$", "amount", "=", "0", ";", "$", "absoluteDiscount", "=", "0", ";", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "0", ...
This filter allows you to loop over the selected Channels. Each channel can have three prices 'min', 'base', 'list'. The default calculation simply adds a discount of 13,5% if more than one channel is selected. In addition, you'll get a special discount of 100 whatever, if your job will be posted on jobs.yawik.org :-) Returns the result of filtering $value @param array $value @throws Exception\RuntimeException If filtering $value is impossible @return mixed
[ "This", "filter", "allows", "you", "to", "loop", "over", "the", "selected", "Channels", ".", "Each", "channel", "can", "have", "three", "prices", "min", "base", "list", ".", "The", "default", "calculation", "simply", "adds", "a", "discount", "of", "13", "5...
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Filter/ChannelPrices.php#L61-L86
train
yawik/jobs
src/Controller/IndexController.php
IndexController.indexAction
public function indexAction() { /* @var $request \Zend\Http\Request */ $request = $this->getRequest(); $queryParams = $request->getQuery(); $params = $queryParams->get('params', []); $jsonFormat = 'json' == $queryParams->get('format'); $isRecruiter = $this->acl()->isRole(User::ROLE_RECRUITER); if (!$jsonFormat && !$request->isXmlHttpRequest()) { $session = new Session('Jobs\Index'); $sessionKey = $this->auth()->isLoggedIn() ? 'userParams' : 'guestParams'; $sessionParams = $session[$sessionKey]; if ($sessionParams) { $params = array_merge($sessionParams, $params); } elseif ($isRecruiter) { $params['by'] = 'me'; } $session[$sessionKey] = $params; $queryParams->set('params', $params); $this->searchForm->bind($queryParams); } if (!isset($params['sort'])) { $params['sort'] = '-date'; } $paginator = $this->paginator('Jobs/Job', $params); $return = [ 'by' => $queryParams->get('by', 'all'), 'jobs' => $paginator, ]; if (isset($this->searchForm)) { $return['filterForm'] = $this->searchForm; } $model = new ViewModel(); $model->setVariables($return); $model->setTemplate('jobs/index/index'); return $model; }
php
public function indexAction() { /* @var $request \Zend\Http\Request */ $request = $this->getRequest(); $queryParams = $request->getQuery(); $params = $queryParams->get('params', []); $jsonFormat = 'json' == $queryParams->get('format'); $isRecruiter = $this->acl()->isRole(User::ROLE_RECRUITER); if (!$jsonFormat && !$request->isXmlHttpRequest()) { $session = new Session('Jobs\Index'); $sessionKey = $this->auth()->isLoggedIn() ? 'userParams' : 'guestParams'; $sessionParams = $session[$sessionKey]; if ($sessionParams) { $params = array_merge($sessionParams, $params); } elseif ($isRecruiter) { $params['by'] = 'me'; } $session[$sessionKey] = $params; $queryParams->set('params', $params); $this->searchForm->bind($queryParams); } if (!isset($params['sort'])) { $params['sort'] = '-date'; } $paginator = $this->paginator('Jobs/Job', $params); $return = [ 'by' => $queryParams->get('by', 'all'), 'jobs' => $paginator, ]; if (isset($this->searchForm)) { $return['filterForm'] = $this->searchForm; } $model = new ViewModel(); $model->setVariables($return); $model->setTemplate('jobs/index/index'); return $model; }
[ "public", "function", "indexAction", "(", ")", "{", "/* @var $request \\Zend\\Http\\Request */", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "queryParams", "=", "$", "request", "->", "getQuery", "(", ")", ";", "$", "params", "="...
List job postings @return ViewModel
[ "List", "job", "postings" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Controller/IndexController.php#L64-L108
train
yawik/jobs
src/Controller/IndexController.php
IndexController.dashboardAction
public function dashboardAction() { /* @var $request \Zend\Http\Request */ $request = $this->getRequest(); $params = $request->getQuery(); $isRecruiter = $this->Acl()->isRole(User::ROLE_RECRUITER); if ($isRecruiter) { $params->set('by', 'me'); } $paginator = $this->paginator('Jobs/Job'); return [ 'script' => 'jobs/index/dashboard', 'type' => $this->params('type'), 'myJobs' => $this->jobRepository, 'jobs' => $paginator ]; }
php
public function dashboardAction() { /* @var $request \Zend\Http\Request */ $request = $this->getRequest(); $params = $request->getQuery(); $isRecruiter = $this->Acl()->isRole(User::ROLE_RECRUITER); if ($isRecruiter) { $params->set('by', 'me'); } $paginator = $this->paginator('Jobs/Job'); return [ 'script' => 'jobs/index/dashboard', 'type' => $this->params('type'), 'myJobs' => $this->jobRepository, 'jobs' => $paginator ]; }
[ "public", "function", "dashboardAction", "(", ")", "{", "/* @var $request \\Zend\\Http\\Request */", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "params", "=", "$", "request", "->", "getQuery", "(", ")", ";", "$", "isRecruiter", ...
Handles the dashboard widget for the jobs module. @return array
[ "Handles", "the", "dashboard", "widget", "for", "the", "jobs", "module", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Controller/IndexController.php#L115-L134
train
yawik/jobs
src/Form/OrganizationSelect.php
OrganizationSelect.setSelectableOrganizations
public function setSelectableOrganizations($organizations, $addEmptyOption = true) { $options = $addEmptyOption ? ['0' => ''] : []; foreach ($organizations as $org) { /* @var $org \Organizations\Entity\Organization */ $name = $org->getOrganizationName()->getName(); $contact = $org->getContact(); $image = $org->getImage(); $imageUrl = $image ? $image->getUri() : ''; $options[$org->getId()] = $name . '|' . $contact->getCity() . '|' . $contact->getStreet() . '|' . $contact->getHouseNumber() . '|' . $imageUrl; } return $this->setValueOptions($options); }
php
public function setSelectableOrganizations($organizations, $addEmptyOption = true) { $options = $addEmptyOption ? ['0' => ''] : []; foreach ($organizations as $org) { /* @var $org \Organizations\Entity\Organization */ $name = $org->getOrganizationName()->getName(); $contact = $org->getContact(); $image = $org->getImage(); $imageUrl = $image ? $image->getUri() : ''; $options[$org->getId()] = $name . '|' . $contact->getCity() . '|' . $contact->getStreet() . '|' . $contact->getHouseNumber() . '|' . $imageUrl; } return $this->setValueOptions($options); }
[ "public", "function", "setSelectableOrganizations", "(", "$", "organizations", ",", "$", "addEmptyOption", "=", "true", ")", "{", "$", "options", "=", "$", "addEmptyOption", "?", "[", "'0'", "=>", "''", "]", ":", "[", "]", ";", "foreach", "(", "$", "orga...
Sets the selectable organizations. @param Cursor|array $organizations @param bool $addEmptyOption If true, an empty option is created as the first value option. @return self
[ "Sets", "the", "selectable", "organizations", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Form/OrganizationSelect.php#L53-L73
train
yawik/jobs
src/Entity/Salary.php
Salary.setUnit
public function setUnit($unit) { $validUnits = self::getValidUnits(); if (!in_array($unit, $validUnits)) { throw new \InvalidArgumentException('Unknown value for time unit interval.'); } $this->unit = $unit; return $this; }
php
public function setUnit($unit) { $validUnits = self::getValidUnits(); if (!in_array($unit, $validUnits)) { throw new \InvalidArgumentException('Unknown value for time unit interval.'); } $this->unit = $unit; return $this; }
[ "public", "function", "setUnit", "(", "$", "unit", ")", "{", "$", "validUnits", "=", "self", "::", "getValidUnits", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "unit", ",", "$", "validUnits", ")", ")", "{", "throw", "new", "\\", "InvalidArgu...
Sets time interval unit. @param string $unit @throws \InvalidArgumentException @return $this
[ "Sets", "time", "interval", "unit", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Salary.php#L140-L151
train
yawik/jobs
src/Entity/Salary.php
Salary.getValidUnits
public static function getValidUnits() { return array( self::UNIT_HOUR, self::UNIT_DAY, self::UNIT_WEEK, self::UNIT_MONTH, self::UNIT_YEAR, ); }
php
public static function getValidUnits() { return array( self::UNIT_HOUR, self::UNIT_DAY, self::UNIT_WEEK, self::UNIT_MONTH, self::UNIT_YEAR, ); }
[ "public", "static", "function", "getValidUnits", "(", ")", "{", "return", "array", "(", "self", "::", "UNIT_HOUR", ",", "self", "::", "UNIT_DAY", ",", "self", "::", "UNIT_WEEK", ",", "self", "::", "UNIT_MONTH", ",", "self", "::", "UNIT_YEAR", ",", ")", "...
Gets valid time interval units collection. @return array
[ "Gets", "valid", "time", "interval", "units", "collection", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Salary.php#L168-L177
train
yawik/jobs
src/Form/ImportFieldset.php
ImportFieldset.init
public function init() { $this->setName('job'); $this->setAttribute('id', 'job'); $this->add( [ 'type' => 'hidden', 'name' => 'id' ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'applyId', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'company', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'title', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'link', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'location', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'contactEmail', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'datePublishStart', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'reference', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'logoRef', ] ); $this->add( [ 'type' => 'Jobs/AtsModeFieldset', ] ); }
php
public function init() { $this->setName('job'); $this->setAttribute('id', 'job'); $this->add( [ 'type' => 'hidden', 'name' => 'id' ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'applyId', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'company', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'title', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'link', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'location', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'contactEmail', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'datePublishStart', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'reference', ] ); $this->add( [ 'type' => 'Zend\Form\Element\Text', 'name' => 'logoRef', ] ); $this->add( [ 'type' => 'Jobs/AtsModeFieldset', ] ); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "setName", "(", "'job'", ")", ";", "$", "this", "->", "setAttribute", "(", "'id'", ",", "'job'", ")", ";", "$", "this", "->", "add", "(", "[", "'type'", "=>", "'hidden'", ",", "'name'"...
defines the valid formular fields, which can be used via API
[ "defines", "the", "valid", "formular", "fields", "which", "can", "be", "used", "via", "API" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Form/ImportFieldset.php#L97-L177
train
Litecms/Page
src/Http/Controllers/PagePublicController.php
PagePublicController.getPage
protected function getPage($slug) { // get page by slug $page = $this->model->getPage($slug); if (is_null($page)) { abort(404); } //Set theme variables $view = $page->view; $view = view()->exists('page::' . $view) ? $view : 'default'; if ($page->compile) { $page->content = blade_compile($page->content); } return $this->response ->setMetaKeyword(strip_tags($page->meta_keyword)) ->setMetaDescription(strip_tags($page->meta_description)) ->setMetaTitle(strip_tags($page->meta_title)) ->view('page::' . $view) ->data(compact('page')) ->output(); }
php
protected function getPage($slug) { // get page by slug $page = $this->model->getPage($slug); if (is_null($page)) { abort(404); } //Set theme variables $view = $page->view; $view = view()->exists('page::' . $view) ? $view : 'default'; if ($page->compile) { $page->content = blade_compile($page->content); } return $this->response ->setMetaKeyword(strip_tags($page->meta_keyword)) ->setMetaDescription(strip_tags($page->meta_description)) ->setMetaTitle(strip_tags($page->meta_title)) ->view('page::' . $view) ->data(compact('page')) ->output(); }
[ "protected", "function", "getPage", "(", "$", "slug", ")", "{", "// get page by slug", "$", "page", "=", "$", "this", "->", "model", "->", "getPage", "(", "$", "slug", ")", ";", "if", "(", "is_null", "(", "$", "page", ")", ")", "{", "abort", "(", "...
Show page. @param string $slug @return response
[ "Show", "page", "." ]
787a2473098ab2e853163d3865d2374db75a144c
https://github.com/Litecms/Page/blob/787a2473098ab2e853163d3865d2374db75a144c/src/Http/Controllers/PagePublicController.php#L29-L54
train
Litecms/Page
src/Page.php
Page.pages
public function pages($idslug, $field) { $page = $this->model->getPage($idslug); return $page[$field]; }
php
public function pages($idslug, $field) { $page = $this->model->getPage($idslug); return $page[$field]; }
[ "public", "function", "pages", "(", "$", "idslug", ",", "$", "field", ")", "{", "$", "page", "=", "$", "this", "->", "model", "->", "getPage", "(", "$", "idslug", ")", ";", "return", "$", "page", "[", "$", "field", "]", ";", "}" ]
Return return field value of a page. @param mixed $idslug @param string $field @return string
[ "Return", "return", "field", "value", "of", "a", "page", "." ]
787a2473098ab2e853163d3865d2374db75a144c
https://github.com/Litecms/Page/blob/787a2473098ab2e853163d3865d2374db75a144c/src/Page.php#L60-L65
train
Litecms/Page
src/Policies/PagePolicy.php
PagePolicy.view
public function view(User $user, Page $page) { if ($user->canDo('page.page.view')) { return true; } return $user->id == $page->user_id; }
php
public function view(User $user, Page $page) { if ($user->canDo('page.page.view')) { return true; } return $user->id == $page->user_id; }
[ "public", "function", "view", "(", "User", "$", "user", ",", "Page", "$", "page", ")", "{", "if", "(", "$", "user", "->", "canDo", "(", "'page.page.view'", ")", ")", "{", "return", "true", ";", "}", "return", "$", "user", "->", "id", "==", "$", "...
Determine if the given user can view the page. @param User $user @param Page $page @return bool
[ "Determine", "if", "the", "given", "user", "can", "view", "the", "page", "." ]
787a2473098ab2e853163d3865d2374db75a144c
https://github.com/Litecms/Page/blob/787a2473098ab2e853163d3865d2374db75a144c/src/Policies/PagePolicy.php#L21-L29
train
Litecms/Page
src/Http/Controllers/PageResourceController.php
PageResourceController.show
public function show(PageRequest $request, Page $page) { if ($page->exists) { $view = 'page::admin.page.show'; } else { $view = 'page::admin.page.new'; } return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('page::page.name')) ->data(compact('page')) ->view($view) ->output(); }
php
public function show(PageRequest $request, Page $page) { if ($page->exists) { $view = 'page::admin.page.show'; } else { $view = 'page::admin.page.new'; } return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('page::page.name')) ->data(compact('page')) ->view($view) ->output(); }
[ "public", "function", "show", "(", "PageRequest", "$", "request", ",", "Page", "$", "page", ")", "{", "if", "(", "$", "page", "->", "exists", ")", "{", "$", "view", "=", "'page::admin.page.show'", ";", "}", "else", "{", "$", "view", "=", "'page::admin....
Display page. @param Request $request @param Model $page @return Response
[ "Display", "page", "." ]
787a2473098ab2e853163d3865d2374db75a144c
https://github.com/Litecms/Page/blob/787a2473098ab2e853163d3865d2374db75a144c/src/Http/Controllers/PageResourceController.php#L65-L78
train
Litecms/Page
src/Http/Controllers/PageResourceController.php
PageResourceController.edit
public function edit(PageRequest $request, Page $page) { return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('page::page.name')) ->view('page::admin.page.edit') ->data(compact('page')) ->output(); }
php
public function edit(PageRequest $request, Page $page) { return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('page::page.name')) ->view('page::admin.page.edit') ->data(compact('page')) ->output(); }
[ "public", "function", "edit", "(", "PageRequest", "$", "request", ",", "Page", "$", "page", ")", "{", "return", "$", "this", "->", "response", "->", "setMetaTitle", "(", "trans", "(", "'app.edit'", ")", ".", "' '", ".", "trans", "(", "'page::page.name'", ...
Show page for editing. @param Request $request @param Model $page @return Response
[ "Show", "page", "for", "editing", "." ]
787a2473098ab2e853163d3865d2374db75a144c
https://github.com/Litecms/Page/blob/787a2473098ab2e853163d3865d2374db75a144c/src/Http/Controllers/PageResourceController.php#L135-L141
train
Litecms/Page
src/Http/Controllers/PageAPIController.php
PageAPIController.setRepository
public function setRepository() { $this->repository = app()->make(PageRepositoryInterface::class); $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\Page\Repositories\Criteria\PageResourceCriteria::class); }
php
public function setRepository() { $this->repository = app()->make(PageRepositoryInterface::class); $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\Page\Repositories\Criteria\PageResourceCriteria::class); }
[ "public", "function", "setRepository", "(", ")", "{", "$", "this", "->", "repository", "=", "app", "(", ")", "->", "make", "(", "PageRepositoryInterface", "::", "class", ")", ";", "$", "this", "->", "repository", "->", "pushCriteria", "(", "\\", "Litepie",...
Initialize page resource controller. @param type PageRepositoryInterface $page @return null
[ "Initialize", "page", "resource", "controller", "." ]
787a2473098ab2e853163d3865d2374db75a144c
https://github.com/Litecms/Page/blob/787a2473098ab2e853163d3865d2374db75a144c/src/Http/Controllers/PageAPIController.php#L23-L29
train
Litecms/Page
src/Http/Controllers/PageAPIController.php
PageAPIController.store
public function store(PageRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('page::page.name')]); $code = 204; $status = 'success'; $url = guard_url('page/page/' . $page->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('page/page'); } return compact('data', 'message', 'code', 'status', 'url'); }
php
public function store(PageRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('page::page.name')]); $code = 204; $status = 'success'; $url = guard_url('page/page/' . $page->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('page/page'); } return compact('data', 'message', 'code', 'status', 'url'); }
[ "public", "function", "store", "(", "PageRequest", "$", "request", ")", "{", "try", "{", "$", "data", "=", "$", "request", "->", "all", "(", ")", ";", "$", "data", "[", "'user_id'", "]", "=", "user_id", "(", ")", ";", "$", "data", "[", "'user_type'...
Create new page. @param Request $request @return Response
[ "Create", "new", "page", "." ]
787a2473098ab2e853163d3865d2374db75a144c
https://github.com/Litecms/Page/blob/787a2473098ab2e853163d3865d2374db75a144c/src/Http/Controllers/PageAPIController.php#L63-L81
train
Litecms/Page
src/Http/Controllers/PageAPIController.php
PageAPIController.destroy
public function destroy(PageRequest $request, Page $page) { try { $page->delete(); $message = trans('messages.success.deleted', ['Module' => trans('page::page.name')]); $code = 202; $status = 'success'; $url = guard_url('page/page/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('page/page/' . $page->getRouteKey()); } return compact('message', 'code', 'status', 'url'); }
php
public function destroy(PageRequest $request, Page $page) { try { $page->delete(); $message = trans('messages.success.deleted', ['Module' => trans('page::page.name')]); $code = 202; $status = 'success'; $url = guard_url('page/page/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('page/page/' . $page->getRouteKey()); } return compact('message', 'code', 'status', 'url'); }
[ "public", "function", "destroy", "(", "PageRequest", "$", "request", ",", "Page", "$", "page", ")", "{", "try", "{", "$", "page", "->", "delete", "(", ")", ";", "$", "message", "=", "trans", "(", "'messages.success.deleted'", ",", "[", "'Module'", "=>", ...
Remove the page. @param Model $page @return Response
[ "Remove", "the", "page", "." ]
787a2473098ab2e853163d3865d2374db75a144c
https://github.com/Litecms/Page/blob/787a2473098ab2e853163d3865d2374db75a144c/src/Http/Controllers/PageAPIController.php#L117-L132
train
statickidz/php-google-translate-free
src/GoogleTranslate.php
GoogleTranslate.translate
public static function translate($source, $target, $text) { // Request translation $response = self::requestTranslation($source, $target, $text); // Get translation text // $response = self::getStringBetween("onmouseout=\"this.style.backgroundColor='#fff'\">", "</span></div>", strval($response)); // Clean translation $translation = self::getSentencesFromJSON($response); return $translation; }
php
public static function translate($source, $target, $text) { // Request translation $response = self::requestTranslation($source, $target, $text); // Get translation text // $response = self::getStringBetween("onmouseout=\"this.style.backgroundColor='#fff'\">", "</span></div>", strval($response)); // Clean translation $translation = self::getSentencesFromJSON($response); return $translation; }
[ "public", "static", "function", "translate", "(", "$", "source", ",", "$", "target", ",", "$", "text", ")", "{", "// Request translation", "$", "response", "=", "self", "::", "requestTranslation", "(", "$", "source", ",", "$", "target", ",", "$", "text", ...
Retrieves the translation of a text @param string $source Original language of the text on notation xx. For example: es, en, it, fr... @param string $target Language to which you want to translate the text in format xx. For example: es, en, it, fr... @param string $text Text that you want to translate @return string a simple string with the translation of the text in the target language
[ "Retrieves", "the", "translation", "of", "a", "text" ]
4fe3155b3f5845d65c15a82dc8b594885d31a035
https://github.com/statickidz/php-google-translate-free/blob/4fe3155b3f5845d65c15a82dc8b594885d31a035/src/GoogleTranslate.php#L40-L52
train
statickidz/php-google-translate-free
src/GoogleTranslate.php
GoogleTranslate.requestTranslation
protected static function requestTranslation($source, $target, $text) { // Google translate URL $url = "https://translate.google.com/translate_a/single?client=at&dt=t&dt=ld&dt=qca&dt=rm&dt=bd&dj=1&hl=es-ES&ie=UTF-8&oe=UTF-8&inputm=2&otf=2&iid=1dd3b944-fa62-4b55-b330-74909a99969e"; $fields = array( 'sl' => urlencode($source), 'tl' => urlencode($target), 'q' => urlencode($text) ); if(strlen($fields['q'])>=5000) throw new \Exception("Maximum number of characters exceeded: 5000"); // URL-ify the data for the POST $fields_string = ""; foreach ($fields as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_USERAGENT, 'AndroidTranslate/5.3.0.RC02.130475354-53000263 5.1 phone TRANSLATE_OPM5_TEST_1'); // Execute post $result = curl_exec($ch); // Close connection curl_close($ch); return $result; }
php
protected static function requestTranslation($source, $target, $text) { // Google translate URL $url = "https://translate.google.com/translate_a/single?client=at&dt=t&dt=ld&dt=qca&dt=rm&dt=bd&dj=1&hl=es-ES&ie=UTF-8&oe=UTF-8&inputm=2&otf=2&iid=1dd3b944-fa62-4b55-b330-74909a99969e"; $fields = array( 'sl' => urlencode($source), 'tl' => urlencode($target), 'q' => urlencode($text) ); if(strlen($fields['q'])>=5000) throw new \Exception("Maximum number of characters exceeded: 5000"); // URL-ify the data for the POST $fields_string = ""; foreach ($fields as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_USERAGENT, 'AndroidTranslate/5.3.0.RC02.130475354-53000263 5.1 phone TRANSLATE_OPM5_TEST_1'); // Execute post $result = curl_exec($ch); // Close connection curl_close($ch); return $result; }
[ "protected", "static", "function", "requestTranslation", "(", "$", "source", ",", "$", "target", ",", "$", "text", ")", "{", "// Google translate URL", "$", "url", "=", "\"https://translate.google.com/translate_a/single?client=at&dt=t&dt=ld&dt=qca&dt=rm&dt=bd&dj=1&hl=es-ES&ie=U...
Internal function to make the request to the translator service @internal @param string $source Original language taken from the 'translate' function @param string $target Target language taken from the ' translate' function @param string $text Text to translate taken from the 'translate' function @return object[] The response of the translation service in JSON format
[ "Internal", "function", "to", "make", "the", "request", "to", "the", "translator", "service" ]
4fe3155b3f5845d65c15a82dc8b594885d31a035
https://github.com/statickidz/php-google-translate-free/blob/4fe3155b3f5845d65c15a82dc8b594885d31a035/src/GoogleTranslate.php#L68-L111
train
statickidz/php-google-translate-free
src/GoogleTranslate.php
GoogleTranslate.getSentencesFromJSON
protected static function getSentencesFromJSON($json) { $sentencesArray = json_decode($json, true); $sentences = ""; foreach ($sentencesArray["sentences"] as $s) { $sentences .= isset($s["trans"]) ? $s["trans"] : ''; } return $sentences; }
php
protected static function getSentencesFromJSON($json) { $sentencesArray = json_decode($json, true); $sentences = ""; foreach ($sentencesArray["sentences"] as $s) { $sentences .= isset($s["trans"]) ? $s["trans"] : ''; } return $sentences; }
[ "protected", "static", "function", "getSentencesFromJSON", "(", "$", "json", ")", "{", "$", "sentencesArray", "=", "json_decode", "(", "$", "json", ",", "true", ")", ";", "$", "sentences", "=", "\"\"", ";", "foreach", "(", "$", "sentencesArray", "[", "\"se...
Dump of the JSON's response in an array @param string $json The JSON object returned by the request function @return string A single string with the translation
[ "Dump", "of", "the", "JSON", "s", "response", "in", "an", "array" ]
4fe3155b3f5845d65c15a82dc8b594885d31a035
https://github.com/statickidz/php-google-translate-free/blob/4fe3155b3f5845d65c15a82dc8b594885d31a035/src/GoogleTranslate.php#L121-L131
train
php-telegram-bot/telegram-bot-manager
src/BotManager.php
BotManager.run
public function run(): self { // Make sure this is a valid call. $this->validateSecret(); $this->validateRequest(); if ($this->action->isAction('webhookinfo')) { $webhookinfo = Request::getWebhookInfo(); /** @noinspection ForgottenDebugOutputInspection */ print_r($webhookinfo->getResult() ?: $webhookinfo->printError(true)); return $this; } if ($this->action->isAction(['set', 'unset', 'reset'])) { return $this->validateAndSetWebhook(); } $this->setBotExtras(); if ($this->action->isAction('handle')) { $this->handleRequest(); } elseif ($this->action->isAction('cron')) { $this->handleCron(); } return $this; }
php
public function run(): self { // Make sure this is a valid call. $this->validateSecret(); $this->validateRequest(); if ($this->action->isAction('webhookinfo')) { $webhookinfo = Request::getWebhookInfo(); /** @noinspection ForgottenDebugOutputInspection */ print_r($webhookinfo->getResult() ?: $webhookinfo->printError(true)); return $this; } if ($this->action->isAction(['set', 'unset', 'reset'])) { return $this->validateAndSetWebhook(); } $this->setBotExtras(); if ($this->action->isAction('handle')) { $this->handleRequest(); } elseif ($this->action->isAction('cron')) { $this->handleCron(); } return $this; }
[ "public", "function", "run", "(", ")", ":", "self", "{", "// Make sure this is a valid call.", "$", "this", "->", "validateSecret", "(", ")", ";", "$", "this", "->", "validateRequest", "(", ")", ";", "if", "(", "$", "this", "->", "action", "->", "isAction"...
Run this thing in all its glory! @return \TelegramBot\TelegramBotManager\BotManager @throws \Longman\TelegramBot\Exception\TelegramException @throws \TelegramBot\TelegramBotManager\Exception\InvalidAccessException @throws \TelegramBot\TelegramBotManager\Exception\InvalidWebhookException @throws \Exception
[ "Run", "this", "thing", "in", "all", "its", "glory!" ]
62333217bdd00fe140ca33ef5a45c16139bc675a
https://github.com/php-telegram-bot/telegram-bot-manager/blob/62333217bdd00fe140ca33ef5a45c16139bc675a/src/BotManager.php#L127-L152
train
php-telegram-bot/telegram-bot-manager
src/BotManager.php
BotManager.initLogging
public function initLogging(array $log_paths): self { foreach ($log_paths as $logger => $logfile) { ('debug' === $logger) && TelegramLog::initDebugLog($logfile); ('error' === $logger) && TelegramLog::initErrorLog($logfile); ('update' === $logger) && TelegramLog::initUpdateLog($logfile); } return $this; }
php
public function initLogging(array $log_paths): self { foreach ($log_paths as $logger => $logfile) { ('debug' === $logger) && TelegramLog::initDebugLog($logfile); ('error' === $logger) && TelegramLog::initErrorLog($logfile); ('update' === $logger) && TelegramLog::initUpdateLog($logfile); } return $this; }
[ "public", "function", "initLogging", "(", "array", "$", "log_paths", ")", ":", "self", "{", "foreach", "(", "$", "log_paths", "as", "$", "logger", "=>", "$", "logfile", ")", "{", "(", "'debug'", "===", "$", "logger", ")", "&&", "TelegramLog", "::", "in...
Initialise all loggers. @param array $log_paths @return \TelegramBot\TelegramBotManager\BotManager @throws \Exception
[ "Initialise", "all", "loggers", "." ]
62333217bdd00fe140ca33ef5a45c16139bc675a
https://github.com/php-telegram-bot/telegram-bot-manager/blob/62333217bdd00fe140ca33ef5a45c16139bc675a/src/BotManager.php#L162-L171
train
php-telegram-bot/telegram-bot-manager
src/BotManager.php
BotManager.validateSecret
public function validateSecret(bool $force = false): self { // If we're running from CLI, secret isn't necessary. if ($force || 'cli' !== PHP_SAPI) { $secret = $this->params->getBotParam('secret'); $secret_get = $this->params->getScriptParam('s'); if (!isset($secret, $secret_get) || $secret !== $secret_get) { throw new InvalidAccessException('Invalid access'); } } return $this; }
php
public function validateSecret(bool $force = false): self { // If we're running from CLI, secret isn't necessary. if ($force || 'cli' !== PHP_SAPI) { $secret = $this->params->getBotParam('secret'); $secret_get = $this->params->getScriptParam('s'); if (!isset($secret, $secret_get) || $secret !== $secret_get) { throw new InvalidAccessException('Invalid access'); } } return $this; }
[ "public", "function", "validateSecret", "(", "bool", "$", "force", "=", "false", ")", ":", "self", "{", "// If we're running from CLI, secret isn't necessary.", "if", "(", "$", "force", "||", "'cli'", "!==", "PHP_SAPI", ")", "{", "$", "secret", "=", "$", "this...
Make sure the passed secret is valid. @param bool $force Force validation, even on CLI. @return \TelegramBot\TelegramBotManager\BotManager @throws \TelegramBot\TelegramBotManager\Exception\InvalidAccessException
[ "Make", "sure", "the", "passed", "secret", "is", "valid", "." ]
62333217bdd00fe140ca33ef5a45c16139bc675a
https://github.com/php-telegram-bot/telegram-bot-manager/blob/62333217bdd00fe140ca33ef5a45c16139bc675a/src/BotManager.php#L181-L193
train
php-telegram-bot/telegram-bot-manager
src/BotManager.php
BotManager.validateAndSetWebhook
public function validateAndSetWebhook(): self { $webhook = $this->params->getBotParam('webhook'); if (empty($webhook['url'] ?? null) && $this->action->isAction(['set', 'reset'])) { throw new InvalidWebhookException('Invalid webhook'); } if ($this->action->isAction(['unset', 'reset'])) { $this->handleOutput($this->telegram->deleteWebhook()->getDescription() . PHP_EOL); // When resetting the webhook, sleep for a bit to prevent too many requests. $this->action->isAction('reset') && sleep(1); } if ($this->action->isAction(['set', 'reset'])) { $webhook_params = array_filter([ 'certificate' => $webhook['certificate'] ?? null, 'max_connections' => $webhook['max_connections'] ?? null, 'allowed_updates' => $webhook['allowed_updates'] ?? null, ], function ($v, $k) { if ($k === 'allowed_updates') { // Special case for allowed_updates, which can be an empty array. return \is_array($v); } return !empty($v); }, ARRAY_FILTER_USE_BOTH); $this->handleOutput( $this->telegram->setWebhook( $webhook['url'] . '?a=handle&s=' . $this->params->getBotParam('secret'), $webhook_params )->getDescription() . PHP_EOL ); } return $this; }
php
public function validateAndSetWebhook(): self { $webhook = $this->params->getBotParam('webhook'); if (empty($webhook['url'] ?? null) && $this->action->isAction(['set', 'reset'])) { throw new InvalidWebhookException('Invalid webhook'); } if ($this->action->isAction(['unset', 'reset'])) { $this->handleOutput($this->telegram->deleteWebhook()->getDescription() . PHP_EOL); // When resetting the webhook, sleep for a bit to prevent too many requests. $this->action->isAction('reset') && sleep(1); } if ($this->action->isAction(['set', 'reset'])) { $webhook_params = array_filter([ 'certificate' => $webhook['certificate'] ?? null, 'max_connections' => $webhook['max_connections'] ?? null, 'allowed_updates' => $webhook['allowed_updates'] ?? null, ], function ($v, $k) { if ($k === 'allowed_updates') { // Special case for allowed_updates, which can be an empty array. return \is_array($v); } return !empty($v); }, ARRAY_FILTER_USE_BOTH); $this->handleOutput( $this->telegram->setWebhook( $webhook['url'] . '?a=handle&s=' . $this->params->getBotParam('secret'), $webhook_params )->getDescription() . PHP_EOL ); } return $this; }
[ "public", "function", "validateAndSetWebhook", "(", ")", ":", "self", "{", "$", "webhook", "=", "$", "this", "->", "params", "->", "getBotParam", "(", "'webhook'", ")", ";", "if", "(", "empty", "(", "$", "webhook", "[", "'url'", "]", "??", "null", ")",...
Make sure the webhook is valid and perform the requested webhook operation. @return \TelegramBot\TelegramBotManager\BotManager @throws \Longman\TelegramBot\Exception\TelegramException @throws \TelegramBot\TelegramBotManager\Exception\InvalidWebhookException
[ "Make", "sure", "the", "webhook", "is", "valid", "and", "perform", "the", "requested", "webhook", "operation", "." ]
62333217bdd00fe140ca33ef5a45c16139bc675a
https://github.com/php-telegram-bot/telegram-bot-manager/blob/62333217bdd00fe140ca33ef5a45c16139bc675a/src/BotManager.php#L202-L237
train
php-telegram-bot/telegram-bot-manager
src/BotManager.php
BotManager.handleOutput
private function handleOutput(string $output): self { $this->output .= $output; if (!self::inTest()) { echo $output; } return $this; }
php
private function handleOutput(string $output): self { $this->output .= $output; if (!self::inTest()) { echo $output; } return $this; }
[ "private", "function", "handleOutput", "(", "string", "$", "output", ")", ":", "self", "{", "$", "this", "->", "output", ".=", "$", "output", ";", "if", "(", "!", "self", "::", "inTest", "(", ")", ")", "{", "echo", "$", "output", ";", "}", "return"...
Save the test output and echo it if we're not in a test. @param string $output @return \TelegramBot\TelegramBotManager\BotManager
[ "Save", "the", "test", "output", "and", "echo", "it", "if", "we", "re", "not", "in", "a", "test", "." ]
62333217bdd00fe140ca33ef5a45c16139bc675a
https://github.com/php-telegram-bot/telegram-bot-manager/blob/62333217bdd00fe140ca33ef5a45c16139bc675a/src/BotManager.php#L246-L255
train
php-telegram-bot/telegram-bot-manager
src/BotManager.php
BotManager.setBotExtrasTelegram
protected function setBotExtrasTelegram(): self { $simple_extras = [ 'admins' => 'enableAdmins', 'commands.paths' => 'addCommandsPaths', 'custom_input' => 'setCustomInput', 'paths.download' => 'setDownloadPath', 'paths.upload' => 'setUploadPath', ]; // For simple telegram extras, just pass the single param value to the Telegram method. foreach ($simple_extras as $param_key => $method) { $param = $this->params->getBotParam($param_key); if (null !== $param) { $this->telegram->$method($param); } } // Database. if ($mysql_config = $this->params->getBotParam('mysql', [])) { $this->telegram->enableMySql( $mysql_config, $mysql_config['table_prefix'] ?? null, $mysql_config['encoding'] ?? 'utf8mb4' ); } // Custom command configs. $command_configs = $this->params->getBotParam('commands.configs', []); foreach ($command_configs as $command => $config) { $this->telegram->setCommandConfig($command, $config); } // Botan with options. if ($botan_token = $this->params->getBotParam('botan.token')) { $botan_options = $this->params->getBotParam('botan.options', []); $this->telegram->enableBotan($botan_token, $botan_options); } return $this; }
php
protected function setBotExtrasTelegram(): self { $simple_extras = [ 'admins' => 'enableAdmins', 'commands.paths' => 'addCommandsPaths', 'custom_input' => 'setCustomInput', 'paths.download' => 'setDownloadPath', 'paths.upload' => 'setUploadPath', ]; // For simple telegram extras, just pass the single param value to the Telegram method. foreach ($simple_extras as $param_key => $method) { $param = $this->params->getBotParam($param_key); if (null !== $param) { $this->telegram->$method($param); } } // Database. if ($mysql_config = $this->params->getBotParam('mysql', [])) { $this->telegram->enableMySql( $mysql_config, $mysql_config['table_prefix'] ?? null, $mysql_config['encoding'] ?? 'utf8mb4' ); } // Custom command configs. $command_configs = $this->params->getBotParam('commands.configs', []); foreach ($command_configs as $command => $config) { $this->telegram->setCommandConfig($command, $config); } // Botan with options. if ($botan_token = $this->params->getBotParam('botan.token')) { $botan_options = $this->params->getBotParam('botan.options', []); $this->telegram->enableBotan($botan_token, $botan_options); } return $this; }
[ "protected", "function", "setBotExtrasTelegram", "(", ")", ":", "self", "{", "$", "simple_extras", "=", "[", "'admins'", "=>", "'enableAdmins'", ",", "'commands.paths'", "=>", "'addCommandsPaths'", ",", "'custom_input'", "=>", "'setCustomInput'", ",", "'paths.download...
Set extra bot parameters for Telegram object. @return \TelegramBot\TelegramBotManager\BotManager @throws \Longman\TelegramBot\Exception\TelegramException
[ "Set", "extra", "bot", "parameters", "for", "Telegram", "object", "." ]
62333217bdd00fe140ca33ef5a45c16139bc675a
https://github.com/php-telegram-bot/telegram-bot-manager/blob/62333217bdd00fe140ca33ef5a45c16139bc675a/src/BotManager.php#L277-L316
train