id
int32 0
241k
| 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
|
---|---|---|---|---|---|---|---|---|---|---|---|
18,700 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Style/TableFull.php | PHPWord_Style_TableFull.setBorderSize | public function setBorderSize($pValue = null) {
$this->_borderTopSize = $pValue;
$this->_borderLeftSize = $pValue;
$this->_borderRightSize = $pValue;
$this->_borderBottomSize = $pValue;
$this->_borderInsideHSize = $pValue;
$this->_borderInsideVSize = $pValue;
} | php | public function setBorderSize($pValue = null) {
$this->_borderTopSize = $pValue;
$this->_borderLeftSize = $pValue;
$this->_borderRightSize = $pValue;
$this->_borderBottomSize = $pValue;
$this->_borderInsideHSize = $pValue;
$this->_borderInsideVSize = $pValue;
} | [
"public",
"function",
"setBorderSize",
"(",
"$",
"pValue",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_borderTopSize",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderLeftSize",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderRightSize",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderBottomSize",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderInsideHSize",
"=",
"$",
"pValue",
";",
"$",
"this",
"->",
"_borderInsideVSize",
"=",
"$",
"pValue",
";",
"}"
]
| Set TLRBVH Border Size
@param int $pValue | [
"Set",
"TLRBVH",
"Border",
"Size"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style/TableFull.php#L250-L257 |
18,701 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Style/TableFull.php | PHPWord_Style_TableFull.getBorderSize | public function getBorderSize() {
$t = $this->getBorderTopSize();
$l = $this->getBorderLeftSize();
$r = $this->getBorderRightSize();
$b = $this->getBorderBottomSize();
$h = $this->getBorderInsideHSize();
$v = $this->getBorderInsideVSize();
return array($t, $l, $r, $b, $h, $v);
} | php | public function getBorderSize() {
$t = $this->getBorderTopSize();
$l = $this->getBorderLeftSize();
$r = $this->getBorderRightSize();
$b = $this->getBorderBottomSize();
$h = $this->getBorderInsideHSize();
$v = $this->getBorderInsideVSize();
return array($t, $l, $r, $b, $h, $v);
} | [
"public",
"function",
"getBorderSize",
"(",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"getBorderTopSize",
"(",
")",
";",
"$",
"l",
"=",
"$",
"this",
"->",
"getBorderLeftSize",
"(",
")",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"getBorderRightSize",
"(",
")",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"getBorderBottomSize",
"(",
")",
";",
"$",
"h",
"=",
"$",
"this",
"->",
"getBorderInsideHSize",
"(",
")",
";",
"$",
"v",
"=",
"$",
"this",
"->",
"getBorderInsideVSize",
"(",
")",
";",
"return",
"array",
"(",
"$",
"t",
",",
"$",
"l",
",",
"$",
"r",
",",
"$",
"b",
",",
"$",
"h",
",",
"$",
"v",
")",
";",
"}"
]
| Get TLRBVH Border Size
@return array | [
"Get",
"TLRBVH",
"Border",
"Size"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style/TableFull.php#L264-L273 |
18,702 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Style/TableFull.php | PHPWord_Style_TableFull.getBorderColor | public function getBorderColor() {
$t = $this->getBorderTopColor();
$l = $this->getBorderLeftColor();
$r = $this->getBorderRightColor();
$b = $this->getBorderBottomColor();
$h = $this->getBorderInsideHColor();
$v = $this->getBorderInsideVColor();
return array($t, $l, $r, $b, $h, $v);
} | php | public function getBorderColor() {
$t = $this->getBorderTopColor();
$l = $this->getBorderLeftColor();
$r = $this->getBorderRightColor();
$b = $this->getBorderBottomColor();
$h = $this->getBorderInsideHColor();
$v = $this->getBorderInsideVColor();
return array($t, $l, $r, $b, $h, $v);
} | [
"public",
"function",
"getBorderColor",
"(",
")",
"{",
"$",
"t",
"=",
"$",
"this",
"->",
"getBorderTopColor",
"(",
")",
";",
"$",
"l",
"=",
"$",
"this",
"->",
"getBorderLeftColor",
"(",
")",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"getBorderRightColor",
"(",
")",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"getBorderBottomColor",
"(",
")",
";",
"$",
"h",
"=",
"$",
"this",
"->",
"getBorderInsideHColor",
"(",
")",
";",
"$",
"v",
"=",
"$",
"this",
"->",
"getBorderInsideVColor",
"(",
")",
";",
"return",
"array",
"(",
"$",
"t",
",",
"$",
"l",
",",
"$",
"r",
",",
"$",
"b",
",",
"$",
"h",
",",
"$",
"v",
")",
";",
"}"
]
| Get TLRB Border Color
@return array | [
"Get",
"TLRB",
"Border",
"Color"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style/TableFull.php#L292-L301 |
18,703 | ClanCats/Core | src/classes/CCShipyard.php | CCShipyard.create | public static function create()
{
$arguments = func_get_args();
$name = array_shift( $arguments );
$class_name = "Core\\CCShipyard_".ucfirst( $name );
if ( !class_exists( $class_name ) )
{
throw new CCException( "CCShipyard - invalid builder (".$name.") given." );
}
$builder = new $class_name;
call_user_func_array( array( $builder, 'create' ), $arguments );
return $builder;
} | php | public static function create()
{
$arguments = func_get_args();
$name = array_shift( $arguments );
$class_name = "Core\\CCShipyard_".ucfirst( $name );
if ( !class_exists( $class_name ) )
{
throw new CCException( "CCShipyard - invalid builder (".$name.") given." );
}
$builder = new $class_name;
call_user_func_array( array( $builder, 'create' ), $arguments );
return $builder;
} | [
"public",
"static",
"function",
"create",
"(",
")",
"{",
"$",
"arguments",
"=",
"func_get_args",
"(",
")",
";",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"arguments",
")",
";",
"$",
"class_name",
"=",
"\"Core\\\\CCShipyard_\"",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class_name",
")",
")",
"{",
"throw",
"new",
"CCException",
"(",
"\"CCShipyard - invalid builder (\"",
".",
"$",
"name",
".",
"\") given.\"",
")",
";",
"}",
"$",
"builder",
"=",
"new",
"$",
"class_name",
";",
"call_user_func_array",
"(",
"array",
"(",
"$",
"builder",
",",
"'create'",
")",
",",
"$",
"arguments",
")",
";",
"return",
"$",
"builder",
";",
"}"
]
| Static call wrapper to require the right builder
@param string $name
@param array $arguments
@return CCShipyard_Builder | [
"Static",
"call",
"wrapper",
"to",
"require",
"the",
"right",
"builder"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCShipyard.php#L21-L39 |
18,704 | picamator/CacheManager | src/Operation/Search.php | Search.hasValidCacheItem | private function hasValidCacheItem(CacheItemInterface $cacheItem, array $fieldList) : bool
{
$data = $cacheItem->get();
if (is_null($data)) {
return false;
}
$fieldDiff = array_diff($fieldList, array_keys($data));
return !$fieldDiff;
} | php | private function hasValidCacheItem(CacheItemInterface $cacheItem, array $fieldList) : bool
{
$data = $cacheItem->get();
if (is_null($data)) {
return false;
}
$fieldDiff = array_diff($fieldList, array_keys($data));
return !$fieldDiff;
} | [
"private",
"function",
"hasValidCacheItem",
"(",
"CacheItemInterface",
"$",
"cacheItem",
",",
"array",
"$",
"fieldList",
")",
":",
"bool",
"{",
"$",
"data",
"=",
"$",
"cacheItem",
"->",
"get",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"fieldDiff",
"=",
"array_diff",
"(",
"$",
"fieldList",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
";",
"return",
"!",
"$",
"fieldDiff",
";",
"}"
]
| Has valid cache item.
@param CacheItemInterface $cacheItem
@param array $fieldList
@return bool | [
"Has",
"valid",
"cache",
"item",
"."
]
| 5e5493910610b65ae31a362786d7963ba3e33806 | https://github.com/picamator/CacheManager/blob/5e5493910610b65ae31a362786d7963ba3e33806/src/Operation/Search.php#L84-L94 |
18,705 | picamator/CacheManager | src/Operation/Search.php | Search.getCacheItemGenerator | private function getCacheItemGenerator(SearchCriteriaInterface $searchCriteria)
{
try {
foreach ($searchCriteria->getIdList() as $item) {
$cacheKey = $this->keyGenerator->generate($item, $searchCriteria);
yield $item => $this->cacheItemPool->getItem($cacheKey);
}
} catch (PsrCacheInvalidArgumentException $e) {
throw new InvalidCacheKeyException($e->getMessage(), $e->getCode(), $e);
}
} | php | private function getCacheItemGenerator(SearchCriteriaInterface $searchCriteria)
{
try {
foreach ($searchCriteria->getIdList() as $item) {
$cacheKey = $this->keyGenerator->generate($item, $searchCriteria);
yield $item => $this->cacheItemPool->getItem($cacheKey);
}
} catch (PsrCacheInvalidArgumentException $e) {
throw new InvalidCacheKeyException($e->getMessage(), $e->getCode(), $e);
}
} | [
"private",
"function",
"getCacheItemGenerator",
"(",
"SearchCriteriaInterface",
"$",
"searchCriteria",
")",
"{",
"try",
"{",
"foreach",
"(",
"$",
"searchCriteria",
"->",
"getIdList",
"(",
")",
"as",
"$",
"item",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"keyGenerator",
"->",
"generate",
"(",
"$",
"item",
",",
"$",
"searchCriteria",
")",
";",
"yield",
"$",
"item",
"=>",
"$",
"this",
"->",
"cacheItemPool",
"->",
"getItem",
"(",
"$",
"cacheKey",
")",
";",
"}",
"}",
"catch",
"(",
"PsrCacheInvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidCacheKeyException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
]
| Retrieve cache data generator.
@param SearchCriteriaInterface $searchCriteria
@throws InvalidCacheKeyException
@return void | [
"Retrieve",
"cache",
"data",
"generator",
"."
]
| 5e5493910610b65ae31a362786d7963ba3e33806 | https://github.com/picamator/CacheManager/blob/5e5493910610b65ae31a362786d7963ba3e33806/src/Operation/Search.php#L105-L116 |
18,706 | cohesion/cohesion-core | src/Structure/Factory/UtilityFactory.php | UtilityFactory.get | public function get($class) {
if ($class instanceof ReflectionClass) {
$reflection = $class;
$class = $reflection->getName();
}
if (isset($this->utils[$class])) {
return $this->utils[$class];
}
if (!isset($reflection)) {
if (!class_exists($class) && !interface_exists($class)) {
throw new InvalidClassException("$class doesn't exist");
}
$reflection = new ReflectionClass($class);
}
$config = null;
if ($this->config) {
$config = $this->config->getConfig($class);
if (!$config) {
$config = $this->config->getConfig($reflection->getShortName());
}
}
if (!$config) {
if ($reflection->isInstantiable() && $this->getConstructor($reflection)->getNumberOfRequiredParameters() == 0) {
return $reflection->newInstance();
} else {
throw new MissingConfigurationException("No configuration found for utility $class");
}
}
$driver = $config->get('driver');
if (!$driver) {
if ($reflection->isInstantiable()) {
$driver = $reflection->getName();
$driverReflection = $reflection;
} else {
throw new MissingConfigurationException("Configuration for $class must include a driver");
}
} else {
if (!class_exists($driver)) {
throw new InvalidClassException("$class driver $driver doesn't exist");
}
$driverReflection = new ReflectionClass($driver);
if (!$driverReflection->isInstantiable()) {
throw new InvalidClassException("$class driver $driver is not instantiable");
}
}
$utility = $this->getClass($driverReflection, $config);
$this->utils[$class] = $utility;
return $utility;
} | php | public function get($class) {
if ($class instanceof ReflectionClass) {
$reflection = $class;
$class = $reflection->getName();
}
if (isset($this->utils[$class])) {
return $this->utils[$class];
}
if (!isset($reflection)) {
if (!class_exists($class) && !interface_exists($class)) {
throw new InvalidClassException("$class doesn't exist");
}
$reflection = new ReflectionClass($class);
}
$config = null;
if ($this->config) {
$config = $this->config->getConfig($class);
if (!$config) {
$config = $this->config->getConfig($reflection->getShortName());
}
}
if (!$config) {
if ($reflection->isInstantiable() && $this->getConstructor($reflection)->getNumberOfRequiredParameters() == 0) {
return $reflection->newInstance();
} else {
throw new MissingConfigurationException("No configuration found for utility $class");
}
}
$driver = $config->get('driver');
if (!$driver) {
if ($reflection->isInstantiable()) {
$driver = $reflection->getName();
$driverReflection = $reflection;
} else {
throw new MissingConfigurationException("Configuration for $class must include a driver");
}
} else {
if (!class_exists($driver)) {
throw new InvalidClassException("$class driver $driver doesn't exist");
}
$driverReflection = new ReflectionClass($driver);
if (!$driverReflection->isInstantiable()) {
throw new InvalidClassException("$class driver $driver is not instantiable");
}
}
$utility = $this->getClass($driverReflection, $config);
$this->utils[$class] = $utility;
return $utility;
} | [
"public",
"function",
"get",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"instanceof",
"ReflectionClass",
")",
"{",
"$",
"reflection",
"=",
"$",
"class",
";",
"$",
"class",
"=",
"$",
"reflection",
"->",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"utils",
"[",
"$",
"class",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"utils",
"[",
"$",
"class",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"reflection",
")",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
"&&",
"!",
"interface_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"InvalidClassException",
"(",
"\"$class doesn't exist\"",
")",
";",
"}",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"}",
"$",
"config",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"config",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"->",
"getConfig",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"$",
"config",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"->",
"getConfig",
"(",
"$",
"reflection",
"->",
"getShortName",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"reflection",
"->",
"isInstantiable",
"(",
")",
"&&",
"$",
"this",
"->",
"getConstructor",
"(",
"$",
"reflection",
")",
"->",
"getNumberOfRequiredParameters",
"(",
")",
"==",
"0",
")",
"{",
"return",
"$",
"reflection",
"->",
"newInstance",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MissingConfigurationException",
"(",
"\"No configuration found for utility $class\"",
")",
";",
"}",
"}",
"$",
"driver",
"=",
"$",
"config",
"->",
"get",
"(",
"'driver'",
")",
";",
"if",
"(",
"!",
"$",
"driver",
")",
"{",
"if",
"(",
"$",
"reflection",
"->",
"isInstantiable",
"(",
")",
")",
"{",
"$",
"driver",
"=",
"$",
"reflection",
"->",
"getName",
"(",
")",
";",
"$",
"driverReflection",
"=",
"$",
"reflection",
";",
"}",
"else",
"{",
"throw",
"new",
"MissingConfigurationException",
"(",
"\"Configuration for $class must include a driver\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"driver",
")",
")",
"{",
"throw",
"new",
"InvalidClassException",
"(",
"\"$class driver $driver doesn't exist\"",
")",
";",
"}",
"$",
"driverReflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"driver",
")",
";",
"if",
"(",
"!",
"$",
"driverReflection",
"->",
"isInstantiable",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidClassException",
"(",
"\"$class driver $driver is not instantiable\"",
")",
";",
"}",
"}",
"$",
"utility",
"=",
"$",
"this",
"->",
"getClass",
"(",
"$",
"driverReflection",
",",
"$",
"config",
")",
";",
"$",
"this",
"->",
"utils",
"[",
"$",
"class",
"]",
"=",
"$",
"utility",
";",
"return",
"$",
"utility",
";",
"}"
]
| Get a utility class
@param mixed $class Either a string of the class name or an instance of a \ReflectionClass representing the utility to get
@return mixed The utility matching the given class
@throws InvalidClassException if either the utility class or the utility driver class doesn't exist
@throws MissingConfigurationException if the utility requires configuration and it doesn't have any, or one of the required variable is missing form the configuration | [
"Get",
"a",
"utility",
"class"
]
| c6352aef7336e06285f0943da68235dc45523998 | https://github.com/cohesion/cohesion-core/blob/c6352aef7336e06285f0943da68235dc45523998/src/Structure/Factory/UtilityFactory.php#L25-L74 |
18,707 | lmammino/e-foundation | src/Cart/Model/Cart.php | Cart.isExpired | public function isExpired()
{
if (null === $this->expiresAt) {
return false;
}
$now = new \DateTime();
return $this->expiresAt < $now;
} | php | public function isExpired()
{
if (null === $this->expiresAt) {
return false;
}
$now = new \DateTime();
return $this->expiresAt < $now;
} | [
"public",
"function",
"isExpired",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"expiresAt",
")",
"{",
"return",
"false",
";",
"}",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"return",
"$",
"this",
"->",
"expiresAt",
"<",
"$",
"now",
";",
"}"
]
| Checks whether the cart is expired or not.
@return Boolean | [
"Checks",
"whether",
"the",
"cart",
"is",
"expired",
"or",
"not",
"."
]
| 198b7047d93eb11c9bc0c7ddf0bfa8229d42807a | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Cart/Model/Cart.php#L146-L155 |
18,708 | titon/db | src/Titon/Db/Query/BindingAware.php | BindingAware.addBinding | public function addBinding($field, $values) {
if (!is_array($values)) {
$values = [$values];
}
foreach ($values as $value) {
if ($value instanceof Predicate) {
$this->resolvePredicate($value);
} else if ($value instanceof SubQuery) {
$this->resolveSubQuery($value);
} else {
$this->_bindings[] = [
'field' => $field,
'value' => $value
];
}
}
return $this;
} | php | public function addBinding($field, $values) {
if (!is_array($values)) {
$values = [$values];
}
foreach ($values as $value) {
if ($value instanceof Predicate) {
$this->resolvePredicate($value);
} else if ($value instanceof SubQuery) {
$this->resolveSubQuery($value);
} else {
$this->_bindings[] = [
'field' => $field,
'value' => $value
];
}
}
return $this;
} | [
"public",
"function",
"addBinding",
"(",
"$",
"field",
",",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"$",
"values",
"=",
"[",
"$",
"values",
"]",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Predicate",
")",
"{",
"$",
"this",
"->",
"resolvePredicate",
"(",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"$",
"value",
"instanceof",
"SubQuery",
")",
"{",
"$",
"this",
"->",
"resolveSubQuery",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_bindings",
"[",
"]",
"=",
"[",
"'field'",
"=>",
"$",
"field",
",",
"'value'",
"=>",
"$",
"value",
"]",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a value to use in SQL parameter binding.
@param string $field
@param mixed $values
@return $this | [
"Add",
"a",
"value",
"to",
"use",
"in",
"SQL",
"parameter",
"binding",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/BindingAware.php#L32-L53 |
18,709 | titon/db | src/Titon/Db/Query/BindingAware.php | BindingAware.resolvePredicate | public function resolvePredicate(Predicate $predicate) {
$this->_bindings = array_merge($this->_bindings, $predicate->getBindings());
return $this;
} | php | public function resolvePredicate(Predicate $predicate) {
$this->_bindings = array_merge($this->_bindings, $predicate->getBindings());
return $this;
} | [
"public",
"function",
"resolvePredicate",
"(",
"Predicate",
"$",
"predicate",
")",
"{",
"$",
"this",
"->",
"_bindings",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_bindings",
",",
"$",
"predicate",
"->",
"getBindings",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Merge an external predicates bindings with the current bindings.
@param \Titon\Db\Query\Predicate $predicate
@return $this | [
"Merge",
"an",
"external",
"predicates",
"bindings",
"with",
"the",
"current",
"bindings",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/BindingAware.php#L70-L74 |
18,710 | titon/db | src/Titon/Db/Query/BindingAware.php | BindingAware.resolveSubQuery | public function resolveSubQuery(SubQuery $query) {
foreach ($query->getGroupedBindings() as $bindings) {
$this->_bindings = array_merge($this->_bindings, $bindings);
}
return $this;
} | php | public function resolveSubQuery(SubQuery $query) {
foreach ($query->getGroupedBindings() as $bindings) {
$this->_bindings = array_merge($this->_bindings, $bindings);
}
return $this;
} | [
"public",
"function",
"resolveSubQuery",
"(",
"SubQuery",
"$",
"query",
")",
"{",
"foreach",
"(",
"$",
"query",
"->",
"getGroupedBindings",
"(",
")",
"as",
"$",
"bindings",
")",
"{",
"$",
"this",
"->",
"_bindings",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_bindings",
",",
"$",
"bindings",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Merge an external sub-queries bindings with the current bindings.
@param \Titon\Db\Query\SubQuery $query
@return $this | [
"Merge",
"an",
"external",
"sub",
"-",
"queries",
"bindings",
"with",
"the",
"current",
"bindings",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/BindingAware.php#L82-L88 |
18,711 | simple-php-mvc/simple-php-mvc | src/MVC/Injection/Extension.php | Extension.getRootDirModule | public function getRootDirModule()
{
$r = new \ReflectionObject($this);
$injectionDir = str_replace('\\', '/', dirname($r->getFileName()));
return $injectionDir . '/..';
} | php | public function getRootDirModule()
{
$r = new \ReflectionObject($this);
$injectionDir = str_replace('\\', '/', dirname($r->getFileName()));
return $injectionDir . '/..';
} | [
"public",
"function",
"getRootDirModule",
"(",
")",
"{",
"$",
"r",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"this",
")",
";",
"$",
"injectionDir",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"dirname",
"(",
"$",
"r",
"->",
"getFileName",
"(",
")",
")",
")",
";",
"return",
"$",
"injectionDir",
".",
"'/..'",
";",
"}"
]
| Get Root Dir Module
@return string Root Dir Module | [
"Get",
"Root",
"Dir",
"Module"
]
| e319eb09d29afad6993acb4a7e35f32a87dd0841 | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Injection/Extension.php#L74-L79 |
18,712 | simple-php-mvc/simple-php-mvc | src/MVC/Injection/Extension.php | Extension.loadRoutes | public function loadRoutes()
{
$routesJsonFile = $this->configDir . '/routes.json';
$routesPhpFile = $this->configDir . '/routes.php';
if (file_exists($this->resourcesDir) && file_exists($this->configDir)) {
if (file_exists($routesJsonFile))
return json_decode(file_get_contents($routesJsonFile), true);
elseif (file_exists($routesPhpFile))
return require_once $routesPhpFile;
} else {
return array();
}
} | php | public function loadRoutes()
{
$routesJsonFile = $this->configDir . '/routes.json';
$routesPhpFile = $this->configDir . '/routes.php';
if (file_exists($this->resourcesDir) && file_exists($this->configDir)) {
if (file_exists($routesJsonFile))
return json_decode(file_get_contents($routesJsonFile), true);
elseif (file_exists($routesPhpFile))
return require_once $routesPhpFile;
} else {
return array();
}
} | [
"public",
"function",
"loadRoutes",
"(",
")",
"{",
"$",
"routesJsonFile",
"=",
"$",
"this",
"->",
"configDir",
".",
"'/routes.json'",
";",
"$",
"routesPhpFile",
"=",
"$",
"this",
"->",
"configDir",
".",
"'/routes.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"resourcesDir",
")",
"&&",
"file_exists",
"(",
"$",
"this",
"->",
"configDir",
")",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"routesJsonFile",
")",
")",
"return",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"routesJsonFile",
")",
",",
"true",
")",
";",
"elseif",
"(",
"file_exists",
"(",
"$",
"routesPhpFile",
")",
")",
"return",
"require_once",
"$",
"routesPhpFile",
";",
"}",
"else",
"{",
"return",
"array",
"(",
")",
";",
"}",
"}"
]
| Load routes of the Module
@return array | [
"Load",
"routes",
"of",
"the",
"Module"
]
| e319eb09d29afad6993acb4a7e35f32a87dd0841 | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Injection/Extension.php#L86-L99 |
18,713 | miisieq/InfaktClient | src/Infakt/Mapper/ReverseMapperTrait.php | ReverseMapperTrait.reverseMapPrice | public function reverseMapPrice(?float $price): ?int
{
if (null === $price) {
return null;
}
if (0.00 === $price) {
return 0;
}
return (int) str_replace('.', '', number_format($price, 2, '.', ''));
} | php | public function reverseMapPrice(?float $price): ?int
{
if (null === $price) {
return null;
}
if (0.00 === $price) {
return 0;
}
return (int) str_replace('.', '', number_format($price, 2, '.', ''));
} | [
"public",
"function",
"reverseMapPrice",
"(",
"?",
"float",
"$",
"price",
")",
":",
"?",
"int",
"{",
"if",
"(",
"null",
"===",
"$",
"price",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"0.00",
"===",
"$",
"price",
")",
"{",
"return",
"0",
";",
"}",
"return",
"(",
"int",
")",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"number_format",
"(",
"$",
"price",
",",
"2",
",",
"'.'",
",",
"''",
")",
")",
";",
"}"
]
| Maps price to string.
@param float|null $price
@return int|null | [
"Maps",
"price",
"to",
"string",
"."
]
| 5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81 | https://github.com/miisieq/InfaktClient/blob/5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81/src/Infakt/Mapper/ReverseMapperTrait.php#L16-L27 |
18,714 | CakeCMS/Core | src/Notify/Email.php | Email.send | public function send($subject, $content, $to, $fromName = '', $fromEmail = '')
{
$mail = new CakeEmail();
$fromName = ($fromName !== '') ? $fromName : $this->_fromName;
$fromEmail = ($fromEmail !== '') ? $fromEmail : $this->_fromEmail;
$transport = new MailTransport();
return $mail
->setTransport($transport)
->setTemplate($this->_tpl)
->setEmailFormat($this->_format)
->setFrom($fromEmail, $fromName)
->setTo($to)
->setSubject($subject)
->setViewVars(['page_title' => $subject])
->send($content);
} | php | public function send($subject, $content, $to, $fromName = '', $fromEmail = '')
{
$mail = new CakeEmail();
$fromName = ($fromName !== '') ? $fromName : $this->_fromName;
$fromEmail = ($fromEmail !== '') ? $fromEmail : $this->_fromEmail;
$transport = new MailTransport();
return $mail
->setTransport($transport)
->setTemplate($this->_tpl)
->setEmailFormat($this->_format)
->setFrom($fromEmail, $fromName)
->setTo($to)
->setSubject($subject)
->setViewVars(['page_title' => $subject])
->send($content);
} | [
"public",
"function",
"send",
"(",
"$",
"subject",
",",
"$",
"content",
",",
"$",
"to",
",",
"$",
"fromName",
"=",
"''",
",",
"$",
"fromEmail",
"=",
"''",
")",
"{",
"$",
"mail",
"=",
"new",
"CakeEmail",
"(",
")",
";",
"$",
"fromName",
"=",
"(",
"$",
"fromName",
"!==",
"''",
")",
"?",
"$",
"fromName",
":",
"$",
"this",
"->",
"_fromName",
";",
"$",
"fromEmail",
"=",
"(",
"$",
"fromEmail",
"!==",
"''",
")",
"?",
"$",
"fromEmail",
":",
"$",
"this",
"->",
"_fromEmail",
";",
"$",
"transport",
"=",
"new",
"MailTransport",
"(",
")",
";",
"return",
"$",
"mail",
"->",
"setTransport",
"(",
"$",
"transport",
")",
"->",
"setTemplate",
"(",
"$",
"this",
"->",
"_tpl",
")",
"->",
"setEmailFormat",
"(",
"$",
"this",
"->",
"_format",
")",
"->",
"setFrom",
"(",
"$",
"fromEmail",
",",
"$",
"fromName",
")",
"->",
"setTo",
"(",
"$",
"to",
")",
"->",
"setSubject",
"(",
"$",
"subject",
")",
"->",
"setViewVars",
"(",
"[",
"'page_title'",
"=>",
"$",
"subject",
"]",
")",
"->",
"send",
"(",
"$",
"content",
")",
";",
"}"
]
| Send message method.
@param string $subject
@param string $content
@param string|array $to
@param string $fromName
@param string $fromEmail
@return array | [
"Send",
"message",
"method",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Notify/Email.php#L95-L111 |
18,715 | factorio-item-browser/export-data | src/Entity/Mod.php | Mod.setDependencies | public function setDependencies(array $dependencies)
{
$this->dependencies = array_values(array_filter($dependencies, function ($dependency): bool {
return $dependency instanceof Dependency;
}));
return $this;
} | php | public function setDependencies(array $dependencies)
{
$this->dependencies = array_values(array_filter($dependencies, function ($dependency): bool {
return $dependency instanceof Dependency;
}));
return $this;
} | [
"public",
"function",
"setDependencies",
"(",
"array",
"$",
"dependencies",
")",
"{",
"$",
"this",
"->",
"dependencies",
"=",
"array_values",
"(",
"array_filter",
"(",
"$",
"dependencies",
",",
"function",
"(",
"$",
"dependency",
")",
":",
"bool",
"{",
"return",
"$",
"dependency",
"instanceof",
"Dependency",
";",
"}",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the dependencies of the mod.
@param array|Dependency[] $dependencies
@return $this Implementing fluent interface. | [
"Sets",
"the",
"dependencies",
"of",
"the",
"mod",
"."
]
| 1413b2eed0fbfed0521457ac7ef0d668ac30c212 | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Mod.php#L258-L264 |
18,716 | xinix-technology/norm | src/Norm/Connection/BonoConnection.php | BonoConnection.restGet | public function restGet($cursor) {
if ($cursor instanceof Cursor) {
$name = $cursor->getCollection()->getName();
$criteria = $cursor->getCriteria();
$limit = $cursor->limit();
$skip = $cursor->skip();
$sorts = $cursor->sort();
$query = array();
foreach ($criteria as $key => $value) {
$query[$key] = $value;
}
if ($limit) {
$query['!limit'] = $limit;
}
if ($skip) {
$query['!skip'] = $skip;
}
if (!empty($sorts)) {
foreach ($sorts as $key => $value) {
$query["!sort[$key]"] = $value;
}
}
$qs = array();
foreach ($query as $key => $value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
$qs[] = '!'.$key.'='.$v;
}
} else {
$qs[] = $key.'='.$value;
}
}
if ($qs) {
$qs = '?'.implode('&', $qs);
} else {
$qs = '';
}
$url = $this->option('baseUrl').'/'.$name.'.json'.$qs;
$client = new Client();
$response = $client->get($url)->send();
return json_decode($response->getBody(true), true);
} else {
throw new Exception('Unimplemented yet!');
}
} | php | public function restGet($cursor) {
if ($cursor instanceof Cursor) {
$name = $cursor->getCollection()->getName();
$criteria = $cursor->getCriteria();
$limit = $cursor->limit();
$skip = $cursor->skip();
$sorts = $cursor->sort();
$query = array();
foreach ($criteria as $key => $value) {
$query[$key] = $value;
}
if ($limit) {
$query['!limit'] = $limit;
}
if ($skip) {
$query['!skip'] = $skip;
}
if (!empty($sorts)) {
foreach ($sorts as $key => $value) {
$query["!sort[$key]"] = $value;
}
}
$qs = array();
foreach ($query as $key => $value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
$qs[] = '!'.$key.'='.$v;
}
} else {
$qs[] = $key.'='.$value;
}
}
if ($qs) {
$qs = '?'.implode('&', $qs);
} else {
$qs = '';
}
$url = $this->option('baseUrl').'/'.$name.'.json'.$qs;
$client = new Client();
$response = $client->get($url)->send();
return json_decode($response->getBody(true), true);
} else {
throw new Exception('Unimplemented yet!');
}
} | [
"public",
"function",
"restGet",
"(",
"$",
"cursor",
")",
"{",
"if",
"(",
"$",
"cursor",
"instanceof",
"Cursor",
")",
"{",
"$",
"name",
"=",
"$",
"cursor",
"->",
"getCollection",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"criteria",
"=",
"$",
"cursor",
"->",
"getCriteria",
"(",
")",
";",
"$",
"limit",
"=",
"$",
"cursor",
"->",
"limit",
"(",
")",
";",
"$",
"skip",
"=",
"$",
"cursor",
"->",
"skip",
"(",
")",
";",
"$",
"sorts",
"=",
"$",
"cursor",
"->",
"sort",
"(",
")",
";",
"$",
"query",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"query",
"[",
"'!limit'",
"]",
"=",
"$",
"limit",
";",
"}",
"if",
"(",
"$",
"skip",
")",
"{",
"$",
"query",
"[",
"'!skip'",
"]",
"=",
"$",
"skip",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"sorts",
")",
")",
"{",
"foreach",
"(",
"$",
"sorts",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
"[",
"\"!sort[$key]\"",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"qs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"query",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"qs",
"[",
"]",
"=",
"'!'",
".",
"$",
"key",
".",
"'='",
".",
"$",
"v",
";",
"}",
"}",
"else",
"{",
"$",
"qs",
"[",
"]",
"=",
"$",
"key",
".",
"'='",
".",
"$",
"value",
";",
"}",
"}",
"if",
"(",
"$",
"qs",
")",
"{",
"$",
"qs",
"=",
"'?'",
".",
"implode",
"(",
"'&'",
",",
"$",
"qs",
")",
";",
"}",
"else",
"{",
"$",
"qs",
"=",
"''",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"option",
"(",
"'baseUrl'",
")",
".",
"'/'",
".",
"$",
"name",
".",
"'.json'",
".",
"$",
"qs",
";",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"$",
"response",
"=",
"$",
"client",
"->",
"get",
"(",
"$",
"url",
")",
"->",
"send",
"(",
")",
";",
"return",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
"true",
")",
",",
"true",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'Unimplemented yet!'",
")",
";",
"}",
"}"
]
| Get data from rest service.
@param \Norm\Cursor $cursor
@throws \Exception
@return array | [
"Get",
"data",
"from",
"rest",
"service",
"."
]
| c357f7d3a75d05324dd84b8f6a968a094c53d603 | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/BonoConnection.php#L52-L107 |
18,717 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addInstallMacroblock | public function addInstallMacroblock($name, $file, $url)
{
$macroblockElement = new InstallMacroblock($name, $file, $url);
return $this->addElement($macroblockElement);
} | php | public function addInstallMacroblock($name, $file, $url)
{
$macroblockElement = new InstallMacroblock($name, $file, $url);
return $this->addElement($macroblockElement);
} | [
"public",
"function",
"addInstallMacroblock",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
"{",
"$",
"macroblockElement",
"=",
"new",
"InstallMacroblock",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"macroblockElement",
")",
";",
"}"
]
| Install a Macroblock
@api
@param string $name Macroblock name
@param string $file Macroblock file
@param string $url Macroblock url
@return static | [
"Install",
"a",
"Macroblock"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L99-L103 |
18,718 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addInstallMap | public function addInstallMap($name, $url)
{
$mapElement = new InstallMap($name, $url);
return $this->addElement($mapElement);
} | php | public function addInstallMap($name, $url)
{
$mapElement = new InstallMap($name, $url);
return $this->addElement($mapElement);
} | [
"public",
"function",
"addInstallMap",
"(",
"$",
"name",
",",
"$",
"url",
")",
"{",
"$",
"mapElement",
"=",
"new",
"InstallMap",
"(",
"$",
"name",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"mapElement",
")",
";",
"}"
]
| Install a map
@api
@param string $name Map name
@param string $url Map url
@return static | [
"Install",
"a",
"map"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L113-L117 |
18,719 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addPlayMap | public function addPlayMap($name, $url)
{
$mapElement = new PlayMap($name, $url);
return $this->addElement($mapElement);
} | php | public function addPlayMap($name, $url)
{
$mapElement = new PlayMap($name, $url);
return $this->addElement($mapElement);
} | [
"public",
"function",
"addPlayMap",
"(",
"$",
"name",
",",
"$",
"url",
")",
"{",
"$",
"mapElement",
"=",
"new",
"PlayMap",
"(",
"$",
"name",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"mapElement",
")",
";",
"}"
]
| Play a map
@api
@param string $name Map name
@param string $url Map url
@return static | [
"Play",
"a",
"map"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L127-L131 |
18,720 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addInstallReplay | public function addInstallReplay($name, $url)
{
$replayElement = new InstallReplay($name, $url);
return $this->addElement($replayElement);
} | php | public function addInstallReplay($name, $url)
{
$replayElement = new InstallReplay($name, $url);
return $this->addElement($replayElement);
} | [
"public",
"function",
"addInstallReplay",
"(",
"$",
"name",
",",
"$",
"url",
")",
"{",
"$",
"replayElement",
"=",
"new",
"InstallReplay",
"(",
"$",
"name",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"replayElement",
")",
";",
"}"
]
| Install a replay
@api
@param string $name Replay name
@param string $url Replay url
@return static | [
"Install",
"a",
"replay"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L141-L145 |
18,721 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addViewReplay | public function addViewReplay($name, $url)
{
$replayElement = new ViewReplay($name, $url);
return $this->addElement($replayElement);
} | php | public function addViewReplay($name, $url)
{
$replayElement = new ViewReplay($name, $url);
return $this->addElement($replayElement);
} | [
"public",
"function",
"addViewReplay",
"(",
"$",
"name",
",",
"$",
"url",
")",
"{",
"$",
"replayElement",
"=",
"new",
"ViewReplay",
"(",
"$",
"name",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"replayElement",
")",
";",
"}"
]
| View a replay
@api
@param string $name Replay name
@param string $url Replay url
@return static | [
"View",
"a",
"replay"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L155-L159 |
18,722 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addPlayReplay | public function addPlayReplay($name, $url)
{
$replayElement = new PlayReplay($name, $url);
return $this->addElement($replayElement);
} | php | public function addPlayReplay($name, $url)
{
$replayElement = new PlayReplay($name, $url);
return $this->addElement($replayElement);
} | [
"public",
"function",
"addPlayReplay",
"(",
"$",
"name",
",",
"$",
"url",
")",
"{",
"$",
"replayElement",
"=",
"new",
"PlayReplay",
"(",
"$",
"name",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"replayElement",
")",
";",
"}"
]
| Play a replay
@api
@param string $name Replay name
@param string $url Replay url
@return static | [
"Play",
"a",
"replay"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L169-L173 |
18,723 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addInstallSkin | public function addInstallSkin($name, $file, $url)
{
$skinElement = new InstallSkin($name, $file, $url);
return $this->addElement($skinElement);
} | php | public function addInstallSkin($name, $file, $url)
{
$skinElement = new InstallSkin($name, $file, $url);
return $this->addElement($skinElement);
} | [
"public",
"function",
"addInstallSkin",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
"{",
"$",
"skinElement",
"=",
"new",
"InstallSkin",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"skinElement",
")",
";",
"}"
]
| Install a skin
@api
@param string $name Skin name
@param string $file Skin file
@param string $url Skin url
@return static | [
"Install",
"a",
"skin"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L184-L188 |
18,724 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addGetSkin | public function addGetSkin($name, $file, $url)
{
$skinElement = new GetSkin($name, $file, $url);
return $this->addElement($skinElement);
} | php | public function addGetSkin($name, $file, $url)
{
$skinElement = new GetSkin($name, $file, $url);
return $this->addElement($skinElement);
} | [
"public",
"function",
"addGetSkin",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
"{",
"$",
"skinElement",
"=",
"new",
"GetSkin",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"skinElement",
")",
";",
"}"
]
| Get a skin
@api
@param string $name Skin name
@param string $file Skin file
@param string $url Skin url
@return static | [
"Get",
"a",
"skin"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L199-L203 |
18,725 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addJoinServer | public function addJoinServer($loginOrIp = null, $port = null)
{
$serverElement = new JoinServer($loginOrIp, $port);
return $this->addElement($serverElement);
} | php | public function addJoinServer($loginOrIp = null, $port = null)
{
$serverElement = new JoinServer($loginOrIp, $port);
return $this->addElement($serverElement);
} | [
"public",
"function",
"addJoinServer",
"(",
"$",
"loginOrIp",
"=",
"null",
",",
"$",
"port",
"=",
"null",
")",
"{",
"$",
"serverElement",
"=",
"new",
"JoinServer",
"(",
"$",
"loginOrIp",
",",
"$",
"port",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"serverElement",
")",
";",
"}"
]
| Join a server
@api
@param string $loginOrIp (optional) Server login or ip
@param int $port (optional) Server port
@return static | [
"Join",
"a",
"server"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L239-L243 |
18,726 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addAddFavorite | public function addAddFavorite($loginOrIp = null, $port = null)
{
$favoriteElement = new AddFavorite($loginOrIp, $port);
return $this->addElement($favoriteElement);
} | php | public function addAddFavorite($loginOrIp = null, $port = null)
{
$favoriteElement = new AddFavorite($loginOrIp, $port);
return $this->addElement($favoriteElement);
} | [
"public",
"function",
"addAddFavorite",
"(",
"$",
"loginOrIp",
"=",
"null",
",",
"$",
"port",
"=",
"null",
")",
"{",
"$",
"favoriteElement",
"=",
"new",
"AddFavorite",
"(",
"$",
"loginOrIp",
",",
"$",
"port",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"favoriteElement",
")",
";",
"}"
]
| Add a server as favorite
@api
@param string $loginOrIp (optional) Server login or ip
@param int $port (optional) Server port
@return static | [
"Add",
"a",
"server",
"as",
"favorite"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L253-L257 |
18,727 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addInstallScript | public function addInstallScript($name, $file, $url)
{
$scriptElement = new InstallScript($name, $file, $url);
return $this->addElement($scriptElement);
} | php | public function addInstallScript($name, $file, $url)
{
$scriptElement = new InstallScript($name, $file, $url);
return $this->addElement($scriptElement);
} | [
"public",
"function",
"addInstallScript",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
"{",
"$",
"scriptElement",
"=",
"new",
"InstallScript",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"scriptElement",
")",
";",
"}"
]
| Install a script
@api
@param string $name Script name
@param string $file Script file
@param string $url Script url
@return static | [
"Install",
"a",
"script"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L268-L272 |
18,728 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addInstallPack | public function addInstallPack($name, $file, $url)
{
$packElement = new InstallPack($name, $file, $url);
return $this->addElement($packElement);
} | php | public function addInstallPack($name, $file, $url)
{
$packElement = new InstallPack($name, $file, $url);
return $this->addElement($packElement);
} | [
"public",
"function",
"addInstallPack",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
"{",
"$",
"packElement",
"=",
"new",
"InstallPack",
"(",
"$",
"name",
",",
"$",
"file",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"addElement",
"(",
"$",
"packElement",
")",
";",
"}"
]
| Install a title pack
@api
@param string $name Pack name
@param string $file Pack file
@param string $url Pack url
@return static | [
"Install",
"a",
"title",
"pack"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L283-L287 |
18,729 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.addElement | public function addElement(Element $element)
{
if (!in_array($element, $this->elements, true)) {
array_push($this->elements, $element);
}
return $this;
} | php | public function addElement(Element $element)
{
if (!in_array($element, $this->elements, true)) {
array_push($this->elements, $element);
}
return $this;
} | [
"public",
"function",
"addElement",
"(",
"Element",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"element",
",",
"$",
"this",
"->",
"elements",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"elements",
",",
"$",
"element",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a ManiaCode Element
@api
@param Element $element Element to add
@return static | [
"Add",
"a",
"ManiaCode",
"Element"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L307-L313 |
18,730 | steeffeen/FancyManiaLinks | FML/ManiaCode.php | ManiaCode.render | public function render($echo = false)
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$domElement = $domDocument->createElement("maniacode");
$domDocument->appendChild($domElement);
if ($this->disableConfirmation) {
$domElement->setAttribute("noconfirmation", 1);
}
foreach ($this->elements as $element) {
$childDomElement = $element->render($domDocument);
$domElement->appendChild($childDomElement);
}
if ($echo) {
header("Content-Type: application/xml; charset=utf-8;");
echo $domDocument->saveXML();
}
return $domDocument;
} | php | public function render($echo = false)
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$domElement = $domDocument->createElement("maniacode");
$domDocument->appendChild($domElement);
if ($this->disableConfirmation) {
$domElement->setAttribute("noconfirmation", 1);
}
foreach ($this->elements as $element) {
$childDomElement = $element->render($domDocument);
$domElement->appendChild($childDomElement);
}
if ($echo) {
header("Content-Type: application/xml; charset=utf-8;");
echo $domDocument->saveXML();
}
return $domDocument;
} | [
"public",
"function",
"render",
"(",
"$",
"echo",
"=",
"false",
")",
"{",
"$",
"domDocument",
"=",
"new",
"\\",
"DOMDocument",
"(",
"\"1.0\"",
",",
"\"utf-8\"",
")",
";",
"$",
"domDocument",
"->",
"xmlStandalone",
"=",
"true",
";",
"$",
"domElement",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"\"maniacode\"",
")",
";",
"$",
"domDocument",
"->",
"appendChild",
"(",
"$",
"domElement",
")",
";",
"if",
"(",
"$",
"this",
"->",
"disableConfirmation",
")",
"{",
"$",
"domElement",
"->",
"setAttribute",
"(",
"\"noconfirmation\"",
",",
"1",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"$",
"childDomElement",
"=",
"$",
"element",
"->",
"render",
"(",
"$",
"domDocument",
")",
";",
"$",
"domElement",
"->",
"appendChild",
"(",
"$",
"childDomElement",
")",
";",
"}",
"if",
"(",
"$",
"echo",
")",
"{",
"header",
"(",
"\"Content-Type: application/xml; charset=utf-8;\"",
")",
";",
"echo",
"$",
"domDocument",
"->",
"saveXML",
"(",
")",
";",
"}",
"return",
"$",
"domDocument",
";",
"}"
]
| Render the ManiaCode
@api
@param bool $echo (optional) If the XML text should be echoed and the Content-Type header should be set
@return \DOMDocument | [
"Render",
"the",
"ManiaCode"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode.php#L362-L385 |
18,731 | helthe/Chronos | Crontab.php | Crontab.render | private function render()
{
$output = '';
foreach ($this->jobs as $job) {
$output .= $this->getTaskDefinition($job);
}
return $output;
} | php | private function render()
{
$output = '';
foreach ($this->jobs as $job) {
$output .= $this->getTaskDefinition($job);
}
return $output;
} | [
"private",
"function",
"render",
"(",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"jobs",
"as",
"$",
"job",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"getTaskDefinition",
"(",
"$",
"job",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
]
| Render all the cron jobs.
@return string | [
"Render",
"all",
"the",
"cron",
"jobs",
"."
]
| 6c783c55c32b323550fc6f21cd644c2be82720b0 | https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/Crontab.php#L166-L175 |
18,732 | joomlatools/joomlatools-platform-legacy | code/base/observable.php | JObservable.attach | public function attach($observer)
{
if (is_array($observer))
{
if (!isset($observer['handler']) || !isset($observer['event']) || !is_callable($observer['handler']))
{
return;
}
// Make sure we haven't already attached this array as an observer
foreach ($this->_observers as $check)
{
if (is_array($check) && $check['event'] == $observer['event'] && $check['handler'] == $observer['handler'])
{
return;
}
}
$this->_observers[] = $observer;
end($this->_observers);
$methods = array($observer['event']);
}
else
{
if (!($observer instanceof JObserver))
{
return;
}
// Make sure we haven't already attached this object as an observer
$class = get_class($observer);
foreach ($this->_observers as $check)
{
if ($check instanceof $class)
{
return;
}
}
$this->_observers[] = $observer;
$methods = array_diff(get_class_methods($observer), get_class_methods('JPlugin'));
}
$key = key($this->_observers);
foreach ($methods as $method)
{
$method = strtolower($method);
if (!isset($this->_methods[$method]))
{
$this->_methods[$method] = array();
}
$this->_methods[$method][] = $key;
}
} | php | public function attach($observer)
{
if (is_array($observer))
{
if (!isset($observer['handler']) || !isset($observer['event']) || !is_callable($observer['handler']))
{
return;
}
// Make sure we haven't already attached this array as an observer
foreach ($this->_observers as $check)
{
if (is_array($check) && $check['event'] == $observer['event'] && $check['handler'] == $observer['handler'])
{
return;
}
}
$this->_observers[] = $observer;
end($this->_observers);
$methods = array($observer['event']);
}
else
{
if (!($observer instanceof JObserver))
{
return;
}
// Make sure we haven't already attached this object as an observer
$class = get_class($observer);
foreach ($this->_observers as $check)
{
if ($check instanceof $class)
{
return;
}
}
$this->_observers[] = $observer;
$methods = array_diff(get_class_methods($observer), get_class_methods('JPlugin'));
}
$key = key($this->_observers);
foreach ($methods as $method)
{
$method = strtolower($method);
if (!isset($this->_methods[$method]))
{
$this->_methods[$method] = array();
}
$this->_methods[$method][] = $key;
}
} | [
"public",
"function",
"attach",
"(",
"$",
"observer",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"observer",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"observer",
"[",
"'handler'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"observer",
"[",
"'event'",
"]",
")",
"||",
"!",
"is_callable",
"(",
"$",
"observer",
"[",
"'handler'",
"]",
")",
")",
"{",
"return",
";",
"}",
"// Make sure we haven't already attached this array as an observer",
"foreach",
"(",
"$",
"this",
"->",
"_observers",
"as",
"$",
"check",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"check",
")",
"&&",
"$",
"check",
"[",
"'event'",
"]",
"==",
"$",
"observer",
"[",
"'event'",
"]",
"&&",
"$",
"check",
"[",
"'handler'",
"]",
"==",
"$",
"observer",
"[",
"'handler'",
"]",
")",
"{",
"return",
";",
"}",
"}",
"$",
"this",
"->",
"_observers",
"[",
"]",
"=",
"$",
"observer",
";",
"end",
"(",
"$",
"this",
"->",
"_observers",
")",
";",
"$",
"methods",
"=",
"array",
"(",
"$",
"observer",
"[",
"'event'",
"]",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"(",
"$",
"observer",
"instanceof",
"JObserver",
")",
")",
"{",
"return",
";",
"}",
"// Make sure we haven't already attached this object as an observer",
"$",
"class",
"=",
"get_class",
"(",
"$",
"observer",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_observers",
"as",
"$",
"check",
")",
"{",
"if",
"(",
"$",
"check",
"instanceof",
"$",
"class",
")",
"{",
"return",
";",
"}",
"}",
"$",
"this",
"->",
"_observers",
"[",
"]",
"=",
"$",
"observer",
";",
"$",
"methods",
"=",
"array_diff",
"(",
"get_class_methods",
"(",
"$",
"observer",
")",
",",
"get_class_methods",
"(",
"'JPlugin'",
")",
")",
";",
"}",
"$",
"key",
"=",
"key",
"(",
"$",
"this",
"->",
"_observers",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"method",
"=",
"strtolower",
"(",
"$",
"method",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_methods",
"[",
"$",
"method",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_methods",
"[",
"$",
"method",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_methods",
"[",
"$",
"method",
"]",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}"
]
| Attach an observer object
@param object $observer An observer object to attach
@return void
@since 11.1
@deprecated 12.3 | [
"Attach",
"an",
"observer",
"object"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/base/observable.php#L102-L159 |
18,733 | joomlatools/joomlatools-platform-legacy | code/base/observable.php | JObservable.detach | public function detach($observer)
{
$retval = false;
$key = array_search($observer, $this->_observers);
if ($key !== false)
{
unset($this->_observers[$key]);
$retval = true;
foreach ($this->_methods as &$method)
{
$k = array_search($key, $method);
if ($k !== false)
{
unset($method[$k]);
}
}
}
return $retval;
} | php | public function detach($observer)
{
$retval = false;
$key = array_search($observer, $this->_observers);
if ($key !== false)
{
unset($this->_observers[$key]);
$retval = true;
foreach ($this->_methods as &$method)
{
$k = array_search($key, $method);
if ($k !== false)
{
unset($method[$k]);
}
}
}
return $retval;
} | [
"public",
"function",
"detach",
"(",
"$",
"observer",
")",
"{",
"$",
"retval",
"=",
"false",
";",
"$",
"key",
"=",
"array_search",
"(",
"$",
"observer",
",",
"$",
"this",
"->",
"_observers",
")",
";",
"if",
"(",
"$",
"key",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_observers",
"[",
"$",
"key",
"]",
")",
";",
"$",
"retval",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"_methods",
"as",
"&",
"$",
"method",
")",
"{",
"$",
"k",
"=",
"array_search",
"(",
"$",
"key",
",",
"$",
"method",
")",
";",
"if",
"(",
"$",
"k",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"method",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"retval",
";",
"}"
]
| Detach an observer object
@param object $observer An observer object to detach.
@return boolean True if the observer object was detached.
@since 11.1
@deprecated 12.3 | [
"Detach",
"an",
"observer",
"object"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/base/observable.php#L171-L194 |
18,734 | ClanCats/Core | src/bundles/UI/E.php | E.attr | public static function attr( $attr = array() ) {
$buffer = " ";
foreach( $attr as $key => $value ) {
$buffer .= $key.'="'.$value.'" ';
}
return substr( $buffer, 0, -1 );
} | php | public static function attr( $attr = array() ) {
$buffer = " ";
foreach( $attr as $key => $value ) {
$buffer .= $key.'="'.$value.'" ';
}
return substr( $buffer, 0, -1 );
} | [
"public",
"static",
"function",
"attr",
"(",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"buffer",
"=",
"\" \"",
";",
"foreach",
"(",
"$",
"attr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"buffer",
".=",
"$",
"key",
".",
"'=\"'",
".",
"$",
"value",
".",
"'\" '",
";",
"}",
"return",
"substr",
"(",
"$",
"buffer",
",",
"0",
",",
"-",
"1",
")",
";",
"}"
]
| generates element attribute string
@param array $attr | [
"generates",
"element",
"attribute",
"string"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/E.php#L44-L51 |
18,735 | ClanCats/Core | src/bundles/UI/E.php | E.render | public function render() {
// execute callback if we have one first
if ( is_closure( $this->value ) ) {
ob_start(); $return = call_user_func( $this->value ); $this->value = ob_get_clean().$return;
}
return '<'.$this->name.static::attr( $this->attr ).
( !is_null( $this->value ) ? '>'.$this->value.'</'.$this->name.'>' : ' />' );
} | php | public function render() {
// execute callback if we have one first
if ( is_closure( $this->value ) ) {
ob_start(); $return = call_user_func( $this->value ); $this->value = ob_get_clean().$return;
}
return '<'.$this->name.static::attr( $this->attr ).
( !is_null( $this->value ) ? '>'.$this->value.'</'.$this->name.'>' : ' />' );
} | [
"public",
"function",
"render",
"(",
")",
"{",
"// execute callback if we have one first",
"if",
"(",
"is_closure",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"return",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"value",
")",
";",
"$",
"this",
"->",
"value",
"=",
"ob_get_clean",
"(",
")",
".",
"$",
"return",
";",
"}",
"return",
"'<'",
".",
"$",
"this",
"->",
"name",
".",
"static",
"::",
"attr",
"(",
"$",
"this",
"->",
"attr",
")",
".",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"value",
")",
"?",
"'>'",
".",
"$",
"this",
"->",
"value",
".",
"'</'",
".",
"$",
"this",
"->",
"name",
".",
"'>'",
":",
"' />'",
")",
";",
"}"
]
| render this element
@return string | [
"render",
"this",
"element"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/E.php#L143-L150 |
18,736 | factorio-item-browser/export-data | src/Registry/Adapter/FileSystemAdapter.php | FileSystemAdapter.save | public function save(string $namespace, string $hash, string $content): void
{
$fileName = $this->getFileName($namespace, $hash);
$this->ensureDirectory(dirname($fileName));
$success = false;
if (!file_exists($fileName) || is_writable($fileName)) {
$success = file_put_contents($fileName, $content);
}
if ($success === false) {
throw new ExportDataException('Unable to write file ' . $fileName);
}
} | php | public function save(string $namespace, string $hash, string $content): void
{
$fileName = $this->getFileName($namespace, $hash);
$this->ensureDirectory(dirname($fileName));
$success = false;
if (!file_exists($fileName) || is_writable($fileName)) {
$success = file_put_contents($fileName, $content);
}
if ($success === false) {
throw new ExportDataException('Unable to write file ' . $fileName);
}
} | [
"public",
"function",
"save",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"hash",
",",
"string",
"$",
"content",
")",
":",
"void",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"getFileName",
"(",
"$",
"namespace",
",",
"$",
"hash",
")",
";",
"$",
"this",
"->",
"ensureDirectory",
"(",
"dirname",
"(",
"$",
"fileName",
")",
")",
";",
"$",
"success",
"=",
"false",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
"||",
"is_writable",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"success",
"=",
"file_put_contents",
"(",
"$",
"fileName",
",",
"$",
"content",
")",
";",
"}",
"if",
"(",
"$",
"success",
"===",
"false",
")",
"{",
"throw",
"new",
"ExportDataException",
"(",
"'Unable to write file '",
".",
"$",
"fileName",
")",
";",
"}",
"}"
]
| Saves the content under the specified hash.
@param string $namespace
@param string $hash
@param string $content
@return void
@throws ExportDataException | [
"Saves",
"the",
"content",
"under",
"the",
"specified",
"hash",
"."
]
| 1413b2eed0fbfed0521457ac7ef0d668ac30c212 | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/Adapter/FileSystemAdapter.php#L43-L55 |
18,737 | factorio-item-browser/export-data | src/Registry/Adapter/FileSystemAdapter.php | FileSystemAdapter.load | public function load(string $namespace, string $hash): ?string
{
$result = null;
$fileName = $this->getFileName($namespace, $hash);
if (file_exists($fileName) && is_readable($fileName)) {
$result = file_get_contents($fileName);
}
return is_string($result) ? $result : null;
} | php | public function load(string $namespace, string $hash): ?string
{
$result = null;
$fileName = $this->getFileName($namespace, $hash);
if (file_exists($fileName) && is_readable($fileName)) {
$result = file_get_contents($fileName);
}
return is_string($result) ? $result : null;
} | [
"public",
"function",
"load",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"hash",
")",
":",
"?",
"string",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"fileName",
"=",
"$",
"this",
"->",
"getFileName",
"(",
"$",
"namespace",
",",
"$",
"hash",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
"&&",
"is_readable",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"result",
"=",
"file_get_contents",
"(",
"$",
"fileName",
")",
";",
"}",
"return",
"is_string",
"(",
"$",
"result",
")",
"?",
"$",
"result",
":",
"null",
";",
"}"
]
| Loads and returns the content of the specified hash, if available.
@param string $namespace
@param string $hash
@return string|null | [
"Loads",
"and",
"returns",
"the",
"content",
"of",
"the",
"specified",
"hash",
"if",
"available",
"."
]
| 1413b2eed0fbfed0521457ac7ef0d668ac30c212 | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/Adapter/FileSystemAdapter.php#L63-L71 |
18,738 | factorio-item-browser/export-data | src/Registry/Adapter/FileSystemAdapter.php | FileSystemAdapter.delete | public function delete(string $namespace, string $hash): void
{
$fileName = $this->getFileName($namespace, $hash);
if (file_exists($fileName)) {
unlink($fileName);
}
} | php | public function delete(string $namespace, string $hash): void
{
$fileName = $this->getFileName($namespace, $hash);
if (file_exists($fileName)) {
unlink($fileName);
}
} | [
"public",
"function",
"delete",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"hash",
")",
":",
"void",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"getFileName",
"(",
"$",
"namespace",
",",
"$",
"hash",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"unlink",
"(",
"$",
"fileName",
")",
";",
"}",
"}"
]
| Deletes the content under the specified hash.
@param string $namespace
@param string $hash | [
"Deletes",
"the",
"content",
"under",
"the",
"specified",
"hash",
"."
]
| 1413b2eed0fbfed0521457ac7ef0d668ac30c212 | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/Adapter/FileSystemAdapter.php#L78-L84 |
18,739 | factorio-item-browser/export-data | src/Registry/Adapter/FileSystemAdapter.php | FileSystemAdapter.getFileName | protected function getFileName(string $namespace, string $hash): string
{
$fileName = implode(DIRECTORY_SEPARATOR, [
$this->directory,
$namespace,
substr($hash, 0, 2),
$hash
]);
return $fileName;
} | php | protected function getFileName(string $namespace, string $hash): string
{
$fileName = implode(DIRECTORY_SEPARATOR, [
$this->directory,
$namespace,
substr($hash, 0, 2),
$hash
]);
return $fileName;
} | [
"protected",
"function",
"getFileName",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"hash",
")",
":",
"string",
"{",
"$",
"fileName",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"[",
"$",
"this",
"->",
"directory",
",",
"$",
"namespace",
",",
"substr",
"(",
"$",
"hash",
",",
"0",
",",
"2",
")",
",",
"$",
"hash",
"]",
")",
";",
"return",
"$",
"fileName",
";",
"}"
]
| Returns the filename to use to save the content with the specified namespace and hash.
@param string $namespace
@param string $hash
@return string | [
"Returns",
"the",
"filename",
"to",
"use",
"to",
"save",
"the",
"content",
"with",
"the",
"specified",
"namespace",
"and",
"hash",
"."
]
| 1413b2eed0fbfed0521457ac7ef0d668ac30c212 | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/Adapter/FileSystemAdapter.php#L92-L101 |
18,740 | factorio-item-browser/export-data | src/Registry/Adapter/FileSystemAdapter.php | FileSystemAdapter.ensureDirectory | protected function ensureDirectory(string $directory): void
{
if (!is_dir($directory)) {
$success = @mkdir($directory, 0775, true);
if (!$success && !is_dir($directory)) {
throw new ExportDataException('Unable to create directory ' . $directory . '.');
}
}
if (!is_writable($directory)) {
throw new ExportDataException('Directory ' . $directory . ' is not writable.');
}
} | php | protected function ensureDirectory(string $directory): void
{
if (!is_dir($directory)) {
$success = @mkdir($directory, 0775, true);
if (!$success && !is_dir($directory)) {
throw new ExportDataException('Unable to create directory ' . $directory . '.');
}
}
if (!is_writable($directory)) {
throw new ExportDataException('Directory ' . $directory . ' is not writable.');
}
} | [
"protected",
"function",
"ensureDirectory",
"(",
"string",
"$",
"directory",
")",
":",
"void",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"success",
"=",
"@",
"mkdir",
"(",
"$",
"directory",
",",
"0775",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"success",
"&&",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"throw",
"new",
"ExportDataException",
"(",
"'Unable to create directory '",
".",
"$",
"directory",
".",
"'.'",
")",
";",
"}",
"}",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"directory",
")",
")",
"{",
"throw",
"new",
"ExportDataException",
"(",
"'Directory '",
".",
"$",
"directory",
".",
"' is not writable.'",
")",
";",
"}",
"}"
]
| Ensures that the specified directory is available and writable.
@param string $directory
@throws ExportDataException | [
"Ensures",
"that",
"the",
"specified",
"directory",
"is",
"available",
"and",
"writable",
"."
]
| 1413b2eed0fbfed0521457ac7ef0d668ac30c212 | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/Adapter/FileSystemAdapter.php#L108-L120 |
18,741 | factorio-item-browser/export-data | src/Registry/Adapter/FileSystemAdapter.php | FileSystemAdapter.getAllHashes | public function getAllHashes(string $namespace): array
{
$directory = implode(DIRECTORY_SEPARATOR, [
$this->directory,
$namespace,
]);
$result = [];
if (is_dir($directory)) {
$directoryIterator = new RecursiveDirectoryIterator(
$directory,
RecursiveDirectoryIterator::SKIP_DOTS
);
foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
/* @var SplFileInfo $file */
$result[] = $file->getFilename();
}
}
return $result;
} | php | public function getAllHashes(string $namespace): array
{
$directory = implode(DIRECTORY_SEPARATOR, [
$this->directory,
$namespace,
]);
$result = [];
if (is_dir($directory)) {
$directoryIterator = new RecursiveDirectoryIterator(
$directory,
RecursiveDirectoryIterator::SKIP_DOTS
);
foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
/* @var SplFileInfo $file */
$result[] = $file->getFilename();
}
}
return $result;
} | [
"public",
"function",
"getAllHashes",
"(",
"string",
"$",
"namespace",
")",
":",
"array",
"{",
"$",
"directory",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"[",
"$",
"this",
"->",
"directory",
",",
"$",
"namespace",
",",
"]",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"directoryIterator",
"=",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"directory",
",",
"RecursiveDirectoryIterator",
"::",
"SKIP_DOTS",
")",
";",
"foreach",
"(",
"new",
"RecursiveIteratorIterator",
"(",
"$",
"directoryIterator",
")",
"as",
"$",
"file",
")",
"{",
"/* @var SplFileInfo $file */",
"$",
"result",
"[",
"]",
"=",
"$",
"file",
"->",
"getFilename",
"(",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Returns all hashes currently known to the adapter.
@param string $namespace
@return array|string[] | [
"Returns",
"all",
"hashes",
"currently",
"known",
"to",
"the",
"adapter",
"."
]
| 1413b2eed0fbfed0521457ac7ef0d668ac30c212 | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Registry/Adapter/FileSystemAdapter.php#L127-L147 |
18,742 | simple-php-mvc/simple-php-mvc | src/MVC/DataBase/Model.php | Model.delete | protected function delete(array $criteria = array())
{
$conditions = array();
foreach ($criteria as $field => $value) {
$conditions[] = "$field = ?";
}
$sql = "DELETE FROM $this->_table WHERE " . implode(' AND ', $conditions);
$pdos = $this->_pdo->prepare($sql);
$pdos->execute(array_values($criteria));
return $pdos->statement()->rowCount();
} | php | protected function delete(array $criteria = array())
{
$conditions = array();
foreach ($criteria as $field => $value) {
$conditions[] = "$field = ?";
}
$sql = "DELETE FROM $this->_table WHERE " . implode(' AND ', $conditions);
$pdos = $this->_pdo->prepare($sql);
$pdos->execute(array_values($criteria));
return $pdos->statement()->rowCount();
} | [
"protected",
"function",
"delete",
"(",
"array",
"$",
"criteria",
"=",
"array",
"(",
")",
")",
"{",
"$",
"conditions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"conditions",
"[",
"]",
"=",
"\"$field = ?\"",
";",
"}",
"$",
"sql",
"=",
"\"DELETE FROM $this->_table WHERE \"",
".",
"implode",
"(",
"' AND '",
",",
"$",
"conditions",
")",
";",
"$",
"pdos",
"=",
"$",
"this",
"->",
"_pdo",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"pdos",
"->",
"execute",
"(",
"array_values",
"(",
"$",
"criteria",
")",
")",
";",
"return",
"$",
"pdos",
"->",
"statement",
"(",
")",
"->",
"rowCount",
"(",
")",
";",
"}"
]
| Function SQL DELETE
@access protected
@param array $criteria
@return int | [
"Function",
"SQL",
"DELETE"
]
| e319eb09d29afad6993acb4a7e35f32a87dd0841 | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/Model.php#L81-L96 |
18,743 | simple-php-mvc/simple-php-mvc | src/MVC/DataBase/Model.php | Model.insert | protected function insert(array $data = array())
{
$fields = array();
$values = array();
foreach ($data as $field => $value) {
$fields[] = $field;
$values[] = '?';
}
$sql = "INSERT INTO $this->_table "
. "(" . implode(', ', $fields) . ")"
. "VALUES (" . implode(', ', $values) . ")";
$pdos = $this->_pdo->prepare($sql);
$pdos->execute(array_values($data));
return $pdos->statement()->rowCount();
} | php | protected function insert(array $data = array())
{
$fields = array();
$values = array();
foreach ($data as $field => $value) {
$fields[] = $field;
$values[] = '?';
}
$sql = "INSERT INTO $this->_table "
. "(" . implode(', ', $fields) . ")"
. "VALUES (" . implode(', ', $values) . ")";
$pdos = $this->_pdo->prepare($sql);
$pdos->execute(array_values($data));
return $pdos->statement()->rowCount();
} | [
"protected",
"function",
"insert",
"(",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"fields",
"[",
"]",
"=",
"$",
"field",
";",
"$",
"values",
"[",
"]",
"=",
"'?'",
";",
"}",
"$",
"sql",
"=",
"\"INSERT INTO $this->_table \"",
".",
"\"(\"",
".",
"implode",
"(",
"', '",
",",
"$",
"fields",
")",
".",
"\")\"",
".",
"\"VALUES (\"",
".",
"implode",
"(",
"', '",
",",
"$",
"values",
")",
".",
"\")\"",
";",
"$",
"pdos",
"=",
"$",
"this",
"->",
"_pdo",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"pdos",
"->",
"execute",
"(",
"array_values",
"(",
"$",
"data",
")",
")",
";",
"return",
"$",
"pdos",
"->",
"statement",
"(",
")",
"->",
"rowCount",
"(",
")",
";",
"}"
]
| Function SQL INSERT
@access protected
@param array $data
@return int | [
"Function",
"SQL",
"INSERT"
]
| e319eb09d29afad6993acb4a7e35f32a87dd0841 | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/Model.php#L104-L123 |
18,744 | simple-php-mvc/simple-php-mvc | src/MVC/DataBase/Model.php | Model.select | protected function select(array $fields, array $criteria = array(), array $operators = array(), array $conditions = array())
{
$sql = "";
$stringConditions = array();
if ((!empty($criteria) && !empty($operators)) && !empty($conditions)) {
if ((count($criteria) == count($operators) && (count($criteria) - 1) == count($conditions))
&& ((count($operators) -1) != count($conditions) && count($criteria) > 1)) {
throw new \Exception("The number of Criteria, Operators and Conditions are not equals.");
}
$criteriaFields = array_keys($criteria);
$stringConditions[] = "$criteriaFields[0] $operators[0] ?";
for ($i = 1; $i < count($criteriaFields); $i++) {
$j = $i - 1;
$stringConditions[] = "$conditions[$j] $criteriaFields[$i] $operators[$i] ?";
}
$sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table "
. "WHERE " . implode(' ', $stringConditions);
} elseif ((!empty($criteria) && !empty($operators)) && count($criteria) > 1) {
if (count($criteria) != count($operators)) {
throw new \Exception("The number of Criteria and Operators are not equals.");
}
$criteriaFields = array_keys($criteria);
for ($i = 0; $i < count($criteriaFields); $i++) {
$stringConditions[] = "$criteriaFields[$i] $operators[$i] ?";
}
$sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table "
. "WHERE " . implode(' AND ', $stringConditions);
} elseif (!empty($criteria)) {
foreach ($criteria as $field => $value) {
$stringConditions[] = "$field = ?";
}
$sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table "
. "WHERE " . implode(' AND ', $stringConditions);
} elseif (!empty($fields)) {
$sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table";
}
$pdos = $this->_pdo->prepare($sql);
$pdos->execute(array_values($criteria));
return $pdos->fetchAll();
} | php | protected function select(array $fields, array $criteria = array(), array $operators = array(), array $conditions = array())
{
$sql = "";
$stringConditions = array();
if ((!empty($criteria) && !empty($operators)) && !empty($conditions)) {
if ((count($criteria) == count($operators) && (count($criteria) - 1) == count($conditions))
&& ((count($operators) -1) != count($conditions) && count($criteria) > 1)) {
throw new \Exception("The number of Criteria, Operators and Conditions are not equals.");
}
$criteriaFields = array_keys($criteria);
$stringConditions[] = "$criteriaFields[0] $operators[0] ?";
for ($i = 1; $i < count($criteriaFields); $i++) {
$j = $i - 1;
$stringConditions[] = "$conditions[$j] $criteriaFields[$i] $operators[$i] ?";
}
$sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table "
. "WHERE " . implode(' ', $stringConditions);
} elseif ((!empty($criteria) && !empty($operators)) && count($criteria) > 1) {
if (count($criteria) != count($operators)) {
throw new \Exception("The number of Criteria and Operators are not equals.");
}
$criteriaFields = array_keys($criteria);
for ($i = 0; $i < count($criteriaFields); $i++) {
$stringConditions[] = "$criteriaFields[$i] $operators[$i] ?";
}
$sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table "
. "WHERE " . implode(' AND ', $stringConditions);
} elseif (!empty($criteria)) {
foreach ($criteria as $field => $value) {
$stringConditions[] = "$field = ?";
}
$sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table "
. "WHERE " . implode(' AND ', $stringConditions);
} elseif (!empty($fields)) {
$sql = "SELECT " . implode(', ', $fields) . " FROM $this->_table";
}
$pdos = $this->_pdo->prepare($sql);
$pdos->execute(array_values($criteria));
return $pdos->fetchAll();
} | [
"protected",
"function",
"select",
"(",
"array",
"$",
"fields",
",",
"array",
"$",
"criteria",
"=",
"array",
"(",
")",
",",
"array",
"$",
"operators",
"=",
"array",
"(",
")",
",",
"array",
"$",
"conditions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"sql",
"=",
"\"\"",
";",
"$",
"stringConditions",
"=",
"array",
"(",
")",
";",
"if",
"(",
"(",
"!",
"empty",
"(",
"$",
"criteria",
")",
"&&",
"!",
"empty",
"(",
"$",
"operators",
")",
")",
"&&",
"!",
"empty",
"(",
"$",
"conditions",
")",
")",
"{",
"if",
"(",
"(",
"count",
"(",
"$",
"criteria",
")",
"==",
"count",
"(",
"$",
"operators",
")",
"&&",
"(",
"count",
"(",
"$",
"criteria",
")",
"-",
"1",
")",
"==",
"count",
"(",
"$",
"conditions",
")",
")",
"&&",
"(",
"(",
"count",
"(",
"$",
"operators",
")",
"-",
"1",
")",
"!=",
"count",
"(",
"$",
"conditions",
")",
"&&",
"count",
"(",
"$",
"criteria",
")",
">",
"1",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"The number of Criteria, Operators and Conditions are not equals.\"",
")",
";",
"}",
"$",
"criteriaFields",
"=",
"array_keys",
"(",
"$",
"criteria",
")",
";",
"$",
"stringConditions",
"[",
"]",
"=",
"\"$criteriaFields[0] $operators[0] ?\"",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"criteriaFields",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"j",
"=",
"$",
"i",
"-",
"1",
";",
"$",
"stringConditions",
"[",
"]",
"=",
"\"$conditions[$j] $criteriaFields[$i] $operators[$i] ?\"",
";",
"}",
"$",
"sql",
"=",
"\"SELECT \"",
".",
"implode",
"(",
"', '",
",",
"$",
"fields",
")",
".",
"\" FROM $this->_table \"",
".",
"\"WHERE \"",
".",
"implode",
"(",
"' '",
",",
"$",
"stringConditions",
")",
";",
"}",
"elseif",
"(",
"(",
"!",
"empty",
"(",
"$",
"criteria",
")",
"&&",
"!",
"empty",
"(",
"$",
"operators",
")",
")",
"&&",
"count",
"(",
"$",
"criteria",
")",
">",
"1",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"criteria",
")",
"!=",
"count",
"(",
"$",
"operators",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"The number of Criteria and Operators are not equals.\"",
")",
";",
"}",
"$",
"criteriaFields",
"=",
"array_keys",
"(",
"$",
"criteria",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"criteriaFields",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"stringConditions",
"[",
"]",
"=",
"\"$criteriaFields[$i] $operators[$i] ?\"",
";",
"}",
"$",
"sql",
"=",
"\"SELECT \"",
".",
"implode",
"(",
"', '",
",",
"$",
"fields",
")",
".",
"\" FROM $this->_table \"",
".",
"\"WHERE \"",
".",
"implode",
"(",
"' AND '",
",",
"$",
"stringConditions",
")",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"criteria",
")",
")",
"{",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"stringConditions",
"[",
"]",
"=",
"\"$field = ?\"",
";",
"}",
"$",
"sql",
"=",
"\"SELECT \"",
".",
"implode",
"(",
"', '",
",",
"$",
"fields",
")",
".",
"\" FROM $this->_table \"",
".",
"\"WHERE \"",
".",
"implode",
"(",
"' AND '",
",",
"$",
"stringConditions",
")",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"sql",
"=",
"\"SELECT \"",
".",
"implode",
"(",
"', '",
",",
"$",
"fields",
")",
".",
"\" FROM $this->_table\"",
";",
"}",
"$",
"pdos",
"=",
"$",
"this",
"->",
"_pdo",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"pdos",
"->",
"execute",
"(",
"array_values",
"(",
"$",
"criteria",
")",
")",
";",
"return",
"$",
"pdos",
"->",
"fetchAll",
"(",
")",
";",
"}"
]
| Function SQL SELECT
@access protected
@param array $fields
@param array $criteria
@param array $operators
@param array $conditions
@return array
@throws \Exception | [
"Function",
"SQL",
"SELECT"
]
| e319eb09d29afad6993acb4a7e35f32a87dd0841 | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/Model.php#L135-L185 |
18,745 | simple-php-mvc/simple-php-mvc | src/MVC/DataBase/Model.php | Model.update | protected function update(array $data = array(), array $criteria)
{
$set = array();
foreach ($data as $columnName => $value) {
$set[] = "$columnName = ?";
}
$params = array_merge(array_values($data), array_values($criteria));
$sql = "UPDATE $this->_table SET " . implode(', ', $set)
. " WHERE " . implode(' = ? AND ', array_keys($criteria)) . " = ?";
$pdos = $this->_pdo->prepare($sql);
$pdos->execute($params);
return $pdos->statement()->rowCount();
} | php | protected function update(array $data = array(), array $criteria)
{
$set = array();
foreach ($data as $columnName => $value) {
$set[] = "$columnName = ?";
}
$params = array_merge(array_values($data), array_values($criteria));
$sql = "UPDATE $this->_table SET " . implode(', ', $set)
. " WHERE " . implode(' = ? AND ', array_keys($criteria)) . " = ?";
$pdos = $this->_pdo->prepare($sql);
$pdos->execute($params);
return $pdos->statement()->rowCount();
} | [
"protected",
"function",
"update",
"(",
"array",
"$",
"data",
"=",
"array",
"(",
")",
",",
"array",
"$",
"criteria",
")",
"{",
"$",
"set",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"columnName",
"=>",
"$",
"value",
")",
"{",
"$",
"set",
"[",
"]",
"=",
"\"$columnName = ?\"",
";",
"}",
"$",
"params",
"=",
"array_merge",
"(",
"array_values",
"(",
"$",
"data",
")",
",",
"array_values",
"(",
"$",
"criteria",
")",
")",
";",
"$",
"sql",
"=",
"\"UPDATE $this->_table SET \"",
".",
"implode",
"(",
"', '",
",",
"$",
"set",
")",
".",
"\" WHERE \"",
".",
"implode",
"(",
"' = ? AND '",
",",
"array_keys",
"(",
"$",
"criteria",
")",
")",
".",
"\" = ?\"",
";",
"$",
"pdos",
"=",
"$",
"this",
"->",
"_pdo",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"pdos",
"->",
"execute",
"(",
"$",
"params",
")",
";",
"return",
"$",
"pdos",
"->",
"statement",
"(",
")",
"->",
"rowCount",
"(",
")",
";",
"}"
]
| Function SQL UPDATE
@access protected
@param array $data
@param array $criteria
@return int | [
"Function",
"SQL",
"UPDATE"
]
| e319eb09d29afad6993acb4a7e35f32a87dd0841 | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/Model.php#L194-L211 |
18,746 | xinix-technology/norm | src/Norm/Connection/FlatFileConnection.php | FlatFileConnection.prepareDatabaseEcosystem | protected function prepareDatabaseEcosystem()
{
$basePath = realpath('../');
$dbPath = $basePath.'/'.$this->options['dbPath'].'/'.$this->options['database'];
if (! is_dir($dbPath)) {
mkdir($dbPath, 0755, true);
}
$this->dbPath = realpath($dbPath);
} | php | protected function prepareDatabaseEcosystem()
{
$basePath = realpath('../');
$dbPath = $basePath.'/'.$this->options['dbPath'].'/'.$this->options['database'];
if (! is_dir($dbPath)) {
mkdir($dbPath, 0755, true);
}
$this->dbPath = realpath($dbPath);
} | [
"protected",
"function",
"prepareDatabaseEcosystem",
"(",
")",
"{",
"$",
"basePath",
"=",
"realpath",
"(",
"'../'",
")",
";",
"$",
"dbPath",
"=",
"$",
"basePath",
".",
"'/'",
".",
"$",
"this",
"->",
"options",
"[",
"'dbPath'",
"]",
".",
"'/'",
".",
"$",
"this",
"->",
"options",
"[",
"'database'",
"]",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dbPath",
")",
")",
"{",
"mkdir",
"(",
"$",
"dbPath",
",",
"0755",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"dbPath",
"=",
"realpath",
"(",
"$",
"dbPath",
")",
";",
"}"
]
| Prepare database file and folder structure.
@return void | [
"Prepare",
"database",
"file",
"and",
"folder",
"structure",
"."
]
| c357f7d3a75d05324dd84b8f6a968a094c53d603 | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/FlatFileConnection.php#L63-L73 |
18,747 | xinix-technology/norm | src/Norm/Connection/FlatFileConnection.php | FlatFileConnection.getCollectionData | public function getCollectionData($collection, $criteria = null)
{
if (is_null($this->dbPath)) {
$this->prepareDatabaseEcosystem();
}
if (! is_dir($this->dbPath.'/'.$collection)) {
mkdir($this->dbPath.'/'.$collection, 0755, true);
}
$rows = array();
if ($handle = opendir($this->dbPath.'/'.$collection)) {
while (false !== ($entry = readdir($handle))) {
if (! in_array($entry, array('.', '..'))) {
if (is_readable($pathToFile = $this->dbPath.'/'.$collection.'/'.$entry)) {
$match = true;
$raw = file_get_contents($pathToFile);
$content = json_decode($raw, true);
if (! is_null($criteria) and ! empty($criteria)) {
if (isset($criteria['!or'])) {
$string = reset(array_values(reset($criteria['!or'])));
if (! preg_match('/'.$string.'/', strtolower($raw))) {
$match = false;
}
} else {
$intersection = array_intersect_assoc($content, $criteria);
if (empty($intersection)) {
$match = false;
}
}
}
if ($match) {
$rows[] = $content;
}
}
}
}
closedir($handle);
}
return $rows;
} | php | public function getCollectionData($collection, $criteria = null)
{
if (is_null($this->dbPath)) {
$this->prepareDatabaseEcosystem();
}
if (! is_dir($this->dbPath.'/'.$collection)) {
mkdir($this->dbPath.'/'.$collection, 0755, true);
}
$rows = array();
if ($handle = opendir($this->dbPath.'/'.$collection)) {
while (false !== ($entry = readdir($handle))) {
if (! in_array($entry, array('.', '..'))) {
if (is_readable($pathToFile = $this->dbPath.'/'.$collection.'/'.$entry)) {
$match = true;
$raw = file_get_contents($pathToFile);
$content = json_decode($raw, true);
if (! is_null($criteria) and ! empty($criteria)) {
if (isset($criteria['!or'])) {
$string = reset(array_values(reset($criteria['!or'])));
if (! preg_match('/'.$string.'/', strtolower($raw))) {
$match = false;
}
} else {
$intersection = array_intersect_assoc($content, $criteria);
if (empty($intersection)) {
$match = false;
}
}
}
if ($match) {
$rows[] = $content;
}
}
}
}
closedir($handle);
}
return $rows;
} | [
"public",
"function",
"getCollectionData",
"(",
"$",
"collection",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"dbPath",
")",
")",
"{",
"$",
"this",
"->",
"prepareDatabaseEcosystem",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"dbPath",
".",
"'/'",
".",
"$",
"collection",
")",
")",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"dbPath",
".",
"'/'",
".",
"$",
"collection",
",",
"0755",
",",
"true",
")",
";",
"}",
"$",
"rows",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"this",
"->",
"dbPath",
".",
"'/'",
".",
"$",
"collection",
")",
")",
"{",
"while",
"(",
"false",
"!==",
"(",
"$",
"entry",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"entry",
",",
"array",
"(",
"'.'",
",",
"'..'",
")",
")",
")",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"pathToFile",
"=",
"$",
"this",
"->",
"dbPath",
".",
"'/'",
".",
"$",
"collection",
".",
"'/'",
".",
"$",
"entry",
")",
")",
"{",
"$",
"match",
"=",
"true",
";",
"$",
"raw",
"=",
"file_get_contents",
"(",
"$",
"pathToFile",
")",
";",
"$",
"content",
"=",
"json_decode",
"(",
"$",
"raw",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"criteria",
")",
"and",
"!",
"empty",
"(",
"$",
"criteria",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"criteria",
"[",
"'!or'",
"]",
")",
")",
"{",
"$",
"string",
"=",
"reset",
"(",
"array_values",
"(",
"reset",
"(",
"$",
"criteria",
"[",
"'!or'",
"]",
")",
")",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/'",
".",
"$",
"string",
".",
"'/'",
",",
"strtolower",
"(",
"$",
"raw",
")",
")",
")",
"{",
"$",
"match",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"intersection",
"=",
"array_intersect_assoc",
"(",
"$",
"content",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"intersection",
")",
")",
"{",
"$",
"match",
"=",
"false",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"match",
")",
"{",
"$",
"rows",
"[",
"]",
"=",
"$",
"content",
";",
"}",
"}",
"}",
"}",
"closedir",
"(",
"$",
"handle",
")",
";",
"}",
"return",
"$",
"rows",
";",
"}"
]
| Getter for specific data for collection
@return array | [
"Getter",
"for",
"specific",
"data",
"for",
"collection"
]
| c357f7d3a75d05324dd84b8f6a968a094c53d603 | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/FlatFileConnection.php#L159-L207 |
18,748 | spiral-modules/scaffolder | source/Scaffolder/AbstractCommand.php | AbstractCommand.writeDeclaration | protected function writeDeclaration(ClassDeclaration $declaration, string $type = null)
{
$type = $type ?? static::ELEMENT;
$filename = $this->config->classFilename($type, $this->argument('name'));
$filename = $this->files->normalizePath($filename);
if ($this->files->exists($filename)) {
$this->writeln(
"<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, "
. "file '<comment>{$filename}</comment>' already exists.</fg=red>"
);
return;
}
//File declaration
$file = new FileDeclaration(
$this->config->classNamespace($type, $this->argument('name'))
);
$file->setComment($this->config->headerLines());
$file->addElement($declaration);
$this->files->write(
$filename,
$file->render(),
FilesInterface::READONLY,
true
);
$this->writeln(
"Declaration of '<info>{$declaration->getName()}</info>' "
. "has been successfully written into '<comment>{$filename}</comment>'."
);
} | php | protected function writeDeclaration(ClassDeclaration $declaration, string $type = null)
{
$type = $type ?? static::ELEMENT;
$filename = $this->config->classFilename($type, $this->argument('name'));
$filename = $this->files->normalizePath($filename);
if ($this->files->exists($filename)) {
$this->writeln(
"<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, "
. "file '<comment>{$filename}</comment>' already exists.</fg=red>"
);
return;
}
//File declaration
$file = new FileDeclaration(
$this->config->classNamespace($type, $this->argument('name'))
);
$file->setComment($this->config->headerLines());
$file->addElement($declaration);
$this->files->write(
$filename,
$file->render(),
FilesInterface::READONLY,
true
);
$this->writeln(
"Declaration of '<info>{$declaration->getName()}</info>' "
. "has been successfully written into '<comment>{$filename}</comment>'."
);
} | [
"protected",
"function",
"writeDeclaration",
"(",
"ClassDeclaration",
"$",
"declaration",
",",
"string",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"$",
"type",
"??",
"static",
"::",
"ELEMENT",
";",
"$",
"filename",
"=",
"$",
"this",
"->",
"config",
"->",
"classFilename",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
")",
";",
"$",
"filename",
"=",
"$",
"this",
"->",
"files",
"->",
"normalizePath",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"this",
"->",
"writeln",
"(",
"\"<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, \"",
".",
"\"file '<comment>{$filename}</comment>' already exists.</fg=red>\"",
")",
";",
"return",
";",
"}",
"//File declaration",
"$",
"file",
"=",
"new",
"FileDeclaration",
"(",
"$",
"this",
"->",
"config",
"->",
"classNamespace",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
")",
")",
";",
"$",
"file",
"->",
"setComment",
"(",
"$",
"this",
"->",
"config",
"->",
"headerLines",
"(",
")",
")",
";",
"$",
"file",
"->",
"addElement",
"(",
"$",
"declaration",
")",
";",
"$",
"this",
"->",
"files",
"->",
"write",
"(",
"$",
"filename",
",",
"$",
"file",
"->",
"render",
"(",
")",
",",
"FilesInterface",
"::",
"READONLY",
",",
"true",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"\"Declaration of '<info>{$declaration->getName()}</info>' \"",
".",
"\"has been successfully written into '<comment>{$filename}</comment>'.\"",
")",
";",
"}"
]
| Write declaration into file.
@param ClassDeclaration $declaration
@param string $type If null static::ELEMENT to be used. | [
"Write",
"declaration",
"into",
"file",
"."
]
| 9be9dd0da6e4b02232db24e797fe5c288afbbddf | https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/AbstractCommand.php#L86-L121 |
18,749 | joomlatools/joomlatools-platform-legacy | code/table/session.php | JTableSession.insert | public function insert($sessionId, $clientId)
{
$this->session_id = $sessionId;
$this->client_id = $clientId;
$this->time = time();
$ret = $this->_db->insertObject($this->_tbl, $this, 'session_id');
if (!$ret)
{
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr()));
return false;
}
else
{
return true;
}
} | php | public function insert($sessionId, $clientId)
{
$this->session_id = $sessionId;
$this->client_id = $clientId;
$this->time = time();
$ret = $this->_db->insertObject($this->_tbl, $this, 'session_id');
if (!$ret)
{
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr()));
return false;
}
else
{
return true;
}
} | [
"public",
"function",
"insert",
"(",
"$",
"sessionId",
",",
"$",
"clientId",
")",
"{",
"$",
"this",
"->",
"session_id",
"=",
"$",
"sessionId",
";",
"$",
"this",
"->",
"client_id",
"=",
"$",
"clientId",
";",
"$",
"this",
"->",
"time",
"=",
"time",
"(",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"_db",
"->",
"insertObject",
"(",
"$",
"this",
"->",
"_tbl",
",",
"$",
"this",
",",
"'session_id'",
")",
";",
"if",
"(",
"!",
"$",
"ret",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"JText",
"::",
"sprintf",
"(",
"'JLIB_DATABASE_ERROR_STORE_FAILED'",
",",
"strtolower",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
",",
"$",
"this",
"->",
"_db",
"->",
"stderr",
"(",
")",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
]
| Insert a session
@param string $sessionId The session id
@param integer $clientId The id of the client application
@return boolean True on success
@since 11.1
@deprecated 13.3 Use SQL queries to interact with the session table. | [
"Insert",
"a",
"session"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L48-L66 |
18,750 | joomlatools/joomlatools-platform-legacy | code/table/session.php | JTableSession.update | public function update($updateNulls = false)
{
$this->time = time();
$ret = $this->_db->updateObject($this->_tbl, $this, 'session_id', $updateNulls);
if (!$ret)
{
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr()));
return false;
}
else
{
return true;
}
} | php | public function update($updateNulls = false)
{
$this->time = time();
$ret = $this->_db->updateObject($this->_tbl, $this, 'session_id', $updateNulls);
if (!$ret)
{
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr()));
return false;
}
else
{
return true;
}
} | [
"public",
"function",
"update",
"(",
"$",
"updateNulls",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"time",
"=",
"time",
"(",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"_db",
"->",
"updateObject",
"(",
"$",
"this",
"->",
"_tbl",
",",
"$",
"this",
",",
"'session_id'",
",",
"$",
"updateNulls",
")",
";",
"if",
"(",
"!",
"$",
"ret",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"JText",
"::",
"sprintf",
"(",
"'JLIB_DATABASE_ERROR_STORE_FAILED'",
",",
"strtolower",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
",",
"$",
"this",
"->",
"_db",
"->",
"stderr",
"(",
")",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
]
| Updates the session
@param boolean $updateNulls True to update fields even if they are null.
@return boolean True on success.
@since 11.1
@deprecated 13.3 Use SQL queries to interact with the session table. | [
"Updates",
"the",
"session"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L78-L93 |
18,751 | joomlatools/joomlatools-platform-legacy | code/table/session.php | JTableSession.destroy | public function destroy($userId, $clientIds = array())
{
$clientIds = implode(',', $clientIds);
$query = $this->_db->getQuery(true)
->delete($this->_db->quoteName($this->_tbl))
->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userId))
->where($this->_db->quoteName('client_id') . ' IN (' . $clientIds . ')');
$this->_db->setQuery($query);
if (!$this->_db->execute())
{
$this->setError($this->_db->stderr());
return false;
}
return true;
} | php | public function destroy($userId, $clientIds = array())
{
$clientIds = implode(',', $clientIds);
$query = $this->_db->getQuery(true)
->delete($this->_db->quoteName($this->_tbl))
->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userId))
->where($this->_db->quoteName('client_id') . ' IN (' . $clientIds . ')');
$this->_db->setQuery($query);
if (!$this->_db->execute())
{
$this->setError($this->_db->stderr());
return false;
}
return true;
} | [
"public",
"function",
"destroy",
"(",
"$",
"userId",
",",
"$",
"clientIds",
"=",
"array",
"(",
")",
")",
"{",
"$",
"clientIds",
"=",
"implode",
"(",
"','",
",",
"$",
"clientIds",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"_db",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"_tbl",
")",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"_db",
"->",
"quoteName",
"(",
"'userid'",
")",
".",
"' = '",
".",
"$",
"this",
"->",
"_db",
"->",
"quote",
"(",
"$",
"userId",
")",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"_db",
"->",
"quoteName",
"(",
"'client_id'",
")",
".",
"' IN ('",
".",
"$",
"clientIds",
".",
"')'",
")",
";",
"$",
"this",
"->",
"_db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_db",
"->",
"execute",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"$",
"this",
"->",
"_db",
"->",
"stderr",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Destroys the pre-existing session
@param integer $userId Identifier of the user for this session.
@param array $clientIds Array of client ids for which session(s) will be destroyed
@return boolean True on success.
@since 11.1
@deprecated 13.3 Use SQL queries to interact with the session table. | [
"Destroys",
"the",
"pre",
"-",
"existing",
"session"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L106-L124 |
18,752 | joomlatools/joomlatools-platform-legacy | code/table/session.php | JTableSession.purge | public function purge($maxLifetime = 1440)
{
$past = time() - $maxLifetime;
$query = $this->_db->getQuery(true)
->delete($this->_db->quoteName($this->_tbl))
->where($this->_db->quoteName('time') . ' < ' . (int) $past);
$this->_db->setQuery($query);
return $this->_db->execute();
} | php | public function purge($maxLifetime = 1440)
{
$past = time() - $maxLifetime;
$query = $this->_db->getQuery(true)
->delete($this->_db->quoteName($this->_tbl))
->where($this->_db->quoteName('time') . ' < ' . (int) $past);
$this->_db->setQuery($query);
return $this->_db->execute();
} | [
"public",
"function",
"purge",
"(",
"$",
"maxLifetime",
"=",
"1440",
")",
"{",
"$",
"past",
"=",
"time",
"(",
")",
"-",
"$",
"maxLifetime",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"_db",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"_tbl",
")",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"_db",
"->",
"quoteName",
"(",
"'time'",
")",
".",
"' < '",
".",
"(",
"int",
")",
"$",
"past",
")",
";",
"$",
"this",
"->",
"_db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"return",
"$",
"this",
"->",
"_db",
"->",
"execute",
"(",
")",
";",
"}"
]
| Purge old sessions
@param integer $maxLifetime Session age in seconds
@return mixed Resource on success, null on fail
@since 11.1
@deprecated 13.3 Use SQL queries to interact with the session table. | [
"Purge",
"old",
"sessions"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L136-L145 |
18,753 | joomlatools/joomlatools-platform-legacy | code/table/session.php | JTableSession.exists | public function exists($userid)
{
$query = $this->_db->getQuery(true)
->select('COUNT(userid)')
->from($this->_db->quoteName($this->_tbl))
->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userid));
$this->_db->setQuery($query);
if (!$result = $this->_db->loadResult())
{
$this->setError($this->_db->stderr());
return false;
}
return (boolean) $result;
} | php | public function exists($userid)
{
$query = $this->_db->getQuery(true)
->select('COUNT(userid)')
->from($this->_db->quoteName($this->_tbl))
->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userid));
$this->_db->setQuery($query);
if (!$result = $this->_db->loadResult())
{
$this->setError($this->_db->stderr());
return false;
}
return (boolean) $result;
} | [
"public",
"function",
"exists",
"(",
"$",
"userid",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"_db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'COUNT(userid)'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"_db",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"_tbl",
")",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"_db",
"->",
"quoteName",
"(",
"'userid'",
")",
".",
"' = '",
".",
"$",
"this",
"->",
"_db",
"->",
"quote",
"(",
"$",
"userid",
")",
")",
";",
"$",
"this",
"->",
"_db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"if",
"(",
"!",
"$",
"result",
"=",
"$",
"this",
"->",
"_db",
"->",
"loadResult",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"$",
"this",
"->",
"_db",
"->",
"stderr",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"(",
"boolean",
")",
"$",
"result",
";",
"}"
]
| Find out if a user has one or more active sessions
@param integer $userid The identifier of the user
@return boolean True if a session for this user exists
@since 11.1
@deprecated 13.3 Use SQL queries to interact with the session table. | [
"Find",
"out",
"if",
"a",
"user",
"has",
"one",
"or",
"more",
"active",
"sessions"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L157-L173 |
18,754 | joomlatools/joomlatools-platform-legacy | code/table/session.php | JTableSession.delete | public function delete($oid = null)
{
$k = $this->_tbl_key;
if ($oid)
{
$this->$k = $oid;
}
$query = $this->_db->getQuery(true)
->delete($this->_db->quoteName($this->_tbl))
->where($this->_db->quoteName($this->_tbl_key) . ' = ' . $this->_db->quote($this->$k));
$this->_db->setQuery($query);
$this->_db->execute();
return true;
} | php | public function delete($oid = null)
{
$k = $this->_tbl_key;
if ($oid)
{
$this->$k = $oid;
}
$query = $this->_db->getQuery(true)
->delete($this->_db->quoteName($this->_tbl))
->where($this->_db->quoteName($this->_tbl_key) . ' = ' . $this->_db->quote($this->$k));
$this->_db->setQuery($query);
$this->_db->execute();
return true;
} | [
"public",
"function",
"delete",
"(",
"$",
"oid",
"=",
"null",
")",
"{",
"$",
"k",
"=",
"$",
"this",
"->",
"_tbl_key",
";",
"if",
"(",
"$",
"oid",
")",
"{",
"$",
"this",
"->",
"$",
"k",
"=",
"$",
"oid",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"_db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"_db",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"_tbl",
")",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"_db",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"_tbl_key",
")",
".",
"' = '",
".",
"$",
"this",
"->",
"_db",
"->",
"quote",
"(",
"$",
"this",
"->",
"$",
"k",
")",
")",
";",
"$",
"this",
"->",
"_db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"this",
"->",
"_db",
"->",
"execute",
"(",
")",
";",
"return",
"true",
";",
"}"
]
| Overloaded delete method
We must override it because of the non-integer primary key
@param integer $oid The object id (optional).
@return mixed True if successful otherwise an error message
@since 11.1
@deprecated 13.3 Use SQL queries to interact with the session table. | [
"Overloaded",
"delete",
"method"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L187-L204 |
18,755 | steeffeen/FancyManiaLinks | FML/Controls/FrameInstance.php | FrameInstance.setModelId | public function setModelId($modelId)
{
$this->modelId = (string)$modelId;
$this->model = null;
return $this;
} | php | public function setModelId($modelId)
{
$this->modelId = (string)$modelId;
$this->model = null;
return $this;
} | [
"public",
"function",
"setModelId",
"(",
"$",
"modelId",
")",
"{",
"$",
"this",
"->",
"modelId",
"=",
"(",
"string",
")",
"$",
"modelId",
";",
"$",
"this",
"->",
"model",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the FrameModel id
@api
@param string $modelId FrameModel id
@return static | [
"Set",
"the",
"FrameModel",
"id"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/FrameInstance.php#L74-L79 |
18,756 | steeffeen/FancyManiaLinks | FML/Controls/FrameInstance.php | FrameInstance.setModel | public function setModel(FrameModel $frameModel)
{
$this->modelId = null;
$this->model = $frameModel;
return $this;
} | php | public function setModel(FrameModel $frameModel)
{
$this->modelId = null;
$this->model = $frameModel;
return $this;
} | [
"public",
"function",
"setModel",
"(",
"FrameModel",
"$",
"frameModel",
")",
"{",
"$",
"this",
"->",
"modelId",
"=",
"null",
";",
"$",
"this",
"->",
"model",
"=",
"$",
"frameModel",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the FrameModel
@api
@param FrameModel $frameModel FrameModel
@return static | [
"Set",
"the",
"FrameModel"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/FrameInstance.php#L99-L104 |
18,757 | steeffeen/FancyManiaLinks | FML/Script/Builder.php | Builder.escapeText | public static function escapeText($text, $addApostrophes = true)
{
$dangers = array('\\', '"', "\n");
$replacements = array('\\\\', '\\"', '\\n');
$escapedText = str_ireplace($dangers, $replacements, $text);
if ($addApostrophes) {
$escapedText = '"' . $escapedText . '"';
}
return $escapedText;
} | php | public static function escapeText($text, $addApostrophes = true)
{
$dangers = array('\\', '"', "\n");
$replacements = array('\\\\', '\\"', '\\n');
$escapedText = str_ireplace($dangers, $replacements, $text);
if ($addApostrophes) {
$escapedText = '"' . $escapedText . '"';
}
return $escapedText;
} | [
"public",
"static",
"function",
"escapeText",
"(",
"$",
"text",
",",
"$",
"addApostrophes",
"=",
"true",
")",
"{",
"$",
"dangers",
"=",
"array",
"(",
"'\\\\'",
",",
"'\"'",
",",
"\"\\n\"",
")",
";",
"$",
"replacements",
"=",
"array",
"(",
"'\\\\\\\\'",
",",
"'\\\\\"'",
",",
"'\\\\n'",
")",
";",
"$",
"escapedText",
"=",
"str_ireplace",
"(",
"$",
"dangers",
",",
"$",
"replacements",
",",
"$",
"text",
")",
";",
"if",
"(",
"$",
"addApostrophes",
")",
"{",
"$",
"escapedText",
"=",
"'\"'",
".",
"$",
"escapedText",
".",
"'\"'",
";",
"}",
"return",
"$",
"escapedText",
";",
"}"
]
| Escape dangerous characters in the given text
@api
@param string $text Text to escape
@param bool $addApostrophes (optional) Add apostrophes before and after the text
@return string | [
"Escape",
"dangerous",
"characters",
"in",
"the",
"given",
"text"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L52-L61 |
18,758 | steeffeen/FancyManiaLinks | FML/Script/Builder.php | Builder.getReal | public static function getReal($value)
{
$value = (float)$value;
$stringVal = (string)$value;
if (!fmod($value, 1)) {
$stringVal .= ".";
}
return $stringVal;
} | php | public static function getReal($value)
{
$value = (float)$value;
$stringVal = (string)$value;
if (!fmod($value, 1)) {
$stringVal .= ".";
}
return $stringVal;
} | [
"public",
"static",
"function",
"getReal",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"(",
"float",
")",
"$",
"value",
";",
"$",
"stringVal",
"=",
"(",
"string",
")",
"$",
"value",
";",
"if",
"(",
"!",
"fmod",
"(",
"$",
"value",
",",
"1",
")",
")",
"{",
"$",
"stringVal",
".=",
"\".\"",
";",
"}",
"return",
"$",
"stringVal",
";",
"}"
]
| Get the 'Real' string representation of the given value
@api
@param float $value Float value to convert to a ManiaScript 'Real'
@return string | [
"Get",
"the",
"Real",
"string",
"representation",
"of",
"the",
"given",
"value"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L105-L113 |
18,759 | steeffeen/FancyManiaLinks | FML/Script/Builder.php | Builder.getArray | public static function getArray(array $array, $associative = true)
{
$arrayText = "[";
$index = 0;
$count = count($array);
foreach ($array as $key => $value) {
if ($associative) {
$arrayText .= static::getValue($key);
$arrayText .= " => ";
}
$arrayText .= static::getValue($value);
if ($index < $count - 1) {
$arrayText .= ", ";
$index++;
}
}
return $arrayText . "]";
} | php | public static function getArray(array $array, $associative = true)
{
$arrayText = "[";
$index = 0;
$count = count($array);
foreach ($array as $key => $value) {
if ($associative) {
$arrayText .= static::getValue($key);
$arrayText .= " => ";
}
$arrayText .= static::getValue($value);
if ($index < $count - 1) {
$arrayText .= ", ";
$index++;
}
}
return $arrayText . "]";
} | [
"public",
"static",
"function",
"getArray",
"(",
"array",
"$",
"array",
",",
"$",
"associative",
"=",
"true",
")",
"{",
"$",
"arrayText",
"=",
"\"[\"",
";",
"$",
"index",
"=",
"0",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"array",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"associative",
")",
"{",
"$",
"arrayText",
".=",
"static",
"::",
"getValue",
"(",
"$",
"key",
")",
";",
"$",
"arrayText",
".=",
"\" => \"",
";",
"}",
"$",
"arrayText",
".=",
"static",
"::",
"getValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"index",
"<",
"$",
"count",
"-",
"1",
")",
"{",
"$",
"arrayText",
".=",
"\", \"",
";",
"$",
"index",
"++",
";",
"}",
"}",
"return",
"$",
"arrayText",
".",
"\"]\"",
";",
"}"
]
| Get the string representation of the given array
@api
@param array $array Array to convert to a ManiaScript array
@param bool $associative (optional) Whether the array should be associative
@return string | [
"Get",
"the",
"string",
"representation",
"of",
"the",
"given",
"array"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L175-L192 |
18,760 | steeffeen/FancyManiaLinks | FML/Script/Builder.php | Builder.getValue | public static function getValue($value)
{
if (is_string($value)) {
return static::escapeText($value);
}
if (is_bool($value)) {
return static::getBoolean($value);
}
if (is_array($value)) {
return static::getArray($value);
}
return $value;
} | php | public static function getValue($value)
{
if (is_string($value)) {
return static::escapeText($value);
}
if (is_bool($value)) {
return static::getBoolean($value);
}
if (is_array($value)) {
return static::getArray($value);
}
return $value;
} | [
"public",
"static",
"function",
"getValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"static",
"::",
"escapeText",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"static",
"::",
"getBoolean",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"static",
"::",
"getArray",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Get the string representation for the given value
@api
@param mixed $value Value
@return string | [
"Get",
"the",
"string",
"representation",
"for",
"the",
"given",
"value"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L201-L213 |
18,761 | steeffeen/FancyManiaLinks | FML/Script/Builder.php | Builder.getInclude | public static function getInclude($file, $namespace = null)
{
if (!$namespace && stripos($file, ".") === false) {
$namespace = $file;
}
$file = static::escapeText($file);
$includeText = "#Include {$file}";
if ($namespace) {
$includeText .= " as {$namespace}";
}
return $includeText . "
";
} | php | public static function getInclude($file, $namespace = null)
{
if (!$namespace && stripos($file, ".") === false) {
$namespace = $file;
}
$file = static::escapeText($file);
$includeText = "#Include {$file}";
if ($namespace) {
$includeText .= " as {$namespace}";
}
return $includeText . "
";
} | [
"public",
"static",
"function",
"getInclude",
"(",
"$",
"file",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"namespace",
"&&",
"stripos",
"(",
"$",
"file",
",",
"\".\"",
")",
"===",
"false",
")",
"{",
"$",
"namespace",
"=",
"$",
"file",
";",
"}",
"$",
"file",
"=",
"static",
"::",
"escapeText",
"(",
"$",
"file",
")",
";",
"$",
"includeText",
"=",
"\"#Include\t{$file}\"",
";",
"if",
"(",
"$",
"namespace",
")",
"{",
"$",
"includeText",
".=",
"\"\tas {$namespace}\"",
";",
"}",
"return",
"$",
"includeText",
".",
"\"\n\"",
";",
"}"
]
| Get the include command for the given file and namespace
@api
@param string $file Include file
@param string $namespace (optional) Include namespace
@return string | [
"Get",
"the",
"include",
"command",
"for",
"the",
"given",
"file",
"and",
"namespace"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L223-L235 |
18,762 | ppetermann/king23 | src/Mongo/MongoService.php | MongoService.getByCriteria | public function getByCriteria($collection, $criteria)
{
if ($data = $this->findOne($collection, $criteria)) {
/** @var MongoObject $obj */
$obj = $this->container->get(
$this->classMap->getClassForResult($collection, $data)
);
$obj->setCollection($collection);
$obj->loadFromArray($data);
return $obj;
}
return null;
} | php | public function getByCriteria($collection, $criteria)
{
if ($data = $this->findOne($collection, $criteria)) {
/** @var MongoObject $obj */
$obj = $this->container->get(
$this->classMap->getClassForResult($collection, $data)
);
$obj->setCollection($collection);
$obj->loadFromArray($data);
return $obj;
}
return null;
} | [
"public",
"function",
"getByCriteria",
"(",
"$",
"collection",
",",
"$",
"criteria",
")",
"{",
"if",
"(",
"$",
"data",
"=",
"$",
"this",
"->",
"findOne",
"(",
"$",
"collection",
",",
"$",
"criteria",
")",
")",
"{",
"/** @var MongoObject $obj */",
"$",
"obj",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"classMap",
"->",
"getClassForResult",
"(",
"$",
"collection",
",",
"$",
"data",
")",
")",
";",
"$",
"obj",
"->",
"setCollection",
"(",
"$",
"collection",
")",
";",
"$",
"obj",
"->",
"loadFromArray",
"(",
"$",
"data",
")",
";",
"return",
"$",
"obj",
";",
"}",
"return",
"null",
";",
"}"
]
| convenience method to retrieve object by criteria, should be used in
public static method by the derived class
@param string $collection
@param array $criteria
@return MongoObject
@throws \MongoException | [
"convenience",
"method",
"to",
"retrieve",
"object",
"by",
"criteria",
"should",
"be",
"used",
"in",
"public",
"static",
"method",
"by",
"the",
"derived",
"class"
]
| 603896083ec89f5ac4d744abd3b1b4db3e914c95 | https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Mongo/MongoService.php#L92-L107 |
18,763 | ppetermann/king23 | src/Mongo/MongoService.php | MongoService.aggregate | public function aggregate($collection, array $pipeline, $options = [])
{
$data = $this->dbConnection->selectCollection($collection)->aggregate($pipeline);
if ($data['ok'] != 1) {
throw new Exception("Tool Aggregation Error: ".$data['errmsg'], $data['code']);
}
return $data['result'];
} | php | public function aggregate($collection, array $pipeline, $options = [])
{
$data = $this->dbConnection->selectCollection($collection)->aggregate($pipeline);
if ($data['ok'] != 1) {
throw new Exception("Tool Aggregation Error: ".$data['errmsg'], $data['code']);
}
return $data['result'];
} | [
"public",
"function",
"aggregate",
"(",
"$",
"collection",
",",
"array",
"$",
"pipeline",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"dbConnection",
"->",
"selectCollection",
"(",
"$",
"collection",
")",
"->",
"aggregate",
"(",
"$",
"pipeline",
")",
";",
"if",
"(",
"$",
"data",
"[",
"'ok'",
"]",
"!=",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Tool Aggregation Error: \"",
".",
"$",
"data",
"[",
"'errmsg'",
"]",
",",
"$",
"data",
"[",
"'code'",
"]",
")",
";",
"}",
"return",
"$",
"data",
"[",
"'result'",
"]",
";",
"}"
]
| Run Aggregation through the Aggregation Pipeline
@param string $collection
@param array $pipeline
@param array $options
@return mixed
@throws Exception | [
"Run",
"Aggregation",
"through",
"the",
"Aggregation",
"Pipeline"
]
| 603896083ec89f5ac4d744abd3b1b4db3e914c95 | https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Mongo/MongoService.php#L137-L145 |
18,764 | ppetermann/king23 | src/Mongo/MongoService.php | MongoService.findOne | public function findOne($collection, array $criteria, array $fields = [])
{
return $this->dbConnection->selectCollection($collection)->findOne($criteria, $fields);
} | php | public function findOne($collection, array $criteria, array $fields = [])
{
return $this->dbConnection->selectCollection($collection)->findOne($criteria, $fields);
} | [
"public",
"function",
"findOne",
"(",
"$",
"collection",
",",
"array",
"$",
"criteria",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"dbConnection",
"->",
"selectCollection",
"(",
"$",
"collection",
")",
"->",
"findOne",
"(",
"$",
"criteria",
",",
"$",
"fields",
")",
";",
"}"
]
| returns the first found matching document
@param string $collection
@param array $criteria
@param array $fields
@return array
@throws \Exception | [
"returns",
"the",
"first",
"found",
"matching",
"document"
]
| 603896083ec89f5ac4d744abd3b1b4db3e914c95 | https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Mongo/MongoService.php#L168-L171 |
18,765 | ppetermann/king23 | src/Mongo/MongoService.php | MongoService.newObject | public function newObject($collection)
{
/** @var MongoObject $obj */
$obj =$this->container->get($this->classMap->getClassForResult($collection, []));
$obj->setCollection($collection);
return $obj;
} | php | public function newObject($collection)
{
/** @var MongoObject $obj */
$obj =$this->container->get($this->classMap->getClassForResult($collection, []));
$obj->setCollection($collection);
return $obj;
} | [
"public",
"function",
"newObject",
"(",
"$",
"collection",
")",
"{",
"/** @var MongoObject $obj */",
"$",
"obj",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"classMap",
"->",
"getClassForResult",
"(",
"$",
"collection",
",",
"[",
"]",
")",
")",
";",
"$",
"obj",
"->",
"setCollection",
"(",
"$",
"collection",
")",
";",
"return",
"$",
"obj",
";",
"}"
]
| conveniant method to create new instances
@param string $collection
@return MongoObject
@throws \MongoException | [
"conveniant",
"method",
"to",
"create",
"new",
"instances"
]
| 603896083ec89f5ac4d744abd3b1b4db3e914c95 | https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Mongo/MongoService.php#L179-L186 |
18,766 | CakeCMS/Core | src/View/Helper/AssetsHelper.php | AssetsHelper.jquery | public function jquery()
{
$this->Html->script('libs/jquery.min.js', $this->_setOptions([
'alias' => __FUNCTION__,
'weight' => self::WEIGHT_CORE
]));
return $this;
} | php | public function jquery()
{
$this->Html->script('libs/jquery.min.js', $this->_setOptions([
'alias' => __FUNCTION__,
'weight' => self::WEIGHT_CORE
]));
return $this;
} | [
"public",
"function",
"jquery",
"(",
")",
"{",
"$",
"this",
"->",
"Html",
"->",
"script",
"(",
"'libs/jquery.min.js'",
",",
"$",
"this",
"->",
"_setOptions",
"(",
"[",
"'alias'",
"=>",
"__FUNCTION__",
",",
"'weight'",
"=>",
"self",
"::",
"WEIGHT_CORE",
"]",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Include jquery lib.
@return $this | [
"Include",
"jquery",
"lib",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L153-L161 |
18,767 | CakeCMS/Core | src/View/Helper/AssetsHelper.php | AssetsHelper.jqueryFactory | public function jqueryFactory()
{
$this->jquery();
$this->Html->script('libs/utils.min.js', $this->_setOptions([
'alias' => 'jquery-utils',
'weight' => self::WEIGHT_LIB
]));
$this->Html->script('libs/jquery-factory.min.js', $this->_setOptions([
'weight' => self::WEIGHT_LIB,
'alias' => 'jquery-factory'
]));
return $this;
} | php | public function jqueryFactory()
{
$this->jquery();
$this->Html->script('libs/utils.min.js', $this->_setOptions([
'alias' => 'jquery-utils',
'weight' => self::WEIGHT_LIB
]));
$this->Html->script('libs/jquery-factory.min.js', $this->_setOptions([
'weight' => self::WEIGHT_LIB,
'alias' => 'jquery-factory'
]));
return $this;
} | [
"public",
"function",
"jqueryFactory",
"(",
")",
"{",
"$",
"this",
"->",
"jquery",
"(",
")",
";",
"$",
"this",
"->",
"Html",
"->",
"script",
"(",
"'libs/utils.min.js'",
",",
"$",
"this",
"->",
"_setOptions",
"(",
"[",
"'alias'",
"=>",
"'jquery-utils'",
",",
"'weight'",
"=>",
"self",
"::",
"WEIGHT_LIB",
"]",
")",
")",
";",
"$",
"this",
"->",
"Html",
"->",
"script",
"(",
"'libs/jquery-factory.min.js'",
",",
"$",
"this",
"->",
"_setOptions",
"(",
"[",
"'weight'",
"=>",
"self",
"::",
"WEIGHT_LIB",
",",
"'alias'",
"=>",
"'jquery-factory'",
"]",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Include jquery factory.
@return $this | [
"Include",
"jquery",
"factory",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L168-L183 |
18,768 | CakeCMS/Core | src/View/Helper/AssetsHelper.php | AssetsHelper.loadPluginAssets | public function loadPluginAssets()
{
$plugin = (string) $this->request->getParam('plugin');
$prefix = ($this->request->getParam('prefix')) ? $this->request->getParam('prefix') . '/' : null;
$action = (string) $this->request->getParam('action');
$controller = (string) $this->request->getParam('controller');
$widgetName = Str::slug($controller . '-' . $action) . '.js';
$cssOptions = ['block' => 'css_bottom', 'fullBase' => true, 'force' => Configure::read('debug')];
$this->Html->css($plugin . '.' . $prefix . 'styles.css', $cssOptions);
$this->Html->less($plugin . '.' . $prefix . 'styles.less', $cssOptions);
$this->Html->script([
$plugin . '.' . $prefix . 'widget/' . $widgetName,
$plugin . '.' . $prefix . 'script.js'
], ['block' => 'script_bottom', 'fullBase' => true]);
} | php | public function loadPluginAssets()
{
$plugin = (string) $this->request->getParam('plugin');
$prefix = ($this->request->getParam('prefix')) ? $this->request->getParam('prefix') . '/' : null;
$action = (string) $this->request->getParam('action');
$controller = (string) $this->request->getParam('controller');
$widgetName = Str::slug($controller . '-' . $action) . '.js';
$cssOptions = ['block' => 'css_bottom', 'fullBase' => true, 'force' => Configure::read('debug')];
$this->Html->css($plugin . '.' . $prefix . 'styles.css', $cssOptions);
$this->Html->less($plugin . '.' . $prefix . 'styles.less', $cssOptions);
$this->Html->script([
$plugin . '.' . $prefix . 'widget/' . $widgetName,
$plugin . '.' . $prefix . 'script.js'
], ['block' => 'script_bottom', 'fullBase' => true]);
} | [
"public",
"function",
"loadPluginAssets",
"(",
")",
"{",
"$",
"plugin",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'plugin'",
")",
";",
"$",
"prefix",
"=",
"(",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'prefix'",
")",
")",
"?",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'prefix'",
")",
".",
"'/'",
":",
"null",
";",
"$",
"action",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'action'",
")",
";",
"$",
"controller",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'controller'",
")",
";",
"$",
"widgetName",
"=",
"Str",
"::",
"slug",
"(",
"$",
"controller",
".",
"'-'",
".",
"$",
"action",
")",
".",
"'.js'",
";",
"$",
"cssOptions",
"=",
"[",
"'block'",
"=>",
"'css_bottom'",
",",
"'fullBase'",
"=>",
"true",
",",
"'force'",
"=>",
"Configure",
"::",
"read",
"(",
"'debug'",
")",
"]",
";",
"$",
"this",
"->",
"Html",
"->",
"css",
"(",
"$",
"plugin",
".",
"'.'",
".",
"$",
"prefix",
".",
"'styles.css'",
",",
"$",
"cssOptions",
")",
";",
"$",
"this",
"->",
"Html",
"->",
"less",
"(",
"$",
"plugin",
".",
"'.'",
".",
"$",
"prefix",
".",
"'styles.less'",
",",
"$",
"cssOptions",
")",
";",
"$",
"this",
"->",
"Html",
"->",
"script",
"(",
"[",
"$",
"plugin",
".",
"'.'",
".",
"$",
"prefix",
".",
"'widget/'",
".",
"$",
"widgetName",
",",
"$",
"plugin",
".",
"'.'",
".",
"$",
"prefix",
".",
"'script.js'",
"]",
",",
"[",
"'block'",
"=>",
"'script_bottom'",
",",
"'fullBase'",
"=>",
"true",
"]",
")",
";",
"}"
]
| Autoload plugin assets.
@return void
@throws \JBZoo\Less\Exception | [
"Autoload",
"plugin",
"assets",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L192-L208 |
18,769 | CakeCMS/Core | src/View/Helper/AssetsHelper.php | AssetsHelper.materialize | public function materialize()
{
$this->jquery();
$this->Html->script('libs/materialize.min.js', $this->_setOptions([
'alias' => __FUNCTION__,
'weight' => self::WEIGHT_LIB
]));
$this->Html->css('libs/materialize.min.css', $this->_setOptions([
'alias' => __FUNCTION__,
'weight' => self::WEIGHT_CORE
]));
return $this;
} | php | public function materialize()
{
$this->jquery();
$this->Html->script('libs/materialize.min.js', $this->_setOptions([
'alias' => __FUNCTION__,
'weight' => self::WEIGHT_LIB
]));
$this->Html->css('libs/materialize.min.css', $this->_setOptions([
'alias' => __FUNCTION__,
'weight' => self::WEIGHT_CORE
]));
return $this;
} | [
"public",
"function",
"materialize",
"(",
")",
"{",
"$",
"this",
"->",
"jquery",
"(",
")",
";",
"$",
"this",
"->",
"Html",
"->",
"script",
"(",
"'libs/materialize.min.js'",
",",
"$",
"this",
"->",
"_setOptions",
"(",
"[",
"'alias'",
"=>",
"__FUNCTION__",
",",
"'weight'",
"=>",
"self",
"::",
"WEIGHT_LIB",
"]",
")",
")",
";",
"$",
"this",
"->",
"Html",
"->",
"css",
"(",
"'libs/materialize.min.css'",
",",
"$",
"this",
"->",
"_setOptions",
"(",
"[",
"'alias'",
"=>",
"__FUNCTION__",
",",
"'weight'",
"=>",
"self",
"::",
"WEIGHT_CORE",
"]",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Include materialize design.
@return $this | [
"Include",
"materialize",
"design",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L215-L230 |
18,770 | CakeCMS/Core | src/View/Helper/AssetsHelper.php | AssetsHelper.toggleField | public function toggleField($selector = '.jsToggleField', $widget = 'JBZoo.FieldToggle', array $options = [])
{
$this->jqueryFactory();
$this->Html->script('Core.admin/widget/field-toggle.js', $this->_setOptions([
'alias' => __FUNCTION__,
'weight' => self::WEIGHT_WIDGET
]));
$options = Hash::merge(['token' => $this->request->getCookie('csrfToken')], $options);
$this->Js->widget($selector, $widget, $options);
return $this;
} | php | public function toggleField($selector = '.jsToggleField', $widget = 'JBZoo.FieldToggle', array $options = [])
{
$this->jqueryFactory();
$this->Html->script('Core.admin/widget/field-toggle.js', $this->_setOptions([
'alias' => __FUNCTION__,
'weight' => self::WEIGHT_WIDGET
]));
$options = Hash::merge(['token' => $this->request->getCookie('csrfToken')], $options);
$this->Js->widget($selector, $widget, $options);
return $this;
} | [
"public",
"function",
"toggleField",
"(",
"$",
"selector",
"=",
"'.jsToggleField'",
",",
"$",
"widget",
"=",
"'JBZoo.FieldToggle'",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"jqueryFactory",
"(",
")",
";",
"$",
"this",
"->",
"Html",
"->",
"script",
"(",
"'Core.admin/widget/field-toggle.js'",
",",
"$",
"this",
"->",
"_setOptions",
"(",
"[",
"'alias'",
"=>",
"__FUNCTION__",
",",
"'weight'",
"=>",
"self",
"::",
"WEIGHT_WIDGET",
"]",
")",
")",
";",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"'token'",
"=>",
"$",
"this",
"->",
"request",
"->",
"getCookie",
"(",
"'csrfToken'",
")",
"]",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"Js",
"->",
"widget",
"(",
"$",
"selector",
",",
"$",
"widget",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Include toggle field js widget.
@param string $selector
@param string $widget
@param array $options
@return $this | [
"Include",
"toggle",
"field",
"js",
"widget",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L296-L309 |
18,771 | restruct/silverstripe-namedlinkfield | src/NamedLinkField.php | NamedLinkField.exists | public function exists()
{
return ($this->page_id > 0 || $this->file_id > 0 || $this->custom_url !== null
|| $this->shortcode !== null && $this->title !== null);
} | php | public function exists()
{
return ($this->page_id > 0 || $this->file_id > 0 || $this->custom_url !== null
|| $this->shortcode !== null && $this->title !== null);
} | [
"public",
"function",
"exists",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"page_id",
">",
"0",
"||",
"$",
"this",
"->",
"file_id",
">",
"0",
"||",
"$",
"this",
"->",
"custom_url",
"!==",
"null",
"||",
"$",
"this",
"->",
"shortcode",
"!==",
"null",
"&&",
"$",
"this",
"->",
"title",
"!==",
"null",
")",
";",
"}"
]
| Determines if any of the properties in this field have a value,
meaning at least one of them is not NULL.
@return boolean | [
"Determines",
"if",
"any",
"of",
"the",
"properties",
"in",
"this",
"field",
"have",
"a",
"value",
"meaning",
"at",
"least",
"one",
"of",
"them",
"is",
"not",
"NULL",
"."
]
| 567c49fdc1b24c219dec2e989fc2013b1c7951af | https://github.com/restruct/silverstripe-namedlinkfield/blob/567c49fdc1b24c219dec2e989fc2013b1c7951af/src/NamedLinkField.php#L321-L325 |
18,772 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.addGroupKeyToPostbox | public function addGroupKeyToPostbox($post)
{
if ($post->post_type !== 'acf-field-group') {
return;
}
// Check if aldready added
global $acfExportManagerHasGroupIdInSidebar;
if ($acfExportManagerHasGroupIdInSidebar) {
return;
}
$acfExportManagerHasGroupIdInSidebar = true;
$fieldgroup = acf_get_field_group($post->ID);
echo '<div class="misc-pub-section"><span style="color:#82878c;font-size:20px;display:inline-block;width:18px;vertical-align:middle;position:relative;top:-1px;text-align:center;margin-right:8px;">#</span>' . $fieldgroup['key'] . '</div>';
} | php | public function addGroupKeyToPostbox($post)
{
if ($post->post_type !== 'acf-field-group') {
return;
}
// Check if aldready added
global $acfExportManagerHasGroupIdInSidebar;
if ($acfExportManagerHasGroupIdInSidebar) {
return;
}
$acfExportManagerHasGroupIdInSidebar = true;
$fieldgroup = acf_get_field_group($post->ID);
echo '<div class="misc-pub-section"><span style="color:#82878c;font-size:20px;display:inline-block;width:18px;vertical-align:middle;position:relative;top:-1px;text-align:center;margin-right:8px;">#</span>' . $fieldgroup['key'] . '</div>';
} | [
"public",
"function",
"addGroupKeyToPostbox",
"(",
"$",
"post",
")",
"{",
"if",
"(",
"$",
"post",
"->",
"post_type",
"!==",
"'acf-field-group'",
")",
"{",
"return",
";",
"}",
"// Check if aldready added",
"global",
"$",
"acfExportManagerHasGroupIdInSidebar",
";",
"if",
"(",
"$",
"acfExportManagerHasGroupIdInSidebar",
")",
"{",
"return",
";",
"}",
"$",
"acfExportManagerHasGroupIdInSidebar",
"=",
"true",
";",
"$",
"fieldgroup",
"=",
"acf_get_field_group",
"(",
"$",
"post",
"->",
"ID",
")",
";",
"echo",
"'<div class=\"misc-pub-section\"><span style=\"color:#82878c;font-size:20px;display:inline-block;width:18px;vertical-align:middle;position:relative;top:-1px;text-align:center;margin-right:8px;\">#</span>'",
".",
"$",
"fieldgroup",
"[",
"'key'",
"]",
".",
"'</div>'",
";",
"}"
]
| Displays the fieldgroup key in misc publishing actions
@param WP_Post $post | [
"Displays",
"the",
"fieldgroup",
"key",
"in",
"misc",
"publishing",
"actions"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L31-L48 |
18,773 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.deleteExport | public function deleteExport(array $fieldgroup) : bool
{
$filename = $this->getExportFilename($fieldgroup);
$this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']);
$this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']);
return true;
} | php | public function deleteExport(array $fieldgroup) : bool
{
$filename = $this->getExportFilename($fieldgroup);
$this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']);
$this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']);
return true;
} | [
"public",
"function",
"deleteExport",
"(",
"array",
"$",
"fieldgroup",
")",
":",
"bool",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getExportFilename",
"(",
"$",
"fieldgroup",
")",
";",
"$",
"this",
"->",
"maybeUnlink",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'php/'",
".",
"$",
"filename",
"[",
"'php'",
"]",
")",
";",
"$",
"this",
"->",
"maybeUnlink",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'json/'",
".",
"$",
"filename",
"[",
"'json'",
"]",
")",
";",
"return",
"true",
";",
"}"
]
| Deletes export file for deleted fieldgroup
@param array $fieldgroup
@return boolean | [
"Deletes",
"export",
"file",
"for",
"deleted",
"fieldgroup"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L75-L83 |
18,774 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.export | public function export(array $fieldgroup, bool $restrictToExportPosts = true, bool $translate = true) : array
{
global $locale;
$locale = "en_US";
// Bail if the fieldgroup shouldn't be exported
if ($restrictToExportPosts && !in_array($fieldgroup['key'], $this->exportPosts)) {
return array();
}
$this->maybeCreateExportFolders();
if ($this->textdomain) {
acf_update_setting('l10n', true);
acf_update_setting('l10n_textdomain', $this->textdomain);
acf_update_setting('l10n_var_export', true);
}
$filename = $this->getExportFilename($fieldgroup);
// Export php file
$this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']);
$code = $this->generatePhp($fieldgroup['ID'], $translate);
$phpFile = fopen($this->exportFolder . 'php/' . $filename['php'], 'w');
fwrite($phpFile, $code);
fclose($phpFile);
// Export json file
$this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']);
$jsonFile = fopen($this->exportFolder . 'json/' . $filename['json'], 'w');
$json = $this->getJson($this->getFieldgroupParams($fieldgroup['ID'], false));
fwrite($jsonFile, $json);
fclose($jsonFile);
return array(
'php' => $this->exportFolder . 'php/' . $filename['php'],
'json' => $this->exportFolder . 'json/' . $filename['json']
);
} | php | public function export(array $fieldgroup, bool $restrictToExportPosts = true, bool $translate = true) : array
{
global $locale;
$locale = "en_US";
// Bail if the fieldgroup shouldn't be exported
if ($restrictToExportPosts && !in_array($fieldgroup['key'], $this->exportPosts)) {
return array();
}
$this->maybeCreateExportFolders();
if ($this->textdomain) {
acf_update_setting('l10n', true);
acf_update_setting('l10n_textdomain', $this->textdomain);
acf_update_setting('l10n_var_export', true);
}
$filename = $this->getExportFilename($fieldgroup);
// Export php file
$this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']);
$code = $this->generatePhp($fieldgroup['ID'], $translate);
$phpFile = fopen($this->exportFolder . 'php/' . $filename['php'], 'w');
fwrite($phpFile, $code);
fclose($phpFile);
// Export json file
$this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']);
$jsonFile = fopen($this->exportFolder . 'json/' . $filename['json'], 'w');
$json = $this->getJson($this->getFieldgroupParams($fieldgroup['ID'], false));
fwrite($jsonFile, $json);
fclose($jsonFile);
return array(
'php' => $this->exportFolder . 'php/' . $filename['php'],
'json' => $this->exportFolder . 'json/' . $filename['json']
);
} | [
"public",
"function",
"export",
"(",
"array",
"$",
"fieldgroup",
",",
"bool",
"$",
"restrictToExportPosts",
"=",
"true",
",",
"bool",
"$",
"translate",
"=",
"true",
")",
":",
"array",
"{",
"global",
"$",
"locale",
";",
"$",
"locale",
"=",
"\"en_US\"",
";",
"// Bail if the fieldgroup shouldn't be exported",
"if",
"(",
"$",
"restrictToExportPosts",
"&&",
"!",
"in_array",
"(",
"$",
"fieldgroup",
"[",
"'key'",
"]",
",",
"$",
"this",
"->",
"exportPosts",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"maybeCreateExportFolders",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"textdomain",
")",
"{",
"acf_update_setting",
"(",
"'l10n'",
",",
"true",
")",
";",
"acf_update_setting",
"(",
"'l10n_textdomain'",
",",
"$",
"this",
"->",
"textdomain",
")",
";",
"acf_update_setting",
"(",
"'l10n_var_export'",
",",
"true",
")",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"getExportFilename",
"(",
"$",
"fieldgroup",
")",
";",
"// Export php file",
"$",
"this",
"->",
"maybeUnlink",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'php/'",
".",
"$",
"filename",
"[",
"'php'",
"]",
")",
";",
"$",
"code",
"=",
"$",
"this",
"->",
"generatePhp",
"(",
"$",
"fieldgroup",
"[",
"'ID'",
"]",
",",
"$",
"translate",
")",
";",
"$",
"phpFile",
"=",
"fopen",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'php/'",
".",
"$",
"filename",
"[",
"'php'",
"]",
",",
"'w'",
")",
";",
"fwrite",
"(",
"$",
"phpFile",
",",
"$",
"code",
")",
";",
"fclose",
"(",
"$",
"phpFile",
")",
";",
"// Export json file",
"$",
"this",
"->",
"maybeUnlink",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'json/'",
".",
"$",
"filename",
"[",
"'json'",
"]",
")",
";",
"$",
"jsonFile",
"=",
"fopen",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'json/'",
".",
"$",
"filename",
"[",
"'json'",
"]",
",",
"'w'",
")",
";",
"$",
"json",
"=",
"$",
"this",
"->",
"getJson",
"(",
"$",
"this",
"->",
"getFieldgroupParams",
"(",
"$",
"fieldgroup",
"[",
"'ID'",
"]",
",",
"false",
")",
")",
";",
"fwrite",
"(",
"$",
"jsonFile",
",",
"$",
"json",
")",
";",
"fclose",
"(",
"$",
"jsonFile",
")",
";",
"return",
"array",
"(",
"'php'",
"=>",
"$",
"this",
"->",
"exportFolder",
".",
"'php/'",
".",
"$",
"filename",
"[",
"'php'",
"]",
",",
"'json'",
"=>",
"$",
"this",
"->",
"exportFolder",
".",
"'json/'",
".",
"$",
"filename",
"[",
"'json'",
"]",
")",
";",
"}"
]
| Does the actual export of the php fields
@param array $fieldgroup Fieldgroup data
@return array Paths to exported files | [
"Does",
"the",
"actual",
"export",
"of",
"the",
"php",
"fields"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L101-L139 |
18,775 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.getJson | public function getJson(array $fieldgroup) : string
{
$json = json_encode($fieldgroup, JSON_PRETTY_PRINT);
// Remove translation stuff from json
$json = str_replace('!!__(!!\'', '', $json);
$json = str_replace("!!', !!'" . $this->textdomain . "!!')!!", '', $json);
return '[' . $json . "]\n\r";
} | php | public function getJson(array $fieldgroup) : string
{
$json = json_encode($fieldgroup, JSON_PRETTY_PRINT);
// Remove translation stuff from json
$json = str_replace('!!__(!!\'', '', $json);
$json = str_replace("!!', !!'" . $this->textdomain . "!!')!!", '', $json);
return '[' . $json . "]\n\r";
} | [
"public",
"function",
"getJson",
"(",
"array",
"$",
"fieldgroup",
")",
":",
"string",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"fieldgroup",
",",
"JSON_PRETTY_PRINT",
")",
";",
"// Remove translation stuff from json",
"$",
"json",
"=",
"str_replace",
"(",
"'!!__(!!\\''",
",",
"''",
",",
"$",
"json",
")",
";",
"$",
"json",
"=",
"str_replace",
"(",
"\"!!', !!'\"",
".",
"$",
"this",
"->",
"textdomain",
".",
"\"!!')!!\"",
",",
"''",
",",
"$",
"json",
")",
";",
"return",
"'['",
".",
"$",
"json",
".",
"\"]\\n\\r\"",
";",
"}"
]
| Get fieldgroup as json
@param array $fieldgroup
@return string | [
"Get",
"fieldgroup",
"as",
"json"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L146-L155 |
18,776 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.maybeCreateExportFolders | public function maybeCreateExportFolders()
{
if (!is_writable($this->exportFolder)) {
trigger_error('The export folder (' . $this->exportFolder .') is not writable. Exports will not be saved.', E_USER_ERROR);
}
if (!file_exists($this->exportFolder . 'json')) {
mkdir($this->exportFolder . 'json');
chmod($this->exportFolder . 'json', 0777);
}
if (!file_exists($this->exportFolder . 'php')) {
mkdir($this->exportFolder . 'php');
chmod($this->exportFolder . 'php', 0777);
}
} | php | public function maybeCreateExportFolders()
{
if (!is_writable($this->exportFolder)) {
trigger_error('The export folder (' . $this->exportFolder .') is not writable. Exports will not be saved.', E_USER_ERROR);
}
if (!file_exists($this->exportFolder . 'json')) {
mkdir($this->exportFolder . 'json');
chmod($this->exportFolder . 'json', 0777);
}
if (!file_exists($this->exportFolder . 'php')) {
mkdir($this->exportFolder . 'php');
chmod($this->exportFolder . 'php', 0777);
}
} | [
"public",
"function",
"maybeCreateExportFolders",
"(",
")",
"{",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"this",
"->",
"exportFolder",
")",
")",
"{",
"trigger_error",
"(",
"'The export folder ('",
".",
"$",
"this",
"->",
"exportFolder",
".",
"') is not writable. Exports will not be saved.'",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'json'",
")",
")",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'json'",
")",
";",
"chmod",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'json'",
",",
"0777",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'php'",
")",
")",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'php'",
")",
";",
"chmod",
"(",
"$",
"this",
"->",
"exportFolder",
".",
"'php'",
",",
"0777",
")",
";",
"}",
"}"
]
| Creates export folders if needed
@return void | [
"Creates",
"export",
"folders",
"if",
"needed"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L161-L176 |
18,777 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.getExportFilename | public function getExportFilename(array $fieldgroup) : array
{
if ($key = array_search($fieldgroup['key'], $this->exportPosts)) {
return array(
'php' => $key . '.php',
'json' => $key . '.json'
);
}
return array(
'php' => sanitize_title($fieldgroup['title']) . '.php',
'json' => sanitize_title($fieldgroup['title']) . '.json'
);
} | php | public function getExportFilename(array $fieldgroup) : array
{
if ($key = array_search($fieldgroup['key'], $this->exportPosts)) {
return array(
'php' => $key . '.php',
'json' => $key . '.json'
);
}
return array(
'php' => sanitize_title($fieldgroup['title']) . '.php',
'json' => sanitize_title($fieldgroup['title']) . '.json'
);
} | [
"public",
"function",
"getExportFilename",
"(",
"array",
"$",
"fieldgroup",
")",
":",
"array",
"{",
"if",
"(",
"$",
"key",
"=",
"array_search",
"(",
"$",
"fieldgroup",
"[",
"'key'",
"]",
",",
"$",
"this",
"->",
"exportPosts",
")",
")",
"{",
"return",
"array",
"(",
"'php'",
"=>",
"$",
"key",
".",
"'.php'",
",",
"'json'",
"=>",
"$",
"key",
".",
"'.json'",
")",
";",
"}",
"return",
"array",
"(",
"'php'",
"=>",
"sanitize_title",
"(",
"$",
"fieldgroup",
"[",
"'title'",
"]",
")",
".",
"'.php'",
",",
"'json'",
"=>",
"sanitize_title",
"(",
"$",
"fieldgroup",
"[",
"'title'",
"]",
")",
".",
"'.json'",
")",
";",
"}"
]
| Get filename for the export file
@param array $fieldgroup Fieldgroup data
@return array | [
"Get",
"filename",
"for",
"the",
"export",
"file"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L192-L205 |
18,778 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.generatePhp | protected function generatePhp(int $fieldgroupId, bool $translate = true) : string
{
$strReplace = array(
" " => " ",
"!!\'" => "'",
"'!!" => "",
"!!'" => "",
"array (" => "array(",
" => \n" => " => "
);
$pregReplace = array(
'/([\t\r\n]+?)array/' => 'array',
'/[0-9]+ => array/' => 'array',
'/=>(\s+)array\(/' => '=> array('
);
$fieldgroup = $this->getFieldgroupParams($fieldgroupId, $translate);
$code = var_export($fieldgroup, true);
$code = str_replace(array_keys($strReplace), array_values($strReplace), $code);
$code = preg_replace(array_keys($pregReplace), array_values($pregReplace), $code);
$export = "<?php \n\r\n\rif (function_exists('acf_add_local_field_group')) {\n\r";
$export .= " acf_add_local_field_group({$code});";
$export .= "\n\r}";
acf_update_setting('l10n_var_export', false);
return $export;
} | php | protected function generatePhp(int $fieldgroupId, bool $translate = true) : string
{
$strReplace = array(
" " => " ",
"!!\'" => "'",
"'!!" => "",
"!!'" => "",
"array (" => "array(",
" => \n" => " => "
);
$pregReplace = array(
'/([\t\r\n]+?)array/' => 'array',
'/[0-9]+ => array/' => 'array',
'/=>(\s+)array\(/' => '=> array('
);
$fieldgroup = $this->getFieldgroupParams($fieldgroupId, $translate);
$code = var_export($fieldgroup, true);
$code = str_replace(array_keys($strReplace), array_values($strReplace), $code);
$code = preg_replace(array_keys($pregReplace), array_values($pregReplace), $code);
$export = "<?php \n\r\n\rif (function_exists('acf_add_local_field_group')) {\n\r";
$export .= " acf_add_local_field_group({$code});";
$export .= "\n\r}";
acf_update_setting('l10n_var_export', false);
return $export;
} | [
"protected",
"function",
"generatePhp",
"(",
"int",
"$",
"fieldgroupId",
",",
"bool",
"$",
"translate",
"=",
"true",
")",
":",
"string",
"{",
"$",
"strReplace",
"=",
"array",
"(",
"\" \"",
"=>",
"\" \"",
",",
"\"!!\\'\"",
"=>",
"\"'\"",
",",
"\"'!!\"",
"=>",
"\"\"",
",",
"\"!!'\"",
"=>",
"\"\"",
",",
"\"array (\"",
"=>",
"\"array(\"",
",",
"\" => \\n\"",
"=>",
"\" => \"",
")",
";",
"$",
"pregReplace",
"=",
"array",
"(",
"'/([\\t\\r\\n]+?)array/'",
"=>",
"'array'",
",",
"'/[0-9]+ => array/'",
"=>",
"'array'",
",",
"'/=>(\\s+)array\\(/'",
"=>",
"'=> array('",
")",
";",
"$",
"fieldgroup",
"=",
"$",
"this",
"->",
"getFieldgroupParams",
"(",
"$",
"fieldgroupId",
",",
"$",
"translate",
")",
";",
"$",
"code",
"=",
"var_export",
"(",
"$",
"fieldgroup",
",",
"true",
")",
";",
"$",
"code",
"=",
"str_replace",
"(",
"array_keys",
"(",
"$",
"strReplace",
")",
",",
"array_values",
"(",
"$",
"strReplace",
")",
",",
"$",
"code",
")",
";",
"$",
"code",
"=",
"preg_replace",
"(",
"array_keys",
"(",
"$",
"pregReplace",
")",
",",
"array_values",
"(",
"$",
"pregReplace",
")",
",",
"$",
"code",
")",
";",
"$",
"export",
"=",
"\"<?php \\n\\r\\n\\rif (function_exists('acf_add_local_field_group')) {\\n\\r\"",
";",
"$",
"export",
".=",
"\" acf_add_local_field_group({$code});\"",
";",
"$",
"export",
".=",
"\"\\n\\r}\"",
";",
"acf_update_setting",
"(",
"'l10n_var_export'",
",",
"false",
")",
";",
"return",
"$",
"export",
";",
"}"
]
| Generates PHP exportcode for a fieldgroup
@param int $fieldgroupId
@return string | [
"Generates",
"PHP",
"exportcode",
"for",
"a",
"fieldgroup"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L212-L242 |
18,779 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.getFieldgroupParams | public function getFieldgroupParams(int $fieldgroupId, bool $translate = true) : array
{
// Get the fieldgroup
$fieldgroup = acf_get_field_group($fieldgroupId);
// Bail if fieldgroup is empty
if (empty($fieldgroup)) {
trigger_error('The fieldgroup with id "' . $fieldgroupId . '" is empty.', E_USER_WARNING);
return array();
}
// Get the fields in the fieldgroup
$fieldgroup['fields'] = acf_get_fields($fieldgroup);
// Translate
if ($translate) {
$fieldgroup = $this->translate($fieldgroup);
}
// Preapre for export
return acf_prepare_field_group_for_export($fieldgroup);
} | php | public function getFieldgroupParams(int $fieldgroupId, bool $translate = true) : array
{
// Get the fieldgroup
$fieldgroup = acf_get_field_group($fieldgroupId);
// Bail if fieldgroup is empty
if (empty($fieldgroup)) {
trigger_error('The fieldgroup with id "' . $fieldgroupId . '" is empty.', E_USER_WARNING);
return array();
}
// Get the fields in the fieldgroup
$fieldgroup['fields'] = acf_get_fields($fieldgroup);
// Translate
if ($translate) {
$fieldgroup = $this->translate($fieldgroup);
}
// Preapre for export
return acf_prepare_field_group_for_export($fieldgroup);
} | [
"public",
"function",
"getFieldgroupParams",
"(",
"int",
"$",
"fieldgroupId",
",",
"bool",
"$",
"translate",
"=",
"true",
")",
":",
"array",
"{",
"// Get the fieldgroup",
"$",
"fieldgroup",
"=",
"acf_get_field_group",
"(",
"$",
"fieldgroupId",
")",
";",
"// Bail if fieldgroup is empty",
"if",
"(",
"empty",
"(",
"$",
"fieldgroup",
")",
")",
"{",
"trigger_error",
"(",
"'The fieldgroup with id \"'",
".",
"$",
"fieldgroupId",
".",
"'\" is empty.'",
",",
"E_USER_WARNING",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"// Get the fields in the fieldgroup",
"$",
"fieldgroup",
"[",
"'fields'",
"]",
"=",
"acf_get_fields",
"(",
"$",
"fieldgroup",
")",
";",
"// Translate",
"if",
"(",
"$",
"translate",
")",
"{",
"$",
"fieldgroup",
"=",
"$",
"this",
"->",
"translate",
"(",
"$",
"fieldgroup",
")",
";",
"}",
"// Preapre for export",
"return",
"acf_prepare_field_group_for_export",
"(",
"$",
"fieldgroup",
")",
";",
"}"
]
| Get exportable fieldgroup params
@param int $fieldgroupId
@return array | [
"Get",
"exportable",
"fieldgroup",
"params"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L249-L270 |
18,780 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.translateFieldParams | public function translateFieldParams(array $field) : array
{
$keys = array('prepend', 'append', 'placeholder', 'default_value');
foreach ($keys as $key) {
if (!isset($field[$key])) {
continue;
}
$field[$key] = acf_translate($field[$key]);
}
if (isset($field['sub_fields']) && is_array($field['sub_fields'])) {
foreach ($field['sub_fields'] as &$subfield) {
if (function_exists('\acf_translate_field')) {
$subfield = \acf_translate_field($subfield);
}
}
}
return $field;
} | php | public function translateFieldParams(array $field) : array
{
$keys = array('prepend', 'append', 'placeholder', 'default_value');
foreach ($keys as $key) {
if (!isset($field[$key])) {
continue;
}
$field[$key] = acf_translate($field[$key]);
}
if (isset($field['sub_fields']) && is_array($field['sub_fields'])) {
foreach ($field['sub_fields'] as &$subfield) {
if (function_exists('\acf_translate_field')) {
$subfield = \acf_translate_field($subfield);
}
}
}
return $field;
} | [
"public",
"function",
"translateFieldParams",
"(",
"array",
"$",
"field",
")",
":",
"array",
"{",
"$",
"keys",
"=",
"array",
"(",
"'prepend'",
",",
"'append'",
",",
"'placeholder'",
",",
"'default_value'",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"field",
"[",
"$",
"key",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"field",
"[",
"$",
"key",
"]",
"=",
"acf_translate",
"(",
"$",
"field",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"field",
"[",
"'sub_fields'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"field",
"[",
"'sub_fields'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"field",
"[",
"'sub_fields'",
"]",
"as",
"&",
"$",
"subfield",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'\\acf_translate_field'",
")",
")",
"{",
"$",
"subfield",
"=",
"\\",
"acf_translate_field",
"(",
"$",
"subfield",
")",
";",
"}",
"}",
"}",
"return",
"$",
"field",
";",
"}"
]
| Translate field params
@param array $field ACF Field params
@return array Translated ACF field params | [
"Translate",
"field",
"params"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L294-L316 |
18,781 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.setExportFolder | public function setExportFolder(string $folder)
{
$folder = trailingslashit($folder);
if (!file_exists($folder)) {
if (!mkdir($folder)) {
trigger_error('The export folder (' . $folder .') can not be found. Exports will not be saved.', E_USER_WARNING);
} else {
chmod($folder, 0777);
}
}
$this->exportFolder = $folder;
} | php | public function setExportFolder(string $folder)
{
$folder = trailingslashit($folder);
if (!file_exists($folder)) {
if (!mkdir($folder)) {
trigger_error('The export folder (' . $folder .') can not be found. Exports will not be saved.', E_USER_WARNING);
} else {
chmod($folder, 0777);
}
}
$this->exportFolder = $folder;
} | [
"public",
"function",
"setExportFolder",
"(",
"string",
"$",
"folder",
")",
"{",
"$",
"folder",
"=",
"trailingslashit",
"(",
"$",
"folder",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"folder",
")",
")",
"{",
"if",
"(",
"!",
"mkdir",
"(",
"$",
"folder",
")",
")",
"{",
"trigger_error",
"(",
"'The export folder ('",
".",
"$",
"folder",
".",
"') can not be found. Exports will not be saved.'",
",",
"E_USER_WARNING",
")",
";",
"}",
"else",
"{",
"chmod",
"(",
"$",
"folder",
",",
"0777",
")",
";",
"}",
"}",
"$",
"this",
"->",
"exportFolder",
"=",
"$",
"folder",
";",
"}"
]
| Set exports folder
@param string $folder Path to exports folder
@return void | [
"Set",
"exports",
"folder"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L323-L336 |
18,782 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.autoExport | public function autoExport(array $ids)
{
$this->exportPosts = array_replace($this->exportPosts, $ids);
$this->exportPosts = array_unique($this->exportPosts);
} | php | public function autoExport(array $ids)
{
$this->exportPosts = array_replace($this->exportPosts, $ids);
$this->exportPosts = array_unique($this->exportPosts);
} | [
"public",
"function",
"autoExport",
"(",
"array",
"$",
"ids",
")",
"{",
"$",
"this",
"->",
"exportPosts",
"=",
"array_replace",
"(",
"$",
"this",
"->",
"exportPosts",
",",
"$",
"ids",
")",
";",
"$",
"this",
"->",
"exportPosts",
"=",
"array_unique",
"(",
"$",
"this",
"->",
"exportPosts",
")",
";",
"}"
]
| Sets which acf-fieldgroups postids to autoexport
@param array $ids
@return void | [
"Sets",
"which",
"acf",
"-",
"fieldgroups",
"postids",
"to",
"autoexport"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L343-L347 |
18,783 | helsingborg-stad/acf-export-manager | src/AcfExportManager.php | AcfExportManager.handleBulkExport | public function handleBulkExport($redirectTo, $doaction, $postIds)
{
if ($doaction !== 'acfExportManager-export') {
return $redirectTo;
}
foreach ($postIds as $postId) {
$fieldgroup = acf_get_field_group($postId);
if (!in_array($fieldgroup['key'], $this->exportPosts)) {
continue;
}
$this->export($fieldgroup, false, false);
}
$redirectTo = add_query_arg('bulkExportedFieldgroups', count($postIds), $redirectTo);
return $redirectTo;
} | php | public function handleBulkExport($redirectTo, $doaction, $postIds)
{
if ($doaction !== 'acfExportManager-export') {
return $redirectTo;
}
foreach ($postIds as $postId) {
$fieldgroup = acf_get_field_group($postId);
if (!in_array($fieldgroup['key'], $this->exportPosts)) {
continue;
}
$this->export($fieldgroup, false, false);
}
$redirectTo = add_query_arg('bulkExportedFieldgroups', count($postIds), $redirectTo);
return $redirectTo;
} | [
"public",
"function",
"handleBulkExport",
"(",
"$",
"redirectTo",
",",
"$",
"doaction",
",",
"$",
"postIds",
")",
"{",
"if",
"(",
"$",
"doaction",
"!==",
"'acfExportManager-export'",
")",
"{",
"return",
"$",
"redirectTo",
";",
"}",
"foreach",
"(",
"$",
"postIds",
"as",
"$",
"postId",
")",
"{",
"$",
"fieldgroup",
"=",
"acf_get_field_group",
"(",
"$",
"postId",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"fieldgroup",
"[",
"'key'",
"]",
",",
"$",
"this",
"->",
"exportPosts",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"export",
"(",
"$",
"fieldgroup",
",",
"false",
",",
"false",
")",
";",
"}",
"$",
"redirectTo",
"=",
"add_query_arg",
"(",
"'bulkExportedFieldgroups'",
",",
"count",
"(",
"$",
"postIds",
")",
",",
"$",
"redirectTo",
")",
";",
"return",
"$",
"redirectTo",
";",
"}"
]
| Handles bulk exporting
@param string $redirectTo Redirect
@param string $doaction The bulk action to do
@param array $postIds Selected posts
@return string The redirect | [
"Handles",
"bulk",
"exporting"
]
| 27e904a24eb013cac5c8f3d3c30e88b5b9b7859b | https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L375-L394 |
18,784 | forkiss/pharest | src/Pharest/ExceptionHandler.php | ExceptionHandler.hasCustomHandler | public function hasCustomHandler()
{
if (!class_exists(\App\Exception\Handler::class)) {
return false;
}
if (!in_array(\Pharest\Exception\ExceptionHandler::class, class_implements(\App\Exception\Handler::class))) {
return false;
}
return true;
} | php | public function hasCustomHandler()
{
if (!class_exists(\App\Exception\Handler::class)) {
return false;
}
if (!in_array(\Pharest\Exception\ExceptionHandler::class, class_implements(\App\Exception\Handler::class))) {
return false;
}
return true;
} | [
"public",
"function",
"hasCustomHandler",
"(",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"\\",
"App",
"\\",
"Exception",
"\\",
"Handler",
"::",
"class",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"\\",
"Pharest",
"\\",
"Exception",
"\\",
"ExceptionHandler",
"::",
"class",
",",
"class_implements",
"(",
"\\",
"App",
"\\",
"Exception",
"\\",
"Handler",
"::",
"class",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Determine if the app has custom exception handler
@return bool | [
"Determine",
"if",
"the",
"app",
"has",
"custom",
"exception",
"handler"
]
| f8b444f9bba446bf7994d98f27585529aefed565 | https://github.com/forkiss/pharest/blob/f8b444f9bba446bf7994d98f27585529aefed565/src/Pharest/ExceptionHandler.php#L34-L45 |
18,785 | ClanCats/Core | src/classes/CCDate.php | CCDate.relative | public static function relative($ts)
{
if(!ctype_digit($ts))
$ts = strtotime($ts);
$diff = time() - $ts;
if($diff == 0)
return __('Core::common.date.now');
elseif($diff > 0)
{
$day_diff = floor($diff / 86400);
if($day_diff == 0)
{
if($diff < 60) return __('Core::common.date.just_now');
if($diff < 120) return __('Core::common.date.minute_ago');
if($diff < 3600) return __('Core::common.date.minutes_ago', array( 'num' => floor($diff / 60) ) );
if($diff < 7200) return __('Core::common.date.hour_ago');
if($diff < 86400) return __('Core::common.date.hours_ago', array( 'num' => floor($diff / 3600) ) );
}
if($day_diff == 1) return __('Core::common.date.yesterday');
if($day_diff < 7) return __('Core::common.date.days_ago', array( 'num' => $day_diff ) );
if($day_diff < 31) return __('Core::common.date.weeks_ago', array( 'num' => ceil($day_diff / 7) ) );
if($day_diff < 60) return __('Core::common.date.last_month');
return date('F Y', $ts);
}
else
{
$diff = abs($diff);
$day_diff = floor($diff / 86400);
if($day_diff == 0)
{
if($diff < 120) return __('Core::common.date.in_minute');
if($diff < 3600) return __('Core::common.date.in_minutes', array( 'num' => floor($diff / 60) ) );
if($diff < 7200) return __('Core::common.date.in_hour');
if($diff < 86400) return __('Core::common.date.in_hours', array( 'num' => floor($diff / 3600) ) );
}
if($day_diff == 1) return __('Core::common.date.tomorrow');
if($day_diff < 4) return date('l', $ts);
if($day_diff < 7 + (7 - date('w'))) return 'next week';
if(ceil($day_diff / 7) < 4) return 'in ' . ceil($day_diff / 7) . ' weeks';
if(date('n', $ts) == date('n') + 1) return 'next month';
return date('F Y', $ts);
}
} | php | public static function relative($ts)
{
if(!ctype_digit($ts))
$ts = strtotime($ts);
$diff = time() - $ts;
if($diff == 0)
return __('Core::common.date.now');
elseif($diff > 0)
{
$day_diff = floor($diff / 86400);
if($day_diff == 0)
{
if($diff < 60) return __('Core::common.date.just_now');
if($diff < 120) return __('Core::common.date.minute_ago');
if($diff < 3600) return __('Core::common.date.minutes_ago', array( 'num' => floor($diff / 60) ) );
if($diff < 7200) return __('Core::common.date.hour_ago');
if($diff < 86400) return __('Core::common.date.hours_ago', array( 'num' => floor($diff / 3600) ) );
}
if($day_diff == 1) return __('Core::common.date.yesterday');
if($day_diff < 7) return __('Core::common.date.days_ago', array( 'num' => $day_diff ) );
if($day_diff < 31) return __('Core::common.date.weeks_ago', array( 'num' => ceil($day_diff / 7) ) );
if($day_diff < 60) return __('Core::common.date.last_month');
return date('F Y', $ts);
}
else
{
$diff = abs($diff);
$day_diff = floor($diff / 86400);
if($day_diff == 0)
{
if($diff < 120) return __('Core::common.date.in_minute');
if($diff < 3600) return __('Core::common.date.in_minutes', array( 'num' => floor($diff / 60) ) );
if($diff < 7200) return __('Core::common.date.in_hour');
if($diff < 86400) return __('Core::common.date.in_hours', array( 'num' => floor($diff / 3600) ) );
}
if($day_diff == 1) return __('Core::common.date.tomorrow');
if($day_diff < 4) return date('l', $ts);
if($day_diff < 7 + (7 - date('w'))) return 'next week';
if(ceil($day_diff / 7) < 4) return 'in ' . ceil($day_diff / 7) . ' weeks';
if(date('n', $ts) == date('n') + 1) return 'next month';
return date('F Y', $ts);
}
} | [
"public",
"static",
"function",
"relative",
"(",
"$",
"ts",
")",
"{",
"if",
"(",
"!",
"ctype_digit",
"(",
"$",
"ts",
")",
")",
"$",
"ts",
"=",
"strtotime",
"(",
"$",
"ts",
")",
";",
"$",
"diff",
"=",
"time",
"(",
")",
"-",
"$",
"ts",
";",
"if",
"(",
"$",
"diff",
"==",
"0",
")",
"return",
"__",
"(",
"'Core::common.date.now'",
")",
";",
"elseif",
"(",
"$",
"diff",
">",
"0",
")",
"{",
"$",
"day_diff",
"=",
"floor",
"(",
"$",
"diff",
"/",
"86400",
")",
";",
"if",
"(",
"$",
"day_diff",
"==",
"0",
")",
"{",
"if",
"(",
"$",
"diff",
"<",
"60",
")",
"return",
"__",
"(",
"'Core::common.date.just_now'",
")",
";",
"if",
"(",
"$",
"diff",
"<",
"120",
")",
"return",
"__",
"(",
"'Core::common.date.minute_ago'",
")",
";",
"if",
"(",
"$",
"diff",
"<",
"3600",
")",
"return",
"__",
"(",
"'Core::common.date.minutes_ago'",
",",
"array",
"(",
"'num'",
"=>",
"floor",
"(",
"$",
"diff",
"/",
"60",
")",
")",
")",
";",
"if",
"(",
"$",
"diff",
"<",
"7200",
")",
"return",
"__",
"(",
"'Core::common.date.hour_ago'",
")",
";",
"if",
"(",
"$",
"diff",
"<",
"86400",
")",
"return",
"__",
"(",
"'Core::common.date.hours_ago'",
",",
"array",
"(",
"'num'",
"=>",
"floor",
"(",
"$",
"diff",
"/",
"3600",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"day_diff",
"==",
"1",
")",
"return",
"__",
"(",
"'Core::common.date.yesterday'",
")",
";",
"if",
"(",
"$",
"day_diff",
"<",
"7",
")",
"return",
"__",
"(",
"'Core::common.date.days_ago'",
",",
"array",
"(",
"'num'",
"=>",
"$",
"day_diff",
")",
")",
";",
"if",
"(",
"$",
"day_diff",
"<",
"31",
")",
"return",
"__",
"(",
"'Core::common.date.weeks_ago'",
",",
"array",
"(",
"'num'",
"=>",
"ceil",
"(",
"$",
"day_diff",
"/",
"7",
")",
")",
")",
";",
"if",
"(",
"$",
"day_diff",
"<",
"60",
")",
"return",
"__",
"(",
"'Core::common.date.last_month'",
")",
";",
"return",
"date",
"(",
"'F Y'",
",",
"$",
"ts",
")",
";",
"}",
"else",
"{",
"$",
"diff",
"=",
"abs",
"(",
"$",
"diff",
")",
";",
"$",
"day_diff",
"=",
"floor",
"(",
"$",
"diff",
"/",
"86400",
")",
";",
"if",
"(",
"$",
"day_diff",
"==",
"0",
")",
"{",
"if",
"(",
"$",
"diff",
"<",
"120",
")",
"return",
"__",
"(",
"'Core::common.date.in_minute'",
")",
";",
"if",
"(",
"$",
"diff",
"<",
"3600",
")",
"return",
"__",
"(",
"'Core::common.date.in_minutes'",
",",
"array",
"(",
"'num'",
"=>",
"floor",
"(",
"$",
"diff",
"/",
"60",
")",
")",
")",
";",
"if",
"(",
"$",
"diff",
"<",
"7200",
")",
"return",
"__",
"(",
"'Core::common.date.in_hour'",
")",
";",
"if",
"(",
"$",
"diff",
"<",
"86400",
")",
"return",
"__",
"(",
"'Core::common.date.in_hours'",
",",
"array",
"(",
"'num'",
"=>",
"floor",
"(",
"$",
"diff",
"/",
"3600",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"day_diff",
"==",
"1",
")",
"return",
"__",
"(",
"'Core::common.date.tomorrow'",
")",
";",
"if",
"(",
"$",
"day_diff",
"<",
"4",
")",
"return",
"date",
"(",
"'l'",
",",
"$",
"ts",
")",
";",
"if",
"(",
"$",
"day_diff",
"<",
"7",
"+",
"(",
"7",
"-",
"date",
"(",
"'w'",
")",
")",
")",
"return",
"'next week'",
";",
"if",
"(",
"ceil",
"(",
"$",
"day_diff",
"/",
"7",
")",
"<",
"4",
")",
"return",
"'in '",
".",
"ceil",
"(",
"$",
"day_diff",
"/",
"7",
")",
".",
"' weeks'",
";",
"if",
"(",
"date",
"(",
"'n'",
",",
"$",
"ts",
")",
"==",
"date",
"(",
"'n'",
")",
"+",
"1",
")",
"return",
"'next month'",
";",
"return",
"date",
"(",
"'F Y'",
",",
"$",
"ts",
")",
";",
"}",
"}"
]
| to string relative string
@param int $ts
@return string | [
"to",
"string",
"relative",
"string"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCDate.php#L100-L143 |
18,786 | ppetermann/king23 | src/TwigIntegration/TwigController.php | TwigController.render | protected function render($template, $context = [])
{
$context = array_merge($this->_context, $context);
$body = $this->twig->render($template, $context);
return $body;
} | php | protected function render($template, $context = [])
{
$context = array_merge($this->_context, $context);
$body = $this->twig->render($template, $context);
return $body;
} | [
"protected",
"function",
"render",
"(",
"$",
"template",
",",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"context",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_context",
",",
"$",
"context",
")",
";",
"$",
"body",
"=",
"$",
"this",
"->",
"twig",
"->",
"render",
"(",
"$",
"template",
",",
"$",
"context",
")",
";",
"return",
"$",
"body",
";",
"}"
]
| render template with context, will merge context with allready known
context
@param string $template
@param array $context
@return string | [
"render",
"template",
"with",
"context",
"will",
"merge",
"context",
"with",
"allready",
"known",
"context"
]
| 603896083ec89f5ac4d744abd3b1b4db3e914c95 | https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/TwigIntegration/TwigController.php#L95-L100 |
18,787 | iocaste/microservice-foundation | src/Seeder/Seeder.php | Seeder.truncateTables | public function truncateTables()
{
$dbName = env('DB_DATABASE');
// Get all tables list, except migrations table
$tables = DB::select('SHOW TABLES WHERE `Tables_in_'.$dbName.'` != ?', ['migrations']);
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
foreach ($tables as $table) {
DB::table($table->{'Tables_in_' . $dbName})->truncate();
}
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
} | php | public function truncateTables()
{
$dbName = env('DB_DATABASE');
// Get all tables list, except migrations table
$tables = DB::select('SHOW TABLES WHERE `Tables_in_'.$dbName.'` != ?', ['migrations']);
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
foreach ($tables as $table) {
DB::table($table->{'Tables_in_' . $dbName})->truncate();
}
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
} | [
"public",
"function",
"truncateTables",
"(",
")",
"{",
"$",
"dbName",
"=",
"env",
"(",
"'DB_DATABASE'",
")",
";",
"// Get all tables list, except migrations table",
"$",
"tables",
"=",
"DB",
"::",
"select",
"(",
"'SHOW TABLES WHERE `Tables_in_'",
".",
"$",
"dbName",
".",
"'` != ?'",
",",
"[",
"'migrations'",
"]",
")",
";",
"DB",
"::",
"statement",
"(",
"'SET FOREIGN_KEY_CHECKS=0;'",
")",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"DB",
"::",
"table",
"(",
"$",
"table",
"->",
"{",
"'Tables_in_'",
".",
"$",
"dbName",
"}",
")",
"->",
"truncate",
"(",
")",
";",
"}",
"DB",
"::",
"statement",
"(",
"'SET FOREIGN_KEY_CHECKS=1;'",
")",
";",
"}"
]
| Truncates all tables except migrations. | [
"Truncates",
"all",
"tables",
"except",
"migrations",
"."
]
| 274a154de4299e8a57314bab972e09f6d8cdae9e | https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Seeder/Seeder.php#L16-L28 |
18,788 | SachaMorard/phalcon-console | Library/Phalcon/Builder/Path.php | Path.getConfig | public function getConfig($type = null)
{
$types = ['php' => true, 'ini' => true];
$type = isset($types[$type]) ? $type : 'ini';
foreach (['app/config/', 'config/', 'apps/config/', 'apps/frontend/config/'] as $configPath) {
if ('ini' == $type && file_exists($this->rootPath . $configPath . 'config.ini')) {
return new ConfigIni($this->rootPath . $configPath . 'config.ini');
} else {
if (file_exists($this->rootPath . $configPath. 'config.php')) {
$config = include($this->rootPath . $configPath . 'config.php');
if (is_array($config)) {
$config = new Config($config);
}
return $config;
}
}
}
$directory = new RecursiveDirectoryIterator('.');
$iterator = new RecursiveIteratorIterator($directory);
foreach ($iterator as $f) {
if (preg_match('/config\.php$/i', $f->getPathName())) {
$config = include $f->getPathName();
if (is_array($config)) {
$config = new Config($config);
}
return $config;
} else {
if (preg_match('/config\.ini$/i', $f->getPathName())) {
return new ConfigIni($f->getPathName());
}
}
}
throw new BuilderException("Builder can't locate the configuration file");
} | php | public function getConfig($type = null)
{
$types = ['php' => true, 'ini' => true];
$type = isset($types[$type]) ? $type : 'ini';
foreach (['app/config/', 'config/', 'apps/config/', 'apps/frontend/config/'] as $configPath) {
if ('ini' == $type && file_exists($this->rootPath . $configPath . 'config.ini')) {
return new ConfigIni($this->rootPath . $configPath . 'config.ini');
} else {
if (file_exists($this->rootPath . $configPath. 'config.php')) {
$config = include($this->rootPath . $configPath . 'config.php');
if (is_array($config)) {
$config = new Config($config);
}
return $config;
}
}
}
$directory = new RecursiveDirectoryIterator('.');
$iterator = new RecursiveIteratorIterator($directory);
foreach ($iterator as $f) {
if (preg_match('/config\.php$/i', $f->getPathName())) {
$config = include $f->getPathName();
if (is_array($config)) {
$config = new Config($config);
}
return $config;
} else {
if (preg_match('/config\.ini$/i', $f->getPathName())) {
return new ConfigIni($f->getPathName());
}
}
}
throw new BuilderException("Builder can't locate the configuration file");
} | [
"public",
"function",
"getConfig",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"types",
"=",
"[",
"'php'",
"=>",
"true",
",",
"'ini'",
"=>",
"true",
"]",
";",
"$",
"type",
"=",
"isset",
"(",
"$",
"types",
"[",
"$",
"type",
"]",
")",
"?",
"$",
"type",
":",
"'ini'",
";",
"foreach",
"(",
"[",
"'app/config/'",
",",
"'config/'",
",",
"'apps/config/'",
",",
"'apps/frontend/config/'",
"]",
"as",
"$",
"configPath",
")",
"{",
"if",
"(",
"'ini'",
"==",
"$",
"type",
"&&",
"file_exists",
"(",
"$",
"this",
"->",
"rootPath",
".",
"$",
"configPath",
".",
"'config.ini'",
")",
")",
"{",
"return",
"new",
"ConfigIni",
"(",
"$",
"this",
"->",
"rootPath",
".",
"$",
"configPath",
".",
"'config.ini'",
")",
";",
"}",
"else",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"rootPath",
".",
"$",
"configPath",
".",
"'config.php'",
")",
")",
"{",
"$",
"config",
"=",
"include",
"(",
"$",
"this",
"->",
"rootPath",
".",
"$",
"configPath",
".",
"'config.php'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"new",
"Config",
"(",
"$",
"config",
")",
";",
"}",
"return",
"$",
"config",
";",
"}",
"}",
"}",
"$",
"directory",
"=",
"new",
"RecursiveDirectoryIterator",
"(",
"'.'",
")",
";",
"$",
"iterator",
"=",
"new",
"RecursiveIteratorIterator",
"(",
"$",
"directory",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/config\\.php$/i'",
",",
"$",
"f",
"->",
"getPathName",
"(",
")",
")",
")",
"{",
"$",
"config",
"=",
"include",
"$",
"f",
"->",
"getPathName",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"new",
"Config",
"(",
"$",
"config",
")",
";",
"}",
"return",
"$",
"config",
";",
"}",
"else",
"{",
"if",
"(",
"preg_match",
"(",
"'/config\\.ini$/i'",
",",
"$",
"f",
"->",
"getPathName",
"(",
")",
")",
")",
"{",
"return",
"new",
"ConfigIni",
"(",
"$",
"f",
"->",
"getPathName",
"(",
")",
")",
";",
"}",
"}",
"}",
"throw",
"new",
"BuilderException",
"(",
"\"Builder can't locate the configuration file\"",
")",
";",
"}"
]
| Tries to find the current configuration in the application
@param string $type Config type: ini | php
@return \Phalcon\Config
@throws BuilderException | [
"Tries",
"to",
"find",
"the",
"current",
"configuration",
"in",
"the",
"application"
]
| a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3 | https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Builder/Path.php#L50-L88 |
18,789 | SachaMorard/phalcon-console | Library/Phalcon/Builder/Path.php | Path.isAbsolutePath | public function isAbsolutePath($path)
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
if (preg_match('/^[A-Z]:\\\\/', $path)) {
return true;
}
} else {
if (substr($path, 0, 1) == DIRECTORY_SEPARATOR) {
return true;
}
}
return false;
} | php | public function isAbsolutePath($path)
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
if (preg_match('/^[A-Z]:\\\\/', $path)) {
return true;
}
} else {
if (substr($path, 0, 1) == DIRECTORY_SEPARATOR) {
return true;
}
}
return false;
} | [
"public",
"function",
"isAbsolutePath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"strtoupper",
"(",
"substr",
"(",
"PHP_OS",
",",
"0",
",",
"3",
")",
")",
"===",
"'WIN'",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^[A-Z]:\\\\\\\\/'",
",",
"$",
"path",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"1",
")",
"==",
"DIRECTORY_SEPARATOR",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Check if a path is absolute
@param string $path Path to check
@return bool | [
"Check",
"if",
"a",
"path",
"is",
"absolute"
]
| a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3 | https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Builder/Path.php#L115-L128 |
18,790 | ClanCats/Core | src/classes/CCAsset/Holder.php | CCAsset_Holder.add | public function add( $item )
{
// when the first character is a "smaller than" we simply assume
// that a custom tag has been passed and not a filepath
if ( strpos( $item, "<" ) !== false )
{
$macro = '_';
} else {
$macro = CCStr::extension( $item );
}
if ( !isset( $this->assets[$macro] ) )
{
$this->assets[$macro] = array();
}
$this->assets[$macro][] = $item;
} | php | public function add( $item )
{
// when the first character is a "smaller than" we simply assume
// that a custom tag has been passed and not a filepath
if ( strpos( $item, "<" ) !== false )
{
$macro = '_';
} else {
$macro = CCStr::extension( $item );
}
if ( !isset( $this->assets[$macro] ) )
{
$this->assets[$macro] = array();
}
$this->assets[$macro][] = $item;
} | [
"public",
"function",
"add",
"(",
"$",
"item",
")",
"{",
"// when the first character is a \"smaller than\" we simply assume",
"// that a custom tag has been passed and not a filepath",
"if",
"(",
"strpos",
"(",
"$",
"item",
",",
"\"<\"",
")",
"!==",
"false",
")",
"{",
"$",
"macro",
"=",
"'_'",
";",
"}",
"else",
"{",
"$",
"macro",
"=",
"CCStr",
"::",
"extension",
"(",
"$",
"item",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"assets",
"[",
"$",
"macro",
"]",
")",
")",
"{",
"$",
"this",
"->",
"assets",
"[",
"$",
"macro",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"assets",
"[",
"$",
"macro",
"]",
"[",
"]",
"=",
"$",
"item",
";",
"}"
]
| Add an asset to the holder. Basically this method checks the
file extension to sort them and generate the correct code using the macros.
$holder->add( 'jquery.js' );
$holder->add( 'style.css' );
$holder->add( '<script>document.write( "Hello World" );</script>' );
@param string $item
@return void | [
"Add",
"an",
"asset",
"to",
"the",
"holder",
".",
"Basically",
"this",
"method",
"checks",
"the",
"file",
"extension",
"to",
"sort",
"them",
"and",
"generate",
"the",
"correct",
"code",
"using",
"the",
"macros",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCAsset/Holder.php#L39-L56 |
18,791 | Lansoweb/LosBase | src/LosBase/Controller/ODM/AbstractCrudController.php | AbstractCrudController.getForm | public function getForm($documentClass = null)
{
if (null === $documentClass) {
$documentClass = $this->getDocumentClass();
}
$builder = new AnnotationBuilder();
$form = $builder->createForm($documentClass);
$hasDocument = false;
foreach ($form->getElements() as $element) {
if (method_exists($element, 'setObjectManager')) {
$element->setObjectManager($this->getDocumentManager());
$hasDocument = true;
} elseif (method_exists($element, 'getProxy')) {
$proxy = $element->getProxy();
if (method_exists($proxy, 'setObjectManager')) {
$proxy->setObjectManager($this->getDocumentManager());
$hasDocument = true;
}
}
}
if ($hasDocument) {
$hydrator = new DoctrineObjectHydrator($this->getDocumentManager(), $documentClass);
$form->setHydrator($hydrator);
} else {
$form->setHydrator(new ClassMethods());
}
$form->add([
'type' => 'Zend\Form\Element\Csrf',
'name' => 'csrf',
'attributes' => [
'id' => 'csrf',
],
]);
$submitElement = new \Zend\Form\Element\Button('submit');
$submitElement->setAttributes([
'type' => 'submit',
'class' => 'btn btn-primary',
]);
$submitElement->setLabel('Salvar');
$form->add($submitElement, [
'priority' => -100,
]);
$cancelarElement = new \Zend\Form\Element\Button('cancelar');
$cancelarElement->setAttributes([
'type' => 'button',
'class' => 'btn btn-default',
'onclick' => 'top.location=\''.$this->url()
->fromRoute($this->getActionRoute('list')).'\'',
]);
$cancelarElement->setLabel('Cancelar');
$form->add($cancelarElement, [
'priority' => -100,
]);
return $form;
} | php | public function getForm($documentClass = null)
{
if (null === $documentClass) {
$documentClass = $this->getDocumentClass();
}
$builder = new AnnotationBuilder();
$form = $builder->createForm($documentClass);
$hasDocument = false;
foreach ($form->getElements() as $element) {
if (method_exists($element, 'setObjectManager')) {
$element->setObjectManager($this->getDocumentManager());
$hasDocument = true;
} elseif (method_exists($element, 'getProxy')) {
$proxy = $element->getProxy();
if (method_exists($proxy, 'setObjectManager')) {
$proxy->setObjectManager($this->getDocumentManager());
$hasDocument = true;
}
}
}
if ($hasDocument) {
$hydrator = new DoctrineObjectHydrator($this->getDocumentManager(), $documentClass);
$form->setHydrator($hydrator);
} else {
$form->setHydrator(new ClassMethods());
}
$form->add([
'type' => 'Zend\Form\Element\Csrf',
'name' => 'csrf',
'attributes' => [
'id' => 'csrf',
],
]);
$submitElement = new \Zend\Form\Element\Button('submit');
$submitElement->setAttributes([
'type' => 'submit',
'class' => 'btn btn-primary',
]);
$submitElement->setLabel('Salvar');
$form->add($submitElement, [
'priority' => -100,
]);
$cancelarElement = new \Zend\Form\Element\Button('cancelar');
$cancelarElement->setAttributes([
'type' => 'button',
'class' => 'btn btn-default',
'onclick' => 'top.location=\''.$this->url()
->fromRoute($this->getActionRoute('list')).'\'',
]);
$cancelarElement->setLabel('Cancelar');
$form->add($cancelarElement, [
'priority' => -100,
]);
return $form;
} | [
"public",
"function",
"getForm",
"(",
"$",
"documentClass",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"documentClass",
")",
"{",
"$",
"documentClass",
"=",
"$",
"this",
"->",
"getDocumentClass",
"(",
")",
";",
"}",
"$",
"builder",
"=",
"new",
"AnnotationBuilder",
"(",
")",
";",
"$",
"form",
"=",
"$",
"builder",
"->",
"createForm",
"(",
"$",
"documentClass",
")",
";",
"$",
"hasDocument",
"=",
"false",
";",
"foreach",
"(",
"$",
"form",
"->",
"getElements",
"(",
")",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"element",
",",
"'setObjectManager'",
")",
")",
"{",
"$",
"element",
"->",
"setObjectManager",
"(",
"$",
"this",
"->",
"getDocumentManager",
"(",
")",
")",
";",
"$",
"hasDocument",
"=",
"true",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"element",
",",
"'getProxy'",
")",
")",
"{",
"$",
"proxy",
"=",
"$",
"element",
"->",
"getProxy",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"proxy",
",",
"'setObjectManager'",
")",
")",
"{",
"$",
"proxy",
"->",
"setObjectManager",
"(",
"$",
"this",
"->",
"getDocumentManager",
"(",
")",
")",
";",
"$",
"hasDocument",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"hasDocument",
")",
"{",
"$",
"hydrator",
"=",
"new",
"DoctrineObjectHydrator",
"(",
"$",
"this",
"->",
"getDocumentManager",
"(",
")",
",",
"$",
"documentClass",
")",
";",
"$",
"form",
"->",
"setHydrator",
"(",
"$",
"hydrator",
")",
";",
"}",
"else",
"{",
"$",
"form",
"->",
"setHydrator",
"(",
"new",
"ClassMethods",
"(",
")",
")",
";",
"}",
"$",
"form",
"->",
"add",
"(",
"[",
"'type'",
"=>",
"'Zend\\Form\\Element\\Csrf'",
",",
"'name'",
"=>",
"'csrf'",
",",
"'attributes'",
"=>",
"[",
"'id'",
"=>",
"'csrf'",
",",
"]",
",",
"]",
")",
";",
"$",
"submitElement",
"=",
"new",
"\\",
"Zend",
"\\",
"Form",
"\\",
"Element",
"\\",
"Button",
"(",
"'submit'",
")",
";",
"$",
"submitElement",
"->",
"setAttributes",
"(",
"[",
"'type'",
"=>",
"'submit'",
",",
"'class'",
"=>",
"'btn btn-primary'",
",",
"]",
")",
";",
"$",
"submitElement",
"->",
"setLabel",
"(",
"'Salvar'",
")",
";",
"$",
"form",
"->",
"add",
"(",
"$",
"submitElement",
",",
"[",
"'priority'",
"=>",
"-",
"100",
",",
"]",
")",
";",
"$",
"cancelarElement",
"=",
"new",
"\\",
"Zend",
"\\",
"Form",
"\\",
"Element",
"\\",
"Button",
"(",
"'cancelar'",
")",
";",
"$",
"cancelarElement",
"->",
"setAttributes",
"(",
"[",
"'type'",
"=>",
"'button'",
",",
"'class'",
"=>",
"'btn btn-default'",
",",
"'onclick'",
"=>",
"'top.location=\\''",
".",
"$",
"this",
"->",
"url",
"(",
")",
"->",
"fromRoute",
"(",
"$",
"this",
"->",
"getActionRoute",
"(",
"'list'",
")",
")",
".",
"'\\''",
",",
"]",
")",
";",
"$",
"cancelarElement",
"->",
"setLabel",
"(",
"'Cancelar'",
")",
";",
"$",
"form",
"->",
"add",
"(",
"$",
"cancelarElement",
",",
"[",
"'priority'",
"=>",
"-",
"100",
",",
"]",
")",
";",
"return",
"$",
"form",
";",
"}"
]
| Retorna a form para o cadastro do documento. | [
"Retorna",
"a",
"form",
"para",
"o",
"cadastro",
"do",
"documento",
"."
]
| 90e18a53d29c1bd841c149dca43aa365eecc656d | https://github.com/Lansoweb/LosBase/blob/90e18a53d29c1bd841c149dca43aa365eecc656d/src/LosBase/Controller/ODM/AbstractCrudController.php#L135-L196 |
18,792 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerPeer.php | BaseCustomerPeer.doSelectJoinCountry | public static function doSelectJoinCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(CustomerPeer::DATABASE_NAME);
}
CustomerPeer::addSelectColumns($criteria);
$startcol = CustomerPeer::NUM_HYDRATE_COLUMNS;
CountryPeer::addSelectColumns($criteria);
$criteria->addJoin(CustomerPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = CustomerPeer::getOMClass();
$obj1 = new $cls();
$obj1->hydrate($row);
CustomerPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
$key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
$obj2 = CountryPeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = CountryPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
CountryPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
// Add the $obj1 (Customer) to $obj2 (Country)
$obj2->addCustomer($obj1);
} // if joined row was not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
} | php | public static function doSelectJoinCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(CustomerPeer::DATABASE_NAME);
}
CustomerPeer::addSelectColumns($criteria);
$startcol = CustomerPeer::NUM_HYDRATE_COLUMNS;
CountryPeer::addSelectColumns($criteria);
$criteria->addJoin(CustomerPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = CustomerPeer::getOMClass();
$obj1 = new $cls();
$obj1->hydrate($row);
CustomerPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
$key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
$obj2 = CountryPeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = CountryPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
CountryPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
// Add the $obj1 (Customer) to $obj2 (Country)
$obj2->addCustomer($obj1);
} // if joined row was not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
} | [
"public",
"static",
"function",
"doSelectJoinCountry",
"(",
"Criteria",
"$",
"criteria",
",",
"$",
"con",
"=",
"null",
",",
"$",
"join_behavior",
"=",
"Criteria",
"::",
"LEFT_JOIN",
")",
"{",
"$",
"criteria",
"=",
"clone",
"$",
"criteria",
";",
"// Set the correct dbName if it has not been overridden",
"if",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
"==",
"Propel",
"::",
"getDefaultDB",
"(",
")",
")",
"{",
"$",
"criteria",
"->",
"setDbName",
"(",
"CustomerPeer",
"::",
"DATABASE_NAME",
")",
";",
"}",
"CustomerPeer",
"::",
"addSelectColumns",
"(",
"$",
"criteria",
")",
";",
"$",
"startcol",
"=",
"CustomerPeer",
"::",
"NUM_HYDRATE_COLUMNS",
";",
"CountryPeer",
"::",
"addSelectColumns",
"(",
"$",
"criteria",
")",
";",
"$",
"criteria",
"->",
"addJoin",
"(",
"CustomerPeer",
"::",
"COUNTRY_ID",
",",
"CountryPeer",
"::",
"ID",
",",
"$",
"join_behavior",
")",
";",
"$",
"stmt",
"=",
"BasePeer",
"::",
"doSelect",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"$",
"results",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_NUM",
")",
")",
"{",
"$",
"key1",
"=",
"CustomerPeer",
"::",
"getPrimaryKeyHashFromRow",
"(",
"$",
"row",
",",
"0",
")",
";",
"if",
"(",
"null",
"!==",
"(",
"$",
"obj1",
"=",
"CustomerPeer",
"::",
"getInstanceFromPool",
"(",
"$",
"key1",
")",
")",
")",
"{",
"// We no longer rehydrate the object, since this can cause data loss.",
"// See http://www.propelorm.org/ticket/509",
"// $obj1->hydrate($row, 0, true); // rehydrate",
"}",
"else",
"{",
"$",
"cls",
"=",
"CustomerPeer",
"::",
"getOMClass",
"(",
")",
";",
"$",
"obj1",
"=",
"new",
"$",
"cls",
"(",
")",
";",
"$",
"obj1",
"->",
"hydrate",
"(",
"$",
"row",
")",
";",
"CustomerPeer",
"::",
"addInstanceToPool",
"(",
"$",
"obj1",
",",
"$",
"key1",
")",
";",
"}",
"// if $obj1 already loaded",
"$",
"key2",
"=",
"CountryPeer",
"::",
"getPrimaryKeyHashFromRow",
"(",
"$",
"row",
",",
"$",
"startcol",
")",
";",
"if",
"(",
"$",
"key2",
"!==",
"null",
")",
"{",
"$",
"obj2",
"=",
"CountryPeer",
"::",
"getInstanceFromPool",
"(",
"$",
"key2",
")",
";",
"if",
"(",
"!",
"$",
"obj2",
")",
"{",
"$",
"cls",
"=",
"CountryPeer",
"::",
"getOMClass",
"(",
")",
";",
"$",
"obj2",
"=",
"new",
"$",
"cls",
"(",
")",
";",
"$",
"obj2",
"->",
"hydrate",
"(",
"$",
"row",
",",
"$",
"startcol",
")",
";",
"CountryPeer",
"::",
"addInstanceToPool",
"(",
"$",
"obj2",
",",
"$",
"key2",
")",
";",
"}",
"// if obj2 already loaded",
"// Add the $obj1 (Customer) to $obj2 (Country)",
"$",
"obj2",
"->",
"addCustomer",
"(",
"$",
"obj1",
")",
";",
"}",
"// if joined row was not null",
"$",
"results",
"[",
"]",
"=",
"$",
"obj1",
";",
"}",
"$",
"stmt",
"->",
"closeCursor",
"(",
")",
";",
"return",
"$",
"results",
";",
"}"
]
| Selects a collection of Customer objects pre-filled with their Country objects.
@param Criteria $criteria
@param PropelPDO $con
@param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@return array Array of Customer objects.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Selects",
"a",
"collection",
"of",
"Customer",
"objects",
"pre",
"-",
"filled",
"with",
"their",
"Country",
"objects",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerPeer.php#L589-L644 |
18,793 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerPeer.php | BaseCustomerPeer.doDeleteAll | public static function doDeleteAll(PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += CustomerPeer::doOnDeleteCascade(new Criteria(CustomerPeer::DATABASE_NAME), $con);
CustomerPeer::doOnDeleteSetNull(new Criteria(CustomerPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(CustomerPeer::TABLE_NAME, $con, CustomerPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CustomerPeer::clearInstancePool();
CustomerPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | php | public static function doDeleteAll(PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += CustomerPeer::doOnDeleteCascade(new Criteria(CustomerPeer::DATABASE_NAME), $con);
CustomerPeer::doOnDeleteSetNull(new Criteria(CustomerPeer::DATABASE_NAME), $con);
$affectedRows += BasePeer::doDeleteAll(CustomerPeer::TABLE_NAME, $con, CustomerPeer::DATABASE_NAME);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CustomerPeer::clearInstancePool();
CustomerPeer::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | [
"public",
"static",
"function",
"doDeleteAll",
"(",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"CustomerPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"$",
"affectedRows",
"=",
"0",
";",
"// initialize var to track total num of affected rows",
"try",
"{",
"// use transaction because $criteria could contain info",
"// for more than one table or we could emulating ON DELETE CASCADE, etc.",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"$",
"affectedRows",
"+=",
"CustomerPeer",
"::",
"doOnDeleteCascade",
"(",
"new",
"Criteria",
"(",
"CustomerPeer",
"::",
"DATABASE_NAME",
")",
",",
"$",
"con",
")",
";",
"CustomerPeer",
"::",
"doOnDeleteSetNull",
"(",
"new",
"Criteria",
"(",
"CustomerPeer",
"::",
"DATABASE_NAME",
")",
",",
"$",
"con",
")",
";",
"$",
"affectedRows",
"+=",
"BasePeer",
"::",
"doDeleteAll",
"(",
"CustomerPeer",
"::",
"TABLE_NAME",
",",
"$",
"con",
",",
"CustomerPeer",
"::",
"DATABASE_NAME",
")",
";",
"// Because this db requires some delete cascade/set null emulation, we have to",
"// clear the cached instance *after* the emulation has happened (since",
"// instances get re-added by the select statement contained therein).",
"CustomerPeer",
"::",
"clearInstancePool",
"(",
")",
";",
"CustomerPeer",
"::",
"clearRelatedInstancePool",
"(",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"affectedRows",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollBack",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
]
| Deletes all rows from the customer table.
@param PropelPDO $con the connection to use
@return int The number of affected rows (if supported by underlying database driver).
@throws PropelException | [
"Deletes",
"all",
"rows",
"from",
"the",
"customer",
"table",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerPeer.php#L889-L914 |
18,794 | whisller/IrcBotBundle | EventListener/Irc/ServerRequestListener.php | ServerRequestListener.processStringData | private function processStringData(DataFromServerEvent $event)
{
$regex = "/^(?:[:@]([^\\s]+) )?([^\\s]+)(?: ((?:[^:\\s][^\\s]* ?)*))?(?: ?:(.*))?$/"; // @author Joshua Lückers (http://joshualuckers.nl/2010/01/10/regular-expression-to-match-raw-irc-messages/)
preg_match($regex, $event->getData(), $matches);
if (isset($matches[2]) && ('' !== trim($matches[2]))) {
$this->dispatcher->dispatch('whisnet_irc_bot.irc_command_'.$matches[2], new IrcCommandFoundEvent($matches));
}
} | php | private function processStringData(DataFromServerEvent $event)
{
$regex = "/^(?:[:@]([^\\s]+) )?([^\\s]+)(?: ((?:[^:\\s][^\\s]* ?)*))?(?: ?:(.*))?$/"; // @author Joshua Lückers (http://joshualuckers.nl/2010/01/10/regular-expression-to-match-raw-irc-messages/)
preg_match($regex, $event->getData(), $matches);
if (isset($matches[2]) && ('' !== trim($matches[2]))) {
$this->dispatcher->dispatch('whisnet_irc_bot.irc_command_'.$matches[2], new IrcCommandFoundEvent($matches));
}
} | [
"private",
"function",
"processStringData",
"(",
"DataFromServerEvent",
"$",
"event",
")",
"{",
"$",
"regex",
"=",
"\"/^(?:[:@]([^\\\\s]+) )?([^\\\\s]+)(?: ((?:[^:\\\\s][^\\\\s]* ?)*))?(?: ?:(.*))?$/\"",
";",
"// @author Joshua Lückers (http://joshualuckers.nl/2010/01/10/regular-expression-to-match-raw-irc-messages/)",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"event",
"->",
"getData",
"(",
")",
",",
"$",
"matches",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"&&",
"(",
"''",
"!==",
"trim",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
")",
")",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"'whisnet_irc_bot.irc_command_'",
".",
"$",
"matches",
"[",
"2",
"]",
",",
"new",
"IrcCommandFoundEvent",
"(",
"$",
"matches",
")",
")",
";",
"}",
"}"
]
| Process string response from server.
@param DataFromServerEvent $event | [
"Process",
"string",
"response",
"from",
"server",
"."
]
| d8bcafc1599cbbc7756b0a59f51ee988a2de0f2e | https://github.com/whisller/IrcBotBundle/blob/d8bcafc1599cbbc7756b0a59f51ee988a2de0f2e/EventListener/Irc/ServerRequestListener.php#L45-L53 |
18,795 | EvanDotPro/EdpGithub | src/EdpGithub/Listener/Auth/HttpToken.php | HttpToken.preSend | public function preSend(Event $e)
{
$validator = new NotEmpty();
if (!isset($this->options['tokenOrLogin'])
|| !$validator->isValid($this->options['tokenOrLogin'])
) {
throw new Exception\InvalidArgumentException('You need to set OAuth token!');
}
/* @var Http\Request $request */
$request = $e->getTarget();
$headers = $request->getHeaders();
$params = array(
'Authorization' => 'token ' . $this->options['tokenOrLogin'],
);
$headers->addHeaders($params);
} | php | public function preSend(Event $e)
{
$validator = new NotEmpty();
if (!isset($this->options['tokenOrLogin'])
|| !$validator->isValid($this->options['tokenOrLogin'])
) {
throw new Exception\InvalidArgumentException('You need to set OAuth token!');
}
/* @var Http\Request $request */
$request = $e->getTarget();
$headers = $request->getHeaders();
$params = array(
'Authorization' => 'token ' . $this->options['tokenOrLogin'],
);
$headers->addHeaders($params);
} | [
"public",
"function",
"preSend",
"(",
"Event",
"$",
"e",
")",
"{",
"$",
"validator",
"=",
"new",
"NotEmpty",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'tokenOrLogin'",
"]",
")",
"||",
"!",
"$",
"validator",
"->",
"isValid",
"(",
"$",
"this",
"->",
"options",
"[",
"'tokenOrLogin'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'You need to set OAuth token!'",
")",
";",
"}",
"/* @var Http\\Request $request */",
"$",
"request",
"=",
"$",
"e",
"->",
"getTarget",
"(",
")",
";",
"$",
"headers",
"=",
"$",
"request",
"->",
"getHeaders",
"(",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'Authorization'",
"=>",
"'token '",
".",
"$",
"this",
"->",
"options",
"[",
"'tokenOrLogin'",
"]",
",",
")",
";",
"$",
"headers",
"->",
"addHeaders",
"(",
"$",
"params",
")",
";",
"}"
]
| Add Authorization Token to Header
@throws Exception\InvalidArgumentException | [
"Add",
"Authorization",
"Token",
"to",
"Header"
]
| 51f3e33e02edbef011103e3c2c1629d46af011a3 | https://github.com/EvanDotPro/EdpGithub/blob/51f3e33e02edbef011103e3c2c1629d46af011a3/src/EdpGithub/Listener/Auth/HttpToken.php#L17-L35 |
18,796 | ClanCats/Core | src/console/migrator.php | migrator.action_create | public function action_create( $params )
{
$name = array_shift( $params );
$file = \DB\Migrator::path( $name );
\CCFile::write( $file, "# ---> up\n\n\n\n# ---> down\n\n" );
} | php | public function action_create( $params )
{
$name = array_shift( $params );
$file = \DB\Migrator::path( $name );
\CCFile::write( $file, "# ---> up\n\n\n\n# ---> down\n\n" );
} | [
"public",
"function",
"action_create",
"(",
"$",
"params",
")",
"{",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"params",
")",
";",
"$",
"file",
"=",
"\\",
"DB",
"\\",
"Migrator",
"::",
"path",
"(",
"$",
"name",
")",
";",
"\\",
"CCFile",
"::",
"write",
"(",
"$",
"file",
",",
"\"# ---> up\\n\\n\\n\\n# ---> down\\n\\n\"",
")",
";",
"}"
]
| Create new migration
@param array $params
@return void | [
"Create",
"new",
"migration"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/migrator.php#L66-L73 |
18,797 | PortaText/php-sdk | src/PortaText/Command/Api/Sms.php | Sms.schedule | public function schedule($type, $details)
{
$schedule = array();
$schedule[$type] = $details;
return $this->setArgument("schedule", $schedule);
} | php | public function schedule($type, $details)
{
$schedule = array();
$schedule[$type] = $details;
return $this->setArgument("schedule", $schedule);
} | [
"public",
"function",
"schedule",
"(",
"$",
"type",
",",
"$",
"details",
")",
"{",
"$",
"schedule",
"=",
"array",
"(",
")",
";",
"$",
"schedule",
"[",
"$",
"type",
"]",
"=",
"$",
"details",
";",
"return",
"$",
"this",
"->",
"setArgument",
"(",
"\"schedule\"",
",",
"$",
"schedule",
")",
";",
"}"
]
| Schedule this message
@param integer $type Schedule type.
@param array $details Schedule configuration.
@return PortaText\Command\ICommand
@see https://github.com/PortaText/docs/wiki/REST-API#schedules | [
"Schedule",
"this",
"message"
]
| dbe04ef043db5b251953f9de57aa4d0f1785dfcc | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Sms.php#L140-L145 |
18,798 | yuncms/framework | src/helpers/SearchHelper.php | SearchHelper._getCharMap | private static function _getCharMap(): array
{
// Keep local copy
static $map = [];
if (empty($map)) {
// This will replace accented chars with non-accented chars
foreach (StringHelper::asciiCharMap() as $asciiChar => $charsArray) {
foreach ($charsArray as $char) {
$map[$char] = $asciiChar;
}
}
// Replace punctuation with a space
foreach (self::_getPunctuation() as $value) {
$map[$value] = ' ';
}
}
// Return the char map
return $map;
} | php | private static function _getCharMap(): array
{
// Keep local copy
static $map = [];
if (empty($map)) {
// This will replace accented chars with non-accented chars
foreach (StringHelper::asciiCharMap() as $asciiChar => $charsArray) {
foreach ($charsArray as $char) {
$map[$char] = $asciiChar;
}
}
// Replace punctuation with a space
foreach (self::_getPunctuation() as $value) {
$map[$value] = ' ';
}
}
// Return the char map
return $map;
} | [
"private",
"static",
"function",
"_getCharMap",
"(",
")",
":",
"array",
"{",
"// Keep local copy",
"static",
"$",
"map",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"map",
")",
")",
"{",
"// This will replace accented chars with non-accented chars",
"foreach",
"(",
"StringHelper",
"::",
"asciiCharMap",
"(",
")",
"as",
"$",
"asciiChar",
"=>",
"$",
"charsArray",
")",
"{",
"foreach",
"(",
"$",
"charsArray",
"as",
"$",
"char",
")",
"{",
"$",
"map",
"[",
"$",
"char",
"]",
"=",
"$",
"asciiChar",
";",
"}",
"}",
"// Replace punctuation with a space",
"foreach",
"(",
"self",
"::",
"_getPunctuation",
"(",
")",
"as",
"$",
"value",
")",
"{",
"$",
"map",
"[",
"$",
"value",
"]",
"=",
"' '",
";",
"}",
"}",
"// Return the char map",
"return",
"$",
"map",
";",
"}"
]
| Get array of chars to be used for conversion.
@return array | [
"Get",
"array",
"of",
"chars",
"to",
"be",
"used",
"for",
"conversion",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/SearchHelper.php#L71-L92 |
18,799 | gibilogic/crud-bundle | Utility/FlashableTrait.php | FlashableTrait.addUserFlash | protected function addUserFlash(SessionInterface $session, $type, $message)
{
$session->getFlashBag()->add($type, $message);
} | php | protected function addUserFlash(SessionInterface $session, $type, $message)
{
$session->getFlashBag()->add($type, $message);
} | [
"protected",
"function",
"addUserFlash",
"(",
"SessionInterface",
"$",
"session",
",",
"$",
"type",
",",
"$",
"message",
")",
"{",
"$",
"session",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"$",
"type",
",",
"$",
"message",
")",
";",
"}"
]
| Adds a flash message to the given session.
@param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
@param string $type
@param string $message | [
"Adds",
"a",
"flash",
"message",
"to",
"the",
"given",
"session",
"."
]
| 847e7c7bee4016026411eb230154f24986335633 | https://github.com/gibilogic/crud-bundle/blob/847e7c7bee4016026411eb230154f24986335633/Utility/FlashableTrait.php#L64-L67 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.