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
MLukman/Securilex
src/SecurityServiceProvider.php
SecurityServiceProvider.getCurrentPathRelativeToBase
protected function getCurrentPathRelativeToBase($path = null) { if (!$path) { // using $_SERVER instead of using Request method // to get original request path instead of any forwarded request $path = $_SERVER['REQUEST_URI']; } $base_path = $this->app['request']->getBasePath(); return substr(strtok($path, '?'), strlen($base_path)); }
php
protected function getCurrentPathRelativeToBase($path = null) { if (!$path) { // using $_SERVER instead of using Request method // to get original request path instead of any forwarded request $path = $_SERVER['REQUEST_URI']; } $base_path = $this->app['request']->getBasePath(); return substr(strtok($path, '?'), strlen($base_path)); }
[ "protected", "function", "getCurrentPathRelativeToBase", "(", "$", "path", "=", "null", ")", "{", "if", "(", "!", "$", "path", ")", "{", "// using $_SERVER instead of using Request method", "// to get original request path instead of any forwarded request", "$", "path", "="...
Get current path relative to base path. @param string $path Path to process. Optional, default to current path @return string
[ "Get", "current", "path", "relative", "to", "base", "path", "." ]
d86ccae6df2ff9029a6d033b20e15f7f48fab79d
https://github.com/MLukman/Securilex/blob/d86ccae6df2ff9029a6d033b20e15f7f48fab79d/src/SecurityServiceProvider.php#L238-L247
train
erickmcarvalho/likepdo
src/LikePDO/Instances/LikePDOStatement.php
LikePDOStatement.debugDumpParams
public function debugDumpParams() { if(!is_resource($this->resource)) { throw new LikePDOException("There is no active statement"); return false; } else { $parameters = array(); if(count($this->parametersBound) > 0) { foreach($this->parametersBound as $key => $param) { if(!isset($this->parameters[$key])) { $parameters[] = array ( "key" => is_string($key) == true ? "Name: [".strlen($key)."] ".$key : "Position #".$key, "paramno" => is_string($key) == true ? -1 : $key, "name" => is_string($key) == true ? "[".strlen($key)."] \"".$key."\"" : "[0] \"\"", "is_param" => 1, "param_type" => $param['data_type'] ); } } } if(count($this->parameters) > 0) { foreach($this->parameters as $key => $param) { if(!isset($this->parametersBound[$key])) { $parameters[] = array ( "key" => is_string($key) == true ? "Name: [".strlen($key)."] ".$key : "Position #".$key.":", "paramno" => is_string($key) == true ? -1 : $key, "name" => is_string($key) == true ? "[".strlen($key)."] \"".$key."\"" : "[0] \"\"", "is_param" => 1, "param_type" => $param['data_type'] ); } } } printf("SQL: [%d] %s".PHP_EOL."Params: %d".PHP_EOL.PHP_EOL, strlen($this->queryString), $this->queryString, count($parameters)); if(count($parameters) > 0) { foreach($parameters as $param) { printf("Key: %s".PHP_EOL, $param['key']); printf("paramno=%d".PHP_EOL, $param['paramno']); printf("name=%s".PHP_EOL, $param['name']); printf("is_param=%d".PHP_EOL, $param['is_param']); printf("param_type=%d".PHP_EOL, $param['param_type']); } } return true; } }
php
public function debugDumpParams() { if(!is_resource($this->resource)) { throw new LikePDOException("There is no active statement"); return false; } else { $parameters = array(); if(count($this->parametersBound) > 0) { foreach($this->parametersBound as $key => $param) { if(!isset($this->parameters[$key])) { $parameters[] = array ( "key" => is_string($key) == true ? "Name: [".strlen($key)."] ".$key : "Position #".$key, "paramno" => is_string($key) == true ? -1 : $key, "name" => is_string($key) == true ? "[".strlen($key)."] \"".$key."\"" : "[0] \"\"", "is_param" => 1, "param_type" => $param['data_type'] ); } } } if(count($this->parameters) > 0) { foreach($this->parameters as $key => $param) { if(!isset($this->parametersBound[$key])) { $parameters[] = array ( "key" => is_string($key) == true ? "Name: [".strlen($key)."] ".$key : "Position #".$key.":", "paramno" => is_string($key) == true ? -1 : $key, "name" => is_string($key) == true ? "[".strlen($key)."] \"".$key."\"" : "[0] \"\"", "is_param" => 1, "param_type" => $param['data_type'] ); } } } printf("SQL: [%d] %s".PHP_EOL."Params: %d".PHP_EOL.PHP_EOL, strlen($this->queryString), $this->queryString, count($parameters)); if(count($parameters) > 0) { foreach($parameters as $param) { printf("Key: %s".PHP_EOL, $param['key']); printf("paramno=%d".PHP_EOL, $param['paramno']); printf("name=%s".PHP_EOL, $param['name']); printf("is_param=%d".PHP_EOL, $param['is_param']); printf("param_type=%d".PHP_EOL, $param['param_type']); } } return true; } }
[ "public", "function", "debugDumpParams", "(", ")", "{", "if", "(", "!", "is_resource", "(", "$", "this", "->", "resource", ")", ")", "{", "throw", "new", "LikePDOException", "(", "\"There is no active statement\"", ")", ";", "return", "false", ";", "}", "els...
Dump an SQL prepared command @return void
[ "Dump", "an", "SQL", "prepared", "command" ]
469f82f63d98fbabacdcdc27cb770b112428e4e5
https://github.com/erickmcarvalho/likepdo/blob/469f82f63d98fbabacdcdc27cb770b112428e4e5/src/LikePDO/Instances/LikePDOStatement.php#L328-L391
train
erickmcarvalho/likepdo
src/LikePDO/Instances/LikePDOStatement.php
LikePDOStatement.nextRowset
public function nextRowset() { if(!is_resource($this->resource)) { throw new LikePDOException("There is no active statement"); return false; } else { return $this->pdo->driver->nextResult($this->resource); } }
php
public function nextRowset() { if(!is_resource($this->resource)) { throw new LikePDOException("There is no active statement"); return false; } else { return $this->pdo->driver->nextResult($this->resource); } }
[ "public", "function", "nextRowset", "(", ")", "{", "if", "(", "!", "is_resource", "(", "$", "this", "->", "resource", ")", ")", "{", "throw", "new", "LikePDOException", "(", "\"There is no active statement\"", ")", ";", "return", "false", ";", "}", "else", ...
Advances to the next rowset in a multi-rowset statement handle @return boolean
[ "Advances", "to", "the", "next", "rowset", "in", "a", "multi", "-", "rowset", "statement", "handle" ]
469f82f63d98fbabacdcdc27cb770b112428e4e5
https://github.com/erickmcarvalho/likepdo/blob/469f82f63d98fbabacdcdc27cb770b112428e4e5/src/LikePDO/Instances/LikePDOStatement.php#L1302-L1313
train
samurai-fw/samurai
src/Samurai/Controller/Controller.php
Controller.getFilters
public function getFilters() { $filters = []; $names = explode('_', $this->name); $base = ''; $filters = []; while ($name = array_shift($names)) { $filter = $this->_searchInControllerDir($base, 'filter.yml'); if ($filter) $filters[] = $filter; // when has rest. if (count($names) > 0) { $base = $base . DS . ucfirst($name); // when last. } else { $filter = $this->_searchInControllerDir($base, "{$name}.filter.yml"); if ($filter) $filters[] = $filter; } } return $filters; }
php
public function getFilters() { $filters = []; $names = explode('_', $this->name); $base = ''; $filters = []; while ($name = array_shift($names)) { $filter = $this->_searchInControllerDir($base, 'filter.yml'); if ($filter) $filters[] = $filter; // when has rest. if (count($names) > 0) { $base = $base . DS . ucfirst($name); // when last. } else { $filter = $this->_searchInControllerDir($base, "{$name}.filter.yml"); if ($filter) $filters[] = $filter; } } return $filters; }
[ "public", "function", "getFilters", "(", ")", "{", "$", "filters", "=", "[", "]", ";", "$", "names", "=", "explode", "(", "'_'", ",", "$", "this", "->", "name", ")", ";", "$", "base", "=", "''", ";", "$", "filters", "=", "[", "]", ";", "while",...
Get filter paths 1. Controller/filter.yml 2. Controller/foo.filter.yml
[ "Get", "filter", "paths" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Controller/Controller.php#L117-L140
train
samurai-fw/samurai
src/Samurai/Controller/Controller.php
Controller.getFilterKey
public function getFilterKey($action = null) { // controller.action $controller = $this->getName(); return $action ? $controller . '.' . $action : $controller; }
php
public function getFilterKey($action = null) { // controller.action $controller = $this->getName(); return $action ? $controller . '.' . $action : $controller; }
[ "public", "function", "getFilterKey", "(", "$", "action", "=", "null", ")", "{", "// controller.action", "$", "controller", "=", "$", "this", "->", "getName", "(", ")", ";", "return", "$", "action", "?", "$", "controller", ".", "'.'", ".", "$", "action",...
Get filter key @param string $action @return string
[ "Get", "filter", "key" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Controller/Controller.php#L149-L154
train
samurai-fw/samurai
src/Samurai/Controller/Controller.php
Controller.task
public function task($name, array $options = []) { $this->taskProcessor->setOutput($this); $this->taskProcessor->execute($name, $options); }
php
public function task($name, array $options = []) { $this->taskProcessor->setOutput($this); $this->taskProcessor->execute($name, $options); }
[ "public", "function", "task", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "taskProcessor", "->", "setOutput", "(", "$", "this", ")", ";", "$", "this", "->", "taskProcessor", "->", "execute", "(", "$", ...
get a task. @access public @param string $name @return Samurai\Console\Task\Task
[ "get", "a", "task", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Controller/Controller.php#L207-L211
train
samurai-fw/samurai
src/Samurai/Controller/Controller.php
Controller._searchInControllerDir
private function _searchInControllerDir($base_dir, $file_name) { $dirs = $this->application->getControllerDirectories(); foreach ($dirs as $dir) { $filter = $this->finder->path($dir . $base_dir)->name($file_name)->find()->first(); if ($filter) return $filter; } }
php
private function _searchInControllerDir($base_dir, $file_name) { $dirs = $this->application->getControllerDirectories(); foreach ($dirs as $dir) { $filter = $this->finder->path($dir . $base_dir)->name($file_name)->find()->first(); if ($filter) return $filter; } }
[ "private", "function", "_searchInControllerDir", "(", "$", "base_dir", ",", "$", "file_name", ")", "{", "$", "dirs", "=", "$", "this", "->", "application", "->", "getControllerDirectories", "(", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", ")",...
search in controller dirs @param string $base_dir @param string $file_name @return Samurai\Samurai\Component\FileSystem\Finder\Iterator\Iterator
[ "search", "in", "controller", "dirs" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Controller/Controller.php#L259-L266
train
bernardosecades/packagist-security-checker
src/Compiler/Compiler.php
Compiler.addPHPFiles
private function addPHPFiles(Phar $phar) { $finder = new Finder(); $finder ->files() ->ignoreVCS(true) ->name('*.php') ->notName('Compiler.php') ->in(realpath(__DIR__.'/../../src')); foreach ($finder as $file) { $this->addFile($phar, $file); } return $this; }
php
private function addPHPFiles(Phar $phar) { $finder = new Finder(); $finder ->files() ->ignoreVCS(true) ->name('*.php') ->notName('Compiler.php') ->in(realpath(__DIR__.'/../../src')); foreach ($finder as $file) { $this->addFile($phar, $file); } return $this; }
[ "private", "function", "addPHPFiles", "(", "Phar", "$", "phar", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "files", "(", ")", "->", "ignoreVCS", "(", "true", ")", "->", "name", "(", "'*.php'", ")", "->", "not...
Add php files @param Phar $phar Phar instance @return Compiler self Object
[ "Add", "php", "files" ]
da8212da47f3e0c08ec4a226496788853e9879d9
https://github.com/bernardosecades/packagist-security-checker/blob/da8212da47f3e0c08ec4a226496788853e9879d9/src/Compiler/Compiler.php#L159-L174
train
bernardosecades/packagist-security-checker
src/Compiler/Compiler.php
Compiler.addVendorFiles
private function addVendorFiles(Phar $phar) { $vendorPath = __DIR__.'/../../vendor/'; $requiredDependencies = [ realpath($vendorPath.'symfony/'), realpath($vendorPath.'doctrine/'), realpath($vendorPath.'guzzlehttp'), realpath($vendorPath.'psr'), ]; $finder = new Finder(); $finder ->files() ->ignoreVCS(true) ->name('*.php') ->exclude(['Tests', 'tests']) ->in($requiredDependencies); foreach ($finder as $file) { $this->addFile($phar, $file); } return $this; }
php
private function addVendorFiles(Phar $phar) { $vendorPath = __DIR__.'/../../vendor/'; $requiredDependencies = [ realpath($vendorPath.'symfony/'), realpath($vendorPath.'doctrine/'), realpath($vendorPath.'guzzlehttp'), realpath($vendorPath.'psr'), ]; $finder = new Finder(); $finder ->files() ->ignoreVCS(true) ->name('*.php') ->exclude(['Tests', 'tests']) ->in($requiredDependencies); foreach ($finder as $file) { $this->addFile($phar, $file); } return $this; }
[ "private", "function", "addVendorFiles", "(", "Phar", "$", "phar", ")", "{", "$", "vendorPath", "=", "__DIR__", ".", "'/../../vendor/'", ";", "$", "requiredDependencies", "=", "[", "realpath", "(", "$", "vendorPath", ".", "'symfony/'", ")", ",", "realpath", ...
Add vendor files @param Phar $phar Phar instance @return Compiler self Object
[ "Add", "vendor", "files" ]
da8212da47f3e0c08ec4a226496788853e9879d9
https://github.com/bernardosecades/packagist-security-checker/blob/da8212da47f3e0c08ec4a226496788853e9879d9/src/Compiler/Compiler.php#L183-L207
train
bernardosecades/packagist-security-checker
src/Compiler/Compiler.php
Compiler.addComposerVendorFiles
private function addComposerVendorFiles(Phar $phar) { $vendorPath = __DIR__.'/../../vendor/'; $this ->addFile($phar, new \SplFileInfo($vendorPath.'autoload.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_namespaces.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_psr4.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_classmap.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_real.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_static.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/ClassLoader.php')); return $this; }
php
private function addComposerVendorFiles(Phar $phar) { $vendorPath = __DIR__.'/../../vendor/'; $this ->addFile($phar, new \SplFileInfo($vendorPath.'autoload.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_namespaces.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_psr4.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_classmap.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_real.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/autoload_static.php')) ->addFile($phar, new \SplFileInfo($vendorPath.'composer/ClassLoader.php')); return $this; }
[ "private", "function", "addComposerVendorFiles", "(", "Phar", "$", "phar", ")", "{", "$", "vendorPath", "=", "__DIR__", ".", "'/../../vendor/'", ";", "$", "this", "->", "addFile", "(", "$", "phar", ",", "new", "\\", "SplFileInfo", "(", "$", "vendorPath", "...
Add composer vendor files @param Phar $phar Phar @return Compiler self Object
[ "Add", "composer", "vendor", "files" ]
da8212da47f3e0c08ec4a226496788853e9879d9
https://github.com/bernardosecades/packagist-security-checker/blob/da8212da47f3e0c08ec4a226496788853e9879d9/src/Compiler/Compiler.php#L216-L230
train
marando/phpSOFA
src/Marando/IAU/iauEe00a.php
iauEe00a.Ee00a
public static function Ee00a($date1, $date2) { $dpsipr; $depspr; $epsa; $dpsi; $deps; $ee; /* IAU 2000 precession-rate adjustments. */ IAU::Pr00($date1, $date2, $dpsipr, $depspr); /* Mean obliquity, consistent with IAU 2000 precession-nutation. */ $epsa = IAU::Obl80($date1, $date2) + $depspr; /* Nutation in longitude. */ IAU::Nut00a($date1, $date2, $dpsi, $deps); /* Equation of the equinoxes. */ $ee = IAU::Ee00($date1, $date2, $epsa, $dpsi); return $ee; }
php
public static function Ee00a($date1, $date2) { $dpsipr; $depspr; $epsa; $dpsi; $deps; $ee; /* IAU 2000 precession-rate adjustments. */ IAU::Pr00($date1, $date2, $dpsipr, $depspr); /* Mean obliquity, consistent with IAU 2000 precession-nutation. */ $epsa = IAU::Obl80($date1, $date2) + $depspr; /* Nutation in longitude. */ IAU::Nut00a($date1, $date2, $dpsi, $deps); /* Equation of the equinoxes. */ $ee = IAU::Ee00($date1, $date2, $epsa, $dpsi); return $ee; }
[ "public", "static", "function", "Ee00a", "(", "$", "date1", ",", "$", "date2", ")", "{", "$", "dpsipr", ";", "$", "depspr", ";", "$", "epsa", ";", "$", "dpsi", ";", "$", "deps", ";", "$", "ee", ";", "/* IAU 2000 precession-rate adjustments. */", "IAU", ...
- - - - - - - - - i a u E e 0 0 a - - - - - - - - - Equation of the equinoxes, compatible with IAU 2000 resolutions. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: support function. Given: date1,date2 double TT as a 2-part Julian Date (Note 1) Returned (function value): double equation of the equinoxes (Note 2) Notes: 1) The TT date date1+date2 is a Julian Date, apportioned in any convenient way between the two arguments. For example, JD(TT)=2450123.7 could be expressed in any of these ways, among others: date1 date2 2450123.7 0.0 (JD method) 2451545.0 -1421.3 (J2000 method) 2400000.5 50123.2 (MJD method) 2450123.5 0.2 (date & time method) The JD method is the most natural and convenient to use in cases where the loss of several decimal digits of resolution is acceptable. The J2000 method is best matched to the way the argument is handled internally and will deliver the optimum resolution. The MJD method and the date & time methods are both good compromises between resolution and convenience. 2) The result, which is in radians, operates in the following sense: Greenwich apparent ST = GMST + equation of the equinoxes 3) The result is compatible with the IAU 2000 resolutions. For further details, see IERS Conventions 2003 and Capitaine et al. (2002). Called: iauPr00 IAU 2000 precession adjustments iauObl80 mean obliquity, IAU 1980 iauNut00a nutation, IAU 2000A iauEe00 equation of the equinoxes, IAU 2000 References: Capitaine, N., Wallace, P.T. and McCarthy, D.D., "Expressions to implement the IAU 2000 definition of UT1", Astronomy & Astrophysics, 406, 1135-1149 (2003). McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32, BKG (2004). This revision: 2008 May 16 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "E", "e", "0", "0", "a", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauEe00a.php#L75-L96
train
MehrAlsNix/Assumptions
src/Extensions/Network.php
Network.assumeSocket
public static function assumeSocket($address, $port = 0): void { $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); assumeThat($socket, is(not(false)), self::$SOCK_ERR_MSG . socket_last_error($socket)); assumeThat( @socket_connect($socket, $address, $port), is(not(false)), 'Unable to connect: ' . $address . ':' . $port ); }
php
public static function assumeSocket($address, $port = 0): void { $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); assumeThat($socket, is(not(false)), self::$SOCK_ERR_MSG . socket_last_error($socket)); assumeThat( @socket_connect($socket, $address, $port), is(not(false)), 'Unable to connect: ' . $address . ':' . $port ); }
[ "public", "static", "function", "assumeSocket", "(", "$", "address", ",", "$", "port", "=", "0", ")", ":", "void", "{", "$", "socket", "=", "@", "socket_create", "(", "AF_INET", ",", "SOCK_STREAM", ",", "SOL_TCP", ")", ";", "assumeThat", "(", "$", "soc...
Assumes that a specified socket connection could be established. @param string $address @param int $port @return void @throws AssumptionViolatedException
[ "Assumes", "that", "a", "specified", "socket", "connection", "could", "be", "established", "." ]
5d28349354bc80409beeac52df79e57d1d52bcf2
https://github.com/MehrAlsNix/Assumptions/blob/5d28349354bc80409beeac52df79e57d1d52bcf2/src/Extensions/Network.php#L44-L54
train
axypro/creator
helpers/PointerFormat.php
PointerFormat.normalize
public static function normalize($pointer, array $context = null) { if (is_object($pointer)) { return ['value' => $pointer]; } if (is_string($pointer)) { return ['classname' => $pointer]; } if ($pointer === null) { return []; } if ($pointer === false) { throw new Disabled(''); } if (!is_array($pointer)) { throw new InvalidPointer('invalid pointer type'); } if (!isset($pointer[0])) { return $pointer; } return self::normalizeNumeric($pointer, $context); }
php
public static function normalize($pointer, array $context = null) { if (is_object($pointer)) { return ['value' => $pointer]; } if (is_string($pointer)) { return ['classname' => $pointer]; } if ($pointer === null) { return []; } if ($pointer === false) { throw new Disabled(''); } if (!is_array($pointer)) { throw new InvalidPointer('invalid pointer type'); } if (!isset($pointer[0])) { return $pointer; } return self::normalizeNumeric($pointer, $context); }
[ "public", "static", "function", "normalize", "(", "$", "pointer", ",", "array", "$", "context", "=", "null", ")", "{", "if", "(", "is_object", "(", "$", "pointer", ")", ")", "{", "return", "[", "'value'", "=>", "$", "pointer", "]", ";", "}", "if", ...
Normalizes the pointer format @param mixed $pointer @param array $context [optional] @return array @throws \axy\creator\errors\InvalidPointer @throws \axy\creator\errors\Disabled
[ "Normalizes", "the", "pointer", "format" ]
3d74e2201cdb93912d32b1d80d1fdc44018f132a
https://github.com/axypro/creator/blob/3d74e2201cdb93912d32b1d80d1fdc44018f132a/helpers/PointerFormat.php#L26-L47
train
lasallecrm/lasallecrm-l5-listmanagement-pkg
src/Http/Controllers/FrontendListUnsubscribeController.php
FrontendListUnsubscribeController.unsubscribe
public function unsubscribe($token) { // Does the token exist in the list_unsubscribe_token database table? if (!$this->model->isTokenValid($token)) { return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.token_invalid', [ 'title' => 'Invalid Unsubscribe Token', ]); } $emailID = $this->model->getEmailIdByToken($token); $listID = $this->model->getListIdByToken($token); // email address $email = $this->emailRepository->getEmailByEmailId($emailID); // list's name $listName = $this->listRepository->getListnameByListId($listID); // Delete all list_unsubscribe_token records for this email_id and list_id $this->model->deleteAllTokensForListIDandEmailID($listID,$emailID); // un-enabled (ie, disable) the list_email database record for this email_id and list_id $this->list_EmailRepository->enabledFalse($emailID, $listID); return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.unsubscribe_success', [ 'title' => 'Unsubscribe Successful', 'email' => $email, 'listName' => $listName ]); }
php
public function unsubscribe($token) { // Does the token exist in the list_unsubscribe_token database table? if (!$this->model->isTokenValid($token)) { return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.token_invalid', [ 'title' => 'Invalid Unsubscribe Token', ]); } $emailID = $this->model->getEmailIdByToken($token); $listID = $this->model->getListIdByToken($token); // email address $email = $this->emailRepository->getEmailByEmailId($emailID); // list's name $listName = $this->listRepository->getListnameByListId($listID); // Delete all list_unsubscribe_token records for this email_id and list_id $this->model->deleteAllTokensForListIDandEmailID($listID,$emailID); // un-enabled (ie, disable) the list_email database record for this email_id and list_id $this->list_EmailRepository->enabledFalse($emailID, $listID); return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.unsubscribe_success', [ 'title' => 'Unsubscribe Successful', 'email' => $email, 'listName' => $listName ]); }
[ "public", "function", "unsubscribe", "(", "$", "token", ")", "{", "// Does the token exist in the list_unsubscribe_token database table?", "if", "(", "!", "$", "this", "->", "model", "->", "isTokenValid", "(", "$", "token", ")", ")", "{", "return", "view", "(", ...
Unsubscribe from a LaSalleCRM email list @param $token
[ "Unsubscribe", "from", "a", "LaSalleCRM", "email", "list" ]
4b5da1af5d25d5fb4be5199f3cf22da313d475f3
https://github.com/lasallecrm/lasallecrm-l5-listmanagement-pkg/blob/4b5da1af5d25d5fb4be5199f3cf22da313d475f3/src/Http/Controllers/FrontendListUnsubscribeController.php#L98-L127
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.get
public function get($configurationIdentifier, $defaultValue = null) { /** * Checks if the value is defined in the configuration elements. */ if (!array_key_exists($configurationIdentifier, $this->configurationElements)) { if (!is_null($defaultValue)) { return $defaultValue; } throw new ConfigurationParameterNotFoundException(); } $valueIsCached = $this ->cache ->contains($configurationIdentifier); /** * The value is cached, so we can securely return its value. * We must unserialize the value if needed. */ if (false !== $valueIsCached) { return $this ->cache ->fetch($configurationIdentifier); } list($configurationNamespace, $configurationKey) = $this->splitConfigurationKey($configurationIdentifier); $configurationLoaded = $this->loadConfiguration( $configurationNamespace, $configurationKey ); if (!($configurationLoaded instanceof ConfigurationInterface)) { $configurationElement = $this->configurationElements[$configurationIdentifier]; $configurationValue = isset($configurationElement['reference']) ? $this->parameterBag->get($configurationElement['reference']) : $configurationElement['default_value']; if (empty($configurationValue) && !$configurationElement['can_be_empty']) { $message = $configurationElement['empty_message'] ?: 'The configuration element "' . $configurationIdentifier . '" cannot be resolved'; throw new Exception($message); } $configurationLoaded = $this ->createConfigurationInstance( $configurationIdentifier, $configurationNamespace, $configurationKey, $configurationValue ); $this->flushConfiguration($configurationLoaded); } $configurationValueUnserialized = $this->flushConfigurationToCache( $configurationLoaded, $configurationIdentifier ); return $configurationValueUnserialized; }
php
public function get($configurationIdentifier, $defaultValue = null) { /** * Checks if the value is defined in the configuration elements. */ if (!array_key_exists($configurationIdentifier, $this->configurationElements)) { if (!is_null($defaultValue)) { return $defaultValue; } throw new ConfigurationParameterNotFoundException(); } $valueIsCached = $this ->cache ->contains($configurationIdentifier); /** * The value is cached, so we can securely return its value. * We must unserialize the value if needed. */ if (false !== $valueIsCached) { return $this ->cache ->fetch($configurationIdentifier); } list($configurationNamespace, $configurationKey) = $this->splitConfigurationKey($configurationIdentifier); $configurationLoaded = $this->loadConfiguration( $configurationNamespace, $configurationKey ); if (!($configurationLoaded instanceof ConfigurationInterface)) { $configurationElement = $this->configurationElements[$configurationIdentifier]; $configurationValue = isset($configurationElement['reference']) ? $this->parameterBag->get($configurationElement['reference']) : $configurationElement['default_value']; if (empty($configurationValue) && !$configurationElement['can_be_empty']) { $message = $configurationElement['empty_message'] ?: 'The configuration element "' . $configurationIdentifier . '" cannot be resolved'; throw new Exception($message); } $configurationLoaded = $this ->createConfigurationInstance( $configurationIdentifier, $configurationNamespace, $configurationKey, $configurationValue ); $this->flushConfiguration($configurationLoaded); } $configurationValueUnserialized = $this->flushConfigurationToCache( $configurationLoaded, $configurationIdentifier ); return $configurationValueUnserialized; }
[ "public", "function", "get", "(", "$", "configurationIdentifier", ",", "$", "defaultValue", "=", "null", ")", "{", "/**\n * Checks if the value is defined in the configuration elements.\n */", "if", "(", "!", "array_key_exists", "(", "$", "configurationIdentif...
Loads a parameter given the format "namespace.key". @param string $configurationIdentifier Configuration identifier @param string|null $defaultValue Default value @return null|string|bool Configuration parameter value @throws ConfigurationParameterNotFoundException Configuration parameter not found @throws Exception Configuration cannot be resolved
[ "Loads", "a", "parameter", "given", "the", "format", "namespace", ".", "key", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L171-L234
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.delete
public function delete($configurationIdentifier) { /** * Checks if the value is defined in the configuration elements. */ if (!array_key_exists($configurationIdentifier, $this->configurationElements)) { throw new ConfigurationParameterNotFoundException(); } /** * Checks if the configuration element is read-only. */ if ( is_array($this->configurationElements[$configurationIdentifier]) && $this->configurationElements[$configurationIdentifier]['read_only'] === true ) { throw new ConfigurationNotEditableException(); } $valueIsCached = $this ->cache ->contains($configurationIdentifier); /** * The value is cached, so first we have to remove it. */ if (false !== $valueIsCached) { $this ->cache ->delete($configurationIdentifier); } list($configurationNamespace, $configurationKey) = $this->splitConfigurationKey($configurationIdentifier); $configurationLoaded = $this->loadConfiguration( $configurationNamespace, $configurationKey ); if ($configurationLoaded instanceof ConfigurationInterface) { /* * Configuration is found, delete it */ $this->deleteConfiguration($configurationLoaded); return true; } /* * Configuration instance was not found */ return false; }
php
public function delete($configurationIdentifier) { /** * Checks if the value is defined in the configuration elements. */ if (!array_key_exists($configurationIdentifier, $this->configurationElements)) { throw new ConfigurationParameterNotFoundException(); } /** * Checks if the configuration element is read-only. */ if ( is_array($this->configurationElements[$configurationIdentifier]) && $this->configurationElements[$configurationIdentifier]['read_only'] === true ) { throw new ConfigurationNotEditableException(); } $valueIsCached = $this ->cache ->contains($configurationIdentifier); /** * The value is cached, so first we have to remove it. */ if (false !== $valueIsCached) { $this ->cache ->delete($configurationIdentifier); } list($configurationNamespace, $configurationKey) = $this->splitConfigurationKey($configurationIdentifier); $configurationLoaded = $this->loadConfiguration( $configurationNamespace, $configurationKey ); if ($configurationLoaded instanceof ConfigurationInterface) { /* * Configuration is found, delete it */ $this->deleteConfiguration($configurationLoaded); return true; } /* * Configuration instance was not found */ return false; }
[ "public", "function", "delete", "(", "$", "configurationIdentifier", ")", "{", "/**\n * Checks if the value is defined in the configuration elements.\n */", "if", "(", "!", "array_key_exists", "(", "$", "configurationIdentifier", ",", "$", "this", "->", "confi...
Deletes a parameter given the format "namespace.key". @param string $configurationIdentifier @return bool @throws ConfigurationNotEditableException Configuration parameter is read-only @throws ConfigurationParameterNotFoundException Configuration parameter not found
[ "Deletes", "a", "parameter", "given", "the", "format", "namespace", ".", "key", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L246-L298
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.loadConfiguration
private function loadConfiguration( $configurationNamespace, $configurationKey ) { $configurationEntity = $this ->configurationRepository ->find([ 'namespace' => $configurationNamespace, 'key' => $configurationKey, ]); return $configurationEntity; }
php
private function loadConfiguration( $configurationNamespace, $configurationKey ) { $configurationEntity = $this ->configurationRepository ->find([ 'namespace' => $configurationNamespace, 'key' => $configurationKey, ]); return $configurationEntity; }
[ "private", "function", "loadConfiguration", "(", "$", "configurationNamespace", ",", "$", "configurationKey", ")", "{", "$", "configurationEntity", "=", "$", "this", "->", "configurationRepository", "->", "find", "(", "[", "'namespace'", "=>", "$", "configurationNam...
Loads a configuration. @param string $configurationNamespace Configuration namespace @param string $configurationKey Configuration key @return ConfigurationInterface|null Object saved
[ "Loads", "a", "configuration", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L308-L320
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.flushConfiguration
private function flushConfiguration(ConfigurationInterface $configuration) { $this ->configurationObjectManager ->persist($configuration); $this ->configurationObjectManager ->flush($configuration); return $this; }
php
private function flushConfiguration(ConfigurationInterface $configuration) { $this ->configurationObjectManager ->persist($configuration); $this ->configurationObjectManager ->flush($configuration); return $this; }
[ "private", "function", "flushConfiguration", "(", "ConfigurationInterface", "$", "configuration", ")", "{", "$", "this", "->", "configurationObjectManager", "->", "persist", "(", "$", "configuration", ")", ";", "$", "this", "->", "configurationObjectManager", "->", ...
Flushes a configuration instance. @param ConfigurationInterface $configuration Configuration instance @return ConfigurationManager Self object
[ "Flushes", "a", "configuration", "instance", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L329-L340
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.deleteConfiguration
private function deleteConfiguration(ConfigurationInterface $configuration) { $this ->configurationObjectManager ->remove($configuration); $this ->configurationObjectManager ->flush($configuration); return $this; }
php
private function deleteConfiguration(ConfigurationInterface $configuration) { $this ->configurationObjectManager ->remove($configuration); $this ->configurationObjectManager ->flush($configuration); return $this; }
[ "private", "function", "deleteConfiguration", "(", "ConfigurationInterface", "$", "configuration", ")", "{", "$", "this", "->", "configurationObjectManager", "->", "remove", "(", "$", "configuration", ")", ";", "$", "this", "->", "configurationObjectManager", "->", ...
Deletes a configuration instance. @param ConfigurationInterface $configuration Configuration instance @return $this Self object
[ "Deletes", "a", "configuration", "instance", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L349-L360
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.createConfigurationInstance
private function createConfigurationInstance( $configurationIdentifier, $configurationNamespace, $configurationKey, $configurationValue ) { /** * Value is not found on database. We can just check if the value is * defined in the configuration elements, and we can generate new entry * for our database. */ if (!$this->configurationElements[$configurationIdentifier]) { throw new ConfigurationParameterNotFoundException(); } $configurationType = $this->configurationElements[$configurationIdentifier]['type']; $configurationValue = $this ->serializeValue( $configurationValue, $configurationType ); $configurationEntity = $this ->configurationFactory ->create() ->setKey($configurationKey) ->setNamespace($configurationNamespace) ->setName($this->configurationElements[$configurationIdentifier]['name']) ->setType($configurationType) ->setValue($configurationValue); return $configurationEntity; }
php
private function createConfigurationInstance( $configurationIdentifier, $configurationNamespace, $configurationKey, $configurationValue ) { /** * Value is not found on database. We can just check if the value is * defined in the configuration elements, and we can generate new entry * for our database. */ if (!$this->configurationElements[$configurationIdentifier]) { throw new ConfigurationParameterNotFoundException(); } $configurationType = $this->configurationElements[$configurationIdentifier]['type']; $configurationValue = $this ->serializeValue( $configurationValue, $configurationType ); $configurationEntity = $this ->configurationFactory ->create() ->setKey($configurationKey) ->setNamespace($configurationNamespace) ->setName($this->configurationElements[$configurationIdentifier]['name']) ->setType($configurationType) ->setValue($configurationValue); return $configurationEntity; }
[ "private", "function", "createConfigurationInstance", "(", "$", "configurationIdentifier", ",", "$", "configurationNamespace", ",", "$", "configurationKey", ",", "$", "configurationValue", ")", "{", "/**\n * Value is not found on database. We can just check if the value is\...
Creates a new configuration instance and serializes. @param string $configurationIdentifier Configuration identifier @param string $configurationNamespace Configuration namespace @param string $configurationKey Configuration key @param mixed $configurationValue Configuration value @return ConfigurationInterface New Configuration created @throws ConfigurationParameterNotFoundException Configuration parameter not found
[ "Creates", "a", "new", "configuration", "instance", "and", "serializes", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L374-L407
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.flushConfigurationToCache
private function flushConfigurationToCache( ConfigurationInterface $configuration, $configurationIdentifier ) { $configurationValue = $this->unserializeValue( $configuration->getValue(), $configuration->getType() ); $this ->cache ->save( $configurationIdentifier, $configurationValue ); return $configurationValue; }
php
private function flushConfigurationToCache( ConfigurationInterface $configuration, $configurationIdentifier ) { $configurationValue = $this->unserializeValue( $configuration->getValue(), $configuration->getType() ); $this ->cache ->save( $configurationIdentifier, $configurationValue ); return $configurationValue; }
[ "private", "function", "flushConfigurationToCache", "(", "ConfigurationInterface", "$", "configuration", ",", "$", "configurationIdentifier", ")", "{", "$", "configurationValue", "=", "$", "this", "->", "unserializeValue", "(", "$", "configuration", "->", "getValue", ...
Saves configuration into cache. @param ConfigurationInterface $configuration Configuration @param string $configurationIdentifier Configuration identifier @return mixed flushed value
[ "Saves", "configuration", "into", "cache", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L417-L434
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.splitConfigurationKey
private function splitConfigurationKey($configurationIdentifier) { $configurationIdentifier = explode('.', $configurationIdentifier, 2); if (count($configurationIdentifier) === 1) { array_unshift($configurationIdentifier, ''); } return $configurationIdentifier; }
php
private function splitConfigurationKey($configurationIdentifier) { $configurationIdentifier = explode('.', $configurationIdentifier, 2); if (count($configurationIdentifier) === 1) { array_unshift($configurationIdentifier, ''); } return $configurationIdentifier; }
[ "private", "function", "splitConfigurationKey", "(", "$", "configurationIdentifier", ")", "{", "$", "configurationIdentifier", "=", "explode", "(", "'.'", ",", "$", "configurationIdentifier", ",", "2", ")", ";", "if", "(", "count", "(", "$", "configurationIdentifi...
Split the configuration identifier and return each part. @param string $configurationIdentifier Configuration identifier @return string[] Identifier splitted
[ "Split", "the", "configuration", "identifier", "and", "return", "each", "part", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L443-L452
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.unserializeValue
private function unserializeValue($configurationValue, $configurationType) { switch ($configurationType) { case ElcodiConfigurationTypes::TYPE_BOOLEAN: $configurationValue = (boolean) $configurationValue; break; case ElcodiConfigurationTypes::TYPE_ARRAY: $configurationValue = json_decode($configurationValue, true); break; } return $configurationValue; }
php
private function unserializeValue($configurationValue, $configurationType) { switch ($configurationType) { case ElcodiConfigurationTypes::TYPE_BOOLEAN: $configurationValue = (boolean) $configurationValue; break; case ElcodiConfigurationTypes::TYPE_ARRAY: $configurationValue = json_decode($configurationValue, true); break; } return $configurationValue; }
[ "private", "function", "unserializeValue", "(", "$", "configurationValue", ",", "$", "configurationType", ")", "{", "switch", "(", "$", "configurationType", ")", "{", "case", "ElcodiConfigurationTypes", "::", "TYPE_BOOLEAN", ":", "$", "configurationValue", "=", "(",...
Unserialize configuration value. @param string $configurationValue Configuration value @param string $configurationType Configuration type @return mixed Configuration value unserialized
[ "Unserialize", "configuration", "value", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L462-L476
train
elcodi/Configuration
Services/ConfigurationManager.php
ConfigurationManager.serializeValue
private function serializeValue($configurationValue, $configurationType) { switch ($configurationType) { case ElcodiConfigurationTypes::TYPE_ARRAY: $configurationValue = json_encode($configurationValue); break; } return $configurationValue; }
php
private function serializeValue($configurationValue, $configurationType) { switch ($configurationType) { case ElcodiConfigurationTypes::TYPE_ARRAY: $configurationValue = json_encode($configurationValue); break; } return $configurationValue; }
[ "private", "function", "serializeValue", "(", "$", "configurationValue", ",", "$", "configurationType", ")", "{", "switch", "(", "$", "configurationType", ")", "{", "case", "ElcodiConfigurationTypes", "::", "TYPE_ARRAY", ":", "$", "configurationValue", "=", "json_en...
Serialize configuration value. @param string $configurationValue Configuration value @param string $configurationType Configuration type @return string Configuration value serialized
[ "Serialize", "configuration", "value", "." ]
1e416269c2e1bd957f98c6b1845dffb218794c55
https://github.com/elcodi/Configuration/blob/1e416269c2e1bd957f98c6b1845dffb218794c55/Services/ConfigurationManager.php#L486-L496
train
chilimatic/transformer-component
src/Time/DateDiffToDecimalTime.php
DateDiffToDecimalTime.transform
public function transform($content, $options = []) { if (!$content instanceof \DateInterval) { return 0; } $decTime = 0; $decTime += ($content->d ? $content->d * 60 * 24 : 0); $decTime += ($content->h ? $content->h * 60 : 0); $decTime += $content->i; $decTime += ($content->s ? $content->s / 60 : 0); return $decTime; }
php
public function transform($content, $options = []) { if (!$content instanceof \DateInterval) { return 0; } $decTime = 0; $decTime += ($content->d ? $content->d * 60 * 24 : 0); $decTime += ($content->h ? $content->h * 60 : 0); $decTime += $content->i; $decTime += ($content->s ? $content->s / 60 : 0); return $decTime; }
[ "public", "function", "transform", "(", "$", "content", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "content", "instanceof", "\\", "DateInterval", ")", "{", "return", "0", ";", "}", "$", "decTime", "=", "0", ";", "$", "decTim...
calculates the time down to the minutes @param \DateInterval $content @param array $options @return string
[ "calculates", "the", "time", "down", "to", "the", "minutes" ]
1d20cda19531bb3d3476666793906680ee523363
https://github.com/chilimatic/transformer-component/blob/1d20cda19531bb3d3476666793906680ee523363/src/Time/DateDiffToDecimalTime.php#L22-L35
train
tenside/core
src/Task/Composer/DumpAutoloadTask.php
DumpAutoloadTask.prepareInput
protected function prepareInput() { $arguments = [ '--optimize' => (bool) $this->file->get(self::SETTING_OPTIMIZE), '--no-dev' => true, ]; $input = new ArrayInput($arguments); $input->setInteractive(false); return $input; }
php
protected function prepareInput() { $arguments = [ '--optimize' => (bool) $this->file->get(self::SETTING_OPTIMIZE), '--no-dev' => true, ]; $input = new ArrayInput($arguments); $input->setInteractive(false); return $input; }
[ "protected", "function", "prepareInput", "(", ")", "{", "$", "arguments", "=", "[", "'--optimize'", "=>", "(", "bool", ")", "$", "this", "->", "file", "->", "get", "(", "self", "::", "SETTING_OPTIMIZE", ")", ",", "'--no-dev'", "=>", "true", ",", "]", "...
Prepare the input interface for the command. @return InputInterface
[ "Prepare", "the", "input", "interface", "for", "the", "command", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/Composer/DumpAutoloadTask.php#L67-L78
train
mxc-commons/mxc-servicemanager
src/AbstractFactory/ReflectionBasedAbstractFactory.php
ReflectionBasedAbstractFactory.resolveParameterWithoutConfigService
private function resolveParameterWithoutConfigService(ContainerInterface $container, $requestedName) { /** * @param ReflectionParameter $parameter * @return mixed * @throws ServiceNotFoundException If type-hinted parameter cannot be * resolved to a service in the container. */ return function (ReflectionParameter $parameter) use ($container, $requestedName) { return $this->resolveParameter($parameter, $container, $requestedName); }; }
php
private function resolveParameterWithoutConfigService(ContainerInterface $container, $requestedName) { /** * @param ReflectionParameter $parameter * @return mixed * @throws ServiceNotFoundException If type-hinted parameter cannot be * resolved to a service in the container. */ return function (ReflectionParameter $parameter) use ($container, $requestedName) { return $this->resolveParameter($parameter, $container, $requestedName); }; }
[ "private", "function", "resolveParameterWithoutConfigService", "(", "ContainerInterface", "$", "container", ",", "$", "requestedName", ")", "{", "/**\n * @param ReflectionParameter $parameter\n * @return mixed\n * @throws ServiceNotFoundException If type-hinted parame...
Resolve a parameter to a value. Returns a callback for resolving a parameter to a value, but without allowing mapping array `$config` arguments to the `config` service. @param ContainerInterface $container @param string $requestedName @return callable
[ "Resolve", "a", "parameter", "to", "a", "value", "." ]
547a9ed579b96d32cb54db5723510d75fcad71be
https://github.com/mxc-commons/mxc-servicemanager/blob/547a9ed579b96d32cb54db5723510d75fcad71be/src/AbstractFactory/ReflectionBasedAbstractFactory.php#L151-L162
train
mxc-commons/mxc-servicemanager
src/AbstractFactory/ReflectionBasedAbstractFactory.php
ReflectionBasedAbstractFactory.resolveParameterWithConfigService
private function resolveParameterWithConfigService(ContainerInterface $container, $requestedName) { /** * @param ReflectionParameter $parameter * @return mixed * @throws ServiceNotFoundException If type-hinted parameter cannot be * resolved to a service in the container. */ return function (ReflectionParameter $parameter) use ($container, $requestedName) { if ($parameter->isArray() && $parameter->getName() === 'config') { return $container->get('config'); } return $this->resolveParameter($parameter, $container, $requestedName); }; }
php
private function resolveParameterWithConfigService(ContainerInterface $container, $requestedName) { /** * @param ReflectionParameter $parameter * @return mixed * @throws ServiceNotFoundException If type-hinted parameter cannot be * resolved to a service in the container. */ return function (ReflectionParameter $parameter) use ($container, $requestedName) { if ($parameter->isArray() && $parameter->getName() === 'config') { return $container->get('config'); } return $this->resolveParameter($parameter, $container, $requestedName); }; }
[ "private", "function", "resolveParameterWithConfigService", "(", "ContainerInterface", "$", "container", ",", "$", "requestedName", ")", "{", "/**\n * @param ReflectionParameter $parameter\n * @return mixed\n * @throws ServiceNotFoundException If type-hinted parameter...
Returns a callback for resolving a parameter to a value, including mapping 'config' arguments. Unlike resolveParameter(), this version will detect `$config` array arguments and have them return the 'config' service. @param ContainerInterface $container @param string $requestedName @return callable
[ "Returns", "a", "callback", "for", "resolving", "a", "parameter", "to", "a", "value", "including", "mapping", "config", "arguments", "." ]
547a9ed579b96d32cb54db5723510d75fcad71be
https://github.com/mxc-commons/mxc-servicemanager/blob/547a9ed579b96d32cb54db5723510d75fcad71be/src/AbstractFactory/ReflectionBasedAbstractFactory.php#L174-L188
train
mxc-commons/mxc-servicemanager
src/AbstractFactory/ReflectionBasedAbstractFactory.php
ReflectionBasedAbstractFactory.resolveParameter
private function resolveParameter(ReflectionParameter $parameter, ContainerInterface $container, $requestedName) { if ($parameter->isArray()) { return []; } if (! $parameter->getClass()) { if (! $parameter->isDefaultValueAvailable()) { throw new ServiceNotFoundException(sprintf( 'Unable to create service "%s"; unable to resolve parameter "%s" ' . 'to a class, interface, or array type', $requestedName, $parameter->getName() )); } return $parameter->getDefaultValue(); } $type = $parameter->getClass()->getName(); $type = isset($this->aliases[$type]) ? $this->aliases[$type] : $type; if ($container->has($type)) { return $container->get($type); } if (! $parameter->isOptional()) { throw new ServiceNotFoundException(sprintf( 'Unable to create service "%s"; unable to resolve parameter "%s" using type hint "%s"', $requestedName, $parameter->getName(), $type )); } // Type not available in container, but the value is optional and has a // default defined. return $parameter->getDefaultValue(); }
php
private function resolveParameter(ReflectionParameter $parameter, ContainerInterface $container, $requestedName) { if ($parameter->isArray()) { return []; } if (! $parameter->getClass()) { if (! $parameter->isDefaultValueAvailable()) { throw new ServiceNotFoundException(sprintf( 'Unable to create service "%s"; unable to resolve parameter "%s" ' . 'to a class, interface, or array type', $requestedName, $parameter->getName() )); } return $parameter->getDefaultValue(); } $type = $parameter->getClass()->getName(); $type = isset($this->aliases[$type]) ? $this->aliases[$type] : $type; if ($container->has($type)) { return $container->get($type); } if (! $parameter->isOptional()) { throw new ServiceNotFoundException(sprintf( 'Unable to create service "%s"; unable to resolve parameter "%s" using type hint "%s"', $requestedName, $parameter->getName(), $type )); } // Type not available in container, but the value is optional and has a // default defined. return $parameter->getDefaultValue(); }
[ "private", "function", "resolveParameter", "(", "ReflectionParameter", "$", "parameter", ",", "ContainerInterface", "$", "container", ",", "$", "requestedName", ")", "{", "if", "(", "$", "parameter", "->", "isArray", "(", ")", ")", "{", "return", "[", "]", "...
Logic common to all parameter resolution. @param ReflectionParameter $parameter @param ContainerInterface $container @param string $requestedName @return mixed @throws ServiceNotFoundException If type-hinted parameter cannot be resolved to a service in the container.
[ "Logic", "common", "to", "all", "parameter", "resolution", "." ]
547a9ed579b96d32cb54db5723510d75fcad71be
https://github.com/mxc-commons/mxc-servicemanager/blob/547a9ed579b96d32cb54db5723510d75fcad71be/src/AbstractFactory/ReflectionBasedAbstractFactory.php#L200-L238
train
mandango/MandangoBundle
DependencyInjection/MandangoExtension.php
MandangoExtension.load
public function load(array $configs, ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('mandango.xml'); $processor = new Processor(); $configuration = new Configuration($container->getParameter('kernel.debug')); $config = $processor->process($configuration->getConfigTree(), $configs); // model_dir if (isset($config['model_dir'])) { $container->setParameter('mandango.model_dir', $config['model_dir']); } // logging if (isset($config['logging']) && $config['logging']) { $container->getDefinition('mandango')->addArgument(array(new Reference('mandango.logger'), 'logQuery')); } // default_connection if (isset($config['default_connection'])) { $container->getDefinition('mandango')->addMethodCall('setDefaultConnectionName', array($config['default_connection'])); } // extra config classes dirs $container->setParameter('mandango.extra_config_classes_dirs', $config['extra_config_classes_dirs']); // connections foreach ($config['connections'] as $name => $connection) { $definition = new Definition($connection['class'], array( $connection['server'], $connection['database'], $connection['options'], )); $connectionDefinitionName = sprintf('mandango.%s_connection', $name); $container->setDefinition($connectionDefinitionName, $definition); // ->setConnection $container->getDefinition('mandango')->addMethodCall('setConnection', array( $name, new Reference($connectionDefinitionName), )); } }
php
public function load(array $configs, ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('mandango.xml'); $processor = new Processor(); $configuration = new Configuration($container->getParameter('kernel.debug')); $config = $processor->process($configuration->getConfigTree(), $configs); // model_dir if (isset($config['model_dir'])) { $container->setParameter('mandango.model_dir', $config['model_dir']); } // logging if (isset($config['logging']) && $config['logging']) { $container->getDefinition('mandango')->addArgument(array(new Reference('mandango.logger'), 'logQuery')); } // default_connection if (isset($config['default_connection'])) { $container->getDefinition('mandango')->addMethodCall('setDefaultConnectionName', array($config['default_connection'])); } // extra config classes dirs $container->setParameter('mandango.extra_config_classes_dirs', $config['extra_config_classes_dirs']); // connections foreach ($config['connections'] as $name => $connection) { $definition = new Definition($connection['class'], array( $connection['server'], $connection['database'], $connection['options'], )); $connectionDefinitionName = sprintf('mandango.%s_connection', $name); $container->setDefinition($connectionDefinitionName, $definition); // ->setConnection $container->getDefinition('mandango')->addMethodCall('setConnection', array( $name, new Reference($connectionDefinitionName), )); } }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "loader", "=", "new", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ...
Responds to the "mandango" configuration parameter. @param array $configs @param ContainerBuilder $container
[ "Responds", "to", "the", "mandango", "configuration", "parameter", "." ]
36e2ff4cc43989abbb3bd2f84cd7909c0f39d5b9
https://github.com/mandango/MandangoBundle/blob/36e2ff4cc43989abbb3bd2f84cd7909c0f39d5b9/DependencyInjection/MandangoExtension.php#L35-L79
train
tekkla/core-html
Core/Html/FormDesigner/FormElement.php
FormElement.&
public function &setContent($content) { // Set element type by analyzing the element switch (true) { case ($content instanceof FormGroup): $this->type = 'group'; break; case ($content instanceof ControlsCollectionInterface): $this->type = 'collection'; break; case ($content instanceof AbstractForm): $this->type = 'control'; break; case ($content instanceof AbstractHtml): $this->type = 'factory'; break; default: $this->type = 'html'; } $this->content = $content; return $content; }
php
public function &setContent($content) { // Set element type by analyzing the element switch (true) { case ($content instanceof FormGroup): $this->type = 'group'; break; case ($content instanceof ControlsCollectionInterface): $this->type = 'collection'; break; case ($content instanceof AbstractForm): $this->type = 'control'; break; case ($content instanceof AbstractHtml): $this->type = 'factory'; break; default: $this->type = 'html'; } $this->content = $content; return $content; }
[ "public", "function", "&", "setContent", "(", "$", "content", ")", "{", "// Set element type by analyzing the element", "switch", "(", "true", ")", "{", "case", "(", "$", "content", "instanceof", "FormGroup", ")", ":", "$", "this", "->", "type", "=", "'group'"...
Sets the element. @param sting|AbstractForm|AbstractHtml $element @return Ambigous <\Core\Html\AbstractForm, \Core\Html\AbstractHtml, \Core\Html\FormDesigner\FormGroup>
[ "Sets", "the", "element", "." ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/FormDesigner/FormElement.php#L75-L103
train
atelierspierrot/library
src/Library/HttpFundamental/Response.php
Response.download
public function download($file = null, $type = null, $file_name = null) { if (!empty($file) && @file_exists($file)) { if (is_null($file_name)) { $file_name_parts = explode('/', $file); $file_name = end( $file_name_parts ); } $this->addHeader('Content-disposition', 'attachment; filename='.$file_name); $this->addHeader('Content-Type', 'application/force-download'); $this->addHeader('Content-Transfer-Encoding', $type); $this->addHeader('Content-Length', filesize($file)); $this->addHeader('Pragma', 'no-cache'); $this->addHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0, public'); $this->addHeader('Expires', '0'); $this->renderHeaders(); readfile( $file ); exit; } return; }
php
public function download($file = null, $type = null, $file_name = null) { if (!empty($file) && @file_exists($file)) { if (is_null($file_name)) { $file_name_parts = explode('/', $file); $file_name = end( $file_name_parts ); } $this->addHeader('Content-disposition', 'attachment; filename='.$file_name); $this->addHeader('Content-Type', 'application/force-download'); $this->addHeader('Content-Transfer-Encoding', $type); $this->addHeader('Content-Length', filesize($file)); $this->addHeader('Pragma', 'no-cache'); $this->addHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0, public'); $this->addHeader('Expires', '0'); $this->renderHeaders(); readfile( $file ); exit; } return; }
[ "public", "function", "download", "(", "$", "file", "=", "null", ",", "$", "type", "=", "null", ",", "$", "file_name", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "file", ")", "&&", "@", "file_exists", "(", "$", "file", ")", ")", ...
Force client to download a file @param null $file @param null $type @param null $file_name
[ "Force", "client", "to", "download", "a", "file" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/HttpFundamental/Response.php#L360-L379
train
bishopb/vanilla
applications/vanilla/settings/class.hooks.php
VanillaHooks.UserModel_BeforeDeleteUser_Handler
public function UserModel_BeforeDeleteUser_Handler($Sender) { $UserID = GetValue('UserID', $Sender->EventArguments); $Options = GetValue('Options', $Sender->EventArguments, array()); $Options = is_array($Options) ? $Options : array(); $Content =& $Sender->EventArguments['Content']; $this->DeleteUserData($UserID, $Options, $Content); }
php
public function UserModel_BeforeDeleteUser_Handler($Sender) { $UserID = GetValue('UserID', $Sender->EventArguments); $Options = GetValue('Options', $Sender->EventArguments, array()); $Options = is_array($Options) ? $Options : array(); $Content =& $Sender->EventArguments['Content']; $this->DeleteUserData($UserID, $Options, $Content); }
[ "public", "function", "UserModel_BeforeDeleteUser_Handler", "(", "$", "Sender", ")", "{", "$", "UserID", "=", "GetValue", "(", "'UserID'", ",", "$", "Sender", "->", "EventArguments", ")", ";", "$", "Options", "=", "GetValue", "(", "'Options'", ",", "$", "Sen...
Remove Vanilla data when deleting a user. @since 2.0.0 @package Vanilla @param UserModel $Sender UserModel.
[ "Remove", "Vanilla", "data", "when", "deleting", "a", "user", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/settings/class.hooks.php#L158-L165
train
bishopb/vanilla
applications/vanilla/settings/class.hooks.php
VanillaHooks.UserModel_GetCategoryViewPermission_Create
public function UserModel_GetCategoryViewPermission_Create($Sender) { static $PermissionModel = NULL; $UserID = ArrayValue(0, $Sender->EventArguments, ''); $CategoryID = ArrayValue(1, $Sender->EventArguments, ''); $Permission = GetValue(2, $Sender->EventArguments, 'Vanilla.Discussions.View'); if ($UserID && $CategoryID) { if ($PermissionModel === NULL) $PermissionModel = new PermissionModel(); $Category = CategoryModel::Categories($CategoryID); if ($Category) $PermissionCategoryID = $Category['PermissionCategoryID']; else $PermissionCategoryID = -1; $Result = $PermissionModel->GetUserPermissions($UserID, $Permission, 'Category', 'PermissionCategoryID', 'CategoryID', $PermissionCategoryID); return (GetValue($Permission, GetValue(0, $Result), FALSE)) ? TRUE : FALSE; } return FALSE; }
php
public function UserModel_GetCategoryViewPermission_Create($Sender) { static $PermissionModel = NULL; $UserID = ArrayValue(0, $Sender->EventArguments, ''); $CategoryID = ArrayValue(1, $Sender->EventArguments, ''); $Permission = GetValue(2, $Sender->EventArguments, 'Vanilla.Discussions.View'); if ($UserID && $CategoryID) { if ($PermissionModel === NULL) $PermissionModel = new PermissionModel(); $Category = CategoryModel::Categories($CategoryID); if ($Category) $PermissionCategoryID = $Category['PermissionCategoryID']; else $PermissionCategoryID = -1; $Result = $PermissionModel->GetUserPermissions($UserID, $Permission, 'Category', 'PermissionCategoryID', 'CategoryID', $PermissionCategoryID); return (GetValue($Permission, GetValue(0, $Result), FALSE)) ? TRUE : FALSE; } return FALSE; }
[ "public", "function", "UserModel_GetCategoryViewPermission_Create", "(", "$", "Sender", ")", "{", "static", "$", "PermissionModel", "=", "NULL", ";", "$", "UserID", "=", "ArrayValue", "(", "0", ",", "$", "Sender", "->", "EventArguments", ",", "''", ")", ";", ...
Check whether a user has access to view discussions in a particular category. @since 2.0.18 @example $UserModel->GetCategoryViewPermission($UserID, $CategoryID). @param $Sender UserModel. @return bool Whether user has permission.
[ "Check", "whether", "a", "user", "has", "access", "to", "view", "discussions", "in", "a", "particular", "category", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/settings/class.hooks.php#L176-L197
train
bishopb/vanilla
applications/vanilla/settings/class.hooks.php
VanillaHooks.Base_Render_Before
public function Base_Render_Before($Sender) { $Session = Gdn::Session(); if ($Sender->Menu) $Sender->Menu->AddLink('Discussions', T('Discussions'), '/discussions', FALSE, array('Standard' => TRUE)); }
php
public function Base_Render_Before($Sender) { $Session = Gdn::Session(); if ($Sender->Menu) $Sender->Menu->AddLink('Discussions', T('Discussions'), '/discussions', FALSE, array('Standard' => TRUE)); }
[ "public", "function", "Base_Render_Before", "(", "$", "Sender", ")", "{", "$", "Session", "=", "Gdn", "::", "Session", "(", ")", ";", "if", "(", "$", "Sender", "->", "Menu", ")", "$", "Sender", "->", "Menu", "->", "AddLink", "(", "'Discussions'", ",", ...
Adds 'Discussion' item to menu. 'Base_Render_Before' will trigger before every pageload across apps. If you abuse this hook, Tim with throw a Coke can at your head. @since 2.0.0 @package Vanilla @param object $Sender DashboardController.
[ "Adds", "Discussion", "item", "to", "menu", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/settings/class.hooks.php#L210-L214
train
bishopb/vanilla
applications/vanilla/settings/class.hooks.php
VanillaHooks.ProfileController_AddProfileTabs_Handler
public function ProfileController_AddProfileTabs_Handler($Sender) { if (is_object($Sender->User) && $Sender->User->UserID > 0) { $UserID = $Sender->User->UserID; // Add the discussion tab $DiscussionsLabel = Sprite('SpDiscussions').' '.T('Discussions'); $CommentsLabel = Sprite('SpComments').' '.T('Comments'); if (C('Vanilla.Profile.ShowCounts', TRUE)) { $DiscussionsLabel .= '<span class="Aside">'.CountString(GetValueR('User.CountDiscussions', $Sender, NULL), "/profile/count/discussions?userid=$UserID").'</span>'; $CommentsLabel .= '<span class="Aside">'.CountString(GetValueR('User.CountComments', $Sender, NULL), "/profile/count/comments?userid=$UserID").'</span>'; } $Sender->AddProfileTab(T('Discussions'), 'profile/discussions/'.$Sender->User->UserID.'/'.rawurlencode($Sender->User->Name), 'Discussions', $DiscussionsLabel); $Sender->AddProfileTab(T('Comments'), 'profile/comments/'.$Sender->User->UserID.'/'.rawurlencode($Sender->User->Name), 'Comments', $CommentsLabel); // Add the discussion tab's CSS and Javascript. $Sender->AddJsFile('jquery.gardenmorepager.js'); $Sender->AddJsFile('discussions.js'); } }
php
public function ProfileController_AddProfileTabs_Handler($Sender) { if (is_object($Sender->User) && $Sender->User->UserID > 0) { $UserID = $Sender->User->UserID; // Add the discussion tab $DiscussionsLabel = Sprite('SpDiscussions').' '.T('Discussions'); $CommentsLabel = Sprite('SpComments').' '.T('Comments'); if (C('Vanilla.Profile.ShowCounts', TRUE)) { $DiscussionsLabel .= '<span class="Aside">'.CountString(GetValueR('User.CountDiscussions', $Sender, NULL), "/profile/count/discussions?userid=$UserID").'</span>'; $CommentsLabel .= '<span class="Aside">'.CountString(GetValueR('User.CountComments', $Sender, NULL), "/profile/count/comments?userid=$UserID").'</span>'; } $Sender->AddProfileTab(T('Discussions'), 'profile/discussions/'.$Sender->User->UserID.'/'.rawurlencode($Sender->User->Name), 'Discussions', $DiscussionsLabel); $Sender->AddProfileTab(T('Comments'), 'profile/comments/'.$Sender->User->UserID.'/'.rawurlencode($Sender->User->Name), 'Comments', $CommentsLabel); // Add the discussion tab's CSS and Javascript. $Sender->AddJsFile('jquery.gardenmorepager.js'); $Sender->AddJsFile('discussions.js'); } }
[ "public", "function", "ProfileController_AddProfileTabs_Handler", "(", "$", "Sender", ")", "{", "if", "(", "is_object", "(", "$", "Sender", "->", "User", ")", "&&", "$", "Sender", "->", "User", "->", "UserID", ">", "0", ")", "{", "$", "UserID", "=", "$",...
Adds 'Discussions' tab to profiles and adds CSS & JS files to their head. @since 2.0.0 @package Vanilla @param object $Sender ProfileController.
[ "Adds", "Discussions", "tab", "to", "profiles", "and", "adds", "CSS", "&", "JS", "files", "to", "their", "head", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/settings/class.hooks.php#L224-L240
train
bishopb/vanilla
applications/vanilla/settings/class.hooks.php
VanillaHooks.ProfileController_AfterPreferencesDefined_Handler
public function ProfileController_AfterPreferencesDefined_Handler($Sender) { $Sender->Preferences['Notifications']['Email.DiscussionComment'] = T('Notify me when people comment on my discussions.'); $Sender->Preferences['Notifications']['Email.BookmarkComment'] = T('Notify me when people comment on my bookmarked discussions.'); $Sender->Preferences['Notifications']['Email.Mention'] = T('Notify me when people mention me.'); $Sender->Preferences['Notifications']['Popup.DiscussionComment'] = T('Notify me when people comment on my discussions.'); $Sender->Preferences['Notifications']['Popup.BookmarkComment'] = T('Notify me when people comment on my bookmarked discussions.'); $Sender->Preferences['Notifications']['Popup.Mention'] = T('Notify me when people mention me.'); // if (Gdn::Session()->CheckPermission('Garden.AdvancedNotifications.Allow')) { // $Sender->Preferences['Notifications']['Email.NewDiscussion'] = array(T('Notify me when people start new discussions.'), 'Meta'); // $Sender->Preferences['Notifications']['Email.NewComment'] = array(T('Notify me when people comment on a discussion.'), 'Meta'); //// $Sender->Preferences['Notifications']['Popup.NewDiscussion'] = T('Notify me when people start new discussions.'); // } if (Gdn::Session()->CheckPermission('Garden.AdvancedNotifications.Allow')) { $PostBack = $Sender->Form->IsPostBack(); $Set = array(); // Add the category definitions to for the view to pick up. $DoHeadings = C('Vanilla.Categories.DoHeadings'); // Grab all of the categories. $Categories = array(); $Prefixes = array('Email.NewDiscussion', 'Popup.NewDiscussion', 'Email.NewComment', 'Popup.NewComment'); foreach (CategoryModel::Categories() as $Category) { if (!$Category['PermsDiscussionsView'] || $Category['Depth'] <= 0 || $Category['Depth'] > 2 || $Category['Archived']) continue; $Category['Heading'] = ($DoHeadings && $Category['Depth'] <= 1); $Categories[] = $Category; if ($PostBack) { foreach ($Prefixes as $Prefix) { $FieldName = "$Prefix.{$Category['CategoryID']}"; $Value = $Sender->Form->GetFormValue($FieldName, NULL); if (!$Value) $Value = NULL; $Set[$FieldName] = $Value; } } } $Sender->SetData('CategoryNotifications', $Categories); if ($PostBack) { UserModel::SetMeta($Sender->User->UserID, $Set, 'Preferences.'); } } }
php
public function ProfileController_AfterPreferencesDefined_Handler($Sender) { $Sender->Preferences['Notifications']['Email.DiscussionComment'] = T('Notify me when people comment on my discussions.'); $Sender->Preferences['Notifications']['Email.BookmarkComment'] = T('Notify me when people comment on my bookmarked discussions.'); $Sender->Preferences['Notifications']['Email.Mention'] = T('Notify me when people mention me.'); $Sender->Preferences['Notifications']['Popup.DiscussionComment'] = T('Notify me when people comment on my discussions.'); $Sender->Preferences['Notifications']['Popup.BookmarkComment'] = T('Notify me when people comment on my bookmarked discussions.'); $Sender->Preferences['Notifications']['Popup.Mention'] = T('Notify me when people mention me.'); // if (Gdn::Session()->CheckPermission('Garden.AdvancedNotifications.Allow')) { // $Sender->Preferences['Notifications']['Email.NewDiscussion'] = array(T('Notify me when people start new discussions.'), 'Meta'); // $Sender->Preferences['Notifications']['Email.NewComment'] = array(T('Notify me when people comment on a discussion.'), 'Meta'); //// $Sender->Preferences['Notifications']['Popup.NewDiscussion'] = T('Notify me when people start new discussions.'); // } if (Gdn::Session()->CheckPermission('Garden.AdvancedNotifications.Allow')) { $PostBack = $Sender->Form->IsPostBack(); $Set = array(); // Add the category definitions to for the view to pick up. $DoHeadings = C('Vanilla.Categories.DoHeadings'); // Grab all of the categories. $Categories = array(); $Prefixes = array('Email.NewDiscussion', 'Popup.NewDiscussion', 'Email.NewComment', 'Popup.NewComment'); foreach (CategoryModel::Categories() as $Category) { if (!$Category['PermsDiscussionsView'] || $Category['Depth'] <= 0 || $Category['Depth'] > 2 || $Category['Archived']) continue; $Category['Heading'] = ($DoHeadings && $Category['Depth'] <= 1); $Categories[] = $Category; if ($PostBack) { foreach ($Prefixes as $Prefix) { $FieldName = "$Prefix.{$Category['CategoryID']}"; $Value = $Sender->Form->GetFormValue($FieldName, NULL); if (!$Value) $Value = NULL; $Set[$FieldName] = $Value; } } } $Sender->SetData('CategoryNotifications', $Categories); if ($PostBack) { UserModel::SetMeta($Sender->User->UserID, $Set, 'Preferences.'); } } }
[ "public", "function", "ProfileController_AfterPreferencesDefined_Handler", "(", "$", "Sender", ")", "{", "$", "Sender", "->", "Preferences", "[", "'Notifications'", "]", "[", "'Email.DiscussionComment'", "]", "=", "T", "(", "'Notify me when people comment on my discussions....
Adds email notification options to profiles. @since 2.0.0 @package Vanilla @param ProfileController $Sender
[ "Adds", "email", "notification", "options", "to", "profiles", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/settings/class.hooks.php#L250-L297
train
bishopb/vanilla
applications/vanilla/settings/class.hooks.php
VanillaHooks.ProfileController_Comments_Create
public function ProfileController_Comments_Create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '') { $Sender->EditMode(FALSE); $View = $Sender->View; // Tell the ProfileController what tab to load $Sender->GetUserInfo($UserReference, $Username, $UserID); $Sender->_SetBreadcrumbs(T('Comments'), UserUrl($Sender->User, '', 'comments')); $Sender->SetTabView('Comments', 'profile', 'Discussion', 'Vanilla'); $PageSize = Gdn::Config('Vanilla.Discussions.PerPage', 30); list($Offset, $Limit) = OffsetLimit($Page, $PageSize); $CommentModel = new CommentModel(); $Comments = $CommentModel->GetByUser2($Sender->User->UserID, $Limit, $Offset, $Sender->Request->Get('lid')); $TotalRecords = $Offset + $CommentModel->LastCommentCount + 1; // Build a pager $PagerFactory = new Gdn_PagerFactory(); $Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender); $Sender->Pager->MoreCode = 'More Comments'; $Sender->Pager->LessCode = 'Newer Comments'; $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure( $Offset, $Limit, $TotalRecords, UserUrl($Sender->User, '', 'comments').'?page={Page}' //?lid='.$CommentModel->LastCommentID ); // Deliver JSON data if necessary if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) { $Sender->SetJson('LessRow', $Sender->Pager->ToString('less')); $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more')); $Sender->View = 'profilecomments'; } $Sender->SetData('Comments', $Comments); // Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views $Sender->HandlerType = HANDLER_TYPE_NORMAL; // Do not show discussion options $Sender->ShowOptions = FALSE; if ($Sender->Head) { $Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive')); } // Render the ProfileController $Sender->Render(); }
php
public function ProfileController_Comments_Create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '') { $Sender->EditMode(FALSE); $View = $Sender->View; // Tell the ProfileController what tab to load $Sender->GetUserInfo($UserReference, $Username, $UserID); $Sender->_SetBreadcrumbs(T('Comments'), UserUrl($Sender->User, '', 'comments')); $Sender->SetTabView('Comments', 'profile', 'Discussion', 'Vanilla'); $PageSize = Gdn::Config('Vanilla.Discussions.PerPage', 30); list($Offset, $Limit) = OffsetLimit($Page, $PageSize); $CommentModel = new CommentModel(); $Comments = $CommentModel->GetByUser2($Sender->User->UserID, $Limit, $Offset, $Sender->Request->Get('lid')); $TotalRecords = $Offset + $CommentModel->LastCommentCount + 1; // Build a pager $PagerFactory = new Gdn_PagerFactory(); $Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender); $Sender->Pager->MoreCode = 'More Comments'; $Sender->Pager->LessCode = 'Newer Comments'; $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure( $Offset, $Limit, $TotalRecords, UserUrl($Sender->User, '', 'comments').'?page={Page}' //?lid='.$CommentModel->LastCommentID ); // Deliver JSON data if necessary if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) { $Sender->SetJson('LessRow', $Sender->Pager->ToString('less')); $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more')); $Sender->View = 'profilecomments'; } $Sender->SetData('Comments', $Comments); // Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views $Sender->HandlerType = HANDLER_TYPE_NORMAL; // Do not show discussion options $Sender->ShowOptions = FALSE; if ($Sender->Head) { $Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive')); } // Render the ProfileController $Sender->Render(); }
[ "public", "function", "ProfileController_Comments_Create", "(", "$", "Sender", ",", "$", "UserReference", "=", "''", ",", "$", "Username", "=", "''", ",", "$", "Page", "=", "''", ",", "$", "UserID", "=", "''", ")", "{", "$", "Sender", "->", "EditMode", ...
Creates virtual 'Comments' method in ProfileController. @since 2.0.0 @package Vanilla @param ProfileController $Sender ProfileController.
[ "Creates", "virtual", "Comments", "method", "in", "ProfileController", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/settings/class.hooks.php#L362-L410
train
bishopb/vanilla
applications/vanilla/settings/class.hooks.php
VanillaHooks.ProfileController_Discussions_Create
public function ProfileController_Discussions_Create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '') { $Sender->EditMode(FALSE); // Tell the ProfileController what tab to load $Sender->GetUserInfo($UserReference, $Username, $UserID); $Sender->_SetBreadcrumbs(T('Discussions'), UserUrl($Sender->User, '', 'discussions')); $Sender->SetTabView('Discussions', 'Profile', 'Discussions', 'Vanilla'); $Sender->CountCommentsPerPage = C('Vanilla.Comments.PerPage', 30); list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30)); $DiscussionModel = new DiscussionModel(); $Discussions = $DiscussionModel->GetByUser($Sender->User->UserID, $Limit, $Offset); $CountDiscussions = $Offset + $DiscussionModel->LastDiscussionCount + 1; $Sender->DiscussionData = $Sender->SetData('Discussions', $Discussions); // Build a pager $PagerFactory = new Gdn_PagerFactory(); $Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender); $Sender->Pager->MoreCode = 'More Discussions'; $Sender->Pager->LessCode = 'Newer Discussions'; $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure( $Offset, $Limit, $CountDiscussions, UserUrl($Sender->User, '', 'discussions').'?page={Page}' ); // Deliver JSON data if necessary if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) { $Sender->SetJson('LessRow', $Sender->Pager->ToString('less')); $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more')); $Sender->View = 'discussions'; } // Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views $Sender->HandlerType = HANDLER_TYPE_NORMAL; // Do not show discussion options $Sender->ShowOptions = FALSE; if ($Sender->Head) { // These pages offer only duplicate content to search engines and are a bit slow. $Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive')); } // Render the ProfileController $Sender->Render(); }
php
public function ProfileController_Discussions_Create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '') { $Sender->EditMode(FALSE); // Tell the ProfileController what tab to load $Sender->GetUserInfo($UserReference, $Username, $UserID); $Sender->_SetBreadcrumbs(T('Discussions'), UserUrl($Sender->User, '', 'discussions')); $Sender->SetTabView('Discussions', 'Profile', 'Discussions', 'Vanilla'); $Sender->CountCommentsPerPage = C('Vanilla.Comments.PerPage', 30); list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30)); $DiscussionModel = new DiscussionModel(); $Discussions = $DiscussionModel->GetByUser($Sender->User->UserID, $Limit, $Offset); $CountDiscussions = $Offset + $DiscussionModel->LastDiscussionCount + 1; $Sender->DiscussionData = $Sender->SetData('Discussions', $Discussions); // Build a pager $PagerFactory = new Gdn_PagerFactory(); $Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender); $Sender->Pager->MoreCode = 'More Discussions'; $Sender->Pager->LessCode = 'Newer Discussions'; $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure( $Offset, $Limit, $CountDiscussions, UserUrl($Sender->User, '', 'discussions').'?page={Page}' ); // Deliver JSON data if necessary if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) { $Sender->SetJson('LessRow', $Sender->Pager->ToString('less')); $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more')); $Sender->View = 'discussions'; } // Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views $Sender->HandlerType = HANDLER_TYPE_NORMAL; // Do not show discussion options $Sender->ShowOptions = FALSE; if ($Sender->Head) { // These pages offer only duplicate content to search engines and are a bit slow. $Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive')); } // Render the ProfileController $Sender->Render(); }
[ "public", "function", "ProfileController_Discussions_Create", "(", "$", "Sender", ",", "$", "UserReference", "=", "''", ",", "$", "Username", "=", "''", ",", "$", "Page", "=", "''", ",", "$", "UserID", "=", "''", ")", "{", "$", "Sender", "->", "EditMode"...
Creates virtual 'Discussions' method in ProfileController. @since 2.0.0 @package Vanilla @param ProfileController $Sender ProfileController.
[ "Creates", "virtual", "Discussions", "method", "in", "ProfileController", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/settings/class.hooks.php#L420-L469
train
bishopb/vanilla
applications/vanilla/settings/class.hooks.php
VanillaHooks.Base_GetAppSettingsMenuItems_Handler
public function Base_GetAppSettingsMenuItems_Handler($Sender) { $Menu = &$Sender->EventArguments['SideMenu']; $Menu->AddLink('Moderation', T('Flood Control'), 'vanilla/settings/floodcontrol', 'Garden.Settings.Manage'); $Menu->AddLink('Forum', T('Categories'), 'vanilla/settings/managecategories', 'Garden.Settings.Manage'); $Menu->AddLink('Forum', T('Advanced'), 'vanilla/settings/advanced', 'Garden.Settings.Manage'); $Menu->AddLink('Forum', T('Blog Comments'), 'dashboard/embed/comments', 'Garden.Settings.Manage'); $Menu->AddLink('Forum', T('Embed Forum'), 'dashboard/embed/forum', 'Garden.Settings.Manage'); }
php
public function Base_GetAppSettingsMenuItems_Handler($Sender) { $Menu = &$Sender->EventArguments['SideMenu']; $Menu->AddLink('Moderation', T('Flood Control'), 'vanilla/settings/floodcontrol', 'Garden.Settings.Manage'); $Menu->AddLink('Forum', T('Categories'), 'vanilla/settings/managecategories', 'Garden.Settings.Manage'); $Menu->AddLink('Forum', T('Advanced'), 'vanilla/settings/advanced', 'Garden.Settings.Manage'); $Menu->AddLink('Forum', T('Blog Comments'), 'dashboard/embed/comments', 'Garden.Settings.Manage'); $Menu->AddLink('Forum', T('Embed Forum'), 'dashboard/embed/forum', 'Garden.Settings.Manage'); }
[ "public", "function", "Base_GetAppSettingsMenuItems_Handler", "(", "$", "Sender", ")", "{", "$", "Menu", "=", "&", "$", "Sender", "->", "EventArguments", "[", "'SideMenu'", "]", ";", "$", "Menu", "->", "AddLink", "(", "'Moderation'", ",", "T", "(", "'Flood C...
Adds items to dashboard menu. @since 2.0.0 @package Vanilla @param object $Sender DashboardController.
[ "Adds", "items", "to", "dashboard", "menu", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/settings/class.hooks.php#L539-L546
train
bishopb/vanilla
applications/vanilla/settings/class.hooks.php
VanillaHooks.Setup
public function Setup() { $Database = Gdn::Database(); $Config = Gdn::Factory(Gdn::AliasConfig); $Drop = Gdn::Config('Vanilla.Version') === FALSE ? TRUE : FALSE; $Explicit = TRUE; // Call structure.php to update database $Validation = new Gdn_Validation(); // Needed by structure.php to validate permission names include(PATH_APPLICATIONS . DS . 'vanilla' . DS . 'settings' . DS . 'structure.php'); SaveToConfig('Routes.DefaultController', 'discussions'); }
php
public function Setup() { $Database = Gdn::Database(); $Config = Gdn::Factory(Gdn::AliasConfig); $Drop = Gdn::Config('Vanilla.Version') === FALSE ? TRUE : FALSE; $Explicit = TRUE; // Call structure.php to update database $Validation = new Gdn_Validation(); // Needed by structure.php to validate permission names include(PATH_APPLICATIONS . DS . 'vanilla' . DS . 'settings' . DS . 'structure.php'); SaveToConfig('Routes.DefaultController', 'discussions'); }
[ "public", "function", "Setup", "(", ")", "{", "$", "Database", "=", "Gdn", "::", "Database", "(", ")", ";", "$", "Config", "=", "Gdn", "::", "Factory", "(", "Gdn", "::", "AliasConfig", ")", ";", "$", "Drop", "=", "Gdn", "::", "Config", "(", "'Vanil...
Automatically executed when application is enabled. @since 2.0.0 @package Vanilla
[ "Automatically", "executed", "when", "application", "is", "enabled", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/settings/class.hooks.php#L554-L565
train
phossa2/libs
src/Phossa2/Di/Traits/InstanceFactoryTrait.php
InstanceFactoryTrait.getInstance
protected function getInstance(/*# string */ $id, array $args) { // get id & scope info list($rawId, $scopedId, $scope) = $this->realScopeInfo($id); // get from the pool if (isset($this->pool[$scopedId])) { return $this->pool[$scopedId]; } // create instance $instance = $this->createInstance($rawId, $args); // save in the pool if (empty($args) && ScopeInterface::SCOPE_SINGLE !== $scope) { $this->pool[$scopedId] = $instance; } return $instance; }
php
protected function getInstance(/*# string */ $id, array $args) { // get id & scope info list($rawId, $scopedId, $scope) = $this->realScopeInfo($id); // get from the pool if (isset($this->pool[$scopedId])) { return $this->pool[$scopedId]; } // create instance $instance = $this->createInstance($rawId, $args); // save in the pool if (empty($args) && ScopeInterface::SCOPE_SINGLE !== $scope) { $this->pool[$scopedId] = $instance; } return $instance; }
[ "protected", "function", "getInstance", "(", "/*# string */", "$", "id", ",", "array", "$", "args", ")", "{", "// get id & scope info", "list", "(", "$", "rawId", ",", "$", "scopedId", ",", "$", "scope", ")", "=", "$", "this", "->", "realScopeInfo", "(", ...
Get the instance either from the pool or create it @param string $id service id with or without the scope @param array $args arguments for the constructor @return object @throws LogicException if instantiation goes wrong @throws RuntimeException if method execution goes wrong @access protected
[ "Get", "the", "instance", "either", "from", "the", "pool", "or", "create", "it" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Traits/InstanceFactoryTrait.php#L68-L87
train
phossa2/libs
src/Phossa2/Di/Traits/InstanceFactoryTrait.php
InstanceFactoryTrait.realScopeInfo
protected function realScopeInfo(/*# string */ $id)/*# : array */ { list($rawId, $scope) = $this->scopedInfo($id); // special treatment if $scope is a '#service_id' if (isset($this->loop[$scope])) { $scope .= '_' . $this->loop[$scope]; } return [$rawId, $this->scopedId($rawId, $scope), $scope]; }
php
protected function realScopeInfo(/*# string */ $id)/*# : array */ { list($rawId, $scope) = $this->scopedInfo($id); // special treatment if $scope is a '#service_id' if (isset($this->loop[$scope])) { $scope .= '_' . $this->loop[$scope]; } return [$rawId, $this->scopedId($rawId, $scope), $scope]; }
[ "protected", "function", "realScopeInfo", "(", "/*# string */", "$", "id", ")", "/*# : array */", "{", "list", "(", "$", "rawId", ",", "$", "scope", ")", "=", "$", "this", "->", "scopedInfo", "(", "$", "id", ")", ";", "// special treatment if $scope is a '#ser...
Full scope info with consideration of ancestor instances @param string $id @return array @access protected
[ "Full", "scope", "info", "with", "consideration", "of", "ancestor", "instances" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Traits/InstanceFactoryTrait.php#L96-L106
train
phossa2/libs
src/Phossa2/Di/Traits/InstanceFactoryTrait.php
InstanceFactoryTrait.createInstance
protected function createInstance(/*# string */ $rawId, array $args) { // conver 'service_id' to '#service_id' $serviceId = ObjectResolver::getServiceId($rawId); if (isset($this->loop[$serviceId])) { throw new LogicException( Message::get(Message::DI_LOOP_DETECTED, $rawId), Message::DI_LOOP_DETECTED ); } else { $this->loop[$serviceId] = ++$this->counter; $obj = $this->getFactory()->createInstance($rawId, $args); unset($this->loop[$serviceId]); return $obj; } }
php
protected function createInstance(/*# string */ $rawId, array $args) { // conver 'service_id' to '#service_id' $serviceId = ObjectResolver::getServiceId($rawId); if (isset($this->loop[$serviceId])) { throw new LogicException( Message::get(Message::DI_LOOP_DETECTED, $rawId), Message::DI_LOOP_DETECTED ); } else { $this->loop[$serviceId] = ++$this->counter; $obj = $this->getFactory()->createInstance($rawId, $args); unset($this->loop[$serviceId]); return $obj; } }
[ "protected", "function", "createInstance", "(", "/*# string */", "$", "rawId", ",", "array", "$", "args", ")", "{", "// conver 'service_id' to '#service_id'", "$", "serviceId", "=", "ObjectResolver", "::", "getServiceId", "(", "$", "rawId", ")", ";", "if", "(", ...
Create the instance with loop detection Loop: an instance depends on itself in the creation chain. @param string $rawId @param array $args arguments for the constructor if any @return object @throws LogicException if instantiation goes wrong or loop detected @access protected
[ "Create", "the", "instance", "with", "loop", "detection" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Traits/InstanceFactoryTrait.php#L119-L135
train
phossa2/libs
src/Phossa2/Di/Traits/InstanceFactoryTrait.php
InstanceFactoryTrait.initContainer
protected function initContainer() { $initNode = $this->getResolver()->getSectionId('', 'init'); if ($this->getResolver()->has($initNode)) { $this->getFactory()->executeMethodBatch( $this->getResolver()->get($initNode) ); } return $this; }
php
protected function initContainer() { $initNode = $this->getResolver()->getSectionId('', 'init'); if ($this->getResolver()->has($initNode)) { $this->getFactory()->executeMethodBatch( $this->getResolver()->get($initNode) ); } return $this; }
[ "protected", "function", "initContainer", "(", ")", "{", "$", "initNode", "=", "$", "this", "->", "getResolver", "(", ")", "->", "getSectionId", "(", "''", ",", "'init'", ")", ";", "if", "(", "$", "this", "->", "getResolver", "(", ")", "->", "has", "...
execute init methods defined in 'di.init' node @return $this @throws RuntimeException if anything goes wrong @access protected
[ "execute", "init", "methods", "defined", "in", "di", ".", "init", "node" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Traits/InstanceFactoryTrait.php#L144-L154
train
easy-system/es-http
src/Response/SapiEmitter.php
SapiEmitter.emit
public function emit(ResponseInterface $response) { $filename = $linenum = null; if (headers_sent($filename, $linenum)) { throw new RuntimeException(sprintf( 'Unable to emit response; headers already sent in "%s" ' . 'on line "%s".', $filename, $linenum )); } $this ->emitStatusLine($response) ->emitHeaders($response) ->emitBody($response); }
php
public function emit(ResponseInterface $response) { $filename = $linenum = null; if (headers_sent($filename, $linenum)) { throw new RuntimeException(sprintf( 'Unable to emit response; headers already sent in "%s" ' . 'on line "%s".', $filename, $linenum )); } $this ->emitStatusLine($response) ->emitHeaders($response) ->emitBody($response); }
[ "public", "function", "emit", "(", "ResponseInterface", "$", "response", ")", "{", "$", "filename", "=", "$", "linenum", "=", "null", ";", "if", "(", "headers_sent", "(", "$", "filename", ",", "$", "linenum", ")", ")", "{", "throw", "new", "RuntimeExcept...
Emits the response. @param \Psr\Http\Message\ResponseInterface $response The response @throws \RuntimeException If headers is already sent
[ "Emits", "the", "response", "." ]
dd5852e94901e147a7546a8715133408ece767a1
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Response/SapiEmitter.php#L27-L42
train
easy-system/es-http
src/Response/SapiEmitter.php
SapiEmitter.emitStatusLine
protected function emitStatusLine(ResponseInterface $response) { $reasonPhrase = $response->getReasonPhrase(); header(sprintf( 'HTTP/%s %d%s', $response->getProtocolVersion(), $response->getStatusCode(), ($reasonPhrase ? ' ' . $reasonPhrase : '') )); return $this; }
php
protected function emitStatusLine(ResponseInterface $response) { $reasonPhrase = $response->getReasonPhrase(); header(sprintf( 'HTTP/%s %d%s', $response->getProtocolVersion(), $response->getStatusCode(), ($reasonPhrase ? ' ' . $reasonPhrase : '') )); return $this; }
[ "protected", "function", "emitStatusLine", "(", "ResponseInterface", "$", "response", ")", "{", "$", "reasonPhrase", "=", "$", "response", "->", "getReasonPhrase", "(", ")", ";", "header", "(", "sprintf", "(", "'HTTP/%s %d%s'", ",", "$", "response", "->", "get...
Emits the status line. @param \Psr\Http\Message\ResponseInterface $response The response @return self
[ "Emits", "the", "status", "line", "." ]
dd5852e94901e147a7546a8715133408ece767a1
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Response/SapiEmitter.php#L51-L62
train
easy-system/es-http
src/Response/SapiEmitter.php
SapiEmitter.emitHeaders
protected function emitHeaders(ResponseInterface $response) { $normalize = function ($headerName) { $name = str_replace('-', ' ', $headerName); $filtered = str_replace(' ', '-', ucwords($name)); return $filtered; }; foreach ($response->getHeaders() as $headerName => $values) { $name = $normalize($headerName); $first = true; foreach ($values as $value) { header(sprintf( '%s: %s', $name, $value ), $first); $first = false; } } return $this; }
php
protected function emitHeaders(ResponseInterface $response) { $normalize = function ($headerName) { $name = str_replace('-', ' ', $headerName); $filtered = str_replace(' ', '-', ucwords($name)); return $filtered; }; foreach ($response->getHeaders() as $headerName => $values) { $name = $normalize($headerName); $first = true; foreach ($values as $value) { header(sprintf( '%s: %s', $name, $value ), $first); $first = false; } } return $this; }
[ "protected", "function", "emitHeaders", "(", "ResponseInterface", "$", "response", ")", "{", "$", "normalize", "=", "function", "(", "$", "headerName", ")", "{", "$", "name", "=", "str_replace", "(", "'-'", ",", "' '", ",", "$", "headerName", ")", ";", "...
Emits headers. @param \Psr\Http\Message\ResponseInterface $response The response @return self
[ "Emits", "headers", "." ]
dd5852e94901e147a7546a8715133408ece767a1
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Response/SapiEmitter.php#L71-L93
train
easy-system/es-http
src/Response/SapiEmitter.php
SapiEmitter.emitBody
protected function emitBody(ResponseInterface $response) { while (ob_get_level()) { ob_end_flush(); } $body = $response->getBody(); if ($body->getSize()) { echo $body; } return $this; }
php
protected function emitBody(ResponseInterface $response) { while (ob_get_level()) { ob_end_flush(); } $body = $response->getBody(); if ($body->getSize()) { echo $body; } return $this; }
[ "protected", "function", "emitBody", "(", "ResponseInterface", "$", "response", ")", "{", "while", "(", "ob_get_level", "(", ")", ")", "{", "ob_end_flush", "(", ")", ";", "}", "$", "body", "=", "$", "response", "->", "getBody", "(", ")", ";", "if", "("...
Emits body. @param \Psr\Http\Message\ResponseInterface $response The response @return self
[ "Emits", "body", "." ]
dd5852e94901e147a7546a8715133408ece767a1
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Response/SapiEmitter.php#L102-L114
train
reflex-php/lockdown
src/Reflex/Lockdown/Roles/Eloquent/Provider.php
Provider.findWithPermission
public function findWithPermission($permission) { return array_filter( $this->findAll(), function ($role) use ($permission) { return $role->has($permission); } ); }
php
public function findWithPermission($permission) { return array_filter( $this->findAll(), function ($role) use ($permission) { return $role->has($permission); } ); }
[ "public", "function", "findWithPermission", "(", "$", "permission", ")", "{", "return", "array_filter", "(", "$", "this", "->", "findAll", "(", ")", ",", "function", "(", "$", "role", ")", "use", "(", "$", "permission", ")", "{", "return", "$", "role", ...
Find roles with permission @param \Reflex\Lockdown\Permissions\PermissionInterface $permission Permission instance @return mixed
[ "Find", "roles", "with", "permission" ]
2798e448608eef469f2924d75013deccfd6aca44
https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Roles/Eloquent/Provider.php#L128-L136
train
reflex-php/lockdown
src/Reflex/Lockdown/Roles/Eloquent/Provider.php
Provider.findWithoutPermission
public function findWithoutPermission($permission) { return array_filter( $this->findAll(), function ($role) use ($permission) { return $role->hasnt($permission); } ); }
php
public function findWithoutPermission($permission) { return array_filter( $this->findAll(), function ($role) use ($permission) { return $role->hasnt($permission); } ); }
[ "public", "function", "findWithoutPermission", "(", "$", "permission", ")", "{", "return", "array_filter", "(", "$", "this", "->", "findAll", "(", ")", ",", "function", "(", "$", "role", ")", "use", "(", "$", "permission", ")", "{", "return", "$", "role"...
Find roles without permission @param \Reflex\Lockdown\Permissions\PermissionInterface $permission Permission instance @return mixed
[ "Find", "roles", "without", "permission" ]
2798e448608eef469f2924d75013deccfd6aca44
https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Roles/Eloquent/Provider.php#L144-L152
train
monomelodies/ornament
src/Adapter/Pdo.php
Pdo.load
public function load(Container $object) { $pks = []; $values = $this->parameters; $identifier = $this->identifier; foreach ($this->primaryKey as $key) { if (isset($object->$key)) { $pks[$key] = sprintf('%s.%s = ?', $identifier, $key); $values[] = $object->$key; } else { throw new Exception\PrimaryKey($identifier, $key); } } $fields = $this->fields; foreach ($fields as &$field) { $field = "$identifier.$field"; } $identifier .= $this->generateJoin($fields); $sql = "SELECT %s FROM %s WHERE %s"; $stmt = $this->getStatement(sprintf( $sql, implode(', ', $fields), $identifier, implode(' AND ', $pks) )); $stmt->setFetchMode(Base::FETCH_INTO, $object); $stmt->execute($values); $stmt->fetch(); $object->markClean(); }
php
public function load(Container $object) { $pks = []; $values = $this->parameters; $identifier = $this->identifier; foreach ($this->primaryKey as $key) { if (isset($object->$key)) { $pks[$key] = sprintf('%s.%s = ?', $identifier, $key); $values[] = $object->$key; } else { throw new Exception\PrimaryKey($identifier, $key); } } $fields = $this->fields; foreach ($fields as &$field) { $field = "$identifier.$field"; } $identifier .= $this->generateJoin($fields); $sql = "SELECT %s FROM %s WHERE %s"; $stmt = $this->getStatement(sprintf( $sql, implode(', ', $fields), $identifier, implode(' AND ', $pks) )); $stmt->setFetchMode(Base::FETCH_INTO, $object); $stmt->execute($values); $stmt->fetch(); $object->markClean(); }
[ "public", "function", "load", "(", "Container", "$", "object", ")", "{", "$", "pks", "=", "[", "]", ";", "$", "values", "=", "$", "this", "->", "parameters", ";", "$", "identifier", "=", "$", "this", "->", "identifier", ";", "foreach", "(", "$", "t...
Load data into a single model. @param Container $object A container object. @return void @throws Ornament\Exception\PrimaryKey if no primary key was set or could be determined, and loading would inevitably fail.
[ "Load", "data", "into", "a", "single", "model", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Adapter/Pdo.php#L107-L136
train
monomelodies/ornament
src/Adapter/Pdo.php
Pdo.generateJoin
protected function generateJoin(array &$fields) { $annotations = $this->annotations['class']; $props = $this->annotations['properties']; $table = ''; foreach (['Require' => '', 'Include' => 'LEFT '] as $type => $join) { if (isset($annotations[$type])) { foreach ($annotations[$type] as $local => $joinCond) { if (is_numeric($local)) { foreach ($joinCond as $local => $joinCond) { } } // Hack to make the annotationParser recurse. $joinCond = AnnotationParser::getAnnotations( '/** @joinCond '.implode(', ', $joinCond).' */' )['joincond']; $table .= sprintf( ' %1$sJOIN %2$s ON ', $join, $local ); $conds = []; foreach ($joinCond as $ref => $me) { if ($me == '?') { $conds[] = sprintf( "%s.%s = $me", $local, $ref ); } else { $conds[] = sprintf( "%s.%s = %s.%s", $local, $ref, $this->identifier, $me ); } } $table .= implode(" AND ", $conds); } } } foreach ($fields as &$field) { $name = str_replace("{$this->identifier}.", '', $field); if (isset($props[$name]['From'])) { $field = sprintf( '%s %s', $props[$name]['From'], $name ); } } return $table; }
php
protected function generateJoin(array &$fields) { $annotations = $this->annotations['class']; $props = $this->annotations['properties']; $table = ''; foreach (['Require' => '', 'Include' => 'LEFT '] as $type => $join) { if (isset($annotations[$type])) { foreach ($annotations[$type] as $local => $joinCond) { if (is_numeric($local)) { foreach ($joinCond as $local => $joinCond) { } } // Hack to make the annotationParser recurse. $joinCond = AnnotationParser::getAnnotations( '/** @joinCond '.implode(', ', $joinCond).' */' )['joincond']; $table .= sprintf( ' %1$sJOIN %2$s ON ', $join, $local ); $conds = []; foreach ($joinCond as $ref => $me) { if ($me == '?') { $conds[] = sprintf( "%s.%s = $me", $local, $ref ); } else { $conds[] = sprintf( "%s.%s = %s.%s", $local, $ref, $this->identifier, $me ); } } $table .= implode(" AND ", $conds); } } } foreach ($fields as &$field) { $name = str_replace("{$this->identifier}.", '', $field); if (isset($props[$name]['From'])) { $field = sprintf( '%s %s', $props[$name]['From'], $name ); } } return $table; }
[ "protected", "function", "generateJoin", "(", "array", "&", "$", "fields", ")", "{", "$", "annotations", "=", "$", "this", "->", "annotations", "[", "'class'", "]", ";", "$", "props", "=", "$", "this", "->", "annotations", "[", "'properties'", "]", ";", ...
Internal helper to generate a JOIN statement. @param array $fields Array of fields to extend. @return string The JOIN statement to append to the query string.
[ "Internal", "helper", "to", "generate", "a", "JOIN", "statement", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Adapter/Pdo.php#L144-L198
train
monomelodies/ornament
src/Adapter/Pdo.php
Pdo.getStatement
protected function getStatement($sql) { if (!isset($this->statements[$sql])) { $this->statements[$sql] = $this->adapter->prepare($sql); } return $this->statements[$sql]; }
php
protected function getStatement($sql) { if (!isset($this->statements[$sql])) { $this->statements[$sql] = $this->adapter->prepare($sql); } return $this->statements[$sql]; }
[ "protected", "function", "getStatement", "(", "$", "sql", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "statements", "[", "$", "sql", "]", ")", ")", "{", "$", "this", "->", "statements", "[", "$", "sql", "]", "=", "$", "this", "->",...
Protected helper to either get or create a PDOStatement. @param string $sql SQL to prepare the statement with. @return PDOStatement A PDOStatement.
[ "Protected", "helper", "to", "either", "get", "or", "create", "a", "PDOStatement", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Adapter/Pdo.php#L206-L212
train
thunderwolf/twAdminPlugin
lib/twAdmin.class.php
twAdmin.routeExists
public static function routeExists($route, sfContext $context) { try { if ($route{0} == '@') { $context->getRouting()->generate(substr($route, 1)); } return true; } catch (Exception $e) { return false; } }
php
public static function routeExists($route, sfContext $context) { try { if ($route{0} == '@') { $context->getRouting()->generate(substr($route, 1)); } return true; } catch (Exception $e) { return false; } }
[ "public", "static", "function", "routeExists", "(", "$", "route", ",", "sfContext", "$", "context", ")", "{", "try", "{", "if", "(", "$", "route", "{", "0", "}", "==", "'@'", ")", "{", "$", "context", "->", "getRouting", "(", ")", "->", "generate", ...
Check if the supplied route exists @param string $route @param sfContext $context @return boolean
[ "Check", "if", "the", "supplied", "route", "exists" ]
85a4af0f49a535b6c8327567524f770f805d6454
https://github.com/thunderwolf/twAdminPlugin/blob/85a4af0f49a535b6c8327567524f770f805d6454/lib/twAdmin.class.php#L44-L54
train
agalbourdin/agl-core
src/Mysql/Query/Raw.php
Raw.query
public function query($pQuery, array $pParams = array()) { $this->_stm = Agl::app()->getDb()->getConnection()->prepare($pQuery); if (! $this->_stm->execute($pParams)) { $error = $this->_stm->errorInfo(); throw new Exception("The query failed with message '" . $error[2] . "'"); } if (Agl::app()->isDebugMode()) { Agl::app()->getDb()->incrementCounter(); } return $this->_stm->fetchAll(PDO::FETCH_ASSOC); }
php
public function query($pQuery, array $pParams = array()) { $this->_stm = Agl::app()->getDb()->getConnection()->prepare($pQuery); if (! $this->_stm->execute($pParams)) { $error = $this->_stm->errorInfo(); throw new Exception("The query failed with message '" . $error[2] . "'"); } if (Agl::app()->isDebugMode()) { Agl::app()->getDb()->incrementCounter(); } return $this->_stm->fetchAll(PDO::FETCH_ASSOC); }
[ "public", "function", "query", "(", "$", "pQuery", ",", "array", "$", "pParams", "=", "array", "(", ")", ")", "{", "$", "this", "->", "_stm", "=", "Agl", "::", "app", "(", ")", "->", "getDb", "(", ")", "->", "getConnection", "(", ")", "->", "prep...
Commit the query to the database and return the result. @return Select
[ "Commit", "the", "query", "to", "the", "database", "and", "return", "the", "result", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mysql/Query/Raw.php#L34-L48
train
halimonalexander/sid
src/Sid.php
Sid.extractConstants
private static function extractConstants() { $oClass = new \ReflectionClass(get_called_class()); $constants = $oClass->getConstants(); unset( $constants['IS_IMPLICIT_ABSTRACT'], $constants['IS_EXPLICIT_ABSTRACT'], $constants['IS_FINAL'] ); return $constants; }
php
private static function extractConstants() { $oClass = new \ReflectionClass(get_called_class()); $constants = $oClass->getConstants(); unset( $constants['IS_IMPLICIT_ABSTRACT'], $constants['IS_EXPLICIT_ABSTRACT'], $constants['IS_FINAL'] ); return $constants; }
[ "private", "static", "function", "extractConstants", "(", ")", "{", "$", "oClass", "=", "new", "\\", "ReflectionClass", "(", "get_called_class", "(", ")", ")", ";", "$", "constants", "=", "$", "oClass", "->", "getConstants", "(", ")", ";", "unset", "(", ...
Extract constants using ReflectionClass
[ "Extract", "constants", "using", "ReflectionClass" ]
7bfa551af1b941c95e9be81812e5edecd9d9bd16
https://github.com/halimonalexander/sid/blob/7bfa551af1b941c95e9be81812e5edecd9d9bd16/src/Sid.php#L56-L67
train
halimonalexander/sid
src/Sid.php
Sid.updateHiddenValue
protected static function updateHiddenValue($list, $name) { $sid = $list[$name]; unset($list[$name]); preg_match("/" . self::$hiddenSidNamePattern . "/", $name, $match); $list[$match[1]] = $sid; return $list; }
php
protected static function updateHiddenValue($list, $name) { $sid = $list[$name]; unset($list[$name]); preg_match("/" . self::$hiddenSidNamePattern . "/", $name, $match); $list[$match[1]] = $sid; return $list; }
[ "protected", "static", "function", "updateHiddenValue", "(", "$", "list", ",", "$", "name", ")", "{", "$", "sid", "=", "$", "list", "[", "$", "name", "]", ";", "unset", "(", "$", "list", "[", "$", "name", "]", ")", ";", "preg_match", "(", "\"/\"", ...
Update hidden value's name by removing leading _ @param $list @param $name @return mixed
[ "Update", "hidden", "value", "s", "name", "by", "removing", "leading", "_" ]
7bfa551af1b941c95e9be81812e5edecd9d9bd16
https://github.com/halimonalexander/sid/blob/7bfa551af1b941c95e9be81812e5edecd9d9bd16/src/Sid.php#L134-L143
train
halimonalexander/sid
src/Sid.php
Sid.getList
public static function getList(bool $full = false) { $class = get_called_class(); if (empty(self::$list[$class])) { self::$list[$class] = self::loadList(); } $list = self::$list[$class]; foreach ($list as $name => $sid) { if (static::isHidden($name)) { if (!$full) unset($list[$name]); else $list = self::updateHiddenValue($list, $name); } } return $list; }
php
public static function getList(bool $full = false) { $class = get_called_class(); if (empty(self::$list[$class])) { self::$list[$class] = self::loadList(); } $list = self::$list[$class]; foreach ($list as $name => $sid) { if (static::isHidden($name)) { if (!$full) unset($list[$name]); else $list = self::updateHiddenValue($list, $name); } } return $list; }
[ "public", "static", "function", "getList", "(", "bool", "$", "full", "=", "false", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "empty", "(", "self", "::", "$", "list", "[", "$", "class", "]", ")", ")", "{", "self", ...
Get full sid list @param bool $full @return array List of values as: Name => Sid
[ "Get", "full", "sid", "list" ]
7bfa551af1b941c95e9be81812e5edecd9d9bd16
https://github.com/halimonalexander/sid/blob/7bfa551af1b941c95e9be81812e5edecd9d9bd16/src/Sid.php#L199-L218
train
halimonalexander/sid
src/Sid.php
Sid.getNameById
public static function getNameById($sid) { $list = self::getList(true); $key = array_search($sid, $list); if ($key === false) throw new SidItemNotFound('Sid not exists'); return $key; }
php
public static function getNameById($sid) { $list = self::getList(true); $key = array_search($sid, $list); if ($key === false) throw new SidItemNotFound('Sid not exists'); return $key; }
[ "public", "static", "function", "getNameById", "(", "$", "sid", ")", "{", "$", "list", "=", "self", "::", "getList", "(", "true", ")", ";", "$", "key", "=", "array_search", "(", "$", "sid", ",", "$", "list", ")", ";", "if", "(", "$", "key", "==="...
Return constant name from SID. @param int $id SID to find @return string Name of constant. @throws SidItemNotFound
[ "Return", "constant", "name", "from", "SID", "." ]
7bfa551af1b941c95e9be81812e5edecd9d9bd16
https://github.com/halimonalexander/sid/blob/7bfa551af1b941c95e9be81812e5edecd9d9bd16/src/Sid.php#L239-L247
train
halimonalexander/sid
src/Sid.php
Sid.getTitle
public static function getTitle($id, $lang, $context = 'default') { $name = self::getNameById($id); $class = self::getClassWithoutNamespace(); return call_user_func(self::getCallback($lang), $name, $class, $context); }
php
public static function getTitle($id, $lang, $context = 'default') { $name = self::getNameById($id); $class = self::getClassWithoutNamespace(); return call_user_func(self::getCallback($lang), $name, $class, $context); }
[ "public", "static", "function", "getTitle", "(", "$", "id", ",", "$", "lang", ",", "$", "context", "=", "'default'", ")", "{", "$", "name", "=", "self", "::", "getNameById", "(", "$", "id", ")", ";", "$", "class", "=", "self", "::", "getClassWithoutN...
Get Sid title from vocabulary @param int $id @param string $lang @param string $context @return mixed
[ "Get", "Sid", "title", "from", "vocabulary" ]
7bfa551af1b941c95e9be81812e5edecd9d9bd16
https://github.com/halimonalexander/sid/blob/7bfa551af1b941c95e9be81812e5edecd9d9bd16/src/Sid.php#L258-L264
train
setrun/setrun-component-sys
src/behaviors/TimeAgoBehavior.php
TimeAgoBehavior.getTimeAgo
public function getTimeAgo($field = null, $options = []){ $attribute = $this->attribute; if ($field !== null) { $attribute = $field; } $year = $options['year'] ?? 'full:{day} {month} {year}'; $month = $options['month'] ?? 'full:{day} {month}'; if ($this->owner->hasAttribute($attribute)) { $value = $this->owner{$attribute}; if (!is_numeric($this->owner{$attribute})) { $value = strtotime($this->owner{$attribute}); } $updatedM = date('m', $value); $currM = date('m', time()); $updatedY = date('Y', $value); $currY = date('Y', time()); if ($updatedY !== $currY) { return Html::tag('time', Yii::$app->formatter->asDate($value, 'long')); } if ($updatedM < $currM) { return Html::tag('time', Yii::$app->formatter->asDate($value, 'medium')); } return TimeAgo::widget(['timestamp' => $value, 'language' => Yii::$app->language]); } return null; }
php
public function getTimeAgo($field = null, $options = []){ $attribute = $this->attribute; if ($field !== null) { $attribute = $field; } $year = $options['year'] ?? 'full:{day} {month} {year}'; $month = $options['month'] ?? 'full:{day} {month}'; if ($this->owner->hasAttribute($attribute)) { $value = $this->owner{$attribute}; if (!is_numeric($this->owner{$attribute})) { $value = strtotime($this->owner{$attribute}); } $updatedM = date('m', $value); $currM = date('m', time()); $updatedY = date('Y', $value); $currY = date('Y', time()); if ($updatedY !== $currY) { return Html::tag('time', Yii::$app->formatter->asDate($value, 'long')); } if ($updatedM < $currM) { return Html::tag('time', Yii::$app->formatter->asDate($value, 'medium')); } return TimeAgo::widget(['timestamp' => $value, 'language' => Yii::$app->language]); } return null; }
[ "public", "function", "getTimeAgo", "(", "$", "field", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "attribute", "=", "$", "this", "->", "attribute", ";", "if", "(", "$", "field", "!==", "null", ")", "{", "$", "attribute", "=", ...
Get a date in the time ago format @return string @throws \Exception
[ "Get", "a", "date", "in", "the", "time", "ago", "format" ]
ad9a6442a2921e0f061ed4e455b050c56029d565
https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/behaviors/TimeAgoBehavior.php#L31-L59
train
PsyduckMans/PHPX-Propel
src/PHPX/Propel/Util/Ext/Direct/Criteria.php
Criteria.bindSort
public static function bindSort(\Criteria $criteria, $sort) { $direction = $sort['direction']; switch($direction) { case self::SORT_DIRECTION_DESC: $criteria->addDescendingOrderByColumn($sort['column']); break; case self::SORT_DIRECTION_ASC: $criteria->addAscendingOrderByColumn($sort['column']); break; default: throw new RuntimeException('Unsupport Ext direct sort direction:'.$direction); } }
php
public static function bindSort(\Criteria $criteria, $sort) { $direction = $sort['direction']; switch($direction) { case self::SORT_DIRECTION_DESC: $criteria->addDescendingOrderByColumn($sort['column']); break; case self::SORT_DIRECTION_ASC: $criteria->addAscendingOrderByColumn($sort['column']); break; default: throw new RuntimeException('Unsupport Ext direct sort direction:'.$direction); } }
[ "public", "static", "function", "bindSort", "(", "\\", "Criteria", "$", "criteria", ",", "$", "sort", ")", "{", "$", "direction", "=", "$", "sort", "[", "'direction'", "]", ";", "switch", "(", "$", "direction", ")", "{", "case", "self", "::", "SORT_DIR...
bind Ext direct sort to Propel Criteria @param \Criteria $criteria @param $sort array( 'direction' => 'DESC', 'column' => UserPeer::ID ) @throws RuntimeException @return void
[ "bind", "Ext", "direct", "sort", "to", "Propel", "Criteria" ]
5d251d577d47352c568cf04576b94104754dd7da
https://github.com/PsyduckMans/PHPX-Propel/blob/5d251d577d47352c568cf04576b94104754dd7da/src/PHPX/Propel/Util/Ext/Direct/Criteria.php#L38-L50
train
zoopcommerce/shard
lib/Zoop/Shard/AccessControl/AccessController.php
AccessController.areAllowed
public function areAllowed(array $actions, ClassMetadata $metadata, $document = null, ChangeSet $changeSet = null) { if (!$metadata->hasProperty('permissions')) { return new AllowedResult(false); } //first check the generic 'guest' role $result = $this->checkRolesAgainstActions(['guest'], $actions, $metadata); if (!$result->getAllowed() || $result->hasCriteria()) { //now load the user roles if the generic 'guest' role failed $roles = $this->getRoles($metadata, $document); $result = $this->checkRolesAgainstActions($roles, $actions, $metadata); } if (isset($document)) { return $this->testCritieraAgainstDocument($metadata, $document, $changeSet, $result); } return $result; }
php
public function areAllowed(array $actions, ClassMetadata $metadata, $document = null, ChangeSet $changeSet = null) { if (!$metadata->hasProperty('permissions')) { return new AllowedResult(false); } //first check the generic 'guest' role $result = $this->checkRolesAgainstActions(['guest'], $actions, $metadata); if (!$result->getAllowed() || $result->hasCriteria()) { //now load the user roles if the generic 'guest' role failed $roles = $this->getRoles($metadata, $document); $result = $this->checkRolesAgainstActions($roles, $actions, $metadata); } if (isset($document)) { return $this->testCritieraAgainstDocument($metadata, $document, $changeSet, $result); } return $result; }
[ "public", "function", "areAllowed", "(", "array", "$", "actions", ",", "ClassMetadata", "$", "metadata", ",", "$", "document", "=", "null", ",", "ChangeSet", "$", "changeSet", "=", "null", ")", "{", "if", "(", "!", "$", "metadata", "->", "hasProperty", "...
Determines if an action can be done by the current User @param array $action @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata @param type $document @return \Zoop\Shard\AccessControl\IsAllowedResult
[ "Determines", "if", "an", "action", "can", "be", "done", "by", "the", "current", "User" ]
14dde6ff25bc3125ad35667c8ff65cb755750b27
https://github.com/zoopcommerce/shard/blob/14dde6ff25bc3125ad35667c8ff65cb755750b27/lib/Zoop/Shard/AccessControl/AccessController.php#L37-L57
train
webignition/html-document-link-url-finder
src/HtmlDocumentLinkUrlFinder.php
HtmlDocumentLinkUrlFinder.looksLikeConcatenatedJsString
private function looksLikeConcatenatedJsString(string $url): bool { $patternBody = "^'\s+\+\s+.*\s+\+\s+'$"; $pattern = '/'.$patternBody.'/i'; return preg_match($pattern, $url) > 0; }
php
private function looksLikeConcatenatedJsString(string $url): bool { $patternBody = "^'\s+\+\s+.*\s+\+\s+'$"; $pattern = '/'.$patternBody.'/i'; return preg_match($pattern, $url) > 0; }
[ "private", "function", "looksLikeConcatenatedJsString", "(", "string", "$", "url", ")", ":", "bool", "{", "$", "patternBody", "=", "\"^'\\s+\\+\\s+.*\\s+\\+\\s+'$\"", ";", "$", "pattern", "=", "'/'", ".", "$", "patternBody", ".", "'/i'", ";", "return", "preg_mat...
Determine if the URL value from an element attribute looks like a concatenated JS string Some documents contain script elements which concatenate JS values together to make URLs for elements that are inserted into the DOM. This is all fine. e.g. VimeoList.push('<img src="' + value['ListImage'] + '" />'); A subset of such documents are badly-formed such that the script contents are not recognised by the DOM parser and end up as element nodes in the DOM e.g. the above would result in a <img src="' + value['ListImage'] + '" /> element present in the DOM. This applies to both the \DOMDocument parser and the W3C HTML validation parser. It is assumed both parsers are not identically buggy. We need to check if a URL value looks like a concatenated JS string so that we can exclude them. Example URL value: ' + value['ListImage'] + ' Pseudopattern: START'<whitespace?><plus char><whitespace?><anything><whitespace?><plus char><whitespace?>'END @param string $url @return bool
[ "Determine", "if", "the", "URL", "value", "from", "an", "element", "attribute", "looks", "like", "a", "concatenated", "JS", "string" ]
247820dd8c7d68ddd7f61c21dfc51fa7ed46bfbf
https://github.com/webignition/html-document-link-url-finder/blob/247820dd8c7d68ddd7f61c21dfc51fa7ed46bfbf/src/HtmlDocumentLinkUrlFinder.php#L130-L136
train
diatem-net/jin-dataformat
src/DataFormat/Csv.php
Csv.fputcsv
protected function fputcsv($filePointer, $dataArray, $delimiter = ",", $enclosure = "\"") { // Build the string $string = ""; // No leading delimiter $writeDelimiter = false; foreach ($dataArray as $dataElement) { // Replaces a double quote with two double quotes $dataElement = str_replace("\"", "\"\"", $dataElement); // Adds a delimiter before each field (except the first) if ($writeDelimiter) { $string .= $delimiter; } // Encloses each field with $enclosure and adds it to the string if ($enclosure) { $string .= $enclosure . $dataElement . $enclosure; } else { $string .= $dataElement; } // Delimiters are used every time except the first. $writeDelimiter = true; } // Append new line $string .= "\n"; // Write the string to the file fwrite($filePointer, $string); }
php
protected function fputcsv($filePointer, $dataArray, $delimiter = ",", $enclosure = "\"") { // Build the string $string = ""; // No leading delimiter $writeDelimiter = false; foreach ($dataArray as $dataElement) { // Replaces a double quote with two double quotes $dataElement = str_replace("\"", "\"\"", $dataElement); // Adds a delimiter before each field (except the first) if ($writeDelimiter) { $string .= $delimiter; } // Encloses each field with $enclosure and adds it to the string if ($enclosure) { $string .= $enclosure . $dataElement . $enclosure; } else { $string .= $dataElement; } // Delimiters are used every time except the first. $writeDelimiter = true; } // Append new line $string .= "\n"; // Write the string to the file fwrite($filePointer, $string); }
[ "protected", "function", "fputcsv", "(", "$", "filePointer", ",", "$", "dataArray", ",", "$", "delimiter", "=", "\",\"", ",", "$", "enclosure", "=", "\"\\\"\"", ")", "{", "// Build the string\r", "$", "string", "=", "\"\"", ";", "// No leading delimiter\r", "$...
Write a line to a file @param string $filePointer File resource to write in @param array $dataArray Data to write out @param string $delimiter Field separator @param string $enclosure Enclosure
[ "Write", "a", "line", "to", "a", "file" ]
3d8b0aeb8dcf0b81dc319faf79006ddea9cfa6dd
https://github.com/diatem-net/jin-dataformat/blob/3d8b0aeb8dcf0b81dc319faf79006ddea9cfa6dd/src/DataFormat/Csv.php#L177-L203
train
diatem-net/jin-dataformat
src/DataFormat/Csv.php
Csv.writeDataInIO
protected function writeDataInIO($fp) { // Écriture des données if ($this->useAssociativeArray) { foreach ($this->data as $donnee) { foreach ($donnee as &$champ) { $champ = (is_string($champ)) ? iconv("UTF-8", "Windows-1252//TRANSLIT", $champ) : $champ; } $this->fputcsv($fp, $donnee, ';', $this->enclosures); } } else { for ($i = 0; $i < count($this->data); $i++) { for ($j = 0; $j < count($this->data[$i]); $j++) { $this->fputcsv($fp, $this->data[$i][$j], ';', $this->enclosures); } } } }
php
protected function writeDataInIO($fp) { // Écriture des données if ($this->useAssociativeArray) { foreach ($this->data as $donnee) { foreach ($donnee as &$champ) { $champ = (is_string($champ)) ? iconv("UTF-8", "Windows-1252//TRANSLIT", $champ) : $champ; } $this->fputcsv($fp, $donnee, ';', $this->enclosures); } } else { for ($i = 0; $i < count($this->data); $i++) { for ($j = 0; $j < count($this->data[$i]); $j++) { $this->fputcsv($fp, $this->data[$i][$j], ';', $this->enclosures); } } } }
[ "protected", "function", "writeDataInIO", "(", "$", "fp", ")", "{", "// Écriture des données\r", "if", "(", "$", "this", "->", "useAssociativeArray", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "donnee", ")", "{", "foreach", "(", "$", ...
Ecrit dans le flux de sortie @param ressource $fp
[ "Ecrit", "dans", "le", "flux", "de", "sortie" ]
3d8b0aeb8dcf0b81dc319faf79006ddea9cfa6dd
https://github.com/diatem-net/jin-dataformat/blob/3d8b0aeb8dcf0b81dc319faf79006ddea9cfa6dd/src/DataFormat/Csv.php#L210-L227
train
seeren/application
src/Application.php
Application.sendErrorDocument
private function sendErrorDocument( ResponseInterface $response): ResponseInterface { if ($this->errorDocument && preg_match( "/^(4|5){1}[0-2]{1}[0-9]{1}$/", $response->getStatusCode()) ) { $this->errorDocument = str_replace( "{status}", $response->getStatusCode(), $this->errorDocument ); if ($this->errorDocument !== filter_input(INPUT_SERVER, "REQUEST_URI")) { $response = $response->withHeader( Response::HEADER_REFRESH, "0; " . $this->errorDocument ); } } return $response; }
php
private function sendErrorDocument( ResponseInterface $response): ResponseInterface { if ($this->errorDocument && preg_match( "/^(4|5){1}[0-2]{1}[0-9]{1}$/", $response->getStatusCode()) ) { $this->errorDocument = str_replace( "{status}", $response->getStatusCode(), $this->errorDocument ); if ($this->errorDocument !== filter_input(INPUT_SERVER, "REQUEST_URI")) { $response = $response->withHeader( Response::HEADER_REFRESH, "0; " . $this->errorDocument ); } } return $response; }
[ "private", "function", "sendErrorDocument", "(", "ResponseInterface", "$", "response", ")", ":", "ResponseInterface", "{", "if", "(", "$", "this", "->", "errorDocument", "&&", "preg_match", "(", "\"/^(4|5){1}[0-2]{1}[0-9]{1}$/\"", ",", "$", "response", "->", "getSta...
Send error document @param ResponseInterface $response psr-7 response @return ResponseInterface psr-7 response
[ "Send", "error", "document" ]
bd36ec219fa24f33cd8686f3aaae70deb9cf61ea
https://github.com/seeren/application/blob/bd36ec219fa24f33cd8686f3aaae70deb9cf61ea/src/Application.php#L54-L71
train
vakata/router
src/Router.php
Router.setPrefix
public function setPrefix(string $prefix) : RouterInterface { $prefix = trim($prefix, '/'); $this->prefix = $prefix.(strlen($prefix) ? '/' : ''); return $this; }
php
public function setPrefix(string $prefix) : RouterInterface { $prefix = trim($prefix, '/'); $this->prefix = $prefix.(strlen($prefix) ? '/' : ''); return $this; }
[ "public", "function", "setPrefix", "(", "string", "$", "prefix", ")", ":", "RouterInterface", "{", "$", "prefix", "=", "trim", "(", "$", "prefix", ",", "'/'", ")", ";", "$", "this", "->", "prefix", "=", "$", "prefix", ".", "(", "strlen", "(", "$", ...
Set the prefix for all future URLs, used mainly internally. @param string $prefix the prefix to prepend @return self
[ "Set", "the", "prefix", "for", "all", "future", "URLs", "used", "mainly", "internally", "." ]
de392bdc8ed1353a59529c3bcf78574e1ad72545
https://github.com/vakata/router/blob/de392bdc8ed1353a59529c3bcf78574e1ad72545/src/Router.php#L130-L134
train
vakata/router
src/Router.php
Router.add
public function add($method, $url = null, $handler = null) : RouterInterface { $temp = [ 'method' => [ 'GET', 'POST' ], 'url' => '', 'handler' => null ]; foreach (func_get_args() as $arg) { if (is_callable($arg)) { $temp['handler'] = $arg; } else if (in_array($arg, ['GET', 'HEAD', 'POST', 'PATCH', 'DELETE', 'PUT', 'OPTIONS', 'REPORT'])) { $temp['method'] = $arg; } else { $temp['url'] = $arg; } } list($method, $url, $handler) = array_values($temp); if (!$url && $this->prefix) { $url = $this->prefix; } else { if (!$url) { $url = '{**}'; } $url = $this->prefix.$url; } if (!$method) { $method = ['GET','POST']; } if (!is_array($method)) { $method = [$method]; } if (!is_callable($handler)) { throw new RouterException('No valid handler found'); } foreach ($method as $m) { if (!isset($this->routes[$m])) { $this->routes[$m] = []; } $this->routes[$m][$url] = $handler; } return $this; }
php
public function add($method, $url = null, $handler = null) : RouterInterface { $temp = [ 'method' => [ 'GET', 'POST' ], 'url' => '', 'handler' => null ]; foreach (func_get_args() as $arg) { if (is_callable($arg)) { $temp['handler'] = $arg; } else if (in_array($arg, ['GET', 'HEAD', 'POST', 'PATCH', 'DELETE', 'PUT', 'OPTIONS', 'REPORT'])) { $temp['method'] = $arg; } else { $temp['url'] = $arg; } } list($method, $url, $handler) = array_values($temp); if (!$url && $this->prefix) { $url = $this->prefix; } else { if (!$url) { $url = '{**}'; } $url = $this->prefix.$url; } if (!$method) { $method = ['GET','POST']; } if (!is_array($method)) { $method = [$method]; } if (!is_callable($handler)) { throw new RouterException('No valid handler found'); } foreach ($method as $m) { if (!isset($this->routes[$m])) { $this->routes[$m] = []; } $this->routes[$m][$url] = $handler; } return $this; }
[ "public", "function", "add", "(", "$", "method", ",", "$", "url", "=", "null", ",", "$", "handler", "=", "null", ")", ":", "RouterInterface", "{", "$", "temp", "=", "[", "'method'", "=>", "[", "'GET'", ",", "'POST'", "]", ",", "'url'", "=>", "''", ...
Add a route. All params are optional and each of them can be omitted independently. @param array|string $method HTTP verbs for which this route is valid @param string $url the route URL (check the usage docs for information on supported formats) @param callable $handler the handler to execute when the route is matched @return self
[ "Add", "a", "route", ".", "All", "params", "are", "optional", "and", "each", "of", "them", "can", "be", "omitted", "independently", "." ]
de392bdc8ed1353a59529c3bcf78574e1ad72545
https://github.com/vakata/router/blob/de392bdc8ed1353a59529c3bcf78574e1ad72545/src/Router.php#L155-L196
train
WaddlingCo/streamperk-bundle
ServerBundle/Entity/Server.php
Server.userHasAccess
public function userHasAccess(User $user) { if ($this->getWhitelisted() === false) { return true; } $criteria = Criteria::create() ->where(Criteria::expr()->eq('user', $user)) ->setMaxResults(1); $serverUsers = $this->users->matching($criteria); if ($serverUsers->count() === 0) { return false; } $serverUser = $serverUsers->first(); if ($serverUser->getBanned() === true) { return false; } if ($this->getRequiresApproval() === true && $serverUser->getApproved() === false) { return false; } return true; }
php
public function userHasAccess(User $user) { if ($this->getWhitelisted() === false) { return true; } $criteria = Criteria::create() ->where(Criteria::expr()->eq('user', $user)) ->setMaxResults(1); $serverUsers = $this->users->matching($criteria); if ($serverUsers->count() === 0) { return false; } $serverUser = $serverUsers->first(); if ($serverUser->getBanned() === true) { return false; } if ($this->getRequiresApproval() === true && $serverUser->getApproved() === false) { return false; } return true; }
[ "public", "function", "userHasAccess", "(", "User", "$", "user", ")", "{", "if", "(", "$", "this", "->", "getWhitelisted", "(", ")", "===", "false", ")", "{", "return", "true", ";", "}", "$", "criteria", "=", "Criteria", "::", "create", "(", ")", "->...
Get whether the user has access @return boolean
[ "Get", "whether", "the", "user", "has", "access" ]
bb930778690a9a5e0f0a7308d9449c03239c5e35
https://github.com/WaddlingCo/streamperk-bundle/blob/bb930778690a9a5e0f0a7308d9449c03239c5e35/ServerBundle/Entity/Server.php#L635-L661
train
bruery/platform-core
src/bundles/UserBundle/Form/Type/ProfileType.php
ProfileType.buildUserForm
protected function buildUserForm(FormBuilderInterface $builder, array $options) { $now = new \DateTime(); $builder ->add('username', null, array('label' => 'form.label_username', 'translation_domain' => 'SonataUserBundle')) ->add('email', 'email', array('label' => 'form.label_email', 'translation_domain' => 'SonataUserBundle', 'read_only'=>true, 'attr'=>array('class'=>'span12'))) ->add('firstname', null, array('label' => 'form.label_firstname', 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12'))) ->add('lastname', null, array('label' => 'form.label_lastname','translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12'))) ->add('website', null, array('label' => 'form.label_website', 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12'))) ->add('phone', null, array('required' => false, 'label' => 'form.label_phone', 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12'))) ->add('dateOfBirth', 'sonata_type_date_picker', array( 'years' => range(1900, $now->format('Y')), 'dp_min_date' => '1-1-1900', 'dp_max_date' => $now->format('c'), 'required' => false, )) ->add('gender', 'choice', array( 'label' => 'form.label_gender', 'choices' => array( UserInterface::GENDER_UNKNOWN => 'gender_unknown', UserInterface::GENDER_FEMALE => 'gender_female', UserInterface::GENDER_MAN => 'gender_male', ), 'required' => true, 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12') )); }
php
protected function buildUserForm(FormBuilderInterface $builder, array $options) { $now = new \DateTime(); $builder ->add('username', null, array('label' => 'form.label_username', 'translation_domain' => 'SonataUserBundle')) ->add('email', 'email', array('label' => 'form.label_email', 'translation_domain' => 'SonataUserBundle', 'read_only'=>true, 'attr'=>array('class'=>'span12'))) ->add('firstname', null, array('label' => 'form.label_firstname', 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12'))) ->add('lastname', null, array('label' => 'form.label_lastname','translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12'))) ->add('website', null, array('label' => 'form.label_website', 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12'))) ->add('phone', null, array('required' => false, 'label' => 'form.label_phone', 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12'))) ->add('dateOfBirth', 'sonata_type_date_picker', array( 'years' => range(1900, $now->format('Y')), 'dp_min_date' => '1-1-1900', 'dp_max_date' => $now->format('c'), 'required' => false, )) ->add('gender', 'choice', array( 'label' => 'form.label_gender', 'choices' => array( UserInterface::GENDER_UNKNOWN => 'gender_unknown', UserInterface::GENDER_FEMALE => 'gender_female', UserInterface::GENDER_MAN => 'gender_male', ), 'required' => true, 'translation_domain' => 'SonataUserBundle', 'attr'=>array('class'=>'span12') )); }
[ "protected", "function", "buildUserForm", "(", "FormBuilderInterface", "$", "builder", ",", "array", "$", "options", ")", "{", "$", "now", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "builder", "->", "add", "(", "'username'", ",", "null", ",", "arr...
Builds the embedded form representing the user. @param FormBuilderInterface $builder @param array $options
[ "Builds", "the", "embedded", "form", "representing", "the", "user", "." ]
46153c181b2d852763afa30f7378bcbc1b2f4ef3
https://github.com/bruery/platform-core/blob/46153c181b2d852763afa30f7378bcbc1b2f4ef3/src/bundles/UserBundle/Form/Type/ProfileType.php#L90-L118
train
crysalead/validator
src/Validator.php
Validator.set
public function set($name, $rule = null) { if (!is_array($name)) { $name = [$name => $rule]; } $this->_handlers = $name + $this->_handlers; }
php
public function set($name, $rule = null) { if (!is_array($name)) { $name = [$name => $rule]; } $this->_handlers = $name + $this->_handlers; }
[ "public", "function", "set", "(", "$", "name", ",", "$", "rule", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "name", ")", ")", "{", "$", "name", "=", "[", "$", "name", "=>", "$", "rule", "]", ";", "}", "$", "this", "->", "_...
Sets one or several validation rules. For example: {{{ $validator = new Validator(); $validator->set('zeroToNine', '/^[0-9]$/'); $isValid = $validator->isZeroToNine('5'); // true $isValid = $validator->isZeroToNine('20'); // false }}} Alternatively, the first parameter may be an array of rules expressed as key/value pairs, as in the following: {{{ $validator = new Validator(); $validator->set([ 'zeroToNine' => '/^[0-9]$/', 'tenToNineteen' => '/^1[0-9]$/', ]); }}} In addition to regular expressions, validation rules can also be defined as full anonymous functions: {{{ use app\model\Account; $validator = new Validator(); $validator->set('accountActive', function($value, $options = []) { $value = is_int($value) ? Account::id($value) : $value; return (boolean) $value->is_active; }); $testAccount = Account::create(['is_active' => false]); $validator->isAccountActive($testAccount); // returns false }}} These functions can take up to 3 parameters: - `$value` _mixed_ : This is the actual value to be validated (as in the above example). - `$options` _array_: This parameter allows a validation rule to implement custom options. - `'format'` _string_: Often, validation rules come in multiple "formats", for example: postal codes, which vary by country or region. Defining multiple formats allows you to retain flexibility in how you validate data. In cases where a user's country of origin is known, the appropriate validation rule may be selected. In cases where it is not known, the value of `$format` may be `'any'`, which should pass if any format matches. In cases where validation rule formats are not mutually exclusive, the value may be `'all'`, in which case all must match. @param mixed $name The name of the validation rule (string), or an array of key/value pairs of names and rules. @param string $rule If $name is a string, this should be a string regular expression, or a closure that returns a boolean indicating success. Should be left blank if `$name` is an array.
[ "Sets", "one", "or", "several", "validation", "rules", "." ]
37070c0753351f250096c8495874544fbb6620cb
https://github.com/crysalead/validator/blob/37070c0753351f250096c8495874544fbb6620cb/src/Validator.php#L157-L163
train
crysalead/validator
src/Validator.php
Validator.has
public function has($name) { $checker = $this->_classes['checker']; return isset($this->_handlers[$name]) || $checker::has($name); }
php
public function has($name) { $checker = $this->_classes['checker']; return isset($this->_handlers[$name]) || $checker::has($name); }
[ "public", "function", "has", "(", "$", "name", ")", "{", "$", "checker", "=", "$", "this", "->", "_classes", "[", "'checker'", "]", ";", "return", "isset", "(", "$", "this", "->", "_handlers", "[", "$", "name", "]", ")", "||", "$", "checker", "::",...
Checks if a validation handler exists. @param string $name A validation handler name.
[ "Checks", "if", "a", "validation", "handler", "exists", "." ]
37070c0753351f250096c8495874544fbb6620cb
https://github.com/crysalead/validator/blob/37070c0753351f250096c8495874544fbb6620cb/src/Validator.php#L170-L174
train
crysalead/validator
src/Validator.php
Validator.get
public function get($name) { if (isset($this->_handlers[$name])) { return $this->_handlers[$name]; } $checker = $this->_classes['checker']; if ($checker::has($name)) { return $checker::get($name); } throw new InvalidArgumentException("Unexisting `{$name}` as validation handler."); }
php
public function get($name) { if (isset($this->_handlers[$name])) { return $this->_handlers[$name]; } $checker = $this->_classes['checker']; if ($checker::has($name)) { return $checker::get($name); } throw new InvalidArgumentException("Unexisting `{$name}` as validation handler."); }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_handlers", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "_handlers", "[", "$", "name", "]", ";", "}", "$", "checker", "...
Returns a validation handler. @param string $name A validation handler name.
[ "Returns", "a", "validation", "handler", "." ]
37070c0753351f250096c8495874544fbb6620cb
https://github.com/crysalead/validator/blob/37070c0753351f250096c8495874544fbb6620cb/src/Validator.php#L181-L191
train
crysalead/validator
src/Validator.php
Validator.rule
public function rule($field, $rules = []) { $defaults = [ 'message' => null, 'required' => true, 'skipEmpty' => false, 'format' => 'any', 'not' => false, 'on' => null ]; $rules = $rules ? (array) $rules : []; foreach ($rules as $name => $options) { if (is_numeric($name)) { $name = $options; $options = []; } if (is_string($options)) { $options = ['message' => $options]; } $options += $defaults; $this->_rules[$field][$name] = $options; } }
php
public function rule($field, $rules = []) { $defaults = [ 'message' => null, 'required' => true, 'skipEmpty' => false, 'format' => 'any', 'not' => false, 'on' => null ]; $rules = $rules ? (array) $rules : []; foreach ($rules as $name => $options) { if (is_numeric($name)) { $name = $options; $options = []; } if (is_string($options)) { $options = ['message' => $options]; } $options += $defaults; $this->_rules[$field][$name] = $options; } }
[ "public", "function", "rule", "(", "$", "field", ",", "$", "rules", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'message'", "=>", "null", ",", "'required'", "=>", "true", ",", "'skipEmpty'", "=>", "false", ",", "'format'", "=>", "'any'", ","...
Sets a rule. @param mixed $name A fieldname. @param string $handler A validation handler name.
[ "Sets", "a", "rule", "." ]
37070c0753351f250096c8495874544fbb6620cb
https://github.com/crysalead/validator/blob/37070c0753351f250096c8495874544fbb6620cb/src/Validator.php#L220-L244
train
crysalead/validator
src/Validator.php
Validator.validates
public function validates($data, $options = []) { $events = (array) (isset($options['events']) ? $options['events'] : null); $this->_errors = []; $error = $this->_error; foreach ($this->_rules as $field => $rules) { $values = static::values($data, explode('.', $field)); foreach ($rules as $name => $rule) { $rule += $options; $rule['field'] = $field; if ($events && $rule['on'] && !array_intersect($events, (array) $rule['on'])) { continue; } if (!$values && $rule['required']) { $rule['message'] = null; $this->_errors[$field][] = $error('required', $rule, $this->_meta); break; } else { foreach ($values as $key => $value) { if (empty($value) && $rule['skipEmpty']) { continue; } if (!$this->is($name, $value, $rule + compact('data'), $params)) { $this->_errors[$key][] = $error($name, $params + $rule, $this->_meta); } } } } } return !$this->_errors; }
php
public function validates($data, $options = []) { $events = (array) (isset($options['events']) ? $options['events'] : null); $this->_errors = []; $error = $this->_error; foreach ($this->_rules as $field => $rules) { $values = static::values($data, explode('.', $field)); foreach ($rules as $name => $rule) { $rule += $options; $rule['field'] = $field; if ($events && $rule['on'] && !array_intersect($events, (array) $rule['on'])) { continue; } if (!$values && $rule['required']) { $rule['message'] = null; $this->_errors[$field][] = $error('required', $rule, $this->_meta); break; } else { foreach ($values as $key => $value) { if (empty($value) && $rule['skipEmpty']) { continue; } if (!$this->is($name, $value, $rule + compact('data'), $params)) { $this->_errors[$key][] = $error($name, $params + $rule, $this->_meta); } } } } } return !$this->_errors; }
[ "public", "function", "validates", "(", "$", "data", ",", "$", "options", "=", "[", "]", ")", "{", "$", "events", "=", "(", "array", ")", "(", "isset", "(", "$", "options", "[", "'events'", "]", ")", "?", "$", "options", "[", "'events'", "]", ":"...
Validates a set of values against a specified rules list. This method may be used to validate any arbitrary array of data against a set of validation rules. @param array $data An array of key/value pairs, where the values are to be checked. @param array $rules An array of rules to check the values in `$values` against. Each key in `$rules` should match a key contained in `$values`, and each value should be a validation rule in one of the allowable formats. For example, if you are validating a data set containing a `'credit_card'` key, possible values for `$rules` would be as follows: - `['credit_card' => 'You must include a credit card number']`: This is the simplest form of validation rule, in which the value is simply a message to display if the rule fails. Using this format, all other validation settings inherit from the defaults, including the validation rule itself, which only checks to see that the corresponding key in `$values` is present and contains a value that is not empty. _Please note when globalizing validation messages:_ When specifying messages, it may be preferable to use a code string (i.e. `'ERR_NO_TITLE'`) instead of the full text of the validation error. These code strings may then be translated by the appropriate tools in the templating layer. - `['credit_card' => ['creditCard', 'message' => 'Invalid CC #']]`: In the second format, the validation rule (in this case `creditCard`) and associated configuration are specified as an array, where the rule to use is the first value in the array (no key), and additional settings are specified as other keys in the array. Please see the list below for more information on allowed keys. - The final format allows you to apply multiple validation rules to a single value, and it is specified as follows: `['credit_card' => [ ['not:empty', 'message' => 'You must include credit card number'], ['creditCard', 'message' => 'Your credit card number must be valid'] ]];` @param array $options Validator-specific options. Each rule defined as an array can contain any of the following settings (in addition to the first value, which represents the rule to be used): - `'message'` _string_: The error message to be returned if the validation rule fails. See the note above regarding globalization of error messages. - `'required`' _boolean_: Represents whether the value is required to be present in `$values`. If `'required'` is set to `false`, the validation rule will be skipped if the corresponding key is not present. Defaults to `true`. - `'skipEmpty'` _boolean_: Similar to `'required'`, this setting (if `true`) will cause the validation rule to be skipped if the corresponding value is empty (an empty string or `null`). Defaults to `false`. - `'format'` _string_: If the validation rule has multiple format definitions (see the `add()` or `init()` methods), the name of the format to be used can be specified here. Additionally, two special values can be used: either `'any'`, which means that all formats will be checked and the rule will pass if any format passes, or `'all'`, which requires all formats to pass in order for the rule check to succeed. @return array Returns an array containing all validation failures for data in `$values`, where each key matches a key in `$values`, and each value is an array of that element's validation errors.
[ "Validates", "a", "set", "of", "values", "against", "a", "specified", "rules", "list", ".", "This", "method", "may", "be", "used", "to", "validate", "any", "arbitrary", "array", "of", "data", "against", "a", "set", "of", "validation", "rules", "." ]
37070c0753351f250096c8495874544fbb6620cb
https://github.com/crysalead/validator/blob/37070c0753351f250096c8495874544fbb6620cb/src/Validator.php#L298-L333
train
crysalead/validator
src/Validator.php
Validator.is
public function is($name, $value, $options = [], &$params = []) { $not = false; if (strncmp($name, 'not:', 4) === 0) { $name = substr($name, 4); $not = true; } $handlers = $this->get($name); $handlers = is_array($handlers) ? $handlers : [$handlers]; $checker = $this->_classes['checker']; return $checker::check($value, $handlers, $options, $params) !== $not; }
php
public function is($name, $value, $options = [], &$params = []) { $not = false; if (strncmp($name, 'not:', 4) === 0) { $name = substr($name, 4); $not = true; } $handlers = $this->get($name); $handlers = is_array($handlers) ? $handlers : [$handlers]; $checker = $this->_classes['checker']; return $checker::check($value, $handlers, $options, $params) !== $not; }
[ "public", "function", "is", "(", "$", "name", ",", "$", "value", ",", "$", "options", "=", "[", "]", ",", "&", "$", "params", "=", "[", "]", ")", "{", "$", "not", "=", "false", ";", "if", "(", "strncmp", "(", "$", "name", ",", "'not:'", ",", ...
Checks a single value against a validation handler. @param string $rule The validation handler name. @param mixed $value The value to check. @param array $options The options array. @return boolean Returns `true` or `false` indicating whether the validation rule check succeeded or failed.
[ "Checks", "a", "single", "value", "against", "a", "validation", "handler", "." ]
37070c0753351f250096c8495874544fbb6620cb
https://github.com/crysalead/validator/blob/37070c0753351f250096c8495874544fbb6620cb/src/Validator.php#L354-L366
train
crysalead/validator
src/Validator.php
Validator.values
public static function values($data, $path = [], $base = null) { if (!$path) { $base = $base ?: 0; return [$base => $data]; } $field = array_shift($path); if ($field === '*') { $values = []; foreach ($data as $key => $value) { $values = array_merge($values, static::values($value, $path, $base . '.' . $key)); } return $values; } elseif (!isset($data[$field])) { return []; } elseif (!$path) { return [$base ? $base . '.' . $field : $field => $data[$field]]; } else { return static::values($data[$field], $path, $base ? $base . '.' . $field : $field); } }
php
public static function values($data, $path = [], $base = null) { if (!$path) { $base = $base ?: 0; return [$base => $data]; } $field = array_shift($path); if ($field === '*') { $values = []; foreach ($data as $key => $value) { $values = array_merge($values, static::values($value, $path, $base . '.' . $key)); } return $values; } elseif (!isset($data[$field])) { return []; } elseif (!$path) { return [$base ? $base . '.' . $field : $field => $data[$field]]; } else { return static::values($data[$field], $path, $base ? $base . '.' . $field : $field); } }
[ "public", "static", "function", "values", "(", "$", "data", ",", "$", "path", "=", "[", "]", ",", "$", "base", "=", "null", ")", "{", "if", "(", "!", "$", "path", ")", "{", "$", "base", "=", "$", "base", "?", ":", "0", ";", "return", "[", "...
Extracts all values corresponding to a field names path. @param array $data The data. @param array $path An array of field names. @param array $base The dotted fielname path of the data. @return array The extracted values.
[ "Extracts", "all", "values", "corresponding", "to", "a", "field", "names", "path", "." ]
37070c0753351f250096c8495874544fbb6620cb
https://github.com/crysalead/validator/blob/37070c0753351f250096c8495874544fbb6620cb/src/Validator.php#L397-L419
train
kherge-abandoned/Wisdom
src/lib/KevinGH/Wisdom/Wisdom.php
Wisdom.addLoader
public function addLoader(Loader $loader) { $loader->setLocator($this->locator); $this->resolver->addLoader($loader); }
php
public function addLoader(Loader $loader) { $loader->setLocator($this->locator); $this->resolver->addLoader($loader); }
[ "public", "function", "addLoader", "(", "Loader", "$", "loader", ")", "{", "$", "loader", "->", "setLocator", "(", "$", "this", "->", "locator", ")", ";", "$", "this", "->", "resolver", "->", "addLoader", "(", "$", "loader", ")", ";", "}" ]
Adds the loader. @param Loader $loader The loader.
[ "Adds", "the", "loader", "." ]
eb5b1dadde0729f2ccd1b241c2cecebc778e22f3
https://github.com/kherge-abandoned/Wisdom/blob/eb5b1dadde0729f2ccd1b241c2cecebc778e22f3/src/lib/KevinGH/Wisdom/Wisdom.php#L98-L103
train
kherge-abandoned/Wisdom
src/lib/KevinGH/Wisdom/Wisdom.php
Wisdom.get
public function get($file, $values = null, array &$imported = array()) { if ((null !== $values) && (false === is_array($values))) { if (false === ($values instanceof ArrayAccess)) { throw new InvalidArgumentException( 'The value of $values is not an array or an instance of ArrayAccess.' ); } } if (null !== $values) { $values = $this->mergeValues($this->values, $values); } else { $values = $this->values; } $new = dirname($file) . DIRECTORY_SEPARATOR . $this->prefix . basename($file); try { $found = $this->locator->locate($new); } catch (InvalidArgumentException $first) { if (empty($this->prefix)) { throw $first; } try { $found = $this->locator->locate($file); } catch (InvalidArgumentException $second) { throw $first; } } if (in_array($found, $imported)) { throw new LogicException(sprintf( 'Circular dependency detected for: %s', $found )); } $imported[] = $found; if (false === empty($this->cache)) { $cache = new ConfigCache( $this->cache . DIRECTORY_SEPARATOR . $file . '.php', $this->debug ); if ($cache->isFresh()) { return $this->import(require $cache, $values, $imported); } } if (false === ($loader = $this->resolver->resolve($file))) { throw new InvalidArgumentException(sprintf( 'No loader available for file: %s', $file )); } $loader->setValues($values); $data = $loader->load($found); if (isset($cache)) { $cache->write( '<?php return ' . var_export($data, true) . ';', array(new FileResource($found)) ); } return $this->import($data, $values, $imported); }
php
public function get($file, $values = null, array &$imported = array()) { if ((null !== $values) && (false === is_array($values))) { if (false === ($values instanceof ArrayAccess)) { throw new InvalidArgumentException( 'The value of $values is not an array or an instance of ArrayAccess.' ); } } if (null !== $values) { $values = $this->mergeValues($this->values, $values); } else { $values = $this->values; } $new = dirname($file) . DIRECTORY_SEPARATOR . $this->prefix . basename($file); try { $found = $this->locator->locate($new); } catch (InvalidArgumentException $first) { if (empty($this->prefix)) { throw $first; } try { $found = $this->locator->locate($file); } catch (InvalidArgumentException $second) { throw $first; } } if (in_array($found, $imported)) { throw new LogicException(sprintf( 'Circular dependency detected for: %s', $found )); } $imported[] = $found; if (false === empty($this->cache)) { $cache = new ConfigCache( $this->cache . DIRECTORY_SEPARATOR . $file . '.php', $this->debug ); if ($cache->isFresh()) { return $this->import(require $cache, $values, $imported); } } if (false === ($loader = $this->resolver->resolve($file))) { throw new InvalidArgumentException(sprintf( 'No loader available for file: %s', $file )); } $loader->setValues($values); $data = $loader->load($found); if (isset($cache)) { $cache->write( '<?php return ' . var_export($data, true) . ';', array(new FileResource($found)) ); } return $this->import($data, $values, $imported); }
[ "public", "function", "get", "(", "$", "file", ",", "$", "values", "=", "null", ",", "array", "&", "$", "imported", "=", "array", "(", ")", ")", "{", "if", "(", "(", "null", "!==", "$", "values", ")", "&&", "(", "false", "===", "is_array", "(", ...
Returns the data for the configuration file. @param string $file The file name. @param array|object $values The new replacement values. @param array &$imported The list of imported resources. @return array The configuration data. @throws InvalidArgumentException If the value is not supported. @throws LogicException If a circular dependency is detected.
[ "Returns", "the", "data", "for", "the", "configuration", "file", "." ]
eb5b1dadde0729f2ccd1b241c2cecebc778e22f3
https://github.com/kherge-abandoned/Wisdom/blob/eb5b1dadde0729f2ccd1b241c2cecebc778e22f3/src/lib/KevinGH/Wisdom/Wisdom.php#L117-L188
train
kherge-abandoned/Wisdom
src/lib/KevinGH/Wisdom/Wisdom.php
Wisdom.import
public function import(array $data, $values = null, array &$imported = array()) { if (false === isset($data['imports'])) { return $data; } $imports = $data['imports']; unset($data['imports']); foreach ($imports as $resource) { $data = array_replace_recursive( $this->get($resource, $values, $imported), $data ); } return $data; }
php
public function import(array $data, $values = null, array &$imported = array()) { if (false === isset($data['imports'])) { return $data; } $imports = $data['imports']; unset($data['imports']); foreach ($imports as $resource) { $data = array_replace_recursive( $this->get($resource, $values, $imported), $data ); } return $data; }
[ "public", "function", "import", "(", "array", "$", "data", ",", "$", "values", "=", "null", ",", "array", "&", "$", "imported", "=", "array", "(", ")", ")", "{", "if", "(", "false", "===", "isset", "(", "$", "data", "[", "'imports'", "]", ")", ")...
Manages the "imports" directive in configuration files. @param array $data The current data. @param array|object $values The new replacement values. @param array &$imported The list of imported resources. @return array The data merged with the imported resources. @throws LogicException If a circular reference is detected.
[ "Manages", "the", "imports", "directive", "in", "configuration", "files", "." ]
eb5b1dadde0729f2ccd1b241c2cecebc778e22f3
https://github.com/kherge-abandoned/Wisdom/blob/eb5b1dadde0729f2ccd1b241c2cecebc778e22f3/src/lib/KevinGH/Wisdom/Wisdom.php#L201-L219
train
kherge-abandoned/Wisdom
src/lib/KevinGH/Wisdom/Wisdom.php
Wisdom.setValues
public function setValues($values) { if ((null !== $values) && (false === is_array($values))) { if (false === ($values instanceof ArrayAccess)) { throw new InvalidArgumentException( 'The value of $values is not an array or an instance of ArrayAccess.' ); } } $this->values = $values; }
php
public function setValues($values) { if ((null !== $values) && (false === is_array($values))) { if (false === ($values instanceof ArrayAccess)) { throw new InvalidArgumentException( 'The value of $values is not an array or an instance of ArrayAccess.' ); } } $this->values = $values; }
[ "public", "function", "setValues", "(", "$", "values", ")", "{", "if", "(", "(", "null", "!==", "$", "values", ")", "&&", "(", "false", "===", "is_array", "(", "$", "values", ")", ")", ")", "{", "if", "(", "false", "===", "(", "$", "values", "ins...
Sets the default replacement values. @param array|object The replacement values. @throws InvalidArgumentException If the value is not supported.
[ "Sets", "the", "default", "replacement", "values", "." ]
eb5b1dadde0729f2ccd1b241c2cecebc778e22f3
https://github.com/kherge-abandoned/Wisdom/blob/eb5b1dadde0729f2ccd1b241c2cecebc778e22f3/src/lib/KevinGH/Wisdom/Wisdom.php#L258-L269
train
kherge-abandoned/Wisdom
src/lib/KevinGH/Wisdom/Wisdom.php
Wisdom.mergeValues
private function mergeValues($a, $b) { $x = array(); $y = array(); if (is_array($a)) { $x = $a; } foreach ($b as $key => $value) { $x[$key] = $value; } return $x; }
php
private function mergeValues($a, $b) { $x = array(); $y = array(); if (is_array($a)) { $x = $a; } foreach ($b as $key => $value) { $x[$key] = $value; } return $x; }
[ "private", "function", "mergeValues", "(", "$", "a", ",", "$", "b", ")", "{", "$", "x", "=", "array", "(", ")", ";", "$", "y", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "a", ")", ")", "{", "$", "x", "=", "$", "a", ";",...
Merges two sets of replacement values. @param array|object $a The replacement values. @param array|object $b The replacement values. @return array The merged values.
[ "Merges", "two", "sets", "of", "replacement", "values", "." ]
eb5b1dadde0729f2ccd1b241c2cecebc778e22f3
https://github.com/kherge-abandoned/Wisdom/blob/eb5b1dadde0729f2ccd1b241c2cecebc778e22f3/src/lib/KevinGH/Wisdom/Wisdom.php#L279-L293
train
Softpampa/moip-sdk-php
src/Subscriptions/Resources/Subscriptions.php
Subscriptions.suspend
public function suspend($code = null) { if (! $code) { $code = $this->data->code; } $response = $this->client->put('/{code}/suspend', [$code]); if (! $response->hasErrors()) { $this->event->dispatch('SUBSCRIPTION.SUSPENDED', new SubscriptionsEvent($this->data)); } return $this; }
php
public function suspend($code = null) { if (! $code) { $code = $this->data->code; } $response = $this->client->put('/{code}/suspend', [$code]); if (! $response->hasErrors()) { $this->event->dispatch('SUBSCRIPTION.SUSPENDED', new SubscriptionsEvent($this->data)); } return $this; }
[ "public", "function", "suspend", "(", "$", "code", "=", "null", ")", "{", "if", "(", "!", "$", "code", ")", "{", "$", "code", "=", "$", "this", "->", "data", "->", "code", ";", "}", "$", "response", "=", "$", "this", "->", "client", "->", "put"...
Suspend a subscription @param string $code @return $this
[ "Suspend", "a", "subscription" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Subscriptions.php#L85-L98
train
Softpampa/moip-sdk-php
src/Subscriptions/Resources/Subscriptions.php
Subscriptions.setNextInvoiceDate
public function setNextInvoiceDate($date) { $date = DateTime::createFromFormat('Y-m-d', $date); $this->next_invoice_date = new stdClass(); $this->next_invoice_date->day = $date->format('d'); $this->next_invoice_date->month = $date->format('m'); $this->next_invoice_date->year = $date->format('Y'); return $this; }
php
public function setNextInvoiceDate($date) { $date = DateTime::createFromFormat('Y-m-d', $date); $this->next_invoice_date = new stdClass(); $this->next_invoice_date->day = $date->format('d'); $this->next_invoice_date->month = $date->format('m'); $this->next_invoice_date->year = $date->format('Y'); return $this; }
[ "public", "function", "setNextInvoiceDate", "(", "$", "date", ")", "{", "$", "date", "=", "DateTime", "::", "createFromFormat", "(", "'Y-m-d'", ",", "$", "date", ")", ";", "$", "this", "->", "next_invoice_date", "=", "new", "stdClass", "(", ")", ";", "$"...
Set next invoice date @param string $date @return $this
[ "Set", "next", "invoice", "date" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Subscriptions.php#L202-L212
train
Softpampa/moip-sdk-php
src/Subscriptions/Resources/Subscriptions.php
Subscriptions.setNewCustomer
public function setNewCustomer(Customers $customer) { $this->client->addQueryString('new_customer', true); $this->data->customer = $customer->jsonSerialize(); return $this; }
php
public function setNewCustomer(Customers $customer) { $this->client->addQueryString('new_customer', true); $this->data->customer = $customer->jsonSerialize(); return $this; }
[ "public", "function", "setNewCustomer", "(", "Customers", "$", "customer", ")", "{", "$", "this", "->", "client", "->", "addQueryString", "(", "'new_customer'", ",", "true", ")", ";", "$", "this", "->", "data", "->", "customer", "=", "$", "customer", "->",...
Set New Customer @param Customers $customer @return $this
[ "Set", "New", "Customer" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Subscriptions/Resources/Subscriptions.php#L267-L274
train
fazland/elastica-odm
src/Configuration.php
Configuration.getRepositoryFactory
public function getRepositoryFactory(): RepositoryFactoryInterface { if (null !== $this->repositoryFactory) { return $this->repositoryFactory; } $factory = new DefaultRepositoryFactory(); $factory->setDefaultRepositoryClassName($this->getDefaultRepositoryClassName()); return $factory; }
php
public function getRepositoryFactory(): RepositoryFactoryInterface { if (null !== $this->repositoryFactory) { return $this->repositoryFactory; } $factory = new DefaultRepositoryFactory(); $factory->setDefaultRepositoryClassName($this->getDefaultRepositoryClassName()); return $factory; }
[ "public", "function", "getRepositoryFactory", "(", ")", ":", "RepositoryFactoryInterface", "{", "if", "(", "null", "!==", "$", "this", "->", "repositoryFactory", ")", "{", "return", "$", "this", "->", "repositoryFactory", ";", "}", "$", "factory", "=", "new", ...
Sets the repository factory. @return RepositoryFactoryInterface
[ "Sets", "the", "repository", "factory", "." ]
9d7276ea9ea9103c670f13f889bf59568ff35274
https://github.com/fazland/elastica-odm/blob/9d7276ea9ea9103c670f13f889bf59568ff35274/src/Configuration.php#L195-L205
train
marando/phpSOFA
src/Marando/IAU/iauUtctai.php
iauUtctai.Utctai
public static function Utctai($utc1, $utc2, &$tai1, &$tai2) { $big1; $iy; $im; $id; $j; $iyt; $imt; $idt; $u1; $u2; $fd; $dat0; $dat12; $w; $dat24; $dlod; $dleap; $z1; $z2; $a2; /* Put the two parts of the UTC into big-first order. */ $big1 = ( $utc1 >= $utc2 ); if ($big1) { $u1 = $utc1; $u2 = $utc2; } else { $u1 = $utc2; $u2 = $utc1; } /* Get TAI-UTC at 0h today. */ $j = IAU::Jd2cal($u1, $u2, $iy, $im, $id, $fd); if ($j !=0 ) return j; $j = IAU::Dat($iy, $im, $id, 0.0, $dat0); if ($j < 0) return $j; /* Get TAI-UTC at 12h today (to detect drift). */ $j = IAU::Dat($iy, $im, $id, 0.5, $dat12); if ($j < 0) return $j; /* Get TAI-UTC at 0h tomorrow (to detect jumps). */ $j = IAU::Jd2cal($u1 + 1.5, $u2 - $fd, $iyt, $imt, $idt, $w); if ($j!=0) return $j; $j = IAU::Dat($iyt, $imt, $idt, 0.0, $dat24); if ($j < 0) return $j; /* Separate TAI-UTC change into per-day (DLOD) and any jump (DLEAP). */ $dlod = 2.0 * ($dat12 - $dat0); $dleap = $dat24 - ($dat0 + $dlod); /* Remove any scaling applied to spread leap into preceding day. */ $fd *= (DAYSEC + $dleap) / DAYSEC; /* Scale from (pre-1972) UTC seconds to SI seconds. */ $fd *= (DAYSEC + $dlod) / DAYSEC; /* Today's calendar date to 2-part JD. */ if (IAU::Cal2jd($iy, $im, $id, $z1, $z2)) return -1; /* Assemble the TAI result, preserving the UTC split and order. */ $a2 = $z1 - $u1; $a2 += $z2; $a2 += $fd + $dat0 / DAYSEC; if ($big1) { $tai1 = $u1; $tai2 = $a2; } else { $tai1 = $a2; $tai2 = $u1; } /* Status. */ return $j; }
php
public static function Utctai($utc1, $utc2, &$tai1, &$tai2) { $big1; $iy; $im; $id; $j; $iyt; $imt; $idt; $u1; $u2; $fd; $dat0; $dat12; $w; $dat24; $dlod; $dleap; $z1; $z2; $a2; /* Put the two parts of the UTC into big-first order. */ $big1 = ( $utc1 >= $utc2 ); if ($big1) { $u1 = $utc1; $u2 = $utc2; } else { $u1 = $utc2; $u2 = $utc1; } /* Get TAI-UTC at 0h today. */ $j = IAU::Jd2cal($u1, $u2, $iy, $im, $id, $fd); if ($j !=0 ) return j; $j = IAU::Dat($iy, $im, $id, 0.0, $dat0); if ($j < 0) return $j; /* Get TAI-UTC at 12h today (to detect drift). */ $j = IAU::Dat($iy, $im, $id, 0.5, $dat12); if ($j < 0) return $j; /* Get TAI-UTC at 0h tomorrow (to detect jumps). */ $j = IAU::Jd2cal($u1 + 1.5, $u2 - $fd, $iyt, $imt, $idt, $w); if ($j!=0) return $j; $j = IAU::Dat($iyt, $imt, $idt, 0.0, $dat24); if ($j < 0) return $j; /* Separate TAI-UTC change into per-day (DLOD) and any jump (DLEAP). */ $dlod = 2.0 * ($dat12 - $dat0); $dleap = $dat24 - ($dat0 + $dlod); /* Remove any scaling applied to spread leap into preceding day. */ $fd *= (DAYSEC + $dleap) / DAYSEC; /* Scale from (pre-1972) UTC seconds to SI seconds. */ $fd *= (DAYSEC + $dlod) / DAYSEC; /* Today's calendar date to 2-part JD. */ if (IAU::Cal2jd($iy, $im, $id, $z1, $z2)) return -1; /* Assemble the TAI result, preserving the UTC split and order. */ $a2 = $z1 - $u1; $a2 += $z2; $a2 += $fd + $dat0 / DAYSEC; if ($big1) { $tai1 = $u1; $tai2 = $a2; } else { $tai1 = $a2; $tai2 = $u1; } /* Status. */ return $j; }
[ "public", "static", "function", "Utctai", "(", "$", "utc1", ",", "$", "utc2", ",", "&", "$", "tai1", ",", "&", "$", "tai2", ")", "{", "$", "big1", ";", "$", "iy", ";", "$", "im", ";", "$", "id", ";", "$", "j", ";", "$", "iyt", ";", "$", "...
- - - - - - - - - - i a u U t c t a i - - - - - - - - - - Time scale transformation: Coordinated Universal Time, UTC, to International Atomic Time, TAI. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: canonical. Given: utc1,utc2 double UTC as a 2-part quasi Julian Date (Notes 1-4) Returned: tai1,tai2 double TAI as a 2-part Julian Date (Note 5) Returned (function value): int status: +1 = dubious year (Note 3) 0 = OK -1 = unacceptable date Notes: 1) utc1+utc2 is quasi Julian Date (see Note 2), apportioned in any convenient way between the two arguments, for example where utc1 is the Julian Day Number and utc2 is the fraction of a day. 2) JD cannot unambiguously represent UTC during a leap second unless special measures are taken. The convention in the present function is that the JD day represents UTC days whether the length is 86399, 86400 or 86401 SI seconds. In the 1960-1972 era there were smaller jumps (in either direction) each time the linear UTC(TAI) expression was changed, and these "mini-leaps" are also included in the SOFA convention. 3) The warning status "dubious year" flags UTCs that predate the introduction of the time scale or that are too far in the future to be trusted. See iauDat for further details. 4) The function iauDtf2d converts from calendar date and time of day into 2-part Julian Date, and in the case of UTC implements the leap-second-ambiguity convention described above. 5) The returned TAI1,TAI2 are such that their sum is the TAI Julian Date. Called: iauJd2cal JD to Gregorian calendar iauDat delta(AT) = TAI-UTC iauCal2jd Gregorian calendar to JD References: McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32, BKG (2004) Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann (ed), University Science Books (1992) This revision: 2013 July 26 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "U", "t", "c", "t", "a", "i", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauUtctai.php#L76-L159
train
slickframework/mvc
src/Router/Builder/RouteFactory.php
RouteFactory.simpleRoute
protected function simpleRoute($name, $data) { if (is_string($data)) { return $this->map->get($name, $data); } return $this->createRoute($name, $data); }
php
protected function simpleRoute($name, $data) { if (is_string($data)) { return $this->map->get($name, $data); } return $this->createRoute($name, $data); }
[ "protected", "function", "simpleRoute", "(", "$", "name", ",", "$", "data", ")", "{", "if", "(", "is_string", "(", "$", "data", ")", ")", "{", "return", "$", "this", "->", "map", "->", "get", "(", "$", "name", ",", "$", "data", ")", ";", "}", "...
Check if the data is a simple string, create a get with it If not a string pass the data to the construction chain where the route will be set with the data array passed @param string $name The route name @param string|array $data Meta data fo the route @return Route
[ "Check", "if", "the", "data", "is", "a", "simple", "string", "create", "a", "get", "with", "it" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Router/Builder/RouteFactory.php#L55-L61
train
slickframework/mvc
src/Router/Builder/RouteFactory.php
RouteFactory.setRouteProperties
protected function setRouteProperties(Route $route, array $data) { $methods = get_class_methods(Route::class); $methods = array_diff($methods, ["allows", "path"]); foreach($data as $method => $args) { if (in_array($method, $methods)) { $route->$method($args); } } return $route; }
php
protected function setRouteProperties(Route $route, array $data) { $methods = get_class_methods(Route::class); $methods = array_diff($methods, ["allows", "path"]); foreach($data as $method => $args) { if (in_array($method, $methods)) { $route->$method($args); } } return $route; }
[ "protected", "function", "setRouteProperties", "(", "Route", "$", "route", ",", "array", "$", "data", ")", "{", "$", "methods", "=", "get_class_methods", "(", "Route", "::", "class", ")", ";", "$", "methods", "=", "array_diff", "(", "$", "methods", ",", ...
Parses data array to set route properties @param Route $route @param array $data @return Route
[ "Parses", "data", "array", "to", "set", "route", "properties" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Router/Builder/RouteFactory.php#L93-L103
train
wollanup/php-api-rest
src/Service/Request/QueryModifier/Modifier/Base/ModifierBase.php
ModifierBase.apply
public function apply(ModelCriteria $query) { if (!empty($this->modifiers)) { foreach ($this->modifiers as $modifier) { if ($this->hasAllRequiredData($modifier)) { $modifier['property'] = str_replace('/', '.', $modifier['property']); # Check if the filter is occurring on a related model if (strpos($modifier['property'], '.') !== false) { $propertyParts = explode('.', $modifier['property']); # The last part is the related property we want to filter with, so remove it from the parts and store into a variable $propertyField = array_pop($propertyParts); # The new last part is the relation name $relationName = array_pop($propertyParts); # Apply the modifier $this->applyModifier($query, $this->buildClause($propertyField, $relationName), $modifier); } else { # Apply the modifier $this->applyModifier($query, $this->buildClause($modifier['property'], $query->getModelShortName()), $modifier); } } } } }
php
public function apply(ModelCriteria $query) { if (!empty($this->modifiers)) { foreach ($this->modifiers as $modifier) { if ($this->hasAllRequiredData($modifier)) { $modifier['property'] = str_replace('/', '.', $modifier['property']); # Check if the filter is occurring on a related model if (strpos($modifier['property'], '.') !== false) { $propertyParts = explode('.', $modifier['property']); # The last part is the related property we want to filter with, so remove it from the parts and store into a variable $propertyField = array_pop($propertyParts); # The new last part is the relation name $relationName = array_pop($propertyParts); # Apply the modifier $this->applyModifier($query, $this->buildClause($propertyField, $relationName), $modifier); } else { # Apply the modifier $this->applyModifier($query, $this->buildClause($modifier['property'], $query->getModelShortName()), $modifier); } } } } }
[ "public", "function", "apply", "(", "ModelCriteria", "$", "query", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "modifiers", ")", ")", "{", "foreach", "(", "$", "this", "->", "modifiers", "as", "$", "modifier", ")", "{", "if", "(", "$...
Apply the filter to the ModelQuery @param \Propel\Runtime\ActiveQuery\ModelCriteria $query
[ "Apply", "the", "filter", "to", "the", "ModelQuery" ]
185eac8a8412e5997d8e292ebd0e38787ae4b949
https://github.com/wollanup/php-api-rest/blob/185eac8a8412e5997d8e292ebd0e38787ae4b949/src/Service/Request/QueryModifier/Modifier/Base/ModifierBase.php#L76-L102
train
CatLabInteractive/Neuron
src/Neuron/Tools/Text.php
Text.get
public static function get ($message1, $message2 = null, $n = null) { $in = self::getInstance (); return $in->getText ($message1, $message2, $n); }
php
public static function get ($message1, $message2 = null, $n = null) { $in = self::getInstance (); return $in->getText ($message1, $message2, $n); }
[ "public", "static", "function", "get", "(", "$", "message1", ",", "$", "message2", "=", "null", ",", "$", "n", "=", "null", ")", "{", "$", "in", "=", "self", "::", "getInstance", "(", ")", ";", "return", "$", "in", "->", "getText", "(", "$", "mes...
Little helper method. @param string $message1 @param string|null $message2 @param string|null $n @return string
[ "Little", "helper", "method", "." ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Tools/Text.php#L70-L74
train
digipolisgent/openbib-id-api
src/Value/UserActivities/ExpenseCollection.php
ExpenseCollection.fromXml
public static function fromXml(\DOMNodeList $xml) { $items = array(); foreach ($xml as $xmlTag) { $items[] = Expense::fromXml($xmlTag); } return new static($items); }
php
public static function fromXml(\DOMNodeList $xml) { $items = array(); foreach ($xml as $xmlTag) { $items[] = Expense::fromXml($xmlTag); } return new static($items); }
[ "public", "static", "function", "fromXml", "(", "\\", "DOMNodeList", "$", "xml", ")", "{", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "xml", "as", "$", "xmlTag", ")", "{", "$", "items", "[", "]", "=", "Expense", "::", "fromXml"...
Builds a ExpenseCollection object from XML. @param \DOMNodeList $xml The list of xml tags representing the expenses. @return ExpenseCollection A ExpenseCollection object
[ "Builds", "a", "ExpenseCollection", "object", "from", "XML", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Value/UserActivities/ExpenseCollection.php#L18-L25
train
easy-system/es-http
src/Factory/UriQueryFactory.php
UriQueryFactory.make
public static function make(array $server = null) { if (empty($server)) { $server = $_SERVER; } if (isset($server['REQUEST_URI'])) { return parse_url($server['REQUEST_URI'], PHP_URL_QUERY); } }
php
public static function make(array $server = null) { if (empty($server)) { $server = $_SERVER; } if (isset($server['REQUEST_URI'])) { return parse_url($server['REQUEST_URI'], PHP_URL_QUERY); } }
[ "public", "static", "function", "make", "(", "array", "$", "server", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "server", ")", ")", "{", "$", "server", "=", "$", "_SERVER", ";", "}", "if", "(", "isset", "(", "$", "server", "[", "'REQUES...
Makes a string with Uri query. @param array $server Optional; null by default or empty array means global $_SERVER. The source data @return string|null Returns the Uri query if any, null otherwise
[ "Makes", "a", "string", "with", "Uri", "query", "." ]
dd5852e94901e147a7546a8715133408ece767a1
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Factory/UriQueryFactory.php#L25-L34
train
harmony-project/modular-routing
source/EventListener/RoutingSubscriber.php
RoutingSubscriber.onKernelRequest
public function onKernelRequest(GetResponseEvent $event) { if (null === $module = $event->getRequest()->get('module')) { return; } if (!$module instanceof ModuleInterface) { $module = $this->getModularRouter()->getModuleByRequest($event->getRequest()); } // todo remove current module functionality, as it can lead to unexpected behavior $this->getModuleManager()->setCurrentModule($module); }
php
public function onKernelRequest(GetResponseEvent $event) { if (null === $module = $event->getRequest()->get('module')) { return; } if (!$module instanceof ModuleInterface) { $module = $this->getModularRouter()->getModuleByRequest($event->getRequest()); } // todo remove current module functionality, as it can lead to unexpected behavior $this->getModuleManager()->setCurrentModule($module); }
[ "public", "function", "onKernelRequest", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "null", "===", "$", "module", "=", "$", "event", "->", "getRequest", "(", ")", "->", "get", "(", "'module'", ")", ")", "{", "return", ";", "}", "if", ...
Handles actions before the kernel matches the controller. @param GetResponseEvent $event
[ "Handles", "actions", "before", "the", "kernel", "matches", "the", "controller", "." ]
399bb427678ddc17c67295c738b96faea485e2d8
https://github.com/harmony-project/modular-routing/blob/399bb427678ddc17c67295c738b96faea485e2d8/source/EventListener/RoutingSubscriber.php#L78-L90
train
kevindierkx/elicit
src/Connector/AbstractConnector.php
AbstractConnector.createConnection
public function createConnection(array $config) { if (! isset($config['host'])) { throw new InvalidArgumentException("No host provided."); } $this->setHost($config['host']); // We check the configuration for request headers. Some API's require // certain headers for all requests. Providing them in the configuration // makes it easier to provide these headers on each request. if (isset($config['headers'])) { $this->setHeaders($config['headers']); } return $this; }
php
public function createConnection(array $config) { if (! isset($config['host'])) { throw new InvalidArgumentException("No host provided."); } $this->setHost($config['host']); // We check the configuration for request headers. Some API's require // certain headers for all requests. Providing them in the configuration // makes it easier to provide these headers on each request. if (isset($config['headers'])) { $this->setHeaders($config['headers']); } return $this; }
[ "public", "function", "createConnection", "(", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'host'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"No host provided.\"", ")", ";", "}", "$", ...
Initialize connector. @param array $config @return self @throws InvalidArgumentException
[ "Initialize", "connector", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Connector/AbstractConnector.php#L56-L72
train
kevindierkx/elicit
src/Connector/AbstractConnector.php
AbstractConnector.prepare
public function prepare(array $query) { $client = new Client; $this->client = $client; $this->request = $client->createRequest( $this->prepareMethod($query), $this->prepareRequestUrl($query), [ 'headers' => $this->prepareHeaders($query), 'body' => $this->prepareBody($query), ] ); return $this; }
php
public function prepare(array $query) { $client = new Client; $this->client = $client; $this->request = $client->createRequest( $this->prepareMethod($query), $this->prepareRequestUrl($query), [ 'headers' => $this->prepareHeaders($query), 'body' => $this->prepareBody($query), ] ); return $this; }
[ "public", "function", "prepare", "(", "array", "$", "query", ")", "{", "$", "client", "=", "new", "Client", ";", "$", "this", "->", "client", "=", "$", "client", ";", "$", "this", "->", "request", "=", "$", "client", "->", "createRequest", "(", "$", ...
Prepare a new request for execution. @param array $query @return self
[ "Prepare", "a", "new", "request", "for", "execution", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Connector/AbstractConnector.php#L80-L95
train
kevindierkx/elicit
src/Connector/AbstractConnector.php
AbstractConnector.prepareRequestUrl
protected function prepareRequestUrl(array $query) { $path = isset($query['from']['path']) ? $query['from']['path'] : null; $wheres = isset($query['wheres']) ? $query['wheres'] : null; $baseUrl = $this->host.$path; // Here we validate that there are any wheres in the // request. When none are provided we will return the // Request Url without the question mark. if (! is_null($wheres)) { return $baseUrl.'?'.$wheres; } return $baseUrl; }
php
protected function prepareRequestUrl(array $query) { $path = isset($query['from']['path']) ? $query['from']['path'] : null; $wheres = isset($query['wheres']) ? $query['wheres'] : null; $baseUrl = $this->host.$path; // Here we validate that there are any wheres in the // request. When none are provided we will return the // Request Url without the question mark. if (! is_null($wheres)) { return $baseUrl.'?'.$wheres; } return $baseUrl; }
[ "protected", "function", "prepareRequestUrl", "(", "array", "$", "query", ")", "{", "$", "path", "=", "isset", "(", "$", "query", "[", "'from'", "]", "[", "'path'", "]", ")", "?", "$", "query", "[", "'from'", "]", "[", "'path'", "]", ":", "null", "...
Prepare request URL from query. @param array $query @return string
[ "Prepare", "request", "URL", "from", "query", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Connector/AbstractConnector.php#L114-L130
train
kevindierkx/elicit
src/Connector/AbstractConnector.php
AbstractConnector.prepareBody
protected function prepareBody(array $query) { $method = isset($query['from']['method']) ? $query['from']['method'] : null; if ($method === 'POST') { // The query grammar already parsed the body for us. // We return the value of the query and guzzle does the rest. return isset($query['body']) ? $query['body'] : null; } }
php
protected function prepareBody(array $query) { $method = isset($query['from']['method']) ? $query['from']['method'] : null; if ($method === 'POST') { // The query grammar already parsed the body for us. // We return the value of the query and guzzle does the rest. return isset($query['body']) ? $query['body'] : null; } }
[ "protected", "function", "prepareBody", "(", "array", "$", "query", ")", "{", "$", "method", "=", "isset", "(", "$", "query", "[", "'from'", "]", "[", "'method'", "]", ")", "?", "$", "query", "[", "'from'", "]", "[", "'method'", "]", ":", "null", "...
Prepare body from query. @param array $query @return string|array|null
[ "Prepare", "body", "from", "query", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Connector/AbstractConnector.php#L156-L165
train