repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
jelix/php-redis-plugin
plugins/cache/redis_php/redis_php.cache.php
redis_phpCacheDriver.set
public function set($key, $value, $ttl = 0) { if (is_resource($value)) { return false; } $used_key = $this->getUsedKey($key); $res = $this->redis->set($used_key, $this->esc($value)); if ($res !== 'OK') { return false; } if ($ttl === 0) { return true; } if ($ttl != 0 && $ttl > 2592000) { $ttl -= time(); } if ($ttl <= 0) { return true; } return ($this->redis->expire($used_key, $ttl) == 1); }
php
public function set($key, $value, $ttl = 0) { if (is_resource($value)) { return false; } $used_key = $this->getUsedKey($key); $res = $this->redis->set($used_key, $this->esc($value)); if ($res !== 'OK') { return false; } if ($ttl === 0) { return true; } if ($ttl != 0 && $ttl > 2592000) { $ttl -= time(); } if ($ttl <= 0) { return true; } return ($this->redis->expire($used_key, $ttl) == 1); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "0", ")", "{", "if", "(", "is_resource", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "$", "used_key", "=", "$", "this", "->", "getUsedKey", ...
set a specific data in the cache @param string $key key used for storing data @param mixed $var data to store @param int $ttl data time expiration @return boolean false if failure
[ "set", "a", "specific", "data", "in", "the", "cache" ]
bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b
https://github.com/jelix/php-redis-plugin/blob/bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b/plugins/cache/redis_php/redis_php.cache.php#L151-L173
train
jelix/php-redis-plugin
plugins/cache/redis_php/redis_php.cache.php
redis_phpCacheDriver.delete
public function delete($key) { $used_key = $this->getUsedKey($key); return ($this->redis->delete($used_key) > 0); }
php
public function delete($key) { $used_key = $this->getUsedKey($key); return ($this->redis->delete($used_key) > 0); }
[ "public", "function", "delete", "(", "$", "key", ")", "{", "$", "used_key", "=", "$", "this", "->", "getUsedKey", "(", "$", "key", ")", ";", "return", "(", "$", "this", "->", "redis", "->", "delete", "(", "$", "used_key", ")", ">", "0", ")", ";",...
delete a specific data in the cache @param string $key key used for storing data in the cache @return boolean false if failure
[ "delete", "a", "specific", "data", "in", "the", "cache" ]
bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b
https://github.com/jelix/php-redis-plugin/blob/bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b/plugins/cache/redis_php/redis_php.cache.php#L180-L183
train
jelix/php-redis-plugin
plugins/cache/redis_php/redis_php.cache.php
redis_phpCacheDriver.flush
public function flush() { if (!$this->key_prefix) { return ($this->redis->flushdb() == 'OK'); } switch($this->key_prefix_flush_method) { case 'direct': $this->redis->flushByPrefix($this->key_prefix); return true; case 'event': jEvent::notify('jCacheRedisFlushKeyPrefix', array('prefix'=>$this->key_prefix, 'profile' =>$this->profileName)); return true; case 'jcacheredisworker': $this->redis->rpush('jcacheredisdelkeys', $this->key_prefix); return true; } return false; }
php
public function flush() { if (!$this->key_prefix) { return ($this->redis->flushdb() == 'OK'); } switch($this->key_prefix_flush_method) { case 'direct': $this->redis->flushByPrefix($this->key_prefix); return true; case 'event': jEvent::notify('jCacheRedisFlushKeyPrefix', array('prefix'=>$this->key_prefix, 'profile' =>$this->profileName)); return true; case 'jcacheredisworker': $this->redis->rpush('jcacheredisdelkeys', $this->key_prefix); return true; } return false; }
[ "public", "function", "flush", "(", ")", "{", "if", "(", "!", "$", "this", "->", "key_prefix", ")", "{", "return", "(", "$", "this", "->", "redis", "->", "flushdb", "(", ")", "==", "'OK'", ")", ";", "}", "switch", "(", "$", "this", "->", "key_pre...
clear all data in the cache. If key_prefix is set, only keys with that prefix will be removed. Note that in that case, it can result in a huge performance issue. See key_prefix_flush_method to configure the best method for your app and your server. @return boolean false if failure
[ "clear", "all", "data", "in", "the", "cache", "." ]
bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b
https://github.com/jelix/php-redis-plugin/blob/bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b/plugins/cache/redis_php/redis_php.cache.php#L266-L283
train
lazyguru/jira
src/JiraService.php
JiraService.setWorklog
public function setWorklog($date, $ticket, $timeSpent, $comment = '') { $this->uri = "{$this->site}/rest/api/2/issue/{$ticket}/worklog"; if (is_numeric($timeSpent)) { $timeSpent .= 'h'; } $startedDate = $this->_formatTimestamp($date); $data = [ 'timeSpent' => $timeSpent, 'started' => $startedDate, 'comment' => $comment ]; $this->output->debug(print_r($data, true)); $data = json_encode($data); $response = $this->processRequest($data); $this->_handleError($data, $response); return $response; }
php
public function setWorklog($date, $ticket, $timeSpent, $comment = '') { $this->uri = "{$this->site}/rest/api/2/issue/{$ticket}/worklog"; if (is_numeric($timeSpent)) { $timeSpent .= 'h'; } $startedDate = $this->_formatTimestamp($date); $data = [ 'timeSpent' => $timeSpent, 'started' => $startedDate, 'comment' => $comment ]; $this->output->debug(print_r($data, true)); $data = json_encode($data); $response = $this->processRequest($data); $this->_handleError($data, $response); return $response; }
[ "public", "function", "setWorklog", "(", "$", "date", ",", "$", "ticket", ",", "$", "timeSpent", ",", "$", "comment", "=", "''", ")", "{", "$", "this", "->", "uri", "=", "\"{$this->site}/rest/api/2/issue/{$ticket}/worklog\"", ";", "if", "(", "is_numeric", "(...
Create worklog entry in Jira @param array $site @param string $date @param string $ticket @param mixed $timeSpent @param string $comment @throws Exception @return mixed
[ "Create", "worklog", "entry", "in", "Jira" ]
79e5e1f2b2c65b45faae5f8fe0f045e3eaba048b
https://github.com/lazyguru/jira/blob/79e5e1f2b2c65b45faae5f8fe0f045e3eaba048b/src/JiraService.php#L48-L69
train
tenside/core
src/Task/Composer/ComposerTaskFactory.php
ComposerTaskFactory.createUpgrade
protected function createUpgrade($metaData) { $this->ensureHomePath($metaData); if (!$metaData->has(UpgradeTask::SETTING_DATA_DIR)) { $metaData->set(UpgradeTask::SETTING_DATA_DIR, $this->home->tensideDataDir()); } return new UpgradeTask($metaData); }
php
protected function createUpgrade($metaData) { $this->ensureHomePath($metaData); if (!$metaData->has(UpgradeTask::SETTING_DATA_DIR)) { $metaData->set(UpgradeTask::SETTING_DATA_DIR, $this->home->tensideDataDir()); } return new UpgradeTask($metaData); }
[ "protected", "function", "createUpgrade", "(", "$", "metaData", ")", "{", "$", "this", "->", "ensureHomePath", "(", "$", "metaData", ")", ";", "if", "(", "!", "$", "metaData", "->", "has", "(", "UpgradeTask", "::", "SETTING_DATA_DIR", ")", ")", "{", "$",...
Create an upgrade task instance. @param JsonArray $metaData The meta data for the task. @return UpgradeTask
[ "Create", "an", "upgrade", "task", "instance", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/Composer/ComposerTaskFactory.php#L68-L75
train
tenside/core
src/Task/Composer/ComposerTaskFactory.php
ComposerTaskFactory.ensureHomePath
private function ensureHomePath(JsonArray $metaData) { if ($metaData->has(AbstractPackageManipulatingTask::SETTING_HOME)) { return; } $metaData->set(AbstractPackageManipulatingTask::SETTING_HOME, $this->home->homeDir()); }
php
private function ensureHomePath(JsonArray $metaData) { if ($metaData->has(AbstractPackageManipulatingTask::SETTING_HOME)) { return; } $metaData->set(AbstractPackageManipulatingTask::SETTING_HOME, $this->home->homeDir()); }
[ "private", "function", "ensureHomePath", "(", "JsonArray", "$", "metaData", ")", "{", "if", "(", "$", "metaData", "->", "has", "(", "AbstractPackageManipulatingTask", "::", "SETTING_HOME", ")", ")", "{", "return", ";", "}", "$", "metaData", "->", "set", "(",...
Ensure the home path has been set in the passed meta data. @param JsonArray $metaData The meta data to examine. @return void
[ "Ensure", "the", "home", "path", "has", "been", "set", "in", "the", "passed", "meta", "data", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/Composer/ComposerTaskFactory.php#L110-L116
train
SergioMadness/framework
framework/components/eventhandler/traits/EventTrait.php
EventTrait.on
public function on($type, $callback) { if (!isset($this->callbacks[$type])) { $this->callbacks[$type] = []; } $this->callbacks[$type][] = $callback; return $this; }
php
public function on($type, $callback) { if (!isset($this->callbacks[$type])) { $this->callbacks[$type] = []; } $this->callbacks[$type][] = $callback; return $this; }
[ "public", "function", "on", "(", "$", "type", ",", "$", "callback", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "callbacks", "[", "$", "type", "]", ")", ")", "{", "$", "this", "->", "callbacks", "[", "$", "type", "]", "=", "[", ...
Register event handler @param string $type @param \Closure|array|string $callback @return $this
[ "Register", "event", "handler" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/eventhandler/traits/EventTrait.php#L17-L24
train
asbsoft/yii2module-news_2b_161124
models/NewsArchieve.php
NewsArchieve.preSaveText
public static function preSaveText($text, $controller, $transTable = []) { $module = Module::getModuleByClassname(Module::className()); $editorContentHelper = $module->contentHelper; $text = trim($text); if (empty($text)) return ''; $text = $editorContentHelper::afterSelectBody($text); // convert @uploads/.../ID to realpath $text = strtr($text, $transTable); $html = $text; $viewFile = dirname(__DIR__) . '/views/news-archieve-text.php'; if (is_file($viewFile)) { $text = static::START_TEXT_TAG . $text . static::END_TEXT_TAG; $html = Yii::$app->view->renderFile($viewFile, ['text' => $text], $controller); } return $html; }
php
public static function preSaveText($text, $controller, $transTable = []) { $module = Module::getModuleByClassname(Module::className()); $editorContentHelper = $module->contentHelper; $text = trim($text); if (empty($text)) return ''; $text = $editorContentHelper::afterSelectBody($text); // convert @uploads/.../ID to realpath $text = strtr($text, $transTable); $html = $text; $viewFile = dirname(__DIR__) . '/views/news-archieve-text.php'; if (is_file($viewFile)) { $text = static::START_TEXT_TAG . $text . static::END_TEXT_TAG; $html = Yii::$app->view->renderFile($viewFile, ['text' => $text], $controller); } return $html; }
[ "public", "static", "function", "preSaveText", "(", "$", "text", ",", "$", "controller", ",", "$", "transTable", "=", "[", "]", ")", "{", "$", "module", "=", "Module", "::", "getModuleByClassname", "(", "Module", "::", "className", "(", ")", ")", ";", ...
Processing text before saving. @param string $text @param Controller $controller @param array $transTable @return string
[ "Processing", "text", "before", "saving", "." ]
9e9a7fdb458c88c7cdcd060cdc07cc4a7664690d
https://github.com/asbsoft/yii2module-news_2b_161124/blob/9e9a7fdb458c88c7cdcd060cdc07cc4a7664690d/models/NewsArchieve.php#L112-L131
train
asbsoft/yii2module-news_2b_161124
models/NewsArchieve.php
NewsArchieve.getSlug
public static function getSlug($model) { $i18nModels = $model->i18n; $slugs = []; foreach ($i18nModels as $i18nModel) { if (empty($i18nModel->body)) continue; // skip languages for news without body $slugs[$i18nModel->lang_code] = $i18nModel->slug; } //$langs = array_keys(LangHelper::activeLanguages()); // better use as container-module's member: $module = Module::getModuleByClassname(Module::className()); $langHelper = $module->langHelper; $langs = array_keys($langHelper::activeLanguages()); $slug = ''; foreach ($langs as $lang) { if (!empty($slugs[$lang])) { $slug = $slugs[$lang]; break; } } if (strlen($slug) > static::$slugMaxLen) { $slug = substr($slug, 0, static::$slugMaxLen); } $slug = trim($slug, '-'); return $slug; }
php
public static function getSlug($model) { $i18nModels = $model->i18n; $slugs = []; foreach ($i18nModels as $i18nModel) { if (empty($i18nModel->body)) continue; // skip languages for news without body $slugs[$i18nModel->lang_code] = $i18nModel->slug; } //$langs = array_keys(LangHelper::activeLanguages()); // better use as container-module's member: $module = Module::getModuleByClassname(Module::className()); $langHelper = $module->langHelper; $langs = array_keys($langHelper::activeLanguages()); $slug = ''; foreach ($langs as $lang) { if (!empty($slugs[$lang])) { $slug = $slugs[$lang]; break; } } if (strlen($slug) > static::$slugMaxLen) { $slug = substr($slug, 0, static::$slugMaxLen); } $slug = trim($slug, '-'); return $slug; }
[ "public", "static", "function", "getSlug", "(", "$", "model", ")", "{", "$", "i18nModels", "=", "$", "model", "->", "i18n", ";", "$", "slugs", "=", "[", "]", ";", "foreach", "(", "$", "i18nModels", "as", "$", "i18nModel", ")", "{", "if", "(", "empt...
Get first non-empty slug of news. Search in default languages priority. @param News $model @return string
[ "Get", "first", "non", "-", "empty", "slug", "of", "news", ".", "Search", "in", "default", "languages", "priority", "." ]
9e9a7fdb458c88c7cdcd060cdc07cc4a7664690d
https://github.com/asbsoft/yii2module-news_2b_161124/blob/9e9a7fdb458c88c7cdcd060cdc07cc4a7664690d/models/NewsArchieve.php#L138-L163
train
bmdevel/php-index
classes/Range.php
Range.contains
public function contains($key) { if ($this->inclusive && in_array($key, array($this->min, $this->max))) { return true; } return $key > $this->min && $key < $this->max; }
php
public function contains($key) { if ($this->inclusive && in_array($key, array($this->min, $this->max))) { return true; } return $key > $this->min && $key < $this->max; }
[ "public", "function", "contains", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "inclusive", "&&", "in_array", "(", "$", "key", ",", "array", "(", "$", "this", "->", "min", ",", "$", "this", "->", "max", ")", ")", ")", "{", "return", ...
Returns true if key is inside this range @param String $key @return bool
[ "Returns", "true", "if", "key", "is", "inside", "this", "range" ]
6a6b476f1706b9524bfb34f6ce0963b1aea91259
https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/Range.php#L70-L77
train
mickeyhead7/mickeyhead7-rsvp
src/Response/JsonapiResponse.php
JsonApiResponse.setLinks
public function setLinks() { // Only required for collections as items contain links by default if ($this->resource instanceof Collection && $paginator = $this->resource->getPaginator()) { $pagination = new Pagination($paginator); $this->links = $pagination->generateCollectionLinks(); } else { unset($this->links); } return $this; }
php
public function setLinks() { // Only required for collections as items contain links by default if ($this->resource instanceof Collection && $paginator = $this->resource->getPaginator()) { $pagination = new Pagination($paginator); $this->links = $pagination->generateCollectionLinks(); } else { unset($this->links); } return $this; }
[ "public", "function", "setLinks", "(", ")", "{", "// Only required for collections as items contain links by default", "if", "(", "$", "this", "->", "resource", "instanceof", "Collection", "&&", "$", "paginator", "=", "$", "this", "->", "resource", "->", "getPaginator...
Set the response links data @return $this Instance of self
[ "Set", "the", "response", "links", "data" ]
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L49-L60
train
mickeyhead7/mickeyhead7-rsvp
src/Response/JsonapiResponse.php
JsonApiResponse.setData
public function setData() { // Process a collection if ($this->resource instanceof Collection) { $this->data = []; foreach ($this->resource->getData() as $resource) { $this->parseItem(new Item($resource, $this->resource->getTransformer())); } } // Process an item elseif ($this->resource instanceof Item) { $this->parseItem($this->resource); } return $this; }
php
public function setData() { // Process a collection if ($this->resource instanceof Collection) { $this->data = []; foreach ($this->resource->getData() as $resource) { $this->parseItem(new Item($resource, $this->resource->getTransformer())); } } // Process an item elseif ($this->resource instanceof Item) { $this->parseItem($this->resource); } return $this; }
[ "public", "function", "setData", "(", ")", "{", "// Process a collection", "if", "(", "$", "this", "->", "resource", "instanceof", "Collection", ")", "{", "$", "this", "->", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "resource", "->",...
Creates the response @return $this Instance of self
[ "Creates", "the", "response" ]
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L67-L84
train
mickeyhead7/mickeyhead7-rsvp
src/Response/JsonapiResponse.php
JsonApiResponse.parseItem
private function parseItem(Item $item) { // Get and format an item $tmp = $this->getFormattedItem($item); // Get related data $relationships = $this->getRelationships($item); // Closure function to internally parse related includes $parseRelationships = function($key, Item $item, array $relationships = []) { $related = $this->getFormattedItem($item); if (!in_array($related, $this->relationships)) { $this->relationships[] = $related; } unset($related['attributes']); unset($related['links']); $relationships[$key]['data'][] = $related; return $relationships; }; // Loop data to create includes response data foreach ($relationships as $key => $value) { if ($value instanceof Collection) { foreach ($value->getData() as $include_value) { $relationships = $parseRelationships($key, new Item($include_value, $value->getTransformer()), $relationships); } } else if ($value instanceof Item) { $relationships = $parseRelationships($key, $value, $relationships); } } // Pass the relationships data into the item $tmp['relationships'] = $relationships; // Set the response data if (is_array($this->data)) { $this->data[] = $tmp; } else { $this->data = $tmp; } return $this; }
php
private function parseItem(Item $item) { // Get and format an item $tmp = $this->getFormattedItem($item); // Get related data $relationships = $this->getRelationships($item); // Closure function to internally parse related includes $parseRelationships = function($key, Item $item, array $relationships = []) { $related = $this->getFormattedItem($item); if (!in_array($related, $this->relationships)) { $this->relationships[] = $related; } unset($related['attributes']); unset($related['links']); $relationships[$key]['data'][] = $related; return $relationships; }; // Loop data to create includes response data foreach ($relationships as $key => $value) { if ($value instanceof Collection) { foreach ($value->getData() as $include_value) { $relationships = $parseRelationships($key, new Item($include_value, $value->getTransformer()), $relationships); } } else if ($value instanceof Item) { $relationships = $parseRelationships($key, $value, $relationships); } } // Pass the relationships data into the item $tmp['relationships'] = $relationships; // Set the response data if (is_array($this->data)) { $this->data[] = $tmp; } else { $this->data = $tmp; } return $this; }
[ "private", "function", "parseItem", "(", "Item", "$", "item", ")", "{", "// Get and format an item", "$", "tmp", "=", "$", "this", "->", "getFormattedItem", "(", "$", "item", ")", ";", "// Get related data", "$", "relationships", "=", "$", "this", "->", "get...
Parses an item into response data @param Item $item Resource item @return $this Instance of self
[ "Parses", "an", "item", "into", "response", "data" ]
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L92-L137
train
mickeyhead7/mickeyhead7-rsvp
src/Response/JsonapiResponse.php
JsonApiResponse.getFormattedItem
private function getFormattedItem(Item $item) { $data = [ 'type' => $this->getFormattedName($item->getTransformer()), 'id' => $item->getData()->id, 'attributes' => $item->sanitize(), ]; if ($links = $item->getLinks()) { $data['links'] = $links; } return $data; }
php
private function getFormattedItem(Item $item) { $data = [ 'type' => $this->getFormattedName($item->getTransformer()), 'id' => $item->getData()->id, 'attributes' => $item->sanitize(), ]; if ($links = $item->getLinks()) { $data['links'] = $links; } return $data; }
[ "private", "function", "getFormattedItem", "(", "Item", "$", "item", ")", "{", "$", "data", "=", "[", "'type'", "=>", "$", "this", "->", "getFormattedName", "(", "$", "item", "->", "getTransformer", "(", ")", ")", ",", "'id'", "=>", "$", "item", "->", ...
Formats an item ready for response @param Item $item Resource item @return array Formatted item data
[ "Formats", "an", "item", "ready", "for", "response" ]
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L145-L158
train
mickeyhead7/mickeyhead7-rsvp
src/Response/JsonapiResponse.php
JsonApiResponse.getFormattedName
private function getFormattedName($class) { $class_name = (substr(strrchr(get_class($class), "\\"), 1)); $underscored = preg_replace('/([a-z])([A-Z])/', '$1_$2', $class_name); return strtolower($underscored); }
php
private function getFormattedName($class) { $class_name = (substr(strrchr(get_class($class), "\\"), 1)); $underscored = preg_replace('/([a-z])([A-Z])/', '$1_$2', $class_name); return strtolower($underscored); }
[ "private", "function", "getFormattedName", "(", "$", "class", ")", "{", "$", "class_name", "=", "(", "substr", "(", "strrchr", "(", "get_class", "(", "$", "class", ")", ",", "\"\\\\\"", ")", ",", "1", ")", ")", ";", "$", "underscored", "=", "preg_repla...
Formats a class name for readable use in the response @param $class Class name to format @return string Formatted name
[ "Formats", "a", "class", "name", "for", "readable", "use", "in", "the", "response" ]
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L166-L172
train
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_par...
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
train
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", "->"...
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
train
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", "(", "$",...
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
train
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", "(", "$", "m...
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
train
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'", ")", ";", "}...
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
train
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", ")", ...
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
train
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", ")", ...
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
train
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",...
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
train
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", ";...
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
train
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", "{",...
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
train
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", ...
Load key. @param $key
[ "Load", "key", "." ]
8328423f81c69b8fabc04b4f6b1f3ba712695374
https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Config/Repository.php#L33-L54
train
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_va...
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
train
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", "(", "$", "v...
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
train
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"...
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
train
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", "(", ...
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
train
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", "{", ...
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
train
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", "(", "...
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
train
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", "{", ...
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
train
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'",...
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
train
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", "(", "$", "...
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
train
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", "(", "$", ...
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
train
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
train
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 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
train
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
train
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", ")", ".", "' = ?'", ",", "[",...
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
train
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", "(", "...
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
train
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", "(", ...
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
train
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", "$", ...
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
train
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", ".", "' = ?'", ")", "->", "ex...
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
train
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'", ",", "$", "condi...
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
train
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", "->", "con...
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
train
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", ")", "...
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
train
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", "=", "(", "$", "r...
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
train
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", "(", ")", ...
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
train
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", ...
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
train
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", "(", "'/\\\...
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
train
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", "->", "ta...
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
train
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", "[", "]", "=", ...
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
train
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",...
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
train
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", ...
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
train
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", ".=", "\...
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
train
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", ...
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
train
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'", "]", ")", "...
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
train
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", ";", ...
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
train
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...
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
train
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", "===", ...
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
train
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"...
Load plugin data @return $this
[ "Load", "plugin", "data" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Plugin/Plugin.php#L93-L128
train
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", ")", "instanc...
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
train
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", "(", ")",...
Add a channel. @api @param ChannelInterface $channel
[ "Add", "a", "channel", "." ]
1f95656ae963b68734935773c11e44c0af412303
https://github.com/Notifier/Notifier/blob/1f95656ae963b68734935773c11e44c0af412303/src/Notifier.php#L96-L105
train
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", ...
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
train
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", "(", ")...
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
train
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", "(",...
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
train
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"...
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
train
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", "(", "$", "de...
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
train
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", "="...
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
train
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", "->", "e...
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
train
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", "=", "$...
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
train
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", ...
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
train
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
train
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", "...
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
train
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", "(", "'{d...
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", "se...
ddf82ba91b169e47dce2eee6cea7c2d20428c647
https://github.com/phonedotcom/mason-php/blob/ddf82ba91b169e47dce2eee6cea7c2d20428c647/src/Builder/Components/Base.php#L96-L122
train
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'", "=>", "Formatt...
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
train
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'", ")", ";", "}", "$", "te...
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
train
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"...
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
train
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"...
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
train
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", "(", "$", "to...
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
train
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", "(", ")", "->", "f...
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
train
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", ")", "$",...
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
train
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 StorageMeta...
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
train
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", "(", ")", ")", "{"...
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
train
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", "(", ...
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
train
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",...
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
train
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", ";", "}", "$...
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
train
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", "$", ...
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
train
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", "=>", "$", ...
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
train
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", ";", "...
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
train
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", "(", ...
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
train
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", ...
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
train
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", "...
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
train
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", "=>", ...
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
train
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"...
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
train
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", "(", "$", "thi...
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
train
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", ";", "$...
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
train
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", "->", "$",...
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
train
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", ...
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
train