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
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.paginateRaw
public function paginateRaw($count, $page, $itemsPerPage) { $this->paginator->tweak($count, $itemsPerPage, $page); $this->limit($this->paginator->countOffset(), $this->paginator->getItemsPerPage()); return $this; }
php
public function paginateRaw($count, $page, $itemsPerPage) { $this->paginator->tweak($count, $itemsPerPage, $page); $this->limit($this->paginator->countOffset(), $this->paginator->getItemsPerPage()); return $this; }
[ "public", "function", "paginateRaw", "(", "$", "count", ",", "$", "page", ",", "$", "itemsPerPage", ")", "{", "$", "this", "->", "paginator", "->", "tweak", "(", "$", "count", ",", "$", "itemsPerPage", ",", "$", "page", ")", ";", "$", "this", "->", ...
Paginates a result-set without automatic query guessing @param integer $count @param integer $page Current page @param integer $itemsPerPage Items per page to be shown @return \Krystal\Db\Sql\Db
[ "Paginates", "a", "result", "-", "set", "without", "automatic", "query", "guessing" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L452-L458
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.paginate
public function paginate($page, $itemsPerPage, $column = '1') { $count = $this->getCount($column); if ($this->isDriver('mysql') || $this->isDriver('sqlite')) { // Alter paginator's state $this->paginateRaw($count, $page, $itemsPerPage); } else { throw new RuntimeException('Smart pagination algorithm is currently supported only for MySQL and SQLite'); } return $this; }
php
public function paginate($page, $itemsPerPage, $column = '1') { $count = $this->getCount($column); if ($this->isDriver('mysql') || $this->isDriver('sqlite')) { // Alter paginator's state $this->paginateRaw($count, $page, $itemsPerPage); } else { throw new RuntimeException('Smart pagination algorithm is currently supported only for MySQL and SQLite'); } return $this; }
[ "public", "function", "paginate", "(", "$", "page", ",", "$", "itemsPerPage", ",", "$", "column", "=", "'1'", ")", "{", "$", "count", "=", "$", "this", "->", "getCount", "(", "$", "column", ")", ";", "if", "(", "$", "this", "->", "isDriver", "(", ...
Automatically paginates result-set @param integer $page Current page @param integer $itemsPerPage Items per page to be shown @param string $column Column to be selected when counting @throws \RuntimeException If algorithm isn't supported for current driver @return \Krystal\Db\Sql\Db
[ "Automatically", "paginates", "result", "-", "set" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L469-L481
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.getPrimaryKey
public function getPrimaryKey($table) { $db = $this->showKeys()->from($table) ->whereEquals('Key_name', new RawBinding('PRIMARY')); return $db->query('Column_name'); }
php
public function getPrimaryKey($table) { $db = $this->showKeys()->from($table) ->whereEquals('Key_name', new RawBinding('PRIMARY')); return $db->query('Column_name'); }
[ "public", "function", "getPrimaryKey", "(", "$", "table", ")", "{", "$", "db", "=", "$", "this", "->", "showKeys", "(", ")", "->", "from", "(", "$", "table", ")", "->", "whereEquals", "(", "'Key_name'", ",", "new", "RawBinding", "(", "'PRIMARY'", ")", ...
Gets primary out of a table @param string $table @return string|boolean False if no primary key available
[ "Gets", "primary", "out", "of", "a", "table" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L512-L518
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.raw
public function raw($query, array $bindings = array()) { if (!empty($bindings)) { foreach ($bindings as $column => $value) { $this->bind($column, $value); } } $this->queryBuilder->raw($query); return $this; }
php
public function raw($query, array $bindings = array()) { if (!empty($bindings)) { foreach ($bindings as $column => $value) { $this->bind($column, $value); } } $this->queryBuilder->raw($query); return $this; }
[ "public", "function", "raw", "(", "$", "query", ",", "array", "$", "bindings", "=", "array", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "bindings", ")", ")", "{", "foreach", "(", "$", "bindings", "as", "$", "column", "=>", "$", "value...
Executes raw query @param string $query @param array $bindings @return \Krystal\Db\Sql\Db
[ "Executes", "raw", "query" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L564-L574
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.getStmt
public function getStmt() { // Make sure there are no nested arrays if (ArrayUtils::hasAtLeastOneArrayValue($this->bindings)) { throw new RuntimeException('PDO bindings can not contain nested arrays'); } // Build target query before bindings are cleared purely for logging purpose $log = str_replace(array_keys($this->bindings), array_values($this->bindings), $this->queryBuilder->getQueryString()); // Execute it $stmt = $this->pdo->prepare($this->queryBuilder->getQueryString()); $stmt->execute($this->bindings); // Log target query $this->queryLogger->add($log); // Clear the buffer $this->clear(); return $stmt; }
php
public function getStmt() { // Make sure there are no nested arrays if (ArrayUtils::hasAtLeastOneArrayValue($this->bindings)) { throw new RuntimeException('PDO bindings can not contain nested arrays'); } // Build target query before bindings are cleared purely for logging purpose $log = str_replace(array_keys($this->bindings), array_values($this->bindings), $this->queryBuilder->getQueryString()); // Execute it $stmt = $this->pdo->prepare($this->queryBuilder->getQueryString()); $stmt->execute($this->bindings); // Log target query $this->queryLogger->add($log); // Clear the buffer $this->clear(); return $stmt; }
[ "public", "function", "getStmt", "(", ")", "{", "// Make sure there are no nested arrays", "if", "(", "ArrayUtils", "::", "hasAtLeastOneArrayValue", "(", "$", "this", "->", "bindings", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'PDO bindings can not cont...
Returns prepared PDO statement For internal usage only, regarding its public visibility @throws \RuntimeException If bindings contain nested arrays @return \PDOStatement
[ "Returns", "prepared", "PDO", "statement", "For", "internal", "usage", "only", "regarding", "its", "public", "visibility" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L583-L604
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.queryAll
public function queryAll($column = null, $mode = null) { if (is_null($mode)) { $mode = $this->pdo->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); } $result = array(); $rows = $this->getStmt()->fetchAll($mode); if ($column == null) { $result = $rows; } else { foreach ($rows as $row) { if (isset($row[$column])) { $result[] = $row[$column]; } else { return false; } } } if ($this->relationProcessor->hasQueue()) { return $this->relationProcessor->process($result); } else { return $result; } }
php
public function queryAll($column = null, $mode = null) { if (is_null($mode)) { $mode = $this->pdo->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); } $result = array(); $rows = $this->getStmt()->fetchAll($mode); if ($column == null) { $result = $rows; } else { foreach ($rows as $row) { if (isset($row[$column])) { $result[] = $row[$column]; } else { return false; } } } if ($this->relationProcessor->hasQueue()) { return $this->relationProcessor->process($result); } else { return $result; } }
[ "public", "function", "queryAll", "(", "$", "column", "=", "null", ",", "$", "mode", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "mode", ")", ")", "{", "$", "mode", "=", "$", "this", "->", "pdo", "->", "getAttribute", "(", "PDO", "::",...
Queries for all result-set @param string $column Optionally can be filtered by a column @param integer $mode Fetch mode. Can be overridden when needed @return mixed
[ "Queries", "for", "all", "result", "-", "set" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L613-L639
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.query
public function query($column = null, $mode = null) { if (is_null($mode)) { $mode = $this->pdo->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); } $result = array(); $rows = $this->getStmt()->fetch($mode); if ($column !== null) { if (isset($rows[$column])) { $result = $rows[$column]; } else { $result = false; } } else { $result = $rows; } if ($this->relationProcessor->hasQueue()) { $data = $this->relationProcessor->process(array($result)); return isset($data[0]) ? $data[0] : false; } // By default return $result; }
php
public function query($column = null, $mode = null) { if (is_null($mode)) { $mode = $this->pdo->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); } $result = array(); $rows = $this->getStmt()->fetch($mode); if ($column !== null) { if (isset($rows[$column])) { $result = $rows[$column]; } else { $result = false; } } else { $result = $rows; } if ($this->relationProcessor->hasQueue()) { $data = $this->relationProcessor->process(array($result)); return isset($data[0]) ? $data[0] : false; } // By default return $result; }
[ "public", "function", "query", "(", "$", "column", "=", "null", ",", "$", "mode", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "mode", ")", ")", "{", "$", "mode", "=", "$", "this", "->", "pdo", "->", "getAttribute", "(", "PDO", "::", ...
Queries for a single result-set @param string $column Optionally can be filtered by a column @param integer $mode Fetch mode. Can be overridden when needed @return mixed
[ "Queries", "for", "a", "single", "result", "-", "set" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L648-L674
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.queryScalar
public function queryScalar($mode = null) { $result = $this->query(null, $mode); if (is_array($result)) { // Filter by values $result = array_values($result); return isset($result[0]) ? $result[0] : false; } return false; }
php
public function queryScalar($mode = null) { $result = $this->query(null, $mode); if (is_array($result)) { // Filter by values $result = array_values($result); return isset($result[0]) ? $result[0] : false; } return false; }
[ "public", "function", "queryScalar", "(", "$", "mode", "=", "null", ")", "{", "$", "result", "=", "$", "this", "->", "query", "(", "null", ",", "$", "mode", ")", ";", "if", "(", "is_array", "(", "$", "result", ")", ")", "{", "// Filter by values", ...
Queries for a single result-set returning a value of a first column @param integer $mode Fetch mode. Can be overridden when needed @return string|boolean
[ "Queries", "for", "a", "single", "result", "-", "set", "returning", "a", "value", "of", "a", "first", "column" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L682-L693
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.increment
public function increment($table, $column, $step = 1) { $this->queryBuilder->increment($table, $column, $step); return $this; }
php
public function increment($table, $column, $step = 1) { $this->queryBuilder->increment($table, $column, $step); return $this; }
[ "public", "function", "increment", "(", "$", "table", ",", "$", "column", ",", "$", "step", "=", "1", ")", "{", "$", "this", "->", "queryBuilder", "->", "increment", "(", "$", "table", ",", "$", "column", ",", "$", "step", ")", ";", "return", "$", ...
Appends increment condition @param string $table @param string $column @param integer $step @return \Krystal\Db\Sql\Db
[ "Appends", "increment", "condition" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L800-L804
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.decrement
public function decrement($table, $column, $step = 1) { $this->queryBuilder->decrement($table, $column, $step); return $this; }
php
public function decrement($table, $column, $step = 1) { $this->queryBuilder->decrement($table, $column, $step); return $this; }
[ "public", "function", "decrement", "(", "$", "table", ",", "$", "column", ",", "$", "step", "=", "1", ")", "{", "$", "this", "->", "queryBuilder", "->", "decrement", "(", "$", "table", ",", "$", "column", ",", "$", "step", ")", ";", "return", "$", ...
Appends decrement condition @param string $table @param string $column @param integer $step @return \Krystal\Db\Sql\Db
[ "Appends", "decrement", "condition" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L814-L818
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.equals
public function equals($column, $value, $filter = false) { return $this->compare($column, '=', $value, $filter); }
php
public function equals($column, $value, $filter = false) { return $this->compare($column, '=', $value, $filter); }
[ "public", "function", "equals", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "compare", "(", "$", "column", ",", "'='", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ]
Appends a raw comparison with = operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "a", "raw", "comparison", "with", "=", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1010-L1013
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.notEquals
public function notEquals($column, $value, $filter = false) { return $this->compare($column, '!=', $value, $filter); }
php
public function notEquals($column, $value, $filter = false) { return $this->compare($column, '!=', $value, $filter); }
[ "public", "function", "notEquals", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "compare", "(", "$", "column", ",", "'!='", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ]
Appends a raw comparison with != operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "a", "raw", "comparison", "with", "!", "=", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1023-L1026
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.like
public function like($column, $value, $filter = false) { return $this->compare($column, 'LIKE', $value, $filter); }
php
public function like($column, $value, $filter = false) { return $this->compare($column, 'LIKE', $value, $filter); }
[ "public", "function", "like", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "compare", "(", "$", "column", ",", "'LIKE'", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ]
Appends a raw comparison with LIKE operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "a", "raw", "comparison", "with", "LIKE", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1036-L1039
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.notLike
public function notLike($column, $value, $filter = false) { return $this->compare($column, 'NOT LIKE', $value, $filter); }
php
public function notLike($column, $value, $filter = false) { return $this->compare($column, 'NOT LIKE', $value, $filter); }
[ "public", "function", "notLike", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "compare", "(", "$", "column", ",", "'NOT LIKE'", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ...
Appends a raw comparison with NOT LIKE operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "a", "raw", "comparison", "with", "NOT", "LIKE", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1049-L1052
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.greaterThan
public function greaterThan($column, $value, $filter = false) { return $this->compare($column, '>', $value, $filter); }
php
public function greaterThan($column, $value, $filter = false) { return $this->compare($column, '>', $value, $filter); }
[ "public", "function", "greaterThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "compare", "(", "$", "column", ",", "'>'", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ]
Appends a raw comparison with > operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "a", "raw", "comparison", "with", ">", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1062-L1065
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.lessThan
public function lessThan($column, $value, $filter = false) { return $this->compare($column, '<', $value, $filter); }
php
public function lessThan($column, $value, $filter = false) { return $this->compare($column, '<', $value, $filter); }
[ "public", "function", "lessThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "compare", "(", "$", "column", ",", "'<'", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ]
Appends a raw comparison with < operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "a", "raw", "comparison", "with", "<", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1075-L1078
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.orWhereBetween
public function orWhereBetween($column, $a, $b, $filter = false) { return $this->between(__FUNCTION__, $column, $a, $b, $filter); }
php
public function orWhereBetween($column, $a, $b, $filter = false) { return $this->between(__FUNCTION__, $column, $a, $b, $filter); }
[ "public", "function", "orWhereBetween", "(", "$", "column", ",", "$", "a", ",", "$", "b", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "between", "(", "__FUNCTION__", ",", "$", "column", ",", "$", "a", ",", "$", "b", "...
Appends OR WHERE with BETWEEN operator @param string $column @param string $a First value @param string $b Second value @param boolean $filter Whether to rely on filter @return \Krystal\Db\Sql\Db
[ "Appends", "OR", "WHERE", "with", "BETWEEN", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1316-L1319
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.between
private function between($method, $column, $a, $b, $filter) { if (!$this->queryBuilder->isFilterable($filter, array($a, $b))) { return $this; } if ($a instanceof RawSqlFragmentInterface) { $x = $a->getFragment(); } if ($b instanceof RawSqlFragmentInterface) { $y = $b->getFragment(); } // When doing betweens, unique placeholders come in handy if (!isset($x)) { $x = $this->getUniqPlaceholder(); } if (!isset($y)) { $y = $this->getUniqPlaceholder(); } // Prepare query string call_user_func(array($this->queryBuilder, $method), $column, $x, $y, $filter); // And finally bind values if (!($a instanceof RawSqlFragmentInterface)) { $this->bind($x, $a); } if (!($b instanceof RawSqlFragmentInterface)) { $this->bind($y, $b); } return $this; }
php
private function between($method, $column, $a, $b, $filter) { if (!$this->queryBuilder->isFilterable($filter, array($a, $b))) { return $this; } if ($a instanceof RawSqlFragmentInterface) { $x = $a->getFragment(); } if ($b instanceof RawSqlFragmentInterface) { $y = $b->getFragment(); } // When doing betweens, unique placeholders come in handy if (!isset($x)) { $x = $this->getUniqPlaceholder(); } if (!isset($y)) { $y = $this->getUniqPlaceholder(); } // Prepare query string call_user_func(array($this->queryBuilder, $method), $column, $x, $y, $filter); // And finally bind values if (!($a instanceof RawSqlFragmentInterface)) { $this->bind($x, $a); } if (!($b instanceof RawSqlFragmentInterface)) { $this->bind($y, $b); } return $this; }
[ "private", "function", "between", "(", "$", "method", ",", "$", "column", ",", "$", "a", ",", "$", "b", ",", "$", "filter", ")", "{", "if", "(", "!", "$", "this", "->", "queryBuilder", "->", "isFilterable", "(", "$", "filter", ",", "array", "(", ...
Adds WHERE with BETWEEN operator @param string $method Method to be called from query builder @param string $column @param string $a First value @param string $b Second value @param boolean $filter Whether to rely on filter @return \Krystal\Db\Sql\Db
[ "Adds", "WHERE", "with", "BETWEEN", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1401-L1437
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.constraint
private function constraint($method, $column, $operator, $value, $filter) { if (!$this->queryBuilder->isFilterable($filter, $value)) { return $this; } call_user_func(array($this->queryBuilder, $method), $column, $operator, $this->createUniqPlaceholder($value)); return $this; }
php
private function constraint($method, $column, $operator, $value, $filter) { if (!$this->queryBuilder->isFilterable($filter, $value)) { return $this; } call_user_func(array($this->queryBuilder, $method), $column, $operator, $this->createUniqPlaceholder($value)); return $this; }
[ "private", "function", "constraint", "(", "$", "method", ",", "$", "column", ",", "$", "operator", ",", "$", "value", ",", "$", "filter", ")", "{", "if", "(", "!", "$", "this", "->", "queryBuilder", "->", "isFilterable", "(", "$", "filter", ",", "$",...
Adds a constraint to the query @param string $method @param string $column @param string $operator @param string $value @param boolean $filter Whether to filter by empty value @return \Krystal\Db\Sql\Db
[ "Adds", "a", "constraint", "to", "the", "query" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1449-L1457
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.whereInValues
private function whereInValues($method, $column, $values, $filter) { if (!$this->queryBuilder->isFilterable($filter, $values)) { return $this; } if ($values instanceof RawBindingInterface) { call_user_func(array($this->queryBuilder, $method), $column, $values->getTarget(), $filter); } elseif ($values instanceof RawSqlFragmentInterface) { call_user_func(array($this->queryBuilder, $method), $column, $values, $filter); } else { // Prepare bindings, firstly $bindings = array(); foreach ($values as $value) { // Generate unique placeholder $placeholder = $this->getUniqPlaceholder(); // Append to collection $bindings[$placeholder] = $value; } call_user_func(array($this->queryBuilder, $method), $column, array_keys($bindings), $filter); // Now bind what we have so far foreach ($bindings as $key => $value) { $this->bind($key, $value); } } return $this; }
php
private function whereInValues($method, $column, $values, $filter) { if (!$this->queryBuilder->isFilterable($filter, $values)) { return $this; } if ($values instanceof RawBindingInterface) { call_user_func(array($this->queryBuilder, $method), $column, $values->getTarget(), $filter); } elseif ($values instanceof RawSqlFragmentInterface) { call_user_func(array($this->queryBuilder, $method), $column, $values, $filter); } else { // Prepare bindings, firstly $bindings = array(); foreach ($values as $value) { // Generate unique placeholder $placeholder = $this->getUniqPlaceholder(); // Append to collection $bindings[$placeholder] = $value; } call_user_func(array($this->queryBuilder, $method), $column, array_keys($bindings), $filter); // Now bind what we have so far foreach ($bindings as $key => $value) { $this->bind($key, $value); } } return $this; }
[ "private", "function", "whereInValues", "(", "$", "method", ",", "$", "column", ",", "$", "values", ",", "$", "filter", ")", "{", "if", "(", "!", "$", "this", "->", "queryBuilder", "->", "isFilterable", "(", "$", "filter", ",", "$", "values", ")", ")...
Internal method to handle WHERE IN methods @param string $method @param string $column @param array|\Krystal\Db\Sql\RawBindingInterface|\Krystal\Db\Sql\RawSqlFragmentInterface $values @param boolean $filter Whether to rely on filter @return \Krystal\Db\Sql\Db
[ "Internal", "method", "to", "handle", "WHERE", "IN", "methods" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1546-L1576
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.where
public function where($column, $operator, $value, $filter = false) { return $this->constraint(__FUNCTION__, $column, $operator, $value, $filter); }
php
public function where($column, $operator, $value, $filter = false) { return $this->constraint(__FUNCTION__, $column, $operator, $value, $filter); }
[ "public", "function", "where", "(", "$", "column", ",", "$", "operator", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "constraint", "(", "__FUNCTION__", ",", "$", "column", ",", "$", "operator", ",", "$"...
Adds where clause @param string $column @param string $operator @param string $value @param boolean $filter Whether to filter by empty value @return \Krystal\Db\Sql\Db
[ "Adds", "where", "clause" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1587-L1590
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.orWhereEquals
public function orWhereEquals($column, $value, $filter = false) { return $this->orWhere($column, '=', $value, $filter); }
php
public function orWhereEquals($column, $value, $filter = false) { return $this->orWhere($column, '=', $value, $filter); }
[ "public", "function", "orWhereEquals", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "orWhere", "(", "$", "column", ",", "'='", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ]
Appends OR WHERE expression with equality operator @param string $column @param string $value @param boolean $filter @return \Krystal\Db\Sql\Db
[ "Appends", "OR", "WHERE", "expression", "with", "equality", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1653-L1656
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.orWhereNotEquals
public function orWhereNotEquals($column, $value, $filter = false) { return $this->orWhere($column, '!=', $value, $filter); }
php
public function orWhereNotEquals($column, $value, $filter = false) { return $this->orWhere($column, '!=', $value, $filter); }
[ "public", "function", "orWhereNotEquals", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "orWhere", "(", "$", "column", ",", "'!='", ",", "$", "value", ",", "$", "filter", ")", ";", "...
Appends OR WHERE with != operator @param string $column @param string $value @param boolean $filter @return \Krystal\Db\Sql\Db
[ "Appends", "OR", "WHERE", "with", "!", "=", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1666-L1669
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.orWhereGreaterThanOrEquals
public function orWhereGreaterThanOrEquals($column, $value, $filter = false) { return $this->orWhere($column, '>=', $value, $filter); }
php
public function orWhereGreaterThanOrEquals($column, $value, $filter = false) { return $this->orWhere($column, '>=', $value, $filter); }
[ "public", "function", "orWhereGreaterThanOrEquals", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "orWhere", "(", "$", "column", ",", "'>='", ",", "$", "value", ",", "$", "filter", ")", ...
Appends OR WHERE with >= operator @param string $column @param string $value @param boolean $filter @return \Krystal\Db\Sql\Db
[ "Appends", "OR", "WHERE", "with", ">", "=", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1679-L1682
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.orWhereLessThanOrEquals
public function orWhereLessThanOrEquals($column, $value, $filter = false) { return $this->orWhere($column, '<=', $value, $filter); }
php
public function orWhereLessThanOrEquals($column, $value, $filter = false) { return $this->orWhere($column, '<=', $value, $filter); }
[ "public", "function", "orWhereLessThanOrEquals", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "orWhere", "(", "$", "column", ",", "'<='", ",", "$", "value", ",", "$", "filter", ")", "...
Appends OR WHERE with <= operator @param string $column @param string $value @param boolean $filter @return \Krystal\Db\Sql\Db
[ "Appends", "OR", "WHERE", "with", "<", "=", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1692-L1695
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.whereGreaterThan
public function whereGreaterThan($column, $value, $filter = false) { return $this->where($column, '>', $value, $filter); }
php
public function whereGreaterThan($column, $value, $filter = false) { return $this->where($column, '>', $value, $filter); }
[ "public", "function", "whereGreaterThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "where", "(", "$", "column", ",", "'>'", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ...
Appends WHERE clause with > operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "WHERE", "clause", "with", ">", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1744-L1747
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.andWhereGreaterThan
public function andWhereGreaterThan($column, $value, $filter = false) { return $this->andWhere($column, '>', $value, $filter); }
php
public function andWhereGreaterThan($column, $value, $filter = false) { return $this->andWhere($column, '>', $value, $filter); }
[ "public", "function", "andWhereGreaterThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "andWhere", "(", "$", "column", ",", "'>'", ",", "$", "value", ",", "$", "filter", ")", ";", ...
Appends AND WHERE clause with > operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "AND", "WHERE", "clause", "with", ">", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1757-L1760
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.andWhereLessThan
public function andWhereLessThan($column, $value, $filter = false) { return $this->andWhere($column, '<', $value, $filter); }
php
public function andWhereLessThan($column, $value, $filter = false) { return $this->andWhere($column, '<', $value, $filter); }
[ "public", "function", "andWhereLessThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "andWhere", "(", "$", "column", ",", "'<'", ",", "$", "value", ",", "$", "filter", ")", ";", "...
Appends AND WHERE clause with < operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "AND", "WHERE", "clause", "with", "<", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1770-L1773
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.whereLessThan
public function whereLessThan($column, $value, $filter = false) { return $this->where($column, '<', $value, $filter); }
php
public function whereLessThan($column, $value, $filter = false) { return $this->where($column, '<', $value, $filter); }
[ "public", "function", "whereLessThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "where", "(", "$", "column", ",", "'<'", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ]
Appends WHERE clause with < operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "WHERE", "clause", "with", "<", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1783-L1786
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.orWhereLessThan
public function orWhereLessThan($column, $value, $filter = false) { return $this->orWhere($column, '<', $value, $filter); }
php
public function orWhereLessThan($column, $value, $filter = false) { return $this->orWhere($column, '<', $value, $filter); }
[ "public", "function", "orWhereLessThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "orWhere", "(", "$", "column", ",", "'<'", ",", "$", "value", ",", "$", "filter", ")", ";", "}"...
Appends WHERE clause with "less than" operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "WHERE", "clause", "with", "less", "than", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1796-L1799
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.orWhereGreaterThan
public function orWhereGreaterThan($column, $value, $filter = false) { return $this->orWhere($column, '>', $value, $filter); }
php
public function orWhereGreaterThan($column, $value, $filter = false) { return $this->orWhere($column, '>', $value, $filter); }
[ "public", "function", "orWhereGreaterThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "orWhere", "(", "$", "column", ",", "'>'", ",", "$", "value", ",", "$", "filter", ")", ";", ...
Appends OR WHERE clause with "greater than" operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "OR", "WHERE", "clause", "with", "greater", "than", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1809-L1812
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.andWhereLike
public function andWhereLike($column, $value, $filter = false) { return $this->andWhere($column, 'LIKE', $value, $filter); }
php
public function andWhereLike($column, $value, $filter = false) { return $this->andWhere($column, 'LIKE', $value, $filter); }
[ "public", "function", "andWhereLike", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "andWhere", "(", "$", "column", ",", "'LIKE'", ",", "$", "value", ",", "$", "filter", ")", ";", "}...
Appends WHERE with "like" operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "WHERE", "with", "like", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1822-L1825
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.andWhereNotLike
public function andWhereNotLike($column, $value, $filter = false) { return $this->andWhere($column, 'NOT LIKE', $value, $filter); }
php
public function andWhereNotLike($column, $value, $filter = false) { return $this->andWhere($column, 'NOT LIKE', $value, $filter); }
[ "public", "function", "andWhereNotLike", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "andWhere", "(", "$", "column", ",", "'NOT LIKE'", ",", "$", "value", ",", "$", "filter", ")", ";...
Appends WHERE with "NOT LIKE" operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "WHERE", "with", "NOT", "LIKE", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1835-L1838
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.orWhereLike
public function orWhereLike($column, $value, $filter = false) { return $this->orWhere($column, 'LIKE', $value, $filter); }
php
public function orWhereLike($column, $value, $filter = false) { return $this->orWhere($column, 'LIKE', $value, $filter); }
[ "public", "function", "orWhereLike", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "orWhere", "(", "$", "column", ",", "'LIKE'", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ...
Appends OR WHERE LIKE condition @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "OR", "WHERE", "LIKE", "condition" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1848-L1851
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.orWhereNotLike
public function orWhereNotLike($column, $value, $filter = false) { return $this->orWhere($column, 'NOT LIKE', $value, $filter); }
php
public function orWhereNotLike($column, $value, $filter = false) { return $this->orWhere($column, 'NOT LIKE', $value, $filter); }
[ "public", "function", "orWhereNotLike", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "orWhere", "(", "$", "column", ",", "'NOT LIKE'", ",", "$", "value", ",", "$", "filter", ")", ";",...
Appends OR WHERE NOT LIKE condition @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "OR", "WHERE", "NOT", "LIKE", "condition" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1861-L1864
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.whereLike
public function whereLike($column, $value, $filter = false) { return $this->where($column, 'LIKE', $value, $filter); }
php
public function whereLike($column, $value, $filter = false) { return $this->where($column, 'LIKE', $value, $filter); }
[ "public", "function", "whereLike", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "where", "(", "$", "column", ",", "'LIKE'", ",", "$", "value", ",", "$", "filter", ")", ";", "}" ]
Appends WHERE LIKE condition @param string $column @param string $value @param boolean $filter Whether to rely on filter @return \Krystal\Db\Sql\Db
[ "Appends", "WHERE", "LIKE", "condition" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1874-L1877
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.andWhereEquals
public function andWhereEquals($column, $value, $filter = false) { return $this->andWhere($column, '=', $value, $filter); }
php
public function andWhereEquals($column, $value, $filter = false) { return $this->andWhere($column, '=', $value, $filter); }
[ "public", "function", "andWhereEquals", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "andWhere", "(", "$", "column", ",", "'='", ",", "$", "value", ",", "$", "filter", ")", ";", "}"...
Appends AND for where clause with equality operator @param string $column @param string $value @param boolean $filter Whether to filter by empty value @return \Krystal\Db\Sql\Db
[ "Appends", "AND", "for", "where", "clause", "with", "equality", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1887-L1890
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.andWhereNotEquals
public function andWhereNotEquals($column, $value, $filter = false) { return $this->andWhere($column, '!=', $value, $filter); }
php
public function andWhereNotEquals($column, $value, $filter = false) { return $this->andWhere($column, '!=', $value, $filter); }
[ "public", "function", "andWhereNotEquals", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "andWhere", "(", "$", "column", ",", "'!='", ",", "$", "value", ",", "$", "filter", ")", ";", ...
Appends AND WHERE clause with equality operator @param string $column @param string $value @param boolean $filter Whether to filter by value @return \Krystal\Db\Sql\Db
[ "Appends", "AND", "WHERE", "clause", "with", "equality", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1900-L1903
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.andWhereEqualsOrGreaterThan
public function andWhereEqualsOrGreaterThan($column, $value, $filter = false) { return $this->andWhere($column, '>=', $value, $filter); }
php
public function andWhereEqualsOrGreaterThan($column, $value, $filter = false) { return $this->andWhere($column, '>=', $value, $filter); }
[ "public", "function", "andWhereEqualsOrGreaterThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "andWhere", "(", "$", "column", ",", "'>='", ",", "$", "value", ",", "$", "filter", ")"...
Appends AND WHERE with >= operator @param string $column @param string $value @param boolean $filter @return \Krystal\Db\Sql\Db
[ "Appends", "AND", "WHERE", "with", ">", "=", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1913-L1916
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.andWhereEqualsOrLessThan
public function andWhereEqualsOrLessThan($column, $value, $filter = false) { return $this->andWhere($column, '<=', $value, $filter); }
php
public function andWhereEqualsOrLessThan($column, $value, $filter = false) { return $this->andWhere($column, '<=', $value, $filter); }
[ "public", "function", "andWhereEqualsOrLessThan", "(", "$", "column", ",", "$", "value", ",", "$", "filter", "=", "false", ")", "{", "return", "$", "this", "->", "andWhere", "(", "$", "column", ",", "'<='", ",", "$", "value", ",", "$", "filter", ")", ...
Appends AND WHERE with <= operator @param string $column @param string $value @param boolean $filter @return \Krystal\Db\Sql\Db
[ "Appends", "AND", "WHERE", "with", "<", "=", "operator" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L1926-L1929
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/Db.php
Db.dropTable
public function dropTable($table, $ifExists = true) { $this->queryBuilder->dropTable($table, $ifExists); return $this; }
php
public function dropTable($table, $ifExists = true) { $this->queryBuilder->dropTable($table, $ifExists); return $this; }
[ "public", "function", "dropTable", "(", "$", "table", ",", "$", "ifExists", "=", "true", ")", "{", "$", "this", "->", "queryBuilder", "->", "dropTable", "(", "$", "table", ",", "$", "ifExists", ")", ";", "return", "$", "this", ";", "}" ]
Appends DROP TABLE statement @param string $table Table name @param boolean $ifExists Whether to generate IF EXIST condition as well @return \Krystal\Db\Sql\Db
[ "Appends", "DROP", "TABLE", "statement" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Db.php#L2041-L2045
train
Firesphere/silverstripe-newsmodule
code/forms/CommentForm.php
CommentForm.CommentStore
public function CommentStore($data, $form) { /** * If the "Extra" field is filled, we have a bot. * Also, the nsas (<noscript> Anti Spam) is a bot. Bot's don't use javascript. * Note, a legitimate visitor that has JS disabled, will be unable to post! */ if (!isset($data['Extra']) || $data['Extra'] == '' || isset($data['nsas'])) { $data['Comment'] = Convert::raw2sql($data['Comment']); $exists = Comment::get() ->filter(array('Comment:PartialMatch' => $data['Comment'])) ->where('ABS(TIMEDIFF(NOW(), Created)) < 60'); if (!$exists->count()) { $comment = Comment::create(); $form->saveInto($comment); $comment->NewsID = $data['NewsID']; $comment->write(); } } Controller::curr()->redirectBack(); }
php
public function CommentStore($data, $form) { /** * If the "Extra" field is filled, we have a bot. * Also, the nsas (<noscript> Anti Spam) is a bot. Bot's don't use javascript. * Note, a legitimate visitor that has JS disabled, will be unable to post! */ if (!isset($data['Extra']) || $data['Extra'] == '' || isset($data['nsas'])) { $data['Comment'] = Convert::raw2sql($data['Comment']); $exists = Comment::get() ->filter(array('Comment:PartialMatch' => $data['Comment'])) ->where('ABS(TIMEDIFF(NOW(), Created)) < 60'); if (!$exists->count()) { $comment = Comment::create(); $form->saveInto($comment); $comment->NewsID = $data['NewsID']; $comment->write(); } } Controller::curr()->redirectBack(); }
[ "public", "function", "CommentStore", "(", "$", "data", ",", "$", "form", ")", "{", "/**\n * If the \"Extra\" field is filled, we have a bot.\n * Also, the nsas (<noscript> Anti Spam) is a bot. Bot's don't use javascript.\n * Note, a legitimate visitor that has JS disab...
Store it. And also check if it's no double-post. Limited to 60 seconds, but it can be differed. I wonder if this is XSS safe? The saveInto does this for me, right? @param array $data Posted data as array @param Form $form FormObject containing the entire Form as an Object.
[ "Store", "it", ".", "And", "also", "check", "if", "it", "s", "no", "double", "-", "post", ".", "Limited", "to", "60", "seconds", "but", "it", "can", "be", "differed", ".", "I", "wonder", "if", "this", "is", "XSS", "safe?", "The", "saveInto", "does", ...
98c501bf940878ed9c044124409b85a3e3c4265c
https://github.com/Firesphere/silverstripe-newsmodule/blob/98c501bf940878ed9c044124409b85a3e3c4265c/code/forms/CommentForm.php#L59-L79
train
luismanuelamengual/NeoPHP
src/NeoPHP/Exceptions/Exceptions.php
Exceptions.flattenArgument
private static function flattenArgument (&$value, $key) { if ($value instanceof Closure) { $closureReflection = new ReflectionFunction($value); $value = sprintf('(Closure at %s:%s)', $closureReflection->getFileName(), $closureReflection->getStartLine()); } elseif (is_object($value)) { $value = sprintf('object(%s)', get_class($value)); } elseif (is_resource($value)) { $value = sprintf('resource(%s)', get_resource_type($value)); } }
php
private static function flattenArgument (&$value, $key) { if ($value instanceof Closure) { $closureReflection = new ReflectionFunction($value); $value = sprintf('(Closure at %s:%s)', $closureReflection->getFileName(), $closureReflection->getStartLine()); } elseif (is_object($value)) { $value = sprintf('object(%s)', get_class($value)); } elseif (is_resource($value)) { $value = sprintf('resource(%s)', get_resource_type($value)); } }
[ "private", "static", "function", "flattenArgument", "(", "&", "$", "value", ",", "$", "key", ")", "{", "if", "(", "$", "value", "instanceof", "Closure", ")", "{", "$", "closureReflection", "=", "new", "ReflectionFunction", "(", "$", "value", ")", ";", "$...
Limpia de Clousures un argumento para que pueda ser serializable @param mixed $value Valor del argumento @param mixed $key Llave del argumento @throws ReflectionException
[ "Limpia", "de", "Clousures", "un", "argumento", "para", "que", "pueda", "ser", "serializable" ]
da7c5831974b37dd4b0b170d9aa64e61404d819b
https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Exceptions/Exceptions.php#L36-L45
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.dynamic
public static function dynamic($type, $name, $value, array $attributes = array(), $extra = array()) { switch ($type) { case 'text': return self::text($name, $value, $attributes); case 'password': return self::password($name, $value, $attributes); case 'url': return self::url($name, $value, $attributes); case 'range': return self::range($name, $value, $attributes); case 'number': return self::number($name, $value, $attributes); case 'hidden': return self::hidden($name, $value, $attributes); case 'date': return self::date($name, $value, $attributes); case 'time': return self::time($name, $value, $attributes); case 'color': return self::color($name, $value, $attributes); case 'textarea': return self::textarea($name, $value, $attributes); case 'radio': return self::radio($name, $value, (bool) $value, $attributes); case 'checkbox': return self::checkbox($name, $value, $attributes, false); case 'select': return self::select($name, $extra, $value, $attributes); default: throw new UnexpectedValueException(sprintf('Unexpected value supplied %s', $type)); } }
php
public static function dynamic($type, $name, $value, array $attributes = array(), $extra = array()) { switch ($type) { case 'text': return self::text($name, $value, $attributes); case 'password': return self::password($name, $value, $attributes); case 'url': return self::url($name, $value, $attributes); case 'range': return self::range($name, $value, $attributes); case 'number': return self::number($name, $value, $attributes); case 'hidden': return self::hidden($name, $value, $attributes); case 'date': return self::date($name, $value, $attributes); case 'time': return self::time($name, $value, $attributes); case 'color': return self::color($name, $value, $attributes); case 'textarea': return self::textarea($name, $value, $attributes); case 'radio': return self::radio($name, $value, (bool) $value, $attributes); case 'checkbox': return self::checkbox($name, $value, $attributes, false); case 'select': return self::select($name, $extra, $value, $attributes); default: throw new UnexpectedValueException(sprintf('Unexpected value supplied %s', $type)); } }
[ "public", "static", "function", "dynamic", "(", "$", "type", ",", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "extra", "=", "array", "(", ")", ")", "{", "switch", "(", "$", "type", ")", "{", ...
Creates dynamic input element @param string $type Input type @param string $name @param string $value @param array $attributes Input attributes @param array $extra Select option elements, in case 'select' is supplied as a type @throws \UnexpectedValueException If unknown type supplied @return string
[ "Creates", "dynamic", "input", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L31-L63
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.icon
public static function icon($icon, $link, array $attributes = array()) { // Inner text $text = sprintf('<i class="%s"></i> ', $icon); return self::link($text, $link, $attributes); }
php
public static function icon($icon, $link, array $attributes = array()) { // Inner text $text = sprintf('<i class="%s"></i> ', $icon); return self::link($text, $link, $attributes); }
[ "public", "static", "function", "icon", "(", "$", "icon", ",", "$", "link", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "// Inner text", "$", "text", "=", "sprintf", "(", "'<i class=\"%s\"></i> '", ",", "$", "icon", ")", ";", "re...
Creates a link with inner icon @param string $icon @param string $link @param array $attributes Extra attributes @return string
[ "Creates", "a", "link", "with", "inner", "icon" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L73-L79
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.link
public static function link($text, $link = '#', array $attributes = array()) { if (!is_null($link)) { $attributes['href'] = $link; } $node = new Node\Link($text); return $node->render($attributes); }
php
public static function link($text, $link = '#', array $attributes = array()) { if (!is_null($link)) { $attributes['href'] = $link; } $node = new Node\Link($text); return $node->render($attributes); }
[ "public", "static", "function", "link", "(", "$", "text", ",", "$", "link", "=", "'#'", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "link", ")", ")", "{", "$", "attributes", "[", "'href'...
Creates link element @param string $text @param string $link @param array $attributes Extra attributes @return string
[ "Creates", "link", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L89-L97
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.option
public static function option($value, $text, array $attributes = array()) { if (!is_null($value)) { $attributes['value'] = $value; } $node = new Node\Option($text); return $node->render($attributes); }
php
public static function option($value, $text, array $attributes = array()) { if (!is_null($value)) { $attributes['value'] = $value; } $node = new Node\Option($text); return $node->render($attributes); }
[ "public", "static", "function", "option", "(", "$", "value", ",", "$", "text", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "attributes", "[", "'value'", "]", ...
Creates standalone "option" element @param string $value @param string $text @param array $attributes Extra attributes @return string
[ "Creates", "standalone", "option", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L125-L133
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.button
public static function button($text, array $attributes = array()) { $node = new Node\Button($text); return $node->render($attributes); }
php
public static function button($text, array $attributes = array()) { $node = new Node\Button($text); return $node->render($attributes); }
[ "public", "static", "function", "button", "(", "$", "text", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "node", "=", "new", "Node", "\\", "Button", "(", "$", "text", ")", ";", "return", "$", "node", "->", "render", "(", ...
Creates button element @param string $text @param array $attributes Extra attributes @return string
[ "Creates", "button", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L168-L172
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.radio
public static function radio($name, $value, $checked, array $attributes = array()) { if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } $node = new Node\Radio($checked); return $node->render($attributes); }
php
public static function radio($name, $value, $checked, array $attributes = array()) { if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } $node = new Node\Radio($checked); return $node->render($attributes); }
[ "public", "static", "function", "radio", "(", "$", "name", ",", "$", "value", ",", "$", "checked", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "attributes", "...
Creates "Radio" node element @param string $name Element name @param string $name Element value @param boolean $checked Whether it should be checked or not @param array $attributes Extra attributes @return string
[ "Creates", "Radio", "node", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L183-L195
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.checkbox
public static function checkbox($name, $checked, array $attributes = array(), $serialize = true) { if ($name !== null) { $attributes['name'] = $name; } $node = new Node\Checkbox($serialize, $checked); return $node->render($attributes); }
php
public static function checkbox($name, $checked, array $attributes = array(), $serialize = true) { if ($name !== null) { $attributes['name'] = $name; } $node = new Node\Checkbox($serialize, $checked); return $node->render($attributes); }
[ "public", "static", "function", "checkbox", "(", "$", "name", ",", "$", "checked", ",", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "serialize", "=", "true", ")", "{", "if", "(", "$", "name", "!==", "null", ")", "{", "$", "attribu...
Creates "Checkbox" node element @param string $name Element name @param boolean $checked Whether it should be checked or not @param array $attributes Extra attributes @param boolean $serialize Whether the element should be serializeable or not @return string
[ "Creates", "Checkbox", "node", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L206-L214
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.file
public static function file($name, $accept = null, array $attributes = array()) { if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($accept)) { $attributes['accept'] = $accept; } $node = new Node\File(); return $node->render($attributes); }
php
public static function file($name, $accept = null, array $attributes = array()) { if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($accept)) { $attributes['accept'] = $accept; } $node = new Node\File(); return $node->render($attributes); }
[ "public", "static", "function", "file", "(", "$", "name", ",", "$", "accept", "=", "null", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "attributes", "[", "'na...
Creates "File" node element @param string $name @param string $accept What type of files the input should accept @param array $attributes Extra attributes @return string
[ "Creates", "File", "node", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L224-L236
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.select
public static function select($name, array $list = array(), $selected, array $attributes = array(), $prompt = false, Closure $optionVisitor = null) { if ($prompt !== false) { // Merge keeping indexes $list = array('' => $prompt) + $list; } $node = new Node\Select($list, $selected, array(), $optionVisitor); if ($name !== null) { $attributes['name'] = $name; } return $node->render($attributes); }
php
public static function select($name, array $list = array(), $selected, array $attributes = array(), $prompt = false, Closure $optionVisitor = null) { if ($prompt !== false) { // Merge keeping indexes $list = array('' => $prompt) + $list; } $node = new Node\Select($list, $selected, array(), $optionVisitor); if ($name !== null) { $attributes['name'] = $name; } return $node->render($attributes); }
[ "public", "static", "function", "select", "(", "$", "name", ",", "array", "$", "list", "=", "array", "(", ")", ",", "$", "selected", ",", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "prompt", "=", "false", ",", "Closure", "$", "op...
Creates "Select" element with its child "Option" nodes @param string $name @param array $list @param string|array $select Select child option @param array $attributes Extra attributes @param string|boolean $prompt Optional prompt text @param \Closure $optionVisitor Optional visitor to build attributes of option tag @return string
[ "Creates", "Select", "element", "with", "its", "child", "Option", "nodes" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L249-L263
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.textarea
public static function textarea($name, $text, array $attributes = array()) { if ($name !== null) { $attributes['name'] = $name; } $node = new Node\Textarea($text); return $node->render($attributes); }
php
public static function textarea($name, $text, array $attributes = array()) { if ($name !== null) { $attributes['name'] = $name; } $node = new Node\Textarea($text); return $node->render($attributes); }
[ "public", "static", "function", "textarea", "(", "$", "name", ",", "$", "text", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "$", "name", "!==", "null", ")", "{", "$", "attributes", "[", "'name'", "]", "=", "$", "...
Creates textarea element @param string $name Element name @param string $text Text to be supplied between tags @param array $attributes Extra attributes @return string
[ "Creates", "textarea", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L273-L281
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.text
public static function text($name, $value, array $attributes = array()) { $node = new Node\Text(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
public static function text($name, $value, array $attributes = array()) { $node = new Node\Text(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
[ "public", "static", "function", "text", "(", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "node", "=", "new", "Node", "\\", "Text", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "...
Creates text input element @param string $name Element name @param string $value Element value @param array $attributes Extra attributes @return string
[ "Creates", "text", "input", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L291-L304
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.color
public static function color($name, $value, array $attributes = array()) { $node = new Node\Color(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
public static function color($name, $value, array $attributes = array()) { $node = new Node\Color(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
[ "public", "static", "function", "color", "(", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "node", "=", "new", "Node", "\\", "Color", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", ...
Creates color input element @param string $name Element name @param string $value Element value @param array $attributes Extra attributes @return string
[ "Creates", "color", "input", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L314-L327
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.email
public static function email($name, $value, array $attributes = array()) { $node = new Node\Email(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
public static function email($name, $value, array $attributes = array()) { $node = new Node\Email(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
[ "public", "static", "function", "email", "(", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "node", "=", "new", "Node", "\\", "Email", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", ...
Creates email input element @param string $name Element name @param string $value Element value @param array $attributes Extra attributes @return string
[ "Creates", "email", "input", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L383-L396
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.hidden
public static function hidden($name, $value, array $attributes = array()) { $node = new Node\Hidden(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
public static function hidden($name, $value, array $attributes = array()) { $node = new Node\Hidden(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
[ "public", "static", "function", "hidden", "(", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "node", "=", "new", "Node", "\\", "Hidden", "(", ")", ";", "if", "(", "!", "is_null", "(", "$",...
Creates hidden input element @param string $name Element name @param string $value Element value @param array $attributes Extra attributes @return string
[ "Creates", "hidden", "input", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L406-L419
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.number
public static function number($name, $value, array $attributes = array()) { $node = new Node\Number(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
public static function number($name, $value, array $attributes = array()) { $node = new Node\Number(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
[ "public", "static", "function", "number", "(", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "node", "=", "new", "Node", "\\", "Number", "(", ")", ";", "if", "(", "!", "is_null", "(", "$",...
Creates number input element @param string $name Element name @param string $value Element value @param array $attributes Extra attributes @return string
[ "Creates", "number", "input", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L429-L442
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.range
public static function range($name, $value, array $attributes = array()) { $node = new Node\Range(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
public static function range($name, $value, array $attributes = array()) { $node = new Node\Range(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
[ "public", "static", "function", "range", "(", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "node", "=", "new", "Node", "\\", "Range", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", ...
Creates range input element @param string $name Element name @param string $value Element value @param array $attributes Extra attributes @return string
[ "Creates", "range", "input", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L452-L465
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.url
public static function url($name, $value, array $attributes = array()) { $node = new Node\Url(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
public static function url($name, $value, array $attributes = array()) { $node = new Node\Url(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
[ "public", "static", "function", "url", "(", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "node", "=", "new", "Node", "\\", "Url", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "na...
Creates URL input element @param string $name Element name @param string $value Element value @param array $attributes Extra attributes @return string
[ "Creates", "URL", "input", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L475-L488
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.password
public static function password($name, $value, array $attributes = array()) { $node = new Node\Password(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
public static function password($name, $value, array $attributes = array()) { $node = new Node\Password(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
[ "public", "static", "function", "password", "(", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "node", "=", "new", "Node", "\\", "Password", "(", ")", ";", "if", "(", "!", "is_null", "(", ...
Creates password input element @param string $name Element name @param string $value Element value @param array $attributes Extra attributes @return string
[ "Creates", "password", "input", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L498-L511
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.object
public static function object($width, $height, $data) { $node = new Node\Object(); $attributes = array( 'width' => $width, 'height' => $height, 'data' => $data ); return $node->render($attributes); }
php
public static function object($width, $height, $data) { $node = new Node\Object(); $attributes = array( 'width' => $width, 'height' => $height, 'data' => $data ); return $node->render($attributes); }
[ "public", "static", "function", "object", "(", "$", "width", ",", "$", "height", ",", "$", "data", ")", "{", "$", "node", "=", "new", "Node", "\\", "Object", "(", ")", ";", "$", "attributes", "=", "array", "(", "'width'", "=>", "$", "width", ",", ...
Renders object element @param int $width @param int $height @param string $data @return string
[ "Renders", "object", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L521-L532
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.audio
public static function audio($src, array $attrs = array(), $error = null) { $node = new Node\Audio($src, $error); return $node->render($attrs); }
php
public static function audio($src, array $attrs = array(), $error = null) { $node = new Node\Audio($src, $error); return $node->render($attrs); }
[ "public", "static", "function", "audio", "(", "$", "src", ",", "array", "$", "attrs", "=", "array", "(", ")", ",", "$", "error", "=", "null", ")", "{", "$", "node", "=", "new", "Node", "\\", "Audio", "(", "$", "src", ",", "$", "error", ")", ";"...
Renders audio element @param array|string $src @param array $attrs @param string $error Error message can be overriden on demand @return string
[ "Renders", "audio", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L542-L547
train
krystal-framework/krystal.framework
src/Krystal/Form/Element.php
Element.video
public static function video($src, array $attrs = array(), $error = null) { $node = new Node\Video($src, $error); return $node->render($attrs); }
php
public static function video($src, array $attrs = array(), $error = null) { $node = new Node\Video($src, $error); return $node->render($attrs); }
[ "public", "static", "function", "video", "(", "$", "src", ",", "array", "$", "attrs", "=", "array", "(", ")", ",", "$", "error", "=", "null", ")", "{", "$", "node", "=", "new", "Node", "\\", "Video", "(", "$", "src", ",", "$", "error", ")", ";"...
Renders video element @param array|string $src @param array $attrs Available attributes - boolean $autoplay Whether autoplay is required - boolean $loop Specifies that the video will start over again, every time it is finished - boolean $muted Specifies that the audio output of the video should be muted - int $width Optional width - int $height Optional height - string $poster Specifies an image to be shown while the video is downloading, or until the user hits the play button @param string $error Error message @return string
[ "Renders", "video", "element" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element.php#L566-L571
train
spiral/odm
source/Spiral/ODM/DocumentEntity.php
DocumentEntity.publicValue
public function publicValue(): array { $public = parent::publicValue(); array_walk_recursive($public, function (&$value) { if ($value instanceof ObjectID) { $value = (string)$value; } }); return $public; }
php
public function publicValue(): array { $public = parent::publicValue(); array_walk_recursive($public, function (&$value) { if ($value instanceof ObjectID) { $value = (string)$value; } }); return $public; }
[ "public", "function", "publicValue", "(", ")", ":", "array", "{", "$", "public", "=", "parent", "::", "publicValue", "(", ")", ";", "array_walk_recursive", "(", "$", "public", ",", "function", "(", "&", "$", "value", ")", "{", "if", "(", "$", "value", ...
Since most of ODM documents might contain ObjectIDs and other fields we will try to normalize them into string values. @return array
[ "Since", "most", "of", "ODM", "documents", "might", "contain", "ObjectIDs", "and", "other", "fields", "we", "will", "try", "to", "normalize", "them", "into", "string", "values", "." ]
06087691a05dcfaa86c6c461660c6029db4de06e
https://github.com/spiral/odm/blob/06087691a05dcfaa86c6c461660c6029db4de06e/source/Spiral/ODM/DocumentEntity.php#L363-L374
train
droath/project-x
src/TaskCommonTrait.php
TaskCommonTrait.runSilentCommand
protected function runSilentCommand(TaskInterface $task) { return $task->printOutput(false) // This is weird as you would expect this to give you more // information, but it suppresses the exit code from display. ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_DEBUG) ->run(); }
php
protected function runSilentCommand(TaskInterface $task) { return $task->printOutput(false) // This is weird as you would expect this to give you more // information, but it suppresses the exit code from display. ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_DEBUG) ->run(); }
[ "protected", "function", "runSilentCommand", "(", "TaskInterface", "$", "task", ")", "{", "return", "$", "task", "->", "printOutput", "(", "false", ")", "// This is weird as you would expect this to give you more", "// information, but it suppresses the exit code from display.", ...
Run silent command.
[ "Run", "silent", "command", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/TaskCommonTrait.php#L16-L23
train
krystal-framework/krystal.framework
src/Krystal/Form/Element/Select.php
Select.createDefaultOptionNodes
private function createDefaultOptionNodes() { $nodes = array(); foreach ($this->defaults as $key => $value) { // Only scalars are allowed, the rest is ignored if (is_scalar($value)) { array_push($nodes, $this->createOptionNode($key, $value)); } } return $nodes; }
php
private function createDefaultOptionNodes() { $nodes = array(); foreach ($this->defaults as $key => $value) { // Only scalars are allowed, the rest is ignored if (is_scalar($value)) { array_push($nodes, $this->createOptionNode($key, $value)); } } return $nodes; }
[ "private", "function", "createDefaultOptionNodes", "(", ")", "{", "$", "nodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "defaults", "as", "$", "key", "=>", "$", "value", ")", "{", "// Only scalars are allowed, the rest is ignored", "if"...
Creates default option node @return \Krystal\Form\NodeElement
[ "Creates", "default", "option", "node" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element/Select.php#L70-L82
train
krystal-framework/krystal.framework
src/Krystal/Form/Element/Select.php
Select.isActiveNode
private function isActiveNode($value) { if (is_array($this->active)) { $actives = array_values($this->active); return in_array($value, $actives); } else { // Select all if asterik is provided if ($this->active === '*') { return true; } // Without type-casting it's error-prone return (string) $this->active == (string) $value; } }
php
private function isActiveNode($value) { if (is_array($this->active)) { $actives = array_values($this->active); return in_array($value, $actives); } else { // Select all if asterik is provided if ($this->active === '*') { return true; } // Without type-casting it's error-prone return (string) $this->active == (string) $value; } }
[ "private", "function", "isActiveNode", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "active", ")", ")", "{", "$", "actives", "=", "array_values", "(", "$", "this", "->", "active", ")", ";", "return", "in_array", "(", "$...
Determines whether node is active @param string $value @return boolean
[ "Determines", "whether", "node", "is", "active" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element/Select.php#L90-L104
train
krystal-framework/krystal.framework
src/Krystal/Form/Element/Select.php
Select.createOptionNode
private function createOptionNode($value, $text) { $option = new NodeElement(); $option->openTag('option') ->addAttribute('value', $value); // Mark as selected on demand if ($this->isActiveNode($value)) { $option->addProperty('selected'); } // If callback is provided, then use it to build attributes if ($this->optionVisitor instanceof Closure) { $result = call_user_func($this->optionVisitor, $value, $text); // Visitor must return an array containing these keys if (is_array($result)) { $option->addAttributes($result); } else { // Incorrect returned value throw new UnexpectedValueException( sprintf('The visitor must return associative array with attribute names and their corresponding values. Received - "%s"', gettype($result)) ); } } $option->finalize() ->setText($text) ->closeTag(); return $option; }
php
private function createOptionNode($value, $text) { $option = new NodeElement(); $option->openTag('option') ->addAttribute('value', $value); // Mark as selected on demand if ($this->isActiveNode($value)) { $option->addProperty('selected'); } // If callback is provided, then use it to build attributes if ($this->optionVisitor instanceof Closure) { $result = call_user_func($this->optionVisitor, $value, $text); // Visitor must return an array containing these keys if (is_array($result)) { $option->addAttributes($result); } else { // Incorrect returned value throw new UnexpectedValueException( sprintf('The visitor must return associative array with attribute names and their corresponding values. Received - "%s"', gettype($result)) ); } } $option->finalize() ->setText($text) ->closeTag(); return $option; }
[ "private", "function", "createOptionNode", "(", "$", "value", ",", "$", "text", ")", "{", "$", "option", "=", "new", "NodeElement", "(", ")", ";", "$", "option", "->", "openTag", "(", "'option'", ")", "->", "addAttribute", "(", "'value'", ",", "$", "va...
Creates option node @param string $value @param string $text @throws \UnexpectedValueException If visitor is not returning an associative array @return \Krystal\Form\NodeElement
[ "Creates", "option", "node" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element/Select.php#L114-L145
train
krystal-framework/krystal.framework
src/Krystal/Form/Element/Select.php
Select.createOptgroupNode
private function createOptgroupNode($label, array $list) { $optgroup = new NodeElement(); $optgroup->openTag('optgroup') ->addAttribute('label', $label) ->finalize(); foreach ($this->getOptions($list) as $option) { $optgroup->appendChild($option); } $optgroup->closeTag(); return $optgroup; }
php
private function createOptgroupNode($label, array $list) { $optgroup = new NodeElement(); $optgroup->openTag('optgroup') ->addAttribute('label', $label) ->finalize(); foreach ($this->getOptions($list) as $option) { $optgroup->appendChild($option); } $optgroup->closeTag(); return $optgroup; }
[ "private", "function", "createOptgroupNode", "(", "$", "label", ",", "array", "$", "list", ")", "{", "$", "optgroup", "=", "new", "NodeElement", "(", ")", ";", "$", "optgroup", "->", "openTag", "(", "'optgroup'", ")", "->", "addAttribute", "(", "'label'", ...
Creates optgroup node with nested options @param string $label @param array $list @return \Krystal\Form\NodeElement
[ "Creates", "optgroup", "node", "with", "nested", "options" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element/Select.php#L154-L168
train
krystal-framework/krystal.framework
src/Krystal/Form/Element/Select.php
Select.getOptions
private function getOptions(array $list) { // To be returned $elements = array(); foreach ($list as $value => $text) { array_push($elements, $this->createOptionNode($value, $text)); } return $elements; }
php
private function getOptions(array $list) { // To be returned $elements = array(); foreach ($list as $value => $text) { array_push($elements, $this->createOptionNode($value, $text)); } return $elements; }
[ "private", "function", "getOptions", "(", "array", "$", "list", ")", "{", "// To be returned", "$", "elements", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "value", "=>", "$", "text", ")", "{", "array_push", "(", "$", "elements...
Returns a collection of prepared option elements @param array $list @return array
[ "Returns", "a", "collection", "of", "prepared", "option", "elements" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element/Select.php#L176-L186
train
fxpio/fxp-bootstrap
Block/DataSource/DataSource.php
DataSource.formatIndex
protected function formatIndex($name) { if (\is_string($name)) { $exp = explode('.', $name); if (0 < \count($exp)) { $name = $exp[\count($exp) - 1]; } } return $name; }
php
protected function formatIndex($name) { if (\is_string($name)) { $exp = explode('.', $name); if (0 < \count($exp)) { $name = $exp[\count($exp) - 1]; } } return $name; }
[ "protected", "function", "formatIndex", "(", "$", "name", ")", "{", "if", "(", "\\", "is_string", "(", "$", "name", ")", ")", "{", "$", "exp", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "if", "(", "0", "<", "\\", "count", "(", "$",...
Format the index without prefix with dot. @param string $name The index @return string
[ "Format", "the", "index", "without", "prefix", "with", "dot", "." ]
4ff1408018c71d18b6951b1f8d7c5ad0b684eadb
https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSource.php#L410-L421
train
fxpio/fxp-bootstrap
Block/DataSource/DataSource.php
DataSource.getDataField
protected function getDataField($dataRow, $name, \Closure $emptyData = null) { $value = null !== $name && '' !== $name ? $this->propertyAccessor->getValue($dataRow, $name) : null; if (null === $value && $emptyData instanceof \Closure) { $value = $emptyData($dataRow, $name); } return $value; }
php
protected function getDataField($dataRow, $name, \Closure $emptyData = null) { $value = null !== $name && '' !== $name ? $this->propertyAccessor->getValue($dataRow, $name) : null; if (null === $value && $emptyData instanceof \Closure) { $value = $emptyData($dataRow, $name); } return $value; }
[ "protected", "function", "getDataField", "(", "$", "dataRow", ",", "$", "name", ",", "\\", "Closure", "$", "emptyData", "=", "null", ")", "{", "$", "value", "=", "null", "!==", "$", "name", "&&", "''", "!==", "$", "name", "?", "$", "this", "->", "p...
Get the field value of data row. @param array|object $dataRow @param string $name @param \Closure|null $emptyData @return mixed|null
[ "Get", "the", "field", "value", "of", "data", "row", "." ]
4ff1408018c71d18b6951b1f8d7c5ad0b684eadb
https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSource.php#L432-L443
train
fxpio/fxp-bootstrap
Block/DataSource/DataSource.php
DataSource.overrideCellOptions
protected function overrideCellOptions(BlockInterface $column, $formatter, $data, array $options) { $config = $column->getConfig(); if ($config->hasOption('override_options') && ($override = $config->getOption('override_options')) instanceof \Closure) { /* @var \Closure $override */ $options = $override($options, $data, $formatter); } return $options; }
php
protected function overrideCellOptions(BlockInterface $column, $formatter, $data, array $options) { $config = $column->getConfig(); if ($config->hasOption('override_options') && ($override = $config->getOption('override_options')) instanceof \Closure) { /* @var \Closure $override */ $options = $override($options, $data, $formatter); } return $options; }
[ "protected", "function", "overrideCellOptions", "(", "BlockInterface", "$", "column", ",", "$", "formatter", ",", "$", "data", ",", "array", "$", "options", ")", "{", "$", "config", "=", "$", "column", "->", "getConfig", "(", ")", ";", "if", "(", "$", ...
Override the formatter options. @param BlockInterface $column The block of column @param string $formatter The formatter class name @param mixed $data The data of record @param array $options The options of formatter @return array The options overloaded
[ "Override", "the", "formatter", "options", "." ]
4ff1408018c71d18b6951b1f8d7c5ad0b684eadb
https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSource.php#L550-L561
train
fxpio/fxp-bootstrap
Block/DataSource/DataSource.php
DataSource.doPreGetData
protected function doPreGetData() { foreach ($this->dataTransformers as $dataTransformer) { if ($dataTransformer instanceof PreGetDataTransformerInterface) { $dataTransformer->preGetData($this->config); } } }
php
protected function doPreGetData() { foreach ($this->dataTransformers as $dataTransformer) { if ($dataTransformer instanceof PreGetDataTransformerInterface) { $dataTransformer->preGetData($this->config); } } }
[ "protected", "function", "doPreGetData", "(", ")", "{", "foreach", "(", "$", "this", "->", "dataTransformers", "as", "$", "dataTransformer", ")", "{", "if", "(", "$", "dataTransformer", "instanceof", "PreGetDataTransformerInterface", ")", "{", "$", "dataTransforme...
Action before getting the data.
[ "Action", "before", "getting", "the", "data", "." ]
4ff1408018c71d18b6951b1f8d7c5ad0b684eadb
https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSource.php#L566-L573
train
fxpio/fxp-bootstrap
Block/DataSource/DataSource.php
DataSource.doPostGetData
protected function doPostGetData() { foreach ($this->dataTransformers as $dataTransformer) { if ($dataTransformer instanceof PostGetDataTransformerInterface) { $dataTransformer->postGetData($this->config); } } }
php
protected function doPostGetData() { foreach ($this->dataTransformers as $dataTransformer) { if ($dataTransformer instanceof PostGetDataTransformerInterface) { $dataTransformer->postGetData($this->config); } } }
[ "protected", "function", "doPostGetData", "(", ")", "{", "foreach", "(", "$", "this", "->", "dataTransformers", "as", "$", "dataTransformer", ")", "{", "if", "(", "$", "dataTransformer", "instanceof", "PostGetDataTransformerInterface", ")", "{", "$", "dataTransfor...
Action after getting the data.
[ "Action", "after", "getting", "the", "data", "." ]
4ff1408018c71d18b6951b1f8d7c5ad0b684eadb
https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSource.php#L578-L585
train
aphiria/serialization
src/Encoding/DefaultEncoderRegistrant.php
DefaultEncoderRegistrant.registerDefaultEncoders
public function registerDefaultEncoders(EncoderRegistry $encoders): EncoderRegistry { $encoders->registerDefaultObjectEncoder(new ObjectEncoder($encoders, $this->propertyNameFormatter)); $encoders->registerDefaultScalarEncoder(new ScalarEncoder()); $encoders->registerEncoder('array', new ArrayEncoder($encoders)); $dateTimeEncoder = new DateTimeEncoder($this->dateTimeFormat); $encoders->registerEncoder(DateTime::class, $dateTimeEncoder); $encoders->registerEncoder(DateTimeImmutable::class, $dateTimeEncoder); $encoders->registerEncoder(DateTimeInterface::class, $dateTimeEncoder); return $encoders; }
php
public function registerDefaultEncoders(EncoderRegistry $encoders): EncoderRegistry { $encoders->registerDefaultObjectEncoder(new ObjectEncoder($encoders, $this->propertyNameFormatter)); $encoders->registerDefaultScalarEncoder(new ScalarEncoder()); $encoders->registerEncoder('array', new ArrayEncoder($encoders)); $dateTimeEncoder = new DateTimeEncoder($this->dateTimeFormat); $encoders->registerEncoder(DateTime::class, $dateTimeEncoder); $encoders->registerEncoder(DateTimeImmutable::class, $dateTimeEncoder); $encoders->registerEncoder(DateTimeInterface::class, $dateTimeEncoder); return $encoders; }
[ "public", "function", "registerDefaultEncoders", "(", "EncoderRegistry", "$", "encoders", ")", ":", "EncoderRegistry", "{", "$", "encoders", "->", "registerDefaultObjectEncoder", "(", "new", "ObjectEncoder", "(", "$", "encoders", ",", "$", "this", "->", "propertyNam...
Registers the default encoders @param EncoderRegistry $encoders The encoders to register to @return EncoderRegistry The registry with the default encoders registered
[ "Registers", "the", "default", "encoders" ]
ae9144ce24a810f1c546421b18829f80826c70e0
https://github.com/aphiria/serialization/blob/ae9144ce24a810f1c546421b18829f80826c70e0/src/Encoding/DefaultEncoderRegistrant.php#L47-L58
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.exportDrupalConfig
public function exportDrupalConfig() { $version = $this->getProjectVersion(); if ($version >= 8) { $this->runDrushCommand('cex'); $this->saveDrupalUuid(); } return $this; }
php
public function exportDrupalConfig() { $version = $this->getProjectVersion(); if ($version >= 8) { $this->runDrushCommand('cex'); $this->saveDrupalUuid(); } return $this; }
[ "public", "function", "exportDrupalConfig", "(", ")", "{", "$", "version", "=", "$", "this", "->", "getProjectVersion", "(", ")", ";", "if", "(", "$", "version", ">=", "8", ")", "{", "$", "this", "->", "runDrushCommand", "(", "'cex'", ")", ";", "$", ...
Export Drupal configuration. @return self
[ "Export", "Drupal", "configuration", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L261-L271
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.importDrupalConfig
public function importDrupalConfig($reimport_attempts = 1, $localhost = false) { if ($this->getProjectVersion() >= 8) { try { $drush = (new DrushCommand(null, $localhost)) ->command('cr') ->command('cim'); $this->runDrushCommand($drush, false, $localhost); } catch (TaskResultRuntimeException $exception) { if ($reimport_attempts < 1) { throw $exception; } $errors = 0; $result = null; // Attempt to resolve import issues by reimporting the // configurations again. This workaround was added due to // the following issue: // @see https://www.drupal.org/project/drupal/issues/2923899 for ($i = 0; $i < $reimport_attempts; $i++) { $result = $this->runDrushCommand('cim', false, $localhost); if ($result->getExitCode() === ResultData::EXITCODE_OK) { break; } ++$errors; } if (!isset($result)) { throw new \Exception('Missing result object.'); } else if ($errors == $reimport_attempts) { throw new TaskResultRuntimeException($result); } } } return $this; }
php
public function importDrupalConfig($reimport_attempts = 1, $localhost = false) { if ($this->getProjectVersion() >= 8) { try { $drush = (new DrushCommand(null, $localhost)) ->command('cr') ->command('cim'); $this->runDrushCommand($drush, false, $localhost); } catch (TaskResultRuntimeException $exception) { if ($reimport_attempts < 1) { throw $exception; } $errors = 0; $result = null; // Attempt to resolve import issues by reimporting the // configurations again. This workaround was added due to // the following issue: // @see https://www.drupal.org/project/drupal/issues/2923899 for ($i = 0; $i < $reimport_attempts; $i++) { $result = $this->runDrushCommand('cim', false, $localhost); if ($result->getExitCode() === ResultData::EXITCODE_OK) { break; } ++$errors; } if (!isset($result)) { throw new \Exception('Missing result object.'); } else if ($errors == $reimport_attempts) { throw new TaskResultRuntimeException($result); } } } return $this; }
[ "public", "function", "importDrupalConfig", "(", "$", "reimport_attempts", "=", "1", ",", "$", "localhost", "=", "false", ")", "{", "if", "(", "$", "this", "->", "getProjectVersion", "(", ")", ">=", "8", ")", "{", "try", "{", "$", "drush", "=", "(", ...
Drupal import configurations. @param int $reimport_attempts Set the amount of reimport attempts to invoke. @param bool $localhost Determine if the drush command should be ran on the host. @return $this @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Drupal", "import", "configurations", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L286-L325
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.optionForm
public function optionForm() { $fields = []; $default = $this->defaultInstallOptions(); $fields[] = (new BooleanField('site', 'Setup Drupal site options?')) ->setDefault(false) ->setSubform(function ($subform, $value) use ($default) { if ($value === true) { $subform->addFields([ (new TextField('name', 'Drupal site name?')) ->setDefault($default['site']['name']), (new TextField('profile', 'Drupal site profile?')) ->setDefault($default['site']['profile']), ]); } }); $fields[] = (new BooleanField('account', 'Setup Drupal account options?')) ->setDefault(false) ->setSubform(function ($subform, $value) use ($default) { if ($value === true) { $subform->addFields([ (new TextField('mail', 'Account email:')) ->setDefault($default['account']['mail']), (new TextField('name', 'Account username:')) ->setDefault($default['account']['name']), (new TextField('pass', 'Account password:')) ->setHidden(true) ->setDefault($default['account']['pass']), ]); } }); return (new Form()) ->addFields($fields); }
php
public function optionForm() { $fields = []; $default = $this->defaultInstallOptions(); $fields[] = (new BooleanField('site', 'Setup Drupal site options?')) ->setDefault(false) ->setSubform(function ($subform, $value) use ($default) { if ($value === true) { $subform->addFields([ (new TextField('name', 'Drupal site name?')) ->setDefault($default['site']['name']), (new TextField('profile', 'Drupal site profile?')) ->setDefault($default['site']['profile']), ]); } }); $fields[] = (new BooleanField('account', 'Setup Drupal account options?')) ->setDefault(false) ->setSubform(function ($subform, $value) use ($default) { if ($value === true) { $subform->addFields([ (new TextField('mail', 'Account email:')) ->setDefault($default['account']['mail']), (new TextField('name', 'Account username:')) ->setDefault($default['account']['name']), (new TextField('pass', 'Account password:')) ->setHidden(true) ->setDefault($default['account']['pass']), ]); } }); return (new Form()) ->addFields($fields); }
[ "public", "function", "optionForm", "(", ")", "{", "$", "fields", "=", "[", "]", ";", "$", "default", "=", "$", "this", "->", "defaultInstallOptions", "(", ")", ";", "$", "fields", "[", "]", "=", "(", "new", "BooleanField", "(", "'site'", ",", "'Setu...
Drupal option form object. @return \Droath\ConsoleForm\Form
[ "Drupal", "option", "form", "object", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L332-L368
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupProject
public function setupProject() { $this->taskWriteToFile(ProjectX::projectRoot() . '/.gitignore') ->text($this->loadTemplateContents('.gitignore.txt')) ->place('PROJECT_ROOT', $this->getInstallRoot(true)) ->run(); return $this; }
php
public function setupProject() { $this->taskWriteToFile(ProjectX::projectRoot() . '/.gitignore') ->text($this->loadTemplateContents('.gitignore.txt')) ->place('PROJECT_ROOT', $this->getInstallRoot(true)) ->run(); return $this; }
[ "public", "function", "setupProject", "(", ")", "{", "$", "this", "->", "taskWriteToFile", "(", "ProjectX", "::", "projectRoot", "(", ")", ".", "'/.gitignore'", ")", "->", "text", "(", "$", "this", "->", "loadTemplateContents", "(", "'.gitignore.txt'", ")", ...
Setup project. The setup process consist of the following: - Copy over .gitignore file to project root. @return self
[ "Setup", "project", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L445-L453
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupProjectComposer
public function setupProjectComposer() { $this->mergeProjectComposerTemplate(); $install_root = substr(static::installRoot(), 1); $version = $this->getProjectVersion(); $this->composer ->setType('project') ->setPreferStable(true) ->setMinimumStability('dev') ->setConfig([ 'platform' => [ 'php' => "{$this->getEnvPhpVersion()}" ] ]) ->addRepository('drupal', [ 'type' => 'composer', 'url' => "https://packages.drupal.org/{$version}" ]) ->addRequires([ 'drupal/core' => static::DRUPAL_8_VERSION, 'composer/installers' => '^1.1', 'cweagans/composer-patches' => '^1.5', 'drupal-composer/drupal-scaffold' => '^2.0' ]) ->addExtra('drupal-scaffold', [ 'excludes' => [ 'robot.txt' ], 'initial' => [ 'sites/development.services.yml' => 'sites/development.services.yml', 'sites/example.settings.local.php' => 'sites/example.settings.local.php' ], 'omit-defaults' => false ]) ->addExtra('installer-paths', [ $install_root . '/core' => ['type:drupal-core'], $install_root . '/modules/contrib/{$name}' => ['type:drupal-module'], $install_root . '/profiles/custom/{$name}' => ['type:drupal-profile'], $install_root . '/themes/contrib/{$name}'=> ['type:drupal-theme'], 'drush/contrib/{$name}'=> ['type:drupal-drush'] ]); return $this; }
php
public function setupProjectComposer() { $this->mergeProjectComposerTemplate(); $install_root = substr(static::installRoot(), 1); $version = $this->getProjectVersion(); $this->composer ->setType('project') ->setPreferStable(true) ->setMinimumStability('dev') ->setConfig([ 'platform' => [ 'php' => "{$this->getEnvPhpVersion()}" ] ]) ->addRepository('drupal', [ 'type' => 'composer', 'url' => "https://packages.drupal.org/{$version}" ]) ->addRequires([ 'drupal/core' => static::DRUPAL_8_VERSION, 'composer/installers' => '^1.1', 'cweagans/composer-patches' => '^1.5', 'drupal-composer/drupal-scaffold' => '^2.0' ]) ->addExtra('drupal-scaffold', [ 'excludes' => [ 'robot.txt' ], 'initial' => [ 'sites/development.services.yml' => 'sites/development.services.yml', 'sites/example.settings.local.php' => 'sites/example.settings.local.php' ], 'omit-defaults' => false ]) ->addExtra('installer-paths', [ $install_root . '/core' => ['type:drupal-core'], $install_root . '/modules/contrib/{$name}' => ['type:drupal-module'], $install_root . '/profiles/custom/{$name}' => ['type:drupal-profile'], $install_root . '/themes/contrib/{$name}'=> ['type:drupal-theme'], 'drush/contrib/{$name}'=> ['type:drupal-drush'] ]); return $this; }
[ "public", "function", "setupProjectComposer", "(", ")", "{", "$", "this", "->", "mergeProjectComposerTemplate", "(", ")", ";", "$", "install_root", "=", "substr", "(", "static", "::", "installRoot", "(", ")", ",", "1", ")", ";", "$", "version", "=", "$", ...
Setup project composer requirements. @return self
[ "Setup", "project", "composer", "requirements", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L460-L504
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.packageDrupalBuild
public function packageDrupalBuild($build_root) { $project_root = ProjectX::projectRoot(); $build_install = $build_root . static::installRoot(); $install_path = $this->getInstallPath(); $stack = $this->taskFilesystemStack(); $static_files = [ "{$project_root}/salt.txt" => "{$build_root}/salt.txt", "{$install_path}/.htaccess" => "{$build_install}/.htaccess", "{$install_path}/index.php" => "{$build_install}/index.php", "{$install_path}/robots.txt" => "{$build_install}/robots.txt", "{$install_path}/update.php" => "{$build_install}/update.php", "{$install_path}/web.config" => "{$build_install}/web.config", "{$install_path}/sites/default/settings.php" => "{$build_install}/sites/default/settings.php", ]; foreach ($static_files as $source => $destination) { if (!file_exists($source)) { continue; } $stack->copy($source, $destination); } $mirror_directories = [ '/config', static::installRoot() . '/libraries', static::installRoot() . '/themes/custom', static::installRoot() . '/modules/custom', static::installRoot() . '/profiles/custom' ]; foreach ($mirror_directories as $directory) { $path_to_directory = "{$project_root}{$directory}"; if (!file_exists($path_to_directory)) { continue; } $stack->mirror($path_to_directory, "{$build_root}{$directory}"); } $stack->run(); return $this; }
php
public function packageDrupalBuild($build_root) { $project_root = ProjectX::projectRoot(); $build_install = $build_root . static::installRoot(); $install_path = $this->getInstallPath(); $stack = $this->taskFilesystemStack(); $static_files = [ "{$project_root}/salt.txt" => "{$build_root}/salt.txt", "{$install_path}/.htaccess" => "{$build_install}/.htaccess", "{$install_path}/index.php" => "{$build_install}/index.php", "{$install_path}/robots.txt" => "{$build_install}/robots.txt", "{$install_path}/update.php" => "{$build_install}/update.php", "{$install_path}/web.config" => "{$build_install}/web.config", "{$install_path}/sites/default/settings.php" => "{$build_install}/sites/default/settings.php", ]; foreach ($static_files as $source => $destination) { if (!file_exists($source)) { continue; } $stack->copy($source, $destination); } $mirror_directories = [ '/config', static::installRoot() . '/libraries', static::installRoot() . '/themes/custom', static::installRoot() . '/modules/custom', static::installRoot() . '/profiles/custom' ]; foreach ($mirror_directories as $directory) { $path_to_directory = "{$project_root}{$directory}"; if (!file_exists($path_to_directory)) { continue; } $stack->mirror($path_to_directory, "{$build_root}{$directory}"); } $stack->run(); return $this; }
[ "public", "function", "packageDrupalBuild", "(", "$", "build_root", ")", "{", "$", "project_root", "=", "ProjectX", "::", "projectRoot", "(", ")", ";", "$", "build_install", "=", "$", "build_root", ".", "static", "::", "installRoot", "(", ")", ";", "$", "i...
Package up Drupal into a build directory. The process consist of the following: - Copy config - Copy salt.txt, index.php, settings.php, .htaccess, robots.txt, update.php, and web.config. - Copy themes, modules, and profile custom code. @param $build_root The build root path. @return self
[ "Package", "up", "Drupal", "into", "a", "build", "directory", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L518-L560
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDrush
public function setupDrush($exclude_remote = false) { $project_root = ProjectX::projectRoot(); $this->taskFilesystemStack() ->mirror($this->getTemplateFilePath('drush'), "$project_root/drush") ->copy($this->getTemplateFilePath('drush.wrapper'), "$project_root/drush.wrapper") ->run(); $this->taskWriteToFile("{$project_root}/drush/drushrc.php") ->append() ->place('PROJECT_ROOT', $this->getInstallRoot(true)) ->run(); $this->setupDrushAlias($exclude_remote); return $this; }
php
public function setupDrush($exclude_remote = false) { $project_root = ProjectX::projectRoot(); $this->taskFilesystemStack() ->mirror($this->getTemplateFilePath('drush'), "$project_root/drush") ->copy($this->getTemplateFilePath('drush.wrapper'), "$project_root/drush.wrapper") ->run(); $this->taskWriteToFile("{$project_root}/drush/drushrc.php") ->append() ->place('PROJECT_ROOT', $this->getInstallRoot(true)) ->run(); $this->setupDrushAlias($exclude_remote); return $this; }
[ "public", "function", "setupDrush", "(", "$", "exclude_remote", "=", "false", ")", "{", "$", "project_root", "=", "ProjectX", "::", "projectRoot", "(", ")", ";", "$", "this", "->", "taskFilesystemStack", "(", ")", "->", "mirror", "(", "$", "this", "->", ...
Setup Drupal drush. The setup process consist of the following: - Copy the template drush directory into the project root. @param bool $exclude_remote Exclude the remote drush aliases from being generated. @return self
[ "Setup", "Drupal", "drush", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L573-L590
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDrushAlias
public function setupDrushAlias($exclude_remote = false) { $project_root = ProjectX::projectRoot(); if (!file_exists("$project_root/drush/site-aliases")) { $continue = $this->askConfirmQuestion( "Drush aliases haven't been setup for this project.\n" . "\nDo you want run the Drush alias setup?", true ); if (!$continue) { return $this; } $this->setupDrush($exclude_remote); } else { $this->setupDrushLocalAlias(); if (!$exclude_remote) { $this->setupDrushRemoteAliases(); } } return $this; }
php
public function setupDrushAlias($exclude_remote = false) { $project_root = ProjectX::projectRoot(); if (!file_exists("$project_root/drush/site-aliases")) { $continue = $this->askConfirmQuestion( "Drush aliases haven't been setup for this project.\n" . "\nDo you want run the Drush alias setup?", true ); if (!$continue) { return $this; } $this->setupDrush($exclude_remote); } else { $this->setupDrushLocalAlias(); if (!$exclude_remote) { $this->setupDrushRemoteAliases(); } } return $this; }
[ "public", "function", "setupDrushAlias", "(", "$", "exclude_remote", "=", "false", ")", "{", "$", "project_root", "=", "ProjectX", "::", "projectRoot", "(", ")", ";", "if", "(", "!", "file_exists", "(", "\"$project_root/drush/site-aliases\"", ")", ")", "{", "$...
Setup Drush aliases. @param bool $exclude_remote Exclude the remote drush aliases from being generated. @return self
[ "Setup", "Drush", "aliases", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L623-L647
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDrushLocalAlias
public function setupDrushLocalAlias($alias_name = null) { $config = ProjectX::getProjectConfig(); $alias_name = isset($alias_name) ? Utiltiy::machineName($alias_name) : ProjectX::getProjectMachineName(); $alias_content = $this->drushAliasFileContent( $alias_name, $config->getHost()['name'], $this->getInstallPath() ); $project_root = ProjectX::projectRoot(); $this ->taskWriteToFile("$project_root/drush/site-aliases/local.aliases.drushrc.php") ->line($alias_content) ->run(); return $this; }
php
public function setupDrushLocalAlias($alias_name = null) { $config = ProjectX::getProjectConfig(); $alias_name = isset($alias_name) ? Utiltiy::machineName($alias_name) : ProjectX::getProjectMachineName(); $alias_content = $this->drushAliasFileContent( $alias_name, $config->getHost()['name'], $this->getInstallPath() ); $project_root = ProjectX::projectRoot(); $this ->taskWriteToFile("$project_root/drush/site-aliases/local.aliases.drushrc.php") ->line($alias_content) ->run(); return $this; }
[ "public", "function", "setupDrushLocalAlias", "(", "$", "alias_name", "=", "null", ")", "{", "$", "config", "=", "ProjectX", "::", "getProjectConfig", "(", ")", ";", "$", "alias_name", "=", "isset", "(", "$", "alias_name", ")", "?", "Utiltiy", "::", "machi...
Setup Drupal local alias. The setup process consist of the following: - Create the local.aliases.drushrc.php file based on the local . @return self
[ "Setup", "Drupal", "local", "alias", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L657-L678
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDrushRemoteAliases
public function setupDrushRemoteAliases() { $project_root = ProjectX::projectRoot(); $drush_aliases_dir = "$project_root/drush/site-aliases"; foreach (ProjectX::getRemoteEnvironments() as $realm => $environment) { $file_task = $this ->taskWriteToFile("$drush_aliases_dir/$realm.aliases.drushrc.php"); $has_content = false; for ($i = 0; $i < count($environment); $i++) { $instance = $environment[$i]; if (!isset($instance['name']) || !isset($instance['path']) || !isset($instance['uri']) || !isset($instance['ssh_url'])) { continue; } list($ssh_user, $ssh_host) = explode('@', $instance['ssh_url']); $options = [ 'remote_user' => $ssh_user, 'remote_host' => $ssh_host ]; $content = $this->drushAliasFileContent( $instance['name'], $instance['uri'], $instance['path'], $options, $i === 0 ); $has_content = true; $file_task->line($content); } if ($has_content) { $file_task->run(); } } return $this; }
php
public function setupDrushRemoteAliases() { $project_root = ProjectX::projectRoot(); $drush_aliases_dir = "$project_root/drush/site-aliases"; foreach (ProjectX::getRemoteEnvironments() as $realm => $environment) { $file_task = $this ->taskWriteToFile("$drush_aliases_dir/$realm.aliases.drushrc.php"); $has_content = false; for ($i = 0; $i < count($environment); $i++) { $instance = $environment[$i]; if (!isset($instance['name']) || !isset($instance['path']) || !isset($instance['uri']) || !isset($instance['ssh_url'])) { continue; } list($ssh_user, $ssh_host) = explode('@', $instance['ssh_url']); $options = [ 'remote_user' => $ssh_user, 'remote_host' => $ssh_host ]; $content = $this->drushAliasFileContent( $instance['name'], $instance['uri'], $instance['path'], $options, $i === 0 ); $has_content = true; $file_task->line($content); } if ($has_content) { $file_task->run(); } } return $this; }
[ "public", "function", "setupDrushRemoteAliases", "(", ")", "{", "$", "project_root", "=", "ProjectX", "::", "projectRoot", "(", ")", ";", "$", "drush_aliases_dir", "=", "\"$project_root/drush/site-aliases\"", ";", "foreach", "(", "ProjectX", "::", "getRemoteEnvironmen...
Setup Drush remote aliases. The setup process consist of the following: - Write the remote $aliases[] into a drush alias file; which is based off the remote realm. @return self
[ "Setup", "Drush", "remote", "aliases", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L689-L733
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.createDrupalLoginLink
public function createDrupalLoginLink($user = null, $path = null, $localhost = false) { $arg = []; if (isset($user)) { $arg[] = $user; } if (isset($path)) { $arg[] = $path; } $args = implode(' ', $arg); $drush = (new DrushCommand(null, $localhost)) ->command("uli {$args}"); $this->runDrushCommand($drush, false, $localhost); return $this; }
php
public function createDrupalLoginLink($user = null, $path = null, $localhost = false) { $arg = []; if (isset($user)) { $arg[] = $user; } if (isset($path)) { $arg[] = $path; } $args = implode(' ', $arg); $drush = (new DrushCommand(null, $localhost)) ->command("uli {$args}"); $this->runDrushCommand($drush, false, $localhost); return $this; }
[ "public", "function", "createDrupalLoginLink", "(", "$", "user", "=", "null", ",", "$", "path", "=", "null", ",", "$", "localhost", "=", "false", ")", "{", "$", "arg", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "user", ")", ")", "{", "$", ...
Create a Drupal login link. @param null $user The drupal login user. @param null $path The path to redirect to after login. @param bool $localhost Run the command on localhost. @return $this
[ "Create", "a", "Drupal", "login", "link", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L777-L794
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDrupalFilesystem
public function setupDrupalFilesystem() { $this->taskFilesystemStack() ->chmod($this->sitesPath, 0775, 0000, true) ->mkdir("{$this->sitesPath}/default/files", 0775, true) ->run(); if ($this->getProjectVersion() >= 8) { $install_path = $this->getInstallPath(); $this->taskFilesystemStack() ->mkdir("{$install_path}/profiles/custom", 0775, true) ->mkdir("{$install_path}/modules/custom", 0775, true) ->mkdir("{$install_path}/modules/contrib", 0775, true) ->run(); } return $this; }
php
public function setupDrupalFilesystem() { $this->taskFilesystemStack() ->chmod($this->sitesPath, 0775, 0000, true) ->mkdir("{$this->sitesPath}/default/files", 0775, true) ->run(); if ($this->getProjectVersion() >= 8) { $install_path = $this->getInstallPath(); $this->taskFilesystemStack() ->mkdir("{$install_path}/profiles/custom", 0775, true) ->mkdir("{$install_path}/modules/custom", 0775, true) ->mkdir("{$install_path}/modules/contrib", 0775, true) ->run(); } return $this; }
[ "public", "function", "setupDrupalFilesystem", "(", ")", "{", "$", "this", "->", "taskFilesystemStack", "(", ")", "->", "chmod", "(", "$", "this", "->", "sitesPath", ",", "0775", ",", "0000", ",", "true", ")", "->", "mkdir", "(", "\"{$this->sitesPath}/defaul...
Setup Drupal filesystem. The setup process consist of the following: - Change site permission. - Creates defaults files directory. @return self
[ "Setup", "Drupal", "filesystem", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L805-L823
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDrupalSettings
public function setupDrupalSettings() { $this->_copy( "{$this->sitesPath}/default/default.settings.php", $this->settingFile ); $install_root = dirname($this->getQualifiedInstallRoot()); if ($this->getProjectVersion() >= 8) { $this->taskWriteToFile("{$install_root}/salt.txt") ->line(Utility::randomHash()) ->run(); $this->taskFilesystemStack() ->mkdir("{$install_root}/config", 0775) ->chmod("{$install_root}/salt.txt", 0775) ->run(); $this->taskWriteToFile($this->settingFile) ->append() ->regexReplace( '/\#\sif.+\/settings\.local\.php.+\n#.+\n\#\s}/', $this->drupalSettingsLocalInclude() ) ->replace( '$config_directories = array();', '$config_directories[CONFIG_SYNC_DIRECTORY] = dirname(DRUPAL_ROOT) . \'/config\';' ) ->replace( '$settings[\'hash_salt\'] = \'\';', '$settings[\'hash_salt\'] = file_get_contents(dirname(DRUPAL_ROOT) . \'/salt.txt\');' ) ->run(); } return $this; }
php
public function setupDrupalSettings() { $this->_copy( "{$this->sitesPath}/default/default.settings.php", $this->settingFile ); $install_root = dirname($this->getQualifiedInstallRoot()); if ($this->getProjectVersion() >= 8) { $this->taskWriteToFile("{$install_root}/salt.txt") ->line(Utility::randomHash()) ->run(); $this->taskFilesystemStack() ->mkdir("{$install_root}/config", 0775) ->chmod("{$install_root}/salt.txt", 0775) ->run(); $this->taskWriteToFile($this->settingFile) ->append() ->regexReplace( '/\#\sif.+\/settings\.local\.php.+\n#.+\n\#\s}/', $this->drupalSettingsLocalInclude() ) ->replace( '$config_directories = array();', '$config_directories[CONFIG_SYNC_DIRECTORY] = dirname(DRUPAL_ROOT) . \'/config\';' ) ->replace( '$settings[\'hash_salt\'] = \'\';', '$settings[\'hash_salt\'] = file_get_contents(dirname(DRUPAL_ROOT) . \'/salt.txt\');' ) ->run(); } return $this; }
[ "public", "function", "setupDrupalSettings", "(", ")", "{", "$", "this", "->", "_copy", "(", "\"{$this->sitesPath}/default/default.settings.php\"", ",", "$", "this", "->", "settingFile", ")", ";", "$", "install_root", "=", "dirname", "(", "$", "this", "->", "get...
Setup Drupal settings file. The setup process consist of the following: - Copy over default settings.php. - Create the Drupal config directory. - Generate salt and place text file outside docroot. - Replace commented local.settings include statement. - Replace $config_directories with a config directory outside docroot. - Replace $settings['hash_salt'] with path to generated the salt text file. @return self
[ "Setup", "Drupal", "settings", "file", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L838-L874
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDrupalLocalSettings
public function setupDrupalLocalSettings() { $version = $this->getProjectVersion(); $local_settings = $this ->templateManager() ->loadTemplate("{$version}/settings.local.txt"); $this->_remove($this->settingLocalFile); if ($version >= 8) { $setting_path = "{$this->sitesPath}/example.settings.local.php"; if (file_exists($setting_path)) { $this->_copy($setting_path, $this->settingLocalFile); } else { $this->taskWriteToFile($this->settingLocalFile) ->text("<?php\r\n") ->run(); } } else { $this->taskWriteToFile($this->settingLocalFile) ->text("<?php\r\n") ->run(); } $database = $this->getDatabaseInfo(); $this->taskWriteToFile($this->settingLocalFile) ->append() ->appendUnlessMatches('/\$databases\[.+\]/', $local_settings) ->place('DB_NAME', $database->getDatabase()) ->place('DB_USER', $database->getUser()) ->place('DB_PASS', $database->getPassword()) ->place('DB_HOST', $database->getHostname()) ->place('DB_PORT', $database->getPort()) ->place('DB_PROTOCOL', $database->getProtocol()) ->run(); return $this; }
php
public function setupDrupalLocalSettings() { $version = $this->getProjectVersion(); $local_settings = $this ->templateManager() ->loadTemplate("{$version}/settings.local.txt"); $this->_remove($this->settingLocalFile); if ($version >= 8) { $setting_path = "{$this->sitesPath}/example.settings.local.php"; if (file_exists($setting_path)) { $this->_copy($setting_path, $this->settingLocalFile); } else { $this->taskWriteToFile($this->settingLocalFile) ->text("<?php\r\n") ->run(); } } else { $this->taskWriteToFile($this->settingLocalFile) ->text("<?php\r\n") ->run(); } $database = $this->getDatabaseInfo(); $this->taskWriteToFile($this->settingLocalFile) ->append() ->appendUnlessMatches('/\$databases\[.+\]/', $local_settings) ->place('DB_NAME', $database->getDatabase()) ->place('DB_USER', $database->getUser()) ->place('DB_PASS', $database->getPassword()) ->place('DB_HOST', $database->getHostname()) ->place('DB_PORT', $database->getPort()) ->place('DB_PROTOCOL', $database->getProtocol()) ->run(); return $this; }
[ "public", "function", "setupDrupalLocalSettings", "(", ")", "{", "$", "version", "=", "$", "this", "->", "getProjectVersion", "(", ")", ";", "$", "local_settings", "=", "$", "this", "->", "templateManager", "(", ")", "->", "loadTemplate", "(", "\"{$version}/se...
Setup Drupal local settings file. The setup process consist of the following: - Copy over example.settings.local.php. - Appends database connection details. @return self @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface @throws \Exception
[ "Setup", "Drupal", "local", "settings", "file", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L888-L926
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDrupalInstall
public function setupDrupalInstall($localhost = false) { $this->say('Waiting on Drupal database to become available...'); $database = $this->getDatabaseInfo(); $engine = $this->getEngineInstance(); $install_path = $this->getInstallPath(); if ($engine instanceof DockerEngineType && !$localhost) { $drush = $this->drushInstallCommonStack( '/var/www/html/vendor/bin/drush', '/var/www/html' . static::installRoot(), $database ); $result = $engine->execRaw( $drush->getCommand(), $this->getPhpServiceName() ); } else { // Run the drupal installation from the host machine. The host will // need to have the database client binaries installed. $database->setHostname('127.0.0.1'); if (!$this->hasDatabaseConnection($database->getHostname(), $database->getPort())) { throw new \Exception( sprintf('Unable to connection to Drupal database %s', $database->getHostname()) ); } // Sometimes it takes awhile after the mysql host is up on the // network to become totally available to except connections. Due to // the uncertainty we'll need to sleep for about 30 seconds. sleep(30); $result = $this->drushInstallCommonStack( 'drush', $install_path, $database )->run(); } $this->validateTaskResult($result); // Update permissions to ensure all files can be accessed on the install // path for both user and groups. $this->_chmod($install_path, 0775, 0000, true); return $this; }
php
public function setupDrupalInstall($localhost = false) { $this->say('Waiting on Drupal database to become available...'); $database = $this->getDatabaseInfo(); $engine = $this->getEngineInstance(); $install_path = $this->getInstallPath(); if ($engine instanceof DockerEngineType && !$localhost) { $drush = $this->drushInstallCommonStack( '/var/www/html/vendor/bin/drush', '/var/www/html' . static::installRoot(), $database ); $result = $engine->execRaw( $drush->getCommand(), $this->getPhpServiceName() ); } else { // Run the drupal installation from the host machine. The host will // need to have the database client binaries installed. $database->setHostname('127.0.0.1'); if (!$this->hasDatabaseConnection($database->getHostname(), $database->getPort())) { throw new \Exception( sprintf('Unable to connection to Drupal database %s', $database->getHostname()) ); } // Sometimes it takes awhile after the mysql host is up on the // network to become totally available to except connections. Due to // the uncertainty we'll need to sleep for about 30 seconds. sleep(30); $result = $this->drushInstallCommonStack( 'drush', $install_path, $database )->run(); } $this->validateTaskResult($result); // Update permissions to ensure all files can be accessed on the install // path for both user and groups. $this->_chmod($install_path, 0775, 0000, true); return $this; }
[ "public", "function", "setupDrupalInstall", "(", "$", "localhost", "=", "false", ")", "{", "$", "this", "->", "say", "(", "'Waiting on Drupal database to become available...'", ")", ";", "$", "database", "=", "$", "this", "->", "getDatabaseInfo", "(", ")", ";", ...
Setup Drupal install. The setup process consist of the following: - Check if project database is available. - Install Drupal using the drush executable. - Update install path permissions recursively. @param bool $localhost A flag to determine if Drupal should be installed using localhost. @return self @throws \Robo\Exception\TaskException
[ "Setup", "Drupal", "install", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L942-L989
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.removeGitSubmodulesInVendor
public function removeGitSubmodulesInVendor($base_path = null) { $base_path = isset($base_path) && file_exists($base_path) ? $base_path : ProjectX::projectRoot(); $composer = $this->getComposer(); $composer_config = $composer->getConfig(); $vendor_dir = isset($composer_config['vendor-dir']) ? $composer_config['vendor-dir'] : 'vendor'; $this->removeGitSubmodules( [$base_path . "/{$vendor_dir}"], 2 ); return $this; }
php
public function removeGitSubmodulesInVendor($base_path = null) { $base_path = isset($base_path) && file_exists($base_path) ? $base_path : ProjectX::projectRoot(); $composer = $this->getComposer(); $composer_config = $composer->getConfig(); $vendor_dir = isset($composer_config['vendor-dir']) ? $composer_config['vendor-dir'] : 'vendor'; $this->removeGitSubmodules( [$base_path . "/{$vendor_dir}"], 2 ); return $this; }
[ "public", "function", "removeGitSubmodulesInVendor", "(", "$", "base_path", "=", "null", ")", "{", "$", "base_path", "=", "isset", "(", "$", "base_path", ")", "&&", "file_exists", "(", "$", "base_path", ")", "?", "$", "base_path", ":", "ProjectX", "::", "p...
Remove git submodule in vendor. @param null $base_path The base path on which to check for composer installed paths. @return $this
[ "Remove", "git", "submodule", "in", "vendor", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L999-L1018
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.getValidComposerInstallPaths
public function getValidComposerInstallPaths($base_path = null) { $filepaths = []; /** @var ComposerConfig $composer */ $composer = $this->getComposer(); $composer_extra = $composer->getExtra(); $base_path = isset($base_path) && file_exists($base_path) ? $base_path : ProjectX::projectRoot(); $installed_paths = isset($composer_extra['installer-paths']) ? array_keys($composer_extra['installer-paths']) : []; $installed_directory = substr(static::getInstallPath(), strrpos(static::getInstallPath(), '/')); foreach ($installed_paths as $installed_path) { $path_info = pathinfo($installed_path); $directory = "/{$path_info['dirname']}"; if (strpos($directory, $installed_directory) === false) { continue; } $filename = $path_info['filename'] !== '{$name}' ? "/{$path_info['filename']}" : null; $filepath = $base_path . $directory . $filename; if (!file_exists($filepath)) { continue; } $filepaths[] = $filepath; } return $filepaths; }
php
public function getValidComposerInstallPaths($base_path = null) { $filepaths = []; /** @var ComposerConfig $composer */ $composer = $this->getComposer(); $composer_extra = $composer->getExtra(); $base_path = isset($base_path) && file_exists($base_path) ? $base_path : ProjectX::projectRoot(); $installed_paths = isset($composer_extra['installer-paths']) ? array_keys($composer_extra['installer-paths']) : []; $installed_directory = substr(static::getInstallPath(), strrpos(static::getInstallPath(), '/')); foreach ($installed_paths as $installed_path) { $path_info = pathinfo($installed_path); $directory = "/{$path_info['dirname']}"; if (strpos($directory, $installed_directory) === false) { continue; } $filename = $path_info['filename'] !== '{$name}' ? "/{$path_info['filename']}" : null; $filepath = $base_path . $directory . $filename; if (!file_exists($filepath)) { continue; } $filepaths[] = $filepath; } return $filepaths; }
[ "public", "function", "getValidComposerInstallPaths", "(", "$", "base_path", "=", "null", ")", "{", "$", "filepaths", "=", "[", "]", ";", "/** @var ComposerConfig $composer */", "$", "composer", "=", "$", "this", "->", "getComposer", "(", ")", ";", "$", "compo...
Get valid composer install paths. @param null $base_path The base path on which to check for composer installed paths. @return array
[ "Get", "valid", "composer", "install", "paths", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1078-L1115
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.runDrushCommand
public function runDrushCommand($command, $quiet = false, $localhost = false) { if ($command instanceof CommandBuilder) { $drush = $command; } else { $drush = new DrushCommand(null, $localhost); foreach (explode('&&', $command) as $string) { $drush->command($string); } } return $this->executeEngineCommand( $drush, $this->getPhpServiceName(), [], $quiet, $localhost ); ; }
php
public function runDrushCommand($command, $quiet = false, $localhost = false) { if ($command instanceof CommandBuilder) { $drush = $command; } else { $drush = new DrushCommand(null, $localhost); foreach (explode('&&', $command) as $string) { $drush->command($string); } } return $this->executeEngineCommand( $drush, $this->getPhpServiceName(), [], $quiet, $localhost ); ; }
[ "public", "function", "runDrushCommand", "(", "$", "command", ",", "$", "quiet", "=", "false", ",", "$", "localhost", "=", "false", ")", "{", "if", "(", "$", "command", "instanceof", "CommandBuilder", ")", "{", "$", "drush", "=", "$", "command", ";", "...
Run Drush command. @param string|CommandBuilder $command The drush command to execute. @param bool $quiet Silence command output. @param bool $localhost Run command on localhost. @return ResultData
[ "Run", "Drush", "command", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1129-L1148
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setDrupalUuid
public function setDrupalUuid($localhost = false) { if ($this->getProjectVersion() >= 8) { $build_info = $this->getProjectOptionByKey('build_info'); if ($build_info !== false && isset($build_info['uuid']) && !empty($build_info['uuid'])) { $drush = new DrushCommand(null, $localhost); $drush ->command("cset system.site uuid {$build_info['uuid']}") ->command('ev \'\Drupal::entityManager()->getStorage("shortcut_set")->load("default")->delete();\''); $this->runDrushCommand($drush, false, $localhost); } } return $this; }
php
public function setDrupalUuid($localhost = false) { if ($this->getProjectVersion() >= 8) { $build_info = $this->getProjectOptionByKey('build_info'); if ($build_info !== false && isset($build_info['uuid']) && !empty($build_info['uuid'])) { $drush = new DrushCommand(null, $localhost); $drush ->command("cset system.site uuid {$build_info['uuid']}") ->command('ev \'\Drupal::entityManager()->getStorage("shortcut_set")->load("default")->delete();\''); $this->runDrushCommand($drush, false, $localhost); } } return $this; }
[ "public", "function", "setDrupalUuid", "(", "$", "localhost", "=", "false", ")", "{", "if", "(", "$", "this", "->", "getProjectVersion", "(", ")", ">=", "8", ")", "{", "$", "build_info", "=", "$", "this", "->", "getProjectOptionByKey", "(", "'build_info'",...
Set Drupal UUID. @param bool $localhost Determine if the drush command should be ran on the host. @return $this @throws \Exception
[ "Set", "Drupal", "UUID", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1171-L1189
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.refreshDatabaseSettings
protected function refreshDatabaseSettings() { /** @var Database $database */ $database = $this->getDatabaseInfo(); $settings = file_get_contents($this->settingLocalFile); // Replace database properties based on database info. foreach ($database->asArray() as $property => $value) { $settings = $this->replaceDatabaseProperty( $property, $value, $settings ); } // Replace the namespace property based on the database protocol. $namespace_base = addslashes('Drupal\\\\Core\\\\Database\\\\Driver\\\\'); $settings = $this->replaceDatabaseProperty( 'namespace', "{$namespace_base}{$database->getProtocol()}", $settings ); // Check if file contents whats updated. $status = file_put_contents($this->settingLocalFile, $settings); if (false === $status) { throw new \Exception( sprintf('Unable to refresh database settings in (%s).', $this->settingLocalFile) ); return false; } return true; }
php
protected function refreshDatabaseSettings() { /** @var Database $database */ $database = $this->getDatabaseInfo(); $settings = file_get_contents($this->settingLocalFile); // Replace database properties based on database info. foreach ($database->asArray() as $property => $value) { $settings = $this->replaceDatabaseProperty( $property, $value, $settings ); } // Replace the namespace property based on the database protocol. $namespace_base = addslashes('Drupal\\\\Core\\\\Database\\\\Driver\\\\'); $settings = $this->replaceDatabaseProperty( 'namespace', "{$namespace_base}{$database->getProtocol()}", $settings ); // Check if file contents whats updated. $status = file_put_contents($this->settingLocalFile, $settings); if (false === $status) { throw new \Exception( sprintf('Unable to refresh database settings in (%s).', $this->settingLocalFile) ); return false; } return true; }
[ "protected", "function", "refreshDatabaseSettings", "(", ")", "{", "/** @var Database $database */", "$", "database", "=", "$", "this", "->", "getDatabaseInfo", "(", ")", ";", "$", "settings", "=", "file_get_contents", "(", "$", "this", "->", "settingLocalFile", "...
Refresh database settings. @return bool Return boolean based on if refresh was successful. @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Refresh", "database", "settings", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1213-L1248
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.setupDatabaseFromRestore
protected function setupDatabaseFromRestore( $method = null, $localhost = false ) { /** @var EngineType $engine */ $engine = $this->getEngineInstance(); if ($engine instanceof DockerEngineType) { $options = $this->databaseRestoreOptions(); if (!isset($method) || !in_array($method, $options)) { $method = $this->doAsk(new ChoiceQuestion( 'Setup the project using? ', $options )); } switch ($method) { case 'site-config': $this ->setupDrupalInstall($localhost) ->setDrupalUuid($localhost) ->importDrupalConfig(1, $localhost); break; case 'database-import': $this->importDatabaseToService($this->getPhpServiceName(), null, true, $localhost); break; default: /** @var DrupalPlatformRestoreInterface $platform */ $platform = $this->getPlatformInstance(); if ($platform instanceof DrupalPlatformRestoreInterface) { $platform->drupalRestore($method); } } $this->clearDrupalCache($localhost); } else { $classname = get_class($engine); throw new \RuntimeException( sprintf("The engine type %s isn't supported", $classname::getLabel()) ); } return $this; }
php
protected function setupDatabaseFromRestore( $method = null, $localhost = false ) { /** @var EngineType $engine */ $engine = $this->getEngineInstance(); if ($engine instanceof DockerEngineType) { $options = $this->databaseRestoreOptions(); if (!isset($method) || !in_array($method, $options)) { $method = $this->doAsk(new ChoiceQuestion( 'Setup the project using? ', $options )); } switch ($method) { case 'site-config': $this ->setupDrupalInstall($localhost) ->setDrupalUuid($localhost) ->importDrupalConfig(1, $localhost); break; case 'database-import': $this->importDatabaseToService($this->getPhpServiceName(), null, true, $localhost); break; default: /** @var DrupalPlatformRestoreInterface $platform */ $platform = $this->getPlatformInstance(); if ($platform instanceof DrupalPlatformRestoreInterface) { $platform->drupalRestore($method); } } $this->clearDrupalCache($localhost); } else { $classname = get_class($engine); throw new \RuntimeException( sprintf("The engine type %s isn't supported", $classname::getLabel()) ); } return $this; }
[ "protected", "function", "setupDatabaseFromRestore", "(", "$", "method", "=", "null", ",", "$", "localhost", "=", "false", ")", "{", "/** @var EngineType $engine */", "$", "engine", "=", "$", "this", "->", "getEngineInstance", "(", ")", ";", "if", "(", "$", ...
Setup a Drupal database from restore. @param null $method The method on how to restore. @param bool $localhost Run commands using the localhost. @return $this @throws \Robo\Exception\TaskException
[ "Setup", "a", "Drupal", "database", "from", "restore", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1303-L1348
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.databaseRestoreOptions
protected function databaseRestoreOptions() { $options = []; if ($this->getProjectVersion() >= 8 && $this->hasDrupalConfig()) { $options[] = 'site-config'; } $options[] = 'database-import'; /** @var DrupalPlatformRestoreInterface $platform */ $platform = $this->getPlatformInstance(); if ($platform instanceof DrupalPlatformRestoreInterface) { $options = array_merge($options, $platform->drupalRestoreOptions()); } return $options; }
php
protected function databaseRestoreOptions() { $options = []; if ($this->getProjectVersion() >= 8 && $this->hasDrupalConfig()) { $options[] = 'site-config'; } $options[] = 'database-import'; /** @var DrupalPlatformRestoreInterface $platform */ $platform = $this->getPlatformInstance(); if ($platform instanceof DrupalPlatformRestoreInterface) { $options = array_merge($options, $platform->drupalRestoreOptions()); } return $options; }
[ "protected", "function", "databaseRestoreOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "if", "(", "$", "this", "->", "getProjectVersion", "(", ")", ">=", "8", "&&", "$", "this", "->", "hasDrupalConfig", "(", ")", ")", "{", "$", "options"...
Drupal database restore options. @return array
[ "Drupal", "database", "restore", "options", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1355-L1372
train
droath/project-x
src/Project/DrupalProjectType.php
DrupalProjectType.hasDatabaseInfoChanged
protected function hasDatabaseInfoChanged() { $settings_uri = $this->settingLocalFile; if (file_exists($settings_uri)) { $settings = file_get_contents($settings_uri); $match_status = preg_match_all("/\'(database|username|password|host|port|driver)\'\s=>\s\'(.+)\'\,?/", $settings, $matches); if ($match_status !== false) { $database = $this->getDatabaseInfo(); $database_file = array_combine($matches[1], $matches[2]); foreach ($database->asArray() as $property => $value) { if (isset($database_file[$property]) && $database_file[$property] != $value) { return true; } } } } return false; }
php
protected function hasDatabaseInfoChanged() { $settings_uri = $this->settingLocalFile; if (file_exists($settings_uri)) { $settings = file_get_contents($settings_uri); $match_status = preg_match_all("/\'(database|username|password|host|port|driver)\'\s=>\s\'(.+)\'\,?/", $settings, $matches); if ($match_status !== false) { $database = $this->getDatabaseInfo(); $database_file = array_combine($matches[1], $matches[2]); foreach ($database->asArray() as $property => $value) { if (isset($database_file[$property]) && $database_file[$property] != $value) { return true; } } } } return false; }
[ "protected", "function", "hasDatabaseInfoChanged", "(", ")", "{", "$", "settings_uri", "=", "$", "this", "->", "settingLocalFile", ";", "if", "(", "file_exists", "(", "$", "settings_uri", ")", ")", "{", "$", "settings", "=", "file_get_contents", "(", "$", "s...
Determine if database info has been updated. @return bool Return TRUE if database info has been changed; otherwise FALSE. @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Determine", "if", "database", "info", "has", "been", "updated", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/DrupalProjectType.php#L1398-L1419
train