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/AbstractMapper.php | AbstractMapper.fetchAllByColumn | final public function fetchAllByColumn($column, $value, $select = '*')
{
$this->validateShortcutData();
return $this->db->select($select)
->from(static::getTableName())
->whereEquals($column, $value)
->queryAll();
} | php | final public function fetchAllByColumn($column, $value, $select = '*')
{
$this->validateShortcutData();
return $this->db->select($select)
->from(static::getTableName())
->whereEquals($column, $value)
->queryAll();
} | [
"final",
"public",
"function",
"fetchAllByColumn",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"select",
"=",
"'*'",
")",
"{",
"$",
"this",
"->",
"validateShortcutData",
"(",
")",
";",
"return",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"$",
... | Fetches all row data by column's value
@param string $column
@param string $value
@param mixed $select
@return array | [
"Fetches",
"all",
"row",
"data",
"by",
"column",
"s",
"value"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L684-L692 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.fetchByColumn | final public function fetchByColumn($column, $value, $select = '*')
{
$this->validateShortcutData();
return $this->db->select($select)
->from(static::getTableName())
->whereEquals($column, $value)
->query();
} | php | final public function fetchByColumn($column, $value, $select = '*')
{
$this->validateShortcutData();
return $this->db->select($select)
->from(static::getTableName())
->whereEquals($column, $value)
->query();
} | [
"final",
"public",
"function",
"fetchByColumn",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"select",
"=",
"'*'",
")",
"{",
"$",
"this",
"->",
"validateShortcutData",
"(",
")",
";",
"return",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"$",
"s... | Fetches single row a column
@param string $column The name of PK column
@param string $value The value of PK
@param mixed $select Data to be selected. By default all columns are selected
@return array | [
"Fetches",
"single",
"row",
"a",
"column"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L702-L710 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.deleteByColumn | final public function deleteByColumn($column, $value)
{
$this->validateShortcutData();
return $this->db->delete()
->from(static::getTableName())
->whereEquals($column, $value)
->execute();
} | php | final public function deleteByColumn($column, $value)
{
$this->validateShortcutData();
return $this->db->delete()
->from(static::getTableName())
->whereEquals($column, $value)
->execute();
} | [
"final",
"public",
"function",
"deleteByColumn",
"(",
"$",
"column",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"validateShortcutData",
"(",
")",
";",
"return",
"$",
"this",
"->",
"db",
"->",
"delete",
"(",
")",
"->",
"from",
"(",
"static",
"::",
... | Deletes a row by its associated PK
@param string PK's column
@param string PK's value
@return boolean | [
"Deletes",
"a",
"row",
"by",
"its",
"associated",
"PK"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L719-L727 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.countByColumn | final public function countByColumn($column, $value, $field = null)
{
$this->validateShortcutData();
$alias = 'count';
if ($field === null) {
$field = $this->getPk();
}
return (int) $this->db->select()
->count($field, $alias)
->from(static::getTableName())
->whereEquals($column, $value)
->query($alias);
} | php | final public function countByColumn($column, $value, $field = null)
{
$this->validateShortcutData();
$alias = 'count';
if ($field === null) {
$field = $this->getPk();
}
return (int) $this->db->select()
->count($field, $alias)
->from(static::getTableName())
->whereEquals($column, $value)
->query($alias);
} | [
"final",
"public",
"function",
"countByColumn",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"field",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"validateShortcutData",
"(",
")",
";",
"$",
"alias",
"=",
"'count'",
";",
"if",
"(",
"$",
"field",
"==... | Counts by provided column's value
@param string $column
@param string $value
@param string $field Field to be counted. By default the value of PK is taken
@return integer | [
"Counts",
"by",
"provided",
"column",
"s",
"value"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L737-L751 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.incrementColumnByPk | final public function incrementColumnByPk($pk, $column, $step = 1, $table = null)
{
return $this->db->increment($this->getTable($table), $column, $step)
->whereEquals($this->getPk(), $pk)
->execute();
} | php | final public function incrementColumnByPk($pk, $column, $step = 1, $table = null)
{
return $this->db->increment($this->getTable($table), $column, $step)
->whereEquals($this->getPk(), $pk)
->execute();
} | [
"final",
"public",
"function",
"incrementColumnByPk",
"(",
"$",
"pk",
",",
"$",
"column",
",",
"$",
"step",
"=",
"1",
",",
"$",
"table",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"increment",
"(",
"$",
"this",
"->",
"getTable",
... | Increments column's value by associated PK's value
@param string $pk PK's value
@param string $column Target column
@param integer $step
@param string $table Optionally current table can be overridden
@return boolean | [
"Increments",
"column",
"s",
"value",
"by",
"associated",
"PK",
"s",
"value"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L762-L767 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.decrementColumnByPk | final public function decrementColumnByPk($pk, $column, $step = 1, $table = null)
{
return $this->db->decrement($this->getTable($table), $column, $step)
->whereEquals($this->getPk(), $pk)
->execute();
} | php | final public function decrementColumnByPk($pk, $column, $step = 1, $table = null)
{
return $this->db->decrement($this->getTable($table), $column, $step)
->whereEquals($this->getPk(), $pk)
->execute();
} | [
"final",
"public",
"function",
"decrementColumnByPk",
"(",
"$",
"pk",
",",
"$",
"column",
",",
"$",
"step",
"=",
"1",
",",
"$",
"table",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"decrement",
"(",
"$",
"this",
"->",
"getTable",
... | Decrements column's value by associated PK's value
@param string $pk PK's value
@param string $column Target column
@param integer $step
@param string $table Optionally current table can be overridden
@return boolean | [
"Decrements",
"column",
"s",
"value",
"by",
"associated",
"PK",
"s",
"value"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L778-L783 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.dropTables | final public function dropTables(array $tables, $fkChecks = false)
{
// Whether FK checks are enabled
if ($fkChecks == false) {
$this->db->raw('SET FOREIGN_KEY_CHECKS=0')
->execute();
}
foreach ($tables as $table) {
if (!$this->dropTable($table)) {
return false;
}
}
// Whether FK checks are enabled
if ($fkChecks == false) {
$this->db->raw('SET FOREIGN_KEY_CHECKS=1')
->execute();
}
return true;
} | php | final public function dropTables(array $tables, $fkChecks = false)
{
// Whether FK checks are enabled
if ($fkChecks == false) {
$this->db->raw('SET FOREIGN_KEY_CHECKS=0')
->execute();
}
foreach ($tables as $table) {
if (!$this->dropTable($table)) {
return false;
}
}
// Whether FK checks are enabled
if ($fkChecks == false) {
$this->db->raw('SET FOREIGN_KEY_CHECKS=1')
->execute();
}
return true;
} | [
"final",
"public",
"function",
"dropTables",
"(",
"array",
"$",
"tables",
",",
"$",
"fkChecks",
"=",
"false",
")",
"{",
"// Whether FK checks are enabled",
"if",
"(",
"$",
"fkChecks",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"raw",
"(",
"'... | Drop several tables at once
@param array $tables
@param boolean $fkChecks Whether to enabled Foreign Key checks
@return boolean | [
"Drop",
"several",
"tables",
"at",
"once"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L806-L827 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.dropColumn | public function dropColumn($column, $table = null)
{
return $this->db->alterTable($this->getTable($table))
->dropColumn($column)
->execute();
} | php | public function dropColumn($column, $table = null)
{
return $this->db->alterTable($this->getTable($table))
->dropColumn($column)
->execute();
} | [
"public",
"function",
"dropColumn",
"(",
"$",
"column",
",",
"$",
"table",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"alterTable",
"(",
"$",
"this",
"->",
"getTable",
"(",
"$",
"table",
")",
")",
"->",
"dropColumn",
"(",
"$",
... | Drops a column
@param string $column Column name
@param string $table Table name. By default it uses mapper's table
@return boolean | [
"Drops",
"a",
"column"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L851-L856 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.renameColumn | public function renameColumn($old, $new, $table = null)
{
return $this->db->alterTable($this->getTable($table))
->renameColumn($old, $new)
->execute();
} | php | public function renameColumn($old, $new, $table = null)
{
return $this->db->alterTable($this->getTable($table))
->renameColumn($old, $new)
->execute();
} | [
"public",
"function",
"renameColumn",
"(",
"$",
"old",
",",
"$",
"new",
",",
"$",
"table",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"alterTable",
"(",
"$",
"this",
"->",
"getTable",
"(",
"$",
"table",
")",
")",
"->",
"renameC... | Renames a column
@param string $old Old name
@param string $new New name
@param string $table Table name. By default it uses mapper's table
@return boolean | [
"Renames",
"a",
"column"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L866-L871 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.createIndex | public function createIndex($name, $target, $unique = false, $table = null)
{
return $this->db->createIndex($table, $name, $target, $unique)
->execute();
} | php | public function createIndex($name, $target, $unique = false, $table = null)
{
return $this->db->createIndex($table, $name, $target, $unique)
->execute();
} | [
"public",
"function",
"createIndex",
"(",
"$",
"name",
",",
"$",
"target",
",",
"$",
"unique",
"=",
"false",
",",
"$",
"table",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"createIndex",
"(",
"$",
"table",
",",
"$",
"name",
",",... | Creates an INDEX
@param string $name Index name
@param string|array $target Column name or collection of ones
@param boolean $unique Whether it should be unique or not
@param string $table Table name. By default it uses mapper's table
@return boolean | [
"Creates",
"an",
"INDEX"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L897-L901 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.dropIndex | public function dropIndex($name, $table = null)
{
return $this->db->dropIndex($table, $name)
->execute();
} | php | public function dropIndex($name, $table = null)
{
return $this->db->dropIndex($table, $name)
->execute();
} | [
"public",
"function",
"dropIndex",
"(",
"$",
"name",
",",
"$",
"table",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"dropIndex",
"(",
"$",
"table",
",",
"$",
"name",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Drops an INDEX
@param string $name Index name
@param string $table Table name. By default it uses mapper's table
@return boolean | [
"Drops",
"an",
"INDEX"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L910-L914 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.addPrimaryKey | public function addPrimaryKey($name, $target, $table = null)
{
return $this->db->alterTable($this->getTable($table))
->addConstraint($name)
->primaryKey($target)
->execute();
} | php | public function addPrimaryKey($name, $target, $table = null)
{
return $this->db->alterTable($this->getTable($table))
->addConstraint($name)
->primaryKey($target)
->execute();
} | [
"public",
"function",
"addPrimaryKey",
"(",
"$",
"name",
",",
"$",
"target",
",",
"$",
"table",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"alterTable",
"(",
"$",
"this",
"->",
"getTable",
"(",
"$",
"table",
")",
")",
"->",
"ad... | Adds a primary key
@param string $name PK's name
@param string|array $target Column name or collection of ones
@param string $table Table name. By default it uses mapper's table
@return boolean | [
"Adds",
"a",
"primary",
"key"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L924-L930 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.dropPrimaryKey | public function dropPrimaryKey($name, $table = null)
{
return $this->db->alterTable($this->getTable($table))
->dropConstraint($name)
->execute();
} | php | public function dropPrimaryKey($name, $table = null)
{
return $this->db->alterTable($this->getTable($table))
->dropConstraint($name)
->execute();
} | [
"public",
"function",
"dropPrimaryKey",
"(",
"$",
"name",
",",
"$",
"table",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"alterTable",
"(",
"$",
"this",
"->",
"getTable",
"(",
"$",
"table",
")",
")",
"->",
"dropConstraint",
"(",
"... | Drops a primary key
@param string $name PK's name
@param string $table Table name. By default it uses mapper's table
@return boolean | [
"Drops",
"a",
"primary",
"key"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L939-L944 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/AbstractMapper.php | AbstractMapper.getMaxId | public function getMaxId()
{
$column = $this->getPk();
return $this->db->select($column)
->from(static::getTableName())
->orderBy($column)
->desc()
->limit(1)
->query($column);
} | php | public function getMaxId()
{
$column = $this->getPk();
return $this->db->select($column)
->from(static::getTableName())
->orderBy($column)
->desc()
->limit(1)
->query($column);
} | [
"public",
"function",
"getMaxId",
"(",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getPk",
"(",
")",
";",
"return",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"$",
"column",
")",
"->",
"from",
"(",
"static",
"::",
"getTableName",
"(",
")",... | Returns maximal id
@return integer | [
"Returns",
"maximal",
"id"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/AbstractMapper.php#L951-L961 | train |
droath/project-x | src/Project/ProjectType.php | ProjectType.installRoot | public static function installRoot()
{
$install_root = ProjectX::getProjectConfig()
->getRoot();
// Ensure a forward slash has been added to the install root.
$install_root = substr($install_root, 0, 1) != '/'
? "/{$install_root}"
: $install_root;
if (isset($install_root) && !empty($install_root)) {
return $install_root;
}
return static::INSTALL_ROOT;
} | php | public static function installRoot()
{
$install_root = ProjectX::getProjectConfig()
->getRoot();
// Ensure a forward slash has been added to the install root.
$install_root = substr($install_root, 0, 1) != '/'
? "/{$install_root}"
: $install_root;
if (isset($install_root) && !empty($install_root)) {
return $install_root;
}
return static::INSTALL_ROOT;
} | [
"public",
"static",
"function",
"installRoot",
"(",
")",
"{",
"$",
"install_root",
"=",
"ProjectX",
"::",
"getProjectConfig",
"(",
")",
"->",
"getRoot",
"(",
")",
";",
"// Ensure a forward slash has been added to the install root.",
"$",
"install_root",
"=",
"substr",... | Project current install root. | [
"Project",
"current",
"install",
"root",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/ProjectType.php#L54-L69 | train |
droath/project-x | src/Project/ProjectType.php | ProjectType.getInstallRoot | public function getInstallRoot($strip_slash = false)
{
$install_root = static::installRoot();
return $strip_slash === false
? $install_root
: substr($install_root, 1);
} | php | public function getInstallRoot($strip_slash = false)
{
$install_root = static::installRoot();
return $strip_slash === false
? $install_root
: substr($install_root, 1);
} | [
"public",
"function",
"getInstallRoot",
"(",
"$",
"strip_slash",
"=",
"false",
")",
"{",
"$",
"install_root",
"=",
"static",
"::",
"installRoot",
"(",
")",
";",
"return",
"$",
"strip_slash",
"===",
"false",
"?",
"$",
"install_root",
":",
"substr",
"(",
"$"... | Get project current install root.
@param bool $strip_slash
Strip the the beginning slash from the install root.
@return string | [
"Get",
"project",
"current",
"install",
"root",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/ProjectType.php#L79-L86 | train |
droath/project-x | src/Project/ProjectType.php | ProjectType.onDeployBuild | public function onDeployBuild($build_root)
{
$install_root = $build_root . static::installRoot();
if (!file_exists($install_root)) {
$this->_mkdir($install_root);
}
} | php | public function onDeployBuild($build_root)
{
$install_root = $build_root . static::installRoot();
if (!file_exists($install_root)) {
$this->_mkdir($install_root);
}
} | [
"public",
"function",
"onDeployBuild",
"(",
"$",
"build_root",
")",
"{",
"$",
"install_root",
"=",
"$",
"build_root",
".",
"static",
"::",
"installRoot",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"install_root",
")",
")",
"{",
"$",
"this",
... | React on the deploy build.
@param $build_root
The build root directory. | [
"React",
"on",
"the",
"deploy",
"build",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/ProjectType.php#L146-L153 | train |
droath/project-x | src/Project/ProjectType.php | ProjectType.setupProjectFilesystem | public function setupProjectFilesystem()
{
$this->taskFilesystemStack()
->chmod(ProjectX::projectRoot(), 0775)
->mkdir($this->getInstallPath(), 0775)
->run();
return $this;
} | php | public function setupProjectFilesystem()
{
$this->taskFilesystemStack()
->chmod(ProjectX::projectRoot(), 0775)
->mkdir($this->getInstallPath(), 0775)
->run();
return $this;
} | [
"public",
"function",
"setupProjectFilesystem",
"(",
")",
"{",
"$",
"this",
"->",
"taskFilesystemStack",
"(",
")",
"->",
"chmod",
"(",
"ProjectX",
"::",
"projectRoot",
"(",
")",
",",
"0775",
")",
"->",
"mkdir",
"(",
"$",
"this",
"->",
"getInstallPath",
"("... | Setup project filesystem.
The setup process consist of the following:
- Update project root permission.
- Make project install directory.
@return self | [
"Setup",
"project",
"filesystem",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/ProjectType.php#L190-L198 | train |
droath/project-x | src/Project/ProjectType.php | ProjectType.getProjectOptionByKey | public function getProjectOptionByKey($key)
{
$options = $this->getProjectOptions();
if (!isset($options[$key])) {
return false;
}
return $options[$key];
} | php | public function getProjectOptionByKey($key)
{
$options = $this->getProjectOptions();
if (!isset($options[$key])) {
return false;
}
return $options[$key];
} | [
"public",
"function",
"getProjectOptionByKey",
"(",
"$",
"key",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getProjectOptions",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"false"... | Get project option by key.
@param string $key
The unique key for the option.
@return mixed|bool
The set value for the given project option key; otherwise FALSE. | [
"Get",
"project",
"option",
"by",
"key",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/ProjectType.php#L239-L248 | train |
droath/project-x | src/Project/ProjectType.php | ProjectType.createSymbolicLinksOnProject | public function createSymbolicLinksOnProject(array $options)
{
$project_root = ProjectX::projectRoot();
$excludes = isset($options['excludes'])
? $options['excludes']
: [];
$includes = isset($options['includes'])
? $options['includes']
: [];
$target_dir = isset($options['target_dir'])
? $options['target_dir']
: null;
$source_dir = isset($options['source_dir'])
? $options['source_dir']
: $project_root;
$symlink_command = new SymlinkCommand();
/** @var SplFileInfo $file_info */
foreach (new \FilesystemIterator($project_root, \FilesystemIterator::SKIP_DOTS) as $file_info) {
$filename = $file_info->getFilename();
if (strpos($filename, '.') === 0
|| in_array($filename, $excludes)) {
continue;
}
if (!empty($includes) && !in_array($filename, $includes)) {
continue;
}
$symlink_command->link("{$source_dir}/{$filename}", "{$target_dir}/{$filename}");
}
return $symlink_command;
} | php | public function createSymbolicLinksOnProject(array $options)
{
$project_root = ProjectX::projectRoot();
$excludes = isset($options['excludes'])
? $options['excludes']
: [];
$includes = isset($options['includes'])
? $options['includes']
: [];
$target_dir = isset($options['target_dir'])
? $options['target_dir']
: null;
$source_dir = isset($options['source_dir'])
? $options['source_dir']
: $project_root;
$symlink_command = new SymlinkCommand();
/** @var SplFileInfo $file_info */
foreach (new \FilesystemIterator($project_root, \FilesystemIterator::SKIP_DOTS) as $file_info) {
$filename = $file_info->getFilename();
if (strpos($filename, '.') === 0
|| in_array($filename, $excludes)) {
continue;
}
if (!empty($includes) && !in_array($filename, $includes)) {
continue;
}
$symlink_command->link("{$source_dir}/{$filename}", "{$target_dir}/{$filename}");
}
return $symlink_command;
} | [
"public",
"function",
"createSymbolicLinksOnProject",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"project_root",
"=",
"ProjectX",
"::",
"projectRoot",
"(",
")",
";",
"$",
"excludes",
"=",
"isset",
"(",
"$",
"options",
"[",
"'excludes'",
"]",
")",
"?",
"$... | Create symbolic links on project.
@param array $options
@return SymlinkCommand | [
"Create",
"symbolic",
"links",
"on",
"project",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/ProjectType.php#L289-L328 | train |
droath/project-x | src/Project/ProjectType.php | ProjectType.canBuild | protected function canBuild()
{
$rebuild = false;
if ($this->isBuilt()) {
$rebuild = $this->askConfirmQuestion(
'Project has already been built, do you want to rebuild?',
false
);
if (!$rebuild) {
return static::BUILD_ABORT;
}
}
return !$rebuild ? static::BUILD_FRESH : static::BUILD_DIRTY;
} | php | protected function canBuild()
{
$rebuild = false;
if ($this->isBuilt()) {
$rebuild = $this->askConfirmQuestion(
'Project has already been built, do you want to rebuild?',
false
);
if (!$rebuild) {
return static::BUILD_ABORT;
}
}
return !$rebuild ? static::BUILD_FRESH : static::BUILD_DIRTY;
} | [
"protected",
"function",
"canBuild",
"(",
")",
"{",
"$",
"rebuild",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isBuilt",
"(",
")",
")",
"{",
"$",
"rebuild",
"=",
"$",
"this",
"->",
"askConfirmQuestion",
"(",
"'Project has already been built, do you wa... | Can project run it's build process.
@return int
Return the build status. | [
"Can",
"project",
"run",
"it",
"s",
"build",
"process",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/ProjectType.php#L344-L360 | train |
droath/project-x | src/Project/ProjectType.php | ProjectType.getProjectOptions | protected function getProjectOptions()
{
$config = ProjectX::getProjectConfig();
$type = $config->getType();
$options = $config->getOptions();
return isset($options[$type])
? $options[$type]
: [];
} | php | protected function getProjectOptions()
{
$config = ProjectX::getProjectConfig();
$type = $config->getType();
$options = $config->getOptions();
return isset($options[$type])
? $options[$type]
: [];
} | [
"protected",
"function",
"getProjectOptions",
"(",
")",
"{",
"$",
"config",
"=",
"ProjectX",
"::",
"getProjectConfig",
"(",
")",
";",
"$",
"type",
"=",
"$",
"config",
"->",
"getType",
"(",
")",
";",
"$",
"options",
"=",
"$",
"config",
"->",
"getOptions",... | Get project options.
@return array
An array of project options defined in the Project-X configuration. | [
"Get",
"project",
"options",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/ProjectType.php#L421-L431 | train |
krystal-framework/krystal.framework | src/Krystal/Widget/Pagination/PaginationMaker.php | PaginationMaker.render | public function render()
{
// Run only in case paginator has at least one page
if ($this->paginator->hasPages()) {
$ulClass = $this->getOption('ulClass', 'pagination');
return $this->renderList($ulClass, $this->createPaginationItems());
}
} | php | public function render()
{
// Run only in case paginator has at least one page
if ($this->paginator->hasPages()) {
$ulClass = $this->getOption('ulClass', 'pagination');
return $this->renderList($ulClass, $this->createPaginationItems());
}
} | [
"public",
"function",
"render",
"(",
")",
"{",
"// Run only in case paginator has at least one page",
"if",
"(",
"$",
"this",
"->",
"paginator",
"->",
"hasPages",
"(",
")",
")",
"{",
"$",
"ulClass",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'ulClass'",
",",
... | Renders pagination block
@return string | [
"Renders",
"pagination",
"block"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Widget/Pagination/PaginationMaker.php#L44-L51 | train |
krystal-framework/krystal.framework | src/Krystal/Widget/Pagination/PaginationMaker.php | PaginationMaker.createPaginationItems | private function createPaginationItems()
{
// Grab overrides if present
$linkClass = $this->getOption('linkClass', 'page-link');
$itemClass = $this->getOption('itemClass', 'page-item');
$itemActiveClass = $this->getOption('itemActiveClass', 'page-item active');
$previousCaption = ' « ' . $this->getOption('previousCaption', '');
$nextCaption = $this->getOption('nextCaption', '') . ' » ';
// To be returned
$items = array();
// First - check if first previous page available
if ($this->paginator->hasPreviousPage()) {
$items[] = $this->createListItem($itemClass, $this->renderLink($previousCaption, $this->paginator->getPreviousPageUrl(), $linkClass));
}
foreach ($this->paginator->getPageNumbers() as $page) {
if (is_numeric($page)) {
$currentClass = $this->paginator->isCurrentPage($page) ? $itemActiveClass : $itemClass;
$items[] = $this->createListItem($currentClass, $this->renderLink($page, $this->paginator->getUrl($page), $linkClass));
} else {
$items[] = $this->createListItem($itemClass, $this->renderLink($page, '#', $linkClass));
}
}
// Last - check if next page available
if ($this->paginator->hasNextPage()) {
$items[] = $this->createListItem($itemClass, $this->renderLink($nextCaption, $this->paginator->getNextPageUrl(), $linkClass));
}
return $items;
} | php | private function createPaginationItems()
{
// Grab overrides if present
$linkClass = $this->getOption('linkClass', 'page-link');
$itemClass = $this->getOption('itemClass', 'page-item');
$itemActiveClass = $this->getOption('itemActiveClass', 'page-item active');
$previousCaption = ' « ' . $this->getOption('previousCaption', '');
$nextCaption = $this->getOption('nextCaption', '') . ' » ';
// To be returned
$items = array();
// First - check if first previous page available
if ($this->paginator->hasPreviousPage()) {
$items[] = $this->createListItem($itemClass, $this->renderLink($previousCaption, $this->paginator->getPreviousPageUrl(), $linkClass));
}
foreach ($this->paginator->getPageNumbers() as $page) {
if (is_numeric($page)) {
$currentClass = $this->paginator->isCurrentPage($page) ? $itemActiveClass : $itemClass;
$items[] = $this->createListItem($currentClass, $this->renderLink($page, $this->paginator->getUrl($page), $linkClass));
} else {
$items[] = $this->createListItem($itemClass, $this->renderLink($page, '#', $linkClass));
}
}
// Last - check if next page available
if ($this->paginator->hasNextPage()) {
$items[] = $this->createListItem($itemClass, $this->renderLink($nextCaption, $this->paginator->getNextPageUrl(), $linkClass));
}
return $items;
} | [
"private",
"function",
"createPaginationItems",
"(",
")",
"{",
"// Grab overrides if present",
"$",
"linkClass",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'linkClass'",
",",
"'page-link'",
")",
";",
"$",
"itemClass",
"=",
"$",
"this",
"->",
"getOption",
"(",
... | Create navigation items
@return array | [
"Create",
"navigation",
"items"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Widget/Pagination/PaginationMaker.php#L58-L90 | train |
i-lateral/silverstripe-checkout | code/control/Payment_Controller.php | Payment_Controller.callback | public function callback($request)
{
// If post data exists, process. Otherwise provide error
if ($this->payment_handler === null) {
// Redirect to error page
return $this->redirect(Controller::join_links(
Director::BaseURL(),
$this->config()->url_segment,
'complete',
'error'
));
}
// Hand the request over to the payment handler
return $this
->payment_handler
->handleRequest($request, $this->model);
} | php | public function callback($request)
{
// If post data exists, process. Otherwise provide error
if ($this->payment_handler === null) {
// Redirect to error page
return $this->redirect(Controller::join_links(
Director::BaseURL(),
$this->config()->url_segment,
'complete',
'error'
));
}
// Hand the request over to the payment handler
return $this
->payment_handler
->handleRequest($request, $this->model);
} | [
"public",
"function",
"callback",
"(",
"$",
"request",
")",
"{",
"// If post data exists, process. Otherwise provide error",
"if",
"(",
"$",
"this",
"->",
"payment_handler",
"===",
"null",
")",
"{",
"// Redirect to error page",
"return",
"$",
"this",
"->",
"redirect",... | This method can be called by a payment gateway to provide
automated integration.
This action performs some basic setup then hands control directly
to the payment handler's "callback" action.
@param $request Current Request Object | [
"This",
"method",
"can",
"be",
"called",
"by",
"a",
"payment",
"gateway",
"to",
"provide",
"automated",
"integration",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/Payment_Controller.php#L240-L257 | train |
fxpio/fxp-bootstrap | Block/DataSource/DataSourceConfig.php | DataSourceConfig.addColumn | public function addColumn(BlockInterface $column, $index = null)
{
$this->mappingColumns = null;
if (null !== $index) {
array_splice($this->columns, $index, 0, $column);
} else {
array_push($this->columns, $column);
}
return $this;
} | php | public function addColumn(BlockInterface $column, $index = null)
{
$this->mappingColumns = null;
if (null !== $index) {
array_splice($this->columns, $index, 0, $column);
} else {
array_push($this->columns, $column);
}
return $this;
} | [
"public",
"function",
"addColumn",
"(",
"BlockInterface",
"$",
"column",
",",
"$",
"index",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"mappingColumns",
"=",
"null",
";",
"if",
"(",
"null",
"!==",
"$",
"index",
")",
"{",
"array_splice",
"(",
"$",
"this"... | Add column.
@param BlockInterface $column
@param int $index
@return self | [
"Add",
"column",
"."
] | 4ff1408018c71d18b6951b1f8d7c5ad0b684eadb | https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSourceConfig.php#L112-L123 | train |
fxpio/fxp-bootstrap | Block/DataSource/DataSourceConfig.php | DataSourceConfig.removeColumn | public function removeColumn($index)
{
$this->mappingColumns = null;
array_splice($this->columns, $index, 1);
return $this;
} | php | public function removeColumn($index)
{
$this->mappingColumns = null;
array_splice($this->columns, $index, 1);
return $this;
} | [
"public",
"function",
"removeColumn",
"(",
"$",
"index",
")",
"{",
"$",
"this",
"->",
"mappingColumns",
"=",
"null",
";",
"array_splice",
"(",
"$",
"this",
"->",
"columns",
",",
"$",
"index",
",",
"1",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Remove column.
@param int $index
@return self | [
"Remove",
"column",
"."
] | 4ff1408018c71d18b6951b1f8d7c5ad0b684eadb | https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSourceConfig.php#L132-L138 | train |
fxpio/fxp-bootstrap | Block/DataSource/DataSourceConfig.php | DataSourceConfig.setSortColumns | public function setSortColumns(array $columns)
{
$this->sortColumns = [];
$this->mappingSortColumns = [];
foreach ($columns as $i => $column) {
if (!isset($column['name'])) {
throw new InvalidArgumentException('The "name" property of sort column must be present ("sort" property is optional)');
}
if (isset($column['sort']) && 'asc' !== $column['sort'] && 'desc' !== $column['sort']) {
throw new InvalidArgumentException('The "sort" property of sort column must have "asc" or "desc" value');
}
if ($this->isSorted($column['name'])) {
throw new InvalidArgumentException(sprintf('The "%s" column is already sorted', $column['name']));
}
$this->sortColumns[] = $column;
$this->mappingSortColumns[$column['name']] = $i;
}
return $this;
} | php | public function setSortColumns(array $columns)
{
$this->sortColumns = [];
$this->mappingSortColumns = [];
foreach ($columns as $i => $column) {
if (!isset($column['name'])) {
throw new InvalidArgumentException('The "name" property of sort column must be present ("sort" property is optional)');
}
if (isset($column['sort']) && 'asc' !== $column['sort'] && 'desc' !== $column['sort']) {
throw new InvalidArgumentException('The "sort" property of sort column must have "asc" or "desc" value');
}
if ($this->isSorted($column['name'])) {
throw new InvalidArgumentException(sprintf('The "%s" column is already sorted', $column['name']));
}
$this->sortColumns[] = $column;
$this->mappingSortColumns[$column['name']] = $i;
}
return $this;
} | [
"public",
"function",
"setSortColumns",
"(",
"array",
"$",
"columns",
")",
"{",
"$",
"this",
"->",
"sortColumns",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"mappingSortColumns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"i",
"=>",
"... | Set sort columns.
@param array $columns
@return self | [
"Set",
"sort",
"columns",
"."
] | 4ff1408018c71d18b6951b1f8d7c5ad0b684eadb | https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSourceConfig.php#L157-L180 | train |
fxpio/fxp-bootstrap | Block/DataSource/DataSourceConfig.php | DataSourceConfig.getSortColumn | public function getSortColumn($column)
{
$val = null;
if ($this->isSorted($column)) {
$def = $this->sortColumns[$this->mappingSortColumns[$column]];
if (isset($def['sort'])) {
$val = $def['sort'];
}
}
return $val;
} | php | public function getSortColumn($column)
{
$val = null;
if ($this->isSorted($column)) {
$def = $this->sortColumns[$this->mappingSortColumns[$column]];
if (isset($def['sort'])) {
$val = $def['sort'];
}
}
return $val;
} | [
"public",
"function",
"getSortColumn",
"(",
"$",
"column",
")",
"{",
"$",
"val",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"isSorted",
"(",
"$",
"column",
")",
")",
"{",
"$",
"def",
"=",
"$",
"this",
"->",
"sortColumns",
"[",
"$",
"this",
"... | Get sort column.
@param string $column The column name
@return string|null | [
"Get",
"sort",
"column",
"."
] | 4ff1408018c71d18b6951b1f8d7c5ad0b684eadb | https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSourceConfig.php#L199-L212 | train |
fxpio/fxp-bootstrap | Block/DataSource/DataSourceConfig.php | DataSourceConfig.getColumnIndex | public function getColumnIndex($name)
{
if (!\is_array($this->mappingColumns)) {
$this->mappingColumns = [];
/* @var BlockInterface $column */
foreach ($this->getColumns() as $i => $column) {
$this->mappingColumns[$column->getName()] = $i;
}
}
if (isset($this->mappingColumns[$name])) {
$column = $this->columns[$this->mappingColumns[$name]];
return $column->getOption('index');
}
throw new InvalidArgumentException(sprintf('The column name "%s" does not exist', $name));
} | php | public function getColumnIndex($name)
{
if (!\is_array($this->mappingColumns)) {
$this->mappingColumns = [];
/* @var BlockInterface $column */
foreach ($this->getColumns() as $i => $column) {
$this->mappingColumns[$column->getName()] = $i;
}
}
if (isset($this->mappingColumns[$name])) {
$column = $this->columns[$this->mappingColumns[$name]];
return $column->getOption('index');
}
throw new InvalidArgumentException(sprintf('The column name "%s" does not exist', $name));
} | [
"public",
"function",
"getColumnIndex",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"mappingColumns",
")",
")",
"{",
"$",
"this",
"->",
"mappingColumns",
"=",
"[",
"]",
";",
"/* @var BlockInterface $column */",
"fo... | Return the index name of column.
@param string $name
@return string The index
@throws InvalidArgumentException When column does not exit | [
"Return",
"the",
"index",
"name",
"of",
"column",
"."
] | 4ff1408018c71d18b6951b1f8d7c5ad0b684eadb | https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/DataSource/DataSourceConfig.php#L259-L277 | train |
Droeftoeter/pokapi | src/Pokapi/Authentication/TrainersClub.php | TrainersClub.fetchExecutionToken | protected function fetchExecutionToken()
{
try {
$response = $this->client->get(static::LOGIN_URL, [
'headers' => [
'User-Agent' => 'niantic'
]
]);
} catch(ServerException $e) {
sleep(1);
return $this->fetchExecutionToken();
}
if ($response->getStatusCode() !== 200) {
throw new AuthenticationException("Could not retrieve execution token. Got status code " . $response->getStatusCode());
}
$jsonData = json_decode($response->getBody()->getContents());
if (!$jsonData || !isset($jsonData->execution)) {
throw new AuthenticationException("Could not retrieve execution token. Invalid JSON. TrainersClub could be offline or unstable.");
}
return $jsonData;
} | php | protected function fetchExecutionToken()
{
try {
$response = $this->client->get(static::LOGIN_URL, [
'headers' => [
'User-Agent' => 'niantic'
]
]);
} catch(ServerException $e) {
sleep(1);
return $this->fetchExecutionToken();
}
if ($response->getStatusCode() !== 200) {
throw new AuthenticationException("Could not retrieve execution token. Got status code " . $response->getStatusCode());
}
$jsonData = json_decode($response->getBody()->getContents());
if (!$jsonData || !isset($jsonData->execution)) {
throw new AuthenticationException("Could not retrieve execution token. Invalid JSON. TrainersClub could be offline or unstable.");
}
return $jsonData;
} | [
"protected",
"function",
"fetchExecutionToken",
"(",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"static",
"::",
"LOGIN_URL",
",",
"[",
"'headers'",
"=>",
"[",
"'User-Agent'",
"=>",
"'niantic'",
"]",
"]",
")... | Get data we need
@return mixed
@throws \Exception | [
"Get",
"data",
"we",
"need"
] | 3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3 | https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Authentication/TrainersClub.php#L143-L167 | train |
cleaniquecoders/artisan-makers | src/Console/Commands/MakeObserverCommand.php | MakeObserverCommand.registerObserverServiceProvider | public function registerObserverServiceProvider()
{
if (! $this->files->exists(app_path('Providers/ObserverServiceProvider.php'))) {
$this->call('make:provider', [
'name' => 'ObserverServiceProvider',
]);
$this->info('Please register your ObserverServiceProvider in config/app.php.');
$this->info('Do run php artisan config:cache to make sure ObserverServiceProvider is loaded.');
} else {
$this->info(app_path('Providers/ObserverServiceProvider.php') . ' already exist.');
}
} | php | public function registerObserverServiceProvider()
{
if (! $this->files->exists(app_path('Providers/ObserverServiceProvider.php'))) {
$this->call('make:provider', [
'name' => 'ObserverServiceProvider',
]);
$this->info('Please register your ObserverServiceProvider in config/app.php.');
$this->info('Do run php artisan config:cache to make sure ObserverServiceProvider is loaded.');
} else {
$this->info(app_path('Providers/ObserverServiceProvider.php') . ' already exist.');
}
} | [
"public",
"function",
"registerObserverServiceProvider",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"app_path",
"(",
"'Providers/ObserverServiceProvider.php'",
")",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'make:prov... | Register Observer Service Provider.
@void | [
"Register",
"Observer",
"Service",
"Provider",
"."
] | fb332240008dd520dfd3a67f2e7aec3071144613 | https://github.com/cleaniquecoders/artisan-makers/blob/fb332240008dd520dfd3a67f2e7aec3071144613/src/Console/Commands/MakeObserverCommand.php#L60-L71 | train |
wpfulcrum/extender | src/Extender/Arr/FilterArray.php | FilterArray.addElementToFilteredArray | protected static function addElementToFilteredArray($key, $value)
{
if (is_null(self::$filteringCallback)) {
return ($value);
}
if (is_string(self::$filteringCallback) && function_exists(self::$filteringCallback)) {
$callback = self::$filteringCallback;
return $callback($key, $value);
}
return call_user_func(self::$filteringCallback, $key, $value);
} | php | protected static function addElementToFilteredArray($key, $value)
{
if (is_null(self::$filteringCallback)) {
return ($value);
}
if (is_string(self::$filteringCallback) && function_exists(self::$filteringCallback)) {
$callback = self::$filteringCallback;
return $callback($key, $value);
}
return call_user_func(self::$filteringCallback, $key, $value);
} | [
"protected",
"static",
"function",
"addElementToFilteredArray",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"filteringCallback",
")",
")",
"{",
"return",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"is_s... | Invoke the callback to check if the current element should be
added to the resultant filtered array.
@since 3.0.0
@param string $key
@param mixed $value
@return bool | [
"Invoke",
"the",
"callback",
"to",
"check",
"if",
"the",
"current",
"element",
"should",
"be",
"added",
"to",
"the",
"resultant",
"filtered",
"array",
"."
] | 96c9170d94959c0513c1d487bae2a67de6a20348 | https://github.com/wpfulcrum/extender/blob/96c9170d94959c0513c1d487bae2a67de6a20348/src/Extender/Arr/FilterArray.php#L36-L49 | train |
wpfulcrum/extender | src/Extender/Arr/FilterArray.php | FilterArray.filterStrings | protected static function filterStrings(array &$subjectArray, $goDeep = null, $filterFunction = null)
{
$arrayWalkFunction = self::getArrayWalkFunction($goDeep);
$arrayWalkFunction($subjectArray, function (&$item) use ($filterFunction) {
if (!is_string($item)) {
return;
}
if (is_callable($filterFunction)) {
$item = $filterFunction($item);
}
$item = trim($item);
});
return $subjectArray;
} | php | protected static function filterStrings(array &$subjectArray, $goDeep = null, $filterFunction = null)
{
$arrayWalkFunction = self::getArrayWalkFunction($goDeep);
$arrayWalkFunction($subjectArray, function (&$item) use ($filterFunction) {
if (!is_string($item)) {
return;
}
if (is_callable($filterFunction)) {
$item = $filterFunction($item);
}
$item = trim($item);
});
return $subjectArray;
} | [
"protected",
"static",
"function",
"filterStrings",
"(",
"array",
"&",
"$",
"subjectArray",
",",
"$",
"goDeep",
"=",
"null",
",",
"$",
"filterFunction",
"=",
"null",
")",
"{",
"$",
"arrayWalkFunction",
"=",
"self",
"::",
"getArrayWalkFunction",
"(",
"$",
"go... | Filter the strings within the given array. Strings will be trimmed with
an optional filter function to process too.
@since 3.0.0
@param array $subjectArray Array to work on.
@param bool|null $goDeep Walk deeply through each level when true.
@param callable|null $filterFunction
@return array | [
"Filter",
"the",
"strings",
"within",
"the",
"given",
"array",
".",
"Strings",
"will",
"be",
"trimmed",
"with",
"an",
"optional",
"filter",
"function",
"to",
"process",
"too",
"."
] | 96c9170d94959c0513c1d487bae2a67de6a20348 | https://github.com/wpfulcrum/extender/blob/96c9170d94959c0513c1d487bae2a67de6a20348/src/Extender/Arr/FilterArray.php#L133-L150 | train |
devgeniem/wp-readonly-options | plugin.php | ReadonlyOptions.init | static function init() {
// This can be overridden if something else feels better
self::$hover_text = 'This option is set readonly in ' . basename(__DIR__).'/'.basename(__FILE__);
// Use javascript hack in admin option pages
if ( is_admin() && ! defined('WP_READONLY_OPTIONS_NO_JS') ) {
add_action('admin_enqueue_scripts', [ __CLASS__, 'set_admin_readonly_js' ] );
}
} | php | static function init() {
// This can be overridden if something else feels better
self::$hover_text = 'This option is set readonly in ' . basename(__DIR__).'/'.basename(__FILE__);
// Use javascript hack in admin option pages
if ( is_admin() && ! defined('WP_READONLY_OPTIONS_NO_JS') ) {
add_action('admin_enqueue_scripts', [ __CLASS__, 'set_admin_readonly_js' ] );
}
} | [
"static",
"function",
"init",
"(",
")",
"{",
"// This can be overridden if something else feels better",
"self",
"::",
"$",
"hover_text",
"=",
"'This option is set readonly in '",
".",
"basename",
"(",
"__DIR__",
")",
".",
"'/'",
".",
"basename",
"(",
"__FILE__",
")",... | Setup hooks, filters and default options | [
"Setup",
"hooks",
"filters",
"and",
"default",
"options"
] | df1d6ffe3354b8799717dbcfd5668acaf37b57dc | https://github.com/devgeniem/wp-readonly-options/blob/df1d6ffe3354b8799717dbcfd5668acaf37b57dc/plugin.php#L30-L38 | train |
devgeniem/wp-readonly-options | plugin.php | ReadonlyOptions.set | static function set( array $options ) {
if ( is_array( $options ) ) {
// Force mentioned options with filters
foreach ( $options as $must_use_option => $must_use_value ) {
// Always return this value for the option
add_filter( "pre_option_{$must_use_option}", function() use ( $must_use_value ) {
return $must_use_value;
});
// Always deny saving this value to the DB
// wp-includes/option.php:280-291 stops updating this option if it's same
add_filter( "pre_update_option_{$must_use_option}", function() use ( $must_use_value ) {
return $must_use_value;
});
}
// Add to all options which can be used later on in admin_footer hook
self::add_options( $options );
}
} | php | static function set( array $options ) {
if ( is_array( $options ) ) {
// Force mentioned options with filters
foreach ( $options as $must_use_option => $must_use_value ) {
// Always return this value for the option
add_filter( "pre_option_{$must_use_option}", function() use ( $must_use_value ) {
return $must_use_value;
});
// Always deny saving this value to the DB
// wp-includes/option.php:280-291 stops updating this option if it's same
add_filter( "pre_update_option_{$must_use_option}", function() use ( $must_use_value ) {
return $must_use_value;
});
}
// Add to all options which can be used later on in admin_footer hook
self::add_options( $options );
}
} | [
"static",
"function",
"set",
"(",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"// Force mentioned options with filters",
"foreach",
"(",
"$",
"options",
"as",
"$",
"must_use_option",
"=>",
"$",
"must_use_value"... | Forces options from WP_READONLY_OPTIONS array to be predetermined
This is useful if some plugin doesn't allow defining options in wp-config.php
@param $options array - List of forced options | [
"Forces",
"options",
"from",
"WP_READONLY_OPTIONS",
"array",
"to",
"be",
"predetermined",
"This",
"is",
"useful",
"if",
"some",
"plugin",
"doesn",
"t",
"allow",
"defining",
"options",
"in",
"wp",
"-",
"config",
".",
"php"
] | df1d6ffe3354b8799717dbcfd5668acaf37b57dc | https://github.com/devgeniem/wp-readonly-options/blob/df1d6ffe3354b8799717dbcfd5668acaf37b57dc/plugin.php#L55-L77 | train |
Droeftoeter/pokapi | src/Pokapi/Rpc/AuthTicket.php | AuthTicket.fromProto | public static function fromProto(ProtoAuthTicket $ticket) : self
{
return new self($ticket->getStart()->getContents(), $ticket->getEnd()->getContents(), $ticket->getExpireTimestampMs());
} | php | public static function fromProto(ProtoAuthTicket $ticket) : self
{
return new self($ticket->getStart()->getContents(), $ticket->getEnd()->getContents(), $ticket->getExpireTimestampMs());
} | [
"public",
"static",
"function",
"fromProto",
"(",
"ProtoAuthTicket",
"$",
"ticket",
")",
":",
"self",
"{",
"return",
"new",
"self",
"(",
"$",
"ticket",
"->",
"getStart",
"(",
")",
"->",
"getContents",
"(",
")",
",",
"$",
"ticket",
"->",
"getEnd",
"(",
... | Create from prototicket
@param ProtoAuthTicket $ticket
@return AuthTicket | [
"Create",
"from",
"prototicket"
] | 3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3 | https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Rpc/AuthTicket.php#L75-L78 | train |
krystal-framework/krystal.framework | src/Krystal/Form/FlashBag.php | FlashBag.prepare | private function prepare()
{
if (!$this->storage->has(self::FLASH_KEY)) {
$this->storage->set(self::FLASH_KEY, array());
}
} | php | private function prepare()
{
if (!$this->storage->has(self::FLASH_KEY)) {
$this->storage->set(self::FLASH_KEY, array());
}
} | [
"private",
"function",
"prepare",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"storage",
"->",
"has",
"(",
"self",
"::",
"FLASH_KEY",
")",
")",
"{",
"$",
"this",
"->",
"storage",
"->",
"set",
"(",
"self",
"::",
"FLASH_KEY",
",",
"array",
"(",... | Prepares a messenger for usage
@return void | [
"Prepares",
"a",
"messenger",
"for",
"usage"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/FlashBag.php#L61-L66 | train |
krystal-framework/krystal.framework | src/Krystal/Form/FlashBag.php | FlashBag.has | public function has($key)
{
$flashMessages = $this->storage->get(self::FLASH_KEY);
return isset($flashMessages[$key]);
} | php | public function has($key)
{
$flashMessages = $this->storage->get(self::FLASH_KEY);
return isset($flashMessages[$key]);
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"flashMessages",
"=",
"$",
"this",
"->",
"storage",
"->",
"get",
"(",
"self",
"::",
"FLASH_KEY",
")",
";",
"return",
"isset",
"(",
"$",
"flashMessages",
"[",
"$",
"key",
"]",
")",
";",
"}... | Checks whether message key exists
@param string $key
@return boolean | [
"Checks",
"whether",
"message",
"key",
"exists"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/FlashBag.php#L84-L88 | train |
krystal-framework/krystal.framework | src/Krystal/Form/FlashBag.php | FlashBag.set | public function set($key, $message)
{
$this->storage->set(self::FLASH_KEY, array($key => $message));
return $this;
} | php | public function set($key, $message)
{
$this->storage->set(self::FLASH_KEY, array($key => $message));
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"storage",
"->",
"set",
"(",
"self",
"::",
"FLASH_KEY",
",",
"array",
"(",
"$",
"key",
"=>",
"$",
"message",
")",
")",
";",
"return",
"$",
"this",
";"... | Sets a message by given key name
@param string $key
@param string $message
@return \Krystal\Form\FlashMessenger | [
"Sets",
"a",
"message",
"by",
"given",
"key",
"name"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/FlashBag.php#L97-L101 | train |
krystal-framework/krystal.framework | src/Krystal/Form/FlashBag.php | FlashBag.get | public function get($key)
{
if ($this->has($key)) {
$flashMessages = $this->storage->get(self::FLASH_KEY);
$message = $flashMessages[$key];
$this->remove($key);
if ($this->translator instanceof TranslatorInterface) {
$message = $this->translator->translate($message);
}
return $message;
} else {
throw new RuntimeException(sprintf(
'Attempted to read non-existing key %s', $key
));
}
} | php | public function get($key)
{
if ($this->has($key)) {
$flashMessages = $this->storage->get(self::FLASH_KEY);
$message = $flashMessages[$key];
$this->remove($key);
if ($this->translator instanceof TranslatorInterface) {
$message = $this->translator->translate($message);
}
return $message;
} else {
throw new RuntimeException(sprintf(
'Attempted to read non-existing key %s', $key
));
}
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"flashMessages",
"=",
"$",
"this",
"->",
"storage",
"->",
"get",
"(",
"self",
"::",
"FLASH_KEY",
")",
";",
"$",
"m... | Returns a message associated with a given key
@param string $key
@throws \RuntimeException If attempted to read non-existing key
@return string | [
"Returns",
"a",
"message",
"associated",
"with",
"a",
"given",
"key"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/FlashBag.php#L121-L139 | train |
krystal-framework/krystal.framework | src/Krystal/InstanceManager/Factory.php | Factory.buildClassNameByFileName | final protected function buildClassNameByFileName($filename)
{
$className = sprintf('%s/%s', $this->getNamespace(), $filename);
// Normalize it
$className = str_replace(array('//', '/', '\\'), '\\', $className);
return $className;
} | php | final protected function buildClassNameByFileName($filename)
{
$className = sprintf('%s/%s', $this->getNamespace(), $filename);
// Normalize it
$className = str_replace(array('//', '/', '\\'), '\\', $className);
return $className;
} | [
"final",
"protected",
"function",
"buildClassNameByFileName",
"(",
"$",
"filename",
")",
"{",
"$",
"className",
"=",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"this",
"->",
"getNamespace",
"(",
")",
",",
"$",
"filename",
")",
";",
"// Normalize it",
"$",
"classNa... | Builds a classname according to defined pseudo-namespace
@param string $filename PSR-0 compliant name
@return string | [
"Builds",
"a",
"classname",
"according",
"to",
"defined",
"pseudo",
"-",
"namespace"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/InstanceManager/Factory.php#L50-L57 | train |
krystal-framework/krystal.framework | src/Krystal/InstanceManager/Factory.php | Factory.build | final public function build()
{
$arguments = func_get_args();
$filename = array_shift($arguments);
$className = $this->buildClassNameByFileName($filename);
$ib = new InstanceBuilder();
return $ib->build($className, $arguments);
} | php | final public function build()
{
$arguments = func_get_args();
$filename = array_shift($arguments);
$className = $this->buildClassNameByFileName($filename);
$ib = new InstanceBuilder();
return $ib->build($className, $arguments);
} | [
"final",
"public",
"function",
"build",
"(",
")",
"{",
"$",
"arguments",
"=",
"func_get_args",
"(",
")",
";",
"$",
"filename",
"=",
"array_shift",
"(",
"$",
"arguments",
")",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"buildClassNameByFileName",
"(",
... | Builds an instance
Heavily relies on PSR-0 autoloader
@param string $filename (Without extension and base path)
@param mixed $arguments [...]
@throws \RuntimeException if cannot load a class
@return object | [
"Builds",
"an",
"instance",
"Heavily",
"relies",
"on",
"PSR",
"-",
"0",
"autoloader"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/InstanceManager/Factory.php#L68-L77 | train |
krystal-framework/krystal.framework | src/Krystal/Tree/AdjacencyList/Render/AbstractRenderer.php | AbstractRenderer.hasParent | protected function hasParent($id, array $relationships)
{
foreach ($relationships as $parentId => $children) {
// 0 is reserved, therefore must be ignored
if ($parentId == 0) {
continue;
}
if (in_array($id, $children)) {
return true;
}
}
// By default
return false;
} | php | protected function hasParent($id, array $relationships)
{
foreach ($relationships as $parentId => $children) {
// 0 is reserved, therefore must be ignored
if ($parentId == 0) {
continue;
}
if (in_array($id, $children)) {
return true;
}
}
// By default
return false;
} | [
"protected",
"function",
"hasParent",
"(",
"$",
"id",
",",
"array",
"$",
"relationships",
")",
"{",
"foreach",
"(",
"$",
"relationships",
"as",
"$",
"parentId",
"=>",
"$",
"children",
")",
"{",
"// 0 is reserved, therefore must be ignored",
"if",
"(",
"$",
"pa... | Determines whether given id has a parent
@param string|integer $id
@param array $relationships
@return boolean | [
"Determines",
"whether",
"given",
"id",
"has",
"a",
"parent"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Tree/AdjacencyList/Render/AbstractRenderer.php#L125-L140 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Filter/QueryContainer.php | QueryContainer.getParam | private function getParam($param, $default = null)
{
if (isset($this->query[$param])) {
return $this->query[$param];
} else {
return $default;
}
} | php | private function getParam($param, $default = null)
{
if (isset($this->query[$param])) {
return $this->query[$param];
} else {
return $default;
}
} | [
"private",
"function",
"getParam",
"(",
"$",
"param",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"query",
"[",
"$",
"param",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"query",
"[",
"$",
"param",... | Returns parameter's value from query
@param string $param
@param mixed $default
@return string | [
"Returns",
"parameter",
"s",
"value",
"from",
"query"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Filter/QueryContainer.php#L61-L68 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Filter/QueryContainer.php | QueryContainer.isSortedByMethod | private function isSortedByMethod($column, $value)
{
return $this->isSortedBy($column) && $this->getParam(FilterInvoker::FILTER_PARAM_DESC) == $value;
} | php | private function isSortedByMethod($column, $value)
{
return $this->isSortedBy($column) && $this->getParam(FilterInvoker::FILTER_PARAM_DESC) == $value;
} | [
"private",
"function",
"isSortedByMethod",
"(",
"$",
"column",
",",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"isSortedBy",
"(",
"$",
"column",
")",
"&&",
"$",
"this",
"->",
"getParam",
"(",
"FilterInvoker",
"::",
"FILTER_PARAM_DESC",
")",
"==",... | Determines whether a column has been sorted either by ASC or DESC method
@param string $column Column name
@param string $value
@return boolean | [
"Determines",
"whether",
"a",
"column",
"has",
"been",
"sorted",
"either",
"by",
"ASC",
"or",
"DESC",
"method"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Filter/QueryContainer.php#L87-L90 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Filter/QueryContainer.php | QueryContainer.getColumnSortingUrl | public function getColumnSortingUrl($column)
{
$data = array(
FilterInvoker::FILTER_PARAM_PAGE => $this->getCurrentPageNumber(),
FilterInvoker::FILTER_PARAM_DESC => !$this->isSortedByDesc($column),
FilterInvoker::FILTER_PARAM_SORT => $column
);
return FilterInvoker::createUrl(array_merge($this->query, $data), $this->route);
} | php | public function getColumnSortingUrl($column)
{
$data = array(
FilterInvoker::FILTER_PARAM_PAGE => $this->getCurrentPageNumber(),
FilterInvoker::FILTER_PARAM_DESC => !$this->isSortedByDesc($column),
FilterInvoker::FILTER_PARAM_SORT => $column
);
return FilterInvoker::createUrl(array_merge($this->query, $data), $this->route);
} | [
"public",
"function",
"getColumnSortingUrl",
"(",
"$",
"column",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"FilterInvoker",
"::",
"FILTER_PARAM_PAGE",
"=>",
"$",
"this",
"->",
"getCurrentPageNumber",
"(",
")",
",",
"FilterInvoker",
"::",
"FILTER_PARAM_DESC",
"=>... | Returns sorting URL for a particular column
@param string $column Column name
@return string | [
"Returns",
"sorting",
"URL",
"for",
"a",
"particular",
"column"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Filter/QueryContainer.php#L131-L140 | train |
Larium/larium_creditcard | src/CreditCard/CreditCard.php | CreditCard.withToken | public function withToken(Token $token)
{
$card = $this->with('token', $token);
if (null !== $card->number) {
$lastDigits = strlen($card->number) <= 4
? $card->number :
substr($card->number, -4);
$card->number = "XXXX-XXXX-XXXX-" . $lastDigits;
}
$card->cvv = null;
return $card;
} | php | public function withToken(Token $token)
{
$card = $this->with('token', $token);
if (null !== $card->number) {
$lastDigits = strlen($card->number) <= 4
? $card->number :
substr($card->number, -4);
$card->number = "XXXX-XXXX-XXXX-" . $lastDigits;
}
$card->cvv = null;
return $card;
} | [
"public",
"function",
"withToken",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"card",
"=",
"$",
"this",
"->",
"with",
"(",
"'token'",
",",
"$",
"token",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"card",
"->",
"number",
")",
"{",
"$",
"lastDigits",
... | Sets token value.
@param Token $token
@return CreditCard | [
"Sets",
"token",
"value",
"."
] | ea1957bbe28e2448498abe7bb5a5b6ff0020bb2d | https://github.com/Larium/larium_creditcard/blob/ea1957bbe28e2448498abe7bb5a5b6ff0020bb2d/src/CreditCard/CreditCard.php#L327-L341 | train |
droath/project-x | src/Database.php | Database.asArray | public function asArray()
{
$array = [];
$properties = (new \ReflectionClass($this))
->getProperties(ReflectionProperty::IS_PUBLIC);
foreach ($properties as $object) {
$value = $object->getValue($this);
if (!isset($value)) {
continue;
}
$property = $object->getName();
if (!empty($this->mappings)
&& isset($this->mappings[$property])) {
$property = $this->mappings[$property];
}
$array[$property] = $value;
}
return new \ArrayIterator($array);
} | php | public function asArray()
{
$array = [];
$properties = (new \ReflectionClass($this))
->getProperties(ReflectionProperty::IS_PUBLIC);
foreach ($properties as $object) {
$value = $object->getValue($this);
if (!isset($value)) {
continue;
}
$property = $object->getName();
if (!empty($this->mappings)
&& isset($this->mappings[$property])) {
$property = $this->mappings[$property];
}
$array[$property] = $value;
}
return new \ArrayIterator($array);
} | [
"public",
"function",
"asArray",
"(",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"$",
"properties",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getProperties",
"(",
"ReflectionProperty",
"::",
"IS_PUBLIC",
")",
";",
"f... | The array representation of database object.
@return \ArrayIterator
@throws \ReflectionException | [
"The",
"array",
"representation",
"of",
"database",
"object",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Database.php#L178-L200 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.importDatabaseToService | public function importDatabaseToService($service = null, $import_path = null, $copy_to_service = false, $localhost = false)
{
$destination = $this->resolveDatabaseImportDestination(
$import_path,
$service,
$copy_to_service,
$localhost
);
/** @var CommandBuilder $command */
$command = $this->resolveDatabaseImportCommand()->command("< {$destination}");
$this->executeEngineCommand($command, $service, [], false, $localhost);
return $this;
} | php | public function importDatabaseToService($service = null, $import_path = null, $copy_to_service = false, $localhost = false)
{
$destination = $this->resolveDatabaseImportDestination(
$import_path,
$service,
$copy_to_service,
$localhost
);
/** @var CommandBuilder $command */
$command = $this->resolveDatabaseImportCommand()->command("< {$destination}");
$this->executeEngineCommand($command, $service, [], false, $localhost);
return $this;
} | [
"public",
"function",
"importDatabaseToService",
"(",
"$",
"service",
"=",
"null",
",",
"$",
"import_path",
"=",
"null",
",",
"$",
"copy_to_service",
"=",
"false",
",",
"$",
"localhost",
"=",
"false",
")",
"{",
"$",
"destination",
"=",
"$",
"this",
"->",
... | Import database dump into a service.
@param null $service
The database service name to use.
@param null $import_path
The path to the database file.
@param bool $copy_to_service
Copy imported file to service.
@param bool $localhost
Flag to determine if the command should be ran from localhost.
@return $this
@throws \Exception | [
"Import",
"database",
"dump",
"into",
"a",
"service",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L200-L215 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.getDatabaseInfo | public function getDatabaseInfo(ServiceDbInterface $instance = null, $allow_override = true)
{
if (!isset($instance)) {
/** @var EngineType $engine */
$engine = $this->getEngineInstance();
$instance = $engine->getServiceInstanceByInterface(
ServiceDbInterface::class
);
if ($instance === false) {
throw new \RuntimeException(
'Unable to find a service for the database instance.'
);
}
}
$database = $this->getServiceInstanceDatabase($instance);
if (!$allow_override || !isset($this->databaseOverride)) {
return $database;
}
// Process database overrides on the current db object.
foreach (get_object_vars($this->databaseOverride) as $property => $value) {
if (empty($value)) {
continue;
}
$method = 'set' . ucwords($property);
if (!method_exists($database, $method)) {
continue;
}
$database = call_user_func_array(
[$database, $method],
[$value]
);
}
return $database;
} | php | public function getDatabaseInfo(ServiceDbInterface $instance = null, $allow_override = true)
{
if (!isset($instance)) {
/** @var EngineType $engine */
$engine = $this->getEngineInstance();
$instance = $engine->getServiceInstanceByInterface(
ServiceDbInterface::class
);
if ($instance === false) {
throw new \RuntimeException(
'Unable to find a service for the database instance.'
);
}
}
$database = $this->getServiceInstanceDatabase($instance);
if (!$allow_override || !isset($this->databaseOverride)) {
return $database;
}
// Process database overrides on the current db object.
foreach (get_object_vars($this->databaseOverride) as $property => $value) {
if (empty($value)) {
continue;
}
$method = 'set' . ucwords($property);
if (!method_exists($database, $method)) {
continue;
}
$database = call_user_func_array(
[$database, $method],
[$value]
);
}
return $database;
} | [
"public",
"function",
"getDatabaseInfo",
"(",
"ServiceDbInterface",
"$",
"instance",
"=",
"null",
",",
"$",
"allow_override",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"instance",
")",
")",
"{",
"/** @var EngineType $engine */",
"$",
"engine",
... | Get database information based on services.
@param ServiceDbInterface|null $instance
Instance of the environment engine DB service.
@param bool $allow_override
Set if to false to not include overrides.
@return DatabaseInterface | [
"Get",
"database",
"information",
"based",
"on",
"services",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L241-L279 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.getEnvPhpVersion | public function getEnvPhpVersion()
{
/** @var EngineType $engine */
$engine = $this->getEngineInstance();
$instance = $engine->getServiceInstanceByType('php');
if (empty($instance)) {
throw new \RuntimeException(
'No php service has been found.'
);
}
$service = $instance[0];
return $service->getVersion();
} | php | public function getEnvPhpVersion()
{
/** @var EngineType $engine */
$engine = $this->getEngineInstance();
$instance = $engine->getServiceInstanceByType('php');
if (empty($instance)) {
throw new \RuntimeException(
'No php service has been found.'
);
}
$service = $instance[0];
return $service->getVersion();
} | [
"public",
"function",
"getEnvPhpVersion",
"(",
")",
"{",
"/** @var EngineType $engine */",
"$",
"engine",
"=",
"$",
"this",
"->",
"getEngineInstance",
"(",
")",
";",
"$",
"instance",
"=",
"$",
"engine",
"->",
"getServiceInstanceByType",
"(",
"'php'",
")",
";",
... | Get environment PHP version.
@return string
The PHP version defined by the environment engine service. | [
"Get",
"environment",
"PHP",
"version",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L287-L301 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.initBehat | public function initBehat()
{
$root_path = ProjectX::projectRoot();
if ($this->hasBehat()
&& !file_exists("$root_path/tests/Behat/features")) {
$this->taskBehat()
->option('init')
->option('config', "{$root_path}/tests/Behat/behat.yml")
->run();
}
return $this;
} | php | public function initBehat()
{
$root_path = ProjectX::projectRoot();
if ($this->hasBehat()
&& !file_exists("$root_path/tests/Behat/features")) {
$this->taskBehat()
->option('init')
->option('config', "{$root_path}/tests/Behat/behat.yml")
->run();
}
return $this;
} | [
"public",
"function",
"initBehat",
"(",
")",
"{",
"$",
"root_path",
"=",
"ProjectX",
"::",
"projectRoot",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasBehat",
"(",
")",
"&&",
"!",
"file_exists",
"(",
"\"$root_path/tests/Behat/features\"",
")",
")",
"{"... | Initialize Behat for the project.
@return self | [
"Initialize",
"Behat",
"for",
"the",
"project",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L365-L378 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.setupPhpCodeSniffer | public function setupPhpCodeSniffer()
{
$root_path = ProjectX::projectRoot();
$this->taskWriteToFile("{$root_path}/phpcs.xml.dist")
->text($this->loadTemplateContents('phpcs.xml.dist'))
->place('PROJECT_ROOT', $this->getInstallRoot())
->run();
$this->composer->addRequires([
'squizlabs/php_codesniffer' => static::PHPCS_VERSION,
], true);
return $this;
} | php | public function setupPhpCodeSniffer()
{
$root_path = ProjectX::projectRoot();
$this->taskWriteToFile("{$root_path}/phpcs.xml.dist")
->text($this->loadTemplateContents('phpcs.xml.dist'))
->place('PROJECT_ROOT', $this->getInstallRoot())
->run();
$this->composer->addRequires([
'squizlabs/php_codesniffer' => static::PHPCS_VERSION,
], true);
return $this;
} | [
"public",
"function",
"setupPhpCodeSniffer",
"(",
")",
"{",
"$",
"root_path",
"=",
"ProjectX",
"::",
"projectRoot",
"(",
")",
";",
"$",
"this",
"->",
"taskWriteToFile",
"(",
"\"{$root_path}/phpcs.xml.dist\"",
")",
"->",
"text",
"(",
"$",
"this",
"->",
"loadTem... | Setup PHP code sniffer. | [
"Setup",
"PHP",
"code",
"sniffer",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L419-L433 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.packagePhpBuild | public function packagePhpBuild($build_root)
{
$project_root = ProjectX::projectRoot();
$stack = $this->taskFilesystemStack();
if (file_exists("{$project_root}/patches")) {
$stack->mirror("{$project_root}/patches", "{$build_root}/patches");
}
$stack->copy("{$project_root}/composer.json", "{$build_root}/composer.json");
$stack->copy("{$project_root}/composer.lock", "{$build_root}/composer.lock");
$stack->run();
return $this;
} | php | public function packagePhpBuild($build_root)
{
$project_root = ProjectX::projectRoot();
$stack = $this->taskFilesystemStack();
if (file_exists("{$project_root}/patches")) {
$stack->mirror("{$project_root}/patches", "{$build_root}/patches");
}
$stack->copy("{$project_root}/composer.json", "{$build_root}/composer.json");
$stack->copy("{$project_root}/composer.lock", "{$build_root}/composer.lock");
$stack->run();
return $this;
} | [
"public",
"function",
"packagePhpBuild",
"(",
"$",
"build_root",
")",
"{",
"$",
"project_root",
"=",
"ProjectX",
"::",
"projectRoot",
"(",
")",
";",
"$",
"stack",
"=",
"$",
"this",
"->",
"taskFilesystemStack",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
... | Package PHP build.
The process consist of following:
- Copy patches.
- Copy composer.json and composer.lock
@param $build_root
The build root path.
@return self | [
"Package",
"PHP",
"build",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L492-L505 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.updateComposer | public function updateComposer($lock = false)
{
$update = $this->taskComposerUpdate();
if ($lock) {
$update->option('lock');
}
$update->run();
return $this;
} | php | public function updateComposer($lock = false)
{
$update = $this->taskComposerUpdate();
if ($lock) {
$update->option('lock');
}
$update->run();
return $this;
} | [
"public",
"function",
"updateComposer",
"(",
"$",
"lock",
"=",
"false",
")",
"{",
"$",
"update",
"=",
"$",
"this",
"->",
"taskComposerUpdate",
"(",
")",
";",
"if",
"(",
"$",
"lock",
")",
"{",
"$",
"update",
"->",
"option",
"(",
"'lock'",
")",
";",
... | Update composer packages.
@param bool $lock
Determine to update composer using --lock.
@return self | [
"Update",
"composer",
"packages",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L515-L525 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.hasComposerPackage | public function hasComposerPackage($vendor, $dev = false)
{
$packages = !$dev
? $this->composer->getRequire()
: $this->composer->getRequireDev();
return isset($packages[$vendor]);
} | php | public function hasComposerPackage($vendor, $dev = false)
{
$packages = !$dev
? $this->composer->getRequire()
: $this->composer->getRequireDev();
return isset($packages[$vendor]);
} | [
"public",
"function",
"hasComposerPackage",
"(",
"$",
"vendor",
",",
"$",
"dev",
"=",
"false",
")",
"{",
"$",
"packages",
"=",
"!",
"$",
"dev",
"?",
"$",
"this",
"->",
"composer",
"->",
"getRequire",
"(",
")",
":",
"$",
"this",
"->",
"composer",
"->"... | Has composer package.
@param string $vendor
The package vendor project namespace.
@param boolean $dev
A flag defining if it's a dev requirement.
@return boolean | [
"Has",
"composer",
"package",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L550-L558 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.extractArchive | protected function extractArchive($filename, $destination, $service = null, $localhost = false)
{
$mime_type = null;
if (file_exists($filename) && $localhost) {
$mime_type = mime_content_type($filename);
} else {
$engine = $this->getEngineInstance();
if ($engine instanceof DockerEngineType) {
$mime_type = $engine->getFileMimeType($filename, $service);
}
}
$command = null;
switch ($mime_type) {
case 'application/gzip':
case 'application/x-gzip':
$command = (new CommandBuilder('gunzip', $localhost))
->command("-c {$filename} > {$destination}");
break;
}
if (!isset($command)) {
return $filename;
}
// Remove destination file if on localhost.
if (file_exists($destination) && $localhost) {
$this->_remove($destination);
}
$this->executeEngineCommand($command, $service, [], false, $localhost);
return $destination;
} | php | protected function extractArchive($filename, $destination, $service = null, $localhost = false)
{
$mime_type = null;
if (file_exists($filename) && $localhost) {
$mime_type = mime_content_type($filename);
} else {
$engine = $this->getEngineInstance();
if ($engine instanceof DockerEngineType) {
$mime_type = $engine->getFileMimeType($filename, $service);
}
}
$command = null;
switch ($mime_type) {
case 'application/gzip':
case 'application/x-gzip':
$command = (new CommandBuilder('gunzip', $localhost))
->command("-c {$filename} > {$destination}");
break;
}
if (!isset($command)) {
return $filename;
}
// Remove destination file if on localhost.
if (file_exists($destination) && $localhost) {
$this->_remove($destination);
}
$this->executeEngineCommand($command, $service, [], false, $localhost);
return $destination;
} | [
"protected",
"function",
"extractArchive",
"(",
"$",
"filename",
",",
"$",
"destination",
",",
"$",
"service",
"=",
"null",
",",
"$",
"localhost",
"=",
"false",
")",
"{",
"$",
"mime_type",
"=",
"null",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filename",... | Extract archive within appropriate environment.
@param $filename
The path to the file archive.
@param $destination
The destination path of extracted data.
@param string|null $service
The service name.
@param bool $localhost
Extract archive on host.
@return null|boolean
@throws \Exception | [
"Extract",
"archive",
"within",
"appropriate",
"environment",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L683-L717 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.resolveDatabaseImportPath | protected function resolveDatabaseImportPath($import_path = null)
{
if (!isset($import_path)) {
$import_path = $this->doAsk(
new Question(
'Input the path to the database file: '
)
);
if (!file_exists($import_path)) {
throw new \Exception(
'The path to the database file does not exist.'
);
}
}
return new \SplFileInfo($import_path);
} | php | protected function resolveDatabaseImportPath($import_path = null)
{
if (!isset($import_path)) {
$import_path = $this->doAsk(
new Question(
'Input the path to the database file: '
)
);
if (!file_exists($import_path)) {
throw new \Exception(
'The path to the database file does not exist.'
);
}
}
return new \SplFileInfo($import_path);
} | [
"protected",
"function",
"resolveDatabaseImportPath",
"(",
"$",
"import_path",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"import_path",
")",
")",
"{",
"$",
"import_path",
"=",
"$",
"this",
"->",
"doAsk",
"(",
"new",
"Question",
"(",
"'Inp... | Resolve database import path.
@param string|null $import_path
The path to use for the database import.
@return \SplFileInfo
The database import path.
@throws \Exception | [
"Resolve",
"database",
"import",
"path",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L729-L746 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.resolveDatabaseImportDestination | protected function resolveDatabaseImportDestination($import_path, $service, $copy_to_service = false, $localhost = false)
{
/** @var \SplFileInfo $import_path */
$path = $this->resolveDatabaseImportPath($import_path);
$filename = $path->getFilename();
$extract_filename = substr($filename, 0, strrpos($filename, '.'));
if (!$localhost) {
// Copy file to service if uploaded from localhost.
if ($copy_to_service) {
/** @var DockerEngineType $engine */
$engine = $this->getEngineInstance();
if ($engine instanceof DockerEngineType) {
$engine->copyFileToService($path->getRealPath(), '/tmp', $service);
}
}
return $this->extractArchive(
"/tmp/{$filename}",
"/tmp/{$extract_filename}",
$service,
$localhost
);
}
return $this->extractArchive(
$path->getRealPath(),
"/tmp/{$extract_filename}",
null,
$localhost
);
} | php | protected function resolveDatabaseImportDestination($import_path, $service, $copy_to_service = false, $localhost = false)
{
/** @var \SplFileInfo $import_path */
$path = $this->resolveDatabaseImportPath($import_path);
$filename = $path->getFilename();
$extract_filename = substr($filename, 0, strrpos($filename, '.'));
if (!$localhost) {
// Copy file to service if uploaded from localhost.
if ($copy_to_service) {
/** @var DockerEngineType $engine */
$engine = $this->getEngineInstance();
if ($engine instanceof DockerEngineType) {
$engine->copyFileToService($path->getRealPath(), '/tmp', $service);
}
}
return $this->extractArchive(
"/tmp/{$filename}",
"/tmp/{$extract_filename}",
$service,
$localhost
);
}
return $this->extractArchive(
$path->getRealPath(),
"/tmp/{$extract_filename}",
null,
$localhost
);
} | [
"protected",
"function",
"resolveDatabaseImportDestination",
"(",
"$",
"import_path",
",",
"$",
"service",
",",
"$",
"copy_to_service",
"=",
"false",
",",
"$",
"localhost",
"=",
"false",
")",
"{",
"/** @var \\SplFileInfo $import_path */",
"$",
"path",
"=",
"$",
"t... | Resolve database import destination.
@param $import_path
The database import path.
@param $service
The service name.
@param bool $copy_to_service
Copy imported file to service.
@param bool $localhost
Resolve destination path from host.
@return bool|null
@throws \Exception | [
"Resolve",
"database",
"import",
"destination",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L762-L795 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.resolveDatabaseServiceInstance | protected function resolveDatabaseServiceInstance($service = null)
{
/** @var EngineType $engine */
$engine = $this->getEngineInstance();
$services = $engine->getServiceInstanceByGroup('database');
if (!isset($service) || !isset($services[$service])) {
if (count($services) > 1) {
$options = array_keys($services);
$service = $this->doAsk(
new ChoiceQuestion(
'Select the database service to use for import: ',
$options
)
);
} else {
$options = array_keys($services);
$service = reset($options);
}
}
if (!isset($services[$service])) {
throw new \RuntimeException(
'Unable to resolve database service.'
);
}
return $services[$service];
} | php | protected function resolveDatabaseServiceInstance($service = null)
{
/** @var EngineType $engine */
$engine = $this->getEngineInstance();
$services = $engine->getServiceInstanceByGroup('database');
if (!isset($service) || !isset($services[$service])) {
if (count($services) > 1) {
$options = array_keys($services);
$service = $this->doAsk(
new ChoiceQuestion(
'Select the database service to use for import: ',
$options
)
);
} else {
$options = array_keys($services);
$service = reset($options);
}
}
if (!isset($services[$service])) {
throw new \RuntimeException(
'Unable to resolve database service.'
);
}
return $services[$service];
} | [
"protected",
"function",
"resolveDatabaseServiceInstance",
"(",
"$",
"service",
"=",
"null",
")",
"{",
"/** @var EngineType $engine */",
"$",
"engine",
"=",
"$",
"this",
"->",
"getEngineInstance",
"(",
")",
";",
"$",
"services",
"=",
"$",
"engine",
"->",
"getSer... | Resolve database service instance.
@param null $service
The database service name.
@return mixed | [
"Resolve",
"database",
"service",
"instance",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L805-L833 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.resolveDatabaseImportCommand | protected function resolveDatabaseImportCommand($service = null)
{
/** @var ServiceDbInterface $instance */
$instance = $this->resolveDatabaseServiceInstance($service);
/** @var DatabaseInterface $database */
$database = $this->getDatabaseInfo($instance);
switch ($database->getProtocol()) {
case 'mysql':
return (new MysqlCommand())
->host($database->getHostname())
->username($database->getUser())
->password($database->getPassword())
->database($database->getDatabase());
case 'pgsql':
return (new PgsqlCommand())
->host($database->getHostname())
->username($database->getUser())
->password($database->getPassword())
->database($database->getDatabase());
}
} | php | protected function resolveDatabaseImportCommand($service = null)
{
/** @var ServiceDbInterface $instance */
$instance = $this->resolveDatabaseServiceInstance($service);
/** @var DatabaseInterface $database */
$database = $this->getDatabaseInfo($instance);
switch ($database->getProtocol()) {
case 'mysql':
return (new MysqlCommand())
->host($database->getHostname())
->username($database->getUser())
->password($database->getPassword())
->database($database->getDatabase());
case 'pgsql':
return (new PgsqlCommand())
->host($database->getHostname())
->username($database->getUser())
->password($database->getPassword())
->database($database->getDatabase());
}
} | [
"protected",
"function",
"resolveDatabaseImportCommand",
"(",
"$",
"service",
"=",
"null",
")",
"{",
"/** @var ServiceDbInterface $instance */",
"$",
"instance",
"=",
"$",
"this",
"->",
"resolveDatabaseServiceInstance",
"(",
"$",
"service",
")",
";",
"/** @var DatabaseI... | Resolve database import command.
@param string|null $service
The database service name.
@return CommandBuilder
The database command based on the provide service. | [
"Resolve",
"database",
"import",
"command",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L844-L866 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.hasDatabaseConnection | protected function hasDatabaseConnection($host, $port = 3306, $seconds = 30)
{
$hostChecker = $this->getHostChecker();
$hostChecker
->setHost($host)
->setPort($port);
return $hostChecker->isPortOpenRepeater($seconds);
} | php | protected function hasDatabaseConnection($host, $port = 3306, $seconds = 30)
{
$hostChecker = $this->getHostChecker();
$hostChecker
->setHost($host)
->setPort($port);
return $hostChecker->isPortOpenRepeater($seconds);
} | [
"protected",
"function",
"hasDatabaseConnection",
"(",
"$",
"host",
",",
"$",
"port",
"=",
"3306",
",",
"$",
"seconds",
"=",
"30",
")",
"{",
"$",
"hostChecker",
"=",
"$",
"this",
"->",
"getHostChecker",
"(",
")",
";",
"$",
"hostChecker",
"->",
"setHost",... | Check if host has database connection.
@param string $host
The database hostname.
@param int $port
The database port.
@param int $seconds
The amount of seconds to continually check.
@return bool
Return true if the database is connectible; otherwise false. | [
"Check",
"if",
"host",
"has",
"database",
"connection",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L881-L889 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.getServiceInstanceDatabase | protected function getServiceInstanceDatabase(ServiceDbInterface $instance)
{
$port = current($instance->getHostPorts());
return (new Database($this->databaseInfoMapping()))
->setPort($port)
->setUser($instance->username())
->setPassword($instance->password())
->setProtocol($instance->protocol())
->setHostname($instance->getName())
->setDatabase($instance->database());
} | php | protected function getServiceInstanceDatabase(ServiceDbInterface $instance)
{
$port = current($instance->getHostPorts());
return (new Database($this->databaseInfoMapping()))
->setPort($port)
->setUser($instance->username())
->setPassword($instance->password())
->setProtocol($instance->protocol())
->setHostname($instance->getName())
->setDatabase($instance->database());
} | [
"protected",
"function",
"getServiceInstanceDatabase",
"(",
"ServiceDbInterface",
"$",
"instance",
")",
"{",
"$",
"port",
"=",
"current",
"(",
"$",
"instance",
"->",
"getHostPorts",
"(",
")",
")",
";",
"return",
"(",
"new",
"Database",
"(",
"$",
"this",
"->"... | Get a service instance database object.
@param ServiceDbInterface $instance
The service database instance.
@return Database
The database object. | [
"Get",
"a",
"service",
"instance",
"database",
"object",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L900-L911 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.mergeProjectComposerTemplate | protected function mergeProjectComposerTemplate()
{
if ($contents = $this->loadTemplateContents('composer.json', 'json')) {
$this->composer = $this->composer->update($contents);
}
return $this;
} | php | protected function mergeProjectComposerTemplate()
{
if ($contents = $this->loadTemplateContents('composer.json', 'json')) {
$this->composer = $this->composer->update($contents);
}
return $this;
} | [
"protected",
"function",
"mergeProjectComposerTemplate",
"(",
")",
"{",
"if",
"(",
"$",
"contents",
"=",
"$",
"this",
"->",
"loadTemplateContents",
"(",
"'composer.json'",
",",
"'json'",
")",
")",
"{",
"$",
"this",
"->",
"composer",
"=",
"$",
"this",
"->",
... | Merge project composer template.
This will try and load a composer.json template from the project root. If
not found it will search in the application template root for the
particular project type.
The method only exist so that projects can merge in composer requirements
during the project build cycle. If those requirements were declared in
the composer.json root, and dependencies are needed based on the project
type on which haven't been added yet, can cause issues.
@return self | [
"Merge",
"project",
"composer",
"template",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L927-L934 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.setupComposerPackages | protected function setupComposerPackages()
{
$platform = $this->getPlatformInstance();
if ($platform instanceof ComposerPackageInterface) {
$platform->alterComposer($this->composer);
}
$this->saveComposer();
return $this;
} | php | protected function setupComposerPackages()
{
$platform = $this->getPlatformInstance();
if ($platform instanceof ComposerPackageInterface) {
$platform->alterComposer($this->composer);
}
$this->saveComposer();
return $this;
} | [
"protected",
"function",
"setupComposerPackages",
"(",
")",
"{",
"$",
"platform",
"=",
"$",
"this",
"->",
"getPlatformInstance",
"(",
")",
";",
"if",
"(",
"$",
"platform",
"instanceof",
"ComposerPackageInterface",
")",
"{",
"$",
"platform",
"->",
"alterComposer"... | Setup composer packages.
@return $this | [
"Setup",
"composer",
"packages",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L941-L951 | train |
droath/project-x | src/Project/PhpProjectType.php | PhpProjectType.composer | private function composer()
{
$composer_file = $this->composerFile();
return file_exists($composer_file)
? ComposerConfig::createFromFile($composer_file)
: new ComposerConfig();
} | php | private function composer()
{
$composer_file = $this->composerFile();
return file_exists($composer_file)
? ComposerConfig::createFromFile($composer_file)
: new ComposerConfig();
} | [
"private",
"function",
"composer",
"(",
")",
"{",
"$",
"composer_file",
"=",
"$",
"this",
"->",
"composerFile",
"(",
")",
";",
"return",
"file_exists",
"(",
"$",
"composer_file",
")",
"?",
"ComposerConfig",
"::",
"createFromFile",
"(",
"$",
"composer_file",
... | Composer config instance.
@return \Droath\ProjectX\Config\ComposerConfig | [
"Composer",
"config",
"instance",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/PhpProjectType.php#L958-L965 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCart.php | ShoppingCart.setAvailablePostage | public function setAvailablePostage($country, $code)
{
$postage_areas = new ShippingCalculator($code, $country);
$postage_areas
->setCost($this->SubTotalCost)
->setWeight($this->TotalWeight)
->setItems($this->TotalItems);
$postage_areas = $postage_areas->getPostageAreas();
Session::set("Checkout.AvailablePostage", $postage_areas);
return $this;
} | php | public function setAvailablePostage($country, $code)
{
$postage_areas = new ShippingCalculator($code, $country);
$postage_areas
->setCost($this->SubTotalCost)
->setWeight($this->TotalWeight)
->setItems($this->TotalItems);
$postage_areas = $postage_areas->getPostageAreas();
Session::set("Checkout.AvailablePostage", $postage_areas);
return $this;
} | [
"public",
"function",
"setAvailablePostage",
"(",
"$",
"country",
",",
"$",
"code",
")",
"{",
"$",
"postage_areas",
"=",
"new",
"ShippingCalculator",
"(",
"$",
"code",
",",
"$",
"country",
")",
";",
"$",
"postage_areas",
"->",
"setCost",
"(",
"$",
"this",
... | Set postage that is available to the shopping cart based on the
country and zip code submitted
@param $country 2 character country code
@param $code Zip or Postal code
@return ShoppingCart | [
"Set",
"postage",
"that",
"is",
"available",
"to",
"the",
"shopping",
"cart",
"based",
"on",
"the",
"country",
"and",
"zip",
"code",
"submitted"
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCart.php#L170-L184 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCart.php | ShoppingCart.isCollection | public function isCollection()
{
if (Checkout::config()->click_and_collect) {
$type = Session::get("Checkout.Delivery");
return ($type == "collect") ? true : false;
} else {
return false;
}
} | php | public function isCollection()
{
if (Checkout::config()->click_and_collect) {
$type = Session::get("Checkout.Delivery");
return ($type == "collect") ? true : false;
} else {
return false;
}
} | [
"public",
"function",
"isCollection",
"(",
")",
"{",
"if",
"(",
"Checkout",
"::",
"config",
"(",
")",
"->",
"click_and_collect",
")",
"{",
"$",
"type",
"=",
"Session",
"::",
"get",
"(",
"\"Checkout.Delivery\"",
")",
";",
"return",
"(",
"$",
"type",
"==",... | Are we collecting the current cart? If click and collect is
disabled then this returns false, otherwise checks if the user
has set this via a session.
@return Boolean | [
"Are",
"we",
"collecting",
"the",
"current",
"cart?",
"If",
"click",
"and",
"collect",
"is",
"disabled",
"then",
"this",
"returns",
"false",
"otherwise",
"checks",
"if",
"the",
"user",
"has",
"set",
"this",
"via",
"a",
"session",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCart.php#L193-L202 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCart.php | ShoppingCart.isDeliverable | public function isDeliverable()
{
$deliverable = false;
foreach ($this->getItems() as $item) {
if ($item->Deliverable) {
$deliverable = true;
}
}
return $deliverable;
} | php | public function isDeliverable()
{
$deliverable = false;
foreach ($this->getItems() as $item) {
if ($item->Deliverable) {
$deliverable = true;
}
}
return $deliverable;
} | [
"public",
"function",
"isDeliverable",
"(",
")",
"{",
"$",
"deliverable",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"getItems",
"(",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"Deliverable",
")",
"{",
"$",
"deliverabl... | Determine if the current cart contains delivereable items.
This is used to determine setting and usage of delivery and
postage options in the checkout.
@return Boolean | [
"Determine",
"if",
"the",
"current",
"cart",
"contains",
"delivereable",
"items",
".",
"This",
"is",
"used",
"to",
"determine",
"setting",
"and",
"usage",
"of",
"delivery",
"and",
"postage",
"options",
"in",
"the",
"checkout",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCart.php#L211-L222 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCart.php | ShoppingCart.emptycart | public function emptycart()
{
$this->extend("onBeforeEmpty");
$this->removeAll();
$this->save();
$this->setSessionMessage(
"bad",
_t("Checkout.EmptiedCart", "Shopping cart emptied")
);
return $this->redirectBack();
} | php | public function emptycart()
{
$this->extend("onBeforeEmpty");
$this->removeAll();
$this->save();
$this->setSessionMessage(
"bad",
_t("Checkout.EmptiedCart", "Shopping cart emptied")
);
return $this->redirectBack();
} | [
"public",
"function",
"emptycart",
"(",
")",
"{",
"$",
"this",
"->",
"extend",
"(",
"\"onBeforeEmpty\"",
")",
";",
"$",
"this",
"->",
"removeAll",
"(",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"setSessionMessage",
"(",
"... | Action that will clear shopping cart and associated sessions | [
"Action",
"that",
"will",
"clear",
"shopping",
"cart",
"and",
"associated",
"sessions"
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCart.php#L339-L351 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCart.php | ShoppingCart.save | public function save()
{
Session::clear("Checkout.PostageID");
// Extend our save operation
$this->extend("onBeforeSave");
// Save cart items
Session::set(
"Checkout.ShoppingCart.Items",
serialize($this->items)
);
// Save cart discounts
Session::set(
"Checkout.ShoppingCart.Discount",
serialize($this->discount)
);
// Update available postage
if ($data = Session::get("Form.Form_PostageForm.data")) {
$country = $data["Country"];
$code = $data["ZipCode"];
$this->setAvailablePostage($country, $code);
}
} | php | public function save()
{
Session::clear("Checkout.PostageID");
// Extend our save operation
$this->extend("onBeforeSave");
// Save cart items
Session::set(
"Checkout.ShoppingCart.Items",
serialize($this->items)
);
// Save cart discounts
Session::set(
"Checkout.ShoppingCart.Discount",
serialize($this->discount)
);
// Update available postage
if ($data = Session::get("Form.Form_PostageForm.data")) {
$country = $data["Country"];
$code = $data["ZipCode"];
$this->setAvailablePostage($country, $code);
}
} | [
"public",
"function",
"save",
"(",
")",
"{",
"Session",
"::",
"clear",
"(",
"\"Checkout.PostageID\"",
")",
";",
"// Extend our save operation",
"$",
"this",
"->",
"extend",
"(",
"\"onBeforeSave\"",
")",
";",
"// Save cart items",
"Session",
"::",
"set",
"(",
"\"... | Save the current products list and postage to a session. | [
"Save",
"the",
"current",
"products",
"list",
"and",
"postage",
"to",
"a",
"session",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCart.php#L518-L543 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCart.php | ShoppingCart.getSubTotalCost | public function getSubTotalCost()
{
$total = 0;
foreach ($this->items as $item) {
if ($item->SubTotal) {
$total += $item->SubTotal;
}
}
return $total;
} | php | public function getSubTotalCost()
{
$total = 0;
foreach ($this->items as $item) {
if ($item->SubTotal) {
$total += $item->SubTotal;
}
}
return $total;
} | [
"public",
"function",
"getSubTotalCost",
"(",
")",
"{",
"$",
"total",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"SubTotal",
")",
"{",
"$",
"total",
"+=",
"$",
"item",
"->... | Find the cost of all items in the cart, without any tax.
@return Currency | [
"Find",
"the",
"cost",
"of",
"all",
"items",
"in",
"the",
"cart",
"without",
"any",
"tax",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCart.php#L607-L618 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCart.php | ShoppingCart.getDiscountAmount | public function getDiscountAmount()
{
$total = 0;
$discount = 0;
foreach ($this->items as $item) {
if ($item->Price) {
$total += ($item->Price * $item->Quantity);
}
if ($item->Discount) {
$discount += ($item->TotalDiscount);
}
}
if ($discount > $total) {
$discount = $total;
}
return $discount;
} | php | public function getDiscountAmount()
{
$total = 0;
$discount = 0;
foreach ($this->items as $item) {
if ($item->Price) {
$total += ($item->Price * $item->Quantity);
}
if ($item->Discount) {
$discount += ($item->TotalDiscount);
}
}
if ($discount > $total) {
$discount = $total;
}
return $discount;
} | [
"public",
"function",
"getDiscountAmount",
"(",
")",
"{",
"$",
"total",
"=",
"0",
";",
"$",
"discount",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"Price",
")",
"{",
"$",
... | Find the total discount based on discount items added.
@return Currency | [
"Find",
"the",
"total",
"discount",
"based",
"on",
"discount",
"items",
"added",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCart.php#L641-L661 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCart.php | ShoppingCart.doAddDiscount | public function doAddDiscount($data, $form)
{
$code_to_search = $data['DiscountCode'];
// First check if the discount is already added (so we don't
// query the DB if we don't have to).
if (!$this->discount || ($this->discount && $this->discount->Code != $code_to_search)) {
$code = Discount::get()
->filter("Code", $code_to_search)
->exclude("Expires:LessThan", date("Y-m-d"))
->first();
if ($code) {
$this->discount = $code;
}
}
$this->save();
return $this->redirectBack();
} | php | public function doAddDiscount($data, $form)
{
$code_to_search = $data['DiscountCode'];
// First check if the discount is already added (so we don't
// query the DB if we don't have to).
if (!$this->discount || ($this->discount && $this->discount->Code != $code_to_search)) {
$code = Discount::get()
->filter("Code", $code_to_search)
->exclude("Expires:LessThan", date("Y-m-d"))
->first();
if ($code) {
$this->discount = $code;
}
}
$this->save();
return $this->redirectBack();
} | [
"public",
"function",
"doAddDiscount",
"(",
"$",
"data",
",",
"$",
"form",
")",
"{",
"$",
"code_to_search",
"=",
"$",
"data",
"[",
"'DiscountCode'",
"]",
";",
"// First check if the discount is already added (so we don't",
"// query the DB if we don't have to).",
"if",
... | Action that will find a discount based on the code
@param type $data
@param type $form | [
"Action",
"that",
"will",
"find",
"a",
"discount",
"based",
"on",
"the",
"code"
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCart.php#L919-L939 | train |
i-lateral/silverstripe-checkout | code/control/shoppingcart/ShoppingCart.php | ShoppingCart.doSetPostage | public function doSetPostage($data, $form)
{
$country = $data["Country"];
$code = $data["ZipCode"];
$this->setAvailablePostage($country, $code);
$postage = Session::get("Checkout.AvailablePostage");
// Check that postage is set, if not, see if we can set a default
if (array_key_exists("PostageID", $data) && $data["PostageID"]) {
// First is the current postage ID in the list of postage
// areas
if ($postage && $postage->exists() && $postage->find("ID", $data["PostageID"])) {
$id = $data["PostageID"];
} else {
$id = $postage->first()->ID;
}
$data["PostageID"] = $id;
Session::set("Checkout.PostageID", $id);
} else {
// Finally set the default postage
if ($postage && $postage->exists()) {
$data["PostageID"] = $postage->first()->ID;
Session::set("Checkout.PostageID", $postage->first()->ID);
}
}
// Set the form pre-populate data before redirecting
Session::set("Form.{$form->FormName()}.data", $data);
$url = Controller::join_links($this->Link(), "#{$form->FormName()}");
return $this->redirect($url);
} | php | public function doSetPostage($data, $form)
{
$country = $data["Country"];
$code = $data["ZipCode"];
$this->setAvailablePostage($country, $code);
$postage = Session::get("Checkout.AvailablePostage");
// Check that postage is set, if not, see if we can set a default
if (array_key_exists("PostageID", $data) && $data["PostageID"]) {
// First is the current postage ID in the list of postage
// areas
if ($postage && $postage->exists() && $postage->find("ID", $data["PostageID"])) {
$id = $data["PostageID"];
} else {
$id = $postage->first()->ID;
}
$data["PostageID"] = $id;
Session::set("Checkout.PostageID", $id);
} else {
// Finally set the default postage
if ($postage && $postage->exists()) {
$data["PostageID"] = $postage->first()->ID;
Session::set("Checkout.PostageID", $postage->first()->ID);
}
}
// Set the form pre-populate data before redirecting
Session::set("Form.{$form->FormName()}.data", $data);
$url = Controller::join_links($this->Link(), "#{$form->FormName()}");
return $this->redirect($url);
} | [
"public",
"function",
"doSetPostage",
"(",
"$",
"data",
",",
"$",
"form",
")",
"{",
"$",
"country",
"=",
"$",
"data",
"[",
"\"Country\"",
"]",
";",
"$",
"code",
"=",
"$",
"data",
"[",
"\"ZipCode\"",
"]",
";",
"$",
"this",
"->",
"setAvailablePostage",
... | Method that deals with get postage details and setting the
postage
@param $data
@param $form | [
"Method",
"that",
"deals",
"with",
"get",
"postage",
"details",
"and",
"setting",
"the",
"postage"
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/control/shoppingcart/ShoppingCart.php#L948-L984 | train |
Tecnocreaciones/ToolsBundle | Features/BaseWebUserContext.php | BaseWebUserContext.iFillTheUiSelectWithAndSelectElement2 | public function iFillTheUiSelectWithAndSelectElement2($id, $item)
{
$items = explode("-", $item);
if(count($items) > 0){
$item = $items[0].'-'.((int)$items[1] - 1);
}else {
$item = "0-".((int)$item - 1);
}
$idItem = sprintf("#ui-select-choices-row-%s",$item);
$this->iClickTheElement(sprintf("#%s > div.ui-select-match.ng-scope > span",$id));
$this->spin(function($context) use ($idItem){
$element = $context->findElement($idItem);
return $element != null;
},20);
$element = $this->findElement($idItem);
$element->click();
} | php | public function iFillTheUiSelectWithAndSelectElement2($id, $item)
{
$items = explode("-", $item);
if(count($items) > 0){
$item = $items[0].'-'.((int)$items[1] - 1);
}else {
$item = "0-".((int)$item - 1);
}
$idItem = sprintf("#ui-select-choices-row-%s",$item);
$this->iClickTheElement(sprintf("#%s > div.ui-select-match.ng-scope > span",$id));
$this->spin(function($context) use ($idItem){
$element = $context->findElement($idItem);
return $element != null;
},20);
$element = $this->findElement($idItem);
$element->click();
} | [
"public",
"function",
"iFillTheUiSelectWithAndSelectElement2",
"(",
"$",
"id",
",",
"$",
"item",
")",
"{",
"$",
"items",
"=",
"explode",
"(",
"\"-\"",
",",
"$",
"item",
")",
";",
"if",
"(",
"count",
"(",
"$",
"items",
")",
">",
"0",
")",
"{",
"$",
... | Selecccionar datos en select de tipo UI
@Given I fill the ui select :id with element :item | [
"Selecccionar",
"datos",
"en",
"select",
"de",
"tipo",
"UI"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseWebUserContext.php#L174-L191 | train |
Tecnocreaciones/ToolsBundle | Features/BaseWebUserContext.php | BaseWebUserContext.generatePageUrl | protected function generatePageUrl($route, array $parameters = array())
{
// $parts = explode(' ', trim($page), 2);
// $route = implode('_', $parts);
// $route = str_replace(' ', '_', $route);
$path = $this->generateUrl($route, $parameters);
// var_dump($this->getMinkParameter('base_url'));
// var_dump($path);
// die;
if ('Selenium2Driver' === strstr(get_class($this->getSession()->getDriver()), 'Selenium2Driver')) {
return sprintf('%s%s', $this->getMinkParameter('base_url'), $path);
}
return $path;
} | php | protected function generatePageUrl($route, array $parameters = array())
{
// $parts = explode(' ', trim($page), 2);
// $route = implode('_', $parts);
// $route = str_replace(' ', '_', $route);
$path = $this->generateUrl($route, $parameters);
// var_dump($this->getMinkParameter('base_url'));
// var_dump($path);
// die;
if ('Selenium2Driver' === strstr(get_class($this->getSession()->getDriver()), 'Selenium2Driver')) {
return sprintf('%s%s', $this->getMinkParameter('base_url'), $path);
}
return $path;
} | [
"protected",
"function",
"generatePageUrl",
"(",
"$",
"route",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"// $parts = explode(' ', trim($page), 2);",
"// $route = implode('_', $parts);",
"// $route = str_replace(' ', '_', $route);",
... | Generate page url.
This method uses simple convention where page argument is prefixed
with "sylius_" and used as route name passed to router generate method.
@param string $page
@param array $parameters
@return string | [
"Generate",
"page",
"url",
".",
"This",
"method",
"uses",
"simple",
"convention",
"where",
"page",
"argument",
"is",
"prefixed",
"with",
"sylius_",
"and",
"used",
"as",
"route",
"name",
"passed",
"to",
"router",
"generate",
"method",
"."
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseWebUserContext.php#L203-L220 | train |
Tecnocreaciones/ToolsBundle | Features/BaseWebUserContext.php | BaseWebUserContext.iWaitForTextToDisappear | public function iWaitForTextToDisappear($text)
{
$this->spin(function(FeatureContext $context) use ($text) {
try {
$context->assertPageContainsText($text);
}
catch(\Behat\Mink\Exception\ResponseTextException $e) {
return true;
}
return false;
});
} | php | public function iWaitForTextToDisappear($text)
{
$this->spin(function(FeatureContext $context) use ($text) {
try {
$context->assertPageContainsText($text);
}
catch(\Behat\Mink\Exception\ResponseTextException $e) {
return true;
}
return false;
});
} | [
"public",
"function",
"iWaitForTextToDisappear",
"(",
"$",
"text",
")",
"{",
"$",
"this",
"->",
"spin",
"(",
"function",
"(",
"FeatureContext",
"$",
"context",
")",
"use",
"(",
"$",
"text",
")",
"{",
"try",
"{",
"$",
"context",
"->",
"assertPageContainsTex... | Espera que un texto desaparesca de la pagina
@When I wait for :text to disappear
@Then I should see :text disappear
@param $text
@throws \Exception | [
"Espera",
"que",
"un",
"texto",
"desaparesca",
"de",
"la",
"pagina"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseWebUserContext.php#L265-L276 | train |
Tecnocreaciones/ToolsBundle | Features/BaseWebUserContext.php | BaseWebUserContext.spin | public function spin($lambda, $wait = 15,$errorCallback = null)
{
$time = time();
$stopTime = $time + $wait;
while (time() < $stopTime)
{
try {
if ($lambda($this)) {
return;
}
} catch (\Exception $e) {
// do nothing
}
usleep(250000);
}
if($errorCallback !== null){
$errorCallback($this);
}
throw new \Exception("Spin function timed out after {$wait} seconds");
} | php | public function spin($lambda, $wait = 15,$errorCallback = null)
{
$time = time();
$stopTime = $time + $wait;
while (time() < $stopTime)
{
try {
if ($lambda($this)) {
return;
}
} catch (\Exception $e) {
// do nothing
}
usleep(250000);
}
if($errorCallback !== null){
$errorCallback($this);
}
throw new \Exception("Spin function timed out after {$wait} seconds");
} | [
"public",
"function",
"spin",
"(",
"$",
"lambda",
",",
"$",
"wait",
"=",
"15",
",",
"$",
"errorCallback",
"=",
"null",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"$",
"stopTime",
"=",
"$",
"time",
"+",
"$",
"wait",
";",
"while",
"(",
"t... | Espera hasta que devuelva true la funcion pasada
Based on Behat's own example
@see http://docs.behat.org/en/v2.5/cookbook/using_spin_functions.html#adding-a-timeout
@param $lambda
@param int $wait
@throws \Exception | [
"Espera",
"hasta",
"que",
"devuelva",
"true",
"la",
"funcion",
"pasada",
"Based",
"on",
"Behat",
"s",
"own",
"example"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseWebUserContext.php#L316-L336 | train |
droath/project-x | src/Config/ComposerConfig.php | ComposerConfig.addRequires | public function addRequires(array $requires, $dev = false)
{
foreach ($requires as $vendor => $version) {
if (!isset($vendor) || !isset($version)) {
continue;
}
if (!$dev) {
$this->addRequire($vendor, $version);
} else {
$this->addDevRequire($vendor, $version);
}
}
return $this;
} | php | public function addRequires(array $requires, $dev = false)
{
foreach ($requires as $vendor => $version) {
if (!isset($vendor) || !isset($version)) {
continue;
}
if (!$dev) {
$this->addRequire($vendor, $version);
} else {
$this->addDevRequire($vendor, $version);
}
}
return $this;
} | [
"public",
"function",
"addRequires",
"(",
"array",
"$",
"requires",
",",
"$",
"dev",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"requires",
"as",
"$",
"vendor",
"=>",
"$",
"version",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"vendor",
")",
"||... | Add an array of required packages.
@param array $requires | [
"Add",
"an",
"array",
"of",
"required",
"packages",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Config/ComposerConfig.php#L127-L142 | train |
droath/project-x | src/Config/ComposerConfig.php | ComposerConfig.addRequire | public function addRequire($vendor, $version)
{
if (!isset($this->require[$vendor])) {
$this->require[$vendor] = $version;
}
return $this;
} | php | public function addRequire($vendor, $version)
{
if (!isset($this->require[$vendor])) {
$this->require[$vendor] = $version;
}
return $this;
} | [
"public",
"function",
"addRequire",
"(",
"$",
"vendor",
",",
"$",
"version",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"require",
"[",
"$",
"vendor",
"]",
")",
")",
"{",
"$",
"this",
"->",
"require",
"[",
"$",
"vendor",
"]",
"=",... | Add a single require package.
@param string $vendor
The composer package vendor.
@param string $version
The composer package version. | [
"Add",
"a",
"single",
"require",
"package",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Config/ComposerConfig.php#L152-L159 | train |
droath/project-x | src/Config/ComposerConfig.php | ComposerConfig.addDevRequire | public function addDevRequire($vendor, $version)
{
if (!isset($this->require_dev[$vendor])) {
$this->require_dev[$vendor] = $version;
}
return $this;
} | php | public function addDevRequire($vendor, $version)
{
if (!isset($this->require_dev[$vendor])) {
$this->require_dev[$vendor] = $version;
}
return $this;
} | [
"public",
"function",
"addDevRequire",
"(",
"$",
"vendor",
",",
"$",
"version",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"require_dev",
"[",
"$",
"vendor",
"]",
")",
")",
"{",
"$",
"this",
"->",
"require_dev",
"[",
"$",
"vendor",
... | Add a single development require package.
@param string $vendor
The composer package vendor.
@param string $version
The composer package version. | [
"Add",
"a",
"single",
"development",
"require",
"package",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Config/ComposerConfig.php#L169-L176 | train |
droath/project-x | src/Config/ComposerConfig.php | ComposerConfig.addExtra | public function addExtra($key, array $options)
{
if (!isset($this->extra[$key])) {
$this->extra[$key] = $options;
}
return $this;
} | php | public function addExtra($key, array $options)
{
if (!isset($this->extra[$key])) {
$this->extra[$key] = $options;
}
return $this;
} | [
"public",
"function",
"addExtra",
"(",
"$",
"key",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"extra",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"extra",
"[",
"$",
"key",
"]",
"=",
"... | Add extra options.
@param string $key
The unique extra namespace.
@param array $options
The extra options. | [
"Add",
"extra",
"options",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Config/ComposerConfig.php#L186-L193 | train |
phpcodecrafting/php-beanstalk | lib/Beanstalk/Stats.php | Stats.getStat | public function getStat($stat)
{
if (isset($this->stats[$stat])) {
return $this->stats[$stat];
}
return false;
} | php | public function getStat($stat)
{
if (isset($this->stats[$stat])) {
return $this->stats[$stat];
}
return false;
} | [
"public",
"function",
"getStat",
"(",
"$",
"stat",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"stats",
"[",
"$",
"stat",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"stats",
"[",
"$",
"stat",
"]",
";",
"}",
"return",
"false",
";... | Get the value of a given stat
@param string $stat Stat name to get the value of
@return string Stat's value
@return boolean false when value not set | [
"Get",
"the",
"value",
"of",
"a",
"given",
"stat"
] | 833c52122bb4879ef2945dab34b32992a6bd718c | https://github.com/phpcodecrafting/php-beanstalk/blob/833c52122bb4879ef2945dab34b32992a6bd718c/lib/Beanstalk/Stats.php#L45-L52 | train |
i-lateral/silverstripe-checkout | code/extensions/CheckoutMemberExtension.php | CheckoutMemberExtension.getDefaultAddress | public function getDefaultAddress()
{
if ($this->cached_address) {
return $this->cached_address;
} else {
$address = $this
->owner
->Addresses()
->sort("Default", "DESC")
->first();
$this->cached_address = $address;
return $address;
}
} | php | public function getDefaultAddress()
{
if ($this->cached_address) {
return $this->cached_address;
} else {
$address = $this
->owner
->Addresses()
->sort("Default", "DESC")
->first();
$this->cached_address = $address;
return $address;
}
} | [
"public",
"function",
"getDefaultAddress",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cached_address",
")",
"{",
"return",
"$",
"this",
"->",
"cached_address",
";",
"}",
"else",
"{",
"$",
"address",
"=",
"$",
"this",
"->",
"owner",
"->",
"Addresses",
... | Get the default address from our list of addreses. If no default
is set, we should return the first in the list.
@return MemberAddress | [
"Get",
"the",
"default",
"address",
"from",
"our",
"list",
"of",
"addreses",
".",
"If",
"no",
"default",
"is",
"set",
"we",
"should",
"return",
"the",
"first",
"in",
"the",
"list",
"."
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/extensions/CheckoutMemberExtension.php#L67-L82 | train |
i-lateral/silverstripe-checkout | code/extensions/CheckoutMemberExtension.php | CheckoutMemberExtension.getDiscount | public function getDiscount()
{
$discounts = ArrayList::create();
foreach ($this->owner->Groups() as $group) {
foreach ($group->Discounts() as $discount) {
$discounts->add($discount);
}
}
$discounts->sort("Amount", "DESC");
return $discounts->first();
} | php | public function getDiscount()
{
$discounts = ArrayList::create();
foreach ($this->owner->Groups() as $group) {
foreach ($group->Discounts() as $discount) {
$discounts->add($discount);
}
}
$discounts->sort("Amount", "DESC");
return $discounts->first();
} | [
"public",
"function",
"getDiscount",
"(",
")",
"{",
"$",
"discounts",
"=",
"ArrayList",
"::",
"create",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"owner",
"->",
"Groups",
"(",
")",
"as",
"$",
"group",
")",
"{",
"foreach",
"(",
"$",
"group",
... | Get a discount from the groups this member is in
@return Discount | [
"Get",
"a",
"discount",
"from",
"the",
"groups",
"this",
"member",
"is",
"in"
] | 2089b57ac2b7feb86dccde8a6864ae70ce463497 | https://github.com/i-lateral/silverstripe-checkout/blob/2089b57ac2b7feb86dccde8a6864ae70ce463497/code/extensions/CheckoutMemberExtension.php#L144-L157 | train |
Tecnocreaciones/ToolsBundle | Service/SequenceGenerator/SequenceGeneratorBase.php | SequenceGeneratorBase.buildRef | public function buildRef(ItemReferenceInterface $item,array $config) {
$mask = $config['mask'];
$className = $config['className'];
$field = $config['field'];
$qb = $this->sequenceGenerator->createQueryBuilder();
$qb->from($className,'p');
return $this->sequenceGenerator->generateNext($qb, $mask,$field,[],$config);
} | php | public function buildRef(ItemReferenceInterface $item,array $config) {
$mask = $config['mask'];
$className = $config['className'];
$field = $config['field'];
$qb = $this->sequenceGenerator->createQueryBuilder();
$qb->from($className,'p');
return $this->sequenceGenerator->generateNext($qb, $mask,$field,[],$config);
} | [
"public",
"function",
"buildRef",
"(",
"ItemReferenceInterface",
"$",
"item",
",",
"array",
"$",
"config",
")",
"{",
"$",
"mask",
"=",
"$",
"config",
"[",
"'mask'",
"]",
";",
"$",
"className",
"=",
"$",
"config",
"[",
"'className'",
"]",
";",
"$",
"fie... | Construye la referencia por defecto
@param ItemReferenceInterface $item
@param array $config
@return type | [
"Construye",
"la",
"referencia",
"por",
"defecto"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Service/SequenceGenerator/SequenceGeneratorBase.php#L37-L44 | train |
Tecnocreaciones/ToolsBundle | Service/SequenceGenerator/SequenceGeneratorBase.php | SequenceGeneratorBase.setRef | public function setRef(ItemReferenceInterface $item)
{
$className = ClassUtils::getRealClass(get_class($item));
$classMap = $this->getClassMap();
if(!isset($classMap[$className])){
throw new LogicException(sprintf("No ha definido la configuracion de '%s' para generar su referencia",$className));
}
$resolver = new \Symfony\Component\OptionsResolver\OptionsResolver();
$resolver->setDefined([
"method","field","options","mask"
]);
$resolver->setDefaults([
'method' => 'buildRef',
'field' => 'ref',
'use_cache' => false,
// 'options' => array()
]);
$config = $resolver->resolve($classMap[$className]);
$config['className'] = $className;
$method = $config['method'];
$ref = $this->$method($item,$config);
$item->setRef($ref);
return $ref;
} | php | public function setRef(ItemReferenceInterface $item)
{
$className = ClassUtils::getRealClass(get_class($item));
$classMap = $this->getClassMap();
if(!isset($classMap[$className])){
throw new LogicException(sprintf("No ha definido la configuracion de '%s' para generar su referencia",$className));
}
$resolver = new \Symfony\Component\OptionsResolver\OptionsResolver();
$resolver->setDefined([
"method","field","options","mask"
]);
$resolver->setDefaults([
'method' => 'buildRef',
'field' => 'ref',
'use_cache' => false,
// 'options' => array()
]);
$config = $resolver->resolve($classMap[$className]);
$config['className'] = $className;
$method = $config['method'];
$ref = $this->$method($item,$config);
$item->setRef($ref);
return $ref;
} | [
"public",
"function",
"setRef",
"(",
"ItemReferenceInterface",
"$",
"item",
")",
"{",
"$",
"className",
"=",
"ClassUtils",
"::",
"getRealClass",
"(",
"get_class",
"(",
"$",
"item",
")",
")",
";",
"$",
"classMap",
"=",
"$",
"this",
"->",
"getClassMap",
"(",... | Establece la referencia aun objeto
@param ItemReferenceInterface $item
@return type
@throws LogicException | [
"Establece",
"la",
"referencia",
"aun",
"objeto"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Service/SequenceGenerator/SequenceGeneratorBase.php#L52-L77 | train |
Tecnocreaciones/ToolsBundle | Service/SequenceGenerator/SequenceGeneratorBase.php | SequenceGeneratorBase.setSequenceGenerator | function setSequenceGenerator(\Tecnocreaciones\Bundle\ToolsBundle\Service\SequenceGenerator $sequenceGenerator) {
$this->sequenceGenerator = $sequenceGenerator;
} | php | function setSequenceGenerator(\Tecnocreaciones\Bundle\ToolsBundle\Service\SequenceGenerator $sequenceGenerator) {
$this->sequenceGenerator = $sequenceGenerator;
} | [
"function",
"setSequenceGenerator",
"(",
"\\",
"Tecnocreaciones",
"\\",
"Bundle",
"\\",
"ToolsBundle",
"\\",
"Service",
"\\",
"SequenceGenerator",
"$",
"sequenceGenerator",
")",
"{",
"$",
"this",
"->",
"sequenceGenerator",
"=",
"$",
"sequenceGenerator",
";",
"}"
] | Establece el generador de secuencia
@param \Tecnocreaciones\Bundle\ToolsBundle\Service\SequenceGenerator $sequenceGenerator | [
"Establece",
"el",
"generador",
"de",
"secuencia"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Service/SequenceGenerator/SequenceGeneratorBase.php#L83-L85 | train |
Tecnocreaciones/ToolsBundle | Twig/Extension/UtilsExtension.php | UtilsExtension.renderTabs | public function renderTabs(\Tecnoready\Common\Model\Tab\Tab $tab,array $parameters = [])
{
$parameters["tab"] = $tab;
return $this->container->get('templating')->render($this->config["tabs"]["template"],
$parameters
);
} | php | public function renderTabs(\Tecnoready\Common\Model\Tab\Tab $tab,array $parameters = [])
{
$parameters["tab"] = $tab;
return $this->container->get('templating')->render($this->config["tabs"]["template"],
$parameters
);
} | [
"public",
"function",
"renderTabs",
"(",
"\\",
"Tecnoready",
"\\",
"Common",
"\\",
"Model",
"\\",
"Tab",
"\\",
"Tab",
"$",
"tab",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"[",
"\"tab\"",
"]",
"=",
"$",
"tab",
";",
... | Render base tabs
@author Máximo Sojo maxsojo13@gmail.com <maxtoan at atechnologies>
@param \Atechnologies\ToolsBundle\Model\Core\Tab\Tab
@param array
@return [type] | [
"Render",
"base",
"tabs"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Twig/Extension/UtilsExtension.php#L266-L272 | train |
vaniocz/easy-mailer | src/HtmlMessageContent.php | HtmlMessageContent.asPlainText | public function asPlainText(): string
{
return $this->text ?? $this->text = (new Html2Text($this->html))->getText();
} | php | public function asPlainText(): string
{
return $this->text ?? $this->text = (new Html2Text($this->html))->getText();
} | [
"public",
"function",
"asPlainText",
"(",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"text",
"??",
"$",
"this",
"->",
"text",
"=",
"(",
"new",
"Html2Text",
"(",
"$",
"this",
"->",
"html",
")",
")",
"->",
"getText",
"(",
")",
";",
"}"
] | Convert this content into a plain text.
@return string This content as a plain text. | [
"Convert",
"this",
"content",
"into",
"a",
"plain",
"text",
"."
] | 5795dade8b8cca5590a74a7d99408c8947b1215e | https://github.com/vaniocz/easy-mailer/blob/5795dade8b8cca5590a74a7d99408c8947b1215e/src/HtmlMessageContent.php#L71-L74 | train |
spiral/odm | source/Spiral/ODM/Schemas/SchemaBuilder.php | SchemaBuilder.packSchema | public function packSchema(): array
{
$result = [];
foreach ($this->schemas as $class => $schema) {
$item = [
//Instantiator class
ODMInterface::D_INSTANTIATOR => $schema->getInstantiator(),
//Primary collection class
ODMInterface::D_PRIMARY_CLASS => $schema->resolvePrimary($this),
//Instantiator and entity specific schema
ODMInterface::D_SCHEMA => $schema->packSchema($this),
];
if (!$schema->isEmbedded()) {
$item[ODMInterface::D_SOURCE_CLASS] = $this->getSource($class);
$item[ODMInterface::D_DATABASE] = $schema->getDatabase();
$item[ODMInterface::D_COLLECTION] = $schema->getCollection();
}
$result[$class] = $item;
}
return $result;
} | php | public function packSchema(): array
{
$result = [];
foreach ($this->schemas as $class => $schema) {
$item = [
//Instantiator class
ODMInterface::D_INSTANTIATOR => $schema->getInstantiator(),
//Primary collection class
ODMInterface::D_PRIMARY_CLASS => $schema->resolvePrimary($this),
//Instantiator and entity specific schema
ODMInterface::D_SCHEMA => $schema->packSchema($this),
];
if (!$schema->isEmbedded()) {
$item[ODMInterface::D_SOURCE_CLASS] = $this->getSource($class);
$item[ODMInterface::D_DATABASE] = $schema->getDatabase();
$item[ODMInterface::D_COLLECTION] = $schema->getCollection();
}
$result[$class] = $item;
}
return $result;
} | [
"public",
"function",
"packSchema",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"schemas",
"as",
"$",
"class",
"=>",
"$",
"schema",
")",
"{",
"$",
"item",
"=",
"[",
"//Instantiator class",
"ODMIn... | Pack declared schemas in a normalized form.
@return array | [
"Pack",
"declared",
"schemas",
"in",
"a",
"normalized",
"form",
"."
] | 06087691a05dcfaa86c6c461660c6029db4de06e | https://github.com/spiral/odm/blob/06087691a05dcfaa86c6c461660c6029db4de06e/source/Spiral/ODM/Schemas/SchemaBuilder.php#L167-L192 | train |
spiral/odm | source/Spiral/ODM/Schemas/SchemaBuilder.php | SchemaBuilder.createIndexes | public function createIndexes()
{
foreach ($this->schemas as $class => $schema) {
if ($schema->isEmbedded()) {
continue;
}
$collection = $this->manager->database(
$schema->getDatabase()
)->selectCollection(
$schema->getCollection()
);
//Declaring needed indexes
foreach ($schema->getIndexes() as $index) {
$collection->createIndex($index->getIndex(), $index->getOptions());
}
}
} | php | public function createIndexes()
{
foreach ($this->schemas as $class => $schema) {
if ($schema->isEmbedded()) {
continue;
}
$collection = $this->manager->database(
$schema->getDatabase()
)->selectCollection(
$schema->getCollection()
);
//Declaring needed indexes
foreach ($schema->getIndexes() as $index) {
$collection->createIndex($index->getIndex(), $index->getOptions());
}
}
} | [
"public",
"function",
"createIndexes",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"schemas",
"as",
"$",
"class",
"=>",
"$",
"schema",
")",
"{",
"if",
"(",
"$",
"schema",
"->",
"isEmbedded",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"col... | Create all declared indexes.
@throws UnsupportedException
@throws DriverException | [
"Create",
"all",
"declared",
"indexes",
"."
] | 06087691a05dcfaa86c6c461660c6029db4de06e | https://github.com/spiral/odm/blob/06087691a05dcfaa86c6c461660c6029db4de06e/source/Spiral/ODM/Schemas/SchemaBuilder.php#L200-L218 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Response/FileDownloader.php | FileDownloader.prepare | private function prepare($mimeType, $baseName)
{
// Ensure that output buffering is turned off. @ - intentionally
@ob_end_clean();
// Special hack for legacy IE version
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
// Prepare required headers
$headers = array(
'Content-Type' => $mimeType,
'Content-Disposition' => sprintf('attachment; filename="%s"', rawurldecode($baseName)),
'Content-Transfer-Encoding' => 'binary',
'Accept-Ranges' => 'bytes',
'Cache-control' => 'private',
'Pragma' => 'private',
'Expires' => 'Thu, 21 Jul 1999 05:00:00 GMT'
);
$this->headerBag->appendPairs($headers)
->send()
->clear();
} | php | private function prepare($mimeType, $baseName)
{
// Ensure that output buffering is turned off. @ - intentionally
@ob_end_clean();
// Special hack for legacy IE version
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
// Prepare required headers
$headers = array(
'Content-Type' => $mimeType,
'Content-Disposition' => sprintf('attachment; filename="%s"', rawurldecode($baseName)),
'Content-Transfer-Encoding' => 'binary',
'Accept-Ranges' => 'bytes',
'Cache-control' => 'private',
'Pragma' => 'private',
'Expires' => 'Thu, 21 Jul 1999 05:00:00 GMT'
);
$this->headerBag->appendPairs($headers)
->send()
->clear();
} | [
"private",
"function",
"prepare",
"(",
"$",
"mimeType",
",",
"$",
"baseName",
")",
"{",
"// Ensure that output buffering is turned off. @ - intentionally",
"@",
"ob_end_clean",
"(",
")",
";",
"// Special hack for legacy IE version",
"if",
"(",
"ini_get",
"(",
"'zlib.outpu... | Prepares initial headers to be sent with minor tweaks
@param string $mimeType
@param string $baseName
@return void | [
"Prepares",
"initial",
"headers",
"to",
"be",
"sent",
"with",
"minor",
"tweaks"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Response/FileDownloader.php#L45-L69 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Response/FileDownloader.php | FileDownloader.preload | private function preload($target, $alias)
{
if (!is_file($target) || !is_readable($target)) {
throw new RuntimeException('Either invalid file supplied or its not readable');
}
// Prepare base name
if ($alias === null) {
$baseName = FileManager::getBaseName($target);
} else {
$baseName = $alias;
}
// Grab the Mime-Type
$mime = FileManager::getMimeType($target);
$this->prepare($mime, $baseName);
} | php | private function preload($target, $alias)
{
if (!is_file($target) || !is_readable($target)) {
throw new RuntimeException('Either invalid file supplied or its not readable');
}
// Prepare base name
if ($alias === null) {
$baseName = FileManager::getBaseName($target);
} else {
$baseName = $alias;
}
// Grab the Mime-Type
$mime = FileManager::getMimeType($target);
$this->prepare($mime, $baseName);
} | [
"private",
"function",
"preload",
"(",
"$",
"target",
",",
"$",
"alias",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"target",
")",
"||",
"!",
"is_readable",
"(",
"$",
"target",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Either invali... | Preloads all required params
@param string $target
@param string $alias Appears as alias
@throws \RuntimeException If can't access the target file
@return void | [
"Preloads",
"all",
"required",
"params"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Response/FileDownloader.php#L79-L96 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Response/FileDownloader.php | FileDownloader.download | public function download($target, $alias = null)
{
$this->preload($target, $alias);
// Count file size in bytes
$size = filesize($target);
// multipart-download and download resuming support
if (isset($_SERVER['HTTP_RANGE'])) {
list($a, $range) = explode("=", $_SERVER['HTTP_RANGE'], 2);
list($range) = explode(",", $range, 2);
list($range, $range_end) = explode("-", $range);
$range = intval($range);
if (!$range_end) {
$range_end = $size - 1;
} else {
$range_end = intval($range_end);
}
$new_length = $range_end - $range + 1;
$headers = array(
'Content-Length' => $new_length,
'Content-Range' => sprintf('bytes %s', $range - $range_end / $size)
);
$this->headerBag->setStatusCode(206)
->setPairs($headers)
->send();
} else {
$new_length = $size;
$this->headerBag->appendPair('Content-Length', $size)
->send()
->clear();
}
$chunksize = 1024 * 1024;
$bytes_send = 0;
$target = fopen($target, 'r');
if (isset($_SERVER['HTTP_RANGE'])) {
fseek($target, $range);
}
while (!feof($target) && (!connection_aborted()) && ($bytes_send < $new_length)) {
$buffer = fread($target, $chunksize);
print($buffer);
flush();
$bytes_send += strlen($buffer);
}
fclose($target);
} | php | public function download($target, $alias = null)
{
$this->preload($target, $alias);
// Count file size in bytes
$size = filesize($target);
// multipart-download and download resuming support
if (isset($_SERVER['HTTP_RANGE'])) {
list($a, $range) = explode("=", $_SERVER['HTTP_RANGE'], 2);
list($range) = explode(",", $range, 2);
list($range, $range_end) = explode("-", $range);
$range = intval($range);
if (!$range_end) {
$range_end = $size - 1;
} else {
$range_end = intval($range_end);
}
$new_length = $range_end - $range + 1;
$headers = array(
'Content-Length' => $new_length,
'Content-Range' => sprintf('bytes %s', $range - $range_end / $size)
);
$this->headerBag->setStatusCode(206)
->setPairs($headers)
->send();
} else {
$new_length = $size;
$this->headerBag->appendPair('Content-Length', $size)
->send()
->clear();
}
$chunksize = 1024 * 1024;
$bytes_send = 0;
$target = fopen($target, 'r');
if (isset($_SERVER['HTTP_RANGE'])) {
fseek($target, $range);
}
while (!feof($target) && (!connection_aborted()) && ($bytes_send < $new_length)) {
$buffer = fread($target, $chunksize);
print($buffer);
flush();
$bytes_send += strlen($buffer);
}
fclose($target);
} | [
"public",
"function",
"download",
"(",
"$",
"target",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"preload",
"(",
"$",
"target",
",",
"$",
"alias",
")",
";",
"// Count file size in bytes",
"$",
"size",
"=",
"filesize",
"(",
"$",
"targe... | Sends downloadable headers for a file
@param string $filename A path to the target file
@param string $alias Basename name can be optionally changed
@throws \RuntimeException If can't access the target file
@return void | [
"Sends",
"downloadable",
"headers",
"for",
"a",
"file"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Response/FileDownloader.php#L106-L164 | train |
krystal-framework/krystal.framework | src/Krystal/Application/Controller/AbstractController.php | AbstractController.redirectToRoute | final protected function redirectToRoute($route)
{
$url = $this->urlBuilder->build($route);
if ($url !== null) {
$this->response->redirect($url);
} else {
throw new RuntimeException(sprintf('Unknown route supplied for redirection "%s"', $route));
}
} | php | final protected function redirectToRoute($route)
{
$url = $this->urlBuilder->build($route);
if ($url !== null) {
$this->response->redirect($url);
} else {
throw new RuntimeException(sprintf('Unknown route supplied for redirection "%s"', $route));
}
} | [
"final",
"protected",
"function",
"redirectToRoute",
"(",
"$",
"route",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"urlBuilder",
"->",
"build",
"(",
"$",
"route",
")",
";",
"if",
"(",
"$",
"url",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"resp... | Redirects to given route
@param string $route Target route
@throws \RuntimeException if unknown route supplied
@return void | [
"Redirects",
"to",
"given",
"route"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Controller/AbstractController.php#L127-L136 | train |
krystal-framework/krystal.framework | src/Krystal/Application/Controller/AbstractController.php | AbstractController.getQueryFilter | final protected function getQueryFilter(FilterableServiceInterface $service, $perPageCount, $route)
{
$invoker = new FilterInvoker($this->request->getQuery(), $route);
return $invoker->invoke($service, $perPageCount);
} | php | final protected function getQueryFilter(FilterableServiceInterface $service, $perPageCount, $route)
{
$invoker = new FilterInvoker($this->request->getQuery(), $route);
return $invoker->invoke($service, $perPageCount);
} | [
"final",
"protected",
"function",
"getQueryFilter",
"(",
"FilterableServiceInterface",
"$",
"service",
",",
"$",
"perPageCount",
",",
"$",
"route",
")",
"{",
"$",
"invoker",
"=",
"new",
"FilterInvoker",
"(",
"$",
"this",
"->",
"request",
"->",
"getQuery",
"(",... | Applies filtering method from the service that implements corresponding interface
That's just a shortcut method
@param \Krystal\Db\Filter\FilterableServiceInterface $service A service which implement this interface
@param integer $perPageCount Items per page to display
@param string $route Base route
@return array | [
"Applies",
"filtering",
"method",
"from",
"the",
"service",
"that",
"implements",
"corresponding",
"interface",
"That",
"s",
"just",
"a",
"shortcut",
"method"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Controller/AbstractController.php#L159-L163 | train |
krystal-framework/krystal.framework | src/Krystal/Application/Controller/AbstractController.php | AbstractController.getOptions | public function getOptions($key = null)
{
if ($key == null) {
return $this->options;
} else {
return $this->options[$key];
}
} | php | public function getOptions($key = null)
{
if ($key == null) {
return $this->options;
} else {
return $this->options[$key];
}
} | [
"public",
"function",
"getOptions",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"options",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]"... | Returns current options for a matched controller
@param string $key
@return array | [
"Returns",
"current",
"options",
"for",
"a",
"matched",
"controller"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Controller/AbstractController.php#L245-L252 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.