repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
bolt/bolt
src/Twig/SetcontentNode.php
SetcontentNode.compile
public function compile(Compiler $compiler) { $arguments = $this->getAttribute('arguments'); if ($this->legacy) { $this->compileLegacy($compiler, $arguments); return; } $compiler ->addDebugInfo($this) ->write("\$context['") ...
php
public function compile(Compiler $compiler) { $arguments = $this->getAttribute('arguments'); if ($this->legacy) { $this->compileLegacy($compiler, $arguments); return; } $compiler ->addDebugInfo($this) ->write("\$context['") ...
[ "public", "function", "compile", "(", "Compiler", "$", "compiler", ")", "{", "$", "arguments", "=", "$", "this", "->", "getAttribute", "(", "'arguments'", ")", ";", "if", "(", "$", "this", "->", "legacy", ")", "{", "$", "this", "->", "compileLegacy", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/SetcontentNode.php#L48-L77
bolt/bolt
src/Twig/SetcontentNode.php
SetcontentNode.compileLegacy
private function compileLegacy(Compiler $compiler, Node $arguments) { Deprecated::warn('Calling {{ setcontent }} in legacy storage mode', 3.4, "Set 'compatibility/setcontent_legacy: false' in config.yml"); $compiler ->addDebugInfo($this) ->write("\$context['") ->...
php
private function compileLegacy(Compiler $compiler, Node $arguments) { Deprecated::warn('Calling {{ setcontent }} in legacy storage mode', 3.4, "Set 'compatibility/setcontent_legacy: false' in config.yml"); $compiler ->addDebugInfo($this) ->write("\$context['") ->...
[ "private", "function", "compileLegacy", "(", "Compiler", "$", "compiler", ",", "Node", "$", "arguments", ")", "{", "Deprecated", "::", "warn", "(", "'Calling {{ setcontent }} in legacy storage mode'", ",", "3.4", ",", "\"Set 'compatibility/setcontent_legacy: false' in confi...
@param Compiler $compiler @param Node $arguments @deprecated Deprecated since 3.4, to be removed in 4.0.
[ "@param", "Compiler", "$compiler", "@param", "Node", "$arguments" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/SetcontentNode.php#L85-L108
bolt/bolt
src/Storage/Entity/LogChange.php
LogChange.getChangedFields
public function getChangedFields(array $contentType) { $changedFields = []; if (empty($this->diff)) { return $changedFields; } // Get the ContentType that we're dealing with $fields = $contentType['fields']; $hash = [ 'html' => 'field...
php
public function getChangedFields(array $contentType) { $changedFields = []; if (empty($this->diff)) { return $changedFields; } // Get the ContentType that we're dealing with $fields = $contentType['fields']; $hash = [ 'html' => 'field...
[ "public", "function", "getChangedFields", "(", "array", "$", "contentType", ")", "{", "$", "changedFields", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "this", "->", "diff", ")", ")", "{", "return", "$", "changedFields", ";", "}", "// Get the Conte...
Get changed fields. @param array $contentType @return array
[ "Get", "changed", "fields", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Entity/LogChange.php#L177-L229
bolt/bolt
src/Storage/Entity/LogChange.php
LogChange.fieldList
private function fieldList($key, $value, array $fields) { return [ 'type' => $fields[$key]['type'], 'before' => ['render' => Json::parse($value[0])], 'after' => ['render' => Json::parse($value[1])], ]; }
php
private function fieldList($key, $value, array $fields) { return [ 'type' => $fields[$key]['type'], 'before' => ['render' => Json::parse($value[0])], 'after' => ['render' => Json::parse($value[1])], ]; }
[ "private", "function", "fieldList", "(", "$", "key", ",", "$", "value", ",", "array", "$", "fields", ")", "{", "return", "[", "'type'", "=>", "$", "fields", "[", "$", "key", "]", "[", "'type'", "]", ",", "'before'", "=>", "[", "'render'", "=>", "Js...
Compile changes for list field types. @param string $key @param string $value @param array $fields @return array
[ "Compile", "changes", "for", "list", "field", "types", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Entity/LogChange.php#L254-L261
bolt/bolt
src/Storage/Entity/LogChange.php
LogChange.fieldGeolocation
private function fieldGeolocation($key, $value, array $fields) { $before = Json::parse($value[0]); $after = Json::parse($value[1]); return [ 'type' => $fields[$key]['type'], 'before' => [ 'render' => [ 'address' => $bef...
php
private function fieldGeolocation($key, $value, array $fields) { $before = Json::parse($value[0]); $after = Json::parse($value[1]); return [ 'type' => $fields[$key]['type'], 'before' => [ 'render' => [ 'address' => $bef...
[ "private", "function", "fieldGeolocation", "(", "$", "key", ",", "$", "value", ",", "array", "$", "fields", ")", "{", "$", "before", "=", "Json", "::", "parse", "(", "$", "value", "[", "0", "]", ")", ";", "$", "after", "=", "Json", "::", "parse", ...
Compile changes for geolocation field types. @param string $key @param string $value @param array $fields @return array
[ "Compile", "changes", "for", "geolocation", "field", "types", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Entity/LogChange.php#L272-L296
bolt/bolt
src/Storage/Entity/LogChange.php
LogChange.fieldImage
private function fieldImage($key, $value, array $fields) { $before = Json::parse($value[0]); $after = Json::parse($value[1]); return [ 'type' => $fields[$key]['type'], 'before' => [ 'render' => [ 'file' => $before['file'], ...
php
private function fieldImage($key, $value, array $fields) { $before = Json::parse($value[0]); $after = Json::parse($value[1]); return [ 'type' => $fields[$key]['type'], 'before' => [ 'render' => [ 'file' => $before['file'], ...
[ "private", "function", "fieldImage", "(", "$", "key", ",", "$", "value", ",", "array", "$", "fields", ")", "{", "$", "before", "=", "Json", "::", "parse", "(", "$", "value", "[", "0", "]", ")", ";", "$", "after", "=", "Json", "::", "parse", "(", ...
Compile changes for image field types. @param string $key @param string $value @param array $fields @return array
[ "Compile", "changes", "for", "image", "field", "types", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Entity/LogChange.php#L307-L327
bolt/bolt
src/Storage/Entity/LogChange.php
LogChange.fieldOembed
private function fieldOembed($key, $value, array $fields) { $before = Json::parse($value[0]); $after = Json::parse($value[1]); return [ 'type' => $fields[$key]['type'], 'before' => [ 'render' => [ 'url' => $before['url'...
php
private function fieldOembed($key, $value, array $fields) { $before = Json::parse($value[0]); $after = Json::parse($value[1]); return [ 'type' => $fields[$key]['type'], 'before' => [ 'render' => [ 'url' => $before['url'...
[ "private", "function", "fieldOembed", "(", "$", "key", ",", "$", "value", ",", "array", "$", "fields", ")", "{", "$", "before", "=", "Json", "::", "parse", "(", "$", "value", "[", "0", "]", ")", ";", "$", "after", "=", "Json", "::", "parse", "(",...
Compile changes for embed field types. @param string $key @param string $value @param array $fields @return array
[ "Compile", "changes", "for", "embed", "field", "types", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Entity/LogChange.php#L338-L372
bolt/bolt
src/Storage/Entity/LogChange.php
LogChange.fieldSelect
private function fieldSelect($key, $value, array $fields) { if (isset($fields[$key]['multiple']) && $fields[$key]['multiple']) { $before = $value[0]; $after = $value[1]; } else { $before = $value[0]; $after = $value[1]; } return [ ...
php
private function fieldSelect($key, $value, array $fields) { if (isset($fields[$key]['multiple']) && $fields[$key]['multiple']) { $before = $value[0]; $after = $value[1]; } else { $before = $value[0]; $after = $value[1]; } return [ ...
[ "private", "function", "fieldSelect", "(", "$", "key", ",", "$", "value", ",", "array", "$", "fields", ")", "{", "if", "(", "isset", "(", "$", "fields", "[", "$", "key", "]", "[", "'multiple'", "]", ")", "&&", "$", "fields", "[", "$", "key", "]",...
Compile changes for select field types. @param string $key @param string $value @param array $fields @return array
[ "Compile", "changes", "for", "select", "field", "types", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Entity/LogChange.php#L383-L398
bolt/bolt
src/Storage/Entity/LogChange.php
LogChange.fieldVideo
private function fieldVideo($key, $value, array $fields) { $before = Json::parse($value[0]); $after = Json::parse($value[1]); return [ 'type' => $fields[$key]['type'], 'before' => [ 'render' => [ 'url' => $before['url'], ...
php
private function fieldVideo($key, $value, array $fields) { $before = Json::parse($value[0]); $after = Json::parse($value[1]); return [ 'type' => $fields[$key]['type'], 'before' => [ 'render' => [ 'url' => $before['url'], ...
[ "private", "function", "fieldVideo", "(", "$", "key", ",", "$", "value", ",", "array", "$", "fields", ")", "{", "$", "before", "=", "Json", "::", "parse", "(", "$", "value", "[", "0", "]", ")", ";", "$", "after", "=", "Json", "::", "parse", "(", ...
Compile changes for video field types. @param string $key @param string $value @param array $fields @return array
[ "Compile", "changes", "for", "video", "field", "types", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Entity/LogChange.php#L409-L437
bolt/bolt
src/Storage/Migration/Import.php
Import.run
public function run(Bag $importData, MutableBag $responseBag, $overwrite = false, Bag $importUsers = null) { $this->validateContentTypes($importData); $relationQueue = MutableBag::from([]); if ($importUsers) { $this->importUsers($importUsers, $responseBag); } for...
php
public function run(Bag $importData, MutableBag $responseBag, $overwrite = false, Bag $importUsers = null) { $this->validateContentTypes($importData); $relationQueue = MutableBag::from([]); if ($importUsers) { $this->importUsers($importUsers, $responseBag); } for...
[ "public", "function", "run", "(", "Bag", "$", "importData", ",", "MutableBag", "$", "responseBag", ",", "$", "overwrite", "=", "false", ",", "Bag", "$", "importUsers", "=", "null", ")", "{", "$", "this", "->", "validateContentTypes", "(", "$", "importData"...
@param Bag $importData @param MutableBag $responseBag @param bool $overwrite @param Bag $importUsers @throws \Bolt\Exception\InvalidRepositoryException @return MutableBag
[ "@param", "Bag", "$importData", "@param", "MutableBag", "$responseBag", "@param", "bool", "$overwrite", "@param", "Bag", "$importUsers" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Migration/Import.php#L58-L72
bolt/bolt
src/Storage/Migration/Import.php
Import.importUsers
private function importUsers(Bag $importUsers, MutableBag $responseBag) { /** @var Repository\UsersRepository $repo */ $repo = $this->em->getRepository(Entity\Users::class); foreach ($importUsers as $user) { $entity = new Entity\Users($user->toArrayRecursive()); $ent...
php
private function importUsers(Bag $importUsers, MutableBag $responseBag) { /** @var Repository\UsersRepository $repo */ $repo = $this->em->getRepository(Entity\Users::class); foreach ($importUsers as $user) { $entity = new Entity\Users($user->toArrayRecursive()); $ent...
[ "private", "function", "importUsers", "(", "Bag", "$", "importUsers", ",", "MutableBag", "$", "responseBag", ")", "{", "/** @var Repository\\UsersRepository $repo */", "$", "repo", "=", "$", "this", "->", "em", "->", "getRepository", "(", "Entity", "\\", "Users", ...
@param Bag $importUsers @param MutableBag $responseBag @throws \Bolt\Exception\InvalidRepositoryException
[ "@param", "Bag", "$importUsers", "@param", "MutableBag", "$responseBag" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Migration/Import.php#L80-L95
bolt/bolt
src/Storage/Migration/Import.php
Import.importContentType
private function importContentType( $contentTypeName, Bag $importData, MutableBag $relationQueue, MutableBag $responseBag, $overwrite ) { $count = 0; /** @var Repository $repo */ $repo = $this->em->getRepository($contentTypeName); // Build a l...
php
private function importContentType( $contentTypeName, Bag $importData, MutableBag $relationQueue, MutableBag $responseBag, $overwrite ) { $count = 0; /** @var Repository $repo */ $repo = $this->em->getRepository($contentTypeName); // Build a l...
[ "private", "function", "importContentType", "(", "$", "contentTypeName", ",", "Bag", "$", "importData", ",", "MutableBag", "$", "relationQueue", ",", "MutableBag", "$", "responseBag", ",", "$", "overwrite", ")", "{", "$", "count", "=", "0", ";", "/** @var Repo...
Perform an import for records under a single ContentType key. @param string $contentTypeName @param Bag $importData @param MutableBag $relationQueue @param MutableBag $responseBag @param bool $overwrite @throws \Bolt\Exception\InvalidRepositoryException
[ "Perform", "an", "import", "for", "records", "under", "a", "single", "ContentType", "key", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Migration/Import.php#L108-L157
bolt/bolt
src/Storage/Migration/Import.php
Import.addRelations
private function addRelations(Repository $repo, MutableBag $relationQueue, Bag $importDatum, MutableBag $relationFields) { $classMeta = $repo->getClassMetadata(); foreach ($relationFields as $fieldName) { $relationName = $classMeta->getBoltName() . '/' . $importDatum->get('slug'); ...
php
private function addRelations(Repository $repo, MutableBag $relationQueue, Bag $importDatum, MutableBag $relationFields) { $classMeta = $repo->getClassMetadata(); foreach ($relationFields as $fieldName) { $relationName = $classMeta->getBoltName() . '/' . $importDatum->get('slug'); ...
[ "private", "function", "addRelations", "(", "Repository", "$", "repo", ",", "MutableBag", "$", "relationQueue", ",", "Bag", "$", "importDatum", ",", "MutableBag", "$", "relationFields", ")", "{", "$", "classMeta", "=", "$", "repo", "->", "getClassMetadata", "(...
Queue an entities relations for later processing. @param Repository $repo @param MutableBag $relationQueue @param Bag $importDatum @param MutableBag $relationFields
[ "Queue", "an", "entities", "relations", "for", "later", "processing", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Migration/Import.php#L191-L204
bolt/bolt
src/Storage/Migration/Import.php
Import.processRelationQueue
private function processRelationQueue(Bag $relationQueue) { foreach ($relationQueue as $source => $links) { $entity = $this->query->getContent($source); $relations = []; foreach ($links as $linkKey) { $relation = $this->query->getContent($linkKey); ...
php
private function processRelationQueue(Bag $relationQueue) { foreach ($relationQueue as $source => $links) { $entity = $this->query->getContent($source); $relations = []; foreach ($links as $linkKey) { $relation = $this->query->getContent($linkKey); ...
[ "private", "function", "processRelationQueue", "(", "Bag", "$", "relationQueue", ")", "{", "foreach", "(", "$", "relationQueue", "as", "$", "source", "=>", "$", "links", ")", "{", "$", "entity", "=", "$", "this", "->", "query", "->", "getContent", "(", "...
Since relations can't be processed until we are sure all the individual records are saved this goes through the queue after an import and links up all the related ones. @param Bag $relationQueue
[ "Since", "relations", "can", "t", "be", "processed", "until", "we", "are", "sure", "all", "the", "individual", "records", "are", "saved", "this", "goes", "through", "the", "queue", "after", "an", "import", "and", "links", "up", "all", "the", "related", "on...
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Migration/Import.php#L213-L230
bolt/bolt
src/Storage/Migration/Import.php
Import.validateContentTypes
private function validateContentTypes(Bag $importData) { $contentTypeNames = $this->contentTypes->keys()->toArray(); $importData->filter(function ($k, $v) use ($contentTypeNames) { if (!in_array($k, $contentTypeNames)) { throw new RuntimeException(sprintf('ContentType "%s...
php
private function validateContentTypes(Bag $importData) { $contentTypeNames = $this->contentTypes->keys()->toArray(); $importData->filter(function ($k, $v) use ($contentTypeNames) { if (!in_array($k, $contentTypeNames)) { throw new RuntimeException(sprintf('ContentType "%s...
[ "private", "function", "validateContentTypes", "(", "Bag", "$", "importData", ")", "{", "$", "contentTypeNames", "=", "$", "this", "->", "contentTypes", "->", "keys", "(", ")", "->", "toArray", "(", ")", ";", "$", "importData", "->", "filter", "(", "functi...
Check that the import file's ContentTypes exists. @param Bag $importData @throws RuntimeException
[ "Check", "that", "the", "import", "file", "s", "ContentTypes", "exists", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Migration/Import.php#L239-L247
bolt/bolt
src/Omnisearch.php
Omnisearch.find
private function find($query, $path = 'theme', $name = '*.twig', $contains = false, $priority = 0) { if (!$this->showFiles) { return; } $finder = (new Finder()) ->files() ->ignoreVCS(true) ->notName('*~') ->in($this->app['path_reso...
php
private function find($query, $path = 'theme', $name = '*.twig', $contains = false, $priority = 0) { if (!$this->showFiles) { return; } $finder = (new Finder()) ->files() ->ignoreVCS(true) ->notName('*~') ->in($this->app['path_reso...
[ "private", "function", "find", "(", "$", "query", ",", "$", "path", "=", "'theme'", ",", "$", "name", "=", "'*.twig'", ",", "$", "contains", "=", "false", ",", "$", "priority", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "showFiles", "...
Find in files. @param string $query @param string $path @param string $name @param bool|string $contains @param int $priority
[ "Find", "in", "files", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Omnisearch.php#L314-L354
bolt/bolt
src/Omnisearch.php
Omnisearch.search
private function search($query, $withRecord = false) { if (!$this->showRecords) { return; } $user = $this->app['users']->getCurrentUser(); $isLegacy = $this->app['config']->get('general/compatibility/setcontent_legacy', true); if ($isLegacy) { $searc...
php
private function search($query, $withRecord = false) { if (!$this->showRecords) { return; } $user = $this->app['users']->getCurrentUser(); $isLegacy = $this->app['config']->get('general/compatibility/setcontent_legacy', true); if ($isLegacy) { $searc...
[ "private", "function", "search", "(", "$", "query", ",", "$", "withRecord", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "showRecords", ")", "{", "return", ";", "}", "$", "user", "=", "$", "this", "->", "app", "[", "'users'", "]", "...
Search in database. @param string $query @param bool $withRecord
[ "Search", "in", "database", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Omnisearch.php#L362-L412
bolt/bolt
src/Omnisearch.php
Omnisearch.compareOptions
private function compareOptions($a, $b) { $comparison = $b['priority'] - $a['priority']; if ($comparison == 0) { return strcasecmp($a['path'], $b['path']); } return $comparison; }
php
private function compareOptions($a, $b) { $comparison = $b['priority'] - $a['priority']; if ($comparison == 0) { return strcasecmp($a['path'], $b['path']); } return $comparison; }
[ "private", "function", "compareOptions", "(", "$", "a", ",", "$", "b", ")", "{", "$", "comparison", "=", "$", "b", "[", "'priority'", "]", "-", "$", "a", "[", "'priority'", "]", ";", "if", "(", "$", "comparison", "==", "0", ")", "{", "return", "s...
OmnisearchOption implements Comparable. @param array $a @param array $b @return int
[ "OmnisearchOption", "implements", "Comparable", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Omnisearch.php#L427-L436
bolt/bolt
src/Storage/Collection/Relations.php
Relations.addEntity
protected function addEntity($type, $id, Entity\Content $owner) { $newEntity = new Entity\Relations([ 'from_contenttype' => (string) $owner->getContenttype(), 'from_id' => $owner->getId(), 'to_contenttype' => $type, 'to_id' => $id, ...
php
protected function addEntity($type, $id, Entity\Content $owner) { $newEntity = new Entity\Relations([ 'from_contenttype' => (string) $owner->getContenttype(), 'from_id' => $owner->getId(), 'to_contenttype' => $type, 'to_id' => $id, ...
[ "protected", "function", "addEntity", "(", "$", "type", ",", "$", "id", ",", "Entity", "\\", "Content", "$", "owner", ")", "{", "$", "newEntity", "=", "new", "Entity", "\\", "Relations", "(", "[", "'from_contenttype'", "=>", "(", "string", ")", "$", "o...
Adds a related entity by type, id and owner @param string $type @param int $id @param Entity\Content $owner
[ "Adds", "a", "related", "entity", "by", "type", "id", "and", "owner" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Collection/Relations.php#L79-L88
bolt/bolt
src/Storage/Collection/Relations.php
Relations.associate
public function associate($type, array $items = null) { if ($this->getOwner() === null) { throw new DomainException('Unable to associate relations to a collection that does not have an owning entity!'); } if ($type instanceof Entity\Content) { $this->addEntity((string...
php
public function associate($type, array $items = null) { if ($this->getOwner() === null) { throw new DomainException('Unable to associate relations to a collection that does not have an owning entity!'); } if ($type instanceof Entity\Content) { $this->addEntity((string...
[ "public", "function", "associate", "(", "$", "type", ",", "array", "$", "items", "=", "null", ")", "{", "if", "(", "$", "this", "->", "getOwner", "(", ")", "===", "null", ")", "{", "throw", "new", "DomainException", "(", "'Unable to associate relations to ...
Associate related items by type and identifiers @param string|Entity\Content $type @param array|null $items
[ "Associate", "related", "items", "by", "type", "and", "identifiers" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Collection/Relations.php#L96-L120
bolt/bolt
src/Storage/Collection/Relations.php
Relations.update
public function update(Relations $collection) { $updated = []; // First give priority to already existing entities foreach ($collection as $entity) { $master = $this->getOriginal($entity); $master->setSortorder($entity->getSortorder()); $updated[] = $maste...
php
public function update(Relations $collection) { $updated = []; // First give priority to already existing entities foreach ($collection as $entity) { $master = $this->getOriginal($entity); $master->setSortorder($entity->getSortorder()); $updated[] = $maste...
[ "public", "function", "update", "(", "Relations", "$", "collection", ")", "{", "$", "updated", "=", "[", "]", ";", "// First give priority to already existing entities", "foreach", "(", "$", "collection", "as", "$", "entity", ")", "{", "$", "master", "=", "$",...
Runs a check on an incoming collection to make sure that duplicates are filtered out. Precedence is given to records that are already persisted, with any diff in incoming properties updated. Any records not in the incoming set are deleted from the collection and the deleted ones returned as an array. @param Relations...
[ "Runs", "a", "check", "on", "an", "incoming", "collection", "to", "make", "sure", "that", "duplicates", "are", "filtered", "out", ".", "Precedence", "is", "given", "to", "records", "that", "are", "already", "persisted", "with", "any", "diff", "in", "incoming...
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Collection/Relations.php#L142-L166
bolt/bolt
src/Storage/Collection/Relations.php
Relations.getGrouped
public function getGrouped() { $types = []; $elements = $this->toArray(); /** @var Entity\Relations $element */ foreach ($elements as $element) { $type = $element->get('to_contenttype'); $types[$type][] = $element; } return $types; }
php
public function getGrouped() { $types = []; $elements = $this->toArray(); /** @var Entity\Relations $element */ foreach ($elements as $element) { $type = $element->get('to_contenttype'); $types[$type][] = $element; } return $types; }
[ "public", "function", "getGrouped", "(", ")", "{", "$", "types", "=", "[", "]", ";", "$", "elements", "=", "$", "this", "->", "toArray", "(", ")", ";", "/** @var Entity\\Relations $element */", "foreach", "(", "$", "elements", "as", "$", "element", ")", ...
Get the related types that are in the collection, grouped by ContentType key. @internal @return array
[ "Get", "the", "related", "types", "that", "are", "in", "the", "collection", "grouped", "by", "ContentType", "key", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Collection/Relations.php#L175-L186
bolt/bolt
src/Storage/Collection/Relations.php
Relations.getOriginal
public function getOriginal(Entity\Relations $entity) { foreach ($this as $k => $existing) { if ( $existing->getFromId() == $entity->getFromId() && $existing->getFromContenttype() === $entity->getFromContenttype() && $existing->getToContenttype() =...
php
public function getOriginal(Entity\Relations $entity) { foreach ($this as $k => $existing) { if ( $existing->getFromId() == $entity->getFromId() && $existing->getFromContenttype() === $entity->getFromContenttype() && $existing->getToContenttype() =...
[ "public", "function", "getOriginal", "(", "Entity", "\\", "Relations", "$", "entity", ")", "{", "foreach", "(", "$", "this", "as", "$", "k", "=>", "$", "existing", ")", "{", "if", "(", "$", "existing", "->", "getFromId", "(", ")", "==", "$", "entity"...
This loops over the existing collection to see if the properties in the incoming are already available on a saved record. To do this it checks the four key properties if there's a match it returns the original, otherwise it returns the new and adds the new one to the collection. @param Entity\Relations $entity @retur...
[ "This", "loops", "over", "the", "existing", "collection", "to", "see", "if", "the", "properties", "in", "the", "incoming", "are", "already", "available", "on", "a", "saved", "record", ".", "To", "do", "this", "it", "checks", "the", "four", "key", "properti...
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Collection/Relations.php#L198-L212
bolt/bolt
src/Storage/Collection/Relations.php
Relations.getField
public function getField($fieldName, $biDirectional = false, $contentTypeName = null, $contentTypeId = null) { if ($biDirectional) { $filter = function ($el) use ($fieldName, $contentTypeName, $contentTypeId) { /** @var Entity\Relations $el */ if ($el->getFromCont...
php
public function getField($fieldName, $biDirectional = false, $contentTypeName = null, $contentTypeId = null) { if ($biDirectional) { $filter = function ($el) use ($fieldName, $contentTypeName, $contentTypeId) { /** @var Entity\Relations $el */ if ($el->getFromCont...
[ "public", "function", "getField", "(", "$", "fieldName", ",", "$", "biDirectional", "=", "false", ",", "$", "contentTypeName", "=", "null", ",", "$", "contentTypeId", "=", "null", ")", "{", "if", "(", "$", "biDirectional", ")", "{", "$", "filter", "=", ...
Gets a specific relation type name from the overall collection. @param string $fieldName @param bool $biDirectional @param string $contentTypeName @param int $contentTypeId @return Relations
[ "Gets", "a", "specific", "relation", "type", "name", "from", "the", "overall", "collection", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Collection/Relations.php#L224-L253
bolt/bolt
src/Storage/Collection/Relations.php
Relations.incoming
public function incoming(Entity\Content $entity) { return $this->filter(function ($el) use ($entity) { /** @var Entity\Relations $el */ return $el->getToContenttype() == (string) $entity->getContenttype() && $el->getToId() === $entity->getId(); }); }
php
public function incoming(Entity\Content $entity) { return $this->filter(function ($el) use ($entity) { /** @var Entity\Relations $el */ return $el->getToContenttype() == (string) $entity->getContenttype() && $el->getToId() === $entity->getId(); }); }
[ "public", "function", "incoming", "(", "Entity", "\\", "Content", "$", "entity", ")", "{", "return", "$", "this", "->", "filter", "(", "function", "(", "$", "el", ")", "use", "(", "$", "entity", ")", "{", "/** @var Entity\\Relations $el */", "return", "$",...
Identifies which relations are incoming to the given entity. @param Entity\Content $entity @return mixed
[ "Identifies", "which", "relations", "are", "incoming", "to", "the", "given", "entity", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Collection/Relations.php#L262-L268
bolt/bolt
src/Storage/Collection/Relations.php
Relations.buildLazyCollection
protected function buildLazyCollection($items) { if ($this->em === null) { return parent::getIterator(); } $collection = new LazyCollection(); foreach ($items as $proxy) { $collection->add(new EntityProxy($proxy->to_contenttype, $proxy->to_id, $this->em)); ...
php
protected function buildLazyCollection($items) { if ($this->em === null) { return parent::getIterator(); } $collection = new LazyCollection(); foreach ($items as $proxy) { $collection->add(new EntityProxy($proxy->to_contenttype, $proxy->to_id, $this->em)); ...
[ "protected", "function", "buildLazyCollection", "(", "$", "items", ")", "{", "if", "(", "$", "this", "->", "em", "===", "null", ")", "{", "return", "parent", "::", "getIterator", "(", ")", ";", "}", "$", "collection", "=", "new", "LazyCollection", "(", ...
@param iterable $items @return LazyCollection
[ "@param", "iterable", "$items" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Collection/Relations.php#L296-L308
bolt/bolt
src/Storage/Field/Type/DateType.php
DateType.query
public function query(QueryInterface $query, ClassMetadata $metadata) { $field = $this->mapping['fieldname']; $dateParams = $query->getWhereParametersFor($field); foreach ($dateParams as $key => $val) { $time = strtotime($val); if (!$time) { throw new ...
php
public function query(QueryInterface $query, ClassMetadata $metadata) { $field = $this->mapping['fieldname']; $dateParams = $query->getWhereParametersFor($field); foreach ($dateParams as $key => $val) { $time = strtotime($val); if (!$time) { throw new ...
[ "public", "function", "query", "(", "QueryInterface", "$", "query", ",", "ClassMetadata", "$", "metadata", ")", "{", "$", "field", "=", "$", "this", "->", "mapping", "[", "'fieldname'", "]", ";", "$", "dateParams", "=", "$", "query", "->", "getWhereParamet...
Date fields perform substitution on the parameters passed in to query. To handle this we pass every parameter through `strtotime()` to make sure that it is a valid search. @param QueryInterface $query @param ClassMetadata $metadata @throws QueryParseException @return \Doctrine\DBAL\Query\QueryBuilder|null
[ "Date", "fields", "perform", "substitution", "on", "the", "parameters", "passed", "in", "to", "query", ".", "To", "handle", "this", "we", "pass", "every", "parameter", "through", "strtotime", "()", "to", "make", "sure", "that", "it", "is", "a", "valid", "s...
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Type/DateType.php#L41-L53
bolt/bolt
src/Twig/Runtime/DumpRuntime.php
DumpRuntime.dump
public function dump(Environment $env, $context) { if (!$this->isEnabled($env)) { return null; } if (func_num_args() === 2) { $vars = []; foreach ($context as $key => $value) { if (!$value instanceof Template) { $vars[$...
php
public function dump(Environment $env, $context) { if (!$this->isEnabled($env)) { return null; } if (func_num_args() === 2) { $vars = []; foreach ($context as $key => $value) { if (!$value instanceof Template) { $vars[$...
[ "public", "function", "dump", "(", "Environment", "$", "env", ",", "$", "context", ")", "{", "if", "(", "!", "$", "this", "->", "isEnabled", "(", "$", "env", ")", ")", "{", "return", "null", ";", "}", "if", "(", "func_num_args", "(", ")", "===", ...
@param Environment $env @param mixed $context @return bool|null|string
[ "@param", "Environment", "$env", "@param", "mixed", "$context" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/Runtime/DumpRuntime.php#L51-L79
bolt/bolt
src/Twig/Runtime/DumpRuntime.php
DumpRuntime.dumpBacktrace
public function dumpBacktrace(Environment $env, $context, $depth) { if (!$this->isEnabled($env)) { return null; } return $this->dump($env, $context, debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, $depth)); }
php
public function dumpBacktrace(Environment $env, $context, $depth) { if (!$this->isEnabled($env)) { return null; } return $this->dump($env, $context, debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, $depth)); }
[ "public", "function", "dumpBacktrace", "(", "Environment", "$", "env", ",", "$", "context", ",", "$", "depth", ")", "{", "if", "(", "!", "$", "this", "->", "isEnabled", "(", "$", "env", ")", ")", "{", "return", "null", ";", "}", "return", "$", "thi...
Output pretty-printed backtrace. @param Environment $env @param array $context @param int $depth @return string|null
[ "Output", "pretty", "-", "printed", "backtrace", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/Runtime/DumpRuntime.php#L90-L97
bolt/bolt
src/Twig/Runtime/DumpRuntime.php
DumpRuntime.isEnabled
protected function isEnabled(Environment $env) { return $env->isDebug() && ($this->debugShowLoggedoff || $this->users->getCurrentUser() !== null); }
php
protected function isEnabled(Environment $env) { return $env->isDebug() && ($this->debugShowLoggedoff || $this->users->getCurrentUser() !== null); }
[ "protected", "function", "isEnabled", "(", "Environment", "$", "env", ")", "{", "return", "$", "env", "->", "isDebug", "(", ")", "&&", "(", "$", "this", "->", "debugShowLoggedoff", "||", "$", "this", "->", "users", "->", "getCurrentUser", "(", ")", "!=="...
@param Environment $env @return bool
[ "@param", "Environment", "$env" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/Runtime/DumpRuntime.php#L104-L107
bolt/bolt
src/Storage/Field/Type/JoinTypeBase.php
JoinTypeBase.normalizeData
protected function normalizeData($data, $field, $separator = ',') { $normalized = []; foreach ($data as $key => $value) { if (strpos($key, '_') === 0 && strpos($key, $field) === 1) { $path = explode('_', str_replace('_' . $field, '', $key)); $normalized[$...
php
protected function normalizeData($data, $field, $separator = ',') { $normalized = []; foreach ($data as $key => $value) { if (strpos($key, '_') === 0 && strpos($key, $field) === 1) { $path = explode('_', str_replace('_' . $field, '', $key)); $normalized[$...
[ "protected", "function", "normalizeData", "(", "$", "data", ",", "$", "field", ",", "$", "separator", "=", "','", ")", "{", "$", "normalized", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", ...
This method takes the flat underscore separated key->value data that comes from the query result and turns it into a properly structured array. The second part of the method also removes duplicate values in the case where an aggregate query returns more than one copy of the row. For example, `_from_id => "4,4,4"` gets...
[ "This", "method", "takes", "the", "flat", "underscore", "separated", "key", "-", ">", "value", "data", "that", "comes", "from", "the", "query", "result", "and", "turns", "it", "into", "a", "properly", "structured", "array", ".", "The", "second", "part", "o...
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Type/JoinTypeBase.php#L35-L59
bolt/bolt
src/Storage/Field/Type/JoinTypeBase.php
JoinTypeBase.rewriteQueryFilterParameters
protected function rewriteQueryFilterParameters(Filter $filter, QueryInterface $query, $field, $column) { $originalExpression = $filter->getExpressionObject(); $reflected = new ReflectionProperty(CompositeExpression::class, 'parts'); $reflected->setAccessible(true); $reflected2 = n...
php
protected function rewriteQueryFilterParameters(Filter $filter, QueryInterface $query, $field, $column) { $originalExpression = $filter->getExpressionObject(); $reflected = new ReflectionProperty(CompositeExpression::class, 'parts'); $reflected->setAccessible(true); $reflected2 = n...
[ "protected", "function", "rewriteQueryFilterParameters", "(", "Filter", "$", "filter", ",", "QueryInterface", "$", "query", ",", "$", "field", ",", "$", "column", ")", "{", "$", "originalExpression", "=", "$", "filter", "->", "getExpressionObject", "(", ")", "...
This method does an in-place modification of a generic contenttype.field query to the format actually used in the raw sql category. For instance a simple query might say `entries.tags = 'movies'` but now we are in the context of entries the actual SQL fragment needs to be `tags.slug = 'movies'`. We don't know this unti...
[ "This", "method", "does", "an", "in", "-", "place", "modification", "of", "a", "generic", "contenttype", ".", "field", "query", "to", "the", "format", "actually", "used", "in", "the", "raw", "sql", "category", ".", "For", "instance", "a", "simple", "query"...
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Type/JoinTypeBase.php#L75-L103
bolt/bolt
src/Storage/Field/Type/JoinTypeBase.php
JoinTypeBase.normalizeFromPost
public function normalizeFromPost($entity, $target) { $key = $this->mapping['fieldname']; $accessor = 'get' . ucfirst($key); $outerCollection = $entity->$accessor(); if ($outerCollection === null || $outerCollection instanceof Collections\Collection) { return null; ...
php
public function normalizeFromPost($entity, $target) { $key = $this->mapping['fieldname']; $accessor = 'get' . ucfirst($key); $outerCollection = $entity->$accessor(); if ($outerCollection === null || $outerCollection instanceof Collections\Collection) { return null; ...
[ "public", "function", "normalizeFromPost", "(", "$", "entity", ",", "$", "target", ")", "{", "$", "key", "=", "$", "this", "->", "mapping", "[", "'fieldname'", "]", ";", "$", "accessor", "=", "'get'", ".", "ucfirst", "(", "$", "key", ")", ";", "$", ...
@param object|Entity\Content $entity @param string $target @return Collections\ArrayCollection|null
[ "@param", "object|Entity", "\\", "Content", "$entity", "@param", "string", "$target" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Type/JoinTypeBase.php#L111-L136
bolt/bolt
src/Controller/Backend/FileManager.php
FileManager.edit
public function edit(Request $request, $namespace, $file) { /** @var File $file */ $file = $this->filesystem()->getFile("$namespace://$file"); if (!$file->authorized()) { $this->flashes()->error(Trans::__('general.phrase.access-denied-permissions-edit-file', ['%s' => $file->getP...
php
public function edit(Request $request, $namespace, $file) { /** @var File $file */ $file = $this->filesystem()->getFile("$namespace://$file"); if (!$file->authorized()) { $this->flashes()->error(Trans::__('general.phrase.access-denied-permissions-edit-file', ['%s' => $file->getP...
[ "public", "function", "edit", "(", "Request", "$", "request", ",", "$", "namespace", ",", "$", "file", ")", "{", "/** @var File $file */", "$", "file", "=", "$", "this", "->", "filesystem", "(", ")", "->", "getFile", "(", "\"$namespace://$file\"", ")", ";"...
File editor. @param Request $request The Symfony Request @param string $namespace The filesystem namespace @param string $file The file path @return \Symfony\Component\HttpFoundation\Response
[ "File", "editor", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Controller/Backend/FileManager.php#L65-L121
bolt/bolt
src/Controller/Backend/FileManager.php
FileManager.manage
public function manage(Request $request, $namespace, $path) { $fullPath = "$namespace://$path"; $directory = $this->filesystem()->getDir($fullPath); $listing = new Listing($directory); $showHidden = $this->isAllowed('files:hidden'); if (!$listing->isAuthorized()) { ...
php
public function manage(Request $request, $namespace, $path) { $fullPath = "$namespace://$path"; $directory = $this->filesystem()->getDir($fullPath); $listing = new Listing($directory); $showHidden = $this->isAllowed('files:hidden'); if (!$listing->isAuthorized()) { ...
[ "public", "function", "manage", "(", "Request", "$", "request", ",", "$", "namespace", ",", "$", "path", ")", "{", "$", "fullPath", "=", "\"$namespace://$path\"", ";", "$", "directory", "=", "$", "this", "->", "filesystem", "(", ")", "->", "getDir", "(",...
The file management browser. @param Request $request The Symfony Request @param string $namespace The filesystem namespace @param string $path The path prefix @return \Bolt\Response\TemplateResponse|\Symfony\Component\HttpFoundation\RedirectResponse
[ "The", "file", "management", "browser", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Controller/Backend/FileManager.php#L132-L185
bolt/bolt
src/Controller/Backend/FileManager.php
FileManager.handleEdit
private function handleEdit(FormInterface $form, FileInterface $file) { $data = $form->getData(); $contents = Input::cleanPostedData($data['contents']) . "\n"; // Remove ^M and \r characters from the file. $contents = str_ireplace("\x0D", '', $contents); // Before trying to ...
php
private function handleEdit(FormInterface $form, FileInterface $file) { $data = $form->getData(); $contents = Input::cleanPostedData($data['contents']) . "\n"; // Remove ^M and \r characters from the file. $contents = str_ireplace("\x0D", '', $contents); // Before trying to ...
[ "private", "function", "handleEdit", "(", "FormInterface", "$", "form", ",", "FileInterface", "$", "file", ")", "{", "$", "data", "=", "$", "form", "->", "getData", "(", ")", ";", "$", "contents", "=", "Input", "::", "cleanPostedData", "(", "$", "data", ...
Handle a file edit POST. @param FormInterface $form @param FileInterface $file @return JsonResponse
[ "Handle", "a", "file", "edit", "POST", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Controller/Backend/FileManager.php#L195-L229
bolt/bolt
src/Controller/Backend/FileManager.php
FileManager.handleUpload
private function handleUpload(FormInterface $form, DirectoryInterface $directory) { /** @var UploadedFile[] $files */ $files = $form->get('select')->getData(); $permissions = $this->app['filepermissions']; foreach ($files as $fileToProcess) { $fileToProcess = [ ...
php
private function handleUpload(FormInterface $form, DirectoryInterface $directory) { /** @var UploadedFile[] $files */ $files = $form->get('select')->getData(); $permissions = $this->app['filepermissions']; foreach ($files as $fileToProcess) { $fileToProcess = [ ...
[ "private", "function", "handleUpload", "(", "FormInterface", "$", "form", ",", "DirectoryInterface", "$", "directory", ")", "{", "/** @var UploadedFile[] $files */", "$", "files", "=", "$", "form", "->", "get", "(", "'select'", ")", "->", "getData", "(", ")", ...
Handle the upload POST. @param FormInterface $form @param DirectoryInterface $directory
[ "Handle", "the", "upload", "POST", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Controller/Backend/FileManager.php#L237-L275
bolt/bolt
src/Controller/Backend/FileManager.php
FileManager.processUpload
private function processUpload(DirectoryInterface $directory, $filename, array $fileToProcess) { $this->app['upload.namespace'] = $directory->getMountPoint(); $handler = $this->app['upload']; $handler->setPrefix($directory->getPath() . '/'); try { $result = $handler->proc...
php
private function processUpload(DirectoryInterface $directory, $filename, array $fileToProcess) { $this->app['upload.namespace'] = $directory->getMountPoint(); $handler = $this->app['upload']; $handler->setPrefix($directory->getPath() . '/'); try { $result = $handler->proc...
[ "private", "function", "processUpload", "(", "DirectoryInterface", "$", "directory", ",", "$", "filename", ",", "array", "$", "fileToProcess", ")", "{", "$", "this", "->", "app", "[", "'upload.namespace'", "]", "=", "$", "directory", "->", "getMountPoint", "("...
Process an individual file upload. @param DirectoryInterface $directory @param string $filename @param array $fileToProcess
[ "Process", "an", "individual", "file", "upload", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Controller/Backend/FileManager.php#L284-L316
bolt/bolt
src/Controller/Backend/FileManager.php
FileManager.getRelatedFiles
private function getRelatedFiles(FileInterface $file) { // Match foo(_local).*(.dist) $base = $file->getFilename(); $ext = Path::getExtension($base); $base = Path::getFilenameWithoutExtension($base); $base = Str::replaceLast($base, '_local', ''); $dir = $file->getPar...
php
private function getRelatedFiles(FileInterface $file) { // Match foo(_local).*(.dist) $base = $file->getFilename(); $ext = Path::getExtension($base); $base = Path::getFilenameWithoutExtension($base); $base = Str::replaceLast($base, '_local', ''); $dir = $file->getPar...
[ "private", "function", "getRelatedFiles", "(", "FileInterface", "$", "file", ")", "{", "// Match foo(_local).*(.dist)", "$", "base", "=", "$", "file", "->", "getFilename", "(", ")", ";", "$", "ext", "=", "Path", "::", "getExtension", "(", "$", "base", ")", ...
Gather related (present) files. Matches: foo(_local)?\.*(.dist)? i.e., if we're editing config.yml, we also want to check for config.yml.dist and config_local.yml @param FileInterface $file @return FileInterface[]
[ "Gather", "related", "(", "present", ")", "files", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Controller/Backend/FileManager.php#L330-L348
bolt/bolt
src/Controller/Async/AsyncBase.php
AsyncBase.before
public function before(Request $request) { // Start the 'stopwatch' for the profiler. $this->app['stopwatch']->start('bolt.async.before'); // If there's no active session, don't do anything. $authCookie = $request->cookies->get($this->app['token.authentication.name']); if ($...
php
public function before(Request $request) { // Start the 'stopwatch' for the profiler. $this->app['stopwatch']->start('bolt.async.before'); // If there's no active session, don't do anything. $authCookie = $request->cookies->get($this->app['token.authentication.name']); if ($...
[ "public", "function", "before", "(", "Request", "$", "request", ")", "{", "// Start the 'stopwatch' for the profiler.", "$", "this", "->", "app", "[", "'stopwatch'", "]", "->", "start", "(", "'bolt.async.before'", ")", ";", "// If there's no active session, don't do any...
Middleware function to do some tasks that should be done for all asynchronous requests. @param Request $request
[ "Middleware", "function", "to", "do", "some", "tasks", "that", "should", "be", "done", "for", "all", "asynchronous", "requests", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Controller/Async/AsyncBase.php#L35-L48
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.isValidSession
public function isValidSession($authCookie) { if ($authCookie === null) { throw new AccessControlException('Can not validate session with an empty token.'); } if ($this->validSession !== null) { return $this->validSession; } $check = false; $...
php
public function isValidSession($authCookie) { if ($authCookie === null) { throw new AccessControlException('Can not validate session with an empty token.'); } if ($this->validSession !== null) { return $this->validSession; } $check = false; $...
[ "public", "function", "isValidSession", "(", "$", "authCookie", ")", "{", "if", "(", "$", "authCookie", "===", "null", ")", "{", "throw", "new", "AccessControlException", "(", "'Can not validate session with an empty token.'", ")", ";", "}", "if", "(", "$", "thi...
We will not allow tampering with sessions, so we make sure the current session is still valid for the device on which it was created, and that the username, and IP address, are still the same. 1. If user has a valid session and it is fresh, check against cookie: - If NOT a match refuse - If a match accept 2. If user h...
[ "We", "will", "not", "allow", "tampering", "with", "sessions", "so", "we", "make", "sure", "the", "current", "session", "is", "still", "valid", "for", "the", "device", "on", "which", "it", "was", "created", "and", "that", "the", "username", "and", "IP", ...
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L114-L144
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.revokeSession
public function revokeSession() { try { // Only show this flash if there are users in the system. // Not when we're about to get redirected to the "first users" screen. if ($this->getRepositoryUsers()->count() > 0) { $this->flashLogger->info(Trans::__('gen...
php
public function revokeSession() { try { // Only show this flash if there are users in the system. // Not when we're about to get redirected to the "first users" screen. if ($this->getRepositoryUsers()->count() > 0) { $this->flashLogger->info(Trans::__('gen...
[ "public", "function", "revokeSession", "(", ")", "{", "try", "{", "// Only show this flash if there are users in the system.", "// Not when we're about to get redirected to the \"first users\" screen.", "if", "(", "$", "this", "->", "getRepositoryUsers", "(", ")", "->", "count"...
Log out the currently logged in user. @return bool
[ "Log", "out", "the", "currently", "logged", "in", "user", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L151-L180
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.checkSessionStored
protected function checkSessionStored(Token\Token $sessionAuth) { if (time() - $sessionAuth->getChecked() > 600) { return false; } return $this->checkSessionKeys($sessionAuth); }
php
protected function checkSessionStored(Token\Token $sessionAuth) { if (time() - $sessionAuth->getChecked() > 600) { return false; } return $this->checkSessionKeys($sessionAuth); }
[ "protected", "function", "checkSessionStored", "(", "Token", "\\", "Token", "$", "sessionAuth", ")", "{", "if", "(", "time", "(", ")", "-", "$", "sessionAuth", "->", "getChecked", "(", ")", ">", "600", ")", "{", "return", "false", ";", "}", "return", "...
Check the stored session, if we're past expiry then return false regardless and force a check/update from the database authentication record. @param Token\Token $sessionAuth @return bool
[ "Check", "the", "stored", "session", "if", "we", "re", "past", "expiry", "then", "return", "false", "regardless", "and", "force", "a", "check", "/", "update", "from", "the", "database", "authentication", "record", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L191-L198
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.checkSessionDatabase
protected function checkSessionDatabase($authCookie) { $userIp = $this->cookieOptions['remoteaddr'] ? $this->getClientIp() : null; $userAgent = $this->cookieOptions['browseragent'] ? $this->getClientUserAgent() : null; try { if (!$authTokenEntity = $this->getRepositoryAuthtoken(...
php
protected function checkSessionDatabase($authCookie) { $userIp = $this->cookieOptions['remoteaddr'] ? $this->getClientIp() : null; $userAgent = $this->cookieOptions['browseragent'] ? $this->getClientUserAgent() : null; try { if (!$authTokenEntity = $this->getRepositoryAuthtoken(...
[ "protected", "function", "checkSessionDatabase", "(", "$", "authCookie", ")", "{", "$", "userIp", "=", "$", "this", "->", "cookieOptions", "[", "'remoteaddr'", "]", "?", "$", "this", "->", "getClientIp", "(", ")", ":", "null", ";", "$", "userAgent", "=", ...
Check the user authentication cookie against what is stored in the database. @param string $authCookie @return bool
[ "Check", "the", "user", "authentication", "cookie", "against", "what", "is", "stored", "in", "the", "database", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L208-L237
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.checkSessionKeys
protected function checkSessionKeys(Token\Token $sessionAuth) { $userEntity = $sessionAuth->getUser(); $tokenEntity = $sessionAuth->getToken(); // The auth token is based on hostname, IP and browser user agent $key = $this->getAuthToken($userEntity->getId(), $tokenEntity->getSalt())...
php
protected function checkSessionKeys(Token\Token $sessionAuth) { $userEntity = $sessionAuth->getUser(); $tokenEntity = $sessionAuth->getToken(); // The auth token is based on hostname, IP and browser user agent $key = $this->getAuthToken($userEntity->getId(), $tokenEntity->getSalt())...
[ "protected", "function", "checkSessionKeys", "(", "Token", "\\", "Token", "$", "sessionAuth", ")", "{", "$", "userEntity", "=", "$", "sessionAuth", "->", "getUser", "(", ")", ";", "$", "tokenEntity", "=", "$", "sessionAuth", "->", "getToken", "(", ")", ";"...
Check the session is still valid for the device on which it was created, and. i.e. the username, IP address, and (if configured) the browser agent values are all still the same. @param Token\Token $sessionAuth @return bool
[ "Check", "the", "session", "is", "still", "valid", "for", "the", "device", "on", "which", "it", "was", "created", "and", ".", "i", ".", "e", ".", "the", "username", "IP", "address", "and", "(", "if", "configured", ")", "the", "browser", "agent", "value...
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L248-L269
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.getActiveSessions
public function getActiveSessions() { // Parse the user-agents to get a user-friendly Browser, version and platform. $parser = UAParser\Parser::create(); $this->getRepositoryAuthtoken()->deleteExpiredTokens(); $sessions = $this->getRepositoryAuthtoken()->getActiveSessions() ?: []; ...
php
public function getActiveSessions() { // Parse the user-agents to get a user-friendly Browser, version and platform. $parser = UAParser\Parser::create(); $this->getRepositoryAuthtoken()->deleteExpiredTokens(); $sessions = $this->getRepositoryAuthtoken()->getActiveSessions() ?: []; ...
[ "public", "function", "getActiveSessions", "(", ")", "{", "// Parse the user-agents to get a user-friendly Browser, version and platform.", "$", "parser", "=", "UAParser", "\\", "Parser", "::", "create", "(", ")", ";", "$", "this", "->", "getRepositoryAuthtoken", "(", "...
Lookup active sessions. @return array
[ "Lookup", "active", "sessions", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L276-L289
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.getAuthToken
protected function getAuthToken($userId, $salt) { if (empty($userId) || empty($salt)) { throw new \InvalidArgumentException(__FUNCTION__ . ' required a name and salt to be provided.'); } $token = (string) new Token\Generator($userId, $salt, $this->getClientIp(), $this->getClient...
php
protected function getAuthToken($userId, $salt) { if (empty($userId) || empty($salt)) { throw new \InvalidArgumentException(__FUNCTION__ . ' required a name and salt to be provided.'); } $token = (string) new Token\Generator($userId, $salt, $this->getClientIp(), $this->getClient...
[ "protected", "function", "getAuthToken", "(", "$", "userId", ",", "$", "salt", ")", "{", "if", "(", "empty", "(", "$", "userId", ")", "||", "empty", "(", "$", "salt", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "__FUNCTION__", ...
Get a MD5 hash key to identify the session with. This is calculated from a name, a salt, and optionally the remote IP address, broswer's agent string and the user's HTTP hostname. @param string $userId @param string $salt @return string|bool
[ "Get", "a", "MD5", "hash", "key", "to", "identify", "the", "session", "with", ".", "This", "is", "calculated", "from", "a", "name", "a", "salt", "and", "optionally", "the", "remote", "IP", "address", "broswer", "s", "agent", "string", "and", "the", "user...
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L301-L312
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.getClientHost
protected function getClientHost() { if ($this->requestStack->getCurrentRequest() === null) { throw new \RuntimeException(sprintf('%s can not be called outside of request cycle', __METHOD__)); } return $this->requestStack->getCurrentRequest()->getHost(); }
php
protected function getClientHost() { if ($this->requestStack->getCurrentRequest() === null) { throw new \RuntimeException(sprintf('%s can not be called outside of request cycle', __METHOD__)); } return $this->requestStack->getCurrentRequest()->getHost(); }
[ "protected", "function", "getClientHost", "(", ")", "{", "if", "(", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", "===", "null", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'%s can not be called outside of ...
Return the user's host name. @return string
[ "Return", "the", "user", "s", "host", "name", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L319-L326
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.getClientIp
protected function getClientIp() { if ($this->requestStack->getCurrentRequest() === null) { throw new \RuntimeException(sprintf('%s can not be called outside of request cycle', __METHOD__)); } return $this->requestStack->getCurrentRequest()->getClientIp() ?: '127.0.0.1'; }
php
protected function getClientIp() { if ($this->requestStack->getCurrentRequest() === null) { throw new \RuntimeException(sprintf('%s can not be called outside of request cycle', __METHOD__)); } return $this->requestStack->getCurrentRequest()->getClientIp() ?: '127.0.0.1'; }
[ "protected", "function", "getClientIp", "(", ")", "{", "if", "(", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", "===", "null", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'%s can not be called outside of re...
Return the user's IP address. @return string
[ "Return", "the", "user", "s", "IP", "address", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L333-L340
bolt/bolt
src/AccessControl/AccessChecker.php
AccessChecker.getClientUserAgent
protected function getClientUserAgent() { if ($this->requestStack->getCurrentRequest() === null) { throw new \RuntimeException(sprintf('%s can not be called outside of request cycle', __METHOD__)); } return $this->requestStack->getCurrentRequest()->server->get('HTTP_USER_AGENT')...
php
protected function getClientUserAgent() { if ($this->requestStack->getCurrentRequest() === null) { throw new \RuntimeException(sprintf('%s can not be called outside of request cycle', __METHOD__)); } return $this->requestStack->getCurrentRequest()->server->get('HTTP_USER_AGENT')...
[ "protected", "function", "getClientUserAgent", "(", ")", "{", "if", "(", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", "===", "null", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'%s can not be called outsid...
Return the user's browser User Agent. @return string
[ "Return", "the", "user", "s", "browser", "User", "Agent", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/AccessControl/AccessChecker.php#L347-L354
bolt/bolt
src/Twig/SecurityPolicy.php
SecurityPolicy.addAllowedMethod
public function addAllowedMethod($class, $method) { if (!isset($this->allowedMethods[$class])) { $this->allowedMethods[$class] = []; } $this->allowedMethods[$class][] = strtolower($method); }
php
public function addAllowedMethod($class, $method) { if (!isset($this->allowedMethods[$class])) { $this->allowedMethods[$class] = []; } $this->allowedMethods[$class][] = strtolower($method); }
[ "public", "function", "addAllowedMethod", "(", "$", "class", ",", "$", "method", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "allowedMethods", "[", "$", "class", "]", ")", ")", "{", "$", "this", "->", "allowedMethods", "[", "$", "class...
Add class method allowed by this policy. @param string $class @param string $method
[ "Add", "class", "method", "allowed", "by", "this", "policy", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/SecurityPolicy.php#L110-L116
bolt/bolt
src/Twig/SecurityPolicy.php
SecurityPolicy.addAllowedProperty
public function addAllowedProperty($class, $property) { if (!isset($this->allowedProperties[$class])) { $this->allowedProperties[$class] = []; } $this->allowedProperties[$class][] = $property; }
php
public function addAllowedProperty($class, $property) { if (!isset($this->allowedProperties[$class])) { $this->allowedProperties[$class] = []; } $this->allowedProperties[$class][] = $property; }
[ "public", "function", "addAllowedProperty", "(", "$", "class", ",", "$", "property", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "allowedProperties", "[", "$", "class", "]", ")", ")", "{", "$", "this", "->", "allowedProperties", "[", "$"...
Add class property allowed by this policy. @param string $class @param string $property
[ "Add", "class", "property", "allowed", "by", "this", "policy", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/SecurityPolicy.php#L135-L141
bolt/bolt
src/Twig/SecurityPolicy.php
SecurityPolicy.checkSecurity
public function checkSecurity($tags, $filters, $functions) { foreach ($tags as $tag) { if (!in_array($tag, $this->allowedTags)) { throw new SecurityNotAllowedTagError(sprintf("Tag '%s' is not allowed.", $tag), $tag); } } foreach ($filters as $filter) ...
php
public function checkSecurity($tags, $filters, $functions) { foreach ($tags as $tag) { if (!in_array($tag, $this->allowedTags)) { throw new SecurityNotAllowedTagError(sprintf("Tag '%s' is not allowed.", $tag), $tag); } } foreach ($filters as $filter) ...
[ "public", "function", "checkSecurity", "(", "$", "tags", ",", "$", "filters", ",", "$", "functions", ")", "{", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "if", "(", "!", "in_array", "(", "$", "tag", ",", "$", "this", "->", "allowedTag...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/SecurityPolicy.php#L154-L173
bolt/bolt
src/Twig/SecurityPolicy.php
SecurityPolicy.checkMethodAllowed
public function checkMethodAllowed($obj, $method) { if ($obj instanceof TemplateInterface || $obj instanceof Markup) { return; } if ($obj instanceof SecurityProxyInterface) { $objClass = $obj->getProxiedClass(); } else { $objClass = get_class($obj...
php
public function checkMethodAllowed($obj, $method) { if ($obj instanceof TemplateInterface || $obj instanceof Markup) { return; } if ($obj instanceof SecurityProxyInterface) { $objClass = $obj->getProxiedClass(); } else { $objClass = get_class($obj...
[ "public", "function", "checkMethodAllowed", "(", "$", "obj", ",", "$", "method", ")", "{", "if", "(", "$", "obj", "instanceof", "TemplateInterface", "||", "$", "obj", "instanceof", "Markup", ")", "{", "return", ";", "}", "if", "(", "$", "obj", "instanceo...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/SecurityPolicy.php#L178-L207
bolt/bolt
src/Twig/SecurityPolicy.php
SecurityPolicy.checkPropertyAllowed
public function checkPropertyAllowed($obj, $property) { $allowed = false; if ($obj instanceof SecurityProxyInterface) { $objClass = $obj->getProxiedClass(); } else { $objClass = get_class($obj); } foreach ($this->allowedProperties as $class => $prope...
php
public function checkPropertyAllowed($obj, $property) { $allowed = false; if ($obj instanceof SecurityProxyInterface) { $objClass = $obj->getProxiedClass(); } else { $objClass = get_class($obj); } foreach ($this->allowedProperties as $class => $prope...
[ "public", "function", "checkPropertyAllowed", "(", "$", "obj", ",", "$", "property", ")", "{", "$", "allowed", "=", "false", ";", "if", "(", "$", "obj", "instanceof", "SecurityProxyInterface", ")", "{", "$", "objClass", "=", "$", "obj", "->", "getProxiedCl...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Twig/SecurityPolicy.php#L212-L236
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.generate
public function generate($count) { if (!is_int($count) || $count < 1) { throw new \InvalidArgumentException(sprintf('%s requires a value greater than 1.', __METHOD__)); } $ownerIds = $this->getValidOwnerIds(); for ($i = 0; $i < $count; $i++) { /** @var Entit...
php
public function generate($count) { if (!is_int($count) || $count < 1) { throw new \InvalidArgumentException(sprintf('%s requires a value greater than 1.', __METHOD__)); } $ownerIds = $this->getValidOwnerIds(); for ($i = 0; $i < $count; $i++) { /** @var Entit...
[ "public", "function", "generate", "(", "$", "count", ")", "{", "if", "(", "!", "is_int", "(", "$", "count", ")", "||", "$", "count", "<", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'%s requires a value greater th...
Generate 'n' number of dummy records. @param int $count @return array
[ "Generate", "n", "number", "of", "dummy", "records", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L109-L134
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.fillEntity
private function fillEntity(Entity\Content $contentEntity) { $contentType = $this->repository->getEntityManager()->getContentType($contentEntity->getContenttype()); foreach ($contentType['fields'] as $field => $values) { $this->setFieldValue($contentEntity, $contentType, $field, $values...
php
private function fillEntity(Entity\Content $contentEntity) { $contentType = $this->repository->getEntityManager()->getContentType($contentEntity->getContenttype()); foreach ($contentType['fields'] as $field => $values) { $this->setFieldValue($contentEntity, $contentType, $field, $values...
[ "private", "function", "fillEntity", "(", "Entity", "\\", "Content", "$", "contentEntity", ")", "{", "$", "contentType", "=", "$", "this", "->", "repository", "->", "getEntityManager", "(", ")", "->", "getContentType", "(", "$", "contentEntity", "->", "getCont...
Create a single ContentType entity. @param Entity\Content $contentEntity
[ "Create", "a", "single", "ContentType", "entity", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L151-L180
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.setTaxonomyCollection
private function setTaxonomyCollection(Entity\Content $contentEntity, $contentType) { if (empty($contentType['taxonomy'])) { return; } /** @var Collection\Taxonomy $taxonomies */ $taxonomies = $this->repository->getEntityManager()->createCollection(Entity\Taxonomy::class)...
php
private function setTaxonomyCollection(Entity\Content $contentEntity, $contentType) { if (empty($contentType['taxonomy'])) { return; } /** @var Collection\Taxonomy $taxonomies */ $taxonomies = $this->repository->getEntityManager()->createCollection(Entity\Taxonomy::class)...
[ "private", "function", "setTaxonomyCollection", "(", "Entity", "\\", "Content", "$", "contentEntity", ",", "$", "contentType", ")", "{", "if", "(", "empty", "(", "$", "contentType", "[", "'taxonomy'", "]", ")", ")", "{", "return", ";", "}", "/** @var Collect...
Add some random taxonomy entries on the record. @param Entity\Content $contentEntity @param array|ContentType $contentType
[ "Add", "some", "random", "taxonomy", "entries", "on", "the", "record", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L311-L347
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.getTaxonomyEntity
private function getTaxonomyEntity(Entity\Content $contentEntity, $taxonomy) { return new Entity\Taxonomy([ 'content_id' => $contentEntity->getId(), 'contenttype' => (string) $contentEntity->getContentType(), 'taxonomytype' => $taxonomy, ]); }
php
private function getTaxonomyEntity(Entity\Content $contentEntity, $taxonomy) { return new Entity\Taxonomy([ 'content_id' => $contentEntity->getId(), 'contenttype' => (string) $contentEntity->getContentType(), 'taxonomytype' => $taxonomy, ]); }
[ "private", "function", "getTaxonomyEntity", "(", "Entity", "\\", "Content", "$", "contentEntity", ",", "$", "taxonomy", ")", "{", "return", "new", "Entity", "\\", "Taxonomy", "(", "[", "'content_id'", "=>", "$", "contentEntity", "->", "getId", "(", ")", ",",...
Get a base taxonomy entity object. @param Entity\Content $contentEntity @param string $taxonomy @return Entity\Taxonomy
[ "Get", "a", "base", "taxonomy", "entity", "object", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L357-L364
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.getValidOwnerIds
private function getValidOwnerIds() { $userRepo = $this->repository->getEntityManager()->getRepository(Entity\Users::class); $query = $userRepo->createQueryBuilder() ->select('id') ->where('enabled = :enabled') ->setParameter('enabled', true) ; $us...
php
private function getValidOwnerIds() { $userRepo = $this->repository->getEntityManager()->getRepository(Entity\Users::class); $query = $userRepo->createQueryBuilder() ->select('id') ->where('enabled = :enabled') ->setParameter('enabled', true) ; $us...
[ "private", "function", "getValidOwnerIds", "(", ")", "{", "$", "userRepo", "=", "$", "this", "->", "repository", "->", "getEntityManager", "(", ")", "->", "getRepository", "(", "Entity", "\\", "Users", "::", "class", ")", ";", "$", "query", "=", "$", "us...
Return an array of enabled system IDs. @return array
[ "Return", "an", "array", "of", "enabled", "system", "IDs", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L371-L382
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.getImageFiles
private function getImageFiles() { if ($this->imageFiles === null) { // Get a list of images. $this->imageFiles = $this->filesystem ->find() ->in('files://') ->name('/\.jpe?g$/') ->name('*.png') ->toArray...
php
private function getImageFiles() { if ($this->imageFiles === null) { // Get a list of images. $this->imageFiles = $this->filesystem ->find() ->in('files://') ->name('/\.jpe?g$/') ->name('*.png') ->toArray...
[ "private", "function", "getImageFiles", "(", ")", "{", "if", "(", "$", "this", "->", "imageFiles", "===", "null", ")", "{", "// Get a list of images.", "$", "this", "->", "imageFiles", "=", "$", "this", "->", "filesystem", "->", "find", "(", ")", "->", "...
Return an array of file names in the "files" filesystem. @return \Bolt\Filesystem\Handler\Image[]
[ "Return", "an", "array", "of", "file", "names", "in", "the", "files", "filesystem", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L389-L403
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.getReservedTitle
private function getReservedTitle($contentTypeName) { $defaultTitles = $this->defaultTitles->get($contentTypeName); $title = array_shift($defaultTitles); $existing = $this->repository->findOneBy(['title' => $title]); if ($existing || $title === null) { $title = trim(stri...
php
private function getReservedTitle($contentTypeName) { $defaultTitles = $this->defaultTitles->get($contentTypeName); $title = array_shift($defaultTitles); $existing = $this->repository->findOneBy(['title' => $title]); if ($existing || $title === null) { $title = trim(stri...
[ "private", "function", "getReservedTitle", "(", "$", "contentTypeName", ")", "{", "$", "defaultTitles", "=", "$", "this", "->", "defaultTitles", "->", "get", "(", "$", "contentTypeName", ")", ";", "$", "title", "=", "array_shift", "(", "$", "defaultTitles", ...
Get the title for a 'Block' ContentType. Check if the desired ones aren't present in the database yet, and return them in order. @param string $contentTypeName @return string
[ "Get", "the", "title", "for", "a", "Block", "ContentType", ".", "Check", "if", "the", "desired", "ones", "aren", "t", "present", "in", "the", "database", "yet", "and", "return", "them", "in", "order", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L413-L425
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.getRandomTags
private function getRandomTags($count = 5) { $tags = ['action', 'adult', 'adventure', 'alpha', 'animals', 'animation', 'anime', 'architecture', 'art', 'astronomy', 'baby', 'batshitinsane', 'biography', 'biology', 'book', 'books', 'business', 'business', 'camera', 'cars', 'cats', 'cin...
php
private function getRandomTags($count = 5) { $tags = ['action', 'adult', 'adventure', 'alpha', 'animals', 'animation', 'anime', 'architecture', 'art', 'astronomy', 'baby', 'batshitinsane', 'biography', 'biology', 'book', 'books', 'business', 'business', 'camera', 'cars', 'cats', 'cin...
[ "private", "function", "getRandomTags", "(", "$", "count", "=", "5", ")", "{", "$", "tags", "=", "[", "'action'", ",", "'adult'", ",", "'adventure'", ",", "'alpha'", ",", "'animals'", ",", "'animation'", ",", "'anime'", ",", "'architecture'", ",", "'art'",...
Get an array of random tags @param int $count @return string[]
[ "Get", "an", "array", "of", "random", "tags" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L434-L457
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.getRandomImage
private function getRandomImage($type, $placeholder) { $pathKey = $type === 'image' ? 'file' : 'filename'; if ($placeholder && ($filename = $this->fetchPlaceholder($placeholder))) { return [$pathKey => $filename, 'title' => 'placeholder', 'alt' => 'placeholder']; } $ima...
php
private function getRandomImage($type, $placeholder) { $pathKey = $type === 'image' ? 'file' : 'filename'; if ($placeholder && ($filename = $this->fetchPlaceholder($placeholder))) { return [$pathKey => $filename, 'title' => 'placeholder', 'alt' => 'placeholder']; } $ima...
[ "private", "function", "getRandomImage", "(", "$", "type", ",", "$", "placeholder", ")", "{", "$", "pathKey", "=", "$", "type", "===", "'image'", "?", "'file'", ":", "'filename'", ";", "if", "(", "$", "placeholder", "&&", "(", "$", "filename", "=", "$"...
Get a random image. @param string $type @param string|null $placeholder @return array|null
[ "Get", "a", "random", "image", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L467-L485
bolt/bolt
src/Storage/Database/Prefill/RecordContentGenerator.php
RecordContentGenerator.fetchPlaceholder
private function fetchPlaceholder($placeholder) { try { $image = $this->imageClient->get($placeholder); } catch (RequestException $e) { // We couldn't fetch the file, fall back to default behaviour return false; } $filename = sprintf('placeholder_...
php
private function fetchPlaceholder($placeholder) { try { $image = $this->imageClient->get($placeholder); } catch (RequestException $e) { // We couldn't fetch the file, fall back to default behaviour return false; } $filename = sprintf('placeholder_...
[ "private", "function", "fetchPlaceholder", "(", "$", "placeholder", ")", "{", "try", "{", "$", "image", "=", "$", "this", "->", "imageClient", "->", "get", "(", "$", "placeholder", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "/...
Attempt to fetch a placeholder image from a remote URL. @param string $placeholder @return array|bool
[ "Attempt", "to", "fetch", "a", "placeholder", "image", "from", "a", "remote", "URL", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Prefill/RecordContentGenerator.php#L494-L513
bolt/bolt
src/Configuration/Validation/Cache.php
Cache.check
public function check() { $path = $this->pathResolver->resolve('cache'); if (!is_dir($path)) { throw new CacheValidationException($path); } if (!is_writable($path)) { throw new CacheValidationException($path); } }
php
public function check() { $path = $this->pathResolver->resolve('cache'); if (!is_dir($path)) { throw new CacheValidationException($path); } if (!is_writable($path)) { throw new CacheValidationException($path); } }
[ "public", "function", "check", "(", ")", "{", "$", "path", "=", "$", "this", "->", "pathResolver", "->", "resolve", "(", "'cache'", ")", ";", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "throw", "new", "CacheValidationException", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Configuration/Validation/Cache.php#L21-L30
bolt/bolt
src/Cron.php
Cron.execute
public function execute($param = []) { $this->param = $param; $this->runtime = new \DateTime(); // Get schedules $this->getRunTimes(); // Time of day for daily, weekly, monthly and yearly jobs $this->getScheduleThreshold(); $event = new CronEvent($this->app...
php
public function execute($param = []) { $this->param = $param; $this->runtime = new \DateTime(); // Get schedules $this->getRunTimes(); // Time of day for daily, weekly, monthly and yearly jobs $this->getScheduleThreshold(); $event = new CronEvent($this->app...
[ "public", "function", "execute", "(", "$", "param", "=", "[", "]", ")", "{", "$", "this", "->", "param", "=", "$", "param", ";", "$", "this", "->", "runtime", "=", "new", "\\", "DateTime", "(", ")", ";", "// Get schedules", "$", "this", "->", "getR...
Run the jobs. @param array $param @return bool
[ "Run", "the", "jobs", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Cron.php#L77-L96
bolt/bolt
src/Cron.php
Cron.executeSingle
private function executeSingle(CronEvent $event, $interimName, array $data) { if ($this->isExecutable($interimName)) { $this->notify($data['message']); /** @var Entity\Cron $cronEntity */ $cronEntity = $this->jobs[$interimName]['entity']; try { ...
php
private function executeSingle(CronEvent $event, $interimName, array $data) { if ($this->isExecutable($interimName)) { $this->notify($data['message']); /** @var Entity\Cron $cronEntity */ $cronEntity = $this->jobs[$interimName]['entity']; try { ...
[ "private", "function", "executeSingle", "(", "CronEvent", "$", "event", ",", "$", "interimName", ",", "array", "$", "data", ")", "{", "if", "(", "$", "this", "->", "isExecutable", "(", "$", "interimName", ")", ")", "{", "$", "this", "->", "notify", "("...
Run a single cron dispatcher. @param CronEvent $event @param string $interimName @param array $data
[ "Run", "a", "single", "cron", "dispatcher", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Cron.php#L105-L120
bolt/bolt
src/Cron.php
Cron.isExecutable
private function isExecutable($interimName) { if ($this->param['run'] && $this->param['event'] === $interimName) { return true; } elseif (!$this->app['dispatcher']->hasListeners($interimName)) { return false; } $nextRun = $this->jobs[$interimName]['nextRunTim...
php
private function isExecutable($interimName) { if ($this->param['run'] && $this->param['event'] === $interimName) { return true; } elseif (!$this->app['dispatcher']->hasListeners($interimName)) { return false; } $nextRun = $this->jobs[$interimName]['nextRunTim...
[ "private", "function", "isExecutable", "(", "$", "interimName", ")", "{", "if", "(", "$", "this", "->", "param", "[", "'run'", "]", "&&", "$", "this", "->", "param", "[", "'event'", "]", "===", "$", "interimName", ")", "{", "return", "true", ";", "}"...
Test whether or not to call dispatcher. @param string $interimName The cron event name @return bool Dispatch event or not
[ "Test", "whether", "or", "not", "to", "call", "dispatcher", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Cron.php#L129-L146
bolt/bolt
src/Cron.php
Cron.getScheduleThreshold
private function getScheduleThreshold() { $hour = $this->app['config']->get('general/cron_hour', '03:00'); if (is_numeric($hour)) { $hour .= ':00'; } $this->cronHour = new \DateTime($hour); }
php
private function getScheduleThreshold() { $hour = $this->app['config']->get('general/cron_hour', '03:00'); if (is_numeric($hour)) { $hour .= ':00'; } $this->cronHour = new \DateTime($hour); }
[ "private", "function", "getScheduleThreshold", "(", ")", "{", "$", "hour", "=", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'general/cron_hour'", ",", "'03:00'", ")", ";", "if", "(", "is_numeric", "(", "$", "hour", ")", ")", "{",...
Get our configured hour and convert it to UNIX time.
[ "Get", "our", "configured", "hour", "and", "convert", "it", "to", "UNIX", "time", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Cron.php#L151-L160
bolt/bolt
src/Cron.php
Cron.getRunTimes
private function getRunTimes() { foreach (array_keys($this->jobs) as $interimName) { if (!$runEntity = $this->repository->getNextRunTime($interimName)) { $epoch = new \DateTime(); $epoch->setTimestamp(0); $runEntity = new Entity\Cron(['interim' => ...
php
private function getRunTimes() { foreach (array_keys($this->jobs) as $interimName) { if (!$runEntity = $this->repository->getNextRunTime($interimName)) { $epoch = new \DateTime(); $epoch->setTimestamp(0); $runEntity = new Entity\Cron(['interim' => ...
[ "private", "function", "getRunTimes", "(", ")", "{", "foreach", "(", "array_keys", "(", "$", "this", "->", "jobs", ")", "as", "$", "interimName", ")", "{", "if", "(", "!", "$", "runEntity", "=", "$", "this", "->", "repository", "->", "getNextRunTime", ...
Query table for last run time of each interim.
[ "Query", "table", "for", "last", "run", "time", "of", "each", "interim", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Cron.php#L165-L178
bolt/bolt
src/Cron.php
Cron.getNextRunTime
private function getNextRunTime($interimName, Entity\Cron $runEntity) { $interval = new \DateInterval($this->jobs[$interimName]['increment']); $nextRunTime = clone $runEntity->getLastrun(); $nextRunTime->add($interval); return $nextRunTime; }
php
private function getNextRunTime($interimName, Entity\Cron $runEntity) { $interval = new \DateInterval($this->jobs[$interimName]['increment']); $nextRunTime = clone $runEntity->getLastrun(); $nextRunTime->add($interval); return $nextRunTime; }
[ "private", "function", "getNextRunTime", "(", "$", "interimName", ",", "Entity", "\\", "Cron", "$", "runEntity", ")", "{", "$", "interval", "=", "new", "\\", "DateInterval", "(", "$", "this", "->", "jobs", "[", "$", "interimName", "]", "[", "'increment'", ...
Get the next run time for a given interim. @param string $interimName The interim; CRON_HOURLY, CRON_DAILY, CRON_WEEKLY, CRON_MONTHLY or CRON_YEARLY @param \Bolt\Storage\Entity\Cron $runEntity The last execution time of the interim @return \DateTime
[ "Get", "the", "next", "run", "time", "for", "a", "given", "interim", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Cron.php#L188-L195
bolt/bolt
src/Cron.php
Cron.notify
private function notify($message) { if ($this->output !== null) { $this->output->writeln("<info>{$message}</info>"); } $this->app['logger.system']->info($message, ['event' => 'cron']); }
php
private function notify($message) { if ($this->output !== null) { $this->output->writeln("<info>{$message}</info>"); } $this->app['logger.system']->info($message, ['event' => 'cron']); }
[ "private", "function", "notify", "(", "$", "message", ")", "{", "if", "(", "$", "this", "->", "output", "!==", "null", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "\"<info>{$message}</info>\"", ")", ";", "}", "$", "this", "->", "app", ...
If we're passed an OutputInterface, we're called from Nut and can notify the end user. @param string $message
[ "If", "we", "re", "passed", "an", "OutputInterface", "we", "re", "called", "from", "Nut", "and", "can", "notify", "the", "end", "user", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Cron.php#L203-L210
bolt/bolt
src/Cron.php
Cron.handleError
private function handleError(\Exception $e, $interimName) { // Console feedback $this->output->writeln('<error>A ' . $interimName . ' job failed. The exception returned was:</error>'); $this->output->writeln('<error> ' . $e->getMessage() . '</error>'); $this->output->writeln('<err...
php
private function handleError(\Exception $e, $interimName) { // Console feedback $this->output->writeln('<error>A ' . $interimName . ' job failed. The exception returned was:</error>'); $this->output->writeln('<error> ' . $e->getMessage() . '</error>'); $this->output->writeln('<err...
[ "private", "function", "handleError", "(", "\\", "Exception", "$", "e", ",", "$", "interimName", ")", "{", "// Console feedback", "$", "this", "->", "output", "->", "writeln", "(", "'<error>A '", ".", "$", "interimName", ".", "' job failed. The exception returned ...
Provide feedback on exceptions in cron jobs. @param \Exception $e The passed exception @param string $interimName The cron handler name
[ "Provide", "feedback", "on", "exceptions", "in", "cron", "jobs", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Cron.php#L218-L228
bolt/bolt
src/Storage/Database/Schema/Comparison/Comparator.php
Comparator.diffColumn
public function diffColumn(Column $column1, Column $column2) { $changedProperties = parent::diffColumn($column1, $column2); if (DBAL\Version::compare('2.6.0') < 0) { return $changedProperties; } if ($column1->getType()->getName() === Types\Type::JSON_ARRAY && $column2->g...
php
public function diffColumn(Column $column1, Column $column2) { $changedProperties = parent::diffColumn($column1, $column2); if (DBAL\Version::compare('2.6.0') < 0) { return $changedProperties; } if ($column1->getType()->getName() === Types\Type::JSON_ARRAY && $column2->g...
[ "public", "function", "diffColumn", "(", "Column", "$", "column1", ",", "Column", "$", "column2", ")", "{", "$", "changedProperties", "=", "parent", "::", "diffColumn", "(", "$", "column1", ",", "$", "column2", ")", ";", "if", "(", "DBAL", "\\", "Version...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Schema/Comparison/Comparator.php#L24-L38
bolt/bolt
src/Nut/UserManage.php
UserManage.execute
protected function execute(InputInterface $input, OutputInterface $output) { /** @var \Bolt\Storage\Repository\UsersRepository $repo */ $repo = $this->app['storage']->getRepository(Entity\Users::class); $userLogin = $input->getArgument('login'); $userEntity = $this->getUser($repo, $...
php
protected function execute(InputInterface $input, OutputInterface $output) { /** @var \Bolt\Storage\Repository\UsersRepository $repo */ $repo = $this->app['storage']->getRepository(Entity\Users::class); $userLogin = $input->getArgument('login'); $userEntity = $this->getUser($repo, $...
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "/** @var \\Bolt\\Storage\\Repository\\UsersRepository $repo */", "$", "repo", "=", "$", "this", "->", "app", "[", "'storage'", "]", "->", "getR...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Nut/UserManage.php#L36-L90
bolt/bolt
src/Nut/UserManage.php
UserManage.getUser
protected function getUser(UsersRepository $repo, $userLogin) { $userEntity = $repo->findOneBy(['username' => $userLogin]); if ($userEntity) { return $userEntity; } return $repo->findOneBy(['email' => $userLogin]); }
php
protected function getUser(UsersRepository $repo, $userLogin) { $userEntity = $repo->findOneBy(['username' => $userLogin]); if ($userEntity) { return $userEntity; } return $repo->findOneBy(['email' => $userLogin]); }
[ "protected", "function", "getUser", "(", "UsersRepository", "$", "repo", ",", "$", "userLogin", ")", "{", "$", "userEntity", "=", "$", "repo", "->", "findOneBy", "(", "[", "'username'", "=>", "$", "userLogin", "]", ")", ";", "if", "(", "$", "userEntity",...
@param UsersRepository $repo @param string $userLogin @return Entity\Users|false
[ "@param", "UsersRepository", "$repo", "@param", "string", "$userLogin" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Nut/UserManage.php#L98-L106
bolt/bolt
src/Storage/ContentRequest/Modify.php
Modify.action
public function action($contentTypeName, array $changeRequest) { foreach ($changeRequest as $recordId => $actionData) { if ($actionData === null) { continue; } $repo = $this->em->getRepository($contentTypeName); foreach ($actionData as $action...
php
public function action($contentTypeName, array $changeRequest) { foreach ($changeRequest as $recordId => $actionData) { if ($actionData === null) { continue; } $repo = $this->em->getRepository($contentTypeName); foreach ($actionData as $action...
[ "public", "function", "action", "(", "$", "contentTypeName", ",", "array", "$", "changeRequest", ")", "{", "foreach", "(", "$", "changeRequest", "as", "$", "recordId", "=>", "$", "actionData", ")", "{", "if", "(", "$", "actionData", "===", "null", ")", "...
Modify an individual ContentType's records. @param string $contentTypeName ContentType slug @param array $changeRequest Change array in the format of: [id => [action => [field => value]]]
[ "Modify", "an", "individual", "ContentType", "s", "records", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/ContentRequest/Modify.php#L56-L71
bolt/bolt
src/Storage/ContentRequest/Modify.php
Modify.modifyContentTypeRecord
protected function modifyContentTypeRecord(Repository $repo, Content $entity, $action, $fieldData) { if ($action === 'delete') { return $this->deleteRecord($repo, $entity); } if ($action === 'modify' && $fieldData !== null) { $this->modifyRecord($entity, $fieldData); ...
php
protected function modifyContentTypeRecord(Repository $repo, Content $entity, $action, $fieldData) { if ($action === 'delete') { return $this->deleteRecord($repo, $entity); } if ($action === 'modify' && $fieldData !== null) { $this->modifyRecord($entity, $fieldData); ...
[ "protected", "function", "modifyContentTypeRecord", "(", "Repository", "$", "repo", ",", "Content", "$", "entity", ",", "$", "action", ",", "$", "fieldData", ")", "{", "if", "(", "$", "action", "===", "'delete'", ")", "{", "return", "$", "this", "->", "d...
Perform modification action(s) on a ContentType record. @param Repository $repo @param Content $entity @param string $action @param array|null $fieldData @return bool
[ "Perform", "modification", "action", "(", "s", ")", "on", "a", "ContentType", "record", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/ContentRequest/Modify.php#L83-L95
bolt/bolt
src/Storage/ContentRequest/Modify.php
Modify.deleteRecord
protected function deleteRecord(Repository $repo, Content $entity) { $recordId = $entity->getId(); /** @var Mapping\ContentType $contentType */ $contentType = $entity->getContenttype(); $contentTypeName = (string) $contentType; if (!$this->users->isAllowed("contenttype:$conte...
php
protected function deleteRecord(Repository $repo, Content $entity) { $recordId = $entity->getId(); /** @var Mapping\ContentType $contentType */ $contentType = $entity->getContenttype(); $contentTypeName = (string) $contentType; if (!$this->users->isAllowed("contenttype:$conte...
[ "protected", "function", "deleteRecord", "(", "Repository", "$", "repo", ",", "Content", "$", "entity", ")", "{", "$", "recordId", "=", "$", "entity", "->", "getId", "(", ")", ";", "/** @var Mapping\\ContentType $contentType */", "$", "contentType", "=", "$", ...
Execute the deletion of a record. @param Repository $repo @param Content $entity @return bool
[ "Execute", "the", "deletion", "of", "a", "record", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/ContentRequest/Modify.php#L105-L130
bolt/bolt
src/Storage/ContentRequest/Modify.php
Modify.modifyRecord
protected function modifyRecord(Content $entity, array $fieldData) { foreach ($fieldData as $field => $value) { if (strtolower($field) === 'status') { $this->transistionRecordStatus($entity, $value); } elseif (strtolower($field) === 'ownerid') { $this-...
php
protected function modifyRecord(Content $entity, array $fieldData) { foreach ($fieldData as $field => $value) { if (strtolower($field) === 'status') { $this->transistionRecordStatus($entity, $value); } elseif (strtolower($field) === 'ownerid') { $this-...
[ "protected", "function", "modifyRecord", "(", "Content", "$", "entity", ",", "array", "$", "fieldData", ")", "{", "foreach", "(", "$", "fieldData", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "strtolower", "(", "$", "field", ")", "==="...
Modify a record's value(s). @param Content $entity @param array $fieldData
[ "Modify", "a", "record", "s", "value", "(", "s", ")", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/ContentRequest/Modify.php#L138-L149
bolt/bolt
src/Storage/ContentRequest/Modify.php
Modify.modifyRecordValue
protected function modifyRecordValue(Content $entity, $field, $value) { $recordId = $entity->getId(); $contentTypeName = (string) $entity->getContenttype(); $canModify = $this->users->isAllowed("contenttype:$contentTypeName:edit:$recordId"); if (!$canModify) { $this->logg...
php
protected function modifyRecordValue(Content $entity, $field, $value) { $recordId = $entity->getId(); $contentTypeName = (string) $entity->getContenttype(); $canModify = $this->users->isAllowed("contenttype:$contentTypeName:edit:$recordId"); if (!$canModify) { $this->logg...
[ "protected", "function", "modifyRecordValue", "(", "Content", "$", "entity", ",", "$", "field", ",", "$", "value", ")", "{", "$", "recordId", "=", "$", "entity", "->", "getId", "(", ")", ";", "$", "contentTypeName", "=", "(", "string", ")", "$", "entit...
Modify a record's value if permitted. @param Content $entity @param string $field @param mixed $value
[ "Modify", "a", "record", "s", "value", "if", "permitted", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/ContentRequest/Modify.php#L158-L170
bolt/bolt
src/Storage/ContentRequest/Modify.php
Modify.transistionRecordStatus
protected function transistionRecordStatus(Content $entity, $newStatus) { $contentTypeName = (string) $entity->getContenttype(); $canTransition = $this->users->isContentStatusTransitionAllowed($entity->getStatus(), $newStatus, $contentTypeName, $entity->getId()); if (!$canTransition) { ...
php
protected function transistionRecordStatus(Content $entity, $newStatus) { $contentTypeName = (string) $entity->getContenttype(); $canTransition = $this->users->isContentStatusTransitionAllowed($entity->getStatus(), $newStatus, $contentTypeName, $entity->getId()); if (!$canTransition) { ...
[ "protected", "function", "transistionRecordStatus", "(", "Content", "$", "entity", ",", "$", "newStatus", ")", "{", "$", "contentTypeName", "=", "(", "string", ")", "$", "entity", "->", "getContenttype", "(", ")", ";", "$", "canTransition", "=", "$", "this",...
Transition a record's status if permitted. @param Content $entity @param string $newStatus
[ "Transition", "a", "record", "s", "status", "if", "permitted", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/ContentRequest/Modify.php#L178-L189
bolt/bolt
src/Storage/ContentRequest/Modify.php
Modify.transistionRecordOwner
protected function transistionRecordOwner(Content $entity, $ownerId) { $recordId = $entity->getId(); $contentTypeName = (string) $entity->getContenttype(); $canChangeOwner = $this->users->isAllowed("contenttype:$contentTypeName:change-ownership:$recordId"); if (!$canChangeOwner) { ...
php
protected function transistionRecordOwner(Content $entity, $ownerId) { $recordId = $entity->getId(); $contentTypeName = (string) $entity->getContenttype(); $canChangeOwner = $this->users->isAllowed("contenttype:$contentTypeName:change-ownership:$recordId"); if (!$canChangeOwner) { ...
[ "protected", "function", "transistionRecordOwner", "(", "Content", "$", "entity", ",", "$", "ownerId", ")", "{", "$", "recordId", "=", "$", "entity", "->", "getId", "(", ")", ";", "$", "contentTypeName", "=", "(", "string", ")", "$", "entity", "->", "get...
Transition a record's owner if permitted. @param Content $entity @param int $ownerId
[ "Transition", "a", "record", "s", "owner", "if", "permitted", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/ContentRequest/Modify.php#L197-L209
bolt/bolt
src/Provider/TwigServiceProvider.php
TwigServiceProvider.boot
public function boot(Application $app) { // Add path here since "theme" filesystem isn't mounted until boot. $themePath = 'theme://' . $app['config']->get('theme/template_directory'); $app['twig.loader.bolt_filesystem']->prependPath($themePath, 'theme'); $app['twig.loader.bolt_filesy...
php
public function boot(Application $app) { // Add path here since "theme" filesystem isn't mounted until boot. $themePath = 'theme://' . $app['config']->get('theme/template_directory'); $app['twig.loader.bolt_filesystem']->prependPath($themePath, 'theme'); $app['twig.loader.bolt_filesy...
[ "public", "function", "boot", "(", "Application", "$", "app", ")", "{", "// Add path here since \"theme\" filesystem isn't mounted until boot.", "$", "themePath", "=", "'theme://'", ".", "$", "app", "[", "'config'", "]", "->", "get", "(", "'theme/template_directory'", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Provider/TwigServiceProvider.php#L322-L328
bolt/bolt
src/Storage/Database/Schema/Table/BaseTable.php
BaseTable.buildTable
public function buildTable(Schema $schema, $aliasName, $charset, $collate) { $tableName = $this->tablePrefix . $aliasName; $this->table = $schema->createTable($tableName); $this->table->addOption('alias', $aliasName); $this->table->addOption('charset', $charset); $this->table...
php
public function buildTable(Schema $schema, $aliasName, $charset, $collate) { $tableName = $this->tablePrefix . $aliasName; $this->table = $schema->createTable($tableName); $this->table->addOption('alias', $aliasName); $this->table->addOption('charset', $charset); $this->table...
[ "public", "function", "buildTable", "(", "Schema", "$", "schema", ",", "$", "aliasName", ",", "$", "charset", ",", "$", "collate", ")", "{", "$", "tableName", "=", "$", "this", "->", "tablePrefix", ".", "$", "aliasName", ";", "$", "this", "->", "table"...
Get the table's schema object. @param Schema $schema @param string $aliasName @param string $charset @param string $collate @return \Doctrine\DBAL\Schema\Table
[ "Get", "the", "table", "s", "schema", "object", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Database/Schema/Table/BaseTable.php#L66-L81
bolt/bolt
src/Composer/Action/UpdatePackage.php
UpdatePackage.execute
public function execute(array $packages = [], array $options = []) { // Handle passed in options foreach ($options as $key => $value) { $this->getOptions()->set($key, $value); } /** @var \Composer\Composer $composer */ $composer = $this->getComposer(); $i...
php
public function execute(array $packages = [], array $options = []) { // Handle passed in options foreach ($options as $key => $value) { $this->getOptions()->set($key, $value); } /** @var \Composer\Composer $composer */ $composer = $this->getComposer(); $i...
[ "public", "function", "execute", "(", "array", "$", "packages", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// Handle passed in options", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "$", ...
Update packages. @param $packages array Indexed array of package names to update @param $options array [Optional] changed option set @throws \Bolt\Exception\PackageManagerException @return int 0 on success or a positive error code on failure
[ "Update", "packages", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Composer/Action/UpdatePackage.php#L25-L62
bolt/bolt
src/Storage/Field/Sanitiser/Sanitiser.php
Sanitiser.sanitise
public function sanitise($value, $isWysiwyg = false) { $allowedTags = $isWysiwyg ? $this->getWyswigAllowedTags() : $this->getAllowedTags(); // Check if the input containts encoded HTML entities. If it does, we'll // need to decode the output later. This is because th...
php
public function sanitise($value, $isWysiwyg = false) { $allowedTags = $isWysiwyg ? $this->getWyswigAllowedTags() : $this->getAllowedTags(); // Check if the input containts encoded HTML entities. If it does, we'll // need to decode the output later. This is because th...
[ "public", "function", "sanitise", "(", "$", "value", ",", "$", "isWysiwyg", "=", "false", ")", "{", "$", "allowedTags", "=", "$", "isWysiwyg", "?", "$", "this", "->", "getWyswigAllowedTags", "(", ")", ":", "$", "this", "->", "getAllowedTags", "(", ")", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Sanitiser/Sanitiser.php#L38-L68
bolt/bolt
src/Storage/Field/Sanitiser/Sanitiser.php
Sanitiser.getWyswigAllowedTags
protected function getWyswigAllowedTags() { $allowedBecauseWysiwyg = [ 'div', 'p', 'br', 'pre', 'a', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'ul', 'ol', 'strong', 'em', 'i', 'b', ]; if ($this->isWysiwygEnabled('images')) { $allo...
php
protected function getWyswigAllowedTags() { $allowedBecauseWysiwyg = [ 'div', 'p', 'br', 'pre', 'a', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'ul', 'ol', 'strong', 'em', 'i', 'b', ]; if ($this->isWysiwygEnabled('images')) { $allo...
[ "protected", "function", "getWyswigAllowedTags", "(", ")", "{", "$", "allowedBecauseWysiwyg", "=", "[", "'div'", ",", "'p'", ",", "'br'", ",", "'pre'", ",", "'a'", ",", "'h1'", ",", "'h2'", ",", "'h3'", ",", "'h4'", ",", "'h5'", ",", "'h6'", ",", "'li'...
Return a list of allowed tags needed for WYSIWYG field types. For HTML fields we want to override a few tags, e.g, it makes no sense to disallow `<iframe>` if we have `embed: true` in config.yml. @return array
[ "Return", "a", "list", "of", "allowed", "tags", "needed", "for", "WYSIWYG", "field", "types", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Sanitiser/Sanitiser.php#L115-L171
bolt/bolt
src/Storage/Field/Sanitiser/Sanitiser.php
Sanitiser.isWysiwygEnabled
protected function isWysiwygEnabled($name) { return isset($this->allowedWyswig[$name]) && (bool) $this->allowedWyswig[$name]; }
php
protected function isWysiwygEnabled($name) { return isset($this->allowedWyswig[$name]) && (bool) $this->allowedWyswig[$name]; }
[ "protected", "function", "isWysiwygEnabled", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "allowedWyswig", "[", "$", "name", "]", ")", "&&", "(", "bool", ")", "$", "this", "->", "allowedWyswig", "[", "$", "name", "]", ";", "...
Return a WYSIWYG configuration value. @param string $name @return bool
[ "Return", "a", "WYSIWYG", "configuration", "value", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Sanitiser/Sanitiser.php#L180-L183
bolt/bolt
src/Composer/Action/DumpAutoload.php
DumpAutoload.execute
public function execute() { /** @var $composer \Composer\Composer */ $composer = $this->getComposer(); $installationManager = $composer->getInstallationManager(); $localRepo = $composer->getRepositoryManager()->getLocalRepository(); $package = $composer->getPackage(); ...
php
public function execute() { /** @var $composer \Composer\Composer */ $composer = $this->getComposer(); $installationManager = $composer->getInstallationManager(); $localRepo = $composer->getRepositoryManager()->getLocalRepository(); $package = $composer->getPackage(); ...
[ "public", "function", "execute", "(", ")", "{", "/** @var $composer \\Composer\\Composer */", "$", "composer", "=", "$", "this", "->", "getComposer", "(", ")", ";", "$", "installationManager", "=", "$", "composer", "->", "getInstallationManager", "(", ")", ";", ...
Dump autoloaders. @throws \Bolt\Exception\PackageManagerException @return int 0 on success or a positive error code on failure
[ "Dump", "autoloaders", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Composer/Action/DumpAutoload.php#L21-L54
bolt/bolt
src/Storage/Field/Collection/FieldCollection.php
FieldCollection.getNew
public function getNew() { $created = []; foreach ($this as $k => $entity) { $id = $entity->getId(); if (!$id) { $created[] = $entity; } } return $created; }
php
public function getNew() { $created = []; foreach ($this as $k => $entity) { $id = $entity->getId(); if (!$id) { $created[] = $entity; } } return $created; }
[ "public", "function", "getNew", "(", ")", "{", "$", "created", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "k", "=>", "$", "entity", ")", "{", "$", "id", "=", "$", "entity", "->", "getId", "(", ")", ";", "if", "(", "!", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Collection/FieldCollection.php#L41-L52
bolt/bolt
src/Storage/Field/Collection/FieldCollection.php
FieldCollection.getExisting
public function getExisting() { $set = []; foreach ($this as $k => $entity) { $id = $entity->getId(); if ($id) { $set[] = $entity; } } return $set; }
php
public function getExisting() { $set = []; foreach ($this as $k => $entity) { $id = $entity->getId(); if ($id) { $set[] = $entity; } } return $set; }
[ "public", "function", "getExisting", "(", ")", "{", "$", "set", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "k", "=>", "$", "entity", ")", "{", "$", "id", "=", "$", "entity", "->", "getId", "(", ")", ";", "if", "(", "$", "id",...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Collection/FieldCollection.php#L57-L68
bolt/bolt
src/Storage/Field/Collection/FieldCollection.php
FieldCollection.get
public function get($key) { $result = parent::get($key); if ($result instanceof FieldValue) { $result = $result->getValue(); } return $result; }
php
public function get($key) { $result = parent::get($key); if ($result instanceof FieldValue) { $result = $result->getValue(); } return $result; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "result", "=", "parent", "::", "get", "(", "$", "key", ")", ";", "if", "(", "$", "result", "instanceof", "FieldValue", ")", "{", "$", "result", "=", "$", "result", "->", "getValue", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Collection/FieldCollection.php#L73-L82
bolt/bolt
src/Storage/Field/Collection/FieldCollection.php
FieldCollection.setGrouping
public function setGrouping($grouping) { $this->grouping = $grouping; foreach ($this as $entity) { $entity->setGrouping($grouping); } }
php
public function setGrouping($grouping) { $this->grouping = $grouping; foreach ($this as $entity) { $entity->setGrouping($grouping); } }
[ "public", "function", "setGrouping", "(", "$", "grouping", ")", "{", "$", "this", "->", "grouping", "=", "$", "grouping", ";", "foreach", "(", "$", "this", "as", "$", "entity", ")", "{", "$", "entity", "->", "setGrouping", "(", "$", "grouping", ")", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Collection/FieldCollection.php#L87-L94
bolt/bolt
src/Storage/Field/Collection/FieldCollection.php
FieldCollection.add
public function add($value) { Assert::isInstanceOf($value, FieldValue::class); $this->set($value->getFieldName(), $value); return true; }
php
public function add($value) { Assert::isInstanceOf($value, FieldValue::class); $this->set($value->getFieldName(), $value); return true; }
[ "public", "function", "add", "(", "$", "value", ")", "{", "Assert", "::", "isInstanceOf", "(", "$", "value", ",", "FieldValue", "::", "class", ")", ";", "$", "this", "->", "set", "(", "$", "value", "->", "getFieldName", "(", ")", ",", "$", "value", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Collection/FieldCollection.php#L115-L122
bolt/bolt
src/Storage/Field/Collection/FieldCollection.php
FieldCollection.set
public function set($key, $value) { Assert::isInstanceOf($value, FieldValue::class); $value->setGrouping($this->grouping); parent::set($key, $value); }
php
public function set($key, $value) { Assert::isInstanceOf($value, FieldValue::class); $value->setGrouping($this->grouping); parent::set($key, $value); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "Assert", "::", "isInstanceOf", "(", "$", "value", ",", "FieldValue", "::", "class", ")", ";", "$", "value", "->", "setGrouping", "(", "$", "this", "->", "grouping", ")", ";",...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Collection/FieldCollection.php#L127-L134
bolt/bolt
src/Storage/Field/Collection/FieldCollection.php
FieldCollection.getFieldType
public function getFieldType($fieldName) { $field = parent::get($fieldName); if ($field) { return $field->getFieldType(); } return null; }
php
public function getFieldType($fieldName) { $field = parent::get($fieldName); if ($field) { return $field->getFieldType(); } return null; }
[ "public", "function", "getFieldType", "(", "$", "fieldName", ")", "{", "$", "field", "=", "parent", "::", "get", "(", "$", "fieldName", ")", ";", "if", "(", "$", "field", ")", "{", "return", "$", "field", "->", "getFieldType", "(", ")", ";", "}", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Collection/FieldCollection.php#L158-L167
bolt/bolt
src/Storage/Field/Collection/FieldCollection.php
FieldCollection.getRenderedValue
public function getRenderedValue($fieldName) { $field = parent::get($fieldName); if (!$field instanceof FieldValue) { return null; } $fieldType = $field->getFieldType(); $value = $field->getValue(); if ($fieldType === 'markdown') { $markdown...
php
public function getRenderedValue($fieldName) { $field = parent::get($fieldName); if (!$field instanceof FieldValue) { return null; } $fieldType = $field->getFieldType(); $value = $field->getValue(); if ($fieldType === 'markdown') { $markdown...
[ "public", "function", "getRenderedValue", "(", "$", "fieldName", ")", "{", "$", "field", "=", "parent", "::", "get", "(", "$", "fieldName", ")", ";", "if", "(", "!", "$", "field", "instanceof", "FieldValue", ")", "{", "return", "null", ";", "}", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Storage/Field/Collection/FieldCollection.php#L172-L193
bolt/bolt
src/Asset/Widget/Queue.php
Queue.add
public function add(WidgetAssetInterface $widget) { $widget->setKey(); $this->queue[$widget->getKey()] = $widget; }
php
public function add(WidgetAssetInterface $widget) { $widget->setKey(); $this->queue[$widget->getKey()] = $widget; }
[ "public", "function", "add", "(", "WidgetAssetInterface", "$", "widget", ")", "{", "$", "widget", "->", "setKey", "(", ")", ";", "$", "this", "->", "queue", "[", "$", "widget", "->", "getKey", "(", ")", "]", "=", "$", "widget", ";", "}" ]
Add a widget to the queue. @param WidgetAssetInterface $widget
[ "Add", "a", "widget", "to", "the", "queue", "." ]
train
https://github.com/bolt/bolt/blob/127434d79990b54abfb3e830243deaf725baa4de/src/Asset/Widget/Queue.php#L67-L71