repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
boomcms/boom-core
src/BoomCMS/Chunk/Linkset.php
Linkset.getLinks
public function getLinks(int $limit = 0): array { if ($this->links === null) { $links = $this->attrs['links'] ?? []; $this->links = $this->removeInvalidOrHiddenLinks($links); } return $limit > 0 ? array_slice($this->links, 0, $limit) : $this->links; }
php
public function getLinks(int $limit = 0): array { if ($this->links === null) { $links = $this->attrs['links'] ?? []; $this->links = $this->removeInvalidOrHiddenLinks($links); } return $limit > 0 ? array_slice($this->links, 0, $limit) : $this->links; }
[ "public", "function", "getLinks", "(", "int", "$", "limit", "=", "0", ")", ":", "array", "{", "if", "(", "$", "this", "->", "links", "===", "null", ")", "{", "$", "links", "=", "$", "this", "->", "attrs", "[", "'links'", "]", "??", "[", "]", ";", "$", "this", "->", "links", "=", "$", "this", "->", "removeInvalidOrHiddenLinks", "(", "$", "links", ")", ";", "}", "return", "$", "limit", ">", "0", "?", "array_slice", "(", "$", "this", "->", "links", ",", "0", ",", "$", "limit", ")", ":", "$", "this", "->", "links", ";", "}" ]
Returns an array of links in the linkset. Or an empty array if the linkset doesn't contain any (valid, visible) links @param int $limit @return array
[ "Returns", "an", "array", "of", "links", "in", "the", "linkset", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Linkset.php#L63-L71
train
markstory/mini-asset
src/Filter/TimestampImage.php
TimestampImage.input
public function input($filename, $content) { $this->_filename = $filename; $content = preg_replace_callback($this->_backgroundPattern, array($this, '_replace'), $content); $content = preg_replace_callback($this->_backgroundImagePattern, array($this, '_replace'), $content); return $content; }
php
public function input($filename, $content) { $this->_filename = $filename; $content = preg_replace_callback($this->_backgroundPattern, array($this, '_replace'), $content); $content = preg_replace_callback($this->_backgroundImagePattern, array($this, '_replace'), $content); return $content; }
[ "public", "function", "input", "(", "$", "filename", ",", "$", "content", ")", "{", "$", "this", "->", "_filename", "=", "$", "filename", ";", "$", "content", "=", "preg_replace_callback", "(", "$", "this", "->", "_backgroundPattern", ",", "array", "(", "$", "this", ",", "'_replace'", ")", ",", "$", "content", ")", ";", "$", "content", "=", "preg_replace_callback", "(", "$", "this", "->", "_backgroundImagePattern", ",", "array", "(", "$", "this", ",", "'_replace'", ")", ",", "$", "content", ")", ";", "return", "$", "content", ";", "}" ]
Input filter. Locates CSS background images relative to the filename and gets the filemtime for the images. @param string $filename The file being processed @param string $content The file content @return The content with images timestamped.
[ "Input", "filter", ".", "Locates", "CSS", "background", "images", "relative", "to", "the", "filename", "and", "gets", "the", "filemtime", "for", "the", "images", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/TimestampImage.php#L56-L62
train
markstory/mini-asset
src/Filter/TimestampImage.php
TimestampImage._replace
protected function _replace($matches) { $webroot = null; if (defined('WWW_ROOT')) { $webroot = WWW_ROOT; } if (!empty($this->_settings['webroot'])) { $webroot = $this->_settings['webroot']; } $path = $matches['path']; if ($path[0] === '/') { $imagePath = $webroot . rtrim($path, '/'); } else { $imagePath = realpath(dirname($this->_filename) . DIRECTORY_SEPARATOR . $path); } if (file_exists($imagePath)) { $path = $this->_timestamp($imagePath, $path); } return $matches['prop'] . $path . $matches['trail']; }
php
protected function _replace($matches) { $webroot = null; if (defined('WWW_ROOT')) { $webroot = WWW_ROOT; } if (!empty($this->_settings['webroot'])) { $webroot = $this->_settings['webroot']; } $path = $matches['path']; if ($path[0] === '/') { $imagePath = $webroot . rtrim($path, '/'); } else { $imagePath = realpath(dirname($this->_filename) . DIRECTORY_SEPARATOR . $path); } if (file_exists($imagePath)) { $path = $this->_timestamp($imagePath, $path); } return $matches['prop'] . $path . $matches['trail']; }
[ "protected", "function", "_replace", "(", "$", "matches", ")", "{", "$", "webroot", "=", "null", ";", "if", "(", "defined", "(", "'WWW_ROOT'", ")", ")", "{", "$", "webroot", "=", "WWW_ROOT", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "_settings", "[", "'webroot'", "]", ")", ")", "{", "$", "webroot", "=", "$", "this", "->", "_settings", "[", "'webroot'", "]", ";", "}", "$", "path", "=", "$", "matches", "[", "'path'", "]", ";", "if", "(", "$", "path", "[", "0", "]", "===", "'/'", ")", "{", "$", "imagePath", "=", "$", "webroot", ".", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "}", "else", "{", "$", "imagePath", "=", "realpath", "(", "dirname", "(", "$", "this", "->", "_filename", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "path", ")", ";", "}", "if", "(", "file_exists", "(", "$", "imagePath", ")", ")", "{", "$", "path", "=", "$", "this", "->", "_timestamp", "(", "$", "imagePath", ",", "$", "path", ")", ";", "}", "return", "$", "matches", "[", "'prop'", "]", ".", "$", "path", ".", "$", "matches", "[", "'trail'", "]", ";", "}" ]
Do replacements. - $matches[0] -> whole background line. - $matches[path] -> the url with any wrapping '/' If the image path starts with / its assumed to be an absolute path which will be prepended with settings[webroot] or WWW_ROOT @param array $matches Array of matches @return string Replaced code.
[ "Do", "replacements", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/TimestampImage.php#L76-L96
train
markstory/mini-asset
src/Filter/TimestampImage.php
TimestampImage._timestamp
protected function _timestamp($filepath, $path) { if (strpos($path, '?') === false) { $path .= '?t=' . filemtime($filepath); } return $path; }
php
protected function _timestamp($filepath, $path) { if (strpos($path, '?') === false) { $path .= '?t=' . filemtime($filepath); } return $path; }
[ "protected", "function", "_timestamp", "(", "$", "filepath", ",", "$", "path", ")", "{", "if", "(", "strpos", "(", "$", "path", ",", "'?'", ")", "===", "false", ")", "{", "$", "path", ".=", "'?t='", ".", "filemtime", "(", "$", "filepath", ")", ";", "}", "return", "$", "path", ";", "}" ]
Add timestamps to the given path. Will not change paths with querystrings, as they could have anything in them or be customized already. @param string $filepath The absolute path to the file for timestamping @param string $path The path to append a timestamp to. @return string Path with a timestamp.
[ "Add", "timestamps", "to", "the", "given", "path", ".", "Will", "not", "change", "paths", "with", "querystrings", "as", "they", "could", "have", "anything", "in", "them", "or", "be", "customized", "already", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/TimestampImage.php#L107-L113
train
boomcms/boom-core
src/BoomCMS/FileInfo/Drivers/DefaultDriver.php
DefaultDriver.oneOf
protected function oneOf(array $keys, $default = null) { $metadata = $this->getMetadata(); foreach ($keys as $key) { if (isset($metadata[$key])) { return $metadata[$key]; } } return $default; }
php
protected function oneOf(array $keys, $default = null) { $metadata = $this->getMetadata(); foreach ($keys as $key) { if (isset($metadata[$key])) { return $metadata[$key]; } } return $default; }
[ "protected", "function", "oneOf", "(", "array", "$", "keys", ",", "$", "default", "=", "null", ")", "{", "$", "metadata", "=", "$", "this", "->", "getMetadata", "(", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "metadata", "[", "$", "key", "]", ")", ")", "{", "return", "$", "metadata", "[", "$", "key", "]", ";", "}", "}", "return", "$", "default", ";", "}" ]
Loop through an array of metadata keys and return the first one that exists. @param array $keys @param mixed $default @return mixed
[ "Loop", "through", "an", "array", "of", "metadata", "keys", "and", "return", "the", "first", "one", "that", "exists", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/FileInfo/Drivers/DefaultDriver.php#L132-L143
train
inteleon/extended-fpdf
src/Pdf.php
Pdf.WriteXY
public function WriteXY($x, $y, $line, $txt, $link = '') { $this->SetXY($x, $y); $this->Write($line, $txt, $link); }
php
public function WriteXY($x, $y, $line, $txt, $link = '') { $this->SetXY($x, $y); $this->Write($line, $txt, $link); }
[ "public", "function", "WriteXY", "(", "$", "x", ",", "$", "y", ",", "$", "line", ",", "$", "txt", ",", "$", "link", "=", "''", ")", "{", "$", "this", "->", "SetXY", "(", "$", "x", ",", "$", "y", ")", ";", "$", "this", "->", "Write", "(", "$", "line", ",", "$", "txt", ",", "$", "link", ")", ";", "}" ]
Write to position @param string $x @param string $y @param string $line @param string $txt @param string|identifier $link URL or identifier returned by AddLink(). @return void
[ "Write", "to", "position" ]
0bf54d0ee18f6f582ce7ce2b1d3bacf8a24b7fe3
https://github.com/inteleon/extended-fpdf/blob/0bf54d0ee18f6f582ce7ce2b1d3bacf8a24b7fe3/src/Pdf.php#L398-L402
train
inteleon/extended-fpdf
src/Pdf.php
Pdf.arc
public function arc($x1, $y1, $x2, $y2, $x3, $y3) { $h = $this->h; $this->out( sprintf( '%.2F %.2F %.2F %.2F %.2F %.2F c ', $x1 * $this->k, ($h - $y1) * $this->k, $x2 * $this->k, ($h - $y2) * $this->k, $x3 * $this->k, ($h - $y3) * $this->k ) ); }
php
public function arc($x1, $y1, $x2, $y2, $x3, $y3) { $h = $this->h; $this->out( sprintf( '%.2F %.2F %.2F %.2F %.2F %.2F c ', $x1 * $this->k, ($h - $y1) * $this->k, $x2 * $this->k, ($h - $y2) * $this->k, $x3 * $this->k, ($h - $y3) * $this->k ) ); }
[ "public", "function", "arc", "(", "$", "x1", ",", "$", "y1", ",", "$", "x2", ",", "$", "y2", ",", "$", "x3", ",", "$", "y3", ")", "{", "$", "h", "=", "$", "this", "->", "h", ";", "$", "this", "->", "out", "(", "sprintf", "(", "'%.2F %.2F %.2F %.2F %.2F %.2F c '", ",", "$", "x1", "*", "$", "this", "->", "k", ",", "(", "$", "h", "-", "$", "y1", ")", "*", "$", "this", "->", "k", ",", "$", "x2", "*", "$", "this", "->", "k", ",", "(", "$", "h", "-", "$", "y2", ")", "*", "$", "this", "->", "k", ",", "$", "x3", "*", "$", "this", "->", "k", ",", "(", "$", "h", "-", "$", "y3", ")", "*", "$", "this", "->", "k", ")", ")", ";", "}" ]
Create an Arc. @param int $x1 @param int $y1 @param int $x2 @param int $y2 @param int $x3 @param int $y3
[ "Create", "an", "Arc", "." ]
0bf54d0ee18f6f582ce7ce2b1d3bacf8a24b7fe3
https://github.com/inteleon/extended-fpdf/blob/0bf54d0ee18f6f582ce7ce2b1d3bacf8a24b7fe3/src/Pdf.php#L671-L685
train
inteleon/extended-fpdf
src/Pdf.php
Pdf.circle
public function circle($x, $y, $r, $style = 'D') { $this->Ellipse($x, $y, $r, $r, $style); }
php
public function circle($x, $y, $r, $style = 'D') { $this->Ellipse($x, $y, $r, $r, $style); }
[ "public", "function", "circle", "(", "$", "x", ",", "$", "y", ",", "$", "r", ",", "$", "style", "=", "'D'", ")", "{", "$", "this", "->", "Ellipse", "(", "$", "x", ",", "$", "y", ",", "$", "r", ",", "$", "r", ",", "$", "style", ")", ";", "}" ]
create a circle. @param int $x @param int $y @param int $r @param string $style
[ "create", "a", "circle", "." ]
0bf54d0ee18f6f582ce7ce2b1d3bacf8a24b7fe3
https://github.com/inteleon/extended-fpdf/blob/0bf54d0ee18f6f582ce7ce2b1d3bacf8a24b7fe3/src/Pdf.php#L695-L698
train
inteleon/extended-fpdf
src/Pdf.php
Pdf.getCode128CheckNum
public function getCode128CheckNum($val) { $sum = 103; for ($i = 0; $i < strlen($val); $i++) { $sum += ($i + 1) * $this->ChrToC128(ord(substr($val, $i, 1))); } $ch_num = $sum % 103; return $ch_num; }
php
public function getCode128CheckNum($val) { $sum = 103; for ($i = 0; $i < strlen($val); $i++) { $sum += ($i + 1) * $this->ChrToC128(ord(substr($val, $i, 1))); } $ch_num = $sum % 103; return $ch_num; }
[ "public", "function", "getCode128CheckNum", "(", "$", "val", ")", "{", "$", "sum", "=", "103", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "val", ")", ";", "$", "i", "++", ")", "{", "$", "sum", "+=", "(", "$", "i", "+", "1", ")", "*", "$", "this", "->", "ChrToC128", "(", "ord", "(", "substr", "(", "$", "val", ",", "$", "i", ",", "1", ")", ")", ")", ";", "}", "$", "ch_num", "=", "$", "sum", "%", "103", ";", "return", "$", "ch_num", ";", "}" ]
helper method get Code 128. @param string $val @return int
[ "helper", "method", "get", "Code", "128", "." ]
0bf54d0ee18f6f582ce7ce2b1d3bacf8a24b7fe3
https://github.com/inteleon/extended-fpdf/blob/0bf54d0ee18f6f582ce7ce2b1d3bacf8a24b7fe3/src/Pdf.php#L983-L993
train
boomcms/boom-core
src/BoomCMS/Page/History/Diff.php
Diff.compare
public function compare(PageVersion $new, PageVersion $old) { if ($new->getRestoredVersionId()) { return new Diff\RestoredVersion($new, $old); } if ($new->isContentChange()) { return new Diff\ChunkChange($new, $old); } if ($new->getTemplateId() !== $old->getTemplateId()) { return new Diff\TemplateChange($new, $old); } if (strcmp($new->getTitle(), $old->getTitle()) !== 0) { return new Diff\TitleChange($new, $old); } if ($new->isPendingApproval() && !$old->isPendingApproval()) { return new Diff\ApprovalRequest($new, $old); } if ($new->isEmbargoed($new->getEditedTime())) { if (!$old->isEmbargoed($old->getEditedTime())) { return new Diff\Embargoed($new, $old); } if ($new->getEmbargoedUntil()->getTimestamp() !== $old->getEmbargoedUntil()->getTimestamp()) { return new Diff\EmbargoChanged($new, $old); } } if ($new->isPublished($new->getEditedTime())) { if (!$old->isPublished($old->getEditedTime())) { return new Diff\Published($new, $old); } } }
php
public function compare(PageVersion $new, PageVersion $old) { if ($new->getRestoredVersionId()) { return new Diff\RestoredVersion($new, $old); } if ($new->isContentChange()) { return new Diff\ChunkChange($new, $old); } if ($new->getTemplateId() !== $old->getTemplateId()) { return new Diff\TemplateChange($new, $old); } if (strcmp($new->getTitle(), $old->getTitle()) !== 0) { return new Diff\TitleChange($new, $old); } if ($new->isPendingApproval() && !$old->isPendingApproval()) { return new Diff\ApprovalRequest($new, $old); } if ($new->isEmbargoed($new->getEditedTime())) { if (!$old->isEmbargoed($old->getEditedTime())) { return new Diff\Embargoed($new, $old); } if ($new->getEmbargoedUntil()->getTimestamp() !== $old->getEmbargoedUntil()->getTimestamp()) { return new Diff\EmbargoChanged($new, $old); } } if ($new->isPublished($new->getEditedTime())) { if (!$old->isPublished($old->getEditedTime())) { return new Diff\Published($new, $old); } } }
[ "public", "function", "compare", "(", "PageVersion", "$", "new", ",", "PageVersion", "$", "old", ")", "{", "if", "(", "$", "new", "->", "getRestoredVersionId", "(", ")", ")", "{", "return", "new", "Diff", "\\", "RestoredVersion", "(", "$", "new", ",", "$", "old", ")", ";", "}", "if", "(", "$", "new", "->", "isContentChange", "(", ")", ")", "{", "return", "new", "Diff", "\\", "ChunkChange", "(", "$", "new", ",", "$", "old", ")", ";", "}", "if", "(", "$", "new", "->", "getTemplateId", "(", ")", "!==", "$", "old", "->", "getTemplateId", "(", ")", ")", "{", "return", "new", "Diff", "\\", "TemplateChange", "(", "$", "new", ",", "$", "old", ")", ";", "}", "if", "(", "strcmp", "(", "$", "new", "->", "getTitle", "(", ")", ",", "$", "old", "->", "getTitle", "(", ")", ")", "!==", "0", ")", "{", "return", "new", "Diff", "\\", "TitleChange", "(", "$", "new", ",", "$", "old", ")", ";", "}", "if", "(", "$", "new", "->", "isPendingApproval", "(", ")", "&&", "!", "$", "old", "->", "isPendingApproval", "(", ")", ")", "{", "return", "new", "Diff", "\\", "ApprovalRequest", "(", "$", "new", ",", "$", "old", ")", ";", "}", "if", "(", "$", "new", "->", "isEmbargoed", "(", "$", "new", "->", "getEditedTime", "(", ")", ")", ")", "{", "if", "(", "!", "$", "old", "->", "isEmbargoed", "(", "$", "old", "->", "getEditedTime", "(", ")", ")", ")", "{", "return", "new", "Diff", "\\", "Embargoed", "(", "$", "new", ",", "$", "old", ")", ";", "}", "if", "(", "$", "new", "->", "getEmbargoedUntil", "(", ")", "->", "getTimestamp", "(", ")", "!==", "$", "old", "->", "getEmbargoedUntil", "(", ")", "->", "getTimestamp", "(", ")", ")", "{", "return", "new", "Diff", "\\", "EmbargoChanged", "(", "$", "new", ",", "$", "old", ")", ";", "}", "}", "if", "(", "$", "new", "->", "isPublished", "(", "$", "new", "->", "getEditedTime", "(", ")", ")", ")", "{", "if", "(", "!", "$", "old", "->", "isPublished", "(", "$", "old", "->", "getEditedTime", "(", ")", ")", ")", "{", "return", "new", "Diff", "\\", "Published", "(", "$", "new", ",", "$", "old", ")", ";", "}", "}", "}" ]
Compare two versions. @param PageVersion $new @param PageVersion $old @return Diff\BaseChange
[ "Compare", "two", "versions", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Page/History/Diff.php#L17-L54
train
boomcms/boom-core
src/BoomCMS/Chunk/Provider.php
Provider.allowedToEdit
public function allowedToEdit(Page $page = null) { if ($page === null) { return true; } return Editor::isEnabled() && $this->gate->allows('edit', $page); }
php
public function allowedToEdit(Page $page = null) { if ($page === null) { return true; } return Editor::isEnabled() && $this->gate->allows('edit', $page); }
[ "public", "function", "allowedToEdit", "(", "Page", "$", "page", "=", "null", ")", "{", "if", "(", "$", "page", "===", "null", ")", "{", "return", "true", ";", "}", "return", "Editor", "::", "isEnabled", "(", ")", "&&", "$", "this", "->", "gate", "->", "allows", "(", "'edit'", ",", "$", "page", ")", ";", "}" ]
Returns whether the logged in user is allowed to edit a page. @return bool
[ "Returns", "whether", "the", "logged", "in", "user", "is", "allowed", "to", "edit", "a", "page", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Provider.php#L84-L91
train
boomcms/boom-core
src/BoomCMS/Chunk/Provider.php
Provider.edit
public function edit($type, $slotname, $page = null) { $className = $this->getClassName($type); if ($page === null) { $page = Router::getActivePage(); } $model = $this->find($type, $slotname, $page->getCurrentVersion()); $attrs = $model ? $model->toArray() : []; $chunk = new $className($page, $attrs, $slotname); return $chunk->editable($this->allowedToEdit($page)); }
php
public function edit($type, $slotname, $page = null) { $className = $this->getClassName($type); if ($page === null) { $page = Router::getActivePage(); } $model = $this->find($type, $slotname, $page->getCurrentVersion()); $attrs = $model ? $model->toArray() : []; $chunk = new $className($page, $attrs, $slotname); return $chunk->editable($this->allowedToEdit($page)); }
[ "public", "function", "edit", "(", "$", "type", ",", "$", "slotname", ",", "$", "page", "=", "null", ")", "{", "$", "className", "=", "$", "this", "->", "getClassName", "(", "$", "type", ")", ";", "if", "(", "$", "page", "===", "null", ")", "{", "$", "page", "=", "Router", "::", "getActivePage", "(", ")", ";", "}", "$", "model", "=", "$", "this", "->", "find", "(", "$", "type", ",", "$", "slotname", ",", "$", "page", "->", "getCurrentVersion", "(", ")", ")", ";", "$", "attrs", "=", "$", "model", "?", "$", "model", "->", "toArray", "(", ")", ":", "[", "]", ";", "$", "chunk", "=", "new", "$", "className", "(", "$", "page", ",", "$", "attrs", ",", "$", "slotname", ")", ";", "return", "$", "chunk", "->", "editable", "(", "$", "this", "->", "allowedToEdit", "(", "$", "page", ")", ")", ";", "}" ]
Returns a chunk object of the required type. @param string $type Chunk type, e.g. text, feature, etc. @param string $slotname The name of the slot to retrieve a chunk from. @param mixed $page The page the chunk belongs to. If not given then the page from the current request will be used. @return BaseChunk
[ "Returns", "a", "chunk", "object", "of", "the", "required", "type", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Provider.php#L102-L116
train
boomcms/boom-core
src/BoomCMS/Chunk/Provider.php
Provider.find
public function find($type, $slotname, PageVersion $version) { $cached = $this->getFromCache($type, $slotname, $version); if ($cached !== false) { return $cached; } $class = $this->getModelName($type); $chunk = $version->getId() ? $class::getSingleChunk($version, $slotname)->first() : null; $this->saveToCache($type, $slotname, $version, $chunk); return $chunk; }
php
public function find($type, $slotname, PageVersion $version) { $cached = $this->getFromCache($type, $slotname, $version); if ($cached !== false) { return $cached; } $class = $this->getModelName($type); $chunk = $version->getId() ? $class::getSingleChunk($version, $slotname)->first() : null; $this->saveToCache($type, $slotname, $version, $chunk); return $chunk; }
[ "public", "function", "find", "(", "$", "type", ",", "$", "slotname", ",", "PageVersion", "$", "version", ")", "{", "$", "cached", "=", "$", "this", "->", "getFromCache", "(", "$", "type", ",", "$", "slotname", ",", "$", "version", ")", ";", "if", "(", "$", "cached", "!==", "false", ")", "{", "return", "$", "cached", ";", "}", "$", "class", "=", "$", "this", "->", "getModelName", "(", "$", "type", ")", ";", "$", "chunk", "=", "$", "version", "->", "getId", "(", ")", "?", "$", "class", "::", "getSingleChunk", "(", "$", "version", ",", "$", "slotname", ")", "->", "first", "(", ")", ":", "null", ";", "$", "this", "->", "saveToCache", "(", "$", "type", ",", "$", "slotname", ",", "$", "version", ",", "$", "chunk", ")", ";", "return", "$", "chunk", ";", "}" ]
Find a chunk by page version, type, and slotname. @param string $type @param string $slotname @param PageVersion $version @return null|BaseChunk
[ "Find", "a", "chunk", "by", "page", "version", "type", "and", "slotname", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Provider.php#L127-L144
train
boomcms/boom-core
src/BoomCMS/Chunk/Provider.php
Provider.findById
public function findById($type, $chunkId) { $model = $this->getModelName($type); return $model::find($chunkId); }
php
public function findById($type, $chunkId) { $model = $this->getModelName($type); return $model::find($chunkId); }
[ "public", "function", "findById", "(", "$", "type", ",", "$", "chunkId", ")", "{", "$", "model", "=", "$", "this", "->", "getModelName", "(", "$", "type", ")", ";", "return", "$", "model", "::", "find", "(", "$", "chunkId", ")", ";", "}" ]
Find a chunk by it's ID. @param string $type @param int $chunkId @return ChunkModel
[ "Find", "a", "chunk", "by", "it", "s", "ID", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Provider.php#L154-L159
train
boomcms/boom-core
src/BoomCMS/Chunk/Provider.php
Provider.getFromCache
public function getFromCache($type, $slotname, PageVersion $version) { $key = $this->getCacheKey($type, $slotname, $version); return $this->cache->get($key, false); }
php
public function getFromCache($type, $slotname, PageVersion $version) { $key = $this->getCacheKey($type, $slotname, $version); return $this->cache->get($key, false); }
[ "public", "function", "getFromCache", "(", "$", "type", ",", "$", "slotname", ",", "PageVersion", "$", "version", ")", "{", "$", "key", "=", "$", "this", "->", "getCacheKey", "(", "$", "type", ",", "$", "slotname", ",", "$", "version", ")", ";", "return", "$", "this", "->", "cache", "->", "get", "(", "$", "key", ",", "false", ")", ";", "}" ]
Get a chunk from the cache. @param type $type @param type $slotname @param PageVersion $version @return mixed
[ "Get", "a", "chunk", "from", "the", "cache", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Provider.php#L218-L223
train
boomcms/boom-core
src/BoomCMS/Chunk/Provider.php
Provider.insert
public function insert($type, $slotname, $page = null) { if ($page === null || $page === Router::getActivePage()) { return $this->edit($type, $slotname, $page); } return $this->get($type, $slotname, $page); }
php
public function insert($type, $slotname, $page = null) { if ($page === null || $page === Router::getActivePage()) { return $this->edit($type, $slotname, $page); } return $this->get($type, $slotname, $page); }
[ "public", "function", "insert", "(", "$", "type", ",", "$", "slotname", ",", "$", "page", "=", "null", ")", "{", "if", "(", "$", "page", "===", "null", "||", "$", "page", "===", "Router", "::", "getActivePage", "(", ")", ")", "{", "return", "$", "this", "->", "edit", "(", "$", "type", ",", "$", "slotname", ",", "$", "page", ")", ";", "}", "return", "$", "this", "->", "get", "(", "$", "type", ",", "$", "slotname", ",", "$", "page", ")", ";", "}" ]
Insert a chunk into a page. @param string $type @param string $slotname @param null|Page $page @return mixed
[ "Insert", "a", "chunk", "into", "a", "page", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Provider.php#L234-L241
train
boomcms/boom-core
src/BoomCMS/Chunk/Provider.php
Provider.saveToCache
public function saveToCache($type, $slotname, $version, ChunkModel $chunk = null) { $key = $this->getCacheKey($type, $slotname, $version); $this->cache->forever($key, $chunk); }
php
public function saveToCache($type, $slotname, $version, ChunkModel $chunk = null) { $key = $this->getCacheKey($type, $slotname, $version); $this->cache->forever($key, $chunk); }
[ "public", "function", "saveToCache", "(", "$", "type", ",", "$", "slotname", ",", "$", "version", ",", "ChunkModel", "$", "chunk", "=", "null", ")", "{", "$", "key", "=", "$", "this", "->", "getCacheKey", "(", "$", "type", ",", "$", "slotname", ",", "$", "version", ")", ";", "$", "this", "->", "cache", "->", "forever", "(", "$", "key", ",", "$", "chunk", ")", ";", "}" ]
Save a chunk to the cache. @param type $type @param type $slotname @param type $version @param null|ChunkModel $chunk
[ "Save", "a", "chunk", "to", "the", "cache", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Provider.php#L251-L256
train
boomcms/boom-core
src/BoomCMS/Chunk/Provider.php
Provider.since
public function since(PageVersion $version) { $chunks = []; foreach ($this->types as $type) { $className = $this->getModelName($type); $chunks[$type] = $className::getSince($version)->get(); } return $chunks; }
php
public function since(PageVersion $version) { $chunks = []; foreach ($this->types as $type) { $className = $this->getModelName($type); $chunks[$type] = $className::getSince($version)->get(); } return $chunks; }
[ "public", "function", "since", "(", "PageVersion", "$", "version", ")", "{", "$", "chunks", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "types", "as", "$", "type", ")", "{", "$", "className", "=", "$", "this", "->", "getModelName", "(", "$", "type", ")", ";", "$", "chunks", "[", "$", "type", "]", "=", "$", "className", "::", "getSince", "(", "$", "version", ")", "->", "get", "(", ")", ";", "}", "return", "$", "chunks", ";", "}" ]
Returns an array of chunks which have changed since a version. @param PageVersion $version @return array
[ "Returns", "an", "array", "of", "chunks", "which", "have", "changed", "since", "a", "version", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Provider.php#L265-L276
train
markstory/mini-asset
src/Filter/TypeScript.php
TypeScript.input
public function input($filename, $input) { if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) { return $input; } $tmpFile = tempnam(TMP, 'TYPESCRIPT'); $cmd = $this->_settings['typescript'] . " " . escapeshellarg($filename) . " --out " . $tmpFile; $this->_runCmd($cmd, null); $output = file_get_contents($tmpFile); unlink($tmpFile); return $output; }
php
public function input($filename, $input) { if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) { return $input; } $tmpFile = tempnam(TMP, 'TYPESCRIPT'); $cmd = $this->_settings['typescript'] . " " . escapeshellarg($filename) . " --out " . $tmpFile; $this->_runCmd($cmd, null); $output = file_get_contents($tmpFile); unlink($tmpFile); return $output; }
[ "public", "function", "input", "(", "$", "filename", ",", "$", "input", ")", "{", "if", "(", "substr", "(", "$", "filename", ",", "strlen", "(", "$", "this", "->", "_settings", "[", "'ext'", "]", ")", "*", "-", "1", ")", "!==", "$", "this", "->", "_settings", "[", "'ext'", "]", ")", "{", "return", "$", "input", ";", "}", "$", "tmpFile", "=", "tempnam", "(", "TMP", ",", "'TYPESCRIPT'", ")", ";", "$", "cmd", "=", "$", "this", "->", "_settings", "[", "'typescript'", "]", ".", "\" \"", ".", "escapeshellarg", "(", "$", "filename", ")", ".", "\" --out \"", ".", "$", "tmpFile", ";", "$", "this", "->", "_runCmd", "(", "$", "cmd", ",", "null", ")", ";", "$", "output", "=", "file_get_contents", "(", "$", "tmpFile", ")", ";", "unlink", "(", "$", "tmpFile", ")", ";", "return", "$", "output", ";", "}" ]
Runs `tsc` against files that match the configured extension. @param string $filename Filename being processed. @param string $content Content of the file being processed. @return string
[ "Runs", "tsc", "against", "files", "that", "match", "the", "configured", "extension", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/TypeScript.php#L38-L50
train
markstory/mini-asset
src/Filter/Uglifyjs.php
Uglifyjs.output
public function output($filename, $input) { $cmdSep = $this->_settings['version'] <= 1 ? ' - ' : ''; $cmd = $this->_settings['node'] . ' ' . $this->_settings['uglify'] . $cmdSep . $this->_settings['options']; $env = array('NODE_PATH' => $this->_settings['node_path']); return $this->_runCmd($cmd, $input, $env); }
php
public function output($filename, $input) { $cmdSep = $this->_settings['version'] <= 1 ? ' - ' : ''; $cmd = $this->_settings['node'] . ' ' . $this->_settings['uglify'] . $cmdSep . $this->_settings['options']; $env = array('NODE_PATH' => $this->_settings['node_path']); return $this->_runCmd($cmd, $input, $env); }
[ "public", "function", "output", "(", "$", "filename", ",", "$", "input", ")", "{", "$", "cmdSep", "=", "$", "this", "->", "_settings", "[", "'version'", "]", "<=", "1", "?", "' - '", ":", "''", ";", "$", "cmd", "=", "$", "this", "->", "_settings", "[", "'node'", "]", ".", "' '", ".", "$", "this", "->", "_settings", "[", "'uglify'", "]", ".", "$", "cmdSep", ".", "$", "this", "->", "_settings", "[", "'options'", "]", ";", "$", "env", "=", "array", "(", "'NODE_PATH'", "=>", "$", "this", "->", "_settings", "[", "'node_path'", "]", ")", ";", "return", "$", "this", "->", "_runCmd", "(", "$", "cmd", ",", "$", "input", ",", "$", "env", ")", ";", "}" ]
Run `uglifyjs` against the output and compress it. @param string $filename Name of the file being generated. @param string $input The uncompressed contents for $filename. @return string Compressed contents.
[ "Run", "uglifyjs", "against", "the", "output", "and", "compress", "it", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/Uglifyjs.php#L50-L56
train
markstory/mini-asset
src/Filter/CssDependencyTrait.php
CssDependencyTrait._findFile
protected function _findFile($file) { foreach ($this->_settings['paths'] as $path) { $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if (file_exists($path . $file)) { return $path . $file; } } return $file; }
php
protected function _findFile($file) { foreach ($this->_settings['paths'] as $path) { $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if (file_exists($path . $file)) { return $path . $file; } } return $file; }
[ "protected", "function", "_findFile", "(", "$", "file", ")", "{", "foreach", "(", "$", "this", "->", "_settings", "[", "'paths'", "]", "as", "$", "path", ")", "{", "$", "path", "=", "rtrim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "file_exists", "(", "$", "path", ".", "$", "file", ")", ")", "{", "return", "$", "path", ".", "$", "file", ";", "}", "}", "return", "$", "file", ";", "}" ]
Attempt to locate a file in the configured paths. @param string $file The file to find. @return string The resolved file.
[ "Attempt", "to", "locate", "a", "file", "in", "the", "configured", "paths", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/CssDependencyTrait.php#L92-L101
train
markstory/mini-asset
src/Filter/CssDependencyTrait.php
CssDependencyTrait._prependPrefixToFilename
protected function _prependPrefixToFilename($name) { $ds = DIRECTORY_SEPARATOR; $parts = explode($ds, $name); $filename = end($parts); if ($name === $filename || $filename[0] === $this->optionalDependencyPrefix) { return $this->optionalDependencyPrefix . $name; } return str_replace( $ds . $filename, $ds . $this->optionalDependencyPrefix . $filename, $name ); }
php
protected function _prependPrefixToFilename($name) { $ds = DIRECTORY_SEPARATOR; $parts = explode($ds, $name); $filename = end($parts); if ($name === $filename || $filename[0] === $this->optionalDependencyPrefix) { return $this->optionalDependencyPrefix . $name; } return str_replace( $ds . $filename, $ds . $this->optionalDependencyPrefix . $filename, $name ); }
[ "protected", "function", "_prependPrefixToFilename", "(", "$", "name", ")", "{", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "$", "parts", "=", "explode", "(", "$", "ds", ",", "$", "name", ")", ";", "$", "filename", "=", "end", "(", "$", "parts", ")", ";", "if", "(", "$", "name", "===", "$", "filename", "||", "$", "filename", "[", "0", "]", "===", "$", "this", "->", "optionalDependencyPrefix", ")", "{", "return", "$", "this", "->", "optionalDependencyPrefix", ".", "$", "name", ";", "}", "return", "str_replace", "(", "$", "ds", ".", "$", "filename", ",", "$", "ds", ".", "$", "this", "->", "optionalDependencyPrefix", ".", "$", "filename", ",", "$", "name", ")", ";", "}" ]
Prepends filenames with defined prefix if not already defined. @param string $name The file name. @param string The prefixed filename.
[ "Prepends", "filenames", "with", "defined", "prefix", "if", "not", "already", "defined", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/CssDependencyTrait.php#L109-L125
train
boomcms/boom-core
src/BoomCMS/Database/Models/Chunk/Slideshow.php
Slideshow.setSlidesAttribute
public function setSlidesAttribute($slides) { foreach ($slides as &$slide) { if (!$slide instanceof Slideshow\Slide) { $slide['url'] = (isset($slide['page']) && $slide['page'] > 0) ? $slide['page'] : isset($slide['url']) ? $slide['url'] : null; unset($slide['page']); if (isset($slide['asset']) && is_array($slide['asset'])) { $slide['asset_id'] = $slide['asset']['id']; unset($slide['asset']); } $slide = new Slideshow\Slide($slide); } } $this->created(function () use ($slides) { $this->slides()->saveMany($slides); }); }
php
public function setSlidesAttribute($slides) { foreach ($slides as &$slide) { if (!$slide instanceof Slideshow\Slide) { $slide['url'] = (isset($slide['page']) && $slide['page'] > 0) ? $slide['page'] : isset($slide['url']) ? $slide['url'] : null; unset($slide['page']); if (isset($slide['asset']) && is_array($slide['asset'])) { $slide['asset_id'] = $slide['asset']['id']; unset($slide['asset']); } $slide = new Slideshow\Slide($slide); } } $this->created(function () use ($slides) { $this->slides()->saveMany($slides); }); }
[ "public", "function", "setSlidesAttribute", "(", "$", "slides", ")", "{", "foreach", "(", "$", "slides", "as", "&", "$", "slide", ")", "{", "if", "(", "!", "$", "slide", "instanceof", "Slideshow", "\\", "Slide", ")", "{", "$", "slide", "[", "'url'", "]", "=", "(", "isset", "(", "$", "slide", "[", "'page'", "]", ")", "&&", "$", "slide", "[", "'page'", "]", ">", "0", ")", "?", "$", "slide", "[", "'page'", "]", ":", "isset", "(", "$", "slide", "[", "'url'", "]", ")", "?", "$", "slide", "[", "'url'", "]", ":", "null", ";", "unset", "(", "$", "slide", "[", "'page'", "]", ")", ";", "if", "(", "isset", "(", "$", "slide", "[", "'asset'", "]", ")", "&&", "is_array", "(", "$", "slide", "[", "'asset'", "]", ")", ")", "{", "$", "slide", "[", "'asset_id'", "]", "=", "$", "slide", "[", "'asset'", "]", "[", "'id'", "]", ";", "unset", "(", "$", "slide", "[", "'asset'", "]", ")", ";", "}", "$", "slide", "=", "new", "Slideshow", "\\", "Slide", "(", "$", "slide", ")", ";", "}", "}", "$", "this", "->", "created", "(", "function", "(", ")", "use", "(", "$", "slides", ")", "{", "$", "this", "->", "slides", "(", ")", "->", "saveMany", "(", "$", "slides", ")", ";", "}", ")", ";", "}" ]
Persists slide data to the database.
[ "Persists", "slide", "data", "to", "the", "database", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Chunk/Slideshow.php#L24-L46
train
boomcms/boom-core
src/BoomCMS/Http/Controllers/Page/Acl.php
Acl.index
public function index(Page $page) { $this->auth($page); return view('boomcms::editor.page.settings.acl', [ 'page' => $page, 'allGroups' => GroupFacade::findAll(), 'groupIds' => $page->getAclGroupIds(), ]); }
php
public function index(Page $page) { $this->auth($page); return view('boomcms::editor.page.settings.acl', [ 'page' => $page, 'allGroups' => GroupFacade::findAll(), 'groupIds' => $page->getAclGroupIds(), ]); }
[ "public", "function", "index", "(", "Page", "$", "page", ")", "{", "$", "this", "->", "auth", "(", "$", "page", ")", ";", "return", "view", "(", "'boomcms::editor.page.settings.acl'", ",", "[", "'page'", "=>", "$", "page", ",", "'allGroups'", "=>", "GroupFacade", "::", "findAll", "(", ")", ",", "'groupIds'", "=>", "$", "page", "->", "getAclGroupIds", "(", ")", ",", "]", ")", ";", "}" ]
View the page ACL settings. @param Page $page @return View
[ "View", "the", "page", "ACL", "settings", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Http/Controllers/Page/Acl.php#L43-L52
train
keboola/php-component
src/BaseComponent.php
BaseComponent.loadConfig
protected function loadConfig(): void { $configClass = $this->getConfigClass(); $configDefinitionClass = $this->getConfigDefinitionClass(); try { $this->config = new $configClass( $this->getRawConfig(), new $configDefinitionClass() ); } catch (InvalidConfigurationException $e) { throw new UserException($e->getMessage(), 0, $e); } }
php
protected function loadConfig(): void { $configClass = $this->getConfigClass(); $configDefinitionClass = $this->getConfigDefinitionClass(); try { $this->config = new $configClass( $this->getRawConfig(), new $configDefinitionClass() ); } catch (InvalidConfigurationException $e) { throw new UserException($e->getMessage(), 0, $e); } }
[ "protected", "function", "loadConfig", "(", ")", ":", "void", "{", "$", "configClass", "=", "$", "this", "->", "getConfigClass", "(", ")", ";", "$", "configDefinitionClass", "=", "$", "this", "->", "getConfigDefinitionClass", "(", ")", ";", "try", "{", "$", "this", "->", "config", "=", "new", "$", "configClass", "(", "$", "this", "->", "getRawConfig", "(", ")", ",", "new", "$", "configDefinitionClass", "(", ")", ")", ";", "}", "catch", "(", "InvalidConfigurationException", "$", "e", ")", "{", "throw", "new", "UserException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Automatically loads configuration from datadir, instantiates specified config class and validates it with specified confing definition class
[ "Automatically", "loads", "configuration", "from", "datadir", "instantiates", "specified", "config", "class", "and", "validates", "it", "with", "specified", "confing", "definition", "class" ]
5a068b1dcbf461d8209f7f2358e01f7afca344a5
https://github.com/keboola/php-component/blob/5a068b1dcbf461d8209f7f2358e01f7afca344a5/src/BaseComponent.php#L86-L98
train
boomcms/boom-core
src/BoomCMS/Support/Helpers/Asset.php
Asset.controller
public static function controller(AssetModel $asset) { $namespace = 'BoomCMS\Http\Controllers\ViewAsset\\'; if (!$asset->getExtension()) { return; } $byExtension = $namespace.ucfirst($asset->getExtension()); if (class_exists($byExtension)) { return $byExtension; } $byType = $namespace.ucfirst($asset->getType()); if (class_exists($byType)) { return $byType; } return $namespace.'BaseController'; }
php
public static function controller(AssetModel $asset) { $namespace = 'BoomCMS\Http\Controllers\ViewAsset\\'; if (!$asset->getExtension()) { return; } $byExtension = $namespace.ucfirst($asset->getExtension()); if (class_exists($byExtension)) { return $byExtension; } $byType = $namespace.ucfirst($asset->getType()); if (class_exists($byType)) { return $byType; } return $namespace.'BaseController'; }
[ "public", "static", "function", "controller", "(", "AssetModel", "$", "asset", ")", "{", "$", "namespace", "=", "'BoomCMS\\Http\\Controllers\\ViewAsset\\\\'", ";", "if", "(", "!", "$", "asset", "->", "getExtension", "(", ")", ")", "{", "return", ";", "}", "$", "byExtension", "=", "$", "namespace", ".", "ucfirst", "(", "$", "asset", "->", "getExtension", "(", ")", ")", ";", "if", "(", "class_exists", "(", "$", "byExtension", ")", ")", "{", "return", "$", "byExtension", ";", "}", "$", "byType", "=", "$", "namespace", ".", "ucfirst", "(", "$", "asset", "->", "getType", "(", ")", ")", ";", "if", "(", "class_exists", "(", "$", "byType", ")", ")", "{", "return", "$", "byType", ";", "}", "return", "$", "namespace", ".", "'BaseController'", ";", "}" ]
Return the controller to be used to display an asset. @param Asset $asset @return string
[ "Return", "the", "controller", "to", "be", "used", "to", "display", "an", "asset", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers/Asset.php#L17-L36
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig._addConstants
protected function _addConstants($constants) { foreach ($constants as $key => $value) { if (is_resource($value) === false) { if (is_array($value) || strpos($value, DIRECTORY_SEPARATOR) === false) { continue; } if ($value !== DIRECTORY_SEPARATOR && !@file_exists($value)) { continue; } $this->constantMap[$key] = rtrim($value, DIRECTORY_SEPARATOR); } } ksort($this->constantMap); }
php
protected function _addConstants($constants) { foreach ($constants as $key => $value) { if (is_resource($value) === false) { if (is_array($value) || strpos($value, DIRECTORY_SEPARATOR) === false) { continue; } if ($value !== DIRECTORY_SEPARATOR && !@file_exists($value)) { continue; } $this->constantMap[$key] = rtrim($value, DIRECTORY_SEPARATOR); } } ksort($this->constantMap); }
[ "protected", "function", "_addConstants", "(", "$", "constants", ")", "{", "foreach", "(", "$", "constants", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_resource", "(", "$", "value", ")", "===", "false", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "||", "strpos", "(", "$", "value", ",", "DIRECTORY_SEPARATOR", ")", "===", "false", ")", "{", "continue", ";", "}", "if", "(", "$", "value", "!==", "DIRECTORY_SEPARATOR", "&&", "!", "@", "file_exists", "(", "$", "value", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "constantMap", "[", "$", "key", "]", "=", "rtrim", "(", "$", "value", ",", "DIRECTORY_SEPARATOR", ")", ";", "}", "}", "ksort", "(", "$", "this", "->", "constantMap", ")", ";", "}" ]
Add path based constants to the mapped constants. @param array $constants The constants to map @return void
[ "Add", "path", "based", "constants", "to", "the", "mapped", "constants", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L116-L130
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.load
public function load($path, $prefix = '') { $config = $this->readConfig($path); foreach ($config as $section => $values) { if (in_array($section, self::$_extensionTypes)) { // extension section, merge in the defaults. $defaults = $this->get($section); if ($defaults) { $values = array_merge($defaults, $values); } $this->addExtension($section, $values); } elseif (strtolower($section) === self::GENERAL) { if (!empty($values['timestampPath'])) { $path = $this->_replacePathConstants($values['timestampPath']); $values['timestampPath'] = rtrim($path, '/') . '/'; } $this->set(self::GENERAL, $values); } elseif (strpos($section, self::FILTER_PREFIX) === 0) { // filter section. $name = str_replace(self::FILTER_PREFIX, '', $section); $this->filterConfig($name, $values); } else { $lastDot = strrpos($section, '.') + 1; $extension = substr($section, $lastDot); $key = $section; // must be a build target. $this->addTarget($prefix . $key, $values); } } $this->resolveExtends(); return $this; }
php
public function load($path, $prefix = '') { $config = $this->readConfig($path); foreach ($config as $section => $values) { if (in_array($section, self::$_extensionTypes)) { // extension section, merge in the defaults. $defaults = $this->get($section); if ($defaults) { $values = array_merge($defaults, $values); } $this->addExtension($section, $values); } elseif (strtolower($section) === self::GENERAL) { if (!empty($values['timestampPath'])) { $path = $this->_replacePathConstants($values['timestampPath']); $values['timestampPath'] = rtrim($path, '/') . '/'; } $this->set(self::GENERAL, $values); } elseif (strpos($section, self::FILTER_PREFIX) === 0) { // filter section. $name = str_replace(self::FILTER_PREFIX, '', $section); $this->filterConfig($name, $values); } else { $lastDot = strrpos($section, '.') + 1; $extension = substr($section, $lastDot); $key = $section; // must be a build target. $this->addTarget($prefix . $key, $values); } } $this->resolveExtends(); return $this; }
[ "public", "function", "load", "(", "$", "path", ",", "$", "prefix", "=", "''", ")", "{", "$", "config", "=", "$", "this", "->", "readConfig", "(", "$", "path", ")", ";", "foreach", "(", "$", "config", "as", "$", "section", "=>", "$", "values", ")", "{", "if", "(", "in_array", "(", "$", "section", ",", "self", "::", "$", "_extensionTypes", ")", ")", "{", "// extension section, merge in the defaults.", "$", "defaults", "=", "$", "this", "->", "get", "(", "$", "section", ")", ";", "if", "(", "$", "defaults", ")", "{", "$", "values", "=", "array_merge", "(", "$", "defaults", ",", "$", "values", ")", ";", "}", "$", "this", "->", "addExtension", "(", "$", "section", ",", "$", "values", ")", ";", "}", "elseif", "(", "strtolower", "(", "$", "section", ")", "===", "self", "::", "GENERAL", ")", "{", "if", "(", "!", "empty", "(", "$", "values", "[", "'timestampPath'", "]", ")", ")", "{", "$", "path", "=", "$", "this", "->", "_replacePathConstants", "(", "$", "values", "[", "'timestampPath'", "]", ")", ";", "$", "values", "[", "'timestampPath'", "]", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ".", "'/'", ";", "}", "$", "this", "->", "set", "(", "self", "::", "GENERAL", ",", "$", "values", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "section", ",", "self", "::", "FILTER_PREFIX", ")", "===", "0", ")", "{", "// filter section.", "$", "name", "=", "str_replace", "(", "self", "::", "FILTER_PREFIX", ",", "''", ",", "$", "section", ")", ";", "$", "this", "->", "filterConfig", "(", "$", "name", ",", "$", "values", ")", ";", "}", "else", "{", "$", "lastDot", "=", "strrpos", "(", "$", "section", ",", "'.'", ")", "+", "1", ";", "$", "extension", "=", "substr", "(", "$", "section", ",", "$", "lastDot", ")", ";", "$", "key", "=", "$", "section", ";", "// must be a build target.", "$", "this", "->", "addTarget", "(", "$", "prefix", ".", "$", "key", ",", "$", "values", ")", ";", "}", "}", "$", "this", "->", "resolveExtends", "(", ")", ";", "return", "$", "this", ";", "}" ]
Load a config file into the current instance. @param string $path The config file to load. @param string $prefix The string to prefix all targets in $path with. @return $this
[ "Load", "a", "config", "file", "into", "the", "current", "instance", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L163-L198
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.readConfig
protected function readConfig($filename) { if (empty($filename) || !is_string($filename) || !file_exists($filename)) { throw new RuntimeException(sprintf('Configuration file "%s" was not found.', $filename)); } $this->_modifiedTime = max($this->_modifiedTime, filemtime($filename)); if (function_exists('parse_ini_file')) { return parse_ini_file($filename, true); } else { return parse_ini_string(file_get_contents($filename), true); } }
php
protected function readConfig($filename) { if (empty($filename) || !is_string($filename) || !file_exists($filename)) { throw new RuntimeException(sprintf('Configuration file "%s" was not found.', $filename)); } $this->_modifiedTime = max($this->_modifiedTime, filemtime($filename)); if (function_exists('parse_ini_file')) { return parse_ini_file($filename, true); } else { return parse_ini_string(file_get_contents($filename), true); } }
[ "protected", "function", "readConfig", "(", "$", "filename", ")", "{", "if", "(", "empty", "(", "$", "filename", ")", "||", "!", "is_string", "(", "$", "filename", ")", "||", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Configuration file \"%s\" was not found.'", ",", "$", "filename", ")", ")", ";", "}", "$", "this", "->", "_modifiedTime", "=", "max", "(", "$", "this", "->", "_modifiedTime", ",", "filemtime", "(", "$", "filename", ")", ")", ";", "if", "(", "function_exists", "(", "'parse_ini_file'", ")", ")", "{", "return", "parse_ini_file", "(", "$", "filename", ",", "true", ")", ";", "}", "else", "{", "return", "parse_ini_string", "(", "file_get_contents", "(", "$", "filename", ")", ",", "true", ")", ";", "}", "}" ]
Read the configuration file from disk @param string $filename Name of the inifile to parse @return array Inifile contents @throws RuntimeException
[ "Read", "the", "configuration", "file", "from", "disk" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L207-L219
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.resolveExtends
protected function resolveExtends() { $extend = []; foreach ($this->_targets as $name => $target) { if (empty($target['extend'])) { continue; } $parent = $target['extend']; if (empty($this->_targets[$parent])) { throw new RuntimeException("Invalid extend in '$name'. There is no '$parent' target defined."); } $extend[] = $name; } $expander = function ($target) use (&$expander, $extend) { $config = $this->_targets[$target]; $parentConfig = false; // Recurse through parents to collect all config. if (in_array($target, $extend)) { $parentConfig = $expander($config['extend']); } if (!$parentConfig) { return $config; } $config['files'] = array_merge($parentConfig['files'], $config['files']); $config['filters'] = array_merge($parentConfig['filters'], $config['filters']); $config['theme'] = $parentConfig['theme'] || $config['theme']; return $config; }; foreach ($extend as $target) { $this->_targets[$target] = $expander($target); } }
php
protected function resolveExtends() { $extend = []; foreach ($this->_targets as $name => $target) { if (empty($target['extend'])) { continue; } $parent = $target['extend']; if (empty($this->_targets[$parent])) { throw new RuntimeException("Invalid extend in '$name'. There is no '$parent' target defined."); } $extend[] = $name; } $expander = function ($target) use (&$expander, $extend) { $config = $this->_targets[$target]; $parentConfig = false; // Recurse through parents to collect all config. if (in_array($target, $extend)) { $parentConfig = $expander($config['extend']); } if (!$parentConfig) { return $config; } $config['files'] = array_merge($parentConfig['files'], $config['files']); $config['filters'] = array_merge($parentConfig['filters'], $config['filters']); $config['theme'] = $parentConfig['theme'] || $config['theme']; return $config; }; foreach ($extend as $target) { $this->_targets[$target] = $expander($target); } }
[ "protected", "function", "resolveExtends", "(", ")", "{", "$", "extend", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_targets", "as", "$", "name", "=>", "$", "target", ")", "{", "if", "(", "empty", "(", "$", "target", "[", "'extend'", "]", ")", ")", "{", "continue", ";", "}", "$", "parent", "=", "$", "target", "[", "'extend'", "]", ";", "if", "(", "empty", "(", "$", "this", "->", "_targets", "[", "$", "parent", "]", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Invalid extend in '$name'. There is no '$parent' target defined.\"", ")", ";", "}", "$", "extend", "[", "]", "=", "$", "name", ";", "}", "$", "expander", "=", "function", "(", "$", "target", ")", "use", "(", "&", "$", "expander", ",", "$", "extend", ")", "{", "$", "config", "=", "$", "this", "->", "_targets", "[", "$", "target", "]", ";", "$", "parentConfig", "=", "false", ";", "// Recurse through parents to collect all config.", "if", "(", "in_array", "(", "$", "target", ",", "$", "extend", ")", ")", "{", "$", "parentConfig", "=", "$", "expander", "(", "$", "config", "[", "'extend'", "]", ")", ";", "}", "if", "(", "!", "$", "parentConfig", ")", "{", "return", "$", "config", ";", "}", "$", "config", "[", "'files'", "]", "=", "array_merge", "(", "$", "parentConfig", "[", "'files'", "]", ",", "$", "config", "[", "'files'", "]", ")", ";", "$", "config", "[", "'filters'", "]", "=", "array_merge", "(", "$", "parentConfig", "[", "'filters'", "]", ",", "$", "config", "[", "'filters'", "]", ")", ";", "$", "config", "[", "'theme'", "]", "=", "$", "parentConfig", "[", "'theme'", "]", "||", "$", "config", "[", "'theme'", "]", ";", "return", "$", "config", ";", "}", ";", "foreach", "(", "$", "extend", "as", "$", "target", ")", "{", "$", "this", "->", "_targets", "[", "$", "target", "]", "=", "$", "expander", "(", "$", "target", ")", ";", "}", "}" ]
Once all targets have been built, resolve extend options. @return void @throws RuntimeException
[ "Once", "all", "targets", "have", "been", "built", "resolve", "extend", "options", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L227-L261
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig._parseExtensionDef
protected function _parseExtensionDef($target) { $paths = array(); if (!empty($target['paths'])) { $paths = array_map(array($this, '_replacePathConstants'), (array)$target['paths']); } $target['paths'] = $paths; if (!empty($target['cachePath'])) { $path = $this->_replacePathConstants($target['cachePath']); $target['cachePath'] = rtrim($path, '/') . '/'; } return $target; }
php
protected function _parseExtensionDef($target) { $paths = array(); if (!empty($target['paths'])) { $paths = array_map(array($this, '_replacePathConstants'), (array)$target['paths']); } $target['paths'] = $paths; if (!empty($target['cachePath'])) { $path = $this->_replacePathConstants($target['cachePath']); $target['cachePath'] = rtrim($path, '/') . '/'; } return $target; }
[ "protected", "function", "_parseExtensionDef", "(", "$", "target", ")", "{", "$", "paths", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "target", "[", "'paths'", "]", ")", ")", "{", "$", "paths", "=", "array_map", "(", "array", "(", "$", "this", ",", "'_replacePathConstants'", ")", ",", "(", "array", ")", "$", "target", "[", "'paths'", "]", ")", ";", "}", "$", "target", "[", "'paths'", "]", "=", "$", "paths", ";", "if", "(", "!", "empty", "(", "$", "target", "[", "'cachePath'", "]", ")", ")", "{", "$", "path", "=", "$", "this", "->", "_replacePathConstants", "(", "$", "target", "[", "'cachePath'", "]", ")", ";", "$", "target", "[", "'cachePath'", "]", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ".", "'/'", ";", "}", "return", "$", "target", ";", "}" ]
Parses paths in an extension definition @param array $data Array of extension information. @return array Array of build extension information with paths replaced.
[ "Parses", "paths", "in", "an", "extension", "definition" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L281-L293
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.set
public function set($path, $value) { $parts = explode('.', $path); switch (count($parts)) { case 2: $this->_data[$parts[0]][$parts[1]] = $value; break; case 1: $this->_data[$parts[0]] = $value; break; case 0: throw new RuntimeException('Path was empty.'); default: throw new RuntimeException('Too many parts in path.'); } }
php
public function set($path, $value) { $parts = explode('.', $path); switch (count($parts)) { case 2: $this->_data[$parts[0]][$parts[1]] = $value; break; case 1: $this->_data[$parts[0]] = $value; break; case 0: throw new RuntimeException('Path was empty.'); default: throw new RuntimeException('Too many parts in path.'); } }
[ "public", "function", "set", "(", "$", "path", ",", "$", "value", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "path", ")", ";", "switch", "(", "count", "(", "$", "parts", ")", ")", "{", "case", "2", ":", "$", "this", "->", "_data", "[", "$", "parts", "[", "0", "]", "]", "[", "$", "parts", "[", "1", "]", "]", "=", "$", "value", ";", "break", ";", "case", "1", ":", "$", "this", "->", "_data", "[", "$", "parts", "[", "0", "]", "]", "=", "$", "value", ";", "break", ";", "case", "0", ":", "throw", "new", "RuntimeException", "(", "'Path was empty.'", ")", ";", "default", ":", "throw", "new", "RuntimeException", "(", "'Too many parts in path.'", ")", ";", "}", "}" ]
Set values into the config object, You can't modify targets, or filters with this. Use the appropriate methods for those settings. @param string $path The path to set. @param string $value The value to set. @throws RuntimeException
[ "Set", "values", "into", "the", "config", "object", "You", "can", "t", "modify", "targets", "or", "filters", "with", "this", ".", "Use", "the", "appropriate", "methods", "for", "those", "settings", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L315-L330
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.get
public function get($path) { $parts = explode('.', $path); switch (count($parts)) { case 2: if (isset($this->_data[$parts[0]][$parts[1]])) { return $this->_data[$parts[0]][$parts[1]]; } break; case 1: if (isset($this->_data[$parts[0]])) { return $this->_data[$parts[0]]; } break; case 0: throw new RuntimeException('Path was empty.'); default: throw new RuntimeException('Too many parts in path.'); } }
php
public function get($path) { $parts = explode('.', $path); switch (count($parts)) { case 2: if (isset($this->_data[$parts[0]][$parts[1]])) { return $this->_data[$parts[0]][$parts[1]]; } break; case 1: if (isset($this->_data[$parts[0]])) { return $this->_data[$parts[0]]; } break; case 0: throw new RuntimeException('Path was empty.'); default: throw new RuntimeException('Too many parts in path.'); } }
[ "public", "function", "get", "(", "$", "path", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "path", ")", ";", "switch", "(", "count", "(", "$", "parts", ")", ")", "{", "case", "2", ":", "if", "(", "isset", "(", "$", "this", "->", "_data", "[", "$", "parts", "[", "0", "]", "]", "[", "$", "parts", "[", "1", "]", "]", ")", ")", "{", "return", "$", "this", "->", "_data", "[", "$", "parts", "[", "0", "]", "]", "[", "$", "parts", "[", "1", "]", "]", ";", "}", "break", ";", "case", "1", ":", "if", "(", "isset", "(", "$", "this", "->", "_data", "[", "$", "parts", "[", "0", "]", "]", ")", ")", "{", "return", "$", "this", "->", "_data", "[", "$", "parts", "[", "0", "]", "]", ";", "}", "break", ";", "case", "0", ":", "throw", "new", "RuntimeException", "(", "'Path was empty.'", ")", ";", "default", ":", "throw", "new", "RuntimeException", "(", "'Too many parts in path.'", ")", ";", "}", "}" ]
Get values from the config data. @param string $path The path you want. @throws RuntimeException On invalid paths.
[ "Get", "values", "from", "the", "config", "data", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L338-L357
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.targetFilters
public function targetFilters($name) { $ext = $this->getExt($name); $filters = []; if (isset($this->_data[$ext][self::FILTERS])) { $filters = $this->_data[$ext][self::FILTERS]; } if (!empty($this->_targets[$name][self::FILTERS])) { $buildFilters = $this->_targets[$name][self::FILTERS]; $filters = array_merge($filters, $buildFilters); } return array_unique($filters); }
php
public function targetFilters($name) { $ext = $this->getExt($name); $filters = []; if (isset($this->_data[$ext][self::FILTERS])) { $filters = $this->_data[$ext][self::FILTERS]; } if (!empty($this->_targets[$name][self::FILTERS])) { $buildFilters = $this->_targets[$name][self::FILTERS]; $filters = array_merge($filters, $buildFilters); } return array_unique($filters); }
[ "public", "function", "targetFilters", "(", "$", "name", ")", "{", "$", "ext", "=", "$", "this", "->", "getExt", "(", "$", "name", ")", ";", "$", "filters", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "_data", "[", "$", "ext", "]", "[", "self", "::", "FILTERS", "]", ")", ")", "{", "$", "filters", "=", "$", "this", "->", "_data", "[", "$", "ext", "]", "[", "self", "::", "FILTERS", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "_targets", "[", "$", "name", "]", "[", "self", "::", "FILTERS", "]", ")", ")", "{", "$", "buildFilters", "=", "$", "this", "->", "_targets", "[", "$", "name", "]", "[", "self", "::", "FILTERS", "]", ";", "$", "filters", "=", "array_merge", "(", "$", "filters", ",", "$", "buildFilters", ")", ";", "}", "return", "array_unique", "(", "$", "filters", ")", ";", "}" ]
Get the filters for a build target. @param string $name The build target to get filters for. @return array
[ "Get", "the", "filters", "for", "a", "build", "target", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L383-L395
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.allFilters
public function allFilters() { $filters = []; foreach ($this->extensions() as $ext) { if (empty($this->_data[$ext][self::FILTERS])) { continue; } $filters = array_merge($filters, $this->_data[$ext][self::FILTERS]); } foreach ($this->_targets as $target) { if (empty($target[self::FILTERS])) { continue; } $filters = array_merge($filters, $target[self::FILTERS]); } return array_unique($filters); }
php
public function allFilters() { $filters = []; foreach ($this->extensions() as $ext) { if (empty($this->_data[$ext][self::FILTERS])) { continue; } $filters = array_merge($filters, $this->_data[$ext][self::FILTERS]); } foreach ($this->_targets as $target) { if (empty($target[self::FILTERS])) { continue; } $filters = array_merge($filters, $target[self::FILTERS]); } return array_unique($filters); }
[ "public", "function", "allFilters", "(", ")", "{", "$", "filters", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "extensions", "(", ")", "as", "$", "ext", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_data", "[", "$", "ext", "]", "[", "self", "::", "FILTERS", "]", ")", ")", "{", "continue", ";", "}", "$", "filters", "=", "array_merge", "(", "$", "filters", ",", "$", "this", "->", "_data", "[", "$", "ext", "]", "[", "self", "::", "FILTERS", "]", ")", ";", "}", "foreach", "(", "$", "this", "->", "_targets", "as", "$", "target", ")", "{", "if", "(", "empty", "(", "$", "target", "[", "self", "::", "FILTERS", "]", ")", ")", "{", "continue", ";", "}", "$", "filters", "=", "array_merge", "(", "$", "filters", ",", "$", "target", "[", "self", "::", "FILTERS", "]", ")", ";", "}", "return", "array_unique", "(", "$", "filters", ")", ";", "}" ]
Get configuration for all filters. Useful for building FilterRegistry objects @return array Config data related to all filters.
[ "Get", "configuration", "for", "all", "filters", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L404-L420
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.cachePath
public function cachePath($ext, $path = null) { if ($path === null) { if (isset($this->_data[$ext]['cachePath'])) { return $this->_data[$ext]['cachePath']; } return ''; } $path = $this->_replacePathConstants($path); $this->_data[$ext]['cachePath'] = rtrim($path, '/') . '/'; }
php
public function cachePath($ext, $path = null) { if ($path === null) { if (isset($this->_data[$ext]['cachePath'])) { return $this->_data[$ext]['cachePath']; } return ''; } $path = $this->_replacePathConstants($path); $this->_data[$ext]['cachePath'] = rtrim($path, '/') . '/'; }
[ "public", "function", "cachePath", "(", "$", "ext", ",", "$", "path", "=", "null", ")", "{", "if", "(", "$", "path", "===", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_data", "[", "$", "ext", "]", "[", "'cachePath'", "]", ")", ")", "{", "return", "$", "this", "->", "_data", "[", "$", "ext", "]", "[", "'cachePath'", "]", ";", "}", "return", "''", ";", "}", "$", "path", "=", "$", "this", "->", "_replacePathConstants", "(", "$", "path", ")", ";", "$", "this", "->", "_data", "[", "$", "ext", "]", "[", "'cachePath'", "]", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ".", "'/'", ";", "}" ]
Accessor for getting the cachePath for a given extension. @param string $ext Extension to get paths for. @param string $path The path to cache files using $ext to.
[ "Accessor", "for", "getting", "the", "cachePath", "for", "a", "given", "extension", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L531-L541
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.addTarget
public function addTarget($target, array $config) { $ext = $this->getExt($target); $config += [ 'files' => [], 'filters' => [], 'theme' => false, 'extend' => false, 'require' => [], ]; if (!empty($config['paths'])) { $config['paths'] = array_map(array($this, '_replacePathConstants'), (array)$config['paths']); } $this->_targets[$target] = $config; }
php
public function addTarget($target, array $config) { $ext = $this->getExt($target); $config += [ 'files' => [], 'filters' => [], 'theme' => false, 'extend' => false, 'require' => [], ]; if (!empty($config['paths'])) { $config['paths'] = array_map(array($this, '_replacePathConstants'), (array)$config['paths']); } $this->_targets[$target] = $config; }
[ "public", "function", "addTarget", "(", "$", "target", ",", "array", "$", "config", ")", "{", "$", "ext", "=", "$", "this", "->", "getExt", "(", "$", "target", ")", ";", "$", "config", "+=", "[", "'files'", "=>", "[", "]", ",", "'filters'", "=>", "[", "]", ",", "'theme'", "=>", "false", ",", "'extend'", "=>", "false", ",", "'require'", "=>", "[", "]", ",", "]", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'paths'", "]", ")", ")", "{", "$", "config", "[", "'paths'", "]", "=", "array_map", "(", "array", "(", "$", "this", ",", "'_replacePathConstants'", ")", ",", "(", "array", ")", "$", "config", "[", "'paths'", "]", ")", ";", "}", "$", "this", "->", "_targets", "[", "$", "target", "]", "=", "$", "config", ";", "}" ]
Create a new build target. @param string $target Name of the target file. The extension will be inferred based on the last extension. @param array $config Config data for the target. Should contain files, filters and theme key.
[ "Create", "a", "new", "build", "target", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L590-L604
train
markstory/mini-asset
src/AssetConfig.php
AssetConfig.theme
public function theme($theme = null) { if ($theme === null) { return isset($this->_data['theme']) ? $this->_data['theme'] : ''; } $this->_data['theme'] = $theme; }
php
public function theme($theme = null) { if ($theme === null) { return isset($this->_data['theme']) ? $this->_data['theme'] : ''; } $this->_data['theme'] = $theme; }
[ "public", "function", "theme", "(", "$", "theme", "=", "null", ")", "{", "if", "(", "$", "theme", "===", "null", ")", "{", "return", "isset", "(", "$", "this", "->", "_data", "[", "'theme'", "]", ")", "?", "$", "this", "->", "_data", "[", "'theme'", "]", ":", "''", ";", "}", "$", "this", "->", "_data", "[", "'theme'", "]", "=", "$", "theme", ";", "}" ]
Set the active theme for building assets. @param string $theme The theme name to set. Null to get @return mixed Either null on set, or theme on get
[ "Set", "the", "active", "theme", "for", "building", "assets", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetConfig.php#L612-L618
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter.write
public function write(AssetTarget $build, $content) { $ext = $build->ext(); $path = $build->outputDir(); if (!is_writable($path)) { throw new RuntimeException('Cannot write cache file. Unable to write to ' . $path); } $filename = $this->buildFileName($build); $success = file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $content) !== false; $this->finalize($build); return $success; }
php
public function write(AssetTarget $build, $content) { $ext = $build->ext(); $path = $build->outputDir(); if (!is_writable($path)) { throw new RuntimeException('Cannot write cache file. Unable to write to ' . $path); } $filename = $this->buildFileName($build); $success = file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $content) !== false; $this->finalize($build); return $success; }
[ "public", "function", "write", "(", "AssetTarget", "$", "build", ",", "$", "content", ")", "{", "$", "ext", "=", "$", "build", "->", "ext", "(", ")", ";", "$", "path", "=", "$", "build", "->", "outputDir", "(", ")", ";", "if", "(", "!", "is_writable", "(", "$", "path", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Cannot write cache file. Unable to write to '", ".", "$", "path", ")", ";", "}", "$", "filename", "=", "$", "this", "->", "buildFileName", "(", "$", "build", ")", ";", "$", "success", "=", "file_put_contents", "(", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "filename", ",", "$", "content", ")", "!==", "false", ";", "$", "this", "->", "finalize", "(", "$", "build", ")", ";", "return", "$", "success", ";", "}" ]
Writes content into a file @param AssetTarget $build The filename to write. @param string $content The contents to write. @throws RuntimeException
[ "Writes", "content", "into", "a", "file" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L78-L90
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter.invalidate
public function invalidate(AssetTarget $build) { $ext = $build->ext(); if (empty($this->timestamp[$ext])) { return false; } $this->_invalidated = $build->name(); $this->setTimestamp($build, 0); }
php
public function invalidate(AssetTarget $build) { $ext = $build->ext(); if (empty($this->timestamp[$ext])) { return false; } $this->_invalidated = $build->name(); $this->setTimestamp($build, 0); }
[ "public", "function", "invalidate", "(", "AssetTarget", "$", "build", ")", "{", "$", "ext", "=", "$", "build", "->", "ext", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "timestamp", "[", "$", "ext", "]", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "_invalidated", "=", "$", "build", "->", "name", "(", ")", ";", "$", "this", "->", "setTimestamp", "(", "$", "build", ",", "0", ")", ";", "}" ]
Invalidate a build before re-generating the file. @param string $build The build to invalidate. @return void
[ "Invalidate", "a", "build", "before", "re", "-", "generating", "the", "file", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L98-L106
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter.finalize
public function finalize(AssetTarget $build) { $ext = $build->ext(); if (empty($this->timestamp[$ext])) { return; } $data = $this->_readTimestamp(); $name = $this->buildCacheName($build); if (!isset($data[$name])) { return; } $time = $data[$name]; unset($data[$name]); $this->_invalidated = null; $name = $this->buildCacheName($build); $data[$name] = $time; $this->_writeTimestamp($data); }
php
public function finalize(AssetTarget $build) { $ext = $build->ext(); if (empty($this->timestamp[$ext])) { return; } $data = $this->_readTimestamp(); $name = $this->buildCacheName($build); if (!isset($data[$name])) { return; } $time = $data[$name]; unset($data[$name]); $this->_invalidated = null; $name = $this->buildCacheName($build); $data[$name] = $time; $this->_writeTimestamp($data); }
[ "public", "function", "finalize", "(", "AssetTarget", "$", "build", ")", "{", "$", "ext", "=", "$", "build", "->", "ext", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "timestamp", "[", "$", "ext", "]", ")", ")", "{", "return", ";", "}", "$", "data", "=", "$", "this", "->", "_readTimestamp", "(", ")", ";", "$", "name", "=", "$", "this", "->", "buildCacheName", "(", "$", "build", ")", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "name", "]", ")", ")", "{", "return", ";", "}", "$", "time", "=", "$", "data", "[", "$", "name", "]", ";", "unset", "(", "$", "data", "[", "$", "name", "]", ")", ";", "$", "this", "->", "_invalidated", "=", "null", ";", "$", "name", "=", "$", "this", "->", "buildCacheName", "(", "$", "build", ")", ";", "$", "data", "[", "$", "name", "]", "=", "$", "time", ";", "$", "this", "->", "_writeTimestamp", "(", "$", "data", ")", ";", "}" ]
Finalize a build after written to filesystem. @param AssetTarget $build The build to finalize. @return void
[ "Finalize", "a", "build", "after", "written", "to", "filesystem", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L114-L131
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter.setTimestamp
public function setTimestamp(AssetTarget $build, $time) { $ext = $build->ext(); if (empty($this->timestamp[$ext])) { return; } $data = $this->_readTimestamp(); $name = $this->buildCacheName($build); $data[$name] = $time; $this->_writeTimestamp($data); }
php
public function setTimestamp(AssetTarget $build, $time) { $ext = $build->ext(); if (empty($this->timestamp[$ext])) { return; } $data = $this->_readTimestamp(); $name = $this->buildCacheName($build); $data[$name] = $time; $this->_writeTimestamp($data); }
[ "public", "function", "setTimestamp", "(", "AssetTarget", "$", "build", ",", "$", "time", ")", "{", "$", "ext", "=", "$", "build", "->", "ext", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "timestamp", "[", "$", "ext", "]", ")", ")", "{", "return", ";", "}", "$", "data", "=", "$", "this", "->", "_readTimestamp", "(", ")", ";", "$", "name", "=", "$", "this", "->", "buildCacheName", "(", "$", "build", ")", ";", "$", "data", "[", "$", "name", "]", "=", "$", "time", ";", "$", "this", "->", "_writeTimestamp", "(", "$", "data", ")", ";", "}" ]
Set the timestamp for a build file. @param AssetTarget $build The name of the build to set a timestamp for. @param int $time The timestamp. @return void
[ "Set", "the", "timestamp", "for", "a", "build", "file", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L140-L150
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter._readTimestamp
protected function _readTimestamp() { $data = array(); if (empty($data) && file_exists($this->path . static::BUILD_TIME_FILE)) { $data = file_get_contents($this->path . static::BUILD_TIME_FILE); if ($data) { $data = unserialize($data); } } return $data; }
php
protected function _readTimestamp() { $data = array(); if (empty($data) && file_exists($this->path . static::BUILD_TIME_FILE)) { $data = file_get_contents($this->path . static::BUILD_TIME_FILE); if ($data) { $data = unserialize($data); } } return $data; }
[ "protected", "function", "_readTimestamp", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "data", ")", "&&", "file_exists", "(", "$", "this", "->", "path", ".", "static", "::", "BUILD_TIME_FILE", ")", ")", "{", "$", "data", "=", "file_get_contents", "(", "$", "this", "->", "path", ".", "static", "::", "BUILD_TIME_FILE", ")", ";", "if", "(", "$", "data", ")", "{", "$", "data", "=", "unserialize", "(", "$", "data", ")", ";", "}", "}", "return", "$", "data", ";", "}" ]
Read timestamps from either the fast cache, or the serialized file. @return array An array of timestamps for build files.
[ "Read", "timestamps", "from", "either", "the", "fast", "cache", "or", "the", "serialized", "file", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L184-L194
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter._writeTimestamp
protected function _writeTimestamp($data) { $data = serialize($data); file_put_contents($this->path . static::BUILD_TIME_FILE, $data); chmod($this->path . static::BUILD_TIME_FILE, 0644); }
php
protected function _writeTimestamp($data) { $data = serialize($data); file_put_contents($this->path . static::BUILD_TIME_FILE, $data); chmod($this->path . static::BUILD_TIME_FILE, 0644); }
[ "protected", "function", "_writeTimestamp", "(", "$", "data", ")", "{", "$", "data", "=", "serialize", "(", "$", "data", ")", ";", "file_put_contents", "(", "$", "this", "->", "path", ".", "static", "::", "BUILD_TIME_FILE", ",", "$", "data", ")", ";", "chmod", "(", "$", "this", "->", "path", ".", "static", "::", "BUILD_TIME_FILE", ",", "0644", ")", ";", "}" ]
Write timestamps to either the fast cache, or the serialized file. @param array $data An array of timestamps for build files. @return void
[ "Write", "timestamps", "to", "either", "the", "fast", "cache", "or", "the", "serialized", "file", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L202-L207
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter.buildFileName
public function buildFileName(AssetTarget $target, $timestamp = true) { $file = $target->name(); if ($target->isThemed() && $this->theme) { $file = $this->theme . '-' . $file; } if ($timestamp) { $time = $this->getTimestamp($target); $file = $this->_timestampFile($file, $time); } return $file; }
php
public function buildFileName(AssetTarget $target, $timestamp = true) { $file = $target->name(); if ($target->isThemed() && $this->theme) { $file = $this->theme . '-' . $file; } if ($timestamp) { $time = $this->getTimestamp($target); $file = $this->_timestampFile($file, $time); } return $file; }
[ "public", "function", "buildFileName", "(", "AssetTarget", "$", "target", ",", "$", "timestamp", "=", "true", ")", "{", "$", "file", "=", "$", "target", "->", "name", "(", ")", ";", "if", "(", "$", "target", "->", "isThemed", "(", ")", "&&", "$", "this", "->", "theme", ")", "{", "$", "file", "=", "$", "this", "->", "theme", ".", "'-'", ".", "$", "file", ";", "}", "if", "(", "$", "timestamp", ")", "{", "$", "time", "=", "$", "this", "->", "getTimestamp", "(", "$", "target", ")", ";", "$", "file", "=", "$", "this", "->", "_timestampFile", "(", "$", "file", ",", "$", "time", ")", ";", "}", "return", "$", "file", ";", "}" ]
Get the final filename for a build. Resolves theme prefixes and timestamps. @param AssetTarget $target The build target name. @return string The build filename to cache on disk.
[ "Get", "the", "final", "filename", "for", "a", "build", ".", "Resolves", "theme", "prefixes", "and", "timestamps", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L216-L227
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter.buildCacheName
public function buildCacheName($build) { $name = $this->buildFileName($build, false); if ($build->name() == $this->_invalidated) { return '~' . $name; } return $name; }
php
public function buildCacheName($build) { $name = $this->buildFileName($build, false); if ($build->name() == $this->_invalidated) { return '~' . $name; } return $name; }
[ "public", "function", "buildCacheName", "(", "$", "build", ")", "{", "$", "name", "=", "$", "this", "->", "buildFileName", "(", "$", "build", ",", "false", ")", ";", "if", "(", "$", "build", "->", "name", "(", ")", "==", "$", "this", "->", "_invalidated", ")", "{", "return", "'~'", ".", "$", "name", ";", "}", "return", "$", "name", ";", "}" ]
Get the cache name a build. @param string $build The build target name. @return string The build cache name.
[ "Get", "the", "cache", "name", "a", "build", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L235-L242
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter.clearTimestamps
public function clearTimestamps() { $path = $this->path . static::BUILD_TIME_FILE; if (file_exists($path)) { unlink($this->path . static::BUILD_TIME_FILE); } }
php
public function clearTimestamps() { $path = $this->path . static::BUILD_TIME_FILE; if (file_exists($path)) { unlink($this->path . static::BUILD_TIME_FILE); } }
[ "public", "function", "clearTimestamps", "(", ")", "{", "$", "path", "=", "$", "this", "->", "path", ".", "static", "::", "BUILD_TIME_FILE", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "unlink", "(", "$", "this", "->", "path", ".", "static", "::", "BUILD_TIME_FILE", ")", ";", "}", "}" ]
Clear timestamps for assets. @return void
[ "Clear", "timestamps", "for", "assets", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L249-L255
train
markstory/mini-asset
src/Output/AssetWriter.php
AssetWriter._timestampFile
protected function _timestampFile($file, $time) { if (!$time) { return $file; } $pos = strrpos($file, '.'); $name = substr($file, 0, $pos); $ext = substr($file, $pos); return $name . '.v' . $time . $ext; }
php
protected function _timestampFile($file, $time) { if (!$time) { return $file; } $pos = strrpos($file, '.'); $name = substr($file, 0, $pos); $ext = substr($file, $pos); return $name . '.v' . $time . $ext; }
[ "protected", "function", "_timestampFile", "(", "$", "file", ",", "$", "time", ")", "{", "if", "(", "!", "$", "time", ")", "{", "return", "$", "file", ";", "}", "$", "pos", "=", "strrpos", "(", "$", "file", ",", "'.'", ")", ";", "$", "name", "=", "substr", "(", "$", "file", ",", "0", ",", "$", "pos", ")", ";", "$", "ext", "=", "substr", "(", "$", "file", ",", "$", "pos", ")", ";", "return", "$", "name", ".", "'.v'", ".", "$", "time", ".", "$", "ext", ";", "}" ]
Modify a file name and append in the timestamp @param string $file The filename. @param int $time The timestamp. @return string The build filename to cache on disk.
[ "Modify", "a", "file", "name", "and", "append", "in", "the", "timestamp" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Output/AssetWriter.php#L264-L273
train
markstory/mini-asset
src/AssetScanner.php
AssetScanner._generateTree
protected function _generateTree($path) { $paths = glob($path, GLOB_ONLYDIR); if (!$paths) { $paths = array(); } array_unshift($paths, dirname($path)); return $paths; }
php
protected function _generateTree($path) { $paths = glob($path, GLOB_ONLYDIR); if (!$paths) { $paths = array(); } array_unshift($paths, dirname($path)); return $paths; }
[ "protected", "function", "_generateTree", "(", "$", "path", ")", "{", "$", "paths", "=", "glob", "(", "$", "path", ",", "GLOB_ONLYDIR", ")", ";", "if", "(", "!", "$", "paths", ")", "{", "$", "paths", "=", "array", "(", ")", ";", "}", "array_unshift", "(", "$", "paths", ",", "dirname", "(", "$", "path", ")", ")", ";", "return", "$", "paths", ";", "}" ]
Discover all the sub directories for a given path. @param string $path The path to search @return array Array of subdirectories.
[ "Discover", "all", "the", "sub", "directories", "for", "a", "given", "path", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetScanner.php#L98-L106
train
markstory/mini-asset
src/AssetScanner.php
AssetScanner.find
public function find($file) { $found = false; $expanded = $this->_expandPrefix($file); if (file_exists($expanded)) { return $expanded; } foreach ($this->_paths as $path) { $file = $this->_normalizePath($file, DIRECTORY_SEPARATOR); $fullPath = $path . $file; if (file_exists($fullPath)) { $found = $fullPath; break; } } return $found; }
php
public function find($file) { $found = false; $expanded = $this->_expandPrefix($file); if (file_exists($expanded)) { return $expanded; } foreach ($this->_paths as $path) { $file = $this->_normalizePath($file, DIRECTORY_SEPARATOR); $fullPath = $path . $file; if (file_exists($fullPath)) { $found = $fullPath; break; } } return $found; }
[ "public", "function", "find", "(", "$", "file", ")", "{", "$", "found", "=", "false", ";", "$", "expanded", "=", "$", "this", "->", "_expandPrefix", "(", "$", "file", ")", ";", "if", "(", "file_exists", "(", "$", "expanded", ")", ")", "{", "return", "$", "expanded", ";", "}", "foreach", "(", "$", "this", "->", "_paths", "as", "$", "path", ")", "{", "$", "file", "=", "$", "this", "->", "_normalizePath", "(", "$", "file", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "fullPath", "=", "$", "path", ".", "$", "file", ";", "if", "(", "file_exists", "(", "$", "fullPath", ")", ")", "{", "$", "found", "=", "$", "fullPath", ";", "break", ";", "}", "}", "return", "$", "found", ";", "}" ]
Find a file in the connected paths, and check for its existance. @param string $file The file you want to find. @return mixed Either false on a miss, or the full path of the file.
[ "Find", "a", "file", "in", "the", "connected", "paths", "and", "check", "for", "its", "existance", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetScanner.php#L114-L131
train
boomcms/boom-core
src/BoomCMS/Http/Controllers/Page/Settings.php
Settings.getDelete
public function getDelete(Page $page) { $this->authorize('delete', $page); return view($this->viewPrefix.'.delete', [ 'children' => $page->countChildren(), 'page' => $page, ]); }
php
public function getDelete(Page $page) { $this->authorize('delete', $page); return view($this->viewPrefix.'.delete', [ 'children' => $page->countChildren(), 'page' => $page, ]); }
[ "public", "function", "getDelete", "(", "Page", "$", "page", ")", "{", "$", "this", "->", "authorize", "(", "'delete'", ",", "$", "page", ")", ";", "return", "view", "(", "$", "this", "->", "viewPrefix", ".", "'.delete'", ",", "[", "'children'", "=>", "$", "page", "->", "countChildren", "(", ")", ",", "'page'", "=>", "$", "page", ",", "]", ")", ";", "}" ]
Show the delete page confirmation. @param Page $page @return View
[ "Show", "the", "delete", "page", "confirmation", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Http/Controllers/Page/Settings.php#L68-L76
train
boomcms/boom-core
src/BoomCMS/Http/Controllers/Page/Settings.php
Settings.getHistory
public function getHistory(Page $page) { $this->authorize('edit', $page); return view("$this->viewPrefix.history", [ 'versions' => PageVersionFacade::history($page), 'page' => $page, 'diff' => new Diff(), ]); }
php
public function getHistory(Page $page) { $this->authorize('edit', $page); return view("$this->viewPrefix.history", [ 'versions' => PageVersionFacade::history($page), 'page' => $page, 'diff' => new Diff(), ]); }
[ "public", "function", "getHistory", "(", "Page", "$", "page", ")", "{", "$", "this", "->", "authorize", "(", "'edit'", ",", "$", "page", ")", ";", "return", "view", "(", "\"$this->viewPrefix.history\"", ",", "[", "'versions'", "=>", "PageVersionFacade", "::", "history", "(", "$", "page", ")", ",", "'page'", "=>", "$", "page", ",", "'diff'", "=>", "new", "Diff", "(", ")", ",", "]", ")", ";", "}" ]
Show the page version history. @param Page $page @return View
[ "Show", "the", "page", "version", "history", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Http/Controllers/Page/Settings.php#L101-L110
train
boomcms/boom-core
src/BoomCMS/Http/Controllers/Page/Settings.php
Settings.postAdmin
public function postAdmin(Request $request, Page $page) { $this->authorize('editAdmin', $page); $page ->setInternalName($request->input('internal_name')) ->setAddPageBehaviour($request->input('add_behaviour')) ->setChildAddPageBehaviour($request->input('child_add_behaviour')) ->setDisableDelete($request->has('disable_delete')); PageFacade::save($page); }
php
public function postAdmin(Request $request, Page $page) { $this->authorize('editAdmin', $page); $page ->setInternalName($request->input('internal_name')) ->setAddPageBehaviour($request->input('add_behaviour')) ->setChildAddPageBehaviour($request->input('child_add_behaviour')) ->setDisableDelete($request->has('disable_delete')); PageFacade::save($page); }
[ "public", "function", "postAdmin", "(", "Request", "$", "request", ",", "Page", "$", "page", ")", "{", "$", "this", "->", "authorize", "(", "'editAdmin'", ",", "$", "page", ")", ";", "$", "page", "->", "setInternalName", "(", "$", "request", "->", "input", "(", "'internal_name'", ")", ")", "->", "setAddPageBehaviour", "(", "$", "request", "->", "input", "(", "'add_behaviour'", ")", ")", "->", "setChildAddPageBehaviour", "(", "$", "request", "->", "input", "(", "'child_add_behaviour'", ")", ")", "->", "setDisableDelete", "(", "$", "request", "->", "has", "(", "'disable_delete'", ")", ")", ";", "PageFacade", "::", "save", "(", "$", "page", ")", ";", "}" ]
Save the page admin settings. @param Request $request @param Page $page
[ "Save", "the", "page", "admin", "settings", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Http/Controllers/Page/Settings.php#L187-L198
train
boomcms/boom-core
src/BoomCMS/Http/Controllers/Page/Settings.php
Settings.postChildren
public function postChildren(Request $request, Page $page) { $this->authorize('editChildrenBasic', $page); $post = $request->input(); $page->setChildTemplateId($request->input('children_template_id')); if (Gate::allows('editChildrenAdvanced', $page)) { $page ->setChildrenUrlPrefix($request->input('children_url_prefix')) ->setChildrenVisibleInNav($request->has('children_visible_in_nav')) ->setChildrenVisibleInNavCms($request->has('children_visible_in_nav_cms')) ->setGrandchildTemplateId($request->input('grandchild_template_id')); } if (isset($post['children_ordering_policy']) && isset($post['children_ordering_direction'])) { $page->setChildOrderingPolicy($post['children_ordering_policy'], $post['children_ordering_direction']); } PageFacade::save($page); }
php
public function postChildren(Request $request, Page $page) { $this->authorize('editChildrenBasic', $page); $post = $request->input(); $page->setChildTemplateId($request->input('children_template_id')); if (Gate::allows('editChildrenAdvanced', $page)) { $page ->setChildrenUrlPrefix($request->input('children_url_prefix')) ->setChildrenVisibleInNav($request->has('children_visible_in_nav')) ->setChildrenVisibleInNavCms($request->has('children_visible_in_nav_cms')) ->setGrandchildTemplateId($request->input('grandchild_template_id')); } if (isset($post['children_ordering_policy']) && isset($post['children_ordering_direction'])) { $page->setChildOrderingPolicy($post['children_ordering_policy'], $post['children_ordering_direction']); } PageFacade::save($page); }
[ "public", "function", "postChildren", "(", "Request", "$", "request", ",", "Page", "$", "page", ")", "{", "$", "this", "->", "authorize", "(", "'editChildrenBasic'", ",", "$", "page", ")", ";", "$", "post", "=", "$", "request", "->", "input", "(", ")", ";", "$", "page", "->", "setChildTemplateId", "(", "$", "request", "->", "input", "(", "'children_template_id'", ")", ")", ";", "if", "(", "Gate", "::", "allows", "(", "'editChildrenAdvanced'", ",", "$", "page", ")", ")", "{", "$", "page", "->", "setChildrenUrlPrefix", "(", "$", "request", "->", "input", "(", "'children_url_prefix'", ")", ")", "->", "setChildrenVisibleInNav", "(", "$", "request", "->", "has", "(", "'children_visible_in_nav'", ")", ")", "->", "setChildrenVisibleInNavCms", "(", "$", "request", "->", "has", "(", "'children_visible_in_nav_cms'", ")", ")", "->", "setGrandchildTemplateId", "(", "$", "request", "->", "input", "(", "'grandchild_template_id'", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "post", "[", "'children_ordering_policy'", "]", ")", "&&", "isset", "(", "$", "post", "[", "'children_ordering_direction'", "]", ")", ")", "{", "$", "page", "->", "setChildOrderingPolicy", "(", "$", "post", "[", "'children_ordering_policy'", "]", ",", "$", "post", "[", "'children_ordering_direction'", "]", ")", ";", "}", "PageFacade", "::", "save", "(", "$", "page", ")", ";", "}" ]
Save the child page settings. @param Request $request @param Page $page
[ "Save", "the", "child", "page", "settings", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Http/Controllers/Page/Settings.php#L206-L227
train
boomcms/boom-core
src/BoomCMS/Http/Controllers/Page/Settings.php
Settings.postFeature
public function postFeature(Request $request, Page $page) { $this->authorize('editFeature', $page); $page->setFeatureImageId($request->input('feature_image_id')); PageFacade::save($page); }
php
public function postFeature(Request $request, Page $page) { $this->authorize('editFeature', $page); $page->setFeatureImageId($request->input('feature_image_id')); PageFacade::save($page); }
[ "public", "function", "postFeature", "(", "Request", "$", "request", ",", "Page", "$", "page", ")", "{", "$", "this", "->", "authorize", "(", "'editFeature'", ",", "$", "page", ")", ";", "$", "page", "->", "setFeatureImageId", "(", "$", "request", "->", "input", "(", "'feature_image_id'", ")", ")", ";", "PageFacade", "::", "save", "(", "$", "page", ")", ";", "}" ]
Save the page feature image. @param Request $request @param Page $page
[ "Save", "the", "page", "feature", "image", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Http/Controllers/Page/Settings.php#L246-L253
train
boomcms/boom-core
src/BoomCMS/Http/Controllers/Page/Settings.php
Settings.postNavigation
public function postNavigation(Request $request, Page $page) { $this->authorize('editNavBasic', $page); if (Gate::allows('editNavAdvanced', $page)) { $parent = Page::find($request->input('parent_id')); if ($parent) { $page->setParent($parent); } } $page ->setVisibleInNav($request->has('visible_in_nav')) ->setVisibleInCmsNav($request->has('visible_in_nav_cms')); PageFacade::save($page); }
php
public function postNavigation(Request $request, Page $page) { $this->authorize('editNavBasic', $page); if (Gate::allows('editNavAdvanced', $page)) { $parent = Page::find($request->input('parent_id')); if ($parent) { $page->setParent($parent); } } $page ->setVisibleInNav($request->has('visible_in_nav')) ->setVisibleInCmsNav($request->has('visible_in_nav_cms')); PageFacade::save($page); }
[ "public", "function", "postNavigation", "(", "Request", "$", "request", ",", "Page", "$", "page", ")", "{", "$", "this", "->", "authorize", "(", "'editNavBasic'", ",", "$", "page", ")", ";", "if", "(", "Gate", "::", "allows", "(", "'editNavAdvanced'", ",", "$", "page", ")", ")", "{", "$", "parent", "=", "Page", "::", "find", "(", "$", "request", "->", "input", "(", "'parent_id'", ")", ")", ";", "if", "(", "$", "parent", ")", "{", "$", "page", "->", "setParent", "(", "$", "parent", ")", ";", "}", "}", "$", "page", "->", "setVisibleInNav", "(", "$", "request", "->", "has", "(", "'visible_in_nav'", ")", ")", "->", "setVisibleInCmsNav", "(", "$", "request", "->", "has", "(", "'visible_in_nav_cms'", ")", ")", ";", "PageFacade", "::", "save", "(", "$", "page", ")", ";", "}" ]
Save the page navigation settings. @param Request $request @param Page $page
[ "Save", "the", "page", "navigation", "settings", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Http/Controllers/Page/Settings.php#L261-L278
train
boomcms/boom-core
src/BoomCMS/Http/Controllers/Page/Settings.php
Settings.postSortChildren
public function postSortChildren(Request $request, Page $page) { $this->authorize('editChildrenBasic', $page); Bus::dispatch(new ReorderChildPages($page, $request->input('sequences'))); }
php
public function postSortChildren(Request $request, Page $page) { $this->authorize('editChildrenBasic', $page); Bus::dispatch(new ReorderChildPages($page, $request->input('sequences'))); }
[ "public", "function", "postSortChildren", "(", "Request", "$", "request", ",", "Page", "$", "page", ")", "{", "$", "this", "->", "authorize", "(", "'editChildrenBasic'", ",", "$", "page", ")", ";", "Bus", "::", "dispatch", "(", "new", "ReorderChildPages", "(", "$", "page", ",", "$", "request", "->", "input", "(", "'sequences'", ")", ")", ")", ";", "}" ]
Save the order of child pages. @param Request $request @param Page $page
[ "Save", "the", "order", "of", "child", "pages", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Http/Controllers/Page/Settings.php#L305-L310
train
boomcms/boom-core
src/BoomCMS/Http/Controllers/Page/Settings.php
Settings.postVisibility
public function postVisibility(Request $request, Page $page) { $this->authorize('publish', $page); $wasVisible = $page->isVisible(); $page->setVisibleAtAnyTime($request->input('visible')); if ($page->isVisibleAtAnyTime()) { if ($request->has('visible_from')) { $page->setVisibleFrom(new DateTime($request->input('visible_from'))); } $visibleTo = ($request->has('toggle_visible_to')) ? new DateTime($request->input('visible_to')) : null; $page->setVisibleTo($visibleTo); } PageFacade::save($page); if (!$wasVisible && $page->isVisible()) { Event::fire(new Events\PageWasMadeVisible($page, auth()->user())); } return (int) $page->isVisible(); }
php
public function postVisibility(Request $request, Page $page) { $this->authorize('publish', $page); $wasVisible = $page->isVisible(); $page->setVisibleAtAnyTime($request->input('visible')); if ($page->isVisibleAtAnyTime()) { if ($request->has('visible_from')) { $page->setVisibleFrom(new DateTime($request->input('visible_from'))); } $visibleTo = ($request->has('toggle_visible_to')) ? new DateTime($request->input('visible_to')) : null; $page->setVisibleTo($visibleTo); } PageFacade::save($page); if (!$wasVisible && $page->isVisible()) { Event::fire(new Events\PageWasMadeVisible($page, auth()->user())); } return (int) $page->isVisible(); }
[ "public", "function", "postVisibility", "(", "Request", "$", "request", ",", "Page", "$", "page", ")", "{", "$", "this", "->", "authorize", "(", "'publish'", ",", "$", "page", ")", ";", "$", "wasVisible", "=", "$", "page", "->", "isVisible", "(", ")", ";", "$", "page", "->", "setVisibleAtAnyTime", "(", "$", "request", "->", "input", "(", "'visible'", ")", ")", ";", "if", "(", "$", "page", "->", "isVisibleAtAnyTime", "(", ")", ")", "{", "if", "(", "$", "request", "->", "has", "(", "'visible_from'", ")", ")", "{", "$", "page", "->", "setVisibleFrom", "(", "new", "DateTime", "(", "$", "request", "->", "input", "(", "'visible_from'", ")", ")", ")", ";", "}", "$", "visibleTo", "=", "(", "$", "request", "->", "has", "(", "'toggle_visible_to'", ")", ")", "?", "new", "DateTime", "(", "$", "request", "->", "input", "(", "'visible_to'", ")", ")", ":", "null", ";", "$", "page", "->", "setVisibleTo", "(", "$", "visibleTo", ")", ";", "}", "PageFacade", "::", "save", "(", "$", "page", ")", ";", "if", "(", "!", "$", "wasVisible", "&&", "$", "page", "->", "isVisible", "(", ")", ")", "{", "Event", "::", "fire", "(", "new", "Events", "\\", "PageWasMadeVisible", "(", "$", "page", ",", "auth", "(", ")", "->", "user", "(", ")", ")", ")", ";", "}", "return", "(", "int", ")", "$", "page", "->", "isVisible", "(", ")", ";", "}" ]
Save the page visibility settings. @param Request $request @param Page $page @return int
[ "Save", "the", "page", "visibility", "settings", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Http/Controllers/Page/Settings.php#L320-L347
train
markstory/mini-asset
src/Filter/Sprockets.php
Sprockets._replace
protected function _replace($matches) { $file = $this->_currentFile; if ($matches[1] === '"') { // Same directory include $file = $this->_findFile($matches[2], dirname($file) . DIRECTORY_SEPARATOR); } else { // scan all paths $file = $this->_findFile($matches[2]); } // prevent double inclusion if (isset($this->_loaded[$file])) { return ""; } $this->_loaded[$file] = true; $content = file_get_contents($file); if ($return = $this->input($file, $content)) { return $return . "\n"; } return ''; }
php
protected function _replace($matches) { $file = $this->_currentFile; if ($matches[1] === '"') { // Same directory include $file = $this->_findFile($matches[2], dirname($file) . DIRECTORY_SEPARATOR); } else { // scan all paths $file = $this->_findFile($matches[2]); } // prevent double inclusion if (isset($this->_loaded[$file])) { return ""; } $this->_loaded[$file] = true; $content = file_get_contents($file); if ($return = $this->input($file, $content)) { return $return . "\n"; } return ''; }
[ "protected", "function", "_replace", "(", "$", "matches", ")", "{", "$", "file", "=", "$", "this", "->", "_currentFile", ";", "if", "(", "$", "matches", "[", "1", "]", "===", "'\"'", ")", "{", "// Same directory include", "$", "file", "=", "$", "this", "->", "_findFile", "(", "$", "matches", "[", "2", "]", ",", "dirname", "(", "$", "file", ")", ".", "DIRECTORY_SEPARATOR", ")", ";", "}", "else", "{", "// scan all paths", "$", "file", "=", "$", "this", "->", "_findFile", "(", "$", "matches", "[", "2", "]", ")", ";", "}", "// prevent double inclusion", "if", "(", "isset", "(", "$", "this", "->", "_loaded", "[", "$", "file", "]", ")", ")", "{", "return", "\"\"", ";", "}", "$", "this", "->", "_loaded", "[", "$", "file", "]", "=", "true", ";", "$", "content", "=", "file_get_contents", "(", "$", "file", ")", ";", "if", "(", "$", "return", "=", "$", "this", "->", "input", "(", "$", "file", ",", "$", "content", ")", ")", "{", "return", "$", "return", ".", "\"\\n\"", ";", "}", "return", "''", ";", "}" ]
Performs the replacements and inlines dependencies. @param array $matches @return string content
[ "Performs", "the", "replacements", "and", "inlines", "dependencies", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/Sprockets.php#L87-L109
train
boomcms/boom-core
src/BoomCMS/Database/Models/Page.php
Page.addVersion
public function addVersion(array $attrs = []): PageVersionInterface { if ($oldVersion = $this->getCurrentVersion()) { $attrs += $oldVersion->toArray(); } // Chunk type and ID fields shouldn't be copied. unset($attrs[PageVersion::ATTR_CHUNK_TYPE]); unset($attrs[PageVersion::ATTR_CHUNK_ID]); unset($attrs[PageVersion::ATTR_RESTORED_FROM]); $newVersion = new PageVersion($attrs); $newVersion->setPage($this); /* * Only make the new version a draft if the old version is published. * When a new page is created we set the edited_at time to make the first version published */ if ($oldVersion->isPublished()) { $newVersion->makeDraft(); } $newVersion->save(); $this->setCurrentVersion($newVersion); return $this->getCurrentVersion(); }
php
public function addVersion(array $attrs = []): PageVersionInterface { if ($oldVersion = $this->getCurrentVersion()) { $attrs += $oldVersion->toArray(); } // Chunk type and ID fields shouldn't be copied. unset($attrs[PageVersion::ATTR_CHUNK_TYPE]); unset($attrs[PageVersion::ATTR_CHUNK_ID]); unset($attrs[PageVersion::ATTR_RESTORED_FROM]); $newVersion = new PageVersion($attrs); $newVersion->setPage($this); /* * Only make the new version a draft if the old version is published. * When a new page is created we set the edited_at time to make the first version published */ if ($oldVersion->isPublished()) { $newVersion->makeDraft(); } $newVersion->save(); $this->setCurrentVersion($newVersion); return $this->getCurrentVersion(); }
[ "public", "function", "addVersion", "(", "array", "$", "attrs", "=", "[", "]", ")", ":", "PageVersionInterface", "{", "if", "(", "$", "oldVersion", "=", "$", "this", "->", "getCurrentVersion", "(", ")", ")", "{", "$", "attrs", "+=", "$", "oldVersion", "->", "toArray", "(", ")", ";", "}", "// Chunk type and ID fields shouldn't be copied.", "unset", "(", "$", "attrs", "[", "PageVersion", "::", "ATTR_CHUNK_TYPE", "]", ")", ";", "unset", "(", "$", "attrs", "[", "PageVersion", "::", "ATTR_CHUNK_ID", "]", ")", ";", "unset", "(", "$", "attrs", "[", "PageVersion", "::", "ATTR_RESTORED_FROM", "]", ")", ";", "$", "newVersion", "=", "new", "PageVersion", "(", "$", "attrs", ")", ";", "$", "newVersion", "->", "setPage", "(", "$", "this", ")", ";", "/*\n * Only make the new version a draft if the old version is published.\n * When a new page is created we set the edited_at time to make the first version published\n */", "if", "(", "$", "oldVersion", "->", "isPublished", "(", ")", ")", "{", "$", "newVersion", "->", "makeDraft", "(", ")", ";", "}", "$", "newVersion", "->", "save", "(", ")", ";", "$", "this", "->", "setCurrentVersion", "(", "$", "newVersion", ")", ";", "return", "$", "this", "->", "getCurrentVersion", "(", ")", ";", "}" ]
Adds a new version to the page. If the current version is embargoed then the new version is also embargoed. If the current version is published then the new version becomes a draft.
[ "Adds", "a", "new", "version", "to", "the", "page", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Page.php#L161-L188
train
boomcms/boom-core
src/BoomCMS/Database/Models/Page.php
Page.getDefaultChildTemplateId
public function getDefaultChildTemplateId(): int { if (!empty($this->{self::ATTR_CHILD_TEMPLATE})) { return (int) $this->{self::ATTR_CHILD_TEMPLATE}; } $parent = $this->getParent(); return ($parent && !empty($parent->getGrandchildTemplateId())) ? $parent->getGrandchildTemplateId() : $this->getTemplateId(); }
php
public function getDefaultChildTemplateId(): int { if (!empty($this->{self::ATTR_CHILD_TEMPLATE})) { return (int) $this->{self::ATTR_CHILD_TEMPLATE}; } $parent = $this->getParent(); return ($parent && !empty($parent->getGrandchildTemplateId())) ? $parent->getGrandchildTemplateId() : $this->getTemplateId(); }
[ "public", "function", "getDefaultChildTemplateId", "(", ")", ":", "int", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "{", "self", "::", "ATTR_CHILD_TEMPLATE", "}", ")", ")", "{", "return", "(", "int", ")", "$", "this", "->", "{", "self", "::", "ATTR_CHILD_TEMPLATE", "}", ";", "}", "$", "parent", "=", "$", "this", "->", "getParent", "(", ")", ";", "return", "(", "$", "parent", "&&", "!", "empty", "(", "$", "parent", "->", "getGrandchildTemplateId", "(", ")", ")", ")", "?", "$", "parent", "->", "getGrandchildTemplateId", "(", ")", ":", "$", "this", "->", "getTemplateId", "(", ")", ";", "}" ]
Returns the default template ID that child pages should use.
[ "Returns", "the", "default", "template", "ID", "that", "child", "pages", "should", "use", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Page.php#L314-L325
train
boomcms/boom-core
src/BoomCMS/Database/Models/Page.php
Page.getDefaultGrandchildTemplateId
public function getDefaultGrandchildTemplateId(): int { $grandchildTemplateId = $this->getGrandchildTemplateId(); return empty($grandchildTemplateId) ? $this->getTemplateId() : (int) $grandchildTemplateId; }
php
public function getDefaultGrandchildTemplateId(): int { $grandchildTemplateId = $this->getGrandchildTemplateId(); return empty($grandchildTemplateId) ? $this->getTemplateId() : (int) $grandchildTemplateId; }
[ "public", "function", "getDefaultGrandchildTemplateId", "(", ")", ":", "int", "{", "$", "grandchildTemplateId", "=", "$", "this", "->", "getGrandchildTemplateId", "(", ")", ";", "return", "empty", "(", "$", "grandchildTemplateId", ")", "?", "$", "this", "->", "getTemplateId", "(", ")", ":", "(", "int", ")", "$", "grandchildTemplateId", ";", "}" ]
If a default grandchild template ID is set then that is returned. Otherwise the current template ID of this page is returned.
[ "If", "a", "default", "grandchild", "template", "ID", "is", "set", "then", "that", "is", "returned", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Page.php#L332-L337
train
boomcms/boom-core
src/BoomCMS/Database/Models/Page.php
Page.getVisibleTo
public function getVisibleTo() { return empty($this->{self::ATTR_VISIBLE_TO}) ? null : new DateTime('@'.$this->{self::ATTR_VISIBLE_TO}); }
php
public function getVisibleTo() { return empty($this->{self::ATTR_VISIBLE_TO}) ? null : new DateTime('@'.$this->{self::ATTR_VISIBLE_TO}); }
[ "public", "function", "getVisibleTo", "(", ")", "{", "return", "empty", "(", "$", "this", "->", "{", "self", "::", "ATTR_VISIBLE_TO", "}", ")", "?", "null", ":", "new", "DateTime", "(", "'@'", ".", "$", "this", "->", "{", "self", "::", "ATTR_VISIBLE_TO", "}", ")", ";", "}" ]
Returns the visible to date, or null if none is set. @return null|DateTime
[ "Returns", "the", "visible", "to", "date", "or", "null", "if", "none", "is", "set", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Page.php#L447-L450
train
boomcms/boom-core
src/BoomCMS/Database/Models/Page.php
Page.setEmbargoTime
public function setEmbargoTime(DateTime $time): PageInterface { $this->addVersion([ PageVersion::ATTR_PENDING_APPROVAL => false, PageVersion::ATTR_EMBARGOED_UNTIL => $time->getTimestamp(), ]); return $this; }
php
public function setEmbargoTime(DateTime $time): PageInterface { $this->addVersion([ PageVersion::ATTR_PENDING_APPROVAL => false, PageVersion::ATTR_EMBARGOED_UNTIL => $time->getTimestamp(), ]); return $this; }
[ "public", "function", "setEmbargoTime", "(", "DateTime", "$", "time", ")", ":", "PageInterface", "{", "$", "this", "->", "addVersion", "(", "[", "PageVersion", "::", "ATTR_PENDING_APPROVAL", "=>", "false", ",", "PageVersion", "::", "ATTR_EMBARGOED_UNTIL", "=>", "$", "time", "->", "getTimestamp", "(", ")", ",", "]", ")", ";", "return", "$", "this", ";", "}" ]
Set an embargo time for any unpublished changes. If the time is in the past then the changes become published.
[ "Set", "an", "embargo", "time", "for", "any", "unpublished", "changes", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Page.php#L643-L651
train
boomcms/boom-core
src/BoomCMS/Database/Models/Page.php
Page.url
public function url() { if ($this->{self::ATTR_PRIMARY_URI} === null) { return; } if ($this->primaryUrl === null) { $this->primaryUrl = new URL([ 'page' => $this, 'location' => $this->{self::ATTR_PRIMARY_URI}, 'is_primary' => true, ]); } return $this->primaryUrl; }
php
public function url() { if ($this->{self::ATTR_PRIMARY_URI} === null) { return; } if ($this->primaryUrl === null) { $this->primaryUrl = new URL([ 'page' => $this, 'location' => $this->{self::ATTR_PRIMARY_URI}, 'is_primary' => true, ]); } return $this->primaryUrl; }
[ "public", "function", "url", "(", ")", "{", "if", "(", "$", "this", "->", "{", "self", "::", "ATTR_PRIMARY_URI", "}", "===", "null", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "primaryUrl", "===", "null", ")", "{", "$", "this", "->", "primaryUrl", "=", "new", "URL", "(", "[", "'page'", "=>", "$", "this", ",", "'location'", "=>", "$", "this", "->", "{", "self", "::", "ATTR_PRIMARY_URI", "}", ",", "'is_primary'", "=>", "true", ",", "]", ")", ";", "}", "return", "$", "this", "->", "primaryUrl", ";", "}" ]
Returns the URL object for the page's primary URI. The URL can be displayed by casting the returned object to a string: (string) $page->url(); @return URLInterface|null
[ "Returns", "the", "URL", "object", "for", "the", "page", "s", "primary", "URI", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Page.php#L774-L789
train
boomcms/boom-core
src/BoomCMS/Database/Models/Page.php
Page.scopeCurrentVersion
public function scopeCurrentVersion(Builder $query) { $subquery = $this->getCurrentVersionQuery(); return $query ->select('version.*') ->addSelect('version.id as version:id') ->addSelect('version.created_at as version:created_at') ->addSelect('version.created_by as version:created_by') ->addSelect('pages.*') ->join(DB::raw('('.$subquery->toSql().') as v2'), 'pages.id', '=', 'v2.page_id') ->mergeBindings($subquery) ->join('page_versions as version', function (JoinClause $join) { $join ->on('pages.id', '=', 'version.page_id') ->on('v2.id', '=', 'version.id'); }); }
php
public function scopeCurrentVersion(Builder $query) { $subquery = $this->getCurrentVersionQuery(); return $query ->select('version.*') ->addSelect('version.id as version:id') ->addSelect('version.created_at as version:created_at') ->addSelect('version.created_by as version:created_by') ->addSelect('pages.*') ->join(DB::raw('('.$subquery->toSql().') as v2'), 'pages.id', '=', 'v2.page_id') ->mergeBindings($subquery) ->join('page_versions as version', function (JoinClause $join) { $join ->on('pages.id', '=', 'version.page_id') ->on('v2.id', '=', 'version.id'); }); }
[ "public", "function", "scopeCurrentVersion", "(", "Builder", "$", "query", ")", "{", "$", "subquery", "=", "$", "this", "->", "getCurrentVersionQuery", "(", ")", ";", "return", "$", "query", "->", "select", "(", "'version.*'", ")", "->", "addSelect", "(", "'version.id as version:id'", ")", "->", "addSelect", "(", "'version.created_at as version:created_at'", ")", "->", "addSelect", "(", "'version.created_by as version:created_by'", ")", "->", "addSelect", "(", "'pages.*'", ")", "->", "join", "(", "DB", "::", "raw", "(", "'('", ".", "$", "subquery", "->", "toSql", "(", ")", ".", "') as v2'", ")", ",", "'pages.id'", ",", "'='", ",", "'v2.page_id'", ")", "->", "mergeBindings", "(", "$", "subquery", ")", "->", "join", "(", "'page_versions as version'", ",", "function", "(", "JoinClause", "$", "join", ")", "{", "$", "join", "->", "on", "(", "'pages.id'", ",", "'='", ",", "'version.page_id'", ")", "->", "on", "(", "'v2.id'", ",", "'='", ",", "'version.id'", ")", ";", "}", ")", ";", "}" ]
Scope for getting pages with the current version. This doesn't work as a global scope as changing the select columns breaks queries which add select columns. e.g. finding pages by related tags. @param Builder $query @return Builder
[ "Scope", "for", "getting", "pages", "with", "the", "current", "version", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Database/Models/Page.php#L836-L853
train
boomcms/boom-core
src/BoomCMS/Support/Helpers/URL.php
URL.fromTitle
public static function fromTitle($base, $title) { $url = static::sanitise($title); // If the base URL isn't empty and there's no trailing / then add one. if ($base && substr($base, -1) != '/') { $base = $base.'/'; } $url = ($base == '/') ? $url : $base.$url; return static::makeUnique($url); }
php
public static function fromTitle($base, $title) { $url = static::sanitise($title); // If the base URL isn't empty and there's no trailing / then add one. if ($base && substr($base, -1) != '/') { $base = $base.'/'; } $url = ($base == '/') ? $url : $base.$url; return static::makeUnique($url); }
[ "public", "static", "function", "fromTitle", "(", "$", "base", ",", "$", "title", ")", "{", "$", "url", "=", "static", "::", "sanitise", "(", "$", "title", ")", ";", "// If the base URL isn't empty and there's no trailing / then add one.", "if", "(", "$", "base", "&&", "substr", "(", "$", "base", ",", "-", "1", ")", "!=", "'/'", ")", "{", "$", "base", "=", "$", "base", ".", "'/'", ";", "}", "$", "url", "=", "(", "$", "base", "==", "'/'", ")", "?", "$", "url", ":", "$", "base", ".", "$", "url", ";", "return", "static", "::", "makeUnique", "(", "$", "url", ")", ";", "}" ]
Generate a unique URL from a page title. @param string $base @param string $title
[ "Generate", "a", "unique", "URL", "from", "a", "page", "title", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers/URL.php#L20-L32
train
boomcms/boom-core
src/BoomCMS/Support/Helpers/URL.php
URL.getInternalPath
public static function getInternalPath($url) { $path = parse_url($url, PHP_URL_PATH); return ($path === '/') ? $path : ltrim($path, '/'); }
php
public static function getInternalPath($url) { $path = parse_url($url, PHP_URL_PATH); return ($path === '/') ? $path : ltrim($path, '/'); }
[ "public", "static", "function", "getInternalPath", "(", "$", "url", ")", "{", "$", "path", "=", "parse_url", "(", "$", "url", ",", "PHP_URL_PATH", ")", ";", "return", "(", "$", "path", "===", "'/'", ")", "?", "$", "path", ":", "ltrim", "(", "$", "path", ",", "'/'", ")", ";", "}" ]
Returns a path which can be used to query the database of internal URLs. Removes the leading forward slash for non-root URLs And removes everything except the path portion of the URL @param string $url @return string
[ "Returns", "a", "path", "which", "can", "be", "used", "to", "query", "the", "database", "of", "internal", "URLs", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers/URL.php#L71-L76
train
boomcms/boom-core
src/BoomCMS/Support/Helpers/URL.php
URL.isInternal
public static function isInternal($url) { $relative = static::makeRelative($url); if (substr($relative, 0, 1) !== '/') { return false; } $path = static::getInternalPath($relative); return !URLFacade::isAvailable($path); }
php
public static function isInternal($url) { $relative = static::makeRelative($url); if (substr($relative, 0, 1) !== '/') { return false; } $path = static::getInternalPath($relative); return !URLFacade::isAvailable($path); }
[ "public", "static", "function", "isInternal", "(", "$", "url", ")", "{", "$", "relative", "=", "static", "::", "makeRelative", "(", "$", "url", ")", ";", "if", "(", "substr", "(", "$", "relative", ",", "0", ",", "1", ")", "!==", "'/'", ")", "{", "return", "false", ";", "}", "$", "path", "=", "static", "::", "getInternalPath", "(", "$", "relative", ")", ";", "return", "!", "URLFacade", "::", "isAvailable", "(", "$", "path", ")", ";", "}" ]
Determine whether a path is valid internal path. @param string $url @return bool
[ "Determine", "whether", "a", "path", "is", "valid", "internal", "path", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers/URL.php#L85-L96
train
boomcms/boom-core
src/BoomCMS/Support/Helpers/URL.php
URL.sanitise
public static function sanitise($url) { $url = trim($url); $url = strtolower($url); $url = parse_url($url, PHP_URL_PATH); // Make sure it doesn't contain a hostname $url = preg_replace('|/+|', '/', $url); // Remove duplicate forward slashes. if ($url !== '/') { // Remove trailing or preceeding slashes $url = trim($url, '/'); } $url = preg_replace('|[^'.preg_quote('-').'\/\pL\pN\s]+|u', '', $url); // Remove all characters that are not a hypeh, letters, numbers, or forward slash $url = preg_replace('|['.preg_quote('-').'\s]+|u', '-', $url); // Replace all hypens and whitespace by a single hyphen return $url; }
php
public static function sanitise($url) { $url = trim($url); $url = strtolower($url); $url = parse_url($url, PHP_URL_PATH); // Make sure it doesn't contain a hostname $url = preg_replace('|/+|', '/', $url); // Remove duplicate forward slashes. if ($url !== '/') { // Remove trailing or preceeding slashes $url = trim($url, '/'); } $url = preg_replace('|[^'.preg_quote('-').'\/\pL\pN\s]+|u', '', $url); // Remove all characters that are not a hypeh, letters, numbers, or forward slash $url = preg_replace('|['.preg_quote('-').'\s]+|u', '-', $url); // Replace all hypens and whitespace by a single hyphen return $url; }
[ "public", "static", "function", "sanitise", "(", "$", "url", ")", "{", "$", "url", "=", "trim", "(", "$", "url", ")", ";", "$", "url", "=", "strtolower", "(", "$", "url", ")", ";", "$", "url", "=", "parse_url", "(", "$", "url", ",", "PHP_URL_PATH", ")", ";", "// Make sure it doesn't contain a hostname", "$", "url", "=", "preg_replace", "(", "'|/+|'", ",", "'/'", ",", "$", "url", ")", ";", "// Remove duplicate forward slashes.", "if", "(", "$", "url", "!==", "'/'", ")", "{", "// Remove trailing or preceeding slashes", "$", "url", "=", "trim", "(", "$", "url", ",", "'/'", ")", ";", "}", "$", "url", "=", "preg_replace", "(", "'|[^'", ".", "preg_quote", "(", "'-'", ")", ".", "'\\/\\pL\\pN\\s]+|u'", ",", "''", ",", "$", "url", ")", ";", "// Remove all characters that are not a hypeh, letters, numbers, or forward slash", "$", "url", "=", "preg_replace", "(", "'|['", ".", "preg_quote", "(", "'-'", ")", ".", "'\\s]+|u'", ",", "'-'", ",", "$", "url", ")", ";", "// Replace all hypens and whitespace by a single hyphen", "return", "$", "url", ";", "}" ]
Remove invalid characters from a URL. @param string $url
[ "Remove", "invalid", "characters", "from", "a", "URL", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Support/Helpers/URL.php#L122-L138
train
contributte/bootstrap
src/PluggableConfigurator.php
PluggableConfigurator.getDefaultParameters
protected function getDefaultParameters(): array { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $last = end($trace); $debugMode = static::detectDebugMode(); return [ 'appDir' => isset($trace[2]['file']) ? dirname($trace[2]['file']) : null, 'wwwDir' => isset($last['file']) ? dirname($last['file']) : null, 'debugMode' => $debugMode, 'productionMode' => !$debugMode, 'consoleMode' => PHP_SAPI === 'cli', ]; }
php
protected function getDefaultParameters(): array { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $last = end($trace); $debugMode = static::detectDebugMode(); return [ 'appDir' => isset($trace[2]['file']) ? dirname($trace[2]['file']) : null, 'wwwDir' => isset($last['file']) ? dirname($last['file']) : null, 'debugMode' => $debugMode, 'productionMode' => !$debugMode, 'consoleMode' => PHP_SAPI === 'cli', ]; }
[ "protected", "function", "getDefaultParameters", "(", ")", ":", "array", "{", "$", "trace", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_IGNORE_ARGS", ")", ";", "$", "last", "=", "end", "(", "$", "trace", ")", ";", "$", "debugMode", "=", "static", "::", "detectDebugMode", "(", ")", ";", "return", "[", "'appDir'", "=>", "isset", "(", "$", "trace", "[", "2", "]", "[", "'file'", "]", ")", "?", "dirname", "(", "$", "trace", "[", "2", "]", "[", "'file'", "]", ")", ":", "null", ",", "'wwwDir'", "=>", "isset", "(", "$", "last", "[", "'file'", "]", ")", "?", "dirname", "(", "$", "last", "[", "'file'", "]", ")", ":", "null", ",", "'debugMode'", "=>", "$", "debugMode", ",", "'productionMode'", "=>", "!", "$", "debugMode", ",", "'consoleMode'", "=>", "PHP_SAPI", "===", "'cli'", ",", "]", ";", "}" ]
Collect default parameters @return mixed[]
[ "Collect", "default", "parameters" ]
24bca98d65a3885b74f3e7fcdd0fbb454df06b7b
https://github.com/contributte/bootstrap/blob/24bca98d65a3885b74f3e7fcdd0fbb454df06b7b/src/PluggableConfigurator.php#L40-L53
train
markstory/mini-asset
src/Filter/ImportInline.php
ImportInline._replace
protected function _replace($matches) { $required = empty($matches[2]) ? $matches[4] : $matches[2]; $filename = $this->scanner()->find($required); if (!$filename) { throw new RuntimeException(sprintf('Could not find dependency "%s"', $required)); } if (empty($this->_loaded[$filename])) { return $this->input($filename, file_get_contents($filename)); } return ''; }
php
protected function _replace($matches) { $required = empty($matches[2]) ? $matches[4] : $matches[2]; $filename = $this->scanner()->find($required); if (!$filename) { throw new RuntimeException(sprintf('Could not find dependency "%s"', $required)); } if (empty($this->_loaded[$filename])) { return $this->input($filename, file_get_contents($filename)); } return ''; }
[ "protected", "function", "_replace", "(", "$", "matches", ")", "{", "$", "required", "=", "empty", "(", "$", "matches", "[", "2", "]", ")", "?", "$", "matches", "[", "4", "]", ":", "$", "matches", "[", "2", "]", ";", "$", "filename", "=", "$", "this", "->", "scanner", "(", ")", "->", "find", "(", "$", "required", ")", ";", "if", "(", "!", "$", "filename", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Could not find dependency \"%s\"'", ",", "$", "required", ")", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "_loaded", "[", "$", "filename", "]", ")", ")", "{", "return", "$", "this", "->", "input", "(", "$", "filename", ",", "file_get_contents", "(", "$", "filename", ")", ")", ";", "}", "return", "''", ";", "}" ]
Does file replacements. @param array $matches @throws RuntimeException
[ "Does", "file", "replacements", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/ImportInline.php#L67-L78
train
boomcms/boom-core
src/BoomCMS/Chunk/Location.php
Location.attributes
public function attributes() { return [ $this->attributePrefix.'address' => (int) $this->address, $this->attributePrefix.'title' => (int) $this->title, ]; }
php
public function attributes() { return [ $this->attributePrefix.'address' => (int) $this->address, $this->attributePrefix.'title' => (int) $this->title, ]; }
[ "public", "function", "attributes", "(", ")", "{", "return", "[", "$", "this", "->", "attributePrefix", ".", "'address'", "=>", "(", "int", ")", "$", "this", "->", "address", ",", "$", "this", "->", "attributePrefix", ".", "'title'", "=>", "(", "int", ")", "$", "this", "->", "title", ",", "]", ";", "}" ]
Returns the array of chunk attributes. @return array
[ "Returns", "the", "array", "of", "chunk", "attributes", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Location.php#L48-L54
train
boomcms/boom-core
src/BoomCMS/Chunk/Location.php
Location.show
public function show() { return View::make($this->viewPrefix."location.$this->template", [ 'lat' => $this->getLat(), 'lng' => $this->getLng(), 'address' => $this->getAddress(), 'title' => $this->getTitle(), 'postcode' => $this->getPostcode(), 'location' => $this->getLocation(), ]); }
php
public function show() { return View::make($this->viewPrefix."location.$this->template", [ 'lat' => $this->getLat(), 'lng' => $this->getLng(), 'address' => $this->getAddress(), 'title' => $this->getTitle(), 'postcode' => $this->getPostcode(), 'location' => $this->getLocation(), ]); }
[ "public", "function", "show", "(", ")", "{", "return", "View", "::", "make", "(", "$", "this", "->", "viewPrefix", ".", "\"location.$this->template\"", ",", "[", "'lat'", "=>", "$", "this", "->", "getLat", "(", ")", ",", "'lng'", "=>", "$", "this", "->", "getLng", "(", ")", ",", "'address'", "=>", "$", "this", "->", "getAddress", "(", ")", ",", "'title'", "=>", "$", "this", "->", "getTitle", "(", ")", ",", "'postcode'", "=>", "$", "this", "->", "getPostcode", "(", ")", ",", "'location'", "=>", "$", "this", "->", "getLocation", "(", ")", ",", "]", ")", ";", "}" ]
Show a chunk where the target is set.
[ "Show", "a", "chunk", "where", "the", "target", "is", "set", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Location.php#L131-L141
train
boomcms/boom-core
src/BoomCMS/Policies/PersonPolicy.php
PersonPolicy.editSuperuser
public function editSuperuser(Person $user, Person $editing) { return $user->isSuperUser() && !$user->is($editing); }
php
public function editSuperuser(Person $user, Person $editing) { return $user->isSuperUser() && !$user->is($editing); }
[ "public", "function", "editSuperuser", "(", "Person", "$", "user", ",", "Person", "$", "editing", ")", "{", "return", "$", "user", "->", "isSuperUser", "(", ")", "&&", "!", "$", "user", "->", "is", "(", "$", "editing", ")", ";", "}" ]
Whether a user can edit the superuser status of another. @param Person $user @param Person $editing @return bool
[ "Whether", "a", "user", "can", "edit", "the", "superuser", "status", "of", "another", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Policies/PersonPolicy.php#L17-L20
train
markstory/mini-asset
src/AssetProcess.php
AssetProcess.run
public function run($input = null) { $descriptorSpec = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w') ); $process = proc_open( $this->_command, $descriptorSpec, $pipes, null, $this->_env ); if (is_resource($process)) { fwrite($pipes[0], $input); fclose($pipes[0]); $this->_output = stream_get_contents($pipes[1]); fclose($pipes[1]); $this->_error = stream_get_contents($pipes[2]); fclose($pipes[2]); proc_close($process); } return $this->_output; }
php
public function run($input = null) { $descriptorSpec = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w') ); $process = proc_open( $this->_command, $descriptorSpec, $pipes, null, $this->_env ); if (is_resource($process)) { fwrite($pipes[0], $input); fclose($pipes[0]); $this->_output = stream_get_contents($pipes[1]); fclose($pipes[1]); $this->_error = stream_get_contents($pipes[2]); fclose($pipes[2]); proc_close($process); } return $this->_output; }
[ "public", "function", "run", "(", "$", "input", "=", "null", ")", "{", "$", "descriptorSpec", "=", "array", "(", "0", "=>", "array", "(", "'pipe'", ",", "'r'", ")", ",", "1", "=>", "array", "(", "'pipe'", ",", "'w'", ")", ",", "2", "=>", "array", "(", "'pipe'", ",", "'w'", ")", ")", ";", "$", "process", "=", "proc_open", "(", "$", "this", "->", "_command", ",", "$", "descriptorSpec", ",", "$", "pipes", ",", "null", ",", "$", "this", "->", "_env", ")", ";", "if", "(", "is_resource", "(", "$", "process", ")", ")", "{", "fwrite", "(", "$", "pipes", "[", "0", "]", ",", "$", "input", ")", ";", "fclose", "(", "$", "pipes", "[", "0", "]", ")", ";", "$", "this", "->", "_output", "=", "stream_get_contents", "(", "$", "pipes", "[", "1", "]", ")", ";", "fclose", "(", "$", "pipes", "[", "1", "]", ")", ";", "$", "this", "->", "_error", "=", "stream_get_contents", "(", "$", "pipes", "[", "2", "]", ")", ";", "fclose", "(", "$", "pipes", "[", "2", "]", ")", ";", "proc_close", "(", "$", "process", ")", ";", "}", "return", "$", "this", "->", "_output", ";", "}" ]
Run the command and capture the output as the return. @param string $input STDIN for the command. @param string Output from the command.
[ "Run", "the", "command", "and", "capture", "the", "output", "as", "the", "return", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetProcess.php#L93-L119
train
markstory/mini-asset
src/Filter/Hogan.php
Hogan._generateScript
protected function _generateScript($file, $filename, $input) { $id = str_replace($this->_settings['ext'], '', basename($filename)); $filepath = str_replace($this->_settings['ext'], '', $filename); foreach ($this->_settings['paths'] as $path) { $path = rtrim($path, '/') . '/'; if (strpos($filepath, $path) === 0) { $filepath = str_replace($path, '', $filepath); } } $config = [ 'asString' => true, ]; $text = <<<JS var hogan = require('hogan.js'), util = require('util'); try { var template = hogan.compile(%s, %s); util.print('\\nwindow.JST["%s"] = window.JST["%s"] = ' + template + ';'); process.exit(0); } catch (e) { console.error(e); process.exit(1); } JS; $contents = sprintf( $text, json_encode($input), json_encode($config), $id, $filepath ); file_put_contents($file, $contents); }
php
protected function _generateScript($file, $filename, $input) { $id = str_replace($this->_settings['ext'], '', basename($filename)); $filepath = str_replace($this->_settings['ext'], '', $filename); foreach ($this->_settings['paths'] as $path) { $path = rtrim($path, '/') . '/'; if (strpos($filepath, $path) === 0) { $filepath = str_replace($path, '', $filepath); } } $config = [ 'asString' => true, ]; $text = <<<JS var hogan = require('hogan.js'), util = require('util'); try { var template = hogan.compile(%s, %s); util.print('\\nwindow.JST["%s"] = window.JST["%s"] = ' + template + ';'); process.exit(0); } catch (e) { console.error(e); process.exit(1); } JS; $contents = sprintf( $text, json_encode($input), json_encode($config), $id, $filepath ); file_put_contents($file, $contents); }
[ "protected", "function", "_generateScript", "(", "$", "file", ",", "$", "filename", ",", "$", "input", ")", "{", "$", "id", "=", "str_replace", "(", "$", "this", "->", "_settings", "[", "'ext'", "]", ",", "''", ",", "basename", "(", "$", "filename", ")", ")", ";", "$", "filepath", "=", "str_replace", "(", "$", "this", "->", "_settings", "[", "'ext'", "]", ",", "''", ",", "$", "filename", ")", ";", "foreach", "(", "$", "this", "->", "_settings", "[", "'paths'", "]", "as", "$", "path", ")", "{", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ".", "'/'", ";", "if", "(", "strpos", "(", "$", "filepath", ",", "$", "path", ")", "===", "0", ")", "{", "$", "filepath", "=", "str_replace", "(", "$", "path", ",", "''", ",", "$", "filepath", ")", ";", "}", "}", "$", "config", "=", "[", "'asString'", "=>", "true", ",", "]", ";", "$", "text", "=", " <<<JS\nvar hogan = require('hogan.js'),\n util = require('util');\n\ntry {\n var template = hogan.compile(%s, %s);\n util.print('\\\\nwindow.JST[\"%s\"] = window.JST[\"%s\"] = ' + template + ';');\n process.exit(0);\n} catch (e) {\n console.error(e);\n process.exit(1);\n}\nJS", ";", "$", "contents", "=", "sprintf", "(", "$", "text", ",", "json_encode", "(", "$", "input", ")", ",", "json_encode", "(", "$", "config", ")", ",", "$", "id", ",", "$", "filepath", ")", ";", "file_put_contents", "(", "$", "file", ",", "$", "contents", ")", ";", "}" ]
Generates the javascript passed into node to precompile the the mustache template. @param string $file The tempfile to put the script in. @param string $id The template id in window.JST @param string input The mustache template content. @return void
[ "Generates", "the", "javascript", "passed", "into", "node", "to", "precompile", "the", "the", "mustache", "template", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/Hogan.php#L76-L113
train
boomcms/boom-core
src/BoomCMS/FileInfo/Drivers/Pdf.php
Pdf.getThumbnail
public function getThumbnail(): Imagick { $image = new Imagick($this->file->getPathname().'[0]'); $image->setImageFormat('png'); return $image; }
php
public function getThumbnail(): Imagick { $image = new Imagick($this->file->getPathname().'[0]'); $image->setImageFormat('png'); return $image; }
[ "public", "function", "getThumbnail", "(", ")", ":", "Imagick", "{", "$", "image", "=", "new", "Imagick", "(", "$", "this", "->", "file", "->", "getPathname", "(", ")", ".", "'[0]'", ")", ";", "$", "image", "->", "setImageFormat", "(", "'png'", ")", ";", "return", "$", "image", ";", "}" ]
Generates a thumbnail for the PDF from the first page of the document. @return Imagick
[ "Generates", "a", "thumbnail", "for", "the", "PDF", "from", "the", "first", "page", "of", "the", "document", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/FileInfo/Drivers/Pdf.php#L37-L43
train
boomcms/boom-core
src/BoomCMS/FileInfo/Drivers/Pdf.php
Pdf.readMetadata
public function readMetadata(): array { try { $parser = new Parser(); $pdf = $parser->parseFile($this->file->getPathname()); return $pdf->getDetails(); } catch (Exception $e) { return []; } }
php
public function readMetadata(): array { try { $parser = new Parser(); $pdf = $parser->parseFile($this->file->getPathname()); return $pdf->getDetails(); } catch (Exception $e) { return []; } }
[ "public", "function", "readMetadata", "(", ")", ":", "array", "{", "try", "{", "$", "parser", "=", "new", "Parser", "(", ")", ";", "$", "pdf", "=", "$", "parser", "->", "parseFile", "(", "$", "this", "->", "file", "->", "getPathname", "(", ")", ")", ";", "return", "$", "pdf", "->", "getDetails", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "[", "]", ";", "}", "}" ]
Extracts metadata from a PDF. @return array
[ "Extracts", "metadata", "from", "a", "PDF", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/FileInfo/Drivers/Pdf.php#L66-L76
train
keboola/php-component
src/Config/BaseConfigDefinition.php
BaseConfigDefinition.getRootDefinition
protected function getRootDefinition(TreeBuilder $treeBuilder): ArrayNodeDefinition { /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->root('root'); $rootNode->ignoreExtraKeys(false); // @formatter:off $rootNode ->children() ->append($this->getParametersDefinition()); // @formatter:on return $rootNode; }
php
protected function getRootDefinition(TreeBuilder $treeBuilder): ArrayNodeDefinition { /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->root('root'); $rootNode->ignoreExtraKeys(false); // @formatter:off $rootNode ->children() ->append($this->getParametersDefinition()); // @formatter:on return $rootNode; }
[ "protected", "function", "getRootDefinition", "(", "TreeBuilder", "$", "treeBuilder", ")", ":", "ArrayNodeDefinition", "{", "/** @var ArrayNodeDefinition $rootNode */", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'root'", ")", ";", "$", "rootNode", "->", "ignoreExtraKeys", "(", "false", ")", ";", "// @formatter:off", "$", "rootNode", "->", "children", "(", ")", "->", "append", "(", "$", "this", "->", "getParametersDefinition", "(", ")", ")", ";", "// @formatter:on", "return", "$", "rootNode", ";", "}" ]
Root definition to be overridden in special cases
[ "Root", "definition", "to", "be", "overridden", "in", "special", "cases" ]
5a068b1dcbf461d8209f7f2358e01f7afca344a5
https://github.com/keboola/php-component/blob/5a068b1dcbf461d8209f7f2358e01f7afca344a5/src/Config/BaseConfigDefinition.php#L46-L59
train
markstory/mini-asset
src/Filter/FilterCollection.php
FilterCollection.input
public function input($file, $content) { foreach ($this->filters as $filter) { $content = $filter->input($file, $content); } return $content; }
php
public function input($file, $content) { foreach ($this->filters as $filter) { $content = $filter->input($file, $content); } return $content; }
[ "public", "function", "input", "(", "$", "file", ",", "$", "content", ")", "{", "foreach", "(", "$", "this", "->", "filters", "as", "$", "filter", ")", "{", "$", "content", "=", "$", "filter", "->", "input", "(", "$", "file", ",", "$", "content", ")", ";", "}", "return", "$", "content", ";", "}" ]
Apply all the input filters in sequence to the file and content. @param string $file Filename being processed. @param string $content The content of the file. @return string The content with all input filters applied.
[ "Apply", "all", "the", "input", "filters", "in", "sequence", "to", "the", "file", "and", "content", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/FilterCollection.php#L48-L54
train
markstory/mini-asset
src/Filter/FilterCollection.php
FilterCollection.output
public function output($target, $content) { foreach ($this->filters as $filter) { $content = $filter->output($target, $content); } return $content; }
php
public function output($target, $content) { foreach ($this->filters as $filter) { $content = $filter->output($target, $content); } return $content; }
[ "public", "function", "output", "(", "$", "target", ",", "$", "content", ")", "{", "foreach", "(", "$", "this", "->", "filters", "as", "$", "filter", ")", "{", "$", "content", "=", "$", "filter", "->", "output", "(", "$", "target", ",", "$", "content", ")", ";", "}", "return", "$", "content", ";", "}" ]
Apply all the output filters in sequence to the file and content. @param string $file Filename being processed. @param string $content The content of the file. @return string The content with all output filters applied.
[ "Apply", "all", "the", "output", "filters", "in", "sequence", "to", "the", "file", "and", "content", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/FilterCollection.php#L63-L69
train
boomcms/boom-core
src/BoomCMS/Chunk/Asset.php
Asset.getAsset
public function getAsset() { if ($this->asset === null) { $this->asset = AssetFacade::find($this->getAssetId()); } return $this->asset; }
php
public function getAsset() { if ($this->asset === null) { $this->asset = AssetFacade::find($this->getAssetId()); } return $this->asset; }
[ "public", "function", "getAsset", "(", ")", "{", "if", "(", "$", "this", "->", "asset", "===", "null", ")", "{", "$", "this", "->", "asset", "=", "AssetFacade", "::", "find", "(", "$", "this", "->", "getAssetId", "(", ")", ")", ";", "}", "return", "$", "this", "->", "asset", ";", "}" ]
Returns the associated asset. @return AssetContract
[ "Returns", "the", "associated", "asset", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Asset.php#L58-L65
train
boomcms/boom-core
src/BoomCMS/Chunk/Asset.php
Asset.getLink
public function getLink() { if ($this->link === null && isset($this->attrs['url'])) { $this->link = LinkObject::factory($this->attrs['url']); } return $this->link; }
php
public function getLink() { if ($this->link === null && isset($this->attrs['url'])) { $this->link = LinkObject::factory($this->attrs['url']); } return $this->link; }
[ "public", "function", "getLink", "(", ")", "{", "if", "(", "$", "this", "->", "link", "===", "null", "&&", "isset", "(", "$", "this", "->", "attrs", "[", "'url'", "]", ")", ")", "{", "$", "this", "->", "link", "=", "LinkObject", "::", "factory", "(", "$", "this", "->", "attrs", "[", "'url'", "]", ")", ";", "}", "return", "$", "this", "->", "link", ";", "}" ]
Returns a LinkObject for the associated link. @return LinkObject
[ "Returns", "a", "LinkObject", "for", "the", "associated", "link", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Chunk/Asset.php#L94-L101
train
markstory/mini-asset
src/Cli/BaseTask.php
BaseTask.config
public function config() { if (!$this->config) { $config = new AssetConfig(); $config->load($this->cli->arguments->get('config')); $this->config = $config; } return $this->config; }
php
public function config() { if (!$this->config) { $config = new AssetConfig(); $config->load($this->cli->arguments->get('config')); $this->config = $config; } return $this->config; }
[ "public", "function", "config", "(", ")", "{", "if", "(", "!", "$", "this", "->", "config", ")", "{", "$", "config", "=", "new", "AssetConfig", "(", ")", ";", "$", "config", "->", "load", "(", "$", "this", "->", "cli", "->", "arguments", "->", "get", "(", "'config'", ")", ")", ";", "$", "this", "->", "config", "=", "$", "config", ";", "}", "return", "$", "this", "->", "config", ";", "}" ]
Get the injected config or build a config object from the CLI option. @return \MiniAsset\AssetConfig
[ "Get", "the", "injected", "config", "or", "build", "a", "config", "object", "from", "the", "CLI", "option", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Cli/BaseTask.php#L40-L48
train
markstory/mini-asset
src/Cli/BaseTask.php
BaseTask.main
public function main($argv) { $this->addArguments(); try { $this->cli->arguments->parse($argv); } catch (\Exception $e) { $this->cli->usage(); return 0; } if ($this->cli->arguments->get('help')) { $this->cli->usage(); return 0; } return $this->execute(); }
php
public function main($argv) { $this->addArguments(); try { $this->cli->arguments->parse($argv); } catch (\Exception $e) { $this->cli->usage(); return 0; } if ($this->cli->arguments->get('help')) { $this->cli->usage(); return 0; } return $this->execute(); }
[ "public", "function", "main", "(", "$", "argv", ")", "{", "$", "this", "->", "addArguments", "(", ")", ";", "try", "{", "$", "this", "->", "cli", "->", "arguments", "->", "parse", "(", "$", "argv", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "cli", "->", "usage", "(", ")", ";", "return", "0", ";", "}", "if", "(", "$", "this", "->", "cli", "->", "arguments", "->", "get", "(", "'help'", ")", ")", "{", "$", "this", "->", "cli", "->", "usage", "(", ")", ";", "return", "0", ";", "}", "return", "$", "this", "->", "execute", "(", ")", ";", "}" ]
Execute the task given a set of CLI arguments. @param array $argv The arguments to use. @return int
[ "Execute", "the", "task", "given", "a", "set", "of", "CLI", "arguments", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Cli/BaseTask.php#L56-L70
train
markstory/mini-asset
src/Cli/BaseTask.php
BaseTask.verbose
public function verbose($text, $short = '') { if (!$this->cli->arguments->defined('verbose')) { if (strlen($short)) { $this->cli->inline($short); } return; } $this->cli->out($text); }
php
public function verbose($text, $short = '') { if (!$this->cli->arguments->defined('verbose')) { if (strlen($short)) { $this->cli->inline($short); } return; } $this->cli->out($text); }
[ "public", "function", "verbose", "(", "$", "text", ",", "$", "short", "=", "''", ")", "{", "if", "(", "!", "$", "this", "->", "cli", "->", "arguments", "->", "defined", "(", "'verbose'", ")", ")", "{", "if", "(", "strlen", "(", "$", "short", ")", ")", "{", "$", "this", "->", "cli", "->", "inline", "(", "$", "short", ")", ";", "}", "return", ";", "}", "$", "this", "->", "cli", "->", "out", "(", "$", "text", ")", ";", "}" ]
Output verbose information. @param string $text The text to output. @param string $short The short alternative.
[ "Output", "verbose", "information", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Cli/BaseTask.php#L78-L87
train
markstory/mini-asset
src/Cli/BaseTask.php
BaseTask.bootstrapApp
protected function bootstrapApp() { $files = explode(',', $this->cli->arguments->get('bootstrap')); foreach ($files as $file) { require_once $file; } }
php
protected function bootstrapApp() { $files = explode(',', $this->cli->arguments->get('bootstrap')); foreach ($files as $file) { require_once $file; } }
[ "protected", "function", "bootstrapApp", "(", ")", "{", "$", "files", "=", "explode", "(", "','", ",", "$", "this", "->", "cli", "->", "arguments", "->", "get", "(", "'bootstrap'", ")", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "require_once", "$", "file", ";", "}", "}" ]
Include any additional bootstrap files an application might need to create its environment of constants. @return void
[ "Include", "any", "additional", "bootstrap", "files", "an", "application", "might", "need", "to", "create", "its", "environment", "of", "constants", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Cli/BaseTask.php#L95-L101
train
boomcms/boom-core
src/BoomCMS/FileInfo/Drivers/Mpeg.php
Mpeg.readMetadata
public function readMetadata(): array { try { $ffprobe = FFProbe::create(); return $ffprobe ->format($this->file->getPathname()) ->all(); } catch (ExecutableNotFoundException $e) { return []; } }
php
public function readMetadata(): array { try { $ffprobe = FFProbe::create(); return $ffprobe ->format($this->file->getPathname()) ->all(); } catch (ExecutableNotFoundException $e) { return []; } }
[ "public", "function", "readMetadata", "(", ")", ":", "array", "{", "try", "{", "$", "ffprobe", "=", "FFProbe", "::", "create", "(", ")", ";", "return", "$", "ffprobe", "->", "format", "(", "$", "this", "->", "file", "->", "getPathname", "(", ")", ")", "->", "all", "(", ")", ";", "}", "catch", "(", "ExecutableNotFoundException", "$", "e", ")", "{", "return", "[", "]", ";", "}", "}" ]
Extracts metadata via FFProbe. @return array
[ "Extracts", "metadata", "via", "FFProbe", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/FileInfo/Drivers/Mpeg.php#L15-L26
train
contributte/bootstrap
src/ExtraConfigurator.php
ExtraConfigurator.parseParameters
public static function parseParameters(array $variables, string $prefix): array { $map = function (&$array, array $keys, $value) use (&$map) { if (count($keys) <= 0) return $value; $key = array_shift($keys); if (!is_array($array)) { throw new InvalidStateException(sprintf('Invalid structure for key "%s" value "%s"', implode($keys), $value)); } if (!array_key_exists($key, $array)) { $array[$key] = []; } // Recursive $array[$key] = $map($array[$key], $keys, $value); return $array; }; $parameters = []; foreach ($variables as $key => $value) { // Ensure value $value = getenv($key); if (strpos($key, $prefix) === 0 && $value !== false) { // Parse PREFIX{delimiter=__}{NAME-1}{delimiter=__}{NAME-N} $keys = static::parseParameter(substr($key, strlen($prefix))); // Make array structure $map($parameters, $keys, $value); } } return $parameters; }
php
public static function parseParameters(array $variables, string $prefix): array { $map = function (&$array, array $keys, $value) use (&$map) { if (count($keys) <= 0) return $value; $key = array_shift($keys); if (!is_array($array)) { throw new InvalidStateException(sprintf('Invalid structure for key "%s" value "%s"', implode($keys), $value)); } if (!array_key_exists($key, $array)) { $array[$key] = []; } // Recursive $array[$key] = $map($array[$key], $keys, $value); return $array; }; $parameters = []; foreach ($variables as $key => $value) { // Ensure value $value = getenv($key); if (strpos($key, $prefix) === 0 && $value !== false) { // Parse PREFIX{delimiter=__}{NAME-1}{delimiter=__}{NAME-N} $keys = static::parseParameter(substr($key, strlen($prefix))); // Make array structure $map($parameters, $keys, $value); } } return $parameters; }
[ "public", "static", "function", "parseParameters", "(", "array", "$", "variables", ",", "string", "$", "prefix", ")", ":", "array", "{", "$", "map", "=", "function", "(", "&", "$", "array", ",", "array", "$", "keys", ",", "$", "value", ")", "use", "(", "&", "$", "map", ")", "{", "if", "(", "count", "(", "$", "keys", ")", "<=", "0", ")", "return", "$", "value", ";", "$", "key", "=", "array_shift", "(", "$", "keys", ")", ";", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "{", "throw", "new", "InvalidStateException", "(", "sprintf", "(", "'Invalid structure for key \"%s\" value \"%s\"'", ",", "implode", "(", "$", "keys", ")", ",", "$", "value", ")", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", ")", "{", "$", "array", "[", "$", "key", "]", "=", "[", "]", ";", "}", "// Recursive", "$", "array", "[", "$", "key", "]", "=", "$", "map", "(", "$", "array", "[", "$", "key", "]", ",", "$", "keys", ",", "$", "value", ")", ";", "return", "$", "array", ";", "}", ";", "$", "parameters", "=", "[", "]", ";", "foreach", "(", "$", "variables", "as", "$", "key", "=>", "$", "value", ")", "{", "// Ensure value", "$", "value", "=", "getenv", "(", "$", "key", ")", ";", "if", "(", "strpos", "(", "$", "key", ",", "$", "prefix", ")", "===", "0", "&&", "$", "value", "!==", "false", ")", "{", "// Parse PREFIX{delimiter=__}{NAME-1}{delimiter=__}{NAME-N}", "$", "keys", "=", "static", "::", "parseParameter", "(", "substr", "(", "$", "key", ",", "strlen", "(", "$", "prefix", ")", ")", ")", ";", "// Make array structure", "$", "map", "(", "$", "parameters", ",", "$", "keys", ",", "$", "value", ")", ";", "}", "}", "return", "$", "parameters", ";", "}" ]
Parse given parameters with custom prefix @param mixed[] $variables @return mixed[]
[ "Parse", "given", "parameters", "with", "custom", "prefix" ]
24bca98d65a3885b74f3e7fcdd0fbb454df06b7b
https://github.com/contributte/bootstrap/blob/24bca98d65a3885b74f3e7fcdd0fbb454df06b7b/src/ExtraConfigurator.php#L108-L142
train
contributte/bootstrap
src/ExtraConfigurator.php
ExtraConfigurator.parseAllEnvironmentParameters
public static function parseAllEnvironmentParameters(): array { $parameters = []; foreach ($_SERVER as $key => $value) { // Ensure value $value = getenv($key); if ($value !== false) { $parameters[$key] = $value; } } return $parameters; }
php
public static function parseAllEnvironmentParameters(): array { $parameters = []; foreach ($_SERVER as $key => $value) { // Ensure value $value = getenv($key); if ($value !== false) { $parameters[$key] = $value; } } return $parameters; }
[ "public", "static", "function", "parseAllEnvironmentParameters", "(", ")", ":", "array", "{", "$", "parameters", "=", "[", "]", ";", "foreach", "(", "$", "_SERVER", "as", "$", "key", "=>", "$", "value", ")", "{", "// Ensure value", "$", "value", "=", "getenv", "(", "$", "key", ")", ";", "if", "(", "$", "value", "!==", "false", ")", "{", "$", "parameters", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "parameters", ";", "}" ]
Parse all environment variables @return mixed[]
[ "Parse", "all", "environment", "variables" ]
24bca98d65a3885b74f3e7fcdd0fbb454df06b7b
https://github.com/contributte/bootstrap/blob/24bca98d65a3885b74f3e7fcdd0fbb454df06b7b/src/ExtraConfigurator.php#L175-L187
train
markstory/mini-asset
src/AssetCollection.php
AssetCollection.append
public function append(AssetTarget $target) { $name = $target->name(); $this->indexed[$name] = $target; $this->items[] = $name; }
php
public function append(AssetTarget $target) { $name = $target->name(); $this->indexed[$name] = $target; $this->items[] = $name; }
[ "public", "function", "append", "(", "AssetTarget", "$", "target", ")", "{", "$", "name", "=", "$", "target", "->", "name", "(", ")", ";", "$", "this", "->", "indexed", "[", "$", "name", "]", "=", "$", "target", ";", "$", "this", "->", "items", "[", "]", "=", "$", "name", ";", "}" ]
Append an asset to the collection. @param AssetTarget $target The target to append @return void
[ "Append", "an", "asset", "to", "the", "collection", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetCollection.php#L81-L86
train
markstory/mini-asset
src/AssetCollection.php
AssetCollection.get
public function get($name) { if (!isset($this->indexed[$name])) { return null; } if (empty($this->indexed[$name])) { $this->indexed[$name] = $this->factory->target($name); } return $this->indexed[$name]; }
php
public function get($name) { if (!isset($this->indexed[$name])) { return null; } if (empty($this->indexed[$name])) { $this->indexed[$name] = $this->factory->target($name); } return $this->indexed[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "indexed", "[", "$", "name", "]", ")", ")", "{", "return", "null", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "indexed", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "indexed", "[", "$", "name", "]", "=", "$", "this", "->", "factory", "->", "target", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "indexed", "[", "$", "name", "]", ";", "}" ]
Get an asset from the collection @param string $name The name of the asset you want. @return null|AssetTarget Either null or the asset target.
[ "Get", "an", "asset", "from", "the", "collection" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetCollection.php#L94-L103
train
markstory/mini-asset
src/AssetCollection.php
AssetCollection.remove
public function remove($name) { if (!isset($this->indexed[$name])) { return; } unset($this->indexed[$name]); foreach ($this->items as $i => $v) { if ($v === $name) { unset($this->items[$i]); } } }
php
public function remove($name) { if (!isset($this->indexed[$name])) { return; } unset($this->indexed[$name]); foreach ($this->items as $i => $v) { if ($v === $name) { unset($this->items[$i]); } } }
[ "public", "function", "remove", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "indexed", "[", "$", "name", "]", ")", ")", "{", "return", ";", "}", "unset", "(", "$", "this", "->", "indexed", "[", "$", "name", "]", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "i", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "===", "$", "name", ")", "{", "unset", "(", "$", "this", "->", "items", "[", "$", "i", "]", ")", ";", "}", "}", "}" ]
Remove an asset from the collection @param string $name The name of the asset you want to remove @return void
[ "Remove", "an", "asset", "from", "the", "collection" ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/AssetCollection.php#L122-L134
train
boomcms/boom-core
src/BoomCMS/FileInfo/FileInfo.php
FileInfo.create
public function create(File $file): FileInfoDriver { $driver = $this->getDriver($file->getMimeType()); $className = __NAMESPACE__.'\Drivers\\'.$driver; return new $className($file); }
php
public function create(File $file): FileInfoDriver { $driver = $this->getDriver($file->getMimeType()); $className = __NAMESPACE__.'\Drivers\\'.$driver; return new $className($file); }
[ "public", "function", "create", "(", "File", "$", "file", ")", ":", "FileInfoDriver", "{", "$", "driver", "=", "$", "this", "->", "getDriver", "(", "$", "file", "->", "getMimeType", "(", ")", ")", ";", "$", "className", "=", "__NAMESPACE__", ".", "'\\Drivers\\\\'", ".", "$", "driver", ";", "return", "new", "$", "className", "(", "$", "file", ")", ";", "}" ]
Factory method for retrieving a FileInfo object. @param File $file @return FileInfoDriver
[ "Factory", "method", "for", "retrieving", "a", "FileInfo", "object", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/FileInfo/FileInfo.php#L30-L36
train
boomcms/boom-core
src/BoomCMS/FileInfo/FileInfo.php
FileInfo.getDriver
public function getDriver(string $mimetype) { foreach ($this->byMimetype as $match => $driver) { if ($mimetype === $match) { return $driver; } } foreach ($this->byMimeStart as $match => $driver) { if (strpos($mimetype, $match) === 0) { return $driver; } } return 'DefaultDriver'; }
php
public function getDriver(string $mimetype) { foreach ($this->byMimetype as $match => $driver) { if ($mimetype === $match) { return $driver; } } foreach ($this->byMimeStart as $match => $driver) { if (strpos($mimetype, $match) === 0) { return $driver; } } return 'DefaultDriver'; }
[ "public", "function", "getDriver", "(", "string", "$", "mimetype", ")", "{", "foreach", "(", "$", "this", "->", "byMimetype", "as", "$", "match", "=>", "$", "driver", ")", "{", "if", "(", "$", "mimetype", "===", "$", "match", ")", "{", "return", "$", "driver", ";", "}", "}", "foreach", "(", "$", "this", "->", "byMimeStart", "as", "$", "match", "=>", "$", "driver", ")", "{", "if", "(", "strpos", "(", "$", "mimetype", ",", "$", "match", ")", "===", "0", ")", "{", "return", "$", "driver", ";", "}", "}", "return", "'DefaultDriver'", ";", "}" ]
Determines which driver to use for a given mimetype. @param string $mimetype @return string
[ "Determines", "which", "driver", "to", "use", "for", "a", "given", "mimetype", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/FileInfo/FileInfo.php#L45-L60
train
boomcms/boom-core
src/BoomCMS/Policies/PagePolicy.php
PagePolicy.view
public function view(Person $person, Page $page) { if (!$page->aclEnabled()) { return true; } if ($page->wasCreatedBy($person) || $this->managesPages()) { return true; } $aclGroupIds = $page->getAclGroupIds(); if (count($aclGroupIds) === 0) { return true; } $groups = $person->getGroups(); foreach ($groups as $group) { if ($aclGroupIds->contains($group->getId())) { return true; } } return false; }
php
public function view(Person $person, Page $page) { if (!$page->aclEnabled()) { return true; } if ($page->wasCreatedBy($person) || $this->managesPages()) { return true; } $aclGroupIds = $page->getAclGroupIds(); if (count($aclGroupIds) === 0) { return true; } $groups = $person->getGroups(); foreach ($groups as $group) { if ($aclGroupIds->contains($group->getId())) { return true; } } return false; }
[ "public", "function", "view", "(", "Person", "$", "person", ",", "Page", "$", "page", ")", "{", "if", "(", "!", "$", "page", "->", "aclEnabled", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "page", "->", "wasCreatedBy", "(", "$", "person", ")", "||", "$", "this", "->", "managesPages", "(", ")", ")", "{", "return", "true", ";", "}", "$", "aclGroupIds", "=", "$", "page", "->", "getAclGroupIds", "(", ")", ";", "if", "(", "count", "(", "$", "aclGroupIds", ")", "===", "0", ")", "{", "return", "true", ";", "}", "$", "groups", "=", "$", "person", "->", "getGroups", "(", ")", ";", "foreach", "(", "$", "groups", "as", "$", "group", ")", "{", "if", "(", "$", "aclGroupIds", "->", "contains", "(", "$", "group", "->", "getId", "(", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Whether the page can be viewed. @param Person $person @param Page $page @return bool
[ "Whether", "the", "page", "can", "be", "viewed", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Policies/PagePolicy.php#L65-L90
train
markstory/mini-asset
src/Filter/FilterRegistry.php
FilterRegistry.collection
public function collection(AssetTarget $target) { $filters = []; foreach ($target->filterNames() as $name) { $filter = $this->get($name); if ($filter === null) { throw new RuntimeException("Filter '$name' was not loaded/configured."); } // Clone filters so the registry is not polluted. $copy = clone $filter; $copy->settings([ 'target' => $target->name(), 'paths' => $target->paths() ]); $filters[] = $copy; } return new FilterCollection($filters); }
php
public function collection(AssetTarget $target) { $filters = []; foreach ($target->filterNames() as $name) { $filter = $this->get($name); if ($filter === null) { throw new RuntimeException("Filter '$name' was not loaded/configured."); } // Clone filters so the registry is not polluted. $copy = clone $filter; $copy->settings([ 'target' => $target->name(), 'paths' => $target->paths() ]); $filters[] = $copy; } return new FilterCollection($filters); }
[ "public", "function", "collection", "(", "AssetTarget", "$", "target", ")", "{", "$", "filters", "=", "[", "]", ";", "foreach", "(", "$", "target", "->", "filterNames", "(", ")", "as", "$", "name", ")", "{", "$", "filter", "=", "$", "this", "->", "get", "(", "$", "name", ")", ";", "if", "(", "$", "filter", "===", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"Filter '$name' was not loaded/configured.\"", ")", ";", "}", "// Clone filters so the registry is not polluted.", "$", "copy", "=", "clone", "$", "filter", ";", "$", "copy", "->", "settings", "(", "[", "'target'", "=>", "$", "target", "->", "name", "(", ")", ",", "'paths'", "=>", "$", "target", "->", "paths", "(", ")", "]", ")", ";", "$", "filters", "[", "]", "=", "$", "copy", ";", "}", "return", "new", "FilterCollection", "(", "$", "filters", ")", ";", "}" ]
Get a filter collection for a specific target. @param \MiniAsset\AssetTarget $target The target to get a filter collection for. @return \MiniAsset\Filter\FilterCollection
[ "Get", "a", "filter", "collection", "for", "a", "specific", "target", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/FilterRegistry.php#L102-L119
train
boomcms/boom-core
src/BoomCMS/Theme/Commands/Publish.php
Publish.fire
public function fire() { $themes = $this->manager->findAndInstallThemes(); foreach ($themes as $theme) { $directories = [ $theme->getPublicDirectory() => public_path('vendor/boomcms/themes/'.$theme->getName()), $theme->getMigrationsDirectory() => base_path('migrations/boomcms'), ]; foreach ($directories as $from => $to) { if ($this->files->exists($from)) { $this->publishDirectory($from, $to); } } } }
php
public function fire() { $themes = $this->manager->findAndInstallThemes(); foreach ($themes as $theme) { $directories = [ $theme->getPublicDirectory() => public_path('vendor/boomcms/themes/'.$theme->getName()), $theme->getMigrationsDirectory() => base_path('migrations/boomcms'), ]; foreach ($directories as $from => $to) { if ($this->files->exists($from)) { $this->publishDirectory($from, $to); } } } }
[ "public", "function", "fire", "(", ")", "{", "$", "themes", "=", "$", "this", "->", "manager", "->", "findAndInstallThemes", "(", ")", ";", "foreach", "(", "$", "themes", "as", "$", "theme", ")", "{", "$", "directories", "=", "[", "$", "theme", "->", "getPublicDirectory", "(", ")", "=>", "public_path", "(", "'vendor/boomcms/themes/'", ".", "$", "theme", "->", "getName", "(", ")", ")", ",", "$", "theme", "->", "getMigrationsDirectory", "(", ")", "=>", "base_path", "(", "'migrations/boomcms'", ")", ",", "]", ";", "foreach", "(", "$", "directories", "as", "$", "from", "=>", "$", "to", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "from", ")", ")", "{", "$", "this", "->", "publishDirectory", "(", "$", "from", ",", "$", "to", ")", ";", "}", "}", "}", "}" ]
Publishes migrations and public files for all themes to their respective directories. The /public directory within all themes is copied to the application's public directory to make them accessible to the webserver The migrations directory for all themes is copied to a shared migrations/boomcms directory from where they can be run together @return mixed
[ "Publishes", "migrations", "and", "public", "files", "for", "all", "themes", "to", "their", "respective", "directories", "." ]
cc835772e3c33dac3e56c36a8db2c9e6da313c7b
https://github.com/boomcms/boom-core/blob/cc835772e3c33dac3e56c36a8db2c9e6da313c7b/src/BoomCMS/Theme/Commands/Publish.php#L55-L71
train
markstory/mini-asset
src/Filter/ScssPHP.php
ScssPHP.input
public function input($filename, $input) { if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) { return $input; } if (!class_exists('Leafo\\ScssPhp\\Compiler')) { throw new \Exception(sprintf('Cannot not load filter class "%s".', 'Leafo\\ScssPhp\\Compiler')); } $sc = new Compiler(); $sc->addImportPath(dirname($filename)); return $sc->compile($input); }
php
public function input($filename, $input) { if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) { return $input; } if (!class_exists('Leafo\\ScssPhp\\Compiler')) { throw new \Exception(sprintf('Cannot not load filter class "%s".', 'Leafo\\ScssPhp\\Compiler')); } $sc = new Compiler(); $sc->addImportPath(dirname($filename)); return $sc->compile($input); }
[ "public", "function", "input", "(", "$", "filename", ",", "$", "input", ")", "{", "if", "(", "substr", "(", "$", "filename", ",", "strlen", "(", "$", "this", "->", "_settings", "[", "'ext'", "]", ")", "*", "-", "1", ")", "!==", "$", "this", "->", "_settings", "[", "'ext'", "]", ")", "{", "return", "$", "input", ";", "}", "if", "(", "!", "class_exists", "(", "'Leafo\\\\ScssPhp\\\\Compiler'", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Cannot not load filter class \"%s\".'", ",", "'Leafo\\\\ScssPhp\\\\Compiler'", ")", ")", ";", "}", "$", "sc", "=", "new", "Compiler", "(", ")", ";", "$", "sc", "->", "addImportPath", "(", "dirname", "(", "$", "filename", ")", ")", ";", "return", "$", "sc", "->", "compile", "(", "$", "input", ")", ";", "}" ]
Runs `scssc` against any files that match the configured extension. @param string $filename The name of the input file. @param string $input The content of the file. @throws \Exception @return string
[ "Runs", "scssc", "against", "any", "files", "that", "match", "the", "configured", "extension", "." ]
5564bcbe2749a28d7978d36362c390bce39083a3
https://github.com/markstory/mini-asset/blob/5564bcbe2749a28d7978d36362c390bce39083a3/src/Filter/ScssPHP.php#L50-L61
train