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
16,800
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.getCurrentUrl
protected function getCurrentUrl() { $isHttps = $this->getServerVar('HTTPS'); $forwardedProto = $this->getServerVar('HTTP_X_FORWARDED_PROTO'); if ($isHttps == 'on' || $forwardedProto === 'https') { $schema = 'https://'; } else { $schema = 'http://'; } $host = $this->getServerVar('HTTP_HOST'); if (preg_match('#:(\d+)$#', $host, $match)) { $port = ':' . $match[1]; } else { $port = ''; } $urls = parse_url($this->getServerVar('REQUEST_URI')); $path = $urls['path']; $query = ''; return $schema . $host . $port . $path . $query; }
php
protected function getCurrentUrl() { $isHttps = $this->getServerVar('HTTPS'); $forwardedProto = $this->getServerVar('HTTP_X_FORWARDED_PROTO'); if ($isHttps == 'on' || $forwardedProto === 'https') { $schema = 'https://'; } else { $schema = 'http://'; } $host = $this->getServerVar('HTTP_HOST'); if (preg_match('#:(\d+)$#', $host, $match)) { $port = ':' . $match[1]; } else { $port = ''; } $urls = parse_url($this->getServerVar('REQUEST_URI')); $path = $urls['path']; $query = ''; return $schema . $host . $port . $path . $query; }
[ "protected", "function", "getCurrentUrl", "(", ")", "{", "$", "isHttps", "=", "$", "this", "->", "getServerVar", "(", "'HTTPS'", ")", ";", "$", "forwardedProto", "=", "$", "this", "->", "getServerVar", "(", "'HTTP_X_FORWARDED_PROTO'", ")", ";", "if", "(", "$", "isHttps", "==", "'on'", "||", "$", "forwardedProto", "===", "'https'", ")", "{", "$", "schema", "=", "'https://'", ";", "}", "else", "{", "$", "schema", "=", "'http://'", ";", "}", "$", "host", "=", "$", "this", "->", "getServerVar", "(", "'HTTP_HOST'", ")", ";", "if", "(", "preg_match", "(", "'#:(\\d+)$#'", ",", "$", "host", ",", "$", "match", ")", ")", "{", "$", "port", "=", "':'", ".", "$", "match", "[", "1", "]", ";", "}", "else", "{", "$", "port", "=", "''", ";", "}", "$", "urls", "=", "parse_url", "(", "$", "this", "->", "getServerVar", "(", "'REQUEST_URI'", ")", ")", ";", "$", "path", "=", "$", "urls", "[", "'path'", "]", ";", "$", "query", "=", "''", ";", "return", "$", "schema", ".", "$", "host", ".", "$", "port", ".", "$", "path", ".", "$", "query", ";", "}" ]
Get Current Url @return string
[ "Get", "Current", "Url" ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L367-L389
16,801
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
MinecraftJP.validateIdToken
protected function validateIdToken($idToken) { $segments = explode('.', $idToken); if (count($segments) != 3) { throw new InvalidIdTokenException('Invalid Token'); } $header = json_decode($this->decodeBase64Url($segments[0]), true); if (empty($header)) { throw new InvalidIdTokenException('Invalid Token'); } $payload = json_decode($this->decodeBase64Url($segments[1]), true); if (empty($payload)) { throw new InvalidIdTokenException('Invalid Token'); } $signature = $this->decodeBase64Url($segments[2]); $signingInput = implode('.', array($segments[0], $segments[1])); $kid = isset($header['kid']) ? $header['kid'] : null; switch ($header['alg']) { case 'RS256': case 'RS384': case 'RS512': // η½²εζ€œθ¨Όη”¨γ«ε…¬ι–‹ι΅γ‚’ε–εΎ—γ™γ‚‹ $publicKey = $this->getPublicKey($kid); $algo = 'sha' . substr($header['alg'], 2); if (openssl_verify($signingInput, $signature, $publicKey, $algo) != 1) { openssl_free_key($publicKey); throw new InvalidIdTokenException('Signature Mismatch'); } openssl_free_key($publicKey); break; default: throw new InvalidIdTokenException('Unsupported Algorithm: ' . $header['alg']); } // Check Issuer if ($payload['iss'] != 'minecraft.jp') { throw new InvalidIdTokenException('Invalid Issuer.'); } // Check Client Id if ($payload['aud'] != $this->getClientId()) { throw new InvalidIdTokenException('Client ID Mismatch.'); } // Check expired $now = time(); if ($payload['exp'] < $now || $payload['iat'] < $now - 600) { throw new InvalidIdTokenException('ID Token expired.'); } // Check nonce if ($payload['nonce'] != $this->sessionStorage->read('nonce')) { throw new InvalidIdTokenException('Nonce Mismatch.'); } $this->sessionStorage->remove('nonce'); return $payload; }
php
protected function validateIdToken($idToken) { $segments = explode('.', $idToken); if (count($segments) != 3) { throw new InvalidIdTokenException('Invalid Token'); } $header = json_decode($this->decodeBase64Url($segments[0]), true); if (empty($header)) { throw new InvalidIdTokenException('Invalid Token'); } $payload = json_decode($this->decodeBase64Url($segments[1]), true); if (empty($payload)) { throw new InvalidIdTokenException('Invalid Token'); } $signature = $this->decodeBase64Url($segments[2]); $signingInput = implode('.', array($segments[0], $segments[1])); $kid = isset($header['kid']) ? $header['kid'] : null; switch ($header['alg']) { case 'RS256': case 'RS384': case 'RS512': // η½²εζ€œθ¨Όη”¨γ«ε…¬ι–‹ι΅γ‚’ε–εΎ—γ™γ‚‹ $publicKey = $this->getPublicKey($kid); $algo = 'sha' . substr($header['alg'], 2); if (openssl_verify($signingInput, $signature, $publicKey, $algo) != 1) { openssl_free_key($publicKey); throw new InvalidIdTokenException('Signature Mismatch'); } openssl_free_key($publicKey); break; default: throw new InvalidIdTokenException('Unsupported Algorithm: ' . $header['alg']); } // Check Issuer if ($payload['iss'] != 'minecraft.jp') { throw new InvalidIdTokenException('Invalid Issuer.'); } // Check Client Id if ($payload['aud'] != $this->getClientId()) { throw new InvalidIdTokenException('Client ID Mismatch.'); } // Check expired $now = time(); if ($payload['exp'] < $now || $payload['iat'] < $now - 600) { throw new InvalidIdTokenException('ID Token expired.'); } // Check nonce if ($payload['nonce'] != $this->sessionStorage->read('nonce')) { throw new InvalidIdTokenException('Nonce Mismatch.'); } $this->sessionStorage->remove('nonce'); return $payload; }
[ "protected", "function", "validateIdToken", "(", "$", "idToken", ")", "{", "$", "segments", "=", "explode", "(", "'.'", ",", "$", "idToken", ")", ";", "if", "(", "count", "(", "$", "segments", ")", "!=", "3", ")", "{", "throw", "new", "InvalidIdTokenException", "(", "'Invalid Token'", ")", ";", "}", "$", "header", "=", "json_decode", "(", "$", "this", "->", "decodeBase64Url", "(", "$", "segments", "[", "0", "]", ")", ",", "true", ")", ";", "if", "(", "empty", "(", "$", "header", ")", ")", "{", "throw", "new", "InvalidIdTokenException", "(", "'Invalid Token'", ")", ";", "}", "$", "payload", "=", "json_decode", "(", "$", "this", "->", "decodeBase64Url", "(", "$", "segments", "[", "1", "]", ")", ",", "true", ")", ";", "if", "(", "empty", "(", "$", "payload", ")", ")", "{", "throw", "new", "InvalidIdTokenException", "(", "'Invalid Token'", ")", ";", "}", "$", "signature", "=", "$", "this", "->", "decodeBase64Url", "(", "$", "segments", "[", "2", "]", ")", ";", "$", "signingInput", "=", "implode", "(", "'.'", ",", "array", "(", "$", "segments", "[", "0", "]", ",", "$", "segments", "[", "1", "]", ")", ")", ";", "$", "kid", "=", "isset", "(", "$", "header", "[", "'kid'", "]", ")", "?", "$", "header", "[", "'kid'", "]", ":", "null", ";", "switch", "(", "$", "header", "[", "'alg'", "]", ")", "{", "case", "'RS256'", ":", "case", "'RS384'", ":", "case", "'RS512'", ":", "// η½²εζ€œθ¨Όη”¨γ«ε…¬ι–‹ι΅γ‚’ε–εΎ—γ™γ‚‹", "$", "publicKey", "=", "$", "this", "->", "getPublicKey", "(", "$", "kid", ")", ";", "$", "algo", "=", "'sha'", ".", "substr", "(", "$", "header", "[", "'alg'", "]", ",", "2", ")", ";", "if", "(", "openssl_verify", "(", "$", "signingInput", ",", "$", "signature", ",", "$", "publicKey", ",", "$", "algo", ")", "!=", "1", ")", "{", "openssl_free_key", "(", "$", "publicKey", ")", ";", "throw", "new", "InvalidIdTokenException", "(", "'Signature Mismatch'", ")", ";", "}", "openssl_free_key", "(", "$", "publicKey", ")", ";", "break", ";", "default", ":", "throw", "new", "InvalidIdTokenException", "(", "'Unsupported Algorithm: '", ".", "$", "header", "[", "'alg'", "]", ")", ";", "}", "// Check Issuer", "if", "(", "$", "payload", "[", "'iss'", "]", "!=", "'minecraft.jp'", ")", "{", "throw", "new", "InvalidIdTokenException", "(", "'Invalid Issuer.'", ")", ";", "}", "// Check Client Id", "if", "(", "$", "payload", "[", "'aud'", "]", "!=", "$", "this", "->", "getClientId", "(", ")", ")", "{", "throw", "new", "InvalidIdTokenException", "(", "'Client ID Mismatch.'", ")", ";", "}", "// Check expired", "$", "now", "=", "time", "(", ")", ";", "if", "(", "$", "payload", "[", "'exp'", "]", "<", "$", "now", "||", "$", "payload", "[", "'iat'", "]", "<", "$", "now", "-", "600", ")", "{", "throw", "new", "InvalidIdTokenException", "(", "'ID Token expired.'", ")", ";", "}", "// Check nonce", "if", "(", "$", "payload", "[", "'nonce'", "]", "!=", "$", "this", "->", "sessionStorage", "->", "read", "(", "'nonce'", ")", ")", "{", "throw", "new", "InvalidIdTokenException", "(", "'Nonce Mismatch.'", ")", ";", "}", "$", "this", "->", "sessionStorage", "->", "remove", "(", "'nonce'", ")", ";", "return", "$", "payload", ";", "}" ]
Validate ID Token @param $idToken @return mixed @throws Exception
[ "Validate", "ID", "Token" ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L436-L495
16,802
MinecraftJP/minecraftjp-php-sdk
src/MinecraftJP.php
PHPSessionStorage.read
public function read($key) { return isset($_SESSION[$this->prefix . $key]) ? $_SESSION[$this->prefix . $key] : null; }
php
public function read($key) { return isset($_SESSION[$this->prefix . $key]) ? $_SESSION[$this->prefix . $key] : null; }
[ "public", "function", "read", "(", "$", "key", ")", "{", "return", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "prefix", ".", "$", "key", "]", ")", "?", "$", "_SESSION", "[", "$", "this", "->", "prefix", ".", "$", "key", "]", ":", "null", ";", "}" ]
Read from session @param $key string @return mixed
[ "Read", "from", "session" ]
ecc592c9b6d33eb0c896210f7c9948672db54728
https://github.com/MinecraftJP/minecraftjp-php-sdk/blob/ecc592c9b6d33eb0c896210f7c9948672db54728/src/MinecraftJP.php#L681-L683
16,803
parsnick/steak
src/Build/Builder.php
Builder.build
public function build($sourceDir, $outputDir) { $sourceList = $this->findSources($sourceDir, $outputDir); return array_walk($sourceList, [$this, 'publish']); }
php
public function build($sourceDir, $outputDir) { $sourceList = $this->findSources($sourceDir, $outputDir); return array_walk($sourceList, [$this, 'publish']); }
[ "public", "function", "build", "(", "$", "sourceDir", ",", "$", "outputDir", ")", "{", "$", "sourceList", "=", "$", "this", "->", "findSources", "(", "$", "sourceDir", ",", "$", "outputDir", ")", ";", "return", "array_walk", "(", "$", "sourceList", ",", "[", "$", "this", ",", "'publish'", "]", ")", ";", "}" ]
Build the site. @param string $sourceDir @param string $outputDir @return bool
[ "Build", "the", "site", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Build/Builder.php#L43-L48
16,804
parsnick/steak
src/Build/Builder.php
Builder.findSources
protected function findSources($searchIn, $outputTo) { $files = iterator_to_array(new FilesystemIterator($searchIn)); return array_map(function (SplFileInfo $file) use ($outputTo) { return $this->makeSource($file, $outputTo); }, $files); }
php
protected function findSources($searchIn, $outputTo) { $files = iterator_to_array(new FilesystemIterator($searchIn)); return array_map(function (SplFileInfo $file) use ($outputTo) { return $this->makeSource($file, $outputTo); }, $files); }
[ "protected", "function", "findSources", "(", "$", "searchIn", ",", "$", "outputTo", ")", "{", "$", "files", "=", "iterator_to_array", "(", "new", "FilesystemIterator", "(", "$", "searchIn", ")", ")", ";", "return", "array_map", "(", "function", "(", "SplFileInfo", "$", "file", ")", "use", "(", "$", "outputTo", ")", "{", "return", "$", "this", "->", "makeSource", "(", "$", "file", ",", "$", "outputTo", ")", ";", "}", ",", "$", "files", ")", ";", "}" ]
Create array of Sources from the given input directory. @param string $searchIn @param string $outputTo @return array
[ "Create", "array", "of", "Sources", "from", "the", "given", "input", "directory", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Build/Builder.php#L57-L66
16,805
parsnick/steak
src/Build/Builder.php
Builder.makeSource
public function makeSource(SplFileInfo $file, $outputDir) { return new Source($file->getPathname(), $outputDir . DIRECTORY_SEPARATOR . $file->getFilename()); }
php
public function makeSource(SplFileInfo $file, $outputDir) { return new Source($file->getPathname(), $outputDir . DIRECTORY_SEPARATOR . $file->getFilename()); }
[ "public", "function", "makeSource", "(", "SplFileInfo", "$", "file", ",", "$", "outputDir", ")", "{", "return", "new", "Source", "(", "$", "file", "->", "getPathname", "(", ")", ",", "$", "outputDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", "->", "getFilename", "(", ")", ")", ";", "}" ]
Create a Source from the given file and output dir. @param SplFileInfo $file @param string $outputDir @return Source
[ "Create", "a", "Source", "from", "the", "given", "file", "and", "output", "dir", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Build/Builder.php#L75-L78
16,806
parsnick/steak
src/Build/Builder.php
Builder.clean
public function clean($dir, $preserveGit = false) { $filesystem = new Filesystem(); if ( ! $filesystem->exists($dir)) { return $filesystem->makeDirectory($dir, 0755, true); } foreach (new FilesystemIterator($dir) as $file) { if ($preserveGit && $file->getFilename() == '.git') { continue; } if ($file->isDir() && ! $file->isLink()) { $filesystem->deleteDirectory($file); } else { $filesystem->delete($file); } } return true; }
php
public function clean($dir, $preserveGit = false) { $filesystem = new Filesystem(); if ( ! $filesystem->exists($dir)) { return $filesystem->makeDirectory($dir, 0755, true); } foreach (new FilesystemIterator($dir) as $file) { if ($preserveGit && $file->getFilename() == '.git') { continue; } if ($file->isDir() && ! $file->isLink()) { $filesystem->deleteDirectory($file); } else { $filesystem->delete($file); } } return true; }
[ "public", "function", "clean", "(", "$", "dir", ",", "$", "preserveGit", "=", "false", ")", "{", "$", "filesystem", "=", "new", "Filesystem", "(", ")", ";", "if", "(", "!", "$", "filesystem", "->", "exists", "(", "$", "dir", ")", ")", "{", "return", "$", "filesystem", "->", "makeDirectory", "(", "$", "dir", ",", "0755", ",", "true", ")", ";", "}", "foreach", "(", "new", "FilesystemIterator", "(", "$", "dir", ")", "as", "$", "file", ")", "{", "if", "(", "$", "preserveGit", "&&", "$", "file", "->", "getFilename", "(", ")", "==", "'.git'", ")", "{", "continue", ";", "}", "if", "(", "$", "file", "->", "isDir", "(", ")", "&&", "!", "$", "file", "->", "isLink", "(", ")", ")", "{", "$", "filesystem", "->", "deleteDirectory", "(", "$", "file", ")", ";", "}", "else", "{", "$", "filesystem", "->", "delete", "(", "$", "file", ")", ";", "}", "}", "return", "true", ";", "}" ]
Remove the contents of a directory, but not the directory itself. @param string $dir @param bool $preserveGit @return bool
[ "Remove", "the", "contents", "of", "a", "directory", "but", "not", "the", "directory", "itself", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Build/Builder.php#L105-L125
16,807
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/PDO.php
PDO.prepare
public function prepare($sql, array $driverOptions = array()) { $this->numStatements++; $pdos = $this->_pdo->prepare($sql, $driverOptions); return new PDOStatement($this, $pdos); }
php
public function prepare($sql, array $driverOptions = array()) { $this->numStatements++; $pdos = $this->_pdo->prepare($sql, $driverOptions); return new PDOStatement($this, $pdos); }
[ "public", "function", "prepare", "(", "$", "sql", ",", "array", "$", "driverOptions", "=", "array", "(", ")", ")", "{", "$", "this", "->", "numStatements", "++", ";", "$", "pdos", "=", "$", "this", "->", "_pdo", "->", "prepare", "(", "$", "sql", ",", "$", "driverOptions", ")", ";", "return", "new", "PDOStatement", "(", "$", "this", ",", "$", "pdos", ")", ";", "}" ]
Prepare the statement SQL @access public @param string $sql Statement SQL @param srray $driverOptions Driver options @return PDOStatement
[ "Prepare", "the", "statement", "SQL" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/PDO.php#L100-L107
16,808
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/PDO.php
PDO.query
public function query($sql) { $this->numExecutes++; $this->numStatements++; $pdos = $this->_pdo->query($sql); return new PDOStatement($this, $pdos); }
php
public function query($sql) { $this->numExecutes++; $this->numStatements++; $pdos = $this->_pdo->query($sql); return new PDOStatement($this, $pdos); }
[ "public", "function", "query", "(", "$", "sql", ")", "{", "$", "this", "->", "numExecutes", "++", ";", "$", "this", "->", "numStatements", "++", ";", "$", "pdos", "=", "$", "this", "->", "_pdo", "->", "query", "(", "$", "sql", ")", ";", "return", "new", "PDOStatement", "(", "$", "this", ",", "$", "pdos", ")", ";", "}" ]
Executes the statement query @access public @param string $sql Statement SQL @return PDOStatement
[ "Executes", "the", "statement", "query" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/PDO.php#L115-L123
16,809
nyeholt/silverstripe-external-content
code/transform/ExternalContentImporter.php
ExternalContentImporter.import
public function import($contentItem, $target, $includeParent = false, $includeChildren = true, $duplicateStrategy='Overwrite', $params = array()) { $this->runOnImportStart(); $this->params = $params; // if the queuedjobs module exists, use that $queuedVersion = 'Queued' . get_class($this); if ($this->config()->use_queue && ClassInfo::exists('QueuedJob') && ClassInfo::exists($queuedVersion)) { $importer = new $queuedVersion( $contentItem, $target, $includeParent, $includeChildren, $duplicateStrategy, $params); $service = singleton('QueuedJobService'); $service->queueJob($importer); return $importer; } $children = null; if ($includeParent) { // Get the children of a particular node $children = new ArrayList(); $children->push($contentItem); } else { $children = $contentItem->stageChildren(); } $this->importChildren($children, $target, $includeChildren, $duplicateStrategy); $this->runOnImportEnd(); return true; }
php
public function import($contentItem, $target, $includeParent = false, $includeChildren = true, $duplicateStrategy='Overwrite', $params = array()) { $this->runOnImportStart(); $this->params = $params; // if the queuedjobs module exists, use that $queuedVersion = 'Queued' . get_class($this); if ($this->config()->use_queue && ClassInfo::exists('QueuedJob') && ClassInfo::exists($queuedVersion)) { $importer = new $queuedVersion( $contentItem, $target, $includeParent, $includeChildren, $duplicateStrategy, $params); $service = singleton('QueuedJobService'); $service->queueJob($importer); return $importer; } $children = null; if ($includeParent) { // Get the children of a particular node $children = new ArrayList(); $children->push($contentItem); } else { $children = $contentItem->stageChildren(); } $this->importChildren($children, $target, $includeChildren, $duplicateStrategy); $this->runOnImportEnd(); return true; }
[ "public", "function", "import", "(", "$", "contentItem", ",", "$", "target", ",", "$", "includeParent", "=", "false", ",", "$", "includeChildren", "=", "true", ",", "$", "duplicateStrategy", "=", "'Overwrite'", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "this", "->", "runOnImportStart", "(", ")", ";", "$", "this", "->", "params", "=", "$", "params", ";", "// if the queuedjobs module exists, use that", "$", "queuedVersion", "=", "'Queued'", ".", "get_class", "(", "$", "this", ")", ";", "if", "(", "$", "this", "->", "config", "(", ")", "->", "use_queue", "&&", "ClassInfo", "::", "exists", "(", "'QueuedJob'", ")", "&&", "ClassInfo", "::", "exists", "(", "$", "queuedVersion", ")", ")", "{", "$", "importer", "=", "new", "$", "queuedVersion", "(", "$", "contentItem", ",", "$", "target", ",", "$", "includeParent", ",", "$", "includeChildren", ",", "$", "duplicateStrategy", ",", "$", "params", ")", ";", "$", "service", "=", "singleton", "(", "'QueuedJobService'", ")", ";", "$", "service", "->", "queueJob", "(", "$", "importer", ")", ";", "return", "$", "importer", ";", "}", "$", "children", "=", "null", ";", "if", "(", "$", "includeParent", ")", "{", "// Get the children of a particular node", "$", "children", "=", "new", "ArrayList", "(", ")", ";", "$", "children", "->", "push", "(", "$", "contentItem", ")", ";", "}", "else", "{", "$", "children", "=", "$", "contentItem", "->", "stageChildren", "(", ")", ";", "}", "$", "this", "->", "importChildren", "(", "$", "children", ",", "$", "target", ",", "$", "includeChildren", ",", "$", "duplicateStrategy", ")", ";", "$", "this", "->", "runOnImportEnd", "(", ")", ";", "return", "true", ";", "}" ]
Import from a content source to a particular target @param ExternalContentItem $contentItem @param SiteTree $target @param boolean $includeParent Whether to include the selected item in the import or not @param String $duplicateStrategy How to handle duplication @param array $params All parameters passed with the import request.
[ "Import", "from", "a", "content", "source", "to", "a", "particular", "target" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/transform/ExternalContentImporter.php#L34-L66
16,810
nyeholt/silverstripe-external-content
code/transform/ExternalContentImporter.php
ExternalContentImporter.importChildren
protected function importChildren($children, $parent, $includeChildren, $duplicateStrategy) { if (!$children) { return; } // get the importer to use, import, then see if there's any foreach ($children as $child) { $pageType = $this->getExternalType($child); if (isset($this->contentTransforms[$pageType])) { $transformer = $this->contentTransforms[$pageType]; $result = $transformer->transform($child, $parent, $duplicateStrategy); $this->extend('onAfterImport', $result); // if there's more, then transform them if ($includeChildren && $result && $result->children && count($result->children)) { // import the children $this->importChildren($result->children, $result->page, $includeChildren, $duplicateStrategy); } } } }
php
protected function importChildren($children, $parent, $includeChildren, $duplicateStrategy) { if (!$children) { return; } // get the importer to use, import, then see if there's any foreach ($children as $child) { $pageType = $this->getExternalType($child); if (isset($this->contentTransforms[$pageType])) { $transformer = $this->contentTransforms[$pageType]; $result = $transformer->transform($child, $parent, $duplicateStrategy); $this->extend('onAfterImport', $result); // if there's more, then transform them if ($includeChildren && $result && $result->children && count($result->children)) { // import the children $this->importChildren($result->children, $result->page, $includeChildren, $duplicateStrategy); } } } }
[ "protected", "function", "importChildren", "(", "$", "children", ",", "$", "parent", ",", "$", "includeChildren", ",", "$", "duplicateStrategy", ")", "{", "if", "(", "!", "$", "children", ")", "{", "return", ";", "}", "// get the importer to use, import, then see if there's any", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "pageType", "=", "$", "this", "->", "getExternalType", "(", "$", "child", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "contentTransforms", "[", "$", "pageType", "]", ")", ")", "{", "$", "transformer", "=", "$", "this", "->", "contentTransforms", "[", "$", "pageType", "]", ";", "$", "result", "=", "$", "transformer", "->", "transform", "(", "$", "child", ",", "$", "parent", ",", "$", "duplicateStrategy", ")", ";", "$", "this", "->", "extend", "(", "'onAfterImport'", ",", "$", "result", ")", ";", "// if there's more, then transform them", "if", "(", "$", "includeChildren", "&&", "$", "result", "&&", "$", "result", "->", "children", "&&", "count", "(", "$", "result", "->", "children", ")", ")", "{", "// import the children", "$", "this", "->", "importChildren", "(", "$", "result", "->", "children", ",", "$", "result", "->", "page", ",", "$", "includeChildren", ",", "$", "duplicateStrategy", ")", ";", "}", "}", "}", "}" ]
Execute the importing of several children @param DataObjectSet $children @param SiteTree $parent
[ "Execute", "the", "importing", "of", "several", "children" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/transform/ExternalContentImporter.php#L74-L95
16,811
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedImage.php
ExtendedImage.getBase64Tag
public function getBase64Tag() { if($this->owner->exists()) { $url = $this->owner->getBase64Source(); $title = ($this->owner->Title) ? $this->owner->Title : $this->owner->Filename; if($this->owner->Title) { $title = Convert::raw2att($this->owner->Title); } else { if(preg_match("/([^\/]*)\.[a-zA-Z0-9]{1,6}$/", $title, $matches)) $title = Convert::raw2att($matches[1]); } return "<img src=\"$url\" alt=\"$title\" />"; } }
php
public function getBase64Tag() { if($this->owner->exists()) { $url = $this->owner->getBase64Source(); $title = ($this->owner->Title) ? $this->owner->Title : $this->owner->Filename; if($this->owner->Title) { $title = Convert::raw2att($this->owner->Title); } else { if(preg_match("/([^\/]*)\.[a-zA-Z0-9]{1,6}$/", $title, $matches)) $title = Convert::raw2att($matches[1]); } return "<img src=\"$url\" alt=\"$title\" />"; } }
[ "public", "function", "getBase64Tag", "(", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "exists", "(", ")", ")", "{", "$", "url", "=", "$", "this", "->", "owner", "->", "getBase64Source", "(", ")", ";", "$", "title", "=", "(", "$", "this", "->", "owner", "->", "Title", ")", "?", "$", "this", "->", "owner", "->", "Title", ":", "$", "this", "->", "owner", "->", "Filename", ";", "if", "(", "$", "this", "->", "owner", "->", "Title", ")", "{", "$", "title", "=", "Convert", "::", "raw2att", "(", "$", "this", "->", "owner", "->", "Title", ")", ";", "}", "else", "{", "if", "(", "preg_match", "(", "\"/([^\\/]*)\\.[a-zA-Z0-9]{1,6}$/\"", ",", "$", "title", ",", "$", "matches", ")", ")", "$", "title", "=", "Convert", "::", "raw2att", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "return", "\"<img src=\\\"$url\\\" alt=\\\"$title\\\" />\"", ";", "}", "}" ]
Return an XHTML img tag for this Image. @return string
[ "Return", "an", "XHTML", "img", "tag", "for", "this", "Image", "." ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedImage.php#L29-L40
16,812
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedImage.php
ExtendedImage.getBase64Source
public function getBase64Source(){ $Fullpath = $this->owner->getFullPath(); $cache = SS_Cache::factory('Base64Image'); $cachekey = md5($Fullpath); if(!($Base64Image = $cache->load($cachekey))){ $Base64Image = base64_encode(file_get_contents($Fullpath)); $cache->save($Base64Image); } $type = strtolower($this->owner->getExtension()); return "data:image/".$type.";base64,".$Base64Image; }
php
public function getBase64Source(){ $Fullpath = $this->owner->getFullPath(); $cache = SS_Cache::factory('Base64Image'); $cachekey = md5($Fullpath); if(!($Base64Image = $cache->load($cachekey))){ $Base64Image = base64_encode(file_get_contents($Fullpath)); $cache->save($Base64Image); } $type = strtolower($this->owner->getExtension()); return "data:image/".$type.";base64,".$Base64Image; }
[ "public", "function", "getBase64Source", "(", ")", "{", "$", "Fullpath", "=", "$", "this", "->", "owner", "->", "getFullPath", "(", ")", ";", "$", "cache", "=", "SS_Cache", "::", "factory", "(", "'Base64Image'", ")", ";", "$", "cachekey", "=", "md5", "(", "$", "Fullpath", ")", ";", "if", "(", "!", "(", "$", "Base64Image", "=", "$", "cache", "->", "load", "(", "$", "cachekey", ")", ")", ")", "{", "$", "Base64Image", "=", "base64_encode", "(", "file_get_contents", "(", "$", "Fullpath", ")", ")", ";", "$", "cache", "->", "save", "(", "$", "Base64Image", ")", ";", "}", "$", "type", "=", "strtolower", "(", "$", "this", "->", "owner", "->", "getExtension", "(", ")", ")", ";", "return", "\"data:image/\"", ".", "$", "type", ".", "\";base64,\"", ".", "$", "Base64Image", ";", "}" ]
retrun the Base64 Notation of the Image
[ "retrun", "the", "Base64", "Notation", "of", "the", "Image" ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedImage.php#L45-L58
16,813
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedImage.php
ExtendedImage.DetectFace
public function DetectFace(){ $detector = new svay\FaceDetector(); $detector->faceDetect($this->owner->getFullPath()); return $detector->getFace(); }
php
public function DetectFace(){ $detector = new svay\FaceDetector(); $detector->faceDetect($this->owner->getFullPath()); return $detector->getFace(); }
[ "public", "function", "DetectFace", "(", ")", "{", "$", "detector", "=", "new", "svay", "\\", "FaceDetector", "(", ")", ";", "$", "detector", "->", "faceDetect", "(", "$", "this", "->", "owner", "->", "getFullPath", "(", ")", ")", ";", "return", "$", "detector", "->", "getFace", "(", ")", ";", "}" ]
Detect a Face inside the image returns null or an Array with x, y coordinates and w = width/height (square) @return Array
[ "Detect", "a", "Face", "inside", "the", "image" ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedImage.php#L66-L70
16,814
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedImage.php
ExtendedImage.DetectedFace
public function DetectedFace(){ if($this->owner->exists()) { $cacheFile = $this->owner->cacheDetectedFaceFilename(); if(!file_exists(Director::baseFolder()."/".$cacheFile) || isset($_GET['flush'])) { $this->owner->generateDetectedFaceImage(); } if($this->owner instanceof SecureImage) $cached = new SecureImage_Cached($cacheFile); else $cached = new Image_Cached($cacheFile); // Pass through the title so the templates can use it $cached->Title = $this->owner->Title; $cached->ID = $this->owner->ID; $cached->ParentID = $this->owner->ParentID; return $cached; } }
php
public function DetectedFace(){ if($this->owner->exists()) { $cacheFile = $this->owner->cacheDetectedFaceFilename(); if(!file_exists(Director::baseFolder()."/".$cacheFile) || isset($_GET['flush'])) { $this->owner->generateDetectedFaceImage(); } if($this->owner instanceof SecureImage) $cached = new SecureImage_Cached($cacheFile); else $cached = new Image_Cached($cacheFile); // Pass through the title so the templates can use it $cached->Title = $this->owner->Title; $cached->ID = $this->owner->ID; $cached->ParentID = $this->owner->ParentID; return $cached; } }
[ "public", "function", "DetectedFace", "(", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "exists", "(", ")", ")", "{", "$", "cacheFile", "=", "$", "this", "->", "owner", "->", "cacheDetectedFaceFilename", "(", ")", ";", "if", "(", "!", "file_exists", "(", "Director", "::", "baseFolder", "(", ")", ".", "\"/\"", ".", "$", "cacheFile", ")", "||", "isset", "(", "$", "_GET", "[", "'flush'", "]", ")", ")", "{", "$", "this", "->", "owner", "->", "generateDetectedFaceImage", "(", ")", ";", "}", "if", "(", "$", "this", "->", "owner", "instanceof", "SecureImage", ")", "$", "cached", "=", "new", "SecureImage_Cached", "(", "$", "cacheFile", ")", ";", "else", "$", "cached", "=", "new", "Image_Cached", "(", "$", "cacheFile", ")", ";", "// Pass through the title so the templates can use it", "$", "cached", "->", "Title", "=", "$", "this", "->", "owner", "->", "Title", ";", "$", "cached", "->", "ID", "=", "$", "this", "->", "owner", "->", "ID", ";", "$", "cached", "->", "ParentID", "=", "$", "this", "->", "owner", "->", "ParentID", ";", "return", "$", "cached", ";", "}", "}" ]
returns the image with the face marked in a red square @return Image_Cached|SecureImage_Cached
[ "returns", "the", "image", "with", "the", "face", "marked", "in", "a", "red", "square" ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedImage.php#L77-L94
16,815
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedImage.php
ExtendedImage.getMergedImage
public function getMergedImage($format, $padding, $mergeimage) { if($this->owner->exists() && Director::fileExists($mergeimage)) { $cacheFile = $this->owner->cacheMergedFilename($format, $padding, $mergeimage); if(!file_exists(Director::baseFolder()."/".$cacheFile) || isset($_GET['flush'])) { // merge the current image over the given Merging Image if($format == 'over') $this->owner->generateMergedImage($padding, $mergeimage, $this->owner->getFullPath(), $cacheFile); // merge the current image over the given Merging Image else $this->owner->generateMergedImage($padding, $this->owner->getFullPath(), $mergeimage, $cacheFile); } if($this->owner instanceof SecureImage) $cached = new SecureImage_Cached($cacheFile); else $cached = new Image_Cached($cacheFile); // Pass through the title so the templates can use it $cached->Title = $this->owner->Title; $cached->ID = $this->owner->ID; $cached->ParentID = $this->owner->ParentID; return $cached; } }
php
public function getMergedImage($format, $padding, $mergeimage) { if($this->owner->exists() && Director::fileExists($mergeimage)) { $cacheFile = $this->owner->cacheMergedFilename($format, $padding, $mergeimage); if(!file_exists(Director::baseFolder()."/".$cacheFile) || isset($_GET['flush'])) { // merge the current image over the given Merging Image if($format == 'over') $this->owner->generateMergedImage($padding, $mergeimage, $this->owner->getFullPath(), $cacheFile); // merge the current image over the given Merging Image else $this->owner->generateMergedImage($padding, $this->owner->getFullPath(), $mergeimage, $cacheFile); } if($this->owner instanceof SecureImage) $cached = new SecureImage_Cached($cacheFile); else $cached = new Image_Cached($cacheFile); // Pass through the title so the templates can use it $cached->Title = $this->owner->Title; $cached->ID = $this->owner->ID; $cached->ParentID = $this->owner->ParentID; return $cached; } }
[ "public", "function", "getMergedImage", "(", "$", "format", ",", "$", "padding", ",", "$", "mergeimage", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "exists", "(", ")", "&&", "Director", "::", "fileExists", "(", "$", "mergeimage", ")", ")", "{", "$", "cacheFile", "=", "$", "this", "->", "owner", "->", "cacheMergedFilename", "(", "$", "format", ",", "$", "padding", ",", "$", "mergeimage", ")", ";", "if", "(", "!", "file_exists", "(", "Director", "::", "baseFolder", "(", ")", ".", "\"/\"", ".", "$", "cacheFile", ")", "||", "isset", "(", "$", "_GET", "[", "'flush'", "]", ")", ")", "{", "// merge the current image over the given Merging Image", "if", "(", "$", "format", "==", "'over'", ")", "$", "this", "->", "owner", "->", "generateMergedImage", "(", "$", "padding", ",", "$", "mergeimage", ",", "$", "this", "->", "owner", "->", "getFullPath", "(", ")", ",", "$", "cacheFile", ")", ";", "// merge the current image over the given Merging Image", "else", "$", "this", "->", "owner", "->", "generateMergedImage", "(", "$", "padding", ",", "$", "this", "->", "owner", "->", "getFullPath", "(", ")", ",", "$", "mergeimage", ",", "$", "cacheFile", ")", ";", "}", "if", "(", "$", "this", "->", "owner", "instanceof", "SecureImage", ")", "$", "cached", "=", "new", "SecureImage_Cached", "(", "$", "cacheFile", ")", ";", "else", "$", "cached", "=", "new", "Image_Cached", "(", "$", "cacheFile", ")", ";", "// Pass through the title so the templates can use it", "$", "cached", "->", "Title", "=", "$", "this", "->", "owner", "->", "Title", ";", "$", "cached", "->", "ID", "=", "$", "this", "->", "owner", "->", "ID", ";", "$", "cached", "->", "ParentID", "=", "$", "this", "->", "owner", "->", "ParentID", ";", "return", "$", "cached", ";", "}", "}" ]
Return an image object representing the merged image. @param type $format @param type $padding @param type $mergeimage @return Image_Cached
[ "Return", "an", "image", "object", "representing", "the", "merged", "image", "." ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedImage.php#L180-L200
16,816
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedImage.php
ExtendedImage.generateMergedImage
public function generateMergedImage($padding, $bgImagePath, $overlayImagePath, $cacheFile){ $bgImage = Injector::inst()->createWithArgs(Image::get_backend(), array( $bgImagePath )); $ovImage = Injector::inst()->createWithArgs(Image::get_backend(), array( $overlayImagePath )); $frontImage = $this->owner->generateFit($ovImage, ($bgImage->getWidth() - (2*$padding)), ($bgImage->getHeight() - (2*$padding))); $backend = $bgImage->merge($frontImage); if($backend){ $backend->writeTo(Director::baseFolder()."/" . $cacheFile); } }
php
public function generateMergedImage($padding, $bgImagePath, $overlayImagePath, $cacheFile){ $bgImage = Injector::inst()->createWithArgs(Image::get_backend(), array( $bgImagePath )); $ovImage = Injector::inst()->createWithArgs(Image::get_backend(), array( $overlayImagePath )); $frontImage = $this->owner->generateFit($ovImage, ($bgImage->getWidth() - (2*$padding)), ($bgImage->getHeight() - (2*$padding))); $backend = $bgImage->merge($frontImage); if($backend){ $backend->writeTo(Director::baseFolder()."/" . $cacheFile); } }
[ "public", "function", "generateMergedImage", "(", "$", "padding", ",", "$", "bgImagePath", ",", "$", "overlayImagePath", ",", "$", "cacheFile", ")", "{", "$", "bgImage", "=", "Injector", "::", "inst", "(", ")", "->", "createWithArgs", "(", "Image", "::", "get_backend", "(", ")", ",", "array", "(", "$", "bgImagePath", ")", ")", ";", "$", "ovImage", "=", "Injector", "::", "inst", "(", ")", "->", "createWithArgs", "(", "Image", "::", "get_backend", "(", ")", ",", "array", "(", "$", "overlayImagePath", ")", ")", ";", "$", "frontImage", "=", "$", "this", "->", "owner", "->", "generateFit", "(", "$", "ovImage", ",", "(", "$", "bgImage", "->", "getWidth", "(", ")", "-", "(", "2", "*", "$", "padding", ")", ")", ",", "(", "$", "bgImage", "->", "getHeight", "(", ")", "-", "(", "2", "*", "$", "padding", ")", ")", ")", ";", "$", "backend", "=", "$", "bgImage", "->", "merge", "(", "$", "frontImage", ")", ";", "if", "(", "$", "backend", ")", "{", "$", "backend", "->", "writeTo", "(", "Director", "::", "baseFolder", "(", ")", ".", "\"/\"", ".", "$", "cacheFile", ")", ";", "}", "}" ]
genereate the merged image
[ "genereate", "the", "merged", "image" ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedImage.php#L241-L256
16,817
andrelohmann/silverstripe-extended-image
code/extensions/ExtendedImage.php
ExtendedImage.ToJPEG
public function ToJPEG($quality = null, $backgroundColor = null) { if (!$quality) $quality = Config::inst()->get('ExtendedImage', 'get_jpeg_default_quality'); if (!$backgroundColor) $backgroundColor = Config::inst()->get('ExtendedImage', 'get_jpeg_default_background_color'); return $this->owner->getJPEGImage($quality, $backgroundColor); }
php
public function ToJPEG($quality = null, $backgroundColor = null) { if (!$quality) $quality = Config::inst()->get('ExtendedImage', 'get_jpeg_default_quality'); if (!$backgroundColor) $backgroundColor = Config::inst()->get('ExtendedImage', 'get_jpeg_default_background_color'); return $this->owner->getJPEGImage($quality, $backgroundColor); }
[ "public", "function", "ToJPEG", "(", "$", "quality", "=", "null", ",", "$", "backgroundColor", "=", "null", ")", "{", "if", "(", "!", "$", "quality", ")", "$", "quality", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "'ExtendedImage'", ",", "'get_jpeg_default_quality'", ")", ";", "if", "(", "!", "$", "backgroundColor", ")", "$", "backgroundColor", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "'ExtendedImage'", ",", "'get_jpeg_default_background_color'", ")", ";", "return", "$", "this", "->", "owner", "->", "getJPEGImage", "(", "$", "quality", ",", "$", "backgroundColor", ")", ";", "}" ]
Generate a jpeg image from the source set quality and backgroundColor for Transparency @param $quality @param $backgroundColor
[ "Generate", "a", "jpeg", "image", "from", "the", "source" ]
178e9142ae8ff63f9bf36464093379f6e836b90b
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/extensions/ExtendedImage.php#L433-L440
16,818
SachaMorard/phalcon-console
Library/Phalcon/Commands/Command.php
Command.checkRequired
public function checkRequired($required) { foreach ($required as $fieldRequired) { if (!isset($this->_parameters[$fieldRequired])) { throw new CommandsException("The parameter '$fieldRequired' is required for this script"); } } }
php
public function checkRequired($required) { foreach ($required as $fieldRequired) { if (!isset($this->_parameters[$fieldRequired])) { throw new CommandsException("The parameter '$fieldRequired' is required for this script"); } } }
[ "public", "function", "checkRequired", "(", "$", "required", ")", "{", "foreach", "(", "$", "required", "as", "$", "fieldRequired", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_parameters", "[", "$", "fieldRequired", "]", ")", ")", "{", "throw", "new", "CommandsException", "(", "\"The parameter '$fieldRequired' is required for this script\"", ")", ";", "}", "}", "}" ]
Check that a set of parameters has been received. @param $required @throws CommandsException
[ "Check", "that", "a", "set", "of", "parameters", "has", "been", "received", "." ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/Command.php#L263-L270
16,819
SachaMorard/phalcon-console
Library/Phalcon/Commands/Command.php
Command.showHelp
public function showHelp($possibleParameters) { echo get_class($this).' - Usage:'.PHP_EOL.PHP_EOL; foreach ($possibleParameters as $parameter => $description) { echo html_entity_decode($description, ENT_COMPAT, $this->_encoding).PHP_EOL; } }
php
public function showHelp($possibleParameters) { echo get_class($this).' - Usage:'.PHP_EOL.PHP_EOL; foreach ($possibleParameters as $parameter => $description) { echo html_entity_decode($description, ENT_COMPAT, $this->_encoding).PHP_EOL; } }
[ "public", "function", "showHelp", "(", "$", "possibleParameters", ")", "{", "echo", "get_class", "(", "$", "this", ")", ".", "' - Usage:'", ".", "PHP_EOL", ".", "PHP_EOL", ";", "foreach", "(", "$", "possibleParameters", "as", "$", "parameter", "=>", "$", "description", ")", "{", "echo", "html_entity_decode", "(", "$", "description", ",", "ENT_COMPAT", ",", "$", "this", "->", "_encoding", ")", ".", "PHP_EOL", ";", "}", "}" ]
Displays help for the script. @param array $possibleParameters
[ "Displays", "help", "for", "the", "script", "." ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/Command.php#L290-L296
16,820
SachaMorard/phalcon-console
Library/Phalcon/Commands/Command.php
Command.getOptions
public function getOptions($filters = null) { if (!$filters) { return $this->_parameters; } $result = []; foreach ($this->_parameters as $param) { $result[] = $this->filter($param, $filters); } return $result; }
php
public function getOptions($filters = null) { if (!$filters) { return $this->_parameters; } $result = []; foreach ($this->_parameters as $param) { $result[] = $this->filter($param, $filters); } return $result; }
[ "public", "function", "getOptions", "(", "$", "filters", "=", "null", ")", "{", "if", "(", "!", "$", "filters", ")", "{", "return", "$", "this", "->", "_parameters", ";", "}", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_parameters", "as", "$", "param", ")", "{", "$", "result", "[", "]", "=", "$", "this", "->", "filter", "(", "$", "param", ",", "$", "filters", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns all received options. @param mixed $filters Filter name or array of filters [Optional] @return array
[ "Returns", "all", "received", "options", "." ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/Command.php#L305-L318
16,821
SachaMorard/phalcon-console
Library/Phalcon/Commands/Command.php
Command.getOption
public function getOption($option, $filters = null, $defaultValue = null) { if (is_array($option)) { foreach ($option as $optionItem) { if (isset($this->_parameters[$optionItem])) { if ($filters !== null) { return $this->filter($this->_parameters[$optionItem], $filters); } return $this->_parameters[$optionItem]; } } return $defaultValue; } if (isset($this->_parameters[$option])) { if ($filters !== null) { return $this->filter($this->_parameters[$option], $filters); } return $this->_parameters[$option]; } return $defaultValue; }
php
public function getOption($option, $filters = null, $defaultValue = null) { if (is_array($option)) { foreach ($option as $optionItem) { if (isset($this->_parameters[$optionItem])) { if ($filters !== null) { return $this->filter($this->_parameters[$optionItem], $filters); } return $this->_parameters[$optionItem]; } } return $defaultValue; } if (isset($this->_parameters[$option])) { if ($filters !== null) { return $this->filter($this->_parameters[$option], $filters); } return $this->_parameters[$option]; } return $defaultValue; }
[ "public", "function", "getOption", "(", "$", "option", ",", "$", "filters", "=", "null", ",", "$", "defaultValue", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "option", ")", ")", "{", "foreach", "(", "$", "option", "as", "$", "optionItem", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_parameters", "[", "$", "optionItem", "]", ")", ")", "{", "if", "(", "$", "filters", "!==", "null", ")", "{", "return", "$", "this", "->", "filter", "(", "$", "this", "->", "_parameters", "[", "$", "optionItem", "]", ",", "$", "filters", ")", ";", "}", "return", "$", "this", "->", "_parameters", "[", "$", "optionItem", "]", ";", "}", "}", "return", "$", "defaultValue", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_parameters", "[", "$", "option", "]", ")", ")", "{", "if", "(", "$", "filters", "!==", "null", ")", "{", "return", "$", "this", "->", "filter", "(", "$", "this", "->", "_parameters", "[", "$", "option", "]", ",", "$", "filters", ")", ";", "}", "return", "$", "this", "->", "_parameters", "[", "$", "option", "]", ";", "}", "return", "$", "defaultValue", ";", "}" ]
Returns the value of an option received. @param mixed $option Option name or array of options @param mixed $filters Filter name or array of filters [Optional] @param mixed $defaultValue Default value [Optional] @return mixed
[ "Returns", "the", "value", "of", "an", "option", "received", "." ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/Command.php#L329-L354
16,822
SachaMorard/phalcon-console
Library/Phalcon/Commands/Command.php
Command.isReceivedOption
public function isReceivedOption($option) { if (!is_array($option)) { $option = [$option]; } foreach ($option as $op) { if (isset($this->_parameters[$op])) { return true; } } return false; }
php
public function isReceivedOption($option) { if (!is_array($option)) { $option = [$option]; } foreach ($option as $op) { if (isset($this->_parameters[$op])) { return true; } } return false; }
[ "public", "function", "isReceivedOption", "(", "$", "option", ")", "{", "if", "(", "!", "is_array", "(", "$", "option", ")", ")", "{", "$", "option", "=", "[", "$", "option", "]", ";", "}", "foreach", "(", "$", "option", "as", "$", "op", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_parameters", "[", "$", "op", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Indicates whether the script was a particular option. @param string $option @return boolean
[ "Indicates", "whether", "the", "script", "was", "a", "particular", "option", "." ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/Command.php#L362-L375
16,823
SachaMorard/phalcon-console
Library/Phalcon/Commands/Command.php
Command.getLastUnNamedParam
public function getLastUnNamedParam() { foreach (array_reverse($this->_parameters) as $key => $value) { if (is_numeric($key)) { return $value; } } return false; }
php
public function getLastUnNamedParam() { foreach (array_reverse($this->_parameters) as $key => $value) { if (is_numeric($key)) { return $value; } } return false; }
[ "public", "function", "getLastUnNamedParam", "(", ")", "{", "foreach", "(", "array_reverse", "(", "$", "this", "->", "_parameters", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "return", "$", "value", ";", "}", "}", "return", "false", ";", "}" ]
Gets the last parameter is not associated with any parameter name. @return string
[ "Gets", "the", "last", "parameter", "is", "not", "associated", "with", "any", "parameter", "name", "." ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/Command.php#L397-L406
16,824
SachaMorard/phalcon-console
Library/Phalcon/Commands/Command.php
Command.printParameters
public function printParameters($parameters) { $length = 0; foreach ($parameters as $parameter => $description) { if ($length == 0) { $length = strlen($parameter); } if (strlen($parameter) > $length) { $length = strlen($parameter); } } print Color::head('Options:') . PHP_EOL; foreach ($parameters as $parameter => $description) { print Color::colorize(' --' . $parameter . str_repeat(' ', $length - strlen($parameter)), Color::FG_GREEN); print Color::colorize(" " . $description) . PHP_EOL; } }
php
public function printParameters($parameters) { $length = 0; foreach ($parameters as $parameter => $description) { if ($length == 0) { $length = strlen($parameter); } if (strlen($parameter) > $length) { $length = strlen($parameter); } } print Color::head('Options:') . PHP_EOL; foreach ($parameters as $parameter => $description) { print Color::colorize(' --' . $parameter . str_repeat(' ', $length - strlen($parameter)), Color::FG_GREEN); print Color::colorize(" " . $description) . PHP_EOL; } }
[ "public", "function", "printParameters", "(", "$", "parameters", ")", "{", "$", "length", "=", "0", ";", "foreach", "(", "$", "parameters", "as", "$", "parameter", "=>", "$", "description", ")", "{", "if", "(", "$", "length", "==", "0", ")", "{", "$", "length", "=", "strlen", "(", "$", "parameter", ")", ";", "}", "if", "(", "strlen", "(", "$", "parameter", ")", ">", "$", "length", ")", "{", "$", "length", "=", "strlen", "(", "$", "parameter", ")", ";", "}", "}", "print", "Color", "::", "head", "(", "'Options:'", ")", ".", "PHP_EOL", ";", "foreach", "(", "$", "parameters", "as", "$", "parameter", "=>", "$", "description", ")", "{", "print", "Color", "::", "colorize", "(", "' --'", ".", "$", "parameter", ".", "str_repeat", "(", "' '", ",", "$", "length", "-", "strlen", "(", "$", "parameter", ")", ")", ",", "Color", "::", "FG_GREEN", ")", ";", "print", "Color", "::", "colorize", "(", "\" \"", ".", "$", "description", ")", ".", "PHP_EOL", ";", "}", "}" ]
Prints the available options in the script @param array $parameters
[ "Prints", "the", "available", "options", "in", "the", "script" ]
a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3
https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/Command.php#L425-L442
16,825
thienhungho/yii2-order-management
src/modules/OrderManage/controllers/OrderController.php
OrderController.findModel
protected function findModel($id) { if (($model = Order::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
php
protected function findModel($id) { if (($model = Order::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "if", "(", "(", "$", "model", "=", "Order", "::", "findOne", "(", "$", "id", ")", ")", "!==", "null", ")", "{", "return", "$", "model", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "t", "(", "'app'", ",", "'The requested page does not exist.'", ")", ")", ";", "}", "}" ]
Finds the Order model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param integer $id @return Order the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "Order", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
f263f0b2168d6f5e99cee2e20a5878d09d4e81c0
https://github.com/thienhungho/yii2-order-management/blob/f263f0b2168d6f5e99cee2e20a5878d09d4e81c0/src/modules/OrderManage/controllers/OrderController.php#L306-L313
16,826
anime-db/world-art-filler-bundle
src/Service/Browser.php
Browser.getDom
public function getDom($path) { $dom = new \DOMDocument('1.0', 'utf8'); if (($content = $this->getContent($path)) && $dom->loadHTML($content)) { return $dom; } else { return; } }
php
public function getDom($path) { $dom = new \DOMDocument('1.0', 'utf8'); if (($content = $this->getContent($path)) && $dom->loadHTML($content)) { return $dom; } else { return; } }
[ "public", "function", "getDom", "(", "$", "path", ")", "{", "$", "dom", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'utf8'", ")", ";", "if", "(", "(", "$", "content", "=", "$", "this", "->", "getContent", "(", "$", "path", ")", ")", "&&", "$", "dom", "->", "loadHTML", "(", "$", "content", ")", ")", "{", "return", "$", "dom", ";", "}", "else", "{", "return", ";", "}", "}" ]
Get DOMDocument from path. Receive content from the URL, cleaning using Tidy and creating DOM document @param string $path @return \DOMDocument|null
[ "Get", "DOMDocument", "from", "path", "." ]
f2ef4dbd12fe39c18183d1628b5049b8d381e42c
https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Browser.php#L108-L116
16,827
anime-db/world-art-filler-bundle
src/Service/Browser.php
Browser.getContent
public function getContent($path) { /* @var $response \Guzzle\Http\Message\Response */ $response = $this->getBrowser()->get($path)->send(); if ($response->isError()) { throw new \RuntimeException('Failed to query the server '.$this->host); } if ($response->getStatusCode() !== 200 || !($html = $response->getBody(true))) { return; } $html = iconv('windows-1251', 'utf-8', $html); // clean content $config = [ 'output-xhtml' => true, 'indent' => true, 'indent-spaces' => 0, 'fix-backslash' => true, 'hide-comments' => true, 'drop-empty-paras' => true, 'wrap' => false, ]; $tidy = new \tidy(); $tidy->parseString($html, $config, 'utf8'); $tidy->cleanRepair(); $html = $tidy->root()->value; // ignore blocks $html = preg_replace('/<noembed>.*?<\/noembed>/is', '', $html); $html = preg_replace('/<noindex>.*?<\/noindex>/is', '', $html); // remove noembed return $html; }
php
public function getContent($path) { /* @var $response \Guzzle\Http\Message\Response */ $response = $this->getBrowser()->get($path)->send(); if ($response->isError()) { throw new \RuntimeException('Failed to query the server '.$this->host); } if ($response->getStatusCode() !== 200 || !($html = $response->getBody(true))) { return; } $html = iconv('windows-1251', 'utf-8', $html); // clean content $config = [ 'output-xhtml' => true, 'indent' => true, 'indent-spaces' => 0, 'fix-backslash' => true, 'hide-comments' => true, 'drop-empty-paras' => true, 'wrap' => false, ]; $tidy = new \tidy(); $tidy->parseString($html, $config, 'utf8'); $tidy->cleanRepair(); $html = $tidy->root()->value; // ignore blocks $html = preg_replace('/<noembed>.*?<\/noembed>/is', '', $html); $html = preg_replace('/<noindex>.*?<\/noindex>/is', '', $html); // remove noembed return $html; }
[ "public", "function", "getContent", "(", "$", "path", ")", "{", "/* @var $response \\Guzzle\\Http\\Message\\Response */", "$", "response", "=", "$", "this", "->", "getBrowser", "(", ")", "->", "get", "(", "$", "path", ")", "->", "send", "(", ")", ";", "if", "(", "$", "response", "->", "isError", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Failed to query the server '", ".", "$", "this", "->", "host", ")", ";", "}", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "!==", "200", "||", "!", "(", "$", "html", "=", "$", "response", "->", "getBody", "(", "true", ")", ")", ")", "{", "return", ";", "}", "$", "html", "=", "iconv", "(", "'windows-1251'", ",", "'utf-8'", ",", "$", "html", ")", ";", "// clean content", "$", "config", "=", "[", "'output-xhtml'", "=>", "true", ",", "'indent'", "=>", "true", ",", "'indent-spaces'", "=>", "0", ",", "'fix-backslash'", "=>", "true", ",", "'hide-comments'", "=>", "true", ",", "'drop-empty-paras'", "=>", "true", ",", "'wrap'", "=>", "false", ",", "]", ";", "$", "tidy", "=", "new", "\\", "tidy", "(", ")", ";", "$", "tidy", "->", "parseString", "(", "$", "html", ",", "$", "config", ",", "'utf8'", ")", ";", "$", "tidy", "->", "cleanRepair", "(", ")", ";", "$", "html", "=", "$", "tidy", "->", "root", "(", ")", "->", "value", ";", "// ignore blocks", "$", "html", "=", "preg_replace", "(", "'/<noembed>.*?<\\/noembed>/is'", ",", "''", ",", "$", "html", ")", ";", "$", "html", "=", "preg_replace", "(", "'/<noindex>.*?<\\/noindex>/is'", ",", "''", ",", "$", "html", ")", ";", "// remove noembed", "return", "$", "html", ";", "}" ]
Get content from path. Receive content from the URL and cleaning using Tidy @param string $path @return string
[ "Get", "content", "from", "path", "." ]
f2ef4dbd12fe39c18183d1628b5049b8d381e42c
https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Browser.php#L127-L158
16,828
anime-db/world-art-filler-bundle
src/Service/Browser.php
Browser.getBrowser
protected function getBrowser() { if (!($this->browser instanceof Client)) { $this->browser = new Client($this->host); // try to set User-Agent from original request $user_agent = self::DEFAULT_USER_AGENT; if ($this->request) { $user_agent = $this->request->server->get('HTTP_USER_AGENT', self::DEFAULT_USER_AGENT); } $this->browser->setDefaultHeaders(['User-Agent' => $user_agent]); // configure browser client $this->browser->setDefaultOption('timeout', $this->timeout); if ($this->proxy_list) { $this->browser->setDefaultOption('proxy', $this->proxy_list[array_rand($this->proxy_list)]); } } return $this->browser; }
php
protected function getBrowser() { if (!($this->browser instanceof Client)) { $this->browser = new Client($this->host); // try to set User-Agent from original request $user_agent = self::DEFAULT_USER_AGENT; if ($this->request) { $user_agent = $this->request->server->get('HTTP_USER_AGENT', self::DEFAULT_USER_AGENT); } $this->browser->setDefaultHeaders(['User-Agent' => $user_agent]); // configure browser client $this->browser->setDefaultOption('timeout', $this->timeout); if ($this->proxy_list) { $this->browser->setDefaultOption('proxy', $this->proxy_list[array_rand($this->proxy_list)]); } } return $this->browser; }
[ "protected", "function", "getBrowser", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "browser", "instanceof", "Client", ")", ")", "{", "$", "this", "->", "browser", "=", "new", "Client", "(", "$", "this", "->", "host", ")", ";", "// try to set User-Agent from original request", "$", "user_agent", "=", "self", "::", "DEFAULT_USER_AGENT", ";", "if", "(", "$", "this", "->", "request", ")", "{", "$", "user_agent", "=", "$", "this", "->", "request", "->", "server", "->", "get", "(", "'HTTP_USER_AGENT'", ",", "self", "::", "DEFAULT_USER_AGENT", ")", ";", "}", "$", "this", "->", "browser", "->", "setDefaultHeaders", "(", "[", "'User-Agent'", "=>", "$", "user_agent", "]", ")", ";", "// configure browser client", "$", "this", "->", "browser", "->", "setDefaultOption", "(", "'timeout'", ",", "$", "this", "->", "timeout", ")", ";", "if", "(", "$", "this", "->", "proxy_list", ")", "{", "$", "this", "->", "browser", "->", "setDefaultOption", "(", "'proxy'", ",", "$", "this", "->", "proxy_list", "[", "array_rand", "(", "$", "this", "->", "proxy_list", ")", "]", ")", ";", "}", "}", "return", "$", "this", "->", "browser", ";", "}" ]
Get HTTP browser. @param \Guzzle\Http\Client
[ "Get", "HTTP", "browser", "." ]
f2ef4dbd12fe39c18183d1628b5049b8d381e42c
https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Browser.php#L165-L185
16,829
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseLicense.php
BaseLicense.validate
public function validate($columns = null) { $res = $this->doValidate($columns); if ($res === true) { $this->validationFailures = array(); return true; } $this->validationFailures = $res; return false; }
php
public function validate($columns = null) { $res = $this->doValidate($columns); if ($res === true) { $this->validationFailures = array(); return true; } $this->validationFailures = $res; return false; }
[ "public", "function", "validate", "(", "$", "columns", "=", "null", ")", "{", "$", "res", "=", "$", "this", "->", "doValidate", "(", "$", "columns", ")", ";", "if", "(", "$", "res", "===", "true", ")", "{", "$", "this", "->", "validationFailures", "=", "array", "(", ")", ";", "return", "true", ";", "}", "$", "this", "->", "validationFailures", "=", "$", "res", ";", "return", "false", ";", "}" ]
Validates the objects modified field values and all objects related to this table. If $columns is either a column name or an array of column names only those columns are validated. @param mixed $columns Column name or an array of column names. @return boolean Whether all columns pass validation. @see doValidate() @see getValidationFailures()
[ "Validates", "the", "objects", "modified", "field", "values", "and", "all", "objects", "related", "to", "this", "table", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseLicense.php#L609-L621
16,830
danrevah/shortify-punit
src/ShortifyPunit.php
ShortifyPunit.mock
public static function mock($mockedClass) { $reflection = self::getMockReflection($mockedClass); return static::mockClass( $reflection, self::$namespace, self::$classBasePrefix ); }
php
public static function mock($mockedClass) { $reflection = self::getMockReflection($mockedClass); return static::mockClass( $reflection, self::$namespace, self::$classBasePrefix ); }
[ "public", "static", "function", "mock", "(", "$", "mockedClass", ")", "{", "$", "reflection", "=", "self", "::", "getMockReflection", "(", "$", "mockedClass", ")", ";", "return", "static", "::", "mockClass", "(", "$", "reflection", ",", "self", "::", "$", "namespace", ",", "self", "::", "$", "classBasePrefix", ")", ";", "}" ]
Mocking interfaces & classes @desc Ignoring final and private methods Examples: // Creating a new mock for SimpleClassForMocking $mock = ShortifyPunit::mock('SimpleClassForMocking'); // Returns NULL, was not stubbed yet $mock->first_method(); @param $mockedClass @return mixed
[ "Mocking", "interfaces", "&", "classes" ]
cedd08f31de8e7409a07d2630701ef4e924cc5f0
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/ShortifyPunit.php#L95-L104
16,831
danrevah/shortify-punit
src/ShortifyPunit.php
ShortifyPunit.partialMock
public static function partialMock($mockedClass) { $reflection = self::getMockReflection($mockedClass); return static::mockClass( $reflection, self::$namespace, self::$classBasePrefix, MockTypes::PARTIAL ); }
php
public static function partialMock($mockedClass) { $reflection = self::getMockReflection($mockedClass); return static::mockClass( $reflection, self::$namespace, self::$classBasePrefix, MockTypes::PARTIAL ); }
[ "public", "static", "function", "partialMock", "(", "$", "mockedClass", ")", "{", "$", "reflection", "=", "self", "::", "getMockReflection", "(", "$", "mockedClass", ")", ";", "return", "static", "::", "mockClass", "(", "$", "reflection", ",", "self", "::", "$", "namespace", ",", "self", "::", "$", "classBasePrefix", ",", "MockTypes", "::", "PARTIAL", ")", ";", "}" ]
Partial Mocking interfaces & classes @desc Partial mock is not stubbing any function by default (to NULL) like in regular mock() Examples: // class to partial mock class Foo { function bar() { return 'bar'; } } $mock = ShortifyPunit::mock('Foo'); $partialMock = ShortifyPunit::partialMock('Foo'); $mock->bar(); // returns NULL echo $partialMock->bar(); // prints 'bar' ShortifyPunit::when($partialMock)->bar()->returns('foo'); // stubbing partial mock echo $partialMock->bar(); // prints 'foo' @param $mockedClass @return mixed
[ "Partial", "Mocking", "interfaces", "&", "classes" ]
cedd08f31de8e7409a07d2630701ef4e924cc5f0
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/ShortifyPunit.php#L129-L139
16,832
danrevah/shortify-punit
src/ShortifyPunit.php
ShortifyPunit._isMethodStubbed
protected static function _isMethodStubbed($className, $instanceId, $methodName) { // check if instance of this method even exist if ( ! isset(self::$returnValues[$className][$instanceId][$methodName])) { return false; } return true; }
php
protected static function _isMethodStubbed($className, $instanceId, $methodName) { // check if instance of this method even exist if ( ! isset(self::$returnValues[$className][$instanceId][$methodName])) { return false; } return true; }
[ "protected", "static", "function", "_isMethodStubbed", "(", "$", "className", ",", "$", "instanceId", ",", "$", "methodName", ")", "{", "// check if instance of this method even exist", "if", "(", "!", "isset", "(", "self", "::", "$", "returnValues", "[", "$", "className", "]", "[", "$", "instanceId", "]", "[", "$", "methodName", "]", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checking if a method with specific arguments has been stubbed @param $className @param $instanceId @param $methodName @return bool
[ "Checking", "if", "a", "method", "with", "specific", "arguments", "has", "been", "stubbed" ]
cedd08f31de8e7409a07d2630701ef4e924cc5f0
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/ShortifyPunit.php#L229-L237
16,833
danrevah/shortify-punit
src/ShortifyPunit.php
ShortifyPunit._createChainResponse
protected static function _createChainResponse( $mockClassInstanceId, $mockClassType, $chainedMethodsBefore, $currentMethod, $args ) { $currentMethodName = key($currentMethod); $rReturnValues = &self::getMockHierarchyResponse( $chainedMethodsBefore, $mockClassType, $mockClassInstanceId ); // Check current method exist in return values chain $serializedArgs = serialize($args); if ( ! isset($rReturnValues[$currentMethodName][$serializedArgs]['response'])) { $serializedArgs = static::checkMatchingArguments( $rReturnValues[$currentMethodName], $args ); if (is_null($serializedArgs)) { return null; } } return self::generateResponse( $rReturnValues[$currentMethodName][$serializedArgs]['response'], $args ); }
php
protected static function _createChainResponse( $mockClassInstanceId, $mockClassType, $chainedMethodsBefore, $currentMethod, $args ) { $currentMethodName = key($currentMethod); $rReturnValues = &self::getMockHierarchyResponse( $chainedMethodsBefore, $mockClassType, $mockClassInstanceId ); // Check current method exist in return values chain $serializedArgs = serialize($args); if ( ! isset($rReturnValues[$currentMethodName][$serializedArgs]['response'])) { $serializedArgs = static::checkMatchingArguments( $rReturnValues[$currentMethodName], $args ); if (is_null($serializedArgs)) { return null; } } return self::generateResponse( $rReturnValues[$currentMethodName][$serializedArgs]['response'], $args ); }
[ "protected", "static", "function", "_createChainResponse", "(", "$", "mockClassInstanceId", ",", "$", "mockClassType", ",", "$", "chainedMethodsBefore", ",", "$", "currentMethod", ",", "$", "args", ")", "{", "$", "currentMethodName", "=", "key", "(", "$", "currentMethod", ")", ";", "$", "rReturnValues", "=", "&", "self", "::", "getMockHierarchyResponse", "(", "$", "chainedMethodsBefore", ",", "$", "mockClassType", ",", "$", "mockClassInstanceId", ")", ";", "// Check current method exist in return values chain", "$", "serializedArgs", "=", "serialize", "(", "$", "args", ")", ";", "if", "(", "!", "isset", "(", "$", "rReturnValues", "[", "$", "currentMethodName", "]", "[", "$", "serializedArgs", "]", "[", "'response'", "]", ")", ")", "{", "$", "serializedArgs", "=", "static", "::", "checkMatchingArguments", "(", "$", "rReturnValues", "[", "$", "currentMethodName", "]", ",", "$", "args", ")", ";", "if", "(", "is_null", "(", "$", "serializedArgs", ")", ")", "{", "return", "null", ";", "}", "}", "return", "self", "::", "generateResponse", "(", "$", "rReturnValues", "[", "$", "currentMethodName", "]", "[", "$", "serializedArgs", "]", "[", "'response'", "]", ",", "$", "args", ")", ";", "}" ]
Setting up a chained mock response, function is called from mocked classes @param $mockClassInstanceId @param $mockClassType @param $chainedMethodsBefore @param $currentMethod @param $args @return null
[ "Setting", "up", "a", "chained", "mock", "response", "function", "is", "called", "from", "mocked", "classes" ]
cedd08f31de8e7409a07d2630701ef4e924cc5f0
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/ShortifyPunit.php#L249-L283
16,834
danrevah/shortify-punit
src/ShortifyPunit.php
ShortifyPunit._setWhenMockResponse
protected static function _setWhenMockResponse( $className, $instanceId, $methodName, $args, $action, $returns ) { $args = serialize($args); $returnValues = array(); $returnValues[$className][$instanceId][$methodName][$args]['response'] = ['action' => $action, 'value' => $returns]; self::_addChainedResponse($returnValues); }
php
protected static function _setWhenMockResponse( $className, $instanceId, $methodName, $args, $action, $returns ) { $args = serialize($args); $returnValues = array(); $returnValues[$className][$instanceId][$methodName][$args]['response'] = ['action' => $action, 'value' => $returns]; self::_addChainedResponse($returnValues); }
[ "protected", "static", "function", "_setWhenMockResponse", "(", "$", "className", ",", "$", "instanceId", ",", "$", "methodName", ",", "$", "args", ",", "$", "action", ",", "$", "returns", ")", "{", "$", "args", "=", "serialize", "(", "$", "args", ")", ";", "$", "returnValues", "=", "array", "(", ")", ";", "$", "returnValues", "[", "$", "className", "]", "[", "$", "instanceId", "]", "[", "$", "methodName", "]", "[", "$", "args", "]", "[", "'response'", "]", "=", "[", "'action'", "=>", "$", "action", ",", "'value'", "=>", "$", "returns", "]", ";", "self", "::", "_addChainedResponse", "(", "$", "returnValues", ")", ";", "}" ]
Setting up a mock response, function is called from mocked classes @param $className @param $instanceId @param $methodName @param $args @param $action @param $returns
[ "Setting", "up", "a", "mock", "response", "function", "is", "called", "from", "mocked", "classes" ]
cedd08f31de8e7409a07d2630701ef4e924cc5f0
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/ShortifyPunit.php#L297-L311
16,835
danrevah/shortify-punit
src/ShortifyPunit.php
ShortifyPunit._addChainedResponse
protected static function _addChainedResponse($response) { $firstChainedMethodName = key($response); if (isset(self::$returnValues[$firstChainedMethodName])) { self::$returnValues[$firstChainedMethodName] = array_replace_recursive( self::$returnValues[$firstChainedMethodName], $response[$firstChainedMethodName] ); } else { self::$returnValues[$firstChainedMethodName] = $response[$firstChainedMethodName]; } }
php
protected static function _addChainedResponse($response) { $firstChainedMethodName = key($response); if (isset(self::$returnValues[$firstChainedMethodName])) { self::$returnValues[$firstChainedMethodName] = array_replace_recursive( self::$returnValues[$firstChainedMethodName], $response[$firstChainedMethodName] ); } else { self::$returnValues[$firstChainedMethodName] = $response[$firstChainedMethodName]; } }
[ "protected", "static", "function", "_addChainedResponse", "(", "$", "response", ")", "{", "$", "firstChainedMethodName", "=", "key", "(", "$", "response", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "returnValues", "[", "$", "firstChainedMethodName", "]", ")", ")", "{", "self", "::", "$", "returnValues", "[", "$", "firstChainedMethodName", "]", "=", "array_replace_recursive", "(", "self", "::", "$", "returnValues", "[", "$", "firstChainedMethodName", "]", ",", "$", "response", "[", "$", "firstChainedMethodName", "]", ")", ";", "}", "else", "{", "self", "::", "$", "returnValues", "[", "$", "firstChainedMethodName", "]", "=", "$", "response", "[", "$", "firstChainedMethodName", "]", ";", "}", "}" ]
Adding chained response to ReturnValues array @param $response
[ "Adding", "chained", "response", "to", "ReturnValues", "array" ]
cedd08f31de8e7409a07d2630701ef4e924cc5f0
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/ShortifyPunit.php#L358-L370
16,836
danrevah/shortify-punit
src/ShortifyPunit.php
ShortifyPunit.&
private static function &getMockHierarchyResponse( $chainedMethodsBefore, $mockClassType, $mockClassInstanceId ) { $rReturnValues = &self::$returnValues[$mockClassType][$mockClassInstanceId]; // Check return values chain foreach ($chainedMethodsBefore as $chainedMethod) { $chainedMethodName = key($chainedMethod); $chainedMethodArgs = $chainedMethod[$chainedMethodName]; $serializedChainMethodArgs = serialize($chainedMethodArgs); $rReturnValues = & $rReturnValues[$chainedMethodName][$serializedChainMethodArgs]; } return $rReturnValues; }
php
private static function &getMockHierarchyResponse( $chainedMethodsBefore, $mockClassType, $mockClassInstanceId ) { $rReturnValues = &self::$returnValues[$mockClassType][$mockClassInstanceId]; // Check return values chain foreach ($chainedMethodsBefore as $chainedMethod) { $chainedMethodName = key($chainedMethod); $chainedMethodArgs = $chainedMethod[$chainedMethodName]; $serializedChainMethodArgs = serialize($chainedMethodArgs); $rReturnValues = & $rReturnValues[$chainedMethodName][$serializedChainMethodArgs]; } return $rReturnValues; }
[ "private", "static", "function", "&", "getMockHierarchyResponse", "(", "$", "chainedMethodsBefore", ",", "$", "mockClassType", ",", "$", "mockClassInstanceId", ")", "{", "$", "rReturnValues", "=", "&", "self", "::", "$", "returnValues", "[", "$", "mockClassType", "]", "[", "$", "mockClassInstanceId", "]", ";", "// Check return values chain", "foreach", "(", "$", "chainedMethodsBefore", "as", "$", "chainedMethod", ")", "{", "$", "chainedMethodName", "=", "key", "(", "$", "chainedMethod", ")", ";", "$", "chainedMethodArgs", "=", "$", "chainedMethod", "[", "$", "chainedMethodName", "]", ";", "$", "serializedChainMethodArgs", "=", "serialize", "(", "$", "chainedMethodArgs", ")", ";", "$", "rReturnValues", "=", "&", "$", "rReturnValues", "[", "$", "chainedMethodName", "]", "[", "$", "serializedChainMethodArgs", "]", ";", "}", "return", "$", "rReturnValues", ";", "}" ]
Returns the mock hierarchy response values @param $chainedMethodsBefore @param $mockClassType @param $mockClassInstanceId @return mixed
[ "Returns", "the", "mock", "hierarchy", "response", "values" ]
cedd08f31de8e7409a07d2630701ef4e924cc5f0
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/ShortifyPunit.php#L398-L414
16,837
necrox87/yii2-nudity-detector
NudityDetector.php
NudityDetector.quantifyYCbCr
public function quantifyYCbCr() { // Init some vars $inc = $this->iteratorIncrement; $width = $this->width(); $height = $this->height(); list($Cb1, $Cb2, $Cr1, $Cr2) = $this->boundsCbCr; $white = $this->excludeWhite; $black = $this->excludeBlack; $total = $count = 0; for($x = 0; $x < $width; $x += $inc) for($y = 0; $y < $height; $y += $inc) { list($r, $g, $b) = $this->rgbXY($x, $y); // Exclude white/black colors from calculation, presumably background if((($r > $white) && ($g > $white) && ($b > $white)) || (($r < $black) && ($g < $black) && ($b < $black))) continue; // Converg pixel RGB color to YCbCr, coefficients already divided by 255 $Cb = 128 + (-0.1482 * $r) + (-0.291 * $g) + (0.4392 * $b); $Cr = 128 + (0.4392 * $r) + (-0.3678 * $g) + (-0.0714 * $b); // Increase counter, if necessary if(($Cb >= $Cb1) && ($Cb <= $Cb2) && ($Cr >= $Cr1) && ($Cr <= $Cr2)) $count++; $total++; } return $count / $total; }
php
public function quantifyYCbCr() { // Init some vars $inc = $this->iteratorIncrement; $width = $this->width(); $height = $this->height(); list($Cb1, $Cb2, $Cr1, $Cr2) = $this->boundsCbCr; $white = $this->excludeWhite; $black = $this->excludeBlack; $total = $count = 0; for($x = 0; $x < $width; $x += $inc) for($y = 0; $y < $height; $y += $inc) { list($r, $g, $b) = $this->rgbXY($x, $y); // Exclude white/black colors from calculation, presumably background if((($r > $white) && ($g > $white) && ($b > $white)) || (($r < $black) && ($g < $black) && ($b < $black))) continue; // Converg pixel RGB color to YCbCr, coefficients already divided by 255 $Cb = 128 + (-0.1482 * $r) + (-0.291 * $g) + (0.4392 * $b); $Cr = 128 + (0.4392 * $r) + (-0.3678 * $g) + (-0.0714 * $b); // Increase counter, if necessary if(($Cb >= $Cb1) && ($Cb <= $Cb2) && ($Cr >= $Cr1) && ($Cr <= $Cr2)) $count++; $total++; } return $count / $total; }
[ "public", "function", "quantifyYCbCr", "(", ")", "{", "// Init some vars", "$", "inc", "=", "$", "this", "->", "iteratorIncrement", ";", "$", "width", "=", "$", "this", "->", "width", "(", ")", ";", "$", "height", "=", "$", "this", "->", "height", "(", ")", ";", "list", "(", "$", "Cb1", ",", "$", "Cb2", ",", "$", "Cr1", ",", "$", "Cr2", ")", "=", "$", "this", "->", "boundsCbCr", ";", "$", "white", "=", "$", "this", "->", "excludeWhite", ";", "$", "black", "=", "$", "this", "->", "excludeBlack", ";", "$", "total", "=", "$", "count", "=", "0", ";", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "$", "width", ";", "$", "x", "+=", "$", "inc", ")", "for", "(", "$", "y", "=", "0", ";", "$", "y", "<", "$", "height", ";", "$", "y", "+=", "$", "inc", ")", "{", "list", "(", "$", "r", ",", "$", "g", ",", "$", "b", ")", "=", "$", "this", "->", "rgbXY", "(", "$", "x", ",", "$", "y", ")", ";", "// Exclude white/black colors from calculation, presumably background", "if", "(", "(", "(", "$", "r", ">", "$", "white", ")", "&&", "(", "$", "g", ">", "$", "white", ")", "&&", "(", "$", "b", ">", "$", "white", ")", ")", "||", "(", "(", "$", "r", "<", "$", "black", ")", "&&", "(", "$", "g", "<", "$", "black", ")", "&&", "(", "$", "b", "<", "$", "black", ")", ")", ")", "continue", ";", "// Converg pixel RGB color to YCbCr, coefficients already divided by 255", "$", "Cb", "=", "128", "+", "(", "-", "0.1482", "*", "$", "r", ")", "+", "(", "-", "0.291", "*", "$", "g", ")", "+", "(", "0.4392", "*", "$", "b", ")", ";", "$", "Cr", "=", "128", "+", "(", "0.4392", "*", "$", "r", ")", "+", "(", "-", "0.3678", "*", "$", "g", ")", "+", "(", "-", "0.0714", "*", "$", "b", ")", ";", "// Increase counter, if necessary", "if", "(", "(", "$", "Cb", ">=", "$", "Cb1", ")", "&&", "(", "$", "Cb", "<=", "$", "Cb2", ")", "&&", "(", "$", "Cr", ">=", "$", "Cr1", ")", "&&", "(", "$", "Cr", "<=", "$", "Cr2", ")", ")", "$", "count", "++", ";", "$", "total", "++", ";", "}", "return", "$", "count", "/", "$", "total", ";", "}" ]
Quantify flesh color amount using YCbCr color model @return float
[ "Quantify", "flesh", "color", "amount", "using", "YCbCr", "color", "model" ]
59474b1480f5ed53a17f06551318d30c3765d143
https://github.com/necrox87/yii2-nudity-detector/blob/59474b1480f5ed53a17f06551318d30c3765d143/NudityDetector.php#L57-L87
16,838
necrox87/yii2-nudity-detector
NudityDetector.php
NudityDetector.isPorn
public function isPorn($threshold = FALSE) { return $threshold === FALSE ? $this->quantifyYCbCr() >= $this->threshold : $this->quantifyYCbCr() >= $threshold; }
php
public function isPorn($threshold = FALSE) { return $threshold === FALSE ? $this->quantifyYCbCr() >= $this->threshold : $this->quantifyYCbCr() >= $threshold; }
[ "public", "function", "isPorn", "(", "$", "threshold", "=", "FALSE", ")", "{", "return", "$", "threshold", "===", "FALSE", "?", "$", "this", "->", "quantifyYCbCr", "(", ")", ">=", "$", "this", "->", "threshold", ":", "$", "this", "->", "quantifyYCbCr", "(", ")", ">=", "$", "threshold", ";", "}" ]
Check if image is of pornographic content @param float $threshold
[ "Check", "if", "image", "is", "of", "pornographic", "content" ]
59474b1480f5ed53a17f06551318d30c3765d143
https://github.com/necrox87/yii2-nudity-detector/blob/59474b1480f5ed53a17f06551318d30c3765d143/NudityDetector.php#L94-L98
16,839
nyeholt/silverstripe-external-content
code/model/ExternalContentItem.php
ExternalContentItem.Link
function Link($action = null) { $cur = Controller::curr(); if ($cur instanceof ExternalContentPage_Controller) { return $cur->data()->LinkFor($this, 'view'); } return ExternalContentPage_Controller::URL_STUB . '/view/' . $this->ID; }
php
function Link($action = null) { $cur = Controller::curr(); if ($cur instanceof ExternalContentPage_Controller) { return $cur->data()->LinkFor($this, 'view'); } return ExternalContentPage_Controller::URL_STUB . '/view/' . $this->ID; }
[ "function", "Link", "(", "$", "action", "=", "null", ")", "{", "$", "cur", "=", "Controller", "::", "curr", "(", ")", ";", "if", "(", "$", "cur", "instanceof", "ExternalContentPage_Controller", ")", "{", "return", "$", "cur", "->", "data", "(", ")", "->", "LinkFor", "(", "$", "this", ",", "'view'", ")", ";", "}", "return", "ExternalContentPage_Controller", "::", "URL_STUB", ".", "'/view/'", ".", "$", "this", "->", "ID", ";", "}" ]
Return a URL that simply links back to the externalcontentadmin class' 'view' action @param $action @return String
[ "Return", "a", "URL", "that", "simply", "links", "back", "to", "the", "externalcontentadmin", "class", "view", "action" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContentItem.php#L141-L147
16,840
nyeholt/silverstripe-external-content
code/model/ExternalContentItem.php
ExternalContentItem.DownloadLink
public function DownloadLink() { // get the base URL, prepend with the external content // controller /download action and add this object's id $cur = Controller::curr(); if ($cur instanceof ExternalContentPage_Controller) { return $cur->data()->LinkFor($this, 'download'); } return ExternalContentPage_Controller::URL_STUB . '/download/' . $this->ID; }
php
public function DownloadLink() { // get the base URL, prepend with the external content // controller /download action and add this object's id $cur = Controller::curr(); if ($cur instanceof ExternalContentPage_Controller) { return $cur->data()->LinkFor($this, 'download'); } return ExternalContentPage_Controller::URL_STUB . '/download/' . $this->ID; }
[ "public", "function", "DownloadLink", "(", ")", "{", "// get the base URL, prepend with the external content", "// controller /download action and add this object's id", "$", "cur", "=", "Controller", "::", "curr", "(", ")", ";", "if", "(", "$", "cur", "instanceof", "ExternalContentPage_Controller", ")", "{", "return", "$", "cur", "->", "data", "(", ")", "->", "LinkFor", "(", "$", "this", ",", "'download'", ")", ";", "}", "return", "ExternalContentPage_Controller", "::", "URL_STUB", ".", "'/download/'", ".", "$", "this", "->", "ID", ";", "}" ]
Where this can be downloaded from @return string
[ "Where", "this", "can", "be", "downloaded", "from" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContentItem.php#L169-L177
16,841
nyeholt/silverstripe-external-content
code/model/ExternalContentItem.php
ExternalContentItem.stageChildren
public function stageChildren($showAll = false) { if ($this->Title != 'Content Root' && $this->source) { $children = new ArrayList(); $item = new ExternalContentItem($this->source, $this->Title . '1'); $item->Title = $this->Title . '1'; $item->MenuTitle = $item->Title; $children->push($item); return $children; } }
php
public function stageChildren($showAll = false) { if ($this->Title != 'Content Root' && $this->source) { $children = new ArrayList(); $item = new ExternalContentItem($this->source, $this->Title . '1'); $item->Title = $this->Title . '1'; $item->MenuTitle = $item->Title; $children->push($item); return $children; } }
[ "public", "function", "stageChildren", "(", "$", "showAll", "=", "false", ")", "{", "if", "(", "$", "this", "->", "Title", "!=", "'Content Root'", "&&", "$", "this", "->", "source", ")", "{", "$", "children", "=", "new", "ArrayList", "(", ")", ";", "$", "item", "=", "new", "ExternalContentItem", "(", "$", "this", "->", "source", ",", "$", "this", "->", "Title", ".", "'1'", ")", ";", "$", "item", "->", "Title", "=", "$", "this", "->", "Title", ".", "'1'", ";", "$", "item", "->", "MenuTitle", "=", "$", "item", "->", "Title", ";", "$", "children", "->", "push", "(", "$", "item", ")", ";", "return", "$", "children", ";", "}", "}" ]
Overridden to load all children from a remote content source instead of this node directly @param boolean $showAll @return ArrayList
[ "Overridden", "to", "load", "all", "children", "from", "a", "remote", "content", "source", "instead", "of", "this", "node", "directly" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContentItem.php#L230-L240
16,842
nyeholt/silverstripe-external-content
code/model/ExternalContentItem.php
ExternalContentItem.Children
public function Children() { if (!$this->children) { $this->children = new ArrayList(); $kids = $this->stageChildren(); if ($kids) { foreach ($kids as $child) { if ($child->canView()) { $this->children->push($child); } } } } return $this->children; }
php
public function Children() { if (!$this->children) { $this->children = new ArrayList(); $kids = $this->stageChildren(); if ($kids) { foreach ($kids as $child) { if ($child->canView()) { $this->children->push($child); } } } } return $this->children; }
[ "public", "function", "Children", "(", ")", "{", "if", "(", "!", "$", "this", "->", "children", ")", "{", "$", "this", "->", "children", "=", "new", "ArrayList", "(", ")", ";", "$", "kids", "=", "$", "this", "->", "stageChildren", "(", ")", ";", "if", "(", "$", "kids", ")", "{", "foreach", "(", "$", "kids", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "canView", "(", ")", ")", "{", "$", "this", "->", "children", "->", "push", "(", "$", "child", ")", ";", "}", "}", "}", "}", "return", "$", "this", "->", "children", ";", "}" ]
Handle a children call by retrieving from stageChildren
[ "Handle", "a", "children", "call", "by", "retrieving", "from", "stageChildren" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContentItem.php#L245-L258
16,843
nyeholt/silverstripe-external-content
code/model/ExternalContentItem.php
ExternalContentItem.getCMSFields
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ParentID'); if (count($this->remoteProperties)) { $mapping = $this->editableFieldMapping(); foreach ($this->remoteProperties as $name => $value) { $field = null; if (isset($mapping[$name])) { $field = $mapping[$name]; if (is_string($field)) { $field = new $field($name, $this->fieldLabel($name), $value); $fields->addFieldToTab('Root.Main', $field); } } else if(!is_object($value) && !is_array($value)){ $value = (string) $value; $field = new ReadonlyField($name, _t('ExternalContentItem.' . $name, $name), $value); $fields->addFieldToTab('Root.Main', $field); } else if(is_object($value) || is_array($value)){ foreach($value as $childName => $childValue) { if(is_object($childValue)) { foreach($childValue as $childChildName => $childChildValue) { $childChildValue = is_object($childChildValue) || is_array($childChildValue) ? json_encode($childChildValue) : (string) $childChildValue; $field = new ReadonlyField("{$childName}{$childChildName}", "{$childName}: {$childChildName}", $childChildValue); $fields->addFieldToTab('Root.Main', $field); } } else { $childValue = is_object($childValue) || is_array($childValue) ? json_encode($childValue) : (string) $childValue; $field = new ReadonlyField("{$childName}{$childValue}", $name . ':' . $childName, $childValue); $fields->addFieldToTab('Root.Main', $field); } } } } } return $fields; }
php
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ParentID'); if (count($this->remoteProperties)) { $mapping = $this->editableFieldMapping(); foreach ($this->remoteProperties as $name => $value) { $field = null; if (isset($mapping[$name])) { $field = $mapping[$name]; if (is_string($field)) { $field = new $field($name, $this->fieldLabel($name), $value); $fields->addFieldToTab('Root.Main', $field); } } else if(!is_object($value) && !is_array($value)){ $value = (string) $value; $field = new ReadonlyField($name, _t('ExternalContentItem.' . $name, $name), $value); $fields->addFieldToTab('Root.Main', $field); } else if(is_object($value) || is_array($value)){ foreach($value as $childName => $childValue) { if(is_object($childValue)) { foreach($childValue as $childChildName => $childChildValue) { $childChildValue = is_object($childChildValue) || is_array($childChildValue) ? json_encode($childChildValue) : (string) $childChildValue; $field = new ReadonlyField("{$childName}{$childChildName}", "{$childName}: {$childChildName}", $childChildValue); $fields->addFieldToTab('Root.Main', $field); } } else { $childValue = is_object($childValue) || is_array($childValue) ? json_encode($childValue) : (string) $childValue; $field = new ReadonlyField("{$childName}{$childValue}", $name . ':' . $childName, $childValue); $fields->addFieldToTab('Root.Main', $field); } } } } } return $fields; }
[ "public", "function", "getCMSFields", "(", ")", "{", "$", "fields", "=", "parent", "::", "getCMSFields", "(", ")", ";", "$", "fields", "->", "removeByName", "(", "'ParentID'", ")", ";", "if", "(", "count", "(", "$", "this", "->", "remoteProperties", ")", ")", "{", "$", "mapping", "=", "$", "this", "->", "editableFieldMapping", "(", ")", ";", "foreach", "(", "$", "this", "->", "remoteProperties", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "field", "=", "null", ";", "if", "(", "isset", "(", "$", "mapping", "[", "$", "name", "]", ")", ")", "{", "$", "field", "=", "$", "mapping", "[", "$", "name", "]", ";", "if", "(", "is_string", "(", "$", "field", ")", ")", "{", "$", "field", "=", "new", "$", "field", "(", "$", "name", ",", "$", "this", "->", "fieldLabel", "(", "$", "name", ")", ",", "$", "value", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Main'", ",", "$", "field", ")", ";", "}", "}", "else", "if", "(", "!", "is_object", "(", "$", "value", ")", "&&", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "(", "string", ")", "$", "value", ";", "$", "field", "=", "new", "ReadonlyField", "(", "$", "name", ",", "_t", "(", "'ExternalContentItem.'", ".", "$", "name", ",", "$", "name", ")", ",", "$", "value", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Main'", ",", "$", "field", ")", ";", "}", "else", "if", "(", "is_object", "(", "$", "value", ")", "||", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "childName", "=>", "$", "childValue", ")", "{", "if", "(", "is_object", "(", "$", "childValue", ")", ")", "{", "foreach", "(", "$", "childValue", "as", "$", "childChildName", "=>", "$", "childChildValue", ")", "{", "$", "childChildValue", "=", "is_object", "(", "$", "childChildValue", ")", "||", "is_array", "(", "$", "childChildValue", ")", "?", "json_encode", "(", "$", "childChildValue", ")", ":", "(", "string", ")", "$", "childChildValue", ";", "$", "field", "=", "new", "ReadonlyField", "(", "\"{$childName}{$childChildName}\"", ",", "\"{$childName}: {$childChildName}\"", ",", "$", "childChildValue", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Main'", ",", "$", "field", ")", ";", "}", "}", "else", "{", "$", "childValue", "=", "is_object", "(", "$", "childValue", ")", "||", "is_array", "(", "$", "childValue", ")", "?", "json_encode", "(", "$", "childValue", ")", ":", "(", "string", ")", "$", "childValue", ";", "$", "field", "=", "new", "ReadonlyField", "(", "\"{$childName}{$childValue}\"", ",", "$", "name", ".", "':'", ".", "$", "childName", ",", "$", "childValue", ")", ";", "$", "fields", "->", "addFieldToTab", "(", "'Root.Main'", ",", "$", "field", ")", ";", "}", "}", "}", "}", "}", "return", "$", "fields", ";", "}" ]
For now just show a field that says this can't be edited @see sapphire/core/model/DataObject#getCMSFields($params)
[ "For", "now", "just", "show", "a", "field", "that", "says", "this", "can", "t", "be", "edited" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContentItem.php#L265-L303
16,844
Double-Opt-in/php-client-api
src/Config/ConfigFactory.php
ConfigFactory.fromArray
public static function fromArray(array $data) { if ( ! array_key_exists('client_id', $data)) throw new ClientConfigurationException('Configuration file has no client_id set'); if ( ! array_key_exists('client_secret', $data)) throw new ClientConfigurationException('Configuration file has no client_secret set'); if ( ! array_key_exists('site_token', $data)) throw new ClientConfigurationException('Configuration file has no site_token set'); $baseUrl = ( ! array_key_exists('api', $data)) ? null : $data['api']; $httpClientConfig = ( ! array_key_exists('http_client', $data)) ? array() : $data['http_client']; $clientConfig = new ClientConfig($data['client_id'], $data['client_secret'], $data['site_token'], $baseUrl, $httpClientConfig); if (array_key_exists('cache_file', $data)) $clientConfig->setAccessTokenCacheFile($data['cache_file']); return $clientConfig; }
php
public static function fromArray(array $data) { if ( ! array_key_exists('client_id', $data)) throw new ClientConfigurationException('Configuration file has no client_id set'); if ( ! array_key_exists('client_secret', $data)) throw new ClientConfigurationException('Configuration file has no client_secret set'); if ( ! array_key_exists('site_token', $data)) throw new ClientConfigurationException('Configuration file has no site_token set'); $baseUrl = ( ! array_key_exists('api', $data)) ? null : $data['api']; $httpClientConfig = ( ! array_key_exists('http_client', $data)) ? array() : $data['http_client']; $clientConfig = new ClientConfig($data['client_id'], $data['client_secret'], $data['site_token'], $baseUrl, $httpClientConfig); if (array_key_exists('cache_file', $data)) $clientConfig->setAccessTokenCacheFile($data['cache_file']); return $clientConfig; }
[ "public", "static", "function", "fromArray", "(", "array", "$", "data", ")", "{", "if", "(", "!", "array_key_exists", "(", "'client_id'", ",", "$", "data", ")", ")", "throw", "new", "ClientConfigurationException", "(", "'Configuration file has no client_id set'", ")", ";", "if", "(", "!", "array_key_exists", "(", "'client_secret'", ",", "$", "data", ")", ")", "throw", "new", "ClientConfigurationException", "(", "'Configuration file has no client_secret set'", ")", ";", "if", "(", "!", "array_key_exists", "(", "'site_token'", ",", "$", "data", ")", ")", "throw", "new", "ClientConfigurationException", "(", "'Configuration file has no site_token set'", ")", ";", "$", "baseUrl", "=", "(", "!", "array_key_exists", "(", "'api'", ",", "$", "data", ")", ")", "?", "null", ":", "$", "data", "[", "'api'", "]", ";", "$", "httpClientConfig", "=", "(", "!", "array_key_exists", "(", "'http_client'", ",", "$", "data", ")", ")", "?", "array", "(", ")", ":", "$", "data", "[", "'http_client'", "]", ";", "$", "clientConfig", "=", "new", "ClientConfig", "(", "$", "data", "[", "'client_id'", "]", ",", "$", "data", "[", "'client_secret'", "]", ",", "$", "data", "[", "'site_token'", "]", ",", "$", "baseUrl", ",", "$", "httpClientConfig", ")", ";", "if", "(", "array_key_exists", "(", "'cache_file'", ",", "$", "data", ")", ")", "$", "clientConfig", "->", "setAccessTokenCacheFile", "(", "$", "data", "[", "'cache_file'", "]", ")", ";", "return", "$", "clientConfig", ";", "}" ]
creates a configuration from array array( 'api' => '', // optional 'client_id' => '...', 'client_secret' => '...', 'site_token' => '', 'cache_file' => '..', ) @param array $data @return ClientConfig @throws ClientConfigurationException
[ "creates", "a", "configuration", "from", "array" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Config/ConfigFactory.php#L30-L53
16,845
Double-Opt-in/php-client-api
src/Config/ConfigFactory.php
ConfigFactory.fromFile
public static function fromFile($filename) { $filename = realpath($filename); if ($filename === false) throw new ClientConfigurationException('Configuration file ' . $filename . ' does not exists'); return static::fromArray(include $filename); }
php
public static function fromFile($filename) { $filename = realpath($filename); if ($filename === false) throw new ClientConfigurationException('Configuration file ' . $filename . ' does not exists'); return static::fromArray(include $filename); }
[ "public", "static", "function", "fromFile", "(", "$", "filename", ")", "{", "$", "filename", "=", "realpath", "(", "$", "filename", ")", ";", "if", "(", "$", "filename", "===", "false", ")", "throw", "new", "ClientConfigurationException", "(", "'Configuration file '", ".", "$", "filename", ".", "' does not exists'", ")", ";", "return", "static", "::", "fromArray", "(", "include", "$", "filename", ")", ";", "}" ]
creates a configuration from a php file returning an array @param string $filename @return ClientConfig @throws ClientConfigurationException
[ "creates", "a", "configuration", "from", "a", "php", "file", "returning", "an", "array" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Config/ConfigFactory.php#L63-L70
16,846
aedart/laravel-helpers
src/Traits/Database/SchemaTrait.php
SchemaTrait.getDefaultSchema
public function getDefaultSchema(): ?Builder { // By default, the schema facade depends upon a // database connection being available. Therefore, // we need to ensure that this is true, before // attempting to return the facade-root $manager = DB::getFacadeRoot(); if (isset($manager) && ! is_null($manager->connection())) { return Schema::getFacadeRoot(); } return $manager; }
php
public function getDefaultSchema(): ?Builder { // By default, the schema facade depends upon a // database connection being available. Therefore, // we need to ensure that this is true, before // attempting to return the facade-root $manager = DB::getFacadeRoot(); if (isset($manager) && ! is_null($manager->connection())) { return Schema::getFacadeRoot(); } return $manager; }
[ "public", "function", "getDefaultSchema", "(", ")", ":", "?", "Builder", "{", "// By default, the schema facade depends upon a", "// database connection being available. Therefore,", "// we need to ensure that this is true, before", "// attempting to return the facade-root", "$", "manager", "=", "DB", "::", "getFacadeRoot", "(", ")", ";", "if", "(", "isset", "(", "$", "manager", ")", "&&", "!", "is_null", "(", "$", "manager", "->", "connection", "(", ")", ")", ")", "{", "return", "Schema", "::", "getFacadeRoot", "(", ")", ";", "}", "return", "$", "manager", ";", "}" ]
Get a default schema value, if any is available @return Builder|null A default schema value or Null if no default value is available
[ "Get", "a", "default", "schema", "value", "if", "any", "is", "available" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Database/SchemaTrait.php#L77-L88
16,847
phrest/sdk
src/Request/RequestOptions.php
RequestOptions.addGetParam
public function addGetParam($param, $value = true) { // Validate if (!is_scalar($param)) { throw new \Exception("Param name must be scalar"); } // Filter if (is_string($value)) { $value = trim($value); } // Set $this->queryParams[trim($param)] = $value; return $this; }
php
public function addGetParam($param, $value = true) { // Validate if (!is_scalar($param)) { throw new \Exception("Param name must be scalar"); } // Filter if (is_string($value)) { $value = trim($value); } // Set $this->queryParams[trim($param)] = $value; return $this; }
[ "public", "function", "addGetParam", "(", "$", "param", ",", "$", "value", "=", "true", ")", "{", "// Validate", "if", "(", "!", "is_scalar", "(", "$", "param", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Param name must be scalar\"", ")", ";", "}", "// Filter", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "}", "// Set", "$", "this", "->", "queryParams", "[", "trim", "(", "$", "param", ")", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Add a GET parameter @param $param @param mixed $value @return $this @throws \Exception
[ "Add", "a", "GET", "parameter" ]
e9f2812ad517b07ca4d284512b530f615305eb47
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Request/RequestOptions.php#L70-L88
16,848
phrest/sdk
src/Request/RequestOptions.php
RequestOptions.addPostParam
public function addPostParam($param, $value = true) { // Validate if (!is_scalar($param)) { throw new \Exception("Param name must be scalar"); } // Filter if (is_string($value)) { $value = trim($value); } // Set $this->postParams[trim($param)] = $value; return $this; }
php
public function addPostParam($param, $value = true) { // Validate if (!is_scalar($param)) { throw new \Exception("Param name must be scalar"); } // Filter if (is_string($value)) { $value = trim($value); } // Set $this->postParams[trim($param)] = $value; return $this; }
[ "public", "function", "addPostParam", "(", "$", "param", ",", "$", "value", "=", "true", ")", "{", "// Validate", "if", "(", "!", "is_scalar", "(", "$", "param", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Param name must be scalar\"", ")", ";", "}", "// Filter", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "}", "// Set", "$", "this", "->", "postParams", "[", "trim", "(", "$", "param", ")", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Add a POST parameter @param $param @param bool $value @return $this @throws \Exception
[ "Add", "a", "POST", "parameter" ]
e9f2812ad517b07ca4d284512b530f615305eb47
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Request/RequestOptions.php#L99-L117
16,849
phrest/sdk
src/Request/RequestOptions.php
RequestOptions.setSearchTerm
public function setSearchTerm($searchTerm) { if (!is_scalar($searchTerm)) { throw new \Exception("Search term must be a string"); } $this->searchTerm = trim($searchTerm); return $this; }
php
public function setSearchTerm($searchTerm) { if (!is_scalar($searchTerm)) { throw new \Exception("Search term must be a string"); } $this->searchTerm = trim($searchTerm); return $this; }
[ "public", "function", "setSearchTerm", "(", "$", "searchTerm", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "searchTerm", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Search term must be a string\"", ")", ";", "}", "$", "this", "->", "searchTerm", "=", "trim", "(", "$", "searchTerm", ")", ";", "return", "$", "this", ";", "}" ]
Set a search term for the request @param $searchTerm @return $this @throws \Exception
[ "Set", "a", "search", "term", "for", "the", "request" ]
e9f2812ad517b07ca4d284512b530f615305eb47
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Request/RequestOptions.php#L137-L147
16,850
phrest/sdk
src/Request/RequestOptions.php
RequestOptions.getGetParams
public function getGetParams() { if (isset($this->searchTerm)) { $this->queryParams['q'] = $this->searchTerm; } return $this->queryParams; }
php
public function getGetParams() { if (isset($this->searchTerm)) { $this->queryParams['q'] = $this->searchTerm; } return $this->queryParams; }
[ "public", "function", "getGetParams", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "searchTerm", ")", ")", "{", "$", "this", "->", "queryParams", "[", "'q'", "]", "=", "$", "this", "->", "searchTerm", ";", "}", "return", "$", "this", "->", "queryParams", ";", "}" ]
Get the request GET params @return array
[ "Get", "the", "request", "GET", "params" ]
e9f2812ad517b07ca4d284512b530f615305eb47
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Request/RequestOptions.php#L166-L174
16,851
phrest/sdk
src/Request/RequestOptions.php
RequestOptions.toArray
public function toArray() { $params = []; if (isset($this->searchTerm)) { $params['q'] = $this->searchTerm; } if (isset($this->parameters)) { foreach ($this->parameters as $paramKey => $paramVal) { $params[$paramKey] = $paramVal; } } return $params; }
php
public function toArray() { $params = []; if (isset($this->searchTerm)) { $params['q'] = $this->searchTerm; } if (isset($this->parameters)) { foreach ($this->parameters as $paramKey => $paramVal) { $params[$paramKey] = $paramVal; } } return $params; }
[ "public", "function", "toArray", "(", ")", "{", "$", "params", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "searchTerm", ")", ")", "{", "$", "params", "[", "'q'", "]", "=", "$", "this", "->", "searchTerm", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "parameters", ")", ")", "{", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "paramKey", "=>", "$", "paramVal", ")", "{", "$", "params", "[", "$", "paramKey", "]", "=", "$", "paramVal", ";", "}", "}", "return", "$", "params", ";", "}" ]
This should no longer be needed todo remove @return array @deprecated
[ "This", "should", "no", "longer", "be", "needed", "todo", "remove" ]
e9f2812ad517b07ca4d284512b530f615305eb47
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Request/RequestOptions.php#L193-L211
16,852
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Repositories/File/EloquentFile.php
EloquentFile.bySystemReferenceTypeBySystemReferenceIdAndByOrganization
public function bySystemReferenceTypeBySystemReferenceIdAndByOrganization($systemReferenceType , $systemReferenceId, $organizationId, $databaseConnectionName = null) { if(empty($databaseConnectionName)) { $databaseConnectionName = $this->databaseConnectionName; } return $this->File->setConnection($databaseConnectionName) ->where('system_reference_type', '=', $systemReferenceType) ->where('system_reference_id', '=', $systemReferenceId) ->where('organization_id', '=', $organizationId) ->get(); }
php
public function bySystemReferenceTypeBySystemReferenceIdAndByOrganization($systemReferenceType , $systemReferenceId, $organizationId, $databaseConnectionName = null) { if(empty($databaseConnectionName)) { $databaseConnectionName = $this->databaseConnectionName; } return $this->File->setConnection($databaseConnectionName) ->where('system_reference_type', '=', $systemReferenceType) ->where('system_reference_id', '=', $systemReferenceId) ->where('organization_id', '=', $organizationId) ->get(); }
[ "public", "function", "bySystemReferenceTypeBySystemReferenceIdAndByOrganization", "(", "$", "systemReferenceType", ",", "$", "systemReferenceId", ",", "$", "organizationId", ",", "$", "databaseConnectionName", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "databaseConnectionName", ")", ")", "{", "$", "databaseConnectionName", "=", "$", "this", "->", "databaseConnectionName", ";", "}", "return", "$", "this", "->", "File", "->", "setConnection", "(", "$", "databaseConnectionName", ")", "->", "where", "(", "'system_reference_type'", ",", "'='", ",", "$", "systemReferenceType", ")", "->", "where", "(", "'system_reference_id'", ",", "'='", ",", "$", "systemReferenceId", ")", "->", "where", "(", "'organization_id'", ",", "'='", ",", "$", "organizationId", ")", "->", "get", "(", ")", ";", "}" ]
Retrieve files by system reference type and system reference id @param int $id parent id @return Illuminate\Database\Eloquent\Collection
[ "Retrieve", "files", "by", "system", "reference", "type", "and", "system", "reference", "id" ]
94c26ab40f5c4dd12e913e73376c24db27588f0b
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Repositories/File/EloquentFile.php#L236-L248
16,853
webforge-labs/psc-cms
lib/Psc/UI/Component/JavaScriptBase.php
JavaScriptBase.widgetSelector
protected function widgetSelector(\Psc\HTML\Tag $tag = NULL, $subSelector = NULL) { $jQuery = \Psc\JS\jQuery::getClassSelector($tag ?: $this->html); if (isset($subSelector)) { $jQuery .= sprintf(".find(%s)", \Psc\JS\Helper::convertString($subSelector)); } return $this->jsExpr($jQuery); }
php
protected function widgetSelector(\Psc\HTML\Tag $tag = NULL, $subSelector = NULL) { $jQuery = \Psc\JS\jQuery::getClassSelector($tag ?: $this->html); if (isset($subSelector)) { $jQuery .= sprintf(".find(%s)", \Psc\JS\Helper::convertString($subSelector)); } return $this->jsExpr($jQuery); }
[ "protected", "function", "widgetSelector", "(", "\\", "Psc", "\\", "HTML", "\\", "Tag", "$", "tag", "=", "NULL", ",", "$", "subSelector", "=", "NULL", ")", "{", "$", "jQuery", "=", "\\", "Psc", "\\", "JS", "\\", "jQuery", "::", "getClassSelector", "(", "$", "tag", "?", ":", "$", "this", "->", "html", ")", ";", "if", "(", "isset", "(", "$", "subSelector", ")", ")", "{", "$", "jQuery", ".=", "sprintf", "(", "\".find(%s)\"", ",", "\\", "Psc", "\\", "JS", "\\", "Helper", "::", "convertString", "(", "$", "subSelector", ")", ")", ";", "}", "return", "$", "this", "->", "jsExpr", "(", "$", "jQuery", ")", ";", "}" ]
denn das hier hat nix mit joose zu tun
[ "denn", "das", "hier", "hat", "nix", "mit", "joose", "zu", "tun" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/Component/JavaScriptBase.php#L34-L42
16,854
steeffeen/FancyManiaLinks
FML/Script/ScriptLabel.php
ScriptLabel.getEventLabels
public static function getEventLabels() { return array(self::ENTRYSUBMIT, self::KEYPRESS, self::MOUSECLICK, self::MOUSEOUT, self::MOUSEOVER); }
php
public static function getEventLabels() { return array(self::ENTRYSUBMIT, self::KEYPRESS, self::MOUSECLICK, self::MOUSEOUT, self::MOUSEOVER); }
[ "public", "static", "function", "getEventLabels", "(", ")", "{", "return", "array", "(", "self", "::", "ENTRYSUBMIT", ",", "self", "::", "KEYPRESS", ",", "self", "::", "MOUSECLICK", ",", "self", "::", "MOUSEOUT", ",", "self", "::", "MOUSEOVER", ")", ";", "}" ]
Get the possible event label names @return string[]
[ "Get", "the", "possible", "event", "label", "names" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/ScriptLabel.php#L188-L191
16,855
aedart/laravel-helpers
src/Traits/Database/DBManagerTrait.php
DBManagerTrait.getDbManager
public function getDbManager(): ?DatabaseManager { if (!$this->hasDbManager()) { $this->setDbManager($this->getDefaultDbManager()); } return $this->dbManager; }
php
public function getDbManager(): ?DatabaseManager { if (!$this->hasDbManager()) { $this->setDbManager($this->getDefaultDbManager()); } return $this->dbManager; }
[ "public", "function", "getDbManager", "(", ")", ":", "?", "DatabaseManager", "{", "if", "(", "!", "$", "this", "->", "hasDbManager", "(", ")", ")", "{", "$", "this", "->", "setDbManager", "(", "$", "this", "->", "getDefaultDbManager", "(", ")", ")", ";", "}", "return", "$", "this", "->", "dbManager", ";", "}" ]
Get db manager If no db manager has been set, this method will set and return a default db manager, if any such value is available @see getDefaultDbManager() @return DatabaseManager|null db manager or null if none db manager has been set
[ "Get", "db", "manager" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Database/DBManagerTrait.php#L53-L59
16,856
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php
BaseRemoteApp.initApiLogs
public function initApiLogs($overrideExisting = true) { if (null !== $this->collApiLogs && !$overrideExisting) { return; } $this->collApiLogs = new PropelObjectCollection(); $this->collApiLogs->setModel('ApiLog'); }
php
public function initApiLogs($overrideExisting = true) { if (null !== $this->collApiLogs && !$overrideExisting) { return; } $this->collApiLogs = new PropelObjectCollection(); $this->collApiLogs->setModel('ApiLog'); }
[ "public", "function", "initApiLogs", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collApiLogs", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collApiLogs", "=", "new", "PropelObjectCollection", "(", ")", ";", "$", "this", "->", "collApiLogs", "->", "setModel", "(", "'ApiLog'", ")", ";", "}" ]
Initializes the collApiLogs collection. By default this just sets the collApiLogs collection to an empty array (like clearcollApiLogs()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collApiLogs", "collection", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php#L2450-L2457
16,857
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php
BaseRemoteApp.getApiLogs
public function getApiLogs($criteria = null, PropelPDO $con = null) { $partial = $this->collApiLogsPartial && !$this->isNew(); if (null === $this->collApiLogs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collApiLogs) { // return empty collection $this->initApiLogs(); } else { $collApiLogs = ApiLogQuery::create(null, $criteria) ->filterByRemoteApp($this) ->find($con); if (null !== $criteria) { if (false !== $this->collApiLogsPartial && count($collApiLogs)) { $this->initApiLogs(false); foreach ($collApiLogs as $obj) { if (false == $this->collApiLogs->contains($obj)) { $this->collApiLogs->append($obj); } } $this->collApiLogsPartial = true; } $collApiLogs->getInternalIterator()->rewind(); return $collApiLogs; } if ($partial && $this->collApiLogs) { foreach ($this->collApiLogs as $obj) { if ($obj->isNew()) { $collApiLogs[] = $obj; } } } $this->collApiLogs = $collApiLogs; $this->collApiLogsPartial = false; } } return $this->collApiLogs; }
php
public function getApiLogs($criteria = null, PropelPDO $con = null) { $partial = $this->collApiLogsPartial && !$this->isNew(); if (null === $this->collApiLogs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collApiLogs) { // return empty collection $this->initApiLogs(); } else { $collApiLogs = ApiLogQuery::create(null, $criteria) ->filterByRemoteApp($this) ->find($con); if (null !== $criteria) { if (false !== $this->collApiLogsPartial && count($collApiLogs)) { $this->initApiLogs(false); foreach ($collApiLogs as $obj) { if (false == $this->collApiLogs->contains($obj)) { $this->collApiLogs->append($obj); } } $this->collApiLogsPartial = true; } $collApiLogs->getInternalIterator()->rewind(); return $collApiLogs; } if ($partial && $this->collApiLogs) { foreach ($this->collApiLogs as $obj) { if ($obj->isNew()) { $collApiLogs[] = $obj; } } } $this->collApiLogs = $collApiLogs; $this->collApiLogsPartial = false; } } return $this->collApiLogs; }
[ "public", "function", "getApiLogs", "(", "$", "criteria", "=", "null", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collApiLogsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collApiLogs", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collApiLogs", ")", "{", "// return empty collection", "$", "this", "->", "initApiLogs", "(", ")", ";", "}", "else", "{", "$", "collApiLogs", "=", "ApiLogQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByRemoteApp", "(", "$", "this", ")", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "if", "(", "false", "!==", "$", "this", "->", "collApiLogsPartial", "&&", "count", "(", "$", "collApiLogs", ")", ")", "{", "$", "this", "->", "initApiLogs", "(", "false", ")", ";", "foreach", "(", "$", "collApiLogs", "as", "$", "obj", ")", "{", "if", "(", "false", "==", "$", "this", "->", "collApiLogs", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "this", "->", "collApiLogs", "->", "append", "(", "$", "obj", ")", ";", "}", "}", "$", "this", "->", "collApiLogsPartial", "=", "true", ";", "}", "$", "collApiLogs", "->", "getInternalIterator", "(", ")", "->", "rewind", "(", ")", ";", "return", "$", "collApiLogs", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collApiLogs", ")", "{", "foreach", "(", "$", "this", "->", "collApiLogs", "as", "$", "obj", ")", "{", "if", "(", "$", "obj", "->", "isNew", "(", ")", ")", "{", "$", "collApiLogs", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collApiLogs", "=", "$", "collApiLogs", ";", "$", "this", "->", "collApiLogsPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collApiLogs", ";", "}" ]
Gets an array of ApiLog objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this RemoteApp is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param PropelPDO $con optional connection object @return PropelObjectCollection|ApiLog[] List of ApiLog objects @throws PropelException
[ "Gets", "an", "array", "of", "ApiLog", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php#L2473-L2516
16,858
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php
BaseRemoteApp.countApiLogs
public function countApiLogs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collApiLogsPartial && !$this->isNew(); if (null === $this->collApiLogs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collApiLogs) { return 0; } if ($partial && !$criteria) { return count($this->getApiLogs()); } $query = ApiLogQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByRemoteApp($this) ->count($con); } return count($this->collApiLogs); }
php
public function countApiLogs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collApiLogsPartial && !$this->isNew(); if (null === $this->collApiLogs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collApiLogs) { return 0; } if ($partial && !$criteria) { return count($this->getApiLogs()); } $query = ApiLogQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByRemoteApp($this) ->count($con); } return count($this->collApiLogs); }
[ "public", "function", "countApiLogs", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collApiLogsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collApiLogs", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collApiLogs", ")", "{", "return", "0", ";", "}", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getApiLogs", "(", ")", ")", ";", "}", "$", "query", "=", "ApiLogQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByRemoteApp", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "return", "count", "(", "$", "this", "->", "collApiLogs", ")", ";", "}" ]
Returns the number of related ApiLog objects. @param Criteria $criteria @param boolean $distinct @param PropelPDO $con @return int Count of related ApiLog objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "ApiLog", "objects", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php#L2559-L2581
16,859
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php
BaseRemoteApp.addApiLog
public function addApiLog(ApiLog $l) { if ($this->collApiLogs === null) { $this->initApiLogs(); $this->collApiLogsPartial = true; } if (!in_array($l, $this->collApiLogs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddApiLog($l); if ($this->apiLogsScheduledForDeletion and $this->apiLogsScheduledForDeletion->contains($l)) { $this->apiLogsScheduledForDeletion->remove($this->apiLogsScheduledForDeletion->search($l)); } } return $this; }
php
public function addApiLog(ApiLog $l) { if ($this->collApiLogs === null) { $this->initApiLogs(); $this->collApiLogsPartial = true; } if (!in_array($l, $this->collApiLogs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddApiLog($l); if ($this->apiLogsScheduledForDeletion and $this->apiLogsScheduledForDeletion->contains($l)) { $this->apiLogsScheduledForDeletion->remove($this->apiLogsScheduledForDeletion->search($l)); } } return $this; }
[ "public", "function", "addApiLog", "(", "ApiLog", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collApiLogs", "===", "null", ")", "{", "$", "this", "->", "initApiLogs", "(", ")", ";", "$", "this", "->", "collApiLogsPartial", "=", "true", ";", "}", "if", "(", "!", "in_array", "(", "$", "l", ",", "$", "this", "->", "collApiLogs", "->", "getArrayCopy", "(", ")", ",", "true", ")", ")", "{", "// only add it if the **same** object is not already associated", "$", "this", "->", "doAddApiLog", "(", "$", "l", ")", ";", "if", "(", "$", "this", "->", "apiLogsScheduledForDeletion", "and", "$", "this", "->", "apiLogsScheduledForDeletion", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "apiLogsScheduledForDeletion", "->", "remove", "(", "$", "this", "->", "apiLogsScheduledForDeletion", "->", "search", "(", "$", "l", ")", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Method called to associate a ApiLog object to this object through the ApiLog foreign key attribute. @param ApiLog $l ApiLog @return RemoteApp The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ApiLog", "object", "to", "this", "object", "through", "the", "ApiLog", "foreign", "key", "attribute", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php#L2590-L2606
16,860
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php
BaseRemoteApp.initRemoteHistoryContaos
public function initRemoteHistoryContaos($overrideExisting = true) { if (null !== $this->collRemoteHistoryContaos && !$overrideExisting) { return; } $this->collRemoteHistoryContaos = new PropelObjectCollection(); $this->collRemoteHistoryContaos->setModel('RemoteHistoryContao'); }
php
public function initRemoteHistoryContaos($overrideExisting = true) { if (null !== $this->collRemoteHistoryContaos && !$overrideExisting) { return; } $this->collRemoteHistoryContaos = new PropelObjectCollection(); $this->collRemoteHistoryContaos->setModel('RemoteHistoryContao'); }
[ "public", "function", "initRemoteHistoryContaos", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collRemoteHistoryContaos", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collRemoteHistoryContaos", "=", "new", "PropelObjectCollection", "(", ")", ";", "$", "this", "->", "collRemoteHistoryContaos", "->", "setModel", "(", "'RemoteHistoryContao'", ")", ";", "}" ]
Initializes the collRemoteHistoryContaos collection. By default this just sets the collRemoteHistoryContaos collection to an empty array (like clearcollRemoteHistoryContaos()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collRemoteHistoryContaos", "collection", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php#L2675-L2682
16,861
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php
BaseRemoteApp.getRemoteHistoryContaos
public function getRemoteHistoryContaos($criteria = null, PropelPDO $con = null) { $partial = $this->collRemoteHistoryContaosPartial && !$this->isNew(); if (null === $this->collRemoteHistoryContaos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRemoteHistoryContaos) { // return empty collection $this->initRemoteHistoryContaos(); } else { $collRemoteHistoryContaos = RemoteHistoryContaoQuery::create(null, $criteria) ->filterByRemoteApp($this) ->find($con); if (null !== $criteria) { if (false !== $this->collRemoteHistoryContaosPartial && count($collRemoteHistoryContaos)) { $this->initRemoteHistoryContaos(false); foreach ($collRemoteHistoryContaos as $obj) { if (false == $this->collRemoteHistoryContaos->contains($obj)) { $this->collRemoteHistoryContaos->append($obj); } } $this->collRemoteHistoryContaosPartial = true; } $collRemoteHistoryContaos->getInternalIterator()->rewind(); return $collRemoteHistoryContaos; } if ($partial && $this->collRemoteHistoryContaos) { foreach ($this->collRemoteHistoryContaos as $obj) { if ($obj->isNew()) { $collRemoteHistoryContaos[] = $obj; } } } $this->collRemoteHistoryContaos = $collRemoteHistoryContaos; $this->collRemoteHistoryContaosPartial = false; } } return $this->collRemoteHistoryContaos; }
php
public function getRemoteHistoryContaos($criteria = null, PropelPDO $con = null) { $partial = $this->collRemoteHistoryContaosPartial && !$this->isNew(); if (null === $this->collRemoteHistoryContaos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRemoteHistoryContaos) { // return empty collection $this->initRemoteHistoryContaos(); } else { $collRemoteHistoryContaos = RemoteHistoryContaoQuery::create(null, $criteria) ->filterByRemoteApp($this) ->find($con); if (null !== $criteria) { if (false !== $this->collRemoteHistoryContaosPartial && count($collRemoteHistoryContaos)) { $this->initRemoteHistoryContaos(false); foreach ($collRemoteHistoryContaos as $obj) { if (false == $this->collRemoteHistoryContaos->contains($obj)) { $this->collRemoteHistoryContaos->append($obj); } } $this->collRemoteHistoryContaosPartial = true; } $collRemoteHistoryContaos->getInternalIterator()->rewind(); return $collRemoteHistoryContaos; } if ($partial && $this->collRemoteHistoryContaos) { foreach ($this->collRemoteHistoryContaos as $obj) { if ($obj->isNew()) { $collRemoteHistoryContaos[] = $obj; } } } $this->collRemoteHistoryContaos = $collRemoteHistoryContaos; $this->collRemoteHistoryContaosPartial = false; } } return $this->collRemoteHistoryContaos; }
[ "public", "function", "getRemoteHistoryContaos", "(", "$", "criteria", "=", "null", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collRemoteHistoryContaosPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collRemoteHistoryContaos", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collRemoteHistoryContaos", ")", "{", "// return empty collection", "$", "this", "->", "initRemoteHistoryContaos", "(", ")", ";", "}", "else", "{", "$", "collRemoteHistoryContaos", "=", "RemoteHistoryContaoQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByRemoteApp", "(", "$", "this", ")", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "if", "(", "false", "!==", "$", "this", "->", "collRemoteHistoryContaosPartial", "&&", "count", "(", "$", "collRemoteHistoryContaos", ")", ")", "{", "$", "this", "->", "initRemoteHistoryContaos", "(", "false", ")", ";", "foreach", "(", "$", "collRemoteHistoryContaos", "as", "$", "obj", ")", "{", "if", "(", "false", "==", "$", "this", "->", "collRemoteHistoryContaos", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "this", "->", "collRemoteHistoryContaos", "->", "append", "(", "$", "obj", ")", ";", "}", "}", "$", "this", "->", "collRemoteHistoryContaosPartial", "=", "true", ";", "}", "$", "collRemoteHistoryContaos", "->", "getInternalIterator", "(", ")", "->", "rewind", "(", ")", ";", "return", "$", "collRemoteHistoryContaos", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collRemoteHistoryContaos", ")", "{", "foreach", "(", "$", "this", "->", "collRemoteHistoryContaos", "as", "$", "obj", ")", "{", "if", "(", "$", "obj", "->", "isNew", "(", ")", ")", "{", "$", "collRemoteHistoryContaos", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collRemoteHistoryContaos", "=", "$", "collRemoteHistoryContaos", ";", "$", "this", "->", "collRemoteHistoryContaosPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collRemoteHistoryContaos", ";", "}" ]
Gets an array of RemoteHistoryContao objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this RemoteApp is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param PropelPDO $con optional connection object @return PropelObjectCollection|RemoteHistoryContao[] List of RemoteHistoryContao objects @throws PropelException
[ "Gets", "an", "array", "of", "RemoteHistoryContao", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php#L2698-L2741
16,862
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php
BaseRemoteApp.countRemoteHistoryContaos
public function countRemoteHistoryContaos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collRemoteHistoryContaosPartial && !$this->isNew(); if (null === $this->collRemoteHistoryContaos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRemoteHistoryContaos) { return 0; } if ($partial && !$criteria) { return count($this->getRemoteHistoryContaos()); } $query = RemoteHistoryContaoQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByRemoteApp($this) ->count($con); } return count($this->collRemoteHistoryContaos); }
php
public function countRemoteHistoryContaos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collRemoteHistoryContaosPartial && !$this->isNew(); if (null === $this->collRemoteHistoryContaos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRemoteHistoryContaos) { return 0; } if ($partial && !$criteria) { return count($this->getRemoteHistoryContaos()); } $query = RemoteHistoryContaoQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByRemoteApp($this) ->count($con); } return count($this->collRemoteHistoryContaos); }
[ "public", "function", "countRemoteHistoryContaos", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collRemoteHistoryContaosPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collRemoteHistoryContaos", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collRemoteHistoryContaos", ")", "{", "return", "0", ";", "}", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getRemoteHistoryContaos", "(", ")", ")", ";", "}", "$", "query", "=", "RemoteHistoryContaoQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByRemoteApp", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "return", "count", "(", "$", "this", "->", "collRemoteHistoryContaos", ")", ";", "}" ]
Returns the number of related RemoteHistoryContao objects. @param Criteria $criteria @param boolean $distinct @param PropelPDO $con @return int Count of related RemoteHistoryContao objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "RemoteHistoryContao", "objects", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php#L2784-L2806
16,863
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php
BaseRemoteApp.addRemoteHistoryContao
public function addRemoteHistoryContao(RemoteHistoryContao $l) { if ($this->collRemoteHistoryContaos === null) { $this->initRemoteHistoryContaos(); $this->collRemoteHistoryContaosPartial = true; } if (!in_array($l, $this->collRemoteHistoryContaos->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddRemoteHistoryContao($l); if ($this->remoteHistoryContaosScheduledForDeletion and $this->remoteHistoryContaosScheduledForDeletion->contains($l)) { $this->remoteHistoryContaosScheduledForDeletion->remove($this->remoteHistoryContaosScheduledForDeletion->search($l)); } } return $this; }
php
public function addRemoteHistoryContao(RemoteHistoryContao $l) { if ($this->collRemoteHistoryContaos === null) { $this->initRemoteHistoryContaos(); $this->collRemoteHistoryContaosPartial = true; } if (!in_array($l, $this->collRemoteHistoryContaos->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddRemoteHistoryContao($l); if ($this->remoteHistoryContaosScheduledForDeletion and $this->remoteHistoryContaosScheduledForDeletion->contains($l)) { $this->remoteHistoryContaosScheduledForDeletion->remove($this->remoteHistoryContaosScheduledForDeletion->search($l)); } } return $this; }
[ "public", "function", "addRemoteHistoryContao", "(", "RemoteHistoryContao", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collRemoteHistoryContaos", "===", "null", ")", "{", "$", "this", "->", "initRemoteHistoryContaos", "(", ")", ";", "$", "this", "->", "collRemoteHistoryContaosPartial", "=", "true", ";", "}", "if", "(", "!", "in_array", "(", "$", "l", ",", "$", "this", "->", "collRemoteHistoryContaos", "->", "getArrayCopy", "(", ")", ",", "true", ")", ")", "{", "// only add it if the **same** object is not already associated", "$", "this", "->", "doAddRemoteHistoryContao", "(", "$", "l", ")", ";", "if", "(", "$", "this", "->", "remoteHistoryContaosScheduledForDeletion", "and", "$", "this", "->", "remoteHistoryContaosScheduledForDeletion", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "remoteHistoryContaosScheduledForDeletion", "->", "remove", "(", "$", "this", "->", "remoteHistoryContaosScheduledForDeletion", "->", "search", "(", "$", "l", ")", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Method called to associate a RemoteHistoryContao object to this object through the RemoteHistoryContao foreign key attribute. @param RemoteHistoryContao $l RemoteHistoryContao @return RemoteApp The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "RemoteHistoryContao", "object", "to", "this", "object", "through", "the", "RemoteHistoryContao", "foreign", "key", "attribute", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteApp.php#L2815-L2831
16,864
drsdre/yii2-xmlsoccer
commands/XmlSoccerController.php
XmlSoccerController.actionImportLeagues
public function actionImportLeagues() { $client = new Client([ 'apiKey' => $this->apiKey ]); $leagues = $client->getAllLeagues(); $count = 0; foreach ($leagues as $league) { $dbLeague = Yii::createObject([ 'class' => $this->leagueClass, 'interface_id' => ArrayHelper::getValue($league, 'Id'), 'name' => ArrayHelper::getValue($league, 'Name'), 'country' => ArrayHelper::getValue($league, 'Country'), 'historical_data' => constant( '\drsdre\yii\xmlsoccer\models\League::HISTORICAL_DATA_' . strtoupper(ArrayHelper::getValue($league, 'Historical_Data', 'no')) ), 'fixtures' => filter_var( strtolower(ArrayHelper::getValue($league, 'Fixtures', 'no')), FILTER_VALIDATE_BOOLEAN ), 'livescore' => filter_var( strtolower(ArrayHelper::getValue($league, 'Livescore', 'no')), FILTER_VALIDATE_BOOLEAN ), 'number_of_matches' => ArrayHelper::getValue($league, 'NumberOfMatches', 0), 'latest_match' => ArrayHelper::getValue($league, 'LatestMatch'), 'is_cup' => filter_var( strtolower(ArrayHelper::getValue($league, 'IsCup', 'no')), FILTER_VALIDATE_BOOLEAN ) ]); /* @var $dbLeague \drsdre\yii\xmlsoccer\models\League */ if (!$dbLeague->save()) { $this->stderr("Failed to import league '{$dbLeague->name}': ", Console::FG_RED); $this->stderr("\n"); foreach ($dbLeague->errors as $attribute => $errors) { foreach ($errors as $error) { $this->stderr("$attribute: $error", Console::BG_YELLOW, Console::FG_BLACK); $this->stderr("\n"); } } $this->stderr("\n"); } else { $count++; $this->stdout("League '{$dbLeague->name}' inserted\n"); } } $this->stdout("\n"); $this->stdout("$count leagues imported", Console::FG_GREEN); $this->stdout("\n"); return ExitCode::OK; }
php
public function actionImportLeagues() { $client = new Client([ 'apiKey' => $this->apiKey ]); $leagues = $client->getAllLeagues(); $count = 0; foreach ($leagues as $league) { $dbLeague = Yii::createObject([ 'class' => $this->leagueClass, 'interface_id' => ArrayHelper::getValue($league, 'Id'), 'name' => ArrayHelper::getValue($league, 'Name'), 'country' => ArrayHelper::getValue($league, 'Country'), 'historical_data' => constant( '\drsdre\yii\xmlsoccer\models\League::HISTORICAL_DATA_' . strtoupper(ArrayHelper::getValue($league, 'Historical_Data', 'no')) ), 'fixtures' => filter_var( strtolower(ArrayHelper::getValue($league, 'Fixtures', 'no')), FILTER_VALIDATE_BOOLEAN ), 'livescore' => filter_var( strtolower(ArrayHelper::getValue($league, 'Livescore', 'no')), FILTER_VALIDATE_BOOLEAN ), 'number_of_matches' => ArrayHelper::getValue($league, 'NumberOfMatches', 0), 'latest_match' => ArrayHelper::getValue($league, 'LatestMatch'), 'is_cup' => filter_var( strtolower(ArrayHelper::getValue($league, 'IsCup', 'no')), FILTER_VALIDATE_BOOLEAN ) ]); /* @var $dbLeague \drsdre\yii\xmlsoccer\models\League */ if (!$dbLeague->save()) { $this->stderr("Failed to import league '{$dbLeague->name}': ", Console::FG_RED); $this->stderr("\n"); foreach ($dbLeague->errors as $attribute => $errors) { foreach ($errors as $error) { $this->stderr("$attribute: $error", Console::BG_YELLOW, Console::FG_BLACK); $this->stderr("\n"); } } $this->stderr("\n"); } else { $count++; $this->stdout("League '{$dbLeague->name}' inserted\n"); } } $this->stdout("\n"); $this->stdout("$count leagues imported", Console::FG_GREEN); $this->stdout("\n"); return ExitCode::OK; }
[ "public", "function", "actionImportLeagues", "(", ")", "{", "$", "client", "=", "new", "Client", "(", "[", "'apiKey'", "=>", "$", "this", "->", "apiKey", "]", ")", ";", "$", "leagues", "=", "$", "client", "->", "getAllLeagues", "(", ")", ";", "$", "count", "=", "0", ";", "foreach", "(", "$", "leagues", "as", "$", "league", ")", "{", "$", "dbLeague", "=", "Yii", "::", "createObject", "(", "[", "'class'", "=>", "$", "this", "->", "leagueClass", ",", "'interface_id'", "=>", "ArrayHelper", "::", "getValue", "(", "$", "league", ",", "'Id'", ")", ",", "'name'", "=>", "ArrayHelper", "::", "getValue", "(", "$", "league", ",", "'Name'", ")", ",", "'country'", "=>", "ArrayHelper", "::", "getValue", "(", "$", "league", ",", "'Country'", ")", ",", "'historical_data'", "=>", "constant", "(", "'\\drsdre\\yii\\xmlsoccer\\models\\League::HISTORICAL_DATA_'", ".", "strtoupper", "(", "ArrayHelper", "::", "getValue", "(", "$", "league", ",", "'Historical_Data'", ",", "'no'", ")", ")", ")", ",", "'fixtures'", "=>", "filter_var", "(", "strtolower", "(", "ArrayHelper", "::", "getValue", "(", "$", "league", ",", "'Fixtures'", ",", "'no'", ")", ")", ",", "FILTER_VALIDATE_BOOLEAN", ")", ",", "'livescore'", "=>", "filter_var", "(", "strtolower", "(", "ArrayHelper", "::", "getValue", "(", "$", "league", ",", "'Livescore'", ",", "'no'", ")", ")", ",", "FILTER_VALIDATE_BOOLEAN", ")", ",", "'number_of_matches'", "=>", "ArrayHelper", "::", "getValue", "(", "$", "league", ",", "'NumberOfMatches'", ",", "0", ")", ",", "'latest_match'", "=>", "ArrayHelper", "::", "getValue", "(", "$", "league", ",", "'LatestMatch'", ")", ",", "'is_cup'", "=>", "filter_var", "(", "strtolower", "(", "ArrayHelper", "::", "getValue", "(", "$", "league", ",", "'IsCup'", ",", "'no'", ")", ")", ",", "FILTER_VALIDATE_BOOLEAN", ")", "]", ")", ";", "/* @var $dbLeague \\drsdre\\yii\\xmlsoccer\\models\\League */", "if", "(", "!", "$", "dbLeague", "->", "save", "(", ")", ")", "{", "$", "this", "->", "stderr", "(", "\"Failed to import league '{$dbLeague->name}': \"", ",", "Console", "::", "FG_RED", ")", ";", "$", "this", "->", "stderr", "(", "\"\\n\"", ")", ";", "foreach", "(", "$", "dbLeague", "->", "errors", "as", "$", "attribute", "=>", "$", "errors", ")", "{", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "$", "this", "->", "stderr", "(", "\"$attribute: $error\"", ",", "Console", "::", "BG_YELLOW", ",", "Console", "::", "FG_BLACK", ")", ";", "$", "this", "->", "stderr", "(", "\"\\n\"", ")", ";", "}", "}", "$", "this", "->", "stderr", "(", "\"\\n\"", ")", ";", "}", "else", "{", "$", "count", "++", ";", "$", "this", "->", "stdout", "(", "\"League '{$dbLeague->name}' inserted\\n\"", ")", ";", "}", "}", "$", "this", "->", "stdout", "(", "\"\\n\"", ")", ";", "$", "this", "->", "stdout", "(", "\"$count leagues imported\"", ",", "Console", "::", "FG_GREEN", ")", ";", "$", "this", "->", "stdout", "(", "\"\\n\"", ")", ";", "return", "ExitCode", "::", "OK", ";", "}" ]
Import all leagues from XMLSoccer interface @return integer Exit code @throws \yii\base\InvalidConfigException
[ "Import", "all", "leagues", "from", "XMLSoccer", "interface" ]
a746edee6269ed0791bac6c6165a946adc30d994
https://github.com/drsdre/yii2-xmlsoccer/blob/a746edee6269ed0791bac6c6165a946adc30d994/commands/XmlSoccerController.php#L82-L138
16,865
drsdre/yii2-xmlsoccer
commands/XmlSoccerController.php
XmlSoccerController.actionShowLeagues
public function actionShowLeagues() { $leagues = call_user_func([$this->leagueClass, 'find']); /* @var $leagues \yii\db\ActiveQuery */ if (!$leagues->count('id')) { $this->stdout("No leagues found. Import by "); $this->stdout("{$this->id}/import-leagues", Console::BOLD); $this->stdout("\n"); return ExitCode::OK; } $first = $leagues->one(); $headers = []; $rows = []; $attributes = []; foreach ($first->toArray() as $attribute => $value) { $attributes[] = $attribute; $headers[] = $first->generateAttributeLabel($attribute); } foreach ($leagues->all() as $league) { $rows[] = array_values($league->toArray($attributes)); } echo Table::widget([ 'headers' => $headers, 'rows' => $rows ]); return ExitCode::OK; }
php
public function actionShowLeagues() { $leagues = call_user_func([$this->leagueClass, 'find']); /* @var $leagues \yii\db\ActiveQuery */ if (!$leagues->count('id')) { $this->stdout("No leagues found. Import by "); $this->stdout("{$this->id}/import-leagues", Console::BOLD); $this->stdout("\n"); return ExitCode::OK; } $first = $leagues->one(); $headers = []; $rows = []; $attributes = []; foreach ($first->toArray() as $attribute => $value) { $attributes[] = $attribute; $headers[] = $first->generateAttributeLabel($attribute); } foreach ($leagues->all() as $league) { $rows[] = array_values($league->toArray($attributes)); } echo Table::widget([ 'headers' => $headers, 'rows' => $rows ]); return ExitCode::OK; }
[ "public", "function", "actionShowLeagues", "(", ")", "{", "$", "leagues", "=", "call_user_func", "(", "[", "$", "this", "->", "leagueClass", ",", "'find'", "]", ")", ";", "/* @var $leagues \\yii\\db\\ActiveQuery */", "if", "(", "!", "$", "leagues", "->", "count", "(", "'id'", ")", ")", "{", "$", "this", "->", "stdout", "(", "\"No leagues found. Import by \"", ")", ";", "$", "this", "->", "stdout", "(", "\"{$this->id}/import-leagues\"", ",", "Console", "::", "BOLD", ")", ";", "$", "this", "->", "stdout", "(", "\"\\n\"", ")", ";", "return", "ExitCode", "::", "OK", ";", "}", "$", "first", "=", "$", "leagues", "->", "one", "(", ")", ";", "$", "headers", "=", "[", "]", ";", "$", "rows", "=", "[", "]", ";", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "first", "->", "toArray", "(", ")", "as", "$", "attribute", "=>", "$", "value", ")", "{", "$", "attributes", "[", "]", "=", "$", "attribute", ";", "$", "headers", "[", "]", "=", "$", "first", "->", "generateAttributeLabel", "(", "$", "attribute", ")", ";", "}", "foreach", "(", "$", "leagues", "->", "all", "(", ")", "as", "$", "league", ")", "{", "$", "rows", "[", "]", "=", "array_values", "(", "$", "league", "->", "toArray", "(", "$", "attributes", ")", ")", ";", "}", "echo", "Table", "::", "widget", "(", "[", "'headers'", "=>", "$", "headers", ",", "'rows'", "=>", "$", "rows", "]", ")", ";", "return", "ExitCode", "::", "OK", ";", "}" ]
Show all leagues @return integer Exit code @throws \Exception
[ "Show", "all", "leagues" ]
a746edee6269ed0791bac6c6165a946adc30d994
https://github.com/drsdre/yii2-xmlsoccer/blob/a746edee6269ed0791bac6c6165a946adc30d994/commands/XmlSoccerController.php#L146-L177
16,866
lode/fem
src/resources.php
resources.get_timestamped_url
private static function get_timestamped_url($file, $type) { $search = ['{{root_dir}}', '{{type}}']; $replace = [self::$root_dir, $type]; $base_path = str_replace($search, $replace, self::$base_path); $base_url = str_replace($search, $replace, self::$base_url); $file = trim($file); $absolute = ($file[0] == '/'); $file = ($absolute) ? $file : $base_url.$file; $full_path = $base_path.$file.'.'.$type; if (file_exists($full_path) == false) { $exception = bootstrap::get_library('exception'); throw new $exception('can not find '.$type.' resource '.$file); } $timestamp = filemtime($full_path); $full_url = $file.'.'.$timestamp.'.'.$type; return $full_url; }
php
private static function get_timestamped_url($file, $type) { $search = ['{{root_dir}}', '{{type}}']; $replace = [self::$root_dir, $type]; $base_path = str_replace($search, $replace, self::$base_path); $base_url = str_replace($search, $replace, self::$base_url); $file = trim($file); $absolute = ($file[0] == '/'); $file = ($absolute) ? $file : $base_url.$file; $full_path = $base_path.$file.'.'.$type; if (file_exists($full_path) == false) { $exception = bootstrap::get_library('exception'); throw new $exception('can not find '.$type.' resource '.$file); } $timestamp = filemtime($full_path); $full_url = $file.'.'.$timestamp.'.'.$type; return $full_url; }
[ "private", "static", "function", "get_timestamped_url", "(", "$", "file", ",", "$", "type", ")", "{", "$", "search", "=", "[", "'{{root_dir}}'", ",", "'{{type}}'", "]", ";", "$", "replace", "=", "[", "self", "::", "$", "root_dir", ",", "$", "type", "]", ";", "$", "base_path", "=", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "self", "::", "$", "base_path", ")", ";", "$", "base_url", "=", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "self", "::", "$", "base_url", ")", ";", "$", "file", "=", "trim", "(", "$", "file", ")", ";", "$", "absolute", "=", "(", "$", "file", "[", "0", "]", "==", "'/'", ")", ";", "$", "file", "=", "(", "$", "absolute", ")", "?", "$", "file", ":", "$", "base_url", ".", "$", "file", ";", "$", "full_path", "=", "$", "base_path", ".", "$", "file", ".", "'.'", ".", "$", "type", ";", "if", "(", "file_exists", "(", "$", "full_path", ")", "==", "false", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'can not find '", ".", "$", "type", ".", "' resource '", ".", "$", "file", ")", ";", "}", "$", "timestamp", "=", "filemtime", "(", "$", "full_path", ")", ";", "$", "full_url", "=", "$", "file", ".", "'.'", ".", "$", "timestamp", ".", "'.'", ".", "$", "type", ";", "return", "$", "full_url", ";", "}" ]
adds a modification timestamp to a file path @param string $file relative path from css/ or js/, excluding the extension or absolute from the docroot when starting with a '/' absolute is handy for loading css from a js plugin directory i.e.: 'foo/bar' will become '/frontend/css/foo/bar.1234567890.css' i.e.: '/frontend/js/plugin/style' will become '/frontend/js/plugin/style.1234567890.css' @param string $type 'css' or 'js' @return string $file with a timestamp before the extension
[ "adds", "a", "modification", "timestamp", "to", "a", "file", "path" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/resources.php#L34-L54
16,867
tableau-mkt/eggs-n-cereal
src/Utils/ConverterToHTML.php
ConverterToHTML.toHTML
public function toHTML($pretty_print = TRUE) { $this->out = new \DOMDocument('1.0', 'UTF-8'); $this->out->formatOutput = $pretty_print; $field = $this->doc->getElementsByTagName('xlf:group')->item(0); foreach ($field->childNodes as $child) { if ($output = $this->convert($child)) { $this->out->appendChild($output); } } return html_entity_decode($this->out->saveHTML(), ENT_QUOTES, 'UTF-8'); }
php
public function toHTML($pretty_print = TRUE) { $this->out = new \DOMDocument('1.0', 'UTF-8'); $this->out->formatOutput = $pretty_print; $field = $this->doc->getElementsByTagName('xlf:group')->item(0); foreach ($field->childNodes as $child) { if ($output = $this->convert($child)) { $this->out->appendChild($output); } } return html_entity_decode($this->out->saveHTML(), ENT_QUOTES, 'UTF-8'); }
[ "public", "function", "toHTML", "(", "$", "pretty_print", "=", "TRUE", ")", "{", "$", "this", "->", "out", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "this", "->", "out", "->", "formatOutput", "=", "$", "pretty_print", ";", "$", "field", "=", "$", "this", "->", "doc", "->", "getElementsByTagName", "(", "'xlf:group'", ")", "->", "item", "(", "0", ")", ";", "foreach", "(", "$", "field", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "output", "=", "$", "this", "->", "convert", "(", "$", "child", ")", ")", "{", "$", "this", "->", "out", "->", "appendChild", "(", "$", "output", ")", ";", "}", "}", "return", "html_entity_decode", "(", "$", "this", "->", "out", "->", "saveHTML", "(", ")", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ";", "}" ]
Converts XML to the corresponding HTML representation. @return string The source XML converted to HTML.
[ "Converts", "XML", "to", "the", "corresponding", "HTML", "representation", "." ]
778b83ddae1dd687724a84545ce8afa1a31e4bcf
https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Utils/ConverterToHTML.php#L36-L49
16,868
ClanCats/Core
src/classes/CCDataObject.php
CCDataObject.set
public function set( $key, $value, $param = null ) { CCArr::set( $key, $value, $this->_data ); }
php
public function set( $key, $value, $param = null ) { CCArr::set( $key, $value, $this->_data ); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "param", "=", "null", ")", "{", "CCArr", "::", "set", "(", "$", "key", ",", "$", "value", ",", "$", "this", "->", "_data", ")", ";", "}" ]
set data to the object. @param string $key @param mixed $value @param mixed $param @return void
[ "set", "data", "to", "the", "object", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCDataObject.php#L43-L46
16,869
Chill-project/Main
Timeline/TimelineBuilder.php
TimelineBuilder.getTimelineHTML
public function getTimelineHTML($context, array $args, $page = 0, $number = 20) { $query = $this->buildUnionQuery($context, $args, $page, $number); $fetched = $this->runQuery($query); $entitiesByKey = $this->getEntities($fetched, $context); return $this->render($fetched, $entitiesByKey, $context, $args); }
php
public function getTimelineHTML($context, array $args, $page = 0, $number = 20) { $query = $this->buildUnionQuery($context, $args, $page, $number); $fetched = $this->runQuery($query); $entitiesByKey = $this->getEntities($fetched, $context); return $this->render($fetched, $entitiesByKey, $context, $args); }
[ "public", "function", "getTimelineHTML", "(", "$", "context", ",", "array", "$", "args", ",", "$", "page", "=", "0", ",", "$", "number", "=", "20", ")", "{", "$", "query", "=", "$", "this", "->", "buildUnionQuery", "(", "$", "context", ",", "$", "args", ",", "$", "page", ",", "$", "number", ")", ";", "$", "fetched", "=", "$", "this", "->", "runQuery", "(", "$", "query", ")", ";", "$", "entitiesByKey", "=", "$", "this", "->", "getEntities", "(", "$", "fetched", ",", "$", "context", ")", ";", "return", "$", "this", "->", "render", "(", "$", "fetched", ",", "$", "entitiesByKey", ",", "$", "context", ",", "$", "args", ")", ";", "}" ]
return an HTML string with timeline This function must be called from controller @example https://redmine.champs-libres.coop/projects/chillperson/repository/revisions/bd2e1b1808f73e39532e9538413025df5487cad0/entry/Controller/TimelinePersonController.php#L47 the implementation in person bundle @param string $context @param array $args arguments defined by the bundle which create the context @param int $page first page = 0 @param int $number number of items by page @return string an HTML representation, must be included using `|raw` filter
[ "return", "an", "HTML", "string", "with", "timeline" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Timeline/TimelineBuilder.php#L66-L73
16,870
Chill-project/Main
Timeline/TimelineBuilder.php
TimelineBuilder.getProvidersByContext
public function getProvidersByContext($context) { $providers = array(); foreach($this->providers[$context] as $providerId) { $providers[] = $this->container->get($providerId); } return $providers; }
php
public function getProvidersByContext($context) { $providers = array(); foreach($this->providers[$context] as $providerId) { $providers[] = $this->container->get($providerId); } return $providers; }
[ "public", "function", "getProvidersByContext", "(", "$", "context", ")", "{", "$", "providers", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "providers", "[", "$", "context", "]", "as", "$", "providerId", ")", "{", "$", "providers", "[", "]", "=", "$", "this", "->", "container", "->", "get", "(", "$", "providerId", ")", ";", "}", "return", "$", "providers", ";", "}" ]
Get providers by context @param string $context @return TimelineProviderInterface[]
[ "Get", "providers", "by", "context" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Timeline/TimelineBuilder.php#L94-L103
16,871
Chill-project/Main
Timeline/TimelineBuilder.php
TimelineBuilder.buildUnionQuery
private function buildUnionQuery($context, array $args, $page, $number) { //throw an exception if no provider have been defined for this context if (!array_key_exists($context, $this->providers)) { throw new \LogicException(sprintf('No builders have been defined for "%s"' . ' context', $context)); } //append SELECT queries with UNION keyword between them $union = ''; foreach($this->getProvidersByContext($context) as $provider) { $select = $this->buildSelectQuery($provider, $context, $args); $append = ($union === '') ? $select : ' UNION '.$select; $union .= $append; } //add ORDER BY clause and LIMIT $union .= sprintf(' ORDER BY date DESC LIMIT %d OFFSET %d', $number, $page * $number); return $union; }
php
private function buildUnionQuery($context, array $args, $page, $number) { //throw an exception if no provider have been defined for this context if (!array_key_exists($context, $this->providers)) { throw new \LogicException(sprintf('No builders have been defined for "%s"' . ' context', $context)); } //append SELECT queries with UNION keyword between them $union = ''; foreach($this->getProvidersByContext($context) as $provider) { $select = $this->buildSelectQuery($provider, $context, $args); $append = ($union === '') ? $select : ' UNION '.$select; $union .= $append; } //add ORDER BY clause and LIMIT $union .= sprintf(' ORDER BY date DESC LIMIT %d OFFSET %d', $number, $page * $number); return $union; }
[ "private", "function", "buildUnionQuery", "(", "$", "context", ",", "array", "$", "args", ",", "$", "page", ",", "$", "number", ")", "{", "//throw an exception if no provider have been defined for this context", "if", "(", "!", "array_key_exists", "(", "$", "context", ",", "$", "this", "->", "providers", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'No builders have been defined for \"%s\"'", ".", "' context'", ",", "$", "context", ")", ")", ";", "}", "//append SELECT queries with UNION keyword between them", "$", "union", "=", "''", ";", "foreach", "(", "$", "this", "->", "getProvidersByContext", "(", "$", "context", ")", "as", "$", "provider", ")", "{", "$", "select", "=", "$", "this", "->", "buildSelectQuery", "(", "$", "provider", ",", "$", "context", ",", "$", "args", ")", ";", "$", "append", "=", "(", "$", "union", "===", "''", ")", "?", "$", "select", ":", "' UNION '", ".", "$", "select", ";", "$", "union", ".=", "$", "append", ";", "}", "//add ORDER BY clause and LIMIT", "$", "union", ".=", "sprintf", "(", "' ORDER BY date DESC LIMIT %d OFFSET %d'", ",", "$", "number", ",", "$", "page", "*", "$", "number", ")", ";", "return", "$", "union", ";", "}" ]
build the UNION query with all providers @uses self::buildSelectQuery to build individual SELECT queries @param string $context @param mixed $args @param int $page @param int $number @return string @throws \LogicException if no builder have been defined for this context
[ "build", "the", "UNION", "query", "with", "all", "providers" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Timeline/TimelineBuilder.php#L117-L137
16,872
Chill-project/Main
Timeline/TimelineBuilder.php
TimelineBuilder.buildSelectQuery
private function buildSelectQuery(TimelineProviderInterface $provider, $context, array $args) { $data = $provider->fetchQuery($context, $args); return sprintf( 'SELECT %s AS id, ' . '%s AS "date", ' . "'%s' AS type " . 'FROM %s ' . 'WHERE %s', $data['id'], $data['date'], $data['type'], $data['FROM'], $data['WHERE']); }
php
private function buildSelectQuery(TimelineProviderInterface $provider, $context, array $args) { $data = $provider->fetchQuery($context, $args); return sprintf( 'SELECT %s AS id, ' . '%s AS "date", ' . "'%s' AS type " . 'FROM %s ' . 'WHERE %s', $data['id'], $data['date'], $data['type'], $data['FROM'], $data['WHERE']); }
[ "private", "function", "buildSelectQuery", "(", "TimelineProviderInterface", "$", "provider", ",", "$", "context", ",", "array", "$", "args", ")", "{", "$", "data", "=", "$", "provider", "->", "fetchQuery", "(", "$", "context", ",", "$", "args", ")", ";", "return", "sprintf", "(", "'SELECT %s AS id, '", ".", "'%s AS \"date\", '", ".", "\"'%s' AS type \"", ".", "'FROM %s '", ".", "'WHERE %s'", ",", "$", "data", "[", "'id'", "]", ",", "$", "data", "[", "'date'", "]", ",", "$", "data", "[", "'type'", "]", ",", "$", "data", "[", "'FROM'", "]", ",", "$", "data", "[", "'WHERE'", "]", ")", ";", "}" ]
return the SQL SELECT query as a string, @uses TimelineProfiderInterface::fetchQuery use the fetchQuery function @param \Chill\MainBundle\Timeline\TimelineProviderInterface $provider @param string $context @param mixed[] $args @return string
[ "return", "the", "SQL", "SELECT", "query", "as", "a", "string" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Timeline/TimelineBuilder.php#L148-L163
16,873
Chill-project/Main
Timeline/TimelineBuilder.php
TimelineBuilder.runQuery
private function runQuery($query) { $resultSetMapping = (new ResultSetMapping()) ->addScalarResult('id', 'id') ->addScalarResult('type', 'type') ->addScalarResult('date', 'date'); return $this->em->createNativeQuery($query, $resultSetMapping) ->getArrayResult(); }
php
private function runQuery($query) { $resultSetMapping = (new ResultSetMapping()) ->addScalarResult('id', 'id') ->addScalarResult('type', 'type') ->addScalarResult('date', 'date'); return $this->em->createNativeQuery($query, $resultSetMapping) ->getArrayResult(); }
[ "private", "function", "runQuery", "(", "$", "query", ")", "{", "$", "resultSetMapping", "=", "(", "new", "ResultSetMapping", "(", ")", ")", "->", "addScalarResult", "(", "'id'", ",", "'id'", ")", "->", "addScalarResult", "(", "'type'", ",", "'type'", ")", "->", "addScalarResult", "(", "'date'", ",", "'date'", ")", ";", "return", "$", "this", "->", "em", "->", "createNativeQuery", "(", "$", "query", ",", "$", "resultSetMapping", ")", "->", "getArrayResult", "(", ")", ";", "}" ]
run the UNION query and return result as an array @param string $query @return array
[ "run", "the", "UNION", "query", "and", "return", "result", "as", "an", "array" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Timeline/TimelineBuilder.php#L171-L180
16,874
Chill-project/Main
Timeline/TimelineBuilder.php
TimelineBuilder.render
private function render(array $fetched, array $entitiesByType, $context, array $args) { //add results to a pretty array $timelineEntries = array(); foreach ($fetched as $result) { $data = $this->getTemplateData( $result['type'], $entitiesByType[$result['type']][$result['id']], //the entity $context, $args); $timelineEntry['date'] = new \DateTime($result['date']); $timelineEntry['template'] = $data['template']; $timelineEntry['template_data'] = $data['template_data']; $timelineEntries[] = $timelineEntry; } return $this->container->get('templating') ->render('ChillMainBundle:Timeline:index.html.twig', array( 'results' => $timelineEntries )); }
php
private function render(array $fetched, array $entitiesByType, $context, array $args) { //add results to a pretty array $timelineEntries = array(); foreach ($fetched as $result) { $data = $this->getTemplateData( $result['type'], $entitiesByType[$result['type']][$result['id']], //the entity $context, $args); $timelineEntry['date'] = new \DateTime($result['date']); $timelineEntry['template'] = $data['template']; $timelineEntry['template_data'] = $data['template_data']; $timelineEntries[] = $timelineEntry; } return $this->container->get('templating') ->render('ChillMainBundle:Timeline:index.html.twig', array( 'results' => $timelineEntries )); }
[ "private", "function", "render", "(", "array", "$", "fetched", ",", "array", "$", "entitiesByType", ",", "$", "context", ",", "array", "$", "args", ")", "{", "//add results to a pretty array", "$", "timelineEntries", "=", "array", "(", ")", ";", "foreach", "(", "$", "fetched", "as", "$", "result", ")", "{", "$", "data", "=", "$", "this", "->", "getTemplateData", "(", "$", "result", "[", "'type'", "]", ",", "$", "entitiesByType", "[", "$", "result", "[", "'type'", "]", "]", "[", "$", "result", "[", "'id'", "]", "]", ",", "//the entity", "$", "context", ",", "$", "args", ")", ";", "$", "timelineEntry", "[", "'date'", "]", "=", "new", "\\", "DateTime", "(", "$", "result", "[", "'date'", "]", ")", ";", "$", "timelineEntry", "[", "'template'", "]", "=", "$", "data", "[", "'template'", "]", ";", "$", "timelineEntry", "[", "'template_data'", "]", "=", "$", "data", "[", "'template_data'", "]", ";", "$", "timelineEntries", "[", "]", "=", "$", "timelineEntry", ";", "}", "return", "$", "this", "->", "container", "->", "get", "(", "'templating'", ")", "->", "render", "(", "'ChillMainBundle:Timeline:index.html.twig'", ",", "array", "(", "'results'", "=>", "$", "timelineEntries", ")", ")", ";", "}" ]
render the timeline as HTML @param array $fetched @param array $entitiesByType @param string $context @param mixed[] $args @return string the HTML representation of the timeline
[ "render", "the", "timeline", "as", "HTML" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Timeline/TimelineBuilder.php#L221-L243
16,875
Chill-project/Main
Timeline/TimelineBuilder.php
TimelineBuilder.getTemplateData
private function getTemplateData($type, $entity, $context, array $args) { foreach($this->getProvidersByContext($context) as $provider) { if ($provider->supportsType($type)) { return $provider->getEntityTemplate($entity, $context, $args); } } }
php
private function getTemplateData($type, $entity, $context, array $args) { foreach($this->getProvidersByContext($context) as $provider) { if ($provider->supportsType($type)) { return $provider->getEntityTemplate($entity, $context, $args); } } }
[ "private", "function", "getTemplateData", "(", "$", "type", ",", "$", "entity", ",", "$", "context", ",", "array", "$", "args", ")", "{", "foreach", "(", "$", "this", "->", "getProvidersByContext", "(", "$", "context", ")", "as", "$", "provider", ")", "{", "if", "(", "$", "provider", "->", "supportsType", "(", "$", "type", ")", ")", "{", "return", "$", "provider", "->", "getEntityTemplate", "(", "$", "entity", ",", "$", "context", ",", "$", "args", ")", ";", "}", "}", "}" ]
get the template data from the provider for the given entity, by type. @param string $type @param mixed $entity @param string $context @param mixed[] $args @return array the template data fetched from the provider
[ "get", "the", "template", "data", "from", "the", "provider", "for", "the", "given", "entity", "by", "type", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Timeline/TimelineBuilder.php#L254-L261
16,876
2amigos/yiifoundation
helpers/Panel.php
Panel.panel
public static function panel($content, $htmlOptions = array()) { ArrayHelper::addValue('class', Enum::PANEL, $htmlOptions); return \CHtml::tag('div', $htmlOptions, $content); }
php
public static function panel($content, $htmlOptions = array()) { ArrayHelper::addValue('class', Enum::PANEL, $htmlOptions); return \CHtml::tag('div', $htmlOptions, $content); }
[ "public", "static", "function", "panel", "(", "$", "content", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "ArrayHelper", "::", "addValue", "(", "'class'", ",", "Enum", "::", "PANEL", ",", "$", "htmlOptions", ")", ";", "return", "\\", "CHtml", "::", "tag", "(", "'div'", ",", "$", "htmlOptions", ",", "$", "content", ")", ";", "}" ]
Generates a panel @param string $content the content to display @param array $htmlOptions the HTML attributes of the panel @return string @see http://foundation.zurb.com/docs/components/panels.html
[ "Generates", "a", "panel" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Panel.php#L31-L35
16,877
2amigos/yiifoundation
helpers/Panel.php
Panel.callout
public static function callout($content, $htmlOptions = array()) { ArrayHelper::addValue('class', Enum::PANEL_CALLOUT, $htmlOptions); return static::panel($content, $htmlOptions); }
php
public static function callout($content, $htmlOptions = array()) { ArrayHelper::addValue('class', Enum::PANEL_CALLOUT, $htmlOptions); return static::panel($content, $htmlOptions); }
[ "public", "static", "function", "callout", "(", "$", "content", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "ArrayHelper", "::", "addValue", "(", "'class'", ",", "Enum", "::", "PANEL_CALLOUT", ",", "$", "htmlOptions", ")", ";", "return", "static", "::", "panel", "(", "$", "content", ",", "$", "htmlOptions", ")", ";", "}" ]
Generates a callout panel @param string $content the content to display @param array $htmlOptions the HTML attributes of the panel @return string
[ "Generates", "a", "callout", "panel" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Panel.php#L44-L48
16,878
ClanCats/Core
src/console/doctor.php
doctor.action_security_key
public function action_security_key( $params ) { $path = \CCPath::config( 'main.config'.EXT ); // Check if the file exists if ( !file_exists( $path ) ) { $this->error( 'Could not find main configuration file.' ); return; } // Now try to replace the placeholder with // an new generated key $data = \CCFile::read( $path ); if ( strpos( $data, '{{security salt here}}' ) === false ) { $this->error( 'The key has already been generated or set.' ); return; } $data = str_replace( '{{security salt here}}', \CCStr::random( 32, 'password' ), $data ); // write the data back down \CCFile::write( $path, $data ); $this->success( 'The key has been generated.' ); }
php
public function action_security_key( $params ) { $path = \CCPath::config( 'main.config'.EXT ); // Check if the file exists if ( !file_exists( $path ) ) { $this->error( 'Could not find main configuration file.' ); return; } // Now try to replace the placeholder with // an new generated key $data = \CCFile::read( $path ); if ( strpos( $data, '{{security salt here}}' ) === false ) { $this->error( 'The key has already been generated or set.' ); return; } $data = str_replace( '{{security salt here}}', \CCStr::random( 32, 'password' ), $data ); // write the data back down \CCFile::write( $path, $data ); $this->success( 'The key has been generated.' ); }
[ "public", "function", "action_security_key", "(", "$", "params", ")", "{", "$", "path", "=", "\\", "CCPath", "::", "config", "(", "'main.config'", ".", "EXT", ")", ";", "// Check if the file exists", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "$", "this", "->", "error", "(", "'Could not find main configuration file.'", ")", ";", "return", ";", "}", "// Now try to replace the placeholder with ", "// an new generated key", "$", "data", "=", "\\", "CCFile", "::", "read", "(", "$", "path", ")", ";", "if", "(", "strpos", "(", "$", "data", ",", "'{{security salt here}}'", ")", "===", "false", ")", "{", "$", "this", "->", "error", "(", "'The key has already been generated or set.'", ")", ";", "return", ";", "}", "$", "data", "=", "str_replace", "(", "'{{security salt here}}'", ",", "\\", "CCStr", "::", "random", "(", "32", ",", "'password'", ")", ",", "$", "data", ")", ";", "// write the data back down", "\\", "CCFile", "::", "write", "(", "$", "path", ",", "$", "data", ")", ";", "$", "this", "->", "success", "(", "'The key has been generated.'", ")", ";", "}" ]
Try to generate a security key in the main config file @param array $params
[ "Try", "to", "generate", "a", "security", "key", "in", "the", "main", "config", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/doctor.php#L43-L68
16,879
barebone-php/barebone-core
lib/Database.php
Database.instance
public static function instance() { if (null === self::$_instance) { $capsule = new Capsule; $capsule->addConnection(self::getConfig()); $capsule->setEventDispatcher(new Dispatcher(new Container)); $capsule->setAsGlobal(); self::$_instance = $capsule; } return self::$_instance; }
php
public static function instance() { if (null === self::$_instance) { $capsule = new Capsule; $capsule->addConnection(self::getConfig()); $capsule->setEventDispatcher(new Dispatcher(new Container)); $capsule->setAsGlobal(); self::$_instance = $capsule; } return self::$_instance; }
[ "public", "static", "function", "instance", "(", ")", "{", "if", "(", "null", "===", "self", "::", "$", "_instance", ")", "{", "$", "capsule", "=", "new", "Capsule", ";", "$", "capsule", "->", "addConnection", "(", "self", "::", "getConfig", "(", ")", ")", ";", "$", "capsule", "->", "setEventDispatcher", "(", "new", "Dispatcher", "(", "new", "Container", ")", ")", ";", "$", "capsule", "->", "setAsGlobal", "(", ")", ";", "self", "::", "$", "_instance", "=", "$", "capsule", ";", "}", "return", "self", "::", "$", "_instance", ";", "}" ]
Instantiate Eloquent ORM @return Capsule
[ "Instantiate", "Eloquent", "ORM" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Database.php#L48-L59
16,880
phpbench/container
lib/Container.php
Container.get
public function get($serviceId) { if (isset($this->services[$serviceId])) { return $this->services[$serviceId]; } if (!isset($this->instantiators[$serviceId])) { throw new \InvalidArgumentException(sprintf( 'No instantiator has been registered for requested service "%s"', $serviceId )); } $this->services[$serviceId] = $this->instantiators[$serviceId]($this); return $this->services[$serviceId]; }
php
public function get($serviceId) { if (isset($this->services[$serviceId])) { return $this->services[$serviceId]; } if (!isset($this->instantiators[$serviceId])) { throw new \InvalidArgumentException(sprintf( 'No instantiator has been registered for requested service "%s"', $serviceId )); } $this->services[$serviceId] = $this->instantiators[$serviceId]($this); return $this->services[$serviceId]; }
[ "public", "function", "get", "(", "$", "serviceId", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "services", "[", "$", "serviceId", "]", ")", ")", "{", "return", "$", "this", "->", "services", "[", "$", "serviceId", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "instantiators", "[", "$", "serviceId", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'No instantiator has been registered for requested service \"%s\"'", ",", "$", "serviceId", ")", ")", ";", "}", "$", "this", "->", "services", "[", "$", "serviceId", "]", "=", "$", "this", "->", "instantiators", "[", "$", "serviceId", "]", "(", "$", "this", ")", ";", "return", "$", "this", "->", "services", "[", "$", "serviceId", "]", ";", "}" ]
Instantiate and return the service with the given ID. Note that this method will return the same instance on subsequent calls. @param string $serviceId @return mixed
[ "Instantiate", "and", "return", "the", "service", "with", "the", "given", "ID", ".", "Note", "that", "this", "method", "will", "return", "the", "same", "instance", "on", "subsequent", "calls", "." ]
7acabddac1fd09cb58d4790443b6b791bf9f3095
https://github.com/phpbench/container/blob/7acabddac1fd09cb58d4790443b6b791bf9f3095/lib/Container.php#L105-L121
16,881
phpbench/container
lib/Container.php
Container.getServiceIdsForTag
public function getServiceIdsForTag($tag) { $serviceIds = []; foreach ($this->tags as $serviceId => $tags) { if (isset($tags[$tag])) { $serviceIds[$serviceId] = $tags[$tag]; } } return $serviceIds; }
php
public function getServiceIdsForTag($tag) { $serviceIds = []; foreach ($this->tags as $serviceId => $tags) { if (isset($tags[$tag])) { $serviceIds[$serviceId] = $tags[$tag]; } } return $serviceIds; }
[ "public", "function", "getServiceIdsForTag", "(", "$", "tag", ")", "{", "$", "serviceIds", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "tags", "as", "$", "serviceId", "=>", "$", "tags", ")", "{", "if", "(", "isset", "(", "$", "tags", "[", "$", "tag", "]", ")", ")", "{", "$", "serviceIds", "[", "$", "serviceId", "]", "=", "$", "tags", "[", "$", "tag", "]", ";", "}", "}", "return", "$", "serviceIds", ";", "}" ]
Return services IDs for the given tag. @param string $tag @return string[][]
[ "Return", "services", "IDs", "for", "the", "given", "tag", "." ]
7acabddac1fd09cb58d4790443b6b791bf9f3095
https://github.com/phpbench/container/blob/7acabddac1fd09cb58d4790443b6b791bf9f3095/lib/Container.php#L146-L156
16,882
phpbench/container
lib/Container.php
Container.register
public function register($serviceId, \Closure $instantiator, array $tags = []) { if (isset($this->instantiators[$serviceId])) { throw new \InvalidArgumentException(sprintf( 'Service with ID "%s" has already been registered', $serviceId)); } $this->instantiators[$serviceId] = $instantiator; $this->tags[$serviceId] = $tags; }
php
public function register($serviceId, \Closure $instantiator, array $tags = []) { if (isset($this->instantiators[$serviceId])) { throw new \InvalidArgumentException(sprintf( 'Service with ID "%s" has already been registered', $serviceId)); } $this->instantiators[$serviceId] = $instantiator; $this->tags[$serviceId] = $tags; }
[ "public", "function", "register", "(", "$", "serviceId", ",", "\\", "Closure", "$", "instantiator", ",", "array", "$", "tags", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "instantiators", "[", "$", "serviceId", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Service with ID \"%s\" has already been registered'", ",", "$", "serviceId", ")", ")", ";", "}", "$", "this", "->", "instantiators", "[", "$", "serviceId", "]", "=", "$", "instantiator", ";", "$", "this", "->", "tags", "[", "$", "serviceId", "]", "=", "$", "tags", ";", "}" ]
Register a service with the given ID and instantiator. The instantiator is a closure which accepts an instance of this container and returns a new instance of the service class. @param string $serviceId @param \Closure $instantiator @param string[][] $tags
[ "Register", "a", "service", "with", "the", "given", "ID", "and", "instantiator", "." ]
7acabddac1fd09cb58d4790443b6b791bf9f3095
https://github.com/phpbench/container/blob/7acabddac1fd09cb58d4790443b6b791bf9f3095/lib/Container.php#L168-L177
16,883
phpbench/container
lib/Container.php
Container.getParameter
public function getParameter($name) { if (!array_key_exists($name, $this->config)) { throw new \InvalidArgumentException(sprintf( 'Parameter "%s" has not been registered', $name )); } return $this->config[$name]; }
php
public function getParameter($name) { if (!array_key_exists($name, $this->config)) { throw new \InvalidArgumentException(sprintf( 'Parameter "%s" has not been registered', $name )); } return $this->config[$name]; }
[ "public", "function", "getParameter", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "config", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Parameter \"%s\" has not been registered'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "config", "[", "$", "name", "]", ";", "}" ]
Return the parameter with the given name. @param string $name @throws \InvalidArgumentException @return mixed
[ "Return", "the", "parameter", "with", "the", "given", "name", "." ]
7acabddac1fd09cb58d4790443b6b791bf9f3095
https://github.com/phpbench/container/blob/7acabddac1fd09cb58d4790443b6b791bf9f3095/lib/Container.php#L216-L226
16,884
ClanCats/Core
src/bundles/Database/Builder.php
Builder.escape_table
public function escape_table( &$query ) { $table = $query->table; if ( is_array( $table ) ) { reset($table); $table = key($table).' as '.$table[key($table)]; } return $this->escape( $table ); }
php
public function escape_table( &$query ) { $table = $query->table; if ( is_array( $table ) ) { reset($table); $table = key($table).' as '.$table[key($table)]; } return $this->escape( $table ); }
[ "public", "function", "escape_table", "(", "&", "$", "query", ")", "{", "$", "table", "=", "$", "query", "->", "table", ";", "if", "(", "is_array", "(", "$", "table", ")", ")", "{", "reset", "(", "$", "table", ")", ";", "$", "table", "=", "key", "(", "$", "table", ")", ".", "' as '", ".", "$", "table", "[", "key", "(", "$", "table", ")", "]", ";", "}", "return", "$", "this", "->", "escape", "(", "$", "table", ")", ";", "}" ]
Escape the table @param Query $query @return string
[ "Escape", "the", "table" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Builder.php#L145-L155
16,885
ClanCats/Core
src/bundles/Database/Builder.php
Builder.parameterize
public function parameterize( $params ) { foreach( $params as $key => $param ) { $params[$key] = $this->param( $param ); } return implode( ', ', $params ); }
php
public function parameterize( $params ) { foreach( $params as $key => $param ) { $params[$key] = $this->param( $param ); } return implode( ', ', $params ); }
[ "public", "function", "parameterize", "(", "$", "params", ")", "{", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "param", ")", "{", "$", "params", "[", "$", "key", "]", "=", "$", "this", "->", "param", "(", "$", "param", ")", ";", "}", "return", "implode", "(", "', '", ",", "$", "params", ")", ";", "}" ]
Convert data to parameters and bind them to the query @param array $params @return string
[ "Convert", "data", "to", "parameters", "and", "bind", "them", "to", "the", "query" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Builder.php#L163-L171
16,886
ClanCats/Core
src/bundles/Database/Builder.php
Builder.compile_insert
public function compile_insert( &$query ) { $build = ( $query->ignore ? 'insert ignore' : 'insert' ).' into '.$this->escape_table( $query ).' '; $value_collection = $query->values; // Get the array keys from the first array in the collection. // We use them as insert keys. $build .= '('.$this->escape_list( array_keys( reset( $value_collection ) ) ).') values '; // add the array values. foreach( $value_collection as $values ) { $build .= '('.$this->parameterize( $values ).'), '; } // cut the last comma away return substr( $build, 0, -2 ); }
php
public function compile_insert( &$query ) { $build = ( $query->ignore ? 'insert ignore' : 'insert' ).' into '.$this->escape_table( $query ).' '; $value_collection = $query->values; // Get the array keys from the first array in the collection. // We use them as insert keys. $build .= '('.$this->escape_list( array_keys( reset( $value_collection ) ) ).') values '; // add the array values. foreach( $value_collection as $values ) { $build .= '('.$this->parameterize( $values ).'), '; } // cut the last comma away return substr( $build, 0, -2 ); }
[ "public", "function", "compile_insert", "(", "&", "$", "query", ")", "{", "$", "build", "=", "(", "$", "query", "->", "ignore", "?", "'insert ignore'", ":", "'insert'", ")", ".", "' into '", ".", "$", "this", "->", "escape_table", "(", "$", "query", ")", ".", "' '", ";", "$", "value_collection", "=", "$", "query", "->", "values", ";", "// Get the array keys from the first array in the collection.", "// We use them as insert keys.", "$", "build", ".=", "'('", ".", "$", "this", "->", "escape_list", "(", "array_keys", "(", "reset", "(", "$", "value_collection", ")", ")", ")", ".", "') values '", ";", "// add the array values.", "foreach", "(", "$", "value_collection", "as", "$", "values", ")", "{", "$", "build", ".=", "'('", ".", "$", "this", "->", "parameterize", "(", "$", "values", ")", ".", "'), '", ";", "}", "// cut the last comma away", "return", "substr", "(", "$", "build", ",", "0", ",", "-", "2", ")", ";", "}" ]
Build an insert query @param Query $query @return string
[ "Build", "an", "insert", "query" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Builder.php#L179-L197
16,887
ClanCats/Core
src/bundles/Database/Builder.php
Builder.compile_update
public function compile_update( &$query ) { $build = 'update '.$this->escape_table( $query ).' set '; // add the array values. foreach( $query->values as $key => $value ) { $build .= $this->escape( $key ).' = '.$this->param( $value ).', '; } $build = substr( $build, 0, -2 ); $build .= $this->compile_where( $query ); $build .= $this->compile_limit( $query ); // cut the last comma away return $build; }
php
public function compile_update( &$query ) { $build = 'update '.$this->escape_table( $query ).' set '; // add the array values. foreach( $query->values as $key => $value ) { $build .= $this->escape( $key ).' = '.$this->param( $value ).', '; } $build = substr( $build, 0, -2 ); $build .= $this->compile_where( $query ); $build .= $this->compile_limit( $query ); // cut the last comma away return $build; }
[ "public", "function", "compile_update", "(", "&", "$", "query", ")", "{", "$", "build", "=", "'update '", ".", "$", "this", "->", "escape_table", "(", "$", "query", ")", ".", "' set '", ";", "// add the array values.", "foreach", "(", "$", "query", "->", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "build", ".=", "$", "this", "->", "escape", "(", "$", "key", ")", ".", "' = '", ".", "$", "this", "->", "param", "(", "$", "value", ")", ".", "', '", ";", "}", "$", "build", "=", "substr", "(", "$", "build", ",", "0", ",", "-", "2", ")", ";", "$", "build", ".=", "$", "this", "->", "compile_where", "(", "$", "query", ")", ";", "$", "build", ".=", "$", "this", "->", "compile_limit", "(", "$", "query", ")", ";", "// cut the last comma away", "return", "$", "build", ";", "}" ]
Build an update query @param Query $query @return string
[ "Build", "an", "update", "query" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Builder.php#L205-L221
16,888
ClanCats/Core
src/bundles/Database/Builder.php
Builder.compile_delete
public function compile_delete( &$query ) { $build = 'delete from '.$this->escape_table( $query ); $build .= $this->compile_where( $query ); $build .= $this->compile_limit( $query ); // cut the last comma away return $build; }
php
public function compile_delete( &$query ) { $build = 'delete from '.$this->escape_table( $query ); $build .= $this->compile_where( $query ); $build .= $this->compile_limit( $query ); // cut the last comma away return $build; }
[ "public", "function", "compile_delete", "(", "&", "$", "query", ")", "{", "$", "build", "=", "'delete from '", ".", "$", "this", "->", "escape_table", "(", "$", "query", ")", ";", "$", "build", ".=", "$", "this", "->", "compile_where", "(", "$", "query", ")", ";", "$", "build", ".=", "$", "this", "->", "compile_limit", "(", "$", "query", ")", ";", "// cut the last comma away", "return", "$", "build", ";", "}" ]
Build an delete query @param Query $query @return string
[ "Build", "an", "delete", "query" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Builder.php#L229-L238
16,889
ClanCats/Core
src/bundles/Database/Builder.php
Builder.compile_select
public function compile_select( &$query ) { $build = ( $query->distinct ? 'select distinct' : 'select' ).' '; if ( !empty( $query->fields ) ) { foreach( $query->fields as $key => $field ) { if ( !is_numeric( $key ) ) { $build .= $this->escape( $key ).' as '.$this->escape( $field ); } elseif ( is_array( $field ) ) { $build .= $this->escape( $field[0] ).' as '.$this->escape( $field[1] ); } else { $build .= $this->escape( $field ); } $build .= ', '; } $build = substr( $build, 0, -2 ); } else { $build .= '*'; } // append the table $build .= ' from '.$this->escape_table( $query ); // build the where stuff $build .= $this->compile_where( $query ); $build .= $this->compile_group( $query ); $build .= $this->compile_order( $query ); $build .= $this->compile_limit_with_offset( $query ); return $build; }
php
public function compile_select( &$query ) { $build = ( $query->distinct ? 'select distinct' : 'select' ).' '; if ( !empty( $query->fields ) ) { foreach( $query->fields as $key => $field ) { if ( !is_numeric( $key ) ) { $build .= $this->escape( $key ).' as '.$this->escape( $field ); } elseif ( is_array( $field ) ) { $build .= $this->escape( $field[0] ).' as '.$this->escape( $field[1] ); } else { $build .= $this->escape( $field ); } $build .= ', '; } $build = substr( $build, 0, -2 ); } else { $build .= '*'; } // append the table $build .= ' from '.$this->escape_table( $query ); // build the where stuff $build .= $this->compile_where( $query ); $build .= $this->compile_group( $query ); $build .= $this->compile_order( $query ); $build .= $this->compile_limit_with_offset( $query ); return $build; }
[ "public", "function", "compile_select", "(", "&", "$", "query", ")", "{", "$", "build", "=", "(", "$", "query", "->", "distinct", "?", "'select distinct'", ":", "'select'", ")", ".", "' '", ";", "if", "(", "!", "empty", "(", "$", "query", "->", "fields", ")", ")", "{", "foreach", "(", "$", "query", "->", "fields", "as", "$", "key", "=>", "$", "field", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "build", ".=", "$", "this", "->", "escape", "(", "$", "key", ")", ".", "' as '", ".", "$", "this", "->", "escape", "(", "$", "field", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "field", ")", ")", "{", "$", "build", ".=", "$", "this", "->", "escape", "(", "$", "field", "[", "0", "]", ")", ".", "' as '", ".", "$", "this", "->", "escape", "(", "$", "field", "[", "1", "]", ")", ";", "}", "else", "{", "$", "build", ".=", "$", "this", "->", "escape", "(", "$", "field", ")", ";", "}", "$", "build", ".=", "', '", ";", "}", "$", "build", "=", "substr", "(", "$", "build", ",", "0", ",", "-", "2", ")", ";", "}", "else", "{", "$", "build", ".=", "'*'", ";", "}", "// append the table", "$", "build", ".=", "' from '", ".", "$", "this", "->", "escape_table", "(", "$", "query", ")", ";", "// build the where stuff", "$", "build", ".=", "$", "this", "->", "compile_where", "(", "$", "query", ")", ";", "$", "build", ".=", "$", "this", "->", "compile_group", "(", "$", "query", ")", ";", "$", "build", ".=", "$", "this", "->", "compile_order", "(", "$", "query", ")", ";", "$", "build", ".=", "$", "this", "->", "compile_limit_with_offset", "(", "$", "query", ")", ";", "return", "$", "build", ";", "}" ]
Build a select @param Query $query @return string
[ "Build", "a", "select" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Builder.php#L246-L286
16,890
ClanCats/Core
src/bundles/Database/Builder.php
Builder.compile_where
public function compile_where( &$query ) { $build = ''; foreach( $query->wheres as $where ) { // to make nested wheres possible you can pass an closure // wich will create a new query where you can add your nested wheres if ( !isset( $where[2] ) && is_closure( $where[1] ) ) { $sub_query = new Query; call_user_func( $where[1], $sub_query ); // The parameters get added by the call of compile where $build .= ' '.$where[0].' ( '.substr( $this->compile_where( $sub_query ), 7 ).' )'; continue; } // when we have an array as where values we have // to parameterize them if ( is_array( $where[3] ) ) { $where[3] = '('.$this->parameterize( $where[3] ).')'; } else { $where[3] = $this->param( $where[3] ); } // we always need to escepe where 1 wich referrs to the key $where[1] = $this->escape( $where[1] ); // implode the beauty $build .= ' '.implode( ' ', $where ); } return $build; }
php
public function compile_where( &$query ) { $build = ''; foreach( $query->wheres as $where ) { // to make nested wheres possible you can pass an closure // wich will create a new query where you can add your nested wheres if ( !isset( $where[2] ) && is_closure( $where[1] ) ) { $sub_query = new Query; call_user_func( $where[1], $sub_query ); // The parameters get added by the call of compile where $build .= ' '.$where[0].' ( '.substr( $this->compile_where( $sub_query ), 7 ).' )'; continue; } // when we have an array as where values we have // to parameterize them if ( is_array( $where[3] ) ) { $where[3] = '('.$this->parameterize( $where[3] ).')'; } else { $where[3] = $this->param( $where[3] ); } // we always need to escepe where 1 wich referrs to the key $where[1] = $this->escape( $where[1] ); // implode the beauty $build .= ' '.implode( ' ', $where ); } return $build; }
[ "public", "function", "compile_where", "(", "&", "$", "query", ")", "{", "$", "build", "=", "''", ";", "foreach", "(", "$", "query", "->", "wheres", "as", "$", "where", ")", "{", "// to make nested wheres possible you can pass an closure ", "// wich will create a new query where you can add your nested wheres", "if", "(", "!", "isset", "(", "$", "where", "[", "2", "]", ")", "&&", "is_closure", "(", "$", "where", "[", "1", "]", ")", ")", "{", "$", "sub_query", "=", "new", "Query", ";", "call_user_func", "(", "$", "where", "[", "1", "]", ",", "$", "sub_query", ")", ";", "// The parameters get added by the call of compile where", "$", "build", ".=", "' '", ".", "$", "where", "[", "0", "]", ".", "' ( '", ".", "substr", "(", "$", "this", "->", "compile_where", "(", "$", "sub_query", ")", ",", "7", ")", ".", "' )'", ";", "continue", ";", "}", "// when we have an array as where values we have ", "// to parameterize them", "if", "(", "is_array", "(", "$", "where", "[", "3", "]", ")", ")", "{", "$", "where", "[", "3", "]", "=", "'('", ".", "$", "this", "->", "parameterize", "(", "$", "where", "[", "3", "]", ")", ".", "')'", ";", "}", "else", "{", "$", "where", "[", "3", "]", "=", "$", "this", "->", "param", "(", "$", "where", "[", "3", "]", ")", ";", "}", "// we always need to escepe where 1 wich referrs to the key", "$", "where", "[", "1", "]", "=", "$", "this", "->", "escape", "(", "$", "where", "[", "1", "]", ")", ";", "// implode the beauty", "$", "build", ".=", "' '", ".", "implode", "(", "' '", ",", "$", "where", ")", ";", "}", "return", "$", "build", ";", "}" ]
Build the where part @param Query $query @return string
[ "Build", "the", "where", "part" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Builder.php#L294-L333
16,891
ClanCats/Core
src/bundles/Database/Builder.php
Builder.compile_limit_with_offset
public function compile_limit_with_offset( &$query ) { if ( is_null( $query->limit ) ) { return ""; } return ' limit '.( (int) $query->offset ).', '.( (int) $query->limit ); }
php
public function compile_limit_with_offset( &$query ) { if ( is_null( $query->limit ) ) { return ""; } return ' limit '.( (int) $query->offset ).', '.( (int) $query->limit ); }
[ "public", "function", "compile_limit_with_offset", "(", "&", "$", "query", ")", "{", "if", "(", "is_null", "(", "$", "query", "->", "limit", ")", ")", "{", "return", "\"\"", ";", "}", "return", "' limit '", ".", "(", "(", "int", ")", "$", "query", "->", "offset", ")", ".", "', '", ".", "(", "(", "int", ")", "$", "query", "->", "limit", ")", ";", "}" ]
Build the limit and offset part @param Query $query @return string
[ "Build", "the", "limit", "and", "offset", "part" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Builder.php#L341-L349
16,892
vi-kon/laravel-auth
src/ViKon/Auth/AuthSeederTrait.php
AuthSeederTrait.newUserModel
protected function newUserModel($username, $password, array $options = []) { $user = new User(); $user->username = $username; $user->password = $password; foreach ($options as $key => $value) { $user->{$key} = $value; } return $user; }
php
protected function newUserModel($username, $password, array $options = []) { $user = new User(); $user->username = $username; $user->password = $password; foreach ($options as $key => $value) { $user->{$key} = $value; } return $user; }
[ "protected", "function", "newUserModel", "(", "$", "username", ",", "$", "password", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "user", "=", "new", "User", "(", ")", ";", "$", "user", "->", "username", "=", "$", "username", ";", "$", "user", "->", "password", "=", "$", "password", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "user", "->", "{", "$", "key", "}", "=", "$", "value", ";", "}", "return", "$", "user", ";", "}" ]
Create new user model instance @param string $username @param string $password @param array $options @return \ViKon\Auth\Model\User
[ "Create", "new", "user", "model", "instance" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/AuthSeederTrait.php#L28-L39
16,893
vi-kon/laravel-auth
src/ViKon/Auth/AuthSeederTrait.php
AuthSeederTrait.createUserModel
protected function createUserModel($username, $password, array $options = []) { $user = $this->newUserModel($username, $password, $options); $user->save(); return $user; }
php
protected function createUserModel($username, $password, array $options = []) { $user = $this->newUserModel($username, $password, $options); $user->save(); return $user; }
[ "protected", "function", "createUserModel", "(", "$", "username", ",", "$", "password", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "user", "=", "$", "this", "->", "newUserModel", "(", "$", "username", ",", "$", "password", ",", "$", "options", ")", ";", "$", "user", "->", "save", "(", ")", ";", "return", "$", "user", ";", "}" ]
Create and store in database new user model instance @param string $username @param string $password @param array $options @return \ViKon\Auth\Model\User
[ "Create", "and", "store", "in", "database", "new", "user", "model", "instance" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/AuthSeederTrait.php#L50-L56
16,894
vi-kon/laravel-auth
src/ViKon/Auth/AuthSeederTrait.php
AuthSeederTrait.createUserRecord
protected function createUserRecord($username, $password, array $options = []) { return [ // Username User::FIELD_USERNAME => $username, // Password User::FIELD_PASSWORD => bcrypt($password), // Email User::FIELD_EMAIL => array_key_exists(User::FIELD_EMAIL, $options) ? $options[User::FIELD_EMAIL] : $username . '@local . com', // Home User::FIELD_HOME => array_key_exists(User::FIELD_HOME, $options) ? $options[User::FIELD_HOME] : null, // Is blocked User::FIELD_BLOCKED => array_key_exists(User::FIELD_BLOCKED, $options) ? $options[User::FIELD_BLOCKED] : false, // Is static User::FIELD_STATIC => array_key_exists(User::FIELD_STATIC, $options) ? $options[User::FIELD_STATIC] : false, // Is hidden User::FIELD_HIDDEN => array_key_exists(User::FIELD_HIDDEN, $options) ? $options[User::FIELD_HIDDEN] : false, ]; }
php
protected function createUserRecord($username, $password, array $options = []) { return [ // Username User::FIELD_USERNAME => $username, // Password User::FIELD_PASSWORD => bcrypt($password), // Email User::FIELD_EMAIL => array_key_exists(User::FIELD_EMAIL, $options) ? $options[User::FIELD_EMAIL] : $username . '@local . com', // Home User::FIELD_HOME => array_key_exists(User::FIELD_HOME, $options) ? $options[User::FIELD_HOME] : null, // Is blocked User::FIELD_BLOCKED => array_key_exists(User::FIELD_BLOCKED, $options) ? $options[User::FIELD_BLOCKED] : false, // Is static User::FIELD_STATIC => array_key_exists(User::FIELD_STATIC, $options) ? $options[User::FIELD_STATIC] : false, // Is hidden User::FIELD_HIDDEN => array_key_exists(User::FIELD_HIDDEN, $options) ? $options[User::FIELD_HIDDEN] : false, ]; }
[ "protected", "function", "createUserRecord", "(", "$", "username", ",", "$", "password", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "[", "// Username", "User", "::", "FIELD_USERNAME", "=>", "$", "username", ",", "// Password", "User", "::", "FIELD_PASSWORD", "=>", "bcrypt", "(", "$", "password", ")", ",", "// Email", "User", "::", "FIELD_EMAIL", "=>", "array_key_exists", "(", "User", "::", "FIELD_EMAIL", ",", "$", "options", ")", "?", "$", "options", "[", "User", "::", "FIELD_EMAIL", "]", ":", "$", "username", ".", "'@local . com'", ",", "// Home", "User", "::", "FIELD_HOME", "=>", "array_key_exists", "(", "User", "::", "FIELD_HOME", ",", "$", "options", ")", "?", "$", "options", "[", "User", "::", "FIELD_HOME", "]", ":", "null", ",", "// Is blocked", "User", "::", "FIELD_BLOCKED", "=>", "array_key_exists", "(", "User", "::", "FIELD_BLOCKED", ",", "$", "options", ")", "?", "$", "options", "[", "User", "::", "FIELD_BLOCKED", "]", ":", "false", ",", "// Is static", "User", "::", "FIELD_STATIC", "=>", "array_key_exists", "(", "User", "::", "FIELD_STATIC", ",", "$", "options", ")", "?", "$", "options", "[", "User", "::", "FIELD_STATIC", "]", ":", "false", ",", "// Is hidden", "User", "::", "FIELD_HIDDEN", "=>", "array_key_exists", "(", "User", "::", "FIELD_HIDDEN", ",", "$", "options", ")", "?", "$", "options", "[", "User", "::", "FIELD_HIDDEN", "]", ":", "false", ",", "]", ";", "}" ]
Create single user record @param string $username authentication username @param string $password authentication password @param array $options additional column values @return array array with user field values
[ "Create", "single", "user", "record" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/AuthSeederTrait.php#L67-L95
16,895
vi-kon/laravel-auth
src/ViKon/Auth/AuthSeederTrait.php
AuthSeederTrait.newGroupModel
protected function newGroupModel($token, array $options = []) { $group = new Group(); $group->token = $token; foreach ($options as $key => $value) { $group->{$key} = $value; } return $group; }
php
protected function newGroupModel($token, array $options = []) { $group = new Group(); $group->token = $token; foreach ($options as $key => $value) { $group->{$key} = $value; } return $group; }
[ "protected", "function", "newGroupModel", "(", "$", "token", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "group", "=", "new", "Group", "(", ")", ";", "$", "group", "->", "token", "=", "$", "token", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "group", "->", "{", "$", "key", "}", "=", "$", "value", ";", "}", "return", "$", "group", ";", "}" ]
Create new group model instance @param string $token group token @param array $options additional column valuesF @return \ViKon\Auth\Model\Group
[ "Create", "new", "group", "model", "instance" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/AuthSeederTrait.php#L105-L115
16,896
vi-kon/laravel-auth
src/ViKon/Auth/AuthSeederTrait.php
AuthSeederTrait.createGroupModel
protected function createGroupModel($token, array $options = []) { $group = $this->newGroupModel($token, $options); $group->save(); return $group; }
php
protected function createGroupModel($token, array $options = []) { $group = $this->newGroupModel($token, $options); $group->save(); return $group; }
[ "protected", "function", "createGroupModel", "(", "$", "token", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "group", "=", "$", "this", "->", "newGroupModel", "(", "$", "token", ",", "$", "options", ")", ";", "$", "group", "->", "save", "(", ")", ";", "return", "$", "group", ";", "}" ]
Create and store in database new group model instance @param string $token group token @param array $options additional column values @return \ViKon\Auth\Model\Group
[ "Create", "and", "store", "in", "database", "new", "group", "model", "instance" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/AuthSeederTrait.php#L125-L131
16,897
vi-kon/laravel-auth
src/ViKon/Auth/AuthSeederTrait.php
AuthSeederTrait.newRoleModel
protected function newRoleModel($token, array $options = []) { $role = new Role(); $role->token = $token; foreach ($options as $key => $value) { $role->{$key} = $value; } return $role; }
php
protected function newRoleModel($token, array $options = []) { $role = new Role(); $role->token = $token; foreach ($options as $key => $value) { $role->{$key} = $value; } return $role; }
[ "protected", "function", "newRoleModel", "(", "$", "token", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "role", "=", "new", "Role", "(", ")", ";", "$", "role", "->", "token", "=", "$", "token", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "role", "->", "{", "$", "key", "}", "=", "$", "value", ";", "}", "return", "$", "role", ";", "}" ]
Create new role model instance @param string $token role token @param array $options additional column valuesF @return \ViKon\Auth\Model\Role
[ "Create", "new", "role", "model", "instance" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/AuthSeederTrait.php#L141-L151
16,898
vi-kon/laravel-auth
src/ViKon/Auth/AuthSeederTrait.php
AuthSeederTrait.createRoleModel
protected function createRoleModel($token, array $options = []) { $role = $this->newRoleModel($token, $options); $role->save(); return $role; }
php
protected function createRoleModel($token, array $options = []) { $role = $this->newRoleModel($token, $options); $role->save(); return $role; }
[ "protected", "function", "createRoleModel", "(", "$", "token", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "role", "=", "$", "this", "->", "newRoleModel", "(", "$", "token", ",", "$", "options", ")", ";", "$", "role", "->", "save", "(", ")", ";", "return", "$", "role", ";", "}" ]
Create and store in database new role model instance @param string $token role token @param array $options additional column values @return \ViKon\Auth\Model\Role
[ "Create", "and", "store", "in", "database", "new", "role", "model", "instance" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/AuthSeederTrait.php#L161-L167
16,899
vi-kon/laravel-auth
src/ViKon/Auth/AuthSeederTrait.php
AuthSeederTrait.newPermissionModel
protected function newPermissionModel($token, array $options = []) { $permission = new Permission(); $permission->token = $token; foreach ($options as $key => $value) { $permission->{$key} = $value; } return $permission; }
php
protected function newPermissionModel($token, array $options = []) { $permission = new Permission(); $permission->token = $token; foreach ($options as $key => $value) { $permission->{$key} = $value; } return $permission; }
[ "protected", "function", "newPermissionModel", "(", "$", "token", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "permission", "=", "new", "Permission", "(", ")", ";", "$", "permission", "->", "token", "=", "$", "token", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "permission", "->", "{", "$", "key", "}", "=", "$", "value", ";", "}", "return", "$", "permission", ";", "}" ]
Create new permission model instance @param string $token @param array $options @return \ViKon\Auth\Model\Permission
[ "Create", "new", "permission", "model", "instance" ]
501c20128f43347a2ca271a53435297f9ef7f567
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/AuthSeederTrait.php#L177-L187