id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
232,900
asinfotrack/yii2-toolbox
widgets/SimpleNav.php
SimpleNav.isItemActive
protected function isItemActive($item) { if (!isset($item['url'])) return false; if (is_callable($this->isActiveCallback)) { return call_user_func($this->isActiveCallback, $item); } else { return \asinfotrack\yii2\toolbox\helpers\Url::isUrlActive($item['url']); } }
php
protected function isItemActive($item) { if (!isset($item['url'])) return false; if (is_callable($this->isActiveCallback)) { return call_user_func($this->isActiveCallback, $item); } else { return \asinfotrack\yii2\toolbox\helpers\Url::isUrlActive($item['url']); } }
[ "protected", "function", "isItemActive", "(", "$", "item", ")", "{", "if", "(", "!", "isset", "(", "$", "item", "[", "'url'", "]", ")", ")", "return", "false", ";", "if", "(", "is_callable", "(", "$", "this", "->", "isActiveCallback", ")", ")", "{", "return", "call_user_func", "(", "$", "this", "->", "isActiveCallback", ",", "$", "item", ")", ";", "}", "else", "{", "return", "\\", "asinfotrack", "\\", "yii2", "\\", "toolbox", "\\", "helpers", "\\", "Url", "::", "isUrlActive", "(", "$", "item", "[", "'url'", "]", ")", ";", "}", "}" ]
Determines if an url is active or not. @param array $item the item config @return bool true if active
[ "Determines", "if", "an", "url", "is", "active", "or", "not", "." ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/widgets/SimpleNav.php#L195-L204
232,901
phillies2k/ratchet-bundle
WebSocket/Client/AnonymousClientProvider.php
AnonymousClientProvider.findByAccessToken
public function findByAccessToken($accessToken) { if ($accessToken === '') { $client = new AnonymousClient(); $this->clients[$client->getAccessToken()] = $client; return $client; } if (! isset($this->clients[$accessToken])) { return null; } return $this->clients[$accessToken]; }
php
public function findByAccessToken($accessToken) { if ($accessToken === '') { $client = new AnonymousClient(); $this->clients[$client->getAccessToken()] = $client; return $client; } if (! isset($this->clients[$accessToken])) { return null; } return $this->clients[$accessToken]; }
[ "public", "function", "findByAccessToken", "(", "$", "accessToken", ")", "{", "if", "(", "$", "accessToken", "===", "''", ")", "{", "$", "client", "=", "new", "AnonymousClient", "(", ")", ";", "$", "this", "->", "clients", "[", "$", "client", "->", "getAccessToken", "(", ")", "]", "=", "$", "client", ";", "return", "$", "client", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "clients", "[", "$", "accessToken", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "clients", "[", "$", "accessToken", "]", ";", "}" ]
Returns a client found by the access token. @param string $accessToken @return ClientInterface
[ "Returns", "a", "client", "found", "by", "the", "access", "token", "." ]
1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3
https://github.com/phillies2k/ratchet-bundle/blob/1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3/WebSocket/Client/AnonymousClientProvider.php#L30-L46
232,902
phillies2k/ratchet-bundle
WebSocket/Client/AnonymousClientProvider.php
AnonymousClientProvider.updateClient
public function updateClient(ClientInterface $client) { if (isset($this->clients[$client->getAccessToken()])) { $this->clients[$client->getAccessToken()] = $client; } }
php
public function updateClient(ClientInterface $client) { if (isset($this->clients[$client->getAccessToken()])) { $this->clients[$client->getAccessToken()] = $client; } }
[ "public", "function", "updateClient", "(", "ClientInterface", "$", "client", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "clients", "[", "$", "client", "->", "getAccessToken", "(", ")", "]", ")", ")", "{", "$", "this", "->", "clients", "[", "$", "client", "->", "getAccessToken", "(", ")", "]", "=", "$", "client", ";", "}", "}" ]
Updates the given client in the underlying data layer. @param ClientInterface $client @return void
[ "Updates", "the", "given", "client", "in", "the", "underlying", "data", "layer", "." ]
1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3
https://github.com/phillies2k/ratchet-bundle/blob/1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3/WebSocket/Client/AnonymousClientProvider.php#L54-L59
232,903
dmitriybelyy/yii2-cassandra-cql
phpcassa/SystemManager.php
SystemManager.create_keyspace
public function create_keyspace($keyspace, $attrs) { $ksdef = $this->make_ksdef($keyspace, $attrs); $this->client->system_add_keyspace($ksdef); $this->wait_for_agreement(); }
php
public function create_keyspace($keyspace, $attrs) { $ksdef = $this->make_ksdef($keyspace, $attrs); $this->client->system_add_keyspace($ksdef); $this->wait_for_agreement(); }
[ "public", "function", "create_keyspace", "(", "$", "keyspace", ",", "$", "attrs", ")", "{", "$", "ksdef", "=", "$", "this", "->", "make_ksdef", "(", "$", "keyspace", ",", "$", "attrs", ")", ";", "$", "this", "->", "client", "->", "system_add_keyspace", "(", "$", "ksdef", ")", ";", "$", "this", "->", "wait_for_agreement", "(", ")", ";", "}" ]
Creates a new keyspace. Example usage: <code> use phpcassa\SystemManager; use phpcassa\Schema\StrategyClass; $sys = SystemManager(); $attrs = array("strategy_class" => StrategyClass\SIMPLE_STRATEGY, "strategy_options" => array("replication_factor" => "1")); $sys->create_keyspace("Keyspace1", $attrs); </code> @param string $keyspace the keyspace name @param array $attrs an array that maps attribute names to values. Valid attribute names include "strategy_class", "strategy_options", and "replication_factor". By default, SimpleStrategy will be used with a replication factor of 1 and no strategy options.
[ "Creates", "a", "new", "keyspace", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/SystemManager.php#L84-L88
232,904
dmitriybelyy/yii2-cassandra-cql
phpcassa/SystemManager.php
SystemManager.alter_keyspace
public function alter_keyspace($keyspace, $attrs) { $ksdef = $this->client->describe_keyspace($keyspace); $ksdef = $this->make_ksdef($keyspace, $attrs, $ksdef); $this->client->system_update_keyspace($ksdef); $this->wait_for_agreement(); }
php
public function alter_keyspace($keyspace, $attrs) { $ksdef = $this->client->describe_keyspace($keyspace); $ksdef = $this->make_ksdef($keyspace, $attrs, $ksdef); $this->client->system_update_keyspace($ksdef); $this->wait_for_agreement(); }
[ "public", "function", "alter_keyspace", "(", "$", "keyspace", ",", "$", "attrs", ")", "{", "$", "ksdef", "=", "$", "this", "->", "client", "->", "describe_keyspace", "(", "$", "keyspace", ")", ";", "$", "ksdef", "=", "$", "this", "->", "make_ksdef", "(", "$", "keyspace", ",", "$", "attrs", ",", "$", "ksdef", ")", ";", "$", "this", "->", "client", "->", "system_update_keyspace", "(", "$", "ksdef", ")", ";", "$", "this", "->", "wait_for_agreement", "(", ")", ";", "}" ]
Modifies a keyspace's properties. Example usage: <code> $sys = SystemManager(); $attrs = array("replication_factor" => 2); $sys->alter_keyspace("Keyspace1", $attrs); </code> @param string $keyspace the keyspace to modify @param array $attrs an array that maps attribute names to values. Valid attribute names include "strategy_class", "strategy_options", and "replication_factor".
[ "Modifies", "a", "keyspace", "s", "properties", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/SystemManager.php#L107-L112
232,905
dmitriybelyy/yii2-cassandra-cql
phpcassa/SystemManager.php
SystemManager.create_column_family
public function create_column_family($keyspace, $column_family, $attrs=null) { if ($attrs === null) $attrs = array(); $this->client->set_keyspace($keyspace); $cfdef = $this->make_cfdef($keyspace, $column_family, $attrs); $this->client->system_add_column_family($cfdef); $this->wait_for_agreement(); }
php
public function create_column_family($keyspace, $column_family, $attrs=null) { if ($attrs === null) $attrs = array(); $this->client->set_keyspace($keyspace); $cfdef = $this->make_cfdef($keyspace, $column_family, $attrs); $this->client->system_add_column_family($cfdef); $this->wait_for_agreement(); }
[ "public", "function", "create_column_family", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "attrs", "=", "null", ")", "{", "if", "(", "$", "attrs", "===", "null", ")", "$", "attrs", "=", "array", "(", ")", ";", "$", "this", "->", "client", "->", "set_keyspace", "(", "$", "keyspace", ")", ";", "$", "cfdef", "=", "$", "this", "->", "make_cfdef", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "attrs", ")", ";", "$", "this", "->", "client", "->", "system_add_column_family", "(", "$", "cfdef", ")", ";", "$", "this", "->", "wait_for_agreement", "(", ")", ";", "}" ]
Creates a column family. Example usage: <code> $sys = SystemManager(); $attrs = array("column_type" => "Standard", "comparator_type" => "org.apache.cassandra.db.marshal.AsciiType", "memtable_throughput_in_mb" => 32); $sys->create_column_family("Keyspace1", "ColumnFamily1", $attrs); </code> @param string $keyspace the keyspace containing the column family @param string $column_family the name of the column family @param array $attrs an array that maps attribute names to values.
[ "Creates", "a", "column", "family", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/SystemManager.php#L169-L177
232,906
dmitriybelyy/yii2-cassandra-cql
phpcassa/SystemManager.php
SystemManager.alter_column_family
public function alter_column_family($keyspace, $column_family, $attrs) { $cfdef = $this->get_cfdef($keyspace, $column_family); $cfdef = $this->make_cfdef($keyspace, $column_family, $attrs, $cfdef); $this->client->set_keyspace($cfdef->keyspace); $this->client->system_update_column_family($cfdef); $this->wait_for_agreement(); }
php
public function alter_column_family($keyspace, $column_family, $attrs) { $cfdef = $this->get_cfdef($keyspace, $column_family); $cfdef = $this->make_cfdef($keyspace, $column_family, $attrs, $cfdef); $this->client->set_keyspace($cfdef->keyspace); $this->client->system_update_column_family($cfdef); $this->wait_for_agreement(); }
[ "public", "function", "alter_column_family", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "attrs", ")", "{", "$", "cfdef", "=", "$", "this", "->", "get_cfdef", "(", "$", "keyspace", ",", "$", "column_family", ")", ";", "$", "cfdef", "=", "$", "this", "->", "make_cfdef", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "attrs", ",", "$", "cfdef", ")", ";", "$", "this", "->", "client", "->", "set_keyspace", "(", "$", "cfdef", "->", "keyspace", ")", ";", "$", "this", "->", "client", "->", "system_update_column_family", "(", "$", "cfdef", ")", ";", "$", "this", "->", "wait_for_agreement", "(", ")", ";", "}" ]
Modifies a column family's attributes. Example usage: <code> $sys = SystemManager(); $attrs = array("max_compaction_threshold" => 10); $sys->alter_column_family("Keyspace1", "ColumnFamily1", $attrs); </code> @param string $keyspace the keyspace containing the column family @param string $column_family the name of the column family @param array $attrs an array that maps attribute names to values.
[ "Modifies", "a", "column", "family", "s", "attributes", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/SystemManager.php#L221-L227
232,907
dmitriybelyy/yii2-cassandra-cql
phpcassa/SystemManager.php
SystemManager.truncate_column_family
public function truncate_column_family($keyspace, $column_family) { $this->client->set_keyspace($keyspace); $this->client->truncate($column_family); }
php
public function truncate_column_family($keyspace, $column_family) { $this->client->set_keyspace($keyspace); $this->client->truncate($column_family); }
[ "public", "function", "truncate_column_family", "(", "$", "keyspace", ",", "$", "column_family", ")", "{", "$", "this", "->", "client", "->", "set_keyspace", "(", "$", "keyspace", ")", ";", "$", "this", "->", "client", "->", "truncate", "(", "$", "column_family", ")", ";", "}" ]
Mark the entire column family as deleted. From the user's perspective a successful call to truncate will result complete data deletion from cfname. Internally, however, disk space will not be immediatily released, as with all deletes in cassandra, this one only marks the data as deleted. The operation succeeds only if all hosts in the cluster at available and will throw an UnavailableException if some hosts are down. Example usage: <code> $sys = SystemManager(); $sys->truncate_column_family("Keyspace1", "ColumnFamily1"); </code> @param string $keyspace the keyspace the CF is in @param string $column_family the column family name
[ "Mark", "the", "entire", "column", "family", "as", "deleted", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/SystemManager.php#L261-L264
232,908
dmitriybelyy/yii2-cassandra-cql
phpcassa/SystemManager.php
SystemManager.create_index
public function create_index($keyspace, $column_family, $column, $data_type=self::KEEP, $index_name=NULL, $index_type=IndexType::KEYS) { $this->_alter_column($keyspace, $column_family, $column, $data_type=$data_type, $index_type=$index_type, $index_name=$index_name); }
php
public function create_index($keyspace, $column_family, $column, $data_type=self::KEEP, $index_name=NULL, $index_type=IndexType::KEYS) { $this->_alter_column($keyspace, $column_family, $column, $data_type=$data_type, $index_type=$index_type, $index_name=$index_name); }
[ "public", "function", "create_index", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "column", ",", "$", "data_type", "=", "self", "::", "KEEP", ",", "$", "index_name", "=", "NULL", ",", "$", "index_type", "=", "IndexType", "::", "KEYS", ")", "{", "$", "this", "->", "_alter_column", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "column", ",", "$", "data_type", "=", "$", "data_type", ",", "$", "index_type", "=", "$", "index_type", ",", "$", "index_name", "=", "$", "index_name", ")", ";", "}" ]
Adds an index to a column family. Example usage: <code> $sys = new SystemManager(); $sys->create_index("Keyspace1", "Users", "name", "UTF8Type"); </code> @param string $keyspace the name of the keyspace containing the column family @param string $column_family the name of the column family @param string $column the name of the column to put the index on @param string $data_type the data type of the values being indexed @param string $index_name an optional name for the index @param IndexType $index_type the type of index. Defaults to \cassandra\IndexType::KEYS_INDEX, which is currently the only option.
[ "Adds", "an", "index", "to", "a", "column", "family", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/SystemManager.php#L284-L289
232,909
dmitriybelyy/yii2-cassandra-cql
phpcassa/SystemManager.php
SystemManager.drop_index
public function drop_index($keyspace, $column_family, $column) { $this->_alter_column($keyspace, $column_family, $column, $data_type=self::KEEP, $index_type=NULL, $index_name=NULL); }
php
public function drop_index($keyspace, $column_family, $column) { $this->_alter_column($keyspace, $column_family, $column, $data_type=self::KEEP, $index_type=NULL, $index_name=NULL); }
[ "public", "function", "drop_index", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "column", ")", "{", "$", "this", "->", "_alter_column", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "column", ",", "$", "data_type", "=", "self", "::", "KEEP", ",", "$", "index_type", "=", "NULL", ",", "$", "index_name", "=", "NULL", ")", ";", "}" ]
Drop an index from a column family. Example usage: <code> $sys = new SystemManager(); $sys->drop_index("Keyspace1", "Users", "name"); </code> @param string $keyspace the name of the keyspace containing the column family @param string $column_family the name of the column family @param string $column the name of the column to drop the index from
[ "Drop", "an", "index", "from", "a", "column", "family", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/SystemManager.php#L305-L308
232,910
dmitriybelyy/yii2-cassandra-cql
phpcassa/SystemManager.php
SystemManager.alter_column
public function alter_column($keyspace, $column_family, $column, $data_type) { $this->_alter_column($keyspace, $column_family, $column, $data_type); }
php
public function alter_column($keyspace, $column_family, $column, $data_type) { $this->_alter_column($keyspace, $column_family, $column, $data_type); }
[ "public", "function", "alter_column", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "column", ",", "$", "data_type", ")", "{", "$", "this", "->", "_alter_column", "(", "$", "keyspace", ",", "$", "column_family", ",", "$", "column", ",", "$", "data_type", ")", ";", "}" ]
Changes or sets the validation class of a single column. Example usage: <code> $sys = new SystemManager(); $sys->alter_column("Keyspace1", "Users", "name", "UTF8Type"); </code> @param string $keyspace the name of the keyspace containing the column family @param string $column_family the name of the column family @param string $column the name of the column to put the index on @param string $data_type the data type of the values being indexed
[ "Changes", "or", "sets", "the", "validation", "class", "of", "a", "single", "column", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/SystemManager.php#L325-L327
232,911
irishdan/PDFTronBundle
Services/PDFCropper.php
PDFCropper.crop
public function crop($inputPDFPath, $outputPDFPath, $padding = 10, $x2 = null, $y1 = null, $y2 = null) { $inputDoc = new \PDFDoc($inputPDFPath); $inputDoc->InitSecurityHandler(); $iterator = $inputDoc->GetPageIterator(); for ($iterator; $iterator->HasNext(); $iterator->Next()) { $mediaBox = new \Rect($iterator->Current()->GetMediaBox()); $mediaBox->x1 += $padding; $mediaBox->x2 -= empty($x2) ? $padding : $x2; $mediaBox->y1 += empty($y1) ? $padding : $y1; $mediaBox->y2 -= empty($y2) ? $padding : $y2; $mediaBox->Update(); } $inputDoc->Save($outputPDFPath, 0); $inputDoc->Close(); }
php
public function crop($inputPDFPath, $outputPDFPath, $padding = 10, $x2 = null, $y1 = null, $y2 = null) { $inputDoc = new \PDFDoc($inputPDFPath); $inputDoc->InitSecurityHandler(); $iterator = $inputDoc->GetPageIterator(); for ($iterator; $iterator->HasNext(); $iterator->Next()) { $mediaBox = new \Rect($iterator->Current()->GetMediaBox()); $mediaBox->x1 += $padding; $mediaBox->x2 -= empty($x2) ? $padding : $x2; $mediaBox->y1 += empty($y1) ? $padding : $y1; $mediaBox->y2 -= empty($y2) ? $padding : $y2; $mediaBox->Update(); } $inputDoc->Save($outputPDFPath, 0); $inputDoc->Close(); }
[ "public", "function", "crop", "(", "$", "inputPDFPath", ",", "$", "outputPDFPath", ",", "$", "padding", "=", "10", ",", "$", "x2", "=", "null", ",", "$", "y1", "=", "null", ",", "$", "y2", "=", "null", ")", "{", "$", "inputDoc", "=", "new", "\\", "PDFDoc", "(", "$", "inputPDFPath", ")", ";", "$", "inputDoc", "->", "InitSecurityHandler", "(", ")", ";", "$", "iterator", "=", "$", "inputDoc", "->", "GetPageIterator", "(", ")", ";", "for", "(", "$", "iterator", ";", "$", "iterator", "->", "HasNext", "(", ")", ";", "$", "iterator", "->", "Next", "(", ")", ")", "{", "$", "mediaBox", "=", "new", "\\", "Rect", "(", "$", "iterator", "->", "Current", "(", ")", "->", "GetMediaBox", "(", ")", ")", ";", "$", "mediaBox", "->", "x1", "+=", "$", "padding", ";", "$", "mediaBox", "->", "x2", "-=", "empty", "(", "$", "x2", ")", "?", "$", "padding", ":", "$", "x2", ";", "$", "mediaBox", "->", "y1", "+=", "empty", "(", "$", "y1", ")", "?", "$", "padding", ":", "$", "y1", ";", "$", "mediaBox", "->", "y2", "-=", "empty", "(", "$", "y2", ")", "?", "$", "padding", ":", "$", "y2", ";", "$", "mediaBox", "->", "Update", "(", ")", ";", "}", "$", "inputDoc", "->", "Save", "(", "$", "outputPDFPath", ",", "0", ")", ";", "$", "inputDoc", "->", "Close", "(", ")", ";", "}" ]
Crops an external padding from every page of the PDF. @param $inputPDFPath @param null $outputPDFPath @param int $padding @param null $x2 @param null $y1 @param null $y2
[ "Crops", "an", "external", "padding", "from", "every", "page", "of", "the", "PDF", "." ]
72926bf9a39256a8438b320f61ec071be3c5a655
https://github.com/irishdan/PDFTronBundle/blob/72926bf9a39256a8438b320f61ec071be3c5a655/Services/PDFCropper.php#L38-L57
232,912
silverstripe-archive/deploynaut
code/tasks/SyncProjectsAndEnvironments.php
SyncProjectsAndEnvironments.removeObsoleteEnvironments
protected function removeObsoleteEnvironments($paths, $project, $dryRun = false) { $list = $project->Environments(); $basePaths = array_map(function($path) { return basename($path); }, $paths); $removeList = $list->filter('Filename:not', $basePaths); if($removeList->count() === 0) { return; } foreach($removeList as $remove) { $this->message('Removing "'.basename($remove->Name).'" from db'); if(!$dryRun) { $removeList->remove($remove); } } }
php
protected function removeObsoleteEnvironments($paths, $project, $dryRun = false) { $list = $project->Environments(); $basePaths = array_map(function($path) { return basename($path); }, $paths); $removeList = $list->filter('Filename:not', $basePaths); if($removeList->count() === 0) { return; } foreach($removeList as $remove) { $this->message('Removing "'.basename($remove->Name).'" from db'); if(!$dryRun) { $removeList->remove($remove); } } }
[ "protected", "function", "removeObsoleteEnvironments", "(", "$", "paths", ",", "$", "project", ",", "$", "dryRun", "=", "false", ")", "{", "$", "list", "=", "$", "project", "->", "Environments", "(", ")", ";", "$", "basePaths", "=", "array_map", "(", "function", "(", "$", "path", ")", "{", "return", "basename", "(", "$", "path", ")", ";", "}", ",", "$", "paths", ")", ";", "$", "removeList", "=", "$", "list", "->", "filter", "(", "'Filename:not'", ",", "$", "basePaths", ")", ";", "if", "(", "$", "removeList", "->", "count", "(", ")", "===", "0", ")", "{", "return", ";", "}", "foreach", "(", "$", "removeList", "as", "$", "remove", ")", "{", "$", "this", "->", "message", "(", "'Removing \"'", ".", "basename", "(", "$", "remove", "->", "Name", ")", ".", "'\" from db'", ")", ";", "if", "(", "!", "$", "dryRun", ")", "{", "$", "removeList", "->", "remove", "(", "$", "remove", ")", ";", "}", "}", "}" ]
Remove environment files that can't be found on disk @param array $paths Array of pathnames @param DNProject @param bool $dryRun
[ "Remove", "environment", "files", "that", "can", "t", "be", "found", "on", "disk" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/tasks/SyncProjectsAndEnvironments.php#L54-L72
232,913
irishdan/PDFTronBundle
Services/PDFThumbnailGenerator.php
PDFThumbnailGenerator.drawImage
public function drawImage($PDFFilePath = '', $outputPath = '', $dpi = 92, $page = 1, $imageType = 'JPEG') { $draw = new \PDFDraw(); $draw->SetDPI($dpi); $doc = new \PDFDoc($PDFFilePath); $doc->InitSecurityHandler(); $pg = $doc->GetPage($page); $draw->Export($pg, $outputPath, $imageType); $doc->Close(); }
php
public function drawImage($PDFFilePath = '', $outputPath = '', $dpi = 92, $page = 1, $imageType = 'JPEG') { $draw = new \PDFDraw(); $draw->SetDPI($dpi); $doc = new \PDFDoc($PDFFilePath); $doc->InitSecurityHandler(); $pg = $doc->GetPage($page); $draw->Export($pg, $outputPath, $imageType); $doc->Close(); }
[ "public", "function", "drawImage", "(", "$", "PDFFilePath", "=", "''", ",", "$", "outputPath", "=", "''", ",", "$", "dpi", "=", "92", ",", "$", "page", "=", "1", ",", "$", "imageType", "=", "'JPEG'", ")", "{", "$", "draw", "=", "new", "\\", "PDFDraw", "(", ")", ";", "$", "draw", "->", "SetDPI", "(", "$", "dpi", ")", ";", "$", "doc", "=", "new", "\\", "PDFDoc", "(", "$", "PDFFilePath", ")", ";", "$", "doc", "->", "InitSecurityHandler", "(", ")", ";", "$", "pg", "=", "$", "doc", "->", "GetPage", "(", "$", "page", ")", ";", "$", "draw", "->", "Export", "(", "$", "pg", ",", "$", "outputPath", ",", "$", "imageType", ")", ";", "$", "doc", "->", "Close", "(", ")", ";", "}" ]
Create an image from a page of a PDF. @param string $PDFFilePath @param string $outputPath @param int $dpi @param int $page @param string $imageType
[ "Create", "an", "image", "from", "a", "page", "of", "a", "PDF", "." ]
72926bf9a39256a8438b320f61ec071be3c5a655
https://github.com/irishdan/PDFTronBundle/blob/72926bf9a39256a8438b320f61ec071be3c5a655/Services/PDFThumbnailGenerator.php#L41-L51
232,914
OzanKurt/google-analytics
src/Analytics.php
Analytics.configure
private function configure() { $analyticsConfig = $this->googleServicesCore->getConfig('analytics'); if (array_key_exists('viewId', $analyticsConfig)) { $this->viewId = $analyticsConfig['viewId']; } }
php
private function configure() { $analyticsConfig = $this->googleServicesCore->getConfig('analytics'); if (array_key_exists('viewId', $analyticsConfig)) { $this->viewId = $analyticsConfig['viewId']; } }
[ "private", "function", "configure", "(", ")", "{", "$", "analyticsConfig", "=", "$", "this", "->", "googleServicesCore", "->", "getConfig", "(", "'analytics'", ")", ";", "if", "(", "array_key_exists", "(", "'viewId'", ",", "$", "analyticsConfig", ")", ")", "{", "$", "this", "->", "viewId", "=", "$", "analyticsConfig", "[", "'viewId'", "]", ";", "}", "}" ]
Set the configuration details of analytics. @return void
[ "Set", "the", "configuration", "details", "of", "analytics", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Analytics.php#L98-L105
232,915
OzanKurt/google-analytics
src/Analytics.php
Analytics.getRealtimeData
public function getRealtimeData() { $this->validateViewId(); $this->setMetrics('rt:activeUsers'); $data = $this->service->data_realtime->get( $this->viewId, $this->getMetricsAsString(), $this->getOptions() ); return $data->toSimpleObject()->totalsForAllResults; }
php
public function getRealtimeData() { $this->validateViewId(); $this->setMetrics('rt:activeUsers'); $data = $this->service->data_realtime->get( $this->viewId, $this->getMetricsAsString(), $this->getOptions() ); return $data->toSimpleObject()->totalsForAllResults; }
[ "public", "function", "getRealtimeData", "(", ")", "{", "$", "this", "->", "validateViewId", "(", ")", ";", "$", "this", "->", "setMetrics", "(", "'rt:activeUsers'", ")", ";", "$", "data", "=", "$", "this", "->", "service", "->", "data_realtime", "->", "get", "(", "$", "this", "->", "viewId", ",", "$", "this", "->", "getMetricsAsString", "(", ")", ",", "$", "this", "->", "getOptions", "(", ")", ")", ";", "return", "$", "data", "->", "toSimpleObject", "(", ")", "->", "totalsForAllResults", ";", "}" ]
Execute the query and fetch the results to a collection. @return array
[ "Execute", "the", "query", "and", "fetch", "the", "results", "to", "a", "collection", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Analytics.php#L129-L142
232,916
OzanKurt/google-analytics
src/Analytics.php
Analytics.execute
public function execute($parameters = [], $parseResult = true) { $this->validateViewId(); $this->mergeParams($parameters); /* * A query can't run without any metrics. */ if (!$this->metricsAreSet()) { throw new UndefinedMetricsException(); } $result = $this->service->data_ga->get( $this->viewId, $this->period->getStartDate()->format('Y-m-d'), $this->period->getEndDate()->format('Y-m-d'), $this->getMetricsAsString(), $this->getOptions() ); if ($parseResult) { return $this->parseResult($result); } return $result; }
php
public function execute($parameters = [], $parseResult = true) { $this->validateViewId(); $this->mergeParams($parameters); /* * A query can't run without any metrics. */ if (!$this->metricsAreSet()) { throw new UndefinedMetricsException(); } $result = $this->service->data_ga->get( $this->viewId, $this->period->getStartDate()->format('Y-m-d'), $this->period->getEndDate()->format('Y-m-d'), $this->getMetricsAsString(), $this->getOptions() ); if ($parseResult) { return $this->parseResult($result); } return $result; }
[ "public", "function", "execute", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "validateViewId", "(", ")", ";", "$", "this", "->", "mergeParams", "(", "$", "parameters", ")", ";", "/*\n * A query can't run without any metrics.\n */", "if", "(", "!", "$", "this", "->", "metricsAreSet", "(", ")", ")", "{", "throw", "new", "UndefinedMetricsException", "(", ")", ";", "}", "$", "result", "=", "$", "this", "->", "service", "->", "data_ga", "->", "get", "(", "$", "this", "->", "viewId", ",", "$", "this", "->", "period", "->", "getStartDate", "(", ")", "->", "format", "(", "'Y-m-d'", ")", ",", "$", "this", "->", "period", "->", "getEndDate", "(", ")", "->", "format", "(", "'Y-m-d'", ")", ",", "$", "this", "->", "getMetricsAsString", "(", ")", ",", "$", "this", "->", "getOptions", "(", ")", ")", ";", "if", "(", "$", "parseResult", ")", "{", "return", "$", "this", "->", "parseResult", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Execute the query by merging arrays to current ones. @param array $parameters @return $this
[ "Execute", "the", "query", "by", "merging", "arrays", "to", "current", "ones", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Analytics.php#L151-L177
232,917
OzanKurt/google-analytics
src/Analytics.php
Analytics.parseResult
public function parseResult($results) { $simpleDataTable = $results->getDataTable()->toSimpleObject(); foreach ($simpleDataTable->cols as $col) { $cols[] = $col['label']; } foreach ($simpleDataTable->rows as $row) { foreach ($row['c'] as $key => $value) { $rowData[$cols[$key]] = $value['v']; } $rows[] = $rowData; unset($rowData); } return [ 'cols' => $cols, 'rows' => $rows, ]; }
php
public function parseResult($results) { $simpleDataTable = $results->getDataTable()->toSimpleObject(); foreach ($simpleDataTable->cols as $col) { $cols[] = $col['label']; } foreach ($simpleDataTable->rows as $row) { foreach ($row['c'] as $key => $value) { $rowData[$cols[$key]] = $value['v']; } $rows[] = $rowData; unset($rowData); } return [ 'cols' => $cols, 'rows' => $rows, ]; }
[ "public", "function", "parseResult", "(", "$", "results", ")", "{", "$", "simpleDataTable", "=", "$", "results", "->", "getDataTable", "(", ")", "->", "toSimpleObject", "(", ")", ";", "foreach", "(", "$", "simpleDataTable", "->", "cols", "as", "$", "col", ")", "{", "$", "cols", "[", "]", "=", "$", "col", "[", "'label'", "]", ";", "}", "foreach", "(", "$", "simpleDataTable", "->", "rows", "as", "$", "row", ")", "{", "foreach", "(", "$", "row", "[", "'c'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "rowData", "[", "$", "cols", "[", "$", "key", "]", "]", "=", "$", "value", "[", "'v'", "]", ";", "}", "$", "rows", "[", "]", "=", "$", "rowData", ";", "unset", "(", "$", "rowData", ")", ";", "}", "return", "[", "'cols'", "=>", "$", "cols", ",", "'rows'", "=>", "$", "rows", ",", "]", ";", "}" ]
Parse the dirty google data response. @var \Google_Service_Analytics_GaData results @return array
[ "Parse", "the", "dirty", "google", "data", "response", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Analytics.php#L200-L222
232,918
mcustiel/php-simple-request
src/Validator/AbstractAnnotationSpecifiedValidator.php
AbstractAnnotationSpecifiedValidator.createValidatorInstanceFromAnnotation
protected function createValidatorInstanceFromAnnotation($validatorAnnotation) { return ValidatorBuilder::builder() ->withSpecification($validatorAnnotation->getValue()) ->withClass($validatorAnnotation->getAssociatedClass()) ->build(); }
php
protected function createValidatorInstanceFromAnnotation($validatorAnnotation) { return ValidatorBuilder::builder() ->withSpecification($validatorAnnotation->getValue()) ->withClass($validatorAnnotation->getAssociatedClass()) ->build(); }
[ "protected", "function", "createValidatorInstanceFromAnnotation", "(", "$", "validatorAnnotation", ")", "{", "return", "ValidatorBuilder", "::", "builder", "(", ")", "->", "withSpecification", "(", "$", "validatorAnnotation", "->", "getValue", "(", ")", ")", "->", "withClass", "(", "$", "validatorAnnotation", "->", "getAssociatedClass", "(", ")", ")", "->", "build", "(", ")", ";", "}" ]
Constructs a Validator object from a Validator annotation. @param \Mcustiel\SimpleRequest\Annotation\ValidatorAnnotation $validatorAnnotation @return \Mcustiel\SimpleRequest\Interfaces\ValidatorInterface Created validator object.
[ "Constructs", "a", "Validator", "object", "from", "a", "Validator", "annotation", "." ]
4d0fc06092ccdff3ea488c67b394225c7243428f
https://github.com/mcustiel/php-simple-request/blob/4d0fc06092ccdff3ea488c67b394225c7243428f/src/Validator/AbstractAnnotationSpecifiedValidator.php#L61-L67
232,919
webfactorybulgaria/laravel-shop
src/Traits/ShopCartTrait.php
ShopCartTrait.increase
public function increase($item, $quantity = 1, $quantityReset = false) { $item->quantity = $quantityReset ? $quantity : $item->quantity + $quantity; $item->save(); $this->resetCalculations(); return $this; }
php
public function increase($item, $quantity = 1, $quantityReset = false) { $item->quantity = $quantityReset ? $quantity : $item->quantity + $quantity; $item->save(); $this->resetCalculations(); return $this; }
[ "public", "function", "increase", "(", "$", "item", ",", "$", "quantity", "=", "1", ",", "$", "quantityReset", "=", "false", ")", "{", "$", "item", "->", "quantity", "=", "$", "quantityReset", "?", "$", "quantity", ":", "$", "item", "->", "quantity", "+", "$", "quantity", ";", "$", "item", "->", "save", "(", ")", ";", "$", "this", "->", "resetCalculations", "(", ")", ";", "return", "$", "this", ";", "}" ]
Directly increase already existing item @param Item $item Item to add. @param int $quantity Item quantity in cart. @return Item
[ "Directly", "increase", "already", "existing", "item" ]
9d191b7d17395bd875505bfbc0b1077dc6c87869
https://github.com/webfactorybulgaria/laravel-shop/blob/9d191b7d17395bd875505bfbc0b1077dc6c87869/src/Traits/ShopCartTrait.php#L170-L179
232,920
webfactorybulgaria/laravel-shop
src/Traits/ShopCartTrait.php
ShopCartTrait.remove
public function remove($item, $quantity = 0) { // Get item //$cartItem = $this->getItem(is_array($item) ? $item['sku'] : $item->sku, $item->attributes_hash); // Remove or decrease quantity if (!empty($quantity)) { $item->quantity -= $quantity; $item->save(); if ($item->quantity > 0) return true; } $item->delete(); $this->resetCalculations(); return $this; }
php
public function remove($item, $quantity = 0) { // Get item //$cartItem = $this->getItem(is_array($item) ? $item['sku'] : $item->sku, $item->attributes_hash); // Remove or decrease quantity if (!empty($quantity)) { $item->quantity -= $quantity; $item->save(); if ($item->quantity > 0) return true; } $item->delete(); $this->resetCalculations(); return $this; }
[ "public", "function", "remove", "(", "$", "item", ",", "$", "quantity", "=", "0", ")", "{", "// Get item", "//$cartItem = $this->getItem(is_array($item) ? $item['sku'] : $item->sku, $item->attributes_hash);", "// Remove or decrease quantity", "if", "(", "!", "empty", "(", "$", "quantity", ")", ")", "{", "$", "item", "->", "quantity", "-=", "$", "quantity", ";", "$", "item", "->", "save", "(", ")", ";", "if", "(", "$", "item", "->", "quantity", ">", "0", ")", "return", "true", ";", "}", "$", "item", "->", "delete", "(", ")", ";", "$", "this", "->", "resetCalculations", "(", ")", ";", "return", "$", "this", ";", "}" ]
Removes an item from the cart or decreases its quantity. Returns flag indicating if removal was successful. @param mixed $item Item to remove, can be an Store Item, a Model with ShopItemTrait or an array. @param int $quantity Item quantity to decrease. 0 if wanted item to be removed completly. @return bool
[ "Removes", "an", "item", "from", "the", "cart", "or", "decreases", "its", "quantity", ".", "Returns", "flag", "indicating", "if", "removal", "was", "successful", "." ]
9d191b7d17395bd875505bfbc0b1077dc6c87869
https://github.com/webfactorybulgaria/laravel-shop/blob/9d191b7d17395bd875505bfbc0b1077dc6c87869/src/Traits/ShopCartTrait.php#L190-L205
232,921
webfactorybulgaria/laravel-shop
src/Traits/ShopCartTrait.php
ShopCartTrait.scopeCurrent
public function scopeCurrent($query) { $cart = $query->whereCurrent()->first(); if (empty($cart)) { if (!Auth::guest()) { $cart = call_user_func( Config::get('shop.cart') . '::create', [ 'user_id' => Auth::user()->shopId, 'session_id' => session('visitor_id') ]); } else { $cart = call_user_func( Config::get('shop.cart') . '::create', [ 'session_id' => session('visitor_id') ]); } } return $cart; }
php
public function scopeCurrent($query) { $cart = $query->whereCurrent()->first(); if (empty($cart)) { if (!Auth::guest()) { $cart = call_user_func( Config::get('shop.cart') . '::create', [ 'user_id' => Auth::user()->shopId, 'session_id' => session('visitor_id') ]); } else { $cart = call_user_func( Config::get('shop.cart') . '::create', [ 'session_id' => session('visitor_id') ]); } } return $cart; }
[ "public", "function", "scopeCurrent", "(", "$", "query", ")", "{", "$", "cart", "=", "$", "query", "->", "whereCurrent", "(", ")", "->", "first", "(", ")", ";", "if", "(", "empty", "(", "$", "cart", ")", ")", "{", "if", "(", "!", "Auth", "::", "guest", "(", ")", ")", "{", "$", "cart", "=", "call_user_func", "(", "Config", "::", "get", "(", "'shop.cart'", ")", ".", "'::create'", ",", "[", "'user_id'", "=>", "Auth", "::", "user", "(", ")", "->", "shopId", ",", "'session_id'", "=>", "session", "(", "'visitor_id'", ")", "]", ")", ";", "}", "else", "{", "$", "cart", "=", "call_user_func", "(", "Config", "::", "get", "(", "'shop.cart'", ")", ".", "'::create'", ",", "[", "'session_id'", "=>", "session", "(", "'visitor_id'", ")", "]", ")", ";", "}", "}", "return", "$", "cart", ";", "}" ]
Scope to current user cart and returns class model. @param \Illuminate\Database\Eloquent\Builder $query Query. @return this
[ "Scope", "to", "current", "user", "cart", "and", "returns", "class", "model", "." ]
9d191b7d17395bd875505bfbc0b1077dc6c87869
https://github.com/webfactorybulgaria/laravel-shop/blob/9d191b7d17395bd875505bfbc0b1077dc6c87869/src/Traits/ShopCartTrait.php#L283-L300
232,922
mpratt/RelativeTime
Lib/RelativeTime/Languages/LanguageAdapter.php
LanguageAdapter.offsetGet
public function offsetGet($id) { if (!array_key_exists($id, $this->strings)) { throw new InvalidArgumentException($id . ' is not defined'); } return $this->strings[$id]; }
php
public function offsetGet($id) { if (!array_key_exists($id, $this->strings)) { throw new InvalidArgumentException($id . ' is not defined'); } return $this->strings[$id]; }
[ "public", "function", "offsetGet", "(", "$", "id", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "strings", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "$", "id", ".", "' is not defined'", ")", ";", "}", "return", "$", "this", "->", "strings", "[", "$", "id", "]", ";", "}" ]
Gets a parameter @param string $id @return string @throws InvalidArgumentException if the id is not defined
[ "Gets", "a", "parameter" ]
cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5
https://github.com/mpratt/RelativeTime/blob/cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5/Lib/RelativeTime/Languages/LanguageAdapter.php#L47-L54
232,923
CottaCush/phalcon-user-auth
src/Models/UserPasswordChange.php
UserPasswordChange.validateNewPassword
public static function validateNewPassword($userId, $newPassword, $max = self::MAX_PASSWORD_CHANGES_BEFORE_REUSE) { $recentPasswords = UserPasswordChange::query() ->where("user_id = :user_id:") ->bind(["user_id" => $userId]) ->orderBy("date_changed DESC") ->limit($max - 1) ->execute() ->toArray(); foreach ($recentPasswords as $aRecentPassword) { if (Utils::verifyPassword($newPassword, $aRecentPassword['password_hash'])) { throw new PasswordChangeException("You cannot use any of your last {$max} passwords"); } } }
php
public static function validateNewPassword($userId, $newPassword, $max = self::MAX_PASSWORD_CHANGES_BEFORE_REUSE) { $recentPasswords = UserPasswordChange::query() ->where("user_id = :user_id:") ->bind(["user_id" => $userId]) ->orderBy("date_changed DESC") ->limit($max - 1) ->execute() ->toArray(); foreach ($recentPasswords as $aRecentPassword) { if (Utils::verifyPassword($newPassword, $aRecentPassword['password_hash'])) { throw new PasswordChangeException("You cannot use any of your last {$max} passwords"); } } }
[ "public", "static", "function", "validateNewPassword", "(", "$", "userId", ",", "$", "newPassword", ",", "$", "max", "=", "self", "::", "MAX_PASSWORD_CHANGES_BEFORE_REUSE", ")", "{", "$", "recentPasswords", "=", "UserPasswordChange", "::", "query", "(", ")", "->", "where", "(", "\"user_id = :user_id:\"", ")", "->", "bind", "(", "[", "\"user_id\"", "=>", "$", "userId", "]", ")", "->", "orderBy", "(", "\"date_changed DESC\"", ")", "->", "limit", "(", "$", "max", "-", "1", ")", "->", "execute", "(", ")", "->", "toArray", "(", ")", ";", "foreach", "(", "$", "recentPasswords", "as", "$", "aRecentPassword", ")", "{", "if", "(", "Utils", "::", "verifyPassword", "(", "$", "newPassword", ",", "$", "aRecentPassword", "[", "'password_hash'", "]", ")", ")", "{", "throw", "new", "PasswordChangeException", "(", "\"You cannot use any of your last {$max} passwords\"", ")", ";", "}", "}", "}" ]
check if the new password does not correspond to the previous max passwords We use max-1 in the query because we are assuming that the user's current password is inclusive of the last max passwords used and this has already been checked above @param int $userId @param string $newPassword @param int $max @throws PasswordChangeException
[ "check", "if", "the", "new", "password", "does", "not", "correspond", "to", "the", "previous", "max", "passwords", "We", "use", "max", "-", "1", "in", "the", "query", "because", "we", "are", "assuming", "that", "the", "user", "s", "current", "password", "is", "inclusive", "of", "the", "last", "max", "passwords", "used", "and", "this", "has", "already", "been", "checked", "above" ]
89c8a1ae5e6f712591ba66bc2dd5e8a9f73b9d54
https://github.com/CottaCush/phalcon-user-auth/blob/89c8a1ae5e6f712591ba66bc2dd5e8a9f73b9d54/src/Models/UserPasswordChange.php#L123-L138
232,924
asinfotrack/yii2-toolbox
components/MemoryUrlManager.php
MemoryUrlManager.isMemoryRelevant
protected function isMemoryRelevant($memoryPath=null) { if ($memoryPath === null) $memoryPath = $this->getCurrentMemoryPath(); //check if there is an array matching the given path $arr = $this->memoryMap; foreach ($memoryPath as $part) { if (!isset($arr[$part])) return false; $arr = $arr[$part]; } return true; }
php
protected function isMemoryRelevant($memoryPath=null) { if ($memoryPath === null) $memoryPath = $this->getCurrentMemoryPath(); //check if there is an array matching the given path $arr = $this->memoryMap; foreach ($memoryPath as $part) { if (!isset($arr[$part])) return false; $arr = $arr[$part]; } return true; }
[ "protected", "function", "isMemoryRelevant", "(", "$", "memoryPath", "=", "null", ")", "{", "if", "(", "$", "memoryPath", "===", "null", ")", "$", "memoryPath", "=", "$", "this", "->", "getCurrentMemoryPath", "(", ")", ";", "//check if there is an array matching the given path", "$", "arr", "=", "$", "this", "->", "memoryMap", ";", "foreach", "(", "$", "memoryPath", "as", "$", "part", ")", "{", "if", "(", "!", "isset", "(", "$", "arr", "[", "$", "part", "]", ")", ")", "return", "false", ";", "$", "arr", "=", "$", "arr", "[", "$", "part", "]", ";", "}", "return", "true", ";", "}" ]
Checks whether or not a certain route is memory relevant @param array $memoryPath the memory path parts (eg `['site', 'index']`) @return bool true if relevant
[ "Checks", "whether", "or", "not", "a", "certain", "route", "is", "memory", "relevant" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/components/MemoryUrlManager.php#L123-L135
232,925
asinfotrack/yii2-toolbox
components/MemoryUrlManager.php
MemoryUrlManager.loadRememberedParams
protected function loadRememberedParams(&$params) { //load the data $memoryData = $this->loadMemory($this->getMemoryKey(explode('/', trim($params[0], '/')))); if (empty($memoryData)) return; //add to params foreach ($memoryData as $paramName=>$paramVal) { if (isset($params[$paramName])) continue; $params[$paramName] = $paramVal; } }
php
protected function loadRememberedParams(&$params) { //load the data $memoryData = $this->loadMemory($this->getMemoryKey(explode('/', trim($params[0], '/')))); if (empty($memoryData)) return; //add to params foreach ($memoryData as $paramName=>$paramVal) { if (isset($params[$paramName])) continue; $params[$paramName] = $paramVal; } }
[ "protected", "function", "loadRememberedParams", "(", "&", "$", "params", ")", "{", "//load the data", "$", "memoryData", "=", "$", "this", "->", "loadMemory", "(", "$", "this", "->", "getMemoryKey", "(", "explode", "(", "'/'", ",", "trim", "(", "$", "params", "[", "0", "]", ",", "'/'", ")", ")", ")", ")", ";", "if", "(", "empty", "(", "$", "memoryData", ")", ")", "return", ";", "//add to params", "foreach", "(", "$", "memoryData", "as", "$", "paramName", "=>", "$", "paramVal", ")", "{", "if", "(", "isset", "(", "$", "params", "[", "$", "paramName", "]", ")", ")", "continue", ";", "$", "params", "[", "$", "paramName", "]", "=", "$", "paramVal", ";", "}", "}" ]
This method is responsible for loading the params from memory storage. Params are simply added to the params provided when calling `createUrl`. If a param is already defined it has precedence over the loaded value. @param array $params the params array as provided by `createUrl`
[ "This", "method", "is", "responsible", "for", "loading", "the", "params", "from", "memory", "storage", ".", "Params", "are", "simply", "added", "to", "the", "params", "provided", "when", "calling", "createUrl", ".", "If", "a", "param", "is", "already", "defined", "it", "has", "precedence", "over", "the", "loaded", "value", "." ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/components/MemoryUrlManager.php#L144-L155
232,926
asinfotrack/yii2-toolbox
components/MemoryUrlManager.php
MemoryUrlManager.saveRememberedParams
protected function saveRememberedParams() { $queryParams = Yii::$app->request->queryParams; if (empty($queryParams)) return; //prepare data array $memoryData = []; //fetch rules $arr = $this->memoryMap; foreach ($this->getCurrentMemoryPath() as $part) { if (!isset($arr[$part])) return; $arr = $arr[$part]; } //iterate over params foreach ($queryParams as $paramName=>$paramVal) { foreach ($arr as $key=>$val) { $rule = $val instanceof \Closure ? $key : $val; $callback = $val instanceof \Closure ? $val : null; //check callback if set if ($callback !== null) { if (!call_user_func($callback)) continue; } //fix incorrect specified rules for regex comparison if ($rule[0] !== '/') $rule = '/' . $rule; if ($rule[strlen($rule) - 1] !== '/') $rule = $rule . '/'; //match the rules if (preg_match($rule, $paramName) !== 0) { $memoryData[$paramName] = $paramVal; break; } } } //save the data $this->saveMemory($this->getMemoryKey(), $memoryData); }
php
protected function saveRememberedParams() { $queryParams = Yii::$app->request->queryParams; if (empty($queryParams)) return; //prepare data array $memoryData = []; //fetch rules $arr = $this->memoryMap; foreach ($this->getCurrentMemoryPath() as $part) { if (!isset($arr[$part])) return; $arr = $arr[$part]; } //iterate over params foreach ($queryParams as $paramName=>$paramVal) { foreach ($arr as $key=>$val) { $rule = $val instanceof \Closure ? $key : $val; $callback = $val instanceof \Closure ? $val : null; //check callback if set if ($callback !== null) { if (!call_user_func($callback)) continue; } //fix incorrect specified rules for regex comparison if ($rule[0] !== '/') $rule = '/' . $rule; if ($rule[strlen($rule) - 1] !== '/') $rule = $rule . '/'; //match the rules if (preg_match($rule, $paramName) !== 0) { $memoryData[$paramName] = $paramVal; break; } } } //save the data $this->saveMemory($this->getMemoryKey(), $memoryData); }
[ "protected", "function", "saveRememberedParams", "(", ")", "{", "$", "queryParams", "=", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", ";", "if", "(", "empty", "(", "$", "queryParams", ")", ")", "return", ";", "//prepare data array", "$", "memoryData", "=", "[", "]", ";", "//fetch rules", "$", "arr", "=", "$", "this", "->", "memoryMap", ";", "foreach", "(", "$", "this", "->", "getCurrentMemoryPath", "(", ")", "as", "$", "part", ")", "{", "if", "(", "!", "isset", "(", "$", "arr", "[", "$", "part", "]", ")", ")", "return", ";", "$", "arr", "=", "$", "arr", "[", "$", "part", "]", ";", "}", "//iterate over params", "foreach", "(", "$", "queryParams", "as", "$", "paramName", "=>", "$", "paramVal", ")", "{", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "rule", "=", "$", "val", "instanceof", "\\", "Closure", "?", "$", "key", ":", "$", "val", ";", "$", "callback", "=", "$", "val", "instanceof", "\\", "Closure", "?", "$", "val", ":", "null", ";", "//check callback if set", "if", "(", "$", "callback", "!==", "null", ")", "{", "if", "(", "!", "call_user_func", "(", "$", "callback", ")", ")", "continue", ";", "}", "//fix incorrect specified rules for regex comparison", "if", "(", "$", "rule", "[", "0", "]", "!==", "'/'", ")", "$", "rule", "=", "'/'", ".", "$", "rule", ";", "if", "(", "$", "rule", "[", "strlen", "(", "$", "rule", ")", "-", "1", "]", "!==", "'/'", ")", "$", "rule", "=", "$", "rule", ".", "'/'", ";", "//match the rules", "if", "(", "preg_match", "(", "$", "rule", ",", "$", "paramName", ")", "!==", "0", ")", "{", "$", "memoryData", "[", "$", "paramName", "]", "=", "$", "paramVal", ";", "break", ";", "}", "}", "}", "//save the data", "$", "this", "->", "saveMemory", "(", "$", "this", "->", "getMemoryKey", "(", ")", ",", "$", "memoryData", ")", ";", "}" ]
This method is responsible for saving the params to be remembered. It does it by comparing to the rules defined in `memoryMap`.
[ "This", "method", "is", "responsible", "for", "saving", "the", "params", "to", "be", "remembered", ".", "It", "does", "it", "by", "comparing", "to", "the", "rules", "defined", "in", "memoryMap", "." ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/components/MemoryUrlManager.php#L161-L201
232,927
asinfotrack/yii2-toolbox
components/MemoryUrlManager.php
MemoryUrlManager.getMemoryKey
protected function getMemoryKey($parts=null) { return $this->memorySessionPrefix . implode('-', $parts !== null ? $parts : $this->getCurrentMemoryPath()); }
php
protected function getMemoryKey($parts=null) { return $this->memorySessionPrefix . implode('-', $parts !== null ? $parts : $this->getCurrentMemoryPath()); }
[ "protected", "function", "getMemoryKey", "(", "$", "parts", "=", "null", ")", "{", "return", "$", "this", "->", "memorySessionPrefix", ".", "implode", "(", "'-'", ",", "$", "parts", "!==", "null", "?", "$", "parts", ":", "$", "this", "->", "getCurrentMemoryPath", "(", ")", ")", ";", "}" ]
Generates the key to identify the storage slot in use. Override this to generate your own storage-keys. @param array $parts optional specific parts (defaults to current request parts) @return string the key
[ "Generates", "the", "key", "to", "identify", "the", "storage", "slot", "in", "use", ".", "Override", "this", "to", "generate", "your", "own", "storage", "-", "keys", "." ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/components/MemoryUrlManager.php#L210-L213
232,928
SocialEngine/sniffer-rules
src/SocialEngine/SnifferRules/Standard/SocialEngine/Sniffs/Methods/MethodNameSniff.php
SocialEngine_Sniffs_Methods_MethodNameSniff.checkClassHasValidSuffix
private function checkClassHasValidSuffix($className, $classSuffix = null) { if ($classSuffix === '*') { return true; } $classSuffixPos = strrpos($className, $classSuffix); return $classSuffixPos === (strlen($className) - strlen($classSuffix)); }
php
private function checkClassHasValidSuffix($className, $classSuffix = null) { if ($classSuffix === '*') { return true; } $classSuffixPos = strrpos($className, $classSuffix); return $classSuffixPos === (strlen($className) - strlen($classSuffix)); }
[ "private", "function", "checkClassHasValidSuffix", "(", "$", "className", ",", "$", "classSuffix", "=", "null", ")", "{", "if", "(", "$", "classSuffix", "===", "'*'", ")", "{", "return", "true", ";", "}", "$", "classSuffixPos", "=", "strrpos", "(", "$", "className", ",", "$", "classSuffix", ")", ";", "return", "$", "classSuffixPos", "===", "(", "strlen", "(", "$", "className", ")", "-", "strlen", "(", "$", "classSuffix", ")", ")", ";", "}" ]
Returns true if the specified class suffix is in the class name. @param string $className @param string $classSuffix @return boolean
[ "Returns", "true", "if", "the", "specified", "class", "suffix", "is", "in", "the", "class", "name", "." ]
b7cabe03277440f2eb9c5243179f0521f161f7c6
https://github.com/SocialEngine/sniffer-rules/blob/b7cabe03277440f2eb9c5243179f0521f161f7c6/src/SocialEngine/SnifferRules/Standard/SocialEngine/Sniffs/Methods/MethodNameSniff.php#L98-L105
232,929
SocialEngine/sniffer-rules
src/SocialEngine/SnifferRules/Standard/SocialEngine/Sniffs/Methods/MethodNameSniff.php
SocialEngine_Sniffs_Methods_MethodNameSniff.checkMethodHasValidPrefix
private function checkMethodHasValidPrefix($methodName, $methodPrefix = []) { if (in_array('*', $methodPrefix)) { return true; } foreach ($methodPrefix as $prefix) { if (strpos($methodName, $prefix) === 0) { return true; } } }
php
private function checkMethodHasValidPrefix($methodName, $methodPrefix = []) { if (in_array('*', $methodPrefix)) { return true; } foreach ($methodPrefix as $prefix) { if (strpos($methodName, $prefix) === 0) { return true; } } }
[ "private", "function", "checkMethodHasValidPrefix", "(", "$", "methodName", ",", "$", "methodPrefix", "=", "[", "]", ")", "{", "if", "(", "in_array", "(", "'*'", ",", "$", "methodPrefix", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "methodPrefix", "as", "$", "prefix", ")", "{", "if", "(", "strpos", "(", "$", "methodName", ",", "$", "prefix", ")", "===", "0", ")", "{", "return", "true", ";", "}", "}", "}" ]
Returns true if the specified method prefix is in the method name. @param string $methodName @param string $methodPrefix @return boolean
[ "Returns", "true", "if", "the", "specified", "method", "prefix", "is", "in", "the", "method", "name", "." ]
b7cabe03277440f2eb9c5243179f0521f161f7c6
https://github.com/SocialEngine/sniffer-rules/blob/b7cabe03277440f2eb9c5243179f0521f161f7c6/src/SocialEngine/SnifferRules/Standard/SocialEngine/Sniffs/Methods/MethodNameSniff.php#L115-L125
232,930
tedslittlerobot/html-table-builder
src/Elements/Traits/Classable.php
Classable.classes
public function classes(array $classes) : Element { $this->classes = array_merge($this->classes, $classes); return $this; }
php
public function classes(array $classes) : Element { $this->classes = array_merge($this->classes, $classes); return $this; }
[ "public", "function", "classes", "(", "array", "$", "classes", ")", ":", "Element", "{", "$", "this", "->", "classes", "=", "array_merge", "(", "$", "this", "->", "classes", ",", "$", "classes", ")", ";", "return", "$", "this", ";", "}" ]
Add several classes @param string $class @return $this
[ "Add", "several", "classes" ]
12597f8c44dde9f002c74b0aeadefec2bdb2eafa
https://github.com/tedslittlerobot/html-table-builder/blob/12597f8c44dde9f002c74b0aeadefec2bdb2eafa/src/Elements/Traits/Classable.php#L34-L39
232,931
affilinet/productdata-php-sdk
src/Affilinet/ProductData/Responses/ResponseElements/FacetValue.php
FacetValue.generateSerializedProductsRequest
public function generateSerializedProductsRequest(ProductsRequestInterface $request) { $newRequest = clone $request; switch ($this->getFacet()->getName()) { case 'ShopName': case 'ProgramId': // There is no valid filter Query for these facets, add debug log $request->getAffilinetClient() ->getLog() ->addDebug( 'You can not filter SearchProducts with ' . $this->getFacet()->getName() . ' Seems like you used this facet and tried to generate a Link or a ProductsRequest for this facets\' results.' ); break; case 'ShopId': $newRequest->onlyFromShopIds([$this->getValue()]); break; case 'ShopCategoryId': $newRequest->onlyFromCategories([$this->getValue()], false, false); break; case 'AffilinetCategoryId': $newRequest->onlyFromCategories([$this->getValue()]); break; default : $newRequest->addFilterQuery($this->getFacet()->getName(), $this->getValue()); } return $newRequest->serialize(); }
php
public function generateSerializedProductsRequest(ProductsRequestInterface $request) { $newRequest = clone $request; switch ($this->getFacet()->getName()) { case 'ShopName': case 'ProgramId': // There is no valid filter Query for these facets, add debug log $request->getAffilinetClient() ->getLog() ->addDebug( 'You can not filter SearchProducts with ' . $this->getFacet()->getName() . ' Seems like you used this facet and tried to generate a Link or a ProductsRequest for this facets\' results.' ); break; case 'ShopId': $newRequest->onlyFromShopIds([$this->getValue()]); break; case 'ShopCategoryId': $newRequest->onlyFromCategories([$this->getValue()], false, false); break; case 'AffilinetCategoryId': $newRequest->onlyFromCategories([$this->getValue()]); break; default : $newRequest->addFilterQuery($this->getFacet()->getName(), $this->getValue()); } return $newRequest->serialize(); }
[ "public", "function", "generateSerializedProductsRequest", "(", "ProductsRequestInterface", "$", "request", ")", "{", "$", "newRequest", "=", "clone", "$", "request", ";", "switch", "(", "$", "this", "->", "getFacet", "(", ")", "->", "getName", "(", ")", ")", "{", "case", "'ShopName'", ":", "case", "'ProgramId'", ":", "// There is no valid filter Query for these facets, add debug log", "$", "request", "->", "getAffilinetClient", "(", ")", "->", "getLog", "(", ")", "->", "addDebug", "(", "'You can not filter SearchProducts with '", ".", "$", "this", "->", "getFacet", "(", ")", "->", "getName", "(", ")", ".", "' Seems like you used this facet and tried to generate a Link or a ProductsRequest for this facets\\' results.'", ")", ";", "break", ";", "case", "'ShopId'", ":", "$", "newRequest", "->", "onlyFromShopIds", "(", "[", "$", "this", "->", "getValue", "(", ")", "]", ")", ";", "break", ";", "case", "'ShopCategoryId'", ":", "$", "newRequest", "->", "onlyFromCategories", "(", "[", "$", "this", "->", "getValue", "(", ")", "]", ",", "false", ",", "false", ")", ";", "break", ";", "case", "'AffilinetCategoryId'", ":", "$", "newRequest", "->", "onlyFromCategories", "(", "[", "$", "this", "->", "getValue", "(", ")", "]", ")", ";", "break", ";", "default", ":", "$", "newRequest", "->", "addFilterQuery", "(", "$", "this", "->", "getFacet", "(", ")", "->", "getName", "(", ")", ",", "$", "this", "->", "getValue", "(", ")", ")", ";", "}", "return", "$", "newRequest", "->", "serialize", "(", ")", ";", "}" ]
Returns the serialized ProductsRequest to retrieve the results behind this facet value @param ProductsRequestInterface $request @return string
[ "Returns", "the", "serialized", "ProductsRequest", "to", "retrieve", "the", "results", "behind", "this", "facet", "value" ]
fd3979a5b4531ea2140b4202651eca56bab98229
https://github.com/affilinet/productdata-php-sdk/blob/fd3979a5b4531ea2140b4202651eca56bab98229/src/Affilinet/ProductData/Responses/ResponseElements/FacetValue.php#L104-L141
232,932
dmitriybelyy/yii2-cassandra-cql
phpcassa/Connection/ConnectionPool.php
ConnectionPool.get
public function get() { $num_conns = count($this->queue); if ($num_conns < $this->pool_size) { try { $this->make_conn(); } catch (NoServerAvailable $e) { if ($num_conns == 0) throw $e; } } return array_shift($this->queue); }
php
public function get() { $num_conns = count($this->queue); if ($num_conns < $this->pool_size) { try { $this->make_conn(); } catch (NoServerAvailable $e) { if ($num_conns == 0) throw $e; } } return array_shift($this->queue); }
[ "public", "function", "get", "(", ")", "{", "$", "num_conns", "=", "count", "(", "$", "this", "->", "queue", ")", ";", "if", "(", "$", "num_conns", "<", "$", "this", "->", "pool_size", ")", "{", "try", "{", "$", "this", "->", "make_conn", "(", ")", ";", "}", "catch", "(", "NoServerAvailable", "$", "e", ")", "{", "if", "(", "$", "num_conns", "==", "0", ")", "throw", "$", "e", ";", "}", "}", "return", "array_shift", "(", "$", "this", "->", "queue", ")", ";", "}" ]
Retrieves a connection from the pool. If the pool has fewer than $pool_size connections in it, a new connection will be created. @return ConnectionWrapper a connection
[ "Retrieves", "a", "connection", "from", "the", "pool", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/Connection/ConnectionPool.php#L162-L173
232,933
dmitriybelyy/yii2-cassandra-cql
phpcassa/Connection/ConnectionPool.php
ConnectionPool.return_connection
public function return_connection($connection) { if ($connection->op_count >= $this->recycle) { $this->stats['recycled'] += 1; $connection->close(); $this->make_conn(); $connection = $this->get(); } array_push($this->queue, $connection); }
php
public function return_connection($connection) { if ($connection->op_count >= $this->recycle) { $this->stats['recycled'] += 1; $connection->close(); $this->make_conn(); $connection = $this->get(); } array_push($this->queue, $connection); }
[ "public", "function", "return_connection", "(", "$", "connection", ")", "{", "if", "(", "$", "connection", "->", "op_count", ">=", "$", "this", "->", "recycle", ")", "{", "$", "this", "->", "stats", "[", "'recycled'", "]", "+=", "1", ";", "$", "connection", "->", "close", "(", ")", ";", "$", "this", "->", "make_conn", "(", ")", ";", "$", "connection", "=", "$", "this", "->", "get", "(", ")", ";", "}", "array_push", "(", "$", "this", "->", "queue", ",", "$", "connection", ")", ";", "}" ]
Returns a connection to the pool. @param ConnectionWrapper $connection
[ "Returns", "a", "connection", "to", "the", "pool", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/Connection/ConnectionPool.php#L179-L187
232,934
dmitriybelyy/yii2-cassandra-cql
phpcassa/Connection/ConnectionPool.php
ConnectionPool.describe_keyspace
public function describe_keyspace() { if (NULL === $this->keyspace_description) { $this->keyspace_description = $this->call("describe_keyspace", $this->keyspace); } return $this->keyspace_description; }
php
public function describe_keyspace() { if (NULL === $this->keyspace_description) { $this->keyspace_description = $this->call("describe_keyspace", $this->keyspace); } return $this->keyspace_description; }
[ "public", "function", "describe_keyspace", "(", ")", "{", "if", "(", "NULL", "===", "$", "this", "->", "keyspace_description", ")", "{", "$", "this", "->", "keyspace_description", "=", "$", "this", "->", "call", "(", "\"describe_keyspace\"", ",", "$", "this", "->", "keyspace", ")", ";", "}", "return", "$", "this", "->", "keyspace_description", ";", "}" ]
Gets the keyspace description, caching the results for later lookups. @return mixed
[ "Gets", "the", "keyspace", "description", "caching", "the", "results", "for", "later", "lookups", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/Connection/ConnectionPool.php#L193-L199
232,935
dmitriybelyy/yii2-cassandra-cql
phpcassa/Connection/ConnectionPool.php
ConnectionPool.call
public function call() { $args = func_get_args(); // Get all of the args passed to this function $f = array_shift($args); // pull the function from the beginning $retry_count = 0; if ($this->max_retries == -1) $tries = self::MAX_RETRIES; elseif ($this->max_retries == 0) $tries = 1; else $tries = $this->max_retries + 1; foreach (range(1, $tries) as $retry_count) { $conn = $this->get(); $conn->op_count += 1; try { $resp = call_user_func_array(array($conn->client, $f), $args); $this->return_connection($conn); return $resp; } catch (NotFoundException $nfe) { $this->return_connection($conn); throw $nfe; } catch (TimedOutException $toe) { $last_err = $toe; $this->handle_conn_failure($conn, $f, $toe, $retry_count); } catch (UnavailableException $ue) { $last_err = $ue; $this->handle_conn_failure($conn, $f, $ue, $retry_count); } catch (TTransportException $tte) { $last_err = $tte; $this->handle_conn_failure($conn, $f, $tte, $retry_count); } catch (\Exception $e) { $this->handle_conn_failure($conn, $f, $e, $retry_count); throw $e; } } throw new MaxRetriesException("An attempt to execute $f failed $tries times.". " The last error was " . get_class($last_err) . ":" . $last_err->getMessage()); }
php
public function call() { $args = func_get_args(); // Get all of the args passed to this function $f = array_shift($args); // pull the function from the beginning $retry_count = 0; if ($this->max_retries == -1) $tries = self::MAX_RETRIES; elseif ($this->max_retries == 0) $tries = 1; else $tries = $this->max_retries + 1; foreach (range(1, $tries) as $retry_count) { $conn = $this->get(); $conn->op_count += 1; try { $resp = call_user_func_array(array($conn->client, $f), $args); $this->return_connection($conn); return $resp; } catch (NotFoundException $nfe) { $this->return_connection($conn); throw $nfe; } catch (TimedOutException $toe) { $last_err = $toe; $this->handle_conn_failure($conn, $f, $toe, $retry_count); } catch (UnavailableException $ue) { $last_err = $ue; $this->handle_conn_failure($conn, $f, $ue, $retry_count); } catch (TTransportException $tte) { $last_err = $tte; $this->handle_conn_failure($conn, $f, $tte, $retry_count); } catch (\Exception $e) { $this->handle_conn_failure($conn, $f, $e, $retry_count); throw $e; } } throw new MaxRetriesException("An attempt to execute $f failed $tries times.". " The last error was " . get_class($last_err) . ":" . $last_err->getMessage()); }
[ "public", "function", "call", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "// Get all of the args passed to this function", "$", "f", "=", "array_shift", "(", "$", "args", ")", ";", "// pull the function from the beginning", "$", "retry_count", "=", "0", ";", "if", "(", "$", "this", "->", "max_retries", "==", "-", "1", ")", "$", "tries", "=", "self", "::", "MAX_RETRIES", ";", "elseif", "(", "$", "this", "->", "max_retries", "==", "0", ")", "$", "tries", "=", "1", ";", "else", "$", "tries", "=", "$", "this", "->", "max_retries", "+", "1", ";", "foreach", "(", "range", "(", "1", ",", "$", "tries", ")", "as", "$", "retry_count", ")", "{", "$", "conn", "=", "$", "this", "->", "get", "(", ")", ";", "$", "conn", "->", "op_count", "+=", "1", ";", "try", "{", "$", "resp", "=", "call_user_func_array", "(", "array", "(", "$", "conn", "->", "client", ",", "$", "f", ")", ",", "$", "args", ")", ";", "$", "this", "->", "return_connection", "(", "$", "conn", ")", ";", "return", "$", "resp", ";", "}", "catch", "(", "NotFoundException", "$", "nfe", ")", "{", "$", "this", "->", "return_connection", "(", "$", "conn", ")", ";", "throw", "$", "nfe", ";", "}", "catch", "(", "TimedOutException", "$", "toe", ")", "{", "$", "last_err", "=", "$", "toe", ";", "$", "this", "->", "handle_conn_failure", "(", "$", "conn", ",", "$", "f", ",", "$", "toe", ",", "$", "retry_count", ")", ";", "}", "catch", "(", "UnavailableException", "$", "ue", ")", "{", "$", "last_err", "=", "$", "ue", ";", "$", "this", "->", "handle_conn_failure", "(", "$", "conn", ",", "$", "f", ",", "$", "ue", ",", "$", "retry_count", ")", ";", "}", "catch", "(", "TTransportException", "$", "tte", ")", "{", "$", "last_err", "=", "$", "tte", ";", "$", "this", "->", "handle_conn_failure", "(", "$", "conn", ",", "$", "f", ",", "$", "tte", ",", "$", "retry_count", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "handle_conn_failure", "(", "$", "conn", ",", "$", "f", ",", "$", "e", ",", "$", "retry_count", ")", ";", "throw", "$", "e", ";", "}", "}", "throw", "new", "MaxRetriesException", "(", "\"An attempt to execute $f failed $tries times.\"", ".", "\" The last error was \"", ".", "get_class", "(", "$", "last_err", ")", ".", "\":\"", ".", "$", "last_err", "->", "getMessage", "(", ")", ")", ";", "}" ]
Performs a Thrift operation using a connection from the pool. The first argument should be the name of the function. The following arguments should be the arguments for that Thrift function. If the connect fails with any exception other than a NotFoundException, the connection will be closed and replaced in the pool. If the Exception is suitable for retrying the operation (TimedOutException, UnavailableException, TTransportException), the operation will be retried with a new connection after an exponentially increasing backoff is performed. To avoid automatic retries, create a ConnectionPool with the $max_retries argument set to 0. In general, this method should *not* be used by users of the library. It is primarily intended for internal use, but is left exposed as an open workaround if needed. @return mixed
[ "Performs", "a", "Thrift", "operation", "using", "a", "connection", "from", "the", "pool", ".", "The", "first", "argument", "should", "be", "the", "name", "of", "the", "function", ".", "The", "following", "arguments", "should", "be", "the", "arguments", "for", "that", "Thrift", "function", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/Connection/ConnectionPool.php#L247-L286
232,936
silverstripe-archive/deploynaut
code/backends/SimplePackageGenerator.php
SimplePackageGenerator.generatePackage
public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) { $tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename)); if(!file_exists($tempPath)) mkdir($tempPath); // Execute these in sequence until there's a failure $processes = array( // Export the relevant SHA into a temp folder new Process("git archive $sha | tar -x -C " . escapeshellarg($tempPath), $baseDir), // Run build script new Process($this->buildScript, $tempPath, null, null, 3600), // Compress the result new Process("tar -czf " . escapeshellarg($outputFilename) . " " . escapeshellarg(basename($tempPath)), dirname($tempPath)), ); // Call at the end, regardless of success or failure $cleanup = array( // Delete the temporary staging folder new Process("rm -rf " . escapeshellarg($tempPath)), ); try { $this->executeProcesses($processes, $log); } catch(Exception $e) { // Execute cleanup on failure $this->executeProcesses($cleanup, $log); throw $e; } // Execute cleanup on success $this->executeProcesses($cleanup, $log); return true; }
php
public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) { $tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename)); if(!file_exists($tempPath)) mkdir($tempPath); // Execute these in sequence until there's a failure $processes = array( // Export the relevant SHA into a temp folder new Process("git archive $sha | tar -x -C " . escapeshellarg($tempPath), $baseDir), // Run build script new Process($this->buildScript, $tempPath, null, null, 3600), // Compress the result new Process("tar -czf " . escapeshellarg($outputFilename) . " " . escapeshellarg(basename($tempPath)), dirname($tempPath)), ); // Call at the end, regardless of success or failure $cleanup = array( // Delete the temporary staging folder new Process("rm -rf " . escapeshellarg($tempPath)), ); try { $this->executeProcesses($processes, $log); } catch(Exception $e) { // Execute cleanup on failure $this->executeProcesses($cleanup, $log); throw $e; } // Execute cleanup on success $this->executeProcesses($cleanup, $log); return true; }
[ "public", "function", "generatePackage", "(", "$", "sha", ",", "$", "baseDir", ",", "$", "outputFilename", ",", "DeploynautLogFile", "$", "log", ")", "{", "$", "tempPath", "=", "TEMP_FOLDER", ".", "\"/\"", ".", "str_replace", "(", "\".tar.gz\"", ",", "\"\"", ",", "basename", "(", "$", "outputFilename", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "tempPath", ")", ")", "mkdir", "(", "$", "tempPath", ")", ";", "// Execute these in sequence until there's a failure", "$", "processes", "=", "array", "(", "// Export the relevant SHA into a temp folder", "new", "Process", "(", "\"git archive $sha | tar -x -C \"", ".", "escapeshellarg", "(", "$", "tempPath", ")", ",", "$", "baseDir", ")", ",", "// Run build script", "new", "Process", "(", "$", "this", "->", "buildScript", ",", "$", "tempPath", ",", "null", ",", "null", ",", "3600", ")", ",", "// Compress the result", "new", "Process", "(", "\"tar -czf \"", ".", "escapeshellarg", "(", "$", "outputFilename", ")", ".", "\" \"", ".", "escapeshellarg", "(", "basename", "(", "$", "tempPath", ")", ")", ",", "dirname", "(", "$", "tempPath", ")", ")", ",", ")", ";", "// Call at the end, regardless of success or failure", "$", "cleanup", "=", "array", "(", "// Delete the temporary staging folder", "new", "Process", "(", "\"rm -rf \"", ".", "escapeshellarg", "(", "$", "tempPath", ")", ")", ",", ")", ";", "try", "{", "$", "this", "->", "executeProcesses", "(", "$", "processes", ",", "$", "log", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "// Execute cleanup on failure", "$", "this", "->", "executeProcesses", "(", "$", "cleanup", ",", "$", "log", ")", ";", "throw", "$", "e", ";", "}", "// Execute cleanup on success", "$", "this", "->", "executeProcesses", "(", "$", "cleanup", ",", "$", "log", ")", ";", "return", "true", ";", "}" ]
Generate the package
[ "Generate", "the", "package" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/backends/SimplePackageGenerator.php#L34-L65
232,937
silverstripe-archive/deploynaut
code/backends/SimplePackageGenerator.php
SimplePackageGenerator.executeProcesses
protected function executeProcesses($processes, DeploynautLogFile $log) { foreach($processes as $process) { $process->mustRun(function ($type, $buffer) use($log) { $log->write($buffer); }); } }
php
protected function executeProcesses($processes, DeploynautLogFile $log) { foreach($processes as $process) { $process->mustRun(function ($type, $buffer) use($log) { $log->write($buffer); }); } }
[ "protected", "function", "executeProcesses", "(", "$", "processes", ",", "DeploynautLogFile", "$", "log", ")", "{", "foreach", "(", "$", "processes", "as", "$", "process", ")", "{", "$", "process", "->", "mustRun", "(", "function", "(", "$", "type", ",", "$", "buffer", ")", "use", "(", "$", "log", ")", "{", "$", "log", "->", "write", "(", "$", "buffer", ")", ";", "}", ")", ";", "}", "}" ]
Execute an array of processes, one after the other, throwing an exception on the first failure. @param array $processes An array of Symfony\Component\Process\Process objects @param DeploynautLogFile $log The log to send output to
[ "Execute", "an", "array", "of", "processes", "one", "after", "the", "other", "throwing", "an", "exception", "on", "the", "first", "failure", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/backends/SimplePackageGenerator.php#L73-L79
232,938
asinfotrack/yii2-toolbox
widgets/grid/AdvancedDataColumn.php
AdvancedDataColumn.applyColumnWidths
private function applyColumnWidths() { $styles = []; if (!empty($this->columnWidth)) $styles['width'] = $this->prepareWidthStyleValue($this->columnWidth); if (!empty($this->minColumnWidth)) $styles['min-width'] = $this->prepareWidthStyleValue($this->minColumnWidth); if (!empty($this->maxColumnWidth)) $styles['max-width'] = $this->prepareWidthStyleValue($this->maxColumnWidth); Html::addCssStyle($this->options, $styles, true); }
php
private function applyColumnWidths() { $styles = []; if (!empty($this->columnWidth)) $styles['width'] = $this->prepareWidthStyleValue($this->columnWidth); if (!empty($this->minColumnWidth)) $styles['min-width'] = $this->prepareWidthStyleValue($this->minColumnWidth); if (!empty($this->maxColumnWidth)) $styles['max-width'] = $this->prepareWidthStyleValue($this->maxColumnWidth); Html::addCssStyle($this->options, $styles, true); }
[ "private", "function", "applyColumnWidths", "(", ")", "{", "$", "styles", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "columnWidth", ")", ")", "$", "styles", "[", "'width'", "]", "=", "$", "this", "->", "prepareWidthStyleValue", "(", "$", "this", "->", "columnWidth", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "minColumnWidth", ")", ")", "$", "styles", "[", "'min-width'", "]", "=", "$", "this", "->", "prepareWidthStyleValue", "(", "$", "this", "->", "minColumnWidth", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "maxColumnWidth", ")", ")", "$", "styles", "[", "'max-width'", "]", "=", "$", "this", "->", "prepareWidthStyleValue", "(", "$", "this", "->", "maxColumnWidth", ")", ";", "Html", "::", "addCssStyle", "(", "$", "this", "->", "options", ",", "$", "styles", ",", "true", ")", ";", "}" ]
Applies the column width options. Existing width styles will be overridden.
[ "Applies", "the", "column", "width", "options", ".", "Existing", "width", "styles", "will", "be", "overridden", "." ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/widgets/grid/AdvancedDataColumn.php#L104-L112
232,939
asinfotrack/yii2-toolbox
widgets/grid/AdvancedDataColumn.php
AdvancedDataColumn.applyTextAlignments
private function applyTextAlignments() { //align all has precedence if ($this->textAlignAll != null) { $this->applyTextAlignmentToOptions($this->headerOptions, $this->textAlignAll); $this->applyTextAlignmentToOptions($this->filterOptions, $this->textAlignAll); $this->applyTextAlignmentToOptions($this->filterInputOptions, $this->textAlignAll); $this->applyTextAlignmentToOptions($this->contentOptions, $this->textAlignAll); $this->applyTextAlignmentToOptions($this->footerOptions, $this->textAlignAll); } //individual $this->applyTextAlignmentToOptions($this->headerOptions, $this->textAlignHeader); $this->applyTextAlignmentToOptions($this->filterOptions, $this->textAlignFilter); $this->applyTextAlignmentToOptions($this->filterInputOptions, $this->textAlignFilter); $this->applyTextAlignmentToOptions($this->contentOptions, $this->textAlignContent); $this->applyTextAlignmentToOptions($this->footerOptions, $this->textAlignFooter); }
php
private function applyTextAlignments() { //align all has precedence if ($this->textAlignAll != null) { $this->applyTextAlignmentToOptions($this->headerOptions, $this->textAlignAll); $this->applyTextAlignmentToOptions($this->filterOptions, $this->textAlignAll); $this->applyTextAlignmentToOptions($this->filterInputOptions, $this->textAlignAll); $this->applyTextAlignmentToOptions($this->contentOptions, $this->textAlignAll); $this->applyTextAlignmentToOptions($this->footerOptions, $this->textAlignAll); } //individual $this->applyTextAlignmentToOptions($this->headerOptions, $this->textAlignHeader); $this->applyTextAlignmentToOptions($this->filterOptions, $this->textAlignFilter); $this->applyTextAlignmentToOptions($this->filterInputOptions, $this->textAlignFilter); $this->applyTextAlignmentToOptions($this->contentOptions, $this->textAlignContent); $this->applyTextAlignmentToOptions($this->footerOptions, $this->textAlignFooter); }
[ "private", "function", "applyTextAlignments", "(", ")", "{", "//align all has precedence", "if", "(", "$", "this", "->", "textAlignAll", "!=", "null", ")", "{", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "headerOptions", ",", "$", "this", "->", "textAlignAll", ")", ";", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "filterOptions", ",", "$", "this", "->", "textAlignAll", ")", ";", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "filterInputOptions", ",", "$", "this", "->", "textAlignAll", ")", ";", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "contentOptions", ",", "$", "this", "->", "textAlignAll", ")", ";", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "footerOptions", ",", "$", "this", "->", "textAlignAll", ")", ";", "}", "//individual", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "headerOptions", ",", "$", "this", "->", "textAlignHeader", ")", ";", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "filterOptions", ",", "$", "this", "->", "textAlignFilter", ")", ";", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "filterInputOptions", ",", "$", "this", "->", "textAlignFilter", ")", ";", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "contentOptions", ",", "$", "this", "->", "textAlignContent", ")", ";", "$", "this", "->", "applyTextAlignmentToOptions", "(", "$", "this", "->", "footerOptions", ",", "$", "this", "->", "textAlignFooter", ")", ";", "}" ]
Applies the text alignment to the grid parts
[ "Applies", "the", "text", "alignment", "to", "the", "grid", "parts" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/widgets/grid/AdvancedDataColumn.php#L127-L144
232,940
asinfotrack/yii2-toolbox
widgets/grid/AdvancedDataColumn.php
AdvancedDataColumn.applyTextAlignmentToOptions
private function applyTextAlignmentToOptions(&$options, $alignment) { //catch illegal values if (!in_array($alignment, self::$LEGAL_ALIGNMENTS)) { throw new InvalidConfigException(sprintf('Illegal text alignment value for %s!', self::className())); } //strip already applied classes classes foreach (self::$CSS_CLASSES as $cssClass) Html::removeCssClass($options, $cssClass); //apply actual css class switch ($alignment) { case null: case self::TEXT_LEFT: if ($this->textAlignLeftClass == null) break; Html::addCssClass($options, $this->textAlignLeftClass); break; case self::TEXT_CENTER: if ($this->textAlignCenterClass == null) break; Html::addCssClass($options, $this->textAlignCenterClass); break; case self::TEXT_RIGHT: if ($this->textAlignRightClass == null) break; Html::addCssClass($options, $this->textAlignRightClass); break; } }
php
private function applyTextAlignmentToOptions(&$options, $alignment) { //catch illegal values if (!in_array($alignment, self::$LEGAL_ALIGNMENTS)) { throw new InvalidConfigException(sprintf('Illegal text alignment value for %s!', self::className())); } //strip already applied classes classes foreach (self::$CSS_CLASSES as $cssClass) Html::removeCssClass($options, $cssClass); //apply actual css class switch ($alignment) { case null: case self::TEXT_LEFT: if ($this->textAlignLeftClass == null) break; Html::addCssClass($options, $this->textAlignLeftClass); break; case self::TEXT_CENTER: if ($this->textAlignCenterClass == null) break; Html::addCssClass($options, $this->textAlignCenterClass); break; case self::TEXT_RIGHT: if ($this->textAlignRightClass == null) break; Html::addCssClass($options, $this->textAlignRightClass); break; } }
[ "private", "function", "applyTextAlignmentToOptions", "(", "&", "$", "options", ",", "$", "alignment", ")", "{", "//catch illegal values", "if", "(", "!", "in_array", "(", "$", "alignment", ",", "self", "::", "$", "LEGAL_ALIGNMENTS", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "sprintf", "(", "'Illegal text alignment value for %s!'", ",", "self", "::", "className", "(", ")", ")", ")", ";", "}", "//strip already applied classes classes", "foreach", "(", "self", "::", "$", "CSS_CLASSES", "as", "$", "cssClass", ")", "Html", "::", "removeCssClass", "(", "$", "options", ",", "$", "cssClass", ")", ";", "//apply actual css class", "switch", "(", "$", "alignment", ")", "{", "case", "null", ":", "case", "self", "::", "TEXT_LEFT", ":", "if", "(", "$", "this", "->", "textAlignLeftClass", "==", "null", ")", "break", ";", "Html", "::", "addCssClass", "(", "$", "options", ",", "$", "this", "->", "textAlignLeftClass", ")", ";", "break", ";", "case", "self", "::", "TEXT_CENTER", ":", "if", "(", "$", "this", "->", "textAlignCenterClass", "==", "null", ")", "break", ";", "Html", "::", "addCssClass", "(", "$", "options", ",", "$", "this", "->", "textAlignCenterClass", ")", ";", "break", ";", "case", "self", "::", "TEXT_RIGHT", ":", "if", "(", "$", "this", "->", "textAlignRightClass", "==", "null", ")", "break", ";", "Html", "::", "addCssClass", "(", "$", "options", ",", "$", "this", "->", "textAlignRightClass", ")", ";", "break", ";", "}", "}" ]
Applies the alignment to the options of a certain grid part @param array $options the grid part options @param integer $alignment the alignment constant (@see AdvancedDataColumn::TEXT_%alignment) @throws InvalidConfigException in case of an unknown alignment value
[ "Applies", "the", "alignment", "to", "the", "options", "of", "a", "certain", "grid", "part" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/widgets/grid/AdvancedDataColumn.php#L152-L178
232,941
SocialEngine/sniffer-rules
src/SocialEngine/SnifferRules/Command/SniffCommand.php
SniffCommand.getCliOptions
private function getCliOptions() { $validOptions = []; foreach ($this->getOptions() as $option) { $key = $option[0]; $validOptions[$key] = $this->option($key); } return array_filter($validOptions); }
php
private function getCliOptions() { $validOptions = []; foreach ($this->getOptions() as $option) { $key = $option[0]; $validOptions[$key] = $this->option($key); } return array_filter($validOptions); }
[ "private", "function", "getCliOptions", "(", ")", "{", "$", "validOptions", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOptions", "(", ")", "as", "$", "option", ")", "{", "$", "key", "=", "$", "option", "[", "0", "]", ";", "$", "validOptions", "[", "$", "key", "]", "=", "$", "this", "->", "option", "(", "$", "key", ")", ";", "}", "return", "array_filter", "(", "$", "validOptions", ")", ";", "}" ]
Generates options array from passed in cli options @return array
[ "Generates", "options", "array", "from", "passed", "in", "cli", "options" ]
b7cabe03277440f2eb9c5243179f0521f161f7c6
https://github.com/SocialEngine/sniffer-rules/blob/b7cabe03277440f2eb9c5243179f0521f161f7c6/src/SocialEngine/SnifferRules/Command/SniffCommand.php#L205-L215
232,942
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.Backend
public function Backend() { $backends = array_keys($this->config()->get('allowed_backends', Config::FIRST_SET)); switch(sizeof($backends)) { // Nothing allowed, use the default value "DeploymentBackend" case 0: $backend = "DeploymentBackend"; break; // Only 1 thing allowed, use that case 1: $backend = $backends[0]; break; // Multiple choices, use our choice if it's legal, otherwise default to the first item on the list default: $backend = $this->BackendIdentifier; if(!in_array($backend, $backends)) $backend = $backends[0]; } return Injector::inst()->get($backend); }
php
public function Backend() { $backends = array_keys($this->config()->get('allowed_backends', Config::FIRST_SET)); switch(sizeof($backends)) { // Nothing allowed, use the default value "DeploymentBackend" case 0: $backend = "DeploymentBackend"; break; // Only 1 thing allowed, use that case 1: $backend = $backends[0]; break; // Multiple choices, use our choice if it's legal, otherwise default to the first item on the list default: $backend = $this->BackendIdentifier; if(!in_array($backend, $backends)) $backend = $backends[0]; } return Injector::inst()->get($backend); }
[ "public", "function", "Backend", "(", ")", "{", "$", "backends", "=", "array_keys", "(", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'allowed_backends'", ",", "Config", "::", "FIRST_SET", ")", ")", ";", "switch", "(", "sizeof", "(", "$", "backends", ")", ")", "{", "// Nothing allowed, use the default value \"DeploymentBackend\"", "case", "0", ":", "$", "backend", "=", "\"DeploymentBackend\"", ";", "break", ";", "// Only 1 thing allowed, use that", "case", "1", ":", "$", "backend", "=", "$", "backends", "[", "0", "]", ";", "break", ";", "// Multiple choices, use our choice if it's legal, otherwise default to the first item on the list", "default", ":", "$", "backend", "=", "$", "this", "->", "BackendIdentifier", ";", "if", "(", "!", "in_array", "(", "$", "backend", ",", "$", "backends", ")", ")", "$", "backend", "=", "$", "backends", "[", "0", "]", ";", "}", "return", "Injector", "::", "inst", "(", ")", "->", "get", "(", "$", "backend", ")", ";", "}" ]
Get the deployment backend used for this environment. Enforces compliance with the allowed_backends setting; if the DNEnvironment.BackendIdentifier value is illegal then that value is ignored. @return DeploymentBackend
[ "Get", "the", "deployment", "backend", "used", "for", "this", "environment", ".", "Enforces", "compliance", "with", "the", "allowed_backends", "setting", ";", "if", "the", "DNEnvironment", ".", "BackendIdentifier", "value", "is", "illegal", "then", "that", "value", "is", "ignored", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L179-L199
232,943
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.canView
public function canView($member = null) { if(!$member) $member = Member::currentUser(); if(!$member) return false; // Must be logged in to check permissions if(Permission::checkMember($member, 'ADMIN')) return true; // if no Viewers or ViewerGroups defined, fallback to DNProject::canView permissions if($this->Viewers()->exists() || $this->ViewerGroups()->exists()) { return $this->Viewers()->byID($member->ID) || $member->inGroups($this->ViewerGroups()); } return $this->Project()->canView($member); }
php
public function canView($member = null) { if(!$member) $member = Member::currentUser(); if(!$member) return false; // Must be logged in to check permissions if(Permission::checkMember($member, 'ADMIN')) return true; // if no Viewers or ViewerGroups defined, fallback to DNProject::canView permissions if($this->Viewers()->exists() || $this->ViewerGroups()->exists()) { return $this->Viewers()->byID($member->ID) || $member->inGroups($this->ViewerGroups()); } return $this->Project()->canView($member); }
[ "public", "function", "canView", "(", "$", "member", "=", "null", ")", "{", "if", "(", "!", "$", "member", ")", "$", "member", "=", "Member", "::", "currentUser", "(", ")", ";", "if", "(", "!", "$", "member", ")", "return", "false", ";", "// Must be logged in to check permissions", "if", "(", "Permission", "::", "checkMember", "(", "$", "member", ",", "'ADMIN'", ")", ")", "return", "true", ";", "// if no Viewers or ViewerGroups defined, fallback to DNProject::canView permissions", "if", "(", "$", "this", "->", "Viewers", "(", ")", "->", "exists", "(", ")", "||", "$", "this", "->", "ViewerGroups", "(", ")", "->", "exists", "(", ")", ")", "{", "return", "$", "this", "->", "Viewers", "(", ")", "->", "byID", "(", "$", "member", "->", "ID", ")", "||", "$", "member", "->", "inGroups", "(", "$", "this", "->", "ViewerGroups", "(", ")", ")", ";", "}", "return", "$", "this", "->", "Project", "(", ")", "->", "canView", "(", "$", "member", ")", ";", "}" ]
Environments are only viewable by people that can view the environment. @param Member $member @return boolean
[ "Environments", "are", "only", "viewable", "by", "people", "that", "can", "view", "the", "environment", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L306-L319
232,944
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.canDeploy
public function canDeploy($member = null) { if(!$member) $member = Member::currentUser(); if(!$member) return false; // Must be logged in to check permissions if(Permission::checkMember($member, 'ADMIN')) return true; return $this->Deployers()->byID($member->ID) || $member->inGroups($this->DeployerGroups()); }
php
public function canDeploy($member = null) { if(!$member) $member = Member::currentUser(); if(!$member) return false; // Must be logged in to check permissions if(Permission::checkMember($member, 'ADMIN')) return true; return $this->Deployers()->byID($member->ID) || $member->inGroups($this->DeployerGroups()); }
[ "public", "function", "canDeploy", "(", "$", "member", "=", "null", ")", "{", "if", "(", "!", "$", "member", ")", "$", "member", "=", "Member", "::", "currentUser", "(", ")", ";", "if", "(", "!", "$", "member", ")", "return", "false", ";", "// Must be logged in to check permissions", "if", "(", "Permission", "::", "checkMember", "(", "$", "member", ",", "'ADMIN'", ")", ")", "return", "true", ";", "return", "$", "this", "->", "Deployers", "(", ")", "->", "byID", "(", "$", "member", "->", "ID", ")", "||", "$", "member", "->", "inGroups", "(", "$", "this", "->", "DeployerGroups", "(", ")", ")", ";", "}" ]
Allow deploy only to some people. @param Member $member @return boolean
[ "Allow", "deploy", "only", "to", "some", "people", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L327-L335
232,945
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.canAbort
public function canAbort($member = null) { if(!$member) $member = Member::currentUser(); if(!$member) return false; if(Permission::checkMember($member, 'ADMIN')) return true; return $this->PipelineCancellers()->byID($member->ID) || $member->inGroups($this->PipelineCancellerGroups()); }
php
public function canAbort($member = null) { if(!$member) $member = Member::currentUser(); if(!$member) return false; if(Permission::checkMember($member, 'ADMIN')) return true; return $this->PipelineCancellers()->byID($member->ID) || $member->inGroups($this->PipelineCancellerGroups()); }
[ "public", "function", "canAbort", "(", "$", "member", "=", "null", ")", "{", "if", "(", "!", "$", "member", ")", "$", "member", "=", "Member", "::", "currentUser", "(", ")", ";", "if", "(", "!", "$", "member", ")", "return", "false", ";", "if", "(", "Permission", "::", "checkMember", "(", "$", "member", ",", "'ADMIN'", ")", ")", "return", "true", ";", "return", "$", "this", "->", "PipelineCancellers", "(", ")", "->", "byID", "(", "$", "member", "->", "ID", ")", "||", "$", "member", "->", "inGroups", "(", "$", "this", "->", "PipelineCancellerGroups", "(", ")", ")", ";", "}" ]
Determine if the specified user can abort any pipelines @param type $member @return boolean
[ "Determine", "if", "the", "specified", "user", "can", "abort", "any", "pipelines" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L420-L428
232,946
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.canApprove
public function canApprove($member = null) { if(!$member) $member = Member::currentUser(); if(!$member) return false; if(Permission::checkMember($member, 'ADMIN')) return true; return $this->PipelineApprovers()->byID($member->ID) || $member->inGroups($this->PipelineApproverGroups()); }
php
public function canApprove($member = null) { if(!$member) $member = Member::currentUser(); if(!$member) return false; if(Permission::checkMember($member, 'ADMIN')) return true; return $this->PipelineApprovers()->byID($member->ID) || $member->inGroups($this->PipelineApproverGroups()); }
[ "public", "function", "canApprove", "(", "$", "member", "=", "null", ")", "{", "if", "(", "!", "$", "member", ")", "$", "member", "=", "Member", "::", "currentUser", "(", ")", ";", "if", "(", "!", "$", "member", ")", "return", "false", ";", "if", "(", "Permission", "::", "checkMember", "(", "$", "member", ",", "'ADMIN'", ")", ")", "return", "true", ";", "return", "$", "this", "->", "PipelineApprovers", "(", ")", "->", "byID", "(", "$", "member", "->", "ID", ")", "||", "$", "member", "->", "inGroups", "(", "$", "this", "->", "PipelineApproverGroups", "(", ")", ")", ";", "}" ]
Determine if the specified user can approve any pipelines @param type $member @return boolean
[ "Determine", "if", "the", "specified", "user", "can", "approve", "any", "pipelines" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L436-L443
232,947
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.CurrentBuild
public function CurrentBuild() { // The DeployHistory function is far too slow to use for this $deploy = DNDeployment::get()->filter(array('EnvironmentID' => $this->ID, 'Status' => 'Finished'))->sort('LastEdited DESC')->first(); if (!$deploy || (!$deploy->SHA)) { return false; } $repo = $this->Project()->getRepository(); if (!$repo) { return $deploy; } try { $commit = $repo->getCommit($deploy->SHA); if ($commit) { $deploy->Message = Convert::raw2xml($commit->getMessage()); } // We can't find this SHA, so we ignore adding a commit message to the deployment } catch (Exception $ex) { } return $deploy; }
php
public function CurrentBuild() { // The DeployHistory function is far too slow to use for this $deploy = DNDeployment::get()->filter(array('EnvironmentID' => $this->ID, 'Status' => 'Finished'))->sort('LastEdited DESC')->first(); if (!$deploy || (!$deploy->SHA)) { return false; } $repo = $this->Project()->getRepository(); if (!$repo) { return $deploy; } try { $commit = $repo->getCommit($deploy->SHA); if ($commit) { $deploy->Message = Convert::raw2xml($commit->getMessage()); } // We can't find this SHA, so we ignore adding a commit message to the deployment } catch (Exception $ex) { } return $deploy; }
[ "public", "function", "CurrentBuild", "(", ")", "{", "// The DeployHistory function is far too slow to use for this", "$", "deploy", "=", "DNDeployment", "::", "get", "(", ")", "->", "filter", "(", "array", "(", "'EnvironmentID'", "=>", "$", "this", "->", "ID", ",", "'Status'", "=>", "'Finished'", ")", ")", "->", "sort", "(", "'LastEdited DESC'", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "deploy", "||", "(", "!", "$", "deploy", "->", "SHA", ")", ")", "{", "return", "false", ";", "}", "$", "repo", "=", "$", "this", "->", "Project", "(", ")", "->", "getRepository", "(", ")", ";", "if", "(", "!", "$", "repo", ")", "{", "return", "$", "deploy", ";", "}", "try", "{", "$", "commit", "=", "$", "repo", "->", "getCommit", "(", "$", "deploy", "->", "SHA", ")", ";", "if", "(", "$", "commit", ")", "{", "$", "deploy", "->", "Message", "=", "Convert", "::", "raw2xml", "(", "$", "commit", "->", "getMessage", "(", ")", ")", ";", "}", "// We can't find this SHA, so we ignore adding a commit message to the deployment", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "}", "return", "$", "deploy", ";", "}" ]
Get the current deployed build for this environment Dear people of the future: If you are looking to optimize this, simply create a CurrentBuildSHA(), which can be a lot faster. I presume you came here because of the Project display template, which only needs a SHA. @return string
[ "Get", "the", "current", "deployed", "build", "for", "this", "environment" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L598-L620
232,948
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.DeployHistory
public function DeployHistory() { $history = $this ->Deployments() ->sort('LastEdited DESC'); $repo = $this->Project()->getRepository(); if(!$repo) { return $history; } $ammendedHistory = new ArrayList(); foreach($history as $deploy) { if(!$deploy->SHA) { continue; } try { $commit = $repo->getCommit($deploy->SHA); if($commit) { $deploy->Message = Convert::raw2xml($commit->getMessage()); } // We can't find this SHA, so we ignore adding a commit message to the deployment } catch (Exception $ex) { } $ammendedHistory->push($deploy); } return $ammendedHistory; }
php
public function DeployHistory() { $history = $this ->Deployments() ->sort('LastEdited DESC'); $repo = $this->Project()->getRepository(); if(!$repo) { return $history; } $ammendedHistory = new ArrayList(); foreach($history as $deploy) { if(!$deploy->SHA) { continue; } try { $commit = $repo->getCommit($deploy->SHA); if($commit) { $deploy->Message = Convert::raw2xml($commit->getMessage()); } // We can't find this SHA, so we ignore adding a commit message to the deployment } catch (Exception $ex) { } $ammendedHistory->push($deploy); } return $ammendedHistory; }
[ "public", "function", "DeployHistory", "(", ")", "{", "$", "history", "=", "$", "this", "->", "Deployments", "(", ")", "->", "sort", "(", "'LastEdited DESC'", ")", ";", "$", "repo", "=", "$", "this", "->", "Project", "(", ")", "->", "getRepository", "(", ")", ";", "if", "(", "!", "$", "repo", ")", "{", "return", "$", "history", ";", "}", "$", "ammendedHistory", "=", "new", "ArrayList", "(", ")", ";", "foreach", "(", "$", "history", "as", "$", "deploy", ")", "{", "if", "(", "!", "$", "deploy", "->", "SHA", ")", "{", "continue", ";", "}", "try", "{", "$", "commit", "=", "$", "repo", "->", "getCommit", "(", "$", "deploy", "->", "SHA", ")", ";", "if", "(", "$", "commit", ")", "{", "$", "deploy", "->", "Message", "=", "Convert", "::", "raw2xml", "(", "$", "commit", "->", "getMessage", "(", ")", ")", ";", "}", "// We can't find this SHA, so we ignore adding a commit message to the deployment", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "}", "$", "ammendedHistory", "->", "push", "(", "$", "deploy", ")", ";", "}", "return", "$", "ammendedHistory", ";", "}" ]
A history of all builds deployed to this environment @return ArrayList
[ "A", "history", "of", "all", "builds", "deployed", "to", "this", "environment" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L627-L652
232,949
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.buildPermissionField
protected function buildPermissionField($groupField, $memberField, $groups, $members) { return FieldGroup::create( ListboxField::create($groupField, false, $groups) ->setMultiple(true) ->setAttribute('data-placeholder', 'Groups') ->setAttribute('placeholder', 'Groups') ->setAttribute('style', 'width: 400px;'), ListboxField::create($memberField, false, $members) ->setMultiple(true) ->setAttribute('data-placeholder', 'Members') ->setAttribute('placeholder', 'Members') ->setAttribute('style', 'width: 400px;') ); }
php
protected function buildPermissionField($groupField, $memberField, $groups, $members) { return FieldGroup::create( ListboxField::create($groupField, false, $groups) ->setMultiple(true) ->setAttribute('data-placeholder', 'Groups') ->setAttribute('placeholder', 'Groups') ->setAttribute('style', 'width: 400px;'), ListboxField::create($memberField, false, $members) ->setMultiple(true) ->setAttribute('data-placeholder', 'Members') ->setAttribute('placeholder', 'Members') ->setAttribute('style', 'width: 400px;') ); }
[ "protected", "function", "buildPermissionField", "(", "$", "groupField", ",", "$", "memberField", ",", "$", "groups", ",", "$", "members", ")", "{", "return", "FieldGroup", "::", "create", "(", "ListboxField", "::", "create", "(", "$", "groupField", ",", "false", ",", "$", "groups", ")", "->", "setMultiple", "(", "true", ")", "->", "setAttribute", "(", "'data-placeholder'", ",", "'Groups'", ")", "->", "setAttribute", "(", "'placeholder'", ",", "'Groups'", ")", "->", "setAttribute", "(", "'style'", ",", "'width: 400px;'", ")", ",", "ListboxField", "::", "create", "(", "$", "memberField", ",", "false", ",", "$", "members", ")", "->", "setMultiple", "(", "true", ")", "->", "setAttribute", "(", "'data-placeholder'", ",", "'Members'", ")", "->", "setAttribute", "(", "'placeholder'", ",", "'Members'", ")", "->", "setAttribute", "(", "'style'", ",", "'width: 400px;'", ")", ")", ";", "}" ]
Build a set of multi-select fields for assigning permissions to a pair of group and member many_many relations @param string $groupField Group field name @param string $memberField Member field name @param array $groups List of groups @param array $members List of members @return FieldGroup
[ "Build", "a", "set", "of", "multi", "-", "select", "fields", "for", "assigning", "permissions", "to", "a", "pair", "of", "group", "and", "member", "many_many", "relations" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L698-L712
232,950
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.checkEnvironmentPath
protected function checkEnvironmentPath() { // Create folder if it doesn't exist $configDir = dirname($this->getConfigFilename()); if(!file_exists($configDir) && $configDir) { mkdir($configDir, 0777, true); } }
php
protected function checkEnvironmentPath() { // Create folder if it doesn't exist $configDir = dirname($this->getConfigFilename()); if(!file_exists($configDir) && $configDir) { mkdir($configDir, 0777, true); } }
[ "protected", "function", "checkEnvironmentPath", "(", ")", "{", "// Create folder if it doesn't exist", "$", "configDir", "=", "dirname", "(", "$", "this", "->", "getConfigFilename", "(", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "configDir", ")", "&&", "$", "configDir", ")", "{", "mkdir", "(", "$", "configDir", ",", "0777", ",", "true", ")", ";", "}", "}" ]
Ensure that environment paths are setup on the local filesystem
[ "Ensure", "that", "environment", "paths", "are", "setup", "on", "the", "local", "filesystem" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L964-L970
232,951
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.writeConfigFile
protected function writeConfigFile() { if(!$this->config()->get('allow_web_editing')) return; // Create a basic new environment config from a template if( !$this->envFileExists() && $this->Filename && $this->CreateEnvConfig ) { $templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template'; file_put_contents($this->getConfigFilename(), file_get_contents($templateFile)); } else if($this->envFileExists() && $this->DeployConfig) { file_put_contents($this->getConfigFilename(), $this->DeployConfig); } }
php
protected function writeConfigFile() { if(!$this->config()->get('allow_web_editing')) return; // Create a basic new environment config from a template if( !$this->envFileExists() && $this->Filename && $this->CreateEnvConfig ) { $templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template'; file_put_contents($this->getConfigFilename(), file_get_contents($templateFile)); } else if($this->envFileExists() && $this->DeployConfig) { file_put_contents($this->getConfigFilename(), $this->DeployConfig); } }
[ "protected", "function", "writeConfigFile", "(", ")", "{", "if", "(", "!", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'allow_web_editing'", ")", ")", "return", ";", "// Create a basic new environment config from a template", "if", "(", "!", "$", "this", "->", "envFileExists", "(", ")", "&&", "$", "this", "->", "Filename", "&&", "$", "this", "->", "CreateEnvConfig", ")", "{", "$", "templateFile", "=", "$", "this", "->", "config", "(", ")", "->", "template_file", "?", ":", "BASE_PATH", ".", "'/deploynaut/environment.template'", ";", "file_put_contents", "(", "$", "this", "->", "getConfigFilename", "(", ")", ",", "file_get_contents", "(", "$", "templateFile", ")", ")", ";", "}", "else", "if", "(", "$", "this", "->", "envFileExists", "(", ")", "&&", "$", "this", "->", "DeployConfig", ")", "{", "file_put_contents", "(", "$", "this", "->", "getConfigFilename", "(", ")", ",", "$", "this", "->", "DeployConfig", ")", ";", "}", "}" ]
Write the deployment config file to filesystem
[ "Write", "the", "deployment", "config", "file", "to", "filesystem" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L975-L988
232,952
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.writePipelineFile
protected function writePipelineFile() { if(!$this->config()->get('allow_web_editing')) return; $path = $this->getPipelineFilename(); if($this->PipelineConfig) { // Update file file_put_contents($path, $this->PipelineConfig); } elseif($this->isChanged('PipelineConfig') && file_exists($path)) { // Remove file if deleted unlink($path); } }
php
protected function writePipelineFile() { if(!$this->config()->get('allow_web_editing')) return; $path = $this->getPipelineFilename(); if($this->PipelineConfig) { // Update file file_put_contents($path, $this->PipelineConfig); } elseif($this->isChanged('PipelineConfig') && file_exists($path)) { // Remove file if deleted unlink($path); } }
[ "protected", "function", "writePipelineFile", "(", ")", "{", "if", "(", "!", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'allow_web_editing'", ")", ")", "return", ";", "$", "path", "=", "$", "this", "->", "getPipelineFilename", "(", ")", ";", "if", "(", "$", "this", "->", "PipelineConfig", ")", "{", "// Update file", "file_put_contents", "(", "$", "path", ",", "$", "this", "->", "PipelineConfig", ")", ";", "}", "elseif", "(", "$", "this", "->", "isChanged", "(", "'PipelineConfig'", ")", "&&", "file_exists", "(", "$", "path", ")", ")", "{", "// Remove file if deleted", "unlink", "(", "$", "path", ")", ";", "}", "}" ]
Write the pipeline config file to filesystem
[ "Write", "the", "pipeline", "config", "file", "to", "filesystem" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L993-L1003
232,953
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.onAfterDelete
public function onAfterDelete() { parent::onAfterDelete(); // Create a basic new environment config from a template if($this->config()->get('allow_web_editing') && $this->envFileExists()) { unlink($this->getConfigFilename()); } }
php
public function onAfterDelete() { parent::onAfterDelete(); // Create a basic new environment config from a template if($this->config()->get('allow_web_editing') && $this->envFileExists()) { unlink($this->getConfigFilename()); } }
[ "public", "function", "onAfterDelete", "(", ")", "{", "parent", "::", "onAfterDelete", "(", ")", ";", "// Create a basic new environment config from a template", "if", "(", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'allow_web_editing'", ")", "&&", "$", "this", "->", "envFileExists", "(", ")", ")", "{", "unlink", "(", "$", "this", "->", "getConfigFilename", "(", ")", ")", ";", "}", "}" ]
Delete any related config files
[ "Delete", "any", "related", "config", "files" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L1008-L1014
232,954
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.getConfigFilename
public function getConfigFilename() { if(!$this->Project()->exists()) { return ''; } if(!$this->Filename) { return ''; } return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename; }
php
public function getConfigFilename() { if(!$this->Project()->exists()) { return ''; } if(!$this->Filename) { return ''; } return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename; }
[ "public", "function", "getConfigFilename", "(", ")", "{", "if", "(", "!", "$", "this", "->", "Project", "(", ")", "->", "exists", "(", ")", ")", "{", "return", "''", ";", "}", "if", "(", "!", "$", "this", "->", "Filename", ")", "{", "return", "''", ";", "}", "return", "$", "this", "->", "DNData", "(", ")", "->", "getEnvironmentDir", "(", ")", ".", "'/'", ".", "$", "this", "->", "Project", "(", ")", "->", "Name", ".", "'/'", ".", "$", "this", "->", "Filename", ";", "}" ]
Returns the path to the ruby config file @return string
[ "Returns", "the", "path", "to", "the", "ruby", "config", "file" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L1043-L1051
232,955
silverstripe-archive/deploynaut
code/model/DNEnvironment.php
DNEnvironment.getDependentFilteredCommits
public function getDependentFilteredCommits() { // check if this environment depends on another environemnt $dependsOnEnv = $this->DependsOnEnvironment(); if(empty($dependsOnEnv)) return null; // Check if there is a filter $config = $this->GenericPipelineConfig(); $filter = isset($config->PipelineConfig->FilteredCommits) ? $config->PipelineConfig->FilteredCommits : null; if (empty($filter)) return null; // Create and execute filter if (!class_exists($filter)) throw new Exception(sprintf("Class %s does not exist", $filter)); $commitClass = $filter::create(); // setup the environment to check for commits $commitClass->env = $dependsOnEnv; return $commitClass->getCommits(); }
php
public function getDependentFilteredCommits() { // check if this environment depends on another environemnt $dependsOnEnv = $this->DependsOnEnvironment(); if(empty($dependsOnEnv)) return null; // Check if there is a filter $config = $this->GenericPipelineConfig(); $filter = isset($config->PipelineConfig->FilteredCommits) ? $config->PipelineConfig->FilteredCommits : null; if (empty($filter)) return null; // Create and execute filter if (!class_exists($filter)) throw new Exception(sprintf("Class %s does not exist", $filter)); $commitClass = $filter::create(); // setup the environment to check for commits $commitClass->env = $dependsOnEnv; return $commitClass->getCommits(); }
[ "public", "function", "getDependentFilteredCommits", "(", ")", "{", "// check if this environment depends on another environemnt", "$", "dependsOnEnv", "=", "$", "this", "->", "DependsOnEnvironment", "(", ")", ";", "if", "(", "empty", "(", "$", "dependsOnEnv", ")", ")", "return", "null", ";", "// Check if there is a filter", "$", "config", "=", "$", "this", "->", "GenericPipelineConfig", "(", ")", ";", "$", "filter", "=", "isset", "(", "$", "config", "->", "PipelineConfig", "->", "FilteredCommits", ")", "?", "$", "config", "->", "PipelineConfig", "->", "FilteredCommits", ":", "null", ";", "if", "(", "empty", "(", "$", "filter", ")", ")", "return", "null", ";", "// Create and execute filter", "if", "(", "!", "class_exists", "(", "$", "filter", ")", ")", "throw", "new", "Exception", "(", "sprintf", "(", "\"Class %s does not exist\"", ",", "$", "filter", ")", ")", ";", "$", "commitClass", "=", "$", "filter", "::", "create", "(", ")", ";", "// setup the environment to check for commits", "$", "commitClass", "->", "env", "=", "$", "dependsOnEnv", ";", "return", "$", "commitClass", "->", "getCommits", "(", ")", ";", "}" ]
Helper function to retrieve filtered commits from an environment this environment depends on @return DataList
[ "Helper", "function", "to", "retrieve", "filtered", "commits", "from", "an", "environment", "this", "environment", "depends", "on" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNEnvironment.php#L1119-L1137
232,956
mpratt/RelativeTime
Lib/RelativeTime/RelativeTime.php
RelativeTime.convert
public function convert($fromTime, $toTime = null) { $interval = $this->getInterval($fromTime, $toTime); $units = $this->calculateUnits($interval); return $this->translation->translate($units, $interval->invert); }
php
public function convert($fromTime, $toTime = null) { $interval = $this->getInterval($fromTime, $toTime); $units = $this->calculateUnits($interval); return $this->translation->translate($units, $interval->invert); }
[ "public", "function", "convert", "(", "$", "fromTime", ",", "$", "toTime", "=", "null", ")", "{", "$", "interval", "=", "$", "this", "->", "getInterval", "(", "$", "fromTime", ",", "$", "toTime", ")", ";", "$", "units", "=", "$", "this", "->", "calculateUnits", "(", "$", "interval", ")", ";", "return", "$", "this", "->", "translation", "->", "translate", "(", "$", "units", ",", "$", "interval", "->", "invert", ")", ";", "}" ]
Converts 2 dates to its relative time. @param string $fromTime @param string $toTime When null is given, uses the current date. @return string
[ "Converts", "2", "dates", "to", "its", "relative", "time", "." ]
cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5
https://github.com/mpratt/RelativeTime/blob/cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5/Lib/RelativeTime/RelativeTime.php#L59-L65
232,957
mpratt/RelativeTime
Lib/RelativeTime/RelativeTime.php
RelativeTime.timeAgo
public function timeAgo($date) { $interval = $this->getInterval(time(), $date); if ($interval->invert) { return $this->convert(time(), $date); } return $this->translation->translate(); }
php
public function timeAgo($date) { $interval = $this->getInterval(time(), $date); if ($interval->invert) { return $this->convert(time(), $date); } return $this->translation->translate(); }
[ "public", "function", "timeAgo", "(", "$", "date", ")", "{", "$", "interval", "=", "$", "this", "->", "getInterval", "(", "time", "(", ")", ",", "$", "date", ")", ";", "if", "(", "$", "interval", "->", "invert", ")", "{", "return", "$", "this", "->", "convert", "(", "time", "(", ")", ",", "$", "date", ")", ";", "}", "return", "$", "this", "->", "translation", "->", "translate", "(", ")", ";", "}" ]
Tells the time passed between the current date and the given date @param string $date @return string
[ "Tells", "the", "time", "passed", "between", "the", "current", "date", "and", "the", "given", "date" ]
cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5
https://github.com/mpratt/RelativeTime/blob/cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5/Lib/RelativeTime/RelativeTime.php#L73-L81
232,958
mpratt/RelativeTime
Lib/RelativeTime/RelativeTime.php
RelativeTime.getInterval
protected function getInterval($fromTime, $toTime = null) { $fromTime = new DateTime($this->normalizeDate($fromTime)); $toTime = new DateTime($this->normalizeDate($toTime)); return $fromTime->diff($toTime); }
php
protected function getInterval($fromTime, $toTime = null) { $fromTime = new DateTime($this->normalizeDate($fromTime)); $toTime = new DateTime($this->normalizeDate($toTime)); return $fromTime->diff($toTime); }
[ "protected", "function", "getInterval", "(", "$", "fromTime", ",", "$", "toTime", "=", "null", ")", "{", "$", "fromTime", "=", "new", "DateTime", "(", "$", "this", "->", "normalizeDate", "(", "$", "fromTime", ")", ")", ";", "$", "toTime", "=", "new", "DateTime", "(", "$", "this", "->", "normalizeDate", "(", "$", "toTime", ")", ")", ";", "return", "$", "fromTime", "->", "diff", "(", "$", "toTime", ")", ";", "}" ]
Calculates the interval between the dates and returns an array with the valid time. @param string $fromTime @param string $toTime When null is given, uses the current date. @return DateInterval
[ "Calculates", "the", "interval", "between", "the", "dates", "and", "returns", "an", "array", "with", "the", "valid", "time", "." ]
cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5
https://github.com/mpratt/RelativeTime/blob/cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5/Lib/RelativeTime/RelativeTime.php#L107-L113
232,959
mpratt/RelativeTime
Lib/RelativeTime/RelativeTime.php
RelativeTime.normalizeDate
protected function normalizeDate($date) { $date = str_replace(array('/', '|'), '-', $date); if (empty($date)) { return date('Y-m-d H:i:s'); } else if (ctype_digit($date)) { return date('Y-m-d H:i:s', $date); } return $date; }
php
protected function normalizeDate($date) { $date = str_replace(array('/', '|'), '-', $date); if (empty($date)) { return date('Y-m-d H:i:s'); } else if (ctype_digit($date)) { return date('Y-m-d H:i:s', $date); } return $date; }
[ "protected", "function", "normalizeDate", "(", "$", "date", ")", "{", "$", "date", "=", "str_replace", "(", "array", "(", "'/'", ",", "'|'", ")", ",", "'-'", ",", "$", "date", ")", ";", "if", "(", "empty", "(", "$", "date", ")", ")", "{", "return", "date", "(", "'Y-m-d H:i:s'", ")", ";", "}", "else", "if", "(", "ctype_digit", "(", "$", "date", ")", ")", "{", "return", "date", "(", "'Y-m-d H:i:s'", ",", "$", "date", ")", ";", "}", "return", "$", "date", ";", "}" ]
Normalizes a date for the DateTime class @param string $date @return string
[ "Normalizes", "a", "date", "for", "the", "DateTime", "class" ]
cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5
https://github.com/mpratt/RelativeTime/blob/cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5/Lib/RelativeTime/RelativeTime.php#L121-L132
232,960
mpratt/RelativeTime
Lib/RelativeTime/RelativeTime.php
RelativeTime.calculateUnits
protected function calculateUnits(DateInterval $interval) { $units = array_filter(array( 'years' => (int) $interval->y, 'months' => (int) $interval->m, 'days' => (int) $interval->d, 'hours' => (int) $interval->h, 'minutes' => (int) $interval->i, 'seconds' => (int) $interval->s, )); if (empty($units)) { return array(); } else if ((int) $this->config['truncate'] > 0) { return array_slice($units, 0, (int) $this->config['truncate']); } return $units; }
php
protected function calculateUnits(DateInterval $interval) { $units = array_filter(array( 'years' => (int) $interval->y, 'months' => (int) $interval->m, 'days' => (int) $interval->d, 'hours' => (int) $interval->h, 'minutes' => (int) $interval->i, 'seconds' => (int) $interval->s, )); if (empty($units)) { return array(); } else if ((int) $this->config['truncate'] > 0) { return array_slice($units, 0, (int) $this->config['truncate']); } return $units; }
[ "protected", "function", "calculateUnits", "(", "DateInterval", "$", "interval", ")", "{", "$", "units", "=", "array_filter", "(", "array", "(", "'years'", "=>", "(", "int", ")", "$", "interval", "->", "y", ",", "'months'", "=>", "(", "int", ")", "$", "interval", "->", "m", ",", "'days'", "=>", "(", "int", ")", "$", "interval", "->", "d", ",", "'hours'", "=>", "(", "int", ")", "$", "interval", "->", "h", ",", "'minutes'", "=>", "(", "int", ")", "$", "interval", "->", "i", ",", "'seconds'", "=>", "(", "int", ")", "$", "interval", "->", "s", ",", ")", ")", ";", "if", "(", "empty", "(", "$", "units", ")", ")", "{", "return", "array", "(", ")", ";", "}", "else", "if", "(", "(", "int", ")", "$", "this", "->", "config", "[", "'truncate'", "]", ">", "0", ")", "{", "return", "array_slice", "(", "$", "units", ",", "0", ",", "(", "int", ")", "$", "this", "->", "config", "[", "'truncate'", "]", ")", ";", "}", "return", "$", "units", ";", "}" ]
Given a DateInterval, creates an array with the time units and truncates it when necesary. @param DateInterval $interval @return array
[ "Given", "a", "DateInterval", "creates", "an", "array", "with", "the", "time", "units", "and", "truncates", "it", "when", "necesary", "." ]
cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5
https://github.com/mpratt/RelativeTime/blob/cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5/Lib/RelativeTime/RelativeTime.php#L141-L159
232,961
stephanecoinon/papertrail
src/Php.php
Php.boot
public static function boot($host = null, $port = null, $prefix = '') { $host or $host = getenv('PAPERTRAIL_HOST'); $port or $port = getenv('PAPERTRAIL_PORT'); $prefix and $prefix = "[$prefix] "; return (new static($host, $port, $prefix)) ->detectFrameworkOrFail() ->registerPapertrailHandler(); }
php
public static function boot($host = null, $port = null, $prefix = '') { $host or $host = getenv('PAPERTRAIL_HOST'); $port or $port = getenv('PAPERTRAIL_PORT'); $prefix and $prefix = "[$prefix] "; return (new static($host, $port, $prefix)) ->detectFrameworkOrFail() ->registerPapertrailHandler(); }
[ "public", "static", "function", "boot", "(", "$", "host", "=", "null", ",", "$", "port", "=", "null", ",", "$", "prefix", "=", "''", ")", "{", "$", "host", "or", "$", "host", "=", "getenv", "(", "'PAPERTRAIL_HOST'", ")", ";", "$", "port", "or", "$", "port", "=", "getenv", "(", "'PAPERTRAIL_PORT'", ")", ";", "$", "prefix", "and", "$", "prefix", "=", "\"[$prefix] \"", ";", "return", "(", "new", "static", "(", "$", "host", ",", "$", "port", ",", "$", "prefix", ")", ")", "->", "detectFrameworkOrFail", "(", ")", "->", "registerPapertrailHandler", "(", ")", ";", "}" ]
Boot connector with given host, port and log message prefix. If host or port are omitted, we'll try to get them from the environment variables PAPERTRAIL_HOST and PAPERTRAIL_PORT. @param string $host Papertrail log server, ie log.papertrailapp.com @param int $port Papertrail port number for log server @param string $prefix Prefix to use for each log message @return \Psr\Log\LoggerInterface
[ "Boot", "connector", "with", "given", "host", "port", "and", "log", "message", "prefix", "." ]
b1d1771b21f65427701e6d5eb8515c7cd17a8e56
https://github.com/stephanecoinon/papertrail/blob/b1d1771b21f65427701e6d5eb8515c7cd17a8e56/src/Php.php#L42-L51
232,962
stephanecoinon/papertrail
src/Php.php
Php.getHandler
public function getHandler($host, $port, $prefix) { $syslog = new SyslogUdpHandler($host, $port); $formatter = new LineFormatter("$prefix%channel%.%level_name%: %message% %extra%"); $syslog->setFormatter($formatter); return $syslog; }
php
public function getHandler($host, $port, $prefix) { $syslog = new SyslogUdpHandler($host, $port); $formatter = new LineFormatter("$prefix%channel%.%level_name%: %message% %extra%"); $syslog->setFormatter($formatter); return $syslog; }
[ "public", "function", "getHandler", "(", "$", "host", ",", "$", "port", ",", "$", "prefix", ")", "{", "$", "syslog", "=", "new", "SyslogUdpHandler", "(", "$", "host", ",", "$", "port", ")", ";", "$", "formatter", "=", "new", "LineFormatter", "(", "\"$prefix%channel%.%level_name%: %message% %extra%\"", ")", ";", "$", "syslog", "->", "setFormatter", "(", "$", "formatter", ")", ";", "return", "$", "syslog", ";", "}" ]
Get Papertrail SysLog handler. @param string $host @param int $port @param string $prefix @return \Monolog\Handler\HandlerInterface
[ "Get", "Papertrail", "SysLog", "handler", "." ]
b1d1771b21f65427701e6d5eb8515c7cd17a8e56
https://github.com/stephanecoinon/papertrail/blob/b1d1771b21f65427701e6d5eb8515c7cd17a8e56/src/Php.php#L72-L79
232,963
asinfotrack/yii2-toolbox
widgets/FlashMessages.php
FlashMessages.loadFlashes
protected function loadFlashes() { if (isset($this->loadFlashesCallback) && $this->loadFlashesCallback instanceof \Closure) { return call_user_func($this->loadFlashesCallback); } else { return Yii::$app->session->getAllFlashes(); } }
php
protected function loadFlashes() { if (isset($this->loadFlashesCallback) && $this->loadFlashesCallback instanceof \Closure) { return call_user_func($this->loadFlashesCallback); } else { return Yii::$app->session->getAllFlashes(); } }
[ "protected", "function", "loadFlashes", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "loadFlashesCallback", ")", "&&", "$", "this", "->", "loadFlashesCallback", "instanceof", "\\", "Closure", ")", "{", "return", "call_user_func", "(", "$", "this", "->", "loadFlashesCallback", ")", ";", "}", "else", "{", "return", "Yii", "::", "$", "app", "->", "session", "->", "getAllFlashes", "(", ")", ";", "}", "}" ]
Populates the internal var with flash messages either retrieved via session or custom callback. @return array an array containing the flash message data
[ "Populates", "the", "internal", "var", "with", "flash", "messages", "either", "retrieved", "via", "session", "or", "custom", "callback", "." ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/widgets/FlashMessages.php#L106-L113
232,964
asinfotrack/yii2-toolbox
widgets/FlashMessages.php
FlashMessages.renderAlertBox
protected function renderAlertBox($type, $content) { //options $options = $this->alertOptions; Html::addCssClass($options, 'alert-' . $type); //start container $ret = Html::beginTag('div', $options); //close button if ($this->closeButton !== false) { $ret .= $this->renderCloseButton(); } //content $ret .= $content; //end container return $ret . Html::endTag('div') . "\n"; }
php
protected function renderAlertBox($type, $content) { //options $options = $this->alertOptions; Html::addCssClass($options, 'alert-' . $type); //start container $ret = Html::beginTag('div', $options); //close button if ($this->closeButton !== false) { $ret .= $this->renderCloseButton(); } //content $ret .= $content; //end container return $ret . Html::endTag('div') . "\n"; }
[ "protected", "function", "renderAlertBox", "(", "$", "type", ",", "$", "content", ")", "{", "//options", "$", "options", "=", "$", "this", "->", "alertOptions", ";", "Html", "::", "addCssClass", "(", "$", "options", ",", "'alert-'", ".", "$", "type", ")", ";", "//start container", "$", "ret", "=", "Html", "::", "beginTag", "(", "'div'", ",", "$", "options", ")", ";", "//close button", "if", "(", "$", "this", "->", "closeButton", "!==", "false", ")", "{", "$", "ret", ".=", "$", "this", "->", "renderCloseButton", "(", ")", ";", "}", "//content", "$", "ret", ".=", "$", "content", ";", "//end container", "return", "$", "ret", ".", "Html", "::", "endTag", "(", "'div'", ")", ".", "\"\\n\"", ";", "}" ]
Creates an alert box @param string $type the flash-type (eg success, danger, etc.) @param string $content the content of the flash message @return string the html code
[ "Creates", "an", "alert", "box" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/widgets/FlashMessages.php#L122-L141
232,965
lamoni/netconf
src/NetConf.php
NetConf.sendRaw
public function sendRaw($data, $rootNode, $endOfMessageDelimiter, $attributes=array(), $waitForReply=true) { $data = str_replace('<?xml version="1.0"?>', '', (string)$data); $data = new SimpleXMLElement("<{$rootNode}>$data</{$rootNode}>"); foreach ($attributes as $attribute_name=>$attribute_value) { $data->addAttribute($attribute_name, $attribute_value); } $data = str_replace('<?xml version="1.0"?>', '', $data->asXML()); $this->sendHistory[] = $data; $this->ssh->write($data."]]>]]>\n"); if (!$waitForReply) { return true; } return $this->readReply($endOfMessageDelimiter); }
php
public function sendRaw($data, $rootNode, $endOfMessageDelimiter, $attributes=array(), $waitForReply=true) { $data = str_replace('<?xml version="1.0"?>', '', (string)$data); $data = new SimpleXMLElement("<{$rootNode}>$data</{$rootNode}>"); foreach ($attributes as $attribute_name=>$attribute_value) { $data->addAttribute($attribute_name, $attribute_value); } $data = str_replace('<?xml version="1.0"?>', '', $data->asXML()); $this->sendHistory[] = $data; $this->ssh->write($data."]]>]]>\n"); if (!$waitForReply) { return true; } return $this->readReply($endOfMessageDelimiter); }
[ "public", "function", "sendRaw", "(", "$", "data", ",", "$", "rootNode", ",", "$", "endOfMessageDelimiter", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "waitForReply", "=", "true", ")", "{", "$", "data", "=", "str_replace", "(", "'<?xml version=\"1.0\"?>'", ",", "''", ",", "(", "string", ")", "$", "data", ")", ";", "$", "data", "=", "new", "SimpleXMLElement", "(", "\"<{$rootNode}>$data</{$rootNode}>\"", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "attribute_name", "=>", "$", "attribute_value", ")", "{", "$", "data", "->", "addAttribute", "(", "$", "attribute_name", ",", "$", "attribute_value", ")", ";", "}", "$", "data", "=", "str_replace", "(", "'<?xml version=\"1.0\"?>'", ",", "''", ",", "$", "data", "->", "asXML", "(", ")", ")", ";", "$", "this", "->", "sendHistory", "[", "]", "=", "$", "data", ";", "$", "this", "->", "ssh", "->", "write", "(", "$", "data", ".", "\"]]>]]>\\n\"", ")", ";", "if", "(", "!", "$", "waitForReply", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "readReply", "(", "$", "endOfMessageDelimiter", ")", ";", "}" ]
Handles the actual building and sending of XML to the server @param $data @param $rootNode @param $endOfMessageDelimiter @param array $attributes @param bool $waitForReply @return bool|mixed
[ "Handles", "the", "actual", "building", "and", "sending", "of", "XML", "to", "the", "server" ]
e0ee6cd792e75f15163e51e70b293dba2b8ee4b4
https://github.com/lamoni/netconf/blob/e0ee6cd792e75f15163e51e70b293dba2b8ee4b4/src/NetConf.php#L167-L193
232,966
lamoni/netconf
src/NetConf.php
NetConf.sendHello
public function sendHello() { $helloXML = new SimpleXMLElement("<capabilities> </capabilities>"); foreach ($this->myCapabilities as $capability) { $helloXML->addChild("capability", $capability); } $this->sendRaw( $helloXML->asXML(), "hello", null, [], false ); }
php
public function sendHello() { $helloXML = new SimpleXMLElement("<capabilities> </capabilities>"); foreach ($this->myCapabilities as $capability) { $helloXML->addChild("capability", $capability); } $this->sendRaw( $helloXML->asXML(), "hello", null, [], false ); }
[ "public", "function", "sendHello", "(", ")", "{", "$", "helloXML", "=", "new", "SimpleXMLElement", "(", "\"<capabilities> </capabilities>\"", ")", ";", "foreach", "(", "$", "this", "->", "myCapabilities", "as", "$", "capability", ")", "{", "$", "helloXML", "->", "addChild", "(", "\"capability\"", ",", "$", "capability", ")", ";", "}", "$", "this", "->", "sendRaw", "(", "$", "helloXML", "->", "asXML", "(", ")", ",", "\"hello\"", ",", "null", ",", "[", "]", ",", "false", ")", ";", "}" ]
Sends our Hello message
[ "Sends", "our", "Hello", "message" ]
e0ee6cd792e75f15163e51e70b293dba2b8ee4b4
https://github.com/lamoni/netconf/blob/e0ee6cd792e75f15163e51e70b293dba2b8ee4b4/src/NetConf.php#L218-L236
232,967
lamoni/netconf
src/NetConf.php
NetConf.copyConfig
public function copyConfig($source, $target) { if (substr($source, 0, 4) === "url:") { $source = "<url>".substr($source, 4)."</url>"; } else { $source = "<{$source}/>"; } if (substr($target, 0, 4) === "url:") { $target = "<url>".substr($target, 4)."</url>"; } else { $target = "<{$target}/>"; } $copyConfig = new SimpleXMLElement( "<copy-config>". "<source>{$source}</source>". "<target>{$target}</target>". "</copy-config>" ); return $this->sendRPC($copyConfig->asXML()); }
php
public function copyConfig($source, $target) { if (substr($source, 0, 4) === "url:") { $source = "<url>".substr($source, 4)."</url>"; } else { $source = "<{$source}/>"; } if (substr($target, 0, 4) === "url:") { $target = "<url>".substr($target, 4)."</url>"; } else { $target = "<{$target}/>"; } $copyConfig = new SimpleXMLElement( "<copy-config>". "<source>{$source}</source>". "<target>{$target}</target>". "</copy-config>" ); return $this->sendRPC($copyConfig->asXML()); }
[ "public", "function", "copyConfig", "(", "$", "source", ",", "$", "target", ")", "{", "if", "(", "substr", "(", "$", "source", ",", "0", ",", "4", ")", "===", "\"url:\"", ")", "{", "$", "source", "=", "\"<url>\"", ".", "substr", "(", "$", "source", ",", "4", ")", ".", "\"</url>\"", ";", "}", "else", "{", "$", "source", "=", "\"<{$source}/>\"", ";", "}", "if", "(", "substr", "(", "$", "target", ",", "0", ",", "4", ")", "===", "\"url:\"", ")", "{", "$", "target", "=", "\"<url>\"", ".", "substr", "(", "$", "target", ",", "4", ")", ".", "\"</url>\"", ";", "}", "else", "{", "$", "target", "=", "\"<{$target}/>\"", ";", "}", "$", "copyConfig", "=", "new", "SimpleXMLElement", "(", "\"<copy-config>\"", ".", "\"<source>{$source}</source>\"", ".", "\"<target>{$target}</target>\"", ".", "\"</copy-config>\"", ")", ";", "return", "$", "this", "->", "sendRPC", "(", "$", "copyConfig", "->", "asXML", "(", ")", ")", ";", "}" ]
Handles copying a datastore to a different datastore @param $source - Pass in dataStore name, or prefix like "url:http://test.com/config" to generate the <url> node @param $target - Pass in dataStore name, or prefix like "url:http://test.com/config" to generate the <url> node
[ "Handles", "copying", "a", "datastore", "to", "a", "different", "datastore" ]
e0ee6cd792e75f15163e51e70b293dba2b8ee4b4
https://github.com/lamoni/netconf/blob/e0ee6cd792e75f15163e51e70b293dba2b8ee4b4/src/NetConf.php#L383-L417
232,968
bav-php/bav
classes/validator/ContextValidation.php
ContextValidation.isValidBank
public function isValidBank($bankID) { try { $this->initialized = true; $this->bank = $this->backend->getBank($bankID); return true; } catch (BankNotFoundException $e) { $this->bank = null; return false; } }
php
public function isValidBank($bankID) { try { $this->initialized = true; $this->bank = $this->backend->getBank($bankID); return true; } catch (BankNotFoundException $e) { $this->bank = null; return false; } }
[ "public", "function", "isValidBank", "(", "$", "bankID", ")", "{", "try", "{", "$", "this", "->", "initialized", "=", "true", ";", "$", "this", "->", "bank", "=", "$", "this", "->", "backend", "->", "getBank", "(", "$", "bankID", ")", ";", "return", "true", ";", "}", "catch", "(", "BankNotFoundException", "$", "e", ")", "{", "$", "this", "->", "bank", "=", "null", ";", "return", "false", ";", "}", "}" ]
Returns true if a bank exists. This method sets the bank context and should be called first. @throws DataBackendException @param string $bankID @return bool @see DataBackend::isValidBank()
[ "Returns", "true", "if", "a", "bank", "exists", "." ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/validator/ContextValidation.php#L53-L65
232,969
bav-php/bav
classes/validator/ContextValidation.php
ContextValidation.isValidAccount
public function isValidAccount($account) { if (! $this->initialized) { throw new InvalidContextException("You have to call isValidBank() before."); } // No valid bank makes every account valid if ($this->bank == null) { return true; } return $this->bank->isValid($account); }
php
public function isValidAccount($account) { if (! $this->initialized) { throw new InvalidContextException("You have to call isValidBank() before."); } // No valid bank makes every account valid if ($this->bank == null) { return true; } return $this->bank->isValid($account); }
[ "public", "function", "isValidAccount", "(", "$", "account", ")", "{", "if", "(", "!", "$", "this", "->", "initialized", ")", "{", "throw", "new", "InvalidContextException", "(", "\"You have to call isValidBank() before.\"", ")", ";", "}", "// No valid bank makes every account valid", "if", "(", "$", "this", "->", "bank", "==", "null", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "bank", "->", "isValid", "(", "$", "account", ")", ";", "}" ]
Returns true if the account is valid for the current context. You have to have called isValidBank() before! If the current context is no valid bank every account will validate to true. @param string $account @see isValidBank() @see Bank::isValid() @throws InvalidContextException isValidBank() was not called before. @return bool
[ "Returns", "true", "if", "the", "account", "is", "valid", "for", "the", "current", "context", "." ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/validator/ContextValidation.php#L79-L93
232,970
swoft-cloud/swoft-http-message
src/Server/Response.php
Response.redirect
public function redirect($url, $status = 302) { $response = $this; $response = $response->withAddedHeader('Location', (string)$url)->withStatus($status); return $response; }
php
public function redirect($url, $status = 302) { $response = $this; $response = $response->withAddedHeader('Location', (string)$url)->withStatus($status); return $response; }
[ "public", "function", "redirect", "(", "$", "url", ",", "$", "status", "=", "302", ")", "{", "$", "response", "=", "$", "this", ";", "$", "response", "=", "$", "response", "->", "withAddedHeader", "(", "'Location'", ",", "(", "string", ")", "$", "url", ")", "->", "withStatus", "(", "$", "status", ")", ";", "return", "$", "response", ";", "}" ]
Redirect to a URL @param string $url @param null|int $status @return static
[ "Redirect", "to", "a", "URL" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Response.php#L56-L61
232,971
swoft-cloud/swoft-http-message
src/Server/Response.php
Response.raw
public function raw(string $data = '', int $status = 200): Response { $response = $this; // Headers $response = $response->withoutHeader('Content-Type')->withAddedHeader('Content-Type', 'text/plain'); $this->getCharset() && $response = $response->withCharset($this->getCharset()); // Content $data && $response = $response->withContent($data); // Status code $status && $response = $response->withStatus($status); return $response; }
php
public function raw(string $data = '', int $status = 200): Response { $response = $this; // Headers $response = $response->withoutHeader('Content-Type')->withAddedHeader('Content-Type', 'text/plain'); $this->getCharset() && $response = $response->withCharset($this->getCharset()); // Content $data && $response = $response->withContent($data); // Status code $status && $response = $response->withStatus($status); return $response; }
[ "public", "function", "raw", "(", "string", "$", "data", "=", "''", ",", "int", "$", "status", "=", "200", ")", ":", "Response", "{", "$", "response", "=", "$", "this", ";", "// Headers", "$", "response", "=", "$", "response", "->", "withoutHeader", "(", "'Content-Type'", ")", "->", "withAddedHeader", "(", "'Content-Type'", ",", "'text/plain'", ")", ";", "$", "this", "->", "getCharset", "(", ")", "&&", "$", "response", "=", "$", "response", "->", "withCharset", "(", "$", "this", "->", "getCharset", "(", ")", ")", ";", "// Content", "$", "data", "&&", "$", "response", "=", "$", "response", "->", "withContent", "(", "$", "data", ")", ";", "// Status code", "$", "status", "&&", "$", "response", "=", "$", "response", "->", "withStatus", "(", "$", "status", ")", ";", "return", "$", "response", ";", "}" ]
return a Raw format response @param string $data The data @param int $status The HTTP status code. @return \Swoft\Http\Message\Server\Response when $data not jsonable
[ "return", "a", "Raw", "format", "response" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Response.php#L70-L85
232,972
swoft-cloud/swoft-http-message
src/Server/Response.php
Response.json
public function json($data = [], int $status = 200, int $encodingOptions = JSON_UNESCAPED_UNICODE): Response { $response = $this; // Headers $response = $response->withoutHeader('Content-Type')->withAddedHeader('Content-Type', 'application/json'); $this->getCharset() && $response = $response->withCharset($this->getCharset()); // Content if ($data && ($this->isArrayable($data) || is_string($data))) { is_string($data) && $data = ['data' => $data]; $content = JsonHelper::encode($data, $encodingOptions); $response = $response->withContent($content); } else { $response = $response->withContent('{}'); } // Status code $status && $response = $response->withStatus($status); return $response; }
php
public function json($data = [], int $status = 200, int $encodingOptions = JSON_UNESCAPED_UNICODE): Response { $response = $this; // Headers $response = $response->withoutHeader('Content-Type')->withAddedHeader('Content-Type', 'application/json'); $this->getCharset() && $response = $response->withCharset($this->getCharset()); // Content if ($data && ($this->isArrayable($data) || is_string($data))) { is_string($data) && $data = ['data' => $data]; $content = JsonHelper::encode($data, $encodingOptions); $response = $response->withContent($content); } else { $response = $response->withContent('{}'); } // Status code $status && $response = $response->withStatus($status); return $response; }
[ "public", "function", "json", "(", "$", "data", "=", "[", "]", ",", "int", "$", "status", "=", "200", ",", "int", "$", "encodingOptions", "=", "JSON_UNESCAPED_UNICODE", ")", ":", "Response", "{", "$", "response", "=", "$", "this", ";", "// Headers", "$", "response", "=", "$", "response", "->", "withoutHeader", "(", "'Content-Type'", ")", "->", "withAddedHeader", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "$", "this", "->", "getCharset", "(", ")", "&&", "$", "response", "=", "$", "response", "->", "withCharset", "(", "$", "this", "->", "getCharset", "(", ")", ")", ";", "// Content", "if", "(", "$", "data", "&&", "(", "$", "this", "->", "isArrayable", "(", "$", "data", ")", "||", "is_string", "(", "$", "data", ")", ")", ")", "{", "is_string", "(", "$", "data", ")", "&&", "$", "data", "=", "[", "'data'", "=>", "$", "data", "]", ";", "$", "content", "=", "JsonHelper", "::", "encode", "(", "$", "data", ",", "$", "encodingOptions", ")", ";", "$", "response", "=", "$", "response", "->", "withContent", "(", "$", "content", ")", ";", "}", "else", "{", "$", "response", "=", "$", "response", "->", "withContent", "(", "'{}'", ")", ";", "}", "// Status code", "$", "status", "&&", "$", "response", "=", "$", "response", "->", "withStatus", "(", "$", "status", ")", ";", "return", "$", "response", ";", "}" ]
return a Json format response @param array|Arrayable $data The data @param int $status The HTTP status code. @param int $encodingOptions Json encoding options @return static when $data not jsonable @throws \InvalidArgumentException
[ "return", "a", "Json", "format", "response" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Response.php#L96-L118
232,973
swoft-cloud/swoft-http-message
src/Server/Response.php
Response.withCookie
public function withCookie(Cookie $cookie) { $clone = clone $this; $clone->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie; return $clone; }
php
public function withCookie(Cookie $cookie) { $clone = clone $this; $clone->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie; return $clone; }
[ "public", "function", "withCookie", "(", "Cookie", "$", "cookie", ")", "{", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "cookies", "[", "$", "cookie", "->", "getDomain", "(", ")", "]", "[", "$", "cookie", "->", "getPath", "(", ")", "]", "[", "$", "cookie", "->", "getName", "(", ")", "]", "=", "$", "cookie", ";", "return", "$", "clone", ";", "}" ]
Return an instance with specified cookies. @param Cookie $cookie @return static
[ "Return", "an", "instance", "with", "specified", "cookies", "." ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Response.php#L182-L187
232,974
juanmf/PdfManager
Fpdi/FpdiPdf.php
FpdiPdf.importPdf
public function importPdf($filename, $onlyPreImported = false) { $pages = $this->setSourceFile($filename); if ($onlyPreImported) { if (! ($filename instanceof Pdf)) { return; } foreach ($filename->_importedPages as $k => $tplId) { // Recycling $filename's Tpls $tpl = $filename->_tpls[$tplId]; $this->tpl++; $this->_tpls[$this->tpl] = $tpl; $this->_importedPages[$k] = $this->tpl; //use the imported page and place it at point 0,0; calculate width and height //automaticallay and ajust the page size to the size of the imported page $this->addPage(); $this->useTemplate($this->tpl, null, null, 0, 0, true); } return; } for ($i = 1; $i <= $pages; $i++) { $this->addPage(); //use the imported page and place it at point 0,0; calculate width and height //automaticallay and ajust the page size to the size of the imported page $this->useTemplate($this->importPage($i), null, null, 0, 0, true); } }
php
public function importPdf($filename, $onlyPreImported = false) { $pages = $this->setSourceFile($filename); if ($onlyPreImported) { if (! ($filename instanceof Pdf)) { return; } foreach ($filename->_importedPages as $k => $tplId) { // Recycling $filename's Tpls $tpl = $filename->_tpls[$tplId]; $this->tpl++; $this->_tpls[$this->tpl] = $tpl; $this->_importedPages[$k] = $this->tpl; //use the imported page and place it at point 0,0; calculate width and height //automaticallay and ajust the page size to the size of the imported page $this->addPage(); $this->useTemplate($this->tpl, null, null, 0, 0, true); } return; } for ($i = 1; $i <= $pages; $i++) { $this->addPage(); //use the imported page and place it at point 0,0; calculate width and height //automaticallay and ajust the page size to the size of the imported page $this->useTemplate($this->importPage($i), null, null, 0, 0, true); } }
[ "public", "function", "importPdf", "(", "$", "filename", ",", "$", "onlyPreImported", "=", "false", ")", "{", "$", "pages", "=", "$", "this", "->", "setSourceFile", "(", "$", "filename", ")", ";", "if", "(", "$", "onlyPreImported", ")", "{", "if", "(", "!", "(", "$", "filename", "instanceof", "Pdf", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "filename", "->", "_importedPages", "as", "$", "k", "=>", "$", "tplId", ")", "{", "// Recycling $filename's Tpls", "$", "tpl", "=", "$", "filename", "->", "_tpls", "[", "$", "tplId", "]", ";", "$", "this", "->", "tpl", "++", ";", "$", "this", "->", "_tpls", "[", "$", "this", "->", "tpl", "]", "=", "$", "tpl", ";", "$", "this", "->", "_importedPages", "[", "$", "k", "]", "=", "$", "this", "->", "tpl", ";", "//use the imported page and place it at point 0,0; calculate width and height", "//automaticallay and ajust the page size to the size of the imported page ", "$", "this", "->", "addPage", "(", ")", ";", "$", "this", "->", "useTemplate", "(", "$", "this", "->", "tpl", ",", "null", ",", "null", ",", "0", ",", "0", ",", "true", ")", ";", "}", "return", ";", "}", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "pages", ";", "$", "i", "++", ")", "{", "$", "this", "->", "addPage", "(", ")", ";", "//use the imported page and place it at point 0,0; calculate width and height", "//automaticallay and ajust the page size to the size of the imported page ", "$", "this", "->", "useTemplate", "(", "$", "this", "->", "importPage", "(", "$", "i", ")", ",", "null", ",", "null", ",", "0", ",", "0", ",", "true", ")", ";", "}", "}" ]
Must import an exsting PDF and allow to continue working with it. @param string|Pdf $filename Either the path or an other Pdf Instance @param boolean $onlyPreImported If $filename is a Pdf Instance, it might have already imported just some pages of its {@link FPDI#currentFilename}. if this is the case, respect that page selection instead of importing all. Optional, defaults to false.
[ "Must", "import", "an", "exsting", "PDF", "and", "allow", "to", "continue", "working", "with", "it", "." ]
0b2a199981486a08206d015e7f1e5e26397301f0
https://github.com/juanmf/PdfManager/blob/0b2a199981486a08206d015e7f1e5e26397301f0/Fpdi/FpdiPdf.php#L34-L61
232,975
mcustiel/php-simple-request
src/Validator/Items.php
Items.validateRest
private function validateRest(array $list) { $count = count($this->items); return $this->additionalItems === true || $this->validateArray( array_slice($list, $count, count($list) - $count), $this->additionalItems ); }
php
private function validateRest(array $list) { $count = count($this->items); return $this->additionalItems === true || $this->validateArray( array_slice($list, $count, count($list) - $count), $this->additionalItems ); }
[ "private", "function", "validateRest", "(", "array", "$", "list", ")", "{", "$", "count", "=", "count", "(", "$", "this", "->", "items", ")", ";", "return", "$", "this", "->", "additionalItems", "===", "true", "||", "$", "this", "->", "validateArray", "(", "array_slice", "(", "$", "list", ",", "$", "count", ",", "count", "(", "$", "list", ")", "-", "$", "count", ")", ",", "$", "this", "->", "additionalItems", ")", ";", "}" ]
Validates each element against its corresponding validator. Then, if additionalItems is a validator, checks the rest again those validators. @param array $list @return bool
[ "Validates", "each", "element", "against", "its", "corresponding", "validator", ".", "Then", "if", "additionalItems", "is", "a", "validator", "checks", "the", "rest", "again", "those", "validators", "." ]
4d0fc06092ccdff3ea488c67b394225c7243428f
https://github.com/mcustiel/php-simple-request/blob/4d0fc06092ccdff3ea488c67b394225c7243428f/src/Validator/Items.php#L116-L124
232,976
mcustiel/php-simple-request
src/Validator/Items.php
Items.validateTuple
private function validateTuple(array $tuple) { $keys = array_keys($tuple); $count = count($this->items); for ($index = 0; $index < $count; $index++) { // In the specification is not clear what to do when instance size // is less than items size. I chose to pass null and if null passes // the validation, it returns true. $value = isset($keys[$index]) ? $tuple[$keys[$index]] : null; if (!$this->items[$index]->validate($value)) { return false; } } return true; }
php
private function validateTuple(array $tuple) { $keys = array_keys($tuple); $count = count($this->items); for ($index = 0; $index < $count; $index++) { // In the specification is not clear what to do when instance size // is less than items size. I chose to pass null and if null passes // the validation, it returns true. $value = isset($keys[$index]) ? $tuple[$keys[$index]] : null; if (!$this->items[$index]->validate($value)) { return false; } } return true; }
[ "private", "function", "validateTuple", "(", "array", "$", "tuple", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "tuple", ")", ";", "$", "count", "=", "count", "(", "$", "this", "->", "items", ")", ";", "for", "(", "$", "index", "=", "0", ";", "$", "index", "<", "$", "count", ";", "$", "index", "++", ")", "{", "// In the specification is not clear what to do when instance size", "// is less than items size. I chose to pass null and if null passes", "// the validation, it returns true.", "$", "value", "=", "isset", "(", "$", "keys", "[", "$", "index", "]", ")", "?", "$", "tuple", "[", "$", "keys", "[", "$", "index", "]", "]", ":", "null", ";", "if", "(", "!", "$", "this", "->", "items", "[", "$", "index", "]", "->", "validate", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Validates each one of the elements of the array against its corresponding specified validator. @param array $tuple @return bool
[ "Validates", "each", "one", "of", "the", "elements", "of", "the", "array", "against", "its", "corresponding", "specified", "validator", "." ]
4d0fc06092ccdff3ea488c67b394225c7243428f
https://github.com/mcustiel/php-simple-request/blob/4d0fc06092ccdff3ea488c67b394225c7243428f/src/Validator/Items.php#L134-L149
232,977
mcustiel/php-simple-request
src/Validator/Items.php
Items.setItems
private function setItems($specification) { if ($specification instanceof ValidatorAnnotation) { $this->items = $this->createValidatorInstanceFromAnnotation( $specification ); } else { $this->checkSpecificationIsArray($specification); $this->items = $this->convertAnnotationsToValidators($specification); } }
php
private function setItems($specification) { if ($specification instanceof ValidatorAnnotation) { $this->items = $this->createValidatorInstanceFromAnnotation( $specification ); } else { $this->checkSpecificationIsArray($specification); $this->items = $this->convertAnnotationsToValidators($specification); } }
[ "private", "function", "setItems", "(", "$", "specification", ")", "{", "if", "(", "$", "specification", "instanceof", "ValidatorAnnotation", ")", "{", "$", "this", "->", "items", "=", "$", "this", "->", "createValidatorInstanceFromAnnotation", "(", "$", "specification", ")", ";", "}", "else", "{", "$", "this", "->", "checkSpecificationIsArray", "(", "$", "specification", ")", ";", "$", "this", "->", "items", "=", "$", "this", "->", "convertAnnotationsToValidators", "(", "$", "specification", ")", ";", "}", "}" ]
Checks and sets the specified items values. @param array|\Mcustiel\SimpleRequest\Interfaces\ValidatorInterface $specification
[ "Checks", "and", "sets", "the", "specified", "items", "values", "." ]
4d0fc06092ccdff3ea488c67b394225c7243428f
https://github.com/mcustiel/php-simple-request/blob/4d0fc06092ccdff3ea488c67b394225c7243428f/src/Validator/Items.php#L156-L166
232,978
mcustiel/php-simple-request
src/Validator/Items.php
Items.setAdditionalItems
private function setAdditionalItems($specification) { if (is_bool($specification)) { $this->additionalItems = $specification; } elseif ($specification instanceof ValidatorAnnotation) { $this->additionalItems = $this->createValidatorInstanceFromAnnotation( $specification ); } else { throw new UnspecifiedValidatorException( 'The validator is being initialized without a valid validator Annotation' ); } }
php
private function setAdditionalItems($specification) { if (is_bool($specification)) { $this->additionalItems = $specification; } elseif ($specification instanceof ValidatorAnnotation) { $this->additionalItems = $this->createValidatorInstanceFromAnnotation( $specification ); } else { throw new UnspecifiedValidatorException( 'The validator is being initialized without a valid validator Annotation' ); } }
[ "private", "function", "setAdditionalItems", "(", "$", "specification", ")", "{", "if", "(", "is_bool", "(", "$", "specification", ")", ")", "{", "$", "this", "->", "additionalItems", "=", "$", "specification", ";", "}", "elseif", "(", "$", "specification", "instanceof", "ValidatorAnnotation", ")", "{", "$", "this", "->", "additionalItems", "=", "$", "this", "->", "createValidatorInstanceFromAnnotation", "(", "$", "specification", ")", ";", "}", "else", "{", "throw", "new", "UnspecifiedValidatorException", "(", "'The validator is being initialized without a valid validator Annotation'", ")", ";", "}", "}" ]
Checks and sets the specified additionalItems. @param bool|\Mcustiel\SimpleRequest\Interfaces\ValidatorInterface $specification
[ "Checks", "and", "sets", "the", "specified", "additionalItems", "." ]
4d0fc06092ccdff3ea488c67b394225c7243428f
https://github.com/mcustiel/php-simple-request/blob/4d0fc06092ccdff3ea488c67b394225c7243428f/src/Validator/Items.php#L182-L195
232,979
mcustiel/php-simple-request
src/Validator/Items.php
Items.validateArray
private function validateArray(array $array, ValidatorInterface $validator) { foreach ($array as $item) { if (!$validator->validate($item)) { return false; } } return true; }
php
private function validateArray(array $array, ValidatorInterface $validator) { foreach ($array as $item) { if (!$validator->validate($item)) { return false; } } return true; }
[ "private", "function", "validateArray", "(", "array", "$", "array", ",", "ValidatorInterface", "$", "validator", ")", "{", "foreach", "(", "$", "array", "as", "$", "item", ")", "{", "if", "(", "!", "$", "validator", "->", "validate", "(", "$", "item", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Validates an array against a specific validator. @param array $array @param \Mcustiel\SimpleRequest\Interfaces\ValidatorInterface $validator
[ "Validates", "an", "array", "against", "a", "specific", "validator", "." ]
4d0fc06092ccdff3ea488c67b394225c7243428f
https://github.com/mcustiel/php-simple-request/blob/4d0fc06092ccdff3ea488c67b394225c7243428f/src/Validator/Items.php#L203-L212
232,980
bav-php/bav
classes/validator/ValidatorChain.php
ValidatorChain.getResult
protected function getResult() { foreach ($this->validators as $validator) { if (! $this->continueValidation($validator)) { return false; } if ($this->useValidator($validator) && $validator->isValid($this->account)) { return true; } } return false; }
php
protected function getResult() { foreach ($this->validators as $validator) { if (! $this->continueValidation($validator)) { return false; } if ($this->useValidator($validator) && $validator->isValid($this->account)) { return true; } } return false; }
[ "protected", "function", "getResult", "(", ")", "{", "foreach", "(", "$", "this", "->", "validators", "as", "$", "validator", ")", "{", "if", "(", "!", "$", "this", "->", "continueValidation", "(", "$", "validator", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "useValidator", "(", "$", "validator", ")", "&&", "$", "validator", "->", "isValid", "(", "$", "this", "->", "account", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Iterates through the validators. @return bool
[ "Iterates", "through", "the", "validators", "." ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/validator/ValidatorChain.php#L58-L72
232,981
sebastiansulinski/dotenv
src/DotEnv/DotEnv.php
DotEnv.load
public function load(): self { $this->loader = new Loader($this->files, true); $this->loader->load(); return $this; }
php
public function load(): self { $this->loader = new Loader($this->files, true); $this->loader->load(); return $this; }
[ "public", "function", "load", "(", ")", ":", "self", "{", "$", "this", "->", "loader", "=", "new", "Loader", "(", "$", "this", "->", "files", ",", "true", ")", ";", "$", "this", "->", "loader", "->", "load", "(", ")", ";", "return", "$", "this", ";", "}" ]
Load the files and set new environment variables without overwriting the existing ones. @return \SSD\DotEnv\DotEnv
[ "Load", "the", "files", "and", "set", "new", "environment", "variables", "without", "overwriting", "the", "existing", "ones", "." ]
a298fa533e641aa7ea4cbf89061613226de87bd4
https://github.com/sebastiansulinski/dotenv/blob/a298fa533e641aa7ea4cbf89061613226de87bd4/src/DotEnv/DotEnv.php#L47-L53
232,982
sebastiansulinski/dotenv
src/DotEnv/DotEnv.php
DotEnv.overload
public function overload(): self { $this->loader = new Loader($this->files); $this->loader->load(); return $this; }
php
public function overload(): self { $this->loader = new Loader($this->files); $this->loader->load(); return $this; }
[ "public", "function", "overload", "(", ")", ":", "self", "{", "$", "this", "->", "loader", "=", "new", "Loader", "(", "$", "this", "->", "files", ")", ";", "$", "this", "->", "loader", "->", "load", "(", ")", ";", "return", "$", "this", ";", "}" ]
Load the files and set new environment variables overwriting the existing ones. @return \SSD\DotEnv\DotEnv
[ "Load", "the", "files", "and", "set", "new", "environment", "variables", "overwriting", "the", "existing", "ones", "." ]
a298fa533e641aa7ea4cbf89061613226de87bd4
https://github.com/sebastiansulinski/dotenv/blob/a298fa533e641aa7ea4cbf89061613226de87bd4/src/DotEnv/DotEnv.php#L61-L67
232,983
sebastiansulinski/dotenv
src/DotEnv/DotEnv.php
DotEnv.toArray
public function toArray(string $loadingMethod = null): array { $this->loader = new Loader($this->files); return $this->loader->toArray($loadingMethod); }
php
public function toArray(string $loadingMethod = null): array { $this->loader = new Loader($this->files); return $this->loader->toArray($loadingMethod); }
[ "public", "function", "toArray", "(", "string", "$", "loadingMethod", "=", "null", ")", ":", "array", "{", "$", "this", "->", "loader", "=", "new", "Loader", "(", "$", "this", "->", "files", ")", ";", "return", "$", "this", "->", "loader", "->", "toArray", "(", "$", "loadingMethod", ")", ";", "}" ]
Fetch variables as array without setting environment variables. @param string|null $loadingMethod @return array
[ "Fetch", "variables", "as", "array", "without", "setting", "environment", "variables", "." ]
a298fa533e641aa7ea4cbf89061613226de87bd4
https://github.com/sebastiansulinski/dotenv/blob/a298fa533e641aa7ea4cbf89061613226de87bd4/src/DotEnv/DotEnv.php#L76-L81
232,984
sebastiansulinski/dotenv
src/DotEnv/DotEnv.php
DotEnv.get
public static function get(string $name, $default = null) { $value = getenv($name); if ($value === false) { return static::value($default); } switch (strtolower($value)) { case 'true': case '(true)': return true; case 'false': case '(false)': return false; case 'null': case '(null)': return null; } return static::sanitise($value); }
php
public static function get(string $name, $default = null) { $value = getenv($name); if ($value === false) { return static::value($default); } switch (strtolower($value)) { case 'true': case '(true)': return true; case 'false': case '(false)': return false; case 'null': case '(null)': return null; } return static::sanitise($value); }
[ "public", "static", "function", "get", "(", "string", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "getenv", "(", "$", "name", ")", ";", "if", "(", "$", "value", "===", "false", ")", "{", "return", "static", "::", "value", "(", "$", "default", ")", ";", "}", "switch", "(", "strtolower", "(", "$", "value", ")", ")", "{", "case", "'true'", ":", "case", "'(true)'", ":", "return", "true", ";", "case", "'false'", ":", "case", "'(false)'", ":", "return", "false", ";", "case", "'null'", ":", "case", "'(null)'", ":", "return", "null", ";", "}", "return", "static", "::", "sanitise", "(", "$", "value", ")", ";", "}" ]
Pull value associated with the environment variable. @param string $name @param mixed|null $default @return mixed
[ "Pull", "value", "associated", "with", "the", "environment", "variable", "." ]
a298fa533e641aa7ea4cbf89061613226de87bd4
https://github.com/sebastiansulinski/dotenv/blob/a298fa533e641aa7ea4cbf89061613226de87bd4/src/DotEnv/DotEnv.php#L101-L124
232,985
sebastiansulinski/dotenv
src/DotEnv/DotEnv.php
DotEnv.is
public static function is(string $name, $value): bool { if (!static::has($name)) { return false; } return static::get($name) == $value; }
php
public static function is(string $name, $value): bool { if (!static::has($name)) { return false; } return static::get($name) == $value; }
[ "public", "static", "function", "is", "(", "string", "$", "name", ",", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "has", "(", "$", "name", ")", ")", "{", "return", "false", ";", "}", "return", "static", "::", "get", "(", "$", "name", ")", "==", "$", "value", ";", "}" ]
Check if variable with a given key has a given value. @param string $name @param mixed $value @return bool
[ "Check", "if", "variable", "with", "a", "given", "key", "has", "a", "given", "value", "." ]
a298fa533e641aa7ea4cbf89061613226de87bd4
https://github.com/sebastiansulinski/dotenv/blob/a298fa533e641aa7ea4cbf89061613226de87bd4/src/DotEnv/DotEnv.php#L160-L167
232,986
chillerlan/php-bbcode
src/Output/HTML/HTMLSanitizer.php
HTMLSanitizer.sanitizeInput
public function sanitizeInput(string $content):string{ return htmlspecialchars($content, ENT_NOQUOTES | ENT_SUBSTITUTE | ENT_DISALLOWED | ENT_HTML5, 'UTF-8', false); }
php
public function sanitizeInput(string $content):string{ return htmlspecialchars($content, ENT_NOQUOTES | ENT_SUBSTITUTE | ENT_DISALLOWED | ENT_HTML5, 'UTF-8', false); }
[ "public", "function", "sanitizeInput", "(", "string", "$", "content", ")", ":", "string", "{", "return", "htmlspecialchars", "(", "$", "content", ",", "ENT_NOQUOTES", "|", "ENT_SUBSTITUTE", "|", "ENT_DISALLOWED", "|", "ENT_HTML5", ",", "'UTF-8'", ",", "false", ")", ";", "}" ]
Sanitizes the input before parsing to prevent vulnerabilities or compatibility problems. @param $content string to sanitize @return string
[ "Sanitizes", "the", "input", "before", "parsing", "to", "prevent", "vulnerabilities", "or", "compatibility", "problems", "." ]
902bdcce41ffc74ae4c419a6890268468d6741b2
https://github.com/chillerlan/php-bbcode/blob/902bdcce41ffc74ae4c419a6890268468d6741b2/src/Output/HTML/HTMLSanitizer.php#L26-L28
232,987
silverstripe-archive/deploynaut
code/model/jobs/DNDeployment.php
DNDeployment.ResqueStatus
public function ResqueStatus() { $status = new Resque_Job_Status($this->ResqueToken); $statusCode = $status->get(); // The Resque job can no longer be found, fallback to the DNDeployment.Status if($statusCode === false) { // Translate from the DNDeployment.Status to the Resque job status for UI purposes switch($this->Status) { case 'Finished': return 'Complete'; case 'Started': return 'Running'; default: return $this->Status; } } return self::map_resque_status($statusCode); }
php
public function ResqueStatus() { $status = new Resque_Job_Status($this->ResqueToken); $statusCode = $status->get(); // The Resque job can no longer be found, fallback to the DNDeployment.Status if($statusCode === false) { // Translate from the DNDeployment.Status to the Resque job status for UI purposes switch($this->Status) { case 'Finished': return 'Complete'; case 'Started': return 'Running'; default: return $this->Status; } } return self::map_resque_status($statusCode); }
[ "public", "function", "ResqueStatus", "(", ")", "{", "$", "status", "=", "new", "Resque_Job_Status", "(", "$", "this", "->", "ResqueToken", ")", ";", "$", "statusCode", "=", "$", "status", "->", "get", "(", ")", ";", "// The Resque job can no longer be found, fallback to the DNDeployment.Status", "if", "(", "$", "statusCode", "===", "false", ")", "{", "// Translate from the DNDeployment.Status to the Resque job status for UI purposes", "switch", "(", "$", "this", "->", "Status", ")", "{", "case", "'Finished'", ":", "return", "'Complete'", ";", "case", "'Started'", ":", "return", "'Running'", ";", "default", ":", "return", "$", "this", "->", "Status", ";", "}", "}", "return", "self", "::", "map_resque_status", "(", "$", "statusCode", ")", ";", "}" ]
Returns the status of the resque job @return string
[ "Returns", "the", "status", "of", "the", "resque", "job" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/jobs/DNDeployment.php#L100-L116
232,988
silverstripe-archive/deploynaut
code/model/jobs/DNDeployment.php
DNDeployment.enqueueDeployment
protected function enqueueDeployment() { $environment = $this->Environment(); $project = $environment->Project(); $log = $this->log(); $args = array( 'environmentName' => $environment->Name, 'sha' => $this->SHA, 'repository' => $project->LocalCVSPath, 'logfile' => $this->logfile(), 'projectName' => $project->Name, 'env' => $project->getProcessEnv(), 'deploymentID' => $this->ID, 'leaveMaintenacePage' => $this->LeaveMaintenacePage ); if(!$this->DeployerID) { $this->DeployerID = Member::currentUserID(); } if($this->DeployerID) { $deployer = $this->Deployer(); $message = sprintf( 'Deploy to %s initiated by %s (%s), with IP address %s', $environment->getFullName(), $deployer->getName(), $deployer->Email, Controller::curr()->getRequest()->getIP() ); $log->write($message); } return Resque::enqueue('deploy', 'DeployJob', $args, true); }
php
protected function enqueueDeployment() { $environment = $this->Environment(); $project = $environment->Project(); $log = $this->log(); $args = array( 'environmentName' => $environment->Name, 'sha' => $this->SHA, 'repository' => $project->LocalCVSPath, 'logfile' => $this->logfile(), 'projectName' => $project->Name, 'env' => $project->getProcessEnv(), 'deploymentID' => $this->ID, 'leaveMaintenacePage' => $this->LeaveMaintenacePage ); if(!$this->DeployerID) { $this->DeployerID = Member::currentUserID(); } if($this->DeployerID) { $deployer = $this->Deployer(); $message = sprintf( 'Deploy to %s initiated by %s (%s), with IP address %s', $environment->getFullName(), $deployer->getName(), $deployer->Email, Controller::curr()->getRequest()->getIP() ); $log->write($message); } return Resque::enqueue('deploy', 'DeployJob', $args, true); }
[ "protected", "function", "enqueueDeployment", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "Environment", "(", ")", ";", "$", "project", "=", "$", "environment", "->", "Project", "(", ")", ";", "$", "log", "=", "$", "this", "->", "log", "(", ")", ";", "$", "args", "=", "array", "(", "'environmentName'", "=>", "$", "environment", "->", "Name", ",", "'sha'", "=>", "$", "this", "->", "SHA", ",", "'repository'", "=>", "$", "project", "->", "LocalCVSPath", ",", "'logfile'", "=>", "$", "this", "->", "logfile", "(", ")", ",", "'projectName'", "=>", "$", "project", "->", "Name", ",", "'env'", "=>", "$", "project", "->", "getProcessEnv", "(", ")", ",", "'deploymentID'", "=>", "$", "this", "->", "ID", ",", "'leaveMaintenacePage'", "=>", "$", "this", "->", "LeaveMaintenacePage", ")", ";", "if", "(", "!", "$", "this", "->", "DeployerID", ")", "{", "$", "this", "->", "DeployerID", "=", "Member", "::", "currentUserID", "(", ")", ";", "}", "if", "(", "$", "this", "->", "DeployerID", ")", "{", "$", "deployer", "=", "$", "this", "->", "Deployer", "(", ")", ";", "$", "message", "=", "sprintf", "(", "'Deploy to %s initiated by %s (%s), with IP address %s'", ",", "$", "environment", "->", "getFullName", "(", ")", ",", "$", "deployer", "->", "getName", "(", ")", ",", "$", "deployer", "->", "Email", ",", "Controller", "::", "curr", "(", ")", "->", "getRequest", "(", ")", "->", "getIP", "(", ")", ")", ";", "$", "log", "->", "write", "(", "$", "message", ")", ";", "}", "return", "Resque", "::", "enqueue", "(", "'deploy'", ",", "'DeployJob'", ",", "$", "args", ",", "true", ")", ";", "}" ]
Start a resque job for this deployment @return string Resque token
[ "Start", "a", "resque", "job", "for", "this", "deployment" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/jobs/DNDeployment.php#L123-L156
232,989
irishdan/PDFTronBundle
Services/PDFToXODConverter.php
PDFToXODConverter.createXODOutputOptions
protected function createXODOutputOptions($options = []) { $xodOptions = new \XODOutputOptions(); foreach ($options as $optionKey => $optionValue) { // Convert to camel case. $converter = new CamelCaseToSnakeCaseNameConverter(); $camel = $converter->denormalize($optionKey); $setter = 'set' . $camel; // if setter exists set te value. if (method_exists($xodOptions, $setter)) { $xodOptions->{$setter}($optionValue); } } return $xodOptions; }
php
protected function createXODOutputOptions($options = []) { $xodOptions = new \XODOutputOptions(); foreach ($options as $optionKey => $optionValue) { // Convert to camel case. $converter = new CamelCaseToSnakeCaseNameConverter(); $camel = $converter->denormalize($optionKey); $setter = 'set' . $camel; // if setter exists set te value. if (method_exists($xodOptions, $setter)) { $xodOptions->{$setter}($optionValue); } } return $xodOptions; }
[ "protected", "function", "createXODOutputOptions", "(", "$", "options", "=", "[", "]", ")", "{", "$", "xodOptions", "=", "new", "\\", "XODOutputOptions", "(", ")", ";", "foreach", "(", "$", "options", "as", "$", "optionKey", "=>", "$", "optionValue", ")", "{", "// Convert to camel case.", "$", "converter", "=", "new", "CamelCaseToSnakeCaseNameConverter", "(", ")", ";", "$", "camel", "=", "$", "converter", "->", "denormalize", "(", "$", "optionKey", ")", ";", "$", "setter", "=", "'set'", ".", "$", "camel", ";", "// if setter exists set te value.", "if", "(", "method_exists", "(", "$", "xodOptions", ",", "$", "setter", ")", ")", "{", "$", "xodOptions", "->", "{", "$", "setter", "}", "(", "$", "optionValue", ")", ";", "}", "}", "return", "$", "xodOptions", ";", "}" ]
Creates an XODOutputOptions object to customise XOD output. @param array $options @return \XODOutputOptions
[ "Creates", "an", "XODOutputOptions", "object", "to", "customise", "XOD", "output", "." ]
72926bf9a39256a8438b320f61ec071be3c5a655
https://github.com/irishdan/PDFTronBundle/blob/72926bf9a39256a8438b320f61ec071be3c5a655/Services/PDFToXODConverter.php#L56-L72
232,990
dmitriybelyy/yii2-cassandra-cql
Cache.php
Cache.createTable
public function createTable() { if ($this->cassandra instanceof Connection) { $cql = 'CREATE TABLE IF NOT EXISTS ' . $this->getTableFullName() . " ( key text PRIMARY KEY, value blob ) WITH COMPACT STORAGE AND bloom_filter_fp_chance=0.001000 AND caching='ALL' AND comment='Used for cassandra caching at yii2' AND dclocal_read_repair_chance=0.000000 AND gc_grace_seconds=86400 AND read_repair_chance=0.100000 AND replicate_on_write='true' AND populate_io_cache_on_flush='false' AND compaction={'class': 'LeveledCompactionStrategy', 'sstable_size_in_mb': 256} AND compression={'sstable_compression': 'DeflateCompressor'};"; $this->cassandra->cql3Query($cql); } }
php
public function createTable() { if ($this->cassandra instanceof Connection) { $cql = 'CREATE TABLE IF NOT EXISTS ' . $this->getTableFullName() . " ( key text PRIMARY KEY, value blob ) WITH COMPACT STORAGE AND bloom_filter_fp_chance=0.001000 AND caching='ALL' AND comment='Used for cassandra caching at yii2' AND dclocal_read_repair_chance=0.000000 AND gc_grace_seconds=86400 AND read_repair_chance=0.100000 AND replicate_on_write='true' AND populate_io_cache_on_flush='false' AND compaction={'class': 'LeveledCompactionStrategy', 'sstable_size_in_mb': 256} AND compression={'sstable_compression': 'DeflateCompressor'};"; $this->cassandra->cql3Query($cql); } }
[ "public", "function", "createTable", "(", ")", "{", "if", "(", "$", "this", "->", "cassandra", "instanceof", "Connection", ")", "{", "$", "cql", "=", "'CREATE TABLE IF NOT EXISTS '", ".", "$", "this", "->", "getTableFullName", "(", ")", ".", "\" (\n key text PRIMARY KEY,\n value blob\n ) WITH COMPACT STORAGE AND\n bloom_filter_fp_chance=0.001000 AND\n caching='ALL' AND\n comment='Used for cassandra caching at yii2' AND\n dclocal_read_repair_chance=0.000000 AND\n gc_grace_seconds=86400 AND\n read_repair_chance=0.100000 AND\n replicate_on_write='true' AND\n populate_io_cache_on_flush='false' AND\n compaction={'class': 'LeveledCompactionStrategy', 'sstable_size_in_mb': 256} AND\n compression={'sstable_compression': 'DeflateCompressor'};\"", ";", "$", "this", "->", "cassandra", "->", "cql3Query", "(", "$", "cql", ")", ";", "}", "}" ]
Init cache table. You must run this manually once.
[ "Init", "cache", "table", ".", "You", "must", "run", "this", "manually", "once", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/Cache.php#L58-L78
232,991
dmitriybelyy/yii2-cassandra-cql
Cache.php
Cache.getTableFullName
protected function getTableFullName() { $prefix = !empty($this->tablePrefix) && is_string($this->tablePrefix) ? $this->tablePrefix . '_' : ''; return $prefix . $this->tableName; }
php
protected function getTableFullName() { $prefix = !empty($this->tablePrefix) && is_string($this->tablePrefix) ? $this->tablePrefix . '_' : ''; return $prefix . $this->tableName; }
[ "protected", "function", "getTableFullName", "(", ")", "{", "$", "prefix", "=", "!", "empty", "(", "$", "this", "->", "tablePrefix", ")", "&&", "is_string", "(", "$", "this", "->", "tablePrefix", ")", "?", "$", "this", "->", "tablePrefix", ".", "'_'", ":", "''", ";", "return", "$", "prefix", ".", "$", "this", "->", "tableName", ";", "}" ]
Get full table name if you use prefix. @return string
[ "Get", "full", "table", "name", "if", "you", "use", "prefix", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/Cache.php#L177-L181
232,992
mcustiel/php-simple-request
src/Strategies/Properties/PropertyParserToObject.php
PropertyParserToObject.createInstanceOfTypeFromValue
private function createInstanceOfTypeFromValue($value) { if (!isset($value)) { return null; } if (class_exists($this->type)) { return $this->requestBuilder->parseRequest($value, $this->type); } throw new InvalidAnnotationException( "Class {$this->type} does not exist. Annotated in property {$this->name}." ); }
php
private function createInstanceOfTypeFromValue($value) { if (!isset($value)) { return null; } if (class_exists($this->type)) { return $this->requestBuilder->parseRequest($value, $this->type); } throw new InvalidAnnotationException( "Class {$this->type} does not exist. Annotated in property {$this->name}." ); }
[ "private", "function", "createInstanceOfTypeFromValue", "(", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "value", ")", ")", "{", "return", "null", ";", "}", "if", "(", "class_exists", "(", "$", "this", "->", "type", ")", ")", "{", "return", "$", "this", "->", "requestBuilder", "->", "parseRequest", "(", "$", "value", ",", "$", "this", "->", "type", ")", ";", "}", "throw", "new", "InvalidAnnotationException", "(", "\"Class {$this->type} does not exist. Annotated in property {$this->name}.\"", ")", ";", "}" ]
Parses the value as it is an instance of the class specified in type property. @param array|\stdClass $value The value to parse and convert to an object @throws \Mcustiel\SimpleRequest\Exception\InvalidAnnotationException @return object Parsed value as instance of class specified in type property
[ "Parses", "the", "value", "as", "it", "is", "an", "instance", "of", "the", "class", "specified", "in", "type", "property", "." ]
4d0fc06092ccdff3ea488c67b394225c7243428f
https://github.com/mcustiel/php-simple-request/blob/4d0fc06092ccdff3ea488c67b394225c7243428f/src/Strategies/Properties/PropertyParserToObject.php#L49-L60
232,993
silverstripe-archive/deploynaut
code/control/DNRoot.php
DNRoot.getUploadSnapshotForm
public function getUploadSnapshotForm(SS_HTTPRequest $request) { // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if(!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404); } if(!$project->canUploadArchive()) { return new SS_HTTPResponse("Not allowed to upload", 401); } // Framing an environment as a "group of people with download access" // makes more sense to the user here, while still allowing us to enforce // environment specific restrictions on downloading the file later on. $envs = $project->DNEnvironmentList()->filterByCallback(function($item) {return $item->canUploadArchive();}); $envsMap = array(); foreach($envs as $env) { $envsMap[$env->ID] = $env->Name; } $maxSize = min(File::ini2bytes(ini_get('upload_max_filesize')), File::ini2bytes(ini_get('post_max_size'))); $fileField = DataArchiveFileField::create('ArchiveFile', 'File'); $fileField->getValidator()->setAllowedExtensions(array('sspak')); $fileField->getValidator()->setAllowedMaxFileSize(array('*' => $maxSize)); $form = new Form( $this, 'UploadSnapshotForm', new FieldList( $fileField, DropdownField::create('Mode', 'What does this file contain?', DNDataArchive::get_mode_map()), DropdownField::create('EnvironmentID', 'Initial ownership of the file', $envsMap) ), new FieldList( $action = new FormAction('doUploadSnapshot', "Upload File") ), new RequiredFields('ArchiveFile') ); $action->addExtraClass('btn'); $form->disableSecurityToken(); $form->addExtraClass('fields-wide'); // Tweak the action so it plays well with our fake URL structure. $form->setFormAction($project->Link().'/UploadSnapshotForm'); return $form; }
php
public function getUploadSnapshotForm(SS_HTTPRequest $request) { // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if(!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404); } if(!$project->canUploadArchive()) { return new SS_HTTPResponse("Not allowed to upload", 401); } // Framing an environment as a "group of people with download access" // makes more sense to the user here, while still allowing us to enforce // environment specific restrictions on downloading the file later on. $envs = $project->DNEnvironmentList()->filterByCallback(function($item) {return $item->canUploadArchive();}); $envsMap = array(); foreach($envs as $env) { $envsMap[$env->ID] = $env->Name; } $maxSize = min(File::ini2bytes(ini_get('upload_max_filesize')), File::ini2bytes(ini_get('post_max_size'))); $fileField = DataArchiveFileField::create('ArchiveFile', 'File'); $fileField->getValidator()->setAllowedExtensions(array('sspak')); $fileField->getValidator()->setAllowedMaxFileSize(array('*' => $maxSize)); $form = new Form( $this, 'UploadSnapshotForm', new FieldList( $fileField, DropdownField::create('Mode', 'What does this file contain?', DNDataArchive::get_mode_map()), DropdownField::create('EnvironmentID', 'Initial ownership of the file', $envsMap) ), new FieldList( $action = new FormAction('doUploadSnapshot', "Upload File") ), new RequiredFields('ArchiveFile') ); $action->addExtraClass('btn'); $form->disableSecurityToken(); $form->addExtraClass('fields-wide'); // Tweak the action so it plays well with our fake URL structure. $form->setFormAction($project->Link().'/UploadSnapshotForm'); return $form; }
[ "public", "function", "getUploadSnapshotForm", "(", "SS_HTTPRequest", "$", "request", ")", "{", "// Performs canView permission check by limiting visible projects", "$", "project", "=", "$", "this", "->", "getCurrentProject", "(", ")", ";", "if", "(", "!", "$", "project", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Project '\"", ".", "Convert", "::", "raw2xml", "(", "$", "request", "->", "latestParam", "(", "'Project'", ")", ")", ".", "\"' not found.\"", ",", "404", ")", ";", "}", "if", "(", "!", "$", "project", "->", "canUploadArchive", "(", ")", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Not allowed to upload\"", ",", "401", ")", ";", "}", "// Framing an environment as a \"group of people with download access\"", "// makes more sense to the user here, while still allowing us to enforce", "// environment specific restrictions on downloading the file later on.", "$", "envs", "=", "$", "project", "->", "DNEnvironmentList", "(", ")", "->", "filterByCallback", "(", "function", "(", "$", "item", ")", "{", "return", "$", "item", "->", "canUploadArchive", "(", ")", ";", "}", ")", ";", "$", "envsMap", "=", "array", "(", ")", ";", "foreach", "(", "$", "envs", "as", "$", "env", ")", "{", "$", "envsMap", "[", "$", "env", "->", "ID", "]", "=", "$", "env", "->", "Name", ";", "}", "$", "maxSize", "=", "min", "(", "File", "::", "ini2bytes", "(", "ini_get", "(", "'upload_max_filesize'", ")", ")", ",", "File", "::", "ini2bytes", "(", "ini_get", "(", "'post_max_size'", ")", ")", ")", ";", "$", "fileField", "=", "DataArchiveFileField", "::", "create", "(", "'ArchiveFile'", ",", "'File'", ")", ";", "$", "fileField", "->", "getValidator", "(", ")", "->", "setAllowedExtensions", "(", "array", "(", "'sspak'", ")", ")", ";", "$", "fileField", "->", "getValidator", "(", ")", "->", "setAllowedMaxFileSize", "(", "array", "(", "'*'", "=>", "$", "maxSize", ")", ")", ";", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "'UploadSnapshotForm'", ",", "new", "FieldList", "(", "$", "fileField", ",", "DropdownField", "::", "create", "(", "'Mode'", ",", "'What does this file contain?'", ",", "DNDataArchive", "::", "get_mode_map", "(", ")", ")", ",", "DropdownField", "::", "create", "(", "'EnvironmentID'", ",", "'Initial ownership of the file'", ",", "$", "envsMap", ")", ")", ",", "new", "FieldList", "(", "$", "action", "=", "new", "FormAction", "(", "'doUploadSnapshot'", ",", "\"Upload File\"", ")", ")", ",", "new", "RequiredFields", "(", "'ArchiveFile'", ")", ")", ";", "$", "action", "->", "addExtraClass", "(", "'btn'", ")", ";", "$", "form", "->", "disableSecurityToken", "(", ")", ";", "$", "form", "->", "addExtraClass", "(", "'fields-wide'", ")", ";", "// Tweak the action so it plays well with our fake URL structure.", "$", "form", "->", "setFormAction", "(", "$", "project", "->", "Link", "(", ")", ".", "'/UploadSnapshotForm'", ")", ";", "return", "$", "form", ";", "}" ]
Construct the upload form. @param SS_HTTPRequest $request @return Form
[ "Construct", "the", "upload", "form", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/control/DNRoot.php#L254-L299
232,994
silverstripe-archive/deploynaut
code/control/DNRoot.php
DNRoot.beginPipeline
protected function beginPipeline($data, $form, $isDryRun = false) { $buildName = $form->getSelectedBuild($data); // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if(!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($this->getRequest()->latestParam('Project')) . "' not found.", 404); } // Performs canView permission check by limiting visible projects $environment = $this->getCurrentEnvironment($project); if(!$environment) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($this->getRequest()->latestParam('Environment')) . "' not found.", 404); } if(!$environment->DryRunEnabled && $isDryRun) { return new SS_HTTPResponse("Dry-run for pipelines is not enabled for this environment", 404); } // Initiate the pipeline $sha = $project->DNBuildList()->byName($buildName); $pipeline = Pipeline::create(); $pipeline->DryRun = $isDryRun; $pipeline->SkipSnapshot = !empty($data['SkipSnapshot']) && $data['SkipSnapshot']; $pipeline->EnvironmentID = $environment->ID; $pipeline->AuthorID = Member::currentUserID(); $pipeline->SHA = $sha->FullName(); // Record build at time of execution if($currentBuild = $environment->CurrentBuild()) { $pipeline->PreviousDeploymentID = $currentBuild->ID; } $pipeline->start(); // start() will call write(), so no need to do it here as well. return $this->redirect($environment->Link()); }
php
protected function beginPipeline($data, $form, $isDryRun = false) { $buildName = $form->getSelectedBuild($data); // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if(!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($this->getRequest()->latestParam('Project')) . "' not found.", 404); } // Performs canView permission check by limiting visible projects $environment = $this->getCurrentEnvironment($project); if(!$environment) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($this->getRequest()->latestParam('Environment')) . "' not found.", 404); } if(!$environment->DryRunEnabled && $isDryRun) { return new SS_HTTPResponse("Dry-run for pipelines is not enabled for this environment", 404); } // Initiate the pipeline $sha = $project->DNBuildList()->byName($buildName); $pipeline = Pipeline::create(); $pipeline->DryRun = $isDryRun; $pipeline->SkipSnapshot = !empty($data['SkipSnapshot']) && $data['SkipSnapshot']; $pipeline->EnvironmentID = $environment->ID; $pipeline->AuthorID = Member::currentUserID(); $pipeline->SHA = $sha->FullName(); // Record build at time of execution if($currentBuild = $environment->CurrentBuild()) { $pipeline->PreviousDeploymentID = $currentBuild->ID; } $pipeline->start(); // start() will call write(), so no need to do it here as well. return $this->redirect($environment->Link()); }
[ "protected", "function", "beginPipeline", "(", "$", "data", ",", "$", "form", ",", "$", "isDryRun", "=", "false", ")", "{", "$", "buildName", "=", "$", "form", "->", "getSelectedBuild", "(", "$", "data", ")", ";", "// Performs canView permission check by limiting visible projects", "$", "project", "=", "$", "this", "->", "getCurrentProject", "(", ")", ";", "if", "(", "!", "$", "project", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Project '\"", ".", "Convert", "::", "raw2xml", "(", "$", "this", "->", "getRequest", "(", ")", "->", "latestParam", "(", "'Project'", ")", ")", ".", "\"' not found.\"", ",", "404", ")", ";", "}", "// Performs canView permission check by limiting visible projects", "$", "environment", "=", "$", "this", "->", "getCurrentEnvironment", "(", "$", "project", ")", ";", "if", "(", "!", "$", "environment", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Environment '\"", ".", "Convert", "::", "raw2xml", "(", "$", "this", "->", "getRequest", "(", ")", "->", "latestParam", "(", "'Environment'", ")", ")", ".", "\"' not found.\"", ",", "404", ")", ";", "}", "if", "(", "!", "$", "environment", "->", "DryRunEnabled", "&&", "$", "isDryRun", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Dry-run for pipelines is not enabled for this environment\"", ",", "404", ")", ";", "}", "// Initiate the pipeline", "$", "sha", "=", "$", "project", "->", "DNBuildList", "(", ")", "->", "byName", "(", "$", "buildName", ")", ";", "$", "pipeline", "=", "Pipeline", "::", "create", "(", ")", ";", "$", "pipeline", "->", "DryRun", "=", "$", "isDryRun", ";", "$", "pipeline", "->", "SkipSnapshot", "=", "!", "empty", "(", "$", "data", "[", "'SkipSnapshot'", "]", ")", "&&", "$", "data", "[", "'SkipSnapshot'", "]", ";", "$", "pipeline", "->", "EnvironmentID", "=", "$", "environment", "->", "ID", ";", "$", "pipeline", "->", "AuthorID", "=", "Member", "::", "currentUserID", "(", ")", ";", "$", "pipeline", "->", "SHA", "=", "$", "sha", "->", "FullName", "(", ")", ";", "// Record build at time of execution", "if", "(", "$", "currentBuild", "=", "$", "environment", "->", "CurrentBuild", "(", ")", ")", "{", "$", "pipeline", "->", "PreviousDeploymentID", "=", "$", "currentBuild", "->", "ID", ";", "}", "$", "pipeline", "->", "start", "(", ")", ";", "// start() will call write(), so no need to do it here as well.", "return", "$", "this", "->", "redirect", "(", "$", "environment", "->", "Link", "(", ")", ")", ";", "}" ]
Start a pipeline @param array $data @param DeployForm $form @param bool $isDryRun @return \SS_HTTPResponse
[ "Start", "a", "pipeline" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/control/DNRoot.php#L621-L654
232,995
silverstripe-archive/deploynaut
code/control/DNRoot.php
DNRoot.getDeployForm
public function getDeployForm(SS_HTTPRequest $request) { // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if(!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404); } // Performs canView permission check by limiting visible projects $environment = $this->getCurrentEnvironment($project); if(!$environment) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404); } if(!$environment->canDeploy()) { return new SS_HTTPResponse("Not allowed to deploy", 401); } if(!$project->repoExists()) { $literalField = new LiteralField('noRepoWarning', '<strong>The GIT repository is for the time being not available.</strong>'); return Form::create($this, 'DeployForm', new FieldList($literalField), new FieldList()); } // Generate the form $form = new DeployForm($this, 'DeployForm', $environment, $project); // Tweak the action so it plays well with our fake URL structure. $form->setFormAction($request->getURL().'/DeployForm'); return $form; }
php
public function getDeployForm(SS_HTTPRequest $request) { // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if(!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404); } // Performs canView permission check by limiting visible projects $environment = $this->getCurrentEnvironment($project); if(!$environment) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404); } if(!$environment->canDeploy()) { return new SS_HTTPResponse("Not allowed to deploy", 401); } if(!$project->repoExists()) { $literalField = new LiteralField('noRepoWarning', '<strong>The GIT repository is for the time being not available.</strong>'); return Form::create($this, 'DeployForm', new FieldList($literalField), new FieldList()); } // Generate the form $form = new DeployForm($this, 'DeployForm', $environment, $project); // Tweak the action so it plays well with our fake URL structure. $form->setFormAction($request->getURL().'/DeployForm'); return $form; }
[ "public", "function", "getDeployForm", "(", "SS_HTTPRequest", "$", "request", ")", "{", "// Performs canView permission check by limiting visible projects", "$", "project", "=", "$", "this", "->", "getCurrentProject", "(", ")", ";", "if", "(", "!", "$", "project", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Project '\"", ".", "Convert", "::", "raw2xml", "(", "$", "request", "->", "latestParam", "(", "'Project'", ")", ")", ".", "\"' not found.\"", ",", "404", ")", ";", "}", "// Performs canView permission check by limiting visible projects", "$", "environment", "=", "$", "this", "->", "getCurrentEnvironment", "(", "$", "project", ")", ";", "if", "(", "!", "$", "environment", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Environment '\"", ".", "Convert", "::", "raw2xml", "(", "$", "request", "->", "latestParam", "(", "'Environment'", ")", ")", ".", "\"' not found.\"", ",", "404", ")", ";", "}", "if", "(", "!", "$", "environment", "->", "canDeploy", "(", ")", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Not allowed to deploy\"", ",", "401", ")", ";", "}", "if", "(", "!", "$", "project", "->", "repoExists", "(", ")", ")", "{", "$", "literalField", "=", "new", "LiteralField", "(", "'noRepoWarning'", ",", "'<strong>The GIT repository is for the time being not available.</strong>'", ")", ";", "return", "Form", "::", "create", "(", "$", "this", ",", "'DeployForm'", ",", "new", "FieldList", "(", "$", "literalField", ")", ",", "new", "FieldList", "(", ")", ")", ";", "}", "// Generate the form", "$", "form", "=", "new", "DeployForm", "(", "$", "this", ",", "'DeployForm'", ",", "$", "environment", ",", "$", "project", ")", ";", "// Tweak the action so it plays well with our fake URL structure.", "$", "form", "->", "setFormAction", "(", "$", "request", "->", "getURL", "(", ")", ".", "'/DeployForm'", ")", ";", "return", "$", "form", ";", "}" ]
Construct the deployment form @param SS_HTTPRequest $request @return Form
[ "Construct", "the", "deployment", "form" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/control/DNRoot.php#L724-L752
232,996
silverstripe-archive/deploynaut
code/control/DNRoot.php
DNRoot.doDeploy
public function doDeploy($data, $form) { $buildName = $form->getSelectedBuild($data); // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if(!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($this->getRequest()->latestParam('Project')) . "' not found.", 404); } // Performs canView permission check by limiting visible projects $environment = $this->getCurrentEnvironment($project); if(!$environment) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($this->getRequest()->latestParam('Environment')) . "' not found.", 404); } // Initiate the deployment // The extension point should pass in: Project, Environment, SelectRelease, buildName $this->extend('doDeploy', $project, $environment, $buildName, $data); $sha = $project->DNBuildList()->byName($buildName); $deployment = DNDeployment::create(); $deployment->EnvironmentID = $environment->ID; $deployment->SHA = $sha->FullName(); $deployment->write(); $deployment->start(); return $this->redirect($deployment->Link()); }
php
public function doDeploy($data, $form) { $buildName = $form->getSelectedBuild($data); // Performs canView permission check by limiting visible projects $project = $this->getCurrentProject(); if(!$project) { return new SS_HTTPResponse("Project '" . Convert::raw2xml($this->getRequest()->latestParam('Project')) . "' not found.", 404); } // Performs canView permission check by limiting visible projects $environment = $this->getCurrentEnvironment($project); if(!$environment) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($this->getRequest()->latestParam('Environment')) . "' not found.", 404); } // Initiate the deployment // The extension point should pass in: Project, Environment, SelectRelease, buildName $this->extend('doDeploy', $project, $environment, $buildName, $data); $sha = $project->DNBuildList()->byName($buildName); $deployment = DNDeployment::create(); $deployment->EnvironmentID = $environment->ID; $deployment->SHA = $sha->FullName(); $deployment->write(); $deployment->start(); return $this->redirect($deployment->Link()); }
[ "public", "function", "doDeploy", "(", "$", "data", ",", "$", "form", ")", "{", "$", "buildName", "=", "$", "form", "->", "getSelectedBuild", "(", "$", "data", ")", ";", "// Performs canView permission check by limiting visible projects", "$", "project", "=", "$", "this", "->", "getCurrentProject", "(", ")", ";", "if", "(", "!", "$", "project", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Project '\"", ".", "Convert", "::", "raw2xml", "(", "$", "this", "->", "getRequest", "(", ")", "->", "latestParam", "(", "'Project'", ")", ")", ".", "\"' not found.\"", ",", "404", ")", ";", "}", "// Performs canView permission check by limiting visible projects", "$", "environment", "=", "$", "this", "->", "getCurrentEnvironment", "(", "$", "project", ")", ";", "if", "(", "!", "$", "environment", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Environment '\"", ".", "Convert", "::", "raw2xml", "(", "$", "this", "->", "getRequest", "(", ")", "->", "latestParam", "(", "'Environment'", ")", ")", ".", "\"' not found.\"", ",", "404", ")", ";", "}", "// Initiate the deployment", "// The extension point should pass in: Project, Environment, SelectRelease, buildName", "$", "this", "->", "extend", "(", "'doDeploy'", ",", "$", "project", ",", "$", "environment", ",", "$", "buildName", ",", "$", "data", ")", ";", "$", "sha", "=", "$", "project", "->", "DNBuildList", "(", ")", "->", "byName", "(", "$", "buildName", ")", ";", "$", "deployment", "=", "DNDeployment", "::", "create", "(", ")", ";", "$", "deployment", "->", "EnvironmentID", "=", "$", "environment", "->", "ID", ";", "$", "deployment", "->", "SHA", "=", "$", "sha", "->", "FullName", "(", ")", ";", "$", "deployment", "->", "write", "(", ")", ";", "$", "deployment", "->", "start", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "deployment", "->", "Link", "(", ")", ")", ";", "}" ]
Deployment form submission handler. Initiate a DNDeployment record and redirect to it for status polling @param array $data @param DeployForm $form @return \SS_HTTPResponse
[ "Deployment", "form", "submission", "handler", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/control/DNRoot.php#L763-L789
232,997
silverstripe-archive/deploynaut
code/control/DNRoot.php
DNRoot.deploy
public function deploy(SS_HTTPRequest $request) { $params = $request->params(); $deployment = DNDeployment::get()->byId($params['Identifier']); if(!$deployment || !$deployment->ID) throw new SS_HTTPResponse_Exception('Deployment not found', 404); if(!$deployment->canView()) return Security::permissionFailure(); $environment = $deployment->Environment(); $project = $environment->Project(); if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this deploy"); if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); return $this->customise(new ArrayData(array( 'Deployment' => $deployment, )))->renderWith('DNRoot_deploy'); }
php
public function deploy(SS_HTTPRequest $request) { $params = $request->params(); $deployment = DNDeployment::get()->byId($params['Identifier']); if(!$deployment || !$deployment->ID) throw new SS_HTTPResponse_Exception('Deployment not found', 404); if(!$deployment->canView()) return Security::permissionFailure(); $environment = $deployment->Environment(); $project = $environment->Project(); if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this deploy"); if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); return $this->customise(new ArrayData(array( 'Deployment' => $deployment, )))->renderWith('DNRoot_deploy'); }
[ "public", "function", "deploy", "(", "SS_HTTPRequest", "$", "request", ")", "{", "$", "params", "=", "$", "request", "->", "params", "(", ")", ";", "$", "deployment", "=", "DNDeployment", "::", "get", "(", ")", "->", "byId", "(", "$", "params", "[", "'Identifier'", "]", ")", ";", "if", "(", "!", "$", "deployment", "||", "!", "$", "deployment", "->", "ID", ")", "throw", "new", "SS_HTTPResponse_Exception", "(", "'Deployment not found'", ",", "404", ")", ";", "if", "(", "!", "$", "deployment", "->", "canView", "(", ")", ")", "return", "Security", "::", "permissionFailure", "(", ")", ";", "$", "environment", "=", "$", "deployment", "->", "Environment", "(", ")", ";", "$", "project", "=", "$", "environment", "->", "Project", "(", ")", ";", "if", "(", "$", "environment", "->", "Name", "!=", "$", "params", "[", "'Environment'", "]", ")", "throw", "new", "LogicException", "(", "\"Environment in URL doesn't match this deploy\"", ")", ";", "if", "(", "$", "project", "->", "Name", "!=", "$", "params", "[", "'Project'", "]", ")", "throw", "new", "LogicException", "(", "\"Project in URL doesn't match this deploy\"", ")", ";", "return", "$", "this", "->", "customise", "(", "new", "ArrayData", "(", "array", "(", "'Deployment'", "=>", "$", "deployment", ",", ")", ")", ")", "->", "renderWith", "(", "'DNRoot_deploy'", ")", ";", "}" ]
Action - Do the actual deploy @param SS_HTTPRequest $request
[ "Action", "-", "Do", "the", "actual", "deploy" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/control/DNRoot.php#L796-L812
232,998
silverstripe-archive/deploynaut
code/control/DNRoot.php
DNRoot.getMoveForm
public function getMoveForm($request, $dataArchive = null) { $dataArchive = $dataArchive ? $dataArchive : DNDataArchive::get()->byId($request->requestVar('DataArchiveID')); $envs = $dataArchive->validTargetEnvironments(); if(!$envs) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404); } $form = new Form( $this, 'MoveForm', new FieldList( new HiddenField('DataArchiveID', false, $dataArchive->ID), new LiteralField('Warning', '<p class="text-warning"><strong>Warning:</strong> This will make the snapshot available to people with access to the target environment.<br>By pressing "Change ownership" you confirm that you have considered data confidentiality regulations.</p>'), new DropdownField('EnvironmentID', 'Environment', $envs->map()) ), new FieldList( FormAction::create('doMove', 'Change ownership')->addExtraClass('btn') ) ); $form->setFormAction($this->getCurrentProject()->Link() . '/MoveForm'); return $form; }
php
public function getMoveForm($request, $dataArchive = null) { $dataArchive = $dataArchive ? $dataArchive : DNDataArchive::get()->byId($request->requestVar('DataArchiveID')); $envs = $dataArchive->validTargetEnvironments(); if(!$envs) { return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404); } $form = new Form( $this, 'MoveForm', new FieldList( new HiddenField('DataArchiveID', false, $dataArchive->ID), new LiteralField('Warning', '<p class="text-warning"><strong>Warning:</strong> This will make the snapshot available to people with access to the target environment.<br>By pressing "Change ownership" you confirm that you have considered data confidentiality regulations.</p>'), new DropdownField('EnvironmentID', 'Environment', $envs->map()) ), new FieldList( FormAction::create('doMove', 'Change ownership')->addExtraClass('btn') ) ); $form->setFormAction($this->getCurrentProject()->Link() . '/MoveForm'); return $form; }
[ "public", "function", "getMoveForm", "(", "$", "request", ",", "$", "dataArchive", "=", "null", ")", "{", "$", "dataArchive", "=", "$", "dataArchive", "?", "$", "dataArchive", ":", "DNDataArchive", "::", "get", "(", ")", "->", "byId", "(", "$", "request", "->", "requestVar", "(", "'DataArchiveID'", ")", ")", ";", "$", "envs", "=", "$", "dataArchive", "->", "validTargetEnvironments", "(", ")", ";", "if", "(", "!", "$", "envs", ")", "{", "return", "new", "SS_HTTPResponse", "(", "\"Environment '\"", ".", "Convert", "::", "raw2xml", "(", "$", "request", "->", "latestParam", "(", "'Environment'", ")", ")", ".", "\"' not found.\"", ",", "404", ")", ";", "}", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "'MoveForm'", ",", "new", "FieldList", "(", "new", "HiddenField", "(", "'DataArchiveID'", ",", "false", ",", "$", "dataArchive", "->", "ID", ")", ",", "new", "LiteralField", "(", "'Warning'", ",", "'<p class=\"text-warning\"><strong>Warning:</strong> This will make the snapshot available to people with access to the target environment.<br>By pressing \"Change ownership\" you confirm that you have considered data confidentiality regulations.</p>'", ")", ",", "new", "DropdownField", "(", "'EnvironmentID'", ",", "'Environment'", ",", "$", "envs", "->", "map", "(", ")", ")", ")", ",", "new", "FieldList", "(", "FormAction", "::", "create", "(", "'doMove'", ",", "'Change ownership'", ")", "->", "addExtraClass", "(", "'btn'", ")", ")", ")", ";", "$", "form", "->", "setFormAction", "(", "$", "this", "->", "getCurrentProject", "(", ")", "->", "Link", "(", ")", ".", "'/MoveForm'", ")", ";", "return", "$", "form", ";", "}" ]
Build snapshot move form.
[ "Build", "snapshot", "move", "form", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/control/DNRoot.php#L1195-L1218
232,999
phillies2k/ratchet-bundle
WebSocket/Payload.php
Payload.decode
public static function decode($msg) { try { $data = json_decode($msg, true); return $data; } catch (\Exception $e) { throw new \InvalidArgumentException('Invalid json format'); } }
php
public static function decode($msg) { try { $data = json_decode($msg, true); return $data; } catch (\Exception $e) { throw new \InvalidArgumentException('Invalid json format'); } }
[ "public", "static", "function", "decode", "(", "$", "msg", ")", "{", "try", "{", "$", "data", "=", "json_decode", "(", "$", "msg", ",", "true", ")", ";", "return", "$", "data", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid json format'", ")", ";", "}", "}" ]
Decodes the given string input and returns an array of data for this payload. Throws InvalidArgumentException on decoding errors. @param string $msg @return array @throws \InvalidArgumentException
[ "Decodes", "the", "given", "string", "input", "and", "returns", "an", "array", "of", "data", "for", "this", "payload", ".", "Throws", "InvalidArgumentException", "on", "decoding", "errors", "." ]
1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3
https://github.com/phillies2k/ratchet-bundle/blob/1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3/WebSocket/Payload.php#L57-L66