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
231,600
sjdaws/vocal
src/Sjdaws/Vocal/Vocal.php
Vocal.setRelationship
private function setRelationship(Vocal $record, $relationship, $class, $index) { // If we have an index we're dealing with a many relationship if ($index !== null) { $collection = ($this->{$relationship}) ? $this->{$relationship} : new Collection; $collection->put($index, $record); return $this->setRelation($relationship, $collection); } // belongsTo and morphTo become parent records via associate $model = $this->{$class}(); if (method_exists($model, 'associate')) { return $model->associate($record)->forceSave(); } else { return $this->setRelation($relationship, $record); } }
php
private function setRelationship(Vocal $record, $relationship, $class, $index) { // If we have an index we're dealing with a many relationship if ($index !== null) { $collection = ($this->{$relationship}) ? $this->{$relationship} : new Collection; $collection->put($index, $record); return $this->setRelation($relationship, $collection); } // belongsTo and morphTo become parent records via associate $model = $this->{$class}(); if (method_exists($model, 'associate')) { return $model->associate($record)->forceSave(); } else { return $this->setRelation($relationship, $record); } }
[ "private", "function", "setRelationship", "(", "Vocal", "$", "record", ",", "$", "relationship", ",", "$", "class", ",", "$", "index", ")", "{", "// If we have an index we're dealing with a many relationship", "if", "(", "$", "index", "!==", "null", ")", "{", "$", "collection", "=", "(", "$", "this", "->", "{", "$", "relationship", "}", ")", "?", "$", "this", "->", "{", "$", "relationship", "}", ":", "new", "Collection", ";", "$", "collection", "->", "put", "(", "$", "index", ",", "$", "record", ")", ";", "return", "$", "this", "->", "setRelation", "(", "$", "relationship", ",", "$", "collection", ")", ";", "}", "// belongsTo and morphTo become parent records via associate", "$", "model", "=", "$", "this", "->", "{", "$", "class", "}", "(", ")", ";", "if", "(", "method_exists", "(", "$", "model", ",", "'associate'", ")", ")", "{", "return", "$", "model", "->", "associate", "(", "$", "record", ")", "->", "forceSave", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "setRelation", "(", "$", "relationship", ",", "$", "record", ")", ";", "}", "}" ]
Attach two records together via relationship @param Vocal $record @param string $relationship @param string $class @param integer|string|null $index @return \Illuminate\Database\Eloquent\Model
[ "Attach", "two", "records", "together", "via", "relationship" ]
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L1045-L1066
231,601
sjdaws/vocal
src/Sjdaws/Vocal/Vocal.php
Vocal.setRuleset
private function setRuleset(array $rules = []) { // Passed rules rule, but we will use model rules if nothing has been passed $this->rules = $this->ruleset = $this->selectRules($rules); // Expand out rules foreach ($this->rules as $field => &$rule) { // Change pipe delimited rules to arrays $set = $this->pipeToArray($rule); $rule = $this->processRuleset($field, $set); } }
php
private function setRuleset(array $rules = []) { // Passed rules rule, but we will use model rules if nothing has been passed $this->rules = $this->ruleset = $this->selectRules($rules); // Expand out rules foreach ($this->rules as $field => &$rule) { // Change pipe delimited rules to arrays $set = $this->pipeToArray($rule); $rule = $this->processRuleset($field, $set); } }
[ "private", "function", "setRuleset", "(", "array", "$", "rules", "=", "[", "]", ")", "{", "// Passed rules rule, but we will use model rules if nothing has been passed", "$", "this", "->", "rules", "=", "$", "this", "->", "ruleset", "=", "$", "this", "->", "selectRules", "(", "$", "rules", ")", ";", "// Expand out rules", "foreach", "(", "$", "this", "->", "rules", "as", "$", "field", "=>", "&", "$", "rule", ")", "{", "// Change pipe delimited rules to arrays", "$", "set", "=", "$", "this", "->", "pipeToArray", "(", "$", "rule", ")", ";", "$", "rule", "=", "$", "this", "->", "processRuleset", "(", "$", "field", ",", "$", "set", ")", ";", "}", "}" ]
Set relationship rules @param array $rules @return null
[ "Set", "relationship", "rules" ]
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L1074-L1086
231,602
sjdaws/vocal
src/Sjdaws/Vocal/Vocal.php
Vocal.timestamp
public function timestamp($value = null) { // Use now if no time was passed if ( ! $value) $value = $this->freshTimestamp(); return $this->fromDateTime($value); }
php
public function timestamp($value = null) { // Use now if no time was passed if ( ! $value) $value = $this->freshTimestamp(); return $this->fromDateTime($value); }
[ "public", "function", "timestamp", "(", "$", "value", "=", "null", ")", "{", "// Use now if no time was passed", "if", "(", "!", "$", "value", ")", "$", "value", "=", "$", "this", "->", "freshTimestamp", "(", ")", ";", "return", "$", "this", "->", "fromDateTime", "(", "$", "value", ")", ";", "}" ]
Generate a database compatible timestamp using now as default @param mixed $value @return string
[ "Generate", "a", "database", "compatible", "timestamp", "using", "now", "as", "default" ]
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L1094-L1100
231,603
sjdaws/vocal
src/Sjdaws/Vocal/Vocal.php
Vocal.usesSoftDeletes
private function usesSoftDeletes() { return ( (isset($this->forceDeleting) && ! $this->forceDeleting) || (isset($this->softDelete) && ! $this->softDelete) ); }
php
private function usesSoftDeletes() { return ( (isset($this->forceDeleting) && ! $this->forceDeleting) || (isset($this->softDelete) && ! $this->softDelete) ); }
[ "private", "function", "usesSoftDeletes", "(", ")", "{", "return", "(", "(", "isset", "(", "$", "this", "->", "forceDeleting", ")", "&&", "!", "$", "this", "->", "forceDeleting", ")", "||", "(", "isset", "(", "$", "this", "->", "softDelete", ")", "&&", "!", "$", "this", "->", "softDelete", ")", ")", ";", "}" ]
Determine if a model is using soft deletes @return bool
[ "Determine", "if", "a", "model", "is", "using", "soft", "deletes" ]
ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f
https://github.com/sjdaws/vocal/blob/ea9bc7b8bbf6c8140fe1aa285716a559f6f6cf7f/src/Sjdaws/Vocal/Vocal.php#L1107-L1113
231,604
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.init
public function init($path = null) { $path = is_null($path) ? $this->environment->path : $path; // Check if clone already exists at this path. If so we can safely skip. if (file_exists($path)) { $wrapper = new GitWrapper(); $wrapper->setTimeout(3600); try { $working_copy = new GitWorkingCopy($wrapper, $path); $output = $working_copy->remote('-v'); } catch (GitException $e) { throw new \Exception('Path already exists.'); } // if repo exists in the remotes already, this working copy is ok. if (strpos(strtolower($output), strtolower($this->app->repo)) !== false) { return true; } else { throw new Exception('Git clone already exists at that path, but it is not for this app.'); } } try { // Create App folder mkdir($path, 0755, TRUE); chdir($path); // Clone repo $wrapper = new GitWrapper(); $wrapper->setTimeout(3600); $wrapper->streamOutput(); $wrapper->cloneRepository($this->app->repo, $path); // Checkout correct version. $git = new GitWorkingCopy($wrapper, $this->getSourcePath()); $git->checkout($this->environment->version); } catch (\GitWrapper\GitException $e) { // If exception is because there is no git ref, continue. if (strpos($e->getMessage(), 'error: pathspec') !== 0) { return false; } } chdir($path); $wrapper->git('branch'); $wrapper->git('status'); $this->loadConfig(); // Run the build hooks if (!empty($this->config['hooks']['build'])) { chdir($this->getSourcePath()); $process = new Process($this->config['hooks']['build']); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo $buffer; } else { echo $buffer; } }); } return $this->writeConfig(); }
php
public function init($path = null) { $path = is_null($path) ? $this->environment->path : $path; // Check if clone already exists at this path. If so we can safely skip. if (file_exists($path)) { $wrapper = new GitWrapper(); $wrapper->setTimeout(3600); try { $working_copy = new GitWorkingCopy($wrapper, $path); $output = $working_copy->remote('-v'); } catch (GitException $e) { throw new \Exception('Path already exists.'); } // if repo exists in the remotes already, this working copy is ok. if (strpos(strtolower($output), strtolower($this->app->repo)) !== false) { return true; } else { throw new Exception('Git clone already exists at that path, but it is not for this app.'); } } try { // Create App folder mkdir($path, 0755, TRUE); chdir($path); // Clone repo $wrapper = new GitWrapper(); $wrapper->setTimeout(3600); $wrapper->streamOutput(); $wrapper->cloneRepository($this->app->repo, $path); // Checkout correct version. $git = new GitWorkingCopy($wrapper, $this->getSourcePath()); $git->checkout($this->environment->version); } catch (\GitWrapper\GitException $e) { // If exception is because there is no git ref, continue. if (strpos($e->getMessage(), 'error: pathspec') !== 0) { return false; } } chdir($path); $wrapper->git('branch'); $wrapper->git('status'); $this->loadConfig(); // Run the build hooks if (!empty($this->config['hooks']['build'])) { chdir($this->getSourcePath()); $process = new Process($this->config['hooks']['build']); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo $buffer; } else { echo $buffer; } }); } return $this->writeConfig(); }
[ "public", "function", "init", "(", "$", "path", "=", "null", ")", "{", "$", "path", "=", "is_null", "(", "$", "path", ")", "?", "$", "this", "->", "environment", "->", "path", ":", "$", "path", ";", "// Check if clone already exists at this path. If so we can safely skip.", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "$", "wrapper", "=", "new", "GitWrapper", "(", ")", ";", "$", "wrapper", "->", "setTimeout", "(", "3600", ")", ";", "try", "{", "$", "working_copy", "=", "new", "GitWorkingCopy", "(", "$", "wrapper", ",", "$", "path", ")", ";", "$", "output", "=", "$", "working_copy", "->", "remote", "(", "'-v'", ")", ";", "}", "catch", "(", "GitException", "$", "e", ")", "{", "throw", "new", "\\", "Exception", "(", "'Path already exists.'", ")", ";", "}", "// if repo exists in the remotes already, this working copy is ok.", "if", "(", "strpos", "(", "strtolower", "(", "$", "output", ")", ",", "strtolower", "(", "$", "this", "->", "app", "->", "repo", ")", ")", "!==", "false", ")", "{", "return", "true", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'Git clone already exists at that path, but it is not for this app.'", ")", ";", "}", "}", "try", "{", "// Create App folder", "mkdir", "(", "$", "path", ",", "0755", ",", "TRUE", ")", ";", "chdir", "(", "$", "path", ")", ";", "// Clone repo", "$", "wrapper", "=", "new", "GitWrapper", "(", ")", ";", "$", "wrapper", "->", "setTimeout", "(", "3600", ")", ";", "$", "wrapper", "->", "streamOutput", "(", ")", ";", "$", "wrapper", "->", "cloneRepository", "(", "$", "this", "->", "app", "->", "repo", ",", "$", "path", ")", ";", "// Checkout correct version.", "$", "git", "=", "new", "GitWorkingCopy", "(", "$", "wrapper", ",", "$", "this", "->", "getSourcePath", "(", ")", ")", ";", "$", "git", "->", "checkout", "(", "$", "this", "->", "environment", "->", "version", ")", ";", "}", "catch", "(", "\\", "GitWrapper", "\\", "GitException", "$", "e", ")", "{", "// If exception is because there is no git ref, continue.", "if", "(", "strpos", "(", "$", "e", "->", "getMessage", "(", ")", ",", "'error: pathspec'", ")", "!==", "0", ")", "{", "return", "false", ";", "}", "}", "chdir", "(", "$", "path", ")", ";", "$", "wrapper", "->", "git", "(", "'branch'", ")", ";", "$", "wrapper", "->", "git", "(", "'status'", ")", ";", "$", "this", "->", "loadConfig", "(", ")", ";", "// Run the build hooks", "if", "(", "!", "empty", "(", "$", "this", "->", "config", "[", "'hooks'", "]", "[", "'build'", "]", ")", ")", "{", "chdir", "(", "$", "this", "->", "getSourcePath", "(", ")", ")", ";", "$", "process", "=", "new", "Process", "(", "$", "this", "->", "config", "[", "'hooks'", "]", "[", "'build'", "]", ")", ";", "$", "process", "->", "run", "(", "function", "(", "$", "type", ",", "$", "buffer", ")", "{", "if", "(", "Process", "::", "ERR", "===", "$", "type", ")", "{", "echo", "$", "buffer", ";", "}", "else", "{", "echo", "$", "buffer", ";", "}", "}", ")", ";", "}", "return", "$", "this", "->", "writeConfig", "(", ")", ";", "}" ]
Clones the source code for this project.
[ "Clones", "the", "source", "code", "for", "this", "project", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L54-L120
231,605
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.writeConfig
public function writeConfig() { // Create the app/environment folder $fs = new FileSystem(); try { $fs->mkdir($this->getDockerComposePath()); } catch (IOExceptionInterface $e) { return false; } // Create the environments docker-compose file. $dumper = new Dumper(); try { $fs->remove($this->getDockerComposePath().'/docker-compose.yml'); $fs->dumpFile($this->getDockerComposePath().'/docker-compose.yml', $dumper->dump($this->getDockerComposeArray(), 10)); return true; } catch (IOExceptionInterface $e) { return false; } }
php
public function writeConfig() { // Create the app/environment folder $fs = new FileSystem(); try { $fs->mkdir($this->getDockerComposePath()); } catch (IOExceptionInterface $e) { return false; } // Create the environments docker-compose file. $dumper = new Dumper(); try { $fs->remove($this->getDockerComposePath().'/docker-compose.yml'); $fs->dumpFile($this->getDockerComposePath().'/docker-compose.yml', $dumper->dump($this->getDockerComposeArray(), 10)); return true; } catch (IOExceptionInterface $e) { return false; } }
[ "public", "function", "writeConfig", "(", ")", "{", "// Create the app/environment folder", "$", "fs", "=", "new", "FileSystem", "(", ")", ";", "try", "{", "$", "fs", "->", "mkdir", "(", "$", "this", "->", "getDockerComposePath", "(", ")", ")", ";", "}", "catch", "(", "IOExceptionInterface", "$", "e", ")", "{", "return", "false", ";", "}", "// Create the environments docker-compose file.", "$", "dumper", "=", "new", "Dumper", "(", ")", ";", "try", "{", "$", "fs", "->", "remove", "(", "$", "this", "->", "getDockerComposePath", "(", ")", ".", "'/docker-compose.yml'", ")", ";", "$", "fs", "->", "dumpFile", "(", "$", "this", "->", "getDockerComposePath", "(", ")", ".", "'/docker-compose.yml'", ",", "$", "dumper", "->", "dump", "(", "$", "this", "->", "getDockerComposeArray", "(", ")", ",", "10", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "IOExceptionInterface", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Write the docker-compose.yml file. @return bool
[ "Write", "the", "docker", "-", "compose", ".", "yml", "file", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L127-L148
231,606
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.deploy
public function deploy($version) { // Checkout the branch $wrapper = new GitWrapper(); $wrapper->streamOutput(); $git = new GitWorkingCopy($wrapper, $this->getSourcePath()); $git->checkout($version); $git->pull(); // Reload config so any changes get picked up. $this->reloadConfig(); // Run the deploy hooks, if there are any. if (isset($this->config['hooks']['deploy']) && !empty($this->config['hooks']['deploy'])) { chdir($this->getSourcePath()); $process = new Process($this->config['hooks']['deploy']); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { // Error echo $buffer; } else { // OK echo $buffer; } }); } // @TODO: Save the environment // @TODO: Create EnvironmentFactory->save(); // Returning the branch for now. The command is saving the info. return $this->getRepo()->getCurrentBranch(); }
php
public function deploy($version) { // Checkout the branch $wrapper = new GitWrapper(); $wrapper->streamOutput(); $git = new GitWorkingCopy($wrapper, $this->getSourcePath()); $git->checkout($version); $git->pull(); // Reload config so any changes get picked up. $this->reloadConfig(); // Run the deploy hooks, if there are any. if (isset($this->config['hooks']['deploy']) && !empty($this->config['hooks']['deploy'])) { chdir($this->getSourcePath()); $process = new Process($this->config['hooks']['deploy']); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { // Error echo $buffer; } else { // OK echo $buffer; } }); } // @TODO: Save the environment // @TODO: Create EnvironmentFactory->save(); // Returning the branch for now. The command is saving the info. return $this->getRepo()->getCurrentBranch(); }
[ "public", "function", "deploy", "(", "$", "version", ")", "{", "// Checkout the branch", "$", "wrapper", "=", "new", "GitWrapper", "(", ")", ";", "$", "wrapper", "->", "streamOutput", "(", ")", ";", "$", "git", "=", "new", "GitWorkingCopy", "(", "$", "wrapper", ",", "$", "this", "->", "getSourcePath", "(", ")", ")", ";", "$", "git", "->", "checkout", "(", "$", "version", ")", ";", "$", "git", "->", "pull", "(", ")", ";", "// Reload config so any changes get picked up.", "$", "this", "->", "reloadConfig", "(", ")", ";", "// Run the deploy hooks, if there are any.", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'hooks'", "]", "[", "'deploy'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "config", "[", "'hooks'", "]", "[", "'deploy'", "]", ")", ")", "{", "chdir", "(", "$", "this", "->", "getSourcePath", "(", ")", ")", ";", "$", "process", "=", "new", "Process", "(", "$", "this", "->", "config", "[", "'hooks'", "]", "[", "'deploy'", "]", ")", ";", "$", "process", "->", "run", "(", "function", "(", "$", "type", ",", "$", "buffer", ")", "{", "if", "(", "Process", "::", "ERR", "===", "$", "type", ")", "{", "// Error", "echo", "$", "buffer", ";", "}", "else", "{", "// OK", "echo", "$", "buffer", ";", "}", "}", ")", ";", "}", "// @TODO: Save the environment", "// @TODO: Create EnvironmentFactory->save();", "// Returning the branch for now. The command is saving the info.", "return", "$", "this", "->", "getRepo", "(", ")", "->", "getCurrentBranch", "(", ")", ";", "}" ]
Deploy a version to an environment. @param $version A git branch, tag, or sha.
[ "Deploy", "a", "version", "to", "an", "environment", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L224-L256
231,607
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.getDockerComposePath
public function getDockerComposePath() { return getenv('HOME').'/.terra/environments/'.$this->app->name.'/'.$this->app->name.'-'.$this->environment->name; }
php
public function getDockerComposePath() { return getenv('HOME').'/.terra/environments/'.$this->app->name.'/'.$this->app->name.'-'.$this->environment->name; }
[ "public", "function", "getDockerComposePath", "(", ")", "{", "return", "getenv", "(", "'HOME'", ")", ".", "'/.terra/environments/'", ".", "$", "this", "->", "app", "->", "name", ".", "'/'", ".", "$", "this", "->", "app", "->", "name", ".", "'-'", ".", "$", "this", "->", "environment", "->", "name", ";", "}" ]
Get's the path to this environments docker-compose file. This is just a temporary solution. We should probably just make a generic "environment_config_folder" that decides where to put any generated config for any environment using any provider. @return string
[ "Get", "s", "the", "path", "to", "this", "environments", "docker", "-", "compose", "file", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L267-L270
231,608
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.enable
public function enable() { if ($this->writeConfig() === false) { return false; } $process = new Process('docker-compose up -d', $this->getDockerComposePath()); $process->setTimeout(null); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'DOCKER > '.$buffer; } else { echo 'DOCKER > '.$buffer; } }); if ($process->isSuccessful()) { return true; } }
php
public function enable() { if ($this->writeConfig() === false) { return false; } $process = new Process('docker-compose up -d', $this->getDockerComposePath()); $process->setTimeout(null); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'DOCKER > '.$buffer; } else { echo 'DOCKER > '.$buffer; } }); if ($process->isSuccessful()) { return true; } }
[ "public", "function", "enable", "(", ")", "{", "if", "(", "$", "this", "->", "writeConfig", "(", ")", "===", "false", ")", "{", "return", "false", ";", "}", "$", "process", "=", "new", "Process", "(", "'docker-compose up -d'", ",", "$", "this", "->", "getDockerComposePath", "(", ")", ")", ";", "$", "process", "->", "setTimeout", "(", "null", ")", ";", "$", "process", "->", "run", "(", "function", "(", "$", "type", ",", "$", "buffer", ")", "{", "if", "(", "Process", "::", "ERR", "===", "$", "type", ")", "{", "echo", "'DOCKER > '", ".", "$", "buffer", ";", "}", "else", "{", "echo", "'DOCKER > '", ".", "$", "buffer", ";", "}", "}", ")", ";", "if", "(", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "return", "true", ";", "}", "}" ]
Turns on an environment. In this class, we use `docker-compose up`. @return bool
[ "Turns", "on", "an", "environment", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L440-L458
231,609
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.destroy
public function destroy() { // Run docker-compose kill echo "\n"; echo "Running 'docker-compose kill' in ".$this->getDockerComposePath()."\n"; $process = new Process('docker-compose kill', $this->getDockerComposePath()); $process->setTimeout(null); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'DOCKER > '.$buffer; } else { echo 'DOCKER > '.$buffer; } }); // Run docker-compose rm echo "\n"; echo "Running 'docker-compose rm -f' in ".$this->getDockerComposePath()."\n"; $process = new Process('docker-compose rm -f', $this->getDockerComposePath()); $process->setTimeout(null); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'DOCKER > '.$buffer; } else { echo 'DOCKER > '.$buffer; } }); // @TODO: Remove ~/.terra/environments/* folder. }
php
public function destroy() { // Run docker-compose kill echo "\n"; echo "Running 'docker-compose kill' in ".$this->getDockerComposePath()."\n"; $process = new Process('docker-compose kill', $this->getDockerComposePath()); $process->setTimeout(null); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'DOCKER > '.$buffer; } else { echo 'DOCKER > '.$buffer; } }); // Run docker-compose rm echo "\n"; echo "Running 'docker-compose rm -f' in ".$this->getDockerComposePath()."\n"; $process = new Process('docker-compose rm -f', $this->getDockerComposePath()); $process->setTimeout(null); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'DOCKER > '.$buffer; } else { echo 'DOCKER > '.$buffer; } }); // @TODO: Remove ~/.terra/environments/* folder. }
[ "public", "function", "destroy", "(", ")", "{", "// Run docker-compose kill", "echo", "\"\\n\"", ";", "echo", "\"Running 'docker-compose kill' in \"", ".", "$", "this", "->", "getDockerComposePath", "(", ")", ".", "\"\\n\"", ";", "$", "process", "=", "new", "Process", "(", "'docker-compose kill'", ",", "$", "this", "->", "getDockerComposePath", "(", ")", ")", ";", "$", "process", "->", "setTimeout", "(", "null", ")", ";", "$", "process", "->", "run", "(", "function", "(", "$", "type", ",", "$", "buffer", ")", "{", "if", "(", "Process", "::", "ERR", "===", "$", "type", ")", "{", "echo", "'DOCKER > '", ".", "$", "buffer", ";", "}", "else", "{", "echo", "'DOCKER > '", ".", "$", "buffer", ";", "}", "}", ")", ";", "// Run docker-compose rm", "echo", "\"\\n\"", ";", "echo", "\"Running 'docker-compose rm -f' in \"", ".", "$", "this", "->", "getDockerComposePath", "(", ")", ".", "\"\\n\"", ";", "$", "process", "=", "new", "Process", "(", "'docker-compose rm -f'", ",", "$", "this", "->", "getDockerComposePath", "(", ")", ")", ";", "$", "process", "->", "setTimeout", "(", "null", ")", ";", "$", "process", "->", "run", "(", "function", "(", "$", "type", ",", "$", "buffer", ")", "{", "if", "(", "Process", "::", "ERR", "===", "$", "type", ")", "{", "echo", "'DOCKER > '", ".", "$", "buffer", ";", "}", "else", "{", "echo", "'DOCKER > '", ".", "$", "buffer", ";", "}", "}", ")", ";", "// @TODO: Remove ~/.terra/environments/* folder.", "}" ]
Destroy an environment. @return bool|string
[ "Destroy", "an", "environment", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L492-L521
231,610
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.scale
public function scale($scale) { $cmd = "docker-compose scale app=$scale && docker-compose up -d --no-deps load"; $process = new Process($cmd, $this->getDockerComposePath()); $process->setTimeout(null); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'DOCKER > '.$buffer; } else { echo 'DOCKER > '.$buffer; } }); if (!$process->isSuccessful()) { return false; } else { return $process->getOutput(); } }
php
public function scale($scale) { $cmd = "docker-compose scale app=$scale && docker-compose up -d --no-deps load"; $process = new Process($cmd, $this->getDockerComposePath()); $process->setTimeout(null); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { echo 'DOCKER > '.$buffer; } else { echo 'DOCKER > '.$buffer; } }); if (!$process->isSuccessful()) { return false; } else { return $process->getOutput(); } }
[ "public", "function", "scale", "(", "$", "scale", ")", "{", "$", "cmd", "=", "\"docker-compose scale app=$scale && docker-compose up -d --no-deps load\"", ";", "$", "process", "=", "new", "Process", "(", "$", "cmd", ",", "$", "this", "->", "getDockerComposePath", "(", ")", ")", ";", "$", "process", "->", "setTimeout", "(", "null", ")", ";", "$", "process", "->", "run", "(", "function", "(", "$", "type", ",", "$", "buffer", ")", "{", "if", "(", "Process", "::", "ERR", "===", "$", "type", ")", "{", "echo", "'DOCKER > '", ".", "$", "buffer", ";", "}", "else", "{", "echo", "'DOCKER > '", ".", "$", "buffer", ";", "}", "}", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "return", "false", ";", "}", "else", "{", "return", "$", "process", "->", "getOutput", "(", ")", ";", "}", "}" ]
Basically a wrapper for docker-compose scale.
[ "Basically", "a", "wrapper", "for", "docker", "-", "compose", "scale", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L526-L543
231,611
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.getPort
public function getPort() { $process = new Process('docker-compose port load 80', $this->getDockerComposePath()); $process->run(); if (!$process->isSuccessful()) { return false; } else { $output_array = explode(':', trim($process->getOutput())); return array_pop($output_array); } }
php
public function getPort() { $process = new Process('docker-compose port load 80', $this->getDockerComposePath()); $process->run(); if (!$process->isSuccessful()) { return false; } else { $output_array = explode(':', trim($process->getOutput())); return array_pop($output_array); } }
[ "public", "function", "getPort", "(", ")", "{", "$", "process", "=", "new", "Process", "(", "'docker-compose port load 80'", ",", "$", "this", "->", "getDockerComposePath", "(", ")", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "return", "false", ";", "}", "else", "{", "$", "output_array", "=", "explode", "(", "':'", ",", "trim", "(", "$", "process", "->", "getOutput", "(", ")", ")", ")", ";", "return", "array_pop", "(", "$", "output_array", ")", ";", "}", "}" ]
Get's the exposed port of the load balancer container. @return bool|mixed
[ "Get", "s", "the", "exposed", "port", "of", "the", "load", "balancer", "container", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L550-L560
231,612
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.getScale
public function getScale() { // Get current scale of app service $process = new Process('docker-compose ps -q app', $this->getDockerComposePath()); $process->run(); if (!$process->isSuccessful()) { return false; } $container_list = trim($process->getOutput()); $lines = explode(PHP_EOL, $container_list); $app_scale = count($lines); return $app_scale; }
php
public function getScale() { // Get current scale of app service $process = new Process('docker-compose ps -q app', $this->getDockerComposePath()); $process->run(); if (!$process->isSuccessful()) { return false; } $container_list = trim($process->getOutput()); $lines = explode(PHP_EOL, $container_list); $app_scale = count($lines); return $app_scale; }
[ "public", "function", "getScale", "(", ")", "{", "// Get current scale of app service", "$", "process", "=", "new", "Process", "(", "'docker-compose ps -q app'", ",", "$", "this", "->", "getDockerComposePath", "(", ")", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "return", "false", ";", "}", "$", "container_list", "=", "trim", "(", "$", "process", "->", "getOutput", "(", ")", ")", ";", "$", "lines", "=", "explode", "(", "PHP_EOL", ",", "$", "container_list", ")", ";", "$", "app_scale", "=", "count", "(", "$", "lines", ")", ";", "return", "$", "app_scale", ";", "}" ]
Get the current scale of the app container. @return bool
[ "Get", "the", "current", "scale", "of", "the", "app", "container", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L603-L616
231,613
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.writeDrushAlias
public function writeDrushAlias() { $drush_alias_file_path = "{$_SERVER['HOME']}/.drush/terra.{$this->app->name}.aliases.drushrc.php"; $drush_alias_file = array(); $drush_alias_file[] = '<?php'; foreach ($this->app->environments as $environment_name => $environment) { $factory = new self($environment, $this->app); $path = "/app/" . $environment['document_root']; $drush_alias_file[] = '// DO NOT EDIT. This is generated by Terra. Any changes will be overridden when the environment is re-enabled.'; $drush_alias_file[] = "\$aliases['{$environment_name}'] = array("; $drush_alias_file[] = " 'uri' => '{$factory->getHost()}:{$factory->getPort()}',"; $drush_alias_file[] = " 'root' => '$path',"; $drush_alias_file[] = " 'remote-host' => '{$factory->getHost()}',"; $drush_alias_file[] = " 'remote-user' => 'terra',"; $drush_alias_file[] = " 'ssh-options' => '-p {$factory->getDrushPort()}',"; $drush_alias_file[] = ');'; } $fs = new FileSystem(); try { $fs->dumpFile($drush_alias_file_path, implode("\n", $drush_alias_file)); return true; } catch (IOException $e) { return false; } }
php
public function writeDrushAlias() { $drush_alias_file_path = "{$_SERVER['HOME']}/.drush/terra.{$this->app->name}.aliases.drushrc.php"; $drush_alias_file = array(); $drush_alias_file[] = '<?php'; foreach ($this->app->environments as $environment_name => $environment) { $factory = new self($environment, $this->app); $path = "/app/" . $environment['document_root']; $drush_alias_file[] = '// DO NOT EDIT. This is generated by Terra. Any changes will be overridden when the environment is re-enabled.'; $drush_alias_file[] = "\$aliases['{$environment_name}'] = array("; $drush_alias_file[] = " 'uri' => '{$factory->getHost()}:{$factory->getPort()}',"; $drush_alias_file[] = " 'root' => '$path',"; $drush_alias_file[] = " 'remote-host' => '{$factory->getHost()}',"; $drush_alias_file[] = " 'remote-user' => 'terra',"; $drush_alias_file[] = " 'ssh-options' => '-p {$factory->getDrushPort()}',"; $drush_alias_file[] = ');'; } $fs = new FileSystem(); try { $fs->dumpFile($drush_alias_file_path, implode("\n", $drush_alias_file)); return true; } catch (IOException $e) { return false; } }
[ "public", "function", "writeDrushAlias", "(", ")", "{", "$", "drush_alias_file_path", "=", "\"{$_SERVER['HOME']}/.drush/terra.{$this->app->name}.aliases.drushrc.php\"", ";", "$", "drush_alias_file", "=", "array", "(", ")", ";", "$", "drush_alias_file", "[", "]", "=", "'<?php'", ";", "foreach", "(", "$", "this", "->", "app", "->", "environments", "as", "$", "environment_name", "=>", "$", "environment", ")", "{", "$", "factory", "=", "new", "self", "(", "$", "environment", ",", "$", "this", "->", "app", ")", ";", "$", "path", "=", "\"/app/\"", ".", "$", "environment", "[", "'document_root'", "]", ";", "$", "drush_alias_file", "[", "]", "=", "'// DO NOT EDIT. This is generated by Terra. Any changes will be overridden when the environment is re-enabled.'", ";", "$", "drush_alias_file", "[", "]", "=", "\"\\$aliases['{$environment_name}'] = array(\"", ";", "$", "drush_alias_file", "[", "]", "=", "\" 'uri' => '{$factory->getHost()}:{$factory->getPort()}',\"", ";", "$", "drush_alias_file", "[", "]", "=", "\" 'root' => '$path',\"", ";", "$", "drush_alias_file", "[", "]", "=", "\" 'remote-host' => '{$factory->getHost()}',\"", ";", "$", "drush_alias_file", "[", "]", "=", "\" 'remote-user' => 'terra',\"", ";", "$", "drush_alias_file", "[", "]", "=", "\" 'ssh-options' => '-p {$factory->getDrushPort()}',\"", ";", "$", "drush_alias_file", "[", "]", "=", "');'", ";", "}", "$", "fs", "=", "new", "FileSystem", "(", ")", ";", "try", "{", "$", "fs", "->", "dumpFile", "(", "$", "drush_alias_file_path", ",", "implode", "(", "\"\\n\"", ",", "$", "drush_alias_file", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "IOException", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Writes a local drush alias file.
[ "Writes", "a", "local", "drush", "alias", "file", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L621-L650
231,614
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.runDrushCommand
public function runDrushCommand($drush_command, $alias = NULL) { if ($alias == NULL) { $alias = $this->getDrushAlias(); } $cmd = "drush {$alias} $drush_command"; $process = new Process($cmd); $process->setTimeout(null); $process->run(); return trim($process->getOutput()); }
php
public function runDrushCommand($drush_command, $alias = NULL) { if ($alias == NULL) { $alias = $this->getDrushAlias(); } $cmd = "drush {$alias} $drush_command"; $process = new Process($cmd); $process->setTimeout(null); $process->run(); return trim($process->getOutput()); }
[ "public", "function", "runDrushCommand", "(", "$", "drush_command", ",", "$", "alias", "=", "NULL", ")", "{", "if", "(", "$", "alias", "==", "NULL", ")", "{", "$", "alias", "=", "$", "this", "->", "getDrushAlias", "(", ")", ";", "}", "$", "cmd", "=", "\"drush {$alias} $drush_command\"", ";", "$", "process", "=", "new", "Process", "(", "$", "cmd", ")", ";", "$", "process", "->", "setTimeout", "(", "null", ")", ";", "$", "process", "->", "run", "(", ")", ";", "return", "trim", "(", "$", "process", "->", "getOutput", "(", ")", ")", ";", "}" ]
Runs a drush command for a specified alias.
[ "Runs", "a", "drush", "command", "for", "a", "specified", "alias", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L669-L681
231,615
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.getTerraYmlContent
public function getTerraYmlContent() { $dumper = new Dumper(); // A mix of comments and YAML output. $content = "# The relative path to your exposed web files.\n"; $input = array('document_root' => $this->config['document_root']); $content .= $dumper->dump($input, 10); return $content; }
php
public function getTerraYmlContent() { $dumper = new Dumper(); // A mix of comments and YAML output. $content = "# The relative path to your exposed web files.\n"; $input = array('document_root' => $this->config['document_root']); $content .= $dumper->dump($input, 10); return $content; }
[ "public", "function", "getTerraYmlContent", "(", ")", "{", "$", "dumper", "=", "new", "Dumper", "(", ")", ";", "// A mix of comments and YAML output.", "$", "content", "=", "\"# The relative path to your exposed web files.\\n\"", ";", "$", "input", "=", "array", "(", "'document_root'", "=>", "$", "this", "->", "config", "[", "'document_root'", "]", ")", ";", "$", "content", ".=", "$", "dumper", "->", "dump", "(", "$", "input", ",", "10", ")", ";", "return", "$", "content", ";", "}" ]
Generates the `.terra.yml` file for this environment. @return string
[ "Generates", "the", ".", "terra", ".", "yml", "file", "for", "this", "environment", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L688-L698
231,616
terra-ops/terra-cli
src/terra/Factory/EnvironmentFactory.php
EnvironmentFactory.writeTerraYml
public function writeTerraYml() { // Create the environment's terra.yml file. $fs = new Filesystem(); try { $fs->dumpFile($this->getSourcePath().'/.terra.yml', $this->getTerraYmlContent()); return true; } catch (IOExceptionInterface $e) { return false; } }
php
public function writeTerraYml() { // Create the environment's terra.yml file. $fs = new Filesystem(); try { $fs->dumpFile($this->getSourcePath().'/.terra.yml', $this->getTerraYmlContent()); return true; } catch (IOExceptionInterface $e) { return false; } }
[ "public", "function", "writeTerraYml", "(", ")", "{", "// Create the environment's terra.yml file.", "$", "fs", "=", "new", "Filesystem", "(", ")", ";", "try", "{", "$", "fs", "->", "dumpFile", "(", "$", "this", "->", "getSourcePath", "(", ")", ".", "'/.terra.yml'", ",", "$", "this", "->", "getTerraYmlContent", "(", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "IOExceptionInterface", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Write the `.terra.yml` file. @return bool
[ "Write", "the", ".", "terra", ".", "yml", "file", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory/EnvironmentFactory.php#L705-L715
231,617
EcomDev/cache-key
src/NormalizerChain.php
NormalizerChain.normalize
public function normalize($key) { foreach ($this->chain as $normalizer) { $key = $normalizer->normalize($key); } return $key; }
php
public function normalize($key) { foreach ($this->chain as $normalizer) { $key = $normalizer->normalize($key); } return $key; }
[ "public", "function", "normalize", "(", "$", "key", ")", "{", "foreach", "(", "$", "this", "->", "chain", "as", "$", "normalizer", ")", "{", "$", "key", "=", "$", "normalizer", "->", "normalize", "(", "$", "key", ")", ";", "}", "return", "$", "key", ";", "}" ]
Normalizes key by calling each item in chain @param string $key @return string
[ "Normalizes", "key", "by", "calling", "each", "item", "in", "chain" ]
5f90f5a013100ec57d7f3a842f48222ba8a4ccf9
https://github.com/EcomDev/cache-key/blob/5f90f5a013100ec57d7f3a842f48222ba8a4ccf9/src/NormalizerChain.php#L38-L45
231,618
kuzzleio/sdk-php
src/Security/Document.php
Document.update
public function update(array $content, array $options = []) { $data = [ '_id' => $this->id, 'body' => $content ]; $response = $this->security->getKuzzle()->query( $this->security->buildQueryArgs($this->updateActionName), $data, $options ); $this->setContent($response['result']['_source']); return $this; }
php
public function update(array $content, array $options = []) { $data = [ '_id' => $this->id, 'body' => $content ]; $response = $this->security->getKuzzle()->query( $this->security->buildQueryArgs($this->updateActionName), $data, $options ); $this->setContent($response['result']['_source']); return $this; }
[ "public", "function", "update", "(", "array", "$", "content", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'_id'", "=>", "$", "this", "->", "id", ",", "'body'", "=>", "$", "content", "]", ";", "$", "response", "=", "$", "this", "->", "security", "->", "getKuzzle", "(", ")", "->", "query", "(", "$", "this", "->", "security", "->", "buildQueryArgs", "(", "$", "this", "->", "updateActionName", ")", ",", "$", "data", ",", "$", "options", ")", ";", "$", "this", "->", "setContent", "(", "$", "response", "[", "'result'", "]", "[", "'_source'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Performs a partial content update on this object. @param array $content New profile content @param array $options Optional parameters @return Document
[ "Performs", "a", "partial", "content", "update", "on", "this", "object", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Document.php#L103-L119
231,619
praxisnetau/silverware
src/Extensions/Model/ImageDefaultsExtension.php
ImageDefaultsExtension.getDefaultImageResizeWidth
public function getDefaultImageResizeWidth() { if ($width = $this->owner->ImageDefaultResizeWidth) { return $width; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageResizeWidth'); } }
php
public function getDefaultImageResizeWidth() { if ($width = $this->owner->ImageDefaultResizeWidth) { return $width; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageResizeWidth'); } }
[ "public", "function", "getDefaultImageResizeWidth", "(", ")", "{", "if", "(", "$", "width", "=", "$", "this", "->", "owner", "->", "ImageDefaultResizeWidth", ")", "{", "return", "$", "width", ";", "}", "if", "(", "$", "this", "->", "owner", "->", "hasExtension", "(", "MetaDataExtension", "::", "class", ")", ")", "{", "return", "$", "this", "->", "owner", "->", "getFieldFromParent", "(", "'DefaultImageResizeWidth'", ")", ";", "}", "}" ]
Answers the default image resize width. @return integer
[ "Answers", "the", "default", "image", "resize", "width", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/ImageDefaultsExtension.php#L122-L131
231,620
praxisnetau/silverware
src/Extensions/Model/ImageDefaultsExtension.php
ImageDefaultsExtension.getDefaultImageResizeHeight
public function getDefaultImageResizeHeight() { if ($height = $this->owner->ImageDefaultResizeHeight) { return $height; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageResizeHeight'); } }
php
public function getDefaultImageResizeHeight() { if ($height = $this->owner->ImageDefaultResizeHeight) { return $height; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageResizeHeight'); } }
[ "public", "function", "getDefaultImageResizeHeight", "(", ")", "{", "if", "(", "$", "height", "=", "$", "this", "->", "owner", "->", "ImageDefaultResizeHeight", ")", "{", "return", "$", "height", ";", "}", "if", "(", "$", "this", "->", "owner", "->", "hasExtension", "(", "MetaDataExtension", "::", "class", ")", ")", "{", "return", "$", "this", "->", "owner", "->", "getFieldFromParent", "(", "'DefaultImageResizeHeight'", ")", ";", "}", "}" ]
Answers the default image resize height. @return integer
[ "Answers", "the", "default", "image", "resize", "height", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/ImageDefaultsExtension.php#L138-L147
231,621
praxisnetau/silverware
src/Extensions/Model/ImageDefaultsExtension.php
ImageDefaultsExtension.getDefaultImageResizeMethod
public function getDefaultImageResizeMethod() { if ($method = $this->owner->ImageDefaultResizeMethod) { return $method; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageResizeMethod'); } }
php
public function getDefaultImageResizeMethod() { if ($method = $this->owner->ImageDefaultResizeMethod) { return $method; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageResizeMethod'); } }
[ "public", "function", "getDefaultImageResizeMethod", "(", ")", "{", "if", "(", "$", "method", "=", "$", "this", "->", "owner", "->", "ImageDefaultResizeMethod", ")", "{", "return", "$", "method", ";", "}", "if", "(", "$", "this", "->", "owner", "->", "hasExtension", "(", "MetaDataExtension", "::", "class", ")", ")", "{", "return", "$", "this", "->", "owner", "->", "getFieldFromParent", "(", "'DefaultImageResizeMethod'", ")", ";", "}", "}" ]
Answers the default image resize method. @return string
[ "Answers", "the", "default", "image", "resize", "method", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/ImageDefaultsExtension.php#L154-L163
231,622
praxisnetau/silverware
src/Extensions/Model/ImageDefaultsExtension.php
ImageDefaultsExtension.getDefaultImageAlignment
public function getDefaultImageAlignment() { if ($alignment = $this->owner->ImageDefaultAlignment) { return $alignment; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageAlignment'); } }
php
public function getDefaultImageAlignment() { if ($alignment = $this->owner->ImageDefaultAlignment) { return $alignment; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageAlignment'); } }
[ "public", "function", "getDefaultImageAlignment", "(", ")", "{", "if", "(", "$", "alignment", "=", "$", "this", "->", "owner", "->", "ImageDefaultAlignment", ")", "{", "return", "$", "alignment", ";", "}", "if", "(", "$", "this", "->", "owner", "->", "hasExtension", "(", "MetaDataExtension", "::", "class", ")", ")", "{", "return", "$", "this", "->", "owner", "->", "getFieldFromParent", "(", "'DefaultImageAlignment'", ")", ";", "}", "}" ]
Answers the default image alignment. @return string
[ "Answers", "the", "default", "image", "alignment", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/ImageDefaultsExtension.php#L170-L179
231,623
praxisnetau/silverware
src/Extensions/Model/ImageDefaultsExtension.php
ImageDefaultsExtension.getDefaultImageLinked
public function getDefaultImageLinked() { if ($method = $this->owner->ImageDefaultLinked) { return (boolean) $method; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageLinked'); } }
php
public function getDefaultImageLinked() { if ($method = $this->owner->ImageDefaultLinked) { return (boolean) $method; } if ($this->owner->hasExtension(MetaDataExtension::class)) { return $this->owner->getFieldFromParent('DefaultImageLinked'); } }
[ "public", "function", "getDefaultImageLinked", "(", ")", "{", "if", "(", "$", "method", "=", "$", "this", "->", "owner", "->", "ImageDefaultLinked", ")", "{", "return", "(", "boolean", ")", "$", "method", ";", "}", "if", "(", "$", "this", "->", "owner", "->", "hasExtension", "(", "MetaDataExtension", "::", "class", ")", ")", "{", "return", "$", "this", "->", "owner", "->", "getFieldFromParent", "(", "'DefaultImageLinked'", ")", ";", "}", "}" ]
Answers the default image linked setting. @return string
[ "Answers", "the", "default", "image", "linked", "setting", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/ImageDefaultsExtension.php#L186-L195
231,624
i-am-tom/schemer
src/Formatter/Assoc.php
Assoc.only
public function only(array $keys) : Assoc { return $this->pipe( function (array $values) use ($keys) : array { foreach ($values as $key => $_) { if (!in_array($key, $keys)) { unset($values[$key]); } } return $values; } ); }
php
public function only(array $keys) : Assoc { return $this->pipe( function (array $values) use ($keys) : array { foreach ($values as $key => $_) { if (!in_array($key, $keys)) { unset($values[$key]); } } return $values; } ); }
[ "public", "function", "only", "(", "array", "$", "keys", ")", ":", "Assoc", "{", "return", "$", "this", "->", "pipe", "(", "function", "(", "array", "$", "values", ")", "use", "(", "$", "keys", ")", ":", "array", "{", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "_", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "keys", ")", ")", "{", "unset", "(", "$", "values", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "values", ";", "}", ")", ";", "}" ]
The array will only contain keys from a given list. @param array $keys @return Schemer\Formatter\Assoc
[ "The", "array", "will", "only", "contain", "keys", "from", "a", "given", "list", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Assoc.php#L37-L50
231,625
i-am-tom/schemer
src/Formatter/Assoc.php
Assoc.rename
public function rename(string $from, string $to) : Assoc { return $this->pipe( function (array $values) use ($from, $to) : array { if (isset($values[$from])) { $values[$to] = $values[$from]; unset($values[$from]); } return $values; } ); }
php
public function rename(string $from, string $to) : Assoc { return $this->pipe( function (array $values) use ($from, $to) : array { if (isset($values[$from])) { $values[$to] = $values[$from]; unset($values[$from]); } return $values; } ); }
[ "public", "function", "rename", "(", "string", "$", "from", ",", "string", "$", "to", ")", ":", "Assoc", "{", "return", "$", "this", "->", "pipe", "(", "function", "(", "array", "$", "values", ")", "use", "(", "$", "from", ",", "$", "to", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "values", "[", "$", "from", "]", ")", ")", "{", "$", "values", "[", "$", "to", "]", "=", "$", "values", "[", "$", "from", "]", ";", "unset", "(", "$", "values", "[", "$", "from", "]", ")", ";", "}", "return", "$", "values", ";", "}", ")", ";", "}" ]
The array will have the given key renamed. @param string $from @param string $to @return Schemer\Formatter\Assoc
[ "The", "array", "will", "have", "the", "given", "key", "renamed", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Assoc.php#L58-L70
231,626
i-am-tom/schemer
src/Formatter/Assoc.php
Assoc.renameMany
public function renameMany(array $map) : Assoc { $pairs = array_map(function ($a, $b) { return [$a, $b]; }, array_keys($map), array_values($map)); return array_reduce($pairs, function ($that, $pair) { list ($from, $to) = $pair; return $that->rename($from, $to); }, $this); }
php
public function renameMany(array $map) : Assoc { $pairs = array_map(function ($a, $b) { return [$a, $b]; }, array_keys($map), array_values($map)); return array_reduce($pairs, function ($that, $pair) { list ($from, $to) = $pair; return $that->rename($from, $to); }, $this); }
[ "public", "function", "renameMany", "(", "array", "$", "map", ")", ":", "Assoc", "{", "$", "pairs", "=", "array_map", "(", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "[", "$", "a", ",", "$", "b", "]", ";", "}", ",", "array_keys", "(", "$", "map", ")", ",", "array_values", "(", "$", "map", ")", ")", ";", "return", "array_reduce", "(", "$", "pairs", ",", "function", "(", "$", "that", ",", "$", "pair", ")", "{", "list", "(", "$", "from", ",", "$", "to", ")", "=", "$", "pair", ";", "return", "$", "that", "->", "rename", "(", "$", "from", ",", "$", "to", ")", ";", "}", ",", "$", "this", ")", ";", "}" ]
The array will have the given keys renamed. @param array $map [from => to] mappings. @return Schemer\Formatter\Assoc
[ "The", "array", "will", "have", "the", "given", "keys", "renamed", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Assoc.php#L77-L88
231,627
i-am-tom/schemer
src/Formatter/Assoc.php
Assoc.strip
public function strip(array $keys) : Assoc { return $this->pipe( function (array $values) use ($keys) : array { foreach ($keys as $key) { if (isset($values[$key])) { unset($values[$key]); } } return $values; } ); }
php
public function strip(array $keys) : Assoc { return $this->pipe( function (array $values) use ($keys) : array { foreach ($keys as $key) { if (isset($values[$key])) { unset($values[$key]); } } return $values; } ); }
[ "public", "function", "strip", "(", "array", "$", "keys", ")", ":", "Assoc", "{", "return", "$", "this", "->", "pipe", "(", "function", "(", "array", "$", "values", ")", "use", "(", "$", "keys", ")", ":", "array", "{", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "values", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "values", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "values", ";", "}", ")", ";", "}" ]
The array will not contain keys from a given list. @param array $keys @return Schemer\Formatter\Assoc
[ "The", "array", "will", "not", "contain", "keys", "from", "a", "given", "list", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Assoc.php#L95-L108
231,628
digiaonline/paytrail-php
src/Object/Payment.php
Payment.addProduct
public function addProduct(Product $product) { if (count($this->products) > self::MAX_PRODUCT_COUNT) { throw new TooManyProducts( sprintf( 'Paytrail can only handle up to %d different products. Please group products using "amount".', self::MAX_PRODUCT_COUNT ) ); } $this->products[] = $product; }
php
public function addProduct(Product $product) { if (count($this->products) > self::MAX_PRODUCT_COUNT) { throw new TooManyProducts( sprintf( 'Paytrail can only handle up to %d different products. Please group products using "amount".', self::MAX_PRODUCT_COUNT ) ); } $this->products[] = $product; }
[ "public", "function", "addProduct", "(", "Product", "$", "product", ")", "{", "if", "(", "count", "(", "$", "this", "->", "products", ")", ">", "self", "::", "MAX_PRODUCT_COUNT", ")", "{", "throw", "new", "TooManyProducts", "(", "sprintf", "(", "'Paytrail can only handle up to %d different products. Please group products using \"amount\".'", ",", "self", "::", "MAX_PRODUCT_COUNT", ")", ")", ";", "}", "$", "this", "->", "products", "[", "]", "=", "$", "product", ";", "}" ]
Add a product. @param \Paytrail\Object\Product $product The product to add. @throws \Paytrail\Exception\TooManyProducts
[ "Add", "a", "product", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Object/Payment.php#L165-L176
231,629
digiaonline/paytrail-php
src/Object/Payment.php
Payment.toArray
public function toArray() { $array = array(); $array['orderNumber'] = $this->orderNumber; if (isset($this->referenceNumber)) { $array['referenceNumber'] = $this->referenceNumber; } if (isset($this->description)) { $array['description'] = $this->description; } $array['currency'] = $this->currency; if (isset($this->locale)) { $array['locale'] = $this->locale; } $array['orderDetails'] = array( 'includeVat' => $this->vatMode, 'products' => array(), ); if ($this->urlSet !== null) { $array['urlSet'] = $this->urlSet->toArray(); } if ($this->contact !== null) { $array['orderDetails']['contact'] = $this->contact->toArray(); } foreach ($this->products as $product) { $array['orderDetails']['products'][] = $product->toArray(); } return $array; }
php
public function toArray() { $array = array(); $array['orderNumber'] = $this->orderNumber; if (isset($this->referenceNumber)) { $array['referenceNumber'] = $this->referenceNumber; } if (isset($this->description)) { $array['description'] = $this->description; } $array['currency'] = $this->currency; if (isset($this->locale)) { $array['locale'] = $this->locale; } $array['orderDetails'] = array( 'includeVat' => $this->vatMode, 'products' => array(), ); if ($this->urlSet !== null) { $array['urlSet'] = $this->urlSet->toArray(); } if ($this->contact !== null) { $array['orderDetails']['contact'] = $this->contact->toArray(); } foreach ($this->products as $product) { $array['orderDetails']['products'][] = $product->toArray(); } return $array; }
[ "public", "function", "toArray", "(", ")", "{", "$", "array", "=", "array", "(", ")", ";", "$", "array", "[", "'orderNumber'", "]", "=", "$", "this", "->", "orderNumber", ";", "if", "(", "isset", "(", "$", "this", "->", "referenceNumber", ")", ")", "{", "$", "array", "[", "'referenceNumber'", "]", "=", "$", "this", "->", "referenceNumber", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "description", ")", ")", "{", "$", "array", "[", "'description'", "]", "=", "$", "this", "->", "description", ";", "}", "$", "array", "[", "'currency'", "]", "=", "$", "this", "->", "currency", ";", "if", "(", "isset", "(", "$", "this", "->", "locale", ")", ")", "{", "$", "array", "[", "'locale'", "]", "=", "$", "this", "->", "locale", ";", "}", "$", "array", "[", "'orderDetails'", "]", "=", "array", "(", "'includeVat'", "=>", "$", "this", "->", "vatMode", ",", "'products'", "=>", "array", "(", ")", ",", ")", ";", "if", "(", "$", "this", "->", "urlSet", "!==", "null", ")", "{", "$", "array", "[", "'urlSet'", "]", "=", "$", "this", "->", "urlSet", "->", "toArray", "(", ")", ";", "}", "if", "(", "$", "this", "->", "contact", "!==", "null", ")", "{", "$", "array", "[", "'orderDetails'", "]", "[", "'contact'", "]", "=", "$", "this", "->", "contact", "->", "toArray", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "products", "as", "$", "product", ")", "{", "$", "array", "[", "'orderDetails'", "]", "[", "'products'", "]", "[", "]", "=", "$", "product", "->", "toArray", "(", ")", ";", "}", "return", "$", "array", ";", "}" ]
Convert the payment object to an array. @return array
[ "Convert", "the", "payment", "object", "to", "an", "array", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Object/Payment.php#L183-L213
231,630
digiaonline/paytrail-php
src/Object/Payment.php
Payment.setLocale
public function setLocale($locale) { if ( ! in_array($locale, self::$supportedLocales)) { throw new LocaleNotSupported(sprintf('Locale "%s" is not supported.', $locale)); } $this->locale = $locale; }
php
public function setLocale($locale) { if ( ! in_array($locale, self::$supportedLocales)) { throw new LocaleNotSupported(sprintf('Locale "%s" is not supported.', $locale)); } $this->locale = $locale; }
[ "public", "function", "setLocale", "(", "$", "locale", ")", "{", "if", "(", "!", "in_array", "(", "$", "locale", ",", "self", "::", "$", "supportedLocales", ")", ")", "{", "throw", "new", "LocaleNotSupported", "(", "sprintf", "(", "'Locale \"%s\" is not supported.'", ",", "$", "locale", ")", ")", ";", "}", "$", "this", "->", "locale", "=", "$", "locale", ";", "}" ]
Sets the locale. @param string $locale The locale to set. @throws @throws \Paytrail\Exception\LocaleNotSupported
[ "Sets", "the", "locale", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Object/Payment.php#L277-L283
231,631
stratifyphp/router
src/Router.php
Router.process
public function process(ServerRequestInterface $request, DelegateInterface $delegate) : ResponseInterface { $matcher = $this->routerContainer->getMatcher(); $route = $matcher->match($request); if ($route === false) { // Call the next middleware return $delegate->process($request); } foreach ($route->attributes as $key => $val) { $request = $request->withAttribute($key, $val); } return $this->dispatch($route->handler, $request); }
php
public function process(ServerRequestInterface $request, DelegateInterface $delegate) : ResponseInterface { $matcher = $this->routerContainer->getMatcher(); $route = $matcher->match($request); if ($route === false) { // Call the next middleware return $delegate->process($request); } foreach ($route->attributes as $key => $val) { $request = $request->withAttribute($key, $val); } return $this->dispatch($route->handler, $request); }
[ "public", "function", "process", "(", "ServerRequestInterface", "$", "request", ",", "DelegateInterface", "$", "delegate", ")", ":", "ResponseInterface", "{", "$", "matcher", "=", "$", "this", "->", "routerContainer", "->", "getMatcher", "(", ")", ";", "$", "route", "=", "$", "matcher", "->", "match", "(", "$", "request", ")", ";", "if", "(", "$", "route", "===", "false", ")", "{", "// Call the next middleware", "return", "$", "delegate", "->", "process", "(", "$", "request", ")", ";", "}", "foreach", "(", "$", "route", "->", "attributes", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "request", "=", "$", "request", "->", "withAttribute", "(", "$", "key", ",", "$", "val", ")", ";", "}", "return", "$", "this", "->", "dispatch", "(", "$", "route", "->", "handler", ",", "$", "request", ")", ";", "}" ]
Route the incoming request to its handler, or call the next middleware if no route was found.
[ "Route", "the", "incoming", "request", "to", "its", "handler", "or", "call", "the", "next", "middleware", "if", "no", "route", "was", "found", "." ]
5026d54c7f7a18c83e942f42e8da001e6e2f180f
https://github.com/stratifyphp/router/blob/5026d54c7f7a18c83e942f42e8da001e6e2f180f/src/Router.php#L55-L71
231,632
praxisnetau/silverware
src/Extensions/Lists/ListSourceExtension.php
ListSourceExtension.getListItems
public function getListItems() { // Create List: $items = ArrayList::create(); // Obtain Items from Source: if ($source = $this->owner->getSource()) { // Obtain Source List: $list = $source->getListItems(); // Filter List Items (if applicable): if (in_array(ListFilter::class, class_uses($source))) { if ($where = $source->getListWhere()) { $list = $list->where($where); } foreach ($source->getListFilters() as $filter) { $list = $list->filter($filter); } } // Merge List Items: $items->merge($list); } // Sort Items (if applicable): if ($this->owner->SortItemsBy) { $items = $this->sort($items); } // Remove Items without Images (if applicable): if ($this->owner->ImageItems) { $items = $items->filterByCallback(function ($item) { return $item->hasMetaImage(); }); } // Reverse Items (if applicable): if ($this->owner->ReverseItems) { $items = $items->reverse(); } // Limit Items (if applicable): if ($limit = $this->owner->NumberOfItems) { $items = $items->limit($limit); } // Paginate Items (if applicable): if ($this->owner->PaginateItems && $this->owner->SortItemsBy != self::SORT_RANDOM) { $items = PaginatedList::create($items, $this->getRequest()); $items->setPaginationGetVar($this->owner->getPaginationGetVar()); if ($this->owner->ItemsPerPage) { $items->setPageLength($this->owner->ItemsPerPage); } } // Associate Items with Rendering Component: foreach ($items as $item) { $item->setRenderer($this->owner); } // Answer List: return $items; }
php
public function getListItems() { // Create List: $items = ArrayList::create(); // Obtain Items from Source: if ($source = $this->owner->getSource()) { // Obtain Source List: $list = $source->getListItems(); // Filter List Items (if applicable): if (in_array(ListFilter::class, class_uses($source))) { if ($where = $source->getListWhere()) { $list = $list->where($where); } foreach ($source->getListFilters() as $filter) { $list = $list->filter($filter); } } // Merge List Items: $items->merge($list); } // Sort Items (if applicable): if ($this->owner->SortItemsBy) { $items = $this->sort($items); } // Remove Items without Images (if applicable): if ($this->owner->ImageItems) { $items = $items->filterByCallback(function ($item) { return $item->hasMetaImage(); }); } // Reverse Items (if applicable): if ($this->owner->ReverseItems) { $items = $items->reverse(); } // Limit Items (if applicable): if ($limit = $this->owner->NumberOfItems) { $items = $items->limit($limit); } // Paginate Items (if applicable): if ($this->owner->PaginateItems && $this->owner->SortItemsBy != self::SORT_RANDOM) { $items = PaginatedList::create($items, $this->getRequest()); $items->setPaginationGetVar($this->owner->getPaginationGetVar()); if ($this->owner->ItemsPerPage) { $items->setPageLength($this->owner->ItemsPerPage); } } // Associate Items with Rendering Component: foreach ($items as $item) { $item->setRenderer($this->owner); } // Answer List: return $items; }
[ "public", "function", "getListItems", "(", ")", "{", "// Create List:", "$", "items", "=", "ArrayList", "::", "create", "(", ")", ";", "// Obtain Items from Source:", "if", "(", "$", "source", "=", "$", "this", "->", "owner", "->", "getSource", "(", ")", ")", "{", "// Obtain Source List:", "$", "list", "=", "$", "source", "->", "getListItems", "(", ")", ";", "// Filter List Items (if applicable):", "if", "(", "in_array", "(", "ListFilter", "::", "class", ",", "class_uses", "(", "$", "source", ")", ")", ")", "{", "if", "(", "$", "where", "=", "$", "source", "->", "getListWhere", "(", ")", ")", "{", "$", "list", "=", "$", "list", "->", "where", "(", "$", "where", ")", ";", "}", "foreach", "(", "$", "source", "->", "getListFilters", "(", ")", "as", "$", "filter", ")", "{", "$", "list", "=", "$", "list", "->", "filter", "(", "$", "filter", ")", ";", "}", "}", "// Merge List Items:", "$", "items", "->", "merge", "(", "$", "list", ")", ";", "}", "// Sort Items (if applicable):", "if", "(", "$", "this", "->", "owner", "->", "SortItemsBy", ")", "{", "$", "items", "=", "$", "this", "->", "sort", "(", "$", "items", ")", ";", "}", "// Remove Items without Images (if applicable):", "if", "(", "$", "this", "->", "owner", "->", "ImageItems", ")", "{", "$", "items", "=", "$", "items", "->", "filterByCallback", "(", "function", "(", "$", "item", ")", "{", "return", "$", "item", "->", "hasMetaImage", "(", ")", ";", "}", ")", ";", "}", "// Reverse Items (if applicable):", "if", "(", "$", "this", "->", "owner", "->", "ReverseItems", ")", "{", "$", "items", "=", "$", "items", "->", "reverse", "(", ")", ";", "}", "// Limit Items (if applicable):", "if", "(", "$", "limit", "=", "$", "this", "->", "owner", "->", "NumberOfItems", ")", "{", "$", "items", "=", "$", "items", "->", "limit", "(", "$", "limit", ")", ";", "}", "// Paginate Items (if applicable):", "if", "(", "$", "this", "->", "owner", "->", "PaginateItems", "&&", "$", "this", "->", "owner", "->", "SortItemsBy", "!=", "self", "::", "SORT_RANDOM", ")", "{", "$", "items", "=", "PaginatedList", "::", "create", "(", "$", "items", ",", "$", "this", "->", "getRequest", "(", ")", ")", ";", "$", "items", "->", "setPaginationGetVar", "(", "$", "this", "->", "owner", "->", "getPaginationGetVar", "(", ")", ")", ";", "if", "(", "$", "this", "->", "owner", "->", "ItemsPerPage", ")", "{", "$", "items", "->", "setPageLength", "(", "$", "this", "->", "owner", "->", "ItemsPerPage", ")", ";", "}", "}", "// Associate Items with Rendering Component:", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "item", "->", "setRenderer", "(", "$", "this", "->", "owner", ")", ";", "}", "// Answer List:", "return", "$", "items", ";", "}" ]
Answers a list of items. @return ArrayList
[ "Answers", "a", "list", "of", "items", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Lists/ListSourceExtension.php#L225-L310
231,633
praxisnetau/silverware
src/Extensions/Lists/ListSourceExtension.php
ListSourceExtension.setSource
public function setSource($source) { if ($source instanceof ListSource) { $this->source = $source; } if ($source instanceof SS_List) { $this->source = ListWrapper::create($source); } return $this->owner; }
php
public function setSource($source) { if ($source instanceof ListSource) { $this->source = $source; } if ($source instanceof SS_List) { $this->source = ListWrapper::create($source); } return $this->owner; }
[ "public", "function", "setSource", "(", "$", "source", ")", "{", "if", "(", "$", "source", "instanceof", "ListSource", ")", "{", "$", "this", "->", "source", "=", "$", "source", ";", "}", "if", "(", "$", "source", "instanceof", "SS_List", ")", "{", "$", "this", "->", "source", "=", "ListWrapper", "::", "create", "(", "$", "source", ")", ";", "}", "return", "$", "this", "->", "owner", ";", "}" ]
Defines the list source for the extended object. @param ListSource|SS_List $source @return DataObject
[ "Defines", "the", "list", "source", "for", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Lists/ListSourceExtension.php#L329-L340
231,634
praxisnetau/silverware
src/Extensions/Lists/ListSourceExtension.php
ListSourceExtension.getSource
public function getSource() { if ($this->source) { return $this->source; } if ($this->owner->ListSourceID) { return $this->owner->ListSource(); } }
php
public function getSource() { if ($this->source) { return $this->source; } if ($this->owner->ListSourceID) { return $this->owner->ListSource(); } }
[ "public", "function", "getSource", "(", ")", "{", "if", "(", "$", "this", "->", "source", ")", "{", "return", "$", "this", "->", "source", ";", "}", "if", "(", "$", "this", "->", "owner", "->", "ListSourceID", ")", "{", "return", "$", "this", "->", "owner", "->", "ListSource", "(", ")", ";", "}", "}" ]
Answers the list source from the extended object. @return ListSource
[ "Answers", "the", "list", "source", "from", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Lists/ListSourceExtension.php#L347-L356
231,635
praxisnetau/silverware
src/Extensions/Lists/ListSourceExtension.php
ListSourceExtension.sort
protected function sort(SS_List $list) { switch ($this->owner->SortItemsBy) { // Random Sort Order: case self::SORT_RANDOM: if ($list instanceof DataList) { return $list->sort(DB::get_conn()->random()); } $items = $list->toArray(); shuffle($items); return ArrayList::create($items); // Default Sort Order: default: return $list; } }
php
protected function sort(SS_List $list) { switch ($this->owner->SortItemsBy) { // Random Sort Order: case self::SORT_RANDOM: if ($list instanceof DataList) { return $list->sort(DB::get_conn()->random()); } $items = $list->toArray(); shuffle($items); return ArrayList::create($items); // Default Sort Order: default: return $list; } }
[ "protected", "function", "sort", "(", "SS_List", "$", "list", ")", "{", "switch", "(", "$", "this", "->", "owner", "->", "SortItemsBy", ")", "{", "// Random Sort Order:", "case", "self", "::", "SORT_RANDOM", ":", "if", "(", "$", "list", "instanceof", "DataList", ")", "{", "return", "$", "list", "->", "sort", "(", "DB", "::", "get_conn", "(", ")", "->", "random", "(", ")", ")", ";", "}", "$", "items", "=", "$", "list", "->", "toArray", "(", ")", ";", "shuffle", "(", "$", "items", ")", ";", "return", "ArrayList", "::", "create", "(", "$", "items", ")", ";", "// Default Sort Order:", "default", ":", "return", "$", "list", ";", "}", "}" ]
Sorts the given list of items. @param SS_List $list @return SS_List
[ "Sorts", "the", "given", "list", "of", "items", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Lists/ListSourceExtension.php#L412-L437
231,636
praxisnetau/silverware
src/Grid/ColumnSpan.php
ColumnSpan.getSpanSummary
public function getSpanSummary() { $summary = []; $span = $this->dbObject('Span'); foreach ($span->getViewports() as $viewport) { if ($value = $span->getField($viewport)) { $summary[] = sprintf('%s: %s', $viewport, $value); } } return implode(', ', $summary); }
php
public function getSpanSummary() { $summary = []; $span = $this->dbObject('Span'); foreach ($span->getViewports() as $viewport) { if ($value = $span->getField($viewport)) { $summary[] = sprintf('%s: %s', $viewport, $value); } } return implode(', ', $summary); }
[ "public", "function", "getSpanSummary", "(", ")", "{", "$", "summary", "=", "[", "]", ";", "$", "span", "=", "$", "this", "->", "dbObject", "(", "'Span'", ")", ";", "foreach", "(", "$", "span", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "if", "(", "$", "value", "=", "$", "span", "->", "getField", "(", "$", "viewport", ")", ")", "{", "$", "summary", "[", "]", "=", "sprintf", "(", "'%s: %s'", ",", "$", "viewport", ",", "$", "value", ")", ";", "}", "}", "return", "implode", "(", "', '", ",", "$", "summary", ")", ";", "}" ]
Answers a summary of the defined column spans. @return string
[ "Answers", "a", "summary", "of", "the", "defined", "column", "spans", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/ColumnSpan.php#L270-L285
231,637
praxisnetau/silverware
src/Grid/ColumnSpan.php
ColumnSpan.isActive
public function isActive() { if (($page = Director::get_current_page()) && $page instanceof Page) { $ids = $this->Pages()->column('ID'); if (!$this->isInherited()) { return in_array($page->ID, $ids); } return !empty(array_intersect($ids, $page->getAncestors(true)->column('ID'))); } return false; }
php
public function isActive() { if (($page = Director::get_current_page()) && $page instanceof Page) { $ids = $this->Pages()->column('ID'); if (!$this->isInherited()) { return in_array($page->ID, $ids); } return !empty(array_intersect($ids, $page->getAncestors(true)->column('ID'))); } return false; }
[ "public", "function", "isActive", "(", ")", "{", "if", "(", "(", "$", "page", "=", "Director", "::", "get_current_page", "(", ")", ")", "&&", "$", "page", "instanceof", "Page", ")", "{", "$", "ids", "=", "$", "this", "->", "Pages", "(", ")", "->", "column", "(", "'ID'", ")", ";", "if", "(", "!", "$", "this", "->", "isInherited", "(", ")", ")", "{", "return", "in_array", "(", "$", "page", "->", "ID", ",", "$", "ids", ")", ";", "}", "return", "!", "empty", "(", "array_intersect", "(", "$", "ids", ",", "$", "page", "->", "getAncestors", "(", "true", ")", "->", "column", "(", "'ID'", ")", ")", ")", ";", "}", "return", "false", ";", "}" ]
Answers true if the column span is active for the current page. @return boolean
[ "Answers", "true", "if", "the", "column", "span", "is", "active", "for", "the", "current", "page", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/ColumnSpan.php#L302-L317
231,638
Josantonius/PHP-Hook
src/Hook.php
Hook.addAction
public static function addAction($tag, $func, $priority = 8, $args = 0) { $that = self::getInstance(self::$id); $that->callbacks[$tag][$priority][] = [ 'function' => $func, 'arguments' => $args, ]; return true; }
php
public static function addAction($tag, $func, $priority = 8, $args = 0) { $that = self::getInstance(self::$id); $that->callbacks[$tag][$priority][] = [ 'function' => $func, 'arguments' => $args, ]; return true; }
[ "public", "static", "function", "addAction", "(", "$", "tag", ",", "$", "func", ",", "$", "priority", "=", "8", ",", "$", "args", "=", "0", ")", "{", "$", "that", "=", "self", "::", "getInstance", "(", "self", "::", "$", "id", ")", ";", "$", "that", "->", "callbacks", "[", "$", "tag", "]", "[", "$", "priority", "]", "[", "]", "=", "[", "'function'", "=>", "$", "func", ",", "'arguments'", "=>", "$", "args", ",", "]", ";", "return", "true", ";", "}" ]
Attach custom function to action hook. @since 1.0.3 @param string $tag → action hook name @param callable $func → function to attach to action hook @param int $priority → order in which the action is executed @param int $args → number of arguments accepted @return bool
[ "Attach", "custom", "function", "to", "action", "hook", "." ]
12552ef239ea73f3463f2e213f0bdee47568905e
https://github.com/Josantonius/PHP-Hook/blob/12552ef239ea73f3463f2e213f0bdee47568905e/src/Hook.php#L105-L115
231,639
Josantonius/PHP-Hook
src/Hook.php
Hook.doAction
public static function doAction($tag, $args = [], $remove = true) { $that = self::getInstance(self::$id); self::$current = $tag; $that->actions['count']++; if (! array_key_exists($tag, $that->actions)) { $that->actions[$tag] = 0; } $that->actions[$tag]++; $actions = $that->getActions($tag, $remove); asort($actions); foreach ($actions as $priority) { foreach ($priority as $action) { $action = $that->runAction($action, $args); } } self::$current = false; return (isset($action)) ? $action : false; }
php
public static function doAction($tag, $args = [], $remove = true) { $that = self::getInstance(self::$id); self::$current = $tag; $that->actions['count']++; if (! array_key_exists($tag, $that->actions)) { $that->actions[$tag] = 0; } $that->actions[$tag]++; $actions = $that->getActions($tag, $remove); asort($actions); foreach ($actions as $priority) { foreach ($priority as $action) { $action = $that->runAction($action, $args); } } self::$current = false; return (isset($action)) ? $action : false; }
[ "public", "static", "function", "doAction", "(", "$", "tag", ",", "$", "args", "=", "[", "]", ",", "$", "remove", "=", "true", ")", "{", "$", "that", "=", "self", "::", "getInstance", "(", "self", "::", "$", "id", ")", ";", "self", "::", "$", "current", "=", "$", "tag", ";", "$", "that", "->", "actions", "[", "'count'", "]", "++", ";", "if", "(", "!", "array_key_exists", "(", "$", "tag", ",", "$", "that", "->", "actions", ")", ")", "{", "$", "that", "->", "actions", "[", "$", "tag", "]", "=", "0", ";", "}", "$", "that", "->", "actions", "[", "$", "tag", "]", "++", ";", "$", "actions", "=", "$", "that", "->", "getActions", "(", "$", "tag", ",", "$", "remove", ")", ";", "asort", "(", "$", "actions", ")", ";", "foreach", "(", "$", "actions", "as", "$", "priority", ")", "{", "foreach", "(", "$", "priority", "as", "$", "action", ")", "{", "$", "action", "=", "$", "that", "->", "runAction", "(", "$", "action", ",", "$", "args", ")", ";", "}", "}", "self", "::", "$", "current", "=", "false", ";", "return", "(", "isset", "(", "$", "action", ")", ")", "?", "$", "action", ":", "false", ";", "}" ]
Run all hooks attached to the hook. By default it will look for getInstance method to use singleton pattern and create a single instance of the class. If it does not exist it will create a new object. @see setSingletonName() for change the method name. @since 1.0.3 @param string $tag → action hook name @param mixed $args → optional arguments @param bool $remove → delete hook after executing actions @return returns the output of the last action or false
[ "Run", "all", "hooks", "attached", "to", "the", "hook", "." ]
12552ef239ea73f3463f2e213f0bdee47568905e
https://github.com/Josantonius/PHP-Hook/blob/12552ef239ea73f3463f2e213f0bdee47568905e/src/Hook.php#L152-L177
231,640
Josantonius/PHP-Hook
src/Hook.php
Hook.setSingletonName
public static function setSingletonName($method) { $that = self::getInstance(self::$id); $that->singleton = $method; }
php
public static function setSingletonName($method) { $that = self::getInstance(self::$id); $that->singleton = $method; }
[ "public", "static", "function", "setSingletonName", "(", "$", "method", ")", "{", "$", "that", "=", "self", "::", "getInstance", "(", "self", "::", "$", "id", ")", ";", "$", "that", "->", "singleton", "=", "$", "method", ";", "}" ]
Set method name for use singleton pattern. @since 1.0.0 @param string $method → singleton method name
[ "Set", "method", "name", "for", "use", "singleton", "pattern", "." ]
12552ef239ea73f3463f2e213f0bdee47568905e
https://github.com/Josantonius/PHP-Hook/blob/12552ef239ea73f3463f2e213f0bdee47568905e/src/Hook.php#L186-L191
231,641
Josantonius/PHP-Hook
src/Hook.php
Hook.isAction
public static function isAction($tag) { $that = self::getInstance(self::$id); return isset($that->callbacks[$tag]); }
php
public static function isAction($tag) { $that = self::getInstance(self::$id); return isset($that->callbacks[$tag]); }
[ "public", "static", "function", "isAction", "(", "$", "tag", ")", "{", "$", "that", "=", "self", "::", "getInstance", "(", "self", "::", "$", "id", ")", ";", "return", "isset", "(", "$", "that", "->", "callbacks", "[", "$", "tag", "]", ")", ";", "}" ]
Check if there is a certain action hook. @since 1.0.7 @param string $tag → action hook name @return bool
[ "Check", "if", "there", "is", "a", "certain", "action", "hook", "." ]
12552ef239ea73f3463f2e213f0bdee47568905e
https://github.com/Josantonius/PHP-Hook/blob/12552ef239ea73f3463f2e213f0bdee47568905e/src/Hook.php#L214-L219
231,642
Josantonius/PHP-Hook
src/Hook.php
Hook.runAction
private function runAction($action, $args) { $function = $action['function']; $argsNumber = $action['arguments']; $class = (isset($function[0])) ? $function[0] : false; $method = (isset($function[1])) ? $function[1] : false; $args = $this->getArguments($argsNumber, $args); if (! ($class && $method) && function_exists($function)) { return call_user_func($function, $args); } elseif ($obj = call_user_func([$class, $this->singleton])) { if ($obj !== false) { return call_user_func_array([$obj, $method], $args); } } elseif (class_exists($class)) { $instance = new $class; return call_user_func_array([$instance, $method], $args); } }
php
private function runAction($action, $args) { $function = $action['function']; $argsNumber = $action['arguments']; $class = (isset($function[0])) ? $function[0] : false; $method = (isset($function[1])) ? $function[1] : false; $args = $this->getArguments($argsNumber, $args); if (! ($class && $method) && function_exists($function)) { return call_user_func($function, $args); } elseif ($obj = call_user_func([$class, $this->singleton])) { if ($obj !== false) { return call_user_func_array([$obj, $method], $args); } } elseif (class_exists($class)) { $instance = new $class; return call_user_func_array([$instance, $method], $args); } }
[ "private", "function", "runAction", "(", "$", "action", ",", "$", "args", ")", "{", "$", "function", "=", "$", "action", "[", "'function'", "]", ";", "$", "argsNumber", "=", "$", "action", "[", "'arguments'", "]", ";", "$", "class", "=", "(", "isset", "(", "$", "function", "[", "0", "]", ")", ")", "?", "$", "function", "[", "0", "]", ":", "false", ";", "$", "method", "=", "(", "isset", "(", "$", "function", "[", "1", "]", ")", ")", "?", "$", "function", "[", "1", "]", ":", "false", ";", "$", "args", "=", "$", "this", "->", "getArguments", "(", "$", "argsNumber", ",", "$", "args", ")", ";", "if", "(", "!", "(", "$", "class", "&&", "$", "method", ")", "&&", "function_exists", "(", "$", "function", ")", ")", "{", "return", "call_user_func", "(", "$", "function", ",", "$", "args", ")", ";", "}", "elseif", "(", "$", "obj", "=", "call_user_func", "(", "[", "$", "class", ",", "$", "this", "->", "singleton", "]", ")", ")", "{", "if", "(", "$", "obj", "!==", "false", ")", "{", "return", "call_user_func_array", "(", "[", "$", "obj", ",", "$", "method", "]", ",", "$", "args", ")", ";", "}", "}", "elseif", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "instance", "=", "new", "$", "class", ";", "return", "call_user_func_array", "(", "[", "$", "instance", ",", "$", "method", "]", ",", "$", "args", ")", ";", "}", "}" ]
Run action hook. @since 1.0.3 @param string $action → action hook @param int $args → arguments @return callable|false → returns the calling function
[ "Run", "action", "hook", "." ]
12552ef239ea73f3463f2e213f0bdee47568905e
https://github.com/Josantonius/PHP-Hook/blob/12552ef239ea73f3463f2e213f0bdee47568905e/src/Hook.php#L231-L252
231,643
Josantonius/PHP-Hook
src/Hook.php
Hook.getActions
private function getActions($tag, $remove) { if (isset($this->callbacks[$tag])) { $actions = $this->callbacks[$tag]; if ($remove) { unset($this->callbacks[$tag]); } } return (isset($actions)) ? $actions : []; }
php
private function getActions($tag, $remove) { if (isset($this->callbacks[$tag])) { $actions = $this->callbacks[$tag]; if ($remove) { unset($this->callbacks[$tag]); } } return (isset($actions)) ? $actions : []; }
[ "private", "function", "getActions", "(", "$", "tag", ",", "$", "remove", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "callbacks", "[", "$", "tag", "]", ")", ")", "{", "$", "actions", "=", "$", "this", "->", "callbacks", "[", "$", "tag", "]", ";", "if", "(", "$", "remove", ")", "{", "unset", "(", "$", "this", "->", "callbacks", "[", "$", "tag", "]", ")", ";", "}", "}", "return", "(", "isset", "(", "$", "actions", ")", ")", "?", "$", "actions", ":", "[", "]", ";", "}" ]
Get actions for hook @since 1.0.3 @param string $tag → action hook name @param bool $remove → delete hook after executing actions @return object|false → returns the calling function
[ "Get", "actions", "for", "hook" ]
12552ef239ea73f3463f2e213f0bdee47568905e
https://github.com/Josantonius/PHP-Hook/blob/12552ef239ea73f3463f2e213f0bdee47568905e/src/Hook.php#L264-L274
231,644
Josantonius/PHP-Hook
src/Hook.php
Hook.getArguments
private function getArguments($argsNumber, $arguments) { if ($argsNumber == 1 && is_string($arguments)) { return [$arguments]; } elseif ($argsNumber === count($arguments)) { return $arguments; } for ($i = 0; $i < $argsNumber; $i++) { if (array_key_exists($i, $arguments)) { $args[] = $arguments[$i]; continue; } return $args; } return []; }
php
private function getArguments($argsNumber, $arguments) { if ($argsNumber == 1 && is_string($arguments)) { return [$arguments]; } elseif ($argsNumber === count($arguments)) { return $arguments; } for ($i = 0; $i < $argsNumber; $i++) { if (array_key_exists($i, $arguments)) { $args[] = $arguments[$i]; continue; } return $args; } return []; }
[ "private", "function", "getArguments", "(", "$", "argsNumber", ",", "$", "arguments", ")", "{", "if", "(", "$", "argsNumber", "==", "1", "&&", "is_string", "(", "$", "arguments", ")", ")", "{", "return", "[", "$", "arguments", "]", ";", "}", "elseif", "(", "$", "argsNumber", "===", "count", "(", "$", "arguments", ")", ")", "{", "return", "$", "arguments", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "argsNumber", ";", "$", "i", "++", ")", "{", "if", "(", "array_key_exists", "(", "$", "i", ",", "$", "arguments", ")", ")", "{", "$", "args", "[", "]", "=", "$", "arguments", "[", "$", "i", "]", ";", "continue", ";", "}", "return", "$", "args", ";", "}", "return", "[", "]", ";", "}" ]
Get arguments for action. @since 1.0.3 @param int $argsNumber → arguments number @param mixed $arguments → arguments @return array → arguments
[ "Get", "arguments", "for", "action", "." ]
12552ef239ea73f3463f2e213f0bdee47568905e
https://github.com/Josantonius/PHP-Hook/blob/12552ef239ea73f3463f2e213f0bdee47568905e/src/Hook.php#L286-L304
231,645
praxisnetau/silverware
src/Grid/Section.php
Section.renderContainer
public function renderContainer($layout = null, $title = null) { return sprintf( "<div class=\"%s\">\n%s</div>\n", $this->getContainerClass(), $this->renderChildren($layout, $title) ); }
php
public function renderContainer($layout = null, $title = null) { return sprintf( "<div class=\"%s\">\n%s</div>\n", $this->getContainerClass(), $this->renderChildren($layout, $title) ); }
[ "public", "function", "renderContainer", "(", "$", "layout", "=", "null", ",", "$", "title", "=", "null", ")", "{", "return", "sprintf", "(", "\"<div class=\\\"%s\\\">\\n%s</div>\\n\"", ",", "$", "this", "->", "getContainerClass", "(", ")", ",", "$", "this", "->", "renderChildren", "(", "$", "layout", ",", "$", "title", ")", ")", ";", "}" ]
Renders the container for the HTML template. @param string $layout Page layout passed from template. @param string $title Page title passed from template. @return string
[ "Renders", "the", "container", "for", "the", "HTML", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/Section.php#L268-L275
231,646
praxisnetau/silverware
src/Grid/Section.php
Section.getPositionOptions
public function getPositionOptions() { return [ self::POSITION_FIXED_TOP => _t(__CLASS__ . '.FIXEDTOP', 'Fixed Top'), self::POSITION_FIXED_BOTTOM => _t(__CLASS__ . '.FIXEDBOTTOM', 'Fixed Bottom'), self::POSITION_STICKY_TOP => _t(__CLASS__ . '.STICKYTOP', 'Sticky Top') ]; }
php
public function getPositionOptions() { return [ self::POSITION_FIXED_TOP => _t(__CLASS__ . '.FIXEDTOP', 'Fixed Top'), self::POSITION_FIXED_BOTTOM => _t(__CLASS__ . '.FIXEDBOTTOM', 'Fixed Bottom'), self::POSITION_STICKY_TOP => _t(__CLASS__ . '.STICKYTOP', 'Sticky Top') ]; }
[ "public", "function", "getPositionOptions", "(", ")", "{", "return", "[", "self", "::", "POSITION_FIXED_TOP", "=>", "_t", "(", "__CLASS__", ".", "'.FIXEDTOP'", ",", "'Fixed Top'", ")", ",", "self", "::", "POSITION_FIXED_BOTTOM", "=>", "_t", "(", "__CLASS__", ".", "'.FIXEDBOTTOM'", ",", "'Fixed Bottom'", ")", ",", "self", "::", "POSITION_STICKY_TOP", "=>", "_t", "(", "__CLASS__", ".", "'.STICKYTOP'", ",", "'Sticky Top'", ")", "]", ";", "}" ]
Answers an array of options for the position field. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "position", "field", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/Section.php#L282-L289
231,647
i-am-tom/schemer
src/Validator/Boolean.php
Boolean.true
public function true(string $error = 'not true') : Boolean { return $this->pipe( self::predicate( function (bool $bool) : bool { return !!$bool; }, $error ) ); }
php
public function true(string $error = 'not true') : Boolean { return $this->pipe( self::predicate( function (bool $bool) : bool { return !!$bool; }, $error ) ); }
[ "public", "function", "true", "(", "string", "$", "error", "=", "'not true'", ")", ":", "Boolean", "{", "return", "$", "this", "->", "pipe", "(", "self", "::", "predicate", "(", "function", "(", "bool", "$", "bool", ")", ":", "bool", "{", "return", "!", "!", "$", "bool", ";", "}", ",", "$", "error", ")", ")", ";", "}" ]
The value must be true. @param string $error @return Schemer\Validator\Boolean
[ "The", "value", "must", "be", "true", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator/Boolean.php#L26-L36
231,648
wallstreetio/ontraport
src/Resources/Resource.php
Resource.find
public function find($id) { $response = $this->ontraport->get( $this->getSingularNamespace(), $this->toArray(compact('id')) ); return $this->ontraport->item($this, $response); }
php
public function find($id) { $response = $this->ontraport->get( $this->getSingularNamespace(), $this->toArray(compact('id')) ); return $this->ontraport->item($this, $response); }
[ "public", "function", "find", "(", "$", "id", ")", "{", "$", "response", "=", "$", "this", "->", "ontraport", "->", "get", "(", "$", "this", "->", "getSingularNamespace", "(", ")", ",", "$", "this", "->", "toArray", "(", "compact", "(", "'id'", ")", ")", ")", ";", "return", "$", "this", "->", "ontraport", "->", "item", "(", "$", "this", ",", "$", "response", ")", ";", "}" ]
Find an Ontraport resource. @param int $id @return \Wsio\Ontraport\Fluent
[ "Find", "an", "Ontraport", "resource", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L96-L103
231,649
wallstreetio/ontraport
src/Resources/Resource.php
Resource.get
public function get(array $parameters = array()) { $response = $this->ontraport->get( $this->getNamespace(), $this->toArray($parameters) ); return $this->ontraport->collection($this, $response); }
php
public function get(array $parameters = array()) { $response = $this->ontraport->get( $this->getNamespace(), $this->toArray($parameters) ); return $this->ontraport->collection($this, $response); }
[ "public", "function", "get", "(", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "response", "=", "$", "this", "->", "ontraport", "->", "get", "(", "$", "this", "->", "getNamespace", "(", ")", ",", "$", "this", "->", "toArray", "(", "$", "parameters", ")", ")", ";", "return", "$", "this", "->", "ontraport", "->", "collection", "(", "$", "this", ",", "$", "response", ")", ";", "}" ]
Retrieve a collection of Ontraport resources. @param array $parameters @return array
[ "Retrieve", "a", "collection", "of", "Ontraport", "resources", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L123-L130
231,650
wallstreetio/ontraport
src/Resources/Resource.php
Resource.create
public function create(array $data) { $response = $this->ontraport->post( $this->getNamespace(), $this->toArray($data) ); return $this->ontraport->item($this, $response); }
php
public function create(array $data) { $response = $this->ontraport->post( $this->getNamespace(), $this->toArray($data) ); return $this->ontraport->item($this, $response); }
[ "public", "function", "create", "(", "array", "$", "data", ")", "{", "$", "response", "=", "$", "this", "->", "ontraport", "->", "post", "(", "$", "this", "->", "getNamespace", "(", ")", ",", "$", "this", "->", "toArray", "(", "$", "data", ")", ")", ";", "return", "$", "this", "->", "ontraport", "->", "item", "(", "$", "this", ",", "$", "response", ")", ";", "}" ]
Create a new Ontraport resource. @param array $data @return \Wsio\Ontraport\Fluent
[ "Create", "a", "new", "Ontraport", "resource", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L138-L145
231,651
wallstreetio/ontraport
src/Resources/Resource.php
Resource.update
public function update($data, $override = null) { if (func_num_args() == 2) { $override['id'] = $data; $data = $override; } $response = $this->ontraport->put( $this->getNamespace(), $this->toArray($data) ); return $this->ontraport->item($this, $response); }
php
public function update($data, $override = null) { if (func_num_args() == 2) { $override['id'] = $data; $data = $override; } $response = $this->ontraport->put( $this->getNamespace(), $this->toArray($data) ); return $this->ontraport->item($this, $response); }
[ "public", "function", "update", "(", "$", "data", ",", "$", "override", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "==", "2", ")", "{", "$", "override", "[", "'id'", "]", "=", "$", "data", ";", "$", "data", "=", "$", "override", ";", "}", "$", "response", "=", "$", "this", "->", "ontraport", "->", "put", "(", "$", "this", "->", "getNamespace", "(", ")", ",", "$", "this", "->", "toArray", "(", "$", "data", ")", ")", ";", "return", "$", "this", "->", "ontraport", "->", "item", "(", "$", "this", ",", "$", "response", ")", ";", "}" ]
Update an Ontraport resource. @param mixed $data @param array|null $override @return \Wsio\Ontraport\Fluent
[ "Update", "an", "Ontraport", "resource", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L154-L166
231,652
wallstreetio/ontraport
src/Resources/Resource.php
Resource.delete
public function delete($id = null) { if (is_null($id) || is_array($id)) { return $this->deleteMany($id); } $response = $this->ontraport->delete( $this->getSingularNamespace(), $this->toArray(compact('id')) ); return $this->ontraport->item($this, $response); }
php
public function delete($id = null) { if (is_null($id) || is_array($id)) { return $this->deleteMany($id); } $response = $this->ontraport->delete( $this->getSingularNamespace(), $this->toArray(compact('id')) ); return $this->ontraport->item($this, $response); }
[ "public", "function", "delete", "(", "$", "id", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "id", ")", "||", "is_array", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "deleteMany", "(", "$", "id", ")", ";", "}", "$", "response", "=", "$", "this", "->", "ontraport", "->", "delete", "(", "$", "this", "->", "getSingularNamespace", "(", ")", ",", "$", "this", "->", "toArray", "(", "compact", "(", "'id'", ")", ")", ")", ";", "return", "$", "this", "->", "ontraport", "->", "item", "(", "$", "this", ",", "$", "response", ")", ";", "}" ]
Delete one or more Ontraport resources. @param mixed $id @return \Wsio\Ontraport\Fluent
[ "Delete", "one", "or", "more", "Ontraport", "resources", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L174-L185
231,653
wallstreetio/ontraport
src/Resources/Resource.php
Resource.deleteMany
public function deleteMany($ids = null) { if (is_null($ids)) { $parameters = [ 'performAll' => true ]; } else { $parameters = [ 'ids' => implode(',', (array) $ids), ]; } $response = $this->ontraport->delete( $this->getNamespace(), $this->toArray($parameters) ); // When deleting many objects, we get a string for the data field in the response, // saying "Deleted". When an object does not exist, it is ignored by oap. I believe // its safe to assume that we can always return successfuly here. Unless we receive // a non 200 status code in which case an InvalidRequest would be thrown. return true; }
php
public function deleteMany($ids = null) { if (is_null($ids)) { $parameters = [ 'performAll' => true ]; } else { $parameters = [ 'ids' => implode(',', (array) $ids), ]; } $response = $this->ontraport->delete( $this->getNamespace(), $this->toArray($parameters) ); // When deleting many objects, we get a string for the data field in the response, // saying "Deleted". When an object does not exist, it is ignored by oap. I believe // its safe to assume that we can always return successfuly here. Unless we receive // a non 200 status code in which case an InvalidRequest would be thrown. return true; }
[ "public", "function", "deleteMany", "(", "$", "ids", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "ids", ")", ")", "{", "$", "parameters", "=", "[", "'performAll'", "=>", "true", "]", ";", "}", "else", "{", "$", "parameters", "=", "[", "'ids'", "=>", "implode", "(", "','", ",", "(", "array", ")", "$", "ids", ")", ",", "]", ";", "}", "$", "response", "=", "$", "this", "->", "ontraport", "->", "delete", "(", "$", "this", "->", "getNamespace", "(", ")", ",", "$", "this", "->", "toArray", "(", "$", "parameters", ")", ")", ";", "// When deleting many objects, we get a string for the data field in the response,", "// saying \"Deleted\". When an object does not exist, it is ignored by oap. I believe", "// its safe to assume that we can always return successfuly here. Unless we receive", "// a non 200 status code in which case an InvalidRequest would be thrown.", "return", "true", ";", "}" ]
Delete a list of Ontraport resources. @param array $ids @return \Wsio\Ontraport\Fluent
[ "Delete", "a", "list", "of", "Ontraport", "resources", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L193-L215
231,654
wallstreetio/ontraport
src/Resources/Resource.php
Resource.info
public function info(array $data = []) { return $this->ontraport->get($this->getNamespace() . '/getInfo', $this->toArray($data)); }
php
public function info(array $data = []) { return $this->ontraport->get($this->getNamespace() . '/getInfo', $this->toArray($data)); }
[ "public", "function", "info", "(", "array", "$", "data", "=", "[", "]", ")", "{", "return", "$", "this", "->", "ontraport", "->", "get", "(", "$", "this", "->", "getNamespace", "(", ")", ".", "'/getInfo'", ",", "$", "this", "->", "toArray", "(", "$", "data", ")", ")", ";", "}" ]
Retrieve information about an Ontraport resource. @return array
[ "Retrieve", "information", "about", "an", "Ontraport", "resource", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L239-L242
231,655
wallstreetio/ontraport
src/Resources/Resource.php
Resource.meta
public function meta(array $data = []) { return $this->ontraport->get($this->getNamespace() . '/meta', $this->toArray($data)); }
php
public function meta(array $data = []) { return $this->ontraport->get($this->getNamespace() . '/meta', $this->toArray($data)); }
[ "public", "function", "meta", "(", "array", "$", "data", "=", "[", "]", ")", "{", "return", "$", "this", "->", "ontraport", "->", "get", "(", "$", "this", "->", "getNamespace", "(", ")", ".", "'/meta'", ",", "$", "this", "->", "toArray", "(", "$", "data", ")", ")", ";", "}" ]
Retrieve meta about an Ontraport resource. @param array $data @return array
[ "Retrieve", "meta", "about", "an", "Ontraport", "resource", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L250-L253
231,656
wallstreetio/ontraport
src/Resources/Resource.php
Resource.orderBy
public function orderBy($field, $direction = 'asc') { $this->sort = $field; $this->sortDirection = $direction; return $this; }
php
public function orderBy($field, $direction = 'asc') { $this->sort = $field; $this->sortDirection = $direction; return $this; }
[ "public", "function", "orderBy", "(", "$", "field", ",", "$", "direction", "=", "'asc'", ")", "{", "$", "this", "->", "sort", "=", "$", "field", ";", "$", "this", "->", "sortDirection", "=", "$", "direction", ";", "return", "$", "this", ";", "}" ]
The field and direction to sort by. @param string $field @param string $direction @return $this
[ "The", "field", "and", "direction", "to", "sort", "by", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L336-L342
231,657
wallstreetio/ontraport
src/Resources/Resource.php
Resource.where
public function where($field, $operator = null, $value = null, $boolean = 'AND') { // If the developer is adding multiple where statements together, // we will enforce that by adding the approriate boolean. if ($this->condition && count($this->condition) > 0) { $this->condition[] = $boolean; } // Here we will make some assumptions about the operator. If only two values // are passed in, we will assume the operator is an equals sign. Furthermore, // we will identify if the value is null and apply the respective operator. list($value, $operator) = $this->prepareValueAndOperator( $value, $operator, func_num_args() == 2 ); $this->condition[] = [ 'field' => compact('field'), 'op' => $operator, 'value' => $value ]; return $this; }
php
public function where($field, $operator = null, $value = null, $boolean = 'AND') { // If the developer is adding multiple where statements together, // we will enforce that by adding the approriate boolean. if ($this->condition && count($this->condition) > 0) { $this->condition[] = $boolean; } // Here we will make some assumptions about the operator. If only two values // are passed in, we will assume the operator is an equals sign. Furthermore, // we will identify if the value is null and apply the respective operator. list($value, $operator) = $this->prepareValueAndOperator( $value, $operator, func_num_args() == 2 ); $this->condition[] = [ 'field' => compact('field'), 'op' => $operator, 'value' => $value ]; return $this; }
[ "public", "function", "where", "(", "$", "field", ",", "$", "operator", "=", "null", ",", "$", "value", "=", "null", ",", "$", "boolean", "=", "'AND'", ")", "{", "// If the developer is adding multiple where statements together,", "// we will enforce that by adding the approriate boolean.", "if", "(", "$", "this", "->", "condition", "&&", "count", "(", "$", "this", "->", "condition", ")", ">", "0", ")", "{", "$", "this", "->", "condition", "[", "]", "=", "$", "boolean", ";", "}", "// Here we will make some assumptions about the operator. If only two values", "// are passed in, we will assume the operator is an equals sign. Furthermore,", "// we will identify if the value is null and apply the respective operator.", "list", "(", "$", "value", ",", "$", "operator", ")", "=", "$", "this", "->", "prepareValueAndOperator", "(", "$", "value", ",", "$", "operator", ",", "func_num_args", "(", ")", "==", "2", ")", ";", "$", "this", "->", "condition", "[", "]", "=", "[", "'field'", "=>", "compact", "(", "'field'", ")", ",", "'op'", "=>", "$", "operator", ",", "'value'", "=>", "$", "value", "]", ";", "return", "$", "this", ";", "}" ]
Add a constraint to the request query. @param string $field @param string $operator @param string $value @param string $boolean @return $this
[ "Add", "a", "constraint", "to", "the", "request", "query", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L364-L388
231,658
wallstreetio/ontraport
src/Resources/Resource.php
Resource.whereIn
public function whereIn($field, $values) { $list = array_map(function ($value) { return compact('value'); }, $values); $this->condition[] = [ 'field' => compact('field'), 'op' => '=', 'value' => compact('list') ]; return $this; }
php
public function whereIn($field, $values) { $list = array_map(function ($value) { return compact('value'); }, $values); $this->condition[] = [ 'field' => compact('field'), 'op' => '=', 'value' => compact('list') ]; return $this; }
[ "public", "function", "whereIn", "(", "$", "field", ",", "$", "values", ")", "{", "$", "list", "=", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "compact", "(", "'value'", ")", ";", "}", ",", "$", "values", ")", ";", "$", "this", "->", "condition", "[", "]", "=", "[", "'field'", "=>", "compact", "(", "'field'", ")", ",", "'op'", "=>", "'='", ",", "'value'", "=>", "compact", "(", "'list'", ")", "]", ";", "return", "$", "this", ";", "}" ]
Add a where in constraint to the request query. @param string $field @param array $values @return $this
[ "Add", "a", "where", "in", "constraint", "to", "the", "request", "query", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L424-L437
231,659
wallstreetio/ontraport
src/Resources/Resource.php
Resource.prepareValueAndOperator
protected function prepareValueAndOperator($value, $operator) { if (is_null($value) && ! in_array($operator, ['='])) { $value = $operator; $operator = '='; } elseif (! in_array($operator, ['='])) { throw new \InvalidArgumentException('Illegal operator and value combination.'); } if (is_null($value)) { $value = 'NULL'; $operator = 'IS'; } else { $value = compact('value'); } return [$value, $operator]; }
php
protected function prepareValueAndOperator($value, $operator) { if (is_null($value) && ! in_array($operator, ['='])) { $value = $operator; $operator = '='; } elseif (! in_array($operator, ['='])) { throw new \InvalidArgumentException('Illegal operator and value combination.'); } if (is_null($value)) { $value = 'NULL'; $operator = 'IS'; } else { $value = compact('value'); } return [$value, $operator]; }
[ "protected", "function", "prepareValueAndOperator", "(", "$", "value", ",", "$", "operator", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", "&&", "!", "in_array", "(", "$", "operator", ",", "[", "'='", "]", ")", ")", "{", "$", "value", "=", "$", "operator", ";", "$", "operator", "=", "'='", ";", "}", "elseif", "(", "!", "in_array", "(", "$", "operator", ",", "[", "'='", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Illegal operator and value combination.'", ")", ";", "}", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "value", "=", "'NULL'", ";", "$", "operator", "=", "'IS'", ";", "}", "else", "{", "$", "value", "=", "compact", "(", "'value'", ")", ";", "}", "return", "[", "$", "value", ",", "$", "operator", "]", ";", "}" ]
Retrieve the value an operator of the conditional. @param mixed $value @param mixed $operator @return array
[ "Retrieve", "the", "value", "an", "operator", "of", "the", "conditional", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L446-L463
231,660
wallstreetio/ontraport
src/Resources/Resource.php
Resource.toArray
public function toArray(array $data = []) { return array_filter(array_merge([ 'start' => $this->start, 'range' => $this->range, 'sort' => $this->sort, 'sortDir' => $this->sortDirection, 'search' => $this->search, 'searchNotes' => $this->searchNotes, 'condition' => $this->condition ? json_encode($this->condition) : null ], $data), function ($value) { return $value !== null; }); }
php
public function toArray(array $data = []) { return array_filter(array_merge([ 'start' => $this->start, 'range' => $this->range, 'sort' => $this->sort, 'sortDir' => $this->sortDirection, 'search' => $this->search, 'searchNotes' => $this->searchNotes, 'condition' => $this->condition ? json_encode($this->condition) : null ], $data), function ($value) { return $value !== null; }); }
[ "public", "function", "toArray", "(", "array", "$", "data", "=", "[", "]", ")", "{", "return", "array_filter", "(", "array_merge", "(", "[", "'start'", "=>", "$", "this", "->", "start", ",", "'range'", "=>", "$", "this", "->", "range", ",", "'sort'", "=>", "$", "this", "->", "sort", ",", "'sortDir'", "=>", "$", "this", "->", "sortDirection", ",", "'search'", "=>", "$", "this", "->", "search", ",", "'searchNotes'", "=>", "$", "this", "->", "searchNotes", ",", "'condition'", "=>", "$", "this", "->", "condition", "?", "json_encode", "(", "$", "this", "->", "condition", ")", ":", "null", "]", ",", "$", "data", ")", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", ";", "}" ]
Retrieve the default request parameters. @param array $data @return array
[ "Retrieve", "the", "default", "request", "parameters", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L471-L484
231,661
wallstreetio/ontraport
src/Resources/Resource.php
Resource.reset
public function reset() { $this->start = null; $this->range = null; $this->sort = null; $this->sortDirection = null; $this->search = null; $this->searchNotes = null; $this->condition = null; return $this; }
php
public function reset() { $this->start = null; $this->range = null; $this->sort = null; $this->sortDirection = null; $this->search = null; $this->searchNotes = null; $this->condition = null; return $this; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "start", "=", "null", ";", "$", "this", "->", "range", "=", "null", ";", "$", "this", "->", "sort", "=", "null", ";", "$", "this", "->", "sortDirection", "=", "null", ";", "$", "this", "->", "search", "=", "null", ";", "$", "this", "->", "searchNotes", "=", "null", ";", "$", "this", "->", "condition", "=", "null", ";", "return", "$", "this", ";", "}" ]
Reset the resource parameters. @return $this
[ "Reset", "the", "resource", "parameters", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Resources/Resource.php#L491-L501
231,662
praxisnetau/silverware
src/Extensions/AreaExtension.php
AreaExtension.getPanelForArea
public function getPanelForArea(AreaComponent $area) { // Answer Panel from Children: foreach ($this->owner->getChildPanels() as $panel) { if ($panel->hasArea($area)) { return $panel; } } // Answer Panel from Owner: foreach ($this->owner->Panels() as $panel) { if ($panel->hasArea($area)) { return $panel; } } // Answer Panel from Parent: if (($parent = $this->owner->getParent()) && $parent instanceof Page) { if (($panel = $parent->getPanelForArea($area)) && $panel->isInherited()) { return $panel; } } // Answer Panel for All Pages: return $area->getFolderPanels()->find('ShowOn', 'AllPages'); }
php
public function getPanelForArea(AreaComponent $area) { // Answer Panel from Children: foreach ($this->owner->getChildPanels() as $panel) { if ($panel->hasArea($area)) { return $panel; } } // Answer Panel from Owner: foreach ($this->owner->Panels() as $panel) { if ($panel->hasArea($area)) { return $panel; } } // Answer Panel from Parent: if (($parent = $this->owner->getParent()) && $parent instanceof Page) { if (($panel = $parent->getPanelForArea($area)) && $panel->isInherited()) { return $panel; } } // Answer Panel for All Pages: return $area->getFolderPanels()->find('ShowOn', 'AllPages'); }
[ "public", "function", "getPanelForArea", "(", "AreaComponent", "$", "area", ")", "{", "// Answer Panel from Children:", "foreach", "(", "$", "this", "->", "owner", "->", "getChildPanels", "(", ")", "as", "$", "panel", ")", "{", "if", "(", "$", "panel", "->", "hasArea", "(", "$", "area", ")", ")", "{", "return", "$", "panel", ";", "}", "}", "// Answer Panel from Owner:", "foreach", "(", "$", "this", "->", "owner", "->", "Panels", "(", ")", "as", "$", "panel", ")", "{", "if", "(", "$", "panel", "->", "hasArea", "(", "$", "area", ")", ")", "{", "return", "$", "panel", ";", "}", "}", "// Answer Panel from Parent:", "if", "(", "(", "$", "parent", "=", "$", "this", "->", "owner", "->", "getParent", "(", ")", ")", "&&", "$", "parent", "instanceof", "Page", ")", "{", "if", "(", "(", "$", "panel", "=", "$", "parent", "->", "getPanelForArea", "(", "$", "area", ")", ")", "&&", "$", "panel", "->", "isInherited", "(", ")", ")", "{", "return", "$", "panel", ";", "}", "}", "// Answer Panel for All Pages:", "return", "$", "area", "->", "getFolderPanels", "(", ")", "->", "find", "(", "'ShowOn'", ",", "'AllPages'", ")", ";", "}" ]
Answers the panel associated with the given area component. @param AreaComponent $area @return Panel
[ "Answers", "the", "panel", "associated", "with", "the", "given", "area", "component", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/AreaExtension.php#L54-L89
231,663
i-am-tom/schemer
src/Validator/NestableAbstract.php
NestableAbstract.unnest
protected static function unnest(NestableResult $struct) : Result { $result = $struct->outer(); foreach ($struct as $key => $error) { if ($error instanceof NestableResult) { $error = self::unnest($error); } $result = $result->concat( $error->map(function ($e) use ($key) { return $key . ': ' . $e; }) ); } return $result; }
php
protected static function unnest(NestableResult $struct) : Result { $result = $struct->outer(); foreach ($struct as $key => $error) { if ($error instanceof NestableResult) { $error = self::unnest($error); } $result = $result->concat( $error->map(function ($e) use ($key) { return $key . ': ' . $e; }) ); } return $result; }
[ "protected", "static", "function", "unnest", "(", "NestableResult", "$", "struct", ")", ":", "Result", "{", "$", "result", "=", "$", "struct", "->", "outer", "(", ")", ";", "foreach", "(", "$", "struct", "as", "$", "key", "=>", "$", "error", ")", "{", "if", "(", "$", "error", "instanceof", "NestableResult", ")", "{", "$", "error", "=", "self", "::", "unnest", "(", "$", "error", ")", ";", "}", "$", "result", "=", "$", "result", "->", "concat", "(", "$", "error", "->", "map", "(", "function", "(", "$", "e", ")", "use", "(", "$", "key", ")", "{", "return", "$", "key", ".", "': '", ".", "$", "e", ";", "}", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Collapse a nested error into a standard Result object. @param array $errors The nested error set. @return Result The unnested Result object.
[ "Collapse", "a", "nested", "error", "into", "a", "standard", "Result", "object", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator/NestableAbstract.php#L47-L64
231,664
praxisnetau/silverware
src/Extensions/Style/CornerStyle.php
CornerStyle.getCornerStyleClass
public function getCornerStyleClass() { switch ($this->owner->CornerStyle) { case self::CORNER_ROUNDED: return $this->style('rounded'); case self::CORNER_CIRCULAR: return $this->style('rounded.circle'); } }
php
public function getCornerStyleClass() { switch ($this->owner->CornerStyle) { case self::CORNER_ROUNDED: return $this->style('rounded'); case self::CORNER_CIRCULAR: return $this->style('rounded.circle'); } }
[ "public", "function", "getCornerStyleClass", "(", ")", "{", "switch", "(", "$", "this", "->", "owner", "->", "CornerStyle", ")", "{", "case", "self", "::", "CORNER_ROUNDED", ":", "return", "$", "this", "->", "style", "(", "'rounded'", ")", ";", "case", "self", "::", "CORNER_CIRCULAR", ":", "return", "$", "this", "->", "style", "(", "'rounded.circle'", ")", ";", "}", "}" ]
Answers the corner style class of the extended object. @return string
[ "Answers", "the", "corner", "style", "class", "of", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/CornerStyle.php#L125-L133
231,665
praxisnetau/silverware
src/Tools/ViewTools.php
ViewTools.convertClass
public function convertClass($val) { if (is_array($val)) { foreach ($val as $k => $v) { $val[$k] = $this->convertClass($v); } return $val; } return strtolower(trim(str_replace('\\', '-', $val), '-')); }
php
public function convertClass($val) { if (is_array($val)) { foreach ($val as $k => $v) { $val[$k] = $this->convertClass($v); } return $val; } return strtolower(trim(str_replace('\\', '-', $val), '-')); }
[ "public", "function", "convertClass", "(", "$", "val", ")", "{", "if", "(", "is_array", "(", "$", "val", ")", ")", "{", "foreach", "(", "$", "val", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "val", "[", "$", "k", "]", "=", "$", "this", "->", "convertClass", "(", "$", "v", ")", ";", "}", "return", "$", "val", ";", "}", "return", "strtolower", "(", "trim", "(", "str_replace", "(", "'\\\\'", ",", "'-'", ",", "$", "val", ")", ",", "'-'", ")", ")", ";", "}" ]
Converts the given value to a string suitable for HTML class attributes. @param string|array $val @return string
[ "Converts", "the", "given", "value", "to", "a", "string", "suitable", "for", "HTML", "class", "attributes", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/ViewTools.php#L60-L73
231,666
praxisnetau/silverware
src/Tools/ViewTools.php
ViewTools.getAncestorClassNames
public function getAncestorClassNames($nameOrObject, $stopAt = null, $removeNamespaces = true) { return $this->convertClass( ClassTools::singleton()->getObjectAncestry( $nameOrObject, $stopAt, $removeNamespaces ) ); }
php
public function getAncestorClassNames($nameOrObject, $stopAt = null, $removeNamespaces = true) { return $this->convertClass( ClassTools::singleton()->getObjectAncestry( $nameOrObject, $stopAt, $removeNamespaces ) ); }
[ "public", "function", "getAncestorClassNames", "(", "$", "nameOrObject", ",", "$", "stopAt", "=", "null", ",", "$", "removeNamespaces", "=", "true", ")", "{", "return", "$", "this", "->", "convertClass", "(", "ClassTools", "::", "singleton", "(", ")", "->", "getObjectAncestry", "(", "$", "nameOrObject", ",", "$", "stopAt", ",", "$", "removeNamespaces", ")", ")", ";", "}" ]
Answers an array of ancestor class names for the given object. @param string|object $nameOrObject Class name or object. @param string $stopAt Ancestor class to stop at. @param boolean $removeNamespaces If true, remove namespaces from class names. @return array
[ "Answers", "an", "array", "of", "ancestor", "class", "names", "for", "the", "given", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/ViewTools.php#L84-L93
231,667
praxisnetau/silverware
src/Tools/ViewTools.php
ViewTools.combineFiles
public function combineFiles($name, $files) { $backend = Requirements::backend(); $path = File::join_paths($backend->getCombinedFilesFolder(), $name); return $backend->getAssetHandler()->getContentURL($path, function () use ($files) { $output = []; foreach ($files as $file => $data) { $output[] = "/***** FILE: $file *****/"; $output[] = $data; } return implode("\n", $output); }); }
php
public function combineFiles($name, $files) { $backend = Requirements::backend(); $path = File::join_paths($backend->getCombinedFilesFolder(), $name); return $backend->getAssetHandler()->getContentURL($path, function () use ($files) { $output = []; foreach ($files as $file => $data) { $output[] = "/***** FILE: $file *****/"; $output[] = $data; } return implode("\n", $output); }); }
[ "public", "function", "combineFiles", "(", "$", "name", ",", "$", "files", ")", "{", "$", "backend", "=", "Requirements", "::", "backend", "(", ")", ";", "$", "path", "=", "File", "::", "join_paths", "(", "$", "backend", "->", "getCombinedFilesFolder", "(", ")", ",", "$", "name", ")", ";", "return", "$", "backend", "->", "getAssetHandler", "(", ")", "->", "getContentURL", "(", "$", "path", ",", "function", "(", ")", "use", "(", "$", "files", ")", "{", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "file", "=>", "$", "data", ")", "{", "$", "output", "[", "]", "=", "\"/***** FILE: $file *****/\"", ";", "$", "output", "[", "]", "=", "$", "data", ";", "}", "return", "implode", "(", "\"\\n\"", ",", "$", "output", ")", ";", "}", ")", ";", "}" ]
Combines the given array of files into a single file within the specified name and answers the URL. @param string $name @param array $files @return string
[ "Combines", "the", "given", "array", "of", "files", "into", "a", "single", "file", "within", "the", "specified", "name", "and", "answers", "the", "URL", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/ViewTools.php#L150-L168
231,668
praxisnetau/silverware
src/Tools/ViewTools.php
ViewTools.minifyCSS
public function minifyCSS($css, $wrap = 200) { // Remove Comments: $css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css); // Remove Space Following Colons: $css = str_replace(': ', ':', $css); // Remove Whitespace: $css = str_replace(["\r\n", "\r", "\n", "\t", ' ', ' ', ' '], '', $css); // Wrap and Answer: return wordwrap($css, $wrap); }
php
public function minifyCSS($css, $wrap = 200) { // Remove Comments: $css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css); // Remove Space Following Colons: $css = str_replace(': ', ':', $css); // Remove Whitespace: $css = str_replace(["\r\n", "\r", "\n", "\t", ' ', ' ', ' '], '', $css); // Wrap and Answer: return wordwrap($css, $wrap); }
[ "public", "function", "minifyCSS", "(", "$", "css", ",", "$", "wrap", "=", "200", ")", "{", "// Remove Comments:", "$", "css", "=", "preg_replace", "(", "'!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!'", ",", "''", ",", "$", "css", ")", ";", "// Remove Space Following Colons:", "$", "css", "=", "str_replace", "(", "': '", ",", "':'", ",", "$", "css", ")", ";", "// Remove Whitespace:", "$", "css", "=", "str_replace", "(", "[", "\"\\r\\n\"", ",", "\"\\r\"", ",", "\"\\n\"", ",", "\"\\t\"", ",", "' '", ",", "' '", ",", "' '", "]", ",", "''", ",", "$", "css", ")", ";", "// Wrap and Answer:", "return", "wordwrap", "(", "$", "css", ",", "$", "wrap", ")", ";", "}" ]
Minifies and wraps the given string of CSS. @param string $css @param integer $wrap @return string
[ "Minifies", "and", "wraps", "the", "given", "string", "of", "CSS", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/ViewTools.php#L178-L195
231,669
praxisnetau/silverware
src/Tools/ViewTools.php
ViewTools.getAttributesHTML
public function getAttributesHTML($attributes) { // Initialise: $markup = []; // Remove Empty Attributes: $attributes = array_filter($attributes, function ($v) { return ($v || $v === 0 || $v === '0'); }); // Render Remaining Attributes: foreach ($attributes as $name => $value) { $markup[] = sprintf('%s="%s"', $name, ($value === true) ? $name : Convert::raw2att($value)); } // Answer Markup: return implode(' ', $markup); }
php
public function getAttributesHTML($attributes) { // Initialise: $markup = []; // Remove Empty Attributes: $attributes = array_filter($attributes, function ($v) { return ($v || $v === 0 || $v === '0'); }); // Render Remaining Attributes: foreach ($attributes as $name => $value) { $markup[] = sprintf('%s="%s"', $name, ($value === true) ? $name : Convert::raw2att($value)); } // Answer Markup: return implode(' ', $markup); }
[ "public", "function", "getAttributesHTML", "(", "$", "attributes", ")", "{", "// Initialise:", "$", "markup", "=", "[", "]", ";", "// Remove Empty Attributes:", "$", "attributes", "=", "array_filter", "(", "$", "attributes", ",", "function", "(", "$", "v", ")", "{", "return", "(", "$", "v", "||", "$", "v", "===", "0", "||", "$", "v", "===", "'0'", ")", ";", "}", ")", ";", "// Render Remaining Attributes:", "foreach", "(", "$", "attributes", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "markup", "[", "]", "=", "sprintf", "(", "'%s=\"%s\"'", ",", "$", "name", ",", "(", "$", "value", "===", "true", ")", "?", "$", "name", ":", "Convert", "::", "raw2att", "(", "$", "value", ")", ")", ";", "}", "// Answer Markup:", "return", "implode", "(", "' '", ",", "$", "markup", ")", ";", "}" ]
Converts the given associative array of attributes to a string of HTML. @param array $attributes @return string
[ "Converts", "the", "given", "associative", "array", "of", "attributes", "to", "a", "string", "of", "HTML", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/ViewTools.php#L204-L225
231,670
praxisnetau/silverware
src/Tools/ViewTools.php
ViewTools.processAttributeArgs
public function processAttributeArgs($stringOrArray, ViewableData $object, ViewableData $parent = null) { $args = (array) $stringOrArray; foreach ($args as $key => $arg) { $args[$key] = $this->processAttribute($arg, $object, $parent); } return $args; }
php
public function processAttributeArgs($stringOrArray, ViewableData $object, ViewableData $parent = null) { $args = (array) $stringOrArray; foreach ($args as $key => $arg) { $args[$key] = $this->processAttribute($arg, $object, $parent); } return $args; }
[ "public", "function", "processAttributeArgs", "(", "$", "stringOrArray", ",", "ViewableData", "$", "object", ",", "ViewableData", "$", "parent", "=", "null", ")", "{", "$", "args", "=", "(", "array", ")", "$", "stringOrArray", ";", "foreach", "(", "$", "args", "as", "$", "key", "=>", "$", "arg", ")", "{", "$", "args", "[", "$", "key", "]", "=", "$", "this", "->", "processAttribute", "(", "$", "arg", ",", "$", "object", ",", "$", "parent", ")", ";", "}", "return", "$", "args", ";", "}" ]
Processes the given array of arguments for an attribute. @param string|array $stringOrArray @param ViewableData $object @param ViewableData $parent @return array
[ "Processes", "the", "given", "array", "of", "arguments", "for", "an", "attribute", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/ViewTools.php#L316-L325
231,671
praxisnetau/silverware
src/Tools/ViewTools.php
ViewTools.renderCSS
public function renderCSS(ViewableData $object, $template, $css = []) { if (SSViewer::hasTemplate($template)) { return array_merge( $css, preg_split('/\r\n|\n|\r/', (string) $object->renderWith($template)) ); } return $css; }
php
public function renderCSS(ViewableData $object, $template, $css = []) { if (SSViewer::hasTemplate($template)) { return array_merge( $css, preg_split('/\r\n|\n|\r/', (string) $object->renderWith($template)) ); } return $css; }
[ "public", "function", "renderCSS", "(", "ViewableData", "$", "object", ",", "$", "template", ",", "$", "css", "=", "[", "]", ")", "{", "if", "(", "SSViewer", "::", "hasTemplate", "(", "$", "template", ")", ")", "{", "return", "array_merge", "(", "$", "css", ",", "preg_split", "(", "'/\\r\\n|\\n|\\r/'", ",", "(", "string", ")", "$", "object", "->", "renderWith", "(", "$", "template", ")", ")", ")", ";", "}", "return", "$", "css", ";", "}" ]
Renders the given object using the given CSS template. @param ViewableData $object @param string $template @param array $css @return array
[ "Renders", "the", "given", "object", "using", "the", "given", "CSS", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/ViewTools.php#L348-L360
231,672
praxisnetau/silverware
src/Extensions/Model/LinkToExtension.php
LinkToExtension.getLinkAttributes
public function getLinkAttributes() { $attributes = [ 'href' => $this->owner->Link, 'title' => $this->owner->LinkTitle ]; if ($class = $this->owner->LinkClass) { $attributes['class'] = $class; } if ($this->owner->OpenLinkInNewTab) { $attributes['target'] = '_blank'; } return $attributes; }
php
public function getLinkAttributes() { $attributes = [ 'href' => $this->owner->Link, 'title' => $this->owner->LinkTitle ]; if ($class = $this->owner->LinkClass) { $attributes['class'] = $class; } if ($this->owner->OpenLinkInNewTab) { $attributes['target'] = '_blank'; } return $attributes; }
[ "public", "function", "getLinkAttributes", "(", ")", "{", "$", "attributes", "=", "[", "'href'", "=>", "$", "this", "->", "owner", "->", "Link", ",", "'title'", "=>", "$", "this", "->", "owner", "->", "LinkTitle", "]", ";", "if", "(", "$", "class", "=", "$", "this", "->", "owner", "->", "LinkClass", ")", "{", "$", "attributes", "[", "'class'", "]", "=", "$", "class", ";", "}", "if", "(", "$", "this", "->", "owner", "->", "OpenLinkInNewTab", ")", "{", "$", "attributes", "[", "'target'", "]", "=", "'_blank'", ";", "}", "return", "$", "attributes", ";", "}" ]
Answers an array of attributes for a link. @return array
[ "Answers", "an", "array", "of", "attributes", "for", "a", "link", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/LinkToExtension.php#L178-L194
231,673
praxisnetau/silverware
src/Extensions/Model/LinkToExtension.php
LinkToExtension.getLink
public function getLink() { if ($this->owner->isURL() && $this->owner->LinkURL) { return $this->owner->dbObject('LinkURL')->URL(); } if ($this->owner->isPage() && $this->owner->LinkPageID) { return $this->owner->LinkPage()->Link(); } }
php
public function getLink() { if ($this->owner->isURL() && $this->owner->LinkURL) { return $this->owner->dbObject('LinkURL')->URL(); } if ($this->owner->isPage() && $this->owner->LinkPageID) { return $this->owner->LinkPage()->Link(); } }
[ "public", "function", "getLink", "(", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "isURL", "(", ")", "&&", "$", "this", "->", "owner", "->", "LinkURL", ")", "{", "return", "$", "this", "->", "owner", "->", "dbObject", "(", "'LinkURL'", ")", "->", "URL", "(", ")", ";", "}", "if", "(", "$", "this", "->", "owner", "->", "isPage", "(", ")", "&&", "$", "this", "->", "owner", "->", "LinkPageID", ")", "{", "return", "$", "this", "->", "owner", "->", "LinkPage", "(", ")", "->", "Link", "(", ")", ";", "}", "}" ]
Answers the link for the template. @return string
[ "Answers", "the", "link", "for", "the", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/LinkToExtension.php#L241-L250
231,674
praxisnetau/silverware
src/Forms/ViewportsField.php
ViewportsField.setSource
public function setSource($source) { $this->source = $this->getSourceAsArray($source); $this->updateViewportFields(); return $this; }
php
public function setSource($source) { $this->source = $this->getSourceAsArray($source); $this->updateViewportFields(); return $this; }
[ "public", "function", "setSource", "(", "$", "source", ")", "{", "$", "this", "->", "source", "=", "$", "this", "->", "getSourceAsArray", "(", "$", "source", ")", ";", "$", "this", "->", "updateViewportFields", "(", ")", ";", "return", "$", "this", ";", "}" ]
Defines the value of the source attribute. @param array|ArrayAccess $source @return $this
[ "Defines", "the", "value", "of", "the", "source", "attribute", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/ViewportsField.php#L223-L230
231,675
praxisnetau/silverware
src/Forms/ViewportsField.php
ViewportsField.setViewportLabel
public function setViewportLabel($viewport, $label) { $this->labels[$viewport] = $label; $this->updateViewportFields(); return $this; }
php
public function setViewportLabel($viewport, $label) { $this->labels[$viewport] = $label; $this->updateViewportFields(); return $this; }
[ "public", "function", "setViewportLabel", "(", "$", "viewport", ",", "$", "label", ")", "{", "$", "this", "->", "labels", "[", "$", "viewport", "]", "=", "$", "label", ";", "$", "this", "->", "updateViewportFields", "(", ")", ";", "return", "$", "this", ";", "}" ]
Defines the label for the specified viewport. @param string $viewport @param string $label @return $this
[ "Defines", "the", "label", "for", "the", "specified", "viewport", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/ViewportsField.php#L308-L315
231,676
praxisnetau/silverware
src/Forms/ViewportsField.php
ViewportsField.getViewportValues
public function getViewportValues() { $values = []; foreach ($this->getViewports() as $viewport) { $values[$viewport] = $this->getViewportField($viewport)->dataValue(); } return $values; }
php
public function getViewportValues() { $values = []; foreach ($this->getViewports() as $viewport) { $values[$viewport] = $this->getViewportField($viewport)->dataValue(); } return $values; }
[ "public", "function", "getViewportValues", "(", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "$", "values", "[", "$", "viewport", "]", "=", "$", "this", "->", "getViewportField", "(", "$", "viewport", ")", "->", "dataValue", "(", ")", ";", "}", "return", "$", "values", ";", "}" ]
Answers an array containing the values of the viewport fields. @return array
[ "Answers", "an", "array", "containing", "the", "values", "of", "the", "viewport", "fields", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/ViewportsField.php#L338-L347
231,677
praxisnetau/silverware
src/Forms/ViewportsField.php
ViewportsField.setHiddenViewports
public function setHiddenViewports() { $args = func_get_args(); if (count($args) == 1 && is_array($args[0])) { $viewports = $args[0]; } else { $viewports = $args; } foreach ($viewports as $viewport) { if ($this->getViewportField($viewport)) { $this->hidden[$viewport] = true; } } $this->updateViewportFields(); return $this; }
php
public function setHiddenViewports() { $args = func_get_args(); if (count($args) == 1 && is_array($args[0])) { $viewports = $args[0]; } else { $viewports = $args; } foreach ($viewports as $viewport) { if ($this->getViewportField($viewport)) { $this->hidden[$viewport] = true; } } $this->updateViewportFields(); return $this; }
[ "public", "function", "setHiddenViewports", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "args", ")", "==", "1", "&&", "is_array", "(", "$", "args", "[", "0", "]", ")", ")", "{", "$", "viewports", "=", "$", "args", "[", "0", "]", ";", "}", "else", "{", "$", "viewports", "=", "$", "args", ";", "}", "foreach", "(", "$", "viewports", "as", "$", "viewport", ")", "{", "if", "(", "$", "this", "->", "getViewportField", "(", "$", "viewport", ")", ")", "{", "$", "this", "->", "hidden", "[", "$", "viewport", "]", "=", "true", ";", "}", "}", "$", "this", "->", "updateViewportFields", "(", ")", ";", "return", "$", "this", ";", "}" ]
Defines the viewport fields to hide from display. @return $this
[ "Defines", "the", "viewport", "fields", "to", "hide", "from", "display", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/ViewportsField.php#L354-L375
231,678
praxisnetau/silverware
src/Forms/ViewportsField.php
ViewportsField.getSourceAsArray
protected function getSourceAsArray($source) { if (!is_array($source) && !($source instanceof ArrayAccess)) { user_error('$source passed in as invalid type', E_USER_ERROR); } if ($source instanceof SS_List || $source instanceof Map) { $source = $source->toArray(); } return $source; }
php
protected function getSourceAsArray($source) { if (!is_array($source) && !($source instanceof ArrayAccess)) { user_error('$source passed in as invalid type', E_USER_ERROR); } if ($source instanceof SS_List || $source instanceof Map) { $source = $source->toArray(); } return $source; }
[ "protected", "function", "getSourceAsArray", "(", "$", "source", ")", "{", "if", "(", "!", "is_array", "(", "$", "source", ")", "&&", "!", "(", "$", "source", "instanceof", "ArrayAccess", ")", ")", "{", "user_error", "(", "'$source passed in as invalid type'", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "$", "source", "instanceof", "SS_List", "||", "$", "source", "instanceof", "Map", ")", "{", "$", "source", "=", "$", "source", "->", "toArray", "(", ")", ";", "}", "return", "$", "source", ";", "}" ]
Converts the given source parameter to an array. @param array|ArrayAccess $source @return array
[ "Converts", "the", "given", "source", "parameter", "to", "an", "array", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/ViewportsField.php#L481-L492
231,679
praxisnetau/silverware
src/Forms/ViewportsField.php
ViewportsField.buildViewportFields
protected function buildViewportFields() { foreach ($this->getViewports() as $viewport) { $this->push($this->buildViewportField($viewport)); } }
php
protected function buildViewportFields() { foreach ($this->getViewports() as $viewport) { $this->push($this->buildViewportField($viewport)); } }
[ "protected", "function", "buildViewportFields", "(", ")", "{", "foreach", "(", "$", "this", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "$", "this", "->", "push", "(", "$", "this", "->", "buildViewportField", "(", "$", "viewport", ")", ")", ";", "}", "}" ]
Builds the viewport fields for the receiver. @return void
[ "Builds", "the", "viewport", "fields", "for", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/ViewportsField.php#L499-L504
231,680
praxisnetau/silverware
src/Forms/ViewportsField.php
ViewportsField.buildViewportField
protected function buildViewportField($viewport) { if ($this->useTextInput) { $field = TextField::create( $this->getViewportName($viewport), $this->getViewportLabel($viewport) ); } else { $field = DropdownField::create( $this->getViewportName($viewport), $this->getViewportLabel($viewport), $this->getSource() ); } return $field; }
php
protected function buildViewportField($viewport) { if ($this->useTextInput) { $field = TextField::create( $this->getViewportName($viewport), $this->getViewportLabel($viewport) ); } else { $field = DropdownField::create( $this->getViewportName($viewport), $this->getViewportLabel($viewport), $this->getSource() ); } return $field; }
[ "protected", "function", "buildViewportField", "(", "$", "viewport", ")", "{", "if", "(", "$", "this", "->", "useTextInput", ")", "{", "$", "field", "=", "TextField", "::", "create", "(", "$", "this", "->", "getViewportName", "(", "$", "viewport", ")", ",", "$", "this", "->", "getViewportLabel", "(", "$", "viewport", ")", ")", ";", "}", "else", "{", "$", "field", "=", "DropdownField", "::", "create", "(", "$", "this", "->", "getViewportName", "(", "$", "viewport", ")", ",", "$", "this", "->", "getViewportLabel", "(", "$", "viewport", ")", ",", "$", "this", "->", "getSource", "(", ")", ")", ";", "}", "return", "$", "field", ";", "}" ]
Builds and answers a form field for the specified viewport. @param string $viewport @return FormField
[ "Builds", "and", "answers", "a", "form", "field", "for", "the", "specified", "viewport", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/ViewportsField.php#L513-L533
231,681
praxisnetau/silverware
src/Forms/ViewportsField.php
ViewportsField.updateViewportFields
protected function updateViewportFields() { foreach ($this->getViewports() as $viewport) { // Obtain Field: if (!($field = $this->getViewportField($viewport))) { continue; } // Update Title: $field->setTitle($this->getViewportLabel($viewport)); // Update Hidden Status: if ($this->isViewportHidden($viewport)) { $field->addExtraClass('hidden'); } else { $field->removeExtraClass('hidden'); } // Update Dropdown Fields: if ($field instanceof DropdownField) { // Update Empty Strings: if ($field->hasMethod('setEmptyString')) { $field->setEmptyString(' ')->setAttribute('data-placeholder', $this->emptyString); } // Update Source: $field->setSource($this->getSource()); } // Update Disabled Flags: $field->setDisabled($this->disabled); // Update Readonly Flags: $field->setReadonly($this->readonly); } }
php
protected function updateViewportFields() { foreach ($this->getViewports() as $viewport) { // Obtain Field: if (!($field = $this->getViewportField($viewport))) { continue; } // Update Title: $field->setTitle($this->getViewportLabel($viewport)); // Update Hidden Status: if ($this->isViewportHidden($viewport)) { $field->addExtraClass('hidden'); } else { $field->removeExtraClass('hidden'); } // Update Dropdown Fields: if ($field instanceof DropdownField) { // Update Empty Strings: if ($field->hasMethod('setEmptyString')) { $field->setEmptyString(' ')->setAttribute('data-placeholder', $this->emptyString); } // Update Source: $field->setSource($this->getSource()); } // Update Disabled Flags: $field->setDisabled($this->disabled); // Update Readonly Flags: $field->setReadonly($this->readonly); } }
[ "protected", "function", "updateViewportFields", "(", ")", "{", "foreach", "(", "$", "this", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "// Obtain Field:", "if", "(", "!", "(", "$", "field", "=", "$", "this", "->", "getViewportField", "(", "$", "viewport", ")", ")", ")", "{", "continue", ";", "}", "// Update Title:", "$", "field", "->", "setTitle", "(", "$", "this", "->", "getViewportLabel", "(", "$", "viewport", ")", ")", ";", "// Update Hidden Status:", "if", "(", "$", "this", "->", "isViewportHidden", "(", "$", "viewport", ")", ")", "{", "$", "field", "->", "addExtraClass", "(", "'hidden'", ")", ";", "}", "else", "{", "$", "field", "->", "removeExtraClass", "(", "'hidden'", ")", ";", "}", "// Update Dropdown Fields:", "if", "(", "$", "field", "instanceof", "DropdownField", ")", "{", "// Update Empty Strings:", "if", "(", "$", "field", "->", "hasMethod", "(", "'setEmptyString'", ")", ")", "{", "$", "field", "->", "setEmptyString", "(", "' '", ")", "->", "setAttribute", "(", "'data-placeholder'", ",", "$", "this", "->", "emptyString", ")", ";", "}", "// Update Source:", "$", "field", "->", "setSource", "(", "$", "this", "->", "getSource", "(", ")", ")", ";", "}", "// Update Disabled Flags:", "$", "field", "->", "setDisabled", "(", "$", "this", "->", "disabled", ")", ";", "// Update Readonly Flags:", "$", "field", "->", "setReadonly", "(", "$", "this", "->", "readonly", ")", ";", "}", "}" ]
Updates the viewport fields after a state change. @return void
[ "Updates", "the", "viewport", "fields", "after", "a", "state", "change", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/ViewportsField.php#L540-L587
231,682
kamilZ/B2Backblaze
src/B2Backblaze/B2Service.php
B2Service.authorize
public function authorize() { $response = $this->client->b2AuthorizeAccount(); if ($response->isOk()) { $this->apiURL = $response->get('apiUrl'); $this->token = $response->get('authorizationToken'); $this->downloadURL = $response->get('downloadUrl'); $this->minimumPartSize = $response->get('minimumPartSize'); return true; } return false; }
php
public function authorize() { $response = $this->client->b2AuthorizeAccount(); if ($response->isOk()) { $this->apiURL = $response->get('apiUrl'); $this->token = $response->get('authorizationToken'); $this->downloadURL = $response->get('downloadUrl'); $this->minimumPartSize = $response->get('minimumPartSize'); return true; } return false; }
[ "public", "function", "authorize", "(", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "b2AuthorizeAccount", "(", ")", ";", "if", "(", "$", "response", "->", "isOk", "(", ")", ")", "{", "$", "this", "->", "apiURL", "=", "$", "response", "->", "get", "(", "'apiUrl'", ")", ";", "$", "this", "->", "token", "=", "$", "response", "->", "get", "(", "'authorizationToken'", ")", ";", "$", "this", "->", "downloadURL", "=", "$", "response", "->", "get", "(", "'downloadUrl'", ")", ";", "$", "this", "->", "minimumPartSize", "=", "$", "response", "->", "get", "(", "'minimumPartSize'", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Authenticate with server. @return bool
[ "Authenticate", "with", "server", "." ]
64d25e60849f7bcb957a070af3231694da118f55
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Service.php#L41-L54
231,683
kamilZ/B2Backblaze
src/B2Backblaze/B2Service.php
B2Service.isBucketExist
public function isBucketExist($bucketId) { $this->ensureAuthorized(); $response = $this->client->b2ListBuckets($this->apiURL, $this->token); if ($response->isOk()) { $buckets = $response->get('buckets'); if (!is_null($buckets)) { foreach ($buckets as $bucket) { if ($bucketId == $bucket['bucketId']) { return true; } } } } return false; }
php
public function isBucketExist($bucketId) { $this->ensureAuthorized(); $response = $this->client->b2ListBuckets($this->apiURL, $this->token); if ($response->isOk()) { $buckets = $response->get('buckets'); if (!is_null($buckets)) { foreach ($buckets as $bucket) { if ($bucketId == $bucket['bucketId']) { return true; } } } } return false; }
[ "public", "function", "isBucketExist", "(", "$", "bucketId", ")", "{", "$", "this", "->", "ensureAuthorized", "(", ")", ";", "$", "response", "=", "$", "this", "->", "client", "->", "b2ListBuckets", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ")", ";", "if", "(", "$", "response", "->", "isOk", "(", ")", ")", "{", "$", "buckets", "=", "$", "response", "->", "get", "(", "'buckets'", ")", ";", "if", "(", "!", "is_null", "(", "$", "buckets", ")", ")", "{", "foreach", "(", "$", "buckets", "as", "$", "bucket", ")", "{", "if", "(", "$", "bucketId", "==", "$", "bucket", "[", "'bucketId'", "]", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Returns true if bucket exist. @param $bucketId @return bool
[ "Returns", "true", "if", "bucket", "exist", "." ]
64d25e60849f7bcb957a070af3231694da118f55
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Service.php#L63-L79
231,684
kamilZ/B2Backblaze
src/B2Backblaze/B2Service.php
B2Service.get
public function get($bucketName, $fileName, $private = false, $metadataOnly = false) { $token = null; if ($private == true) { $this->ensureAuthorized(); $token = $this->token; } $response = $this->client->b2DownloadFileByName($this->downloadURL, $bucketName, $fileName, $token, $metadataOnly); if ($response->isOk(false)) { return array('headers' => $response->getHeaders(), 'content' => $response->getRawContent()); } return false; }
php
public function get($bucketName, $fileName, $private = false, $metadataOnly = false) { $token = null; if ($private == true) { $this->ensureAuthorized(); $token = $this->token; } $response = $this->client->b2DownloadFileByName($this->downloadURL, $bucketName, $fileName, $token, $metadataOnly); if ($response->isOk(false)) { return array('headers' => $response->getHeaders(), 'content' => $response->getRawContent()); } return false; }
[ "public", "function", "get", "(", "$", "bucketName", ",", "$", "fileName", ",", "$", "private", "=", "false", ",", "$", "metadataOnly", "=", "false", ")", "{", "$", "token", "=", "null", ";", "if", "(", "$", "private", "==", "true", ")", "{", "$", "this", "->", "ensureAuthorized", "(", ")", ";", "$", "token", "=", "$", "this", "->", "token", ";", "}", "$", "response", "=", "$", "this", "->", "client", "->", "b2DownloadFileByName", "(", "$", "this", "->", "downloadURL", ",", "$", "bucketName", ",", "$", "fileName", ",", "$", "token", ",", "$", "metadataOnly", ")", ";", "if", "(", "$", "response", "->", "isOk", "(", "false", ")", ")", "{", "return", "array", "(", "'headers'", "=>", "$", "response", "->", "getHeaders", "(", ")", ",", "'content'", "=>", "$", "response", "->", "getRawContent", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Returns the file content and file metadata. @param String $bucketName @param String $fileName @param bool $private @param bool $metadataOnly @return array|bool
[ "Returns", "the", "file", "content", "and", "file", "metadata", "." ]
64d25e60849f7bcb957a070af3231694da118f55
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Service.php#L116-L129
231,685
kamilZ/B2Backblaze
src/B2Backblaze/B2Service.php
B2Service.insert
public function insert($bucketId, $file, $fileName) { $this->ensureAuthorized(); if(!$this->downloadToken || !$this->uploadURL){ $response = $this->client->b2GetUploadURL($this->apiURL, $this->token, $bucketId); if ($response->isOk()) { $this->downloadToken = $response->get('authorizationToken'); $this->uploadURL = $response->get('uploadUrl'); }else{ return false; } } $response2 = $this->client->b2UploadFile($file, $this->uploadURL, $this->downloadToken, $fileName); if ($response2->isOk()) { return $response2->getData(); }else{ // b2_get_upload_url returns an upload authorization token. This token lasts at most 24 hours. // However, it is only valid to upload data to one storage pod. If that pod is offline, full or overloaded, // a request to b2_upload_file again. $response = $this->client->b2GetUploadURL($this->apiURL, $this->token, $bucketId); if ($response->isOk()) { $this->downloadToken = $response->get('authorizationToken'); $this->uploadURL = $response->get('uploadUrl'); $this->client->b2UploadFile($file, $this->uploadURL, $this->downloadToken, $fileName); if ($response2->isOk()) { return $response2->getData(); } } } return false; }
php
public function insert($bucketId, $file, $fileName) { $this->ensureAuthorized(); if(!$this->downloadToken || !$this->uploadURL){ $response = $this->client->b2GetUploadURL($this->apiURL, $this->token, $bucketId); if ($response->isOk()) { $this->downloadToken = $response->get('authorizationToken'); $this->uploadURL = $response->get('uploadUrl'); }else{ return false; } } $response2 = $this->client->b2UploadFile($file, $this->uploadURL, $this->downloadToken, $fileName); if ($response2->isOk()) { return $response2->getData(); }else{ // b2_get_upload_url returns an upload authorization token. This token lasts at most 24 hours. // However, it is only valid to upload data to one storage pod. If that pod is offline, full or overloaded, // a request to b2_upload_file again. $response = $this->client->b2GetUploadURL($this->apiURL, $this->token, $bucketId); if ($response->isOk()) { $this->downloadToken = $response->get('authorizationToken'); $this->uploadURL = $response->get('uploadUrl'); $this->client->b2UploadFile($file, $this->uploadURL, $this->downloadToken, $fileName); if ($response2->isOk()) { return $response2->getData(); } } } return false; }
[ "public", "function", "insert", "(", "$", "bucketId", ",", "$", "file", ",", "$", "fileName", ")", "{", "$", "this", "->", "ensureAuthorized", "(", ")", ";", "if", "(", "!", "$", "this", "->", "downloadToken", "||", "!", "$", "this", "->", "uploadURL", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "b2GetUploadURL", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ",", "$", "bucketId", ")", ";", "if", "(", "$", "response", "->", "isOk", "(", ")", ")", "{", "$", "this", "->", "downloadToken", "=", "$", "response", "->", "get", "(", "'authorizationToken'", ")", ";", "$", "this", "->", "uploadURL", "=", "$", "response", "->", "get", "(", "'uploadUrl'", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}", "$", "response2", "=", "$", "this", "->", "client", "->", "b2UploadFile", "(", "$", "file", ",", "$", "this", "->", "uploadURL", ",", "$", "this", "->", "downloadToken", ",", "$", "fileName", ")", ";", "if", "(", "$", "response2", "->", "isOk", "(", ")", ")", "{", "return", "$", "response2", "->", "getData", "(", ")", ";", "}", "else", "{", "// b2_get_upload_url returns an upload authorization token. This token lasts at most 24 hours.", "// However, it is only valid to upload data to one storage pod. If that pod is offline, full or overloaded,", "// a request to b2_upload_file again.", "$", "response", "=", "$", "this", "->", "client", "->", "b2GetUploadURL", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ",", "$", "bucketId", ")", ";", "if", "(", "$", "response", "->", "isOk", "(", ")", ")", "{", "$", "this", "->", "downloadToken", "=", "$", "response", "->", "get", "(", "'authorizationToken'", ")", ";", "$", "this", "->", "uploadURL", "=", "$", "response", "->", "get", "(", "'uploadUrl'", ")", ";", "$", "this", "->", "client", "->", "b2UploadFile", "(", "$", "file", ",", "$", "this", "->", "uploadURL", ",", "$", "this", "->", "downloadToken", ",", "$", "fileName", ")", ";", "if", "(", "$", "response2", "->", "isOk", "(", ")", ")", "{", "return", "$", "response2", "->", "getData", "(", ")", ";", "}", "}", "}", "return", "false", ";", "}" ]
Inserts file and returns array of file metadata. @param String $bucketId @param mixed $file @param String $fileName @return array|bool|null @throws B2Exception
[ "Inserts", "file", "and", "returns", "array", "of", "file", "metadata", "." ]
64d25e60849f7bcb957a070af3231694da118f55
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Service.php#L172-L203
231,686
kamilZ/B2Backblaze
src/B2Backblaze/B2Service.php
B2Service.insertLarge
public function insertLarge($bucketId, $filePath, $fileName) { $this->ensureAuthorized(); // start large file: $startResponse = $this->client->b2StartLargeFile($this->apiURL, $this->token, $bucketId, $fileName); $fileId = $startResponse->get("fileId"); try{ // get upload url for part file: $uploadUrlResponse = $this->client->b2GetUploadPartURL($this->apiURL, $this->token, $fileId); // upload large file: $responses = $this->client->b2UploadPart($uploadUrlResponse->get("uploadUrl"), $uploadUrlResponse->get("authorizationToken"), $filePath); $sha1s = []; foreach($responses as $response){ $sha1s[] = $response->get("contentSha1"); } // finish large file $response = $this->client->b2FinishLargeFile($this->apiURL, $this->token, $fileId, $sha1s); if($response->isOk()){ return $response->getData(); } }catch (B2Exception $exception){ $this->client->b2CancelLargeFile($this->apiURL, $this->token, $fileId); } return false; }
php
public function insertLarge($bucketId, $filePath, $fileName) { $this->ensureAuthorized(); // start large file: $startResponse = $this->client->b2StartLargeFile($this->apiURL, $this->token, $bucketId, $fileName); $fileId = $startResponse->get("fileId"); try{ // get upload url for part file: $uploadUrlResponse = $this->client->b2GetUploadPartURL($this->apiURL, $this->token, $fileId); // upload large file: $responses = $this->client->b2UploadPart($uploadUrlResponse->get("uploadUrl"), $uploadUrlResponse->get("authorizationToken"), $filePath); $sha1s = []; foreach($responses as $response){ $sha1s[] = $response->get("contentSha1"); } // finish large file $response = $this->client->b2FinishLargeFile($this->apiURL, $this->token, $fileId, $sha1s); if($response->isOk()){ return $response->getData(); } }catch (B2Exception $exception){ $this->client->b2CancelLargeFile($this->apiURL, $this->token, $fileId); } return false; }
[ "public", "function", "insertLarge", "(", "$", "bucketId", ",", "$", "filePath", ",", "$", "fileName", ")", "{", "$", "this", "->", "ensureAuthorized", "(", ")", ";", "// start large file:", "$", "startResponse", "=", "$", "this", "->", "client", "->", "b2StartLargeFile", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ",", "$", "bucketId", ",", "$", "fileName", ")", ";", "$", "fileId", "=", "$", "startResponse", "->", "get", "(", "\"fileId\"", ")", ";", "try", "{", "// get upload url for part file:", "$", "uploadUrlResponse", "=", "$", "this", "->", "client", "->", "b2GetUploadPartURL", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ",", "$", "fileId", ")", ";", "// upload large file:", "$", "responses", "=", "$", "this", "->", "client", "->", "b2UploadPart", "(", "$", "uploadUrlResponse", "->", "get", "(", "\"uploadUrl\"", ")", ",", "$", "uploadUrlResponse", "->", "get", "(", "\"authorizationToken\"", ")", ",", "$", "filePath", ")", ";", "$", "sha1s", "=", "[", "]", ";", "foreach", "(", "$", "responses", "as", "$", "response", ")", "{", "$", "sha1s", "[", "]", "=", "$", "response", "->", "get", "(", "\"contentSha1\"", ")", ";", "}", "// finish large file", "$", "response", "=", "$", "this", "->", "client", "->", "b2FinishLargeFile", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ",", "$", "fileId", ",", "$", "sha1s", ")", ";", "if", "(", "$", "response", "->", "isOk", "(", ")", ")", "{", "return", "$", "response", "->", "getData", "(", ")", ";", "}", "}", "catch", "(", "B2Exception", "$", "exception", ")", "{", "$", "this", "->", "client", "->", "b2CancelLargeFile", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ",", "$", "fileId", ")", ";", "}", "return", "false", ";", "}" ]
Inserts large file and returns array of file metadata. Large files can range in size from 5MB to 10TB. Each large file must consist of at least 2 parts, and all of the parts except the last one must be at least 5MB in size. The last part must contain at least one byte. @param String $bucketId @param mixed $filePath @param String $fileName @return array|bool|null @throws B2Exception
[ "Inserts", "large", "file", "and", "returns", "array", "of", "file", "metadata", ".", "Large", "files", "can", "range", "in", "size", "from", "5MB", "to", "10TB", ".", "Each", "large", "file", "must", "consist", "of", "at", "least", "2", "parts", "and", "all", "of", "the", "parts", "except", "the", "last", "one", "must", "be", "at", "least", "5MB", "in", "size", ".", "The", "last", "part", "must", "contain", "at", "least", "one", "byte", "." ]
64d25e60849f7bcb957a070af3231694da118f55
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Service.php#L219-L243
231,687
kamilZ/B2Backblaze
src/B2Backblaze/B2Service.php
B2Service.delete
public function delete($bucketName, $fileName, $private = false) { $data = $this->get($bucketName, $fileName, $private, true); if ($data !== false && array_key_exists('x-bz-file-id', $data['headers'])) { $response = $this->client->b2DeleteFileVersion($this->apiURL, $this->token, $data['headers']['x-bz-file-id'], $fileName); return $response->isOk(); } return false; }
php
public function delete($bucketName, $fileName, $private = false) { $data = $this->get($bucketName, $fileName, $private, true); if ($data !== false && array_key_exists('x-bz-file-id', $data['headers'])) { $response = $this->client->b2DeleteFileVersion($this->apiURL, $this->token, $data['headers']['x-bz-file-id'], $fileName); return $response->isOk(); } return false; }
[ "public", "function", "delete", "(", "$", "bucketName", ",", "$", "fileName", ",", "$", "private", "=", "false", ")", "{", "$", "data", "=", "$", "this", "->", "get", "(", "$", "bucketName", ",", "$", "fileName", ",", "$", "private", ",", "true", ")", ";", "if", "(", "$", "data", "!==", "false", "&&", "array_key_exists", "(", "'x-bz-file-id'", ",", "$", "data", "[", "'headers'", "]", ")", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "b2DeleteFileVersion", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ",", "$", "data", "[", "'headers'", "]", "[", "'x-bz-file-id'", "]", ",", "$", "fileName", ")", ";", "return", "$", "response", "->", "isOk", "(", ")", ";", "}", "return", "false", ";", "}" ]
Delete file version. @param String $bucketName @param String $fileName @param bool $private @return bool
[ "Delete", "file", "version", "." ]
64d25e60849f7bcb957a070af3231694da118f55
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Service.php#L254-L264
231,688
kamilZ/B2Backblaze
src/B2Backblaze/B2Service.php
B2Service.all
public function all($bucketId) { $this->ensureAuthorized(); $list = array(); $nexFile = null; do { $response = $this->client->b2ListFileNames($this->apiURL, $this->token, $bucketId, $nexFile, 1000); if ($response->isOk()) { $files = $response->get('files'); $nexFile = $response->get('nextFileName'); if (!is_null($files)) { array_merge($list, $files); } if (is_null($nexFile)) { return $list; } } } while (true); return $list; }
php
public function all($bucketId) { $this->ensureAuthorized(); $list = array(); $nexFile = null; do { $response = $this->client->b2ListFileNames($this->apiURL, $this->token, $bucketId, $nexFile, 1000); if ($response->isOk()) { $files = $response->get('files'); $nexFile = $response->get('nextFileName'); if (!is_null($files)) { array_merge($list, $files); } if (is_null($nexFile)) { return $list; } } } while (true); return $list; }
[ "public", "function", "all", "(", "$", "bucketId", ")", "{", "$", "this", "->", "ensureAuthorized", "(", ")", ";", "$", "list", "=", "array", "(", ")", ";", "$", "nexFile", "=", "null", ";", "do", "{", "$", "response", "=", "$", "this", "->", "client", "->", "b2ListFileNames", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ",", "$", "bucketId", ",", "$", "nexFile", ",", "1000", ")", ";", "if", "(", "$", "response", "->", "isOk", "(", ")", ")", "{", "$", "files", "=", "$", "response", "->", "get", "(", "'files'", ")", ";", "$", "nexFile", "=", "$", "response", "->", "get", "(", "'nextFileName'", ")", ";", "if", "(", "!", "is_null", "(", "$", "files", ")", ")", "{", "array_merge", "(", "$", "list", ",", "$", "files", ")", ";", "}", "if", "(", "is_null", "(", "$", "nexFile", ")", ")", "{", "return", "$", "list", ";", "}", "}", "}", "while", "(", "true", ")", ";", "return", "$", "list", ";", "}" ]
Returns the list of files in bucket. @param String $bucketId @return array @throws B2Exception
[ "Returns", "the", "list", "of", "files", "in", "bucket", "." ]
64d25e60849f7bcb957a070af3231694da118f55
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Service.php#L303-L323
231,689
kamilZ/B2Backblaze
src/B2Backblaze/B2Service.php
B2Service.existsInList
public function existsInList($bucketId, $fileName) { $this->ensureAuthorized(); $response = $this->client->b2ListFileNames($this->apiURL, $this->token, $bucketId, $fileName, 1); if (!$response->isOk(false)) { return false; } return $response->get('files')[0]['fileName'] === $fileName; }
php
public function existsInList($bucketId, $fileName) { $this->ensureAuthorized(); $response = $this->client->b2ListFileNames($this->apiURL, $this->token, $bucketId, $fileName, 1); if (!$response->isOk(false)) { return false; } return $response->get('files')[0]['fileName'] === $fileName; }
[ "public", "function", "existsInList", "(", "$", "bucketId", ",", "$", "fileName", ")", "{", "$", "this", "->", "ensureAuthorized", "(", ")", ";", "$", "response", "=", "$", "this", "->", "client", "->", "b2ListFileNames", "(", "$", "this", "->", "apiURL", ",", "$", "this", "->", "token", ",", "$", "bucketId", ",", "$", "fileName", ",", "1", ")", ";", "if", "(", "!", "$", "response", "->", "isOk", "(", "false", ")", ")", "{", "return", "false", ";", "}", "return", "$", "response", "->", "get", "(", "'files'", ")", "[", "0", "]", "[", "'fileName'", "]", "===", "$", "fileName", ";", "}" ]
Check if the filename exists. @param String $bucketId @param String $fileName @return bool
[ "Check", "if", "the", "filename", "exists", "." ]
64d25e60849f7bcb957a070af3231694da118f55
https://github.com/kamilZ/B2Backblaze/blob/64d25e60849f7bcb957a070af3231694da118f55/src/B2Backblaze/B2Service.php#L334-L343
231,690
praxisnetau/silverware
src/Grid/Frameworks/Bootstrap/Framework.php
Framework.getTextAlignmentClass
public function getTextAlignmentClass($viewport, $value) { if ($value) { $class = [$this->getStyle('text')]; $class[] = $this->getStyle('viewport', $viewport); $class[] = $this->getStyle('align', $value); return implode('-', array_filter($class)); } }
php
public function getTextAlignmentClass($viewport, $value) { if ($value) { $class = [$this->getStyle('text')]; $class[] = $this->getStyle('viewport', $viewport); $class[] = $this->getStyle('align', $value); return implode('-', array_filter($class)); } }
[ "public", "function", "getTextAlignmentClass", "(", "$", "viewport", ",", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "class", "=", "[", "$", "this", "->", "getStyle", "(", "'text'", ")", "]", ";", "$", "class", "[", "]", "=", "$", "this", "->", "getStyle", "(", "'viewport'", ",", "$", "viewport", ")", ";", "$", "class", "[", "]", "=", "$", "this", "->", "getStyle", "(", "'align'", ",", "$", "value", ")", ";", "return", "implode", "(", "'-'", ",", "array_filter", "(", "$", "class", ")", ")", ";", "}", "}" ]
Answers the text alignment class for the specified viewport and value. @param string $viewport @param string $value @return string
[ "Answers", "the", "text", "alignment", "class", "for", "the", "specified", "viewport", "and", "value", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/Frameworks/Bootstrap/Framework.php#L64-L77
231,691
praxisnetau/silverware
src/Grid/Frameworks/Bootstrap/Framework.php
Framework.getImageAlignmentClass
public function getImageAlignmentClass($viewport, $value) { if ($value) { $class = [$this->getStyle('image')]; $class[] = $this->getStyle('viewport', $viewport); $class[] = $this->getStyle('align', $value); return implode('-', array_filter($class)); } }
php
public function getImageAlignmentClass($viewport, $value) { if ($value) { $class = [$this->getStyle('image')]; $class[] = $this->getStyle('viewport', $viewport); $class[] = $this->getStyle('align', $value); return implode('-', array_filter($class)); } }
[ "public", "function", "getImageAlignmentClass", "(", "$", "viewport", ",", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "class", "=", "[", "$", "this", "->", "getStyle", "(", "'image'", ")", "]", ";", "$", "class", "[", "]", "=", "$", "this", "->", "getStyle", "(", "'viewport'", ",", "$", "viewport", ")", ";", "$", "class", "[", "]", "=", "$", "this", "->", "getStyle", "(", "'align'", ",", "$", "value", ")", ";", "return", "implode", "(", "'-'", ",", "array_filter", "(", "$", "class", ")", ")", ";", "}", "}" ]
Answers the image alignment class for the specified viewport and value. @param string $viewport @param string $value @return string
[ "Answers", "the", "image", "alignment", "class", "for", "the", "specified", "viewport", "and", "value", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/Frameworks/Bootstrap/Framework.php#L87-L100
231,692
praxisnetau/silverware
src/Components/TableComponent.php
TableComponent.getColumns
public function getColumns() { $columns = ArrayList::create(); foreach ($this->getEnabledChildren() as $child) { $columns->push( ArrayData::create([ 'Child' => $child, 'ColumnClass' => $this->ColumnClass ]) ); } return $columns; }
php
public function getColumns() { $columns = ArrayList::create(); foreach ($this->getEnabledChildren() as $child) { $columns->push( ArrayData::create([ 'Child' => $child, 'ColumnClass' => $this->ColumnClass ]) ); } return $columns; }
[ "public", "function", "getColumns", "(", ")", "{", "$", "columns", "=", "ArrayList", "::", "create", "(", ")", ";", "foreach", "(", "$", "this", "->", "getEnabledChildren", "(", ")", "as", "$", "child", ")", "{", "$", "columns", "->", "push", "(", "ArrayData", "::", "create", "(", "[", "'Child'", "=>", "$", "child", ",", "'ColumnClass'", "=>", "$", "this", "->", "ColumnClass", "]", ")", ")", ";", "}", "return", "$", "columns", ";", "}" ]
Answers a list of the columns within the receiver. @return ArrayList
[ "Answers", "a", "list", "of", "the", "columns", "within", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/TableComponent.php#L191-L207
231,693
praxisnetau/silverware
src/Components/TableComponent.php
TableComponent.getColumnClassNames
public function getColumnClassNames() { $classes = array_merge( $this->styles('column'), Column::singleton()->getSpanClassNames($this->dbObject('ColumnSpan')) ); $this->extend('updateColumnClassNames', $classes); return $classes; }
php
public function getColumnClassNames() { $classes = array_merge( $this->styles('column'), Column::singleton()->getSpanClassNames($this->dbObject('ColumnSpan')) ); $this->extend('updateColumnClassNames', $classes); return $classes; }
[ "public", "function", "getColumnClassNames", "(", ")", "{", "$", "classes", "=", "array_merge", "(", "$", "this", "->", "styles", "(", "'column'", ")", ",", "Column", "::", "singleton", "(", ")", "->", "getSpanClassNames", "(", "$", "this", "->", "dbObject", "(", "'ColumnSpan'", ")", ")", ")", ";", "$", "this", "->", "extend", "(", "'updateColumnClassNames'", ",", "$", "classes", ")", ";", "return", "$", "classes", ";", "}" ]
Answers an array of column class names for the template. @return array
[ "Answers", "an", "array", "of", "column", "class", "names", "for", "the", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/TableComponent.php#L214-L224
231,694
praxisnetau/silverware
src/Dev/FixtureBlueprint.php
FixtureBlueprint.createObject
public function createObject($identifier, $data = null, $fixtures = null, $filter = []) { // Trigger Before Create Event: $this->onBeforeCreate($identifier, $data, $fixtures); // Attempt Object Creation: try { // Obtain Object: $object = $this->findOrMakeObject($identifier, $data, $fixtures, $filter); // Populate Object: $this->populateObject($object, $data, $fixtures); // Write Object to Database: $this->writeObject($object); } catch (Exception $e) { // Enable Validation (on failure): $this->enableValidation(); // Throw Exception Again: throw $e; } // Trigger After Create Event: $this->onAfterCreate($object, $identifier, $data, $fixtures); // Answer Object: return $object; }
php
public function createObject($identifier, $data = null, $fixtures = null, $filter = []) { // Trigger Before Create Event: $this->onBeforeCreate($identifier, $data, $fixtures); // Attempt Object Creation: try { // Obtain Object: $object = $this->findOrMakeObject($identifier, $data, $fixtures, $filter); // Populate Object: $this->populateObject($object, $data, $fixtures); // Write Object to Database: $this->writeObject($object); } catch (Exception $e) { // Enable Validation (on failure): $this->enableValidation(); // Throw Exception Again: throw $e; } // Trigger After Create Event: $this->onAfterCreate($object, $identifier, $data, $fixtures); // Answer Object: return $object; }
[ "public", "function", "createObject", "(", "$", "identifier", ",", "$", "data", "=", "null", ",", "$", "fixtures", "=", "null", ",", "$", "filter", "=", "[", "]", ")", "{", "// Trigger Before Create Event:", "$", "this", "->", "onBeforeCreate", "(", "$", "identifier", ",", "$", "data", ",", "$", "fixtures", ")", ";", "// Attempt Object Creation:", "try", "{", "// Obtain Object:", "$", "object", "=", "$", "this", "->", "findOrMakeObject", "(", "$", "identifier", ",", "$", "data", ",", "$", "fixtures", ",", "$", "filter", ")", ";", "// Populate Object:", "$", "this", "->", "populateObject", "(", "$", "object", ",", "$", "data", ",", "$", "fixtures", ")", ";", "// Write Object to Database:", "$", "this", "->", "writeObject", "(", "$", "object", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "// Enable Validation (on failure):", "$", "this", "->", "enableValidation", "(", ")", ";", "// Throw Exception Again:", "throw", "$", "e", ";", "}", "// Trigger After Create Event:", "$", "this", "->", "onAfterCreate", "(", "$", "object", ",", "$", "identifier", ",", "$", "data", ",", "$", "fixtures", ")", ";", "// Answer Object:", "return", "$", "object", ";", "}" ]
Creates a data object using the provided data. @param string $identifier Unique identifier for this fixture type. @param array $data Map of property names with associated values. @param array $fixtures Map of fixture names to an array of identifiers and IDs. @param array $filter Map of property names and associated values to filter by. @return DataObject
[ "Creates", "a", "data", "object", "using", "the", "provided", "data", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Dev/FixtureBlueprint.php#L120-L161
231,695
praxisnetau/silverware
src/Dev/FixtureBlueprint.php
FixtureBlueprint.findOrMakeObject
public function findOrMakeObject($identifier, $data = null, $fixtures = null, $filter = []) { // Handle Default Parent: if (($ID = $this->getDefaultParent()) && !isset($data['ParentID'])) { $data['ParentID'] = $filter['ParentID'] = $ID; } // Obtain Existing Object: $object = $this->findObject($identifier, $data, $filter); // Create Object (if does not exist): if (!$object) { // Create Object Instance: $object = $this->makeObject(); // Populate Identifier: $this->populateIdentifier($object, $identifier); // Populate Defaults: $this->populateDefaults($object, $identifier, $data, $fixtures); // Populate Parent: $this->populateParent($object, $data); // Show Create Message: $this->createMessage($object, $identifier); } else { // Show Update Message: $this->updateMessage($object, $identifier); } // Mutate Class (if required): $object = $this->mutateClass($object, $identifier, $data); // Write Object to Database: $object->write(); // Handle Versioning: $this->publishObject($object); // Record Object in Fixtures: $this->addFixture($object, $identifier); // Answer Object: return $object; }
php
public function findOrMakeObject($identifier, $data = null, $fixtures = null, $filter = []) { // Handle Default Parent: if (($ID = $this->getDefaultParent()) && !isset($data['ParentID'])) { $data['ParentID'] = $filter['ParentID'] = $ID; } // Obtain Existing Object: $object = $this->findObject($identifier, $data, $filter); // Create Object (if does not exist): if (!$object) { // Create Object Instance: $object = $this->makeObject(); // Populate Identifier: $this->populateIdentifier($object, $identifier); // Populate Defaults: $this->populateDefaults($object, $identifier, $data, $fixtures); // Populate Parent: $this->populateParent($object, $data); // Show Create Message: $this->createMessage($object, $identifier); } else { // Show Update Message: $this->updateMessage($object, $identifier); } // Mutate Class (if required): $object = $this->mutateClass($object, $identifier, $data); // Write Object to Database: $object->write(); // Handle Versioning: $this->publishObject($object); // Record Object in Fixtures: $this->addFixture($object, $identifier); // Answer Object: return $object; }
[ "public", "function", "findOrMakeObject", "(", "$", "identifier", ",", "$", "data", "=", "null", ",", "$", "fixtures", "=", "null", ",", "$", "filter", "=", "[", "]", ")", "{", "// Handle Default Parent:", "if", "(", "(", "$", "ID", "=", "$", "this", "->", "getDefaultParent", "(", ")", ")", "&&", "!", "isset", "(", "$", "data", "[", "'ParentID'", "]", ")", ")", "{", "$", "data", "[", "'ParentID'", "]", "=", "$", "filter", "[", "'ParentID'", "]", "=", "$", "ID", ";", "}", "// Obtain Existing Object:", "$", "object", "=", "$", "this", "->", "findObject", "(", "$", "identifier", ",", "$", "data", ",", "$", "filter", ")", ";", "// Create Object (if does not exist):", "if", "(", "!", "$", "object", ")", "{", "// Create Object Instance:", "$", "object", "=", "$", "this", "->", "makeObject", "(", ")", ";", "// Populate Identifier:", "$", "this", "->", "populateIdentifier", "(", "$", "object", ",", "$", "identifier", ")", ";", "// Populate Defaults:", "$", "this", "->", "populateDefaults", "(", "$", "object", ",", "$", "identifier", ",", "$", "data", ",", "$", "fixtures", ")", ";", "// Populate Parent:", "$", "this", "->", "populateParent", "(", "$", "object", ",", "$", "data", ")", ";", "// Show Create Message:", "$", "this", "->", "createMessage", "(", "$", "object", ",", "$", "identifier", ")", ";", "}", "else", "{", "// Show Update Message:", "$", "this", "->", "updateMessage", "(", "$", "object", ",", "$", "identifier", ")", ";", "}", "// Mutate Class (if required):", "$", "object", "=", "$", "this", "->", "mutateClass", "(", "$", "object", ",", "$", "identifier", ",", "$", "data", ")", ";", "// Write Object to Database:", "$", "object", "->", "write", "(", ")", ";", "// Handle Versioning:", "$", "this", "->", "publishObject", "(", "$", "object", ")", ";", "// Record Object in Fixtures:", "$", "this", "->", "addFixture", "(", "$", "object", ",", "$", "identifier", ")", ";", "// Answer Object:", "return", "$", "object", ";", "}" ]
Answers either an existing instance or a new instance of the data object. @param string $identifier @param array $data @param array $fixtures @param array $filter @return DataObject
[ "Answers", "either", "an", "existing", "instance", "or", "a", "new", "instance", "of", "the", "data", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Dev/FixtureBlueprint.php#L173-L236
231,696
praxisnetau/silverware
src/Dev/FixtureBlueprint.php
FixtureBlueprint.findObject
public function findObject($identifier, $data, $filter) { if ($objects = $this->findObjects($identifier, $data, $filter)) { if ($objects->exists()) { return $objects->first(); } } }
php
public function findObject($identifier, $data, $filter) { if ($objects = $this->findObjects($identifier, $data, $filter)) { if ($objects->exists()) { return $objects->first(); } } }
[ "public", "function", "findObject", "(", "$", "identifier", ",", "$", "data", ",", "$", "filter", ")", "{", "if", "(", "$", "objects", "=", "$", "this", "->", "findObjects", "(", "$", "identifier", ",", "$", "data", ",", "$", "filter", ")", ")", "{", "if", "(", "$", "objects", "->", "exists", "(", ")", ")", "{", "return", "$", "objects", "->", "first", "(", ")", ";", "}", "}", "}" ]
Answers an existing instance of the data object. @param string $identifier @param array $data @param array $filter @return DataObject
[ "Answers", "an", "existing", "instance", "of", "the", "data", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Dev/FixtureBlueprint.php#L247-L256
231,697
praxisnetau/silverware
src/Dev/FixtureBlueprint.php
FixtureBlueprint.findObjects
public function findObjects($identifier, $data, $filter) { $objects = DataList::create($this->getClass()); if (!$objects->exists() && $this->config()->filter_by_base_class) { $objects = DataList::create($this->getBaseClass()); } if (is_array($filter)) { $objects = $objects->filter($filter); } if (isset($data[$this->getMatchOnName()])) { return $this->matchObjects($objects, $data); } if ($field = $this->getDefaultIdentifier()) { return $objects->filter($field, $identifier); } $title = $this->getIdentifierOrTitle($identifier, $data); return $objects->filterByCallback(function ($item, $list) use ($title) { return ($item->Title == $title); }); }
php
public function findObjects($identifier, $data, $filter) { $objects = DataList::create($this->getClass()); if (!$objects->exists() && $this->config()->filter_by_base_class) { $objects = DataList::create($this->getBaseClass()); } if (is_array($filter)) { $objects = $objects->filter($filter); } if (isset($data[$this->getMatchOnName()])) { return $this->matchObjects($objects, $data); } if ($field = $this->getDefaultIdentifier()) { return $objects->filter($field, $identifier); } $title = $this->getIdentifierOrTitle($identifier, $data); return $objects->filterByCallback(function ($item, $list) use ($title) { return ($item->Title == $title); }); }
[ "public", "function", "findObjects", "(", "$", "identifier", ",", "$", "data", ",", "$", "filter", ")", "{", "$", "objects", "=", "DataList", "::", "create", "(", "$", "this", "->", "getClass", "(", ")", ")", ";", "if", "(", "!", "$", "objects", "->", "exists", "(", ")", "&&", "$", "this", "->", "config", "(", ")", "->", "filter_by_base_class", ")", "{", "$", "objects", "=", "DataList", "::", "create", "(", "$", "this", "->", "getBaseClass", "(", ")", ")", ";", "}", "if", "(", "is_array", "(", "$", "filter", ")", ")", "{", "$", "objects", "=", "$", "objects", "->", "filter", "(", "$", "filter", ")", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "$", "this", "->", "getMatchOnName", "(", ")", "]", ")", ")", "{", "return", "$", "this", "->", "matchObjects", "(", "$", "objects", ",", "$", "data", ")", ";", "}", "if", "(", "$", "field", "=", "$", "this", "->", "getDefaultIdentifier", "(", ")", ")", "{", "return", "$", "objects", "->", "filter", "(", "$", "field", ",", "$", "identifier", ")", ";", "}", "$", "title", "=", "$", "this", "->", "getIdentifierOrTitle", "(", "$", "identifier", ",", "$", "data", ")", ";", "return", "$", "objects", "->", "filterByCallback", "(", "function", "(", "$", "item", ",", "$", "list", ")", "use", "(", "$", "title", ")", "{", "return", "(", "$", "item", "->", "Title", "==", "$", "title", ")", ";", "}", ")", ";", "}" ]
Answers a list of the existing objects in the database. @param string $identifier @param array $data @param array $filter @return DataList
[ "Answers", "a", "list", "of", "the", "existing", "objects", "in", "the", "database", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Dev/FixtureBlueprint.php#L267-L292
231,698
praxisnetau/silverware
src/Dev/FixtureBlueprint.php
FixtureBlueprint.matchObjects
public function matchObjects(DataList $objects, $data) { // Detect Filter: $name = $this->getMatchOnName(); if (isset($data[$name])) { $filter = []; $matchOn = $data[$name]; if (is_array($matchOn)) { // Handle Array Filter: if (ArrayLib::is_associative($matchOn)) { $filter = $matchOn; } else { foreach ($matchOn as $field) { if (isset($data[$field])) { $filter[$field] = $data[$field]; } } } } elseif (isset($data[$matchOn])) { // Handle String Filter: $filter[$matchOn] = $data[$matchOn]; } foreach ($filter as $k => $v) { $filter[$k] = $this->processValue($v); } return $objects->filter($filter); } return $objects; }
php
public function matchObjects(DataList $objects, $data) { // Detect Filter: $name = $this->getMatchOnName(); if (isset($data[$name])) { $filter = []; $matchOn = $data[$name]; if (is_array($matchOn)) { // Handle Array Filter: if (ArrayLib::is_associative($matchOn)) { $filter = $matchOn; } else { foreach ($matchOn as $field) { if (isset($data[$field])) { $filter[$field] = $data[$field]; } } } } elseif (isset($data[$matchOn])) { // Handle String Filter: $filter[$matchOn] = $data[$matchOn]; } foreach ($filter as $k => $v) { $filter[$k] = $this->processValue($v); } return $objects->filter($filter); } return $objects; }
[ "public", "function", "matchObjects", "(", "DataList", "$", "objects", ",", "$", "data", ")", "{", "// Detect Filter:", "$", "name", "=", "$", "this", "->", "getMatchOnName", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "$", "name", "]", ")", ")", "{", "$", "filter", "=", "[", "]", ";", "$", "matchOn", "=", "$", "data", "[", "$", "name", "]", ";", "if", "(", "is_array", "(", "$", "matchOn", ")", ")", "{", "// Handle Array Filter:", "if", "(", "ArrayLib", "::", "is_associative", "(", "$", "matchOn", ")", ")", "{", "$", "filter", "=", "$", "matchOn", ";", "}", "else", "{", "foreach", "(", "$", "matchOn", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "field", "]", ")", ")", "{", "$", "filter", "[", "$", "field", "]", "=", "$", "data", "[", "$", "field", "]", ";", "}", "}", "}", "}", "elseif", "(", "isset", "(", "$", "data", "[", "$", "matchOn", "]", ")", ")", "{", "// Handle String Filter:", "$", "filter", "[", "$", "matchOn", "]", "=", "$", "data", "[", "$", "matchOn", "]", ";", "}", "foreach", "(", "$", "filter", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "filter", "[", "$", "k", "]", "=", "$", "this", "->", "processValue", "(", "$", "v", ")", ";", "}", "return", "$", "objects", "->", "filter", "(", "$", "filter", ")", ";", "}", "return", "$", "objects", ";", "}" ]
Answers those objects within the given data list matching the provided filter. @param DataList $objects @param array $data @return DataList
[ "Answers", "those", "objects", "within", "the", "given", "data", "list", "matching", "the", "provided", "filter", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Dev/FixtureBlueprint.php#L302-L350
231,699
praxisnetau/silverware
src/Dev/FixtureBlueprint.php
FixtureBlueprint.mutateClass
public function mutateClass(DataObject $object, $identifier, $data) { $class = $this->getClass(); if ($object->ClassName != $class) { // Show Notice Message: $this->noticeMessage( sprintf( 'Mutating %s (%s to %s)', $identifier, get_class($object), $class ) ); // Mutate Object: $object = $object->newClassInstance($class); // Write Object to Database: $object->write(); $object->flushCache(); } return $object; }
php
public function mutateClass(DataObject $object, $identifier, $data) { $class = $this->getClass(); if ($object->ClassName != $class) { // Show Notice Message: $this->noticeMessage( sprintf( 'Mutating %s (%s to %s)', $identifier, get_class($object), $class ) ); // Mutate Object: $object = $object->newClassInstance($class); // Write Object to Database: $object->write(); $object->flushCache(); } return $object; }
[ "public", "function", "mutateClass", "(", "DataObject", "$", "object", ",", "$", "identifier", ",", "$", "data", ")", "{", "$", "class", "=", "$", "this", "->", "getClass", "(", ")", ";", "if", "(", "$", "object", "->", "ClassName", "!=", "$", "class", ")", "{", "// Show Notice Message:", "$", "this", "->", "noticeMessage", "(", "sprintf", "(", "'Mutating %s (%s to %s)'", ",", "$", "identifier", ",", "get_class", "(", "$", "object", ")", ",", "$", "class", ")", ")", ";", "// Mutate Object:", "$", "object", "=", "$", "object", "->", "newClassInstance", "(", "$", "class", ")", ";", "// Write Object to Database:", "$", "object", "->", "write", "(", ")", ";", "$", "object", "->", "flushCache", "(", ")", ";", "}", "return", "$", "object", ";", "}" ]
Mutates the class of the given object, if required. @param DataObject $object @param string $identifier @param array $data @return DataObject
[ "Mutates", "the", "class", "of", "the", "given", "object", "if", "required", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Dev/FixtureBlueprint.php#L424-L453