id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
235,800
mickeyhead7/mickeyhead7-rsvp
src/Response/JsonapiResponse.php
JsonApiResponse.getRelationships
private function getRelationships(Item $item) { if ($include_params = $this->resource->getIncludeParams()) { $item->setIncludeParams($include_params); return $item->getIncluded(); } return []; }
php
private function getRelationships(Item $item) { if ($include_params = $this->resource->getIncludeParams()) { $item->setIncludeParams($include_params); return $item->getIncluded(); } return []; }
[ "private", "function", "getRelationships", "(", "Item", "$", "item", ")", "{", "if", "(", "$", "include_params", "=", "$", "this", "->", "resource", "->", "getIncludeParams", "(", ")", ")", "{", "$", "item", "->", "setIncludeParams", "(", "$", "include_params", ")", ";", "return", "$", "item", "->", "getIncluded", "(", ")", ";", "}", "return", "[", "]", ";", "}" ]
Gets the related data for a resource item @param Item $item Resource item @return array|null Relationships data
[ "Gets", "the", "related", "data", "for", "a", "resource", "item" ]
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L180-L189
235,801
mickeyhead7/mickeyhead7-rsvp
src/Response/JsonapiResponse.php
JsonApiResponse.setMeta
public function setMeta() { if ($meta = $this->resource->getMeta()) { $this->meta = $meta; } else { unset($this->meta); } return $this; }
php
public function setMeta() { if ($meta = $this->resource->getMeta()) { $this->meta = $meta; } else { unset($this->meta); } return $this; }
[ "public", "function", "setMeta", "(", ")", "{", "if", "(", "$", "meta", "=", "$", "this", "->", "resource", "->", "getMeta", "(", ")", ")", "{", "$", "this", "->", "meta", "=", "$", "meta", ";", "}", "else", "{", "unset", "(", "$", "this", "->", "meta", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the response meta data @return $this Instance of self
[ "Set", "the", "response", "meta", "data" ]
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L196-L205
235,802
osflab/view
Table.php
Table.setLinkFieldKey
public function setLinkFieldKey($linkFieldKey) { if (!is_string($linkFieldKey)) { $msg = "Link field key must be a string"; throw new OpenStates_View_Exception($msg); } $this->linkFieldKey = $linkFieldKey; return $this; }
php
public function setLinkFieldKey($linkFieldKey) { if (!is_string($linkFieldKey)) { $msg = "Link field key must be a string"; throw new OpenStates_View_Exception($msg); } $this->linkFieldKey = $linkFieldKey; return $this; }
[ "public", "function", "setLinkFieldKey", "(", "$", "linkFieldKey", ")", "{", "if", "(", "!", "is_string", "(", "$", "linkFieldKey", ")", ")", "{", "$", "msg", "=", "\"Link field key must be a string\"", ";", "throw", "new", "OpenStates_View_Exception", "(", "$", "msg", ")", ";", "}", "$", "this", "->", "linkFieldKey", "=", "$", "linkFieldKey", ";", "return", "$", "this", ";", "}" ]
Set the link field key used by link pattern @param string $linkFieldKey @return $this
[ "Set", "the", "link", "field", "key", "used", "by", "link", "pattern" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Table.php#L280-L288
235,803
osflab/view
Table.php
Table.setLabelPrefix
public function setLabelPrefix($labelPrefix) { if (!is_string($labelPrefix)) { $msg = "Label prefix must be a string"; throw new OpenStates_View_Exception($msg); } $this->labelPrefix = $labelPrefix; return $this; }
php
public function setLabelPrefix($labelPrefix) { if (!is_string($labelPrefix)) { $msg = "Label prefix must be a string"; throw new OpenStates_View_Exception($msg); } $this->labelPrefix = $labelPrefix; return $this; }
[ "public", "function", "setLabelPrefix", "(", "$", "labelPrefix", ")", "{", "if", "(", "!", "is_string", "(", "$", "labelPrefix", ")", ")", "{", "$", "msg", "=", "\"Label prefix must be a string\"", ";", "throw", "new", "OpenStates_View_Exception", "(", "$", "msg", ")", ";", "}", "$", "this", "->", "labelPrefix", "=", "$", "labelPrefix", ";", "return", "$", "this", ";", "}" ]
Set the common label prefix @param string $labelPrefix @return $this
[ "Set", "the", "common", "label", "prefix" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Table.php#L319-L327
235,804
drmvc/config
src/Config/Config.php
Config.loadFile
private function loadFile(string $path) { if (!file_exists($path)) { throw new Exception('Configuration file "' . $path . '" is not found'); } if (!is_readable($path)) { throw new Exception('Configuration file "' . $path . '" is not readable'); } // Include file $content = include $path; if (!\is_array($content)) { throw new Exception("Passed file \"$path\" is not array"); } return $content; }
php
private function loadFile(string $path) { if (!file_exists($path)) { throw new Exception('Configuration file "' . $path . '" is not found'); } if (!is_readable($path)) { throw new Exception('Configuration file "' . $path . '" is not readable'); } // Include file $content = include $path; if (!\is_array($content)) { throw new Exception("Passed file \"$path\" is not array"); } return $content; }
[ "private", "function", "loadFile", "(", "string", "$", "path", ")", "{", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "Exception", "(", "'Configuration file \"'", ".", "$", "path", ".", "'\" is not found'", ")", ";", "}", "if", "(", "!", "is_readable", "(", "$", "path", ")", ")", "{", "throw", "new", "Exception", "(", "'Configuration file \"'", ".", "$", "path", ".", "'\" is not readable'", ")", ";", "}", "// Include file", "$", "content", "=", "include", "$", "path", ";", "if", "(", "!", "\\", "is_array", "(", "$", "content", ")", ")", "{", "throw", "new", "Exception", "(", "\"Passed file \\\"$path\\\" is not array\"", ")", ";", "}", "return", "$", "content", ";", "}" ]
Load parameters from filesystem @param string $path @return mixed @throws Exception
[ "Load", "parameters", "from", "filesystem" ]
f6278177eec9ed13ec3f8bb2b62633725f504526
https://github.com/drmvc/config/blob/f6278177eec9ed13ec3f8bb2b62633725f504526/src/Config/Config.php#L42-L60
235,805
drmvc/config
src/Config/Config.php
Config.load
public function load(string $path, string $key = null): ConfigInterface { try { // Read parameters from file $parameters = $this->loadFile($path); // If key is provided then need put parameters into subarray if (null !== $key) { $parameters = [$key => $parameters]; } // Keep configuration $this->setter($parameters); } catch (Exception $e) { // Error message implemented in exception } return $this; }
php
public function load(string $path, string $key = null): ConfigInterface { try { // Read parameters from file $parameters = $this->loadFile($path); // If key is provided then need put parameters into subarray if (null !== $key) { $parameters = [$key => $parameters]; } // Keep configuration $this->setter($parameters); } catch (Exception $e) { // Error message implemented in exception } return $this; }
[ "public", "function", "load", "(", "string", "$", "path", ",", "string", "$", "key", "=", "null", ")", ":", "ConfigInterface", "{", "try", "{", "// Read parameters from file", "$", "parameters", "=", "$", "this", "->", "loadFile", "(", "$", "path", ")", ";", "// If key is provided then need put parameters into subarray", "if", "(", "null", "!==", "$", "key", ")", "{", "$", "parameters", "=", "[", "$", "key", "=>", "$", "parameters", "]", ";", "}", "// Keep configuration", "$", "this", "->", "setter", "(", "$", "parameters", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "// Error message implemented in exception", "}", "return", "$", "this", ";", "}" ]
Load configuration file, show config path if needed @param string $path path to file with array @param string $key in which subkey this file must be saved @return ConfigInterface
[ "Load", "configuration", "file", "show", "config", "path", "if", "needed" ]
f6278177eec9ed13ec3f8bb2b62633725f504526
https://github.com/drmvc/config/blob/f6278177eec9ed13ec3f8bb2b62633725f504526/src/Config/Config.php#L69-L87
235,806
drmvc/config
src/Config/Config.php
Config.setter
private function setter(array $parameters) { // Parse array and set values array_map( function($key, $value) { $this->set($key, $value); }, array_keys($parameters), $parameters ); }
php
private function setter(array $parameters) { // Parse array and set values array_map( function($key, $value) { $this->set($key, $value); }, array_keys($parameters), $parameters ); }
[ "private", "function", "setter", "(", "array", "$", "parameters", ")", "{", "// Parse array and set values", "array_map", "(", "function", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", ",", "array_keys", "(", "$", "parameters", ")", ",", "$", "parameters", ")", ";", "}" ]
Put keys from array of parameters into internal array @param array $parameters
[ "Put", "keys", "from", "array", "of", "parameters", "into", "internal", "array" ]
f6278177eec9ed13ec3f8bb2b62633725f504526
https://github.com/drmvc/config/blob/f6278177eec9ed13ec3f8bb2b62633725f504526/src/Config/Config.php#L94-L104
235,807
drmvc/config
src/Config/Config.php
Config.set
public function set(string $key, $value): ConfigInterface { $this->_config[$key] = \is_array($value) ? new Config($value) : $value; return $this; }
php
public function set(string $key, $value): ConfigInterface { $this->_config[$key] = \is_array($value) ? new Config($value) : $value; return $this; }
[ "public", "function", "set", "(", "string", "$", "key", ",", "$", "value", ")", ":", "ConfigInterface", "{", "$", "this", "->", "_config", "[", "$", "key", "]", "=", "\\", "is_array", "(", "$", "value", ")", "?", "new", "Config", "(", "$", "value", ")", ":", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set some parameter of configuration @param string $key @param mixed $value @return ConfigInterface
[ "Set", "some", "parameter", "of", "configuration" ]
f6278177eec9ed13ec3f8bb2b62633725f504526
https://github.com/drmvc/config/blob/f6278177eec9ed13ec3f8bb2b62633725f504526/src/Config/Config.php#L113-L120
235,808
drmvc/config
src/Config/Config.php
Config.get
public function get(string $key = null) { $result = (null !== $key) ? $this->_config[$key] ?? null : $this->_config; return $result; }
php
public function get(string $key = null) { $result = (null !== $key) ? $this->_config[$key] ?? null : $this->_config; return $result; }
[ "public", "function", "get", "(", "string", "$", "key", "=", "null", ")", "{", "$", "result", "=", "(", "null", "!==", "$", "key", ")", "?", "$", "this", "->", "_config", "[", "$", "key", "]", "??", "null", ":", "$", "this", "->", "_config", ";", "return", "$", "result", ";", "}" ]
Get single parameter by name or null, or all available parameters @param string|null $key @return mixed
[ "Get", "single", "parameter", "by", "name", "or", "null", "or", "all", "available", "parameters" ]
f6278177eec9ed13ec3f8bb2b62633725f504526
https://github.com/drmvc/config/blob/f6278177eec9ed13ec3f8bb2b62633725f504526/src/Config/Config.php#L128-L135
235,809
drmvc/config
src/Config/Config.php
Config.clean
public function clean(string $key = null): ConfigInterface { if (null !== $key) { unset($this->_config[$key]); } else { $this->_config = []; } return $this; }
php
public function clean(string $key = null): ConfigInterface { if (null !== $key) { unset($this->_config[$key]); } else { $this->_config = []; } return $this; }
[ "public", "function", "clean", "(", "string", "$", "key", "=", "null", ")", ":", "ConfigInterface", "{", "if", "(", "null", "!==", "$", "key", ")", "{", "unset", "(", "$", "this", "->", "_config", "[", "$", "key", "]", ")", ";", "}", "else", "{", "$", "this", "->", "_config", "=", "[", "]", ";", "}", "return", "$", "this", ";", "}" ]
Remove single value or clean config @param string|null $key @return ConfigInterface
[ "Remove", "single", "value", "or", "clean", "config" ]
f6278177eec9ed13ec3f8bb2b62633725f504526
https://github.com/drmvc/config/blob/f6278177eec9ed13ec3f8bb2b62633725f504526/src/Config/Config.php#L143-L152
235,810
nano7/Foundation
src/Config/Repository.php
Repository.loadKey
protected function loadKey($key) { // Pegar soh o primeiro key $parts = explode('.', $key); $first = $parts[0]; // Verificar se item já foi adicionado if (array_key_exists($first, $this->items)) { return; } if (array_key_exists($first, $this->finded)) { return; } $file = config_path(sprintf('%s.php', $first)); if (file_exists($file)) { $this->set($first, require $file); } $this->finded[$first] = true; }
php
protected function loadKey($key) { // Pegar soh o primeiro key $parts = explode('.', $key); $first = $parts[0]; // Verificar se item já foi adicionado if (array_key_exists($first, $this->items)) { return; } if (array_key_exists($first, $this->finded)) { return; } $file = config_path(sprintf('%s.php', $first)); if (file_exists($file)) { $this->set($first, require $file); } $this->finded[$first] = true; }
[ "protected", "function", "loadKey", "(", "$", "key", ")", "{", "// Pegar soh o primeiro key", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "$", "first", "=", "$", "parts", "[", "0", "]", ";", "// Verificar se item já foi adicionado", "if", "(", "array_key_exists", "(", "$", "first", ",", "$", "this", "->", "items", ")", ")", "{", "return", ";", "}", "if", "(", "array_key_exists", "(", "$", "first", ",", "$", "this", "->", "finded", ")", ")", "{", "return", ";", "}", "$", "file", "=", "config_path", "(", "sprintf", "(", "'%s.php'", ",", "$", "first", ")", ")", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "$", "this", "->", "set", "(", "$", "first", ",", "require", "$", "file", ")", ";", "}", "$", "this", "->", "finded", "[", "$", "first", "]", "=", "true", ";", "}" ]
Load key. @param $key
[ "Load", "key", "." ]
8328423f81c69b8fabc04b4f6b1f3ba712695374
https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Config/Repository.php#L33-L54
235,811
academic/VipaImportBundle
Importer/PKP/JournalContactImporter.php
JournalContactImporter.importContacts
public function importContacts($journal, $journalId) { $this->consoleOutput->writeln("Importing journal's contacts..."); $settingsSql = "SELECT locale, setting_name, setting_value FROM journal_settings WHERE journal_id = :id"; $settingsStatement = $this->dbalConnection->prepare($settingsSql); $settingsStatement->bindValue('id', $journalId); $settingsStatement->execute(); $settings = array(); $pkpSettings = $settingsStatement->fetchAll(); foreach ($pkpSettings as $setting) { $name = $setting['setting_name']; $value = $setting['setting_value']; $settings[$name] = $value; } $contact = new JournalContact(); $contact->setFullName($settings['contactName']); $contact->setEmail($settings['contactEmail']); $contact->setPhone($settings['contactPhone']); $contact->setAddress($settings['contactMailingAddress']); $types = $this->em->getRepository('VipaJournalBundle:ContactTypes')->findAll(); !empty($types) && $contact->setContactType($types[0]); $journal->addJournalContact($contact); }
php
public function importContacts($journal, $journalId) { $this->consoleOutput->writeln("Importing journal's contacts..."); $settingsSql = "SELECT locale, setting_name, setting_value FROM journal_settings WHERE journal_id = :id"; $settingsStatement = $this->dbalConnection->prepare($settingsSql); $settingsStatement->bindValue('id', $journalId); $settingsStatement->execute(); $settings = array(); $pkpSettings = $settingsStatement->fetchAll(); foreach ($pkpSettings as $setting) { $name = $setting['setting_name']; $value = $setting['setting_value']; $settings[$name] = $value; } $contact = new JournalContact(); $contact->setFullName($settings['contactName']); $contact->setEmail($settings['contactEmail']); $contact->setPhone($settings['contactPhone']); $contact->setAddress($settings['contactMailingAddress']); $types = $this->em->getRepository('VipaJournalBundle:ContactTypes')->findAll(); !empty($types) && $contact->setContactType($types[0]); $journal->addJournalContact($contact); }
[ "public", "function", "importContacts", "(", "$", "journal", ",", "$", "journalId", ")", "{", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Importing journal's contacts...\"", ")", ";", "$", "settingsSql", "=", "\"SELECT locale, setting_name, setting_value FROM journal_settings WHERE journal_id = :id\"", ";", "$", "settingsStatement", "=", "$", "this", "->", "dbalConnection", "->", "prepare", "(", "$", "settingsSql", ")", ";", "$", "settingsStatement", "->", "bindValue", "(", "'id'", ",", "$", "journalId", ")", ";", "$", "settingsStatement", "->", "execute", "(", ")", ";", "$", "settings", "=", "array", "(", ")", ";", "$", "pkpSettings", "=", "$", "settingsStatement", "->", "fetchAll", "(", ")", ";", "foreach", "(", "$", "pkpSettings", "as", "$", "setting", ")", "{", "$", "name", "=", "$", "setting", "[", "'setting_name'", "]", ";", "$", "value", "=", "$", "setting", "[", "'setting_value'", "]", ";", "$", "settings", "[", "$", "name", "]", "=", "$", "value", ";", "}", "$", "contact", "=", "new", "JournalContact", "(", ")", ";", "$", "contact", "->", "setFullName", "(", "$", "settings", "[", "'contactName'", "]", ")", ";", "$", "contact", "->", "setEmail", "(", "$", "settings", "[", "'contactEmail'", "]", ")", ";", "$", "contact", "->", "setPhone", "(", "$", "settings", "[", "'contactPhone'", "]", ")", ";", "$", "contact", "->", "setAddress", "(", "$", "settings", "[", "'contactMailingAddress'", "]", ")", ";", "$", "types", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'VipaJournalBundle:ContactTypes'", ")", "->", "findAll", "(", ")", ";", "!", "empty", "(", "$", "types", ")", "&&", "$", "contact", "->", "setContactType", "(", "$", "types", "[", "0", "]", ")", ";", "$", "journal", "->", "addJournalContact", "(", "$", "contact", ")", ";", "}" ]
Imports contacts of the given journal. @param Journal $journal The journal whose contacts are going to be imported @param int $journalId Old ID of the journal @throws \Doctrine\DBAL\DBALException
[ "Imports", "contacts", "of", "the", "given", "journal", "." ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/JournalContactImporter.php#L17-L45
235,812
mithun12000/yii2-urlasset
src/component/UrlAsset.php
UrlAsset.setViewParams
public function setViewParams($view) { foreach ($this->url as $url) { if(isset($view->params['urls']) && is_array($view->params['urls'])){ $view->params['urls'] = $this->MenuMerge($view->params['urls'],$url); }else{ $view->params['urls'] = $url; } } if($module = $this->getModule()){ $view->params['urls'][$module]['active']=true; } }
php
public function setViewParams($view) { foreach ($this->url as $url) { if(isset($view->params['urls']) && is_array($view->params['urls'])){ $view->params['urls'] = $this->MenuMerge($view->params['urls'],$url); }else{ $view->params['urls'] = $url; } } if($module = $this->getModule()){ $view->params['urls'][$module]['active']=true; } }
[ "public", "function", "setViewParams", "(", "$", "view", ")", "{", "foreach", "(", "$", "this", "->", "url", "as", "$", "url", ")", "{", "if", "(", "isset", "(", "$", "view", "->", "params", "[", "'urls'", "]", ")", "&&", "is_array", "(", "$", "view", "->", "params", "[", "'urls'", "]", ")", ")", "{", "$", "view", "->", "params", "[", "'urls'", "]", "=", "$", "this", "->", "MenuMerge", "(", "$", "view", "->", "params", "[", "'urls'", "]", ",", "$", "url", ")", ";", "}", "else", "{", "$", "view", "->", "params", "[", "'urls'", "]", "=", "$", "url", ";", "}", "}", "if", "(", "$", "module", "=", "$", "this", "->", "getModule", "(", ")", ")", "{", "$", "view", "->", "params", "[", "'urls'", "]", "[", "$", "module", "]", "[", "'active'", "]", "=", "true", ";", "}", "}" ]
Registers url params on given View @param \yii\web\View $view the view that the asset files are to be registered with.
[ "Registers", "url", "params", "on", "given", "View" ]
d075092f461be216ae8e2b22920ffaf1dbe492e4
https://github.com/mithun12000/yii2-urlasset/blob/d075092f461be216ae8e2b22920ffaf1dbe492e4/src/component/UrlAsset.php#L107-L122
235,813
coolms/doctrine
src/Mapping/Dateable/Mapping/Event/Adapter/ORM.php
ORM.getObjectChangeSet
public function getObjectChangeSet($uow, $object) { $changeSet = parent::getObjectChangeSet($uow, $object); $meta = $this->getObjectManager()->getClassMetadata(get_class($object)); $refl = $meta->getReflectionClass(); $updates = $uow->getScheduledCollectionUpdates(); $delitions = $uow->getScheduledCollectionDeletions(); foreach ($meta->getAssociationNames() as $name) { if ($meta->isSingleValuedAssociation($name)) { continue; } $property = $refl->getProperty($name); $property->setAccessible(true); $assoc = $property->getValue($object); if (in_array($assoc, $updates, true) || in_array($assoc, $delitions, true)) { $changeSet[$name] = [$assoc, $assoc]; } } return $changeSet; }
php
public function getObjectChangeSet($uow, $object) { $changeSet = parent::getObjectChangeSet($uow, $object); $meta = $this->getObjectManager()->getClassMetadata(get_class($object)); $refl = $meta->getReflectionClass(); $updates = $uow->getScheduledCollectionUpdates(); $delitions = $uow->getScheduledCollectionDeletions(); foreach ($meta->getAssociationNames() as $name) { if ($meta->isSingleValuedAssociation($name)) { continue; } $property = $refl->getProperty($name); $property->setAccessible(true); $assoc = $property->getValue($object); if (in_array($assoc, $updates, true) || in_array($assoc, $delitions, true)) { $changeSet[$name] = [$assoc, $assoc]; } } return $changeSet; }
[ "public", "function", "getObjectChangeSet", "(", "$", "uow", ",", "$", "object", ")", "{", "$", "changeSet", "=", "parent", "::", "getObjectChangeSet", "(", "$", "uow", ",", "$", "object", ")", ";", "$", "meta", "=", "$", "this", "->", "getObjectManager", "(", ")", "->", "getClassMetadata", "(", "get_class", "(", "$", "object", ")", ")", ";", "$", "refl", "=", "$", "meta", "->", "getReflectionClass", "(", ")", ";", "$", "updates", "=", "$", "uow", "->", "getScheduledCollectionUpdates", "(", ")", ";", "$", "delitions", "=", "$", "uow", "->", "getScheduledCollectionDeletions", "(", ")", ";", "foreach", "(", "$", "meta", "->", "getAssociationNames", "(", ")", "as", "$", "name", ")", "{", "if", "(", "$", "meta", "->", "isSingleValuedAssociation", "(", "$", "name", ")", ")", "{", "continue", ";", "}", "$", "property", "=", "$", "refl", "->", "getProperty", "(", "$", "name", ")", ";", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "assoc", "=", "$", "property", "->", "getValue", "(", "$", "object", ")", ";", "if", "(", "in_array", "(", "$", "assoc", ",", "$", "updates", ",", "true", ")", "||", "in_array", "(", "$", "assoc", ",", "$", "delitions", ",", "true", ")", ")", "{", "$", "changeSet", "[", "$", "name", "]", "=", "[", "$", "assoc", ",", "$", "assoc", "]", ";", "}", "}", "return", "$", "changeSet", ";", "}" ]
Overriden. Added support for ManyToMany association changes {@inheritDoc}
[ "Overriden", ".", "Added", "support", "for", "ManyToMany", "association", "changes" ]
d7d233594b37cd0c3abc37a46e4e4b965767c3b4
https://github.com/coolms/doctrine/blob/d7d233594b37cd0c3abc37a46e4e4b965767c3b4/src/Mapping/Dateable/Mapping/Event/Adapter/ORM.php#L39-L60
235,814
vinala/kernel
src/Resources/Assets.php
Assets.css
public static function css($files, $nest = true) { if (is_array($files)) { foreach ($files as $file) { self::cssCall($file, $nest); } } elseif (is_string($files)) { self::cssCall($files, $nest); } }
php
public static function css($files, $nest = true) { if (is_array($files)) { foreach ($files as $file) { self::cssCall($file, $nest); } } elseif (is_string($files)) { self::cssCall($files, $nest); } }
[ "public", "static", "function", "css", "(", "$", "files", ",", "$", "nest", "=", "true", ")", "{", "if", "(", "is_array", "(", "$", "files", ")", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "self", "::", "cssCall", "(", "$", "file", ",", "$", "nest", ")", ";", "}", "}", "elseif", "(", "is_string", "(", "$", "files", ")", ")", "{", "self", "::", "cssCall", "(", "$", "files", ",", "$", "nest", ")", ";", "}", "}" ]
Call CSS files. @param string|array $files @param bool $nest @return string
[ "Call", "CSS", "files", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Resources/Assets.php#L30-L39
235,815
vinala/kernel
src/Resources/Assets.php
Assets.cssCall
public static function cssCall($file, $nest) { if (strpos($file, 'http://') !== false) { $path = $file.'.css'; } else { if ($nest) { $file = str_replace('.', '/', $file); $path = path().'assets/css/'.$file.'.css'; } else { $path = $file; } } self::cssTag($path); }
php
public static function cssCall($file, $nest) { if (strpos($file, 'http://') !== false) { $path = $file.'.css'; } else { if ($nest) { $file = str_replace('.', '/', $file); $path = path().'assets/css/'.$file.'.css'; } else { $path = $file; } } self::cssTag($path); }
[ "public", "static", "function", "cssCall", "(", "$", "file", ",", "$", "nest", ")", "{", "if", "(", "strpos", "(", "$", "file", ",", "'http://'", ")", "!==", "false", ")", "{", "$", "path", "=", "$", "file", ".", "'.css'", ";", "}", "else", "{", "if", "(", "$", "nest", ")", "{", "$", "file", "=", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "file", ")", ";", "$", "path", "=", "path", "(", ")", ".", "'assets/css/'", ".", "$", "file", ".", "'.css'", ";", "}", "else", "{", "$", "path", "=", "$", "file", ";", "}", "}", "self", "::", "cssTag", "(", "$", "path", ")", ";", "}" ]
The process to CSS HTML Tag. @param string $file @param bool $nest @return null
[ "The", "process", "to", "CSS", "HTML", "Tag", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Resources/Assets.php#L49-L63
235,816
vinala/kernel
src/Resources/Assets.php
Assets.js
public static function js($files, $nest = true) { if (is_array($files)) { foreach ($files as $file) { self::jsCall($file, $nest); } } elseif (is_string($files)) { self::jsCall($files, $nest); } }
php
public static function js($files, $nest = true) { if (is_array($files)) { foreach ($files as $file) { self::jsCall($file, $nest); } } elseif (is_string($files)) { self::jsCall($files, $nest); } }
[ "public", "static", "function", "js", "(", "$", "files", ",", "$", "nest", "=", "true", ")", "{", "if", "(", "is_array", "(", "$", "files", ")", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "self", "::", "jsCall", "(", "$", "file", ",", "$", "nest", ")", ";", "}", "}", "elseif", "(", "is_string", "(", "$", "files", ")", ")", "{", "self", "::", "jsCall", "(", "$", "files", ",", "$", "nest", ")", ";", "}", "}" ]
Call JS files. @param string|array $files @param bool $nest @return string
[ "Call", "JS", "files", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Resources/Assets.php#L85-L94
235,817
vinala/kernel
src/Resources/Assets.php
Assets.jsCall
public static function jsCall($file, $nest) { if (strpos($file, 'http://') !== false) { $path = $file.'.js'; } else { if ($nest) { $file = str_replace('.', '/', $file); $path = path().'assets/js/'.$file.'.js'; } else { $path = $file; } } self::jsTag($path); }
php
public static function jsCall($file, $nest) { if (strpos($file, 'http://') !== false) { $path = $file.'.js'; } else { if ($nest) { $file = str_replace('.', '/', $file); $path = path().'assets/js/'.$file.'.js'; } else { $path = $file; } } self::jsTag($path); }
[ "public", "static", "function", "jsCall", "(", "$", "file", ",", "$", "nest", ")", "{", "if", "(", "strpos", "(", "$", "file", ",", "'http://'", ")", "!==", "false", ")", "{", "$", "path", "=", "$", "file", ".", "'.js'", ";", "}", "else", "{", "if", "(", "$", "nest", ")", "{", "$", "file", "=", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "file", ")", ";", "$", "path", "=", "path", "(", ")", ".", "'assets/js/'", ".", "$", "file", ".", "'.js'", ";", "}", "else", "{", "$", "path", "=", "$", "file", ";", "}", "}", "self", "::", "jsTag", "(", "$", "path", ")", ";", "}" ]
The process to JS HTML Tag. @param string $file @param bool $nest @return null
[ "The", "process", "to", "JS", "HTML", "Tag", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Resources/Assets.php#L104-L118
235,818
oromedialab/zf2-lazy-form
src/Service/ModuleService.php
ModuleService.defaultConfig
public function defaultConfig($name) { $config = $this->config(); $default = array_key_exists('default', $config) ? $config['default'] : array(); if (!array_key_exists($name, $default)) { return array(); } return $default[$name]; }
php
public function defaultConfig($name) { $config = $this->config(); $default = array_key_exists('default', $config) ? $config['default'] : array(); if (!array_key_exists($name, $default)) { return array(); } return $default[$name]; }
[ "public", "function", "defaultConfig", "(", "$", "name", ")", "{", "$", "config", "=", "$", "this", "->", "config", "(", ")", ";", "$", "default", "=", "array_key_exists", "(", "'default'", ",", "$", "config", ")", "?", "$", "config", "[", "'default'", "]", ":", "array", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "default", ")", ")", "{", "return", "array", "(", ")", ";", "}", "return", "$", "default", "[", "$", "name", "]", ";", "}" ]
Get default value for given attribute @param string $name @return array
[ "Get", "default", "value", "for", "given", "attribute" ]
f98474ee389ceefb9ed0d9874322a81f4628e11e
https://github.com/oromedialab/zf2-lazy-form/blob/f98474ee389ceefb9ed0d9874322a81f4628e11e/src/Service/ModuleService.php#L69-L77
235,819
oromedialab/zf2-lazy-form
src/Service/ModuleService.php
ModuleService.lazySet
public function lazySet(array $sets) { $config = $this->config(); if (!array_key_exists('lazy-set', $config) || !is_array($config['lazy-set'])) { throw new \Exception('Config with key "lazy-set" does not exist or incorrect data type given in '.__NAMESPACE__); } $lazySetConfig = $config['lazy-set']; foreach ($sets as $set) { if (!array_key_exists($set, $lazySetConfig)) { throw new \Exception('"lazy-set" with name "'.$set.'" does not exist in '.__NAMESPACE__); } } $lazySets = array(); foreach ($sets as $setIdentifier) { $lazySet = $lazySetConfig[$setIdentifier]; foreach ($lazySet as $type => $set) { if (!is_array($set)) { $lazySet[$type] = $set; continue; } foreach ($set as $index => $attribute) { $deepArray = !in_array($type, $this->deepArrayFalse); $value = $this->configParser($type, $attribute); if (empty($value)) { $value = array(); } if ($deepArray) { $lazySet[$type][$index] = $value; } else { $lazySet[$type] = $value; } } } $lazySets = array_merge_recursive($lazySet, $lazySets); } return $lazySets; }
php
public function lazySet(array $sets) { $config = $this->config(); if (!array_key_exists('lazy-set', $config) || !is_array($config['lazy-set'])) { throw new \Exception('Config with key "lazy-set" does not exist or incorrect data type given in '.__NAMESPACE__); } $lazySetConfig = $config['lazy-set']; foreach ($sets as $set) { if (!array_key_exists($set, $lazySetConfig)) { throw new \Exception('"lazy-set" with name "'.$set.'" does not exist in '.__NAMESPACE__); } } $lazySets = array(); foreach ($sets as $setIdentifier) { $lazySet = $lazySetConfig[$setIdentifier]; foreach ($lazySet as $type => $set) { if (!is_array($set)) { $lazySet[$type] = $set; continue; } foreach ($set as $index => $attribute) { $deepArray = !in_array($type, $this->deepArrayFalse); $value = $this->configParser($type, $attribute); if (empty($value)) { $value = array(); } if ($deepArray) { $lazySet[$type][$index] = $value; } else { $lazySet[$type] = $value; } } } $lazySets = array_merge_recursive($lazySet, $lazySets); } return $lazySets; }
[ "public", "function", "lazySet", "(", "array", "$", "sets", ")", "{", "$", "config", "=", "$", "this", "->", "config", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "'lazy-set'", ",", "$", "config", ")", "||", "!", "is_array", "(", "$", "config", "[", "'lazy-set'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Config with key \"lazy-set\" does not exist or incorrect data type given in '", ".", "__NAMESPACE__", ")", ";", "}", "$", "lazySetConfig", "=", "$", "config", "[", "'lazy-set'", "]", ";", "foreach", "(", "$", "sets", "as", "$", "set", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "set", ",", "$", "lazySetConfig", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'\"lazy-set\" with name \"'", ".", "$", "set", ".", "'\" does not exist in '", ".", "__NAMESPACE__", ")", ";", "}", "}", "$", "lazySets", "=", "array", "(", ")", ";", "foreach", "(", "$", "sets", "as", "$", "setIdentifier", ")", "{", "$", "lazySet", "=", "$", "lazySetConfig", "[", "$", "setIdentifier", "]", ";", "foreach", "(", "$", "lazySet", "as", "$", "type", "=>", "$", "set", ")", "{", "if", "(", "!", "is_array", "(", "$", "set", ")", ")", "{", "$", "lazySet", "[", "$", "type", "]", "=", "$", "set", ";", "continue", ";", "}", "foreach", "(", "$", "set", "as", "$", "index", "=>", "$", "attribute", ")", "{", "$", "deepArray", "=", "!", "in_array", "(", "$", "type", ",", "$", "this", "->", "deepArrayFalse", ")", ";", "$", "value", "=", "$", "this", "->", "configParser", "(", "$", "type", ",", "$", "attribute", ")", ";", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "$", "value", "=", "array", "(", ")", ";", "}", "if", "(", "$", "deepArray", ")", "{", "$", "lazySet", "[", "$", "type", "]", "[", "$", "index", "]", "=", "$", "value", ";", "}", "else", "{", "$", "lazySet", "[", "$", "type", "]", "=", "$", "value", ";", "}", "}", "}", "$", "lazySets", "=", "array_merge_recursive", "(", "$", "lazySet", ",", "$", "lazySets", ")", ";", "}", "return", "$", "lazySets", ";", "}" ]
Convert lazy-set format to zend-form compatible array format @param string $id @return array
[ "Convert", "lazy", "-", "set", "format", "to", "zend", "-", "form", "compatible", "array", "format" ]
f98474ee389ceefb9ed0d9874322a81f4628e11e
https://github.com/oromedialab/zf2-lazy-form/blob/f98474ee389ceefb9ed0d9874322a81f4628e11e/src/Service/ModuleService.php#L85-L122
235,820
kengoldfarb/underscore_libs
src/_Libs/_File.php
_File.closeFile
private function closeFile() { $this->filename = NULL; if ($this->fh !== NULL && $this->fh !== FALSE) { $rc = fclose($this->fh); return $rc; } else { return TRUE; } }
php
private function closeFile() { $this->filename = NULL; if ($this->fh !== NULL && $this->fh !== FALSE) { $rc = fclose($this->fh); return $rc; } else { return TRUE; } }
[ "private", "function", "closeFile", "(", ")", "{", "$", "this", "->", "filename", "=", "NULL", ";", "if", "(", "$", "this", "->", "fh", "!==", "NULL", "&&", "$", "this", "->", "fh", "!==", "FALSE", ")", "{", "$", "rc", "=", "fclose", "(", "$", "this", "->", "fh", ")", ";", "return", "$", "rc", ";", "}", "else", "{", "return", "TRUE", ";", "}", "}" ]
Closes the current file handle @return bool TRUE on success / FALSE on failure
[ "Closes", "the", "current", "file", "handle" ]
e0d584f25093b594e67b8a3068ebd41c7f6483c5
https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_File.php#L118-L126
235,821
sharkodlak/php-gettext
src/ShortMethodsTrait.php
ShortMethodsTrait.dn_
public function dn_($domain, $singular, $plural, $count) { return $this->dngettext($domain, $singular, $plural, $count); }
php
public function dn_($domain, $singular, $plural, $count) { return $this->dngettext($domain, $singular, $plural, $count); }
[ "public", "function", "dn_", "(", "$", "domain", ",", "$", "singular", ",", "$", "plural", ",", "$", "count", ")", "{", "return", "$", "this", "->", "dngettext", "(", "$", "domain", ",", "$", "singular", ",", "$", "plural", ",", "$", "count", ")", ";", "}" ]
Plural version of d_. Some languages have more than one form for plural messages dependent on the count. @param string $domain In which domain (filename) to look up. @param string $singular Message in singular form. @param string $plural Message in plural form. @param int $count The number (e.g. item count) to determine the translation for the respective grammatical number. @return string Returns correct plural form of message if found, otherwise it returns $singular for $count == 1 or $plural for rest. @see ShortMethodsTrait::d_() To view message in given domain lookup. @see Translator::dngettext() Long method name alias.
[ "Plural", "version", "of", "d_", ".", "Some", "languages", "have", "more", "than", "one", "form", "for", "plural", "messages", "dependent", "on", "the", "count", "." ]
383162b6cd4d3f33787f7cc614dafe5509b4924d
https://github.com/sharkodlak/php-gettext/blob/383162b6cd4d3f33787f7cc614dafe5509b4924d/src/ShortMethodsTrait.php#L50-L52
235,822
sharkodlak/php-gettext
src/ShortMethodsTrait.php
ShortMethodsTrait.dnp_
public function dnp_($domain, $context, $singular, $plural, $count) { return $this->dnpgettext($domain, $context, $singular, $plural, $count); }
php
public function dnp_($domain, $context, $singular, $plural, $count) { return $this->dnpgettext($domain, $context, $singular, $plural, $count); }
[ "public", "function", "dnp_", "(", "$", "domain", ",", "$", "context", ",", "$", "singular", ",", "$", "plural", ",", "$", "count", ")", "{", "return", "$", "this", "->", "dnpgettext", "(", "$", "domain", ",", "$", "context", ",", "$", "singular", ",", "$", "plural", ",", "$", "count", ")", ";", "}" ]
Plural version of dp_. Some languages have more than one form for plural messages dependent on the count. @param string $domain In which domain (filename) to look up. @param string $context Context name that distinguishes particular translation. Should be short and rarely need to change. @param string $singular Message in singular form. @param string $plural Message in plural form. @param int $count The number (e.g. item count) to determine the translation for the respective grammatical number. @return string Returns correct plural form of message if found, otherwise it returns $singular for $count == 1 or $plural for rest. @see ShortMethodsTrait::dn_() To view plural version of dgettext. @see ShortMethodsTrait::dp_() To view contextual (particular) message in the given domain lookup. @see Translator::dnpgettext() Long method name alias.
[ "Plural", "version", "of", "dp_", ".", "Some", "languages", "have", "more", "than", "one", "form", "for", "plural", "messages", "dependent", "on", "the", "count", "." ]
383162b6cd4d3f33787f7cc614dafe5509b4924d
https://github.com/sharkodlak/php-gettext/blob/383162b6cd4d3f33787f7cc614dafe5509b4924d/src/ShortMethodsTrait.php#L70-L72
235,823
sharkodlak/php-gettext
src/ShortMethodsTrait.php
ShortMethodsTrait.np_
public function np_($context, $singular, $plural, $count) { return $this->npgettext($context, $singular, $plural, $count); }
php
public function np_($context, $singular, $plural, $count) { return $this->npgettext($context, $singular, $plural, $count); }
[ "public", "function", "np_", "(", "$", "context", ",", "$", "singular", ",", "$", "plural", ",", "$", "count", ")", "{", "return", "$", "this", "->", "npgettext", "(", "$", "context", ",", "$", "singular", ",", "$", "plural", ",", "$", "count", ")", ";", "}" ]
Plural version of p_. Some languages have more than one form for plural messages dependent on the count. @param string $context Context name that distinguishes particular translation. Should be short and rarely need to change. @param string $singular Message in singular form. @param string $plural Message in plural form. @param int $count The number (e.g. item count) to determine the translation for the respective grammatical number. @return string Returns correct plural form of message if found, otherwise it returns $singular for $count == 1 or $plural for rest. @see ShortMethodsTrait::n_() To view plural version of gettext. @see ShortMethodsTrait::p_() To view contextual (particular) message in the current domain lookup. @see Translator::npgettext() Long method name alias.
[ "Plural", "version", "of", "p_", ".", "Some", "languages", "have", "more", "than", "one", "form", "for", "plural", "messages", "dependent", "on", "the", "count", "." ]
383162b6cd4d3f33787f7cc614dafe5509b4924d
https://github.com/sharkodlak/php-gettext/blob/383162b6cd4d3f33787f7cc614dafe5509b4924d/src/ShortMethodsTrait.php#L120-L122
235,824
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.find
public function find($column, $value) { return $this->getFirst((is_null($column) ? $this->key : $column) . ' = ?', [$value]); }
php
public function find($column, $value) { return $this->getFirst((is_null($column) ? $this->key : $column) . ' = ?', [$value]); }
[ "public", "function", "find", "(", "$", "column", ",", "$", "value", ")", "{", "return", "$", "this", "->", "getFirst", "(", "(", "is_null", "(", "$", "column", ")", "?", "$", "this", "->", "key", ":", "$", "column", ")", ".", "' = ?'", ",", "[", "$", "value", "]", ")", ";", "}" ]
Find and return first entry by key. @param string|null $column Key column name (pass null to use registered primary key). @param mixed $value Key value. @return mixed Model instance.
[ "Find", "and", "return", "first", "entry", "by", "key", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L76-L79
235,825
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.getFirst
public function getFirst($conditions = null, $values = [], $options = []) { return $this->processSingleResult($this->executeQuery(null, $conditions, $values, $options)); }
php
public function getFirst($conditions = null, $values = [], $options = []) { return $this->processSingleResult($this->executeQuery(null, $conditions, $values, $options)); }
[ "public", "function", "getFirst", "(", "$", "conditions", "=", "null", ",", "$", "values", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "processSingleResult", "(", "$", "this", "->", "executeQuery", "(", "null", ",", "$", "conditions", ",", "$", "values", ",", "$", "options", ")", ")", ";", "}" ]
Retrieve first entry, optionally filtered by search criteria. @param string $conditions Where conditions. @param array $values Array of condition values to bind. @param array $options Query options. @return mixed Model instance.
[ "Retrieve", "first", "entry", "optionally", "filtered", "by", "search", "criteria", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L91-L94
235,826
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.getAll
public function getAll($conditions = null, $values = [], $options = []) { return $this->processMultipleResults($this->executeQuery(null, $conditions, $values, $options)); }
php
public function getAll($conditions = null, $values = [], $options = []) { return $this->processMultipleResults($this->executeQuery(null, $conditions, $values, $options)); }
[ "public", "function", "getAll", "(", "$", "conditions", "=", "null", ",", "$", "values", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "processMultipleResults", "(", "$", "this", "->", "executeQuery", "(", "null", ",", "$", "conditions", ",", "$", "values", ",", "$", "options", ")", ")", ";", "}" ]
Retrieve all entries, optionally filtered by search criteria. @param string $conditions Where conditions. @param array $values Array of condition values to bind. @param array $options Query options. @return array Array of all matching entries.
[ "Retrieve", "all", "entries", "optionally", "filtered", "by", "search", "criteria", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L106-L109
235,827
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.save
public function save($model) { if (isset($model->{$this->key})) { return $this->update($model); } return $this->create($model); }
php
public function save($model) { if (isset($model->{$this->key})) { return $this->update($model); } return $this->create($model); }
[ "public", "function", "save", "(", "$", "model", ")", "{", "if", "(", "isset", "(", "$", "model", "->", "{", "$", "this", "->", "key", "}", ")", ")", "{", "return", "$", "this", "->", "update", "(", "$", "model", ")", ";", "}", "return", "$", "this", "->", "create", "(", "$", "model", ")", ";", "}" ]
Save entry by inserting if ID is missing and updating if ID exists. @param mixed $model Model instance. @return void
[ "Save", "entry", "by", "inserting", "if", "ID", "is", "missing", "and", "updating", "if", "ID", "exists", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L119-L126
235,828
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.delete
public function delete($model) { $this->db->connect() ->deleteFrom($this->table) ->where($this->key . ' = ?') ->execute([$model->{$this->key}]); $model->{$this->key} = null; }
php
public function delete($model) { $this->db->connect() ->deleteFrom($this->table) ->where($this->key . ' = ?') ->execute([$model->{$this->key}]); $model->{$this->key} = null; }
[ "public", "function", "delete", "(", "$", "model", ")", "{", "$", "this", "->", "db", "->", "connect", "(", ")", "->", "deleteFrom", "(", "$", "this", "->", "table", ")", "->", "where", "(", "$", "this", "->", "key", ".", "' = ?'", ")", "->", "execute", "(", "[", "$", "model", "->", "{", "$", "this", "->", "key", "}", "]", ")", ";", "$", "model", "->", "{", "$", "this", "->", "key", "}", "=", "null", ";", "}" ]
Delete entry. @param mixed $model Model instance.
[ "Delete", "entry", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L134-L141
235,829
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.count
public function count($conditions = null, $values = []) { $res = $this->executeQuery('COUNT(' . $this->key . ') AS num', $conditions, $values) ->fetch(); return (isset($res->num) ? (int)$res->num : 0); }
php
public function count($conditions = null, $values = []) { $res = $this->executeQuery('COUNT(' . $this->key . ') AS num', $conditions, $values) ->fetch(); return (isset($res->num) ? (int)$res->num : 0); }
[ "public", "function", "count", "(", "$", "conditions", "=", "null", ",", "$", "values", "=", "[", "]", ")", "{", "$", "res", "=", "$", "this", "->", "executeQuery", "(", "'COUNT('", ".", "$", "this", "->", "key", ".", "') AS num'", ",", "$", "conditions", ",", "$", "values", ")", "->", "fetch", "(", ")", ";", "return", "(", "isset", "(", "$", "res", "->", "num", ")", "?", "(", "int", ")", "$", "res", "->", "num", ":", "0", ")", ";", "}" ]
Count entries, optionally filtered by search criteria. @param string $conditions Where conditions. @param array $values Array of condition values to bind. @return int Number of entries.
[ "Count", "entries", "optionally", "filtered", "by", "search", "criteria", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L152-L157
235,830
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.executeQuery
protected function executeQuery($select = null, $conditions = null, $values = [], $options = []) { $query = $this->db->connect(); if (!empty($this->fetchRefs)) { $query = $this->setupJoin($query, $select, $conditions, (isset($options['order']) ? $options['order'] : null)); } else { $query = (!is_null($select) ? $query->select($select) : $query->select()); $query = $query->from($this->table); if (!is_null($conditions)) { $query = $query->where($conditions); } if (isset($options['order'])) { $query = $query->orderBy($options['order']); } } if (isset($options['limit'])) { $query = $query->limit($options['limit']); } if (isset($options['offset'])) { $query = $query->offset($options['offset']); } return $query->execute($values); }
php
protected function executeQuery($select = null, $conditions = null, $values = [], $options = []) { $query = $this->db->connect(); if (!empty($this->fetchRefs)) { $query = $this->setupJoin($query, $select, $conditions, (isset($options['order']) ? $options['order'] : null)); } else { $query = (!is_null($select) ? $query->select($select) : $query->select()); $query = $query->from($this->table); if (!is_null($conditions)) { $query = $query->where($conditions); } if (isset($options['order'])) { $query = $query->orderBy($options['order']); } } if (isset($options['limit'])) { $query = $query->limit($options['limit']); } if (isset($options['offset'])) { $query = $query->offset($options['offset']); } return $query->execute($values); }
[ "protected", "function", "executeQuery", "(", "$", "select", "=", "null", ",", "$", "conditions", "=", "null", ",", "$", "values", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "query", "=", "$", "this", "->", "db", "->", "connect", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "fetchRefs", ")", ")", "{", "$", "query", "=", "$", "this", "->", "setupJoin", "(", "$", "query", ",", "$", "select", ",", "$", "conditions", ",", "(", "isset", "(", "$", "options", "[", "'order'", "]", ")", "?", "$", "options", "[", "'order'", "]", ":", "null", ")", ")", ";", "}", "else", "{", "$", "query", "=", "(", "!", "is_null", "(", "$", "select", ")", "?", "$", "query", "->", "select", "(", "$", "select", ")", ":", "$", "query", "->", "select", "(", ")", ")", ";", "$", "query", "=", "$", "query", "->", "from", "(", "$", "this", "->", "table", ")", ";", "if", "(", "!", "is_null", "(", "$", "conditions", ")", ")", "{", "$", "query", "=", "$", "query", "->", "where", "(", "$", "conditions", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'order'", "]", ")", ")", "{", "$", "query", "=", "$", "query", "->", "orderBy", "(", "$", "options", "[", "'order'", "]", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "options", "[", "'limit'", "]", ")", ")", "{", "$", "query", "=", "$", "query", "->", "limit", "(", "$", "options", "[", "'limit'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'offset'", "]", ")", ")", "{", "$", "query", "=", "$", "query", "->", "offset", "(", "$", "options", "[", "'offset'", "]", ")", ";", "}", "return", "$", "query", "->", "execute", "(", "$", "values", ")", ";", "}" ]
Execute query for selection methods. @param string $select Selection criteria. @param string $conditions Where conditions. @param array $values Array of where condition values to bind. @param array $options Query options. @return \Anax\Database\DatabaseQueryBuilder Database service instance with executed internal query.
[ "Execute", "query", "for", "selection", "methods", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L170-L194
235,831
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.populateModelFromJoin
protected function populateModelFromJoin($result) { // extract main model $model = new $this->modelClass(); foreach (array_keys(get_object_vars($model)) as $attr) { $model->$attr = $result->$attr; } // extract referenced models $refs = $model->getReferences(); $refs2 = (is_array($this->fetchRefs) ? $this->fetchRefs : array_keys($refs)); sort($refs2); foreach ($refs2 as $idx => $name) { $prefix = "REF{$idx}_{$name}__"; // handle null result if (is_null($result->{$prefix . $refs[$name]['key']})) { $refModel = null; } else { $refModel = new $refs[$name]['model'](); foreach (array_keys(get_object_vars($refModel)) as $attr) { $refModel->$attr = $result->{$prefix . $attr}; } } // inject manager reference if ($refModel && $this->manager) { $this->manager->manageModel($refModel); } $model->$name = $refModel; } return $model; }
php
protected function populateModelFromJoin($result) { // extract main model $model = new $this->modelClass(); foreach (array_keys(get_object_vars($model)) as $attr) { $model->$attr = $result->$attr; } // extract referenced models $refs = $model->getReferences(); $refs2 = (is_array($this->fetchRefs) ? $this->fetchRefs : array_keys($refs)); sort($refs2); foreach ($refs2 as $idx => $name) { $prefix = "REF{$idx}_{$name}__"; // handle null result if (is_null($result->{$prefix . $refs[$name]['key']})) { $refModel = null; } else { $refModel = new $refs[$name]['model'](); foreach (array_keys(get_object_vars($refModel)) as $attr) { $refModel->$attr = $result->{$prefix . $attr}; } } // inject manager reference if ($refModel && $this->manager) { $this->manager->manageModel($refModel); } $model->$name = $refModel; } return $model; }
[ "protected", "function", "populateModelFromJoin", "(", "$", "result", ")", "{", "// extract main model", "$", "model", "=", "new", "$", "this", "->", "modelClass", "(", ")", ";", "foreach", "(", "array_keys", "(", "get_object_vars", "(", "$", "model", ")", ")", "as", "$", "attr", ")", "{", "$", "model", "->", "$", "attr", "=", "$", "result", "->", "$", "attr", ";", "}", "// extract referenced models", "$", "refs", "=", "$", "model", "->", "getReferences", "(", ")", ";", "$", "refs2", "=", "(", "is_array", "(", "$", "this", "->", "fetchRefs", ")", "?", "$", "this", "->", "fetchRefs", ":", "array_keys", "(", "$", "refs", ")", ")", ";", "sort", "(", "$", "refs2", ")", ";", "foreach", "(", "$", "refs2", "as", "$", "idx", "=>", "$", "name", ")", "{", "$", "prefix", "=", "\"REF{$idx}_{$name}__\"", ";", "// handle null result", "if", "(", "is_null", "(", "$", "result", "->", "{", "$", "prefix", ".", "$", "refs", "[", "$", "name", "]", "[", "'key'", "]", "}", ")", ")", "{", "$", "refModel", "=", "null", ";", "}", "else", "{", "$", "refModel", "=", "new", "$", "refs", "[", "$", "name", "]", "[", "'model'", "]", "(", ")", ";", "foreach", "(", "array_keys", "(", "get_object_vars", "(", "$", "refModel", ")", ")", "as", "$", "attr", ")", "{", "$", "refModel", "->", "$", "attr", "=", "$", "result", "->", "{", "$", "prefix", ".", "$", "attr", "}", ";", "}", "}", "// inject manager reference", "if", "(", "$", "refModel", "&&", "$", "this", "->", "manager", ")", "{", "$", "this", "->", "manager", "->", "manageModel", "(", "$", "refModel", ")", ";", "}", "$", "model", "->", "$", "name", "=", "$", "refModel", ";", "}", "return", "$", "model", ";", "}" ]
Populate model instance including retrieved references from join query result. @param object $result Query result. @return mixed Populated model instance.
[ "Populate", "model", "instance", "including", "retrieved", "references", "from", "join", "query", "result", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L205-L239
235,832
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.processSingleResult
protected function processSingleResult($query) { if (!empty($this->fetchRefs)) { $res = $query->fetch(); $model = ($res ? $this->populateModelFromJoin($res) : $res); } else { $model = $query->fetchClass($this->modelClass); } if ($model && isset($this->manager)) { $this->manager->manageModel($model); } $this->fetchReferences(false); return $model; }
php
protected function processSingleResult($query) { if (!empty($this->fetchRefs)) { $res = $query->fetch(); $model = ($res ? $this->populateModelFromJoin($res) : $res); } else { $model = $query->fetchClass($this->modelClass); } if ($model && isset($this->manager)) { $this->manager->manageModel($model); } $this->fetchReferences(false); return $model; }
[ "protected", "function", "processSingleResult", "(", "$", "query", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "fetchRefs", ")", ")", "{", "$", "res", "=", "$", "query", "->", "fetch", "(", ")", ";", "$", "model", "=", "(", "$", "res", "?", "$", "this", "->", "populateModelFromJoin", "(", "$", "res", ")", ":", "$", "res", ")", ";", "}", "else", "{", "$", "model", "=", "$", "query", "->", "fetchClass", "(", "$", "this", "->", "modelClass", ")", ";", "}", "if", "(", "$", "model", "&&", "isset", "(", "$", "this", "->", "manager", ")", ")", "{", "$", "this", "->", "manager", "->", "manageModel", "(", "$", "model", ")", ";", "}", "$", "this", "->", "fetchReferences", "(", "false", ")", ";", "return", "$", "model", ";", "}" ]
Process single query result and return model instance. @param \Anax\Database\DatabaseQueryBuilder $query Database service instance with executed internal query. @return mixed Model instance.
[ "Process", "single", "query", "result", "and", "return", "model", "instance", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L249-L262
235,833
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.processMultipleResults
protected function processMultipleResults($query) { if (!empty($this->fetchRefs)) { $models = []; foreach ($query->fetchAll() as $model) { $models[] = $this->populateModelFromJoin($model); } } else { $models = $query->fetchAllClass($this->modelClass); } if (isset($this->manager)) { foreach ($models as $model) { $this->manager->manageModel($model); } } $this->fetchReferences(false); return $models; }
php
protected function processMultipleResults($query) { if (!empty($this->fetchRefs)) { $models = []; foreach ($query->fetchAll() as $model) { $models[] = $this->populateModelFromJoin($model); } } else { $models = $query->fetchAllClass($this->modelClass); } if (isset($this->manager)) { foreach ($models as $model) { $this->manager->manageModel($model); } } $this->fetchReferences(false); return $models; }
[ "protected", "function", "processMultipleResults", "(", "$", "query", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "fetchRefs", ")", ")", "{", "$", "models", "=", "[", "]", ";", "foreach", "(", "$", "query", "->", "fetchAll", "(", ")", "as", "$", "model", ")", "{", "$", "models", "[", "]", "=", "$", "this", "->", "populateModelFromJoin", "(", "$", "model", ")", ";", "}", "}", "else", "{", "$", "models", "=", "$", "query", "->", "fetchAllClass", "(", "$", "this", "->", "modelClass", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "manager", ")", ")", "{", "foreach", "(", "$", "models", "as", "$", "model", ")", "{", "$", "this", "->", "manager", "->", "manageModel", "(", "$", "model", ")", ";", "}", "}", "$", "this", "->", "fetchReferences", "(", "false", ")", ";", "return", "$", "models", ";", "}" ]
Process multiple query results and return model instances. @param \Anax\Database\DatabaseQueryBuilder $query Database service instance with executed internal query. @return array Array of model instances.
[ "Process", "multiple", "query", "results", "and", "return", "model", "instances", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L272-L289
235,834
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.setupJoin
private function setupJoin($query, $select, $conditions, $order = null) { // find references $model = new $this->modelClass(); $refs = $model->getReferences(); if (is_array($this->fetchRefs)) { $refs = array_intersect_key($refs, array_flip($this->fetchRefs)); } ksort($refs); // prefix main model selection if (!is_null($select)) { $select = $this->prefixModelAttributes($select, $model); } else { $select = $this->table . '.*'; } // set up reference aliases and join conditions $select = [$select]; $join = []; $idx = 0; foreach ($refs as $name => $ref) { // prefix attributes $refTable = "REF{$idx}_{$name}"; $idx++; foreach (array_keys(get_object_vars(new $ref['model']())) as $attr) { $select[] = "{$refTable}.{$attr} AS '{$refTable}__{$attr}'"; } // generate join conditions $joinCond = $this->table . '.' . $ref['attribute'] . " = {$refTable}." . $ref['key']; $refRepo = $this->manager->getByClass($ref['model']); if ($this->softRefs && $refRepo instanceof SoftDbRepository) { $joinCond .= " AND $refTable." . $refRepo->getDeletedAttribute() . ' IS NULL'; } $join[] = [$refRepo->getCollectionName() . " AS $refTable", $joinCond]; } // generate join query $query = $query->select(implode(', ', $select))->from($this->table); foreach ($join as $args) { $query = $query->leftJoin($args[0], $args[1]); } // prefix where conditions if (!is_null($conditions)) { $query = $query->where($this->prefixModelAttributes($conditions, $model)); } // prefix order by clause if (!is_null($order)) { $query = $query->orderBy($this->prefixModelAttributes($order, $model)); } return $query; }
php
private function setupJoin($query, $select, $conditions, $order = null) { // find references $model = new $this->modelClass(); $refs = $model->getReferences(); if (is_array($this->fetchRefs)) { $refs = array_intersect_key($refs, array_flip($this->fetchRefs)); } ksort($refs); // prefix main model selection if (!is_null($select)) { $select = $this->prefixModelAttributes($select, $model); } else { $select = $this->table . '.*'; } // set up reference aliases and join conditions $select = [$select]; $join = []; $idx = 0; foreach ($refs as $name => $ref) { // prefix attributes $refTable = "REF{$idx}_{$name}"; $idx++; foreach (array_keys(get_object_vars(new $ref['model']())) as $attr) { $select[] = "{$refTable}.{$attr} AS '{$refTable}__{$attr}'"; } // generate join conditions $joinCond = $this->table . '.' . $ref['attribute'] . " = {$refTable}." . $ref['key']; $refRepo = $this->manager->getByClass($ref['model']); if ($this->softRefs && $refRepo instanceof SoftDbRepository) { $joinCond .= " AND $refTable." . $refRepo->getDeletedAttribute() . ' IS NULL'; } $join[] = [$refRepo->getCollectionName() . " AS $refTable", $joinCond]; } // generate join query $query = $query->select(implode(', ', $select))->from($this->table); foreach ($join as $args) { $query = $query->leftJoin($args[0], $args[1]); } // prefix where conditions if (!is_null($conditions)) { $query = $query->where($this->prefixModelAttributes($conditions, $model)); } // prefix order by clause if (!is_null($order)) { $query = $query->orderBy($this->prefixModelAttributes($order, $model)); } return $query; }
[ "private", "function", "setupJoin", "(", "$", "query", ",", "$", "select", ",", "$", "conditions", ",", "$", "order", "=", "null", ")", "{", "// find references", "$", "model", "=", "new", "$", "this", "->", "modelClass", "(", ")", ";", "$", "refs", "=", "$", "model", "->", "getReferences", "(", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "fetchRefs", ")", ")", "{", "$", "refs", "=", "array_intersect_key", "(", "$", "refs", ",", "array_flip", "(", "$", "this", "->", "fetchRefs", ")", ")", ";", "}", "ksort", "(", "$", "refs", ")", ";", "// prefix main model selection", "if", "(", "!", "is_null", "(", "$", "select", ")", ")", "{", "$", "select", "=", "$", "this", "->", "prefixModelAttributes", "(", "$", "select", ",", "$", "model", ")", ";", "}", "else", "{", "$", "select", "=", "$", "this", "->", "table", ".", "'.*'", ";", "}", "// set up reference aliases and join conditions", "$", "select", "=", "[", "$", "select", "]", ";", "$", "join", "=", "[", "]", ";", "$", "idx", "=", "0", ";", "foreach", "(", "$", "refs", "as", "$", "name", "=>", "$", "ref", ")", "{", "// prefix attributes", "$", "refTable", "=", "\"REF{$idx}_{$name}\"", ";", "$", "idx", "++", ";", "foreach", "(", "array_keys", "(", "get_object_vars", "(", "new", "$", "ref", "[", "'model'", "]", "(", ")", ")", ")", "as", "$", "attr", ")", "{", "$", "select", "[", "]", "=", "\"{$refTable}.{$attr} AS '{$refTable}__{$attr}'\"", ";", "}", "// generate join conditions", "$", "joinCond", "=", "$", "this", "->", "table", ".", "'.'", ".", "$", "ref", "[", "'attribute'", "]", ".", "\" = {$refTable}.\"", ".", "$", "ref", "[", "'key'", "]", ";", "$", "refRepo", "=", "$", "this", "->", "manager", "->", "getByClass", "(", "$", "ref", "[", "'model'", "]", ")", ";", "if", "(", "$", "this", "->", "softRefs", "&&", "$", "refRepo", "instanceof", "SoftDbRepository", ")", "{", "$", "joinCond", ".=", "\" AND $refTable.\"", ".", "$", "refRepo", "->", "getDeletedAttribute", "(", ")", ".", "' IS NULL'", ";", "}", "$", "join", "[", "]", "=", "[", "$", "refRepo", "->", "getCollectionName", "(", ")", ".", "\" AS $refTable\"", ",", "$", "joinCond", "]", ";", "}", "// generate join query", "$", "query", "=", "$", "query", "->", "select", "(", "implode", "(", "', '", ",", "$", "select", ")", ")", "->", "from", "(", "$", "this", "->", "table", ")", ";", "foreach", "(", "$", "join", "as", "$", "args", ")", "{", "$", "query", "=", "$", "query", "->", "leftJoin", "(", "$", "args", "[", "0", "]", ",", "$", "args", "[", "1", "]", ")", ";", "}", "// prefix where conditions", "if", "(", "!", "is_null", "(", "$", "conditions", ")", ")", "{", "$", "query", "=", "$", "query", "->", "where", "(", "$", "this", "->", "prefixModelAttributes", "(", "$", "conditions", ",", "$", "model", ")", ")", ";", "}", "// prefix order by clause", "if", "(", "!", "is_null", "(", "$", "order", ")", ")", "{", "$", "query", "=", "$", "query", "->", "orderBy", "(", "$", "this", "->", "prefixModelAttributes", "(", "$", "order", ",", "$", "model", ")", ")", ";", "}", "return", "$", "query", ";", "}" ]
Set up join query for reference retrieval. @param \Anax\Database\DatabaseQueryBuilder $query Database service instance with initialized query. @param string $select Selection criteria. @param string $conditions Where conditions. @param string $order Order by clause. @return \Anax\Database\DatabaseQueryBuilder Database service instance with prepared join query. @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)
[ "Set", "up", "join", "query", "for", "reference", "retrieval", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L305-L360
235,835
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.prefixModelAttributes
private function prefixModelAttributes($input, $model) { foreach (array_keys(get_object_vars($model)) as $attr) { $input = preg_replace('/\\b' . $attr . '\\b/', $this->table . ".$attr", $input); } return $input; }
php
private function prefixModelAttributes($input, $model) { foreach (array_keys(get_object_vars($model)) as $attr) { $input = preg_replace('/\\b' . $attr . '\\b/', $this->table . ".$attr", $input); } return $input; }
[ "private", "function", "prefixModelAttributes", "(", "$", "input", ",", "$", "model", ")", "{", "foreach", "(", "array_keys", "(", "get_object_vars", "(", "$", "model", ")", ")", "as", "$", "attr", ")", "{", "$", "input", "=", "preg_replace", "(", "'/\\\\b'", ".", "$", "attr", ".", "'\\\\b/'", ",", "$", "this", "->", "table", ".", "\".$attr\"", ",", "$", "input", ")", ";", "}", "return", "$", "input", ";", "}" ]
Prefix model attributes with the associated table name. @param string $input Input string. @param object $model Model instance. @return string String with table-prefixed attributes.
[ "Prefix", "model", "attributes", "with", "the", "associated", "table", "name", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L371-L377
235,836
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.create
private function create($model) { $attrs = $this->getMutableAttributes($model); $this->db ->connect() ->insert($this->table, array_keys($attrs)) ->execute(array_values($attrs)); $model->{$this->key} = $this->db->lastInsertId(); }
php
private function create($model) { $attrs = $this->getMutableAttributes($model); $this->db ->connect() ->insert($this->table, array_keys($attrs)) ->execute(array_values($attrs)); $model->{$this->key} = $this->db->lastInsertId(); }
[ "private", "function", "create", "(", "$", "model", ")", "{", "$", "attrs", "=", "$", "this", "->", "getMutableAttributes", "(", "$", "model", ")", ";", "$", "this", "->", "db", "->", "connect", "(", ")", "->", "insert", "(", "$", "this", "->", "table", ",", "array_keys", "(", "$", "attrs", ")", ")", "->", "execute", "(", "array_values", "(", "$", "attrs", ")", ")", ";", "$", "model", "->", "{", "$", "this", "->", "key", "}", "=", "$", "this", "->", "db", "->", "lastInsertId", "(", ")", ";", "}" ]
Create new entry. @param mixed $model Model instance.
[ "Create", "new", "entry", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L385-L393
235,837
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.update
private function update($model) { $attrs = $this->getMutableAttributes($model); $values = array_values($attrs); $values[] = $model->{$this->key}; $this->db ->connect() ->update($this->table, array_keys($attrs)) ->where($this->key . ' = ?') ->execute($values); }
php
private function update($model) { $attrs = $this->getMutableAttributes($model); $values = array_values($attrs); $values[] = $model->{$this->key}; $this->db ->connect() ->update($this->table, array_keys($attrs)) ->where($this->key . ' = ?') ->execute($values); }
[ "private", "function", "update", "(", "$", "model", ")", "{", "$", "attrs", "=", "$", "this", "->", "getMutableAttributes", "(", "$", "model", ")", ";", "$", "values", "=", "array_values", "(", "$", "attrs", ")", ";", "$", "values", "[", "]", "=", "$", "model", "->", "{", "$", "this", "->", "key", "}", ";", "$", "this", "->", "db", "->", "connect", "(", ")", "->", "update", "(", "$", "this", "->", "table", ",", "array_keys", "(", "$", "attrs", ")", ")", "->", "where", "(", "$", "this", "->", "key", ".", "' = ?'", ")", "->", "execute", "(", "$", "values", ")", ";", "}" ]
Update entry. @param mixed $model Model instance.
[ "Update", "entry", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L401-L411
235,838
lrc-se/bth-anax-repository
src/Repository/DbRepository.php
DbRepository.getMutableAttributes
private function getMutableAttributes($model) { $attrs = get_object_vars($model); unset($attrs[$this->key]); // remove reference attributes, if any if ($model instanceof ManagedModelInterface) { foreach (array_keys($model->getReferences()) as $ref) { unset($attrs[$ref]); } } return $attrs; }
php
private function getMutableAttributes($model) { $attrs = get_object_vars($model); unset($attrs[$this->key]); // remove reference attributes, if any if ($model instanceof ManagedModelInterface) { foreach (array_keys($model->getReferences()) as $ref) { unset($attrs[$ref]); } } return $attrs; }
[ "private", "function", "getMutableAttributes", "(", "$", "model", ")", "{", "$", "attrs", "=", "get_object_vars", "(", "$", "model", ")", ";", "unset", "(", "$", "attrs", "[", "$", "this", "->", "key", "]", ")", ";", "// remove reference attributes, if any", "if", "(", "$", "model", "instanceof", "ManagedModelInterface", ")", "{", "foreach", "(", "array_keys", "(", "$", "model", "->", "getReferences", "(", ")", ")", "as", "$", "ref", ")", "{", "unset", "(", "$", "attrs", "[", "$", "ref", "]", ")", ";", "}", "}", "return", "$", "attrs", ";", "}" ]
Get mutable model attributes. @param object $model Model instance. @return array Array of attributes.
[ "Get", "mutable", "model", "attributes", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/DbRepository.php#L421-L434
235,839
Kylob/Form
src/Component.php
Component.set
public function set($property, $name, $value = null) { $set = (is_array($name)) ? $name : array($name => $value); switch ($property) { case 'errors': $this->validator->errors = array_merge($this->validator->errors, $set); break; case 'values': case 'header': case 'hidden': $this->$property = array_merge($this->$property, $set); break; case 'footer': foreach ((array) $name as $value) { $this->footer[] = $value; } break; } }
php
public function set($property, $name, $value = null) { $set = (is_array($name)) ? $name : array($name => $value); switch ($property) { case 'errors': $this->validator->errors = array_merge($this->validator->errors, $set); break; case 'values': case 'header': case 'hidden': $this->$property = array_merge($this->$property, $set); break; case 'footer': foreach ((array) $name as $value) { $this->footer[] = $value; } break; } }
[ "public", "function", "set", "(", "$", "property", ",", "$", "name", ",", "$", "value", "=", "null", ")", "{", "$", "set", "=", "(", "is_array", "(", "$", "name", ")", ")", "?", "$", "name", ":", "array", "(", "$", "name", "=>", "$", "value", ")", ";", "switch", "(", "$", "property", ")", "{", "case", "'errors'", ":", "$", "this", "->", "validator", "->", "errors", "=", "array_merge", "(", "$", "this", "->", "validator", "->", "errors", ",", "$", "set", ")", ";", "break", ";", "case", "'values'", ":", "case", "'header'", ":", "case", "'hidden'", ":", "$", "this", "->", "$", "property", "=", "array_merge", "(", "$", "this", "->", "$", "property", ",", "$", "set", ")", ";", "break", ";", "case", "'footer'", ":", "foreach", "(", "(", "array", ")", "$", "name", "as", "$", "value", ")", "{", "$", "this", "->", "footer", "[", "]", "=", "$", "value", ";", "}", "break", ";", "}", "}" ]
Set public properties. Useful for Twig templates that can't set them directly. @param string $property The one you want to set. Either '**errors**' (for the Validator), '**header**', '**footer**', '**hidden**', or the '**values**' above. @param string|array $name Make this an ``array($name => $value, ...)`` to set multiple values at once. @param mixed $value Only used if **$name** is a string, and you're not setting any '**footer**' HTML.
[ "Set", "public", "properties", ".", "Useful", "for", "Twig", "templates", "that", "can", "t", "set", "them", "directly", "." ]
147e21a486653cc35481dad6d038a919e12ea19d
https://github.com/Kylob/Form/blob/147e21a486653cc35481dad6d038a919e12ea19d/src/Component.php#L80-L98
235,840
Kylob/Form
src/Component.php
Component.close
public function close() { $html = implode('', $this->footer); foreach ($this->hidden as $key => $value) { $html .= "\n\t".$this->input('hidden', array( 'name' => $key, 'value' => htmlspecialchars((string) $value), )); } return $html."\n</form>"; }
php
public function close() { $html = implode('', $this->footer); foreach ($this->hidden as $key => $value) { $html .= "\n\t".$this->input('hidden', array( 'name' => $key, 'value' => htmlspecialchars((string) $value), )); } return $html."\n</form>"; }
[ "public", "function", "close", "(", ")", "{", "$", "html", "=", "implode", "(", "''", ",", "$", "this", "->", "footer", ")", ";", "foreach", "(", "$", "this", "->", "hidden", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "html", ".=", "\"\\n\\t\"", ".", "$", "this", "->", "input", "(", "'hidden'", ",", "array", "(", "'name'", "=>", "$", "key", ",", "'value'", "=>", "htmlspecialchars", "(", "(", "string", ")", "$", "value", ")", ",", ")", ")", ";", "}", "return", "$", "html", ".", "\"\\n</form>\"", ";", "}" ]
Closes and cleans up shop. @return string The closing ``</form>`` tag with the ``$form->footer`` and ``$form->hidden`` fields preceding it. @example ```php echo $form->close(); ```
[ "Closes", "and", "cleans", "up", "shop", "." ]
147e21a486653cc35481dad6d038a919e12ea19d
https://github.com/Kylob/Form/blob/147e21a486653cc35481dad6d038a919e12ea19d/src/Component.php#L594-L605
235,841
Kylob/Form
src/Component.php
Component.validate
public function validate($field, array $attributes = array()) { foreach ($this->validator->rules($field) as $validate => $param) { $attributes["data-rule-{$validate}"] = htmlspecialchars($param); } foreach ($this->validator->messages($field) as $rule => $message) { $attributes["data-msg-{$rule}"] = htmlspecialchars($message); } return $attributes; }
php
public function validate($field, array $attributes = array()) { foreach ($this->validator->rules($field) as $validate => $param) { $attributes["data-rule-{$validate}"] = htmlspecialchars($param); } foreach ($this->validator->messages($field) as $rule => $message) { $attributes["data-msg-{$rule}"] = htmlspecialchars($message); } return $attributes; }
[ "public", "function", "validate", "(", "$", "field", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "validator", "->", "rules", "(", "$", "field", ")", "as", "$", "validate", "=>", "$", "param", ")", "{", "$", "attributes", "[", "\"data-rule-{$validate}\"", "]", "=", "htmlspecialchars", "(", "$", "param", ")", ";", "}", "foreach", "(", "$", "this", "->", "validator", "->", "messages", "(", "$", "field", ")", "as", "$", "rule", "=>", "$", "message", ")", "{", "$", "attributes", "[", "\"data-msg-{$rule}\"", "]", "=", "htmlspecialchars", "(", "$", "message", ")", ";", "}", "return", "$", "attributes", ";", "}" ]
This adds the jQuery Validation rules and messages set earlier to the input field's submitted attributes. This is used internally when creating form fields using this class. @param string $field The input's name. @param array $attributes The currently constituted attributes. @return array The submitted attributes with the data rules and messages applied. @see http://johnnycode.com/2014/03/27/using-jquery-validate-plugin-html5-data-attribute-rules/ ```php $form->validator->set('field', array('required' => 'Do this or else.')); $attributes = $form->validate('field', array('name' => 'field')); ```
[ "This", "adds", "the", "jQuery", "Validation", "rules", "and", "messages", "set", "earlier", "to", "the", "input", "field", "s", "submitted", "attributes", ".", "This", "is", "used", "internally", "when", "creating", "form", "fields", "using", "this", "class", "." ]
147e21a486653cc35481dad6d038a919e12ea19d
https://github.com/Kylob/Form/blob/147e21a486653cc35481dad6d038a919e12ea19d/src/Component.php#L642-L652
235,842
Kylob/Form
src/Component.php
Component.flatten
private function flatten(array $array) { $single = array(); if (isset($array['hier'])) { unset($array['hier']); } foreach ($array as $key => $value) { if (is_array($value)) { foreach ($this->flatten($value) as $key => $value) { $single[$key] = $value; } } else { $single[$key] = $value; } } return $single; }
php
private function flatten(array $array) { $single = array(); if (isset($array['hier'])) { unset($array['hier']); } foreach ($array as $key => $value) { if (is_array($value)) { foreach ($this->flatten($value) as $key => $value) { $single[$key] = $value; } } else { $single[$key] = $value; } } return $single; }
[ "private", "function", "flatten", "(", "array", "$", "array", ")", "{", "$", "single", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "array", "[", "'hier'", "]", ")", ")", "{", "unset", "(", "$", "array", "[", "'hier'", "]", ")", ";", "}", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "this", "->", "flatten", "(", "$", "value", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "single", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "else", "{", "$", "single", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "single", ";", "}" ]
This is used with menus for getting to the bottom of multi-dimensional arrays, and determining it's root keys and values. @param array $array @return array A single-dimensional ``array($key => $value, ...)``'s.
[ "This", "is", "used", "with", "menus", "for", "getting", "to", "the", "bottom", "of", "multi", "-", "dimensional", "arrays", "and", "determining", "it", "s", "root", "keys", "and", "values", "." ]
147e21a486653cc35481dad6d038a919e12ea19d
https://github.com/Kylob/Form/blob/147e21a486653cc35481dad6d038a919e12ea19d/src/Component.php#L661-L678
235,843
nirosa/bencode
src/Bencode.php
Bencode.encode
public function encode($d) { if (is_array($d)) { $def = 'd'; $s = ''; // If first array key is an integer, assume list. $list = false; if (is_int(array_keys($d)[0])) { $list = true; $def = 'l'; } ksort($d, SORT_STRING); foreach ($d as $key => $value) { if (is_string($key)) { if ($list) { throw new Exception('Invalid bencode data.', 1); } $s .= strlen($key) . ':' . $key; } if (is_int($value) || is_float($value)) { $s .= 'i' . $value . 'e'; } elseif (is_string($value)) { $s .= strlen($value) . ':' . $value; } else { $s .= $this->encode($value); } } return $def . $s . 'e'; } elseif (is_int($d)) { return 'i' . $d . 'e'; } elseif (is_string($d)) { return strlen($d) . ':' . $d; } else { throw new Exception('Invalid data provided to Bencode.', 1); } }
php
public function encode($d) { if (is_array($d)) { $def = 'd'; $s = ''; // If first array key is an integer, assume list. $list = false; if (is_int(array_keys($d)[0])) { $list = true; $def = 'l'; } ksort($d, SORT_STRING); foreach ($d as $key => $value) { if (is_string($key)) { if ($list) { throw new Exception('Invalid bencode data.', 1); } $s .= strlen($key) . ':' . $key; } if (is_int($value) || is_float($value)) { $s .= 'i' . $value . 'e'; } elseif (is_string($value)) { $s .= strlen($value) . ':' . $value; } else { $s .= $this->encode($value); } } return $def . $s . 'e'; } elseif (is_int($d)) { return 'i' . $d . 'e'; } elseif (is_string($d)) { return strlen($d) . ':' . $d; } else { throw new Exception('Invalid data provided to Bencode.', 1); } }
[ "public", "function", "encode", "(", "$", "d", ")", "{", "if", "(", "is_array", "(", "$", "d", ")", ")", "{", "$", "def", "=", "'d'", ";", "$", "s", "=", "''", ";", "// If first array key is an integer, assume list.", "$", "list", "=", "false", ";", "if", "(", "is_int", "(", "array_keys", "(", "$", "d", ")", "[", "0", "]", ")", ")", "{", "$", "list", "=", "true", ";", "$", "def", "=", "'l'", ";", "}", "ksort", "(", "$", "d", ",", "SORT_STRING", ")", ";", "foreach", "(", "$", "d", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "if", "(", "$", "list", ")", "{", "throw", "new", "Exception", "(", "'Invalid bencode data.'", ",", "1", ")", ";", "}", "$", "s", ".=", "strlen", "(", "$", "key", ")", ".", "':'", ".", "$", "key", ";", "}", "if", "(", "is_int", "(", "$", "value", ")", "||", "is_float", "(", "$", "value", ")", ")", "{", "$", "s", ".=", "'i'", ".", "$", "value", ".", "'e'", ";", "}", "elseif", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "s", ".=", "strlen", "(", "$", "value", ")", ".", "':'", ".", "$", "value", ";", "}", "else", "{", "$", "s", ".=", "$", "this", "->", "encode", "(", "$", "value", ")", ";", "}", "}", "return", "$", "def", ".", "$", "s", ".", "'e'", ";", "}", "elseif", "(", "is_int", "(", "$", "d", ")", ")", "{", "return", "'i'", ".", "$", "d", ".", "'e'", ";", "}", "elseif", "(", "is_string", "(", "$", "d", ")", ")", "{", "return", "strlen", "(", "$", "d", ")", ".", "':'", ".", "$", "d", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'Invalid data provided to Bencode.'", ",", "1", ")", ";", "}", "}" ]
Encodes data to Bencode data. @param array|string|integer $d Data to encode. @return string Bencoded data.
[ "Encodes", "data", "to", "Bencode", "data", "." ]
2e5b6c1820cee9355b51049177be9d44178a8b8e
https://github.com/nirosa/bencode/blob/2e5b6c1820cee9355b51049177be9d44178a8b8e/src/Bencode.php#L24-L63
235,844
nirosa/bencode
src/Bencode.php
Bencode.decode
public function decode($d, &$pos = 0) { if (!is_string($d)) { throw new Exception('Tried to decode non-string data.', 1); } if (strlen($d) <= $pos) { return null; } switch ($d[$pos]) { case 'd': $ret = []; $pos++; while ($d[$pos] != 'e') { $key = $this->decode($d, $pos); $value = $this->decode($d, $pos); if (is_null($key) || is_null($value)) { break; } $ret[$key] = $value; } $pos++; return $ret; case 'l': $ret = []; $pos++; while ($d[$pos] != 'e') { $value = $this->decode($d, $pos); if (is_null($value)) { break; } $ret[] = $value; } $pos++; return $ret; case 'i': $pos++; $length = strpos($d, 'e', $pos) - $pos; $value = intval(substr($d, $pos, $length)); $pos += $length + 1; return $value; default: $length = strpos($d, ':', $pos) - $pos; if (!$this->validLength($length)) { return null; } $valueLength = intval(substr($d, $pos, $length)); $pos += $length + 1; $str = substr($d, $pos, $valueLength); $pos += $valueLength; return $str; } }
php
public function decode($d, &$pos = 0) { if (!is_string($d)) { throw new Exception('Tried to decode non-string data.', 1); } if (strlen($d) <= $pos) { return null; } switch ($d[$pos]) { case 'd': $ret = []; $pos++; while ($d[$pos] != 'e') { $key = $this->decode($d, $pos); $value = $this->decode($d, $pos); if (is_null($key) || is_null($value)) { break; } $ret[$key] = $value; } $pos++; return $ret; case 'l': $ret = []; $pos++; while ($d[$pos] != 'e') { $value = $this->decode($d, $pos); if (is_null($value)) { break; } $ret[] = $value; } $pos++; return $ret; case 'i': $pos++; $length = strpos($d, 'e', $pos) - $pos; $value = intval(substr($d, $pos, $length)); $pos += $length + 1; return $value; default: $length = strpos($d, ':', $pos) - $pos; if (!$this->validLength($length)) { return null; } $valueLength = intval(substr($d, $pos, $length)); $pos += $length + 1; $str = substr($d, $pos, $valueLength); $pos += $valueLength; return $str; } }
[ "public", "function", "decode", "(", "$", "d", ",", "&", "$", "pos", "=", "0", ")", "{", "if", "(", "!", "is_string", "(", "$", "d", ")", ")", "{", "throw", "new", "Exception", "(", "'Tried to decode non-string data.'", ",", "1", ")", ";", "}", "if", "(", "strlen", "(", "$", "d", ")", "<=", "$", "pos", ")", "{", "return", "null", ";", "}", "switch", "(", "$", "d", "[", "$", "pos", "]", ")", "{", "case", "'d'", ":", "$", "ret", "=", "[", "]", ";", "$", "pos", "++", ";", "while", "(", "$", "d", "[", "$", "pos", "]", "!=", "'e'", ")", "{", "$", "key", "=", "$", "this", "->", "decode", "(", "$", "d", ",", "$", "pos", ")", ";", "$", "value", "=", "$", "this", "->", "decode", "(", "$", "d", ",", "$", "pos", ")", ";", "if", "(", "is_null", "(", "$", "key", ")", "||", "is_null", "(", "$", "value", ")", ")", "{", "break", ";", "}", "$", "ret", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "pos", "++", ";", "return", "$", "ret", ";", "case", "'l'", ":", "$", "ret", "=", "[", "]", ";", "$", "pos", "++", ";", "while", "(", "$", "d", "[", "$", "pos", "]", "!=", "'e'", ")", "{", "$", "value", "=", "$", "this", "->", "decode", "(", "$", "d", ",", "$", "pos", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "break", ";", "}", "$", "ret", "[", "]", "=", "$", "value", ";", "}", "$", "pos", "++", ";", "return", "$", "ret", ";", "case", "'i'", ":", "$", "pos", "++", ";", "$", "length", "=", "strpos", "(", "$", "d", ",", "'e'", ",", "$", "pos", ")", "-", "$", "pos", ";", "$", "value", "=", "intval", "(", "substr", "(", "$", "d", ",", "$", "pos", ",", "$", "length", ")", ")", ";", "$", "pos", "+=", "$", "length", "+", "1", ";", "return", "$", "value", ";", "default", ":", "$", "length", "=", "strpos", "(", "$", "d", ",", "':'", ",", "$", "pos", ")", "-", "$", "pos", ";", "if", "(", "!", "$", "this", "->", "validLength", "(", "$", "length", ")", ")", "{", "return", "null", ";", "}", "$", "valueLength", "=", "intval", "(", "substr", "(", "$", "d", ",", "$", "pos", ",", "$", "length", ")", ")", ";", "$", "pos", "+=", "$", "length", "+", "1", ";", "$", "str", "=", "substr", "(", "$", "d", ",", "$", "pos", ",", "$", "valueLength", ")", ";", "$", "pos", "+=", "$", "valueLength", ";", "return", "$", "str", ";", "}", "}" ]
Decodes Bencode data. @param string $d Bencode data to decode. @param integer &$pos Data position pointer. @return array|string|integer Decoded data.
[ "Decodes", "Bencode", "data", "." ]
2e5b6c1820cee9355b51049177be9d44178a8b8e
https://github.com/nirosa/bencode/blob/2e5b6c1820cee9355b51049177be9d44178a8b8e/src/Bencode.php#L71-L127
235,845
phossa2/libs
src/Phossa2/Db/Driver/Mysqli/Result.php
Result.getFields
protected function getFields()/*# : bool */ { if (null === $this->cols) { $result = $this->statement->result_metadata(); if (false === $result) { return false; } $this->cols = []; // set column name foreach ($result->fetch_fields() as $col) { $this->cols[] = $col->name; } } return true; }
php
protected function getFields()/*# : bool */ { if (null === $this->cols) { $result = $this->statement->result_metadata(); if (false === $result) { return false; } $this->cols = []; // set column name foreach ($result->fetch_fields() as $col) { $this->cols[] = $col->name; } } return true; }
[ "protected", "function", "getFields", "(", ")", "/*# : bool */", "{", "if", "(", "null", "===", "$", "this", "->", "cols", ")", "{", "$", "result", "=", "$", "this", "->", "statement", "->", "result_metadata", "(", ")", ";", "if", "(", "false", "===", "$", "result", ")", "{", "return", "false", ";", "}", "$", "this", "->", "cols", "=", "[", "]", ";", "// set column name", "foreach", "(", "$", "result", "->", "fetch_fields", "(", ")", "as", "$", "col", ")", "{", "$", "this", "->", "cols", "[", "]", "=", "$", "col", "->", "name", ";", "}", "}", "return", "true", ";", "}" ]
Get fields first @return bool @access protected
[ "Get", "fields", "first" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Driver/Mysqli/Result.php#L177-L193
235,846
rozaverta/cmf
core/Plugin/Plugin.php
Plugin.load
public function load() { if( $this->cacheType() === "data" ) { $ref = new \ReflectionClass($this); $cache_name = Str::snake($ref->getShortName()); $cache_data = $this->cacheData(); if( isset($cache_data["id"]) ) { $id = $cache_data["id"]; unset($cache_data["id"]); } else { $id = $cache_data; } $cache = new Cache( $id, "plugin/" . $cache_name, $cache_data ); if( $cache->ready() ) { $this->plugin_data = $cache->import(); } else { $this->loadPluginData(); $cache->export($this->plugin_data); } } else { $this->loadPluginData(); } return $this; }
php
public function load() { if( $this->cacheType() === "data" ) { $ref = new \ReflectionClass($this); $cache_name = Str::snake($ref->getShortName()); $cache_data = $this->cacheData(); if( isset($cache_data["id"]) ) { $id = $cache_data["id"]; unset($cache_data["id"]); } else { $id = $cache_data; } $cache = new Cache( $id, "plugin/" . $cache_name, $cache_data ); if( $cache->ready() ) { $this->plugin_data = $cache->import(); } else { $this->loadPluginData(); $cache->export($this->plugin_data); } } else { $this->loadPluginData(); } return $this; }
[ "public", "function", "load", "(", ")", "{", "if", "(", "$", "this", "->", "cacheType", "(", ")", "===", "\"data\"", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "cache_name", "=", "Str", "::", "snake", "(", "$", "ref", "->", "getShortName", "(", ")", ")", ";", "$", "cache_data", "=", "$", "this", "->", "cacheData", "(", ")", ";", "if", "(", "isset", "(", "$", "cache_data", "[", "\"id\"", "]", ")", ")", "{", "$", "id", "=", "$", "cache_data", "[", "\"id\"", "]", ";", "unset", "(", "$", "cache_data", "[", "\"id\"", "]", ")", ";", "}", "else", "{", "$", "id", "=", "$", "cache_data", ";", "}", "$", "cache", "=", "new", "Cache", "(", "$", "id", ",", "\"plugin/\"", ".", "$", "cache_name", ",", "$", "cache_data", ")", ";", "if", "(", "$", "cache", "->", "ready", "(", ")", ")", "{", "$", "this", "->", "plugin_data", "=", "$", "cache", "->", "import", "(", ")", ";", "}", "else", "{", "$", "this", "->", "loadPluginData", "(", ")", ";", "$", "cache", "->", "export", "(", "$", "this", "->", "plugin_data", ")", ";", "}", "}", "else", "{", "$", "this", "->", "loadPluginData", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Load plugin data @return $this
[ "Load", "plugin", "data" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Plugin/Plugin.php#L93-L128
235,847
Arbitracker/VCSWrapper
src/main/php/Arbit/VCSWrapper/Archive/Directory.php
Directory.hasChildren
public function hasChildren() { if ($this->resources === null) { $this->initializeResouces(); } return current($this->resources) instanceof \Arbit\VCSWrapper\Directory; }
php
public function hasChildren() { if ($this->resources === null) { $this->initializeResouces(); } return current($this->resources) instanceof \Arbit\VCSWrapper\Directory; }
[ "public", "function", "hasChildren", "(", ")", "{", "if", "(", "$", "this", "->", "resources", "===", "null", ")", "{", "$", "this", "->", "initializeResouces", "(", ")", ";", "}", "return", "current", "(", "$", "this", "->", "resources", ")", "instanceof", "\\", "Arbit", "\\", "VCSWrapper", "\\", "Directory", ";", "}" ]
Returns if an iterator can be created fot the current entry. @return bool
[ "Returns", "if", "an", "iterator", "can", "be", "created", "fot", "the", "current", "entry", "." ]
64907c0c438600ce67d79a5d17f5155563f2bbf2
https://github.com/Arbitracker/VCSWrapper/blob/64907c0c438600ce67d79a5d17f5155563f2bbf2/src/main/php/Arbit/VCSWrapper/Archive/Directory.php#L163-L170
235,848
Notifier/Notifier
src/Notifier.php
Notifier.addChannel
public function addChannel(ChannelInterface $channel) { $this->getChannelStore() ->addChannel($channel); $processor = $channel->getProcessor(); if ($processor) { $this->getProcessorStore()->addProcessor($processor); } }
php
public function addChannel(ChannelInterface $channel) { $this->getChannelStore() ->addChannel($channel); $processor = $channel->getProcessor(); if ($processor) { $this->getProcessorStore()->addProcessor($processor); } }
[ "public", "function", "addChannel", "(", "ChannelInterface", "$", "channel", ")", "{", "$", "this", "->", "getChannelStore", "(", ")", "->", "addChannel", "(", "$", "channel", ")", ";", "$", "processor", "=", "$", "channel", "->", "getProcessor", "(", ")", ";", "if", "(", "$", "processor", ")", "{", "$", "this", "->", "getProcessorStore", "(", ")", "->", "addProcessor", "(", "$", "processor", ")", ";", "}", "}" ]
Add a channel. @api @param ChannelInterface $channel
[ "Add", "a", "channel", "." ]
1f95656ae963b68734935773c11e44c0af412303
https://github.com/Notifier/Notifier/blob/1f95656ae963b68734935773c11e44c0af412303/src/Notifier.php#L96-L105
235,849
Notifier/Notifier
src/Notifier.php
Notifier.sendMessage
public function sendMessage(MessageInterface $message, array $recipients) { $messageProcessor = new MessageProcessor($this->getProcessorStore()); $message = $messageProcessor->preProcessMessage($message); foreach ($recipients as $recipient) { foreach ($this->getChannels($message, $recipient) as $channel) { $processedMessage = $messageProcessor ->processMessage(clone($message), $recipient); if ($channel->isHandling($processedMessage, $recipient)) { $channel->send($processedMessage, $recipient); } } } }
php
public function sendMessage(MessageInterface $message, array $recipients) { $messageProcessor = new MessageProcessor($this->getProcessorStore()); $message = $messageProcessor->preProcessMessage($message); foreach ($recipients as $recipient) { foreach ($this->getChannels($message, $recipient) as $channel) { $processedMessage = $messageProcessor ->processMessage(clone($message), $recipient); if ($channel->isHandling($processedMessage, $recipient)) { $channel->send($processedMessage, $recipient); } } } }
[ "public", "function", "sendMessage", "(", "MessageInterface", "$", "message", ",", "array", "$", "recipients", ")", "{", "$", "messageProcessor", "=", "new", "MessageProcessor", "(", "$", "this", "->", "getProcessorStore", "(", ")", ")", ";", "$", "message", "=", "$", "messageProcessor", "->", "preProcessMessage", "(", "$", "message", ")", ";", "foreach", "(", "$", "recipients", "as", "$", "recipient", ")", "{", "foreach", "(", "$", "this", "->", "getChannels", "(", "$", "message", ",", "$", "recipient", ")", "as", "$", "channel", ")", "{", "$", "processedMessage", "=", "$", "messageProcessor", "->", "processMessage", "(", "clone", "(", "$", "message", ")", ",", "$", "recipient", ")", ";", "if", "(", "$", "channel", "->", "isHandling", "(", "$", "processedMessage", ",", "$", "recipient", ")", ")", "{", "$", "channel", "->", "send", "(", "$", "processedMessage", ",", "$", "recipient", ")", ";", "}", "}", "}", "}" ]
Send a message to any number of recipients. @api @param MessageInterface $message @param RecipientInterface[] $recipients
[ "Send", "a", "message", "to", "any", "number", "of", "recipients", "." ]
1f95656ae963b68734935773c11e44c0af412303
https://github.com/Notifier/Notifier/blob/1f95656ae963b68734935773c11e44c0af412303/src/Notifier.php#L140-L154
235,850
Notifier/Notifier
src/Notifier.php
Notifier.getChannels
private function getChannels(MessageInterface $message, RecipientInterface $recipient) { $channels = $this->channelResolver ->getChannels($message->getType(), $this->getChannelStore()); return $this->channelResolver ->filterChannels($recipient, $message->getType(), $channels); }
php
private function getChannels(MessageInterface $message, RecipientInterface $recipient) { $channels = $this->channelResolver ->getChannels($message->getType(), $this->getChannelStore()); return $this->channelResolver ->filterChannels($recipient, $message->getType(), $channels); }
[ "private", "function", "getChannels", "(", "MessageInterface", "$", "message", ",", "RecipientInterface", "$", "recipient", ")", "{", "$", "channels", "=", "$", "this", "->", "channelResolver", "->", "getChannels", "(", "$", "message", "->", "getType", "(", ")", ",", "$", "this", "->", "getChannelStore", "(", ")", ")", ";", "return", "$", "this", "->", "channelResolver", "->", "filterChannels", "(", "$", "recipient", ",", "$", "message", "->", "getType", "(", ")", ",", "$", "channels", ")", ";", "}" ]
Apply all logic to get the correct channels for the current recipient. @param MessageInterface $message @param RecipientInterface $recipient @return ChannelInterface[]
[ "Apply", "all", "logic", "to", "get", "the", "correct", "channels", "for", "the", "current", "recipient", "." ]
1f95656ae963b68734935773c11e44c0af412303
https://github.com/Notifier/Notifier/blob/1f95656ae963b68734935773c11e44c0af412303/src/Notifier.php#L163-L170
235,851
koinephp/Core
lib/Koine/Hash.php
Hash.reject
public function reject(Closure $callback) { $hash = $this->create(); foreach ($this as $key => $value) { if ($callback($value, $key) == false) { $hash[$key] = $value; } } return $hash; }
php
public function reject(Closure $callback) { $hash = $this->create(); foreach ($this as $key => $value) { if ($callback($value, $key) == false) { $hash[$key] = $value; } } return $hash; }
[ "public", "function", "reject", "(", "Closure", "$", "callback", ")", "{", "$", "hash", "=", "$", "this", "->", "create", "(", ")", ";", "foreach", "(", "$", "this", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "callback", "(", "$", "value", ",", "$", "key", ")", "==", "false", ")", "{", "$", "hash", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "hash", ";", "}" ]
Rejects elements if the given function evaluates to true @param Closure $callable function @return Hash the new hash containing the non rejected elements
[ "Rejects", "elements", "if", "the", "given", "function", "evaluates", "to", "true" ]
9b9543f1b4699fd515590f2f94654bad098821ff
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/Hash.php#L188-L199
235,852
koinephp/Core
lib/Koine/Hash.php
Hash.map
public function map(Closure $callback) { $hash = $this->create(); $this->each(function ($value, $key) use ($callback, $hash) { $hash[] = $callback($value, $key); }); return $hash; }
php
public function map(Closure $callback) { $hash = $this->create(); $this->each(function ($value, $key) use ($callback, $hash) { $hash[] = $callback($value, $key); }); return $hash; }
[ "public", "function", "map", "(", "Closure", "$", "callback", ")", "{", "$", "hash", "=", "$", "this", "->", "create", "(", ")", ";", "$", "this", "->", "each", "(", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "callback", ",", "$", "hash", ")", "{", "$", "hash", "[", "]", "=", "$", "callback", "(", "$", "value", ",", "$", "key", ")", ";", "}", ")", ";", "return", "$", "hash", ";", "}" ]
Maps elements into a new Hash @param Closure $callback @return Hash
[ "Maps", "elements", "into", "a", "new", "Hash" ]
9b9543f1b4699fd515590f2f94654bad098821ff
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/Hash.php#L244-L253
235,853
koinephp/Core
lib/Koine/Hash.php
Hash.fetch
public function fetch($key, $default = null) { if ($this->hasKey($key)) { return $this[$key]; } elseif ($default !== null) { if (is_callable($default)) { return $default($key); } return $default; } throw new InvalidArgumentException("Invalid key '$key'"); }
php
public function fetch($key, $default = null) { if ($this->hasKey($key)) { return $this[$key]; } elseif ($default !== null) { if (is_callable($default)) { return $default($key); } return $default; } throw new InvalidArgumentException("Invalid key '$key'"); }
[ "public", "function", "fetch", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "this", "->", "hasKey", "(", "$", "key", ")", ")", "{", "return", "$", "this", "[", "$", "key", "]", ";", "}", "elseif", "(", "$", "default", "!==", "null", ")", "{", "if", "(", "is_callable", "(", "$", "default", ")", ")", "{", "return", "$", "default", "(", "$", "key", ")", ";", "}", "return", "$", "default", ";", "}", "throw", "new", "InvalidArgumentException", "(", "\"Invalid key '$key'\"", ")", ";", "}" ]
Get the value by the key. Throws exception when key is not set @param string $key @param mixed $default either value or callable function @return mixed the value for the given key @throws InvalidArgumentException
[ "Get", "the", "value", "by", "the", "key", ".", "Throws", "exception", "when", "key", "is", "not", "set" ]
9b9543f1b4699fd515590f2f94654bad098821ff
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/Hash.php#L354-L367
235,854
koinephp/Core
lib/Koine/Hash.php
Hash.valuesAt
public function valuesAt() { $args = func_get_args(); if (is_array($args[0])) { $args = $args[0]; } $hash = $this->create(); foreach ($args as $key) { $hash[] = $this[$key]; } return $hash; }
php
public function valuesAt() { $args = func_get_args(); if (is_array($args[0])) { $args = $args[0]; } $hash = $this->create(); foreach ($args as $key) { $hash[] = $this[$key]; } return $hash; }
[ "public", "function", "valuesAt", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "is_array", "(", "$", "args", "[", "0", "]", ")", ")", "{", "$", "args", "=", "$", "args", "[", "0", "]", ";", "}", "$", "hash", "=", "$", "this", "->", "create", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "key", ")", "{", "$", "hash", "[", "]", "=", "$", "this", "[", "$", "key", "]", ";", "}", "return", "$", "hash", ";", "}" ]
Get the values at the given indexes. Both work the same: <code> $hash->valuesAt(array('a', 'b')); $hash->valuesAt('a', 'b'); </code> @param mixed keys @return Hash containing the values at the given keys
[ "Get", "the", "values", "at", "the", "given", "indexes", "." ]
9b9543f1b4699fd515590f2f94654bad098821ff
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/Hash.php#L382-L397
235,855
koinephp/Core
lib/Koine/Hash.php
Hash.groupBy
public function groupBy($criteria) { $criteria = $this->factoryCallableCriteria($criteria); $groups = $this->create(); $this->each(function ($element, $key) use ($groups, $criteria) { $groupName = $criteria($element, $key); $elements = $groups->offsetGet($groupName, array()); $elements[] = $element; $groups[$groupName] = $elements; }); return $groups; }
php
public function groupBy($criteria) { $criteria = $this->factoryCallableCriteria($criteria); $groups = $this->create(); $this->each(function ($element, $key) use ($groups, $criteria) { $groupName = $criteria($element, $key); $elements = $groups->offsetGet($groupName, array()); $elements[] = $element; $groups[$groupName] = $elements; }); return $groups; }
[ "public", "function", "groupBy", "(", "$", "criteria", ")", "{", "$", "criteria", "=", "$", "this", "->", "factoryCallableCriteria", "(", "$", "criteria", ")", ";", "$", "groups", "=", "$", "this", "->", "create", "(", ")", ";", "$", "this", "->", "each", "(", "function", "(", "$", "element", ",", "$", "key", ")", "use", "(", "$", "groups", ",", "$", "criteria", ")", "{", "$", "groupName", "=", "$", "criteria", "(", "$", "element", ",", "$", "key", ")", ";", "$", "elements", "=", "$", "groups", "->", "offsetGet", "(", "$", "groupName", ",", "array", "(", ")", ")", ";", "$", "elements", "[", "]", "=", "$", "element", ";", "$", "groups", "[", "$", "groupName", "]", "=", "$", "elements", ";", "}", ")", ";", "return", "$", "groups", ";", "}" ]
Group elements by the given criteria @param mixed $criteria it can be either a callable function or a string, representing a key of an element @return Hash
[ "Group", "elements", "by", "the", "given", "criteria" ]
9b9543f1b4699fd515590f2f94654bad098821ff
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/Hash.php#L467-L480
235,856
koinephp/Core
lib/Koine/Hash.php
Hash.sortBy
public function sortBy($criteria) { $criteria = $this->factoryCallableCriteria($criteria); $sorted = $this->create(); $groups = $this->groupBy($criteria); $criterias = $this->map(function ($element, $key) use ($criteria) { return $criteria($element, $key); })->toArray(); sort($criterias); $criterias = array_unique($criterias); foreach ($criterias as $key) { foreach ($groups[$key] as $element) { $sorted[] = $element; } } return $sorted; }
php
public function sortBy($criteria) { $criteria = $this->factoryCallableCriteria($criteria); $sorted = $this->create(); $groups = $this->groupBy($criteria); $criterias = $this->map(function ($element, $key) use ($criteria) { return $criteria($element, $key); })->toArray(); sort($criterias); $criterias = array_unique($criterias); foreach ($criterias as $key) { foreach ($groups[$key] as $element) { $sorted[] = $element; } } return $sorted; }
[ "public", "function", "sortBy", "(", "$", "criteria", ")", "{", "$", "criteria", "=", "$", "this", "->", "factoryCallableCriteria", "(", "$", "criteria", ")", ";", "$", "sorted", "=", "$", "this", "->", "create", "(", ")", ";", "$", "groups", "=", "$", "this", "->", "groupBy", "(", "$", "criteria", ")", ";", "$", "criterias", "=", "$", "this", "->", "map", "(", "function", "(", "$", "element", ",", "$", "key", ")", "use", "(", "$", "criteria", ")", "{", "return", "$", "criteria", "(", "$", "element", ",", "$", "key", ")", ";", "}", ")", "->", "toArray", "(", ")", ";", "sort", "(", "$", "criterias", ")", ";", "$", "criterias", "=", "array_unique", "(", "$", "criterias", ")", ";", "foreach", "(", "$", "criterias", "as", "$", "key", ")", "{", "foreach", "(", "$", "groups", "[", "$", "key", "]", "as", "$", "element", ")", "{", "$", "sorted", "[", "]", "=", "$", "element", ";", "}", "}", "return", "$", "sorted", ";", "}" ]
Sort elements by the given criteria @param mixed $criteria it can be either a callable function or a string, representing a key of an element @return Hash
[ "Sort", "elements", "by", "the", "given", "criteria" ]
9b9543f1b4699fd515590f2f94654bad098821ff
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/Hash.php#L490-L510
235,857
koinephp/Core
lib/Koine/Hash.php
Hash.factoryCallableCriteria
private function factoryCallableCriteria($criteria) { if (!$this->isCallable($criteria)) { $criteria = function ($element, $key) use ($criteria) { return $element->fetch($criteria); }; } return $criteria; }
php
private function factoryCallableCriteria($criteria) { if (!$this->isCallable($criteria)) { $criteria = function ($element, $key) use ($criteria) { return $element->fetch($criteria); }; } return $criteria; }
[ "private", "function", "factoryCallableCriteria", "(", "$", "criteria", ")", "{", "if", "(", "!", "$", "this", "->", "isCallable", "(", "$", "criteria", ")", ")", "{", "$", "criteria", "=", "function", "(", "$", "element", ",", "$", "key", ")", "use", "(", "$", "criteria", ")", "{", "return", "$", "element", "->", "fetch", "(", "$", "criteria", ")", ";", "}", ";", "}", "return", "$", "criteria", ";", "}" ]
Get a function that returns something based on an element item @mixed $criteria either a callable function that returns a value or a string that is an element key @return callable
[ "Get", "a", "function", "that", "returns", "something", "based", "on", "an", "element", "item" ]
9b9543f1b4699fd515590f2f94654bad098821ff
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/Hash.php#L557-L566
235,858
koinephp/Core
lib/Koine/Hash.php
Hash.merge
public function merge(Hash $other, Closure $closure = null) { return $this->mergeInto(clone $this, $other, $closure); }
php
public function merge(Hash $other, Closure $closure = null) { return $this->mergeInto(clone $this, $other, $closure); }
[ "public", "function", "merge", "(", "Hash", "$", "other", ",", "Closure", "$", "closure", "=", "null", ")", "{", "return", "$", "this", "->", "mergeInto", "(", "clone", "$", "this", ",", "$", "other", ",", "$", "closure", ")", ";", "}" ]
Merges the two hashes and return a new Instance of a hash @param Hash $other @param Closure $closure function to resolv conflicts @return Hash the merged hash
[ "Merges", "the", "two", "hashes", "and", "return", "a", "new", "Instance", "of", "a", "hash" ]
9b9543f1b4699fd515590f2f94654bad098821ff
https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/Hash.php#L604-L607
235,859
phonedotcom/mason-php
src/Builder/Components/Base.php
Base.minimize
public function minimize() { foreach (get_object_vars($this) as $property => $value) { if ($value instanceof self) { $value->minimize(); } elseif (is_array($value)) { $this->minimizeArray($value); } } return $this; }
php
public function minimize() { foreach (get_object_vars($this) as $property => $value) { if ($value instanceof self) { $value->minimize(); } elseif (is_array($value)) { $this->minimizeArray($value); } } return $this; }
[ "public", "function", "minimize", "(", ")", "{", "foreach", "(", "get_object_vars", "(", "$", "this", ")", "as", "$", "property", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "self", ")", "{", "$", "value", "->", "minimize", "(", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "minimizeArray", "(", "$", "value", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Recursively remove all properties that don't belong in the minimal representation of this object @return $this
[ "Recursively", "remove", "all", "properties", "that", "don", "t", "belong", "in", "the", "minimal", "representation", "of", "this", "object" ]
ddf82ba91b169e47dce2eee6cea7c2d20428c647
https://github.com/phonedotcom/mason-php/blob/ddf82ba91b169e47dce2eee6cea7c2d20428c647/src/Builder/Components/Base.php#L58-L70
235,860
phonedotcom/mason-php
src/Builder/Components/Base.php
Base.sort
public function sort( array $defaultOrder, array $controlsOrder = null, array $metaOrder = null, array $errorOrder = null ) { if (!in_array('{data}', $defaultOrder)) { throw new \InvalidArgumentException('Placeholder "{data}" not listed in $defaultOrder'); } elseif ($controlsOrder && !in_array('{data}', $controlsOrder)) { throw new \InvalidArgumentException('Placeholder "{data}" not listed in $controlsOrder'); } elseif ($metaOrder && !in_array('{data}', $metaOrder)) { throw new \InvalidArgumentException('Placeholder "{data}" not listed in $metaOrder'); } elseif ($errorOrder && !in_array('{data}', $errorOrder)) { throw new \InvalidArgumentException('Placeholder "{data}" not listed in $errorOrder'); } $controlsOrder || $controlsOrder = $defaultOrder; $metaOrder || $metaOrder = $defaultOrder; $errorOrder || $errorOrder = $defaultOrder; $this->applySort('', $defaultOrder, $controlsOrder, $metaOrder, $errorOrder); return $this; }
php
public function sort( array $defaultOrder, array $controlsOrder = null, array $metaOrder = null, array $errorOrder = null ) { if (!in_array('{data}', $defaultOrder)) { throw new \InvalidArgumentException('Placeholder "{data}" not listed in $defaultOrder'); } elseif ($controlsOrder && !in_array('{data}', $controlsOrder)) { throw new \InvalidArgumentException('Placeholder "{data}" not listed in $controlsOrder'); } elseif ($metaOrder && !in_array('{data}', $metaOrder)) { throw new \InvalidArgumentException('Placeholder "{data}" not listed in $metaOrder'); } elseif ($errorOrder && !in_array('{data}', $errorOrder)) { throw new \InvalidArgumentException('Placeholder "{data}" not listed in $errorOrder'); } $controlsOrder || $controlsOrder = $defaultOrder; $metaOrder || $metaOrder = $defaultOrder; $errorOrder || $errorOrder = $defaultOrder; $this->applySort('', $defaultOrder, $controlsOrder, $metaOrder, $errorOrder); return $this; }
[ "public", "function", "sort", "(", "array", "$", "defaultOrder", ",", "array", "$", "controlsOrder", "=", "null", ",", "array", "$", "metaOrder", "=", "null", ",", "array", "$", "errorOrder", "=", "null", ")", "{", "if", "(", "!", "in_array", "(", "'{data}'", ",", "$", "defaultOrder", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Placeholder \"{data}\" not listed in $defaultOrder'", ")", ";", "}", "elseif", "(", "$", "controlsOrder", "&&", "!", "in_array", "(", "'{data}'", ",", "$", "controlsOrder", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Placeholder \"{data}\" not listed in $controlsOrder'", ")", ";", "}", "elseif", "(", "$", "metaOrder", "&&", "!", "in_array", "(", "'{data}'", ",", "$", "metaOrder", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Placeholder \"{data}\" not listed in $metaOrder'", ")", ";", "}", "elseif", "(", "$", "errorOrder", "&&", "!", "in_array", "(", "'{data}'", ",", "$", "errorOrder", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Placeholder \"{data}\" not listed in $errorOrder'", ")", ";", "}", "$", "controlsOrder", "||", "$", "controlsOrder", "=", "$", "defaultOrder", ";", "$", "metaOrder", "||", "$", "metaOrder", "=", "$", "defaultOrder", ";", "$", "errorOrder", "||", "$", "errorOrder", "=", "$", "defaultOrder", ";", "$", "this", "->", "applySort", "(", "''", ",", "$", "defaultOrder", ",", "$", "controlsOrder", ",", "$", "metaOrder", ",", "$", "errorOrder", ")", ";", "return", "$", "this", ";", "}" ]
This method allows an object's properties to be sorted according to an arbitrary sequence of properties. This is useful for standardizing the sequence of properties across several documents and for keeping the more important properties higher up. @param array $defaultOrder Preferred order of property names. Can include any Mason or custom property. Ordering will be applied at all levels within the document. Properties that are not found at a given level are gracefully ignored. Must include an element named "{data}". This is where all unspecified properties will be placed. All such properties will maintain the same order as they had before sorting. @return $this
[ "This", "method", "allows", "an", "object", "s", "properties", "to", "be", "sorted", "according", "to", "an", "arbitrary", "sequence", "of", "properties", ".", "This", "is", "useful", "for", "standardizing", "the", "sequence", "of", "properties", "across", "several", "documents", "and", "for", "keeping", "the", "more", "important", "properties", "higher", "up", "." ]
ddf82ba91b169e47dce2eee6cea7c2d20428c647
https://github.com/phonedotcom/mason-php/blob/ddf82ba91b169e47dce2eee6cea7c2d20428c647/src/Builder/Components/Base.php#L96-L122
235,861
snapwp/snap-debug
src/Handlers/Ajax.php
Ajax.handle
public function handle() { if (! $this->is_ajax_request()) { return Handler::DONE; } $response = [ 'success' => false, 'data' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()), ]; if (Misc::canSendHeaders()) { \header('Content-Type: application/json; charset=' . get_option('blog_charset')); } echo wp_json_encode($response, JSON_PRETTY_PRINT); return Handler::QUIT; }
php
public function handle() { if (! $this->is_ajax_request()) { return Handler::DONE; } $response = [ 'success' => false, 'data' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()), ]; if (Misc::canSendHeaders()) { \header('Content-Type: application/json; charset=' . get_option('blog_charset')); } echo wp_json_encode($response, JSON_PRETTY_PRINT); return Handler::QUIT; }
[ "public", "function", "handle", "(", ")", "{", "if", "(", "!", "$", "this", "->", "is_ajax_request", "(", ")", ")", "{", "return", "Handler", "::", "DONE", ";", "}", "$", "response", "=", "[", "'success'", "=>", "false", ",", "'data'", "=>", "Formatter", "::", "formatExceptionAsDataArray", "(", "$", "this", "->", "getInspector", "(", ")", ",", "$", "this", "->", "addTraceToOutput", "(", ")", ")", ",", "]", ";", "if", "(", "Misc", "::", "canSendHeaders", "(", ")", ")", "{", "\\", "header", "(", "'Content-Type: application/json; charset='", ".", "get_option", "(", "'blog_charset'", ")", ")", ";", "}", "echo", "wp_json_encode", "(", "$", "response", ",", "JSON_PRETTY_PRINT", ")", ";", "return", "Handler", "::", "QUIT", ";", "}" ]
The error handler. Send the error is the standard WordPress AJAX format. @since 1.0.0 @return int
[ "The", "error", "handler", ".", "Send", "the", "error", "is", "the", "standard", "WordPress", "AJAX", "format", "." ]
49c0c258ce50098a3fca076ce122adf57571f2e2
https://github.com/snapwp/snap-debug/blob/49c0c258ce50098a3fca076ce122adf57571f2e2/src/Handlers/Ajax.php#L22-L40
235,862
luxorphp/mysql
src/StatementMYSQL.php
StatementMYSQL.executeQuery
public function executeQuery(): IResultSet { if (!strlen($this->sql) > 0) { throw new \Exception('Error sentencia sql no valida'); } $temp = $this->conect->query($this->sql); $this->sql = ""; if ($temp == null) { throw new \Exception('Error no se pudo encontrar nada en la base de datos'); } return new ResultSetMYSQL($temp); }
php
public function executeQuery(): IResultSet { if (!strlen($this->sql) > 0) { throw new \Exception('Error sentencia sql no valida'); } $temp = $this->conect->query($this->sql); $this->sql = ""; if ($temp == null) { throw new \Exception('Error no se pudo encontrar nada en la base de datos'); } return new ResultSetMYSQL($temp); }
[ "public", "function", "executeQuery", "(", ")", ":", "IResultSet", "{", "if", "(", "!", "strlen", "(", "$", "this", "->", "sql", ")", ">", "0", ")", "{", "throw", "new", "\\", "Exception", "(", "'Error sentencia sql no valida'", ")", ";", "}", "$", "temp", "=", "$", "this", "->", "conect", "->", "query", "(", "$", "this", "->", "sql", ")", ";", "$", "this", "->", "sql", "=", "\"\"", ";", "if", "(", "$", "temp", "==", "null", ")", "{", "throw", "new", "\\", "Exception", "(", "'Error no se pudo encontrar nada en la base de datos'", ")", ";", "}", "return", "new", "ResultSetMYSQL", "(", "$", "temp", ")", ";", "}" ]
Permite haser una lectura de los datos. @return IResultSet retorna un objeto de typo IResultSet si es todo correcto y null en caso de errores.
[ "Permite", "haser", "una", "lectura", "de", "los", "datos", "." ]
ca6ad7a82edd776d4a703f45a01bcaaf297af344
https://github.com/luxorphp/mysql/blob/ca6ad7a82edd776d4a703f45a01bcaaf297af344/src/StatementMYSQL.php#L60-L74
235,863
as3io/modlr-persister-mongodb
src/Query.php
Query.executeDelete
public function executeDelete(EntityMetadata $metadata, Store $store, array $criteria) { $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); return $this->createQueryBuilder($metadata) ->remove() ->setQueryArray($criteria) ->getQuery() ->execute(); ; }
php
public function executeDelete(EntityMetadata $metadata, Store $store, array $criteria) { $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); return $this->createQueryBuilder($metadata) ->remove() ->setQueryArray($criteria) ->getQuery() ->execute(); ; }
[ "public", "function", "executeDelete", "(", "EntityMetadata", "$", "metadata", ",", "Store", "$", "store", ",", "array", "$", "criteria", ")", "{", "$", "criteria", "=", "$", "this", "->", "getFormatter", "(", ")", "->", "formatQuery", "(", "$", "metadata", ",", "$", "store", ",", "$", "criteria", ")", ";", "return", "$", "this", "->", "createQueryBuilder", "(", "$", "metadata", ")", "->", "remove", "(", ")", "->", "setQueryArray", "(", "$", "criteria", ")", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", ";", "}" ]
Executes a delete for the provided metadata and criteria. @param EntityMetadata $metadata @param Store $store @param array $criteria @return array|bool
[ "Executes", "a", "delete", "for", "the", "provided", "metadata", "and", "criteria", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L63-L72
235,864
as3io/modlr-persister-mongodb
src/Query.php
Query.executeFind
public function executeFind(EntityMetadata $metadata, Store $store, array $criteria, array $fields = [], array $sort = [], $offset = 0, $limit = 0) { $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); $builder = $this->createQueryBuilder($metadata) ->find() ->setQueryArray($criteria) ; $this->appendSearch($builder, $criteria); $this->appendFields($builder, $fields); $this->appendSort($builder, $sort); $this->appendLimitAndOffset($builder, $limit, $offset); return $builder->getQuery()->execute(); }
php
public function executeFind(EntityMetadata $metadata, Store $store, array $criteria, array $fields = [], array $sort = [], $offset = 0, $limit = 0) { $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); $builder = $this->createQueryBuilder($metadata) ->find() ->setQueryArray($criteria) ; $this->appendSearch($builder, $criteria); $this->appendFields($builder, $fields); $this->appendSort($builder, $sort); $this->appendLimitAndOffset($builder, $limit, $offset); return $builder->getQuery()->execute(); }
[ "public", "function", "executeFind", "(", "EntityMetadata", "$", "metadata", ",", "Store", "$", "store", ",", "array", "$", "criteria", ",", "array", "$", "fields", "=", "[", "]", ",", "array", "$", "sort", "=", "[", "]", ",", "$", "offset", "=", "0", ",", "$", "limit", "=", "0", ")", "{", "$", "criteria", "=", "$", "this", "->", "getFormatter", "(", ")", "->", "formatQuery", "(", "$", "metadata", ",", "$", "store", ",", "$", "criteria", ")", ";", "$", "builder", "=", "$", "this", "->", "createQueryBuilder", "(", "$", "metadata", ")", "->", "find", "(", ")", "->", "setQueryArray", "(", "$", "criteria", ")", ";", "$", "this", "->", "appendSearch", "(", "$", "builder", ",", "$", "criteria", ")", ";", "$", "this", "->", "appendFields", "(", "$", "builder", ",", "$", "fields", ")", ";", "$", "this", "->", "appendSort", "(", "$", "builder", ",", "$", "sort", ")", ";", "$", "this", "->", "appendLimitAndOffset", "(", "$", "builder", ",", "$", "limit", ",", "$", "offset", ")", ";", "return", "$", "builder", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", "}" ]
Finds records from the database based on the provided metadata and criteria. @param EntityMetadata $metadata The model metadata that the database should query against. @param Store $store The store. @param array $criteria The query criteria. @param array $fields Fields to include/exclude. @param array $sort The sort criteria. @param int $offset The starting offset, aka the number of Models to skip. @param int $limit The number of Models to limit. @return \Doctrine\MongoDB\Cursor
[ "Finds", "records", "from", "the", "database", "based", "on", "the", "provided", "metadata", "and", "criteria", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L86-L101
235,865
as3io/modlr-persister-mongodb
src/Query.php
Query.executeInsert
public function executeInsert(EntityMetadata $metadata, array $toInsert) { return $this->createQueryBuilder($metadata) ->insert() ->setNewObj($toInsert) ->getQuery() ->execute() ; }
php
public function executeInsert(EntityMetadata $metadata, array $toInsert) { return $this->createQueryBuilder($metadata) ->insert() ->setNewObj($toInsert) ->getQuery() ->execute() ; }
[ "public", "function", "executeInsert", "(", "EntityMetadata", "$", "metadata", ",", "array", "$", "toInsert", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "$", "metadata", ")", "->", "insert", "(", ")", "->", "setNewObj", "(", "$", "toInsert", ")", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", "}" ]
Executes an insert for the provided metadata. @param EntityMetadata $metadata @param array $toInsert @return array|bool
[ "Executes", "an", "insert", "for", "the", "provided", "metadata", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L110-L118
235,866
as3io/modlr-persister-mongodb
src/Query.php
Query.executeUpdate
public function executeUpdate(EntityMetadata $metadata, Store $store, array $criteria, array $toUpdate) { $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); return $this->createQueryBuilder($metadata) ->update() ->setQueryArray($criteria) ->setNewObj($toUpdate) ->getQuery() ->execute(); ; }
php
public function executeUpdate(EntityMetadata $metadata, Store $store, array $criteria, array $toUpdate) { $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); return $this->createQueryBuilder($metadata) ->update() ->setQueryArray($criteria) ->setNewObj($toUpdate) ->getQuery() ->execute(); ; }
[ "public", "function", "executeUpdate", "(", "EntityMetadata", "$", "metadata", ",", "Store", "$", "store", ",", "array", "$", "criteria", ",", "array", "$", "toUpdate", ")", "{", "$", "criteria", "=", "$", "this", "->", "getFormatter", "(", ")", "->", "formatQuery", "(", "$", "metadata", ",", "$", "store", ",", "$", "criteria", ")", ";", "return", "$", "this", "->", "createQueryBuilder", "(", "$", "metadata", ")", "->", "update", "(", ")", "->", "setQueryArray", "(", "$", "criteria", ")", "->", "setNewObj", "(", "$", "toUpdate", ")", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", ";", "}" ]
Updates a record from the database based on the provided metadata and criteria. @param EntityMetadata $metadata The model metadata that the database should query against. @param Store $store The store. @param array $criteria The query criteria. @param array $toUpdate The data to update. @return array|bool
[ "Updates", "a", "record", "from", "the", "database", "based", "on", "the", "provided", "metadata", "and", "criteria", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L129-L139
235,867
as3io/modlr-persister-mongodb
src/Query.php
Query.getInverseCriteria
public function getInverseCriteria(EntityMetadata $owner, EntityMetadata $related, $identifiers, $inverseField) { $criteria = [ $inverseField => (array) $identifiers, ]; if (true === $related->isChildEntity()) { // The relationship is owned by a polymorphic model. Must include the type in the root criteria. $criteria[Persister::POLYMORPHIC_KEY] = $related->type; } return $criteria; }
php
public function getInverseCriteria(EntityMetadata $owner, EntityMetadata $related, $identifiers, $inverseField) { $criteria = [ $inverseField => (array) $identifiers, ]; if (true === $related->isChildEntity()) { // The relationship is owned by a polymorphic model. Must include the type in the root criteria. $criteria[Persister::POLYMORPHIC_KEY] = $related->type; } return $criteria; }
[ "public", "function", "getInverseCriteria", "(", "EntityMetadata", "$", "owner", ",", "EntityMetadata", "$", "related", ",", "$", "identifiers", ",", "$", "inverseField", ")", "{", "$", "criteria", "=", "[", "$", "inverseField", "=>", "(", "array", ")", "$", "identifiers", ",", "]", ";", "if", "(", "true", "===", "$", "related", "->", "isChildEntity", "(", ")", ")", "{", "// The relationship is owned by a polymorphic model. Must include the type in the root criteria.", "$", "criteria", "[", "Persister", "::", "POLYMORPHIC_KEY", "]", "=", "$", "related", "->", "type", ";", "}", "return", "$", "criteria", ";", "}" ]
Gets standard database retrieval criteria for an inverse relationship. @param EntityMetadata $owner @param EntityMetadata $related @param string|array $identifiers @param string $inverseField @return array
[ "Gets", "standard", "database", "retrieval", "criteria", "for", "an", "inverse", "relationship", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L158-L168
235,868
as3io/modlr-persister-mongodb
src/Query.php
Query.getModelCollection
public function getModelCollection(EntityMetadata $metadata) { if (!$metadata->persistence instanceof StorageMetadata) { throw PersisterException::badRequest('Wrong StorageMetadata type'); } return $this->connection->selectCollection($metadata->persistence->db, $metadata->persistence->collection); }
php
public function getModelCollection(EntityMetadata $metadata) { if (!$metadata->persistence instanceof StorageMetadata) { throw PersisterException::badRequest('Wrong StorageMetadata type'); } return $this->connection->selectCollection($metadata->persistence->db, $metadata->persistence->collection); }
[ "public", "function", "getModelCollection", "(", "EntityMetadata", "$", "metadata", ")", "{", "if", "(", "!", "$", "metadata", "->", "persistence", "instanceof", "StorageMetadata", ")", "{", "throw", "PersisterException", "::", "badRequest", "(", "'Wrong StorageMetadata type'", ")", ";", "}", "return", "$", "this", "->", "connection", "->", "selectCollection", "(", "$", "metadata", "->", "persistence", "->", "db", ",", "$", "metadata", "->", "persistence", "->", "collection", ")", ";", "}" ]
Gets the MongoDB Collection object for a Model. @param EntityMetadata $metadata @return \Doctrine\MongoDB\Collection
[ "Gets", "the", "MongoDB", "Collection", "object", "for", "a", "Model", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L176-L182
235,869
as3io/modlr-persister-mongodb
src/Query.php
Query.getRetrieveCritiera
public function getRetrieveCritiera(EntityMetadata $metadata, $identifiers = null) { $criteria = []; if (true === $metadata->isChildEntity()) { $criteria[Persister::POLYMORPHIC_KEY] = $metadata->type; } elseif (true === $metadata->isPolymorphic() && false === $metadata->isAbstract()) { $criteria[Persister::POLYMORPHIC_KEY] = $metadata->type; } $identifiers = (array) $identifiers; if (empty($identifiers)) { return $criteria; } $criteria[Persister::IDENTIFIER_KEY] = (1 === count($identifiers)) ? reset($identifiers) : $identifiers; return $criteria; }
php
public function getRetrieveCritiera(EntityMetadata $metadata, $identifiers = null) { $criteria = []; if (true === $metadata->isChildEntity()) { $criteria[Persister::POLYMORPHIC_KEY] = $metadata->type; } elseif (true === $metadata->isPolymorphic() && false === $metadata->isAbstract()) { $criteria[Persister::POLYMORPHIC_KEY] = $metadata->type; } $identifiers = (array) $identifiers; if (empty($identifiers)) { return $criteria; } $criteria[Persister::IDENTIFIER_KEY] = (1 === count($identifiers)) ? reset($identifiers) : $identifiers; return $criteria; }
[ "public", "function", "getRetrieveCritiera", "(", "EntityMetadata", "$", "metadata", ",", "$", "identifiers", "=", "null", ")", "{", "$", "criteria", "=", "[", "]", ";", "if", "(", "true", "===", "$", "metadata", "->", "isChildEntity", "(", ")", ")", "{", "$", "criteria", "[", "Persister", "::", "POLYMORPHIC_KEY", "]", "=", "$", "metadata", "->", "type", ";", "}", "elseif", "(", "true", "===", "$", "metadata", "->", "isPolymorphic", "(", ")", "&&", "false", "===", "$", "metadata", "->", "isAbstract", "(", ")", ")", "{", "$", "criteria", "[", "Persister", "::", "POLYMORPHIC_KEY", "]", "=", "$", "metadata", "->", "type", ";", "}", "$", "identifiers", "=", "(", "array", ")", "$", "identifiers", ";", "if", "(", "empty", "(", "$", "identifiers", ")", ")", "{", "return", "$", "criteria", ";", "}", "$", "criteria", "[", "Persister", "::", "IDENTIFIER_KEY", "]", "=", "(", "1", "===", "count", "(", "$", "identifiers", ")", ")", "?", "reset", "(", "$", "identifiers", ")", ":", "$", "identifiers", ";", "return", "$", "criteria", ";", "}" ]
Gets standard database retrieval criteria for an entity and the provided identifiers. @param EntityMetadata $metadata The entity to retrieve database records for. @param string|array|null $identifiers The IDs to query. @return array
[ "Gets", "standard", "database", "retrieval", "criteria", "for", "an", "entity", "and", "the", "provided", "identifiers", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L191-L206
235,870
as3io/modlr-persister-mongodb
src/Query.php
Query.appendFields
private function appendFields(QueryBuilder $builder, array $fields) { list($fields, $include) = $this->prepareFields($fields); if (!empty($fields)) { $method = (true === $include) ? 'select' : 'exclude'; $builder->$method(array_keys($fields)); } return $this; }
php
private function appendFields(QueryBuilder $builder, array $fields) { list($fields, $include) = $this->prepareFields($fields); if (!empty($fields)) { $method = (true === $include) ? 'select' : 'exclude'; $builder->$method(array_keys($fields)); } return $this; }
[ "private", "function", "appendFields", "(", "QueryBuilder", "$", "builder", ",", "array", "$", "fields", ")", "{", "list", "(", "$", "fields", ",", "$", "include", ")", "=", "$", "this", "->", "prepareFields", "(", "$", "fields", ")", ";", "if", "(", "!", "empty", "(", "$", "fields", ")", ")", "{", "$", "method", "=", "(", "true", "===", "$", "include", ")", "?", "'select'", ":", "'exclude'", ";", "$", "builder", "->", "$", "method", "(", "array_keys", "(", "$", "fields", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Appends projection fields to a Query Builder. @param QueryBuilder $builder @param array $fields @return self
[ "Appends", "projection", "fields", "to", "a", "Query", "Builder", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L215-L223
235,871
as3io/modlr-persister-mongodb
src/Query.php
Query.appendLimitAndOffset
private function appendLimitAndOffset(QueryBuilder $builder, $limit, $offset) { $limit = (int) $limit; $offset = (int) $offset; if ($limit > 0) { $builder->limit($limit); } if ($offset > 0) { $builder->skip($offset); } return $this; }
php
private function appendLimitAndOffset(QueryBuilder $builder, $limit, $offset) { $limit = (int) $limit; $offset = (int) $offset; if ($limit > 0) { $builder->limit($limit); } if ($offset > 0) { $builder->skip($offset); } return $this; }
[ "private", "function", "appendLimitAndOffset", "(", "QueryBuilder", "$", "builder", ",", "$", "limit", ",", "$", "offset", ")", "{", "$", "limit", "=", "(", "int", ")", "$", "limit", ";", "$", "offset", "=", "(", "int", ")", "$", "offset", ";", "if", "(", "$", "limit", ">", "0", ")", "{", "$", "builder", "->", "limit", "(", "$", "limit", ")", ";", "}", "if", "(", "$", "offset", ">", "0", ")", "{", "$", "builder", "->", "skip", "(", "$", "offset", ")", ";", "}", "return", "$", "this", ";", "}" ]
Appends offset and limit criteria to a Query Builder @param QueryBuilder $builder @param int $limit @param int $offset @return self
[ "Appends", "offset", "and", "limit", "criteria", "to", "a", "Query", "Builder" ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L233-L246
235,872
as3io/modlr-persister-mongodb
src/Query.php
Query.appendSearch
private function appendSearch(QueryBuilder $builder, array $criteria) { if (false === $this->isSearchQuery($criteria)) { return $this; } $builder->selectMeta('searchScore', 'textScore'); $builder->sortMeta('searchScore', 'textScore'); return $this; }
php
private function appendSearch(QueryBuilder $builder, array $criteria) { if (false === $this->isSearchQuery($criteria)) { return $this; } $builder->selectMeta('searchScore', 'textScore'); $builder->sortMeta('searchScore', 'textScore'); return $this; }
[ "private", "function", "appendSearch", "(", "QueryBuilder", "$", "builder", ",", "array", "$", "criteria", ")", "{", "if", "(", "false", "===", "$", "this", "->", "isSearchQuery", "(", "$", "criteria", ")", ")", "{", "return", "$", "this", ";", "}", "$", "builder", "->", "selectMeta", "(", "'searchScore'", ",", "'textScore'", ")", ";", "$", "builder", "->", "sortMeta", "(", "'searchScore'", ",", "'textScore'", ")", ";", "return", "$", "this", ";", "}" ]
Appends text search score and sorting to a Query Builder. @param QueryBuilder $builder @param array $criteria @return self
[ "Appends", "text", "search", "score", "and", "sorting", "to", "a", "Query", "Builder", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L255-L263
235,873
as3io/modlr-persister-mongodb
src/Query.php
Query.appendSort
private function appendSort(QueryBuilder $builder, array $sort) { if (!empty($sort)) { $builder->sort($sort); } return $this; }
php
private function appendSort(QueryBuilder $builder, array $sort) { if (!empty($sort)) { $builder->sort($sort); } return $this; }
[ "private", "function", "appendSort", "(", "QueryBuilder", "$", "builder", ",", "array", "$", "sort", ")", "{", "if", "(", "!", "empty", "(", "$", "sort", ")", ")", "{", "$", "builder", "->", "sort", "(", "$", "sort", ")", ";", "}", "return", "$", "this", ";", "}" ]
Appends sorting criteria to a Query Builder. @param QueryBuilder $builder @param array $sort @return self
[ "Appends", "sorting", "criteria", "to", "a", "Query", "Builder", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L272-L278
235,874
as3io/modlr-persister-mongodb
src/Query.php
Query.isSearchQuery
private function isSearchQuery(array $criteria) { if (isset($criteria['$text'])) { return true; } foreach ($criteria as $key => $value) { if (is_array($value) && true === $this->isSearchQuery($value)) { return true; } } return false; }
php
private function isSearchQuery(array $criteria) { if (isset($criteria['$text'])) { return true; } foreach ($criteria as $key => $value) { if (is_array($value) && true === $this->isSearchQuery($value)) { return true; } } return false; }
[ "private", "function", "isSearchQuery", "(", "array", "$", "criteria", ")", "{", "if", "(", "isset", "(", "$", "criteria", "[", "'$text'", "]", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "criteria", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "true", "===", "$", "this", "->", "isSearchQuery", "(", "$", "value", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Determines if the provided query criteria contains text search. @param array $criteria @return bool
[ "Determines", "if", "the", "provided", "query", "criteria", "contains", "text", "search", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L286-L297
235,875
as3io/modlr-persister-mongodb
src/Query.php
Query.prepareFields
private function prepareFields(array $fields) { $include = null; foreach ($fields as $key => $type) { $type = (bool) $type; if (null === $include) { $include = $type; } if ($type !== $include) { PersisterException::badRequest('Field projection mismatch. You cannot both exclude and include fields.'); } $fields[$key] = $type; } return [$fields, $include]; }
php
private function prepareFields(array $fields) { $include = null; foreach ($fields as $key => $type) { $type = (bool) $type; if (null === $include) { $include = $type; } if ($type !== $include) { PersisterException::badRequest('Field projection mismatch. You cannot both exclude and include fields.'); } $fields[$key] = $type; } return [$fields, $include]; }
[ "private", "function", "prepareFields", "(", "array", "$", "fields", ")", "{", "$", "include", "=", "null", ";", "foreach", "(", "$", "fields", "as", "$", "key", "=>", "$", "type", ")", "{", "$", "type", "=", "(", "bool", ")", "$", "type", ";", "if", "(", "null", "===", "$", "include", ")", "{", "$", "include", "=", "$", "type", ";", "}", "if", "(", "$", "type", "!==", "$", "include", ")", "{", "PersisterException", "::", "badRequest", "(", "'Field projection mismatch. You cannot both exclude and include fields.'", ")", ";", "}", "$", "fields", "[", "$", "key", "]", "=", "$", "type", ";", "}", "return", "[", "$", "fields", ",", "$", "include", "]", ";", "}" ]
Prepares projection fields for a query and returns as a tuple. @param array $fields @return array @throws PersisterException
[ "Prepares", "projection", "fields", "for", "a", "query", "and", "returns", "as", "a", "tuple", "." ]
7f7474d1996167d3b03a72ead42c0662166506a3
https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Query.php#L306-L320
235,876
SergioMadness/framework
framework/components/datapaginator/abstraction/Paginator.php
Paginator.getPage
public function getPage() { if (empty($this->page) && ($paramName = $this->getParamName()) != '') { $this->setPage(\pwf\basic\Application::$instance->getRequest()->get($paramName)); } return $this->page; }
php
public function getPage() { if (empty($this->page) && ($paramName = $this->getParamName()) != '') { $this->setPage(\pwf\basic\Application::$instance->getRequest()->get($paramName)); } return $this->page; }
[ "public", "function", "getPage", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "page", ")", "&&", "(", "$", "paramName", "=", "$", "this", "->", "getParamName", "(", ")", ")", "!=", "''", ")", "{", "$", "this", "->", "setPage", "(", "\\", "pwf", "\\", "basic", "\\", "Application", "::", "$", "instance", "->", "getRequest", "(", ")", "->", "get", "(", "$", "paramName", ")", ")", ";", "}", "return", "$", "this", "->", "page", ";", "}" ]
Get current page number @return int
[ "Get", "current", "page", "number" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/datapaginator/abstraction/Paginator.php#L45-L52
235,877
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.update
public function update($input, $fields, &$errCount = 0) { $operation = $this->getUpdateOperation($input, $fields); $operation->validate($errCount); return $operation->runIfValid(); }
php
public function update($input, $fields, &$errCount = 0) { $operation = $this->getUpdateOperation($input, $fields); $operation->validate($errCount); return $operation->runIfValid(); }
[ "public", "function", "update", "(", "$", "input", ",", "$", "fields", ",", "&", "$", "errCount", "=", "0", ")", "{", "$", "operation", "=", "$", "this", "->", "getUpdateOperation", "(", "$", "input", ",", "$", "fields", ")", ";", "$", "operation", "->", "validate", "(", "$", "errCount", ")", ";", "return", "$", "operation", "->", "runIfValid", "(", ")", ";", "}" ]
Update this permanent object from input data array @param array $input The input data we will check and extract, used by children @param string[] $fields The array of fields to check @param int &$errCount Output parameter for the number of occurred errors validating fields. @return int 1 in case of success, else 0. @see runForUpdate() This method require to be overridden but it still be called too by the child classes. Here $input is not used, it is reserved for child classes. $data must contain a filled array of new data. This method update the EDIT event log. Before saving, runForUpdate() is called to let child classes to run custom instructions. Parameter $fields is really useful to allow partial modification only (against form hack).
[ "Update", "this", "permanent", "object", "from", "input", "data", "array" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L281-L285
235,878
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.getUpdateOperation
public function getUpdateOperation($input, $fields) { $operation = new UpdateTransactionOperation(static::getClass(), $input, $fields, $this); $operation->setSQLAdapter(static::getSQLAdapter()); return $operation; }
php
public function getUpdateOperation($input, $fields) { $operation = new UpdateTransactionOperation(static::getClass(), $input, $fields, $this); $operation->setSQLAdapter(static::getSQLAdapter()); return $operation; }
[ "public", "function", "getUpdateOperation", "(", "$", "input", ",", "$", "fields", ")", "{", "$", "operation", "=", "new", "UpdateTransactionOperation", "(", "static", "::", "getClass", "(", ")", ",", "$", "input", ",", "$", "fields", ",", "$", "this", ")", ";", "$", "operation", "->", "setSQLAdapter", "(", "static", "::", "getSQLAdapter", "(", ")", ")", ";", "return", "$", "operation", ";", "}" ]
Get the update operation @param array $input The input data we will check and extract, used by children @param string[] $fields The array of fields to check @return UpdateTransactionOperation
[ "Get", "the", "update", "operation" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L294-L298
235,879
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.onValidUpdate
public static function onValidUpdate(&$input, $newErrors) { // Don't care about some errors, other fields should be updated. $found = 0; foreach( $input as $fieldname => $fieldvalue ) { if( in_array($fieldname, static::$fields) ) { $found++; } } if( $found ) { static::fillLogEvent($input, 'edit'); static::fillLogEvent($input, 'update'); } return $found ? true : false; }
php
public static function onValidUpdate(&$input, $newErrors) { // Don't care about some errors, other fields should be updated. $found = 0; foreach( $input as $fieldname => $fieldvalue ) { if( in_array($fieldname, static::$fields) ) { $found++; } } if( $found ) { static::fillLogEvent($input, 'edit'); static::fillLogEvent($input, 'update'); } return $found ? true : false; }
[ "public", "static", "function", "onValidUpdate", "(", "&", "$", "input", ",", "$", "newErrors", ")", "{", "// Don't care about some errors, other fields should be updated.", "$", "found", "=", "0", ";", "foreach", "(", "$", "input", "as", "$", "fieldname", "=>", "$", "fieldvalue", ")", "{", "if", "(", "in_array", "(", "$", "fieldname", ",", "static", "::", "$", "fields", ")", ")", "{", "$", "found", "++", ";", "}", "}", "if", "(", "$", "found", ")", "{", "static", "::", "fillLogEvent", "(", "$", "input", ",", "'edit'", ")", ";", "static", "::", "fillLogEvent", "(", "$", "input", ",", "'update'", ")", ";", "}", "return", "$", "found", "?", "true", ":", "false", ";", "}" ]
Callback when validating update @param array $input @param int $newErrors @return boolean
[ "Callback", "when", "validating", "update" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L307-L320
235,880
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.extractUpdateQuery
public static function extractUpdateQuery(&$input, PermanentObject $object) { static::onEdit($input, $object); foreach( $input as $fieldName => $fieldValue ) { // If saving object, value is the same, validator should check if value is new if( !in_array($fieldName, static::$fields) ) { unset($input[$fieldName]); } } $options = array( 'what' => $input, 'table' => static::$table, 'where' => static::getIDField() . '=' . $object->id(), 'number' => 1, ); return $options; }
php
public static function extractUpdateQuery(&$input, PermanentObject $object) { static::onEdit($input, $object); foreach( $input as $fieldName => $fieldValue ) { // If saving object, value is the same, validator should check if value is new if( !in_array($fieldName, static::$fields) ) { unset($input[$fieldName]); } } $options = array( 'what' => $input, 'table' => static::$table, 'where' => static::getIDField() . '=' . $object->id(), 'number' => 1, ); return $options; }
[ "public", "static", "function", "extractUpdateQuery", "(", "&", "$", "input", ",", "PermanentObject", "$", "object", ")", "{", "static", "::", "onEdit", "(", "$", "input", ",", "$", "object", ")", ";", "foreach", "(", "$", "input", "as", "$", "fieldName", "=>", "$", "fieldValue", ")", "{", "// If saving object, value is the same, validator should check if value is new", "if", "(", "!", "in_array", "(", "$", "fieldName", ",", "static", "::", "$", "fields", ")", ")", "{", "unset", "(", "$", "input", "[", "$", "fieldName", "]", ")", ";", "}", "}", "$", "options", "=", "array", "(", "'what'", "=>", "$", "input", ",", "'table'", "=>", "static", "::", "$", "table", ",", "'where'", "=>", "static", "::", "getIDField", "(", ")", ".", "'='", ".", "$", "object", "->", "id", "(", ")", ",", "'number'", "=>", "1", ",", ")", ";", "return", "$", "options", ";", "}" ]
Extract an update query from this object @param array $input @param PermanentObject $object @return array @uses UpdateTransactionOperation
[ "Extract", "an", "update", "query", "from", "this", "object" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L331-L349
235,881
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.save
public function save() { if( empty($this->modFields) || $this->isDeleted() ) { return false; } $data = array_filterbykeys($this->data, $this->modFields); if( !$data ) { throw new Exception('No updated data found but there is modified fields, unable to update'); } $operation = $this->getUpdateOperation($data, $this->modFields); // Do not validate, new data are invalid due to the fact the new data are already in object // $operation->validate(); $r = $operation->run(); $this->modFields = array(); if( !$this->onSavedInProgress ) { // Protect script against saving loops $this->onSavedInProgress = true; static::onSaved($data, $this); $this->onSavedInProgress = false; } return $r; }
php
public function save() { if( empty($this->modFields) || $this->isDeleted() ) { return false; } $data = array_filterbykeys($this->data, $this->modFields); if( !$data ) { throw new Exception('No updated data found but there is modified fields, unable to update'); } $operation = $this->getUpdateOperation($data, $this->modFields); // Do not validate, new data are invalid due to the fact the new data are already in object // $operation->validate(); $r = $operation->run(); $this->modFields = array(); if( !$this->onSavedInProgress ) { // Protect script against saving loops $this->onSavedInProgress = true; static::onSaved($data, $this); $this->onSavedInProgress = false; } return $r; }
[ "public", "function", "save", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "modFields", ")", "||", "$", "this", "->", "isDeleted", "(", ")", ")", "{", "return", "false", ";", "}", "$", "data", "=", "array_filterbykeys", "(", "$", "this", "->", "data", ",", "$", "this", "->", "modFields", ")", ";", "if", "(", "!", "$", "data", ")", "{", "throw", "new", "Exception", "(", "'No updated data found but there is modified fields, unable to update'", ")", ";", "}", "$", "operation", "=", "$", "this", "->", "getUpdateOperation", "(", "$", "data", ",", "$", "this", "->", "modFields", ")", ";", "// Do not validate, new data are invalid due to the fact the new data are already in object", "// \t\t$operation->validate();", "$", "r", "=", "$", "operation", "->", "run", "(", ")", ";", "$", "this", "->", "modFields", "=", "array", "(", ")", ";", "if", "(", "!", "$", "this", "->", "onSavedInProgress", ")", "{", "// Protect script against saving loops", "$", "this", "->", "onSavedInProgress", "=", "true", ";", "static", "::", "onSaved", "(", "$", "data", ",", "$", "this", ")", ";", "$", "this", "->", "onSavedInProgress", "=", "false", ";", "}", "return", "$", "r", ";", "}" ]
Save this permanent object @return bool|int True in case of success @throws Exception If some fields was modified, it saves these fields using the SQL Adapter.
[ "Save", "this", "permanent", "object" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L428-L449
235,882
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.remove
public function remove() { if( $this->isDeleted() ) { return 0; } $operation = $this->getDeleteOperation(); $errors = 0; $operation->validate($errors); return $operation->runIfValid(); }
php
public function remove() { if( $this->isDeleted() ) { return 0; } $operation = $this->getDeleteOperation(); $errors = 0; $operation->validate($errors); return $operation->runIfValid(); }
[ "public", "function", "remove", "(", ")", "{", "if", "(", "$", "this", "->", "isDeleted", "(", ")", ")", "{", "return", "0", ";", "}", "$", "operation", "=", "$", "this", "->", "getDeleteOperation", "(", ")", ";", "$", "errors", "=", "0", ";", "$", "operation", "->", "validate", "(", "$", "errors", ")", ";", "return", "$", "operation", "->", "runIfValid", "(", ")", ";", "}" ]
What do you think it does ? @return int
[ "What", "do", "you", "think", "it", "does", "?" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L462-L470
235,883
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.reload
public function reload($field = null) { $IDFIELD = static::getIDField(); $options = array('where' => $IDFIELD . '=' . $this->$IDFIELD, 'output' => SQLAdapter::ARR_FIRST); if( $field ) { if( !in_array($field, static::$fields) ) { throw new FieldNotFoundException($field, static::getClass()); } $i = array_search($this->modFields, $field); if( $i !== false ) { unset($this->modFields[$i]); } $options['what'] = $field; } else { $this->modFields = array(); } try { $data = static::get($options); } catch( SQLException $e ) { $data = null; } if( empty($data) ) { $this->markAsDeleted(); return false; } if( !is_null($field) ) { $this->data[$field] = $data[$field]; } else { $this->data = $data; } return true; }
php
public function reload($field = null) { $IDFIELD = static::getIDField(); $options = array('where' => $IDFIELD . '=' . $this->$IDFIELD, 'output' => SQLAdapter::ARR_FIRST); if( $field ) { if( !in_array($field, static::$fields) ) { throw new FieldNotFoundException($field, static::getClass()); } $i = array_search($this->modFields, $field); if( $i !== false ) { unset($this->modFields[$i]); } $options['what'] = $field; } else { $this->modFields = array(); } try { $data = static::get($options); } catch( SQLException $e ) { $data = null; } if( empty($data) ) { $this->markAsDeleted(); return false; } if( !is_null($field) ) { $this->data[$field] = $data[$field]; } else { $this->data = $data; } return true; }
[ "public", "function", "reload", "(", "$", "field", "=", "null", ")", "{", "$", "IDFIELD", "=", "static", "::", "getIDField", "(", ")", ";", "$", "options", "=", "array", "(", "'where'", "=>", "$", "IDFIELD", ".", "'='", ".", "$", "this", "->", "$", "IDFIELD", ",", "'output'", "=>", "SQLAdapter", "::", "ARR_FIRST", ")", ";", "if", "(", "$", "field", ")", "{", "if", "(", "!", "in_array", "(", "$", "field", ",", "static", "::", "$", "fields", ")", ")", "{", "throw", "new", "FieldNotFoundException", "(", "$", "field", ",", "static", "::", "getClass", "(", ")", ")", ";", "}", "$", "i", "=", "array_search", "(", "$", "this", "->", "modFields", ",", "$", "field", ")", ";", "if", "(", "$", "i", "!==", "false", ")", "{", "unset", "(", "$", "this", "->", "modFields", "[", "$", "i", "]", ")", ";", "}", "$", "options", "[", "'what'", "]", "=", "$", "field", ";", "}", "else", "{", "$", "this", "->", "modFields", "=", "array", "(", ")", ";", "}", "try", "{", "$", "data", "=", "static", "::", "get", "(", "$", "options", ")", ";", "}", "catch", "(", "SQLException", "$", "e", ")", "{", "$", "data", "=", "null", ";", "}", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "$", "this", "->", "markAsDeleted", "(", ")", ";", "return", "false", ";", "}", "if", "(", "!", "is_null", "(", "$", "field", ")", ")", "{", "$", "this", "->", "data", "[", "$", "field", "]", "=", "$", "data", "[", "$", "field", "]", ";", "}", "else", "{", "$", "this", "->", "data", "=", "$", "data", ";", "}", "return", "true", ";", "}" ]
Reload fields from database @param string $field The field to reload, default is null (all fields). @return boolean True if done @throws FieldNotFoundException Update the current object's fields from database. If $field is not set, it reloads only one field else all fields. Also it removes the reloaded fields from the modified ones list.
[ "Reload", "fields", "from", "database" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L498-L528
235,884
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.getValue
public function getValue($key = null) { if( empty($key) ) { return $this->data; } if( !array_key_exists($key, $this->data) ) { throw new FieldNotFoundException($key, static::getClass()); } return $this->data[$key]; }
php
public function getValue($key = null) { if( empty($key) ) { return $this->data; } if( !array_key_exists($key, $this->data) ) { throw new FieldNotFoundException($key, static::getClass()); } return $this->data[$key]; }
[ "public", "function", "getValue", "(", "$", "key", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "data", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "data", ")", ")", "{", "throw", "new", "FieldNotFoundException", "(", "$", "key", ",", "static", "::", "getClass", "(", ")", ")", ";", "}", "return", "$", "this", "->", "data", "[", "$", "key", "]", ";", "}" ]
Get one value or all values @param string $key Name of the field to get. @return mixed|array @throws FieldNotFoundException Get the value of field $key or all data values if $key is null.
[ "Get", "one", "value", "or", "all", "values" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L603-L611
235,885
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.setValue
public function setValue($key, $value) { if( !isset($key) ) { // Invalid key throw new Exception("nullKey"); } else if( !in_array($key, static::$fields) ) { // Unknown key throw new FieldNotFoundException($key, static::getClass()); } else if( $key === static::$IDFIELD ) { // ID is not editable throw new Exception("idNotEditable"); } else if( $value !== $this->data[$key] ) { // The value is different $this->addModFields($key); $this->data[$key] = $value; } return $this; }
php
public function setValue($key, $value) { if( !isset($key) ) { // Invalid key throw new Exception("nullKey"); } else if( !in_array($key, static::$fields) ) { // Unknown key throw new FieldNotFoundException($key, static::getClass()); } else if( $key === static::$IDFIELD ) { // ID is not editable throw new Exception("idNotEditable"); } else if( $value !== $this->data[$key] ) { // The value is different $this->addModFields($key); $this->data[$key] = $value; } return $this; }
[ "public", "function", "setValue", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "key", ")", ")", "{", "// Invalid key", "throw", "new", "Exception", "(", "\"nullKey\"", ")", ";", "}", "else", "if", "(", "!", "in_array", "(", "$", "key", ",", "static", "::", "$", "fields", ")", ")", "{", "// Unknown key", "throw", "new", "FieldNotFoundException", "(", "$", "key", ",", "static", "::", "getClass", "(", ")", ")", ";", "}", "else", "if", "(", "$", "key", "===", "static", "::", "$", "IDFIELD", ")", "{", "// ID is not editable", "throw", "new", "Exception", "(", "\"idNotEditable\"", ")", ";", "}", "else", "if", "(", "$", "value", "!==", "$", "this", "->", "data", "[", "$", "key", "]", ")", "{", "// The value is different", "$", "this", "->", "addModFields", "(", "$", "key", ")", ";", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of a field @param string $key Name of the field to set @param mixed $value New value of the field @return $this @throws Exception @throws FieldNotFoundException Set the field $key with the new $value.
[ "Set", "the", "value", "of", "a", "field" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L624-L643
235,886
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.equals
public function equals($o) { return (get_class($this) == get_class($o) && $this->id() == $o->id()); }
php
public function equals($o) { return (get_class($this) == get_class($o) && $this->id() == $o->id()); }
[ "public", "function", "equals", "(", "$", "o", ")", "{", "return", "(", "get_class", "(", "$", "this", ")", "==", "get_class", "(", "$", "o", ")", "&&", "$", "this", "->", "id", "(", ")", "==", "$", "o", "->", "id", "(", ")", ")", ";", "}" ]
Verify equality with another object @param object $o The object to compare. @return boolean True if this object represents the same data, else False. Compare the class and the ID field value of the 2 objects.
[ "Verify", "equality", "with", "another", "object" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L653-L655
235,887
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.getLogEvent
public static function getLogEvent($event, $time = null, $ipAdd = null) { return array( $event . '_time' => isset($time) ? $time : time(), $event . '_date' => isset($time) ? sqlDatetime($time) : sqlDatetime(), $event . '_ip' => isset($ipAdd) ? $ipAdd : (!empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1'), ); }
php
public static function getLogEvent($event, $time = null, $ipAdd = null) { return array( $event . '_time' => isset($time) ? $time : time(), $event . '_date' => isset($time) ? sqlDatetime($time) : sqlDatetime(), $event . '_ip' => isset($ipAdd) ? $ipAdd : (!empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1'), ); }
[ "public", "static", "function", "getLogEvent", "(", "$", "event", ",", "$", "time", "=", "null", ",", "$", "ipAdd", "=", "null", ")", "{", "return", "array", "(", "$", "event", ".", "'_time'", "=>", "isset", "(", "$", "time", ")", "?", "$", "time", ":", "time", "(", ")", ",", "$", "event", ".", "'_date'", "=>", "isset", "(", "$", "time", ")", "?", "sqlDatetime", "(", "$", "time", ")", ":", "sqlDatetime", "(", ")", ",", "$", "event", ".", "'_ip'", "=>", "isset", "(", "$", "ipAdd", ")", "?", "$", "ipAdd", ":", "(", "!", "empty", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", "?", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ":", "'127.0.0.1'", ")", ",", ")", ";", "}" ]
Get the log of an event @param string $event The event to log in this object @param int $time A specified time to use for logging event @param string $ipAdd A specified IP Address to use for logging event @return array @deprecated @see logEvent() Build a new log event for $event for this time and the user IP address.
[ "Get", "the", "log", "of", "an", "event" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L729-L735
235,888
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.isFieldEditable
public static function isFieldEditable($fieldName) { if( $fieldName == static::$IDFIELD ) { return false; } if( !is_null(static::$editableFields) ) { return in_array($fieldName, static::$editableFields); } if( method_exists(static::$validator, 'isFieldEditable') ) { return in_array($fieldName, static::$editableFields); } return in_array($fieldName, static::$fields); }
php
public static function isFieldEditable($fieldName) { if( $fieldName == static::$IDFIELD ) { return false; } if( !is_null(static::$editableFields) ) { return in_array($fieldName, static::$editableFields); } if( method_exists(static::$validator, 'isFieldEditable') ) { return in_array($fieldName, static::$editableFields); } return in_array($fieldName, static::$fields); }
[ "public", "static", "function", "isFieldEditable", "(", "$", "fieldName", ")", "{", "if", "(", "$", "fieldName", "==", "static", "::", "$", "IDFIELD", ")", "{", "return", "false", ";", "}", "if", "(", "!", "is_null", "(", "static", "::", "$", "editableFields", ")", ")", "{", "return", "in_array", "(", "$", "fieldName", ",", "static", "::", "$", "editableFields", ")", ";", "}", "if", "(", "method_exists", "(", "static", "::", "$", "validator", ",", "'isFieldEditable'", ")", ")", "{", "return", "in_array", "(", "$", "fieldName", ",", "static", "::", "$", "editableFields", ")", ";", "}", "return", "in_array", "(", "$", "fieldName", ",", "static", "::", "$", "fields", ")", ";", "}" ]
Test if field is editable @param string $fieldName @return boolean
[ "Test", "if", "field", "is", "editable" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L756-L767
235,889
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.get
public static function get($options = null) { if( $options === null ) { /** @noinspection PhpIncompatibleReturnTypeInspection */ return static::select(); } if( $options instanceof SQLSelectRequest ) { $options->setSQLAdapter(static::getSQLAdapter()); $options->setIDField(static::$IDFIELD); $options->from(static::$table); return $options->run(); } if( is_string($options) ) { $args = func_get_args(); $options = array();// Pointing argument foreach( array('where', 'orderby') as $i => $key ) { if( !isset($args[$i]) ) { break; } $options[$key] = $args[$i]; } } $options['table'] = static::$table; // May be incompatible with old revisions (< R398) if( !isset($options['output']) ) { $options['output'] = SQLAdapter::ARR_OBJECTS; } //This method intercepts outputs of array of objects. $onlyOne = $objects = 0; if( in_array($options['output'], array(SQLAdapter::ARR_OBJECTS, SQLAdapter::OBJECT)) ) { if( $options['output'] == SQLAdapter::OBJECT ) { $options['number'] = 1; $onlyOne = 1; } $options['output'] = SQLAdapter::ARR_ASSOC; $objects = 1; } $sqlAdapter = static::getSQLAdapter(); $r = $sqlAdapter->select($options); if( empty($r) && in_array($options['output'], array(SQLAdapter::ARR_ASSOC, SQLAdapter::ARR_OBJECTS, SQLAdapter::ARR_FIRST)) ) { return $onlyOne && $objects ? null : array(); } if( !empty($r) && $objects ) { if( $onlyOne ) { $r = static::load($r[0]); } else { foreach( $r as &$rdata ) { $rdata = static::load($rdata); } } } return $r; }
php
public static function get($options = null) { if( $options === null ) { /** @noinspection PhpIncompatibleReturnTypeInspection */ return static::select(); } if( $options instanceof SQLSelectRequest ) { $options->setSQLAdapter(static::getSQLAdapter()); $options->setIDField(static::$IDFIELD); $options->from(static::$table); return $options->run(); } if( is_string($options) ) { $args = func_get_args(); $options = array();// Pointing argument foreach( array('where', 'orderby') as $i => $key ) { if( !isset($args[$i]) ) { break; } $options[$key] = $args[$i]; } } $options['table'] = static::$table; // May be incompatible with old revisions (< R398) if( !isset($options['output']) ) { $options['output'] = SQLAdapter::ARR_OBJECTS; } //This method intercepts outputs of array of objects. $onlyOne = $objects = 0; if( in_array($options['output'], array(SQLAdapter::ARR_OBJECTS, SQLAdapter::OBJECT)) ) { if( $options['output'] == SQLAdapter::OBJECT ) { $options['number'] = 1; $onlyOne = 1; } $options['output'] = SQLAdapter::ARR_ASSOC; $objects = 1; } $sqlAdapter = static::getSQLAdapter(); $r = $sqlAdapter->select($options); if( empty($r) && in_array($options['output'], array(SQLAdapter::ARR_ASSOC, SQLAdapter::ARR_OBJECTS, SQLAdapter::ARR_FIRST)) ) { return $onlyOne && $objects ? null : array(); } if( !empty($r) && $objects ) { if( $onlyOne ) { $r = static::load($r[0]); } else { foreach( $r as &$rdata ) { $rdata = static::load($rdata); } } } return $r; }
[ "public", "static", "function", "get", "(", "$", "options", "=", "null", ")", "{", "if", "(", "$", "options", "===", "null", ")", "{", "/** @noinspection PhpIncompatibleReturnTypeInspection */", "return", "static", "::", "select", "(", ")", ";", "}", "if", "(", "$", "options", "instanceof", "SQLSelectRequest", ")", "{", "$", "options", "->", "setSQLAdapter", "(", "static", "::", "getSQLAdapter", "(", ")", ")", ";", "$", "options", "->", "setIDField", "(", "static", "::", "$", "IDFIELD", ")", ";", "$", "options", "->", "from", "(", "static", "::", "$", "table", ")", ";", "return", "$", "options", "->", "run", "(", ")", ";", "}", "if", "(", "is_string", "(", "$", "options", ")", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "options", "=", "array", "(", ")", ";", "// Pointing argument", "foreach", "(", "array", "(", "'where'", ",", "'orderby'", ")", "as", "$", "i", "=>", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "args", "[", "$", "i", "]", ")", ")", "{", "break", ";", "}", "$", "options", "[", "$", "key", "]", "=", "$", "args", "[", "$", "i", "]", ";", "}", "}", "$", "options", "[", "'table'", "]", "=", "static", "::", "$", "table", ";", "// May be incompatible with old revisions (< R398)", "if", "(", "!", "isset", "(", "$", "options", "[", "'output'", "]", ")", ")", "{", "$", "options", "[", "'output'", "]", "=", "SQLAdapter", "::", "ARR_OBJECTS", ";", "}", "//This method intercepts outputs of array of objects.", "$", "onlyOne", "=", "$", "objects", "=", "0", ";", "if", "(", "in_array", "(", "$", "options", "[", "'output'", "]", ",", "array", "(", "SQLAdapter", "::", "ARR_OBJECTS", ",", "SQLAdapter", "::", "OBJECT", ")", ")", ")", "{", "if", "(", "$", "options", "[", "'output'", "]", "==", "SQLAdapter", "::", "OBJECT", ")", "{", "$", "options", "[", "'number'", "]", "=", "1", ";", "$", "onlyOne", "=", "1", ";", "}", "$", "options", "[", "'output'", "]", "=", "SQLAdapter", "::", "ARR_ASSOC", ";", "$", "objects", "=", "1", ";", "}", "$", "sqlAdapter", "=", "static", "::", "getSQLAdapter", "(", ")", ";", "$", "r", "=", "$", "sqlAdapter", "->", "select", "(", "$", "options", ")", ";", "if", "(", "empty", "(", "$", "r", ")", "&&", "in_array", "(", "$", "options", "[", "'output'", "]", ",", "array", "(", "SQLAdapter", "::", "ARR_ASSOC", ",", "SQLAdapter", "::", "ARR_OBJECTS", ",", "SQLAdapter", "::", "ARR_FIRST", ")", ")", ")", "{", "return", "$", "onlyOne", "&&", "$", "objects", "?", "null", ":", "array", "(", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "r", ")", "&&", "$", "objects", ")", "{", "if", "(", "$", "onlyOne", ")", "{", "$", "r", "=", "static", "::", "load", "(", "$", "r", "[", "0", "]", ")", ";", "}", "else", "{", "foreach", "(", "$", "r", "as", "&", "$", "rdata", ")", "{", "$", "rdata", "=", "static", "::", "load", "(", "$", "rdata", ")", ";", "}", "}", "}", "return", "$", "r", ";", "}" ]
Get some permanent objects @param array $options The options used to get the permanents object @return SQLSelectRequest|static|static[]|array An array of array containing object's data @see SQLAdapter Get an objects' list using this class' table. Take care that output=SQLAdapter::ARR_OBJECTS and number=1 is different from output=SQLAdapter::OBJECT
[ "Get", "some", "permanent", "objects" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L790-L841
235,890
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.load
public static function load($in, $nullable = true, $usingCache = true) { if( empty($in) ) { if( $nullable ) { return null; } static::throwNotFound('invalidParameter_load'); } // Try to load an object from this class if( is_object($in) && $in instanceof static ) { return $in; } $IDFIELD = static::$IDFIELD; // If $in is an array, we trust him, as data of the object. if( is_array($in) ) { $id = $in[$IDFIELD]; $data = $in; } else { $id = $in; } if( !is_ID($id) ) { static::throwException('invalidID'); } // Loading cached if( $usingCache && isset(static::$instances[static::getClass()][$id]) ) { return static::$instances[static::getClass()][$id]; } // If we don't get the data, we request them. if( empty($data) ) { // Getting data $obj = static::get(array( 'where' => $IDFIELD . '=' . $id, 'output' => SQLAdapter::OBJECT, )); // Ho no, we don't have the data, we can't load the object ! if( empty($obj) ) { if( $nullable ) { return null; } static::throwNotFound(); } } else { $obj = new static($data); } // Caching object return $usingCache ? $obj->checkCache() : $obj; }
php
public static function load($in, $nullable = true, $usingCache = true) { if( empty($in) ) { if( $nullable ) { return null; } static::throwNotFound('invalidParameter_load'); } // Try to load an object from this class if( is_object($in) && $in instanceof static ) { return $in; } $IDFIELD = static::$IDFIELD; // If $in is an array, we trust him, as data of the object. if( is_array($in) ) { $id = $in[$IDFIELD]; $data = $in; } else { $id = $in; } if( !is_ID($id) ) { static::throwException('invalidID'); } // Loading cached if( $usingCache && isset(static::$instances[static::getClass()][$id]) ) { return static::$instances[static::getClass()][$id]; } // If we don't get the data, we request them. if( empty($data) ) { // Getting data $obj = static::get(array( 'where' => $IDFIELD . '=' . $id, 'output' => SQLAdapter::OBJECT, )); // Ho no, we don't have the data, we can't load the object ! if( empty($obj) ) { if( $nullable ) { return null; } static::throwNotFound(); } } else { $obj = new static($data); } // Caching object return $usingCache ? $obj->checkCache() : $obj; }
[ "public", "static", "function", "load", "(", "$", "in", ",", "$", "nullable", "=", "true", ",", "$", "usingCache", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "in", ")", ")", "{", "if", "(", "$", "nullable", ")", "{", "return", "null", ";", "}", "static", "::", "throwNotFound", "(", "'invalidParameter_load'", ")", ";", "}", "// Try to load an object from this class", "if", "(", "is_object", "(", "$", "in", ")", "&&", "$", "in", "instanceof", "static", ")", "{", "return", "$", "in", ";", "}", "$", "IDFIELD", "=", "static", "::", "$", "IDFIELD", ";", "// If $in is an array, we trust him, as data of the object.", "if", "(", "is_array", "(", "$", "in", ")", ")", "{", "$", "id", "=", "$", "in", "[", "$", "IDFIELD", "]", ";", "$", "data", "=", "$", "in", ";", "}", "else", "{", "$", "id", "=", "$", "in", ";", "}", "if", "(", "!", "is_ID", "(", "$", "id", ")", ")", "{", "static", "::", "throwException", "(", "'invalidID'", ")", ";", "}", "// Loading cached", "if", "(", "$", "usingCache", "&&", "isset", "(", "static", "::", "$", "instances", "[", "static", "::", "getClass", "(", ")", "]", "[", "$", "id", "]", ")", ")", "{", "return", "static", "::", "$", "instances", "[", "static", "::", "getClass", "(", ")", "]", "[", "$", "id", "]", ";", "}", "// If we don't get the data, we request them.", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "// Getting data", "$", "obj", "=", "static", "::", "get", "(", "array", "(", "'where'", "=>", "$", "IDFIELD", ".", "'='", ".", "$", "id", ",", "'output'", "=>", "SQLAdapter", "::", "OBJECT", ",", ")", ")", ";", "// Ho no, we don't have the data, we can't load the object !", "if", "(", "empty", "(", "$", "obj", ")", ")", "{", "if", "(", "$", "nullable", ")", "{", "return", "null", ";", "}", "static", "::", "throwNotFound", "(", ")", ";", "}", "}", "else", "{", "$", "obj", "=", "new", "static", "(", "$", "data", ")", ";", "}", "// Caching object", "return", "$", "usingCache", "?", "$", "obj", "->", "checkCache", "(", ")", ":", "$", "obj", ";", "}" ]
Load a permanent object @param mixed|mixed[] $in The object ID to load or a valid array of the object's data @param boolean $nullable True to silent errors row and return null @param boolean $usingCache True to cache load and set cache, false to not cache @return static The object loaded from database @see static::get() Loads the object with the ID $id or the array data. The return value is always a static object (no null, no array, no other object).
[ "Load", "a", "permanent", "object" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L855-L900
235,891
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.checkCache
protected function checkCache() { if( isset(static::$instances[static::getClass()][$this->id()]) ) { return static::$instances[static::getClass()][$this->id()]; } static::$instances[static::getClass()][$this->id()] = $this; return $this; }
php
protected function checkCache() { if( isset(static::$instances[static::getClass()][$this->id()]) ) { return static::$instances[static::getClass()][$this->id()]; } static::$instances[static::getClass()][$this->id()] = $this; return $this; }
[ "protected", "function", "checkCache", "(", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "instances", "[", "static", "::", "getClass", "(", ")", "]", "[", "$", "this", "->", "id", "(", ")", "]", ")", ")", "{", "return", "static", "::", "$", "instances", "[", "static", "::", "getClass", "(", ")", "]", "[", "$", "this", "->", "id", "(", ")", "]", ";", "}", "static", "::", "$", "instances", "[", "static", "::", "getClass", "(", ")", "]", "[", "$", "this", "->", "id", "(", ")", "]", "=", "$", "this", ";", "return", "$", "this", ";", "}" ]
Check if this object is cached and cache it @return \Orpheus\Publisher\PermanentObject\PermanentObject
[ "Check", "if", "this", "object", "is", "cached", "and", "cache", "it" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L920-L926
235,892
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.clearDeletedInstances
public static function clearDeletedInstances() { if( !isset(static::$instances[static::getClass()]) ) { return; } $instances = &static::$instances[static::getClass()]; foreach( $instances as $id => $obj ) { /* @var static $obj */ if( $obj->isDeleted() ) { unset($instances[$id]); } } }
php
public static function clearDeletedInstances() { if( !isset(static::$instances[static::getClass()]) ) { return; } $instances = &static::$instances[static::getClass()]; foreach( $instances as $id => $obj ) { /* @var static $obj */ if( $obj->isDeleted() ) { unset($instances[$id]); } } }
[ "public", "static", "function", "clearDeletedInstances", "(", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "instances", "[", "static", "::", "getClass", "(", ")", "]", ")", ")", "{", "return", ";", "}", "$", "instances", "=", "&", "static", "::", "$", "instances", "[", "static", "::", "getClass", "(", ")", "]", ";", "foreach", "(", "$", "instances", "as", "$", "id", "=>", "$", "obj", ")", "{", "/* @var static $obj */", "if", "(", "$", "obj", "->", "isDeleted", "(", ")", ")", "{", "unset", "(", "$", "instances", "[", "$", "id", "]", ")", ";", "}", "}", "}" ]
Remove deleted instances from cache
[ "Remove", "deleted", "instances", "from", "cache" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L940-L951
235,893
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.escapeIdentifier
public static function escapeIdentifier($identifier = null) { $sqlAdapter = static::getSQLAdapter(); return $sqlAdapter->escapeIdentifier($identifier ? $identifier : static::$table); }
php
public static function escapeIdentifier($identifier = null) { $sqlAdapter = static::getSQLAdapter(); return $sqlAdapter->escapeIdentifier($identifier ? $identifier : static::$table); }
[ "public", "static", "function", "escapeIdentifier", "(", "$", "identifier", "=", "null", ")", "{", "$", "sqlAdapter", "=", "static", "::", "getSQLAdapter", "(", ")", ";", "return", "$", "sqlAdapter", "->", "escapeIdentifier", "(", "$", "identifier", "?", "$", "identifier", ":", "static", "::", "$", "table", ")", ";", "}" ]
Escape identifier through instance @param string $identifier The identifier to escape. Default is table name. @return string The escaped identifier @see SQLAdapter::escapeIdentifier() @see static::ei()
[ "Escape", "identifier", "through", "instance" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L978-L981
235,894
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.getCreateOperation
public static function getCreateOperation($input, $fields) { $operation = new CreateTransactionOperation(static::getClass(), $input, $fields); $operation->setSQLAdapter(static::getSQLAdapter()); return $operation; }
php
public static function getCreateOperation($input, $fields) { $operation = new CreateTransactionOperation(static::getClass(), $input, $fields); $operation->setSQLAdapter(static::getSQLAdapter()); return $operation; }
[ "public", "static", "function", "getCreateOperation", "(", "$", "input", ",", "$", "fields", ")", "{", "$", "operation", "=", "new", "CreateTransactionOperation", "(", "static", "::", "getClass", "(", ")", ",", "$", "input", ",", "$", "fields", ")", ";", "$", "operation", "->", "setSQLAdapter", "(", "static", "::", "getSQLAdapter", "(", ")", ")", ";", "return", "$", "operation", ";", "}" ]
Get the create operation @param array $input The input data we will check and extract, used by children @param string[] $fields The array of fields to check @return CreateTransactionOperation
[ "Get", "the", "create", "operation" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L1082-L1086
235,895
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.onValidCreate
public static function onValidCreate(&$input, $newErrors) { if( $newErrors ) { static::throwException('errorCreateChecking'); } static::fillLogEvent($input, 'create'); static::fillLogEvent($input, 'edit'); // $input = static::getLogEvent('create') + static::getLogEvent('edit') + $input; return true; }
php
public static function onValidCreate(&$input, $newErrors) { if( $newErrors ) { static::throwException('errorCreateChecking'); } static::fillLogEvent($input, 'create'); static::fillLogEvent($input, 'edit'); // $input = static::getLogEvent('create') + static::getLogEvent('edit') + $input; return true; }
[ "public", "static", "function", "onValidCreate", "(", "&", "$", "input", ",", "$", "newErrors", ")", "{", "if", "(", "$", "newErrors", ")", "{", "static", "::", "throwException", "(", "'errorCreateChecking'", ")", ";", "}", "static", "::", "fillLogEvent", "(", "$", "input", ",", "'create'", ")", ";", "static", "::", "fillLogEvent", "(", "$", "input", ",", "'edit'", ")", ";", "// \t\t$input = static::getLogEvent('create') + static::getLogEvent('edit') + $input;", "return", "true", ";", "}" ]
Callback when validating create @param array $input @param int $newErrors @return boolean
[ "Callback", "when", "validating", "create" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L1095-L1103
235,896
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.extractCreateQuery
public static function extractCreateQuery(&$input) { // To do on Edit static::onEdit($input, null); foreach( $input as $fieldname => $fieldvalue ) { if( !in_array($fieldname, static::$fields) ) { unset($input[$fieldname]); } } $options = array( 'table' => static::$table, 'what' => $input, ); return $options; }
php
public static function extractCreateQuery(&$input) { // To do on Edit static::onEdit($input, null); foreach( $input as $fieldname => $fieldvalue ) { if( !in_array($fieldname, static::$fields) ) { unset($input[$fieldname]); } } $options = array( 'table' => static::$table, 'what' => $input, ); return $options; }
[ "public", "static", "function", "extractCreateQuery", "(", "&", "$", "input", ")", "{", "// To do on Edit", "static", "::", "onEdit", "(", "$", "input", ",", "null", ")", ";", "foreach", "(", "$", "input", "as", "$", "fieldname", "=>", "$", "fieldvalue", ")", "{", "if", "(", "!", "in_array", "(", "$", "fieldname", ",", "static", "::", "$", "fields", ")", ")", "{", "unset", "(", "$", "input", "[", "$", "fieldname", "]", ")", ";", "}", "}", "$", "options", "=", "array", "(", "'table'", "=>", "static", "::", "$", "table", ",", "'what'", "=>", "$", "input", ",", ")", ";", "return", "$", "options", ";", "}" ]
Extract a create query from this class @param array $input @return array
[ "Extract", "a", "create", "query", "from", "this", "class" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L1111-L1126
235,897
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.completeFields
public static function completeFields($data) { foreach( static::$fields as $fieldname ) { if( !isset($data[$fieldname]) ) { $data[$fieldname] = ''; } } return $data; }
php
public static function completeFields($data) { foreach( static::$fields as $fieldname ) { if( !isset($data[$fieldname]) ) { $data[$fieldname] = ''; } } return $data; }
[ "public", "static", "function", "completeFields", "(", "$", "data", ")", "{", "foreach", "(", "static", "::", "$", "fields", "as", "$", "fieldname", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "fieldname", "]", ")", ")", "{", "$", "data", "[", "$", "fieldname", "]", "=", "''", ";", "}", "}", "return", "$", "data", ";", "}" ]
Complete missing fields @param array $data The data array to complete. @return array The completed data array. Complete an array of data of an object of this class by setting missing fields with empty string.
[ "Complete", "missing", "fields" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L1153-L1160
235,898
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.checkUserInput
public static function checkUserInput($input, $fields = null, $ref = null, &$errCount = 0) { if( !isset($errCount) ) { $errCount = 0; } // Allow reversed parameters 2 & 3 - Declared as useless // if( !is_array($fields) && !is_object($ref) ) { // $tmp = $fields; $fields = $ref; $ref = $tmp; unset($tmp); // } // if( is_null($ref) && is_object($ref) ) { // $ref = $fields; // $fields = null; // } if( is_array(static::$validator) ) { if( $fields === null ) { $fields = static::$editableFields; } if( empty($fields) ) { return array(); } $data = array(); foreach( $fields as $field ) { // If editing the id field if( $field == static::$IDFIELD ) { continue; } $value = $notset = null; try { try { // Field to validate if( !empty(static::$validator[$field]) ) { $checkMeth = static::$validator[$field]; // If not defined, we just get the value without check $value = static::$checkMeth($input, $ref); // Field to NOT validate } else if( array_key_exists($field, $input) ) { $value = $input[$field]; } else { $notset = 1; } if( !isset($notset) && ($ref === null || $value != $ref->$field) && ($fields === null || in_array($field, $fields)) ) { $data[$field] = $value; } } catch( UserException $e ) { if( $value === null && isset($input[$field]) ) { $value = $input[$field]; } throw InvalidFieldException::from($e, $field, $value); } } catch( InvalidFieldException $e ) { $errCount++; reportError($e, static::getDomain()); } } return $data; } else if( is_object(static::$validator) ) { if( method_exists(static::$validator, 'validate') ) { return static::$validator->validate($input, $fields, $ref, $errCount); } } return array(); }
php
public static function checkUserInput($input, $fields = null, $ref = null, &$errCount = 0) { if( !isset($errCount) ) { $errCount = 0; } // Allow reversed parameters 2 & 3 - Declared as useless // if( !is_array($fields) && !is_object($ref) ) { // $tmp = $fields; $fields = $ref; $ref = $tmp; unset($tmp); // } // if( is_null($ref) && is_object($ref) ) { // $ref = $fields; // $fields = null; // } if( is_array(static::$validator) ) { if( $fields === null ) { $fields = static::$editableFields; } if( empty($fields) ) { return array(); } $data = array(); foreach( $fields as $field ) { // If editing the id field if( $field == static::$IDFIELD ) { continue; } $value = $notset = null; try { try { // Field to validate if( !empty(static::$validator[$field]) ) { $checkMeth = static::$validator[$field]; // If not defined, we just get the value without check $value = static::$checkMeth($input, $ref); // Field to NOT validate } else if( array_key_exists($field, $input) ) { $value = $input[$field]; } else { $notset = 1; } if( !isset($notset) && ($ref === null || $value != $ref->$field) && ($fields === null || in_array($field, $fields)) ) { $data[$field] = $value; } } catch( UserException $e ) { if( $value === null && isset($input[$field]) ) { $value = $input[$field]; } throw InvalidFieldException::from($e, $field, $value); } } catch( InvalidFieldException $e ) { $errCount++; reportError($e, static::getDomain()); } } return $data; } else if( is_object(static::$validator) ) { if( method_exists(static::$validator, 'validate') ) { return static::$validator->validate($input, $fields, $ref, $errCount); } } return array(); }
[ "public", "static", "function", "checkUserInput", "(", "$", "input", ",", "$", "fields", "=", "null", ",", "$", "ref", "=", "null", ",", "&", "$", "errCount", "=", "0", ")", "{", "if", "(", "!", "isset", "(", "$", "errCount", ")", ")", "{", "$", "errCount", "=", "0", ";", "}", "// Allow reversed parameters 2 & 3 - Declared as useless", "// \t\tif( !is_array($fields) && !is_object($ref) ) {", "// \t\t\t$tmp = $fields; $fields = $ref; $ref = $tmp; unset($tmp);", "// \t\t}", "// \t\tif( is_null($ref) && is_object($ref) ) {", "// \t\t\t$ref = $fields;", "// \t\t\t$fields = null;", "// \t\t}", "if", "(", "is_array", "(", "static", "::", "$", "validator", ")", ")", "{", "if", "(", "$", "fields", "===", "null", ")", "{", "$", "fields", "=", "static", "::", "$", "editableFields", ";", "}", "if", "(", "empty", "(", "$", "fields", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "// If editing the id field", "if", "(", "$", "field", "==", "static", "::", "$", "IDFIELD", ")", "{", "continue", ";", "}", "$", "value", "=", "$", "notset", "=", "null", ";", "try", "{", "try", "{", "// Field to validate", "if", "(", "!", "empty", "(", "static", "::", "$", "validator", "[", "$", "field", "]", ")", ")", "{", "$", "checkMeth", "=", "static", "::", "$", "validator", "[", "$", "field", "]", ";", "// If not defined, we just get the value without check", "$", "value", "=", "static", "::", "$", "checkMeth", "(", "$", "input", ",", "$", "ref", ")", ";", "// Field to NOT validate", "}", "else", "if", "(", "array_key_exists", "(", "$", "field", ",", "$", "input", ")", ")", "{", "$", "value", "=", "$", "input", "[", "$", "field", "]", ";", "}", "else", "{", "$", "notset", "=", "1", ";", "}", "if", "(", "!", "isset", "(", "$", "notset", ")", "&&", "(", "$", "ref", "===", "null", "||", "$", "value", "!=", "$", "ref", "->", "$", "field", ")", "&&", "(", "$", "fields", "===", "null", "||", "in_array", "(", "$", "field", ",", "$", "fields", ")", ")", ")", "{", "$", "data", "[", "$", "field", "]", "=", "$", "value", ";", "}", "}", "catch", "(", "UserException", "$", "e", ")", "{", "if", "(", "$", "value", "===", "null", "&&", "isset", "(", "$", "input", "[", "$", "field", "]", ")", ")", "{", "$", "value", "=", "$", "input", "[", "$", "field", "]", ";", "}", "throw", "InvalidFieldException", "::", "from", "(", "$", "e", ",", "$", "field", ",", "$", "value", ")", ";", "}", "}", "catch", "(", "InvalidFieldException", "$", "e", ")", "{", "$", "errCount", "++", ";", "reportError", "(", "$", "e", ",", "static", "::", "getDomain", "(", ")", ")", ";", "}", "}", "return", "$", "data", ";", "}", "else", "if", "(", "is_object", "(", "static", "::", "$", "validator", ")", ")", "{", "if", "(", "method_exists", "(", "static", "::", "$", "validator", ",", "'validate'", ")", ")", "{", "return", "static", "::", "$", "validator", "->", "validate", "(", "$", "input", ",", "$", "fields", ",", "$", "ref", ",", "$", "errCount", ")", ";", "}", "}", "return", "array", "(", ")", ";", "}" ]
Check user input @param array $input The user input data to check. @param string[] $fields The array of fields to check. Default value is null. @param PermanentObject $ref The referenced object (update only). Default value is null. @param int $errCount The resulting error count, as pointer. Output parameter. @return array The valid data. Check if the class could generate a valid object from $input. The method could modify the user input to fix them but it must return the data. The data are passed through the validator, for different cases: - If empty, this function return an empty array. - If an array, it uses an field => checkMethod association.
[ "Check", "user", "input" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L1262-L1329
235,899
Sowapps/orpheus-publisher
src/Publisher/PermanentObject/PermanentObject.php
PermanentObject.getClassData
public static function getClassData(&$classData = null) { $class = static::getClass(); if( !isset(static::$knownClassData[$class]) ) { static::$knownClassData[$class] = (object)array( 'sqlAdapter' => null, ); } $classData = static::$knownClassData[$class]; return $classData; }
php
public static function getClassData(&$classData = null) { $class = static::getClass(); if( !isset(static::$knownClassData[$class]) ) { static::$knownClassData[$class] = (object)array( 'sqlAdapter' => null, ); } $classData = static::$knownClassData[$class]; return $classData; }
[ "public", "static", "function", "getClassData", "(", "&", "$", "classData", "=", "null", ")", "{", "$", "class", "=", "static", "::", "getClass", "(", ")", ";", "if", "(", "!", "isset", "(", "static", "::", "$", "knownClassData", "[", "$", "class", "]", ")", ")", "{", "static", "::", "$", "knownClassData", "[", "$", "class", "]", "=", "(", "object", ")", "array", "(", "'sqlAdapter'", "=>", "null", ",", ")", ";", "}", "$", "classData", "=", "static", "::", "$", "knownClassData", "[", "$", "class", "]", ";", "return", "$", "classData", ";", "}" ]
Get all gathered data about this class @param array $classData @return array
[ "Get", "all", "gathered", "data", "about", "this", "class" ]
e33508538a0aa6f7491d724ca1cb09893203bfba
https://github.com/Sowapps/orpheus-publisher/blob/e33508538a0aa6f7491d724ca1cb09893203bfba/src/Publisher/PermanentObject/PermanentObject.php#L1386-L1395