repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasManager.php
AliasManager.removeCustomAlias
public function removeCustomAlias($nodeId, $siteId) { $this ->database ->update('ucms_seo_route') ->condition('node_id', $nodeId) ->condition('site_id', $siteId) ->fields(['is_protected' => 0, 'is_outdated' => 1]) ->execute() ; }
php
public function removeCustomAlias($nodeId, $siteId) { $this ->database ->update('ucms_seo_route') ->condition('node_id', $nodeId) ->condition('site_id', $siteId) ->fields(['is_protected' => 0, 'is_outdated' => 1]) ->execute() ; }
[ "public", "function", "removeCustomAlias", "(", "$", "nodeId", ",", "$", "siteId", ")", "{", "$", "this", "->", "database", "->", "update", "(", "'ucms_seo_route'", ")", "->", "condition", "(", "'node_id'", ",", "$", "nodeId", ")", "->", "condition", "(", ...
Remove custom alias for @param int $nodeId @param int $siteId
[ "Remove", "custom", "alias", "for" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L359-L369
train
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasManager.php
AliasManager.getPathAlias
public function getPathAlias($nodeId, $siteId) { $route = $this ->database ->query( "SELECT route, is_outdated FROM {ucms_seo_route} WHERE node_id = :node AND site_id = :site", [':node' => $nodeId, ':site' => $siteId] ) ->fetch() ; if (!$route || $route->is_outdated) { return $this->computeAndStorePathAlias($nodeId, $siteId, ($route ? $route->route : null)); } else { return $route->route; } }
php
public function getPathAlias($nodeId, $siteId) { $route = $this ->database ->query( "SELECT route, is_outdated FROM {ucms_seo_route} WHERE node_id = :node AND site_id = :site", [':node' => $nodeId, ':site' => $siteId] ) ->fetch() ; if (!$route || $route->is_outdated) { return $this->computeAndStorePathAlias($nodeId, $siteId, ($route ? $route->route : null)); } else { return $route->route; } }
[ "public", "function", "getPathAlias", "(", "$", "nodeId", ",", "$", "siteId", ")", "{", "$", "route", "=", "$", "this", "->", "database", "->", "query", "(", "\"SELECT route, is_outdated FROM {ucms_seo_route} WHERE node_id = :node AND site_id = :site\"", ",", "[", "':...
Get alias for node on site Internally, if no alias was already computed, this will recompute and store it into a custom route match table. @param int $nodeId @param int $siteId @return string
[ "Get", "alias", "for", "node", "on", "site" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L402-L418
train
makinacorpus/drupal-ucms
ucms_seo/src/Path/AliasManager.php
AliasManager.matchPath
public function matchPath($alias, $siteId) { $nodeId = $this ->database ->query( "SELECT node_id FROM {ucms_seo_route} WHERE route = :route AND site_id = :site", [':route' => $alias, ':site' => $siteId] ) ->fetchField() ; return $nodeId ? ((int)$nodeId) : null; }
php
public function matchPath($alias, $siteId) { $nodeId = $this ->database ->query( "SELECT node_id FROM {ucms_seo_route} WHERE route = :route AND site_id = :site", [':route' => $alias, ':site' => $siteId] ) ->fetchField() ; return $nodeId ? ((int)$nodeId) : null; }
[ "public", "function", "matchPath", "(", "$", "alias", ",", "$", "siteId", ")", "{", "$", "nodeId", "=", "$", "this", "->", "database", "->", "query", "(", "\"SELECT node_id FROM {ucms_seo_route} WHERE route = :route AND site_id = :site\"", ",", "[", "':route'", "=>"...
Match path on given site @todo this one will be *very* hard to compute without umenu taking care of it for us; @param string $alias @param int $siteId @return null|int The node identifier if found
[ "Match", "path", "on", "given", "site" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/AliasManager.php#L432-L444
train
makinacorpus/drupal-ucms
ucms_site/src/Controller/AutocompleteController.php
AutocompleteController.userAutocompleteAction
public function userAutocompleteAction($string) { $manager = $this->getSiteManager(); $account = $this->getCurrentUser(); if (!$manager->getAccess()->userIsWebmaster($account) && !$this->isGranted(Access::PERM_USER_MANAGE_ALL)) { throw $this->createAccessDeniedException(); } $database = $this->getDatabaseConnection(); $q = $database ->select('users', 'u') ->fields('u', ['uid', 'name']) ->condition('u.name', '%' . $database->escapeLike($string) . '%', 'LIKE') ->condition('u.uid', [0, 1], 'NOT IN') ->orderBy('u.name', 'asc') ->range(0, 16) ->addTag('ucms_user_access') ; $suggest = []; foreach ($q->execute()->fetchAll() as $record) { $key = $record->name . ' [' . $record->uid . ']'; $suggest[$key] = check_plain($record->name); } return new JsonResponse($suggest); }
php
public function userAutocompleteAction($string) { $manager = $this->getSiteManager(); $account = $this->getCurrentUser(); if (!$manager->getAccess()->userIsWebmaster($account) && !$this->isGranted(Access::PERM_USER_MANAGE_ALL)) { throw $this->createAccessDeniedException(); } $database = $this->getDatabaseConnection(); $q = $database ->select('users', 'u') ->fields('u', ['uid', 'name']) ->condition('u.name', '%' . $database->escapeLike($string) . '%', 'LIKE') ->condition('u.uid', [0, 1], 'NOT IN') ->orderBy('u.name', 'asc') ->range(0, 16) ->addTag('ucms_user_access') ; $suggest = []; foreach ($q->execute()->fetchAll() as $record) { $key = $record->name . ' [' . $record->uid . ']'; $suggest[$key] = check_plain($record->name); } return new JsonResponse($suggest); }
[ "public", "function", "userAutocompleteAction", "(", "$", "string", ")", "{", "$", "manager", "=", "$", "this", "->", "getSiteManager", "(", ")", ";", "$", "account", "=", "$", "this", "->", "getCurrentUser", "(", ")", ";", "if", "(", "!", "$", "manage...
User autocomplete callback
[ "User", "autocomplete", "callback" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Controller/AutocompleteController.php#L45-L73
train
makinacorpus/drupal-ucms
ucms_composition/src/Command/MigrateFromLayoutCommand.php
MigrateFromLayoutCommand.parseSquash
private function parseSquash(string $string) : array { // As always, regexes to the rescue $matches = []; // @todo find out why using /^...$/ does not work capturing all groups if (!preg_match_all('/((\(\w+(?:\s+\w+)+\)\s*)+?)/ui', trim($string), $matches)) { throw new \InvalidArgumentException(); } $ret = []; foreach ($matches[1] as $group) { $ret[] = array_filter(preg_split('/[\(\)\s]+/', $group)); } return $ret; }
php
private function parseSquash(string $string) : array { // As always, regexes to the rescue $matches = []; // @todo find out why using /^...$/ does not work capturing all groups if (!preg_match_all('/((\(\w+(?:\s+\w+)+\)\s*)+?)/ui', trim($string), $matches)) { throw new \InvalidArgumentException(); } $ret = []; foreach ($matches[1] as $group) { $ret[] = array_filter(preg_split('/[\(\)\s]+/', $group)); } return $ret; }
[ "private", "function", "parseSquash", "(", "string", "$", "string", ")", ":", "array", "{", "// As always, regexes to the rescue", "$", "matches", "=", "[", "]", ";", "// @todo find out why using /^...$/ does not work capturing all groups", "if", "(", "!", "preg_match_all...
Parse the squash option @param string $string @return null|string[][]
[ "Parse", "the", "squash", "option" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_composition/src/Command/MigrateFromLayoutCommand.php#L62-L78
train
despark/ignicms
src/Console/Commands/File/ClearTemp.php
ClearTemp.handle
public function handle() { $deleteBefore = Carbon::now()->subWeek(); $filesToDelete = $this->tempModel->where('created_at', '<=', $deleteBefore)->get(); $failed = []; foreach ($filesToDelete as $file) { // delete the file if (! \File::delete($file->getTempPath())) { $this->output->warning(sprintf('%s file not found. Skipping...', $file->getTempPath())); } } $deletedRecords = DB::table($this->tempModel->getTable()) ->where('created_at', '<=', $deleteBefore) ->delete(); $this->output->success(sprintf('%d temp file cleaned', $deletedRecords)); }
php
public function handle() { $deleteBefore = Carbon::now()->subWeek(); $filesToDelete = $this->tempModel->where('created_at', '<=', $deleteBefore)->get(); $failed = []; foreach ($filesToDelete as $file) { // delete the file if (! \File::delete($file->getTempPath())) { $this->output->warning(sprintf('%s file not found. Skipping...', $file->getTempPath())); } } $deletedRecords = DB::table($this->tempModel->getTable()) ->where('created_at', '<=', $deleteBefore) ->delete(); $this->output->success(sprintf('%d temp file cleaned', $deletedRecords)); }
[ "public", "function", "handle", "(", ")", "{", "$", "deleteBefore", "=", "Carbon", "::", "now", "(", ")", "->", "subWeek", "(", ")", ";", "$", "filesToDelete", "=", "$", "this", "->", "tempModel", "->", "where", "(", "'created_at'", ",", "'<='", ",", ...
Run command.
[ "Run", "command", "." ]
d55775a4656a7e99017d2ef3f8160599d600d2a7
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Console/Commands/File/ClearTemp.php#L47-L65
train
despark/ignicms
public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Config.php
CI_Config.load
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { $file = ($file == '') ? 'config' : str_replace('.php', '', $file); $found = FALSE; $loaded = FALSE; $check_locations = defined('ENVIRONMENT') ? array(ENVIRONMENT.'/'.$file, $file) : array($file); foreach ($this->_config_paths as $path) { foreach ($check_locations as $location) { $file_path = $path.'config/'.$location.'.php'; if (in_array($file_path, $this->is_loaded, TRUE)) { $loaded = TRUE; continue 2; } if (file_exists($file_path)) { $found = TRUE; break; } } if ($found === FALSE) { continue; } include($file_path); if ( ! isset($config) OR ! is_array($config)) { if ($fail_gracefully === TRUE) { return FALSE; } show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.'); } if ($use_sections === TRUE) { if (isset($this->config[$file])) { $this->config[$file] = array_merge($this->config[$file], $config); } else { $this->config[$file] = $config; } } else { $this->config = array_merge($this->config, $config); } $this->is_loaded[] = $file_path; unset($config); $loaded = TRUE; log_message('debug', 'Config file loaded: '.$file_path); break; } if ($loaded === FALSE) { if ($fail_gracefully === TRUE) { return FALSE; } show_error('The configuration file '.$file.'.php does not exist.'); } return TRUE; }
php
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { $file = ($file == '') ? 'config' : str_replace('.php', '', $file); $found = FALSE; $loaded = FALSE; $check_locations = defined('ENVIRONMENT') ? array(ENVIRONMENT.'/'.$file, $file) : array($file); foreach ($this->_config_paths as $path) { foreach ($check_locations as $location) { $file_path = $path.'config/'.$location.'.php'; if (in_array($file_path, $this->is_loaded, TRUE)) { $loaded = TRUE; continue 2; } if (file_exists($file_path)) { $found = TRUE; break; } } if ($found === FALSE) { continue; } include($file_path); if ( ! isset($config) OR ! is_array($config)) { if ($fail_gracefully === TRUE) { return FALSE; } show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.'); } if ($use_sections === TRUE) { if (isset($this->config[$file])) { $this->config[$file] = array_merge($this->config[$file], $config); } else { $this->config[$file] = $config; } } else { $this->config = array_merge($this->config, $config); } $this->is_loaded[] = $file_path; unset($config); $loaded = TRUE; log_message('debug', 'Config file loaded: '.$file_path); break; } if ($loaded === FALSE) { if ($fail_gracefully === TRUE) { return FALSE; } show_error('The configuration file '.$file.'.php does not exist.'); } return TRUE; }
[ "function", "load", "(", "$", "file", "=", "''", ",", "$", "use_sections", "=", "FALSE", ",", "$", "fail_gracefully", "=", "FALSE", ")", "{", "$", "file", "=", "(", "$", "file", "==", "''", ")", "?", "'config'", ":", "str_replace", "(", "'.php'", "...
Load Config File @access public @param string the config file name @param boolean if configuration values should be loaded into their own section @param boolean true if errors should just return false, false if an error message should be displayed @return boolean if the file was loaded correctly
[ "Load", "Config", "File" ]
d55775a4656a7e99017d2ef3f8160599d600d2a7
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Config.php#L96-L175
train
despark/ignicms
public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Config.php
CI_Config.item
function item($item, $index = '') { if ($index == '') { if ( ! isset($this->config[$item])) { return FALSE; } $pref = $this->config[$item]; } else { if ( ! isset($this->config[$index])) { return FALSE; } if ( ! isset($this->config[$index][$item])) { return FALSE; } $pref = $this->config[$index][$item]; } return $pref; }
php
function item($item, $index = '') { if ($index == '') { if ( ! isset($this->config[$item])) { return FALSE; } $pref = $this->config[$item]; } else { if ( ! isset($this->config[$index])) { return FALSE; } if ( ! isset($this->config[$index][$item])) { return FALSE; } $pref = $this->config[$index][$item]; } return $pref; }
[ "function", "item", "(", "$", "item", ",", "$", "index", "=", "''", ")", "{", "if", "(", "$", "index", "==", "''", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "$", "item", "]", ")", ")", "{", "return", "FALSE", ...
Fetch a config file item @access public @param string the config item name @param string the index name @param bool @return string
[ "Fetch", "a", "config", "file", "item" ]
d55775a4656a7e99017d2ef3f8160599d600d2a7
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Config.php#L189-L216
train
loyals-online/silverstripe-tinymce4
code/forms/CustomHtmlEditorConfig.php
CustomHtmlEditorConfig.get
public static function get($identifier = 'default') { if (!array_key_exists($identifier, self::$configs)) self::$configs[$identifier] = new CustomHtmlEditorConfig(); return self::$configs[$identifier]; }
php
public static function get($identifier = 'default') { if (!array_key_exists($identifier, self::$configs)) self::$configs[$identifier] = new CustomHtmlEditorConfig(); return self::$configs[$identifier]; }
[ "public", "static", "function", "get", "(", "$", "identifier", "=", "'default'", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "identifier", ",", "self", "::", "$", "configs", ")", ")", "self", "::", "$", "configs", "[", "$", "identifier", "]...
Get the HtmlEditorConfig object for the given identifier. This is a correct way to get an HtmlEditorConfig instance - do not call 'new' @param $identifier string - the identifier for the config set @return HtmlEditorConfig - the configuration object. This will be created if it does not yet exist for that identifier
[ "Get", "the", "HtmlEditorConfig", "object", "for", "the", "given", "identifier", ".", "This", "is", "a", "correct", "way", "to", "get", "an", "HtmlEditorConfig", "instance", "-", "do", "not", "call", "new" ]
c0603d074ebbb6b8a429f2d2856778e3643bba34
https://github.com/loyals-online/silverstripe-tinymce4/blob/c0603d074ebbb6b8a429f2d2856778e3643bba34/code/forms/CustomHtmlEditorConfig.php#L28-L31
train
artkonekt/gears
src/Backend/BackendFactory.php
BackendFactory.create
public static function create(string $driver) : Backend { if (strpos($driver, '\\') === false) { $class = __NAMESPACE__ . '\\Drivers\\' . studly_case($driver); } else { $class = $driver; } if (!class_exists($class)) { throw new \InvalidArgumentException( sprintf( 'Class `%s` does not exist, so it\'s far from being a good settings backend candidate', $class ) ); } return app()->make($class); }
php
public static function create(string $driver) : Backend { if (strpos($driver, '\\') === false) { $class = __NAMESPACE__ . '\\Drivers\\' . studly_case($driver); } else { $class = $driver; } if (!class_exists($class)) { throw new \InvalidArgumentException( sprintf( 'Class `%s` does not exist, so it\'s far from being a good settings backend candidate', $class ) ); } return app()->make($class); }
[ "public", "static", "function", "create", "(", "string", "$", "driver", ")", ":", "Backend", "{", "if", "(", "strpos", "(", "$", "driver", ",", "'\\\\'", ")", "===", "false", ")", "{", "$", "class", "=", "__NAMESPACE__", ".", "'\\\\Drivers\\\\'", ".", ...
Creates a new backend instance based on the passed driver @param string $driver Can be a short name for built in drivers eg. 'database' or a FQCN @return Backend
[ "Creates", "a", "new", "backend", "instance", "based", "on", "the", "passed", "driver" ]
6c006a3e8e334d8100aab768a2a5e807bcac5695
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/BackendFactory.php#L25-L43
train
makinacorpus/drupal-ucms
ucms_site/src/NodeManager.php
NodeManager.createReference
public function createReference(Site $site, NodeInterface $node) { $nodeId = $node->id(); $siteId = $site->getId(); $this ->db ->merge('ucms_site_node') ->key(['nid' => $nodeId, 'site_id' => $siteId]) ->execute() ; if (!in_array($siteId, $node->ucms_sites)) { $node->ucms_sites[] = $siteId; } $this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', [$nodeId])); $this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteId, $nodeId)); }
php
public function createReference(Site $site, NodeInterface $node) { $nodeId = $node->id(); $siteId = $site->getId(); $this ->db ->merge('ucms_site_node') ->key(['nid' => $nodeId, 'site_id' => $siteId]) ->execute() ; if (!in_array($siteId, $node->ucms_sites)) { $node->ucms_sites[] = $siteId; } $this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', [$nodeId])); $this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteId, $nodeId)); }
[ "public", "function", "createReference", "(", "Site", "$", "site", ",", "NodeInterface", "$", "node", ")", "{", "$", "nodeId", "=", "$", "node", "->", "id", "(", ")", ";", "$", "siteId", "=", "$", "site", "->", "getId", "(", ")", ";", "$", "this", ...
Reference node into a site @param Site $site @param NodeInterface $node
[ "Reference", "node", "into", "a", "site" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L91-L109
train
makinacorpus/drupal-ucms
ucms_site/src/NodeManager.php
NodeManager.createReferenceBulkForNode
public function createReferenceBulkForNode($nodeId, $siteIdList) { // @todo Optimize me foreach ($siteIdList as $siteId) { $this ->db ->merge('ucms_site_node') ->key(['nid' => $nodeId, 'site_id' => $siteId]) ->execute() ; } $this ->entityManager ->getStorage('node') ->resetCache([$nodeId]) ; $this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', [$nodeId])); $this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteIdList, $nodeId)); }
php
public function createReferenceBulkForNode($nodeId, $siteIdList) { // @todo Optimize me foreach ($siteIdList as $siteId) { $this ->db ->merge('ucms_site_node') ->key(['nid' => $nodeId, 'site_id' => $siteId]) ->execute() ; } $this ->entityManager ->getStorage('node') ->resetCache([$nodeId]) ; $this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', [$nodeId])); $this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteIdList, $nodeId)); }
[ "public", "function", "createReferenceBulkForNode", "(", "$", "nodeId", ",", "$", "siteIdList", ")", "{", "// @todo Optimize me", "foreach", "(", "$", "siteIdList", "as", "$", "siteId", ")", "{", "$", "this", "->", "db", "->", "merge", "(", "'ucms_site_node'",...
Reference a single within multiple sites @param int $nodeId @param int[] $siteIdList
[ "Reference", "a", "single", "within", "multiple", "sites" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L117-L137
train
makinacorpus/drupal-ucms
ucms_site/src/NodeManager.php
NodeManager.createReferenceBulkInSite
public function createReferenceBulkInSite($siteId, $nodeIdList) { // @todo Optimize me foreach ($nodeIdList as $nodeId) { $this ->db ->merge('ucms_site_node') ->key(['nid' => $nodeId, 'site_id' => $siteId]) ->execute() ; } $this ->entityManager ->getStorage('node') ->resetCache($nodeIdList) ; $this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', $nodeIdList)); $this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteId, $nodeIdList)); }
php
public function createReferenceBulkInSite($siteId, $nodeIdList) { // @todo Optimize me foreach ($nodeIdList as $nodeId) { $this ->db ->merge('ucms_site_node') ->key(['nid' => $nodeId, 'site_id' => $siteId]) ->execute() ; } $this ->entityManager ->getStorage('node') ->resetCache($nodeIdList) ; $this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', $nodeIdList)); $this->eventDispatcher->dispatch(SiteEvents::EVENT_ATTACH, new SiteAttachEvent($siteId, $nodeIdList)); }
[ "public", "function", "createReferenceBulkInSite", "(", "$", "siteId", ",", "$", "nodeIdList", ")", "{", "// @todo Optimize me", "foreach", "(", "$", "nodeIdList", "as", "$", "nodeId", ")", "{", "$", "this", "->", "db", "->", "merge", "(", "'ucms_site_node'", ...
Reference multiple nodes within a single site @param int $siteId @param int[] $nodeIdList
[ "Reference", "multiple", "nodes", "within", "a", "single", "site" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L145-L165
train
makinacorpus/drupal-ucms
ucms_site/src/NodeManager.php
NodeManager.createUnsavedClone
public function createUnsavedClone(NodeInterface $original, array $updates = []) { // This method, instead of the clone operator, will actually drop all // existing references and pointers and give you raw values. // All credits to https://stackoverflow.com/a/10831885/5826569 $node = unserialize(serialize($original)); $node->nid = null; $node->vid = null; $node->tnid = null; $node->log = null; $node->created = null; $node->changed = null; $node->path = null; $node->files = []; // Fills in the some default values. $node->status = 0; $node->promote = 0; $node->sticky = 0; $node->revision = 1; // Resets sites information. $node->site_id = null; $node->ucms_sites = []; // Sets the origin_id and parent_id. $node->parent_nid = $original->id(); $node->origin_nid = empty($original->origin_nid) ? $original->id() : $original->origin_nid; // Forces node indexing. $node->ucms_index_now = 1; // @todo find a better way // Sets the node's owner. if (isset($updates['uid'])) { $account = $this->entityManager->getStorage('user')->load($updates['uid']); $node->uid = $account->id(); $node->name = $account->getAccountName(); $node->revision_uid = $account->id(); unset($updates['uid']); } foreach ($updates as $key => $value) { $node->{$key} = $value; } return $node; }
php
public function createUnsavedClone(NodeInterface $original, array $updates = []) { // This method, instead of the clone operator, will actually drop all // existing references and pointers and give you raw values. // All credits to https://stackoverflow.com/a/10831885/5826569 $node = unserialize(serialize($original)); $node->nid = null; $node->vid = null; $node->tnid = null; $node->log = null; $node->created = null; $node->changed = null; $node->path = null; $node->files = []; // Fills in the some default values. $node->status = 0; $node->promote = 0; $node->sticky = 0; $node->revision = 1; // Resets sites information. $node->site_id = null; $node->ucms_sites = []; // Sets the origin_id and parent_id. $node->parent_nid = $original->id(); $node->origin_nid = empty($original->origin_nid) ? $original->id() : $original->origin_nid; // Forces node indexing. $node->ucms_index_now = 1; // @todo find a better way // Sets the node's owner. if (isset($updates['uid'])) { $account = $this->entityManager->getStorage('user')->load($updates['uid']); $node->uid = $account->id(); $node->name = $account->getAccountName(); $node->revision_uid = $account->id(); unset($updates['uid']); } foreach ($updates as $key => $value) { $node->{$key} = $value; } return $node; }
[ "public", "function", "createUnsavedClone", "(", "NodeInterface", "$", "original", ",", "array", "$", "updates", "=", "[", "]", ")", "{", "// This method, instead of the clone operator, will actually drop all", "// existing references and pointers and give you raw values.", "// A...
Create unsaved node clone @param NodeInterface $original Original node to clone @param array $updates Any fields that will replace properties on the new node object, set the 'uid' property as user identifier @return NodeInterface Unsaved clone
[ "Create", "unsaved", "node", "clone" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L179-L222
train
makinacorpus/drupal-ucms
ucms_site/src/NodeManager.php
NodeManager.createAndSaveClone
public function createAndSaveClone(NodeInterface $original, array $updates = []) { $clone = $this->createUnsavedClone($original, $updates); $this->entityManager->getStorage('node')->save($clone); return $clone; }
php
public function createAndSaveClone(NodeInterface $original, array $updates = []) { $clone = $this->createUnsavedClone($original, $updates); $this->entityManager->getStorage('node')->save($clone); return $clone; }
[ "public", "function", "createAndSaveClone", "(", "NodeInterface", "$", "original", ",", "array", "$", "updates", "=", "[", "]", ")", "{", "$", "clone", "=", "$", "this", "->", "createUnsavedClone", "(", "$", "original", ",", "$", "updates", ")", ";", "$"...
Clone the given node @param NodeInterface $original Original node to clone @param array $updates Any fields that will replace properties on the new node object, set the 'uid' property as user identifier @return NodeInterface New duplicated node, it has already been saved, to update values use the $updates parameter
[ "Clone", "the", "given", "node" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L237-L243
train
makinacorpus/drupal-ucms
ucms_site/src/NodeManager.php
NodeManager.deleteReferenceBulkFromSite
public function deleteReferenceBulkFromSite($siteId, $nodeIdList) { if (!$nodeIdList) { return; } $this ->db ->delete('ucms_site_node') ->condition('nid', $nodeIdList) ->condition('site_id', $siteId) ->execute() ; $this ->entityManager ->getStorage('node') ->resetCache($nodeIdList) ; $this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', $nodeIdList)); $this->eventDispatcher->dispatch(SiteEvents::EVENT_DETACH, new SiteAttachEvent($siteId, $nodeIdList)); }
php
public function deleteReferenceBulkFromSite($siteId, $nodeIdList) { if (!$nodeIdList) { return; } $this ->db ->delete('ucms_site_node') ->condition('nid', $nodeIdList) ->condition('site_id', $siteId) ->execute() ; $this ->entityManager ->getStorage('node') ->resetCache($nodeIdList) ; $this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', $nodeIdList)); $this->eventDispatcher->dispatch(SiteEvents::EVENT_DETACH, new SiteAttachEvent($siteId, $nodeIdList)); }
[ "public", "function", "deleteReferenceBulkFromSite", "(", "$", "siteId", ",", "$", "nodeIdList", ")", "{", "if", "(", "!", "$", "nodeIdList", ")", "{", "return", ";", "}", "$", "this", "->", "db", "->", "delete", "(", "'ucms_site_node'", ")", "->", "cond...
Unreference node for a site @param int $siteId @param int[] $nodeIdList
[ "Unreference", "node", "for", "a", "site" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L251-L273
train
makinacorpus/drupal-ucms
ucms_site/src/NodeManager.php
NodeManager.findSiteCandidatesForReference
public function findSiteCandidatesForReference(NodeInterface $node, $userId) { $ne = $this ->db ->select('ucms_site_node', 'sn') ->where("sn.site_id = sa.site_id") ->condition('sn.nid', $node->id()) ; $ne->addExpression('1'); $idList = $this ->db ->select('ucms_site_access', 'sa') ->fields('sa', ['site_id']) ->condition('sa.uid', $userId) ->notExists($ne) ->groupBy('sa.site_id') ->execute() ->fetchCol() ; return $this->manager->getStorage()->loadAll($idList); }
php
public function findSiteCandidatesForReference(NodeInterface $node, $userId) { $ne = $this ->db ->select('ucms_site_node', 'sn') ->where("sn.site_id = sa.site_id") ->condition('sn.nid', $node->id()) ; $ne->addExpression('1'); $idList = $this ->db ->select('ucms_site_access', 'sa') ->fields('sa', ['site_id']) ->condition('sa.uid', $userId) ->notExists($ne) ->groupBy('sa.site_id') ->execute() ->fetchCol() ; return $this->manager->getStorage()->loadAll($idList); }
[ "public", "function", "findSiteCandidatesForReference", "(", "NodeInterface", "$", "node", ",", "$", "userId", ")", "{", "$", "ne", "=", "$", "this", "->", "db", "->", "select", "(", "'ucms_site_node'", ",", "'sn'", ")", "->", "where", "(", "\"sn.site_id = s...
Find candidate sites for referencing this node @param NodeInterface $node @param int $userId @return Site[]
[ "Find", "candidate", "sites", "for", "referencing", "this", "node" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L283-L305
train
makinacorpus/drupal-ucms
ucms_site/src/NodeManager.php
NodeManager.findSiteCandidatesForCloning
public function findSiteCandidatesForCloning(NodeInterface $node, $userId) { /* * The right and only working query for this. * SELECT DISTINCT(sa.site_id) FROM ucms_site_access sa JOIN ucms_site_node sn ON sn.site_id = sa.site_id WHERE sa.uid = 13 -- current user AND sn. AND sa.role = 1 -- webmaster AND sa.site_id <> 2 -- node current site AND NOT EXISTS ( SELECT 1 FROM node en WHERE en.site_id = sa.site_id AND ( en.parent_nid = 6 -- node we are looking for OR nid = 6 ) ) ; */ $sq = $this ->db ->select('node', 'en') ->where('en.site_id = sa.site_id') ->where('en.parent_nid = :nid1 OR nid = :nid2', [':nid1' => $node->id(), ':nid2' => $node->id()]) ; $sq->addExpression('1'); $q = $this ->db ->select('ucms_site_access', 'sa') ->fields('sa', ['site_id']) ->condition('sa.uid', $userId) ->condition('sa.role', Access::ROLE_WEBMASTER) ; $q->join('ucms_site_node', 'sn', 'sn.site_id = sa.site_id'); $q->condition('sn.nid', $node->id()); // The node might not be attached to any site if it is a global content if ($node->site_id) { $q->condition('sa.site_id', $node->site_id, '<>'); } $idList = $q ->notExists($sq) ->addTag('ucms_site_access') ->execute() ->fetchCol() ; return $this->manager->getStorage()->loadAll($idList); }
php
public function findSiteCandidatesForCloning(NodeInterface $node, $userId) { /* * The right and only working query for this. * SELECT DISTINCT(sa.site_id) FROM ucms_site_access sa JOIN ucms_site_node sn ON sn.site_id = sa.site_id WHERE sa.uid = 13 -- current user AND sn. AND sa.role = 1 -- webmaster AND sa.site_id <> 2 -- node current site AND NOT EXISTS ( SELECT 1 FROM node en WHERE en.site_id = sa.site_id AND ( en.parent_nid = 6 -- node we are looking for OR nid = 6 ) ) ; */ $sq = $this ->db ->select('node', 'en') ->where('en.site_id = sa.site_id') ->where('en.parent_nid = :nid1 OR nid = :nid2', [':nid1' => $node->id(), ':nid2' => $node->id()]) ; $sq->addExpression('1'); $q = $this ->db ->select('ucms_site_access', 'sa') ->fields('sa', ['site_id']) ->condition('sa.uid', $userId) ->condition('sa.role', Access::ROLE_WEBMASTER) ; $q->join('ucms_site_node', 'sn', 'sn.site_id = sa.site_id'); $q->condition('sn.nid', $node->id()); // The node might not be attached to any site if it is a global content if ($node->site_id) { $q->condition('sa.site_id', $node->site_id, '<>'); } $idList = $q ->notExists($sq) ->addTag('ucms_site_access') ->execute() ->fetchCol() ; return $this->manager->getStorage()->loadAll($idList); }
[ "public", "function", "findSiteCandidatesForCloning", "(", "NodeInterface", "$", "node", ",", "$", "userId", ")", "{", "/*\n * The right and only working query for this.\n *\n SELECT DISTINCT(sa.site_id)\n FROM ucms_site_access sa\n JOIN ucms_...
Find candidate sites for cloning this node @param NodeInterface $node @param int $userId @return Site[]
[ "Find", "candidate", "sites", "for", "cloning", "this", "node" ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L315-L374
train
makinacorpus/drupal-ucms
ucms_site/src/NodeManager.php
NodeManager.getCloningMapping
public function getCloningMapping(Site $site) { if (isset($this->cloningMapping[$site->getId()])) { return $this->cloningMapping[$site->getId()]; } $q = $this->db ->select('node', 'n') ->fields('n', ['parent_nid', 'nid']) ->isNotNull('parent_nid') ->condition('site_id', $site->id) ->condition('status', NODE_PUBLISHED) ->orderBy('created', 'ASC') ; $mapping = []; foreach ($q->execute()->fetchAll() as $row) { if (isset($mapping[(int) $row->parent_nid])) { continue; } $mapping[(int) $row->parent_nid] = (int) $row->nid; } $this->cloningMapping[$site->getId()] = $mapping; return $mapping; }
php
public function getCloningMapping(Site $site) { if (isset($this->cloningMapping[$site->getId()])) { return $this->cloningMapping[$site->getId()]; } $q = $this->db ->select('node', 'n') ->fields('n', ['parent_nid', 'nid']) ->isNotNull('parent_nid') ->condition('site_id', $site->id) ->condition('status', NODE_PUBLISHED) ->orderBy('created', 'ASC') ; $mapping = []; foreach ($q->execute()->fetchAll() as $row) { if (isset($mapping[(int) $row->parent_nid])) { continue; } $mapping[(int) $row->parent_nid] = (int) $row->nid; } $this->cloningMapping[$site->getId()] = $mapping; return $mapping; }
[ "public", "function", "getCloningMapping", "(", "Site", "$", "site", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cloningMapping", "[", "$", "site", "->", "getId", "(", ")", "]", ")", ")", "{", "return", "$", "this", "->", "cloningMapping", ...
Provides a mapping array of parent identifiers to clone identifiers. If there is several clones for a same parent, the first created will be passed. @param Site $site @return integer[]
[ "Provides", "a", "mapping", "array", "of", "parent", "identifiers", "to", "clone", "identifiers", "." ]
6b8a84305472d2cad816102672f10274b3bbb535
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeManager.php#L386-L413
train
tck/zf-imageresizer
src/TckImageResizer/Service/ImageProcessing.php
ImageProcessing.process
public function process($source, $target, $commands) { $targetFolder = pathinfo($target, PATHINFO_DIRNAME); if (!file_exists($targetFolder)) { mkdir($targetFolder, 0777, true); } $this->image = $this->getImagineService()->open($source); foreach ($this->analyseCommands($commands) as $command) { if ($this->runCommand($command)) { continue; } $this->runCustomCommand($command); } $this->image->save($target); }
php
public function process($source, $target, $commands) { $targetFolder = pathinfo($target, PATHINFO_DIRNAME); if (!file_exists($targetFolder)) { mkdir($targetFolder, 0777, true); } $this->image = $this->getImagineService()->open($source); foreach ($this->analyseCommands($commands) as $command) { if ($this->runCommand($command)) { continue; } $this->runCustomCommand($command); } $this->image->save($target); }
[ "public", "function", "process", "(", "$", "source", ",", "$", "target", ",", "$", "commands", ")", "{", "$", "targetFolder", "=", "pathinfo", "(", "$", "target", ",", "PATHINFO_DIRNAME", ")", ";", "if", "(", "!", "file_exists", "(", "$", "targetFolder",...
Process command to image source and save to target @param string $source @param string $target @param string $commands @return void
[ "Process", "command", "to", "image", "source", "and", "save", "to", "target" ]
7461f588bbf12cbf9544a68778541d052b68fd07
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L82-L97
train
tck/zf-imageresizer
src/TckImageResizer/Service/ImageProcessing.php
ImageProcessing.process404
public function process404($target, $commands) { if (file_exists($target)) { return; } $targetFolder = pathinfo($target, PATHINFO_DIRNAME); if (!file_exists($targetFolder)) { mkdir($targetFolder, 0777, true); } $text = 'Not found'; $backgroundColor = null; $color = null; $width = null; $height = null; foreach ($this->analyseCommands($commands) as $command) { if ('thumb' === $command['command'] || 'resize' === $command['command']) { $width = $command['params'][0]; $height = $command['params'][1]; } elseif ('404' === $command['command']) { if (isset($command['params'][0]) && UrlSafeBase64::valid($command['params'][0])) { $text = UrlSafeBase64::decode($command['params'][0]); } if (isset($command['params'][1])) { $backgroundColor = $command['params'][1]; } if (isset($command['params'][2])) { $color = $command['params'][2]; } if (isset($command['params'][3])) { $width = $command['params'][3]; } if (isset($command['params'][4])) { $height = $command['params'][4]; } } } $this->image404($text, $backgroundColor, $color, $width, $height); $this->image->save($target); }
php
public function process404($target, $commands) { if (file_exists($target)) { return; } $targetFolder = pathinfo($target, PATHINFO_DIRNAME); if (!file_exists($targetFolder)) { mkdir($targetFolder, 0777, true); } $text = 'Not found'; $backgroundColor = null; $color = null; $width = null; $height = null; foreach ($this->analyseCommands($commands) as $command) { if ('thumb' === $command['command'] || 'resize' === $command['command']) { $width = $command['params'][0]; $height = $command['params'][1]; } elseif ('404' === $command['command']) { if (isset($command['params'][0]) && UrlSafeBase64::valid($command['params'][0])) { $text = UrlSafeBase64::decode($command['params'][0]); } if (isset($command['params'][1])) { $backgroundColor = $command['params'][1]; } if (isset($command['params'][2])) { $color = $command['params'][2]; } if (isset($command['params'][3])) { $width = $command['params'][3]; } if (isset($command['params'][4])) { $height = $command['params'][4]; } } } $this->image404($text, $backgroundColor, $color, $width, $height); $this->image->save($target); }
[ "public", "function", "process404", "(", "$", "target", ",", "$", "commands", ")", "{", "if", "(", "file_exists", "(", "$", "target", ")", ")", "{", "return", ";", "}", "$", "targetFolder", "=", "pathinfo", "(", "$", "target", ",", "PATHINFO_DIRNAME", ...
Process command to create 404 image and save to target @param string $target @param string $commands @return void
[ "Process", "command", "to", "create", "404", "image", "and", "save", "to", "target" ]
7461f588bbf12cbf9544a68778541d052b68fd07
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L107-L149
train
tck/zf-imageresizer
src/TckImageResizer/Service/ImageProcessing.php
ImageProcessing.runCommand
protected function runCommand($command) { $method = 'image' . ucfirst(strtolower($command['command'])); if (!method_exists($this, $method)) { return false; } call_user_func_array([$this, $method], $command['params']); return true; }
php
protected function runCommand($command) { $method = 'image' . ucfirst(strtolower($command['command'])); if (!method_exists($this, $method)) { return false; } call_user_func_array([$this, $method], $command['params']); return true; }
[ "protected", "function", "runCommand", "(", "$", "command", ")", "{", "$", "method", "=", "'image'", ".", "ucfirst", "(", "strtolower", "(", "$", "command", "[", "'command'", "]", ")", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", ...
Run command if exists @param array $command @return boolean
[ "Run", "command", "if", "exists" ]
7461f588bbf12cbf9544a68778541d052b68fd07
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L179-L188
train
tck/zf-imageresizer
src/TckImageResizer/Service/ImageProcessing.php
ImageProcessing.runCustomCommand
protected function runCustomCommand($command) { if (!CommandRegistry::hasCommand($command['command'])) { throw new BadMethodCallException('Command "' . $command['command'] . '" not found'); } $customCommand = CommandRegistry::getCommand($command['command']); array_unshift($command['params'], $this->image); call_user_func_array($customCommand, $command['params']); return true; }
php
protected function runCustomCommand($command) { if (!CommandRegistry::hasCommand($command['command'])) { throw new BadMethodCallException('Command "' . $command['command'] . '" not found'); } $customCommand = CommandRegistry::getCommand($command['command']); array_unshift($command['params'], $this->image); call_user_func_array($customCommand, $command['params']); return true; }
[ "protected", "function", "runCustomCommand", "(", "$", "command", ")", "{", "if", "(", "!", "CommandRegistry", "::", "hasCommand", "(", "$", "command", "[", "'command'", "]", ")", ")", "{", "throw", "new", "BadMethodCallException", "(", "'Command \"'", ".", ...
Run custom command if exists @param array $command @return boolean
[ "Run", "custom", "command", "if", "exists" ]
7461f588bbf12cbf9544a68778541d052b68fd07
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L197-L208
train
tck/zf-imageresizer
src/TckImageResizer/Service/ImageProcessing.php
ImageProcessing.imageThumb
protected function imageThumb($width, $height) { $width = (int) $width; $height = (int) $height; if ($width <= 0) { throw new BadMethodCallException('Invalid parameter width for command "thumb"'); } if ($height <= 0) { throw new BadMethodCallException('Invalid parameter height for command "thumb"'); } $this->image = $this->image->thumbnail(new Box($width, $height)); }
php
protected function imageThumb($width, $height) { $width = (int) $width; $height = (int) $height; if ($width <= 0) { throw new BadMethodCallException('Invalid parameter width for command "thumb"'); } if ($height <= 0) { throw new BadMethodCallException('Invalid parameter height for command "thumb"'); } $this->image = $this->image->thumbnail(new Box($width, $height)); }
[ "protected", "function", "imageThumb", "(", "$", "width", ",", "$", "height", ")", "{", "$", "width", "=", "(", "int", ")", "$", "width", ";", "$", "height", "=", "(", "int", ")", "$", "height", ";", "if", "(", "$", "width", "<=", "0", ")", "{"...
Command image thumb @param int $width @param int $height @return void
[ "Command", "image", "thumb" ]
7461f588bbf12cbf9544a68778541d052b68fd07
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L218-L229
train
tck/zf-imageresizer
src/TckImageResizer/Service/ImageProcessing.php
ImageProcessing.imageGamma
protected function imageGamma($correction) { $correction = (float) $correction; $this->image->effects()->gamma($correction); }
php
protected function imageGamma($correction) { $correction = (float) $correction; $this->image->effects()->gamma($correction); }
[ "protected", "function", "imageGamma", "(", "$", "correction", ")", "{", "$", "correction", "=", "(", "float", ")", "$", "correction", ";", "$", "this", "->", "image", "->", "effects", "(", ")", "->", "gamma", "(", "$", "correction", ")", ";", "}" ]
Command image gamma @param float $correction @return void
[ "Command", "image", "gamma" ]
7461f588bbf12cbf9544a68778541d052b68fd07
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L279-L284
train
tck/zf-imageresizer
src/TckImageResizer/Service/ImageProcessing.php
ImageProcessing.imageColorize
protected function imageColorize($hexColor) { if (strlen($hexColor) != 6 || !preg_match('![0-9abcdef]!i', $hexColor)) { throw new BadMethodCallException('Invalid parameter color for command "colorize"'); } $color = $this->image->palette()->color('#' . $hexColor); $this->image->effects()->colorize($color); }
php
protected function imageColorize($hexColor) { if (strlen($hexColor) != 6 || !preg_match('![0-9abcdef]!i', $hexColor)) { throw new BadMethodCallException('Invalid parameter color for command "colorize"'); } $color = $this->image->palette()->color('#' . $hexColor); $this->image->effects()->colorize($color); }
[ "protected", "function", "imageColorize", "(", "$", "hexColor", ")", "{", "if", "(", "strlen", "(", "$", "hexColor", ")", "!=", "6", "||", "!", "preg_match", "(", "'![0-9abcdef]!i'", ",", "$", "hexColor", ")", ")", "{", "throw", "new", "BadMethodCallExcept...
Command image colorize @param string $hexColor @return void
[ "Command", "image", "colorize" ]
7461f588bbf12cbf9544a68778541d052b68fd07
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L293-L301
train
tck/zf-imageresizer
src/TckImageResizer/Service/ImageProcessing.php
ImageProcessing.imageBlur
protected function imageBlur($sigma = 1) { $sigma = (float) $sigma; $this->image->effects()->blur($sigma); }
php
protected function imageBlur($sigma = 1) { $sigma = (float) $sigma; $this->image->effects()->blur($sigma); }
[ "protected", "function", "imageBlur", "(", "$", "sigma", "=", "1", ")", "{", "$", "sigma", "=", "(", "float", ")", "$", "sigma", ";", "$", "this", "->", "image", "->", "effects", "(", ")", "->", "blur", "(", "$", "sigma", ")", ";", "}" ]
Command image blur @param float $sigma @return void
[ "Command", "image", "blur" ]
7461f588bbf12cbf9544a68778541d052b68fd07
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L320-L325
train
tck/zf-imageresizer
src/TckImageResizer/Service/ImageProcessing.php
ImageProcessing.drawCenteredText
protected function drawCenteredText($text, $color) { $width = $this->image->getSize()->getWidth(); $height = $this->image->getSize()->getHeight(); $fontColor = $this->image->palette()->color('#' . $color); $fontSize = 48; $widthFactor = $width > 160 ? 0.8 : 0.9; $heightFactor = $height > 160 ? 0.8 : 0.9; do { $font = $this->getImagineService() ->font(__DIR__ . '/../../../data/font/Roboto-Regular.ttf', $fontSize, $fontColor); $fontBox = $font->box($text); $fontSize = round($fontSize * 0.8); } while ($fontSize > 5 && ($width * $widthFactor < $fontBox->getWidth() || $height * $heightFactor < $fontBox->getHeight())); $pointX = max(0, floor(($width - $fontBox->getWidth()) / 2)); $pointY = max(0, floor(($height - $fontBox->getHeight()) / 2)); $this->image->draw()->text($text, $font, new Point($pointX, $pointY)); }
php
protected function drawCenteredText($text, $color) { $width = $this->image->getSize()->getWidth(); $height = $this->image->getSize()->getHeight(); $fontColor = $this->image->palette()->color('#' . $color); $fontSize = 48; $widthFactor = $width > 160 ? 0.8 : 0.9; $heightFactor = $height > 160 ? 0.8 : 0.9; do { $font = $this->getImagineService() ->font(__DIR__ . '/../../../data/font/Roboto-Regular.ttf', $fontSize, $fontColor); $fontBox = $font->box($text); $fontSize = round($fontSize * 0.8); } while ($fontSize > 5 && ($width * $widthFactor < $fontBox->getWidth() || $height * $heightFactor < $fontBox->getHeight())); $pointX = max(0, floor(($width - $fontBox->getWidth()) / 2)); $pointY = max(0, floor(($height - $fontBox->getHeight()) / 2)); $this->image->draw()->text($text, $font, new Point($pointX, $pointY)); }
[ "protected", "function", "drawCenteredText", "(", "$", "text", ",", "$", "color", ")", "{", "$", "width", "=", "$", "this", "->", "image", "->", "getSize", "(", ")", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "this", "->", "image", "...
Draw centered text in current image @param string $text @param string $color @return void
[ "Draw", "centered", "text", "in", "current", "image" ]
7461f588bbf12cbf9544a68778541d052b68fd07
https://github.com/tck/zf-imageresizer/blob/7461f588bbf12cbf9544a68778541d052b68fd07/src/TckImageResizer/Service/ImageProcessing.php#L385-L406
train
runcmf/runbb
src/RunBB/Model/Admin/Plugins.php
Plugins.deactivate
public function deactivate($name) { $name = Container::get('hooks')->fire('model.plugin.deactivate.name', $name); $activePlugins = $this->manager->getActivePlugins(); // Check if plugin is actually activated if (($k = array_search($name, $activePlugins)) !== false) { $plugin = DB::forTable('plugins')->where('name', $name)->find_one(); if (!$plugin) { $plugin = DB::forTable('plugins')->create()->set('name', $name); } $plugin->set('active', 0); // Allow additionnal deactivate functions $this->manager->deactivate($name); $plugin = Container::get('hooks')->fireDB('model.plugin.deactivate', $plugin); $plugin->save(); $this->manager->setActivePlugins(); return $plugin; } return true; }
php
public function deactivate($name) { $name = Container::get('hooks')->fire('model.plugin.deactivate.name', $name); $activePlugins = $this->manager->getActivePlugins(); // Check if plugin is actually activated if (($k = array_search($name, $activePlugins)) !== false) { $plugin = DB::forTable('plugins')->where('name', $name)->find_one(); if (!$plugin) { $plugin = DB::forTable('plugins')->create()->set('name', $name); } $plugin->set('active', 0); // Allow additionnal deactivate functions $this->manager->deactivate($name); $plugin = Container::get('hooks')->fireDB('model.plugin.deactivate', $plugin); $plugin->save(); $this->manager->setActivePlugins(); return $plugin; } return true; }
[ "public", "function", "deactivate", "(", "$", "name", ")", "{", "$", "name", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fire", "(", "'model.plugin.deactivate.name'", ",", "$", "name", ")", ";", "$", "activePlugins", "=", "$", "this", "->"...
Deactivate a plugin
[ "Deactivate", "a", "plugin" ]
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Admin/Plugins.php#L99-L123
train
runcmf/runbb
src/RunBB/Model/Admin/Plugins.php
Plugins.uninstall
public function uninstall($name) { $name = Container::get('hooks')->fire('model.plugin.uninstall.name', $name); $activePlugins = $this->manager->getActivePlugins(); // Check if plugin is disabled, for security if (!in_array($name, $activePlugins)) { $plugin = DB::forTable('plugins')->where('name', $name)->find_one(); if ($plugin) { $plugin->delete(); } // Allow additional uninstalling functions $this->manager->uninstall($name); if (file_exists(ForumEnv::get('FORUM_ROOT').'plugins'.DIRECTORY_SEPARATOR.$name)) { AdminUtils::deleteFolder(ForumEnv::get('FORUM_ROOT').'plugins'.DIRECTORY_SEPARATOR.$name); } $this->manager->setActivePlugins(); } return true; }
php
public function uninstall($name) { $name = Container::get('hooks')->fire('model.plugin.uninstall.name', $name); $activePlugins = $this->manager->getActivePlugins(); // Check if plugin is disabled, for security if (!in_array($name, $activePlugins)) { $plugin = DB::forTable('plugins')->where('name', $name)->find_one(); if ($plugin) { $plugin->delete(); } // Allow additional uninstalling functions $this->manager->uninstall($name); if (file_exists(ForumEnv::get('FORUM_ROOT').'plugins'.DIRECTORY_SEPARATOR.$name)) { AdminUtils::deleteFolder(ForumEnv::get('FORUM_ROOT').'plugins'.DIRECTORY_SEPARATOR.$name); } $this->manager->setActivePlugins(); } return true; }
[ "public", "function", "uninstall", "(", "$", "name", ")", "{", "$", "name", "=", "Container", "::", "get", "(", "'hooks'", ")", "->", "fire", "(", "'model.plugin.uninstall.name'", ",", "$", "name", ")", ";", "$", "activePlugins", "=", "$", "this", "->", ...
Uninstall a plugin after deactivated
[ "Uninstall", "a", "plugin", "after", "deactivated" ]
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Model/Admin/Plugins.php#L128-L151
train
bitExpert/adroit
src/bitExpert/Adroit/Resolver/AbstractResolverMiddleware.php
AbstractResolverMiddleware.validateResolvers
private function validateResolvers(array $resolvers) { foreach ($resolvers as $index => $resolver) { if (!$this->isValidResolver($resolver)) { throw new \InvalidArgumentException(sprintf( 'Resolver at index %s of type "%s" is not valid resolver type', $index, get_class($resolver) )); } } }
php
private function validateResolvers(array $resolvers) { foreach ($resolvers as $index => $resolver) { if (!$this->isValidResolver($resolver)) { throw new \InvalidArgumentException(sprintf( 'Resolver at index %s of type "%s" is not valid resolver type', $index, get_class($resolver) )); } } }
[ "private", "function", "validateResolvers", "(", "array", "$", "resolvers", ")", "{", "foreach", "(", "$", "resolvers", "as", "$", "index", "=>", "$", "resolver", ")", "{", "if", "(", "!", "$", "this", "->", "isValidResolver", "(", "$", "resolver", ")", ...
Internal resolver setter which validates the resolvers @param \bitExpert\Adroit\Resolver\Resolver[] $resolvers @throws \InvalidArgumentException
[ "Internal", "resolver", "setter", "which", "validates", "the", "resolvers" ]
ecba7e59b864c88bd4639c87194ad842320e5f76
https://github.com/bitExpert/adroit/blob/ecba7e59b864c88bd4639c87194ad842320e5f76/src/bitExpert/Adroit/Resolver/AbstractResolverMiddleware.php#L47-L58
train
despark/ignicms
src/Models/Image.php
Image.__isset
public function __isset($key) { $result = parent::__isset($key); if ($result) { return $result; } // if (! $result && $key == 'identifier') { // $resourceModel = $this->getResourceModel(); // if ($resourceModel && $resourceModel instanceof AdminModel) { // return ! is_null($resourceModel->getIdentifier()); // } // } // If we don't have a value try to find it in metadata if (! $result && $key != 'meta') { return isset($this->meta[$key]); } }
php
public function __isset($key) { $result = parent::__isset($key); if ($result) { return $result; } // if (! $result && $key == 'identifier') { // $resourceModel = $this->getResourceModel(); // if ($resourceModel && $resourceModel instanceof AdminModel) { // return ! is_null($resourceModel->getIdentifier()); // } // } // If we don't have a value try to find it in metadata if (! $result && $key != 'meta') { return isset($this->meta[$key]); } }
[ "public", "function", "__isset", "(", "$", "key", ")", "{", "$", "result", "=", "parent", "::", "__isset", "(", "$", "key", ")", ";", "if", "(", "$", "result", ")", "{", "return", "$", "result", ";", "}", "// if (! $result && $key == 'identifier') {...
Override magic isset so we can check for identifier metadata and properties. @param string $key @return bool
[ "Override", "magic", "isset", "so", "we", "can", "check", "for", "identifier", "metadata", "and", "properties", "." ]
d55775a4656a7e99017d2ef3f8160599d600d2a7
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Models/Image.php#L423-L440
train
accompli/accompli
src/Configuration/Configuration.php
Configuration.load
public function load($configurationFile = null) { $this->hosts = array(); $this->configuration = array(); if (isset($configurationFile)) { $this->configurationFile = $configurationFile; } if (file_exists($this->configurationFile) === false) { throw new InvalidArgumentException(sprintf('The configuration file "%s" is not valid.', $this->configurationFile)); } $json = file_get_contents($this->configurationFile); $this->validateSyntax($json); $json = $this->importExtendedConfiguration($json); if ($this->validateSchema($json)) { $this->configuration = json_decode($json, true); } $this->processEventSubscribers(); }
php
public function load($configurationFile = null) { $this->hosts = array(); $this->configuration = array(); if (isset($configurationFile)) { $this->configurationFile = $configurationFile; } if (file_exists($this->configurationFile) === false) { throw new InvalidArgumentException(sprintf('The configuration file "%s" is not valid.', $this->configurationFile)); } $json = file_get_contents($this->configurationFile); $this->validateSyntax($json); $json = $this->importExtendedConfiguration($json); if ($this->validateSchema($json)) { $this->configuration = json_decode($json, true); } $this->processEventSubscribers(); }
[ "public", "function", "load", "(", "$", "configurationFile", "=", "null", ")", "{", "$", "this", "->", "hosts", "=", "array", "(", ")", ";", "$", "this", "->", "configuration", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "configuration...
Loads and validates the JSON configuration. @param string|null $configurationFile @throws InvalidArgumentException
[ "Loads", "and", "validates", "the", "JSON", "configuration", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Configuration/Configuration.php#L73-L96
train
accompli/accompli
src/Configuration/Configuration.php
Configuration.processEventSubscribers
private function processEventSubscribers() { if (isset($this->configuration['events']['subscribers'])) { foreach ($this->configuration['events']['subscribers'] as $i => $subscriber) { if (is_string($subscriber)) { $this->configuration['events']['subscribers'][$i] = array('class' => $subscriber); } } } }
php
private function processEventSubscribers() { if (isset($this->configuration['events']['subscribers'])) { foreach ($this->configuration['events']['subscribers'] as $i => $subscriber) { if (is_string($subscriber)) { $this->configuration['events']['subscribers'][$i] = array('class' => $subscriber); } } } }
[ "private", "function", "processEventSubscribers", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "configuration", "[", "'events'", "]", "[", "'subscribers'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "configuration", "[", "'events'...
Processes event subscriber configurations to match the same format.
[ "Processes", "event", "subscriber", "configurations", "to", "match", "the", "same", "format", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Configuration/Configuration.php#L180-L189
train
accompli/accompli
src/Configuration/Configuration.php
Configuration.getHosts
public function getHosts() { if (empty($this->hosts) && isset($this->configuration['hosts'])) { foreach ($this->configuration['hosts'] as $host) { $this->hosts[] = ObjectFactory::getInstance()->newInstance(Host::class, $host); } } return $this->hosts; }
php
public function getHosts() { if (empty($this->hosts) && isset($this->configuration['hosts'])) { foreach ($this->configuration['hosts'] as $host) { $this->hosts[] = ObjectFactory::getInstance()->newInstance(Host::class, $host); } } return $this->hosts; }
[ "public", "function", "getHosts", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "hosts", ")", "&&", "isset", "(", "$", "this", "->", "configuration", "[", "'hosts'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "configuration",...
Returns the configured hosts. @return Host[]
[ "Returns", "the", "configured", "hosts", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Configuration/Configuration.php#L196-L205
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.loadArray
public function loadArray(array $data = array()) { // if no $data was passed try loading the default configuration file if (empty($data)) { $this->loadFile(); return; } // if data was passed, map via setters $unmappedData = parent::loadArray($data); // put the rest into $this->additionalSettings $this->mapAdditionalSettings($unmappedData); }
php
public function loadArray(array $data = array()) { // if no $data was passed try loading the default configuration file if (empty($data)) { $this->loadFile(); return; } // if data was passed, map via setters $unmappedData = parent::loadArray($data); // put the rest into $this->additionalSettings $this->mapAdditionalSettings($unmappedData); }
[ "public", "function", "loadArray", "(", "array", "$", "data", "=", "array", "(", ")", ")", "{", "// if no $data was passed try loading the default configuration file", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "$", "this", "->", "loadFile", "(", ")"...
Tries to assign the values of an array to the configuration fields or load it from a file. This overrides ShopgateContainer::loadArray() which is called on object instantiation. It tries to assign the values of $data to the class attributes by $data's keys. If a key is not the name of a class attribute it's appended to $this->additionalSettings.<br /> <br /> If $data is empty or not an array, the method calls $this->loadFile(). @param $data array<string, mixed> The data to be assigned to the configuration. @return void
[ "Tries", "to", "assign", "the", "values", "of", "an", "array", "to", "the", "configuration", "fields", "or", "load", "it", "from", "a", "file", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L705-L719
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.loadFile
public function loadFile($path = null) { $config = null; // try loading files if (!empty($path) && file_exists($path)) { // try $path $config = $this->includeFile($path); if (!$config) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'The passed configuration file "' . $path . '" does not exist or does not define the $shopgate_config variable.' ); } } else { // try myconfig.php $config = $this->includeFile($this->buildConfigFilePath()); // if unsuccessful, use default configuration values if (!$config) { return; } } // if we got here, we have a $shopgate_config to load $unmappedData = parent::loadArray($config); $this->mapAdditionalSettings($unmappedData); }
php
public function loadFile($path = null) { $config = null; // try loading files if (!empty($path) && file_exists($path)) { // try $path $config = $this->includeFile($path); if (!$config) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'The passed configuration file "' . $path . '" does not exist or does not define the $shopgate_config variable.' ); } } else { // try myconfig.php $config = $this->includeFile($this->buildConfigFilePath()); // if unsuccessful, use default configuration values if (!$config) { return; } } // if we got here, we have a $shopgate_config to load $unmappedData = parent::loadArray($config); $this->mapAdditionalSettings($unmappedData); }
[ "public", "function", "loadFile", "(", "$", "path", "=", "null", ")", "{", "$", "config", "=", "null", ";", "// try loading files", "if", "(", "!", "empty", "(", "$", "path", ")", "&&", "file_exists", "(", "$", "path", ")", ")", "{", "// try $path", ...
Tries to load the configuration from a file. If a $path is passed, this method tries to include the file. If that fails an exception is thrown.<br /> <br /> If $path is empty it tries to load .../shopgate_library/config/myconfig.php or if that fails, .../shopgate_library/config/config.php is tried to be loaded. If that fails too, an exception is thrown.<br /> <br /> The configuration file must be a PHP script defining an indexed array called $shopgate_config containing the desired configuration values to set. If that is not the case, an exception is thrown @param string $path The path to the configuration file or nothing to load the default Shopgate Cart Integration SDK configuration files. @throws ShopgateLibraryException in case a configuration file could not be loaded or the $shopgate_config is not set.
[ "Tries", "to", "load", "the", "configuration", "from", "a", "file", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L739-L767
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.loadByShopNumber
public function loadByShopNumber($shopNumber) { if (empty($shopNumber) || !preg_match($this->coreValidations['shop_number'], $shopNumber)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'configuration file cannot be found without shop number' ); } // find all config files $configFile = null; $files = scandir(dirname($this->buildConfigFilePath())); ob_start(); foreach ($files as $file) { if (!is_file($this->buildConfigFilePath($file))) { continue; } $shopgate_config = null; /** @noinspection PhpIncludeInspection */ include($this->buildConfigFilePath($file)); if (isset($shopgate_config) && isset($shopgate_config['shop_number']) && ($shopgate_config['shop_number'] == $shopNumber)) { $configFile = $this->buildConfigFilePath($file); break; } } ob_end_clean(); if (empty($configFile)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'no configuration file found for shop number "' . $shopNumber . '"', true, false ); } $this->loadFile($configFile); $this->initFileNames(); }
php
public function loadByShopNumber($shopNumber) { if (empty($shopNumber) || !preg_match($this->coreValidations['shop_number'], $shopNumber)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'configuration file cannot be found without shop number' ); } // find all config files $configFile = null; $files = scandir(dirname($this->buildConfigFilePath())); ob_start(); foreach ($files as $file) { if (!is_file($this->buildConfigFilePath($file))) { continue; } $shopgate_config = null; /** @noinspection PhpIncludeInspection */ include($this->buildConfigFilePath($file)); if (isset($shopgate_config) && isset($shopgate_config['shop_number']) && ($shopgate_config['shop_number'] == $shopNumber)) { $configFile = $this->buildConfigFilePath($file); break; } } ob_end_clean(); if (empty($configFile)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'no configuration file found for shop number "' . $shopNumber . '"', true, false ); } $this->loadFile($configFile); $this->initFileNames(); }
[ "public", "function", "loadByShopNumber", "(", "$", "shopNumber", ")", "{", "if", "(", "empty", "(", "$", "shopNumber", ")", "||", "!", "preg_match", "(", "$", "this", "->", "coreValidations", "[", "'shop_number'", "]", ",", "$", "shopNumber", ")", ")", ...
Loads the configuration file for a given Shopgate shop number. @param string $shopNumber The shop number. @throws ShopgateLibraryException in case the $shopNumber is empty or no configuration file can be found.
[ "Loads", "the", "configuration", "file", "for", "a", "given", "Shopgate", "shop", "number", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L776-L815
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.loadByLanguage
public function loadByLanguage($language) { if (!is_null($language) && !preg_match('/[a-z]{2}/', $language)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'invalid language code "' . $language . '"', true, false ); } $this->loadFile($this->buildConfigFilePath('myconfig-' . $language . '.php')); $this->initFileNames(); }
php
public function loadByLanguage($language) { if (!is_null($language) && !preg_match('/[a-z]{2}/', $language)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'invalid language code "' . $language . '"', true, false ); } $this->loadFile($this->buildConfigFilePath('myconfig-' . $language . '.php')); $this->initFileNames(); }
[ "public", "function", "loadByLanguage", "(", "$", "language", ")", "{", "if", "(", "!", "is_null", "(", "$", "language", ")", "&&", "!", "preg_match", "(", "'/[a-z]{2}/'", ",", "$", "language", ")", ")", "{", "throw", "new", "ShopgateLibraryException", "("...
Loads the configuration file by a given language or the global configuration file. @param string|null $language the ISO-639 code of the language or null to load global configuration @throws ShopgateLibraryException
[ "Loads", "the", "configuration", "file", "by", "a", "given", "language", "or", "the", "global", "configuration", "file", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L824-L837
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.initFileNames
protected function initFileNames() { $this->items_csv_filename = 'items-' . $this->language . '.csv'; $this->items_xml_filename = 'items-' . $this->language . '.xml'; $this->items_json_filename = 'items-' . $this->language . '.json'; $this->media_csv_filename = 'media-' . $this->language . '.csv'; $this->categories_csv_filename = 'categories-' . $this->language . '.csv'; $this->categories_xml_filename = 'categories-' . $this->language . '.xml'; $this->categories_json_filename = 'categories-' . $this->language . '.json'; $this->reviews_csv_filename = 'reviews-' . $this->language . '.csv'; $this->access_log_filename = 'access-' . $this->language . '.log'; $this->request_log_filename = 'request-' . $this->language . '.log'; $this->error_log_filename = 'error-' . $this->language . '.log'; $this->debug_log_filename = 'debug-' . $this->language . '.log'; $this->redirect_keyword_cache_filename = 'redirect_keywords-' . $this->language . '.txt'; $this->redirect_skip_keyword_cache_filename = 'skip_redirect_keywords-' . $this->language . '.txt'; }
php
protected function initFileNames() { $this->items_csv_filename = 'items-' . $this->language . '.csv'; $this->items_xml_filename = 'items-' . $this->language . '.xml'; $this->items_json_filename = 'items-' . $this->language . '.json'; $this->media_csv_filename = 'media-' . $this->language . '.csv'; $this->categories_csv_filename = 'categories-' . $this->language . '.csv'; $this->categories_xml_filename = 'categories-' . $this->language . '.xml'; $this->categories_json_filename = 'categories-' . $this->language . '.json'; $this->reviews_csv_filename = 'reviews-' . $this->language . '.csv'; $this->access_log_filename = 'access-' . $this->language . '.log'; $this->request_log_filename = 'request-' . $this->language . '.log'; $this->error_log_filename = 'error-' . $this->language . '.log'; $this->debug_log_filename = 'debug-' . $this->language . '.log'; $this->redirect_keyword_cache_filename = 'redirect_keywords-' . $this->language . '.txt'; $this->redirect_skip_keyword_cache_filename = 'skip_redirect_keywords-' . $this->language . '.txt'; }
[ "protected", "function", "initFileNames", "(", ")", "{", "$", "this", "->", "items_csv_filename", "=", "'items-'", ".", "$", "this", "->", "language", ".", "'.csv'", ";", "$", "this", "->", "items_xml_filename", "=", "'items-'", ".", "$", "this", "->", "la...
Sets the file names according to the language of the configuration.
[ "Sets", "the", "file", "names", "according", "to", "the", "language", "of", "the", "configuration", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L842-L863
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.saveFile
public function saveFile(array $fieldList, $path = null, $validate = true) { // if desired, validate before doing anything else if ($validate) { $this->validate($fieldList); } // preserve values of the fields to save $saveFields = array(); $currentConfig = $this->toArray(); foreach ($fieldList as $field) { $saveFields[$field] = (isset($currentConfig[$field])) ? $currentConfig[$field] : null; } // load the current configuration file try { $this->loadFile($path); } catch (ShopgateLibraryException $e) { ShopgateLogger::getInstance()->log( '-- Don\'t worry about the "error reading or writing configuration", that was just a routine check during saving.' ); } // merge old config with new values $newConfig = array_merge($this->toArray(), $saveFields); // default if no path to the configuration file is set if (empty($path)) { $path = $this->buildConfigFilePath(); } // create the array definition string and save it to the file $shopgateConfigFile = "<?php\n\$shopgate_config = " . var_export($newConfig, true) . ';'; if (!@file_put_contents($path, $shopgateConfigFile)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'The configuration file "' . $path . '" could not be saved.' ); } }
php
public function saveFile(array $fieldList, $path = null, $validate = true) { // if desired, validate before doing anything else if ($validate) { $this->validate($fieldList); } // preserve values of the fields to save $saveFields = array(); $currentConfig = $this->toArray(); foreach ($fieldList as $field) { $saveFields[$field] = (isset($currentConfig[$field])) ? $currentConfig[$field] : null; } // load the current configuration file try { $this->loadFile($path); } catch (ShopgateLibraryException $e) { ShopgateLogger::getInstance()->log( '-- Don\'t worry about the "error reading or writing configuration", that was just a routine check during saving.' ); } // merge old config with new values $newConfig = array_merge($this->toArray(), $saveFields); // default if no path to the configuration file is set if (empty($path)) { $path = $this->buildConfigFilePath(); } // create the array definition string and save it to the file $shopgateConfigFile = "<?php\n\$shopgate_config = " . var_export($newConfig, true) . ';'; if (!@file_put_contents($path, $shopgateConfigFile)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'The configuration file "' . $path . '" could not be saved.' ); } }
[ "public", "function", "saveFile", "(", "array", "$", "fieldList", ",", "$", "path", "=", "null", ",", "$", "validate", "=", "true", ")", "{", "// if desired, validate before doing anything else", "if", "(", "$", "validate", ")", "{", "$", "this", "->", "vali...
Saves the desired configuration fields to the specified file or myconfig.php. This calls $this->loadFile() with the given $path to load the current configuration. In case that fails, the $shopgate_config array is initialized empty. The values defined in $fieldList are then validated (if desired), assigned to $shopgate_config and saved to the specified file or myconfig.php. In case the file cannot be (over)written or created, an exception with code ShopgateLibrary::CONFIG_READ_WRITE_ERROR is thrown. In case the validation fails for one or more fields, an exception with code ShopgateLibrary::CONFIG_INVALID_VALUE is thrown. The failed fields are appended as additional information in form of a comma-separated list. @param string[] $fieldList The list of fieldnames that should be saved to the configuration file. @param string $path The path to the configuration file or empty to use .../shopgate_library/config/myconfig.php. @param bool $validate True to validate the fields that should be set. @throws ShopgateLibraryException in case the configuration can't be loaded or saved.
[ "Saves", "the", "desired", "configuration", "fields", "to", "the", "specified", "file", "or", "myconfig", ".", "php", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L895-L936
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.saveFileForLanguage
public function saveFileForLanguage(array $fieldList, $language = null, $validate = true) { $fileName = null; if (!is_null($language)) { $this->setLanguage($language); $fieldList[] = 'language'; $fileName = $this->buildConfigFilePath('myconfig-' . $language . '.php'); } $this->saveFile($fieldList, $fileName, $validate); }
php
public function saveFileForLanguage(array $fieldList, $language = null, $validate = true) { $fileName = null; if (!is_null($language)) { $this->setLanguage($language); $fieldList[] = 'language'; $fileName = $this->buildConfigFilePath('myconfig-' . $language . '.php'); } $this->saveFile($fieldList, $fileName, $validate); }
[ "public", "function", "saveFileForLanguage", "(", "array", "$", "fieldList", ",", "$", "language", "=", "null", ",", "$", "validate", "=", "true", ")", "{", "$", "fileName", "=", "null", ";", "if", "(", "!", "is_null", "(", "$", "language", ")", ")", ...
Saves the desired fields to the configuration file for a given language or global configuration @param string[] $fieldList the list of fieldnames that should be saved to the configuration file. @param string $language the ISO-639 code of the language or null to save to global configuration @param bool $validate true to validate the fields that should be set. @throws ShopgateLibraryException in case the configuration can't be loaded or saved.
[ "Saves", "the", "desired", "fields", "to", "the", "configuration", "file", "for", "a", "given", "language", "or", "global", "configuration" ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L947-L957
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.checkDuplicates
public function checkDuplicates() { $shopNumbers = array(); $files = scandir(dirname($this->buildConfigFilePath())); foreach ($files as $file) { if (!is_file($this->buildConfigFilePath($file))) { continue; } $shopgate_config = null; /** @noinspection PhpIncludeInspection */ include($this->buildConfigFilePath($file)); if (isset($shopgate_config) && isset($shopgate_config['shop_number'])) { if (in_array($shopgate_config['shop_number'], $shopNumbers)) { return true; } else { $shopNumbers[] = $shopgate_config['shop_number']; } } } return false; }
php
public function checkDuplicates() { $shopNumbers = array(); $files = scandir(dirname($this->buildConfigFilePath())); foreach ($files as $file) { if (!is_file($this->buildConfigFilePath($file))) { continue; } $shopgate_config = null; /** @noinspection PhpIncludeInspection */ include($this->buildConfigFilePath($file)); if (isset($shopgate_config) && isset($shopgate_config['shop_number'])) { if (in_array($shopgate_config['shop_number'], $shopNumbers)) { return true; } else { $shopNumbers[] = $shopgate_config['shop_number']; } } } return false; }
[ "public", "function", "checkDuplicates", "(", ")", "{", "$", "shopNumbers", "=", "array", "(", ")", ";", "$", "files", "=", "scandir", "(", "dirname", "(", "$", "this", "->", "buildConfigFilePath", "(", ")", ")", ")", ";", "foreach", "(", "$", "files",...
Checks for duplicate shop numbers in multiple configurations. This checks all files in the configuration folder and shop numbers in all configuration files. @return bool true if there are duplicates, false otherwise.
[ "Checks", "for", "duplicate", "shop", "numbers", "in", "multiple", "configurations", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L967-L990
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.checkMultipleConfigs
public function checkMultipleConfigs() { $files = scandir(dirname($this->buildConfigFilePath())); $counter = 0; foreach ($files as $file) { if (!is_file($this->buildConfigFilePath($file))) { continue; } if (substr($file, -4) !== '.php') { continue; } ob_start(); /** @noinspection PhpIncludeInspection */ include($this->buildConfigFilePath($file)); ob_end_clean(); if (!isset($shopgate_config)) { continue; } $counter++; unset($shopgate_config); } return ($counter > 1); }
php
public function checkMultipleConfigs() { $files = scandir(dirname($this->buildConfigFilePath())); $counter = 0; foreach ($files as $file) { if (!is_file($this->buildConfigFilePath($file))) { continue; } if (substr($file, -4) !== '.php') { continue; } ob_start(); /** @noinspection PhpIncludeInspection */ include($this->buildConfigFilePath($file)); ob_end_clean(); if (!isset($shopgate_config)) { continue; } $counter++; unset($shopgate_config); } return ($counter > 1); }
[ "public", "function", "checkMultipleConfigs", "(", ")", "{", "$", "files", "=", "scandir", "(", "dirname", "(", "$", "this", "->", "buildConfigFilePath", "(", ")", ")", ")", ";", "$", "counter", "=", "0", ";", "foreach", "(", "$", "files", "as", "$", ...
Checks if there is more than one configuration file available. @return bool true if multiple configuration files are available, false otherwise.
[ "Checks", "if", "there", "is", "more", "than", "one", "configuration", "file", "available", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L997-L1024
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.useGlobalFor
public function useGlobalFor($language) { $fileName = $this->buildConfigFilePath('myconfig-' . $language . '.php'); if (file_exists($fileName)) { if (!@unlink($fileName)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'Error deleting configuration file "' . $fileName . "'." ); } } }
php
public function useGlobalFor($language) { $fileName = $this->buildConfigFilePath('myconfig-' . $language . '.php'); if (file_exists($fileName)) { if (!@unlink($fileName)) { throw new ShopgateLibraryException( ShopgateLibraryException::CONFIG_READ_WRITE_ERROR, 'Error deleting configuration file "' . $fileName . "'." ); } } }
[ "public", "function", "useGlobalFor", "(", "$", "language", ")", "{", "$", "fileName", "=", "$", "this", "->", "buildConfigFilePath", "(", "'myconfig-'", ".", "$", "language", ".", "'.php'", ")", ";", "if", "(", "file_exists", "(", "$", "fileName", ")", ...
Removes the configuration file for the language requested. @param string $language the ISO-639 code of the language or null to load global configuration @throws ShopgateLibraryException in case the file exists but cannot be deleted.
[ "Removes", "the", "configuration", "file", "for", "the", "language", "requested", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L1045-L1056
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfig.mapAdditionalSettings
private function mapAdditionalSettings($data = array()) { foreach ($data as $key => $value) { $this->additionalSettings[$key] = $value; } }
php
private function mapAdditionalSettings($data = array()) { foreach ($data as $key => $value) { $this->additionalSettings[$key] = $value; } }
[ "private", "function", "mapAdditionalSettings", "(", "$", "data", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "additionalSettings", "[", "$", "key", "]", "=", "$", ...
Maps the passed data to the additional settings array. @param array <string, mixed> $data The data to map.
[ "Maps", "the", "passed", "data", "to", "the", "additional", "settings", "array", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2305-L2310
train
shopgate/cart-integration-sdk
src/configuration.php
ShopgateConfigOld.deprecated
private static function deprecated($methodName) { $message = 'Use of ' . $methodName . ' and the whole ShopgateConfigOld class is deprecated.'; trigger_error($message, E_USER_DEPRECATED); ShopgateLogger::getInstance()->log($message); }
php
private static function deprecated($methodName) { $message = 'Use of ' . $methodName . ' and the whole ShopgateConfigOld class is deprecated.'; trigger_error($message, E_USER_DEPRECATED); ShopgateLogger::getInstance()->log($message); }
[ "private", "static", "function", "deprecated", "(", "$", "methodName", ")", "{", "$", "message", "=", "'Use of '", ".", "$", "methodName", ".", "' and the whole ShopgateConfigOld class is deprecated.'", ";", "trigger_error", "(", "$", "message", ",", "E_USER_DEPRECATE...
Issues a PHP deprecated warning and log entry for calls to deprecated ShopgateConfigOld methods. @param string $methodName The name of the called method.
[ "Issues", "a", "PHP", "deprecated", "warning", "and", "log", "entry", "for", "calls", "to", "deprecated", "ShopgateConfigOld", "methods", "." ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/configuration.php#L2838-L2843
train
mosbth/Anax-MVC
src/View/CViewContainerBasic.php
CViewContainerBasic.addString
public function addString($content, $region = 'main', $sort = 0) { $view = $this->di->get('view'); $view->set($content, [], $sort, 'string'); $view->setDI($this->di); $this->views[$region][] = $view; return $this; }
php
public function addString($content, $region = 'main', $sort = 0) { $view = $this->di->get('view'); $view->set($content, [], $sort, 'string'); $view->setDI($this->di); $this->views[$region][] = $view; return $this; }
[ "public", "function", "addString", "(", "$", "content", ",", "$", "region", "=", "'main'", ",", "$", "sort", "=", "0", ")", "{", "$", "view", "=", "$", "this", "->", "di", "->", "get", "(", "'view'", ")", ";", "$", "view", "->", "set", "(", "$"...
Add a string as a view. @param string $content the content @param string $region which region to attach the view @param int $sort which order to display the views @return $this
[ "Add", "a", "string", "as", "a", "view", "." ]
5574d105bcec9df8e57532a321585f6521b4581c
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L88-L96
train
mosbth/Anax-MVC
src/View/CViewContainerBasic.php
CViewContainerBasic.setBasePath
public function setBasePath($path) { if (!is_dir($path)) { throw new \Exception("Base path for views is not a directory: " . $path); } $this->path = rtrim($path, '/') . '/'; }
php
public function setBasePath($path) { if (!is_dir($path)) { throw new \Exception("Base path for views is not a directory: " . $path); } $this->path = rtrim($path, '/') . '/'; }
[ "public", "function", "setBasePath", "(", "$", "path", ")", "{", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Base path for views is not a directory: \"", ".", "$", "path", ")", ";", "}", "$", "thi...
Set base path where to find views. @param string $path where all views reside @return $this @throws \Exception
[ "Set", "base", "path", "where", "to", "find", "views", "." ]
5574d105bcec9df8e57532a321585f6521b4581c
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L121-L127
train
mosbth/Anax-MVC
src/View/CViewContainerBasic.php
CViewContainerBasic.render
public function render($region = 'main') { if (!isset($this->views[$region])) { return $this; } mergesort($this->views[$region], function ($a, $b) { $sa = $a->sortOrder(); $sb = $b->sortOrder(); if ($sa == $sb) { return 0; } return $sa < $sb ? -1 : 1; }); foreach ($this->views[$region] as $view) { $view->render(); } return $this; }
php
public function render($region = 'main') { if (!isset($this->views[$region])) { return $this; } mergesort($this->views[$region], function ($a, $b) { $sa = $a->sortOrder(); $sb = $b->sortOrder(); if ($sa == $sb) { return 0; } return $sa < $sb ? -1 : 1; }); foreach ($this->views[$region] as $view) { $view->render(); } return $this; }
[ "public", "function", "render", "(", "$", "region", "=", "'main'", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "views", "[", "$", "region", "]", ")", ")", "{", "return", "$", "this", ";", "}", "mergesort", "(", "$", "this", "->", ...
Render all views for a specific region. @param string $region which region to use @return $this
[ "Render", "all", "views", "for", "a", "specific", "region", "." ]
5574d105bcec9df8e57532a321585f6521b4581c
https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/View/CViewContainerBasic.php#L152-L174
train
shopgate/cart-integration-sdk
src/models/Abstract.php
Shopgate_Model_Abstract.getData
public function getData($key = '', $index = null) { if ('' === $key) { return $this->data; } $default = null; if (isset($this->data[$key])) { if (is_null($index)) { return $this->data[$key]; } $value = $this->data[$key]; if (is_array($value)) { if (isset($value[$index])) { return $value[$index]; } return null; } return $default; } return $default; }
php
public function getData($key = '', $index = null) { if ('' === $key) { return $this->data; } $default = null; if (isset($this->data[$key])) { if (is_null($index)) { return $this->data[$key]; } $value = $this->data[$key]; if (is_array($value)) { if (isset($value[$index])) { return $value[$index]; } return null; } return $default; } return $default; }
[ "public", "function", "getData", "(", "$", "key", "=", "''", ",", "$", "index", "=", "null", ")", "{", "if", "(", "''", "===", "$", "key", ")", "{", "return", "$", "this", "->", "data", ";", "}", "$", "default", "=", "null", ";", "if", "(", "...
returns data from key or all @param string $key @param null $index @return array|null
[ "returns", "data", "from", "key", "or", "all" ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/Abstract.php#L131-L156
train
BugBuster1701/contao-xing-bundle
src/Resources/contao/classes/XingImage.php
XingImage.getXingImageLink
public function getXingImageLink($xinglayout, $xing_source = 'xing_local') { $arrXingImageDefinitions= array(); $xingSrcProfile = '//www.xing.com/img/buttons/'; $xingSrcCompany = '//www.xing.com/img/xing/xe/corporate_pages/'; $xingSrcLocal = 'bundles/bugbusterxing/'; if (file_exists(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php")) { include(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php"); } if (isset($arrXingImageDefinitions[$xinglayout])) { $this->image_file = $arrXingImageDefinitions[$xinglayout]['image_file']; $this->image_size = $arrXingImageDefinitions[$xinglayout]['image_size']; $this->image_title = $arrXingImageDefinitions[$xinglayout]['image_title']; } if ('xing_local' == $xing_source || '' == $xing_source) { $xingSrcProfile = $xingSrcLocal; $xingSrcCompany = $xingSrcLocal; } if ($xinglayout < 999) { $xing_images = '<img src="'.$xingSrcProfile.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">'; } else { $xing_images = '<img src="'.$xingSrcCompany.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">'; } return $xing_images; }
php
public function getXingImageLink($xinglayout, $xing_source = 'xing_local') { $arrXingImageDefinitions= array(); $xingSrcProfile = '//www.xing.com/img/buttons/'; $xingSrcCompany = '//www.xing.com/img/xing/xe/corporate_pages/'; $xingSrcLocal = 'bundles/bugbusterxing/'; if (file_exists(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php")) { include(TL_ROOT . "/vendor/bugbuster/contao-xing-bundle/src/Resources/contao/config/xing_image_definitions.php"); } if (isset($arrXingImageDefinitions[$xinglayout])) { $this->image_file = $arrXingImageDefinitions[$xinglayout]['image_file']; $this->image_size = $arrXingImageDefinitions[$xinglayout]['image_size']; $this->image_title = $arrXingImageDefinitions[$xinglayout]['image_title']; } if ('xing_local' == $xing_source || '' == $xing_source) { $xingSrcProfile = $xingSrcLocal; $xingSrcCompany = $xingSrcLocal; } if ($xinglayout < 999) { $xing_images = '<img src="'.$xingSrcProfile.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">'; } else { $xing_images = '<img src="'.$xingSrcCompany.$this->image_file.'" '.$this->image_size.' alt="XING" title="'.$this->image_title.'">'; } return $xing_images; }
[ "public", "function", "getXingImageLink", "(", "$", "xinglayout", ",", "$", "xing_source", "=", "'xing_local'", ")", "{", "$", "arrXingImageDefinitions", "=", "array", "(", ")", ";", "$", "xingSrcProfile", "=", "'//www.xing.com/img/buttons/'", ";", "$", "xingSrcCo...
get Image Link
[ "get", "Image", "Link" ]
e2816a6e6ff439812de6599712c5b8b756e4738a
https://github.com/BugBuster1701/contao-xing-bundle/blob/e2816a6e6ff439812de6599712c5b8b756e4738a/src/Resources/contao/classes/XingImage.php#L32-L66
train
shopgate/cart-integration-sdk
src/models/AbstractExport.php
Shopgate_Model_AbstractExport.generateData
public function generateData() { foreach ($this->fireMethods as $method) { $this->log( "Calling function \"{$method}\": Actual memory usage before method: " . $this->getMemoryUsageString(), ShopgateLogger::LOGTYPE_DEBUG ); $this->{$method}(); } return $this; }
php
public function generateData() { foreach ($this->fireMethods as $method) { $this->log( "Calling function \"{$method}\": Actual memory usage before method: " . $this->getMemoryUsageString(), ShopgateLogger::LOGTYPE_DEBUG ); $this->{$method}(); } return $this; }
[ "public", "function", "generateData", "(", ")", "{", "foreach", "(", "$", "this", "->", "fireMethods", "as", "$", "method", ")", "{", "$", "this", "->", "log", "(", "\"Calling function \\\"{$method}\\\": Actual memory usage before method: \"", ".", "$", "this", "-...
generate data dom object @return $this
[ "generate", "data", "dom", "object" ]
cf12ecf8bdb8f4c407209000002fd00261e53b06
https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/AbstractExport.php#L134-L146
train
accompli/accompli
src/Console/Logger/ConsoleLogger.php
ConsoleLogger.getTaskActionStatusSectionFromContext
private function getTaskActionStatusSectionFromContext(array $context) { $actionStatusSection = ''; if ($this->output->isDecorated()) { $actionStatusSection = sprintf(self::ANSI_CURSOR_BACKWARD_FORMAT, 1); } if (isset($context['event.task.action']) && isset($this->taskActionStatusToOutputMap[$context['event.task.action']])) { $actionStatusSection = sprintf('[<event-task-action-%1$s>%2$s</event-task-action-%1$s>]', $context['event.task.action'], $this->taskActionStatusToOutputMap[$context['event.task.action']]); } return $actionStatusSection; }
php
private function getTaskActionStatusSectionFromContext(array $context) { $actionStatusSection = ''; if ($this->output->isDecorated()) { $actionStatusSection = sprintf(self::ANSI_CURSOR_BACKWARD_FORMAT, 1); } if (isset($context['event.task.action']) && isset($this->taskActionStatusToOutputMap[$context['event.task.action']])) { $actionStatusSection = sprintf('[<event-task-action-%1$s>%2$s</event-task-action-%1$s>]', $context['event.task.action'], $this->taskActionStatusToOutputMap[$context['event.task.action']]); } return $actionStatusSection; }
[ "private", "function", "getTaskActionStatusSectionFromContext", "(", "array", "$", "context", ")", "{", "$", "actionStatusSection", "=", "''", ";", "if", "(", "$", "this", "->", "output", "->", "isDecorated", "(", ")", ")", "{", "$", "actionStatusSection", "="...
Returns the task status section based on the context. @param array $context @return string
[ "Returns", "the", "task", "status", "section", "based", "on", "the", "context", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L233-L244
train
accompli/accompli
src/Console/Logger/ConsoleLogger.php
ConsoleLogger.getMessageLineCount
private function getMessageLineCount($message) { $messageLength = FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $message); return ceil($messageLength / $this->getTerminalWidth()); }
php
private function getMessageLineCount($message) { $messageLength = FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $message); return ceil($messageLength / $this->getTerminalWidth()); }
[ "private", "function", "getMessageLineCount", "(", "$", "message", ")", "{", "$", "messageLength", "=", "FormatterHelper", "::", "strlenWithoutDecoration", "(", "$", "this", "->", "output", "->", "getFormatter", "(", ")", ",", "$", "message", ")", ";", "return...
Returns the line count of the message based on the terminal width. @param string $message @return int
[ "Returns", "the", "line", "count", "of", "the", "message", "based", "on", "the", "terminal", "width", "." ]
618f28377448d8caa90d63bfa5865a3ee15e49e7
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Logger/ConsoleLogger.php#L275-L280
train
silverstripe/silverstripe-versionfeed
src/VersionFeed.php
VersionFeed.getDiff
public function getDiff() { $changes = $this->getDiffList($this->owner->Version, 1); if ($changes && $changes->Count()) { return $changes->First(); } return null; }
php
public function getDiff() { $changes = $this->getDiffList($this->owner->Version, 1); if ($changes && $changes->Count()) { return $changes->First(); } return null; }
[ "public", "function", "getDiff", "(", ")", "{", "$", "changes", "=", "$", "this", "->", "getDiffList", "(", "$", "this", "->", "owner", "->", "Version", ",", "1", ")", ";", "if", "(", "$", "changes", "&&", "$", "changes", "->", "Count", "(", ")", ...
Return a single diff representing this version. Returns the initial version if there is nothing to compare to. @return DataObject|null Object with relevant fields diffed.
[ "Return", "a", "single", "diff", "representing", "this", "version", ".", "Returns", "the", "initial", "version", "if", "there", "is", "nothing", "to", "compare", "to", "." ]
831f03a2b85602c7a7fba110e0ef51c36ad4f204
https://github.com/silverstripe/silverstripe-versionfeed/blob/831f03a2b85602c7a7fba110e0ef51c36ad4f204/src/VersionFeed.php#L161-L169
train
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php
Standard.uploadFile
public function uploadFile( \stdClass $params ) { $this->checkParams( $params, array( 'site' ) ); $this->setLocale( $params->site ); $clientFilename = ''; $context = $this->getContext(); $request = $context->getView()->request(); $dest = $this->storeFile( $request, $clientFilename ); $result = (object) array( 'site' => $params->site, 'items' => array( (object) array( 'job.label' => 'Product text import: ' . $clientFilename, 'job.method' => 'Product_Import_Text.importFile', 'job.parameter' => array( 'site' => $params->site, 'items' => $dest, ), 'job.status' => 1, ), ), ); $jobController = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'admin/job' ); $jobController->saveItems( $result ); return array( 'items' => $dest, 'success' => true, ); }
php
public function uploadFile( \stdClass $params ) { $this->checkParams( $params, array( 'site' ) ); $this->setLocale( $params->site ); $clientFilename = ''; $context = $this->getContext(); $request = $context->getView()->request(); $dest = $this->storeFile( $request, $clientFilename ); $result = (object) array( 'site' => $params->site, 'items' => array( (object) array( 'job.label' => 'Product text import: ' . $clientFilename, 'job.method' => 'Product_Import_Text.importFile', 'job.parameter' => array( 'site' => $params->site, 'items' => $dest, ), 'job.status' => 1, ), ), ); $jobController = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'admin/job' ); $jobController->saveItems( $result ); return array( 'items' => $dest, 'success' => true, ); }
[ "public", "function", "uploadFile", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'site'", ")", ")", ";", "$", "this", "->", "setLocale", "(", "$", "params", "->", "site", ")...
Uploads a CSV file with all product texts. @param \stdClass $params Object containing the properties
[ "Uploads", "a", "CSV", "file", "with", "all", "product", "texts", "." ]
594ee7cec90fd63a4773c05c93f353e66d9b3408
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php#L42-L75
train
aimeos/ai-admin-extadm
controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php
Standard.importFile
public function importFile( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'items' ) ); $this->setLocale( $params->site ); $fs = $this->getContext()->getFilesystemManager()->get( 'fs-admin' ); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $path ) { $tmpfile = $fs->readf( $path ); /** controller/extjs/product/import/text/standard/container/type * Container file type storing all language files of the texts to import * * When exporting texts, one file or content object is created per * language. All those files or content objects are put into one container * file so editors don't have to download one file for each language. * * The container file types that are supported by default are: * * Zip * * Extensions implement other container types like spread sheets, XMLs or * more advanced ways of handling the exported data. * * @param string Container file type * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/format */ /** controller/extjs/product/import/text/standard/container/format * Format of the language files for the texts to import * * The exported texts are stored in one file or content object per * language. The format of that file or content object can be configured * with this option but most formats are bound to a specific container * type. * * The formats that are supported by default are: * * CSV (requires container type "Zip") * * Extensions implement other container types like spread sheets, XMLs or * more advanced ways of handling the exported data. * * @param string Content file type * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/type * @see controller/extjs/product/import/text/standard/container/options */ /** controller/extjs/product/import/text/standard/container/options * Options changing the expected format for the texts to import * * Each content format may support some configuration options to change * the output for that content type. * * The options for the CSV content format are: * * csv-separator, default ',' * * csv-enclosure, default '"' * * csv-escape, default '"' * * csv-lineend, default '\n' * * For format options provided by other container types implemented by * extensions, please have a look into the extension documentation. * * @param array Associative list of options with the name as key and its value * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/format */ $container = $this->createContainer( $tmpfile, 'controller/extjs/product/import/text/standard/container' ); $textTypeMap = []; foreach( $this->getTextTypes( 'product' ) as $item ) { $textTypeMap[$item->getCode()] = $item->getId(); } foreach( $container as $content ) { $this->importTextsFromContent( $content, $textTypeMap, 'product' ); } unlink( $tmpfile ); $fs->rm( $path ); } return array( 'success' => true, ); }
php
public function importFile( \stdClass $params ) { $this->checkParams( $params, array( 'site', 'items' ) ); $this->setLocale( $params->site ); $fs = $this->getContext()->getFilesystemManager()->get( 'fs-admin' ); $items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items ); foreach( $items as $path ) { $tmpfile = $fs->readf( $path ); /** controller/extjs/product/import/text/standard/container/type * Container file type storing all language files of the texts to import * * When exporting texts, one file or content object is created per * language. All those files or content objects are put into one container * file so editors don't have to download one file for each language. * * The container file types that are supported by default are: * * Zip * * Extensions implement other container types like spread sheets, XMLs or * more advanced ways of handling the exported data. * * @param string Container file type * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/format */ /** controller/extjs/product/import/text/standard/container/format * Format of the language files for the texts to import * * The exported texts are stored in one file or content object per * language. The format of that file or content object can be configured * with this option but most formats are bound to a specific container * type. * * The formats that are supported by default are: * * CSV (requires container type "Zip") * * Extensions implement other container types like spread sheets, XMLs or * more advanced ways of handling the exported data. * * @param string Content file type * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/type * @see controller/extjs/product/import/text/standard/container/options */ /** controller/extjs/product/import/text/standard/container/options * Options changing the expected format for the texts to import * * Each content format may support some configuration options to change * the output for that content type. * * The options for the CSV content format are: * * csv-separator, default ',' * * csv-enclosure, default '"' * * csv-escape, default '"' * * csv-lineend, default '\n' * * For format options provided by other container types implemented by * extensions, please have a look into the extension documentation. * * @param array Associative list of options with the name as key and its value * @since 2014.03 * @category Developer * @category User * @see controller/extjs/product/import/text/standard/container/format */ $container = $this->createContainer( $tmpfile, 'controller/extjs/product/import/text/standard/container' ); $textTypeMap = []; foreach( $this->getTextTypes( 'product' ) as $item ) { $textTypeMap[$item->getCode()] = $item->getId(); } foreach( $container as $content ) { $this->importTextsFromContent( $content, $textTypeMap, 'product' ); } unlink( $tmpfile ); $fs->rm( $path ); } return array( 'success' => true, ); }
[ "public", "function", "importFile", "(", "\\", "stdClass", "$", "params", ")", "{", "$", "this", "->", "checkParams", "(", "$", "params", ",", "array", "(", "'site'", ",", "'items'", ")", ")", ";", "$", "this", "->", "setLocale", "(", "$", "params", ...
Imports a CSV file with all product texts. @param \stdClass $params Object containing the properties
[ "Imports", "a", "CSV", "file", "with", "all", "product", "texts", "." ]
594ee7cec90fd63a4773c05c93f353e66d9b3408
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Import/Text/Standard.php#L83-L176
train
artkonekt/gears
src/Backend/Drivers/CachedDatabase.php
CachedDatabase.pkey
protected function pkey(string $key, $userId): string { return sprintf('%s(%s).%s', self::PREFERENCES_KEY_PREFIX, $userId, $key); }
php
protected function pkey(string $key, $userId): string { return sprintf('%s(%s).%s', self::PREFERENCES_KEY_PREFIX, $userId, $key); }
[ "protected", "function", "pkey", "(", "string", "$", "key", ",", "$", "userId", ")", ":", "string", "{", "return", "sprintf", "(", "'%s(%s).%s'", ",", "self", "::", "PREFERENCES_KEY_PREFIX", ",", "$", "userId", ",", "$", "key", ")", ";", "}" ]
Returns the cache key for a preference for user @param string $key @param int $userId @return string
[ "Returns", "the", "cache", "key", "for", "a", "preference", "for", "user" ]
6c006a3e8e334d8100aab768a2a5e807bcac5695
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/Drivers/CachedDatabase.php#L168-L171
train
artkonekt/gears
src/Backend/Drivers/CachedDatabase.php
CachedDatabase.sforget
protected function sforget($key) { $keys = is_array($key) ? $key : [$key]; foreach ($keys as $key) { $this->cache->forget($this->skey($key)); } $this->cache->forget($this->skey('*')); }
php
protected function sforget($key) { $keys = is_array($key) ? $key : [$key]; foreach ($keys as $key) { $this->cache->forget($this->skey($key)); } $this->cache->forget($this->skey('*')); }
[ "protected", "function", "sforget", "(", "$", "key", ")", "{", "$", "keys", "=", "is_array", "(", "$", "key", ")", "?", "$", "key", ":", "[", "$", "key", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "this", "->", "c...
Removes a setting from the cache by its key @param string|array $key One or more keys
[ "Removes", "a", "setting", "from", "the", "cache", "by", "its", "key" ]
6c006a3e8e334d8100aab768a2a5e807bcac5695
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/Drivers/CachedDatabase.php#L178-L187
train
artkonekt/gears
src/Backend/Drivers/CachedDatabase.php
CachedDatabase.pforget
protected function pforget($key, $userId) { $keys = is_array($key) ? $key : [$key]; foreach ($keys as $key) { $this->cache->forget($this->pkey($key, $userId)); } $this->cache->forget($this->pkey('*', $userId)); }
php
protected function pforget($key, $userId) { $keys = is_array($key) ? $key : [$key]; foreach ($keys as $key) { $this->cache->forget($this->pkey($key, $userId)); } $this->cache->forget($this->pkey('*', $userId)); }
[ "protected", "function", "pforget", "(", "$", "key", ",", "$", "userId", ")", "{", "$", "keys", "=", "is_array", "(", "$", "key", ")", "?", "$", "key", ":", "[", "$", "key", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "...
Removes a preference from the cache by key and user @param string|array $key One or more keys @param int $userId
[ "Removes", "a", "preference", "from", "the", "cache", "by", "key", "and", "user" ]
6c006a3e8e334d8100aab768a2a5e807bcac5695
https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Backend/Drivers/CachedDatabase.php#L195-L204
train
spiral/orm
source/Spiral/ORM/Entities/Relations/HasManyRelation.php
HasManyRelation.detach
public function detach(RecordInterface $record): RecordInterface { $this->loadData(true); foreach ($this->instances as $index => $instance) { if ($this->match($instance, $record)) { //Remove from save unset($this->instances[$index]); return $instance; } } throw new RelationException("Record {$record} not found in HasMany relation"); }
php
public function detach(RecordInterface $record): RecordInterface { $this->loadData(true); foreach ($this->instances as $index => $instance) { if ($this->match($instance, $record)) { //Remove from save unset($this->instances[$index]); return $instance; } } throw new RelationException("Record {$record} not found in HasMany relation"); }
[ "public", "function", "detach", "(", "RecordInterface", "$", "record", ")", ":", "RecordInterface", "{", "$", "this", "->", "loadData", "(", "true", ")", ";", "foreach", "(", "$", "this", "->", "instances", "as", "$", "index", "=>", "$", "instance", ")",...
Detach given object from set of instances but do not delete it in database, use it to transfer object between sets. @param \Spiral\ORM\RecordInterface $record @return \Spiral\ORM\RecordInterface @throws RelationException When object not presented in a set.
[ "Detach", "given", "object", "from", "set", "of", "instances", "but", "do", "not", "delete", "it", "in", "database", "use", "it", "to", "transfer", "object", "between", "sets", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/HasManyRelation.php#L143-L156
train
spiral/orm
source/Spiral/ORM/Entities/Relations/HasManyRelation.php
HasManyRelation.loadRelated
protected function loadRelated(): array { $innerKey = $this->parent->getField($this->key(Record::INNER_KEY)); if (!empty($innerKey)) { return $this->createSelector($innerKey)->fetchData(); } return []; }
php
protected function loadRelated(): array { $innerKey = $this->parent->getField($this->key(Record::INNER_KEY)); if (!empty($innerKey)) { return $this->createSelector($innerKey)->fetchData(); } return []; }
[ "protected", "function", "loadRelated", "(", ")", ":", "array", "{", "$", "innerKey", "=", "$", "this", "->", "parent", "->", "getField", "(", "$", "this", "->", "key", "(", "Record", "::", "INNER_KEY", ")", ")", ";", "if", "(", "!", "empty", "(", ...
Fetch data from database. Lazy load. @return array
[ "Fetch", "data", "from", "database", ".", "Lazy", "load", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/HasManyRelation.php#L227-L235
train
spiral/orm
source/Spiral/ORM/Entities/Relations/HasManyRelation.php
HasManyRelation.createSelector
protected function createSelector($innerKey): RecordSelector { $selector = $this->orm->selector($this->class)->where( $this->key(Record::OUTER_KEY), $innerKey ); $decorator = new AliasDecorator($selector, 'where', $selector->getAlias()); if (!empty($this->schema[Record::WHERE])) { //Configuring where conditions with alias resolution $decorator->where($this->schema[Record::WHERE]); } if (!empty($this->key(Record::MORPH_KEY))) { //Morph key $decorator->where( '{@}.' . $this->key(Record::MORPH_KEY), $this->orm->define(get_class($this->parent), ORMInterface::R_ROLE_NAME) ); } if (!empty($this->schema[Record::ORDER_BY])) { //Sorting $decorator->orderBy((array)$this->schema[Record::ORDER_BY]); } return $selector; }
php
protected function createSelector($innerKey): RecordSelector { $selector = $this->orm->selector($this->class)->where( $this->key(Record::OUTER_KEY), $innerKey ); $decorator = new AliasDecorator($selector, 'where', $selector->getAlias()); if (!empty($this->schema[Record::WHERE])) { //Configuring where conditions with alias resolution $decorator->where($this->schema[Record::WHERE]); } if (!empty($this->key(Record::MORPH_KEY))) { //Morph key $decorator->where( '{@}.' . $this->key(Record::MORPH_KEY), $this->orm->define(get_class($this->parent), ORMInterface::R_ROLE_NAME) ); } if (!empty($this->schema[Record::ORDER_BY])) { //Sorting $decorator->orderBy((array)$this->schema[Record::ORDER_BY]); } return $selector; }
[ "protected", "function", "createSelector", "(", "$", "innerKey", ")", ":", "RecordSelector", "{", "$", "selector", "=", "$", "this", "->", "orm", "->", "selector", "(", "$", "this", "->", "class", ")", "->", "where", "(", "$", "this", "->", "key", "(",...
Create outer selector for a given inner key value. @param mixed $innerKey @return RecordSelector
[ "Create", "outer", "selector", "for", "a", "given", "inner", "key", "value", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/HasManyRelation.php#L244-L271
train
rinvex/cortex-foundation
src/Relations/BelongsToMorph.php
BelongsToMorph.build
public static function build(Model $parent, $related, $name, $type = null, $id = null, $otherKey = null, $relation = null) { // If no relation name was given, we will use this debug backtrace to extract // the calling method's name and use that as the relationship name as most // of the time this will be what we desire to use for the relationships. if (is_null($relation)) { [$current, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $relation = $caller['function']; } $morphName = array_get(array_flip(Relation::morphMap()), $related, $related); [$type, $id] = self::getMorphs(snake_case($name), $type, $id); $instance = new $related(); // Once we have the foreign key names, we'll just create a new Eloquent query // for the related models and returns the relationship instance which will // actually be responsible for retrieving and hydrating every relations. $query = $instance->newQuery(); $otherKey = $otherKey ?: $instance->getKeyName(); return new self($query, $parent, $morphName, $type, $id, $otherKey, $relation); }
php
public static function build(Model $parent, $related, $name, $type = null, $id = null, $otherKey = null, $relation = null) { // If no relation name was given, we will use this debug backtrace to extract // the calling method's name and use that as the relationship name as most // of the time this will be what we desire to use for the relationships. if (is_null($relation)) { [$current, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $relation = $caller['function']; } $morphName = array_get(array_flip(Relation::morphMap()), $related, $related); [$type, $id] = self::getMorphs(snake_case($name), $type, $id); $instance = new $related(); // Once we have the foreign key names, we'll just create a new Eloquent query // for the related models and returns the relationship instance which will // actually be responsible for retrieving and hydrating every relations. $query = $instance->newQuery(); $otherKey = $otherKey ?: $instance->getKeyName(); return new self($query, $parent, $morphName, $type, $id, $otherKey, $relation); }
[ "public", "static", "function", "build", "(", "Model", "$", "parent", ",", "$", "related", ",", "$", "name", ",", "$", "type", "=", "null", ",", "$", "id", "=", "null", ",", "$", "otherKey", "=", "null", ",", "$", "relation", "=", "null", ")", "{...
Define an inverse morph relationship. @param Model $parent @param string $related @param string $name @param string $type @param string $id @param string $otherKey @param string $relation @return \Illuminate\Database\Eloquent\Relations\BelongsTo
[ "Define", "an", "inverse", "morph", "relationship", "." ]
230c100d98131c76f777e5036b3e7cd83af49e6e
https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Relations/BelongsToMorph.php#L109-L134
train
spiral/orm
source/Spiral/ORM/Entities/Relations/Traits/SyncedTrait.php
SyncedTrait.isSynced
protected function isSynced(RecordInterface $inner, RecordInterface $outer): bool { if (empty($inner->primaryKey()) || empty($outer->primaryKey())) { //Parent not saved return false; } //Comparing FK values return $outer->getField( $this->key(Record::OUTER_KEY) ) == $inner->getField( $this->key(Record::INNER_KEY) ); }
php
protected function isSynced(RecordInterface $inner, RecordInterface $outer): bool { if (empty($inner->primaryKey()) || empty($outer->primaryKey())) { //Parent not saved return false; } //Comparing FK values return $outer->getField( $this->key(Record::OUTER_KEY) ) == $inner->getField( $this->key(Record::INNER_KEY) ); }
[ "protected", "function", "isSynced", "(", "RecordInterface", "$", "inner", ",", "RecordInterface", "$", "outer", ")", ":", "bool", "{", "if", "(", "empty", "(", "$", "inner", "->", "primaryKey", "(", ")", ")", "||", "empty", "(", "$", "outer", "->", "p...
If record not synced or can't be synced. Only work for PK based relations. @param RecordInterface $inner @param RecordInterface $outer @return bool
[ "If", "record", "not", "synced", "or", "can", "t", "be", "synced", ".", "Only", "work", "for", "PK", "based", "relations", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/Traits/SyncedTrait.php#L26-L39
train
spiral/orm
source/Spiral/ORM/Entities/Loaders/ManyToManyLoader.php
ManyToManyLoader.pivotKey
protected function pivotKey(string $key) { if (!isset($this->schema[$key])) { return null; } return $this->pivotAlias() . '.' . $this->schema[$key]; }
php
protected function pivotKey(string $key) { if (!isset($this->schema[$key])) { return null; } return $this->pivotAlias() . '.' . $this->schema[$key]; }
[ "protected", "function", "pivotKey", "(", "string", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "schema", "[", "$", "key", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "pivotAlias", "(", ...
Key related to pivot table. Must include pivot table alias. @see pivotKey() @param string $key @return null|string
[ "Key", "related", "to", "pivot", "table", ".", "Must", "include", "pivot", "table", "alias", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Loaders/ManyToManyLoader.php#L251-L258
train
spiral/orm
source/Spiral/ORM/RecordEntity.php
RecordEntity.handleInsert
private function handleInsert(InsertCommand $command) { //Mounting PK $this->setField($this->primaryColumn(), $command->getInsertID(), true, false); //Once command executed we will know some information about it's context //(for exampled added FKs), this information must already be in database (added to command), //so no need to track changes foreach ($command->getContext() as $name => $value) { $this->setField($name, $value, true, false); } $this->state = ORMInterface::STATE_LOADED; $this->dispatch('created', new RecordEvent($this, $command)); }
php
private function handleInsert(InsertCommand $command) { //Mounting PK $this->setField($this->primaryColumn(), $command->getInsertID(), true, false); //Once command executed we will know some information about it's context //(for exampled added FKs), this information must already be in database (added to command), //so no need to track changes foreach ($command->getContext() as $name => $value) { $this->setField($name, $value, true, false); } $this->state = ORMInterface::STATE_LOADED; $this->dispatch('created', new RecordEvent($this, $command)); }
[ "private", "function", "handleInsert", "(", "InsertCommand", "$", "command", ")", "{", "//Mounting PK", "$", "this", "->", "setField", "(", "$", "this", "->", "primaryColumn", "(", ")", ",", "$", "command", "->", "getInsertID", "(", ")", ",", "true", ",", ...
Handle result of insert command. @param InsertCommand $command
[ "Handle", "result", "of", "insert", "command", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/RecordEntity.php#L445-L459
train
spiral/orm
source/Spiral/ORM/RecordEntity.php
RecordEntity.handleUpdate
private function handleUpdate(UpdateCommand $command) { //Once command executed we will know some information about it's context (for exampled added FKs) foreach ($command->getContext() as $name => $value) { $this->setField($name, $value, true, false); } $this->state = ORMInterface::STATE_LOADED; $this->dispatch('updated', new RecordEvent($this, $command)); }
php
private function handleUpdate(UpdateCommand $command) { //Once command executed we will know some information about it's context (for exampled added FKs) foreach ($command->getContext() as $name => $value) { $this->setField($name, $value, true, false); } $this->state = ORMInterface::STATE_LOADED; $this->dispatch('updated', new RecordEvent($this, $command)); }
[ "private", "function", "handleUpdate", "(", "UpdateCommand", "$", "command", ")", "{", "//Once command executed we will know some information about it's context (for exampled added FKs)", "foreach", "(", "$", "command", "->", "getContext", "(", ")", "as", "$", "name", "=>",...
Handle result of update command. @param UpdateCommand $command
[ "Handle", "result", "of", "update", "command", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/RecordEntity.php#L466-L475
train
spiral/orm
source/Spiral/ORM/RecordEntity.php
RecordEntity.handleDelete
private function handleDelete(DeleteCommand $command) { $this->state = ORMInterface::STATE_DELETED; $this->dispatch('deleted', new RecordEvent($this, $command)); }
php
private function handleDelete(DeleteCommand $command) { $this->state = ORMInterface::STATE_DELETED; $this->dispatch('deleted', new RecordEvent($this, $command)); }
[ "private", "function", "handleDelete", "(", "DeleteCommand", "$", "command", ")", "{", "$", "this", "->", "state", "=", "ORMInterface", "::", "STATE_DELETED", ";", "$", "this", "->", "dispatch", "(", "'deleted'", ",", "new", "RecordEvent", "(", "$", "this", ...
Handle result of delete command. @param DeleteCommand $command
[ "Handle", "result", "of", "delete", "command", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/RecordEntity.php#L482-L486
train
spiral/orm
source/Spiral/ORM/EntityMap.php
EntityMap.remember
public function remember(RecordInterface $entity, bool $ignoreLimit = false): RecordInterface { if (!$ignoreLimit && !is_null($this->maxSize) && count($this->entities) > $this->maxSize - 1) { throw new MapException('Entity cache size exceeded'); } if (empty($entity->primaryKey())) { throw new MapException("Unable to store non identified entity " . get_class($entity)); } $cacheID = get_class($entity) . ':' . $entity->primaryKey(); return $this->entities[$cacheID] = $entity; }
php
public function remember(RecordInterface $entity, bool $ignoreLimit = false): RecordInterface { if (!$ignoreLimit && !is_null($this->maxSize) && count($this->entities) > $this->maxSize - 1) { throw new MapException('Entity cache size exceeded'); } if (empty($entity->primaryKey())) { throw new MapException("Unable to store non identified entity " . get_class($entity)); } $cacheID = get_class($entity) . ':' . $entity->primaryKey(); return $this->entities[$cacheID] = $entity; }
[ "public", "function", "remember", "(", "RecordInterface", "$", "entity", ",", "bool", "$", "ignoreLimit", "=", "false", ")", ":", "RecordInterface", "{", "if", "(", "!", "$", "ignoreLimit", "&&", "!", "is_null", "(", "$", "this", "->", "maxSize", ")", "&...
Add Record to entity cache. Primary key value will be used as identifier. Attention, existed entity will be replaced! @param RecordInterface $entity @param bool $ignoreLimit Cache overflow will be ignored. @return RecordInterface Returns given entity. @throws MapException When cache size exceeded.
[ "Add", "Record", "to", "entity", "cache", ".", "Primary", "key", "value", "will", "be", "used", "as", "identifier", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/EntityMap.php#L59-L72
train
spiral/orm
source/Spiral/ORM/EntityMap.php
EntityMap.forget
public function forget(RecordInterface $entity) { $cacheID = get_class($entity) . ':' . $entity->primaryKey(); unset($this->entities[$cacheID]); }
php
public function forget(RecordInterface $entity) { $cacheID = get_class($entity) . ':' . $entity->primaryKey(); unset($this->entities[$cacheID]); }
[ "public", "function", "forget", "(", "RecordInterface", "$", "entity", ")", "{", "$", "cacheID", "=", "get_class", "(", "$", "entity", ")", ".", "':'", ".", "$", "entity", "->", "primaryKey", "(", ")", ";", "unset", "(", "$", "this", "->", "entities", ...
Remove entity record from entity cache. Primary key value will be used as identifier. @param RecordInterface $entity
[ "Remove", "entity", "record", "from", "entity", "cache", ".", "Primary", "key", "value", "will", "be", "used", "as", "identifier", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/EntityMap.php#L79-L83
train
spiral/orm
source/Spiral/ORM/EntityMap.php
EntityMap.get
public function get(string $class, string $identity) { if (!$this->has($class, $identity)) { return null; } return $this->entities["{$class}:{$identity}"]; }
php
public function get(string $class, string $identity) { if (!$this->has($class, $identity)) { return null; } return $this->entities["{$class}:{$identity}"]; }
[ "public", "function", "get", "(", "string", "$", "class", ",", "string", "$", "identity", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "class", ",", "$", "identity", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this...
Fetch entity from cache. @param string $class @param string $identity @return null|mixed
[ "Fetch", "entity", "from", "cache", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/EntityMap.php#L106-L113
train
spiral/orm
source/Spiral/ORM/Entities/Nodes/PivotedRootNode.php
PivotedRootNode.duplicateCriteria
protected function duplicateCriteria(array &$data) { $pivotData = $data[ORMInterface::PIVOT_DATA]; //Unique row criteria return $pivotData[$this->innerPivotKey] . '.' . $pivotData[$this->outerPivotKey]; }
php
protected function duplicateCriteria(array &$data) { $pivotData = $data[ORMInterface::PIVOT_DATA]; //Unique row criteria return $pivotData[$this->innerPivotKey] . '.' . $pivotData[$this->outerPivotKey]; }
[ "protected", "function", "duplicateCriteria", "(", "array", "&", "$", "data", ")", "{", "$", "pivotData", "=", "$", "data", "[", "ORMInterface", "::", "PIVOT_DATA", "]", ";", "//Unique row criteria", "return", "$", "pivotData", "[", "$", "this", "->", "inner...
De-duplication in pivot tables based on values in pivot table. @param array $data @return string
[ "De", "-", "duplication", "in", "pivot", "tables", "based", "on", "values", "in", "pivot", "table", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/PivotedRootNode.php#L94-L100
train
rinvex/cortex-foundation
src/Traits/Auditable.php
Auditable.bootAuditable
public static function bootAuditable() { static::creating(function (Model $model) { $model->created_by_id || $model->created_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey(); $model->created_by_type || $model->created_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass(); $model->updated_by_id || $model->updated_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey(); $model->updated_by_type || $model->updated_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass(); }); static::updating(function (Model $model) { $model->isDirty('updated_by_id') || $model->updated_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey(); $model->isDirty('updated_by_type') || $model->updated_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass(); }); }
php
public static function bootAuditable() { static::creating(function (Model $model) { $model->created_by_id || $model->created_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey(); $model->created_by_type || $model->created_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass(); $model->updated_by_id || $model->updated_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey(); $model->updated_by_type || $model->updated_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass(); }); static::updating(function (Model $model) { $model->isDirty('updated_by_id') || $model->updated_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey(); $model->isDirty('updated_by_type') || $model->updated_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass(); }); }
[ "public", "static", "function", "bootAuditable", "(", ")", "{", "static", "::", "creating", "(", "function", "(", "Model", "$", "model", ")", "{", "$", "model", "->", "created_by_id", "||", "$", "model", "->", "created_by_id", "=", "optional", "(", "auth",...
Boot the Auditable trait for the model. @return void
[ "Boot", "the", "Auditable", "trait", "for", "the", "model", "." ]
230c100d98131c76f777e5036b3e7cd83af49e6e
https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Traits/Auditable.php#L48-L62
train
rinvex/cortex-foundation
src/Traits/Auditable.php
Auditable.scopeOfCreator
public function scopeOfCreator(Builder $builder, Model $user): Builder { return $builder->where('created_by_type', $user->getMorphClass())->where('created_by_id', $user->getKey()); }
php
public function scopeOfCreator(Builder $builder, Model $user): Builder { return $builder->where('created_by_type', $user->getMorphClass())->where('created_by_id', $user->getKey()); }
[ "public", "function", "scopeOfCreator", "(", "Builder", "$", "builder", ",", "Model", "$", "user", ")", ":", "Builder", "{", "return", "$", "builder", "->", "where", "(", "'created_by_type'", ",", "$", "user", "->", "getMorphClass", "(", ")", ")", "->", ...
Get audits of the given creator. @param \Illuminate\Database\Eloquent\Builder $builder @param \Illuminate\Database\Eloquent\Model $user @return \Illuminate\Database\Eloquent\Builder
[ "Get", "audits", "of", "the", "given", "creator", "." ]
230c100d98131c76f777e5036b3e7cd83af49e6e
https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Traits/Auditable.php#L92-L95
train
rinvex/cortex-foundation
src/Traits/Auditable.php
Auditable.scopeOfUpdater
public function scopeOfUpdater(Builder $builder, Model $user): Builder { return $builder->where('updated_by_type', $user->getMorphClass())->where('updated_by_id', $user->getKey()); }
php
public function scopeOfUpdater(Builder $builder, Model $user): Builder { return $builder->where('updated_by_type', $user->getMorphClass())->where('updated_by_id', $user->getKey()); }
[ "public", "function", "scopeOfUpdater", "(", "Builder", "$", "builder", ",", "Model", "$", "user", ")", ":", "Builder", "{", "return", "$", "builder", "->", "where", "(", "'updated_by_type'", ",", "$", "user", "->", "getMorphClass", "(", ")", ")", "->", ...
Get audits of the given updater. @param \Illuminate\Database\Eloquent\Builder $builder @param \Illuminate\Database\Eloquent\Model $user @return \Illuminate\Database\Eloquent\Builder
[ "Get", "audits", "of", "the", "given", "updater", "." ]
230c100d98131c76f777e5036b3e7cd83af49e6e
https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Traits/Auditable.php#L105-L108
train
spiral/orm
source/Spiral/ORM/Entities/RecordIterator.php
RecordIterator.getIterator
public function getIterator(): \Generator { foreach ($this->data as $index => $data) { if (isset($data[ORMInterface::PIVOT_DATA])) { /* * When pivot data is provided we are able to use it as array key. */ $index = $data[ORMInterface::PIVOT_DATA]; unset($data[ORMInterface::PIVOT_DATA]); } yield $index => $this->orm->make( $this->class, $data, ORMInterface::STATE_LOADED, true ); } }
php
public function getIterator(): \Generator { foreach ($this->data as $index => $data) { if (isset($data[ORMInterface::PIVOT_DATA])) { /* * When pivot data is provided we are able to use it as array key. */ $index = $data[ORMInterface::PIVOT_DATA]; unset($data[ORMInterface::PIVOT_DATA]); } yield $index => $this->orm->make( $this->class, $data, ORMInterface::STATE_LOADED, true ); } }
[ "public", "function", "getIterator", "(", ")", ":", "\\", "Generator", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "index", "=>", "$", "data", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "ORMInterface", "::", "PIVOT_DATA", "]"...
Generate over data. Method will use pibot @return \Generator
[ "Generate", "over", "data", ".", "Method", "will", "use", "pibot" ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/RecordIterator.php#L57-L75
train
spiral/orm
source/Spiral/ORM/Entities/Relations/HasOneRelation.php
HasOneRelation.queueRelated
private function queueRelated(ContextualCommandInterface $parentCommand): CommandInterface { if (empty($this->instance)) { return new NullCommand(); } //Related entity store command $innerCommand = $this->instance->queueStore(true); //Inversed version of BelongsTo if (!$this->isSynced($this->parent, $this->instance)) { //Syncing FKs after primary command been executed $parentCommand->onExecute(function ($outerCommand) use ($innerCommand) { $innerCommand->addContext( $this->key(Record::OUTER_KEY), $this->lookupKey(Record::INNER_KEY, $this->parent, $outerCommand) ); if (!empty($morphKey = $this->key(Record::MORPH_KEY))) { //HasOne relation support additional morph key $innerCommand->addContext( $this->key(Record::MORPH_KEY), $this->orm->define(get_class($this->parent), ORMInterface::R_ROLE_NAME) ); } }); } return $innerCommand; }
php
private function queueRelated(ContextualCommandInterface $parentCommand): CommandInterface { if (empty($this->instance)) { return new NullCommand(); } //Related entity store command $innerCommand = $this->instance->queueStore(true); //Inversed version of BelongsTo if (!$this->isSynced($this->parent, $this->instance)) { //Syncing FKs after primary command been executed $parentCommand->onExecute(function ($outerCommand) use ($innerCommand) { $innerCommand->addContext( $this->key(Record::OUTER_KEY), $this->lookupKey(Record::INNER_KEY, $this->parent, $outerCommand) ); if (!empty($morphKey = $this->key(Record::MORPH_KEY))) { //HasOne relation support additional morph key $innerCommand->addContext( $this->key(Record::MORPH_KEY), $this->orm->define(get_class($this->parent), ORMInterface::R_ROLE_NAME) ); } }); } return $innerCommand; }
[ "private", "function", "queueRelated", "(", "ContextualCommandInterface", "$", "parentCommand", ")", ":", "CommandInterface", "{", "if", "(", "empty", "(", "$", "this", "->", "instance", ")", ")", "{", "return", "new", "NullCommand", "(", ")", ";", "}", "//R...
Store related instance. @param ContextualCommandInterface $parentCommand @return CommandInterface
[ "Store", "related", "instance", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/HasOneRelation.php#L83-L112
train
robertlemke/RobertLemke.Plugin.Blog
Classes/Service/NotificationService.php
NotificationService.sendNewCommentNotification
public function sendNewCommentNotification(NodeInterface $commentNode, NodeInterface $postNode) { if ($this->settings['notifications']['to']['email'] === '') { return; } if (!class_exists('Neos\SwiftMailer\Message')) { $this->systemLogger->log('The package "Neos.SwiftMailer" is required to send notifications!'); return; } try { $mail = new Message(); $mail ->setFrom([$this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']]) ->setReplyTo([$commentNode->getProperty('emailAddress') => $commentNode->getProperty('author')]) ->setTo([$this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']]) ->setSubject('New comment on blog post "' . $postNode->getProperty('title') . '"' . ($commentNode->getProperty('spam') ? ' (SPAM)' : '')) ->setBody($commentNode->getProperty('text')) ->send(); } catch (\Exception $e) { $this->systemLogger->logException($e); } }
php
public function sendNewCommentNotification(NodeInterface $commentNode, NodeInterface $postNode) { if ($this->settings['notifications']['to']['email'] === '') { return; } if (!class_exists('Neos\SwiftMailer\Message')) { $this->systemLogger->log('The package "Neos.SwiftMailer" is required to send notifications!'); return; } try { $mail = new Message(); $mail ->setFrom([$this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']]) ->setReplyTo([$commentNode->getProperty('emailAddress') => $commentNode->getProperty('author')]) ->setTo([$this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']]) ->setSubject('New comment on blog post "' . $postNode->getProperty('title') . '"' . ($commentNode->getProperty('spam') ? ' (SPAM)' : '')) ->setBody($commentNode->getProperty('text')) ->send(); } catch (\Exception $e) { $this->systemLogger->logException($e); } }
[ "public", "function", "sendNewCommentNotification", "(", "NodeInterface", "$", "commentNode", ",", "NodeInterface", "$", "postNode", ")", "{", "if", "(", "$", "this", "->", "settings", "[", "'notifications'", "]", "[", "'to'", "]", "[", "'email'", "]", "===", ...
Send a new notification that a comment has been created @param NodeInterface $commentNode The comment node @param NodeInterface $postNode The post node @return void
[ "Send", "a", "new", "notification", "that", "a", "comment", "has", "been", "created" ]
7780d7e37022056ebe31088c7917ecaad8881dde
https://github.com/robertlemke/RobertLemke.Plugin.Blog/blob/7780d7e37022056ebe31088c7917ecaad8881dde/Classes/Service/NotificationService.php#L53-L77
train
flownative/flow-google-cloudstorage
Classes/StorageFactory.php
StorageFactory.create
public function create($credentialsProfileName = 'default') { if (!isset($this->credentialProfiles[$credentialsProfileName])) { throw new Exception(sprintf('The specified Google Cloud Storage credentials profile "%s" does not exist, please check your settings.', $credentialsProfileName), 1446553024); } if (!empty($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded'])) { $googleCloud = new ServiceBuilder([ 'keyFile' => json_decode(base64_decode($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded']), true) ]); } else { if (substr($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'], 0, 1) !== '/') { $privateKeyPathAndFilename = FLOW_PATH_ROOT . $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename']; } else { $privateKeyPathAndFilename = $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename']; } if (!file_exists($privateKeyPathAndFilename)) { throw new Exception(sprintf('The Google Cloud Storage private key file "%s" does not exist. Either the file is missing or you need to adjust your settings.', $privateKeyPathAndFilename), 1446553054); } $googleCloud = new ServiceBuilder([ 'keyFilePath' => $privateKeyPathAndFilename ]); } return $googleCloud->storage(); }
php
public function create($credentialsProfileName = 'default') { if (!isset($this->credentialProfiles[$credentialsProfileName])) { throw new Exception(sprintf('The specified Google Cloud Storage credentials profile "%s" does not exist, please check your settings.', $credentialsProfileName), 1446553024); } if (!empty($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded'])) { $googleCloud = new ServiceBuilder([ 'keyFile' => json_decode(base64_decode($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonBase64Encoded']), true) ]); } else { if (substr($this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename'], 0, 1) !== '/') { $privateKeyPathAndFilename = FLOW_PATH_ROOT . $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename']; } else { $privateKeyPathAndFilename = $this->credentialProfiles[$credentialsProfileName]['credentials']['privateKeyJsonPathAndFilename']; } if (!file_exists($privateKeyPathAndFilename)) { throw new Exception(sprintf('The Google Cloud Storage private key file "%s" does not exist. Either the file is missing or you need to adjust your settings.', $privateKeyPathAndFilename), 1446553054); } $googleCloud = new ServiceBuilder([ 'keyFilePath' => $privateKeyPathAndFilename ]); } return $googleCloud->storage(); }
[ "public", "function", "create", "(", "$", "credentialsProfileName", "=", "'default'", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "credentialProfiles", "[", "$", "credentialsProfileName", "]", ")", ")", "{", "throw", "new", "Exception", "(", ...
Creates a new Storage instance and authenticates against the Google API @param string $credentialsProfileName @return \Google\Cloud\Storage\StorageClient @throws Exception
[ "Creates", "a", "new", "Storage", "instance", "and", "authenticates", "against", "the", "Google", "API" ]
78c76b2a0eb10fa514bbae71f93f351ee58dacd3
https://github.com/flownative/flow-google-cloudstorage/blob/78c76b2a0eb10fa514bbae71f93f351ee58dacd3/Classes/StorageFactory.php#L43-L69
train
spiral/orm
source/Spiral/ORM/Schemas/Relations/ManyToManySchema.php
ManyToManySchema.pivotTable
protected function pivotTable(): string { if (!empty($this->option(Record::PIVOT_TABLE))) { return $this->option(Record::PIVOT_TABLE); } $source = $this->definition->sourceContext(); $target = $this->definition->targetContext(); //Generating pivot table name $names = [$source->getRole(), $target->getRole()]; asort($names); return implode('_', $names) . static::PIVOT_POSTFIX; }
php
protected function pivotTable(): string { if (!empty($this->option(Record::PIVOT_TABLE))) { return $this->option(Record::PIVOT_TABLE); } $source = $this->definition->sourceContext(); $target = $this->definition->targetContext(); //Generating pivot table name $names = [$source->getRole(), $target->getRole()]; asort($names); return implode('_', $names) . static::PIVOT_POSTFIX; }
[ "protected", "function", "pivotTable", "(", ")", ":", "string", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "option", "(", "Record", "::", "PIVOT_TABLE", ")", ")", ")", "{", "return", "$", "this", "->", "option", "(", "Record", "::", "PIVOT...
Generate name of pivot table or fetch if from schema. @return string
[ "Generate", "name", "of", "pivot", "table", "or", "fetch", "if", "from", "schema", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/ManyToManySchema.php#L301-L315
train
robertlemke/RobertLemke.Plugin.Blog
Classes/Eel/FilterByReferenceOperation.php
FilterByReferenceOperation.evaluate
public function evaluate(FlowQuery $flowQuery, array $arguments) { if (empty($arguments[0])) { throw new FlowQueryException('filterByReference() needs reference property name by which nodes should be filtered', 1545778273); } if (empty($arguments[1])) { throw new FlowQueryException('filterByReference() needs node reference by which nodes should be filtered', 1545778276); } /** @var NodeInterface $nodeReference */ list($filterByPropertyPath, $nodeReference) = $arguments; $filteredNodes = []; foreach ($flowQuery->getContext() as $node) { /** @var NodeInterface $node */ $propertyValue = $node->getProperty($filterByPropertyPath); if ($nodeReference === $propertyValue || (is_array($propertyValue) && in_array($nodeReference, $propertyValue, TRUE))) { $filteredNodes[] = $node; } } $flowQuery->setContext($filteredNodes); }
php
public function evaluate(FlowQuery $flowQuery, array $arguments) { if (empty($arguments[0])) { throw new FlowQueryException('filterByReference() needs reference property name by which nodes should be filtered', 1545778273); } if (empty($arguments[1])) { throw new FlowQueryException('filterByReference() needs node reference by which nodes should be filtered', 1545778276); } /** @var NodeInterface $nodeReference */ list($filterByPropertyPath, $nodeReference) = $arguments; $filteredNodes = []; foreach ($flowQuery->getContext() as $node) { /** @var NodeInterface $node */ $propertyValue = $node->getProperty($filterByPropertyPath); if ($nodeReference === $propertyValue || (is_array($propertyValue) && in_array($nodeReference, $propertyValue, TRUE))) { $filteredNodes[] = $node; } } $flowQuery->setContext($filteredNodes); }
[ "public", "function", "evaluate", "(", "FlowQuery", "$", "flowQuery", ",", "array", "$", "arguments", ")", "{", "if", "(", "empty", "(", "$", "arguments", "[", "0", "]", ")", ")", "{", "throw", "new", "FlowQueryException", "(", "'filterByReference() needs re...
First argument is property to filter by, must be of reference of references type. Second is object to filter by, must be Node. @param FlowQuery $flowQuery @param array $arguments The arguments for this operation. @return void @throws FlowQueryException @throws \Neos\ContentRepository\Exception\NodeException
[ "First", "argument", "is", "property", "to", "filter", "by", "must", "be", "of", "reference", "of", "references", "type", ".", "Second", "is", "object", "to", "filter", "by", "must", "be", "Node", "." ]
7780d7e37022056ebe31088c7917ecaad8881dde
https://github.com/robertlemke/RobertLemke.Plugin.Blog/blob/7780d7e37022056ebe31088c7917ecaad8881dde/Classes/Eel/FilterByReferenceOperation.php#L47-L68
train
spiral/orm
source/Spiral/ORM/Entities/Relations/ManyToMorphedRelation.php
ManyToMorphedRelation.getVariation
public function getVariation(string $variation): ManyToManyRelation { if (isset($this->nested[$variation])) { return $this->nested[$variation]; } if (!isset($this->schema[Record::MORPHED_ALIASES][$variation])) { throw new RelationException("Undefined morphed variation '{$variation}'"); } $class = $this->schema[Record::MORPHED_ALIASES][$variation]; $relation = new ManyToManyRelation( $class, $this->makeSchema($class), $this->orm, $this->orm->define($class, ORMInterface::R_ROLE_NAME) ); return $this->nested[$variation] = $relation->withContext($this->parent, false); }
php
public function getVariation(string $variation): ManyToManyRelation { if (isset($this->nested[$variation])) { return $this->nested[$variation]; } if (!isset($this->schema[Record::MORPHED_ALIASES][$variation])) { throw new RelationException("Undefined morphed variation '{$variation}'"); } $class = $this->schema[Record::MORPHED_ALIASES][$variation]; $relation = new ManyToManyRelation( $class, $this->makeSchema($class), $this->orm, $this->orm->define($class, ORMInterface::R_ROLE_NAME) ); return $this->nested[$variation] = $relation->withContext($this->parent, false); }
[ "public", "function", "getVariation", "(", "string", "$", "variation", ")", ":", "ManyToManyRelation", "{", "if", "(", "isset", "(", "$", "this", "->", "nested", "[", "$", "variation", "]", ")", ")", "{", "return", "$", "this", "->", "nested", "[", "$"...
Get nested relation for a given variation. @param string $variation @return ManyToManyRelation @throws RelationException
[ "Get", "nested", "relation", "for", "a", "given", "variation", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToMorphedRelation.php#L101-L121
train
spiral/orm
source/Spiral/ORM/Entities/Relations/ManyToMorphedRelation.php
ManyToMorphedRelation.makeSchema
protected function makeSchema(string $class): array { //Using as basement $schema = $this->schema; unset($schema[Record::MORPHED_ALIASES]); //We do not have this information in morphed relation but it's required for ManyToMany $schema[Record::WHERE] = []; //This must be unified in future, for now we can fetch columns directly from there $recordSchema = $this->orm->define($class, ORMInterface::R_SCHEMA); $schema[Record::RELATION_COLUMNS] = array_keys($recordSchema[Record::SH_DEFAULTS]); return $schema; }
php
protected function makeSchema(string $class): array { //Using as basement $schema = $this->schema; unset($schema[Record::MORPHED_ALIASES]); //We do not have this information in morphed relation but it's required for ManyToMany $schema[Record::WHERE] = []; //This must be unified in future, for now we can fetch columns directly from there $recordSchema = $this->orm->define($class, ORMInterface::R_SCHEMA); $schema[Record::RELATION_COLUMNS] = array_keys($recordSchema[Record::SH_DEFAULTS]); return $schema; }
[ "protected", "function", "makeSchema", "(", "string", "$", "class", ")", ":", "array", "{", "//Using as basement", "$", "schema", "=", "$", "this", "->", "schema", ";", "unset", "(", "$", "schema", "[", "Record", "::", "MORPHED_ALIASES", "]", ")", ";", "...
Create relation schema for nested relation. @param string $class @return array
[ "Create", "relation", "schema", "for", "nested", "relation", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Relations/ManyToMorphedRelation.php#L182-L196
train
spiral/orm
source/Spiral/ORM/AbstractRecord.php
AbstractRecord.packChanges
protected function packChanges(bool $skipPrimary = false): array { if (!$this->hasChanges() && !$this->isSolid()) { return []; } if ($this->isSolid()) { //Solid record always updated as one big solid $updates = $this->packValue(); } else { //Updating each field individually $updates = []; foreach ($this->getFields(false) as $field => $value) { //Handled by sub-accessor if ($value instanceof RecordAccessorInterface) { if ($value->hasChanges()) { $updates[$field] = $value->compileUpdates($field); continue; } $value = $value->packValue(); } //Field change registered if (array_key_exists($field, $this->changes)) { $updates[$field] = $value; } } } if ($skipPrimary) { unset($updates[$this->primaryColumn()]); } return $updates; }
php
protected function packChanges(bool $skipPrimary = false): array { if (!$this->hasChanges() && !$this->isSolid()) { return []; } if ($this->isSolid()) { //Solid record always updated as one big solid $updates = $this->packValue(); } else { //Updating each field individually $updates = []; foreach ($this->getFields(false) as $field => $value) { //Handled by sub-accessor if ($value instanceof RecordAccessorInterface) { if ($value->hasChanges()) { $updates[$field] = $value->compileUpdates($field); continue; } $value = $value->packValue(); } //Field change registered if (array_key_exists($field, $this->changes)) { $updates[$field] = $value; } } } if ($skipPrimary) { unset($updates[$this->primaryColumn()]); } return $updates; }
[ "protected", "function", "packChanges", "(", "bool", "$", "skipPrimary", "=", "false", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "hasChanges", "(", ")", "&&", "!", "$", "this", "->", "isSolid", "(", ")", ")", "{", "return", "[", "]...
Create set of fields to be sent to UPDATE statement. @param bool $skipPrimary Skip primary key @return array
[ "Create", "set", "of", "fields", "to", "be", "sent", "to", "UPDATE", "statement", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/AbstractRecord.php#L297-L332
train
rinvex/cortex-foundation
src/Http/Controllers/AbstractController.php
AbstractController.guessGuard
protected function guessGuard(): string { $accessarea = str_before(Route::currentRouteName(), '.'); $guard = str_plural(mb_strstr($accessarea, 'area', true)); return config('auth.guards.'.$guard) ? $guard : config('auth.defaults.guard'); }
php
protected function guessGuard(): string { $accessarea = str_before(Route::currentRouteName(), '.'); $guard = str_plural(mb_strstr($accessarea, 'area', true)); return config('auth.guards.'.$guard) ? $guard : config('auth.defaults.guard'); }
[ "protected", "function", "guessGuard", "(", ")", ":", "string", "{", "$", "accessarea", "=", "str_before", "(", "Route", "::", "currentRouteName", "(", ")", ",", "'.'", ")", ";", "$", "guard", "=", "str_plural", "(", "mb_strstr", "(", "$", "accessarea", ...
Guess guard from accessarea. @return string
[ "Guess", "guard", "from", "accessarea", "." ]
230c100d98131c76f777e5036b3e7cd83af49e6e
https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Http/Controllers/AbstractController.php#L73-L79
train
rinvex/cortex-foundation
src/Http/Controllers/AbstractController.php
AbstractController.guessPasswordResetBroker
protected function guessPasswordResetBroker(): string { $accessarea = str_before(Route::currentRouteName(), '.'); $passwordResetBroker = str_plural(mb_strstr($accessarea, 'area', true)); return config('auth.passwords.'.$passwordResetBroker) ? $passwordResetBroker : config('auth.defaults.passwords'); }
php
protected function guessPasswordResetBroker(): string { $accessarea = str_before(Route::currentRouteName(), '.'); $passwordResetBroker = str_plural(mb_strstr($accessarea, 'area', true)); return config('auth.passwords.'.$passwordResetBroker) ? $passwordResetBroker : config('auth.defaults.passwords'); }
[ "protected", "function", "guessPasswordResetBroker", "(", ")", ":", "string", "{", "$", "accessarea", "=", "str_before", "(", "Route", "::", "currentRouteName", "(", ")", ",", "'.'", ")", ";", "$", "passwordResetBroker", "=", "str_plural", "(", "mb_strstr", "(...
Guess password reset broker from accessarea. @return string
[ "Guess", "password", "reset", "broker", "from", "accessarea", "." ]
230c100d98131c76f777e5036b3e7cd83af49e6e
https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Http/Controllers/AbstractController.php#L114-L120
train
rinvex/cortex-foundation
src/Http/Controllers/AbstractController.php
AbstractController.guessEmailVerificationBroker
protected function guessEmailVerificationBroker(): string { $accessarea = str_before(Route::currentRouteName(), '.'); $emailVerificationBroker = str_plural(mb_strstr($accessarea, 'area', true)); return config('auth.passwords.'.$emailVerificationBroker) ? $emailVerificationBroker : config('auth.defaults.passwords'); }
php
protected function guessEmailVerificationBroker(): string { $accessarea = str_before(Route::currentRouteName(), '.'); $emailVerificationBroker = str_plural(mb_strstr($accessarea, 'area', true)); return config('auth.passwords.'.$emailVerificationBroker) ? $emailVerificationBroker : config('auth.defaults.passwords'); }
[ "protected", "function", "guessEmailVerificationBroker", "(", ")", ":", "string", "{", "$", "accessarea", "=", "str_before", "(", "Route", "::", "currentRouteName", "(", ")", ",", "'.'", ")", ";", "$", "emailVerificationBroker", "=", "str_plural", "(", "mb_strst...
Guess email verification broker from accessarea. @return string
[ "Guess", "email", "verification", "broker", "from", "accessarea", "." ]
230c100d98131c76f777e5036b3e7cd83af49e6e
https://github.com/rinvex/cortex-foundation/blob/230c100d98131c76f777e5036b3e7cd83af49e6e/src/Http/Controllers/AbstractController.php#L137-L143
train
spiral/orm
source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php
MorphedTrait.findOuter
protected function findOuter(SchemaBuilder $builder) { foreach ($this->findTargets($builder) as $schema) { $outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase()); $outerKey = $this->option(Record::OUTER_KEY); if ($outerKey == ORMInterface::R_PRIMARY_KEY) { $outerKey = current($outerTable->getPrimaryKeys()); } if (!$outerTable->hasColumn($outerKey)) { throw new RelationSchemaException(sprintf("Outer key '%s'.'%s' (%s) does not exists", $outerTable->getName(), $outerKey, $this->getDefinition()->getName() )); } return $outerTable->column($outerKey); } return null; }
php
protected function findOuter(SchemaBuilder $builder) { foreach ($this->findTargets($builder) as $schema) { $outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase()); $outerKey = $this->option(Record::OUTER_KEY); if ($outerKey == ORMInterface::R_PRIMARY_KEY) { $outerKey = current($outerTable->getPrimaryKeys()); } if (!$outerTable->hasColumn($outerKey)) { throw new RelationSchemaException(sprintf("Outer key '%s'.'%s' (%s) does not exists", $outerTable->getName(), $outerKey, $this->getDefinition()->getName() )); } return $outerTable->column($outerKey); } return null; }
[ "protected", "function", "findOuter", "(", "SchemaBuilder", "$", "builder", ")", "{", "foreach", "(", "$", "this", "->", "findTargets", "(", "$", "builder", ")", "as", "$", "schema", ")", "{", "$", "outerTable", "=", "$", "builder", "->", "requestTable", ...
Resolving outer key. @param \Spiral\ORM\Schemas\SchemaBuilder $builder @return \Spiral\Database\Schemas\Prototypes\AbstractColumn|null When no outer records found NULL will be returned.
[ "Resolving", "outer", "key", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php#L30-L52
train
spiral/orm
source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php
MorphedTrait.verifyOuter
protected function verifyOuter(SchemaBuilder $builder, AbstractColumn $column) { foreach ($this->findTargets($builder) as $schema) { $outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase()); if (!$outerTable->hasColumn($column->getName())) { //Column is missing throw new RelationSchemaException( "Unable to build morphed relation, outer key '{$column->getName()}' " . "is missing in '{$outerTable->getName()}'" ); } if ($outerTable->column($column->getName())->phpType() != $column->phpType()) { //Inconsistent type throw new RelationSchemaException( "Unable to build morphed relation, outer key '{$column->getName()}' " . "has different type in '{$outerTable->getName()}'" ); } } }
php
protected function verifyOuter(SchemaBuilder $builder, AbstractColumn $column) { foreach ($this->findTargets($builder) as $schema) { $outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase()); if (!$outerTable->hasColumn($column->getName())) { //Column is missing throw new RelationSchemaException( "Unable to build morphed relation, outer key '{$column->getName()}' " . "is missing in '{$outerTable->getName()}'" ); } if ($outerTable->column($column->getName())->phpType() != $column->phpType()) { //Inconsistent type throw new RelationSchemaException( "Unable to build morphed relation, outer key '{$column->getName()}' " . "has different type in '{$outerTable->getName()}'" ); } } }
[ "protected", "function", "verifyOuter", "(", "SchemaBuilder", "$", "builder", ",", "AbstractColumn", "$", "column", ")", "{", "foreach", "(", "$", "this", "->", "findTargets", "(", "$", "builder", ")", "as", "$", "schema", ")", "{", "$", "outerTable", "=",...
Make sure all tables have same outer key. @param \Spiral\ORM\Schemas\SchemaBuilder $builder @param \Spiral\Database\Schemas\Prototypes\AbstractColumn $column @throws RelationSchemaException
[ "Make", "sure", "all", "tables", "have", "same", "outer", "key", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php#L62-L83
train
spiral/orm
source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php
MorphedTrait.findTargets
protected function findTargets(SchemaBuilder $builder): \Generator { foreach ($builder->getSchemas() as $schema) { if (!is_a($schema->getClass(), $this->getDefinition()->getTarget(), true)) { //Not our targets continue; } yield $schema; } }
php
protected function findTargets(SchemaBuilder $builder): \Generator { foreach ($builder->getSchemas() as $schema) { if (!is_a($schema->getClass(), $this->getDefinition()->getTarget(), true)) { //Not our targets continue; } yield $schema; } }
[ "protected", "function", "findTargets", "(", "SchemaBuilder", "$", "builder", ")", ":", "\\", "Generator", "{", "foreach", "(", "$", "builder", "->", "getSchemas", "(", ")", "as", "$", "schema", ")", "{", "if", "(", "!", "is_a", "(", "$", "schema", "->...
Find all matched schemas. @param \Spiral\ORM\Schemas\SchemaBuilder $builder @return \Generator|\Spiral\ORM\Schemas\SchemaInterface[]
[ "Find", "all", "matched", "schemas", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/Traits/MorphedTrait.php#L92-L101
train
swoft-cloud/swoft-rpc-server
src/Router/HandlerMapping.php
HandlerMapping.getHandler
public function getHandler(...$params): array { list($interfaceClass, $version, $method) = $params; return $this->match($interfaceClass, $version, $method); }
php
public function getHandler(...$params): array { list($interfaceClass, $version, $method) = $params; return $this->match($interfaceClass, $version, $method); }
[ "public", "function", "getHandler", "(", "...", "$", "params", ")", ":", "array", "{", "list", "(", "$", "interfaceClass", ",", "$", "version", ",", "$", "method", ")", "=", "$", "params", ";", "return", "$", "this", "->", "match", "(", "$", "interfa...
Get handler from router @param array ...$params @return array @throws \InvalidArgumentException
[ "Get", "handler", "from", "router" ]
527ce20421ad46919b16ebdcc12658f0e3807a07
https://github.com/swoft-cloud/swoft-rpc-server/blob/527ce20421ad46919b16ebdcc12658f0e3807a07/src/Router/HandlerMapping.php#L28-L32
train
swoft-cloud/swoft-rpc-server
src/Router/HandlerMapping.php
HandlerMapping.getServiceKey
private function getServiceKey(string $interfaceClass, string $version, string $method): string { return \sprintf('%s_%s_%s', $interfaceClass, $version, $method); }
php
private function getServiceKey(string $interfaceClass, string $version, string $method): string { return \sprintf('%s_%s_%s', $interfaceClass, $version, $method); }
[ "private", "function", "getServiceKey", "(", "string", "$", "interfaceClass", ",", "string", "$", "version", ",", "string", "$", "method", ")", ":", "string", "{", "return", "\\", "sprintf", "(", "'%s_%s_%s'", ",", "$", "interfaceClass", ",", "$", "version",...
Get service key @param string $interfaceClass @param string $version @param string $method @return string
[ "Get", "service", "key" ]
527ce20421ad46919b16ebdcc12658f0e3807a07
https://github.com/swoft-cloud/swoft-rpc-server/blob/527ce20421ad46919b16ebdcc12658f0e3807a07/src/Router/HandlerMapping.php#L101-L104
train
spiral/orm
source/Spiral/ORM/Schemas/Relations/AbstractSchema.php
AbstractSchema.isConstrained
public function isConstrained() { $source = $this->definition->sourceContext(); $target = $this->definition->targetContext(); if (empty($target)) { return false; } if ($source->getDatabase() != $target->getDatabase()) { //Unable to create constrains for records in different databases return false; } return $this->option(Record::CREATE_CONSTRAINT); }
php
public function isConstrained() { $source = $this->definition->sourceContext(); $target = $this->definition->targetContext(); if (empty($target)) { return false; } if ($source->getDatabase() != $target->getDatabase()) { //Unable to create constrains for records in different databases return false; } return $this->option(Record::CREATE_CONSTRAINT); }
[ "public", "function", "isConstrained", "(", ")", "{", "$", "source", "=", "$", "this", "->", "definition", "->", "sourceContext", "(", ")", ";", "$", "target", "=", "$", "this", "->", "definition", "->", "targetContext", "(", ")", ";", "if", "(", "empt...
Check if relation requests foreign key constraints to be created. @return bool
[ "Check", "if", "relation", "requests", "foreign", "key", "constraints", "to", "be", "created", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Schemas/Relations/AbstractSchema.php#L126-L140
train
spiral/orm
source/Spiral/ORM/Entities/Nodes/AbstractNode.php
AbstractNode.getReferences
public function getReferences(): array { if (empty($this->parent)) { throw new NodeException("Unable to aggregate reference values, parent is missing"); } if (empty($this->parent->references[$this->outerKey])) { return []; } return array_keys($this->parent->references[$this->outerKey]); }
php
public function getReferences(): array { if (empty($this->parent)) { throw new NodeException("Unable to aggregate reference values, parent is missing"); } if (empty($this->parent->references[$this->outerKey])) { return []; } return array_keys($this->parent->references[$this->outerKey]); }
[ "public", "function", "getReferences", "(", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "this", "->", "parent", ")", ")", "{", "throw", "new", "NodeException", "(", "\"Unable to aggregate reference values, parent is missing\"", ")", ";", "}", "if", "...
Get list of reference key values aggregated by parent. @return array @throws NodeException
[ "Get", "list", "of", "reference", "key", "values", "aggregated", "by", "parent", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L118-L129
train
spiral/orm
source/Spiral/ORM/Entities/Nodes/AbstractNode.php
AbstractNode.registerNode
final public function registerNode(string $container, AbstractNode $node) { $node->container = $container; $node->parent = $this; $this->nodes[$container] = $node; if (!empty($node->outerKey)) { //This will make parser to aggregate such key in order to be used in later statement $this->trackReference($node->outerKey); } }
php
final public function registerNode(string $container, AbstractNode $node) { $node->container = $container; $node->parent = $this; $this->nodes[$container] = $node; if (!empty($node->outerKey)) { //This will make parser to aggregate such key in order to be used in later statement $this->trackReference($node->outerKey); } }
[ "final", "public", "function", "registerNode", "(", "string", "$", "container", ",", "AbstractNode", "$", "node", ")", "{", "$", "node", "->", "container", "=", "$", "container", ";", "$", "node", "->", "parent", "=", "$", "this", ";", "$", "this", "->...
Register new node into NodeTree. Nodes used to convert flat results into tree representation using reference aggregations. @param string $container @param AbstractNode $node @throws NodeException
[ "Register", "new", "node", "into", "NodeTree", ".", "Nodes", "used", "to", "convert", "flat", "results", "into", "tree", "representation", "using", "reference", "aggregations", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L140-L151
train
spiral/orm
source/Spiral/ORM/Entities/Nodes/AbstractNode.php
AbstractNode.fetchNode
final public function fetchNode(string $container): AbstractNode { if (!isset($this->nodes[$container])) { throw new NodeException("Undefined node {$container}"); } return $this->nodes[$container]; }
php
final public function fetchNode(string $container): AbstractNode { if (!isset($this->nodes[$container])) { throw new NodeException("Undefined node {$container}"); } return $this->nodes[$container]; }
[ "final", "public", "function", "fetchNode", "(", "string", "$", "container", ")", ":", "AbstractNode", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "nodes", "[", "$", "container", "]", ")", ")", "{", "throw", "new", "NodeException", "(", "\"Un...
Fetch sub node. @param string $container @return AbstractNode @throws NodeException
[ "Fetch", "sub", "node", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L173-L180
train
spiral/orm
source/Spiral/ORM/Entities/Nodes/AbstractNode.php
AbstractNode.parseRow
final public function parseRow(int $dataOffset, array $row): int { //Fetching Node specific data from resulted row $data = $this->fetchData($dataOffset, $row); if ($this->deduplicate($data)) { //Create reference keys $this->collectReferences($data); //Make sure that all nested relations are registered $this->ensurePlaceholders($data); //Add data into result set $this->pushData($data); } elseif (!empty($this->parent)) { //Registering duplicates rows in each parent row $this->pushData($data); } $innerOffset = 0; foreach ($this->nodes as $container => $node) { if ($node->joined) { /** * We are looking into branch like structure: * node * - node * - node * - node * node * * This means offset has to be calculated using all nested nodes */ $innerColumns = $node->parseRow($this->countColumns + $dataOffset, $row); //Counting next selection offset $dataOffset += $innerColumns; //Counting nested tree offset $innerOffset += $innerColumns; } } return $this->countColumns + $innerOffset; }
php
final public function parseRow(int $dataOffset, array $row): int { //Fetching Node specific data from resulted row $data = $this->fetchData($dataOffset, $row); if ($this->deduplicate($data)) { //Create reference keys $this->collectReferences($data); //Make sure that all nested relations are registered $this->ensurePlaceholders($data); //Add data into result set $this->pushData($data); } elseif (!empty($this->parent)) { //Registering duplicates rows in each parent row $this->pushData($data); } $innerOffset = 0; foreach ($this->nodes as $container => $node) { if ($node->joined) { /** * We are looking into branch like structure: * node * - node * - node * - node * node * * This means offset has to be calculated using all nested nodes */ $innerColumns = $node->parseRow($this->countColumns + $dataOffset, $row); //Counting next selection offset $dataOffset += $innerColumns; //Counting nested tree offset $innerOffset += $innerColumns; } } return $this->countColumns + $innerOffset; }
[ "final", "public", "function", "parseRow", "(", "int", "$", "dataOffset", ",", "array", "$", "row", ")", ":", "int", "{", "//Fetching Node specific data from resulted row", "$", "data", "=", "$", "this", "->", "fetchData", "(", "$", "dataOffset", ",", "$", "...
Parser result work, fetch data and mount it into parent tree. @param int $dataOffset @param array $row @return int Must return number of handled columns.
[ "Parser", "result", "work", "fetch", "data", "and", "mount", "it", "into", "parent", "tree", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L190-L233
train
spiral/orm
source/Spiral/ORM/Entities/Nodes/AbstractNode.php
AbstractNode.fetchData
protected function fetchData(int $dataOffset, array $line): array { if (empty($this->columns)) { return $line; } try { //Combine column names with sliced piece of row return array_combine( $this->columns, array_slice($line, $dataOffset, $this->countColumns) ); } catch (\Exception $e) { throw new NodeException("Unable to parse incoming row", $e->getCode(), $e); } }
php
protected function fetchData(int $dataOffset, array $line): array { if (empty($this->columns)) { return $line; } try { //Combine column names with sliced piece of row return array_combine( $this->columns, array_slice($line, $dataOffset, $this->countColumns) ); } catch (\Exception $e) { throw new NodeException("Unable to parse incoming row", $e->getCode(), $e); } }
[ "protected", "function", "fetchData", "(", "int", "$", "dataOffset", ",", "array", "$", "line", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "this", "->", "columns", ")", ")", "{", "return", "$", "line", ";", "}", "try", "{", "//Combine colu...
Fetch record columns from query row, must use data offset to slice required part of query. @param int $dataOffset @param array $line @return array
[ "Fetch", "record", "columns", "from", "query", "row", "must", "use", "data", "offset", "to", "slice", "required", "part", "of", "query", "." ]
a301cd1b664e65496dab648d77ee92bf4fb6949b
https://github.com/spiral/orm/blob/a301cd1b664e65496dab648d77ee92bf4fb6949b/source/Spiral/ORM/Entities/Nodes/AbstractNode.php#L357-L372
train