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
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/plugins/PluginInstallationService.php
PluginInstallationService.insertCMSNavItem
protected function insertCMSNavItem(CMSNavItem $cms_nav_item, Plugin $plugin) { $cms_nav_item->PluginID = $plugin->PluginID; // if($cms_nav_item->Slug == '') // $cms_nav_item->Slug = SlugUtils::createSlug($cms_nav_item->Label); // // if (empty($cms_nav_item->SortOrder)) // $cms_nav_item->SortOrder = PHP_INT_MAX; $cms_nav_item->ModifiedDate = $plugin->ModifiedDate; try { if (!$this->CMSNavItemService->slugExists($cms_nav_item->Slug)) { $this->CMSNavItemService->add($cms_nav_item); return true; } else { $existing_nav_item = $this->CMSNavItemService->getBySlug($cms_nav_item->Slug); if($existing_nav_item->PluginID == $cms_nav_item->PluginID) { $cms_nav_item->CMSNavItemID = $existing_nav_item->CMSNavItemID; $this->CMSNavItemService->edit($cms_nav_item); } } } catch(ValidationException $ve) { throw new Exception('CMSNavItem ['.$cms_nav_item->Slug.']: '.$ve->getMessage()); } return false; }
php
protected function insertCMSNavItem(CMSNavItem $cms_nav_item, Plugin $plugin) { $cms_nav_item->PluginID = $plugin->PluginID; // if($cms_nav_item->Slug == '') // $cms_nav_item->Slug = SlugUtils::createSlug($cms_nav_item->Label); // // if (empty($cms_nav_item->SortOrder)) // $cms_nav_item->SortOrder = PHP_INT_MAX; $cms_nav_item->ModifiedDate = $plugin->ModifiedDate; try { if (!$this->CMSNavItemService->slugExists($cms_nav_item->Slug)) { $this->CMSNavItemService->add($cms_nav_item); return true; } else { $existing_nav_item = $this->CMSNavItemService->getBySlug($cms_nav_item->Slug); if($existing_nav_item->PluginID == $cms_nav_item->PluginID) { $cms_nav_item->CMSNavItemID = $existing_nav_item->CMSNavItemID; $this->CMSNavItemService->edit($cms_nav_item); } } } catch(ValidationException $ve) { throw new Exception('CMSNavItem ['.$cms_nav_item->Slug.']: '.$ve->getMessage()); } return false; }
[ "protected", "function", "insertCMSNavItem", "(", "CMSNavItem", "$", "cms_nav_item", ",", "Plugin", "$", "plugin", ")", "{", "$", "cms_nav_item", "->", "PluginID", "=", "$", "plugin", "->", "PluginID", ";", "// if($cms_nav_item->Slug == '')", "// $cms_nav_item->Slug = SlugUtils::createSlug($cms_nav_item->Label);", "//", "// if (empty($cms_nav_item->SortOrder))", "// $cms_nav_item->SortOrder = PHP_INT_MAX;", "$", "cms_nav_item", "->", "ModifiedDate", "=", "$", "plugin", "->", "ModifiedDate", ";", "try", "{", "if", "(", "!", "$", "this", "->", "CMSNavItemService", "->", "slugExists", "(", "$", "cms_nav_item", "->", "Slug", ")", ")", "{", "$", "this", "->", "CMSNavItemService", "->", "add", "(", "$", "cms_nav_item", ")", ";", "return", "true", ";", "}", "else", "{", "$", "existing_nav_item", "=", "$", "this", "->", "CMSNavItemService", "->", "getBySlug", "(", "$", "cms_nav_item", "->", "Slug", ")", ";", "if", "(", "$", "existing_nav_item", "->", "PluginID", "==", "$", "cms_nav_item", "->", "PluginID", ")", "{", "$", "cms_nav_item", "->", "CMSNavItemID", "=", "$", "existing_nav_item", "->", "CMSNavItemID", ";", "$", "this", "->", "CMSNavItemService", "->", "edit", "(", "$", "cms_nav_item", ")", ";", "}", "}", "}", "catch", "(", "ValidationException", "$", "ve", ")", "{", "throw", "new", "Exception", "(", "'CMSNavItem ['", ".", "$", "cms_nav_item", "->", "Slug", ".", "']: '", ".", "$", "ve", "->", "getMessage", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Inserts the specified CMS Nav Item @param CMSNavItem $cms_nav_item The item to insert @param Plugin $plugin The plugin that owns the nav item @return boolean true on success
[ "Inserts", "the", "specified", "CMS", "Nav", "Item" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/plugins/PluginInstallationService.php#L631-L661
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/plugins/PluginInstallationService.php
PluginInstallationService.processElements
protected function processElements(Plugin $plugin, &$log = '', $xml = false) { if (!$xml) $xml = $this->loadXML($plugin->Path); if(!$xml) throw new Exception('Missing plugin.xml file for plugin ['.$plugin->Slug.']'); $processedSlugs = array(); // add elements $elements = $xml->elements; if (!empty($elements)) { foreach ( $elements->element as $elementNode ) { $element = new Element(); $this->ModelMapper->defaultsOnModel($element); $this->SystemXMLConverter->xmlToElement($element, $elementNode); $log .= "Processing element descriptor: {$element->Slug}\n"; if ($this->ElementService->slugExists($element->Slug)) { $existingElement = $this->ElementService->getBySlug($element->Slug); if ($existingElement->PluginID != $plugin->PluginID) { $log .= 'WARNING: Element already exists for slug: '.$existingElement->Slug."\n"; continue; } $element->ElementID = $existingElement->ElementID; } $element->PluginID = $plugin->PluginID; $anchorSite = $this->SiteService->getAnchoredSite(); if(empty($anchorSite)) throw new Exception('Cannot install element without anchor site'); $element->AnchoredSiteSlug = $anchorSite->getSlug(); $element->AnchoredSiteSlugOverride = $anchorSite->getSlug(); $element->AnchoredSite = $anchorSite; if ($this->ElementService->slugExists($element->Slug)) { $log .= "Element updated...\n"; $this->ElementService->edit($element); } else { $log .= "Element created...\n"; $this->ElementService->add($element); } $log .= "ID: {$element->ElementID}\n"; $log .= "Slug: {$element->Slug}\n"; $log .= "Name: {$element->Name}\n"; $log .= "Description: {$element->Description}\n"; $log .= "\n"; $log .= "Creating element DB schema..."; $element = $this->ElementService->getBySlug($element->Slug); //refresh schema $this->NodeService->createDBSchema($element); $log .= "done.\n\n"; } } }
php
protected function processElements(Plugin $plugin, &$log = '', $xml = false) { if (!$xml) $xml = $this->loadXML($plugin->Path); if(!$xml) throw new Exception('Missing plugin.xml file for plugin ['.$plugin->Slug.']'); $processedSlugs = array(); // add elements $elements = $xml->elements; if (!empty($elements)) { foreach ( $elements->element as $elementNode ) { $element = new Element(); $this->ModelMapper->defaultsOnModel($element); $this->SystemXMLConverter->xmlToElement($element, $elementNode); $log .= "Processing element descriptor: {$element->Slug}\n"; if ($this->ElementService->slugExists($element->Slug)) { $existingElement = $this->ElementService->getBySlug($element->Slug); if ($existingElement->PluginID != $plugin->PluginID) { $log .= 'WARNING: Element already exists for slug: '.$existingElement->Slug."\n"; continue; } $element->ElementID = $existingElement->ElementID; } $element->PluginID = $plugin->PluginID; $anchorSite = $this->SiteService->getAnchoredSite(); if(empty($anchorSite)) throw new Exception('Cannot install element without anchor site'); $element->AnchoredSiteSlug = $anchorSite->getSlug(); $element->AnchoredSiteSlugOverride = $anchorSite->getSlug(); $element->AnchoredSite = $anchorSite; if ($this->ElementService->slugExists($element->Slug)) { $log .= "Element updated...\n"; $this->ElementService->edit($element); } else { $log .= "Element created...\n"; $this->ElementService->add($element); } $log .= "ID: {$element->ElementID}\n"; $log .= "Slug: {$element->Slug}\n"; $log .= "Name: {$element->Name}\n"; $log .= "Description: {$element->Description}\n"; $log .= "\n"; $log .= "Creating element DB schema..."; $element = $this->ElementService->getBySlug($element->Slug); //refresh schema $this->NodeService->createDBSchema($element); $log .= "done.\n\n"; } } }
[ "protected", "function", "processElements", "(", "Plugin", "$", "plugin", ",", "&", "$", "log", "=", "''", ",", "$", "xml", "=", "false", ")", "{", "if", "(", "!", "$", "xml", ")", "$", "xml", "=", "$", "this", "->", "loadXML", "(", "$", "plugin", "->", "Path", ")", ";", "if", "(", "!", "$", "xml", ")", "throw", "new", "Exception", "(", "'Missing plugin.xml file for plugin ['", ".", "$", "plugin", "->", "Slug", ".", "']'", ")", ";", "$", "processedSlugs", "=", "array", "(", ")", ";", "// add elements", "$", "elements", "=", "$", "xml", "->", "elements", ";", "if", "(", "!", "empty", "(", "$", "elements", ")", ")", "{", "foreach", "(", "$", "elements", "->", "element", "as", "$", "elementNode", ")", "{", "$", "element", "=", "new", "Element", "(", ")", ";", "$", "this", "->", "ModelMapper", "->", "defaultsOnModel", "(", "$", "element", ")", ";", "$", "this", "->", "SystemXMLConverter", "->", "xmlToElement", "(", "$", "element", ",", "$", "elementNode", ")", ";", "$", "log", ".=", "\"Processing element descriptor: {$element->Slug}\\n\"", ";", "if", "(", "$", "this", "->", "ElementService", "->", "slugExists", "(", "$", "element", "->", "Slug", ")", ")", "{", "$", "existingElement", "=", "$", "this", "->", "ElementService", "->", "getBySlug", "(", "$", "element", "->", "Slug", ")", ";", "if", "(", "$", "existingElement", "->", "PluginID", "!=", "$", "plugin", "->", "PluginID", ")", "{", "$", "log", ".=", "'WARNING: Element already exists for slug: '", ".", "$", "existingElement", "->", "Slug", ".", "\"\\n\"", ";", "continue", ";", "}", "$", "element", "->", "ElementID", "=", "$", "existingElement", "->", "ElementID", ";", "}", "$", "element", "->", "PluginID", "=", "$", "plugin", "->", "PluginID", ";", "$", "anchorSite", "=", "$", "this", "->", "SiteService", "->", "getAnchoredSite", "(", ")", ";", "if", "(", "empty", "(", "$", "anchorSite", ")", ")", "throw", "new", "Exception", "(", "'Cannot install element without anchor site'", ")", ";", "$", "element", "->", "AnchoredSiteSlug", "=", "$", "anchorSite", "->", "getSlug", "(", ")", ";", "$", "element", "->", "AnchoredSiteSlugOverride", "=", "$", "anchorSite", "->", "getSlug", "(", ")", ";", "$", "element", "->", "AnchoredSite", "=", "$", "anchorSite", ";", "if", "(", "$", "this", "->", "ElementService", "->", "slugExists", "(", "$", "element", "->", "Slug", ")", ")", "{", "$", "log", ".=", "\"Element updated...\\n\"", ";", "$", "this", "->", "ElementService", "->", "edit", "(", "$", "element", ")", ";", "}", "else", "{", "$", "log", ".=", "\"Element created...\\n\"", ";", "$", "this", "->", "ElementService", "->", "add", "(", "$", "element", ")", ";", "}", "$", "log", ".=", "\"ID: {$element->ElementID}\\n\"", ";", "$", "log", ".=", "\"Slug: {$element->Slug}\\n\"", ";", "$", "log", ".=", "\"Name: {$element->Name}\\n\"", ";", "$", "log", ".=", "\"Description: {$element->Description}\\n\"", ";", "$", "log", ".=", "\"\\n\"", ";", "$", "log", ".=", "\"Creating element DB schema...\"", ";", "$", "element", "=", "$", "this", "->", "ElementService", "->", "getBySlug", "(", "$", "element", "->", "Slug", ")", ";", "//refresh schema", "$", "this", "->", "NodeService", "->", "createDBSchema", "(", "$", "element", ")", ";", "$", "log", ".=", "\"done.\\n\\n\"", ";", "}", "}", "}" ]
Add all the elements defined by this plugin @param Plugin $plugin The plugin to analyze @param string &$log A string to hold logging detail @return void
[ "Add", "all", "the", "elements", "defined", "by", "this", "plugin" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/plugins/PluginInstallationService.php#L671-L734
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/plugins/PluginInstallationService.php
PluginInstallationService.processInstallScript
public function processInstallScript(Plugin $plugin, &$log) { $script = $plugin->Path .'/install.php'; if(file_exists($script)) { include_once $script; } }
php
public function processInstallScript(Plugin $plugin, &$log) { $script = $plugin->Path .'/install.php'; if(file_exists($script)) { include_once $script; } }
[ "public", "function", "processInstallScript", "(", "Plugin", "$", "plugin", ",", "&", "$", "log", ")", "{", "$", "script", "=", "$", "plugin", "->", "Path", ".", "'/install.php'", ";", "if", "(", "file_exists", "(", "$", "script", ")", ")", "{", "include_once", "$", "script", ";", "}", "}" ]
Runs the install script from the plugin @param Plugin $plugin The Plugin to analyze @param string &$log A log string that can be updated @return void
[ "Runs", "the", "install", "script", "from", "the", "plugin" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/plugins/PluginInstallationService.php#L744-L750
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/plugins/PluginInstallationService.php
PluginInstallationService.processUpgradeScript
public function processUpgradeScript(Plugin $plugin, &$log, $installedVersion) { $script = $plugin->Path .'/upgrade.php'; if(file_exists($script)) include_once $script; }
php
public function processUpgradeScript(Plugin $plugin, &$log, $installedVersion) { $script = $plugin->Path .'/upgrade.php'; if(file_exists($script)) include_once $script; }
[ "public", "function", "processUpgradeScript", "(", "Plugin", "$", "plugin", ",", "&", "$", "log", ",", "$", "installedVersion", ")", "{", "$", "script", "=", "$", "plugin", "->", "Path", ".", "'/upgrade.php'", ";", "if", "(", "file_exists", "(", "$", "script", ")", ")", "include_once", "$", "script", ";", "}" ]
Runs the upgrade script for the plugin @param Plugin $plugin The Plugin to analyze @param string &$log A helpful string that will be appended with details of actions @return void
[ "Runs", "the", "upgrade", "script", "for", "the", "plugin" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/plugins/PluginInstallationService.php#L760-L767
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/plugins/PluginInstallationService.php
PluginInstallationService.autoupgradePlugin
public function autoupgradePlugin(Plugin $plugin) { if(empty($plugin) || !$plugin->isInstalled() || !$plugin->isEnabled()) return; $xml = $this->loadXML($plugin->Path); if(empty($xml)) return; if($plugin->Version != ($newversion = strval($xml->info->version))) { $plugin->NewVersion = $newversion; return; } if(!$this->TransactionManager->isTransactionInProgress()) $this->TransactionManager->begin(); $xmlFile = $plugin->Path.'/plugin.xml'; $ts = $this->DateFactory->newLocalDate(filemtime($xmlFile)); $md5 = md5_file($xmlFile); $changed = $this->processAspects($plugin, $log); if($plugin->Md5 !== $md5) { $plugin->Md5 = $md5; $this->processCMSNavItems($plugin, $log, $xml); $this->processElements($plugin, $log, $xml); $changed = true; } // rerun element schemas if($changed) { $plugin->AutoUpgraded = true; if(!$this->TransactionManager->isTransactionInProgress()) $this->TransactionManager->begin(); // foreach($this->ElementService->findAll()->getResults() as $element) // $this->NodeService->createDBSchema($element); $plugin = $this->PluginService->edit($plugin); } }
php
public function autoupgradePlugin(Plugin $plugin) { if(empty($plugin) || !$plugin->isInstalled() || !$plugin->isEnabled()) return; $xml = $this->loadXML($plugin->Path); if(empty($xml)) return; if($plugin->Version != ($newversion = strval($xml->info->version))) { $plugin->NewVersion = $newversion; return; } if(!$this->TransactionManager->isTransactionInProgress()) $this->TransactionManager->begin(); $xmlFile = $plugin->Path.'/plugin.xml'; $ts = $this->DateFactory->newLocalDate(filemtime($xmlFile)); $md5 = md5_file($xmlFile); $changed = $this->processAspects($plugin, $log); if($plugin->Md5 !== $md5) { $plugin->Md5 = $md5; $this->processCMSNavItems($plugin, $log, $xml); $this->processElements($plugin, $log, $xml); $changed = true; } // rerun element schemas if($changed) { $plugin->AutoUpgraded = true; if(!$this->TransactionManager->isTransactionInProgress()) $this->TransactionManager->begin(); // foreach($this->ElementService->findAll()->getResults() as $element) // $this->NodeService->createDBSchema($element); $plugin = $this->PluginService->edit($plugin); } }
[ "public", "function", "autoupgradePlugin", "(", "Plugin", "$", "plugin", ")", "{", "if", "(", "empty", "(", "$", "plugin", ")", "||", "!", "$", "plugin", "->", "isInstalled", "(", ")", "||", "!", "$", "plugin", "->", "isEnabled", "(", ")", ")", "return", ";", "$", "xml", "=", "$", "this", "->", "loadXML", "(", "$", "plugin", "->", "Path", ")", ";", "if", "(", "empty", "(", "$", "xml", ")", ")", "return", ";", "if", "(", "$", "plugin", "->", "Version", "!=", "(", "$", "newversion", "=", "strval", "(", "$", "xml", "->", "info", "->", "version", ")", ")", ")", "{", "$", "plugin", "->", "NewVersion", "=", "$", "newversion", ";", "return", ";", "}", "if", "(", "!", "$", "this", "->", "TransactionManager", "->", "isTransactionInProgress", "(", ")", ")", "$", "this", "->", "TransactionManager", "->", "begin", "(", ")", ";", "$", "xmlFile", "=", "$", "plugin", "->", "Path", ".", "'/plugin.xml'", ";", "$", "ts", "=", "$", "this", "->", "DateFactory", "->", "newLocalDate", "(", "filemtime", "(", "$", "xmlFile", ")", ")", ";", "$", "md5", "=", "md5_file", "(", "$", "xmlFile", ")", ";", "$", "changed", "=", "$", "this", "->", "processAspects", "(", "$", "plugin", ",", "$", "log", ")", ";", "if", "(", "$", "plugin", "->", "Md5", "!==", "$", "md5", ")", "{", "$", "plugin", "->", "Md5", "=", "$", "md5", ";", "$", "this", "->", "processCMSNavItems", "(", "$", "plugin", ",", "$", "log", ",", "$", "xml", ")", ";", "$", "this", "->", "processElements", "(", "$", "plugin", ",", "$", "log", ",", "$", "xml", ")", ";", "$", "changed", "=", "true", ";", "}", "// rerun element schemas", "if", "(", "$", "changed", ")", "{", "$", "plugin", "->", "AutoUpgraded", "=", "true", ";", "if", "(", "!", "$", "this", "->", "TransactionManager", "->", "isTransactionInProgress", "(", ")", ")", "$", "this", "->", "TransactionManager", "->", "begin", "(", ")", ";", "// foreach($this->ElementService->findAll()->getResults() as $element)", "// $this->NodeService->createDBSchema($element);", "$", "plugin", "=", "$", "this", "->", "PluginService", "->", "edit", "(", "$", "plugin", ")", ";", "}", "}" ]
Reruns the aspect installation to upgrade the plugin if needed @param Plugin $plugin The plugin to upgrade @return void
[ "Reruns", "the", "aspect", "installation", "to", "upgrade", "the", "plugin", "if", "needed" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/plugins/PluginInstallationService.php#L889-L937
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/plugins/PluginInstallationService.php
PluginInstallationService.upgradePlugin
public function upgradePlugin($pluginSlug, $pluginPath, Errors &$errors) { $log = ""; $plugin = $this->PluginService->getBySlug($pluginSlug); $existingPriority = $plugin->Priority; if (empty($plugin) || !$plugin->isInstalled()) { $log .= "Plugin is not installed."; return array($log, 'fail'); } $log .= "Upgrading plugin [$pluginSlug]...\n"; $xml = $this->loadXML($plugin->Path); $originalVersion = $plugin->Version; $plugin = $this->SystemXMLConverter->xmlToPlugin($plugin, $xml); $plugin->Priority = $existingPriority; $plugin->ModifiedDate = $this->DateFactory->newStorageDate(filemtime($pluginPath.'/plugin.xml')); $plugin->Md5 = md5_file($pluginPath.'/plugin.xml'); $this->PluginService->edit($plugin); $plugin = $this->PluginService->getBySlug($pluginSlug); $this->processAspects($plugin, $log); foreach($this->ElementService->findAll()->getResults() as $element) $this->NodeService->createDBSchema($element); $this->processPluginXML($plugin, $errors, $log, $xml); $errors->throwOnError(); $this->processUpgradeScript($plugin, $log, $originalVersion); $this->ApplicationContext->clearContextFiles(); return array($log, strpos($log, 'WARNING')=== FALSE?'success':'warn'); }
php
public function upgradePlugin($pluginSlug, $pluginPath, Errors &$errors) { $log = ""; $plugin = $this->PluginService->getBySlug($pluginSlug); $existingPriority = $plugin->Priority; if (empty($plugin) || !$plugin->isInstalled()) { $log .= "Plugin is not installed."; return array($log, 'fail'); } $log .= "Upgrading plugin [$pluginSlug]...\n"; $xml = $this->loadXML($plugin->Path); $originalVersion = $plugin->Version; $plugin = $this->SystemXMLConverter->xmlToPlugin($plugin, $xml); $plugin->Priority = $existingPriority; $plugin->ModifiedDate = $this->DateFactory->newStorageDate(filemtime($pluginPath.'/plugin.xml')); $plugin->Md5 = md5_file($pluginPath.'/plugin.xml'); $this->PluginService->edit($plugin); $plugin = $this->PluginService->getBySlug($pluginSlug); $this->processAspects($plugin, $log); foreach($this->ElementService->findAll()->getResults() as $element) $this->NodeService->createDBSchema($element); $this->processPluginXML($plugin, $errors, $log, $xml); $errors->throwOnError(); $this->processUpgradeScript($plugin, $log, $originalVersion); $this->ApplicationContext->clearContextFiles(); return array($log, strpos($log, 'WARNING')=== FALSE?'success':'warn'); }
[ "public", "function", "upgradePlugin", "(", "$", "pluginSlug", ",", "$", "pluginPath", ",", "Errors", "&", "$", "errors", ")", "{", "$", "log", "=", "\"\"", ";", "$", "plugin", "=", "$", "this", "->", "PluginService", "->", "getBySlug", "(", "$", "pluginSlug", ")", ";", "$", "existingPriority", "=", "$", "plugin", "->", "Priority", ";", "if", "(", "empty", "(", "$", "plugin", ")", "||", "!", "$", "plugin", "->", "isInstalled", "(", ")", ")", "{", "$", "log", ".=", "\"Plugin is not installed.\"", ";", "return", "array", "(", "$", "log", ",", "'fail'", ")", ";", "}", "$", "log", ".=", "\"Upgrading plugin [$pluginSlug]...\\n\"", ";", "$", "xml", "=", "$", "this", "->", "loadXML", "(", "$", "plugin", "->", "Path", ")", ";", "$", "originalVersion", "=", "$", "plugin", "->", "Version", ";", "$", "plugin", "=", "$", "this", "->", "SystemXMLConverter", "->", "xmlToPlugin", "(", "$", "plugin", ",", "$", "xml", ")", ";", "$", "plugin", "->", "Priority", "=", "$", "existingPriority", ";", "$", "plugin", "->", "ModifiedDate", "=", "$", "this", "->", "DateFactory", "->", "newStorageDate", "(", "filemtime", "(", "$", "pluginPath", ".", "'/plugin.xml'", ")", ")", ";", "$", "plugin", "->", "Md5", "=", "md5_file", "(", "$", "pluginPath", ".", "'/plugin.xml'", ")", ";", "$", "this", "->", "PluginService", "->", "edit", "(", "$", "plugin", ")", ";", "$", "plugin", "=", "$", "this", "->", "PluginService", "->", "getBySlug", "(", "$", "pluginSlug", ")", ";", "$", "this", "->", "processAspects", "(", "$", "plugin", ",", "$", "log", ")", ";", "foreach", "(", "$", "this", "->", "ElementService", "->", "findAll", "(", ")", "->", "getResults", "(", ")", "as", "$", "element", ")", "$", "this", "->", "NodeService", "->", "createDBSchema", "(", "$", "element", ")", ";", "$", "this", "->", "processPluginXML", "(", "$", "plugin", ",", "$", "errors", ",", "$", "log", ",", "$", "xml", ")", ";", "$", "errors", "->", "throwOnError", "(", ")", ";", "$", "this", "->", "processUpgradeScript", "(", "$", "plugin", ",", "$", "log", ",", "$", "originalVersion", ")", ";", "$", "this", "->", "ApplicationContext", "->", "clearContextFiles", "(", ")", ";", "return", "array", "(", "$", "log", ",", "strpos", "(", "$", "log", ",", "'WARNING'", ")", "===", "FALSE", "?", "'success'", ":", "'warn'", ")", ";", "}" ]
Force an upgrade of the specified plugin @param string $pluginSlug The slug for the installed plugin @param string $pluginPath The path to the plugin @param Errors &$errors An errors object to update on error @return array 2 items in this array. First, the log, second is a boolean indicating success (true on successful install)
[ "Force", "an", "upgrade", "of", "the", "specified", "plugin" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/plugins/PluginInstallationService.php#L948-L991
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/plugins/PluginInstallationService.php
PluginInstallationService.uninstallPlugin
public function uninstallPlugin($pluginSlug, Errors $errors, $purge = false) { $log = ""; $plugin = $this->PluginService->getBySlug($pluginSlug); if (empty($plugin) || !$plugin->isInstalled()) { $log .= "Plugin not installed."; return array($log,'fail'); } $pluginPath = $plugin->getPath(); $log .= "Uninstalling plugin: {$pluginSlug}\n"; $plugin->Enabled = false; $plugin->Installed = false; $this->PluginService->edit($plugin); $log .= "Plugin uninstalled...\n"; $log .= "ID: {$plugin->PluginID}\n"; $log .= "Slug: {$plugin->Slug}\n"; $log .= "Title: {$plugin->Title}\n"; $log .= "Description: {$plugin->Description}\n"; $log .= "Md5: {$plugin->Md5}\n"; $log .= "\n"; if ($purge) { $this->uninstallAspects($plugin); $this->uninstallCMSNavItems($plugin); } //SUCCESS! $this->ApplicationContext->clearContextFiles(); $log .= "\nSUCCESS!\n\n"; return array($log, strpos($log, 'WARNING')=== FALSE?'success':'warn'); }
php
public function uninstallPlugin($pluginSlug, Errors $errors, $purge = false) { $log = ""; $plugin = $this->PluginService->getBySlug($pluginSlug); if (empty($plugin) || !$plugin->isInstalled()) { $log .= "Plugin not installed."; return array($log,'fail'); } $pluginPath = $plugin->getPath(); $log .= "Uninstalling plugin: {$pluginSlug}\n"; $plugin->Enabled = false; $plugin->Installed = false; $this->PluginService->edit($plugin); $log .= "Plugin uninstalled...\n"; $log .= "ID: {$plugin->PluginID}\n"; $log .= "Slug: {$plugin->Slug}\n"; $log .= "Title: {$plugin->Title}\n"; $log .= "Description: {$plugin->Description}\n"; $log .= "Md5: {$plugin->Md5}\n"; $log .= "\n"; if ($purge) { $this->uninstallAspects($plugin); $this->uninstallCMSNavItems($plugin); } //SUCCESS! $this->ApplicationContext->clearContextFiles(); $log .= "\nSUCCESS!\n\n"; return array($log, strpos($log, 'WARNING')=== FALSE?'success':'warn'); }
[ "public", "function", "uninstallPlugin", "(", "$", "pluginSlug", ",", "Errors", "$", "errors", ",", "$", "purge", "=", "false", ")", "{", "$", "log", "=", "\"\"", ";", "$", "plugin", "=", "$", "this", "->", "PluginService", "->", "getBySlug", "(", "$", "pluginSlug", ")", ";", "if", "(", "empty", "(", "$", "plugin", ")", "||", "!", "$", "plugin", "->", "isInstalled", "(", ")", ")", "{", "$", "log", ".=", "\"Plugin not installed.\"", ";", "return", "array", "(", "$", "log", ",", "'fail'", ")", ";", "}", "$", "pluginPath", "=", "$", "plugin", "->", "getPath", "(", ")", ";", "$", "log", ".=", "\"Uninstalling plugin: {$pluginSlug}\\n\"", ";", "$", "plugin", "->", "Enabled", "=", "false", ";", "$", "plugin", "->", "Installed", "=", "false", ";", "$", "this", "->", "PluginService", "->", "edit", "(", "$", "plugin", ")", ";", "$", "log", ".=", "\"Plugin uninstalled...\\n\"", ";", "$", "log", ".=", "\"ID: {$plugin->PluginID}\\n\"", ";", "$", "log", ".=", "\"Slug: {$plugin->Slug}\\n\"", ";", "$", "log", ".=", "\"Title: {$plugin->Title}\\n\"", ";", "$", "log", ".=", "\"Description: {$plugin->Description}\\n\"", ";", "$", "log", ".=", "\"Md5: {$plugin->Md5}\\n\"", ";", "$", "log", ".=", "\"\\n\"", ";", "if", "(", "$", "purge", ")", "{", "$", "this", "->", "uninstallAspects", "(", "$", "plugin", ")", ";", "$", "this", "->", "uninstallCMSNavItems", "(", "$", "plugin", ")", ";", "}", "//SUCCESS!", "$", "this", "->", "ApplicationContext", "->", "clearContextFiles", "(", ")", ";", "$", "log", ".=", "\"\\nSUCCESS!\\n\\n\"", ";", "return", "array", "(", "$", "log", ",", "strpos", "(", "$", "log", ",", "'WARNING'", ")", "===", "FALSE", "?", "'success'", ":", "'warn'", ")", ";", "}" ]
Removes the specified plugin @param string $pluginSlug The slug of the plugin to remove @param Errors $errors An errors object to update if things go wrong @param boolean $purge If true, then uninstall all elements and aspects from the plugin as well @return array 2 items in this array. First, the log, second is a boolean indicating success (true on successful install)
[ "Removes", "the", "specified", "plugin" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/plugins/PluginInstallationService.php#L1003-L1045
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/plugins/PluginInstallationService.php
PluginInstallationService.uninstallAspects
protected function uninstallAspects(Plugin $plugin) { $dto = new DTO(array('PluginID'=>$plugin->PluginID)); $aspects = $this->AspectService->findAll($dto)->getResults(); foreach ($aspects as $aspect) { $this->AspectService->delete($aspect->Slug); } }
php
protected function uninstallAspects(Plugin $plugin) { $dto = new DTO(array('PluginID'=>$plugin->PluginID)); $aspects = $this->AspectService->findAll($dto)->getResults(); foreach ($aspects as $aspect) { $this->AspectService->delete($aspect->Slug); } }
[ "protected", "function", "uninstallAspects", "(", "Plugin", "$", "plugin", ")", "{", "$", "dto", "=", "new", "DTO", "(", "array", "(", "'PluginID'", "=>", "$", "plugin", "->", "PluginID", ")", ")", ";", "$", "aspects", "=", "$", "this", "->", "AspectService", "->", "findAll", "(", "$", "dto", ")", "->", "getResults", "(", ")", ";", "foreach", "(", "$", "aspects", "as", "$", "aspect", ")", "{", "$", "this", "->", "AspectService", "->", "delete", "(", "$", "aspect", "->", "Slug", ")", ";", "}", "}" ]
Removes all aspects that were installed by this plugin @param Plugin $plugin The plugin with aspects to remove @return void
[ "Removes", "all", "aspects", "that", "were", "installed", "by", "this", "plugin" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/plugins/PluginInstallationService.php#L1054-L1063
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/plugins/PluginInstallationService.php
PluginInstallationService.uninstallCMSNavItems
protected function uninstallCMSNavItems(Plugin $plugin) { $dto = new DTO(array('PluginID' => $plugin->PluginID)); $navitems = $this->CMSNavItemService->findAll($dto)->getResults(); rsort($navitems); foreach ($navitems as $navitem) { $this->CMSNavItemService->delete($navitem->Slug); } }
php
protected function uninstallCMSNavItems(Plugin $plugin) { $dto = new DTO(array('PluginID' => $plugin->PluginID)); $navitems = $this->CMSNavItemService->findAll($dto)->getResults(); rsort($navitems); foreach ($navitems as $navitem) { $this->CMSNavItemService->delete($navitem->Slug); } }
[ "protected", "function", "uninstallCMSNavItems", "(", "Plugin", "$", "plugin", ")", "{", "$", "dto", "=", "new", "DTO", "(", "array", "(", "'PluginID'", "=>", "$", "plugin", "->", "PluginID", ")", ")", ";", "$", "navitems", "=", "$", "this", "->", "CMSNavItemService", "->", "findAll", "(", "$", "dto", ")", "->", "getResults", "(", ")", ";", "rsort", "(", "$", "navitems", ")", ";", "foreach", "(", "$", "navitems", "as", "$", "navitem", ")", "{", "$", "this", "->", "CMSNavItemService", "->", "delete", "(", "$", "navitem", "->", "Slug", ")", ";", "}", "}" ]
Removes all cms nav items that were installed by this plugin @param Plugin $plugin The plugin with cms nav items to remove @return void
[ "Removes", "all", "cms", "nav", "items", "that", "were", "installed", "by", "this", "plugin" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/plugins/PluginInstallationService.php#L1072-L1082
train
horntell/php-sdk
lib/guzzle/GuzzleHttp/Event/ListenerAttacherTrait.php
ListenerAttacherTrait.attachListeners
private function attachListeners(HasEmitterInterface $object, array $listeners) { $emitter = $object->getEmitter(); foreach ($listeners as $el) { if ($el['once']) { $emitter->once($el['name'], $el['fn'], $el['priority']); } else { $emitter->on($el['name'], $el['fn'], $el['priority']); } } }
php
private function attachListeners(HasEmitterInterface $object, array $listeners) { $emitter = $object->getEmitter(); foreach ($listeners as $el) { if ($el['once']) { $emitter->once($el['name'], $el['fn'], $el['priority']); } else { $emitter->on($el['name'], $el['fn'], $el['priority']); } } }
[ "private", "function", "attachListeners", "(", "HasEmitterInterface", "$", "object", ",", "array", "$", "listeners", ")", "{", "$", "emitter", "=", "$", "object", "->", "getEmitter", "(", ")", ";", "foreach", "(", "$", "listeners", "as", "$", "el", ")", "{", "if", "(", "$", "el", "[", "'once'", "]", ")", "{", "$", "emitter", "->", "once", "(", "$", "el", "[", "'name'", "]", ",", "$", "el", "[", "'fn'", "]", ",", "$", "el", "[", "'priority'", "]", ")", ";", "}", "else", "{", "$", "emitter", "->", "on", "(", "$", "el", "[", "'name'", "]", ",", "$", "el", "[", "'fn'", "]", ",", "$", "el", "[", "'priority'", "]", ")", ";", "}", "}", "}" ]
Attaches event listeners and properly sets their priorities and whether or not they are are only executed once. @param HasEmitterInterface $object Object that has the event emitter. @param array $listeners Array of hashes representing event event listeners. Each item contains "name", "fn", "priority", & "once".
[ "Attaches", "event", "listeners", "and", "properly", "sets", "their", "priorities", "and", "whether", "or", "not", "they", "are", "are", "only", "executed", "once", "." ]
e5205e9396a21b754d5651a8aa5898da5922a1b7
https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Event/ListenerAttacherTrait.php#L21-L31
train
horntell/php-sdk
lib/guzzle/GuzzleHttp/Event/ListenerAttacherTrait.php
ListenerAttacherTrait.buildListener
private function buildListener($name, $data, &$listeners) { static $defaults = ['priority' => 0, 'once' => false]; // If a callable is provided, normalize it to the array format. if (is_callable($data)) { $data = ['fn' => $data]; } // Prepare the listener and add it to the array, recursively. if (isset($data['fn'])) { $data['name'] = $name; $listeners[] = $data + $defaults; } elseif (is_array($data)) { foreach ($data as $listenerData) { $this->buildListener($name, $listenerData, $listeners); } } else { throw new \InvalidArgumentException('Each event listener must be a ' . 'callable or an associative array containing a "fn" key.'); } }
php
private function buildListener($name, $data, &$listeners) { static $defaults = ['priority' => 0, 'once' => false]; // If a callable is provided, normalize it to the array format. if (is_callable($data)) { $data = ['fn' => $data]; } // Prepare the listener and add it to the array, recursively. if (isset($data['fn'])) { $data['name'] = $name; $listeners[] = $data + $defaults; } elseif (is_array($data)) { foreach ($data as $listenerData) { $this->buildListener($name, $listenerData, $listeners); } } else { throw new \InvalidArgumentException('Each event listener must be a ' . 'callable or an associative array containing a "fn" key.'); } }
[ "private", "function", "buildListener", "(", "$", "name", ",", "$", "data", ",", "&", "$", "listeners", ")", "{", "static", "$", "defaults", "=", "[", "'priority'", "=>", "0", ",", "'once'", "=>", "false", "]", ";", "// If a callable is provided, normalize it to the array format.", "if", "(", "is_callable", "(", "$", "data", ")", ")", "{", "$", "data", "=", "[", "'fn'", "=>", "$", "data", "]", ";", "}", "// Prepare the listener and add it to the array, recursively.", "if", "(", "isset", "(", "$", "data", "[", "'fn'", "]", ")", ")", "{", "$", "data", "[", "'name'", "]", "=", "$", "name", ";", "$", "listeners", "[", "]", "=", "$", "data", "+", "$", "defaults", ";", "}", "elseif", "(", "is_array", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "listenerData", ")", "{", "$", "this", "->", "buildListener", "(", "$", "name", ",", "$", "listenerData", ",", "$", "listeners", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Each event listener must be a '", ".", "'callable or an associative array containing a \"fn\" key.'", ")", ";", "}", "}" ]
Creates a complete event listener definition from the provided array of listener data. Also works recursively if more than one listeners are contained in the provided array. @param string $name Name of the event the listener is for. @param array|callable $data Event listener data to prepare. @param array $listeners Array of listeners, passed by reference. @throws \InvalidArgumentException if the event data is malformed.
[ "Creates", "a", "complete", "event", "listener", "definition", "from", "the", "provided", "array", "of", "listener", "data", ".", "Also", "works", "recursively", "if", "more", "than", "one", "listeners", "are", "contained", "in", "the", "provided", "array", "." ]
e5205e9396a21b754d5651a8aa5898da5922a1b7
https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Event/ListenerAttacherTrait.php#L67-L88
train
swaros/golib
src/Types/Timer.php
Timer.validTimeStr
public function validTimeStr ( $time ) { if ($time === '0000-00-00 00:00:00') { return true; } if ($this->fitNonExistingDates && $this->isNonExistingTimeString( $time )) { $time = $this->getPossibleDateString( $time ); } return (is_string( $time ) && strlen( $time ) == 19 && $time == date( 'Y-m-d H:i:s', strtotime( $time ) )); }
php
public function validTimeStr ( $time ) { if ($time === '0000-00-00 00:00:00') { return true; } if ($this->fitNonExistingDates && $this->isNonExistingTimeString( $time )) { $time = $this->getPossibleDateString( $time ); } return (is_string( $time ) && strlen( $time ) == 19 && $time == date( 'Y-m-d H:i:s', strtotime( $time ) )); }
[ "public", "function", "validTimeStr", "(", "$", "time", ")", "{", "if", "(", "$", "time", "===", "'0000-00-00 00:00:00'", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "fitNonExistingDates", "&&", "$", "this", "->", "isNonExistingTimeString", "(", "$", "time", ")", ")", "{", "$", "time", "=", "$", "this", "->", "getPossibleDateString", "(", "$", "time", ")", ";", "}", "return", "(", "is_string", "(", "$", "time", ")", "&&", "strlen", "(", "$", "time", ")", "==", "19", "&&", "$", "time", "==", "date", "(", "'Y-m-d H:i:s'", ",", "strtotime", "(", "$", "time", ")", ")", ")", ";", "}" ]
validate an string ... only valid datestring will pass @param string $time formated for Y-m-d H:i:s @return boolan
[ "validate", "an", "string", "...", "only", "valid", "datestring", "will", "pass" ]
9e75c8fb36de7c09b01a6c1c0d27c45f02fed567
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Types/Timer.php#L132-L143
train
Eden-PHP/Block
Form/Address.php
Address.setData
public function setData($data) { if(is_array($data)) { $this->data = $data; } $args = func_get_args(); $this->data[$args[0]] = $args[1]; return $this; }
php
public function setData($data) { if(is_array($data)) { $this->data = $data; } $args = func_get_args(); $this->data[$args[0]] = $args[1]; return $this; }
[ "public", "function", "setData", "(", "$", "data", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "this", "->", "data", "=", "$", "data", ";", "}", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "this", "->", "data", "[", "$", "args", "[", "0", "]", "]", "=", "$", "args", "[", "1", "]", ";", "return", "$", "this", ";", "}" ]
Sets form data @param array|string @return Eden\Block\Form\Address
[ "Sets", "form", "data" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Form/Address.php#L335-L345
train
Eden-PHP/Block
Form/Address.php
Address.setHolders
public function setHolders($holders) { if(is_array($holders)) { $this->holders = $holders; } $args = func_get_args(); $this->holders[$args[0]] = $args[1]; return $this; }
php
public function setHolders($holders) { if(is_array($holders)) { $this->holders = $holders; } $args = func_get_args(); $this->holders[$args[0]] = $args[1]; return $this; }
[ "public", "function", "setHolders", "(", "$", "holders", ")", "{", "if", "(", "is_array", "(", "$", "holders", ")", ")", "{", "$", "this", "->", "holders", "=", "$", "holders", ";", "}", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "this", "->", "holders", "[", "$", "args", "[", "0", "]", "]", "=", "$", "args", "[", "1", "]", ";", "return", "$", "this", ";", "}" ]
Sets place holders @param string|array @return Eden\Block\Form\Address
[ "Sets", "place", "holders" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Form/Address.php#L385-L395
train
Eden-PHP/Block
Form/Address.php
Address.show
public function show(array $fields) { $this->show = array(); foreach($fields as $field) { $this->show[$field] = true; } return $this; }
php
public function show(array $fields) { $this->show = array(); foreach($fields as $field) { $this->show[$field] = true; } return $this; }
[ "public", "function", "show", "(", "array", "$", "fields", ")", "{", "$", "this", "->", "show", "=", "array", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "this", "->", "show", "[", "$", "field", "]", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Shows only the specified in the order specified @param array @return Eden\Block\Form\Address
[ "Shows", "only", "the", "specified", "in", "the", "order", "specified" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Form/Address.php#L469-L478
train
ndavison/groundwork-framework
src/Groundwork/Classes/Container.php
Container.register
public function register($alias, \Closure $closure) { if (!is_string($alias)) throw new Exception('Application::register() requires a string as the first parameter.'); $this->registered[$alias] = $closure; return true; }
php
public function register($alias, \Closure $closure) { if (!is_string($alias)) throw new Exception('Application::register() requires a string as the first parameter.'); $this->registered[$alias] = $closure; return true; }
[ "public", "function", "register", "(", "$", "alias", ",", "\\", "Closure", "$", "closure", ")", "{", "if", "(", "!", "is_string", "(", "$", "alias", ")", ")", "throw", "new", "Exception", "(", "'Application::register() requires a string as the first parameter.'", ")", ";", "$", "this", "->", "registered", "[", "$", "alias", "]", "=", "$", "closure", ";", "return", "true", ";", "}" ]
Registers a alias and Closure pair in the IoC container. @param string $alias @param \Closure $closure @return boolean
[ "Registers", "a", "alias", "and", "Closure", "pair", "in", "the", "IoC", "container", "." ]
c3d22a1410c8d8a07b4ca1f99a35a1181516cd6c
https://github.com/ndavison/groundwork-framework/blob/c3d22a1410c8d8a07b4ca1f99a35a1181516cd6c/src/Groundwork/Classes/Container.php#L33-L41
train
ndavison/groundwork-framework
src/Groundwork/Classes/Container.php
Container.get
public function get($alias) { if (!isset($this->registered[$alias])) return false; // Does an instance exist for this alias? if (isset($this->instance[$alias]) && is_object($this->instance[$alias])) return $this->instance[$alias]; // Execute the Closure to get the first instance $this->instance[$alias] = $this->registered[$alias]($this); if (!is_object($this->instance[$alias])) throw new Exception('The alias "' . $alias . '" does not return an object.'); return $this->instance[$alias]; }
php
public function get($alias) { if (!isset($this->registered[$alias])) return false; // Does an instance exist for this alias? if (isset($this->instance[$alias]) && is_object($this->instance[$alias])) return $this->instance[$alias]; // Execute the Closure to get the first instance $this->instance[$alias] = $this->registered[$alias]($this); if (!is_object($this->instance[$alias])) throw new Exception('The alias "' . $alias . '" does not return an object.'); return $this->instance[$alias]; }
[ "public", "function", "get", "(", "$", "alias", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "registered", "[", "$", "alias", "]", ")", ")", "return", "false", ";", "// Does an instance exist for this alias?", "if", "(", "isset", "(", "$", "this", "->", "instance", "[", "$", "alias", "]", ")", "&&", "is_object", "(", "$", "this", "->", "instance", "[", "$", "alias", "]", ")", ")", "return", "$", "this", "->", "instance", "[", "$", "alias", "]", ";", "// Execute the Closure to get the first instance", "$", "this", "->", "instance", "[", "$", "alias", "]", "=", "$", "this", "->", "registered", "[", "$", "alias", "]", "(", "$", "this", ")", ";", "if", "(", "!", "is_object", "(", "$", "this", "->", "instance", "[", "$", "alias", "]", ")", ")", "throw", "new", "Exception", "(", "'The alias \"'", ".", "$", "alias", ".", "'\" does not return an object.'", ")", ";", "return", "$", "this", "->", "instance", "[", "$", "alias", "]", ";", "}" ]
Returns the instance associated with the supplied alias. @param string $alias @return object|boolean
[ "Returns", "the", "instance", "associated", "with", "the", "supplied", "alias", "." ]
c3d22a1410c8d8a07b4ca1f99a35a1181516cd6c
https://github.com/ndavison/groundwork-framework/blob/c3d22a1410c8d8a07b4ca1f99a35a1181516cd6c/src/Groundwork/Classes/Container.php#L49-L64
train
ndavison/groundwork-framework
src/Groundwork/Classes/Container.php
Container.getNew
public function getNew($alias) { if (!isset($this->registered[$alias])) return false; // Execute the Closure to get the first instance $object = $this->registered[$alias]($this); if (!is_object($object)) throw new Exception('The alias "' . $alias . '" does not return an object.'); return $object; }
php
public function getNew($alias) { if (!isset($this->registered[$alias])) return false; // Execute the Closure to get the first instance $object = $this->registered[$alias]($this); if (!is_object($object)) throw new Exception('The alias "' . $alias . '" does not return an object.'); return $object; }
[ "public", "function", "getNew", "(", "$", "alias", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "registered", "[", "$", "alias", "]", ")", ")", "return", "false", ";", "// Execute the Closure to get the first instance", "$", "object", "=", "$", "this", "->", "registered", "[", "$", "alias", "]", "(", "$", "this", ")", ";", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "throw", "new", "Exception", "(", "'The alias \"'", ".", "$", "alias", ".", "'\" does not return an object.'", ")", ";", "return", "$", "object", ";", "}" ]
Returns a new instance associated with the supplies alias. @param string $alias @return object|boolean
[ "Returns", "a", "new", "instance", "associated", "with", "the", "supplies", "alias", "." ]
c3d22a1410c8d8a07b4ca1f99a35a1181516cd6c
https://github.com/ndavison/groundwork-framework/blob/c3d22a1410c8d8a07b4ca1f99a35a1181516cd6c/src/Groundwork/Classes/Container.php#L72-L83
train
ciims/ciims-modules-hybridauth
models/RemoteLinkAccountForm.php
RemoteLinkAccountForm.validateUserPassword
public function validateUserPassword($attributes, $params) { $this->_user = Users::model()->findByPk(Yii::app()->user->id); if ($this->_user == NULL) { $this->addError('password', Yii::t('HybridAuth.main', 'Unable to identify user.')); return false; } $hash = Users::model()->encryptHash($this->_user->email, $this->password, Yii::app()->params['encryptionKey']); $result = password_verify($hash, $this->_user->password); if ($result == false) { $this->addError('password', Yii::t('HybridAuth.main', 'The password you entered is invalid.')); return false; } return true; }
php
public function validateUserPassword($attributes, $params) { $this->_user = Users::model()->findByPk(Yii::app()->user->id); if ($this->_user == NULL) { $this->addError('password', Yii::t('HybridAuth.main', 'Unable to identify user.')); return false; } $hash = Users::model()->encryptHash($this->_user->email, $this->password, Yii::app()->params['encryptionKey']); $result = password_verify($hash, $this->_user->password); if ($result == false) { $this->addError('password', Yii::t('HybridAuth.main', 'The password you entered is invalid.')); return false; } return true; }
[ "public", "function", "validateUserPassword", "(", "$", "attributes", ",", "$", "params", ")", "{", "$", "this", "->", "_user", "=", "Users", "::", "model", "(", ")", "->", "findByPk", "(", "Yii", "::", "app", "(", ")", "->", "user", "->", "id", ")", ";", "if", "(", "$", "this", "->", "_user", "==", "NULL", ")", "{", "$", "this", "->", "addError", "(", "'password'", ",", "Yii", "::", "t", "(", "'HybridAuth.main'", ",", "'Unable to identify user.'", ")", ")", ";", "return", "false", ";", "}", "$", "hash", "=", "Users", "::", "model", "(", ")", "->", "encryptHash", "(", "$", "this", "->", "_user", "->", "email", ",", "$", "this", "->", "password", ",", "Yii", "::", "app", "(", ")", "->", "params", "[", "'encryptionKey'", "]", ")", ";", "$", "result", "=", "password_verify", "(", "$", "hash", ",", "$", "this", "->", "_user", "->", "password", ")", ";", "if", "(", "$", "result", "==", "false", ")", "{", "$", "this", "->", "addError", "(", "'password'", ",", "Yii", "::", "t", "(", "'HybridAuth.main'", ",", "'The password you entered is invalid.'", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Ensures that the password entered matches the one provided during registration @param array $attributes @param array $params return array
[ "Ensures", "that", "the", "password", "entered", "matches", "the", "one", "provided", "during", "registration" ]
417b2682bf3468dd509164a9b773d886359a7aec
https://github.com/ciims/ciims-modules-hybridauth/blob/417b2682bf3468dd509164a9b773d886359a7aec/models/RemoteLinkAccountForm.php#L55-L76
train
ciims/ciims-modules-hybridauth
models/RemoteLinkAccountForm.php
RemoteLinkAccountForm.save
public function save() { if (!$this->validate()) return false; $meta = new UserMetadata; $meta->attributes = array( 'user_id' => $this->_user->id, 'key' => $this->provider.'Provider', 'value' => $this->adapter->identifier ); // Save the associative object return $meta->save(); }
php
public function save() { if (!$this->validate()) return false; $meta = new UserMetadata; $meta->attributes = array( 'user_id' => $this->_user->id, 'key' => $this->provider.'Provider', 'value' => $this->adapter->identifier ); // Save the associative object return $meta->save(); }
[ "public", "function", "save", "(", ")", "{", "if", "(", "!", "$", "this", "->", "validate", "(", ")", ")", "return", "false", ";", "$", "meta", "=", "new", "UserMetadata", ";", "$", "meta", "->", "attributes", "=", "array", "(", "'user_id'", "=>", "$", "this", "->", "_user", "->", "id", ",", "'key'", "=>", "$", "this", "->", "provider", ".", "'Provider'", ",", "'value'", "=>", "$", "this", "->", "adapter", "->", "identifier", ")", ";", "// Save the associative object", "return", "$", "meta", "->", "save", "(", ")", ";", "}" ]
Bind's the user identity to the mdoel @return boolean
[ "Bind", "s", "the", "user", "identity", "to", "the", "mdoel" ]
417b2682bf3468dd509164a9b773d886359a7aec
https://github.com/ciims/ciims-modules-hybridauth/blob/417b2682bf3468dd509164a9b773d886359a7aec/models/RemoteLinkAccountForm.php#L82-L96
train
kambalabs/KmbPmProxy
src/KmbPmProxy/Hydrator/RevisionHydrator.php
RevisionHydrator.hydrate
public function hydrate($puppetModules, $revision) { if ($revision->hasGroups()) { foreach ($revision->getGroups() as $group) { $this->groupHydrator->hydrate($puppetModules, $group); } } }
php
public function hydrate($puppetModules, $revision) { if ($revision->hasGroups()) { foreach ($revision->getGroups() as $group) { $this->groupHydrator->hydrate($puppetModules, $group); } } }
[ "public", "function", "hydrate", "(", "$", "puppetModules", ",", "$", "revision", ")", "{", "if", "(", "$", "revision", "->", "hasGroups", "(", ")", ")", "{", "foreach", "(", "$", "revision", "->", "getGroups", "(", ")", "as", "$", "group", ")", "{", "$", "this", "->", "groupHydrator", "->", "hydrate", "(", "$", "puppetModules", ",", "$", "group", ")", ";", "}", "}", "}" ]
Hydrate revision with the provided puppet modules data. @param PuppetModule[] $puppetModules @param RevisionInterface $revision @return RevisionInterface
[ "Hydrate", "revision", "with", "the", "provided", "puppet", "modules", "data", "." ]
b4c664ae8b6f29e4e8768461ed99e1b0b80bde18
https://github.com/kambalabs/KmbPmProxy/blob/b4c664ae8b6f29e4e8768461ed99e1b0b80bde18/src/KmbPmProxy/Hydrator/RevisionHydrator.php#L38-L45
train
koolkode/stream
src/ChunkEncodedInputStream.php
ChunkEncodedInputStream.loadBuffer
protected function loadBuffer() { $this->buffer = ''; if($this->finished) { return; } while(!$this->stream->eof() && strlen($this->buffer) < $this->chunkSize) { $this->buffer .= $this->stream->read($this->chunkSize - strlen($this->buffer)); } if($this->buffer === '') { $this->finished = true; $this->buffer .= "0\r\n\r\n"; } else { $this->buffer = sprintf("%X\r\n%s\r\n", strlen($this->buffer), $this->buffer); } }
php
protected function loadBuffer() { $this->buffer = ''; if($this->finished) { return; } while(!$this->stream->eof() && strlen($this->buffer) < $this->chunkSize) { $this->buffer .= $this->stream->read($this->chunkSize - strlen($this->buffer)); } if($this->buffer === '') { $this->finished = true; $this->buffer .= "0\r\n\r\n"; } else { $this->buffer = sprintf("%X\r\n%s\r\n", strlen($this->buffer), $this->buffer); } }
[ "protected", "function", "loadBuffer", "(", ")", "{", "$", "this", "->", "buffer", "=", "''", ";", "if", "(", "$", "this", "->", "finished", ")", "{", "return", ";", "}", "while", "(", "!", "$", "this", "->", "stream", "->", "eof", "(", ")", "&&", "strlen", "(", "$", "this", "->", "buffer", ")", "<", "$", "this", "->", "chunkSize", ")", "{", "$", "this", "->", "buffer", ".=", "$", "this", "->", "stream", "->", "read", "(", "$", "this", "->", "chunkSize", "-", "strlen", "(", "$", "this", "->", "buffer", ")", ")", ";", "}", "if", "(", "$", "this", "->", "buffer", "===", "''", ")", "{", "$", "this", "->", "finished", "=", "true", ";", "$", "this", "->", "buffer", ".=", "\"0\\r\\n\\r\\n\"", ";", "}", "else", "{", "$", "this", "->", "buffer", "=", "sprintf", "(", "\"%X\\r\\n%s\\r\\n\"", ",", "strlen", "(", "$", "this", "->", "buffer", ")", ",", "$", "this", "->", "buffer", ")", ";", "}", "}" ]
Read data from the underlying input stream into the read buffer.
[ "Read", "data", "from", "the", "underlying", "input", "stream", "into", "the", "read", "buffer", "." ]
05e83efd76e1cb9e40a972711986b4a7e38bc141
https://github.com/koolkode/stream/blob/05e83efd76e1cb9e40a972711986b4a7e38bc141/src/ChunkEncodedInputStream.php#L159-L182
train
ezra-obiwale/dSCore
src/Core/Flash.php
Flash.getMessage
final public function getMessage($parsed = true) { return ($parsed) ? $this->parseMessages($this->messages) : $this->messages; }
php
final public function getMessage($parsed = true) { return ($parsed) ? $this->parseMessages($this->messages) : $this->messages; }
[ "final", "public", "function", "getMessage", "(", "$", "parsed", "=", "true", ")", "{", "return", "(", "$", "parsed", ")", "?", "$", "this", "->", "parseMessages", "(", "$", "this", "->", "messages", ")", ":", "$", "this", "->", "messages", ";", "}" ]
Fetches the flash message @return string
[ "Fetches", "the", "flash", "message" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Flash.php#L56-L59
train
ezra-obiwale/dSCore
src/Core/Flash.php
Flash.getSuccessMessage
final public function getSuccessMessage($parsed = true) { return ($parsed) ? $this->parseMessages($this->successMessages) : $this->successMessages; }
php
final public function getSuccessMessage($parsed = true) { return ($parsed) ? $this->parseMessages($this->successMessages) : $this->successMessages; }
[ "final", "public", "function", "getSuccessMessage", "(", "$", "parsed", "=", "true", ")", "{", "return", "(", "$", "parsed", ")", "?", "$", "this", "->", "parseMessages", "(", "$", "this", "->", "successMessages", ")", ":", "$", "this", "->", "successMessages", ";", "}" ]
Fetches the flash success message @return string
[ "Fetches", "the", "flash", "success", "message" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Flash.php#L84-L87
train
ezra-obiwale/dSCore
src/Core/Flash.php
Flash.getErrorMessage
final public function getErrorMessage($parsed = true) { return ($parsed) ? $this->parseMessages($this->errorMessages) : $this->errorMessages; }
php
final public function getErrorMessage($parsed = true) { return ($parsed) ? $this->parseMessages($this->errorMessages) : $this->errorMessages; }
[ "final", "public", "function", "getErrorMessage", "(", "$", "parsed", "=", "true", ")", "{", "return", "(", "$", "parsed", ")", "?", "$", "this", "->", "parseMessages", "(", "$", "this", "->", "errorMessages", ")", ":", "$", "this", "->", "errorMessages", ";", "}" ]
Fetches the flash error message @return string
[ "Fetches", "the", "flash", "error", "message" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Flash.php#L112-L115
train
Wedeto/HTTP
src/Responder.php
Responder.process
public function process(Request $request, Result $result) { $this->setRequest($request); $this->setResult($result); $this->respond(); }
php
public function process(Request $request, Result $result) { $this->setRequest($request); $this->setResult($result); $this->respond(); }
[ "public", "function", "process", "(", "Request", "$", "request", ",", "Result", "$", "result", ")", "{", "$", "this", "->", "setRequest", "(", "$", "request", ")", ";", "$", "this", "->", "setResult", "(", "$", "result", ")", ";", "$", "this", "->", "respond", "(", ")", ";", "}" ]
Implement the Processor interface. @param Wedeto\HTTP\Request $request The request answered @param Wedeto\HTTP\Response $response The response to the request
[ "Implement", "the", "Processor", "interface", "." ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Responder.php#L73-L78
train
Wedeto/HTTP
src/Responder.php
Responder.setResponseCode
public function setResponseCode(int $code) { if ($code < 100 || $code > 599) { $err = new \InvalidArgumentException("Attempting to set status code to $code"); self::$logger->critical("Invalid status {0}: {1}", [$code, $err]); $this->response_code = 500; } else { $this->response_code = $code; } return $this; }
php
public function setResponseCode(int $code) { if ($code < 100 || $code > 599) { $err = new \InvalidArgumentException("Attempting to set status code to $code"); self::$logger->critical("Invalid status {0}: {1}", [$code, $err]); $this->response_code = 500; } else { $this->response_code = $code; } return $this; }
[ "public", "function", "setResponseCode", "(", "int", "$", "code", ")", "{", "if", "(", "$", "code", "<", "100", "||", "$", "code", ">", "599", ")", "{", "$", "err", "=", "new", "\\", "InvalidArgumentException", "(", "\"Attempting to set status code to $code\"", ")", ";", "self", "::", "$", "logger", "->", "critical", "(", "\"Invalid status {0}: {1}\"", ",", "[", "$", "code", ",", "$", "err", "]", ")", ";", "$", "this", "->", "response_code", "=", "500", ";", "}", "else", "{", "$", "this", "->", "response_code", "=", "$", "code", ";", "}", "return", "$", "this", ";", "}" ]
Set the HTTP Response code @param int $code The HTTP response code @return Wedeto\HTTP\Responder Provides fluent interface
[ "Set", "the", "HTTP", "Response", "code" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Responder.php#L192-L205
train
Wedeto/HTTP
src/Responder.php
Responder.endAllOutputBuffers
public function endAllOutputBuffers($lvl = 0) { $ob_cnt = 0; while (ob_get_level() > $lvl) { ++$ob_cnt; $contents = ob_get_contents(); ob_end_clean(); if (self::$logger instanceof \Psr\Log\NullLogger) continue; $lines = explode("\n", $contents); foreach ($lines as $n => $line) { if (!empty($line)) self::$logger->debug("Script output: {0}/{1}: {2}", [$ob_cnt, $n + 1, $line]); } } }
php
public function endAllOutputBuffers($lvl = 0) { $ob_cnt = 0; while (ob_get_level() > $lvl) { ++$ob_cnt; $contents = ob_get_contents(); ob_end_clean(); if (self::$logger instanceof \Psr\Log\NullLogger) continue; $lines = explode("\n", $contents); foreach ($lines as $n => $line) { if (!empty($line)) self::$logger->debug("Script output: {0}/{1}: {2}", [$ob_cnt, $n + 1, $line]); } } }
[ "public", "function", "endAllOutputBuffers", "(", "$", "lvl", "=", "0", ")", "{", "$", "ob_cnt", "=", "0", ";", "while", "(", "ob_get_level", "(", ")", ">", "$", "lvl", ")", "{", "++", "$", "ob_cnt", ";", "$", "contents", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "if", "(", "self", "::", "$", "logger", "instanceof", "\\", "Psr", "\\", "Log", "\\", "NullLogger", ")", "continue", ";", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "contents", ")", ";", "foreach", "(", "$", "lines", "as", "$", "n", "=>", "$", "line", ")", "{", "if", "(", "!", "empty", "(", "$", "line", ")", ")", "self", "::", "$", "logger", "->", "debug", "(", "\"Script output: {0}/{1}: {2}\"", ",", "[", "$", "ob_cnt", ",", "$", "n", "+", "1", ",", "$", "line", "]", ")", ";", "}", "}", "}" ]
Close all active output buffers and log their contents
[ "Close", "all", "active", "output", "buffers", "and", "log", "their", "contents" ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Responder.php#L218-L237
train
Wedeto/HTTP
src/Responder.php
Responder.respond
public function respond() { // Make sure there always is a response if (null === $this->result) { $this->result = new Result; $this->result->setResponse(new Error(500, "No output produced")); } // Close and log all script output that hasn't been cleaned yet $this->endAllOutputBuffers($this->target_ob_level); // Add Content-Type mime header $response = $this->result->getResponse(); $mime = $response->getMimeTypes(); if (empty($mime)) { $mime = Request::cli() ? "text/plain" : "text/html"; } elseif (is_array($mime)) { $types = $mime; $mime = null; foreach ($types as $type) { if ($this->request->accepts($type)) { $mime = $type; break; } } } // If mime is not accepted, return a 406 response if (empty($mime) || !$this->request->accepts($mime)) { $mime = 'text/html'; $this->result->setResponse(new Error(406, "Not Acceptable", 'No acceptable response can be offered')); } // Execute hooks $hook_params = [ 'responder' => $this, 'request' => $this->request, 'mime' => $mime, ]; $hook_params = Hook::execute('Wedeto.HTTP.Responder.Respond', $hook_params); // Check if mime type was updated if (is_string($hook_params['mime'])) $mime_charset = $hook_params['mime']; $mime_charset = $mime; $tp = new FileType('', $mime); if ($tp->isPlainText()) $mime_charset .= '; charset=utf-8'; // Set mime type $this->setHeader('Content-Type', $mime_charset); // Add headers from response to the final response foreach ($this->result->getAllHeaders() as $key => $value) $this->setHeader($key, $value); // Store the response code $this->setResponseCode($response->getStatusCode()); // All preparational work is done, time to send stuff to the client $this->doOutput($mime); }
php
public function respond() { // Make sure there always is a response if (null === $this->result) { $this->result = new Result; $this->result->setResponse(new Error(500, "No output produced")); } // Close and log all script output that hasn't been cleaned yet $this->endAllOutputBuffers($this->target_ob_level); // Add Content-Type mime header $response = $this->result->getResponse(); $mime = $response->getMimeTypes(); if (empty($mime)) { $mime = Request::cli() ? "text/plain" : "text/html"; } elseif (is_array($mime)) { $types = $mime; $mime = null; foreach ($types as $type) { if ($this->request->accepts($type)) { $mime = $type; break; } } } // If mime is not accepted, return a 406 response if (empty($mime) || !$this->request->accepts($mime)) { $mime = 'text/html'; $this->result->setResponse(new Error(406, "Not Acceptable", 'No acceptable response can be offered')); } // Execute hooks $hook_params = [ 'responder' => $this, 'request' => $this->request, 'mime' => $mime, ]; $hook_params = Hook::execute('Wedeto.HTTP.Responder.Respond', $hook_params); // Check if mime type was updated if (is_string($hook_params['mime'])) $mime_charset = $hook_params['mime']; $mime_charset = $mime; $tp = new FileType('', $mime); if ($tp->isPlainText()) $mime_charset .= '; charset=utf-8'; // Set mime type $this->setHeader('Content-Type', $mime_charset); // Add headers from response to the final response foreach ($this->result->getAllHeaders() as $key => $value) $this->setHeader($key, $value); // Store the response code $this->setResponseCode($response->getStatusCode()); // All preparational work is done, time to send stuff to the client $this->doOutput($mime); }
[ "public", "function", "respond", "(", ")", "{", "// Make sure there always is a response", "if", "(", "null", "===", "$", "this", "->", "result", ")", "{", "$", "this", "->", "result", "=", "new", "Result", ";", "$", "this", "->", "result", "->", "setResponse", "(", "new", "Error", "(", "500", ",", "\"No output produced\"", ")", ")", ";", "}", "// Close and log all script output that hasn't been cleaned yet", "$", "this", "->", "endAllOutputBuffers", "(", "$", "this", "->", "target_ob_level", ")", ";", "// Add Content-Type mime header", "$", "response", "=", "$", "this", "->", "result", "->", "getResponse", "(", ")", ";", "$", "mime", "=", "$", "response", "->", "getMimeTypes", "(", ")", ";", "if", "(", "empty", "(", "$", "mime", ")", ")", "{", "$", "mime", "=", "Request", "::", "cli", "(", ")", "?", "\"text/plain\"", ":", "\"text/html\"", ";", "}", "elseif", "(", "is_array", "(", "$", "mime", ")", ")", "{", "$", "types", "=", "$", "mime", ";", "$", "mime", "=", "null", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "if", "(", "$", "this", "->", "request", "->", "accepts", "(", "$", "type", ")", ")", "{", "$", "mime", "=", "$", "type", ";", "break", ";", "}", "}", "}", "// If mime is not accepted, return a 406 response", "if", "(", "empty", "(", "$", "mime", ")", "||", "!", "$", "this", "->", "request", "->", "accepts", "(", "$", "mime", ")", ")", "{", "$", "mime", "=", "'text/html'", ";", "$", "this", "->", "result", "->", "setResponse", "(", "new", "Error", "(", "406", ",", "\"Not Acceptable\"", ",", "'No acceptable response can be offered'", ")", ")", ";", "}", "// Execute hooks", "$", "hook_params", "=", "[", "'responder'", "=>", "$", "this", ",", "'request'", "=>", "$", "this", "->", "request", ",", "'mime'", "=>", "$", "mime", ",", "]", ";", "$", "hook_params", "=", "Hook", "::", "execute", "(", "'Wedeto.HTTP.Responder.Respond'", ",", "$", "hook_params", ")", ";", "// Check if mime type was updated", "if", "(", "is_string", "(", "$", "hook_params", "[", "'mime'", "]", ")", ")", "$", "mime_charset", "=", "$", "hook_params", "[", "'mime'", "]", ";", "$", "mime_charset", "=", "$", "mime", ";", "$", "tp", "=", "new", "FileType", "(", "''", ",", "$", "mime", ")", ";", "if", "(", "$", "tp", "->", "isPlainText", "(", ")", ")", "$", "mime_charset", ".=", "'; charset=utf-8'", ";", "// Set mime type", "$", "this", "->", "setHeader", "(", "'Content-Type'", ",", "$", "mime_charset", ")", ";", "// Add headers from response to the final response", "foreach", "(", "$", "this", "->", "result", "->", "getAllHeaders", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "$", "this", "->", "setHeader", "(", "$", "key", ",", "$", "value", ")", ";", "// Store the response code", "$", "this", "->", "setResponseCode", "(", "$", "response", "->", "getStatusCode", "(", ")", ")", ";", "// All preparational work is done, time to send stuff to the client", "$", "this", "->", "doOutput", "(", "$", "mime", ")", ";", "}" ]
Prepare the output before sending it, run hooks, collect headers and finally call doRespond which produces the output.
[ "Prepare", "the", "output", "before", "sending", "it", "run", "hooks", "collect", "headers", "and", "finally", "call", "doRespond", "which", "produces", "the", "output", "." ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Responder.php#L243-L313
train
Wedeto/HTTP
src/Responder.php
Responder.doOutput
protected function doOutput(string $mime) { // Set HTTP response code http_response_code($this->response_code); // Set headers if (!headers_sent()) { foreach ($this->headers as $name => $value) header($name . ': ' . $value); // Set cookies foreach ($this->cookies as $cookie) { setcookie( $cookie->getName(), $cookie->getValue(), $cookie->getExpires(), $cookie->getPath(), $cookie->getDomain(), $cookie->getSecure(), $cookie->getHTTPOnly() ); } } else self::$logger->critical('Headers were already sent when Responder wants to send them'); // Perform output $this->result->getResponse()->output($mime); // We're done $desc = StatusCode::description($this->response_code); self::$logger->info("[{0} {1}] {2}", [$this->response_code, $desc, $this->request->url]); }
php
protected function doOutput(string $mime) { // Set HTTP response code http_response_code($this->response_code); // Set headers if (!headers_sent()) { foreach ($this->headers as $name => $value) header($name . ': ' . $value); // Set cookies foreach ($this->cookies as $cookie) { setcookie( $cookie->getName(), $cookie->getValue(), $cookie->getExpires(), $cookie->getPath(), $cookie->getDomain(), $cookie->getSecure(), $cookie->getHTTPOnly() ); } } else self::$logger->critical('Headers were already sent when Responder wants to send them'); // Perform output $this->result->getResponse()->output($mime); // We're done $desc = StatusCode::description($this->response_code); self::$logger->info("[{0} {1}] {2}", [$this->response_code, $desc, $this->request->url]); }
[ "protected", "function", "doOutput", "(", "string", "$", "mime", ")", "{", "// Set HTTP response code", "http_response_code", "(", "$", "this", "->", "response_code", ")", ";", "// Set headers", "if", "(", "!", "headers_sent", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "headers", "as", "$", "name", "=>", "$", "value", ")", "header", "(", "$", "name", ".", "': '", ".", "$", "value", ")", ";", "// Set cookies", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "cookie", ")", "{", "setcookie", "(", "$", "cookie", "->", "getName", "(", ")", ",", "$", "cookie", "->", "getValue", "(", ")", ",", "$", "cookie", "->", "getExpires", "(", ")", ",", "$", "cookie", "->", "getPath", "(", ")", ",", "$", "cookie", "->", "getDomain", "(", ")", ",", "$", "cookie", "->", "getSecure", "(", ")", ",", "$", "cookie", "->", "getHTTPOnly", "(", ")", ")", ";", "}", "}", "else", "self", "::", "$", "logger", "->", "critical", "(", "'Headers were already sent when Responder wants to send them'", ")", ";", "// Perform output", "$", "this", "->", "result", "->", "getResponse", "(", ")", "->", "output", "(", "$", "mime", ")", ";", "// We're done", "$", "desc", "=", "StatusCode", "::", "description", "(", "$", "this", "->", "response_code", ")", ";", "self", "::", "$", "logger", "->", "info", "(", "\"[{0} {1}] {2}\"", ",", "[", "$", "this", "->", "response_code", ",", "$", "desc", ",", "$", "this", "->", "request", "->", "url", "]", ")", ";", "}" ]
This method sends data to the client after all preparational work has been done. @param string $mime The mime-type of the response that has been selected
[ "This", "method", "sends", "data", "to", "the", "client", "after", "all", "preparational", "work", "has", "been", "done", "." ]
7318eff1b81a3c103c4263466d09b7f3593b70b9
https://github.com/Wedeto/HTTP/blob/7318eff1b81a3c103c4263466d09b7f3593b70b9/src/Responder.php#L322-L356
train
Formula9/Core
src/Silex/Application/FormTrait.php
FormTrait.namedForm
public function namedForm($name, $data = null, array $options = array(), $type = null) { return $this['form.factory']->createNamedBuilder($name, $type ?: FormType::class, $data, $options); }
php
public function namedForm($name, $data = null, array $options = array(), $type = null) { return $this['form.factory']->createNamedBuilder($name, $type ?: FormType::class, $data, $options); }
[ "public", "function", "namedForm", "(", "$", "name", ",", "$", "data", "=", "null", ",", "array", "$", "options", "=", "array", "(", ")", ",", "$", "type", "=", "null", ")", "{", "return", "$", "this", "[", "'form.factory'", "]", "->", "createNamedBuilder", "(", "$", "name", ",", "$", "type", "?", ":", "FormType", "::", "class", ",", "$", "data", ",", "$", "options", ")", ";", "}" ]
Creates and returns a named form builder instance. @param string $name @param mixed $data The initial data for the form @param array $options Options for the form @param string|FormTypeInterface $type Type of the form @return FormBuilder
[ "Creates", "and", "returns", "a", "named", "form", "builder", "instance", "." ]
7786e873bceaa32a6ac36b10c959628739218011
https://github.com/Formula9/Core/blob/7786e873bceaa32a6ac36b10c959628739218011/src/Silex/Application/FormTrait.php#L51-L54
train
nanbando/mysql
src/MysqlPlugin.php
MysqlPlugin.getExportCommand
private function getExportCommand(array $parameter, $file, $hidePassword = false) { $username = $parameter['username']; $password = $parameter['password']; $database = $parameter['database']; $host = $parameter['host']; $port = $parameter['port']; return sprintf( 'mysqldump -u%s%s%s%s %s > %s', $username, isset($password) ? (' -p' . ($hidePassword ? '***' : "'" . addcslashes($password, "'") . "'")) : '', isset($host) ? (' -h ' . $host) : '', isset($port) ? (' -P ' . $port) : '', $database, $file ); }
php
private function getExportCommand(array $parameter, $file, $hidePassword = false) { $username = $parameter['username']; $password = $parameter['password']; $database = $parameter['database']; $host = $parameter['host']; $port = $parameter['port']; return sprintf( 'mysqldump -u%s%s%s%s %s > %s', $username, isset($password) ? (' -p' . ($hidePassword ? '***' : "'" . addcslashes($password, "'") . "'")) : '', isset($host) ? (' -h ' . $host) : '', isset($port) ? (' -P ' . $port) : '', $database, $file ); }
[ "private", "function", "getExportCommand", "(", "array", "$", "parameter", ",", "$", "file", ",", "$", "hidePassword", "=", "false", ")", "{", "$", "username", "=", "$", "parameter", "[", "'username'", "]", ";", "$", "password", "=", "$", "parameter", "[", "'password'", "]", ";", "$", "database", "=", "$", "parameter", "[", "'database'", "]", ";", "$", "host", "=", "$", "parameter", "[", "'host'", "]", ";", "$", "port", "=", "$", "parameter", "[", "'port'", "]", ";", "return", "sprintf", "(", "'mysqldump -u%s%s%s%s %s > %s'", ",", "$", "username", ",", "isset", "(", "$", "password", ")", "?", "(", "' -p'", ".", "(", "$", "hidePassword", "?", "'***'", ":", "\"'\"", ".", "addcslashes", "(", "$", "password", ",", "\"'\"", ")", ".", "\"'\"", ")", ")", ":", "''", ",", "isset", "(", "$", "host", ")", "?", "(", "' -h '", ".", "$", "host", ")", ":", "''", ",", "isset", "(", "$", "port", ")", "?", "(", "' -P '", ".", "$", "port", ")", ":", "''", ",", "$", "database", ",", "$", "file", ")", ";", "}" ]
Returns command to export database. @param array $parameter @param string $file @param bool $hidePassword @return string
[ "Returns", "command", "to", "export", "database", "." ]
d4cfb2b60c180ac77ae42fcb30b7e7f3452ba1bd
https://github.com/nanbando/mysql/blob/d4cfb2b60c180ac77ae42fcb30b7e7f3452ba1bd/src/MysqlPlugin.php#L102-L119
train
nanbando/mysql
src/MysqlPlugin.php
MysqlPlugin.getImportCommand
private function getImportCommand(array $parameter, $file, $hidePassword = false) { $username = $parameter['username']; $password = $parameter['password']; $database = $parameter['database']; $host = $parameter['host']; $port = $parameter['port']; return sprintf( 'mysql -u%s%s%s%s %s < %s', $username, isset($password) ? (' -p' . ($hidePassword ? '***' : $password)) : '', isset($host) ? (' -h ' . $host) : '', isset($port) ? (' -P ' . $port) : '', $database, $file ); }
php
private function getImportCommand(array $parameter, $file, $hidePassword = false) { $username = $parameter['username']; $password = $parameter['password']; $database = $parameter['database']; $host = $parameter['host']; $port = $parameter['port']; return sprintf( 'mysql -u%s%s%s%s %s < %s', $username, isset($password) ? (' -p' . ($hidePassword ? '***' : $password)) : '', isset($host) ? (' -h ' . $host) : '', isset($port) ? (' -P ' . $port) : '', $database, $file ); }
[ "private", "function", "getImportCommand", "(", "array", "$", "parameter", ",", "$", "file", ",", "$", "hidePassword", "=", "false", ")", "{", "$", "username", "=", "$", "parameter", "[", "'username'", "]", ";", "$", "password", "=", "$", "parameter", "[", "'password'", "]", ";", "$", "database", "=", "$", "parameter", "[", "'database'", "]", ";", "$", "host", "=", "$", "parameter", "[", "'host'", "]", ";", "$", "port", "=", "$", "parameter", "[", "'port'", "]", ";", "return", "sprintf", "(", "'mysql -u%s%s%s%s %s < %s'", ",", "$", "username", ",", "isset", "(", "$", "password", ")", "?", "(", "' -p'", ".", "(", "$", "hidePassword", "?", "'***'", ":", "$", "password", ")", ")", ":", "''", ",", "isset", "(", "$", "host", ")", "?", "(", "' -h '", ".", "$", "host", ")", ":", "''", ",", "isset", "(", "$", "port", ")", "?", "(", "' -P '", ".", "$", "port", ")", ":", "''", ",", "$", "database", ",", "$", "file", ")", ";", "}" ]
Returns command to import database. @param array $parameter @param string $file @param bool $hidePassword @return string
[ "Returns", "command", "to", "import", "database", "." ]
d4cfb2b60c180ac77ae42fcb30b7e7f3452ba1bd
https://github.com/nanbando/mysql/blob/d4cfb2b60c180ac77ae42fcb30b7e7f3452ba1bd/src/MysqlPlugin.php#L130-L147
train
MichaelJ2324/PHP-REST-Client
src/Endpoint/Data/AbstractEndpointData.php
AbstractEndpointData.setProperties
public function setProperties(array $properties) { if (!isset($properties[self::DATA_PROPERTY_REQUIRED])){ $properties[self::DATA_PROPERTY_REQUIRED] = array(); } if (!isset($properties[self::DATA_PROPERTY_DEFAULTS])){ $properties[self::DATA_PROPERTY_DEFAULTS] = array(); } $this->properties = $properties; return $this; }
php
public function setProperties(array $properties) { if (!isset($properties[self::DATA_PROPERTY_REQUIRED])){ $properties[self::DATA_PROPERTY_REQUIRED] = array(); } if (!isset($properties[self::DATA_PROPERTY_DEFAULTS])){ $properties[self::DATA_PROPERTY_DEFAULTS] = array(); } $this->properties = $properties; return $this; }
[ "public", "function", "setProperties", "(", "array", "$", "properties", ")", "{", "if", "(", "!", "isset", "(", "$", "properties", "[", "self", "::", "DATA_PROPERTY_REQUIRED", "]", ")", ")", "{", "$", "properties", "[", "self", "::", "DATA_PROPERTY_REQUIRED", "]", "=", "array", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "properties", "[", "self", "::", "DATA_PROPERTY_DEFAULTS", "]", ")", ")", "{", "$", "properties", "[", "self", "::", "DATA_PROPERTY_DEFAULTS", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "properties", "=", "$", "properties", ";", "return", "$", "this", ";", "}" ]
Set properties for data @param array $properties @return $this
[ "Set", "properties", "for", "data" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Endpoint/Data/AbstractEndpointData.php#L148-L157
train
MichaelJ2324/PHP-REST-Client
src/Endpoint/Data/AbstractEndpointData.php
AbstractEndpointData.configureDefaultData
protected function configureDefaultData(){ if (isset($this->properties['defaults']) && is_array($this->properties['defaults'])){ foreach($this->properties['defaults'] as $data => $value){ if (!isset($this->data[$data])){ $this->data[$data] = $value; } } } return $this; }
php
protected function configureDefaultData(){ if (isset($this->properties['defaults']) && is_array($this->properties['defaults'])){ foreach($this->properties['defaults'] as $data => $value){ if (!isset($this->data[$data])){ $this->data[$data] = $value; } } } return $this; }
[ "protected", "function", "configureDefaultData", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "properties", "[", "'defaults'", "]", ")", "&&", "is_array", "(", "$", "this", "->", "properties", "[", "'defaults'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "properties", "[", "'defaults'", "]", "as", "$", "data", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "$", "data", "]", ")", ")", "{", "$", "this", "->", "data", "[", "$", "data", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Configures Data with defaults based on properties array @return $this
[ "Configures", "Data", "with", "defaults", "based", "on", "properties", "array" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Endpoint/Data/AbstractEndpointData.php#L192-L201
train
MichaelJ2324/PHP-REST-Client
src/Endpoint/Data/AbstractEndpointData.php
AbstractEndpointData.verifyRequiredData
protected function verifyRequiredData() { $errors = array( 'missing' => array(), 'invalid' => array() ); $error = FALSE; if (!empty($this->properties['required'])) { foreach ($this->properties['required'] as $property => $type) { if (!isset($this->data[$property])) { $errors['missing'][] = $property; $error = TRUE; continue; } if ($type !== NULL && gettype($this->data[$property]) !== $type) { $errors['invalid'][] = $property; $error = TRUE; } } } if ($error){ $errorMsg = ''; if (!empty($errors['missing'])){ $errorMsg .= "Missing [".implode(",",$errors['missing']). "] "; } if (!empty($errors['invalid'])){ $errorMsg .= "Invalid [".implode(",",$errors['invalid'])."]"; } throw new InvalidData($errorMsg); } return $error; }
php
protected function verifyRequiredData() { $errors = array( 'missing' => array(), 'invalid' => array() ); $error = FALSE; if (!empty($this->properties['required'])) { foreach ($this->properties['required'] as $property => $type) { if (!isset($this->data[$property])) { $errors['missing'][] = $property; $error = TRUE; continue; } if ($type !== NULL && gettype($this->data[$property]) !== $type) { $errors['invalid'][] = $property; $error = TRUE; } } } if ($error){ $errorMsg = ''; if (!empty($errors['missing'])){ $errorMsg .= "Missing [".implode(",",$errors['missing']). "] "; } if (!empty($errors['invalid'])){ $errorMsg .= "Invalid [".implode(",",$errors['invalid'])."]"; } throw new InvalidData($errorMsg); } return $error; }
[ "protected", "function", "verifyRequiredData", "(", ")", "{", "$", "errors", "=", "array", "(", "'missing'", "=>", "array", "(", ")", ",", "'invalid'", "=>", "array", "(", ")", ")", ";", "$", "error", "=", "FALSE", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "properties", "[", "'required'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "properties", "[", "'required'", "]", "as", "$", "property", "=>", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "$", "property", "]", ")", ")", "{", "$", "errors", "[", "'missing'", "]", "[", "]", "=", "$", "property", ";", "$", "error", "=", "TRUE", ";", "continue", ";", "}", "if", "(", "$", "type", "!==", "NULL", "&&", "gettype", "(", "$", "this", "->", "data", "[", "$", "property", "]", ")", "!==", "$", "type", ")", "{", "$", "errors", "[", "'invalid'", "]", "[", "]", "=", "$", "property", ";", "$", "error", "=", "TRUE", ";", "}", "}", "}", "if", "(", "$", "error", ")", "{", "$", "errorMsg", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "errors", "[", "'missing'", "]", ")", ")", "{", "$", "errorMsg", ".=", "\"Missing [\"", ".", "implode", "(", "\",\"", ",", "$", "errors", "[", "'missing'", "]", ")", ".", "\"] \"", ";", "}", "if", "(", "!", "empty", "(", "$", "errors", "[", "'invalid'", "]", ")", ")", "{", "$", "errorMsg", ".=", "\"Invalid [\"", ".", "implode", "(", "\",\"", ",", "$", "errors", "[", "'invalid'", "]", ")", ".", "\"]\"", ";", "}", "throw", "new", "InvalidData", "(", "$", "errorMsg", ")", ";", "}", "return", "$", "error", ";", "}" ]
Validate Required Data for the Endpoint @return bool @throws InvalidData
[ "Validate", "Required", "Data", "for", "the", "Endpoint" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Endpoint/Data/AbstractEndpointData.php#L208-L239
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/elements/ElementDAO.php
ElementDAO.preCacheTranslateObject
public function preCacheTranslateObject(ModelObject $obj) { // merge aspects //$db = $this->getConnection(); // $q = new Query(); // $q->select('aspectid'); // $q->from('elementaspectrel'); // $q->where("elementid = {$db->quote($obj->{$obj->getPrimaryKey()})}"); // $aspectIDs = $db->readCol($q); // $this->populateRels(); // $aspectSlugs = array_key_exists($obj->Slug, $this->aspectrel)?$this->aspectrel[$obj->Slug]['Aspects']:array(); $aspectSlugs = $obj->getAspectSlugs(); $schema = new NodeSchema(); if (!empty($aspectSlugs)) { $aspects = $this->AspectDAO->multiGetBySlug($aspectSlugs); $newAspects = array(); foreach ($aspects as $aspect) { // $plugin = $this->PluginService->getByID($aspect['PluginID']); // if(empty($plugin) || !$plugin->isInstalled() || !$plugin->isEnabled()) // continue; $aspectSchema = $aspect->getSchema(); foreach ($aspectSchema->getTagDefs() as $tagDef) $schema->addTagDef($tagDef); foreach ($aspectSchema->getMetaDefs() as $metaDef) $schema->addMetaDef($metaDef); $newAspects[] = $aspect; } $obj->setAspects($newAspects); } $obj->setSchema($schema); $obj->setAnchoredSite($this->SiteService->getAnchoredSite()); $obj->setAnchoredSiteSlug($obj->getAnchoredSite()->getSlug()); return $obj; }
php
public function preCacheTranslateObject(ModelObject $obj) { // merge aspects //$db = $this->getConnection(); // $q = new Query(); // $q->select('aspectid'); // $q->from('elementaspectrel'); // $q->where("elementid = {$db->quote($obj->{$obj->getPrimaryKey()})}"); // $aspectIDs = $db->readCol($q); // $this->populateRels(); // $aspectSlugs = array_key_exists($obj->Slug, $this->aspectrel)?$this->aspectrel[$obj->Slug]['Aspects']:array(); $aspectSlugs = $obj->getAspectSlugs(); $schema = new NodeSchema(); if (!empty($aspectSlugs)) { $aspects = $this->AspectDAO->multiGetBySlug($aspectSlugs); $newAspects = array(); foreach ($aspects as $aspect) { // $plugin = $this->PluginService->getByID($aspect['PluginID']); // if(empty($plugin) || !$plugin->isInstalled() || !$plugin->isEnabled()) // continue; $aspectSchema = $aspect->getSchema(); foreach ($aspectSchema->getTagDefs() as $tagDef) $schema->addTagDef($tagDef); foreach ($aspectSchema->getMetaDefs() as $metaDef) $schema->addMetaDef($metaDef); $newAspects[] = $aspect; } $obj->setAspects($newAspects); } $obj->setSchema($schema); $obj->setAnchoredSite($this->SiteService->getAnchoredSite()); $obj->setAnchoredSiteSlug($obj->getAnchoredSite()->getSlug()); return $obj; }
[ "public", "function", "preCacheTranslateObject", "(", "ModelObject", "$", "obj", ")", "{", "// merge aspects", "//$db = $this->getConnection();", "// $q = new Query();", "// $q->select('aspectid');", "// $q->from('elementaspectrel');", "// $q->where(\"elementid = {$db->quote($obj->{$obj->getPrimaryKey()})}\");", "// $aspectIDs = $db->readCol($q);", "// $this->populateRels();", "// $aspectSlugs = array_key_exists($obj->Slug, $this->aspectrel)?$this->aspectrel[$obj->Slug]['Aspects']:array();", "$", "aspectSlugs", "=", "$", "obj", "->", "getAspectSlugs", "(", ")", ";", "$", "schema", "=", "new", "NodeSchema", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "aspectSlugs", ")", ")", "{", "$", "aspects", "=", "$", "this", "->", "AspectDAO", "->", "multiGetBySlug", "(", "$", "aspectSlugs", ")", ";", "$", "newAspects", "=", "array", "(", ")", ";", "foreach", "(", "$", "aspects", "as", "$", "aspect", ")", "{", "// $plugin = $this->PluginService->getByID($aspect['PluginID']);", "// if(empty($plugin) || !$plugin->isInstalled() || !$plugin->isEnabled())", "// continue;", "$", "aspectSchema", "=", "$", "aspect", "->", "getSchema", "(", ")", ";", "foreach", "(", "$", "aspectSchema", "->", "getTagDefs", "(", ")", "as", "$", "tagDef", ")", "$", "schema", "->", "addTagDef", "(", "$", "tagDef", ")", ";", "foreach", "(", "$", "aspectSchema", "->", "getMetaDefs", "(", ")", "as", "$", "metaDef", ")", "$", "schema", "->", "addMetaDef", "(", "$", "metaDef", ")", ";", "$", "newAspects", "[", "]", "=", "$", "aspect", ";", "}", "$", "obj", "->", "setAspects", "(", "$", "newAspects", ")", ";", "}", "$", "obj", "->", "setSchema", "(", "$", "schema", ")", ";", "$", "obj", "->", "setAnchoredSite", "(", "$", "this", "->", "SiteService", "->", "getAnchoredSite", "(", ")", ")", ";", "$", "obj", "->", "setAnchoredSiteSlug", "(", "$", "obj", "->", "getAnchoredSite", "(", ")", "->", "getSlug", "(", ")", ")", ";", "return", "$", "obj", ";", "}" ]
Sets the schema for the element @param Element $obj The element to analyze @return Element the translated element
[ "Sets", "the", "schema", "for", "the", "element" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/elements/ElementDAO.php#L57-L106
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/elements/ElementDAO.php
ElementDAO.findAll
public function findAll(DTO $dto) { if($dto->hasParameter($this->getModel()->getPrimaryKey()) || $dto->hasParameter('Slug') || $dto->hasParameter('PluginID') // || $dto->hasParameter('DefaultOrder') // || $dto->hasParameter('StartDate') // || $dto->hasParameter('EndDate') // || $dto->hasParameter('Search') || $dto->getLimit() != null || $dto->getOffset() != null || $dto->getOrderBys() != null ) { $sd = __CLASS__.(string)serialize($dto); $slugs = $this->SystemCache->get($sd); if ($slugs === false) { // find slugs $this->loadSource(); $slugs = array(); $sort_array = array(); $dir = 'ASC'; $orderbys = $dto->getOrderBys(); if(!empty($orderbys)) foreach($orderbys as $col => $dir) {} else $col = 'Slug'; foreach($this->objectsBySlug as $slug => $obj) { if(($val = $dto->getParameter('Slug')) != null) { if($obj->Slug != $val) continue; } if(($val = $dto->getParameter('PluginID')) != null) { if($obj->PluginID != $val) continue; } $slugs[] = $slug; $sort_array[] = $obj[$col]; } array_multisort($sort_array, strtolower($dir)=='asc'?SORT_ASC:SORT_DESC, SORT_REGULAR, $slugs); $this->SystemCache->put($sd, $slugs, 0); } } else { $this->populateRels(); if(!empty($this->aspectrel)) { foreach($this->aspectrel as $elementSlug => $element) { if ($dto->hasParameter('IncludesAspect')) { $aspect = strtolower($dto->getParameter('IncludesAspect')); if(!in_array($aspect, (array)$element['Aspects'])) continue; } $slugs[] = $elementSlug; } } } $results = array(); if(!empty($slugs)) { // retrieve objects $rows = $this->multiGetBySlug($slugs); foreach ($slugs as $slug) $results[] = $rows[$slug]; } $dto->setResults($results); return $dto; }
php
public function findAll(DTO $dto) { if($dto->hasParameter($this->getModel()->getPrimaryKey()) || $dto->hasParameter('Slug') || $dto->hasParameter('PluginID') // || $dto->hasParameter('DefaultOrder') // || $dto->hasParameter('StartDate') // || $dto->hasParameter('EndDate') // || $dto->hasParameter('Search') || $dto->getLimit() != null || $dto->getOffset() != null || $dto->getOrderBys() != null ) { $sd = __CLASS__.(string)serialize($dto); $slugs = $this->SystemCache->get($sd); if ($slugs === false) { // find slugs $this->loadSource(); $slugs = array(); $sort_array = array(); $dir = 'ASC'; $orderbys = $dto->getOrderBys(); if(!empty($orderbys)) foreach($orderbys as $col => $dir) {} else $col = 'Slug'; foreach($this->objectsBySlug as $slug => $obj) { if(($val = $dto->getParameter('Slug')) != null) { if($obj->Slug != $val) continue; } if(($val = $dto->getParameter('PluginID')) != null) { if($obj->PluginID != $val) continue; } $slugs[] = $slug; $sort_array[] = $obj[$col]; } array_multisort($sort_array, strtolower($dir)=='asc'?SORT_ASC:SORT_DESC, SORT_REGULAR, $slugs); $this->SystemCache->put($sd, $slugs, 0); } } else { $this->populateRels(); if(!empty($this->aspectrel)) { foreach($this->aspectrel as $elementSlug => $element) { if ($dto->hasParameter('IncludesAspect')) { $aspect = strtolower($dto->getParameter('IncludesAspect')); if(!in_array($aspect, (array)$element['Aspects'])) continue; } $slugs[] = $elementSlug; } } } $results = array(); if(!empty($slugs)) { // retrieve objects $rows = $this->multiGetBySlug($slugs); foreach ($slugs as $slug) $results[] = $rows[$slug]; } $dto->setResults($results); return $dto; }
[ "public", "function", "findAll", "(", "DTO", "$", "dto", ")", "{", "if", "(", "$", "dto", "->", "hasParameter", "(", "$", "this", "->", "getModel", "(", ")", "->", "getPrimaryKey", "(", ")", ")", "||", "$", "dto", "->", "hasParameter", "(", "'Slug'", ")", "||", "$", "dto", "->", "hasParameter", "(", "'PluginID'", ")", "// || $dto->hasParameter('DefaultOrder')", "// || $dto->hasParameter('StartDate')", "// || $dto->hasParameter('EndDate')", "// || $dto->hasParameter('Search')", "||", "$", "dto", "->", "getLimit", "(", ")", "!=", "null", "||", "$", "dto", "->", "getOffset", "(", ")", "!=", "null", "||", "$", "dto", "->", "getOrderBys", "(", ")", "!=", "null", ")", "{", "$", "sd", "=", "__CLASS__", ".", "(", "string", ")", "serialize", "(", "$", "dto", ")", ";", "$", "slugs", "=", "$", "this", "->", "SystemCache", "->", "get", "(", "$", "sd", ")", ";", "if", "(", "$", "slugs", "===", "false", ")", "{", "// find slugs", "$", "this", "->", "loadSource", "(", ")", ";", "$", "slugs", "=", "array", "(", ")", ";", "$", "sort_array", "=", "array", "(", ")", ";", "$", "dir", "=", "'ASC'", ";", "$", "orderbys", "=", "$", "dto", "->", "getOrderBys", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "orderbys", ")", ")", "foreach", "(", "$", "orderbys", "as", "$", "col", "=>", "$", "dir", ")", "{", "}", "else", "$", "col", "=", "'Slug'", ";", "foreach", "(", "$", "this", "->", "objectsBySlug", "as", "$", "slug", "=>", "$", "obj", ")", "{", "if", "(", "(", "$", "val", "=", "$", "dto", "->", "getParameter", "(", "'Slug'", ")", ")", "!=", "null", ")", "{", "if", "(", "$", "obj", "->", "Slug", "!=", "$", "val", ")", "continue", ";", "}", "if", "(", "(", "$", "val", "=", "$", "dto", "->", "getParameter", "(", "'PluginID'", ")", ")", "!=", "null", ")", "{", "if", "(", "$", "obj", "->", "PluginID", "!=", "$", "val", ")", "continue", ";", "}", "$", "slugs", "[", "]", "=", "$", "slug", ";", "$", "sort_array", "[", "]", "=", "$", "obj", "[", "$", "col", "]", ";", "}", "array_multisort", "(", "$", "sort_array", ",", "strtolower", "(", "$", "dir", ")", "==", "'asc'", "?", "SORT_ASC", ":", "SORT_DESC", ",", "SORT_REGULAR", ",", "$", "slugs", ")", ";", "$", "this", "->", "SystemCache", "->", "put", "(", "$", "sd", ",", "$", "slugs", ",", "0", ")", ";", "}", "}", "else", "{", "$", "this", "->", "populateRels", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "aspectrel", ")", ")", "{", "foreach", "(", "$", "this", "->", "aspectrel", "as", "$", "elementSlug", "=>", "$", "element", ")", "{", "if", "(", "$", "dto", "->", "hasParameter", "(", "'IncludesAspect'", ")", ")", "{", "$", "aspect", "=", "strtolower", "(", "$", "dto", "->", "getParameter", "(", "'IncludesAspect'", ")", ")", ";", "if", "(", "!", "in_array", "(", "$", "aspect", ",", "(", "array", ")", "$", "element", "[", "'Aspects'", "]", ")", ")", "continue", ";", "}", "$", "slugs", "[", "]", "=", "$", "elementSlug", ";", "}", "}", "}", "$", "results", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "slugs", ")", ")", "{", "// retrieve objects", "$", "rows", "=", "$", "this", "->", "multiGetBySlug", "(", "$", "slugs", ")", ";", "foreach", "(", "$", "slugs", "as", "$", "slug", ")", "$", "results", "[", "]", "=", "$", "rows", "[", "$", "slug", "]", ";", "}", "$", "dto", "->", "setResults", "(", "$", "results", ")", ";", "return", "$", "dto", ";", "}" ]
Finds matching elements @param DTO $dto A DTO that can accept the following params: <PrimaryKey> Slug PluginID Anchored DefaultOrder AnchoredSiteID StartDate string ModifiedDate is after this EndDate string ModifiedDate is before this Search string Matches any part of name, slug, or description IncludesAllAspects string A list of aspects that results must be related to IncludesAspects string A list of aspects that results must relate to at least one of @return DTO The filled DTO object
[ "Finds", "matching", "elements" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/elements/ElementDAO.php#L126-L222
train
linpax/microphp-framework
src/web/Ftp.php
Ftp.cd
public function cd($directory = null) { if (\ftp_chdir($this->_stream, $directory)) { return true; } $this->error = "Failed to change directory to \"{$directory}\""; return false; }
php
public function cd($directory = null) { if (\ftp_chdir($this->_stream, $directory)) { return true; } $this->error = "Failed to change directory to \"{$directory}\""; return false; }
[ "public", "function", "cd", "(", "$", "directory", "=", "null", ")", "{", "if", "(", "\\", "ftp_chdir", "(", "$", "this", "->", "_stream", ",", "$", "directory", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "error", "=", "\"Failed to change directory to \\\"{$directory}\\\"\"", ";", "return", "false", ";", "}" ]
Change current directory on FTP server @param string $directory @return bool
[ "Change", "current", "directory", "on", "FTP", "server" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/web/Ftp.php#L128-L137
train
linpax/microphp-framework
src/web/Ftp.php
Ftp.delete
public function delete($remote_file = null) { if (\ftp_delete($this->_stream, $remote_file)) { return true; } $this->error = 'Failed to delete file "'.$remote_file.'"'; return false; }
php
public function delete($remote_file = null) { if (\ftp_delete($this->_stream, $remote_file)) { return true; } $this->error = 'Failed to delete file "'.$remote_file.'"'; return false; }
[ "public", "function", "delete", "(", "$", "remote_file", "=", "null", ")", "{", "if", "(", "\\", "ftp_delete", "(", "$", "this", "->", "_stream", ",", "$", "remote_file", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "error", "=", "'Failed to delete file \"'", ".", "$", "remote_file", ".", "'\"'", ";", "return", "false", ";", "}" ]
Delete file on FTP server @param string $remote_file @return bool
[ "Delete", "file", "on", "FTP", "server" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/web/Ftp.php#L194-L203
train
linpax/microphp-framework
src/web/Ftp.php
Ftp.mkdir
public function mkdir($directory = null) { if (\ftp_mkdir($this->_stream, $directory)) { return true; } $this->error = 'Failed to create directory "'.$directory.'"'; return false; }
php
public function mkdir($directory = null) { if (\ftp_mkdir($this->_stream, $directory)) { return true; } $this->error = 'Failed to create directory "'.$directory.'"'; return false; }
[ "public", "function", "mkdir", "(", "$", "directory", "=", "null", ")", "{", "if", "(", "\\", "ftp_mkdir", "(", "$", "this", "->", "_stream", ",", "$", "directory", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "error", "=", "'Failed to create directory \"'", ".", "$", "directory", ".", "'\"'", ";", "return", "false", ";", "}" ]
Create directory on FTP server @param string $directory @return bool
[ "Create", "directory", "on", "FTP", "server" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/web/Ftp.php#L250-L259
train
linpax/microphp-framework
src/web/Ftp.php
Ftp.rmdir
public function rmdir($directory = null) { if (\ftp_rmdir($this->_stream, $directory)) { return true; } $this->error = 'Failed to remove directory "'.$directory.'"'; return false; }
php
public function rmdir($directory = null) { if (\ftp_rmdir($this->_stream, $directory)) { return true; } $this->error = 'Failed to remove directory "'.$directory.'"'; return false; }
[ "public", "function", "rmdir", "(", "$", "directory", "=", "null", ")", "{", "if", "(", "\\", "ftp_rmdir", "(", "$", "this", "->", "_stream", ",", "$", "directory", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "error", "=", "'Failed to remove directory \"'", ".", "$", "directory", ".", "'\"'", ";", "return", "false", ";", "}" ]
Remove directory on FTP server @param string $directory @return bool
[ "Remove", "directory", "on", "FTP", "server" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/web/Ftp.php#L317-L326
train
nice-php/benchmark
src/BenchmarkCollection.php
BenchmarkCollection.execute
public function execute() { $results = array(); foreach ($this->benchmarks as $benchmark) { $results += $benchmark->execute(); } return $results; }
php
public function execute() { $results = array(); foreach ($this->benchmarks as $benchmark) { $results += $benchmark->execute(); } return $results; }
[ "public", "function", "execute", "(", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "benchmarks", "as", "$", "benchmark", ")", "{", "$", "results", "+=", "$", "benchmark", "->", "execute", "(", ")", ";", "}", "return", "$", "results", ";", "}" ]
Execute the registered tests and return the results @return array The results
[ "Execute", "the", "registered", "tests", "and", "return", "the", "results" ]
2084c77dbb88cd76006abbfe85b2b704f6bbd1cf
https://github.com/nice-php/benchmark/blob/2084c77dbb88cd76006abbfe85b2b704f6bbd1cf/src/BenchmarkCollection.php#L82-L90
train
stubbles/stubbles-peer
src/main/php/http/HttpConnection.php
HttpConnection.authorizedAs
public function authorizedAs(string $user, string $password): self { $this->headers->putAuthorization($user, $password); return $this; }
php
public function authorizedAs(string $user, string $password): self { $this->headers->putAuthorization($user, $password); return $this; }
[ "public", "function", "authorizedAs", "(", "string", "$", "user", ",", "string", "$", "password", ")", ":", "self", "{", "$", "this", "->", "headers", "->", "putAuthorization", "(", "$", "user", ",", "$", "password", ")", ";", "return", "$", "this", ";", "}" ]
authorize with given credentials @api @param string $user @param string $password @return \stubbles\peer\http\HttpConnection
[ "authorize", "with", "given", "credentials" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/HttpConnection.php#L109-L113
train
stubbles/stubbles-peer
src/main/php/http/HttpConnection.php
HttpConnection.usingHeader
public function usingHeader(string $key, $value): self { $this->headers->put($key, $value); return $this; }
php
public function usingHeader(string $key, $value): self { $this->headers->put($key, $value); return $this; }
[ "public", "function", "usingHeader", "(", "string", "$", "key", ",", "$", "value", ")", ":", "self", "{", "$", "this", "->", "headers", "->", "put", "(", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
adds any arbitrary header @api @param string $key name of header @param string $value value of header @return \stubbles\peer\http\HttpConnection
[ "adds", "any", "arbitrary", "header" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/HttpConnection.php#L123-L127
train
stubbles/stubbles-peer
src/main/php/http/HttpConnection.php
HttpConnection.put
public function put(string $body, string $version = HttpVersion::HTTP_1_1): HttpResponse { return HttpRequest::create($this->httpUri, $this->headers) ->put($body, $this->timeout, $version); }
php
public function put(string $body, string $version = HttpVersion::HTTP_1_1): HttpResponse { return HttpRequest::create($this->httpUri, $this->headers) ->put($body, $this->timeout, $version); }
[ "public", "function", "put", "(", "string", "$", "body", ",", "string", "$", "version", "=", "HttpVersion", "::", "HTTP_1_1", ")", ":", "HttpResponse", "{", "return", "HttpRequest", "::", "create", "(", "$", "this", "->", "httpUri", ",", "$", "this", "->", "headers", ")", "->", "put", "(", "$", "body", ",", "$", "this", "->", "timeout", ",", "$", "version", ")", ";", "}" ]
returns response object for given URI after PUT request @api @param string $body @param string $version optional http version, defaults to HTTP/1.1 @return \stubbles\peer\http\HttpResponse @since 2.0.0
[ "returns", "response", "object", "for", "given", "URI", "after", "PUT", "request" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/HttpConnection.php#L178-L182
train
stubbles/stubbles-peer
src/main/php/http/HttpConnection.php
HttpConnection.delete
public function delete(string $version = HttpVersion::HTTP_1_1): HttpResponse { return HttpRequest::create($this->httpUri, $this->headers) ->delete($this->timeout, $version); }
php
public function delete(string $version = HttpVersion::HTTP_1_1): HttpResponse { return HttpRequest::create($this->httpUri, $this->headers) ->delete($this->timeout, $version); }
[ "public", "function", "delete", "(", "string", "$", "version", "=", "HttpVersion", "::", "HTTP_1_1", ")", ":", "HttpResponse", "{", "return", "HttpRequest", "::", "create", "(", "$", "this", "->", "httpUri", ",", "$", "this", "->", "headers", ")", "->", "delete", "(", "$", "this", "->", "timeout", ",", "$", "version", ")", ";", "}" ]
returns response object for given URI after DELETE request @api @param string $version optional http version, defaults to HTTP/1.1 @return \stubbles\peer\http\HttpResponse @since 2.0.0
[ "returns", "response", "object", "for", "given", "URI", "after", "DELETE", "request" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/HttpConnection.php#L192-L196
train
vainproject/vain-user
src/User/Providers/AuthServiceProvider.php
AuthServiceProvider.registerGuest
protected function registerGuest() { $this->app->bind('guest.roles', function ($app) { return ['guest']; }); $this->app->bind('guest.abilities', function ($app) { return ['*.show']; }); $this->app->bind('guest', function ($app) { return new Guest($app['guest.roles'], $app['guest.abilities']); }); }
php
protected function registerGuest() { $this->app->bind('guest.roles', function ($app) { return ['guest']; }); $this->app->bind('guest.abilities', function ($app) { return ['*.show']; }); $this->app->bind('guest', function ($app) { return new Guest($app['guest.roles'], $app['guest.abilities']); }); }
[ "protected", "function", "registerGuest", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'guest.roles'", ",", "function", "(", "$", "app", ")", "{", "return", "[", "'guest'", "]", ";", "}", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "'guest.abilities'", ",", "function", "(", "$", "app", ")", "{", "return", "[", "'*.show'", "]", ";", "}", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "'guest'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "Guest", "(", "$", "app", "[", "'guest.roles'", "]", ",", "$", "app", "[", "'guest.abilities'", "]", ")", ";", "}", ")", ";", "}" ]
Register a guest representing user entity which is not persistable.
[ "Register", "a", "guest", "representing", "user", "entity", "which", "is", "not", "persistable", "." ]
1c059faa61ebf289fcaea39a90b4523cfc9d6efc
https://github.com/vainproject/vain-user/blob/1c059faa61ebf289fcaea39a90b4523cfc9d6efc/src/User/Providers/AuthServiceProvider.php#L75-L88
train
fiiSoft/fiisoft-output-writer
src/Tools/OutputWriter/Adapter/BufferedOutputWriter.php
BufferedOutputWriter.flushTo
public function flushTo(OutputWriter $outputWriter) { if ($outputWriter === $this) { throw new LogicException('Operation not allowed'); } $minLevel = $outputWriter->getLevel(); while (!empty($this->buffer)) { $item = array_shift($this->buffer); if ($item['level'] < $minLevel) { continue; } switch ($item['level']) { case OutputLevel::ERROR: $outputWriter->error($item['message'], $item['newLine']); break; case OutputLevel::NORMAL: $outputWriter->normal($item['message'], $item['newLine']); break; case OutputLevel::VERBOSE: $outputWriter->verbose($item['message'], $item['newLine']); break; case OutputLevel::VERY_VERBOSE: $outputWriter->veryVerb($item['message'], $item['newLine']); break; case OutputLevel::DEBUG: $outputWriter->debug($item['message'], $item['newLine']); break; default: throw new UnexpectedValueException('Unexpected value of level'); } } }
php
public function flushTo(OutputWriter $outputWriter) { if ($outputWriter === $this) { throw new LogicException('Operation not allowed'); } $minLevel = $outputWriter->getLevel(); while (!empty($this->buffer)) { $item = array_shift($this->buffer); if ($item['level'] < $minLevel) { continue; } switch ($item['level']) { case OutputLevel::ERROR: $outputWriter->error($item['message'], $item['newLine']); break; case OutputLevel::NORMAL: $outputWriter->normal($item['message'], $item['newLine']); break; case OutputLevel::VERBOSE: $outputWriter->verbose($item['message'], $item['newLine']); break; case OutputLevel::VERY_VERBOSE: $outputWriter->veryVerb($item['message'], $item['newLine']); break; case OutputLevel::DEBUG: $outputWriter->debug($item['message'], $item['newLine']); break; default: throw new UnexpectedValueException('Unexpected value of level'); } } }
[ "public", "function", "flushTo", "(", "OutputWriter", "$", "outputWriter", ")", "{", "if", "(", "$", "outputWriter", "===", "$", "this", ")", "{", "throw", "new", "LogicException", "(", "'Operation not allowed'", ")", ";", "}", "$", "minLevel", "=", "$", "outputWriter", "->", "getLevel", "(", ")", ";", "while", "(", "!", "empty", "(", "$", "this", "->", "buffer", ")", ")", "{", "$", "item", "=", "array_shift", "(", "$", "this", "->", "buffer", ")", ";", "if", "(", "$", "item", "[", "'level'", "]", "<", "$", "minLevel", ")", "{", "continue", ";", "}", "switch", "(", "$", "item", "[", "'level'", "]", ")", "{", "case", "OutputLevel", "::", "ERROR", ":", "$", "outputWriter", "->", "error", "(", "$", "item", "[", "'message'", "]", ",", "$", "item", "[", "'newLine'", "]", ")", ";", "break", ";", "case", "OutputLevel", "::", "NORMAL", ":", "$", "outputWriter", "->", "normal", "(", "$", "item", "[", "'message'", "]", ",", "$", "item", "[", "'newLine'", "]", ")", ";", "break", ";", "case", "OutputLevel", "::", "VERBOSE", ":", "$", "outputWriter", "->", "verbose", "(", "$", "item", "[", "'message'", "]", ",", "$", "item", "[", "'newLine'", "]", ")", ";", "break", ";", "case", "OutputLevel", "::", "VERY_VERBOSE", ":", "$", "outputWriter", "->", "veryVerb", "(", "$", "item", "[", "'message'", "]", ",", "$", "item", "[", "'newLine'", "]", ")", ";", "break", ";", "case", "OutputLevel", "::", "DEBUG", ":", "$", "outputWriter", "->", "debug", "(", "$", "item", "[", "'message'", "]", ",", "$", "item", "[", "'newLine'", "]", ")", ";", "break", ";", "default", ":", "throw", "new", "UnexpectedValueException", "(", "'Unexpected value of level'", ")", ";", "}", "}", "}" ]
Send all buffered messages to another OutputWriter. Be aware that messages are removed during this process. @param OutputWriter $outputWriter @throws UnexpectedValueException @throws LogicException @return void
[ "Send", "all", "buffered", "messages", "to", "another", "OutputWriter", ".", "Be", "aware", "that", "messages", "are", "removed", "during", "this", "process", "." ]
d275ca8fa90ce87b4caac0af63af9e708314e505
https://github.com/fiiSoft/fiisoft-output-writer/blob/d275ca8fa90ce87b4caac0af63af9e708314e505/src/Tools/OutputWriter/Adapter/BufferedOutputWriter.php#L41-L76
train
sil-project/SeedBatchBundle
src/Admin/OrganismAdmin.php
OrganismAdmin.validateSeedProducerCode
public function validateSeedProducerCode(ErrorElement $errorElement, $object) { $code = $object->getSeedProducerCode(); $container = $this->getConfigurationPool()->getContainer(); $is_new = empty($object->getId()); if (empty($code)) { // Check if organism is a seed producer (belongs to the seed_producers app circle) $app_circles = $container->get('librinfo_crm.app_circles'); if ($app_circles->isInCircle($object, 'seed_producers') && !$is_new) { $errorElement ->with('seedProducerCode') ->addViolation('A seed producer code is required for seed producers') ->end() ; } } else { $registry = $container->get('blast_core.code_generators'); $codeGenerator = $registry->getCodeGenerator(Organism::class, 'seedProducerCode'); if (!$codeGenerator->validate($code)) { $errorElement ->with('seedProducerCode') ->addViolation('Wrong format for seed producer code. It shoud be: ' . $codeGenerator::getHelp()) ->end() ; } } }
php
public function validateSeedProducerCode(ErrorElement $errorElement, $object) { $code = $object->getSeedProducerCode(); $container = $this->getConfigurationPool()->getContainer(); $is_new = empty($object->getId()); if (empty($code)) { // Check if organism is a seed producer (belongs to the seed_producers app circle) $app_circles = $container->get('librinfo_crm.app_circles'); if ($app_circles->isInCircle($object, 'seed_producers') && !$is_new) { $errorElement ->with('seedProducerCode') ->addViolation('A seed producer code is required for seed producers') ->end() ; } } else { $registry = $container->get('blast_core.code_generators'); $codeGenerator = $registry->getCodeGenerator(Organism::class, 'seedProducerCode'); if (!$codeGenerator->validate($code)) { $errorElement ->with('seedProducerCode') ->addViolation('Wrong format for seed producer code. It shoud be: ' . $codeGenerator::getHelp()) ->end() ; } } }
[ "public", "function", "validateSeedProducerCode", "(", "ErrorElement", "$", "errorElement", ",", "$", "object", ")", "{", "$", "code", "=", "$", "object", "->", "getSeedProducerCode", "(", ")", ";", "$", "container", "=", "$", "this", "->", "getConfigurationPool", "(", ")", "->", "getContainer", "(", ")", ";", "$", "is_new", "=", "empty", "(", "$", "object", "->", "getId", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "code", ")", ")", "{", "// Check if organism is a seed producer (belongs to the seed_producers app circle)", "$", "app_circles", "=", "$", "container", "->", "get", "(", "'librinfo_crm.app_circles'", ")", ";", "if", "(", "$", "app_circles", "->", "isInCircle", "(", "$", "object", ",", "'seed_producers'", ")", "&&", "!", "$", "is_new", ")", "{", "$", "errorElement", "->", "with", "(", "'seedProducerCode'", ")", "->", "addViolation", "(", "'A seed producer code is required for seed producers'", ")", "->", "end", "(", ")", ";", "}", "}", "else", "{", "$", "registry", "=", "$", "container", "->", "get", "(", "'blast_core.code_generators'", ")", ";", "$", "codeGenerator", "=", "$", "registry", "->", "getCodeGenerator", "(", "Organism", "::", "class", ",", "'seedProducerCode'", ")", ";", "if", "(", "!", "$", "codeGenerator", "->", "validate", "(", "$", "code", ")", ")", "{", "$", "errorElement", "->", "with", "(", "'seedProducerCode'", ")", "->", "addViolation", "(", "'Wrong format for seed producer code. It shoud be: '", ".", "$", "codeGenerator", "::", "getHelp", "(", ")", ")", "->", "end", "(", ")", ";", "}", "}", "}" ]
Seed producer code validator. @param ErrorElement $errorElement @param Organism $object
[ "Seed", "producer", "code", "validator", "." ]
a2640b5359fe31d3bdb9c9fa2f72141ac841729c
https://github.com/sil-project/SeedBatchBundle/blob/a2640b5359fe31d3bdb9c9fa2f72141ac841729c/src/Admin/OrganismAdmin.php#L94-L121
train
LartTyler/PHP-DaybreakCommons
src/DaybreakStudios/Common/Collection/EnumSet.php
EnumSet.contains
public function contains($e) { if (!EnumUtil::isEnum($e, $this->class)) throw new InvalidArgumentException(sprintf('Element must be an instance of %s.', $this->class)); return ($this->entries & $this->universe[$e->ordinal()]) !== 0; }
php
public function contains($e) { if (!EnumUtil::isEnum($e, $this->class)) throw new InvalidArgumentException(sprintf('Element must be an instance of %s.', $this->class)); return ($this->entries & $this->universe[$e->ordinal()]) !== 0; }
[ "public", "function", "contains", "(", "$", "e", ")", "{", "if", "(", "!", "EnumUtil", "::", "isEnum", "(", "$", "e", ",", "$", "this", "->", "class", ")", ")", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Element must be an instance of %s.'", ",", "$", "this", "->", "class", ")", ")", ";", "return", "(", "$", "this", "->", "entries", "&", "$", "this", "->", "universe", "[", "$", "e", "->", "ordinal", "(", ")", "]", ")", "!==", "0", ";", "}" ]
Returns true if this set contains the given element. @param Enum $e the element to test for @return boolean true if this set contains the element
[ "Returns", "true", "if", "this", "set", "contains", "the", "given", "element", "." ]
db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d
https://github.com/LartTyler/PHP-DaybreakCommons/blob/db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d/src/DaybreakStudios/Common/Collection/EnumSet.php#L67-L72
train
LartTyler/PHP-DaybreakCommons
src/DaybreakStudios/Common/Collection/EnumSet.php
EnumSet.remove
public function remove($e) { if (!EnumUtil::isEnum($e, $this->class)) throw new InvalidArgumentException(sprintf('Element must be an instance of %s.', $this->class)); if (!$this->contains($e)) return false; $this->entries &= ~$this->universe[$e->ordinal()]; return true; }
php
public function remove($e) { if (!EnumUtil::isEnum($e, $this->class)) throw new InvalidArgumentException(sprintf('Element must be an instance of %s.', $this->class)); if (!$this->contains($e)) return false; $this->entries &= ~$this->universe[$e->ordinal()]; return true; }
[ "public", "function", "remove", "(", "$", "e", ")", "{", "if", "(", "!", "EnumUtil", "::", "isEnum", "(", "$", "e", ",", "$", "this", "->", "class", ")", ")", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Element must be an instance of %s.'", ",", "$", "this", "->", "class", ")", ")", ";", "if", "(", "!", "$", "this", "->", "contains", "(", "$", "e", ")", ")", "return", "false", ";", "$", "this", "->", "entries", "&=", "~", "$", "this", "->", "universe", "[", "$", "e", "->", "ordinal", "(", ")", "]", ";", "return", "true", ";", "}" ]
Removes a single instance of an object from this set, if it is present. @param Enum $e the element to remove from this set, if present @return boolean true if this set changed as a result of this call
[ "Removes", "a", "single", "instance", "of", "an", "object", "from", "this", "set", "if", "it", "is", "present", "." ]
db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d
https://github.com/LartTyler/PHP-DaybreakCommons/blob/db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d/src/DaybreakStudios/Common/Collection/EnumSet.php#L84-L94
train
LartTyler/PHP-DaybreakCommons
src/DaybreakStudios/Common/Collection/EnumSet.php
EnumSet.complementOf
public static function complementOf(EnumSet $set) { $values = array(); foreach (call_user_func(array($set->class, 'values')) as $v) if (!$set->contains($v)) $values[] = $v; return new EnumSet($set->class, $values); }
php
public static function complementOf(EnumSet $set) { $values = array(); foreach (call_user_func(array($set->class, 'values')) as $v) if (!$set->contains($v)) $values[] = $v; return new EnumSet($set->class, $values); }
[ "public", "static", "function", "complementOf", "(", "EnumSet", "$", "set", ")", "{", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "call_user_func", "(", "array", "(", "$", "set", "->", "class", ",", "'values'", ")", ")", "as", "$", "v", ")", "if", "(", "!", "$", "set", "->", "contains", "(", "$", "v", ")", ")", "$", "values", "[", "]", "=", "$", "v", ";", "return", "new", "EnumSet", "(", "$", "set", "->", "class", ",", "$", "values", ")", ";", "}" ]
Creates a new EnumSet that is the complement of the given EnumSet. Or in other words, creates an EnumSet containing all enum values that are not present in the given EnumSet. @param EnumSet $set the EnumSet to generate a complement for @return EnumSet the resulting EnumSet
[ "Creates", "a", "new", "EnumSet", "that", "is", "the", "complement", "of", "the", "given", "EnumSet", ".", "Or", "in", "other", "words", "creates", "an", "EnumSet", "containing", "all", "enum", "values", "that", "are", "not", "present", "in", "the", "given", "EnumSet", "." ]
db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d
https://github.com/LartTyler/PHP-DaybreakCommons/blob/db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d/src/DaybreakStudios/Common/Collection/EnumSet.php#L137-L145
train
LartTyler/PHP-DaybreakCommons
src/DaybreakStudios/Common/Collection/EnumSet.php
EnumSet.of
public static function of($class/* , ... $values */) { if (!EnumUtil::isEnumClass($class)) throw new InvalidArgumentException($class . ' is not loaded or does not extend DaybreakStudios\Common\Enum\Enum.'); $values = func_get_args(); array_shift($values); return new EnumSet($class, $values); }
php
public static function of($class/* , ... $values */) { if (!EnumUtil::isEnumClass($class)) throw new InvalidArgumentException($class . ' is not loaded or does not extend DaybreakStudios\Common\Enum\Enum.'); $values = func_get_args(); array_shift($values); return new EnumSet($class, $values); }
[ "public", "static", "function", "of", "(", "$", "class", "/* , ... $values */", ")", "{", "if", "(", "!", "EnumUtil", "::", "isEnumClass", "(", "$", "class", ")", ")", "throw", "new", "InvalidArgumentException", "(", "$", "class", ".", "' is not loaded or does not extend DaybreakStudios\\Common\\Enum\\Enum.'", ")", ";", "$", "values", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "values", ")", ";", "return", "new", "EnumSet", "(", "$", "class", ",", "$", "values", ")", ";", "}" ]
Creates a new EnumSet that contains all of the elements passed to this method after the first. @throws InvalidArgumentException if the given class name is not an enum @param string $class the fully-qualified namespace of the enum @param Enum $values,... zero or more values that the resulting EnumSet should contain @return EnumSet the resulting EnumSet
[ "Creates", "a", "new", "EnumSet", "that", "contains", "all", "of", "the", "elements", "passed", "to", "this", "method", "after", "the", "first", "." ]
db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d
https://github.com/LartTyler/PHP-DaybreakCommons/blob/db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d/src/DaybreakStudios/Common/Collection/EnumSet.php#L166-L175
train
LartTyler/PHP-DaybreakCommons
src/DaybreakStudios/Common/Collection/EnumSet.php
EnumSet.range
public static function range($class, Enum $from, Enum $to) { if (!EnumUtil::isEnumClass($class)) throw new InvalidArgumentException($class . ' is not loaded or does not extend DaybreakStudios\Common\Enum\Enum.'); else if (!EnumUtil::isEnum($from, $class) || !EnumUtil::isEnum($to, $class)) throw new InvalidArgumentException(sprintf('$from and $to must be an instance of %s.', $this->class)); $values = array(); foreach ($class::values() as $v) if ($v->ordinal() >= $from->ordinal() && $v->ordinal() <= $to->ordinal()) $values[] = $v; return new EnumSet($class, $values); }
php
public static function range($class, Enum $from, Enum $to) { if (!EnumUtil::isEnumClass($class)) throw new InvalidArgumentException($class . ' is not loaded or does not extend DaybreakStudios\Common\Enum\Enum.'); else if (!EnumUtil::isEnum($from, $class) || !EnumUtil::isEnum($to, $class)) throw new InvalidArgumentException(sprintf('$from and $to must be an instance of %s.', $this->class)); $values = array(); foreach ($class::values() as $v) if ($v->ordinal() >= $from->ordinal() && $v->ordinal() <= $to->ordinal()) $values[] = $v; return new EnumSet($class, $values); }
[ "public", "static", "function", "range", "(", "$", "class", ",", "Enum", "$", "from", ",", "Enum", "$", "to", ")", "{", "if", "(", "!", "EnumUtil", "::", "isEnumClass", "(", "$", "class", ")", ")", "throw", "new", "InvalidArgumentException", "(", "$", "class", ".", "' is not loaded or does not extend DaybreakStudios\\Common\\Enum\\Enum.'", ")", ";", "else", "if", "(", "!", "EnumUtil", "::", "isEnum", "(", "$", "from", ",", "$", "class", ")", "||", "!", "EnumUtil", "::", "isEnum", "(", "$", "to", ",", "$", "class", ")", ")", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'$from and $to must be an instance of %s.'", ",", "$", "this", "->", "class", ")", ")", ";", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "class", "::", "values", "(", ")", "as", "$", "v", ")", "if", "(", "$", "v", "->", "ordinal", "(", ")", ">=", "$", "from", "->", "ordinal", "(", ")", "&&", "$", "v", "->", "ordinal", "(", ")", "<=", "$", "to", "->", "ordinal", "(", ")", ")", "$", "values", "[", "]", "=", "$", "v", ";", "return", "new", "EnumSet", "(", "$", "class", ",", "$", "values", ")", ";", "}" ]
Creates an EnumSet that initially contains all of the elements between two endpoints. @throws InvalidArgumentException if either of the range endpoints are not enums, or they are not elements from the same enum @param string $class the fully-qualified namespace of the num @param Enum $from the start point of the range @param Enum $to the end point of the range @return EnumSet the resulting EnumSet
[ "Creates", "an", "EnumSet", "that", "initially", "contains", "all", "of", "the", "elements", "between", "two", "endpoints", "." ]
db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d
https://github.com/LartTyler/PHP-DaybreakCommons/blob/db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d/src/DaybreakStudios/Common/Collection/EnumSet.php#L188-L202
train
shrink0r/monatic
src/ManyMaybe.php
ManyMaybe.get
public function get(callable $codeBlock = null) { $getValue = function (Maybe $value) { return $value->get(); }; return array_map($getValue, parent::get($codeBlock)); }
php
public function get(callable $codeBlock = null) { $getValue = function (Maybe $value) { return $value->get(); }; return array_map($getValue, parent::get($codeBlock)); }
[ "public", "function", "get", "(", "callable", "$", "codeBlock", "=", "null", ")", "{", "$", "getValue", "=", "function", "(", "Maybe", "$", "value", ")", "{", "return", "$", "value", "->", "get", "(", ")", ";", "}", ";", "return", "array_map", "(", "$", "getValue", ",", "parent", "::", "get", "(", "$", "codeBlock", ")", ")", ";", "}" ]
Returns the contained collection and applies an optional code-block to each element before returning it. @param callable $codeBlock @return array
[ "Returns", "the", "contained", "collection", "and", "applies", "an", "optional", "code", "-", "block", "to", "each", "element", "before", "returning", "it", "." ]
f39b8b2ef68a397d31d844341487412b335fd107
https://github.com/shrink0r/monatic/blob/f39b8b2ef68a397d31d844341487412b335fd107/src/ManyMaybe.php#L17-L24
train
Topolis/Filter
src/Filter.php
Filter.loadFilters
protected static function loadFilters($filters, $options = []) { $queue = array(); if(!is_array($filters)) { $filters = [$filters]; $options = [$options]; } foreach($filters as $idx => $filtername) { $classname = __NAMESPACE__."\\Types\\".preg_replace("/[^A-z0-9]/", "", ucfirst($filtername))."Filter"; if(!class_exists($classname)) throw new FilterException("Filter class '$filtername' not found"); $filter = new $classname($options[$idx]); if(!$filter instanceof IFilterType) throw new FilterException("Filter is not instance of IFilterType"); $queue[] = $filter; } return $queue; }
php
protected static function loadFilters($filters, $options = []) { $queue = array(); if(!is_array($filters)) { $filters = [$filters]; $options = [$options]; } foreach($filters as $idx => $filtername) { $classname = __NAMESPACE__."\\Types\\".preg_replace("/[^A-z0-9]/", "", ucfirst($filtername))."Filter"; if(!class_exists($classname)) throw new FilterException("Filter class '$filtername' not found"); $filter = new $classname($options[$idx]); if(!$filter instanceof IFilterType) throw new FilterException("Filter is not instance of IFilterType"); $queue[] = $filter; } return $queue; }
[ "protected", "static", "function", "loadFilters", "(", "$", "filters", ",", "$", "options", "=", "[", "]", ")", "{", "$", "queue", "=", "array", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "filters", ")", ")", "{", "$", "filters", "=", "[", "$", "filters", "]", ";", "$", "options", "=", "[", "$", "options", "]", ";", "}", "foreach", "(", "$", "filters", "as", "$", "idx", "=>", "$", "filtername", ")", "{", "$", "classname", "=", "__NAMESPACE__", ".", "\"\\\\Types\\\\\"", ".", "preg_replace", "(", "\"/[^A-z0-9]/\"", ",", "\"\"", ",", "ucfirst", "(", "$", "filtername", ")", ")", ".", "\"Filter\"", ";", "if", "(", "!", "class_exists", "(", "$", "classname", ")", ")", "throw", "new", "FilterException", "(", "\"Filter class '$filtername' not found\"", ")", ";", "$", "filter", "=", "new", "$", "classname", "(", "$", "options", "[", "$", "idx", "]", ")", ";", "if", "(", "!", "$", "filter", "instanceof", "IFilterType", ")", "throw", "new", "FilterException", "(", "\"Filter is not instance of IFilterType\"", ")", ";", "$", "queue", "[", "]", "=", "$", "filter", ";", "}", "return", "$", "queue", ";", "}" ]
load needed filters @param string|array $filters either one filter name or array of filter names. Default: "Plain" @param array $options (Optional) either one options array or array of options array for filters, depending if we specified one or mode filters above. Default: array() @throws FilterException @return IFilterType[] array of initialized filter objects
[ "load", "needed", "filters" ]
6208a6270490c39f028248dc99f21b3e816e388b
https://github.com/Topolis/Filter/blob/6208a6270490c39f028248dc99f21b3e816e388b/src/Filter.php#L78-L103
train
Topolis/Filter
src/Filter.php
Filter.execFilterQueue
protected static function execFilterQueue($value, array $queue, $type) { foreach($queue as $filter) { $value = self::executeValueMethod($value, $filter, $type, "filter"); if($value === self::ERR_INVALID) return false; } return $value; }
php
protected static function execFilterQueue($value, array $queue, $type) { foreach($queue as $filter) { $value = self::executeValueMethod($value, $filter, $type, "filter"); if($value === self::ERR_INVALID) return false; } return $value; }
[ "protected", "static", "function", "execFilterQueue", "(", "$", "value", ",", "array", "$", "queue", ",", "$", "type", ")", "{", "foreach", "(", "$", "queue", "as", "$", "filter", ")", "{", "$", "value", "=", "self", "::", "executeValueMethod", "(", "$", "value", ",", "$", "filter", ",", "$", "type", ",", "\"filter\"", ")", ";", "if", "(", "$", "value", "===", "self", "::", "ERR_INVALID", ")", "return", "false", ";", "}", "return", "$", "value", ";", "}" ]
execute filter queue on a value @param mixed $value unfiltered value @param IFilterType[] $queue array of instantiated filter objects @param $type @return mixed either filtered value or self::ERR_INVALID
[ "execute", "filter", "queue", "on", "a", "value" ]
6208a6270490c39f028248dc99f21b3e816e388b
https://github.com/Topolis/Filter/blob/6208a6270490c39f028248dc99f21b3e816e388b/src/Filter.php#L112-L120
train
ddrv-test/firmapi-core
src/Repository/Build/Mysql.php
Mysql.prepareParams
public function prepareParams($params) { $values['street'] = isset($params['street'])?trim((string)$params['street']):null; $values['number'] = isset($params['number'])?trim((string)$params['number']):null; $values['latitude'] = isset($params['latitude'])?(double)$params['latitude']:null; $values['longitude'] = isset($params['longitude'])?(double)$params['longitude']:null; $values['id'] = $this->getId($values); return $values; }
php
public function prepareParams($params) { $values['street'] = isset($params['street'])?trim((string)$params['street']):null; $values['number'] = isset($params['number'])?trim((string)$params['number']):null; $values['latitude'] = isset($params['latitude'])?(double)$params['latitude']:null; $values['longitude'] = isset($params['longitude'])?(double)$params['longitude']:null; $values['id'] = $this->getId($values); return $values; }
[ "public", "function", "prepareParams", "(", "$", "params", ")", "{", "$", "values", "[", "'street'", "]", "=", "isset", "(", "$", "params", "[", "'street'", "]", ")", "?", "trim", "(", "(", "string", ")", "$", "params", "[", "'street'", "]", ")", ":", "null", ";", "$", "values", "[", "'number'", "]", "=", "isset", "(", "$", "params", "[", "'number'", "]", ")", "?", "trim", "(", "(", "string", ")", "$", "params", "[", "'number'", "]", ")", ":", "null", ";", "$", "values", "[", "'latitude'", "]", "=", "isset", "(", "$", "params", "[", "'latitude'", "]", ")", "?", "(", "double", ")", "$", "params", "[", "'latitude'", "]", ":", "null", ";", "$", "values", "[", "'longitude'", "]", "=", "isset", "(", "$", "params", "[", "'longitude'", "]", ")", "?", "(", "double", ")", "$", "params", "[", "'longitude'", "]", ":", "null", ";", "$", "values", "[", "'id'", "]", "=", "$", "this", "->", "getId", "(", "$", "values", ")", ";", "return", "$", "values", ";", "}" ]
Prepare parameters. @param array $params @return array
[ "Prepare", "parameters", "." ]
8f8843f0fb134568e7764cabd5039e15c579976d
https://github.com/ddrv-test/firmapi-core/blob/8f8843f0fb134568e7764cabd5039e15c579976d/src/Repository/Build/Mysql.php#L40-L48
train
fridge-project/dbal
src/Fridge/DBAL/SchemaManager/SQLCollector/CreateTableSQLCollector.php
CreateTableSQLCollector.collect
public function collect(Table $table) { $this->createTableQueries = array_merge( $this->createTableQueries, $this->platform->getCreateTableSQLQueries($table, array('foreign_key' => false)) ); foreach ($table->getForeignKeys() as $foreignKey) { $this->createForeignKeyQueries = array_merge( $this->createForeignKeyQueries, $this->platform->getCreateForeignKeySQLQueries($foreignKey, $table->getName()) ); } }
php
public function collect(Table $table) { $this->createTableQueries = array_merge( $this->createTableQueries, $this->platform->getCreateTableSQLQueries($table, array('foreign_key' => false)) ); foreach ($table->getForeignKeys() as $foreignKey) { $this->createForeignKeyQueries = array_merge( $this->createForeignKeyQueries, $this->platform->getCreateForeignKeySQLQueries($foreignKey, $table->getName()) ); } }
[ "public", "function", "collect", "(", "Table", "$", "table", ")", "{", "$", "this", "->", "createTableQueries", "=", "array_merge", "(", "$", "this", "->", "createTableQueries", ",", "$", "this", "->", "platform", "->", "getCreateTableSQLQueries", "(", "$", "table", ",", "array", "(", "'foreign_key'", "=>", "false", ")", ")", ")", ";", "foreach", "(", "$", "table", "->", "getForeignKeys", "(", ")", "as", "$", "foreignKey", ")", "{", "$", "this", "->", "createForeignKeyQueries", "=", "array_merge", "(", "$", "this", "->", "createForeignKeyQueries", ",", "$", "this", "->", "platform", "->", "getCreateForeignKeySQLQueries", "(", "$", "foreignKey", ",", "$", "table", "->", "getName", "(", ")", ")", ")", ";", "}", "}" ]
Collects queries to create tables. @param \Fridge\DBAL\Schema\Table $table The table.
[ "Collects", "queries", "to", "create", "tables", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/SchemaManager/SQLCollector/CreateTableSQLCollector.php#L83-L96
train
nails/module-blog
blog/models/blog_widget_model.php
NAILS_Blog_widget_model.categories
public function categories($blogId, $includeCount = true, $onlyPopulated = true) { $oDb = Factory::service('Database'); $oDb->select('c.id,c.blog_id,c.slug,c.label'); if ($includeCount) { $sql = '(SELECT COUNT(DISTINCT bpc.post_id) FROM ' . NAILS_DB_PREFIX . 'blog_post_category bpc JOIN '; $sql .= NAILS_DB_PREFIX . 'blog_post bp ON bpc.post_id = bp.id WHERE bpc.category_id = c.id AND '; $sql .= 'bp.is_published = 1 AND bp.is_deleted = 0 AND bp.published <= NOW()) post_count'; $oDb->select($sql); } if ($onlyPopulated) { $oDb->having('post_count > ', 0); } $oDb->where('c.blog_id', $blogId); $oDb->order_by('c.label'); $categories = $oDb->get(NAILS_DB_PREFIX . 'blog_category c')->result(); $this->load->model('blog/blog_category_model'); foreach ($categories as $category) { $category->url = $this->blog_category_model->formatUrl($category->slug, $category->blog_id); } return $categories; }
php
public function categories($blogId, $includeCount = true, $onlyPopulated = true) { $oDb = Factory::service('Database'); $oDb->select('c.id,c.blog_id,c.slug,c.label'); if ($includeCount) { $sql = '(SELECT COUNT(DISTINCT bpc.post_id) FROM ' . NAILS_DB_PREFIX . 'blog_post_category bpc JOIN '; $sql .= NAILS_DB_PREFIX . 'blog_post bp ON bpc.post_id = bp.id WHERE bpc.category_id = c.id AND '; $sql .= 'bp.is_published = 1 AND bp.is_deleted = 0 AND bp.published <= NOW()) post_count'; $oDb->select($sql); } if ($onlyPopulated) { $oDb->having('post_count > ', 0); } $oDb->where('c.blog_id', $blogId); $oDb->order_by('c.label'); $categories = $oDb->get(NAILS_DB_PREFIX . 'blog_category c')->result(); $this->load->model('blog/blog_category_model'); foreach ($categories as $category) { $category->url = $this->blog_category_model->formatUrl($category->slug, $category->blog_id); } return $categories; }
[ "public", "function", "categories", "(", "$", "blogId", ",", "$", "includeCount", "=", "true", ",", "$", "onlyPopulated", "=", "true", ")", "{", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "$", "oDb", "->", "select", "(", "'c.id,c.blog_id,c.slug,c.label'", ")", ";", "if", "(", "$", "includeCount", ")", "{", "$", "sql", "=", "'(SELECT COUNT(DISTINCT bpc.post_id) FROM '", ".", "NAILS_DB_PREFIX", ".", "'blog_post_category bpc JOIN '", ";", "$", "sql", ".=", "NAILS_DB_PREFIX", ".", "'blog_post bp ON bpc.post_id = bp.id WHERE bpc.category_id = c.id AND '", ";", "$", "sql", ".=", "'bp.is_published = 1 AND bp.is_deleted = 0 AND bp.published <= NOW()) post_count'", ";", "$", "oDb", "->", "select", "(", "$", "sql", ")", ";", "}", "if", "(", "$", "onlyPopulated", ")", "{", "$", "oDb", "->", "having", "(", "'post_count > '", ",", "0", ")", ";", "}", "$", "oDb", "->", "where", "(", "'c.blog_id'", ",", "$", "blogId", ")", ";", "$", "oDb", "->", "order_by", "(", "'c.label'", ")", ";", "$", "categories", "=", "$", "oDb", "->", "get", "(", "NAILS_DB_PREFIX", ".", "'blog_category c'", ")", "->", "result", "(", ")", ";", "$", "this", "->", "load", "->", "model", "(", "'blog/blog_category_model'", ")", ";", "foreach", "(", "$", "categories", "as", "$", "category", ")", "{", "$", "category", "->", "url", "=", "$", "this", "->", "blog_category_model", "->", "formatUrl", "(", "$", "category", "->", "slug", ",", "$", "category", "->", "blog_id", ")", ";", "}", "return", "$", "categories", ";", "}" ]
Returns an array of a blog's categories @param integer $blogId The ID of the blog to get categories from @param boolean $includeCount Whether to include the post count of each category @param boolean $onlyPopulated Whether to remove categories which don't have any posts in them @return array
[ "Returns", "an", "array", "of", "a", "blog", "s", "categories" ]
7b369c5209f4343fff7c7e2a22c237d5a95c8c24
https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_widget_model.php#L95-L127
train
nails/module-blog
blog/models/blog_widget_model.php
NAILS_Blog_widget_model.tags
public function tags($blogId, $includeCount = true, $onlyPopulated = true) { $oDb = Factory::service('Database'); $oDb->select('t.id,t.blog_id,t.slug,t.label'); if ($includeCount) { $sql = '(SELECT COUNT(DISTINCT bpt.post_id) FROM ' . NAILS_DB_PREFIX . 'blog_post_tag bpt JOIN '; $sql .= NAILS_DB_PREFIX . 'blog_post bp ON bpt.post_id = bp.id WHERE bpt.tag_id = t.id AND '; $sql .= 'bp.is_published = 1 AND bp.is_deleted = 0 AND bp.published <= NOW()) post_count'; $oDb->select($sql); } if ($onlyPopulated) { $oDb->having('post_count > ', 0); } $oDb->where('t.blog_id', $blogId); $oDb->order_by('t.label'); $tags = $oDb->get(NAILS_DB_PREFIX . 'blog_tag t')->result(); $this->load->model('blog/blog_tag_model'); foreach ($tags as $tag) { $tag->url = $this->blog_tag_model->formatUrl($tag->slug, $tag->blog_id); } return $tags; }
php
public function tags($blogId, $includeCount = true, $onlyPopulated = true) { $oDb = Factory::service('Database'); $oDb->select('t.id,t.blog_id,t.slug,t.label'); if ($includeCount) { $sql = '(SELECT COUNT(DISTINCT bpt.post_id) FROM ' . NAILS_DB_PREFIX . 'blog_post_tag bpt JOIN '; $sql .= NAILS_DB_PREFIX . 'blog_post bp ON bpt.post_id = bp.id WHERE bpt.tag_id = t.id AND '; $sql .= 'bp.is_published = 1 AND bp.is_deleted = 0 AND bp.published <= NOW()) post_count'; $oDb->select($sql); } if ($onlyPopulated) { $oDb->having('post_count > ', 0); } $oDb->where('t.blog_id', $blogId); $oDb->order_by('t.label'); $tags = $oDb->get(NAILS_DB_PREFIX . 'blog_tag t')->result(); $this->load->model('blog/blog_tag_model'); foreach ($tags as $tag) { $tag->url = $this->blog_tag_model->formatUrl($tag->slug, $tag->blog_id); } return $tags; }
[ "public", "function", "tags", "(", "$", "blogId", ",", "$", "includeCount", "=", "true", ",", "$", "onlyPopulated", "=", "true", ")", "{", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "$", "oDb", "->", "select", "(", "'t.id,t.blog_id,t.slug,t.label'", ")", ";", "if", "(", "$", "includeCount", ")", "{", "$", "sql", "=", "'(SELECT COUNT(DISTINCT bpt.post_id) FROM '", ".", "NAILS_DB_PREFIX", ".", "'blog_post_tag bpt JOIN '", ";", "$", "sql", ".=", "NAILS_DB_PREFIX", ".", "'blog_post bp ON bpt.post_id = bp.id WHERE bpt.tag_id = t.id AND '", ";", "$", "sql", ".=", "'bp.is_published = 1 AND bp.is_deleted = 0 AND bp.published <= NOW()) post_count'", ";", "$", "oDb", "->", "select", "(", "$", "sql", ")", ";", "}", "if", "(", "$", "onlyPopulated", ")", "{", "$", "oDb", "->", "having", "(", "'post_count > '", ",", "0", ")", ";", "}", "$", "oDb", "->", "where", "(", "'t.blog_id'", ",", "$", "blogId", ")", ";", "$", "oDb", "->", "order_by", "(", "'t.label'", ")", ";", "$", "tags", "=", "$", "oDb", "->", "get", "(", "NAILS_DB_PREFIX", ".", "'blog_tag t'", ")", "->", "result", "(", ")", ";", "$", "this", "->", "load", "->", "model", "(", "'blog/blog_tag_model'", ")", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "tag", "->", "url", "=", "$", "this", "->", "blog_tag_model", "->", "formatUrl", "(", "$", "tag", "->", "slug", ",", "$", "tag", "->", "blog_id", ")", ";", "}", "return", "$", "tags", ";", "}" ]
Returns an array of a blog's tags @param integer $blogId The ID of the blog to get tags from @param boolean $includeCount Whether to include the post count of each tag @param boolean $onlyPopulated Whether to remove tags which don't have any posts in them @return array
[ "Returns", "an", "array", "of", "a", "blog", "s", "tags" ]
7b369c5209f4343fff7c7e2a22c237d5a95c8c24
https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/models/blog_widget_model.php#L138-L170
train
spartan/console
src/Definition/CommandTrait.php
CommandTrait.withArgument
public function withArgument($name, $description, array $choices = []) { $this->choices[$name] = $choices; return $this->addArgument($name, InputArgument::REQUIRED, $description); }
php
public function withArgument($name, $description, array $choices = []) { $this->choices[$name] = $choices; return $this->addArgument($name, InputArgument::REQUIRED, $description); }
[ "public", "function", "withArgument", "(", "$", "name", ",", "$", "description", ",", "array", "$", "choices", "=", "[", "]", ")", "{", "$", "this", "->", "choices", "[", "$", "name", "]", "=", "$", "choices", ";", "return", "$", "this", "->", "addArgument", "(", "$", "name", ",", "InputArgument", "::", "REQUIRED", ",", "$", "description", ")", ";", "}" ]
With mandatory argument @param string $name @param string $description @param array $choices @return self
[ "With", "mandatory", "argument" ]
66e3e595b9bf9e274ce35d2f50f7cdd5d9e5e838
https://github.com/spartan/console/blob/66e3e595b9bf9e274ce35d2f50f7cdd5d9e5e838/src/Definition/CommandTrait.php#L88-L93
train
spartan/console
src/Definition/CommandTrait.php
CommandTrait.withOption
public function withOption($name, $description, $default = '', array $choices = []) { $this->choices[$name] = $choices; return $this->addOption($name, null, InputOption::VALUE_OPTIONAL, $description, $default); }
php
public function withOption($name, $description, $default = '', array $choices = []) { $this->choices[$name] = $choices; return $this->addOption($name, null, InputOption::VALUE_OPTIONAL, $description, $default); }
[ "public", "function", "withOption", "(", "$", "name", ",", "$", "description", ",", "$", "default", "=", "''", ",", "array", "$", "choices", "=", "[", "]", ")", "{", "$", "this", "->", "choices", "[", "$", "name", "]", "=", "$", "choices", ";", "return", "$", "this", "->", "addOption", "(", "$", "name", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "$", "description", ",", "$", "default", ")", ";", "}" ]
With optional option @param string $name @param string $description @param mixed $default Default must be empty string to check if the user has provided a value for option @param array $choices @return self
[ "With", "optional", "option" ]
66e3e595b9bf9e274ce35d2f50f7cdd5d9e5e838
https://github.com/spartan/console/blob/66e3e595b9bf9e274ce35d2f50f7cdd5d9e5e838/src/Definition/CommandTrait.php#L105-L110
train
spartan/console
src/Definition/CommandTrait.php
CommandTrait.exec
public function exec(string $command, array $remote = [], $color = 'note-inverted') { if ($remote) { $path = $remote['path'] ? $remote['path'] : '~'; $command = "ssh -t -p {$remote['port']} {$remote['auth']} \"cd {$path} && {$command}\""; } $this->out->writeln("\n<{$color}> {$command} </{$color}>\n"); return passthru($command); }
php
public function exec(string $command, array $remote = [], $color = 'note-inverted') { if ($remote) { $path = $remote['path'] ? $remote['path'] : '~'; $command = "ssh -t -p {$remote['port']} {$remote['auth']} \"cd {$path} && {$command}\""; } $this->out->writeln("\n<{$color}> {$command} </{$color}>\n"); return passthru($command); }
[ "public", "function", "exec", "(", "string", "$", "command", ",", "array", "$", "remote", "=", "[", "]", ",", "$", "color", "=", "'note-inverted'", ")", "{", "if", "(", "$", "remote", ")", "{", "$", "path", "=", "$", "remote", "[", "'path'", "]", "?", "$", "remote", "[", "'path'", "]", ":", "'~'", ";", "$", "command", "=", "\"ssh -t -p {$remote['port']} {$remote['auth']} \\\"cd {$path} && {$command}\\\"\"", ";", "}", "$", "this", "->", "out", "->", "writeln", "(", "\"\\n<{$color}> {$command} </{$color}>\\n\"", ")", ";", "return", "passthru", "(", "$", "command", ")", ";", "}" ]
Execute an command and display output @param string $command @param array $remote @param string $color
[ "Execute", "an", "command", "and", "display", "output" ]
66e3e595b9bf9e274ce35d2f50f7cdd5d9e5e838
https://github.com/spartan/console/blob/66e3e595b9bf9e274ce35d2f50f7cdd5d9e5e838/src/Definition/CommandTrait.php#L239-L249
train
spartan/console
src/Definition/CommandTrait.php
CommandTrait.initialize
public function initialize(InputInterface $input, OutputInterface $output) { $this->in = $input; $this->out = $output; }
php
public function initialize(InputInterface $input, OutputInterface $output) { $this->in = $input; $this->out = $output; }
[ "public", "function", "initialize", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "in", "=", "$", "input", ";", "$", "this", "->", "out", "=", "$", "output", ";", "}" ]
Initializes the command after the input has been bound and before the input is validated. @param InputInterface $input @param OutputInterface $output
[ "Initializes", "the", "command", "after", "the", "input", "has", "been", "bound", "and", "before", "the", "input", "is", "validated", "." ]
66e3e595b9bf9e274ce35d2f50f7cdd5d9e5e838
https://github.com/spartan/console/blob/66e3e595b9bf9e274ce35d2f50f7cdd5d9e5e838/src/Definition/CommandTrait.php#L419-L423
train
mitogh/Katana
src/Edge.php
Edge.filter
public function filter( $sizes ) { $sizes = apply_filters( Config::KATANA_FILTER, $sizes, $this->request_id() ); return $sizes; }
php
public function filter( $sizes ) { $sizes = apply_filters( Config::KATANA_FILTER, $sizes, $this->request_id() ); return $sizes; }
[ "public", "function", "filter", "(", "$", "sizes", ")", "{", "$", "sizes", "=", "apply_filters", "(", "Config", "::", "KATANA_FILTER", ",", "$", "sizes", ",", "$", "this", "->", "request_id", "(", ")", ")", ";", "return", "$", "sizes", ";", "}" ]
WP default filter that runs before the images are being generated, then appplies the custom filter from Katana. @since 1.0.0 @lik http://codex.wordpress.org/Plugin_API/Filter_Reference/intermediate_image_sizes.html @param array $sizes The register sizes of images in WP. @return array $sizes The array of sizes
[ "WP", "default", "filter", "that", "runs", "before", "the", "images", "are", "being", "generated", "then", "appplies", "the", "custom", "filter", "from", "Katana", "." ]
9eb7267f061fbe555dbe9c12461650bb4153915f
https://github.com/mitogh/Katana/blob/9eb7267f061fbe555dbe9c12461650bb4153915f/src/Edge.php#L36-L39
train
pazuzu156/Gravatar
src/Pazuzu156/Gravatar/Gravatar.php
Gravatar.setEmail
public function setEmail($email) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $this->_options['email'] = $email; $this->_options['hash'] = strtolower(md5(trim($this->_options['email']))); } else { throw new \Exception('The email is in an invalid format!'); } return $this; }
php
public function setEmail($email) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $this->_options['email'] = $email; $this->_options['hash'] = strtolower(md5(trim($this->_options['email']))); } else { throw new \Exception('The email is in an invalid format!'); } return $this; }
[ "public", "function", "setEmail", "(", "$", "email", ")", "{", "if", "(", "filter_var", "(", "$", "email", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "$", "this", "->", "_options", "[", "'email'", "]", "=", "$", "email", ";", "$", "this", "->", "_options", "[", "'hash'", "]", "=", "strtolower", "(", "md5", "(", "trim", "(", "$", "this", "->", "_options", "[", "'email'", "]", ")", ")", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'The email is in an invalid format!'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the email you want to use for image generation. @param string $email - The email to use @throws \Exception @return \Pazuzu156\Gravatar\Gravatar
[ "Sets", "the", "email", "you", "want", "to", "use", "for", "image", "generation", "." ]
7ec5c03f8ada81ec15034c671f2750456c89b6d5
https://github.com/pazuzu156/Gravatar/blob/7ec5c03f8ada81ec15034c671f2750456c89b6d5/src/Pazuzu156/Gravatar/Gravatar.php#L110-L120
train
pazuzu156/Gravatar
src/Pazuzu156/Gravatar/Gravatar.php
Gravatar.generateUrl
public function generateUrl($type, $email, array $attr = []) { if (!empty($email)) { $this->setEmail($email); } if (isset($attr['size'])) { $this->setSize($attr['size']); } if (isset($attr['imgset'])) { $this->setImageSet($attr['imgset']); } if (isset($attr['rating'])) { $this->setRating($attr['rating']); } $uri = '?'; $ignore = ['email', 'hash', 'secure']; foreach ($this->_options as $k => $v) { if (!in_array($k, $ignore)) { $uri .= $k.'='.$v.'&'; } } $uri = rtrim($uri, '&'); $base = (($this->_options['secure']) ? self::BASE_HTTPS : self::BASE_HTTP); switch (strtolower($type)) { case 'avatar': $url = $base.'avatar/'; break; case 'profile': $url = $base; break; default: throw new \Exception('Invalid URL type given! Must be avatar or profile!'); } return $url.$this->getHash(); }
php
public function generateUrl($type, $email, array $attr = []) { if (!empty($email)) { $this->setEmail($email); } if (isset($attr['size'])) { $this->setSize($attr['size']); } if (isset($attr['imgset'])) { $this->setImageSet($attr['imgset']); } if (isset($attr['rating'])) { $this->setRating($attr['rating']); } $uri = '?'; $ignore = ['email', 'hash', 'secure']; foreach ($this->_options as $k => $v) { if (!in_array($k, $ignore)) { $uri .= $k.'='.$v.'&'; } } $uri = rtrim($uri, '&'); $base = (($this->_options['secure']) ? self::BASE_HTTPS : self::BASE_HTTP); switch (strtolower($type)) { case 'avatar': $url = $base.'avatar/'; break; case 'profile': $url = $base; break; default: throw new \Exception('Invalid URL type given! Must be avatar or profile!'); } return $url.$this->getHash(); }
[ "public", "function", "generateUrl", "(", "$", "type", ",", "$", "email", ",", "array", "$", "attr", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "email", ")", ")", "{", "$", "this", "->", "setEmail", "(", "$", "email", ")", ";", "}", "if", "(", "isset", "(", "$", "attr", "[", "'size'", "]", ")", ")", "{", "$", "this", "->", "setSize", "(", "$", "attr", "[", "'size'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "attr", "[", "'imgset'", "]", ")", ")", "{", "$", "this", "->", "setImageSet", "(", "$", "attr", "[", "'imgset'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "attr", "[", "'rating'", "]", ")", ")", "{", "$", "this", "->", "setRating", "(", "$", "attr", "[", "'rating'", "]", ")", ";", "}", "$", "uri", "=", "'?'", ";", "$", "ignore", "=", "[", "'email'", ",", "'hash'", ",", "'secure'", "]", ";", "foreach", "(", "$", "this", "->", "_options", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "!", "in_array", "(", "$", "k", ",", "$", "ignore", ")", ")", "{", "$", "uri", ".=", "$", "k", ".", "'='", ".", "$", "v", ".", "'&'", ";", "}", "}", "$", "uri", "=", "rtrim", "(", "$", "uri", ",", "'&'", ")", ";", "$", "base", "=", "(", "(", "$", "this", "->", "_options", "[", "'secure'", "]", ")", "?", "self", "::", "BASE_HTTPS", ":", "self", "::", "BASE_HTTP", ")", ";", "switch", "(", "strtolower", "(", "$", "type", ")", ")", "{", "case", "'avatar'", ":", "$", "url", "=", "$", "base", ".", "'avatar/'", ";", "break", ";", "case", "'profile'", ":", "$", "url", "=", "$", "base", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "'Invalid URL type given! Must be avatar or profile!'", ")", ";", "}", "return", "$", "url", ".", "$", "this", "->", "getHash", "(", ")", ";", "}" ]
Generates the Gravatar URL. @param string $type - [avatar|profile] Get the requested user item @param string $email - The user's email @param array $attr - Extra attributes to set for the image request @throws \Exception @return string
[ "Generates", "the", "Gravatar", "URL", "." ]
7ec5c03f8ada81ec15034c671f2750456c89b6d5
https://github.com/pazuzu156/Gravatar/blob/7ec5c03f8ada81ec15034c671f2750456c89b6d5/src/Pazuzu156/Gravatar/Gravatar.php#L225-L266
train
modulusphp/support
Filesystem.php
Filesystem.chmod
public static function chmod($path, $mode = null) { if ($mode) { return chmod($path, $mode); } return substr(sprintf('%o', fileperms($path)), -4); }
php
public static function chmod($path, $mode = null) { if ($mode) { return chmod($path, $mode); } return substr(sprintf('%o', fileperms($path)), -4); }
[ "public", "static", "function", "chmod", "(", "$", "path", ",", "$", "mode", "=", "null", ")", "{", "if", "(", "$", "mode", ")", "{", "return", "chmod", "(", "$", "path", ",", "$", "mode", ")", ";", "}", "return", "substr", "(", "sprintf", "(", "'%o'", ",", "fileperms", "(", "$", "path", ")", ")", ",", "-", "4", ")", ";", "}" ]
Get or set UNIX mode of a file or directory. @param string $path @param int $mode @return mixed
[ "Get", "or", "set", "UNIX", "mode", "of", "a", "file", "or", "directory", "." ]
b5c5b48dcbeb379e6cd1f29159dc8cdacef3adab
https://github.com/modulusphp/support/blob/b5c5b48dcbeb379e6cd1f29159dc8cdacef3adab/Filesystem.php#L86-L93
train
modulusphp/support
Filesystem.php
Filesystem.copy
public static function copy(string $source, string $destination) { if (is_dir($source)) { @mkdir($destination); $directory = dir($source); while (false !== ($readdirectory = $directory->read())) { if ($readdirectory == '.' || $readdirectory == '..') { continue; } $PathDir = $source . '/' . $readdirectory; if (is_dir($PathDir)) { Filesystem::copy($PathDir, $destination . '/' . $readdirectory); continue; } copy($PathDir, $destination . '/' . $readdirectory); } $directory->close(); } else { copy($source, $destination); } }
php
public static function copy(string $source, string $destination) { if (is_dir($source)) { @mkdir($destination); $directory = dir($source); while (false !== ($readdirectory = $directory->read())) { if ($readdirectory == '.' || $readdirectory == '..') { continue; } $PathDir = $source . '/' . $readdirectory; if (is_dir($PathDir)) { Filesystem::copy($PathDir, $destination . '/' . $readdirectory); continue; } copy($PathDir, $destination . '/' . $readdirectory); } $directory->close(); } else { copy($source, $destination); } }
[ "public", "static", "function", "copy", "(", "string", "$", "source", ",", "string", "$", "destination", ")", "{", "if", "(", "is_dir", "(", "$", "source", ")", ")", "{", "@", "mkdir", "(", "$", "destination", ")", ";", "$", "directory", "=", "dir", "(", "$", "source", ")", ";", "while", "(", "false", "!==", "(", "$", "readdirectory", "=", "$", "directory", "->", "read", "(", ")", ")", ")", "{", "if", "(", "$", "readdirectory", "==", "'.'", "||", "$", "readdirectory", "==", "'..'", ")", "{", "continue", ";", "}", "$", "PathDir", "=", "$", "source", ".", "'/'", ".", "$", "readdirectory", ";", "if", "(", "is_dir", "(", "$", "PathDir", ")", ")", "{", "Filesystem", "::", "copy", "(", "$", "PathDir", ",", "$", "destination", ".", "'/'", ".", "$", "readdirectory", ")", ";", "continue", ";", "}", "copy", "(", "$", "PathDir", ",", "$", "destination", ".", "'/'", ".", "$", "readdirectory", ")", ";", "}", "$", "directory", "->", "close", "(", ")", ";", "}", "else", "{", "copy", "(", "$", "source", ",", "$", "destination", ")", ";", "}", "}" ]
Copy file or folder @param string $source @param string $destination @return void
[ "Copy", "file", "or", "folder" ]
b5c5b48dcbeb379e6cd1f29159dc8cdacef3adab
https://github.com/modulusphp/support/blob/b5c5b48dcbeb379e6cd1f29159dc8cdacef3adab/Filesystem.php#L294-L319
train
black-lamp/blcms-cart
frontend/components/user/UserMailer.php
UserMailer.sendRecoveryMessage
public function sendRecoveryMessage($user, $token) { $mailVars = [ '{token}' => $token->url ]; /** * @var $mailTemplate Template */ $mailTemplate = \Yii::$app->get('emailTemplates') ->getTemplate('recovery', Language::getCurrent()->id); $mailTemplate->parseSubject($mailVars); $mailTemplate->parseBody($mailVars); return \Yii::$app->shopMailer->compose('mail-body', ['bodyContent' => $mailTemplate->getBody()]) ->setFrom([\Yii::$app->shopMailer->transport->getUsername() => \Yii::$app->name ?? Url::to(['/'], true)]) ->setTo($user->email) ->setSubject($mailTemplate->getSubject()) ->send(); }
php
public function sendRecoveryMessage($user, $token) { $mailVars = [ '{token}' => $token->url ]; /** * @var $mailTemplate Template */ $mailTemplate = \Yii::$app->get('emailTemplates') ->getTemplate('recovery', Language::getCurrent()->id); $mailTemplate->parseSubject($mailVars); $mailTemplate->parseBody($mailVars); return \Yii::$app->shopMailer->compose('mail-body', ['bodyContent' => $mailTemplate->getBody()]) ->setFrom([\Yii::$app->shopMailer->transport->getUsername() => \Yii::$app->name ?? Url::to(['/'], true)]) ->setTo($user->email) ->setSubject($mailTemplate->getSubject()) ->send(); }
[ "public", "function", "sendRecoveryMessage", "(", "$", "user", ",", "$", "token", ")", "{", "$", "mailVars", "=", "[", "'{token}'", "=>", "$", "token", "->", "url", "]", ";", "/**\n * @var $mailTemplate Template\n */", "$", "mailTemplate", "=", "\\", "Yii", "::", "$", "app", "->", "get", "(", "'emailTemplates'", ")", "->", "getTemplate", "(", "'recovery'", ",", "Language", "::", "getCurrent", "(", ")", "->", "id", ")", ";", "$", "mailTemplate", "->", "parseSubject", "(", "$", "mailVars", ")", ";", "$", "mailTemplate", "->", "parseBody", "(", "$", "mailVars", ")", ";", "return", "\\", "Yii", "::", "$", "app", "->", "shopMailer", "->", "compose", "(", "'mail-body'", ",", "[", "'bodyContent'", "=>", "$", "mailTemplate", "->", "getBody", "(", ")", "]", ")", "->", "setFrom", "(", "[", "\\", "Yii", "::", "$", "app", "->", "shopMailer", "->", "transport", "->", "getUsername", "(", ")", "=>", "\\", "Yii", "::", "$", "app", "->", "name", "??", "Url", "::", "to", "(", "[", "'/'", "]", ",", "true", ")", "]", ")", "->", "setTo", "(", "$", "user", "->", "email", ")", "->", "setSubject", "(", "$", "mailTemplate", "->", "getSubject", "(", ")", ")", "->", "send", "(", ")", ";", "}" ]
Sends an email to a user with recovery link. @param User $user @param Token $token @return bool
[ "Sends", "an", "email", "to", "a", "user", "with", "recovery", "link", "." ]
314796eecae3ca4ed5fecfdc0231a738af50eba7
https://github.com/black-lamp/blcms-cart/blob/314796eecae3ca4ed5fecfdc0231a738af50eba7/frontend/components/user/UserMailer.php#L211-L230
train
swaros/golib
src/Content/Dom/XmlSimple.php
XmlSimple.getNodeContent
public function getNodeContent($xPath){ if ($this->content->xpath($xPath) !== null){ return (string)trim(end($this->content->xpath($xPath))); } return false; }
php
public function getNodeContent($xPath){ if ($this->content->xpath($xPath) !== null){ return (string)trim(end($this->content->xpath($xPath))); } return false; }
[ "public", "function", "getNodeContent", "(", "$", "xPath", ")", "{", "if", "(", "$", "this", "->", "content", "->", "xpath", "(", "$", "xPath", ")", "!==", "null", ")", "{", "return", "(", "string", ")", "trim", "(", "end", "(", "$", "this", "->", "content", "->", "xpath", "(", "$", "xPath", ")", ")", ")", ";", "}", "return", "false", ";", "}" ]
get the content or false of node. in case of fasle there is no node exists @param type $xPath @return string/boolean
[ "get", "the", "content", "or", "false", "of", "node", ".", "in", "case", "of", "fasle", "there", "is", "no", "node", "exists" ]
9e75c8fb36de7c09b01a6c1c0d27c45f02fed567
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Content/Dom/XmlSimple.php#L31-L36
train
swaros/golib
src/Content/Dom/XmlSimple.php
XmlSimple.getNodeAttribute
public function getNodeAttribute($xPath,$atrName){ $res = $this->content->xpath($xPath); if ($res !== null){ foreach ($res as $set){ return (string)$set[$atrName]; } } return NULL; }
php
public function getNodeAttribute($xPath,$atrName){ $res = $this->content->xpath($xPath); if ($res !== null){ foreach ($res as $set){ return (string)$set[$atrName]; } } return NULL; }
[ "public", "function", "getNodeAttribute", "(", "$", "xPath", ",", "$", "atrName", ")", "{", "$", "res", "=", "$", "this", "->", "content", "->", "xpath", "(", "$", "xPath", ")", ";", "if", "(", "$", "res", "!==", "null", ")", "{", "foreach", "(", "$", "res", "as", "$", "set", ")", "{", "return", "(", "string", ")", "$", "set", "[", "$", "atrName", "]", ";", "}", "}", "return", "NULL", ";", "}" ]
reads an spcific attribute from node @param type $xPath @param type $atrName @return string
[ "reads", "an", "spcific", "attribute", "from", "node" ]
9e75c8fb36de7c09b01a6c1c0d27c45f02fed567
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Content/Dom/XmlSimple.php#L95-L105
train
swaros/golib
src/Content/Dom/XmlSimple.php
XmlSimple.getNodeAttributeBool
public function getNodeAttributeBool($xPath,$atrName,$failReturn = false){ $val = $this->getNodeAttribute($xPath, $atrName); // string sets true/false if (strtolower($val) === 'false'){ return false; } if (strtolower($val) === 'true'){ return true; } if ($val === NULL || !is_bool($val)){ return $failReturn; } return (bool) $val; }
php
public function getNodeAttributeBool($xPath,$atrName,$failReturn = false){ $val = $this->getNodeAttribute($xPath, $atrName); // string sets true/false if (strtolower($val) === 'false'){ return false; } if (strtolower($val) === 'true'){ return true; } if ($val === NULL || !is_bool($val)){ return $failReturn; } return (bool) $val; }
[ "public", "function", "getNodeAttributeBool", "(", "$", "xPath", ",", "$", "atrName", ",", "$", "failReturn", "=", "false", ")", "{", "$", "val", "=", "$", "this", "->", "getNodeAttribute", "(", "$", "xPath", ",", "$", "atrName", ")", ";", "// string sets true/false", "if", "(", "strtolower", "(", "$", "val", ")", "===", "'false'", ")", "{", "return", "false", ";", "}", "if", "(", "strtolower", "(", "$", "val", ")", "===", "'true'", ")", "{", "return", "true", ";", "}", "if", "(", "$", "val", "===", "NULL", "||", "!", "is_bool", "(", "$", "val", ")", ")", "{", "return", "$", "failReturn", ";", "}", "return", "(", "bool", ")", "$", "val", ";", "}" ]
return node attribut value in boolean @param type $xPath @param type $atrName @param type $failReturn @return boolean
[ "return", "node", "attribut", "value", "in", "boolean" ]
9e75c8fb36de7c09b01a6c1c0d27c45f02fed567
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Content/Dom/XmlSimple.php#L169-L183
train
PenoaksDev/Milky-Framework
src/Milky/Pagination/UrlWindowPresenterTrait.php
UrlWindowPresenterTrait.getLinks
protected function getLinks() { $html = ''; if (is_array($this->window['first'])) { $html .= $this->getUrlLinks($this->window['first']); } if (is_array($this->window['slider'])) { $html .= $this->getDots(); $html .= $this->getUrlLinks($this->window['slider']); } if (is_array($this->window['last'])) { $html .= $this->getDots(); $html .= $this->getUrlLinks($this->window['last']); } return $html; }
php
protected function getLinks() { $html = ''; if (is_array($this->window['first'])) { $html .= $this->getUrlLinks($this->window['first']); } if (is_array($this->window['slider'])) { $html .= $this->getDots(); $html .= $this->getUrlLinks($this->window['slider']); } if (is_array($this->window['last'])) { $html .= $this->getDots(); $html .= $this->getUrlLinks($this->window['last']); } return $html; }
[ "protected", "function", "getLinks", "(", ")", "{", "$", "html", "=", "''", ";", "if", "(", "is_array", "(", "$", "this", "->", "window", "[", "'first'", "]", ")", ")", "{", "$", "html", ".=", "$", "this", "->", "getUrlLinks", "(", "$", "this", "->", "window", "[", "'first'", "]", ")", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "window", "[", "'slider'", "]", ")", ")", "{", "$", "html", ".=", "$", "this", "->", "getDots", "(", ")", ";", "$", "html", ".=", "$", "this", "->", "getUrlLinks", "(", "$", "this", "->", "window", "[", "'slider'", "]", ")", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "window", "[", "'last'", "]", ")", ")", "{", "$", "html", ".=", "$", "this", "->", "getDots", "(", ")", ";", "$", "html", ".=", "$", "this", "->", "getUrlLinks", "(", "$", "this", "->", "window", "[", "'last'", "]", ")", ";", "}", "return", "$", "html", ";", "}" ]
Render the actual link slider. @return string
[ "Render", "the", "actual", "link", "slider", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Pagination/UrlWindowPresenterTrait.php#L10-L29
train
honey-comb/resources
src/Http/Controllers/Admin/HCResourceGrabPropertyController.php
HCResourceGrabPropertyController.index
public function index(): View { $config = [ 'title' => trans('HCResource::resource_grab_property.page_title'), 'url' => route('admin.api.resource.grab.property'), 'form' => route('admin.api.form-manager', ['resource.grab.property']), 'headers' => $this->getTableColumns(), 'actions' => ['search'] ]; return view('HCCore::admin.service.index', ['config' => $config]); }
php
public function index(): View { $config = [ 'title' => trans('HCResource::resource_grab_property.page_title'), 'url' => route('admin.api.resource.grab.property'), 'form' => route('admin.api.form-manager', ['resource.grab.property']), 'headers' => $this->getTableColumns(), 'actions' => ['search'] ]; return view('HCCore::admin.service.index', ['config' => $config]); }
[ "public", "function", "index", "(", ")", ":", "View", "{", "$", "config", "=", "[", "'title'", "=>", "trans", "(", "'HCResource::resource_grab_property.page_title'", ")", ",", "'url'", "=>", "route", "(", "'admin.api.resource.grab.property'", ")", ",", "'form'", "=>", "route", "(", "'admin.api.form-manager'", ",", "[", "'resource.grab.property'", "]", ")", ",", "'headers'", "=>", "$", "this", "->", "getTableColumns", "(", ")", ",", "'actions'", "=>", "[", "'search'", "]", "]", ";", "return", "view", "(", "'HCCore::admin.service.index'", ",", "[", "'config'", "=>", "$", "config", "]", ")", ";", "}" ]
Admin panel page view @return View
[ "Admin", "panel", "page", "view" ]
9b82eb2fd99be99edfdc4e76803d95caf981e14b
https://github.com/honey-comb/resources/blob/9b82eb2fd99be99edfdc4e76803d95caf981e14b/src/Http/Controllers/Admin/HCResourceGrabPropertyController.php#L55-L66
train
honey-comb/resources
src/Http/Controllers/Admin/HCResourceGrabPropertyController.php
HCResourceGrabPropertyController.getOptions
public function getOptions(HCResourceGrabPropertyRequest $request): JsonResponse { return response()->json( $this->service->getRepository()->getOptions($request) ); }
php
public function getOptions(HCResourceGrabPropertyRequest $request): JsonResponse { return response()->json( $this->service->getRepository()->getOptions($request) ); }
[ "public", "function", "getOptions", "(", "HCResourceGrabPropertyRequest", "$", "request", ")", ":", "JsonResponse", "{", "return", "response", "(", ")", "->", "json", "(", "$", "this", "->", "service", "->", "getRepository", "(", ")", "->", "getOptions", "(", "$", "request", ")", ")", ";", "}" ]
Create data list @param HCResourceGrabPropertyRequest $request @return JsonResponse
[ "Create", "data", "list" ]
9b82eb2fd99be99edfdc4e76803d95caf981e14b
https://github.com/honey-comb/resources/blob/9b82eb2fd99be99edfdc4e76803d95caf981e14b/src/Http/Controllers/Admin/HCResourceGrabPropertyController.php#L108-L113
train
rollerworks/search-core
SearchFactoryBuilder.php
SearchFactoryBuilder.addTypeExtensions
public function addTypeExtensions(array $typeExtensions) { foreach ($typeExtensions as $typeExtension) { $this->typeExtensions[$typeExtension->getExtendedType()][] = $typeExtension; } return $this; }
php
public function addTypeExtensions(array $typeExtensions) { foreach ($typeExtensions as $typeExtension) { $this->typeExtensions[$typeExtension->getExtendedType()][] = $typeExtension; } return $this; }
[ "public", "function", "addTypeExtensions", "(", "array", "$", "typeExtensions", ")", "{", "foreach", "(", "$", "typeExtensions", "as", "$", "typeExtension", ")", "{", "$", "this", "->", "typeExtensions", "[", "$", "typeExtension", "->", "getExtendedType", "(", ")", "]", "[", "]", "=", "$", "typeExtension", ";", "}", "return", "$", "this", ";", "}" ]
Adds a list of field type extension to the factory. @param FieldTypeExtension[] $typeExtensions @return static The builder
[ "Adds", "a", "list", "of", "field", "type", "extension", "to", "the", "factory", "." ]
6b5671b8c4d6298906ded768261b0a59845140fb
https://github.com/rollerworks/search-core/blob/6b5671b8c4d6298906ded768261b0a59845140fb/SearchFactoryBuilder.php#L149-L156
train
rollerworks/search-core
SearchFactoryBuilder.php
SearchFactoryBuilder.getSearchFactory
public function getSearchFactory(): SearchFactory { $extensions = $this->extensions; if (\count($this->types) > 0 || \count($this->typeExtensions) > 0) { $extensions[] = new PreloadedExtension($this->types, $this->typeExtensions); } $resolvedTypeFactory = $this->resolvedTypeFactory ?? new GenericResolvedFieldTypeFactory(); $registry = new GenericTypeRegistry($extensions, $resolvedTypeFactory); return new GenericSearchFactory($registry, $this->fieldSetRegistry ?? LazyFieldSetRegistry::create()); }
php
public function getSearchFactory(): SearchFactory { $extensions = $this->extensions; if (\count($this->types) > 0 || \count($this->typeExtensions) > 0) { $extensions[] = new PreloadedExtension($this->types, $this->typeExtensions); } $resolvedTypeFactory = $this->resolvedTypeFactory ?? new GenericResolvedFieldTypeFactory(); $registry = new GenericTypeRegistry($extensions, $resolvedTypeFactory); return new GenericSearchFactory($registry, $this->fieldSetRegistry ?? LazyFieldSetRegistry::create()); }
[ "public", "function", "getSearchFactory", "(", ")", ":", "SearchFactory", "{", "$", "extensions", "=", "$", "this", "->", "extensions", ";", "if", "(", "\\", "count", "(", "$", "this", "->", "types", ")", ">", "0", "||", "\\", "count", "(", "$", "this", "->", "typeExtensions", ")", ">", "0", ")", "{", "$", "extensions", "[", "]", "=", "new", "PreloadedExtension", "(", "$", "this", "->", "types", ",", "$", "this", "->", "typeExtensions", ")", ";", "}", "$", "resolvedTypeFactory", "=", "$", "this", "->", "resolvedTypeFactory", "??", "new", "GenericResolvedFieldTypeFactory", "(", ")", ";", "$", "registry", "=", "new", "GenericTypeRegistry", "(", "$", "extensions", ",", "$", "resolvedTypeFactory", ")", ";", "return", "new", "GenericSearchFactory", "(", "$", "registry", ",", "$", "this", "->", "fieldSetRegistry", "??", "LazyFieldSetRegistry", "::", "create", "(", ")", ")", ";", "}" ]
Builds and returns the factory.
[ "Builds", "and", "returns", "the", "factory", "." ]
6b5671b8c4d6298906ded768261b0a59845140fb
https://github.com/rollerworks/search-core/blob/6b5671b8c4d6298906ded768261b0a59845140fb/SearchFactoryBuilder.php#L161-L173
train
Vectrex/vxPHP
src/Image/ImageModifier.php
ImageModifier.watermark
public function watermark() { $args = func_get_args(); if(!count($args)) { throw new ImageModifierException('Insufficient arguments for watermarking.'); } if(!file_exists(realpath($args[0]))) { throw new ImageModifierException('Watermark file not found.'); } $todo = new \stdClass(); $todo->method = __FUNCTION__; $todo->parameters = array($args[0]); $this->queue[] = $todo; }
php
public function watermark() { $args = func_get_args(); if(!count($args)) { throw new ImageModifierException('Insufficient arguments for watermarking.'); } if(!file_exists(realpath($args[0]))) { throw new ImageModifierException('Watermark file not found.'); } $todo = new \stdClass(); $todo->method = __FUNCTION__; $todo->parameters = array($args[0]); $this->queue[] = $todo; }
[ "public", "function", "watermark", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "!", "count", "(", "$", "args", ")", ")", "{", "throw", "new", "ImageModifierException", "(", "'Insufficient arguments for watermarking.'", ")", ";", "}", "if", "(", "!", "file_exists", "(", "realpath", "(", "$", "args", "[", "0", "]", ")", ")", ")", "{", "throw", "new", "ImageModifierException", "(", "'Watermark file not found.'", ")", ";", "}", "$", "todo", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "todo", "->", "method", "=", "__FUNCTION__", ";", "$", "todo", "->", "parameters", "=", "array", "(", "$", "args", "[", "0", "]", ")", ";", "$", "this", "->", "queue", "[", "]", "=", "$", "todo", ";", "}" ]
adds a watermark-"command" to queue @param string $filename @throws ImageModifierException
[ "adds", "a", "watermark", "-", "command", "to", "queue" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Image/ImageModifier.php#L275-L294
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getVarcharSQLDeclarationSnippet
protected function getVarcharSQLDeclarationSnippet($length, $fixed) { if (!is_int($length) || (is_int($length) && ($length <= 0))) { throw PlatformException::invalidVarcharLength(); } if (!is_bool($fixed)) { throw PlatformException::invalidVarcharFixedFlag(); } if ($fixed) { return 'CHAR('.$length.')'; } return 'VARCHAR('.$length.')'; }
php
protected function getVarcharSQLDeclarationSnippet($length, $fixed) { if (!is_int($length) || (is_int($length) && ($length <= 0))) { throw PlatformException::invalidVarcharLength(); } if (!is_bool($fixed)) { throw PlatformException::invalidVarcharFixedFlag(); } if ($fixed) { return 'CHAR('.$length.')'; } return 'VARCHAR('.$length.')'; }
[ "protected", "function", "getVarcharSQLDeclarationSnippet", "(", "$", "length", ",", "$", "fixed", ")", "{", "if", "(", "!", "is_int", "(", "$", "length", ")", "||", "(", "is_int", "(", "$", "length", ")", "&&", "(", "$", "length", "<=", "0", ")", ")", ")", "{", "throw", "PlatformException", "::", "invalidVarcharLength", "(", ")", ";", "}", "if", "(", "!", "is_bool", "(", "$", "fixed", ")", ")", "{", "throw", "PlatformException", "::", "invalidVarcharFixedFlag", "(", ")", ";", "}", "if", "(", "$", "fixed", ")", "{", "return", "'CHAR('", ".", "$", "length", ".", "')'", ";", "}", "return", "'VARCHAR('", ".", "$", "length", ".", "')'", ";", "}" ]
Gets the varchar SQL declaration snippet. @param integer $length The varchar length. @param boolean $fixed TRUE if the varchar is fixed else FALSE. @throws \Fridge\DBAL\Exception\PlatformException If the length is not a positive integer or if the fixed flag is not a boolean. @return string The varchar SQL declaration snippet.
[ "Gets", "the", "varchar", "SQL", "declaration", "snippet", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1028-L1043
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getTransactionIsolationSQLDeclaration
protected function getTransactionIsolationSQLDeclaration($isolation) { if (!$this->supportTransactionIsolations()) { throw PlatformException::methodNotSupported(__METHOD__); } $availableIsolations = array( Connection::TRANSACTION_READ_COMMITTED, Connection::TRANSACTION_READ_UNCOMMITTED, Connection::TRANSACTION_REPEATABLE_READ, Connection::TRANSACTION_SERIALIZABLE, ); if (!in_array($isolation, $availableIsolations)) { throw PlatformException::transactionIsolationDoesNotExist($isolation); } return $isolation; }
php
protected function getTransactionIsolationSQLDeclaration($isolation) { if (!$this->supportTransactionIsolations()) { throw PlatformException::methodNotSupported(__METHOD__); } $availableIsolations = array( Connection::TRANSACTION_READ_COMMITTED, Connection::TRANSACTION_READ_UNCOMMITTED, Connection::TRANSACTION_REPEATABLE_READ, Connection::TRANSACTION_SERIALIZABLE, ); if (!in_array($isolation, $availableIsolations)) { throw PlatformException::transactionIsolationDoesNotExist($isolation); } return $isolation; }
[ "protected", "function", "getTransactionIsolationSQLDeclaration", "(", "$", "isolation", ")", "{", "if", "(", "!", "$", "this", "->", "supportTransactionIsolations", "(", ")", ")", "{", "throw", "PlatformException", "::", "methodNotSupported", "(", "__METHOD__", ")", ";", "}", "$", "availableIsolations", "=", "array", "(", "Connection", "::", "TRANSACTION_READ_COMMITTED", ",", "Connection", "::", "TRANSACTION_READ_UNCOMMITTED", ",", "Connection", "::", "TRANSACTION_REPEATABLE_READ", ",", "Connection", "::", "TRANSACTION_SERIALIZABLE", ",", ")", ";", "if", "(", "!", "in_array", "(", "$", "isolation", ",", "$", "availableIsolations", ")", ")", "{", "throw", "PlatformException", "::", "transactionIsolationDoesNotExist", "(", "$", "isolation", ")", ";", "}", "return", "$", "isolation", ";", "}" ]
Gets the transaction isolation SQL declaration. @param string $isolation The transaction isolation. @throws \Fridge\DBAL\Exception\PlatformException If the transactions isolcation is not supported. @throws \Fridge\DBAL\Exception\PlatformException If the isolation does not exist. @return string The transaction isolation SQL declaration.
[ "Gets", "the", "transaction", "isolation", "SQL", "declaration", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1055-L1073
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getColumnsSQLDeclaration
protected function getColumnsSQLDeclaration(array $columns) { $columnsDeclaration = array(); foreach ($columns as $column) { $columnsDeclaration[] = $this->getColumnSQLDeclaration($column); } return implode(', ', $columnsDeclaration); }
php
protected function getColumnsSQLDeclaration(array $columns) { $columnsDeclaration = array(); foreach ($columns as $column) { $columnsDeclaration[] = $this->getColumnSQLDeclaration($column); } return implode(', ', $columnsDeclaration); }
[ "protected", "function", "getColumnsSQLDeclaration", "(", "array", "$", "columns", ")", "{", "$", "columnsDeclaration", "=", "array", "(", ")", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "$", "columnsDeclaration", "[", "]", "=", "$", "this", "->", "getColumnSQLDeclaration", "(", "$", "column", ")", ";", "}", "return", "implode", "(", "', '", ",", "$", "columnsDeclaration", ")", ";", "}" ]
Gets the columns SQL declaration. @param array $columns The columns (An array of `Fridge\DBAL\Schema\Column`). @return string The columns SQL declaration.
[ "Gets", "the", "columns", "SQL", "declaration", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1082-L1091
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getColumnSQLDeclaration
protected function getColumnSQLDeclaration(Column $column) { $columnDeclaration = $column->getName().' '.$column->getType()->getSQLDeclaration($this, $column->toArray()); if ($column->isNotNull()) { $columnDeclaration .= ' NOT NULL'; } if ($column->getDefault() !== null) { $default = $column->getType()->convertToDatabaseValue($column->getDefault(), $this); $columnDeclaration .= ' DEFAULT '.$this->quote($default); } if ($this->supportInlineColumnComments() && ($this->hasCustomType($column->getType()->getName()) || ($column->getComment() !== null)) ) { $columnDeclaration .= ' COMMENT '.$this->getColumnCommentSQLDeclaration($column); } return $columnDeclaration; }
php
protected function getColumnSQLDeclaration(Column $column) { $columnDeclaration = $column->getName().' '.$column->getType()->getSQLDeclaration($this, $column->toArray()); if ($column->isNotNull()) { $columnDeclaration .= ' NOT NULL'; } if ($column->getDefault() !== null) { $default = $column->getType()->convertToDatabaseValue($column->getDefault(), $this); $columnDeclaration .= ' DEFAULT '.$this->quote($default); } if ($this->supportInlineColumnComments() && ($this->hasCustomType($column->getType()->getName()) || ($column->getComment() !== null)) ) { $columnDeclaration .= ' COMMENT '.$this->getColumnCommentSQLDeclaration($column); } return $columnDeclaration; }
[ "protected", "function", "getColumnSQLDeclaration", "(", "Column", "$", "column", ")", "{", "$", "columnDeclaration", "=", "$", "column", "->", "getName", "(", ")", ".", "' '", ".", "$", "column", "->", "getType", "(", ")", "->", "getSQLDeclaration", "(", "$", "this", ",", "$", "column", "->", "toArray", "(", ")", ")", ";", "if", "(", "$", "column", "->", "isNotNull", "(", ")", ")", "{", "$", "columnDeclaration", ".=", "' NOT NULL'", ";", "}", "if", "(", "$", "column", "->", "getDefault", "(", ")", "!==", "null", ")", "{", "$", "default", "=", "$", "column", "->", "getType", "(", ")", "->", "convertToDatabaseValue", "(", "$", "column", "->", "getDefault", "(", ")", ",", "$", "this", ")", ";", "$", "columnDeclaration", ".=", "' DEFAULT '", ".", "$", "this", "->", "quote", "(", "$", "default", ")", ";", "}", "if", "(", "$", "this", "->", "supportInlineColumnComments", "(", ")", "&&", "(", "$", "this", "->", "hasCustomType", "(", "$", "column", "->", "getType", "(", ")", "->", "getName", "(", ")", ")", "||", "(", "$", "column", "->", "getComment", "(", ")", "!==", "null", ")", ")", ")", "{", "$", "columnDeclaration", ".=", "' COMMENT '", ".", "$", "this", "->", "getColumnCommentSQLDeclaration", "(", "$", "column", ")", ";", "}", "return", "$", "columnDeclaration", ";", "}" ]
Gets the column SQL declaration. @param \Fridge\DBAL\Schema\Column $column The column. @return string The column SQL declaration.
[ "Gets", "the", "column", "SQL", "declaration", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1100-L1121
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getPrimaryKeySQLDeclaration
protected function getPrimaryKeySQLDeclaration(PrimaryKey $primaryKey) { if (!$this->supportPrimaryKeys()) { throw PlatformException::methodNotSupported(__METHOD__); } return 'CONSTRAINT '.$primaryKey->getName().' PRIMARY KEY ('.implode(', ', $primaryKey->getColumnNames()).')'; }
php
protected function getPrimaryKeySQLDeclaration(PrimaryKey $primaryKey) { if (!$this->supportPrimaryKeys()) { throw PlatformException::methodNotSupported(__METHOD__); } return 'CONSTRAINT '.$primaryKey->getName().' PRIMARY KEY ('.implode(', ', $primaryKey->getColumnNames()).')'; }
[ "protected", "function", "getPrimaryKeySQLDeclaration", "(", "PrimaryKey", "$", "primaryKey", ")", "{", "if", "(", "!", "$", "this", "->", "supportPrimaryKeys", "(", ")", ")", "{", "throw", "PlatformException", "::", "methodNotSupported", "(", "__METHOD__", ")", ";", "}", "return", "'CONSTRAINT '", ".", "$", "primaryKey", "->", "getName", "(", ")", ".", "' PRIMARY KEY ('", ".", "implode", "(", "', '", ",", "$", "primaryKey", "->", "getColumnNames", "(", ")", ")", ".", "')'", ";", "}" ]
Gets the primary key SQL declaration. @param \Fridge\DBAL\Schema\PrimaryKey $primaryKey The primary key. @throws \Fridge\DBAL\Exception\PlatformException If the platform does not support primary key. @return string The primary key SQL declaration.
[ "Gets", "the", "primary", "key", "SQL", "declaration", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1132-L1139
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getForeignKeySQLDeclaration
protected function getForeignKeySQLDeclaration(ForeignKey $foreignKey) { if (!$this->supportForeignKeys()) { throw PlatformException::methodNotSupported(__METHOD__); } return 'CONSTRAINT '.$foreignKey->getName(). ' FOREIGN KEY'. ' ('.implode(', ', $foreignKey->getLocalColumnNames()).')'. ' REFERENCES '.$foreignKey->getForeignTableName(). ' ('.implode(', ', $foreignKey->getForeignColumnNames()).')'. ' ON DELETE '.$foreignKey->getOnDelete(). ' ON UPDATE '.$foreignKey->getOnUpdate(); }
php
protected function getForeignKeySQLDeclaration(ForeignKey $foreignKey) { if (!$this->supportForeignKeys()) { throw PlatformException::methodNotSupported(__METHOD__); } return 'CONSTRAINT '.$foreignKey->getName(). ' FOREIGN KEY'. ' ('.implode(', ', $foreignKey->getLocalColumnNames()).')'. ' REFERENCES '.$foreignKey->getForeignTableName(). ' ('.implode(', ', $foreignKey->getForeignColumnNames()).')'. ' ON DELETE '.$foreignKey->getOnDelete(). ' ON UPDATE '.$foreignKey->getOnUpdate(); }
[ "protected", "function", "getForeignKeySQLDeclaration", "(", "ForeignKey", "$", "foreignKey", ")", "{", "if", "(", "!", "$", "this", "->", "supportForeignKeys", "(", ")", ")", "{", "throw", "PlatformException", "::", "methodNotSupported", "(", "__METHOD__", ")", ";", "}", "return", "'CONSTRAINT '", ".", "$", "foreignKey", "->", "getName", "(", ")", ".", "' FOREIGN KEY'", ".", "' ('", ".", "implode", "(", "', '", ",", "$", "foreignKey", "->", "getLocalColumnNames", "(", ")", ")", ".", "')'", ".", "' REFERENCES '", ".", "$", "foreignKey", "->", "getForeignTableName", "(", ")", ".", "' ('", ".", "implode", "(", "', '", ",", "$", "foreignKey", "->", "getForeignColumnNames", "(", ")", ")", ".", "')'", ".", "' ON DELETE '", ".", "$", "foreignKey", "->", "getOnDelete", "(", ")", ".", "' ON UPDATE '", ".", "$", "foreignKey", "->", "getOnUpdate", "(", ")", ";", "}" ]
Gets the foreign key SQL declaration. @param \Fridge\DBAL\Schema\ForeignKey $foreignKey The foreign key. @throws \Fridge\DBAL\Exception\PlatformException If the platform does not support foreign key. @return string The foreign key SQL declaration.
[ "Gets", "the", "foreign", "key", "SQL", "declaration", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1150-L1163
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getIndexSQLDeclaration
protected function getIndexSQLDeclaration(Index $index) { if (!$this->supportIndexes()) { throw PlatformException::methodNotSupported(__METHOD__); } if (!$index->isUnique()) { return 'INDEX '.$index->getName().' ('.implode(', ', $index->getColumnNames()).')'; } return 'CONSTRAINT '.$index->getName().' UNIQUE ('.implode(', ', $index->getColumnNames()).')'; }
php
protected function getIndexSQLDeclaration(Index $index) { if (!$this->supportIndexes()) { throw PlatformException::methodNotSupported(__METHOD__); } if (!$index->isUnique()) { return 'INDEX '.$index->getName().' ('.implode(', ', $index->getColumnNames()).')'; } return 'CONSTRAINT '.$index->getName().' UNIQUE ('.implode(', ', $index->getColumnNames()).')'; }
[ "protected", "function", "getIndexSQLDeclaration", "(", "Index", "$", "index", ")", "{", "if", "(", "!", "$", "this", "->", "supportIndexes", "(", ")", ")", "{", "throw", "PlatformException", "::", "methodNotSupported", "(", "__METHOD__", ")", ";", "}", "if", "(", "!", "$", "index", "->", "isUnique", "(", ")", ")", "{", "return", "'INDEX '", ".", "$", "index", "->", "getName", "(", ")", ".", "' ('", ".", "implode", "(", "', '", ",", "$", "index", "->", "getColumnNames", "(", ")", ")", ".", "')'", ";", "}", "return", "'CONSTRAINT '", ".", "$", "index", "->", "getName", "(", ")", ".", "' UNIQUE ('", ".", "implode", "(", "', '", ",", "$", "index", "->", "getColumnNames", "(", ")", ")", ".", "')'", ";", "}" ]
Gets the index SQL declaration. @param \Fridge\DBAl\Schema\Index $index The index. @throws \Fridge\DBAL\Exception\PlatformException If the platform does not support index. @return string The index SQL declaration.
[ "Gets", "the", "index", "SQL", "declaration", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1174-L1185
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getCheckSQLDeclaration
protected function getCheckSQLDeclaration(Check $check) { if (!$this->supportChecks()) { throw PlatformException::methodNotSupported(__METHOD__); } return 'CONSTRAINT '.$check->getName().' CHECK ('.$check->getDefinition().')'; }
php
protected function getCheckSQLDeclaration(Check $check) { if (!$this->supportChecks()) { throw PlatformException::methodNotSupported(__METHOD__); } return 'CONSTRAINT '.$check->getName().' CHECK ('.$check->getDefinition().')'; }
[ "protected", "function", "getCheckSQLDeclaration", "(", "Check", "$", "check", ")", "{", "if", "(", "!", "$", "this", "->", "supportChecks", "(", ")", ")", "{", "throw", "PlatformException", "::", "methodNotSupported", "(", "__METHOD__", ")", ";", "}", "return", "'CONSTRAINT '", ".", "$", "check", "->", "getName", "(", ")", ".", "' CHECK ('", ".", "$", "check", "->", "getDefinition", "(", ")", ".", "')'", ";", "}" ]
Gets the check constraint SQL declaration. @param \Fridge\DBAL\Schema\Check $check The check constraint. @throws \Fridge\DBAL\Exception\PlatformException If the platform does not support check. @return string The check constraint SQL declaration.
[ "Gets", "the", "check", "constraint", "SQL", "declaration", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1196-L1203
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getCreateColumnCommentsSQLQueries
protected function getCreateColumnCommentsSQLQueries(array $columns, $table) { $queries = array(); foreach ($columns as $column) { if ($this->hasCustomType($column->getType()->getName()) || ($column->getComment() !== null)) { $queries[] = $this->getCreateColumnCommentSQLQuery($column, $table); } } return $queries; }
php
protected function getCreateColumnCommentsSQLQueries(array $columns, $table) { $queries = array(); foreach ($columns as $column) { if ($this->hasCustomType($column->getType()->getName()) || ($column->getComment() !== null)) { $queries[] = $this->getCreateColumnCommentSQLQuery($column, $table); } } return $queries; }
[ "protected", "function", "getCreateColumnCommentsSQLQueries", "(", "array", "$", "columns", ",", "$", "table", ")", "{", "$", "queries", "=", "array", "(", ")", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "if", "(", "$", "this", "->", "hasCustomType", "(", "$", "column", "->", "getType", "(", ")", "->", "getName", "(", ")", ")", "||", "(", "$", "column", "->", "getComment", "(", ")", "!==", "null", ")", ")", "{", "$", "queries", "[", "]", "=", "$", "this", "->", "getCreateColumnCommentSQLQuery", "(", "$", "column", ",", "$", "table", ")", ";", "}", "}", "return", "$", "queries", ";", "}" ]
Gets the create column comments SQL queries. @param array $columns The columns (An array of `Fridge\DBAL\Schema\Column`). @param string $table The table name. @return array The create column comments SQL queries.
[ "Gets", "the", "create", "column", "comments", "SQL", "queries", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1213-L1224
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getCreateColumnCommentSQLQuery
protected function getCreateColumnCommentSQLQuery(Column $column, $table) { return 'COMMENT ON COLUMN '.$table.'.'.$column->getName().' IS '.$this->getColumnCommentSQLDeclaration($column); }
php
protected function getCreateColumnCommentSQLQuery(Column $column, $table) { return 'COMMENT ON COLUMN '.$table.'.'.$column->getName().' IS '.$this->getColumnCommentSQLDeclaration($column); }
[ "protected", "function", "getCreateColumnCommentSQLQuery", "(", "Column", "$", "column", ",", "$", "table", ")", "{", "return", "'COMMENT ON COLUMN '", ".", "$", "table", ".", "'.'", ".", "$", "column", "->", "getName", "(", ")", ".", "' IS '", ".", "$", "this", "->", "getColumnCommentSQLDeclaration", "(", "$", "column", ")", ";", "}" ]
Gets the create column comment SQL query. @param \Fridge\DBAL\Schema\Column $column The column. @param string $table The table name. @return string The create column comment SQL query.
[ "Gets", "the", "create", "column", "comment", "SQL", "query", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1234-L1237
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getColumnCommentSQLDeclaration
protected function getColumnCommentSQLDeclaration(Column $column) { $comment = $column->getComment(); if ($this->hasCustomType($column->getType()->getName())) { $comment .= '(FridgeType::'.strtoupper($column->getType()->getName()).')'; } return $this->quote($comment); }
php
protected function getColumnCommentSQLDeclaration(Column $column) { $comment = $column->getComment(); if ($this->hasCustomType($column->getType()->getName())) { $comment .= '(FridgeType::'.strtoupper($column->getType()->getName()).')'; } return $this->quote($comment); }
[ "protected", "function", "getColumnCommentSQLDeclaration", "(", "Column", "$", "column", ")", "{", "$", "comment", "=", "$", "column", "->", "getComment", "(", ")", ";", "if", "(", "$", "this", "->", "hasCustomType", "(", "$", "column", "->", "getType", "(", ")", "->", "getName", "(", ")", ")", ")", "{", "$", "comment", ".=", "'(FridgeType::'", ".", "strtoupper", "(", "$", "column", "->", "getType", "(", ")", "->", "getName", "(", ")", ")", ".", "')'", ";", "}", "return", "$", "this", "->", "quote", "(", "$", "comment", ")", ";", "}" ]
Gets the column comment SQL declaration. @param \Fridge\DBAL\Schema\Column $column The column. @return string The column comment SQL declaration.
[ "Gets", "the", "column", "comment", "SQL", "declaration", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1246-L1255
train
fridge-project/dbal
src/Fridge/DBAL/Platform/AbstractPlatform.php
AbstractPlatform.getAlterTableSQLQuery
protected function getAlterTableSQLQuery($table, $action, $expression = null) { $alterTable = 'ALTER TABLE '.$table.' '.$action; return $expression !== null ? $alterTable.' '.$expression : $alterTable; }
php
protected function getAlterTableSQLQuery($table, $action, $expression = null) { $alterTable = 'ALTER TABLE '.$table.' '.$action; return $expression !== null ? $alterTable.' '.$expression : $alterTable; }
[ "protected", "function", "getAlterTableSQLQuery", "(", "$", "table", ",", "$", "action", ",", "$", "expression", "=", "null", ")", "{", "$", "alterTable", "=", "'ALTER TABLE '", ".", "$", "table", ".", "' '", ".", "$", "action", ";", "return", "$", "expression", "!==", "null", "?", "$", "alterTable", ".", "' '", ".", "$", "expression", ":", "$", "alterTable", ";", "}" ]
Gets an alter table SQL query. @param string $table The table name. @param string $action The alter table action (ADD, DROP, ...). @param string $expression The alter table expression. @return string The alter table query.
[ "Gets", "an", "alter", "table", "SQL", "query", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Platform/AbstractPlatform.php#L1266-L1271
train
lightwerk/SurfTasks
Classes/Lightwerk/SurfTasks/Task/LockFile/CreateTask.php
CreateTask.rollback
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = []) { $this->removeFile( rtrim($application->getReleasesPath(), '/').'/'.$this->getTargetPath($options), $node, $deployment, $options ); $this->removeFile( rtrim($deployment->getWorkspacePath($application), '/').'/'.$this->getTargetPath($options), $deployment->getNode('localhost'), $deployment, $options ); }
php
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = []) { $this->removeFile( rtrim($application->getReleasesPath(), '/').'/'.$this->getTargetPath($options), $node, $deployment, $options ); $this->removeFile( rtrim($deployment->getWorkspacePath($application), '/').'/'.$this->getTargetPath($options), $deployment->getNode('localhost'), $deployment, $options ); }
[ "public", "function", "rollback", "(", "Node", "$", "node", ",", "Application", "$", "application", ",", "Deployment", "$", "deployment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "removeFile", "(", "rtrim", "(", "$", "application", "->", "getReleasesPath", "(", ")", ",", "'/'", ")", ".", "'/'", ".", "$", "this", "->", "getTargetPath", "(", "$", "options", ")", ",", "$", "node", ",", "$", "deployment", ",", "$", "options", ")", ";", "$", "this", "->", "removeFile", "(", "rtrim", "(", "$", "deployment", "->", "getWorkspacePath", "(", "$", "application", ")", ",", "'/'", ")", ".", "'/'", ".", "$", "this", "->", "getTargetPath", "(", "$", "options", ")", ",", "$", "deployment", "->", "getNode", "(", "'localhost'", ")", ",", "$", "deployment", ",", "$", "options", ")", ";", "}" ]
Rollback this task. @param \TYPO3\Surf\Domain\Model\Node $node @param \TYPO3\Surf\Domain\Model\Application $application @param \TYPO3\Surf\Domain\Model\Deployment $deployment @param array $options
[ "Rollback", "this", "task", "." ]
8a6e4c85e42c762ad6515778c3fc7e19052cd9d1
https://github.com/lightwerk/SurfTasks/blob/8a6e4c85e42c762ad6515778c3fc7e19052cd9d1/Classes/Lightwerk/SurfTasks/Task/LockFile/CreateTask.php#L84-L99
train
fulgurio/LightCMSBundle
Controller/AdminMediaController.php
AdminMediaController.createMedia
private function createMedia(Media $media) { $request = $this->getRequest(); $thumbSizes = $this->container->getParameter('fulgurio_light_cms.thumbs'); $form = $this->createForm(new AdminMediaType($this->container), $media); $formHandler = new AdminMediaHandler(); $formHandler->setForm($form) ->setRequest($request) ->setDoctrine($this->getDoctrine()) ->setUser($this->getUser()) ->setMediaLibraryService($this->get('fulgurio_light_cms.media_library')); if ($formHandler->process($media)) { if ($request->isXmlHttpRequest()) { return $this->jsonResponse((object) array('files' => array( (object) array( 'id' => $media->getId(), 'name' => $media->getOriginalName(), 'url' => $media->getFullPath(), 'thumbnail_url' => LightCMSUtils::getThumbFilename($media->getFullPath(), $media->getMediaType(), $thumbSizes['medium']), 'delete_url' => $this->generateUrl('AdminMediasRemove', array('mediaId' => $media->getId(), 'confirm' => 'yes')), 'delete_type' => 'GET' ) ))); } $this->get('session')->getFlashBag()->add( 'success', $this->get('translator')->trans( isset($options['pageId']) ? 'fulgurio.lightcms.medias.edit_form.success_msg' : 'fulgurio.lightcms.medias.add_form.success_msg', array(), 'admin' ) ); return $this->redirect($this->generateUrl('AdminMedias')); } else if ($request->isXmlHttpRequest()) { //@todo : well, we only manage one error, not the others ... return $this->jsonResponse((object) array('files' => array( (object) array( 'error' => $this->get('translator')->trans('fulgurio.lightcms.medias.add_form.error_msg', array('%MAX_FILE_SIZE%' => ini_get('upload_max_filesize')), 'admin'), ) ))); } $options['form'] = $form->createView(); return $this->render('FulgurioLightCMSBundle:AdminMedia:add.html.twig', $options); }
php
private function createMedia(Media $media) { $request = $this->getRequest(); $thumbSizes = $this->container->getParameter('fulgurio_light_cms.thumbs'); $form = $this->createForm(new AdminMediaType($this->container), $media); $formHandler = new AdminMediaHandler(); $formHandler->setForm($form) ->setRequest($request) ->setDoctrine($this->getDoctrine()) ->setUser($this->getUser()) ->setMediaLibraryService($this->get('fulgurio_light_cms.media_library')); if ($formHandler->process($media)) { if ($request->isXmlHttpRequest()) { return $this->jsonResponse((object) array('files' => array( (object) array( 'id' => $media->getId(), 'name' => $media->getOriginalName(), 'url' => $media->getFullPath(), 'thumbnail_url' => LightCMSUtils::getThumbFilename($media->getFullPath(), $media->getMediaType(), $thumbSizes['medium']), 'delete_url' => $this->generateUrl('AdminMediasRemove', array('mediaId' => $media->getId(), 'confirm' => 'yes')), 'delete_type' => 'GET' ) ))); } $this->get('session')->getFlashBag()->add( 'success', $this->get('translator')->trans( isset($options['pageId']) ? 'fulgurio.lightcms.medias.edit_form.success_msg' : 'fulgurio.lightcms.medias.add_form.success_msg', array(), 'admin' ) ); return $this->redirect($this->generateUrl('AdminMedias')); } else if ($request->isXmlHttpRequest()) { //@todo : well, we only manage one error, not the others ... return $this->jsonResponse((object) array('files' => array( (object) array( 'error' => $this->get('translator')->trans('fulgurio.lightcms.medias.add_form.error_msg', array('%MAX_FILE_SIZE%' => ini_get('upload_max_filesize')), 'admin'), ) ))); } $options['form'] = $form->createView(); return $this->render('FulgurioLightCMSBundle:AdminMedia:add.html.twig', $options); }
[ "private", "function", "createMedia", "(", "Media", "$", "media", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "thumbSizes", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'fulgurio_light_cms.thumbs'", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "AdminMediaType", "(", "$", "this", "->", "container", ")", ",", "$", "media", ")", ";", "$", "formHandler", "=", "new", "AdminMediaHandler", "(", ")", ";", "$", "formHandler", "->", "setForm", "(", "$", "form", ")", "->", "setRequest", "(", "$", "request", ")", "->", "setDoctrine", "(", "$", "this", "->", "getDoctrine", "(", ")", ")", "->", "setUser", "(", "$", "this", "->", "getUser", "(", ")", ")", "->", "setMediaLibraryService", "(", "$", "this", "->", "get", "(", "'fulgurio_light_cms.media_library'", ")", ")", ";", "if", "(", "$", "formHandler", "->", "process", "(", "$", "media", ")", ")", "{", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "return", "$", "this", "->", "jsonResponse", "(", "(", "object", ")", "array", "(", "'files'", "=>", "array", "(", "(", "object", ")", "array", "(", "'id'", "=>", "$", "media", "->", "getId", "(", ")", ",", "'name'", "=>", "$", "media", "->", "getOriginalName", "(", ")", ",", "'url'", "=>", "$", "media", "->", "getFullPath", "(", ")", ",", "'thumbnail_url'", "=>", "LightCMSUtils", "::", "getThumbFilename", "(", "$", "media", "->", "getFullPath", "(", ")", ",", "$", "media", "->", "getMediaType", "(", ")", ",", "$", "thumbSizes", "[", "'medium'", "]", ")", ",", "'delete_url'", "=>", "$", "this", "->", "generateUrl", "(", "'AdminMediasRemove'", ",", "array", "(", "'mediaId'", "=>", "$", "media", "->", "getId", "(", ")", ",", "'confirm'", "=>", "'yes'", ")", ")", ",", "'delete_type'", "=>", "'GET'", ")", ")", ")", ")", ";", "}", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "isset", "(", "$", "options", "[", "'pageId'", "]", ")", "?", "'fulgurio.lightcms.medias.edit_form.success_msg'", ":", "'fulgurio.lightcms.medias.add_form.success_msg'", ",", "array", "(", ")", ",", "'admin'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'AdminMedias'", ")", ")", ";", "}", "else", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "//@todo : well, we only manage one error, not the others ...", "return", "$", "this", "->", "jsonResponse", "(", "(", "object", ")", "array", "(", "'files'", "=>", "array", "(", "(", "object", ")", "array", "(", "'error'", "=>", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'fulgurio.lightcms.medias.add_form.error_msg'", ",", "array", "(", "'%MAX_FILE_SIZE%'", "=>", "ini_get", "(", "'upload_max_filesize'", ")", ")", ",", "'admin'", ")", ",", ")", ")", ")", ")", ";", "}", "$", "options", "[", "'form'", "]", "=", "$", "form", "->", "createView", "(", ")", ";", "return", "$", "this", "->", "render", "(", "'FulgurioLightCMSBundle:AdminMedia:add.html.twig'", ",", "$", "options", ")", ";", "}" ]
Create form for media entity, use for edit or add a media @param Media $media @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
[ "Create", "form", "for", "media", "entity", "use", "for", "edit", "or", "add", "a", "media" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Controller/AdminMediaController.php#L101-L148
train
fulgurio/LightCMSBundle
Controller/AdminMediaController.php
AdminMediaController.removeAction
public function removeAction($mediaId) { $media = $this->getMedia($mediaId); $request = $this->getRequest(); if ($request->request->get('confirm') === 'yes' || $request->get('confirm') === 'yes') { $this->get('fulgurio_light_cms.media_library')->remove($media); $em = $this->getDoctrine()->getManager(); $em->remove($media); $em->flush(); return $this->redirect($this->generateUrl('AdminMedias')); } else if ($request->request->get('confirm') === 'no') { return $this->redirect($this->generateUrl('AdminMedias', array('mediaId' => $mediaId))); } $templateName = $request->isXmlHttpRequest() ? 'FulgurioLightCMSBundle::adminConfirmAjax.html.twig' : 'FulgurioLightCMSBundle::adminConfirm.html.twig'; return $this->render($templateName, array( 'action' => $this->generateUrl('AdminMediasRemove', array('mediaId' => $mediaId)), 'confirmationMessage' => $this->get('translator')->trans('fulgurio.lightcms.medias.delete_confirm_message', array('%FILENAME%' => $media->getOriginalName()), 'admin'), )); }
php
public function removeAction($mediaId) { $media = $this->getMedia($mediaId); $request = $this->getRequest(); if ($request->request->get('confirm') === 'yes' || $request->get('confirm') === 'yes') { $this->get('fulgurio_light_cms.media_library')->remove($media); $em = $this->getDoctrine()->getManager(); $em->remove($media); $em->flush(); return $this->redirect($this->generateUrl('AdminMedias')); } else if ($request->request->get('confirm') === 'no') { return $this->redirect($this->generateUrl('AdminMedias', array('mediaId' => $mediaId))); } $templateName = $request->isXmlHttpRequest() ? 'FulgurioLightCMSBundle::adminConfirmAjax.html.twig' : 'FulgurioLightCMSBundle::adminConfirm.html.twig'; return $this->render($templateName, array( 'action' => $this->generateUrl('AdminMediasRemove', array('mediaId' => $mediaId)), 'confirmationMessage' => $this->get('translator')->trans('fulgurio.lightcms.medias.delete_confirm_message', array('%FILENAME%' => $media->getOriginalName()), 'admin'), )); }
[ "public", "function", "removeAction", "(", "$", "mediaId", ")", "{", "$", "media", "=", "$", "this", "->", "getMedia", "(", "$", "mediaId", ")", ";", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "if", "(", "$", "request", "->", "request", "->", "get", "(", "'confirm'", ")", "===", "'yes'", "||", "$", "request", "->", "get", "(", "'confirm'", ")", "===", "'yes'", ")", "{", "$", "this", "->", "get", "(", "'fulgurio_light_cms.media_library'", ")", "->", "remove", "(", "$", "media", ")", ";", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "remove", "(", "$", "media", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'AdminMedias'", ")", ")", ";", "}", "else", "if", "(", "$", "request", "->", "request", "->", "get", "(", "'confirm'", ")", "===", "'no'", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'AdminMedias'", ",", "array", "(", "'mediaId'", "=>", "$", "mediaId", ")", ")", ")", ";", "}", "$", "templateName", "=", "$", "request", "->", "isXmlHttpRequest", "(", ")", "?", "'FulgurioLightCMSBundle::adminConfirmAjax.html.twig'", ":", "'FulgurioLightCMSBundle::adminConfirm.html.twig'", ";", "return", "$", "this", "->", "render", "(", "$", "templateName", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'AdminMediasRemove'", ",", "array", "(", "'mediaId'", "=>", "$", "mediaId", ")", ")", ",", "'confirmationMessage'", "=>", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'fulgurio.lightcms.medias.delete_confirm_message'", ",", "array", "(", "'%FILENAME%'", "=>", "$", "media", "->", "getOriginalName", "(", ")", ")", ",", "'admin'", ")", ",", ")", ")", ";", "}" ]
Remove media, with confirm form @param number $mediaId
[ "Remove", "media", "with", "confirm", "form" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Controller/AdminMediaController.php#L155-L176
train
fulgurio/LightCMSBundle
Controller/AdminMediaController.php
AdminMediaController.wysiwygMediaAction
public function wysiwygMediaAction() { $form = $this->createForm(new AdminMediaType($this->container), new Media()); return $this->render( 'FulgurioLightCMSBundle:AdminMedia:wysiwygAdd.html.twig', array( 'form' => $form->createView(), 'wysiwyg' => $this->getWysiwyg() ) ); }
php
public function wysiwygMediaAction() { $form = $this->createForm(new AdminMediaType($this->container), new Media()); return $this->render( 'FulgurioLightCMSBundle:AdminMedia:wysiwygAdd.html.twig', array( 'form' => $form->createView(), 'wysiwyg' => $this->getWysiwyg() ) ); }
[ "public", "function", "wysiwygMediaAction", "(", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "AdminMediaType", "(", "$", "this", "->", "container", ")", ",", "new", "Media", "(", ")", ")", ";", "return", "$", "this", "->", "render", "(", "'FulgurioLightCMSBundle:AdminMedia:wysiwygAdd.html.twig'", ",", "array", "(", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'wysiwyg'", "=>", "$", "this", "->", "getWysiwyg", "(", ")", ")", ")", ";", "}" ]
Wysiwyg media popup @return \Symfony\Component\HttpFoundation\Response
[ "Wysiwyg", "media", "popup" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Controller/AdminMediaController.php#L183-L193
train
fulgurio/LightCMSBundle
Controller/AdminMediaController.php
AdminMediaController.wysiwygLinkAction
public function wysiwygLinkAction() { $form = $this->createForm(new AdminMediaType($this->container), new Media()); return $this->render( 'FulgurioLightCMSBundle:AdminMedia:wysiwygAdd.html.twig', array( 'form' => $form->createView(), 'wysiwyg' => $this->getWysiwyg(), 'isLink' => TRUE ) ); }
php
public function wysiwygLinkAction() { $form = $this->createForm(new AdminMediaType($this->container), new Media()); return $this->render( 'FulgurioLightCMSBundle:AdminMedia:wysiwygAdd.html.twig', array( 'form' => $form->createView(), 'wysiwyg' => $this->getWysiwyg(), 'isLink' => TRUE ) ); }
[ "public", "function", "wysiwygLinkAction", "(", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "AdminMediaType", "(", "$", "this", "->", "container", ")", ",", "new", "Media", "(", ")", ")", ";", "return", "$", "this", "->", "render", "(", "'FulgurioLightCMSBundle:AdminMedia:wysiwygAdd.html.twig'", ",", "array", "(", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'wysiwyg'", "=>", "$", "this", "->", "getWysiwyg", "(", ")", ",", "'isLink'", "=>", "TRUE", ")", ")", ";", "}" ]
Wysiwyg link popup @return \Symfony\Component\HttpFoundation\Response
[ "Wysiwyg", "link", "popup" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Controller/AdminMediaController.php#L200-L211
train
fulgurio/LightCMSBundle
Controller/AdminMediaController.php
AdminMediaController.getWysiwyg
private function getWysiwyg() { $wysiwygName = $this->container->getParameter('fulgurio_light_cms.wysiwyg'); if ($wysiwygName && $this->container->hasParameter($wysiwygName)) { return $this->container->getParameter($wysiwygName); } else { return NULL; } }
php
private function getWysiwyg() { $wysiwygName = $this->container->getParameter('fulgurio_light_cms.wysiwyg'); if ($wysiwygName && $this->container->hasParameter($wysiwygName)) { return $this->container->getParameter($wysiwygName); } else { return NULL; } }
[ "private", "function", "getWysiwyg", "(", ")", "{", "$", "wysiwygName", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'fulgurio_light_cms.wysiwyg'", ")", ";", "if", "(", "$", "wysiwygName", "&&", "$", "this", "->", "container", "->", "hasParameter", "(", "$", "wysiwygName", ")", ")", "{", "return", "$", "this", "->", "container", "->", "getParameter", "(", "$", "wysiwygName", ")", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Get specified wysiwig with configuration if set @return \Symfony\Component\DependencyInjection\mixed|NULL
[ "Get", "specified", "wysiwig", "with", "configuration", "if", "set" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Controller/AdminMediaController.php#L218-L229
train
fulgurio/LightCMSBundle
Controller/AdminMediaController.php
AdminMediaController.jsonResponse
private function jsonResponse($data) { $response = new Response(json_encode($data)); $response->headers->set('Content-Type', 'application/json'); return $response; }
php
private function jsonResponse($data) { $response = new Response(json_encode($data)); $response->headers->set('Content-Type', 'application/json'); return $response; }
[ "private", "function", "jsonResponse", "(", "$", "data", ")", "{", "$", "response", "=", "new", "Response", "(", "json_encode", "(", "$", "data", ")", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "return", "$", "response", ";", "}" ]
Return a JSON response @param void $data @return \Symfony\Component\HttpFoundation\Response
[ "Return", "a", "JSON", "response" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Controller/AdminMediaController.php#L257-L262
train