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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Source.php
Source.initPages
public function initPages($overrideExisting = true) { if (null !== $this->collPages && !$overrideExisting) { return; } $collectionClassName = PageTableMap::getTableMap()->getCollectionClassName(); $this->collPages = new $collectionClassName; $this->collPages->setModel('\Attogram\SharedMedia\Orm\Page'); }
php
public function initPages($overrideExisting = true) { if (null !== $this->collPages && !$overrideExisting) { return; } $collectionClassName = PageTableMap::getTableMap()->getCollectionClassName(); $this->collPages = new $collectionClassName; $this->collPages->setModel('\Attogram\SharedMedia\Orm\Page'); }
[ "public", "function", "initPages", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collPages", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "collectionClassName", "=", "PageTableMap", "::", "getTableMap", "(", ")", "->", "getCollectionClassName", "(", ")", ";", "$", "this", "->", "collPages", "=", "new", "$", "collectionClassName", ";", "$", "this", "->", "collPages", "->", "setModel", "(", "'\\Attogram\\SharedMedia\\Orm\\Page'", ")", ";", "}" ]
Initializes the collPages collection. By default this just sets the collPages collection to an empty array (like clearcollPages()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collPages", "collection", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Source.php#L1952-L1962
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Source.php
Source.getPages
public function getPages(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collPagesPartial && !$this->isNew(); if (null === $this->collPages || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPages) { // return empty collection $this->initPages(); } else { $collPages = ChildPageQuery::create(null, $criteria) ->filterBySource($this) ->find($con); if (null !== $criteria) { if (false !== $this->collPagesPartial && count($collPages)) { $this->initPages(false); foreach ($collPages as $obj) { if (false == $this->collPages->contains($obj)) { $this->collPages->append($obj); } } $this->collPagesPartial = true; } return $collPages; } if ($partial && $this->collPages) { foreach ($this->collPages as $obj) { if ($obj->isNew()) { $collPages[] = $obj; } } } $this->collPages = $collPages; $this->collPagesPartial = false; } } return $this->collPages; }
php
public function getPages(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collPagesPartial && !$this->isNew(); if (null === $this->collPages || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPages) { // return empty collection $this->initPages(); } else { $collPages = ChildPageQuery::create(null, $criteria) ->filterBySource($this) ->find($con); if (null !== $criteria) { if (false !== $this->collPagesPartial && count($collPages)) { $this->initPages(false); foreach ($collPages as $obj) { if (false == $this->collPages->contains($obj)) { $this->collPages->append($obj); } } $this->collPagesPartial = true; } return $collPages; } if ($partial && $this->collPages) { foreach ($this->collPages as $obj) { if ($obj->isNew()) { $collPages[] = $obj; } } } $this->collPages = $collPages; $this->collPagesPartial = false; } } return $this->collPages; }
[ "public", "function", "getPages", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collPagesPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collPages", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collPages", ")", "{", "// return empty collection", "$", "this", "->", "initPages", "(", ")", ";", "}", "else", "{", "$", "collPages", "=", "ChildPageQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterBySource", "(", "$", "this", ")", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "if", "(", "false", "!==", "$", "this", "->", "collPagesPartial", "&&", "count", "(", "$", "collPages", ")", ")", "{", "$", "this", "->", "initPages", "(", "false", ")", ";", "foreach", "(", "$", "collPages", "as", "$", "obj", ")", "{", "if", "(", "false", "==", "$", "this", "->", "collPages", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "this", "->", "collPages", "->", "append", "(", "$", "obj", ")", ";", "}", "}", "$", "this", "->", "collPagesPartial", "=", "true", ";", "}", "return", "$", "collPages", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collPages", ")", "{", "foreach", "(", "$", "this", "->", "collPages", "as", "$", "obj", ")", "{", "if", "(", "$", "obj", "->", "isNew", "(", ")", ")", "{", "$", "collPages", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collPages", "=", "$", "collPages", ";", "$", "this", "->", "collPagesPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collPages", ";", "}" ]
Gets an array of ChildPage objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildSource is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return ObjectCollection|ChildPage[] List of ChildPage objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildPage", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Source.php#L1978-L2020
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Source.php
Source.countPages
public function countPages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collPagesPartial && !$this->isNew(); if (null === $this->collPages || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPages) { return 0; } if ($partial && !$criteria) { return count($this->getPages()); } $query = ChildPageQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterBySource($this) ->count($con); } return count($this->collPages); }
php
public function countPages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collPagesPartial && !$this->isNew(); if (null === $this->collPages || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPages) { return 0; } if ($partial && !$criteria) { return count($this->getPages()); } $query = ChildPageQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterBySource($this) ->count($con); } return count($this->collPages); }
[ "public", "function", "countPages", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collPagesPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collPages", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collPages", ")", "{", "return", "0", ";", "}", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getPages", "(", ")", ")", ";", "}", "$", "query", "=", "ChildPageQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterBySource", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "return", "count", "(", "$", "this", "->", "collPages", ")", ";", "}" ]
Returns the number of related Page objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related Page objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "Page", "objects", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Source.php#L2064-L2087
train
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Base/Source.php
Source.addPage
public function addPage(ChildPage $l) { if ($this->collPages === null) { $this->initPages(); $this->collPagesPartial = true; } if (!$this->collPages->contains($l)) { $this->doAddPage($l); if ($this->pagesScheduledForDeletion and $this->pagesScheduledForDeletion->contains($l)) { $this->pagesScheduledForDeletion->remove($this->pagesScheduledForDeletion->search($l)); } } return $this; }
php
public function addPage(ChildPage $l) { if ($this->collPages === null) { $this->initPages(); $this->collPagesPartial = true; } if (!$this->collPages->contains($l)) { $this->doAddPage($l); if ($this->pagesScheduledForDeletion and $this->pagesScheduledForDeletion->contains($l)) { $this->pagesScheduledForDeletion->remove($this->pagesScheduledForDeletion->search($l)); } } return $this; }
[ "public", "function", "addPage", "(", "ChildPage", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collPages", "===", "null", ")", "{", "$", "this", "->", "initPages", "(", ")", ";", "$", "this", "->", "collPagesPartial", "=", "true", ";", "}", "if", "(", "!", "$", "this", "->", "collPages", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "doAddPage", "(", "$", "l", ")", ";", "if", "(", "$", "this", "->", "pagesScheduledForDeletion", "and", "$", "this", "->", "pagesScheduledForDeletion", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "pagesScheduledForDeletion", "->", "remove", "(", "$", "this", "->", "pagesScheduledForDeletion", "->", "search", "(", "$", "l", ")", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Method called to associate a ChildPage object to this object through the ChildPage foreign key attribute. @param ChildPage $l ChildPage @return $this|\Attogram\SharedMedia\Orm\Source The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildPage", "object", "to", "this", "object", "through", "the", "ChildPage", "foreign", "key", "attribute", "." ]
81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Source.php#L2096-L2112
train
translationexchange/tml-php-clientsdk
library/Tr8n/Application.php
Application.submitMissingKeys
public function submitMissingKeys() { if ($this->missing_keys_by_sources == null) return; $params = array(); $source_keys = array(); foreach($this->missing_keys_by_sources as $source => $keys) { array_push($source_keys, $source); $keys_data = array(); foreach($keys as $key) { /** @var $key TranslationKey */ $json = array( "key" => $key->key, "label" => $key->label, "description" => $key->description, "locale" => $key->locale, "level" => $key->level ); array_push($keys_data, $json); } array_push($params, array("source" => $source, "keys" => $keys_data)); } $params = \Tr8n\Utils\ArrayUtils::trim($params); $this->apiClient()->post('source/register_keys', array("source_keys" => json_encode($params))); $this->missing_keys_by_sources = null; // All source caches must be reset for all languages, since the keys have changed foreach ($this->languages_by_locale as $locale => $language) { foreach ($source_keys as $source_key) { Cache::delete(Source::cacheKey($source_key, $locale)); } } }
php
public function submitMissingKeys() { if ($this->missing_keys_by_sources == null) return; $params = array(); $source_keys = array(); foreach($this->missing_keys_by_sources as $source => $keys) { array_push($source_keys, $source); $keys_data = array(); foreach($keys as $key) { /** @var $key TranslationKey */ $json = array( "key" => $key->key, "label" => $key->label, "description" => $key->description, "locale" => $key->locale, "level" => $key->level ); array_push($keys_data, $json); } array_push($params, array("source" => $source, "keys" => $keys_data)); } $params = \Tr8n\Utils\ArrayUtils::trim($params); $this->apiClient()->post('source/register_keys', array("source_keys" => json_encode($params))); $this->missing_keys_by_sources = null; // All source caches must be reset for all languages, since the keys have changed foreach ($this->languages_by_locale as $locale => $language) { foreach ($source_keys as $source_key) { Cache::delete(Source::cacheKey($source_key, $locale)); } } }
[ "public", "function", "submitMissingKeys", "(", ")", "{", "if", "(", "$", "this", "->", "missing_keys_by_sources", "==", "null", ")", "return", ";", "$", "params", "=", "array", "(", ")", ";", "$", "source_keys", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "missing_keys_by_sources", "as", "$", "source", "=>", "$", "keys", ")", "{", "array_push", "(", "$", "source_keys", ",", "$", "source", ")", ";", "$", "keys_data", "=", "array", "(", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "/** @var $key TranslationKey */", "$", "json", "=", "array", "(", "\"key\"", "=>", "$", "key", "->", "key", ",", "\"label\"", "=>", "$", "key", "->", "label", ",", "\"description\"", "=>", "$", "key", "->", "description", ",", "\"locale\"", "=>", "$", "key", "->", "locale", ",", "\"level\"", "=>", "$", "key", "->", "level", ")", ";", "array_push", "(", "$", "keys_data", ",", "$", "json", ")", ";", "}", "array_push", "(", "$", "params", ",", "array", "(", "\"source\"", "=>", "$", "source", ",", "\"keys\"", "=>", "$", "keys_data", ")", ")", ";", "}", "$", "params", "=", "\\", "Tr8n", "\\", "Utils", "\\", "ArrayUtils", "::", "trim", "(", "$", "params", ")", ";", "$", "this", "->", "apiClient", "(", ")", "->", "post", "(", "'source/register_keys'", ",", "array", "(", "\"source_keys\"", "=>", "json_encode", "(", "$", "params", ")", ")", ")", ";", "$", "this", "->", "missing_keys_by_sources", "=", "null", ";", "// All source caches must be reset for all languages, since the keys have changed", "foreach", "(", "$", "this", "->", "languages_by_locale", "as", "$", "locale", "=>", "$", "language", ")", "{", "foreach", "(", "$", "source_keys", "as", "$", "source_key", ")", "{", "Cache", "::", "delete", "(", "Source", "::", "cacheKey", "(", "$", "source_key", ",", "$", "locale", ")", ")", ";", "}", "}", "}" ]
Submits missing keys to the service
[ "Submits", "missing", "keys", "to", "the", "service" ]
fe51473824e62cfd883c6aa0c6a3783a16ce8425
https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Application.php#L393-L427
train
phpffcms/ffcms-core
src/Migrations/Migration.php
Migration.up
public function up() { $record = new MigrationRecord(); if ($this->connection !== null) { $record->setConnection($this->connection); } $record->migration = $this->name; $record->save(); }
php
public function up() { $record = new MigrationRecord(); if ($this->connection !== null) { $record->setConnection($this->connection); } $record->migration = $this->name; $record->save(); }
[ "public", "function", "up", "(", ")", "{", "$", "record", "=", "new", "MigrationRecord", "(", ")", ";", "if", "(", "$", "this", "->", "connection", "!==", "null", ")", "{", "$", "record", "->", "setConnection", "(", "$", "this", "->", "connection", ")", ";", "}", "$", "record", "->", "migration", "=", "$", "this", "->", "name", ";", "$", "record", "->", "save", "(", ")", ";", "}" ]
Insert data into migration table
[ "Insert", "data", "into", "migration", "table" ]
44a309553ef9f115ccfcfd71f2ac6e381c612082
https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Migrations/Migration.php#L35-L43
train
phpffcms/ffcms-core
src/Migrations/Migration.php
Migration.down
public function down() { $record = new MigrationRecord(); if ($this->connection !== null) { $record->setConnection($this->connection); } $record->where('migration', $this->name)->delete(); }
php
public function down() { $record = new MigrationRecord(); if ($this->connection !== null) { $record->setConnection($this->connection); } $record->where('migration', $this->name)->delete(); }
[ "public", "function", "down", "(", ")", "{", "$", "record", "=", "new", "MigrationRecord", "(", ")", ";", "if", "(", "$", "this", "->", "connection", "!==", "null", ")", "{", "$", "record", "->", "setConnection", "(", "$", "this", "->", "connection", ")", ";", "}", "$", "record", "->", "where", "(", "'migration'", ",", "$", "this", "->", "name", ")", "->", "delete", "(", ")", ";", "}" ]
Remove data from migration table
[ "Remove", "data", "from", "migration", "table" ]
44a309553ef9f115ccfcfd71f2ac6e381c612082
https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Migrations/Migration.php#L48-L55
train
Gravitas-GM/PluginBase
src/Gravitas/PluginBase/PluginBase.php
PluginBase.run
public function run() { $this->execute(); if ($handler = $this->getFormHandler(@$_REQUEST['_form_name'])) call_user_func($handler, $_REQUEST); }
php
public function run() { $this->execute(); if ($handler = $this->getFormHandler(@$_REQUEST['_form_name'])) call_user_func($handler, $_REQUEST); }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "execute", "(", ")", ";", "if", "(", "$", "handler", "=", "$", "this", "->", "getFormHandler", "(", "@", "$", "_REQUEST", "[", "'_form_name'", "]", ")", ")", "call_user_func", "(", "$", "handler", ",", "$", "_REQUEST", ")", ";", "}" ]
The entry point for a plugin. This should be called immediately in your bootstrap file.
[ "The", "entry", "point", "for", "a", "plugin", ".", "This", "should", "be", "called", "immediately", "in", "your", "bootstrap", "file", "." ]
a7ca0cf6b286a547a5c7de919cd4423520ed9f06
https://github.com/Gravitas-GM/PluginBase/blob/a7ca0cf6b286a547a5c7de919cd4423520ed9f06/src/Gravitas/PluginBase/PluginBase.php#L41-L46
train
Gravitas-GM/PluginBase
src/Gravitas/PluginBase/PluginBase.php
PluginBase.addResources
public function addResources() { if ($this->resourceChain === null) $this->resourceChain = new ResourceChain($this); return $this->resourceChain; }
php
public function addResources() { if ($this->resourceChain === null) $this->resourceChain = new ResourceChain($this); return $this->resourceChain; }
[ "public", "function", "addResources", "(", ")", "{", "if", "(", "$", "this", "->", "resourceChain", "===", "null", ")", "$", "this", "->", "resourceChain", "=", "new", "ResourceChain", "(", "$", "this", ")", ";", "return", "$", "this", "->", "resourceChain", ";", "}" ]
Returns a ResourceChain object that can be used to add stylesheets and scripts. Functionally, this is the same as calling `add*Script` and `add*Stylesheet` methods, except that it automatically registers all previously registered resources (added via the ResourceChain) as dependencies. @return ResourceChain
[ "Returns", "a", "ResourceChain", "object", "that", "can", "be", "used", "to", "add", "stylesheets", "and", "scripts", "." ]
a7ca0cf6b286a547a5c7de919cd4423520ed9f06
https://github.com/Gravitas-GM/PluginBase/blob/a7ca0cf6b286a547a5c7de919cd4423520ed9f06/src/Gravitas/PluginBase/PluginBase.php#L165-L170
train
johnkrovitch/Sam
Filter/Copy/CopyFilter.php
CopyFilter.run
public function run(array $sources, array $destinations) { $fileSystem = new Filesystem(); // must have the same sources and destinations number if (count($sources) !== count($destinations) && count($destinations) !== 1) { throw new Exception('Sources and destinations count mismatch'); } // if only one destination is specified for multiple sources, it should be a directory. We should create it if // it is not exists if (count($destinations) === 1 && !is_dir($destinations[0]) && count($sources) > 1) { $fileSystem->mkdir($destinations[0]); } $copiedFiles = []; // copy generated files to its destination foreach ($sources as $index => $source) { if (array_key_exists($index, $destinations)) { $destination = $destinations[$index]; } else { $destination = $destinations[0]; } if (is_dir($destination)) { $destination = $this->removeLastSlash($destination); if ($source instanceof \Symfony\Component\Finder\SplFileInfo && $source->getRelativePath()) { $destination .= '/'.$source->getRelativePath(); } $destination .= '/'.$source->getFilename(); } $this->addNotification('copying "'.$source.'" to "'.$destination.'"'); $fileSystem->copy($source->getRealPath(), $destination); $copiedFiles[] = $destination; } return $copiedFiles; }
php
public function run(array $sources, array $destinations) { $fileSystem = new Filesystem(); // must have the same sources and destinations number if (count($sources) !== count($destinations) && count($destinations) !== 1) { throw new Exception('Sources and destinations count mismatch'); } // if only one destination is specified for multiple sources, it should be a directory. We should create it if // it is not exists if (count($destinations) === 1 && !is_dir($destinations[0]) && count($sources) > 1) { $fileSystem->mkdir($destinations[0]); } $copiedFiles = []; // copy generated files to its destination foreach ($sources as $index => $source) { if (array_key_exists($index, $destinations)) { $destination = $destinations[$index]; } else { $destination = $destinations[0]; } if (is_dir($destination)) { $destination = $this->removeLastSlash($destination); if ($source instanceof \Symfony\Component\Finder\SplFileInfo && $source->getRelativePath()) { $destination .= '/'.$source->getRelativePath(); } $destination .= '/'.$source->getFilename(); } $this->addNotification('copying "'.$source.'" to "'.$destination.'"'); $fileSystem->copy($source->getRealPath(), $destination); $copiedFiles[] = $destination; } return $copiedFiles; }
[ "public", "function", "run", "(", "array", "$", "sources", ",", "array", "$", "destinations", ")", "{", "$", "fileSystem", "=", "new", "Filesystem", "(", ")", ";", "// must have the same sources and destinations number", "if", "(", "count", "(", "$", "sources", ")", "!==", "count", "(", "$", "destinations", ")", "&&", "count", "(", "$", "destinations", ")", "!==", "1", ")", "{", "throw", "new", "Exception", "(", "'Sources and destinations count mismatch'", ")", ";", "}", "// if only one destination is specified for multiple sources, it should be a directory. We should create it if", "// it is not exists", "if", "(", "count", "(", "$", "destinations", ")", "===", "1", "&&", "!", "is_dir", "(", "$", "destinations", "[", "0", "]", ")", "&&", "count", "(", "$", "sources", ")", ">", "1", ")", "{", "$", "fileSystem", "->", "mkdir", "(", "$", "destinations", "[", "0", "]", ")", ";", "}", "$", "copiedFiles", "=", "[", "]", ";", "// copy generated files to its destination", "foreach", "(", "$", "sources", "as", "$", "index", "=>", "$", "source", ")", "{", "if", "(", "array_key_exists", "(", "$", "index", ",", "$", "destinations", ")", ")", "{", "$", "destination", "=", "$", "destinations", "[", "$", "index", "]", ";", "}", "else", "{", "$", "destination", "=", "$", "destinations", "[", "0", "]", ";", "}", "if", "(", "is_dir", "(", "$", "destination", ")", ")", "{", "$", "destination", "=", "$", "this", "->", "removeLastSlash", "(", "$", "destination", ")", ";", "if", "(", "$", "source", "instanceof", "\\", "Symfony", "\\", "Component", "\\", "Finder", "\\", "SplFileInfo", "&&", "$", "source", "->", "getRelativePath", "(", ")", ")", "{", "$", "destination", ".=", "'/'", ".", "$", "source", "->", "getRelativePath", "(", ")", ";", "}", "$", "destination", ".=", "'/'", ".", "$", "source", "->", "getFilename", "(", ")", ";", "}", "$", "this", "->", "addNotification", "(", "'copying \"'", ".", "$", "source", ".", "'\" to \"'", ".", "$", "destination", ".", "'\"'", ")", ";", "$", "fileSystem", "->", "copy", "(", "$", "source", "->", "getRealPath", "(", ")", ",", "$", "destination", ")", ";", "$", "copiedFiles", "[", "]", "=", "$", "destination", ";", "}", "return", "$", "copiedFiles", ";", "}" ]
Copy the sources files to the destinations. @param SplFileInfo[] $sources @param string[] $destinations @return SplFileInfo[] @throws Exception
[ "Copy", "the", "sources", "files", "to", "the", "destinations", "." ]
fbd3770c11eecc0a6d8070f439f149062316f606
https://github.com/johnkrovitch/Sam/blob/fbd3770c11eecc0a6d8070f439f149062316f606/Filter/Copy/CopyFilter.php#L22-L62
train
valu-digital/valusetup
src/ValuSetup/Setup/SetupUtils.php
SetupUtils.install
public function install($module, $version, $options = null) { $module = strtolower($module); $options = is_null($options) ? array() : $options; $modules = $this->findModules(); $current = array(); foreach($modules as $name){ $modVersion = $this->getModuleVersion($name); if ($modVersion) { $current[$name] = new SoftwareVersion( $this->getModuleVersion($name)); } } // Resolve deps $deps = $this->resolveDependencies( $module ); if (!$deps->offsetExists($module)) { $deps->offsetSet($module, $version); } $queue = new PriorityQueue(); // Setup all dependencies foreach($deps as $depModule => $depVersion){ if(!$this->hasSetupService($depModule)){ continue; } $setup = $this->initSetupService($depModule); $queue->insert(['service' => $setup, 'module' => $depModule], $setup->getPriority()); } foreach ($queue->getIterator() as $datum) { $service = $datum['service']; $depModule = $datum['module']; $operation = 'setup'; $args = array(); if ($depModule == $module) { $args['options'] = $options; } // complete existing installation $service->exec( $operation, $args ); } return true; }
php
public function install($module, $version, $options = null) { $module = strtolower($module); $options = is_null($options) ? array() : $options; $modules = $this->findModules(); $current = array(); foreach($modules as $name){ $modVersion = $this->getModuleVersion($name); if ($modVersion) { $current[$name] = new SoftwareVersion( $this->getModuleVersion($name)); } } // Resolve deps $deps = $this->resolveDependencies( $module ); if (!$deps->offsetExists($module)) { $deps->offsetSet($module, $version); } $queue = new PriorityQueue(); // Setup all dependencies foreach($deps as $depModule => $depVersion){ if(!$this->hasSetupService($depModule)){ continue; } $setup = $this->initSetupService($depModule); $queue->insert(['service' => $setup, 'module' => $depModule], $setup->getPriority()); } foreach ($queue->getIterator() as $datum) { $service = $datum['service']; $depModule = $datum['module']; $operation = 'setup'; $args = array(); if ($depModule == $module) { $args['options'] = $options; } // complete existing installation $service->exec( $operation, $args ); } return true; }
[ "public", "function", "install", "(", "$", "module", ",", "$", "version", ",", "$", "options", "=", "null", ")", "{", "$", "module", "=", "strtolower", "(", "$", "module", ")", ";", "$", "options", "=", "is_null", "(", "$", "options", ")", "?", "array", "(", ")", ":", "$", "options", ";", "$", "modules", "=", "$", "this", "->", "findModules", "(", ")", ";", "$", "current", "=", "array", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "name", ")", "{", "$", "modVersion", "=", "$", "this", "->", "getModuleVersion", "(", "$", "name", ")", ";", "if", "(", "$", "modVersion", ")", "{", "$", "current", "[", "$", "name", "]", "=", "new", "SoftwareVersion", "(", "$", "this", "->", "getModuleVersion", "(", "$", "name", ")", ")", ";", "}", "}", "// Resolve deps", "$", "deps", "=", "$", "this", "->", "resolveDependencies", "(", "$", "module", ")", ";", "if", "(", "!", "$", "deps", "->", "offsetExists", "(", "$", "module", ")", ")", "{", "$", "deps", "->", "offsetSet", "(", "$", "module", ",", "$", "version", ")", ";", "}", "$", "queue", "=", "new", "PriorityQueue", "(", ")", ";", "// Setup all dependencies", "foreach", "(", "$", "deps", "as", "$", "depModule", "=>", "$", "depVersion", ")", "{", "if", "(", "!", "$", "this", "->", "hasSetupService", "(", "$", "depModule", ")", ")", "{", "continue", ";", "}", "$", "setup", "=", "$", "this", "->", "initSetupService", "(", "$", "depModule", ")", ";", "$", "queue", "->", "insert", "(", "[", "'service'", "=>", "$", "setup", ",", "'module'", "=>", "$", "depModule", "]", ",", "$", "setup", "->", "getPriority", "(", ")", ")", ";", "}", "foreach", "(", "$", "queue", "->", "getIterator", "(", ")", "as", "$", "datum", ")", "{", "$", "service", "=", "$", "datum", "[", "'service'", "]", ";", "$", "depModule", "=", "$", "datum", "[", "'module'", "]", ";", "$", "operation", "=", "'setup'", ";", "$", "args", "=", "array", "(", ")", ";", "if", "(", "$", "depModule", "==", "$", "module", ")", "{", "$", "args", "[", "'options'", "]", "=", "$", "options", ";", "}", "// complete existing installation", "$", "service", "->", "exec", "(", "$", "operation", ",", "$", "args", ")", ";", "}", "return", "true", ";", "}" ]
Install module dependencies @return void
[ "Install", "module", "dependencies" ]
db1a0bfe1262d555eb11cd0d99625b9ee43d6744
https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtils.php#L60-L116
train
valu-digital/valusetup
src/ValuSetup/Setup/SetupUtils.php
SetupUtils.resolveDependencies
public function resolveDependencies($module){ $version = $this->getModuleVersion($module); if(null === $version){ throw new \Exception(sprintf( "Unable to resolve dependencies for module '%s'. Module definitions are missing or incomplete.", $module )); } $resolved = new \ArrayObject(); $this->resolveDepsRecursive($module, $version, $resolved); // Remove dependency to module itself if resolved version // is less than or equal to current version. if($resolved->offsetExists($module) && SoftwareVersion::compare($resolved[$module], $version) <= 0){ unset($resolved[$module]); } return $resolved; }
php
public function resolveDependencies($module){ $version = $this->getModuleVersion($module); if(null === $version){ throw new \Exception(sprintf( "Unable to resolve dependencies for module '%s'. Module definitions are missing or incomplete.", $module )); } $resolved = new \ArrayObject(); $this->resolveDepsRecursive($module, $version, $resolved); // Remove dependency to module itself if resolved version // is less than or equal to current version. if($resolved->offsetExists($module) && SoftwareVersion::compare($resolved[$module], $version) <= 0){ unset($resolved[$module]); } return $resolved; }
[ "public", "function", "resolveDependencies", "(", "$", "module", ")", "{", "$", "version", "=", "$", "this", "->", "getModuleVersion", "(", "$", "module", ")", ";", "if", "(", "null", "===", "$", "version", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "\"Unable to resolve dependencies for module '%s'. Module definitions are missing or incomplete.\"", ",", "$", "module", ")", ")", ";", "}", "$", "resolved", "=", "new", "\\", "ArrayObject", "(", ")", ";", "$", "this", "->", "resolveDepsRecursive", "(", "$", "module", ",", "$", "version", ",", "$", "resolved", ")", ";", "// Remove dependency to module itself if resolved version ", "// is less than or equal to current version.", "if", "(", "$", "resolved", "->", "offsetExists", "(", "$", "module", ")", "&&", "SoftwareVersion", "::", "compare", "(", "$", "resolved", "[", "$", "module", "]", ",", "$", "version", ")", "<=", "0", ")", "{", "unset", "(", "$", "resolved", "[", "$", "module", "]", ")", ";", "}", "return", "$", "resolved", ";", "}" ]
Resolve module dependencies, recursively This method returns an array with dependent module names as keys and versions as values. There may also be a dependency back to module itself with greater version number. Example of dependency tree: - A 1.0 - C 1.0 - A 1.1 - D 2.0 - E 1.0 - B 1.0 - B 1.1 Resolved dependencies: A : 1.1 C : 1.0 E : 1.0 B : 1.1 D : 2.0 @param string $module @throws \Exception @return ArrayObject
[ "Resolve", "module", "dependencies", "recursively" ]
db1a0bfe1262d555eb11cd0d99625b9ee43d6744
https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtils.php#L216-L237
train
valu-digital/valusetup
src/ValuSetup/Setup/SetupUtils.php
SetupUtils.resolveDepsRecursive
protected function resolveDepsRecursive($module, $version, \ArrayObject $resolved){ $module = strtolower($module); // replace if exists with lower version number if($resolved->offsetExists($module)){ $new = new SoftwareVersion($version); // remember the greatest versions if($new->isGt($resolved[$module])){ unset($resolved[$module]); $resolved[$module] = $version; } } else{ $resolved[$module] = $version; } // ask for deps $deps = $this->getModuleDeps($module); if (array_key_exists($module, $deps)) { throw new \Exception( sprintf('Invalid dependency for module %s: dependency cannot point to self', $module)); } foreach ($deps as $name => $depVersion){ // make sure the same module doesn't get resolved again if(!$resolved->offsetExists($name)){ $this->resolveDepsRecursive($name, $depVersion, $resolved); } } if ($resolved[$module] == $version) { unset($resolved[$module]); $resolved[$module] = $version; } }
php
protected function resolveDepsRecursive($module, $version, \ArrayObject $resolved){ $module = strtolower($module); // replace if exists with lower version number if($resolved->offsetExists($module)){ $new = new SoftwareVersion($version); // remember the greatest versions if($new->isGt($resolved[$module])){ unset($resolved[$module]); $resolved[$module] = $version; } } else{ $resolved[$module] = $version; } // ask for deps $deps = $this->getModuleDeps($module); if (array_key_exists($module, $deps)) { throw new \Exception( sprintf('Invalid dependency for module %s: dependency cannot point to self', $module)); } foreach ($deps as $name => $depVersion){ // make sure the same module doesn't get resolved again if(!$resolved->offsetExists($name)){ $this->resolveDepsRecursive($name, $depVersion, $resolved); } } if ($resolved[$module] == $version) { unset($resolved[$module]); $resolved[$module] = $version; } }
[ "protected", "function", "resolveDepsRecursive", "(", "$", "module", ",", "$", "version", ",", "\\", "ArrayObject", "$", "resolved", ")", "{", "$", "module", "=", "strtolower", "(", "$", "module", ")", ";", "// replace if exists with lower version number", "if", "(", "$", "resolved", "->", "offsetExists", "(", "$", "module", ")", ")", "{", "$", "new", "=", "new", "SoftwareVersion", "(", "$", "version", ")", ";", "// remember the greatest versions", "if", "(", "$", "new", "->", "isGt", "(", "$", "resolved", "[", "$", "module", "]", ")", ")", "{", "unset", "(", "$", "resolved", "[", "$", "module", "]", ")", ";", "$", "resolved", "[", "$", "module", "]", "=", "$", "version", ";", "}", "}", "else", "{", "$", "resolved", "[", "$", "module", "]", "=", "$", "version", ";", "}", "// ask for deps", "$", "deps", "=", "$", "this", "->", "getModuleDeps", "(", "$", "module", ")", ";", "if", "(", "array_key_exists", "(", "$", "module", ",", "$", "deps", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Invalid dependency for module %s: dependency cannot point to self'", ",", "$", "module", ")", ")", ";", "}", "foreach", "(", "$", "deps", "as", "$", "name", "=>", "$", "depVersion", ")", "{", "// make sure the same module doesn't get resolved again\r", "if", "(", "!", "$", "resolved", "->", "offsetExists", "(", "$", "name", ")", ")", "{", "$", "this", "->", "resolveDepsRecursive", "(", "$", "name", ",", "$", "depVersion", ",", "$", "resolved", ")", ";", "}", "}", "if", "(", "$", "resolved", "[", "$", "module", "]", "==", "$", "version", ")", "{", "unset", "(", "$", "resolved", "[", "$", "module", "]", ")", ";", "$", "resolved", "[", "$", "module", "]", "=", "$", "version", ";", "}", "}" ]
Resolve dependencies recursively. The level and order in module dependency hierarchy defines the module's priority. @param string $module @param string $version @param \ArrayObject $resolved
[ "Resolve", "dependencies", "recursively", ".", "The", "level", "and", "order", "in", "module", "dependency", "hierarchy", "defines", "the", "module", "s", "priority", "." ]
db1a0bfe1262d555eb11cd0d99625b9ee43d6744
https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtils.php#L247-L284
train
valu-digital/valusetup
src/ValuSetup/Setup/SetupUtils.php
SetupUtils.findModules
public function findModules() { $dirs = $this->getOption('module_dirs'); $modules = array(); foreach($dirs as $dir){ $iterator = new DirectoryIterator($dir); foreach ($iterator as $file) { if (($file->isDir() && substr($file->getBasename(), 0, 1) !== '.') || ($file->isFile() && $file->getExtension() == 'phar')) { $modules[$file->getRealPath()] = strtolower($file->getBasename()); } } } return $modules; }
php
public function findModules() { $dirs = $this->getOption('module_dirs'); $modules = array(); foreach($dirs as $dir){ $iterator = new DirectoryIterator($dir); foreach ($iterator as $file) { if (($file->isDir() && substr($file->getBasename(), 0, 1) !== '.') || ($file->isFile() && $file->getExtension() == 'phar')) { $modules[$file->getRealPath()] = strtolower($file->getBasename()); } } } return $modules; }
[ "public", "function", "findModules", "(", ")", "{", "$", "dirs", "=", "$", "this", "->", "getOption", "(", "'module_dirs'", ")", ";", "$", "modules", "=", "array", "(", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "$", "iterator", "=", "new", "DirectoryIterator", "(", "$", "dir", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "file", ")", "{", "if", "(", "(", "$", "file", "->", "isDir", "(", ")", "&&", "substr", "(", "$", "file", "->", "getBasename", "(", ")", ",", "0", ",", "1", ")", "!==", "'.'", ")", "||", "(", "$", "file", "->", "isFile", "(", ")", "&&", "$", "file", "->", "getExtension", "(", ")", "==", "'phar'", ")", ")", "{", "$", "modules", "[", "$", "file", "->", "getRealPath", "(", ")", "]", "=", "strtolower", "(", "$", "file", "->", "getBasename", "(", ")", ")", ";", "}", "}", "}", "return", "$", "modules", ";", "}" ]
Find all modules installed in module directories @return array
[ "Find", "all", "modules", "installed", "in", "module", "directories" ]
db1a0bfe1262d555eb11cd0d99625b9ee43d6744
https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtils.php#L304-L322
train
valu-digital/valusetup
src/ValuSetup/Setup/SetupUtils.php
SetupUtils.whichModule
public function whichModule($object){ $reflection = new \ReflectionClass($object); $ns = explode('\\', $reflection->getNamespaceName()); if (class_exists($ns[0] . '\Module')) { $reflection = new \ReflectionClass($ns[0] . '\Module'); return strtolower(basename(dirname($reflection->getFileName()))); } else { $path = $reflection->getFileName(); $dirs = $this->getOption('module_dirs'); foreach($dirs as $dir){ $dir = realpath($dir); if(strpos($path, $dir) === 0){ $dir = substr($path, strlen($dir)); $dir = ltrim($dir, DIRECTORY_SEPARATOR); $a = explode(DIRECTORY_SEPARATOR, $dir); return strtolower($a[0]); } } } return null; }
php
public function whichModule($object){ $reflection = new \ReflectionClass($object); $ns = explode('\\', $reflection->getNamespaceName()); if (class_exists($ns[0] . '\Module')) { $reflection = new \ReflectionClass($ns[0] . '\Module'); return strtolower(basename(dirname($reflection->getFileName()))); } else { $path = $reflection->getFileName(); $dirs = $this->getOption('module_dirs'); foreach($dirs as $dir){ $dir = realpath($dir); if(strpos($path, $dir) === 0){ $dir = substr($path, strlen($dir)); $dir = ltrim($dir, DIRECTORY_SEPARATOR); $a = explode(DIRECTORY_SEPARATOR, $dir); return strtolower($a[0]); } } } return null; }
[ "public", "function", "whichModule", "(", "$", "object", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ";", "$", "ns", "=", "explode", "(", "'\\\\'", ",", "$", "reflection", "->", "getNamespaceName", "(", ")", ")", ";", "if", "(", "class_exists", "(", "$", "ns", "[", "0", "]", ".", "'\\Module'", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "ns", "[", "0", "]", ".", "'\\Module'", ")", ";", "return", "strtolower", "(", "basename", "(", "dirname", "(", "$", "reflection", "->", "getFileName", "(", ")", ")", ")", ")", ";", "}", "else", "{", "$", "path", "=", "$", "reflection", "->", "getFileName", "(", ")", ";", "$", "dirs", "=", "$", "this", "->", "getOption", "(", "'module_dirs'", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "$", "dir", "=", "realpath", "(", "$", "dir", ")", ";", "if", "(", "strpos", "(", "$", "path", ",", "$", "dir", ")", "===", "0", ")", "{", "$", "dir", "=", "substr", "(", "$", "path", ",", "strlen", "(", "$", "dir", ")", ")", ";", "$", "dir", "=", "ltrim", "(", "$", "dir", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "a", "=", "explode", "(", "DIRECTORY_SEPARATOR", ",", "$", "dir", ")", ";", "return", "strtolower", "(", "$", "a", "[", "0", "]", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Detect the name of the module based on class @param object $object Setup instance @return string|null Module name
[ "Detect", "the", "name", "of", "the", "module", "based", "on", "class" ]
db1a0bfe1262d555eb11cd0d99625b9ee43d6744
https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtils.php#L353-L378
train
valu-digital/valusetup
src/ValuSetup/Setup/SetupUtils.php
SetupUtils.getModuleVersion
public function getModuleVersion($module) { $config = $this->getModuleDefinition($module); if (isset($config['version'])) { return $config['version']; } else { return SoftwareVersion::DEFAULT_UNRESOLVED_VERSION; } }
php
public function getModuleVersion($module) { $config = $this->getModuleDefinition($module); if (isset($config['version'])) { return $config['version']; } else { return SoftwareVersion::DEFAULT_UNRESOLVED_VERSION; } }
[ "public", "function", "getModuleVersion", "(", "$", "module", ")", "{", "$", "config", "=", "$", "this", "->", "getModuleDefinition", "(", "$", "module", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'version'", "]", ")", ")", "{", "return", "$", "config", "[", "'version'", "]", ";", "}", "else", "{", "return", "SoftwareVersion", "::", "DEFAULT_UNRESOLVED_VERSION", ";", "}", "}" ]
Get current version for module @param string pathule @return string|null
[ "Get", "current", "version", "for", "module" ]
db1a0bfe1262d555eb11cd0d99625b9ee43d6744
https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtils.php#L386-L395
train
valu-digital/valusetup
src/ValuSetup/Setup/SetupUtils.php
SetupUtils.getModuleDefinition
public function getModuleDefinition($module) { $module = strtolower($module); if (!array_key_exists($module, $this->definitions)) { $path = $this->locateModule($module); $config = array(); if($path){ $definition = $path . DIRECTORY_SEPARATOR . $this->getOption('definition_file'); /** * Read version from definition file (e.g. definition.ini) * from either module directory or PHAR archive */ if(is_dir($path) && file_exists($definition)){ $config = \Zend\Config\Factory::fromFile($definition); } else if(is_file($path) && file_exists('phar://'.$definition)){ $config = \Zend\Config\Factory::fromFile('phar://'.$definition); } } $this->definitions[$module] = $config; } return $this->definitions[$module]; }
php
public function getModuleDefinition($module) { $module = strtolower($module); if (!array_key_exists($module, $this->definitions)) { $path = $this->locateModule($module); $config = array(); if($path){ $definition = $path . DIRECTORY_SEPARATOR . $this->getOption('definition_file'); /** * Read version from definition file (e.g. definition.ini) * from either module directory or PHAR archive */ if(is_dir($path) && file_exists($definition)){ $config = \Zend\Config\Factory::fromFile($definition); } else if(is_file($path) && file_exists('phar://'.$definition)){ $config = \Zend\Config\Factory::fromFile('phar://'.$definition); } } $this->definitions[$module] = $config; } return $this->definitions[$module]; }
[ "public", "function", "getModuleDefinition", "(", "$", "module", ")", "{", "$", "module", "=", "strtolower", "(", "$", "module", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "module", ",", "$", "this", "->", "definitions", ")", ")", "{", "$", "path", "=", "$", "this", "->", "locateModule", "(", "$", "module", ")", ";", "$", "config", "=", "array", "(", ")", ";", "if", "(", "$", "path", ")", "{", "$", "definition", "=", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "getOption", "(", "'definition_file'", ")", ";", "/**\n * Read version from definition file (e.g. definition.ini)\n * from either module directory or PHAR archive\n */", "if", "(", "is_dir", "(", "$", "path", ")", "&&", "file_exists", "(", "$", "definition", ")", ")", "{", "$", "config", "=", "\\", "Zend", "\\", "Config", "\\", "Factory", "::", "fromFile", "(", "$", "definition", ")", ";", "}", "else", "if", "(", "is_file", "(", "$", "path", ")", "&&", "file_exists", "(", "'phar://'", ".", "$", "definition", ")", ")", "{", "$", "config", "=", "\\", "Zend", "\\", "Config", "\\", "Factory", "::", "fromFile", "(", "'phar://'", ".", "$", "definition", ")", ";", "}", "}", "$", "this", "->", "definitions", "[", "$", "module", "]", "=", "$", "config", ";", "}", "return", "$", "this", "->", "definitions", "[", "$", "module", "]", ";", "}" ]
Get module definition as an array @param string $module @return array
[ "Get", "module", "definition", "as", "an", "array" ]
db1a0bfe1262d555eb11cd0d99625b9ee43d6744
https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtils.php#L403-L430
train
valu-digital/valusetup
src/ValuSetup/Setup/SetupUtils.php
SetupUtils.getModuleDeps
public function getModuleDeps($module) { $module = strtolower($module); if (!isset($this->deps[$module])) { $map = array(); $deps = array(); $modules = $this->findModules(); foreach ($modules as $name) { $config = $this->getModuleDefinition($name); $map[$name] = isset($config['name']) ? $config['name'] : null; } $config = $this->getModuleDefinition($module); foreach (['require', 'require-dev'] as $key) { if (isset($config[$key])) { foreach ($config[$key] as $composerName => $composerVersion) { $moduleName = array_search($composerName, $map); if ($moduleName !== false) { $deps[$moduleName] = ltrim($composerVersion, '<>='); } } } } $this->deps[$module] = $deps; } return $this->deps[$module]; }
php
public function getModuleDeps($module) { $module = strtolower($module); if (!isset($this->deps[$module])) { $map = array(); $deps = array(); $modules = $this->findModules(); foreach ($modules as $name) { $config = $this->getModuleDefinition($name); $map[$name] = isset($config['name']) ? $config['name'] : null; } $config = $this->getModuleDefinition($module); foreach (['require', 'require-dev'] as $key) { if (isset($config[$key])) { foreach ($config[$key] as $composerName => $composerVersion) { $moduleName = array_search($composerName, $map); if ($moduleName !== false) { $deps[$moduleName] = ltrim($composerVersion, '<>='); } } } } $this->deps[$module] = $deps; } return $this->deps[$module]; }
[ "public", "function", "getModuleDeps", "(", "$", "module", ")", "{", "$", "module", "=", "strtolower", "(", "$", "module", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "deps", "[", "$", "module", "]", ")", ")", "{", "$", "map", "=", "array", "(", ")", ";", "$", "deps", "=", "array", "(", ")", ";", "$", "modules", "=", "$", "this", "->", "findModules", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "name", ")", "{", "$", "config", "=", "$", "this", "->", "getModuleDefinition", "(", "$", "name", ")", ";", "$", "map", "[", "$", "name", "]", "=", "isset", "(", "$", "config", "[", "'name'", "]", ")", "?", "$", "config", "[", "'name'", "]", ":", "null", ";", "}", "$", "config", "=", "$", "this", "->", "getModuleDefinition", "(", "$", "module", ")", ";", "foreach", "(", "[", "'require'", ",", "'require-dev'", "]", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "$", "key", "]", ")", ")", "{", "foreach", "(", "$", "config", "[", "$", "key", "]", "as", "$", "composerName", "=>", "$", "composerVersion", ")", "{", "$", "moduleName", "=", "array_search", "(", "$", "composerName", ",", "$", "map", ")", ";", "if", "(", "$", "moduleName", "!==", "false", ")", "{", "$", "deps", "[", "$", "moduleName", "]", "=", "ltrim", "(", "$", "composerVersion", ",", "'<>='", ")", ";", "}", "}", "}", "}", "$", "this", "->", "deps", "[", "$", "module", "]", "=", "$", "deps", ";", "}", "return", "$", "this", "->", "deps", "[", "$", "module", "]", ";", "}" ]
Retrieve list of module dependencies @param string $module @return array
[ "Retrieve", "list", "of", "module", "dependencies" ]
db1a0bfe1262d555eb11cd0d99625b9ee43d6744
https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtils.php#L438-L470
train
valu-digital/valusetup
src/ValuSetup/Setup/SetupUtils.php
SetupUtils.setConfig
public function setConfig($config) { if(is_string($config) && file_exists($config)){ $options = \Zend\Config\Factory::fromFile($config); $this->setOptions($options); } elseif(!is_array($config) && !($config instanceof \Traversable)){ throw new \InvalidArgumentException('Invalid parameter $config or config file not found'); } $this->options = new SetupUtilsOptions($config); return $this; }
php
public function setConfig($config) { if(is_string($config) && file_exists($config)){ $options = \Zend\Config\Factory::fromFile($config); $this->setOptions($options); } elseif(!is_array($config) && !($config instanceof \Traversable)){ throw new \InvalidArgumentException('Invalid parameter $config or config file not found'); } $this->options = new SetupUtilsOptions($config); return $this; }
[ "public", "function", "setConfig", "(", "$", "config", ")", "{", "if", "(", "is_string", "(", "$", "config", ")", "&&", "file_exists", "(", "$", "config", ")", ")", "{", "$", "options", "=", "\\", "Zend", "\\", "Config", "\\", "Factory", "::", "fromFile", "(", "$", "config", ")", ";", "$", "this", "->", "setOptions", "(", "$", "options", ")", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "config", ")", "&&", "!", "(", "$", "config", "instanceof", "\\", "Traversable", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid parameter $config or config file not found'", ")", ";", "}", "$", "this", "->", "options", "=", "new", "SetupUtilsOptions", "(", "$", "config", ")", ";", "return", "$", "this", ";", "}" ]
Set service options @param array|Traversable|string $config @return Service
[ "Set", "service", "options" ]
db1a0bfe1262d555eb11cd0d99625b9ee43d6744
https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtils.php#L520-L532
train
Vectrex/vxPHP
src/Application/Application.php
Application.getInstance
public static function getInstance(Config $config = null) { if(is_null(self::$instance)) { if(is_null($config)) { throw new ApplicationException('No configuration object provided. Cannot instantiate application.'); } self::$instance = new Application($config); } return self::$instance; }
php
public static function getInstance(Config $config = null) { if(is_null(self::$instance)) { if(is_null($config)) { throw new ApplicationException('No configuration object provided. Cannot instantiate application.'); } self::$instance = new Application($config); } return self::$instance; }
[ "public", "static", "function", "getInstance", "(", "Config", "$", "config", "=", "null", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "instance", ")", ")", "{", "if", "(", "is_null", "(", "$", "config", ")", ")", "{", "throw", "new", "ApplicationException", "(", "'No configuration object provided. Cannot instantiate application.'", ")", ";", "}", "self", "::", "$", "instance", "=", "new", "Application", "(", "$", "config", ")", ";", "}", "return", "self", "::", "$", "instance", ";", "}" ]
Get Application instance. @param Config $config @return Application @throws ApplicationException
[ "Get", "Application", "instance", "." ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L232-L243
train
Vectrex/vxPHP
src/Application/Application.php
Application.registerPlugins
public function registerPlugins() { if($this->plugins) { foreach($this->plugins as $plugin) { $this->eventDispatcher->removeSubscriber($plugin); } } $this->plugins = array(); // initialize plugins (if configured) if($this->config->plugins) { foreach(array_keys($this->config->plugins) as $pluginId) { $this->plugins[] = $this->initializePlugin($pluginId); } } return $this; }
php
public function registerPlugins() { if($this->plugins) { foreach($this->plugins as $plugin) { $this->eventDispatcher->removeSubscriber($plugin); } } $this->plugins = array(); // initialize plugins (if configured) if($this->config->plugins) { foreach(array_keys($this->config->plugins) as $pluginId) { $this->plugins[] = $this->initializePlugin($pluginId); } } return $this; }
[ "public", "function", "registerPlugins", "(", ")", "{", "if", "(", "$", "this", "->", "plugins", ")", "{", "foreach", "(", "$", "this", "->", "plugins", "as", "$", "plugin", ")", "{", "$", "this", "->", "eventDispatcher", "->", "removeSubscriber", "(", "$", "plugin", ")", ";", "}", "}", "$", "this", "->", "plugins", "=", "array", "(", ")", ";", "// initialize plugins (if configured)", "if", "(", "$", "this", "->", "config", "->", "plugins", ")", "{", "foreach", "(", "array_keys", "(", "$", "this", "->", "config", "->", "plugins", ")", "as", "$", "pluginId", ")", "{", "$", "this", "->", "plugins", "[", "]", "=", "$", "this", "->", "initializePlugin", "(", "$", "pluginId", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Unregister all previously registered plugins. read plugin configuration from Config and register all configured plugins @return Application @throws ApplicationException
[ "Unregister", "all", "previously", "registered", "plugins", "." ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L266-L288
train
Vectrex/vxPHP
src/Application/Application.php
Application.getDb
public function getDb() { if(empty($this->db)) { if(empty($this->config->db)) { try { return $this->getVxPDO(); } catch(ApplicationException $e) { return null; } } $config = $this->config->db; $this->db = DatabaseInterfaceFactory::create( isset($config->type) ? $config->type : 'mysql', [ 'host' => $config->host, 'dbname' => $config->name, 'user' => $config->user, 'password' => $config->pass, ] ); } return $this->db; }
php
public function getDb() { if(empty($this->db)) { if(empty($this->config->db)) { try { return $this->getVxPDO(); } catch(ApplicationException $e) { return null; } } $config = $this->config->db; $this->db = DatabaseInterfaceFactory::create( isset($config->type) ? $config->type : 'mysql', [ 'host' => $config->host, 'dbname' => $config->name, 'user' => $config->user, 'password' => $config->pass, ] ); } return $this->db; }
[ "public", "function", "getDb", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "db", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "config", "->", "db", ")", ")", "{", "try", "{", "return", "$", "this", "->", "getVxPDO", "(", ")", ";", "}", "catch", "(", "ApplicationException", "$", "e", ")", "{", "return", "null", ";", "}", "}", "$", "config", "=", "$", "this", "->", "config", "->", "db", ";", "$", "this", "->", "db", "=", "DatabaseInterfaceFactory", "::", "create", "(", "isset", "(", "$", "config", "->", "type", ")", "?", "$", "config", "->", "type", ":", "'mysql'", ",", "[", "'host'", "=>", "$", "config", "->", "host", ",", "'dbname'", "=>", "$", "config", "->", "name", ",", "'user'", "=>", "$", "config", "->", "user", ",", "'password'", "=>", "$", "config", "->", "pass", ",", "]", ")", ";", "}", "return", "$", "this", "->", "db", ";", "}" ]
get default vxPDO instance this method exists for backwards compatibility if no 'db' configuration is found, it tries to return a configured default vxpdo datasource @return \vxPHP\Database\DatabaseInterface @throws \Exception
[ "get", "default", "vxPDO", "instance" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L300-L331
train
Vectrex/vxPHP
src/Application/Application.php
Application.getVxPDO
public function getVxPDO($name = 'default') { if(!array_key_exists($name, $this->vxPDOInstances)) { if(empty($this->config->vxpdo) || !array_key_exists($name, $this->config->vxpdo)) { throw new ApplicationException(sprintf("vxPDO configuration for '%s' not found.", $name)); } $dsConfig = $this->config->vxpdo[$name]; $this->vxPDOInstances[$name] = DatabaseInterfaceFactory::create( $dsConfig->driver, [ 'dsn' => $dsConfig->dsn, 'host' => $dsConfig->host, 'port' => $dsConfig->port, 'dbname' => $dsConfig->dbname, 'user' => $dsConfig->user, 'password' => $dsConfig->password, 'name' => $name ] ); } return $this->vxPDOInstances[$name]; }
php
public function getVxPDO($name = 'default') { if(!array_key_exists($name, $this->vxPDOInstances)) { if(empty($this->config->vxpdo) || !array_key_exists($name, $this->config->vxpdo)) { throw new ApplicationException(sprintf("vxPDO configuration for '%s' not found.", $name)); } $dsConfig = $this->config->vxpdo[$name]; $this->vxPDOInstances[$name] = DatabaseInterfaceFactory::create( $dsConfig->driver, [ 'dsn' => $dsConfig->dsn, 'host' => $dsConfig->host, 'port' => $dsConfig->port, 'dbname' => $dsConfig->dbname, 'user' => $dsConfig->user, 'password' => $dsConfig->password, 'name' => $name ] ); } return $this->vxPDOInstances[$name]; }
[ "public", "function", "getVxPDO", "(", "$", "name", "=", "'default'", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "vxPDOInstances", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "config", "->", "vxpdo", ")", "||", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "config", "->", "vxpdo", ")", ")", "{", "throw", "new", "ApplicationException", "(", "sprintf", "(", "\"vxPDO configuration for '%s' not found.\"", ",", "$", "name", ")", ")", ";", "}", "$", "dsConfig", "=", "$", "this", "->", "config", "->", "vxpdo", "[", "$", "name", "]", ";", "$", "this", "->", "vxPDOInstances", "[", "$", "name", "]", "=", "DatabaseInterfaceFactory", "::", "create", "(", "$", "dsConfig", "->", "driver", ",", "[", "'dsn'", "=>", "$", "dsConfig", "->", "dsn", ",", "'host'", "=>", "$", "dsConfig", "->", "host", ",", "'port'", "=>", "$", "dsConfig", "->", "port", ",", "'dbname'", "=>", "$", "dsConfig", "->", "dbname", ",", "'user'", "=>", "$", "dsConfig", "->", "user", ",", "'password'", "=>", "$", "dsConfig", "->", "password", ",", "'name'", "=>", "$", "name", "]", ")", ";", "}", "return", "$", "this", "->", "vxPDOInstances", "[", "$", "name", "]", ";", "}" ]
get a configured vxPDO instance identified by its datasource name @param string $name @throws ApplicationException @return \vxPHP\Database\DatabaseInterface
[ "get", "a", "configured", "vxPDO", "instance", "identified", "by", "its", "datasource", "name" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L342-L368
train
Vectrex/vxPHP
src/Application/Application.php
Application.getService
public function getService($serviceId) { $args = func_get_args(); $service = $this->initializeService($serviceId, array_splice($args, 1)); $this->services[] = $service; return $service; }
php
public function getService($serviceId) { $args = func_get_args(); $service = $this->initializeService($serviceId, array_splice($args, 1)); $this->services[] = $service; return $service; }
[ "public", "function", "getService", "(", "$", "serviceId", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "service", "=", "$", "this", "->", "initializeService", "(", "$", "serviceId", ",", "array_splice", "(", "$", "args", ",", "1", ")", ")", ";", "$", "this", "->", "services", "[", "]", "=", "$", "service", ";", "return", "$", "service", ";", "}" ]
return a service instance service instances are lazily initialized upon first request any extra argument is passed on to the constructor method of the service @param string $serviceId @return ServiceInterface :ServiceInterface @throws ApplicationException
[ "return", "a", "service", "instance", "service", "instances", "are", "lazily", "initialized", "upon", "first", "request" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L391-L399
train
Vectrex/vxPHP
src/Application/Application.php
Application.hasService
public function hasService($serviceId) { return !empty($this->config->services) && array_key_exists($serviceId, $this->config->services); }
php
public function hasService($serviceId) { return !empty($this->config->services) && array_key_exists($serviceId, $this->config->services); }
[ "public", "function", "hasService", "(", "$", "serviceId", ")", "{", "return", "!", "empty", "(", "$", "this", "->", "config", "->", "services", ")", "&&", "array_key_exists", "(", "$", "serviceId", ",", "$", "this", "->", "config", "->", "services", ")", ";", "}" ]
checks whether a service identified by service id is configured no further checks whether service can be invoked are conducted @param $serviceId @return bool
[ "checks", "whether", "a", "service", "identified", "by", "service", "id", "is", "configured", "no", "further", "checks", "whether", "service", "can", "be", "invoked", "are", "conducted" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L408-L412
train
Vectrex/vxPHP
src/Application/Application.php
Application.runsLocally
public function runsLocally() { if(is_null($this->isLocal)) { $remote = isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !( in_array( @$_SERVER['REMOTE_ADDR'], [ '127.0.0.1', 'fe80::1', '::1' ] ) || PHP_SAPI === 'cli-server' ) ; $this->isLocal = PHP_SAPI === 'cli' || !$remote; } return $this->isLocal; }
php
public function runsLocally() { if(is_null($this->isLocal)) { $remote = isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !( in_array( @$_SERVER['REMOTE_ADDR'], [ '127.0.0.1', 'fe80::1', '::1' ] ) || PHP_SAPI === 'cli-server' ) ; $this->isLocal = PHP_SAPI === 'cli' || !$remote; } return $this->isLocal; }
[ "public", "function", "runsLocally", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "isLocal", ")", ")", "{", "$", "remote", "=", "isset", "(", "$", "_SERVER", "[", "'HTTP_CLIENT_IP'", "]", ")", "||", "isset", "(", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ")", "||", "!", "(", "in_array", "(", "@", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ",", "[", "'127.0.0.1'", ",", "'fe80::1'", ",", "'::1'", "]", ")", "||", "PHP_SAPI", "===", "'cli-server'", ")", ";", "$", "this", "->", "isLocal", "=", "PHP_SAPI", "===", "'cli'", "||", "!", "$", "remote", ";", "}", "return", "$", "this", "->", "isLocal", ";", "}" ]
returns true when the application was called from the command line or in a localhost environment @return boolean
[ "returns", "true", "when", "the", "application", "was", "called", "from", "the", "command", "line", "or", "in", "a", "localhost", "environment" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L442-L469
train
Vectrex/vxPHP
src/Application/Application.php
Application.getSourcePath
public function getSourcePath() { // lazy init if(is_null($this->sourcePath)) { $this->sourcePath = $this->rootPath . 'src' . DIRECTORY_SEPARATOR; } return $this->sourcePath; }
php
public function getSourcePath() { // lazy init if(is_null($this->sourcePath)) { $this->sourcePath = $this->rootPath . 'src' . DIRECTORY_SEPARATOR; } return $this->sourcePath; }
[ "public", "function", "getSourcePath", "(", ")", "{", "// lazy init", "if", "(", "is_null", "(", "$", "this", "->", "sourcePath", ")", ")", "{", "$", "this", "->", "sourcePath", "=", "$", "this", "->", "rootPath", ".", "'src'", ".", "DIRECTORY_SEPARATOR", ";", "}", "return", "$", "this", "->", "sourcePath", ";", "}" ]
get absolute path to application source @return string
[ "get", "absolute", "path", "to", "application", "source" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L476-L490
train
Vectrex/vxPHP
src/Application/Application.php
Application.setAbsoluteAssetsPath
public function setAbsoluteAssetsPath($path) { $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if(!is_null($this->rootPath) && 0 !== strpos($path, $this->rootPath)) { throw new ApplicationException(sprintf("'%s' not within application path '%s'.", $path, $this->rootPath), ApplicationException::PATH_MISMATCH); } $this->absoluteAssetsPath = $path; return $this; }
php
public function setAbsoluteAssetsPath($path) { $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if(!is_null($this->rootPath) && 0 !== strpos($path, $this->rootPath)) { throw new ApplicationException(sprintf("'%s' not within application path '%s'.", $path, $this->rootPath), ApplicationException::PATH_MISMATCH); } $this->absoluteAssetsPath = $path; return $this; }
[ "public", "function", "setAbsoluteAssetsPath", "(", "$", "path", ")", "{", "$", "path", "=", "rtrim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "rootPath", ")", "&&", "0", "!==", "strpos", "(", "$", "path", ",", "$", "this", "->", "rootPath", ")", ")", "{", "throw", "new", "ApplicationException", "(", "sprintf", "(", "\"'%s' not within application path '%s'.\"", ",", "$", "path", ",", "$", "this", "->", "rootPath", ")", ",", "ApplicationException", "::", "PATH_MISMATCH", ")", ";", "}", "$", "this", "->", "absoluteAssetsPath", "=", "$", "path", ";", "return", "$", "this", ";", "}" ]
set absolute assets path the relative assets path is updated @param string $path @return Application @throws ApplicationException
[ "set", "absolute", "assets", "path", "the", "relative", "assets", "path", "is", "updated" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L500-L512
train
Vectrex/vxPHP
src/Application/Application.php
Application.setRootPath
public function setRootPath($path) { $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if(!is_null($this->absoluteAssetsPath) && 0 !== strpos($this->absoluteAssetsPath, $path)) { throw new ApplicationException("'$path' not a parent of assets path '{$this->absoluteAssetsPath}'", ApplicationException::PATH_MISMATCH); } $this->rootPath = $path; $this->relativeAssetsPath = str_replace(DIRECTORY_SEPARATOR, '/', str_replace($this->rootPath, '', (string) $this->absoluteAssetsPath)); return $this; }
php
public function setRootPath($path) { $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if(!is_null($this->absoluteAssetsPath) && 0 !== strpos($this->absoluteAssetsPath, $path)) { throw new ApplicationException("'$path' not a parent of assets path '{$this->absoluteAssetsPath}'", ApplicationException::PATH_MISMATCH); } $this->rootPath = $path; $this->relativeAssetsPath = str_replace(DIRECTORY_SEPARATOR, '/', str_replace($this->rootPath, '', (string) $this->absoluteAssetsPath)); return $this; }
[ "public", "function", "setRootPath", "(", "$", "path", ")", "{", "$", "path", "=", "rtrim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "absoluteAssetsPath", ")", "&&", "0", "!==", "strpos", "(", "$", "this", "->", "absoluteAssetsPath", ",", "$", "path", ")", ")", "{", "throw", "new", "ApplicationException", "(", "\"'$path' not a parent of assets path '{$this->absoluteAssetsPath}'\"", ",", "ApplicationException", "::", "PATH_MISMATCH", ")", ";", "}", "$", "this", "->", "rootPath", "=", "$", "path", ";", "$", "this", "->", "relativeAssetsPath", "=", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "str_replace", "(", "$", "this", "->", "rootPath", ",", "''", ",", "(", "string", ")", "$", "this", "->", "absoluteAssetsPath", ")", ")", ";", "return", "$", "this", ";", "}" ]
set root path of application if an assetspath is set, the relative assets path is updated @param string $path @return Application @throws ApplicationException
[ "set", "root", "path", "of", "application", "if", "an", "assetspath", "is", "set", "the", "relative", "assets", "path", "is", "updated" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L578-L591
train
Vectrex/vxPHP
src/Application/Application.php
Application.getAvailableLocales
public function getAvailableLocales() { foreach($this->locales as $id => $l) { if(!$l) { $this->locales[$id] = new Locale($id); } } return $this->locales; }
php
public function getAvailableLocales() { foreach($this->locales as $id => $l) { if(!$l) { $this->locales[$id] = new Locale($id); } } return $this->locales; }
[ "public", "function", "getAvailableLocales", "(", ")", "{", "foreach", "(", "$", "this", "->", "locales", "as", "$", "id", "=>", "$", "l", ")", "{", "if", "(", "!", "$", "l", ")", "{", "$", "this", "->", "locales", "[", "$", "id", "]", "=", "new", "Locale", "(", "$", "id", ")", ";", "}", "}", "return", "$", "this", "->", "locales", ";", "}" ]
returns an array with available Locale instances because of lazy instantiation, missing instances are created now @return array
[ "returns", "an", "array", "with", "available", "Locale", "instances", "because", "of", "lazy", "instantiation", "missing", "instances", "are", "created", "now" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L689-L698
train
Vectrex/vxPHP
src/Application/Application.php
Application.initializeService
private function initializeService($serviceId, array $constructorArguments) { if(!isset($this->config->services[$serviceId])) { throw new ApplicationException(sprintf("Service '%s' not configured.", $serviceId)); } $configData = $this->config->services[$serviceId]; // get class name $class = $configData['class']; // create instance and pass additional parameters to constructor try { $service = new $class(...$constructorArguments); } catch(\Exception $e) { throw new ApplicationException(sprintf("Instancing of service '%s' failed. Error: %s", $serviceId, $e->getMessage())); } // check whether instance implements ServiceInterface if(!$service instanceof ServiceInterface) { throw new ApplicationException(sprintf("Service '%s' (class %s) does not implement the ServiceInterface.", $serviceId, $class)); } // set parameters $service->setParameters($configData['parameters']); return $service; }
php
private function initializeService($serviceId, array $constructorArguments) { if(!isset($this->config->services[$serviceId])) { throw new ApplicationException(sprintf("Service '%s' not configured.", $serviceId)); } $configData = $this->config->services[$serviceId]; // get class name $class = $configData['class']; // create instance and pass additional parameters to constructor try { $service = new $class(...$constructorArguments); } catch(\Exception $e) { throw new ApplicationException(sprintf("Instancing of service '%s' failed. Error: %s", $serviceId, $e->getMessage())); } // check whether instance implements ServiceInterface if(!$service instanceof ServiceInterface) { throw new ApplicationException(sprintf("Service '%s' (class %s) does not implement the ServiceInterface.", $serviceId, $class)); } // set parameters $service->setParameters($configData['parameters']); return $service; }
[ "private", "function", "initializeService", "(", "$", "serviceId", ",", "array", "$", "constructorArguments", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "->", "services", "[", "$", "serviceId", "]", ")", ")", "{", "throw", "new", "ApplicationException", "(", "sprintf", "(", "\"Service '%s' not configured.\"", ",", "$", "serviceId", ")", ")", ";", "}", "$", "configData", "=", "$", "this", "->", "config", "->", "services", "[", "$", "serviceId", "]", ";", "// get class name", "$", "class", "=", "$", "configData", "[", "'class'", "]", ";", "// create instance and pass additional parameters to constructor", "try", "{", "$", "service", "=", "new", "$", "class", "(", "...", "$", "constructorArguments", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "ApplicationException", "(", "sprintf", "(", "\"Instancing of service '%s' failed. Error: %s\"", ",", "$", "serviceId", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "// check whether instance implements ServiceInterface ", "if", "(", "!", "$", "service", "instanceof", "ServiceInterface", ")", "{", "throw", "new", "ApplicationException", "(", "sprintf", "(", "\"Service '%s' (class %s) does not implement the ServiceInterface.\"", ",", "$", "serviceId", ",", "$", "class", ")", ")", ";", "}", "// set parameters", "$", "service", "->", "setParameters", "(", "$", "configData", "[", "'parameters'", "]", ")", ";", "return", "$", "service", ";", "}" ]
create and initialize a service instance @param string $serviceId @param array $constructorArguments @throws ApplicationException @return ServiceInterface
[ "create", "and", "initialize", "a", "service", "instance" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L802-L835
train
Vectrex/vxPHP
src/Application/Application.php
Application.initializePlugin
private function initializePlugin($pluginId) { $configData = $this->config->plugins[$pluginId]; // load class file $class = str_replace('/', '\\', $configData['class']); $file = $this->rootPath . 'src/' . $configData['classPath'] . $class . '.php'; if(!file_exists($file)) { throw new ApplicationException(sprintf("Class file '%s' for plugin '%s' not found.", $file, $pluginId)); } require $file; // create instance $plugin = new $class; // check whether instance implements SubscriberInterface if(!$plugin instanceof SubscriberInterface) { throw new ApplicationException(sprintf("Plugin '%s' (class %s) does not implement the SubscriberInterface.", $pluginId, $class)); } // set parameters if(!empty($configData['parameters'])) { if(!method_exists($plugin, 'setParameters')) { throw new ApplicationException(sprintf("Plugin '%s' (class %s) does not provide a 'setParameters' method but has parameters configured.", $pluginId, $class)); } $plugin->setParameters($configData['parameters']); } // register plugin with dispatcher EventDispatcher::getInstance()->addSubscriber($plugin); return $plugin; }
php
private function initializePlugin($pluginId) { $configData = $this->config->plugins[$pluginId]; // load class file $class = str_replace('/', '\\', $configData['class']); $file = $this->rootPath . 'src/' . $configData['classPath'] . $class . '.php'; if(!file_exists($file)) { throw new ApplicationException(sprintf("Class file '%s' for plugin '%s' not found.", $file, $pluginId)); } require $file; // create instance $plugin = new $class; // check whether instance implements SubscriberInterface if(!$plugin instanceof SubscriberInterface) { throw new ApplicationException(sprintf("Plugin '%s' (class %s) does not implement the SubscriberInterface.", $pluginId, $class)); } // set parameters if(!empty($configData['parameters'])) { if(!method_exists($plugin, 'setParameters')) { throw new ApplicationException(sprintf("Plugin '%s' (class %s) does not provide a 'setParameters' method but has parameters configured.", $pluginId, $class)); } $plugin->setParameters($configData['parameters']); } // register plugin with dispatcher EventDispatcher::getInstance()->addSubscriber($plugin); return $plugin; }
[ "private", "function", "initializePlugin", "(", "$", "pluginId", ")", "{", "$", "configData", "=", "$", "this", "->", "config", "->", "plugins", "[", "$", "pluginId", "]", ";", "// load class file", "$", "class", "=", "str_replace", "(", "'/'", ",", "'\\\\'", ",", "$", "configData", "[", "'class'", "]", ")", ";", "$", "file", "=", "$", "this", "->", "rootPath", ".", "'src/'", ".", "$", "configData", "[", "'classPath'", "]", ".", "$", "class", ".", "'.php'", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "throw", "new", "ApplicationException", "(", "sprintf", "(", "\"Class file '%s' for plugin '%s' not found.\"", ",", "$", "file", ",", "$", "pluginId", ")", ")", ";", "}", "require", "$", "file", ";", "// create instance", "$", "plugin", "=", "new", "$", "class", ";", "// check whether instance implements SubscriberInterface", "if", "(", "!", "$", "plugin", "instanceof", "SubscriberInterface", ")", "{", "throw", "new", "ApplicationException", "(", "sprintf", "(", "\"Plugin '%s' (class %s) does not implement the SubscriberInterface.\"", ",", "$", "pluginId", ",", "$", "class", ")", ")", ";", "}", "// set parameters", "if", "(", "!", "empty", "(", "$", "configData", "[", "'parameters'", "]", ")", ")", "{", "if", "(", "!", "method_exists", "(", "$", "plugin", ",", "'setParameters'", ")", ")", "{", "throw", "new", "ApplicationException", "(", "sprintf", "(", "\"Plugin '%s' (class %s) does not provide a 'setParameters' method but has parameters configured.\"", ",", "$", "pluginId", ",", "$", "class", ")", ")", ";", "}", "$", "plugin", "->", "setParameters", "(", "$", "configData", "[", "'parameters'", "]", ")", ";", "}", "// register plugin with dispatcher", "EventDispatcher", "::", "getInstance", "(", ")", "->", "addSubscriber", "(", "$", "plugin", ")", ";", "return", "$", "plugin", ";", "}" ]
create, initialize and register a plugin instance @param string $pluginId @throws ApplicationException @return SubscriberInterface
[ "create", "initialize", "and", "register", "a", "plugin", "instance" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Application.php#L844-L887
train
dmj/PicaRecord
src/HAB/Pica/Record/TitleRecord.php
TitleRecord.setFields
public function setFields (array $fields) { $this->_fields = array(); $this->_records = array(); $prevLevel = null; foreach ($fields as $field) { $level = $field->getLevel(); if ($level === 0) { $this->append($field); } else { if ($level === 1 && $prevLevel !== 1) { $localRecord = new LocalRecord(array($field)); $this->addLocalRecord($localRecord); } else { $records = $this->getLocalRecords(); // Handle malformed Pica record w/ missing local record field if (empty($records)) { $localRecord = new LocalRecord(); $this->addLocalRecord($localRecord); } else { $localRecord = end($records); } if ($level === 1) { $localRecord->append($field); } else { $copyRecord = $localRecord->getCopyRecordByItemNumber($field->getOccurrence()); if ($copyRecord) { $copyRecord->append($field); } else { $localRecord->addCopyRecord(new CopyRecord(array($field))); } } } } $prevLevel = $level; } }
php
public function setFields (array $fields) { $this->_fields = array(); $this->_records = array(); $prevLevel = null; foreach ($fields as $field) { $level = $field->getLevel(); if ($level === 0) { $this->append($field); } else { if ($level === 1 && $prevLevel !== 1) { $localRecord = new LocalRecord(array($field)); $this->addLocalRecord($localRecord); } else { $records = $this->getLocalRecords(); // Handle malformed Pica record w/ missing local record field if (empty($records)) { $localRecord = new LocalRecord(); $this->addLocalRecord($localRecord); } else { $localRecord = end($records); } if ($level === 1) { $localRecord->append($field); } else { $copyRecord = $localRecord->getCopyRecordByItemNumber($field->getOccurrence()); if ($copyRecord) { $copyRecord->append($field); } else { $localRecord->addCopyRecord(new CopyRecord(array($field))); } } } } $prevLevel = $level; } }
[ "public", "function", "setFields", "(", "array", "$", "fields", ")", "{", "$", "this", "->", "_fields", "=", "array", "(", ")", ";", "$", "this", "->", "_records", "=", "array", "(", ")", ";", "$", "prevLevel", "=", "null", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "level", "=", "$", "field", "->", "getLevel", "(", ")", ";", "if", "(", "$", "level", "===", "0", ")", "{", "$", "this", "->", "append", "(", "$", "field", ")", ";", "}", "else", "{", "if", "(", "$", "level", "===", "1", "&&", "$", "prevLevel", "!==", "1", ")", "{", "$", "localRecord", "=", "new", "LocalRecord", "(", "array", "(", "$", "field", ")", ")", ";", "$", "this", "->", "addLocalRecord", "(", "$", "localRecord", ")", ";", "}", "else", "{", "$", "records", "=", "$", "this", "->", "getLocalRecords", "(", ")", ";", "// Handle malformed Pica record w/ missing local record field", "if", "(", "empty", "(", "$", "records", ")", ")", "{", "$", "localRecord", "=", "new", "LocalRecord", "(", ")", ";", "$", "this", "->", "addLocalRecord", "(", "$", "localRecord", ")", ";", "}", "else", "{", "$", "localRecord", "=", "end", "(", "$", "records", ")", ";", "}", "if", "(", "$", "level", "===", "1", ")", "{", "$", "localRecord", "->", "append", "(", "$", "field", ")", ";", "}", "else", "{", "$", "copyRecord", "=", "$", "localRecord", "->", "getCopyRecordByItemNumber", "(", "$", "field", "->", "getOccurrence", "(", ")", ")", ";", "if", "(", "$", "copyRecord", ")", "{", "$", "copyRecord", "->", "append", "(", "$", "field", ")", ";", "}", "else", "{", "$", "localRecord", "->", "addCopyRecord", "(", "new", "CopyRecord", "(", "array", "(", "$", "field", ")", ")", ")", ";", "}", "}", "}", "}", "$", "prevLevel", "=", "$", "level", ";", "}", "}" ]
Set the record's fields. @todo Relocate to \HAB\Pica\Record\Record::factory(), maybe @param array $fields Field @return void
[ "Set", "the", "record", "s", "fields", "." ]
bd5577b9a4333aa6156398b94cc870a9377061b8
https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/TitleRecord.php#L63-L99
train
dmj/PicaRecord
src/HAB/Pica/Record/TitleRecord.php
TitleRecord.getLocalRecordByILN
public function getLocalRecordByILN ($iln) { foreach ($this->getLocalRecords() as $localRecord) { if ($localRecord->getILN() == $iln) { return $localRecord; } } return null; }
php
public function getLocalRecordByILN ($iln) { foreach ($this->getLocalRecords() as $localRecord) { if ($localRecord->getILN() == $iln) { return $localRecord; } } return null; }
[ "public", "function", "getLocalRecordByILN", "(", "$", "iln", ")", "{", "foreach", "(", "$", "this", "->", "getLocalRecords", "(", ")", "as", "$", "localRecord", ")", "{", "if", "(", "$", "localRecord", "->", "getILN", "(", ")", "==", "$", "iln", ")", "{", "return", "$", "localRecord", ";", "}", "}", "return", "null", ";", "}" ]
Return a local record identified by its ILN. @param integer $iln Intenal library number @return LocalRecord|null
[ "Return", "a", "local", "record", "identified", "by", "its", "ILN", "." ]
bd5577b9a4333aa6156398b94cc870a9377061b8
https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/TitleRecord.php#L143-L151
train
lasallecms/lasallecms-l5-lasallecmsapi-pkg
src/Repositories/PostRepository.php
PostRepository.getAllPublishablePosts
public function getAllPublishablePosts() { $collection = $this->getAll()->sortByDesc('updated_at'); $filtered = $collection->filter(function ($item) { if ($item->enabled == 1) return true; }); $filtered = $filtered->filter(function ($item) { $todaysDate = DatesHelper::todaysDateSetToLocalTime(); if ($item->publish_on <= $todaysDate) return true; }); // TODO: HAVE TO MANUALLY PAGINATE THE FILTERED COLLECTION :-( // https://laracasts.com/discuss/channels/laravel/laravel-pagination-not-working-with-array-instead-of-collection?page=1#reply-63860 // http://www.reddit.com/r/laravel/comments/32kxn8/creating_a_paginator_manually/ return $filtered->all(); }
php
public function getAllPublishablePosts() { $collection = $this->getAll()->sortByDesc('updated_at'); $filtered = $collection->filter(function ($item) { if ($item->enabled == 1) return true; }); $filtered = $filtered->filter(function ($item) { $todaysDate = DatesHelper::todaysDateSetToLocalTime(); if ($item->publish_on <= $todaysDate) return true; }); // TODO: HAVE TO MANUALLY PAGINATE THE FILTERED COLLECTION :-( // https://laracasts.com/discuss/channels/laravel/laravel-pagination-not-working-with-array-instead-of-collection?page=1#reply-63860 // http://www.reddit.com/r/laravel/comments/32kxn8/creating_a_paginator_manually/ return $filtered->all(); }
[ "public", "function", "getAllPublishablePosts", "(", ")", "{", "$", "collection", "=", "$", "this", "->", "getAll", "(", ")", "->", "sortByDesc", "(", "'updated_at'", ")", ";", "$", "filtered", "=", "$", "collection", "->", "filter", "(", "function", "(", "$", "item", ")", "{", "if", "(", "$", "item", "->", "enabled", "==", "1", ")", "return", "true", ";", "}", ")", ";", "$", "filtered", "=", "$", "filtered", "->", "filter", "(", "function", "(", "$", "item", ")", "{", "$", "todaysDate", "=", "DatesHelper", "::", "todaysDateSetToLocalTime", "(", ")", ";", "if", "(", "$", "item", "->", "publish_on", "<=", "$", "todaysDate", ")", "return", "true", ";", "}", ")", ";", "// TODO: HAVE TO MANUALLY PAGINATE THE FILTERED COLLECTION :-(", "// https://laracasts.com/discuss/channels/laravel/laravel-pagination-not-working-with-array-instead-of-collection?page=1#reply-63860", "// http://www.reddit.com/r/laravel/comments/32kxn8/creating_a_paginator_manually/", "return", "$", "filtered", "->", "all", "(", ")", ";", "}" ]
Get all the posts ENABLED, PUBLISH_ON <= TODAY, DESC @return collection
[ "Get", "all", "the", "posts" ]
05083be19645d52be86d8ba4f322773db348a11d
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/Repositories/PostRepository.php#L74-L91
train
lasallecms/lasallecms-l5-lasallecmsapi-pkg
src/Repositories/PostRepository.php
PostRepository.getCategoryTitleById
public function getCategoryTitleById($categoryId) { $category = DB::table('categories') ->where('id', '=', $categoryId) ->first() ; return $category->title; }
php
public function getCategoryTitleById($categoryId) { $category = DB::table('categories') ->where('id', '=', $categoryId) ->first() ; return $category->title; }
[ "public", "function", "getCategoryTitleById", "(", "$", "categoryId", ")", "{", "$", "category", "=", "DB", "::", "table", "(", "'categories'", ")", "->", "where", "(", "'id'", ",", "'='", ",", "$", "categoryId", ")", "->", "first", "(", ")", ";", "return", "$", "category", "->", "title", ";", "}" ]
Find the category title by the category's id I have this little function here because I do not want to inject the category's repository. The purpose of having the category's title is to build a URL to all posts with that category. @param int $categoryId The category's ID @return string
[ "Find", "the", "category", "title", "by", "the", "category", "s", "id" ]
05083be19645d52be86d8ba4f322773db348a11d
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/Repositories/PostRepository.php#L191-L199
train
lasallecms/lasallecms-l5-lasallecmsapi-pkg
src/Repositories/PostRepository.php
PostRepository.getTagTitlesByPostId
public function getTagTitlesByPostId($postId) { // Grab the tag ID's from the post_tag table $post_tags = DB::table('post_tag') ->where('post_id', '=', $postId) ->get() ; // if there are no tags associated with this post, then return emptiness if (empty($post_tags)) { return $post_tags; } // ah, there are tags associated with the post // initialize the array that will be returned $tagTitles = []; // go through each tag_id and grab the tag's title foreach ($post_tags as $post_tag) { $tag = DB::table('tags') ->select('title') ->where('id', '=', $post_tag->tag_id) ->first(); $tagTitles[] = $tag->title; } return $tagTitles; }
php
public function getTagTitlesByPostId($postId) { // Grab the tag ID's from the post_tag table $post_tags = DB::table('post_tag') ->where('post_id', '=', $postId) ->get() ; // if there are no tags associated with this post, then return emptiness if (empty($post_tags)) { return $post_tags; } // ah, there are tags associated with the post // initialize the array that will be returned $tagTitles = []; // go through each tag_id and grab the tag's title foreach ($post_tags as $post_tag) { $tag = DB::table('tags') ->select('title') ->where('id', '=', $post_tag->tag_id) ->first(); $tagTitles[] = $tag->title; } return $tagTitles; }
[ "public", "function", "getTagTitlesByPostId", "(", "$", "postId", ")", "{", "// Grab the tag ID's from the post_tag table", "$", "post_tags", "=", "DB", "::", "table", "(", "'post_tag'", ")", "->", "where", "(", "'post_id'", ",", "'='", ",", "$", "postId", ")", "->", "get", "(", ")", ";", "// if there are no tags associated with this post, then return emptiness", "if", "(", "empty", "(", "$", "post_tags", ")", ")", "{", "return", "$", "post_tags", ";", "}", "// ah, there are tags associated with the post", "// initialize the array that will be returned", "$", "tagTitles", "=", "[", "]", ";", "// go through each tag_id and grab the tag's title", "foreach", "(", "$", "post_tags", "as", "$", "post_tag", ")", "{", "$", "tag", "=", "DB", "::", "table", "(", "'tags'", ")", "->", "select", "(", "'title'", ")", "->", "where", "(", "'id'", ",", "'='", ",", "$", "post_tag", "->", "tag_id", ")", "->", "first", "(", ")", ";", "$", "tagTitles", "[", "]", "=", "$", "tag", "->", "title", ";", "}", "return", "$", "tagTitles", ";", "}" ]
Find the tag's titles for those tags that are associated with a post. I have this little function here because I do not want to inject the tag's repository. @param int $postId The post's ID @return array
[ "Find", "the", "tag", "s", "titles", "for", "those", "tags", "that", "are", "associated", "with", "a", "post", "." ]
05083be19645d52be86d8ba4f322773db348a11d
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/Repositories/PostRepository.php#L210-L241
train
Kris-Kuiper/sFire-Framework
src/HTTP/Response.php
Response.addHeader
public static function addHeader($type, $value, $code = null) { if(false == is_string($type)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($type)), E_USER_ERROR); } if(false == is_string($value) && false == is_numeric($value)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($value)), E_USER_ERROR); } if(null !== $code && false === ('-' . intval($code) == '-' . $code)) { return trigger_error(sprintf('Argument 3 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($code)), E_USER_ERROR); } if(null === $code) { return header($type . ':' . $value, true); } header($type . ':' . $value, true, $code); }
php
public static function addHeader($type, $value, $code = null) { if(false == is_string($type)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($type)), E_USER_ERROR); } if(false == is_string($value) && false == is_numeric($value)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($value)), E_USER_ERROR); } if(null !== $code && false === ('-' . intval($code) == '-' . $code)) { return trigger_error(sprintf('Argument 3 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($code)), E_USER_ERROR); } if(null === $code) { return header($type . ':' . $value, true); } header($type . ':' . $value, true, $code); }
[ "public", "static", "function", "addHeader", "(", "$", "type", ",", "$", "value", ",", "$", "code", "=", "null", ")", "{", "if", "(", "false", "==", "is_string", "(", "$", "type", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "type", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "false", "==", "is_string", "(", "$", "value", ")", "&&", "false", "==", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 2 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "value", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "null", "!==", "$", "code", "&&", "false", "===", "(", "'-'", ".", "intval", "(", "$", "code", ")", "==", "'-'", ".", "$", "code", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 3 passed to %s() must be of the type integer, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "code", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "null", "===", "$", "code", ")", "{", "return", "header", "(", "$", "type", ".", "':'", ".", "$", "value", ",", "true", ")", ";", "}", "header", "(", "$", "type", ".", "':'", ".", "$", "value", ",", "true", ",", "$", "code", ")", ";", "}" ]
Sets the response header by type and value @param string $type @param string $value
[ "Sets", "the", "response", "header", "by", "type", "and", "value" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Response.php#L21-L40
train
Kris-Kuiper/sFire-Framework
src/HTTP/Response.php
Response.removeHeader
public static function removeHeader($type) { if(false == is_string($type)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($type)), E_USER_ERROR); } header_remove($type); }
php
public static function removeHeader($type) { if(false == is_string($type)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($type)), E_USER_ERROR); } header_remove($type); }
[ "public", "static", "function", "removeHeader", "(", "$", "type", ")", "{", "if", "(", "false", "==", "is_string", "(", "$", "type", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "type", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "header_remove", "(", "$", "type", ")", ";", "}" ]
Remove response header by type @param string $type
[ "Remove", "response", "header", "by", "type" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Response.php#L47-L54
train
Kris-Kuiper/sFire-Framework
src/HTTP/Response.php
Response.file
public static function file(File $file, $filename = null, $mime = null) { if(null !== $filename && false === is_string($filename)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($filename)), E_USER_ERROR); } if(null !== $mime && false === is_string($mime)) { return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($mime)), E_USER_ERROR); } if(null !== $file -> entity()) { //Determine file name $filename = null !== $filename ? $filename : $file -> entity() -> getBasename(); //Add mime if known $mime = null !== $mime ? $mime : $file -> getMime(); if(null !== $mime) { static :: addHeader('Content-Type', $mime); } static :: addHeader('Content-Transfer-Encoding', 'binary'); static :: addHeader('Expires', '0'); static :: addHeader('Pragma', 'public'); static :: addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); static :: addHeader('Content-Length', $file -> entity() -> getFilesize()); static :: addHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate'); static :: addHeader('Expires', 'Tue, 25 Oct '. (date('Y') - 10) .' 05:00:00 GMT'); static :: addHeader('Pragma', 'no-cache'); if($fd = @fopen($file -> entity() -> getBasepath(), 'r')) { ob_clean(); flush(); while(!feof($fd)) { echo fread($fd, 2048); } fclose($fd); } } }
php
public static function file(File $file, $filename = null, $mime = null) { if(null !== $filename && false === is_string($filename)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($filename)), E_USER_ERROR); } if(null !== $mime && false === is_string($mime)) { return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($mime)), E_USER_ERROR); } if(null !== $file -> entity()) { //Determine file name $filename = null !== $filename ? $filename : $file -> entity() -> getBasename(); //Add mime if known $mime = null !== $mime ? $mime : $file -> getMime(); if(null !== $mime) { static :: addHeader('Content-Type', $mime); } static :: addHeader('Content-Transfer-Encoding', 'binary'); static :: addHeader('Expires', '0'); static :: addHeader('Pragma', 'public'); static :: addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); static :: addHeader('Content-Length', $file -> entity() -> getFilesize()); static :: addHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate'); static :: addHeader('Expires', 'Tue, 25 Oct '. (date('Y') - 10) .' 05:00:00 GMT'); static :: addHeader('Pragma', 'no-cache'); if($fd = @fopen($file -> entity() -> getBasepath(), 'r')) { ob_clean(); flush(); while(!feof($fd)) { echo fread($fd, 2048); } fclose($fd); } } }
[ "public", "static", "function", "file", "(", "File", "$", "file", ",", "$", "filename", "=", "null", ",", "$", "mime", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "filename", "&&", "false", "===", "is_string", "(", "$", "filename", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 2 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "filename", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "null", "!==", "$", "mime", "&&", "false", "===", "is_string", "(", "$", "mime", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 3 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "mime", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "null", "!==", "$", "file", "->", "entity", "(", ")", ")", "{", "//Determine file name\r", "$", "filename", "=", "null", "!==", "$", "filename", "?", "$", "filename", ":", "$", "file", "->", "entity", "(", ")", "->", "getBasename", "(", ")", ";", "//Add mime if known\r", "$", "mime", "=", "null", "!==", "$", "mime", "?", "$", "mime", ":", "$", "file", "->", "getMime", "(", ")", ";", "if", "(", "null", "!==", "$", "mime", ")", "{", "static", "::", "addHeader", "(", "'Content-Type'", ",", "$", "mime", ")", ";", "}", "static", "::", "addHeader", "(", "'Content-Transfer-Encoding'", ",", "'binary'", ")", ";", "static", "::", "addHeader", "(", "'Expires'", ",", "'0'", ")", ";", "static", "::", "addHeader", "(", "'Pragma'", ",", "'public'", ")", ";", "static", "::", "addHeader", "(", "'Content-Disposition'", ",", "'attachment; filename=\"'", ".", "$", "filename", ".", "'\"'", ")", ";", "static", "::", "addHeader", "(", "'Content-Length'", ",", "$", "file", "->", "entity", "(", ")", "->", "getFilesize", "(", ")", ")", ";", "static", "::", "addHeader", "(", "'Cache-Control'", ",", "'no-cache, no-store, max-age=0, must-revalidate'", ")", ";", "static", "::", "addHeader", "(", "'Expires'", ",", "'Tue, 25 Oct '", ".", "(", "date", "(", "'Y'", ")", "-", "10", ")", ".", "' 05:00:00 GMT'", ")", ";", "static", "::", "addHeader", "(", "'Pragma'", ",", "'no-cache'", ")", ";", "if", "(", "$", "fd", "=", "@", "fopen", "(", "$", "file", "->", "entity", "(", ")", "->", "getBasepath", "(", ")", ",", "'r'", ")", ")", "{", "ob_clean", "(", ")", ";", "flush", "(", ")", ";", "while", "(", "!", "feof", "(", "$", "fd", ")", ")", "{", "echo", "fread", "(", "$", "fd", ",", "2048", ")", ";", "}", "fclose", "(", "$", "fd", ")", ";", "}", "}", "}" ]
Give a file for the client to download @param sFire\System\File $file @param string $name @param string $mime
[ "Give", "a", "file", "for", "the", "client", "to", "download" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Response.php#L71-L114
train
prolic/HumusMvc
src/HumusMvc/View/Helper/Navigation.php
Navigation.setPluginManager
public function setPluginManager(Navigation\PluginManager $plugins) { if ($this->view) { $plugins->setView($this->view); } $this->plugins = $plugins; return $this; }
php
public function setPluginManager(Navigation\PluginManager $plugins) { if ($this->view) { $plugins->setView($this->view); } $this->plugins = $plugins; return $this; }
[ "public", "function", "setPluginManager", "(", "Navigation", "\\", "PluginManager", "$", "plugins", ")", "{", "if", "(", "$", "this", "->", "view", ")", "{", "$", "plugins", "->", "setView", "(", "$", "this", "->", "view", ")", ";", "}", "$", "this", "->", "plugins", "=", "$", "plugins", ";", "return", "$", "this", ";", "}" ]
Set manager for retrieving navigation helpers @param Navigation\PluginManager $plugins @return Navigation
[ "Set", "manager", "for", "retrieving", "navigation", "helpers" ]
09e8c6422d84b57745cc643047e10761be2a21a7
https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/View/Helper/Navigation.php#L50-L57
train
prolic/HumusMvc
src/HumusMvc/View/Helper/Navigation.php
Navigation.getPluginManager
public function getPluginManager() { if (null === $this->plugins) { $this->setPluginManager(new Navigation\PluginManager()); } return $this->plugins; }
php
public function getPluginManager() { if (null === $this->plugins) { $this->setPluginManager(new Navigation\PluginManager()); } return $this->plugins; }
[ "public", "function", "getPluginManager", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "plugins", ")", "{", "$", "this", "->", "setPluginManager", "(", "new", "Navigation", "\\", "PluginManager", "(", ")", ")", ";", "}", "return", "$", "this", "->", "plugins", ";", "}" ]
Retrieve plugin loader for navigation helpers Lazy-loads an instance of Navigation\HelperLoader if none currently registered. @return Navigation\PluginManager
[ "Retrieve", "plugin", "loader", "for", "navigation", "helpers" ]
09e8c6422d84b57745cc643047e10761be2a21a7
https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/View/Helper/Navigation.php#L67-L73
train
wasinger/adaptimage
src/ImageFileInfo.php
ImageFileInfo.createFromFile
static public function createFromFile($pathname) { if (!file_exists($pathname)) { throw new ImageFileNotFoundException($pathname); } $ii = getimagesize($pathname); $width = $ii[0]; $height = $ii[1]; $imagetype = $ii[2]; $last_modified = filemtime($pathname); $exif = @exif_read_data($pathname); if (isset($exif['Orientation'])) { $orientation = $exif['Orientation']; } else { $orientation = 0; } return new static($pathname, $width, $height, $imagetype, $last_modified, $orientation); }
php
static public function createFromFile($pathname) { if (!file_exists($pathname)) { throw new ImageFileNotFoundException($pathname); } $ii = getimagesize($pathname); $width = $ii[0]; $height = $ii[1]; $imagetype = $ii[2]; $last_modified = filemtime($pathname); $exif = @exif_read_data($pathname); if (isset($exif['Orientation'])) { $orientation = $exif['Orientation']; } else { $orientation = 0; } return new static($pathname, $width, $height, $imagetype, $last_modified, $orientation); }
[ "static", "public", "function", "createFromFile", "(", "$", "pathname", ")", "{", "if", "(", "!", "file_exists", "(", "$", "pathname", ")", ")", "{", "throw", "new", "ImageFileNotFoundException", "(", "$", "pathname", ")", ";", "}", "$", "ii", "=", "getimagesize", "(", "$", "pathname", ")", ";", "$", "width", "=", "$", "ii", "[", "0", "]", ";", "$", "height", "=", "$", "ii", "[", "1", "]", ";", "$", "imagetype", "=", "$", "ii", "[", "2", "]", ";", "$", "last_modified", "=", "filemtime", "(", "$", "pathname", ")", ";", "$", "exif", "=", "@", "exif_read_data", "(", "$", "pathname", ")", ";", "if", "(", "isset", "(", "$", "exif", "[", "'Orientation'", "]", ")", ")", "{", "$", "orientation", "=", "$", "exif", "[", "'Orientation'", "]", ";", "}", "else", "{", "$", "orientation", "=", "0", ";", "}", "return", "new", "static", "(", "$", "pathname", ",", "$", "width", ",", "$", "height", ",", "$", "imagetype", ",", "$", "last_modified", ",", "$", "orientation", ")", ";", "}" ]
Create an ImageFileInfo from an image file @param string $pathname The pathname of an image file. @return ImageFileInfo @throws ImageFileNotFoundException If the image does not exist
[ "Create", "an", "ImageFileInfo", "from", "an", "image", "file" ]
7b529b25081b399451c8bbd56d0cef7daaa83ec4
https://github.com/wasinger/adaptimage/blob/7b529b25081b399451c8bbd56d0cef7daaa83ec4/src/ImageFileInfo.php#L79-L96
train
dmitrya2e/filtration-bundle
Filter/Filter/AbstractRangeOrSingleFilter.php
AbstractRangeOrSingleFilter.setSingleType
public function setSingleType($singleType) { $allowedTypes = [ self::SINGLE_TYPE_EXACT, self::SINGLE_TYPE_GREATER, self::SINGLE_TYPE_GREATER_OR_EQUAL, self::SINGLE_TYPE_LESS, self::SINGLE_TYPE_LESS_OR_EQUAL, ]; if (!is_string($singleType) || !in_array($singleType, $allowedTypes, true)) { throw new InvalidArgumentException(sprintf( 'Invalid "single type" argument. Allowed types: [%s].', implode(', ', $allowedTypes) )); } $this->singleType = $singleType; return $this; }
php
public function setSingleType($singleType) { $allowedTypes = [ self::SINGLE_TYPE_EXACT, self::SINGLE_TYPE_GREATER, self::SINGLE_TYPE_GREATER_OR_EQUAL, self::SINGLE_TYPE_LESS, self::SINGLE_TYPE_LESS_OR_EQUAL, ]; if (!is_string($singleType) || !in_array($singleType, $allowedTypes, true)) { throw new InvalidArgumentException(sprintf( 'Invalid "single type" argument. Allowed types: [%s].', implode(', ', $allowedTypes) )); } $this->singleType = $singleType; return $this; }
[ "public", "function", "setSingleType", "(", "$", "singleType", ")", "{", "$", "allowedTypes", "=", "[", "self", "::", "SINGLE_TYPE_EXACT", ",", "self", "::", "SINGLE_TYPE_GREATER", ",", "self", "::", "SINGLE_TYPE_GREATER_OR_EQUAL", ",", "self", "::", "SINGLE_TYPE_LESS", ",", "self", "::", "SINGLE_TYPE_LESS_OR_EQUAL", ",", "]", ";", "if", "(", "!", "is_string", "(", "$", "singleType", ")", "||", "!", "in_array", "(", "$", "singleType", ",", "$", "allowedTypes", ",", "true", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid \"single type\" argument. Allowed types: [%s].'", ",", "implode", "(", "', '", ",", "$", "allowedTypes", ")", ")", ")", ";", "}", "$", "this", "->", "singleType", "=", "$", "singleType", ";", "return", "$", "this", ";", "}" ]
Sets type for the filter treated as single. @param string $singleType AbstractRangeOrSingleFilter::SINGLE_TYPE_* @return static @throws InvalidArgumentException On invalid argument
[ "Sets", "type", "for", "the", "filter", "treated", "as", "single", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Filter/AbstractRangeOrSingleFilter.php#L455-L474
train
dmitrya2e/filtration-bundle
Filter/Filter/AbstractRangeOrSingleFilter.php
AbstractRangeOrSingleFilter.setFromValuePropertyName
public function setFromValuePropertyName($fromValuePropertyName) { if (!is_string($fromValuePropertyName) || empty($fromValuePropertyName)) { throw new InvalidArgumentException('"From value property name" argument must be string and must not be empty.'); } if (!property_exists($this, $fromValuePropertyName)) { throw new InvalidArgumentException(sprintf('Property "%s" does not exist.', $fromValuePropertyName)); } $this->fromValuePropertyName = $fromValuePropertyName; return $this; }
php
public function setFromValuePropertyName($fromValuePropertyName) { if (!is_string($fromValuePropertyName) || empty($fromValuePropertyName)) { throw new InvalidArgumentException('"From value property name" argument must be string and must not be empty.'); } if (!property_exists($this, $fromValuePropertyName)) { throw new InvalidArgumentException(sprintf('Property "%s" does not exist.', $fromValuePropertyName)); } $this->fromValuePropertyName = $fromValuePropertyName; return $this; }
[ "public", "function", "setFromValuePropertyName", "(", "$", "fromValuePropertyName", ")", "{", "if", "(", "!", "is_string", "(", "$", "fromValuePropertyName", ")", "||", "empty", "(", "$", "fromValuePropertyName", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"From value property name\" argument must be string and must not be empty.'", ")", ";", "}", "if", "(", "!", "property_exists", "(", "$", "this", ",", "$", "fromValuePropertyName", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Property \"%s\" does not exist.'", ",", "$", "fromValuePropertyName", ")", ")", ";", "}", "$", "this", "->", "fromValuePropertyName", "=", "$", "fromValuePropertyName", ";", "return", "$", "this", ";", "}" ]
Sets "from" value property name, which contains the "from" value. @param string $fromValuePropertyName @return static @throws InvalidArgumentException On invalid argument
[ "Sets", "from", "value", "property", "name", "which", "contains", "the", "from", "value", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Filter/AbstractRangeOrSingleFilter.php#L494-L507
train
dmitrya2e/filtration-bundle
Filter/Filter/AbstractRangeOrSingleFilter.php
AbstractRangeOrSingleFilter.setToValuePropertyName
public function setToValuePropertyName($toValuePropertyName) { if (!is_string($toValuePropertyName) || empty($toValuePropertyName)) { throw new InvalidArgumentException('"To value property name" argument must be string and must not be empty.'); } if (!property_exists($this, $toValuePropertyName)) { throw new InvalidArgumentException(sprintf('Property "%s" does not exist.', $toValuePropertyName)); } $this->toValuePropertyName = $toValuePropertyName; return $this; }
php
public function setToValuePropertyName($toValuePropertyName) { if (!is_string($toValuePropertyName) || empty($toValuePropertyName)) { throw new InvalidArgumentException('"To value property name" argument must be string and must not be empty.'); } if (!property_exists($this, $toValuePropertyName)) { throw new InvalidArgumentException(sprintf('Property "%s" does not exist.', $toValuePropertyName)); } $this->toValuePropertyName = $toValuePropertyName; return $this; }
[ "public", "function", "setToValuePropertyName", "(", "$", "toValuePropertyName", ")", "{", "if", "(", "!", "is_string", "(", "$", "toValuePropertyName", ")", "||", "empty", "(", "$", "toValuePropertyName", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"To value property name\" argument must be string and must not be empty.'", ")", ";", "}", "if", "(", "!", "property_exists", "(", "$", "this", ",", "$", "toValuePropertyName", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Property \"%s\" does not exist.'", ",", "$", "toValuePropertyName", ")", ")", ";", "}", "$", "this", "->", "toValuePropertyName", "=", "$", "toValuePropertyName", ";", "return", "$", "this", ";", "}" ]
Sets "to" value property name, which contains the "to" value. @param string $toValuePropertyName @return static @throws InvalidArgumentException On invalid argument
[ "Sets", "to", "value", "property", "name", "which", "contains", "the", "to", "value", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Filter/AbstractRangeOrSingleFilter.php#L527-L540
train
dmitrya2e/filtration-bundle
Filter/Filter/AbstractRangeOrSingleFilter.php
AbstractRangeOrSingleFilter.setFromPostfix
public function setFromPostfix($fromPostfix) { if (!is_string($fromPostfix) || empty($fromPostfix)) { throw new InvalidArgumentException('"From postfix" argument must be string and must not be empty.'); } $this->fromPostfix = $fromPostfix; return $this; }
php
public function setFromPostfix($fromPostfix) { if (!is_string($fromPostfix) || empty($fromPostfix)) { throw new InvalidArgumentException('"From postfix" argument must be string and must not be empty.'); } $this->fromPostfix = $fromPostfix; return $this; }
[ "public", "function", "setFromPostfix", "(", "$", "fromPostfix", ")", "{", "if", "(", "!", "is_string", "(", "$", "fromPostfix", ")", "||", "empty", "(", "$", "fromPostfix", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"From postfix\" argument must be string and must not be empty.'", ")", ";", "}", "$", "this", "->", "fromPostfix", "=", "$", "fromPostfix", ";", "return", "$", "this", ";", "}" ]
Sets "from" name postfix. @param string $fromPostfix @return static @throws InvalidArgumentException On invalid argument
[ "Sets", "from", "name", "postfix", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Filter/AbstractRangeOrSingleFilter.php#L560-L569
train
dmitrya2e/filtration-bundle
Filter/Filter/AbstractRangeOrSingleFilter.php
AbstractRangeOrSingleFilter.setToPostfix
public function setToPostfix($toPostfix) { if (!is_string($toPostfix) || empty($toPostfix)) { throw new InvalidArgumentException('"To postfix" argument must be string and must not be empty.'); } $this->toPostfix = $toPostfix; return $this; }
php
public function setToPostfix($toPostfix) { if (!is_string($toPostfix) || empty($toPostfix)) { throw new InvalidArgumentException('"To postfix" argument must be string and must not be empty.'); } $this->toPostfix = $toPostfix; return $this; }
[ "public", "function", "setToPostfix", "(", "$", "toPostfix", ")", "{", "if", "(", "!", "is_string", "(", "$", "toPostfix", ")", "||", "empty", "(", "$", "toPostfix", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"To postfix\" argument must be string and must not be empty.'", ")", ";", "}", "$", "this", "->", "toPostfix", "=", "$", "toPostfix", ";", "return", "$", "this", ";", "}" ]
Sets "to" name postfix. @param string $toPostfix @return static @throws InvalidArgumentException On invalid argument
[ "Sets", "to", "name", "postfix", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Filter/AbstractRangeOrSingleFilter.php#L589-L598
train
dmitrya2e/filtration-bundle
Filter/Filter/AbstractRangeOrSingleFilter.php
AbstractRangeOrSingleFilter.setRangedFromType
public function setRangedFromType($rangedFromType) { $allowedTypes = [self::RANGED_FROM_TYPE_GREATER, self::RANGED_FROM_TYPE_GREATER_OR_EQUAL]; if (!is_string($rangedFromType) || !in_array($rangedFromType, $allowedTypes, true)) { throw new InvalidArgumentException(sprintf( 'Invalid "ranged to type" argument. Allowed types: [%s].', implode(', ', $allowedTypes) )); } $this->rangedFromType = $rangedFromType; return $this; }
php
public function setRangedFromType($rangedFromType) { $allowedTypes = [self::RANGED_FROM_TYPE_GREATER, self::RANGED_FROM_TYPE_GREATER_OR_EQUAL]; if (!is_string($rangedFromType) || !in_array($rangedFromType, $allowedTypes, true)) { throw new InvalidArgumentException(sprintf( 'Invalid "ranged to type" argument. Allowed types: [%s].', implode(', ', $allowedTypes) )); } $this->rangedFromType = $rangedFromType; return $this; }
[ "public", "function", "setRangedFromType", "(", "$", "rangedFromType", ")", "{", "$", "allowedTypes", "=", "[", "self", "::", "RANGED_FROM_TYPE_GREATER", ",", "self", "::", "RANGED_FROM_TYPE_GREATER_OR_EQUAL", "]", ";", "if", "(", "!", "is_string", "(", "$", "rangedFromType", ")", "||", "!", "in_array", "(", "$", "rangedFromType", ",", "$", "allowedTypes", ",", "true", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid \"ranged to type\" argument. Allowed types: [%s].'", ",", "implode", "(", "', '", ",", "$", "allowedTypes", ")", ")", ")", ";", "}", "$", "this", "->", "rangedFromType", "=", "$", "rangedFromType", ";", "return", "$", "this", ";", "}" ]
Sets "from" type for the filter treated as ranged. @param string $rangedFromType AbstractRangeOrSingleFilter::RANGED_FROM_TYPE_* @return static @throws InvalidArgumentException On invalid argument
[ "Sets", "from", "type", "for", "the", "filter", "treated", "as", "ranged", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Filter/AbstractRangeOrSingleFilter.php#L628-L641
train
dmitrya2e/filtration-bundle
Filter/Filter/AbstractRangeOrSingleFilter.php
AbstractRangeOrSingleFilter.setRangedToType
public function setRangedToType($rangedToType) { $allowedTypes = [self::RANGED_TO_TYPE_LESS, self::RANGED_TO_TYPE_LESS_OR_EQUAL]; if (!is_string($rangedToType) || !in_array($rangedToType, $allowedTypes)) { throw new InvalidArgumentException(sprintf( 'Invalid "ranged to type" argument. Allowed types: [%s].', implode(', ', $allowedTypes) )); } $this->rangedToType = $rangedToType; return $this; }
php
public function setRangedToType($rangedToType) { $allowedTypes = [self::RANGED_TO_TYPE_LESS, self::RANGED_TO_TYPE_LESS_OR_EQUAL]; if (!is_string($rangedToType) || !in_array($rangedToType, $allowedTypes)) { throw new InvalidArgumentException(sprintf( 'Invalid "ranged to type" argument. Allowed types: [%s].', implode(', ', $allowedTypes) )); } $this->rangedToType = $rangedToType; return $this; }
[ "public", "function", "setRangedToType", "(", "$", "rangedToType", ")", "{", "$", "allowedTypes", "=", "[", "self", "::", "RANGED_TO_TYPE_LESS", ",", "self", "::", "RANGED_TO_TYPE_LESS_OR_EQUAL", "]", ";", "if", "(", "!", "is_string", "(", "$", "rangedToType", ")", "||", "!", "in_array", "(", "$", "rangedToType", ",", "$", "allowedTypes", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid \"ranged to type\" argument. Allowed types: [%s].'", ",", "implode", "(", "', '", ",", "$", "allowedTypes", ")", ")", ")", ";", "}", "$", "this", "->", "rangedToType", "=", "$", "rangedToType", ";", "return", "$", "this", ";", "}" ]
Sets "to" type for the filter treated as ranged. @param string $rangedToType AbstractRangeOrSingleFilter::RANGED_TO_TYPE_* @return static @throws InvalidArgumentException On invalid argument
[ "Sets", "to", "type", "for", "the", "filter", "treated", "as", "ranged", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Filter/AbstractRangeOrSingleFilter.php#L661-L674
train
dmitrya2e/filtration-bundle
Filter/Filter/AbstractRangeOrSingleFilter.php
AbstractRangeOrSingleFilter.setFormFieldTypeRangedFrom
public function setFormFieldTypeRangedFrom($formFieldTypeRangedFrom) { if (!is_string($formFieldTypeRangedFrom) || empty($formFieldTypeRangedFrom)) { throw new InvalidArgumentException('"Form field type ranged from" argument must be string and must not be empty.'); } $this->formFieldTypeRangedFrom = $formFieldTypeRangedFrom; return $this; }
php
public function setFormFieldTypeRangedFrom($formFieldTypeRangedFrom) { if (!is_string($formFieldTypeRangedFrom) || empty($formFieldTypeRangedFrom)) { throw new InvalidArgumentException('"Form field type ranged from" argument must be string and must not be empty.'); } $this->formFieldTypeRangedFrom = $formFieldTypeRangedFrom; return $this; }
[ "public", "function", "setFormFieldTypeRangedFrom", "(", "$", "formFieldTypeRangedFrom", ")", "{", "if", "(", "!", "is_string", "(", "$", "formFieldTypeRangedFrom", ")", "||", "empty", "(", "$", "formFieldTypeRangedFrom", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"Form field type ranged from\" argument must be string and must not be empty.'", ")", ";", "}", "$", "this", "->", "formFieldTypeRangedFrom", "=", "$", "formFieldTypeRangedFrom", ";", "return", "$", "this", ";", "}" ]
Sets form field type for "from" field. @param string $formFieldTypeRangedFrom @return static @throws InvalidArgumentException On invalid argument
[ "Sets", "form", "field", "type", "for", "from", "field", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Filter/AbstractRangeOrSingleFilter.php#L694-L703
train
dmitrya2e/filtration-bundle
Filter/Filter/AbstractRangeOrSingleFilter.php
AbstractRangeOrSingleFilter.setFormFieldTypeRangedTo
public function setFormFieldTypeRangedTo($formFieldTypeRangedTo) { if (!is_string($formFieldTypeRangedTo) || empty($formFieldTypeRangedTo)) { throw new InvalidArgumentException('"Form field type ranged to" argument must be string and must not be empty.'); } $this->formFieldTypeRangedTo = $formFieldTypeRangedTo; return $this; }
php
public function setFormFieldTypeRangedTo($formFieldTypeRangedTo) { if (!is_string($formFieldTypeRangedTo) || empty($formFieldTypeRangedTo)) { throw new InvalidArgumentException('"Form field type ranged to" argument must be string and must not be empty.'); } $this->formFieldTypeRangedTo = $formFieldTypeRangedTo; return $this; }
[ "public", "function", "setFormFieldTypeRangedTo", "(", "$", "formFieldTypeRangedTo", ")", "{", "if", "(", "!", "is_string", "(", "$", "formFieldTypeRangedTo", ")", "||", "empty", "(", "$", "formFieldTypeRangedTo", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'\"Form field type ranged to\" argument must be string and must not be empty.'", ")", ";", "}", "$", "this", "->", "formFieldTypeRangedTo", "=", "$", "formFieldTypeRangedTo", ";", "return", "$", "this", ";", "}" ]
Sets form field type for "to" field. @param string $formFieldTypeRangedTo @return static @throws InvalidArgumentException On invalid argument
[ "Sets", "form", "field", "type", "for", "to", "field", "." ]
fed5764af4e43871835744fb84957b2a76e9a215
https://github.com/dmitrya2e/filtration-bundle/blob/fed5764af4e43871835744fb84957b2a76e9a215/Filter/Filter/AbstractRangeOrSingleFilter.php#L723-L732
train
t3v/t3v_core
Classes/Utility/IconUtility.php
IconUtility.iconIdentifier
public static function iconIdentifier(string $iconKey, string $separator = '_'): string { $slugify = new Slugify(['separator' => $separator]); $iconIdentifier = $slugify->slugify($iconKey); return $iconIdentifier; }
php
public static function iconIdentifier(string $iconKey, string $separator = '_'): string { $slugify = new Slugify(['separator' => $separator]); $iconIdentifier = $slugify->slugify($iconKey); return $iconIdentifier; }
[ "public", "static", "function", "iconIdentifier", "(", "string", "$", "iconKey", ",", "string", "$", "separator", "=", "'_'", ")", ":", "string", "{", "$", "slugify", "=", "new", "Slugify", "(", "[", "'separator'", "=>", "$", "separator", "]", ")", ";", "$", "iconIdentifier", "=", "$", "slugify", "->", "slugify", "(", "$", "iconKey", ")", ";", "return", "$", "iconIdentifier", ";", "}" ]
Gets an icon identifier from an icon key. @param string $iconKey The icon key @param string $separator The optional separator, defaults to `_` @return string The icon identifier
[ "Gets", "an", "icon", "identifier", "from", "an", "icon", "key", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/IconUtility.php#L19-L24
train
t3v/t3v_core
Classes/Utility/IconUtility.php
IconUtility.getIconIdentifier
public static function getIconIdentifier(string $iconKey, string $separator = '_'): string { return self::iconIdentifier($iconKey, $separator); }
php
public static function getIconIdentifier(string $iconKey, string $separator = '_'): string { return self::iconIdentifier($iconKey, $separator); }
[ "public", "static", "function", "getIconIdentifier", "(", "string", "$", "iconKey", ",", "string", "$", "separator", "=", "'_'", ")", ":", "string", "{", "return", "self", "::", "iconIdentifier", "(", "$", "iconKey", ",", "$", "separator", ")", ";", "}" ]
Alias for the `iconIdentifier` function. @param string $iconKey The icon key @param string $separator The optional separator, defaults to `_` @return string The icon identifier
[ "Alias", "for", "the", "iconIdentifier", "function", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/IconUtility.php#L33-L35
train
t3v/t3v_core
Classes/Utility/IconUtility.php
IconUtility.iconSignature
public static function iconSignature(string $extensionKey, string $iconIdentifier, string $separator = '-'): string { $iconSignature = mb_strtolower("${extensionKey}${separator}${iconIdentifier}"); return $iconSignature; }
php
public static function iconSignature(string $extensionKey, string $iconIdentifier, string $separator = '-'): string { $iconSignature = mb_strtolower("${extensionKey}${separator}${iconIdentifier}"); return $iconSignature; }
[ "public", "static", "function", "iconSignature", "(", "string", "$", "extensionKey", ",", "string", "$", "iconIdentifier", ",", "string", "$", "separator", "=", "'-'", ")", ":", "string", "{", "$", "iconSignature", "=", "mb_strtolower", "(", "\"${extensionKey}${separator}${iconIdentifier}\"", ")", ";", "return", "$", "iconSignature", ";", "}" ]
Gets an icon signature from an extension key and icon identifier. @param string $extensionKey The extension key @param string $iconIdentifier The icon identifier @param string $separator The optional separator, defaults to `-` @return string The icon signature
[ "Gets", "an", "icon", "signature", "from", "an", "extension", "key", "and", "icon", "identifier", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/IconUtility.php#L45-L49
train
t3v/t3v_core
Classes/Utility/IconUtility.php
IconUtility.getIconSignature
public static function getIconSignature(string $extensionKey, string $iconIdentifier, string $separator = '-'): string { return self::iconSignature($extensionKey, $iconIdentifier, $separator); }
php
public static function getIconSignature(string $extensionKey, string $iconIdentifier, string $separator = '-'): string { return self::iconSignature($extensionKey, $iconIdentifier, $separator); }
[ "public", "static", "function", "getIconSignature", "(", "string", "$", "extensionKey", ",", "string", "$", "iconIdentifier", ",", "string", "$", "separator", "=", "'-'", ")", ":", "string", "{", "return", "self", "::", "iconSignature", "(", "$", "extensionKey", ",", "$", "iconIdentifier", ",", "$", "separator", ")", ";", "}" ]
Alias for the `iconSignature` function. @param string $extensionKey The extension key @param string $iconIdentifier The icon identifier @param string $separator The optional separator, defaults to `-` @return string The icon signature
[ "Alias", "for", "the", "iconSignature", "function", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/IconUtility.php#L59-L61
train
DreadLabs/VantomasWebsite
src/SecretSanta/Donee/Resolver.php
Resolver.resolveFor
public function resolveFor(UserIdInterface $donorId) { $donor = $this->donorRepository->findOneById($donorId); $donee = $this->getResolverHandlerChain()->resolve($donor); $this->eventContext->dispatch(FoundDonee::fromPair($donor, $donee)); return $donee; }
php
public function resolveFor(UserIdInterface $donorId) { $donor = $this->donorRepository->findOneById($donorId); $donee = $this->getResolverHandlerChain()->resolve($donor); $this->eventContext->dispatch(FoundDonee::fromPair($donor, $donee)); return $donee; }
[ "public", "function", "resolveFor", "(", "UserIdInterface", "$", "donorId", ")", "{", "$", "donor", "=", "$", "this", "->", "donorRepository", "->", "findOneById", "(", "$", "donorId", ")", ";", "$", "donee", "=", "$", "this", "->", "getResolverHandlerChain", "(", ")", "->", "resolve", "(", "$", "donor", ")", ";", "$", "this", "->", "eventContext", "->", "dispatch", "(", "FoundDonee", "::", "fromPair", "(", "$", "donor", ",", "$", "donee", ")", ")", ";", "return", "$", "donee", ";", "}" ]
Resolves a donee for the incoming donor user id @param UserIdInterface $donorId User id of the donor @return DoneeInterface A donee
[ "Resolves", "a", "donee", "for", "the", "incoming", "donor", "user", "id" ]
7f85f2b45bdf5ed9fa9d320c805c416bf99cd668
https://github.com/DreadLabs/VantomasWebsite/blob/7f85f2b45bdf5ed9fa9d320c805c416bf99cd668/src/SecretSanta/Donee/Resolver.php#L77-L86
train
DreadLabs/VantomasWebsite
src/SecretSanta/Donee/Resolver.php
Resolver.getResolverHandlerChain
private function getResolverHandlerChain() { $randomResolver = $this->resolverFactory->create(Random::class); $nonMutualResolver = $this->resolverFactory->create(NonMutual::class, $randomResolver); return $this->resolverFactory->create(FromExistingPair::class, $nonMutualResolver); }
php
private function getResolverHandlerChain() { $randomResolver = $this->resolverFactory->create(Random::class); $nonMutualResolver = $this->resolverFactory->create(NonMutual::class, $randomResolver); return $this->resolverFactory->create(FromExistingPair::class, $nonMutualResolver); }
[ "private", "function", "getResolverHandlerChain", "(", ")", "{", "$", "randomResolver", "=", "$", "this", "->", "resolverFactory", "->", "create", "(", "Random", "::", "class", ")", ";", "$", "nonMutualResolver", "=", "$", "this", "->", "resolverFactory", "->", "create", "(", "NonMutual", "::", "class", ",", "$", "randomResolver", ")", ";", "return", "$", "this", "->", "resolverFactory", "->", "create", "(", "FromExistingPair", "::", "class", ",", "$", "nonMutualResolver", ")", ";", "}" ]
Builds and returns the resolver handler chain @return ResolverHandlerInterface
[ "Builds", "and", "returns", "the", "resolver", "handler", "chain" ]
7f85f2b45bdf5ed9fa9d320c805c416bf99cd668
https://github.com/DreadLabs/VantomasWebsite/blob/7f85f2b45bdf5ed9fa9d320c805c416bf99cd668/src/SecretSanta/Donee/Resolver.php#L93-L99
train
BapCat/Remodel
src/Registry.php
Registry.register
public function register(EntityDefinition $builder): void { $this->defs[$builder->full_name] = $builder; $this->unchecked[] = $builder; $binding_name = str_replace('\\', '.', $builder->full_name); $this->ioc->bind('bap.remodel.scopes.' . $binding_name, function() use($builder) { return $builder->scopes; }); foreach($builder->virtuals as $virtual) { $this->ioc->bind("bap.remodel.virtuals.{$binding_name}.{$virtual->alias}", function() use($virtual) { return $virtual->callback; }); } $this->tailor->bindCallback($builder->full_name, function(Generator $gen) use($builder): void { $this->checkDefinitions(); $file = $gen->generate('Entity', $builder->toArray()); $gen->includeFile($file); }); foreach(static::CLASS_SUFFIXES as $class) { $this->tailor->bindCallback($builder->full_name . $class, function(Generator $gen) use($builder, $class): void { $this->checkDefinitions(); $file = $gen->generate($class, $builder->toArray()); $gen->includeFile($file); }); } }
php
public function register(EntityDefinition $builder): void { $this->defs[$builder->full_name] = $builder; $this->unchecked[] = $builder; $binding_name = str_replace('\\', '.', $builder->full_name); $this->ioc->bind('bap.remodel.scopes.' . $binding_name, function() use($builder) { return $builder->scopes; }); foreach($builder->virtuals as $virtual) { $this->ioc->bind("bap.remodel.virtuals.{$binding_name}.{$virtual->alias}", function() use($virtual) { return $virtual->callback; }); } $this->tailor->bindCallback($builder->full_name, function(Generator $gen) use($builder): void { $this->checkDefinitions(); $file = $gen->generate('Entity', $builder->toArray()); $gen->includeFile($file); }); foreach(static::CLASS_SUFFIXES as $class) { $this->tailor->bindCallback($builder->full_name . $class, function(Generator $gen) use($builder, $class): void { $this->checkDefinitions(); $file = $gen->generate($class, $builder->toArray()); $gen->includeFile($file); }); } }
[ "public", "function", "register", "(", "EntityDefinition", "$", "builder", ")", ":", "void", "{", "$", "this", "->", "defs", "[", "$", "builder", "->", "full_name", "]", "=", "$", "builder", ";", "$", "this", "->", "unchecked", "[", "]", "=", "$", "builder", ";", "$", "binding_name", "=", "str_replace", "(", "'\\\\'", ",", "'.'", ",", "$", "builder", "->", "full_name", ")", ";", "$", "this", "->", "ioc", "->", "bind", "(", "'bap.remodel.scopes.'", ".", "$", "binding_name", ",", "function", "(", ")", "use", "(", "$", "builder", ")", "{", "return", "$", "builder", "->", "scopes", ";", "}", ")", ";", "foreach", "(", "$", "builder", "->", "virtuals", "as", "$", "virtual", ")", "{", "$", "this", "->", "ioc", "->", "bind", "(", "\"bap.remodel.virtuals.{$binding_name}.{$virtual->alias}\"", ",", "function", "(", ")", "use", "(", "$", "virtual", ")", "{", "return", "$", "virtual", "->", "callback", ";", "}", ")", ";", "}", "$", "this", "->", "tailor", "->", "bindCallback", "(", "$", "builder", "->", "full_name", ",", "function", "(", "Generator", "$", "gen", ")", "use", "(", "$", "builder", ")", ":", "void", "{", "$", "this", "->", "checkDefinitions", "(", ")", ";", "$", "file", "=", "$", "gen", "->", "generate", "(", "'Entity'", ",", "$", "builder", "->", "toArray", "(", ")", ")", ";", "$", "gen", "->", "includeFile", "(", "$", "file", ")", ";", "}", ")", ";", "foreach", "(", "static", "::", "CLASS_SUFFIXES", "as", "$", "class", ")", "{", "$", "this", "->", "tailor", "->", "bindCallback", "(", "$", "builder", "->", "full_name", ".", "$", "class", ",", "function", "(", "Generator", "$", "gen", ")", "use", "(", "$", "builder", ",", "$", "class", ")", ":", "void", "{", "$", "this", "->", "checkDefinitions", "(", ")", ";", "$", "file", "=", "$", "gen", "->", "generate", "(", "$", "class", ",", "$", "builder", "->", "toArray", "(", ")", ")", ";", "$", "gen", "->", "includeFile", "(", "$", "file", ")", ";", "}", ")", ";", "}", "}" ]
Register an Entity definition. Note this method DOES NOT generate the classes. They are generated when needed. @param EntityDefinition $builder @return void
[ "Register", "an", "Entity", "definition", ".", "Note", "this", "method", "DOES", "NOT", "generate", "the", "classes", ".", "They", "are", "generated", "when", "needed", "." ]
80fcdec8bca22b88c5af9a0a93622c796cf3e7b1
https://github.com/BapCat/Remodel/blob/80fcdec8bca22b88c5af9a0a93622c796cf3e7b1/src/Registry.php#L66-L96
train
GrottoPress/wordpress-meta-box
src/lib/MetaBox.php
MetaBox.preSaveChecksPassed
protected function preSaveChecksPassed(int $post_id): bool { if ($post_id < 1) { return false; } if (\defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return false; } if (!\current_user_can( \get_post_type_object(\get_post_type($post_id))->cap->edit_post, $post_id )) { return false; } if (!isset($_POST[$this->nonce]) || !\wp_verify_nonce($_POST[$this->nonce], \basename(__FILE__)) ) { return false; } return true; }
php
protected function preSaveChecksPassed(int $post_id): bool { if ($post_id < 1) { return false; } if (\defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return false; } if (!\current_user_can( \get_post_type_object(\get_post_type($post_id))->cap->edit_post, $post_id )) { return false; } if (!isset($_POST[$this->nonce]) || !\wp_verify_nonce($_POST[$this->nonce], \basename(__FILE__)) ) { return false; } return true; }
[ "protected", "function", "preSaveChecksPassed", "(", "int", "$", "post_id", ")", ":", "bool", "{", "if", "(", "$", "post_id", "<", "1", ")", "{", "return", "false", ";", "}", "if", "(", "\\", "defined", "(", "'DOING_AUTOSAVE'", ")", "&&", "DOING_AUTOSAVE", ")", "{", "return", "false", ";", "}", "if", "(", "!", "\\", "current_user_can", "(", "\\", "get_post_type_object", "(", "\\", "get_post_type", "(", "$", "post_id", ")", ")", "->", "cap", "->", "edit_post", ",", "$", "post_id", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "_POST", "[", "$", "this", "->", "nonce", "]", ")", "||", "!", "\\", "wp_verify_nonce", "(", "$", "_POST", "[", "$", "this", "->", "nonce", "]", ",", "\\", "basename", "(", "__FILE__", ")", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks to perform prior save
[ "Checks", "to", "perform", "prior", "save" ]
c8c498e29da5f91fbc08d357dac3afdb391fc820
https://github.com/GrottoPress/wordpress-meta-box/blob/c8c498e29da5f91fbc08d357dac3afdb391fc820/src/lib/MetaBox.php#L184-L208
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.createTable
public function createTable( $name, array $columns = array(), array $primaryKey = array(), array $foreignKeys = array(), array $indexes = array(), array $checks = array() ) { $table = new Table($name); foreach ($columns as $column) { if (!isset($column['options'])) { $column['options'] = array(); } $table->createColumn($column['name'], $column['type'], $column['options']); } if (!empty($primaryKey)) { if (!isset($primaryKey['name'])) { $primaryKey['name'] = null; } $table->createPrimaryKey($primaryKey['columns'], $primaryKey['name']); } foreach ($foreignKeys as $foreignKey) { if (!isset($foreignKey['name'])) { $foreignKey['name'] = null; } if (!isset($foreignKey['on_delete'])) { $foreignKey['on_delete'] = ForeignKey::RESTRICT; } if (!isset($foreignKey['on_update'])) { $foreignKey['on_update'] = ForeignKey::RESTRICT; } $table->createForeignKey( $foreignKey['local_columns'], $foreignKey['foreign_table'], $foreignKey['foreign_columns'], $foreignKey['on_delete'], $foreignKey['on_update'], $foreignKey['name'] ); } foreach ($indexes as $index) { if (!isset($index['name'])) { $index['name'] = null; } if (!isset($index['unique'])) { $index['unique'] = false; } $table->createIndex($index['columns'], $index['unique'], $index['name']); } foreach ($checks as $check) { if (!isset($check['name'])) { $check['name'] = null; } $table->createCheck($check['definition'], $check['name']); } $this->addTable($table); return $table; }
php
public function createTable( $name, array $columns = array(), array $primaryKey = array(), array $foreignKeys = array(), array $indexes = array(), array $checks = array() ) { $table = new Table($name); foreach ($columns as $column) { if (!isset($column['options'])) { $column['options'] = array(); } $table->createColumn($column['name'], $column['type'], $column['options']); } if (!empty($primaryKey)) { if (!isset($primaryKey['name'])) { $primaryKey['name'] = null; } $table->createPrimaryKey($primaryKey['columns'], $primaryKey['name']); } foreach ($foreignKeys as $foreignKey) { if (!isset($foreignKey['name'])) { $foreignKey['name'] = null; } if (!isset($foreignKey['on_delete'])) { $foreignKey['on_delete'] = ForeignKey::RESTRICT; } if (!isset($foreignKey['on_update'])) { $foreignKey['on_update'] = ForeignKey::RESTRICT; } $table->createForeignKey( $foreignKey['local_columns'], $foreignKey['foreign_table'], $foreignKey['foreign_columns'], $foreignKey['on_delete'], $foreignKey['on_update'], $foreignKey['name'] ); } foreach ($indexes as $index) { if (!isset($index['name'])) { $index['name'] = null; } if (!isset($index['unique'])) { $index['unique'] = false; } $table->createIndex($index['columns'], $index['unique'], $index['name']); } foreach ($checks as $check) { if (!isset($check['name'])) { $check['name'] = null; } $table->createCheck($check['definition'], $check['name']); } $this->addTable($table); return $table; }
[ "public", "function", "createTable", "(", "$", "name", ",", "array", "$", "columns", "=", "array", "(", ")", ",", "array", "$", "primaryKey", "=", "array", "(", ")", ",", "array", "$", "foreignKeys", "=", "array", "(", ")", ",", "array", "$", "indexes", "=", "array", "(", ")", ",", "array", "$", "checks", "=", "array", "(", ")", ")", "{", "$", "table", "=", "new", "Table", "(", "$", "name", ")", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "if", "(", "!", "isset", "(", "$", "column", "[", "'options'", "]", ")", ")", "{", "$", "column", "[", "'options'", "]", "=", "array", "(", ")", ";", "}", "$", "table", "->", "createColumn", "(", "$", "column", "[", "'name'", "]", ",", "$", "column", "[", "'type'", "]", ",", "$", "column", "[", "'options'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "primaryKey", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "primaryKey", "[", "'name'", "]", ")", ")", "{", "$", "primaryKey", "[", "'name'", "]", "=", "null", ";", "}", "$", "table", "->", "createPrimaryKey", "(", "$", "primaryKey", "[", "'columns'", "]", ",", "$", "primaryKey", "[", "'name'", "]", ")", ";", "}", "foreach", "(", "$", "foreignKeys", "as", "$", "foreignKey", ")", "{", "if", "(", "!", "isset", "(", "$", "foreignKey", "[", "'name'", "]", ")", ")", "{", "$", "foreignKey", "[", "'name'", "]", "=", "null", ";", "}", "if", "(", "!", "isset", "(", "$", "foreignKey", "[", "'on_delete'", "]", ")", ")", "{", "$", "foreignKey", "[", "'on_delete'", "]", "=", "ForeignKey", "::", "RESTRICT", ";", "}", "if", "(", "!", "isset", "(", "$", "foreignKey", "[", "'on_update'", "]", ")", ")", "{", "$", "foreignKey", "[", "'on_update'", "]", "=", "ForeignKey", "::", "RESTRICT", ";", "}", "$", "table", "->", "createForeignKey", "(", "$", "foreignKey", "[", "'local_columns'", "]", ",", "$", "foreignKey", "[", "'foreign_table'", "]", ",", "$", "foreignKey", "[", "'foreign_columns'", "]", ",", "$", "foreignKey", "[", "'on_delete'", "]", ",", "$", "foreignKey", "[", "'on_update'", "]", ",", "$", "foreignKey", "[", "'name'", "]", ")", ";", "}", "foreach", "(", "$", "indexes", "as", "$", "index", ")", "{", "if", "(", "!", "isset", "(", "$", "index", "[", "'name'", "]", ")", ")", "{", "$", "index", "[", "'name'", "]", "=", "null", ";", "}", "if", "(", "!", "isset", "(", "$", "index", "[", "'unique'", "]", ")", ")", "{", "$", "index", "[", "'unique'", "]", "=", "false", ";", "}", "$", "table", "->", "createIndex", "(", "$", "index", "[", "'columns'", "]", ",", "$", "index", "[", "'unique'", "]", ",", "$", "index", "[", "'name'", "]", ")", ";", "}", "foreach", "(", "$", "checks", "as", "$", "check", ")", "{", "if", "(", "!", "isset", "(", "$", "check", "[", "'name'", "]", ")", ")", "{", "$", "check", "[", "'name'", "]", "=", "null", ";", "}", "$", "table", "->", "createCheck", "(", "$", "check", "[", "'definition'", "]", ",", "$", "check", "[", "'name'", "]", ")", ";", "}", "$", "this", "->", "addTable", "(", "$", "table", ")", ";", "return", "$", "table", ";", "}" ]
Creates and adds a new table. @param string $name The table name. @param array $columns The table columns. @param array $primaryKey The table primary key. @param array $foreignKeys The table foreign keys. @param array $indexes The table indexes. @param array $checks The table checks. @return \Fridge\DBAL\Schema\Table The new table.
[ "Creates", "and", "adds", "a", "new", "table", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L61-L133
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.setTables
public function setTables(array $tables) { $this->tables = array(); foreach ($tables as $table) { $this->addTable($table); } }
php
public function setTables(array $tables) { $this->tables = array(); foreach ($tables as $table) { $this->addTable($table); } }
[ "public", "function", "setTables", "(", "array", "$", "tables", ")", "{", "$", "this", "->", "tables", "=", "array", "(", ")", ";", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "$", "this", "->", "addTable", "(", "$", "table", ")", ";", "}", "}" ]
Sets the schema tables. @param array $tables The schema tables.
[ "Sets", "the", "schema", "tables", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L160-L167
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.getTable
public function getTable($name) { if (!$this->hasTable($name)) { throw SchemaException::schemaTableDoesNotExist($this->getName(), $name); } return $this->tables[$name]; }
php
public function getTable($name) { if (!$this->hasTable($name)) { throw SchemaException::schemaTableDoesNotExist($this->getName(), $name); } return $this->tables[$name]; }
[ "public", "function", "getTable", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasTable", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "schemaTableDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "return", "$", "this", "->", "tables", "[", "$", "name", "]", ";", "}" ]
Gets a table. @param string $name The table name. @throws \Fridge\DBAL\Exception\SchemaException If the table does not exist. @return \Fridge\DBAL\Schema\Table The table.
[ "Gets", "a", "table", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L190-L197
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.addTable
public function addTable(Table $table) { if ($this->hasTable($table->getName())) { throw SchemaException::schemaTableAlreadyExists($this->getName(), $table->getName()); } $this->tables[$table->getName()] = $table; if ($table->getSchema() !== $this) { $table->setSchema($this); } }
php
public function addTable(Table $table) { if ($this->hasTable($table->getName())) { throw SchemaException::schemaTableAlreadyExists($this->getName(), $table->getName()); } $this->tables[$table->getName()] = $table; if ($table->getSchema() !== $this) { $table->setSchema($this); } }
[ "public", "function", "addTable", "(", "Table", "$", "table", ")", "{", "if", "(", "$", "this", "->", "hasTable", "(", "$", "table", "->", "getName", "(", ")", ")", ")", "{", "throw", "SchemaException", "::", "schemaTableAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "table", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "tables", "[", "$", "table", "->", "getName", "(", ")", "]", "=", "$", "table", ";", "if", "(", "$", "table", "->", "getSchema", "(", ")", "!==", "$", "this", ")", "{", "$", "table", "->", "setSchema", "(", "$", "this", ")", ";", "}", "}" ]
Adds a table to the schema. @param \Fridge\DBAL\Schema\Table $table The table to add. @throws \Fridge\DBAL\Exception\SchemaException If the table already exists.
[ "Adds", "a", "table", "to", "the", "schema", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L206-L217
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.createSequence
public function createSequence($name, $initialValue = 1, $incrementSize = 1) { $sequence = new Sequence($name, $initialValue, $incrementSize); $this->addSequence($sequence); return $sequence; }
php
public function createSequence($name, $initialValue = 1, $incrementSize = 1) { $sequence = new Sequence($name, $initialValue, $incrementSize); $this->addSequence($sequence); return $sequence; }
[ "public", "function", "createSequence", "(", "$", "name", ",", "$", "initialValue", "=", "1", ",", "$", "incrementSize", "=", "1", ")", "{", "$", "sequence", "=", "new", "Sequence", "(", "$", "name", ",", "$", "initialValue", ",", "$", "incrementSize", ")", ";", "$", "this", "->", "addSequence", "(", "$", "sequence", ")", ";", "return", "$", "sequence", ";", "}" ]
Creates and adds a new sequence. @param string $name The sequence name. @param integer $initialValue The sequence initial value. @param integer $incrementSize The sequence increment size. @return \Fridge\DBAL\Schema\Sequence The new sequence.
[ "Creates", "and", "adds", "a", "new", "sequence", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L269-L275
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.setSequences
public function setSequences(array $sequences) { $this->sequences = array(); foreach ($sequences as $sequence) { $this->addSequence($sequence); } }
php
public function setSequences(array $sequences) { $this->sequences = array(); foreach ($sequences as $sequence) { $this->addSequence($sequence); } }
[ "public", "function", "setSequences", "(", "array", "$", "sequences", ")", "{", "$", "this", "->", "sequences", "=", "array", "(", ")", ";", "foreach", "(", "$", "sequences", "as", "$", "sequence", ")", "{", "$", "this", "->", "addSequence", "(", "$", "sequence", ")", ";", "}", "}" ]
Sets the schema sequences. @param array $sequences The schema sequences.
[ "Sets", "the", "schema", "sequences", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L302-L309
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.getSequence
public function getSequence($name) { if (!$this->hasSequence($name)) { throw SchemaException::schemaSequenceDoesNotExist($this->getName(), $name); } return $this->sequences[$name]; }
php
public function getSequence($name) { if (!$this->hasSequence($name)) { throw SchemaException::schemaSequenceDoesNotExist($this->getName(), $name); } return $this->sequences[$name]; }
[ "public", "function", "getSequence", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasSequence", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "schemaSequenceDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "return", "$", "this", "->", "sequences", "[", "$", "name", "]", ";", "}" ]
Gets a sequence. @param string $name The sequence name. @return \Fridge\DBAL\Schema\Sequence The sequence. @throws \Fridge\DBAL\Exception\SchemaException If the sequence does not exist.
[ "Gets", "a", "sequence", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L332-L339
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.addSequence
public function addSequence(Sequence $sequence) { if ($this->hasSequence($sequence->getName())) { throw SchemaException::schemaSequenceAlreadyExists($this->getName(), $sequence->getName()); } $this->sequences[$sequence->getName()] = $sequence; }
php
public function addSequence(Sequence $sequence) { if ($this->hasSequence($sequence->getName())) { throw SchemaException::schemaSequenceAlreadyExists($this->getName(), $sequence->getName()); } $this->sequences[$sequence->getName()] = $sequence; }
[ "public", "function", "addSequence", "(", "Sequence", "$", "sequence", ")", "{", "if", "(", "$", "this", "->", "hasSequence", "(", "$", "sequence", "->", "getName", "(", ")", ")", ")", "{", "throw", "SchemaException", "::", "schemaSequenceAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "sequence", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "sequences", "[", "$", "sequence", "->", "getName", "(", ")", "]", "=", "$", "sequence", ";", "}" ]
Adds a sequence to the schema. @param Fridge\DBAL\Schema\Sequence $sequence The sequence to add. @throws \Fridge\DBAL\Exception\SchemaException If the sequence already exists.
[ "Adds", "a", "sequence", "to", "the", "schema", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L348-L355
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.renameSequence
public function renameSequence($oldName, $newName) { if (!$this->hasSequence($oldName)) { throw SchemaException::schemaSequenceDoesNotExist($this->getName(), $oldName); } if ($this->hasSequence($newName)) { throw SchemaException::schemaSequenceAlreadyExists($this->getName(), $newName); } $this->sequences[$oldName]->setName($newName); $this->sequences[$newName] = $this->sequences[$oldName]; unset($this->sequences[$oldName]); }
php
public function renameSequence($oldName, $newName) { if (!$this->hasSequence($oldName)) { throw SchemaException::schemaSequenceDoesNotExist($this->getName(), $oldName); } if ($this->hasSequence($newName)) { throw SchemaException::schemaSequenceAlreadyExists($this->getName(), $newName); } $this->sequences[$oldName]->setName($newName); $this->sequences[$newName] = $this->sequences[$oldName]; unset($this->sequences[$oldName]); }
[ "public", "function", "renameSequence", "(", "$", "oldName", ",", "$", "newName", ")", "{", "if", "(", "!", "$", "this", "->", "hasSequence", "(", "$", "oldName", ")", ")", "{", "throw", "SchemaException", "::", "schemaSequenceDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "oldName", ")", ";", "}", "if", "(", "$", "this", "->", "hasSequence", "(", "$", "newName", ")", ")", "{", "throw", "SchemaException", "::", "schemaSequenceAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "newName", ")", ";", "}", "$", "this", "->", "sequences", "[", "$", "oldName", "]", "->", "setName", "(", "$", "newName", ")", ";", "$", "this", "->", "sequences", "[", "$", "newName", "]", "=", "$", "this", "->", "sequences", "[", "$", "oldName", "]", ";", "unset", "(", "$", "this", "->", "sequences", "[", "$", "oldName", "]", ")", ";", "}" ]
Renames a sequence. @param string $oldName The old sequence name. @param string $newName The new sequence name. @throws \Fridge\DBAL\Exception\SchemaException If the old sequence does not exist or if the new sequence already exists.
[ "Renames", "a", "sequence", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L366-L380
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.dropSequence
public function dropSequence($name) { if (!$this->hasSequence($name)) { throw SchemaException::schemaSequenceDoesNotExist($this->getName(), $name); } unset($this->sequences[$name]); }
php
public function dropSequence($name) { if (!$this->hasSequence($name)) { throw SchemaException::schemaSequenceDoesNotExist($this->getName(), $name); } unset($this->sequences[$name]); }
[ "public", "function", "dropSequence", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasSequence", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "schemaSequenceDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "unset", "(", "$", "this", "->", "sequences", "[", "$", "name", "]", ")", ";", "}" ]
Drops a sequence. @param string $name The sequence name. @throws \Fridge\DBAL\Exception\SchemaException If the sequence does not exist.
[ "Drops", "a", "sequence", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L389-L396
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.createView
public function createView($name, $sql = null) { $view = new View($name, $sql); $this->addView($view); return $view; }
php
public function createView($name, $sql = null) { $view = new View($name, $sql); $this->addView($view); return $view; }
[ "public", "function", "createView", "(", "$", "name", ",", "$", "sql", "=", "null", ")", "{", "$", "view", "=", "new", "View", "(", "$", "name", ",", "$", "sql", ")", ";", "$", "this", "->", "addView", "(", "$", "view", ")", ";", "return", "$", "view", ";", "}" ]
Creates and adds a new view. @param string $name The view name. @param string $sql The view sql. @return \Fridge\DBAL\Schema\View The new view.
[ "Creates", "and", "adds", "a", "new", "view", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L406-L412
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.setViews
public function setViews(array $views) { $this->views = array(); foreach ($views as $view) { $this->addView($view); } }
php
public function setViews(array $views) { $this->views = array(); foreach ($views as $view) { $this->addView($view); } }
[ "public", "function", "setViews", "(", "array", "$", "views", ")", "{", "$", "this", "->", "views", "=", "array", "(", ")", ";", "foreach", "(", "$", "views", "as", "$", "view", ")", "{", "$", "this", "->", "addView", "(", "$", "view", ")", ";", "}", "}" ]
Sets the schema views. @param array $views The schema views.
[ "Sets", "the", "schema", "views", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L439-L446
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.getView
public function getView($name) { if (!$this->hasView($name)) { throw SchemaException::schemaViewDoesNotExist($this->getName(), $name); } return $this->views[$name]; }
php
public function getView($name) { if (!$this->hasView($name)) { throw SchemaException::schemaViewDoesNotExist($this->getName(), $name); } return $this->views[$name]; }
[ "public", "function", "getView", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasView", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "schemaViewDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "return", "$", "this", "->", "views", "[", "$", "name", "]", ";", "}" ]
Gets a view. @param string $name The view name. @return \Fridge\DBAL\Schema\View The view. @throws \Fridge\DBAL\Exception\SchemaException If the view does not exist.
[ "Gets", "a", "view", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L469-L476
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.addView
public function addView(View $view) { if ($this->hasView($view->getName())) { throw SchemaException::schemaViewAlreadyExists($this->getName(), $view->getName()); } $this->views[$view->getName()] = $view; }
php
public function addView(View $view) { if ($this->hasView($view->getName())) { throw SchemaException::schemaViewAlreadyExists($this->getName(), $view->getName()); } $this->views[$view->getName()] = $view; }
[ "public", "function", "addView", "(", "View", "$", "view", ")", "{", "if", "(", "$", "this", "->", "hasView", "(", "$", "view", "->", "getName", "(", ")", ")", ")", "{", "throw", "SchemaException", "::", "schemaViewAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "view", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "views", "[", "$", "view", "->", "getName", "(", ")", "]", "=", "$", "view", ";", "}" ]
Adds a view to the schema. @param \Fridge\DBAL\Schema\View $view The view to add. @throws \Fridge\DBAL\Exception\SchemaException If the view already exists.
[ "Adds", "a", "view", "to", "the", "schema", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L485-L492
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.renameView
public function renameView($oldName, $newName) { if (!$this->hasView($oldName)) { throw SchemaException::schemaViewDoesNotExist($this->getName(), $oldName); } if ($this->hasView($newName)) { throw SchemaException::schemaViewAlreadyExists($this->getName(), $newName); } $this->views[$oldName]->setName($newName); $this->views[$newName] = $this->views[$oldName]; unset($this->views[$oldName]); }
php
public function renameView($oldName, $newName) { if (!$this->hasView($oldName)) { throw SchemaException::schemaViewDoesNotExist($this->getName(), $oldName); } if ($this->hasView($newName)) { throw SchemaException::schemaViewAlreadyExists($this->getName(), $newName); } $this->views[$oldName]->setName($newName); $this->views[$newName] = $this->views[$oldName]; unset($this->views[$oldName]); }
[ "public", "function", "renameView", "(", "$", "oldName", ",", "$", "newName", ")", "{", "if", "(", "!", "$", "this", "->", "hasView", "(", "$", "oldName", ")", ")", "{", "throw", "SchemaException", "::", "schemaViewDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "oldName", ")", ";", "}", "if", "(", "$", "this", "->", "hasView", "(", "$", "newName", ")", ")", "{", "throw", "SchemaException", "::", "schemaViewAlreadyExists", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "newName", ")", ";", "}", "$", "this", "->", "views", "[", "$", "oldName", "]", "->", "setName", "(", "$", "newName", ")", ";", "$", "this", "->", "views", "[", "$", "newName", "]", "=", "$", "this", "->", "views", "[", "$", "oldName", "]", ";", "unset", "(", "$", "this", "->", "views", "[", "$", "oldName", "]", ")", ";", "}" ]
Renames a view. @param string $oldName The old view name. @param string $newName The new view name. @throws \Fridge\DBAL\Exception\SchemaException If the old view does not exist or if the new view already exists.
[ "Renames", "a", "view", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L502-L516
train
fridge-project/dbal
src/Fridge/DBAL/Schema/Schema.php
Schema.dropView
public function dropView($name) { if (!$this->hasView($name)) { throw SchemaException::schemaViewDoesNotExist($this->getName(), $name); } unset($this->views[$name]); }
php
public function dropView($name) { if (!$this->hasView($name)) { throw SchemaException::schemaViewDoesNotExist($this->getName(), $name); } unset($this->views[$name]); }
[ "public", "function", "dropView", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasView", "(", "$", "name", ")", ")", "{", "throw", "SchemaException", "::", "schemaViewDoesNotExist", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "name", ")", ";", "}", "unset", "(", "$", "this", "->", "views", "[", "$", "name", "]", ")", ";", "}" ]
Drops a view. @param string $name The view name. @throws \Fridge\DBAL\Exception\SchemaException If the view does not exist.
[ "Drops", "a", "view", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Schema.php#L525-L532
train
mossphp/moss-storage
Moss/Storage/Model/Definition/Field.php
Field.prepareAttributes
protected function prepareAttributes(array $attributes) { foreach ($attributes as $key => $value) { if (is_numeric($key)) { unset($attributes[$key]); $attributes[$value] = true; continue; } } if (isset($attributes['null'])) { unset($attributes['null']); $attributes['notnull'] = false; } return $attributes; }
php
protected function prepareAttributes(array $attributes) { foreach ($attributes as $key => $value) { if (is_numeric($key)) { unset($attributes[$key]); $attributes[$value] = true; continue; } } if (isset($attributes['null'])) { unset($attributes['null']); $attributes['notnull'] = false; } return $attributes; }
[ "protected", "function", "prepareAttributes", "(", "array", "$", "attributes", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "unset", "(", "$", "attributes", "[", "$", "key", "]", ")", ";", "$", "attributes", "[", "$", "value", "]", "=", "true", ";", "continue", ";", "}", "}", "if", "(", "isset", "(", "$", "attributes", "[", "'null'", "]", ")", ")", "{", "unset", "(", "$", "attributes", "[", "'null'", "]", ")", ";", "$", "attributes", "[", "'notnull'", "]", "=", "false", ";", "}", "return", "$", "attributes", ";", "}" ]
Prepares attributes, changes them into key value pairs @param array $attributes @return array
[ "Prepares", "attributes", "changes", "them", "into", "key", "value", "pairs" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Definition/Field.php#L51-L67
train
mossphp/moss-storage
Moss/Storage/Model/Definition/Field.php
Field.table
public function table($table = null) { if ($table !== null) { $this->table = $table; } return $this->table; }
php
public function table($table = null) { if ($table !== null) { $this->table = $table; } return $this->table; }
[ "public", "function", "table", "(", "$", "table", "=", "null", ")", "{", "if", "(", "$", "table", "!==", "null", ")", "{", "$", "this", "->", "table", "=", "$", "table", ";", "}", "return", "$", "this", "->", "table", ";", "}" ]
Returns table owning the field @param null|string $table @return string
[ "Returns", "table", "owning", "the", "field" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Definition/Field.php#L76-L83
train
AmericanCouncils/WebServicesBundle
Negotiator.php
Negotiator.negotiateRequestFormat
public function negotiateRequestFormat(Request $req) { $header = $req->headers->get('Content-Type'); $exp = explode(';', $header); $type = $exp[0]; return isset($this->inputFormatMap[$type]) ? $this->inputFormatMap[$type] : false; }
php
public function negotiateRequestFormat(Request $req) { $header = $req->headers->get('Content-Type'); $exp = explode(';', $header); $type = $exp[0]; return isset($this->inputFormatMap[$type]) ? $this->inputFormatMap[$type] : false; }
[ "public", "function", "negotiateRequestFormat", "(", "Request", "$", "req", ")", "{", "$", "header", "=", "$", "req", "->", "headers", "->", "get", "(", "'Content-Type'", ")", ";", "$", "exp", "=", "explode", "(", "';'", ",", "$", "header", ")", ";", "$", "type", "=", "$", "exp", "[", "0", "]", ";", "return", "isset", "(", "$", "this", "->", "inputFormatMap", "[", "$", "type", "]", ")", "?", "$", "this", "->", "inputFormatMap", "[", "$", "type", "]", ":", "false", ";", "}" ]
Return the incoming format, derived from the Requests content-type header. Generally this is used for determing which format to use during deserialization. @param Request $req @return string
[ "Return", "the", "incoming", "format", "derived", "from", "the", "Requests", "content", "-", "type", "header", ".", "Generally", "this", "is", "used", "for", "determing", "which", "format", "to", "use", "during", "deserialization", "." ]
3f6270ecf31138ba2271a94a407c0d1a05542929
https://github.com/AmericanCouncils/WebServicesBundle/blob/3f6270ecf31138ba2271a94a407c0d1a05542929/Negotiator.php#L74-L82
train
AmericanCouncils/WebServicesBundle
Negotiator.php
Negotiator.negotiateResponseFormat
public function negotiateResponseFormat(Request $req) { return $this->getFormatNegotiator()->getBestFormat($req->headers->get('Accept'), $this->formatPriorities); }
php
public function negotiateResponseFormat(Request $req) { return $this->getFormatNegotiator()->getBestFormat($req->headers->get('Accept'), $this->formatPriorities); }
[ "public", "function", "negotiateResponseFormat", "(", "Request", "$", "req", ")", "{", "return", "$", "this", "->", "getFormatNegotiator", "(", ")", "->", "getBestFormat", "(", "$", "req", "->", "headers", "->", "get", "(", "'Accept'", ")", ",", "$", "this", "->", "formatPriorities", ")", ";", "}" ]
Return the response format type, derived from a Request's Accept header, and configured priorities. @param Request $req @return string
[ "Return", "the", "response", "format", "type", "derived", "from", "a", "Request", "s", "Accept", "header", "and", "configured", "priorities", "." ]
3f6270ecf31138ba2271a94a407c0d1a05542929
https://github.com/AmericanCouncils/WebServicesBundle/blob/3f6270ecf31138ba2271a94a407c0d1a05542929/Negotiator.php#L90-L93
train
AmericanCouncils/WebServicesBundle
Negotiator.php
Negotiator.negotiateResponseLanguage
public function negotiateResponseLanguage(Request $req) { return $this->getLanguageNegotiator()->getBest($req->headers->get('Accept-Language'), $this->langPriorities)->getValue(); }
php
public function negotiateResponseLanguage(Request $req) { return $this->getLanguageNegotiator()->getBest($req->headers->get('Accept-Language'), $this->langPriorities)->getValue(); }
[ "public", "function", "negotiateResponseLanguage", "(", "Request", "$", "req", ")", "{", "return", "$", "this", "->", "getLanguageNegotiator", "(", ")", "->", "getBest", "(", "$", "req", "->", "headers", "->", "get", "(", "'Accept-Language'", ")", ",", "$", "this", "->", "langPriorities", ")", "->", "getValue", "(", ")", ";", "}" ]
Return preferred language, derived from Requests Accept-Language header, and configured priorities. @param Request $req @return string
[ "Return", "preferred", "language", "derived", "from", "Requests", "Accept", "-", "Language", "header", "and", "configured", "priorities", "." ]
3f6270ecf31138ba2271a94a407c0d1a05542929
https://github.com/AmericanCouncils/WebServicesBundle/blob/3f6270ecf31138ba2271a94a407c0d1a05542929/Negotiator.php#L101-L104
train
LCPHP/php-wechat-sdk
src/Wechat.php
Wechat.http_get
public function http_get($url, $data_type='json') { $cl = curl_init(); if(stripos($url, 'https://') !== FALSE) { curl_setopt($cl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($cl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($cl, CURLOPT_SSLVERSION, 1); } curl_setopt($cl, CURLOPT_URL, $url); curl_setopt($cl, CURLOPT_RETURNTRANSFER, 1 ); $content = curl_exec($cl); $status = curl_getinfo($cl); curl_close($cl); if (isset($status['http_code']) && $status['http_code'] == 200) { if ($data_type == 'json') { $content = json_decode($content , true); } return $content; } else { return FALSE; } }
php
public function http_get($url, $data_type='json') { $cl = curl_init(); if(stripos($url, 'https://') !== FALSE) { curl_setopt($cl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($cl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($cl, CURLOPT_SSLVERSION, 1); } curl_setopt($cl, CURLOPT_URL, $url); curl_setopt($cl, CURLOPT_RETURNTRANSFER, 1 ); $content = curl_exec($cl); $status = curl_getinfo($cl); curl_close($cl); if (isset($status['http_code']) && $status['http_code'] == 200) { if ($data_type == 'json') { $content = json_decode($content , true); } return $content; } else { return FALSE; } }
[ "public", "function", "http_get", "(", "$", "url", ",", "$", "data_type", "=", "'json'", ")", "{", "$", "cl", "=", "curl_init", "(", ")", ";", "if", "(", "stripos", "(", "$", "url", ",", "'https://'", ")", "!==", "FALSE", ")", "{", "curl_setopt", "(", "$", "cl", ",", "CURLOPT_SSL_VERIFYPEER", ",", "FALSE", ")", ";", "curl_setopt", "(", "$", "cl", ",", "CURLOPT_SSL_VERIFYHOST", ",", "FALSE", ")", ";", "curl_setopt", "(", "$", "cl", ",", "CURLOPT_SSLVERSION", ",", "1", ")", ";", "}", "curl_setopt", "(", "$", "cl", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "curl_setopt", "(", "$", "cl", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "$", "content", "=", "curl_exec", "(", "$", "cl", ")", ";", "$", "status", "=", "curl_getinfo", "(", "$", "cl", ")", ";", "curl_close", "(", "$", "cl", ")", ";", "if", "(", "isset", "(", "$", "status", "[", "'http_code'", "]", ")", "&&", "$", "status", "[", "'http_code'", "]", "==", "200", ")", "{", "if", "(", "$", "data_type", "==", "'json'", ")", "{", "$", "content", "=", "json_decode", "(", "$", "content", ",", "true", ")", ";", "}", "return", "$", "content", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}" ]
http curl get @param string $url @param string $data_type @return mixed|boolean
[ "http", "curl", "get" ]
0dc164fc462d5fdae7d9c5c35f96c1b227e42db3
https://github.com/LCPHP/php-wechat-sdk/blob/0dc164fc462d5fdae7d9c5c35f96c1b227e42db3/src/Wechat.php#L345-L366
train
Stinger-Soft/PlatformBundle
Controller/BaseController.php
BaseController.hasRole
protected function hasRole($role) { if(!$this->container->has('security.authorization_checker')) { throw new \LogicException('The SecurityBundle is not registered in your application.'); } return false !== $this->get('security.authorization_checker')->isGranted($role); }
php
protected function hasRole($role) { if(!$this->container->has('security.authorization_checker')) { throw new \LogicException('The SecurityBundle is not registered in your application.'); } return false !== $this->get('security.authorization_checker')->isGranted($role); }
[ "protected", "function", "hasRole", "(", "$", "role", ")", "{", "if", "(", "!", "$", "this", "->", "container", "->", "has", "(", "'security.authorization_checker'", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'The SecurityBundle is not registered in your application.'", ")", ";", "}", "return", "false", "!==", "$", "this", "->", "get", "(", "'security.authorization_checker'", ")", "->", "isGranted", "(", "$", "role", ")", ";", "}" ]
Checks whether the current user has the specified role or not @param string $role @throws \LogicException @return boolean
[ "Checks", "whether", "the", "current", "user", "has", "the", "specified", "role", "or", "not" ]
922b9405e5ddc474f288b6be84af2de9a335ac28
https://github.com/Stinger-Soft/PlatformBundle/blob/922b9405e5ddc474f288b6be84af2de9a335ac28/Controller/BaseController.php#L120-L125
train
Eden-PHP/Block
Field.php
Field.button
public function button($value, $name = null) { Argument::i() ->test(1, 'string') ->test(2, 'string', 'null') ->test(3, 'bool'); $field = Button::i()->setValue($value); if(!is_null($name)) { $field->setName($name); } return $field; }
php
public function button($value, $name = null) { Argument::i() ->test(1, 'string') ->test(2, 'string', 'null') ->test(3, 'bool'); $field = Button::i()->setValue($value); if(!is_null($name)) { $field->setName($name); } return $field; }
[ "public", "function", "button", "(", "$", "value", ",", "$", "name", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ")", "->", "test", "(", "2", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "3", ",", "'bool'", ")", ";", "$", "field", "=", "Button", "::", "i", "(", ")", "->", "setValue", "(", "$", "value", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a ui button field @param string @param string|null @param bool @return Eden\Block\Field\Button
[ "Returns", "a", "ui", "button", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L51-L65
train
Eden-PHP/Block
Field.php
Field.checkbox
public function checkbox($name = null, $value = null, $items = array()) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'array', 'null') ->test(3, 'string', 'array'); $field = Checkbox::i()->setItems($items); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function checkbox($name = null, $value = null, $items = array()) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'array', 'null') ->test(3, 'string', 'array'); $field = Checkbox::i()->setItems($items); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "checkbox", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ",", "$", "items", "=", "array", "(", ")", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'array'", ",", "'null'", ")", "->", "test", "(", "3", ",", "'string'", ",", "'array'", ")", ";", "$", "field", "=", "Checkbox", "::", "i", "(", ")", "->", "setItems", "(", "$", "items", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a checkbox field or fieldset @param string|null @param array @param scalar|null @return Eden\Block\Field\Checkbox
[ "Returns", "a", "checkbox", "field", "or", "fieldset" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L75-L93
train
Eden-PHP/Block
Field.php
Field.password
public function password($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Password::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function password($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Password::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "password", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Password", "::", "i", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a password field @param string|null @param scalar|null @return Eden\Block\Field\Text
[ "Returns", "a", "password", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L102-L119
train
Eden-PHP/Block
Field.php
Field.radio
public function radio($name = null, $value = null, array $items = array()) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Radio::i($name)->setItems($items); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function radio($name = null, $value = null, array $items = array()) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Radio::i($name)->setItems($items); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "radio", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ",", "array", "$", "items", "=", "array", "(", ")", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Radio", "::", "i", "(", "$", "name", ")", "->", "setItems", "(", "$", "items", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a radio fieldset @param string|null @param array @param scalar|null @return Eden\Block\Field\Radio
[ "Returns", "a", "radio", "fieldset" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L129-L146
train
Eden-PHP/Block
Field.php
Field.select
public function select($name = null, $value = null, array $items = array()) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Select::i()->setItems($items); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function select($name = null, $value = null, array $items = array()) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Select::i()->setItems($items); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "select", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ",", "array", "$", "items", "=", "array", "(", ")", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Select", "::", "i", "(", ")", "->", "setItems", "(", "$", "items", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a select field @param string|null @param array @param scalar|null @return Eden\Block\Field\Select
[ "Returns", "a", "select", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L156-L173
train
Eden-PHP/Block
Field.php
Field.submit
public function submit($value, $name = null, $image = null) { Argument::i() ->test(1, 'string') ->test(2, 'string', 'null'); $field = Submit::i()->setValue($value); if(!is_null($name)) { $field->setName($name); } if($image) { $field->setImage($image); } return $field; }
php
public function submit($value, $name = null, $image = null) { Argument::i() ->test(1, 'string') ->test(2, 'string', 'null'); $field = Submit::i()->setValue($value); if(!is_null($name)) { $field->setName($name); } if($image) { $field->setImage($image); } return $field; }
[ "public", "function", "submit", "(", "$", "value", ",", "$", "name", "=", "null", ",", "$", "image", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ")", "->", "test", "(", "2", ",", "'string'", ",", "'null'", ")", ";", "$", "field", "=", "Submit", "::", "i", "(", ")", "->", "setValue", "(", "$", "value", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "$", "image", ")", "{", "$", "field", "->", "setImage", "(", "$", "image", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a submit field @param string @param scalar|null @param string|null @return Eden\Block\Field\Submit
[ "Returns", "a", "submit", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L183-L200
train
Eden-PHP/Block
Field.php
Field.mask
public function mask($pattern, $placeholder = null, $name = null, $value = null) { Argument::i() ->test(1, 'string') ->test(2, 'string', 'null') ->test(3, 'string', 'null') ->test(4, 'scalar', 'null'); $field = Mask::i()->setPattern($pattern); if(!is_null($name)) { $field->setName($name); } if(!is_null($placeholder)){ $field->setHolder($placeholder); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function mask($pattern, $placeholder = null, $name = null, $value = null) { Argument::i() ->test(1, 'string') ->test(2, 'string', 'null') ->test(3, 'string', 'null') ->test(4, 'scalar', 'null'); $field = Mask::i()->setPattern($pattern); if(!is_null($name)) { $field->setName($name); } if(!is_null($placeholder)){ $field->setHolder($placeholder); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "mask", "(", "$", "pattern", ",", "$", "placeholder", "=", "null", ",", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ")", "->", "test", "(", "2", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "3", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "4", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Mask", "::", "i", "(", ")", "->", "setPattern", "(", "$", "pattern", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "placeholder", ")", ")", "{", "$", "field", "->", "setHolder", "(", "$", "placeholder", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns an input mask @param string @param string|null @param string|null @param scalar|null @return Eden\Block\Field\Mask
[ "Returns", "an", "input", "mask" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L211-L234
train
Eden-PHP/Block
Field.php
Field.text
public function text($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Text::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function text($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Text::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "text", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Text", "::", "i", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a text field @param string|null @param scalar|null @return Eden\Block\Field\Text
[ "Returns", "a", "text", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L243-L260
train
Eden-PHP/Block
Field.php
Field.textarea
public function textarea($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Textarea::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function textarea($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Textarea::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "textarea", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Textarea", "::", "i", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a textarea field @param string|null @param scalar|null @return Eden\Block\Field\Textarea
[ "Returns", "a", "textarea", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L269-L286
train
Eden-PHP/Block
Field.php
Field.color
public function color($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'string', 'null'); $field = Color::i($name); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function color($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'string', 'null'); $field = Color::i($name); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "color", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'string'", ",", "'null'", ")", ";", "$", "field", "=", "Color", "::", "i", "(", "$", "name", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a color field @param string|null @param scalar|null @return Eden\Block\Field\Color
[ "Returns", "a", "color", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L321-L338
train
Eden-PHP/Block
Field.php
Field.combobox
public function combobox($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Combobox::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function combobox($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Combobox::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "combobox", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Combobox", "::", "i", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a combobox field @param string|null @param scalar|null @return Eden\Block\Field\Combobox
[ "Returns", "a", "combobox", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L347-L364
train
Eden-PHP/Block
Field.php
Field.datetime
public function datetime($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Datetime::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function datetime($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Datetime::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "datetime", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Datetime", "::", "i", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a datetime field @param string|null @param scalar|null @return Eden\Block\Field\Datetime
[ "Returns", "a", "datetime", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L401-L418
train
Eden-PHP/Block
Field.php
Field.file
public function file($name = null, $multiple = false, array $accept = array()) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'bool'); $field = File::i(); if(!is_null($name)) { $field->setName($name); } if($multiple) { $field->setAttributes('multiple', 'multiple'); } if(!empty($accept)) { $field->setAttributes('accept', implode(',', $accept)); } return $field; }
php
public function file($name = null, $multiple = false, array $accept = array()) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'bool'); $field = File::i(); if(!is_null($name)) { $field->setName($name); } if($multiple) { $field->setAttributes('multiple', 'multiple'); } if(!empty($accept)) { $field->setAttributes('accept', implode(',', $accept)); } return $field; }
[ "public", "function", "file", "(", "$", "name", "=", "null", ",", "$", "multiple", "=", "false", ",", "array", "$", "accept", "=", "array", "(", ")", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'bool'", ")", ";", "$", "field", "=", "File", "::", "i", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "$", "multiple", ")", "{", "$", "field", "->", "setAttributes", "(", "'multiple'", ",", "'multiple'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "accept", ")", ")", "{", "$", "field", "->", "setAttributes", "(", "'accept'", ",", "implode", "(", "','", ",", "$", "accept", ")", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a file field @param string|null @param bool @param array @return Eden\Block\Field\File
[ "Returns", "a", "file", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L428-L449
train
Eden-PHP/Block
Field.php
Field.image
public function image($name = null, $multiple = false) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'bool'); $accept = array('image/gif','image/jpg','image/jpeg','image/png'); return $this->file($name, $multiple, $accept); }
php
public function image($name = null, $multiple = false) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'bool'); $accept = array('image/gif','image/jpg','image/jpeg','image/png'); return $this->file($name, $multiple, $accept); }
[ "public", "function", "image", "(", "$", "name", "=", "null", ",", "$", "multiple", "=", "false", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'bool'", ")", ";", "$", "accept", "=", "array", "(", "'image/gif'", ",", "'image/jpg'", ",", "'image/jpeg'", ",", "'image/png'", ")", ";", "return", "$", "this", "->", "file", "(", "$", "name", ",", "$", "multiple", ",", "$", "accept", ")", ";", "}" ]
Returns an image upload field @param string|null @param bool @return Eden\Block\Field\File
[ "Returns", "an", "image", "upload", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L458-L467
train
Eden-PHP/Block
Field.php
Field.markdown
public function markdown($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Markdown::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function markdown($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Markdown::i(); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "markdown", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Markdown", "::", "i", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a Markdown field @param string|null @param scalar|null @return Eden\Block\Field\Markdown
[ "Returns", "a", "Markdown", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L476-L493
train
Eden-PHP/Block
Field.php
Field.slider
public function slider($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Text::i()->setType('range'); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function slider($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Text::i()->setType('range'); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "slider", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Text", "::", "i", "(", ")", "->", "setType", "(", "'range'", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a slider field @param string|null @param scalar|null @return Eden\Block\Field\Text
[ "Returns", "a", "slider", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L502-L519
train
Eden-PHP/Block
Field.php
Field.time
public function time($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Datetime::i() ->setOptions('pickDate', false) ->setOptions('format', 'HH:mm PP'); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
php
public function time($name = null, $value = null) { Argument::i() ->test(1, 'string', 'null') ->test(2, 'scalar', 'null'); $field = Datetime::i() ->setOptions('pickDate', false) ->setOptions('format', 'HH:mm PP'); if(!is_null($name)) { $field->setName($name); } if(!is_null($value)) { $field->setValue($value); } return $field; }
[ "public", "function", "time", "(", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'string'", ",", "'null'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'", ")", ";", "$", "field", "=", "Datetime", "::", "i", "(", ")", "->", "setOptions", "(", "'pickDate'", ",", "false", ")", "->", "setOptions", "(", "'format'", ",", "'HH:mm PP'", ")", ";", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "field", ";", "}" ]
Returns a time field @param string|null @param scalar|null @return Eden\Block\Field\Datetime
[ "Returns", "a", "time", "field" ]
681b9f01dd118612d0fced84d2f702167b52109b
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field.php#L554-L573
train