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
223,100
rpayonline/rpayonline-lite-php
lib/Util/Options.php
Options.parse
public static function parse($opts) { if ($opts instanceof self) { return $opts; } if (is_null($opts)) { return new Options(null, array()); } if (is_array($opts)) { $key = null; if (array_key_exists('api_key', $opts)) { $key = $opts['api_key']; unset($opts['api_key']); } return new Options($key, $opts); } else { throw new Error\InvalidOption('Options have to be array.'); } }
php
public static function parse($opts) { if ($opts instanceof self) { return $opts; } if (is_null($opts)) { return new Options(null, array()); } if (is_array($opts)) { $key = null; if (array_key_exists('api_key', $opts)) { $key = $opts['api_key']; unset($opts['api_key']); } return new Options($key, $opts); } else { throw new Error\InvalidOption('Options have to be array.'); } }
[ "public", "static", "function", "parse", "(", "$", "opts", ")", "{", "if", "(", "$", "opts", "instanceof", "self", ")", "{", "return", "$", "opts", ";", "}", "if", "(", "is_null", "(", "$", "opts", ")", ")", "{", "return", "new", "Options", "(", "null", ",", "array", "(", ")", ")", ";", "}", "if", "(", "is_array", "(", "$", "opts", ")", ")", "{", "$", "key", "=", "null", ";", "if", "(", "array_key_exists", "(", "'api_key'", ",", "$", "opts", ")", ")", "{", "$", "key", "=", "$", "opts", "[", "'api_key'", "]", ";", "unset", "(", "$", "opts", "[", "'api_key'", "]", ")", ";", "}", "return", "new", "Options", "(", "$", "key", ",", "$", "opts", ")", ";", "}", "else", "{", "throw", "new", "Error", "\\", "InvalidOption", "(", "'Options have to be array.'", ")", ";", "}", "}" ]
Load options from array. @param array $opts Request header. @return Options New instance having the given configuration. @throws Error\InvalidOption
[ "Load", "options", "from", "array", "." ]
eed6fc6259668f98a08b31217b4bb5ba5bac09d8
https://github.com/rpayonline/rpayonline-lite-php/blob/eed6fc6259668f98a08b31217b4bb5ba5bac09d8/lib/Util/Options.php#L59-L77
223,101
emilio/php-router
src/Router/Router.php
Router.add
public function add($expr, $callback, $methods = null) { $this->all($expr, $callback, $methods); }
php
public function add($expr, $callback, $methods = null) { $this->all($expr, $callback, $methods); }
[ "public", "function", "add", "(", "$", "expr", ",", "$", "callback", ",", "$", "methods", "=", "null", ")", "{", "$", "this", "->", "all", "(", "$", "expr", ",", "$", "callback", ",", "$", "methods", ")", ";", "}" ]
Alias for all @param string $expr @param callable $callback @param null|array $methods
[ "Alias", "for", "all" ]
55ae2f3a6417a2327715402edb7b404001c5a04f
https://github.com/emilio/php-router/blob/55ae2f3a6417a2327715402edb7b404001c5a04f/src/Router/Router.php#L53-L56
223,102
emilio/php-router
src/Router/Router.php
Router.route
public function route() { foreach ($this->routes as $route) { if ($route->matches($this->path)) { return $route->exec(); } } throw new RouteNotFoundException("No routes matching {$this->path}"); }
php
public function route() { foreach ($this->routes as $route) { if ($route->matches($this->path)) { return $route->exec(); } } throw new RouteNotFoundException("No routes matching {$this->path}"); }
[ "public", "function", "route", "(", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "if", "(", "$", "route", "->", "matches", "(", "$", "this", "->", "path", ")", ")", "{", "return", "$", "route", "->", "exec", "(", ")", ";", "}", "}", "throw", "new", "RouteNotFoundException", "(", "\"No routes matching {$this->path}\"", ")", ";", "}" ]
Test all routes until any of them matches @throws RouteNotFoundException if the route doesn't match with any of the registered routes
[ "Test", "all", "routes", "until", "any", "of", "them", "matches" ]
55ae2f3a6417a2327715402edb7b404001c5a04f
https://github.com/emilio/php-router/blob/55ae2f3a6417a2327715402edb7b404001c5a04f/src/Router/Router.php#L118-L127
223,103
emilio/php-router
src/Router/Router.php
Router.url
public function url($path = null) { if ($path === null) { $path = $this->path; } return $this->base_path . $path; }
php
public function url($path = null) { if ($path === null) { $path = $this->path; } return $this->base_path . $path; }
[ "public", "function", "url", "(", "$", "path", "=", "null", ")", "{", "if", "(", "$", "path", "===", "null", ")", "{", "$", "path", "=", "$", "this", "->", "path", ";", "}", "return", "$", "this", "->", "base_path", ".", "$", "path", ";", "}" ]
Get the current url or the url to a path @param string $path @return string
[ "Get", "the", "current", "url", "or", "the", "url", "to", "a", "path" ]
55ae2f3a6417a2327715402edb7b404001c5a04f
https://github.com/emilio/php-router/blob/55ae2f3a6417a2327715402edb7b404001c5a04f/src/Router/Router.php#L135-L142
223,104
emilio/php-router
src/Router/Router.php
Router.redirect
public function redirect($from_path, $to_path, $code = 302) { $this->all($from_path, function () use ($to_path, $code) { http_response_code($code); header("Location: {$to_path}"); }); }
php
public function redirect($from_path, $to_path, $code = 302) { $this->all($from_path, function () use ($to_path, $code) { http_response_code($code); header("Location: {$to_path}"); }); }
[ "public", "function", "redirect", "(", "$", "from_path", ",", "$", "to_path", ",", "$", "code", "=", "302", ")", "{", "$", "this", "->", "all", "(", "$", "from_path", ",", "function", "(", ")", "use", "(", "$", "to_path", ",", "$", "code", ")", "{", "http_response_code", "(", "$", "code", ")", ";", "header", "(", "\"Location: {$to_path}\"", ")", ";", "}", ")", ";", "}" ]
Redirect from one url to another @param string $from_path @param string $to_path @param int $code
[ "Redirect", "from", "one", "url", "to", "another" ]
55ae2f3a6417a2327715402edb7b404001c5a04f
https://github.com/emilio/php-router/blob/55ae2f3a6417a2327715402edb7b404001c5a04f/src/Router/Router.php#L151-L157
223,105
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.initEnvironment
protected function initEnvironment() { $path = getcwd(); if (!is_file("$path/.env")) { return; } $dotenv = new \Dotenv\Dotenv($path); if ($this->dotEnvOverload) { $dotenv->overload(); } else { $dotenv->load(); } }
php
protected function initEnvironment() { $path = getcwd(); if (!is_file("$path/.env")) { return; } $dotenv = new \Dotenv\Dotenv($path); if ($this->dotEnvOverload) { $dotenv->overload(); } else { $dotenv->load(); } }
[ "protected", "function", "initEnvironment", "(", ")", "{", "$", "path", "=", "getcwd", "(", ")", ";", "if", "(", "!", "is_file", "(", "\"$path/.env\"", ")", ")", "{", "return", ";", "}", "$", "dotenv", "=", "new", "\\", "Dotenv", "\\", "Dotenv", "(", "$", "path", ")", ";", "if", "(", "$", "this", "->", "dotEnvOverload", ")", "{", "$", "dotenv", "->", "overload", "(", ")", ";", "}", "else", "{", "$", "dotenv", "->", "load", "(", ")", ";", "}", "}" ]
Initialize Environment variables by .env file Overload can be activated by setting $this->dotEnvOverload = true; in your RoboFile
[ "Initialize", "Environment", "variables", "by", ".", "env", "file" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L70-L82
223,106
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.taskMagentoCleanVarDirs
protected function taskMagentoCleanVarDirs() { $magentoDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_APP_DIR); $varDirs = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_CLEAN_DIRS); $dirs = []; foreach ($varDirs as $dir) { $dirPath = $dir; if (!empty($magentoDir)) { $dirPath = "{$magentoDir}/$dir"; } if (!is_dir($dirPath)) { $this->logger->notice("File or directory <info>$dirPath</info> does not exist!"); continue; } $dirs[] = $dirPath; } return $this->taskCleanDir($dirs); }
php
protected function taskMagentoCleanVarDirs() { $magentoDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_APP_DIR); $varDirs = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_CLEAN_DIRS); $dirs = []; foreach ($varDirs as $dir) { $dirPath = $dir; if (!empty($magentoDir)) { $dirPath = "{$magentoDir}/$dir"; } if (!is_dir($dirPath)) { $this->logger->notice("File or directory <info>$dirPath</info> does not exist!"); continue; } $dirs[] = $dirPath; } return $this->taskCleanDir($dirs); }
[ "protected", "function", "taskMagentoCleanVarDirs", "(", ")", "{", "$", "magentoDir", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_APP_DIR", ")", ";", "$", "varDirs", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_CLEAN_DIRS", ")", ";", "$", "dirs", "=", "[", "]", ";", "foreach", "(", "$", "varDirs", "as", "$", "dir", ")", "{", "$", "dirPath", "=", "$", "dir", ";", "if", "(", "!", "empty", "(", "$", "magentoDir", ")", ")", "{", "$", "dirPath", "=", "\"{$magentoDir}/$dir\"", ";", "}", "if", "(", "!", "is_dir", "(", "$", "dirPath", ")", ")", "{", "$", "this", "->", "logger", "->", "notice", "(", "\"File or directory <info>$dirPath</info> does not exist!\"", ")", ";", "continue", ";", "}", "$", "dirs", "[", "]", "=", "$", "dirPath", ";", "}", "return", "$", "this", "->", "taskCleanDir", "(", "$", "dirs", ")", ";", "}" ]
Build Task to clean all var dirs @return \Robo\Task\Filesystem\CleanDir
[ "Build", "Task", "to", "clean", "all", "var", "dirs" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L158-L177
223,107
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.taskMysqlCreateDatabase
protected function taskMysqlCreateDatabase($dropDatabase = false) { $dbName = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-name'); $sqlDropDb = "DROP DATABASE `{$dbName}`"; $sqlCreateDb = "CREATE DATABASE IF NOT EXISTS `{$dbName}`"; /** @var RoboFile|CollectionBuilder $collection */ $collection = $this->collectionBuilder(); // Skip database drop and create incase mysql_bin is not set $mysqlBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_MYSQL_BIN); if (empty($mysqlBin)) { $collection->progressMessage('mySQL database managing skipped'); return $collection; } // Drop Database if ($dropDatabase === true) { $taskDropDatabase = $this->taskMysqlCommand(); $taskDropDatabase->option('-e', $sqlDropDb); $collection->progressMessage('Drop Database (as requested)'); $collection->addTask($taskDropDatabase); } // Create DB $createDatabase = $this->taskMysqlCommand(); $createDatabase->option('-e', $sqlCreateDb); $collection->progressMessage('Create Database'); $collection->addTask($createDatabase); return $collection; }
php
protected function taskMysqlCreateDatabase($dropDatabase = false) { $dbName = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-name'); $sqlDropDb = "DROP DATABASE `{$dbName}`"; $sqlCreateDb = "CREATE DATABASE IF NOT EXISTS `{$dbName}`"; /** @var RoboFile|CollectionBuilder $collection */ $collection = $this->collectionBuilder(); // Skip database drop and create incase mysql_bin is not set $mysqlBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_MYSQL_BIN); if (empty($mysqlBin)) { $collection->progressMessage('mySQL database managing skipped'); return $collection; } // Drop Database if ($dropDatabase === true) { $taskDropDatabase = $this->taskMysqlCommand(); $taskDropDatabase->option('-e', $sqlDropDb); $collection->progressMessage('Drop Database (as requested)'); $collection->addTask($taskDropDatabase); } // Create DB $createDatabase = $this->taskMysqlCommand(); $createDatabase->option('-e', $sqlCreateDb); $collection->progressMessage('Create Database'); $collection->addTask($createDatabase); return $collection; }
[ "protected", "function", "taskMysqlCreateDatabase", "(", "$", "dropDatabase", "=", "false", ")", "{", "$", "dbName", "=", "$", "this", "->", "config", "(", "CONFIG", "::", "KEY_BUILD", ".", "'/'", ".", "Config", "::", "KEY_DB", ".", "'/db-name'", ")", ";", "$", "sqlDropDb", "=", "\"DROP DATABASE `{$dbName}`\"", ";", "$", "sqlCreateDb", "=", "\"CREATE DATABASE IF NOT EXISTS `{$dbName}`\"", ";", "/** @var RoboFile|CollectionBuilder $collection */", "$", "collection", "=", "$", "this", "->", "collectionBuilder", "(", ")", ";", "// Skip database drop and create incase mysql_bin is not set", "$", "mysqlBin", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_MYSQL_BIN", ")", ";", "if", "(", "empty", "(", "$", "mysqlBin", ")", ")", "{", "$", "collection", "->", "progressMessage", "(", "'mySQL database managing skipped'", ")", ";", "return", "$", "collection", ";", "}", "// Drop Database", "if", "(", "$", "dropDatabase", "===", "true", ")", "{", "$", "taskDropDatabase", "=", "$", "this", "->", "taskMysqlCommand", "(", ")", ";", "$", "taskDropDatabase", "->", "option", "(", "'-e'", ",", "$", "sqlDropDb", ")", ";", "$", "collection", "->", "progressMessage", "(", "'Drop Database (as requested)'", ")", ";", "$", "collection", "->", "addTask", "(", "$", "taskDropDatabase", ")", ";", "}", "// Create DB", "$", "createDatabase", "=", "$", "this", "->", "taskMysqlCommand", "(", ")", ";", "$", "createDatabase", "->", "option", "(", "'-e'", ",", "$", "sqlCreateDb", ")", ";", "$", "collection", "->", "progressMessage", "(", "'Create Database'", ")", ";", "$", "collection", "->", "addTask", "(", "$", "createDatabase", ")", ";", "return", "$", "collection", ";", "}" ]
Build Task to create database @param bool $dropDatabase @return \Robo\Collection\CollectionBuilder
[ "Build", "Task", "to", "create", "database" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L214-L249
223,108
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.taskMagentoSetProductionMode
protected function taskMagentoSetProductionMode() { $magentoDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_APP_DIR); $task = $this->taskMagentoDeploySetModeTask(); $task->modeProduction(); $task->skipCompilation(); $task->dir($magentoDir); return $task; }
php
protected function taskMagentoSetProductionMode() { $magentoDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_APP_DIR); $task = $this->taskMagentoDeploySetModeTask(); $task->modeProduction(); $task->skipCompilation(); $task->dir($magentoDir); return $task; }
[ "protected", "function", "taskMagentoSetProductionMode", "(", ")", "{", "$", "magentoDir", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_APP_DIR", ")", ";", "$", "task", "=", "$", "this", "->", "taskMagentoDeploySetModeTask", "(", ")", ";", "$", "task", "->", "modeProduction", "(", ")", ";", "$", "task", "->", "skipCompilation", "(", ")", ";", "$", "task", "->", "dir", "(", "$", "magentoDir", ")", ";", "return", "$", "task", ";", "}" ]
Build Task to set magento to production mode @return \Mwltr\Robo\Magento2\Task\DeploySetModeTask
[ "Build", "Task", "to", "set", "magento", "to", "production", "mode" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L297-L307
223,109
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.taskMagentoSetupDiCompile
protected function taskMagentoSetupDiCompile() { $magentoDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_APP_DIR); $task = $this->taskMagentoSetupDiCompileTask(); $task->dir($magentoDir); return $task; }
php
protected function taskMagentoSetupDiCompile() { $magentoDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_APP_DIR); $task = $this->taskMagentoSetupDiCompileTask(); $task->dir($magentoDir); return $task; }
[ "protected", "function", "taskMagentoSetupDiCompile", "(", ")", "{", "$", "magentoDir", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_APP_DIR", ")", ";", "$", "task", "=", "$", "this", "->", "taskMagentoSetupDiCompileTask", "(", ")", ";", "$", "task", "->", "dir", "(", "$", "magentoDir", ")", ";", "return", "$", "task", ";", "}" ]
Build Task to run magento setup di compile @return \Mwltr\Robo\Magento2\Task\SetupDiCompileTask
[ "Build", "Task", "to", "run", "magento", "setup", "di", "compile" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L314-L322
223,110
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.taskMagentoSetupStaticContentDeploy
protected function taskMagentoSetupStaticContentDeploy() { /** @var array $themes */ $themes = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_THEMES); $magentoDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_APP_DIR); /** @var RoboFile|CollectionBuilder $collection */ $collection = $this->collectionBuilder(); foreach ($themes as $theme) { if (!array_key_exists('code', $theme)) { throw new \RuntimeException('invalid theme config: code is missing'); } $task = $collection->taskMagentoSetupStaticContentDeployTask(); $task->addTheme($theme['code']); $task->addLanguages($theme['languages']); $task->jobs(16); $task->dir($magentoDir); } return $collection; }
php
protected function taskMagentoSetupStaticContentDeploy() { /** @var array $themes */ $themes = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_THEMES); $magentoDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_APP_DIR); /** @var RoboFile|CollectionBuilder $collection */ $collection = $this->collectionBuilder(); foreach ($themes as $theme) { if (!array_key_exists('code', $theme)) { throw new \RuntimeException('invalid theme config: code is missing'); } $task = $collection->taskMagentoSetupStaticContentDeployTask(); $task->addTheme($theme['code']); $task->addLanguages($theme['languages']); $task->jobs(16); $task->dir($magentoDir); } return $collection; }
[ "protected", "function", "taskMagentoSetupStaticContentDeploy", "(", ")", "{", "/** @var array $themes */", "$", "themes", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_THEMES", ")", ";", "$", "magentoDir", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_APP_DIR", ")", ";", "/** @var RoboFile|CollectionBuilder $collection */", "$", "collection", "=", "$", "this", "->", "collectionBuilder", "(", ")", ";", "foreach", "(", "$", "themes", "as", "$", "theme", ")", "{", "if", "(", "!", "array_key_exists", "(", "'code'", ",", "$", "theme", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'invalid theme config: code is missing'", ")", ";", "}", "$", "task", "=", "$", "collection", "->", "taskMagentoSetupStaticContentDeployTask", "(", ")", ";", "$", "task", "->", "addTheme", "(", "$", "theme", "[", "'code'", "]", ")", ";", "$", "task", "->", "addLanguages", "(", "$", "theme", "[", "'languages'", "]", ")", ";", "$", "task", "->", "jobs", "(", "16", ")", ";", "$", "task", "->", "dir", "(", "$", "magentoDir", ")", ";", "}", "return", "$", "collection", ";", "}" ]
Build Task to run magento setup static content deploy @return \Robo\Collection\CollectionBuilder @throws \RuntimeException
[ "Build", "Task", "to", "run", "magento", "setup", "static", "content", "deploy" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L355-L376
223,111
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.taskArtifactCreatePackages
protected function taskArtifactCreatePackages() { $rootDir = getcwd(); $tarBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_TAR_BIN); $gitDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_GIT_DIR); $artifactsDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_ARTIFACTS_DIR); /** @var array $artifacts */ $artifacts = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_ARTIFACTS); /** @var RoboFile|CollectionBuilder $collection */ $collection = $this->collectionBuilder(); $collection->progressMessage('cleanup old packages'); // Ensure artifacts-dir is present $collection->taskFilesystemStack()->mkdir($artifactsDir); // Cleanup old tars foreach ($artifacts as $artifactName => $artifactConfig) { $file = "$artifactsDir/$artifactName"; $task = $collection->taskFilesystemStack(); $task->remove($file); } // Create Tars $collection->progressMessage('creating packages'); foreach ($artifacts as $artifactName => $artifactConfig) { $dir = $artifactConfig['dir']; $artifactPath = "$rootDir/$artifactsDir/$artifactName"; $tarOptions = ''; if (array_key_exists('options', $artifactConfig)) { $options = $artifactConfig['options']; $tarOptions = implode(' ', $options); } $tarCmd = "$tarBin $tarOptions -czf $artifactPath $dir"; $task = $collection->taskExec($tarCmd); $task->dir($gitDir); } return $collection; }
php
protected function taskArtifactCreatePackages() { $rootDir = getcwd(); $tarBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_TAR_BIN); $gitDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_GIT_DIR); $artifactsDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_ARTIFACTS_DIR); /** @var array $artifacts */ $artifacts = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_ARTIFACTS); /** @var RoboFile|CollectionBuilder $collection */ $collection = $this->collectionBuilder(); $collection->progressMessage('cleanup old packages'); // Ensure artifacts-dir is present $collection->taskFilesystemStack()->mkdir($artifactsDir); // Cleanup old tars foreach ($artifacts as $artifactName => $artifactConfig) { $file = "$artifactsDir/$artifactName"; $task = $collection->taskFilesystemStack(); $task->remove($file); } // Create Tars $collection->progressMessage('creating packages'); foreach ($artifacts as $artifactName => $artifactConfig) { $dir = $artifactConfig['dir']; $artifactPath = "$rootDir/$artifactsDir/$artifactName"; $tarOptions = ''; if (array_key_exists('options', $artifactConfig)) { $options = $artifactConfig['options']; $tarOptions = implode(' ', $options); } $tarCmd = "$tarBin $tarOptions -czf $artifactPath $dir"; $task = $collection->taskExec($tarCmd); $task->dir($gitDir); } return $collection; }
[ "protected", "function", "taskArtifactCreatePackages", "(", ")", "{", "$", "rootDir", "=", "getcwd", "(", ")", ";", "$", "tarBin", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_TAR_BIN", ")", ";", "$", "gitDir", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_GIT_DIR", ")", ";", "$", "artifactsDir", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_ARTIFACTS_DIR", ")", ";", "/** @var array $artifacts */", "$", "artifacts", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_ARTIFACTS", ")", ";", "/** @var RoboFile|CollectionBuilder $collection */", "$", "collection", "=", "$", "this", "->", "collectionBuilder", "(", ")", ";", "$", "collection", "->", "progressMessage", "(", "'cleanup old packages'", ")", ";", "// Ensure artifacts-dir is present", "$", "collection", "->", "taskFilesystemStack", "(", ")", "->", "mkdir", "(", "$", "artifactsDir", ")", ";", "// Cleanup old tars", "foreach", "(", "$", "artifacts", "as", "$", "artifactName", "=>", "$", "artifactConfig", ")", "{", "$", "file", "=", "\"$artifactsDir/$artifactName\"", ";", "$", "task", "=", "$", "collection", "->", "taskFilesystemStack", "(", ")", ";", "$", "task", "->", "remove", "(", "$", "file", ")", ";", "}", "// Create Tars", "$", "collection", "->", "progressMessage", "(", "'creating packages'", ")", ";", "foreach", "(", "$", "artifacts", "as", "$", "artifactName", "=>", "$", "artifactConfig", ")", "{", "$", "dir", "=", "$", "artifactConfig", "[", "'dir'", "]", ";", "$", "artifactPath", "=", "\"$rootDir/$artifactsDir/$artifactName\"", ";", "$", "tarOptions", "=", "''", ";", "if", "(", "array_key_exists", "(", "'options'", ",", "$", "artifactConfig", ")", ")", "{", "$", "options", "=", "$", "artifactConfig", "[", "'options'", "]", ";", "$", "tarOptions", "=", "implode", "(", "' '", ",", "$", "options", ")", ";", "}", "$", "tarCmd", "=", "\"$tarBin $tarOptions -czf $artifactPath $dir\"", ";", "$", "task", "=", "$", "collection", "->", "taskExec", "(", "$", "tarCmd", ")", ";", "$", "task", "->", "dir", "(", "$", "gitDir", ")", ";", "}", "return", "$", "collection", ";", "}" ]
Build Task for artifact creation @return \Robo\Collection\CollectionBuilder
[ "Build", "Task", "for", "artifact", "creation" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L383-L427
223,112
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.taskDeployerDeploy
protected function taskDeployerDeploy($stage, $branch) { $deployerBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_DEPLOYER_BIN); $task = $this->taskDeployerDeployTask($deployerBin); if ($this->isTag($branch)) { $task->tag($branch); } else { $task->branch($branch); } $task->stage($stage); // Map Verbosity $output = $this->output(); if ($output->isDebug()) { $task->debug(); } elseif ($output->isVeryVerbose()) { $task->veryVerbose(); } elseif ($output->isVerbose()) { $task->verbose(); } elseif ($output->isQuiet()) { $task->quiet(); } return $task; }
php
protected function taskDeployerDeploy($stage, $branch) { $deployerBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_DEPLOYER_BIN); $task = $this->taskDeployerDeployTask($deployerBin); if ($this->isTag($branch)) { $task->tag($branch); } else { $task->branch($branch); } $task->stage($stage); // Map Verbosity $output = $this->output(); if ($output->isDebug()) { $task->debug(); } elseif ($output->isVeryVerbose()) { $task->veryVerbose(); } elseif ($output->isVerbose()) { $task->verbose(); } elseif ($output->isQuiet()) { $task->quiet(); } return $task; }
[ "protected", "function", "taskDeployerDeploy", "(", "$", "stage", ",", "$", "branch", ")", "{", "$", "deployerBin", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_DEPLOYER_BIN", ")", ";", "$", "task", "=", "$", "this", "->", "taskDeployerDeployTask", "(", "$", "deployerBin", ")", ";", "if", "(", "$", "this", "->", "isTag", "(", "$", "branch", ")", ")", "{", "$", "task", "->", "tag", "(", "$", "branch", ")", ";", "}", "else", "{", "$", "task", "->", "branch", "(", "$", "branch", ")", ";", "}", "$", "task", "->", "stage", "(", "$", "stage", ")", ";", "// Map Verbosity", "$", "output", "=", "$", "this", "->", "output", "(", ")", ";", "if", "(", "$", "output", "->", "isDebug", "(", ")", ")", "{", "$", "task", "->", "debug", "(", ")", ";", "}", "elseif", "(", "$", "output", "->", "isVeryVerbose", "(", ")", ")", "{", "$", "task", "->", "veryVerbose", "(", ")", ";", "}", "elseif", "(", "$", "output", "->", "isVerbose", "(", ")", ")", "{", "$", "task", "->", "verbose", "(", ")", ";", "}", "elseif", "(", "$", "output", "->", "isQuiet", "(", ")", ")", "{", "$", "task", "->", "quiet", "(", ")", ";", "}", "return", "$", "task", ";", "}" ]
Build Task for deployer deploy @param string $stage @param string $branch @return \Mwltr\Robo\Deployer\Task\DeployTask
[ "Build", "Task", "for", "deployer", "deploy" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L437-L464
223,113
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.taskMysqlCommand
protected function taskMysqlCommand() { $mysqlBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_MYSQL_BIN); $dbHost = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-host'); $dbUser = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-user'); $dbPass = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-password'); $hostParts = explode(':', $dbHost); $dbPort = null; if (count($hostParts) === 2) { $dbPort = array_pop($hostParts); $dbHost = array_pop($hostParts); } $createDatabase = $this->taskExec($mysqlBin); $createDatabase->option('-h', $dbHost); if ($dbPort !== null) { $createDatabase->option('-P', $dbPort); } $createDatabase->option('-u', $dbUser); if ($dbPass) { $createDatabase->option("-p$dbPass"); } return $createDatabase; }
php
protected function taskMysqlCommand() { $mysqlBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_MYSQL_BIN); $dbHost = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-host'); $dbUser = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-user'); $dbPass = $this->config(CONFIG::KEY_BUILD . '/' . Config::KEY_DB . '/db-password'); $hostParts = explode(':', $dbHost); $dbPort = null; if (count($hostParts) === 2) { $dbPort = array_pop($hostParts); $dbHost = array_pop($hostParts); } $createDatabase = $this->taskExec($mysqlBin); $createDatabase->option('-h', $dbHost); if ($dbPort !== null) { $createDatabase->option('-P', $dbPort); } $createDatabase->option('-u', $dbUser); if ($dbPass) { $createDatabase->option("-p$dbPass"); } return $createDatabase; }
[ "protected", "function", "taskMysqlCommand", "(", ")", "{", "$", "mysqlBin", "=", "$", "this", "->", "config", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_MYSQL_BIN", ")", ";", "$", "dbHost", "=", "$", "this", "->", "config", "(", "CONFIG", "::", "KEY_BUILD", ".", "'/'", ".", "Config", "::", "KEY_DB", ".", "'/db-host'", ")", ";", "$", "dbUser", "=", "$", "this", "->", "config", "(", "CONFIG", "::", "KEY_BUILD", ".", "'/'", ".", "Config", "::", "KEY_DB", ".", "'/db-user'", ")", ";", "$", "dbPass", "=", "$", "this", "->", "config", "(", "CONFIG", "::", "KEY_BUILD", ".", "'/'", ".", "Config", "::", "KEY_DB", ".", "'/db-password'", ")", ";", "$", "hostParts", "=", "explode", "(", "':'", ",", "$", "dbHost", ")", ";", "$", "dbPort", "=", "null", ";", "if", "(", "count", "(", "$", "hostParts", ")", "===", "2", ")", "{", "$", "dbPort", "=", "array_pop", "(", "$", "hostParts", ")", ";", "$", "dbHost", "=", "array_pop", "(", "$", "hostParts", ")", ";", "}", "$", "createDatabase", "=", "$", "this", "->", "taskExec", "(", "$", "mysqlBin", ")", ";", "$", "createDatabase", "->", "option", "(", "'-h'", ",", "$", "dbHost", ")", ";", "if", "(", "$", "dbPort", "!==", "null", ")", "{", "$", "createDatabase", "->", "option", "(", "'-P'", ",", "$", "dbPort", ")", ";", "}", "$", "createDatabase", "->", "option", "(", "'-u'", ",", "$", "dbUser", ")", ";", "if", "(", "$", "dbPass", ")", "{", "$", "createDatabase", "->", "option", "(", "\"-p$dbPass\"", ")", ";", "}", "return", "$", "createDatabase", ";", "}" ]
Create a mysql Command @return \Robo\Task\Base\Exec
[ "Create", "a", "mysql", "Command" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L471-L498
223,114
mwr/magedeploy2
src/Robo/RoboTasks.php
RoboTasks.createTask
protected function createTask() { $task = \call_user_func_array(['parent', 'task'], \func_get_args()); $task->setInput($this->input()); $task->setOutput($this->output()); return $task; }
php
protected function createTask() { $task = \call_user_func_array(['parent', 'task'], \func_get_args()); $task->setInput($this->input()); $task->setOutput($this->output()); return $task; }
[ "protected", "function", "createTask", "(", ")", "{", "$", "task", "=", "\\", "call_user_func_array", "(", "[", "'parent'", ",", "'task'", "]", ",", "\\", "func_get_args", "(", ")", ")", ";", "$", "task", "->", "setInput", "(", "$", "this", "->", "input", "(", ")", ")", ";", "$", "task", "->", "setOutput", "(", "$", "this", "->", "output", "(", ")", ")", ";", "return", "$", "task", ";", "}" ]
Create a Task and transfer input and output instances This is needed if you have task that needs the current input / output @return \Robo\Contract\TaskInterface
[ "Create", "a", "Task", "and", "transfer", "input", "and", "output", "instances" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Robo/RoboTasks.php#L541-L548
223,115
StyleCI/SDK
src/Client.php
Client.get
protected function get(string $uri, array $query = []) { $response = $this->client->request('GET', $uri, $query ? ['query' => $query] : []); return json_decode((string) $response->getBody(), true); }
php
protected function get(string $uri, array $query = []) { $response = $this->client->request('GET', $uri, $query ? ['query' => $query] : []); return json_decode((string) $response->getBody(), true); }
[ "protected", "function", "get", "(", "string", "$", "uri", ",", "array", "$", "query", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "request", "(", "'GET'", ",", "$", "uri", ",", "$", "query", "?", "[", "'query'", "=>", "$", "query", "]", ":", "[", "]", ")", ";", "return", "json_decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "}" ]
Send a get request, and parse the result as json. @param string $uri @param array $query @return array
[ "Send", "a", "get", "request", "and", "parse", "the", "result", "as", "json", "." ]
efa64d0aef64522cb8f504a94c828ba68f8edd55
https://github.com/StyleCI/SDK/blob/efa64d0aef64522cb8f504a94c828ba68f8edd55/src/Client.php#L114-L119
223,116
mwr/magedeploy2
src/Config/ConfigWriter.php
ConfigWriter.write
public function write(Config $config) { $pathBuildDb = Config::KEY_BUILD . '/' . Config::KEY_DB . '/'; /** @var array $artifacts */ $artifacts = $config->get(Config::KEY_DEPLOY . '/' . Config::KEY_ARTIFACTS); $artifactsExport = ''; foreach ($artifacts as $artifactName => $artifact) { $artifactVarExport = $this->varExport($artifact); $artifactsExport .= "'$artifactName' => $artifactVarExport,\n"; } /** @var array $themes */ $themes = $config->get(Config::KEY_DEPLOY . '/' . Config::KEY_THEMES); $themesExport = ''; foreach ($themes as $theme) { $themesExport .= $this->varExport($theme) . ",\n"; } $vars = [ '{{GIT_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_GIT_BIN), '{{PHP_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_PHP_BIN), '{{TAR_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_TAR_BIN), '{{MYSQL_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_MYSQL_BIN), '{{COMPOSER_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_COMPOSER_BIN), '{{DEPLOYER_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_DEPLOYER_BIN), '{{GIT_URL}}' => $config->get(Config::KEY_DEPLOY . '/' . Config::KEY_GIT_URL), "'{{ARTIFACTS}}'" => trim($artifactsExport), "'{{THEMES}}'" => trim($themesExport), '{{DB_HOST}}' => $config->get($pathBuildDb . 'db-host'), '{{DB_NAME}}' => $config->get($pathBuildDb . 'db-name'), '{{DB_USER}}' => $config->get($pathBuildDb . 'db-user'), '{{DB_PASSWORD}}' => $config->get($pathBuildDb . 'db-password'), ]; $search = array_keys($vars); $replace = array_values($vars); $md2Template = file_get_contents(__DIR__ . '/magedeploy2.template.php'); $configFileContent = str_replace($search, $replace, $md2Template); file_put_contents(Config::FILENAME, $configFileContent); }
php
public function write(Config $config) { $pathBuildDb = Config::KEY_BUILD . '/' . Config::KEY_DB . '/'; /** @var array $artifacts */ $artifacts = $config->get(Config::KEY_DEPLOY . '/' . Config::KEY_ARTIFACTS); $artifactsExport = ''; foreach ($artifacts as $artifactName => $artifact) { $artifactVarExport = $this->varExport($artifact); $artifactsExport .= "'$artifactName' => $artifactVarExport,\n"; } /** @var array $themes */ $themes = $config->get(Config::KEY_DEPLOY . '/' . Config::KEY_THEMES); $themesExport = ''; foreach ($themes as $theme) { $themesExport .= $this->varExport($theme) . ",\n"; } $vars = [ '{{GIT_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_GIT_BIN), '{{PHP_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_PHP_BIN), '{{TAR_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_TAR_BIN), '{{MYSQL_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_MYSQL_BIN), '{{COMPOSER_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_COMPOSER_BIN), '{{DEPLOYER_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_DEPLOYER_BIN), '{{GIT_URL}}' => $config->get(Config::KEY_DEPLOY . '/' . Config::KEY_GIT_URL), "'{{ARTIFACTS}}'" => trim($artifactsExport), "'{{THEMES}}'" => trim($themesExport), '{{DB_HOST}}' => $config->get($pathBuildDb . 'db-host'), '{{DB_NAME}}' => $config->get($pathBuildDb . 'db-name'), '{{DB_USER}}' => $config->get($pathBuildDb . 'db-user'), '{{DB_PASSWORD}}' => $config->get($pathBuildDb . 'db-password'), ]; $search = array_keys($vars); $replace = array_values($vars); $md2Template = file_get_contents(__DIR__ . '/magedeploy2.template.php'); $configFileContent = str_replace($search, $replace, $md2Template); file_put_contents(Config::FILENAME, $configFileContent); }
[ "public", "function", "write", "(", "Config", "$", "config", ")", "{", "$", "pathBuildDb", "=", "Config", "::", "KEY_BUILD", ".", "'/'", ".", "Config", "::", "KEY_DB", ".", "'/'", ";", "/** @var array $artifacts */", "$", "artifacts", "=", "$", "config", "->", "get", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_ARTIFACTS", ")", ";", "$", "artifactsExport", "=", "''", ";", "foreach", "(", "$", "artifacts", "as", "$", "artifactName", "=>", "$", "artifact", ")", "{", "$", "artifactVarExport", "=", "$", "this", "->", "varExport", "(", "$", "artifact", ")", ";", "$", "artifactsExport", ".=", "\"'$artifactName' => $artifactVarExport,\\n\"", ";", "}", "/** @var array $themes */", "$", "themes", "=", "$", "config", "->", "get", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_THEMES", ")", ";", "$", "themesExport", "=", "''", ";", "foreach", "(", "$", "themes", "as", "$", "theme", ")", "{", "$", "themesExport", ".=", "$", "this", "->", "varExport", "(", "$", "theme", ")", ".", "\",\\n\"", ";", "}", "$", "vars", "=", "[", "'{{GIT_BIN}}'", "=>", "$", "config", "->", "get", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_GIT_BIN", ")", ",", "'{{PHP_BIN}}'", "=>", "$", "config", "->", "get", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_PHP_BIN", ")", ",", "'{{TAR_BIN}}'", "=>", "$", "config", "->", "get", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_TAR_BIN", ")", ",", "'{{MYSQL_BIN}}'", "=>", "$", "config", "->", "get", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_MYSQL_BIN", ")", ",", "'{{COMPOSER_BIN}}'", "=>", "$", "config", "->", "get", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_COMPOSER_BIN", ")", ",", "'{{DEPLOYER_BIN}}'", "=>", "$", "config", "->", "get", "(", "Config", "::", "KEY_ENV", ".", "'/'", ".", "Config", "::", "KEY_DEPLOYER_BIN", ")", ",", "'{{GIT_URL}}'", "=>", "$", "config", "->", "get", "(", "Config", "::", "KEY_DEPLOY", ".", "'/'", ".", "Config", "::", "KEY_GIT_URL", ")", ",", "\"'{{ARTIFACTS}}'\"", "=>", "trim", "(", "$", "artifactsExport", ")", ",", "\"'{{THEMES}}'\"", "=>", "trim", "(", "$", "themesExport", ")", ",", "'{{DB_HOST}}'", "=>", "$", "config", "->", "get", "(", "$", "pathBuildDb", ".", "'db-host'", ")", ",", "'{{DB_NAME}}'", "=>", "$", "config", "->", "get", "(", "$", "pathBuildDb", ".", "'db-name'", ")", ",", "'{{DB_USER}}'", "=>", "$", "config", "->", "get", "(", "$", "pathBuildDb", ".", "'db-user'", ")", ",", "'{{DB_PASSWORD}}'", "=>", "$", "config", "->", "get", "(", "$", "pathBuildDb", ".", "'db-password'", ")", ",", "]", ";", "$", "search", "=", "array_keys", "(", "$", "vars", ")", ";", "$", "replace", "=", "array_values", "(", "$", "vars", ")", ";", "$", "md2Template", "=", "file_get_contents", "(", "__DIR__", ".", "'/magedeploy2.template.php'", ")", ";", "$", "configFileContent", "=", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "$", "md2Template", ")", ";", "file_put_contents", "(", "Config", "::", "FILENAME", ",", "$", "configFileContent", ")", ";", "}" ]
Write Config to file from Config object @return void
[ "Write", "Config", "to", "file", "from", "Config", "object" ]
8252f61ee4810f5aa2448090a51cb2d3916d6421
https://github.com/mwr/magedeploy2/blob/8252f61ee4810f5aa2448090a51cb2d3916d6421/src/Config/ConfigWriter.php#L20-L64
223,117
symlex/doctrine-active-record
src/Model/Model.php
Model.getModelName
public function getModelName(): string { $className = get_class($this); $postfix = $this->getFactory()->getFactoryPostfix(); $namespace = $this->getFactory()->getFactoryNamespace(); if ($postfix != '') { $result = substr($className, strlen($namespace), strlen($postfix) * -1); } else { $result = substr($className, strlen($namespace)); } return $result; }
php
public function getModelName(): string { $className = get_class($this); $postfix = $this->getFactory()->getFactoryPostfix(); $namespace = $this->getFactory()->getFactoryNamespace(); if ($postfix != '') { $result = substr($className, strlen($namespace), strlen($postfix) * -1); } else { $result = substr($className, strlen($namespace)); } return $result; }
[ "public", "function", "getModelName", "(", ")", ":", "string", "{", "$", "className", "=", "get_class", "(", "$", "this", ")", ";", "$", "postfix", "=", "$", "this", "->", "getFactory", "(", ")", "->", "getFactoryPostfix", "(", ")", ";", "$", "namespace", "=", "$", "this", "->", "getFactory", "(", ")", "->", "getFactoryNamespace", "(", ")", ";", "if", "(", "$", "postfix", "!=", "''", ")", "{", "$", "result", "=", "substr", "(", "$", "className", ",", "strlen", "(", "$", "namespace", ")", ",", "strlen", "(", "$", "postfix", ")", "*", "-", "1", ")", ";", "}", "else", "{", "$", "result", "=", "substr", "(", "$", "className", ",", "strlen", "(", "$", "namespace", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the model name without prefix and postfix @return string
[ "Returns", "the", "model", "name", "without", "prefix", "and", "postfix" ]
918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d
https://github.com/symlex/doctrine-active-record/blob/918dbdf73a0acf32a0d70a3d5c39e290ac3e3b8d/src/Model/Model.php#L194-L208
223,118
DevGroup-ru/yii2-tag-dependency-helper
src/CacheableActiveRecord.php
CacheableActiveRecord.events
public function events() { return [ ActiveRecord::EVENT_AFTER_DELETE => [$this->owner, 'invalidateTags'], ActiveRecord::EVENT_AFTER_INSERT => [$this->owner, 'invalidateTags'], ActiveRecord::EVENT_AFTER_UPDATE => [$this->owner, 'invalidateTags'], ]; }
php
public function events() { return [ ActiveRecord::EVENT_AFTER_DELETE => [$this->owner, 'invalidateTags'], ActiveRecord::EVENT_AFTER_INSERT => [$this->owner, 'invalidateTags'], ActiveRecord::EVENT_AFTER_UPDATE => [$this->owner, 'invalidateTags'], ]; }
[ "public", "function", "events", "(", ")", "{", "return", "[", "ActiveRecord", "::", "EVENT_AFTER_DELETE", "=>", "[", "$", "this", "->", "owner", ",", "'invalidateTags'", "]", ",", "ActiveRecord", "::", "EVENT_AFTER_INSERT", "=>", "[", "$", "this", "->", "owner", ",", "'invalidateTags'", "]", ",", "ActiveRecord", "::", "EVENT_AFTER_UPDATE", "=>", "[", "$", "this", "->", "owner", ",", "'invalidateTags'", "]", ",", "]", ";", "}" ]
Get events list. @return array
[ "Get", "events", "list", "." ]
23e7d26df35fc9605aa674f03cd701f46909214a
https://github.com/DevGroup-ru/yii2-tag-dependency-helper/blob/23e7d26df35fc9605aa674f03cd701f46909214a/src/CacheableActiveRecord.php#L23-L30
223,119
tabacitu/menumanager
src/Models/MenuItem.php
MenuItem.getTree
public static function getTree() { $menu = MenuItem::orderBy('lft')->get(); if ($menu->count()) { foreach ($menu as $k => $menu_item) { $menu_item->children = collect([]); foreach ($menu as $i => $menu_subitem) { if ($menu_subitem->parent_id == $menu_item->id) { $menu_item->children->push($menu_subitem); // remove the subitem for the first level $menu = $menu->reject(function ($item) use ($menu_subitem) { return $item->id == $menu_subitem->id; }); } } } } return $menu; }
php
public static function getTree() { $menu = MenuItem::orderBy('lft')->get(); if ($menu->count()) { foreach ($menu as $k => $menu_item) { $menu_item->children = collect([]); foreach ($menu as $i => $menu_subitem) { if ($menu_subitem->parent_id == $menu_item->id) { $menu_item->children->push($menu_subitem); // remove the subitem for the first level $menu = $menu->reject(function ($item) use ($menu_subitem) { return $item->id == $menu_subitem->id; }); } } } } return $menu; }
[ "public", "static", "function", "getTree", "(", ")", "{", "$", "menu", "=", "MenuItem", "::", "orderBy", "(", "'lft'", ")", "->", "get", "(", ")", ";", "if", "(", "$", "menu", "->", "count", "(", ")", ")", "{", "foreach", "(", "$", "menu", "as", "$", "k", "=>", "$", "menu_item", ")", "{", "$", "menu_item", "->", "children", "=", "collect", "(", "[", "]", ")", ";", "foreach", "(", "$", "menu", "as", "$", "i", "=>", "$", "menu_subitem", ")", "{", "if", "(", "$", "menu_subitem", "->", "parent_id", "==", "$", "menu_item", "->", "id", ")", "{", "$", "menu_item", "->", "children", "->", "push", "(", "$", "menu_subitem", ")", ";", "// remove the subitem for the first level", "$", "menu", "=", "$", "menu", "->", "reject", "(", "function", "(", "$", "item", ")", "use", "(", "$", "menu_subitem", ")", "{", "return", "$", "item", "->", "id", "==", "$", "menu_subitem", "->", "id", ";", "}", ")", ";", "}", "}", "}", "}", "return", "$", "menu", ";", "}" ]
Get all menu items, in a hierarchical collection. Only supports 2 levels of indentation.
[ "Get", "all", "menu", "items", "in", "a", "hierarchical", "collection", ".", "Only", "supports", "2", "levels", "of", "indentation", "." ]
3152c7f7263f226c4225cf661978569ccbb7fa89
https://github.com/tabacitu/menumanager/blob/3152c7f7263f226c4225cf661978569ccbb7fa89/src/Models/MenuItem.php#L32-L55
223,120
shopsys/doctrine-orm
lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php
AbstractExporter.export
public function export() { if ( ! is_dir($this->_outputDir)) { mkdir($this->_outputDir, 0775, true); } foreach ($this->_metadata as $metadata) { // In case output is returned, write it to a file, skip otherwise if($output = $this->exportClassMetadata($metadata)){ $path = $this->_generateOutputPath($metadata); $dir = dirname($path); if ( ! is_dir($dir)) { mkdir($dir, 0775, true); } if (file_exists($path) && !$this->_overwriteExistingFiles) { throw ExportException::attemptOverwriteExistingFile($path); } file_put_contents($path, $output); chmod($path, 0664); } } }
php
public function export() { if ( ! is_dir($this->_outputDir)) { mkdir($this->_outputDir, 0775, true); } foreach ($this->_metadata as $metadata) { // In case output is returned, write it to a file, skip otherwise if($output = $this->exportClassMetadata($metadata)){ $path = $this->_generateOutputPath($metadata); $dir = dirname($path); if ( ! is_dir($dir)) { mkdir($dir, 0775, true); } if (file_exists($path) && !$this->_overwriteExistingFiles) { throw ExportException::attemptOverwriteExistingFile($path); } file_put_contents($path, $output); chmod($path, 0664); } } }
[ "public", "function", "export", "(", ")", "{", "if", "(", "!", "is_dir", "(", "$", "this", "->", "_outputDir", ")", ")", "{", "mkdir", "(", "$", "this", "->", "_outputDir", ",", "0775", ",", "true", ")", ";", "}", "foreach", "(", "$", "this", "->", "_metadata", "as", "$", "metadata", ")", "{", "// In case output is returned, write it to a file, skip otherwise", "if", "(", "$", "output", "=", "$", "this", "->", "exportClassMetadata", "(", "$", "metadata", ")", ")", "{", "$", "path", "=", "$", "this", "->", "_generateOutputPath", "(", "$", "metadata", ")", ";", "$", "dir", "=", "dirname", "(", "$", "path", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0775", ",", "true", ")", ";", "}", "if", "(", "file_exists", "(", "$", "path", ")", "&&", "!", "$", "this", "->", "_overwriteExistingFiles", ")", "{", "throw", "ExportException", "::", "attemptOverwriteExistingFile", "(", "$", "path", ")", ";", "}", "file_put_contents", "(", "$", "path", ",", "$", "output", ")", ";", "chmod", "(", "$", "path", ",", "0664", ")", ";", "}", "}", "}" ]
Exports each ClassMetadata instance to a single Doctrine Mapping file named after the entity. @return void @throws \Doctrine\ORM\Tools\Export\ExportException
[ "Exports", "each", "ClassMetadata", "instance", "to", "a", "single", "Doctrine", "Mapping", "file", "named", "after", "the", "entity", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php#L130-L151
223,121
shopsys/doctrine-orm
lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php
AbstractExporter._generateOutputPath
protected function _generateOutputPath(ClassMetadataInfo $metadata) { return $this->_outputDir . '/' . str_replace('\\', '.', $metadata->name) . $this->_extension; }
php
protected function _generateOutputPath(ClassMetadataInfo $metadata) { return $this->_outputDir . '/' . str_replace('\\', '.', $metadata->name) . $this->_extension; }
[ "protected", "function", "_generateOutputPath", "(", "ClassMetadataInfo", "$", "metadata", ")", "{", "return", "$", "this", "->", "_outputDir", ".", "'/'", ".", "str_replace", "(", "'\\\\'", ",", "'.'", ",", "$", "metadata", "->", "name", ")", ".", "$", "this", "->", "_extension", ";", "}" ]
Generates the path to write the class for the given ClassMetadataInfo instance. @param ClassMetadataInfo $metadata @return string
[ "Generates", "the", "path", "to", "write", "the", "class", "for", "the", "given", "ClassMetadataInfo", "instance", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php#L160-L163
223,122
mespronos/mespronos
src/Controller/BetController.php
BetController.updateBetsFromGame
public static function updateBetsFromGame(Game $game) { $bets = $game->getBets(); $points = $game->getLeague()->getPoints(); foreach ($bets as $bet) { self::updateBetFromGame($bet, $game, $points); } }
php
public static function updateBetsFromGame(Game $game) { $bets = $game->getBets(); $points = $game->getLeague()->getPoints(); foreach ($bets as $bet) { self::updateBetFromGame($bet, $game, $points); } }
[ "public", "static", "function", "updateBetsFromGame", "(", "Game", "$", "game", ")", "{", "$", "bets", "=", "$", "game", "->", "getBets", "(", ")", ";", "$", "points", "=", "$", "game", "->", "getLeague", "(", ")", "->", "getPoints", "(", ")", ";", "foreach", "(", "$", "bets", "as", "$", "bet", ")", "{", "self", "::", "updateBetFromGame", "(", "$", "bet", ",", "$", "game", ",", "$", "points", ")", ";", "}", "}" ]
Define bets scores for a given game @param \Drupal\mespronos\Entity\Game $game @return boolean
[ "Define", "bets", "scores", "for", "a", "given", "game" ]
73757663581ed9040944768073d1d9abc761196b
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Controller/BetController.php#L33-L39
223,123
mespronos/mespronos
src/Controller/BetController.php
BetController.betsLeft
public static function betsLeft(\Drupal\user\Entity\User $user, Day $day) { $now_date = new \DateTime(); $now_date->setTimezone(new \DateTimeZone('GMT')); $injected_database = Database::getConnection(); $subquery = $injected_database->select('mespronos__bet', 'b'); $subquery->leftJoin('mespronos__game', 'g', 'b.game = g.id'); $subquery->fields('g', ['id']); $subquery->condition('g.day', $day->id()); $subquery->condition('b.better', $user->id()); $query = $injected_database->select('mespronos__game', 'g'); $query->addExpression('count(g.id)', 'nb_bet_left'); $query->condition('g.day', $day->id()); $query->condition('g.game_date', $now_date->format('Y-m-d\TH:i:s'), '>'); $query->condition('g.id', $subquery, 'NOT IN'); $results = $query->execute()->fetchAssoc(); return $results['nb_bet_left']; }
php
public static function betsLeft(\Drupal\user\Entity\User $user, Day $day) { $now_date = new \DateTime(); $now_date->setTimezone(new \DateTimeZone('GMT')); $injected_database = Database::getConnection(); $subquery = $injected_database->select('mespronos__bet', 'b'); $subquery->leftJoin('mespronos__game', 'g', 'b.game = g.id'); $subquery->fields('g', ['id']); $subquery->condition('g.day', $day->id()); $subquery->condition('b.better', $user->id()); $query = $injected_database->select('mespronos__game', 'g'); $query->addExpression('count(g.id)', 'nb_bet_left'); $query->condition('g.day', $day->id()); $query->condition('g.game_date', $now_date->format('Y-m-d\TH:i:s'), '>'); $query->condition('g.id', $subquery, 'NOT IN'); $results = $query->execute()->fetchAssoc(); return $results['nb_bet_left']; }
[ "public", "static", "function", "betsLeft", "(", "\\", "Drupal", "\\", "user", "\\", "Entity", "\\", "User", "$", "user", ",", "Day", "$", "day", ")", "{", "$", "now_date", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "now_date", "->", "setTimezone", "(", "new", "\\", "DateTimeZone", "(", "'GMT'", ")", ")", ";", "$", "injected_database", "=", "Database", "::", "getConnection", "(", ")", ";", "$", "subquery", "=", "$", "injected_database", "->", "select", "(", "'mespronos__bet'", ",", "'b'", ")", ";", "$", "subquery", "->", "leftJoin", "(", "'mespronos__game'", ",", "'g'", ",", "'b.game = g.id'", ")", ";", "$", "subquery", "->", "fields", "(", "'g'", ",", "[", "'id'", "]", ")", ";", "$", "subquery", "->", "condition", "(", "'g.day'", ",", "$", "day", "->", "id", "(", ")", ")", ";", "$", "subquery", "->", "condition", "(", "'b.better'", ",", "$", "user", "->", "id", "(", ")", ")", ";", "$", "query", "=", "$", "injected_database", "->", "select", "(", "'mespronos__game'", ",", "'g'", ")", ";", "$", "query", "->", "addExpression", "(", "'count(g.id)'", ",", "'nb_bet_left'", ")", ";", "$", "query", "->", "condition", "(", "'g.day'", ",", "$", "day", "->", "id", "(", ")", ")", ";", "$", "query", "->", "condition", "(", "'g.game_date'", ",", "$", "now_date", "->", "format", "(", "'Y-m-d\\TH:i:s'", ")", ",", "'>'", ")", ";", "$", "query", "->", "condition", "(", "'g.id'", ",", "$", "subquery", ",", "'NOT IN'", ")", ";", "$", "results", "=", "$", "query", "->", "execute", "(", ")", "->", "fetchAssoc", "(", ")", ";", "return", "$", "results", "[", "'nb_bet_left'", "]", ";", "}" ]
Determine number of games left to bet for a given user on a given day @param \Drupal\user\Entity\User $user @param \Drupal\mespronos\Entity\Day $day @return integer number of game left to bet
[ "Determine", "number", "of", "games", "left", "to", "bet", "for", "a", "given", "user", "on", "a", "given", "day" ]
73757663581ed9040944768073d1d9abc761196b
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Controller/BetController.php#L149-L169
223,124
shopsys/doctrine-orm
lib/Doctrine/ORM/Tools/SchemaValidator.php
SchemaValidator.validateMapping
public function validateMapping() { $errors = array(); $cmf = $this->em->getMetadataFactory(); $classes = $cmf->getAllMetadata(); foreach ($classes as $class) { if ($ce = $this->validateClass($class)) { $errors[$class->name] = $ce; } } return $errors; }
php
public function validateMapping() { $errors = array(); $cmf = $this->em->getMetadataFactory(); $classes = $cmf->getAllMetadata(); foreach ($classes as $class) { if ($ce = $this->validateClass($class)) { $errors[$class->name] = $ce; } } return $errors; }
[ "public", "function", "validateMapping", "(", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "$", "cmf", "=", "$", "this", "->", "em", "->", "getMetadataFactory", "(", ")", ";", "$", "classes", "=", "$", "cmf", "->", "getAllMetadata", "(", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "if", "(", "$", "ce", "=", "$", "this", "->", "validateClass", "(", "$", "class", ")", ")", "{", "$", "errors", "[", "$", "class", "->", "name", "]", "=", "$", "ce", ";", "}", "}", "return", "$", "errors", ";", "}" ]
Checks the internal consistency of all mapping files. There are several checks that can't be done at runtime or are too expensive, which can be verified with this command. For example: 1. Check if a relation with "mappedBy" is actually connected to that specified field. 2. Check if "mappedBy" and "inversedBy" are consistent to each other. 3. Check if "referencedColumnName" attributes are really pointing to primary key columns. @return array
[ "Checks", "the", "internal", "consistency", "of", "all", "mapping", "files", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/SchemaValidator.php#L64-L77
223,125
shopsys/doctrine-orm
lib/Doctrine/ORM/Tools/SchemaValidator.php
SchemaValidator.schemaInSyncWithMetadata
public function schemaInSyncWithMetadata() { $schemaTool = new SchemaTool($this->em); $allMetadata = $this->em->getMetadataFactory()->getAllMetadata(); return count($schemaTool->getUpdateSchemaSql($allMetadata, true)) == 0; }
php
public function schemaInSyncWithMetadata() { $schemaTool = new SchemaTool($this->em); $allMetadata = $this->em->getMetadataFactory()->getAllMetadata(); return count($schemaTool->getUpdateSchemaSql($allMetadata, true)) == 0; }
[ "public", "function", "schemaInSyncWithMetadata", "(", ")", "{", "$", "schemaTool", "=", "new", "SchemaTool", "(", "$", "this", "->", "em", ")", ";", "$", "allMetadata", "=", "$", "this", "->", "em", "->", "getMetadataFactory", "(", ")", "->", "getAllMetadata", "(", ")", ";", "return", "count", "(", "$", "schemaTool", "->", "getUpdateSchemaSql", "(", "$", "allMetadata", ",", "true", ")", ")", "==", "0", ";", "}" ]
Checks if the Database Schema is in sync with the current metadata state. @return bool
[ "Checks", "if", "the", "Database", "Schema", "is", "in", "sync", "with", "the", "current", "metadata", "state", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/SchemaValidator.php#L264-L271
223,126
imanee/imanee
src/ImageResource/GDResource.php
GDResource.getExtensionByFileName
public function getExtensionByFileName($filepath) { $path = pathinfo($filepath); // check if the file has the extenison and we need // to lower down the extension (caused unknown extension for uppercased extension) if (isset($path['extension'])) { return strtolower($path['extension']); } else if (is_string($this->getMime())) { return str_replace("image/", "", $this->getMime()); } else if ($this->format != "") { return $this->format; } else { // fallback to enable save image on empty extension. ImageMagick has no problem with this. return "jpg"; } }
php
public function getExtensionByFileName($filepath) { $path = pathinfo($filepath); // check if the file has the extenison and we need // to lower down the extension (caused unknown extension for uppercased extension) if (isset($path['extension'])) { return strtolower($path['extension']); } else if (is_string($this->getMime())) { return str_replace("image/", "", $this->getMime()); } else if ($this->format != "") { return $this->format; } else { // fallback to enable save image on empty extension. ImageMagick has no problem with this. return "jpg"; } }
[ "public", "function", "getExtensionByFileName", "(", "$", "filepath", ")", "{", "$", "path", "=", "pathinfo", "(", "$", "filepath", ")", ";", "// check if the file has the extenison and we need", "// to lower down the extension (caused unknown extension for uppercased extension)", "if", "(", "isset", "(", "$", "path", "[", "'extension'", "]", ")", ")", "{", "return", "strtolower", "(", "$", "path", "[", "'extension'", "]", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "this", "->", "getMime", "(", ")", ")", ")", "{", "return", "str_replace", "(", "\"image/\"", ",", "\"\"", ",", "$", "this", "->", "getMime", "(", ")", ")", ";", "}", "else", "if", "(", "$", "this", "->", "format", "!=", "\"\"", ")", "{", "return", "$", "this", "->", "format", ";", "}", "else", "{", "// fallback to enable save image on empty extension. ImageMagick has no problem with this.", "return", "\"jpg\"", ";", "}", "}" ]
A workaround to keep compatibility with Imagick when writing images to disk. @param string $filepath @return string
[ "A", "workaround", "to", "keep", "compatibility", "with", "Imagick", "when", "writing", "images", "to", "disk", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/ImageResource/GDResource.php#L362-L378
223,127
imanee/imanee
src/ImageResource/GDResource.php
GDResource.createBlank
private function createBlank($width, $height) { $blank = imagecreatetruecolor($width, $height); /** * This is not ideal when converting png to jpeg as instead of a default * black background we end up with a white one. * This is alleviated by additional use of imagecopyresampled() before * outputting jpegs. */ if ($this->getMime() === 'image/png') { imagealphablending($blank, false); imagesavealpha($blank, true); } return $blank; }
php
private function createBlank($width, $height) { $blank = imagecreatetruecolor($width, $height); /** * This is not ideal when converting png to jpeg as instead of a default * black background we end up with a white one. * This is alleviated by additional use of imagecopyresampled() before * outputting jpegs. */ if ($this->getMime() === 'image/png') { imagealphablending($blank, false); imagesavealpha($blank, true); } return $blank; }
[ "private", "function", "createBlank", "(", "$", "width", ",", "$", "height", ")", "{", "$", "blank", "=", "imagecreatetruecolor", "(", "$", "width", ",", "$", "height", ")", ";", "/**\n * This is not ideal when converting png to jpeg as instead of a default\n * black background we end up with a white one.\n * This is alleviated by additional use of imagecopyresampled() before\n * outputting jpegs.\n */", "if", "(", "$", "this", "->", "getMime", "(", ")", "===", "'image/png'", ")", "{", "imagealphablending", "(", "$", "blank", ",", "false", ")", ";", "imagesavealpha", "(", "$", "blank", ",", "true", ")", ";", "}", "return", "$", "blank", ";", "}" ]
Helper method which returns a blank GD resource. Retains alpha for PNGs @param int $width width required @param int $height height required @return resource (GD)
[ "Helper", "method", "which", "returns", "a", "blank", "GD", "resource", ".", "Retains", "alpha", "for", "PNGs" ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/ImageResource/GDResource.php#L490-L506
223,128
imanee/imanee
src/ImageResource/GDResource.php
GDResource.fixTransparency
private function fixTransparency($transparency) { $transparency = 100 - $transparency; $transparency /= 100; $image = $this->getResource(); // Get image width and height $width = $this->getWidth(); $height = $this->getHeight(); // Turn alpha blending off imagealphablending($image, false); // Loop through image pixels and modify alpha for each for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) { // Get current alpha value $colorxy = imagecolorat($image, $x, $y); $alpha = ($colorxy >> 24) & 0xFF; // Calculate new alpha $alpha = 127 + 127 * $transparency * ($alpha - 127) / 127; // Get the color index with new alpha $alphacolorxy = imagecolorallocatealpha( $image, ($colorxy >> 16) & 0xFF, ($colorxy >> 8) & 0xFF, $colorxy & 0xFF, $alpha ); // Set pixel with the new color + opacity if (!imagesetpixel($image, $x, $y, $alphacolorxy)) { return false; } } } $this->setResource($image); return true; }
php
private function fixTransparency($transparency) { $transparency = 100 - $transparency; $transparency /= 100; $image = $this->getResource(); // Get image width and height $width = $this->getWidth(); $height = $this->getHeight(); // Turn alpha blending off imagealphablending($image, false); // Loop through image pixels and modify alpha for each for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) { // Get current alpha value $colorxy = imagecolorat($image, $x, $y); $alpha = ($colorxy >> 24) & 0xFF; // Calculate new alpha $alpha = 127 + 127 * $transparency * ($alpha - 127) / 127; // Get the color index with new alpha $alphacolorxy = imagecolorallocatealpha( $image, ($colorxy >> 16) & 0xFF, ($colorxy >> 8) & 0xFF, $colorxy & 0xFF, $alpha ); // Set pixel with the new color + opacity if (!imagesetpixel($image, $x, $y, $alphacolorxy)) { return false; } } } $this->setResource($image); return true; }
[ "private", "function", "fixTransparency", "(", "$", "transparency", ")", "{", "$", "transparency", "=", "100", "-", "$", "transparency", ";", "$", "transparency", "/=", "100", ";", "$", "image", "=", "$", "this", "->", "getResource", "(", ")", ";", "// Get image width and height", "$", "width", "=", "$", "this", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "this", "->", "getHeight", "(", ")", ";", "// Turn alpha blending off", "imagealphablending", "(", "$", "image", ",", "false", ")", ";", "// Loop through image pixels and modify alpha for each", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "$", "width", ";", "$", "x", "++", ")", "{", "for", "(", "$", "y", "=", "0", ";", "$", "y", "<", "$", "height", ";", "$", "y", "++", ")", "{", "// Get current alpha value", "$", "colorxy", "=", "imagecolorat", "(", "$", "image", ",", "$", "x", ",", "$", "y", ")", ";", "$", "alpha", "=", "(", "$", "colorxy", ">>", "24", ")", "&", "0xFF", ";", "// Calculate new alpha", "$", "alpha", "=", "127", "+", "127", "*", "$", "transparency", "*", "(", "$", "alpha", "-", "127", ")", "/", "127", ";", "// Get the color index with new alpha", "$", "alphacolorxy", "=", "imagecolorallocatealpha", "(", "$", "image", ",", "(", "$", "colorxy", ">>", "16", ")", "&", "0xFF", ",", "(", "$", "colorxy", ">>", "8", ")", "&", "0xFF", ",", "$", "colorxy", "&", "0xFF", ",", "$", "alpha", ")", ";", "// Set pixel with the new color + opacity", "if", "(", "!", "imagesetpixel", "(", "$", "image", ",", "$", "x", ",", "$", "y", ",", "$", "alphacolorxy", ")", ")", "{", "return", "false", ";", "}", "}", "}", "$", "this", "->", "setResource", "(", "$", "image", ")", ";", "return", "true", ";", "}" ]
Helper method in order to preserve transparency @param int $transparency Transparency in percentage - 0 (opaque) to 100 (transparent). @return bool true on success or false on failure.
[ "Helper", "method", "in", "order", "to", "preserve", "transparency" ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/ImageResource/GDResource.php#L546-L586
223,129
shopsys/doctrine-orm
lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
XmlDriver.columnToArray
private function columnToArray(SimpleXMLElement $fieldMapping) { $mapping = array( 'fieldName' => (string) $fieldMapping['name'], ); if (isset($fieldMapping['type'])) { $mapping['type'] = (string) $fieldMapping['type']; } if (isset($fieldMapping['column'])) { $mapping['columnName'] = (string) $fieldMapping['column']; } if (isset($fieldMapping['length'])) { $mapping['length'] = (int) $fieldMapping['length']; } if (isset($fieldMapping['precision'])) { $mapping['precision'] = (int) $fieldMapping['precision']; } if (isset($fieldMapping['scale'])) { $mapping['scale'] = (int) $fieldMapping['scale']; } if (isset($fieldMapping['unique'])) { $mapping['unique'] = $this->evaluateBoolean($fieldMapping['unique']); } if (isset($fieldMapping['nullable'])) { $mapping['nullable'] = $this->evaluateBoolean($fieldMapping['nullable']); } if (isset($fieldMapping['version']) && $fieldMapping['version']) { $mapping['version'] = $this->evaluateBoolean($fieldMapping['version']); } if (isset($fieldMapping['column-definition'])) { $mapping['columnDefinition'] = (string) $fieldMapping['column-definition']; } if (isset($fieldMapping->options)) { $mapping['options'] = $this->_parseOptions($fieldMapping->options->children()); } return $mapping; }
php
private function columnToArray(SimpleXMLElement $fieldMapping) { $mapping = array( 'fieldName' => (string) $fieldMapping['name'], ); if (isset($fieldMapping['type'])) { $mapping['type'] = (string) $fieldMapping['type']; } if (isset($fieldMapping['column'])) { $mapping['columnName'] = (string) $fieldMapping['column']; } if (isset($fieldMapping['length'])) { $mapping['length'] = (int) $fieldMapping['length']; } if (isset($fieldMapping['precision'])) { $mapping['precision'] = (int) $fieldMapping['precision']; } if (isset($fieldMapping['scale'])) { $mapping['scale'] = (int) $fieldMapping['scale']; } if (isset($fieldMapping['unique'])) { $mapping['unique'] = $this->evaluateBoolean($fieldMapping['unique']); } if (isset($fieldMapping['nullable'])) { $mapping['nullable'] = $this->evaluateBoolean($fieldMapping['nullable']); } if (isset($fieldMapping['version']) && $fieldMapping['version']) { $mapping['version'] = $this->evaluateBoolean($fieldMapping['version']); } if (isset($fieldMapping['column-definition'])) { $mapping['columnDefinition'] = (string) $fieldMapping['column-definition']; } if (isset($fieldMapping->options)) { $mapping['options'] = $this->_parseOptions($fieldMapping->options->children()); } return $mapping; }
[ "private", "function", "columnToArray", "(", "SimpleXMLElement", "$", "fieldMapping", ")", "{", "$", "mapping", "=", "array", "(", "'fieldName'", "=>", "(", "string", ")", "$", "fieldMapping", "[", "'name'", "]", ",", ")", ";", "if", "(", "isset", "(", "$", "fieldMapping", "[", "'type'", "]", ")", ")", "{", "$", "mapping", "[", "'type'", "]", "=", "(", "string", ")", "$", "fieldMapping", "[", "'type'", "]", ";", "}", "if", "(", "isset", "(", "$", "fieldMapping", "[", "'column'", "]", ")", ")", "{", "$", "mapping", "[", "'columnName'", "]", "=", "(", "string", ")", "$", "fieldMapping", "[", "'column'", "]", ";", "}", "if", "(", "isset", "(", "$", "fieldMapping", "[", "'length'", "]", ")", ")", "{", "$", "mapping", "[", "'length'", "]", "=", "(", "int", ")", "$", "fieldMapping", "[", "'length'", "]", ";", "}", "if", "(", "isset", "(", "$", "fieldMapping", "[", "'precision'", "]", ")", ")", "{", "$", "mapping", "[", "'precision'", "]", "=", "(", "int", ")", "$", "fieldMapping", "[", "'precision'", "]", ";", "}", "if", "(", "isset", "(", "$", "fieldMapping", "[", "'scale'", "]", ")", ")", "{", "$", "mapping", "[", "'scale'", "]", "=", "(", "int", ")", "$", "fieldMapping", "[", "'scale'", "]", ";", "}", "if", "(", "isset", "(", "$", "fieldMapping", "[", "'unique'", "]", ")", ")", "{", "$", "mapping", "[", "'unique'", "]", "=", "$", "this", "->", "evaluateBoolean", "(", "$", "fieldMapping", "[", "'unique'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "fieldMapping", "[", "'nullable'", "]", ")", ")", "{", "$", "mapping", "[", "'nullable'", "]", "=", "$", "this", "->", "evaluateBoolean", "(", "$", "fieldMapping", "[", "'nullable'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "fieldMapping", "[", "'version'", "]", ")", "&&", "$", "fieldMapping", "[", "'version'", "]", ")", "{", "$", "mapping", "[", "'version'", "]", "=", "$", "this", "->", "evaluateBoolean", "(", "$", "fieldMapping", "[", "'version'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "fieldMapping", "[", "'column-definition'", "]", ")", ")", "{", "$", "mapping", "[", "'columnDefinition'", "]", "=", "(", "string", ")", "$", "fieldMapping", "[", "'column-definition'", "]", ";", "}", "if", "(", "isset", "(", "$", "fieldMapping", "->", "options", ")", ")", "{", "$", "mapping", "[", "'options'", "]", "=", "$", "this", "->", "_parseOptions", "(", "$", "fieldMapping", "->", "options", "->", "children", "(", ")", ")", ";", "}", "return", "$", "mapping", ";", "}" ]
Parses the given field as array. @param SimpleXMLElement $fieldMapping @return array
[ "Parses", "the", "given", "field", "as", "array", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php#L712-L759
223,130
kenhyuwa/blade-minify
src/Middleware/Minify.php
Minify.shouldReplaceSpecial
private function shouldReplaceSpecial($buffer) { return strpos($buffer, '<pre') !== false || strpos($buffer, '&lt;pre') !== false || strpos($buffer, '//') !== false; }
php
private function shouldReplaceSpecial($buffer) { return strpos($buffer, '<pre') !== false || strpos($buffer, '&lt;pre') !== false || strpos($buffer, '//') !== false; }
[ "private", "function", "shouldReplaceSpecial", "(", "$", "buffer", ")", "{", "return", "strpos", "(", "$", "buffer", ",", "'<pre'", ")", "!==", "false", "||", "strpos", "(", "$", "buffer", ",", "'&lt;pre'", ")", "!==", "false", "||", "strpos", "(", "$", "buffer", ",", "'//'", ")", "!==", "false", ";", "}" ]
Check should special RegEx rules be applied @param string $buffer @return bool
[ "Check", "should", "special", "RegEx", "rules", "be", "applied" ]
1fa3e943470656d98ea1bfe6ade044d20f731a3b
https://github.com/kenhyuwa/blade-minify/blob/1fa3e943470656d98ea1bfe6ade044d20f731a3b/src/Middleware/Minify.php#L66-L71
223,131
shopsys/doctrine-orm
lib/Doctrine/ORM/Query.php
Query.setLockMode
public function setLockMode($lockMode) { if (in_array($lockMode, array(LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE), true)) { if ( ! $this->_em->getConnection()->isTransactionActive()) { throw TransactionRequiredException::transactionRequired(); } } $this->setHint(self::HINT_LOCK_MODE, $lockMode); return $this; }
php
public function setLockMode($lockMode) { if (in_array($lockMode, array(LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE), true)) { if ( ! $this->_em->getConnection()->isTransactionActive()) { throw TransactionRequiredException::transactionRequired(); } } $this->setHint(self::HINT_LOCK_MODE, $lockMode); return $this; }
[ "public", "function", "setLockMode", "(", "$", "lockMode", ")", "{", "if", "(", "in_array", "(", "$", "lockMode", ",", "array", "(", "LockMode", "::", "NONE", ",", "LockMode", "::", "PESSIMISTIC_READ", ",", "LockMode", "::", "PESSIMISTIC_WRITE", ")", ",", "true", ")", ")", "{", "if", "(", "!", "$", "this", "->", "_em", "->", "getConnection", "(", ")", "->", "isTransactionActive", "(", ")", ")", "{", "throw", "TransactionRequiredException", "::", "transactionRequired", "(", ")", ";", "}", "}", "$", "this", "->", "setHint", "(", "self", "::", "HINT_LOCK_MODE", ",", "$", "lockMode", ")", ";", "return", "$", "this", ";", "}" ]
Set the lock mode for this Query. @see \Doctrine\DBAL\LockMode @param int $lockMode @return Query @throws TransactionRequiredException
[ "Set", "the", "lock", "mode", "for", "this", "Query", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query.php#L664-L675
223,132
mmerian/phpcrawl
libs/PHPCrawlerURLFilter.class.php
PHPCrawlerURLFilter.keepRedirectUrls
public static function keepRedirectUrls(PHPCrawlerDocumentInfo $DocumentInfo, $decrease_link_depths = false) { $cnt = count($DocumentInfo->links_found_url_descriptors); for ($x=0; $x<$cnt; $x++) { if ($DocumentInfo->links_found_url_descriptors[$x]->is_redirect_url == false) { $DocumentInfo->links_found_url_descriptors[$x] = null; } else if ($decrease_link_depths = true) // Decrease linkdepths { $DocumentInfo->links_found_url_descriptors[$x]->url_link_depth--; } } }
php
public static function keepRedirectUrls(PHPCrawlerDocumentInfo $DocumentInfo, $decrease_link_depths = false) { $cnt = count($DocumentInfo->links_found_url_descriptors); for ($x=0; $x<$cnt; $x++) { if ($DocumentInfo->links_found_url_descriptors[$x]->is_redirect_url == false) { $DocumentInfo->links_found_url_descriptors[$x] = null; } else if ($decrease_link_depths = true) // Decrease linkdepths { $DocumentInfo->links_found_url_descriptors[$x]->url_link_depth--; } } }
[ "public", "static", "function", "keepRedirectUrls", "(", "PHPCrawlerDocumentInfo", "$", "DocumentInfo", ",", "$", "decrease_link_depths", "=", "false", ")", "{", "$", "cnt", "=", "count", "(", "$", "DocumentInfo", "->", "links_found_url_descriptors", ")", ";", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "$", "cnt", ";", "$", "x", "++", ")", "{", "if", "(", "$", "DocumentInfo", "->", "links_found_url_descriptors", "[", "$", "x", "]", "->", "is_redirect_url", "==", "false", ")", "{", "$", "DocumentInfo", "->", "links_found_url_descriptors", "[", "$", "x", "]", "=", "null", ";", "}", "else", "if", "(", "$", "decrease_link_depths", "=", "true", ")", "// Decrease linkdepths\r", "{", "$", "DocumentInfo", "->", "links_found_url_descriptors", "[", "$", "x", "]", "->", "url_link_depth", "--", ";", "}", "}", "}" ]
Filters out all non-redirect-URLs from the URLs given in the PHPCrawlerDocumentInfo-object @param PHPCrawlerDocumentInfo $DocumentInfo PHPCrawlerDocumentInfo-object containing all found links of the current document. @param bool $decrease_link_depths
[ "Filters", "out", "all", "non", "-", "redirect", "-", "URLs", "from", "the", "URLs", "given", "in", "the", "PHPCrawlerDocumentInfo", "-", "object" ]
1c5e07ff33cf079c69191eb9540a3ced64d392dc
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerURLFilter.class.php#L117-L131
223,133
shopsys/doctrine-orm
lib/Doctrine/ORM/Tools/Setup.php
Setup.registerAutoloadDirectory
public static function registerAutoloadDirectory($directory) { if (!class_exists('Doctrine\Common\ClassLoader', false)) { require_once $directory . "/Doctrine/Common/ClassLoader.php"; } $loader = new ClassLoader("Doctrine", $directory); $loader->register(); $loader = new ClassLoader("Symfony\Component", $directory . "/Doctrine"); $loader->register(); }
php
public static function registerAutoloadDirectory($directory) { if (!class_exists('Doctrine\Common\ClassLoader', false)) { require_once $directory . "/Doctrine/Common/ClassLoader.php"; } $loader = new ClassLoader("Doctrine", $directory); $loader->register(); $loader = new ClassLoader("Symfony\Component", $directory . "/Doctrine"); $loader->register(); }
[ "public", "static", "function", "registerAutoloadDirectory", "(", "$", "directory", ")", "{", "if", "(", "!", "class_exists", "(", "'Doctrine\\Common\\ClassLoader'", ",", "false", ")", ")", "{", "require_once", "$", "directory", ".", "\"/Doctrine/Common/ClassLoader.php\"", ";", "}", "$", "loader", "=", "new", "ClassLoader", "(", "\"Doctrine\"", ",", "$", "directory", ")", ";", "$", "loader", "->", "register", "(", ")", ";", "$", "loader", "=", "new", "ClassLoader", "(", "\"Symfony\\Component\"", ",", "$", "directory", ".", "\"/Doctrine\"", ")", ";", "$", "loader", "->", "register", "(", ")", ";", "}" ]
Use this method to register all autoloads for a downloaded Doctrine library. Pick the directory the library was uncompressed into. @param string $directory @return void
[ "Use", "this", "method", "to", "register", "all", "autoloads", "for", "a", "downloaded", "Doctrine", "library", ".", "Pick", "the", "directory", "the", "library", "was", "uncompressed", "into", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Setup.php#L45-L56
223,134
shopsys/doctrine-orm
lib/Doctrine/ORM/Tools/Setup.php
Setup.createAnnotationMetadataConfiguration
public static function createAnnotationMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null, $useSimpleAnnotationReader = true) { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths, $useSimpleAnnotationReader)); return $config; }
php
public static function createAnnotationMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null, $useSimpleAnnotationReader = true) { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths, $useSimpleAnnotationReader)); return $config; }
[ "public", "static", "function", "createAnnotationMetadataConfiguration", "(", "array", "$", "paths", ",", "$", "isDevMode", "=", "false", ",", "$", "proxyDir", "=", "null", ",", "Cache", "$", "cache", "=", "null", ",", "$", "useSimpleAnnotationReader", "=", "true", ")", "{", "$", "config", "=", "self", "::", "createConfiguration", "(", "$", "isDevMode", ",", "$", "proxyDir", ",", "$", "cache", ")", ";", "$", "config", "->", "setMetadataDriverImpl", "(", "$", "config", "->", "newDefaultAnnotationDriver", "(", "$", "paths", ",", "$", "useSimpleAnnotationReader", ")", ")", ";", "return", "$", "config", ";", "}" ]
Creates a configuration with an annotation metadata driver. @param array $paths @param boolean $isDevMode @param string $proxyDir @param Cache $cache @param bool $useSimpleAnnotationReader @return Configuration
[ "Creates", "a", "configuration", "with", "an", "annotation", "metadata", "driver", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Setup.php#L69-L75
223,135
shopsys/doctrine-orm
lib/Doctrine/ORM/Tools/Setup.php
Setup.createYAMLMetadataConfiguration
public static function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new YamlDriver($paths)); return $config; }
php
public static function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null) { $config = self::createConfiguration($isDevMode, $proxyDir, $cache); $config->setMetadataDriverImpl(new YamlDriver($paths)); return $config; }
[ "public", "static", "function", "createYAMLMetadataConfiguration", "(", "array", "$", "paths", ",", "$", "isDevMode", "=", "false", ",", "$", "proxyDir", "=", "null", ",", "Cache", "$", "cache", "=", "null", ")", "{", "$", "config", "=", "self", "::", "createConfiguration", "(", "$", "isDevMode", ",", "$", "proxyDir", ",", "$", "cache", ")", ";", "$", "config", "->", "setMetadataDriverImpl", "(", "new", "YamlDriver", "(", "$", "paths", ")", ")", ";", "return", "$", "config", ";", "}" ]
Creates a configuration with a yaml metadata driver. @param array $paths @param boolean $isDevMode @param string $proxyDir @param Cache $cache @return Configuration
[ "Creates", "a", "configuration", "with", "a", "yaml", "metadata", "driver", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Setup.php#L105-L111
223,136
tequilarapido/socialite-okta
src/SocialiteManager.php
SocialiteManager.createOktaDriver
public function createOktaDriver() { $config = $this->app['config']['services.okta']; $provider = $this->buildProvider(OktaProvider::class, $config); $provider->setOktaUrl($config['url']); return $provider; }
php
public function createOktaDriver() { $config = $this->app['config']['services.okta']; $provider = $this->buildProvider(OktaProvider::class, $config); $provider->setOktaUrl($config['url']); return $provider; }
[ "public", "function", "createOktaDriver", "(", ")", "{", "$", "config", "=", "$", "this", "->", "app", "[", "'config'", "]", "[", "'services.okta'", "]", ";", "$", "provider", "=", "$", "this", "->", "buildProvider", "(", "OktaProvider", "::", "class", ",", "$", "config", ")", ";", "$", "provider", "->", "setOktaUrl", "(", "$", "config", "[", "'url'", "]", ")", ";", "return", "$", "provider", ";", "}" ]
Creates Okta provider and bind it to Laravel Socialite. @return \Laravel\Socialite\Two\AbstractProvider
[ "Creates", "Okta", "provider", "and", "bind", "it", "to", "Laravel", "Socialite", "." ]
0ca5ba3012f7e7671d6cd5b4df53cf16ad86a8d9
https://github.com/tequilarapido/socialite-okta/blob/0ca5ba3012f7e7671d6cd5b4df53cf16ad86a8d9/src/SocialiteManager.php#L12-L21
223,137
imanee/imanee
src/ImageResource/ImagickResource.php
ImagickResource.getImagickDraw
public function getImagickDraw(Drawer $drawer) { $imdraw = new ImagickDraw(); $imdraw->setFont($drawer->getFont()); $imdraw->setFillColor($drawer->getFontColor()); $imdraw->setFontSize($drawer->getFontSize()); $imdraw->setTextAlignment($drawer->getTextAlign()); return $imdraw; }
php
public function getImagickDraw(Drawer $drawer) { $imdraw = new ImagickDraw(); $imdraw->setFont($drawer->getFont()); $imdraw->setFillColor($drawer->getFontColor()); $imdraw->setFontSize($drawer->getFontSize()); $imdraw->setTextAlignment($drawer->getTextAlign()); return $imdraw; }
[ "public", "function", "getImagickDraw", "(", "Drawer", "$", "drawer", ")", "{", "$", "imdraw", "=", "new", "ImagickDraw", "(", ")", ";", "$", "imdraw", "->", "setFont", "(", "$", "drawer", "->", "getFont", "(", ")", ")", ";", "$", "imdraw", "->", "setFillColor", "(", "$", "drawer", "->", "getFontColor", "(", ")", ")", ";", "$", "imdraw", "->", "setFontSize", "(", "$", "drawer", "->", "getFontSize", "(", ")", ")", ";", "$", "imdraw", "->", "setTextAlignment", "(", "$", "drawer", "->", "getTextAlign", "(", ")", ")", ";", "return", "$", "imdraw", ";", "}" ]
Translates the Drawer object to a ImagickDraw. @param Drawer $drawer @return ImagickDraw
[ "Translates", "the", "Drawer", "object", "to", "a", "ImagickDraw", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/ImageResource/ImagickResource.php#L337-L347
223,138
imanee/imanee
src/ImageResource/ImagickResource.php
ImagickResource.setOpacity
public function setOpacity(Imagick $resource, $transparency) { $alpha = $transparency / 100; if ($alpha >= 1) { return true; } $rows = $resource->getPixelIterator(); foreach ($rows as $cols) { foreach ($cols as $pixel) { /** @var ImagickPixel $pixel */ $current = $pixel->getColorValue(Imagick::COLOR_ALPHA); $pixel->setColorValue(Imagick::COLOR_ALPHA, (($current - $alpha > 0) ? ($current - $alpha) : (0))); $rows->syncIterator(); } } return true; }
php
public function setOpacity(Imagick $resource, $transparency) { $alpha = $transparency / 100; if ($alpha >= 1) { return true; } $rows = $resource->getPixelIterator(); foreach ($rows as $cols) { foreach ($cols as $pixel) { /** @var ImagickPixel $pixel */ $current = $pixel->getColorValue(Imagick::COLOR_ALPHA); $pixel->setColorValue(Imagick::COLOR_ALPHA, (($current - $alpha > 0) ? ($current - $alpha) : (0))); $rows->syncIterator(); } } return true; }
[ "public", "function", "setOpacity", "(", "Imagick", "$", "resource", ",", "$", "transparency", ")", "{", "$", "alpha", "=", "$", "transparency", "/", "100", ";", "if", "(", "$", "alpha", ">=", "1", ")", "{", "return", "true", ";", "}", "$", "rows", "=", "$", "resource", "->", "getPixelIterator", "(", ")", ";", "foreach", "(", "$", "rows", "as", "$", "cols", ")", "{", "foreach", "(", "$", "cols", "as", "$", "pixel", ")", "{", "/** @var ImagickPixel $pixel */", "$", "current", "=", "$", "pixel", "->", "getColorValue", "(", "Imagick", "::", "COLOR_ALPHA", ")", ";", "$", "pixel", "->", "setColorValue", "(", "Imagick", "::", "COLOR_ALPHA", ",", "(", "(", "$", "current", "-", "$", "alpha", ">", "0", ")", "?", "(", "$", "current", "-", "$", "alpha", ")", ":", "(", "0", ")", ")", ")", ";", "$", "rows", "->", "syncIterator", "(", ")", ";", "}", "}", "return", "true", ";", "}" ]
Manually sets the transparency pixel per pixel. This method properly sets the opacity on a png with transparency, by iterating pixel per pixel. It's a substitute for the Imagick::setImageOpacity, since it doesn't handle well transparent backgrounds. @param Imagick $resource The imagick resource to set opacity @param int $transparency The transparency percentage, 0 (opaque) to 100 (transparent). @return bool Returns true if successful.
[ "Manually", "sets", "the", "transparency", "pixel", "per", "pixel", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/ImageResource/ImagickResource.php#L400-L423
223,139
mespronos/mespronos
src/Controller/DayController.php
DayController.getlastDays
public static function getlastDays($nb = 5, League $league = null, $include_archived = false) { $day_storage = \Drupal::entityTypeManager()->getStorage('day'); $injected_database = Database::getConnection(); $now = new \DateTime(null, new \DateTimeZone("UTC")); $query = $injected_database->select('mespronos__game', 'g'); $query->addExpression('min(game_date)', 'day_date'); $query->addExpression('count(g.id)', 'nb_game_over'); $query->groupBy('day'); $query->fields('g', array('day')); $query->join('mespronos__day', 'd', 'd.id = g.day'); if ($league) { $query->condition('d.league', $league->id()); } else { $query->join('mespronos__league', 'l', 'l.id = d.league'); if (!$include_archived) { $query->condition('l.status', 'active'); } } $query->condition('game_date', $now->format('Y-m-d\TH:i:s'), '<'); $query->orderBy('day_date', 'DESC'); $query->range(0, $nb); $results = $query->execute(); $results = $results->fetchAllAssoc('day'); $days = $day_storage->loadMultiple(array_keys($results)); foreach ($results as $key => &$day_data) { $day_data->nb_game = $days[$key]->getNbGame(); $day_data->nb_game_with_score = $days[$key]->getNbGameWIthScore(); $day_data->entity = $days[$key]; } return $results; }
php
public static function getlastDays($nb = 5, League $league = null, $include_archived = false) { $day_storage = \Drupal::entityTypeManager()->getStorage('day'); $injected_database = Database::getConnection(); $now = new \DateTime(null, new \DateTimeZone("UTC")); $query = $injected_database->select('mespronos__game', 'g'); $query->addExpression('min(game_date)', 'day_date'); $query->addExpression('count(g.id)', 'nb_game_over'); $query->groupBy('day'); $query->fields('g', array('day')); $query->join('mespronos__day', 'd', 'd.id = g.day'); if ($league) { $query->condition('d.league', $league->id()); } else { $query->join('mespronos__league', 'l', 'l.id = d.league'); if (!$include_archived) { $query->condition('l.status', 'active'); } } $query->condition('game_date', $now->format('Y-m-d\TH:i:s'), '<'); $query->orderBy('day_date', 'DESC'); $query->range(0, $nb); $results = $query->execute(); $results = $results->fetchAllAssoc('day'); $days = $day_storage->loadMultiple(array_keys($results)); foreach ($results as $key => &$day_data) { $day_data->nb_game = $days[$key]->getNbGame(); $day_data->nb_game_with_score = $days[$key]->getNbGameWIthScore(); $day_data->entity = $days[$key]; } return $results; }
[ "public", "static", "function", "getlastDays", "(", "$", "nb", "=", "5", ",", "League", "$", "league", "=", "null", ",", "$", "include_archived", "=", "false", ")", "{", "$", "day_storage", "=", "\\", "Drupal", "::", "entityTypeManager", "(", ")", "->", "getStorage", "(", "'day'", ")", ";", "$", "injected_database", "=", "Database", "::", "getConnection", "(", ")", ";", "$", "now", "=", "new", "\\", "DateTime", "(", "null", ",", "new", "\\", "DateTimeZone", "(", "\"UTC\"", ")", ")", ";", "$", "query", "=", "$", "injected_database", "->", "select", "(", "'mespronos__game'", ",", "'g'", ")", ";", "$", "query", "->", "addExpression", "(", "'min(game_date)'", ",", "'day_date'", ")", ";", "$", "query", "->", "addExpression", "(", "'count(g.id)'", ",", "'nb_game_over'", ")", ";", "$", "query", "->", "groupBy", "(", "'day'", ")", ";", "$", "query", "->", "fields", "(", "'g'", ",", "array", "(", "'day'", ")", ")", ";", "$", "query", "->", "join", "(", "'mespronos__day'", ",", "'d'", ",", "'d.id = g.day'", ")", ";", "if", "(", "$", "league", ")", "{", "$", "query", "->", "condition", "(", "'d.league'", ",", "$", "league", "->", "id", "(", ")", ")", ";", "}", "else", "{", "$", "query", "->", "join", "(", "'mespronos__league'", ",", "'l'", ",", "'l.id = d.league'", ")", ";", "if", "(", "!", "$", "include_archived", ")", "{", "$", "query", "->", "condition", "(", "'l.status'", ",", "'active'", ")", ";", "}", "}", "$", "query", "->", "condition", "(", "'game_date'", ",", "$", "now", "->", "format", "(", "'Y-m-d\\TH:i:s'", ")", ",", "'<'", ")", ";", "$", "query", "->", "orderBy", "(", "'day_date'", ",", "'DESC'", ")", ";", "$", "query", "->", "range", "(", "0", ",", "$", "nb", ")", ";", "$", "results", "=", "$", "query", "->", "execute", "(", ")", ";", "$", "results", "=", "$", "results", "->", "fetchAllAssoc", "(", "'day'", ")", ";", "$", "days", "=", "$", "day_storage", "->", "loadMultiple", "(", "array_keys", "(", "$", "results", ")", ")", ";", "foreach", "(", "$", "results", "as", "$", "key", "=>", "&", "$", "day_data", ")", "{", "$", "day_data", "->", "nb_game", "=", "$", "days", "[", "$", "key", "]", "->", "getNbGame", "(", ")", ";", "$", "day_data", "->", "nb_game_with_score", "=", "$", "days", "[", "$", "key", "]", "->", "getNbGameWIthScore", "(", ")", ";", "$", "day_data", "->", "entity", "=", "$", "days", "[", "$", "key", "]", ";", "}", "return", "$", "results", ";", "}" ]
Return past days @param int $nb number of days to return @param \Drupal\mespronos\Entity\League|NULL $league @return mixed
[ "Return", "past", "days" ]
73757663581ed9040944768073d1d9abc761196b
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Controller/DayController.php#L187-L220
223,140
shopsys/doctrine-orm
lib/Doctrine/ORM/EntityRepository.php
EntityRepository.createNativeNamedQuery
public function createNativeNamedQuery($queryName) { $queryMapping = $this->_class->getNamedNativeQuery($queryName); $rsm = new Query\ResultSetMappingBuilder($this->_em); $rsm->addNamedNativeQueryMapping($this->_class, $queryMapping); return $this->_em->createNativeQuery($queryMapping['query'], $rsm); }
php
public function createNativeNamedQuery($queryName) { $queryMapping = $this->_class->getNamedNativeQuery($queryName); $rsm = new Query\ResultSetMappingBuilder($this->_em); $rsm->addNamedNativeQueryMapping($this->_class, $queryMapping); return $this->_em->createNativeQuery($queryMapping['query'], $rsm); }
[ "public", "function", "createNativeNamedQuery", "(", "$", "queryName", ")", "{", "$", "queryMapping", "=", "$", "this", "->", "_class", "->", "getNamedNativeQuery", "(", "$", "queryName", ")", ";", "$", "rsm", "=", "new", "Query", "\\", "ResultSetMappingBuilder", "(", "$", "this", "->", "_em", ")", ";", "$", "rsm", "->", "addNamedNativeQueryMapping", "(", "$", "this", "->", "_class", ",", "$", "queryMapping", ")", ";", "return", "$", "this", "->", "_em", "->", "createNativeQuery", "(", "$", "queryMapping", "[", "'query'", "]", ",", "$", "rsm", ")", ";", "}" ]
Creates a native SQL query. @param string $queryName @return NativeQuery
[ "Creates", "a", "native", "SQL", "query", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/EntityRepository.php#L123-L130
223,141
imanee/imanee
src/Imanee.php
Imanee.newImage
public function newImage($width, $height, $background = 'white') { $this->resource->createNew($width, $height, $background); return $this; }
php
public function newImage($width, $height, $background = 'white') { $this->resource->createNew($width, $height, $background); return $this; }
[ "public", "function", "newImage", "(", "$", "width", ",", "$", "height", ",", "$", "background", "=", "'white'", ")", "{", "$", "this", "->", "resource", "->", "createNew", "(", "$", "width", ",", "$", "height", ",", "$", "background", ")", ";", "return", "$", "this", ";", "}" ]
Creates a new "blank" image. @param int $width The width of the image. @param int $height The height of the image. @param string $background The image background. @return $this
[ "Creates", "a", "new", "blank", "image", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L121-L126
223,142
imanee/imanee
src/Imanee.php
Imanee.resize
public function resize($width, $height, $bestfit = true, $stretch = true) { if (!$stretch and (($width >= $this->getWidth()) and ($height >= $this->getHeight()))) { return $this; } $this->resource->resize($width, $height, $bestfit, $stretch); return $this; }
php
public function resize($width, $height, $bestfit = true, $stretch = true) { if (!$stretch and (($width >= $this->getWidth()) and ($height >= $this->getHeight()))) { return $this; } $this->resource->resize($width, $height, $bestfit, $stretch); return $this; }
[ "public", "function", "resize", "(", "$", "width", ",", "$", "height", ",", "$", "bestfit", "=", "true", ",", "$", "stretch", "=", "true", ")", "{", "if", "(", "!", "$", "stretch", "and", "(", "(", "$", "width", ">=", "$", "this", "->", "getWidth", "(", ")", ")", "and", "(", "$", "height", ">=", "$", "this", "->", "getHeight", "(", ")", ")", ")", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "resource", "->", "resize", "(", "$", "width", ",", "$", "height", ",", "$", "bestfit", ",", "$", "stretch", ")", ";", "return", "$", "this", ";", "}" ]
Resizes the current image resource. @param int $width The new width. @param int $height The new height. @param bool $bestfit When set to true, will fit the image inside the provided box dimensions. When set to false, will force resize to the specified dimensions, which may cause the resulting image to be out of proportion. @param bool $stretch When set to false, an image smaller than the box area won't be scaled up to meet the desired size. Defaults to true @return $this
[ "Resizes", "the", "current", "image", "resource", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L175-L184
223,143
imanee/imanee
src/Imanee.php
Imanee.crop
public function crop($width, $height, $coordX, $coordY) { $this->resource->crop($width, $height, $coordX, $coordY); return $this; }
php
public function crop($width, $height, $coordX, $coordY) { $this->resource->crop($width, $height, $coordX, $coordY); return $this; }
[ "public", "function", "crop", "(", "$", "width", ",", "$", "height", ",", "$", "coordX", ",", "$", "coordY", ")", "{", "$", "this", "->", "resource", "->", "crop", "(", "$", "width", ",", "$", "height", ",", "$", "coordX", ",", "$", "coordY", ")", ";", "return", "$", "this", ";", "}" ]
Crops a portion of the image. @param int $width The width. @param int $height The height. @param int $coordX The X coordinate. @param int $coordY The Y coordinate. @return $this
[ "Crops", "a", "portion", "of", "the", "image", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L213-L218
223,144
imanee/imanee
src/Imanee.php
Imanee.thumbnail
public function thumbnail($width, $height, $crop = false, $stretch = true) { if (!$stretch and (($width >= $this->getWidth()) and ($height >= $this->getHeight()))) { return $this; } $this->resource->thumbnail($width, $height, $crop); return $this; }
php
public function thumbnail($width, $height, $crop = false, $stretch = true) { if (!$stretch and (($width >= $this->getWidth()) and ($height >= $this->getHeight()))) { return $this; } $this->resource->thumbnail($width, $height, $crop); return $this; }
[ "public", "function", "thumbnail", "(", "$", "width", ",", "$", "height", ",", "$", "crop", "=", "false", ",", "$", "stretch", "=", "true", ")", "{", "if", "(", "!", "$", "stretch", "and", "(", "(", "$", "width", ">=", "$", "this", "->", "getWidth", "(", ")", ")", "and", "(", "$", "height", ">=", "$", "this", "->", "getHeight", "(", ")", ")", ")", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "resource", "->", "thumbnail", "(", "$", "width", ",", "$", "height", ",", "$", "crop", ")", ";", "return", "$", "this", ";", "}" ]
Creates a thumbnail of the current resource. If crop is true, the result will be a perfect fit thumbnail with the given dimensions, cropped by the center. If crop is false, the thumbnail will use the best fit for the dimensions. @param int $width Width of the thumbnail. @param int $height Height of the thumbnail. @param bool $crop When set to true, the thumbnail will be cropped from the center to match the given size. @param bool $stretch When set to false, an image smaller than the box area won't be scaled up to meet the desired size. Defaults to true @return $this
[ "Creates", "a", "thumbnail", "of", "the", "current", "resource", ".", "If", "crop", "is", "true", "the", "result", "will", "be", "a", "perfect", "fit", "thumbnail", "with", "the", "given", "dimensions", "cropped", "by", "the", "center", ".", "If", "crop", "is", "false", "the", "thumbnail", "will", "use", "the", "best", "fit", "for", "the", "dimensions", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L234-L243
223,145
imanee/imanee
src/Imanee.php
Imanee.write
public function write($path, $jpeg_quality = null) { $this->resource->write($path, $jpeg_quality); return $this; }
php
public function write($path, $jpeg_quality = null) { $this->resource->write($path, $jpeg_quality); return $this; }
[ "public", "function", "write", "(", "$", "path", ",", "$", "jpeg_quality", "=", "null", ")", "{", "$", "this", "->", "resource", "->", "write", "(", "$", "path", ",", "$", "jpeg_quality", ")", ";", "return", "$", "this", ";", "}" ]
Saves the image to disk. If the second param is provided, will try to compress the image using JPEG compression. The format will be decided based on the extension used for the filename. If, for instance, a "img.png" is provided, the image will be saved as PNG and the compression will not take affect. @param string $path The file path to save the image. @param int $jpeg_quality The quality for JPEG files, 1 to 100 where 100 means no compression (higher quality and bigger file). @return $this
[ "Saves", "the", "image", "to", "disk", ".", "If", "the", "second", "param", "is", "provided", "will", "try", "to", "compress", "the", "image", "using", "JPEG", "compression", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L309-L314
223,146
imanee/imanee
src/Imanee.php
Imanee.setResource
public function setResource(ImageResourceInterface $resource) { $this->resource = $resource; if ($this->resource instanceof ImageFilterableInterface) { $this->filterResolver = new FilterResolver($this->resource->loadFilters()); } }
php
public function setResource(ImageResourceInterface $resource) { $this->resource = $resource; if ($this->resource instanceof ImageFilterableInterface) { $this->filterResolver = new FilterResolver($this->resource->loadFilters()); } }
[ "public", "function", "setResource", "(", "ImageResourceInterface", "$", "resource", ")", "{", "$", "this", "->", "resource", "=", "$", "resource", ";", "if", "(", "$", "this", "->", "resource", "instanceof", "ImageFilterableInterface", ")", "{", "$", "this", "->", "filterResolver", "=", "new", "FilterResolver", "(", "$", "this", "->", "resource", "->", "loadFilters", "(", ")", ")", ";", "}", "}" ]
Sets the current Image Resource. @param ImageResourceInterface $resource
[ "Sets", "the", "current", "Image", "Resource", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L331-L338
223,147
imanee/imanee
src/Imanee.php
Imanee.adjustFontSize
public function adjustFontSize($text, Drawer $drawer, $width) { if (! ($this->resource instanceof ImageWritableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $fontSize = 0; $metrics['width'] = 0; while ($metrics['width'] <= $width) { $drawer->setFontSize($fontSize); $metrics = $this->resource->getTextGeometry($text, $drawer); $fontSize++; } return $drawer; }
php
public function adjustFontSize($text, Drawer $drawer, $width) { if (! ($this->resource instanceof ImageWritableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $fontSize = 0; $metrics['width'] = 0; while ($metrics['width'] <= $width) { $drawer->setFontSize($fontSize); $metrics = $this->resource->getTextGeometry($text, $drawer); $fontSize++; } return $drawer; }
[ "public", "function", "adjustFontSize", "(", "$", "text", ",", "Drawer", "$", "drawer", ",", "$", "width", ")", "{", "if", "(", "!", "(", "$", "this", "->", "resource", "instanceof", "ImageWritableInterface", ")", ")", "{", "throw", "new", "UnsupportedMethodException", "(", "\"This method is not supported by the ImageResource in use.\"", ")", ";", "}", "$", "fontSize", "=", "0", ";", "$", "metrics", "[", "'width'", "]", "=", "0", ";", "while", "(", "$", "metrics", "[", "'width'", "]", "<=", "$", "width", ")", "{", "$", "drawer", "->", "setFontSize", "(", "$", "fontSize", ")", ";", "$", "metrics", "=", "$", "this", "->", "resource", "->", "getTextGeometry", "(", "$", "text", ",", "$", "drawer", ")", ";", "$", "fontSize", "++", ";", "}", "return", "$", "drawer", ";", "}" ]
Adjusts the font size of the Drawer object to fit a text in the desired width. @param string $text @param Drawer $drawer @param int $width @return Drawer @throws UnsupportedMethodException
[ "Adjusts", "the", "font", "size", "of", "the", "Drawer", "object", "to", "fit", "a", "text", "in", "the", "desired", "width", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L359-L375
223,148
imanee/imanee
src/Imanee.php
Imanee.annotate
public function annotate($text, $coordX, $coordY, $size = null, $angle = 0) { if (! ($this->resource instanceof ImageWritableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $drawer = $this->getDrawer(); if ($size) { $drawer->setFontSize($size); } $this->resource->annotate($text, $coordX, $coordY, $angle, $drawer); return $this; }
php
public function annotate($text, $coordX, $coordY, $size = null, $angle = 0) { if (! ($this->resource instanceof ImageWritableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $drawer = $this->getDrawer(); if ($size) { $drawer->setFontSize($size); } $this->resource->annotate($text, $coordX, $coordY, $angle, $drawer); return $this; }
[ "public", "function", "annotate", "(", "$", "text", ",", "$", "coordX", ",", "$", "coordY", ",", "$", "size", "=", "null", ",", "$", "angle", "=", "0", ")", "{", "if", "(", "!", "(", "$", "this", "->", "resource", "instanceof", "ImageWritableInterface", ")", ")", "{", "throw", "new", "UnsupportedMethodException", "(", "\"This method is not supported by the ImageResource in use.\"", ")", ";", "}", "$", "drawer", "=", "$", "this", "->", "getDrawer", "(", ")", ";", "if", "(", "$", "size", ")", "{", "$", "drawer", "->", "setFontSize", "(", "$", "size", ")", ";", "}", "$", "this", "->", "resource", "->", "annotate", "(", "$", "text", ",", "$", "coordX", ",", "$", "coordY", ",", "$", "angle", ",", "$", "drawer", ")", ";", "return", "$", "this", ";", "}" ]
Writes text to an image. @param string $text The text to be written. @param int $coordX The X coordinate for text placement. @param int $coordY The Y coordinate for text placement. @param int $size The font size. @param int $angle The angle. @return $this @throws UnsupportedMethodException
[ "Writes", "text", "to", "an", "image", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L436-L450
223,149
imanee/imanee
src/Imanee.php
Imanee.placeImage
public function placeImage( $image, $place_constant = Imanee::IM_POS_TOP_LEFT, $width = null, $height = null, $transparency = 0 ) { if (! ($this->resource instanceof ImageComposableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } if (!is_object($image)) { $img = clone $this; $img->load($image); $image = $img; } if (! ($image instanceof \Imanee\Imanee)) { throw new UnsupportedFormatException('Object not supported. It must be an instance of Imanee'); } if ($width and $height) { $image->resize($width, $height); } list ($coordX, $coordY) = PixelMath::getPlacementCoordinates( $image->getSize(), ['width' => $this->getWidth(), 'height' => $this->getHeight()], $place_constant ); $this->resource->compositeImage($image, $coordX, $coordY, 0, 0, $transparency); return $this; }
php
public function placeImage( $image, $place_constant = Imanee::IM_POS_TOP_LEFT, $width = null, $height = null, $transparency = 0 ) { if (! ($this->resource instanceof ImageComposableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } if (!is_object($image)) { $img = clone $this; $img->load($image); $image = $img; } if (! ($image instanceof \Imanee\Imanee)) { throw new UnsupportedFormatException('Object not supported. It must be an instance of Imanee'); } if ($width and $height) { $image->resize($width, $height); } list ($coordX, $coordY) = PixelMath::getPlacementCoordinates( $image->getSize(), ['width' => $this->getWidth(), 'height' => $this->getHeight()], $place_constant ); $this->resource->compositeImage($image, $coordX, $coordY, 0, 0, $transparency); return $this; }
[ "public", "function", "placeImage", "(", "$", "image", ",", "$", "place_constant", "=", "Imanee", "::", "IM_POS_TOP_LEFT", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "transparency", "=", "0", ")", "{", "if", "(", "!", "(", "$", "this", "->", "resource", "instanceof", "ImageComposableInterface", ")", ")", "{", "throw", "new", "UnsupportedMethodException", "(", "\"This method is not supported by the ImageResource in use.\"", ")", ";", "}", "if", "(", "!", "is_object", "(", "$", "image", ")", ")", "{", "$", "img", "=", "clone", "$", "this", ";", "$", "img", "->", "load", "(", "$", "image", ")", ";", "$", "image", "=", "$", "img", ";", "}", "if", "(", "!", "(", "$", "image", "instanceof", "\\", "Imanee", "\\", "Imanee", ")", ")", "{", "throw", "new", "UnsupportedFormatException", "(", "'Object not supported. It must be an instance of Imanee'", ")", ";", "}", "if", "(", "$", "width", "and", "$", "height", ")", "{", "$", "image", "->", "resize", "(", "$", "width", ",", "$", "height", ")", ";", "}", "list", "(", "$", "coordX", ",", "$", "coordY", ")", "=", "PixelMath", "::", "getPlacementCoordinates", "(", "$", "image", "->", "getSize", "(", ")", ",", "[", "'width'", "=>", "$", "this", "->", "getWidth", "(", ")", ",", "'height'", "=>", "$", "this", "->", "getHeight", "(", ")", "]", ",", "$", "place_constant", ")", ";", "$", "this", "->", "resource", "->", "compositeImage", "(", "$", "image", ",", "$", "coordX", ",", "$", "coordY", ",", "0", ",", "0", ",", "$", "transparency", ")", ";", "return", "$", "this", ";", "}" ]
Places an image on top of the current resource. If the width and height are supplied, will perform a resize before placing the image. @param mixed $image Path to an image on filesystem or an Imanee Object. @param int $place_constant One of the Imanee::IM_POS constants, defaults to IM_POS_TOP_LEFT (top left corner). @param int $width Width for the placement. @param int $height Height for the placement. @param int $transparency Transparency of the placed image - 0 (default) to 100 (transparent). @return $this @throws UnsupportedMethodException @throws UnsupportedFormatException
[ "Places", "an", "image", "on", "top", "of", "the", "current", "resource", ".", "If", "the", "width", "and", "height", "are", "supplied", "will", "perform", "a", "resize", "before", "placing", "the", "image", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L516-L550
223,150
imanee/imanee
src/Imanee.php
Imanee.watermark
public function watermark($image, $place_constant = Imanee::IM_POS_BOTTOM_RIGHT, $transparency = 0) { $this->placeImage($image, $place_constant, 0, 0, $transparency); return $this; }
php
public function watermark($image, $place_constant = Imanee::IM_POS_BOTTOM_RIGHT, $transparency = 0) { $this->placeImage($image, $place_constant, 0, 0, $transparency); return $this; }
[ "public", "function", "watermark", "(", "$", "image", ",", "$", "place_constant", "=", "Imanee", "::", "IM_POS_BOTTOM_RIGHT", ",", "$", "transparency", "=", "0", ")", "{", "$", "this", "->", "placeImage", "(", "$", "image", ",", "$", "place_constant", ",", "0", ",", "0", ",", "$", "transparency", ")", ";", "return", "$", "this", ";", "}" ]
Convenient method to place a watermark image on top of the current resource. @param mixed $image The path to the watermark image file or an Imanee object. @param int $place_constant One of the Imanee::IM_POS constants @param int $transparency Watermark transparency percentage. @return $this
[ "Convenient", "method", "to", "place", "a", "watermark", "image", "on", "top", "of", "the", "current", "resource", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L561-L566
223,151
imanee/imanee
src/Imanee.php
Imanee.addFilter
public function addFilter(FilterInterface $filter) { if (! ($this->resource instanceof ImageFilterableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $this->getFilterResolver()->addFilter($filter); return $this; }
php
public function addFilter(FilterInterface $filter) { if (! ($this->resource instanceof ImageFilterableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $this->getFilterResolver()->addFilter($filter); return $this; }
[ "public", "function", "addFilter", "(", "FilterInterface", "$", "filter", ")", "{", "if", "(", "!", "(", "$", "this", "->", "resource", "instanceof", "ImageFilterableInterface", ")", ")", "{", "throw", "new", "UnsupportedMethodException", "(", "\"This method is not supported by the ImageResource in use.\"", ")", ";", "}", "$", "this", "->", "getFilterResolver", "(", ")", "->", "addFilter", "(", "$", "filter", ")", ";", "return", "$", "this", ";", "}" ]
Adds a custom filter to the FilterResolver. @param FilterInterface $filter The Filter @return $this @throws UnsupportedMethodException
[ "Adds", "a", "custom", "filter", "to", "the", "FilterResolver", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L593-L602
223,152
imanee/imanee
src/Imanee.php
Imanee.applyFilter
public function applyFilter($filter, array $options = []) { if (! ($this->resource instanceof ImageFilterableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $filter = $this->getFilterResolver()->resolve($filter); if (!$filter) { throw new FilterNotFoundException(); } $filter->apply($this, $options); return $this; }
php
public function applyFilter($filter, array $options = []) { if (! ($this->resource instanceof ImageFilterableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $filter = $this->getFilterResolver()->resolve($filter); if (!$filter) { throw new FilterNotFoundException(); } $filter->apply($this, $options); return $this; }
[ "public", "function", "applyFilter", "(", "$", "filter", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "(", "$", "this", "->", "resource", "instanceof", "ImageFilterableInterface", ")", ")", "{", "throw", "new", "UnsupportedMethodException", "(", "\"This method is not supported by the ImageResource in use.\"", ")", ";", "}", "$", "filter", "=", "$", "this", "->", "getFilterResolver", "(", ")", "->", "resolve", "(", "$", "filter", ")", ";", "if", "(", "!", "$", "filter", ")", "{", "throw", "new", "FilterNotFoundException", "(", ")", ";", "}", "$", "filter", "->", "apply", "(", "$", "this", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Tries to apply the specified filter to the current resource. @param string $filter The filter identifier, e.g. "filter_bw". @param array $options @return $this @throws FilterNotFoundException @throws UnsupportedMethodException
[ "Tries", "to", "apply", "the", "specified", "filter", "to", "the", "current", "resource", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L615-L630
223,153
imanee/imanee
src/Imanee.php
Imanee.removeFrame
public function removeFrame($offset) { if (!isset($this->frames[$offset])) { throw new \InvalidArgumentException('Offset does not exist.'); } unset($this->frames[$offset]); return $this; }
php
public function removeFrame($offset) { if (!isset($this->frames[$offset])) { throw new \InvalidArgumentException('Offset does not exist.'); } unset($this->frames[$offset]); return $this; }
[ "public", "function", "removeFrame", "(", "$", "offset", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "frames", "[", "$", "offset", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Offset does not exist.'", ")", ";", "}", "unset", "(", "$", "this", "->", "frames", "[", "$", "offset", "]", ")", ";", "return", "$", "this", ";", "}" ]
Removes a frame from a list used for generating animated Gifs. @param int $offset @throws \InvalidArgumentException @return Imanee
[ "Removes", "a", "frame", "from", "a", "list", "used", "for", "generating", "animated", "Gifs", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L677-L686
223,154
imanee/imanee
src/Imanee.php
Imanee.textGen
public static function textGen( $text, Drawer $drawer = null, $format = 'png', $background = 'transparent', ImageResourceInterface $resource = null ) { $imanee = new Imanee(null, $resource); if ($drawer !== null) { $imanee->setDrawer($drawer); } $size = $imanee->resource->getTextGeometry($text, $imanee->getDrawer()); $imanee->newImage($size['width'], $size['height'], $background); $imanee->setFormat($format); $imanee->placeText($text, Imanee::IM_POS_TOP_LEFT); return $imanee; }
php
public static function textGen( $text, Drawer $drawer = null, $format = 'png', $background = 'transparent', ImageResourceInterface $resource = null ) { $imanee = new Imanee(null, $resource); if ($drawer !== null) { $imanee->setDrawer($drawer); } $size = $imanee->resource->getTextGeometry($text, $imanee->getDrawer()); $imanee->newImage($size['width'], $size['height'], $background); $imanee->setFormat($format); $imanee->placeText($text, Imanee::IM_POS_TOP_LEFT); return $imanee; }
[ "public", "static", "function", "textGen", "(", "$", "text", ",", "Drawer", "$", "drawer", "=", "null", ",", "$", "format", "=", "'png'", ",", "$", "background", "=", "'transparent'", ",", "ImageResourceInterface", "$", "resource", "=", "null", ")", "{", "$", "imanee", "=", "new", "Imanee", "(", "null", ",", "$", "resource", ")", ";", "if", "(", "$", "drawer", "!==", "null", ")", "{", "$", "imanee", "->", "setDrawer", "(", "$", "drawer", ")", ";", "}", "$", "size", "=", "$", "imanee", "->", "resource", "->", "getTextGeometry", "(", "$", "text", ",", "$", "imanee", "->", "getDrawer", "(", ")", ")", ";", "$", "imanee", "->", "newImage", "(", "$", "size", "[", "'width'", "]", ",", "$", "size", "[", "'height'", "]", ",", "$", "background", ")", ";", "$", "imanee", "->", "setFormat", "(", "$", "format", ")", ";", "$", "imanee", "->", "placeText", "(", "$", "text", ",", "Imanee", "::", "IM_POS_TOP_LEFT", ")", ";", "return", "$", "imanee", ";", "}" ]
Generates text-only images. @param string $text @param Drawer $drawer @param string $format @param string $background @return Imanee
[ "Generates", "text", "-", "only", "images", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L723-L743
223,155
imanee/imanee
src/Imanee.php
Imanee.arrayAnimate
public static function arrayAnimate(array $images, $delay = 20) { $imanee = new Imanee(); if (! ($imanee->resource instanceof ImageAnimatableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } return $imanee ->resource ->animate($images, $delay); }
php
public static function arrayAnimate(array $images, $delay = 20) { $imanee = new Imanee(); if (! ($imanee->resource instanceof ImageAnimatableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } return $imanee ->resource ->animate($images, $delay); }
[ "public", "static", "function", "arrayAnimate", "(", "array", "$", "images", ",", "$", "delay", "=", "20", ")", "{", "$", "imanee", "=", "new", "Imanee", "(", ")", ";", "if", "(", "!", "(", "$", "imanee", "->", "resource", "instanceof", "ImageAnimatableInterface", ")", ")", "{", "throw", "new", "UnsupportedMethodException", "(", "\"This method is not supported by the ImageResource in use.\"", ")", ";", "}", "return", "$", "imanee", "->", "resource", "->", "animate", "(", "$", "images", ",", "$", "delay", ")", ";", "}" ]
Generates an animated gif from an array of images. @param array $images Array containing paths to the images that should be used as frames. @param int $delay @return string @throws UnsupportedMethodException
[ "Generates", "an", "animated", "gif", "from", "an", "array", "of", "images", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L755-L766
223,156
imanee/imanee
src/Imanee.php
Imanee.globAnimate
public static function globAnimate($pattern, $delay = 20) { $imanee = new Imanee(); if (! ($imanee->resource instanceof ImageAnimatableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $frames = []; foreach (glob($pattern) as $image) { $frames[] = $image; } return $imanee ->resource ->animate($frames, $delay); }
php
public static function globAnimate($pattern, $delay = 20) { $imanee = new Imanee(); if (! ($imanee->resource instanceof ImageAnimatableInterface)) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } $frames = []; foreach (glob($pattern) as $image) { $frames[] = $image; } return $imanee ->resource ->animate($frames, $delay); }
[ "public", "static", "function", "globAnimate", "(", "$", "pattern", ",", "$", "delay", "=", "20", ")", "{", "$", "imanee", "=", "new", "Imanee", "(", ")", ";", "if", "(", "!", "(", "$", "imanee", "->", "resource", "instanceof", "ImageAnimatableInterface", ")", ")", "{", "throw", "new", "UnsupportedMethodException", "(", "\"This method is not supported by the ImageResource in use.\"", ")", ";", "}", "$", "frames", "=", "[", "]", ";", "foreach", "(", "glob", "(", "$", "pattern", ")", "as", "$", "image", ")", "{", "$", "frames", "[", "]", "=", "$", "image", ";", "}", "return", "$", "imanee", "->", "resource", "->", "animate", "(", "$", "frames", ",", "$", "delay", ")", ";", "}" ]
Generates an animated gif from image files in a directory. @param string $pattern @param int $delay @return string @throws UnsupportedMethodException
[ "Generates", "an", "animated", "gif", "from", "image", "files", "in", "a", "directory", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L778-L795
223,157
imanee/imanee
src/Imanee.php
Imanee.getImageInfo
public static function getImageInfo($imagePath) { if (!is_file($imagePath)) { throw new ImageNotFoundException( sprintf("File '%s' not found. Are you sure this is the right path?", $imagePath) ); } $info = getimagesize($imagePath); return [ 'mime' => $info['mime'], 'width' => $info[0], 'height' => $info[1], ]; }
php
public static function getImageInfo($imagePath) { if (!is_file($imagePath)) { throw new ImageNotFoundException( sprintf("File '%s' not found. Are you sure this is the right path?", $imagePath) ); } $info = getimagesize($imagePath); return [ 'mime' => $info['mime'], 'width' => $info[0], 'height' => $info[1], ]; }
[ "public", "static", "function", "getImageInfo", "(", "$", "imagePath", ")", "{", "if", "(", "!", "is_file", "(", "$", "imagePath", ")", ")", "{", "throw", "new", "ImageNotFoundException", "(", "sprintf", "(", "\"File '%s' not found. Are you sure this is the right path?\"", ",", "$", "imagePath", ")", ")", ";", "}", "$", "info", "=", "getimagesize", "(", "$", "imagePath", ")", ";", "return", "[", "'mime'", "=>", "$", "info", "[", "'mime'", "]", ",", "'width'", "=>", "$", "info", "[", "0", "]", ",", "'height'", "=>", "$", "info", "[", "1", "]", ",", "]", ";", "}" ]
Get info about an image saved in disk. @param string $imagePath @return array Array containing the keys 'mime', 'width' and 'height'. @throws ImageNotFoundException
[ "Get", "info", "about", "an", "image", "saved", "in", "disk", "." ]
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/Imanee.php#L806-L821
223,158
shopsys/doctrine-orm
lib/Doctrine/ORM/AbstractQuery.php
AbstractQuery.setResultSetMapping
public function setResultSetMapping(Query\ResultSetMapping $rsm) { $this->translateNamespaces($rsm); $this->_resultSetMapping = $rsm; return $this; }
php
public function setResultSetMapping(Query\ResultSetMapping $rsm) { $this->translateNamespaces($rsm); $this->_resultSetMapping = $rsm; return $this; }
[ "public", "function", "setResultSetMapping", "(", "Query", "\\", "ResultSetMapping", "$", "rsm", ")", "{", "$", "this", "->", "translateNamespaces", "(", "$", "rsm", ")", ";", "$", "this", "->", "_resultSetMapping", "=", "$", "rsm", ";", "return", "$", "this", ";", "}" ]
Sets the ResultSetMapping that should be used for hydration. @param \Doctrine\ORM\Query\ResultSetMapping $rsm @return static This query instance.
[ "Sets", "the", "ResultSetMapping", "that", "should", "be", "used", "for", "hydration", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/AbstractQuery.php#L446-L452
223,159
shopsys/doctrine-orm
lib/Doctrine/ORM/AbstractQuery.php
AbstractQuery.translateNamespaces
private function translateNamespaces(Query\ResultSetMapping $rsm) { $translate = function ($alias) { return $this->_em->getClassMetadata($alias)->getName(); }; $rsm->aliasMap = array_map($translate, $rsm->aliasMap); $rsm->declaringClasses = array_map($translate, $rsm->declaringClasses); }
php
private function translateNamespaces(Query\ResultSetMapping $rsm) { $translate = function ($alias) { return $this->_em->getClassMetadata($alias)->getName(); }; $rsm->aliasMap = array_map($translate, $rsm->aliasMap); $rsm->declaringClasses = array_map($translate, $rsm->declaringClasses); }
[ "private", "function", "translateNamespaces", "(", "Query", "\\", "ResultSetMapping", "$", "rsm", ")", "{", "$", "translate", "=", "function", "(", "$", "alias", ")", "{", "return", "$", "this", "->", "_em", "->", "getClassMetadata", "(", "$", "alias", ")", "->", "getName", "(", ")", ";", "}", ";", "$", "rsm", "->", "aliasMap", "=", "array_map", "(", "$", "translate", ",", "$", "rsm", "->", "aliasMap", ")", ";", "$", "rsm", "->", "declaringClasses", "=", "array_map", "(", "$", "translate", ",", "$", "rsm", "->", "declaringClasses", ")", ";", "}" ]
Allows to translate entity namespaces to full qualified names. @param Query\ResultSetMapping $rsm @return void
[ "Allows", "to", "translate", "entity", "namespaces", "to", "full", "qualified", "names", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/AbstractQuery.php#L471-L479
223,160
shopsys/doctrine-orm
lib/Doctrine/ORM/AbstractQuery.php
AbstractQuery.getHint
public function getHint($name) { return isset($this->_hints[$name]) ? $this->_hints[$name] : false; }
php
public function getHint($name) { return isset($this->_hints[$name]) ? $this->_hints[$name] : false; }
[ "public", "function", "getHint", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "_hints", "[", "$", "name", "]", ")", "?", "$", "this", "->", "_hints", "[", "$", "name", "]", ":", "false", ";", "}" ]
Gets the value of a query hint. If the hint name is not recognized, FALSE is returned. @param string $name The name of the hint. @return mixed The value of the hint or FALSE, if the hint name is not recognized.
[ "Gets", "the", "value", "of", "a", "query", "hint", ".", "If", "the", "hint", "name", "is", "not", "recognized", "FALSE", "is", "returned", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/AbstractQuery.php#L858-L861
223,161
shopsys/doctrine-orm
lib/Doctrine/ORM/AbstractQuery.php
AbstractQuery.executeUsingQueryCache
private function executeUsingQueryCache($parameters = null, $hydrationMode = null) { $rsm = $this->getResultSetMapping(); $querykey = new QueryCacheKey($this->getHash(), $this->lifetime, $this->cacheMode ?: Cache::MODE_NORMAL); $queryCache = $this->_em->getCache()->getQueryCache($this->cacheRegion); $result = $queryCache->get($querykey, $rsm, $this->_hints); if ($result !== null) { if ($this->cacheLogger) { $this->cacheLogger->queryCacheHit($queryCache->getRegion()->getName(), $querykey); } return $result; } $result = $this->executeIgnoreQueryCache($parameters, $hydrationMode); $cached = $queryCache->put($querykey, $rsm, $result, $this->_hints); if ($this->cacheLogger) { $this->cacheLogger->queryCacheMiss($queryCache->getRegion()->getName(), $querykey); if ($cached) { $this->cacheLogger->queryCachePut($queryCache->getRegion()->getName(), $querykey); } } return $result; }
php
private function executeUsingQueryCache($parameters = null, $hydrationMode = null) { $rsm = $this->getResultSetMapping(); $querykey = new QueryCacheKey($this->getHash(), $this->lifetime, $this->cacheMode ?: Cache::MODE_NORMAL); $queryCache = $this->_em->getCache()->getQueryCache($this->cacheRegion); $result = $queryCache->get($querykey, $rsm, $this->_hints); if ($result !== null) { if ($this->cacheLogger) { $this->cacheLogger->queryCacheHit($queryCache->getRegion()->getName(), $querykey); } return $result; } $result = $this->executeIgnoreQueryCache($parameters, $hydrationMode); $cached = $queryCache->put($querykey, $rsm, $result, $this->_hints); if ($this->cacheLogger) { $this->cacheLogger->queryCacheMiss($queryCache->getRegion()->getName(), $querykey); if ($cached) { $this->cacheLogger->queryCachePut($queryCache->getRegion()->getName(), $querykey); } } return $result; }
[ "private", "function", "executeUsingQueryCache", "(", "$", "parameters", "=", "null", ",", "$", "hydrationMode", "=", "null", ")", "{", "$", "rsm", "=", "$", "this", "->", "getResultSetMapping", "(", ")", ";", "$", "querykey", "=", "new", "QueryCacheKey", "(", "$", "this", "->", "getHash", "(", ")", ",", "$", "this", "->", "lifetime", ",", "$", "this", "->", "cacheMode", "?", ":", "Cache", "::", "MODE_NORMAL", ")", ";", "$", "queryCache", "=", "$", "this", "->", "_em", "->", "getCache", "(", ")", "->", "getQueryCache", "(", "$", "this", "->", "cacheRegion", ")", ";", "$", "result", "=", "$", "queryCache", "->", "get", "(", "$", "querykey", ",", "$", "rsm", ",", "$", "this", "->", "_hints", ")", ";", "if", "(", "$", "result", "!==", "null", ")", "{", "if", "(", "$", "this", "->", "cacheLogger", ")", "{", "$", "this", "->", "cacheLogger", "->", "queryCacheHit", "(", "$", "queryCache", "->", "getRegion", "(", ")", "->", "getName", "(", ")", ",", "$", "querykey", ")", ";", "}", "return", "$", "result", ";", "}", "$", "result", "=", "$", "this", "->", "executeIgnoreQueryCache", "(", "$", "parameters", ",", "$", "hydrationMode", ")", ";", "$", "cached", "=", "$", "queryCache", "->", "put", "(", "$", "querykey", ",", "$", "rsm", ",", "$", "result", ",", "$", "this", "->", "_hints", ")", ";", "if", "(", "$", "this", "->", "cacheLogger", ")", "{", "$", "this", "->", "cacheLogger", "->", "queryCacheMiss", "(", "$", "queryCache", "->", "getRegion", "(", ")", "->", "getName", "(", ")", ",", "$", "querykey", ")", ";", "if", "(", "$", "cached", ")", "{", "$", "this", "->", "cacheLogger", "->", "queryCachePut", "(", "$", "queryCache", "->", "getRegion", "(", ")", "->", "getName", "(", ")", ",", "$", "querykey", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Load from second level cache or executes the query and put into cache. @param ArrayCollection|array|null $parameters @param integer|null $hydrationMode @return mixed
[ "Load", "from", "second", "level", "cache", "or", "executes", "the", "query", "and", "put", "into", "cache", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/AbstractQuery.php#L993-L1020
223,162
shopsys/doctrine-orm
lib/Doctrine/ORM/AbstractQuery.php
AbstractQuery.getHydrationCacheId
protected function getHydrationCacheId() { $parameters = array(); foreach ($this->getParameters() as $parameter) { $parameters[$parameter->getName()] = $this->processParameterValue($parameter->getValue()); } $sql = $this->getSQL(); $queryCacheProfile = $this->getHydrationCacheProfile(); $hints = $this->getHints(); $hints['hydrationMode'] = $this->getHydrationMode(); ksort($hints); return $queryCacheProfile->generateCacheKeys($sql, $parameters, $hints); }
php
protected function getHydrationCacheId() { $parameters = array(); foreach ($this->getParameters() as $parameter) { $parameters[$parameter->getName()] = $this->processParameterValue($parameter->getValue()); } $sql = $this->getSQL(); $queryCacheProfile = $this->getHydrationCacheProfile(); $hints = $this->getHints(); $hints['hydrationMode'] = $this->getHydrationMode(); ksort($hints); return $queryCacheProfile->generateCacheKeys($sql, $parameters, $hints); }
[ "protected", "function", "getHydrationCacheId", "(", ")", "{", "$", "parameters", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getParameters", "(", ")", "as", "$", "parameter", ")", "{", "$", "parameters", "[", "$", "parameter", "->", "getName", "(", ")", "]", "=", "$", "this", "->", "processParameterValue", "(", "$", "parameter", "->", "getValue", "(", ")", ")", ";", "}", "$", "sql", "=", "$", "this", "->", "getSQL", "(", ")", ";", "$", "queryCacheProfile", "=", "$", "this", "->", "getHydrationCacheProfile", "(", ")", ";", "$", "hints", "=", "$", "this", "->", "getHints", "(", ")", ";", "$", "hints", "[", "'hydrationMode'", "]", "=", "$", "this", "->", "getHydrationMode", "(", ")", ";", "ksort", "(", "$", "hints", ")", ";", "return", "$", "queryCacheProfile", "->", "generateCacheKeys", "(", "$", "sql", ",", "$", "parameters", ",", "$", "hints", ")", ";", "}" ]
Get the result cache id to use to store the result set cache entry. Will return the configured id if it exists otherwise a hash will be automatically generated for you. @return array ($key, $hash)
[ "Get", "the", "result", "cache", "id", "to", "use", "to", "store", "the", "result", "set", "cache", "entry", ".", "Will", "return", "the", "configured", "id", "if", "it", "exists", "otherwise", "a", "hash", "will", "be", "automatically", "generated", "for", "you", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/AbstractQuery.php#L1029-L1045
223,163
shopsys/doctrine-orm
lib/Doctrine/ORM/AbstractQuery.php
AbstractQuery.getHash
protected function getHash() { $query = $this->getSQL(); $hints = $this->getHints(); $params = array_map(function(Parameter $parameter) { // Small optimization // Does not invoke processParameterValue for scalar values if (is_scalar($value = $parameter->getValue())) { return $value; } return $this->processParameterValue($value); }, $this->parameters->getValues()); ksort($hints); return sha1($query . '-' . serialize($params) . '-' . serialize($hints)); }
php
protected function getHash() { $query = $this->getSQL(); $hints = $this->getHints(); $params = array_map(function(Parameter $parameter) { // Small optimization // Does not invoke processParameterValue for scalar values if (is_scalar($value = $parameter->getValue())) { return $value; } return $this->processParameterValue($value); }, $this->parameters->getValues()); ksort($hints); return sha1($query . '-' . serialize($params) . '-' . serialize($hints)); }
[ "protected", "function", "getHash", "(", ")", "{", "$", "query", "=", "$", "this", "->", "getSQL", "(", ")", ";", "$", "hints", "=", "$", "this", "->", "getHints", "(", ")", ";", "$", "params", "=", "array_map", "(", "function", "(", "Parameter", "$", "parameter", ")", "{", "// Small optimization", "// Does not invoke processParameterValue for scalar values", "if", "(", "is_scalar", "(", "$", "value", "=", "$", "parameter", "->", "getValue", "(", ")", ")", ")", "{", "return", "$", "value", ";", "}", "return", "$", "this", "->", "processParameterValue", "(", "$", "value", ")", ";", "}", ",", "$", "this", "->", "parameters", "->", "getValues", "(", ")", ")", ";", "ksort", "(", "$", "hints", ")", ";", "return", "sha1", "(", "$", "query", ".", "'-'", ".", "serialize", "(", "$", "params", ")", ".", "'-'", ".", "serialize", "(", "$", "hints", ")", ")", ";", "}" ]
Generates a string of currently query to use for the cache second level cache. @return string
[ "Generates", "a", "string", "of", "currently", "query", "to", "use", "for", "the", "cache", "second", "level", "cache", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/AbstractQuery.php#L1102-L1119
223,164
mespronos/mespronos
mespronos_group/src/EventSubscriber/MespronosGroupSubscriber.php
MespronosGroupSubscriber.onKernelException
public function onKernelException(GetResponseEvent $event) { $exception = $event->getException(); if (!($exception instanceof AccessDeniedHttpException)) { return; } if ($this->route_match->getRouteName() != 'entity.group.canonical') { return; } drupal_set_message(t('You are not a member of this group'), 'warning'); $group = $this->route_match->getParameter('group'); $response = new RedirectResponse(\Drupal::url('mespronos_group.group.join', ['group'=>$group->id()])); $event->setResponse($response); }
php
public function onKernelException(GetResponseEvent $event) { $exception = $event->getException(); if (!($exception instanceof AccessDeniedHttpException)) { return; } if ($this->route_match->getRouteName() != 'entity.group.canonical') { return; } drupal_set_message(t('You are not a member of this group'), 'warning'); $group = $this->route_match->getParameter('group'); $response = new RedirectResponse(\Drupal::url('mespronos_group.group.join', ['group'=>$group->id()])); $event->setResponse($response); }
[ "public", "function", "onKernelException", "(", "GetResponseEvent", "$", "event", ")", "{", "$", "exception", "=", "$", "event", "->", "getException", "(", ")", ";", "if", "(", "!", "(", "$", "exception", "instanceof", "AccessDeniedHttpException", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "route_match", "->", "getRouteName", "(", ")", "!=", "'entity.group.canonical'", ")", "{", "return", ";", "}", "drupal_set_message", "(", "t", "(", "'You are not a member of this group'", ")", ",", "'warning'", ")", ";", "$", "group", "=", "$", "this", "->", "route_match", "->", "getParameter", "(", "'group'", ")", ";", "$", "response", "=", "new", "RedirectResponse", "(", "\\", "Drupal", "::", "url", "(", "'mespronos_group.group.join'", ",", "[", "'group'", "=>", "$", "group", "->", "id", "(", ")", "]", ")", ")", ";", "$", "event", "->", "setResponse", "(", "$", "response", ")", ";", "}" ]
Redirects on 403 Access Denied kernel exceptions. @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event The Event to process. @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException Thrown when the access is denied and redirects to user login page.
[ "Redirects", "on", "403", "Access", "Denied", "kernel", "exceptions", "." ]
73757663581ed9040944768073d1d9abc761196b
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/mespronos_group/src/EventSubscriber/MespronosGroupSubscriber.php#L49-L61
223,165
mmerian/phpcrawl
libs/UrlCache/PHPCrawlerSQLiteURLCache.class.php
PHPCrawlerSQLiteURLCache.addURLs
public function addURLs($urls) { PHPCrawlerBenchmark::start("adding_urls_to_sqlitecache"); $this->PDO->exec("BEGIN EXCLUSIVE TRANSACTION;"); $cnt = count($urls); for ($x=0; $x<$cnt; $x++) { if ($urls[$x] != null) { $this->addURL($urls[$x]); } // Commit after 1000 URLs (reduces memory-usage) if ($x%1000 == 0 && $x > 0) { $this->PDO->exec("COMMIT;"); $this->PDO->exec("BEGIN EXCLUSIVE TRANSACTION;"); } } $this->PDO->exec("COMMIT;"); $this->PreparedInsertStatement->closeCursor(); if ($this->db_analyzed == false) { $this->PDO->exec("ANALYZE;"); $this->db_analyzed = true; } PHPCrawlerBenchmark::stop("adding_urls_to_sqlitecache"); }
php
public function addURLs($urls) { PHPCrawlerBenchmark::start("adding_urls_to_sqlitecache"); $this->PDO->exec("BEGIN EXCLUSIVE TRANSACTION;"); $cnt = count($urls); for ($x=0; $x<$cnt; $x++) { if ($urls[$x] != null) { $this->addURL($urls[$x]); } // Commit after 1000 URLs (reduces memory-usage) if ($x%1000 == 0 && $x > 0) { $this->PDO->exec("COMMIT;"); $this->PDO->exec("BEGIN EXCLUSIVE TRANSACTION;"); } } $this->PDO->exec("COMMIT;"); $this->PreparedInsertStatement->closeCursor(); if ($this->db_analyzed == false) { $this->PDO->exec("ANALYZE;"); $this->db_analyzed = true; } PHPCrawlerBenchmark::stop("adding_urls_to_sqlitecache"); }
[ "public", "function", "addURLs", "(", "$", "urls", ")", "{", "PHPCrawlerBenchmark", "::", "start", "(", "\"adding_urls_to_sqlitecache\"", ")", ";", "$", "this", "->", "PDO", "->", "exec", "(", "\"BEGIN EXCLUSIVE TRANSACTION;\"", ")", ";", "$", "cnt", "=", "count", "(", "$", "urls", ")", ";", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "$", "cnt", ";", "$", "x", "++", ")", "{", "if", "(", "$", "urls", "[", "$", "x", "]", "!=", "null", ")", "{", "$", "this", "->", "addURL", "(", "$", "urls", "[", "$", "x", "]", ")", ";", "}", "// Commit after 1000 URLs (reduces memory-usage)\r", "if", "(", "$", "x", "%", "1000", "==", "0", "&&", "$", "x", ">", "0", ")", "{", "$", "this", "->", "PDO", "->", "exec", "(", "\"COMMIT;\"", ")", ";", "$", "this", "->", "PDO", "->", "exec", "(", "\"BEGIN EXCLUSIVE TRANSACTION;\"", ")", ";", "}", "}", "$", "this", "->", "PDO", "->", "exec", "(", "\"COMMIT;\"", ")", ";", "$", "this", "->", "PreparedInsertStatement", "->", "closeCursor", "(", ")", ";", "if", "(", "$", "this", "->", "db_analyzed", "==", "false", ")", "{", "$", "this", "->", "PDO", "->", "exec", "(", "\"ANALYZE;\"", ")", ";", "$", "this", "->", "db_analyzed", "=", "true", ";", "}", "PHPCrawlerBenchmark", "::", "stop", "(", "\"adding_urls_to_sqlitecache\"", ")", ";", "}" ]
Adds an bunch of URLs to the url-cache @param array $urls A numeric array containing the URLs as PHPCrawlerURLDescriptor-objects
[ "Adds", "an", "bunch", "of", "URLs", "to", "the", "url", "-", "cache" ]
1c5e07ff33cf079c69191eb9540a3ced64d392dc
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/UrlCache/PHPCrawlerSQLiteURLCache.class.php#L144-L176
223,166
mmerian/phpcrawl
libs/UrlCache/PHPCrawlerSQLiteURLCache.class.php
PHPCrawlerSQLiteURLCache.cleanup
public function cleanup() { // Has to be done, otherwise sqlite-file is locked on Windows-OS $this->PDO = null; $this->PreparedInsertStatement = null; unlink($this->sqlite_db_file); }
php
public function cleanup() { // Has to be done, otherwise sqlite-file is locked on Windows-OS $this->PDO = null; $this->PreparedInsertStatement = null; unlink($this->sqlite_db_file); }
[ "public", "function", "cleanup", "(", ")", "{", "// Has to be done, otherwise sqlite-file is locked on Windows-OS\r", "$", "this", "->", "PDO", "=", "null", ";", "$", "this", "->", "PreparedInsertStatement", "=", "null", ";", "unlink", "(", "$", "this", "->", "sqlite_db_file", ")", ";", "}" ]
Cleans up the cache after is it not needed anymore.
[ "Cleans", "up", "the", "cache", "after", "is", "it", "not", "needed", "anymore", "." ]
1c5e07ff33cf079c69191eb9540a3ced64d392dc
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/UrlCache/PHPCrawlerSQLiteURLCache.class.php#L302-L309
223,167
shopsys/doctrine-orm
lib/Doctrine/ORM/Query/QueryExpressionVisitor.php
QueryExpressionVisitor.convertComparisonOperator
private static function convertComparisonOperator($criteriaOperator) { return isset(self::$operatorMap[$criteriaOperator]) ? self::$operatorMap[$criteriaOperator] : null; }
php
private static function convertComparisonOperator($criteriaOperator) { return isset(self::$operatorMap[$criteriaOperator]) ? self::$operatorMap[$criteriaOperator] : null; }
[ "private", "static", "function", "convertComparisonOperator", "(", "$", "criteriaOperator", ")", "{", "return", "isset", "(", "self", "::", "$", "operatorMap", "[", "$", "criteriaOperator", "]", ")", "?", "self", "::", "$", "operatorMap", "[", "$", "criteriaOperator", "]", ":", "null", ";", "}" ]
Converts Criteria expression to Query one based on static map. @param string $criteriaOperator @return string|null
[ "Converts", "Criteria", "expression", "to", "Query", "one", "based", "on", "static", "map", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php#L101-L104
223,168
stuttter/wp-event-calendar
wp-event-calendar/includes/common/event.php
WP_Event_Calendar_Event.event_status_to_rfc
protected function event_status_to_rfc() { // Make sure the EventStatus is to spec if ( ! empty( $this->event_status_mapping[ $this->event_status ] ) ) { return $this->event_status_mapping[ $this->event_status ]; } // Returning EventScheduled/CONFIRMED if spec does not match return $this->event_status_mapping[ 'EventScheduled' ]; }
php
protected function event_status_to_rfc() { // Make sure the EventStatus is to spec if ( ! empty( $this->event_status_mapping[ $this->event_status ] ) ) { return $this->event_status_mapping[ $this->event_status ]; } // Returning EventScheduled/CONFIRMED if spec does not match return $this->event_status_mapping[ 'EventScheduled' ]; }
[ "protected", "function", "event_status_to_rfc", "(", ")", "{", "// Make sure the EventStatus is to spec", "if", "(", "!", "empty", "(", "$", "this", "->", "event_status_mapping", "[", "$", "this", "->", "event_status", "]", ")", ")", "{", "return", "$", "this", "->", "event_status_mapping", "[", "$", "this", "->", "event_status", "]", ";", "}", "// Returning EventScheduled/CONFIRMED if spec does not match", "return", "$", "this", "->", "event_status_mapping", "[", "'EventScheduled'", "]", ";", "}" ]
This converts the Schema.org enumeration to the RFC spec @see https://tools.ietf.org/html/rfc5545#section-3.8.1.11 @see http://schema.org/EventStatusType @return string Event Status according to RFC5545
[ "This", "converts", "the", "Schema", ".", "org", "enumeration", "to", "the", "RFC", "spec" ]
e2221b52f0683c105c64fca056daa63763ea8665
https://github.com/stuttter/wp-event-calendar/blob/e2221b52f0683c105c64fca056daa63763ea8665/wp-event-calendar/includes/common/event.php#L143-L152
223,169
stuttter/wp-event-calendar
wp-event-calendar/includes/common/event.php
WP_Event_Calendar_Event.event_recurrance_to_rfc
protected function event_recurrance_to_rfc() { // No recurrance by default $frequency = ''; // Check how our event repeats switch ( $this->repeat ) { case 10: $frequency = 'FREQ=WEEKLY'; break; case 100: $frequency = 'FREQ=MONTHLY'; break; case 1000: $frequency = 'FREQ=YEARLY'; break; } // Get the UNTIL portion if the frequency and end_date are not empty if ( ! empty( $frequency ) && ! empty( $this->end_date ) ) { $frequency .= ';UNTIL=' . $this->event_date_to_rfc( $this->end_date ); } return $frequency; }
php
protected function event_recurrance_to_rfc() { // No recurrance by default $frequency = ''; // Check how our event repeats switch ( $this->repeat ) { case 10: $frequency = 'FREQ=WEEKLY'; break; case 100: $frequency = 'FREQ=MONTHLY'; break; case 1000: $frequency = 'FREQ=YEARLY'; break; } // Get the UNTIL portion if the frequency and end_date are not empty if ( ! empty( $frequency ) && ! empty( $this->end_date ) ) { $frequency .= ';UNTIL=' . $this->event_date_to_rfc( $this->end_date ); } return $frequency; }
[ "protected", "function", "event_recurrance_to_rfc", "(", ")", "{", "// No recurrance by default", "$", "frequency", "=", "''", ";", "// Check how our event repeats", "switch", "(", "$", "this", "->", "repeat", ")", "{", "case", "10", ":", "$", "frequency", "=", "'FREQ=WEEKLY'", ";", "break", ";", "case", "100", ":", "$", "frequency", "=", "'FREQ=MONTHLY'", ";", "break", ";", "case", "1000", ":", "$", "frequency", "=", "'FREQ=YEARLY'", ";", "break", ";", "}", "// Get the UNTIL portion if the frequency and end_date are not empty", "if", "(", "!", "empty", "(", "$", "frequency", ")", "&&", "!", "empty", "(", "$", "this", "->", "end_date", ")", ")", "{", "$", "frequency", ".=", "';UNTIL='", ".", "$", "this", "->", "event_date_to_rfc", "(", "$", "this", "->", "end_date", ")", ";", "}", "return", "$", "frequency", ";", "}" ]
Returns the event recurrence in accordance with the RFC @see https://tools.ietf.org/html/rfc5545#section-3.3.10 @return string Frequency of repeated event
[ "Returns", "the", "event", "recurrence", "in", "accordance", "with", "the", "RFC" ]
e2221b52f0683c105c64fca056daa63763ea8665
https://github.com/stuttter/wp-event-calendar/blob/e2221b52f0683c105c64fca056daa63763ea8665/wp-event-calendar/includes/common/event.php#L181-L205
223,170
shopsys/doctrine-orm
lib/Doctrine/ORM/UnitOfWork.php
UnitOfWork.computeSingleEntityChangeSet
private function computeSingleEntityChangeSet($entity) { $state = $this->getEntityState($entity); if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) { throw new \InvalidArgumentException("Entity has to be managed or scheduled for removal for single computation " . self::objToStr($entity)); } $class = $this->em->getClassMetadata(get_class($entity)); if ($state === self::STATE_MANAGED && $class->isChangeTrackingDeferredImplicit()) { $this->persist($entity); } // Compute changes for INSERTed entities first. This must always happen even in this case. $this->computeScheduleInsertsChangeSets(); if ($class->isReadOnly) { return; } // Ignore uninitialized proxy objects if ($entity instanceof Proxy && ! $entity->__isInitialized__) { return; } // Only MANAGED entities that are NOT SCHEDULED FOR INSERTION OR DELETION are processed here. $oid = spl_object_hash($entity); if ( ! isset($this->entityInsertions[$oid]) && ! isset($this->entityDeletions[$oid]) && isset($this->entityStates[$oid])) { $this->computeChangeSet($class, $entity); } }
php
private function computeSingleEntityChangeSet($entity) { $state = $this->getEntityState($entity); if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) { throw new \InvalidArgumentException("Entity has to be managed or scheduled for removal for single computation " . self::objToStr($entity)); } $class = $this->em->getClassMetadata(get_class($entity)); if ($state === self::STATE_MANAGED && $class->isChangeTrackingDeferredImplicit()) { $this->persist($entity); } // Compute changes for INSERTed entities first. This must always happen even in this case. $this->computeScheduleInsertsChangeSets(); if ($class->isReadOnly) { return; } // Ignore uninitialized proxy objects if ($entity instanceof Proxy && ! $entity->__isInitialized__) { return; } // Only MANAGED entities that are NOT SCHEDULED FOR INSERTION OR DELETION are processed here. $oid = spl_object_hash($entity); if ( ! isset($this->entityInsertions[$oid]) && ! isset($this->entityDeletions[$oid]) && isset($this->entityStates[$oid])) { $this->computeChangeSet($class, $entity); } }
[ "private", "function", "computeSingleEntityChangeSet", "(", "$", "entity", ")", "{", "$", "state", "=", "$", "this", "->", "getEntityState", "(", "$", "entity", ")", ";", "if", "(", "$", "state", "!==", "self", "::", "STATE_MANAGED", "&&", "$", "state", "!==", "self", "::", "STATE_REMOVED", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Entity has to be managed or scheduled for removal for single computation \"", ".", "self", "::", "objToStr", "(", "$", "entity", ")", ")", ";", "}", "$", "class", "=", "$", "this", "->", "em", "->", "getClassMetadata", "(", "get_class", "(", "$", "entity", ")", ")", ";", "if", "(", "$", "state", "===", "self", "::", "STATE_MANAGED", "&&", "$", "class", "->", "isChangeTrackingDeferredImplicit", "(", ")", ")", "{", "$", "this", "->", "persist", "(", "$", "entity", ")", ";", "}", "// Compute changes for INSERTed entities first. This must always happen even in this case.", "$", "this", "->", "computeScheduleInsertsChangeSets", "(", ")", ";", "if", "(", "$", "class", "->", "isReadOnly", ")", "{", "return", ";", "}", "// Ignore uninitialized proxy objects", "if", "(", "$", "entity", "instanceof", "Proxy", "&&", "!", "$", "entity", "->", "__isInitialized__", ")", "{", "return", ";", "}", "// Only MANAGED entities that are NOT SCHEDULED FOR INSERTION OR DELETION are processed here.", "$", "oid", "=", "spl_object_hash", "(", "$", "entity", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "entityInsertions", "[", "$", "oid", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "entityDeletions", "[", "$", "oid", "]", ")", "&&", "isset", "(", "$", "this", "->", "entityStates", "[", "$", "oid", "]", ")", ")", "{", "$", "this", "->", "computeChangeSet", "(", "$", "class", ",", "$", "entity", ")", ";", "}", "}" ]
Only flushes the given entity according to a ruleset that keeps the UoW consistent. 1. All entities scheduled for insertion, (orphan) removals and changes in collections are processed as well! 2. Read Only entities are skipped. 3. Proxies are skipped. 4. Only if entity is properly managed. @param object $entity @return void @throws \InvalidArgumentException
[ "Only", "flushes", "the", "given", "entity", "according", "to", "a", "ruleset", "that", "keeps", "the", "UoW", "consistent", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/UnitOfWork.php#L470-L502
223,171
shopsys/doctrine-orm
lib/Doctrine/ORM/UnitOfWork.php
UnitOfWork.getCommitOrderCalculator
public function getCommitOrderCalculator() { if ($this->commitOrderCalculator === null) { $this->commitOrderCalculator = new Internal\CommitOrderCalculator; } return $this->commitOrderCalculator; }
php
public function getCommitOrderCalculator() { if ($this->commitOrderCalculator === null) { $this->commitOrderCalculator = new Internal\CommitOrderCalculator; } return $this->commitOrderCalculator; }
[ "public", "function", "getCommitOrderCalculator", "(", ")", "{", "if", "(", "$", "this", "->", "commitOrderCalculator", "===", "null", ")", "{", "$", "this", "->", "commitOrderCalculator", "=", "new", "Internal", "\\", "CommitOrderCalculator", ";", "}", "return", "$", "this", "->", "commitOrderCalculator", ";", "}" ]
Gets the CommitOrderCalculator used by the UnitOfWork to order commits. @return \Doctrine\ORM\Internal\CommitOrderCalculator
[ "Gets", "the", "CommitOrderCalculator", "used", "by", "the", "UnitOfWork", "to", "order", "commits", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/UnitOfWork.php#L2359-L2366
223,172
shopsys/doctrine-orm
lib/Doctrine/ORM/UnitOfWork.php
UnitOfWork.getOriginalEntityData
public function getOriginalEntityData($entity) { $oid = spl_object_hash($entity); if (isset($this->originalEntityData[$oid])) { return $this->originalEntityData[$oid]; } return array(); }
php
public function getOriginalEntityData($entity) { $oid = spl_object_hash($entity); if (isset($this->originalEntityData[$oid])) { return $this->originalEntityData[$oid]; } return array(); }
[ "public", "function", "getOriginalEntityData", "(", "$", "entity", ")", "{", "$", "oid", "=", "spl_object_hash", "(", "$", "entity", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "originalEntityData", "[", "$", "oid", "]", ")", ")", "{", "return", "$", "this", "->", "originalEntityData", "[", "$", "oid", "]", ";", "}", "return", "array", "(", ")", ";", "}" ]
Gets the original data of an entity. The original data is the data that was present at the time the entity was reconstituted from the database. @param object $entity @return array
[ "Gets", "the", "original", "data", "of", "an", "entity", ".", "The", "original", "data", "is", "the", "data", "that", "was", "present", "at", "the", "time", "the", "entity", "was", "reconstituted", "from", "the", "database", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/UnitOfWork.php#L2867-L2876
223,173
shopsys/doctrine-orm
lib/Doctrine/ORM/UnitOfWork.php
UnitOfWork.size
public function size() { $countArray = array_map(function ($item) { return count($item); }, $this->identityMap); return array_sum($countArray); }
php
public function size() { $countArray = array_map(function ($item) { return count($item); }, $this->identityMap); return array_sum($countArray); }
[ "public", "function", "size", "(", ")", "{", "$", "countArray", "=", "array_map", "(", "function", "(", "$", "item", ")", "{", "return", "count", "(", "$", "item", ")", ";", "}", ",", "$", "this", "->", "identityMap", ")", ";", "return", "array_sum", "(", "$", "countArray", ")", ";", "}" ]
Calculates the size of the UnitOfWork. The size of the UnitOfWork is the number of entities in the identity map. @return integer
[ "Calculates", "the", "size", "of", "the", "UnitOfWork", ".", "The", "size", "of", "the", "UnitOfWork", "is", "the", "number", "of", "entities", "in", "the", "identity", "map", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/UnitOfWork.php#L3000-L3005
223,174
shopsys/doctrine-orm
lib/Doctrine/ORM/UnitOfWork.php
UnitOfWork.isReadOnly
public function isReadOnly($object) { if ( ! is_object($object)) { throw ORMInvalidArgumentException::readOnlyRequiresManagedEntity($object); } return isset($this->readOnlyObjects[spl_object_hash($object)]); }
php
public function isReadOnly($object) { if ( ! is_object($object)) { throw ORMInvalidArgumentException::readOnlyRequiresManagedEntity($object); } return isset($this->readOnlyObjects[spl_object_hash($object)]); }
[ "public", "function", "isReadOnly", "(", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "ORMInvalidArgumentException", "::", "readOnlyRequiresManagedEntity", "(", "$", "object", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "readOnlyObjects", "[", "spl_object_hash", "(", "$", "object", ")", "]", ")", ";", "}" ]
Is this entity read only? @param object $object @return bool @throws ORMInvalidArgumentException
[ "Is", "this", "entity", "read", "only?" ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/UnitOfWork.php#L3265-L3272
223,175
shopsys/doctrine-orm
lib/Doctrine/ORM/UnitOfWork.php
UnitOfWork.afterTransactionComplete
private function afterTransactionComplete() { if ( ! $this->hasCache) { return; } foreach ($this->persisters as $persister) { if ($persister instanceof CachedPersister) { $persister->afterTransactionComplete(); } } foreach ($this->collectionPersisters as $persister) { if ($persister instanceof CachedPersister) { $persister->afterTransactionComplete(); } } }
php
private function afterTransactionComplete() { if ( ! $this->hasCache) { return; } foreach ($this->persisters as $persister) { if ($persister instanceof CachedPersister) { $persister->afterTransactionComplete(); } } foreach ($this->collectionPersisters as $persister) { if ($persister instanceof CachedPersister) { $persister->afterTransactionComplete(); } } }
[ "private", "function", "afterTransactionComplete", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasCache", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "persisters", "as", "$", "persister", ")", "{", "if", "(", "$", "persister", "instanceof", "CachedPersister", ")", "{", "$", "persister", "->", "afterTransactionComplete", "(", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "collectionPersisters", "as", "$", "persister", ")", "{", "if", "(", "$", "persister", "instanceof", "CachedPersister", ")", "{", "$", "persister", "->", "afterTransactionComplete", "(", ")", ";", "}", "}", "}" ]
Perform whatever processing is encapsulated here after completion of the transaction.
[ "Perform", "whatever", "processing", "is", "encapsulated", "here", "after", "completion", "of", "the", "transaction", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/UnitOfWork.php#L3277-L3294
223,176
shopsys/doctrine-orm
lib/Doctrine/ORM/UnitOfWork.php
UnitOfWork.afterTransactionRolledBack
private function afterTransactionRolledBack() { if ( ! $this->hasCache) { return; } foreach ($this->persisters as $persister) { if ($persister instanceof CachedPersister) { $persister->afterTransactionRolledBack(); } } foreach ($this->collectionPersisters as $persister) { if ($persister instanceof CachedPersister) { $persister->afterTransactionRolledBack(); } } }
php
private function afterTransactionRolledBack() { if ( ! $this->hasCache) { return; } foreach ($this->persisters as $persister) { if ($persister instanceof CachedPersister) { $persister->afterTransactionRolledBack(); } } foreach ($this->collectionPersisters as $persister) { if ($persister instanceof CachedPersister) { $persister->afterTransactionRolledBack(); } } }
[ "private", "function", "afterTransactionRolledBack", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasCache", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "persisters", "as", "$", "persister", ")", "{", "if", "(", "$", "persister", "instanceof", "CachedPersister", ")", "{", "$", "persister", "->", "afterTransactionRolledBack", "(", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "collectionPersisters", "as", "$", "persister", ")", "{", "if", "(", "$", "persister", "instanceof", "CachedPersister", ")", "{", "$", "persister", "->", "afterTransactionRolledBack", "(", ")", ";", "}", "}", "}" ]
Perform whatever processing is encapsulated here after completion of the rolled-back.
[ "Perform", "whatever", "processing", "is", "encapsulated", "here", "after", "completion", "of", "the", "rolled", "-", "back", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/UnitOfWork.php#L3299-L3316
223,177
shopsys/doctrine-orm
lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
DatabaseDriver.buildIndexes
private function buildIndexes(ClassMetadataInfo $metadata) { $tableName = $metadata->table['name']; $indexes = $this->tables[$tableName]->getIndexes(); foreach($indexes as $index){ if ($index->isPrimary()) { continue; } $indexName = $index->getName(); $indexColumns = $index->getColumns(); $constraintType = $index->isUnique() ? 'uniqueConstraints' : 'indexes'; $metadata->table[$constraintType][$indexName]['columns'] = $indexColumns; } }
php
private function buildIndexes(ClassMetadataInfo $metadata) { $tableName = $metadata->table['name']; $indexes = $this->tables[$tableName]->getIndexes(); foreach($indexes as $index){ if ($index->isPrimary()) { continue; } $indexName = $index->getName(); $indexColumns = $index->getColumns(); $constraintType = $index->isUnique() ? 'uniqueConstraints' : 'indexes'; $metadata->table[$constraintType][$indexName]['columns'] = $indexColumns; } }
[ "private", "function", "buildIndexes", "(", "ClassMetadataInfo", "$", "metadata", ")", "{", "$", "tableName", "=", "$", "metadata", "->", "table", "[", "'name'", "]", ";", "$", "indexes", "=", "$", "this", "->", "tables", "[", "$", "tableName", "]", "->", "getIndexes", "(", ")", ";", "foreach", "(", "$", "indexes", "as", "$", "index", ")", "{", "if", "(", "$", "index", "->", "isPrimary", "(", ")", ")", "{", "continue", ";", "}", "$", "indexName", "=", "$", "index", "->", "getName", "(", ")", ";", "$", "indexColumns", "=", "$", "index", "->", "getColumns", "(", ")", ";", "$", "constraintType", "=", "$", "index", "->", "isUnique", "(", ")", "?", "'uniqueConstraints'", ":", "'indexes'", ";", "$", "metadata", "->", "table", "[", "$", "constraintType", "]", "[", "$", "indexName", "]", "[", "'columns'", "]", "=", "$", "indexColumns", ";", "}", "}" ]
Build indexes from a class metadata. @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata
[ "Build", "indexes", "from", "a", "class", "metadata", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php#L317-L335
223,178
shopsys/doctrine-orm
lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
DatabaseDriver.buildFieldMapping
private function buildFieldMapping($tableName, Column $column) { $fieldMapping = array( 'fieldName' => $this->getFieldNameForColumn($tableName, $column->getName(), false), 'columnName' => $column->getName(), 'type' => $column->getType()->getName(), 'nullable' => ( ! $column->getNotNull()), ); // Type specific elements switch ($fieldMapping['type']) { case Type::TARRAY: case Type::BLOB: case Type::GUID: case Type::JSON_ARRAY: case Type::OBJECT: case Type::SIMPLE_ARRAY: case Type::STRING: case Type::TEXT: $fieldMapping['length'] = $column->getLength(); $fieldMapping['options']['fixed'] = $column->getFixed(); break; case Type::DECIMAL: case Type::FLOAT: $fieldMapping['precision'] = $column->getPrecision(); $fieldMapping['scale'] = $column->getScale(); break; case Type::INTEGER: case Type::BIGINT: case Type::SMALLINT: $fieldMapping['options']['unsigned'] = $column->getUnsigned(); break; } // Comment if (($comment = $column->getComment()) !== null) { $fieldMapping['options']['comment'] = $comment; } // Default if (($default = $column->getDefault()) !== null) { $fieldMapping['options']['default'] = $default; } return $fieldMapping; }
php
private function buildFieldMapping($tableName, Column $column) { $fieldMapping = array( 'fieldName' => $this->getFieldNameForColumn($tableName, $column->getName(), false), 'columnName' => $column->getName(), 'type' => $column->getType()->getName(), 'nullable' => ( ! $column->getNotNull()), ); // Type specific elements switch ($fieldMapping['type']) { case Type::TARRAY: case Type::BLOB: case Type::GUID: case Type::JSON_ARRAY: case Type::OBJECT: case Type::SIMPLE_ARRAY: case Type::STRING: case Type::TEXT: $fieldMapping['length'] = $column->getLength(); $fieldMapping['options']['fixed'] = $column->getFixed(); break; case Type::DECIMAL: case Type::FLOAT: $fieldMapping['precision'] = $column->getPrecision(); $fieldMapping['scale'] = $column->getScale(); break; case Type::INTEGER: case Type::BIGINT: case Type::SMALLINT: $fieldMapping['options']['unsigned'] = $column->getUnsigned(); break; } // Comment if (($comment = $column->getComment()) !== null) { $fieldMapping['options']['comment'] = $comment; } // Default if (($default = $column->getDefault()) !== null) { $fieldMapping['options']['default'] = $default; } return $fieldMapping; }
[ "private", "function", "buildFieldMapping", "(", "$", "tableName", ",", "Column", "$", "column", ")", "{", "$", "fieldMapping", "=", "array", "(", "'fieldName'", "=>", "$", "this", "->", "getFieldNameForColumn", "(", "$", "tableName", ",", "$", "column", "->", "getName", "(", ")", ",", "false", ")", ",", "'columnName'", "=>", "$", "column", "->", "getName", "(", ")", ",", "'type'", "=>", "$", "column", "->", "getType", "(", ")", "->", "getName", "(", ")", ",", "'nullable'", "=>", "(", "!", "$", "column", "->", "getNotNull", "(", ")", ")", ",", ")", ";", "// Type specific elements", "switch", "(", "$", "fieldMapping", "[", "'type'", "]", ")", "{", "case", "Type", "::", "TARRAY", ":", "case", "Type", "::", "BLOB", ":", "case", "Type", "::", "GUID", ":", "case", "Type", "::", "JSON_ARRAY", ":", "case", "Type", "::", "OBJECT", ":", "case", "Type", "::", "SIMPLE_ARRAY", ":", "case", "Type", "::", "STRING", ":", "case", "Type", "::", "TEXT", ":", "$", "fieldMapping", "[", "'length'", "]", "=", "$", "column", "->", "getLength", "(", ")", ";", "$", "fieldMapping", "[", "'options'", "]", "[", "'fixed'", "]", "=", "$", "column", "->", "getFixed", "(", ")", ";", "break", ";", "case", "Type", "::", "DECIMAL", ":", "case", "Type", "::", "FLOAT", ":", "$", "fieldMapping", "[", "'precision'", "]", "=", "$", "column", "->", "getPrecision", "(", ")", ";", "$", "fieldMapping", "[", "'scale'", "]", "=", "$", "column", "->", "getScale", "(", ")", ";", "break", ";", "case", "Type", "::", "INTEGER", ":", "case", "Type", "::", "BIGINT", ":", "case", "Type", "::", "SMALLINT", ":", "$", "fieldMapping", "[", "'options'", "]", "[", "'unsigned'", "]", "=", "$", "column", "->", "getUnsigned", "(", ")", ";", "break", ";", "}", "// Comment", "if", "(", "(", "$", "comment", "=", "$", "column", "->", "getComment", "(", ")", ")", "!==", "null", ")", "{", "$", "fieldMapping", "[", "'options'", "]", "[", "'comment'", "]", "=", "$", "comment", ";", "}", "// Default", "if", "(", "(", "$", "default", "=", "$", "column", "->", "getDefault", "(", ")", ")", "!==", "null", ")", "{", "$", "fieldMapping", "[", "'options'", "]", "[", "'default'", "]", "=", "$", "default", ";", "}", "return", "$", "fieldMapping", ";", "}" ]
Build field mapping from a schema column definition @param string $tableName @param \Doctrine\DBAL\Schema\Column $column @return array
[ "Build", "field", "mapping", "from", "a", "schema", "column", "definition" ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php#L390-L437
223,179
shopsys/doctrine-orm
lib/Doctrine/ORM/Configuration.php
Configuration.getNamedQuery
public function getNamedQuery($name) { if ( ! isset($this->_attributes['namedQueries'][$name])) { throw ORMException::namedQueryNotFound($name); } return $this->_attributes['namedQueries'][$name]; }
php
public function getNamedQuery($name) { if ( ! isset($this->_attributes['namedQueries'][$name])) { throw ORMException::namedQueryNotFound($name); } return $this->_attributes['namedQueries'][$name]; }
[ "public", "function", "getNamedQuery", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_attributes", "[", "'namedQueries'", "]", "[", "$", "name", "]", ")", ")", "{", "throw", "ORMException", "::", "namedQueryNotFound", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "_attributes", "[", "'namedQueries'", "]", "[", "$", "name", "]", ";", "}" ]
Gets a previously registered named DQL query. @param string $name The name of the query. @return string The DQL query. @throws ORMException
[ "Gets", "a", "previously", "registered", "named", "DQL", "query", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Configuration.php#L332-L339
223,180
shopsys/doctrine-orm
lib/Doctrine/ORM/Configuration.php
Configuration.addNamedNativeQuery
public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm) { $this->_attributes['namedNativeQueries'][$name] = array($sql, $rsm); }
php
public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm) { $this->_attributes['namedNativeQueries'][$name] = array($sql, $rsm); }
[ "public", "function", "addNamedNativeQuery", "(", "$", "name", ",", "$", "sql", ",", "Query", "\\", "ResultSetMapping", "$", "rsm", ")", "{", "$", "this", "->", "_attributes", "[", "'namedNativeQueries'", "]", "[", "$", "name", "]", "=", "array", "(", "$", "sql", ",", "$", "rsm", ")", ";", "}" ]
Adds a named native query to the configuration. @param string $name The name of the query. @param string $sql The native SQL query string. @param Query\ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query. @return void
[ "Adds", "a", "named", "native", "query", "to", "the", "configuration", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Configuration.php#L350-L353
223,181
shopsys/doctrine-orm
lib/Doctrine/ORM/Configuration.php
Configuration.getNamedNativeQuery
public function getNamedNativeQuery($name) { if ( ! isset($this->_attributes['namedNativeQueries'][$name])) { throw ORMException::namedNativeQueryNotFound($name); } return $this->_attributes['namedNativeQueries'][$name]; }
php
public function getNamedNativeQuery($name) { if ( ! isset($this->_attributes['namedNativeQueries'][$name])) { throw ORMException::namedNativeQueryNotFound($name); } return $this->_attributes['namedNativeQueries'][$name]; }
[ "public", "function", "getNamedNativeQuery", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_attributes", "[", "'namedNativeQueries'", "]", "[", "$", "name", "]", ")", ")", "{", "throw", "ORMException", "::", "namedNativeQueryNotFound", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "_attributes", "[", "'namedNativeQueries'", "]", "[", "$", "name", "]", ";", "}" ]
Gets the components of a previously registered named native query. @param string $name The name of the query. @return array A tuple with the first element being the SQL string and the second element being the ResultSetMapping. @throws ORMException
[ "Gets", "the", "components", "of", "a", "previously", "registered", "named", "native", "query", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Configuration.php#L365-L372
223,182
shopsys/doctrine-orm
lib/Doctrine/ORM/Configuration.php
Configuration.getCustomStringFunction
public function getCustomStringFunction($name) { $name = strtolower($name); return isset($this->_attributes['customStringFunctions'][$name]) ? $this->_attributes['customStringFunctions'][$name] : null; }
php
public function getCustomStringFunction($name) { $name = strtolower($name); return isset($this->_attributes['customStringFunctions'][$name]) ? $this->_attributes['customStringFunctions'][$name] : null; }
[ "public", "function", "getCustomStringFunction", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "return", "isset", "(", "$", "this", "->", "_attributes", "[", "'customStringFunctions'", "]", "[", "$", "name", "]", ")", "?", "$", "this", "->", "_attributes", "[", "'customStringFunctions'", "]", "[", "$", "name", "]", ":", "null", ";", "}" ]
Gets the implementation class name of a registered custom string DQL function. @param string $name @return string|null
[ "Gets", "the", "implementation", "class", "name", "of", "a", "registered", "custom", "string", "DQL", "function", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Configuration.php#L440-L447
223,183
shopsys/doctrine-orm
lib/Doctrine/ORM/Configuration.php
Configuration.getCustomNumericFunction
public function getCustomNumericFunction($name) { $name = strtolower($name); return isset($this->_attributes['customNumericFunctions'][$name]) ? $this->_attributes['customNumericFunctions'][$name] : null; }
php
public function getCustomNumericFunction($name) { $name = strtolower($name); return isset($this->_attributes['customNumericFunctions'][$name]) ? $this->_attributes['customNumericFunctions'][$name] : null; }
[ "public", "function", "getCustomNumericFunction", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "return", "isset", "(", "$", "this", "->", "_attributes", "[", "'customNumericFunctions'", "]", "[", "$", "name", "]", ")", "?", "$", "this", "->", "_attributes", "[", "'customNumericFunctions'", "]", "[", "$", "name", "]", ":", "null", ";", "}" ]
Gets the implementation class name of a registered custom numeric DQL function. @param string $name @return string|null
[ "Gets", "the", "implementation", "class", "name", "of", "a", "registered", "custom", "numeric", "DQL", "function", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Configuration.php#L498-L505
223,184
shopsys/doctrine-orm
lib/Doctrine/ORM/Configuration.php
Configuration.getCustomHydrationMode
public function getCustomHydrationMode($modeName) { return isset($this->_attributes['customHydrationModes'][$modeName]) ? $this->_attributes['customHydrationModes'][$modeName] : null; }
php
public function getCustomHydrationMode($modeName) { return isset($this->_attributes['customHydrationModes'][$modeName]) ? $this->_attributes['customHydrationModes'][$modeName] : null; }
[ "public", "function", "getCustomHydrationMode", "(", "$", "modeName", ")", "{", "return", "isset", "(", "$", "this", "->", "_attributes", "[", "'customHydrationModes'", "]", "[", "$", "modeName", "]", ")", "?", "$", "this", "->", "_attributes", "[", "'customHydrationModes'", "]", "[", "$", "modeName", "]", ":", "null", ";", "}" ]
Gets the hydrator class for the given hydration mode name. @param string $modeName The hydration mode name. @return string|null The hydrator class name.
[ "Gets", "the", "hydrator", "class", "for", "the", "given", "hydration", "mode", "name", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Configuration.php#L607-L612
223,185
shopsys/doctrine-orm
lib/Doctrine/ORM/Configuration.php
Configuration.getDefaultQueryHint
public function getDefaultQueryHint($name) { return isset($this->_attributes['defaultQueryHints'][$name]) ? $this->_attributes['defaultQueryHints'][$name] : false; }
php
public function getDefaultQueryHint($name) { return isset($this->_attributes['defaultQueryHints'][$name]) ? $this->_attributes['defaultQueryHints'][$name] : false; }
[ "public", "function", "getDefaultQueryHint", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "_attributes", "[", "'defaultQueryHints'", "]", "[", "$", "name", "]", ")", "?", "$", "this", "->", "_attributes", "[", "'defaultQueryHints'", "]", "[", "$", "name", "]", ":", "false", ";", "}" ]
Gets the value of a default query hint. If the hint name is not recognized, FALSE is returned. @since 2.5 @param string $name The name of the hint. @return mixed The value of the hint or FALSE, if the hint name is not recognized.
[ "Gets", "the", "value", "of", "a", "default", "query", "hint", ".", "If", "the", "hint", "name", "is", "not", "recognized", "FALSE", "is", "returned", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Configuration.php#L908-L913
223,186
shopsys/doctrine-orm
lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php
EmbeddedBuilder.build
public function build() { $cm = $this->builder->getClassMetadata(); $cm->mapEmbedded($this->mapping); return $this->builder; }
php
public function build() { $cm = $this->builder->getClassMetadata(); $cm->mapEmbedded($this->mapping); return $this->builder; }
[ "public", "function", "build", "(", ")", "{", "$", "cm", "=", "$", "this", "->", "builder", "->", "getClassMetadata", "(", ")", ";", "$", "cm", "->", "mapEmbedded", "(", "$", "this", "->", "mapping", ")", ";", "return", "$", "this", "->", "builder", ";", "}" ]
Finalizes this embeddable and attach it to the ClassMetadata. Without this call an EmbeddedBuilder has no effect on the ClassMetadata. @return ClassMetadataBuilder
[ "Finalizes", "this", "embeddable", "and", "attach", "it", "to", "the", "ClassMetadata", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/EmbeddedBuilder.php#L72-L79
223,187
shopsys/doctrine-orm
lib/Doctrine/ORM/Query/ResultSetMapping.php
ResultSetMapping.addScalarResult
public function addScalarResult($columnName, $alias, $type = 'string') { $this->scalarMappings[$columnName] = $alias; $this->typeMappings[$columnName] = $type; if ( ! $this->isMixed && $this->fieldMappings) { $this->isMixed = true; } return $this; }
php
public function addScalarResult($columnName, $alias, $type = 'string') { $this->scalarMappings[$columnName] = $alias; $this->typeMappings[$columnName] = $type; if ( ! $this->isMixed && $this->fieldMappings) { $this->isMixed = true; } return $this; }
[ "public", "function", "addScalarResult", "(", "$", "columnName", ",", "$", "alias", ",", "$", "type", "=", "'string'", ")", "{", "$", "this", "->", "scalarMappings", "[", "$", "columnName", "]", "=", "$", "alias", ";", "$", "this", "->", "typeMappings", "[", "$", "columnName", "]", "=", "$", "type", ";", "if", "(", "!", "$", "this", "->", "isMixed", "&&", "$", "this", "->", "fieldMappings", ")", "{", "$", "this", "->", "isMixed", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Adds a scalar result mapping. @param string $columnName The name of the column in the SQL result set. @param string $alias The result alias with which the scalar result should be placed in the result structure. @param string $type The column type @return ResultSetMapping This ResultSetMapping instance. @todo Rename: addScalar
[ "Adds", "a", "scalar", "result", "mapping", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/ResultSetMapping.php#L377-L387
223,188
mmerian/phpcrawl
libs/ProcessCommunication/PHPCrawlerStatusHandler.class.php
PHPCrawlerStatusHandler.updateCrawlerStatus
public function updateCrawlerStatus($PageInfo, $abort_reason = null, $first_content_url = null, $last_request_time = null) { PHPCrawlerBenchmark::start("updating_crawler_status"); // Set semaphore/lock if if ($this->lock_status_updates == true) { $sem_key = sem_get($this->crawler_uniqid); sem_acquire($sem_key); } // Get current Status $crawler_status = $this->getCrawlerStatus(); // Update status if ($PageInfo != null) { // Increase number of followed links $crawler_status->links_followed++; // Increase documents_received-counter if ($PageInfo->received == true) $crawler_status->documents_received++; // Increase bytes-counter $crawler_status->bytes_received += $PageInfo->bytes_received + $PageInfo->header_bytes_received; // Benchmarks if ($PageInfo->error_occured == false) { // server connect time $crawler_status->sum_server_connect_time += $PageInfo->server_connect_time; $crawler_status->sum_server_connects++; // server response time $crawler_status->sum_server_response_time += $PageInfo->server_response_time; $crawler_status->sum_server_responses++; // data transfer time $crawler_status->sum_data_transfer_time += $PageInfo->data_transfer_time; // unbuffered bytes read $crawler_status->unbuffered_bytes_read += $PageInfo->unbuffered_bytes_read; } } // Set abortreason if ($abort_reason !== null) $crawler_status->abort_reason = $abort_reason; // Set first_content_url if ($first_content_url !== null) $crawler_status->first_content_url = $first_content_url; // Set last request-time if ($last_request_time !== null) $crawler_status->last_request_time = $last_request_time; // Write crawler-status back $this->setCrawlerStatus($crawler_status); // Remove semaphore/lock if ($this->lock_status_updates == true) { sem_release($sem_key); } PHPCrawlerBenchmark::stop("updating_crawler_status"); }
php
public function updateCrawlerStatus($PageInfo, $abort_reason = null, $first_content_url = null, $last_request_time = null) { PHPCrawlerBenchmark::start("updating_crawler_status"); // Set semaphore/lock if if ($this->lock_status_updates == true) { $sem_key = sem_get($this->crawler_uniqid); sem_acquire($sem_key); } // Get current Status $crawler_status = $this->getCrawlerStatus(); // Update status if ($PageInfo != null) { // Increase number of followed links $crawler_status->links_followed++; // Increase documents_received-counter if ($PageInfo->received == true) $crawler_status->documents_received++; // Increase bytes-counter $crawler_status->bytes_received += $PageInfo->bytes_received + $PageInfo->header_bytes_received; // Benchmarks if ($PageInfo->error_occured == false) { // server connect time $crawler_status->sum_server_connect_time += $PageInfo->server_connect_time; $crawler_status->sum_server_connects++; // server response time $crawler_status->sum_server_response_time += $PageInfo->server_response_time; $crawler_status->sum_server_responses++; // data transfer time $crawler_status->sum_data_transfer_time += $PageInfo->data_transfer_time; // unbuffered bytes read $crawler_status->unbuffered_bytes_read += $PageInfo->unbuffered_bytes_read; } } // Set abortreason if ($abort_reason !== null) $crawler_status->abort_reason = $abort_reason; // Set first_content_url if ($first_content_url !== null) $crawler_status->first_content_url = $first_content_url; // Set last request-time if ($last_request_time !== null) $crawler_status->last_request_time = $last_request_time; // Write crawler-status back $this->setCrawlerStatus($crawler_status); // Remove semaphore/lock if ($this->lock_status_updates == true) { sem_release($sem_key); } PHPCrawlerBenchmark::stop("updating_crawler_status"); }
[ "public", "function", "updateCrawlerStatus", "(", "$", "PageInfo", ",", "$", "abort_reason", "=", "null", ",", "$", "first_content_url", "=", "null", ",", "$", "last_request_time", "=", "null", ")", "{", "PHPCrawlerBenchmark", "::", "start", "(", "\"updating_crawler_status\"", ")", ";", "// Set semaphore/lock if\r", "if", "(", "$", "this", "->", "lock_status_updates", "==", "true", ")", "{", "$", "sem_key", "=", "sem_get", "(", "$", "this", "->", "crawler_uniqid", ")", ";", "sem_acquire", "(", "$", "sem_key", ")", ";", "}", "// Get current Status\r", "$", "crawler_status", "=", "$", "this", "->", "getCrawlerStatus", "(", ")", ";", "// Update status\r", "if", "(", "$", "PageInfo", "!=", "null", ")", "{", "// Increase number of followed links\r", "$", "crawler_status", "->", "links_followed", "++", ";", "// Increase documents_received-counter\r", "if", "(", "$", "PageInfo", "->", "received", "==", "true", ")", "$", "crawler_status", "->", "documents_received", "++", ";", "// Increase bytes-counter\r", "$", "crawler_status", "->", "bytes_received", "+=", "$", "PageInfo", "->", "bytes_received", "+", "$", "PageInfo", "->", "header_bytes_received", ";", "// Benchmarks\r", "if", "(", "$", "PageInfo", "->", "error_occured", "==", "false", ")", "{", "// server connect time\r", "$", "crawler_status", "->", "sum_server_connect_time", "+=", "$", "PageInfo", "->", "server_connect_time", ";", "$", "crawler_status", "->", "sum_server_connects", "++", ";", "// server response time\r", "$", "crawler_status", "->", "sum_server_response_time", "+=", "$", "PageInfo", "->", "server_response_time", ";", "$", "crawler_status", "->", "sum_server_responses", "++", ";", "// data transfer time\r", "$", "crawler_status", "->", "sum_data_transfer_time", "+=", "$", "PageInfo", "->", "data_transfer_time", ";", "// unbuffered bytes read\r", "$", "crawler_status", "->", "unbuffered_bytes_read", "+=", "$", "PageInfo", "->", "unbuffered_bytes_read", ";", "}", "}", "// Set abortreason\r", "if", "(", "$", "abort_reason", "!==", "null", ")", "$", "crawler_status", "->", "abort_reason", "=", "$", "abort_reason", ";", "// Set first_content_url\r", "if", "(", "$", "first_content_url", "!==", "null", ")", "$", "crawler_status", "->", "first_content_url", "=", "$", "first_content_url", ";", "// Set last request-time\r", "if", "(", "$", "last_request_time", "!==", "null", ")", "$", "crawler_status", "->", "last_request_time", "=", "$", "last_request_time", ";", "// Write crawler-status back\r", "$", "this", "->", "setCrawlerStatus", "(", "$", "crawler_status", ")", ";", "// Remove semaphore/lock\r", "if", "(", "$", "this", "->", "lock_status_updates", "==", "true", ")", "{", "sem_release", "(", "$", "sem_key", ")", ";", "}", "PHPCrawlerBenchmark", "::", "stop", "(", "\"updating_crawler_status\"", ")", ";", "}" ]
Updates the status of the crawler @param PHPCrawlerDocumentInfo $PageInfo The PHPCrawlerDocumentInfo-object of the last received document or NULL if no document was received. @param int $abort_reason One of the PHPCrawlerAbortReasons::ABORTREASON-constants if the crawling-process should get aborted, otherwise NULL @param string $first_content_url The first URL some content was found in (or NULL if no content was found so far).
[ "Updates", "the", "status", "of", "the", "crawler" ]
1c5e07ff33cf079c69191eb9540a3ced64d392dc
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/ProcessCommunication/PHPCrawlerStatusHandler.class.php#L79-L143
223,189
mespronos/mespronos
src/Entity/Day.php
Day.postSave
public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); if (\Drupal::moduleHandler()->moduleExists('pathauto')) { \Drupal::service('pathauto.generator')->updateEntityAlias($this, 'update'); $trans = \Drupal::service('transliteration'); $alias_manager = \Drupal::service('path.alias_manager'); $alias_storage = \Drupal::service('path.alias_storage'); $system_path = '/mespronos/day/'.$this->id().'/bet'; $alias_day = $alias_manager->getAliasByPath('/mespronos/day/'.$this->id()); $path_alias = str_replace('.html', '', $alias_day).'/pronostiquer.html'; $urlAlias = $alias_manager->getAliasByPath($system_path); if ($urlAlias && $urlAlias != $path_alias) { $alias_storage->save($system_path, $path_alias); } $user_ids = \Drupal::entityQuery('user')->execute(); $users = \Drupal::entityTypeManager()->getStorage("user")->loadMultiple($user_ids); foreach ($users as $user) { $system_path = '/mespronos/day/'.$this->id().'/results/user/'.$user->id(); $path_alias = str_replace('.html', '', $alias_day).'/les-pronos-de-'.$trans->transliterate($user->label()).'.html'; $urlAlias = $alias_manager->getAliasByPath($system_path); if ($urlAlias && $urlAlias != $path_alias) { $alias_storage->save($system_path, $path_alias); } } } }
php
public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); if (\Drupal::moduleHandler()->moduleExists('pathauto')) { \Drupal::service('pathauto.generator')->updateEntityAlias($this, 'update'); $trans = \Drupal::service('transliteration'); $alias_manager = \Drupal::service('path.alias_manager'); $alias_storage = \Drupal::service('path.alias_storage'); $system_path = '/mespronos/day/'.$this->id().'/bet'; $alias_day = $alias_manager->getAliasByPath('/mespronos/day/'.$this->id()); $path_alias = str_replace('.html', '', $alias_day).'/pronostiquer.html'; $urlAlias = $alias_manager->getAliasByPath($system_path); if ($urlAlias && $urlAlias != $path_alias) { $alias_storage->save($system_path, $path_alias); } $user_ids = \Drupal::entityQuery('user')->execute(); $users = \Drupal::entityTypeManager()->getStorage("user")->loadMultiple($user_ids); foreach ($users as $user) { $system_path = '/mespronos/day/'.$this->id().'/results/user/'.$user->id(); $path_alias = str_replace('.html', '', $alias_day).'/les-pronos-de-'.$trans->transliterate($user->label()).'.html'; $urlAlias = $alias_manager->getAliasByPath($system_path); if ($urlAlias && $urlAlias != $path_alias) { $alias_storage->save($system_path, $path_alias); } } } }
[ "public", "function", "postSave", "(", "EntityStorageInterface", "$", "storage", ",", "$", "update", "=", "TRUE", ")", "{", "parent", "::", "postSave", "(", "$", "storage", ",", "$", "update", ")", ";", "if", "(", "\\", "Drupal", "::", "moduleHandler", "(", ")", "->", "moduleExists", "(", "'pathauto'", ")", ")", "{", "\\", "Drupal", "::", "service", "(", "'pathauto.generator'", ")", "->", "updateEntityAlias", "(", "$", "this", ",", "'update'", ")", ";", "$", "trans", "=", "\\", "Drupal", "::", "service", "(", "'transliteration'", ")", ";", "$", "alias_manager", "=", "\\", "Drupal", "::", "service", "(", "'path.alias_manager'", ")", ";", "$", "alias_storage", "=", "\\", "Drupal", "::", "service", "(", "'path.alias_storage'", ")", ";", "$", "system_path", "=", "'/mespronos/day/'", ".", "$", "this", "->", "id", "(", ")", ".", "'/bet'", ";", "$", "alias_day", "=", "$", "alias_manager", "->", "getAliasByPath", "(", "'/mespronos/day/'", ".", "$", "this", "->", "id", "(", ")", ")", ";", "$", "path_alias", "=", "str_replace", "(", "'.html'", ",", "''", ",", "$", "alias_day", ")", ".", "'/pronostiquer.html'", ";", "$", "urlAlias", "=", "$", "alias_manager", "->", "getAliasByPath", "(", "$", "system_path", ")", ";", "if", "(", "$", "urlAlias", "&&", "$", "urlAlias", "!=", "$", "path_alias", ")", "{", "$", "alias_storage", "->", "save", "(", "$", "system_path", ",", "$", "path_alias", ")", ";", "}", "$", "user_ids", "=", "\\", "Drupal", "::", "entityQuery", "(", "'user'", ")", "->", "execute", "(", ")", ";", "$", "users", "=", "\\", "Drupal", "::", "entityTypeManager", "(", ")", "->", "getStorage", "(", "\"user\"", ")", "->", "loadMultiple", "(", "$", "user_ids", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "system_path", "=", "'/mespronos/day/'", ".", "$", "this", "->", "id", "(", ")", ".", "'/results/user/'", ".", "$", "user", "->", "id", "(", ")", ";", "$", "path_alias", "=", "str_replace", "(", "'.html'", ",", "''", ",", "$", "alias_day", ")", ".", "'/les-pronos-de-'", ".", "$", "trans", "->", "transliterate", "(", "$", "user", "->", "label", "(", ")", ")", ".", "'.html'", ";", "$", "urlAlias", "=", "$", "alias_manager", "->", "getAliasByPath", "(", "$", "system_path", ")", ";", "if", "(", "$", "urlAlias", "&&", "$", "urlAlias", "!=", "$", "path_alias", ")", "{", "$", "alias_storage", "->", "save", "(", "$", "system_path", ",", "$", "path_alias", ")", ";", "}", "}", "}", "}" ]
Create pathauto aliases for the day @param \Drupal\Core\Entity\EntityStorageInterface $storage @param bool $update
[ "Create", "pathauto", "aliases", "for", "the", "day" ]
73757663581ed9040944768073d1d9abc761196b
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Entity/Day.php#L72-L100
223,190
shopsys/doctrine-orm
lib/Doctrine/ORM/Query/SqlWalker.php
SqlWalker.getSQLColumnAlias
public function getSQLColumnAlias($columnName) { return $this->quoteStrategy->getColumnAlias($columnName, $this->aliasCounter++, $this->platform); }
php
public function getSQLColumnAlias($columnName) { return $this->quoteStrategy->getColumnAlias($columnName, $this->aliasCounter++, $this->platform); }
[ "public", "function", "getSQLColumnAlias", "(", "$", "columnName", ")", "{", "return", "$", "this", "->", "quoteStrategy", "->", "getColumnAlias", "(", "$", "columnName", ",", "$", "this", "->", "aliasCounter", "++", ",", "$", "this", "->", "platform", ")", ";", "}" ]
Gets an SQL column alias for a column name. @param string $columnName @return string
[ "Gets", "an", "SQL", "column", "alias", "for", "a", "column", "name", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/SqlWalker.php#L327-L330
223,191
shopsys/doctrine-orm
lib/Doctrine/ORM/Query/SqlWalker.php
SqlWalker.walkRangeVariableDeclaration
public function walkRangeVariableDeclaration($rangeVariableDeclaration) { $class = $this->em->getClassMetadata($rangeVariableDeclaration->abstractSchemaName); $dqlAlias = $rangeVariableDeclaration->aliasIdentificationVariable; if ($rangeVariableDeclaration->isRoot) { $this->rootAliases[] = $dqlAlias; } $sql = $this->platform->appendLockHint( $this->quoteStrategy->getTableName($class, $this->platform) . ' ' . $this->getSQLTableAlias($class->getTableName(), $dqlAlias), $this->query->getHint(Query::HINT_LOCK_MODE) ); if ($class->isInheritanceTypeJoined()) { $sql .= $this->_generateClassTableInheritanceJoins($class, $dqlAlias); } return $sql; }
php
public function walkRangeVariableDeclaration($rangeVariableDeclaration) { $class = $this->em->getClassMetadata($rangeVariableDeclaration->abstractSchemaName); $dqlAlias = $rangeVariableDeclaration->aliasIdentificationVariable; if ($rangeVariableDeclaration->isRoot) { $this->rootAliases[] = $dqlAlias; } $sql = $this->platform->appendLockHint( $this->quoteStrategy->getTableName($class, $this->platform) . ' ' . $this->getSQLTableAlias($class->getTableName(), $dqlAlias), $this->query->getHint(Query::HINT_LOCK_MODE) ); if ($class->isInheritanceTypeJoined()) { $sql .= $this->_generateClassTableInheritanceJoins($class, $dqlAlias); } return $sql; }
[ "public", "function", "walkRangeVariableDeclaration", "(", "$", "rangeVariableDeclaration", ")", "{", "$", "class", "=", "$", "this", "->", "em", "->", "getClassMetadata", "(", "$", "rangeVariableDeclaration", "->", "abstractSchemaName", ")", ";", "$", "dqlAlias", "=", "$", "rangeVariableDeclaration", "->", "aliasIdentificationVariable", ";", "if", "(", "$", "rangeVariableDeclaration", "->", "isRoot", ")", "{", "$", "this", "->", "rootAliases", "[", "]", "=", "$", "dqlAlias", ";", "}", "$", "sql", "=", "$", "this", "->", "platform", "->", "appendLockHint", "(", "$", "this", "->", "quoteStrategy", "->", "getTableName", "(", "$", "class", ",", "$", "this", "->", "platform", ")", ".", "' '", ".", "$", "this", "->", "getSQLTableAlias", "(", "$", "class", "->", "getTableName", "(", ")", ",", "$", "dqlAlias", ")", ",", "$", "this", "->", "query", "->", "getHint", "(", "Query", "::", "HINT_LOCK_MODE", ")", ")", ";", "if", "(", "$", "class", "->", "isInheritanceTypeJoined", "(", ")", ")", "{", "$", "sql", ".=", "$", "this", "->", "_generateClassTableInheritanceJoins", "(", "$", "class", ",", "$", "dqlAlias", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL. @param AST\RangeVariableDeclaration $rangeVariableDeclaration @return string
[ "Walks", "down", "a", "RangeVariableDeclaration", "AST", "node", "thereby", "generating", "the", "appropriate", "SQL", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/SqlWalker.php#L872-L892
223,192
shopsys/doctrine-orm
lib/Doctrine/ORM/Query/SqlWalker.php
SqlWalker.walkCaseExpression
public function walkCaseExpression($expression) { switch (true) { case ($expression instanceof AST\CoalesceExpression): return $this->walkCoalesceExpression($expression); case ($expression instanceof AST\NullIfExpression): return $this->walkNullIfExpression($expression); case ($expression instanceof AST\GeneralCaseExpression): return $this->walkGeneralCaseExpression($expression); case ($expression instanceof AST\SimpleCaseExpression): return $this->walkSimpleCaseExpression($expression); default: return ''; } }
php
public function walkCaseExpression($expression) { switch (true) { case ($expression instanceof AST\CoalesceExpression): return $this->walkCoalesceExpression($expression); case ($expression instanceof AST\NullIfExpression): return $this->walkNullIfExpression($expression); case ($expression instanceof AST\GeneralCaseExpression): return $this->walkGeneralCaseExpression($expression); case ($expression instanceof AST\SimpleCaseExpression): return $this->walkSimpleCaseExpression($expression); default: return ''; } }
[ "public", "function", "walkCaseExpression", "(", "$", "expression", ")", "{", "switch", "(", "true", ")", "{", "case", "(", "$", "expression", "instanceof", "AST", "\\", "CoalesceExpression", ")", ":", "return", "$", "this", "->", "walkCoalesceExpression", "(", "$", "expression", ")", ";", "case", "(", "$", "expression", "instanceof", "AST", "\\", "NullIfExpression", ")", ":", "return", "$", "this", "->", "walkNullIfExpression", "(", "$", "expression", ")", ";", "case", "(", "$", "expression", "instanceof", "AST", "\\", "GeneralCaseExpression", ")", ":", "return", "$", "this", "->", "walkGeneralCaseExpression", "(", "$", "expression", ")", ";", "case", "(", "$", "expression", "instanceof", "AST", "\\", "SimpleCaseExpression", ")", ":", "return", "$", "this", "->", "walkSimpleCaseExpression", "(", "$", "expression", ")", ";", "default", ":", "return", "''", ";", "}", "}" ]
Walks down a CaseExpression AST node and generates the corresponding SQL. @param AST\CoalesceExpression|AST\NullIfExpression|AST\GeneralCaseExpression|AST\SimpleCaseExpression $expression @return string The SQL.
[ "Walks", "down", "a", "CaseExpression", "AST", "node", "and", "generates", "the", "corresponding", "SQL", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/SqlWalker.php#L1169-L1187
223,193
shopsys/doctrine-orm
lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php
AttachEntityListenersListener.addEntityListener
public function addEntityListener($entityClass, $listenerClass, $eventName, $listenerCallback = null) { $this->entityListeners[ltrim($entityClass, '\\')][] = array( 'event' => $eventName, 'class' => $listenerClass, 'method' => $listenerCallback ?: $eventName ); }
php
public function addEntityListener($entityClass, $listenerClass, $eventName, $listenerCallback = null) { $this->entityListeners[ltrim($entityClass, '\\')][] = array( 'event' => $eventName, 'class' => $listenerClass, 'method' => $listenerCallback ?: $eventName ); }
[ "public", "function", "addEntityListener", "(", "$", "entityClass", ",", "$", "listenerClass", ",", "$", "eventName", ",", "$", "listenerCallback", "=", "null", ")", "{", "$", "this", "->", "entityListeners", "[", "ltrim", "(", "$", "entityClass", ",", "'\\\\'", ")", "]", "[", "]", "=", "array", "(", "'event'", "=>", "$", "eventName", ",", "'class'", "=>", "$", "listenerClass", ",", "'method'", "=>", "$", "listenerCallback", "?", ":", "$", "eventName", ")", ";", "}" ]
Adds a entity listener for a specific entity. @param string $entityClass The entity to attach the listener. @param string $listenerClass The listener class. @param string $eventName The entity lifecycle event. @param string $listenerCallback|null The listener callback method or NULL to use $eventName. @return void
[ "Adds", "a", "entity", "listener", "for", "a", "specific", "entity", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php#L48-L55
223,194
shopsys/doctrine-orm
lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php
JoinedSubclassPersister.getVersionedClassMetadata
private function getVersionedClassMetadata() { if (isset($this->class->fieldMappings[$this->class->versionField]['inherited'])) { $definingClassName = $this->class->fieldMappings[$this->class->versionField]['inherited']; return $this->em->getClassMetadata($definingClassName); } return $this->class; }
php
private function getVersionedClassMetadata() { if (isset($this->class->fieldMappings[$this->class->versionField]['inherited'])) { $definingClassName = $this->class->fieldMappings[$this->class->versionField]['inherited']; return $this->em->getClassMetadata($definingClassName); } return $this->class; }
[ "private", "function", "getVersionedClassMetadata", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "class", "->", "fieldMappings", "[", "$", "this", "->", "class", "->", "versionField", "]", "[", "'inherited'", "]", ")", ")", "{", "$", "definingClassName", "=", "$", "this", "->", "class", "->", "fieldMappings", "[", "$", "this", "->", "class", "->", "versionField", "]", "[", "'inherited'", "]", ";", "return", "$", "this", "->", "em", "->", "getClassMetadata", "(", "$", "definingClassName", ")", ";", "}", "return", "$", "this", "->", "class", ";", "}" ]
This function finds the ClassMetadata instance in an inheritance hierarchy that is responsible for enabling versioning. @return \Doctrine\ORM\Mapping\ClassMetadata
[ "This", "function", "finds", "the", "ClassMetadata", "instance", "in", "an", "inheritance", "hierarchy", "that", "is", "responsible", "for", "enabling", "versioning", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php#L76-L85
223,195
shopsys/doctrine-orm
lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php
JoinedSubclassPersister.getOwningTable
public function getOwningTable($fieldName) { if (isset($this->owningTableMap[$fieldName])) { return $this->owningTableMap[$fieldName]; } switch (true) { case isset($this->class->associationMappings[$fieldName]['inherited']): $cm = $this->em->getClassMetadata($this->class->associationMappings[$fieldName]['inherited']); break; case isset($this->class->fieldMappings[$fieldName]['inherited']): $cm = $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]['inherited']); break; default: $cm = $this->class; break; } $tableName = $cm->getTableName(); $quotedTableName = $this->quoteStrategy->getTableName($cm, $this->platform); $this->owningTableMap[$fieldName] = $tableName; $this->quotedTableMap[$tableName] = $quotedTableName; return $tableName; }
php
public function getOwningTable($fieldName) { if (isset($this->owningTableMap[$fieldName])) { return $this->owningTableMap[$fieldName]; } switch (true) { case isset($this->class->associationMappings[$fieldName]['inherited']): $cm = $this->em->getClassMetadata($this->class->associationMappings[$fieldName]['inherited']); break; case isset($this->class->fieldMappings[$fieldName]['inherited']): $cm = $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]['inherited']); break; default: $cm = $this->class; break; } $tableName = $cm->getTableName(); $quotedTableName = $this->quoteStrategy->getTableName($cm, $this->platform); $this->owningTableMap[$fieldName] = $tableName; $this->quotedTableMap[$tableName] = $quotedTableName; return $tableName; }
[ "public", "function", "getOwningTable", "(", "$", "fieldName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "owningTableMap", "[", "$", "fieldName", "]", ")", ")", "{", "return", "$", "this", "->", "owningTableMap", "[", "$", "fieldName", "]", ";", "}", "switch", "(", "true", ")", "{", "case", "isset", "(", "$", "this", "->", "class", "->", "associationMappings", "[", "$", "fieldName", "]", "[", "'inherited'", "]", ")", ":", "$", "cm", "=", "$", "this", "->", "em", "->", "getClassMetadata", "(", "$", "this", "->", "class", "->", "associationMappings", "[", "$", "fieldName", "]", "[", "'inherited'", "]", ")", ";", "break", ";", "case", "isset", "(", "$", "this", "->", "class", "->", "fieldMappings", "[", "$", "fieldName", "]", "[", "'inherited'", "]", ")", ":", "$", "cm", "=", "$", "this", "->", "em", "->", "getClassMetadata", "(", "$", "this", "->", "class", "->", "fieldMappings", "[", "$", "fieldName", "]", "[", "'inherited'", "]", ")", ";", "break", ";", "default", ":", "$", "cm", "=", "$", "this", "->", "class", ";", "break", ";", "}", "$", "tableName", "=", "$", "cm", "->", "getTableName", "(", ")", ";", "$", "quotedTableName", "=", "$", "this", "->", "quoteStrategy", "->", "getTableName", "(", "$", "cm", ",", "$", "this", "->", "platform", ")", ";", "$", "this", "->", "owningTableMap", "[", "$", "fieldName", "]", "=", "$", "tableName", ";", "$", "this", "->", "quotedTableMap", "[", "$", "tableName", "]", "=", "$", "quotedTableName", ";", "return", "$", "tableName", ";", "}" ]
Gets the name of the table that owns the column the given field is mapped to. @param string $fieldName @return string @override
[ "Gets", "the", "name", "of", "the", "table", "that", "owns", "the", "column", "the", "given", "field", "is", "mapped", "to", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php#L96-L123
223,196
shopsys/doctrine-orm
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
ClassMetadataFactory.addDefaultDiscriminatorMap
private function addDefaultDiscriminatorMap(ClassMetadata $class) { $allClasses = $this->driver->getAllClassNames(); $fqcn = $class->getName(); $map = array($this->getShortName($class->name) => $fqcn); $duplicates = array(); foreach ($allClasses as $subClassCandidate) { if (is_subclass_of($subClassCandidate, $fqcn)) { $shortName = $this->getShortName($subClassCandidate); if (isset($map[$shortName])) { $duplicates[] = $shortName; } $map[$shortName] = $subClassCandidate; } } if ($duplicates) { throw MappingException::duplicateDiscriminatorEntry($class->name, $duplicates, $map); } $class->setDiscriminatorMap($map); }
php
private function addDefaultDiscriminatorMap(ClassMetadata $class) { $allClasses = $this->driver->getAllClassNames(); $fqcn = $class->getName(); $map = array($this->getShortName($class->name) => $fqcn); $duplicates = array(); foreach ($allClasses as $subClassCandidate) { if (is_subclass_of($subClassCandidate, $fqcn)) { $shortName = $this->getShortName($subClassCandidate); if (isset($map[$shortName])) { $duplicates[] = $shortName; } $map[$shortName] = $subClassCandidate; } } if ($duplicates) { throw MappingException::duplicateDiscriminatorEntry($class->name, $duplicates, $map); } $class->setDiscriminatorMap($map); }
[ "private", "function", "addDefaultDiscriminatorMap", "(", "ClassMetadata", "$", "class", ")", "{", "$", "allClasses", "=", "$", "this", "->", "driver", "->", "getAllClassNames", "(", ")", ";", "$", "fqcn", "=", "$", "class", "->", "getName", "(", ")", ";", "$", "map", "=", "array", "(", "$", "this", "->", "getShortName", "(", "$", "class", "->", "name", ")", "=>", "$", "fqcn", ")", ";", "$", "duplicates", "=", "array", "(", ")", ";", "foreach", "(", "$", "allClasses", "as", "$", "subClassCandidate", ")", "{", "if", "(", "is_subclass_of", "(", "$", "subClassCandidate", ",", "$", "fqcn", ")", ")", "{", "$", "shortName", "=", "$", "this", "->", "getShortName", "(", "$", "subClassCandidate", ")", ";", "if", "(", "isset", "(", "$", "map", "[", "$", "shortName", "]", ")", ")", "{", "$", "duplicates", "[", "]", "=", "$", "shortName", ";", "}", "$", "map", "[", "$", "shortName", "]", "=", "$", "subClassCandidate", ";", "}", "}", "if", "(", "$", "duplicates", ")", "{", "throw", "MappingException", "::", "duplicateDiscriminatorEntry", "(", "$", "class", "->", "name", ",", "$", "duplicates", ",", "$", "map", ")", ";", "}", "$", "class", "->", "setDiscriminatorMap", "(", "$", "map", ")", ";", "}" ]
Adds a default discriminator map if no one is given If an entity is of any inheritance type and does not contain a discriminator map, then the map is generated automatically. This process is expensive computation wise. The automatically generated discriminator map contains the lowercase short name of each class as key. @param \Doctrine\ORM\Mapping\ClassMetadata $class @throws MappingException
[ "Adds", "a", "default", "discriminator", "map", "if", "no", "one", "is", "given" ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php#L355-L379
223,197
shopsys/doctrine-orm
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
ClassMetadataFactory.getShortName
private function getShortName($className) { if (strpos($className, "\\") === false) { return strtolower($className); } $parts = explode("\\", $className); return strtolower(end($parts)); }
php
private function getShortName($className) { if (strpos($className, "\\") === false) { return strtolower($className); } $parts = explode("\\", $className); return strtolower(end($parts)); }
[ "private", "function", "getShortName", "(", "$", "className", ")", "{", "if", "(", "strpos", "(", "$", "className", ",", "\"\\\\\"", ")", "===", "false", ")", "{", "return", "strtolower", "(", "$", "className", ")", ";", "}", "$", "parts", "=", "explode", "(", "\"\\\\\"", ",", "$", "className", ")", ";", "return", "strtolower", "(", "end", "(", "$", "parts", ")", ")", ";", "}" ]
Gets the lower-case short name of a class. @param string $className @return string
[ "Gets", "the", "lower", "-", "case", "short", "name", "of", "a", "class", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php#L388-L396
223,198
shopsys/doctrine-orm
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
ClassMetadataFactory.addNestedEmbeddedClasses
private function addNestedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass, $prefix) { foreach ($subClass->embeddedClasses as $property => $embeddableClass) { if (isset($embeddableClass['inherited'])) { continue; } $embeddableMetadata = $this->getMetadataFor($embeddableClass['class']); $parentClass->mapEmbedded(array( 'fieldName' => $prefix . '.' . $property, 'class' => $embeddableMetadata->name, 'columnPrefix' => $embeddableClass['columnPrefix'], 'declaredField' => $embeddableClass['declaredField'] ? $prefix . '.' . $embeddableClass['declaredField'] : $prefix, 'originalField' => $embeddableClass['originalField'] ?: $property, )); } }
php
private function addNestedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass, $prefix) { foreach ($subClass->embeddedClasses as $property => $embeddableClass) { if (isset($embeddableClass['inherited'])) { continue; } $embeddableMetadata = $this->getMetadataFor($embeddableClass['class']); $parentClass->mapEmbedded(array( 'fieldName' => $prefix . '.' . $property, 'class' => $embeddableMetadata->name, 'columnPrefix' => $embeddableClass['columnPrefix'], 'declaredField' => $embeddableClass['declaredField'] ? $prefix . '.' . $embeddableClass['declaredField'] : $prefix, 'originalField' => $embeddableClass['originalField'] ?: $property, )); } }
[ "private", "function", "addNestedEmbeddedClasses", "(", "ClassMetadata", "$", "subClass", ",", "ClassMetadata", "$", "parentClass", ",", "$", "prefix", ")", "{", "foreach", "(", "$", "subClass", "->", "embeddedClasses", "as", "$", "property", "=>", "$", "embeddableClass", ")", "{", "if", "(", "isset", "(", "$", "embeddableClass", "[", "'inherited'", "]", ")", ")", "{", "continue", ";", "}", "$", "embeddableMetadata", "=", "$", "this", "->", "getMetadataFor", "(", "$", "embeddableClass", "[", "'class'", "]", ")", ";", "$", "parentClass", "->", "mapEmbedded", "(", "array", "(", "'fieldName'", "=>", "$", "prefix", ".", "'.'", ".", "$", "property", ",", "'class'", "=>", "$", "embeddableMetadata", "->", "name", ",", "'columnPrefix'", "=>", "$", "embeddableClass", "[", "'columnPrefix'", "]", ",", "'declaredField'", "=>", "$", "embeddableClass", "[", "'declaredField'", "]", "?", "$", "prefix", ".", "'.'", ".", "$", "embeddableClass", "[", "'declaredField'", "]", ":", "$", "prefix", ",", "'originalField'", "=>", "$", "embeddableClass", "[", "'originalField'", "]", "?", ":", "$", "property", ",", ")", ")", ";", "}", "}" ]
Adds nested embedded classes metadata to a parent class. @param ClassMetadata $subClass Sub embedded class metadata to add nested embedded classes metadata from. @param ClassMetadata $parentClass Parent class to add nested embedded classes metadata to. @param string $prefix Embedded classes' prefix to use for nested embedded classes field names.
[ "Adds", "nested", "embedded", "classes", "metadata", "to", "a", "parent", "class", "." ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php#L474-L493
223,199
shopsys/doctrine-orm
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
ClassMetadataFactory.addInheritedIndexes
private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $parentClass) { if (! $parentClass->isMappedSuperclass) { return; } foreach (array('uniqueConstraints', 'indexes') as $indexType) { if (isset($parentClass->table[$indexType])) { foreach ($parentClass->table[$indexType] as $indexName => $index) { if (isset($subClass->table[$indexType][$indexName])) { continue; // Let the inheriting table override indices } $subClass->table[$indexType][$indexName] = $index; } } } }
php
private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $parentClass) { if (! $parentClass->isMappedSuperclass) { return; } foreach (array('uniqueConstraints', 'indexes') as $indexType) { if (isset($parentClass->table[$indexType])) { foreach ($parentClass->table[$indexType] as $indexName => $index) { if (isset($subClass->table[$indexType][$indexName])) { continue; // Let the inheriting table override indices } $subClass->table[$indexType][$indexName] = $index; } } } }
[ "private", "function", "addInheritedIndexes", "(", "ClassMetadata", "$", "subClass", ",", "ClassMetadata", "$", "parentClass", ")", "{", "if", "(", "!", "$", "parentClass", "->", "isMappedSuperclass", ")", "{", "return", ";", "}", "foreach", "(", "array", "(", "'uniqueConstraints'", ",", "'indexes'", ")", "as", "$", "indexType", ")", "{", "if", "(", "isset", "(", "$", "parentClass", "->", "table", "[", "$", "indexType", "]", ")", ")", "{", "foreach", "(", "$", "parentClass", "->", "table", "[", "$", "indexType", "]", "as", "$", "indexName", "=>", "$", "index", ")", "{", "if", "(", "isset", "(", "$", "subClass", "->", "table", "[", "$", "indexType", "]", "[", "$", "indexName", "]", ")", ")", "{", "continue", ";", "// Let the inheriting table override indices", "}", "$", "subClass", "->", "table", "[", "$", "indexType", "]", "[", "$", "indexName", "]", "=", "$", "index", ";", "}", "}", "}", "}" ]
Copy the table indices from the parent class superclass to the child class @param ClassMetadata $subClass @param ClassMetadata $parentClass @return void
[ "Copy", "the", "table", "indices", "from", "the", "parent", "class", "superclass", "to", "the", "child", "class" ]
faf2288cd1c133c4b5340079a26aa4f14dd7beab
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php#L503-L520